diff --git a/.env.example b/.env.example index 5bc02df9c..1949c48f4 100644 --- a/.env.example +++ b/.env.example @@ -129,18 +129,20 @@ AISSTREAM_API_KEY= # 0 disables the silence watch entirely. # AISSTREAM_SILENCE_TIMEOUT_MS=120000 -# Optional: TomTom live traffic flow (BYOK freemium — free tier is ~50,000 tile -# requests/day, get a key at https://developer.tomtom.com). SERVER-SIDE ONLY: +# Optional: TomTom live traffic flow (BYOK freemium — the free tier is 200,000 +# Traffic Flow & Incidents tile requests per MONTH, not per day; no credit card +# required. Get a key at https://developer.tomtom.com). SERVER-SIDE ONLY: # the browser fetches same-origin /api/tomtom/* and never sees the key. # Keyless fallback: the traffic layer runs its built-in simulation (white dots, # hardcoded per-road-class speeds) — no key required for the layer to work. # TOMTOM_API_KEY= -# Optional soft cap on upstream tile fetches per UTC day (default 40000) — a +# Optional soft cap on upstream tile fetches per UTC day (default 6000) — a # configurable application safety ceiling, not a guarantee of staying within # TomTom's free allowance (currently 200K tile requests/month: -# https://docs.tomtom.com/pricing/). Over the cap the proxy serves cached/stale -# tiles instead of hitting upstream. -# TOMTOM_DAILY_TILE_BUDGET=40000 +# https://docs.tomtom.com/pricing/). 6000/day keeps a 31-day month at 186K, +# inside that allowance. Over the cap the proxy serves cached/stale tiles +# instead of hitting upstream. +# TOMTOM_DAILY_TILE_BUDGET=6000 # Optional: CCTV layer tuning (advanced). Defaults are sensible — leave unset # unless you're customizing the camera source pack. diff --git a/.gitignore b/.gitignore index 491a82c15..1a64fff39 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,13 @@ node_modules dist +# Credential files. `.env` alone is not enough: Vite's loadEnv (see +# server/standalone/vite.config.js) and scripts/setup-doctor.mjs both read the +# full dotenv ladder — .env, .env.local, .env. and .env..local — +# so a key placed in any of them is live for the app. Only .env was ignored, +# leaving the other three committable. .env.example is the tracked template. .env +.env.* +!.env.example *.log screenshots/ qa-shots/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b5622678..c63e33945 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,27 @@ unknown instead of 102.3 knots and 360 degrees. Genuine readings, including a stopped vessel's zero and the highest encodable values, are unchanged. +- Render native `` controls declare a dark colour scheme and explicit option +colours, so the browser-painted option list matches the panel it drops out of. +The scheme is declared on the controls rather than on the document root, so +hand-tuned scrollbar and text-input skins are unchanged. Applies to the HUD +layout, Scenes, CCTV camera, Radio filter and Draw colour menus. + Vessel snapshot completeness is separate from freshness. A current snapshot with rejected or duplicate records shows PARTIAL with accepted/received counts; stale or unknown freshness and transport failures retain their warnings. Partial @@ -3808,7 +3814,8 @@ easier to meet (detection is now on more often), but does not create it. - Traffic runs in `sim` mode (white dots, hardcoded speeds) unless `TOMTOM_API_KEY` is configured (env or Keychain `tomtom-api`/`api-key`), which enables `live` mode: TomTom flow vector tiles via the budget-governed `/api/tomtom` proxy - (`.gev-cache/tomtom/`, 120 s TTL, `TOMTOM_DAILY_TILE_BUDGET` default 40k/day), + (`.gev-cache/tomtom/`, 120 s TTL, `TOMTOM_DAILY_TILE_BUDGET` default 6k/day, + sized so a 31-day month stays inside TomTom's 200K/month free allowance), decoded client-side (`flowTiles.js`), matched onto Overpass roads (`flowMatch.js`), and rendered as green/amber/red dot color + speed/density scaling (`trafficFlowStyle.js`); closures spawn no dots; unmatched roads stay diff --git a/scripts/format-scope.json b/scripts/format-scope.json index dc623c0c0..2ed4f1081 100644 --- a/scripts/format-scope.json +++ b/scripts/format-scope.json @@ -495,6 +495,7 @@ "src/layers/cctv/source.test.mjs", "src/data/alprCameras.js", "src/data/alprCameras.test.mjs", + "src/data/dataCredits.test.mjs", "src/layers/alpr/index.js", "src/layers/alpr/model.js", "src/layers/alpr/policy.js", diff --git a/server/providers/traffic.js b/server/providers/traffic.js index fda118753..2a3c2e60a 100644 --- a/server/providers/traffic.js +++ b/server/providers/traffic.js @@ -23,9 +23,16 @@ import { * Budget governor (mirrors the OpenSky credit-governor philosophy — last-good * data beats a dead layer): a persistent counter (.gev-cache/tomtom/budget.json, * keyed by UTC date, reset on day change) counts upstream fetch attempts - * against a soft cap (TOMTOM_DAILY_TILE_BUDGET, default 40,000 of the free - * tier's ~50k/day). Over the cap the proxy serves stale tiles when available, - * else 429 {error:'budget'}. + * against a soft cap (TOMTOM_DAILY_TILE_BUDGET). Over the cap the proxy + * serves stale tiles when available, else 429 {error:'budget'}. + * + * The default is derived from TomTom's published free allowance, which is + * granted MONTHLY, not daily: 200,000 Traffic Flow & Incidents tile requests + * per month (https://docs.tomtom.com/pricing/). The previous 40,000/day + * default — and the "~50k/day" figure this comment used to cite — exhausted + * a month's entire allowance in five days, leaving the traffic layer dead + * for the rest of the billing period. 6,000/day keeps a full 31-day month + * inside the allowance (186,000) with headroom to spare. * * GET /api/tomtom/status → {hasKey, dailyCount, budget, date}. Keyless mode: * status reports hasKey:false and the tile endpoint 503s {error:'no_key'} @@ -37,7 +44,8 @@ export function tomtomProxy() { const TILE_TTL_MS = 120_000; const CACHE_DIR = path.join(process.cwd(), '.gev-cache', 'tomtom'); const BUDGET_PATH = path.join(CACHE_DIR, 'budget.json'); - const DEFAULT_DAILY_BUDGET = 40000; + // 200,000/month free tier / 31 days = 6,451. Rounded down for headroom. + const DEFAULT_DAILY_BUDGET = 6000; const MEM_MAX_ENTRIES = 256; const UPSTREAM_TIMEOUT_MS = 15000; diff --git a/src/data/dataCredits.js b/src/data/dataCredits.js index 76029ace8..dde7d3b62 100644 --- a/src/data/dataCredits.js +++ b/src/data/dataCredits.js @@ -42,6 +42,17 @@ export const DATA_CREDITS = [ 'adsb.lol ' + '(ODbL 1.0)', }, + { + key: 'adsbdb', + html: + 'Aircraft type, registration & flight routes: ' + + 'adsbdb ' + + '· aircraft data from PlaneBase · ICAO-to-N-number conversion by ' + + 'Guillaume Michel · route data is the work of ' + + 'David Taylor, Edinburgh, and Jim Mason, Glasgow, and may not be ' + + 'copied, published, or incorporated into other databases without the ' + + 'explicit permission of David J Taylor, Edinburgh', + }, { key: 'aisstream', html: diff --git a/src/data/dataCredits.test.mjs b/src/data/dataCredits.test.mjs new file mode 100644 index 000000000..5172867c4 --- /dev/null +++ b/src/data/dataCredits.test.mjs @@ -0,0 +1,39 @@ +import { test } from 'node:test'; +import assert from 'node:assert/strict'; +import { DATA_CREDITS } from './dataCredits.js'; + +test('every credit carries a unique key and some markup to render', () => { + const keys = DATA_CREDITS.map((entry) => entry.key); + assert.equal( + new Set(keys).size, + keys.length, + 'a duplicate key would silently shadow one provider’s credit', + ); + for (const entry of DATA_CREDITS) { + assert.ok(entry.key, 'a credit without a key cannot be registered'); + assert.ok( + entry.html && entry.html.trim().length > 0, + `credit ${entry.key} has nothing to show`, + ); + } +}); + +test('adsbdb is credited and carries its published route-data restriction', () => { + const credit = DATA_CREDITS.find((entry) => entry.key === 'adsbdb'); + assert.ok( + credit, + 'adsbdb supplies aircraft type and routes and must be credited', + ); + // adsbdb publishes this restriction for its route data. Pin the provider's + // credits and restriction here so a later edit cannot silently remove them. + assert.match(credit.html, /David Taylor, Edinburgh/); + assert.match(credit.html, /Jim Mason, Glasgow/); + assert.match( + credit.html, + /may not be\s+copied, published, or incorporated into other databases/, + ); + assert.match(credit.html, /explicit permission of David J Taylor, Edinburgh/); + assert.match(credit.html, /PlaneBase/); + assert.match(credit.html, /Guillaume Michel/); + assert.match(credit.html, /href="https:\/\/www\.adsbdb\.com"/); +}); diff --git a/src/ui/styles/foundation.css b/src/ui/styles/foundation.css index 828eb9922..2d374b2c6 100644 --- a/src/ui/styles/foundation.css +++ b/src/ui/styles/foundation.css @@ -14,6 +14,8 @@ --text-primary: #e8eaed; --text-secondary: rgba(232, 234, 237, 0.5); --text-dim: rgba(232, 234, 237, 0.3); + /* Opaque surface for browser-painted menus, which cannot use --glass-bg. */ + --menu-bg: #12121c; --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace; --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; --panel-radius: 16px; @@ -69,6 +71,26 @@ outline-offset: 2px; } +/* Native `