Merge main through #1637 into the renderer seam

Ports the cockpit bridge view, the orbital view riding a satellite with
ground-site focus, satellite classes and draw-mark row actions onto the
renderer contract. The orbital view's imagery look-ahead pre-load is
dropped (no contract member); tiles load as they come on screen.
This commit is contained in:
Sameh Khamis committed 2026-11-10 01:35:00 -08:00
commit e48ed3eb9e
169 files changed
+22415 -681

No files matched your search

+200 -7
View File
@@ -1,8 +1,13 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { parseTleText, tleLineLaunchYear } from '../../sources/tle.js';
import { createIngestion } from './ingestion.js';
import {
SATCAT_KEEP_MS,
SATCAT_WAIT_MS,
createIngestion,
} from './ingestion.js';
import { createOrbits } from './orbits.js';
import { createControls } from './controls.js';
// The ISS set (1 January 2024) with its catalog field swapped per satellite.
const ISS_LINE1 =
@@ -23,7 +28,7 @@ const orbitParts = {
rendering: { _rendererPositions: (positions) => positions },
};
function ingestionFor(catalogText) {
function ingestionFor(catalogText, { source: sourceExtras = {} } = {}) {
const state = {
_trackingRefreshEpoch: 0,
_activeUpdateControllers: new Set(),
@@ -34,6 +39,8 @@ function ingestionFor(catalogText) {
_denseLoadToken: 0,
_catalogRevision: 0,
_params: { catalog: 'core', showOrbits: false },
_satcat: new Map(),
_ucs: null,
now: Date.now,
coverageChanged() {},
};
@@ -43,7 +50,17 @@ function ingestionFor(catalogText) {
propagatePosition: () => ({ longitude: 0, latitude: 0, altitude: 4e5 }),
},
labels: { _syncIssOverlay() {} },
controls: { _pointStyleFor: () => ({}) },
controls: {
_pointStyleFor: () => ({}),
_classVisible: () => true,
_syncIssOrbit() {},
_applyClassVisibility() {
state.visibilityApplied = (state.visibilityApplied || 0) + 1;
},
_notifyRowControls() {
state.rowNotified = (state.rowNotified || 0) + 1;
},
},
rendering: {
_clearPoints() {
state._points.clear();
@@ -51,9 +68,10 @@ function ingestionFor(catalogText) {
_clearOrbitPaths() {
state._orbitPaths.clear();
},
_addPoint(noradId, position) {
state._points.set(noradId, { position });
_addPoint(noradId, position, style, show = true) {
state._points.set(noradId, { position, show });
},
_setPointStyle() {},
_showOrbitPath() {},
_setOrbitPathShown() {},
},
@@ -64,9 +82,12 @@ function ingestionFor(catalogText) {
catalog: {},
};
const source = {
async readGroup() {
return { ok: true, text: catalogText };
async readGroup(path) {
const text =
typeof catalogText === 'function' ? catalogText(path) : catalogText;
return { ok: true, text };
},
...sourceExtras,
};
const { methods } = createIngestion({ state, services: {}, parts, source });
return { state, update: () => methods.update({}) };
@@ -134,3 +155,175 @@ test('a satellite with a blank designator keeps matching by name', async (t) =>
69728,
);
});
test('a hanging SATCAT read neither holds the catalog nor is lost when it lands', async (t) => {
t.mock.method(console, 'log', () => {});
t.mock.method(console, 'warn', () => {});
t.mock.timers.enable({ apis: ['setTimeout'] });
let answer;
const satcatAnswer = new Promise((resolve) => {
answer = resolve;
});
const { state, update } = ingestionFor(
(path) => (path === 'stations' ? tleSet('OLD STAGE', '40115') : ''),
{ source: { readSatcat: () => satcatAnswer } },
);
state._enabled = true;
const settle = async () => {
for (let turn = 0; turn < 20; turn += 1)
await new Promise((resolve) => setImmediate(resolve));
};
const rebuilt = update();
await settle();
t.mock.timers.tick(SATCAT_WAIT_MS);
await rebuilt;
// Built without SATCAT: neither name nor group says what it is (the
// stations group alone makes no station).
assert.equal(state._catalog.get(40115).satelliteClass, 'probes');
const revision = state._catalogRevision;
// SATCAT lands late: a rocket body.
answer({
ok: true,
stale: true,
text: 'OBJECT_NAME,OBJECT_ID,NORAD_CAT_ID,OBJECT_TYPE,OPS_STATUS_CODE,OWNER\nOLD STAGE,2014-048B,40115,R/B,,US',
});
await settle();
assert.equal(state._catalog.get(40115).satelliteClass, 'debris');
assert.equal(state._catalogRevision, revision + 1, 'the legend refreshes');
assert.ok(state.visibilityApplied >= 1 && state.rowNotified >= 1);
assert.equal(state._satcatState, 'stale', 'its staleness is kept');
});
test('a satellite in visual and resource is imaging, whichever group shows it', async (t) => {
t.mock.method(console, 'log', () => {});
t.mock.method(console, 'warn', () => {});
// A name no pattern knows, no UCS record and no SATCAT: only its groups.
const { state, update } = ingestionFor((path) =>
path === 'visual' || path === 'resource'
? tleSet('ZZ TESTSAT', '50001')
: '',
);
await update();
const sat = state._catalog.get(50001);
assert.equal(sat.group, 'visual', 'shown under the first group');
assert.deepEqual(sat.groups, ['visual', 'resource']);
assert.equal(sat.satelliteClass, 'imaging');
});
test('a stale SATCAT copy never overrules a current read of the same object', async (t) => {
t.mock.method(console, 'log', () => {});
t.mock.method(console, 'warn', () => {});
const header =
'OBJECT_NAME,OBJECT_ID,NORAD_CAT_ID,OBJECT_TYPE,OPS_STATUS_CODE,OWNER\n';
const { state, update } = ingestionFor(tleSet('ZZ TESTSAT', '50002'), {
source: {
// visual is current and says it died; resource, a cached copy, still
// says it works.
readSatcat: async (path) =>
path === 'visual'
? { ok: true, text: `${header}ZZ TESTSAT,2015-001A,50002,PAY,-,US` }
: path === 'resource'
? {
ok: true,
stale: true,
text: `${header}ZZ TESTSAT,2015-001A,50002,PAY,+,US`,
}
: { ok: true, text: header },
},
});
await update();
assert.equal(state._catalog.get(50002).satelliteClass, 'debris');
});
test('a failed SATCAT read is told on the layer row, not only the console', async (t) => {
t.mock.method(console, 'log', () => {});
t.mock.method(console, 'warn', () => {});
const { state, update } = ingestionFor(tleSet('OLD STAGE', '40115'), {
source: { readSatcat: async () => ({ ok: false, text: '' }) },
});
await update();
assert.equal(state._satcatState, 'unavailable');
assert.ok(state.rowNotified >= 1, 'the row repaints');
const controls = createControls({
state: {
...state,
_params: { ...state._params, showPoints: true },
_classTallyCache: {},
},
services: { layerState: { isExplicitLayerStateOrigin: () => false } },
parts: {},
source: {},
});
const row = controls.methods.getRowControls();
assert.equal(row.info, 'Classes may lag: SATCAT unavailable');
assert.match(row.infoTitle, /SATCAT/);
const current = createControls({
state: {
...state,
_satcatState: 'current',
_params: { ...state._params, showPoints: true },
_classTallyCache: {},
},
services: { layerState: { isExplicitLayerStateOrigin: () => false } },
parts: {},
source: {},
});
assert.equal(current.methods.getRowControls().info, '');
});
test('a current SATCAT read is kept between updates; a failed one is asked again', async (t) => {
t.mock.method(console, 'log', () => {});
t.mock.method(console, 'warn', () => {});
const header =
'OBJECT_NAME,OBJECT_ID,NORAD_CAT_ID,OBJECT_TYPE,OPS_STATUS_CODE\n';
let reads = 0;
let ok = true;
const { state, update } = ingestionFor(tleSet('ZZ TESTSAT', '50003'), {
source: {
readSatcat: async () => {
reads++;
return ok
? { ok: true, text: `${header}ZZ TESTSAT,2015-001A,50003,PAY,-` }
: { ok: false, text: '' };
},
},
});
await update();
const perUpdate = reads;
assert.ok(perUpdate > 0);
await update();
assert.equal(reads, perUpdate, 'a fresh read is not asked again');
assert.equal(
state._catalog.get(50003).satelliteClass,
'debris',
'the held records still class the rebuilt catalog',
);
state._satcatReadAtMs -= SATCAT_KEEP_MS;
ok = false;
await update();
assert.equal(reads, 2 * perUpdate, 'an old read is asked again');
assert.equal(state._satcatState, 'unavailable');
await update();
assert.equal(reads, 3 * perUpdate, 'a failed read is asked again');
});
test('a failed imaging-sensor pack is warned about, as the UCS pack is', async (t) => {
t.mock.method(console, 'log', () => {});
const warn = t.mock.method(console, 'warn', () => {});
const { state, update } = ingestionFor(tleSet('OLD STAGE', '40115'), {
source: {
readSensors: async () => {
throw new Error('chunk failed');
},
},
});
await update();
assert.ok(
warn.mock.calls.some((call) =>
/sensor pack unavailable/i.test(call.arguments[0]),
),
'the failure is not swallowed',
);
assert.equal(state._catalog.get(40115).sensor, null, 'base zoom steps');
});