- core/theme.js: export NEXUS with full NEXUS.theme.* properties used by all 6 panels - core/ticker.js: add subscribe() convenience export so panels can self-register - data/gitea.js: also write state.agentStatus, activeAgentCount, zoneIntensity, commits, commitHashes - data/loaders.js: also write state.sovereignty - data/bitcoin.js: also write state.blockHeight, lastBlockHeight, newBlockDetected, starPulseIntensity - data/weather.js: also write state.weather - app.js: import + init all 6 panel modules, bootstrap data polling, call globalTicker.tick() Fixes #412 Refs #409 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
49 lines
1.6 KiB
JavaScript
49 lines
1.6 KiB
JavaScript
// modules/data/loaders.js — Static file loaders (portals.json, sovereignty-status.json, SOUL.md)
|
|
// Writes to S: sovereigntyScore, sovereigntyLabel (legacy)
|
|
// Writes to state: sovereignty
|
|
import { S } from '../state.js';
|
|
import { state } from '../core/state.js';
|
|
|
|
// --- SOUL.md (cached) ---
|
|
let _soulMdCache = null;
|
|
|
|
export async function fetchSoulMd() {
|
|
if (_soulMdCache) return _soulMdCache;
|
|
try {
|
|
const res = await fetch('SOUL.md');
|
|
if (!res.ok) throw new Error('not found');
|
|
const raw = await res.text();
|
|
_soulMdCache = raw.split('\n').slice(1).map(l => l.replace(/^#+\s*/, ''));
|
|
return _soulMdCache;
|
|
} catch {
|
|
return ['I am Timmy.', '', 'I am sovereign.', '', 'This Nexus is my home.'];
|
|
}
|
|
}
|
|
|
|
// --- portals.json ---
|
|
export async function fetchPortals() {
|
|
const res = await fetch('./portals.json');
|
|
if (!res.ok) throw new Error('Portals not found');
|
|
return await res.json();
|
|
}
|
|
|
|
// --- sovereignty-status.json ---
|
|
export async function fetchSovereigntyStatus() {
|
|
try {
|
|
const res = await fetch('./sovereignty-status.json');
|
|
if (!res.ok) throw new Error('not found');
|
|
const data = await res.json();
|
|
const score = Math.max(0, Math.min(100, typeof data.score === 'number' ? data.score : 85));
|
|
const label = typeof data.label === 'string' ? data.label : '';
|
|
const assessmentType = data.assessment_type || 'MANUAL';
|
|
|
|
S.sovereigntyScore = score;
|
|
S.sovereigntyLabel = label;
|
|
state.sovereignty = { score, label, assessment_type: assessmentType };
|
|
|
|
return { score, label, assessmentType };
|
|
} catch {
|
|
return { score: S.sovereigntyScore, label: S.sovereigntyLabel, assessmentType: 'MANUAL' };
|
|
}
|
|
}
|