Merge main and switch Cesium and Navara in place through Vue

Preserve the camera, map source and layer selection across engine sessions. Restore the previous engine if startup fails and retain local history navigation.
This commit is contained in:
German Khokhlov committed 2026-11-02 13:10:36 +04:00
commit b8f4d097c4
1691 files changed
+225876 -41594

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
import { defineStore } from 'pinia';
import { shallowRef } from 'vue';
/**
* The Global Context compass and contact direction overlay as its view
* renders it. The awareness layer presents it through
* `subscribeDirectionOverlay()` and the application shell publishes it here.
*/
export const useAwarenessDirectionStore = defineStore(
'gev-awareness-direction',
() => {
/**
* `{container, hidden, ring, heading, labels, markers}`, or null while
* the layer has no overlay. `container` is the element it sits in.
*/
const overlay = shallowRef(null);
/**
* @param {?object} next A fresh presentation, frozen by the layer; every
* publish re-renders.
*/
function publish(next) {
overlay.value = next;
}
return { overlay, publish };
},
);
+35
View File
@@ -0,0 +1,35 @@
import { defineStore } from 'pinia';
import { markRaw, shallowRef } from 'vue';
/**
* The Bhote Koshi event's reconstruction panel as its view renders it. The
* event layer (src/data/bhoteKoshiEvent.js) presents each control's state
* and the field reports; the view sends clicks and slider moves back to the
* connected controls.
*/
export const useBhoteKoshiPanelStore = defineStore(
'gev-bhote-koshi-panel',
() => {
/**
* `{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`.
*/
const panel = shallowRef(null);
/** @param {?object} next A fresh presentation; every publish re-renders. */
function publish(next) {
panel.value = next && markRaw(next);
}
/** The controls the panel's buttons, sliders and reports call. */
const controls = shallowRef(null);
/** @param {?object} next The controls, or null to disconnect. */
function connect(next) {
controls.value = next && markRaw(next);
}
return { panel, publish, controls, connect };
},
);
+88
View File
@@ -0,0 +1,88 @@
import { defineStore } from 'pinia';
import { markRaw, shallowRef } from 'vue';
/**
* The CCTV panel as its view renders it. CctvControls presents the buttons,
* CAL chip, meta line and calibration readout (`presentCctvPanel()`), runs
* the frame preview, source badge and typed summary, and publishes them
* here, with the camera picker's options; it keeps its listeners on the
* panel's controls.
*/
export const useCctvStore = defineStore('gev-cctv', () => {
/** The presented panel; null until the controls first render. */
const view = shallowRef(null);
/**
* The pose value being typed: `{field, label, ariaLabel, step, value,
* finish(commit, typedText)}`, or null.
*/
const calEdit = shallowRef(null);
/** The preview: requested and shown frame, loading and error state. */
const frame = shallowRef(null);
/** Whether the live video surface replaces the still frame. */
const live = shallowRef(false);
/** `{label, state}` for the source badge; null until first synced. */
const sourceBadge = shallowRef(null);
/**
* The camera picker: `{options: [{value, label}], note, disabled,
* selection: {value}|{index}|null}`; null until first rendered.
*/
const picker = shallowRef(null);
/** The scene summary as typed so far; null until the first one. */
const summary = shallowRef(null);
/** @param {object} next A fresh presentation; every publish re-renders. */
function publish(next) {
view.value = markRaw(next);
}
let editCount = 0;
/** @param {object|null} edit Each edit gets its own `id`, and input. */
function setCalEdit(edit) {
calEdit.value = edit ? markRaw({ ...edit, id: ++editCount }) : null;
}
/** @param {object} next */
function setFrame(next) {
frame.value = markRaw(next);
}
/** @param {boolean} on */
function setLive(on) {
live.value = Boolean(on);
}
/** @param {{label: string, state: string}} next */
function setSourceBadge(next) {
sourceBadge.value = markRaw(next);
}
/** @param {object} next */
function setPicker(next) {
picker.value = markRaw(next);
}
/** @param {string} text */
function setSummary(text) {
summary.value = text;
}
return {
view,
calEdit,
frame,
live,
sourceBadge,
summary,
picker,
publish,
setCalEdit,
setFrame,
setLive,
setSourceBadge,
setSummary,
setPicker,
};
});
+33
View File
@@ -0,0 +1,33 @@
import { defineStore } from 'pinia';
import { markRaw, shallowRef } from 'vue';
/**
* The full-globe celestial ring as its view renders it. The ring owner
* (src/celestialRing.js) presents the overlay's state, the outline and where
* the sun and moon layers and markers sit; the view hands its two canvases
* back to the connected controls, which paint them.
*/
export const useCelestialRingStore = defineStore('gev-celestial-ring', () => {
/**
* `{owner, container, enabled, visible, globeVisible, ephemerisUpdates,
* size, outline, sun, moon, sunMarker, moonMarker}`, or null while no ring
* exists. `container` is the element it sits in; `owner` is passed back
* with each canvas.
*/
const ring = shallowRef(null);
/** @param {?object} next A fresh presentation; every publish re-renders. */
function publish(next) {
ring.value = next && markRaw(next);
}
/** The controls whose `attach(owner, kind, canvas)` each canvas calls. */
const controls = shallowRef(null);
/** @param {?object} next The controls, or null to disconnect. */
function connect(next) {
controls.value = next && markRaw(next);
}
return { ring, publish, controls, connect };
});
+107
View File
@@ -0,0 +1,107 @@
import { defineStore } from 'pinia';
import { markRaw, shallowRef } from 'vue';
/**
* Cockpit content as its views render it. The Cockpit controller presents
* which Cockpit surfaces are shown, the briefing card's pages, cycle toggle, regional news and local
* conditions, the Contact card's readouts and weather toggle, the
* instruments, the flight plan, the vision selector and the signal rows,
* and publishes them
* here; it keeps the controls' listeners.
*/
export const useCockpitStore = defineStore('gev-cockpit', () => {
/** Which Cockpit surfaces are shown; null until the controller first syncs. */
const presence = shallowRef(null);
/** @param {?object} next A fresh presentation of the shown surfaces. */
function publishPresence(next) {
presence.value = next && markRaw(next);
}
/** The presented briefing; null until the controller first presents it. */
const brief = shallowRef(null);
/** @param {?object} next A fresh presentation of the briefing card. */
function publishBrief(next) {
brief.value = next && markRaw(next);
}
/** The presented Contact card; null until the controller first presents it. */
const context = shallowRef(null);
/** @param {?object} next A fresh presentation of the Contact card. */
function publishContext(next) {
context.value = next && markRaw(next);
}
/** The presented instruments; null until the first HUD update. */
const instruments = shallowRef(null);
/** @param {?object} next A fresh presentation of the instruments. */
function publishInstruments(next) {
instruments.value = next && markRaw(next);
}
/** The presented flight plan and destination arrow; null until the first. */
const route = shallowRef(null);
/** @param {?object} next A fresh presentation of the route. */
function publishRoute(next) {
route.value = next && markRaw(next);
}
/** The presented vision selector; null until the first vision change. */
const vision = shallowRef(null);
/** @param {?object} next A fresh presentation of the vision selector. */
function publishVision(next) {
vision.value = next && markRaw(next);
}
/** The presented signal rows; null until the controller first presents them. */
const signals = shallowRef(null);
/** @param {?object[]} next A fresh presentation of the signal rows. */
function publishSignals(next) {
signals.value = next && markRaw(next);
}
/**
* The utility strip's measured layout: its top and height limits as CSS
* lengths (null leaves the stylesheet's), whether only the expanded control
* fits, and whether a collapsed control beside an expanded one is hidden
* from assistive technology. Null until the first layout pass.
*/
const utilityLayout = shallowRef(null);
/** @param {?object} next A fresh layout; one equal to the current is dropped. */
function publishUtilityLayout(next) {
const current = utilityLayout.value;
if (
next &&
current &&
Object.keys(next).every((key) => next[key] === current[key])
)
return;
utilityLayout.value = next && markRaw(next);
}
return {
presence,
publishPresence,
brief,
publishBrief,
context,
publishContext,
instruments,
publishInstruments,
route,
publishRoute,
vision,
publishVision,
signals,
publishSignals,
utilityLayout,
publishUtilityLayout,
};
});
+76
View File
@@ -0,0 +1,76 @@
import { defineStore } from 'pinia';
import { markRaw, shallowRef } from 'vue';
/**
* The Context panel's mode switch as its view renders it. ContextControls
* presents the selected mode, the transition busy state and the nearby
* sites search (`_presentContext()`) and publishes them here; it
* keeps its listeners and transactions. The Contacts and Space Missions
* layers publish their panels beside it, and the app connects each layer's
* commands.
*/
export const useContextStore = defineStore('gev-context', () => {
/** The presented mode switch; null until the controls first render. */
const view = shallowRef(null);
/** @param {object} next A fresh presentation; every publish re-renders. */
function publish(next) {
view.value = markRaw(next);
}
/** The Contacts panel; null until the layer first publishes. */
const awareness = shallowRef(null);
/** @param {object} next A fresh presentation of the Contacts panel. */
function publishAwareness(next) {
awareness.value = next && markRaw(next);
}
/**
* The Contacts layer whose navigation the panel calls: `navigatePrevious`,
* `focusCurrent`, `navigateNext` and `focusTarget`.
*/
const awarenessLayer = shallowRef(null);
/** @param {?object} layer The Contacts layer, or null to disconnect. */
function connectAwareness(layer) {
awarenessLayer.value = layer && markRaw(layer);
}
/** The Space Missions roster; null until the layer first presents it. */
const missionRoster = shallowRef(null);
/** The selected space mission; null while none is selected. */
const mission = shallowRef(null);
/**
* @param {?{roster: ?object, mission: ?object}} next The layer's view. The
* layer keeps an unchanged roster's object, which re-renders nothing.
*/
function publishMissions(next) {
missionRoster.value = next?.roster ? markRaw(next.roster) : null;
mission.value = next?.mission ? markRaw(next.mission) : null;
}
/** The Space Missions layer whose panel commands the components call. */
const missionsLayer = shallowRef(null);
/** @param {?object} layer The Space Missions layer, or null to disconnect. */
function connectMissions(layer) {
missionsLayer.value = layer && markRaw(layer);
}
return {
view,
publish,
awareness,
publishAwareness,
awarenessLayer,
connectAwareness,
missionRoster,
mission,
publishMissions,
missionsLayer,
connectMissions,
};
});
+34
View File
@@ -0,0 +1,34 @@
import { defineStore } from 'pinia';
import { markRaw, shallowRef } from 'vue';
/**
* The loaded data packs' attribution cards as their view renders them. Each
* set of data-pack presentations (src/scenes/dataPacks/presentation.js)
* presents its own panel, with a card for each pack and its media player
* when the pack is media.
*/
export const useDataPacksStore = defineStore('gev-data-packs', () => {
/**
* `[{owner, key, container, cards: [{key, id, title, url, media}]}]`, one
* per owner showing cards. `container` is the element the panel sits in;
* `media` is `{kind: 'video'|'audio', src}` or null.
*/
const panels = shallowRef([]);
/**
* @param {object} owner The presentations publishing.
* @param {?object} panel Their fresh panel, or null to remove it.
*/
function publish(owner, panel) {
const index = panels.value.findIndex((item) => item.owner === owner);
const next = panels.value.slice();
if (!panel) {
if (index < 0) return;
next.splice(index, 1);
} else if (index < 0) next.push(markRaw({ ...panel, owner }));
else next[index] = markRaw({ ...panel, owner });
panels.value = next;
}
return { panels, publish };
});
+138
View File
@@ -0,0 +1,138 @@
import { defineStore } from 'pinia';
import { markRaw, shallowRef } from 'vue';
import { createOwners } from './owners.js';
/**
* The Display panel as its view renders it. VisualSettings presents its
* groups (`_presentDisplay()`), AircraftDisplay the 3D aircraft group, the
* draw tool its controls and the file import its list, and each publishes
* here. The controls' changes reach their owners (DisplayBindings, the draw
* tool and the file import) through act(). VisualSettings also
* publishes the active style, which the dock and the scene chrome show, and
* the map source controls publish their chip row beside it.
*/
export const useDisplayStore = defineStore('gev-display', () => {
/** The presented panel; null until VisualSettings first renders. */
const view = shallowRef(null);
/** @param {object} next A fresh presentation; every publish re-renders. */
function publish(next) {
view.value = markRaw(next);
}
/** The 3D aircraft group; null until AircraftDisplay first renders. */
const models3d = shallowRef(null);
/** @param {object} next A fresh presentation of the 3D aircraft group. */
function publishModels3d(next) {
models3d.value = markRaw(next);
}
/** The Draw controls; null until the draw tool first renders. */
const draw = shallowRef(null);
/** @param {object} next A fresh presentation of the Draw controls. */
function publishDraw(next) {
draw.value = markRaw(next);
}
/** The imported files and hint; null until the file import renders. */
const geoImport = shallowRef(null);
/** @param {object} next A fresh presentation of the imported files. */
function publishGeoImport(next) {
geoImport.value = markRaw(next);
}
/** The active visual style; null until VisualSettings first presents it. */
const style = shallowRef(null);
/** @param {{name: string, label: string}} next The active style and its label. */
function publishStyle(next) {
style.value = markRaw(next);
}
/** The map source chips and status; null until the controls first render. */
const mapSource = shallowRef(null);
// Connected only by the standalone app. Embedded hosts own their engine.
const globeEngine = shallowRef(null);
function presentGlobeEngine(next) {
globeEngine.value = next;
}
/** @param {object} next A fresh presentation of the map source row. */
function publishMapSource(next) {
mapSource.value = next && markRaw(next);
}
/** The map source controls whose `select(id)` a chip calls. */
const mapSourceControls = shallowRef(null);
/** @param {?object} controls The map source controls, or null to disconnect. */
function connectMapSource(controls) {
mapSourceControls.value = controls && markRaw(controls);
}
// DisplayBindings answers the Display controls and the dock's style
// buttons, the draw tool and the file import their own.
const { connect, detach, act } = createOwners();
/**
* The active style's parameter rows, `{style, rows}`; null while the style
* has none. Each row's change calls act('setStyleParameter', name, value).
*/
const parameters = shallowRef(null);
/** @param {?{style: string, rows: object[]}} next */
function publishParameters(next) {
parameters.value = next && markRaw(next);
}
/**
* The Cockpit's Display popover slots while Cockpit shows the Display
* controls, `{hud, detection, parameters, models3d}` (elements); null while
* they stay in the Display panel. The panel teleports its groups there.
*/
const cockpitPortal = shallowRef(null);
/** @param {?object} next The slots, or null to bring the groups home. */
function publishCockpitPortal(next) {
cockpitPortal.value = next && markRaw(next);
}
/** The phone shell's tab bar; null until the shell first presents it. */
const phoneShell = shallowRef(null);
/** @param {?{enabled: boolean, sheet: string|null, tabs: object[]}} next The phone shell's tabs, whether it is on and its open sheet. */
function publishPhoneShell(next) {
phoneShell.value = next && markRaw(next);
}
return {
view,
publish,
models3d,
publishModels3d,
draw,
publishDraw,
geoImport,
publishGeoImport,
style,
publishStyle,
parameters,
publishParameters,
cockpitPortal,
publishCockpitPortal,
phoneShell,
publishPhoneShell,
globeEngine,
presentGlobeEngine,
mapSource,
publishMapSource,
mapSourceControls,
connectMapSource,
connect,
detach,
act,
};
});
+31
View File
@@ -0,0 +1,31 @@
import { defineStore } from 'pinia';
import { markRaw, shallowRef } from 'vue';
/**
* The first-run mission launcher as the welcome view renders it.
* initFirstRunExperience presents it and connects the controls its buttons
* and checkbox call.
*/
export const useFirstRunStore = defineStore('gev-first-run', () => {
/**
* `{removed, shown, visible, closing, state, busy, status, description,
* environmentalTitle, environmentalSub, scrollable}`, or null until the
* launcher is initialized (the card stays hidden).
*/
const launcher = shallowRef(null);
/** @param {?object} next A fresh presentation; every publish re-renders. */
function publish(next) {
launcher.value = next && markRaw(next);
}
/** `{choose(choice), dismiss(), suppress(wanted) → boolean}`, or null. */
const controls = shallowRef(null);
/** @param {?object} next The launcher's controls, or null to disconnect. */
function connect(next) {
controls.value = next && markRaw(next);
}
return { launcher, publish, controls, connect };
});
+95
View File
@@ -0,0 +1,95 @@
import { defineStore } from 'pinia';
import { computed, ref, shallowReactive } from 'vue';
import { createOwners } from './owners.js';
/**
* The top-center globe actions as their view renders them, and the cockpit's
* reset. The shell publishes whether a clear of the selected data layers or a
* reset to the full globe view is under way and the camera's tilt and
* heading, and answers the buttons through act().
*/
export const useGlobeActionsStore = defineStore('gev-globe-actions', () => {
const owners = createOwners();
// Who answers which action, as the computed state below reads it.
const ownership = ref(0);
/**
* Whether the work behind an action is under way, kept per owner so its
* button shows the owner that answers it; null until that owner says.
*/
function ownedBusy(name) {
const byOwner = shallowReactive(new Map());
const busy = computed(() => {
void ownership.value;
return byOwner.get(owners.ownerOf(name)) ?? null;
});
/**
* @param {object} token The owner's, from connect().
* @param {boolean} value
*/
const publish = (token, value) => {
byOwner.set(token, Boolean(value));
};
return { byOwner, busy, publish };
}
const clearing = ownedBusy('clear');
const resetting = ownedBusy('reset');
/** Whether a clear of the selected data layers is under way. */
const clearBusy = clearing.busy;
const publishClearBusy = clearing.publish;
/** Whether a reset to the full globe view is under way. */
const resetBusy = resetting.busy;
const publishResetting = resetting.publish;
/**
* Whether the map reads as tilted and the camera's whole-degree heading;
* null until the camera controls first say.
* @type {import('vue').Ref<{ tilted: boolean, heading: number } | null>}
*/
const camera = ref(null);
/**
* Take the camera's state; the same state again changes nothing, so its
* owner can publish it on every frame the camera draws.
* @param {{ tilted: boolean, heading: number } | null} state
*/
function publishCamera(state) {
const current = camera.value;
if (!state) {
camera.value = null;
return;
}
const tilted = Boolean(state.tilted);
if (current?.tilted === tilted && current.heading === state.heading) return;
camera.value = { tilted, heading: state.heading };
}
/** @param {Record<string, Function>} actions */
function connect(actions) {
const token = owners.connect(actions);
ownership.value += 1;
return token;
}
function detach(token) {
owners.detach(token);
clearing.byOwner.delete(token);
resetting.byOwner.delete(token);
ownership.value += 1;
}
const { act, owns } = owners;
return {
clearBusy,
publishClearBusy,
resetBusy,
publishResetting,
camera,
publishCamera,
connect,
detach,
act,
owns,
};
});
+19
View File
@@ -0,0 +1,19 @@
import { defineStore } from 'pinia';
import { shallowRef } from 'vue';
/**
* The Intel HUD as its view renders it. IntelHUD presents its readouts,
* visibility, layout variant and style colors and the application shell
* publishes them here.
*/
export const useHudStore = defineStore('gev-hud', () => {
/** The presented HUD, frozen by IntelHUD; null until it is built. */
const hud = shallowRef(null);
/** @param {?object} next A fresh presentation; every publish re-renders. */
function publish(next) {
hud.value = next;
}
return { hud, publish };
});
+35
View File
@@ -0,0 +1,35 @@
import { defineStore } from 'pinia';
import { markRaw, shallowRef } from 'vue';
/**
* The before/after imagery dividers on the page, as their view renders them.
* Each split (src/ui/imagerySplit.js) publishes its line under its own key
* and withdraws it when destroyed; the view sends pointer and keyboard input
* back to that split's controls.
*/
export const useImagerySplitStore = defineStore('gev-imagery-split', () => {
/** The dividers in creation order: `{key, view, controls}`. */
const splits = shallowRef([]);
/**
* Show or update one divider.
* @param {number} key The split's own key.
* @param {object} view A fresh presentation of its line.
* @param {object} controls What the view calls for its input.
*/
function publish(key, view, controls) {
const entry = markRaw({ key, view, controls });
const index = splits.value.findIndex((split) => split.key === key);
splits.value =
index < 0
? [...splits.value, entry]
: splits.value.map((split, at) => (at === index ? entry : split));
}
/** @param {number} key The split to remove. */
function withdraw(key) {
splits.value = splits.value.filter((split) => split.key !== key);
}
return { splits, publish, withdraw };
});
+19
View File
@@ -0,0 +1,19 @@
import { defineStore } from 'pinia';
import { markRaw, shallowRef } from 'vue';
/**
* The interface language picker as its view renders it. The shell publishes
* the active language and what a choice does once it decides to show the
* picker; a host that does not initialize Core's locale never does.
*/
export const useLocaleStore = defineStore('gev-locale', () => {
/** `{current, onSelect, focus}`, or null while no picker is shown. */
const picker = shallowRef(null);
/** @param {?{current: string, onSelect: (locale: string) => void, focus?: boolean}} next */
function publishPicker(next) {
picker.value = next && markRaw(next);
}
return { picker, publishPicker };
});
+29
View File
@@ -0,0 +1,29 @@
import { defineStore } from 'pinia';
import { markRaw, shallowRef } from 'vue';
/**
* The dock's location tray as its view renders it. LocationControls
* presents the city pills, the landmark row, the mini status, the search
* error, the search field's open and searching state and the ORBIT indicator
* and publishes them here; it keeps the search field's key, input and blur
* listeners.
*/
export const useLocationStore = defineStore('gev-location', () => {
/** The presented tray; null until the controls first render. */
const view = shallowRef(null);
/** @param {?object} next A fresh presentation; every publish re-renders. */
function publish(next) {
view.value = next && markRaw(next);
}
/** The controls whose `chooseCity(id)` and `choosePoi(index)` pills call. */
const controls = shallowRef(null);
/** @param {?object} next The location controls, or null to disconnect. */
function connect(next) {
controls.value = next && markRaw(next);
}
return { view, publish, controls, connect };
});
+22
View File
@@ -0,0 +1,22 @@
import { defineStore } from 'pinia';
import { markRaw, shallowRef } from 'vue';
/**
* The Space Missions replay vehicle overlay as its view renders it. The
* launches layer presents it through `subscribeReplayOverlay()` and the
* application shell publishes each presentation here.
*/
export const useMissionReplayStore = defineStore('gev-mission-replay', () => {
/**
* `{visible, mode, thrusting, paused, transform, rotation, iconOpacity,
* labelOpacity, title, detail}`, or null while the layer has no overlay.
*/
const overlay = shallowRef(null);
/** @param {?object} next A fresh presentation; every publish re-renders. */
function publish(next) {
overlay.value = next && markRaw(next);
}
return { overlay, publish };
});
+64
View File
@@ -0,0 +1,64 @@
/**
* The owners answering a store's controls. A view calls `act(name, ...args)`;
* the newest connected owner with an action of that name answers it, so an
* owner that connects again replaces itself, and owners of different actions
* sit side by side.
* @returns {{connect: Function, detach: Function, act: Function, owns: Function, ownerOf: Function}}
*/
export function createOwners() {
/** @type {Array<{actions: object}>} Oldest first. */
const owners = [];
/**
* Answer the actions named in `actions`.
* @param {Record<string, Function>} actions
* @returns {object} Token for detach().
*/
function connect(actions) {
const token = { actions };
owners.push(token);
return token;
}
/** Stop answering for the owner holding `token`; the others stay. */
function detach(token) {
const index = owners.indexOf(token);
if (index >= 0) owners.splice(index, 1);
}
/**
* A control's change: call the newest connected owner's action of that
* name, if any.
* @param {string} name
* @param {...unknown} args
* @returns {unknown} What the action returned, if one answered.
*/
function act(name, ...args) {
for (let index = owners.length - 1; index >= 0; index -= 1) {
const action = owners[index].actions[name];
if (action) return action(...args);
}
}
/**
* The token of the owner that answers `name`, if any.
* @param {string} name
* @returns {object | undefined}
*/
function ownerOf(name) {
for (let index = owners.length - 1; index >= 0; index -= 1)
if (owners[index].actions[name]) return owners[index];
}
/**
* Whether the owner holding `token` is the one that answers `name`, so an
* owner that also publishes state can leave it to a newer one.
* @param {object} token
* @param {string} name
*/
function owns(token, name) {
return Boolean(token) && ownerOf(name) === token;
}
return { connect, detach, act, owns, ownerOf };
}
+57
View File
@@ -0,0 +1,57 @@
// src/ui/stores/owners.test.mjs — the newest connected owner with an action
// answers it; detaching hands the action back to the one before.
import test from 'node:test';
import assert from 'node:assert/strict';
import { createOwners } from './owners.js';
test('the newest owner with an action answers it, and detach hands it back', () => {
const { connect, detach, act } = createOwners();
const calls = [];
const first = connect({
play: (n) => calls.push(['first.play', n]),
stop: () => calls.push(['first.stop']),
});
const second = connect({ play: (n) => calls.push(['second.play', n]) });
act('play', 1);
act('stop');
act('missing');
detach(second);
act('play', 2);
detach(second);
detach(first);
act('play', 3);
assert.deepEqual(calls, [
['second.play', 1],
['first.stop'],
['first.play', 2],
]);
});
test('act returns what the answering action returned', () => {
const { connect, act } = createOwners();
connect({ pick: (tag) => `kept ${tag}` });
assert.equal(act('pick', 'jazz'), 'kept jazz');
assert.equal(act('missing'), undefined);
});
test('owns names the owner that answers an action', () => {
const { connect, detach, owns } = createOwners();
const older = connect({ tilt() {}, share() {} });
const newer = connect({ tilt() {} });
assert.equal(owns(newer, 'tilt'), true);
assert.equal(owns(older, 'tilt'), false);
assert.equal(owns(older, 'share'), true);
assert.equal(owns(newer, 'missing'), false);
assert.equal(owns(null, 'tilt'), false);
detach(newer);
assert.equal(owns(older, 'tilt'), true);
});
test('ownerOf names the token that answers an action', () => {
const { connect, ownerOf } = createOwners();
const older = connect({ clear() {}, share() {} });
const newer = connect({ clear() {} });
assert.equal(ownerOf('clear'), newer);
assert.equal(ownerOf('share'), older);
assert.equal(ownerOf('missing'), undefined);
});
+99
View File
@@ -0,0 +1,99 @@
import { defineStore } from 'pinia';
import { shallowRef } from 'vue';
/**
* @typedef {object} PanelChromeHandlers
* @property {(panelId: string) => void} toggle A collapse button's click.
* @property {(panelId: string) => void} pin A dock pin button's click.
*/
/**
* @typedef {object} PanelState
* @property {boolean} collapsed Whether the panel is closed, by the person or
* by its layout.
* @property {boolean} pinned A dock tray kept open (`dock-pinned`).
* @property {boolean} pinnedTop The pinned tray drawn on top.
* @property {?('layout'|'accordion')} auto Why a layout closed the panel
* (`layout-auto-collapsed`, `accordion-collapsed`), or null when the
* person's own choice stands.
*/
/** A panel's state before its owner has said otherwise. */
const BLANK = Object.freeze({
collapsed: false,
pinned: false,
pinnedTop: false,
auto: null,
});
/**
* Each panel's disclosure state, which its root (`vPanelState`) and its
* collapse, dock and pin buttons render. PanelChrome owns the panels: it and
* the layouts it runs publish here whenever a panel opens, closes or is
* pinned, and it connects the buttons' clicks; the views only render and
* forward clicks.
*/
export const usePanelChromeStore = defineStore('gev-panel-chrome', () => {
/**
* `{[panelId]: PanelState}`, frozen; a panel is absent until its owner
* first presents it, and it keeps its markup's classes until then.
*/
const panels = shallowRef(Object.freeze({}));
/** @type {{handlers: PanelChromeHandlers}|null} */
let owner = null;
/**
* Present the panels for an owner, replacing any earlier owner. The
* buttons start from the new owner's states, not the last owner's.
* @param {PanelChromeHandlers} handlers
* @returns {object} Token for publish() and detach().
*/
function connect(handlers) {
owner = { handlers };
panels.value = Object.freeze({});
return owner;
}
/** @returns {boolean} Whether `token` is the owner presenting now. */
function owns(token) {
return !!token && token === owner;
}
/**
* Merge `patch` into a panel's state for the owner holding `token`; an
* unchanged state is not republished.
* @param {object} token
* @param {string} panelId
* @param {Partial<PanelState>} patch
*/
function publish(token, panelId, patch) {
if (!owns(token) || !panelId) return;
const prior = panels.value[panelId];
const next = { ...BLANK, ...prior, ...patch };
if (prior && Object.keys(BLANK).every((key) => prior[key] === next[key]))
return;
panels.value = Object.freeze({
...panels.value,
[panelId]: Object.freeze(next),
});
}
/**
* Stop forwarding clicks for the owner holding `token`; the buttons keep
* the last state it presented. A later owner is left alone.
*/
function detach(token) {
if (token === owner) owner = null;
}
/**
* Forward a button's click to the owner, if one is connected.
* @param {keyof PanelChromeHandlers} name
* @param {string} panelId
*/
function act(name, panelId) {
owner?.handlers[name]?.(panelId);
}
return { panels, connect, owns, publish, detach, act };
});
+57
View File
@@ -0,0 +1,57 @@
import { defineStore } from 'pinia';
import { reactive } from 'vue';
/**
* @typedef {object} RailPanel
* @property {string} id Panel element id.
* @property {string} title The panel's translated title.
* @property {boolean} open Whether the panel is expanded.
* @property {boolean} available Whether the panel is offered (not `hidden`).
*/
const samePanels = (a, b) =>
a.length === b.length &&
a.every(
(panel, index) =>
panel.id === b[index].id &&
panel.title === b[index].title &&
panel.open === b[index].open &&
panel.available === b[index].available,
);
/**
* The desktop side panels as the rails present them. Panel disclosure stays
* with PanelChrome; this store publishes each side's panels in order.
*/
export const usePanelStore = defineStore('gev-panels', () => {
/** @type {{left: RailPanel[], right: RailPanel[]}} */
const sides = reactive({ left: [], right: [] });
/**
* Replace one side's panels, keeping the array when nothing changed.
* @param {'left'|'right'} side Sidebar.
* @param {RailPanel[]} panels Panels in display order.
*/
function setSide(side, panels) {
if (!samePanels(sides[side], panels)) sides[side] = panels;
}
/**
* @param {'left'|'right'} side Sidebar.
* @returns {string|null} The open panel's id.
*/
function openPanelId(side) {
return (
sides[side].find((panel) => panel.open && panel.available)?.id ?? null
);
}
/** @param {string} id Panel id. */
function isOpen(id) {
return [...sides.left, ...sides.right].some(
(panel) => panel.id === id && panel.open,
);
}
return { sides, setSide, openPanelId, isOpen };
});
+27
View File
@@ -0,0 +1,27 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { createPinia } from 'pinia';
import { usePanelStore } from './panels.js';
test('the panel store reports each side’s open panel and keeps unchanged sides', () => {
const store = usePanelStore(createPinia());
const left = [
{ id: 'data-panel', open: false, available: true },
{ id: 'scene-panel', open: true, available: true },
];
store.setSide('left', left);
store.setSide('right', [
{ id: 'weather-panel', open: true, available: false },
]);
assert.equal(store.openPanelId('left'), 'scene-panel');
// An open panel that is not offered is not the side's open panel.
assert.equal(store.openPanelId('right'), null);
assert.equal(store.isOpen('scene-panel'), true);
assert.equal(store.isOpen('data-panel'), false);
const published = store.sides.left;
store.setSide(
'left',
left.map((panel) => ({ ...panel })),
);
assert.equal(store.sides.left, published);
});
+32
View File
@@ -0,0 +1,32 @@
import { defineStore } from 'pinia';
import { markRaw, shallowRef } from 'vue';
/**
* The voice pointer reticles as their view renders them. Each PointerReticle
* (src/voice/pointerReticle.js) presents where the user pointed while its
* voice turn is live.
*/
export const usePointerReticleStore = defineStore('gev-pointer-reticle', () => {
/**
* `[{owner, visible, left, top, target}]` in client pixels, one per
* reticle that has shown, `target` being 'entity' or 'ground'.
*/
const reticles = shallowRef([]);
/**
* @param {object} owner The reticle publishing.
* @param {?object} view Its fresh presentation, or null to remove it.
*/
function publish(owner, view) {
const index = reticles.value.findIndex((item) => item.owner === owner);
const next = reticles.value.slice();
if (!view) {
if (index < 0) return;
next.splice(index, 1);
} else if (index < 0) next.push(markRaw({ ...view, owner }));
else next[index] = markRaw({ ...view, owner });
reticles.value = next;
}
return { reticles, publish };
});
+31
View File
@@ -0,0 +1,31 @@
import { defineStore } from 'pinia';
import { markRaw, shallowRef } from 'vue';
/**
* Provider Settings (the dev-only key setup) as its view renders it. The
* setup owner (src/keySetup.js) presents the POWER UP chip, the dialog, its
* key rows, the field values and the status line, and publishes them here;
* the view sends clicks and typing to the connected owner.
*/
export const useProviderSettingsStore = defineStore(
'gev-provider-settings',
() => {
/** The presented setup; null until the owner first publishes. */
const view = shallowRef(null);
/** @param {?object} next A fresh presentation; every publish re-renders. */
function publish(next) {
view.value = next && markRaw(next);
}
/** The setup owner the controls call, or null while none is wired. */
const controls = shallowRef(null);
/** @param {?object} next The owner, or null to disconnect. */
function connect(next) {
controls.value = next && markRaw(next);
}
return { view, publish, controls, connect };
},
);
+62
View File
@@ -0,0 +1,62 @@
import { defineStore } from 'pinia';
import { markRaw, shallowRef } from 'vue';
import { createOwners } from './owners.js';
/**
* The Radio panel as its view renders it. RadioControls presents the
* directory row, station card, transport, volume and playback line and the
* Cockpit's compact radio controls (`renderRadioState()`), which Cockpit
* utility popover is open, and the directory tuner, and publishes them here;
* it keeps its listeners. LocalSdrControls publishes the local RTL-SDR card
* beside it, and the card's controls reach it through act().
*/
export const useRadioStore = defineStore('gev-radio', () => {
/** The presented panel; null until the controls first render. */
const view = shallowRef(null);
/** @param {object} next A fresh presentation; every publish re-renders. */
function publish(next) {
view.value = markRaw(next);
}
/** The local RTL-SDR card; null until its controls first render. */
const sdr = shallowRef(null);
/** @param {object} next A fresh presentation of the RTL-SDR card. */
function publishSdr(next) {
sdr.value = markRaw(next);
}
/** The open Cockpit utility popover; null until one first opens or closes. */
const utility = shallowRef(null);
/** @param {{display: boolean, radio: boolean}} next */
function publishUtility(next) {
utility.value = markRaw(next);
}
/** The directory tuner; null until the controls first present it. */
const tuner = shallowRef(null);
/** @param {object} next A fresh presentation of the tuner. */
function publishTuner(next) {
tuner.value = markRaw(next);
}
// LocalSdrControls answers the RTL-SDR card's controls.
const { connect, detach, act } = createOwners();
return {
view,
publish,
sdr,
publishSdr,
utility,
publishUtility,
tuner,
publishTuner,
connect,
detach,
act,
};
});
+18
View File
@@ -0,0 +1,18 @@
import { defineStore } from 'pinia';
import { ref } from 'vue';
/**
* Recording composition as the scene chrome renders it. RecordingControls
* publishes the safe frame a recording composes in.
*/
export const useRecordingStore = defineStore('gev-recording', () => {
/** The recording's safe frame, '16:9' or '9:16'; null while none records. */
const safeFrame = ref(null);
/** @param {'16:9' | '9:16' | null} next */
function publishSafeFrame(next) {
safeFrame.value = next == null ? null : next === '9:16' ? '9:16' : '16:9';
}
return { safeFrame, publishSafeFrame };
});
+35
View File
@@ -0,0 +1,35 @@
import { defineStore } from 'pinia';
import { markRaw, shallowRef } from 'vue';
/**
* The active shot's Scene actions panel as its view renders it. The scene
* interactions owner (src/scenes/interactions.js) presents the actions, the
* status line and the source card here; the view sends action clicks back to
* the connected controls.
*/
export const useSceneInteractionsStore = defineStore(
'gev-scene-interactions',
() => {
/**
* `{id, owner, container, items, status, busy, selected, outlined,
* card}`, or null while the shot has no actions. `container` is the
* element it sits in; `owner` is passed back with each dispatch.
*/
const panel = shallowRef(null);
/** @param {?object} next A fresh presentation; every publish re-renders. */
function publish(next) {
panel.value = next && markRaw(next);
}
/** The controls whose `dispatch(id, owner)` an action button calls. */
const controls = shallowRef(null);
/** @param {?object} next The controls, or null to disconnect. */
function connect(next) {
controls.value = next && markRaw(next);
}
return { panel, publish, controls, connect };
},
);
+36
View File
@@ -0,0 +1,36 @@
import { defineStore } from 'pinia';
import { markRaw, shallowRef } from 'vue';
/**
* Scene sharing as its views render it. The sharing owner
* (src/scenes/sharing.js) offers the EDIT DETAILS / SHARE SCENE bar and
* presents its one open dialog here; the views send clicks, typing and file
* choices back to the connected dialog.
*/
export const useSceneSharingStore = defineStore('gev-scene-sharing', () => {
/** The bar's actions ({edit, share}), or null while no owner offers it. */
const toolbar = shallowRef(null);
/** @param {?{edit: Function, share: Function}} next */
function offerToolbar(next) {
toolbar.value = next && markRaw(next);
}
/** The open dialog's presentation, or null while none is open. */
const dialog = shallowRef(null);
/** @param {?object} next A fresh presentation; every publish re-renders. */
function publishDialog(next) {
dialog.value = next && markRaw(next);
}
/** The open dialog the view calls, or null while none is wired. */
const controls = shallowRef(null);
/** @param {?object} next The dialog, or null to disconnect. */
function connect(next) {
controls.value = next && markRaw(next);
}
return { toolbar, offerToolbar, dialog, publishDialog, controls, connect };
});
+120
View File
@@ -0,0 +1,120 @@
import { defineStore } from 'pinia';
import { markRaw, shallowRef } from 'vue';
/**
* @typedef {object} SceneRowHandlers
* @property {(shotId: string) => void} select
* @property {(sceneId: string, shotId: string, title: string) => void} rename
* @property {(sceneId: string, shotId: string) => void} load
* @property {(sceneId: string, shotId: string) => void} remove
* @property {(sceneId: string) => void} selectScene The select's choice.
* @property {(file: File) => Promise<void>|void} importFile A chosen file.
* @property {() => void} create, deleteScene, capture, update, start, stop,
* next, export, download The panel's buttons.
*/
/**
* The Scene panel's project list as the panel views render it. SceneControls
* owns the project presentation: it publishes here and attaches the row
* actions; the views only render and forward clicks.
*/
export const useSceneStore = defineStore('gev-scenes', () => {
// Scenes arrive as fresh read-only copies; only replacing them re-renders.
const scenes = shallowRef(markRaw([]));
const selectedSceneId = shallowRef(null);
const selectedShotId = shallowRef(null);
// The select's choice, updated only when its options are rendered.
const listedSceneId = shallowRef(null);
// Counts option renders: each one re-applies the select's choice, which
// the person may have changed since.
const listedRevision = shallowRef(0);
/**
* The panel's buttons, status line, progress and runtime chip:
* `{running, hasShots, disabled: {[button]: boolean}, status, progress,
* runtime, playLabel}`, or null until an owner presents them.
*/
const panel = shallowRef(null);
/** @param {?object} next A fresh presentation; every publish re-renders. */
function publishPanel(next) {
panel.value = next && markRaw(next);
}
/** Whether an owner presents the project; until then the list is empty. */
const attached = shallowRef(false);
/** @type {{handlers: SceneRowHandlers}|null} */
let owner = null;
/**
* Present the project for an owner, replacing any earlier owner.
* @param {SceneRowHandlers} handlers
* @returns {object} Token for detach().
*/
function attach(handlers) {
owner = { handlers };
attached.value = true;
return owner;
}
/** Publish the shot list; `scenes` is copied so every publish re-renders. */
function publish(state) {
scenes.value = markRaw([...(state.scenes ?? [])]);
selectedSceneId.value = state.selectedSceneId ?? null;
selectedShotId.value = state.selectedShotId ?? null;
}
/** Publish the project and the select's choice. */
function publishOptions(state) {
publish(state);
listedSceneId.value = state.selectedSceneId ?? null;
listedRevision.value++;
}
/** @param {string|null} id */
function selectShot(id) {
selectedShotId.value = id ?? null;
}
/**
* Stop presenting for the owner holding `token`: the list empties and row
* clicks do nothing. A later owner's presentation is left alone.
*/
function detach(token) {
if (token !== owner) return;
owner = null;
attached.value = false;
publishOptions({});
}
/** @returns {boolean} Whether `token` is the owner presenting now. */
function owns(token) {
return !!token && token === owner;
}
/**
* Forward a row action to the owner, if one is attached.
* @param {keyof SceneRowHandlers} name
* @returns {*} What the owner's handler returned (an import's promise).
*/
function act(name, ...args) {
return owner?.handlers[name]?.(...args);
}
return {
scenes,
selectedSceneId,
selectedShotId,
listedSceneId,
listedRevision,
attached,
panel,
publishPanel,
attach,
publish,
publishOptions,
selectShot,
detach,
owns,
act,
};
});
+38
View File
@@ -0,0 +1,38 @@
import { defineStore } from 'pinia';
import { markRaw, shallowRef } from 'vue';
/**
* The screen-space annotation board as its view renders it. The screen
* annotation renderer (src/annotations/screenAnnotationRenderer.js) presents
* every mark's SVG parts after each rendered frame; the view hands back the
* elements the renderer measures and reports when a draw-on stroke finishes.
*/
export const useScreenAnnotationsStore = defineStore(
'gev-screen-annotations',
() => {
/**
* `{owner, viewBox, markers, marks}`, or null while no renderer exists.
* Each mark is `{key, className, opacity, display, drawn, children}`;
* `owner` is passed back with each element and report.
*/
const board = shallowRef(null);
/** @param {?object} next A fresh presentation; every publish re-renders. */
function publish(next) {
board.value = next && markRaw(next);
}
/**
* The controls whose `attach(owner, key, kind, element)` and
* `drawn(owner, key)` the view calls.
*/
const controls = shallowRef(null);
/** @param {?object} next The controls, or null to disconnect. */
function connect(next) {
controls.value = next && markRaw(next);
}
return { board, publish, controls, connect };
},
);
+72
View File
@@ -0,0 +1,72 @@
import { defineStore } from 'pinia';
import { markRaw, shallowRef } from 'vue';
/**
* The scene's status chips as their views render them. ShellFeedback
* (src/ui/shellFeedback.js) publishes the top-center loading status and the
* road network chip, CctvControls the camera grid chip; the toast shows
* what any owner's createToast() (src/ui/toast.js) publishes, and the title
* bar the FPS readout createFrameRateMonitor() publishes. Each label keeps its
* last text while hidden, so the next change flaps from what was shown.
*/
export const useStatusStore = defineStore('gev-status', () => {
/**
* `{hidden, state, label, detail, stopped}`; null until first published.
* `stopped` rests a label for good once its owner is destroyed.
*/
const loading = shallowRef(null);
/** `{visible, label, immediate, progress, stopped}`, or null. */
const traffic = shallowRef(null);
/** `{visible, label, immediate, progress, stopped}`, or null. */
const cctv = shallowRef(null);
/**
* The page toast, `{text, visible, shown}`; null until the first one.
* `shown` changes with every show, which rewrites the text.
*/
const toast = shallowRef(null);
/**
* The title bar's FPS readout, `{visible, text}`; null while no monitor
* counts frames.
*/
const fps = shallowRef(null);
/** @param {?object} next A fresh presentation of the loading status. */
function publishLoading(next) {
loading.value = next && markRaw(next);
}
/** @param {?object} next A fresh presentation of the road network chip. */
function publishTraffic(next) {
traffic.value = next && markRaw(next);
}
/** @param {?object} next A fresh presentation of the camera grid chip. */
function publishCctv(next) {
cctv.value = next && markRaw(next);
}
/** @param {?{text: string, visible: boolean, shown: number}} next */
function publishToast(next) {
toast.value = next && markRaw(next);
}
/** @param {?{visible: boolean, text: string}} next */
function publishFps(next) {
fps.value = next && markRaw(next);
}
return {
fps,
publishFps,
toast,
publishToast,
loading,
publishLoading,
traffic,
publishTraffic,
cctv,
publishCctv,
};
});
+80
View File
@@ -0,0 +1,80 @@
import { defineStore } from 'pinia';
import { markRaw, shallowRef } from 'vue';
/**
* @typedef {object} StreetLevelHandlers
* @property {(stop: number) => void} setSinceStop Record a SINCE stop.
* @property {(stop: number) => string} describeSinceStop A stop's readout.
*/
/**
* The Street Level panel as its view renders it. StreetLevelControls owns
* the presentation (`presentStreetLevelPanel()`), the viewer and EXPAND: it
* publishes here and attaches the actions the view forwards.
*/
export const useStreetLevelStore = defineStore('gev-street-level', () => {
/** The presented panel; null until an owner renders, then its last render. */
const view = shallowRef(null);
/** Whether EXPAND has the viewer full screen; null until first synced. */
const expanded = shallowRef(null);
/** False on a page with neither element fullscreen nor popovers. */
const expandAvailable = shallowRef(true);
/** @type {{handlers: StreetLevelHandlers}|null} */
let owner = null;
/**
* Present the panel for an owner, replacing any earlier owner.
* @param {StreetLevelHandlers} handlers
* @returns {object} Token for detach().
*/
function attach(handlers) {
owner = { handlers };
return owner;
}
/** @param {object} next A fresh presentation; every publish re-renders. */
function publish(next) {
view.value = markRaw(next);
}
/** @param {boolean} on */
function setExpanded(on) {
expanded.value = Boolean(on);
}
/** @param {boolean} available */
function setExpandAvailable(available) {
expandAvailable.value = Boolean(available);
}
/**
* Stop forwarding actions to the owner holding `token`. The panel keeps
* its last render, as the page did when its controls were wired by hand.
*/
function detach(token) {
if (owner === token) owner = null;
}
/** Forward a view action to the owner. */
function act(name, ...args) {
owner?.handlers[name]?.(...args);
}
/** The readout of a SINCE stop while its thumb is dragged. */
function describeSinceStop(stop) {
return owner?.handlers.describeSinceStop?.(stop) ?? '';
}
return {
view,
expanded,
expandAvailable,
attach,
publish,
setExpanded,
setExpandAvailable,
detach,
act,
describeSinceStop,
};
});
+39
View File
@@ -0,0 +1,39 @@
import { defineStore } from 'pinia';
import { markRaw, shallowRef } from 'vue';
/**
* The voice control as the command dock renders it. The voice control
* presenter (src/voice/control.js) holds the control's state for the session
* owners and publishes it here; the view sends clicks, keys and form changes
* back to the connected presenter.
*/
export const useVoiceStore = defineStore('gev-voice', () => {
/** The presented control; null while no voice session owns one. */
const view = shallowRef(null);
/** @param {?object} next A fresh presentation; every publish re-renders. */
function publish(next) {
view.value = next && markRaw(next);
}
/** The presenter the view calls, or null while none is wired. */
const controls = shallowRef(null);
/** @param {?object} next The presenter, or null to disconnect. */
function connect(next) {
controls.value = next && markRaw(next);
}
/**
* The waveform's bars, apart from the view: they change every animation
* frame while voice is live, and only the visualizer renders them.
*/
const bars = shallowRef(null);
/** @param {?Array<{level: string, opacity: string}>} next */
function publishBars(next) {
bars.value = next && markRaw(next);
}
return { view, publish, controls, connect, bars, publishBars };
});
+22
View File
@@ -0,0 +1,22 @@
import { defineStore } from 'pinia';
import { markRaw, shallowRef } from 'vue';
/**
* The wind inspection marker as its view renders it. The marker owner
* (src/layers/wind/inspectionMarker.js) presents where the inspected point
* falls on screen after every rendered frame.
*/
export const useWindInspectionStore = defineStore('gev-wind-inspection', () => {
/**
* `{owner, container, visible, left, top}`, in pixels from the container's
* corner, or null while no point is inspected.
*/
const marker = shallowRef(null);
/** @param {?object} next A fresh presentation; every publish re-renders. */
function publish(next) {
marker.value = next && markRaw(next);
}
return { marker, publish };
});
+34
View File
@@ -0,0 +1,34 @@
import { defineStore } from 'pinia';
import { markRaw, shallowRef } from 'vue';
/**
* The visible map target list as its view renders it. The world overlay
* (src/overlays/worldOverlay.js) presents the actionable cards it painted and
* the last focus announcement; the application shell publishes them here and
* connects the overlay's activation.
*/
export const useWorldOverlayActionsStore = defineStore(
'gev-world-overlay-actions',
() => {
/**
* `{owner, items: [{key, label, selected}], status}`, or null without an
* overlay host. `owner` is passed back with each activation.
*/
const actions = shallowRef(null);
/** @param {?object} next A fresh presentation; every publish re-renders. */
function publish(next) {
actions.value = next && markRaw(next);
}
/** The controls whose `activate(owner, key)` a target button calls. */
const controls = shallowRef(null);
/** @param {?object} next The controls, or null to disconnect. */
function connect(next) {
controls.value = next && markRaw(next);
}
return { actions, publish, controls, connect };
},
);