Merge main into denis/iss-live-telemetry

Conflicts: the locale catalogs and package boundaries are three-way merges
(no message changed differently on both sides); zh-Hant is regenerated
from zh-CN. bhoteKoshiEmbeddedMedia.js keeps main's card counter and the
branch's shared YouTube loader (youtubeApi.js), so the media file builds
one script element fewer. The Cockpit briefing's LIVE tab and the orbital
NADIR/RESET button are main's UiButton.
This commit is contained in:
Denis Groshev committed 2026-11-20 10:50:16 +01:00
commit edbf3a234d
244 files changed
+11747 -1273

No files matched your search

+2 -1
View File
@@ -13,7 +13,8 @@ export const useBhoteKoshiPanelStore = defineStore(
/**
* `{owner, sceneBeat, refs, beforeDate, afterDate, reports}`, or null while
* the event layer is off. Each entry of `refs` holds one control's
* `textContent`, `hidden`, `disabled`, `value` and `attributes`.
* `textContent`, `hidden`, `disabled`, `value` and `attributes`; the
* cinematic button's also holds `pressed`.
*/
const panel = shallowRef(null);
+125
View File
@@ -93,6 +93,26 @@ export const useEntityCardStore = defineStore('gev-entity-card', () => {
const lost = ref(false);
/** Bumped on each refresh, so ages shown on the card tick. */
const tick = ref(0);
/**
* True while the item is not to be seen: out of its feed, off screen or
* behind the globe. The card then offers to find it.
*/
const away = ref(false);
/**
* Finding the item again (see locate): `'idle'`, `'finding'` while its
* layer looks it up, or `'none'` when it has no reading at the time.
*/
const finding = ref('idle');
/**
* Where an item out of its feed was found (see locate):
* `{lat, lon, altitudeM, observedAtMs, atMs}`, or null.
*/
const located = shallowRef(null);
/** The track reference of the card's item, kept for when it leaves its feed. */
let reference = null;
let locating = null;
/** An aircraft found again is followed once it is back in its feed. */
let followWhenBack = false;
/**
* What the camera shows, for the panel to describe when nothing is picked:
* `{center: {lat, lon}, rect: {west, south, east, north}, heightM}`.
@@ -229,12 +249,105 @@ export const useEntityCardStore = defineStore('gev-entity-card', () => {
// Keep showing the last reading when the item drops out of its feed.
if (!next || next.key !== current.key || next.basis !== 'record') {
lost.value = current.basis === 'record';
away.value = lost.value || !shown(current);
tick.value++;
return;
}
const wasLost = lost.value;
card.value = markRaw(next);
lost.value = false;
// The camera follows it where it is drawn, which can be ahead of its last
// reading; one being followed is always in view.
away.value = !isFollowing() && !shown(next);
tick.value++;
if (wasLost) back(next);
}
/** Whether the camera shows the item; true when the shell cannot tell. */
function shown(current) {
const test = shell.value?.onScreen;
return typeof test === 'function' ? test(current) !== false : true;
}
/**
* The item is back in its feed: its layer selects it again, as the click
* that picked it did, and an aircraft just found is followed.
*/
function back(current) {
const follows = followWhenBack;
// A lookup still running is no longer needed: the feed has it.
stopLocating();
reference =
layerOf(current.layerId)?.referenceOf?.(current.identity?.id) ??
reference;
shell.value?.reselect?.(current, { follow: follows });
}
const layerOf = (layerId) =>
shell.value?.dataManager?.()?.layers?.get?.(layerId)?.module ?? null;
/**
* Take the camera back to the item. One the camera can see or one still in
* its feed is flown to (an aircraft followed); one out of its feed is
* looked up at the layer's time (the world clock's while it follows the
* clock) on its own track, shown there and flown to, and its layer picks
* it up again once its feed has it.
* @returns {Promise<void>}
*/
async function locate() {
const current = card.value;
if (!current) return;
if (!lost.value) {
if (canFollow()) follow();
else flyTo();
return;
}
const layer = layerOf(current.layerId);
if (typeof layer?.locate !== 'function') {
flyTo();
return;
}
locating?.abort();
const controller = new AbortController();
locating = controller;
finding.value = 'finding';
let result;
try {
result = await layer.locate(current.identity?.id, {
reference,
signal: controller.signal,
});
} catch {
result = { status: 'none' };
}
if (locating !== controller) return;
locating = null;
const now = card.value;
if (!now || now.key !== current.key) return;
if (result?.status !== 'found') {
finding.value = 'none';
return;
}
finding.value = 'idle';
located.value = markRaw({ ...result });
card.value = markRaw({
...now,
lat: result.lat,
lon: result.lon,
altitudeM: Number.isFinite(result.altitudeM)
? result.altitudeM
: now.altitudeM,
});
followWhenBack = canFollow();
shell.value?.flyTo?.(card.value);
}
function stopLocating() {
locating?.abort();
locating = null;
finding.value = 'idle';
located.value = null;
followWhenBack = false;
}
/**
@@ -261,6 +374,11 @@ export const useEntityCardStore = defineStore('gev-entity-card', () => {
*/
function select(identity, { fly = false, follow: autoFollow = true } = {}) {
if (!read(identity)) return false;
stopLocating();
away.value = false;
reference =
layerOf(identity.layerId)?.referenceOf?.(card.value?.identity?.id) ??
null;
clearInterval(timer);
timer = setInterval(refresh, REFRESH_MS);
shell.value?.openPanel?.();
@@ -292,6 +410,9 @@ export const useEntityCardStore = defineStore('gev-entity-card', () => {
timer = null;
card.value = null;
lost.value = false;
away.value = false;
reference = null;
stopLocating();
}
const flyTo = () => card.value && shell.value?.flyTo?.(card.value);
@@ -324,6 +445,10 @@ export const useEntityCardStore = defineStore('gev-entity-card', () => {
card,
lost,
tick,
away,
finding,
located,
locate,
connect,
select,
clear,
+154
View File
@@ -0,0 +1,154 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { createPinia } from 'pinia';
import { useEntityCardStore } from './entityCard.js';
/**
* A vessels layer whose one vessel can leave its feed, and a shell that
* records what the card asks of it.
*/
function setup({ found = true } = {}) {
const vessel = {
id: 'v1',
name: 'ARCADIA',
lat: 1,
lon: 10,
reference: 'vessel:v1',
};
let inFeed = true;
const asked = [];
const module = {
getAnalystRecords: () => (inFeed ? [{ ...vessel }] : []),
referenceOf: (id) => (id === 'v1' && inFeed ? vessel.reference : null),
async locate(id, { reference }) {
asked.push({ id, reference });
return found
? {
status: 'found',
lat: 5,
lon: 50,
altitudeM: null,
observedAtMs: 1_000,
atMs: 61_000,
}
: { status: 'none' };
},
};
const dataManager = {
isEnabled: () => true,
layers: new Map([['ais-live-vessels', { module }]]),
getAll: () => [],
};
const shell = {
flown: [],
followed: [],
reselected: [],
visible: true,
dataManager: () => dataManager,
openPanel() {},
flyTo(card) {
shell.flown.push([card.lat, card.lon]);
},
follow(card) {
shell.followed.push(card.key);
},
reselect(card, options) {
shell.reselected.push([card.identity.id, options.follow]);
},
onScreen: () => shell.visible,
canFollow: () => false,
};
const store = useEntityCardStore(createPinia());
store.connect(shell);
return {
store,
shell,
asked,
leave: () => (inFeed = false),
come: () => (inFeed = true),
};
}
test('a vessel out of its feed is looked up, shown where it was and flown to', async (t) => {
const { store, shell, asked, leave, come } = setup();
t.after(() => store.clear());
assert.equal(store.select({ layerId: 'ais-live-vessels', id: 'v1' }), true);
assert.equal(store.away, false, 'on screen and in its feed');
leave();
store.refresh();
assert.equal(store.lost, true);
assert.equal(store.away, true, 'out of its feed: the card offers to find it');
await store.locate();
assert.deepEqual(
asked,
[{ id: 'v1', reference: 'vessel:v1' }],
'by the reference it had',
);
assert.equal(store.card.lat, 5);
assert.equal(store.card.lon, 50);
assert.deepEqual(shell.flown, [[5, 50]]);
assert.equal(store.located.observedAtMs, 1_000);
assert.equal(store.finding, 'idle');
come();
store.refresh();
assert.equal(store.lost, false, 'back in its feed');
assert.equal(store.located, null);
assert.deepEqual(
shell.reselected,
[['v1', false]],
'its layer selects it again',
);
});
test('a vessel with no reading at the time says so and stays put', async (t) => {
const { store, shell, leave } = setup({ found: false });
t.after(() => store.clear());
store.select({ layerId: 'ais-live-vessels', id: 'v1' });
leave();
store.refresh();
await store.locate();
assert.equal(store.finding, 'none');
assert.deepEqual(shell.flown, [], 'the camera stays');
assert.equal(store.card.lat, 1, 'the card keeps its last reading');
});
test('an item in its feed but off screen is flown to without a lookup', async (t) => {
const { store, shell, asked } = setup();
t.after(() => store.clear());
store.select({ layerId: 'ais-live-vessels', id: 'v1' });
shell.visible = false;
store.refresh();
assert.equal(store.away, true, 'off screen');
await store.locate();
assert.deepEqual(asked, []);
assert.deepEqual(shell.flown, [[1, 10]]);
});
test('an item the camera follows is never away, wherever its last reading is', (t) => {
const { store, shell } = setup();
t.after(() => store.clear());
store.select({ layerId: 'ais-live-vessels', id: 'v1' });
shell.visible = false;
store.following = store.card.key;
store.refresh();
assert.equal(store.away, false);
});
test('a lookup still running when the item comes back is dropped', async (t) => {
const { store, shell, leave, come } = setup();
t.after(() => store.clear());
store.select({ layerId: 'ais-live-vessels', id: 'v1' });
leave();
store.refresh();
const pending = store.locate();
come();
store.refresh();
await pending;
assert.equal(store.lost, false);
assert.equal(store.located, null, 'no old reading on a live card');
assert.equal(store.card.lat, 1, 'the card keeps its live position');
assert.deepEqual(shell.flown, [], 'the camera stays');
});
+29
View File
@@ -0,0 +1,29 @@
import { defineStore } from 'pinia';
import { markRaw, shallowRef } from 'vue';
/**
* The Street Level photo viewer (KartaView, Panoramax) as its view renders
* it. The street-level layer presents it through `subscribePhotoViewer()`
* and the application shell publishes each presentation here.
*/
export const useStreetLevelPhotoStore = defineStore(
'gev-street-level-photo',
() => {
/**
* `{host, mountKey, providerId, label, alt, kind, src, fit, canvasKey,
* dragging, prevLabel, prevDisabled, nextLabel, nextDisabled, actions}`,
* or null while no photo viewer is mounted. Of the viewers mounting in
* the host, only the one mounted last (the largest `mountKey`) is
* published; `actions.supersede()` tells the others they are not drawn
* (see `ViewerAdapter.subscribeView` in src/layers/streetLevel/registry.js).
*/
const photo = shallowRef(null);
/** @param {?object} next A fresh presentation; every publish re-renders. */
function publish(next) {
photo.value = next && markRaw(next);
}
return { photo, publish };
},
);