mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-23 11:42:21 +00:00
Merge main into byrdit/recent-imagery-dateline
This commit is contained in:
commit
8fd0a35f6a
391 files changed
+32429
-1796
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { followedOf } from '../data/followed.js';
|
||||
import { readEntityRecord } from '../data/entityRecords.js';
|
||||
import { nextTick } from 'vue';
|
||||
import { nextTick, watch } from 'vue';
|
||||
import { resolveImageryHost } from '../layers/weather/imageryHost.js';
|
||||
import { ShellFacade } from './shellFacade.js';
|
||||
import { AircraftDisplay } from './aircraftDisplay.js';
|
||||
@@ -25,6 +25,7 @@ import { CctvControls } from './cctv.js';
|
||||
import { StreetLevelControls } from './streetLevelControls.js';
|
||||
import { createWildlifeSightingCard } from './wildlifeSightingCard.js';
|
||||
import { RadioControls } from './radio.js';
|
||||
import { LiveControls } from './liveControls.js';
|
||||
import { LocalSdrControls } from './localSdrControls.js';
|
||||
import { LocationNavigation } from './locationNavigation.js';
|
||||
import { bindCameraOrientationControls } from './cameraOrientationControls.js';
|
||||
@@ -62,9 +63,12 @@ import { applyLocaleChoice } from './localePicker.js';
|
||||
import { PanelNavigation } from './panelNavigation.js';
|
||||
import { applicationPinia, createUiRuntime } from './vueRuntime.js';
|
||||
import { useContextStore } from './stores/context.js';
|
||||
import { useLiveStore } from './stores/live.js';
|
||||
import { useStationStore } from './stores/station.js';
|
||||
import { useSpaceMissionsStore } from './stores/spaceMissions.js';
|
||||
import { SpaceMissionsControls } from './spaceMissionsControls.js';
|
||||
import { useMissionReplayStore } from './stores/missionReplay.js';
|
||||
import { useStreetLevelPhotoStore } from './stores/streetLevelPhoto.js';
|
||||
import { useCelestialRingStore } from './stores/celestialRing.js';
|
||||
import { icrfToFixedAxes } from '../sky/icrf.js';
|
||||
import { useWorldOverlayActionsStore } from './stores/worldOverlayActions.js';
|
||||
@@ -117,6 +121,8 @@ export class StyleManager extends ShellFacade {
|
||||
* @param {{lon: number, lat: number, height: number, heading?: number,
|
||||
* pitch?: number}|null} [options.homeView] - where the title's logo goes
|
||||
* back to (degrees): the view the app started from.
|
||||
* @param {string[]} [options.startLayers] - the layers a bare address (one
|
||||
* that carries no link) starts with; none by default.
|
||||
*/
|
||||
constructor(
|
||||
viewer,
|
||||
@@ -128,6 +134,7 @@ export class StyleManager extends ShellFacade {
|
||||
initialShareCode = null,
|
||||
localePicker = true,
|
||||
homeView = null,
|
||||
startLayers = [],
|
||||
} = {},
|
||||
) {
|
||||
super();
|
||||
@@ -256,6 +263,7 @@ export class StyleManager extends ShellFacade {
|
||||
updateFeedback: () => this._updateGlobalLoadingFeedback(),
|
||||
applyFollowOffset: (followed, offset) =>
|
||||
applyShareFollowOffset(viewer, followed, offset),
|
||||
startLayers,
|
||||
});
|
||||
|
||||
this._visualSettings = new VisualSettings({
|
||||
@@ -1029,8 +1037,12 @@ export class StyleManager extends ShellFacade {
|
||||
}
|
||||
|
||||
_initGlobalContextPanel() {
|
||||
const { radioLayer, militaryInstallationsLayer, militaryAwarenessLayer } =
|
||||
this.services;
|
||||
const {
|
||||
radioLayer,
|
||||
militaryInstallationsLayer,
|
||||
militaryAwarenessLayer,
|
||||
satellitesLayer,
|
||||
} = this.services;
|
||||
const contextStore = useContextStore(applicationPinia());
|
||||
this._contextControls = new ContextControls({
|
||||
elements: {
|
||||
@@ -1070,6 +1082,39 @@ export class StyleManager extends ShellFacade {
|
||||
militaryAwarenessLayer?.subscribeDirectionOverlay?.((view) =>
|
||||
awarenessDirectionStore.publish(view),
|
||||
);
|
||||
// The STATION section: the selected space station's moving parts, as
|
||||
// the satellites layer presents them; its controls reach the layer.
|
||||
const stationStore = useStationStore(applicationPinia());
|
||||
this._stationPanelUnsubscribe?.();
|
||||
if (this._stationOwner) stationStore.detach(this._stationOwner);
|
||||
this._stationOwner = null;
|
||||
stationStore.publish(null);
|
||||
if (satellitesLayer?.getStationActions)
|
||||
this._stationOwner = stationStore.connect(
|
||||
satellitesLayer.getStationActions(),
|
||||
);
|
||||
this._stationPanelUnsubscribe = satellitesLayer?.subscribeStationPanel?.(
|
||||
(view) => stationStore.publish(view),
|
||||
);
|
||||
// The LIVE section: streams attached to whatever the tracking layers
|
||||
// select, in the platform's own player, loaded only once Play is pressed.
|
||||
this._liveControls?.destroy();
|
||||
const liveStore = useLiveStore(applicationPinia());
|
||||
this._liveControls = new LiveControls({
|
||||
store: liveStore,
|
||||
actions: {
|
||||
getLayer: (layerId) =>
|
||||
this._dataManager?.layers?.get(layerId)?.module ?? null,
|
||||
scheduleLayout: () => this._scheduleRightPanelLayout(),
|
||||
},
|
||||
});
|
||||
// The Cockpit briefing offers its LIVE page while a stream is on offer.
|
||||
this._liveOfferedUnwatch?.();
|
||||
this._liveOfferedUnwatch = watch(
|
||||
() => liveStore.view !== null,
|
||||
(offered) => this.cockpitView?.setBriefLiveOffered?.(offered),
|
||||
{ immediate: true },
|
||||
);
|
||||
}
|
||||
|
||||
_initSpaceMissionsPanel() {
|
||||
@@ -1200,7 +1245,18 @@ export class StyleManager extends ShellFacade {
|
||||
const { streetLevelLayer } = this.services;
|
||||
this._streetLevelControls?.destroy();
|
||||
this._streetLevelControls = null;
|
||||
// The photo viewer (KartaView, Panoramax), which the layer panels draw
|
||||
// into the viewer host. A viewer left by an earlier shell must
|
||||
// not outlive its layer.
|
||||
const streetLevelPhotoStore = useStreetLevelPhotoStore(applicationPinia());
|
||||
this._streetLevelPhotoUnsubscribe?.();
|
||||
this._streetLevelPhotoUnsubscribe = null;
|
||||
streetLevelPhotoStore.publish(null);
|
||||
if (!this._streetLevelPanel || !streetLevelLayer) return;
|
||||
this._streetLevelPhotoUnsubscribe =
|
||||
streetLevelLayer.subscribePhotoViewer?.((view) =>
|
||||
streetLevelPhotoStore.publish(view),
|
||||
) ?? null;
|
||||
// Photo framing yields to newer navigation and releases tracking like
|
||||
// any deferred flight.
|
||||
streetLevelLayer.attachNavigation?.({
|
||||
@@ -1959,6 +2015,14 @@ export class StyleManager extends ShellFacade {
|
||||
this.services?.streetLevelLayer?.attachNavigation?.(null);
|
||||
this._streetLevelControls?.destroy();
|
||||
this._radioControls?.destroy();
|
||||
this._liveControls?.destroy();
|
||||
this._liveOfferedUnwatch?.();
|
||||
this._liveOfferedUnwatch = null;
|
||||
this._stationPanelUnsubscribe?.();
|
||||
this._stationPanelUnsubscribe = null;
|
||||
if (this._stationOwner)
|
||||
useStationStore(applicationPinia()).detach(this._stationOwner);
|
||||
this._stationOwner = null;
|
||||
this._localSdrControls?.destroy();
|
||||
this._awarenessPanelUnsubscribe?.();
|
||||
this._awarenessPanelUnsubscribe = null;
|
||||
@@ -1969,7 +2033,10 @@ export class StyleManager extends ShellFacade {
|
||||
this._spaceMissionsControls = null;
|
||||
this._missionReplayUnsubscribe?.();
|
||||
this._missionReplayUnsubscribe = null;
|
||||
this._streetLevelPhotoUnsubscribe?.();
|
||||
this._streetLevelPhotoUnsubscribe = null;
|
||||
useMissionReplayStore(applicationPinia()).publish(null);
|
||||
useStreetLevelPhotoStore(applicationPinia()).publish(null);
|
||||
const contextStore = useContextStore(applicationPinia());
|
||||
contextStore.connectAwareness(null);
|
||||
contextStore.publishAwareness(null);
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
<script setup>
|
||||
import { t } from '../../i18n/index.js';
|
||||
|
||||
// The Bhote Koshi event's embedded media cards and the hidden YouTube
|
||||
// preload, as src/data/bhoteKoshiEmbeddedMedia.js presents them inside its
|
||||
// overlay root. The owner renders synchronously on every change and places
|
||||
// each card beside its map anchor after each frame (its position, its
|
||||
// leader's line and whether it shows); a card's player is filled by the
|
||||
// provider: the YouTube frame drawn here, or the Facebook player and X post
|
||||
// the provider SDKs build inside it. The card's body takes taps (the root
|
||||
// and the leader do not); Stories keeps that.
|
||||
defineProps({
|
||||
/** `{key, src, title}` of the hidden YouTube preload, or null. */
|
||||
warm: { type: Object, default: null },
|
||||
/**
|
||||
* The cards in insertion order: `{id, provider, portrait, entering,
|
||||
* leaving, unavailable, label, title, status, url, frame, bind}`; `frame`
|
||||
* is `{src, title, onLoad}` for a YouTube card and null otherwise, and
|
||||
* `bind(name, element)` hands the owner the elements it places and fills.
|
||||
*/
|
||||
cards: { type: Array, default: () => [] },
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<iframe
|
||||
v-if="warm"
|
||||
:key="warm.key"
|
||||
class="bhote-embedded-media-warmup"
|
||||
:src="warm.src"
|
||||
:title="warm.title"
|
||||
tabindex="-1"
|
||||
aria-hidden="true"
|
||||
loading="eager"
|
||||
referrerpolicy="strict-origin-when-cross-origin"
|
||||
></iframe>
|
||||
<section
|
||||
v-for="card in cards"
|
||||
:key="card.id"
|
||||
:ref="(el) => card.bind('card', el)"
|
||||
class="bhote-embedded-callout"
|
||||
:class="[
|
||||
`is-${card.provider}`,
|
||||
{
|
||||
'is-portrait': card.portrait,
|
||||
'is-entering': card.entering,
|
||||
'is-leaving': card.leaving,
|
||||
'is-unavailable': card.unavailable,
|
||||
},
|
||||
]"
|
||||
:data-provider="card.provider"
|
||||
:aria-label="card.label"
|
||||
>
|
||||
<svg
|
||||
:ref="(el) => card.bind('leader', el)"
|
||||
class="bhote-embedded-callout-leader"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<path
|
||||
pathLength="1"
|
||||
fill="none"
|
||||
stroke="rgba(147,213,228,.72)"
|
||||
stroke-width="1.5"
|
||||
/>
|
||||
<circle r="4" fill="#6be8ff" stroke="#ffffff" stroke-width="1.5" />
|
||||
</svg>
|
||||
<div class="bhote-embedded-callout-body" data-overlay-input>
|
||||
<div
|
||||
v-if="card.frame"
|
||||
:ref="(el) => card.bind('player', el)"
|
||||
class="bhote-embedded-callout-player ui-scroll"
|
||||
>
|
||||
<iframe
|
||||
:ref="(el) => card.bind('frameElement', el)"
|
||||
:src="card.frame.src"
|
||||
:title="card.frame.title"
|
||||
allow="autoplay; encrypted-media; picture-in-picture; fullscreen"
|
||||
allowfullscreen
|
||||
loading="eager"
|
||||
referrerpolicy="strict-origin-when-cross-origin"
|
||||
@load.once="card.frame.onLoad"
|
||||
></iframe>
|
||||
</div>
|
||||
<div
|
||||
v-else
|
||||
:ref="(el) => card.bind('player', el)"
|
||||
class="bhote-embedded-callout-player ui-scroll"
|
||||
></div>
|
||||
<footer>
|
||||
<strong>{{ card.title }}</strong>
|
||||
<small role="status">{{ card.status }}</small>
|
||||
<a :href="card.url" target="_blank" rel="noopener noreferrer">{{
|
||||
t('OPEN ORIGINAL ↗')
|
||||
}}</a>
|
||||
</footer>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -3,6 +3,7 @@ import { storeToRefs } from 'pinia';
|
||||
import { computed } from 'vue';
|
||||
import { t } from '../../i18n/index.js';
|
||||
import { useCctvStore } from '../stores/cctv.js';
|
||||
import UiButton from '../kit/UiButton.vue';
|
||||
|
||||
// One click-to-type pose chip. The panel's delegated click starts an edit
|
||||
// in CctvControls, which publishes it; the chip then holds a number input
|
||||
@@ -42,7 +43,7 @@ function onBlur(event) {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<button
|
||||
<UiButton
|
||||
class="cctv-cal-value"
|
||||
:data-cal-field="field"
|
||||
:disabled="edit ? false : view?.calibration.disabled"
|
||||
@@ -60,6 +61,6 @@ function onBlur(event) {
|
||||
@click.stop /></template
|
||||
><template v-else>{{
|
||||
view?.calibration.values[field] ?? `${t(label)} --`
|
||||
}}</template></button
|
||||
}}</template></UiButton
|
||||
>
|
||||
</template>
|
||||
@@ -0,0 +1,197 @@
|
||||
// src/ui/cctvPickerOpening.test.mjs — the picker and the opening camera.
|
||||
// The opening camera follows the view until someone picks one. The picker
|
||||
// shows it as its own option; a native select fires no change for the
|
||||
// option it already shows, so FOCUS keeps that camera, and leaving the list
|
||||
// without a choice lets it follow the view.
|
||||
import '../testSupport/registerDom.mjs';
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import * as Cesium from 'cesium';
|
||||
import { createPinia } from 'pinia';
|
||||
import { createApp, nextTick } from 'vue';
|
||||
import cctvLayer, {
|
||||
_setCctvCoverageStateForTest,
|
||||
_setCctvOverlayHostForTest,
|
||||
reopenNearestCamera,
|
||||
} from '../data/cctv.js';
|
||||
import { bindFakeDraw } from '../testSupport/fakeDrawPort.mjs';
|
||||
import { CctvControls } from './cctvControls.js';
|
||||
import { useCctvStore } from './stores/cctv.js';
|
||||
import CctvPanel from './views/panels/CctvPanel.vue';
|
||||
|
||||
const TRAFALGAR = [51.508, -0.128];
|
||||
const CAMBRIDGE = [51.513, -0.129];
|
||||
|
||||
function record(id, [lat, lon]) {
|
||||
return {
|
||||
camera: {
|
||||
id,
|
||||
name: `Camera ${id}`,
|
||||
city: 'London',
|
||||
lat,
|
||||
lon,
|
||||
headingDeg: 41,
|
||||
pitchDeg: -5,
|
||||
fovDeg: 56,
|
||||
rangeM: 210,
|
||||
mountHeightM: 100,
|
||||
groundElevationM: 0,
|
||||
},
|
||||
coverageEntities: [],
|
||||
projection: null,
|
||||
activationDone: true,
|
||||
groundResolved: {},
|
||||
groundSamples: {},
|
||||
groundPrior: 0,
|
||||
frustumGeometry: null,
|
||||
frustumPositions: null,
|
||||
probeClampRangeM: null,
|
||||
position: Cesium.Cartesian3.fromDegrees(lon, lat, 100),
|
||||
};
|
||||
}
|
||||
|
||||
function viewerAt([lat, lon]) {
|
||||
const viewer = {
|
||||
isDestroyed: () => false,
|
||||
eye: { lat, lon, height: 300 },
|
||||
scene: {
|
||||
canvas: { clientWidth: 1200, clientHeight: 800 },
|
||||
cartesianToCanvasCoordinates: () => undefined,
|
||||
primitives: { add: (p) => p, remove: () => true },
|
||||
requestRender() {},
|
||||
},
|
||||
};
|
||||
// The layer reads the eye and flies through the renderer's camera port.
|
||||
viewer.draw = bindFakeDraw(viewer, {
|
||||
camera: {
|
||||
pose: () => ({ ...viewer.eye }),
|
||||
on: () => () => {},
|
||||
followed: null,
|
||||
flyToBounds() {},
|
||||
},
|
||||
}).draw;
|
||||
return viewer;
|
||||
}
|
||||
|
||||
/** A settled move: the view is now over `[lat, lon]`. */
|
||||
function settleOver(viewer, [lat, lon]) {
|
||||
viewer.eye = { lat, lon, height: 300 };
|
||||
return reopenNearestCamera();
|
||||
}
|
||||
|
||||
/**
|
||||
* CCTV opened at Trafalgar Square, then a settled move re-opened it at
|
||||
* Cambridge Circus; the panel is connected to the layer.
|
||||
*/
|
||||
async function reopenedAtCambridge(t) {
|
||||
_setCctvOverlayHostForTest({
|
||||
setEntries() {},
|
||||
setVisible() {},
|
||||
clearSource() {},
|
||||
});
|
||||
// Activation builds the frame image and asks for ground heights; this test
|
||||
// has no server. happy-dom's request timeout would hold the run open 30 s.
|
||||
const originalImage = globalThis.Image;
|
||||
const originalFetch = globalThis.fetch;
|
||||
const originalTimeout = AbortSignal.timeout;
|
||||
globalThis.Image = class {};
|
||||
globalThis.fetch = async () => {
|
||||
throw new TypeError('no server in this test');
|
||||
};
|
||||
AbortSignal.timeout = () => new AbortController().signal;
|
||||
const trafalgar = record('a-trafalgar', TRAFALGAR);
|
||||
const cambridge = record('b-cambridge', CAMBRIDGE);
|
||||
// enable() assigned the opening camera without activating it.
|
||||
trafalgar.activationDone = false;
|
||||
const viewer = viewerAt(TRAFALGAR);
|
||||
_setCctvCoverageStateForTest({
|
||||
viewer,
|
||||
records: [trafalgar, cambridge],
|
||||
activeCameraId: 'a-trafalgar',
|
||||
enabled: true,
|
||||
openingCameraProvisional: true,
|
||||
});
|
||||
|
||||
document.body.replaceChildren();
|
||||
const host = document.body.appendChild(document.createElement('div'));
|
||||
const pinia = createPinia();
|
||||
const app = createApp(CctvPanel).use(pinia);
|
||||
app.mount(host);
|
||||
const select = document.getElementById('cctv-camera-select');
|
||||
const controls = new CctvControls({
|
||||
elements: {
|
||||
_cctvPanel: document.getElementById('cctv-panel'),
|
||||
_cctvSelect: select,
|
||||
_cctvFocusBtn: document.getElementById('cctv-focus-btn'),
|
||||
},
|
||||
cctv: cctvLayer,
|
||||
actions: {
|
||||
isEnabled: () => true,
|
||||
toggleEnabled: async () => true,
|
||||
runExplicitFocus(select, focus) {
|
||||
const cameraId = select();
|
||||
if (cameraId) focus(cameraId);
|
||||
},
|
||||
setParams: (params) => cctvLayer.setParams(params),
|
||||
setPanelCollapsed() {},
|
||||
syncViewport() {},
|
||||
},
|
||||
store: useCctvStore(pinia),
|
||||
});
|
||||
controls.connect();
|
||||
t.after(() => {
|
||||
controls.destroy();
|
||||
app.unmount();
|
||||
globalThis.Image = originalImage;
|
||||
globalThis.fetch = originalFetch;
|
||||
AbortSignal.timeout = originalTimeout;
|
||||
_setCctvOverlayHostForTest();
|
||||
_setCctvCoverageStateForTest({ enabled: false });
|
||||
});
|
||||
|
||||
assert.equal(settleOver(viewer, CAMBRIDGE), true);
|
||||
await nextTick();
|
||||
assert.equal(cctvLayer.getUIState().activeCameraId, 'b-cambridge');
|
||||
return { viewer, select };
|
||||
}
|
||||
|
||||
test('the opening camera shows as its own option', async (t) => {
|
||||
const { select } = await reopenedAtCambridge(t);
|
||||
assert.equal(select.value, 'b-cambridge');
|
||||
const shown = select.options[select.selectedIndex];
|
||||
assert.equal(shown.hidden, false);
|
||||
assert.equal(shown.disabled, false);
|
||||
assert.equal(
|
||||
[...select.options].filter((option) => option.value === 'b-cambridge')
|
||||
.length,
|
||||
1,
|
||||
'the list shows the camera once',
|
||||
);
|
||||
assert.ok([...select.options].every((option) => !option.hidden));
|
||||
});
|
||||
|
||||
test('FOCUS on the shown camera keeps it after a pan', async (t) => {
|
||||
const { viewer, select } = await reopenedAtCambridge(t);
|
||||
const focus = document.getElementById('cctv-focus-btn');
|
||||
assert.equal(focus.disabled, false);
|
||||
focus.click();
|
||||
// The click handler waits for the layer switch before it picks.
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
await nextTick();
|
||||
|
||||
assert.equal(settleOver(viewer, TRAFALGAR), false);
|
||||
assert.equal(cctvLayer.getUIState().activeCameraId, 'b-cambridge');
|
||||
assert.equal(select.value, 'b-cambridge');
|
||||
});
|
||||
|
||||
test('leaving the picker without a pick lets the camera follow a pan', async (t) => {
|
||||
const { viewer, select } = await reopenedAtCambridge(t);
|
||||
select.focus();
|
||||
select.blur();
|
||||
await nextTick();
|
||||
|
||||
assert.equal(settleOver(viewer, TRAFALGAR), true);
|
||||
await nextTick();
|
||||
assert.equal(cctvLayer.getUIState().activeCameraId, 'a-trafalgar');
|
||||
assert.equal(select.value, 'a-trafalgar');
|
||||
});
|
||||
@@ -46,6 +46,48 @@ export const COCKPIT_BRIEF_PAGES = [
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* The fourth page, LIVE: the ridden subject's live video, the LIVE section
|
||||
* of Context in the card. Offered only while a stream is on offer (the
|
||||
* `gev-live` store's view is not null); the automatic cycle never turns to it.
|
||||
*/
|
||||
export const COCKPIT_LIVE_BRIEF_PAGE = Object.freeze({
|
||||
id: 'live',
|
||||
kickerKey: msg('LIVE VIDEO'),
|
||||
subtitleKey: msg('STREAM ATTACHED TO THE SUBJECT'),
|
||||
// Attribution stays English; the page itself credits the stream's owner.
|
||||
source: 'YOUTUBE EMBEDDED PLAYER · MUTED',
|
||||
});
|
||||
|
||||
/**
|
||||
* The pages on offer: the three fixed ones, and LIVE after them while the
|
||||
* ridden subject has a stream.
|
||||
* @param {boolean} liveOffered
|
||||
* @returns {readonly object[]}
|
||||
*/
|
||||
export function cockpitBriefPages(liveOffered) {
|
||||
return liveOffered
|
||||
? [...COCKPIT_BRIEF_PAGES, COCKPIT_LIVE_BRIEF_PAGE]
|
||||
: COCKPIT_BRIEF_PAGES;
|
||||
}
|
||||
|
||||
/**
|
||||
* Where the automatic cycle goes from the page at `index`: the next page
|
||||
* that is not LIVE (video is never started by the cycle), wrapping; null
|
||||
* while LIVE is the shown page, where the cycle waits as it does under the
|
||||
* pointer.
|
||||
* @param {readonly object[]} pages
|
||||
* @param {number} index
|
||||
* @returns {number|null}
|
||||
*/
|
||||
export function briefCycleTarget(pages, index) {
|
||||
if (pages[index]?.id === 'live') return null;
|
||||
const count = pages.length;
|
||||
let next = (index + 1) % count;
|
||||
if (pages[next]?.id === 'live') next = (next + 1) % count;
|
||||
return next;
|
||||
}
|
||||
|
||||
// The cycle toggle's tooltip, as literal keys for the extractor.
|
||||
export const CYCLE_HELP_KEYS = Object.freeze({
|
||||
on: msg(
|
||||
|
||||
@@ -9,8 +9,9 @@ import {
|
||||
formatCockpitWindDirection,
|
||||
} from './cockpitPresentation.js';
|
||||
import {
|
||||
COCKPIT_BRIEF_PAGES,
|
||||
CYCLE_HELP_KEYS,
|
||||
briefCycleTarget,
|
||||
cockpitBriefPages,
|
||||
createBriefState,
|
||||
newsWindowFooter,
|
||||
} from './cockpitBriefPages.js';
|
||||
@@ -48,11 +49,17 @@ export function publishBriefView() {
|
||||
});
|
||||
}
|
||||
|
||||
/** The pages on offer now: three, or four with LIVE while a stream is. */
|
||||
function briefPages() {
|
||||
return cockpitBriefPages(this.briefLiveOffered === true);
|
||||
}
|
||||
|
||||
export function showBriefPage(index, { manual = false } = {}) {
|
||||
if (this.destroyed) return;
|
||||
const count = COCKPIT_BRIEF_PAGES.length;
|
||||
const pages = briefPages.call(this);
|
||||
const count = pages.length;
|
||||
this.briefPageIndex = ((Number(index) % count) + count) % count;
|
||||
const page = COCKPIT_BRIEF_PAGES[this.briefPageIndex];
|
||||
const page = pages[this.briefPageIndex];
|
||||
Object.assign(this.brief, {
|
||||
pageIndex: this.briefPageIndex,
|
||||
pageId: page.id,
|
||||
@@ -101,6 +108,20 @@ export function relocalizeBrief() {
|
||||
this.renderRegionalBriefStatus(this.brief.news.state, this.lastSubjectInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Offer or withdraw the LIVE page, as the ridden subject's stream comes and
|
||||
* goes. A LIVE page shown as its stream goes falls back to Live Signals;
|
||||
* otherwise the shown page stays and its position counts the pages anew.
|
||||
*/
|
||||
export function setBriefLiveOffered(offered) {
|
||||
if (this.destroyed) return;
|
||||
const next = offered === true;
|
||||
if (next === this.briefLiveOffered) return;
|
||||
this.briefLiveOffered = next;
|
||||
const count = cockpitBriefPages(next).length;
|
||||
this.showBriefPage(this.briefPageIndex < count ? this.briefPageIndex : 0);
|
||||
}
|
||||
|
||||
export function setBriefAutoRotate(enabled) {
|
||||
if (this.destroyed) return;
|
||||
this.briefAutoRotateEnabled = Boolean(enabled);
|
||||
@@ -129,7 +150,13 @@ export function startBriefRotation({ reset = false } = {}) {
|
||||
this.signalStream?.contains(document.activeElement) === true;
|
||||
const isInteracting = hasPointer || hasFocus;
|
||||
if (!isInteracting) {
|
||||
this.showBriefPage(this.briefPageIndex + 1);
|
||||
// The cycle never turns to the LIVE page, and waits while it is shown:
|
||||
// video starts and stops on request only.
|
||||
const target = briefCycleTarget(
|
||||
briefPages.call(this),
|
||||
this.briefPageIndex,
|
||||
);
|
||||
if (target !== null) this.showBriefPage(target);
|
||||
}
|
||||
this.startBriefRotation();
|
||||
}, COCKPIT_BRIEF_ROTATE_MS);
|
||||
|
||||
@@ -8,18 +8,24 @@ import { fileURLToPath } from 'node:url';
|
||||
import { createPinia } from 'pinia';
|
||||
import { createApp, nextTick } from 'vue';
|
||||
import { setLocale } from '../i18n/index.js';
|
||||
import { createBriefState } from './cockpitBriefPages.js';
|
||||
import {
|
||||
briefCycleTarget,
|
||||
cockpitBriefPages,
|
||||
createBriefState,
|
||||
} from './cockpitBriefPages.js';
|
||||
import {
|
||||
maybeRefreshRegionalBrief,
|
||||
publishBriefView,
|
||||
renderRegionalBrief,
|
||||
renderRegionalBriefStatus,
|
||||
setBriefAutoRotate,
|
||||
setBriefLiveOffered,
|
||||
showBriefPage,
|
||||
updateLocalPosition,
|
||||
} from './cockpitBriefing.js';
|
||||
import { setSignalCollapsed } from './cockpitLayout.js';
|
||||
import { useCockpitStore } from './stores/cockpit.js';
|
||||
import { useLiveStore } from './stores/live.js';
|
||||
import CockpitBriefing from './views/panels/CockpitBriefing.vue';
|
||||
|
||||
function fixture(t) {
|
||||
@@ -35,9 +41,11 @@ function fixture(t) {
|
||||
destroyed: false,
|
||||
briefPageIndex: 0,
|
||||
briefAutoRotateEnabled: false,
|
||||
briefLiveOffered: false,
|
||||
brief: createBriefState(),
|
||||
publishBrief: (view) => store.publishBrief(view),
|
||||
publishBriefView,
|
||||
showBriefPage,
|
||||
scheduleContextLayout() {},
|
||||
startBriefRotation() {},
|
||||
stopBriefRotation() {},
|
||||
@@ -49,11 +57,50 @@ function fixture(t) {
|
||||
[...document.querySelectorAll('[data-cockpit-brief-page]')]
|
||||
.filter((page) => !page.hidden)
|
||||
.map((page) => page.dataset.cockpitBriefPage);
|
||||
// The tabs on offer: the LIVE tab is in the markup but hidden without a stream.
|
||||
const current = () =>
|
||||
[...document.querySelectorAll('[data-cockpit-brief-index]')].map((tab) =>
|
||||
tab.getAttribute('aria-current'),
|
||||
[...document.querySelectorAll('[data-cockpit-brief-index]')]
|
||||
.filter((tab) => !tab.hidden)
|
||||
.map((tab) => tab.getAttribute('aria-current'));
|
||||
// A stream on offer for the ridden subject, as LiveControls publishes it;
|
||||
// the briefing then offers its LIVE page.
|
||||
const liveStore = useLiveStore(pinia);
|
||||
const liveActed = [];
|
||||
liveStore.connect({
|
||||
cycleLive: (direction) => liveActed.push(['cycle', direction]),
|
||||
playLive: () => liveActed.push(['play']),
|
||||
stopLive: () => liveActed.push(['stop']),
|
||||
retryLive: () => liveActed.push(['retry']),
|
||||
hideLive: (where) => liveActed.push(['hide', where]),
|
||||
});
|
||||
const offerLive = async (view) => {
|
||||
liveStore.publish(
|
||||
view && {
|
||||
label: 'ISS (ZARYA)',
|
||||
streams: [
|
||||
{ id: 'iss-exterior', title: 'Exterior cameras', owner: 'NASA' },
|
||||
{ id: 'iss-crew', title: 'Live video and audio', owner: 'NASA' },
|
||||
],
|
||||
index: 0,
|
||||
count: 2,
|
||||
current: {
|
||||
id: 'iss-exterior',
|
||||
title: 'Exterior cameras',
|
||||
owner: 'NASA',
|
||||
ownerUrl: 'https://www.youtube.com/@NASA',
|
||||
note: 'NASA video, via YouTube',
|
||||
watchUrl: 'https://www.youtube.com/watch?v=ROboUHfPUrU',
|
||||
},
|
||||
state: 'idle',
|
||||
reason: null,
|
||||
...view,
|
||||
},
|
||||
);
|
||||
return { $, text, owner, visiblePages, current };
|
||||
setBriefLiveOffered.call(owner, view !== null);
|
||||
await nextTick();
|
||||
await nextTick();
|
||||
};
|
||||
return { $, text, owner, visiblePages, current, offerLive, liveActed };
|
||||
}
|
||||
|
||||
const INFO = { latitude: 30.25, longitude: -97.75 };
|
||||
@@ -111,6 +158,157 @@ test('pages, the cycle toggle and the source follow the controller', async (t) =
|
||||
assert.match(auto.title, /^Stop automatic page cycling/);
|
||||
});
|
||||
|
||||
test('without a stream the briefing keeps its three pages and hides the LIVE tab', async (t) => {
|
||||
const { $, text, owner, visiblePages } = fixture(t);
|
||||
const liveTab = $('[data-cockpit-brief-index="3"]');
|
||||
assert.equal(liveTab.hidden, true);
|
||||
assert.equal(liveTab.textContent, 'LIVE');
|
||||
assert.equal(liveTab.getAttribute('aria-label'), 'Show Live Video');
|
||||
assert.equal(
|
||||
$('[data-cockpit-brief-page="live"]').querySelector('*'),
|
||||
null,
|
||||
'no page body without a stream',
|
||||
);
|
||||
// Next from Local wraps to Live Signals, past the page not on offer.
|
||||
showBriefPage.call(owner, 3);
|
||||
await nextTick();
|
||||
assert.deepEqual(visiblePages(), ['signals']);
|
||||
assert.equal(text('#cockpit-brief-position'), '1 / 3');
|
||||
});
|
||||
|
||||
test('with a stream the LIVE page is the fourth, reached by the arrows and its tab', async (t) => {
|
||||
const { $, text, owner, visiblePages, current, offerLive } = fixture(t);
|
||||
await offerLive({});
|
||||
assert.equal(text('#cockpit-brief-position'), '1 / 4');
|
||||
const liveTab = $('[data-cockpit-brief-index="3"]');
|
||||
assert.equal(liveTab.hidden, false);
|
||||
assert.deepEqual(current(), ['true', 'false', 'false', 'false']);
|
||||
showBriefPage.call(owner, 2);
|
||||
showBriefPage.call(owner, owner.briefPageIndex + 1);
|
||||
await nextTick();
|
||||
assert.deepEqual(visiblePages(), ['live']);
|
||||
assert.deepEqual(current(), ['false', 'false', 'false', 'true']);
|
||||
assert.equal(text('#cockpit-brief-kicker'), 'LIVE VIDEO');
|
||||
assert.equal(
|
||||
text('#cockpit-brief-subtitle'),
|
||||
'STREAM ATTACHED TO THE SUBJECT',
|
||||
);
|
||||
assert.equal(text('#cockpit-brief-position'), '4 / 4');
|
||||
assert.equal(
|
||||
text('#cockpit-brief-source'),
|
||||
'YOUTUBE EMBEDDED PLAYER · MUTED',
|
||||
);
|
||||
assert.equal($('#cockpit-signal-stream').dataset.briefPage, 'live');
|
||||
// The page shows what the LIVE section shows, with the player's own screen.
|
||||
const page = $('[data-cockpit-brief-page="live"]');
|
||||
assert.equal(
|
||||
page.querySelector('.cockpit-live-subject strong').textContent,
|
||||
'ISS (ZARYA)',
|
||||
);
|
||||
assert.equal(text('#cockpit-live-stream-title'), 'Exterior cameras · 1/2');
|
||||
assert.ok($('#cockpit-live-player-host'));
|
||||
assert.ok($('#cockpit-live-previous'));
|
||||
assert.ok($('#cockpit-live-next'));
|
||||
assert.equal(text('#cockpit-live-badge-text'), 'OFF');
|
||||
assert.equal(text('#cockpit-live-status'), 'Click to play');
|
||||
assert.ok($('#cockpit-live-play'), 'Play, under the IP notice');
|
||||
assert.match(
|
||||
page.querySelector('.cockpit-live-privacy').textContent,
|
||||
/sees your IP address/,
|
||||
);
|
||||
assert.equal(
|
||||
$('#cockpit-live-watch-link').getAttribute('href'),
|
||||
'https://www.youtube.com/watch?v=ROboUHfPUrU',
|
||||
);
|
||||
// Next from LIVE wraps to Live Signals.
|
||||
showBriefPage.call(owner, owner.briefPageIndex + 1);
|
||||
await nextTick();
|
||||
assert.deepEqual(visiblePages(), ['signals']);
|
||||
assert.equal(text('#cockpit-brief-position'), '1 / 4');
|
||||
});
|
||||
|
||||
test('the LIVE page loads the stream only on Play, stops it when left, and its controls reach LiveControls', async (t) => {
|
||||
const { $, owner, offerLive, liveActed } = fixture(t);
|
||||
await offerLive({});
|
||||
assert.deepEqual(liveActed, [], 'riding the station loads no player');
|
||||
showBriefPage.call(owner, 3);
|
||||
await nextTick();
|
||||
$('#cockpit-live-play').click();
|
||||
assert.deepEqual(liveActed, [['play']]);
|
||||
await offerLive({ state: 'playing' });
|
||||
const page = $('[data-cockpit-brief-page="live"]');
|
||||
assert.equal($('#cockpit-live-badge-text').textContent, 'ON AIR');
|
||||
assert.equal(
|
||||
page.querySelector('.live-dot').classList.contains('on-air'),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
page.querySelector('.live-screen').classList.contains('active'),
|
||||
true,
|
||||
);
|
||||
assert.equal($('#cockpit-live-status').textContent, 'Live');
|
||||
$('#cockpit-live-next').click();
|
||||
$('#cockpit-live-previous').click();
|
||||
assert.deepEqual(liveActed, [['play'], ['cycle', 1], ['cycle', -1]]);
|
||||
// Leaving the page stops what plays there.
|
||||
showBriefPage.call(owner, 0);
|
||||
await nextTick();
|
||||
assert.deepEqual(liveActed.at(-1), ['hide', 'cockpit']);
|
||||
showBriefPage.call(owner, 3);
|
||||
await nextTick();
|
||||
await offerLive({ state: 'offline', reason: 'timeout' });
|
||||
const card = page.querySelector('.live-card');
|
||||
assert.equal(card.classList.contains('offline'), true);
|
||||
assert.equal(card.querySelector('strong').textContent, 'Stream is offline');
|
||||
$('#cockpit-live-retry').click();
|
||||
assert.deepEqual(liveActed.at(-1), ['retry']);
|
||||
await offerLive({ state: 'unavailable', reason: 'error-150' });
|
||||
assert.equal($('#cockpit-live-retry'), null);
|
||||
assert.equal(
|
||||
$('#cockpit-live-status').textContent,
|
||||
'This stream cannot play here',
|
||||
);
|
||||
});
|
||||
|
||||
test('the stream going while LIVE is shown falls back to Live Signals with three pages', async (t) => {
|
||||
const { $, text, owner, visiblePages, offerLive } = fixture(t);
|
||||
await offerLive({});
|
||||
showBriefPage.call(owner, 3);
|
||||
await nextTick();
|
||||
assert.deepEqual(visiblePages(), ['live']);
|
||||
await offerLive(null);
|
||||
assert.deepEqual(visiblePages(), ['signals']);
|
||||
assert.equal(text('#cockpit-brief-position'), '1 / 3');
|
||||
assert.equal($('[data-cockpit-brief-index="3"]').hidden, true);
|
||||
// Going on another page, the page stays and only the count changes.
|
||||
showBriefPage.call(owner, 1);
|
||||
await offerLive({});
|
||||
assert.deepEqual(visiblePages(), ['news']);
|
||||
assert.equal(text('#cockpit-brief-position'), '2 / 4');
|
||||
// Offering what is already offered changes nothing.
|
||||
const views = [];
|
||||
owner.publishBrief = (view) => views.push(view);
|
||||
setBriefLiveOffered.call(owner, true);
|
||||
assert.equal(views.length, 0);
|
||||
});
|
||||
|
||||
test('the automatic cycle never turns to the LIVE page and waits while it is shown', () => {
|
||||
const three = cockpitBriefPages(false);
|
||||
assert.deepEqual(
|
||||
[0, 1, 2].map((index) => briefCycleTarget(three, index)),
|
||||
[1, 2, 0],
|
||||
);
|
||||
const four = cockpitBriefPages(true);
|
||||
assert.equal(four.length, 4);
|
||||
assert.equal(four[3].id, 'live');
|
||||
assert.deepEqual(
|
||||
[0, 1, 2].map((index) => briefCycleTarget(four, index)),
|
||||
[1, 2, 0],
|
||||
'Local goes back to Live Signals, past LIVE',
|
||||
);
|
||||
assert.equal(briefCycleTarget(four, 3), null, 'shown by hand, LIVE stays');
|
||||
});
|
||||
|
||||
test('regional news and local conditions render what the region returned', async (t) => {
|
||||
const { $, text, owner } = fixture(t);
|
||||
renderRegionalBriefStatus.call(owner, 'loading', INFO);
|
||||
|
||||
@@ -26,10 +26,12 @@ import {
|
||||
import { update } from './cockpitCamera.js';
|
||||
import {
|
||||
beginOrbital,
|
||||
orbitalViewSignal,
|
||||
endOrbital,
|
||||
resetOrbitalLook,
|
||||
jumpToSensorSwath,
|
||||
onOrbitalWheel,
|
||||
stepOrbitalMount,
|
||||
stepOrbitalZoom,
|
||||
turnOrbitalLook,
|
||||
updateOrbital,
|
||||
@@ -77,6 +79,7 @@ import {
|
||||
publishBriefView,
|
||||
showBriefPage,
|
||||
setBriefAutoRotate,
|
||||
setBriefLiveOffered,
|
||||
startBriefRotation,
|
||||
stopBriefRotation,
|
||||
updateLocalPosition,
|
||||
@@ -273,6 +276,8 @@ export class CockpitViewController {
|
||||
this.signalSignatures = new Map();
|
||||
this.briefPageIndex = 0;
|
||||
this.briefAutoRotateEnabled = false;
|
||||
/** Whether the briefing offers its LIVE page (the subject has a stream). */
|
||||
this.briefLiveOffered = false;
|
||||
// Cockpit's views render what these receive.
|
||||
this.publishPresence = publish.presence ?? (() => {});
|
||||
this.publishBrief = publish.brief ?? (() => {});
|
||||
@@ -403,6 +408,10 @@ export class CockpitViewController {
|
||||
else if (target?.closest?.('#cockpit-orbital-zoom-out'))
|
||||
this.stepOrbitalZoom(-1);
|
||||
else if (target?.closest?.('#cockpit-orbital-nadir')) this.orbitalNadir();
|
||||
else if (target?.closest?.('#cockpit-orbital-view-next'))
|
||||
this.nextOrbitalView();
|
||||
else if (target?.closest?.('#cockpit-orbital-view-previous'))
|
||||
this.previousOrbitalView();
|
||||
else if (target?.closest?.('#cockpit-orbital-sensor'))
|
||||
this.jumpToSensorSwath();
|
||||
});
|
||||
@@ -456,6 +465,26 @@ export class CockpitViewController {
|
||||
beginOrbital() {
|
||||
return beginOrbital.call(this);
|
||||
}
|
||||
|
||||
orbitalViewSignal(info) {
|
||||
return orbitalViewSignal.call(this, info);
|
||||
}
|
||||
|
||||
/**
|
||||
* The station view's right arrow: step to the station's next view.
|
||||
* @returns {boolean} True when the view changed.
|
||||
*/
|
||||
nextOrbitalView() {
|
||||
return stepOrbitalMount.call(this, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* The station view's left arrow: step back to the view before.
|
||||
* @returns {boolean} True when the view changed.
|
||||
*/
|
||||
previousOrbitalView() {
|
||||
return stepOrbitalMount.call(this, -1);
|
||||
}
|
||||
endOrbital() {
|
||||
return endOrbital.call(this);
|
||||
}
|
||||
@@ -713,6 +742,9 @@ export class CockpitViewController {
|
||||
setBriefAutoRotate(enabled) {
|
||||
return setBriefAutoRotate.call(this, enabled);
|
||||
}
|
||||
setBriefLiveOffered(offered) {
|
||||
return setBriefLiveOffered.call(this, offered);
|
||||
}
|
||||
startBriefRotation(options) {
|
||||
return startBriefRotation.call(this, options);
|
||||
}
|
||||
|
||||
@@ -116,8 +116,19 @@ function sitePosition(site) {
|
||||
: null;
|
||||
}
|
||||
|
||||
/** The mapped site a canvas position shows, through the layer's picks. */
|
||||
/**
|
||||
* The mapped site a canvas position shows: through the layer's own lookup
|
||||
* where it has one (`findAt`: the dot, the site entity or the label box the
|
||||
* overlay paints, which is what a click lands on from orbit), else through
|
||||
* its pick ids.
|
||||
*/
|
||||
function siteAt(controller, position) {
|
||||
try {
|
||||
const found = sitesLayer(controller)?.findAt?.(position) ?? null;
|
||||
if (found) return found;
|
||||
} catch {
|
||||
// Fall through to the pick ids.
|
||||
}
|
||||
let picked = null;
|
||||
try {
|
||||
picked = findQuery(controller.viewer)?.pick(position.x, position.y) ?? null;
|
||||
@@ -289,8 +300,9 @@ export function routeSceneClick() {
|
||||
}
|
||||
return input.onClick((event) => {
|
||||
// Another layer's card or label painted on top takes the click: the site
|
||||
// under it does not focus, and the click does not end a held focus.
|
||||
if (isUnderOtherCard(event)) return;
|
||||
// under it does not focus, and the click does not end a held focus. A
|
||||
// site's own label is not another layer's: it focuses that site.
|
||||
if (isUnderOtherCard(event, [SITES_LAYER_ID])) return;
|
||||
this.onOrbitalClick(event?.position);
|
||||
});
|
||||
}
|
||||
@@ -303,15 +315,26 @@ export function routeSceneClick() {
|
||||
* held from its last record). Also rebuilds
|
||||
* the orbital Live Signals rows on their own clock.
|
||||
* @param {object} state The orbital session.
|
||||
* @param {{direction: object, up: object, right: object}} nadir This
|
||||
* frame's nadir frame.
|
||||
* @param {{x: number, y: number, z: number}} position The satellite, ECEF.
|
||||
* @param {{direction: object, up: object, right: object}} nadir The frame
|
||||
* the look turns about this frame: the nadir one, or a station view's.
|
||||
* @param {{x: number, y: number, z: number}} position Where the camera is,
|
||||
* ECEF: the satellite, or the station view's point on it.
|
||||
* @param {number} nowMs
|
||||
* @param {{direction: object, up: object, right: object}|null} [trueNadir]
|
||||
* The nadir frame when `nadir` is a station view's: the rows still word
|
||||
* their angles from straight down.
|
||||
* @returns {boolean} True when it placed `state.lookView` itself.
|
||||
*/
|
||||
export function updateOrbitalFocus(state, nadir, position, nowMs) {
|
||||
export function updateOrbitalFocus(
|
||||
state,
|
||||
nadir,
|
||||
position,
|
||||
nowMs,
|
||||
trueNadir = null,
|
||||
) {
|
||||
state.focusFrame = {
|
||||
nadir,
|
||||
trueNadir,
|
||||
position: { x: position.x, y: position.y, z: position.z },
|
||||
};
|
||||
// After a satellite switch the first frame on the new satellite (the hop
|
||||
@@ -465,13 +488,21 @@ export function orbitalSitesInReach(info) {
|
||||
});
|
||||
state.listedSites = remembered;
|
||||
const focusKey = state.focus?.key ?? null;
|
||||
const positions = new Map(candidates.map((c) => [c.key, c.position]));
|
||||
// Reach is measured about the frame the look turns in; the angle shown
|
||||
// is always from straight down, also from a station view.
|
||||
const shownOffNadir = (key, offNadirDeg) => {
|
||||
if (!frame.trueNadir) return offNadirDeg;
|
||||
const look = focusLook(frame.trueNadir, frame.position, positions.get(key));
|
||||
return Number.isFinite(look?.offNadirDeg) ? look.offNadirDeg : offNadirDeg;
|
||||
};
|
||||
return {
|
||||
entries: pointsInReach(candidates, {
|
||||
nadir: frame.nadir,
|
||||
satellite: frame.position,
|
||||
}).map(({ key, offNadirDeg }) => ({
|
||||
site: byId.get(key),
|
||||
offNadirDeg,
|
||||
offNadirDeg: shownOffNadir(key, offNadirDeg),
|
||||
focused: key === focusKey,
|
||||
})),
|
||||
};
|
||||
|
||||
@@ -41,10 +41,34 @@ const FRAME_MS = 16;
|
||||
|
||||
/** Satellites the layer knows, by NORAD id: the ridden one and its neighbours. */
|
||||
const SATELLITES = Object.freeze({
|
||||
25544: { name: 'ISS (ZARYA)', lat: 30, lon: -97, alt: 420_000, cls: 'stations' },
|
||||
49260: { name: 'LANDSAT 9', lat: 31.5, lon: -95, alt: 705_000, cls: 'imaging' },
|
||||
40697: { name: 'SENTINEL-2A', lat: 26, lon: -99, alt: 786_000, cls: 'imaging' },
|
||||
99001: { name: 'DEB FRAGMENT', lat: 30.2, lon: -97.1, alt: 430_000, cls: 'debris' },
|
||||
25544: {
|
||||
name: 'ISS (ZARYA)',
|
||||
lat: 30,
|
||||
lon: -97,
|
||||
alt: 420_000,
|
||||
cls: 'stations',
|
||||
},
|
||||
49260: {
|
||||
name: 'LANDSAT 9',
|
||||
lat: 31.5,
|
||||
lon: -95,
|
||||
alt: 705_000,
|
||||
cls: 'imaging',
|
||||
},
|
||||
40697: {
|
||||
name: 'SENTINEL-2A',
|
||||
lat: 26,
|
||||
lon: -99,
|
||||
alt: 786_000,
|
||||
cls: 'imaging',
|
||||
},
|
||||
99001: {
|
||||
name: 'DEB FRAGMENT',
|
||||
lat: 30.2,
|
||||
lon: -97.1,
|
||||
alt: 430_000,
|
||||
cls: 'debris',
|
||||
},
|
||||
});
|
||||
|
||||
/** Mapped sites as the installations layer keeps them. */
|
||||
@@ -58,6 +82,8 @@ const SITES = Object.freeze({
|
||||
lon: -96.5,
|
||||
memberNames: ['North Field'],
|
||||
at: { x: 100, y: 100 },
|
||||
// Where the overlay paints its label box: nothing picks there.
|
||||
labelAt: { x: 140, y: 70 },
|
||||
},
|
||||
bravo: {
|
||||
id: 'osm:military:way/202',
|
||||
@@ -102,7 +128,11 @@ function installationsLayer() {
|
||||
withPosition(record) {
|
||||
return {
|
||||
...record,
|
||||
position: Cesium.Cartesian3.fromDegrees(record.longitude, record.latitude, 0),
|
||||
position: Cesium.Cartesian3.fromDegrees(
|
||||
record.longitude,
|
||||
record.latitude,
|
||||
0,
|
||||
),
|
||||
};
|
||||
},
|
||||
// As the layer's own: loaded installations within `rangeM` of
|
||||
@@ -119,7 +149,10 @@ function installationsLayer() {
|
||||
from,
|
||||
Cesium.Cartographic.fromDegrees(record.longitude, record.latitude),
|
||||
);
|
||||
return { ...layer.withPosition(record), distanceM: geodesic.surfaceDistance };
|
||||
return {
|
||||
...layer.withPosition(record),
|
||||
distanceM: geodesic.surfaceDistance,
|
||||
};
|
||||
})
|
||||
.filter((record) => record.distanceM <= rangeM)
|
||||
.sort((a, b) => a.distanceM - b.distanceM)
|
||||
@@ -135,6 +168,17 @@ function installationsLayer() {
|
||||
const id = hit?.meta?.installationId ?? null;
|
||||
return id ? layer.getById(id) : null;
|
||||
},
|
||||
// As the layer's: the label box the overlay paints, where no primitive
|
||||
// picks (the dot is left to the pick ids here).
|
||||
findAt(position) {
|
||||
const site = Object.values(SITES).find(
|
||||
(s) =>
|
||||
s.labelAt &&
|
||||
s.labelAt.x === position?.x &&
|
||||
s.labelAt.y === position?.y,
|
||||
);
|
||||
return site ? layer.getById(site.id) : null;
|
||||
},
|
||||
};
|
||||
return layer;
|
||||
}
|
||||
@@ -192,7 +236,11 @@ function satellitesLayer(viewer) {
|
||||
},
|
||||
// As the layer's: the nearest shown satellites, bounded, with the
|
||||
// asked-for ids and classes left out.
|
||||
getNearestPositions(center, maxCount = 8, { excludeIds = [], excludeClasses = [] } = {}) {
|
||||
getNearestPositions(
|
||||
center,
|
||||
maxCount = 8,
|
||||
{ excludeIds = [], excludeClasses = [] } = {},
|
||||
) {
|
||||
layer.calls.push(['nearest']);
|
||||
const skip = new Set(excludeIds.map(String));
|
||||
return layer
|
||||
@@ -216,7 +264,9 @@ function satellitesLayer(viewer) {
|
||||
if (!positions.has(id)) return false;
|
||||
layer.calls.push(['track', id]);
|
||||
layer.tracked = id;
|
||||
followEntity(viewer, { position: { getValue: () => layer.position(id) } });
|
||||
followEntity(viewer, {
|
||||
position: { getValue: () => layer.position(id) },
|
||||
});
|
||||
return true;
|
||||
},
|
||||
setCockpitSubject(noradId) {
|
||||
@@ -236,7 +286,11 @@ function fixture(t, { reducedMotion = false } = {}) {
|
||||
const host = document.body.appendChild(document.createElement('div'));
|
||||
const pinia = createPinia();
|
||||
const app = createApp(
|
||||
defineComponent(() => () => [h(ContextView), h(IntelHudView), h(CockpitView)]),
|
||||
defineComponent(() => () => [
|
||||
h(ContextView),
|
||||
h(IntelHudView),
|
||||
h(CockpitView),
|
||||
]),
|
||||
).use(pinia);
|
||||
app.mount(host);
|
||||
useHudStore(pinia);
|
||||
@@ -278,7 +332,10 @@ function fixture(t, { reducedMotion = false } = {}) {
|
||||
handler.stockDouble = ({ position }) => {
|
||||
handler.stockDoubleClicks += 1;
|
||||
const picked = picks.get(`${position.x},${position.y}`);
|
||||
followEntity(viewer, picked ? { position: { getValue: () => null } } : null);
|
||||
followEntity(
|
||||
viewer,
|
||||
picked ? { position: { getValue: () => null } } : null,
|
||||
);
|
||||
};
|
||||
// The viewer's stock handler holds them, so the scene's input has them to
|
||||
// hold off.
|
||||
@@ -376,7 +433,11 @@ function fixture(t, { reducedMotion = false } = {}) {
|
||||
globalThis.matchMedia = previousMatchMedia;
|
||||
performance.now = originalNow;
|
||||
Date.now = originalDateNow;
|
||||
document.body.classList.remove('cockpit-mode', 'cockpit-bridge', 'cockpit-orbit');
|
||||
document.body.classList.remove(
|
||||
'cockpit-mode',
|
||||
'cockpit-bridge',
|
||||
'cockpit-orbit',
|
||||
);
|
||||
});
|
||||
|
||||
const frame = () => {
|
||||
@@ -456,7 +517,10 @@ function missDeg(shot, key) {
|
||||
|
||||
/** The camera's angle from nadir, degrees. */
|
||||
function offNadir(shot) {
|
||||
const toCentre = Cesium.Cartesian3.negate(shot.destination, new Cesium.Cartesian3());
|
||||
const toCentre = Cesium.Cartesian3.negate(
|
||||
shot.destination,
|
||||
new Cesium.Cartesian3(),
|
||||
);
|
||||
return angleDeg(shot.direction, toCentre);
|
||||
}
|
||||
|
||||
@@ -467,7 +531,10 @@ function siteOffNadir(shot, key) {
|
||||
shot.destination,
|
||||
new Cesium.Cartesian3(),
|
||||
);
|
||||
const toCentre = Cesium.Cartesian3.negate(shot.destination, new Cesium.Cartesian3());
|
||||
const toCentre = Cesium.Cartesian3.negate(
|
||||
shot.destination,
|
||||
new Cesium.Cartesian3(),
|
||||
);
|
||||
return angleDeg(line, toCentre);
|
||||
}
|
||||
|
||||
@@ -522,7 +589,9 @@ test('in orbit Live Signals lists the sites getNearby finds and the nearest sate
|
||||
assert.ok(shown.length <= 5, 'five rows at most');
|
||||
assert.equal(shown[0].title, 'TRACK ACQUIRED', 'the track row stays first');
|
||||
// Two site rows, nearest to nadir first, then the satellites (debris out).
|
||||
const sitesShown = shown.filter((row) => row.target?.layerId === 'military-installations');
|
||||
const sitesShown = shown.filter(
|
||||
(row) => row.target?.layerId === 'military-installations',
|
||||
);
|
||||
assert.deepEqual(
|
||||
sitesShown.map((row) => row.target.id).sort(),
|
||||
[SITES.alpha.id, SITES.bravo.id].sort(),
|
||||
@@ -531,16 +600,33 @@ test('in orbit Live Signals lists the sites getNearby finds and the nearest sate
|
||||
assert.match(row.detail, /^(BASE|AIRFIELD) · OFF-NADIR \d+\.\d°$/);
|
||||
assert.match(row.className, /nearby actionable/);
|
||||
}
|
||||
const satellitesShown = shown.filter((row) => row.target?.layerId === 'satellites');
|
||||
assert.deepEqual(satellitesShown.map((row) => row.title), ['LANDSAT 9', 'SENTINEL-2A']);
|
||||
assert.match(satellitesShown[0].detail, /^SATELLITE · (AHEAD|[LR] \d{3}°) · [\d,.]+\s+KM$/);
|
||||
const satellitesShown = shown.filter(
|
||||
(row) => row.target?.layerId === 'satellites',
|
||||
);
|
||||
assert.deepEqual(
|
||||
satellitesShown.map((row) => row.title),
|
||||
['LANDSAT 9', 'SENTINEL-2A'],
|
||||
);
|
||||
assert.match(
|
||||
satellitesShown[0].detail,
|
||||
/^SATELLITE · (AHEAD|[LR] \d{3}°) · [\d,.]+\s+KM$/,
|
||||
);
|
||||
// Each row names its own action.
|
||||
assert.equal(siteRow(scene, 'alpha').getAttribute('aria-label'), 'Keep the camera on Camp Alpha');
|
||||
assert.equal(satelliteRow(scene, 49260).getAttribute('aria-label'), 'Ride LANDSAT 9');
|
||||
assert.equal(
|
||||
siteRow(scene, 'alpha').getAttribute('aria-label'),
|
||||
'Keep the camera on Camp Alpha',
|
||||
);
|
||||
assert.equal(
|
||||
satelliteRow(scene, 49260).getAttribute('aria-label'),
|
||||
'Ride LANDSAT 9',
|
||||
);
|
||||
// Rebuilt on the clock, rows keep their keys and times.
|
||||
const before = shown.map((row) => [row.key, row.time]);
|
||||
await refreshRows(scene);
|
||||
assert.deepEqual(rows(scene).map((row) => [row.key, row.time]), before);
|
||||
assert.deepEqual(
|
||||
rows(scene).map((row) => [row.key, row.time]),
|
||||
before,
|
||||
);
|
||||
});
|
||||
|
||||
test('a site row turns the camera onto it, holds it, and reads its off-nadir angle', async (t) => {
|
||||
@@ -552,11 +638,17 @@ test('a site row turns the camera onto it, holds it, and reads its off-nadir ang
|
||||
// The first frames turn part of the way: no jump onto the site.
|
||||
assert.ok(missDeg(scene.frame(), 'alpha') > 5, 'still turning');
|
||||
const largest = run(scene, LAND_FRAMES);
|
||||
assert.ok(largest > 0.1 && largest < MAX_TURN_PER_FRAME_DEG, `turned ${largest}° in a frame`);
|
||||
assert.ok(
|
||||
largest > 0.1 && largest < MAX_TURN_PER_FRAME_DEG,
|
||||
`turned ${largest}° in a frame`,
|
||||
);
|
||||
for (let i = 0; i < 20; i += 1) {
|
||||
scene.satellites.move(0.002, 0.002);
|
||||
const shot = scene.frame();
|
||||
assert.ok(missDeg(shot, 'alpha') < 1e-5, `frame ${i}: ${missDeg(shot, 'alpha')}°`);
|
||||
assert.ok(
|
||||
missDeg(shot, 'alpha') < 1e-5,
|
||||
`frame ${i}: ${missDeg(shot, 'alpha')}°`,
|
||||
);
|
||||
}
|
||||
for (let i = 0; i < 8; i += 1) scene.frame();
|
||||
await settle();
|
||||
@@ -566,14 +658,20 @@ test('a site row turns the camera onto it, holds it, and reads its off-nadir ang
|
||||
`OFF-NADIR ${siteOffNadir(shot, 'alpha').toFixed(1)}°`,
|
||||
);
|
||||
assert.equal($('#cockpit-orbital-focus').textContent, 'FOCUS · Camp Alpha');
|
||||
assert.equal($('#cockpit-orbital-look-readout').getAttribute('aria-live'), 'off');
|
||||
assert.equal(
|
||||
$('#cockpit-orbital-look-readout').getAttribute('aria-live'),
|
||||
'off',
|
||||
);
|
||||
assert.equal(store.orbital.footprintKm, null);
|
||||
assert.match($('.cockpit-orbital-swath').textContent, /^SWATH ≈ [\d.]+ KM$/);
|
||||
// The held site's row reads as the subject does, first among the sites.
|
||||
const held = rows(scene).find((row) => row.target?.id === SITES.alpha.id);
|
||||
assert.match(held.className, /^track actionable$/);
|
||||
assert.match(held.detail, /^FOCUS · BASE · OFF-NADIR/);
|
||||
assert.equal(siteRow(scene, 'alpha').getAttribute('aria-label'), 'Release the camera from Camp Alpha');
|
||||
assert.equal(
|
||||
siteRow(scene, 'alpha').getAttribute('aria-label'),
|
||||
'Release the camera from Camp Alpha',
|
||||
);
|
||||
// The held site's FOCUS is a status, worded apart from the FOCUS command.
|
||||
t.after(() => setLocale('en'));
|
||||
setLocale('es');
|
||||
@@ -600,7 +698,10 @@ test('another site row switches the focus; the held site row ends it', async (t)
|
||||
assert.ok(largest < MAX_TURN_PER_FRAME_DEG, `turned ${largest}° in a frame`);
|
||||
assert.ok(missDeg(scene.shots.at(-1), 'bravo') < 1e-5);
|
||||
await settle();
|
||||
assert.match(rows(scene).find((row) => row.target?.id === SITES.alpha.id).className, /^nearby/);
|
||||
assert.match(
|
||||
rows(scene).find((row) => row.target?.id === SITES.alpha.id).className,
|
||||
/^nearby/,
|
||||
);
|
||||
siteRow(scene, 'bravo').click();
|
||||
assert.equal(cockpit.orbital.focus, null);
|
||||
const back = run(scene, LAND_FRAMES, { drift: 0 });
|
||||
@@ -617,7 +718,11 @@ test('a click on a site marker focuses it through the layer; a click elsewhere e
|
||||
run(scene, LAND_FRAMES);
|
||||
assert.ok(missDeg(scene.shots.at(-1), 'alpha') < 1e-5);
|
||||
scene.click(SITES.alpha.at);
|
||||
assert.equal(cockpit.orbital.focus.key, SITES.alpha.id, 'kept on a second click');
|
||||
assert.equal(
|
||||
cockpit.orbital.focus.key,
|
||||
SITES.alpha.id,
|
||||
'kept on a second click',
|
||||
);
|
||||
const focused = offNadir(scene.shots.at(-1));
|
||||
scene.click(EMPTY_GROUND);
|
||||
assert.equal(cockpit.orbital.focus, null);
|
||||
@@ -640,18 +745,26 @@ test('a click a tool owns is left alone', async (t) => {
|
||||
const lease = claimPointer('draw');
|
||||
t.after(() => releasePointer(lease));
|
||||
scene.click(SITES.alpha.at);
|
||||
assert.equal(scene.cockpit.orbital.focus ?? null, null, 'no focus while drawing');
|
||||
assert.equal(
|
||||
scene.cockpit.orbital.focus ?? null,
|
||||
null,
|
||||
'no focus while drawing',
|
||||
);
|
||||
releasePointer(lease);
|
||||
scene.click(SITES.alpha.at);
|
||||
const again = claimPointer('draw');
|
||||
t.after(() => releasePointer(again));
|
||||
scene.click(EMPTY_GROUND);
|
||||
assert.equal(scene.cockpit.orbital.focus.key, SITES.alpha.id, 'kept while drawing');
|
||||
assert.equal(
|
||||
scene.cockpit.orbital.focus.key,
|
||||
SITES.alpha.id,
|
||||
'kept while drawing',
|
||||
);
|
||||
});
|
||||
|
||||
// The card or label painted on top takes the click: a site under another
|
||||
// layer's card does not focus, and a click there does not end a held focus.
|
||||
test('another layer\'s card over the orbital view keeps the click', async (t) => {
|
||||
test("another layer's card over the orbital view keeps the click", async (t) => {
|
||||
const scene = await inOrbit(t);
|
||||
let top = { sourceId: 'earthquake-card', entryId: 'earthquake-card:ak1' };
|
||||
setClickCardHitTest(() => top);
|
||||
@@ -663,7 +776,11 @@ test('another layer\'s card over the orbital view keeps the click', async (t) =>
|
||||
assert.equal(scene.cockpit.orbital.focus.key, SITES.alpha.id);
|
||||
top = { sourceId: 'earthquake-card', entryId: 'earthquake-card:ak1' };
|
||||
scene.click(EMPTY_GROUND);
|
||||
assert.equal(scene.cockpit.orbital.focus.key, SITES.alpha.id, 'covered: kept');
|
||||
assert.equal(
|
||||
scene.cockpit.orbital.focus.key,
|
||||
SITES.alpha.id,
|
||||
'covered: kept',
|
||||
);
|
||||
});
|
||||
|
||||
test('a double-click on a site focuses it and keeps the orbital view', async (t) => {
|
||||
@@ -678,7 +795,11 @@ test('a double-click on a site focuses it and keeps the orbital view', async (t)
|
||||
scene.doubleClick(SITES.bravo.at);
|
||||
assert.equal(cockpit.orbital.focus.key, SITES.bravo.id);
|
||||
scene.doubleClick(SITES.far.at);
|
||||
assert.equal(handler.stockDoubleClicks, 0, 'beyond reach: not focused, not tracked');
|
||||
assert.equal(
|
||||
handler.stockDoubleClicks,
|
||||
0,
|
||||
'beyond reach: not focused, not tracked',
|
||||
);
|
||||
scene.frame();
|
||||
assert.equal(cockpit.active, true);
|
||||
scene.doubleClick(EMPTY_GROUND);
|
||||
@@ -720,8 +841,15 @@ test('turning the layer off ends the focus and says why; a reload around the sit
|
||||
assert.ok(status, 'a status row says why no site is listed');
|
||||
assert.equal(status.detail, 'ENABLE MAPPED INSTALLATIONS FOR SITE PINGS');
|
||||
assert.equal(status.className, 'warning');
|
||||
assert.ok(!rows(scene).some((row) => row.target?.layerId === 'military-installations'));
|
||||
assert.equal(rows(scene).filter((row) => row.target?.layerId === 'satellites').length, 2);
|
||||
assert.ok(
|
||||
!rows(scene).some(
|
||||
(row) => row.target?.layerId === 'military-installations',
|
||||
),
|
||||
);
|
||||
assert.equal(
|
||||
rows(scene).filter((row) => row.target?.layerId === 'satellites').length,
|
||||
2,
|
||||
);
|
||||
scene.sites.enabled = true;
|
||||
await refreshRows(scene);
|
||||
assert.ok(!rows(scene).some((row) => row.title === 'SITES STANDBY'));
|
||||
@@ -732,7 +860,11 @@ test('turning the layer off ends the focus and says why; a reload around the sit
|
||||
const loaded = scene.sites.records;
|
||||
scene.sites.records = loaded.filter((r) => r.id !== SITES.bravo.id);
|
||||
run(scene, 10);
|
||||
assert.equal(scene.cockpit.orbital.focus.key, SITES.bravo.id, 'kept through a reload');
|
||||
assert.equal(
|
||||
scene.cockpit.orbital.focus.key,
|
||||
SITES.bravo.id,
|
||||
'kept through a reload',
|
||||
);
|
||||
assert.ok(missDeg(scene.shots.at(-1), 'bravo') < 1e-5, 'still centred');
|
||||
scene.sites.records = loaded;
|
||||
// A row the list shows works even if the layer just dropped its site.
|
||||
@@ -745,7 +877,10 @@ test('turning the layer off ends the focus and says why; a reload around the sit
|
||||
test('a satellite row rides it, staying in orbit; RETURN goes back', async (t) => {
|
||||
const scene = await inOrbit(t);
|
||||
const { cockpit, satellites, viewer, modeEvents } = scene;
|
||||
assert.ok(!rows(scene).some((row) => row.title.startsWith('RETURN')), 'no history yet');
|
||||
assert.ok(
|
||||
!rows(scene).some((row) => row.title.startsWith('RETURN')),
|
||||
'no history yet',
|
||||
);
|
||||
siteRow(scene, 'alpha').click();
|
||||
run(scene, 5);
|
||||
const before = Cesium.Cartesian3.clone(scene.shots.at(-1).destination);
|
||||
@@ -755,21 +890,36 @@ test('a satellite row rides it, staying in orbit; RETURN goes back', async (t) =
|
||||
satelliteRow(scene, 49260).click();
|
||||
const newTrack = cockpit.signalItems.filter((item) => item.key === 'track');
|
||||
assert.equal(newTrack.length, 1);
|
||||
assert.ok(newTrack[0].timestamp > firstTrack.timestamp, 'the new ride’s own time');
|
||||
assert.deepEqual(satellites.calls.slice(-2), [['track', 49260], ['subject', 49260]]);
|
||||
assert.ok(
|
||||
newTrack[0].timestamp > firstTrack.timestamp,
|
||||
'the new ride’s own time',
|
||||
);
|
||||
assert.deepEqual(satellites.calls.slice(-2), [
|
||||
['track', 49260],
|
||||
['subject', 49260],
|
||||
]);
|
||||
assert.equal(followedOf(viewer), null, 'the Cockpit keeps the camera');
|
||||
assert.equal(cockpit.subjectId, 49260);
|
||||
assert.equal(cockpit.orbital.focus, null, 'the focus is reset');
|
||||
assert.equal(modeEvents.at(-1)?.active, true);
|
||||
await settle();
|
||||
const shown = rows(scene);
|
||||
assert.deepEqual([shown[0].title, shown[0].detail], ['TRACK ACQUIRED', 'LANDSAT 9 · NADIR VIEW']);
|
||||
assert.deepEqual(
|
||||
[shown[0].title, shown[0].detail],
|
||||
['TRACK ACQUIRED', 'LANDSAT 9 · NADIR VIEW'],
|
||||
);
|
||||
assert.equal(shown.filter((row) => row.title === 'TRACK ACQUIRED').length, 1);
|
||||
const back = shown.find((row) => row.title === 'RETURN · ISS (ZARYA)');
|
||||
assert.ok(back, 'a RETURN row while there is history');
|
||||
assert.equal(back.detail, 'PREVIOUS SATELLITE');
|
||||
assert.equal(satelliteRow(scene, 25544).getAttribute('aria-label'), 'Return to ISS (ZARYA)');
|
||||
assert.ok(!shown.some((row) => row.title === 'ISS (ZARYA)'), 'listed once, as RETURN');
|
||||
assert.equal(
|
||||
satelliteRow(scene, 25544).getAttribute('aria-label'),
|
||||
'Return to ISS (ZARYA)',
|
||||
);
|
||||
assert.ok(
|
||||
!shown.some((row) => row.title === 'ISS (ZARYA)'),
|
||||
'listed once, as RETURN',
|
||||
);
|
||||
|
||||
// The camera hops along the way, never in one jump.
|
||||
const target = satellites.position(49260);
|
||||
@@ -779,11 +929,20 @@ test('a satellite row rides it, staying in orbit; RETURN goes back', async (t) =
|
||||
for (let i = 0; i < Math.ceil(ORBITAL_HOP_MS / FRAME_MS) + 2; i += 1) {
|
||||
const shot = scene.frame();
|
||||
assert.equal(cockpit.active, true, `still in orbit at frame ${i}`);
|
||||
largestStep = Math.max(largestStep, Cesium.Cartesian3.distance(previous, shot.destination));
|
||||
largestStep = Math.max(
|
||||
largestStep,
|
||||
Cesium.Cartesian3.distance(previous, shot.destination),
|
||||
);
|
||||
previous = shot.destination;
|
||||
}
|
||||
assert.ok(largestStep < hopM * 0.1, `largest step ${largestStep} m of ${hopM} m`);
|
||||
assert.ok(Cesium.Cartesian3.distance(previous, target) < 1, 'landed on the satellite');
|
||||
assert.ok(
|
||||
largestStep < hopM * 0.1,
|
||||
`largest step ${largestStep} m of ${hopM} m`,
|
||||
);
|
||||
assert.ok(
|
||||
Cesium.Cartesian3.distance(previous, target) < 1,
|
||||
'landed on the satellite',
|
||||
);
|
||||
run(scene, LAND_FRAMES, { drift: 0 });
|
||||
assert.ok(offNadir(scene.shots.at(-1)) < 1e-6, 'looking at nadir');
|
||||
|
||||
@@ -799,10 +958,16 @@ test('a satellite row rides it, staying in orbit; RETURN goes back', async (t) =
|
||||
satelliteRow(scene, 25544).click();
|
||||
assert.equal(cockpit.subjectId, 25544);
|
||||
await settle();
|
||||
assert.ok(!rows(scene).some((row) => row.title.startsWith('RETURN')), 'back at the start');
|
||||
assert.ok(
|
||||
!rows(scene).some((row) => row.title.startsWith('RETURN')),
|
||||
'back at the start',
|
||||
);
|
||||
scene.frame();
|
||||
assert.equal(cockpit.active, true);
|
||||
assert.ok(!satellites.calls.some(([, id]) => id === 99001), 'debris never offered');
|
||||
assert.ok(
|
||||
!satellites.calls.some(([, id]) => id === 99001),
|
||||
'debris never offered',
|
||||
);
|
||||
});
|
||||
|
||||
test('while the camera hops, no stale rows; on landing, rows measured from the new satellite', async (t) => {
|
||||
@@ -821,15 +986,32 @@ test('while the camera hops, no stale rows; on landing, rows measured from the n
|
||||
scene.refreshCard();
|
||||
await settle();
|
||||
assert.ok(cockpit.orbital.hop, 'still hopping');
|
||||
assert.deepEqual(rows(scene).map((row) => row.title), ['TRACK ACQUIRED', 'RETURN · ISS (ZARYA)']);
|
||||
assert.deepEqual(
|
||||
rows(scene).map((row) => row.title),
|
||||
['TRACK ACQUIRED', 'RETURN · ISS (ZARYA)'],
|
||||
);
|
||||
// Landed: the first frame on the satellite rebuilds them at once.
|
||||
for (let i = 0; i < Math.ceil(ORBITAL_HOP_MS / FRAME_MS) + 2; i += 1) scene.frame();
|
||||
for (let i = 0; i < Math.ceil(ORBITAL_HOP_MS / FRAME_MS) + 2; i += 1)
|
||||
scene.frame();
|
||||
await settle();
|
||||
shown = rows(scene);
|
||||
assert.ok(shown.some((row) => row.target?.layerId === 'military-installations'), 'sites back');
|
||||
const satellitesShown = shown.filter((row) => row.title !== 'TRACK ACQUIRED' && row.target?.layerId === 'satellites');
|
||||
assert.ok(!satellitesShown.some((row) => row.title === 'LANDSAT 9'), 'never the ridden one');
|
||||
assert.equal(satellitesShown.filter((row) => row.target.id === '25544').length, 1, 'ISS only as RETURN');
|
||||
assert.ok(
|
||||
shown.some((row) => row.target?.layerId === 'military-installations'),
|
||||
'sites back',
|
||||
);
|
||||
const satellitesShown = shown.filter(
|
||||
(row) =>
|
||||
row.title !== 'TRACK ACQUIRED' && row.target?.layerId === 'satellites',
|
||||
);
|
||||
assert.ok(
|
||||
!satellitesShown.some((row) => row.title === 'LANDSAT 9'),
|
||||
'never the ridden one',
|
||||
);
|
||||
assert.equal(
|
||||
satellitesShown.filter((row) => row.target.id === '25544').length,
|
||||
1,
|
||||
'ISS only as RETURN',
|
||||
);
|
||||
});
|
||||
|
||||
test('RETURN to a satellite that left the catalogue offers the one before it', async (t) => {
|
||||
@@ -846,7 +1028,10 @@ test('RETURN to a satellite that left the catalogue offers the one before it', a
|
||||
satelliteRow(scene, 49260).click();
|
||||
assert.equal(cockpit.subjectId, 40697, 'still on the same satellite');
|
||||
await settle();
|
||||
assert.ok(rows(scene).some((row) => row.title === 'RETURN · ISS (ZARYA)'), 'the one before');
|
||||
assert.ok(
|
||||
rows(scene).some((row) => row.title === 'RETURN · ISS (ZARYA)'),
|
||||
'the one before',
|
||||
);
|
||||
satelliteRow(scene, 25544).click();
|
||||
assert.equal(cockpit.subjectId, 25544);
|
||||
});
|
||||
@@ -858,7 +1043,11 @@ test('with Installations off no site is offered, by row, list or click', async (
|
||||
sites.enabled = false;
|
||||
await refreshRows(scene);
|
||||
assert.ok(rows(scene).some((row) => row.title === 'SITES STANDBY'));
|
||||
assert.equal(cockpit.orbital.listedSites.size, 0, 'nothing kept to focus from');
|
||||
assert.equal(
|
||||
cockpit.orbital.listedSites.size,
|
||||
0,
|
||||
'nothing kept to focus from',
|
||||
);
|
||||
assert.equal(cockpit.toggleOrbitalFocus(SITES.alpha.id), false);
|
||||
scene.click(SITES.alpha.at);
|
||||
assert.equal(cockpit.orbital.focus ?? null, null);
|
||||
@@ -873,7 +1062,10 @@ test('an arrow during the ease back from a focus turns on the arrows’ clock',
|
||||
scene.frame();
|
||||
assert.equal(cockpit.orbital.focusReleasing, true);
|
||||
const view = { ...cockpit.orbital.lookView };
|
||||
assert.ok(Math.abs(view.pitchDeg) > 1 || Math.abs(view.yawDeg) > 1, 'still turned');
|
||||
assert.ok(
|
||||
Math.abs(view.pitchDeg) > 1 || Math.abs(view.yawDeg) > 1,
|
||||
'still turned',
|
||||
);
|
||||
cockpit.onKeyDown({
|
||||
key: 'ArrowUp',
|
||||
target: document.body,
|
||||
@@ -886,7 +1078,10 @@ test('an arrow during the ease back from a focus turns on the arrows’ clock',
|
||||
Math.abs(cockpit.orbital.lookTarget.yawDeg - view.yawDeg) < 1e-6,
|
||||
'across kept',
|
||||
);
|
||||
assert.ok(cockpit.orbital.lookTarget.pitchDeg > view.pitchDeg, 'tilted on up');
|
||||
assert.ok(
|
||||
cockpit.orbital.lookTarget.pitchDeg > view.pitchDeg,
|
||||
'tilted on up',
|
||||
);
|
||||
});
|
||||
|
||||
test('leaving orbit leaves no orbital rows to act on', async (t) => {
|
||||
@@ -901,7 +1096,10 @@ test('leaving orbit leaves no orbital rows to act on', async (t) => {
|
||||
assert.equal(scene.cockpit.toggleOrbitalFocus(SITES.bravo.id), false);
|
||||
assert.equal(scene.cockpit.onOrbitalClick(SITES.bravo.at), false);
|
||||
assert.equal(scene.cockpit.rideOrbitalSatellite(49260), false);
|
||||
assert.equal(scene.cockpit.handleOrbitalSignalClick('satellites', '49260'), false);
|
||||
assert.equal(
|
||||
scene.cockpit.handleOrbitalSignalClick('satellites', '49260'),
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
test('NADIR and Home end a focus; an arrow takes the view over where it is', async (t) => {
|
||||
@@ -944,7 +1142,12 @@ test('reduced motion cuts onto the site, back, and between satellites', async (t
|
||||
assert.ok(offNadir(scene.frame()) < 1e-6, 'back at once');
|
||||
satelliteRow(scene, 49260).click();
|
||||
const shot = scene.frame();
|
||||
assert.ok(Cesium.Cartesian3.distance(shot.destination, scene.satellites.position(49260)) < 1);
|
||||
assert.ok(
|
||||
Cesium.Cartesian3.distance(
|
||||
shot.destination,
|
||||
scene.satellites.position(49260),
|
||||
) < 1,
|
||||
);
|
||||
});
|
||||
|
||||
test('stopping the Cockpit leaves both clicks to the renderer', async (t) => {
|
||||
@@ -975,11 +1178,21 @@ test('the focused site keeps its row after nearer sites push it down', async (t)
|
||||
sources: [],
|
||||
});
|
||||
await refreshRows(scene);
|
||||
const sitesShown = rows(scene).filter((row) => row.target?.layerId === 'military-installations');
|
||||
const sitesShown = rows(scene).filter(
|
||||
(row) => row.target?.layerId === 'military-installations',
|
||||
);
|
||||
assert.equal(sitesShown.length, 2);
|
||||
assert.equal(sitesShown[0].target.id, SITES.alpha.id, 'the focused site is kept, first');
|
||||
assert.equal(
|
||||
sitesShown[0].target.id,
|
||||
SITES.alpha.id,
|
||||
'the focused site is kept, first',
|
||||
);
|
||||
siteRow(scene, 'alpha').click();
|
||||
assert.equal(scene.cockpit.orbital.focus, null, 'its row still ends the focus');
|
||||
assert.equal(
|
||||
scene.cockpit.orbital.focus,
|
||||
null,
|
||||
'its row still ends the focus',
|
||||
);
|
||||
});
|
||||
|
||||
test('a site the layer drops in a reload keeps its row, and its row still focuses it', async (t) => {
|
||||
@@ -990,13 +1203,24 @@ test('a site the layer drops in a reload keeps its row, and its row still focuse
|
||||
// The thinned view reloads without Camp Alpha for a moment.
|
||||
scene.sites.records = loaded.filter((r) => r.id !== SITES.alpha.id);
|
||||
await refreshRows(scene);
|
||||
assert.deepEqual(rows(scene).map((row) => row.key), before, 'the rows hold still');
|
||||
assert.deepEqual(
|
||||
rows(scene).map((row) => row.key),
|
||||
before,
|
||||
'the rows hold still',
|
||||
);
|
||||
siteRow(scene, 'alpha').click();
|
||||
assert.equal(scene.cockpit.orbital.focus?.key, SITES.alpha.id, 'focused from its row');
|
||||
assert.equal(
|
||||
scene.cockpit.orbital.focus?.key,
|
||||
SITES.alpha.id,
|
||||
'focused from its row',
|
||||
);
|
||||
siteRow(scene, 'alpha').click();
|
||||
// Gone for good: after a while it leaves the rows.
|
||||
for (let i = 0; i < 12; i += 1) await refreshRows(scene);
|
||||
assert.ok(!rows(scene).some((row) => row.target?.id === SITES.alpha.id), 'forgotten later');
|
||||
assert.ok(
|
||||
!rows(scene).some((row) => row.target?.id === SITES.alpha.id),
|
||||
'forgotten later',
|
||||
);
|
||||
});
|
||||
|
||||
test('shown rows keep their places while they still qualify', async (t) => {
|
||||
@@ -1021,12 +1245,174 @@ test('shown rows keep their places while they still qualify', async (t) => {
|
||||
const sitesAfter = rows(scene)
|
||||
.filter((row) => row.target?.layerId === 'military-installations')
|
||||
.map((row) => row.target.id);
|
||||
assert.deepEqual(sitesAfter, sitesBefore, 'no row moves while its site is in reach');
|
||||
assert.deepEqual(
|
||||
sitesAfter,
|
||||
sitesBefore,
|
||||
'no row moves while its site is in reach',
|
||||
);
|
||||
// Once a shown site leaves the list, the nearer one takes its slot.
|
||||
scene.sites.records = scene.sites.records.filter((r) => r.id !== SITES.bravo.id);
|
||||
scene.sites.records = scene.sites.records.filter(
|
||||
(r) => r.id !== SITES.bravo.id,
|
||||
);
|
||||
for (let i = 0; i < 12; i += 1) await refreshRows(scene);
|
||||
assert.ok(
|
||||
rows(scene).some((row) => row.target?.id === 'osm:military:way/999'),
|
||||
'the nearer site fills the freed slot',
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* A view from the station: its camera 20 m above the satellite, looking 65°
|
||||
* below level toward the north, as the satellites layer gives it. Camp Alpha,
|
||||
* about 120 km to the north-east of a satellite 420 km up, is some 74°
|
||||
* below level from it: within the view's reach.
|
||||
*/
|
||||
function stationMount(scene) {
|
||||
const position = scene.satellites.position(25544);
|
||||
const enu = Cesium.Transforms.eastNorthUpToFixedFrame(position);
|
||||
const axis = (x, y, z) =>
|
||||
Cesium.Cartesian3.normalize(
|
||||
Cesium.Matrix4.multiplyByPointAsVector(
|
||||
enu,
|
||||
new Cesium.Cartesian3(x, y, z),
|
||||
new Cesium.Cartesian3(),
|
||||
),
|
||||
new Cesium.Cartesian3(),
|
||||
);
|
||||
const down = (65 * Math.PI) / 180;
|
||||
const direction = axis(0, Math.cos(down), -Math.sin(down));
|
||||
const up = axis(0, Math.sin(down), Math.cos(down));
|
||||
return {
|
||||
position: Cesium.Cartesian3.add(
|
||||
position,
|
||||
Cesium.Cartesian3.multiplyByScalar(
|
||||
axis(0, 0, 1),
|
||||
20,
|
||||
new Cesium.Cartesian3(),
|
||||
),
|
||||
new Cesium.Cartesian3(),
|
||||
),
|
||||
direction,
|
||||
up,
|
||||
right: Cesium.Cartesian3.cross(direction, up, new Cesium.Cartesian3()),
|
||||
key: 'zarya',
|
||||
label: 'ZARYA',
|
||||
noradId: 25544,
|
||||
card: null,
|
||||
views: [
|
||||
{ key: 'zarya', label: 'ZARYA', noradId: 25544, card: null },
|
||||
{ key: 'cupola', label: 'CUPOLA', noradId: 25544, card: null },
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
test('from a station view, a site row turns the camera onto it from the view’s own point and holds it', async (t) => {
|
||||
const scene = await inOrbit(t);
|
||||
const { cockpit, satellites } = scene;
|
||||
satellites.getCockpitMount = () => stationMount(scene);
|
||||
scene.frame();
|
||||
await refreshRows(scene);
|
||||
const mount = stationMount(scene);
|
||||
// Camp Alpha lies below and to the north-east, within 45° of the view.
|
||||
assert.ok(missDeg(scene.shots.at(-1), 'alpha') > 5, 'not centred yet');
|
||||
siteRow(scene, 'alpha').click();
|
||||
assert.equal(cockpit.orbital.focus.key, SITES.alpha.id);
|
||||
run(scene, LAND_FRAMES, { drift: 0 });
|
||||
for (let i = 0; i < 10; i += 1) {
|
||||
const shot = scene.frame();
|
||||
// From the view's camera point on the station, not the satellite's.
|
||||
assert.ok(
|
||||
Cesium.Cartesian3.distance(
|
||||
shot.destination,
|
||||
stationMount(scene).position,
|
||||
) < 1e-6,
|
||||
);
|
||||
assert.ok(
|
||||
missDeg(shot, 'alpha') < 1e-4,
|
||||
`frame ${i}: ${missDeg(shot, 'alpha')}°`,
|
||||
);
|
||||
}
|
||||
// The same site from straight down would be off the view's direction.
|
||||
assert.ok(angleDeg(mount.direction, scene.shots.at(-1).direction) > 1);
|
||||
// Its row still words the angle from straight down, not from the view.
|
||||
await refreshRows(scene);
|
||||
const held = rows(scene).find((row) => row.target?.id === SITES.alpha.id);
|
||||
const fromNadir = siteOffNadir(scene.shots.at(-1), 'alpha');
|
||||
const shown = Number(/OFF-NADIR ([\d.]+)°/.exec(held.detail)[1]);
|
||||
assert.ok(Math.abs(shown - fromNadir) < 0.2, `${shown}° vs ${fromNadir}°`);
|
||||
|
||||
// Switching views ends the focus: the new view looks its own way.
|
||||
cockpit.nextOrbitalView();
|
||||
assert.ok(!cockpit.orbital.focus);
|
||||
});
|
||||
|
||||
test('from a station view, a site beyond 45° of where the view looks is not focused', async (t) => {
|
||||
const scene = await inOrbit(t);
|
||||
const { cockpit, satellites } = scene;
|
||||
// The view looks south; Camp Alpha is to the north-east, behind it.
|
||||
satellites.getCockpitMount = () => {
|
||||
const mount = stationMount(scene);
|
||||
const flip = (v) => Cesium.Cartesian3.negate(v, new Cesium.Cartesian3());
|
||||
const enu = Cesium.Transforms.eastNorthUpToFixedFrame(
|
||||
scene.satellites.position(25544),
|
||||
);
|
||||
const south = Cesium.Cartesian3.normalize(
|
||||
Cesium.Matrix4.multiplyByPointAsVector(
|
||||
enu,
|
||||
new Cesium.Cartesian3(0, -0.87, -0.5),
|
||||
new Cesium.Cartesian3(),
|
||||
),
|
||||
new Cesium.Cartesian3(),
|
||||
);
|
||||
const up = Cesium.Cartesian3.normalize(
|
||||
Cesium.Matrix4.multiplyByPointAsVector(
|
||||
enu,
|
||||
new Cesium.Cartesian3(0, -0.5, 0.87),
|
||||
new Cesium.Cartesian3(),
|
||||
),
|
||||
new Cesium.Cartesian3(),
|
||||
);
|
||||
return {
|
||||
...mount,
|
||||
direction: south,
|
||||
up,
|
||||
right: Cesium.Cartesian3.cross(south, up, new Cesium.Cartesian3()),
|
||||
unused: flip,
|
||||
};
|
||||
};
|
||||
scene.frame();
|
||||
await refreshRows(scene);
|
||||
const row = siteRow(scene, 'alpha');
|
||||
if (row) row.click();
|
||||
else cockpit.toggleOrbitalFocus?.(SITES.alpha.id);
|
||||
assert.ok(!cockpit.orbital.focus);
|
||||
});
|
||||
|
||||
test("a click on a site's label box focuses it, as one on its dot does", async (t) => {
|
||||
const scene = await inOrbit(t);
|
||||
const { cockpit, handler, sites } = scene;
|
||||
// No dot is drawn at the label's place: the layer's own lookup is what
|
||||
// finds the site there, through the label box the overlay paints.
|
||||
assert.equal(sites.findByPick(null), null, 'no draw item at the label');
|
||||
assert.equal(sites.findAt(SITES.alpha.labelAt)?.id, SITES.alpha.id);
|
||||
// The overlay reports the label box as the card on top there, as it does
|
||||
// for an interactive entry: the site's own label is not another layer's.
|
||||
const labels = [SITES.alpha.labelAt];
|
||||
setClickCardHitTest((x, y) =>
|
||||
labels.some((at) => at.x === x && at.y === y)
|
||||
? { sourceId: 'military-installations', entryId: SITES.alpha.id }
|
||||
: null,
|
||||
);
|
||||
t.after(() => setClickCardHitTest(null));
|
||||
scene.click(SITES.alpha.labelAt);
|
||||
assert.equal(cockpit.orbital.focus.key, SITES.alpha.id);
|
||||
assert.equal(handler.stockClicks, 1, 'Cesium still gets the click');
|
||||
run(scene, LAND_FRAMES);
|
||||
assert.ok(missDeg(scene.shots.at(-1), 'alpha') < 1e-5);
|
||||
// The label of the focused site again keeps it; another site's dot
|
||||
// switches.
|
||||
scene.click(SITES.alpha.labelAt);
|
||||
assert.equal(cockpit.orbital.focus.key, SITES.alpha.id);
|
||||
scene.click(SITES.bravo.at);
|
||||
assert.equal(cockpit.orbital.focus.key, SITES.bravo.id);
|
||||
});
|
||||
@@ -159,7 +159,7 @@ export function switchOrbitalSatellite(noradId) {
|
||||
'track',
|
||||
'track',
|
||||
t('TRACK ACQUIRED'),
|
||||
t('{label} · NADIR VIEW', { label: info.name }),
|
||||
this.orbitalViewSignal(info),
|
||||
);
|
||||
this.updateOrbitalHud(info);
|
||||
this.refreshOrbitalSignals?.();
|
||||
|
||||
+165
-26
@@ -1,5 +1,6 @@
|
||||
/** The orbital (satellite) view of the Cockpit controller: camera, zoom, look and HUD. */
|
||||
import { isFollowing } from '../data/followed.js';
|
||||
import { clone } from '../geo/vector.js';
|
||||
import { cameraOf, canvasOf, findGlobe } from '../render/rendererOf.js';
|
||||
import { formatNumber, msg, t } from '../i18n/index.js';
|
||||
import {
|
||||
@@ -34,6 +35,10 @@ import {
|
||||
import { cockpitUiUpdateDue } from '../cockpitMath.js';
|
||||
import { createPlaceTracker, nearPlaceRadiusKm } from '../data/placeBelow.js';
|
||||
import { isPointerFree } from '../data/inputOwnership.js';
|
||||
import {
|
||||
issNextMountView,
|
||||
issPreviousMountView,
|
||||
} from '../layers/satellites/issMounts.js';
|
||||
import { zoomableSwathKm } from '../layers/satellites/sensors.js';
|
||||
import {
|
||||
easeOrbitalLook,
|
||||
@@ -41,7 +46,10 @@ import {
|
||||
releaseOrbitalFocus,
|
||||
updateOrbitalFocus,
|
||||
} from './cockpitOrbitalFocus.js';
|
||||
import { orbitalEyePosition } from './cockpitOrbitalSatellites.js';
|
||||
import {
|
||||
orbitalEyePosition,
|
||||
switchOrbitalSatellite,
|
||||
} from './cockpitOrbitalSatellites.js';
|
||||
import {
|
||||
COCKPIT_CONTEXT_UPDATE_MS,
|
||||
COCKPIT_HUD_UPDATE_MS,
|
||||
@@ -84,6 +92,15 @@ export function beginOrbital() {
|
||||
// A zoom step in flight: the magnification it started from and when.
|
||||
transition: null,
|
||||
previousUp: null,
|
||||
// The station's view shown (its key and name) and the views on offer;
|
||||
// null and none for any other satellite. The key is kept while the
|
||||
// model is away, so the same view comes back with it.
|
||||
mountKey: null,
|
||||
mount: null,
|
||||
mountViews: [],
|
||||
// A view of a module with no catalog entry (the Cupola) carries the
|
||||
// card shown in place of the entry it rides; null otherwise.
|
||||
mountCard: null,
|
||||
altitudeM: null,
|
||||
verticalFov: null,
|
||||
lastBriefMs: 0,
|
||||
@@ -270,8 +287,49 @@ export function updateOrbital(nowMs) {
|
||||
);
|
||||
if (!position) return;
|
||||
const state = this.orbital;
|
||||
// The station is ridden from a point on its 3D model, looking along it,
|
||||
// in place of the straight-down picture (the satellites layer says where).
|
||||
const mount =
|
||||
this.services.satellitesLayer?.getCockpitMount?.(state.mountKey) ?? null;
|
||||
if (mount?.key) state.mountKey = mount.key;
|
||||
state.mountViews = mount?.views ?? [];
|
||||
state.mountCard = mount?.card ?? null;
|
||||
// Each view belongs to an entry of its own (Nauka, the ISS, Poisk, the
|
||||
// docked vehicle). The Cockpit rides that entry, so the readout, the TLE
|
||||
// and the signals describe the module the view is from, not the one first
|
||||
// selected. The switch lands on the next frame; one that fails is not
|
||||
// retried until the view changes.
|
||||
if (
|
||||
mount?.noradId !== null &&
|
||||
mount?.noradId !== undefined &&
|
||||
String(mount.noradId) !== String(this.subjectId) &&
|
||||
state.mountSwitchFailed !== mount.key
|
||||
) {
|
||||
if (switchOrbitalSatellite.call(this, mount.noradId)) return;
|
||||
state.mountSwitchFailed = mount.key;
|
||||
}
|
||||
// The model can load after entry, and the picture then changes under the
|
||||
// TRACK ACQUIRED line that named it: say which it is now.
|
||||
const riding = mount !== null;
|
||||
const changed = state.riding !== undefined && state.riding !== riding;
|
||||
state.riding = riding;
|
||||
if (changed) {
|
||||
this.signalItems = (this.signalItems ?? []).filter(
|
||||
(item) => item.key !== 'track',
|
||||
);
|
||||
this.signalSignatures?.delete('track');
|
||||
this.pushCockpitSignal(
|
||||
'track',
|
||||
'track',
|
||||
t('TRACK ACQUIRED'),
|
||||
this.orbitalViewSignal(info),
|
||||
);
|
||||
}
|
||||
state.mount = mount ? mount.label || '' : null;
|
||||
// On the satellite, or on the way to it after Previous/Next.
|
||||
const eye = orbitalEyePosition(state, position, nowMs);
|
||||
const eye = mount
|
||||
? clone(mount.position)
|
||||
: orbitalEyePosition(state, position, nowMs);
|
||||
// Track-up: the ground track at the top, so the picture scrolls along it.
|
||||
// A geostationary satellite has no track and stays north-up.
|
||||
const nadir = nadirOrientation(eye, {
|
||||
@@ -291,15 +349,28 @@ export function updateOrbital(nowMs) {
|
||||
this.lastSubjectInfo = info;
|
||||
goToZoom.call(this, maxZoom);
|
||||
}
|
||||
// A ground focus aims the look itself (src/ui/cockpitOrbitalFocus.js).
|
||||
if (!updateOrbitalFocus.call(this, state, nadir, eye, nowMs))
|
||||
// A ground focus aims the look itself (src/ui/cockpitOrbitalFocus.js),
|
||||
// in the frame the arrows turn: from a station view, its own, from its
|
||||
// camera point on the station. The same ±45° reach holds about it.
|
||||
if (
|
||||
!updateOrbitalFocus.call(
|
||||
this,
|
||||
state,
|
||||
mount ?? nadir,
|
||||
eye,
|
||||
nowMs,
|
||||
mount ? nadir : null,
|
||||
)
|
||||
)
|
||||
state.lookView = easeOrbitalLook(
|
||||
state,
|
||||
nowMs - (state.lookLastMs || nowMs),
|
||||
{ immediate: prefersReducedMotion() },
|
||||
);
|
||||
state.lookLastMs = nowMs;
|
||||
const view = offNadirOrientation(nadir, {
|
||||
// The arrows tilt the view about its own frame: the nadir one, or the
|
||||
// mount's.
|
||||
const view = offNadirOrientation(mount ?? nadir, {
|
||||
northDeg: state.lookView.pitchDeg,
|
||||
eastDeg: state.lookView.yawDeg,
|
||||
});
|
||||
@@ -470,9 +541,19 @@ export function publishOrbitalView(info, transition = IDLE_TRANSITION) {
|
||||
northDeg: state.lookView?.pitchDeg ?? 0,
|
||||
eastDeg: state.lookView?.yawDeg ?? 0,
|
||||
});
|
||||
// Riding the station from a mount on its model: the view's name, and no
|
||||
// ground readings, which describe the nadir picture.
|
||||
const mount = state.mount ?? null;
|
||||
// A module with no catalog entry of its own shows its own card: its name,
|
||||
// what it is and a few facts, in place of the entry's identity and TLE.
|
||||
const card = mount !== null ? (state.mountCard ?? null) : null;
|
||||
this.publishOrbital({
|
||||
name: info.name,
|
||||
classLabel: info.classLabel || '',
|
||||
name: card ? card.name : info.name,
|
||||
mount,
|
||||
facts: card ? card.facts.map((fact) => t(fact)) : null,
|
||||
// How many views the station offers: the arrows show with two or more.
|
||||
mountViews: mount === null ? 0 : (state.mountViews?.length ?? 0),
|
||||
classLabel: card ? t(card.classLabel) : info.classLabel || '',
|
||||
altitudeM: info.altitudeM,
|
||||
velocityMps: Number.isFinite(info.velocityMps) ? info.velocityMps : null,
|
||||
latitude: info.latitude,
|
||||
@@ -480,12 +561,12 @@ export function publishOrbitalView(info, transition = IDLE_TRANSITION) {
|
||||
zoom: state.zoom,
|
||||
zoomSteps: ORBITAL_ZOOM_LADDER.filter((step) => step <= maxZoom),
|
||||
maxZoom,
|
||||
footprintKm: offset ? null : footprintKm,
|
||||
footprintKm: offset || mount !== null ? null : footprintKm,
|
||||
// The imaging sensor's swath, drawn to scale; null without one. The
|
||||
// SENSOR step's zoom is null when the swath lies outside 1x..maxZoom.
|
||||
// Looking past the limb there is no ground for it to cover: no sensor.
|
||||
sensor:
|
||||
swathKm === null || !seesEarth
|
||||
swathKm === null || !seesEarth || mount !== null
|
||||
? null
|
||||
: {
|
||||
label: info.sensor?.label ?? null,
|
||||
@@ -503,18 +584,22 @@ export function publishOrbitalView(info, transition = IDLE_TRANSITION) {
|
||||
transition: { ...transition },
|
||||
look: {
|
||||
offset,
|
||||
readout: focus
|
||||
? wordFocusOffNadir(focus)
|
||||
: offset
|
||||
? wordOffNadir(state.lookTarget, { trackUp })
|
||||
: '',
|
||||
// From a mount the tilt is about the mount's frame, not the nadir.
|
||||
readout:
|
||||
mount !== null
|
||||
? ''
|
||||
: focus
|
||||
? wordFocusOffNadir(focus)
|
||||
: offset
|
||||
? wordOffNadir(state.lookTarget, { trackUp })
|
||||
: '',
|
||||
// The mapped point the view is held on, or null.
|
||||
focus: focus ? { key: focus.key, label: focus.label } : null,
|
||||
// Off nadir, the ground width at the view's centre, approximated from
|
||||
// the nadir footprint (`offNadirSwathScale`); 1 and null at nadir.
|
||||
swathScale,
|
||||
swathKm:
|
||||
offset && seesEarth && Number.isFinite(footprintKm)
|
||||
mount === null && offset && seesEarth && Number.isFinite(footprintKm)
|
||||
? footprintKm * swathScale
|
||||
: null,
|
||||
},
|
||||
@@ -523,23 +608,45 @@ export function publishOrbitalView(info, transition = IDLE_TRANSITION) {
|
||||
trackUp,
|
||||
northDeg: trackUp ? (360 - info.groundTrackDeg) % 360 : 0,
|
||||
place: state.place,
|
||||
noradId: info.noradId ?? null,
|
||||
cosparId: info.cosparId ?? null,
|
||||
tle: info.tle ?? null,
|
||||
noradId: card ? null : (info.noradId ?? null),
|
||||
cosparId: card ? null : (info.cosparId ?? null),
|
||||
tle: card ? null : (info.tle ?? null),
|
||||
// Read on the HUD's cadence, so the age stays current without a timer.
|
||||
// The gap between the TLE's epoch and the time the satellite is shown
|
||||
// at (the world clock's), either side: SGP4 drifts both ways.
|
||||
tleAgeMs: Number.isFinite(info.tle?.epochMs)
|
||||
? Math.abs(
|
||||
(Number.isFinite(info.atMs) ? info.atMs : Date.now()) -
|
||||
info.tle.epochMs,
|
||||
)
|
||||
: null,
|
||||
owner: info.owner ?? null,
|
||||
operator: info.operator ?? null,
|
||||
tleAgeMs:
|
||||
!card && Number.isFinite(info.tle?.epochMs)
|
||||
? Math.abs(
|
||||
(Number.isFinite(info.atMs) ? info.atMs : Date.now()) -
|
||||
info.tle.epochMs,
|
||||
)
|
||||
: null,
|
||||
owner: card ? null : (info.owner ?? null),
|
||||
operator: card ? t(card.operator) : (info.operator ?? null),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The TRACK ACQUIRED line for a satellite subject: which picture it gets.
|
||||
* The station is ridden from a mount on its 3D model (once that is loaded);
|
||||
* every other satellite looks straight down.
|
||||
* @param {object} info Satellite subject.
|
||||
* @returns {string}
|
||||
*/
|
||||
export function orbitalViewSignal(info) {
|
||||
// A running session knows; on entry, before its first frame, the layer does.
|
||||
const riding =
|
||||
this.orbital?.riding ??
|
||||
Boolean(
|
||||
this.services.satellitesLayer?.getCockpitMount?.(
|
||||
this.orbital?.mountKey ?? null,
|
||||
),
|
||||
);
|
||||
return riding
|
||||
? t('{label} · STATION VIEW', { label: info.name })
|
||||
: t('{label} · NADIR VIEW', { label: info.name });
|
||||
}
|
||||
|
||||
/**
|
||||
* Present the orbital view on entry and after a language switch: the HUD,
|
||||
* the local page and a regional brief for the sub-satellite point.
|
||||
@@ -556,6 +663,38 @@ export function updateOrbitalHud(info, nowMs = performance.now()) {
|
||||
updateOrbitalContext.call(this, info, nowMs, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* The station view's arrows: move to its next view (from Nauka, from Zarya,
|
||||
* from Poisk, from the Cupola, from Kibo, from a docked vehicle) or the one
|
||||
* before, wrapping round, looking the way that view looks.
|
||||
* @param {number} [direction] 1 for the next view, -1 for the one before.
|
||||
* @returns {boolean} True when the view changed.
|
||||
*/
|
||||
export function stepOrbitalMount(direction = 1) {
|
||||
if (!this.active || this.subjectKind !== 'satellite' || !this.orbital)
|
||||
return false;
|
||||
const state = this.orbital;
|
||||
const step = direction < 0 ? issPreviousMountView : issNextMountView;
|
||||
const next =
|
||||
state.mount === null ? null : step(state.mountViews, state.mountKey);
|
||||
if (!next) return false;
|
||||
state.mountKey = next.key;
|
||||
state.mount = next.label || '';
|
||||
state.mountCard = next.card ?? null;
|
||||
state.mountSwitchFailed = null;
|
||||
// A ground focus was aimed from the old view: it ends with it.
|
||||
if (state.focus) {
|
||||
state.focus = null;
|
||||
state.focusReleasing = false;
|
||||
this.refreshOrbitalSignals?.();
|
||||
}
|
||||
// Each view has its own way of looking: the look goes back to it.
|
||||
state.lookTarget = { ...NADIR_LOOK };
|
||||
state.lookView = { ...NADIR_LOOK };
|
||||
presentNow.call(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Re-apply the field of view and publish after a zoom or look change. */
|
||||
function presentNow() {
|
||||
const state = this.orbital;
|
||||
|
||||
@@ -1466,3 +1466,535 @@ test('back to nadir from past the limb, the sensor waits for the view', async (t
|
||||
await settle();
|
||||
assert.ok(store.orbital.sensor, 'back on the Earth');
|
||||
});
|
||||
|
||||
/** A mount on the station: 20 m from the satellite's position, looking along the track. */
|
||||
function stationMount() {
|
||||
const centre = satellitePosition();
|
||||
const enu = Cesium.Transforms.eastNorthUpToFixedFrame(centre);
|
||||
const axis = (x, y, z) =>
|
||||
Cesium.Matrix4.multiplyByPointAsVector(
|
||||
enu,
|
||||
new Cesium.Cartesian3(x, y, z),
|
||||
new Cesium.Cartesian3(),
|
||||
);
|
||||
const direction = axis(0, 1, 0);
|
||||
const up = axis(0, 0, 1);
|
||||
return {
|
||||
position: Cesium.Cartesian3.add(
|
||||
centre,
|
||||
Cesium.Cartesian3.multiplyByScalar(up, 20, new Cesium.Cartesian3()),
|
||||
new Cesium.Cartesian3(),
|
||||
),
|
||||
direction,
|
||||
up,
|
||||
right: Cesium.Cartesian3.cross(direction, up, new Cesium.Cartesian3()),
|
||||
label: 'ZARYA',
|
||||
};
|
||||
}
|
||||
|
||||
test('the station is ridden from its mount: the camera sits there and looks along it', async (t) => {
|
||||
const { $, cockpit, satellites, shots, store, clock } = await orbitAt(t);
|
||||
const mount = stationMount();
|
||||
satellites.getCockpitMount = () => mount;
|
||||
clock.advance(16);
|
||||
cockpit.update();
|
||||
await settle();
|
||||
const shot = shots.at(-1);
|
||||
assert.ok(
|
||||
Cesium.Cartesian3.equalsEpsilon(shot.destination, mount.position, 1e-9),
|
||||
'the camera is at the mount, not at the satellite',
|
||||
);
|
||||
near(
|
||||
angleDeg(shot.direction, mount.direction),
|
||||
0,
|
||||
'looks along the mount',
|
||||
1e-9,
|
||||
);
|
||||
near(angleDeg(shot.up, mount.up), 0, 'the mount is upright', 1e-9);
|
||||
|
||||
// The HUD names the view and drops what describes the nadir picture.
|
||||
assert.equal(store.orbital.mount, 'ZARYA');
|
||||
assert.equal(store.orbital.footprintKm, null);
|
||||
assert.equal(store.orbital.sensor, null);
|
||||
assert.equal(
|
||||
$('.cockpit-orbital-kicker').textContent,
|
||||
'STATION VIEW · ZARYA',
|
||||
);
|
||||
assert.equal($('.cockpit-orbital-reticle'), null);
|
||||
assert.equal($('.cockpit-orbital-north'), null);
|
||||
assert.match($('.cockpit-help').textContent, /ARROWS LOOK/);
|
||||
assert.match($('.cockpit-help').textContent, /HOME RESET/);
|
||||
assert.doesNotMatch($('.cockpit-help').textContent, /NADIR/);
|
||||
|
||||
// The arrows turn the view about the mount's own frame, and Home returns.
|
||||
press(cockpit, 'ArrowRight');
|
||||
clock.advance(16);
|
||||
cockpit.update();
|
||||
await settle();
|
||||
const turned = shots.at(-1);
|
||||
near(angleDeg(turned.direction, mount.direction), 5, 'one step is 5°', 1e-6);
|
||||
assert.ok(
|
||||
Cesium.Cartesian3.dot(turned.direction, mount.right) > 0,
|
||||
'right turns toward the mount’s right',
|
||||
);
|
||||
assert.ok(
|
||||
Cesium.Cartesian3.equalsEpsilon(turned.destination, mount.position, 1e-9),
|
||||
);
|
||||
assert.equal($('#cockpit-orbital-nadir').textContent, 'RESET');
|
||||
assert.equal($('#cockpit-orbital-look-readout').textContent, '');
|
||||
press(cockpit, 'Home');
|
||||
clock.advance(16);
|
||||
cockpit.update();
|
||||
near(angleDeg(shots.at(-1).direction, mount.direction), 0, 'Home', 1e-9);
|
||||
});
|
||||
|
||||
test('without a mount the same satellite keeps the nadir picture, and gets it back', async (t) => {
|
||||
const { $, cockpit, satellites, shots, store, clock } = await orbitAt(t);
|
||||
const position = satellitePosition();
|
||||
const toCentre = Cesium.Cartesian3.negate(
|
||||
Cesium.Cartesian3.normalize(position, new Cesium.Cartesian3()),
|
||||
new Cesium.Cartesian3(),
|
||||
);
|
||||
const signals = [];
|
||||
cockpit.pushCockpitSignal = (key, kind, title, detail) =>
|
||||
signals.push(detail);
|
||||
// The model has not loaded yet: straight down, as for any satellite.
|
||||
satellites.getCockpitMount = () => null;
|
||||
clock.advance(16);
|
||||
cockpit.update();
|
||||
await settle();
|
||||
assert.deepEqual(signals, [], 'nothing changed: nothing to say');
|
||||
near(angleDeg(shots.at(-1).direction, toCentre), 0, 'nadir', 1e-9);
|
||||
assert.equal(store.orbital.mount, null);
|
||||
assert.equal(
|
||||
$('.cockpit-orbital-kicker').textContent,
|
||||
'ORBITAL VIEW · NADIR',
|
||||
);
|
||||
assert.ok($('.cockpit-orbital-reticle'));
|
||||
|
||||
// It loads: the view moves to the mount. It goes again: back to nadir.
|
||||
const mount = stationMount();
|
||||
satellites.getCockpitMount = () => mount;
|
||||
clock.advance(1000);
|
||||
cockpit.update();
|
||||
await settle();
|
||||
assert.equal(store.orbital.mount, 'ZARYA');
|
||||
near(angleDeg(shots.at(-1).direction, mount.direction), 0, 'mount', 1e-9);
|
||||
// The TRACK ACQUIRED line follows the picture, once per change.
|
||||
cockpit.update();
|
||||
assert.deepEqual(signals, ['ISS (ZARYA) · STATION VIEW']);
|
||||
satellites.getCockpitMount = () => null;
|
||||
clock.advance(1000);
|
||||
cockpit.update();
|
||||
await settle();
|
||||
assert.deepEqual(signals, [
|
||||
'ISS (ZARYA) · STATION VIEW',
|
||||
'ISS (ZARYA) · NADIR VIEW',
|
||||
]);
|
||||
assert.equal(store.orbital.mount, null);
|
||||
near(angleDeg(shots.at(-1).direction, toCentre), 0, 'nadir again', 1e-9);
|
||||
assert.ok(
|
||||
Cesium.Cartesian3.equalsEpsilon(shots.at(-1).destination, position, 1e-6),
|
||||
);
|
||||
});
|
||||
|
||||
/** The station's views as the satellites layer offers them, by key. */
|
||||
function stationViews({ docked = true } = {}) {
|
||||
const views = [
|
||||
{ key: 'nauka', label: 'NAUKA' },
|
||||
{ key: 'zarya', label: 'ZARYA' },
|
||||
...(docked ? [{ key: 'docked', label: 'PROGRESS-MS 34' }] : []),
|
||||
];
|
||||
const base = stationMount();
|
||||
// Each view sits a different distance above the satellite's position.
|
||||
const heights = { nauka: 10, zarya: 20, docked: 30 };
|
||||
const asked = [];
|
||||
return {
|
||||
asked,
|
||||
views,
|
||||
heightOf(shot) {
|
||||
return Math.round(
|
||||
Cesium.Cartesian3.distance(shot.destination, satellitePosition()),
|
||||
);
|
||||
},
|
||||
getCockpitMount(key) {
|
||||
asked.push(key);
|
||||
const view = views.find((entry) => entry.key === key) ?? views[0];
|
||||
return {
|
||||
...base,
|
||||
position: Cesium.Cartesian3.add(
|
||||
satellitePosition(),
|
||||
Cesium.Cartesian3.multiplyByScalar(
|
||||
base.up,
|
||||
heights[view.key],
|
||||
new Cesium.Cartesian3(),
|
||||
),
|
||||
new Cesium.Cartesian3(),
|
||||
),
|
||||
key: view.key,
|
||||
label: view.label,
|
||||
views,
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
test('the station opens on its first view and the arrows step through the rest', async (t) => {
|
||||
const { $, cockpit, satellites, shots, store, clock } = await orbitAt(t);
|
||||
const station = stationViews();
|
||||
satellites.getCockpitMount = station.getCockpitMount;
|
||||
const frame = async () => {
|
||||
clock.advance(16);
|
||||
cockpit.update();
|
||||
await settle();
|
||||
};
|
||||
await frame();
|
||||
// Nothing was chosen: the layer is asked for its first view, Nauka's,
|
||||
// though the entry ridden is ISS (ZARYA).
|
||||
assert.equal(station.asked[0], null);
|
||||
assert.equal(store.orbital.mount, 'NAUKA');
|
||||
assert.equal(store.orbital.mountViews, 3);
|
||||
assert.equal(station.heightOf(shots.at(-1)), 10);
|
||||
assert.equal(
|
||||
$('.cockpit-orbital-kicker').textContent,
|
||||
'STATION VIEW · NAUKA',
|
||||
);
|
||||
assert.equal(
|
||||
$('#cockpit-orbital-view-next').getAttribute('aria-label'),
|
||||
'Next station view',
|
||||
);
|
||||
assert.equal(
|
||||
$('#cockpit-orbital-view-previous').getAttribute('aria-label'),
|
||||
'Previous station view',
|
||||
);
|
||||
assert.equal($('#cockpit-orbital-view-name').textContent, 'NAUKA');
|
||||
|
||||
// A look off to one side is dropped by the step: each view looks its own way.
|
||||
press(cockpit, 'ArrowRight');
|
||||
await frame();
|
||||
assert.equal(store.orbital.look.offset, true);
|
||||
|
||||
// The button, as a click anywhere inside it.
|
||||
$('#cockpit-orbital-view-next').dispatchEvent(
|
||||
new Event('click', { bubbles: true }),
|
||||
);
|
||||
await settle();
|
||||
assert.equal(store.orbital.mount, 'ZARYA', 'named at once, before a frame');
|
||||
await frame();
|
||||
assert.equal(station.asked.at(-1), 'zarya');
|
||||
assert.equal(station.heightOf(shots.at(-1)), 20);
|
||||
assert.equal(store.orbital.look.offset, false);
|
||||
near(
|
||||
angleDeg(shots.at(-1).direction, stationMount().direction),
|
||||
0,
|
||||
'reset',
|
||||
1e-9,
|
||||
);
|
||||
assert.equal(
|
||||
$('.cockpit-orbital-kicker').textContent,
|
||||
'STATION VIEW · ZARYA',
|
||||
);
|
||||
|
||||
assert.equal(cockpit.nextOrbitalView(), true);
|
||||
await frame();
|
||||
assert.equal(store.orbital.mount, 'PROGRESS-MS 34');
|
||||
assert.equal(station.heightOf(shots.at(-1)), 30);
|
||||
// Round again to the first.
|
||||
assert.equal(cockpit.nextOrbitalView(), true);
|
||||
await frame();
|
||||
assert.equal(store.orbital.mount, 'NAUKA');
|
||||
assert.equal(station.heightOf(shots.at(-1)), 10);
|
||||
});
|
||||
|
||||
test('the chosen view is kept while the model is away, and one view has no arrows', async (t) => {
|
||||
const { $, cockpit, satellites, store, clock } = await orbitAt(t);
|
||||
const station = stationViews({ docked: false });
|
||||
satellites.getCockpitMount = station.getCockpitMount;
|
||||
// A second per frame: the HUD republishes on its own cadence.
|
||||
const frame = async () => {
|
||||
clock.advance(1000);
|
||||
cockpit.update();
|
||||
await settle();
|
||||
};
|
||||
await frame();
|
||||
assert.equal(store.orbital.mountViews, 2);
|
||||
cockpit.nextOrbitalView();
|
||||
await frame();
|
||||
assert.equal(store.orbital.mount, 'ZARYA');
|
||||
// The model goes: nadir, no control, nothing to step.
|
||||
satellites.getCockpitMount = () => null;
|
||||
await frame();
|
||||
assert.equal(store.orbital.mount, null);
|
||||
assert.equal(store.orbital.mountViews, 0);
|
||||
assert.equal($('#cockpit-orbital-view-next'), null);
|
||||
assert.equal($('#cockpit-orbital-view-previous'), null);
|
||||
assert.equal(cockpit.nextOrbitalView(), false);
|
||||
// It comes back: the same view is asked for again.
|
||||
satellites.getCockpitMount = station.getCockpitMount;
|
||||
await frame();
|
||||
assert.equal(station.asked.at(-1), 'zarya');
|
||||
assert.equal(store.orbital.mount, 'ZARYA');
|
||||
|
||||
// A station offering a single view shows no control.
|
||||
station.views.length = 1;
|
||||
await frame();
|
||||
assert.equal(store.orbital.mount, 'NAUKA', 'the view on offer');
|
||||
assert.equal(store.orbital.mountViews, 1);
|
||||
assert.equal($('#cockpit-orbital-view-next'), null);
|
||||
assert.equal($('#cockpit-orbital-view-previous'), null);
|
||||
assert.equal(cockpit.nextOrbitalView(), false);
|
||||
});
|
||||
|
||||
test('the view arrows do nothing outside a station view', async (t) => {
|
||||
const { cockpit, clock } = await orbitAt(t);
|
||||
clock.advance(16);
|
||||
cockpit.update();
|
||||
assert.equal(cockpit.nextOrbitalView(), false);
|
||||
assert.equal(cockpit.previousOrbitalView(), false);
|
||||
cockpit.exit();
|
||||
assert.equal(cockpit.nextOrbitalView(), false);
|
||||
assert.equal(cockpit.previousOrbitalView(), false);
|
||||
});
|
||||
|
||||
test('each station view rides its own entry, so the card describes that module', async (t) => {
|
||||
const { $, cockpit, satellites, store, clock } = await orbitAt(t);
|
||||
// The layer, as it behaves: tracking another entry makes it the subject.
|
||||
const names = {
|
||||
25544: 'ISS (ZARYA)',
|
||||
49044: 'ISS (NAUKA)',
|
||||
36086: 'POISK',
|
||||
68837: 'PROGRESS-MS 34',
|
||||
};
|
||||
let subject = { ...ISS, noradId: 68837, id: '68837', name: names[68837] };
|
||||
const tracked = [];
|
||||
satellites.getCockpitSubject = () => ({ ...subject });
|
||||
satellites.trackById = (noradId) => {
|
||||
tracked.push(Number(noradId));
|
||||
const id = Number(noradId);
|
||||
subject = { ...ISS, noradId: id, id: String(id), name: names[id] };
|
||||
return true;
|
||||
};
|
||||
cockpit.subjectId = 68837;
|
||||
const base = stationMount();
|
||||
const views = [
|
||||
{ key: 'nauka', label: 'NAUKA', noradId: 49044 },
|
||||
{ key: 'zarya', label: 'ZARYA', noradId: 25544 },
|
||||
{ key: 'poisk', label: 'POISK', noradId: 36086 },
|
||||
{ key: 'docked', label: 'PROGRESS-MS 34', noradId: 68837 },
|
||||
];
|
||||
satellites.getCockpitMount = (key) => {
|
||||
const view = views.find((entry) => entry.key === key) ?? views[0];
|
||||
return { ...base, ...view, views };
|
||||
};
|
||||
const frame = async () => {
|
||||
clock.advance(1000);
|
||||
cockpit.update();
|
||||
await settle();
|
||||
};
|
||||
// Entered on the Progress; the view opens on Nauka and rides Nauka.
|
||||
await frame();
|
||||
await frame();
|
||||
assert.deepEqual(tracked, [49044]);
|
||||
assert.equal(cockpit.subjectId, 49044);
|
||||
assert.equal(store.orbital.name, 'ISS (NAUKA)');
|
||||
assert.equal($('.cockpit-orbital-name').textContent, 'ISS (NAUKA)');
|
||||
assert.equal(store.orbital.mount, 'NAUKA');
|
||||
|
||||
// Each step rides the next view's entry.
|
||||
for (const [noradId, name] of [
|
||||
[25544, 'ISS (ZARYA)'],
|
||||
[36086, 'POISK'],
|
||||
[68837, 'PROGRESS-MS 34'],
|
||||
[49044, 'ISS (NAUKA)'],
|
||||
]) {
|
||||
assert.equal(cockpit.nextOrbitalView(), true);
|
||||
await frame();
|
||||
await frame();
|
||||
assert.equal(cockpit.subjectId, noradId);
|
||||
assert.equal(store.orbital.name, name);
|
||||
assert.equal($('.cockpit-orbital-name').textContent, name);
|
||||
}
|
||||
assert.deepEqual(tracked, [49044, 25544, 36086, 68837, 49044]);
|
||||
});
|
||||
|
||||
test('a view with no entry, or one that cannot be ridden, keeps the subject', async (t) => {
|
||||
const { cockpit, satellites, store, clock } = await orbitAt(t);
|
||||
const base = stationMount();
|
||||
let views = [
|
||||
{ key: 'nauka', label: 'NAUKA', noradId: null },
|
||||
{ key: 'zarya', label: 'ZARYA', noradId: 25544 },
|
||||
];
|
||||
satellites.getCockpitMount = (key) => {
|
||||
const view = views.find((entry) => entry.key === key) ?? views[0];
|
||||
return { ...base, ...view, views };
|
||||
};
|
||||
let asked = 0;
|
||||
satellites.trackById = () => {
|
||||
asked += 1;
|
||||
return false;
|
||||
};
|
||||
const frame = async () => {
|
||||
clock.advance(1000);
|
||||
cockpit.update();
|
||||
await settle();
|
||||
};
|
||||
// No entry for Nauka: the ISS stays the subject, and nothing is tracked.
|
||||
await frame();
|
||||
assert.equal(asked, 0);
|
||||
assert.equal(cockpit.subjectId, 25544);
|
||||
assert.equal(store.orbital.mount, 'NAUKA');
|
||||
// An entry the layer will not track: asked once, not every frame.
|
||||
views = [
|
||||
{ key: 'nauka', label: 'NAUKA', noradId: 49044 },
|
||||
{ key: 'zarya', label: 'ZARYA', noradId: 25544 },
|
||||
];
|
||||
await frame();
|
||||
await frame();
|
||||
await frame();
|
||||
assert.equal(asked, 1);
|
||||
assert.equal(cockpit.subjectId, 25544);
|
||||
assert.equal(document.body.classList.contains('cockpit-orbit'), true);
|
||||
});
|
||||
|
||||
const CUPOLA_CARD = Object.freeze({
|
||||
name: 'CUPOLA',
|
||||
classLabel: 'OBSERVATION MODULE · ISS',
|
||||
operator: 'European Space Agency (ESA)',
|
||||
facts: ['7 WINDOWS', 'LAUNCHED 8 FEB 2010 · STS-130'],
|
||||
});
|
||||
|
||||
test('a view with a card of its own shows it in place of the entry’s identity', async (t) => {
|
||||
const { $, cockpit, satellites, store, clock } = await orbitAt(t);
|
||||
const base = stationMount();
|
||||
const views = [
|
||||
{ key: 'zarya', label: 'ZARYA', noradId: 25544, card: null },
|
||||
{ key: 'cupola', label: 'CUPOLA', noradId: 25544, card: CUPOLA_CARD },
|
||||
];
|
||||
satellites.getCockpitMount = (key) => {
|
||||
const view = views.find((entry) => entry.key === key) ?? views[0];
|
||||
return { ...base, ...view, views };
|
||||
};
|
||||
const frame = async () => {
|
||||
clock.advance(1000);
|
||||
cockpit.update();
|
||||
await settle();
|
||||
};
|
||||
await frame();
|
||||
assert.equal(store.orbital.name, 'ISS (ZARYA)');
|
||||
assert.equal(store.orbital.noradId, 25544);
|
||||
assert.equal(store.orbital.facts, null);
|
||||
|
||||
cockpit.nextOrbitalView();
|
||||
await frame();
|
||||
// Same entry ridden (nothing to switch), the Cupola's own card shown.
|
||||
assert.equal(cockpit.subjectId, 25544);
|
||||
assert.equal(store.orbital.mount, 'CUPOLA');
|
||||
assert.equal(store.orbital.name, 'CUPOLA');
|
||||
assert.equal($('.cockpit-orbital-name').textContent, 'CUPOLA');
|
||||
assert.equal(store.orbital.classLabel, 'OBSERVATION MODULE · ISS');
|
||||
assert.equal(store.orbital.operator, 'European Space Agency (ESA)');
|
||||
assert.equal(store.orbital.noradId, null);
|
||||
assert.equal(store.orbital.tle, null);
|
||||
assert.equal(store.orbital.owner, null);
|
||||
assert.equal(
|
||||
$('.cockpit-orbital-ident-text').textContent,
|
||||
'7 WINDOWS · LAUNCHED 8 FEB 2010 · STS-130',
|
||||
);
|
||||
assert.equal($('#cockpit-orbital-tle-toggle'), null);
|
||||
// Altitude, velocity and the sub-satellite point are the station's still.
|
||||
assert.ok($('.cockpit-orbital-altitude').textContent.length > 0);
|
||||
|
||||
// Back round to Zarya: the entry's own card again.
|
||||
cockpit.nextOrbitalView();
|
||||
await frame();
|
||||
assert.equal(store.orbital.name, 'ISS (ZARYA)');
|
||||
assert.equal(store.orbital.noradId, 25544);
|
||||
assert.equal(store.orbital.facts, null);
|
||||
});
|
||||
|
||||
test('leaving a station view selects Nauka; leaving any other keeps the satellite', async (t) => {
|
||||
const { cockpit, satellites, clock } = await orbitAt(t);
|
||||
const names = { 25544: 'ISS (ZARYA)', 49044: 'ISS (NAUKA)' };
|
||||
let subject = { ...ISS };
|
||||
const tracked = [];
|
||||
satellites.getCockpitSubject = () => ({ ...subject });
|
||||
satellites.trackById = (noradId) => {
|
||||
const id = Number(noradId);
|
||||
tracked.push(id);
|
||||
subject = { ...ISS, noradId: id, id: String(id), name: names[id] };
|
||||
return true;
|
||||
};
|
||||
const base = stationMount();
|
||||
const views = [
|
||||
{ key: 'nauka', label: 'NAUKA', noradId: 49044, card: null },
|
||||
{ key: 'cupola', label: 'CUPOLA', noradId: 25544, card: CUPOLA_CARD },
|
||||
];
|
||||
satellites.getCockpitMount = (key) => {
|
||||
const view = views.find((entry) => entry.key === key) ?? views[0];
|
||||
return { ...base, ...view, views };
|
||||
};
|
||||
const frame = async () => {
|
||||
clock.advance(1000);
|
||||
cockpit.update();
|
||||
await settle();
|
||||
};
|
||||
await frame();
|
||||
await frame();
|
||||
// On the Cupola, riding the ISS's entry, when the Cockpit is left.
|
||||
cockpit.nextOrbitalView();
|
||||
await frame();
|
||||
await frame();
|
||||
assert.equal(cockpit.subjectId, 25544);
|
||||
satellites.calls.length = 0;
|
||||
tracked.length = 0;
|
||||
assert.equal(cockpit.exit(), true);
|
||||
assert.deepEqual(tracked, [49044], 'Nauka is selected');
|
||||
assert.deepEqual(satellites.calls, [
|
||||
['subject', null],
|
||||
['refocus', 49044],
|
||||
]);
|
||||
});
|
||||
|
||||
test('leaving the plain orbital view refocuses the satellite ridden', async (t) => {
|
||||
const { cockpit, satellites } = await orbitAt(t);
|
||||
const tracked = [];
|
||||
satellites.trackById = (noradId) => {
|
||||
tracked.push(noradId);
|
||||
return true;
|
||||
};
|
||||
satellites.calls.length = 0;
|
||||
assert.equal(cockpit.exit(), true);
|
||||
assert.deepEqual(tracked, []);
|
||||
assert.deepEqual(satellites.calls, [
|
||||
['subject', null],
|
||||
['refocus', 25544],
|
||||
]);
|
||||
});
|
||||
|
||||
test('the left arrow steps back through the views, wrapping round', async (t) => {
|
||||
const { $, cockpit, satellites, shots, store, clock } = await orbitAt(t);
|
||||
const station = stationViews();
|
||||
satellites.getCockpitMount = station.getCockpitMount;
|
||||
const frame = async () => {
|
||||
clock.advance(16);
|
||||
cockpit.update();
|
||||
await settle();
|
||||
};
|
||||
await frame();
|
||||
assert.equal(store.orbital.mount, 'NAUKA');
|
||||
// From the first view back to the last.
|
||||
$('#cockpit-orbital-view-previous').dispatchEvent(
|
||||
new Event('click', { bubbles: true }),
|
||||
);
|
||||
await settle();
|
||||
assert.equal(store.orbital.mount, 'PROGRESS-MS 34');
|
||||
await frame();
|
||||
// The camera is at the docked vehicle's view (30 m up in this stand-in).
|
||||
assert.equal(station.heightOf(shots.at(-1)), 30);
|
||||
assert.equal(cockpit.previousOrbitalView(), true);
|
||||
await frame();
|
||||
assert.equal(store.orbital.mount, 'ZARYA');
|
||||
assert.equal(cockpit.nextOrbitalView(), true);
|
||||
await frame();
|
||||
assert.equal(store.orbital.mount, 'PROGRESS-MS 34');
|
||||
});
|
||||
@@ -678,7 +678,7 @@ export function enter({ kind = null } = {}) {
|
||||
'track',
|
||||
'track',
|
||||
t('TRACK ACQUIRED'),
|
||||
t('{label} · NADIR VIEW', { label: info.name }),
|
||||
this.orbitalViewSignal(info),
|
||||
);
|
||||
} else if (vessel) {
|
||||
this.pushCockpitSignal(
|
||||
@@ -739,6 +739,14 @@ export function exit({ restoreTracking = true } = {}) {
|
||||
const vesselSubject = this.subjectKind === 'vessel' ? this.subjectId : null;
|
||||
const satelliteSubject =
|
||||
this.subjectKind === 'satellite' ? this.subjectId : null;
|
||||
// Leaving a view from a station selects the station's home entry (the
|
||||
// ISS's Nauka, Tiangong's Tianhe), whichever view or entry it ended on:
|
||||
// the station's first view, and the one it opens on.
|
||||
const station = this.orbital;
|
||||
const stationHome =
|
||||
satelliteSubject !== null && station && station.mount != null
|
||||
? (station.mountViews?.[0]?.noradId ?? null)
|
||||
: null;
|
||||
this.active = false;
|
||||
this.subjectKind = null;
|
||||
this.subjectProvider = null;
|
||||
@@ -810,8 +818,20 @@ export function exit({ restoreTracking = true } = {}) {
|
||||
// Back to the selected vessel's map view, through the layer's own focus.
|
||||
this.services.aisLiveVesselsLayer?.focusSelectedVessel?.();
|
||||
} else if (restoreTracking && satelliteSubject !== null) {
|
||||
// Back to the satellite's follow camera, through the layer's own refocus.
|
||||
this.services.satellitesLayer?.refocusTrackedById?.(satelliteSubject);
|
||||
// Back to the satellite's follow camera, through the layer's own refocus;
|
||||
// from a station, on its home entry.
|
||||
const layer = this.services.satellitesLayer;
|
||||
let subject = satelliteSubject;
|
||||
if (stationHome !== null && String(stationHome) !== String(subject)) {
|
||||
let tracked = false;
|
||||
try {
|
||||
tracked = Boolean(layer?.trackById?.(stationHome, { origin: 'user' }));
|
||||
} catch {
|
||||
tracked = false;
|
||||
}
|
||||
if (tracked) subject = stationHome;
|
||||
}
|
||||
layer?.refocusTrackedById?.(subject);
|
||||
}
|
||||
this.syncEntry();
|
||||
// Return to the card or readout control that opened Cockpit.
|
||||
|
||||
@@ -58,7 +58,10 @@ test('before ContextControls renders, the switch shows its initial markup', (t)
|
||||
);
|
||||
assert.equal(panel.hasAttribute('data-context-mode'), false);
|
||||
const tab = $('global-context-flights-btn');
|
||||
assert.equal(tab.className, 'context-mode-button');
|
||||
assert.equal(
|
||||
tab.className,
|
||||
'ui-button ui-focus ui-button--ghost ui-button--accent context-mode-button',
|
||||
);
|
||||
assert.equal(tab.getAttribute('aria-selected'), 'false');
|
||||
assert.equal(tab.getAttribute('tabindex'), '0');
|
||||
assert.equal(tab.hasAttribute('aria-busy'), false);
|
||||
@@ -150,3 +153,21 @@ test('the nearby sites search is busy, without native disable, until it settles'
|
||||
assert.equal(button.getAttribute('aria-busy'), 'false');
|
||||
assert.equal(button.getAttribute('aria-disabled'), 'false');
|
||||
});
|
||||
|
||||
test('with Context closed, the collapsible sections are already in the page for PanelChrome', (t) => {
|
||||
// PanelChrome finds collapsible panels once, at startup, by their collapse
|
||||
// buttons; Context starts closed, so a section that mounts only while it
|
||||
// is open would never be registered and its +/- would do nothing.
|
||||
fixture(t);
|
||||
assert.equal(
|
||||
document
|
||||
.getElementById('global-context-panel')
|
||||
.classList.contains('collapsed'),
|
||||
true,
|
||||
);
|
||||
const targets = [
|
||||
...document.querySelectorAll('.panel-collapse-btn[data-collapse-target]'),
|
||||
].map((button) => button.dataset.collapseTarget);
|
||||
for (const id of ['station-panel', 'live-panel', 'radio-panel'])
|
||||
assert.ok(targets.includes(id), `${id} is there to be registered`);
|
||||
});
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup>
|
||||
import { t } from '../../i18n/index.js';
|
||||
import UiButton from '../kit/UiButton.vue';
|
||||
import UiCloseButton from '../kit/UiCloseButton.vue';
|
||||
import CreditItem from './CreditItem.vue';
|
||||
|
||||
@@ -33,6 +34,12 @@ const props = defineProps({
|
||||
const SEPARATOR = ' · ';
|
||||
/** A credit's key: the same text and link are one credit. */
|
||||
const key = (credit) => `${credit.text}\u0000${credit.href ?? ''}`;
|
||||
// The list button's words are the slot of a UiButton, which renders inside
|
||||
// the button: a locale that is not bound to a ref changes nothing the button
|
||||
// reads, and the owner patches synchronously and reads the result at once. A
|
||||
// slot given under a condition (`redrawWithView`, always true) is redrawn
|
||||
// whenever this view is, so the words follow a new locale with the rest.
|
||||
const redrawWithView = true;
|
||||
/** Keep `name`'s element for the owner. */
|
||||
const keep = (name) => (element) => {
|
||||
props.elements[name] = element?.$el ?? element;
|
||||
@@ -46,16 +53,17 @@ const keep = (name) => (element) => {
|
||||
><template v-for="(credit, i) in props.inline" :key="key(credit)"
|
||||
>{{ i ? SEPARATOR : '' }}<CreditItem :credit="credit" /></template
|
||||
>{{ props.inline.length && props.listed.length ? SEPARATOR : '' }}</span
|
||||
><button
|
||||
><UiButton
|
||||
:ref="keep('expand')"
|
||||
type="button"
|
||||
class="gev-credits-expand"
|
||||
aria-haspopup="dialog"
|
||||
:aria-controls="props.panelId"
|
||||
:aria-expanded="String(props.open)"
|
||||
:hidden="props.listed.length === 0"
|
||||
@click="props.onExpand()"
|
||||
>{{ t('Data attribution') }}</button
|
||||
><template v-if="redrawWithView" #default>{{
|
||||
t('Data attribution')
|
||||
}}</template></UiButton
|
||||
></div
|
||||
><div
|
||||
:id="props.panelId"
|
||||
|
||||
@@ -557,7 +557,7 @@ test('the imported files render what the file import publishes and keep focus',
|
||||
assert.equal(name.textContent, '<b>a</b>.geojson');
|
||||
assert.equal(name.children.length, 0, 'the name is text');
|
||||
assert.match(name.title, /GEOJSON, 2 map objects$/);
|
||||
assert.equal(toggle.className, 'geo-import-action');
|
||||
assert.ok(toggle.classList.contains('geo-import-action'));
|
||||
assert.equal(toggle.getAttribute('type'), 'button');
|
||||
assert.equal(toggle.getAttribute('aria-pressed'), 'true');
|
||||
assert.equal(toggle.getAttribute('aria-label'), 'Hide <b>a</b>.geojson');
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { resolvePickedContext } from '../data/pickedContext.js';
|
||||
import { onScreen } from '../data/locate.js';
|
||||
import { clickCard } from '../data/pickRegistry.js';
|
||||
import { followedOf, onFollowChanged } from '../data/followed.js';
|
||||
import { fromDegreesInto } from '../geo/ellipsoid.js';
|
||||
@@ -136,6 +137,21 @@ export function installEntityContext({
|
||||
}
|
||||
}
|
||||
|
||||
// An item back in its feed after it left it is selected again in its layer,
|
||||
// as the click that picked it: a vessel is highlighted with its trail, and
|
||||
// an aircraft found again (`follow`) is followed.
|
||||
function reselect(card, { follow: andFollow = false } = {}) {
|
||||
const layer = getDataManager()?.layers?.get?.(card?.layerId)?.module;
|
||||
const id = card?.identity?.id;
|
||||
if (!layer || !id) return;
|
||||
try {
|
||||
if (card.layerId === 'ais-live-vessels') layer.selectById?.(id);
|
||||
else if (andFollow && FOLLOWABLE.has(card.layerId)) follow(card);
|
||||
} catch {
|
||||
// A layer going away meanwhile has nothing to select.
|
||||
}
|
||||
}
|
||||
|
||||
// Aircraft can be flown from, and a satellite ridden in the orbital view:
|
||||
// track the craft, then enter Cockpit on it. Only layers the tracking
|
||||
// action can follow are offered (local ADS-B cannot be tracked).
|
||||
@@ -197,6 +213,14 @@ export function installEntityContext({
|
||||
flyTo,
|
||||
follow,
|
||||
letGo,
|
||||
reselect,
|
||||
// Whether the camera shows the card's item; null when it cannot tell.
|
||||
onScreen: (card) => {
|
||||
const pose = camera()?.pose();
|
||||
if (!pose || !Number.isFinite(card?.lat) || !Number.isFinite(card?.lon))
|
||||
return null;
|
||||
return onScreen(pose, card.lat, card.lon, card.altitudeM ?? 0);
|
||||
},
|
||||
isOpen,
|
||||
regionalBrief,
|
||||
// The renderer's card previews, when it has them.
|
||||
@@ -343,7 +367,12 @@ export function installEntityContext({
|
||||
if (!record?.layerId || inCockpit()) return;
|
||||
store.select({
|
||||
layerId: record.layerId,
|
||||
id: record.id,
|
||||
// A vessel goes by its own id, as a click on it names it, not by the
|
||||
// context store's (src/data/pickedContext.js).
|
||||
id:
|
||||
record.layerId === 'ais-live-vessels' && record.properties?.vesselId
|
||||
? String(record.properties.vesselId)
|
||||
: record.id,
|
||||
label: record.label || record.properties?.name,
|
||||
lat: record.latitude,
|
||||
lon: record.longitude,
|
||||
|
||||
@@ -83,3 +83,60 @@ test('Context names nothing under a card painted on top, and keeps its card', (t
|
||||
tap(null, null);
|
||||
assert.equal(clears, cleared, 'a card over open map is not open map');
|
||||
});
|
||||
|
||||
// A vessel's layer announces its selection with the context store's id; the
|
||||
// card names it by the vessel's own id, as a click on it does.
|
||||
test('a vessel announced by its layer is named by its own id', (t) => {
|
||||
// The page's events, which Node lacks.
|
||||
const events = new EventTarget();
|
||||
for (const name of [
|
||||
'addEventListener',
|
||||
'removeEventListener',
|
||||
'dispatchEvent',
|
||||
])
|
||||
globalThis[name] = events[name].bind(events);
|
||||
t.after(() => {
|
||||
for (const name of [
|
||||
'addEventListener',
|
||||
'removeEventListener',
|
||||
'dispatchEvent',
|
||||
])
|
||||
delete globalThis[name];
|
||||
});
|
||||
const pinia = createPinia();
|
||||
const viewer = { scene: { pick: () => null, drillPick: () => [] } };
|
||||
const input = fakeInput(viewer);
|
||||
const disconnect = installEntityContext({
|
||||
viewer,
|
||||
getDataManager: () => ({
|
||||
isEnabled: () => true,
|
||||
layers: new Map(),
|
||||
getAll: () => [],
|
||||
}),
|
||||
pinia,
|
||||
});
|
||||
t.after(() => {
|
||||
disconnect();
|
||||
input.destroy();
|
||||
});
|
||||
const store = useEntityCardStore(pinia);
|
||||
const named = [];
|
||||
store.select = (identity) => named.push(identity.id);
|
||||
globalThis.dispatchEvent(
|
||||
new CustomEvent('gev:entity-selected', {
|
||||
detail: {
|
||||
layerId: 'ais-live-vessels',
|
||||
id: 'ais-5fdca702',
|
||||
properties: { vesselId: '5fdca702' },
|
||||
latitude: 1,
|
||||
longitude: 2,
|
||||
},
|
||||
}),
|
||||
);
|
||||
globalThis.dispatchEvent(
|
||||
new CustomEvent('gev:entity-selected', {
|
||||
detail: { layerId: 'fires', id: 'fire:1', latitude: 1, longitude: 2 },
|
||||
}),
|
||||
);
|
||||
assert.deepEqual(named, ['5fdca702', 'fire:1']);
|
||||
});
|
||||
@@ -162,7 +162,7 @@ export function initGeoFileImport({
|
||||
? t('Hide {name}', { name: item.name })
|
||||
: t('Show {name}', { name: item.name }),
|
||||
action: 'toggle',
|
||||
pressed: String(item.visible),
|
||||
pressed: Boolean(item.visible),
|
||||
},
|
||||
{
|
||||
icon: 'my_location',
|
||||
|
||||
@@ -220,7 +220,7 @@ test('row buttons hide, show, fly to and remove a file', async () => {
|
||||
shapes: [],
|
||||
});
|
||||
assert.equal(t.tool.list()[0].visible, false);
|
||||
assert.equal(action(rows(t)[0], 'toggle').pressed, 'false');
|
||||
assert.equal(action(rows(t)[0], 'toggle').pressed, false);
|
||||
assert.equal(action(rows(t)[0], 'toggle').icon, 'visibility_off');
|
||||
assert.equal(action(rows(t)[0], 'toggle').label, 'Show a.gpx');
|
||||
glyphClick('fly');
|
||||
|
||||
@@ -769,19 +769,38 @@ test('shared panel hooks affect only opted-in rail surfaces without overriding d
|
||||
);
|
||||
});
|
||||
|
||||
test('narrow Omnibar corners clear the World Timeline over the dock', () => {
|
||||
test('the Omnibar dock sits above the World Timeline, and narrow corners clear the dock', () => {
|
||||
const css = read('./styles/omnibar-dock.css');
|
||||
const timeline = css.match(
|
||||
/#world-timeline \{\s*bottom: calc\(var\(--omnibar-dock-bottom\) \+ (\d+)px\);/,
|
||||
// The bar takes the dock's floor; the dock and the field inside it rise by
|
||||
// the bar's lift (world-timeline.css), as the plain dock does.
|
||||
assert.match(
|
||||
css,
|
||||
/#world-timeline \{\s*bottom: var\(--omnibar-dock-bottom\);/,
|
||||
);
|
||||
assert.match(
|
||||
css,
|
||||
/--omnibar-dock-raised: calc\(\s*var\(--omnibar-dock-bottom\) \+ var\(--world-timeline-lift, 0px\)\s*\);/,
|
||||
);
|
||||
assert.match(
|
||||
css,
|
||||
/#command-dock \{[^}]*bottom: var\(--omnibar-dock-raised\);/,
|
||||
);
|
||||
assert.match(
|
||||
css,
|
||||
/#gev-omnibar \{[^}]*bottom: calc\(var\(--omnibar-dock-raised\) \+ 11px\);/,
|
||||
);
|
||||
assert.doesNotMatch(css, /--world-timeline-lift\s*:/);
|
||||
const lift = read('./styles/world-timeline.css').match(
|
||||
/body:has\(#world-timeline\) \{\s*--world-timeline-lift: (\d+)px;/,
|
||||
);
|
||||
const height = read('./styles/world-timeline.css').match(
|
||||
/#world-timeline \{[^}]*\n {2}height: (\d+)px;/,
|
||||
);
|
||||
assert.ok(lift && height && Number(lift[1]) > Number(height[1]));
|
||||
const corners = css.match(
|
||||
/&:has\(#world-timeline\) \{\s*--omnibar-coordinates-bottom: max\(\s*calc\(var\(--omnibar-dock-bottom\) \+ (\d+)px \+ (\d+)px \+ (\d+)px\)/,
|
||||
/--omnibar-coordinates-bottom: max\(\s*calc\(var\(--omnibar-dock-raised\) \+ (\d+)px \+ (\d+)px\)/,
|
||||
);
|
||||
assert.ok(timeline && height && corners);
|
||||
assert.equal(Number(corners[1]), Number(timeline[1]));
|
||||
assert.equal(Number(corners[2]), Number(height[1]));
|
||||
assert.ok(Number(corners[3]) >= 6);
|
||||
assert.ok(corners);
|
||||
assert.equal(Number(corners[1]), 56);
|
||||
assert.ok(Number(corners[2]) >= 6);
|
||||
});
|
||||
@@ -53,7 +53,7 @@ test('the divider renders on the body with its labels and slider', async (t) =>
|
||||
assert.equal(after.title, 'After');
|
||||
assert.equal(handle.tagName, 'BUTTON');
|
||||
assert.equal(handle.type, 'button');
|
||||
assert.equal(handle.className, 'split-handle');
|
||||
assert.ok(handle.classList.contains('split-handle'));
|
||||
assert.equal(handle.textContent, '↔');
|
||||
assert.equal(handle.getAttribute('role'), 'slider');
|
||||
assert.equal(handle.getAttribute('aria-label'), 'Divider');
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
// The Bhote Koshi event's controls are the kit's: its reconstruction panel
|
||||
// hand-writes no <button> and no Material Symbols span, its buttons are ghost
|
||||
// UiButtons that keep their data-action hooks for bhote-koshi.css and the
|
||||
// tests, and its cinematic button is a pressed toggle whose state the event
|
||||
// layer presents as `pressed`, not as an `aria-pressed` it writes. The
|
||||
// embedded media cards are an SFC rather than markup built in script; they
|
||||
// hold no control (the original link stays a link), and the script builds
|
||||
// only what the provider SDKs need: their script and preconnect tags, the
|
||||
// overlay root, and the Facebook player node it warms and carries into a
|
||||
// card.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
const read = (file) =>
|
||||
readFileSync(new URL(`../../${file}`, import.meta.url), 'utf8');
|
||||
/** The template block: everything outside script, style and comments. */
|
||||
const template = (file) =>
|
||||
read(file)
|
||||
.replace(/<(script|style)\b[\s\S]*?<\/\1\s*>/g, '')
|
||||
.replace(/<!--[\s\S]*?-->/g, '');
|
||||
// An opening tag's attributes, quoted values may hold `>` (`() => x`).
|
||||
const ATTRS = String.raw`(?:[^>"']|"[^"]*"|'[^']*')*`;
|
||||
const tags = (markup, name) =>
|
||||
markup.match(new RegExp(String.raw`<${name}\b${ATTRS}>`, 'g')) ?? [];
|
||||
// An attribute's name, outside the quoted values.
|
||||
const names = (attrs) => attrs.replace(/"[^"]*"|'[^']*'/g, '""');
|
||||
|
||||
const PANEL = 'ui/views/panels/BhoteKoshiPanel.vue';
|
||||
const CARDS = 'ui/bhoteKoshi/BhoteKoshiMediaCards.vue';
|
||||
// Per file: its UiButtons, UiCloseButtons, UiSliders and UiIcons.
|
||||
const SURFACES = {
|
||||
// Previous and next beat, Play, Play scene, Cinematic, Full story, Open
|
||||
// original, Lower gorge, a field report (one tag, one per report) and Open
|
||||
// public map; Close; the split and progress sliders.
|
||||
[PANEL]: [10, 1, 2, 0],
|
||||
// The media cards: a frame, a leader, a footer and the original link.
|
||||
[CARDS]: [0, 0, 0, 0],
|
||||
};
|
||||
|
||||
test('the Bhote Koshi views hand-write no button; each is a kit button', () => {
|
||||
for (const [file, [buttons, closes, sliders]] of Object.entries(SURFACES)) {
|
||||
const markup = template(file);
|
||||
assert.deepEqual(markup.match(/<button\b/gi) ?? [], [], file);
|
||||
assert.deepEqual(markup.match(/<(select|input)\b/gi) ?? [], [], file);
|
||||
assert.equal(tags(markup, 'UiButton').length, buttons, file);
|
||||
assert.equal(tags(markup, 'UiCloseButton').length, closes, file);
|
||||
assert.equal(tags(markup, 'UiSlider').length, sliders, file);
|
||||
}
|
||||
});
|
||||
|
||||
test('the Bhote Koshi views hand-write no Material glyph', () => {
|
||||
for (const [file, [, , , icons]] of Object.entries(SURFACES)) {
|
||||
const markup = template(file);
|
||||
assert.deepEqual(markup.match(/material-symbols/g) ?? [], [], file);
|
||||
const found = tags(markup, 'UiIcon');
|
||||
assert.equal(found.length, icons, file);
|
||||
for (const icon of found) assert.match(icon, /\s:size="null"/, file);
|
||||
}
|
||||
});
|
||||
|
||||
test('the cinematic button takes the kit pressed state', () => {
|
||||
for (const file of Object.keys(SURFACES))
|
||||
for (const [tag, attrs] of template(file).matchAll(
|
||||
new RegExp(String.raw`<[A-Za-z][\w-]*\b(${ATTRS})>`, 'g'),
|
||||
)) {
|
||||
assert.doesNotMatch(
|
||||
names(attrs),
|
||||
/(?:^|\s)(?::|v-bind:)?aria-pressed(?=[\s=/]|$)/,
|
||||
tag,
|
||||
);
|
||||
assert.doesNotMatch(
|
||||
attrs,
|
||||
/(?:^|\s)(?:v-bind|:)=(?:"[^"]*aria-?pressed[^"]*"|'[^']*aria-?pressed[^']*')/i,
|
||||
tag,
|
||||
);
|
||||
}
|
||||
const pressed = tags(template(PANEL), 'UiButton').filter((tag) =>
|
||||
/\s:pressed=/.test(tag),
|
||||
);
|
||||
assert.equal(pressed.length, 1);
|
||||
assert.match(
|
||||
pressed[0],
|
||||
/^<UiButton data-action="cinematic" :pressed="Boolean\(panel\.refs\.cinematicButton\.pressed\)"/,
|
||||
);
|
||||
// bhote-koshi.css styles the pressed button by its aria-pressed.
|
||||
assert.doesNotMatch(pressed[0], /pressed-class/);
|
||||
// The layer presents the state; it writes no aria-pressed of its own.
|
||||
const layer = read('data/bhoteKoshiEvent.js');
|
||||
assert.doesNotMatch(layer, /aria-pressed/);
|
||||
assert.match(
|
||||
layer,
|
||||
/setElementProperty\(button, 'pressed', _cinematicActive\)/,
|
||||
);
|
||||
});
|
||||
|
||||
test('the media cards are drawn by their view, not built in script', () => {
|
||||
const source = read('data/bhoteKoshiEmbeddedMedia.js');
|
||||
assert.doesNotMatch(source, /innerHTML|insertAdjacentHTML|createElementNS/);
|
||||
// Provider scripts and preconnects, the overlay root, and the Facebook
|
||||
// embed node and its warm host. The YouTube API's script is youtubeApi.js's.
|
||||
assert.deepEqual(
|
||||
[...source.matchAll(/createElement\('(\w+)'\)/g)].map((m) => m[1]),
|
||||
['script', 'script', 'link', 'div', 'div', 'div'],
|
||||
);
|
||||
assert.match(source, /renderVue\(\s*h\(BhoteKoshiMediaCards,/);
|
||||
const cards = template(CARDS);
|
||||
const opening = (name, attribute) =>
|
||||
new RegExp(String.raw`<${name}\b${ATTRS}\s${attribute}${ATTRS}>`);
|
||||
for (const part of [
|
||||
opening('iframe', 'class="bhote-embedded-media-warmup"'),
|
||||
opening('section', 'class="bhote-embedded-callout"'),
|
||||
opening('svg', 'class="bhote-embedded-callout-leader"'),
|
||||
opening('div', 'class="bhote-embedded-callout-body" data-overlay-input'),
|
||||
opening('small', 'role="status"'),
|
||||
opening('a', 'target="_blank" rel="noopener noreferrer"'),
|
||||
])
|
||||
assert.match(cards, part);
|
||||
});
|
||||
@@ -0,0 +1,150 @@
|
||||
// The AI chat panel's and the voice control's buttons and Material glyphs
|
||||
// are the kit's: neither their templates nor the voice card and panel
|
||||
// layout buttons they render hand-write a <button> or a Material Symbols
|
||||
// span. Their other glyphs (the chat bubble, the globe, attach, send and
|
||||
// stop, expand and the two Back chevrons) are inline SVG drawn with their own
|
||||
// strokes, which no Material symbol the page loads draws the same, so they
|
||||
// stay SVG. The voice panel's Preview and Settings are tabs (`role="tab"`
|
||||
// with `aria-selected`), not pressed toggles, and DISMISS is a text button,
|
||||
// not a cross, so it is a UiButton rather than a UiCloseButton. The chat's
|
||||
// message box, file picker and the minutes field stay native: the kit has
|
||||
// no text area, file or number field. The voice modules build no controls
|
||||
// in script.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync, readdirSync } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
/** A view's template block: everything outside script, style and comments. */
|
||||
function template(file) {
|
||||
const source = readFileSync(
|
||||
new URL(`../views/panels/${file}`, import.meta.url),
|
||||
'utf8',
|
||||
);
|
||||
return source
|
||||
.replace(/<(script|style)\b[\s\S]*?<\/\1\s*>/g, '')
|
||||
.replace(/<!--[\s\S]*?-->/g, '');
|
||||
}
|
||||
// A tag's attributes, read past quoted values so a handler's `=>` does not
|
||||
// end the tag early.
|
||||
const ATTRS = String.raw`(?:[^>"']|"[^"]*"|'[^']*')*`;
|
||||
const tag = (pattern, flags = '') =>
|
||||
new RegExp(pattern.replaceAll('ATTRS', ATTRS), flags);
|
||||
const tags = (markup, name) =>
|
||||
markup.match(tag(String.raw`<${name}\bATTRS>`, 'g')) ?? [];
|
||||
|
||||
const views = {
|
||||
// Settings, the quick prompts, an attachment's remove, Attach layer,
|
||||
// Attach a file, Expand conversation, the command suggestions, Expand
|
||||
// chat, Add attachment and Send / Stop reply.
|
||||
'ChatPanel.vue': {
|
||||
UiButton: 10,
|
||||
UiCloseButton: 1,
|
||||
UiIcon: 1,
|
||||
UiSelect: 1,
|
||||
svgs: 5,
|
||||
},
|
||||
// The tier button (dock and panel), the mic, Open AI chat, Back to chat,
|
||||
// Back to voice, the Preview and Settings tabs and DISMISS.
|
||||
'VoiceControl.vue': {
|
||||
UiButton: 9,
|
||||
UiCloseButton: 1,
|
||||
UiIcon: 2,
|
||||
UiSelect: 3,
|
||||
UiCheckbox: 2,
|
||||
svgs: 3,
|
||||
},
|
||||
'VoiceCard.vue': { UiButton: 0, UiCloseButton: 1, UiIcon: 0, svgs: 0 },
|
||||
// Dock and minimize.
|
||||
'PanelLayoutButtons.vue': { UiButton: 2, UiIcon: 0, svgs: 2 },
|
||||
'VoiceVisualizer.vue': { UiButton: 0, UiIcon: 0, svgs: 1 },
|
||||
};
|
||||
const markup = Object.fromEntries(
|
||||
Object.keys(views).map((file) => [file, template(file)]),
|
||||
);
|
||||
|
||||
test('the chat and voice views hand-write no button; each is the kit', () => {
|
||||
for (const [file, counts] of Object.entries(views)) {
|
||||
assert.deepEqual(markup[file].match(/<button\b/gi) ?? [], [], file);
|
||||
for (const name of ['UiButton', 'UiCloseButton', 'UiSelect', 'UiCheckbox'])
|
||||
assert.equal(tags(markup[file], name).length, counts[name] ?? 0, file);
|
||||
}
|
||||
});
|
||||
|
||||
test('the pressed toggles take the kit pressed state', () => {
|
||||
for (const [file, view] of Object.entries(markup))
|
||||
assert.doesNotMatch(view, /aria-pressed/, file);
|
||||
const voice = tags(markup['VoiceControl.vue'], 'UiButton');
|
||||
const tiers = voice.filter((button) => /id="gev-voice-tier"/.test(button));
|
||||
assert.equal(tiers.length, 2);
|
||||
for (const tier of tiers)
|
||||
assert.match(tier, /\s:pressed="Boolean\(view\.tier\.pressed\)"/);
|
||||
// The mic writes no aria-pressed while its owner has no state for it.
|
||||
assert.match(
|
||||
markup['VoiceControl.vue'],
|
||||
tag(
|
||||
String.raw`<UiButton\s+id="gev-voice-button"ATTRS\s:pressed="view\.button\.pressed \?\? undefined"`,
|
||||
),
|
||||
);
|
||||
assert.match(
|
||||
markup['PanelLayoutButtons.vue'],
|
||||
tag(
|
||||
String.raw`<UiButton\s+data-layout-dockATTRS\s:pressed="props\.docked"`,
|
||||
),
|
||||
);
|
||||
// The panel tabs are tabs: selected, never pressed.
|
||||
const tabs = voice.filter((button) => /role="tab"/.test(button));
|
||||
assert.equal(tabs.length, 2);
|
||||
for (const button of tabs) {
|
||||
assert.match(button, /\s:aria-selected="/);
|
||||
assert.doesNotMatch(button, /\s:pressed=/);
|
||||
}
|
||||
});
|
||||
|
||||
test('the views hand-write no Material glyph; each is a UiIcon the site sizes', () => {
|
||||
for (const [file, { UiIcon, svgs }] of Object.entries(views)) {
|
||||
assert.deepEqual(markup[file].match(/material-symbols/g) ?? [], [], file);
|
||||
const icons = tags(markup[file], 'UiIcon');
|
||||
assert.equal(icons.length, UiIcon, file);
|
||||
// Without it the kit writes an 18px size that beats voice-cost.css and
|
||||
// voice-card.css.
|
||||
for (const icon of icons) assert.match(icon, /\s:size="null"/, file);
|
||||
assert.equal(markup[file].match(/<svg\b/g)?.length ?? 0, svgs, file);
|
||||
}
|
||||
assert.match(
|
||||
markup['ChatPanel.vue'],
|
||||
/<UiIcon name="settings" class="gev-voice-settings-icon" :size="null" \/>/,
|
||||
);
|
||||
assert.equal(
|
||||
markup['VoiceControl.vue'].match(
|
||||
/<UiIcon name="(?:visibility|settings)" class="gev-voice-panel-tab-icon" :size="null" \/>/g,
|
||||
)?.length,
|
||||
2,
|
||||
);
|
||||
});
|
||||
|
||||
test('the only native fields left are the message box, file picker and minutes', () => {
|
||||
const inputs = Object.values(markup).flatMap((view) => tags(view, 'input'));
|
||||
assert.equal(inputs.length, 2);
|
||||
assert.match(inputs[0], /id="gev-chat-file" type="file"/);
|
||||
assert.match(inputs[1], /id="gev-voice-timeout-input" type="number"/);
|
||||
assert.equal(tags(markup['ChatPanel.vue'], 'textarea').length, 1);
|
||||
for (const view of Object.values(markup)) {
|
||||
assert.deepEqual(view.match(/<select\b/gi) ?? [], []);
|
||||
assert.doesNotMatch(view, /type="(?:checkbox|range)"/);
|
||||
}
|
||||
});
|
||||
|
||||
test('the voice modules build no buttons or Material glyphs in script', () => {
|
||||
const root = fileURLToPath(new URL('../../voice/', import.meta.url));
|
||||
const modules = readdirSync(root, { recursive: true })
|
||||
.filter((file) => file.endsWith('.js') && !/test|Harness/.test(file))
|
||||
.map((file) => path.join(root, file));
|
||||
assert.ok(modules.length > 50);
|
||||
for (const file of modules) {
|
||||
const source = readFileSync(file, 'utf8');
|
||||
assert.doesNotMatch(source, /createElement\(\s*['"]button/, file);
|
||||
assert.doesNotMatch(source, /<button\b|material-symbols/, file);
|
||||
}
|
||||
});
|
||||
@@ -1,6 +1,7 @@
|
||||
// Every close, dismiss and clear button in a Vue view is a UiCloseButton: no
|
||||
// SFC template hand-writes a button whose only content is × or the Material
|
||||
// `close` symbol. Buttons built in script are not read here.
|
||||
// SFC template hand-writes a button whose only content is × (bare or in a
|
||||
// span) or the Material `close` symbol. Buttons built in script are not read
|
||||
// here.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync, readdirSync } from 'node:fs';
|
||||
@@ -30,8 +31,10 @@ function template(source) {
|
||||
// An opening tag's attributes, quoted values may hold `>` (`() => x`).
|
||||
const ATTRS = String.raw`(?:[^>"']|"[^"]*"|'[^']*')*`;
|
||||
const BUTTON = String.raw`(button|UiButton)`;
|
||||
const TIMES = String.raw`×|×|×|×`;
|
||||
const CLOSE_GLYPH = [
|
||||
String.raw`×|×|×|×`,
|
||||
TIMES,
|
||||
String.raw`<span\b${ATTRS}>\s*(?:${TIMES})\s*</span\s*>`,
|
||||
String.raw`<span\b[^>]*\bmaterial-symbols-outlined\b[^>]*>\s*close\s*</span\s*>`,
|
||||
String.raw`<UiIcon${ATTRS}\bname="close"${ATTRS}/>`,
|
||||
].join('|');
|
||||
@@ -54,11 +57,14 @@ test('the scan finds each hand-written close glyph', () => {
|
||||
'<template><UiButton class="x" :label="l">×</UiButton></template>',
|
||||
'<template><button type="button" class="x">\n <span class="material-symbols-outlined" aria-hidden="true">close</span>\n</button></template>',
|
||||
'<template><UiButton class="x"><UiIcon name="close" :size="14" /></UiButton></template>',
|
||||
'<template><button type="button" :aria-label="l"><span aria-hidden="true">×</span></button></template>',
|
||||
'<template><UiButton class="x">\n <span class="glyph">×</span>\n</UiButton></template>',
|
||||
])
|
||||
assert.equal(handWrittenCloses(markup).length, 1, markup);
|
||||
for (const markup of [
|
||||
'<template><UiCloseButton class="x" :label="l" /></template>',
|
||||
'<template><button type="button">{{ name }} ×</button></template>',
|
||||
'<template><button type="button"><span>{{ name }}</span> ×</button></template>',
|
||||
'<template><button type="button">On<span class="material-symbols-outlined">close</span></button></template>',
|
||||
'<template><button type="button"><span class="material-symbols-outlined">close_fullscreen</span></button></template>',
|
||||
])
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
// The Cockpit HUD's controls and glyphs are the kit's: no Cockpit view
|
||||
// hand-writes a <button>, a Material Symbols span, a select, a checkbox or a
|
||||
// range. Its buttons are ghost UiButtons that keep their ids, classes and
|
||||
// labels for the Cockpit controller's listeners and the cockpit stylesheets;
|
||||
// its glyphs are UiIcons with `:size="null"`, so those stylesheets still size
|
||||
// them. The utility strip's −, ◀ ▶ and transport glyphs and the orbital
|
||||
// zoom's − and + are text characters, not Material symbols, and stay text.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readdirSync, readFileSync } from 'node:fs';
|
||||
|
||||
/** A view's template block: everything outside script, style and comments. */
|
||||
function template(file) {
|
||||
const source = readFileSync(
|
||||
new URL(`../views/${file}`, import.meta.url),
|
||||
'utf8',
|
||||
);
|
||||
return source
|
||||
.replace(/<(script|style)\b[\s\S]*?<\/\1\s*>/g, '')
|
||||
.replace(/<!--[\s\S]*?-->/g, '');
|
||||
}
|
||||
const views = {
|
||||
// The vision selector's Previous, Current and Next, Look ahead, and the
|
||||
// view switcher's Reset and Exit; the speed and altitude rims' pointers,
|
||||
// the two vision chevrons, the reticle, the heading caret and the view
|
||||
// switcher's two glyphs.
|
||||
'CockpitView.vue': { buttons: 6, icons: 8 },
|
||||
// Display's and Radio's collapse and launcher buttons, Radio's Enable,
|
||||
// Previous, Play and Next, and the desktop rail's two items and glyphs.
|
||||
'panels/CockpitUtilityControls.vue': { buttons: 10, icons: 2 },
|
||||
// Previous, Next, Auto, the card's collapse and the four page tabs (LIVE
|
||||
// shows only with a stream); the first, second and fourth draw a glyph.
|
||||
'panels/CockpitBriefing.vue': { buttons: 8, icons: 3 },
|
||||
// Previous, Next, the card's collapse and Weather; three of them draw a
|
||||
// glyph, and the nearest contact's arrow is the fourth.
|
||||
'panels/CockpitContext.vue': { buttons: 4, icons: 4 },
|
||||
// A signal row's target and its chevron.
|
||||
'panels/CockpitSignalList.vue': { buttons: 1, icons: 1 },
|
||||
// TLE, Nadir, Zoom out, Zoom in and Sensor, and a station's Previous and
|
||||
// Next view, which draw the two glyphs.
|
||||
'panels/CockpitOrbital.vue': { buttons: 7, icons: 2 },
|
||||
// The LIVE page's Previous, Next, Play and Try again; the first three draw
|
||||
// a glyph.
|
||||
'panels/CockpitLivePage.vue': { buttons: 4, icons: 3 },
|
||||
// The range step.
|
||||
'panels/CockpitRadar.vue': { buttons: 1, icons: 0 },
|
||||
// The flight plan's arrow.
|
||||
'panels/CockpitRoute.vue': { buttons: 0, icons: 1 },
|
||||
// Readouts only.
|
||||
'panels/CockpitProgress.vue': { buttons: 0, icons: 0 },
|
||||
'panels/CockpitRollingValue.vue': { buttons: 0, icons: 0 },
|
||||
};
|
||||
// A tag's attributes, read past quoted values so a handler's `=>` does not
|
||||
// end the tag early.
|
||||
const ATTRS = String.raw`(?:[^>"']|"[^"]*"|'[^']*')*`;
|
||||
const tag = (pattern, flags = '') =>
|
||||
new RegExp(pattern.replaceAll('ATTRS', ATTRS), flags);
|
||||
const markup = Object.fromEntries(
|
||||
Object.keys(views).map((file) => [file, template(file)]),
|
||||
);
|
||||
|
||||
test('every Cockpit view is in the list above', () => {
|
||||
const dir = (sub) =>
|
||||
readdirSync(new URL(`../views/${sub}`, import.meta.url))
|
||||
.filter((name) => /^Cockpit.*\.vue$/.test(name))
|
||||
.map((name) => sub + name);
|
||||
assert.deepEqual(
|
||||
[...dir(''), ...dir('panels/')].sort(),
|
||||
Object.keys(views).sort(),
|
||||
);
|
||||
});
|
||||
|
||||
test('the Cockpit views hand-write no button; each is a UiButton', () => {
|
||||
for (const [file, { buttons }] of Object.entries(views)) {
|
||||
assert.deepEqual(markup[file].match(/<button\b/gi) ?? [], [], file);
|
||||
assert.equal(
|
||||
markup[file].match(/<UiButton\b/g)?.length ?? 0,
|
||||
buttons,
|
||||
file,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('the Cockpit views hand-write no select, checkbox or range', () => {
|
||||
for (const [file, view] of Object.entries(markup)) {
|
||||
assert.deepEqual(view.match(/<(select|input)\b/gi) ?? [], [], file);
|
||||
}
|
||||
// The compact Radio volume.
|
||||
assert.equal(
|
||||
markup['panels/CockpitUtilityControls.vue'].match(/<UiSlider\b/g)?.length,
|
||||
1,
|
||||
);
|
||||
});
|
||||
|
||||
test('the pressed toggles take the kit pressed state', () => {
|
||||
for (const view of Object.values(markup))
|
||||
assert.doesNotMatch(view, tag(String.raw`<\w+\bATTRS\s:?aria-pressed`));
|
||||
const pressed = Object.values(markup).flatMap(
|
||||
(view) =>
|
||||
view.match(tag(String.raw`<UiButton\bATTRS\s:pressed=ATTRS>`, 'g')) ?? [],
|
||||
);
|
||||
// Radio's Enable, the briefing's Auto and the Contact card's Weather.
|
||||
assert.equal(pressed.length, 3);
|
||||
for (const button of pressed) assert.match(button, /:pressed="Boolean\(/);
|
||||
assert.match(
|
||||
markup['panels/CockpitUtilityControls.vue'],
|
||||
tag(
|
||||
String.raw`<UiButton\s+id="cockpit-radio-enable-btn"ATTRS\s:pressed="Boolean\(cockpit\?\.enable\.active\)" pressed-class="active"`,
|
||||
),
|
||||
);
|
||||
assert.match(
|
||||
markup['panels/CockpitBriefing.vue'],
|
||||
tag(
|
||||
String.raw`<UiButton\s+id="cockpit-brief-auto"ATTRS\s:pressed="Boolean\(b\.autoRotate\)"`,
|
||||
),
|
||||
);
|
||||
assert.match(
|
||||
markup['panels/CockpitContext.vue'],
|
||||
tag(
|
||||
String.raw`<UiButton\s+id="cockpit-weather-toggle"ATTRS\s:pressed="Boolean\(c\.weather\)"`,
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
test('the Cockpit views hand-write no Material glyph; each is a UiIcon', () => {
|
||||
for (const [file, { icons }] of Object.entries(views)) {
|
||||
assert.deepEqual(
|
||||
markup[file].match(/material-symbols-outlined/g) ?? [],
|
||||
[],
|
||||
file,
|
||||
);
|
||||
const found =
|
||||
markup[file].match(tag(String.raw`<UiIcon\bATTRS>`, 'g')) ?? [];
|
||||
assert.equal(found.length, icons, file);
|
||||
// Without it the kit writes an 18px size that beats the cockpit's rules.
|
||||
for (const icon of found) assert.match(icon, /\s:size="null"/, file);
|
||||
}
|
||||
});
|
||||
|
||||
test('the heading caret outranks the kit icon rule that loads after it', () => {
|
||||
const css = readFileSync(
|
||||
new URL('../styles/cockpit.css', import.meta.url),
|
||||
'utf8',
|
||||
);
|
||||
// kit.css's `.ui-icon` sets display and line-height with one class and
|
||||
// loads after cockpit.css, so a one-class caret rule would lose to it.
|
||||
assert.match(
|
||||
css,
|
||||
/\n\.cockpit-compass \.cockpit-heading-caret \{\n {2}display: block;/,
|
||||
);
|
||||
assert.doesNotMatch(css, /\n\.cockpit-heading-caret \{/);
|
||||
});
|
||||
@@ -0,0 +1,127 @@
|
||||
// The command dock's and the Context panel's buttons and Material glyphs are
|
||||
// the kit's: neither the dock, the Context view nor the view context it
|
||||
// shows while nothing is picked hand-writes a <button> or a Material Symbols
|
||||
// span. The dock's style buttons are pressed toggles with `active`, its
|
||||
// glyphs (◯ ▦ 🌙 🌡️ ✦ ◐, the search 🔎 and the collapse +) are text
|
||||
// characters, not Material symbols, and stay plain text. Context's tabs and
|
||||
// its Contacts mode button are `role="tab"` controls: they say they are
|
||||
// chosen with `aria-selected` and keep their own `active` class, never
|
||||
// `aria-pressed`.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
/** A view's template block: everything outside script, style and comments. */
|
||||
function template(file) {
|
||||
const source = readFileSync(
|
||||
new URL(`../views/${file}`, import.meta.url),
|
||||
'utf8',
|
||||
);
|
||||
return source
|
||||
.replace(/<(script|style)\b[\s\S]*?<\/\1\s*>/g, '')
|
||||
.replace(/<!--[\s\S]*?-->/g, '');
|
||||
}
|
||||
// A tag's attributes, read past quoted values so a handler's `=>` does not
|
||||
// end the tag early.
|
||||
const ATTRS = String.raw`(?:[^>"']|"[^"]*"|'[^']*')*`;
|
||||
const tag = (pattern, flags = '') =>
|
||||
new RegExp(pattern.replaceAll('ATTRS', ATTRS), flags);
|
||||
const tags = (markup, name) =>
|
||||
markup.match(tag(String.raw`<${name}\bATTRS>`, 'g')) ?? [];
|
||||
|
||||
const dock = template('CommandDockView.vue');
|
||||
const context = template('ContextView.vue');
|
||||
const inView = template('panels/ViewContext.vue');
|
||||
const views = {
|
||||
// The six style buttons, the two tray toggles and their pins, the map
|
||||
// source chips, Location's collapse, its landmark and city pills and the
|
||||
// search toggle.
|
||||
'CommandDockView.vue': { markup: dock, buttons: 15, icons: 0, closes: 0 },
|
||||
// Search and Expand in the header, the two tabs, Contacts, the cockpit
|
||||
// entry, SEARCH NEARBY SITES and the TR-3B chip.
|
||||
'ContextView.vue': { markup: context, buttons: 8, icons: 7, closes: 0 },
|
||||
// An off layer's worldwide tile, an item's row, the place and layer chips
|
||||
// and Ask GEV; a layer's Turn off is a UiCloseButton. The glyphs: the
|
||||
// header's eye, a worldwide tile's (on and off), a layer group's, an
|
||||
// item's motion and the layer chips' add.
|
||||
'panels/ViewContext.vue': { markup: inView, buttons: 5, icons: 6, closes: 1 },
|
||||
};
|
||||
|
||||
test('the dock and Context hand-write no button; each is a UiButton', () => {
|
||||
for (const [file, { markup, buttons, closes }] of Object.entries(views)) {
|
||||
assert.deepEqual(markup.match(/<button\b/gi) ?? [], [], file);
|
||||
assert.deepEqual(markup.match(/<component\b/gi) ?? [], [], file);
|
||||
assert.equal(tags(markup, 'UiButton').length, buttons, file);
|
||||
assert.equal(tags(markup, 'UiCloseButton').length, closes, file);
|
||||
}
|
||||
});
|
||||
|
||||
test('the style buttons are pressed toggles with active', () => {
|
||||
assert.doesNotMatch(dock, /v-class-toggle="\{[^"]*\bactive\b/);
|
||||
const styles = tags(dock, 'UiButton').filter((b) =>
|
||||
/class="style-btn"/.test(b),
|
||||
);
|
||||
assert.deepEqual(
|
||||
styles.map((b) => b.match(/data-style="(\w+)"/)[1]),
|
||||
['normal', 'retro', 'surveillance', 'thermal', 'anime', 'noir'],
|
||||
);
|
||||
for (const button of styles) {
|
||||
const name = button.match(/data-style="(\w+)"/)[1];
|
||||
assert.match(button, /\spressed-class="active"/, name);
|
||||
// Normal stays the pressed one until a style is published.
|
||||
assert.match(
|
||||
button,
|
||||
name === 'normal'
|
||||
? /\s:pressed="!style \|\| style\.name === 'normal'"/
|
||||
: new RegExp(String.raw`\s:pressed="style\?\.name === '${name}'"`),
|
||||
name,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('no tag hand-writes aria-pressed; the pressed toggles take :pressed', () => {
|
||||
for (const [file, { markup }] of Object.entries(views))
|
||||
assert.doesNotMatch(
|
||||
markup,
|
||||
tag(String.raw`<\w+\bATTRS\s:?aria-pressed`),
|
||||
file,
|
||||
);
|
||||
const pressed = (markup) =>
|
||||
tags(markup, 'UiButton').filter((b) => /\s:pressed=/.test(b)).length;
|
||||
// The six styles, two pins, map sources, landmarks and cities.
|
||||
assert.equal(pressed(dock), 11);
|
||||
// Search, Expand and TR-3B.
|
||||
assert.equal(pressed(context), 3);
|
||||
assert.equal(pressed(inView), 0);
|
||||
});
|
||||
|
||||
test("Context's tabs say they are chosen, not pressed", () => {
|
||||
const tabs = tags(context, 'UiButton').filter((b) => /\srole="tab"/.test(b));
|
||||
assert.equal(tabs.length, 3);
|
||||
for (const button of tabs) {
|
||||
assert.match(button, /\s:aria-selected=/);
|
||||
assert.doesNotMatch(button, /\s:pressed=/);
|
||||
assert.match(button, /\s(?::class|v-class-toggle)="\{ active: /);
|
||||
}
|
||||
});
|
||||
|
||||
test('they hand-write no Material glyph; each is a UiIcon', () => {
|
||||
for (const [file, { markup, icons }] of Object.entries(views)) {
|
||||
assert.deepEqual(
|
||||
markup.match(/material-symbols-outlined/g) ?? [],
|
||||
[],
|
||||
file,
|
||||
);
|
||||
const found = tags(markup, 'UiIcon');
|
||||
assert.equal(found.length, icons, file);
|
||||
// Without it the kit writes an 18px size that beats the site rules.
|
||||
for (const icon of found) assert.match(icon, /\s:size="null"/, file);
|
||||
}
|
||||
// An item's motion glyph is an image with its own name, not decoration.
|
||||
const [motion] = tags(inView, 'UiIcon').filter((i) =>
|
||||
/view-context__row-motion/.test(i),
|
||||
);
|
||||
assert.match(motion, /\srole="img"/);
|
||||
assert.match(motion, /\s:aria-label=/);
|
||||
assert.match(motion, /\s:aria-hidden="null"/);
|
||||
});
|
||||
@@ -1,7 +1,8 @@
|
||||
// Every modal dialog in a Vue view is a UiDialog: no SFC template hand-writes
|
||||
// `<dialog>`. Panels drawn as `role="dialog"` (key setup, the welcome
|
||||
// launcher, the CCTV popup, Story Explore's filter) and the render failure's
|
||||
// `alertdialog` are other controls.
|
||||
// launcher, the CCTV popup, Story Explore's filter, the credits, the Omnibar
|
||||
// guide's callout) and the render failure's `alertdialog` are other
|
||||
// controls.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync, readdirSync } from 'node:fs';
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
// UTILITIES ▸ Draw (its toggle, Clear, the colour swatches and the drawn
|
||||
// shapes' rows), Import and the Street Level panel are on the kit: none of
|
||||
// them hand-writes a <button>, a Material Symbols span, a select, a checkbox
|
||||
// or a range. The Draw toggle is a pressed toggle with `active`. The colour
|
||||
// swatches are `role="radio"` buttons: they say they are chosen with
|
||||
// `aria-checked` and their own `active` class, never `aria-pressed`. A drawn
|
||||
// shape's show/hide renames itself (Show …, Hide …) rather than being pressed.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
const source = (file) =>
|
||||
readFileSync(new URL(`../views/panels/${file}`, import.meta.url), 'utf8');
|
||||
/** A view's template block: everything outside script, style and comments. */
|
||||
const template = (file) =>
|
||||
source(file)
|
||||
.replace(/<(script|style)\b[\s\S]*?<\/\1\s*>/g, '')
|
||||
.replace(/<!--[\s\S]*?-->/g, '');
|
||||
// A tag's attributes, read past quoted values so a handler's `=>` does not
|
||||
// end the tag early.
|
||||
const ATTRS = String.raw`(?:[^>"']|"[^"]*"|'[^']*')*`;
|
||||
const tag = (pattern, flags = '') =>
|
||||
new RegExp(pattern.replaceAll('ATTRS', ATTRS), flags);
|
||||
const tags = (markup, name) =>
|
||||
markup.match(tag(String.raw`<${name}\bATTRS>`, 'g')) ?? [];
|
||||
|
||||
const views = {
|
||||
// Draw and Clear.
|
||||
'DrawControls.vue': { buttons: 2, icons: 1, closes: 0 },
|
||||
// The five colours, one v-for.
|
||||
'DrawSwatches.vue': { buttons: 1, icons: 0, closes: 0 },
|
||||
// A row's swatch, show/hide, the application's actions and fly to; remove
|
||||
// is a UiCloseButton.
|
||||
'DrawMarkList.vue': { buttons: 4, icons: 3, closes: 1 },
|
||||
// Import and a file's row actions.
|
||||
'GeoImport.vue': { buttons: 2, icons: 2, closes: 0 },
|
||||
// The status toggle, EXPAND and the nearest-imagery button; the viewer's
|
||||
// close. EXPAND's ⤢ ⤡ and the errors' ⚠ are text, not Material symbols.
|
||||
'StreetLevelPanel.vue': { buttons: 3, icons: 0, closes: 1 },
|
||||
};
|
||||
const markup = Object.fromEntries(
|
||||
Object.keys(views).map((file) => [file, template(file)]),
|
||||
);
|
||||
|
||||
test('the Draw, Import and Street Level views hand-write no button', () => {
|
||||
for (const [file, { buttons, closes }] of Object.entries(views)) {
|
||||
const html = markup[file];
|
||||
assert.deepEqual(html.match(/<button\b/gi) ?? [], [], file);
|
||||
assert.deepEqual(html.match(/<component\b/gi) ?? [], [], file);
|
||||
assert.equal(tags(html, 'UiButton').length, buttons, file);
|
||||
assert.equal(tags(html, 'UiCloseButton').length, closes, file);
|
||||
}
|
||||
});
|
||||
|
||||
test('they hand-write no select, checkbox or range', () => {
|
||||
for (const [file, html] of Object.entries(markup)) {
|
||||
assert.deepEqual(html.match(/<select\b/gi) ?? [], [], file);
|
||||
assert.doesNotMatch(
|
||||
html,
|
||||
tag(String.raw`<input\bATTRS\stype="(?:checkbox|range)"`),
|
||||
file,
|
||||
);
|
||||
}
|
||||
// SINCE is the kit's range.
|
||||
assert.equal(tags(markup['StreetLevelPanel.vue'], 'UiSlider').length, 1);
|
||||
});
|
||||
|
||||
test('they hand-write no Material glyph; each is a UiIcon sized by the site', () => {
|
||||
for (const [file, { icons }] of Object.entries(views)) {
|
||||
const html = markup[file];
|
||||
assert.deepEqual(html.match(/material-symbols-outlined/g) ?? [], [], file);
|
||||
const found = tags(html, 'UiIcon');
|
||||
assert.equal(found.length, icons, file);
|
||||
// Without it the kit writes an 18px size that beats the site rules.
|
||||
for (const icon of found) assert.match(icon, /\s:size="null"/, file);
|
||||
}
|
||||
// Draw's and Import's glyphs keep pp-icon, which sizes them.
|
||||
for (const file of ['DrawControls.vue', 'GeoImport.vue']) {
|
||||
const [icon] = tags(markup[file], 'UiIcon');
|
||||
assert.match(icon, /\sclass="pp-icon"/, file);
|
||||
}
|
||||
});
|
||||
|
||||
test('no tag hand-writes aria-pressed; Draw is a pressed toggle with active', () => {
|
||||
for (const [file, html] of Object.entries(markup))
|
||||
assert.doesNotMatch(
|
||||
html,
|
||||
tag(String.raw`<\w+\bATTRS\s:?aria-pressed`),
|
||||
file,
|
||||
);
|
||||
const [draw] = tags(markup['DrawControls.vue'], 'UiButton').filter((b) =>
|
||||
/\sid="draw-toggle"/.test(b),
|
||||
);
|
||||
assert.match(draw, /\s:pressed="draw\?\.active \?\? false"/);
|
||||
assert.match(draw, /\spressed-class="active"/);
|
||||
const [clear] = tags(markup['DrawControls.vue'], 'UiButton').filter((b) =>
|
||||
/\sid="draw-clear"/.test(b),
|
||||
);
|
||||
assert.doesNotMatch(clear, /\s:pressed=/);
|
||||
// A shape's show/hide says what it does in its name, not by being pressed.
|
||||
for (const button of tags(markup['DrawMarkList.vue'], 'UiButton'))
|
||||
assert.doesNotMatch(button, /\s:pressed=/);
|
||||
});
|
||||
|
||||
test('the colour swatches are radios chosen by aria-checked, never pressed', () => {
|
||||
const [swatch] = tags(markup['DrawSwatches.vue'], 'UiButton');
|
||||
assert.match(swatch, /\srole="radio"/);
|
||||
assert.match(
|
||||
swatch,
|
||||
/\s:aria-checked="String\(color === props\.modelValue\)"/,
|
||||
);
|
||||
assert.match(swatch, /\s:class="\{ active: color === props\.modelValue \}"/);
|
||||
assert.doesNotMatch(swatch, /\s:pressed=|\spressed-class=/);
|
||||
});
|
||||
|
||||
test('code that focuses a converted button reaches its element', () => {
|
||||
// A template ref on a component holds the component, not the button.
|
||||
assert.match(
|
||||
source('DrawSwatches.vue'),
|
||||
/:ref="\(swatch\) => \(buttons\[index\] = swatch\?\.\$el\)"/,
|
||||
);
|
||||
assert.match(
|
||||
source('GeoImport.vue'),
|
||||
/importButton\.value\?\.\$el\.focus\(\)/,
|
||||
);
|
||||
});
|
||||
@@ -31,9 +31,9 @@ const heroViews = [
|
||||
test('the entity card hand-writes no button; each is a UiButton', () => {
|
||||
for (const markup of [card, camera, nearby, ...heroViews])
|
||||
assert.deepEqual(markup.match(/<button\b/gi) ?? [], []);
|
||||
// Photos, Route, 3D, Cockpit view, the cockpit entry, Fly to, Follow and
|
||||
// Ask GEV.
|
||||
assert.equal(card.match(/<UiButton\b/g)?.length, 8);
|
||||
// Photos, Route, 3D, Cockpit view, Find it, the cockpit entry, Fly to,
|
||||
// Follow and Ask GEV.
|
||||
assert.equal(card.match(/<UiButton\b/g)?.length, 9);
|
||||
assert.equal(card.match(/<UiCloseButton\b/g)?.length, 1);
|
||||
// A camera's bigger view and More info; its popup closes with a UiCloseButton.
|
||||
assert.equal(camera.match(/<UiButton\b/g)?.length, 2);
|
||||
@@ -59,9 +59,10 @@ test('the entity card hand-writes no Material glyph; each is a UiIcon', () => {
|
||||
for (const markup of [card, camera, nearby, ...heroViews])
|
||||
assert.deepEqual(markup.match(/material-symbols-outlined/g) ?? [], []);
|
||||
const counts = [
|
||||
// The preview switch's three, the hero glyph, the header icon, the
|
||||
// warning, the route's plane, the route note and the three actions.
|
||||
[card, 11],
|
||||
// The preview switch's three, the hero glyph, the header icon, Find
|
||||
// it, the warning, the route's plane, the route note and the three
|
||||
// actions.
|
||||
[card, 12],
|
||||
// Bigger view, the popup's camera and More info.
|
||||
[camera, 3],
|
||||
// The two weather glyphs, five headings and three row glyphs.
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
// The space missions, Contacts, Radio and provider settings controls are the
|
||||
// kit's: none of their views hand-writes a <button>, a Material Symbols span,
|
||||
// a select or a checkbox. Radio's Enable, the RTL-SDR card's Connect and its
|
||||
// FM and ADS-B modes are pressed toggles with `active`; Radio's Play and the
|
||||
// card's Locate keep their own `active` class, since their words change
|
||||
// with their state rather than saying they are pressed. The RTL-SDR card's
|
||||
// FM frequency stays a native number field (the kit has none), and the radio
|
||||
// tuner's range stays native: its owner moves the handle back to the
|
||||
// selected station on a drag's first input without changing the slot.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
/** A view's template block: everything outside script, style and comments. */
|
||||
function template(file) {
|
||||
const source = readFileSync(
|
||||
new URL(`../views/${file}`, import.meta.url),
|
||||
'utf8',
|
||||
);
|
||||
return source
|
||||
.replace(/<(script|style)\b[\s\S]*?<\/\1\s*>/g, '')
|
||||
.replace(/<!--[\s\S]*?-->/g, '');
|
||||
}
|
||||
// A tag's attributes, read past quoted values so a handler's `=>` does not
|
||||
// end the tag early.
|
||||
const ATTRS = String.raw`(?:[^>"']|"[^"]*"|'[^']*')*`;
|
||||
const tag = (pattern, flags = '') =>
|
||||
new RegExp(pattern.replaceAll('ATTRS', ATTRS), flags);
|
||||
const tags = (markup, name) =>
|
||||
markup.match(tag(String.raw`<${name}\bATTRS>`, 'g')) ?? [];
|
||||
const byId = (markup, name, id) => {
|
||||
const found = tags(markup, name).filter((t) =>
|
||||
new RegExp(String.raw`\sid="${id}"`).test(t),
|
||||
);
|
||||
assert.equal(found.length, 1, id);
|
||||
return found[0];
|
||||
};
|
||||
|
||||
// Each view's UiButtons, UiCloseButtons, UiIcons, UiSelects and UiSliders.
|
||||
const VIEWS = {
|
||||
// FOCUS, REPLAY ASCENT, the replay's pause, PREV, NEXT and SHOW ALL; the
|
||||
// header's deselect and the replay's Cancel close.
|
||||
'panels/MissionDetail.vue': [6, 2, 0, 0, 1],
|
||||
// A mission's row.
|
||||
'panels/MissionRoster.vue': [1, 0, 0, 0, 0],
|
||||
'panels/MissionReplayOverlay.vue': [0, 0, 0, 0, 0],
|
||||
'panels/SpaceMissionsPanel.vue': [0, 0, 0, 0, 0],
|
||||
// PREV, FOCUS, NEXT and a contact's row.
|
||||
'panels/AwarenessPanel.vue': [4, 0, 0, 0, 0],
|
||||
'panels/AwarenessDirection.vue': [0, 0, 0, 0, 0],
|
||||
'panels/AwarenessNames.vue': [0, 0, 0, 0, 0],
|
||||
// Connect, Locate, Change device, FM, ADS-B, Tune and the two seeks.
|
||||
'panels/SdrCard.vue': [8, 0, 0, 1, 1],
|
||||
// Enable, PREV, PLAY, NEXT and STOP.
|
||||
'panels/RadioPanel.vue': [5, 0, 0, 1, 1],
|
||||
'panels/RadioTuner.vue': [0, 0, 0, 0, 0],
|
||||
// The POWER UP chip and its bolt, a key's REMOVE, the voice auth toggle
|
||||
// and SAVE KEYS; the dialog's close.
|
||||
'ProviderSettingsView.vue': [4, 1, 1, 0, 0],
|
||||
};
|
||||
const views = Object.entries(VIEWS).map(([file, counts]) => ({
|
||||
file,
|
||||
markup: template(file),
|
||||
counts,
|
||||
}));
|
||||
|
||||
test('they hand-write no button; each is a UiButton or UiCloseButton', () => {
|
||||
for (const { file, markup, counts } of views) {
|
||||
assert.deepEqual(markup.match(/<button\b/gi) ?? [], [], file);
|
||||
assert.deepEqual(markup.match(/<component\b/gi) ?? [], [], file);
|
||||
assert.equal(tags(markup, 'UiButton').length, counts[0], file);
|
||||
assert.equal(tags(markup, 'UiCloseButton').length, counts[1], file);
|
||||
}
|
||||
});
|
||||
|
||||
test('they hand-write no Material glyph; each is a UiIcon sized by its site', () => {
|
||||
for (const { file, markup, counts } of views) {
|
||||
assert.deepEqual(
|
||||
markup.match(/material-symbols-outlined/g) ?? [],
|
||||
[],
|
||||
file,
|
||||
);
|
||||
const icons = tags(markup, 'UiIcon');
|
||||
assert.equal(icons.length, counts[2], file);
|
||||
// Without it the kit writes an 18px size that beats the site rules.
|
||||
for (const icon of icons) assert.match(icon, /\s:size="null"/, file);
|
||||
}
|
||||
});
|
||||
|
||||
test('their selects and ranges are the kit’s, apart from the tuner', () => {
|
||||
for (const { file, markup, counts } of views) {
|
||||
assert.deepEqual(markup.match(/<select\b/gi) ?? [], [], file);
|
||||
assert.doesNotMatch(markup, /type="checkbox"/, file);
|
||||
assert.equal(tags(markup, 'UiSelect').length, counts[3], file);
|
||||
assert.equal(tags(markup, 'UiSlider').length, counts[4], file);
|
||||
const ranges = tags(markup, 'input').filter((i) =>
|
||||
/\stype="range"/.test(i),
|
||||
);
|
||||
assert.equal(ranges.length, file === 'panels/RadioTuner.vue' ? 1 : 0, file);
|
||||
}
|
||||
});
|
||||
|
||||
test('no tag hand-writes aria-pressed; the pressed toggles take :pressed', () => {
|
||||
const pressed = {
|
||||
'panels/MissionDetail.vue': 1,
|
||||
'panels/SdrCard.vue': 3,
|
||||
'panels/RadioPanel.vue': 1,
|
||||
};
|
||||
for (const { file, markup } of views) {
|
||||
assert.doesNotMatch(
|
||||
markup,
|
||||
tag(String.raw`<\w+\bATTRS\s(?:v-bind)?:?aria-pressed`),
|
||||
file,
|
||||
);
|
||||
const toggles = tags(markup, 'UiButton').filter((b) =>
|
||||
/\s:pressed=/.test(b),
|
||||
);
|
||||
assert.equal(toggles.length, pressed[file] ?? 0, file);
|
||||
}
|
||||
const sdr = views.find((v) => v.file === 'panels/SdrCard.vue').markup;
|
||||
const radio = views.find((v) => v.file === 'panels/RadioPanel.vue').markup;
|
||||
for (const [markup, id] of [
|
||||
[sdr, 'sdr-connect-btn'],
|
||||
[sdr, 'sdr-mode-fm-btn'],
|
||||
[sdr, 'sdr-mode-adsb-btn'],
|
||||
[radio, 'radio-enable-btn'],
|
||||
])
|
||||
assert.match(byId(markup, 'UiButton', id), /\spressed-class="active"/, id);
|
||||
});
|
||||
|
||||
test('Play and Locate keep their own active class rather than pressed', () => {
|
||||
const sdr = views.find((v) => v.file === 'panels/SdrCard.vue').markup;
|
||||
const radio = views.find((v) => v.file === 'panels/RadioPanel.vue').markup;
|
||||
for (const [markup, id] of [
|
||||
[radio, 'radio-play-btn'],
|
||||
[sdr, 'sdr-locate-btn'],
|
||||
]) {
|
||||
const button = byId(markup, 'UiButton', id);
|
||||
assert.doesNotMatch(button, /\s:pressed=/, id);
|
||||
assert.match(button, /\sv-class-toggle="\{ active: /, id);
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,135 @@
|
||||
// The small surfaces' buttons and Material glyphs are the kit's: the locale
|
||||
// picker, the phone tab bar, the globe actions and compass, the imagery
|
||||
// divider, the scene sharing dialog, the layer group index, the celestial
|
||||
// ring, the title logo, Exit clean view, the HUD's cockpit entry, the News
|
||||
// cards, the rail cards, the layer rows' toggles, the credits line and the
|
||||
// camera calibration chips hand-write no <button> and no Material Symbols
|
||||
// span. The Omnibar guide's extra rings are its template's, not built in
|
||||
// script. The locale picker's globe, caret and check and a News card's
|
||||
// category icon stay inline SVG: none is a Material symbol the page loads.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
const read = (file) =>
|
||||
readFileSync(new URL(`../${file}`, import.meta.url), 'utf8');
|
||||
/** The template block: everything outside script, style and comments. */
|
||||
const template = (file) =>
|
||||
read(file)
|
||||
.replace(/<(script|style)\b[\s\S]*?<\/\1\s*>/g, '')
|
||||
.replace(/<!--[\s\S]*?-->/g, '');
|
||||
// An opening tag's attributes, quoted values may hold `>` (`() => x`).
|
||||
const ATTRS = String.raw`(?:[^>"']|"[^"]*"|'[^']*')*`;
|
||||
const tags = (markup, name) =>
|
||||
markup.match(new RegExp(String.raw`<${name}\b${ATTRS}>`, 'g')) ?? [];
|
||||
|
||||
// Per file: its UiButtons, UiCloseButtons and UiIcons.
|
||||
const SURFACES = {
|
||||
'views/panels/LocalePicker.vue': [1, 0, 0],
|
||||
'views/panels/PhoneTabBar.vue': [1, 0, 1],
|
||||
'views/panels/GlobeCompass.vue': [1, 0, 1],
|
||||
// Clear, share, tilt and reset; the clear, tilt and reset glyphs.
|
||||
'views/panels/GlobeActions.vue': [4, 0, 3],
|
||||
'views/panels/ImagerySplitView.vue': [1, 0, 0],
|
||||
// The body's buttons and the footer's.
|
||||
'views/panels/SceneDialog.vue': [2, 0, 0],
|
||||
'views/panels/LayerSectionIndex.vue': [1, 0, 0],
|
||||
// The sun and moon markers.
|
||||
'views/panels/CelestialRing.vue': [0, 0, 2],
|
||||
'views/panels/OmnibarGuide.vue': [3, 1, 0],
|
||||
// The overlay targets' buttons and the title logo.
|
||||
'views/SceneChromeView.vue': [2, 0, 0],
|
||||
'views/DisplayControlsView.vue': [1, 0, 0],
|
||||
'views/IntelHudView.vue': [1, 0, 1],
|
||||
// The card's face and the selected card's clear chip.
|
||||
'news/NewsCard.vue': [2, 0, 0],
|
||||
'rail/RailCard.vue': [1, 0, 0],
|
||||
'layerPanel/LayerRows.vue': [1, 0, 0],
|
||||
'credits/CreditsView.vue': [1, 1, 0],
|
||||
'cctv/CctvCalValue.vue': [1, 0, 0],
|
||||
};
|
||||
|
||||
test('the small surfaces hand-write no button; each is a kit button', () => {
|
||||
for (const [file, [buttons, closes]] of Object.entries(SURFACES)) {
|
||||
const markup = template(file);
|
||||
assert.deepEqual(markup.match(/<button\b/gi) ?? [], [], file);
|
||||
assert.equal(tags(markup, 'UiButton').length, buttons, file);
|
||||
assert.equal(tags(markup, 'UiCloseButton').length, closes, file);
|
||||
}
|
||||
});
|
||||
|
||||
test('the small surfaces hand-write no Material glyph; each is a UiIcon', () => {
|
||||
for (const [file, [, , count]] of Object.entries(SURFACES)) {
|
||||
const markup = template(file);
|
||||
assert.deepEqual(
|
||||
markup.match(/material-symbols-outlined/g) ?? [],
|
||||
[],
|
||||
file,
|
||||
);
|
||||
const icons = tags(markup, 'UiIcon');
|
||||
assert.equal(icons.length, count, file);
|
||||
// Without it the kit writes an 18px size that beats the sites' own rules.
|
||||
for (const icon of icons) assert.match(icon, /\s:size="null"/, file);
|
||||
}
|
||||
});
|
||||
|
||||
test('the only inline SVG glyphs are the locale picker’s and a News category’s', () => {
|
||||
for (const file of Object.keys(SURFACES)) {
|
||||
const expected =
|
||||
file === 'views/panels/LocalePicker.vue'
|
||||
? 3
|
||||
: file === 'news/NewsCard.vue'
|
||||
? 1
|
||||
: 0;
|
||||
assert.equal(template(file).match(/<svg\b/g)?.length ?? 0, expected, file);
|
||||
}
|
||||
});
|
||||
|
||||
test('buttons whose owner patches synchronously redraw their contents with it', () => {
|
||||
// A UiButton's slot renders inside the button, a tick after a change the
|
||||
// button's own attributes do not carry; a conditional slot is redrawn with
|
||||
// its view.
|
||||
// How many of each file's first buttons the owner redraws and reads.
|
||||
for (const [file, count] of [
|
||||
['news/NewsCard.vue', 1],
|
||||
['rail/RailCard.vue', 1],
|
||||
['credits/CreditsView.vue', 1],
|
||||
['views/panels/OmnibarGuide.vue', 3],
|
||||
]) {
|
||||
const markup = template(file);
|
||||
const buttons = tags(markup, 'UiButton').slice(0, count);
|
||||
assert.equal(buttons.length, count, file);
|
||||
let from = 0;
|
||||
for (const button of buttons) {
|
||||
from = markup.indexOf(button, from) + button.length;
|
||||
assert.match(
|
||||
markup.slice(from),
|
||||
/^\s*<template v-if="redrawWithView" #default\s*>/,
|
||||
file,
|
||||
);
|
||||
}
|
||||
assert.match(read(file), /const redrawWithView = true;/, file);
|
||||
}
|
||||
});
|
||||
|
||||
test('the Omnibar guide draws its extra rings in its template', () => {
|
||||
const guide = template('views/panels/OmnibarGuide.vue');
|
||||
assert.match(
|
||||
guide,
|
||||
/<div\s+v-for="i in view\.subRings"\s+:key="i"\s+class="gev-guide-ring gev-guide-ring--sub"\s*><\/div\s*>\s*<\/div\s*>\s*<\/Teleport/,
|
||||
);
|
||||
const owner = read('omnibarGuide.js');
|
||||
assert.deepEqual(owner.match(/createElement\(/g), ['createElement(']);
|
||||
assert.doesNotMatch(owner, /\.className\s*=|\.append\(/);
|
||||
assert.match(owner, /view\.subRings = rest\.length;\s*paint\(\);/);
|
||||
});
|
||||
|
||||
test('the layer disclosure builds no control', () => {
|
||||
// Its one `<button` is a comment's word for the element Chromium focuses.
|
||||
const disclosure = read('panelDisclosure.js');
|
||||
assert.doesNotMatch(disclosure, /createElement|innerHTML|insertAdjacentHTML/);
|
||||
const code = disclosure
|
||||
.replace(/\/\/.*$/gm, '')
|
||||
.replace(/\/\*[\s\S]*?\*\//g, '');
|
||||
assert.doesNotMatch(code, /<button/);
|
||||
});
|
||||
@@ -3,11 +3,12 @@
|
||||
// `<input type="checkbox">`. Their glyphs are inline SVG drawn for Stories
|
||||
// (play, pause, back, filter, search, clear, expand, the GEV eye); no
|
||||
// Material symbol the page loads draws any of them the same, so they stay
|
||||
// SVG, and no view hand-writes a Material Symbols span. The two search
|
||||
// fields keep their own markup rather than UiSearchField, whose Material
|
||||
// magnifier would replace their SVG one, and their clear buttons stay ghost
|
||||
// UiButtons with an SVG cross rather than UiCloseButtons, whose glyph is ×
|
||||
// or the Material `close` symbol.
|
||||
// SVG, and no view hand-writes a Material Symbols span. The three search
|
||||
// fields (Explore's two and the Story context sheet's) keep their own markup
|
||||
// rather than UiSearchField, whose Material magnifier would replace their
|
||||
// SVG one, and Explore's two clear buttons stay ghost UiButtons with an SVG
|
||||
// cross rather than UiCloseButtons, whose glyph is × or the Material `close`
|
||||
// symbol.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
// The Street Level photo viewer (KartaView, Panoramax) is a view with kit
|
||||
// controls: StreetLevelPhotoViewer draws what the photo viewer presents and
|
||||
// hand-writes no <button> and no Material Symbols span; its ‹ › are ghost
|
||||
// UiButtons, not pressed toggles, whose glyphs are text characters. The
|
||||
// photo viewer builds no element of its own, and the street-level layer it
|
||||
// belongs to needs no Vue: the application shell publishes its
|
||||
// presentation to the store the view renders.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
const read = (file) =>
|
||||
readFileSync(new URL(`../../${file}`, import.meta.url), 'utf8');
|
||||
/** The template block: everything outside script, style and comments. */
|
||||
const template = (file) =>
|
||||
read(file)
|
||||
.replace(/<(script|style)\b[\s\S]*?<\/\1\s*>/g, '')
|
||||
.replace(/<!--[\s\S]*?-->/g, '');
|
||||
// An opening tag's attributes, quoted values may hold `>` (`() => x`).
|
||||
const ATTRS = String.raw`(?:[^>"']|"[^"]*"|'[^']*')*`;
|
||||
const tags = (markup, name) =>
|
||||
markup.match(new RegExp(String.raw`<${name}\b${ATTRS}>`, 'g')) ?? [];
|
||||
// An attribute's name, outside the quoted values.
|
||||
const names = (attrs) => attrs.replace(/"[^"]*"|'[^']*'/g, '""');
|
||||
|
||||
const VIEW = 'ui/views/panels/StreetLevelPhotoViewer.vue';
|
||||
const VIEWER = 'layers/streetLevel/photoViewer.js';
|
||||
|
||||
test('the photo viewer hand-writes no button; ‹ and › are kit buttons', () => {
|
||||
const markup = template(VIEW);
|
||||
assert.deepEqual(markup.match(/<button\b/gi) ?? [], [], VIEW);
|
||||
assert.deepEqual(markup.match(/<(select|input)\b/gi) ?? [], [], VIEW);
|
||||
const buttons = tags(markup, 'UiButton');
|
||||
assert.equal(buttons.length, 2);
|
||||
assert.equal(tags(markup, 'UiCloseButton').length, 0);
|
||||
// Ghost buttons with the classes street-level.css styles.
|
||||
for (const [button, side] of [
|
||||
[buttons[0], 'prev'],
|
||||
[buttons[1], 'next'],
|
||||
]) {
|
||||
assert.doesNotMatch(button, /\svariant=/);
|
||||
assert.match(
|
||||
button,
|
||||
new RegExp(`\\sclass="sl-photo-step sl-photo-step-${side}"`),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('the photo viewer hand-writes no Material glyph', () => {
|
||||
const markup = template(VIEW);
|
||||
assert.deepEqual(markup.match(/material-symbols/g) ?? [], [], VIEW);
|
||||
assert.equal(tags(markup, 'UiIcon').length, 0);
|
||||
// ‹ and › are text characters.
|
||||
assert.match(markup, />‹<\/UiButton\s*>/);
|
||||
assert.match(markup, />›<\/UiButton\s*>/);
|
||||
});
|
||||
|
||||
test('the step buttons are not pressed toggles', () => {
|
||||
const markup = template(VIEW);
|
||||
for (const [tag, attrs] of markup.matchAll(
|
||||
new RegExp(String.raw`<[A-Za-z][\w-]*\b(${ATTRS})>`, 'g'),
|
||||
)) {
|
||||
assert.doesNotMatch(
|
||||
names(attrs),
|
||||
/(?:^|\s)(?::|v-bind:)?aria-pressed(?=[\s=/]|$)/,
|
||||
tag,
|
||||
);
|
||||
assert.doesNotMatch(
|
||||
attrs,
|
||||
/(?:^|\s)(?:v-bind|:)=(?:"[^"]*aria-?pressed[^"]*"|'[^']*aria-?pressed[^']*')/i,
|
||||
tag,
|
||||
);
|
||||
assert.doesNotMatch(names(attrs), /(?:^|\s)(?::|v-bind:)?pressed\b/, tag);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* `loadImage`, which downloads through an Image of its own that is never on
|
||||
* the page: the one place a `.src` is written.
|
||||
*/
|
||||
const LOADER = /^export function loadImage\([\s\S]*?^}$/m;
|
||||
// An assignment, plain or compound (`=`, `+=`, `||=`, `??=`, `**=`…), not
|
||||
// a comparison or an arrow.
|
||||
const ASSIGN = String.raw`\s*(?:[-+*/%&|^]|\*\*|<<|>>>?|&&|\|\||\?\?)?=(?![=>])`;
|
||||
const assigned = (target, flags = '') =>
|
||||
new RegExp(String.raw`${target}${ASSIGN}`, flags);
|
||||
// A member or computed member: what a destructuring write must not target.
|
||||
const MEMBER = /[\w$)\]]\s*(?:\.\s*[\w$]|\[)/;
|
||||
|
||||
test('the photo viewer is drawn by its view, and its layer needs no Vue', () => {
|
||||
const source = read(VIEWER);
|
||||
const loader = source.match(LOADER)?.[0];
|
||||
assert.ok(loader, 'loadImage is found');
|
||||
const rest = source.replace(LOADER, '');
|
||||
// No element made, inserted, moved, removed or written: the view does
|
||||
// all of that. (The panorama renderer in panorama.js sizes its canvas's
|
||||
// drawing buffer, as WebGL drawing does; nothing here does.)
|
||||
for (const write of [
|
||||
/createElement/,
|
||||
/\b(?:inner|outer)HTML\b/,
|
||||
/insertAdjacent(?:HTML|Element|Text)/,
|
||||
/\.(?:append|prepend|appendChild|insertBefore|replaceWith|replaceChildren|before|after)\(/,
|
||||
/\.remove\(\)/,
|
||||
/\.(?:set|remove|toggle)Attribute(?:NS)?\(/,
|
||||
/\.(?:classList|className|dataset|style)\b/,
|
||||
assigned(
|
||||
String.raw`\.(?:hidden|disabled|textContent|innerText|tabIndex|title|alt)`,
|
||||
),
|
||||
assigned(String.raw`\.(?:width|height|ariaLabel|id|value)`),
|
||||
// Properties written in bulk or by reflection (an Error's own fields
|
||||
// aside).
|
||||
/\bObject\.assign\(\s*(?!new Error\()/,
|
||||
/\bObject\.definePropert(?:y|ies)\(/,
|
||||
/\bReflect\.(?:set|defineProperty)\(/,
|
||||
/from 'vue'|\.vue'/,
|
||||
])
|
||||
assert.doesNotMatch(source, write);
|
||||
// No property written through brackets (`picture['src'] = …`,
|
||||
// `el[name] ||= …`), outside array destructuring declarations.
|
||||
assert.doesNotMatch(
|
||||
source.replace(/\b(?:const|let|var)\s*\[/g, ''),
|
||||
assigned(String.raw`[\w$)\]]\s*\[[^[\]]*\]`),
|
||||
'a bracket write',
|
||||
);
|
||||
// No destructuring write to a property (`[el.src] = …`,
|
||||
// `({ a: el.id } = …)`); declarations bind names only.
|
||||
for (const pattern of [
|
||||
/(?<!\b(?:const|let|var)\s*)\[((?:[^[\]=;]|\[[^[\]=;]*\])*)\]\s*=(?![=>])/g,
|
||||
/(?<!\b(?:const|let|var)\s*)\{((?:[^{}=;]|\{[^{}=;]*\})*)\}\s*\)?\s*=(?![=>])/g,
|
||||
])
|
||||
for (const [write, targets] of source.matchAll(pattern))
|
||||
assert.doesNotMatch(targets, MEMBER, write);
|
||||
const SRC = assigned(String.raw`\.src`, 'g');
|
||||
assert.doesNotMatch(rest, SRC, 'a .src written on the page');
|
||||
// In loadImage, only on the off-page Image it creates: `image` is bound
|
||||
// once, to that Image, and never rebound or shadowed.
|
||||
assert.match(loader, /\bconst image = new Image\(\);/);
|
||||
assert.equal(
|
||||
loader.match(/\b(?:const|let|var|function|class)\s+image\b/g)?.length,
|
||||
1,
|
||||
'one binding of image',
|
||||
);
|
||||
for (const rebinding of [
|
||||
assigned(String.raw`(?<!\b(?:const|let|var)\s+)(?<![\w$.])image`),
|
||||
/(?<![\w$.])image\s*=>/,
|
||||
/\((?:[^()]*[,{[\s(])?image\b[^()]*\)\s*=>/,
|
||||
/\bfunction\b[^(]*\((?:[^)]*[,{[\s(])?image\b[^)]*\)/,
|
||||
/\b(?:const|let|var)\s*[{[][^=]*\bimage\b/,
|
||||
/\bcatch\s*\([^)]*\bimage\b/,
|
||||
])
|
||||
assert.doesNotMatch(loader, rebinding, 'image rebound or shadowed');
|
||||
const writes = loader.match(SRC)?.length ?? 0;
|
||||
assert.equal(
|
||||
loader.match(assigned(String.raw`(?<![\w$.)\]])image\.src`, 'g'))?.length ??
|
||||
0,
|
||||
writes,
|
||||
'a .src written on something other than the Image',
|
||||
);
|
||||
const markup = template(VIEW);
|
||||
const opening = (name, attribute) =>
|
||||
new RegExp(String.raw`<${name}\b${ATTRS}\s${attribute}${ATTRS}>`);
|
||||
for (const part of [
|
||||
opening('div', 'class="sl-photo-viewer"'),
|
||||
opening('img', 'class="sl-photo-flat"'),
|
||||
opening('canvas', ':key="photo.canvasKey"'),
|
||||
opening('canvas', 'class="sl-photo-pano"'),
|
||||
])
|
||||
assert.match(markup, part);
|
||||
const groups = JSON.parse(
|
||||
readFileSync(
|
||||
new URL('../../../scripts/package-boundaries.json', import.meta.url),
|
||||
'utf8',
|
||||
),
|
||||
);
|
||||
const layer = groups['street-level-layer'];
|
||||
assert.ok(layer.modules.includes(`src/${VIEWER}`));
|
||||
assert.equal(layer.external.includes('vue'), false);
|
||||
assert.equal(
|
||||
layer.modules.some((module) => module.endsWith('.vue')),
|
||||
false,
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,439 @@
|
||||
// The kit's every-control claims in docs/VUE-MIGRATION.md, read from every
|
||||
// SFC outside the kit: every button is a kit button, every select a
|
||||
// UiSelect, every checkbox a UiCheckbox, every range a UiSlider apart from
|
||||
// the two named below, and every Material Symbols glyph a UiIcon; every
|
||||
// pressed toggle is a UiButton with `pressed` (no template hand-writes
|
||||
// `aria-pressed` on any element, as an attribute or inside a `v-bind`
|
||||
// object, apart from the exceptions below), and every close, dismiss and
|
||||
// clear button a UiCloseButton. Outside the kit, no module (nor an SFC's
|
||||
// script) builds a button, select, field or Material glyph in script, or
|
||||
// writes one as markup in a string, apart from the globe panel's standalone
|
||||
// page named below.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync, readdirSync } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const SRC_ROOT = fileURLToPath(new URL('../../', import.meta.url));
|
||||
const KIT_ROOT = fileURLToPath(new URL('./', import.meta.url));
|
||||
const REPO_ROOT = path.resolve(SRC_ROOT, '..');
|
||||
|
||||
// The pressed toggles that still hand-write `aria-pressed`, by file: each
|
||||
// pattern matches exactly one of the file's tags, and no other tag may.
|
||||
const HAND_WRITTEN_PRESSED = {
|
||||
// Explore's story cards are `role="button"` elements, not buttons.
|
||||
'src/ui/views/stories/ExploreScreen.vue': [
|
||||
/^<div class="card" role="button"/,
|
||||
],
|
||||
};
|
||||
|
||||
/** Every SFC under src, outside the kit. */
|
||||
function sfcFiles(directory = SRC_ROOT) {
|
||||
const files = [];
|
||||
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
||||
const absolute = path.join(directory, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
if (path.relative(KIT_ROOT, absolute) !== '')
|
||||
files.push(...sfcFiles(absolute));
|
||||
} else if (entry.isFile() && entry.name.endsWith('.vue'))
|
||||
files.push(absolute);
|
||||
}
|
||||
return files.sort();
|
||||
}
|
||||
|
||||
/** The template block: everything outside script, style and comments. */
|
||||
function template(source) {
|
||||
return source
|
||||
.replace(/<(script|style)\b[\s\S]*?<\/\1\s*>/g, '')
|
||||
.replace(/<!--[\s\S]*?-->/g, '');
|
||||
}
|
||||
|
||||
// An opening tag's attributes, quoted values may hold `>` (`() => x`).
|
||||
const ATTRS = String.raw`(?:[^>"']|"[^"]*"|'[^']*')*`;
|
||||
const RAW_SELECT = /<select\b/gi;
|
||||
const ANY_TAG = new RegExp(String.raw`<[A-Za-z][\w-]*\b(${ATTRS})>`, 'g');
|
||||
// An attribute's name, outside the quoted values.
|
||||
const names = (attrs) => attrs.replace(/"[^"]*"|'[^']*'/g, '""');
|
||||
const PRESSED = /(?:^|\s)(?::|v-bind:)?aria-pressed(?=[\s=/]|$)/;
|
||||
// A `v-bind` object that names aria-pressed.
|
||||
const BOUND_PRESSED =
|
||||
/(?:^|\s)(?:v-bind|:)=(?:"[^"]*aria-?pressed[^"]*"|'[^']*aria-?pressed[^']*')/i;
|
||||
const TIMES = String.raw`×|×|×|×`;
|
||||
const CLOSE_GLYPH = [
|
||||
TIMES,
|
||||
String.raw`<span\b${ATTRS}>\s*(?:${TIMES})\s*</span\s*>`,
|
||||
String.raw`<span\b[^>]*\bmaterial-symbols-outlined\b[^>]*>\s*close\s*</span\s*>`,
|
||||
String.raw`<UiIcon${ATTRS}\bname="close"${ATTRS}/>`,
|
||||
].join('|');
|
||||
const HAND_WRITTEN_CLOSE = new RegExp(
|
||||
String.raw`<(button|UiButton)\b${ATTRS}>\s*(?:${CLOSE_GLYPH})\s*</\1\s*>`,
|
||||
'gi',
|
||||
);
|
||||
|
||||
const tidy = (markup) => markup.replace(/\s+/g, ' ');
|
||||
|
||||
// The two ranges that stay native, by file (docs/VUE-MIGRATION.md says why).
|
||||
const NATIVE_RANGES = {
|
||||
'src/ui/views/panels/RadioTuner.vue': 1,
|
||||
'src/ui/views/panels/WorldTimeline.vue': 1,
|
||||
};
|
||||
const RAW_BUTTON = /<button\b/gi;
|
||||
// A tag whose class, static or bound (alone or in a `v-bind` object), names
|
||||
// a Material Symbols style.
|
||||
const MATERIAL_CLASS =
|
||||
/(?:^|\s)(?:(?::|v-bind:)?class|v-bind|:)=(?:"[^"]*material-symbols[^"]*"|'[^']*material-symbols[^']*')/i;
|
||||
const INPUT_TAG = new RegExp(String.raw`<input\b(${ATTRS})>`, 'gi');
|
||||
// An attribute and its value, read from the tag rather than other values.
|
||||
const ATTRIBUTE = /([^\s=/]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'/>]+)))?/g;
|
||||
/**
|
||||
* A tag's `type`: written, bound to a quoted literal (`:type="'checkbox'"`),
|
||||
* or named in a `v-bind` object; null when it is bound to anything else.
|
||||
*/
|
||||
function inputType(attrs) {
|
||||
for (const m of attrs.matchAll(ATTRIBUTE)) {
|
||||
const name = m[1].toLowerCase();
|
||||
const value = m[2] ?? m[3] ?? m[4] ?? '';
|
||||
if (name === 'type') return value.toLowerCase();
|
||||
if (name === ':type' || name === 'v-bind:type') {
|
||||
const literal = /^\s*(['`])([^'`]*)\1\s*$/.exec(value);
|
||||
if (literal) return literal[2].toLowerCase();
|
||||
}
|
||||
if (name === 'v-bind' || name === ':') {
|
||||
const named = /\btype\s*:\s*(['`])([^'`]*)\1/.exec(value);
|
||||
if (named) return named[2].toLowerCase();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Hand-written buttons in an SFC's template. */
|
||||
const rawButtons = (source) =>
|
||||
[...template(source).matchAll(RAW_BUTTON)].map((m) => m[0]);
|
||||
|
||||
/** Tags in an SFC's template that draw a Material glyph by hand. */
|
||||
function materialGlyphs(source) {
|
||||
const found = [];
|
||||
for (const m of template(source).matchAll(ANY_TAG))
|
||||
if (!/^<UiIcon\b/.test(m[0]) && MATERIAL_CLASS.test(m[1]))
|
||||
found.push(tidy(m[0]));
|
||||
return found;
|
||||
}
|
||||
|
||||
/** Native inputs of a type in an SFC's template. */
|
||||
const nativeInputs = (source, type) =>
|
||||
[...template(source).matchAll(INPUT_TAG)]
|
||||
.filter((m) => inputType(m[1]) === type)
|
||||
.map((m) => tidy(m[0]));
|
||||
|
||||
/** Raw selects in an SFC's template. */
|
||||
const rawSelects = (source) =>
|
||||
[...template(source).matchAll(RAW_SELECT)].map((m) => m[0]);
|
||||
|
||||
/** Tags that hand-write aria-pressed. */
|
||||
function handWrittenPressed(source) {
|
||||
const found = [];
|
||||
for (const m of template(source).matchAll(ANY_TAG))
|
||||
if (PRESSED.test(names(m[1])) || BOUND_PRESSED.test(m[1]))
|
||||
found.push(tidy(m[0]));
|
||||
return found;
|
||||
}
|
||||
|
||||
/** Hand-written close buttons in an SFC's template. */
|
||||
const handWrittenCloses = (source) =>
|
||||
[...template(source).matchAll(HAND_WRITTEN_CLOSE)].map((m) => tidy(m[0]));
|
||||
|
||||
const views = sfcFiles().map((file) => ({
|
||||
file: path.relative(REPO_ROOT, file).split(path.sep).join('/'),
|
||||
source: readFileSync(file, 'utf8'),
|
||||
}));
|
||||
|
||||
test('the scans find each hand-written control', () => {
|
||||
for (const markup of [
|
||||
'<template><select id="x" v-model="a"><option>1</option></select></template>',
|
||||
'<template><SELECT\n class="x"></SELECT></template>',
|
||||
])
|
||||
assert.equal(rawSelects(markup).length, 1, markup);
|
||||
for (const markup of [
|
||||
'<template><UiSelect id="x" v-model="a" /></template>',
|
||||
'<script>const html = "<select>";</script><template><p /></template>',
|
||||
'<template><!-- a <select> once sat here --><p /></template>',
|
||||
])
|
||||
assert.equal(rawSelects(markup).length, 0, markup);
|
||||
|
||||
for (const markup of [
|
||||
'<template><button type="button" :aria-pressed="String(on)">A</button></template>',
|
||||
'<template><UiButton\n class="x"\n :title="a > b ? 1 : 2"\n aria-pressed="true"\n>A</UiButton></template>',
|
||||
'<template><button v-bind:aria-pressed="on">A</button></template>',
|
||||
'<template><div class="card" role="button" tabindex="0" :aria-pressed="on" /></template>',
|
||||
'<template><li role="option" :aria-pressed="on" /></template>',
|
||||
'<template><a :role="\'button\'" :aria-pressed="on">A</a></template>',
|
||||
'<template><UiButton v-bind="{ \'aria-pressed\': on }">A</UiButton></template>',
|
||||
])
|
||||
assert.equal(handWrittenPressed(markup).length, 1, markup);
|
||||
for (const markup of [
|
||||
'<template><UiButton :pressed="Boolean(on)" pressed-class="active">A</UiButton></template>',
|
||||
'<template><button :title="\'aria-pressed\'" @click="q(\'[aria-pressed=true]\')">A</button></template>',
|
||||
'<template><li role="option" :aria-selected="on" /></template>',
|
||||
])
|
||||
assert.equal(handWrittenPressed(markup).length, 0, markup);
|
||||
|
||||
for (const markup of [
|
||||
'<template><button type="button" @click="close">×</button></template>',
|
||||
'<template><button type="button" :aria-label="l"><span aria-hidden="true">×</span></button></template>',
|
||||
'<template><UiButton class="x"><UiIcon name="close" :size="null" /></UiButton></template>',
|
||||
])
|
||||
assert.equal(handWrittenCloses(markup).length, 1, markup);
|
||||
for (const markup of [
|
||||
'<template><UiCloseButton class="x" :label="l" /></template>',
|
||||
'<template><UiButton :label="l"><UiIcon :name="item.icon" :size="null" /></UiButton></template>',
|
||||
])
|
||||
assert.equal(handWrittenCloses(markup).length, 0, markup);
|
||||
});
|
||||
|
||||
test('the scans find each hand-written button, glyph, checkbox and range', () => {
|
||||
for (const markup of [
|
||||
'<template><button type="button">A</button></template>',
|
||||
'<template><BUTTON\n class="x">A</BUTTON></template>',
|
||||
])
|
||||
assert.equal(rawButtons(markup).length, 1, markup);
|
||||
for (const markup of [
|
||||
'<template><UiButton>A</UiButton></template>',
|
||||
'<script>const html = "<button>";</script><template><p /></template>',
|
||||
'<template><!-- a <button> once sat here --><p /></template>',
|
||||
])
|
||||
assert.equal(rawButtons(markup).length, 0, markup);
|
||||
|
||||
for (const markup of [
|
||||
'<template><span class="material-symbols-outlined">search</span></template>',
|
||||
'<template><i class="pp-icon material-symbols-rounded" aria-hidden="true">add</i></template>',
|
||||
'<template><span :class="\'material-symbols-outlined \' + extra">add</span></template>',
|
||||
'<template><span\n class="x material-symbols-sharp"\n :title="a > b ? 1 : 2"\n>add</span></template>',
|
||||
])
|
||||
assert.equal(materialGlyphs(markup).length, 1, markup);
|
||||
for (const markup of [
|
||||
'<template><UiIcon name="search" class="material-symbols-outlined" :size="null" /></template>',
|
||||
'<template><span class="x">search</span></template>',
|
||||
'<template><p /></template><style>.x .material-symbols-outlined { color: red; }</style>',
|
||||
])
|
||||
assert.equal(materialGlyphs(markup).length, 0, markup);
|
||||
|
||||
assert.equal(
|
||||
nativeInputs(
|
||||
'<template><input type="checkbox" v-model="a" /></template>',
|
||||
'checkbox',
|
||||
).length,
|
||||
1,
|
||||
);
|
||||
assert.equal(
|
||||
nativeInputs(
|
||||
'<template><input\n class="x"\n type="range"\n :max="a > b ? 1 : 2"\n/></template>',
|
||||
'range',
|
||||
).length,
|
||||
1,
|
||||
);
|
||||
assert.equal(
|
||||
nativeInputs(
|
||||
'<template><input type="text" :title="\'type=checkbox\'" /></template>',
|
||||
'checkbox',
|
||||
).length,
|
||||
0,
|
||||
);
|
||||
assert.equal(
|
||||
nativeInputs(
|
||||
'<template><UiCheckbox v-model="a">A</UiCheckbox></template>',
|
||||
'checkbox',
|
||||
).length,
|
||||
0,
|
||||
);
|
||||
for (const markup of [
|
||||
`<template><input :type="'checkbox'" /></template>`,
|
||||
`<template><input v-bind:type="'checkbox'" /></template>`,
|
||||
`<template><input v-bind="{ type: 'checkbox' }" /></template>`,
|
||||
'<template><input TYPE="checkbox" /></template>',
|
||||
'<template><input type=checkbox/></template>',
|
||||
])
|
||||
assert.equal(nativeInputs(markup, 'checkbox').length, 1, markup);
|
||||
assert.equal(
|
||||
nativeInputs('<template><input :type="item.type" /></template>', 'checkbox')
|
||||
.length,
|
||||
0,
|
||||
);
|
||||
assert.equal(
|
||||
materialGlyphs(
|
||||
`<template><span v-bind="{ class: 'material-symbols-outlined' }">add</span></template>`,
|
||||
).length,
|
||||
1,
|
||||
);
|
||||
});
|
||||
|
||||
test('the views are read: the scan reaches the views and skips the kit', () => {
|
||||
const files = views.map((view) => view.file);
|
||||
assert.ok(files.includes('src/ui/views/panels/ChatPanel.vue'));
|
||||
assert.ok(files.includes('src/ui/layerPanel/RowRange.vue'));
|
||||
assert.ok(!files.some((file) => file.startsWith('src/ui/kit/')));
|
||||
});
|
||||
|
||||
test('every select in the views is a UiSelect', () => {
|
||||
const found = [];
|
||||
for (const { file, source } of views)
|
||||
for (const markup of rawSelects(source)) found.push(`${file}: ${markup}`);
|
||||
assert.deepEqual(found, []);
|
||||
});
|
||||
|
||||
test('no view hand-writes aria-pressed on a button outside the documented exceptions', () => {
|
||||
const unexpected = [];
|
||||
for (const { file, source } of views) {
|
||||
const allowed = [...(HAND_WRITTEN_PRESSED[file] ?? [])];
|
||||
for (const markup of handWrittenPressed(source)) {
|
||||
const at = allowed.findIndex((pattern) => pattern.test(markup));
|
||||
if (at === -1) unexpected.push(`${file}: ${markup}`);
|
||||
else allowed.splice(at, 1);
|
||||
}
|
||||
assert.deepEqual(allowed, [], `${file}: an exception no longer matches`);
|
||||
}
|
||||
assert.deepEqual(unexpected, []);
|
||||
});
|
||||
|
||||
test('no view hand-writes a close button; each is a UiCloseButton', () => {
|
||||
const found = [];
|
||||
for (const { file, source } of views)
|
||||
for (const markup of handWrittenCloses(source))
|
||||
found.push(`${file}: ${markup}`);
|
||||
assert.deepEqual(found, []);
|
||||
});
|
||||
|
||||
test('every button in the views is a kit button', () => {
|
||||
const found = [];
|
||||
for (const { file, source } of views)
|
||||
for (const markup of rawButtons(source)) found.push(`${file}: ${markup}`);
|
||||
assert.deepEqual(found, []);
|
||||
});
|
||||
|
||||
test('every Material Symbols glyph in the views is a UiIcon', () => {
|
||||
const found = [];
|
||||
for (const { file, source } of views)
|
||||
for (const markup of materialGlyphs(source))
|
||||
found.push(`${file}: ${markup}`);
|
||||
assert.deepEqual(found, []);
|
||||
});
|
||||
|
||||
test('every checkbox in the views is a UiCheckbox', () => {
|
||||
const found = [];
|
||||
for (const { file, source } of views)
|
||||
for (const markup of nativeInputs(source, 'checkbox'))
|
||||
found.push(`${file}: ${markup}`);
|
||||
assert.deepEqual(found, []);
|
||||
});
|
||||
|
||||
test('every range in the views is a UiSlider apart from the two named', () => {
|
||||
const counts = {};
|
||||
for (const { file, source } of views) {
|
||||
const n = nativeInputs(source, 'range').length;
|
||||
if (n) counts[file] = n;
|
||||
}
|
||||
assert.deepEqual(counts, NATIVE_RANGES);
|
||||
});
|
||||
|
||||
// The globe panel's standalone page: plain HTML a host serves, with no Vue
|
||||
// and no kit, so its two buttons are written as markup.
|
||||
const STRING_MARKUP_PAGES = new Set(['src/tools/globePanel.js']);
|
||||
|
||||
/**
|
||||
* Every module under src outside the kit, tests and test support, and every
|
||||
* SFC's script blocks, as `{ file, source }`.
|
||||
*/
|
||||
function scriptSources(directory = SRC_ROOT) {
|
||||
const found = [];
|
||||
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
||||
const absolute = path.join(directory, entry.name);
|
||||
const file = path.relative(REPO_ROOT, absolute).split(path.sep).join('/');
|
||||
if (entry.isDirectory()) {
|
||||
if (
|
||||
path.relative(KIT_ROOT, absolute) !== '' &&
|
||||
entry.name !== 'testSupport'
|
||||
)
|
||||
found.push(...scriptSources(absolute));
|
||||
} else if (
|
||||
!entry.isFile() ||
|
||||
/\.test\.(?:js|mjs|ts)$|Fixture\.mjs$/.test(entry.name)
|
||||
) {
|
||||
continue;
|
||||
} else if (/\.(?:js|mjs|ts)$/.test(entry.name)) {
|
||||
found.push({ file, source: readFileSync(absolute, 'utf8') });
|
||||
} else if (entry.name.endsWith('.vue')) {
|
||||
const blocks = [
|
||||
...readFileSync(absolute, 'utf8').matchAll(
|
||||
/<script\b[^>]*>([\s\S]*?)<\/script\s*>/g,
|
||||
),
|
||||
];
|
||||
found.push({ file, source: blocks.map((m) => m[1]).join('\n') });
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
const SCRIPT_CONTROL =
|
||||
/\bcreateElement(?:NS)?\(\s*(?:[^,)]*,\s*)?['"`](?:button|select|input|textarea)['"`]/gi;
|
||||
const SCRIPT_GLYPH =
|
||||
/['"`][^'"`]*\bmaterial-symbols-(?:outlined|rounded|sharp|\$\{)/g;
|
||||
const STRING_MARKUP = /<(?:button|select|input|textarea)\b/gi;
|
||||
|
||||
/** A source with its comments blanked, line numbers kept. */
|
||||
const uncommented = (source) =>
|
||||
source
|
||||
.replace(/\/\*[\s\S]*?\*\//g, (comment) => comment.replace(/[^\n]/g, ' '))
|
||||
.replace(/(^|[^:'"`\\])\/\/[^\n]*/g, '$1');
|
||||
|
||||
/** Each match in a source, as `file:line: text`. */
|
||||
function hits(file, source, pattern) {
|
||||
return [...source.matchAll(pattern)].map((m) => {
|
||||
const line = source.slice(0, m.index).split('\n').length;
|
||||
return `${file}:${line}: ${source.split('\n')[line - 1].trim()}`;
|
||||
});
|
||||
}
|
||||
|
||||
test('no module outside the kit builds a control or Material glyph in script', () => {
|
||||
const sees = (pattern, text) => [...text.matchAll(pattern)].length > 0;
|
||||
assert.ok(
|
||||
sees(SCRIPT_CONTROL, "const b = document.createElement('button');"),
|
||||
);
|
||||
assert.ok(sees(SCRIPT_CONTROL, 'doc.createElement("INPUT")'));
|
||||
assert.ok(
|
||||
sees(SCRIPT_CONTROL, "someDocument.createElement(\n 'button',\n);"),
|
||||
);
|
||||
assert.ok(!sees(SCRIPT_CONTROL, "document.createElement('div')"));
|
||||
assert.ok(
|
||||
sees(SCRIPT_GLYPH, "span.className = 'material-symbols-outlined';"),
|
||||
);
|
||||
assert.ok(sees(SCRIPT_GLYPH, 'el.className = `material-symbols-${style}`;'));
|
||||
assert.ok(
|
||||
!sees(SCRIPT_GLYPH, 'ctx.font = \'24px "Material Symbols Outlined"\';'),
|
||||
);
|
||||
assert.ok(sees(STRING_MARKUP, "host.innerHTML = '<button>x</button>';"));
|
||||
assert.ok(
|
||||
!sees(STRING_MARKUP, "'<button-row>'".replace('<button-row>', '<buttons>')),
|
||||
);
|
||||
|
||||
const sources = scriptSources();
|
||||
assert.ok(
|
||||
sources.some(({ file }) => file === 'src/ui/views/panels/ChatPanel.vue'),
|
||||
);
|
||||
const found = [];
|
||||
for (const { file, source } of sources) {
|
||||
found.push(
|
||||
...hits(file, source, SCRIPT_CONTROL),
|
||||
...hits(file, source, SCRIPT_GLYPH),
|
||||
);
|
||||
if (!STRING_MARKUP_PAGES.has(file))
|
||||
found.push(...hits(file, uncommented(source), STRING_MARKUP));
|
||||
}
|
||||
assert.deepEqual(found, []);
|
||||
for (const file of STRING_MARKUP_PAGES) {
|
||||
const page = sources.find((s) => s.file === file);
|
||||
assert.ok(
|
||||
page && hits(file, page.source, STRING_MARKUP).length,
|
||||
`${file} no longer writes markup`,
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -5,6 +5,7 @@ import RowRange from './RowRange.vue';
|
||||
import RowSlider from './RowSlider.vue';
|
||||
import RowSwitch from './RowSwitch.vue';
|
||||
import RowText from './RowText.vue';
|
||||
import UiButton from '../kit/UiButton.vue';
|
||||
import { vClassToggle } from '../rail/classToggle.js';
|
||||
|
||||
// The data layer rows under their group headings. LayerPanel presents every
|
||||
@@ -45,8 +46,7 @@ defineProps({
|
||||
v-if="item.count"
|
||||
:class="['data-count', { 'data-count-empty': item.count.empty }]"
|
||||
:text="item.count.text"
|
||||
/><button
|
||||
type="button"
|
||||
/><UiButton
|
||||
:class="['data-toggle-btn', item.toggle.classes]"
|
||||
:data-feed-state="item.toggle.feedState"
|
||||
:aria-disabled="String(item.toggle.ariaDisabled)"
|
||||
@@ -54,7 +54,7 @@ defineProps({
|
||||
:title="item.toggle.title"
|
||||
:aria-label="item.toggle.ariaLabel"
|
||||
@click="onToggle(item.id)"
|
||||
>{{ item.toggle.text }}</button
|
||||
>{{ item.toggle.text }}</UiButton
|
||||
></div
|
||||
></div
|
||||
><RowText tag="div" class="data-toggle-meta" :text="item.meta" /><template
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
<script setup>
|
||||
import UiSelect from '../kit/UiSelect.js';
|
||||
|
||||
// A row's start and end pickers on one line (e.g. the Shipwrecks period).
|
||||
// Both ends share one option list; `onSelect` reports which end moved
|
||||
// ('from' or 'to') and the chosen option value.
|
||||
// ('from' or 'to') and the chosen option value. The owner repaints the row
|
||||
// on a later frame and may reorder the ends (a start picked after the end
|
||||
// swaps them), so each select is given its end's value as a plain `value`
|
||||
// rather than a model: the pick stays until the owner publishes a different
|
||||
// value, which then shows at once, even on the focused select.
|
||||
defineProps({
|
||||
range: { type: Object, required: true },
|
||||
onSelect: { type: Function, default: () => {} },
|
||||
@@ -21,18 +27,18 @@ defineProps({
|
||||
:key="end"
|
||||
class="data-toggle-range-end"
|
||||
><span class="data-toggle-range-caption">{{ range[end].label }}</span
|
||||
><select
|
||||
><UiSelect
|
||||
class="data-toggle-range-select"
|
||||
:data-range-end="end"
|
||||
:aria-label="range[end].ariaLabel || undefined"
|
||||
:value="String(range[end].value)"
|
||||
@change="onSelect(end, $event.target.value)"
|
||||
@update:model-value="onSelect(end, $event)"
|
||||
><option
|
||||
v-for="option in range.options"
|
||||
:key="option.value"
|
||||
:value="String(option.value)"
|
||||
>{{ option.label }}</option
|
||||
></select
|
||||
></UiSelect
|
||||
></label
|
||||
></div
|
||||
></div
|
||||
|
||||
@@ -241,7 +241,7 @@ test('a Data Library row names its entry and draws icon action chips', () => {
|
||||
assert.equal(element.dataset.libraryEntry, 'nasa-black-marble');
|
||||
const button = element.querySelector('[data-chip-id="zoom"]');
|
||||
const glyph = button.children[0];
|
||||
assert.equal(glyph.className, 'material-symbols-outlined');
|
||||
assert.ok(glyph.classList.contains('material-symbols-outlined'));
|
||||
assert.equal(glyph.textContent, 'zoom_in_map');
|
||||
assert.equal(glyph.getAttribute('aria-hidden'), 'true');
|
||||
assert.equal(button.getAttribute('aria-label'), 'Zoom to layer');
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import { after, before, test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { installVueDom } from '../../testSupport/vueDom.mjs';
|
||||
|
||||
let mount;
|
||||
let RowRange;
|
||||
let uninstall;
|
||||
before(async () => {
|
||||
uninstall = installVueDom();
|
||||
({ mount } = await import('@vue/test-utils'));
|
||||
RowRange = (await import('./RowRange.vue')).default;
|
||||
});
|
||||
after(() => uninstall());
|
||||
|
||||
const range = (from, to) => ({
|
||||
id: 'period',
|
||||
label: 'Period',
|
||||
valueText: `${from}–${to}`,
|
||||
from: { label: 'From', value: from },
|
||||
to: { label: 'To', value: to },
|
||||
options: [1900, 1950, 1960, 2000].map((value) => ({
|
||||
value,
|
||||
label: String(value),
|
||||
})),
|
||||
});
|
||||
|
||||
test('a range end keeps a pick until the owner repaints, then shows the owner’s ends', async () => {
|
||||
const picks = [];
|
||||
const wrapper = mount(RowRange, {
|
||||
attachTo: document.body,
|
||||
props: {
|
||||
range: range(1900, 1950),
|
||||
onSelect: (end, value) => picks.push([end, value]),
|
||||
},
|
||||
});
|
||||
const [from, to] = wrapper.findAll('select').map((w) => w.element);
|
||||
assert.equal(from.value, '1900');
|
||||
assert.equal(to.value, '1950');
|
||||
// A start picked after the end: the owner swaps the ends on a later frame.
|
||||
from.focus();
|
||||
from.value = '1960';
|
||||
from.dispatchEvent(new Event('change'));
|
||||
assert.deepEqual(picks, [['from', '1960']]);
|
||||
await wrapper.vm.$nextTick();
|
||||
assert.equal(from.value, '1960');
|
||||
await wrapper.setProps({ range: range(1950, 1960) });
|
||||
assert.equal(document.activeElement, from);
|
||||
assert.equal(from.value, '1950');
|
||||
assert.equal(to.value, '1960');
|
||||
wrapper.unmount();
|
||||
});
|
||||
@@ -0,0 +1,374 @@
|
||||
import {
|
||||
LIVE_STREAMS,
|
||||
liveStreamsFor,
|
||||
youtubeWatchUrl,
|
||||
} from '../data/liveStreams.js';
|
||||
import { createYouTubeLivePlayer } from '../data/youtubeLivePlayer.js';
|
||||
import { useLiveStore } from './stores/live.js';
|
||||
import { applicationPinia } from './vueRuntime.js';
|
||||
|
||||
/** The element the LIVE section in Context keeps for the player. */
|
||||
export const LIVE_PLAYER_HOST_ID = 'live-player-host';
|
||||
|
||||
/**
|
||||
* The element the Cockpit briefing's LIVE page keeps for the player; the one
|
||||
* used while the Cockpit is on, since the right rail is hidden there.
|
||||
*/
|
||||
export const COCKPIT_LIVE_PLAYER_HOST_ID = 'cockpit-live-player-host';
|
||||
|
||||
/**
|
||||
* A layer's selected subject can be judged again as it settles (a satellite
|
||||
* is docked to the station once both orbits have been compared): the keys
|
||||
* are read again this often while something is selected.
|
||||
*/
|
||||
export const LIVE_SUBJECT_REFRESH_MS = 2000;
|
||||
|
||||
/**
|
||||
* Own the live video: which object is selected (the tracking layers'
|
||||
* `gev:awareness-subject-selected`), which streams the list attaches to it,
|
||||
* and the one player. The views (the LIVE section in Context and the Cockpit
|
||||
* briefing's LIVE page) render what this publishes, and the player is built
|
||||
* only when the viewer presses Play in one of them (`playLive`): YouTube sees
|
||||
* the viewer's IP address, so selecting a station by click, a link, a scene
|
||||
* or voice never loads it. The player is built into the view that is shown,
|
||||
* the section's outside the Cockpit and the page's inside it, and goes when
|
||||
* that view is hidden (the section collapsed, Context closed, the Cockpit
|
||||
* page left: `hideLive`), when the Cockpit is entered or left, and when the
|
||||
* selection moves to an object without that stream or clears.
|
||||
*/
|
||||
export class LiveControls {
|
||||
/**
|
||||
* @param {{store?: object, actions: {getLayer: (layerId: string) => object|null,
|
||||
* scheduleLayout?: () => void}, documentRef?: Document, globalRef?: object,
|
||||
* createPlayer?: typeof createYouTubeLivePlayer,
|
||||
* streams?: readonly object[], refreshMs?: number}} options
|
||||
*/
|
||||
constructor({
|
||||
store = useLiveStore(applicationPinia()),
|
||||
actions,
|
||||
documentRef = globalThis.document,
|
||||
globalRef = globalThis,
|
||||
createPlayer = createYouTubeLivePlayer,
|
||||
streams = LIVE_STREAMS,
|
||||
refreshMs = LIVE_SUBJECT_REFRESH_MS,
|
||||
}) {
|
||||
this.store = store;
|
||||
this.actions = actions;
|
||||
this.documentRef = documentRef;
|
||||
this.globalRef = globalRef;
|
||||
this.createPlayer = createPlayer;
|
||||
this.streams = streams;
|
||||
this.refreshMs = refreshMs;
|
||||
this.destroyed = false;
|
||||
/** The selected object: its layer, id and label; null for none. */
|
||||
this.subject = null;
|
||||
/** The streams on offer for it, and the chosen one's id. */
|
||||
this.offered = [];
|
||||
this.currentId = null;
|
||||
/** The player, the element and stream it was built for, and its state. */
|
||||
this.player = null;
|
||||
this.playerHost = null;
|
||||
this.playerStreamId = null;
|
||||
this.playback = { state: 'idle', reason: null };
|
||||
/** Whether the Cockpit is on, which decides the host the player goes in. */
|
||||
this.cockpitActive =
|
||||
documentRef?.body?.classList?.contains?.('cockpit-mode') === true;
|
||||
this.timer = null;
|
||||
/** The view last published, as text: the 2 s refresh resends nothing new. */
|
||||
this.publishedKey = undefined;
|
||||
/** The stop held back for one tick after a clear (see `_onCleared`). */
|
||||
this.clearGrace = null;
|
||||
this.listeners = new AbortController();
|
||||
const { signal } = this.listeners;
|
||||
const target = globalRef.addEventListener ? globalRef : null;
|
||||
target?.addEventListener(
|
||||
'gev:awareness-subject-selected',
|
||||
(event) => this._onSelected(event.detail),
|
||||
{ signal },
|
||||
);
|
||||
target?.addEventListener(
|
||||
'gev:awareness-subject-cleared',
|
||||
(event) => this._onCleared(event.detail),
|
||||
{ signal },
|
||||
);
|
||||
target?.addEventListener(
|
||||
'gev:cockpit-mode-changed',
|
||||
(event) => this._onCockpitMode(event.detail?.active === true),
|
||||
{ signal },
|
||||
);
|
||||
this.owner = store.connect({
|
||||
cycleLive: (direction) => this.cycle(direction),
|
||||
playLive: () => this.play(),
|
||||
stopLive: () => this.stop(),
|
||||
retryLive: () => this.play({ restart: true }),
|
||||
hideLive: (where) => this.hide(where),
|
||||
});
|
||||
store.publish(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* A new selection. A player that is on keeps playing when the new subject
|
||||
* offers the same stream (another entry of the same station: a module, a
|
||||
* docked vehicle, the Cockpit stepping between views on it); otherwise it
|
||||
* goes.
|
||||
*/
|
||||
_onSelected(detail) {
|
||||
if (this.destroyed || !detail?.layerId || detail.id == null) return;
|
||||
this._cancelClearGrace();
|
||||
this.subject = {
|
||||
layerId: detail.layerId,
|
||||
id: detail.id,
|
||||
label: String(detail.label ?? detail.id),
|
||||
};
|
||||
if (this.player) {
|
||||
const offered = liveStreamsFor(this._subjectKeys(), this.streams);
|
||||
if (offered.some((stream) => stream.id === this.playerStreamId))
|
||||
this.currentId = this.playerStreamId;
|
||||
else this.stop();
|
||||
}
|
||||
this._refresh();
|
||||
this._arm();
|
||||
}
|
||||
|
||||
/**
|
||||
* The selection cleared. With a player on, the stop waits one tick: the
|
||||
* Cockpit stepping between views on a station clears the selection and
|
||||
* selects the next entry at once, and a player for the same stream should
|
||||
* not be torn down and rebuilt between the two.
|
||||
*/
|
||||
_onCleared(detail) {
|
||||
if (this.destroyed || !this.subject) return;
|
||||
if (detail?.layerId && detail.layerId !== this.subject.layerId) return;
|
||||
this.subject = null;
|
||||
this._disarm();
|
||||
if (this.player && this.globalRef.setTimeout) {
|
||||
this._cancelClearGrace();
|
||||
this.clearGrace = this.globalRef.setTimeout(() => {
|
||||
this.clearGrace = null;
|
||||
if (this.destroyed || this.subject) return;
|
||||
this.stop();
|
||||
this._refresh();
|
||||
}, 0);
|
||||
return;
|
||||
}
|
||||
this.stop();
|
||||
this._refresh();
|
||||
}
|
||||
|
||||
_cancelClearGrace() {
|
||||
if (this.clearGrace !== null)
|
||||
this.globalRef.clearTimeout?.(this.clearGrace);
|
||||
this.clearGrace = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Cockpit went on or off: the view the player was in is hidden now,
|
||||
* so the player goes. The view now shown offers Play again.
|
||||
*/
|
||||
_onCockpitMode(active) {
|
||||
if (this.destroyed || active === this.cockpitActive) return;
|
||||
this.cockpitActive = active;
|
||||
this.stop();
|
||||
}
|
||||
|
||||
/**
|
||||
* A view was hidden (`section`: the LIVE section collapsed or Context
|
||||
* closed; `cockpit`: the briefing left its LIVE page or went): the player
|
||||
* goes if it was in that view's screen, so nothing plays unseen.
|
||||
* @param {'section'|'cockpit'} where
|
||||
* @returns {boolean} True when a player was removed.
|
||||
*/
|
||||
hide(where) {
|
||||
const id =
|
||||
where === 'cockpit' ? COCKPIT_LIVE_PLAYER_HOST_ID : LIVE_PLAYER_HOST_ID;
|
||||
if (!this.player || this.playerHost?.id !== id) return false;
|
||||
return this.stop();
|
||||
}
|
||||
|
||||
/** The element the player belongs in now: the Cockpit page's, or the section's. */
|
||||
_host() {
|
||||
const id = this.cockpitActive
|
||||
? COCKPIT_LIVE_PLAYER_HOST_ID
|
||||
: LIVE_PLAYER_HOST_ID;
|
||||
return this.documentRef?.getElementById?.(id) ?? null;
|
||||
}
|
||||
|
||||
/** Read the selected subject's keys again on a timer, while one is selected. */
|
||||
_arm() {
|
||||
this._disarm();
|
||||
if (!this.subject || !(this.refreshMs > 0)) return;
|
||||
this.timer = this.globalRef.setInterval(
|
||||
() => this._refresh(),
|
||||
this.refreshMs,
|
||||
);
|
||||
this.timer?.unref?.();
|
||||
}
|
||||
|
||||
_disarm() {
|
||||
if (this.timer !== null) this.globalRef.clearInterval(this.timer);
|
||||
this.timer = null;
|
||||
}
|
||||
|
||||
/** The keys the selected subject is known by, from its layer. */
|
||||
_subjectKeys() {
|
||||
if (!this.subject) return [];
|
||||
const { layerId, id } = this.subject;
|
||||
const keys = [`${layerId}:${id}`];
|
||||
let layer = null;
|
||||
try {
|
||||
layer = this.actions.getLayer?.(layerId) ?? null;
|
||||
} catch {
|
||||
layer = null;
|
||||
}
|
||||
try {
|
||||
for (const key of layer?.getLiveSubjectKeys?.() ?? [])
|
||||
if (typeof key === 'string') keys.push(key);
|
||||
} catch {
|
||||
// A layer that cannot say keeps its plain key.
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
/** Work out the streams on offer and publish. */
|
||||
_refresh() {
|
||||
if (this.destroyed) return;
|
||||
const offered = liveStreamsFor(this._subjectKeys(), this.streams);
|
||||
const changed =
|
||||
offered.length !== this.offered.length ||
|
||||
offered.some((stream, index) => stream.id !== this.offered[index]?.id);
|
||||
this.offered = offered;
|
||||
if (!offered.some((stream) => stream.id === this.currentId)) {
|
||||
// The chosen stream went with the selection: nothing plays on.
|
||||
if (this.player) this.stop();
|
||||
this.currentId = offered[0]?.id ?? null;
|
||||
}
|
||||
this._publish();
|
||||
if (changed) this.actions.scheduleLayout?.();
|
||||
}
|
||||
|
||||
/** Publish `view` unless it is the one published last. */
|
||||
_send(view) {
|
||||
const key = JSON.stringify(view);
|
||||
if (key === this.publishedKey) return;
|
||||
this.publishedKey = key;
|
||||
this.store.publish(view);
|
||||
}
|
||||
|
||||
_publish() {
|
||||
if (this.destroyed) return;
|
||||
if (!this.subject || !this.offered.length) {
|
||||
this._send(null);
|
||||
return;
|
||||
}
|
||||
const index = Math.max(
|
||||
0,
|
||||
this.offered.findIndex((stream) => stream.id === this.currentId),
|
||||
);
|
||||
const current = this.offered[index];
|
||||
this._send({
|
||||
label: this.subject.label,
|
||||
streams: this.offered.map((stream) => ({
|
||||
id: stream.id,
|
||||
title: stream.title,
|
||||
owner: stream.owner,
|
||||
})),
|
||||
index,
|
||||
count: this.offered.length,
|
||||
current: {
|
||||
id: current.id,
|
||||
title: current.title,
|
||||
owner: current.owner,
|
||||
ownerUrl: current.ownerUrl,
|
||||
note: current.note,
|
||||
watchUrl: youtubeWatchUrl(current.videoId),
|
||||
},
|
||||
state: this.playback.state,
|
||||
reason: this.playback.reason,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Step to the next (+1) or previous (-1) stream on offer, wrapping. A
|
||||
* playing stream hands over to the new one.
|
||||
* @returns {boolean} True when the stream changed.
|
||||
*/
|
||||
cycle(direction = 1) {
|
||||
if (this.offered.length < 2) return false;
|
||||
const index = this.offered.findIndex((s) => s.id === this.currentId);
|
||||
const next =
|
||||
(Math.max(index, 0) + (direction < 0 ? -1 : 1) + this.offered.length) %
|
||||
this.offered.length;
|
||||
this.currentId = this.offered[next].id;
|
||||
const wasPlaying = this.player !== null;
|
||||
this.stop();
|
||||
if (wasPlaying) this.play();
|
||||
else this._publish();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the chosen stream in the host now shown: the one call that loads
|
||||
* the player, made only by the viewer's Play (or Try again). A player
|
||||
* already loading or playing that stream in that host is left alone;
|
||||
* `restart` (Try again) builds a fresh one regardless.
|
||||
* @returns {boolean} True when a player is loading or playing afterwards.
|
||||
*/
|
||||
play({ restart = false } = {}) {
|
||||
if (this.destroyed) return false;
|
||||
const stream = this.offered.find((s) => s.id === this.currentId);
|
||||
const host = this._host();
|
||||
if (!stream || !host) return false;
|
||||
const running =
|
||||
this.playback.state === 'loading' || this.playback.state === 'playing';
|
||||
if (
|
||||
!restart &&
|
||||
this.player &&
|
||||
running &&
|
||||
this.playerHost === host &&
|
||||
this.playerStreamId === stream.id
|
||||
)
|
||||
return true;
|
||||
this.stop();
|
||||
this.playback = { state: 'loading', reason: null };
|
||||
this.playerHost = host;
|
||||
this.playerStreamId = stream.id;
|
||||
this.player = this.createPlayer({
|
||||
host,
|
||||
videoId: stream.videoId,
|
||||
documentRef: this.documentRef,
|
||||
globalRef: this.globalRef,
|
||||
onChange: ({ state, reason }) => {
|
||||
if (this.destroyed) return;
|
||||
this.playback = { state, reason };
|
||||
this._publish();
|
||||
},
|
||||
});
|
||||
this._publish();
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Remove the player; the screen goes dark. */
|
||||
stop() {
|
||||
const had = this.player !== null;
|
||||
this.player?.destroy();
|
||||
this.player = null;
|
||||
this.playerHost = null;
|
||||
this.playerStreamId = null;
|
||||
if (had || this.playback.state !== 'idle') {
|
||||
this.playback = { state: 'idle', reason: null };
|
||||
this._publish();
|
||||
}
|
||||
return had;
|
||||
}
|
||||
|
||||
destroy() {
|
||||
if (this.destroyed) return;
|
||||
this._cancelClearGrace();
|
||||
this.stop();
|
||||
this.destroyed = true;
|
||||
this._disarm();
|
||||
this.listeners.abort();
|
||||
this.store.detach(this.owner);
|
||||
this.store.publish(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,442 @@
|
||||
// src/ui/liveControls.test.mjs — LiveControls owns the live video: the
|
||||
// selected object's streams, the one player, which screen it is built into,
|
||||
// and when it goes.
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
COCKPIT_LIVE_PLAYER_HOST_ID,
|
||||
LIVE_PLAYER_HOST_ID,
|
||||
LiveControls,
|
||||
} from './liveControls.js';
|
||||
import { createOwners } from './stores/owners.js';
|
||||
|
||||
const STREAMS = Object.freeze([
|
||||
{
|
||||
id: 'one',
|
||||
platform: 'youtube',
|
||||
videoId: 'AAAAAAAAAAA',
|
||||
title: 'First',
|
||||
owner: 'Owner',
|
||||
ownerUrl: 'https://www.youtube.com/@owner',
|
||||
subjects: ['station:test'],
|
||||
note: 'note',
|
||||
},
|
||||
{
|
||||
id: 'two',
|
||||
platform: 'youtube',
|
||||
videoId: 'BBBBBBBBBBB',
|
||||
title: 'Second',
|
||||
owner: 'Owner',
|
||||
ownerUrl: 'https://www.youtube.com/@owner',
|
||||
subjects: ['station:test'],
|
||||
note: 'note',
|
||||
},
|
||||
{
|
||||
id: 'other',
|
||||
platform: 'youtube',
|
||||
videoId: 'CCCCCCCCCCC',
|
||||
title: 'Elsewhere',
|
||||
owner: 'Owner',
|
||||
ownerUrl: 'https://www.youtube.com/@owner',
|
||||
subjects: ['station:other'],
|
||||
note: 'note',
|
||||
},
|
||||
]);
|
||||
|
||||
function fixture({
|
||||
withHost = true,
|
||||
withCockpitHost = true,
|
||||
cockpitMode = false,
|
||||
} = {}) {
|
||||
const globalRef = new EventTarget();
|
||||
const intervals = [];
|
||||
globalRef.setInterval = (callback, ms) => {
|
||||
const id = intervals.length + 1;
|
||||
intervals.push({ id, callback, ms, cleared: false });
|
||||
return id;
|
||||
};
|
||||
globalRef.clearInterval = (id) => {
|
||||
const timer = intervals.find((entry) => entry.id === id);
|
||||
if (timer) timer.cleared = true;
|
||||
};
|
||||
const timeouts = [];
|
||||
globalRef.setTimeout = (callback, ms) => {
|
||||
timeouts.push({ callback, ms, done: false });
|
||||
return timeouts.length;
|
||||
};
|
||||
globalRef.clearTimeout = (id) => {
|
||||
if (timeouts[id - 1]) timeouts[id - 1].done = true;
|
||||
};
|
||||
/** Run the timeouts due now, as the next tick would. */
|
||||
const tick = () => {
|
||||
for (const timeout of timeouts.splice(0))
|
||||
if (!timeout.done) timeout.callback();
|
||||
};
|
||||
const host = { id: LIVE_PLAYER_HOST_ID };
|
||||
const cockpitHost = { id: COCKPIT_LIVE_PLAYER_HOST_ID };
|
||||
const documentRef = {
|
||||
getElementById: (id) => {
|
||||
if (id === LIVE_PLAYER_HOST_ID) return withHost ? host : null;
|
||||
if (id === COCKPIT_LIVE_PLAYER_HOST_ID)
|
||||
return withCockpitHost ? cockpitHost : null;
|
||||
return null;
|
||||
},
|
||||
body: {
|
||||
classList: { contains: (name) => cockpitMode && name === 'cockpit-mode' },
|
||||
},
|
||||
};
|
||||
const published = [];
|
||||
const store = {
|
||||
...createOwners(),
|
||||
publish: (view) => published.push(view),
|
||||
};
|
||||
let keys = [];
|
||||
const layer = { getLiveSubjectKeys: () => keys };
|
||||
const layouts = [];
|
||||
const players = [];
|
||||
const createPlayer = (options) => {
|
||||
const player = {
|
||||
options,
|
||||
destroyed: 0,
|
||||
destroy: () => (player.destroyed += 1),
|
||||
};
|
||||
players.push(player);
|
||||
return player;
|
||||
};
|
||||
const controls = new LiveControls({
|
||||
store,
|
||||
actions: {
|
||||
getLayer: (layerId) => (layerId === 'satellites' ? layer : null),
|
||||
scheduleLayout: () => layouts.push(1),
|
||||
},
|
||||
documentRef,
|
||||
globalRef,
|
||||
createPlayer,
|
||||
streams: STREAMS,
|
||||
refreshMs: 2000,
|
||||
});
|
||||
const dispatch = (type, detail) =>
|
||||
globalRef.dispatchEvent(new CustomEvent(type, { detail }));
|
||||
const select = (detail) =>
|
||||
dispatch('gev:awareness-subject-selected', {
|
||||
layerId: 'satellites',
|
||||
id: 25544,
|
||||
label: 'ISS (ZARYA)',
|
||||
...detail,
|
||||
});
|
||||
const view = () => published.at(-1);
|
||||
const running = () => intervals.filter((timer) => !timer.cleared);
|
||||
return {
|
||||
controls,
|
||||
store,
|
||||
published,
|
||||
view,
|
||||
dispatch,
|
||||
select,
|
||||
setKeys: (next) => (keys = next),
|
||||
players,
|
||||
layouts,
|
||||
intervals,
|
||||
running,
|
||||
tick,
|
||||
host,
|
||||
cockpitHost,
|
||||
};
|
||||
}
|
||||
|
||||
test('nothing selected publishes no section; a selection with streams publishes them', () => {
|
||||
const f = fixture();
|
||||
assert.equal(f.view(), null);
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
const view = f.view();
|
||||
assert.equal(view.label, 'ISS (ZARYA)');
|
||||
assert.equal(view.count, 2);
|
||||
assert.equal(view.index, 0);
|
||||
assert.deepEqual(
|
||||
view.streams.map((stream) => stream.id),
|
||||
['one', 'two'],
|
||||
);
|
||||
assert.equal(view.current.id, 'one');
|
||||
assert.equal(
|
||||
view.current.watchUrl,
|
||||
'https://www.youtube.com/watch?v=AAAAAAAAAAA',
|
||||
);
|
||||
assert.equal(view.state, 'idle');
|
||||
assert.equal(
|
||||
f.layouts.length,
|
||||
1,
|
||||
'the rail is laid out once the section appears',
|
||||
);
|
||||
assert.equal(f.running().length, 1, 'the subject is re-read on a timer');
|
||||
assert.equal(f.running()[0].ms, 2000);
|
||||
});
|
||||
|
||||
test('a selection no stream names keeps the section away; the plain key counts too', () => {
|
||||
const f = fixture();
|
||||
f.select();
|
||||
assert.equal(f.view(), null);
|
||||
assert.equal(f.layouts.length, 0);
|
||||
// A stream attached to a layer's own `<layer>:<id>` key needs no layer help.
|
||||
const g = fixture();
|
||||
g.setKeys([]);
|
||||
g.select({ layerId: 'satellites', id: 'x' });
|
||||
assert.equal(g.view(), null);
|
||||
});
|
||||
|
||||
test('the layer is asked again on the timer: an entry that settles as docked gains the streams', () => {
|
||||
const f = fixture();
|
||||
f.select();
|
||||
assert.equal(f.view(), null);
|
||||
f.setKeys(['station:test']);
|
||||
f.running()[0].callback();
|
||||
assert.equal(f.view()?.count, 2);
|
||||
assert.equal(f.layouts.length, 1);
|
||||
// Unchanged keys do not lay out again.
|
||||
f.running()[0].callback();
|
||||
assert.equal(f.layouts.length, 1);
|
||||
});
|
||||
|
||||
test('playLive builds the player for the chosen stream in the section, once; Try again builds it anew', () => {
|
||||
const f = fixture();
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
assert.equal(
|
||||
f.players.length,
|
||||
0,
|
||||
'the views ask; selection alone builds nothing',
|
||||
);
|
||||
assert.equal(f.store.act('playLive'), true);
|
||||
assert.equal(f.players.length, 1);
|
||||
assert.equal(f.players[0].options.videoId, 'AAAAAAAAAAA');
|
||||
assert.equal(f.players[0].options.host, f.host);
|
||||
assert.equal(f.view().state, 'loading');
|
||||
// Asked again while loading or playing, the same player stays.
|
||||
assert.equal(f.store.act('playLive'), true);
|
||||
f.players[0].options.onChange({ state: 'playing', reason: null });
|
||||
assert.equal(f.store.act('playLive'), true);
|
||||
assert.equal(f.players.length, 1, 'no second player for the same stream');
|
||||
assert.equal(f.players[0].destroyed, 0);
|
||||
assert.equal(f.view().state, 'playing');
|
||||
f.players[0].options.onChange({ state: 'offline', reason: 'ended' });
|
||||
assert.equal(f.view().state, 'offline');
|
||||
assert.equal(f.view().reason, 'ended');
|
||||
assert.equal(f.store.act('stopLive'), true);
|
||||
assert.equal(f.players[0].destroyed, 1);
|
||||
assert.equal(f.view().state, 'idle');
|
||||
// Try again builds a fresh player.
|
||||
assert.equal(f.store.act('retryLive'), true);
|
||||
assert.equal(f.players.length, 2);
|
||||
});
|
||||
|
||||
test('Play without the host element in the page, or without a selection, does nothing', () => {
|
||||
const noHost = fixture({ withHost: false });
|
||||
noHost.setKeys(['station:test']);
|
||||
noHost.select();
|
||||
assert.equal(noHost.store.act('playLive'), false);
|
||||
assert.equal(noHost.players.length, 0);
|
||||
const idle = fixture();
|
||||
assert.equal(idle.store.act('playLive'), false);
|
||||
});
|
||||
|
||||
test('the arrows step through the streams, wrapping, and a playing stream hands over', () => {
|
||||
const f = fixture();
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
assert.equal(f.store.act('cycleLive', 1), true);
|
||||
assert.equal(f.view().current.id, 'two');
|
||||
assert.equal(f.store.act('cycleLive', 1), true);
|
||||
assert.equal(f.view().current.id, 'one', 'wraps forward');
|
||||
assert.equal(f.store.act('cycleLive', -1), true);
|
||||
assert.equal(f.view().current.id, 'two', 'wraps backward');
|
||||
assert.equal(f.players.length, 0, 'stepping while idle loads nothing');
|
||||
f.store.act('playLive');
|
||||
f.store.act('cycleLive', 1);
|
||||
assert.equal(f.players.length, 2);
|
||||
assert.equal(f.players[0].destroyed, 1);
|
||||
assert.equal(f.players[1].options.videoId, 'AAAAAAAAAAA');
|
||||
assert.equal(f.view().state, 'loading');
|
||||
});
|
||||
|
||||
test('with one stream there is nothing to cycle', () => {
|
||||
const f = fixture();
|
||||
f.setKeys(['station:other']);
|
||||
f.select();
|
||||
assert.equal(f.view().count, 1);
|
||||
assert.equal(f.store.act('cycleLive', 1), false);
|
||||
assert.equal(f.view().current.id, 'other');
|
||||
});
|
||||
|
||||
test('a new selection stops the stream; the same entry selected again keeps it', () => {
|
||||
const f = fixture();
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
f.store.act('playLive');
|
||||
f.select({ origin: 'pick' });
|
||||
assert.equal(f.players[0].destroyed, 0, 'the same subject plays on');
|
||||
f.setKeys(['station:other']);
|
||||
f.select({ id: 99999, label: 'OTHER' });
|
||||
assert.equal(f.players[0].destroyed, 1);
|
||||
assert.equal(f.view().label, 'OTHER');
|
||||
assert.equal(f.view().current.id, 'other');
|
||||
assert.equal(f.view().state, 'idle');
|
||||
});
|
||||
|
||||
test('clearing the selection takes the section down; another layer clearing does not', () => {
|
||||
const f = fixture();
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
f.store.act('playLive');
|
||||
f.dispatch('gev:awareness-subject-cleared', { layerId: 'flights' });
|
||||
assert.equal(f.view().count, 2, 'another layer clearing is not ours');
|
||||
f.dispatch('gev:awareness-subject-cleared', { layerId: 'satellites' });
|
||||
assert.equal(f.running().length, 0, 'the timer stops with the selection');
|
||||
// The stop waits a tick, for a selection that moves straight on.
|
||||
assert.equal(f.players[0].destroyed, 0);
|
||||
f.tick();
|
||||
assert.equal(f.view(), null);
|
||||
assert.equal(f.players[0].destroyed, 1);
|
||||
});
|
||||
|
||||
test('a selection that moves straight on to an entry with the same stream keeps the player', () => {
|
||||
const f = fixture();
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
f.store.act('playLive');
|
||||
// The Cockpit stepping to the next view on the station: cleared, then the
|
||||
// next entry selected, in one go.
|
||||
f.dispatch('gev:awareness-subject-cleared', { layerId: 'satellites' });
|
||||
f.select({ id: 49044, label: 'ISS (NAUKA)' });
|
||||
f.tick();
|
||||
assert.equal(f.players.length, 1, 'not rebuilt');
|
||||
assert.equal(f.players[0].destroyed, 0);
|
||||
assert.equal(f.view().label, 'ISS (NAUKA)');
|
||||
assert.equal(f.view().current.id, 'one');
|
||||
// One without that stream stops it.
|
||||
f.dispatch('gev:awareness-subject-cleared', { layerId: 'satellites' });
|
||||
f.setKeys(['station:other']);
|
||||
f.select({ id: 99999, label: 'OTHER' });
|
||||
f.tick();
|
||||
assert.equal(f.players[0].destroyed, 1);
|
||||
});
|
||||
|
||||
test('entering or leaving the Cockpit removes the player: the view now shown offers Play again', () => {
|
||||
const f = fixture();
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
f.store.act('playLive');
|
||||
f.players[0].options.onChange({ state: 'playing', reason: null });
|
||||
f.dispatch('gev:cockpit-mode-changed', { active: true });
|
||||
assert.equal(f.players[0].destroyed, 1, 'the rail is hidden in the Cockpit');
|
||||
assert.equal(f.players.length, 1, 'nothing is built by itself');
|
||||
assert.equal(f.view().state, 'idle');
|
||||
// The same state again changes nothing.
|
||||
f.dispatch('gev:cockpit-mode-changed', { active: true });
|
||||
assert.equal(f.players.length, 1);
|
||||
// Play in the Cockpit's page builds it in that page's screen.
|
||||
assert.equal(f.store.act('playLive'), true);
|
||||
assert.equal(f.players[1].options.host, f.cockpitHost);
|
||||
f.dispatch('gev:cockpit-mode-changed', { active: false });
|
||||
assert.equal(f.players[1].destroyed, 1);
|
||||
assert.equal(f.players.length, 2);
|
||||
});
|
||||
|
||||
test('a view that is hidden removes the player only when it is in that view', () => {
|
||||
const f = fixture();
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
f.store.act('playLive');
|
||||
assert.equal(f.store.act('hideLive', 'cockpit'), false, 'not in the page');
|
||||
assert.equal(f.players[0].destroyed, 0);
|
||||
assert.equal(f.store.act('hideLive', 'section'), true);
|
||||
assert.equal(f.players[0].destroyed, 1);
|
||||
assert.equal(f.view().state, 'idle');
|
||||
assert.equal(f.store.act('hideLive', 'section'), false, 'nothing left');
|
||||
});
|
||||
|
||||
test('selecting a station with streams builds no player until Play', () => {
|
||||
const f = fixture();
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
f.select({ origin: 'pick' });
|
||||
f.dispatch('gev:cockpit-mode-changed', { active: true });
|
||||
f.dispatch('gev:cockpit-mode-changed', { active: false });
|
||||
assert.equal(f.players.length, 0);
|
||||
assert.equal(f.view().state, 'idle');
|
||||
f.store.act('playLive');
|
||||
assert.equal(f.players.length, 1);
|
||||
});
|
||||
|
||||
test('the Cockpit going on or off with nothing playing builds nothing', () => {
|
||||
const f = fixture();
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
f.dispatch('gev:cockpit-mode-changed', { active: true });
|
||||
f.dispatch('gev:cockpit-mode-changed', { active: false });
|
||||
assert.equal(f.players.length, 0);
|
||||
assert.equal(f.view().state, 'idle');
|
||||
});
|
||||
|
||||
test("entering the Cockpit without the page's screen in the page removes the player", () => {
|
||||
const f = fixture({ withCockpitHost: false });
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
f.store.act('playLive');
|
||||
f.dispatch('gev:cockpit-mode-changed', { active: true });
|
||||
assert.equal(f.players[0].destroyed, 1);
|
||||
assert.equal(f.players.length, 1);
|
||||
assert.equal(
|
||||
f.view().state,
|
||||
'idle',
|
||||
'the view starts it once its screen is there',
|
||||
);
|
||||
assert.equal(f.store.act('playLive'), false, 'still no screen');
|
||||
});
|
||||
|
||||
test("constructed with the Cockpit already on, playLive uses the page's screen", () => {
|
||||
const f = fixture({ cockpitMode: true });
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
assert.equal(f.store.act('playLive'), true);
|
||||
assert.equal(f.players[0].options.host, f.cockpitHost);
|
||||
});
|
||||
|
||||
test('the chosen stream going from the list stops it and picks the first that remains', () => {
|
||||
const f = fixture();
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
f.store.act('cycleLive', 1);
|
||||
f.store.act('playLive');
|
||||
f.setKeys(['station:other']);
|
||||
f.running()[0].callback();
|
||||
assert.equal(f.players[0].destroyed, 1);
|
||||
assert.equal(f.view().current.id, 'other');
|
||||
assert.equal(f.view().state, 'idle');
|
||||
});
|
||||
|
||||
test('destroy stops the stream, detaches the actions and publishes nothing', () => {
|
||||
const f = fixture();
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
f.store.act('playLive');
|
||||
f.controls.destroy();
|
||||
assert.equal(f.players[0].destroyed, 1);
|
||||
assert.equal(f.view(), null);
|
||||
assert.equal(f.store.act('playLive'), undefined, 'no owner answers');
|
||||
assert.equal(f.running().length, 0);
|
||||
const before = f.published.length;
|
||||
f.select();
|
||||
assert.equal(f.published.length, before, 'events after destroy are ignored');
|
||||
});
|
||||
|
||||
test('the 2 s refresh publishes nothing when nothing changed', () => {
|
||||
const f = fixture();
|
||||
f.setKeys(['station:test']);
|
||||
f.select();
|
||||
const count = f.published.length;
|
||||
for (const timer of f.running()) timer.callback();
|
||||
for (const timer of f.running()) timer.callback();
|
||||
assert.equal(f.published.length, count, 'the same view is not sent again');
|
||||
f.store.act('playLive');
|
||||
assert.ok(f.published.length > count, 'a change is');
|
||||
});
|
||||
@@ -0,0 +1,261 @@
|
||||
// src/ui/livePanel.test.mjs — the LIVE panel renders what LiveControls
|
||||
// publishes, over happy-dom; it starts the stream as soon as one is chosen,
|
||||
// collapsed or not, and its controls reach the store's owner.
|
||||
import '../testSupport/registerDom.mjs';
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createPinia } from 'pinia';
|
||||
import { createApp, nextTick } from 'vue';
|
||||
import { useLiveStore } from './stores/live.js';
|
||||
import { usePanelChromeStore } from './stores/panelChrome.js';
|
||||
import LivePanel from './views/panels/LivePanel.vue';
|
||||
|
||||
const settle = async () => {
|
||||
await nextTick();
|
||||
await nextTick();
|
||||
};
|
||||
|
||||
function fixture(t) {
|
||||
document.body.replaceChildren();
|
||||
const host = document.body.appendChild(document.createElement('div'));
|
||||
const pinia = createPinia();
|
||||
const app = createApp(LivePanel).use(pinia);
|
||||
app.mount(host);
|
||||
t.after(() => app.unmount());
|
||||
const store = useLiveStore(pinia);
|
||||
const acted = [];
|
||||
store.connect({
|
||||
cycleLive: (direction) => acted.push(['cycle', direction]),
|
||||
playLive: () => acted.push(['play']),
|
||||
stopLive: () => acted.push(['stop']),
|
||||
retryLive: () => acted.push(['retry']),
|
||||
hideLive: (where) => acted.push(['hide', where]),
|
||||
});
|
||||
const chrome = usePanelChromeStore(pinia);
|
||||
const token = chrome.connect({ toggle() {}, pin() {} });
|
||||
const setOpen = async (open) => {
|
||||
chrome.publish(token, 'live-panel', { collapsed: !open });
|
||||
await settle();
|
||||
};
|
||||
const $ = (id) => document.getElementById(id);
|
||||
const publish = async (view) => {
|
||||
store.publish(
|
||||
view && {
|
||||
label: 'ISS (ZARYA)',
|
||||
streams: [
|
||||
{ id: 'iss-exterior', title: 'Exterior cameras', owner: 'NASA' },
|
||||
{
|
||||
id: 'iss-crew',
|
||||
title: 'Live video and space-to-ground audio',
|
||||
owner: 'NASA',
|
||||
},
|
||||
],
|
||||
index: 0,
|
||||
count: 2,
|
||||
current: {
|
||||
id: 'iss-exterior',
|
||||
title: 'Exterior cameras',
|
||||
owner: 'NASA',
|
||||
ownerUrl: 'https://www.youtube.com/@NASA',
|
||||
note: 'NASA video, via YouTube',
|
||||
watchUrl: 'https://www.youtube.com/watch?v=ROboUHfPUrU',
|
||||
},
|
||||
state: 'idle',
|
||||
reason: null,
|
||||
...view,
|
||||
},
|
||||
);
|
||||
await settle();
|
||||
};
|
||||
return { $, publish, acted, setOpen, chrome, token };
|
||||
}
|
||||
|
||||
test('without a view the section is hidden and shows OFF', (t) => {
|
||||
const { $, acted } = fixture(t);
|
||||
assert.equal($('live-panel').hidden, true);
|
||||
assert.equal($('live-badge-text').textContent, 'OFF');
|
||||
assert.equal(
|
||||
$('live-player-host'),
|
||||
null,
|
||||
'no screen until a stream is offered',
|
||||
);
|
||||
assert.deepEqual(acted, [], 'nothing to start');
|
||||
});
|
||||
|
||||
test('a view shows the subject, the stream and Play under the IP notice, and loads nothing by itself', async (t) => {
|
||||
const { $, publish, acted } = fixture(t);
|
||||
await publish({});
|
||||
const panel = $('live-panel');
|
||||
assert.equal(panel.hidden, false);
|
||||
assert.equal(panel.querySelector('.live-subject').textContent, 'ISS (ZARYA)');
|
||||
assert.equal($('live-stream-title').textContent, 'Exterior cameras · 1/2');
|
||||
assert.ok($('live-previous-btn'));
|
||||
assert.ok($('live-next-btn'));
|
||||
assert.ok($('live-player-host'), 'the screen is in the page for the player');
|
||||
assert.equal(
|
||||
$('live-watch-link').getAttribute('href'),
|
||||
'https://www.youtube.com/watch?v=ROboUHfPUrU',
|
||||
);
|
||||
assert.equal($('live-watch-link').getAttribute('rel'), 'noopener noreferrer');
|
||||
assert.deepEqual(acted, [], 'selecting the station loads no player');
|
||||
// The notice that YouTube sees the viewer's IP address comes before Play.
|
||||
const notice = panel.querySelector('.live-privacy');
|
||||
const play = $('live-play-btn');
|
||||
assert.ok(notice && play);
|
||||
assert.match(notice.textContent, /sees your IP address/);
|
||||
assert.equal(
|
||||
notice.compareDocumentPosition(play) & Node.DOCUMENT_POSITION_FOLLOWING,
|
||||
Node.DOCUMENT_POSITION_FOLLOWING,
|
||||
'the notice is above Play',
|
||||
);
|
||||
assert.equal($('live-status').textContent, 'Click to play');
|
||||
play.click();
|
||||
assert.deepEqual(acted, [['play']], 'Play is what loads the player');
|
||||
// Loading and playing hide Play and ask for nothing more.
|
||||
await publish({ state: 'loading' });
|
||||
assert.equal($('live-play-btn'), null);
|
||||
await publish({ state: 'playing' });
|
||||
assert.deepEqual(acted, [['play']]);
|
||||
});
|
||||
|
||||
test('a different stream chosen while idle waits for Play too', async (t) => {
|
||||
const { $, publish, acted } = fixture(t);
|
||||
await publish({});
|
||||
await publish({
|
||||
current: {
|
||||
id: 'iss-crew',
|
||||
title: 'Live video and space-to-ground audio',
|
||||
owner: 'NASA',
|
||||
ownerUrl: 'https://www.youtube.com/@NASA',
|
||||
note: '',
|
||||
watchUrl: 'https://www.youtube.com/watch?v=M3HKLzjvKPc',
|
||||
},
|
||||
index: 1,
|
||||
});
|
||||
assert.deepEqual(acted, []);
|
||||
assert.ok($('live-play-btn'));
|
||||
});
|
||||
|
||||
test('collapsing the section, or Context, stops the player; opening it starts nothing', async (t) => {
|
||||
const { $, publish, acted, setOpen, chrome, token } = fixture(t);
|
||||
await setOpen(true);
|
||||
await publish({ state: 'playing' });
|
||||
assert.deepEqual(acted, [], 'already playing: nothing to start');
|
||||
await setOpen(false);
|
||||
assert.deepEqual(acted, [['hide', 'section']], 'nothing plays unseen');
|
||||
assert.ok($('live-player-host'), 'the screen keeps its element');
|
||||
await setOpen(true);
|
||||
assert.deepEqual(acted, [['hide', 'section']], 'opening starts nothing');
|
||||
chrome.publish(token, 'global-context-panel', { collapsed: true });
|
||||
await settle();
|
||||
assert.deepEqual(acted, [
|
||||
['hide', 'section'],
|
||||
['hide', 'section'],
|
||||
]);
|
||||
});
|
||||
|
||||
test('while playing the badge says ON AIR with the blinking dot, and there is no card', async (t) => {
|
||||
const { $, publish } = fixture(t);
|
||||
await publish({ state: 'playing' });
|
||||
const panel = $('live-panel');
|
||||
assert.equal(panel.classList.contains('live-on-air'), true);
|
||||
assert.equal($('live-badge-text').textContent, 'ON AIR');
|
||||
assert.equal(
|
||||
panel.querySelector('.live-dot').classList.contains('on-air'),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
panel.querySelector('.live-screen').classList.contains('active'),
|
||||
true,
|
||||
);
|
||||
assert.equal(panel.querySelector('.live-card'), null);
|
||||
assert.equal($('live-status').textContent, 'Live');
|
||||
});
|
||||
|
||||
test('starting shows the waiting dot and says LOADING', async (t) => {
|
||||
const { $, publish } = fixture(t);
|
||||
await publish({ state: 'loading' });
|
||||
assert.equal($('live-badge-text').textContent, 'LOADING');
|
||||
assert.equal(
|
||||
$('live-panel').querySelector('.live-dot').classList.contains('waiting'),
|
||||
true,
|
||||
);
|
||||
assert.equal($('live-status').textContent, 'Starting…');
|
||||
});
|
||||
|
||||
test('an offline stream shows the fallback card with Try again, and is not restarted by itself', async (t) => {
|
||||
const { $, publish, acted } = fixture(t);
|
||||
await publish({ state: 'offline', reason: 'timeout' });
|
||||
const card = $('live-panel').querySelector('.live-card');
|
||||
assert.equal(card.classList.contains('offline'), true);
|
||||
assert.equal(card.querySelector('strong').textContent, 'Stream is offline');
|
||||
assert.equal($('live-status').textContent, 'Stream is offline');
|
||||
assert.deepEqual(acted, [], 'offline is left to Try again');
|
||||
$('live-retry-btn').click();
|
||||
assert.deepEqual(acted, [['retry']]);
|
||||
});
|
||||
|
||||
test('a stream that cannot be embedded says so, without Try again', async (t) => {
|
||||
const { $, publish, acted } = fixture(t);
|
||||
await publish({ state: 'unavailable', reason: 'error-150' });
|
||||
const card = $('live-panel').querySelector('.live-card');
|
||||
assert.equal(card.classList.contains('unavailable'), true);
|
||||
assert.equal(
|
||||
card.querySelector('strong').textContent,
|
||||
'This stream cannot play here',
|
||||
);
|
||||
assert.equal($('live-retry-btn'), null);
|
||||
assert.equal($('live-status').textContent, 'This stream cannot play here');
|
||||
assert.deepEqual(acted, []);
|
||||
});
|
||||
|
||||
test('the arrows step through the streams', async (t) => {
|
||||
const { $, publish, acted } = fixture(t);
|
||||
await publish({ state: 'playing' });
|
||||
$('live-next-btn').click();
|
||||
$('live-previous-btn').click();
|
||||
assert.deepEqual(acted, [
|
||||
['cycle', 1],
|
||||
['cycle', -1],
|
||||
]);
|
||||
});
|
||||
|
||||
test('with one stream there are no arrows and no counter', async (t) => {
|
||||
const { $, publish } = fixture(t);
|
||||
await publish({
|
||||
count: 1,
|
||||
streams: [{ id: 'iss-exterior', title: 'Exterior cameras', owner: 'NASA' }],
|
||||
});
|
||||
assert.equal($('live-previous-btn'), null);
|
||||
assert.equal($('live-next-btn'), null);
|
||||
assert.equal($('live-stream-title').textContent, 'Exterior cameras');
|
||||
});
|
||||
|
||||
test('publishing null hides the section again', async (t) => {
|
||||
const { $, publish } = fixture(t);
|
||||
await publish({});
|
||||
await publish(null);
|
||||
assert.equal($('live-panel').hidden, true);
|
||||
});
|
||||
|
||||
test('a language change keeps the same screen element and neither stops nor restarts the stream', async (t) => {
|
||||
// The player is built into #live-player-host by LiveControls, outside Vue.
|
||||
// A locale change re-renders the panel's words; the screen must be the
|
||||
// same element afterwards, with nothing asked of the owner, or the stream
|
||||
// would be torn down and rebuilt with every language switch.
|
||||
const { getLocale, setLocale } = await import('../i18n/index.js');
|
||||
const originalLocale = getLocale();
|
||||
t.after(() => setLocale(originalLocale));
|
||||
const { $, publish, acted } = fixture(t);
|
||||
await publish({ state: 'playing' });
|
||||
const screen = $('live-player-host');
|
||||
assert.ok(screen, 'the screen is in the page while a stream is offered');
|
||||
const marker = screen.appendChild(document.createElement('span'));
|
||||
const askedBefore = acted.length;
|
||||
setLocale(originalLocale === 'fr' ? 'es' : 'fr');
|
||||
await settle();
|
||||
assert.equal($('live-player-host'), screen, 'the same screen element');
|
||||
assert.equal(marker.parentNode, screen, 'what LiveControls put in it stays');
|
||||
assert.equal(acted.length, askedBefore, 'no play, stop or retry asked');
|
||||
assert.equal($('live-panel').hidden, false);
|
||||
});
|
||||
@@ -0,0 +1,53 @@
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { computed } from 'vue';
|
||||
import { t } from '../i18n/index.js';
|
||||
import { useLiveStore } from './stores/live.js';
|
||||
|
||||
/**
|
||||
* What the LIVE section in Context and the Cockpit briefing's LIVE page
|
||||
* share: the live store's view and its state read as words. Each view calls
|
||||
* this from its setup and renders the result; the controls call LiveControls
|
||||
* through `act`. Nothing here starts the stream: the views show Play while
|
||||
* it is `idle`, and the player is loaded only when the viewer presses it.
|
||||
*/
|
||||
export function useLiveScreen() {
|
||||
const store = useLiveStore();
|
||||
const { act } = store;
|
||||
const { view } = storeToRefs(store);
|
||||
const playing = computed(() => view.value?.state === 'playing');
|
||||
const loading = computed(() => view.value?.state === 'loading');
|
||||
const offline = computed(() => view.value?.state === 'offline');
|
||||
const unavailable = computed(() => view.value?.state === 'unavailable');
|
||||
const idle = computed(
|
||||
() => Boolean(view.value) && view.value.state === 'idle',
|
||||
);
|
||||
const badgeText = computed(() =>
|
||||
playing.value ? t('ON AIR') : loading.value ? t('LOADING') : t('OFF'),
|
||||
);
|
||||
const statusText = computed(() => {
|
||||
switch (view.value?.state) {
|
||||
case 'playing':
|
||||
return t('Live');
|
||||
case 'offline':
|
||||
return t('Stream is offline');
|
||||
case 'unavailable':
|
||||
return t('This stream cannot play here');
|
||||
case 'loading':
|
||||
return t('Starting…');
|
||||
default:
|
||||
return t('Click to play');
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
view,
|
||||
act,
|
||||
idle,
|
||||
playing,
|
||||
loading,
|
||||
offline,
|
||||
unavailable,
|
||||
badgeText,
|
||||
statusText,
|
||||
};
|
||||
}
|
||||
+58
-51
@@ -49,6 +49,11 @@ const meta = () =>
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' · ');
|
||||
// The card's face is the slot of a UiButton, which renders inside the
|
||||
// button: a new item alone would reach it only on a later tick, but the panel
|
||||
// patches synchronously. A slot given under a condition (`redrawWithView`,
|
||||
// always true) is redrawn whenever this card is, so it keeps up.
|
||||
const redrawWithView = true;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -58,60 +63,62 @@ const meta = () =>
|
||||
:data-report-id="item.id"
|
||||
:style="{ '--news-color': item.color }"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="news-card__main ui-focus"
|
||||
<UiButton
|
||||
class="news-card__main"
|
||||
:aria-expanded="open ? 'true' : 'false'"
|
||||
@click="onChoose(item)"
|
||||
><template v-if="redrawWithView" #default>
|
||||
<span v-if="item.picture && !pictureFailed" class="news-card__thumb"
|
||||
><img
|
||||
:src="item.picture.url"
|
||||
alt=""
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
referrerpolicy="no-referrer"
|
||||
v-on="{ error: dropPicture }"
|
||||
/><span
|
||||
v-if="item.picture.video && !clipFailed"
|
||||
class="news-card__play"
|
||||
role="img"
|
||||
:aria-label="t('Video')"
|
||||
>▶</span
|
||||
><span v-if="item.picture.credit" class="news-card__credit">{{
|
||||
item.picture.credit
|
||||
}}</span></span
|
||||
>
|
||||
<span class="news-card__title">{{ item.title }}</span>
|
||||
<span v-if="item.original" class="news-card__note">{{
|
||||
t('English headline by the model')
|
||||
}}</span>
|
||||
<span class="news-card__meta ui-mono"
|
||||
><span
|
||||
class="news-card__marker"
|
||||
:class="{ solid: item.solid }"
|
||||
role="img"
|
||||
:aria-label="item.severityLabel"
|
||||
:title="item.severityLabel"
|
||||
><svg viewBox="0 0 16 16" aria-hidden="true">
|
||||
<path :d="item.icon" /></svg></span
|
||||
><span v-if="item.severity >= 2" class="news-card__severity">{{
|
||||
item.severityLabel
|
||||
}}</span
|
||||
>{{ item.severity >= 2 ? ` · ${meta()}` : meta() }}</span
|
||||
>
|
||||
<span v-if="item.sides" class="news-card__sides">{{ item.sides }}</span>
|
||||
<span v-if="item.chips.length" class="news-card__chips"
|
||||
><span
|
||||
v-for="chip in item.chips"
|
||||
:key="`${chip.kind}:${chip.label}`"
|
||||
class="news-chip"
|
||||
:class="`news-chip--${chip.kind}`"
|
||||
>{{ chip.label }}</span
|
||||
></span
|
||||
>
|
||||
<span v-if="item.via" class="news-card__via ui-mono">{{
|
||||
item.via
|
||||
}}</span>
|
||||
</template></UiButton
|
||||
>
|
||||
<span v-if="item.picture && !pictureFailed" class="news-card__thumb"
|
||||
><img
|
||||
:src="item.picture.url"
|
||||
alt=""
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
referrerpolicy="no-referrer"
|
||||
v-on="{ error: dropPicture }"
|
||||
/><span
|
||||
v-if="item.picture.video && !clipFailed"
|
||||
class="news-card__play"
|
||||
role="img"
|
||||
:aria-label="t('Video')"
|
||||
>▶</span
|
||||
><span v-if="item.picture.credit" class="news-card__credit">{{
|
||||
item.picture.credit
|
||||
}}</span></span
|
||||
>
|
||||
<span class="news-card__title">{{ item.title }}</span>
|
||||
<span v-if="item.original" class="news-card__note">{{
|
||||
t('English headline by the model')
|
||||
}}</span>
|
||||
<span class="news-card__meta ui-mono"
|
||||
><span
|
||||
class="news-card__marker"
|
||||
:class="{ solid: item.solid }"
|
||||
role="img"
|
||||
:aria-label="item.severityLabel"
|
||||
:title="item.severityLabel"
|
||||
><svg viewBox="0 0 16 16" aria-hidden="true">
|
||||
<path :d="item.icon" /></svg></span
|
||||
><span v-if="item.severity >= 2" class="news-card__severity">{{
|
||||
item.severityLabel
|
||||
}}</span
|
||||
>{{ item.severity >= 2 ? ` · ${meta()}` : meta() }}</span
|
||||
>
|
||||
<span v-if="item.sides" class="news-card__sides">{{ item.sides }}</span>
|
||||
<span v-if="item.chips.length" class="news-card__chips"
|
||||
><span
|
||||
v-for="chip in item.chips"
|
||||
:key="`${chip.kind}:${chip.label}`"
|
||||
class="news-chip"
|
||||
:class="`news-chip--${chip.kind}`"
|
||||
>{{ chip.label }}</span
|
||||
></span
|
||||
>
|
||||
<span v-if="item.via" class="news-card__via ui-mono">{{ item.via }}</span>
|
||||
</button>
|
||||
<div v-if="open" class="news-card__open">
|
||||
<video
|
||||
v-if="item.picture?.video && !clipFailed"
|
||||
|
||||
+10
-6
@@ -472,6 +472,9 @@ export function startGuide(steps, { title = '' } = {}) {
|
||||
nextLabel: t('Next'),
|
||||
nextHidden: false,
|
||||
nextQuiet: false,
|
||||
// The extra rings for a step's further targets, after the callout; the
|
||||
// count only grows, and rings a step does not use are faded out.
|
||||
subRings: 0,
|
||||
// Announces each step once; the dialog itself is not a live region, so
|
||||
// its buttons and progress are not read out on every change.
|
||||
status: '',
|
||||
@@ -511,7 +514,9 @@ export function startGuide(steps, { title = '' } = {}) {
|
||||
const root = paint().component.subTree.children[0].el;
|
||||
const ring = root.querySelector(':scope > .gev-guide-ring');
|
||||
const callout = root.querySelector(':scope > .gev-guide-callout');
|
||||
const subRings = [];
|
||||
// The extra rings, read again from the rendered tree whenever more are
|
||||
// drawn.
|
||||
let subRings = [];
|
||||
|
||||
const live = steps.filter(Boolean);
|
||||
let index = -1;
|
||||
@@ -657,11 +662,10 @@ export function startGuide(steps, { title = '' } = {}) {
|
||||
width: `${main.width + pad * 2}px`,
|
||||
height: `${main.height + pad * 2}px`,
|
||||
});
|
||||
while (subRings.length < rest.length) {
|
||||
const sub = doc.createElement('div');
|
||||
sub.className = 'gev-guide-ring gev-guide-ring--sub';
|
||||
root.append(sub);
|
||||
subRings.push(sub);
|
||||
if (subRings.length < rest.length) {
|
||||
view.subRings = rest.length;
|
||||
paint();
|
||||
subRings = [...root.querySelectorAll(':scope > .gev-guide-ring--sub')];
|
||||
}
|
||||
subRings.forEach((sub, i) => {
|
||||
const box = rest[i];
|
||||
|
||||
@@ -134,3 +134,39 @@ test('a walk started while Vue mounts something else still starts and ends', asy
|
||||
assert.equal($('.gev-guide'), null);
|
||||
assert.equal(document.activeElement, field);
|
||||
});
|
||||
|
||||
test('each further target of a step gets its own ring after the callout', async (t) => {
|
||||
const { target } = fixture(t);
|
||||
const more = document.body.appendChild(document.createElement('button'));
|
||||
const box = (left) => () => ({
|
||||
left,
|
||||
top: 20,
|
||||
right: left + 30,
|
||||
bottom: 50,
|
||||
width: 30,
|
||||
height: 30,
|
||||
});
|
||||
target.getBoundingClientRect = box(10);
|
||||
more.getBoundingClientRect = box(100);
|
||||
let targets = [target, more];
|
||||
startGuide([{ targets: () => targets, text: () => 'Press these' }]);
|
||||
const frame = () => new Promise((resolve) => requestAnimationFrame(resolve));
|
||||
await settle();
|
||||
await frame();
|
||||
const subs = () => [...document.querySelectorAll('.gev-guide-ring--sub')];
|
||||
assert.equal(subs().length, 1);
|
||||
const [sub] = subs();
|
||||
assert.equal(sub.className, 'gev-guide-ring gev-guide-ring--sub');
|
||||
assert.equal(sub.parentElement, $('.gev-guide'));
|
||||
assert.equal(sub.previousElementSibling, $('.gev-guide-callout'));
|
||||
assert.equal(sub.childElementCount, 0);
|
||||
assert.equal(sub.style.opacity, '1');
|
||||
assert.equal(sub.style.left, '96px');
|
||||
assert.equal(sub.style.width, '38px');
|
||||
// A step with fewer targets keeps the ring, faded out.
|
||||
targets = [target];
|
||||
$('.gev-guide-ring').dispatchEvent(new Event('scroll', { bubbles: true }));
|
||||
await frame();
|
||||
assert.deepEqual(subs(), [sub]);
|
||||
assert.equal(sub.style.opacity, '0');
|
||||
});
|
||||
@@ -68,7 +68,7 @@ test('before RadioControls renders, the panel shows its initial markup', (t) =>
|
||||
assert.equal($('radio-filter').options.length, 1);
|
||||
assert.equal($('radio-filter').options[0].value, 'all');
|
||||
assert.equal($('radio-filter').options[0].textContent, 'All');
|
||||
assert.equal($('radio-play-btn').getAttribute('class'), null);
|
||||
assert.equal(coreClasses($('radio-play-btn')), '');
|
||||
assert.equal($('radio-play-btn').disabled, true);
|
||||
assert.equal($('radio-volume').value, '80');
|
||||
assert.equal($('radio-volume-value').textContent, '80%');
|
||||
@@ -120,7 +120,7 @@ test('the panel renders the presented directory, station, transport and playback
|
||||
assert.equal($('radio-station-homepage').getAttribute('href'), 'https://example.org/');
|
||||
assert.equal($('radio-station-homepage').hidden, false);
|
||||
const play = $('radio-play-btn');
|
||||
assert.equal(play.className, 'active');
|
||||
assert.equal(coreClasses(play), 'active');
|
||||
assert.equal(play.textContent, 'PAUSE');
|
||||
assert.equal(play.getAttribute('aria-label'), 'Pause selected radio station');
|
||||
assert.equal($('radio-prev-btn').disabled, false);
|
||||
@@ -128,7 +128,7 @@ test('the panel renders the presented directory, station, transport and playback
|
||||
assert.equal($('radio-playback-state').textContent, 'Playing KJAZ');
|
||||
|
||||
await render({ audioState: 'error', filter: 'all' });
|
||||
assert.equal(play.className, '');
|
||||
assert.equal(coreClasses(play), '');
|
||||
assert.equal($('radio-playback-state').className, 'radio-playback-state error');
|
||||
assert.equal($('radio-station-homepage').hasAttribute('href'), false);
|
||||
assert.equal($('radio-station-homepage').hidden, true);
|
||||
|
||||
+33
-23
@@ -2,6 +2,7 @@
|
||||
import { computed, onBeforeUnmount } from 'vue';
|
||||
import RailCardBlocks from './RailCardBlocks.vue';
|
||||
import UiBadge from '../kit/UiBadge.vue';
|
||||
import UiButton from '../kit/UiButton.vue';
|
||||
|
||||
// One keyed card: a disclosure header and its blocks. The owner decides
|
||||
// which card is open.
|
||||
@@ -20,6 +21,12 @@ onBeforeUnmount(() => {
|
||||
live = false;
|
||||
});
|
||||
const select = () => live && props.onOpen(props.card.id);
|
||||
// The header's contents are the slot of a UiButton, which renders inside the
|
||||
// button: a new card alone would reach them only on a later tick, but the
|
||||
// owner patches synchronously and measures at once. A slot given under a
|
||||
// condition (`redrawWithView`, always true) is redrawn whenever this card is,
|
||||
// so it keeps up.
|
||||
const redrawWithView = true;
|
||||
</script>
|
||||
|
||||
<script>
|
||||
@@ -32,33 +39,36 @@ const nextBodyId = () => ++bodies;
|
||||
:class="`rail-card${cardClassName ? ` ${cardClassName}` : ''}${open ? ' is-open' : ''}`"
|
||||
:data-card-id="card.id"
|
||||
:data-open="String(open)"
|
||||
><button
|
||||
><UiButton
|
||||
class="rail-card-header"
|
||||
type="button"
|
||||
:aria-controls="bodyId"
|
||||
:aria-expanded="String(open)"
|
||||
@click="select"
|
||||
><span class="rail-card-labels"
|
||||
><span class="rail-card-heading"
|
||||
><span class="data-icon" aria-hidden="true" :hidden="!card.icon">{{
|
||||
card.icon || ''
|
||||
}}</span
|
||||
><span class="rail-card-title rail-card-nowrap" :title="card.title">{{
|
||||
card.title
|
||||
}}</span></span
|
||||
><UiBadge
|
||||
:class="`gev-status-badge--plain rail-card-badge${badgeClassName ? ` ${badgeClassName}` : ''}`"
|
||||
:hidden="!card.badge"
|
||||
>{{ card.badge || '' }}</UiBadge
|
||||
></span
|
||||
><span class="rail-card-disclosure" aria-hidden="true">{{
|
||||
open ? '▾' : '▸'
|
||||
}}</span
|
||||
><span
|
||||
:class="`rail-card-compact${card.compactStatus ? ' status' : ''}`"
|
||||
:hidden="open"
|
||||
>{{ card.compact || '' }}</span
|
||||
></button
|
||||
><template v-if="redrawWithView" #default
|
||||
><span class="rail-card-labels"
|
||||
><span class="rail-card-heading"
|
||||
><span class="data-icon" aria-hidden="true" :hidden="!card.icon">{{
|
||||
card.icon || ''
|
||||
}}</span
|
||||
><span
|
||||
class="rail-card-title rail-card-nowrap"
|
||||
:title="card.title"
|
||||
>{{ card.title }}</span
|
||||
></span
|
||||
><UiBadge
|
||||
:class="`gev-status-badge--plain rail-card-badge${badgeClassName ? ` ${badgeClassName}` : ''}`"
|
||||
:hidden="!card.badge"
|
||||
>{{ card.badge || '' }}</UiBadge
|
||||
></span
|
||||
><span class="rail-card-disclosure" aria-hidden="true">{{
|
||||
open ? '▾' : '▸'
|
||||
}}</span
|
||||
><span
|
||||
:class="`rail-card-compact${card.compactStatus ? ' status' : ''}`"
|
||||
:hidden="open"
|
||||
>{{ card.compact || '' }}</span
|
||||
></template
|
||||
></UiButton
|
||||
><div :id="bodyId" class="rail-card-body" :hidden="!open"
|
||||
><RailCardBlocks
|
||||
:blocks="card.blocks || []"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import { onBeforeUnmount } from 'vue';
|
||||
import { t } from '../../i18n/index.js';
|
||||
import { formatScaleRange } from '../unitLabels.js';
|
||||
import UiButton from '../kit/UiButton.vue';
|
||||
import UiCloseButton from '../kit/UiCloseButton.vue';
|
||||
import RailCardSetting from './RailCardSetting.vue';
|
||||
import RailChips from './RailChips.vue';
|
||||
@@ -166,28 +167,23 @@ function legendView(legend) {
|
||||
:title="action.title || undefined"
|
||||
@click="dispatch(action, block)"
|
||||
>{{ action.label }}</a
|
||||
><button
|
||||
><UiButton
|
||||
v-else
|
||||
:class="[
|
||||
'data-toggle-chip',
|
||||
{ active: action.pressed, 'is-reserved': action.reserved },
|
||||
]"
|
||||
type="button"
|
||||
:class="['data-toggle-chip', { 'is-reserved': action.reserved }]"
|
||||
:data-action-id="action.id"
|
||||
:title="action.title || undefined"
|
||||
:disabled="Boolean(action.disabled)"
|
||||
:aria-pressed="
|
||||
action.pressed === undefined
|
||||
? undefined
|
||||
: String(Boolean(action.pressed))
|
||||
:pressed="
|
||||
action.pressed === undefined ? undefined : Boolean(action.pressed)
|
||||
"
|
||||
pressed-class="active"
|
||||
:aria-hidden="
|
||||
action.reserved === undefined
|
||||
? undefined
|
||||
: String(Boolean(action.reserved))
|
||||
"
|
||||
@click="dispatch(action, block)"
|
||||
>{{ action.label }}</button
|
||||
>{{ action.label }}</UiButton
|
||||
><span class="rail-card-action-hint" :hidden="!action.hint">{{
|
||||
action.hint || ''
|
||||
}}</span></template
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup>
|
||||
import UiButton from '../kit/UiButton.vue';
|
||||
import UiIcon from '../kit/UiIcon.vue';
|
||||
|
||||
// Keyed chips shared by rail cards; the owner decides what a click does.
|
||||
// An `icon` chip shows a Material Symbol (named in index.html's `icon_names`
|
||||
@@ -29,11 +30,9 @@ const chipClass = (chip) =>
|
||||
:disabled="Boolean(chip.disabled)"
|
||||
:aria-busy="String(Boolean(chip.busy))"
|
||||
@click="onSelect(chip)"
|
||||
><span
|
||||
v-if="chip.icon"
|
||||
class="material-symbols-outlined"
|
||||
aria-hidden="true"
|
||||
>{{ chip.icon }}</span
|
||||
><template v-else>{{ chip.label }}</template></UiButton
|
||||
><UiIcon v-if="chip.icon" :name="chip.icon" :size="null" /><template
|
||||
v-else
|
||||
>{{ chip.label }}</template
|
||||
></UiButton
|
||||
>
|
||||
</template>
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup>
|
||||
import { onMounted, onUpdated, ref } from 'vue';
|
||||
import UiButton from '../kit/UiButton.vue';
|
||||
|
||||
// An ordered list whose rows keep their identity, so a focused row stays.
|
||||
const props = defineProps({
|
||||
@@ -10,7 +11,7 @@ const props = defineProps({
|
||||
const root = ref(null);
|
||||
|
||||
const rowClass = (item) =>
|
||||
`data-row-list-item${item.disabled ? ' note' : ''}${item.active ? ' active' : ''}${item.current ? ' current' : ''}`;
|
||||
`data-row-list-item${item.disabled ? ' note' : ''}${item.current ? ' current' : ''}`;
|
||||
|
||||
// Follow the flight, but never steal a scroll the reader is making
|
||||
// themselves: only when the step actually changed.
|
||||
@@ -43,19 +44,19 @@ onUpdated(followCurrent);
|
||||
v-for="item in list?.items ?? []"
|
||||
:key="item.id"
|
||||
:data-list-item-id="item.id"
|
||||
><button
|
||||
type="button"
|
||||
><UiButton
|
||||
:class="rowClass(item)"
|
||||
:data-list-item-id="item.id"
|
||||
:disabled="Boolean(item.disabled)"
|
||||
:aria-current="item.current ? 'step' : 'false'"
|
||||
:aria-pressed="item.active ? 'true' : 'false'"
|
||||
:pressed="Boolean(item.active)"
|
||||
pressed-class="active"
|
||||
:title="String(item.text ?? '')"
|
||||
@click="onSelect(item)"
|
||||
><span class="data-row-list-lead">{{ String(item.lead ?? '') }}</span
|
||||
><span class="data-row-list-text">{{
|
||||
String(item.text ?? '')
|
||||
}}</span></button
|
||||
}}</span></UiButton
|
||||
></li
|
||||
></ol
|
||||
>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script setup>
|
||||
import { t } from '../../i18n/index.js';
|
||||
import UiButton from '../kit/UiButton.vue';
|
||||
|
||||
// One imagery day in the strip. The owner computes every value; clicks reach
|
||||
// it through the readout's delegated listener.
|
||||
@@ -46,21 +47,18 @@ defineProps({
|
||||
><div class="ri-card-sensor">{{ card.sensor }}</div
|
||||
><div class="ri-card-cloud">{{ card.cloud }}</div
|
||||
><div class="ri-card-chips"
|
||||
><button
|
||||
><UiButton
|
||||
v-for="chip in card.chips"
|
||||
:key="chip.slot"
|
||||
type="button"
|
||||
:class="[
|
||||
'data-toggle-chip ri-chip',
|
||||
{ active: chip.active, 'is-reserved': chip.reserved },
|
||||
]"
|
||||
:class="['data-toggle-chip ri-chip', { 'is-reserved': chip.reserved }]"
|
||||
tabindex="-1"
|
||||
:data-slot="chip.slot"
|
||||
:disabled="chip.disabled"
|
||||
:aria-pressed="String(chip.active)"
|
||||
:disabled="Boolean(chip.disabled)"
|
||||
:pressed="Boolean(chip.active)"
|
||||
pressed-class="active"
|
||||
:aria-hidden="String(chip.reserved)"
|
||||
:aria-label="chip.ariaLabel"
|
||||
>{{ chip.label }}</button
|
||||
>{{ chip.label }}</UiButton
|
||||
></div
|
||||
></div
|
||||
>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { t } from '../../i18n/index.js';
|
||||
import UiButton from '../kit/UiButton.vue';
|
||||
import UiCloseButton from '../kit/UiCloseButton.vue';
|
||||
import UiSegmented from '../kit/UiSegmented.vue';
|
||||
import RailCardBlocks from '../rail/RailCardBlocks.vue';
|
||||
@@ -51,17 +52,16 @@ const modeOptions = computed(() =>
|
||||
aria-live="polite"
|
||||
:title="view.notice.text"
|
||||
>{{ view.notice.text }}</span
|
||||
><button
|
||||
><UiButton
|
||||
id="ri-zoom-in"
|
||||
:class="[
|
||||
'data-toggle-chip ri-zoom-in',
|
||||
{ 'is-reserved': !view.notice.fit },
|
||||
]"
|
||||
type="button"
|
||||
:title="t('Fly in until the view fits the 1,000 km limit')"
|
||||
:disabled="!view.notice.fit"
|
||||
:aria-hidden="String(!view.notice.fit)"
|
||||
>{{ t('ZOOM IN') }}</button
|
||||
>{{ t('ZOOM IN') }}</UiButton
|
||||
></div
|
||||
><div
|
||||
id="ri-strip"
|
||||
@@ -131,21 +131,18 @@ const modeOptions = computed(() =>
|
||||
max="100"
|
||||
step="1"
|
||||
:aria-label="t('Imagery opacity')"
|
||||
:disabled="!view.opacityEnabled" /><button
|
||||
:disabled="!view.opacityEnabled" /><UiButton
|
||||
id="ri-swap"
|
||||
:class="[
|
||||
'data-toggle-chip ri-swap',
|
||||
{
|
||||
'is-reserved': !view.swap.live,
|
||||
active: view.swap.pressed,
|
||||
},
|
||||
{ 'is-reserved': !view.swap.live },
|
||||
]"
|
||||
type="button"
|
||||
:title="t('Trade the two sides of the divider')"
|
||||
:disabled="!view.swap.live"
|
||||
:aria-hidden="String(!view.swap.live)"
|
||||
:aria-pressed="String(view.swap.pressed)"
|
||||
>{{ t('SWAP') }}</button
|
||||
:pressed="Boolean(view.swap.pressed)"
|
||||
pressed-class="active"
|
||||
>{{ t('SWAP') }}</UiButton
|
||||
><div class="ri-exports"
|
||||
><RailCardBlocks
|
||||
:blocks="view.exports"
|
||||
|
||||
@@ -167,7 +167,10 @@ export class ShareRestoration {
|
||||
feedback,
|
||||
updateFeedback,
|
||||
applyFollowOffset = null,
|
||||
startLayers = [],
|
||||
}) {
|
||||
// The layers a bare address starts with; a link names its own.
|
||||
this._startLayers = startLayers;
|
||||
Object.assign(this, {
|
||||
viewer,
|
||||
navigation,
|
||||
@@ -417,9 +420,11 @@ export class ShareRestoration {
|
||||
this._layerStateRestorePromise = this._layerStateCoordinator.start({
|
||||
shareLayerState: this._initialShareState?.layerState || null,
|
||||
shareCreatedAtMs: this._initialShareState?.sharedAtMs ?? null,
|
||||
// Any valid camera/style share isolates recipient-local preferences,
|
||||
// including legacy and malformed-v2 layer payloads.
|
||||
allowLocalState: !this._initialShareState,
|
||||
// A link restores what it carries; a bare address is a clean start
|
||||
// with the default layers. Saved layer choices never come back on
|
||||
// their own, so clearing the address always resets the view.
|
||||
allowLocalState: false,
|
||||
startLayerIds: this._initialShareState ? [] : this._startLayers,
|
||||
});
|
||||
if (this._initialShareSelectionSuperseded) {
|
||||
this._layerStateCoordinator.cancelPendingShareTracking(
|
||||
|
||||
@@ -0,0 +1,215 @@
|
||||
// src/ui/stationPanel.test.mjs — the STATION panel renders what the
|
||||
// satellites layer publishes, over happy-dom; its controls reach the owner.
|
||||
import '../testSupport/registerDom.mjs';
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createPinia } from 'pinia';
|
||||
import { createApp, nextTick } from 'vue';
|
||||
import { useStationStore } from './stores/station.js';
|
||||
import StationPanel from './views/panels/StationPanel.vue';
|
||||
|
||||
function fixture(t) {
|
||||
document.body.replaceChildren();
|
||||
const host = document.body.appendChild(document.createElement('div'));
|
||||
const pinia = createPinia();
|
||||
const app = createApp(StationPanel).use(pinia);
|
||||
app.mount(host);
|
||||
t.after(() => app.unmount());
|
||||
const store = useStationStore(pinia);
|
||||
const acted = [];
|
||||
store.connect({
|
||||
setStationMode: (mode) => acted.push(['mode', mode]),
|
||||
chooseStation: (group, choice) => acted.push(['choose', group, choice]),
|
||||
slideStation: (slider, value) => acted.push(['slide', slider, value]),
|
||||
resumeStationArm: (group) => acted.push(['resume', group]),
|
||||
zoomStation: () => acted.push(['zoom']),
|
||||
});
|
||||
const $ = (id) => document.getElementById(id);
|
||||
const publish = async (view) => {
|
||||
store.publish(
|
||||
view && {
|
||||
key: 'iss',
|
||||
title: 'ISS',
|
||||
subject: 'ISS (ZARYA)',
|
||||
mode: 'automatic',
|
||||
telemetry: { state: 'live', poseAgeMs: 4200, liveUntilMs: null },
|
||||
sunlit: true,
|
||||
note: 'Computed, not live telemetry.',
|
||||
groups: [
|
||||
{
|
||||
id: 'sun',
|
||||
label: 'Sun position',
|
||||
note: null,
|
||||
kind: 'choices',
|
||||
choices: [
|
||||
{ id: 'follow', label: 'Follow the Sun', active: true },
|
||||
{ id: 'ahead', label: 'Ahead', active: false },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'arm',
|
||||
label: 'Canadarm2 (degrees)',
|
||||
note: null,
|
||||
kind: 'sliders',
|
||||
resume: 'Resume sway',
|
||||
sliders: [
|
||||
{
|
||||
id: 'shoulder',
|
||||
label: 'Shoulder roll',
|
||||
min: -120,
|
||||
max: 120,
|
||||
value: 15,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
zoom: { offered: false, label: 'Zoom to the ISS' },
|
||||
...view,
|
||||
},
|
||||
);
|
||||
await nextTick();
|
||||
};
|
||||
const telemetryText = () => $('station-telemetry').textContent.trim();
|
||||
return { $, publish, acted, telemetryText };
|
||||
}
|
||||
|
||||
test('without a view the section is hidden', (t) => {
|
||||
const { $ } = fixture(t);
|
||||
assert.equal($('station-panel').hidden, true);
|
||||
assert.equal($('station-badge').textContent, '');
|
||||
});
|
||||
|
||||
test('Automatic shows the subject, the live telemetry age, the Sun line and the note', async (t) => {
|
||||
const { $, publish, telemetryText } = fixture(t);
|
||||
await publish({});
|
||||
const panel = $('station-panel');
|
||||
assert.equal(panel.hidden, false);
|
||||
assert.equal($('station-badge').textContent, 'ISS');
|
||||
assert.equal(
|
||||
panel.querySelector('.station-subject').textContent,
|
||||
'ISS (ZARYA)',
|
||||
);
|
||||
assert.equal($('station-automatic-btn').getAttribute('aria-checked'), 'true');
|
||||
assert.equal(
|
||||
$('station-automatic-btn').classList.contains('is-active'),
|
||||
true,
|
||||
);
|
||||
assert.equal($('station-manual-btn').getAttribute('aria-checked'), 'false');
|
||||
assert.equal(telemetryText(), 'Telemetry · updated 4 s ago');
|
||||
assert.equal($('station-telemetry').dataset.tone, 'live');
|
||||
assert.equal($('station-sun').textContent, 'Now: in sunlight');
|
||||
assert.equal(
|
||||
panel.querySelectorAll('.station-group').length,
|
||||
0,
|
||||
'no controls in Automatic',
|
||||
);
|
||||
assert.equal($('station-zoom-btn'), null);
|
||||
});
|
||||
|
||||
test('the status line words each telemetry state, with ages in seconds or minutes', async (t) => {
|
||||
const { $, publish, telemetryText } = fixture(t);
|
||||
await publish({
|
||||
telemetry: { state: 'live', poseAgeMs: 95_000, liveUntilMs: null },
|
||||
});
|
||||
assert.equal(telemetryText(), 'Telemetry · updated 2 min ago');
|
||||
await publish({
|
||||
telemetry: { state: 'no-signal', poseAgeMs: null, liveUntilMs: null },
|
||||
});
|
||||
assert.equal(telemetryText(), 'No signal · computed values');
|
||||
assert.equal($('station-telemetry').dataset.tone, 'waiting');
|
||||
await publish({
|
||||
telemetry: {
|
||||
state: 'no-signal',
|
||||
poseAgeMs: 30_000,
|
||||
liveUntilMs: Date.UTC(2026, 10, 13, 12, 0),
|
||||
},
|
||||
});
|
||||
assert.match(telemetryText(), /^No signal since \S.* · computed values$/);
|
||||
await publish({
|
||||
telemetry: { state: 'unavailable', poseAgeMs: 50_000, liveUntilMs: null },
|
||||
});
|
||||
assert.equal(
|
||||
telemetryText(),
|
||||
'Telemetry unavailable · last update 50 s ago · computed values',
|
||||
);
|
||||
assert.equal($('station-telemetry').dataset.tone, 'off');
|
||||
await publish({
|
||||
telemetry: { state: 'unavailable', poseAgeMs: null, liveUntilMs: null },
|
||||
});
|
||||
assert.equal(telemetryText(), 'Telemetry unavailable · computed values');
|
||||
await publish({
|
||||
telemetry: { state: 'disabled', poseAgeMs: null, liveUntilMs: null },
|
||||
});
|
||||
assert.equal(
|
||||
telemetryText(),
|
||||
'Telemetry not enabled on this server · computed values',
|
||||
);
|
||||
// A station with no feed at all (Tiangong).
|
||||
await publish({
|
||||
telemetry: { state: 'none', poseAgeMs: null, liveUntilMs: null },
|
||||
});
|
||||
assert.equal(telemetryText(), 'No public telemetry · computed values');
|
||||
assert.equal($('station-telemetry').dataset.tone, 'off');
|
||||
await publish({
|
||||
telemetry: { state: 'pending', poseAgeMs: null, liveUntilMs: null },
|
||||
});
|
||||
assert.equal(telemetryText(), 'Connecting to telemetry…');
|
||||
assert.equal($('station-telemetry').dataset.tone, 'waiting');
|
||||
await publish({
|
||||
telemetry: { state: 'idle', poseAgeMs: null, liveUntilMs: null },
|
||||
});
|
||||
assert.equal(telemetryText(), 'Telemetry reads while the model is on screen');
|
||||
assert.equal($('station-telemetry').dataset.tone, 'off');
|
||||
await publish({ sunlit: false });
|
||||
assert.equal($('station-sun').textContent, "Now: in the Earth's shadow");
|
||||
});
|
||||
|
||||
test('Manual shows the groups with the active choice, the sliders and the resume button', async (t) => {
|
||||
const { $, publish, telemetryText, acted } = fixture(t);
|
||||
await publish({ mode: 'manual', sunlit: null });
|
||||
const panel = $('station-panel');
|
||||
assert.equal(panel.classList.contains('station-manual'), true);
|
||||
assert.equal($('station-manual-btn').getAttribute('aria-checked'), 'true');
|
||||
assert.equal(telemetryText(), 'Manual · telemetry paused');
|
||||
assert.equal($('station-telemetry').dataset.tone, 'manual');
|
||||
assert.equal($('station-sun'), null);
|
||||
assert.equal(panel.querySelectorAll('.station-group').length, 2);
|
||||
const follow = panel.querySelector('[data-station-choice="sun:follow"]');
|
||||
const ahead = panel.querySelector('[data-station-choice="sun:ahead"]');
|
||||
assert.equal(follow.getAttribute('aria-pressed'), 'true');
|
||||
assert.equal(follow.classList.contains('is-active'), true);
|
||||
assert.equal(ahead.getAttribute('aria-pressed'), 'false');
|
||||
ahead.click();
|
||||
const slider = $('station-slider-shoulder');
|
||||
assert.ok(slider, 'the slider is in the page');
|
||||
assert.equal(
|
||||
panel.querySelector('.station-slider output').textContent,
|
||||
'15°',
|
||||
);
|
||||
panel.querySelector('[data-station-resume="arm"]').click();
|
||||
assert.deepEqual(acted, [
|
||||
['choose', 'sun', 'ahead'],
|
||||
['resume', 'arm'],
|
||||
]);
|
||||
});
|
||||
|
||||
test('the mode buttons and the zoom button call the owner', async (t) => {
|
||||
const { $, publish, acted } = fixture(t);
|
||||
await publish({ zoom: { offered: true, label: 'Zoom to the ISS' } });
|
||||
$('station-manual-btn').click();
|
||||
$('station-automatic-btn').click();
|
||||
assert.equal($('station-zoom-btn').textContent, 'Zoom to the ISS');
|
||||
$('station-zoom-btn').click();
|
||||
assert.deepEqual(acted, [
|
||||
['mode', 'manual'],
|
||||
['mode', 'automatic'],
|
||||
['zoom'],
|
||||
]);
|
||||
});
|
||||
|
||||
test('publishing null hides the section again', async (t) => {
|
||||
const { $, publish } = fixture(t);
|
||||
await publish({});
|
||||
await publish(null);
|
||||
assert.equal($('station-panel').hidden, true);
|
||||
});
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { markRaw, shallowRef } from 'vue';
|
||||
import { createOwners } from './owners.js';
|
||||
|
||||
/**
|
||||
* The LIVE section in Context as its view renders it: the streams on offer
|
||||
* for the selected object, the one chosen and the player's state.
|
||||
* LiveControls presents it (`gev-live` store) and answers the section's
|
||||
* controls through act(): `cycleLive`, `playLive`, `stopLive`, `retryLive`.
|
||||
*/
|
||||
export const useLiveStore = defineStore('gev-live', () => {
|
||||
/** The presented section; null while nothing selected has a stream. */
|
||||
const view = shallowRef(null);
|
||||
|
||||
/** @param {?object} next A fresh presentation; every publish re-renders. */
|
||||
function publish(next) {
|
||||
view.value = next && markRaw(next);
|
||||
}
|
||||
|
||||
const { connect, detach, act } = createOwners();
|
||||
|
||||
return { view, publish, connect, detach, act };
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { markRaw, shallowRef } from 'vue';
|
||||
import { createOwners } from './owners.js';
|
||||
|
||||
/**
|
||||
* The STATION section in Context as its view renders it: the selected
|
||||
* station's controls (Automatic or Manual, the moving parts by hand), where
|
||||
* its joint angles come from right now, and a zoom to it. The satellites
|
||||
* layer's station panel presents it (`gev-station` store) and answers its
|
||||
* controls through act(): `setStationMode`, `chooseStation`, `slideStation`,
|
||||
* `resumeStationArm`, `zoomStation`.
|
||||
*/
|
||||
export const useStationStore = defineStore('gev-station', () => {
|
||||
/** The presented section; null while no station is selected. */
|
||||
const view = shallowRef(null);
|
||||
|
||||
/** @param {?object} next A fresh presentation; every publish re-renders. */
|
||||
function publish(next) {
|
||||
view.value = next && markRaw(next);
|
||||
}
|
||||
|
||||
const { connect, detach, act } = createOwners();
|
||||
|
||||
return { view, publish, connect, detach, act };
|
||||
});
|
||||
@@ -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 };
|
||||
},
|
||||
);
|
||||
@@ -6,6 +6,33 @@ import { createPinia } from 'pinia';
|
||||
import { useStoriesStore } from './stores/stories.js';
|
||||
import { storyById } from '../stories/catalog.js';
|
||||
import StoryScreen from './views/stories/StoryScreen.vue';
|
||||
import StoriesView from './views/StoriesView.vue';
|
||||
|
||||
test('the announcement stays unread when a lazy Stories open resolves to false', async (t) => {
|
||||
const host = document.body.appendChild(document.createElement('div'));
|
||||
const pinia = createPinia();
|
||||
const store = useStoriesStore(pinia);
|
||||
let allowed = false;
|
||||
store.connect({ open: async () => allowed });
|
||||
const app = createApp(StoriesView).use(pinia);
|
||||
app.mount(host);
|
||||
t.after(() => {
|
||||
app.unmount();
|
||||
host.remove();
|
||||
localStorage.removeItem('gevStoriesPopSeen');
|
||||
});
|
||||
|
||||
const entry = host.querySelector('#hStories');
|
||||
entry.click();
|
||||
await nextTick();
|
||||
assert.equal(localStorage.getItem('gevStoriesPopSeen'), null);
|
||||
assert.ok(host.querySelector('#hPop'));
|
||||
|
||||
allowed = true;
|
||||
entry.click();
|
||||
await nextTick();
|
||||
assert.equal(localStorage.getItem('gevStoriesPopSeen'), '1');
|
||||
});
|
||||
|
||||
test('the story screen previews a drag and seeks once on release', async (t) => {
|
||||
const host = document.body.appendChild(document.createElement('div'));
|
||||
|
||||
@@ -78,6 +78,8 @@
|
||||
--cockpit-side-panel-width: min(340px, 28vw);
|
||||
/* HUD bottom offset + tallest scaled telemetry block + 20px clear border. */
|
||||
--cockpit-bottom-rail-safe: calc(clamp(84px, 11vh, 118px) + 100px);
|
||||
/* The phone Display/Radio row shares the visor inset with the roll arc. */
|
||||
--cockpit-visor-top: clamp(62px, 9vh, 90px);
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 145;
|
||||
@@ -95,7 +97,7 @@
|
||||
}
|
||||
.cockpit-visor-shell {
|
||||
position: absolute;
|
||||
inset: clamp(62px, 9vh, 90px) clamp(18px, 3vw, 48px) clamp(38px, 5vh, 56px);
|
||||
inset: var(--cockpit-visor-top) clamp(18px, 3vw, 48px) clamp(38px, 5vh, 56px);
|
||||
transform-style: preserve-3d;
|
||||
perspective: 880px;
|
||||
}
|
||||
@@ -703,7 +705,9 @@ html:not([lang='en']) .cockpit-roll-token.is-separator {
|
||||
color: var(--cockpit-accent);
|
||||
font-size: 12px;
|
||||
}
|
||||
.cockpit-heading-caret {
|
||||
/* Inside the compass, so it outranks the kit icon's own display and
|
||||
line height. */
|
||||
.cockpit-compass .cockpit-heading-caret {
|
||||
display: block;
|
||||
height: 20px;
|
||||
color: var(--cockpit-accent);
|
||||
@@ -1952,6 +1956,61 @@ html:not([lang='en']) .cockpit-brief-tabs button {
|
||||
color: #fff;
|
||||
outline: none;
|
||||
}
|
||||
/* The LIVE tab is in the markup whether or not a stream is on offer. */
|
||||
.cockpit-brief-tabs button[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* The briefing's LIVE page: the LIVE section's parts (live.css) in the
|
||||
card's measure. */
|
||||
.cockpit-live-subject {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 6px;
|
||||
color: #fff;
|
||||
font-size: 9px;
|
||||
letter-spacing: 0.1em;
|
||||
}
|
||||
.cockpit-live-subject strong {
|
||||
overflow: hidden;
|
||||
font-weight: 500;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.cockpit-live-subject .live-badge {
|
||||
flex: none;
|
||||
font-size: 7px;
|
||||
}
|
||||
.cockpit-live-pick {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
margin: 5px 0 6px;
|
||||
}
|
||||
.cockpit-live-pick .live-stream-title {
|
||||
font-size: 8px;
|
||||
}
|
||||
.cockpit-live-pick .live-step .material-symbols-outlined {
|
||||
font-size: 14px;
|
||||
}
|
||||
.cockpit-live-status {
|
||||
margin: 5px 0 0;
|
||||
color: rgba(244, 251, 255, 0.7);
|
||||
font-size: 7px;
|
||||
letter-spacing: 0.1em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.cockpit-live-credit {
|
||||
margin: 4px 0 0;
|
||||
color: rgba(182, 226, 241, 0.72);
|
||||
font: 600 7px/1.2 var(--font-mono);
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.cockpit-live-credit a {
|
||||
color: inherit;
|
||||
}
|
||||
.cockpit-signal-window[data-layout-mode='rail-right-constrained'] {
|
||||
gap: 5px;
|
||||
}
|
||||
@@ -2024,6 +2083,11 @@ body.cockpit-mode
|
||||
) {
|
||||
display: none !important;
|
||||
}
|
||||
/* The first-visit Stories announcement waits, unread, until Cockpit closes:
|
||||
on a phone it would cover the Display/Radio row. */
|
||||
body.cockpit-mode #gev-stories #hPop {
|
||||
display: none;
|
||||
}
|
||||
body.cockpit-mode #left-panel-stack {
|
||||
z-index: 147;
|
||||
display: flex;
|
||||
@@ -2120,10 +2184,31 @@ body.cockpit-mode #intel-hud .hud-right-edge {
|
||||
top: auto;
|
||||
right: 12px;
|
||||
bottom: 152px;
|
||||
flex-direction: row;
|
||||
max-width: calc(100vw - 24px);
|
||||
}
|
||||
body.cockpit-mode .cockpit-utility-controls {
|
||||
flex-direction: row;
|
||||
/* Phone flight and bridge views: one row centred on the Reset/Exit axis,
|
||||
10px below the roll arc (.cockpit-roll-arc: 2px + 96px into the visor).
|
||||
Shorter screens reserve 36px around the 46% centre of .cockpit-reticle
|
||||
(about 25px tall on phones), plus an 8px gap below the 42px row.
|
||||
The row stops at 72px, below the vision controls. Windows under 240px
|
||||
tall, and narrow ones under 450px tall, keep the right-aligned row above
|
||||
Reset/Exit, clear of Reset, LOOK AHEAD and the Stories button, as do
|
||||
satellite and provider views. */
|
||||
@media (min-width: 390px) and (min-height: 240px), (min-height: 450px) {
|
||||
body.cockpit-mode.mobile-shell
|
||||
#cockpit-hud:not([data-generic]):not([data-subject='satellite'])
|
||||
.cockpit-utility-controls {
|
||||
top: clamp(
|
||||
72px,
|
||||
calc(46% - 68px),
|
||||
calc(var(--cockpit-visor-top) + 108px)
|
||||
);
|
||||
bottom: auto;
|
||||
left: 12px;
|
||||
width: max-content;
|
||||
margin-inline: auto;
|
||||
}
|
||||
}
|
||||
body.cockpit-mode .cockpit-utility-launcher {
|
||||
width: min(150px, calc((100vw - 31px) / 2));
|
||||
|
||||
@@ -482,6 +482,21 @@
|
||||
color: #fff;
|
||||
outline: none;
|
||||
}
|
||||
/* A station view's arrows either side of its name. */
|
||||
.cockpit-orbital-views .cockpit-orbital-look-readout {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
}
|
||||
.cockpit-orbital-view-step {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 1px 4px;
|
||||
line-height: 1;
|
||||
}
|
||||
.cockpit-orbital-view-step .material-symbols-outlined {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
/* The Cockpit HUD in orbit (#cockpit-hud[data-subject='satellite']): the
|
||||
orbital readout names the satellite, so the topline keeps only the
|
||||
|
||||
@@ -104,6 +104,33 @@
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
/* Find it: shown while the selected item is off screen or out of its feed. */
|
||||
.entity-card__find {
|
||||
display: grid;
|
||||
flex: none;
|
||||
place-items: center;
|
||||
width: 1.9rem;
|
||||
height: 1.9rem;
|
||||
color: #36dcff;
|
||||
background: rgba(29, 69, 81, 0.35);
|
||||
border: 1px solid rgba(48, 194, 224, 0.55);
|
||||
border-radius: 7px;
|
||||
}
|
||||
|
||||
.entity-card__find:hover,
|
||||
.entity-card__find:focus-visible {
|
||||
color: #fff;
|
||||
background: rgba(48, 194, 224, 0.3);
|
||||
}
|
||||
|
||||
.entity-card__find:disabled {
|
||||
opacity: 0.55;
|
||||
}
|
||||
|
||||
.entity-card__find .material-symbols-outlined {
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
.entity-card__title {
|
||||
margin: 0.55rem 0 0.1rem;
|
||||
overflow-wrap: anywhere;
|
||||
@@ -2180,7 +2207,11 @@
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.entity-hero:is([data-hero='flight'], [data-hero='satellite'], [data-hero='photo']) {
|
||||
.entity-hero:is(
|
||||
[data-hero='flight'],
|
||||
[data-hero='satellite'],
|
||||
[data-hero='photo']
|
||||
) {
|
||||
height: 168px;
|
||||
background: radial-gradient(
|
||||
ellipse 55% 60% at 50% 55%,
|
||||
|
||||
@@ -0,0 +1,238 @@
|
||||
/* The LIVE section inside Context: a live stream in the platform's player. */
|
||||
|
||||
#live-panel[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* A section inside Context, laid out as the Radio section is: its +/-
|
||||
hides and shows the body, and it goes with the Context panel. */
|
||||
#live-panel {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
min-height: 0;
|
||||
margin-top: 10px;
|
||||
padding-top: 10px;
|
||||
border-top: 1px solid rgba(65, 220, 231, 0.16);
|
||||
}
|
||||
.live-panel-inner {
|
||||
position: relative;
|
||||
display: flex;
|
||||
min-height: 0;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
padding: 10px;
|
||||
border: 1px solid rgba(65, 220, 231, 0.18);
|
||||
border-radius: 8px;
|
||||
background: rgba(2, 15, 20, 0.42);
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
|
||||
}
|
||||
#live-panel .panel-header {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
#right-context-rail #global-context-panel:not(.collapsed) #live-panel {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
#live-panel.collapsed .live-panel-inner > :not(.panel-header),
|
||||
#global-context-panel.collapsed #live-panel {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.live-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 10px;
|
||||
letter-spacing: 0.12em;
|
||||
}
|
||||
.live-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.28);
|
||||
box-shadow: none;
|
||||
flex: none;
|
||||
}
|
||||
.live-dot.waiting {
|
||||
background: #ffb547;
|
||||
}
|
||||
.live-dot.on-air {
|
||||
background: #ff3b3b;
|
||||
box-shadow: 0 0 6px rgba(255, 59, 59, 0.9);
|
||||
animation: live-blink 1.2s ease-in-out infinite;
|
||||
}
|
||||
@keyframes live-blink {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
opacity: 0.25;
|
||||
}
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.live-dot.on-air {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
|
||||
.live-subject {
|
||||
font-size: 11px;
|
||||
letter-spacing: 0.08em;
|
||||
opacity: 0.85;
|
||||
margin: 2px 0 6px;
|
||||
}
|
||||
.live-pick {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.live-stream-title {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.06em;
|
||||
}
|
||||
.live-stream-title small {
|
||||
font-weight: 400;
|
||||
opacity: 0.7;
|
||||
}
|
||||
.live-step {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 1px 4px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.25);
|
||||
border-radius: 2px;
|
||||
background: rgba(0, 7, 12, 0.6);
|
||||
color: inherit;
|
||||
cursor: pointer;
|
||||
line-height: 1;
|
||||
}
|
||||
.live-step .material-symbols-outlined {
|
||||
font-size: 18px;
|
||||
}
|
||||
@media (pointer: coarse) {
|
||||
.live-step {
|
||||
min-width: 44px;
|
||||
min-height: 44px;
|
||||
}
|
||||
}
|
||||
.live-step:hover,
|
||||
.live-step:focus-visible {
|
||||
border-color: var(--cockpit-accent, #00dcff);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
/* The screen keeps a 16:9 box whether a player is in it or not. */
|
||||
.live-screen {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
aspect-ratio: 16 / 9;
|
||||
background: #000;
|
||||
border: 1px solid rgba(255, 255, 255, 0.18);
|
||||
border-radius: 2px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.live-player-host,
|
||||
.live-player-host iframe {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: 0;
|
||||
}
|
||||
.live-screen:not(.active) .live-player-host {
|
||||
display: none;
|
||||
}
|
||||
/* The poster's Play: the only way the player is loaded. */
|
||||
.live-play {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
margin: auto;
|
||||
width: max-content;
|
||||
height: max-content;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-width: 44px;
|
||||
min-height: 44px;
|
||||
padding: 8px 18px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.45);
|
||||
border-radius: 4px;
|
||||
background: rgba(0, 7, 12, 0.72);
|
||||
color: #f4fbff;
|
||||
font: inherit;
|
||||
font-size: 12px;
|
||||
letter-spacing: 0.1em;
|
||||
cursor: pointer;
|
||||
}
|
||||
.live-play:hover,
|
||||
.live-play:focus-visible {
|
||||
border-color: #ff3b3b;
|
||||
outline: none;
|
||||
}
|
||||
.live-play .material-symbols-outlined {
|
||||
font-size: 20px;
|
||||
}
|
||||
.live-card {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
padding: 12px;
|
||||
text-align: center;
|
||||
font-size: 11px;
|
||||
letter-spacing: 0.08em;
|
||||
background:
|
||||
radial-gradient(
|
||||
circle at 50% 40%,
|
||||
rgba(0, 220, 255, 0.08),
|
||||
transparent 60%
|
||||
),
|
||||
#050a0f;
|
||||
}
|
||||
.live-card-dot {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
}
|
||||
.live-card.offline .live-card-dot {
|
||||
background: #ff3b3b;
|
||||
opacity: 0.6;
|
||||
}
|
||||
.live-card button {
|
||||
padding: 3px 10px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.35);
|
||||
border-radius: 2px;
|
||||
background: rgba(0, 7, 12, 0.7);
|
||||
color: #f4fbff;
|
||||
font: inherit;
|
||||
letter-spacing: 0.12em;
|
||||
cursor: pointer;
|
||||
}
|
||||
.live-card button:hover,
|
||||
.live-card button:focus-visible {
|
||||
border-color: var(--cockpit-accent, #00dcff);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.live-status {
|
||||
margin: 6px 0 0;
|
||||
font-size: 11px;
|
||||
opacity: 0.85;
|
||||
}
|
||||
.live-credit,
|
||||
.live-privacy {
|
||||
margin: 6px 0 0;
|
||||
font-size: 10px;
|
||||
opacity: 0.75;
|
||||
}
|
||||
.live-credit a {
|
||||
color: inherit;
|
||||
}
|
||||
@@ -8,11 +8,15 @@ body:not(.mobile-shell):not(.cockpit-mode):not(.scene-playback-mode):not(
|
||||
/* Clear of the attribution line under it, however many lines it wraps
|
||||
onto (--credit-line-height, src/ui/creditLineHeight.js). */
|
||||
--omnibar-credits-clear: calc(1rem + var(--credit-line-height, 28px) + 6px);
|
||||
/* The dock, and the World Timeline and narrow corners placed from it,
|
||||
/* The World Timeline, and the dock and narrow corners placed from it,
|
||||
rise over a line wrapped taller than its usual one or two lines. */
|
||||
--omnibar-dock-bottom: max(74px, calc(var(--omnibar-credits-clear) + 2px));
|
||||
/* The dock sits above the World Timeline, rising by its height
|
||||
(--world-timeline-lift, world-timeline.css) as the plain dock does. */
|
||||
--omnibar-dock-raised: calc(
|
||||
var(--omnibar-dock-bottom) + var(--world-timeline-lift, 0px)
|
||||
);
|
||||
--omnibar-coordinates-bottom: max(4.25rem, var(--omnibar-credits-clear));
|
||||
--world-timeline-lift: 0px;
|
||||
|
||||
#intel-hud:is([data-variant='tactical'], [data-variant='minimal'])
|
||||
:is(.hud-top-left, .hud-top-right) {
|
||||
@@ -32,23 +36,14 @@ body:not(.mobile-shell):not(.cockpit-mode):not(.scene-playback-mode):not(
|
||||
}
|
||||
|
||||
#world-timeline {
|
||||
bottom: calc(var(--omnibar-dock-bottom) + 66px);
|
||||
bottom: var(--omnibar-dock-bottom);
|
||||
width: var(--omnibar-dock-width);
|
||||
}
|
||||
|
||||
&:has(#gev-chat-panel:not([hidden]), #gev-voice-panel:not([hidden]))
|
||||
#world-timeline,
|
||||
&:has(#gev-omnibar.has-results):not(
|
||||
:has(#gev-voice-control[data-assistant-mode='voice'])
|
||||
)
|
||||
#world-timeline {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
#command-dock {
|
||||
--dock-voice-width: var(--omnibar-dock-width);
|
||||
top: auto;
|
||||
bottom: var(--omnibar-dock-bottom);
|
||||
bottom: var(--omnibar-dock-raised);
|
||||
z-index: 149;
|
||||
width: var(--omnibar-dock-width);
|
||||
max-width: none;
|
||||
@@ -197,7 +192,7 @@ body:not(.mobile-shell):not(.cockpit-mode):not(.scene-playback-mode):not(
|
||||
|
||||
#gev-omnibar {
|
||||
top: auto;
|
||||
bottom: calc(var(--omnibar-dock-bottom) + 11px);
|
||||
bottom: calc(var(--omnibar-dock-raised) + 11px);
|
||||
left: 50%;
|
||||
width: calc(var(--omnibar-dock-width) - 120px);
|
||||
transform: translateX(-50%);
|
||||
@@ -235,7 +230,7 @@ body:not(.mobile-shell):not(.cockpit-mode):not(.scene-playback-mode):not(
|
||||
bottom: calc(100% + 11px);
|
||||
max-height: min(
|
||||
360px,
|
||||
max(0px, calc(100dvh - var(--omnibar-dock-bottom) - 144px))
|
||||
max(0px, calc(100dvh - var(--omnibar-dock-raised) - 144px))
|
||||
);
|
||||
overflow: auto;
|
||||
border-radius: 18px 18px 0 0;
|
||||
@@ -365,16 +360,9 @@ body:not(.mobile-shell):not(.cockpit-mode):not(.scene-playback-mode):not(
|
||||
rise above the dock. */
|
||||
@media (max-width: 1119px) {
|
||||
--omnibar-coordinates-bottom: max(
|
||||
calc(var(--omnibar-dock-bottom) + 56px + 10px),
|
||||
calc(var(--omnibar-dock-raised) + 56px + 10px),
|
||||
var(--omnibar-credits-clear)
|
||||
);
|
||||
/* And above the World Timeline (42px tall) over the dock. */
|
||||
&:has(#world-timeline) {
|
||||
--omnibar-coordinates-bottom: max(
|
||||
calc(var(--omnibar-dock-bottom) + 66px + 42px + 10px),
|
||||
var(--omnibar-credits-clear)
|
||||
);
|
||||
}
|
||||
#intel-hud[data-variant='tactical'] .hud-bottom-right,
|
||||
&:where(html[dir='rtl'] *):not(.context-docked)
|
||||
#intel-hud[data-variant='tactical']
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
/* The STATION section inside Context: a space station's moving parts. */
|
||||
|
||||
#station-panel[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* A section inside Context, laid out as the Radio section is: its +/-
|
||||
hides and shows the body, and it goes with the Context panel. */
|
||||
#station-panel {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
min-height: 0;
|
||||
margin-top: 10px;
|
||||
padding-top: 10px;
|
||||
border-top: 1px solid rgba(65, 220, 231, 0.16);
|
||||
}
|
||||
.station-panel-inner {
|
||||
position: relative;
|
||||
display: flex;
|
||||
min-height: 0;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
padding: 10px;
|
||||
border: 1px solid rgba(65, 220, 231, 0.18);
|
||||
border-radius: 8px;
|
||||
background: rgba(2, 15, 20, 0.42);
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
|
||||
}
|
||||
#station-panel .panel-header {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
#right-context-rail #global-context-panel:not(.collapsed) #station-panel {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
#station-panel.collapsed .station-panel-inner > :not(.panel-header),
|
||||
#global-context-panel.collapsed #station-panel {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.station-badge {
|
||||
font-size: 10px;
|
||||
letter-spacing: 0.12em;
|
||||
}
|
||||
.station-subject {
|
||||
font-size: 11px;
|
||||
letter-spacing: 0.08em;
|
||||
opacity: 0.85;
|
||||
margin: 2px 0 8px;
|
||||
}
|
||||
.station-modes {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.station-mode,
|
||||
.station-button {
|
||||
padding: 3px 10px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.3);
|
||||
border-radius: 2px;
|
||||
background: rgba(0, 7, 12, 0.6);
|
||||
color: #f4fbff;
|
||||
font: inherit;
|
||||
font-size: 10px;
|
||||
letter-spacing: 0.12em;
|
||||
cursor: pointer;
|
||||
}
|
||||
.station-mode {
|
||||
flex: 1;
|
||||
font-weight: 700;
|
||||
}
|
||||
.station-mode.is-active,
|
||||
.station-button.is-active {
|
||||
border-color: var(--cockpit-accent, #00dcff);
|
||||
color: var(--cockpit-accent, #00dcff);
|
||||
}
|
||||
.station-mode:focus-visible,
|
||||
.station-button:focus-visible {
|
||||
outline: 1px solid var(--cockpit-accent, #00dcff);
|
||||
outline-offset: 1px;
|
||||
}
|
||||
|
||||
.station-telemetry {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin: 0 0 6px;
|
||||
font-size: 11px;
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
.station-telemetry-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
flex: none;
|
||||
}
|
||||
.station-telemetry[data-tone='live'] .station-telemetry-dot {
|
||||
background: #3bff7a;
|
||||
box-shadow: 0 0 6px rgba(59, 255, 122, 0.8);
|
||||
}
|
||||
.station-telemetry[data-tone='waiting'] .station-telemetry-dot {
|
||||
background: #ffb547;
|
||||
}
|
||||
.station-telemetry[data-tone='manual'] .station-telemetry-dot {
|
||||
background: var(--cockpit-accent, #00dcff);
|
||||
}
|
||||
.station-note {
|
||||
margin: 0 0 6px;
|
||||
font-size: 10px;
|
||||
opacity: 0.75;
|
||||
}
|
||||
|
||||
.station-group {
|
||||
margin: 8px 0 0;
|
||||
padding-top: 8px;
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.12);
|
||||
}
|
||||
.station-label {
|
||||
font-size: 10px;
|
||||
letter-spacing: 0.12em;
|
||||
opacity: 0.85;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.station-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
}
|
||||
.station-sliders {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
}
|
||||
.station-slider {
|
||||
display: grid;
|
||||
grid-template-columns: 7em 1fr 3.5em;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 10px;
|
||||
}
|
||||
.station-slider output {
|
||||
text-align: right;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.station-zoom {
|
||||
margin-top: 8px;
|
||||
width: 100%;
|
||||
}
|
||||
@@ -17,14 +17,22 @@ import CockpitProgress from './panels/CockpitProgress.vue';
|
||||
import CockpitRadar from './panels/CockpitRadar.vue';
|
||||
import CockpitRollingValue from './panels/CockpitRollingValue.vue';
|
||||
import CockpitUtilityControls from './panels/CockpitUtilityControls.vue';
|
||||
import UiButton from '../kit/UiButton.vue';
|
||||
import UiIcon from '../kit/UiIcon.vue';
|
||||
|
||||
// The Cockpit HUD. The Cockpit controller presents the instruments, the
|
||||
// destination arrow and the vision selector on every HUD update; until it
|
||||
// does, they show the state they start in. The controller also publishes
|
||||
// which surfaces are shown and the utility strip's measured layout; the
|
||||
// layout pass stays with it, and the controls keep its listeners.
|
||||
const { presence, instruments, route, vision, utilityLayout } =
|
||||
storeToRefs(useCockpitStore());
|
||||
const {
|
||||
presence,
|
||||
instruments,
|
||||
route,
|
||||
vision,
|
||||
utilityLayout,
|
||||
orbital: orbitalView,
|
||||
} = storeToRefs(useCockpitStore());
|
||||
const active = computed(() => Boolean(presence.value?.active));
|
||||
// A vessel subject swaps the aviation readouts for bridge ones.
|
||||
const bridge = computed(() => presence.value?.subjectKind === 'vessel');
|
||||
@@ -34,6 +42,9 @@ const orbital = computed(() => presence.value?.subjectKind === 'satellite');
|
||||
// window view whose readouts, labels and texts the provider words.
|
||||
const generic = computed(() => presence.value?.subjectGeneric === true);
|
||||
const labels = computed(() => presence.value?.subjectLabels ?? null);
|
||||
// The station is ridden from a mount on its 3D model: the arrows look about
|
||||
// it and Home returns to it, where the nadir picture tilts and returns to nadir.
|
||||
const stationView = computed(() => (orbitalView.value?.mount ?? null) !== null);
|
||||
const subject = computed(() =>
|
||||
generic.value
|
||||
? presence.value.subjectKind
|
||||
@@ -171,7 +182,7 @@ const tickStyle = (tick) =>
|
||||
<span v-for="(tick, index) in hud.speedRim.ticks" :key="index" data-speed-rim-tick :hidden="tick.hidden" :class="{ major: tick.major }" :style="tickStyle(tick)"><b>{{ tick.label }}</b><i></i></span>
|
||||
</div>
|
||||
<div class="cockpit-altitude-rim-pointer">
|
||||
<span class="material-symbols-outlined">arrow_right</span>
|
||||
<UiIcon name="arrow_right" :size="null" />
|
||||
<strong id="cockpit-speed-rim-value">{{ hud.speedRim.value }}</strong>
|
||||
</div>
|
||||
</div>
|
||||
@@ -183,7 +194,7 @@ const tickStyle = (tick) =>
|
||||
</div>
|
||||
<div class="cockpit-altitude-rim-pointer">
|
||||
<strong id="cockpit-altitude-rim-value">{{ hud.altitudeRim.value }}</strong>
|
||||
<span class="material-symbols-outlined">arrow_left</span>
|
||||
<UiIcon name="arrow_left" :size="null" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="cockpit-topline">
|
||||
@@ -193,21 +204,21 @@ const tickStyle = (tick) =>
|
||||
<span id="cockpit-aircraft-meta" v-class-toggle="{ emergency: hud.meta.emergency }" class="cockpit-aircraft-meta" :data-tone="generic ? hud.meta.tone : undefined">{{ hud.meta.text }}</span>
|
||||
</div>
|
||||
<div class="cockpit-vision-controls" role="group" :aria-label="t('Cockpit vision style')">
|
||||
<button id="cockpit-vision-previous" class="cockpit-vision-nav" type="button" :aria-label="t('Previous cockpit vision style')" :title="t('Previous vision style')">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">chevron_left</span>
|
||||
<UiButton id="cockpit-vision-previous" class="cockpit-vision-nav" :aria-label="t('Previous cockpit vision style')" :title="t('Previous vision style')">
|
||||
<UiIcon name="chevron_left" :size="null" />
|
||||
<small>{{ t('PREV') }}</small>
|
||||
</button>
|
||||
<button id="cockpit-vision-current" class="cockpit-vision-current" type="button" :data-cockpit-vision="v.mode" :aria-label="visionLabel" :title="visionTitle">
|
||||
</UiButton>
|
||||
<UiButton id="cockpit-vision-current" class="cockpit-vision-current" :data-cockpit-vision="v.mode" :aria-label="visionLabel" :title="visionTitle">
|
||||
<small>{{ t('CURRENT') }}</small>
|
||||
<strong id="cockpit-vision-current-label" aria-live="polite">{{ v.label }}</strong>
|
||||
</button>
|
||||
<button id="cockpit-vision-next" class="cockpit-vision-nav" type="button" :aria-label="t('Next cockpit vision style')" :title="t('Next vision style')">
|
||||
</UiButton>
|
||||
<UiButton id="cockpit-vision-next" class="cockpit-vision-nav" :aria-label="t('Next cockpit vision style')" :title="t('Next vision style')">
|
||||
<small>{{ t('NEXT') }}</small>
|
||||
<span class="material-symbols-outlined" aria-hidden="true">chevron_right</span>
|
||||
</button>
|
||||
<UiIcon name="chevron_right" :size="null" />
|
||||
</UiButton>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!orbital && !generic" class="cockpit-reticle material-symbols-outlined" aria-hidden="true">my_location</div>
|
||||
<UiIcon v-if="!orbital && !generic" name="my_location" class="cockpit-reticle" :size="null" />
|
||||
<!-- A provider's banner: a status that names where the subject is. -->
|
||||
<div v-if="generic && hud.banner" class="cockpit-banner" role="status" :data-tone="hud.banner.tone">
|
||||
<strong>{{ hud.banner.title }}</strong>
|
||||
@@ -216,9 +227,9 @@ const tickStyle = (tick) =>
|
||||
<!-- A view turned off its rest says where it looks and offers the way back. -->
|
||||
<div v-if="looks" class="cockpit-look" :hidden="!look.offset">
|
||||
<span id="cockpit-look-readout" class="cockpit-look-readout" aria-live="polite">{{ look.readout }}</span>
|
||||
<button id="cockpit-look-ahead" type="button" class="cockpit-look-ahead" :aria-label="aheadLabel" :title="t('Look ahead (Home or 0)')" aria-keyshortcuts="Home 0">
|
||||
<UiButton id="cockpit-look-ahead" class="cockpit-look-ahead" :aria-label="aheadLabel" :title="t('Look ahead (Home or 0)')" aria-keyshortcuts="Home 0">
|
||||
<span>{{ t('LOOK AHEAD') }}</span>
|
||||
</button>
|
||||
</UiButton>
|
||||
</div>
|
||||
<div v-if="!orbital" class="cockpit-compass" :aria-label="generic ? hudLabel : bridge ? t('Current vessel heading') : t('Current aircraft heading')">
|
||||
<div class="cockpit-instrument-row">
|
||||
@@ -241,7 +252,7 @@ const tickStyle = (tick) =>
|
||||
<span class="cockpit-readout-unit">{{ t('FT') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<span class="cockpit-heading-caret material-symbols-outlined" aria-hidden="true">arrow_drop_down</span>
|
||||
<UiIcon name="arrow_drop_down" class="cockpit-heading-caret" :size="null" />
|
||||
<div class="cockpit-compass-tape" id="cockpit-compass-tape" aria-hidden="true" :style="bridge ? { '--tape-shift': tapeShift } : undefined"><span v-for="division in hud.compass" :key="division.heading ?? division.slot" :class="(division.active ?? division.slot === 0) ? 'active' : ''" :style="{ '--slot': division.slot, '--depth': Math.abs(division.slot) }">{{ division.label }}</span><template v-if="bridge"><i v-if="hud.compassMarkers?.prograde != null" class="cockpit-compass-marker cockpit-compass-prograde" aria-hidden="true" :style="{ '--slot': hud.compassMarkers.prograde }"></i><i v-if="hud.compassMarkers?.retrograde != null" class="cockpit-compass-marker cockpit-compass-retrograde" aria-hidden="true" :style="{ '--slot': hud.compassMarkers.retrograde }"></i></template></div>
|
||||
</div>
|
||||
<div v-if="!orbital" class="cockpit-position-readout">
|
||||
@@ -270,17 +281,17 @@ const tickStyle = (tick) =>
|
||||
<CockpitRadar />
|
||||
</div>
|
||||
<CockpitUtilityControls />
|
||||
<div class="cockpit-help"><bdi>{{ t('ESC EXIT') }}</bdi><template v-if="looks"> <span>·</span> <bdi>{{ t('ARROWS LOOK') }}</bdi> <span>·</span> <bdi>{{ t('HOME RESET') }}</bdi></template><template v-if="orbital"> <span>·</span> <bdi>{{ t('+/− ZOOM') }}</bdi> <span>·</span> <bdi>{{ t('ARROWS TILT') }}</bdi> <span>·</span> <bdi>{{ t('HOME NADIR') }}</bdi></template></div>
|
||||
<div class="cockpit-help"><bdi>{{ t('ESC EXIT') }}</bdi><template v-if="looks"> <span>·</span> <bdi>{{ t('ARROWS LOOK') }}</bdi> <span>·</span> <bdi>{{ t('HOME RESET') }}</bdi></template><template v-if="orbital"> <span>·</span> <bdi>{{ t('+/− ZOOM') }}</bdi> <span>·</span> <template v-if="stationView"><bdi>{{ t('ARROWS LOOK') }}</bdi> <span>·</span> <bdi>{{ t('HOME RESET') }}</bdi></template><template v-else><bdi>{{ t('ARROWS TILT') }}</bdi> <span>·</span> <bdi>{{ t('HOME NADIR') }}</bdi></template></template></div>
|
||||
</section>
|
||||
|
||||
<nav id="view-switcher" :aria-label="t('View switcher')">
|
||||
<button id="cockpit-reset-globe" type="button" :aria-label="resetBusy ? t('Resetting cockpit to full globe view') : t('Reset cockpit to full globe view')" :title="t('Exit cockpit and return to full globe view')" :hidden="!active" @click="globe.act('reset')">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">public</span>
|
||||
<UiButton id="cockpit-reset-globe" :aria-label="resetBusy ? t('Resetting cockpit to full globe view') : t('Reset cockpit to full globe view')" :title="t('Exit cockpit and return to full globe view')" :hidden="!active" @click="globe.act('reset')">
|
||||
<UiIcon name="public" :size="null" />
|
||||
<span>{{ t('RESET') }}</span>
|
||||
</button>
|
||||
<button id="map-view-switch" type="button" :aria-label="exitLabel" aria-keyshortcuts="Escape" :title="exitLabel" :hidden="!active">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">close_fullscreen</span>
|
||||
</UiButton>
|
||||
<UiButton id="map-view-switch" :aria-label="exitLabel" aria-keyshortcuts="Escape" :title="exitLabel" :hidden="!active">
|
||||
<UiIcon name="close_fullscreen" :size="null" />
|
||||
<span>{{ exitText }}</span>
|
||||
</button>
|
||||
</UiButton>
|
||||
</nav>
|
||||
</template>
|
||||
@@ -72,45 +72,45 @@ function selectMapSource(chip) {
|
||||
<div v-if="slot === 'control'" id="control-panel" v-panel-state="'control-panel'" class="panel-collapsible collapsed">
|
||||
<div class="panel-glow"></div>
|
||||
<div class="panel-inner">
|
||||
<button id="control-panel-toggle" class="panel-header dock-tray-toggle" type="button"
|
||||
<UiButton id="control-panel-toggle" class="panel-header dock-tray-toggle"
|
||||
data-dock-toggle-target="control-panel" :aria-expanded="String(panels['control-panel']?.collapsed === false)"
|
||||
aria-controls="control-panel-popover" :aria-label="trayWords('control-panel', t('VISUAL PRESETS'), t('Expand Visual Presets'))" :title="trayWords('control-panel', t('VISUAL PRESETS'), undefined)">
|
||||
<span class="panel-title"><span class="dock-label-icon dock-label-icon-presets" aria-hidden="true"></span>{{ t('VISUAL PRESETS') }}</span>
|
||||
<span class="panel-divider"></span>
|
||||
</button>
|
||||
</UiButton>
|
||||
<div id="control-panel-popover" class="dock-popover-content">
|
||||
<UiButton class="dock-pin-btn" data-pin-target="control-panel" :label="t('Pin visual presets')" :title="t('Keep visual presets open')" :pressed="!!panels['control-panel']?.pinned" @click="pin($event, 'control-panel')"><img src="/pin.svg" alt="" /></UiButton>
|
||||
<div id="style-buttons" class="button-grid">
|
||||
<button class="style-btn active" data-style="normal" @click="display.act('setStyle', 'normal')" v-class-toggle="{ ...(style && { active: style.name === 'normal' }) }" :title="t('Show the globe without a visual filter.')">
|
||||
<UiButton class="style-btn" data-style="normal" :pressed="!style || style.name === 'normal'" pressed-class="active" @click="display.act('setStyle', 'normal')" :title="t('Show the globe without a visual filter.')">
|
||||
<span class="btn-icon">◯</span>
|
||||
<span class="btn-label">{{ t('Normal') }}</span>
|
||||
<span class="btn-key">1</span>
|
||||
</button>
|
||||
<button class="style-btn" data-style="retro" @click="display.act('setStyle', 'retro')" v-class-toggle="{ ...(style && { active: style.name === 'retro' }) }" :title="t('Emulate a green phosphor CRT with scanlines and screen curvature.')">
|
||||
</UiButton>
|
||||
<UiButton class="style-btn" data-style="retro" :pressed="style?.name === 'retro'" pressed-class="active" @click="display.act('setStyle', 'retro')" :title="t('Emulate a green phosphor CRT with scanlines and screen curvature.')">
|
||||
<span class="btn-icon">▦</span>
|
||||
<span class="btn-label">{{ t('CRT') }}</span>
|
||||
<span class="btn-key">2</span>
|
||||
</button>
|
||||
<button class="style-btn" data-style="surveillance" @click="display.act('setStyle', 'surveillance')" v-class-toggle="{ ...(style && { active: style.name === 'surveillance' }) }" :title="t('Simulate night-vision goggles with green intensification and a tube vignette.')">
|
||||
</UiButton>
|
||||
<UiButton class="style-btn" data-style="surveillance" :pressed="style?.name === 'surveillance'" pressed-class="active" @click="display.act('setStyle', 'surveillance')" :title="t('Simulate night-vision goggles with green intensification and a tube vignette.')">
|
||||
<span class="btn-icon">🌙</span>
|
||||
<span class="btn-label">{{ t('NVG') }}</span>
|
||||
<span class="btn-key">3</span>
|
||||
</button>
|
||||
<button class="style-btn" data-style="thermal" @click="display.act('setStyle', 'thermal')" v-class-toggle="{ ...(style && { active: style.name === 'thermal' }) }" :title="t('Simulate FLIR-style thermal contrast. Turn up Ironbow for color.')">
|
||||
</UiButton>
|
||||
<UiButton class="style-btn" data-style="thermal" :pressed="style?.name === 'thermal'" pressed-class="active" @click="display.act('setStyle', 'thermal')" :title="t('Simulate FLIR-style thermal contrast. Turn up Ironbow for color.')">
|
||||
<span class="btn-icon">🌡️</span>
|
||||
<span class="btn-label">{{ t('FLIR') }}</span>
|
||||
<span class="btn-key">4</span>
|
||||
</button>
|
||||
<button class="style-btn" data-style="anime" @click="display.act('setStyle', 'anime')" v-class-toggle="{ ...(style && { active: style.name === 'anime' }) }" :title="t('Apply bright cel-shaded color and illustrated outlines.')">
|
||||
</UiButton>
|
||||
<UiButton class="style-btn" data-style="anime" :pressed="style?.name === 'anime'" pressed-class="active" @click="display.act('setStyle', 'anime')" :title="t('Apply bright cel-shaded color and illustrated outlines.')">
|
||||
<span class="btn-icon">✦</span>
|
||||
<span class="btn-label">{{ t('Anime') }}</span>
|
||||
<span class="btn-key">5</span>
|
||||
</button>
|
||||
<button class="style-btn" data-style="noir" @click="display.act('setStyle', 'noir')" v-class-toggle="{ ...(style && { active: style.name === 'noir' }) }" :title="t('Apply high-contrast monochrome film-noir grading.')">
|
||||
</UiButton>
|
||||
<UiButton class="style-btn" data-style="noir" :pressed="style?.name === 'noir'" pressed-class="active" @click="display.act('setStyle', 'noir')" :title="t('Apply high-contrast monochrome film-noir grading.')">
|
||||
<span class="btn-icon">◐</span>
|
||||
<span class="btn-label">{{ t('Noir') }}</span>
|
||||
<span class="btn-key">6</span>
|
||||
</button>
|
||||
</UiButton>
|
||||
</div>
|
||||
<section class="map-source-section" aria-labelledby="map-source-label">
|
||||
<div class="map-source-heading">
|
||||
@@ -134,10 +134,10 @@ function selectMapSource(chip) {
|
||||
<div class="panel-glow"></div>
|
||||
<div class="location-inner">
|
||||
<div class="location-toolbar">
|
||||
<button id="location-bar-toggle" class="dock-tray-toggle" type="button" data-dock-toggle-target="location-bar" aria-controls="location-bar-popover" :aria-expanded="String(panels['location-bar']?.collapsed === false)" :aria-label="trayWords('location-bar', t('LOCATION'), t('Expand LOCATION'))" :title="trayWords('location-bar', t('LOCATION'), t('Expand LOCATION'))">
|
||||
<UiButton id="location-bar-toggle" class="dock-tray-toggle" data-dock-toggle-target="location-bar" aria-controls="location-bar-popover" :aria-expanded="String(panels['location-bar']?.collapsed === false)" :aria-label="trayWords('location-bar', t('LOCATION'), t('Expand LOCATION'))" :title="trayWords('location-bar', t('LOCATION'), t('Expand LOCATION'))">
|
||||
<span class="location-toolbar-label"><span class="dock-label-icon dock-label-icon-location" aria-hidden="true"></span>{{ t('LOCATION') }}</span>
|
||||
</button>
|
||||
<button class="panel-collapse-btn" data-collapse-target="location-bar" :title="t('Collapse panel')" @click="chrome.act('toggle', 'location-bar')">+</button>
|
||||
</UiButton>
|
||||
<UiButton class="panel-collapse-btn" data-collapse-target="location-bar" :title="t('Collapse panel')" @click="chrome.act('toggle', 'location-bar')">+</UiButton>
|
||||
</div>
|
||||
<div id="location-mini-status" class="location-mini-status" aria-live="polite">
|
||||
<div id="location-mini-city" class="location-mini-city">{{ loc ? loc.status.city : t('📍 Location: --') }}</div>
|
||||
@@ -150,9 +150,9 @@ function selectMapSource(chip) {
|
||||
<div class="location-city-row">
|
||||
<div id="location-pills" class="location-pills"><UiButton v-for="city in loc?.cities" :key="city.id" class="location-pill" :pressed="Boolean(city.active)" pressed-class="active" :data-location-id="city.id" @click="locationControls?.chooseCity(city.id)">{{ city.label }}</UiButton></div>
|
||||
<div class="location-search-wrap">
|
||||
<button id="search-toggle" class="search-toggle-btn" :title="t('Search any location')" @click="locationControls?.toggleSearch()">
|
||||
<UiButton id="search-toggle" class="search-toggle-btn" :title="t('Search any location')" @click="locationControls?.toggleSearch()">
|
||||
<span>🔎</span>
|
||||
</button>
|
||||
</UiButton>
|
||||
<input type="text" id="location-search" v-class-toggle="{ expanded: !!loc?.searchExpanded, searching: !!loc?.searching }" :placeholder="t('Search any location...')" autocomplete="off" spellcheck="false" :aria-label="t('Search location by name or coordinates')" :aria-invalid="loc?.searchOrigin !== 'omnibar' && loc?.searchError ? 'true' : null" :aria-describedby="loc?.searchOrigin !== 'omnibar' && loc?.searchError ? 'location-search-error' : null" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -15,8 +15,11 @@ import BhoteKoshiPanel from './panels/BhoteKoshiPanel.vue';
|
||||
import EntityCard from './panels/EntityCard.vue';
|
||||
import ViewContext from './panels/ViewContext.vue';
|
||||
import SpaceMissionsPanel from './panels/SpaceMissionsPanel.vue';
|
||||
import LivePanel from './panels/LivePanel.vue';
|
||||
import RadioPanel from './panels/RadioPanel.vue';
|
||||
import StationPanel from './panels/StationPanel.vue';
|
||||
import UiButton from '../kit/UiButton.vue';
|
||||
import UiIcon from '../kit/UiIcon.vue';
|
||||
import UiSearchField from '../kit/UiSearchField.vue';
|
||||
import { cockpitEntryFace } from '../cockpitPresentation.js';
|
||||
import { LAYER_TABS, TAB_AFFECTS, activeTab, availableTabs, contextReady, enabledLayerIds, setEnabledLayers, tabTarget } from '../contextLayerTabs.js';
|
||||
@@ -182,39 +185,44 @@ watch(
|
||||
</RailPanel>
|
||||
<RailPanel id="global-context-panel" start-collapsed v-class-toggle="{ ...(ctx && { 'context-enabled': ctx.enabled }) }" :data-context-mode="ctx?.mode" :data-context-tab="activeTab" :title="t('CONTEXT')" sideways scroll rail-scroller>
|
||||
<template #actions>
|
||||
<button type="button" class="context-dock-btn" :aria-pressed="String(contextSearchOpen)" :aria-label="contextSearchOpen ? t('Close Context search') : t('Search in Context')" :title="contextSearchOpen ? t('Close search') : t('Search in Context')" @click="toggleSearch">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">search</span>
|
||||
</button>
|
||||
<button type="button" class="context-dock-btn" :aria-pressed="String(docked)" :aria-label="docked ? t('Shrink Context back to a panel') : t('Expand Context to a full-height column')" :title="docked ? t('Shrink') : t('Expand')" @click="setDocked(!docked)">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">{{ docked ? 'close_fullscreen' : 'open_in_full' }}</span>
|
||||
</button>
|
||||
<UiButton class="context-dock-btn" :pressed="Boolean(contextSearchOpen)" :aria-label="contextSearchOpen ? t('Close Context search') : t('Search in Context')" :title="contextSearchOpen ? t('Close search') : t('Search in Context')" @click="toggleSearch">
|
||||
<UiIcon name="search" :size="null" />
|
||||
</UiButton>
|
||||
<UiButton class="context-dock-btn" :pressed="docked" :aria-label="docked ? t('Shrink Context back to a panel') : t('Expand Context to a full-height column')" :title="docked ? t('Shrink') : t('Expand')" @click="setDocked(!docked)">
|
||||
<UiIcon :name="docked ? 'close_fullscreen' : 'open_in_full'" :size="null" />
|
||||
</UiButton>
|
||||
</template>
|
||||
<div class="cyber-panel-body ui-scroll" data-rail-scroller>
|
||||
<UiSearchField v-if="contextSearchOpen" ref="searchInput" v-model="contextSearchText" class="context-search" role="search" input-class="context-search__input" :label="searchHint" :placeholder="searchHint" autocomplete="off" spellcheck="false" :clear-label="t('Clear search')" clear-class="context-search__clear" @escape="closeContextSearch" />
|
||||
<div v-if="availableTabs.length" class="context-tabs" role="tablist" :aria-label="t('Context tabs')">
|
||||
<button id="context-tab-btn-view" type="button" role="tab" class="context-tabs__tab" :class="{ active: activeTab === 'view' }" :aria-selected="String(activeTab === 'view')" aria-controls="context-tab-view" :tabindex="activeTab === 'view' ? 0 : -1" @click="activeTab = 'view'" @keydown.left.prevent="switchTab" @keydown.right.prevent="switchTab">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">visibility</span><span class="context-tabs__label">{{ t('Inspector') }}</span>
|
||||
</button>
|
||||
<button id="context-tab-btn-props" type="button" role="tab" class="context-tabs__tab" :class="{ active: activeTab === 'props' }" :aria-selected="String(activeTab === 'props')" aria-controls="context-tab-props" :tabindex="activeTab === 'props' ? 0 : -1" @click="activeTab = 'props'" @keydown.left.prevent="switchTab" @keydown.right.prevent="switchTab">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">tune</span><span class="context-tabs__label">{{ t('Properties') }}</span>
|
||||
</button>
|
||||
<UiButton id="context-tab-btn-view" role="tab" class="context-tabs__tab" :class="{ active: activeTab === 'view' }" :aria-selected="String(activeTab === 'view')" aria-controls="context-tab-view" :tabindex="activeTab === 'view' ? 0 : -1" @click="activeTab = 'view'" @keydown.left.prevent="switchTab" @keydown.right.prevent="switchTab">
|
||||
<UiIcon name="visibility" :size="null" /><span class="context-tabs__label">{{ t('Inspector') }}</span>
|
||||
</UiButton>
|
||||
<UiButton id="context-tab-btn-props" role="tab" class="context-tabs__tab" :class="{ active: activeTab === 'props' }" :aria-selected="String(activeTab === 'props')" aria-controls="context-tab-props" :tabindex="activeTab === 'props' ? 0 : -1" @click="activeTab = 'props'" @keydown.left.prevent="switchTab" @keydown.right.prevent="switchTab">
|
||||
<UiIcon name="tune" :size="null" /><span class="context-tabs__label">{{ t('Properties') }}</span>
|
||||
</UiButton>
|
||||
</div>
|
||||
<!-- Properties: settings of the layers that are on, one section each. -->
|
||||
<div id="context-tab-props" class="context-props" :hidden="activeTab !== 'props'" role="tabpanel" aria-labelledby="context-tab-btn-props">
|
||||
<section v-for="tab in LAYER_TABS" v-show="isShown(tab.id)" :key="tab.id" class="context-props__section">
|
||||
<h4 class="context-props__heading"><span class="material-symbols-outlined" aria-hidden="true">{{ tab.icon }}</span>{{ t(tab.label) }}</h4>
|
||||
<h4 class="context-props__heading"><UiIcon :name="tab.icon" :size="null" />{{ t(tab.label) }}</h4>
|
||||
<ul v-if="affects(tab.id).length" class="context-props__layers">
|
||||
<li v-for="layer in affects(tab.id)" :key="layer.id"><i :style="{ background: layer.color }" aria-hidden="true"></i>{{ layer.name }}</li>
|
||||
</ul>
|
||||
<div :id="`context-tab-${tab.id}`" :ref="setPane(tab.id)" class="context-tab-pane"></div>
|
||||
</section>
|
||||
</div>
|
||||
<!-- Sections PanelChrome owns sit outside the Inspector view, which mounts
|
||||
only while Context is open: PanelChrome finds collapsible panels once,
|
||||
at startup. -->
|
||||
<StationPanel />
|
||||
<LivePanel />
|
||||
<RadioPanel />
|
||||
<div class="global-context-modes" role="tablist" :aria-label="t('Context mode')">
|
||||
<button id="global-context-flights-btn" class="context-mode-button" v-class-toggle="{ active: ctx?.flightsActive }" type="button" role="tab" tabindex="0" :aria-selected="String(ctx?.flightsActive ?? false)" :aria-disabled="ctx && String(ctx.busy)" :aria-busy="ctx && String(ctx.busy)" aria-controls="context-flights-view" :aria-label="t('CONTACTS')" :title="t('Cycles the nearest contacts of whatever type you select — planes, vessels, installations. Satellites track independently.')">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">radar</span>
|
||||
<UiButton id="global-context-flights-btn" class="context-mode-button" v-class-toggle="{ active: ctx?.flightsActive }" role="tab" tabindex="0" :aria-selected="String(ctx?.flightsActive ?? false)" :aria-disabled="ctx && String(ctx.busy)" :aria-busy="ctx && String(ctx.busy)" aria-controls="context-flights-view" :aria-label="t('CONTACTS')" :title="t('Cycles the nearest contacts of whatever type you select — planes, vessels, installations. Satellites track independently.')">
|
||||
<UiIcon name="radar" :size="null" />
|
||||
<span>{{ t('CONTACTS') }}</span>
|
||||
</button>
|
||||
</UiButton>
|
||||
</div>
|
||||
<div id="context-mode-standby" class="context-mode-standby" :hidden="ctx?.enabled">
|
||||
<strong>{{ t('SELECT CONTEXT') }}</strong>
|
||||
@@ -222,11 +230,11 @@ watch(
|
||||
</div>
|
||||
<section id="context-flights-view" class="context-mode-view" role="tabpanel" aria-labelledby="global-context-flights-btn" :hidden="!ctx?.flightsActive">
|
||||
<div class="global-context-actions" :aria-label="t('Contact Context actions')">
|
||||
<button id="cockpit-entry" type="button" :hidden="!cockpit?.entryAvailable">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">{{ entry.icon }}</span>
|
||||
<UiButton id="cockpit-entry" :hidden="!cockpit?.entryAvailable">
|
||||
<UiIcon :name="entry.icon" :size="null" />
|
||||
<span>{{ entry.label }}</span>
|
||||
</button>
|
||||
<button id="installations-search-btn" class="panel-layer-toggle" type="button" :aria-disabled="ctx && String(ctx.installationsBusy)" :aria-busy="ctx && String(ctx.installationsBusy)">{{ t('SEARCH NEARBY SITES') }}</button>
|
||||
</UiButton>
|
||||
<UiButton id="installations-search-btn" class="panel-layer-toggle" :aria-disabled="ctx && String(ctx.installationsBusy)" :aria-busy="ctx && String(ctx.installationsBusy)">{{ t('SEARCH NEARBY SITES') }}</UiButton>
|
||||
<UiButton id="tr3b-toggle" class="tr3b-toggle" :pressed="!!cockpit?.tr3b?.converted" :hidden="!cockpit?.tr3b" :aria-label="t('Reclassify tracked contact as TR-3B')" :title="cockpit?.tr3b?.converted ? t('Restore real aircraft') : t('Reclassify as TR-3B')">🛸</UiButton>
|
||||
</div>
|
||||
<AwarenessPanel v-if="!contactsMatchCard" />
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
import { t } from '../../i18n/index.js';
|
||||
import { useDisplayStore } from '../stores/display.js';
|
||||
import DisplayPanel from './panels/DisplayPanel.vue';
|
||||
import UiButton from '../kit/UiButton.vue';
|
||||
|
||||
const display = useDisplayStore();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<DisplayPanel />
|
||||
<button id="clean-view-exit" @click="display.act('exitCleanView')" :title="t('Return UI controls')">{{ t('EXIT CLEAN VIEW') }}</button>
|
||||
<UiButton id="clean-view-exit" @click="display.act('exitCleanView')" :title="t('Return UI controls')">{{ t('EXIT CLEAN VIEW') }}</UiButton>
|
||||
</template>
|
||||
@@ -4,6 +4,8 @@ import { storeToRefs } from 'pinia';
|
||||
import { useHudStore } from '../stores/hud.js';
|
||||
import { useCockpitStore } from '../stores/cockpit.js';
|
||||
import { cockpitEntryFace } from '../cockpitPresentation.js';
|
||||
import UiButton from '../kit/UiButton.vue';
|
||||
import UiIcon from '../kit/UiIcon.vue';
|
||||
|
||||
// The readouts, visibility, layout variant and colors IntelHUD publishes.
|
||||
const { hud } = storeToRefs(useHudStore());
|
||||
@@ -56,10 +58,10 @@ const entry = computed(() =>
|
||||
<div class="hud-readout"><div id="hud-gsd">{{ view.gsd }}</div></div>
|
||||
<div class="hud-readout"><div id="hud-alt">{{ view.alt }}</div></div>
|
||||
<div class="hud-readout"><div id="hud-ais-vessel" :class="['hud-ais-vessel', { active: view.vessel.active }]">{{ view.vessel.text }}</div></div>
|
||||
<button id="cockpit-entry-readout" type="button" :hidden="!cockpit?.entryAvailable">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">{{ entry.icon }}</span>
|
||||
<UiButton id="cockpit-entry-readout" :hidden="!cockpit?.entryAvailable">
|
||||
<UiIcon :name="entry.icon" :size="null" />
|
||||
<span>{{ entry.label }}</span>
|
||||
</button>
|
||||
</UiButton>
|
||||
</div>
|
||||
<div class="hud-bracket">┘</div>
|
||||
</div>
|
||||
|
||||
@@ -12,6 +12,7 @@ import SceneOptions from './SceneOptions.vue';
|
||||
import SceneShotList from './SceneShotList.vue';
|
||||
import CctvPanel from './panels/CctvPanel.vue';
|
||||
import StreetLevelPanel from './panels/StreetLevelPanel.vue';
|
||||
import StreetLevelPhotoViewer from './panels/StreetLevelPhotoViewer.vue';
|
||||
import DrawControls from './panels/DrawControls.vue';
|
||||
import GeoImport from './panels/GeoImport.vue';
|
||||
import UiSelect from '../kit/UiSelect.js';
|
||||
@@ -71,6 +72,7 @@ async function importChosen(event) {
|
||||
|
||||
<!-- Street Level Panel (moved into #right-context-rail at runtime) -->
|
||||
<StreetLevelPanel />
|
||||
<StreetLevelPhotoViewer />
|
||||
|
||||
<!-- Scene Director Panel -->
|
||||
<RailPanel id="scene-panel" start-collapsed v-class-toggle="{ running: scene?.running, 'has-shots': scene?.hasShots }" :title="t('AUTHORING')" :hint="t('Create and edit scenes')" scroll>
|
||||
|
||||
@@ -8,7 +8,9 @@ import { vStatusText } from '../rail/statusText.js';
|
||||
import { useLocaleStore } from '../stores/locale.js';
|
||||
import { useProviderSettingsStore } from '../stores/providerSettings.js';
|
||||
import LocalePicker from './panels/LocalePicker.vue';
|
||||
import UiButton from '../kit/UiButton.vue';
|
||||
import UiCloseButton from '../kit/UiCloseButton.vue';
|
||||
import UiIcon from '../kit/UiIcon.vue';
|
||||
|
||||
const { picker } = storeToRefs(useLocaleStore());
|
||||
// The key setup owner (src/keySetup.js) presents the chip, the dialog and its
|
||||
@@ -39,10 +41,10 @@ const removeTitle = (title) =>
|
||||
<!-- Bottom-right HUD row: the POWER UP chip (while keys are missing) and
|
||||
the language picker, once the shell publishes it. -->
|
||||
<div id="corner-actions">
|
||||
<button v-if="available" id="key-setup-chip" type="button" :hidden="!chip || chip.hidden" aria-haspopup="dialog" aria-controls="key-setup" :title="chip?.title" :aria-label="chip?.title" @click="controls?.open()">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">bolt</span>
|
||||
<UiButton v-if="available" id="key-setup-chip" :hidden="!chip || chip.hidden" aria-haspopup="dialog" aria-controls="key-setup" :title="chip?.title" :aria-label="chip?.title" @click="controls?.open()">
|
||||
<UiIcon name="bolt" :size="null" />
|
||||
<span data-key-setup-chip-label>{{ chip ? chip.label : t('POWER UP') }}</span>
|
||||
</button>
|
||||
</UiButton>
|
||||
<LocalePicker v-if="picker" :key="picker.current" :current="picker.current" :on-select="picker.onSelect" :focus="picker.focus" />
|
||||
</div>
|
||||
<aside v-if="available" id="key-setup" role="dialog" aria-labelledby="key-setup-title" aria-describedby="key-setup-description" :hidden="dialog.hidden" v-class-toggle="{ visible: dialog.visible }" :data-ready="view?.ready ? 'true' : undefined" @transitionend="controls?.transitionEnd()">
|
||||
@@ -66,16 +68,16 @@ const removeTitle = (title) =>
|
||||
<p class="key-setup-unlocks">{{ key.unlocks }}</p>
|
||||
<div v-if="!key.external" class="key-setup-fields">
|
||||
<input v-for="envVar in key.envVars" :key="envVar" type="password" autocomplete="off" spellcheck="false" :data-env-var="envVar" :aria-label="envVar" :placeholder="key.set ? t('{envVar} saved — paste to replace', { envVar }) : t('paste {envVar}', { envVar })" v-field-value="view.fields[envVar] ?? ''" @input="controls?.setField(envVar, $event.target.value)" />
|
||||
<button v-if="key.managed === 'file'" type="button" class="key-setup-remove" :data-key-setup-remove="JSON.stringify(key.envVars)" :title="removeTitle(key.title)" @click="controls?.remove(key.envVars)">{{ t('REMOVE') }}</button>
|
||||
<UiButton v-if="key.managed === 'file'" class="key-setup-remove" :data-key-setup-remove="JSON.stringify(key.envVars)" :title="removeTitle(key.title)" @click="controls?.remove(key.envVars)">{{ t('REMOVE') }}</UiButton>
|
||||
</div>
|
||||
<div v-if="key.id === 'openai'" class="key-setup-cloud-auth">
|
||||
<span class="key-setup-cloud-auth-state">{{ view.auth.mode === 'oauth' ? t('VOICE AUTH · CHATGPT OAUTH') : t('VOICE AUTH · API KEY') }}</span>
|
||||
<button type="button" class="key-setup-cloud-auth-toggle" data-cloud-voice-auth-toggle="true" :title="view.auth.mode === 'oauth' ? t('Use OPENAI_API_KEY for the next cloud voice session') : t('Use the signed-in local ChatGPT/Codex OAuth session for the next cloud voice session')" :aria-disabled="String(view.auth.busy)" @click="controls?.toggleAuth()">{{ view.auth.mode === 'oauth' ? t('USE API KEY') : t('USE CHATGPT OAUTH') }}</button>
|
||||
<UiButton class="key-setup-cloud-auth-toggle" data-cloud-voice-auth-toggle="true" :title="view.auth.mode === 'oauth' ? t('Use OPENAI_API_KEY for the next cloud voice session') : t('Use the signed-in local ChatGPT/Codex OAuth session for the next cloud voice session')" :aria-disabled="String(view.auth.busy)" @click="controls?.toggleAuth()">{{ view.auth.mode === 'oauth' ? t('USE API KEY') : t('USE CHATGPT OAUTH') }}</UiButton>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<div class="key-setup-footer">
|
||||
<button type="button" class="key-setup-apply" data-key-setup-apply :aria-disabled="view?.saving == null ? undefined : String(view.saving)" @click="controls?.apply()">{{ t('SAVE KEYS') }}</button>
|
||||
<UiButton class="key-setup-apply" data-key-setup-apply :aria-disabled="view?.saving == null ? undefined : String(view.saving)" @click="controls?.apply()">{{ t('SAVE KEYS') }}</UiButton>
|
||||
<span class="key-setup-hint">{{ t('ESC to close') }}</span>
|
||||
</div>
|
||||
<p class="key-setup-note" data-key-setup-status role="status" aria-live="polite" v-status-text="statusText"></p>
|
||||
|
||||
@@ -78,7 +78,7 @@ const vToastText = {
|
||||
<!-- Title -->
|
||||
<div id="title-bar">
|
||||
<div class="title-glow"></div>
|
||||
<h1 aria-labelledby="title-wordmark"><button type="button" class="title-logo brand-logo" data-logo-gaze data-logo-src="/logo.svg" :aria-label="t('Back to live at the starting view')" :title="t('Back to live at the starting view')" @click="globeActions.act('home')"><img src="/logo.svg" alt="" /></button> <span id="title-wordmark" translate="no">GOD'S EYE <span class="title-accent">VIEW</span></span></h1>
|
||||
<h1 aria-labelledby="title-wordmark"><UiButton class="title-logo brand-logo" data-logo-gaze data-logo-src="/logo.svg" :aria-label="t('Back to live at the starting view')" :title="t('Back to live at the starting view')" @click="globeActions.act('home')"><img src="/logo.svg" alt="" /></UiButton> <span id="title-wordmark" translate="no">GOD'S EYE <span class="title-accent">VIEW</span></span></h1>
|
||||
<p class="subtitle scene-text-holdout">{{ t('NO PLACE LEFT BEHIND') }}</p>
|
||||
<div v-if="fps" class="frame-rate-readout scene-text-holdout" :hidden="!fps.visible" :title="t('Rendered globe frames per second · toggle with `')">{{ fps.text }}</div>
|
||||
</div>
|
||||
|
||||
@@ -152,9 +152,9 @@ function markPopSeen() {
|
||||
/* storage off: the popup comes back next visit */
|
||||
}
|
||||
}
|
||||
function openExplore() {
|
||||
markPopSeen();
|
||||
store.controller.open();
|
||||
async function openExplore() {
|
||||
// A refused open (Cockpit) leaves the announcement unread.
|
||||
if (await store.controller.open()) markPopSeen();
|
||||
}
|
||||
|
||||
// ── Opened in GEV: a toast that leads back to the story ──
|
||||
|
||||
@@ -3,6 +3,7 @@ import { storeToRefs } from 'pinia';
|
||||
import { onBeforeUpdate, onUpdated, ref } from 'vue';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import { useContextStore } from '../../stores/context.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import AwarenessNames from './AwarenessNames.vue';
|
||||
|
||||
// The Contacts panel inside Context. The Contacts layer publishes its view
|
||||
@@ -66,16 +67,16 @@ onUpdated(() => {
|
||||
</a>
|
||||
<AwarenessNames v-if="view.subjectNames" :names="view.subjectNames" />
|
||||
<div class="military-awareness-controls" role="group" :aria-label="view.navigation.label">
|
||||
<button type="button" data-awareness-action="previous" :title="view.navigation.previous.title" :disabled="view.navigation.previous.disabled" @click="layer?.navigatePrevious(user)">{{ view.navigation.previous.text }}</button>
|
||||
<button type="button" data-awareness-action="focus" @click="layer?.focusCurrent(user)">{{ view.navigation.focus.text }}</button>
|
||||
<button type="button" data-awareness-action="next" :title="view.navigation.next.title" :disabled="view.navigation.next.disabled" @click="layer?.navigateNext(user)">{{ view.navigation.next.text }}</button>
|
||||
<UiButton data-awareness-action="previous" :title="view.navigation.previous.title" :disabled="view.navigation.previous.disabled" @click="layer?.navigatePrevious(user)">{{ view.navigation.previous.text }}</UiButton>
|
||||
<UiButton data-awareness-action="focus" @click="layer?.focusCurrent(user)">{{ view.navigation.focus.text }}</UiButton>
|
||||
<UiButton data-awareness-action="next" :title="view.navigation.next.title" :disabled="view.navigation.next.disabled" @click="layer?.navigateNext(user)">{{ view.navigation.next.text }}</UiButton>
|
||||
</div>
|
||||
<section v-for="row in view.rows" :key="row.id" :class="['military-awareness-row', row.relationship]">
|
||||
<div><strong>{{ row.label }}</strong><b aria-live="polite">{{ row.count }}</b></div>
|
||||
<small>{{ row.detail }}</small>
|
||||
<ul v-if="row.nearest.length">
|
||||
<li v-for="item in row.nearest" :key="item.key">
|
||||
<button v-if="item.targetId" type="button" class="military-awareness-target" :data-awareness-layer="item.layer" :data-awareness-id="item.targetId" :aria-label="item.ariaLabel" @click="layer?.focusTarget(item.layer, item.targetId, user)">{{ item.label }} <span>{{ item.distance }}</span></button>
|
||||
<UiButton v-if="item.targetId" class="military-awareness-target" :data-awareness-layer="item.layer" :data-awareness-id="item.targetId" :aria-label="item.ariaLabel" @click="layer?.focusTarget(item.layer, item.targetId, user)">{{ item.label }} <span>{{ item.distance }}</span></UiButton>
|
||||
<span v-else class="military-awareness-target unavailable" :aria-label="item.ariaLabel">{{ item.label }} <span>{{ item.distance }}</span></span>
|
||||
<AwarenessNames v-if="item.names" :names="item.names" />
|
||||
</li>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import { useBhoteKoshiPanelStore } from '../../stores/bhoteKoshiPanel.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiCloseButton from '../../kit/UiCloseButton.vue';
|
||||
import UiSlider from '../../kit/UiSlider.js';
|
||||
|
||||
@@ -44,30 +45,30 @@ const sliderValue = (event, scale) => Number(event.target.value) / scale;
|
||||
</div>
|
||||
<UiSlider class="bhote-event-range flood" unstyled data-role="progress" min="0" max="1000" :model-value="panel.refs.progressInput.value" :hidden="panel.refs.progressInput.hidden" :disabled="panel.refs.progressInput.disabled" :aria-label="panel.refs.progressInput.attributes['aria-label']" @update:model-value="call('previewProgress', $event / 1000)" @change="call('commitProgress', sliderValue($event, 1000), { final: true })" />
|
||||
<div class="bhote-event-story-nav" :aria-label="t('Story beat navigation')">
|
||||
<button type="button" data-action="previous-beat" :title="t('Previous story beat')" :aria-label="panel.refs.previousButton.attributes['aria-label']" :disabled="panel.refs.previousButton.disabled" @click="call('previousBeat')">‹</button>
|
||||
<UiButton data-action="previous-beat" :title="t('Previous story beat')" :aria-label="panel.refs.previousButton.attributes['aria-label']" :disabled="panel.refs.previousButton.disabled" @click="call('previousBeat')">‹</UiButton>
|
||||
<div class="bhote-event-story-current">
|
||||
<span data-role="beat-index">{{ panel.refs.beatIndex.textContent }}</span>
|
||||
<strong data-role="beat-title" aria-live="polite">{{ panel.refs.beatTitle.textContent }}</strong>
|
||||
<small data-role="beat-meta">{{ panel.refs.beatMeta.textContent }}</small>
|
||||
</div>
|
||||
<button type="button" data-action="next-beat" :title="t('Next story beat')" :aria-label="panel.refs.nextButton.attributes['aria-label']" :disabled="panel.refs.nextButton.disabled" @click="call('nextBeat')">›</button>
|
||||
<UiButton data-action="next-beat" :title="t('Next story beat')" :aria-label="panel.refs.nextButton.attributes['aria-label']" :disabled="panel.refs.nextButton.disabled" @click="call('nextBeat')">›</UiButton>
|
||||
</div>
|
||||
<div class="bhote-event-actions">
|
||||
<button type="button" data-action="play" :aria-label="panel.refs.playButton.attributes['aria-label']" :disabled="panel.refs.playButton.disabled" @click="call('play')">{{ panel.refs.playButton.textContent }}</button>
|
||||
<button type="button" data-action="play-scene" :hidden="panel.refs.playSceneButton.hidden" :title="t('Play the next shot and continue through this scene')" :aria-label="panel.refs.playSceneButton.attributes['aria-label']" :disabled="panel.refs.playSceneButton.disabled" @click="call('playScene')">{{ panel.refs.playSceneButton.textContent }}</button>
|
||||
<button type="button" data-action="cinematic" :aria-pressed="panel.refs.cinematicButton.attributes['aria-pressed']" :hidden="panel.refs.cinematicButton.hidden" :disabled="panel.refs.cinematicButton.disabled" @click="call('toggleCinematic')">{{ panel.refs.cinematicButton.textContent }}</button>
|
||||
<button type="button" data-action="story-replay" :aria-label="panel.refs.storyReplayButton.attributes['aria-label']" :hidden="panel.refs.storyReplayButton.hidden" :disabled="panel.refs.storyReplayButton.disabled" @click="call('replayCinematic')">{{ panel.refs.storyReplayButton.textContent }}</button>
|
||||
<button type="button" data-action="open-source" :hidden="panel.refs.openSourceButton.hidden" :disabled="panel.refs.openSourceButton.disabled" @click="call('openActiveSource')">{{ t('↗ OPEN ORIGINAL') }}</button>
|
||||
<button type="button" data-action="corridor" :hidden="panel.refs.corridorButton.hidden" :disabled="panel.refs.corridorButton.disabled" @click="call('focusCorridor')">{{ t('⌖ LOWER GORGE') }}</button>
|
||||
<UiButton data-action="play" :aria-label="panel.refs.playButton.attributes['aria-label']" :disabled="panel.refs.playButton.disabled" @click="call('play')">{{ panel.refs.playButton.textContent }}</UiButton>
|
||||
<UiButton data-action="play-scene" :hidden="panel.refs.playSceneButton.hidden" :title="t('Play the next shot and continue through this scene')" :aria-label="panel.refs.playSceneButton.attributes['aria-label']" :disabled="panel.refs.playSceneButton.disabled" @click="call('playScene')">{{ panel.refs.playSceneButton.textContent }}</UiButton>
|
||||
<UiButton data-action="cinematic" :pressed="Boolean(panel.refs.cinematicButton.pressed)" :hidden="panel.refs.cinematicButton.hidden" :disabled="panel.refs.cinematicButton.disabled" @click="call('toggleCinematic')">{{ panel.refs.cinematicButton.textContent }}</UiButton>
|
||||
<UiButton data-action="story-replay" :aria-label="panel.refs.storyReplayButton.attributes['aria-label']" :hidden="panel.refs.storyReplayButton.hidden" :disabled="panel.refs.storyReplayButton.disabled" @click="call('replayCinematic')">{{ panel.refs.storyReplayButton.textContent }}</UiButton>
|
||||
<UiButton data-action="open-source" :hidden="panel.refs.openSourceButton.hidden" :disabled="panel.refs.openSourceButton.disabled" @click="call('openActiveSource')">{{ t('↗ OPEN ORIGINAL') }}</UiButton>
|
||||
<UiButton data-action="corridor" :hidden="panel.refs.corridorButton.hidden" :disabled="panel.refs.corridorButton.disabled" @click="call('focusCorridor')">{{ t('⌖ LOWER GORGE') }}</UiButton>
|
||||
</div>
|
||||
</section>
|
||||
<details class="bhote-event-evidence">
|
||||
<summary>{{ t('FIELD REPORTS · {count}', { count: panel.reports.length }) }}</summary>
|
||||
<div class="bhote-event-report-list"><button v-for="(report, index) in panel.reports" :key="index" type="button" class="bhote-event-report" @click="call('openReport', index)"><span>{{ report.label }}</span><small>{{ report.status }}</small></button></div>
|
||||
<div class="bhote-event-report-list"><UiButton v-for="(report, index) in panel.reports" :key="index" class="bhote-event-report" @click="call('openReport', index)"><span>{{ report.label }}</span><small>{{ report.status }}</small></UiButton></div>
|
||||
</details>
|
||||
<div class="bhote-event-credit">
|
||||
<span>{{ t('GEOLOCATIONS · {credit}', { credit: 'GEO GEORGE SHADRACH' }) }}</span>
|
||||
<button type="button" data-action="geolocation-map" @click="call('openGeolocationMap')">{{ t('↗ OPEN PUBLIC MAP') }}</button>
|
||||
<UiButton data-action="geolocation-map" @click="call('openGeolocationMap')">{{ t('↗ OPEN PUBLIC MAP') }}</UiButton>
|
||||
</div>
|
||||
<p class="bhote-event-caveat"><span data-role="caveat">{{ panel.refs.caveat.textContent }}</span><span data-role="imagery-cloud-note" :hidden="panel.refs.imageryCloudNote.hidden">{{ t(' Clouds are preserved from the source imagery.') }}</span></p>
|
||||
</aside>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script setup>
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useCelestialRingStore } from '../../stores/celestialRing.js';
|
||||
import UiIcon from '../../kit/UiIcon.vue';
|
||||
|
||||
// The full-globe sun/moon ring, inside the viewer's container, as the ring
|
||||
// owner (src/celestialRing.js) presents it.
|
||||
@@ -44,6 +45,6 @@ const markerStyle = (marker) =>
|
||||
|
||||
<template>
|
||||
<Teleport v-if="ring" :to="ring.container">
|
||||
<div :key="ring.id" id="celestial-ring-overlay" class="celestial-ring-overlay" :class="{ visible: ring.visible, disabled: !ring.enabled }" aria-hidden="true" :data-globe-visible="ring.globeVisible ?? undefined" :data-ephemeris-updates="ring.ephemerisUpdates ?? undefined"><div class="celestial-ring-outline" :style="outlineStyle(ring.outline)"></div><canvas v-ring-canvas="{ owner: ring.owner, kind: 'sun' }" class="celestial-ring-canvas celestial-sun-canvas" :style="layerStyle(ring.sun)"></canvas><canvas v-ring-canvas="{ owner: ring.owner, kind: 'moon' }" class="celestial-ring-canvas celestial-moon-canvas" :style="layerStyle(ring.moon)"></canvas><span class="celestial-marker celestial-sun material-symbols-outlined" :style="markerStyle(ring.sunMarker)">light_mode</span><span class="celestial-marker celestial-moon material-symbols-outlined" :style="markerStyle(ring.moonMarker)">dark_mode</span></div>
|
||||
<div :key="ring.id" id="celestial-ring-overlay" class="celestial-ring-overlay" :class="{ visible: ring.visible, disabled: !ring.enabled }" aria-hidden="true" :data-globe-visible="ring.globeVisible ?? undefined" :data-ephemeris-updates="ring.ephemerisUpdates ?? undefined"><div class="celestial-ring-outline" :style="outlineStyle(ring.outline)"></div><canvas v-ring-canvas="{ owner: ring.owner, kind: 'sun' }" class="celestial-ring-canvas celestial-sun-canvas" :style="layerStyle(ring.sun)"></canvas><canvas v-ring-canvas="{ owner: ring.owner, kind: 'moon' }" class="celestial-ring-canvas celestial-moon-canvas" :style="layerStyle(ring.moon)"></canvas><UiIcon class="celestial-marker celestial-sun" name="light_mode" :size="null" :style="markerStyle(ring.sunMarker)" /><UiIcon class="celestial-marker celestial-moon" name="dark_mode" :size="null" :style="markerStyle(ring.moonMarker)" /></div>
|
||||
</Teleport>
|
||||
</template>
|
||||
@@ -5,7 +5,10 @@ import { t } from '../../../i18n/index.js';
|
||||
import { useVoiceStore } from '../../stores/voice.js';
|
||||
import { ASSISTANT_NAME } from '../../../voice/control.js';
|
||||
import PanelLayoutButtons from './PanelLayoutButtons.vue';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiIcon from '../../kit/UiIcon.vue';
|
||||
import UiCloseButton from '../../kit/UiCloseButton.vue';
|
||||
import UiSelect from '../../kit/UiSelect.js';
|
||||
|
||||
// The typed chat in the command dock, as its owner (src/voice/chatControl.js)
|
||||
// writes the voice control presenter. Messages arrive apart from the view, so
|
||||
@@ -15,7 +18,6 @@ const store = useVoiceStore();
|
||||
const { controls, chat: messages } = storeToRefs(store);
|
||||
const emit = (name, ...args) => controls.value?.emit(name, ...args);
|
||||
const list = ref(null);
|
||||
const layerSelect = ref(null);
|
||||
const layerChoice = ref('');
|
||||
|
||||
// The input holds what the person types until its owner writes it (history
|
||||
@@ -55,7 +57,6 @@ watch(messages, (next, previous) => {
|
||||
function attachLayer() {
|
||||
const value = layerChoice.value;
|
||||
layerChoice.value = '';
|
||||
if (layerSelect.value) layerSelect.value.value = '';
|
||||
if (value) emit('chat-layer', value);
|
||||
}
|
||||
|
||||
@@ -68,7 +69,7 @@ const quickPrompts = () => [t('Fly to Tokyo'), t('Show live flights')];
|
||||
<div><strong>{{ t('GEV CHAT') }}</strong><p>{{ t('Ask about the map. Tell it where to go.') }}</p></div>
|
||||
<div id="gev-chat-header-actions">
|
||||
<PanelLayoutButtons :docked="props.view.layout.docked" :minimized="props.view.chat.minimized" @dock="emit('layout-dock')" @minimize="emit('chat-minimize')" />
|
||||
<button v-if="props.view.panel" id="gev-voice-settings-button" class="gev-voice-settings-button" type="button" :aria-label="t('Settings')" :title="t('Settings')" aria-controls="gev-voice-panel" :aria-expanded="String(props.view.voicePanel.settingsExpanded)" @click="emit('settings-button')"><span class="material-symbols-outlined gev-voice-settings-icon" aria-hidden="true">settings</span></button>
|
||||
<UiButton v-if="props.view.panel" id="gev-voice-settings-button" class="gev-voice-settings-button" :aria-label="t('Settings')" :title="t('Settings')" aria-controls="gev-voice-panel" :aria-expanded="String(props.view.voicePanel.settingsExpanded)" @click="emit('settings-button')"><UiIcon name="settings" class="gev-voice-settings-icon" :size="null" /></UiButton>
|
||||
<UiCloseButton id="gev-chat-close" :label="t('Close chat')" @click="emit('chat-close')" />
|
||||
</div>
|
||||
</header>
|
||||
@@ -77,7 +78,7 @@ const quickPrompts = () => [t('Fly to Tokyo'), t('Show live flights')];
|
||||
<svg viewBox="0 0 24 24" width="32" height="32" fill="none" stroke="currentColor" stroke-width="1" aria-hidden="true"><circle cx="12" cy="12" r="10"></circle><ellipse cx="12" cy="12" rx="4" ry="10"></ellipse><path d="M2 12h20"></path></svg>
|
||||
<h3>{{ t('Explore with a question') }}</h3>
|
||||
<p>{{ t('Find a place, explore live data, or change your view.') }}</p>
|
||||
<button v-for="prompt in quickPrompts()" :key="prompt" type="button" :hidden="!props.view.chat.quickChecked" @click="emit('chat-prompt', prompt)">{{ prompt }}</button>
|
||||
<UiButton v-for="prompt in quickPrompts()" :key="prompt" :hidden="!props.view.chat.quickChecked" @click="emit('chat-prompt', prompt)">{{ prompt }}</UiButton>
|
||||
</div>
|
||||
<div v-for="message in messages" :key="message.id" class="gev-chat-message" :data-role="message.role">
|
||||
<small>{{ message.role === 'user' ? t('YOU') : ASSISTANT_NAME }}</small><span>{{ message.text }}</span>
|
||||
@@ -87,36 +88,36 @@ const quickPrompts = () => [t('Fly to Tokyo'), t('Show live flights')];
|
||||
<!-- Stays under the status for the whole conversation. -->
|
||||
<p v-if="props.view.chat.authNote" id="gev-chat-auth-note">{{ props.view.chat.authNote }}</p>
|
||||
<div id="gev-chat-attachments" :aria-label="t('Attachments')" :hidden="!props.view.chat.attachments.length">
|
||||
<button v-for="item in props.view.chat.attachments" :key="item.key" type="button" :disabled="props.view.chat.locked" :aria-label="`${t('Remove attachment')}: ${item.name}`" @click="emit('chat-attachment-remove', item.key)">{{ item.name }} ×</button>
|
||||
<UiButton v-for="item in props.view.chat.attachments" :key="item.key" :disabled="props.view.chat.locked" :aria-label="`${t('Remove attachment')}: ${item.name}`" @click="emit('chat-attachment-remove', item.key)">{{ item.name }} ×</UiButton>
|
||||
</div>
|
||||
<div id="gev-chat-attach-menu" :hidden="!props.view.chat.attachMenuOpen" @keydown="emit('chat-attach-keydown', $event)">
|
||||
<label for="gev-chat-layer">{{ t('Attach a map layer') }}</label>
|
||||
<div id="gev-chat-layer-row">
|
||||
<select id="gev-chat-layer" ref="layerSelect" :disabled="props.view.chat.locked" @change="layerChoice = $event.target.value" @keydown.enter.prevent="attachLayer()">
|
||||
<UiSelect id="gev-chat-layer" v-model="layerChoice" :disabled="props.view.chat.locked" @keydown.enter.prevent="attachLayer()">
|
||||
<option value="">{{ t('Choose a layer…') }}</option>
|
||||
<option v-for="layer in props.view.chat.layers" :key="layer.value" :value="layer.value">{{ layer.label }}</option>
|
||||
</select>
|
||||
<button id="gev-chat-layer-attach" type="button" :disabled="props.view.chat.locked || !layerChoice" @click="attachLayer()">{{ t('Attach layer') }}</button>
|
||||
</UiSelect>
|
||||
<UiButton id="gev-chat-layer-attach" :disabled="props.view.chat.locked || !layerChoice" @click="attachLayer()">{{ t('Attach layer') }}</UiButton>
|
||||
</div>
|
||||
<button id="gev-chat-file-button" type="button" :disabled="props.view.chat.locked" @click="emit('chat-file-button')">{{ t('Attach a file') }}</button>
|
||||
<UiButton id="gev-chat-file-button" :disabled="props.view.chat.locked" @click="emit('chat-file-button')">{{ t('Attach a file') }}</UiButton>
|
||||
<p>{{ t('TXT, Markdown, CSV, JSON or GeoJSON · up to 10 KB in total. Attachments are sent to your AI provider with your message.') }}</p>
|
||||
<input id="gev-chat-file" type="file" accept=".txt,.md,.csv,.json,.geojson" multiple hidden @change="emit('chat-files', $event.target)" />
|
||||
</div>
|
||||
<aside id="gev-chat-mini-reply" :hidden="!props.view.chat.miniReply" :aria-label="t('Latest AI response')">
|
||||
<header><span translate="no">{{ ASSISTANT_NAME }}</span><button id="gev-chat-expand-reply" type="button" :aria-label="t('Expand conversation')" :title="t('Expand conversation')" @click="emit('chat-restore')"><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="M14 4h6v6m0-6-7 7M10 20H4v-6m0 6 7-7"></path></svg></button></header>
|
||||
<header><span translate="no">{{ ASSISTANT_NAME }}</span><UiButton id="gev-chat-expand-reply" :aria-label="t('Expand conversation')" :title="t('Expand conversation')" @click="emit('chat-restore')"><svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="M14 4h6v6m0-6-7 7M10 20H4v-6m0 6 7-7"></path></svg></UiButton></header>
|
||||
<p id="gev-chat-mini-text" aria-live="polite">{{ props.view.chat.miniReply }}</p>
|
||||
</aside>
|
||||
<div id="gev-chat-suggestions" :aria-label="t('Command suggestions')" :hidden="!props.view.chat.suggestions.length">
|
||||
<div v-for="group in props.view.chat.suggestions" :key="group.label">
|
||||
<small>{{ group.label }}</small>
|
||||
<button v-for="command in group.items" :key="command" type="button" :title="command" @click="emit('chat-suggestion', command)">{{ command }}</button>
|
||||
<UiButton v-for="command in group.items" :key="command" :title="command" @click="emit('chat-suggestion', command)">{{ command }}</UiButton>
|
||||
</div>
|
||||
</div>
|
||||
<form id="gev-chat-form" @submit.prevent="emit('chat-submit')">
|
||||
<button id="gev-chat-restore" type="button" :aria-label="t('Expand chat')" :title="t('Expand chat')" @click="emit('chat-restore')"><svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="M5 4h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H9l-6 4V6a2 2 0 0 1 2-2Z"></path></svg></button>
|
||||
<button id="gev-chat-attach" type="button" :disabled="props.view.chat.busy" :aria-label="t('Add attachment')" :aria-expanded="String(props.view.chat.attachMenuOpen)" aria-controls="gev-chat-attach-menu" @click="emit('chat-attach-toggle')" @keydown="emit('chat-attach-keydown', $event)"><svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="m8 12 6-6a3 3 0 0 1 4 4l-8 8a5 5 0 0 1-7-7l9-9"></path></svg></button>
|
||||
<UiButton id="gev-chat-restore" :aria-label="t('Expand chat')" :title="t('Expand chat')" @click="emit('chat-restore')"><svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="M5 4h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H9l-6 4V6a2 2 0 0 1 2-2Z"></path></svg></UiButton>
|
||||
<UiButton id="gev-chat-attach" :disabled="props.view.chat.busy" :aria-label="t('Add attachment')" :aria-expanded="String(props.view.chat.attachMenuOpen)" aria-controls="gev-chat-attach-menu" @click="emit('chat-attach-toggle')" @keydown="emit('chat-attach-keydown', $event)"><svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="m8 12 6-6a3 3 0 0 1 4 4l-8 8a5 5 0 0 1-7-7l9-9"></path></svg></UiButton>
|
||||
<textarea id="gev-chat-input" v-owned-draft="{ text: props.view.chat.draft, revision: props.view.chat.draftRevision }" :rows="props.view.chat.rows" maxlength="4000" :aria-label="t('Message GEV')" :placeholder="t('Ask GEV anything about the map…')" @input="emit('chat-input', $event.target.value)" @keydown="emit('chat-keydown', $event)"></textarea>
|
||||
<button id="gev-chat-send" :type="props.view.chat.busy ? 'button' : 'submit'" :disabled="props.view.chat.sendDisabled" :data-busy="String(props.view.chat.busy)" :aria-label="props.view.chat.busy ? t('Stop reply') : t('Send message')" :title="props.view.chat.busy ? t('Stop reply') : t('Send message')" @click="props.view.chat.busy && emit('chat-stop')"><svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path class="gev-chat-enter-icon" d="M19 5v8H5m5-5-5 5 5 5"></path><rect class="gev-chat-stop-icon" x="6" y="6" width="12" height="12" rx="1.5" fill="currentColor" stroke="none"></rect></svg></button>
|
||||
<UiButton id="gev-chat-send" :type="props.view.chat.busy ? 'button' : 'submit'" :disabled="props.view.chat.sendDisabled" :data-busy="String(props.view.chat.busy)" :aria-label="props.view.chat.busy ? t('Stop reply') : t('Send message')" :title="props.view.chat.busy ? t('Stop reply') : t('Send message')" @click="props.view.chat.busy && emit('chat-stop')"><svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path class="gev-chat-enter-icon" d="M19 5v8H5m5-5-5 5 5 5"></path><rect class="gev-chat-stop-icon" x="6" y="6" width="12" height="12" rx="1.5" fill="currentColor" stroke="none"></rect></svg></UiButton>
|
||||
</form>
|
||||
</section>
|
||||
</template>
|
||||
@@ -4,15 +4,21 @@ import { computed, useTemplateRef } from 'vue';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import { createBriefState } from '../../cockpitBriefPages.js';
|
||||
import { useCockpitStore } from '../../stores/cockpit.js';
|
||||
import { useLiveStore } from '../../stores/live.js';
|
||||
import CockpitLivePage from './CockpitLivePage.vue';
|
||||
import CockpitRoute from './CockpitRoute.vue';
|
||||
import CockpitSignalList from './CockpitSignalList.vue';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiIcon from '../../kit/UiIcon.vue';
|
||||
|
||||
// The Cockpit briefing card. The Cockpit controller presents its pages,
|
||||
// cycle toggle, regional news and local conditions; until it does, the card
|
||||
// shows the state it starts in. The controls keep the controller's
|
||||
// listeners. The route card and the signal rows render themselves.
|
||||
// listeners. The route card, the signal rows and the LIVE page render
|
||||
// themselves; the LIVE page and its tab are there only while the subject has
|
||||
// a stream (the live store's view), which the controller is told of.
|
||||
const { presence, brief } = storeToRefs(useCockpitStore());
|
||||
const { view: live } = storeToRefs(useLiveStore());
|
||||
const initial = createBriefState();
|
||||
const b = computed(() => brief.value ?? initial);
|
||||
// The card's collapse, which its toggle and data-collapsed show.
|
||||
@@ -45,17 +51,17 @@ function leaveSignals() {
|
||||
<strong id="cockpit-brief-subtitle">{{ b.subtitle }}</strong>
|
||||
</div>
|
||||
<nav class="cockpit-card-actions cockpit-brief-actions" :aria-label="t('Cockpit briefing controls')">
|
||||
<button id="cockpit-brief-previous" type="button" :aria-label="t('Previous briefing page')" :title="t('Previous briefing page')">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">chevron_left</span>
|
||||
</button>
|
||||
<UiButton id="cockpit-brief-previous" :aria-label="t('Previous briefing page')" :title="t('Previous briefing page')">
|
||||
<UiIcon name="chevron_left" :size="null" />
|
||||
</UiButton>
|
||||
<span id="cockpit-brief-position" aria-live="polite">{{ b.position }}</span>
|
||||
<button id="cockpit-brief-next" type="button" :aria-label="t('Next briefing page')" :title="t('Next briefing page')">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">chevron_right</span>
|
||||
</button>
|
||||
<UiButton id="cockpit-brief-next" :aria-label="t('Next briefing page')" :title="t('Next briefing page')">
|
||||
<UiIcon name="chevron_right" :size="null" />
|
||||
</UiButton>
|
||||
<UiButton id="cockpit-brief-auto" :aria-label="b.autoLabel" :pressed="Boolean(b.autoRotate)" :title="b.autoHelp">{{ b.autoLabel }}</UiButton>
|
||||
<button id="cockpit-signal-toggle" type="button" :aria-label="collapsed ? t('Expand cockpit briefing panel') : t('Collapse cockpit briefing panel')" :aria-expanded="String(!collapsed)" :title="collapsed ? t('Expand briefing panel') : t('Collapse briefing panel')">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">{{ collapsed ? 'right_panel_open' : 'right_panel_close' }}</span>
|
||||
</button>
|
||||
<UiButton id="cockpit-signal-toggle" :aria-label="collapsed ? t('Expand cockpit briefing panel') : t('Collapse cockpit briefing panel')" :aria-expanded="String(!collapsed)" :title="collapsed ? t('Expand briefing panel') : t('Collapse briefing panel')">
|
||||
<UiIcon :name="collapsed ? 'right_panel_open' : 'right_panel_close'" :size="null" />
|
||||
</UiButton>
|
||||
</nav>
|
||||
</header>
|
||||
<div class="cockpit-brief-stage">
|
||||
@@ -79,13 +85,18 @@ function leaveSignals() {
|
||||
</div>
|
||||
<a class="cockpit-weather-credit" href="https://open-meteo.com/" target="_blank" rel="noopener">{{ t('Weather data by Open-Meteo.com') }}</a>
|
||||
</section>
|
||||
<section data-cockpit-brief-page="live" :aria-label="t('Live video')" :hidden="b.pageId !== 'live'">
|
||||
<CockpitLivePage v-if="live" :shown="b.pageId === 'live' && !collapsed" />
|
||||
</section>
|
||||
</div>
|
||||
<footer class="cockpit-signal-footer">
|
||||
<span id="cockpit-brief-source">{{ b.source }}</span>
|
||||
<nav class="cockpit-brief-tabs" :aria-label="t('Cockpit briefing pages')">
|
||||
<button type="button" data-cockpit-brief-index="0" :aria-label="t('Show Live Signals')" :aria-current="String(b.pageIndex === 0)">{{ t('SIG') }}</button>
|
||||
<button type="button" data-cockpit-brief-index="1" :aria-label="t('Show Regional News')" :aria-current="brief ? String(b.pageIndex === 1) : undefined">{{ t('NEWS') }}</button>
|
||||
<button type="button" data-cockpit-brief-index="2" :aria-label="t('Show Local Info')" :aria-current="brief ? String(b.pageIndex === 2) : undefined">{{ t('LOCAL') }}</button>
|
||||
<UiButton data-cockpit-brief-index="0" :aria-label="t('Show Live Signals')" :aria-current="String(b.pageIndex === 0)">{{ t('SIG') }}</UiButton>
|
||||
<UiButton data-cockpit-brief-index="1" :aria-label="t('Show Regional News')" :aria-current="brief ? String(b.pageIndex === 1) : undefined">{{ t('NEWS') }}</UiButton>
|
||||
<UiButton data-cockpit-brief-index="2" :aria-label="t('Show Local Info')" :aria-current="brief ? String(b.pageIndex === 2) : undefined">{{ t('LOCAL') }}</UiButton>
|
||||
<!-- Always in the markup (the controller binds the tabs once); hidden without a stream. -->
|
||||
<UiButton data-cockpit-brief-index="3" :hidden="!live" :aria-label="t('Show Live Video')" :aria-current="brief ? String(b.pageIndex === 3) : undefined">{{ t('LIVE') }}</UiButton>
|
||||
</nav>
|
||||
</footer>
|
||||
</aside>
|
||||
|
||||
@@ -6,6 +6,7 @@ import { createContextState } from '../../cockpitContextState.js';
|
||||
import { vClassToggle } from '../../rail/classToggle.js';
|
||||
import { useCockpitStore } from '../../stores/cockpit.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiIcon from '../../kit/UiIcon.vue';
|
||||
|
||||
// The Cockpit Contact card. The Cockpit controller presents its scope,
|
||||
// navigation, cohort counts, nearest contact and weather toggle; until it
|
||||
@@ -36,15 +37,15 @@ const weatherLabel = computed(() =>
|
||||
<strong id="cockpit-context-subject">{{ c.subject }}</strong>
|
||||
</div>
|
||||
<nav class="cockpit-card-actions cockpit-context-actions" :aria-label="t('Contact navigation')">
|
||||
<button id="cockpit-context-previous" type="button" :disabled="!c.canPrevious" :aria-label="t('Previous — prior visited contact in the 250 km window')" :title="t('Previous — prior visited contact in the 250 km window')">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">skip_previous</span>
|
||||
</button>
|
||||
<button id="cockpit-context-next" type="button" :disabled="!c.canNext" :aria-label="t('Next — nearest unvisited contact in the 250 km window')" :title="t('Next — nearest unvisited contact in the 250 km window')">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">skip_next</span>
|
||||
</button>
|
||||
<button id="cockpit-context-toggle" type="button" :aria-label="collapsed ? t('Expand Contact panel') : t('Collapse Contact panel')" :aria-expanded="String(!collapsed)" :title="collapsed ? t('Expand contact panel') : t('Collapse contact panel')">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">{{ collapsed ? 'chevron_right' : 'chevron_left' }}</span>
|
||||
</button>
|
||||
<UiButton id="cockpit-context-previous" :disabled="!c.canPrevious" :aria-label="t('Previous — prior visited contact in the 250 km window')" :title="t('Previous — prior visited contact in the 250 km window')">
|
||||
<UiIcon name="skip_previous" :size="null" />
|
||||
</UiButton>
|
||||
<UiButton id="cockpit-context-next" :disabled="!c.canNext" :aria-label="t('Next — nearest unvisited contact in the 250 km window')" :title="t('Next — nearest unvisited contact in the 250 km window')">
|
||||
<UiIcon name="skip_next" :size="null" />
|
||||
</UiButton>
|
||||
<UiButton id="cockpit-context-toggle" :aria-label="collapsed ? t('Expand Contact panel') : t('Collapse Contact panel')" :aria-expanded="String(!collapsed)" :title="collapsed ? t('Expand contact panel') : t('Collapse contact panel')">
|
||||
<UiIcon :name="collapsed ? 'chevron_right' : 'chevron_left'" :size="null" />
|
||||
</UiButton>
|
||||
</nav>
|
||||
<span class="cockpit-context-qualifier">{{ t('CONTEXT ONLY') }}</span>
|
||||
</header>
|
||||
@@ -55,7 +56,7 @@ const weatherLabel = computed(() =>
|
||||
<div v-class-toggle="{ unknown: c.cohorts['military-installations'].unknown }" role="listitem" data-context-cohort="military-installations"><span>{{ t('SITE') }}</span><strong>{{ c.cohorts['military-installations'].count }}</strong><small translate="no" :title="c.cohorts['military-installations'].source">{{ c.cohorts['military-installations'].source }}</small></div>
|
||||
</div>
|
||||
<div class="cockpit-context-nearest">
|
||||
<span id="cockpit-context-direction" v-class-toggle="{ unknown: c.direction.unknown }" class="material-symbols-outlined" :style="directionStyle" aria-hidden="true">navigation</span>
|
||||
<UiIcon id="cockpit-context-direction" v-class-toggle="{ unknown: c.direction.unknown }" name="navigation" :size="null" :style="directionStyle" />
|
||||
<div>
|
||||
<small>{{ t('NEAREST OBSERVED / MAPPED') }}</small>
|
||||
<strong id="cockpit-context-nearest-label" :aria-label="c.nearest.ariaLabel ?? undefined">{{ c.nearest.label }}</strong>
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
<script setup>
|
||||
import { onBeforeUnmount, watch } from 'vue';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiIcon from '../../kit/UiIcon.vue';
|
||||
import { useLiveScreen } from '../../liveScreen.js';
|
||||
|
||||
// The Cockpit briefing's LIVE page: the LIVE section of Context, in the
|
||||
// card's measure, for the ridden subject's streams. The briefing renders it
|
||||
// only while a stream is on offer. LiveControls builds the player into
|
||||
// `#cockpit-live-player-host` while the Cockpit is on (the right rail, and
|
||||
// the section's screen with it, is hidden there), only when the viewer
|
||||
// presses Play, under the notice that YouTube sees their IP address. The
|
||||
// page's controls call LiveControls through the live store, as the section's
|
||||
// do. Leaving the page, or the page going, stops the player.
|
||||
const props = defineProps({
|
||||
/** Whether the briefing shows this page now. */
|
||||
shown: { type: Boolean, default: true },
|
||||
});
|
||||
const {
|
||||
view,
|
||||
act,
|
||||
idle,
|
||||
playing,
|
||||
loading,
|
||||
offline,
|
||||
unavailable,
|
||||
badgeText,
|
||||
statusText,
|
||||
} = useLiveScreen();
|
||||
watch(
|
||||
() => props.shown,
|
||||
(now) => {
|
||||
if (!now) act('hideLive', 'cockpit');
|
||||
},
|
||||
);
|
||||
onBeforeUnmount(() => act('hideLive', 'cockpit'));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<template v-if="view">
|
||||
<div class="cockpit-live-subject">
|
||||
<strong>{{ view.label }}</strong>
|
||||
<span class="live-badge"><span class="live-dot" :class="{ 'on-air': playing, waiting: loading }" aria-hidden="true"></span><span id="cockpit-live-badge-text">{{ badgeText }}</span></span>
|
||||
</div>
|
||||
<div class="cockpit-live-pick" role="group" :aria-label="t('Stream')">
|
||||
<UiButton v-if="view.count > 1" id="cockpit-live-previous" type="button" class="live-step" @click="act('cycleLive', -1)" :aria-label="t('Previous stream')" :title="t('Previous stream')"><UiIcon name="chevron_left" :size="null" /></UiButton>
|
||||
<span id="cockpit-live-stream-title" class="live-stream-title" aria-live="polite">{{ t(view.current.title) }}<small v-if="view.count > 1"> · {{ view.index + 1 }}/{{ view.count }}</small></span>
|
||||
<UiButton v-if="view.count > 1" id="cockpit-live-next" type="button" class="live-step" @click="act('cycleLive', 1)" :aria-label="t('Next stream')" :title="t('Next stream')"><UiIcon name="chevron_right" :size="null" /></UiButton>
|
||||
</div>
|
||||
<p class="live-privacy cockpit-live-privacy">{{ t('Video plays from YouTube, which sees your IP address.') }}</p>
|
||||
<!-- The player's element stays put across re-renders: LiveControls mounts the player in it. -->
|
||||
<div class="live-screen" :class="{ active: playing || loading }">
|
||||
<div id="cockpit-live-player-host" class="live-player-host"></div>
|
||||
<UiButton v-if="idle" id="cockpit-live-play" class="live-play" @click="act('playLive')"><UiIcon name="play_arrow" :size="null" />{{ t('Play') }}</UiButton>
|
||||
<div v-if="offline || unavailable" class="live-card" :class="{ offline, unavailable }">
|
||||
<span class="live-card-dot" aria-hidden="true"></span>
|
||||
<strong>{{ offline ? t('Stream is offline') : t('This stream cannot play here') }}</strong>
|
||||
<UiButton v-if="offline" id="cockpit-live-retry" @click="act('retryLive')">{{ t('Try again') }}</UiButton>
|
||||
</div>
|
||||
</div>
|
||||
<p id="cockpit-live-status" class="cockpit-live-status" role="status" aria-live="polite">{{ statusText }}</p>
|
||||
<p class="cockpit-live-credit"><a :href="view.current.ownerUrl" target="_blank" rel="noopener noreferrer">{{ view.current.owner }}</a> · <a id="cockpit-live-watch-link" :href="view.current.watchUrl" target="_blank" rel="noopener noreferrer">{{ t('Open on YouTube') }}</a></p>
|
||||
</template>
|
||||
</template>
|
||||
@@ -14,6 +14,8 @@ import {
|
||||
shownOwnerMark,
|
||||
} from '../../ownerFlag.js';
|
||||
import { useCockpitStore } from '../../stores/cockpit.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiIcon from '../../kit/UiIcon.vue';
|
||||
|
||||
// The orbital view's HUD: a nadir reticle over the picture, the satellite's
|
||||
// identity and orbit, and the optical zoom. The Cockpit controller presents
|
||||
@@ -118,14 +120,15 @@ const sensorStepShown = computed(
|
||||
// A focused control that turns off (a zoom button at the end of its range,
|
||||
// SENSOR as the view tilts away) hands focus on instead of dropping it to the
|
||||
// page. The watchers run before the re-render, while it still has focus.
|
||||
// Each ref holds a UiButton, whose element is its `$el`.
|
||||
const zoomInButton = ref(null);
|
||||
const zoomOutButton = ref(null);
|
||||
const sensorButton = ref(null);
|
||||
const nadirButton = ref(null);
|
||||
const handFocus = (from, to) => {
|
||||
if (!from || document.activeElement !== from) return;
|
||||
if (!from?.$el || document.activeElement !== from.$el) return;
|
||||
nextTick(() =>
|
||||
(to() ?? document.getElementById('map-view-switch'))?.focus({
|
||||
(to()?.$el ?? document.getElementById('map-view-switch'))?.focus({
|
||||
preventScroll: true,
|
||||
}),
|
||||
);
|
||||
@@ -220,6 +223,8 @@ const shownMark = computed(() =>
|
||||
const identParts = computed(() => {
|
||||
const o = orbital.value;
|
||||
if (!o) return [];
|
||||
// A module with no catalog entry (the Cupola) shows its facts instead.
|
||||
if (Array.isArray(o.facts) && o.facts.length) return [...o.facts];
|
||||
const parts = [];
|
||||
if (o.noradId !== null && o.noradId !== undefined && o.noradId !== '')
|
||||
parts.push(t('NORAD {id}', { id: String(o.noradId) }));
|
||||
@@ -250,6 +255,11 @@ watch(
|
||||
|
||||
// The off-nadir tilt; an untilted view shows no readout or reset.
|
||||
const look = computed(() => orbital.value?.look || { offset: false });
|
||||
// Riding the station from a mount on its 3D model: the view's name, or null
|
||||
// for the straight-down picture every other satellite has.
|
||||
const mount = computed(() => orbital.value?.mount ?? null);
|
||||
// The station offers several views; with two or more, the arrows step through them.
|
||||
const mountViews = computed(() => orbital.value?.mountViews ?? 0);
|
||||
// A ground focus names its target in a polite live region; the angle,
|
||||
// which changes every update, is left out of it.
|
||||
const focusText = computed(() => {
|
||||
@@ -270,7 +280,8 @@ const lensStyle = computed(() => {
|
||||
<section id="cockpit-orbital" class="cockpit-orbital" :class="{ 'cockpit-orbital-focusing': transition.active }" :style="lensStyle" :aria-label="t('Orbital view')" :hidden="!orbital">
|
||||
<template v-if="orbital">
|
||||
<div class="cockpit-orbital-lens" aria-hidden="true"></div>
|
||||
<div class="cockpit-orbital-reticle" :class="{ 'cockpit-orbital-reticle-lock': transition.lockTick }" aria-hidden="true">
|
||||
<!-- The nadir reticle and its north pointer; a view from the station has no ground point at its centre. -->
|
||||
<div v-if="mount === null" class="cockpit-orbital-reticle" :class="{ 'cockpit-orbital-reticle-lock': transition.lockTick }" aria-hidden="true">
|
||||
<span class="cockpit-orbital-bracket cockpit-orbital-bracket-tl"></span>
|
||||
<span class="cockpit-orbital-bracket cockpit-orbital-bracket-tr"></span>
|
||||
<span class="cockpit-orbital-bracket cockpit-orbital-bracket-bl"></span>
|
||||
@@ -287,7 +298,7 @@ const lensStyle = computed(() => {
|
||||
<!-- Under the vision selector: where the ground track is. -->
|
||||
<p v-if="placeText" id="cockpit-orbital-over" class="cockpit-orbital-over"><span>{{ t('CURRENTLY OVER') }}</span> <strong>{{ placeText }}</strong></p>
|
||||
<div class="cockpit-orbital-readout">
|
||||
<p class="cockpit-orbital-kicker">{{ look.offset ? t('ORBITAL VIEW · OFF-NADIR') : t('ORBITAL VIEW · NADIR') }}</p>
|
||||
<p class="cockpit-orbital-kicker">{{ mount !== null ? t('STATION VIEW · {name}', { name: mount }) : look.offset ? t('ORBITAL VIEW · OFF-NADIR') : t('ORBITAL VIEW · NADIR') }}</p>
|
||||
<div class="cockpit-orbital-title">
|
||||
<span v-if="shownMark?.kind === 'flag'" class="cockpit-orbital-flag" role="img" :aria-label="shownMark.label" :title="shownMark.label" :style="shownMark.style"></span>
|
||||
<span v-else-if="shownMark?.kind === 'badge'" class="cockpit-orbital-owner-badge" :title="shownMark.title">{{ shownMark.label }}</span>
|
||||
@@ -298,7 +309,7 @@ const lensStyle = computed(() => {
|
||||
<div v-if="identText" class="cockpit-orbital-ident">
|
||||
<!-- Wraps between parts, never inside a date. -->
|
||||
<span class="cockpit-orbital-ident-text"><template v-for="(part, index) in identParts" :key="index"><template v-if="index"> · </template><span class="cockpit-orbital-ident-part">{{ part }}</span></template></span>
|
||||
<button v-if="tleText" id="cockpit-orbital-tle-toggle" type="button" class="cockpit-orbital-tle-toggle" :aria-expanded="String(tleOpen)" aria-controls="cockpit-orbital-tle" :aria-label="tleOpen ? t('Hide the two-line element set') : t('Show the two-line element set')" :title="tleOpen ? t('Hide the two-line element set') : t('Show the two-line element set')" @click="tleOpen = !tleOpen">{{ t('TLE') }}</button>
|
||||
<UiButton v-if="tleText" id="cockpit-orbital-tle-toggle" class="cockpit-orbital-tle-toggle" :aria-expanded="String(tleOpen)" aria-controls="cockpit-orbital-tle" :aria-label="tleOpen ? t('Hide the two-line element set') : t('Show the two-line element set')" :title="tleOpen ? t('Hide the two-line element set') : t('Show the two-line element set')" @click="tleOpen = !tleOpen">{{ t('TLE') }}</UiButton>
|
||||
</div>
|
||||
<pre v-if="tleText" v-show="tleOpen" id="cockpit-orbital-tle" class="cockpit-orbital-tle" :aria-label="t('Two-line element set')">{{ tleText }}</pre>
|
||||
<dl class="cockpit-orbital-data">
|
||||
@@ -315,21 +326,27 @@ const lensStyle = computed(() => {
|
||||
<dd class="cockpit-orbital-subpoint">{{ subPointText }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<p class="cockpit-orbital-north">{{ trackUp ? t('TRACK UP') : t('NORTH UP') }}</p>
|
||||
<p v-if="mount === null" class="cockpit-orbital-north">{{ trackUp ? t('TRACK UP') : t('NORTH UP') }}</p>
|
||||
<!-- A station view: which one it is, and the step to the next. -->
|
||||
<div v-if="mount !== null && mountViews > 1" class="cockpit-orbital-look cockpit-orbital-views">
|
||||
<UiButton id="cockpit-orbital-view-previous" class="cockpit-orbital-nadir cockpit-orbital-view-step" :aria-label="t('Previous station view')" :title="t('Previous station view')"><UiIcon name="chevron_left" :size="null" /></UiButton>
|
||||
<span id="cockpit-orbital-view-name" class="cockpit-orbital-look-readout" aria-live="polite">{{ mount }}</span>
|
||||
<UiButton id="cockpit-orbital-view-next" class="cockpit-orbital-nadir cockpit-orbital-view-step" :aria-label="t('Next station view')" :title="t('Next station view')"><UiIcon name="chevron_right" :size="null" /></UiButton>
|
||||
</div>
|
||||
<!-- Shown only while the view is tilted off nadir: where it looks and the way back. -->
|
||||
<div v-if="look.offset" class="cockpit-orbital-look">
|
||||
<span id="cockpit-orbital-look-readout" class="cockpit-orbital-look-readout" :aria-live="look.focus ? 'off' : 'polite'">{{ look.readout }}</span>
|
||||
<button id="cockpit-orbital-nadir" ref="nadirButton" type="button" class="cockpit-orbital-nadir" :aria-label="t('Return the view to nadir')" :title="t('Return to nadir (Home or 0)')" aria-keyshortcuts="Home 0">{{ t('NADIR') }}</button>
|
||||
<UiButton id="cockpit-orbital-nadir" ref="nadirButton" class="cockpit-orbital-nadir" :aria-label="mount !== null ? t('Return to the default view') : t('Return the view to nadir')" :title="mount !== null ? t('Return to the default view') : t('Return to nadir (Home or 0)')" aria-keyshortcuts="Home 0">{{ mount !== null ? t('RESET') : t('NADIR') }}</UiButton>
|
||||
</div>
|
||||
<p id="cockpit-orbital-focus" class="cockpit-orbital-focus" aria-live="polite">{{ focusText }}</p>
|
||||
</div>
|
||||
<div class="cockpit-orbital-optics">
|
||||
<button id="cockpit-orbital-zoom-out" ref="zoomOutButton" type="button" class="cockpit-orbital-zoom-button" :disabled="atWidest" :aria-label="t('Zoom out')" :title="t('Zoom out (−)')" aria-keyshortcuts="- _">−</button>
|
||||
<UiButton id="cockpit-orbital-zoom-out" ref="zoomOutButton" class="cockpit-orbital-zoom-button" :disabled="atWidest" :aria-label="t('Zoom out')" :title="t('Zoom out (−)')" aria-keyshortcuts="- _">−</UiButton>
|
||||
<span class="cockpit-orbital-zoom" aria-live="polite">{{ zoomText }}</span>
|
||||
<button id="cockpit-orbital-zoom-in" ref="zoomInButton" type="button" class="cockpit-orbital-zoom-button" :disabled="atTightest" :aria-label="t('Zoom in')" :title="t('Zoom in (+)')" aria-keyshortcuts="+ =">+</button>
|
||||
<UiButton id="cockpit-orbital-zoom-in" ref="zoomInButton" class="cockpit-orbital-zoom-button" :disabled="atTightest" :aria-label="t('Zoom in')" :title="t('Zoom in (+)')" aria-keyshortcuts="+ =">+</UiButton>
|
||||
<span v-if="swathText" class="cockpit-orbital-swath">{{ swathText }}</span>
|
||||
<span v-if="sensorText" class="cockpit-orbital-swath cockpit-orbital-sensor-swath">{{ sensorText }}</span>
|
||||
<button v-if="sensorStepShown" id="cockpit-orbital-sensor" ref="sensorButton" type="button" class="cockpit-orbital-sensor-step" :aria-label="t('Zoom to the imaging sensor swath')" :title="t('Zoom to the imaging sensor swath')">{{ t('SENSOR') }}</button>
|
||||
<UiButton v-if="sensorStepShown" id="cockpit-orbital-sensor" ref="sensorButton" class="cockpit-orbital-sensor-step" :aria-label="t('Zoom to the imaging sensor swath')" :title="t('Zoom to the imaging sensor swath')">{{ t('SENSOR') }}</UiButton>
|
||||
</div>
|
||||
</template>
|
||||
</section>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { storeToRefs } from 'pinia';
|
||||
import { computed, onBeforeUnmount, ref, watch } from 'vue';
|
||||
import { formatNumber, t, tn } from '../../../i18n/index.js';
|
||||
import { useCockpitStore } from '../../stores/cockpit.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
|
||||
// The bridge radar: a heading-up scope of nearby AIS vessels, with a line
|
||||
// where the bridge view looks when it is turned off the bow. The Cockpit
|
||||
@@ -158,7 +159,7 @@ const rangeAction = computed(() =>
|
||||
</template>
|
||||
</div>
|
||||
<div class="cockpit-radar-readout">
|
||||
<button id="cockpit-radar-range" type="button" class="cockpit-radar-range" :aria-label="rangeAction" :title="rangeAction">{{ rangeLabel }}</button>
|
||||
<UiButton id="cockpit-radar-range" class="cockpit-radar-range" :aria-label="rangeAction" :title="rangeAction">{{ rangeLabel }}</UiButton>
|
||||
<span class="cockpit-radar-rings">{{ ringLabel }}</span>
|
||||
<span class="cockpit-radar-count">{{ countLabel }}</span>
|
||||
</div>
|
||||
|
||||
@@ -4,6 +4,7 @@ import { computed } from 'vue';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import { createRouteState } from '../../cockpitInstrumentState.js';
|
||||
import { useCockpitStore } from '../../stores/cockpit.js';
|
||||
import UiIcon from '../../kit/UiIcon.vue';
|
||||
|
||||
// The Cockpit flight plan card. The Cockpit controller presents the route's
|
||||
// endpoints and whether a destination direction exists; until it does, the
|
||||
@@ -39,7 +40,7 @@ const label = computed(() =>
|
||||
<span>{{ t('FROM') }}</span>
|
||||
<strong id="cockpit-route-from">{{ r.from }}</strong>
|
||||
</div>
|
||||
<span v-if="r.kind !== 'vessel'" class="cockpit-route-arrow material-symbols-outlined" aria-hidden="true">east</span>
|
||||
<UiIcon v-if="r.kind !== 'vessel'" name="east" class="cockpit-route-arrow" :size="null" />
|
||||
<div class="cockpit-route-airport">
|
||||
<span>{{ t('TO') }}</span>
|
||||
<strong id="cockpit-route-to">{{ r.to }}</strong>
|
||||
|
||||
@@ -3,6 +3,8 @@ import { storeToRefs } from 'pinia';
|
||||
import { computed } from 'vue';
|
||||
import { vFocusSafeChildren } from '../../rail/focusSafeChildren.js';
|
||||
import { useCockpitStore } from '../../stores/cockpit.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiIcon from '../../kit/UiIcon.vue';
|
||||
|
||||
// The Cockpit's live signal rows. The Cockpit controller presents them;
|
||||
// until it does, the list is empty. Rows reorder several times a second,
|
||||
@@ -18,5 +20,5 @@ const rows = computed(() => signals.value ?? []);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ol id="cockpit-signal-list" v-focus-safe-children="leave" class="cockpit-signal-list" aria-live="polite"><li v-for="row in rows" :key="row.key" :class="row.className" :data-signal-key="row.key"><time>{{ row.time }}</time><div><button v-if="row.target" type="button" class="cockpit-signal-target" :data-signal-layer="row.target.layerId" :data-signal-id="row.target.id" :aria-label="row.target.label"><span class="cockpit-signal-target-label">{{ row.title }}</span><span class="cockpit-signal-target-rule" aria-hidden="true"></span><span class="material-symbols-outlined cockpit-signal-target-chevron" aria-hidden="true">chevron_right</span></button><strong v-else>{{ row.title }}</strong><span>{{ row.detail }}</span></div></li></ol>
|
||||
<ol id="cockpit-signal-list" v-focus-safe-children="leave" class="cockpit-signal-list" aria-live="polite"><li v-for="row in rows" :key="row.key" :class="row.className" :data-signal-key="row.key"><time>{{ row.time }}</time><div><UiButton v-if="row.target" class="cockpit-signal-target" :data-signal-layer="row.target.layerId" :data-signal-id="row.target.id" :aria-label="row.target.label"><span class="cockpit-signal-target-label">{{ row.title }}</span><span class="cockpit-signal-target-rule" aria-hidden="true"></span><UiIcon name="chevron_right" class="cockpit-signal-target-chevron" :size="null" /></UiButton><strong v-else>{{ row.title }}</strong><span>{{ row.detail }}</span></div></li></ol>
|
||||
</template>
|
||||
@@ -8,6 +8,7 @@ import { useRadioStore } from '../../stores/radio.js';
|
||||
import { useCockpitStore } from '../../stores/cockpit.js';
|
||||
import { useDisplayStore } from '../../stores/display.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiIcon from '../../kit/UiIcon.vue';
|
||||
|
||||
// The Cockpit's Display and Radio launchers and their popovers, and the
|
||||
// desktop look's rail, whose icons stay at the edge and open one panel at a
|
||||
@@ -54,8 +55,8 @@ const radioLabel = computed(() =>
|
||||
<div class="cockpit-utility-launcher" data-cockpit-launcher="display">
|
||||
<span>{{ t('DISPLAY') }}</span>
|
||||
<span class="cockpit-utility-divider" aria-hidden="true"></span>
|
||||
<button v-if="open.display" type="button" class="cockpit-utility-collapse" :aria-label="t('Collapse panel')" :title="t('Collapse panel')" @click="act('toggleCockpitUtility', 'display', { returnFocus: true })">−</button>
|
||||
<button id="cockpit-display-toggle-btn" class="cockpit-utility-glyph" type="button" :aria-expanded="String(open.display)" aria-controls="cockpit-display-panel" :aria-label="displayLabel" :title="displayLabel">{{ open.display ? '▶' : '◀' }}</button>
|
||||
<UiButton v-if="open.display" class="cockpit-utility-collapse" :aria-label="t('Collapse panel')" :title="t('Collapse panel')" @click="act('toggleCockpitUtility', 'display', { returnFocus: true })">−</UiButton>
|
||||
<UiButton id="cockpit-display-toggle-btn" class="cockpit-utility-glyph" :aria-expanded="String(open.display)" aria-controls="cockpit-display-panel" :aria-label="displayLabel" :title="displayLabel">{{ open.display ? '▶' : '◀' }}</UiButton>
|
||||
</div>
|
||||
<div id="cockpit-display-panel" class="cockpit-utility-popover ui-scroll" v-class-toggle="{ 'uses-shared-display-controls': !!cockpitPortal }" role="group" :aria-label="t('Cockpit display options')" :hidden="!open.display">
|
||||
<div class="cockpit-display-slot" data-cockpit-display-slot="hud"></div>
|
||||
@@ -68,16 +69,16 @@ const radioLabel = computed(() =>
|
||||
<div class="cockpit-utility-launcher" data-cockpit-launcher="radio">
|
||||
<span>{{ t('RADIO') }}</span>
|
||||
<span class="cockpit-utility-divider" aria-hidden="true"></span>
|
||||
<button v-if="open.radio" type="button" class="cockpit-utility-collapse" :aria-label="t('Collapse panel')" :title="t('Collapse panel')" @click="act('toggleCockpitUtility', 'radio', { returnFocus: true })">−</button>
|
||||
<button id="cockpit-radio-toggle-btn" @click="act('toggleCockpitRadio')" class="cockpit-utility-glyph" type="button" :aria-expanded="String(open.radio)" aria-controls="cockpit-radio-panel" :aria-label="radioLabel" :title="radioLabel">{{ open.radio ? '▶' : '◀' }}</button>
|
||||
<UiButton v-if="open.radio" class="cockpit-utility-collapse" :aria-label="t('Collapse panel')" :title="t('Collapse panel')" @click="act('toggleCockpitUtility', 'radio', { returnFocus: true })">−</UiButton>
|
||||
<UiButton id="cockpit-radio-toggle-btn" @click="act('toggleCockpitRadio')" class="cockpit-utility-glyph" :aria-expanded="String(open.radio)" aria-controls="cockpit-radio-panel" :aria-label="radioLabel" :title="radioLabel">{{ open.radio ? '▶' : '◀' }}</UiButton>
|
||||
</div>
|
||||
<div id="cockpit-radio-panel" class="cockpit-utility-popover cockpit-radio-compact" role="group" :aria-label="t('Cockpit compact Radio controls')" :hidden="!open.radio">
|
||||
<strong id="cockpit-radio-station" class="cockpit-radio-station">{{ cockpit ? cockpit.station : t('READY') }}</strong>
|
||||
<UiButton id="cockpit-radio-enable-btn" @click="act('toggleRadio', 'cockpit')" class="panel-layer-toggle" :pressed="cockpit?.enable.active ?? false" pressed-class="active" :aria-label="cockpit?.enable.label" :aria-disabled="cockpit ? String(cockpit.enable.busy) : undefined" :aria-busy="cockpit ? String(cockpit.enable.busy) : undefined">{{ cockpit ? cockpit.enable.text : t('ENABLE') }}</UiButton>
|
||||
<UiButton id="cockpit-radio-enable-btn" @click="act('toggleRadio', 'cockpit')" class="panel-layer-toggle" :pressed="Boolean(cockpit?.enable.active)" pressed-class="active" :aria-label="cockpit?.enable.label" :aria-disabled="cockpit ? String(cockpit.enable.busy) : undefined" :aria-busy="cockpit ? String(cockpit.enable.busy) : undefined">{{ cockpit ? cockpit.enable.text : t('ENABLE') }}</UiButton>
|
||||
<div class="cockpit-radio-transport">
|
||||
<button id="cockpit-radio-prev-btn" @click="act('cycleRadio', -1, { rotate: false })" type="button" :aria-label="t('Previous filtered radio station')" :disabled="radio ? radio.transport.stepDisabled : true">◀◀</button>
|
||||
<button id="cockpit-radio-play-btn" @click="act('toggleRadioPlayback')" type="button" v-class-toggle="{ active: radio?.transport.play.active }" :aria-label="radio ? radio.transport.play.label : t('Play selected radio station')" :title="cockpit?.play.title" :disabled="radio ? radio.transport.play.disabled : true">{{ cockpit ? cockpit.play.glyph : '▶' }}</button>
|
||||
<button id="cockpit-radio-next-btn" @click="act('cycleRadio', 1, { rotate: false })" type="button" :aria-label="t('Next filtered radio station')" :disabled="radio ? radio.transport.stepDisabled : true">▶▶</button>
|
||||
<UiButton id="cockpit-radio-prev-btn" @click="act('cycleRadio', -1, { rotate: false })" :aria-label="t('Previous filtered radio station')" :disabled="radio ? radio.transport.stepDisabled : true">◀◀</UiButton>
|
||||
<UiButton id="cockpit-radio-play-btn" @click="act('toggleRadioPlayback')" v-class-toggle="{ active: radio?.transport.play.active }" :aria-label="radio ? radio.transport.play.label : t('Play selected radio station')" :title="cockpit?.play.title" :disabled="radio ? radio.transport.play.disabled : true">{{ cockpit ? cockpit.play.glyph : '▶' }}</UiButton>
|
||||
<UiButton id="cockpit-radio-next-btn" @click="act('cycleRadio', 1, { rotate: false })" :aria-label="t('Next filtered radio station')" :disabled="radio ? radio.transport.stepDisabled : true">▶▶</UiButton>
|
||||
</div>
|
||||
<label class="cockpit-radio-volume" for="cockpit-radio-volume">
|
||||
<span>{{ t('VOLUME') }}</span>
|
||||
@@ -92,8 +93,8 @@ const radioLabel = computed(() =>
|
||||
<span>{{ t('RADIO') }}</span>
|
||||
</span>
|
||||
<span class="cockpit-utility-rail__icons">
|
||||
<button type="button" class="cockpit-utility-rail__item" data-cockpit-rail-item="display" :class="{ 'is-on': open.display }" :aria-expanded="String(open.display)" aria-controls="cockpit-display-panel" :aria-label="displayLabel" :title="displayLabel" @click="act('toggleCockpitUtility', 'display')"><span class="material-symbols-outlined" aria-hidden="true">tune</span></button>
|
||||
<button type="button" class="cockpit-utility-rail__item" data-cockpit-rail-item="radio" :class="{ 'is-on': open.radio }" :aria-expanded="String(open.radio)" aria-controls="cockpit-radio-panel" :aria-label="radioLabel" :title="radioLabel" @click="act('toggleCockpitUtility', 'radio')"><span class="material-symbols-outlined" aria-hidden="true">radio</span></button>
|
||||
<UiButton class="cockpit-utility-rail__item" data-cockpit-rail-item="display" :class="{ 'is-on': open.display }" :aria-expanded="String(open.display)" aria-controls="cockpit-display-panel" :aria-label="displayLabel" :title="displayLabel" @click="act('toggleCockpitUtility', 'display')"><UiIcon name="tune" :size="null" /></UiButton>
|
||||
<UiButton class="cockpit-utility-rail__item" data-cockpit-rail-item="radio" :class="{ 'is-on': open.radio }" :aria-expanded="String(open.radio)" aria-controls="cockpit-radio-panel" :aria-label="radioLabel" :title="radioLabel" @click="act('toggleCockpitUtility', 'radio')"><UiIcon name="radio" :size="null" /></UiButton>
|
||||
</span>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { storeToRefs } from 'pinia';
|
||||
import { computed } from 'vue';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiIcon from '../../kit/UiIcon.vue';
|
||||
import UiSegmented from '../../kit/UiSegmented.vue';
|
||||
import { useDisplayStore } from '../../stores/display.js';
|
||||
import DrawMarkList from './DrawMarkList.vue';
|
||||
@@ -27,7 +28,7 @@ const shapeOptions = computed(() => [
|
||||
<template>
|
||||
<div class="pp-toggle-group" id="draw-group">
|
||||
<UiButton class="pp-toggle-btn" :pressed="draw?.active ?? false" pressed-class="active" id="draw-toggle" @click="act('toggleDraw')" :title="t('Draw on the world — click vertices, double-click or Enter to finish, Esc to cancel')">
|
||||
<span class="pp-icon material-symbols-outlined" aria-hidden="true">draw</span>
|
||||
<UiIcon class="pp-icon" name="draw" :size="null" />
|
||||
<span class="pp-label">{{ t('Draw') }}</span>
|
||||
</UiButton>
|
||||
<div class="pp-slider-row" :class="{ visible: draw?.active }" id="draw-mode-row">
|
||||
@@ -36,7 +37,7 @@ const shapeOptions = computed(() => [
|
||||
</div>
|
||||
<div class="pp-slider-row" :class="{ visible: draw?.active }" id="draw-label-row">
|
||||
<span class="draw-hint" id="draw-hint" aria-live="polite">{{ draw?.hint ?? '' }}</span>
|
||||
<button class="pp-mode-btn draw-clear-btn" id="draw-clear" type="button" @click="act('clearDraw')" :title="t('Remove every mark from the board')">{{ t('Clear') }}</button>
|
||||
<UiButton class="pp-mode-btn draw-clear-btn" id="draw-clear" @click="act('clearDraw')" :title="t('Remove every mark from the board')">{{ t('Clear') }}</UiButton>
|
||||
</div>
|
||||
<DrawMarkList />
|
||||
</div>
|
||||
|
||||
@@ -6,7 +6,9 @@ import { DRAW_COLOR_CSS } from '../../../annotations/drawMarks.js';
|
||||
import { vFieldValue } from '../../rail/fieldValue.js';
|
||||
import { vFocusSafeChildren } from '../../rail/focusSafeChildren.js';
|
||||
import DrawSwatches from './DrawSwatches.vue';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiCloseButton from '../../kit/UiCloseButton.vue';
|
||||
import UiIcon from '../../kit/UiIcon.vue';
|
||||
import { useDisplayStore } from '../../stores/display.js';
|
||||
|
||||
// UTILITIES ▸ Draw's shapes, one row each like Import's files: the colour
|
||||
@@ -100,5 +102,5 @@ function leave() {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ul class="geo-import-list draw-mark-list" :class="{ visible: listed }" id="draw-mark-list" v-focus-safe-children="leave" :aria-label="t('Drawn shapes')"><li v-for="row in rows" :key="row.id" class="geo-import-row draw-mark-row" :class="{ 'hidden-mark': row.hidden }" :data-mark-id="row.id" @keydown="onRowKey(row, $event)"><button type="button" class="geo-import-swatch draw-mark-swatch" data-control="swatch" :style="{ background: DRAW_COLOR_CSS[row.color] }" :title="row.labels.swatch" :aria-label="row.labels.swatch" :aria-expanded="String(picking === row.id)" :aria-controls="`draw-mark-colors-${row.id}`" @click="picking = picking === row.id ? null : row.id"></button><DrawSwatches v-if="picking === row.id" :id="`draw-mark-colors-${row.id}`" class="draw-mark-colors" data-control="picker" autofocus :label="row.labels.colors" :model-value="row.color" @update:model-value="recolor(row, $event)" @choose="closePicker(row.id)" /><input type="text" class="geo-import-name draw-mark-name" data-control="name" maxlength="120" autocomplete="off" spellcheck="false" v-field-value="row.name" :placeholder="row.placeholder" :aria-label="row.labels.name" @keydown="onNameKey(row, $event)" @focusout="commit(row, $event.currentTarget)"><button type="button" class="geo-import-action" data-control="toggle" :title="row.labels.toggle" :aria-label="row.labels.toggle" @click="display.act('toggleDrawMark', row.id)"><span class="material-symbols-outlined" aria-hidden="true">{{ row.hidden ? 'visibility_off' : 'visibility' }}</span></button><button v-for="action in row.actions" :key="action.id" type="button" class="geo-import-action draw-mark-action" :data-control="`action-${action.id}`" :data-action="action.id" :title="action.label" :aria-label="action.label" :aria-disabled="String(row.busy)" @click="display.act('runDrawMarkAction', row.id, action.id)"><span class="material-symbols-outlined" aria-hidden="true">{{ action.icon }}</span></button><button type="button" class="geo-import-action" data-control="fly" :title="row.labels.fly" :aria-label="row.labels.fly" @click="display.act('flyToDrawMark', row.id)"><span class="material-symbols-outlined" aria-hidden="true">my_location</span></button><UiCloseButton class="geo-import-action" glyph="icon" data-control="remove" :title="row.labels.remove" :label="row.labels.remove" @click="display.act('removeDrawMark', row.id)" /><span v-if="row.actions.length" class="draw-mark-note" role="status" :aria-busy="String(row.busy)">{{ row.busy ? '…' : row.note }}</span></li></ul>
|
||||
<ul class="geo-import-list draw-mark-list" :class="{ visible: listed }" id="draw-mark-list" v-focus-safe-children="leave" :aria-label="t('Drawn shapes')"><li v-for="row in rows" :key="row.id" class="geo-import-row draw-mark-row" :class="{ 'hidden-mark': row.hidden }" :data-mark-id="row.id" @keydown="onRowKey(row, $event)"><UiButton class="geo-import-swatch draw-mark-swatch" data-control="swatch" :style="{ background: DRAW_COLOR_CSS[row.color] }" :label="row.labels.swatch" :aria-expanded="String(picking === row.id)" :aria-controls="`draw-mark-colors-${row.id}`" @click="picking = picking === row.id ? null : row.id" /><DrawSwatches v-if="picking === row.id" :id="`draw-mark-colors-${row.id}`" class="draw-mark-colors" data-control="picker" autofocus :label="row.labels.colors" :model-value="row.color" @update:model-value="recolor(row, $event)" @choose="closePicker(row.id)" /><input type="text" class="geo-import-name draw-mark-name" data-control="name" maxlength="120" autocomplete="off" spellcheck="false" v-field-value="row.name" :placeholder="row.placeholder" :aria-label="row.labels.name" @keydown="onNameKey(row, $event)" @focusout="commit(row, $event.currentTarget)"><UiButton class="geo-import-action" data-control="toggle" :label="row.labels.toggle" @click="display.act('toggleDrawMark', row.id)"><UiIcon :name="row.hidden ? 'visibility_off' : 'visibility'" :size="null" /></UiButton><UiButton v-for="action in row.actions" :key="action.id" class="geo-import-action draw-mark-action" :data-control="`action-${action.id}`" :data-action="action.id" :label="action.label" :aria-disabled="String(row.busy)" @click="display.act('runDrawMarkAction', row.id, action.id)"><UiIcon :name="action.icon" :size="null" /></UiButton><UiButton class="geo-import-action" data-control="fly" :label="row.labels.fly" @click="display.act('flyToDrawMark', row.id)"><UiIcon name="my_location" :size="null" /></UiButton><UiCloseButton class="geo-import-action" glyph="icon" data-control="remove" :title="row.labels.remove" :label="row.labels.remove" @click="display.act('removeDrawMark', row.id)" /><span v-if="row.actions.length" class="draw-mark-note" role="status" :aria-busy="String(row.busy)">{{ row.busy ? '…' : row.note }}</span></li></ul>
|
||||
</template>
|
||||
@@ -6,11 +6,15 @@ import {
|
||||
DRAW_COLOR_CSS,
|
||||
DRAW_COLOR_NAMES,
|
||||
} from '../../../annotations/drawMarks.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
|
||||
// Draw's five colours as one radio group: the next shape's colour and a
|
||||
// drawn shape's picker. Only the checked colour is a tab stop; the arrows,
|
||||
// Home and End move to and choose another, as a radio group's do. Each swatch
|
||||
// shows its colour from DRAW_COLOR_CSS, the same value the shape is drawn in.
|
||||
// The swatches are ghost UiButtons with role="radio": they say they are
|
||||
// chosen with aria-checked and their own `active` class, never aria-pressed,
|
||||
// and `buttons` keeps their elements for the arrows.
|
||||
// The template is one line: templates keep whitespace.
|
||||
const props = defineProps({
|
||||
modelValue: { type: String, default: 'primary' },
|
||||
@@ -44,5 +48,5 @@ onMounted(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="draw-colors" role="radiogroup" :aria-label="props.label" @keydown="onKey"><button v-for="(color, index) in DRAW_COLORS" :key="color" :ref="(el) => (buttons[index] = el)" type="button" class="draw-color" :class="{ active: color === props.modelValue }" role="radio" :data-color="color" :data-control="`color-${color}`" :aria-checked="String(color === props.modelValue)" :tabindex="color === props.modelValue ? 0 : -1" :style="{ background: DRAW_COLOR_CSS[color] }" :title="t(DRAW_COLOR_NAMES[color])" :aria-label="t(DRAW_COLOR_NAMES[color])" @click="emit('update:modelValue', color), emit('choose', color)"></button></div>
|
||||
<div class="draw-colors" role="radiogroup" :aria-label="props.label" @keydown="onKey"><UiButton v-for="(color, index) in DRAW_COLORS" :key="color" :ref="(swatch) => (buttons[index] = swatch?.$el)" class="draw-color" :class="{ active: color === props.modelValue }" role="radio" :data-color="color" :data-control="`color-${color}`" :aria-checked="String(color === props.modelValue)" :tabindex="color === props.modelValue ? 0 : -1" :style="{ background: DRAW_COLOR_CSS[color] }" :label="t(DRAW_COLOR_NAMES[color])" @click="emit('update:modelValue', color), emit('choose', color)" /></div>
|
||||
</template>
|
||||
@@ -26,7 +26,7 @@ const props = defineProps({
|
||||
withContacts: Boolean,
|
||||
});
|
||||
const store = useEntityCardStore();
|
||||
const { card, lost, tick } = storeToRefs(store);
|
||||
const { card, lost, tick, away, finding, located } = storeToRefs(store);
|
||||
// Cameras carry only an id; the CCTV panel's store knows the picked one's name.
|
||||
const { frame: cctvFrame } = storeToRefs(useCctvStore());
|
||||
const shownTitle = computed(() => {
|
||||
@@ -56,6 +56,15 @@ const status = computed(() => {
|
||||
void tick.value;
|
||||
const current = card.value;
|
||||
if (!current) return null;
|
||||
if (finding.value === 'finding') return { tone: 'aged', text: t('Finding it…') };
|
||||
if (finding.value === 'none') return { tone: 'lost', text: t('No reading at this time') };
|
||||
if (lost.value && located.value)
|
||||
return {
|
||||
tone: 'aged',
|
||||
text: t('Last reading · {age}', {
|
||||
age: ago(Math.max(0, located.value.atMs - located.value.observedAtMs)),
|
||||
}),
|
||||
};
|
||||
if (lost.value) return { tone: 'lost', text: t('Out of feed · last reading') };
|
||||
if (current.observedAgeMs !== null)
|
||||
return {
|
||||
@@ -399,6 +408,7 @@ watch(
|
||||
<h3 class="entity-card__title">{{ shownTitle }}</h3>
|
||||
<span v-if="subtitle" class="entity-card__subtitle">{{ subtitle }}</span>
|
||||
</div>
|
||||
<UiButton v-if="away && card.moving" class="entity-card__find" data-entity-find :label="t('Find it')" :title="t('Find it')" :disabled="finding === 'finding'" @click="store.locate()"><UiIcon name="my_location" :size="null" /></UiButton>
|
||||
<UiCloseButton class="entity-card__close" glyph="icon" :label="t('Close card')" :title="t('Close card')" @click="store.clear()" />
|
||||
</header>
|
||||
|
||||
|
||||
@@ -4,13 +4,17 @@ import { computed, ref } from 'vue';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import { vFocusSafeChildren } from '../../rail/focusSafeChildren.js';
|
||||
import { useDisplayStore } from '../../stores/display.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiIcon from '../../kit/UiIcon.vue';
|
||||
|
||||
// DISPLAY ▸ Import: the button, the hidden picker, the imported files and
|
||||
// the hint. The file import publishes the rows and hint; until it does, the
|
||||
// list is empty. A pick and the row buttons call its actions. Before the
|
||||
// row holding keyboard focus goes, focus moves to the next row's same
|
||||
// button, else the previous row's, else the Import button. The list's
|
||||
// template is one line: templates keep whitespace.
|
||||
// button, else the previous row's, else the Import button. Each row's
|
||||
// actions (show or hide, fly to, remove) are icon buttons the file import
|
||||
// describes, Show/Hide a pressed toggle. The list's template is one line:
|
||||
// templates keep whitespace.
|
||||
const display = useDisplayStore();
|
||||
const { geoImport } = storeToRefs(display);
|
||||
const rows = computed(() => geoImport.value?.rows ?? []);
|
||||
@@ -52,18 +56,18 @@ function leave() {
|
||||
other.querySelector('button');
|
||||
if (target) return target.focus();
|
||||
}
|
||||
importButton.value?.focus();
|
||||
importButton.value?.$el.focus();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="pp-toggle-group" id="geo-import-group">
|
||||
<button ref="importButton" class="pp-toggle-btn" id="geo-import-button" type="button" @click="openPicker" :title="t('Show your own GeoJSON, KML, KMZ or GPX files on the globe (or drop them onto it). File bytes stay on this device; overlays can appear in map screenshots shared with voice.')">
|
||||
<span class="pp-icon material-symbols-outlined" aria-hidden="true">upload_file</span>
|
||||
<UiButton ref="importButton" class="pp-toggle-btn" id="geo-import-button" @click="openPicker" :title="t('Show your own GeoJSON, KML, KMZ or GPX files on the globe (or drop them onto it). File bytes stay on this device; overlays can appear in map screenshots shared with voice.')">
|
||||
<UiIcon class="pp-icon" name="upload_file" :size="null" />
|
||||
<span class="pp-label">{{ t('Import') }}</span>
|
||||
</button>
|
||||
</UiButton>
|
||||
<input ref="picker" type="file" id="geo-import-input" accept=".geojson,.json,.kml,.kmz,.gpx" multiple hidden @change="pick" :aria-label="t('Choose GeoJSON, KML, KMZ or GPX files')">
|
||||
<ul class="geo-import-list" :class="{ visible: listed }" id="geo-import-list" v-focus-safe-children="leave" :aria-label="t('Imported files')"><li v-for="row in rows" :key="row.id" class="geo-import-row" :data-import-id="row.id"><span :class="['geo-import-swatch', { 'own-styles': row.ownStyles }]" :style="row.ownStyles ? null : { background: row.color }"></span><span class="geo-import-name" :title="row.title">{{ row.name }}</span><button v-for="item in row.actions" :key="item.action" type="button" class="geo-import-action" :data-action="item.action" :title="item.label" :aria-label="item.label" :aria-pressed="item.pressed" @click="display.act(ROW_ACTIONS[item.action], row.id)"><span class="material-symbols-outlined" aria-hidden="true">{{ item.icon }}</span></button></li></ul>
|
||||
<ul class="geo-import-list" :class="{ visible: listed }" id="geo-import-list" v-focus-safe-children="leave" :aria-label="t('Imported files')"><li v-for="row in rows" :key="row.id" class="geo-import-row" :data-import-id="row.id"><span :class="['geo-import-swatch', { 'own-styles': row.ownStyles }]" :style="row.ownStyles ? null : { background: row.color }"></span><span class="geo-import-name" :title="row.title">{{ row.name }}</span><UiButton v-for="item in row.actions" :key="item.action" class="geo-import-action" :data-action="item.action" :label="item.label" :pressed="item.pressed" @click="display.act(ROW_ACTIONS[item.action], row.id)"><UiIcon :name="item.icon" :size="null" /></UiButton></li></ul>
|
||||
<span class="draw-hint geo-import-hint" id="geo-import-hint" aria-live="polite">{{ geoImport?.hint ?? '' }}</span>
|
||||
</div>
|
||||
</template>
|
||||
@@ -4,6 +4,8 @@ import { computed } from 'vue';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import { useGlobeActionsStore } from '../../stores/globeActions.js';
|
||||
import GlobeCompass from './GlobeCompass.vue';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiIcon from '../../kit/UiIcon.vue';
|
||||
|
||||
// The top-center camera and share actions. The shell answers the buttons
|
||||
// through the store and publishes a clear under way, which keeps the button
|
||||
@@ -18,18 +20,18 @@ const tilted = computed(() => Boolean(camera.value?.tilted));
|
||||
|
||||
<template>
|
||||
<nav id="top-center-actions" :aria-label="t('Globe actions')">
|
||||
<button id="clear-selected-layers" type="button" :aria-label="clearBusy ? t('Clearing selected data layers') : t('Clear selected data layers')" :aria-disabled="clearBusy == null ? undefined : String(clearBusy)" :aria-busy="clearBusy == null ? undefined : String(clearBusy)" :title="t('Turn off all selected data layers')" @click="act('clear')">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">layers_clear</span>
|
||||
</button>
|
||||
<button id="share-btn" type="button" :aria-label="t('Copy share link')" :title="t('Copy share link')" @click="act('share')">
|
||||
<UiButton id="clear-selected-layers" :aria-label="clearBusy ? t('Clearing selected data layers') : t('Clear selected data layers')" :aria-disabled="clearBusy == null ? undefined : String(clearBusy)" :aria-busy="clearBusy == null ? undefined : String(clearBusy)" :title="t('Turn off all selected data layers')" @click="act('clear')">
|
||||
<UiIcon name="layers_clear" :size="null" />
|
||||
</UiButton>
|
||||
<UiButton id="share-btn" :aria-label="t('Copy share link')" :title="t('Copy share link')" @click="act('share')">
|
||||
<span class="share-icon" aria-hidden="true">🔗</span>
|
||||
</button>
|
||||
<button id="tilt-map-view" type="button" :aria-label="tilted ? t('Return map to straight-down view') : t('Tilt map to oblique view')" :aria-pressed="String(tilted)" :title="t('Toggle straight-down and tilted map views')" @click="act('tilt')">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">view_in_ar</span>
|
||||
</button>
|
||||
</UiButton>
|
||||
<UiButton id="tilt-map-view" :aria-label="tilted ? t('Return map to straight-down view') : t('Tilt map to oblique view')" :pressed="tilted" :title="t('Toggle straight-down and tilted map views')" @click="act('tilt')">
|
||||
<UiIcon name="view_in_ar" :size="null" />
|
||||
</UiButton>
|
||||
<GlobeCompass @click="act('northUp')" />
|
||||
<button id="reset-globe-view" type="button" :aria-label="resetBusy ? t('Resetting to full globe view') : t('Reset to full globe view')" :title="t('Reset camera and return to full globe view')" @click="act('reset')">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">public</span>
|
||||
</button>
|
||||
<UiButton id="reset-globe-view" :aria-label="resetBusy ? t('Resetting to full globe view') : t('Reset to full globe view')" :title="t('Reset camera and return to full globe view')" @click="act('reset')">
|
||||
<UiIcon name="public" :size="null" />
|
||||
</UiButton>
|
||||
</nav>
|
||||
</template>
|
||||
@@ -3,6 +3,8 @@ import { storeToRefs } from 'pinia';
|
||||
import { computed } from 'vue';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import { useGlobeActionsStore } from '../../stores/globeActions.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiIcon from '../../kit/UiIcon.vue';
|
||||
|
||||
// The north-up button: its needle and label follow the published heading,
|
||||
// which changes on every frame a rotating camera draws. Before the camera
|
||||
@@ -20,8 +22,8 @@ const label = computed(() =>
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<button id="north-up-view" type="button" :aria-label="label" :data-north-up="heading == null ? undefined : String(heading === 0)" :style="heading == null ? undefined : { '--camera-heading': `${heading}deg` }" :title="t('Reset map bearing to north')" @click="$emit('click')">
|
||||
<UiButton id="north-up-view" :aria-label="label" :data-north-up="heading == null ? undefined : String(heading === 0)" :style="heading == null ? undefined : { '--camera-heading': `${heading}deg` }" :title="t('Reset map bearing to north')" @click="$emit('click')">
|
||||
<span class="camera-compass-n" aria-hidden="true">N</span>
|
||||
<span class="camera-compass-needle material-symbols-outlined" aria-hidden="true">navigation</span>
|
||||
</button>
|
||||
<UiIcon class="camera-compass-needle" name="navigation" :size="null" />
|
||||
</UiButton>
|
||||
</template>
|
||||
@@ -1,6 +1,7 @@
|
||||
<script setup>
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useImagerySplitStore } from '../../stores/imagerySplit.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
|
||||
// The before/after imagery dividers, as their splits (src/ui/imagerySplit.js)
|
||||
// present them. Each line is a direct child of the body, above the rails; its
|
||||
@@ -11,6 +12,6 @@ const optional = (value) => value ?? undefined;
|
||||
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<div v-for="split in splits" :key="split.key" :id="optional(split.view.id)" data-globe-overlay :hidden="split.view.hidden"><span class="before" :title="optional(split.view.beforeTitle)">{{ split.view.beforeLabel }}</span><button type="button" :class="optional(split.view.handleClass)" role="slider" :aria-label="optional(split.view.ariaLabel)" aria-valuemin="0" aria-valuemax="100" aria-orientation="horizontal" :aria-valuenow="split.view.valueNow" :aria-valuetext="split.view.valueText" @pointerdown="split.controls.pointerdown($event)" @pointermove="split.controls.pointermove($event)" @pointerup="split.controls.pointerup($event)" @pointercancel="split.controls.pointerup($event)" @keydown="split.controls.keydown($event)">↔</button><span class="after" :title="optional(split.view.afterTitle)">{{ split.view.afterLabel }}</span></div>
|
||||
<div v-for="split in splits" :key="split.key" :id="optional(split.view.id)" data-globe-overlay :hidden="split.view.hidden"><span class="before" :title="optional(split.view.beforeTitle)">{{ split.view.beforeLabel }}</span><UiButton :class="optional(split.view.handleClass)" role="slider" :aria-label="optional(split.view.ariaLabel)" aria-valuemin="0" aria-valuemax="100" aria-orientation="horizontal" :aria-valuenow="split.view.valueNow" :aria-valuetext="split.view.valueText" @pointerdown="split.controls.pointerdown($event)" @pointermove="split.controls.pointermove($event)" @pointerup="split.controls.pointerup($event)" @pointercancel="split.controls.pointerup($event)" @keydown="split.controls.keydown($event)">↔</UiButton><span class="after" :title="optional(split.view.afterTitle)">{{ split.view.afterLabel }}</span></div>
|
||||
</Teleport>
|
||||
</template>
|
||||
@@ -1,6 +1,7 @@
|
||||
<script setup>
|
||||
import { onBeforeUnmount, onMounted, ref } from 'vue';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
|
||||
// A slim index beside the Data Layers list: one tick per group (Movement,
|
||||
// Cameras, Infrastructure…). Hovering a tick names its group, clicking it
|
||||
@@ -102,10 +103,9 @@ onBeforeUnmount(() => {
|
||||
|
||||
<template>
|
||||
<nav v-if="sections.length > 1" class="layer-section-index" :aria-label="t('Layer groups')">
|
||||
<button
|
||||
<UiButton
|
||||
v-for="section in sections"
|
||||
:key="section.i"
|
||||
type="button"
|
||||
class="layer-section-index__tick"
|
||||
:class="{ 'is-current': section.i === current }"
|
||||
:aria-label="t('Jump to {name}', { name: section.label })"
|
||||
@@ -115,7 +115,7 @@ onBeforeUnmount(() => {
|
||||
@mouseleave="hideTip"
|
||||
@focus="showTip($event, section)"
|
||||
@blur="hideTip"
|
||||
></button>
|
||||
></UiButton>
|
||||
<Teleport to="body">
|
||||
<span v-if="tip" class="layer-section-index__label"
|
||||
:class="{ 'layer-section-index__label--before': tip.before }" :style="{ left: tip.left, top: tip.top }" aria-hidden="true">{{ tip.label }}</span>
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
<script setup>
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { computed, onBeforeUnmount, watch } from 'vue';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiIcon from '../../kit/UiIcon.vue';
|
||||
import RailPanel from '../../rail/RailPanel.vue';
|
||||
import { vClassToggle } from '../../rail/classToggle.js';
|
||||
import { useLiveScreen } from '../../liveScreen.js';
|
||||
import { usePanelChromeStore } from '../../stores/panelChrome.js';
|
||||
|
||||
// The LIVE section inside Context: the live streams attached to the selected
|
||||
// object (LiveControls publishes them), one at a time in the platform's own
|
||||
// player. It is there only while the selection has a stream. The player is
|
||||
// loaded only when the viewer presses Play, under the notice that YouTube
|
||||
// sees their IP address; collapsing the section, collapsing Context, or the
|
||||
// section leaving the page stops it. Its controls call LiveControls through
|
||||
// the store.
|
||||
const PANEL_ID = 'live-panel';
|
||||
const {
|
||||
view,
|
||||
act,
|
||||
idle,
|
||||
playing,
|
||||
loading,
|
||||
offline,
|
||||
unavailable,
|
||||
badgeText,
|
||||
statusText,
|
||||
} = useLiveScreen();
|
||||
// Nothing plays unseen: a hidden section gives up its player.
|
||||
const { panels } = storeToRefs(usePanelChromeStore());
|
||||
const hidden = computed(
|
||||
() =>
|
||||
(panels.value[PANEL_ID]?.collapsed ?? true) ||
|
||||
panels.value['global-context-panel']?.collapsed === true,
|
||||
);
|
||||
watch(hidden, (now) => {
|
||||
if (now) act('hideLive', 'section');
|
||||
});
|
||||
onBeforeUnmount(() => act('hideLive', 'section'));
|
||||
const liveWords = computed(() => ({
|
||||
expandLabel: t('Expand Live section'),
|
||||
collapseLabel: t('Collapse Live section'),
|
||||
expandTitle: t('Expand Live'),
|
||||
collapseTitle: t('Collapse Live'),
|
||||
}));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<RailPanel :id="PANEL_ID" tag="section" start-collapsed :hidden="!view" v-class-toggle="{ 'live-on-air': playing }" :aria-label="t('Live streams for the selected object')" :title="t('LIVE')" :toggle-words="liveWords" :glow="false" scroll>
|
||||
<template #badge><span class="live-badge"><span class="live-dot" :class="{ 'on-air': playing, waiting: loading }" aria-hidden="true"></span><span id="live-badge-text">{{ badgeText }}</span></span></template>
|
||||
<template v-if="view">
|
||||
<div class="live-subject">{{ view.label }}</div>
|
||||
<div class="live-pick" role="group" :aria-label="t('Stream')">
|
||||
<UiButton v-if="view.count > 1" id="live-previous-btn" type="button" class="live-step" @click="act('cycleLive', -1)" :aria-label="t('Previous stream')" :title="t('Previous stream')"><UiIcon name="chevron_left" :size="null" /></UiButton>
|
||||
<span id="live-stream-title" class="live-stream-title" aria-live="polite">{{ t(view.current.title) }}<small v-if="view.count > 1"> · {{ view.index + 1 }}/{{ view.count }}</small></span>
|
||||
<UiButton v-if="view.count > 1" id="live-next-btn" type="button" class="live-step" @click="act('cycleLive', 1)" :aria-label="t('Next stream')" :title="t('Next stream')"><UiIcon name="chevron_right" :size="null" /></UiButton>
|
||||
</div>
|
||||
<p class="live-privacy">{{ t('Video plays from YouTube, which sees your IP address.') }}</p>
|
||||
<!-- The player's element stays put across re-renders: LiveControls mounts the player in it. -->
|
||||
<div class="live-screen" :class="{ active: playing || loading }">
|
||||
<div id="live-player-host" class="live-player-host"></div>
|
||||
<UiButton v-if="idle" id="live-play-btn" class="live-play" @click="act('playLive')"><UiIcon name="play_arrow" :size="null" />{{ t('Play') }}</UiButton>
|
||||
<div v-if="offline || unavailable" class="live-card" :class="{ offline, unavailable }">
|
||||
<span class="live-card-dot" aria-hidden="true"></span>
|
||||
<strong>{{ offline ? t('Stream is offline') : t('This stream cannot play here') }}</strong>
|
||||
<UiButton v-if="offline" id="live-retry-btn" @click="act('retryLive')">{{ t('Try again') }}</UiButton>
|
||||
</div>
|
||||
</div>
|
||||
<p id="live-status" class="live-status" role="status" aria-live="polite">{{ statusText }}</p>
|
||||
<p class="live-credit"><a :href="view.current.ownerUrl" target="_blank" rel="noopener noreferrer">{{ view.current.owner }}</a> · <a id="live-watch-link" :href="view.current.watchUrl" target="_blank" rel="noopener noreferrer">{{ t('Open on YouTube') }}</a></p>
|
||||
</template>
|
||||
</RailPanel>
|
||||
</template>
|
||||
Loaded 100 of 391 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user