Merge origin/main into german/navara

Main's camera, voice, Cockpit and layer work now runs on the globe
contract where this branch draws through it:

- The voice tilt to an angle, its pivot about the place under the
  crosshair and the frame limit from orbit run through the camera rig;
  src/globeInView.js measures a camera pose with src/geo instead of a
  Cesium camera. The free-look height limit and the globe-in-view
  recovery stay Cesium-only for now.
- Cockpit takes main's own-layer entry rule. Double-clicking the
  followed track goes through cockpitHost.routeDoubleClick, so it works
  on both engines.
- Space Missions' failed-entry rollback and GhostMaps' age filter run
  in the engine-neutral layer code. On Cesium an expired report is
  dropped in place; on Navara its product is redrawn.
- Wildlife Sightings joins the catalog Cesium-only: Navara leaves it
  out, and the shell builds its card only for the real layer, so a
  Navara page no longer fails to start on its stand-in.
- One instruction sentence is shorter, which keeps the Realtime prompt
  within its 55,500-character budget with the Sentinel-2 basemap.
This commit is contained in:
German Khokhlov committed 2026-11-07 01:07:26 +04:00
commit 92c8f8d9da
262 files changed
+32378 -959

No files matched your search

+12 -7
View File
@@ -1,21 +1,26 @@
/** Bounded per-key and aggregate request admission. */
const RATE_LIMITER_MAX_KEYS = 2000;
export function makeRateLimiter({ windowMs, max, globalMax }) {
export function makeRateLimiter({
windowMs,
max,
globalMax,
now = () => Date.now(),
}) {
const hits = new Map(); // key -> number[] (timestamps within window)
let globalTimes = []; // all hits in window, for the global backstop
return function allow(key) {
const now = Date.now();
globalTimes = globalTimes.filter((t) => now - t < windowMs);
const at = now();
globalTimes = globalTimes.filter((t) => at - t < windowMs);
if (globalMax && globalTimes.length >= globalMax) return false; // global backstop
const recent = (hits.get(key) || []).filter((t) => now - t < windowMs);
const recent = (hits.get(key) || []).filter((t) => at - t < windowMs);
if (recent.length >= max) {
hits.set(key, recent);
return false;
}
recent.push(now);
recent.push(at);
hits.set(key, recent);
globalTimes.push(now);
globalTimes.push(at);
// Hard key cap so a key-rotating caller can't grow the map without bound.
if (hits.size > RATE_LIMITER_MAX_KEYS) {
const oldest = hits.keys().next().value;
@@ -23,7 +28,7 @@ export function makeRateLimiter({ windowMs, max, globalMax }) {
}
if (hits.size > 256) {
for (const [k, v] of hits) {
if (!v.length || now - v[v.length - 1] > windowMs) hits.delete(k);
if (!v.length || at - v[v.length - 1] > windowMs) hits.delete(k);
}
}
return true;
+23
View File
@@ -0,0 +1,23 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { makeRateLimiter } from './rateLimit.js';
test('injected time drives per-client and global rolling limits', () => {
let at = 1000;
const allow = makeRateLimiter({
windowMs: 60_000,
max: 2,
globalMax: 3,
now: () => at,
});
assert.equal(allow('a'), true);
assert.equal(allow('a'), true);
assert.equal(allow('a'), false);
assert.equal(allow('b'), true);
assert.equal(allow('c'), false);
at += 59_999;
assert.equal(allow('a'), false);
at += 1;
assert.equal(allow('a'), true);
assert.equal(allow('c'), true);
});
+2
View File
@@ -4,6 +4,7 @@ import { createWfigsPerimeterSource } from '../layers/perimeters/source.js';
import { createDroneAirspaceSource } from '../layers/droneAirspace/source.js';
import { createBundledCableSource } from '../layers/submarineCables/bundledSource.js';
import { createAdsbGnssSource } from '../layers/gnss/source.js';
import { createWildlifeSightingsSource } from '../layers/wildlifeSightings/source.js';
/** Construct the existing reference feeds independently of application setup. */
export function createReferenceSources() {
@@ -12,6 +13,7 @@ export function createReferenceSources() {
'air-quality': createEcccAirQualitySource(),
'fire-perimeters': createWfigsPerimeterSource(),
'drone-airspace': createDroneAirspaceSource(),
'wildlife-sightings': createWildlifeSightingsSource(),
cables: createBundledCableSource(),
'gnss-integrity': createAdsbGnssSource(),
};
+3
View File
@@ -17,6 +17,7 @@ test('reference factories retain compatibility without starting acquisition or s
'air-quality',
'fire-perimeters',
'drone-airspace',
'wildlife-sightings',
'cables',
'gnss-integrity',
]);
@@ -24,12 +25,14 @@ test('reference factories retain compatibility without starting acquisition or s
assert.notEqual(first['air-quality'], second['air-quality']);
assert.notEqual(first['fire-perimeters'], second['fire-perimeters']);
assert.notEqual(first['drone-airspace'], second['drone-airspace']);
assert.notEqual(first['wildlife-sightings'], second['wildlife-sightings']);
assert.notEqual(first.cables, second.cables);
assert.notEqual(first['gnss-integrity'], second['gnss-integrity']);
assert.equal(typeof first.earthquakes.getSnapshot, 'function');
assert.equal(typeof first['air-quality'].getSnapshot, 'function');
assert.equal(typeof first['fire-perimeters'].getSnapshot, 'function');
assert.equal(typeof first['drone-airspace'].getSnapshot, 'function');
assert.equal(typeof first['wildlife-sightings'].getSnapshot, 'function');
assert.equal(typeof first.cables.fetch, 'function');
assert.equal(typeof first['gnss-integrity'].getSnapshot, 'function');
assert.equal(requests, 0);