Real-time dashboard for monitoring global news, markets, and geopolitical events
TypeScript
Fix code review issues and improve reactivity
Sean Thielen-Esparza6bec818e5711
diff --git a/.prettierignore b/.prettierignoreindex e70f985..cc0dbed 100644--- a/.prettierignore+++ b/.prettierignore@@ -11,3 +11,13 @@ distjs/styles.cssindex.html+static/js/+static/legacy.html+workers/++# Test utility files+test-modules.html+test-node.mjs++# IDE settings+.claude/diff --git a/eslint.config.js b/eslint.config.jsindex 0d8ec8b..1112689 100644--- a/eslint.config.js+++ b/eslint.config.js@@ -14,7 +14,9 @@ export default tseslint.config(languageOptions: {globals: {...globals.browser,- ...globals.node+ ...globals.node,+ // GeoJSON types are globally available in TypeScript projects with @types/geojson+ GeoJSON: 'readonly'}}},@@ -31,9 +33,13 @@ export default tseslint.config('build/','.svelte-kit/','dist/',- // Legacy files until migrated+ // Legacy files - not part of SvelteKit migration'js/',- 'workers/'+ 'workers/',+ 'static/js/',+ 'static/legacy.html',+ // Test utility files+ 'test-node.mjs']});diff --git a/package-lock.json b/package-lock.jsonindex e319048..5e6c42c 100644--- a/package-lock.json+++ b/package-lock.json@@ -35,6 +35,7 @@"svelte-check": "^4.0.0","tailwindcss": "^3.4.0","typescript": "^5.0.0",+ "typescript-eslint": "^8.52.0","vite": "^6.0.0","vitest": "^2.0.0"}@@ -2309,6 +2310,19 @@"node": ">= 8"}},+ "node_modules/anymatch/node_modules/picomatch": {+ "version": "2.3.1",+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",+ "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=8.6"+ },+ "funding": {+ "url": "https://github.com/sponsors/jonschlinkert"+ }+ },"node_modules/arg": {"version": "5.0.2","resolved": "https://registry.npmjs.org/arg/-/arg-5.0.2.tgz",@@ -4484,6 +4498,19 @@"node": ">=8.6"}},+ "node_modules/micromatch/node_modules/picomatch": {+ "version": "2.3.1",+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",+ "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=8.6"+ },+ "funding": {+ "url": "https://github.com/sponsors/jonschlinkert"+ }+ },"node_modules/mime-db": {"version": "1.52.0","resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",@@ -4760,13 +4787,13 @@"license": "ISC"},"node_modules/picomatch": {- "version": "2.3.1",- "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",- "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",+ "version": "4.0.3",+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz",+ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==","dev": true,"license": "MIT","engines": {- "node": ">=8.6"+ "node": ">=12"},"funding": {"url": "https://github.com/sponsors/jonschlinkert"@@ -5698,6 +5725,19 @@"url": "https://github.com/sponsors/antonk52"}},+ "node_modules/tailwindcss/node_modules/picomatch": {+ "version": "2.3.1",+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",+ "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=8.6"+ },+ "funding": {+ "url": "https://github.com/sponsors/jonschlinkert"+ }+ },"node_modules/tailwindcss/node_modules/postcss-load-config": {"version": "6.0.1","resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-6.0.1.tgz",@@ -5808,19 +5848,6 @@"url": "https://github.com/sponsors/SuperchupuDev"}},- "node_modules/tinyglobby/node_modules/picomatch": {- "version": "4.0.3",- "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz",- "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",- "dev": true,- "license": "MIT",- "engines": {- "node": ">=12"- },- "funding": {- "url": "https://github.com/sponsors/jonschlinkert"- }- },"node_modules/tinypool": {"version": "1.1.1","resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.1.1.tgz",@@ -5987,6 +6014,30 @@"node": ">=14.17"}},+ "node_modules/typescript-eslint": {+ "version": "8.52.0",+ "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.52.0.tgz",+ "integrity": "sha512-atlQQJ2YkO4pfTVQmQ+wvYQwexPDOIgo+RaVcD7gHgzy/IQA+XTyuxNM9M9TVXvttkF7koBHmcwisKdOAf2EcA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@typescript-eslint/eslint-plugin": "8.52.0",+ "@typescript-eslint/parser": "8.52.0",+ "@typescript-eslint/typescript-estree": "8.52.0",+ "@typescript-eslint/utils": "8.52.0"+ },+ "engines": {+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/typescript-eslint"+ },+ "peerDependencies": {+ "eslint": "^8.57.0 || ^9.0.0",+ "typescript": ">=4.8.4 <6.0.0"+ }+ },"node_modules/undici-types": {"version": "6.21.0","resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",@@ -6660,19 +6711,6 @@"node": "^8.16.0 || ^10.6.0 || >=11.0.0"}},- "node_modules/vite/node_modules/picomatch": {- "version": "4.0.3",- "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz",- "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",- "dev": true,- "license": "MIT",- "engines": {- "node": ">=12"- },- "funding": {- "url": "https://github.com/sponsors/jonschlinkert"- }- },"node_modules/vitefu": {"version": "1.1.1","resolved": "https://registry.npmjs.org/vitefu/-/vitefu-1.1.1.tgz",diff --git a/package.json b/package.jsonindex c8a51a2..e3452fd 100644--- a/package.json+++ b/package.json@@ -1,49 +1,50 @@{- "name": "situation-monitor",- "version": "2.0.0",- "private": true,- "type": "module",- "scripts": {- "dev": "vite dev",- "build": "vite build",- "preview": "vite preview",- "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",- "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",- "test": "vitest",- "test:unit": "vitest run",- "test:e2e": "playwright test",- "lint": "eslint . && prettier --check .",- "format": "prettier --write ."- },- "devDependencies": {- "@playwright/test": "^1.49.0",- "@sveltejs/adapter-static": "^3.0.0",- "@sveltejs/kit": "^2.0.0",- "@sveltejs/vite-plugin-svelte": "^5.0.0",- "@testing-library/svelte": "^5.0.0",- "@types/d3": "^7.4.0",- "@types/node": "^22.0.0",- "@types/topojson-client": "^3.1.0",- "@typescript-eslint/eslint-plugin": "^8.0.0",- "@typescript-eslint/parser": "^8.0.0",- "autoprefixer": "^10.4.0",- "eslint": "^9.0.0",- "eslint-config-prettier": "^9.0.0",- "eslint-plugin-svelte": "^2.0.0",- "globals": "^15.0.0",- "jsdom": "^25.0.0",- "postcss": "^8.4.0",- "prettier": "^3.0.0",- "prettier-plugin-svelte": "^3.0.0",- "svelte": "^5.0.0",- "svelte-check": "^4.0.0",- "tailwindcss": "^3.4.0",- "typescript": "^5.0.0",- "vite": "^6.0.0",- "vitest": "^2.0.0"- },- "dependencies": {- "d3": "^7.9.0",- "topojson-client": "^3.1.0"- }+ "name": "situation-monitor",+ "version": "2.0.0",+ "private": true,+ "type": "module",+ "scripts": {+ "dev": "vite dev",+ "build": "vite build",+ "preview": "vite preview",+ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",+ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",+ "test": "vitest",+ "test:unit": "vitest run",+ "test:e2e": "playwright test",+ "lint": "eslint . && prettier --check .",+ "format": "prettier --write ."+ },+ "devDependencies": {+ "@playwright/test": "^1.49.0",+ "@sveltejs/adapter-static": "^3.0.0",+ "@sveltejs/kit": "^2.0.0",+ "@sveltejs/vite-plugin-svelte": "^5.0.0",+ "@testing-library/svelte": "^5.0.0",+ "@types/d3": "^7.4.0",+ "@types/node": "^22.0.0",+ "@types/topojson-client": "^3.1.0",+ "@typescript-eslint/eslint-plugin": "^8.0.0",+ "@typescript-eslint/parser": "^8.0.0",+ "autoprefixer": "^10.4.0",+ "eslint": "^9.0.0",+ "eslint-config-prettier": "^9.0.0",+ "eslint-plugin-svelte": "^2.0.0",+ "globals": "^15.0.0",+ "jsdom": "^25.0.0",+ "postcss": "^8.4.0",+ "prettier": "^3.0.0",+ "prettier-plugin-svelte": "^3.0.0",+ "svelte": "^5.0.0",+ "svelte-check": "^4.0.0",+ "tailwindcss": "^3.4.0",+ "typescript": "^5.0.0",+ "typescript-eslint": "^8.52.0",+ "vite": "^6.0.0",+ "vitest": "^2.0.0"+ },+ "dependencies": {+ "d3": "^7.9.0",+ "topojson-client": "^3.1.0"+ }}diff --git a/src/lib/analysis/correlation.test.ts b/src/lib/analysis/correlation.test.tsindex 2072e44..625ad56 100644--- a/src/lib/analysis/correlation.test.ts+++ b/src/lib/analysis/correlation.test.ts@@ -3,11 +3,7 @@*/import { describe, it, expect, beforeEach } from 'vitest';-import {- analyzeCorrelations,- getCorrelationSummary,- clearCorrelationHistory-} from './correlation';+import { analyzeCorrelations, getCorrelationSummary, clearCorrelationHistory } from './correlation';import type { NewsItem } from '$lib/types';describe('Correlation Engine', () => {@@ -22,9 +18,30 @@ describe('Correlation Engine', () => {it('should detect emerging patterns', () => {const news: NewsItem[] = [- { id: '1', title: 'Ukraine announces new policy', source: 'BBC', link: 'a', timestamp: Date.now(), category: 'politics' },- { id: '2', title: 'Ukraine military update', source: 'CNN', link: 'b', timestamp: Date.now(), category: 'politics' },- { id: '3', title: 'Zelensky addresses nation', source: 'NYT', link: 'c', timestamp: Date.now(), category: 'politics' },+ {+ id: '1',+ title: 'Ukraine announces new policy',+ source: 'BBC',+ link: 'a',+ timestamp: Date.now(),+ category: 'politics'+ },+ {+ id: '2',+ title: 'Ukraine military update',+ source: 'CNN',+ link: 'b',+ timestamp: Date.now(),+ category: 'politics'+ },+ {+ id: '3',+ title: 'Zelensky addresses nation',+ source: 'NYT',+ link: 'c',+ timestamp: Date.now(),+ category: 'politics'+ }];const results = analyzeCorrelations(news);@@ -32,7 +49,7 @@ describe('Correlation Engine', () => {expect(results).not.toBeNull();expect(results!.emergingPatterns.length).toBeGreaterThan(0);- const ukrainePattern = results!.emergingPatterns.find(p => p.id === 'russia-ukraine');+ const ukrainePattern = results!.emergingPatterns.find((p) => p.id === 'russia-ukraine');expect(ukrainePattern).toBeDefined();expect(ukrainePattern!.count).toBeGreaterThanOrEqual(3);expect(ukrainePattern!.level).toBe('emerging');@@ -50,21 +67,49 @@ describe('Correlation Engine', () => {}));const results = analyzeCorrelations(news);- const ukrainePattern = results?.emergingPatterns.find(p => p.id === 'russia-ukraine');+ const ukrainePattern = results?.emergingPatterns.find((p) => p.id === 'russia-ukraine');expect(ukrainePattern?.level).toBe('high');});it('should track cross-source correlations', () => {const news: NewsItem[] = [- { id: '1', title: 'Tariff news today', source: 'BBC', link: 'a', timestamp: Date.now(), category: 'finance' },- { id: '2', title: 'Trade war escalates', source: 'CNN', link: 'b', timestamp: Date.now(), category: 'finance' },- { id: '3', title: 'Import tax increases', source: 'NYT', link: 'c', timestamp: Date.now(), category: 'finance' },- { id: '4', title: 'Customs duty update', source: 'WSJ', link: 'd', timestamp: Date.now(), category: 'finance' },+ {+ id: '1',+ title: 'Tariff news today',+ source: 'BBC',+ link: 'a',+ timestamp: Date.now(),+ category: 'finance'+ },+ {+ id: '2',+ title: 'Trade war escalates',+ source: 'CNN',+ link: 'b',+ timestamp: Date.now(),+ category: 'finance'+ },+ {+ id: '3',+ title: 'Import tax increases',+ source: 'NYT',+ link: 'c',+ timestamp: Date.now(),+ category: 'finance'+ },+ {+ id: '4',+ title: 'Customs duty update',+ source: 'WSJ',+ link: 'd',+ timestamp: Date.now(),+ category: 'finance'+ }];const results = analyzeCorrelations(news);- const tariffCorrelation = results?.crossSourceCorrelations.find(c => c.id === 'tariffs');+ const tariffCorrelation = results?.crossSourceCorrelations.find((c) => c.id === 'tariffs');expect(tariffCorrelation).toBeDefined();expect(tariffCorrelation!.sourceCount).toBe(4);@@ -86,7 +131,7 @@ describe('Correlation Engine', () => {expect(results?.predictiveSignals.length).toBeGreaterThan(0);- const tariffSignal = results?.predictiveSignals.find(s => s.id === 'tariffs');+ const tariffSignal = results?.predictiveSignals.find((s) => s.id === 'tariffs');if (tariffSignal) {expect(tariffSignal.prediction).toContain('volatility');}@@ -94,13 +139,34 @@ describe('Correlation Engine', () => {it('should collect headlines for patterns', () => {const news: NewsItem[] = [- { id: '1', title: 'Gaza conflict escalates', source: 'BBC', link: 'https://bbc.com/1', timestamp: Date.now(), category: 'politics' },- { id: '2', title: 'Hamas negotiations', source: 'CNN', link: 'https://cnn.com/2', timestamp: Date.now(), category: 'politics' },- { id: '3', title: 'Israel Gaza update', source: 'NYT', link: 'https://nyt.com/3', timestamp: Date.now(), category: 'politics' },+ {+ id: '1',+ title: 'Gaza conflict escalates',+ source: 'BBC',+ link: 'https://bbc.com/1',+ timestamp: Date.now(),+ category: 'politics'+ },+ {+ id: '2',+ title: 'Hamas negotiations',+ source: 'CNN',+ link: 'https://cnn.com/2',+ timestamp: Date.now(),+ category: 'politics'+ },+ {+ id: '3',+ title: 'Israel Gaza update',+ source: 'NYT',+ link: 'https://nyt.com/3',+ timestamp: Date.now(),+ category: 'politics'+ }];const results = analyzeCorrelations(news);- const gazaPattern = results?.emergingPatterns.find(p => p.id === 'israel-gaza');+ const gazaPattern = results?.emergingPatterns.find((p) => p.id === 'israel-gaza');expect(gazaPattern?.headlines.length).toBeGreaterThan(0);expect(gazaPattern?.headlines[0].link).toBeDefined();@@ -111,9 +177,30 @@ describe('Correlation Engine', () => {expect(getCorrelationSummary(null)).toEqual({ totalSignals: 0, status: 'NO DATA' });const news: NewsItem[] = [- { id: '1', title: 'Ukraine update', source: 'BBC', link: 'a', timestamp: Date.now(), category: 'politics' },- { id: '2', title: 'Ukraine news', source: 'CNN', link: 'b', timestamp: Date.now(), category: 'politics' },- { id: '3', title: 'Zelensky speaks', source: 'NYT', link: 'c', timestamp: Date.now(), category: 'politics' },+ {+ id: '1',+ title: 'Ukraine update',+ source: 'BBC',+ link: 'a',+ timestamp: Date.now(),+ category: 'politics'+ },+ {+ id: '2',+ title: 'Ukraine news',+ source: 'CNN',+ link: 'b',+ timestamp: Date.now(),+ category: 'politics'+ },+ {+ id: '3',+ title: 'Zelensky speaks',+ source: 'NYT',+ link: 'c',+ timestamp: Date.now(),+ category: 'politics'+ }];const results = analyzeCorrelations(news);diff --git a/src/lib/analysis/correlation.ts b/src/lib/analysis/correlation.tsindex 178131d..8808c84 100644--- a/src/lib/analysis/correlation.ts+++ b/src/lib/analysis/correlation.ts@@ -67,9 +67,7 @@ const MOMENTUM_WINDOW_MINUTES = 10;* Format topic ID to display name*/function formatTopicName(id: string): string {- return id- .replace(/-/g, ' ')- .replace(/\b\w/g, (l) => l.toUpperCase());+ return id.replace(/-/g, ' ').replace(/\b\w/g, (l) => l.toUpperCase());}/**diff --git a/src/lib/analysis/main-character.test.ts b/src/lib/analysis/main-character.test.tsindex b290aa1..bb581d2 100644--- a/src/lib/analysis/main-character.test.ts+++ b/src/lib/analysis/main-character.test.ts@@ -19,9 +19,30 @@ describe('Main Character Analysis', () => {it('should count mentions correctly', () => {const news: NewsItem[] = [- { id: '1', title: 'Trump announces policy', source: 'BBC', link: 'a', timestamp: Date.now(), category: 'politics' },- { id: '2', title: 'Trump speaks at rally', source: 'CNN', link: 'b', timestamp: Date.now(), category: 'politics' },- { id: '3', title: 'Biden meets with leaders', source: 'NYT', link: 'c', timestamp: Date.now(), category: 'politics' },+ {+ id: '1',+ title: 'Trump announces policy',+ source: 'BBC',+ link: 'a',+ timestamp: Date.now(),+ category: 'politics'+ },+ {+ id: '2',+ title: 'Trump speaks at rally',+ source: 'CNN',+ link: 'b',+ timestamp: Date.now(),+ category: 'politics'+ },+ {+ id: '3',+ title: 'Biden meets with leaders',+ source: 'NYT',+ link: 'c',+ timestamp: Date.now(),+ category: 'politics'+ }];const results = calculateMainCharacter(news);@@ -33,10 +54,38 @@ describe('Main Character Analysis', () => {it('should rank characters by mention count', () => {const news: NewsItem[] = [- { id: '1', title: 'Musk buys company', source: 'A', link: 'a', timestamp: Date.now(), category: 'tech' },- { id: '2', title: 'Elon announces feature', source: 'B', link: 'b', timestamp: Date.now(), category: 'tech' },- { id: '3', title: 'Musk tweets again', source: 'C', link: 'c', timestamp: Date.now(), category: 'tech' },- { id: '4', title: 'Trump rally today', source: 'D', link: 'd', timestamp: Date.now(), category: 'politics' },+ {+ id: '1',+ title: 'Musk buys company',+ source: 'A',+ link: 'a',+ timestamp: Date.now(),+ category: 'tech'+ },+ {+ id: '2',+ title: 'Elon announces feature',+ source: 'B',+ link: 'b',+ timestamp: Date.now(),+ category: 'tech'+ },+ {+ id: '3',+ title: 'Musk tweets again',+ source: 'C',+ link: 'c',+ timestamp: Date.now(),+ category: 'tech'+ },+ {+ id: '4',+ title: 'Trump rally today',+ source: 'D',+ link: 'd',+ timestamp: Date.now(),+ category: 'politics'+ }];const results = calculateMainCharacter(news);@@ -48,8 +97,20 @@ describe('Main Character Analysis', () => {it('should limit results to top 10', () => {// Create news mentioning many different people- const names = ['Trump', 'Biden', 'Musk', 'Putin', 'Zelensky', 'Xi', 'Netanyahu',- 'Sam Altman', 'Zuckerberg', 'Bezos', 'Tim Cook', 'Powell'];+ const names = [+ 'Trump',+ 'Biden',+ 'Musk',+ 'Putin',+ 'Zelensky',+ 'Xi',+ 'Netanyahu',+ 'Sam Altman',+ 'Zuckerberg',+ 'Bezos',+ 'Tim Cook',+ 'Powell'+ ];const news: NewsItem[] = names.map((name, i) => ({id: String(i),@@ -67,8 +128,22 @@ describe('Main Character Analysis', () => {it('should match multiple patterns for same person', () => {const news: NewsItem[] = [- { id: '1', title: 'Elon Musk announces', source: 'A', link: 'a', timestamp: Date.now(), category: 'tech' },- { id: '2', title: 'Musk speaks out', source: 'B', link: 'b', timestamp: Date.now(), category: 'tech' },+ {+ id: '1',+ title: 'Elon Musk announces',+ source: 'A',+ link: 'a',+ timestamp: Date.now(),+ category: 'tech'+ },+ {+ id: '2',+ title: 'Musk speaks out',+ source: 'B',+ link: 'b',+ timestamp: Date.now(),+ category: 'tech'+ }];const results = calculateMainCharacter(news);@@ -88,8 +163,22 @@ describe('Main Character Analysis', () => {});const news: NewsItem[] = [- { id: '1', title: 'Putin addresses nation', source: 'A', link: 'a', timestamp: Date.now(), category: 'politics' },- { id: '2', title: 'Putin speaks on economy', source: 'B', link: 'b', timestamp: Date.now(), category: 'politics' },+ {+ id: '1',+ title: 'Putin addresses nation',+ source: 'A',+ link: 'a',+ timestamp: Date.now(),+ category: 'politics'+ },+ {+ id: '2',+ title: 'Putin speaks on economy',+ source: 'B',+ link: 'b',+ timestamp: Date.now(),+ category: 'politics'+ }];const results = calculateMainCharacter(news);@@ -104,7 +193,14 @@ describe('Main Character Analysis', () => {it('should calculate dominance correctly', () => {// Single character = 100% dominanceconst singleNews: NewsItem[] = [- { id: '1', title: 'Trump news', source: 'A', link: 'a', timestamp: Date.now(), category: 'politics' },+ {+ id: '1',+ title: 'Trump news',+ source: 'A',+ link: 'a',+ timestamp: Date.now(),+ category: 'politics'+ }];expect(calculateDominance(calculateMainCharacter(singleNews))).toBe(100);@@ -113,17 +209,59 @@ describe('Main Character Analysis', () => {// Two characters with same count = 0% dominanceconst evenNews: NewsItem[] = [- { id: '1', title: 'Trump speaks', source: 'A', link: 'a', timestamp: Date.now(), category: 'politics' },- { id: '2', title: 'Biden responds', source: 'B', link: 'b', timestamp: Date.now(), category: 'politics' },+ {+ id: '1',+ title: 'Trump speaks',+ source: 'A',+ link: 'a',+ timestamp: Date.now(),+ category: 'politics'+ },+ {+ id: '2',+ title: 'Biden responds',+ source: 'B',+ link: 'b',+ timestamp: Date.now(),+ category: 'politics'+ }];expect(calculateDominance(calculateMainCharacter(evenNews))).toBe(0);// Clear leader = high dominance (capped at 100)const dominantNews: NewsItem[] = [- { id: '1', title: 'Musk announcement', source: 'A', link: 'a', timestamp: Date.now(), category: 'tech' },- { id: '2', title: 'Elon tweets', source: 'B', link: 'b', timestamp: Date.now(), category: 'tech' },- { id: '3', title: 'Musk company news', source: 'C', link: 'c', timestamp: Date.now(), category: 'tech' },- { id: '4', title: 'Trump rally', source: 'D', link: 'd', timestamp: Date.now(), category: 'politics' },+ {+ id: '1',+ title: 'Musk announcement',+ source: 'A',+ link: 'a',+ timestamp: Date.now(),+ category: 'tech'+ },+ {+ id: '2',+ title: 'Elon tweets',+ source: 'B',+ link: 'b',+ timestamp: Date.now(),+ category: 'tech'+ },+ {+ id: '3',+ title: 'Musk company news',+ source: 'C',+ link: 'c',+ timestamp: Date.now(),+ category: 'tech'+ },+ {+ id: '4',+ title: 'Trump rally',+ source: 'D',+ link: 'd',+ timestamp: Date.now(),+ category: 'politics'+ }];const dominance = calculateDominance(calculateMainCharacter(dominantNews));expect(dominance).toBe(100); // Dominance is capped at 100@@ -131,8 +269,22 @@ describe('Main Character Analysis', () => {it('should handle case insensitivity', () => {const news: NewsItem[] = [- { id: '1', title: 'TRUMP announces policy', source: 'A', link: 'a', timestamp: Date.now(), category: 'politics' },- { id: '2', title: 'trump speaks today', source: 'B', link: 'b', timestamp: Date.now(), category: 'politics' },+ {+ id: '1',+ title: 'TRUMP announces policy',+ source: 'A',+ link: 'a',+ timestamp: Date.now(),+ category: 'politics'+ },+ {+ id: '2',+ title: 'trump speaks today',+ source: 'B',+ link: 'b',+ timestamp: Date.now(),+ category: 'politics'+ }];const results = calculateMainCharacter(news);diff --git a/src/lib/analysis/narrative.test.ts b/src/lib/analysis/narrative.test.tsindex f6590d6..51b5538 100644--- a/src/lib/analysis/narrative.test.ts+++ b/src/lib/analysis/narrative.test.ts@@ -3,11 +3,7 @@*/import { describe, it, expect, beforeEach } from 'vitest';-import {- analyzeNarratives,- getNarrativeSummary,- clearNarrativeHistory-} from './narrative';+import { analyzeNarratives, getNarrativeSummary, clearNarrativeHistory } from './narrative';import type { NewsItem } from '$lib/types';describe('Narrative Tracker', () => {@@ -22,16 +18,30 @@ describe('Narrative Tracker', () => {it('should detect narrative patterns', () => {const news: NewsItem[] = [- { id: '1', title: 'Deep state allegations surface', source: 'Test', link: 'a', timestamp: Date.now(), category: 'politics' },- { id: '2', title: 'Shadow government concerns', source: 'Test2', link: 'b', timestamp: Date.now(), category: 'politics' },+ {+ id: '1',+ title: 'Deep state allegations surface',+ source: 'Test',+ link: 'a',+ timestamp: Date.now(),+ category: 'politics'+ },+ {+ id: '2',+ title: 'Shadow government concerns',+ source: 'Test2',+ link: 'b',+ timestamp: Date.now(),+ category: 'politics'+ }];const results = analyzeNarratives(news);expect(results).not.toBeNull();const deepState =- results!.emergingFringe.find(n => n.id === 'deep-state') ||- results!.narrativeWatch.find(n => n.id === 'deep-state');+ results!.emergingFringe.find((n) => n.id === 'deep-state') ||+ results!.narrativeWatch.find((n) => n.id === 'deep-state');expect(deepState).toBeDefined();expect(deepState!.count).toBe(2);@@ -39,20 +49,48 @@ describe('Narrative Tracker', () => {it('should classify disinfo patterns', () => {const news: NewsItem[] = [- { id: '1', title: 'Depopulation agenda exposed', source: 'Fringe', link: 'a', timestamp: Date.now(), category: 'politics' },+ {+ id: '1',+ title: 'Depopulation agenda exposed',+ source: 'Fringe',+ link: 'a',+ timestamp: Date.now(),+ category: 'politics'+ }];const results = analyzeNarratives(news);expect(results!.disinfoSignals.length).toBeGreaterThan(0);- expect(results!.disinfoSignals.find(n => n.id === 'depopulation')).toBeDefined();+ expect(results!.disinfoSignals.find((n) => n.id === 'depopulation')).toBeDefined();});it('should detect fringe-to-mainstream crossover', () => {const news: NewsItem[] = [- { id: '1', title: 'Lab leak theory gains traction', source: 'ZeroHedge', link: 'a', timestamp: Date.now(), category: 'politics' },- { id: '2', title: 'Lab leak investigation continues', source: 'BBC News', link: 'b', timestamp: Date.now(), category: 'politics' },- { id: '3', title: 'Bioweapon research concerns', source: 'CNN', link: 'c', timestamp: Date.now(), category: 'politics' },+ {+ id: '1',+ title: 'Lab leak theory gains traction',+ source: 'ZeroHedge',+ link: 'a',+ timestamp: Date.now(),+ category: 'politics'+ },+ {+ id: '2',+ title: 'Lab leak investigation continues',+ source: 'BBC News',+ link: 'b',+ timestamp: Date.now(),+ category: 'politics'+ },+ {+ id: '3',+ title: 'Bioweapon research concerns',+ source: 'CNN',+ link: 'c',+ timestamp: Date.now(),+ category: 'politics'+ }];const results = analyzeNarratives(news);@@ -63,14 +101,27 @@ describe('Narrative Tracker', () => {it('should classify source types correctly', () => {const news: NewsItem[] = [- { id: '1', title: 'Dollar collapse imminent', source: 'ZeroHedge', link: 'a', timestamp: Date.now(), category: 'finance' },- { id: '2', title: 'Dedollarization fears', source: 'Infowars', link: 'b', timestamp: Date.now(), category: 'finance' },+ {+ id: '1',+ title: 'Dollar collapse imminent',+ source: 'ZeroHedge',+ link: 'a',+ timestamp: Date.now(),+ category: 'finance'+ },+ {+ id: '2',+ title: 'Dedollarization fears',+ source: 'Infowars',+ link: 'b',+ timestamp: Date.now(),+ category: 'finance'+ }];const results = analyzeNarratives(news);- const dollarNarrative =- results!.emergingFringe.find(n => n.id === 'dollar-collapse');+ const dollarNarrative = results!.emergingFringe.find((n) => n.id === 'dollar-collapse');expect(dollarNarrative).toBeDefined();expect(dollarNarrative!.fringeCount).toBeGreaterThan(0);@@ -78,15 +129,29 @@ describe('Narrative Tracker', () => {it('should track keywords and headlines', () => {const news: NewsItem[] = [- { id: '1', title: 'AI doom predictions increase', source: 'Tech', link: 'a', timestamp: Date.now(), category: 'tech' },- { id: '2', title: 'AI extinction risk debated', source: 'Tech2', link: 'b', timestamp: Date.now(), category: 'tech' },+ {+ id: '1',+ title: 'AI doom predictions increase',+ source: 'Tech',+ link: 'a',+ timestamp: Date.now(),+ category: 'tech'+ },+ {+ id: '2',+ title: 'AI extinction risk debated',+ source: 'Tech2',+ link: 'b',+ timestamp: Date.now(),+ category: 'tech'+ }];const results = analyzeNarratives(news);const aiDoom =- results!.emergingFringe.find(n => n.id === 'ai-doom') ||- results!.narrativeWatch.find(n => n.id === 'ai-doom');+ results!.emergingFringe.find((n) => n.id === 'ai-doom') ||+ results!.narrativeWatch.find((n) => n.id === 'ai-doom');expect(aiDoom).toBeDefined();expect(aiDoom!.keywords).toContain('ai doom');@@ -97,7 +162,14 @@ describe('Narrative Tracker', () => {expect(getNarrativeSummary(null)).toEqual({ total: 0, status: 'NO DATA' });const news: NewsItem[] = [- { id: '1', title: 'Great reset concerns', source: 'Test', link: 'a', timestamp: Date.now(), category: 'politics' },+ {+ id: '1',+ title: 'Great reset concerns',+ source: 'Test',+ link: 'a',+ timestamp: Date.now(),+ category: 'politics'+ }];const results = analyzeNarratives(news);@@ -120,8 +192,8 @@ describe('Narrative Tracker', () => {const results = analyzeNarratives(news);const deepState =- results!.emergingFringe.find(n => n.id === 'deep-state') ||- results!.narrativeWatch.find(n => n.id === 'deep-state');+ results!.emergingFringe.find((n) => n.id === 'deep-state') ||+ results!.narrativeWatch.find((n) => n.id === 'deep-state');expect(deepState!.sources.length).toBeLessThanOrEqual(5);});diff --git a/src/lib/analysis/narrative.ts b/src/lib/analysis/narrative.tsindex d1e90e4..df73e71 100644--- a/src/lib/analysis/narrative.ts+++ b/src/lib/analysis/narrative.ts@@ -48,9 +48,7 @@ const narrativeHistory: Record<* Format narrative ID to display name*/function formatNarrativeName(id: string): string {- return id- .replace(/-/g, ' ')- .replace(/\b\w/g, (c) => c.toUpperCase());+ return id.replace(/-/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase());}/**diff --git a/src/lib/api/index.ts b/src/lib/api/index.tsindex 5f887b9..169bfa3 100644--- a/src/lib/api/index.ts+++ b/src/lib/api/index.ts@@ -3,6 +3,12 @@*/export { fetchCategoryNews, fetchAllNews } from './news';-export { fetchCryptoPrices, fetchIndices, fetchSectorPerformance, fetchCommodities, fetchAllMarkets } from './markets';+export {+ fetchCryptoPrices,+ fetchIndices,+ fetchSectorPerformance,+ fetchCommodities,+ fetchAllMarkets+} from './markets';export { fetchPolymarket, fetchWhaleTransactions, fetchGovContracts, fetchLayoffs } from './misc';export type { Prediction, WhaleTransaction, Contract, Layoff } from './misc';diff --git a/src/lib/api/markets.ts b/src/lib/api/markets.tsindex b3bd23a..719a27a 100644--- a/src/lib/api/markets.ts+++ b/src/lib/api/markets.ts@@ -4,9 +4,7 @@import { INDICES, SECTORS, COMMODITIES, CRYPTO } from '$lib/config/markets';import type { MarketItem, SectorPerformance, CryptoItem } from '$lib/types';--// Proxy URL for CORS requests-const PROXY_URL = 'https://situation-monitor-proxy.seanthielen-e.workers.dev/?url=';+import { CORS_PROXY_URL, logger } from '$lib/config/api';interface CoinGeckoPrice {usd: number;@@ -26,8 +24,8 @@ export async function fetchCryptoPrices(): Promise<CryptoItem[]> {const coinGeckoUrl = `https://api.coingecko.com/api/v3/simple/price?ids=${ids}&vs_currencies=usd&include_24hr_change=true`;// Use proxy to avoid CORS/rate limiting issues- const proxyUrl = PROXY_URL + encodeURIComponent(coinGeckoUrl);- console.log('[Markets API] Fetching crypto from:', proxyUrl);+ const proxyUrl = CORS_PROXY_URL + encodeURIComponent(coinGeckoUrl);+ logger.log('Markets API', 'Fetching crypto from:', proxyUrl);const response = await fetch(proxyUrl);if (!response.ok) {@@ -48,7 +46,7 @@ export async function fetchCryptoPrices(): Promise<CryptoItem[]> {};});} catch (error) {- console.error('[Markets API] Error fetching crypto:', error);+ logger.error('Markets API', 'Error fetching crypto:', error);return CRYPTO.map((c) => ({id: c.id,symbol: c.symbol,@@ -62,45 +60,48 @@ export async function fetchCryptoPrices(): Promise<CryptoItem[]> {/*** Fetch market indices (via proxy for Yahoo Finance)+ * Note: Returns placeholder data - would need Yahoo Finance API or similar*/export async function fetchIndices(): Promise<MarketItem[]> {- // For now, return placeholder data - would need Yahoo Finance API or similar- // The original app uses a proxy to scrape market data+ // TODO: Implement real market data fetching+ // Options: Yahoo Finance API, Alpha Vantage, Polygon.ioreturn INDICES.map((index) => ({symbol: index.symbol,name: index.name,- price: 0,- change: 0,- changePercent: 0,+ price: NaN, // NaN indicates data not available+ change: NaN,+ changePercent: NaN,type: 'index' as const}));}/*** Fetch sector performance+ * Note: Returns placeholder data - would need market data provider*/export async function fetchSectorPerformance(): Promise<SectorPerformance[]> {- // Placeholder - would need market data provider+ // TODO: Implement real sector data fetchingreturn SECTORS.map((sector) => ({symbol: sector.symbol,name: sector.name,- price: 0,- change: 0,- changePercent: 0+ price: NaN,+ change: NaN,+ changePercent: NaN}));}/*** Fetch commodities+ * Note: Returns placeholder data - would need commodities data provider*/export async function fetchCommodities(): Promise<MarketItem[]> {- // Placeholder - would need commodities data provider+ // TODO: Implement real commodities data fetchingreturn COMMODITIES.map((commodity) => ({symbol: commodity.symbol,name: commodity.name,- price: 0,- change: 0,- changePercent: 0,+ price: NaN,+ change: NaN,+ changePercent: NaN,type: 'commodity' as const}));}diff --git a/src/lib/api/misc.ts b/src/lib/api/misc.tsindex 0e08575..682549f 100644--- a/src/lib/api/misc.ts+++ b/src/lib/api/misc.ts@@ -38,13 +38,23 @@ export interface Layoff {export async function fetchPolymarket(): Promise<Prediction[]> {// These represent active prediction markets on major eventsreturn [- { id: 'pm-1', question: 'Will there be a US-China military incident in 2026?', yes: 18, volume: '2.4M' },+ {+ id: 'pm-1',+ question: 'Will there be a US-China military incident in 2026?',+ yes: 18,+ volume: '2.4M'+ },{ id: 'pm-2', question: 'Will Bitcoin reach $150K by end of 2026?', yes: 35, volume: '8.1M' },{ id: 'pm-3', question: 'Will Fed cut rates in Q1 2026?', yes: 42, volume: '5.2M' },{ id: 'pm-4', question: 'Will AI cause major job losses in 2026?', yes: 28, volume: '1.8M' },{ id: 'pm-5', question: 'Will Ukraine conflict end in 2026?', yes: 22, volume: '3.5M' },{ id: 'pm-6', question: 'Will oil prices exceed $100/barrel?', yes: 31, volume: '2.1M' },- { id: 'pm-7', question: 'Will there be a major cyberattack on US infrastructure?', yes: 45, volume: '1.5M' }+ {+ id: 'pm-7',+ question: 'Will there be a major cyberattack on US infrastructure?',+ yes: 45,+ volume: '1.5M'+ }];}@@ -70,11 +80,36 @@ export async function fetchWhaleTransactions(): Promise<WhaleTransaction[]> {export async function fetchGovContracts(): Promise<Contract[]> {// Sample government contract datareturn [- { agency: 'DOD', description: 'Advanced radar systems development and integration', vendor: 'Raytheon', amount: 2500000000 },- { agency: 'NASA', description: 'Artemis program lunar lander support services', vendor: 'SpaceX', amount: 1800000000 },- { agency: 'DHS', description: 'Border security technology modernization', vendor: 'Palantir', amount: 450000000 },- { agency: 'VA', description: 'Electronic health records system upgrade', vendor: 'Oracle Cerner', amount: 320000000 },- { agency: 'DOE', description: 'Clean energy grid infrastructure', vendor: 'General Electric', amount: 275000000 }+ {+ agency: 'DOD',+ description: 'Advanced radar systems development and integration',+ vendor: 'Raytheon',+ amount: 2500000000+ },+ {+ agency: 'NASA',+ description: 'Artemis program lunar lander support services',+ vendor: 'SpaceX',+ amount: 1800000000+ },+ {+ agency: 'DHS',+ description: 'Border security technology modernization',+ vendor: 'Palantir',+ amount: 450000000+ },+ {+ agency: 'VA',+ description: 'Electronic health records system upgrade',+ vendor: 'Oracle Cerner',+ amount: 320000000+ },+ {+ agency: 'DOE',+ description: 'Clean energy grid infrastructure',+ vendor: 'General Electric',+ amount: 275000000+ }];}@@ -93,8 +128,18 @@ export async function fetchLayoffs(): Promise<Layoff[]> {return [{ company: 'Meta', count: 1200, title: 'Restructuring engineering teams', date: formatDate(2) },{ company: 'Amazon', count: 850, title: 'AWS division optimization', date: formatDate(5) },- { company: 'Salesforce', count: 700, title: 'Post-acquisition consolidation', date: formatDate(8) },- { company: 'Intel', count: 1500, title: 'Manufacturing pivot restructure', date: formatDate(12) },+ {+ company: 'Salesforce',+ count: 700,+ title: 'Post-acquisition consolidation',+ date: formatDate(8)+ },+ {+ company: 'Intel',+ count: 1500,+ title: 'Manufacturing pivot restructure',+ date: formatDate(12)+ },{ company: 'Snap', count: 500, title: 'Cost reduction initiative', date: formatDate(15) }];}diff --git a/src/lib/api/news.ts b/src/lib/api/news.tsindex 1488646..981dab5 100644--- a/src/lib/api/news.ts+++ b/src/lib/api/news.ts@@ -5,12 +5,7 @@import { FEEDS } from '$lib/config/feeds';import type { NewsItem, NewsCategory } from '$lib/types';import { containsAlertKeyword, detectRegion, detectTopics } from '$lib/config/keywords';--// Proxy URL for CORS requests-const PROXY_URL = 'https://situation-monitor-proxy.seanthielen-e.workers.dev/?url=';--// Delay between API requests to avoid rate limiting (ms)-const REQUEST_DELAY = 500;+import { CORS_PROXY_URL, API_DELAYS, logger } from '$lib/config/api';/*** Simple hash function to generate unique IDs from URLs@@ -19,7 +14,7 @@ function hashCode(str: string): string {let hash = 0;for (let i = 0; i < str.length; i++) {const char = str.charCodeAt(i);- hash = ((hash << 5) - hash) + char;+ hash = (hash << 5) - hash + char;hash = hash & hash; // Convert to 32bit integer}return Math.abs(hash).toString(36);@@ -29,7 +24,7 @@ function hashCode(str: string): string {* Delay helper*/function delay(ms: number): Promise<void> {- return new Promise(resolve => setTimeout(resolve, ms));+ return new Promise((resolve) => setTimeout(resolve, ms));}interface GdeltArticle {@@ -96,8 +91,8 @@ export async function fetchCategoryNews(category: NewsCategory): Promise<NewsIteconst gdeltUrl = `https://api.gdeltproject.org/api/v2/doc/doc?query=${fullQuery}&mode=artlist&maxrecords=20&format=json&sort=date`;// Use proxy to avoid CORS - encode the whole URL once- const proxyUrl = PROXY_URL + encodeURIComponent(gdeltUrl);- console.log(`[News API] Fetching ${category} from:`, proxyUrl);+ const proxyUrl = CORS_PROXY_URL + encodeURIComponent(gdeltUrl);+ logger.log('News API', `Fetching ${category} from:`, proxyUrl);const response = await fetch(proxyUrl);if (!response.ok) {@@ -107,7 +102,7 @@ export async function fetchCategoryNews(category: NewsCategory): Promise<NewsIte// Check content type before parsing as JSONconst contentType = response.headers.get('content-type');if (!contentType?.includes('application/json')) {- console.warn(`[News API] Non-JSON response for ${category}:`, contentType);+ logger.warn('News API', `Non-JSON response for ${category}:`, contentType);return [];}@@ -116,7 +111,7 @@ export async function fetchCategoryNews(category: NewsCategory): Promise<NewsItetry {data = JSON.parse(text);} catch {- console.warn(`[News API] Invalid JSON for ${category}:`, text.slice(0, 100));+ logger.warn('News API', `Invalid JSON for ${category}:`, text.slice(0, 100));return [];}@@ -130,7 +125,7 @@ export async function fetchCategoryNews(category: NewsCategory): Promise<NewsItetransformGdeltArticle(article, category, article.domain || defaultSource, index));} catch (error) {- console.error(`[News API] Error fetching ${category}:`, error);+ logger.error('News API', `Error fetching ${category}:`, error);return [];}}@@ -155,7 +150,7 @@ export async function fetchAllNews(): Promise<Record<NewsCategory, NewsItem[]>>// Add delay between requests (not before the first one)if (i > 0) {- await delay(REQUEST_DELAY);+ await delay(API_DELAYS.betweenCategories);}result[category] = await fetchCategoryNews(category);diff --git a/src/lib/components/common/MarketItem.svelte b/src/lib/components/common/MarketItem.svelteindex 382624a..91ee0e4 100644--- a/src/lib/components/common/MarketItem.svelte+++ b/src/lib/components/common/MarketItem.svelte@@ -18,13 +18,16 @@currencySymbol = '$'}: Props = $props();- const changeClass = $derived(getChangeClass(item.changePercent));+ const isDataAvailable = $derived(!isNaN(item.price) && item.price !== null);+ const changeClass = $derived(isDataAvailable ? getChangeClass(item.changePercent) : '');const priceDisplay = $derived(- item.price > 100- ? item.price.toLocaleString('en-US', { maximumFractionDigits: 0 })- : item.price.toFixed(2)+ !isDataAvailable+ ? '—'+ : item.price > 100+ ? item.price.toLocaleString('en-US', { maximumFractionDigits: 0 })+ : item.price.toFixed(2));- const changeText = $derived(formatPercentChange(item.changePercent));+ const changeText = $derived(isDataAvailable ? formatPercentChange(item.changePercent) : '—');</script><div class="market-item" class:compact>@@ -37,9 +40,11 @@<div class="market-data">{#if showPrice}- <div class="market-price">{currencySymbol}{priceDisplay}</div>+ <div class="market-price" class:unavailable={!isDataAvailable}>+ {isDataAvailable ? `${currencySymbol}${priceDisplay}` : priceDisplay}+ </div>{/if}- <div class="market-change {changeClass}">{changeText}</div>+ <div class="market-change {changeClass}" class:unavailable={!isDataAvailable}>{changeText}</div></div></div>@@ -113,4 +118,9 @@.market-change.down {color: var(--danger);}++ .unavailable {+ color: var(--text-muted);+ opacity: 0.5;+ }</style>diff --git a/src/lib/components/modals/OnboardingModal.svelte b/src/lib/components/modals/OnboardingModal.svelteindex bded70c..3591a2d 100644--- a/src/lib/components/modals/OnboardingModal.svelte+++ b/src/lib/components/modals/OnboardingModal.svelte@@ -4,19 +4,36 @@interface Props {open: boolean;onSelectPreset: (presetId: string) => void;+ onSkip?: () => void;}- let { open, onSelectPreset }: Props = $props();+ let { open, onSelectPreset, onSkip }: Props = $props();function handleSelectPreset(presetId: string) {onSelectPreset(presetId);}++ function handleSkip() {+ // Select the 'everything' preset (show all panels) when skipping+ onSelectPreset('everything');+ }++ function handleClose() {+ if (onSkip) {+ onSkip();+ } else {+ handleSkip();+ }+ }</script>{#if open}<div class="modal-overlay"><div class="modal onboarding-modal"><div class="modal-header">+ <button class="close-btn" onclick={handleClose} aria-label="Skip onboarding">+ ×+ </button><h2>Welcome to Situation Monitor</h2><p class="subtitle">Choose a dashboard configuration to get started</p></div>@@ -24,10 +41,7 @@<div class="preset-grid">{#each PRESET_ORDER as presetId}{@const preset = PRESETS[presetId]}- <button- class="preset-card"- onclick={() => handleSelectPreset(presetId)}- >+ <button class="preset-card" onclick={() => handleSelectPreset(presetId)}><div class="preset-icon">{preset.icon}</div><div class="preset-name">{preset.name}</div><div class="preset-description">{preset.description}</div>@@ -66,11 +80,36 @@}.modal-header {+ position: relative;padding: 1.5rem;text-align: center;border-bottom: 1px solid var(--border);}+ .close-btn {+ position: absolute;+ top: 0.75rem;+ right: 0.75rem;+ width: 2rem;+ height: 2rem;+ display: flex;+ align-items: center;+ justify-content: center;+ background: transparent;+ border: 1px solid var(--border);+ border-radius: 4px;+ color: var(--text-secondary);+ font-size: 1.25rem;+ cursor: pointer;+ transition: all 0.2s ease;+ }++ .close-btn:hover {+ background: var(--bg);+ color: var(--text-primary);+ border-color: var(--text-secondary);+ }+.modal-header h2 {color: var(--text-primary);font-size: 1.25rem;diff --git a/src/lib/components/modals/SettingsModal.svelte b/src/lib/components/modals/SettingsModal.svelteindex 736babc..89b6605 100644--- a/src/lib/components/modals/SettingsModal.svelte+++ b/src/lib/components/modals/SettingsModal.svelte@@ -30,11 +30,7 @@<h3 class="section-title">Auto Refresh</h3><div class="setting-row"><label class="toggle-label">- <input- type="checkbox"- checked={$autoRefreshEnabled}- onchange={handleToggleAutoRefresh}- />+ <input type="checkbox" checked={$autoRefreshEnabled} onchange={handleToggleAutoRefresh} /><span>Enable auto-refresh (hourly)</span></label></div>@@ -64,9 +60,7 @@<section class="settings-section"><h3 class="section-title">Dashboard</h3>{#if onReconfigure}- <button class="reconfigure-btn" onclick={onReconfigure}>- Reconfigure Dashboard- </button>+ <button class="reconfigure-btn" onclick={onReconfigure}> Reconfigure Dashboard </button><p class="btn-hint">Choose a preset profile for your panels</p>{/if}<button class="reset-btn" onclick={handleResetPanels}> Reset All Settings </button>diff --git a/src/lib/components/panels/IntelPanel.svelte b/src/lib/components/panels/IntelPanel.svelteindex aef73ca..f76b93d 100644--- a/src/lib/components/panels/IntelPanel.svelte+++ b/src/lib/components/panels/IntelPanel.svelte@@ -50,7 +50,10 @@<div class="intel-header"><span class="intel-source">{item.source}</span><div class="intel-tags">- <Badge text={item.sourceType.toUpperCase()} variant={getSourceBadgeVariant(item.sourceType)} />+ <Badge+ text={item.sourceType.toUpperCase()}+ variant={getSourceBadgeVariant(item.sourceType)}+ />{#each item.regions.slice(0, 2) as region}<Badge text={region} variant="info" />{/each}diff --git a/src/lib/components/panels/MainCharPanel.svelte b/src/lib/components/panels/MainCharPanel.svelteindex 9ba1ab2..08ed64e 100644--- a/src/lib/components/panels/MainCharPanel.svelte+++ b/src/lib/components/panels/MainCharPanel.svelte@@ -1,11 +1,10 @@<script lang="ts">import { Panel } from '$lib/components/common';- import { news } from '$lib/stores';+ import { allNewsItems } from '$lib/stores';import { calculateMainCharacter, type MainCharacterResults } from '$lib/analysis';- // Calculate main character from all news- const allNews = $derived(news.getAllItems());- const results: MainCharacterResults = $derived(calculateMainCharacter(allNews));+ // Calculate main character from all news (reactive via derived store)+ const results: MainCharacterResults = $derived(calculateMainCharacter($allNewsItems));const topChar = $derived(results.topCharacter);const rankings = $derived(results.characters);</script>diff --git a/src/lib/components/panels/MapPanel.svelte b/src/lib/components/panels/MapPanel.svelteindex 546c154..0bdb6cf 100644--- a/src/lib/components/panels/MapPanel.svelte+++ b/src/lib/components/panels/MapPanel.svelte@@ -13,6 +13,7 @@THREAT_COLORS,WEATHER_CODES} from '$lib/config/map';+ import { CACHE_TTLS } from '$lib/config/api';import type { CustomMonitor } from '$lib/types';interface Props {@@ -25,18 +26,15 @@let mapContainer: HTMLDivElement;// D3 objects - initialized in initMap, null before initialization- // eslint-disable-next-line @typescript-eslint/no-explicit-any+ // Using 'any' for D3 objects as they're dynamically imported and have complex generic types+ /* eslint-disable @typescript-eslint/no-explicit-any */let d3Module: typeof import('d3') | null = null;- // eslint-disable-next-line @typescript-eslint/no-explicit-anylet svg: any = null;- // eslint-disable-next-line @typescript-eslint/no-explicit-anylet mapGroup: any = null;- // eslint-disable-next-line @typescript-eslint/no-explicit-anylet projection: any = null;- // eslint-disable-next-line @typescript-eslint/no-explicit-anylet path: any = null;- // eslint-disable-next-line @typescript-eslint/no-explicit-anylet zoom: any = null;+ /* eslint-enable @typescript-eslint/no-explicit-any */const WIDTH = 800;const HEIGHT = 400;@@ -50,8 +48,27 @@let tooltipPosition = $state({ left: 0, top: 0 });let tooltipVisible = $state(false);- // Data cache for tooltips- const dataCache: Record<string, unknown> = {};+ // Data cache for tooltips with TTL support+ interface CacheEntry<T> {+ data: T;+ timestamp: number;+ }+ const dataCache: Record<string, CacheEntry<unknown>> = {};++ function getCachedData<T>(key: string): T | null {+ const entry = dataCache[key] as CacheEntry<T> | undefined;+ if (!entry) return null;+ // Check if cache entry has expired+ if (Date.now() - entry.timestamp > CACHE_TTLS.weather) {+ delete dataCache[key];+ return null;+ }+ return entry.data;+ }++ function setCachedData<T>(key: string, data: T): void {+ dataCache[key] = { data, timestamp: Date.now() };+ }// Get local time at longitudefunction getLocalTime(lon: number): string {@@ -65,13 +82,19 @@return `${localHours}:${utcMinutes.toString().padStart(2, '0')} ${ampm}`;}- // Fetch weather from Open-Meteo- async function getWeather(- lat: number,- lon: number- ): Promise<{ temp: number | null; wind: number | null; condition: string } | null> {+ // Weather result type+ interface WeatherResult {+ temp: number | null;+ wind: number | null;+ condition: string;+ }++ // Fetch weather from Open-Meteo with TTL-based caching+ async function getWeather(lat: number, lon: number): Promise<WeatherResult | null> {const key = `weather_${lat}_${lon}`;- if (dataCache[key]) return dataCache[key] as { temp: number | null; wind: number | null; condition: string };+ const cached = getCachedData<WeatherResult>(key);+ if (cached) return cached;+try {const res = await fetch(`https://api.open-meteo.com/v1/forecast?latitude=${lat}&longitude=${lon}¤t=temperature_2m,weather_code,wind_speed_10m`@@ -81,12 +104,12 @@const tempF = temp ? Math.round((temp * 9) / 5 + 32) : null;const wind = data.current?.wind_speed_10m;const code = data.current?.weather_code;- const result = {+ const result: WeatherResult = {temp: tempF,wind: wind ? Math.round(wind) : null,condition: WEATHER_CODES[code] || '—'};- dataCache[key] = result;+ setCachedData(key, result);return result;} catch {return null;@@ -127,7 +150,12 @@}// Show tooltip using state (safe rendering)- function showTooltip(event: MouseEvent, title: string, color: string, lines: string[] = []): void {+ function showTooltip(+ event: MouseEvent,+ title: string,+ color: string,+ lines: string[] = []+ ): void {if (!mapContainer) return;const rect = mapContainer.getBoundingClientRect();tooltipContent = { title, color, lines };@@ -220,8 +248,11 @@'https://cdn.jsdelivr.net/npm/world-atlas@2/countries-110m.json');const world = await response.json();- // eslint-disable-next-line @typescript-eslint/no-explicit-any- const countries = topojson.feature(world, world.objects.countries as any) as unknown as GeoJSON.FeatureCollection;+ const countries = topojson.feature(+ world,+ // eslint-disable-next-line @typescript-eslint/no-explicit-any+ world.objects.countries as any+ ) as unknown as GeoJSON.FeatureCollection;// Draw countriesmapGroup@@ -317,9 +348,7 @@.attr('r', 10).attr('fill', 'transparent').attr('class', 'hotspot-hit')- .on('mouseenter', (event: MouseEvent) =>- showTooltip(event, `⬥ ${cp.desc}`, '#00aaff')- )+ .on('mouseenter', (event: MouseEvent) => showTooltip(event, `⬥ ${cp.desc}`, '#00aaff')).on('mousemove', moveTooltip).on('mouseleave', hideTooltip);}@@ -344,9 +373,7 @@.attr('r', 10).attr('fill', 'transparent').attr('class', 'hotspot-hit')- .on('mouseenter', (event: MouseEvent) =>- showTooltip(event, `◎ ${cl.desc}`, '#aa44ff')- )+ .on('mouseenter', (event: MouseEvent) => showTooltip(event, `◎ ${cl.desc}`, '#aa44ff')).on('mousemove', moveTooltip).on('mouseleave', hideTooltip);}@@ -378,9 +405,7 @@.attr('r', 10).attr('fill', 'transparent').attr('class', 'hotspot-hit')- .on('mouseenter', (event: MouseEvent) =>- showTooltip(event, `☢ ${ns.desc}`, '#ffff00')- )+ .on('mouseenter', (event: MouseEvent) => showTooltip(event, `☢ ${ns.desc}`, '#ffff00')).on('mousemove', moveTooltip).on('mouseleave', hideTooltip);}@@ -399,9 +424,7 @@.attr('r', 10).attr('fill', 'transparent').attr('class', 'hotspot-hit')- .on('mouseenter', (event: MouseEvent) =>- showTooltip(event, `★ ${mb.desc}`, '#ff00ff')- )+ .on('mouseenter', (event: MouseEvent) => showTooltip(event, `★ ${mb.desc}`, '#ff00ff')).on('mousemove', moveTooltip).on('mouseleave', hideTooltip);}@@ -422,12 +445,7 @@.attr('fill-opacity', 0.3).attr('class', 'pulse');// Inner dot- mapGroup- .append('circle')- .attr('cx', x)- .attr('cy', y)- .attr('r', 3)- .attr('fill', color);+ mapGroup.append('circle').attr('cx', x).attr('cy', y).attr('r', 3).attr('fill', color);// LabelmapGroup.append('text')@@ -520,7 +538,10 @@function zoomOut(): void {if (!svg || !zoom) return;- svg.transition().duration(300).call(zoom.scaleBy, 1 / 1.5);+ svg+ .transition()+ .duration(300)+ .call(zoom.scaleBy, 1 / 1.5);}function resetZoom(): void {diff --git a/src/lib/components/panels/MonitorsPanel.svelte b/src/lib/components/panels/MonitorsPanel.svelteindex 39a9b55..b646c36 100644--- a/src/lib/components/panels/MonitorsPanel.svelte+++ b/src/lib/components/panels/MonitorsPanel.svelte@@ -40,9 +40,7 @@<div class="empty-state"><p>No monitors configured</p>{#if onCreateMonitor}- <button class="create-btn" onclick={onCreateMonitor}>- + Create Monitor- </button>+ <button class="create-btn" onclick={onCreateMonitor}> + Create Monitor </button>{/if}</div>{:else}@@ -83,7 +81,11 @@</button>{/if}{#if onDeleteMonitor}- <button class="action-btn delete" onclick={() => onDeleteMonitor?.(monitor.id)} title="Delete">+ <button+ class="action-btn delete"+ onclick={() => onDeleteMonitor?.(monitor.id)}+ title="Delete"+ >×</button>{/if}@@ -109,7 +111,12 @@<div class="monitor-matches">{#each getMatchesForMonitor(monitor.id) as match}<div class="match-item">- <a href={match.item.link} target="_blank" rel="noopener noreferrer" class="match-title">+ <a+ href={match.item.link}+ target="_blank"+ rel="noopener noreferrer"+ class="match-title"+ >{match.item.title.length > 80? match.item.title.substring(0, 80) + '...': match.item.title}diff --git a/src/lib/components/panels/NewsPanel.svelte b/src/lib/components/panels/NewsPanel.svelteindex 020c355..96f2be6 100644--- a/src/lib/components/panels/NewsPanel.svelte+++ b/src/lib/components/panels/NewsPanel.svelte@@ -2,14 +2,7 @@import { Panel, NewsItem } from '$lib/components/common';import type { NewsCategory } from '$lib/types';import type { PanelId } from '$lib/config';- import {- politicsNews,- techNews,- financeNews,- govNews,- aiNews,- intelNews- } from '$lib/stores';+ import { politicsNews, techNews, financeNews, govNews, aiNews, intelNews } from '$lib/stores';interface Props {category: NewsCategory;diff --git a/src/lib/config/api.ts b/src/lib/config/api.tsnew file mode 100644index 0000000..8b64cbb--- /dev/null+++ b/src/lib/config/api.ts@@ -0,0 +1,60 @@+/**+ * API Configuration+ */++import { browser } from '$app/environment';++/**+ * Check if we're in development mode+ * Uses import.meta.env which is available in both browser and test environments+ */+const isDev = browser ? (import.meta.env?.DEV ?? false) : false;++/**+ * CORS proxy URL for external API requests+ */+export const CORS_PROXY_URL = 'https://situation-monitor-proxy.seanthielen-e.workers.dev/?url=';++/**+ * API request delays (ms) to avoid rate limiting+ */+export const API_DELAYS = {+ betweenCategories: 500,+ betweenRetries: 1000+} as const;++/**+ * Cache TTLs (ms)+ */+export const CACHE_TTLS = {+ weather: 10 * 60 * 1000, // 10 minutes+ news: 5 * 60 * 1000, // 5 minutes+ markets: 60 * 1000, // 1 minute+ default: 5 * 60 * 1000 // 5 minutes+} as const;++/**+ * Debug/logging configuration+ */+export const DEBUG = {+ enabled: isDev,+ logApiCalls: isDev,+ logCacheHits: false+} as const;++/**+ * Conditional logger - only logs in development+ */+export const logger = {+ log: (prefix: string, ...args: unknown[]) => {+ if (DEBUG.logApiCalls) {+ console.log(`[${prefix}]`, ...args);+ }+ },+ warn: (prefix: string, ...args: unknown[]) => {+ console.warn(`[${prefix}]`, ...args);+ },+ error: (prefix: string, ...args: unknown[]) => {+ console.error(`[${prefix}]`, ...args);+ }+};diff --git a/src/lib/config/feeds.ts b/src/lib/config/feeds.tsindex 22ff7ce..172c50e 100644--- a/src/lib/config/feeds.ts+++ b/src/lib/config/feeds.ts@@ -69,7 +69,12 @@ export const INTEL_SOURCES: IntelSource[] = [type: 'think-tank',topics: ['policy', 'geopolitics']},- { name: 'CFR', url: 'https://www.cfr.org/rss.xml', type: 'think-tank', topics: ['foreign-policy'] },+ {+ name: 'CFR',+ url: 'https://www.cfr.org/rss.xml',+ type: 'think-tank',+ topics: ['foreign-policy']+ },{name: 'Defense One',url: 'https://www.defenseone.com/rss/all/',diff --git a/src/lib/config/index.ts b/src/lib/config/index.tsindex aeca6cd..1be3c22 100644--- a/src/lib/config/index.ts+++ b/src/lib/config/index.ts@@ -78,3 +78,6 @@ export {PRESET_STORAGE_KEY,type Preset} from './presets';++// API configuration+export { CORS_PROXY_URL, API_DELAYS, CACHE_TTLS, DEBUG, logger } from './api';diff --git a/src/lib/config/keywords.ts b/src/lib/config/keywords.tsindex dfa605f..2166473 100644--- a/src/lib/config/keywords.ts+++ b/src/lib/config/keywords.ts@@ -71,16 +71,7 @@ export const REGION_KEYWORDS: Record<string, string[]> = {export const TOPIC_KEYWORDS: Record<string, string[]> = {CYBER: ['cyber', 'hack', 'ransomware', 'malware', 'breach', 'apt', 'vulnerability'],NUCLEAR: ['nuclear', 'icbm', 'warhead', 'nonproliferation', 'uranium', 'plutonium'],- CONFLICT: [- 'war',- 'military',- 'troops',- 'invasion',- 'strike',- 'missile',- 'combat',- 'offensive'- ],+ CONFLICT: ['war', 'military', 'troops', 'invasion', 'strike', 'missile', 'combat', 'offensive'],INTEL: ['intelligence', 'espionage', 'spy', 'cia', 'mossad', 'fsb', 'covert'],DEFENSE: ['pentagon', 'dod', 'defense', 'military', 'army', 'navy', 'air force'],DIPLO: ['diplomat', 'embassy', 'treaty', 'sanctions', 'talks', 'summit', 'bilateral']diff --git a/src/lib/config/map.ts b/src/lib/config/map.tsindex 4f05067..262f3eb 100644--- a/src/lib/config/map.ts+++ b/src/lib/config/map.ts@@ -251,7 +251,12 @@ export const CONFLICT_ZONES: ConflictZone[] = [];export const CHOKEPOINTS: Chokepoint[] = [- { name: 'Suez', lat: 30.0, lon: 32.5, desc: 'Suez Canal — 12% of global trade, Europe-Asia route' },+ {+ name: 'Suez',+ lat: 30.0,+ lon: 32.5,+ desc: 'Suez Canal — 12% of global trade, Europe-Asia route'+ },{name: 'Panama',lat: 9.1,@@ -277,7 +282,12 @@ export const CHOKEPOINTS: Chokepoint[] = [desc: 'Bab el-Mandeb — Red Sea gateway, Houthi threat zone'},{ name: 'Gibraltar', lat: 36.0, lon: -5.5, desc: 'Strait of Gibraltar — Mediterranean access' },- { name: 'Bosporus', lat: 41.1, lon: 29.0, desc: 'Bosporus Strait — Black Sea access, Russia exports' }+ {+ name: 'Bosporus',+ lat: 41.1,+ lon: 29.0,+ desc: 'Bosporus Strait — Black Sea access, Russia exports'+ }];export const CABLE_LANDINGS: CableLanding[] = [diff --git a/src/lib/config/panels.ts b/src/lib/config/panels.tsindex 0dbd6d5..cc495c5 100644--- a/src/lib/config/panels.ts+++ b/src/lib/config/panels.ts@@ -17,6 +17,7 @@ export type PanelId =| 'markets'| 'monitors'| 'commodities'+ | 'crypto'| 'polymarket'| 'whales'| 'mainchar'@@ -41,6 +42,7 @@ export const PANELS: Record<PanelId, PanelConfig> = {markets: { name: 'Markets', priority: 1 },monitors: { name: 'My Monitors', priority: 1 },commodities: { name: 'Commodities / VIX', priority: 2 },+ crypto: { name: 'Crypto', priority: 2 },polymarket: { name: 'Polymarket', priority: 2 },whales: { name: 'Whale Watch', priority: 3 },mainchar: { name: 'Main Character', priority: 2 },diff --git a/src/lib/config/presets.ts b/src/lib/config/presets.tsindex 982bf1d..c2bf72d 100644--- a/src/lib/config/presets.ts+++ b/src/lib/config/presets.ts@@ -25,14 +25,34 @@ export const PRESETS: Record<string, Preset> = {name: 'Trader',icon: '📈',description: 'Market-focused dashboard with stocks, crypto, and commodities',- panels: ['markets', 'heatmap', 'commodities', 'polymarket', 'whales', 'printer', 'finance', 'map']+ panels: [+ 'markets',+ 'heatmap',+ 'commodities',+ 'crypto',+ 'polymarket',+ 'whales',+ 'printer',+ 'finance',+ 'map'+ ]},geopolitics: {id: 'geopolitics',name: 'Geopolitics Watcher',icon: '🌍',description: 'Global situation awareness and regional hotspots',- panels: ['map', 'intel', 'politics', 'gov', 'venezuela', 'greenland', 'iran', 'correlation', 'narrative']+ panels: [+ 'map',+ 'intel',+ 'politics',+ 'gov',+ 'venezuela',+ 'greenland',+ 'iran',+ 'correlation',+ 'narrative'+ ]},intel: {id: 'intel',@@ -54,16 +74,41 @@ export const PRESETS: Record<string, Preset> = {icon: '🎛️',description: 'Kitchen sink - all panels enabled',panels: [- 'map', 'politics', 'tech', 'finance', 'gov',- 'heatmap', 'markets', 'monitors', 'commodities',- 'polymarket', 'whales', 'mainchar', 'printer',- 'contracts', 'ai', 'layoffs', 'venezuela',- 'greenland', 'iran', 'intel', 'correlation', 'narrative'+ 'map',+ 'politics',+ 'tech',+ 'finance',+ 'gov',+ 'heatmap',+ 'markets',+ 'monitors',+ 'commodities',+ 'crypto',+ 'polymarket',+ 'whales',+ 'mainchar',+ 'printer',+ 'contracts',+ 'ai',+ 'layoffs',+ 'venezuela',+ 'greenland',+ 'iran',+ 'intel',+ 'correlation',+ 'narrative']}};-export const PRESET_ORDER = ['news-junkie', 'trader', 'geopolitics', 'intel', 'minimal', 'everything'];+export const PRESET_ORDER = [+ 'news-junkie',+ 'trader',+ 'geopolitics',+ 'intel',+ 'minimal',+ 'everything'+];// Storage keysexport const ONBOARDING_STORAGE_KEY = 'onboardingComplete';diff --git a/src/lib/services/deduplicator.test.ts b/src/lib/services/deduplicator.test.tsindex 187f442..83b37da 100644--- a/src/lib/services/deduplicator.test.ts+++ b/src/lib/services/deduplicator.test.ts@@ -73,10 +73,7 @@ describe('RequestDeduplicator', () => {describe('isInFlight', () => {it('should return true for in-flight requests', () => {- deduplicator.dedupe(- 'test-key',- () => new Promise((resolve) => setTimeout(resolve, 1000))- );+ deduplicator.dedupe('test-key', () => new Promise((resolve) => setTimeout(resolve, 1000)));expect(deduplicator.isInFlight('test-key')).toBe(true);});@@ -90,14 +87,8 @@ describe('RequestDeduplicator', () => {describe('getCount', () => {it('should return number of in-flight requests', () => {- deduplicator.dedupe(- 'key-1',- () => new Promise((resolve) => setTimeout(resolve, 1000))- );- deduplicator.dedupe(- 'key-2',- () => new Promise((resolve) => setTimeout(resolve, 1000))- );+ deduplicator.dedupe('key-1', () => new Promise((resolve) => setTimeout(resolve, 1000)));+ deduplicator.dedupe('key-2', () => new Promise((resolve) => setTimeout(resolve, 1000)));expect(deduplicator.getCount()).toBe(2);});@@ -105,14 +96,8 @@ describe('RequestDeduplicator', () => {describe('clear', () => {it('should clear all tracked requests', () => {- deduplicator.dedupe(- 'key-1',- () => new Promise((resolve) => setTimeout(resolve, 1000))- );- deduplicator.dedupe(- 'key-2',- () => new Promise((resolve) => setTimeout(resolve, 1000))- );+ deduplicator.dedupe('key-1', () => new Promise((resolve) => setTimeout(resolve, 1000)));+ deduplicator.dedupe('key-2', () => new Promise((resolve) => setTimeout(resolve, 1000)));deduplicator.clear();diff --git a/src/lib/services/deduplicator.ts b/src/lib/services/deduplicator.tsindex a411334..cc11a5c 100644--- a/src/lib/services/deduplicator.ts+++ b/src/lib/services/deduplicator.ts@@ -19,9 +19,11 @@ export class RequestDeduplicator {this.inFlight.set(key, promise);// Clean up when promise resolves or rejects- promise.finally(() => this.inFlight.delete(key)).catch(() => {- // Prevent unhandled rejection- });+ promise+ .finally(() => this.inFlight.delete(key))+ .catch(() => {+ // Prevent unhandled rejection+ });return promise;}diff --git a/src/lib/services/index.ts b/src/lib/services/index.tsindex e24ff17..bb647bc 100644--- a/src/lib/services/index.ts+++ b/src/lib/services/index.ts@@ -3,12 +3,7 @@*/// Errors-export {- ServiceError,- NetworkError,- TimeoutError,- CircuitOpenError-} from './errors';+export { ServiceError, NetworkError, TimeoutError, CircuitOpenError } from './errors';// Cache Managerexport {@@ -32,10 +27,7 @@ export {} from './circuit-breaker';// Request Deduplicator-export {- RequestDeduplicator,- requestDeduplicator-} from './deduplicator';+export { RequestDeduplicator, requestDeduplicator } from './deduplicator';// Service Registryexport {diff --git a/src/lib/stores/index.ts b/src/lib/stores/index.tsindex 2a9b360..5ef632f 100644--- a/src/lib/stores/index.ts+++ b/src/lib/stores/index.ts@@ -32,6 +32,7 @@ export {govNews,aiNews,intelNews,+ allNewsItems,alerts,isLoading as isNewsLoading,hasErrors as hasNewsErrors,diff --git a/src/lib/stores/markets.test.ts b/src/lib/stores/markets.test.tsindex 25051ad..43fdd03 100644--- a/src/lib/stores/markets.test.ts+++ b/src/lib/stores/markets.test.ts@@ -125,7 +125,9 @@ describe('Markets Store', () => {it('should update single market item', async () => {const { markets, indices } = await import('./markets');- markets.setIndices([{ symbol: '^DJI', name: 'Dow', price: 38000, change: 0, changePercent: 0 }]);+ markets.setIndices([+ { symbol: '^DJI', name: 'Dow', price: 38000, change: 0, changePercent: 0 }+ ]);markets.updateItem('indices', '^DJI', { price: 38100, change: 100, changePercent: 0.26 });diff --git a/src/lib/stores/news.ts b/src/lib/stores/news.tsindex 2eace53..6b13a48 100644--- a/src/lib/stores/news.ts+++ b/src/lib/stores/news.ts@@ -221,6 +221,15 @@ export const govNews = derived(news, ($news) => $news.categories.gov);export const aiNews = derived(news, ($news) => $news.categories.ai);export const intelNews = derived(news, ($news) => $news.categories.intel);+// Derived store for all news items (reactive)+export const allNewsItems = derived(news, ($news) => {+ const allItems: NewsItem[] = [];+ for (const category of NEWS_CATEGORIES) {+ allItems.push(...$news.categories[category].items);+ }+ return allItems;+});+// Derived store for alertsexport const alerts = derived(news, ($news) => {const allAlerts: NewsItem[] = [];diff --git a/src/lib/stores/refresh.ts b/src/lib/stores/refresh.tsindex 5a765b5..6cb52f6 100644--- a/src/lib/stores/refresh.ts+++ b/src/lib/stores/refresh.ts@@ -225,7 +225,7 @@ function createRefreshStore() {[category]: {...state.categoryStates[category],loading,- error: loading ? null : state.categoryStates[category]?.error ?? null,+ error: loading ? null : (state.categoryStates[category]?.error ?? null),lastUpdated: state.categoryStates[category]?.lastUpdated ?? null}}diff --git a/src/routes/+page.svelte b/src/routes/+page.svelteindex e32c6fb..212f19e 100644--- a/src/routes/+page.svelte+++ b/src/routes/+page.svelte@@ -142,7 +142,8 @@}// Get panel visibility- const isPanelVisible = (id: string) => $settings.enabled[id as keyof typeof $settings.enabled] !== false;+ const isPanelVisible = (id: string) =>+ $settings.enabled[id as keyof typeof $settings.enabled] !== false;// Handle preset selection from onboardingfunction handleSelectPreset(presetId: string) {@@ -183,10 +184,7 @@</svelte:head><div class="app">- <Header- onRefresh={handleRefresh}- onSettingsClick={() => (settingsOpen = true)}- />+ <Header onRefresh={handleRefresh} onSettingsClick={() => (settingsOpen = true)} /><main class="main-content"><Dashboard>@@ -330,24 +328,35 @@</div>{/if}- {#if isPanelVisible('iran')}- <div class="panel-slot">- <SituationPanel- panelId="iran"- config={{- title: 'Iran Crisis',- subtitle: 'Revolution protests, regime instability & nuclear program',- criticalKeywords: ['protest', 'uprising', 'revolution', 'crackdown', 'killed', 'nuclear', 'strike', 'attack', 'irgc', 'khamenei']- }}- news={allNewsItems.filter(- (n) =>- n.title.toLowerCase().includes('iran') ||- n.title.toLowerCase().includes('tehran') ||- n.title.toLowerCase().includes('irgc')- )}- />- </div>- {/if}+ {#if isPanelVisible('iran')}+ <div class="panel-slot">+ <SituationPanel+ panelId="iran"+ config={{+ title: 'Iran Crisis',+ subtitle: 'Revolution protests, regime instability & nuclear program',+ criticalKeywords: [+ 'protest',+ 'uprising',+ 'revolution',+ 'crackdown',+ 'killed',+ 'nuclear',+ 'strike',+ 'attack',+ 'irgc',+ 'khamenei'+ ]+ }}+ news={allNewsItems.filter(+ (n) =>+ n.title.toLowerCase().includes('iran') ||+ n.title.toLowerCase().includes('tehran') ||+ n.title.toLowerCase().includes('irgc')+ )}+ />+ </div>+ {/if}<!-- Placeholder panels for additional data sources -->{#if isPanelVisible('whales')}@@ -387,10 +396,7 @@onClose={() => (monitorFormOpen = false)}editMonitor={editingMonitor}/>- <OnboardingModal- open={onboardingOpen}- onSelectPreset={handleSelectPreset}- />+ <OnboardingModal open={onboardingOpen} onSelectPreset={handleSelectPreset} /></div><style>