mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 17:52:21 +00:00
Merge main into fix/earthquake-click-details
Resolves conflicts with main: a world focus target's own range past its framed radius replaces the kind's range (#1832), so a quake asks for its own range only past M6 and the earthquake framing stays its floor; FIRMS keeps main's marker stand-in under the card-on-top rule; launches keep main's label click and also read the card on top through the pick registry.
This commit is contained in:
commit
e87aa5190d
1337 files changed
+38638
-9950
No files matched your search
+56
-25
@@ -30,7 +30,7 @@ import { LocationNavigation } from './locationNavigation.js';
|
||||
import { bindCameraOrientationControls } from './cameraOrientationControls.js';
|
||||
import { createMapSourceControls } from './mapSource.js';
|
||||
import { STYLES } from './effects.js';
|
||||
import { isHudLayout } from '../hudLayouts.js';
|
||||
import { isHudLayout, isLegacySonarHudLayout } from '../hudLayouts.js';
|
||||
import {
|
||||
getCyberSonarControlState,
|
||||
setCyberSonarControls,
|
||||
@@ -62,6 +62,8 @@ import { applyLocaleChoice } from './localePicker.js';
|
||||
import { PanelNavigation } from './panelNavigation.js';
|
||||
import { applicationPinia, createUiRuntime } from './vueRuntime.js';
|
||||
import { useContextStore } from './stores/context.js';
|
||||
import { useSpaceMissionsStore } from './stores/spaceMissions.js';
|
||||
import { SpaceMissionsControls } from './spaceMissionsControls.js';
|
||||
import { useMissionReplayStore } from './stores/missionReplay.js';
|
||||
import { useCelestialRingStore } from './stores/celestialRing.js';
|
||||
import { icrfToFixedAxes } from '../sky/icrf.js';
|
||||
@@ -78,6 +80,12 @@ import { useCockpitStore } from './stores/cockpit.js';
|
||||
import { useGlobeActionsStore } from './stores/globeActions.js';
|
||||
import { useRecordingStore } from './stores/recording.js';
|
||||
import { onPlacePacksLoadingChange } from '../data/placeBelow.js';
|
||||
import {
|
||||
hideOsmCredit,
|
||||
registerDynamicCredit,
|
||||
showOsmCredit,
|
||||
WIKIDATA_PLACES_CREDIT,
|
||||
} from '../data/dataCredits.js';
|
||||
import { withPlacePacks } from './placePacksLoading.js';
|
||||
import { preloadOwnerFlags } from './ownerFlag.js';
|
||||
|
||||
@@ -106,6 +114,9 @@ export class StyleManager extends ShellFacade {
|
||||
* @param {object} [options]
|
||||
* @param {boolean} [options.localePicker=true] - false removes the language
|
||||
* picker, for a host that offers its own language choice.
|
||||
* @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.
|
||||
*/
|
||||
constructor(
|
||||
viewer,
|
||||
@@ -116,6 +127,7 @@ export class StyleManager extends ShellFacade {
|
||||
requestServices,
|
||||
initialShareCode = null,
|
||||
localePicker = true,
|
||||
homeView = null,
|
||||
} = {},
|
||||
) {
|
||||
super();
|
||||
@@ -178,6 +190,14 @@ export class StyleManager extends ShellFacade {
|
||||
layers: () => this._dataManager?.getAll?.() || [],
|
||||
setLayer: (id, enabled) =>
|
||||
this._dataManager?.setEnabled(id, enabled, { origin: 'user' }),
|
||||
// The Omnibar shows names from the bundled Wikidata packs.
|
||||
creditPlaces: () =>
|
||||
registerDynamicCredit(this.viewer, WIKIDATA_PLACES_CREDIT),
|
||||
// Photon's suggestions are OpenStreetMap data: credited while shown.
|
||||
creditSuggestions: (shown) =>
|
||||
shown
|
||||
? showOsmCredit(this.viewer, 'omnibar')
|
||||
: hideOsmCredit(this.viewer, 'omnibar'),
|
||||
});
|
||||
// Scrolling at a screen edge steps through that side's rail panels.
|
||||
this._removeRailEdgeScroll = installRailEdgeScroll();
|
||||
@@ -307,6 +327,7 @@ export class StyleManager extends ShellFacade {
|
||||
readControls: () => ({
|
||||
hud: this.hud,
|
||||
_contextControls: this._contextControls,
|
||||
_spaceMissionsControls: this._spaceMissionsControls,
|
||||
_cctvControls: this._cctvControls,
|
||||
_radioControls: this._radioControls,
|
||||
_streetLevelControls: this._streetLevelControls,
|
||||
@@ -340,6 +361,7 @@ export class StyleManager extends ShellFacade {
|
||||
this._locationNavigation = new LocationNavigation({
|
||||
viewer,
|
||||
placeSearch,
|
||||
homeView,
|
||||
navigation: this._navigation,
|
||||
readCockpit: () => this.cockpitView,
|
||||
services: {
|
||||
@@ -669,6 +691,7 @@ export class StyleManager extends ShellFacade {
|
||||
this._initStreetLevelPanel();
|
||||
this._initWildlifeSightingCard();
|
||||
this._initGlobalContextPanel();
|
||||
this._initSpaceMissionsPanel();
|
||||
this._initLocationBar();
|
||||
this._initMobileShell();
|
||||
this._initShareButton();
|
||||
@@ -1005,17 +1028,12 @@ export class StyleManager extends ShellFacade {
|
||||
}
|
||||
|
||||
_initGlobalContextPanel() {
|
||||
const {
|
||||
radioLayer,
|
||||
militaryInstallationsLayer,
|
||||
militaryAwarenessLayer,
|
||||
rocketLaunchesLayer,
|
||||
} = this.services;
|
||||
const { radioLayer, militaryInstallationsLayer, militaryAwarenessLayer } =
|
||||
this.services;
|
||||
const contextStore = useContextStore(applicationPinia());
|
||||
this._contextControls = new ContextControls({
|
||||
elements: {
|
||||
_globalContextFlightsBtn: this._globalContextFlightsBtn,
|
||||
_globalContextMissionsBtn: this._globalContextMissionsBtn,
|
||||
_installationsSearchBtn: this._installationsSearchBtn,
|
||||
},
|
||||
installations: militaryInstallationsLayer,
|
||||
@@ -1051,13 +1069,24 @@ export class StyleManager extends ShellFacade {
|
||||
militaryAwarenessLayer?.subscribeDirectionOverlay?.((view) =>
|
||||
awarenessDirectionStore.publish(view),
|
||||
);
|
||||
}
|
||||
|
||||
_initSpaceMissionsPanel() {
|
||||
const { rocketLaunchesLayer } = this.services;
|
||||
// The Space Missions layer publishes its roster and selected mission.
|
||||
contextStore.connectMissions(rocketLaunchesLayer);
|
||||
this._missionsPanelUnsubscribe?.();
|
||||
contextStore.publishMissions(null);
|
||||
this._missionsPanelUnsubscribe = rocketLaunchesLayer?.subscribePanel?.(
|
||||
(view) => contextStore.publishMissions(view),
|
||||
);
|
||||
this._spaceMissionsControls?.destroy();
|
||||
this._spaceMissionsControls = new SpaceMissionsControls({
|
||||
layer: rocketLaunchesLayer,
|
||||
store: useSpaceMissionsStore(applicationPinia()),
|
||||
actions: {
|
||||
setPanelCollapsed: (...args) => this.setPanelCollapsed(...args),
|
||||
isCockpitActive: () => Boolean(this.cockpitView?.active),
|
||||
// After the panel has rendered as shown: the phone shell will not
|
||||
// open the Missions sheet over a hidden panel.
|
||||
revealPanel: () =>
|
||||
nextTick(() => this.revealPanel('space-missions-panel')),
|
||||
},
|
||||
});
|
||||
// And its replay vehicle overlay, which the scene chrome renders.
|
||||
const missionReplayStore = useMissionReplayStore(applicationPinia());
|
||||
this._missionReplayUnsubscribe?.();
|
||||
@@ -1370,17 +1399,18 @@ export class StyleManager extends ShellFacade {
|
||||
}
|
||||
|
||||
/**
|
||||
* Switches the HUD layout variant.
|
||||
* Switches the HUD layout variant. The removed Cyber layout is accepted
|
||||
* as an alias: it opens Tactical with the Sonar style on.
|
||||
* @param {'tactical'|'minimal'|'cyber'} variantName - Layout variant.
|
||||
* @returns {{ok: boolean, layout?: string, visible?: boolean, error?: string}}
|
||||
*/
|
||||
setHudLayout(variantName) {
|
||||
const variant = String(variantName ?? '').toLowerCase();
|
||||
if (!isHudLayout(variant)) {
|
||||
if (!isHudLayout(variant) && !isLegacySonarHudLayout(variant)) {
|
||||
return { ok: false, error: `Unknown HUD layout: ${variantName}` };
|
||||
}
|
||||
this.shareLinkManager?.claimRestoreLane?.('visual');
|
||||
this._setHudVariant(variant, { applyVisualDefaults: true });
|
||||
this._setHudVariant(variant);
|
||||
return {
|
||||
ok: true,
|
||||
layout: this.hud.getVariant(),
|
||||
@@ -1499,7 +1529,7 @@ export class StyleManager extends ShellFacade {
|
||||
};
|
||||
}
|
||||
|
||||
/** Apply Cyber-only sonar settings through the shared visual controls. */
|
||||
/** Apply sonar visual-style settings through the shared visual controls. */
|
||||
setCyberSonar(settings) {
|
||||
return setCyberSonarControls(this, settings);
|
||||
}
|
||||
@@ -1635,8 +1665,6 @@ export class StyleManager extends ShellFacade {
|
||||
* @param {string} styleName - Target style ('normal'|'retro'|'surveillance'|'thermal'|'anime'|'noir').
|
||||
* @param {object} [options]
|
||||
* @param {boolean} [options.applyPreset=true] - Whether to apply STYLE_PRESET_DEFAULTS for the new style.
|
||||
* @param {boolean} [options.userInitiated=false] - Whether a direct user preset choice owns the Cyber exit style.
|
||||
* @param {boolean} [options.preserveCyberRestore=false] - Whether an automatic style update keeps the Cyber entry snapshot.
|
||||
* @returns {void}
|
||||
*/
|
||||
setStyle(
|
||||
@@ -1716,7 +1744,12 @@ export class StyleManager extends ShellFacade {
|
||||
const store = useGlobeActionsStore(applicationPinia());
|
||||
if (this._resetToken) store.detach(this._resetToken);
|
||||
this._resetToken = controls
|
||||
? store.connect({ reset: () => controls.reset() })
|
||||
? store.connect({
|
||||
reset: () => controls.reset(),
|
||||
home: () => {
|
||||
if (!this._disposed) void this.returnToStart();
|
||||
},
|
||||
})
|
||||
: null;
|
||||
// A reset under way as the controls are replaced stays on the buttons.
|
||||
if (this._resetToken && this._globeResetting != null)
|
||||
@@ -1931,16 +1964,14 @@ export class StyleManager extends ShellFacade {
|
||||
this._awarenessDirectionUnsubscribe?.();
|
||||
this._awarenessDirectionUnsubscribe = null;
|
||||
useAwarenessDirectionStore(applicationPinia()).publish(null);
|
||||
this._missionsPanelUnsubscribe?.();
|
||||
this._missionsPanelUnsubscribe = null;
|
||||
this._spaceMissionsControls?.destroy();
|
||||
this._spaceMissionsControls = null;
|
||||
this._missionReplayUnsubscribe?.();
|
||||
this._missionReplayUnsubscribe = null;
|
||||
useMissionReplayStore(applicationPinia()).publish(null);
|
||||
const contextStore = useContextStore(applicationPinia());
|
||||
contextStore.connectAwareness(null);
|
||||
contextStore.publishAwareness(null);
|
||||
contextStore.connectMissions(null);
|
||||
contextStore.publishMissions(null);
|
||||
this._cockpitCoordinator.stop();
|
||||
this._visualSettings.stop();
|
||||
this.shareLinkManager?.destroy();
|
||||
|
||||
@@ -7,6 +7,7 @@ import assert from 'node:assert/strict';
|
||||
import { createPinia } from 'pinia';
|
||||
import { createApp, defineComponent, h, nextTick } from 'vue';
|
||||
import { CockpitViewController } from './cockpitController.js';
|
||||
import { setLocale } from '../i18n/index.js';
|
||||
import { useCockpitStore } from './stores/cockpit.js';
|
||||
import CockpitView from './views/CockpitView.vue';
|
||||
import ContextView from './views/ContextView.vue';
|
||||
@@ -413,6 +414,33 @@ test('the bridge radar shows nearby ships without its own and steps its range',
|
||||
assert.ok(!$('#cockpit-radar') || $('#cockpit-radar').hidden);
|
||||
});
|
||||
|
||||
test('the radar range and ring spacing agree with their distance (ru)', async (t) => {
|
||||
const { $, cockpit } = fixture(t);
|
||||
t.after(() => setLocale('en'));
|
||||
setLocale('ru');
|
||||
cockpit.enter();
|
||||
await settle();
|
||||
const shown = () => [
|
||||
$('#cockpit-radar-range').textContent.trim(),
|
||||
$('.cockpit-radar-rings').textContent.trim(),
|
||||
];
|
||||
// The ring spacing is a fraction at the short ranges: Intl.PluralRules
|
||||
// gives 0.75 and 1.5 the form of their own.
|
||||
const expected = [
|
||||
['3 МОР. МИЛИ', 'КОЛЬЦА 0,75 МОР. МИЛИ'],
|
||||
['6 МОР. МИЛЬ', 'КОЛЬЦА 1,5 МОР. МИЛИ'],
|
||||
['12 МОР. МИЛЬ', 'КОЛЬЦА 3 МОР. МИЛИ'],
|
||||
['24 МОР. МИЛИ', 'КОЛЬЦА 6 МОР. МИЛЬ'],
|
||||
];
|
||||
for (const [index, labels] of expected.entries()) {
|
||||
if (index) {
|
||||
$('#cockpit-radar-range').click();
|
||||
await settle();
|
||||
}
|
||||
assert.deepEqual(shown(), labels);
|
||||
}
|
||||
});
|
||||
|
||||
test('contact navigation does not jump ship from the bridge', async (t) => {
|
||||
const { cockpit, navigations } = fixture(t);
|
||||
cockpit.enter();
|
||||
@@ -1276,6 +1304,18 @@ test('a ship with no true heading is held, and labelled, on its course', async (
|
||||
signals.some(([, , , detail]) => /COURSE 095°/.test(detail)),
|
||||
JSON.stringify(signals),
|
||||
);
|
||||
// A ship's course has a word of its own: pt RUMO, an aircraft's CURSO.
|
||||
t.after(() => setLocale('en'));
|
||||
setLocale('pt');
|
||||
signals.length = 0;
|
||||
cockpit.exit();
|
||||
await settle();
|
||||
cockpit.enter();
|
||||
await settle();
|
||||
assert.ok(
|
||||
signals.some(([, , , detail]) => /· RUMO 095°$/.test(detail)),
|
||||
JSON.stringify(signals),
|
||||
);
|
||||
});
|
||||
|
||||
test('both entries name the subject the same way', async () => {
|
||||
|
||||
+31
-9
@@ -336,7 +336,7 @@ function updateVessel(nowMs) {
|
||||
* gives none) and slew toward its heading. A frame that is null, malformed or
|
||||
* for another subject ends the view, as an aircraft tracked meanwhile does.
|
||||
* The update runs on the provider's `cameraIntervalMs` (0: every frame), and
|
||||
* its rates advance by the time that interval spans (cockpitSubjectStepSec).
|
||||
* its rates advance by the time since the last update (cockpitSubjectStepSec).
|
||||
*/
|
||||
function updateSubject(nowMs) {
|
||||
const provider = this.subjectProvider;
|
||||
@@ -357,6 +357,7 @@ function updateSubject(nowMs) {
|
||||
}
|
||||
this.lastSubjectFrame = frame;
|
||||
let heightM = frame.heightM;
|
||||
let held = false;
|
||||
if (heightM === null) {
|
||||
this.services.warmGroundFloor?.([
|
||||
{ lat: frame.latitude, lon: frame.longitude },
|
||||
@@ -366,8 +367,10 @@ function updateSubject(nowMs) {
|
||||
frame.longitude,
|
||||
);
|
||||
// A frame with no height stands on the shared floor; while that is cold
|
||||
// it keeps the height it last stood at.
|
||||
heightM = Number.isFinite(floorM) ? floorM : this.subjectHeightM;
|
||||
// the eye keeps the last height it stood at (a frame's or the floor's),
|
||||
// at first the entry frame's.
|
||||
held = !Number.isFinite(floorM);
|
||||
heightM = held ? this.subjectHeightM : floorM;
|
||||
}
|
||||
if (!Number.isFinite(heightM)) {
|
||||
// Nothing to stand on yet, from the first frame: the camera stays where
|
||||
@@ -399,6 +402,21 @@ function updateSubject(nowMs) {
|
||||
}
|
||||
this.surfaceWaitStartedMs = 0;
|
||||
this.surfaceAcquiring = false;
|
||||
if (!held) {
|
||||
// The first height to replace the entry frame's is the anchor's at once
|
||||
// (an inertial anchor would close on it only at the horizontal
|
||||
// correction's rate); where the anchor stands, it stays.
|
||||
if (
|
||||
this.subjectHeightFromEntry &&
|
||||
this.cockpitAnchorValid &&
|
||||
heightM !== this.subjectHeightM
|
||||
) {
|
||||
const anchor = toCartographicRadians(this.cockpitAnchor);
|
||||
if (anchor)
|
||||
this.cockpitAnchor = fromRadians(anchor.lon, anchor.lat, heightM);
|
||||
}
|
||||
this.subjectHeightFromEntry = false;
|
||||
}
|
||||
this.subjectHeightM = heightM;
|
||||
const target = fromDegrees(frame.longitude, frame.latitude, heightM);
|
||||
const dtSec = cockpitSubjectStepSec(nowMs - this.lastFrameMs, intervalMs);
|
||||
@@ -411,7 +429,9 @@ function updateSubject(nowMs) {
|
||||
: slewHeading(
|
||||
this.heading ?? frame.headingDeg,
|
||||
frame.headingDeg,
|
||||
rate * dtSec,
|
||||
// At most half a turn, which reaches any heading: a huge rate times
|
||||
// the step must not overflow to Infinity and stop the turn.
|
||||
Math.min(rate * dtSec, 180),
|
||||
);
|
||||
}
|
||||
let look = null;
|
||||
@@ -459,8 +479,10 @@ function updateSubject(nowMs) {
|
||||
* Aircraft pass none and look along the heading at the profile pitch.
|
||||
*/
|
||||
function placeCamera(target, info, nowMs, dtSec, profile, look = null) {
|
||||
if (!this.cockpitAnchorValid) {
|
||||
this.cockpitAnchor = clone(target);
|
||||
// The update that first sets the anchor stands it on the target: the time
|
||||
// before it (an entry, a floor wait) moved nothing, so it has no step.
|
||||
const anchoring = !this.cockpitAnchorValid;
|
||||
if (anchoring) {
|
||||
this.cockpitAnchorValid = true;
|
||||
this.subjectLiftM = null;
|
||||
}
|
||||
@@ -485,7 +507,7 @@ function placeCamera(target, info, nowMs, dtSec, profile, look = null) {
|
||||
: 0;
|
||||
|
||||
const groundClamp = info.groundClamp !== false;
|
||||
if (info.stale || info.anchor === 'exact') {
|
||||
if (anchoring || info.stale || info.anchor === 'exact') {
|
||||
// A feed backoff has no authoritative velocity epoch to advance from.
|
||||
// Hold the cockpit on the exact layer-rendered position so the camera
|
||||
// cannot coast away while the icon correctly remains fixed.
|
||||
@@ -503,8 +525,8 @@ function placeCamera(target, info, nowMs, dtSec, profile, look = null) {
|
||||
);
|
||||
const correction = sub(target, this.cockpitAnchor);
|
||||
const correctionDistanceM = magnitude(correction);
|
||||
// An application subject's step is already bounded by its own update
|
||||
// interval (cockpitSubjectStepSec); the built-in views keep the 0.1 s.
|
||||
// An application subject's step is already bounded (cockpitSubjectStepSec);
|
||||
// the built-in views keep the 0.1 s.
|
||||
const correctionStepM = cockpitAnchorCorrectionStep(
|
||||
correctionDistanceM,
|
||||
speedMps,
|
||||
|
||||
@@ -194,8 +194,10 @@ export class CockpitViewController {
|
||||
this.surfaceWaitStartedMs = 0;
|
||||
this.surfaceAcquiring = false;
|
||||
this.surfaceFallback = false;
|
||||
/** The height an application subject's frame last stood at (m). */
|
||||
/** The height an application subject's eye last stood at (m). */
|
||||
this.subjectHeightM = null;
|
||||
/** Whether `subjectHeightM` is still the one its entry frame gave. */
|
||||
this.subjectHeightFromEntry = false;
|
||||
/** The ground clamp's eased lift under that subject's eye (m). */
|
||||
this.subjectLiftM = null;
|
||||
/**
|
||||
@@ -735,8 +737,16 @@ export class CockpitViewController {
|
||||
publishCockpitSignals() {
|
||||
return publishCockpitSignals.call(this);
|
||||
}
|
||||
pushCockpitSignal(key, tone, title, detail, target) {
|
||||
return pushCockpitSignal.call(this, key, tone, title, detail, target);
|
||||
pushCockpitSignal(key, tone, title, detail, target, options) {
|
||||
return pushCockpitSignal.call(
|
||||
this,
|
||||
key,
|
||||
tone,
|
||||
title,
|
||||
detail,
|
||||
target,
|
||||
options,
|
||||
);
|
||||
}
|
||||
dropCockpitSignal(key) {
|
||||
return dropCockpitSignal.call(this, key);
|
||||
|
||||
@@ -444,10 +444,10 @@ test('Cockpit places the eye at its aircraft as the Cesium maths did', async ()
|
||||
latitude: 30.19,
|
||||
longitude: -97.67,
|
||||
onGround: false,
|
||||
stale: true,
|
||||
stale: false,
|
||||
};
|
||||
const { owner, views } = cockpitOver({ info, target });
|
||||
// Held on the target while the feed is stale.
|
||||
// The first update stands the anchor on the target.
|
||||
owner.update();
|
||||
let expected = cesiumCockpitEye(Cesium, {
|
||||
target,
|
||||
@@ -456,13 +456,12 @@ test('Cockpit places the eye at its aircraft as the Cesium maths did', async ()
|
||||
dtSec: 0,
|
||||
liftM: 0,
|
||||
});
|
||||
near(views[0].destination, expected.eye, 1e-6, 'stale eye');
|
||||
near(views[0].destination, expected.eye, 1e-6, 'first eye');
|
||||
near(views[0].orientation.direction, expected.forward, 1e-12, 'direction');
|
||||
near(views[0].orientation.up, expected.up, 1e-12, 'up');
|
||||
|
||||
// Live: the anchor coasts 80 ms along the heading and is pulled toward
|
||||
// where the layer now shows the aircraft.
|
||||
info.stale = false;
|
||||
const anchor = Cesium.Cartesian3.clone(expected.anchor);
|
||||
const moved = Cesium.Cartesian3.fromDegrees(-97.6698, 30.1901, 1210);
|
||||
owner.trackedFollow.position = () => moved;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { displayPanelScroller } from './displayPanelScroll.js';
|
||||
|
||||
/**
|
||||
* Show the existing Display groups in Cockpit's Display popover while Cockpit
|
||||
* is on. The portal publishes the popover's slots; the Display panel
|
||||
@@ -37,16 +35,13 @@ export class CockpitDisplayPortal {
|
||||
this.slots = Object.freeze(
|
||||
Object.fromEntries(this.records.map(({ name, slot }) => [name, slot])),
|
||||
);
|
||||
this.standardScrollTop =
|
||||
displayPanelScroller(standardPanel)?.scrollTop || 0;
|
||||
this.standardScrollTop = standardPanel?.scrollTop || 0;
|
||||
this.cockpitScrollTop = cockpitPanel?.scrollTop || 0;
|
||||
const options = { passive: true, signal: this.listeners.signal };
|
||||
standardPanel?.addEventListener(
|
||||
'scroll',
|
||||
() => {
|
||||
if (!this.active)
|
||||
this.standardScrollTop =
|
||||
displayPanelScroller(standardPanel).scrollTop;
|
||||
if (!this.active) this.standardScrollTop = standardPanel.scrollTop;
|
||||
},
|
||||
{ ...options, capture: true },
|
||||
);
|
||||
@@ -98,8 +93,7 @@ export class CockpitDisplayPortal {
|
||||
if (nextActive && this.cockpitPanel)
|
||||
this.cockpitPanel.scrollTop = this.cockpitScrollTop;
|
||||
if (!nextActive && this.standardPanel)
|
||||
displayPanelScroller(this.standardPanel).scrollTop =
|
||||
this.standardScrollTop;
|
||||
this.standardPanel.scrollTop = this.standardScrollTop;
|
||||
};
|
||||
if (!settle) {
|
||||
this.afterRender(() => {
|
||||
@@ -146,8 +140,7 @@ export class CockpitDisplayPortal {
|
||||
this.publish(null);
|
||||
const { standardPanel, standardScrollTop } = this;
|
||||
this.afterRender(() => {
|
||||
if (standardPanel)
|
||||
displayPanelScroller(standardPanel).scrollTop = standardScrollTop;
|
||||
if (standardPanel) standardPanel.scrollTop = standardScrollTop;
|
||||
});
|
||||
this.records = [];
|
||||
this.restoreOwner = null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/** Instrument values, routes and vision controls for the Cockpit controller. */
|
||||
import { formatNumber, t } from '../i18n/index.js';
|
||||
import { formatNumber, t, tn } from '../i18n/index.js';
|
||||
import {
|
||||
COCKPIT_VISION_MODES,
|
||||
normalizeCockpitVisionMode,
|
||||
@@ -256,20 +256,21 @@ function updateSubjectHud(info, nowMs, forceContext) {
|
||||
this.updateLocalPosition(info);
|
||||
this.maybeRefreshRegionalBrief(info);
|
||||
this.showContextCard(false);
|
||||
const keys = new Set();
|
||||
for (const signal of hud.signals) {
|
||||
const key = `subject:${signal.id}`;
|
||||
keys.add(key);
|
||||
this.pushCockpitSignal(
|
||||
key,
|
||||
SUBJECT_SIGNAL_TONES[signal.tone] ?? 'info',
|
||||
signal.title,
|
||||
signal.detail || signal.title,
|
||||
);
|
||||
}
|
||||
const keys = new Set(hud.signals.map(({ id }) => `subject:${id}`));
|
||||
// Rows the view no longer lists leave first, so new ones take their
|
||||
// places rather than push a listed one (or TRACK ACQUIRED) off.
|
||||
for (const key of this.subjectSignalKeys ?? [])
|
||||
if (!keys.has(key)) this.dropCockpitSignal(key);
|
||||
this.subjectSignalKeys = keys;
|
||||
for (const signal of hud.signals)
|
||||
this.pushCockpitSignal(
|
||||
`subject:${signal.id}`,
|
||||
SUBJECT_SIGNAL_TONES[signal.tone] ?? 'info',
|
||||
signal.title,
|
||||
signal.detail || signal.title,
|
||||
null,
|
||||
{ inPlace: true },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -525,7 +526,10 @@ export function updateRadar(info) {
|
||||
);
|
||||
this.publishRadar({
|
||||
...picture,
|
||||
rangeLabel: t('{range} NM', { range: formatNumber(rangeNm) }),
|
||||
// A plural, as the ring spacing is: ru «3 МОР. МИЛИ», «12 МОР. МИЛЬ».
|
||||
rangeLabel: tn(rangeNm, '{range} NM', '{range} NM', {
|
||||
range: formatNumber(rangeNm),
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+3
-135
@@ -2,7 +2,6 @@
|
||||
import {
|
||||
resolveCockpitUtilityAnchor,
|
||||
resolveCockpitUtilityLayout,
|
||||
resolveCyberCockpitPanelLane,
|
||||
} from '../cockpitUtilityLayout.js';
|
||||
import {
|
||||
COCKPIT_UTILITY_REC_GAP_PX,
|
||||
@@ -67,8 +66,6 @@ export function syncContextLayout() {
|
||||
if (window.matchMedia('(max-width: 760px)').matches) {
|
||||
this.context.dataset.layoutMode = 'compact-bottom';
|
||||
this.context.style.removeProperty('--cockpit-context-left');
|
||||
this.context.style.removeProperty('--cockpit-context-top');
|
||||
this.context.style.removeProperty('--cockpit-context-max-height');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -78,56 +75,6 @@ export function syncContextLayout() {
|
||||
'--cockpit-context-left',
|
||||
`${desktopInset.toFixed(1)}px`,
|
||||
);
|
||||
if (document.documentElement.dataset.uiTheme !== 'cyber') {
|
||||
this.context.style.removeProperty('--cockpit-context-top');
|
||||
this.context.style.removeProperty('--cockpit-context-max-height');
|
||||
return;
|
||||
}
|
||||
const defaultTop = Math.max(255, Math.min(300, window.innerHeight * 0.28));
|
||||
// An open left panel Cockpit keeps (Data Layers or Utilities).
|
||||
const dataPanel = document.querySelector(
|
||||
'#left-panel-stack > :is(#data-panel, #utilities-panel):not(.collapsed)',
|
||||
);
|
||||
let desiredTop = defaultTop;
|
||||
if (this.contextCollapsed && dataPanel) {
|
||||
desiredTop = Math.max(
|
||||
desiredTop,
|
||||
dataPanel.getBoundingClientRect().bottom + 8,
|
||||
);
|
||||
}
|
||||
const contextBounds = this.context.getBoundingClientRect();
|
||||
let safeBottom = window.innerHeight - 24;
|
||||
for (const selector of [
|
||||
'#cesium-credits',
|
||||
'#gev-credits',
|
||||
'#command-dock',
|
||||
'#view-switcher',
|
||||
]) {
|
||||
const obstacle = document.querySelector(selector);
|
||||
if (!obstacle) continue;
|
||||
const style = window.getComputedStyle(obstacle);
|
||||
if (
|
||||
style.display === 'none' ||
|
||||
style.visibility === 'hidden' ||
|
||||
Number(style.opacity) === 0
|
||||
)
|
||||
continue;
|
||||
const bounds = obstacle.getBoundingClientRect();
|
||||
const overlapsHorizontally =
|
||||
bounds.right > contextBounds.left && bounds.left < contextBounds.right;
|
||||
if (overlapsHorizontally && bounds.top > desiredTop) {
|
||||
safeBottom = Math.min(safeBottom, bounds.top - 8);
|
||||
}
|
||||
}
|
||||
const boundedTop = Math.max(
|
||||
defaultTop,
|
||||
Math.min(desiredTop, safeBottom - contextBounds.height),
|
||||
);
|
||||
this.context.style.setProperty(
|
||||
'--cockpit-context-top',
|
||||
`${boundedTop.toFixed(1)}px`,
|
||||
);
|
||||
this.context.style.removeProperty('--cockpit-context-max-height');
|
||||
}
|
||||
|
||||
export function syncSignalLayout() {
|
||||
@@ -138,8 +85,6 @@ export function syncSignalLayout() {
|
||||
// The compact strip shows only an expanded control.
|
||||
this.publishUtilityLayout(utilityLayoutView({ hideCollapsed: true }));
|
||||
this.signalStream.style.removeProperty('--cockpit-signal-right');
|
||||
this.signalStream.style.removeProperty('--cockpit-signal-top');
|
||||
this.signalStream.style.removeProperty('--cockpit-signal-max-height');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -149,36 +94,6 @@ export function syncSignalLayout() {
|
||||
'--cockpit-signal-right',
|
||||
`${desktopInset.toFixed(1)}px`,
|
||||
);
|
||||
this.signalStream.style.removeProperty('--cockpit-signal-top');
|
||||
this.signalStream.style.removeProperty('--cockpit-signal-max-height');
|
||||
const cyber = document.documentElement.dataset.uiTheme === 'cyber';
|
||||
const leftPanel = cyber
|
||||
? document.querySelector('#left-panel-stack > #data-panel')
|
||||
: null;
|
||||
const alignedTop = isRenderedOnScreen(leftPanel)
|
||||
? leftPanel.getBoundingClientRect().top
|
||||
: null;
|
||||
// Cyber's two rails share a top edge. Move the briefing below the collapsed
|
||||
// strip rather than pulling the right rail upward to avoid it.
|
||||
if (alignedTop !== null && utilityControls) {
|
||||
const expanded = utilityControls.querySelector(
|
||||
'.cockpit-utility-control.is-expanded',
|
||||
);
|
||||
if (!expanded) {
|
||||
const signalTop = Math.max(
|
||||
Math.max(255, Math.min(300, window.innerHeight * 0.28)),
|
||||
alignedTop + utilityControls.getBoundingClientRect().height + 28,
|
||||
);
|
||||
this.signalStream.style.setProperty(
|
||||
'--cockpit-signal-top',
|
||||
`${signalTop.toFixed(1)}px`,
|
||||
);
|
||||
this.signalStream.style.setProperty(
|
||||
'--cockpit-signal-max-height',
|
||||
`${Math.max(44, window.innerHeight - signalTop - 80).toFixed(1)}px`,
|
||||
);
|
||||
}
|
||||
}
|
||||
const signalBounds = this.signalStream.getBoundingClientRect();
|
||||
const utilityBounds = utilityControls?.getBoundingClientRect();
|
||||
if (utilityBounds) {
|
||||
@@ -203,42 +118,7 @@ export function syncSignalLayout() {
|
||||
collapsedLauncher.scrollHeight,
|
||||
)
|
||||
: 0;
|
||||
if (alignedTop !== null) {
|
||||
const lane = resolveCyberCockpitPanelLane({
|
||||
viewportHeight: window.innerHeight,
|
||||
top: alignedTop,
|
||||
launcherHeight: Math.max(
|
||||
collapsedHeight,
|
||||
collapsedLauncher?.getBoundingClientRect().height || 60,
|
||||
),
|
||||
signalHeight: this.signalCollapsed ? signalBounds.height : 44,
|
||||
contactHeight:
|
||||
this.contextCollapsed && this.context
|
||||
? this.context.getBoundingClientRect().height
|
||||
: 64,
|
||||
});
|
||||
document.body.style.setProperty(
|
||||
'--cyber-cockpit-panel-height',
|
||||
`${lane.panelHeight.toFixed(2)}px`,
|
||||
);
|
||||
this.publishUtilityLayout(
|
||||
utilityLayoutView({
|
||||
top: `${alignedTop.toFixed(2)}px`,
|
||||
maxHeight: `${lane.utilityHeight.toFixed(2)}px`,
|
||||
expandedMaxHeight: `${lane.panelHeight.toFixed(2)}px`,
|
||||
}),
|
||||
);
|
||||
if (expandedControl) {
|
||||
this.signalStream.style.setProperty(
|
||||
'--cockpit-signal-top',
|
||||
`${lane.signalTop.toFixed(2)}px`,
|
||||
);
|
||||
}
|
||||
this.syncContextLayout();
|
||||
return;
|
||||
}
|
||||
// Non-Cyber themes retain their independent REC/briefing corridor. Cyber
|
||||
// uses the rendered Data Layers top after reserving briefing space above.
|
||||
// The REC readout and the briefing card bound the utility corridor.
|
||||
// The readout only anchors the strip while it is genuinely on screen:
|
||||
// the Minimal variant drops it with `display:none`, but HUD Off hides the
|
||||
// whole Intel HUD with `visibility`/`opacity`, which keeps its rect.
|
||||
@@ -254,20 +134,8 @@ export function syncSignalLayout() {
|
||||
collapsedHeight,
|
||||
recGap: COCKPIT_UTILITY_REC_GAP_PX,
|
||||
signalGap: COCKPIT_UTILITY_SIGNAL_GAP_PX,
|
||||
minTopFloor: alignedTop ?? COCKPIT_UTILITY_MIN_TOP_PX,
|
||||
minTopRatio: alignedTop !== null ? 0 : COCKPIT_UTILITY_MIN_TOP_RATIO,
|
||||
signalCollapsed: this.signalCollapsed,
|
||||
utilityExpanded: Boolean(expandedControl),
|
||||
// Only Cyber relocates its collapsed briefing below the utility lane.
|
||||
// Other themes keep the measured visible card as the lower boundary.
|
||||
reserveViewportLane: document.documentElement.dataset.uiTheme === 'cyber',
|
||||
// Cyber keeps the collapsed briefing reachable below the utility instead
|
||||
// of hiding it. Reserve its actual height, including wrapped headings.
|
||||
signalHeight:
|
||||
document.documentElement.dataset.uiTheme === 'cyber' &&
|
||||
this.signalCollapsed
|
||||
? signalBounds.height
|
||||
: 0,
|
||||
minTopFloor: COCKPIT_UTILITY_MIN_TOP_PX,
|
||||
minTopRatio: COCKPIT_UTILITY_MIN_TOP_RATIO,
|
||||
});
|
||||
const availableHeight = utilityAnchor.maxHeight;
|
||||
const utilityLayout =
|
||||
|
||||
@@ -24,6 +24,7 @@ import {
|
||||
fakeInput,
|
||||
} from '../input/testDoubles.mjs';
|
||||
import { CockpitViewController } from './cockpitController.js';
|
||||
import { setLocale, t as translate } from '../i18n/index.js';
|
||||
import { useCockpitStore } from './stores/cockpit.js';
|
||||
import { useHudStore } from './stores/hud.js';
|
||||
import CockpitView from './views/CockpitView.vue';
|
||||
@@ -573,6 +574,18 @@ test('a site row turns the camera onto it, holds it, and reads its off-nadir ang
|
||||
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');
|
||||
// The held site's FOCUS is a status, worded apart from the FOCUS command.
|
||||
t.after(() => setLocale('en'));
|
||||
setLocale('es');
|
||||
await refreshRows(scene);
|
||||
const heldEs = rows(scene).find((row) => row.target?.id === SITES.alpha.id);
|
||||
assert.match(heldEs.detail, /^ENFOQUE · /);
|
||||
assert.match(
|
||||
$('#cockpit-orbital-focus').textContent,
|
||||
/^ENFOQUE · /,
|
||||
'the card names the held site with the same word',
|
||||
);
|
||||
assert.equal(translate('FOCUS'), 'ENFOCAR', 'the command keeps its verb');
|
||||
});
|
||||
|
||||
test('another site row switches the focus; the held site row ends it', async (t) => {
|
||||
|
||||
@@ -132,7 +132,8 @@ function siteRows(info, { settled = true } = {}) {
|
||||
}),
|
||||
});
|
||||
const words = [installationClassLabel(site.class), angle];
|
||||
if (focused) words.unshift(t('FOCUS'));
|
||||
// A status, as on the focus card, not the command: es «ENFOQUE», not «ENFOCAR».
|
||||
if (focused) words.unshift(t('FOCUS', { context: 'site status' }));
|
||||
return {
|
||||
key: `site:${site.id}`,
|
||||
// The held site reads as the subject does.
|
||||
|
||||
@@ -7,6 +7,7 @@ import assert from 'node:assert/strict';
|
||||
import { createPinia } from 'pinia';
|
||||
import { createApp, defineComponent, h, nextTick } from 'vue';
|
||||
import { CockpitViewController } from './cockpitController.js';
|
||||
import { setLocale } from '../i18n/index.js';
|
||||
import { useCockpitStore } from './stores/cockpit.js';
|
||||
import CockpitView from './views/CockpitView.vue';
|
||||
import ContextView from './views/ContextView.vue';
|
||||
@@ -260,3 +261,16 @@ test('entering asks for a panel layout before Vue shows the cards', async (t) =>
|
||||
await new Promise((resolve) => setTimeout(resolve, 50));
|
||||
assert.deepEqual(laid, ['context', 'signals']);
|
||||
});
|
||||
|
||||
test('an aircraft is acquired on its CURSO in Portuguese; a ship keeps RUMO', async (t) => {
|
||||
const { cockpit } = fixture(t);
|
||||
t.after(() => setLocale('en'));
|
||||
setLocale('pt');
|
||||
const signals = [];
|
||||
cockpit.pushCockpitSignal = (...args) => signals.push(args);
|
||||
cockpit.enter();
|
||||
await nextTick();
|
||||
const acquired = signals.find(([key]) => key === 'track');
|
||||
assert.ok(acquired, JSON.stringify(signals));
|
||||
assert.equal(acquired[3], 'UAL123 · CURSO 092°');
|
||||
});
|
||||
@@ -39,17 +39,42 @@ export function publishCockpitSignals() {
|
||||
this.scheduleContextLayout();
|
||||
}
|
||||
|
||||
export function pushCockpitSignal(key, tone, title, detail, target = null) {
|
||||
/**
|
||||
* Log a signal as the newest row, unless its key last said the same.
|
||||
* @param {{inPlace?: boolean}} [options] `inPlace`: a status row, such as a
|
||||
* provider's, that changes where it stands rather than log a new row, so a
|
||||
* changing ETA never pushes a steady warning off the list; it keeps its
|
||||
* time while it stays listed, and one pushed off comes back as the newest
|
||||
* row.
|
||||
*/
|
||||
export function pushCockpitSignal(
|
||||
key,
|
||||
tone,
|
||||
title,
|
||||
detail,
|
||||
target = null,
|
||||
{ inPlace = false } = {},
|
||||
) {
|
||||
if (!title || !detail) return;
|
||||
const signature = `${title}|${detail}|${target?.layerId || ''}|${target?.id || ''}`;
|
||||
if (this.signalSignatures.get(key) === signature) return;
|
||||
this.signalSignatures.set(key, signature);
|
||||
// JSON, not a joined string, so a separator inside a title or detail cannot
|
||||
// make two rows match. An in-place row also changes with its tone alone.
|
||||
const signature = JSON.stringify([
|
||||
title,
|
||||
detail,
|
||||
target?.layerId || '',
|
||||
target?.id || '',
|
||||
inPlace ? tone : '',
|
||||
]);
|
||||
// A locale change words the signal again where it stands.
|
||||
const shown = this.rewordingSignals
|
||||
? this.signalItems.find((item) => item.key === key)
|
||||
: null;
|
||||
const shown =
|
||||
this.rewordingSignals || inPlace
|
||||
? this.signalItems.find((item) => item.key === key)
|
||||
: null;
|
||||
if (this.signalSignatures.get(key) === signature && (!inPlace || shown))
|
||||
return;
|
||||
this.signalSignatures.set(key, signature);
|
||||
if (shown) {
|
||||
Object.assign(shown, { title, detail });
|
||||
Object.assign(shown, { tone, title, detail });
|
||||
this.publishCockpitSignals();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,10 @@ import { fakeScenePorts } from '../testSupport/fakeCesiumScene.mjs';
|
||||
const LAT = 47;
|
||||
const LON = 8;
|
||||
const FLOOR_M = 400;
|
||||
/** Metres in a degree of longitude at LAT. */
|
||||
const M_PER_DEG_LON = 111_320 * Math.cos(Cesium.Math.toRadians(LAT));
|
||||
/** The longitude `m` metres east of LON. */
|
||||
const eastM = (m) => LON + m / M_PER_DEG_LON;
|
||||
|
||||
/** A HUD view model as a provider words it. */
|
||||
const HUD = Object.freeze({
|
||||
@@ -123,7 +127,10 @@ function subjectProvider(overrides = {}) {
|
||||
return { definition, subject, calls };
|
||||
}
|
||||
|
||||
function fixture(t, { providers = [], vessel = null, layerOn = true } = {}) {
|
||||
function fixture(
|
||||
t,
|
||||
{ providers = [], vessel = null, layerOn = true, realSignals = false } = {},
|
||||
) {
|
||||
document.body.replaceChildren();
|
||||
const host = document.body.appendChild(document.createElement('div'));
|
||||
const pinia = createPinia();
|
||||
@@ -204,6 +211,7 @@ function fixture(t, { providers = [], vessel = null, layerOn = true } = {}) {
|
||||
instruments: (view) => store.publishInstruments(view),
|
||||
route: (view) => store.publishRoute(view),
|
||||
radar: (view) => store.publishRadar(view),
|
||||
signals: realSignals ? (view) => store.publishSignals(view) : undefined,
|
||||
},
|
||||
});
|
||||
Object.assign(cockpit, {
|
||||
@@ -211,17 +219,20 @@ function fixture(t, { providers = [], vessel = null, layerOn = true } = {}) {
|
||||
showBriefPage() {},
|
||||
startBriefRotation() {},
|
||||
stopBriefRotation() {},
|
||||
pushCockpitSignal(key, tone, title, detail) {
|
||||
signals.push({ key, tone, title, detail });
|
||||
},
|
||||
dropCockpitSignal(key) {
|
||||
dropped.push(key);
|
||||
},
|
||||
scheduleContextLayout() {},
|
||||
updateLocalPosition() {},
|
||||
maybeRefreshRegionalBrief() {},
|
||||
showContextCard() {},
|
||||
});
|
||||
if (!realSignals)
|
||||
Object.assign(cockpit, {
|
||||
pushCockpitSignal(key, tone, title, detail) {
|
||||
signals.push({ key, tone, title, detail });
|
||||
},
|
||||
dropCockpitSignal(key) {
|
||||
dropped.push(key);
|
||||
},
|
||||
});
|
||||
t.after(() => {
|
||||
cockpit.stop();
|
||||
app.unmount();
|
||||
@@ -281,6 +292,25 @@ async function settle() {
|
||||
/** The provider's last release call. */
|
||||
const lastRelease = (calls) => calls.findLast(([name]) => name === 'release');
|
||||
|
||||
/**
|
||||
* Move `ride`'s subject east at `speedMps` from `startMs` (the manual clock's
|
||||
* start) on an inertial anchor, its frame otherwise as it was with `extra`
|
||||
* on top; returns a function giving its longitude now.
|
||||
*/
|
||||
function movingEast(ride, startMs, speedMps, extra = {}) {
|
||||
const eastNow = () =>
|
||||
eastM((speedMps * (performance.now() - startMs)) / 1000);
|
||||
const base = ride.subject.frame;
|
||||
ride.subject.frame = () => ({
|
||||
...base,
|
||||
longitude: eastNow(),
|
||||
speedMps,
|
||||
anchor: 'inertial',
|
||||
...extra,
|
||||
});
|
||||
return eastNow;
|
||||
}
|
||||
|
||||
/** The camera's height above the ellipsoid in its last shot (m). */
|
||||
const shotHeight = (shots) =>
|
||||
Cesium.Cartographic.fromCartesian(shots.at(-1).destination).height;
|
||||
@@ -560,7 +590,7 @@ test('a subject updated every 500 ms turns, eases and closes on its target at it
|
||||
ride.subject.frame = {
|
||||
...ride.subject.frame,
|
||||
headingDeg: 180,
|
||||
longitude: LON + 100 / (111_320 * Math.cos(Cesium.Math.toRadians(LAT))),
|
||||
longitude: eastM(100),
|
||||
};
|
||||
setFloor(FLOOR_M + 3.5);
|
||||
clock.advance(500);
|
||||
@@ -585,7 +615,78 @@ test('a subject updated every 500 ms turns, eases and closes on its target at it
|
||||
// A long stall (a hidden tab) moves it as one late update would.
|
||||
clock.advance(60_000);
|
||||
cockpit.update();
|
||||
assert.ok(Math.abs(cockpit.heading - 101) < 1e-6, 'at most 0.6 s');
|
||||
assert.ok(Math.abs(cockpit.heading - 110) < 1e-6, 'at most 1.5 s');
|
||||
});
|
||||
|
||||
test('a subject turning at the largest finite rate reaches its heading after a late update', async (t) => {
|
||||
const clock = manualClock(t, 10_000);
|
||||
const ride = subjectProvider({
|
||||
cameraIntervalMs: 500,
|
||||
headingSlewDps: Number.MAX_VALUE,
|
||||
});
|
||||
const { cockpit } = fixture(t, { providers: [ride] });
|
||||
cockpit.syncEntry();
|
||||
assert.equal(cockpit.enter(), true);
|
||||
clock.advance(500);
|
||||
cockpit.update();
|
||||
ride.subject.frame = { ...ride.subject.frame, headingDeg: 180 };
|
||||
// A 1.5 s step: the rate times it overflows to Infinity.
|
||||
clock.advance(1500);
|
||||
cockpit.update();
|
||||
assert.equal(cockpit.heading, 180);
|
||||
});
|
||||
|
||||
test('an inertial subject drawn at 5 frames a second stays near its target', async (t) => {
|
||||
const startMs = 10_000;
|
||||
const clock = manualClock(t, startMs);
|
||||
const ride = subjectProvider();
|
||||
const eastNow = movingEast(ride, startMs, 30);
|
||||
const { cockpit, shots } = fixture(t, { providers: [ride] });
|
||||
cockpit.syncEntry();
|
||||
assert.equal(cockpit.enter(), true);
|
||||
for (let i = 0; i < 300; i += 1) {
|
||||
clock.advance(200);
|
||||
cockpit.update();
|
||||
}
|
||||
const target = Cesium.Cartesian3.fromDegrees(eastNow(), LAT, FLOOR_M + 3.5);
|
||||
const gapM = Cesium.Cartesian3.distance(shots.at(-1).destination, target);
|
||||
assert.ok(
|
||||
gapM < 50,
|
||||
`after 60 s the camera is ${gapM.toFixed(0)} m from the subject`,
|
||||
);
|
||||
});
|
||||
|
||||
test("an inertial subject's first camera update after a floor wait longer than its step stands on it", async (t) => {
|
||||
const startMs = 10_000;
|
||||
const clock = manualClock(t, startMs);
|
||||
const intervalMs = 500;
|
||||
const ride = subjectProvider({ cameraIntervalMs: intervalMs });
|
||||
const eastNow = movingEast(ride, startMs, 30, { heightM: null });
|
||||
const { cockpit, shots, setFloor } = fixture(t, { providers: [ride] });
|
||||
setFloor(undefined);
|
||||
cockpit.syncEntry();
|
||||
assert.equal(cockpit.enter(), true);
|
||||
const before = shots.length;
|
||||
// 2 s cold: longer than the 1.5 s an update may step.
|
||||
for (let waited = intervalMs; waited < 2000; waited += intervalMs) {
|
||||
clock.advance(intervalMs);
|
||||
cockpit.update();
|
||||
}
|
||||
assert.equal(
|
||||
shots.length,
|
||||
before,
|
||||
'no camera update while the floor is cold',
|
||||
);
|
||||
setFloor(FLOOR_M);
|
||||
clock.advance(intervalMs);
|
||||
cockpit.update();
|
||||
const shot = Cesium.Cartographic.fromCartesian(shots[before].destination);
|
||||
const leadM =
|
||||
(Cesium.Math.toDegrees(shot.longitude) - eastNow()) * M_PER_DEG_LON;
|
||||
assert.ok(
|
||||
Math.abs(leadM) < 1,
|
||||
`the first camera update leads the subject by ${leadM.toFixed(2)} m`,
|
||||
);
|
||||
});
|
||||
|
||||
test('an exact anchor sits on the subject, wherever the frame moves it', async (t) => {
|
||||
@@ -863,6 +964,47 @@ test('a floor that never comes ends the view after the bounded wait, releasing t
|
||||
assert.deepEqual(lastRelease(ride.calls), ['release', 'a1', false]);
|
||||
});
|
||||
|
||||
for (const entryHeightM of [0, FLOOR_M]) {
|
||||
test(`a height the entry frame gave (${entryHeightM} m) holds while later frames give none and the floor is cold`, async (t) => {
|
||||
const clock = manualClock(t, 10_000);
|
||||
const ride = subjectProvider();
|
||||
ride.subject.frame = { ...ride.subject.frame, heightM: entryHeightM };
|
||||
const { cockpit, shots, setFloor } = fixture(t, { providers: [ride] });
|
||||
setFloor(undefined);
|
||||
cockpit.syncEntry();
|
||||
assert.equal(cockpit.enter(), true);
|
||||
ride.subject.frame = { ...ride.subject.frame, heightM: null };
|
||||
const waitPastTimeout = () => {
|
||||
for (
|
||||
let elapsed = 0;
|
||||
elapsed < COCKPIT_GROUND_WAIT_TIMEOUT_MS + 1000;
|
||||
elapsed += 100
|
||||
) {
|
||||
clock.advance(100);
|
||||
cockpit.update();
|
||||
}
|
||||
};
|
||||
waitPastTimeout();
|
||||
assert.equal(
|
||||
cockpit.active,
|
||||
true,
|
||||
'the view keeps the height its entry frame gave',
|
||||
);
|
||||
assert.ok(shots.length > 0, 'the camera is placed');
|
||||
assert.ok(Math.abs(shotHeight(shots) - (entryHeightM + 3.5)) < 0.01);
|
||||
// A floor that comes takes over, and is kept once it is cold again.
|
||||
const floorM = FLOOR_M - 100;
|
||||
setFloor(floorM);
|
||||
clock.advance(100);
|
||||
cockpit.update();
|
||||
assert.ok(Math.abs(shotHeight(shots) - (floorM + 3.5)) < 0.01);
|
||||
setFloor(undefined);
|
||||
waitPastTimeout();
|
||||
assert.equal(cockpit.active, true);
|
||||
assert.ok(Math.abs(shotHeight(shots) - (floorM + 3.5)) < 0.01);
|
||||
});
|
||||
}
|
||||
|
||||
test('an asynchronous hold that lands after entry was refused is released again', async (t) => {
|
||||
let heldId = null;
|
||||
const releases = [];
|
||||
@@ -942,6 +1084,30 @@ test('a provider’s labels, entry face and look follow a change of language', a
|
||||
);
|
||||
});
|
||||
|
||||
test('a provider whose labels throw after registration enters with no HUD kicker', async (t) => {
|
||||
manualClock(t, 10_000);
|
||||
let read = false;
|
||||
const ride = subjectProvider({
|
||||
labels() {
|
||||
if (read) throw new Error('word bundle unloaded');
|
||||
read = true;
|
||||
return {
|
||||
view: 'Tram view',
|
||||
exit: 'Exit tram view',
|
||||
exitText: 'EXIT TRAM',
|
||||
kicker: 'TRAM 4',
|
||||
};
|
||||
},
|
||||
});
|
||||
ride.subject.hud = { title: 'Example 12' };
|
||||
const { $, cockpit } = fixture(t, { providers: [ride] });
|
||||
cockpit.syncEntry();
|
||||
assert.equal(cockpit.enter(), true);
|
||||
await settle();
|
||||
// The kicker checked at registration stands in for the HUD view's.
|
||||
assert.equal($('.cockpit-kicker').textContent, 'TRAM 4');
|
||||
});
|
||||
|
||||
test('a read that throws ends the view once; a hud that throws keeps the last', async (t) => {
|
||||
const clock = manualClock(t, 10_000);
|
||||
const ride = subjectProvider();
|
||||
@@ -1122,26 +1288,78 @@ test('a subject first seen together with a built-in one comes after it', async (
|
||||
assert.equal(store.presence.entryKind, 'vessel');
|
||||
});
|
||||
|
||||
/**
|
||||
* Every world position projects to (x, y): the scene query port projects
|
||||
* through Cesium.SceneTransforms.
|
||||
*/
|
||||
function everythingAt(t, x, y) {
|
||||
t.mock.method(
|
||||
Cesium.SceneTransforms,
|
||||
'worldToWindowCoordinates',
|
||||
(_scene, _position, result = new Cesium.Cartesian2()) =>
|
||||
Object.assign(result, { x, y }),
|
||||
);
|
||||
}
|
||||
|
||||
test("a double-click on the selected vessel does not enter an application's subject", async (t) => {
|
||||
const clock = manualClock(t, 10_000);
|
||||
const ride = subjectProvider();
|
||||
ride.subject.candidate = null;
|
||||
const { cockpit, store, viewer } = fixture(t, {
|
||||
const { cockpit, store } = fixture(t, {
|
||||
providers: [ride],
|
||||
vessel: VESSEL,
|
||||
});
|
||||
everythingAt(t, 100, 100);
|
||||
cockpit.syncEntry();
|
||||
assert.equal(store.presence.entryKind, 'vessel');
|
||||
// The first press of the double-click notes where the vessel is drawn.
|
||||
cockpit.onScenePointerDown();
|
||||
// The application's subject is selected after the vessel: it takes entry.
|
||||
clock.advance(500);
|
||||
ride.subject.candidate = { id: 'a1', name: 'Example 12', selectedAt: 1 };
|
||||
cockpit.syncEntry();
|
||||
assert.equal(cockpit.resolveEntryKind(), 'example-kind');
|
||||
// Every world position lands under the pointer, the vessel's sprite too.
|
||||
viewer.scene.cartesianToCanvasCoordinates = (_position, result = {}) =>
|
||||
Object.assign(result, { x: 400, y: 300 });
|
||||
assert.equal(cockpit.onSceneDoubleClick({ x: 400, y: 300 }), false);
|
||||
assert.equal(store.presence.entryKind, 'example-kind');
|
||||
// The user double-clicks the vessel, still selected.
|
||||
assert.equal(cockpit.onSceneDoubleClick({ x: 100, y: 100 }), false);
|
||||
await settle();
|
||||
assert.notEqual(store.presence.active, true);
|
||||
assert.equal(
|
||||
cockpit.subjectProvider ?? null,
|
||||
null,
|
||||
'no provider view entered from a double-click on the vessel',
|
||||
);
|
||||
assert.equal(
|
||||
ride.calls.some(([name]) => name === 'hold'),
|
||||
false,
|
||||
'the provider subject was not held',
|
||||
);
|
||||
});
|
||||
|
||||
test('the same double-click on the vessel alone enters its bridge', async (t) => {
|
||||
manualClock(t, 10_000);
|
||||
const { cockpit, store } = fixture(t, { vessel: VESSEL });
|
||||
everythingAt(t, 100, 100);
|
||||
cockpit.syncEntry();
|
||||
assert.equal(store.presence.entryKind, 'vessel');
|
||||
assert.equal(cockpit.onSceneDoubleClick({ x: 100, y: 100 }), true);
|
||||
await settle();
|
||||
assert.equal(store.presence.active, true, 'the bridge is entered');
|
||||
assert.equal(cockpit.subjectKind, 'vessel');
|
||||
});
|
||||
|
||||
test("a moving vessel's first bridge update after entry stands the anchor on its fix", async (t) => {
|
||||
const clock = manualClock(t, 10_000);
|
||||
const { cockpit } = fixture(t, { vessel: VESSEL });
|
||||
cockpit.syncEntry();
|
||||
assert.equal(cockpit.enter(), true);
|
||||
clock.advance(1000);
|
||||
cockpit.update();
|
||||
const anchor = Cesium.Cartographic.fromCartesian(cockpit.cockpitAnchor);
|
||||
const fix = cockpit.vesselFix;
|
||||
const gapM = Cesium.Cartesian3.distance(
|
||||
Cesium.Cartesian3.fromRadians(anchor.longitude, anchor.latitude, 0),
|
||||
Cesium.Cartesian3.fromDegrees(fix.longitude, fix.latitude, 0),
|
||||
);
|
||||
assert.ok(gapM < 0.01, `the anchor is ${gapM.toFixed(2)} m from the fix`);
|
||||
});
|
||||
|
||||
test('a provider view with look turns with the arrow keys and words its readout', async (t) => {
|
||||
@@ -1188,3 +1406,238 @@ test('rows a HUD view no longer lists leave Live Signals', async (t) => {
|
||||
cockpit.update();
|
||||
assert.ok(dropped.includes('subject:note'));
|
||||
});
|
||||
|
||||
test('a signal still listed stays in Live Signals while another one changes', async (t) => {
|
||||
const clock = manualClock(t, 10_000);
|
||||
const ride = subjectProvider();
|
||||
const { cockpit } = fixture(t, { providers: [ride], realSignals: true });
|
||||
// The ETA is logged first, so it stands below the warning.
|
||||
const hudWith = (minutes) => ({
|
||||
...HUD,
|
||||
signals: [
|
||||
{ id: 'eta', title: 'NEXT', detail: `Central in ${minutes} min` },
|
||||
{
|
||||
id: 'doors',
|
||||
tone: 'warning',
|
||||
title: 'DOORS',
|
||||
detail: 'door fault, car 2',
|
||||
},
|
||||
],
|
||||
});
|
||||
const etaRow = () =>
|
||||
cockpit.signalItems.find((row) => row.key === 'subject:eta');
|
||||
ride.subject.hud = hudWith(10);
|
||||
cockpit.syncEntry();
|
||||
assert.equal(cockpit.enter(), true);
|
||||
const keysAtEntry = cockpit.signalItems.map((row) => row.key);
|
||||
const etaFirstSeen = etaRow().timestamp;
|
||||
for (let minutes = 9; minutes >= 2; minutes -= 1) {
|
||||
ride.subject.hud = hudWith(minutes);
|
||||
clock.advance(1000);
|
||||
cockpit.update();
|
||||
}
|
||||
const keys = cockpit.signalItems.map((row) => row.key);
|
||||
// Each row keeps its place, and the ETA the time it first appeared.
|
||||
assert.deepEqual(keys, keysAtEntry);
|
||||
assert.equal(etaRow().timestamp, etaFirstSeen);
|
||||
assert.ok(
|
||||
keys.includes('subject:doors'),
|
||||
`the warning the HUD still lists is shown (rows: ${keys.join(', ')})`,
|
||||
);
|
||||
// The changing one is one row, worded as it reads now.
|
||||
const etas = cockpit.signalItems.filter((row) => row.key === 'subject:eta');
|
||||
assert.deepEqual(
|
||||
etas.map((row) => row.detail),
|
||||
['Central in 2 min'],
|
||||
);
|
||||
// Rows pushed off the list by newer ones come back while still listed.
|
||||
for (let i = 0; i < 5; i += 1)
|
||||
cockpit.pushCockpitSignal(`other-${i}`, 'info', 'OTHER', `row ${i}`);
|
||||
assert.equal(
|
||||
cockpit.signalItems.some((row) => row.key.startsWith('subject:')),
|
||||
false,
|
||||
);
|
||||
clock.advance(1000);
|
||||
cockpit.update();
|
||||
assert.deepEqual(
|
||||
cockpit.signalItems
|
||||
.map((row) => row.key)
|
||||
.filter((key) => key.startsWith('subject:'))
|
||||
.sort(),
|
||||
['subject:doors', 'subject:eta'],
|
||||
);
|
||||
});
|
||||
|
||||
test('a Live Signals row whose tone alone changes takes the new tone', async (t) => {
|
||||
const clock = manualClock(t, 10_000);
|
||||
const ride = subjectProvider();
|
||||
const { cockpit, store } = fixture(t, {
|
||||
providers: [ride],
|
||||
realSignals: true,
|
||||
});
|
||||
const hudWith = (tone) => ({
|
||||
...HUD,
|
||||
signals: [
|
||||
{ id: 'doors', tone, title: 'DOORS', detail: 'door fault, car 2' },
|
||||
],
|
||||
});
|
||||
// The class of the row Live Signals shows.
|
||||
const doorsTone = () =>
|
||||
store.signals.find((row) => row.title === 'DOORS').className;
|
||||
ride.subject.hud = hudWith('normal');
|
||||
cockpit.syncEntry();
|
||||
assert.equal(cockpit.enter(), true);
|
||||
const tones = [doorsTone()];
|
||||
for (const tone of ['warning', 'normal']) {
|
||||
ride.subject.hud = hudWith(tone);
|
||||
clock.advance(1000);
|
||||
cockpit.update();
|
||||
tones.push(doorsTone());
|
||||
}
|
||||
assert.deepEqual(tones, ['info', 'warning', 'info']);
|
||||
});
|
||||
|
||||
test('rows a HUD view replaces leave before new ones push a listed one off', async (t) => {
|
||||
const clock = manualClock(t, 10_000);
|
||||
const ride = subjectProvider();
|
||||
const { cockpit } = fixture(t, { providers: [ride], realSignals: true });
|
||||
const row = (id, tone) => ({
|
||||
id,
|
||||
tone,
|
||||
title: id.toUpperCase(),
|
||||
detail: `row ${id}`,
|
||||
});
|
||||
ride.subject.hud = {
|
||||
...HUD,
|
||||
signals: [row('w', 'warning'), row('a'), row('b'), row('c')],
|
||||
};
|
||||
cockpit.syncEntry();
|
||||
assert.equal(cockpit.enter(), true);
|
||||
assert.ok(cockpit.signalItems.some((item) => item.key === 'track'));
|
||||
ride.subject.hud = {
|
||||
...HUD,
|
||||
signals: [row('w', 'warning'), row('a'), row('d'), row('e')],
|
||||
};
|
||||
clock.advance(1000);
|
||||
cockpit.update();
|
||||
const keys = cockpit.signalItems.map((item) => item.key);
|
||||
assert.deepEqual(
|
||||
[...keys].sort(),
|
||||
['subject:a', 'subject:d', 'subject:e', 'subject:w', 'track'],
|
||||
`rows right after the change: ${keys.join(', ')}`,
|
||||
);
|
||||
});
|
||||
|
||||
// An inertial subject placed at its entry frame's height while the floor was
|
||||
// cold stands on the floor as soon as it warms, as an exact anchor does.
|
||||
test('an inertial subject placed at its entry height stands on the floor once it warms', async (t) => {
|
||||
const clock = manualClock(t, 10_000);
|
||||
const ride = subjectProvider();
|
||||
ride.subject.frame = {
|
||||
...ride.subject.frame,
|
||||
heightM: FLOOR_M,
|
||||
speedMps: 0,
|
||||
anchor: 'inertial',
|
||||
eye: { ...ride.subject.frame.eye, forwardM: 0 },
|
||||
};
|
||||
const { cockpit, shots, setFloor } = fixture(t, { providers: [ride] });
|
||||
setFloor(undefined);
|
||||
cockpit.syncEntry();
|
||||
assert.equal(cockpit.enter(), true);
|
||||
ride.subject.frame = { ...ride.subject.frame, heightM: null };
|
||||
clock.advance(100);
|
||||
cockpit.update();
|
||||
assert.ok(Math.abs(shotHeight(shots) - (FLOOR_M + 3.5)) < 0.01);
|
||||
const floorM = FLOOR_M - 100;
|
||||
setFloor(floorM);
|
||||
for (let i = 0; i < 10; i += 1) {
|
||||
clock.advance(100);
|
||||
cockpit.update();
|
||||
}
|
||||
const heightM = shotHeight(shots);
|
||||
assert.ok(
|
||||
Math.abs(heightM - (floorM + 3.5)) < 1,
|
||||
`1 s after the floor came the eye is at ${heightM.toFixed(2)} m, not ${floorM + 3.5} m`,
|
||||
);
|
||||
});
|
||||
|
||||
/** How far east of LON the camera's last shot is (m). */
|
||||
const shotEastM = (shots) =>
|
||||
(Cesium.Math.toDegrees(
|
||||
Cesium.Cartographic.fromCartesian(shots.at(-1).destination).longitude,
|
||||
) -
|
||||
LON) *
|
||||
M_PER_DEG_LON;
|
||||
|
||||
test('the first floor after an entry height moves an inertial anchor as a cold floor does', async (t) => {
|
||||
// The provider corrects its subject 100 m east as the floor arrives.
|
||||
const run = (warm) => {
|
||||
const clock = manualClock(t, 10_000);
|
||||
const ride = subjectProvider();
|
||||
ride.subject.frame = {
|
||||
...ride.subject.frame,
|
||||
heightM: FLOOR_M,
|
||||
speedMps: 0,
|
||||
anchor: 'inertial',
|
||||
groundClamp: false,
|
||||
};
|
||||
const { cockpit, shots, setFloor } = fixture(t, { providers: [ride] });
|
||||
setFloor(undefined);
|
||||
cockpit.syncEntry();
|
||||
assert.equal(cockpit.enter(), true);
|
||||
ride.subject.frame = { ...ride.subject.frame, heightM: null };
|
||||
clock.advance(100);
|
||||
cockpit.update();
|
||||
const beforeM = shotEastM(shots);
|
||||
ride.subject.frame = { ...ride.subject.frame, longitude: eastM(100) };
|
||||
if (warm) setFloor(FLOOR_M + 0.1);
|
||||
clock.advance(100);
|
||||
cockpit.update();
|
||||
const stepM = shotEastM(shots) - beforeM;
|
||||
const heightM = shotHeight(shots);
|
||||
cockpit.stop();
|
||||
return { stepM, heightM };
|
||||
};
|
||||
const cold = run(false);
|
||||
const warm = run(true);
|
||||
assert.ok(
|
||||
Math.abs(warm.stepM - cold.stepM) < 0.02,
|
||||
`east step ${warm.stepM.toFixed(3)} m with the floor arriving, ${cold.stepM.toFixed(3)} m with it cold`,
|
||||
);
|
||||
assert.ok(Math.abs(warm.heightM - (FLOOR_M + 0.1 + 3.5)) < 0.02);
|
||||
});
|
||||
|
||||
test('the first floor after an entry height never steps an inertial anchor back to a held fix', async (t) => {
|
||||
const startMs = 10_000;
|
||||
const clock = manualClock(t, startMs);
|
||||
const ride = subjectProvider();
|
||||
const base = {
|
||||
...ride.subject.frame,
|
||||
heightM: FLOOR_M,
|
||||
speedMps: 30,
|
||||
anchor: 'inertial',
|
||||
groundClamp: false,
|
||||
};
|
||||
ride.subject.frame = base;
|
||||
const { cockpit, shots, setFloor } = fixture(t, { providers: [ride] });
|
||||
setFloor(undefined);
|
||||
cockpit.syncEntry();
|
||||
assert.equal(cockpit.enter(), true);
|
||||
// Telemetry that gives a new fix once a second, 30 m on each time.
|
||||
ride.subject.frame = () => ({
|
||||
...base,
|
||||
heightM: null,
|
||||
longitude: eastM(30 * Math.floor((performance.now() - startMs) / 1000)),
|
||||
});
|
||||
for (let i = 0; i < 17; i += 1) {
|
||||
clock.advance(100);
|
||||
cockpit.update();
|
||||
}
|
||||
const beforeM = shotEastM(shots);
|
||||
// The floor arrives 1 cm off the entry height, between two fixes.
|
||||
setFloor(FLOOR_M + 0.01);
|
||||
clock.advance(100);
|
||||
cockpit.update();
|
||||
const stepM = shotEastM(shots) - beforeM;
|
||||
assert.ok(stepM > 0, `the eye stepped ${stepM.toFixed(2)} m east`);
|
||||
});
|
||||
@@ -516,7 +516,10 @@ function enterSubject(provider) {
|
||||
this.surfaceAcquiring = false;
|
||||
this.surfaceFallback = false;
|
||||
this.cockpitAnchorValid = false;
|
||||
this.subjectHeightM = null;
|
||||
// The entry frame's height, if any, stands in for a cold floor
|
||||
// (updateSubject).
|
||||
this.subjectHeightM = frame.heightM;
|
||||
this.subjectHeightFromEntry = true;
|
||||
this.lookRestPitchDeg = provider.look?.restPitchDeg ?? null;
|
||||
this.resetLook({ immediate: true });
|
||||
this.active = true;
|
||||
@@ -683,9 +686,11 @@ export function enter({ kind = null } = {}) {
|
||||
'track',
|
||||
t('TRACK ACQUIRED'),
|
||||
// A ship with no true heading is held on its course over ground; one
|
||||
// with neither is named without a direction.
|
||||
// with neither is named without a direction. A ship's course has a
|
||||
// word of its own: pt «RUMO», where an aircraft's is «CURSO».
|
||||
info.trackSource === 'course'
|
||||
? t('{label} · COURSE {heading}°', {
|
||||
context: 'vessel',
|
||||
label: info.name,
|
||||
heading: trackHeading,
|
||||
})
|
||||
|
||||
@@ -379,7 +379,7 @@ test('the layout pass’s measured fit hides the collapsed control and marks the
|
||||
app.unmount();
|
||||
});
|
||||
|
||||
test('the real layout pass drives the mounted controls: compact hides the collapsed sibling, Cyber shows both', async (t) => {
|
||||
test('the real layout pass drives the mounted controls: compact hides the collapsed sibling, desktop shows both', async (t) => {
|
||||
document.body.replaceChildren();
|
||||
const host = document.body.appendChild(document.createElement('div'));
|
||||
const pinia = createPinia();
|
||||
@@ -403,9 +403,6 @@ test('the real layout pass drives the mounted controls: compact hides the collap
|
||||
window.matchMedia = (query) => ({ matches: compact, media: query });
|
||||
t.after(() => {
|
||||
window.matchMedia = originalMatchMedia;
|
||||
delete document.documentElement.dataset.uiTheme;
|
||||
document.body.style.removeProperty('opacity');
|
||||
document.documentElement.style.removeProperty('opacity');
|
||||
app.unmount();
|
||||
});
|
||||
const strip = document.getElementById('cockpit-utility-controls');
|
||||
@@ -421,34 +418,13 @@ test('the real layout pass drives the mounted controls: compact hides the collap
|
||||
assert.equal(cockpit.utilityLayout.top, null);
|
||||
// Compact hides the sibling without marking the strip primary-only.
|
||||
assert.equal(strip.classList.contains('layout-primary-only'), false);
|
||||
// Cyber aligns the strip with the Data panel and keeps both controls.
|
||||
// The desktop pass anchors the strip in its own corridor and keeps both.
|
||||
compact = false;
|
||||
document.documentElement.dataset.uiTheme = 'cyber';
|
||||
const stack = document.body.appendChild(document.createElement('div'));
|
||||
stack.id = 'left-panel-stack';
|
||||
const dataPanel = stack.appendChild(document.createElement('section'));
|
||||
dataPanel.id = 'data-panel';
|
||||
for (const node of [
|
||||
dataPanel,
|
||||
stack,
|
||||
document.body,
|
||||
document.documentElement,
|
||||
])
|
||||
node.style.opacity = '1';
|
||||
dataPanel.getBoundingClientRect = () => ({
|
||||
top: 120,
|
||||
bottom: 400,
|
||||
left: 0,
|
||||
right: 200,
|
||||
width: 200,
|
||||
height: 280,
|
||||
});
|
||||
syncSignalLayout.call(owner);
|
||||
await nextTick();
|
||||
assert.equal(display.getAttribute('aria-hidden'), 'false');
|
||||
assert.equal(radioControl.getAttribute('aria-hidden'), 'false');
|
||||
assert.equal(cockpit.utilityLayout.top, '120.00px');
|
||||
assert.equal(strip.classList.contains('layout-primary-only'), false);
|
||||
assert.match(cockpit.utilityLayout.top, /^\d+(\.\d+)?px$/);
|
||||
});
|
||||
|
||||
test('the rail opens one panel at a time and reads as a disclosure', async (t) => {
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -4,19 +4,6 @@ import {
|
||||
contextModeWord,
|
||||
} from '../contextModePolicy.js';
|
||||
|
||||
/** Why a Space Missions entry failed: its mission index never loaded, and
|
||||
* the error is no older than `since` (an earlier attempt's is not the cause). */
|
||||
export function spaceMissionsIndexFailure(dataManager, since = 0) {
|
||||
const stats = dataManager?.layers
|
||||
?.get('rocket-launches')
|
||||
?.module?.getStats?.();
|
||||
return stats?.error && stats.lastUpdate == null && stats.errorAt >= since
|
||||
? t(
|
||||
'Space Missions unavailable: the mission index could not load. Try again later.',
|
||||
)
|
||||
: null;
|
||||
}
|
||||
|
||||
export async function _runUserFacingContextAction(
|
||||
operation,
|
||||
message = t('Context could not restore every layer; try again'),
|
||||
@@ -71,7 +58,6 @@ export function getContextModeState() {
|
||||
changing: Boolean(this._contextModeChanging),
|
||||
entering: this._contextModeEntering || null,
|
||||
canContact: !this._contextMode || this._contextMode === 'flights',
|
||||
canMission: !this._contextMode || this._contextMode === 'space-missions',
|
||||
snapshotCaptured: Boolean(this._contextSessionSnapshot),
|
||||
};
|
||||
}
|
||||
@@ -127,7 +113,7 @@ export async function setContextMode(
|
||||
};
|
||||
}
|
||||
const canonical = mode === 'contacts' ? 'flights' : mode;
|
||||
if (!['flights', 'space-missions'].includes(canonical)) {
|
||||
if (canonical !== 'flights') {
|
||||
return {
|
||||
ok: false,
|
||||
action: 'set_context_mode',
|
||||
@@ -222,8 +208,6 @@ export function clearSelectedLayers() {
|
||||
this._contextModeChanging = true;
|
||||
this._contextMode = null;
|
||||
this._contextModeEntering = null;
|
||||
this._contextModeEntryIntent = null;
|
||||
this._contextModeReplacementIntent = null;
|
||||
this._contextSessionSnapshot = null;
|
||||
this._contextRestoreState = null;
|
||||
this._preservePanelStateDuringLayerClear = true;
|
||||
|
||||
@@ -1,27 +1,8 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
import { spaceMissionsIndexFailure } from './contextActions.js';
|
||||
import { translateStatusMessage } from './statusText.js';
|
||||
import { shouldExpandGlobalContextPanel } from '../rightRailPolicy.js';
|
||||
|
||||
export function _initGlobalContextPanel() {
|
||||
const contextTabs = [
|
||||
this._globalContextFlightsBtn,
|
||||
this._globalContextMissionsBtn,
|
||||
].filter(Boolean);
|
||||
contextTabs.forEach((tab, index) =>
|
||||
this.listen(tab, 'keydown', (event) => {
|
||||
let nextIndex = null;
|
||||
if (event.key === 'ArrowRight')
|
||||
nextIndex = (index + 1) % contextTabs.length;
|
||||
else if (event.key === 'ArrowLeft')
|
||||
nextIndex = (index - 1 + contextTabs.length) % contextTabs.length;
|
||||
else if (event.key === 'Home') nextIndex = 0;
|
||||
else if (event.key === 'End') nextIndex = contextTabs.length - 1;
|
||||
if (nextIndex === null) return;
|
||||
event.preventDefault();
|
||||
contextTabs[nextIndex].focus({ preventScroll: true });
|
||||
contextTabs[nextIndex].click();
|
||||
}),
|
||||
);
|
||||
this.listen(this._globalContextFlightsBtn, 'click', () => {
|
||||
if (
|
||||
this.destroyed ||
|
||||
@@ -50,40 +31,6 @@ export function _initGlobalContextPanel() {
|
||||
});
|
||||
});
|
||||
});
|
||||
this.listen(this._globalContextMissionsBtn, 'click', () => {
|
||||
if (
|
||||
this.destroyed ||
|
||||
this._contextModeChanging ||
|
||||
this._clearSelectedLayersPromise
|
||||
)
|
||||
return;
|
||||
const nextMode =
|
||||
this._contextMode === 'space-missions' ? null : 'space-missions';
|
||||
this._claimContextVisualAuthority();
|
||||
const startedAt = Date.now();
|
||||
void this._runUserFacingContextAction(
|
||||
(notificationToken) =>
|
||||
this._selectContextMode(nextMode, { notificationToken }),
|
||||
() =>
|
||||
(nextMode && spaceMissionsIndexFailure(this._dataManager, startedAt)) ||
|
||||
t(
|
||||
'Space Missions could not complete the requested transition; try again',
|
||||
),
|
||||
).then((succeeded) => {
|
||||
if (
|
||||
!this.destroyed &&
|
||||
nextMode &&
|
||||
shouldExpandGlobalContextPanel({
|
||||
action: 'space-missions',
|
||||
explicitUserAction: true,
|
||||
succeeded: succeeded === true,
|
||||
})
|
||||
)
|
||||
this.actions.setPanelCollapsed('global-context-panel', false, {
|
||||
explicit: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
this.listen(this._installationsSearchBtn, 'click', () => {
|
||||
if (
|
||||
this.destroyed ||
|
||||
@@ -112,7 +59,7 @@ export function _initGlobalContextPanel() {
|
||||
if (this.destroyed || searched === false) return false;
|
||||
const stats = this.installations.getStats?.();
|
||||
this.showToast(
|
||||
stats?.statusMessage ||
|
||||
(stats?.statusMessage && translateStatusMessage(stats.statusMessage)) ||
|
||||
(stats?.status === 'zoom-in'
|
||||
? t('Zoom in to search mapped installations')
|
||||
: t('Nearby installations refreshed')),
|
||||
|
||||
@@ -44,9 +44,6 @@ export class ContextControls {
|
||||
this._contextModeChanging = false;
|
||||
this._contextModeGeneration = 0;
|
||||
this._contextModeEntering = null;
|
||||
this._contextModeEntryIntent = null;
|
||||
this._contextModeReplacementIntent = null;
|
||||
this._contextModeDeferredEntryIntent = null;
|
||||
this._contextSessionSnapshot = null;
|
||||
this._contextRestoreState = null;
|
||||
this._contextLayerReactionPromises = new Set();
|
||||
|
||||
@@ -48,7 +48,6 @@ test('Context starts with an explicit idle snapshot', (t) => {
|
||||
changing: false,
|
||||
entering: null,
|
||||
canContact: true,
|
||||
canMission: true,
|
||||
snapshotCaptured: false,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { setLocale } from '../i18n/index.js';
|
||||
import {
|
||||
contextLayerEnableBlockReason,
|
||||
parseContextLayerBlockReason,
|
||||
} from '../contextModePolicy.js';
|
||||
import {
|
||||
_handleContextLayerChange,
|
||||
localizeVisibilityBlockReason,
|
||||
@@ -18,7 +14,7 @@ function fakeShell() {
|
||||
_userFacingContextNotificationTokens: new Set(),
|
||||
_contextSessionSnapshot: null,
|
||||
_contextModeChanging: false,
|
||||
_contextMode: 'space-missions',
|
||||
_contextMode: null,
|
||||
_contextModeEntering: null,
|
||||
_syncContextModeButtons() {},
|
||||
showToast(message) {
|
||||
@@ -28,41 +24,19 @@ function fakeShell() {
|
||||
};
|
||||
}
|
||||
|
||||
const ENGLISH_GUARD =
|
||||
'Space Missions isolates replay data. Exit the mode to enable Live Flights.';
|
||||
|
||||
test.afterEach(() => setLocale('en'));
|
||||
|
||||
test('the guard reason is English data and parses back to its layer name', () => {
|
||||
const reason = contextLayerEnableBlockReason({
|
||||
contextMode: 'space-missions',
|
||||
change: { layerId: 'flights', enabled: true, origin: 'user' },
|
||||
layerName: 'Live Flights',
|
||||
});
|
||||
assert.equal(reason, ENGLISH_GUARD);
|
||||
assert.deepEqual(parseContextLayerBlockReason(reason), {
|
||||
layer: 'Live Flights',
|
||||
});
|
||||
assert.equal(parseContextLayerBlockReason('Data source unavailable'), null);
|
||||
assert.equal(
|
||||
parseContextLayerBlockReason(
|
||||
'Space Missions isolates replay data. Exit the mode to enable .',
|
||||
),
|
||||
null,
|
||||
);
|
||||
});
|
||||
|
||||
test('en: the toast shows the reason unchanged', () => {
|
||||
setLocale('en');
|
||||
const shell = fakeShell();
|
||||
_handleContextLayerChange.call(shell, {
|
||||
type: 'visibility-blocked',
|
||||
layerId: 'flights',
|
||||
layerId: 'street-level',
|
||||
enabled: true,
|
||||
origin: 'user',
|
||||
reason: ENGLISH_GUARD,
|
||||
reason: 'Data source unavailable',
|
||||
});
|
||||
assert.deepEqual(shell.toasts, [ENGLISH_GUARD]);
|
||||
assert.deepEqual(shell.toasts, ['Data source unavailable']);
|
||||
assert.equal(
|
||||
localizeVisibilityBlockReason('Overpass returned HTTP 503'),
|
||||
'Overpass returned HTTP 503',
|
||||
@@ -70,27 +44,6 @@ test('en: the toast shows the reason unchanged', () => {
|
||||
});
|
||||
|
||||
for (const locale of ['es', 'ru']) {
|
||||
test(`${locale}: the Space Missions block toast is localized with the layer name`, () => {
|
||||
setLocale(locale);
|
||||
const reason = contextLayerEnableBlockReason({
|
||||
contextMode: 'space-missions',
|
||||
change: { layerId: 'flights', enabled: true, origin: 'user' },
|
||||
layerName: 'Live Flights',
|
||||
});
|
||||
const shell = fakeShell();
|
||||
_handleContextLayerChange.call(shell, {
|
||||
type: 'visibility-blocked',
|
||||
layerId: 'flights',
|
||||
enabled: true,
|
||||
origin: 'user',
|
||||
reason,
|
||||
});
|
||||
assert.equal(shell.toasts.length, 1);
|
||||
assert.notEqual(shell.toasts[0], ENGLISH_GUARD, 'toast must be localized');
|
||||
assert.doesNotMatch(shell.toasts[0], /Space Missions isolates/);
|
||||
assert.doesNotMatch(shell.toasts[0], /Live Flights/);
|
||||
});
|
||||
|
||||
test(`${locale}: a known lifecycle reason is looked up in the catalog`, () => {
|
||||
setLocale(locale);
|
||||
const shell = fakeShell();
|
||||
|
||||
+21
-109
@@ -1,28 +1,16 @@
|
||||
import { t, translateKnown } from '../i18n/index.js';
|
||||
import {
|
||||
SPACE_MISSIONS_LAYER_BLOCK_REASON,
|
||||
isExplicitUserIntentOrigin,
|
||||
parseContextLayerBlockReason,
|
||||
recordContextRestoreExplicitChange,
|
||||
recordContextSessionUserChange,
|
||||
shouldExitContextForLayerChange,
|
||||
spaceMissionEntryCancellationDisposition,
|
||||
} from '../contextModePolicy.js';
|
||||
import { localizeLayerName } from './layerNames.js';
|
||||
import { spaceMissionsIndexFailure } from './contextActions.js';
|
||||
|
||||
/**
|
||||
* A blocked-visibility reason in the UI language. Reasons stay English (voice
|
||||
* and tools read them): the Space Missions refusal is rebuilt with the layer
|
||||
* name localized, a known sentence is looked up, anything else passes.
|
||||
* and tools read them): a known sentence is looked up, anything else passes.
|
||||
*/
|
||||
export function localizeVisibilityBlockReason(reason) {
|
||||
if (typeof reason !== 'string' || !reason) return reason;
|
||||
const blocked = parseContextLayerBlockReason(reason);
|
||||
if (blocked)
|
||||
return t(SPACE_MISSIONS_LAYER_BLOCK_REASON, {
|
||||
layer: localizeLayerName(blocked.layer),
|
||||
});
|
||||
return translateKnown(reason);
|
||||
}
|
||||
|
||||
@@ -40,74 +28,12 @@ export function _handleContextLayerChange(change) {
|
||||
this.actions.refreshRadio();
|
||||
}
|
||||
if (change?.type === 'visibility-transition') return;
|
||||
// The effective mode must be read BEFORE the entering flag is cleared:
|
||||
// the entry layer's own enable event is the one that clears it, and the
|
||||
// session bookkeeping below needs to know a mode was being entered.
|
||||
// A mode still being entered counts for the session bookkeeping below.
|
||||
const effectiveContextMode = this._contextModeEntering || this._contextMode;
|
||||
if (change?.type === 'visibility-cancelled') {
|
||||
const cancellationDisposition = spaceMissionEntryCancellationDisposition({
|
||||
change,
|
||||
});
|
||||
if (
|
||||
this._contextModeDeferredEntryIntent?.layerId === change.layerId &&
|
||||
this._contextModeDeferredEntryIntent.intentEpoch === change.intentEpoch
|
||||
) {
|
||||
if (cancellationDisposition !== 'replacement') {
|
||||
this._contextModeDeferredEntryIntent = null;
|
||||
}
|
||||
}
|
||||
if (cancellationDisposition === 'replacement') {
|
||||
this._contextModeEntering = 'space-missions';
|
||||
const entryIntent = this._contextModeEntryIntent;
|
||||
if (
|
||||
entryIntent?.generation === this._contextModeGeneration &&
|
||||
entryIntent.layerId === change.layerId &&
|
||||
entryIntent.intentEpoch === change.intentEpoch
|
||||
) {
|
||||
this._contextModeReplacementIntent = {
|
||||
generation: entryIntent.generation,
|
||||
layerId: change.layerId,
|
||||
intentEpoch: change.successorIntentEpoch,
|
||||
};
|
||||
}
|
||||
} else if (cancellationDisposition === 'restore') {
|
||||
this._contextModeEntering = null;
|
||||
this._contextModeEntryIntent = null;
|
||||
this._contextModeReplacementIntent = null;
|
||||
if (this._contextSessionSnapshot && !this._contextModeChanging) {
|
||||
this._contextMode = null;
|
||||
void this._trackContextLayerReaction(
|
||||
this._runUserFacingContextAction(
|
||||
async (notificationToken) => {
|
||||
await this._restoreContextSessionAfterLayerSettles(
|
||||
change.layerId,
|
||||
{
|
||||
notificationToken,
|
||||
},
|
||||
);
|
||||
return true;
|
||||
},
|
||||
'Space Missions cancellation could not restore the previous layer state', // i18n-ignore: English message; the toast shows localizedMessage
|
||||
{
|
||||
localizedMessage: t(
|
||||
'Space Missions cancellation could not restore the previous layer state',
|
||||
),
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
this._syncContextModeButtons();
|
||||
return;
|
||||
}
|
||||
if (
|
||||
change?.layerId === 'rocket-launches' &&
|
||||
['visibility', 'visibility-blocked', 'visibility-failed'].includes(
|
||||
change.type,
|
||||
)
|
||||
) {
|
||||
this._contextModeEntering = null;
|
||||
}
|
||||
if (change?.type === 'visibility-blocked') {
|
||||
if (
|
||||
!this._userFacingContextNotificationTokens.has(change.notificationToken)
|
||||
@@ -121,10 +47,13 @@ export function _handleContextLayerChange(change) {
|
||||
return;
|
||||
}
|
||||
if (change?.type === 'visibility-failed') {
|
||||
// A layer may name why its own start failed (Space Missions: the
|
||||
// mission index never loaded).
|
||||
const failureMessage =
|
||||
(change.layerId === 'rocket-launches' &&
|
||||
change.enabled &&
|
||||
spaceMissionsIndexFailure(this._dataManager)) ||
|
||||
(change.enabled &&
|
||||
this._dataManager?.layers
|
||||
?.get(change.layerId)
|
||||
?.module?.enableFailureMessage?.()) ||
|
||||
t('{layerId} could not {action} cleanly', {
|
||||
layerId: change.layerId,
|
||||
action: change.enabled ? t('start') : t('stop'),
|
||||
@@ -134,7 +63,7 @@ export function _handleContextLayerChange(change) {
|
||||
// notification for this queue to settle, then reconcile the complete
|
||||
// snapshot, including an uncertain failed shell.
|
||||
const needsDeferredShellRestore =
|
||||
['military-awareness', 'rocket-launches'].includes(change.layerId) &&
|
||||
change.layerId === 'military-awareness' &&
|
||||
change.enabled &&
|
||||
this._contextSessionSnapshot &&
|
||||
!this._contextModeChanging;
|
||||
@@ -212,26 +141,6 @@ export function _handleContextLayerChange(change) {
|
||||
),
|
||||
);
|
||||
}
|
||||
} else if (change.layerId === 'rocket-launches') {
|
||||
const ownsContextEntry =
|
||||
isExplicitUserIntentOrigin(change.origin, change.layerId) ||
|
||||
this._contextMode === 'space-missions' ||
|
||||
effectiveContextMode === 'space-missions';
|
||||
if (!ownsContextEntry) return;
|
||||
this._contextMode = change.enabled
|
||||
? 'space-missions'
|
||||
: this._contextMode === 'space-missions'
|
||||
? null
|
||||
: this._contextMode;
|
||||
if (change.enabled) {
|
||||
this._syncContextModeButtons();
|
||||
} else if (this._contextSessionSnapshot) {
|
||||
void this._trackContextLayerReaction(
|
||||
this._runUserFacingContextAction((notificationToken) =>
|
||||
this._deactivateContextForLayerChange({ notificationToken }),
|
||||
),
|
||||
);
|
||||
}
|
||||
} else if (
|
||||
this._contextMode === 'flights' &&
|
||||
[
|
||||
@@ -254,23 +163,26 @@ export function _handleContextLayerChange(change) {
|
||||
change.enabled &&
|
||||
change.origin === 'user' &&
|
||||
!this.cockpitView?.active &&
|
||||
(change.layerId === 'radio' || change.layerId === 'rocket-launches')
|
||||
change.layerId === 'radio'
|
||||
) {
|
||||
// Context's panel shows its main tab for them (ContextView listens).
|
||||
globalThis.dispatchEvent?.(new Event('gev:context-show-view'));
|
||||
this.actions.setPanelCollapsed('global-context-panel', false, {
|
||||
explicit: true,
|
||||
});
|
||||
if (change.layerId === 'radio')
|
||||
this.actions.setPanelCollapsed('radio-panel', false, { explicit: true });
|
||||
this.actions.setPanelCollapsed('radio-panel', false, { explicit: true });
|
||||
}
|
||||
finishContextLayerChange(this);
|
||||
}
|
||||
|
||||
/** The checks every settled layer change ends with. */
|
||||
function finishContextLayerChange(controls) {
|
||||
// Turning off the layer the view rides ends it; every other layer may be
|
||||
// turned on or off freely during a session.
|
||||
const riddenLayerId = this.cockpitView?.active
|
||||
? this.cockpitView.readSubjectLayerId?.()
|
||||
const riddenLayerId = controls.cockpitView?.active
|
||||
? controls.cockpitView.readSubjectLayerId?.()
|
||||
: null;
|
||||
if (riddenLayerId && !this._dataManager?.isEnabled(riddenLayerId)) {
|
||||
this.cockpitView.exit({ restoreTracking: false });
|
||||
if (riddenLayerId && !controls._dataManager?.isEnabled(riddenLayerId)) {
|
||||
controls.cockpitView.exit({ restoreTracking: false });
|
||||
}
|
||||
this._syncContextModeButtons();
|
||||
controls._syncContextModeButtons();
|
||||
}
|
||||
@@ -22,7 +22,6 @@ function fixture(t) {
|
||||
const controls = new ContextControls({
|
||||
elements: {
|
||||
_globalContextFlightsBtn: $('global-context-flights-btn'),
|
||||
_globalContextMissionsBtn: $('global-context-missions-btn'),
|
||||
_installationsSearchBtn: $('installations-search-btn'),
|
||||
},
|
||||
installations: {},
|
||||
@@ -58,61 +57,41 @@ test('before ContextControls renders, the switch shows its initial markup', (t)
|
||||
'ui-panel panel-collapsible collapsed ui-panel--collapsed',
|
||||
);
|
||||
assert.equal(panel.hasAttribute('data-context-mode'), false);
|
||||
for (const id of [
|
||||
'global-context-flights-btn',
|
||||
'global-context-missions-btn',
|
||||
]) {
|
||||
const tab = $(id);
|
||||
assert.equal(tab.className, 'context-mode-button');
|
||||
assert.equal(tab.getAttribute('aria-selected'), 'false');
|
||||
assert.equal(tab.getAttribute('tabindex'), '0');
|
||||
assert.equal(tab.hasAttribute('aria-busy'), false);
|
||||
}
|
||||
const tab = $('global-context-flights-btn');
|
||||
assert.equal(tab.className, 'context-mode-button');
|
||||
assert.equal(tab.getAttribute('aria-selected'), 'false');
|
||||
assert.equal(tab.getAttribute('tabindex'), '0');
|
||||
assert.equal(tab.hasAttribute('aria-busy'), false);
|
||||
assert.equal($('context-mode-standby').hidden, false);
|
||||
assert.equal($('context-flights-view').hidden, true);
|
||||
assert.equal($('context-missions-view').hidden, true);
|
||||
assert.equal($('global-context-missions-btn'), null);
|
||||
assert.equal($('context-missions-view'), null);
|
||||
assert.equal($('installations-search-btn').hasAttribute('aria-busy'), false);
|
||||
});
|
||||
|
||||
test('a transition keeps focus and Tab on both tabs until it settles', async (t) => {
|
||||
test('a Contacts transition keeps the tab focusable until it settles', async (t) => {
|
||||
const { $, controls, sync } = fixture(t);
|
||||
const contacts = $('global-context-flights-btn');
|
||||
const missions = $('global-context-missions-btn');
|
||||
missions.focus();
|
||||
contacts.focus();
|
||||
controls._contextModeChanging = true;
|
||||
await sync();
|
||||
assert.equal(
|
||||
document.activeElement === missions,
|
||||
true,
|
||||
'busy render keeps focus',
|
||||
);
|
||||
for (const tab of [contacts, missions]) {
|
||||
assert.equal(tab.disabled, false);
|
||||
assert.equal(tab.getAttribute('tabindex'), '0');
|
||||
assert.equal(tab.getAttribute('aria-disabled'), 'true');
|
||||
assert.equal(tab.getAttribute('aria-busy'), 'true');
|
||||
}
|
||||
assert.equal(document.activeElement, contacts);
|
||||
assert.equal(contacts.disabled, false);
|
||||
assert.equal(contacts.getAttribute('tabindex'), '0');
|
||||
assert.equal(contacts.getAttribute('aria-disabled'), 'true');
|
||||
assert.equal(contacts.getAttribute('aria-busy'), 'true');
|
||||
|
||||
controls._contextModeChanging = false;
|
||||
controls._contextMode = 'space-missions';
|
||||
controls._contextMode = 'flights';
|
||||
await sync();
|
||||
assert.equal(
|
||||
document.activeElement === missions,
|
||||
true,
|
||||
'settled render keeps focus',
|
||||
);
|
||||
for (const tab of [contacts, missions]) {
|
||||
assert.equal(tab.disabled, false);
|
||||
assert.equal(tab.getAttribute('aria-disabled'), 'false');
|
||||
assert.equal(tab.getAttribute('aria-busy'), 'false');
|
||||
}
|
||||
assert.equal(missions.classList.contains('active'), true);
|
||||
assert.equal(missions.getAttribute('aria-selected'), 'true');
|
||||
assert.equal(contacts.classList.contains('active'), false);
|
||||
assert.equal(contacts.getAttribute('aria-selected'), 'false');
|
||||
assert.equal(document.activeElement, contacts);
|
||||
assert.equal(contacts.disabled, false);
|
||||
assert.equal(contacts.getAttribute('aria-disabled'), 'false');
|
||||
assert.equal(contacts.getAttribute('aria-busy'), 'false');
|
||||
assert.equal(contacts.classList.contains('active'), true);
|
||||
assert.equal(contacts.getAttribute('aria-selected'), 'true');
|
||||
assert.equal($('context-mode-standby').hidden, true);
|
||||
assert.equal($('context-flights-view').hidden, true);
|
||||
assert.equal($('context-missions-view').hidden, false);
|
||||
assert.equal($('context-flights-view').hidden, false);
|
||||
});
|
||||
|
||||
test('the panel carries the mode beside the classes its chrome writes', async (t) => {
|
||||
|
||||
@@ -12,17 +12,10 @@ export function _syncContextModeButtons() {
|
||||
export function _presentContext() {
|
||||
if (this.destroyed) return;
|
||||
const flightsActive = this._contextMode === 'flights';
|
||||
const missionsActive = this._contextMode === 'space-missions';
|
||||
// Both Context choices stay in the ordinary Tab sequence and are never
|
||||
// native-disabled. Arrow keys still provide tablist navigation, but must
|
||||
// not be the only way to reach Space Missions from the keyboard. Semantic
|
||||
// busy state keeps them perceivable while synchronous click guards prevent
|
||||
// a second transition.
|
||||
this.publish({
|
||||
mode: this._contextMode || 'none',
|
||||
enabled: flightsActive || missionsActive,
|
||||
enabled: flightsActive,
|
||||
flightsActive,
|
||||
missionsActive,
|
||||
busy: Boolean(this._contextModeChanging),
|
||||
installationsBusy: this._installationsSearchBusy,
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
CONTEXT_INDEPENDENT_LAYER_IDS,
|
||||
contextRestoreLayerIds,
|
||||
contextSnapshotLayerIds,
|
||||
mergeContextTransitionErrors,
|
||||
@@ -24,7 +25,8 @@ export async function _waitForContextLayerSettlement() {
|
||||
export function _captureContextSessionSnapshot({ excludeLayerIds = [] } = {}) {
|
||||
if (!this._dataManager || this._contextSessionSnapshot) return;
|
||||
const params = {};
|
||||
for (const layerId of ['military-awareness', 'satellites']) {
|
||||
// Satellites is not Context's: the mission controller owns its parameters.
|
||||
for (const layerId of ['military-awareness']) {
|
||||
const value = this._dataManager.getLayerParams(layerId);
|
||||
if (value) params[layerId] = value;
|
||||
}
|
||||
@@ -93,9 +95,11 @@ export async function _restoreContextSession({
|
||||
restoreState.enabledLayerIds,
|
||||
{
|
||||
origin: 'context-restore',
|
||||
excludeLayerIds: settleContactsCoordinator
|
||||
? [...excludeLayerIds, contactsCoordinatorId]
|
||||
: excludeLayerIds,
|
||||
excludeLayerIds: [
|
||||
...excludeLayerIds,
|
||||
...CONTEXT_INDEPENDENT_LAYER_IDS,
|
||||
...(settleContactsCoordinator ? [contactsCoordinatorId] : []),
|
||||
],
|
||||
notificationToken,
|
||||
...(restoreSignal ? { signal: restoreSignal } : {}),
|
||||
},
|
||||
|
||||
+38
-104
@@ -1,11 +1,8 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
import {
|
||||
contextLayerEnableBlockReason,
|
||||
isExplicitUserIntentOrigin,
|
||||
runWithContextModeChanging,
|
||||
settleContextModeChange,
|
||||
shouldCaptureContextSession,
|
||||
shouldDeferContextEntryDuringClear,
|
||||
} from '../contextModePolicy.js';
|
||||
|
||||
export function connectContextManager(manager) {
|
||||
@@ -28,31 +25,6 @@ export function connectContextManager(manager) {
|
||||
this._captureContextSessionSnapshot({
|
||||
excludeLayerIds: [change.layerId],
|
||||
});
|
||||
if (
|
||||
shouldDeferContextEntryDuringClear({
|
||||
change,
|
||||
clearInFlight: Boolean(this._clearSelectedLayersPromise),
|
||||
})
|
||||
) {
|
||||
this._contextModeDeferredEntryIntent = {
|
||||
layerId: change.layerId,
|
||||
intentEpoch: change.intentEpoch,
|
||||
origin: change.origin,
|
||||
};
|
||||
this._contextModeEntering = 'space-missions';
|
||||
this._syncContextModeButtons();
|
||||
}
|
||||
} else if (
|
||||
change?.layerId === 'rocket-launches' &&
|
||||
change.enabled === false &&
|
||||
isExplicitUserIntentOrigin(change.origin, change.layerId)
|
||||
) {
|
||||
this._contextModeDeferredEntryIntent = null;
|
||||
if (this._clearSelectedLayersPromise) {
|
||||
this._contextSessionSnapshot = null;
|
||||
this._contextModeEntering = null;
|
||||
this._syncContextModeButtons();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -60,88 +32,50 @@ export function connectContextManager(manager) {
|
||||
this._dataManagerVisibilityGuardUnsubscribe =
|
||||
this._dataManager.addVisibilityGuard(async (change) => {
|
||||
if (this.destroyed) return null;
|
||||
const layerName =
|
||||
this._dataManager?.layers?.get(change.layerId)?.module?.name ||
|
||||
change.layerId;
|
||||
const reason = contextLayerEnableBlockReason({
|
||||
contextMode: this._contextModeEntering || this._contextMode,
|
||||
change,
|
||||
layerName,
|
||||
});
|
||||
if (reason) return reason;
|
||||
// A direct Contacts start (the coordinator layer itself, not the
|
||||
// Context chooser) isolates its dependencies like the chooser does.
|
||||
if (
|
||||
change.enabled &&
|
||||
['military-awareness', 'rocket-launches'].includes(change.layerId) &&
|
||||
shouldCaptureContextSession(change) &&
|
||||
(!this._contextModeChanging ||
|
||||
(change.layerId === 'rocket-launches' &&
|
||||
this._contextModeDeferredEntryIntent?.intentEpoch ===
|
||||
change.intentEpoch))
|
||||
) {
|
||||
const entryMode =
|
||||
change.layerId === 'rocket-launches' ? 'space-missions' : null;
|
||||
const deferredClearEntry =
|
||||
this._contextModeDeferredEntryIntent?.intentEpoch ===
|
||||
change.intentEpoch;
|
||||
// A deferred entry owns the state after Clear settles. Restoring
|
||||
// Clear's transient busy flag here would leave Context stuck.
|
||||
const priorChanging = deferredClearEntry
|
||||
? false
|
||||
: this._contextModeChanging;
|
||||
const notificationToken =
|
||||
change.notificationToken || Symbol('direct-context-shell-entry');
|
||||
const ownsNotificationToken = !change.notificationToken;
|
||||
if (ownsNotificationToken) {
|
||||
this._userFacingContextNotificationTokens.add(notificationToken);
|
||||
}
|
||||
this._contextModeEntering = entryMode;
|
||||
this._contextModeChanging = true;
|
||||
!change.enabled ||
|
||||
change.layerId !== 'military-awareness' ||
|
||||
!shouldCaptureContextSession(change) ||
|
||||
this._contextModeChanging
|
||||
)
|
||||
return null;
|
||||
const notificationToken =
|
||||
change.notificationToken || Symbol('direct-context-shell-entry');
|
||||
const ownsNotificationToken = !change.notificationToken;
|
||||
if (ownsNotificationToken) {
|
||||
this._userFacingContextNotificationTokens.add(notificationToken);
|
||||
}
|
||||
this._contextModeEntering = null;
|
||||
this._contextModeChanging = true;
|
||||
try {
|
||||
await this._clearLayersOutsideContextMode(null, {
|
||||
notificationToken,
|
||||
});
|
||||
if (this.destroyed) return false;
|
||||
} catch (error) {
|
||||
console.warn(`[Context] ${change.layerId} isolation failed`, error);
|
||||
try {
|
||||
if (deferredClearEntry) {
|
||||
await this._clearSelectedLayersManagerPromise;
|
||||
if (this.destroyed) return false;
|
||||
if (
|
||||
this._contextModeDeferredEntryIntent?.intentEpoch !==
|
||||
change.intentEpoch
|
||||
)
|
||||
return false;
|
||||
this._contextModeDeferredEntryIntent = null;
|
||||
}
|
||||
await this._clearLayersOutsideContextMode(entryMode, {
|
||||
await this._restoreContextSession({
|
||||
excludeLayerIds: [change.layerId],
|
||||
notificationToken,
|
||||
});
|
||||
if (this.destroyed) return false;
|
||||
} catch (error) {
|
||||
this._contextModeEntering = null;
|
||||
console.warn(`[Context] ${change.layerId} isolation failed`, error);
|
||||
try {
|
||||
await this._restoreContextSession({
|
||||
excludeLayerIds: [change.layerId],
|
||||
notificationToken,
|
||||
});
|
||||
} catch (restoreError) {
|
||||
console.warn(
|
||||
`[Context] ${change.layerId} rollback failed`,
|
||||
restoreError,
|
||||
);
|
||||
}
|
||||
return t(
|
||||
'{mode} could not start because another layer did not stop cleanly',
|
||||
{
|
||||
mode:
|
||||
entryMode === 'space-missions'
|
||||
? t('Space Missions')
|
||||
: t('Context'),
|
||||
},
|
||||
} catch (restoreError) {
|
||||
console.warn(
|
||||
`[Context] ${change.layerId} rollback failed`,
|
||||
restoreError,
|
||||
);
|
||||
} finally {
|
||||
if (ownsNotificationToken) {
|
||||
this._userFacingContextNotificationTokens.delete(
|
||||
notificationToken,
|
||||
);
|
||||
}
|
||||
if (!this.destroyed) settleContextModeChange(this, priorChanging);
|
||||
}
|
||||
return t(
|
||||
'{mode} could not start because another layer did not stop cleanly',
|
||||
{ mode: t('Context') },
|
||||
);
|
||||
} finally {
|
||||
if (ownsNotificationToken) {
|
||||
this._userFacingContextNotificationTokens.delete(notificationToken);
|
||||
}
|
||||
if (!this.destroyed) settleContextModeChange(this, false);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
@@ -13,8 +13,6 @@ export async function _selectContextMode(
|
||||
const generation = ++this._contextModeGeneration;
|
||||
const isCurrent = () =>
|
||||
!this.destroyed && generation === this._contextModeGeneration;
|
||||
this._contextModeEntryIntent = null;
|
||||
this._contextModeReplacementIntent = null;
|
||||
this._contextModeChanging = true;
|
||||
this._syncContextModeButtons();
|
||||
try {
|
||||
@@ -47,9 +45,6 @@ export async function _selectContextMode(
|
||||
this._captureContextSessionSnapshot();
|
||||
this._contextMode = mode;
|
||||
this._syncContextModeButtons();
|
||||
// Replay isolation must settle before Space Missions starts. Contacts
|
||||
// keeps its non-dependency teardown in the background so slow source
|
||||
// shutdown does not delay cockpit entry.
|
||||
try {
|
||||
await this._clearLayersOutsideContextMode(mode, {
|
||||
notificationToken,
|
||||
@@ -82,13 +77,8 @@ export async function _selectContextMode(
|
||||
// Entry is one transaction: isolation succeeded above, so a failed mode
|
||||
// activation must roll the cleared layers back instead of stranding the
|
||||
// user in a half-entered mode with an orphaned snapshot.
|
||||
const entryLayerId =
|
||||
mode === 'flights' ? 'military-awareness' : 'rocket-launches';
|
||||
if (mode === 'flights') {
|
||||
this._dataManager.setLayerParams('military-awareness', {
|
||||
passive: false,
|
||||
});
|
||||
}
|
||||
const entryLayerId = 'military-awareness';
|
||||
this._dataManager.setLayerParams(entryLayerId, { passive: false });
|
||||
let activated = false;
|
||||
let activationError = null;
|
||||
let activationIntent = null;
|
||||
@@ -99,11 +89,6 @@ export async function _selectContextMode(
|
||||
true,
|
||||
{ notificationToken, ...(signal ? { signal } : {}) },
|
||||
);
|
||||
this._contextModeEntryIntent = {
|
||||
generation,
|
||||
layerId: entryLayerId,
|
||||
intentEpoch: activationIntent.intentEpoch,
|
||||
};
|
||||
activated = await activationIntent.promise;
|
||||
terminalIntentOutcome =
|
||||
await this._dataManager._waitForVisibilityIntent?.(
|
||||
@@ -114,46 +99,6 @@ export async function _selectContextMode(
|
||||
activationError = error;
|
||||
}
|
||||
if (!isCurrent()) return false;
|
||||
let replacementIntent =
|
||||
mode === 'space-missions' &&
|
||||
this._contextModeReplacementIntent?.generation === generation &&
|
||||
this._contextModeReplacementIntent.layerId === entryLayerId
|
||||
? this._contextModeReplacementIntent
|
||||
: null;
|
||||
while (replacementIntent) {
|
||||
const outcome = await this._dataManager._waitForVisibilityIntent?.(
|
||||
entryLayerId,
|
||||
replacementIntent.intentEpoch,
|
||||
);
|
||||
terminalIntentOutcome = outcome;
|
||||
if (!isCurrent()) return false;
|
||||
const replacementOwnsMode =
|
||||
outcome?.intentEpoch === replacementIntent.intentEpoch &&
|
||||
outcome.enabled === true &&
|
||||
outcome.succeeded === true;
|
||||
if (replacementOwnsMode) {
|
||||
this._contextModeEntering = null;
|
||||
this._contextModeEntryIntent = null;
|
||||
this._contextModeReplacementIntent = null;
|
||||
this._syncContextModeButtons();
|
||||
return true;
|
||||
}
|
||||
const successorEpoch =
|
||||
outcome?.cancellationReason === 'superseded' &&
|
||||
outcome.successorEnabled === true &&
|
||||
Number.isInteger(outcome.successorIntentEpoch) &&
|
||||
outcome.successorIntentEpoch > replacementIntent.intentEpoch
|
||||
? outcome.successorIntentEpoch
|
||||
: null;
|
||||
replacementIntent =
|
||||
successorEpoch === null
|
||||
? null
|
||||
: {
|
||||
generation,
|
||||
layerId: entryLayerId,
|
||||
intentEpoch: successorEpoch,
|
||||
};
|
||||
}
|
||||
if (
|
||||
activationError ||
|
||||
activated === false ||
|
||||
@@ -182,8 +127,6 @@ export async function _selectContextMode(
|
||||
);
|
||||
}
|
||||
this._contextMode = null;
|
||||
this._contextModeEntryIntent = null;
|
||||
this._contextModeReplacementIntent = null;
|
||||
this._syncContextModeButtons();
|
||||
try {
|
||||
await this._restoreContextSession({
|
||||
@@ -205,7 +148,6 @@ export async function _selectContextMode(
|
||||
// while callers still require literal `true` before expanding Context.
|
||||
return cancelledAndSettled ? null : false;
|
||||
}
|
||||
this._contextModeEntryIntent = null;
|
||||
return true;
|
||||
} finally {
|
||||
if (isCurrent()) {
|
||||
@@ -221,8 +163,6 @@ export async function _deactivateContextForLayerChange({
|
||||
this._contextModeGeneration += 1;
|
||||
this._contextModeChanging = true;
|
||||
this._contextMode = null;
|
||||
this._contextModeEntryIntent = null;
|
||||
this._contextModeReplacementIntent = null;
|
||||
// A layer turned off ends Contacts but not the Cockpit: the view ends only
|
||||
// when the layer it rides goes off (see _handleContextLayerChange).
|
||||
this._syncContextModeButtons();
|
||||
|
||||
@@ -9,9 +9,8 @@ import { fileURLToPath } from 'node:url';
|
||||
const HERE = path.dirname(fileURLToPath(import.meta.url));
|
||||
const STYLES = path.join(HERE, 'styles');
|
||||
const LOCALES = path.join(HERE, '..', 'i18n', 'locales');
|
||||
// cyber.css carries decorative theme strings (LOC / GRID, SYS 06 // ...);
|
||||
// street-level.css ' · ESC' is a key cap. Neither is UI copy.
|
||||
const DECORATIVE = new Set(['cyber.css', 'street-level.css']);
|
||||
// street-level.css ' · ESC' is a key cap, not UI copy.
|
||||
const DECORATIVE = new Set(['street-level.css']);
|
||||
|
||||
test('no user-visible text in CSS content: outside decorative themes', () => {
|
||||
const hits = [];
|
||||
|
||||
@@ -38,7 +38,6 @@ export function getCyberSonarControlState(
|
||||
intensityPct: settings.intensity,
|
||||
opacityPct: settings.opacity,
|
||||
sectorDeg: settings.sector,
|
||||
cyberSelected: root?.dataset?.uiTheme === 'cyber',
|
||||
mapSweepActive: isCyberSonarActive(options),
|
||||
contactSweepActive:
|
||||
root?.dataset?.cyberSonarGpu === 'supported' &&
|
||||
@@ -59,10 +58,10 @@ export function setCyberSonarControls(
|
||||
sonar: getCyberSonarControlState(doc, { hudActive: owner?.hud?.visible }),
|
||||
});
|
||||
if (!request || typeof request !== 'object' || Array.isArray(request)) {
|
||||
return fail('Provide Cyber sonar settings as an object.');
|
||||
return fail('Provide sonar settings as an object.');
|
||||
}
|
||||
const fields = Object.keys(request);
|
||||
if (!fields.length) return fail('Provide at least one Cyber sonar setting.');
|
||||
if (!fields.length) return fail('Provide at least one sonar setting.');
|
||||
for (const field of fields) {
|
||||
const value = request[field];
|
||||
if (field === 'enabled') {
|
||||
@@ -70,19 +69,14 @@ export function setCyberSonarControls(
|
||||
continue;
|
||||
}
|
||||
if (!Object.hasOwn(SETTING_FIELDS, field)) {
|
||||
return fail('Unknown Cyber sonar setting.');
|
||||
return fail('Unknown sonar setting.');
|
||||
}
|
||||
const [, min, max] = SETTING_FIELDS[field];
|
||||
if (!Number.isInteger(value) || value < min || value > max) {
|
||||
return fail(`${field} must be an integer from ${min} to ${max}.`);
|
||||
}
|
||||
}
|
||||
if (
|
||||
owner.hud?.getVariant?.() !== 'cyber' ||
|
||||
doc?.documentElement?.dataset?.uiTheme !== 'cyber'
|
||||
) {
|
||||
return fail('Cyber sonar controls require the Cyber HUD layout.');
|
||||
}
|
||||
owner.shareLinkManager?.claimRestoreLane?.('visual');
|
||||
for (const [field, [setting]] of Object.entries(SETTING_FIELDS)) {
|
||||
if (Object.hasOwn(request, field)) {
|
||||
owner._setCyberSonarSetting(setting, request[field]);
|
||||
|
||||
@@ -11,9 +11,9 @@ import { StyleManager } from './applicationShell.js';
|
||||
import { VisualSettings } from './visualSettings.js';
|
||||
import { readFileSync } from 'node:fs';
|
||||
|
||||
function fixture(theme = 'cyber') {
|
||||
function fixture(layout = 'tactical') {
|
||||
const root = {
|
||||
dataset: { uiTheme: theme, cyberSonarGpu: 'supported' },
|
||||
dataset: { cyberSonarGpu: 'supported' },
|
||||
style: { setProperty() {} },
|
||||
};
|
||||
const flags = new Set();
|
||||
@@ -27,7 +27,7 @@ function fixture(theme = 'cyber') {
|
||||
};
|
||||
const calls = [];
|
||||
const owner = {
|
||||
hud: { getVariant: () => theme },
|
||||
hud: { getVariant: () => layout },
|
||||
_setCyberSonarSetting(name, value) {
|
||||
calls.push([name, value]);
|
||||
const suffix = name[0].toUpperCase() + name.slice(1);
|
||||
@@ -50,8 +50,15 @@ test('real runner and facade use visual settings, preserve visibility and return
|
||||
visual.services = { governorRequestRender: (reason) => renders.push(reason) };
|
||||
// No Display panel here: the controls' render is not under test.
|
||||
visual._publishDisplay = () => {};
|
||||
// The shell's share sync; a sonar change keeps the link current.
|
||||
const shares = [];
|
||||
visual._syncShareState = () => shares.push(true);
|
||||
const owner = Object.create(StyleManager.prototype);
|
||||
owner._visualSettings = visual;
|
||||
const claims = [];
|
||||
Object.defineProperty(owner, 'shareLinkManager', { value: {
|
||||
claimRestoreLane: (lane) => claims.push({ lane, renders: renders.length }),
|
||||
} });
|
||||
Object.defineProperty(owner, 'hud', { value: f.owner.hud });
|
||||
const viewer = {
|
||||
camera: { moveEnd: { addEventListener() {} } },
|
||||
@@ -65,19 +72,23 @@ test('real runner and facade use visual settings, preserve visibility and return
|
||||
const runner = createGevActionRunner({ styleManager: owner, viewer, dataManager: {} });
|
||||
const result = await runner('set_cyber_sonar', { enabled: false, intensityPct: 73, sectorDeg: 9 });
|
||||
assert.equal(result.ok, true);
|
||||
assert.deepEqual(claims, [{ lane: 'visual', renders: 0 }]);
|
||||
assert.equal(result.sonar.intensityPct, 73);
|
||||
assert.equal(result.sonar.sectorDeg, 9);
|
||||
assert.equal(result.sonar.enabled, false);
|
||||
assert.equal(f.root.dataset.uiTheme, 'cyber');
|
||||
assert.equal(f.owner.hud.getVariant(), 'tactical');
|
||||
assert.equal(f.hudFlags.has('active'), true);
|
||||
assert.equal(renders.length, 3);
|
||||
assert.equal(shares.length, 1);
|
||||
const before = getCyberSonarControlState();
|
||||
const invalid = await runner('set_cyber_sonar', { rings: 6, opacityPct: 0 });
|
||||
assert.equal(invalid.ok, false);
|
||||
assert.deepEqual(claims, [{ lane: 'visual', renders: 0 }], 'invalid requests claim no authority');
|
||||
assert.deepEqual(getCyberSonarControlState(), before);
|
||||
assert.equal(renders.length, 3);
|
||||
const zero = await runner('set_cyber_sonar', { intensityPct: 0 });
|
||||
assert.equal(zero.sonar.intensityPct, 0);
|
||||
assert.deepEqual(claims.map(({ lane }) => lane), ['visual', 'visual']);
|
||||
assert.equal(zero.sonar.enabled, false);
|
||||
const unavailable = createGevActionRunner({ styleManager: {}, viewer, dataManager: {} });
|
||||
assert.equal((await unavailable('set_cyber_sonar', { enabled: true })).ok, false);
|
||||
@@ -136,11 +147,11 @@ test('rejects the whole invalid request before any mutation', () => {
|
||||
}
|
||||
});
|
||||
|
||||
test('requires Cyber and preserves off state and every omitted setting', () => {
|
||||
for (const theme of ['tactical', 'minimal']) {
|
||||
const f = fixture(theme);
|
||||
assert.equal(setCyberSonarControls(f.owner, { enabled: true }, f.doc).ok, false);
|
||||
assert.deepEqual(f.calls, []);
|
||||
test('works under every HUD layout and preserves off state and every omitted setting', () => {
|
||||
for (const layout of ['tactical', 'minimal']) {
|
||||
const f = fixture(layout);
|
||||
assert.equal(setCyberSonarControls(f.owner, { enabled: true }, f.doc).ok, true);
|
||||
assert.deepEqual(f.calls, [['enabled', true]]);
|
||||
}
|
||||
const f = fixture();
|
||||
f.root.dataset.cyberSonar = 'off';
|
||||
|
||||
@@ -1,950 +0,0 @@
|
||||
import {
|
||||
getScopeMaskFeather,
|
||||
getScopeMaskOpacity,
|
||||
isScopeMaskEnabled,
|
||||
setScopeMaskEnabled,
|
||||
setScopeMaskFeather,
|
||||
setScopeMaskOpacity,
|
||||
} from '../scopeMask.js';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import test from 'node:test';
|
||||
import {
|
||||
applyHudUiTheme,
|
||||
CYBER_VISUAL_DEFAULTS,
|
||||
cyberVisualDefaultsForHudTransition,
|
||||
HUD_LAYOUTS,
|
||||
normalizeHudLayout,
|
||||
} from '../hudLayouts.js';
|
||||
import { GEV_ACTION_SCHEMAS } from '../voice/actionSchemas.js';
|
||||
import { createGevActionRunner } from '../voice/gevActions.js';
|
||||
import { StyleManager } from './applicationShell.js';
|
||||
import { createPinia } from 'pinia';
|
||||
import { useDisplayStore } from './stores/display.js';
|
||||
import { VisualSettings } from './visualSettings.js';
|
||||
import { STYLES } from './visualPresets.js';
|
||||
|
||||
test('CCTV and Context keep their headers outside Cyber-only scroll bodies', () => {
|
||||
for (const file of ['panels/CctvPanel.vue', 'ContextView.vue']) {
|
||||
const markup = readFileSync(
|
||||
new URL(`./views/${file}`, import.meta.url),
|
||||
'utf8',
|
||||
);
|
||||
// The body wears the shared scrollbar skin where Cyber makes it scroll.
|
||||
assert.match(
|
||||
markup,
|
||||
/class="cyber-panel-body ui-scroll" data-rail-scroller/,
|
||||
);
|
||||
assert.ok(
|
||||
// The header is RailPanel's; the body is its first content.
|
||||
markup.indexOf('<RailPanel ') > -1 &&
|
||||
markup.indexOf('<RailPanel ') <
|
||||
markup.indexOf('class="cyber-panel-body ui-scroll"'),
|
||||
);
|
||||
}
|
||||
const shared = readFileSync(
|
||||
new URL('./styles/controls.css', import.meta.url),
|
||||
'utf8',
|
||||
);
|
||||
const cyber = readFileSync(
|
||||
new URL('./styles/cyber.css', import.meta.url),
|
||||
'utf8',
|
||||
);
|
||||
assert.match(shared, /\.cyber-panel-body\s*\{\s*display: contents;/);
|
||||
assert.match(
|
||||
cyber,
|
||||
/:root\[data-ui-theme='cyber'\] \.cyber-panel-body\s*\{[^}]*overflow-y: auto;[^}]*overscroll-behavior: contain;/,
|
||||
);
|
||||
});
|
||||
|
||||
function styleOwner(t, initialVariant = 'cyber') {
|
||||
const previous = { document: globalThis.document, window: globalThis.window };
|
||||
const root = { dataset: {} };
|
||||
globalThis.document = { documentElement: root, querySelectorAll: () => [] };
|
||||
globalThis.window = { dispatchEvent() {} };
|
||||
t.after(() => Object.assign(globalThis, previous));
|
||||
let variant = initialVariant;
|
||||
const calls = [];
|
||||
const hud = {
|
||||
getVariant: () => variant,
|
||||
setVariant: (value) => {
|
||||
// Normalize like the real HUD so retired layouts fall back.
|
||||
variant = normalizeHudLayout(value);
|
||||
applyHudUiTheme(root, variant);
|
||||
},
|
||||
setMode: (value) => calls.push(['mode', value]),
|
||||
onStyleChange: (value) => calls.push(['style', value]),
|
||||
};
|
||||
hud.setVariant(initialVariant);
|
||||
const owner = Object.create(VisualSettings.prototype);
|
||||
Object.assign(owner, {
|
||||
activeStyle: 'normal',
|
||||
store: { publish() {} },
|
||||
readHud: () => hud,
|
||||
readShareLinks: () => ({ onStyleChange() {} }),
|
||||
_visualEffects: {
|
||||
stages: Object.fromEntries(
|
||||
Object.entries(STYLES).map(([name, config]) => [
|
||||
name,
|
||||
{ uniforms: { ...config.uniforms, intensity: 0 } },
|
||||
]),
|
||||
),
|
||||
},
|
||||
services: { governorRequestRender() {}, setDetectionStyle() {} },
|
||||
_setBloomEnabled: (value) => calls.push(['bloom', value]),
|
||||
_setSharpenEnabled: (value) => calls.push(['sharpen', value]),
|
||||
_applyDetectionPreset: (value) => calls.push(['detection', value]),
|
||||
_syncShareState: () => calls.push(['share', variant]),
|
||||
});
|
||||
for (const name of [
|
||||
'setCelestialRingEnabled',
|
||||
'_startTransition',
|
||||
'_publishActiveStyle',
|
||||
'_updateSliderPanel',
|
||||
'_updateHudButtonState',
|
||||
'_syncIrBoost',
|
||||
'_syncCockpitInheritedStyle',
|
||||
'_syncCyberSonarControl',
|
||||
'_scheduleAdaptivePanelLayout',
|
||||
'_setDetectionFade',
|
||||
// Intensities: the fixture has no post-process stages to drive.
|
||||
'_setBloomIntensity',
|
||||
'_setSharpenIntensity',
|
||||
])
|
||||
owner[name] = () => {};
|
||||
return { owner, hud, root, calls };
|
||||
}
|
||||
|
||||
test('visual styles retain Cyber through real preset application without dropping other defaults', (t) => {
|
||||
const { owner, hud, root, calls } = styleOwner(t);
|
||||
for (const style of [
|
||||
'surveillance',
|
||||
'normal',
|
||||
'noir',
|
||||
'anime',
|
||||
'thermal',
|
||||
'retro',
|
||||
]) {
|
||||
owner.setStyle(style);
|
||||
assert.equal(owner.activeStyle, style);
|
||||
assert.equal(hud.getVariant(), 'cyber');
|
||||
assert.equal(root.dataset.uiTheme, 'cyber');
|
||||
assert.deepEqual(calls.at(-1), ['share', 'cyber']);
|
||||
}
|
||||
assert.equal(owner.stages.thermal.uniforms.sensitivity, 0.85);
|
||||
assert.equal(calls.filter(([name]) => name === 'detection').length, 3);
|
||||
assert.equal(
|
||||
calls.filter(([name, value]) => name === 'bloom' && value === false).length,
|
||||
3,
|
||||
);
|
||||
assert.equal(
|
||||
calls.filter(([name, value]) => name === 'sharpen' && value === true)
|
||||
.length,
|
||||
3,
|
||||
);
|
||||
});
|
||||
|
||||
test('non-Cyber style presets and explicit HUD choices remain authoritative', (t) => {
|
||||
const { owner, hud, root } = styleOwner(t);
|
||||
for (const variant of ['tactical', 'minimal']) {
|
||||
owner._setHudVariant(variant);
|
||||
assert.equal(hud.getVariant(), variant);
|
||||
assert.equal(root.dataset.uiTheme, undefined);
|
||||
owner.setStyle('normal');
|
||||
owner.setStyle('surveillance');
|
||||
assert.equal(hud.getVariant(), 'tactical');
|
||||
}
|
||||
});
|
||||
|
||||
test('leaving Cyber without a preset choice restores the prior visual preset', (t) => {
|
||||
const { owner, hud } = styleOwner(t, 'tactical');
|
||||
owner.setStyle('noir');
|
||||
|
||||
owner._setHudVariant('cyber', { applyVisualDefaults: true });
|
||||
assert.equal(owner.activeStyle, 'thermal');
|
||||
assert.equal(owner._preCyberStyle, 'noir');
|
||||
assert.equal(owner._cyberStyleUserSelected, false);
|
||||
|
||||
owner._setHudVariant('minimal', { applyVisualDefaults: true });
|
||||
assert.equal(hud.getVariant(), 'minimal');
|
||||
assert.equal(owner.activeStyle, 'noir');
|
||||
assert.equal(owner._preCyberStyle, null);
|
||||
assert.equal(owner._cyberStyleUserSelected, false);
|
||||
});
|
||||
|
||||
test('a preset explicitly selected in Cyber survives exit and resets for re-entry', (t) => {
|
||||
const { owner, hud } = styleOwner(t, 'tactical');
|
||||
owner.setStyle('noir');
|
||||
|
||||
owner._setHudVariant('cyber', { applyVisualDefaults: true });
|
||||
owner.setStyle('anime', { userInitiated: true });
|
||||
assert.equal(owner.activeStyle, 'anime');
|
||||
assert.equal(owner._preCyberStyle, 'noir');
|
||||
assert.equal(owner._cyberStyleUserSelected, true);
|
||||
|
||||
// Reselecting the active mode must not erase the user's preset intent.
|
||||
owner._setHudVariant('cyber', { applyVisualDefaults: true });
|
||||
assert.equal(owner._preCyberStyle, 'noir');
|
||||
owner._setHudVariant('minimal', { applyVisualDefaults: true });
|
||||
assert.equal(hud.getVariant(), 'minimal');
|
||||
assert.equal(owner.activeStyle, 'anime');
|
||||
assert.equal(owner._preCyberStyle, null);
|
||||
assert.equal(owner._cyberStyleUserSelected, false);
|
||||
|
||||
// A later untouched Cyber round trip restores the new pre-Cyber preset.
|
||||
owner._setHudVariant('cyber', { applyVisualDefaults: true });
|
||||
assert.equal(owner.activeStyle, 'thermal');
|
||||
assert.equal(owner._preCyberStyle, 'anime');
|
||||
owner._setHudVariant('minimal', { applyVisualDefaults: true });
|
||||
assert.equal(owner.activeStyle, 'anime');
|
||||
});
|
||||
|
||||
test('an explicit same-value FLIR choice is preserved on Cyber exit', (t) => {
|
||||
const { owner } = styleOwner(t, 'tactical');
|
||||
owner.setStyle('noir');
|
||||
owner._setHudVariant('cyber', { applyVisualDefaults: true });
|
||||
|
||||
owner.setStyle('thermal', { userInitiated: true });
|
||||
assert.equal(owner.activeStyle, 'thermal');
|
||||
assert.equal(owner._cyberStyleUserSelected, true);
|
||||
owner._setHudVariant('minimal', { applyVisualDefaults: true });
|
||||
assert.equal(owner.activeStyle, 'thermal');
|
||||
});
|
||||
|
||||
test('an authoritative same-Cyber reset clears local preset ownership', (t) => {
|
||||
const { owner } = styleOwner(t, 'tactical');
|
||||
owner.setStyle('noir');
|
||||
owner._setHudVariant('cyber', { applyVisualDefaults: true });
|
||||
owner.setStyle('anime', { userInitiated: true });
|
||||
assert.equal(owner._cyberStyleUserSelected, true);
|
||||
|
||||
owner._setHudVariant('cyber');
|
||||
assert.equal(owner.activeStyle, 'anime');
|
||||
assert.equal(owner._preCyberStyle, null);
|
||||
assert.equal(owner._cyberStyleUserSelected, false);
|
||||
owner._setHudVariant('minimal', { applyVisualDefaults: true });
|
||||
assert.equal(owner.activeStyle, 'anime');
|
||||
});
|
||||
|
||||
test('Display and voice HUD routes preserve explicit Cyber entry and exit authority', async (t) => {
|
||||
const makeOwner = () => {
|
||||
const { owner, hud } = styleOwner(t, 'tactical');
|
||||
owner.setStyle('noir');
|
||||
owner.setHudLayout = (...args) =>
|
||||
StyleManager.prototype.setHudLayout.call(owner, ...args);
|
||||
owner.getControlState = () => ({
|
||||
hud: { layout: hud.getVariant(), visible: true },
|
||||
});
|
||||
return { owner, hud };
|
||||
};
|
||||
|
||||
const display = makeOwner();
|
||||
// The Display panel's layout select and the dock's style buttons call
|
||||
// these actions through the display store.
|
||||
const store = useDisplayStore(createPinia());
|
||||
const token = store.connect({
|
||||
setHudLayout: (value) => display.owner.setHudLayout(value),
|
||||
setStyle: (value) => display.owner.setStyle(value, { userInitiated: true }),
|
||||
});
|
||||
store.act('setHudLayout', 'cyber');
|
||||
assert.equal(display.hud.getVariant(), 'cyber');
|
||||
assert.equal(display.owner.activeStyle, 'thermal');
|
||||
store.act('setStyle', 'anime');
|
||||
assert.equal(display.owner.activeStyle, 'anime');
|
||||
store.act('setHudLayout', 'minimal');
|
||||
assert.equal(display.hud.getVariant(), 'minimal');
|
||||
assert.equal(display.owner.activeStyle, 'anime');
|
||||
store.detach(token);
|
||||
|
||||
const voice = makeOwner();
|
||||
const eventSource = { addEventListener() {}, removeEventListener() {} };
|
||||
const viewer = {
|
||||
camera: { moveEnd: { addEventListener() {} } },
|
||||
clock: { onTick: { addEventListener: () => () => {} } },
|
||||
canvas: eventSource,
|
||||
scene: { canvas: eventSource },
|
||||
};
|
||||
const runVoiceAction = createGevActionRunner({
|
||||
viewer,
|
||||
styleManager: voice.owner,
|
||||
dataManager: {},
|
||||
});
|
||||
const entered = await runVoiceAction('set_hud', { layout: 'cyber' });
|
||||
assert.equal(entered.ok, true);
|
||||
assert.equal(voice.hud.getVariant(), 'cyber');
|
||||
assert.equal(voice.owner.activeStyle, 'thermal');
|
||||
const selected = await runVoiceAction('set_visual_style', { style: 'anime' });
|
||||
assert.equal(selected.ok, true);
|
||||
assert.equal(voice.owner.activeStyle, 'anime');
|
||||
const exited = await runVoiceAction('set_hud', { layout: 'minimal' });
|
||||
assert.equal(exited.ok, true);
|
||||
assert.equal(voice.hud.getVariant(), 'minimal');
|
||||
assert.equal(voice.owner.activeStyle, 'anime');
|
||||
});
|
||||
|
||||
test('scope choice and expanded feather survive every HUD layout and both restore paths', async (t) => {
|
||||
const { owner } = styleOwner(t, 'tactical');
|
||||
const previous = { enabled: isScopeMaskEnabled(), feather: getScopeMaskFeather() };
|
||||
t.after(() => { setScopeMaskEnabled(previous.enabled); setScopeMaskFeather(previous.feather); });
|
||||
Object.assign(owner.services, { setScopeMaskEnabled, setScopeMaskFeather });
|
||||
let shown = null;
|
||||
owner.store = { publish: (view) => (shown = view.scope) };
|
||||
await owner.restoreShareState({ scopeEnabled: false, scopeFeatherPct: 200 });
|
||||
assert.deepEqual(shown, { enabled: false, featherPct: 200, opacityPct: 100 });
|
||||
for (const layout of ['minimal', 'cyber', 'tactical']) {
|
||||
owner._setHudVariant(layout, { applyVisualDefaults: true });
|
||||
assert.equal(isScopeMaskEnabled(), false, layout);
|
||||
assert.equal(getScopeMaskFeather(), 2, layout);
|
||||
assert.equal(shown.enabled, false, layout);
|
||||
}
|
||||
await owner.applyVisualState({ scope: { enabled: true, featherPct: 175 } });
|
||||
assert.equal(isScopeMaskEnabled(), true);
|
||||
assert.equal(getScopeMaskFeather(), 1.75);
|
||||
assert.deepEqual(shown, { enabled: true, featherPct: 175, opacityPct: 100 });
|
||||
await owner.applyVisualState({ scope: { featherPct: 500 } });
|
||||
assert.equal(getScopeMaskFeather(), 2);
|
||||
assert.deepEqual(shown, { enabled: true, featherPct: 200, opacityPct: 100 });
|
||||
});
|
||||
|
||||
test('a shared scope opacity is restored and rides in the next share state', async (t) => {
|
||||
const { owner } = styleOwner(t, 'tactical');
|
||||
const previous = getScopeMaskOpacity();
|
||||
t.after(() => setScopeMaskOpacity(previous));
|
||||
Object.assign(owner.services, {
|
||||
setScopeMaskEnabled() {},
|
||||
setScopeMaskFeather() {},
|
||||
setScopeMaskOpacity,
|
||||
});
|
||||
let shown = null;
|
||||
owner.store = { publish: (view) => (shown = view.scope) };
|
||||
await owner.restoreShareState({ scopeOpacityPct: 60 });
|
||||
assert.equal(getScopeMaskOpacity(), 0.6);
|
||||
assert.equal(shown.opacityPct, 60);
|
||||
// A state without it leaves the opacity alone.
|
||||
await owner.restoreShareState({ scopeFeatherPct: 80 });
|
||||
assert.equal(getScopeMaskOpacity(), 0.6);
|
||||
assert.equal(shown.opacityPct, 60);
|
||||
Object.assign(owner.services, {
|
||||
getDetectionTuning: () => ({ allocationStrategy: 'ELASTIC' }),
|
||||
getDetectionMode: () => 'OFF',
|
||||
isScopeMaskEnabled: () => true,
|
||||
getScopeMaskFeather: () => 0.8,
|
||||
getScopeMaskOpacity,
|
||||
getScopeTerminusOverride: () => null,
|
||||
});
|
||||
owner.readCelestialRing = () => null;
|
||||
assert.equal(owner._readShareState().options.scopeOpacityPct, 60);
|
||||
// A link asking for less than the floor opens at the floor, and says so.
|
||||
await owner.restoreShareState({ scopeOpacityPct: 20 });
|
||||
assert.equal(getScopeMaskOpacity(), 0.5);
|
||||
assert.equal(owner._readShareState().options.scopeOpacityPct, 50);
|
||||
});
|
||||
|
||||
test('a scene shot saved with the retired Snow style plays on Normal', async (t) => {
|
||||
const { owner } = styleOwner(t, 'tactical');
|
||||
owner.setStyle('noir');
|
||||
await owner.applyVisualState({ style: 'snow' });
|
||||
assert.equal(owner.activeStyle, 'normal');
|
||||
});
|
||||
|
||||
test('scene and share HUD transitions do not restore a local pre-Cyber preset', async (t) => {
|
||||
const { owner, hud } = styleOwner(t, 'tactical');
|
||||
owner.setStyle('noir');
|
||||
owner._setHudVariant('cyber', { applyVisualDefaults: true });
|
||||
owner.setStyle('anime', { userInitiated: true });
|
||||
assert.equal(owner._cyberStyleUserSelected, true);
|
||||
|
||||
await owner.applyVisualState({ style: 'retro', hud: { variant: 'cyber' } });
|
||||
assert.equal(hud.getVariant(), 'cyber');
|
||||
assert.equal(owner.activeStyle, 'retro');
|
||||
assert.equal(owner._preCyberStyle, null);
|
||||
assert.equal(owner._cyberStyleUserSelected, false);
|
||||
owner._setHudVariant('minimal', { applyVisualDefaults: true });
|
||||
assert.equal(owner.activeStyle, 'retro');
|
||||
|
||||
owner.setStyle('surveillance');
|
||||
owner._setHudVariant('cyber', { applyVisualDefaults: true });
|
||||
assert.equal(owner._preCyberStyle, 'surveillance');
|
||||
owner.setStyle('anime', { userInitiated: true });
|
||||
await owner.restoreShareState({
|
||||
style: 'thermal',
|
||||
hudVariant: 'cyber',
|
||||
});
|
||||
assert.equal(hud.getVariant(), 'cyber');
|
||||
assert.equal(owner.activeStyle, 'thermal');
|
||||
assert.equal(owner._preCyberStyle, null);
|
||||
assert.equal(owner._cyberStyleUserSelected, false);
|
||||
owner._setHudVariant('tactical', { applyVisualDefaults: true });
|
||||
assert.equal(owner.activeStyle, 'thermal');
|
||||
assert.equal(owner._preCyberStyle, null);
|
||||
});
|
||||
|
||||
test('scene and share restoration override Cyber and preserve restored Cyber parameters', async (t) => {
|
||||
const { owner, hud } = styleOwner(t);
|
||||
await owner.applyVisualState({ style: 'retro', hud: { variant: 'minimal' } });
|
||||
assert.equal(hud.getVariant(), 'minimal');
|
||||
owner._setHudVariant('cyber');
|
||||
await owner.restoreShareState({
|
||||
style: 'surveillance',
|
||||
hudVariant: 'operator',
|
||||
});
|
||||
// A link saved with the retired Operator layout restores as Tactical.
|
||||
assert.equal(hud.getVariant(), 'tactical');
|
||||
await owner.restoreShareState({
|
||||
style: 'thermal',
|
||||
hudVariant: 'cyber',
|
||||
styleParams: { palette: 0.73 },
|
||||
});
|
||||
assert.equal(hud.getVariant(), 'cyber');
|
||||
assert.equal(owner.activeStyle, 'thermal');
|
||||
assert.equal(owner.stages.thermal.uniforms.palette, 0.73);
|
||||
owner._setHudVariant('cyber', { applyVisualDefaults: true });
|
||||
assert.equal(owner.stages.thermal.uniforms.palette, 0.73);
|
||||
owner._setHudVariant('tactical');
|
||||
owner._setHudVariant('cyber', { applyVisualDefaults: true });
|
||||
assert.equal(owner.stages.thermal.uniforms.palette, 0.42);
|
||||
});
|
||||
|
||||
const read = (relative) =>
|
||||
readFileSync(new URL(relative, import.meta.url), 'utf8');
|
||||
|
||||
test('Cyber setup uses a compact toolbar icon and highlights the north-up letter', () => {
|
||||
const css = read('./styles/cyber.css');
|
||||
assert.match(
|
||||
css,
|
||||
/#top-center-actions #key-setup-chip\s*\{[^}]*inset: auto;[^}]*width: 36px;/,
|
||||
);
|
||||
assert.match(css, /#key-setup-chip\[hidden\]\s*\{\s*display: none;/);
|
||||
assert.match(
|
||||
css,
|
||||
/#north-up-view\[data-north-up='true'\]\s+\.camera-compass-n\s*\{[^}]*color: var\(--cyber-red-bright\)/,
|
||||
);
|
||||
});
|
||||
const cyberStyles = read('./styles/cyber.css');
|
||||
|
||||
// Source guards supplement rendered popup/hit-target checks. Inspect one rule
|
||||
// at a time so a safe declaration on a child cannot excuse a clipped ancestor.
|
||||
function cssRuleBody(styles, selector) {
|
||||
const match = styles.match(new RegExp(`${selector.source}\\s*\\{([^}]+)\\}`));
|
||||
assert.ok(match, `Missing CSS rule: ${selector.source}`);
|
||||
return match[1];
|
||||
}
|
||||
|
||||
test('Cyber Voice clips its decoration without clipping descendant help and errors', () => {
|
||||
const owner = cssRuleBody(
|
||||
cyberStyles,
|
||||
/:root\[data-ui-theme='cyber'\] #command-dock > #gev-voice-control/,
|
||||
);
|
||||
assert.match(owner, /isolation:\s*isolate;/);
|
||||
assert.match(owner, /overflow:\s*visible;/);
|
||||
assert.match(owner, /clip-path:\s*none;/);
|
||||
|
||||
const decoration = cssRuleBody(
|
||||
cyberStyles,
|
||||
/:root\[data-ui-theme='cyber'\] #command-dock > #gev-voice-control::before/,
|
||||
);
|
||||
assert.match(decoration, /clip-path:\s*polygon\(/);
|
||||
assert.match(decoration, /pointer-events:\s*none;/);
|
||||
assert.match(decoration, /inset:\s*0;/);
|
||||
assert.match(decoration, /z-index:\s*-1;/);
|
||||
});
|
||||
|
||||
test('Cyber dock pins escape the tray mask and its decoration overrides the legacy arrow geometry', () => {
|
||||
const owner = cssRuleBody(
|
||||
cyberStyles,
|
||||
/:root\[data-ui-theme='cyber'\] #command-dock \.dock-popover-content/,
|
||||
);
|
||||
assert.match(owner, /clip-path:\s*none;/);
|
||||
assert.match(owner, /isolation:\s*isolate;/);
|
||||
|
||||
// Including the tray owners beats #control-panel's more specific old
|
||||
// ::after arrow positioning. Otherwise left:auto can collapse the frame.
|
||||
const decoration = cssRuleBody(
|
||||
cyberStyles,
|
||||
/:root\[data-ui-theme='cyber'\]\s+#command-dock\s+:is\(#location-bar, #control-panel\)\s+\.dock-popover-content::after/,
|
||||
);
|
||||
assert.match(decoration, /inset:\s*0;/);
|
||||
assert.match(decoration, /width:\s*auto;/);
|
||||
assert.match(decoration, /height:\s*auto;/);
|
||||
assert.match(decoration, /transform:\s*none;/);
|
||||
assert.match(decoration, /clip-path:\s*var\(--cyber-panel-frame\);/);
|
||||
assert.match(decoration, /pointer-events:\s*none;/);
|
||||
});
|
||||
|
||||
test('Cyber lower-left telemetry tracks the credit anchor with clearance for its logo row', () => {
|
||||
const telemetry = cssRuleBody(
|
||||
cyberStyles,
|
||||
/#intel-hud\[data-variant='cyber'\] \.hud-bottom-left/,
|
||||
);
|
||||
const offset = telemetry.match(/bottom:\s*calc\(2vh \+ ([\d.]+)rem \+ var\(--world-timeline-lift, 0px\)\);/);
|
||||
assert.ok(offset, 'telemetry must retain the attribution viewport anchor');
|
||||
const credits = read('./styles/command-dock-trays.css');
|
||||
const creditOffsets = [
|
||||
...credits.matchAll(
|
||||
/#cesium-credits\s*\{[^}]*bottom:\s*calc\(2vh \+ ([\d.]+)rem \+ var\(--world-timeline-lift, 0px\)\);/g,
|
||||
),
|
||||
];
|
||||
assert.ok(creditOffsets.length > 0);
|
||||
for (const credit of creditOffsets) {
|
||||
assert.ok(
|
||||
Number(offset[1]) - Number(credit[1]) >= 2.75,
|
||||
'reserve the 28px logo row, baseline descent and 12px clearance at the 16px root size',
|
||||
);
|
||||
}
|
||||
assert.doesNotMatch(cyberStyles, /\.hud-bottom-left\s*\{\s*bottom:\s*60px;/);
|
||||
});
|
||||
|
||||
test('shared panel hooks affect only opted-in rail surfaces without overriding disclosure and concealment', () => {
|
||||
const styles = read('./styles/panel-surfaces.css');
|
||||
const rail = cssRuleBody(
|
||||
styles,
|
||||
/:is\(#left-panel-stack, #right-context-rail\)\s+> \[data-panel-id\]:has\(> \[data-panel-surface\]\)/,
|
||||
);
|
||||
assert.match(rail, /pointer-events:\s*auto;/);
|
||||
assert.doesNotMatch(rail, /(?:display|visibility):/);
|
||||
assert.doesNotMatch(
|
||||
styles,
|
||||
/:is\(#left-panel-stack, #right-context-rail\)\s*> \[data-panel-id\]\s*\{/,
|
||||
);
|
||||
assert.match(
|
||||
styles,
|
||||
/\[data-panel-surface\]:not\(\[hidden\]\):not\(dialog:not\(\[open\]\)\)\s*\{\s*display: flex;/,
|
||||
);
|
||||
assert.match(
|
||||
styles,
|
||||
/dialog\[data-panel-surface\]:not\(\[open\]\)\s*\{\s*display: none !important;/,
|
||||
);
|
||||
assert.match(
|
||||
styles,
|
||||
/body:is\(\.ui-clean-view, \.recording-mode\)[^{]+\{[^}]*visibility: hidden !important;[^}]*pointer-events: none !important;/,
|
||||
);
|
||||
});
|
||||
|
||||
test('Cyber clipped expand controls retain an inset keyboard-focus outline in map and cockpit', () => {
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/:root\[data-ui-theme='cyber'\]\s+:is\(\s*\.panel-collapse-btn,\s*body\.cockpit-mode \.cockpit-utility-glyph\s*\):focus-visible\s*\{[^}]*outline: 2px solid var\(--cyber-red-bright\) !important;[^}]*outline-offset: -3px;[^}]*box-shadow: none;/,
|
||||
);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/:root\[data-ui-theme='cyber'\]\s+:is\(\.panel-collapse-btn, body\.cockpit-mode \.cockpit-utility-glyph\):is\(\s*:hover,\s*:focus-visible\s*\)\s*\{[^}]*border-color: var\(--cyber-red-bright\);/,
|
||||
);
|
||||
});
|
||||
|
||||
test('Cyber Radio retains upstream nested Context ownership', () => {
|
||||
assert.doesNotMatch(cyberStyles, /#right-context-rail\s*>\s*#radio-panel/);
|
||||
});
|
||||
|
||||
test('Cyber cockpit launchers share Data Layers frame and expand-control treatment', () => {
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/:is\(\.panel-collapse-btn, body\.cockpit-mode \.cockpit-utility-glyph\)/,
|
||||
);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/body\.cockpit-mode \.cockpit-utility-launcher \{[^}]*width: var\(--cyber-panel-width\);[^}]*min-height: 60px;[^}]*clip-path: var\(--cyber-panel-frame\);/,
|
||||
);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/\.cockpit-utility-glyph::after \{\s*content: '\+';/,
|
||||
);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/\.cockpit-utility-glyph\[aria-expanded='true'\]::after \{\s*content: '−';/,
|
||||
);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/\.cockpit-utility-control\.is-expanded\s+\.cockpit-utility-launcher \{[^}]*width: 100%;[^}]*clip-path: none;/,
|
||||
);
|
||||
});
|
||||
|
||||
test('Cyber side panels share one width and one framed surface material', () => {
|
||||
assert.match(cyberStyles, /--cyber-panel-width: 272px;/);
|
||||
assert.match(cyberStyles, /--cyber-right-panel-width: 312px;/);
|
||||
assert.match(cyberStyles, /--cyber-panel-collapsed-width: 200px;/);
|
||||
assert.match(cyberStyles, /--cyber-panel-control-size: 30px;/);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/--cyber-panel-surface: rgba\(18, 24, 27, 0\.92\);/,
|
||||
);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/\.cockpit-utility-control\.is-expanded \{[\s\S]*?width: var\(--cyber-right-panel-width\);[\s\S]*?background-color: var\(--cyber-panel-surface\);[\s\S]*?background-image: var\(--cyber-panel-surface-detail\);[\s\S]*?clip-path: var\(--cyber-panel-frame\);/,
|
||||
);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/\.cockpit-utility-control\.is-expanded::after \{[\s\S]*?width: 36px;[\s\S]*?border-top: 1px solid rgba\(225, 102, 102, 0\.84\);/,
|
||||
);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/#global-context-panel #radio-panel\.collapsed \{\s*width: 100%;/,
|
||||
);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/#left-panel-stack\s*> :is\(#data-panel, #utilities-panel, #scene-panel\)\.collapsed \{\s*width: var\(--cyber-panel-collapsed-width\);/,
|
||||
);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/:is\(#data-panel, #utilities-panel, #scene-panel\)\.collapsed\s+:is\(\.data-panel-inner, \.utilities-panel-inner, \.scene-panel-inner\) \{[\s\S]*?height: 50px;[\s\S]*?min-height: 50px;/,
|
||||
);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/\.cockpit-utility-control:not\(\.is-expanded\)\s+\.cockpit-utility-launcher \{\s*width: var\(--cyber-panel-collapsed-width\);/,
|
||||
);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/#pp-toggles\s*> \.pp-header-row\s+\.pp-collapse-btn \{[\s\S]*?width: var\(--cyber-panel-control-size\);[\s\S]*?height: var\(--cyber-panel-control-size\);/,
|
||||
);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/#right-context-rail\s+:is\(\s*\.cctv-panel-inner,\s*\.weather-panel-inner,\s*\.recent-imagery-panel-inner,\s*\.street-level-panel-inner,\s*\.global-context-panel-inner\s*\) \{\s*padding-inline-end: 8px;/,
|
||||
);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/#right-context-rail[\s\S]*?:is\(\s*#cctv-panel,\s*#weather-panel,\s*#recent-imagery-panel,\s*#street-level-panel,\s*#global-context-panel\s*\)\.collapsed[\s\S]*?> \.panel-header \{[\s\S]*?height: 48px;[\s\S]*?padding: 0 10px 0 14px;/,
|
||||
);
|
||||
assert.doesNotMatch(
|
||||
cyberStyles,
|
||||
/\.cockpit-utility-control\.is-expanded\s*\{[^}]*order:/,
|
||||
'expanded Cockpit utilities must retain Display-then-Radio DOM order',
|
||||
);
|
||||
});
|
||||
|
||||
test('Cyber is a canonical HUD layout with a safe Tactical fallback', () => {
|
||||
assert.deepEqual(HUD_LAYOUTS, ['tactical', 'minimal', 'cyber']);
|
||||
assert.equal(normalizeHudLayout('CYBER'), 'cyber');
|
||||
assert.equal(normalizeHudLayout('operator'), 'tactical');
|
||||
assert.equal(normalizeHudLayout('unknown'), 'tactical');
|
||||
});
|
||||
|
||||
test('the Cyber HUD owns the global shell skin and leaving it restores defaults', () => {
|
||||
const root = { dataset: { unrelated: 'preserved' } };
|
||||
assert.equal(applyHudUiTheme(root, 'cyber'), 'cyber');
|
||||
assert.equal(root.dataset.uiTheme, 'cyber');
|
||||
assert.equal(applyHudUiTheme(root, 'minimal'), null);
|
||||
assert.equal(root.dataset.uiTheme, undefined);
|
||||
assert.equal(root.dataset.unrelated, 'preserved');
|
||||
});
|
||||
|
||||
test('an explicit transition into Cyber selects FLIR with Ironbow 0.42 once', () => {
|
||||
assert.deepEqual(CYBER_VISUAL_DEFAULTS, {
|
||||
style: 'thermal',
|
||||
ironbow: 0.42,
|
||||
});
|
||||
assert.equal(
|
||||
cyberVisualDefaultsForHudTransition('tactical', 'cyber', {
|
||||
explicit: true,
|
||||
}),
|
||||
CYBER_VISUAL_DEFAULTS,
|
||||
);
|
||||
assert.equal(
|
||||
cyberVisualDefaultsForHudTransition('cyber', 'cyber', {
|
||||
explicit: true,
|
||||
}),
|
||||
null,
|
||||
);
|
||||
assert.equal(cyberVisualDefaultsForHudTransition('tactical', 'cyber'), null);
|
||||
assert.equal(
|
||||
cyberVisualDefaultsForHudTransition('cyber', 'minimal', {
|
||||
explicit: true,
|
||||
}),
|
||||
null,
|
||||
);
|
||||
});
|
||||
|
||||
test('Cyber visual defaults update the style, thermal palette and render state', () => {
|
||||
const calls = [];
|
||||
const owner = {
|
||||
stages: { thermal: { uniforms: { palette: 0 } } },
|
||||
services: {
|
||||
governorRequestRender: (reason) => calls.push(['render', reason]),
|
||||
},
|
||||
setStyle: (style, options) => calls.push(['style', style, options]),
|
||||
_updateSliderPanel: (style, options) =>
|
||||
calls.push(['sliders', style, options]),
|
||||
};
|
||||
|
||||
VisualSettings.prototype._applyCyberVisualDefaults.call(
|
||||
owner,
|
||||
CYBER_VISUAL_DEFAULTS,
|
||||
);
|
||||
|
||||
assert.equal(owner.stages.thermal.uniforms.palette, 0.42);
|
||||
assert.deepEqual(calls, [
|
||||
[
|
||||
'style',
|
||||
'thermal',
|
||||
{
|
||||
applyPreset: false,
|
||||
revealParameters: false,
|
||||
preserveCyberRestore: true,
|
||||
},
|
||||
],
|
||||
['sliders', 'thermal', { reveal: false }],
|
||||
['render', 'cyber-visual-defaults'],
|
||||
]);
|
||||
});
|
||||
|
||||
test('the Display selector, voice schema and final stylesheet expose Cyber', () => {
|
||||
const display = read('./views/panels/DisplayPanel.vue');
|
||||
const stylesheet = read('../../style.css');
|
||||
const rightRail = read('./rightPanelRail.js');
|
||||
const hud = read('../hud.js');
|
||||
const hudView = read('./views/IntelHudView.vue');
|
||||
const detection = read('../data/detection.js');
|
||||
const aircraftModels = read('../data/aircraftModelLayer.js');
|
||||
const setHud = GEV_ACTION_SCHEMAS.find((schema) => schema.name === 'set_hud');
|
||||
|
||||
assert.match(display, /<option value="cyber">\{\{ t\('Cyber'\) \}\}<\/option>/);
|
||||
assert.match(display, /id="cyber-sonar-toggle"/);
|
||||
assert.match(
|
||||
display,
|
||||
/id="cyber-sonar-opacity"[^>]*:model-value="sonar\?\.opacity \?\? 84" :aria-label="t\('Cyber contact and label opacity'\)"/,
|
||||
);
|
||||
assert.match(display, /id="cyber-sonar-sector"/);
|
||||
assert.deepEqual(setHud.parameters.properties.layout.enum, HUD_LAYOUTS);
|
||||
assert.match(stylesheet, /@import '\.\/src\/ui\/styles\/cyber\.css';\s*$/);
|
||||
assert.match(cyberStyles, /:root\[data-ui-theme='cyber'\]/);
|
||||
assert.match(cyberStyles, /\.material-symbols-outlined/);
|
||||
assert.match(cyberStyles, /\.pp-label/);
|
||||
assert.match(cyberStyles, /#intel-hud\[data-variant='cyber'\]/);
|
||||
assert.match(cyberStyles, /#left-panel-stack/);
|
||||
assert.match(cyberStyles, /#right-context-rail/);
|
||||
assert.match(cyberStyles, /#command-dock/);
|
||||
assert.match(cyberStyles, /--cyber-panel-frame: polygon/);
|
||||
assert.match(cyberStyles, /\.data-panel-inner,/);
|
||||
assert.match(cyberStyles, /#pp-toggles\.collapsed > \.pp-header-row/);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/\.panel-collapsible:not\(#location-bar\):not\(#control-panel\)::after/,
|
||||
);
|
||||
assert.match(cyberStyles, /clip-path: var\(--cyber-panel-frame\);/);
|
||||
assert.match(hudView, /class="hud-sonar" aria-hidden="true"/);
|
||||
assert.match(cyberStyles, /\.hud-sonar::before/);
|
||||
assert.match(cyberStyles, /\.hud-sonar::after/);
|
||||
assert.match(cyberStyles, /@keyframes cyber-sonar-sweep/);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/animation-delay:\s*var\(--cyber-sonar-phase-delay, 0ms\)/,
|
||||
);
|
||||
assert.doesNotMatch(cyberStyles, /--cyber-sonar-angle/);
|
||||
assert.match(cyberStyles, /prefers-reduced-motion: reduce/);
|
||||
assert.match(detection, /candidate\.sonarFactor \?\? 1/);
|
||||
assert.match(detection, /sonarActive && !obj\.skipLabel/);
|
||||
assert.match(detection, /const bracketAlpha = admissionAlpha \* sonarFactor/);
|
||||
assert.match(detection, /sonarSampler\.label\(sonarFactor\)/);
|
||||
assert.match(detection, /createCyberSonarSampler\(width, height, now\)/);
|
||||
assert.match(cyberStyles, /data-cyber-sonar='off'/);
|
||||
assert.match(detection, /governorRequestRender\('cyber-sonar-cadence'\)/);
|
||||
assert.match(
|
||||
detection,
|
||||
/const animatingCount = countAnimatingRenderEntries\(renderEntries\);/,
|
||||
);
|
||||
assert.doesNotMatch(detection, /sonarActive \? 1 : 0/);
|
||||
assert.match(
|
||||
aircraftModels,
|
||||
/alpha: state\._irBoost\s*\?\s*1\s*:\s*aircraftTreatmentAlpha\(/,
|
||||
);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/#title-bar \.title-logo #globe \{[\s\S]*?fill: var\(--cyber-red\);[\s\S]*?stroke: var\(--cyber-red-bright\);/,
|
||||
);
|
||||
assert.match(cyberStyles, /#title-bar \.title-logo #globe_cage/);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/#top-center-actions button\s*\{[\s\S]*?border-radius:\s*0;[\s\S]*?clip-path:\s*polygon\(\s*29% 0,\s*71% 0,[\s\S]*?0 29%\s*\);/,
|
||||
);
|
||||
assert.match(cyberStyles, /#top-center-actions button::before/);
|
||||
assert.match(cyberStyles, /\.hud-top-left/);
|
||||
assert.match(cyberStyles, /transparent 0 min\(40vw, 52vh\)/);
|
||||
assert.match(cyberStyles, /\.hud-bottom-bar \{\s*display: none;/);
|
||||
assert.doesNotMatch(cyberStyles, /\.hud-top-bar/);
|
||||
// Cyber shares the measured rail/credit keep-out rather than overriding it.
|
||||
assert.doesNotMatch(
|
||||
cyberStyles,
|
||||
/#right-context-rail\s*\{[^}]*\b(?:top|bottom|height|max-height):/,
|
||||
);
|
||||
assert.match(cyberStyles, /--cyber-hud-card-top: max\(100px, 10\.25vh\);/);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/--cyber-left-rail-top: max\([\s\S]*?220px,[\s\S]*?calc\(var\(--cyber-hud-card-top\) \+ 120px\)/,
|
||||
);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/\.hud-top-left \{[\s\S]*?top: var\(--cyber-hud-card-top\);/,
|
||||
);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/#left-panel-stack \{[\s\S]*?top: var\(--cyber-left-rail-top\) !important;[\s\S]*?bottom: calc\(2vh \+ 13rem \+ var\(--world-timeline-lift, 0px\)\);/,
|
||||
);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/\.hud-left-edge \{\s*top: calc\(var\(--cyber-left-rail-top\) - 18px\);\s*left: 14px;/,
|
||||
);
|
||||
assert.match(
|
||||
rightRail,
|
||||
/const leftStackTop = settledLeftRailTop\([\s\S]*?const alignedTop = Number\.isFinite\(leftStackTop\)[\s\S]*?baseTop: alignedTop,/,
|
||||
);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/--right-display-collapsed-width: var\(--cyber-panel-collapsed-width\);/,
|
||||
);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/clip-path: polygon\([\s\S]*?12px 0,[\s\S]*?0 12px/,
|
||||
);
|
||||
assert.match(cyberStyles, /\.hud-corner::before/);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/--cyber-telemetry-fill: rgba\(13, 20, 23, 0\.985\);/,
|
||||
);
|
||||
assert.match(cyberStyles, /var\(--cyber-telemetry-fill\)/);
|
||||
assert.match(cyberStyles, />\s*\.panel-header\s+\.panel-title::before/);
|
||||
assert.match(cyberStyles, /\.panel-collapsible\.collapsed::after/);
|
||||
assert.match(cyberStyles, /\.panel-collapsible:not\(\.collapsed\)::after/);
|
||||
assert.match(cyberStyles, /\.context-mode-standby:not\(\[hidden\]\)/);
|
||||
// The base standby is borderless plain text, so the focus card must name its
|
||||
// own frame width and centring rather than inherit them.
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/\.context-mode-standby:not\(\[hidden\]\) \{[^}]*place-content: center;[^}]*border: 1px solid[^}]*text-align: center;/,
|
||||
);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/:root\[data-ui-theme='cyber'\] \.global-context-modes \{[^}]*border: 0;/,
|
||||
);
|
||||
assert.match(cyberStyles, /mask-image: linear-gradient\(/);
|
||||
assert.match(cyberStyles, /flex: 1 1 auto;/);
|
||||
assert.match(cyberStyles, /#left-panel-stack:has/);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/inset-inline-start: calc\(54px \+ var\(--panel-rail-clearance\)\);/,
|
||||
);
|
||||
assert.match(cyberStyles, /right: calc\(51px \+ var\(--panel-rail-clearance\)\);/);
|
||||
// Each side's edge line shows only beside an open panel.
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/#left-panel-stack:has\(> \[data-panel-id\]:not\(\.collapsed, \[hidden\]\)\) \{\s*border-inline-start-color:/,
|
||||
);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/#right-context-rail:has\(> \[data-panel-id\]:not\(\.collapsed, \[hidden\]\)\) \{\s*border-inline-end-color:/,
|
||||
);
|
||||
assert.match(cyberStyles, /bottom: calc\(2vh \+ 13rem \+ var\(--world-timeline-lift, 0px\)\);/);
|
||||
assert.doesNotMatch(cyberStyles, /NAV 01 \/\/ COMMAND BUS \/\/ VIS 03/);
|
||||
assert.match(cyberStyles, /data-layer-id='satellites'/);
|
||||
assert.match(cyberStyles, /#search-toggle::before/);
|
||||
assert.match(cyberStyles, /VISUAL MATRIX \/\/ 03/);
|
||||
assert.match(cyberStyles, /body\.cockpit-mode #cockpit-hud/);
|
||||
assert.match(cyberStyles, /TARGET SCANNING \/\/ LIVE VECTOR/);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/body\.cockpit-mode #global-loading-status \{[\s\S]*?top: 60px;[\s\S]*?z-index: 146;/,
|
||||
);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/body\.cockpit-mode #global-loading-detail \{[\s\S]*?color: var\(--cockpit-accent\);/,
|
||||
);
|
||||
assert.match(cyberStyles, /body\.cockpit-mode \.cockpit-visor-shell::before/);
|
||||
assert.match(cyberStyles, /body\.cockpit-mode \.cockpit-scan-array/);
|
||||
assert.match(cyberStyles, /body\.cockpit-mode \.cockpit-target-side-arcs/);
|
||||
assert.match(cyberStyles, /body\.cockpit-mode \.cockpit-target-ticks/);
|
||||
assert.match(cyberStyles, /body\.cockpit-mode \.cockpit-target-core/);
|
||||
assert.match(cyberStyles, /width: min\(48vw, 60vh\);/);
|
||||
assert.match(cyberStyles, /body\.cockpit-mode \.cockpit-context-window/);
|
||||
assert.match(cyberStyles, /body\.cockpit-mode \.cockpit-signal-window/);
|
||||
assert.match(cyberStyles, /body\.cockpit-mode #intel-hud\.active/);
|
||||
});
|
||||
|
||||
test('Cyber voice telemetry renders a live scan scope without replacing audio ownership', () => {
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/#gev-voice-control\s*\{[\s\S]*?--cyber-voice-wave:/,
|
||||
);
|
||||
assert.match(cyberStyles, /\.gev-voice-visualizer::before/);
|
||||
assert.match(cyberStyles, /\.gev-voice-visualizer::after/);
|
||||
assert.match(cyberStyles, /@keyframes gev-cyber-voice-scan/);
|
||||
assert.match(cyberStyles, /@keyframes gev-cyber-voice-lock/);
|
||||
assert.match(cyberStyles, /\[data-speaker='user'\]/);
|
||||
assert.match(cyberStyles, /\[data-speaker='ai'\]/);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/prefers-reduced-motion: reduce[\s\S]*?gev-voice-visualizer::after[\s\S]*?animation: none/,
|
||||
);
|
||||
});
|
||||
|
||||
test('Cyber Cockpit Display uses the released briefing lane instead of the legacy viewport cap', () => {
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/body\.cockpit-mode\s+#cockpit-display-panel\s*\{[\s\S]*?max-height:\s*calc\(var\(--cockpit-utility-expanded-max-height, 72vh\) - 62px\)/,
|
||||
);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/#cockpit-hud:has\(\.cockpit-utility-control\.is-expanded\)[\s\S]*?\.cockpit-signal-window\[data-collapsed='true'\][\s\S]*?bottom: 80px;[\s\S]*?visibility:\s*visible/,
|
||||
);
|
||||
});
|
||||
|
||||
test('Cyber Cockpit keeps Data Layers inside its bounded rail', () => {
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/body:not\(\.cockpit-mode\)\s+#left-panel-stack:has\([\s\S]*?max-height:\s*none;/,
|
||||
);
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/body\.cockpit-mode\s+#left-panel-stack\s+> :is\(#data-panel, #utilities-panel\) \{[\s\S]*?max-height: min\(64vh, 610px\);/,
|
||||
);
|
||||
});
|
||||
|
||||
test('Cyber desktop cockpit collapsed utility frames match the 50px Data Layers frame', () => {
|
||||
const desktop = cyberStyles.slice(
|
||||
cyberStyles.indexOf('@media (min-width: 961px) and (min-height: 650px)'),
|
||||
cyberStyles.indexOf('@media (max-width: 720px)'),
|
||||
);
|
||||
assert.match(
|
||||
desktop,
|
||||
/:root\[data-ui-theme='cyber'\]\s+body\.cockpit-mode\s+\.cockpit-utility-control:not\(\.is-expanded\)\s+\.cockpit-utility-launcher\s*\{\s*height: 50px;\s*min-height: 50px;\s*padding: 9px 18px 9px 24px;/,
|
||||
);
|
||||
assert.match(
|
||||
desktop,
|
||||
/\.cockpit-utility-control:not\(\.is-expanded\)\s+\.cockpit-utility-launcher::after\s*\{\s*bottom: 6px;/,
|
||||
);
|
||||
});
|
||||
|
||||
test('Cyber right panels preserve intrinsic sizing and the shared rail allocation', () => {
|
||||
assert.doesNotMatch(
|
||||
cyberStyles.slice(cyberStyles.indexOf(":root[data-ui-theme='cyber'] {")),
|
||||
/#right-context-rail\s*>[^{}]+\{[^{}]*\b(?:flex|height|max-height):/,
|
||||
);
|
||||
});
|
||||
|
||||
test('Cyber panels retain clean edges without the added footer band', () => {
|
||||
assert.doesNotMatch(cyberStyles, /--cyber-panel-foot-/);
|
||||
assert.doesNotMatch(cyberStyles, /border-bottom: 24px solid transparent/);
|
||||
});
|
||||
|
||||
test('Cyber keeps Sonar on/off without the removed CSS effect switch or dimmer', () => {
|
||||
const template = readFileSync(
|
||||
new URL('./views/panels/DisplayPanel.vue', import.meta.url),
|
||||
'utf8',
|
||||
);
|
||||
assert.match(template, /id="cyber-sonar-toggle"/);
|
||||
assert.doesNotMatch(template, /data-sonar-mode|cyber-sonar-mode-row/);
|
||||
assert.doesNotMatch(cyberStyles, /cyber-scene-dimmer|data-cyber-sonar-mode/);
|
||||
});
|
||||
|
||||
test('Cyber Display uses a red title without a panel-specific center tab', () => {
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/#pp-toggles \.pp-header-label\s*\{\s*color: var\(--cyber-red-bright\);/,
|
||||
);
|
||||
assert.doesNotMatch(cyberStyles, /#pp-toggles[^,{]*::after\s*\{/);
|
||||
assert.match(cyberStyles, /isolation: isolate;\s*clip-path: none;/);
|
||||
assert.match(cyberStyles, /#pp-toggles:not\(\.collapsed\)::before/);
|
||||
});
|
||||
|
||||
test('Cyber omits only the fictional classification and system header lines', () => {
|
||||
assert.match(
|
||||
cyberStyles,
|
||||
/#intel-hud\[data-variant='cyber'\] \.hud-top-left \.hud-classification,\s*#intel-hud\[data-variant='cyber'\] \.hud-top-left \.hud-system\s*\{\s*display: none;\s*\}/,
|
||||
);
|
||||
});
|
||||
@@ -54,7 +54,7 @@ export class DisplayBindings {
|
||||
documentRef: document,
|
||||
searchInput: this._locationSearch,
|
||||
actions: {
|
||||
setStyle: (style) => this.setStyle(style, { userInitiated: true }),
|
||||
setStyle: (style) => this.setStyle(style),
|
||||
dismissSearch: () => this._closeLocationSearch?.({ ifOpen: true }),
|
||||
toggleHud: () => {
|
||||
this.shareLinkManager?.claimRestoreLane?.('visual');
|
||||
@@ -82,7 +82,7 @@ export class DisplayBindings {
|
||||
this._detachDisplayControls?.();
|
||||
const store = this.displayStore ?? useDisplayStore(applicationPinia());
|
||||
const token = store.connect({
|
||||
setStyle: (style) => this.setStyle(style, { userInitiated: true }),
|
||||
setStyle: (style) => this.setStyle(style),
|
||||
toggleBloom: () => {
|
||||
this.shareLinkManager?.claimRestoreLane?.('visual');
|
||||
this._setBloomEnabled(!this.bloomEnabled);
|
||||
@@ -116,7 +116,7 @@ export class DisplayBindings {
|
||||
},
|
||||
setHudLayout: (value) => {
|
||||
this.shareLinkManager?.claimRestoreLane?.('visual');
|
||||
this._setHudVariant(value, { applyVisualDefaults: true });
|
||||
this._setHudVariant(value);
|
||||
},
|
||||
toggleCleanView: () => this.toggleCleanView(),
|
||||
exitCleanView: () => this.toggleCleanView(false),
|
||||
@@ -155,7 +155,10 @@ export class DisplayBindings {
|
||||
this._updateHudButtonState();
|
||||
this._syncShareState();
|
||||
},
|
||||
toggleSonar: () => this._setCyberSonarEnabled(),
|
||||
toggleSonar: () => {
|
||||
this.shareLinkManager?.claimRestoreLane?.('visual');
|
||||
this._setCyberSonarEnabled();
|
||||
},
|
||||
setSonarRings: (value) => this._setCyberSonarSetting('rings', value),
|
||||
setSonarRange: (value) => this._setCyberSonarSetting('range', value),
|
||||
setSonarIntensity: (value) =>
|
||||
@@ -178,9 +181,8 @@ export class DisplayBindings {
|
||||
// feather and opacity, 3D aircraft on in Proximity.
|
||||
resetVisual: () => {
|
||||
this.shareLinkManager?.claimRestoreLane?.('visual');
|
||||
this.setStyle('normal', { userInitiated: true });
|
||||
// The HUD layout follows the Normal style, as choosing it does: the
|
||||
// Cyber HUD stays Cyber.
|
||||
this.setStyle('normal');
|
||||
// The HUD layout and the Sonar style stay as the viewer set them.
|
||||
this._applyGlobalPostDefaults({ keepHudVariant: true });
|
||||
this._setDetectionAllocation('ELASTIC');
|
||||
this._setScope({ enabled: true, featherPct: 100, opacityPct: 100 });
|
||||
|
||||
@@ -238,20 +238,29 @@ test('the HUD and Sonar controls render what VisualSettings shows', async (t) =>
|
||||
getVariant: () => variant,
|
||||
});
|
||||
owner._scheduleAdaptivePanelLayout = () => {};
|
||||
assert.equal($('cyber-sonar-toggle').textContent, 'ON');
|
||||
assert.equal($('cyber-sonar-toggle').getAttribute('aria-pressed'), 'true');
|
||||
// Sonar is opt-in: OFF until the viewer turns it on.
|
||||
assert.equal($('cyber-sonar-toggle').textContent, 'OFF');
|
||||
assert.equal($('cyber-sonar-toggle').getAttribute('aria-pressed'), 'false');
|
||||
assert.equal(
|
||||
[...$('hud-layout-select').options].map((option) => option.value).join(),
|
||||
'tactical,minimal',
|
||||
);
|
||||
|
||||
owner._syncHudControls();
|
||||
await nextTick();
|
||||
assert.equal($('hud-toggle').classList.contains('active'), true);
|
||||
assert.equal($('hud-layout-row').classList.contains('visible'), true);
|
||||
assert.equal($('hud-layout-select').value, 'minimal');
|
||||
// The toggle shows with the HUD; its sliders wait for Sonar ON.
|
||||
assert.equal($('cyber-sonar-row').classList.contains('visible'), true);
|
||||
assert.equal($('cyber-sonar-rings-row').classList.contains('visible'), false);
|
||||
|
||||
visible = false;
|
||||
owner._updateHudButtonState();
|
||||
await nextTick();
|
||||
assert.equal($('hud-toggle').classList.contains('active'), false);
|
||||
assert.equal($('hud-layout-row').classList.contains('visible'), false);
|
||||
assert.equal($('cyber-sonar-row').classList.contains('visible'), false);
|
||||
|
||||
owner._sonarShown = {
|
||||
enabled: false,
|
||||
@@ -272,6 +281,19 @@ test('the HUD and Sonar controls render what VisualSettings shows', async (t) =>
|
||||
assert.equal($('cyber-sonar-range-value').textContent, '90%');
|
||||
assert.equal($('cyber-sonar-sector').value, '30');
|
||||
assert.equal($('cyber-sonar-sector-value').textContent, '30°');
|
||||
|
||||
visible = true;
|
||||
owner._updateHudButtonState();
|
||||
owner._sonarShown = { ...owner._sonarShown, enabled: true };
|
||||
owner._publishDisplay();
|
||||
await nextTick();
|
||||
assert.equal(toggle.textContent, 'ON');
|
||||
for (const name of ['rings', 'range', 'intensity', 'opacity', 'sector'])
|
||||
assert.equal(
|
||||
$(`cyber-sonar-${name}-row`).classList.contains('visible'),
|
||||
true,
|
||||
name,
|
||||
);
|
||||
});
|
||||
|
||||
test('Scope and Celestial render what VisualSettings shows', async (t) => {
|
||||
|
||||
@@ -321,7 +321,7 @@ test('DisplayBindings sets the scope opacity and resets Visual to its defaults',
|
||||
document.querySelector('#pp-toggles .pp-reset-btn').click();
|
||||
assert.deepEqual(calls, [
|
||||
['claim', 'visual'],
|
||||
['style', 'normal', { userInitiated: true }],
|
||||
['style', 'normal', undefined],
|
||||
['postDefaults', { keepHudVariant: true }],
|
||||
['allocation', 'ELASTIC'],
|
||||
['scope', { enabled: true, featherPct: 100, opacityPct: 100 }],
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
/** Cyber keeps the frame fixed; other layouts retain their existing scroller. */
|
||||
export function displayPanelScroller(panel) {
|
||||
return panel?.ownerDocument?.documentElement?.dataset.uiTheme === 'cyber'
|
||||
? panel.querySelector('.pp-panel-body') || panel
|
||||
: panel;
|
||||
}
|
||||
@@ -60,7 +60,7 @@ export function installEntityContext({
|
||||
const voice = useVoiceStore(pinia);
|
||||
const cockpitStore = useCockpitStore(pinia);
|
||||
const chrome = usePanelChromeStore(pinia);
|
||||
/** Whether Context is open; a closed panel reads nothing. */
|
||||
/** Whether Context is open. (readView also reads while the Omnibar is focused.) */
|
||||
const isOpen = () =>
|
||||
chrome.panels['global-context-panel']?.collapsed === false;
|
||||
const doc = globalThis.document;
|
||||
@@ -221,7 +221,8 @@ export function installEntityContext({
|
||||
// the height. Read when the camera settles, not every frame.
|
||||
const readView = () => {
|
||||
const port = camera();
|
||||
if (!port || !isOpen()) return;
|
||||
if (!port || (!isOpen() && doc?.activeElement?.id !== 'gev-omnibar-input'))
|
||||
return;
|
||||
const pose = port.pose();
|
||||
if (![pose.lat, pose.lon, pose.height].every(Number.isFinite)) return;
|
||||
const middle = pickWorld?.(viewer, 0.5, 0.5);
|
||||
@@ -270,6 +271,12 @@ export function installEntityContext({
|
||||
listen();
|
||||
readView();
|
||||
}, 0);
|
||||
// The Omnibar's nearby suggestions also need a fresh center even with
|
||||
// Context closed. Its focus event requests one camera read.
|
||||
const onSearchFocus = (event) => {
|
||||
if (event.target?.id === 'gev-omnibar-input') readView();
|
||||
};
|
||||
doc?.addEventListener('focusin', onSearchFocus);
|
||||
// Opening the panel describes the view as it is now.
|
||||
let wasOpen = isOpen();
|
||||
const offChrome = chrome.$subscribe(() => {
|
||||
@@ -352,6 +359,7 @@ export function installEntityContext({
|
||||
clearTimeout(trailing);
|
||||
offFollow();
|
||||
offChrome();
|
||||
doc?.removeEventListener('focusin', onSearchFocus);
|
||||
clearTimeout(followCheck);
|
||||
globalThis.removeEventListener?.('gev:entity-selected', onSelected);
|
||||
store.connect(null);
|
||||
|
||||
@@ -48,3 +48,35 @@ test('the FPS readout sits in the title bar, hidden until the backquote key', as
|
||||
await nextTick();
|
||||
assert.equal(readout(), null);
|
||||
});
|
||||
|
||||
test('the title logo is a button that asks for the way back to live at the start view', async (t) => {
|
||||
document.body.replaceChildren();
|
||||
const pinia = createPinia();
|
||||
const app = createApp(SceneChromeView).use(pinia);
|
||||
app.mount(document.body.appendChild(document.createElement('div')));
|
||||
t.after(() => app.unmount());
|
||||
const { useGlobeActionsStore } = await import('./stores/globeActions.js');
|
||||
const calls = [];
|
||||
useGlobeActionsStore(pinia).connect({ home: () => calls.push('home') });
|
||||
const logo = document.querySelector('#title-bar h1 > button.title-logo');
|
||||
assert.ok(logo, 'the logo is the title heading’s button');
|
||||
assert.equal(
|
||||
logo.getAttribute('aria-label'),
|
||||
'Back to live at the starting view',
|
||||
);
|
||||
assert.ok(logo.hasAttribute('data-logo-gaze'));
|
||||
logo.click();
|
||||
assert.deepEqual(calls, ['home']);
|
||||
});
|
||||
|
||||
test('the title heading keeps its own name beside the logo button', async (t) => {
|
||||
document.body.replaceChildren();
|
||||
const app = createApp(SceneChromeView).use(createPinia());
|
||||
app.mount(document.body.appendChild(document.createElement('div')));
|
||||
t.after(() => app.unmount());
|
||||
const heading = document.querySelector('#title-bar h1');
|
||||
const named = document.getElementById(
|
||||
heading.getAttribute('aria-labelledby'),
|
||||
);
|
||||
assert.equal(named.textContent.replace(/\s+/g, ' ').trim(), "GOD'S EYE VIEW");
|
||||
});
|
||||
@@ -0,0 +1,672 @@
|
||||
import {
|
||||
getScopeMaskFeather,
|
||||
getScopeMaskOpacity,
|
||||
isScopeMaskEnabled,
|
||||
setScopeMaskEnabled,
|
||||
setScopeMaskFeather,
|
||||
setScopeMaskOpacity,
|
||||
} from '../scopeMask.js';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readdirSync, readFileSync } from 'node:fs';
|
||||
import test from 'node:test';
|
||||
import {
|
||||
HUD_LAYOUTS,
|
||||
isLegacySonarHudLayout,
|
||||
LEGACY_SONAR_HUD_LAYOUTS,
|
||||
normalizeHudLayout,
|
||||
} from '../hudLayouts.js';
|
||||
import {
|
||||
isCyberMapThemeActive,
|
||||
isCyberSonarActive,
|
||||
isCyberSonarEnabled,
|
||||
setCyberSonarEnabled,
|
||||
} from '../cyberSonar.js';
|
||||
import { GEV_ACTION_SCHEMAS } from '../voice/actionSchemas.js';
|
||||
import { createGevActionRunner } from '../voice/gevActions.js';
|
||||
import { StyleManager } from './applicationShell.js';
|
||||
import { setCyberSonarControls } from './cyberSonarControls.js';
|
||||
import { createPinia } from 'pinia';
|
||||
import { useDisplayStore } from './stores/display.js';
|
||||
import { VisualSettings } from './visualSettings.js';
|
||||
import { STYLES } from './visualPresets.js';
|
||||
|
||||
const read = (relative) =>
|
||||
readFileSync(new URL(relative, import.meta.url), 'utf8');
|
||||
|
||||
function cssRuleBody(styles, selector) {
|
||||
const match = styles.match(new RegExp(`${selector.source}\\s*\\{([^}]+)\\}`));
|
||||
assert.ok(match, `Missing CSS rule: ${selector.source}`);
|
||||
return match[1];
|
||||
}
|
||||
|
||||
function styleOwner(t, initialVariant = 'tactical') {
|
||||
const previous = { document: globalThis.document, window: globalThis.window };
|
||||
const root = { dataset: {} };
|
||||
globalThis.document = { documentElement: root, querySelectorAll: () => [] };
|
||||
globalThis.window = { dispatchEvent() {} };
|
||||
t.after(() => Object.assign(globalThis, previous));
|
||||
let variant = initialVariant;
|
||||
const calls = [];
|
||||
const hud = {
|
||||
getVariant: () => variant,
|
||||
// Normalize like the real HUD so removed layouts fall back.
|
||||
setVariant: (value) => (variant = normalizeHudLayout(value)),
|
||||
setMode: (value) => calls.push(['mode', value]),
|
||||
onStyleChange: (value) => calls.push(['style', value]),
|
||||
visible: true,
|
||||
};
|
||||
hud.setVariant(initialVariant);
|
||||
const owner = Object.create(VisualSettings.prototype);
|
||||
Object.assign(owner, {
|
||||
activeStyle: 'normal',
|
||||
store: { publish() {} },
|
||||
readHud: () => hud,
|
||||
readShareLinks: () => ({ onStyleChange() {} }),
|
||||
_visualEffects: {
|
||||
stages: Object.fromEntries(
|
||||
Object.entries(STYLES).map(([name, config]) => [
|
||||
name,
|
||||
{ uniforms: { ...config.uniforms, intensity: 0 } },
|
||||
]),
|
||||
),
|
||||
},
|
||||
services: {
|
||||
governorRequestRender: (reason) => calls.push(['render', reason]),
|
||||
setDetectionStyle() {},
|
||||
},
|
||||
_setBloomEnabled: (value) => calls.push(['bloom', value]),
|
||||
_setSharpenEnabled: (value) => calls.push(['sharpen', value]),
|
||||
_applyDetectionPreset: (value) => calls.push(['detection', value]),
|
||||
_syncShareState: () => calls.push(['share', variant]),
|
||||
});
|
||||
for (const name of [
|
||||
'setCelestialRingEnabled',
|
||||
'_startTransition',
|
||||
'_publishActiveStyle',
|
||||
'_updateSliderPanel',
|
||||
'_updateHudButtonState',
|
||||
'_syncIrBoost',
|
||||
'_syncCockpitInheritedStyle',
|
||||
'_syncCyberSonarControl',
|
||||
'_scheduleAdaptivePanelLayout',
|
||||
'_setDetectionFade',
|
||||
// Intensities: the fixture has no post-process stages to drive.
|
||||
'_setBloomIntensity',
|
||||
'_setSharpenIntensity',
|
||||
])
|
||||
owner[name] = () => {};
|
||||
return { owner, hud, root, calls };
|
||||
}
|
||||
|
||||
test('Tactical and Minimal are the HUD layouts; Cyber is only a Sonar alias', () => {
|
||||
assert.deepEqual(HUD_LAYOUTS, ['tactical', 'minimal']);
|
||||
assert.deepEqual(LEGACY_SONAR_HUD_LAYOUTS, ['cyber']);
|
||||
assert.equal(normalizeHudLayout('cyber'), 'tactical');
|
||||
assert.equal(normalizeHudLayout('CYBER'), 'tactical');
|
||||
assert.equal(normalizeHudLayout('operator'), 'tactical');
|
||||
assert.equal(normalizeHudLayout('Minimal'), 'minimal');
|
||||
assert.equal(isLegacySonarHudLayout('Cyber'), true);
|
||||
assert.equal(isLegacySonarHudLayout('operator'), false);
|
||||
assert.equal(isLegacySonarHudLayout('tactical'), false);
|
||||
});
|
||||
|
||||
test('a share link, scene or saved view naming Cyber opens Tactical with Sonar on', async (t) => {
|
||||
const { owner, hud, root, calls } = styleOwner(t, 'minimal');
|
||||
assert.equal(isCyberSonarEnabled(root), false);
|
||||
await owner.restoreShareState({ hudVariant: 'cyber' });
|
||||
assert.equal(hud.getVariant(), 'tactical');
|
||||
assert.equal(root.dataset.cyberSonar, 'on');
|
||||
assert.equal(root.dataset.uiTheme, undefined);
|
||||
// Turning it on asks for a frame, so a parked map starts the sweep.
|
||||
assert.ok(
|
||||
calls.some(
|
||||
([name, reason]) => name === 'render' && reason === 'cyber-sonar-toggle',
|
||||
),
|
||||
);
|
||||
// The viewer's own layout choice afterwards leaves the Sonar style alone.
|
||||
owner._setHudVariant('minimal');
|
||||
assert.equal(hud.getVariant(), 'minimal');
|
||||
assert.equal(isCyberSonarEnabled(root), true);
|
||||
// A restored state is authoritative: one that does not name Cyber turns
|
||||
// Sonar off, whether from a link or a scene shot.
|
||||
await owner.restoreShareState({ hudVariant: 'tactical' });
|
||||
assert.equal(isCyberSonarEnabled(root), false);
|
||||
setCyberSonarEnabled(true, root);
|
||||
await owner.applyVisualState({ hud: { variant: 'minimal' } });
|
||||
assert.equal(hud.getVariant(), 'minimal');
|
||||
assert.equal(isCyberSonarEnabled(root), false);
|
||||
await owner.applyVisualState({ hud: { variant: 'cyber' } });
|
||||
assert.equal(hud.getVariant(), 'tactical');
|
||||
assert.equal(isCyberSonarEnabled(root), true);
|
||||
});
|
||||
|
||||
test('links and scene shots record Tactical with Sonar as the Cyber code, and only that', (t) => {
|
||||
const { owner, root } = styleOwner(t, 'tactical');
|
||||
Object.assign(owner.services, {
|
||||
getDetectionTuning: () => ({ allocationStrategy: 'ELASTIC' }),
|
||||
getDetectionMode: () => 'OFF',
|
||||
isScopeMaskEnabled: () => true,
|
||||
getScopeMaskFeather: () => 1,
|
||||
getScopeMaskOpacity: () => 1,
|
||||
getScopeTerminusOverride: () => null,
|
||||
});
|
||||
owner.readCelestialRing = () => null;
|
||||
const shared = () => owner._readShareState().options.hudVariant;
|
||||
assert.equal(shared(), 'tactical');
|
||||
owner._setCyberSonarEnabled(true);
|
||||
assert.equal(shared(), 'cyber');
|
||||
// Minimal has no code that carries Sonar; it stays local.
|
||||
owner._setHudVariant('minimal');
|
||||
assert.equal(shared(), 'minimal');
|
||||
owner._setHudVariant('tactical');
|
||||
assert.equal(shared(), 'cyber');
|
||||
owner._setCyberSonarEnabled(false);
|
||||
assert.equal(shared(), 'tactical');
|
||||
assert.equal(isCyberSonarEnabled(root), false);
|
||||
});
|
||||
|
||||
test('Sonar is opt-in and gated on its toggle, the HUD, Cockpit and motion, not a theme', () => {
|
||||
const classes = new Set();
|
||||
const root = { dataset: {} };
|
||||
const body = { classList: { contains: (name) => classes.has(name) } };
|
||||
const gate = (extra = {}) => ({
|
||||
root,
|
||||
body,
|
||||
hudActive: true,
|
||||
reducedMotion: false,
|
||||
...extra,
|
||||
});
|
||||
assert.equal(isCyberSonarEnabled(root), false);
|
||||
assert.equal(isCyberSonarActive(gate()), false);
|
||||
assert.equal(isCyberMapThemeActive(gate()), false);
|
||||
// The removed Cyber theme attribute no longer enables anything.
|
||||
root.dataset.uiTheme = 'cyber';
|
||||
assert.equal(isCyberSonarActive(gate()), false);
|
||||
delete root.dataset.uiTheme;
|
||||
|
||||
assert.equal(setCyberSonarEnabled(true, root), true);
|
||||
assert.equal(root.dataset.cyberSonar, 'on');
|
||||
assert.equal(isCyberSonarActive(gate()), true);
|
||||
assert.equal(isCyberMapThemeActive(gate()), true);
|
||||
assert.equal(isCyberSonarActive(gate({ hudActive: false })), false);
|
||||
assert.equal(isCyberMapThemeActive(gate({ hudActive: false })), false);
|
||||
// Reduced motion keeps the static treatment and stops the sweep.
|
||||
assert.equal(isCyberSonarActive(gate({ reducedMotion: true })), false);
|
||||
assert.equal(isCyberMapThemeActive(gate({ reducedMotion: true })), true);
|
||||
classes.add('cockpit-mode');
|
||||
assert.equal(isCyberSonarActive(gate()), false);
|
||||
assert.equal(isCyberMapThemeActive(gate()), false);
|
||||
classes.delete('cockpit-mode');
|
||||
|
||||
assert.equal(setCyberSonarEnabled(false, root), false);
|
||||
assert.equal(root.dataset.cyberSonar, 'off');
|
||||
assert.equal(isCyberSonarActive(gate()), false);
|
||||
assert.equal(isCyberMapThemeActive(gate()), false);
|
||||
});
|
||||
|
||||
test('Sonar controls apply under Tactical and Minimal and still validate input', () => {
|
||||
for (const layout of ['tactical', 'minimal']) {
|
||||
const root = { dataset: {} };
|
||||
const doc = {
|
||||
documentElement: root,
|
||||
body: { classList: { contains: () => false } },
|
||||
getElementById: () => null,
|
||||
};
|
||||
const calls = [];
|
||||
const owner = {
|
||||
hud: { getVariant: () => layout, visible: true },
|
||||
_setCyberSonarSetting: (name, value) => calls.push([name, value]),
|
||||
_setCyberSonarEnabled: (value) => {
|
||||
calls.push(['enabled', value]);
|
||||
setCyberSonarEnabled(value, root);
|
||||
},
|
||||
};
|
||||
const applied = setCyberSonarControls(
|
||||
owner,
|
||||
{ enabled: true, rings: 6, sectorDeg: 30 },
|
||||
doc,
|
||||
);
|
||||
assert.equal(applied.ok, true, layout);
|
||||
assert.equal(applied.sonar.enabled, true);
|
||||
assert.equal('cyberSelected' in applied.sonar, false);
|
||||
assert.deepEqual(calls, [
|
||||
['rings', 6],
|
||||
['sector', 30],
|
||||
['enabled', true],
|
||||
]);
|
||||
assert.equal(
|
||||
setCyberSonarControls(owner, { enabled: 'yes' }, doc).error,
|
||||
'enabled must be a boolean.',
|
||||
);
|
||||
assert.equal(
|
||||
setCyberSonarControls(owner, { pulse: 3 }, doc).error,
|
||||
'Unknown sonar setting.',
|
||||
);
|
||||
assert.equal(
|
||||
setCyberSonarControls(owner, { rings: 13 }, doc).error,
|
||||
'rings must be an integer from 3 to 12.',
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('Display and voice HUD routes offer Tactical and Minimal, and Cyber turns Sonar on', async (t) => {
|
||||
const makeOwner = () => {
|
||||
const { owner, hud, root } = styleOwner(t, 'tactical');
|
||||
owner.setStyle('noir');
|
||||
owner.setHudLayout = (...args) =>
|
||||
StyleManager.prototype.setHudLayout.call(owner, ...args);
|
||||
owner.getControlState = () => ({
|
||||
hud: { layout: hud.getVariant(), visible: true },
|
||||
});
|
||||
return { owner, hud, root };
|
||||
};
|
||||
|
||||
const display = makeOwner();
|
||||
const store = useDisplayStore(createPinia());
|
||||
const token = store.connect({
|
||||
setHudLayout: (value) => display.owner.setHudLayout(value),
|
||||
setStyle: (value) => display.owner.setStyle(value),
|
||||
});
|
||||
store.act('setHudLayout', 'minimal');
|
||||
assert.equal(display.hud.getVariant(), 'minimal');
|
||||
// Switching layouts never changes the visual preset.
|
||||
assert.equal(display.owner.activeStyle, 'noir');
|
||||
store.act('setStyle', 'anime');
|
||||
assert.equal(display.owner.activeStyle, 'anime');
|
||||
store.detach(token);
|
||||
|
||||
const setHud = GEV_ACTION_SCHEMAS.find((tool) => tool.name === 'set_hud');
|
||||
assert.deepEqual(setHud.parameters.properties.layout.enum, HUD_LAYOUTS);
|
||||
|
||||
const voice = makeOwner();
|
||||
const eventSource = { addEventListener() {}, removeEventListener() {} };
|
||||
const viewer = {
|
||||
camera: { moveEnd: { addEventListener() {} } },
|
||||
clock: { onTick: { addEventListener: () => () => {} } },
|
||||
canvas: eventSource,
|
||||
scene: { canvas: eventSource },
|
||||
};
|
||||
const runVoiceAction = createGevActionRunner({
|
||||
viewer,
|
||||
styleManager: voice.owner,
|
||||
dataManager: {},
|
||||
});
|
||||
const minimal = await runVoiceAction('set_hud', { layout: 'minimal' });
|
||||
assert.equal(minimal.ok, true);
|
||||
assert.equal(voice.hud.getVariant(), 'minimal');
|
||||
assert.equal(isCyberSonarEnabled(voice.root), false);
|
||||
const legacy = await runVoiceAction('set_hud', { layout: 'cyber' });
|
||||
assert.equal(legacy.ok, true);
|
||||
assert.equal(legacy.layout, 'tactical');
|
||||
assert.equal(voice.hud.getVariant(), 'tactical');
|
||||
assert.equal(isCyberSonarEnabled(voice.root), true);
|
||||
assert.equal(voice.owner.activeStyle, 'noir');
|
||||
const unknown = await runVoiceAction('set_hud', { layout: 'operator' });
|
||||
assert.equal(unknown.ok, false);
|
||||
});
|
||||
|
||||
test('style presets keep their own HUD layout and never touch Sonar', (t) => {
|
||||
const { owner, hud, root } = styleOwner(t);
|
||||
setCyberSonarEnabled(true, root);
|
||||
for (const variant of ['tactical', 'minimal']) {
|
||||
owner._setHudVariant(variant);
|
||||
assert.equal(hud.getVariant(), variant);
|
||||
owner.setStyle('normal');
|
||||
owner.setStyle('surveillance');
|
||||
assert.equal(hud.getVariant(), 'tactical');
|
||||
assert.equal(isCyberSonarEnabled(root), true);
|
||||
}
|
||||
});
|
||||
|
||||
test('the Display panel offers Sonar as an opt-in toggle under the HUD layout', () => {
|
||||
const view = read('./views/panels/DisplayPanel.vue');
|
||||
assert.doesNotMatch(view, /value="cyber"/);
|
||||
assert.match(view, /<option value="tactical">/);
|
||||
assert.match(view, /<option value="minimal">/);
|
||||
assert.match(
|
||||
view,
|
||||
/const sonarOn = computed\(\(\) => sonar\.value\?\.enabled \?\? false\);/,
|
||||
);
|
||||
// The toggle shows with the HUD; its sliders only once Sonar is on.
|
||||
assert.match(
|
||||
view,
|
||||
/cyber-sonar-toggle-row" :class="\{ visible: hud\?\.visible \}" id="cyber-sonar-row"/,
|
||||
);
|
||||
assert.equal(
|
||||
view.match(
|
||||
/cyber-sonar-setting" :class="\{ visible: hud\?\.visible && sonarOn \}"/g,
|
||||
)?.length,
|
||||
5,
|
||||
);
|
||||
assert.match(view, /:aria-label="t\('Sonar contact scanner'\)"/);
|
||||
// Its renderer status speaks only for a Sonar the viewer turned on.
|
||||
assert.match(
|
||||
view,
|
||||
/<output id="cyber-sonar-status"[^>]*:hidden="!\(hud\?\.visible && sonarOn\)"/,
|
||||
);
|
||||
assert.doesNotMatch(view, /t\('Cyber/);
|
||||
});
|
||||
|
||||
test('stylesheets carry no Cyber theme and show the sweep only while Sonar is on', () => {
|
||||
const entry = readFileSync(
|
||||
new URL('../../style.css', import.meta.url),
|
||||
'utf8',
|
||||
);
|
||||
assert.match(entry, /@import '\.\/src\/ui\/styles\/sonar\.css';/);
|
||||
assert.doesNotMatch(entry, /cyber\.css/);
|
||||
const dir = new URL('./styles/', import.meta.url);
|
||||
for (const name of readdirSync(dir).filter((file) => file.endsWith('.css')))
|
||||
assert.doesNotMatch(
|
||||
readFileSync(new URL(name, dir), 'utf8'),
|
||||
/data-ui-theme/,
|
||||
name,
|
||||
);
|
||||
|
||||
const sonar = read('./styles/sonar.css');
|
||||
assert.match(cssRuleBody(sonar, /\n\.hud-sonar/), /display: none;/);
|
||||
assert.match(
|
||||
cssRuleBody(
|
||||
sonar,
|
||||
/\n:root\[data-cyber-sonar='on'\] #intel-hud \.hud-sonar/,
|
||||
),
|
||||
/display: block;/,
|
||||
);
|
||||
// Cockpit and a hidden HUD keep no sweep, not even an invisible one.
|
||||
assert.match(
|
||||
cssRuleBody(
|
||||
sonar,
|
||||
/:root\[data-cyber-sonar='on'\] body\.cockpit-mode #intel-hud \.hud-sonar,\s*:root\[data-cyber-sonar='on'\] #intel-hud:not\(\.active\) \.hud-sonar/,
|
||||
),
|
||||
/display: none;/,
|
||||
);
|
||||
assert.match(
|
||||
sonar,
|
||||
/@media \(prefers-reduced-motion: reduce\)\s*\{\s*:root\[data-cyber-sonar='on'\] #intel-hud \.hud-sonar::after\s*\{\s*display: none;\s*animation: none;/,
|
||||
);
|
||||
// The Vue bindings own the Sonar rows' visibility now.
|
||||
const controls = read('./styles/controls.css');
|
||||
assert.doesNotMatch(controls, /\.cyber-sonar-control\s*\{\s*display: none/);
|
||||
assert.doesNotMatch(controls, /data-cyber-sonar='off'/);
|
||||
});
|
||||
|
||||
test('the desktop bottom row: credits on the Power Up baseline, the dock lifted, the corners level', () => {
|
||||
const rem = 16;
|
||||
const lift = 'var\\(--world-timeline-lift, 0px\\)';
|
||||
const value = (text, pattern) => {
|
||||
const match = text.match(pattern);
|
||||
assert.ok(match, pattern.source);
|
||||
return Number(match[1]);
|
||||
};
|
||||
const block = (text, header) => {
|
||||
const start = text.indexOf(header);
|
||||
assert.ok(start >= 0, header);
|
||||
let depth = 0;
|
||||
for (let i = text.indexOf('{', start); i < text.length; i += 1) {
|
||||
if (text[i] === '{') depth += 1;
|
||||
else if (text[i] === '}' && --depth === 0)
|
||||
return text.slice(start, i + 1);
|
||||
}
|
||||
assert.fail(`unclosed ${header}`);
|
||||
};
|
||||
// Measured constants: the Power Up / language row is 32px tall, 14px up
|
||||
// and about 20rem wide in English; the attribution logo line is 28px; the
|
||||
// single-row dock is 62px; the bottom-right readout is one 26px line
|
||||
// taller than the coordinates.
|
||||
const POWER_UP = { bottom: 14, height: 32 };
|
||||
const CREDIT_HEIGHT = 28;
|
||||
const DOCK_HEIGHT = 62;
|
||||
const timeline = read('./styles/world-timeline.css');
|
||||
const timelineLift = value(
|
||||
timeline,
|
||||
/body:has\(#world-timeline\) \{\s*--world-timeline-lift: (\d+)px;/,
|
||||
);
|
||||
|
||||
// From 1200px the dock and the World Timeline leave the bottom 74px; below
|
||||
// it they return to the bottom edge, where the dock spans the corners.
|
||||
const dock = read('./styles/command-dock.css');
|
||||
const dockFloor = value(
|
||||
dock,
|
||||
new RegExp(
|
||||
`\\n#command-dock \\{[^}]*bottom: calc\\((\\d+)px \\+ ${lift}\\)`,
|
||||
),
|
||||
);
|
||||
assert.match(
|
||||
block(dock, '@media (max-width: 1199px)'),
|
||||
new RegExp(`#command-dock \\{\\s*bottom: calc\\(2vh \\+ ${lift}\\);`),
|
||||
);
|
||||
assert.equal(
|
||||
value(timeline, /\n#world-timeline \{[^}]*bottom: (\d+)px;/),
|
||||
dockFloor,
|
||||
);
|
||||
assert.match(
|
||||
block(timeline, '@media (max-width: 1199px)'),
|
||||
/#world-timeline \{\s*bottom: 2vh;/,
|
||||
);
|
||||
assert.ok(dockFloor >= POWER_UP.bottom + POWER_UP.height + 8);
|
||||
|
||||
// Both credit renderers share Power Up's row, centred on it, below the
|
||||
// dock, and stop short of the corner row instead of running under it:
|
||||
// GEV's own line on its anchor, Cesium's on the absolutely placed box it
|
||||
// draws inside its empty anchor.
|
||||
const trays = read('./styles/command-dock-trays.css');
|
||||
const trayWide = block(trays, '@media (min-width: 1200px)');
|
||||
const caps = {
|
||||
'gev-credits': trays.match(
|
||||
/#gev-credits \{\s*right: auto;\s*bottom: ([\d.]+)rem;\s*left: 1\.5rem;\s*width: max-content !important;\s*max-width: calc\(100vw - 1\.5rem - ([\d.]+)rem\);\s*white-space: normal;/,
|
||||
),
|
||||
'cesium-credits': (() => {
|
||||
const anchor = trays.match(
|
||||
/#cesium-credits \{\s*right: auto;\s*bottom: ([\d.]+)rem;\s*left: 1\.5rem;/,
|
||||
);
|
||||
const box = trayWide.match(
|
||||
/\n #cesium-credits \.cesium-widget-credits \{\s*width: max-content;\s*max-width: calc\(100vw - 1\.5rem - ([\d.]+)rem\);\s*white-space: normal;/,
|
||||
);
|
||||
return anchor && box && [null, anchor[1], box[1]];
|
||||
})(),
|
||||
};
|
||||
for (const [id, match] of Object.entries(caps)) {
|
||||
assert.ok(match, id);
|
||||
const creditsBottom = Number(match[1]) * rem;
|
||||
assert.equal(
|
||||
creditsBottom + CREDIT_HEIGHT / 2,
|
||||
POWER_UP.bottom + POWER_UP.height / 2,
|
||||
);
|
||||
assert.ok(creditsBottom + CREDIT_HEIGHT + 8 <= dockFloor);
|
||||
assert.ok(Number(match[2]) >= 20 + 1.5, `${id} leaves the corner row room`);
|
||||
}
|
||||
// Below 1200px the row returns above the bottom-edge dock, on one line.
|
||||
const narrow = block(trays, '@media (max-width: 1199px)');
|
||||
for (const id of ['cesium-credits', 'gev-credits'])
|
||||
assert.match(narrow, new RegExp(`#${id}[,\\s]`));
|
||||
assert.match(
|
||||
narrow,
|
||||
new RegExp(
|
||||
`\\{\\s*bottom: calc\\(2vh \\+ 5rem \\+ ${lift}\\);\\s*width: auto !important;\\s*max-width: calc\\(100vw - 3rem\\);\\s*white-space: nowrap;`,
|
||||
),
|
||||
);
|
||||
// Right to left the corner row is at the bottom left, so the row moves
|
||||
// right, with the Minimal HUD too (its placement names #intel-hud).
|
||||
assert.match(
|
||||
trayWide,
|
||||
/html\[dir='rtl'\]\s*body:not\(\.context-docked\):not\(\.ui-clean-view\):not\(\.recording-mode\)\s*:is\(#cesium-credits, #gev-credits\),\s*html\[dir='rtl'\]\s*body:not\(\.context-docked\):not\(\.ui-clean-view\):not\(\.recording-mode\):has\(\s*#intel-hud\[data-variant='minimal'\]\.active\s*\)\s*:is\(#cesium-credits, #gev-credits\) \{\s*right: 1\.5rem;\s*left: auto;/,
|
||||
);
|
||||
assert.match(
|
||||
trayWide,
|
||||
/#cesium-credits\s*\.cesium-widget-credits \{\s*right: 0;\s*left: auto;/,
|
||||
);
|
||||
// There the readout clears two lines of the row under it.
|
||||
assert.match(
|
||||
read('./styles/omnibar-dock.css'),
|
||||
/html\[dir='rtl'\] \*\)\s*#intel-hud\[data-variant='tactical'\]\s*\.hud-bottom-right \{\s*bottom: calc\(3\.375rem \+ 1\.5rem\);/,
|
||||
);
|
||||
const locale = read('./styles/locale-picker.css');
|
||||
assert.match(locale, /#corner-actions \{[^}]*inset-inline-end: 0\.9rem;/);
|
||||
|
||||
// From 1200px the readout keeps 8px above Power Up and the coordinates
|
||||
// start level with it. The World Timeline sits between the corners, so they
|
||||
// do not move while it shows.
|
||||
const split = read('./styles/rail-split.css');
|
||||
const wide = block(split, '@media (min-width: 1200px)');
|
||||
const readoutWide =
|
||||
value(
|
||||
wide,
|
||||
/\n #intel-hud\[data-variant='tactical'\] \.hud-bottom-right \{\s*bottom: ([\d.]+)rem;/,
|
||||
) * rem;
|
||||
assert.equal(readoutWide, POWER_UP.bottom + POWER_UP.height + 8);
|
||||
assert.equal(
|
||||
value(wide, /\.hud-bottom-left \{\s*bottom: calc\(([\d.]+)rem \+ 26px\);/) *
|
||||
rem,
|
||||
readoutWide,
|
||||
);
|
||||
assert.doesNotMatch(
|
||||
wide,
|
||||
/hud-bottom-(left|right) \{[^}]*world-timeline-lift/,
|
||||
);
|
||||
// Corners: coordinates ~302px from 36px, readout ~292px to 36px from the
|
||||
// right edge; the bar keeps 12px from each at every width from 1200px.
|
||||
const gutter =
|
||||
value(
|
||||
wide,
|
||||
/#world-timeline \{\s*width: min\(820px, calc\(100vw - ([\d.]+)rem\)\);/,
|
||||
) * rem;
|
||||
assert.ok(gutter / 2 >= 36 + 302 + 12);
|
||||
assert.ok(timelineLift > 0);
|
||||
// Toasts keep 12px above the raised dock.
|
||||
assert.equal(
|
||||
value(
|
||||
wide,
|
||||
new RegExp(`#toast \\{\\s*bottom: calc\\((\\d+)px \\+ ${lift}\\);`),
|
||||
),
|
||||
dockFloor + DOCK_HEIGHT + 12,
|
||||
);
|
||||
// The dock's panels lose the dock's rise from their height budgets.
|
||||
assert.match(
|
||||
wide,
|
||||
/\.gev-voice-panel \{[^}]*calc\(100dvh - 12rem - 74px \+ 2vh - var\(--gev-provider-lift, 0px\)\)/,
|
||||
);
|
||||
assert.match(
|
||||
block(read('./styles/ai-chat.css'), '@media (min-width: 1200px)'),
|
||||
/#gev-chat-panel \{\s*max-height: min\(34rem, calc\(100dvh - 10rem - 74px \+ 2vh\)\);/,
|
||||
);
|
||||
|
||||
// Below 1200px the corners keep the committed layout: the coordinates clear
|
||||
// the raised credit row's logo line by 6px.
|
||||
assert.ok(
|
||||
value(
|
||||
trays.slice(
|
||||
trays.indexOf(
|
||||
'/* The coordinate readout shares the bottom-left corner',
|
||||
),
|
||||
),
|
||||
new RegExp(
|
||||
`\\.hud-bottom-left \\{\\s*bottom: calc\\(2vh \\+ ([\\d.]+)rem \\+ ${lift}\\);`,
|
||||
),
|
||||
) *
|
||||
rem >=
|
||||
5 * rem + CREDIT_HEIGHT + 6,
|
||||
);
|
||||
// The desktop Omnibar layout outranks these rules; its readout keeps the
|
||||
// same 8px above Power Up.
|
||||
const omnibarReadout = value(
|
||||
read('./styles/omnibar-dock.css'),
|
||||
/#intel-hud\[data-variant='tactical'\] \.hud-bottom-right \{\s*bottom: ([\d.]+)rem;/,
|
||||
);
|
||||
assert.equal(omnibarReadout * rem, POWER_UP.bottom + POWER_UP.height + 8);
|
||||
});
|
||||
|
||||
test('scope choice and expanded feather survive every HUD layout and both restore paths', async (t) => {
|
||||
const { owner } = styleOwner(t, 'tactical');
|
||||
const previous = {
|
||||
enabled: isScopeMaskEnabled(),
|
||||
feather: getScopeMaskFeather(),
|
||||
};
|
||||
t.after(() => {
|
||||
setScopeMaskEnabled(previous.enabled);
|
||||
setScopeMaskFeather(previous.feather);
|
||||
});
|
||||
Object.assign(owner.services, { setScopeMaskEnabled, setScopeMaskFeather });
|
||||
let shown = null;
|
||||
owner.store = { publish: (view) => (shown = view.scope) };
|
||||
await owner.restoreShareState({ scopeEnabled: false, scopeFeatherPct: 200 });
|
||||
assert.deepEqual(shown, { enabled: false, featherPct: 200, opacityPct: 100 });
|
||||
for (const layout of ['minimal', 'cyber', 'tactical']) {
|
||||
owner._setHudVariant(layout);
|
||||
assert.equal(isScopeMaskEnabled(), false, layout);
|
||||
assert.equal(getScopeMaskFeather(), 2, layout);
|
||||
assert.equal(shown.enabled, false, layout);
|
||||
}
|
||||
await owner.applyVisualState({ scope: { enabled: true, featherPct: 175 } });
|
||||
assert.equal(isScopeMaskEnabled(), true);
|
||||
assert.equal(getScopeMaskFeather(), 1.75);
|
||||
assert.deepEqual(shown, { enabled: true, featherPct: 175, opacityPct: 100 });
|
||||
await owner.applyVisualState({ scope: { featherPct: 500 } });
|
||||
assert.equal(getScopeMaskFeather(), 2);
|
||||
assert.deepEqual(shown, { enabled: true, featherPct: 200, opacityPct: 100 });
|
||||
});
|
||||
|
||||
test('a shared scope opacity is restored and rides in the next share state', async (t) => {
|
||||
const { owner } = styleOwner(t, 'tactical');
|
||||
const previous = getScopeMaskOpacity();
|
||||
t.after(() => setScopeMaskOpacity(previous));
|
||||
Object.assign(owner.services, {
|
||||
setScopeMaskEnabled() {},
|
||||
setScopeMaskFeather() {},
|
||||
setScopeMaskOpacity,
|
||||
});
|
||||
let shown = null;
|
||||
owner.store = { publish: (view) => (shown = view.scope) };
|
||||
await owner.restoreShareState({ scopeOpacityPct: 60 });
|
||||
assert.equal(getScopeMaskOpacity(), 0.6);
|
||||
assert.equal(shown.opacityPct, 60);
|
||||
// A state without it leaves the opacity alone.
|
||||
await owner.restoreShareState({ scopeFeatherPct: 80 });
|
||||
assert.equal(getScopeMaskOpacity(), 0.6);
|
||||
assert.equal(shown.opacityPct, 60);
|
||||
Object.assign(owner.services, {
|
||||
getDetectionTuning: () => ({ allocationStrategy: 'ELASTIC' }),
|
||||
getDetectionMode: () => 'OFF',
|
||||
isScopeMaskEnabled: () => true,
|
||||
getScopeMaskFeather: () => 0.8,
|
||||
getScopeMaskOpacity,
|
||||
getScopeTerminusOverride: () => null,
|
||||
});
|
||||
owner.readCelestialRing = () => null;
|
||||
assert.equal(owner._readShareState().options.scopeOpacityPct, 60);
|
||||
// A link asking for less than the floor opens at the floor, and says so.
|
||||
await owner.restoreShareState({ scopeOpacityPct: 20 });
|
||||
assert.equal(getScopeMaskOpacity(), 0.5);
|
||||
assert.equal(owner._readShareState().options.scopeOpacityPct, 50);
|
||||
});
|
||||
|
||||
test('a scene shot saved with the retired Snow style plays on Normal', async (t) => {
|
||||
const { owner } = styleOwner(t, 'tactical');
|
||||
owner.setStyle('noir');
|
||||
await owner.applyVisualState({ style: 'snow' });
|
||||
assert.equal(owner.activeStyle, 'normal');
|
||||
});
|
||||
|
||||
test('shared panel hooks affect only opted-in rail surfaces without overriding disclosure and concealment', () => {
|
||||
const styles = read('./styles/panel-surfaces.css');
|
||||
const rail = cssRuleBody(
|
||||
styles,
|
||||
/:is\(#left-panel-stack, #right-context-rail\)\s+> \[data-panel-id\]:has\(> \[data-panel-surface\]\)/,
|
||||
);
|
||||
assert.match(rail, /pointer-events:\s*auto;/);
|
||||
assert.doesNotMatch(rail, /(?:display|visibility):/);
|
||||
assert.doesNotMatch(
|
||||
styles,
|
||||
/:is\(#left-panel-stack, #right-context-rail\)\s*> \[data-panel-id\]\s*\{/,
|
||||
);
|
||||
assert.match(
|
||||
styles,
|
||||
/\[data-panel-surface\]:not\(\[hidden\]\):not\(dialog:not\(\[open\]\)\)\s*\{\s*display: flex;/,
|
||||
);
|
||||
assert.match(
|
||||
styles,
|
||||
/dialog\[data-panel-surface\]:not\(\[open\]\)\s*\{\s*display: none !important;/,
|
||||
);
|
||||
assert.match(
|
||||
styles,
|
||||
/body:is\(\.ui-clean-view, \.recording-mode\)[^{]+\{[^}]*visibility: hidden !important;[^}]*pointer-events: none !important;/,
|
||||
);
|
||||
});
|
||||
@@ -50,6 +50,9 @@ export class LayerBindings {
|
||||
get _contextControls() {
|
||||
return this.readControls()._contextControls;
|
||||
}
|
||||
get _spaceMissionsControls() {
|
||||
return this.readControls()._spaceMissionsControls;
|
||||
}
|
||||
get _cctvControls() {
|
||||
return this.readControls()._cctvControls;
|
||||
}
|
||||
@@ -158,6 +161,15 @@ export class LayerBindings {
|
||||
});
|
||||
this._weatherShellModules.push(news);
|
||||
}
|
||||
// Bike share flies into a covered city from its marker the same way.
|
||||
const bikeshare = this._dataManager?.layers?.get('bikeshare')?.module;
|
||||
if (typeof bikeshare?.attachShellServices === 'function') {
|
||||
bikeshare.attachShellServices({
|
||||
runNavigation: (navigate) =>
|
||||
this.runImmediateNavigation('bike share', navigate),
|
||||
});
|
||||
this._weatherShellModules.push(bikeshare);
|
||||
}
|
||||
}
|
||||
|
||||
_persistAwarenessSelection(event, cleared = false) {
|
||||
@@ -245,6 +257,7 @@ export class LayerBindings {
|
||||
this._dataManagerUnsubscribe = null;
|
||||
}
|
||||
this._contextControls.connect(this._dataManager);
|
||||
this._spaceMissionsControls?.connect(this._dataManager);
|
||||
if (typeof this._dataManager?.subscribe === 'function') {
|
||||
this._dataManagerUnsubscribe = this._dataManager.subscribe((change) => {
|
||||
this._feedback._loadingFeedbackEvent = change;
|
||||
@@ -310,6 +323,7 @@ export class LayerBindings {
|
||||
this._directionsShellModule?.attachShellServices?.(null);
|
||||
this._directionsShellModule = null;
|
||||
this._dataManager = null;
|
||||
this._spaceMissionsControls?.connect(null);
|
||||
this._connectWeatherCamera();
|
||||
}
|
||||
}
|
||||
+48
-14
@@ -7,6 +7,27 @@ import {
|
||||
import { measurePanelNaturalHeight } from './panelMeasurement.js';
|
||||
import { settleSideAccordion } from './panelAccordion.js';
|
||||
|
||||
/**
|
||||
* Whether the desktop Omnibar dock is laid out, by the condition
|
||||
* omnibar-dock.css lays it out by: the bar and the voice control in the
|
||||
* dock, outside the phone layout, the cockpit, playback, clean view and
|
||||
* recording.
|
||||
*/
|
||||
const DOCK_OFF = [
|
||||
'mobile-shell',
|
||||
'cockpit-mode',
|
||||
'scene-playback-mode',
|
||||
'ui-clean-view',
|
||||
'recording-mode',
|
||||
];
|
||||
function desktopOmnibarDock(documentRef) {
|
||||
if (!documentRef?.getElementById?.('gev-omnibar')) return false;
|
||||
const body = documentRef.body;
|
||||
if (DOCK_OFF.some((name) => body?.classList?.contains?.(name))) return false;
|
||||
const voice = documentRef.getElementById('gev-voice-control');
|
||||
return Boolean(voice) && voice.parentElement?.id === 'command-dock';
|
||||
}
|
||||
|
||||
/**
|
||||
* Measure and place the left panel rail for one synchronous layout pass.
|
||||
* The caller owns scheduling, obstacle selection, disclosure preferences and
|
||||
@@ -115,8 +136,15 @@ export function layoutLeftPanelRail({
|
||||
if (hiddenByAncestor) continue;
|
||||
const rect = obstacle.getBoundingClientRect();
|
||||
if (rect.width <= 0 || rect.height <= 0) continue;
|
||||
const overlapsHorizontally =
|
||||
rect.right > stackRect.left && rect.left < stackRect.right;
|
||||
// The centered controls can enter the stack's transparent outer gutter.
|
||||
// Only constrain the lane if they reach an expanded panel itself, whose
|
||||
// actual bounds also include the edge-rail offset.
|
||||
const lanes = ['world-timeline', 'gev-voice-control'].includes(obstacle.id)
|
||||
? laidOutPanels.map((panel) => panel.getBoundingClientRect())
|
||||
: [stackRect];
|
||||
const overlapsHorizontally = lanes.some(
|
||||
(lane) => rect.right > lane.left && rect.left < lane.right,
|
||||
);
|
||||
if (!overlapsHorizontally) continue;
|
||||
|
||||
if (rect.top < baseTop && rect.bottom <= viewportHeight * 0.5) {
|
||||
@@ -220,11 +248,20 @@ export function layoutLeftPanelRail({
|
||||
const tailLayoutBottom = tailLayoutTop + tailRequiredHeight;
|
||||
const tailAvailableHeight = Math.max(0, obstacleSafeBottom - obstacleSafeTop);
|
||||
const tailTolerance = wasTail ? stabilityBand : -stabilityBand;
|
||||
// Data Layers has a scrollable list and a fixed footer. Give it the full
|
||||
// desktop lane while short control panels keep their natural height.
|
||||
const fillDataLayers =
|
||||
exclusive &&
|
||||
expandedPanels.length === 1 &&
|
||||
expandedPanels[0].id === 'data-panel' &&
|
||||
desktopOmnibarDock(documentRef);
|
||||
const shouldTail =
|
||||
!fillDataLayers &&
|
||||
expandedPanels.length > 0 &&
|
||||
tailLayoutTop >= obstacleSafeTop - tailTolerance &&
|
||||
tailLayoutBottom <= obstacleSafeBottom + tailTolerance;
|
||||
const shouldFocus = exceedsCenteredCorridor && !shouldTail;
|
||||
const shouldFocus =
|
||||
fillDataLayers || (exceedsCenteredCorridor && !shouldTail);
|
||||
// Focus mode owns the lane, so let every expanded panel share the full
|
||||
// obstacle-safe corridor. Tail/normal layouts keep the balanced
|
||||
// viewport centering used for compact accordion stacks.
|
||||
@@ -250,10 +287,12 @@ export function layoutLeftPanelRail({
|
||||
rowGap * Math.max(0, expandedPanels.length - 1),
|
||||
)
|
||||
: naturalExpandedHeight;
|
||||
const allocatedExpandedHeights = allocatePanelStackHeights({
|
||||
naturalHeights: naturalExpandedHeights,
|
||||
availableHeight: expandedAvailableHeight,
|
||||
});
|
||||
const allocatedExpandedHeights = fillDataLayers
|
||||
? [expandedAvailableHeight]
|
||||
: allocatePanelStackHeights({
|
||||
naturalHeights: naturalExpandedHeights,
|
||||
availableHeight: expandedAvailableHeight,
|
||||
});
|
||||
const autoCollapseIndices = hud.visible
|
||||
? panelStackAutoCollapseIndices({
|
||||
naturalHeights: naturalExpandedHeights,
|
||||
@@ -278,21 +317,16 @@ export function layoutLeftPanelRail({
|
||||
stack.style.setProperty('--left-stack-safe-bottom', bottomValue);
|
||||
}
|
||||
// The rail stays where the resting stack puts it; only the panels move.
|
||||
// A theme that pins the stack's top (Cyber) leaves nothing to offset.
|
||||
const topPinned =
|
||||
getComputedStyle(stack)
|
||||
.getPropertyValue?.('--panel-stack-top-pinned')
|
||||
?.trim() === '1';
|
||||
// The stack itself rises by the lift below, by a different amount for a
|
||||
// tall panel than at rest; the rail takes up the difference.
|
||||
const lift = (top) => Math.min(0, obstacleSafeTop - top);
|
||||
const railOffset = `${(topPinned ? 0 : safeTop + lift(safeTop) - layoutTop - lift(layoutTop)).toFixed(1)}px`;
|
||||
const railOffset = `${(safeTop + lift(safeTop) - layoutTop - lift(layoutTop)).toFixed(1)}px`;
|
||||
if (stack.style.getPropertyValue('--panel-rail-offset') !== railOffset) {
|
||||
stack.style.setProperty('--panel-rail-offset', railOffset);
|
||||
}
|
||||
// How far the column can rise before it meets the HUD readout, so the rail
|
||||
// and any open panel sit just under it, whether or not a panel is open.
|
||||
const railLift = `${(topPinned ? 0 : lift(layoutTop)).toFixed(1)}px`;
|
||||
const railLift = `${lift(layoutTop).toFixed(1)}px`;
|
||||
if (stack.style.getPropertyValue('--panel-rail-lift') !== railLift) {
|
||||
stack.style.setProperty('--panel-rail-lift', railLift);
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ export class LocationControls {
|
||||
onCity,
|
||||
onPoi,
|
||||
onSearch,
|
||||
onSearchEdit,
|
||||
onReset,
|
||||
publish,
|
||||
doc,
|
||||
@@ -74,6 +75,7 @@ export class LocationControls {
|
||||
poi: t('Landmark: --'),
|
||||
};
|
||||
this.searchError = null;
|
||||
this.searchOrigin = 'dock';
|
||||
// The search field: whether it is open, and whether a lookup runs.
|
||||
this.searchExpanded = Boolean(searchExpanded);
|
||||
this.searching = false;
|
||||
@@ -96,12 +98,16 @@ export class LocationControls {
|
||||
onPoi(cityId, index);
|
||||
});
|
||||
this.bind(elements.search, 'keydown', (event) => {
|
||||
if (event.key === 'Enter') void onSearch(elements.search.value);
|
||||
if (event.key === 'Enter')
|
||||
void this.search(elements.search.value, { origin: 'dock' });
|
||||
});
|
||||
// Typing corrects a failed query; closing the field (which empties it) drops its error.
|
||||
this.bind(elements.search, 'input', () => onSearchEdit?.());
|
||||
this.bind(elements.search, 'input', () => {
|
||||
if (this.searchOrigin === 'dock') onSearchEdit?.();
|
||||
});
|
||||
this.bind(elements.search, 'blur', () => {
|
||||
if (!elements.search.value) onSearchEdit?.();
|
||||
if (this.searchOrigin === 'dock' && !elements.search.value)
|
||||
onSearchEdit?.();
|
||||
});
|
||||
this.present();
|
||||
}
|
||||
@@ -138,9 +144,29 @@ export class LocationControls {
|
||||
searchError: this.searchError,
|
||||
searchExpanded: this.searchExpanded,
|
||||
searching: this.searching,
|
||||
searchOrigin: this.searchOrigin,
|
||||
orbit: this.orbit && { ...this.orbit },
|
||||
};
|
||||
}
|
||||
/** Search through the same lifecycle as the location field. */
|
||||
search(query, { origin = 'omnibar' } = {}) {
|
||||
if (this.destroyed || !String(query || '').trim()) return false;
|
||||
this._requestedSearchOrigin = origin;
|
||||
// Beginning navigation synchronously settles the previous lookup. That
|
||||
// handoff must not clear or blur the draft just submitted by either field.
|
||||
this._startingSearch = true;
|
||||
try {
|
||||
return this.onSearch(query);
|
||||
} finally {
|
||||
this._startingSearch = false;
|
||||
this._requestedSearchOrigin = null;
|
||||
}
|
||||
}
|
||||
/** Editing an external query clears its prior lookup error. */
|
||||
editSearch() {
|
||||
if (!this.destroyed && this.searchOrigin === 'omnibar')
|
||||
this.onSearchEdit?.();
|
||||
}
|
||||
/** A city pill was clicked. */
|
||||
chooseCity(id) {
|
||||
if (!this.destroyed) this.onCity(id);
|
||||
@@ -233,6 +259,8 @@ export class LocationControls {
|
||||
/** Mark the search field while a lookup runs. */
|
||||
setSearching(active) {
|
||||
if (this.destroyed) return;
|
||||
if (active && this._requestedSearchOrigin)
|
||||
this.searchOrigin = this._requestedSearchOrigin;
|
||||
this.searching = Boolean(active);
|
||||
this.present();
|
||||
}
|
||||
@@ -243,6 +271,10 @@ export class LocationControls {
|
||||
settleSearch({ keepQuery = false } = {}) {
|
||||
if (this.destroyed) return;
|
||||
this.searching = false;
|
||||
if (this._startingSearch || this.searchOrigin === 'omnibar') {
|
||||
this.present();
|
||||
return;
|
||||
}
|
||||
if (!keepQuery) {
|
||||
this.closeSearch();
|
||||
return;
|
||||
|
||||
@@ -108,6 +108,7 @@ test('the tray presents its cities, empty status and no landmarks at first', ()
|
||||
searchError: null,
|
||||
searchExpanded: false,
|
||||
searching: false,
|
||||
searchOrigin: 'dock',
|
||||
orbit: null,
|
||||
});
|
||||
f.controls.highlightCity('b');
|
||||
|
||||
@@ -3,6 +3,7 @@ import { stopFollowing } from '../data/followed.js';
|
||||
import { t } from '../i18n/index.js';
|
||||
import { createStateChannel } from '../app/stateChannel.js';
|
||||
import { LocationControls } from './location.js';
|
||||
import { worldClock } from '../time/worldClock.js';
|
||||
|
||||
/** Own destination selection, lookup, orbit and world-jump lifetime. */
|
||||
export class LocationNavigation {
|
||||
@@ -14,10 +15,11 @@ export class LocationNavigation {
|
||||
navigation,
|
||||
readCockpit,
|
||||
operations,
|
||||
homeView = null,
|
||||
}) {
|
||||
Object.assign(
|
||||
this,
|
||||
{ viewer, placeSearch, services, navigation, readCockpit },
|
||||
{ viewer, placeSearch, services, navigation, readCockpit, homeView },
|
||||
elements,
|
||||
operations,
|
||||
);
|
||||
@@ -315,7 +317,24 @@ export class LocationNavigation {
|
||||
}
|
||||
}
|
||||
|
||||
resetToGlobeView() {
|
||||
/**
|
||||
* Back to live, at the view the app started from (the logo): the world
|
||||
* clock goes live and the camera flies to the start view as the globe reset
|
||||
* does, letting go of whatever it follows.
|
||||
*/
|
||||
returnToStart() {
|
||||
if (!this._disposed) worldClock.goLive();
|
||||
if (!this.homeView) return this.resetToGlobeView();
|
||||
// A globe reset under way flies elsewhere: this one replaces it.
|
||||
this._cancelGlobeReset?.();
|
||||
return this.resetToGlobeView({ view: this.homeView });
|
||||
}
|
||||
|
||||
/**
|
||||
* Fly out to the full globe over the current spot, or to `view` (the start
|
||||
* view's shape: `{ lon, lat, height, heading?, pitch? }`, degrees).
|
||||
*/
|
||||
resetToGlobeView({ view = null } = {}) {
|
||||
const {
|
||||
GLOBE_VIEW,
|
||||
flyToGlobeView,
|
||||
@@ -374,6 +393,7 @@ export class LocationNavigation {
|
||||
camera?.release();
|
||||
this._beginWorldJumpTransition();
|
||||
|
||||
const heightM = view?.height ?? GLOBE_VIEW.heightM;
|
||||
let resolveReset;
|
||||
const resetPromise = new Promise((resolve) => {
|
||||
resolveReset = resolve;
|
||||
@@ -391,7 +411,7 @@ export class LocationNavigation {
|
||||
ok: !cancelled,
|
||||
action: 'zoom_to_globe',
|
||||
cancelled,
|
||||
heightKm: Math.round(GLOBE_VIEW.heightM / 1000),
|
||||
heightKm: Math.round(heightM / 1000),
|
||||
centeredOn: {
|
||||
latitude: Number.isFinite(pose?.lat)
|
||||
? Number(pose.lat.toFixed(2))
|
||||
@@ -409,15 +429,13 @@ export class LocationNavigation {
|
||||
this._cancelGlobeReset = () => finish(true);
|
||||
timer = window.setTimeout(() => {
|
||||
const height = findCamera(this.viewer)?.pose().height;
|
||||
finish(
|
||||
!Number.isFinite(height) ||
|
||||
Math.abs(height - GLOBE_VIEW.heightM) > 1000,
|
||||
);
|
||||
finish(!Number.isFinite(height) || Math.abs(height - heightM) > 1000);
|
||||
}, 4200);
|
||||
this._publishGlobeResetting?.(true);
|
||||
const target = flyToGlobeView(this.viewer, {
|
||||
onComplete: () => finish(false),
|
||||
onCancel: () => finish(true),
|
||||
...(view ? { view } : {}),
|
||||
});
|
||||
if (!target) finish(true);
|
||||
return resetPromise;
|
||||
|
||||
@@ -101,6 +101,8 @@ export class LocationSearch {
|
||||
destination: { ...destination },
|
||||
};
|
||||
this.channel.publish(change('found'));
|
||||
// Found and still the current search: a plan may go on.
|
||||
return current() && !controller.signal.aborted;
|
||||
} else {
|
||||
this.onMissing?.();
|
||||
if (!current() || controller.signal.aborted) return;
|
||||
|
||||
@@ -6,14 +6,14 @@ import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createPinia } from 'pinia';
|
||||
import { createApp, h, nextTick } from 'vue';
|
||||
import { useContextStore } from './stores/context.js';
|
||||
import { useSpaceMissionsStore } from './stores/spaceMissions.js';
|
||||
import MissionDetail from './views/panels/MissionDetail.vue';
|
||||
import MissionRoster from './views/panels/MissionRoster.vue';
|
||||
|
||||
function fixture(t) {
|
||||
document.body.replaceChildren();
|
||||
const scroller = document.body.appendChild(document.createElement('div'));
|
||||
scroller.className = 'global-context-panel-inner';
|
||||
scroller.className = 'space-missions-panel-inner';
|
||||
const host = scroller.appendChild(document.createElement('div'));
|
||||
const pinia = createPinia();
|
||||
const app = createApp({
|
||||
@@ -21,13 +21,13 @@ function fixture(t) {
|
||||
}).use(pinia);
|
||||
app.mount(host);
|
||||
t.after(() => app.unmount());
|
||||
const store = useContextStore(pinia);
|
||||
const store = useSpaceMissionsStore(pinia);
|
||||
const calls = [];
|
||||
const record =
|
||||
(name) =>
|
||||
(...args) =>
|
||||
calls.push([name, ...args]);
|
||||
store.connectMissions({
|
||||
store.connect({
|
||||
selectMissionAt: record('select'),
|
||||
selectPreviousMission: record('previous'),
|
||||
selectNextMission: record('next'),
|
||||
@@ -44,7 +44,7 @@ function fixture(t) {
|
||||
});
|
||||
const $ = (selector) => document.querySelector(selector);
|
||||
const publish = async (view) => {
|
||||
store.publishMissions(view);
|
||||
store.publish(view);
|
||||
await nextTick();
|
||||
await nextTick();
|
||||
};
|
||||
@@ -325,7 +325,7 @@ test('the replay controls follow the layer and call its commands', async (t) =>
|
||||
]);
|
||||
});
|
||||
|
||||
test('each newly presented selection returns the Context panel to the top', async (t) => {
|
||||
test('each newly presented selection returns the Space Missions panel to the top', async (t) => {
|
||||
const { publish, scroller } = fixture(t);
|
||||
scroller.scrollTop = 120;
|
||||
await publish({ roster: null, mission: mission({ scrollRequest: 4 }) });
|
||||
|
||||
+23
-2
@@ -30,6 +30,7 @@ export const MOBILE_SHEET_PANELS = Object.freeze({
|
||||
layers: Object.freeze(['data-panel']),
|
||||
cameras: Object.freeze(['cctv-panel', 'street-level-panel']),
|
||||
context: Object.freeze(['global-context-panel']),
|
||||
missions: Object.freeze(['space-missions-panel']),
|
||||
search: Object.freeze(['location-bar']),
|
||||
more: Object.freeze(['control-panel', 'pp-toggles']),
|
||||
});
|
||||
@@ -38,6 +39,11 @@ export const MOBILE_TABS = Object.freeze([
|
||||
Object.freeze({ sheet: 'layers', label: msg('Layers'), icon: 'layers' }),
|
||||
Object.freeze({ sheet: 'cameras', label: msg('Cameras'), icon: 'videocam' }),
|
||||
Object.freeze({ sheet: 'context', label: msg('Context'), icon: 'radar' }),
|
||||
Object.freeze({
|
||||
sheet: 'missions',
|
||||
label: msg('Space Missions'),
|
||||
icon: 'rocket_launch',
|
||||
}),
|
||||
Object.freeze({ sheet: 'search', label: msg('Search'), icon: 'search' }),
|
||||
Object.freeze({ sheet: 'more', label: msg('More'), icon: 'more_horiz' }),
|
||||
]);
|
||||
@@ -142,6 +148,7 @@ export function initMobileShell({
|
||||
.map(element)
|
||||
.filter(Boolean);
|
||||
const dock = element('command-dock');
|
||||
const missionsPanel = element('space-missions-panel');
|
||||
const shown = (node) =>
|
||||
node && globalThis.getComputedStyle?.(node).display !== 'none';
|
||||
|
||||
@@ -254,7 +261,9 @@ export function initMobileShell({
|
||||
const setSheet = (requested) => {
|
||||
swipe = null;
|
||||
if (!body.classList.contains(MOBILE_SHELL_CLASS)) return;
|
||||
const sheet = sheetBlocked(body) ? null : requested;
|
||||
const unavailableMissions =
|
||||
requested === 'missions' && missionsPanel?.hidden;
|
||||
const sheet = sheetBlocked(body) || unavailableMissions ? null : requested;
|
||||
const previous = currentSheetOf(body);
|
||||
if (previous === sheet) return;
|
||||
if (!previous) {
|
||||
@@ -487,9 +496,21 @@ export function initMobileShell({
|
||||
|
||||
if (typeof MutationObserverImpl === 'function') {
|
||||
const observer = new MutationObserverImpl(() => {
|
||||
if (currentSheetOf(body) && sheetBlocked(body)) setSheet(null);
|
||||
const sheet = currentSheetOf(body);
|
||||
if (!sheet) return;
|
||||
if (sheet === 'missions' && missionsPanel?.hidden) {
|
||||
returnFocus = tabFor('layers') ?? returnFocus;
|
||||
setSheet(null);
|
||||
} else if (sheetBlocked(body)) {
|
||||
setSheet(null);
|
||||
}
|
||||
});
|
||||
observer.observe(body, { attributes: true, attributeFilter: ['class'] });
|
||||
if (missionsPanel)
|
||||
observer.observe(missionsPanel, {
|
||||
attributes: true,
|
||||
attributeFilter: ['hidden'],
|
||||
});
|
||||
removers.push(() => observer.disconnect());
|
||||
}
|
||||
|
||||
|
||||
@@ -903,12 +903,11 @@ test('manual Context opens the existing transaction without disabling the tracke
|
||||
}
|
||||
});
|
||||
|
||||
test('manual Context respects Space Missions, busy transitions, missing tracks and disposal', async () => {
|
||||
test('manual Context respects an active mode, busy transitions, missing tracks and disposal', async () => {
|
||||
for (const state of [
|
||||
{ mode: 'space-missions' },
|
||||
{ mode: 'flights' },
|
||||
{ changing: true },
|
||||
{ entering: 'space-missions' },
|
||||
{ entering: 'flights' },
|
||||
{ noTrack: true },
|
||||
{ disposed: true },
|
||||
{ sheet: 'layers' },
|
||||
|
||||
+34
-11
@@ -1,6 +1,6 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { t } from '../../i18n/index.js';
|
||||
import { formatNumber, t, tn } from '../../i18n/index.js';
|
||||
import UiButton from '../kit/UiButton.vue';
|
||||
import UiEmpty from '../kit/UiEmpty.vue';
|
||||
import UiSelect from '../kit/UiSelect.js';
|
||||
@@ -63,9 +63,15 @@ const categoryOptions = computed(() => [
|
||||
const windowOptions = computed(() =>
|
||||
(props.view?.windowChoices ?? []).map((hours) => ({
|
||||
value: String(hours),
|
||||
label: t('Last {hours} h', { hours }),
|
||||
label: lastHours(hours),
|
||||
})),
|
||||
);
|
||||
// The window offers 1 h, so every hour count is a plural: es «Última 1 h».
|
||||
function lastHours(hours) {
|
||||
return tn(hours, 'Last {hours} h', 'Last {hours} h', {
|
||||
hours: formatNumber(hours),
|
||||
});
|
||||
}
|
||||
// The longest choice is the server's whole window, kept as no choice.
|
||||
const chooseWindow = (hours) =>
|
||||
setFilter('hours', hours === props.view?.windowChoices?.[0] ? null : hours);
|
||||
@@ -109,7 +115,16 @@ const clear = () => props.onParams({ clear: true });
|
||||
<section
|
||||
v-if="view"
|
||||
class="news-readout"
|
||||
:aria-label="t('News, last {hours} hours', { hours: view.windowHours })"
|
||||
:aria-label="
|
||||
tn(
|
||||
view.windowHours,
|
||||
'News, last {hours} hour',
|
||||
'News, last {hours} hours',
|
||||
{
|
||||
hours: formatNumber(view.windowHours),
|
||||
},
|
||||
)
|
||||
"
|
||||
>
|
||||
<UiSelect
|
||||
v-if="windowOptions.length > 1"
|
||||
@@ -120,7 +135,7 @@ const clear = () => props.onParams({ clear: true });
|
||||
@update:model-value="chooseWindow(Number($event))"
|
||||
/>
|
||||
<p v-else class="news-readout__window ui-mono">{{
|
||||
t('Last {hours} h', { hours: view.windowHours })
|
||||
lastHours(view.windowHours)
|
||||
}}</p>
|
||||
<div
|
||||
class="news-readout__sections"
|
||||
@@ -196,9 +211,12 @@ const clear = () => props.onParams({ clear: true });
|
||||
v-else-if="!view.inView.items.length && !view.inView.loading"
|
||||
class="news-readout__empty"
|
||||
:title="
|
||||
t('Nothing reported near here in the last {hours} h', {
|
||||
hours: view.windowHours,
|
||||
})
|
||||
tn(
|
||||
view.windowHours,
|
||||
'Nothing reported near here in the last {hours} h',
|
||||
'Nothing reported near here in the last {hours} h',
|
||||
{ hours: formatNumber(view.windowHours) },
|
||||
)
|
||||
"
|
||||
/>
|
||||
<ol
|
||||
@@ -223,7 +241,9 @@ const clear = () => props.onParams({ clear: true });
|
||||
class="news-readout__section"
|
||||
:aria-label="t('Latest news')"
|
||||
>
|
||||
<h3 class="news-readout__head ui-mono">{{ t('Latest') }}</h3>
|
||||
<h3 class="news-readout__head ui-mono">{{
|
||||
t('Latest', { context: 'news list' })
|
||||
}}</h3>
|
||||
<UiEmpty
|
||||
v-if="view.key"
|
||||
class="news-readout__empty"
|
||||
@@ -247,9 +267,12 @@ const clear = () => props.onParams({ clear: true });
|
||||
v-else-if="!view.loading && !view.error"
|
||||
class="news-readout__empty"
|
||||
:title="
|
||||
t('No news matches these filters in the last {hours} h', {
|
||||
hours: view.windowHours,
|
||||
})
|
||||
tn(
|
||||
view.windowHours,
|
||||
'No news matches these filters in the last {hours} h',
|
||||
'No news matches these filters in the last {hours} h',
|
||||
{ hours: formatNumber(view.windowHours) },
|
||||
)
|
||||
"
|
||||
/>
|
||||
<div class="news-readout__footer">
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import '../testSupport/registerDom.mjs';
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { setLocale } from '../i18n/index.js';
|
||||
import { createNewsPanel } from './newsPanel.js';
|
||||
import {
|
||||
NEWS_CATEGORIES,
|
||||
@@ -385,6 +386,54 @@ test('the window choice offers shorter windows; the longest is the server window
|
||||
assert.deepEqual(calls.at(-1)[1], { filters: { hours: null } });
|
||||
});
|
||||
|
||||
test('the time window agrees with its number of hours', (t) => {
|
||||
t.after(() => setLocale('en'));
|
||||
setLocale('es');
|
||||
const { news, panel } = fixture();
|
||||
news.update(view({ windowHours: 24, windowChoices: [24, 12, 6, 3, 1] }));
|
||||
const choice = panel.querySelector(
|
||||
'select.news-readout__window-choice, .news-readout__window-choice select',
|
||||
);
|
||||
assert.deepEqual(
|
||||
[...choice.options].map((option) => option.textContent),
|
||||
['Últimas 24 h', 'Últimas 12 h', 'Últimas 6 h', 'Últimas 3 h', 'Última 1 h'],
|
||||
);
|
||||
news.update(view({ windowHours: 1, items: [], hasMore: false }));
|
||||
assert.equal(
|
||||
panel.querySelector('.news-readout__window').textContent,
|
||||
'Última 1 h',
|
||||
);
|
||||
assert.equal(
|
||||
panel.querySelector('.news-readout').getAttribute('aria-label'),
|
||||
'Noticias de la última 1 hora',
|
||||
);
|
||||
assert.match(
|
||||
panel.textContent,
|
||||
/En la última 1 h no hay noticias que coincidan con estos filtros/,
|
||||
);
|
||||
setLocale('ru');
|
||||
news.update(view({ windowHours: 1, items: [], hasMore: false }));
|
||||
assert.equal(
|
||||
panel.querySelector('.news-readout').getAttribute('aria-label'),
|
||||
'Новости за последний 1 час',
|
||||
);
|
||||
news.update(view({ windowHours: 12, items: [], hasMore: false }));
|
||||
assert.equal(
|
||||
panel.querySelector('.news-readout').getAttribute('aria-label'),
|
||||
'Новости за последние 12 часов',
|
||||
);
|
||||
news.destroy();
|
||||
});
|
||||
|
||||
test('the Latest news heading agrees with the news it heads (fr)', (t) => {
|
||||
t.after(() => setLocale('en'));
|
||||
setLocale('fr');
|
||||
const { news, panel } = fixture();
|
||||
news.update(view());
|
||||
assert.equal(panel.querySelector('.news-readout__head').textContent, 'Dernières');
|
||||
news.destroy();
|
||||
});
|
||||
|
||||
test('the panel names the window the server serves', () => {
|
||||
const { news, panel } = fixture();
|
||||
news.update(view({ windowHours: 12 }));
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
// What Enter does in the Omnibar before a row is chosen with the keyboard:
|
||||
// the one rule, in one place. The rows come from src/ui/omnibarRows.js; the
|
||||
// text this rule reads is the line after readLine (omnibarRows.js).
|
||||
//
|
||||
// Enter performs an action (a plan, a layer switch, a command, Ask GEV) only
|
||||
// when the line asks for it outright:
|
||||
// (a) the action's own clause starts with a verb from ACTION_VERB (one
|
||||
// list, in omnibarIntent.js): "show flights", "play radio in Tokyo",
|
||||
// "go to Austin and show flights". A verb inside a place's name asks
|
||||
// for nothing ("radio near Clear Lake");
|
||||
// (b) or the line is a command's exact label, alone or after ">" ("North
|
||||
// up", "> Clear all layers"); a command row runs on nothing else;
|
||||
// (c) or, for Ask GEV, it is a real question (isRealQuestion).
|
||||
// A whole layer name with a place after near, in, around, over, across or
|
||||
// above ("flights near Tokyo"; not "of" or "at": "Planes of Fame") asks
|
||||
// outright too. Keywords without a verb ask for nothing, however many
|
||||
// clauses they fill ("Fire and Rain", "noir and cctv near austin"). Otherwise
|
||||
// the place row is the default, and any plan or command is offered after
|
||||
// it. A guide found by forgiving a typo, or on a line written as a title
|
||||
// ("How To Train Your Dragon"), is offered, never run. Some actions need
|
||||
// more:
|
||||
// - sound (the Radio layer and radio steps), clearing the map, closing
|
||||
// panels and the cockpit need (a) or (b);
|
||||
// - the microphone, sharing the view, resetting it and the globe view
|
||||
// need (b);
|
||||
// - a layer row runs only when the line names that layer before any
|
||||
// other (the row's `best`): "show flights" with Flights already on
|
||||
// offers Flights, never Military Flights.
|
||||
// Only the first row can be the default, and the pointer never makes one:
|
||||
// a hovered row is chosen by a click, and the arrow keys choose any row.
|
||||
|
||||
import { hasActionVerb, isRealQuestion } from './omnibarIntent.js';
|
||||
|
||||
/**
|
||||
* Words that are both the name of a bundled place (wikidata_cities or
|
||||
* wikidata_places) and, alone, a command, style or layer word. Typed alone
|
||||
* they search the place first and offer the switch second. Found by sweeping
|
||||
* every bundled name through the Omnibar (see docs/CURRENT-STATE.md); a test
|
||||
* checks each is still a bundled name.
|
||||
*/
|
||||
export const PLACE_WORDS = new Set([
|
||||
'bike',
|
||||
'hurricane',
|
||||
'normal',
|
||||
'rain',
|
||||
'ski',
|
||||
'street',
|
||||
'thermal',
|
||||
]);
|
||||
|
||||
/** Whether the whole line is one of PLACE_WORDS, in any case. */
|
||||
export function isPlaceWord(text) {
|
||||
return PLACE_WORDS.has(
|
||||
String(text || '')
|
||||
.trim()
|
||||
.toLowerCase(),
|
||||
);
|
||||
}
|
||||
|
||||
/** Layers whose switching on starts sound. */
|
||||
export const SOUND_LAYERS = new Set(['radio']);
|
||||
/** Camera moves that only their exact label asks for (b). */
|
||||
const NAMED_ONLY = new Set(['share', 'reset', 'zoom_to_globe']);
|
||||
|
||||
/**
|
||||
* Whether a plan's steps ask for themselves. Verbs are read per clause: the
|
||||
* parser marks each step whose own clause had one (`parsed.asked`), so a verb
|
||||
* inside a place's name ("radio near Clear Lake") asks for nothing.
|
||||
* @param {Array<object>} steps
|
||||
* @param {{named: boolean, parsed: object}} line
|
||||
*/
|
||||
function planAsked(steps, { named, parsed }) {
|
||||
if (named) return true;
|
||||
const asked = parsed?.asked || new Set();
|
||||
const requests = steps.filter((step) => step.kind !== 'place');
|
||||
for (const step of requests) {
|
||||
if (step.kind === 'camera' && NAMED_ONLY.has(step.act || step.name))
|
||||
return false;
|
||||
const needsVerb =
|
||||
(step.kind === 'camera' && step.act === 'clear') ||
|
||||
(step.kind === 'panel' && step.action === 'close') ||
|
||||
step.kind === 'cockpit' ||
|
||||
step.kind === 'radio' ||
|
||||
(step.kind === 'layer' && SOUND_LAYERS.has(step.layer.id));
|
||||
if (needsVerb && !asked.has(step)) return false;
|
||||
}
|
||||
if (!requests.length) return false;
|
||||
// Every request asked for by a verb in its own clause. Keywords alone ask
|
||||
// for nothing, however many clauses they fill ("Fire and Rain", "Noir
|
||||
// and Thermal", "New York City noir").
|
||||
if (requests.every((step) => asked.has(step))) return true;
|
||||
// "flights near Tokyo": a whole layer name, and a place after near/in.
|
||||
const [only] = requests;
|
||||
// Only that one request: a bare keyword beside it ("flights near Austin
|
||||
// and noir") is not asked for.
|
||||
return (
|
||||
requests.length === 1 &&
|
||||
only.kind === 'layer' &&
|
||||
only.layer.exact !== false &&
|
||||
parsed?.placeFrom === 'near'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether Enter may run this row without it being chosen.
|
||||
* @param {object} item A row.
|
||||
* @param {string} text The typed line.
|
||||
* @param {object} parsed The line as parseOmnibar read it.
|
||||
* @param {{named: boolean}} context `named`: the line is a command's exact
|
||||
* label.
|
||||
*/
|
||||
export function mayRunOnEnter(item, text, parsed, context) {
|
||||
const verb = hasActionVerb(text);
|
||||
switch (item?.kind) {
|
||||
case 'guide':
|
||||
// A walk found by a typo, or a line written as a title ("How To Train
|
||||
// Your Dragon"), is offered, never run.
|
||||
return !item.loose && !item.titled;
|
||||
case 'place':
|
||||
// A row only for picking ("Search … anyway") never runs on Enter.
|
||||
return !item.explicit;
|
||||
case 'count-show':
|
||||
case 'entity':
|
||||
case 'view-ask':
|
||||
case 'sel-fly':
|
||||
case 'sel-follow':
|
||||
case 'sel-cockpit':
|
||||
case 'sel-ask':
|
||||
case 'sel-close':
|
||||
return true;
|
||||
case 'ask':
|
||||
return isRealQuestion(text);
|
||||
case 'layer':
|
||||
return (
|
||||
Boolean(item.best) &&
|
||||
(!SOUND_LAYERS.has(item.id) || !item.enabled || verb || context.named)
|
||||
);
|
||||
case 'mic':
|
||||
return Boolean(item.named);
|
||||
case 'open-draw':
|
||||
return verb;
|
||||
case 'plan':
|
||||
// A command row runs on its exact label only; a verb that merely
|
||||
// lists it ("hide", "turn off") offers it.
|
||||
if (item.command) return Boolean(item.named);
|
||||
return planAsked(item.steps || [], { named: context.named, parsed });
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The rows in the order shown: when the first may not run on Enter, the
|
||||
* first place row moves ahead of it, so Enter searches the place.
|
||||
*/
|
||||
export function orderForEnter(items, text, parsed, context) {
|
||||
const first = items[0];
|
||||
// A question without "?" still offers a place first when there is one.
|
||||
const askFirst = first?.kind === 'ask' && !String(text).includes('?');
|
||||
if (!first || (!askFirst && mayRunOnEnter(first, text, parsed, context)))
|
||||
return items;
|
||||
const place = items.findIndex((item) => item.kind === 'place');
|
||||
if (place <= 0) return items;
|
||||
return [items[place], ...items.slice(0, place), ...items.slice(place + 1)];
|
||||
}
|
||||
|
||||
/** The row Enter runs before one is chosen with the keyboard, or -1. */
|
||||
export function enterDefault(items, text, parsed, context) {
|
||||
const line = String(text || '').trim();
|
||||
if (!line || /^>\s*$/.test(line)) return -1;
|
||||
return items.length && mayRunOnEnter(items[0], line, parsed, context)
|
||||
? 0
|
||||
: -1;
|
||||
}
|
||||
@@ -0,0 +1,711 @@
|
||||
// "Show me how": a short guided walk through the real controls. Each step
|
||||
// spotlights the control to press, explains it in one line, and waits until
|
||||
// the visitor presses it (or the step is already done), then moves on. It
|
||||
// does not press the controls the walk is about. A layer walk clears
|
||||
// layer-list filter chips only when they would hide the row it is about;
|
||||
// steps scroll their target into view.
|
||||
//
|
||||
// The callout is a non-modal dialog: focus moves to it when a walk starts,
|
||||
// the rest of the page stays usable (the walk is about pressing it), Escape
|
||||
// ends the walk and no other key is taken.
|
||||
//
|
||||
// Recipes are data: any data layer gets one from its id, and the main
|
||||
// features (styles, HUD, compass, tilt, globe view, share, clear) have their
|
||||
// own. The walk works the same for all of them.
|
||||
|
||||
import { t } from '../i18n/index.js';
|
||||
import { EXCLUSIVE_SURFACE_CLASSES } from '../exclusiveSurfaces.js';
|
||||
import { LABEL_LAYERS } from './contextLayerTabs.js';
|
||||
|
||||
const LEFT_RAIL = '.ui-rail--left .ui-rail__item';
|
||||
const RIGHT_RAIL = '.ui-rail--right .ui-rail__item';
|
||||
const MOBILE_PANELS = {
|
||||
'data-panel': 'layers',
|
||||
'pp-toggles': 'more',
|
||||
'global-context-panel': 'context',
|
||||
};
|
||||
const SEARCH_BUTTON = '#layer-finder-search-btn';
|
||||
const SEARCH_INPUT = '#layer-finder-input';
|
||||
const FILTER_BUTTON = '#data-panel .layer-finder__filter button';
|
||||
const AIRCRAFT_LAYERS = new Set(['flights', 'military', 'local-adsb']);
|
||||
/** Above this altitude (metres) the camera already shows the globe. */
|
||||
const GLOBE_ALTITUDE = 2_500_000;
|
||||
/**
|
||||
* Layers spread wider than a street-level view, and the camera altitude
|
||||
* (metres) from which enough of them are in frame. Traffic layers spread over
|
||||
* a region: aircraft cruise kilometres up across hundreds of kilometres, so
|
||||
* from a low, tilted camera almost none are in view. Global layers read best
|
||||
* from the globe view.
|
||||
*/
|
||||
const VIEW_ALTITUDE = Object.freeze({
|
||||
flights: 150_000,
|
||||
military: 400_000,
|
||||
'local-adsb': 60_000,
|
||||
'ais-live-vessels': 120_000,
|
||||
satellites: GLOBE_ALTITUDE,
|
||||
'rocket-launches': GLOBE_ALTITUDE,
|
||||
'weather-cyclones': GLOBE_ALTITUDE,
|
||||
'telegeography-submarine-cables': GLOBE_ALTITUDE,
|
||||
earthquakes: GLOBE_ALTITUDE,
|
||||
'local-firms': GLOBE_ALTITUDE,
|
||||
'weather-satellite': GLOBE_ALTITUDE,
|
||||
});
|
||||
|
||||
const $ = (selector, doc = globalThis.document) => doc?.querySelector(selector);
|
||||
|
||||
/** The camera altitude from the share hash, the app's own record of it. */
|
||||
function cameraAltitude() {
|
||||
const alt = Number(
|
||||
new URLSearchParams(globalThis.location?.hash.slice(1) || '').get('alt'),
|
||||
);
|
||||
return Number.isFinite(alt) ? alt : 0;
|
||||
}
|
||||
|
||||
const pressed = (selector) =>
|
||||
$(selector)?.getAttribute('aria-pressed') === 'true';
|
||||
const screenIsOwned = (doc) =>
|
||||
EXCLUSIVE_SURFACE_CLASSES.some((name) => doc.body.classList.contains(name));
|
||||
|
||||
/** Steps that open a side panel from its rail, unless it is already open. */
|
||||
function openPanelSteps(rail, item, label) {
|
||||
const button = () =>
|
||||
MOBILE_PANELS[item] &&
|
||||
globalThis.document?.body.classList.contains('mobile-shell')
|
||||
? $(`#mobile-tab-bar [data-mobile-sheet="${MOBILE_PANELS[item]}"]`)
|
||||
: $(`${rail}[data-rail-item="${item}"]`);
|
||||
return [
|
||||
{
|
||||
targets: () => [button()],
|
||||
text: () => t('Open {panel}', { panel: label }),
|
||||
done: () =>
|
||||
button()?.getAttribute('aria-pressed') === 'true' ||
|
||||
button()?.getAttribute('aria-expanded') === 'true',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** Steps that open the Visual panel from the left rail. */
|
||||
function openVisualSteps() {
|
||||
return openPanelSteps(LEFT_RAIL, 'pp-toggles', t('Visual'));
|
||||
}
|
||||
|
||||
/** Steps that bring up a section of Context's Properties tab. */
|
||||
function propertiesSteps(section, text) {
|
||||
const pane = `#context-tab-${section}`;
|
||||
const tab = () => $('#context-tab-btn-props');
|
||||
return [
|
||||
...openPanelSteps(RIGHT_RAIL, 'global-context-panel', t('Context')),
|
||||
{
|
||||
targets: () => [tab()],
|
||||
text: () => t('Open Properties: settings for the layers that are on'),
|
||||
skip: () => !tab(),
|
||||
done: () => tab()?.getAttribute('aria-selected') === 'true',
|
||||
},
|
||||
{
|
||||
prepare: () => $(pane)?.scrollIntoView?.({ block: 'center' }),
|
||||
targets: () => [$(pane)?.closest('.context-props__section') || $(pane)],
|
||||
text,
|
||||
skip: () => !$(pane)?.offsetParent,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
const rowHidden = (selector) =>
|
||||
Boolean($(selector)?.classList.contains('is-filtered'));
|
||||
const hasSearchQuery = () => Boolean($(SEARCH_INPUT)?.value.trim());
|
||||
|
||||
/**
|
||||
* The settings that change what a layer shows: its own option chips in the
|
||||
* Data layers row, then, where they apply, the Display panel's detection
|
||||
* labels and how dense they are.
|
||||
* @param {{id: string, shown: string}} layer
|
||||
*/
|
||||
export function layerSettingsGuide(layer) {
|
||||
const rowSelector = `[data-layer-id="${layer.id}"]`;
|
||||
const controls = `${rowSelector} .data-toggle-controls`;
|
||||
const chipNames = () =>
|
||||
[...(globalThis.document?.querySelectorAll(`${controls} button`) || [])]
|
||||
.map((chip) => {
|
||||
const name = chip.textContent.trim();
|
||||
const what = chip.getAttribute('title');
|
||||
// The title as translated: lowering its first letter is wrong in
|
||||
// German and other languages.
|
||||
return what ? `${name}: ${what}` : name;
|
||||
})
|
||||
.filter(Boolean)
|
||||
.join(' · ');
|
||||
return [
|
||||
...openPanelSteps(LEFT_RAIL, 'data-panel', t('Data layers')),
|
||||
{
|
||||
prepare: () => $(rowSelector)?.scrollIntoView?.({ block: 'center' }),
|
||||
targets: () => [$(controls)],
|
||||
text: () =>
|
||||
chipNames()
|
||||
? t('{layer} options. {options}', {
|
||||
layer: layer.shown,
|
||||
options: chipNames(),
|
||||
})
|
||||
: t('{layer} options appear here once it has loaded.', {
|
||||
layer: layer.shown,
|
||||
}),
|
||||
skip: () => !$(controls),
|
||||
},
|
||||
// Labels and 3D models now sit in Context's Properties while their
|
||||
// layers are on.
|
||||
...(LABEL_LAYERS.has(layer.id)
|
||||
? propertiesSteps('labels', () =>
|
||||
t(
|
||||
'Labels tag {layer} on the map. Density sets how many are labelled; Fade and Outside set how they thin out beyond the scope.',
|
||||
{
|
||||
layer: layer.shown,
|
||||
},
|
||||
),
|
||||
)
|
||||
: []),
|
||||
...(AIRCRAFT_LAYERS.has(layer.id)
|
||||
? propertiesSteps('aircraft', () =>
|
||||
t(
|
||||
'3D models: Proximity shows them up close only, All shows every aircraft as a model.',
|
||||
),
|
||||
)
|
||||
: []),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* The walk for one data layer.
|
||||
* @param {{id: string, shown: string}} layer
|
||||
* @param {(id: string) => boolean} isEnabled
|
||||
* @param {{readAltitude?: () => number}} [options] Current camera altitude in metres.
|
||||
*/
|
||||
export function layerGuide(
|
||||
layer,
|
||||
isEnabled,
|
||||
{ readAltitude = cameraAltitude } = {},
|
||||
) {
|
||||
const rowSelector = `[data-layer-id="${layer.id}"]`;
|
||||
return [
|
||||
// The walk asks for Data layers to be opened (or skips that when it is
|
||||
// open); it closes no panel the visitor has open.
|
||||
...openPanelSteps(LEFT_RAIL, 'data-panel', t('Data layers')),
|
||||
{
|
||||
// A filter left on from before could hide the row; start from the full list.
|
||||
prepare: () => {
|
||||
if (rowHidden(rowSelector) && !hasSearchQuery()) {
|
||||
for (const chip of globalThis.document.querySelectorAll(
|
||||
'#data-panel .layer-finder__chip',
|
||||
))
|
||||
chip.click();
|
||||
}
|
||||
},
|
||||
targets: () => [$(SEARCH_BUTTON)],
|
||||
text: () =>
|
||||
t('Press search to find {layer} in the list', { layer: layer.shown }),
|
||||
skip: () => isEnabled(layer.id) || !$(SEARCH_BUTTON),
|
||||
done: () => pressed(SEARCH_BUTTON),
|
||||
},
|
||||
{
|
||||
targets: () => [$(SEARCH_INPUT)],
|
||||
text: () => t('Type {layer}', { layer: layer.shown }),
|
||||
skip: () => isEnabled(layer.id) || !$(SEARCH_INPUT),
|
||||
done: () => hasSearchQuery() && !rowHidden(rowSelector),
|
||||
},
|
||||
{
|
||||
prepare: () => $(rowSelector)?.scrollIntoView?.({ block: 'center' }),
|
||||
targets: () => [$(rowSelector), $(`${rowSelector} .data-toggle-btn`)],
|
||||
text: () => t('Turn on {layer} with its switch', { layer: layer.shown }),
|
||||
skip: () => isEnabled(layer.id),
|
||||
done: () => isEnabled(layer.id),
|
||||
},
|
||||
{
|
||||
// Too close to see them: zoom out (any way) or press the globe view.
|
||||
targets: () => [$('#reset-globe-view')],
|
||||
text: () =>
|
||||
VIEW_ALTITUDE[layer.id] >= GLOBE_ALTITUDE
|
||||
? t('{layer} are easiest to see from the globe view', {
|
||||
layer: layer.shown,
|
||||
})
|
||||
: t(
|
||||
'{layer} spread over a wide area, so few are in view this close. Zoom out, or press the globe view.',
|
||||
{
|
||||
layer: layer.shown,
|
||||
},
|
||||
),
|
||||
skip: () =>
|
||||
!VIEW_ALTITUDE[layer.id] || readAltitude() >= VIEW_ALTITUDE[layer.id],
|
||||
done: () => readAltitude() >= VIEW_ALTITUDE[layer.id],
|
||||
},
|
||||
{
|
||||
// The end: offer the settings that shape this layer.
|
||||
text: () =>
|
||||
t('{layer} is on. Want to fine-tune what it shows?', {
|
||||
layer: layer.shown,
|
||||
}),
|
||||
offer: {
|
||||
label: () => t('Show settings'),
|
||||
steps: () => layerSettingsGuide(layer),
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** Walks for features, keyed like the omnibar's commands. */
|
||||
export const FEATURE_GUIDES = Object.freeze({
|
||||
styles: () => [
|
||||
...openVisualSteps(),
|
||||
{
|
||||
prepare: () =>
|
||||
$('.visual-presets__grid')?.scrollIntoView?.({ block: 'center' }),
|
||||
targets: () => [$('.visual-presets__grid')],
|
||||
text: () =>
|
||||
t('Pick a look: Normal, CRT, NVG, FLIR, Anime or Noir (keys 1–6)'),
|
||||
},
|
||||
],
|
||||
'map-source': () => [
|
||||
...openVisualSteps(),
|
||||
{
|
||||
prepare: () =>
|
||||
$('#pp-toggles .visual-presets')?.scrollIntoView?.({ block: 'start' }),
|
||||
targets: () => [$('#pp-toggles .visual-presets')],
|
||||
text: () =>
|
||||
t(
|
||||
'Under Map source, pick the map underneath: Google 3D, Bing, Esri or OpenStreetMap',
|
||||
),
|
||||
},
|
||||
],
|
||||
hud: () => [
|
||||
...openVisualSteps(),
|
||||
{
|
||||
prepare: () => $('#hud-toggle')?.scrollIntoView?.({ block: 'center' }),
|
||||
targets: () => [$('#hud-toggle')],
|
||||
text: () =>
|
||||
t('Switch the HUD on or off here; Layout picks Tactical or Minimal'),
|
||||
},
|
||||
],
|
||||
scope: () => [
|
||||
...openVisualSteps(),
|
||||
{
|
||||
prepare: () => $('#scope-toggle')?.scrollIntoView?.({ block: 'center' }),
|
||||
targets: () => [$('#scope-toggle')?.closest('.pp-toggle-group')],
|
||||
text: () =>
|
||||
t(
|
||||
'Scope frames the view in a circle. Feather softens its edge, Opacity sets how dark it shades outside.',
|
||||
),
|
||||
},
|
||||
],
|
||||
clean: () => [
|
||||
...openVisualSteps(),
|
||||
{
|
||||
prepare: () =>
|
||||
$('#clean-view-toggle')?.scrollIntoView?.({ block: 'center' }),
|
||||
targets: () => [$('#clean-view-toggle')],
|
||||
text: () => t('Clean UI hides the panels and readouts for a clear view'),
|
||||
},
|
||||
],
|
||||
'find-layer': () => [
|
||||
...openPanelSteps(LEFT_RAIL, 'data-panel', t('Data layers')),
|
||||
{
|
||||
targets: () => [$(SEARCH_BUTTON)],
|
||||
text: () => t('Press search, then type part of a layer name or source'),
|
||||
done: () => pressed(SEARCH_BUTTON),
|
||||
},
|
||||
{
|
||||
targets: () => [$(SEARCH_INPUT)],
|
||||
text: () => t('Type to narrow the list; Esc clears it'),
|
||||
done: hasSearchQuery,
|
||||
},
|
||||
{
|
||||
targets: () => [$(FILTER_BUTTON)],
|
||||
text: () =>
|
||||
t('Filter shows only layers that are on or off, or one category'),
|
||||
},
|
||||
],
|
||||
'filter-layers': () => [
|
||||
...openPanelSteps(LEFT_RAIL, 'data-panel', t('Data layers')),
|
||||
{
|
||||
targets: () => [$(FILTER_BUTTON)],
|
||||
text: () => t('Open the filter'),
|
||||
done: () => $(FILTER_BUTTON)?.getAttribute('aria-expanded') === 'true',
|
||||
},
|
||||
{
|
||||
targets: () => [$('.layer-finder__menu')],
|
||||
text: () =>
|
||||
t(
|
||||
'Pick a status (On, Off) and a category; each shows as a chip you can clear',
|
||||
),
|
||||
},
|
||||
],
|
||||
'section-index': () => [
|
||||
...openPanelSteps(LEFT_RAIL, 'data-panel', t('Data layers')),
|
||||
{
|
||||
targets: () => [$('.layer-section-index')],
|
||||
text: () => t('Hover a tick to see its group; click to jump there'),
|
||||
},
|
||||
],
|
||||
preferences: () => [
|
||||
{
|
||||
targets: () => [$('#corner-actions')],
|
||||
text: () => t('Add provider keys with Power Up, or change the language'),
|
||||
},
|
||||
],
|
||||
edge: () => [
|
||||
...openPanelSteps(LEFT_RAIL, 'data-panel', t('Data layers')),
|
||||
{
|
||||
targets: () => [$('#data-panel .ui-panel-edge')],
|
||||
text: () =>
|
||||
t(
|
||||
'Press this to slide panels over the rail to the screen edge; press again to bring them back',
|
||||
),
|
||||
},
|
||||
],
|
||||
context: () => [
|
||||
...openPanelSteps(RIGHT_RAIL, 'global-context-panel', t('Context')),
|
||||
{
|
||||
targets: () => [$('#global-context-panel .cyber-panel-body')],
|
||||
text: () =>
|
||||
t(
|
||||
'Context describes the view: weather, hazards, what your layers have nearby, and whatever you pick on the map',
|
||||
),
|
||||
},
|
||||
],
|
||||
properties: () =>
|
||||
propertiesSteps('labels', () =>
|
||||
t(
|
||||
'Properties holds the settings for the layers that are on, each layer marked by a coloured dot',
|
||||
),
|
||||
),
|
||||
north: () => [
|
||||
{
|
||||
targets: () => [$('#north-up-view')],
|
||||
text: () => t('Press the compass to face north'),
|
||||
},
|
||||
],
|
||||
tilt: () => [
|
||||
{
|
||||
targets: () => [$('#tilt-map-view')],
|
||||
text: () => t('Tilt the camera for a 3D view'),
|
||||
},
|
||||
],
|
||||
globe: () => [
|
||||
{
|
||||
targets: () => [$('#reset-globe-view')],
|
||||
text: () => t('Zoom out to the whole globe'),
|
||||
},
|
||||
],
|
||||
share: () => [
|
||||
{
|
||||
targets: () => [$('#share-btn')],
|
||||
text: () => t('Copy a link to exactly this view'),
|
||||
},
|
||||
],
|
||||
clear: () => [
|
||||
{
|
||||
targets: () => [$('#clear-selected-layers')],
|
||||
text: () => t('Turn off every layer at once'),
|
||||
},
|
||||
],
|
||||
// Drawing, and measuring with it: a line shows its length and an area its
|
||||
// size while it is drawn (src/annotations/drawMode.js).
|
||||
draw: () => [
|
||||
...openPanelSteps(LEFT_RAIL, 'utilities-panel', t('Utilities')),
|
||||
{
|
||||
prepare: () => $('#draw-group')?.scrollIntoView?.({ block: 'center' }),
|
||||
targets: () => [$('#draw-toggle')],
|
||||
text: () => t('Press Draw to start drawing on the map'),
|
||||
skip: () => pressed('#draw-toggle'),
|
||||
done: () => pressed('#draw-toggle'),
|
||||
},
|
||||
{
|
||||
targets: () => [$('#draw-mode-row')],
|
||||
text: () =>
|
||||
t(
|
||||
'Pick Line to measure a distance or Area for its size, then click points on the map; double-click or Enter finishes',
|
||||
),
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
/** The omnibar command ids that have a feature walk. */
|
||||
export function featureGuideFor(commandId) {
|
||||
if (commandId.startsWith('style-')) return 'styles';
|
||||
if (commandId.startsWith('map-')) return 'map-source';
|
||||
if (commandId.startsWith('hud-')) return 'hud';
|
||||
if (commandId === 'reset') return 'globe';
|
||||
return FEATURE_GUIDES[commandId] ? commandId : null;
|
||||
}
|
||||
|
||||
let active = null;
|
||||
|
||||
/**
|
||||
* Run a walk. Starting another ends the one in progress.
|
||||
* @param {Array<object>} steps
|
||||
* @param {{title?: string}} [options]
|
||||
*/
|
||||
export function startGuide(steps, { title = '' } = {}) {
|
||||
active?.stop();
|
||||
const doc = globalThis.document;
|
||||
if (!doc?.body || screenIsOwned(doc) || !steps?.length) return;
|
||||
const root = doc.createElement('div');
|
||||
root.className = 'gev-guide';
|
||||
root.innerHTML =
|
||||
'<div class="gev-guide-ring"><i></i></div>' +
|
||||
'<div class="gev-guide-callout" role="dialog" aria-modal="false" tabindex="-1" aria-labelledby="gev-guide-title" aria-describedby="gev-guide-text">' +
|
||||
'<div class="gev-guide-head"><p id="gev-guide-title" class="gev-guide-title"></p>' +
|
||||
'<p class="gev-guide-count"></p>' +
|
||||
'<button type="button" class="gev-guide-close"><span aria-hidden="true">×</span></button></div>' +
|
||||
'<ol class="gev-guide-progress" aria-hidden="true"></ol>' +
|
||||
'<div class="gev-guide-body"><p id="gev-guide-text" class="gev-guide-text"></p>' +
|
||||
'<p class="gev-guide-hint"><span class="gev-guide-hint-dot"></span><span></span></p></div>' +
|
||||
'<div class="gev-guide-actions"><p class="gev-guide-keys"><kbd></kbd><span></span></p>' +
|
||||
'<span><button type="button" class="gev-guide-skip" hidden></button>' +
|
||||
'<button type="button" class="gev-guide-offer" hidden></button>' +
|
||||
'<button type="button" class="gev-guide-next"></button></span></div>' +
|
||||
// Announces each step once; the dialog itself is not a live region, so
|
||||
// its buttons and progress are not read out on every change.
|
||||
'<p class="gev-guide-status" role="status" aria-live="polite"></p></div>';
|
||||
// Focus returns where it was when the walk ends, if that is still there.
|
||||
const returnFocus = doc.activeElement;
|
||||
doc.body.append(root);
|
||||
const ring = root.querySelector('.gev-guide-ring');
|
||||
const callout = root.querySelector('.gev-guide-callout');
|
||||
const subRings = [];
|
||||
const endLabel = t('End guide');
|
||||
root.querySelector('.gev-guide-close').setAttribute('aria-label', endLabel);
|
||||
root.querySelector('.gev-guide-close').title = endLabel;
|
||||
// i18n-ignore: the Escape keycap, matching the keyboard shortcut.
|
||||
root.querySelector('.gev-guide-keys kbd').textContent = 'Esc';
|
||||
root.querySelector('.gev-guide-keys span').textContent = t('to end');
|
||||
root.querySelector('.gev-guide-title').textContent = title
|
||||
? t('Guide · {topic}', { topic: title })
|
||||
: t('Guide');
|
||||
root.querySelector('.gev-guide-next').textContent = t('Next');
|
||||
root.querySelector('.gev-guide-hint span:last-child').textContent = t(
|
||||
'Press the highlighted control',
|
||||
);
|
||||
|
||||
const live = steps.filter(Boolean);
|
||||
let index = -1;
|
||||
let frame = 0;
|
||||
let advanceTimer = 0;
|
||||
let stopped = false;
|
||||
let current = null;
|
||||
let shown = 0;
|
||||
|
||||
const stop = () => {
|
||||
if (stopped) return;
|
||||
stopped = true;
|
||||
cancelAnimationFrame(frame);
|
||||
clearInterval(poll);
|
||||
clearTimeout(advanceTimer);
|
||||
resizeObserver?.disconnect();
|
||||
globalThis.removeEventListener?.('resize', schedule);
|
||||
doc.removeEventListener('scroll', schedule, true);
|
||||
doc.removeEventListener('click', onClick, true);
|
||||
doc.removeEventListener('keydown', onKey, true);
|
||||
const hadFocus = root.contains(doc.activeElement);
|
||||
root.remove();
|
||||
if (hadFocus && returnFocus?.isConnected) returnFocus.focus?.();
|
||||
if (active?.stop === stop) active = null;
|
||||
};
|
||||
const next = () => {
|
||||
clearTimeout(advanceTimer);
|
||||
advanceTimer = 0;
|
||||
void run(index + 1);
|
||||
};
|
||||
|
||||
const advance = () => {
|
||||
if (advanceTimer) return;
|
||||
advanceTimer = setTimeout(next, 350);
|
||||
};
|
||||
|
||||
async function run(at) {
|
||||
if (stopped) return;
|
||||
if (screenIsOwned(doc)) return stop();
|
||||
current = null;
|
||||
index = at;
|
||||
const step = live[index];
|
||||
if (!step) return stop();
|
||||
await step.prepare?.();
|
||||
if (stopped || at !== index) return;
|
||||
if (step.skip?.() || step.done?.()) return run(index + 1);
|
||||
current = step;
|
||||
shown += 1;
|
||||
// The total is what is shown so far plus the steps still to come that
|
||||
// would not be skipped as things stand.
|
||||
const total =
|
||||
shown + live.slice(index + 1).filter((later) => !later.skip?.()).length;
|
||||
root.querySelector('.gev-guide-count').textContent = `${shown} / ${total}`;
|
||||
const progress = root.querySelector('.gev-guide-progress');
|
||||
progress.replaceChildren(
|
||||
...Array.from({ length: total }, (_, i) => {
|
||||
const dot = doc.createElement('li');
|
||||
if (i < shown - 1) dot.className = 'done';
|
||||
if (i === shown - 1) dot.className = 'current';
|
||||
return dot;
|
||||
}),
|
||||
);
|
||||
const text = step.text();
|
||||
root.querySelector('.gev-guide-text').textContent = text;
|
||||
root.querySelector('.gev-guide-status').textContent =
|
||||
`${shown} / ${total}: ${text}`;
|
||||
// Steps that point at a control wait for it to be pressed; say so.
|
||||
const waits = Boolean(step.targets) && !step.offer;
|
||||
root.querySelector('.gev-guide-hint').hidden = !waits;
|
||||
const offer = root.querySelector('.gev-guide-offer');
|
||||
const skip = root.querySelector('.gev-guide-skip');
|
||||
offer.hidden = !step.offer;
|
||||
skip.hidden = !step.offer;
|
||||
root.querySelector('.gev-guide-keys').hidden = Boolean(step.offer);
|
||||
if (step.offer) {
|
||||
offer.textContent = step.offer.label();
|
||||
skip.textContent = t('Not now');
|
||||
}
|
||||
const last = index === live.length - 1;
|
||||
const nextButton = root.querySelector('.gev-guide-next');
|
||||
nextButton.hidden = Boolean(step.offer);
|
||||
nextButton.textContent = last
|
||||
? t('Finish')
|
||||
: waits
|
||||
? t('Skip step')
|
||||
: t('Next');
|
||||
nextButton.classList.toggle('quiet', waits && !last);
|
||||
// Replay the entrance so each step reads as new.
|
||||
callout.classList.remove('swap');
|
||||
void callout.offsetWidth;
|
||||
callout.classList.add('swap');
|
||||
root.classList.add('visible');
|
||||
schedule();
|
||||
}
|
||||
|
||||
// The visitor pressed the spotlit control: give the app a moment to react,
|
||||
// then move on (or let `done` decide, for steps that wait on a state).
|
||||
function onClick(event) {
|
||||
if (!current || callout.contains(event.target)) return;
|
||||
const [target] = current.targets?.() || [];
|
||||
if (target?.contains(event.target) && !current.done) advance();
|
||||
}
|
||||
// Only Escape is the walk's: it ends the walk and nothing else (the
|
||||
// Omnibar or a panel behind it stays as it is). Every other key goes on to
|
||||
// the page untouched.
|
||||
function onKey(event) {
|
||||
if (screenIsOwned(doc)) {
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
if (event.key !== 'Escape' || event.isComposing) return;
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
stop();
|
||||
}
|
||||
root.querySelector('.gev-guide-skip').addEventListener('click', stop);
|
||||
root.querySelector('.gev-guide-close').addEventListener('click', stop);
|
||||
root.querySelector('.gev-guide-next').addEventListener('click', () => {
|
||||
if (current) next();
|
||||
});
|
||||
// Taking the offer carries the walk on with its steps.
|
||||
root.querySelector('.gev-guide-offer').addEventListener('click', () => {
|
||||
if (!current?.offer) return;
|
||||
const extra = current.offer.steps() || [];
|
||||
live.splice(index + 1, live.length, ...extra.filter(Boolean));
|
||||
next();
|
||||
});
|
||||
doc.addEventListener('click', onClick, true);
|
||||
doc.addEventListener('keydown', onKey, true);
|
||||
|
||||
// Follow the targets as panels open and scroll, and notice when a step's
|
||||
// goal is reached however it happened: on resize and scroll, when the page
|
||||
// changes size, and otherwise four times a second (panels slide open
|
||||
// without an event to follow). Each is at most one frame's work.
|
||||
let poll = 0;
|
||||
let resizeObserver = null;
|
||||
function schedule() {
|
||||
if (stopped || frame) return;
|
||||
frame = requestAnimationFrame(() => {
|
||||
frame = 0;
|
||||
place();
|
||||
});
|
||||
}
|
||||
const place = () => {
|
||||
if (screenIsOwned(doc)) return stop();
|
||||
if (!current) return;
|
||||
if (current.done?.()) advance();
|
||||
const targets = (current.targets?.() || []).filter(Boolean);
|
||||
const [main, ...rest] = targets.map((element) =>
|
||||
element.getBoundingClientRect(),
|
||||
);
|
||||
if (!main || !main.width) {
|
||||
// Nothing to point at (the closing offer): centre the callout.
|
||||
ring.style.opacity = '0';
|
||||
subRings.forEach((sub) => (sub.style.opacity = '0'));
|
||||
callout.dataset.side = 'none';
|
||||
callout.style.left = `${(innerWidth - (callout.offsetWidth || 280)) / 2}px`;
|
||||
callout.style.top = `${innerHeight * 0.32}px`;
|
||||
return;
|
||||
}
|
||||
const pad = 6;
|
||||
Object.assign(ring.style, {
|
||||
opacity: '1',
|
||||
left: `${main.left - pad}px`,
|
||||
top: `${main.top - pad}px`,
|
||||
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);
|
||||
}
|
||||
subRings.forEach((sub, i) => {
|
||||
const box = rest[i];
|
||||
Object.assign(
|
||||
sub.style,
|
||||
box?.width
|
||||
? {
|
||||
opacity: '1',
|
||||
left: `${box.left - 4}px`,
|
||||
top: `${box.top - 4}px`,
|
||||
width: `${box.width + 8}px`,
|
||||
height: `${box.height + 8}px`,
|
||||
}
|
||||
: { opacity: '0' },
|
||||
);
|
||||
});
|
||||
// The callout sits beside the target, on whichever side has room.
|
||||
const width = callout.offsetWidth || 280;
|
||||
const height = callout.offsetHeight || 120;
|
||||
const gap = 18;
|
||||
const right = main.right + pad + gap;
|
||||
const onRight = right + width < innerWidth - 12;
|
||||
const left = onRight ? right : Math.max(12, main.left - pad - gap - width);
|
||||
const centre = main.top + main.height / 2;
|
||||
const top = Math.max(
|
||||
12,
|
||||
Math.min(innerHeight - height - 12, centre - height / 2),
|
||||
);
|
||||
// The arrow points at the target's middle, kept inside the callout.
|
||||
callout.dataset.side = onRight ? 'right' : 'left';
|
||||
callout.style.setProperty(
|
||||
'--gev-guide-arrow-y',
|
||||
`${Math.min(height - 18, Math.max(18, centre - top))}px`,
|
||||
);
|
||||
callout.style.left = `${left}px`;
|
||||
callout.style.top = `${top}px`;
|
||||
};
|
||||
globalThis.addEventListener?.('resize', schedule);
|
||||
doc.addEventListener('scroll', schedule, true);
|
||||
if (typeof ResizeObserver === 'function') {
|
||||
resizeObserver = new ResizeObserver(schedule);
|
||||
resizeObserver.observe(doc.body);
|
||||
}
|
||||
// A hidden tab has nothing to follow: the poll rests until it is shown.
|
||||
poll = setInterval(() => {
|
||||
if (!doc.hidden) schedule();
|
||||
}, 250);
|
||||
schedule();
|
||||
callout.focus({ preventScroll: true });
|
||||
|
||||
active = { stop };
|
||||
void run(0);
|
||||
return stop;
|
||||
}
|
||||
@@ -0,0 +1,882 @@
|
||||
// What a line typed into the omnibar asks for. A line is split into clauses
|
||||
// ("noir and cctv near austin, north up"); each clause can name a place,
|
||||
// layers to show or hide, a visual style, the HUD, a map stack, a camera move,
|
||||
// radio, the cockpit, the nearest aircraft or something to follow. What is
|
||||
// left of a clause after those are read is taken as a place.
|
||||
//
|
||||
// The result is a plan of steps in the order they should run: the camera
|
||||
// travels first, so layers and radio load for the new view, and following an
|
||||
// entity comes last.
|
||||
|
||||
import { msg } from '../i18n/index.js';
|
||||
|
||||
/** Visual styles, by the words people use for them. */
|
||||
const STYLES = [
|
||||
[/\bblack[- ]and[- ]white\b|\bnoir\b/, 'noir'],
|
||||
[/\b(thermal|flir|heat ?map|infra-?red)\b/, 'thermal'],
|
||||
[/\b(night ?vision|nvg|surveillance)\b/, 'surveillance'],
|
||||
[/\b(retro|crt)\b/, 'retro'],
|
||||
[/\banime\b/, 'anime'],
|
||||
[/\b(normal|default|plain) (style|view|look|colou?rs?)\b/, 'normal'],
|
||||
];
|
||||
|
||||
/** Map stacks. */
|
||||
const STACKS = [
|
||||
[/\b(osm|openstreetmap|street map)\b/, 'osm'],
|
||||
[/\bbing( aerial)?\b/, 'bing-aerial'],
|
||||
[/\b(photo ?real(istic)?|3d tiles)\b/, 'photoreal'],
|
||||
[/\b(esri|satellite imagery)\b/, 'esri-imagery'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Whole-map clears: "turn off all layers", "hide everything", "remove
|
||||
* everything" all clear the layers.
|
||||
*/
|
||||
const CLEAR_ALL =
|
||||
/^(?:(?:(?:turn|switch) off|hide|clear|remove|disable|kill) (?:everything|(?:all|every)(?: the)?(?: data)?(?: layers?)?)|clear (?:the )?(?:layers|map)|no layers)$/;
|
||||
|
||||
/** Camera moves, as globe actions or runner actions. */
|
||||
const CAMERA = [
|
||||
// Whole-map commands come first, so "turn off all layers" is never a place.
|
||||
[CLEAR_ALL, { act: 'clear' }],
|
||||
[
|
||||
/\b(share|copy)( this| the)? (view|link|map|url)\b|^share$/,
|
||||
{ act: 'share' },
|
||||
],
|
||||
[/\breset( the)? (view|camera)\b|\bstart over\b|^home$/, { act: 'reset' }],
|
||||
[/\bnorth[- ]?up\b|\bface north\b/, { act: 'northUp' }],
|
||||
[/\b(tilt|3d view|perspective)\b/, { act: 'tilt' }],
|
||||
[
|
||||
/\b(globe view|whole (globe|earth|world)|reset (the )?globe)\b/,
|
||||
{ name: 'zoom_to_globe', args: {} },
|
||||
],
|
||||
[/\bzoom in\b/, { name: 'adjust_camera_zoom', args: { direction: 'in' } }],
|
||||
[/\bzoom out\b/, { name: 'adjust_camera_zoom', args: { direction: 'out' } }],
|
||||
[
|
||||
/\bstop (the )?(camera|orbit|moving|rotating)\b/,
|
||||
{ name: 'move_camera', args: { motion: 'stop' } },
|
||||
],
|
||||
[
|
||||
/\borbit\b/,
|
||||
{
|
||||
name: 'move_camera',
|
||||
args: { motion: 'orbit', mode: 'continuous' },
|
||||
},
|
||||
],
|
||||
];
|
||||
|
||||
/** Side panels by name, with the rail and rail item that open them. */
|
||||
const PANEL_NAMES = [
|
||||
[
|
||||
/data ?layers?( panel)?|layers panel/,
|
||||
'left',
|
||||
'data-panel',
|
||||
msg('Data layers'),
|
||||
],
|
||||
[
|
||||
/utilities( panel)?|tools panel/,
|
||||
'left',
|
||||
'utilities-panel',
|
||||
msg('Utilities'),
|
||||
],
|
||||
[/authoring( panel)?|scenes? panel/, 'left', 'scene-panel', msg('Authoring')],
|
||||
[/display( panel)?|visual( panel)?/, 'left', 'pp-toggles', msg('Visual')],
|
||||
[/cctv panel|cameras? panel/, 'right', 'cctv-panel', msg('CCTV')],
|
||||
[/street ?level panel/, 'right', 'street-level-panel', msg('Street Level')],
|
||||
[
|
||||
/(space )?missions? panel/,
|
||||
'right',
|
||||
'space-missions-panel',
|
||||
msg('Space Missions'),
|
||||
],
|
||||
[/context( panel)?/, 'right', 'global-context-panel', msg('Context')],
|
||||
];
|
||||
const CLOSE = /\b(collapse|close|hide|minimi[sz]e|dismiss|shut|fold)\b/;
|
||||
const OPEN = /\b(open|expand|show|reveal)\b/;
|
||||
|
||||
/** Words that may sit around a panel's name without naming anything else. */
|
||||
const PANEL_FILLER =
|
||||
/\b(open|expand|show|reveal|collapse|close|hide|minimi[sz]e|dismiss|shut|fold|please|the|me|my|a|panel|sidebar|tab)\b/g;
|
||||
|
||||
/** Whether the clause names this panel and nothing besides it. */
|
||||
const onlyNames = (clause, pattern) =>
|
||||
!tidy(clause.replace(pattern, ' ').replace(PANEL_FILLER, ' '));
|
||||
|
||||
/** A clause about side panels, or null. */
|
||||
function panelStep(clause) {
|
||||
// "hide everything" clears the layers, as "remove everything" does.
|
||||
if (CLEAR_ALL.test(clause)) return null;
|
||||
if (CLOSE.test(clause)) {
|
||||
if (
|
||||
/\b(all|every|both)\b.*\b(panels?|sidebars?)\b|\b(panels|sidebars)\b/.test(
|
||||
clause,
|
||||
) ||
|
||||
// "close everything" alone; "hide everything near tokyo" clears.
|
||||
(/\beverything\b/.test(clause) && onlyNames(clause, /\beverything\b/))
|
||||
)
|
||||
return { kind: 'panel', action: 'close', side: 'all' };
|
||||
// "hide the left panel", never "hide flights near Left Bank".
|
||||
if (/\bleft\b/.test(clause) && onlyNames(clause, /\b(left|side)\b/g))
|
||||
return { kind: 'panel', action: 'close', side: 'left' };
|
||||
if (/\bright\b/.test(clause) && onlyNames(clause, /\b(right|side)\b/g))
|
||||
return { kind: 'panel', action: 'close', side: 'right' };
|
||||
for (const [pattern, side, item, name] of PANEL_NAMES)
|
||||
if (pattern.test(clause) && /panel/.test(clause))
|
||||
return { kind: 'panel', action: 'close', side, item, name };
|
||||
}
|
||||
// "open data layers" opens the panel; "show earthquake data layer" names
|
||||
// a layer, so a name with anything else beside it is not the panel.
|
||||
if (OPEN.test(clause))
|
||||
for (const [pattern, side, item, name] of PANEL_NAMES)
|
||||
if (pattern.test(clause) && onlyNames(clause, pattern))
|
||||
return { kind: 'panel', action: 'open', side, item, name };
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a line clears the whole map ("hide everything", "clear the map",
|
||||
* "hide everything near tokyo"), so layer switches leave it to the plan.
|
||||
*/
|
||||
export function isWholeMapClear(text) {
|
||||
const line = tidy(String(text || '').toLowerCase());
|
||||
const near = line.match(NEAR);
|
||||
return (
|
||||
CLEAR_ALL.test(line) ||
|
||||
Boolean(near && CLEAR_ALL.test(tidy(line.slice(0, near.index))))
|
||||
);
|
||||
}
|
||||
|
||||
/** Whether a line is about side panels, so layer switches leave it alone. */
|
||||
export const isPanelText = (text) =>
|
||||
Boolean(
|
||||
panelStep(
|
||||
String(text || '')
|
||||
.toLowerCase()
|
||||
.trim(),
|
||||
),
|
||||
);
|
||||
|
||||
const LAYER_OFF = /^(hide|turn off|switch off|disable|remove|no)\s+/;
|
||||
const LAYER_ON = /^(show|turn on|switch on|enable|add|display)\s+(me\s+)?/;
|
||||
// "go to" with the place after it, or alone at the end of the line.
|
||||
// "goto" counts only with a place after it: "Goto" is a town in Japan.
|
||||
const GO =
|
||||
/^(?:(?:go to|fly to|take me to|zoom to|jump to|head to)(?:\s+|$)|goto\s+)/i;
|
||||
const FOLLOW = /^(follow|track)\s+(.+)$/;
|
||||
/**
|
||||
* Something that can be followed: a callsign or ICAO address (a word or two
|
||||
* with letters and a digit: "ual123", "a12b2e", "UAL 123"), a nine-digit
|
||||
* MMSI, or the name of something loaded on the map. "Follow Me Bar", "Track
|
||||
* Hill" and "Track 29" are places.
|
||||
*/
|
||||
const FOLLOWABLE = /^(?:the\s+)?(?:(?=.*\d)(?=.*\p{L})\S+(?:\s+\S+)?|\d{9})$/u;
|
||||
/** "nearest plane to heathrow" as well as "near", "in" and the rest. */
|
||||
const NEAR_TO = /\s*\b(?:near|in|at|around|over|across|above|of|to)\s+(.+)$/;
|
||||
const NEAR = /\s*\b(?:near|in|at|around|over|across|above|of)\s+(.+)$/;
|
||||
/** The words of NEAR that place a request somewhere (not "of" or "at"). */
|
||||
const AROUND = /^\s*(?:near|in|around|over|across|above)\b/;
|
||||
const FILLER =
|
||||
/\b(please|the|a|an|me|on|mode|style|view|look|layer|layers|map|data|live)\b/g;
|
||||
/**
|
||||
* A question's form: a question word followed by an auxiliary or another
|
||||
* question word ("what is", "how far", "where's"), or an auxiliary followed
|
||||
* by a pronoun or determiner ("is it raining", "can you show"): "Can Tho
|
||||
* City" and "Is Kinabalu Park" are places.
|
||||
*/
|
||||
const WH_FORM =
|
||||
/^(?:what|where|when|who|why|how|which)(?:'s\b|\s+(?:is|are|was|were|do|does|did|can|could|should|would|will|many|much|far|long|to)\b)/i;
|
||||
const AUX_FORM =
|
||||
/^(?:is|are|was|were|do|does|did|can|could|should|would|will)\s+(?:it|there|you|i|we|they|he|she|the|a|an|this|that|my|your|our|any)\b/i;
|
||||
|
||||
/**
|
||||
* Whether a line is a real question, which Ask GEV may answer on Enter (a
|
||||
* billed call):
|
||||
* - one ending with "?" that has a question form or two non-Latin words
|
||||
* with a word of two letters or more, or five Han, Kana or Hangul characters;
|
||||
* - without "?", only a question word's form ("what is here", "how far is
|
||||
* paris") with a word about something after it, and not written as a
|
||||
* name ("Where Is My Mind").
|
||||
* An auxiliary's form without "?" is never one: "Can You Imagine", "Do it
|
||||
* Best Hardware" and "Is This It" are names. A line with a comma and no "?"
|
||||
* is a place ("Why, Arizona"). Read the line after normalizeLine, in its own
|
||||
* letter case.
|
||||
* @param {string} text
|
||||
*/
|
||||
/** Greetings shaped like questions ("what's up", "how's it going"). */
|
||||
const SMALL_TALK =
|
||||
/^(?:what'?s\s+(?:up|new|good|happening|going on|cooking)|how'?s\s+(?:it going|everything|life|things|your day)|how are (?:you|things)|what are you (?:up to|doing))\b/i;
|
||||
|
||||
export function isRealQuestion(text) {
|
||||
// Full-width and Arabic question marks read as "?".
|
||||
const line = String(text || '')
|
||||
.trim()
|
||||
.replace(/[?؟]/g, '?');
|
||||
if (SMALL_TALK.test(line)) return false;
|
||||
const words = line.replace(/\?+$/, '').split(/\s+/).filter(Boolean);
|
||||
if (line.endsWith('?'))
|
||||
// A name with "?" ("New York?", "Truth or Consequences?", "東京都?") is
|
||||
// offered to GEV, not sent: a question's form, or five Han, Kana or
|
||||
// Hangul characters written without spaces, or two words in other
|
||||
// non-Latin scripts.
|
||||
return (
|
||||
((WH_FORM.test(line) ||
|
||||
AUX_FORM.test(line) ||
|
||||
// Question words in other scripts are not read: two words do.
|
||||
(words.length >= 2 && !/\p{Script=Latin}/u.test(line))) &&
|
||||
words.some((word) => (word.match(/\p{L}/gu) || []).length >= 2)) ||
|
||||
(
|
||||
line.match(
|
||||
/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/gu,
|
||||
) || []
|
||||
).length >= 5
|
||||
);
|
||||
if (line.includes(',')) return false;
|
||||
// The form alone is too little ("how to", "who is it"): a word about
|
||||
// something must follow ("what is here").
|
||||
return (
|
||||
WH_FORM.test(line) &&
|
||||
words.some(
|
||||
(word) => !FORM_WORDS.has(word.toLowerCase().replace(/'s$/, '')),
|
||||
) &&
|
||||
!writtenAsName(words)
|
||||
);
|
||||
}
|
||||
/** Three words or more, each with a capital first letter: a title or a name. */
|
||||
export const writtenAsName = (words) =>
|
||||
words.length >= 3 &&
|
||||
words.every((word) => !/\p{L}/u.test(word) || /^\p{Lu}/u.test(word));
|
||||
/**
|
||||
* An auxiliary's question without "?" ("can you show me", "is it raining
|
||||
* in tokyo"): Ask GEV is offered first but never runs on Enter. Written with
|
||||
* a capital after its first two words it is a name ("Can You Imagine", "Do
|
||||
* it Best Hardware"), and the form alone ("Is there", "Can I") says nothing.
|
||||
*/
|
||||
function isUnmarkedQuestion(text) {
|
||||
const line = String(text || '').trim();
|
||||
const words = line.split(/\s+/).filter(Boolean);
|
||||
return (
|
||||
AUX_FORM.test(line) &&
|
||||
!line.includes(',') &&
|
||||
words.some((word) => !FORM_WORDS.has(word.toLowerCase())) &&
|
||||
!words.slice(2).some((word) => /^\p{Lu}/u.test(word))
|
||||
);
|
||||
}
|
||||
/** The words a question's form is made of, which say nothing on their own. */
|
||||
const FORM_WORDS = new Set(
|
||||
'what where when who why how which is are was were do does did can could should would will many much far long to it there you i we they he she the a an this that my your our any'.split(
|
||||
' ',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* A typed line as the Omnibar reads it, the one normalisation every reader
|
||||
* shares: compatibility forms folded (full-width letters and "?"), curly
|
||||
* apostrophes and quotes made straight, spaces collapsed, a "please" before
|
||||
* or after the request dropped, and a closing full stop or "!" dropped (not
|
||||
* an initial's: "Washington D.C."). Letter case is kept.
|
||||
* @param {string} text
|
||||
*/
|
||||
export function normalizeLine(text, { isRequest = isPlainRequest } = {}) {
|
||||
let line = String(text ?? '')
|
||||
.normalize('NFKC')
|
||||
.replace(/[\u2018\u2019\u201A\u201B\u2032\u02BC]/g, "'")
|
||||
.replace(/[\u201C\u201D\u201E\u201F\u2033]/g, '"')
|
||||
.replace(/؟/g, '?')
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim();
|
||||
const end = /(?<!(?:^|[\s.])\p{L})[.!。]+$/u;
|
||||
line = line.replace(end, '');
|
||||
// "please" is dropped only around a request: "Please Touch Museum",
|
||||
// "Kindly Lane" and "Pretty Please" are names.
|
||||
const polite = line
|
||||
.replace(/^(?:please|pls|plz|kindly)\b[,!]?\s+(?=\S)/i, '')
|
||||
.replace(/(?:\s*,\s*|\s+)(?:please|pls|plz)$/i, '')
|
||||
.replace(end, '')
|
||||
.trim();
|
||||
return polite !== line && polite && isRequest(polite) ? polite : line;
|
||||
}
|
||||
|
||||
/** A request by its own words: a verb starting it, or a real question. */
|
||||
const isPlainRequest = (text) => hasActionVerb(text) || isRealQuestion(text);
|
||||
|
||||
/**
|
||||
* Whether a clause starts with an action verb, in any letter case: the one
|
||||
* test the parser and the Enter rule share.
|
||||
*/
|
||||
export function hasActionVerb(text) {
|
||||
return ACTION_VERB.test(tidy(String(text || '').toLowerCase()));
|
||||
}
|
||||
|
||||
/**
|
||||
* The verbs that make a clause a request, the one list for the parser and
|
||||
* for what Enter may run (src/ui/omnibarEnter.js). A verb counts where the
|
||||
* clause starts ("show flights", "turn radio on"; "radio off" ends one), so
|
||||
* a place named after it never does ("radio near Clear Lake", "radio in
|
||||
* Show Low"). Words that also start names count only alone or before what
|
||||
* they act on: "clear the map", "zoom in", "tilt", "orbit", "stop the
|
||||
* radio", not "Clear Lake", "Zoom Hill", "Tilt Cove" or "Stop, Arkansas".
|
||||
* A keyword in a clause without a verb may be part of a name, and a verb
|
||||
* ends at a space or the line's end ("Hide-A-Way Lake" names a lake).
|
||||
*/
|
||||
export const ACTION_VERB =
|
||||
/^(?:please\s+|now\s+|also\s+)?(?:show|hide|turn|switch|toggle|enable|disable|add|remove|display(?=\s+\S)|play|start|close|open|enter|listen|tune|mute|unmute|follow|track|draw|measure|share|copy|reset|kill(?=\s+(?:the\s+)?(?:radio|music|sound)\b)|silence|pause|face(?=\s+(?:north|south|east|west)\b)|go to|fly to|take me to|head to|jump to|goto|(?:find |select )?nearest|zoom(?=$|\s+(?:in|out|to)\b)|tilt(?=$|\s+(?:the\s+)?(?:camera|view|map|up|down)\b)|orbit(?=$|\s+(?:the\s+)?(?:camera|view|map|it|here|around)\b)|stop(?=$|\s+(?:the\s+)?(?:radio|camera|orbit|orbiting|moving|rotating|music|following)\b)|clear(?=$|\s+(?:the\s+)?(?:map|layers?|everything|all|it)\b))(?=\s|$)|^\S+\s+(?:on|off)$/;
|
||||
/**
|
||||
* The cockpit only with a verb, and only as the end of its clause ("enter
|
||||
* the cockpit", "open cockpit view"): "Cockpit Country" is a place.
|
||||
*/
|
||||
const COCKPIT =
|
||||
/\b(?:enter|open|go into|get in(?:to)?|switch to|show)\s+(?:the\s+)?cockpit(?:\s+(?:view|mode))?$/;
|
||||
/**
|
||||
* The radio only with a verb that applies to it: "play radio in Kill Devil
|
||||
* Hills" turns it on, "Radio City Music Hall" is a place.
|
||||
*/
|
||||
const RADIO_ON =
|
||||
/\b(?:(?:turn|switch) on|play|listen to|tune in(?: to)?|open|start|put on|enable|unmute)\s+(?:the\s+)?radio(?:\s+stations?)?\b|\b(?:turn|switch)\s+(?:the\s+)?radio\s+on\b|\bradio\s+on\b/;
|
||||
const RADIO_OFF =
|
||||
/\b(?:(?:turn|switch) off|stop|mute|disable|silence|pause|kill)\s+(?:the\s+)?radio\b|\b(?:turn|switch)\s+(?:the\s+)?radio\s+off\b|\bradio\s+off\b/;
|
||||
/** Lines this long are not split into a layer and a place word by word. */
|
||||
const MAX_PAIR_WORDS = 6;
|
||||
/**
|
||||
* A place's name has six words at most; an address with a number in it
|
||||
* ("1600 Pennsylvania Ave NW Washington DC 20500") ten.
|
||||
*/
|
||||
export const placeWordLimit = (text) => (/\d/.test(text) ? 10 : 6);
|
||||
/** Lines longer than this that ask for nothing outright are sentences. */
|
||||
const MAX_SENTENCE_WORDS = 8;
|
||||
/** A clause that is only a switch verb, once what it switched is read. */
|
||||
const SWITCH_ONLY =
|
||||
/^(?:(?:turn|switch) (?:on|off)|show|hide|enable|disable|remove|add|display|no)?$/;
|
||||
/** Words beside a layer that say more about it, never a place. */
|
||||
const NOT_A_PLACE =
|
||||
/^(?:stations?|feeds?|data|layers?|live|now|here|map|overlay|tracker|tracking|updates?|info|status|positions?|activity|today|tonight)$/;
|
||||
/** A camera move turned off: orbiting stops; clearing stays a clear. */
|
||||
const cameraOff = (move) =>
|
||||
move.act === 'clear'
|
||||
? move
|
||||
: move.name === 'move_camera' && move.args.motion === 'orbit'
|
||||
? { name: 'move_camera', args: { motion: 'stop' } }
|
||||
: null;
|
||||
/**
|
||||
* The end of a "go to" clause that is a request, not part of the name: "in
|
||||
* noir", "with flights", "at night vision", "show flights".
|
||||
*/
|
||||
const GO_TAIL =
|
||||
/^(.+?)\s+(?:(?:in|with|at)\s+|(show|hide|turn on|turn off|switch on|switch off|enable|disable)\s+)(.+)$/;
|
||||
|
||||
/** Clause separators; "black and white" is joined first so it survives. */
|
||||
const SEPARATORS =
|
||||
/(\s*(?:,|;(?!\s*[-+]?\d)|\+(?!\d)|&|\band then\b|\bthen\b|\band\b|\balso\b)\s*)/;
|
||||
|
||||
function tidy(text) {
|
||||
return text.replace(/\s+/g, ' ').trim();
|
||||
}
|
||||
/** A place without the joining words a removed phrase left at its edges. */
|
||||
const placeName = (text) => {
|
||||
const name = tidy(text)
|
||||
.replace(/^((in|at|near|over|on|of|to|with|and|the)\s+)+/, '')
|
||||
.replace(/(\s+(in|at|near|over|on|of|to|with|and|the))+$/, '')
|
||||
.trim();
|
||||
// A joining word left on its own ("flights in") names no place.
|
||||
return JOINING.test(name) ? '' : name;
|
||||
};
|
||||
const JOINING = /^(in|at|near|over|on|of|to|with|and|the)$/;
|
||||
|
||||
/**
|
||||
* Take the first pattern that matches out of the clause.
|
||||
* @returns {{value: *, rest: string}|null}
|
||||
*/
|
||||
function takeFirst(clause, table) {
|
||||
for (const [pattern, value] of table) {
|
||||
const match = clause.match(pattern);
|
||||
// A whole word only, in any script: "bing" is no part of "Bingöl".
|
||||
const before = match && clause[match.index - 1];
|
||||
const after = match && clause[match.index + match[0].length];
|
||||
if (match && (/\p{L}/u.test(before || '') || /\p{L}/u.test(after || '')))
|
||||
continue;
|
||||
if (match)
|
||||
return {
|
||||
value,
|
||||
rest: tidy(clause.replace(match[0], ' ')),
|
||||
text: match[0],
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read one line into a plan.
|
||||
* @param {string} text What was typed.
|
||||
* @param {(term: string) => Array<{id: string, shown: string, enabled: boolean, score: number}>} matchLayers
|
||||
* @returns {{steps: Array<object>, question: boolean}}
|
||||
*/
|
||||
export function parseOmnibar(
|
||||
text,
|
||||
matchLayers,
|
||||
{ isEntity = () => false } = {},
|
||||
) {
|
||||
const raw = String(text || '').trim();
|
||||
const line = tidy(raw.toLowerCase()).replace(
|
||||
/\b(black[- ]and[- ]white|b ?& ?w)\b/g,
|
||||
'noir',
|
||||
);
|
||||
// `asks`: a real question, which Ask GEV may answer by default. Small talk
|
||||
// ("hi", "help") also goes to GEV, but only when picked.
|
||||
// A comma line without "?" is a place ("Why, Arizona"), not a question.
|
||||
// Only a real question is read as one; any other line ("why", "help",
|
||||
// "what cheer", "List") may still be a place, with Ask GEV offered after.
|
||||
const asks = isRealQuestion(raw);
|
||||
// A line ending in "?" is for GEV even when too short to ask by default.
|
||||
const question = asks || /[??؟]$/.test(line) || isUnmarkedQuestion(raw);
|
||||
if (!line || question) return { steps: [], question, asks, asked: new Set() };
|
||||
|
||||
const steps = [];
|
||||
// The steps whose own clause asked for them with a verb, and the clause
|
||||
// each step came from.
|
||||
const asked = new Set();
|
||||
const clauseOf = new Map();
|
||||
// The clauses with a name left beside their keywords.
|
||||
const placeClauses = new Set();
|
||||
let place = null;
|
||||
|
||||
const clauses = line.split(SEPARATORS);
|
||||
// Keyword steps read from a clause without a verb, and whether the place
|
||||
// is what was left beside them: together they make the line ambiguous.
|
||||
const bareSteps = new Set();
|
||||
let placeBare = false;
|
||||
// Further places joined with "and" ("near New York and Paris"): the plan
|
||||
// goes to the first, and the rest are offered on their own.
|
||||
const extraPlaces = [];
|
||||
let previousHadPlace = false;
|
||||
let previousBarePlace = false;
|
||||
let previousGo = false;
|
||||
// Whether a request was peeled off a "go to" clause, and how the place
|
||||
// was named: after "go to", after "near"/"in", or bare.
|
||||
let goPeeled = false;
|
||||
let placeFrom = null;
|
||||
/** A whole clause that is one style, map, camera move or layer, or null. */
|
||||
const requestIn = (text) => {
|
||||
const words = tidy(text.replace(/\b(mode|style|view|look)\b/g, ' '));
|
||||
for (const table of [STYLES, STACKS, CAMERA]) {
|
||||
const found = takeFirst(words, table);
|
||||
if (found && !found.rest) {
|
||||
if (table === STYLES) return { kind: 'style', style: found.value };
|
||||
if (table === STACKS) return { kind: 'stack', stack: found.value };
|
||||
return { kind: 'camera', ...found.value };
|
||||
}
|
||||
}
|
||||
return layerRequest(words);
|
||||
};
|
||||
/** A layer named in full, switched on unless the verb says off. */
|
||||
const layerRequest = (text, verb = '') => {
|
||||
const [layer] = matchLayers(tidy(text.replace(FILLER, ' ')));
|
||||
if (!named(layer)) return null;
|
||||
return {
|
||||
kind: 'layer',
|
||||
layer,
|
||||
enabled: !/^(hide|turn off|switch off|disable)$/.test(verb),
|
||||
};
|
||||
};
|
||||
let previousLayerEnabled = null;
|
||||
// Whether a clause was read whole as a switch that has no step ("osm
|
||||
// off"): the line is then no place either.
|
||||
let consumed = false;
|
||||
for (let i = 0; i < clauses.length; i += 2) {
|
||||
let clause = tidy(clauses[i]);
|
||||
const separator = clauses[i - 1]?.trim();
|
||||
const afterPlaceComma = previousHadPlace && separator === ',';
|
||||
// "trinidad and tobago": a bare place joined to a bare place by "and".
|
||||
const afterBarePlaceAnd = previousBarePlace && separator === 'and';
|
||||
const continuedLayer = previousLayerEnabled;
|
||||
const afterGo = previousGo;
|
||||
previousGo = false;
|
||||
previousHadPlace = false;
|
||||
previousBarePlace = false;
|
||||
previousLayerEnabled = null;
|
||||
if (!clause) continue;
|
||||
// "noir off", "flights on", "orbit off": a switch after what it switches
|
||||
// reads as one before it ("turn off noir"), so "off" is never a place.
|
||||
const switchAfter = clause.match(/^(.+?)\s+(on|off)$/);
|
||||
if (
|
||||
switchAfter &&
|
||||
!/\b(?:radio|hud)\b/.test(switchAfter[1]) &&
|
||||
requestIn(switchAfter[1])
|
||||
)
|
||||
clause = `turn ${switchAfter[2]} ${switchAfter[1]}`;
|
||||
// Steps of a clause that has a verb are asked for; so are those joined
|
||||
// to a "go to" clause by "and" or "then" ("go to Paris and noir").
|
||||
const clauseVerb =
|
||||
ACTION_VERB.test(clause) ||
|
||||
(afterGo && /^(and|then|and then)$/.test(separator || ''));
|
||||
// `wanted`: whether this step's own clause asked for it; a layer is
|
||||
// asked for only by a switch right before its word (see below).
|
||||
const add = (step, wanted = clauseVerb) => {
|
||||
const key = JSON.stringify(step);
|
||||
let kept = steps.find((existing) => JSON.stringify(existing) === key);
|
||||
if (!kept) steps.push((kept = step));
|
||||
if (!clauseOf.has(kept)) clauseOf.set(kept, i);
|
||||
if (wanted && step.kind !== 'place') asked.add(kept);
|
||||
return kept;
|
||||
};
|
||||
const addBare = (step, wanted = clauseVerb) => {
|
||||
const kept = add(step, wanted);
|
||||
if (!wanted) bareSteps.add(kept);
|
||||
};
|
||||
// `leftover`: a name left beside the clause's keywords ("Show Low
|
||||
// noir"), not one named after near or in ("turn on radio in tokyo").
|
||||
const addPlace = (value, { bare = false, leftover = false } = {}) => {
|
||||
if (!value) return;
|
||||
if (leftover) placeClauses.add(i);
|
||||
if (place && bare && afterBarePlaceAnd) place += ` and ${value}`;
|
||||
else if (place && !afterPlaceComma) {
|
||||
if (separator === 'and') extraPlaces.push(value);
|
||||
return;
|
||||
} else if (!place) {
|
||||
place = value;
|
||||
placeBare = bare;
|
||||
} else place += `, ${value}`;
|
||||
previousHadPlace = true;
|
||||
previousBarePlace = bare;
|
||||
};
|
||||
// "go to Thermal, California", "fly to Tilt Cove": the rest of a "go to"
|
||||
// clause is the place, read before any keyword in it, and so is a part
|
||||
// after a comma that has no verb of its own.
|
||||
// A request that ends the clause is peeled off it ("go to tokyo in
|
||||
// noir", "go to London with flights", "go to tokyo show flights", "go
|
||||
// to tokyo, north up"); the line is then ambiguous, so the place row
|
||||
// still comes first. Names that merely hold a keyword stay whole.
|
||||
const go = clause.match(GO);
|
||||
const tailStep =
|
||||
afterGo && separator === ',' && !clauseVerb ? requestIn(clause) : null;
|
||||
if (tailStep) {
|
||||
add(tailStep);
|
||||
goPeeled = true;
|
||||
previousGo = true;
|
||||
continue;
|
||||
}
|
||||
if (go || (afterGo && separator === ',' && !clauseVerb)) {
|
||||
let value = go ? clause.slice(go[0].length) : clause;
|
||||
const peel = go && value.match(GO_TAIL);
|
||||
const peeled =
|
||||
peel && (peel[2] ? layerRequest(peel[3], peel[2]) : requestIn(peel[3]));
|
||||
if (peeled) {
|
||||
value = peel[1];
|
||||
add(peeled);
|
||||
goPeeled = true;
|
||||
}
|
||||
value = placeName(value);
|
||||
if (go) addPlace(value, { bare: true });
|
||||
else if (value) place += `, ${value}`;
|
||||
if (go && value) placeFrom = 'go';
|
||||
previousHadPlace = true;
|
||||
previousBarePlace = true;
|
||||
previousGo = true;
|
||||
continue;
|
||||
}
|
||||
// "hide everything near tokyo": a whole-map clear with a place after it.
|
||||
const clearNear = clause.match(NEAR);
|
||||
if (clearNear && CLEAR_ALL.test(tidy(clause.slice(0, clearNear.index)))) {
|
||||
add({ kind: 'camera', act: 'clear' });
|
||||
addPlace(placeName(clearNear[1]));
|
||||
placeFrom ??= 'near';
|
||||
continue;
|
||||
}
|
||||
const panel = panelStep(clause);
|
||||
if (panel) {
|
||||
add(panel);
|
||||
continue;
|
||||
}
|
||||
const follow = clause.match(FOLLOW);
|
||||
if (follow) {
|
||||
// "track flights near austin" shows a layer there; "follow AAL123"
|
||||
// follows a craft, and "track it over texas" still goes to Texas.
|
||||
const where = follow[2].match(NEAR);
|
||||
const target = where ? tidy(follow[2].slice(0, where.index)) : follow[2];
|
||||
const [layer] = matchLayers(target.replace(FILLER, ' ').trim());
|
||||
if (named(layer)) {
|
||||
add({ kind: 'layer', layer, enabled: true });
|
||||
previousLayerEnabled = true;
|
||||
if (where) addPlace(placeName(where[1]));
|
||||
continue;
|
||||
}
|
||||
if (FOLLOWABLE.test(target) || isEntity(target.replace(/^the\s+/, ''))) {
|
||||
if (where) addPlace(placeName(where[1]));
|
||||
add({ kind: 'follow', query: target.replace(/^the\s+/, '') });
|
||||
continue;
|
||||
}
|
||||
// Not something to follow: read on, as a place.
|
||||
}
|
||||
// "nearest plane", alone or with a place: "Nearest Plane Crash Site" is
|
||||
// a name.
|
||||
if (
|
||||
/\b(nearest|closest) (plane|aircraft|flight|jet)s?(?:$|\s+(?:to|near|in|at|around|over)\b)/.test(
|
||||
clause,
|
||||
)
|
||||
) {
|
||||
const where = clause.match(NEAR_TO);
|
||||
if (where) addPlace(placeName(where[1]));
|
||||
add({ kind: 'nearest' });
|
||||
continue;
|
||||
}
|
||||
|
||||
// "turn off noir" goes back to the normal style, "turn off orbit"
|
||||
// stops the camera; a map or a camera move has nothing to turn off.
|
||||
const switchOff = LAYER_OFF.test(clause);
|
||||
let took = false;
|
||||
const style = takeFirst(clause, STYLES);
|
||||
if (style) {
|
||||
addBare({ kind: 'style', style: switchOff ? 'normal' : style.value });
|
||||
clause = style.rest;
|
||||
took = true;
|
||||
}
|
||||
const stack = takeFirst(clause, STACKS);
|
||||
if (stack) {
|
||||
if (!switchOff) addBare({ kind: 'stack', stack: stack.value });
|
||||
clause = stack.rest;
|
||||
took = true;
|
||||
}
|
||||
const camera = takeFirst(clause, CAMERA);
|
||||
if (camera) {
|
||||
const move = switchOff ? cameraOff(camera.value) : camera.value;
|
||||
if (move) addBare({ kind: 'camera', ...move });
|
||||
clause = camera.rest;
|
||||
took = true;
|
||||
}
|
||||
const hud = clause.match(
|
||||
/\b(hide|show|turn off|turn on)?\s*hud\s*(on|off)?\b/,
|
||||
);
|
||||
if (hud) {
|
||||
const off = /hide|off/.test(hud[0]) || switchOff;
|
||||
addBare({ kind: 'hud', visible: off ? 'off' : 'on' });
|
||||
clause = tidy(clause.replace(hud[0], ' '));
|
||||
took = true;
|
||||
}
|
||||
// The switch verb is all that is left beside what it switched.
|
||||
if (took && SWITCH_ONLY.test(clause)) {
|
||||
consumed = true;
|
||||
continue;
|
||||
}
|
||||
const cockpit = clause.match(COCKPIT);
|
||||
if (cockpit) {
|
||||
add({ kind: 'cockpit' });
|
||||
clause = tidy(clause.replace(cockpit[0], ' '));
|
||||
}
|
||||
const radioOff = clause.match(RADIO_OFF);
|
||||
const radio = radioOff || clause.match(RADIO_ON);
|
||||
if (radio) {
|
||||
// "turn off the radio", "stop the radio", "mute radio": radio off. The
|
||||
// verbs are never a place.
|
||||
const disable = Boolean(radioOff);
|
||||
const rest = tidy(clause.replace(radio[0], ' '));
|
||||
const where = rest.match(NEAR);
|
||||
// "play radio in tokyo", or the place left beside it: "play radio tokyo".
|
||||
const beside = tidy(rest.replace(FILLER, ' '));
|
||||
if (where) addPlace(placeName(where[1]));
|
||||
else if (beside && !disable) addPlace(placeName(beside));
|
||||
add({ kind: 'radio', action: disable ? 'disable' : 'enable' });
|
||||
continue;
|
||||
}
|
||||
|
||||
// Layers: "hide flights", "cctv near austin", "earthquakes".
|
||||
const off = clause.match(LAYER_OFF);
|
||||
const on = LAYER_ON.test(clause);
|
||||
let body = clause.replace(LAYER_OFF, '').replace(LAYER_ON, '');
|
||||
body = tidy(body.replace(GO, ''));
|
||||
const where = body.match(NEAR);
|
||||
const what = (where ? tidy(body.slice(0, where.index)) : body).replace(
|
||||
/(\s+(in|at|on|with|of|near|to))+$/,
|
||||
'',
|
||||
);
|
||||
const subject = tidy(
|
||||
what.replace(/^(?:all|every)\s+/, '').replace(FILLER, ' '),
|
||||
);
|
||||
const layers = subject ? matchLayers(subject) : [];
|
||||
const enabled = off ? false : on ? true : (continuedLayer ?? true);
|
||||
// A whole layer name: "rock" begins "rockets" but names no layer.
|
||||
if (named(layers[0])) {
|
||||
// Without a switch right before it a layer word may be a place's name
|
||||
// ("Hurricane, Utah", "Kill Devil Hills" is no "kill").
|
||||
addBare({ kind: 'layer', layer: layers[0], enabled }, Boolean(off || on));
|
||||
previousLayerEnabled = enabled;
|
||||
if (where) {
|
||||
addPlace(placeName(where[1]));
|
||||
// "of" and "at" may join the words of a name ("Planes of Fame Air
|
||||
// Museum", "Boats at Sea"); near, in, around, over, across and above
|
||||
// place a request ("flights near Tokyo", "flights over Texas").
|
||||
placeFrom ??= AROUND.test(where[0]) ? 'near' : 'of';
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// A layer and a place side by side, without "in": "tokyo traffic",
|
||||
// "earthquakes japan". The place is whichever side is not the layer.
|
||||
if (
|
||||
!where &&
|
||||
subject.includes(' ') &&
|
||||
subject.split(' ').length <= MAX_PAIR_WORDS
|
||||
) {
|
||||
const words = subject.split(' ');
|
||||
let pair = null;
|
||||
// Only a whole layer name or synonym counts here.
|
||||
for (let cut = 1; cut < words.length && !pair; cut++) {
|
||||
const head = words.slice(0, cut).join(' ');
|
||||
const tail = words.slice(cut).join(' ');
|
||||
const [tailLayer] = matchLayers(tail);
|
||||
const [headLayer] = matchLayers(head);
|
||||
if (named(tailLayer))
|
||||
pair = { layer: tailLayer, place: head, layerFirst: false };
|
||||
else if (named(headLayer))
|
||||
pair = { layer: headLayer, place: tail, layerFirst: true };
|
||||
}
|
||||
// "show radio stations", "flights here": a word about the layer, not
|
||||
// a place.
|
||||
if (pair && (off || on) && NOT_A_PLACE.test(pair.place)) {
|
||||
addBare(
|
||||
{ kind: 'layer', layer: pair.layer, enabled },
|
||||
Boolean(off || on) && pair.layerFirst,
|
||||
);
|
||||
previousLayerEnabled = enabled;
|
||||
continue;
|
||||
}
|
||||
if (pair) {
|
||||
// Asked for only when the switch comes right before the layer word
|
||||
// ("show traffic tokyo"); "show low radio" names Show Low.
|
||||
addBare(
|
||||
{ kind: 'layer', layer: pair.layer, enabled },
|
||||
Boolean(off || on) && pair.layerFirst,
|
||||
);
|
||||
previousLayerEnabled = enabled;
|
||||
addPlace(placeName(pair.place), { bare: true, leftover: true });
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (where && subject === '') addPlace(placeName(where[1]));
|
||||
else if (tidy(body.replace(FILLER, ' '))) {
|
||||
const before = place;
|
||||
addPlace(placeName(body), { bare: !off && !on, leftover: true });
|
||||
// Left over after a switch that switched nothing ("Show Low noir").
|
||||
if (!before && place && (off || on)) placeFrom ??= 'verb';
|
||||
}
|
||||
}
|
||||
|
||||
// A verb with a name left beside its keywords asks for nothing but a layer
|
||||
// switched right after it: "Show Low noir", "Start Point noir" and "Track
|
||||
// Hill noir" name places, they do not ask for noir.
|
||||
for (const [step, index] of clauseOf) {
|
||||
if (step.kind === 'layer' || !asked.has(step)) continue;
|
||||
if (!ACTION_VERB.test(tidy(clauses[index] || ''))) continue;
|
||||
// "show noir" alone asks for noir; only a name left beside the switch
|
||||
// ("Show Low noir") makes it a place.
|
||||
if (!placeClauses.has(index)) continue;
|
||||
const layerAsked = [...clauseOf].some(
|
||||
([other, at]) =>
|
||||
at === index && other.kind === 'layer' && asked.has(other),
|
||||
);
|
||||
if (!layerAsked) {
|
||||
asked.delete(step);
|
||||
bareSteps.add(step);
|
||||
}
|
||||
}
|
||||
// A standalone place retains the user's spelling and punctuation. A comma
|
||||
// before a real command still separates actions in a combined plan.
|
||||
if (!steps.length && !consumed) place = raw.replace(GO, '');
|
||||
// A place is a name of six words at most: anything longer is a sentence
|
||||
// (pasted text, a remark), which names no place. With nothing asked for
|
||||
// beside it, the line is for GEV only and Enter runs nothing.
|
||||
// A long name dropped beside keywords nobody asked for ("San Jose, Santa
|
||||
// Clara County, California, USA flights") makes the line a sentence too.
|
||||
let droppedPlace = false;
|
||||
if (place && place.split(/\s+/).length > placeWordLimit(place)) {
|
||||
place = null;
|
||||
droppedPlace = true;
|
||||
}
|
||||
const sentence =
|
||||
(!place && !steps.length) ||
|
||||
(droppedPlace && steps.every((step) => !asked.has(step))) ||
|
||||
(line.split(' ').length > MAX_SENTENCE_WORDS &&
|
||||
!(place && /\d/.test(place) && !steps.length) &&
|
||||
placeFrom !== 'go' &&
|
||||
steps.every((step) => !asked.has(step)));
|
||||
if (sentence)
|
||||
return {
|
||||
steps: [],
|
||||
question: false,
|
||||
asks: false,
|
||||
sentence: true,
|
||||
asked: new Set(),
|
||||
clauseOf: new Map(),
|
||||
extraPlaces: [],
|
||||
};
|
||||
// One keyword without a verb beside what is left of the line ("Thermal,
|
||||
// California", "Tilt Cove", "tokyo traffic") may be a place's own name:
|
||||
// the whole line is offered as a place ahead of the plan.
|
||||
const joined = /\b(and|then|also)\b|[;+&]/.test(line);
|
||||
const ambiguous =
|
||||
(Boolean(place) && goPeeled) ||
|
||||
(Boolean(place) &&
|
||||
placeBare &&
|
||||
steps.length === 1 &&
|
||||
bareSteps.has(steps[0]) &&
|
||||
!joined) ||
|
||||
// A switch that switched nothing and a keyword nobody asked for, beside
|
||||
// what is left: "Show Low noir", "Show Low radio" name Show Low.
|
||||
(Boolean(place) &&
|
||||
placeFrom === 'verb' &&
|
||||
steps.length > 0 &&
|
||||
steps.every((step) => !asked.has(step)) &&
|
||||
!joined) ||
|
||||
// Keywords nobody asked for beside the rest of a name, joined or not:
|
||||
// "Storm Lake and Spencer", "Thermal and Indio" may be one place, so the
|
||||
// whole line is offered first.
|
||||
(Boolean(place) &&
|
||||
placeFrom !== 'near' &&
|
||||
steps.length > 0 &&
|
||||
steps.every((step) => !asked.has(step)));
|
||||
// Several keywords and nothing asked for ("Fire and Rain", "Noir and
|
||||
// Thermal"): no plan runs on Enter; the line may still be a name.
|
||||
const unasked = steps.length > 0 && steps.every((step) => !asked.has(step));
|
||||
if (place && !placeFrom) placeFrom = placeBare ? 'bare' : 'near';
|
||||
if (place) steps.unshift({ kind: 'place', place });
|
||||
steps.verb = LAYER_OFF.test(line) || LAYER_ON.test(line) || GO.test(line);
|
||||
// Following happens once the camera has settled on the new view.
|
||||
steps.sort((a, b) => (a.kind === 'follow') - (b.kind === 'follow'));
|
||||
return {
|
||||
steps,
|
||||
question,
|
||||
asks,
|
||||
ambiguous,
|
||||
unasked,
|
||||
extraPlaces,
|
||||
placeFrom,
|
||||
peeled: goPeeled,
|
||||
asked,
|
||||
clauseOf,
|
||||
};
|
||||
}
|
||||
|
||||
/** A layer match that names the whole layer, not the start of its name. */
|
||||
function named(layer) {
|
||||
return layer?.score >= 2 && layer.exact !== false;
|
||||
}
|
||||
|
||||
/** "above M5", "m4.5+", "magnitude 6": a magnitude floor in a line. */
|
||||
const MAGNITUDE =
|
||||
/\b(?:above|over|at least|greater than|>=?)?\s*m(?:ag(?:nitude)?)?\s*(\d+(?:\.\d+)?)\s*\+?(?=\s|$)/i;
|
||||
/** Layers whose items have a magnitude. */
|
||||
const MAGNITUDE_LAYERS = /^(earthquakes?|quakes?)$|earthquake/;
|
||||
|
||||
/**
|
||||
* A count request's text without its magnitude floor, and the floor. Only an
|
||||
* earthquake layer reads one: "flights over m25" keeps its words.
|
||||
* @returns {{text: string, minMagnitude: ?number}}
|
||||
*/
|
||||
export function magnitudeFloor(text, matchLayers) {
|
||||
const raw = String(text || '').trim();
|
||||
const match = raw.match(MAGNITUDE);
|
||||
if (!match) return { text: raw, minMagnitude: null };
|
||||
const plain = tidy(raw.replace(match[0], ' '));
|
||||
const layer = parseOmnibar(plain, matchLayers).steps.find(
|
||||
(step) => step.kind === 'layer',
|
||||
)?.layer;
|
||||
return layer && MAGNITUDE_LAYERS.test(String(layer.id))
|
||||
? { text: plain, minMagnitude: Number(match[1]) }
|
||||
: { text: raw, minMagnitude: null };
|
||||
}
|
||||
@@ -0,0 +1,442 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { isPanelText, magnitudeFloor, parseOmnibar } from './omnibarIntent.js';
|
||||
|
||||
const matchLayers = (term) =>
|
||||
['flights', 'ships'].includes(term) ? [{ id: term, score: 2 }] : [];
|
||||
|
||||
test('place lookup retains comma qualifiers in standalone and combined requests', () => {
|
||||
assert.deepEqual(
|
||||
[...parseOmnibar(' Paris, Texas ', matchLayers).steps],
|
||||
[{ kind: 'place', place: 'Paris, Texas' }],
|
||||
);
|
||||
const { steps } = parseOmnibar(
|
||||
'north up, flights near Paris, Texas, follow AAL123',
|
||||
matchLayers,
|
||||
);
|
||||
assert.deepEqual(
|
||||
steps.map(({ kind }) => kind),
|
||||
['place', 'camera', 'layer', 'follow'],
|
||||
);
|
||||
assert.equal(steps[0].place, 'paris, texas');
|
||||
});
|
||||
|
||||
test('named layer removals and orbit stop preserve the requested action', () => {
|
||||
const { steps } = parseOmnibar(
|
||||
'hide all flights and ships, stop orbit',
|
||||
matchLayers,
|
||||
);
|
||||
assert.deepEqual(
|
||||
[...steps],
|
||||
[
|
||||
{ kind: 'layer', layer: { id: 'flights', score: 2 }, enabled: false },
|
||||
{ kind: 'layer', layer: { id: 'ships', score: 2 }, enabled: false },
|
||||
{ kind: 'camera', name: 'move_camera', args: { motion: 'stop' } },
|
||||
],
|
||||
);
|
||||
assert.deepEqual(
|
||||
[...parseOmnibar('turn off all layers', matchLayers).steps],
|
||||
[{ kind: 'camera', act: 'clear' }],
|
||||
);
|
||||
});
|
||||
|
||||
const layersOf = (steps) =>
|
||||
[...steps].map((step) =>
|
||||
step.kind === 'layer'
|
||||
? { kind: 'layer', id: step.layer.id, enabled: step.enabled }
|
||||
: step,
|
||||
);
|
||||
|
||||
test('turning the radio off is a radio step, and its verb is never a place', () => {
|
||||
assert.deepEqual(
|
||||
layersOf(parseOmnibar('tokyo and turn off the radio', matchLayers).steps),
|
||||
[
|
||||
{ kind: 'place', place: 'tokyo' },
|
||||
{ kind: 'radio', action: 'disable' },
|
||||
],
|
||||
);
|
||||
assert.deepEqual(
|
||||
layersOf(
|
||||
parseOmnibar('show flights and stop the radio', matchLayers).steps,
|
||||
),
|
||||
[
|
||||
{ kind: 'layer', id: 'flights', enabled: true },
|
||||
{ kind: 'radio', action: 'disable' },
|
||||
],
|
||||
);
|
||||
assert.deepEqual(
|
||||
layersOf(parseOmnibar('go to austin, mute radio', matchLayers).steps),
|
||||
[
|
||||
{ kind: 'place', place: 'austin' },
|
||||
{ kind: 'radio', action: 'disable' },
|
||||
],
|
||||
);
|
||||
assert.deepEqual(
|
||||
layersOf(parseOmnibar('play radio in tokyo', matchLayers).steps),
|
||||
[
|
||||
{ kind: 'place', place: 'tokyo' },
|
||||
{ kind: 'radio', action: 'enable' },
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
// Layers as the Omnibar matches them: whole names are `exact`, a name's
|
||||
// start is not.
|
||||
const LAYERS = {
|
||||
flights: ['flights'],
|
||||
earthquakes: ['earthquakes', 'quakes'],
|
||||
'local-firms': ['fires'],
|
||||
'rocket-launches': ['rockets', 'launches'],
|
||||
traffic: ['traffic'],
|
||||
radio: ['radio'],
|
||||
};
|
||||
const matchNamed = (term) => {
|
||||
const needle = term.trim().toLowerCase();
|
||||
if (!needle) return [];
|
||||
return Object.entries(LAYERS)
|
||||
.filter(([, words]) =>
|
||||
words.some((word) => needle.length >= 3 && word.startsWith(needle)),
|
||||
)
|
||||
.map(([id, words]) => ({
|
||||
id,
|
||||
score: 2,
|
||||
exact: words.includes(needle) || words.includes(`${needle}s`),
|
||||
}));
|
||||
};
|
||||
|
||||
test('near-miss lines read as people mean them', () => {
|
||||
const read = (text) => layersOf(parseOmnibar(text, matchNamed).steps);
|
||||
const clear = [{ kind: 'camera', act: 'clear' }];
|
||||
assert.deepEqual(read('hide everything'), clear);
|
||||
assert.deepEqual(read('remove everything'), clear);
|
||||
assert.equal(isPanelText('hide everything'), false);
|
||||
assert.equal(isPanelText('close all panels'), true);
|
||||
assert.deepEqual(read('track flights near austin'), [
|
||||
{ kind: 'place', place: 'austin' },
|
||||
{ kind: 'layer', id: 'flights', enabled: true },
|
||||
]);
|
||||
assert.deepEqual(read('follow AAL123'), [
|
||||
{ kind: 'follow', query: 'aal123' },
|
||||
]);
|
||||
assert.deepEqual(read('show earthquake data layer'), [
|
||||
{ kind: 'layer', id: 'earthquakes', enabled: true },
|
||||
]);
|
||||
assert.equal(isPanelText('show earthquake data layer'), false);
|
||||
assert.equal(read('open data layers')[0].item, 'data-panel');
|
||||
assert.equal(
|
||||
read('open space missions panel')[0].item,
|
||||
'space-missions-panel',
|
||||
);
|
||||
assert.equal(
|
||||
read('close the missions panel')[0].item,
|
||||
'space-missions-panel',
|
||||
);
|
||||
// Without "panel" it is the layer, not its panel.
|
||||
assert.equal(isPanelText('show space missions'), false);
|
||||
assert.deepEqual(read('go to trinidad and tobago and show flights'), [
|
||||
{ kind: 'place', place: 'trinidad and tobago' },
|
||||
{ kind: 'layer', id: 'flights', enabled: true },
|
||||
]);
|
||||
// "fire" is a whole layer word, so "Fire Island" is ambiguous: the whole
|
||||
// line is offered as a place first (see the Omnibar test).
|
||||
assert.equal(parseOmnibar('Fire Island', matchNamed).ambiguous, true);
|
||||
assert.deepEqual(read('Show Low, AZ'), [
|
||||
{ kind: 'place', place: 'Show Low, AZ' },
|
||||
]);
|
||||
// Words that also start place names ask only in a longer line.
|
||||
for (const place of ['Can Tho', 'Tell City']) {
|
||||
const { steps, question } = parseOmnibar(place, matchNamed);
|
||||
assert.equal(question, false, place);
|
||||
assert.deepEqual([...steps], [{ kind: 'place', place }]);
|
||||
}
|
||||
assert.equal(parseOmnibar('can you show me', matchNamed).question, true);
|
||||
assert.equal(parseOmnibar('Can Tho?', matchNamed).question, true);
|
||||
assert.equal(parseOmnibar('what is here', matchNamed).question, true);
|
||||
});
|
||||
|
||||
test('a magnitude floor is read for earthquakes only', () => {
|
||||
assert.deepEqual(magnitudeFloor('quakes above m5 in japan', matchNamed), {
|
||||
text: 'quakes in japan',
|
||||
minMagnitude: 5,
|
||||
});
|
||||
assert.deepEqual(magnitudeFloor('earthquakes m4.5+ near tokyo', matchNamed), {
|
||||
text: 'earthquakes near tokyo',
|
||||
minMagnitude: 4.5,
|
||||
});
|
||||
assert.deepEqual(magnitudeFloor('flights over m25', matchNamed), {
|
||||
text: 'flights over m25',
|
||||
minMagnitude: null,
|
||||
});
|
||||
assert.deepEqual(magnitudeFloor('flights near austin', matchNamed), {
|
||||
text: 'flights near austin',
|
||||
minMagnitude: null,
|
||||
});
|
||||
});
|
||||
|
||||
test('place names holding a command word are places, or ambiguous at most', () => {
|
||||
const read = (text) => parseOmnibar(text, matchNamed);
|
||||
// The cockpit and the radio need a verb.
|
||||
for (const text of [
|
||||
'Cockpit Country, Jamaica',
|
||||
'cockpit',
|
||||
'cockpit view',
|
||||
'Rock and Roll Hall of Fame',
|
||||
]) {
|
||||
const { steps } = read(text);
|
||||
assert.deepEqual([...steps], [{ kind: 'place', place: text }], text);
|
||||
}
|
||||
assert.deepEqual([...read('enter cockpit').steps], [{ kind: 'cockpit' }]);
|
||||
assert.equal(
|
||||
read('Radio City Music Hall').steps.some((step) => step.kind === 'radio'),
|
||||
false,
|
||||
);
|
||||
// One keyword without a verb beside the rest of a name: the whole line is
|
||||
// offered as a place ahead of the plan.
|
||||
for (const text of [
|
||||
'Radio City Music Hall',
|
||||
'Radio Free Europe',
|
||||
'Thermal, California',
|
||||
'Tilt Cove',
|
||||
'Hud Valley',
|
||||
'tokyo traffic',
|
||||
])
|
||||
assert.equal(read(text).ambiguous, true, text);
|
||||
// A verb, a joining "and" or "near" makes it a plan.
|
||||
// Keywords nobody asked for, joined to the rest of a name, leave the
|
||||
// whole line a place first too ("Storm Lake and Spencer").
|
||||
assert.equal(read('noir and tokyo').ambiguous, true);
|
||||
for (const text of [
|
||||
'flights near austin',
|
||||
'show traffic in tokyo',
|
||||
'tilt and go to cove',
|
||||
'show noir and tokyo',
|
||||
])
|
||||
assert.equal(read(text).ambiguous, false, text);
|
||||
});
|
||||
|
||||
test('nearest to, several places, and what can be followed', () => {
|
||||
const read = (text) => layersOf(parseOmnibar(text, matchNamed).steps);
|
||||
assert.deepEqual(read('nearest plane to Heathrow'), [
|
||||
{ kind: 'place', place: 'heathrow' },
|
||||
{ kind: 'nearest' },
|
||||
]);
|
||||
const both = parseOmnibar('flights near New York and Paris', matchNamed);
|
||||
assert.equal(both.steps[0].place, 'new york');
|
||||
assert.deepEqual(both.extraPlaces, ['paris']);
|
||||
assert.deepEqual(read('Follow Me Bar'), [
|
||||
{ kind: 'place', place: 'Follow Me Bar' },
|
||||
]);
|
||||
// A name without a digit is followed only when it is loaded on the map.
|
||||
assert.deepEqual(
|
||||
layersOf(
|
||||
parseOmnibar('follow the iss', matchNamed, {
|
||||
isEntity: (name) => name === 'iss',
|
||||
}).steps,
|
||||
),
|
||||
[{ kind: 'follow', query: 'iss' }],
|
||||
);
|
||||
assert.deepEqual(read('Track Hill'), [
|
||||
{ kind: 'place', place: 'Track Hill' },
|
||||
]);
|
||||
assert.deepEqual(read('follow UAL 123'), [
|
||||
{ kind: 'follow', query: 'ual 123' },
|
||||
]);
|
||||
});
|
||||
|
||||
test('a magnitude floor is no part of the place', () => {
|
||||
const { text, minMagnitude } = magnitudeFloor(
|
||||
'show me earthquakes above m5 in japan',
|
||||
matchNamed,
|
||||
);
|
||||
assert.equal(minMagnitude, 5);
|
||||
assert.deepEqual(layersOf(parseOmnibar(text, matchNamed).steps), [
|
||||
{ kind: 'place', place: 'japan' },
|
||||
{ kind: 'layer', id: 'earthquakes', enabled: true },
|
||||
]);
|
||||
});
|
||||
|
||||
test('ar and he mark every Omnibar string alike with a right-to-left mark', async () => {
|
||||
const { readFile } = await import('node:fs/promises');
|
||||
// Every message the Omnibar's code passes to t(), msg() or tn(): after a
|
||||
// colon or comma, before a placeholder or Latin text, both catalogs put
|
||||
// U+200F, so the punctuation stays with the right-to-left text before it.
|
||||
const sources = await Promise.all(
|
||||
[
|
||||
'./views/panels/Omnibar.vue',
|
||||
'./views/panels/VoiceVisualizer.vue',
|
||||
'./omnibarIntent.js',
|
||||
'./omnibarRows.js',
|
||||
'./omnibarGuide.js',
|
||||
'./leftPanelRail.js',
|
||||
].map((file) => readFile(new URL(file, import.meta.url), 'utf8')),
|
||||
);
|
||||
const code = sources.join('\n');
|
||||
// Single- or double-quoted, as t('…') / msg("…") / tn(n, '…', "…").
|
||||
const STRING = String.raw`'((?:\\.|[^'\\])*)'|"((?:\\.|[^"\\])*)"`;
|
||||
const literal = (match, from) => match[from] ?? match[from + 1];
|
||||
const keys = new Set([
|
||||
...[
|
||||
...code.matchAll(
|
||||
new RegExp(String.raw`\b(?:t|msg)\(\s*(?:${STRING})`, 'g'),
|
||||
),
|
||||
].map((match) => literal(match, 1)),
|
||||
...[
|
||||
...code.matchAll(
|
||||
new RegExp(
|
||||
String.raw`\btn\([^,]+,\s*(?:'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"),\s*(?:${STRING})`,
|
||||
'g',
|
||||
),
|
||||
),
|
||||
].map((match) => literal(match, 1)),
|
||||
]);
|
||||
assert.ok(keys.size > 100, `${keys.size} Omnibar messages`);
|
||||
const unmarked = /[:\u060c,] (?!\u200f)(?=[{A-Za-z\u00ab\u05f4"])/;
|
||||
for (const locale of ['ar', 'he']) {
|
||||
const catalog = JSON.parse(
|
||||
await readFile(
|
||||
new URL(`../i18n/locales/${locale}.json`, import.meta.url),
|
||||
'utf8',
|
||||
),
|
||||
);
|
||||
for (const key of keys) {
|
||||
const entry = catalog[key];
|
||||
assert.ok(entry, `${locale} has ${key}`);
|
||||
for (const text of typeof entry === 'string'
|
||||
? [entry]
|
||||
: Object.values(entry))
|
||||
assert.doesNotMatch(text, unmarked, `${locale}: ${key}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('a "go to" clause is all place, and radio verbs apply to the radio', () => {
|
||||
const read = (text) => layersOf(parseOmnibar(text, matchNamed).steps);
|
||||
for (const [text, place] of [
|
||||
['go to cockpit country', 'cockpit country'],
|
||||
['go to Thermal, California', 'Thermal, California'],
|
||||
['fly to Tilt Cove', 'Tilt Cove'],
|
||||
['go to Night Vision Way', 'Night Vision Way'],
|
||||
['go to Whole Earth Provision', 'Whole Earth Provision'],
|
||||
])
|
||||
assert.deepEqual(read(text), [{ kind: 'place', place }], text);
|
||||
assert.deepEqual(read('go to austin, clear everything'), [
|
||||
{ kind: 'place', place: 'austin' },
|
||||
{ kind: 'camera', act: 'clear' },
|
||||
]);
|
||||
assert.deepEqual(read('go to'), []);
|
||||
assert.deepEqual(read('play radio in Kill Devil Hills'), [
|
||||
{ kind: 'place', place: 'kill devil hills' },
|
||||
{ kind: 'radio', action: 'enable' },
|
||||
]);
|
||||
assert.deepEqual(read('enter the cockpit view'), [{ kind: 'cockpit' }]);
|
||||
// Only a real question asks GEV by default; small talk goes there too.
|
||||
assert.equal(parseOmnibar('hi', matchNamed).asks, false);
|
||||
// Small talk is no question: it may be a place, with Ask GEV after it.
|
||||
assert.equal(parseOmnibar('hi', matchNamed).question, false);
|
||||
assert.equal(parseOmnibar('what is here', matchNamed).asks, true);
|
||||
// A long line is not split word by word into a layer and a place.
|
||||
let asked = 0;
|
||||
parseOmnibar('a b c d e f g h i j k l m n o p', (term) => {
|
||||
asked++;
|
||||
return matchNamed(term);
|
||||
});
|
||||
assert.ok(asked <= 2, `${asked} layer lookups`);
|
||||
});
|
||||
|
||||
test('a request ending a "go to" clause is peeled off, and the line is ambiguous', () => {
|
||||
const read = (text) => parseOmnibar(text, matchNamed);
|
||||
for (const [text, place, step] of [
|
||||
['go to tokyo in noir', 'tokyo', { kind: 'style', style: 'noir' }],
|
||||
['go to tokyo, noir', 'tokyo', { kind: 'style', style: 'noir' }],
|
||||
['go to Tokyo, north up', 'tokyo', { kind: 'camera', act: 'northUp' }],
|
||||
[
|
||||
'take me to Austin in thermal',
|
||||
'austin',
|
||||
{ kind: 'style', style: 'thermal' },
|
||||
],
|
||||
[
|
||||
'go to London with flights',
|
||||
'london',
|
||||
{ kind: 'layer', id: 'flights', enabled: true },
|
||||
],
|
||||
[
|
||||
'go to tokyo show flights',
|
||||
'tokyo',
|
||||
{ kind: 'layer', id: 'flights', enabled: true },
|
||||
],
|
||||
]) {
|
||||
const parsed = read(text);
|
||||
assert.equal(parsed.ambiguous, true, text);
|
||||
assert.equal(parsed.peeled, true, text);
|
||||
assert.deepEqual(
|
||||
layersOf(parsed.steps),
|
||||
[{ kind: 'place', place }, step],
|
||||
text,
|
||||
);
|
||||
}
|
||||
for (const text of [
|
||||
'go to Thermal, California',
|
||||
'fly to Tilt Cove',
|
||||
'go to Night Vision Way',
|
||||
'go to cockpit country',
|
||||
])
|
||||
assert.equal(read(text).steps.length, 1, text);
|
||||
// A joining word left alone names no place.
|
||||
assert.deepEqual(
|
||||
layersOf(read('go to Austin and show flights in noir').steps),
|
||||
[
|
||||
{ kind: 'place', place: 'austin' },
|
||||
{ kind: 'style', style: 'noir' },
|
||||
{ kind: 'layer', id: 'flights', enabled: true },
|
||||
],
|
||||
);
|
||||
// A named layer without a verb may be a name: "Hurricane, Utah".
|
||||
assert.equal(read('fires, utah').ambiguous, true);
|
||||
assert.equal(read('flights near austin').placeFrom, 'near');
|
||||
// A comma line without "?" is never a question.
|
||||
for (const text of ['Why, Arizona', 'What Cheer, Iowa', 'Can Tho, Vietnam'])
|
||||
assert.equal(read(text).question, false, text);
|
||||
assert.equal(read('why, arizona?').question, true);
|
||||
});
|
||||
|
||||
test('the one verb test reads any letter case', async () => {
|
||||
const { hasActionVerb } = await import('./omnibarIntent.js');
|
||||
for (const text of [
|
||||
'Turn on the radio',
|
||||
'Turn On Radio',
|
||||
'Draw',
|
||||
'CLEAR THE MAP',
|
||||
])
|
||||
assert.equal(hasActionVerb(text), true, text);
|
||||
for (const text of [
|
||||
'Kill Devil Hills',
|
||||
'Show',
|
||||
'See',
|
||||
'Clear Lake',
|
||||
'Tilt Cove',
|
||||
])
|
||||
assert.equal(hasActionVerb(text), text === 'Show', text);
|
||||
});
|
||||
|
||||
test('every place word is still a bundled place name', async () => {
|
||||
const { readFile, readdir } = await import('node:fs/promises');
|
||||
const { PLACE_WORDS } = await import('./omnibarEnter.js');
|
||||
const names = new Set();
|
||||
const cities = JSON.parse(
|
||||
await readFile(
|
||||
new URL(
|
||||
'../data/local_data/wikidata_cities/cities.json',
|
||||
import.meta.url,
|
||||
),
|
||||
'utf8',
|
||||
),
|
||||
);
|
||||
for (const row of cities.rows) names.add(row[0].toLowerCase());
|
||||
const dir = new URL('../data/local_data/wikidata_places/', import.meta.url);
|
||||
for (const file of await readdir(dir))
|
||||
if (/^-?\d+_-?\d+\.json$/.test(file))
|
||||
for (const row of JSON.parse(await readFile(new URL(file, dir), 'utf8'))
|
||||
.rows)
|
||||
names.add(row[0].toLowerCase());
|
||||
for (const word of PLACE_WORDS) assert.ok(names.has(word), word);
|
||||
});
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,648 @@
|
||||
// src/ui/omnibarRows.test.mjs — the Omnibar's one pipeline from typed text
|
||||
// to rows, read without the DOM: what Enter runs for a line before any row is
|
||||
// chosen, what may go to the place service, and the rows themselves.
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { createOmnibar, readLine } from './omnibarRows.js';
|
||||
import { normalizeLine } from './omnibarIntent.js';
|
||||
|
||||
const LAYERS = [
|
||||
{ id: 'flights', name: 'Live Flights', enabled: false },
|
||||
{ id: 'military', name: 'Military Flights', enabled: false },
|
||||
{ id: 'radio', name: 'Radio', enabled: false },
|
||||
{ id: 'cctv', name: 'CCTV', enabled: false },
|
||||
{ id: 'earthquakes', name: 'Earthquakes', enabled: false },
|
||||
{ id: 'traffic', name: 'Traffic', enabled: false },
|
||||
{ id: 'weather-radar', name: 'Weather radar', enabled: false },
|
||||
];
|
||||
const layers = (on = []) =>
|
||||
LAYERS.map((layer) => ({ ...layer, enabled: on.includes(layer.id) }));
|
||||
|
||||
/** One step of a plan, as the table writes it. */
|
||||
function stepOutcome(step) {
|
||||
switch (step.kind) {
|
||||
case 'place':
|
||||
return `fly(${step.place})`;
|
||||
case 'layer':
|
||||
return `layer(${step.layer.id},${step.enabled ? 'on' : 'off'})`;
|
||||
case 'style':
|
||||
return `style(${step.style})`;
|
||||
case 'stack':
|
||||
return `map(${step.stack})`;
|
||||
case 'camera':
|
||||
return `camera(${step.act || step.args?.motion || step.args?.direction || step.name})`;
|
||||
case 'hud':
|
||||
return `hud(${step.visible})`;
|
||||
case 'panel':
|
||||
return `panel(${step.action} ${step.item || step.side})`;
|
||||
case 'radio':
|
||||
return `radio(${step.action || 'enable'})`;
|
||||
case 'follow':
|
||||
return `follow(${step.query})`;
|
||||
default:
|
||||
return step.kind;
|
||||
}
|
||||
}
|
||||
|
||||
/** What Enter runs for a line before any row is chosen. */
|
||||
function outcome(text, { on = [], places = [] } = {}) {
|
||||
const omnibar = createOmnibar({ layers: layers(on) });
|
||||
const { rows, defaultIndex } = omnibar.rows(text, { places });
|
||||
const row = rows[defaultIndex];
|
||||
if (!row) return 'nothing';
|
||||
switch (row.kind) {
|
||||
case 'place':
|
||||
return `search(${row.place})`;
|
||||
case 'layer':
|
||||
return `layer(${row.id},${row.enabled ? 'on' : 'off'})`;
|
||||
case 'ask':
|
||||
return `ask(${row.query})`;
|
||||
case 'plan':
|
||||
return row.steps.map(stepOutcome).join(' + ');
|
||||
default:
|
||||
return row.kind;
|
||||
}
|
||||
}
|
||||
|
||||
// Every line is read with no row chosen. `search(q)` is the place search,
|
||||
// `nothing` means Enter runs nothing.
|
||||
const OUTCOMES = [
|
||||
// A switch after what it switches is a switch, never a place.
|
||||
['noir off', 'style(normal)'],
|
||||
['Noir off', 'style(normal)'],
|
||||
['noir on', 'style(noir)'],
|
||||
['turn off noir', 'style(normal)'],
|
||||
['thermal off', 'style(normal)'],
|
||||
['night vision off', 'style(normal)'],
|
||||
['orbit off', 'camera(stop)'],
|
||||
['osm off', 'nothing'],
|
||||
['hud off', 'hud(off)'],
|
||||
['radio off', 'radio(disable)'],
|
||||
['cctv off', 'layer(cctv,off)'],
|
||||
['Bath on', 'search(Bath on)'],
|
||||
// A verb ends at a space: hyphenated names are names.
|
||||
['Hide-A-Way Lake noir', 'search(Hide-A-Way Lake noir)'],
|
||||
['Hide-A-Way Lake', 'search(Hide-A-Way Lake)'],
|
||||
['Show-Me Lake radio', 'search(Show-Me Lake radio)'],
|
||||
// A closing full stop, curly apostrophes and "please".
|
||||
['Show flights.', 'layer(flights,on)'],
|
||||
['show flights!', 'layer(flights,on)'],
|
||||
['please show flights', 'layer(flights,on)'],
|
||||
['Please, show flights', 'layer(flights,on)'],
|
||||
['show flights please', 'layer(flights,on)'],
|
||||
['North up.', 'camera(northUp)'],
|
||||
['please north up', 'camera(northUp)'],
|
||||
['Clear all layers!', 'camera(clear)'],
|
||||
['what’s here', 'ask(what’s here)'],
|
||||
['what’s here?', 'ask(what’s here?)'],
|
||||
['Paris, Texas.', 'search(Paris, Texas.)'],
|
||||
['Washington D.C.', 'search(Washington D.C.)'],
|
||||
['please', 'search(please)'],
|
||||
// Ask GEV (a billed call) needs a question, not a name.
|
||||
['Do it Best Hardware', 'search(Do it Best Hardware)'],
|
||||
['Can You Imagine', 'search(Can You Imagine)'],
|
||||
['Is This It', 'search(Is This It)'],
|
||||
['Where Is My Mind', 'search(Where Is My Mind)'],
|
||||
['can you show me', 'nothing'],
|
||||
['is it raining in tokyo', 'nothing'],
|
||||
['is it raining in tokyo?', 'ask(is it raining in tokyo?)'],
|
||||
['where is my mind', 'ask(where is my mind)'],
|
||||
['how far is paris', 'ask(how far is paris)'],
|
||||
['Can Tho City', 'search(Can Tho City)'],
|
||||
['Is there', 'search(Is there)'],
|
||||
// Pasted sentences are no place, and words about a layer are no place.
|
||||
['Show radio stations', 'layer(radio,on)'],
|
||||
['show radio station', 'layer(radio,on)'],
|
||||
['show flights here', 'layer(flights,on)'],
|
||||
['flights here', 'search(flights here)'],
|
||||
['I went to the store yesterday and it was really great', 'nothing'],
|
||||
['the quick brown fox jumps over the lazy dog', 'nothing'],
|
||||
['we saw so many flights over the city and it was loud', 'nothing'],
|
||||
['go to Austin and show flights', 'fly(austin) + layer(flights,on)'],
|
||||
// keywords without a verb ask for nothing,
|
||||
// however many clauses they fill, and names keep their words.
|
||||
['Fire and Rain', 'search(Fire and Rain)'],
|
||||
['Rain, Thermal', 'search(Rain, Thermal)'],
|
||||
['Weather and Traffic', 'search(Weather and Traffic)'],
|
||||
// Each word alone is a command that runs ("orbit", "tilt").
|
||||
['Orbit and Tilt', 'camera(orbit) + camera(tilt)'],
|
||||
['Noir and Thermal', 'search(Noir and Thermal)'],
|
||||
['Trains and Boats and Planes', 'search(Trains and Boats and Planes)'],
|
||||
['Storm Lake and Spencer', 'search(Storm Lake and Spencer)'],
|
||||
['Fire Island and Ocean Beach', 'search(Fire Island and Ocean Beach)'],
|
||||
['Thermal and Indio', 'search(Thermal and Indio)'],
|
||||
['Please Touch Museum', 'search(Please Touch Museum)'],
|
||||
['Kindly Lane', 'search(Kindly Lane)'],
|
||||
['Pretty Please', 'search(Pretty Please)'],
|
||||
['Yahoo!', 'search(Yahoo!)'],
|
||||
['Draw Bridge', 'search(Draw Bridge)'],
|
||||
['draw well', 'search(draw well)'],
|
||||
['draw a line', 'open-draw'],
|
||||
['How To Train Your Dragon', 'nothing'],
|
||||
['how to see satelites', 'ask(how to see satelites)'],
|
||||
['Train Station', 'search(Train Station)'],
|
||||
['Traffic Status', 'search(Traffic Status)'],
|
||||
['Remove Island', 'search(Remove Island)'],
|
||||
['Toggle Inn', 'search(Toggle Inn)'],
|
||||
['Disable Canyon', 'search(Disable Canyon)'],
|
||||
['remove island', 'nothing'],
|
||||
['show noir and show cctv', 'style(noir) + layer(cctv,on)'],
|
||||
// a name with "?" is offered to GEV,
|
||||
// never sent; a question's form is.
|
||||
['New York?', 'nothing'],
|
||||
['Truth or Consequences?', 'nothing'],
|
||||
['Ho Chi Minh City?', 'nothing'],
|
||||
['Santa Cruz de la Sierra?', 'nothing'],
|
||||
['東京都?', 'nothing'],
|
||||
['東京はどこ?', 'ask(東京はどこ?)'],
|
||||
['is it far?', 'ask(is it far?)'],
|
||||
['how about the weather in paris today?', 'nothing'],
|
||||
['123–45–6789', 'nothing'],
|
||||
['what is 4111–1111–1111–1111?', 'nothing'],
|
||||
// a switch with its place after "in" asks;
|
||||
// a vague "how do I" runs no walk; names with "senha" or "xox" in them
|
||||
// and addresses with numbers are places.
|
||||
['turn on radio in tokyo', 'fly(tokyo) + radio(enable)'],
|
||||
['enable radio in tokyo', 'fly(tokyo) + radio(enable)'],
|
||||
['turn on noir in tokyo', 'fly(tokyo) + style(noir)'],
|
||||
['how do I share', 'guide'],
|
||||
['how do I sha', 'nothing'],
|
||||
['Sachsenhausen', 'search(Sachsenhausen)'],
|
||||
['Xoxocotla', 'search(Xoxocotla)'],
|
||||
['Meguro Honmachi 2-chome', 'search(Meguro Honmachi 2-chome)'],
|
||||
[
|
||||
'1600 Pennsylvania Ave NW Washington DC 20500',
|
||||
'search(1600 Pennsylvania Ave NW Washington DC 20500)',
|
||||
],
|
||||
// A long comma address beside a layer word is a sentence; a verb that
|
||||
// starts a name asks for nothing; small talk asks no question.
|
||||
['San Jose, Santa Clara County, California, USA flights', 'nothing'],
|
||||
['Start Point noir', 'search(Start Point noir)'],
|
||||
['Track Hill noir', 'search(Track Hill noir)'],
|
||||
['Open Bay north up', 'search(Open Bay north up)'],
|
||||
['show noir', 'style(noir)'],
|
||||
['play radio tokyo', 'fly(tokyo) + radio(enable)'],
|
||||
["what's up", "search(what's up)"],
|
||||
["how's it going", "search(how's it going)"],
|
||||
["what's the weather in paris", "ask(what's the weather in paris)"],
|
||||
['Hauptstrasse 12 10115 Berlin', 'search(Hauptstrasse 12 10115 Berlin)'],
|
||||
// "of" and "at" may join the words of a name; CJK addresses and
|
||||
// postcodes are places.
|
||||
['Planes of Fame Air Museum', 'search(Planes of Fame Air Museum)'],
|
||||
['Boats at Sea', 'search(Boats at Sea)'],
|
||||
['flights over texas', 'fly(texas) + layer(flights,on)'],
|
||||
['北京市朝阳区建国路88号', 'search(北京市朝阳区建国路88号)'],
|
||||
['東京都港区六本木6丁目', 'search(東京都港区六本木6丁目)'],
|
||||
['Washington DC 20500-0003', 'search(Washington DC 20500-0003)'],
|
||||
['Calle 100 # 19-61 Bogota', 'search(Calle 100 # 19-61 Bogota)'],
|
||||
// Addresses that look like numbers to keep, and long names, are offered
|
||||
// to search on purpose; Enter runs nothing. "Track 7" and "Nearest Plane
|
||||
// Crash Site" are names.
|
||||
['Tverskaya 13 125009 Moscow', 'search(Tverskaya 13 125009 Moscow)'],
|
||||
['Москва, ул. Тверская, д. 13, 125009', 'nothing'],
|
||||
['San Miguel de las Piedras Primera Sección', 'nothing'],
|
||||
['Goto', 'search(Goto)'],
|
||||
['goto tokyo', 'search(tokyo)'],
|
||||
['Track 7', 'search(Track 7)'],
|
||||
['Track 29', 'search(Track 29)'],
|
||||
['Nearest Plane Crash Site', 'search(Nearest Plane Crash Site)'],
|
||||
['nearest plane', 'nearest'],
|
||||
// Lines the mounted Enter table pins too, read through the module.
|
||||
['tokyo traffic', 'search(tokyo traffic)'],
|
||||
['flights near tokyo', 'fly(tokyo) + layer(flights,on)'],
|
||||
['radio near Clear Lake', 'search(clear lake)'],
|
||||
['Thermal', 'search(Thermal)'],
|
||||
['Thermal, California', 'search(Thermal, California)'],
|
||||
['radio', 'search(radio)'],
|
||||
['share', 'nothing'],
|
||||
['hide', 'nothing'],
|
||||
['Turn on the radio', 'layer(radio,on)'],
|
||||
];
|
||||
|
||||
for (const [text, expected] of OUTCOMES)
|
||||
test(`Enter on ${JSON.stringify(text)} runs ${expected}`, () => {
|
||||
assert.equal(outcome(text), expected);
|
||||
});
|
||||
|
||||
test('"show flights" with Live Flights on offers Live Flights, not Military Flights', () => {
|
||||
assert.equal(
|
||||
outcome('show flights', { on: ['flights'] }),
|
||||
'layer(flights,on)',
|
||||
);
|
||||
assert.equal(
|
||||
outcome('turn on flights', { on: ['flights'] }),
|
||||
'layer(flights,on)',
|
||||
);
|
||||
const { rows, defaultIndex } = createOmnibar({
|
||||
layers: layers(['flights']),
|
||||
}).rows('show flights');
|
||||
// Nothing to switch on the default row; Military Flights is offered after.
|
||||
assert.equal(rows[defaultIndex].hint, 'Layer');
|
||||
assert.ok(rows.some((row) => row.id === 'military'));
|
||||
assert.equal(outcome('hide flights', { on: [] }), 'layer(flights,off)');
|
||||
// "military" names Military Flights, never Live Flights.
|
||||
assert.equal(outcome('show military'), 'layer(military,on)');
|
||||
});
|
||||
|
||||
test('a layer near a place cannot admit an unrelated bare style step', () => {
|
||||
assert.doesNotMatch(outcome('flights near Austin and noir'), /style\(noir\)/);
|
||||
assert.equal(
|
||||
outcome('flights near Austin'),
|
||||
'fly(austin) + layer(flights,on)',
|
||||
);
|
||||
});
|
||||
|
||||
test('private text never reaches the place service, the search or GEV', () => {
|
||||
const omnibar = createOmnibar({ layers: layers() });
|
||||
for (const text of [
|
||||
'123 45 6789',
|
||||
'123456789',
|
||||
'123-45-6789',
|
||||
'4111 1111',
|
||||
'١٢٣٤, ٥٦٧٨',
|
||||
'what is my pass\u200bword: violet?',
|
||||
'4111-1111-1111-1111',
|
||||
'+1 415 555',
|
||||
'415 555 0',
|
||||
'415.555.0100',
|
||||
'hunter22',
|
||||
'letmein1',
|
||||
'Tr0ub4dor&3',
|
||||
'pa$$w0rd',
|
||||
'token: abc',
|
||||
'api key=xyz',
|
||||
'password hunter2',
|
||||
'[email protected]',
|
||||
'4111 1111 1111 1111',
|
||||
'john@example.com',
|
||||
'sk_live_abc',
|
||||
'٤١١١ ١١١١ ١١١١ ١١١١',
|
||||
'४१११ ११११ ११११ ११११',
|
||||
'4111.1111.1111.1111',
|
||||
'what is 4111.1111.1111.1111',
|
||||
'where is john@example.com',
|
||||
'card ٤١١١١١١١١١١١١١١١ valid?',
|
||||
'123–45–6789',
|
||||
'415‐555‐0100',
|
||||
'415−555−0100',
|
||||
'4111:1111:1111:1111',
|
||||
'4111|1111|1111|1111',
|
||||
'4111\u200b1111\u200b1111\u200b1111',
|
||||
'contraseña: hunter',
|
||||
'Passwort: geheim',
|
||||
'mot de passe: chat',
|
||||
'пароль qwerty',
|
||||
'api key abcdefgh',
|
||||
]) {
|
||||
assert.equal(omnibar.placeQuery(text), null, text);
|
||||
assert.equal(omnibar.countRequest(text), null, text);
|
||||
const { rows, defaultIndex } = omnibar.rows(text);
|
||||
// Only a row to search it as a place on purpose, never by Enter.
|
||||
assert.ok(
|
||||
rows.every((row) => row.kind === 'place' && row.explicit),
|
||||
text,
|
||||
);
|
||||
assert.equal(defaultIndex, -1, text);
|
||||
}
|
||||
// Callsigns, postcodes, coordinates and street numbers are not secrets.
|
||||
assert.equal(omnibar.placeQuery('SW1A 1AA'), 'SW1A 1AA');
|
||||
assert.equal(omnibar.placeQuery('10 Downing Street'), '10 Downing Street');
|
||||
assert.equal(omnibar.placeQuery('Route 66'), 'Route 66');
|
||||
for (const callsign of ['UAL2110', 'BAW15K', 'N123AB'])
|
||||
assert.equal(omnibar.placeQuery(callsign), null, callsign);
|
||||
for (const text of ['30.2672, -97.7431', '14R PU 2090 4906']) {
|
||||
const { rows, defaultIndex } = omnibar.rows(text);
|
||||
assert.equal(rows[defaultIndex].kind, 'place', text);
|
||||
assert.ok(rows[defaultIndex].coords, text);
|
||||
}
|
||||
});
|
||||
|
||||
test('private text still finds things already on the map, locally', () => {
|
||||
const omnibar = createOmnibar({ layers: layers() });
|
||||
const found = [];
|
||||
const { rows } = omnibar.rows('366123456', {
|
||||
entities: (text) => {
|
||||
found.push(text);
|
||||
return [
|
||||
{
|
||||
key: 'v1',
|
||||
icon: 'directions_boat',
|
||||
identity: 'v1',
|
||||
title: '366123456',
|
||||
layerName: 'Vessels',
|
||||
},
|
||||
];
|
||||
},
|
||||
});
|
||||
assert.deepEqual(found, ['366123456']);
|
||||
assert.deepEqual(
|
||||
rows.map((row) => row.kind),
|
||||
['entity'],
|
||||
);
|
||||
});
|
||||
|
||||
test('a map item named like a place follows the place; a callsign leads', () => {
|
||||
const omnibar = createOmnibar({ layers: layers() });
|
||||
const entities = (text) =>
|
||||
[
|
||||
{
|
||||
key: 's1',
|
||||
icon: 'directions_boat',
|
||||
identity: 's1',
|
||||
title: 'HAMBURG',
|
||||
layerName: 'Vessels',
|
||||
},
|
||||
{
|
||||
key: 'f1',
|
||||
icon: 'flight',
|
||||
identity: 'f1',
|
||||
title: 'UAL123',
|
||||
layerName: 'Flights',
|
||||
},
|
||||
].filter((item) => item.title.toLowerCase().startsWith(text.toLowerCase()));
|
||||
const hamburg = omnibar.rows('Hamburg', { entities });
|
||||
assert.equal(hamburg.rows[hamburg.defaultIndex].kind, 'place');
|
||||
assert.equal(hamburg.rows[1].kind, 'entity');
|
||||
const callsign = omnibar.rows('UAL123', { entities });
|
||||
assert.equal(callsign.rows[callsign.defaultIndex].kind, 'entity');
|
||||
});
|
||||
|
||||
test('a long name or an address that looks private can be searched on purpose', () => {
|
||||
const omnibar = createOmnibar({ layers: layers() });
|
||||
for (const text of [
|
||||
'Москва, ул. Тверская, д. 13, 125009',
|
||||
'San Miguel de las Piedras Primera Sección',
|
||||
]) {
|
||||
const { rows, defaultIndex } = omnibar.rows(text);
|
||||
assert.equal(defaultIndex, -1, text);
|
||||
const row = rows.find((each) => each.explicit);
|
||||
assert.equal(row?.place, text, text);
|
||||
assert.equal(omnibar.placeQuery(text), null, text);
|
||||
}
|
||||
// A bare number names no place.
|
||||
assert.deepEqual(omnibar.rows('4111 1111 1111 1111').rows, []);
|
||||
});
|
||||
|
||||
test('a pasted sentence is never sent to the place service', () => {
|
||||
const omnibar = createOmnibar({ layers: layers() });
|
||||
for (const text of [
|
||||
'I went to the store yesterday and it was really great',
|
||||
'we saw so many flights over the city and it was loud',
|
||||
'Show radio stations',
|
||||
'noir off',
|
||||
'can you show me',
|
||||
])
|
||||
assert.equal(omnibar.placeQuery(text), null, text);
|
||||
assert.equal(omnibar.placeQuery('Tokyo traffic'), 'Tokyo traffic');
|
||||
assert.equal(omnibar.placeQuery('flights near Tokyo.'), 'tokyo');
|
||||
assert.equal(omnibar.placeQuery('Paris, Texas.'), 'Paris, Texas.');
|
||||
assert.equal(omnibar.placeQuery('go to Paris, noir'), 'paris');
|
||||
assert.equal(omnibar.placeQuery('turn on radio in tokyo'), 'tokyo');
|
||||
assert.equal(omnibar.placeQuery('Sachsenhausen'), 'Sachsenhausen');
|
||||
});
|
||||
|
||||
// The wording people use reaches each feature's own walk, and Enter starts
|
||||
// it.
|
||||
const GUIDE_PHRASES = [
|
||||
['how do i change the map style', 'styles'],
|
||||
['how to change the visual style', 'styles'],
|
||||
['show me how to use night vision', 'styles'],
|
||||
['how do i turn on the hud', 'hud'],
|
||||
['how do i hide the hud', 'hud'],
|
||||
['how do i tilt', 'tilt'],
|
||||
['how do i tilt the map', 'tilt'],
|
||||
['how to tilt the camera', 'tilt'],
|
||||
['how to share this view', 'share'],
|
||||
['how do i share a link', 'share'],
|
||||
['how do i reset', 'globe'],
|
||||
['how do i get back to the globe', 'globe'],
|
||||
['how do i see the whole globe', 'globe'],
|
||||
['how do i point north', 'north'],
|
||||
['how do i use the compass', 'north'],
|
||||
['how do i clear all layers', 'clear'],
|
||||
['how to turn off all layers', 'clear'],
|
||||
['how do i change the map', 'map-source'],
|
||||
['how do i switch to openstreetmap', 'map-source'],
|
||||
['how to measure distance', 'draw'],
|
||||
['how do i draw', 'draw'],
|
||||
['how do i draw a line', 'draw'],
|
||||
['how do i measure an area', 'draw'],
|
||||
['how do i search layers', 'find-layer'],
|
||||
['how do i change language', 'preferences'],
|
||||
];
|
||||
for (const [text, feature] of GUIDE_PHRASES)
|
||||
test(`${JSON.stringify(text)} starts the ${feature} walk`, () => {
|
||||
const { rows, defaultIndex } = createOmnibar({ layers: layers() }).rows(
|
||||
text,
|
||||
);
|
||||
assert.equal(rows[defaultIndex]?.kind, 'guide', text);
|
||||
assert.equal(rows[defaultIndex].guide.feature, feature, text);
|
||||
});
|
||||
|
||||
test('a layer named in full leads a feature topic its words also hold', () => {
|
||||
const all = createOmnibar({
|
||||
layers: [
|
||||
...layers(),
|
||||
{ id: 'recent-imagery', name: 'Recent Imagery', enabled: false },
|
||||
{ id: 'weather-lightning', name: 'Lightning density', enabled: false },
|
||||
],
|
||||
});
|
||||
for (const [text, id] of [
|
||||
['how do I see recent imagery', 'recent-imagery'],
|
||||
['how do I see lightning density', 'weather-lightning'],
|
||||
]) {
|
||||
const { rows, defaultIndex } = all.rows(text);
|
||||
assert.equal(rows[defaultIndex].guide.layer?.id, id, text);
|
||||
}
|
||||
// The Context panel's walk stays first beside a layer named Global
|
||||
// Context.
|
||||
const context = createOmnibar({
|
||||
layers: [
|
||||
{ id: 'military-awareness', name: 'Global Context', enabled: false },
|
||||
],
|
||||
}).rows('how do I open global context');
|
||||
assert.equal(context.rows[context.defaultIndex].guide.feature, 'context');
|
||||
});
|
||||
|
||||
test('only an address that looks like a number may be searched anyway', () => {
|
||||
const omnibar = createOmnibar({ layers: layers() });
|
||||
for (const text of [
|
||||
'password hunter2',
|
||||
'[email protected]',
|
||||
'hunter22',
|
||||
'sk-abc123def',
|
||||
'DE89 3704 0044 0532 0130 00',
|
||||
'pin 1234567',
|
||||
'door code 4421',
|
||||
// A number beside a word that says what it is, or one too long for an
|
||||
// address.
|
||||
'code 12345678 Berlin',
|
||||
'token 12345678 Berlin',
|
||||
'user john pass 12345678',
|
||||
'card 4111 1111 1111 1111 please',
|
||||
'my card is 4111111111111111',
|
||||
'routing 021000021 New York',
|
||||
'phone +1 415 555 0100 office',
|
||||
'BSN 123456782 Utrecht',
|
||||
'medicare 1234567890 Sydney',
|
||||
// Digits and words read as they fold: superscript, circled, full-width
|
||||
// or split by a zero-width space; card and phone words in other
|
||||
// languages.
|
||||
'Berlin ⁴¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹',
|
||||
'Berlin ①②③④⑤⑥⑦⑧⑨⑩',
|
||||
'Main St 12 ¹²³⁴⁵⁶⁷⁸⁹¹²³⁴⁵⁶ Berlin',
|
||||
'card 4111 1111 Berlin',
|
||||
'ca\u200brd 4111 1111 Berlin',
|
||||
'Visa 4111 1111 Berlin',
|
||||
'Kreditkarte 4111 1111 Berlin',
|
||||
'Telefon 912 34 567',
|
||||
])
|
||||
assert.deepEqual(omnibar.rows(text).rows, [], text);
|
||||
for (const text of [
|
||||
'Москва, ул. Тверская, д. 13, 125009',
|
||||
'Jl. Jend. Sudirman No. 52-53, 12190 Jakarta',
|
||||
])
|
||||
assert.ok(
|
||||
omnibar.rows(text).rows.some((row) => row.explicit),
|
||||
text,
|
||||
);
|
||||
});
|
||||
|
||||
test("a line naming a layer still starts that layer's walk", () => {
|
||||
const { rows, defaultIndex } = createOmnibar({ layers: layers() }).rows(
|
||||
'how to turn on flights',
|
||||
);
|
||||
assert.equal(rows[defaultIndex].guide.layer.id, 'flights');
|
||||
});
|
||||
|
||||
test('every feature the words name has a walk', async () => {
|
||||
const { FEATURE_GUIDES } = await import('./omnibarGuide.js');
|
||||
const omnibar = createOmnibar({ layers: layers() });
|
||||
for (const [text] of GUIDE_PHRASES) {
|
||||
const { rows, defaultIndex } = omnibar.rows(text);
|
||||
const feature = rows[defaultIndex].guide.feature;
|
||||
assert.equal(typeof FEATURE_GUIDES[feature], 'function', feature);
|
||||
}
|
||||
});
|
||||
|
||||
test('the line is normalised once, in one place', () => {
|
||||
assert.equal(normalizeLine(' Show flights. '), 'Show flights');
|
||||
// "please" goes only around a request; in a name it stays.
|
||||
assert.equal(readLine('please, north up!'), 'north up');
|
||||
assert.equal(readLine('please show flights'), 'show flights');
|
||||
assert.equal(readLine('Please Touch Museum'), 'Please Touch Museum');
|
||||
assert.equal(readLine('Kindly Lane'), 'Kindly Lane');
|
||||
assert.equal(readLine('Pretty Please'), 'Pretty Please');
|
||||
assert.equal(normalizeLine('please, north up!'), 'please, north up');
|
||||
assert.equal(normalizeLine('what’s here'), "what's here");
|
||||
assert.equal(normalizeLine('東京?'), '東京?');
|
||||
assert.equal(normalizeLine('Tokyo'), 'Tokyo');
|
||||
assert.equal(normalizeLine('Washington D.C.'), 'Washington D.C.');
|
||||
assert.equal(normalizeLine('St. Louis.'), 'St. Louis');
|
||||
assert.equal(normalizeLine('please'), 'please');
|
||||
});
|
||||
|
||||
test('the rows the parser and the Enter rule agree on come from one place', () => {
|
||||
// A command named exactly is the default; one merely begun only follows.
|
||||
const omnibar = createOmnibar({ layers: layers() });
|
||||
assert.equal(outcome('North up'), 'camera(northUp)');
|
||||
assert.equal(outcome('> North up'), 'camera(northUp)');
|
||||
const begun = omnibar.rows('> nort');
|
||||
assert.equal(begun.defaultIndex, -1);
|
||||
assert.equal(begun.rows[0].command, 'north');
|
||||
// A Photon place counts for the credit.
|
||||
const { rows } = omnibar.rows('Shibuya', {
|
||||
places: [
|
||||
{
|
||||
name: 'Shibuya',
|
||||
detail: 'Tokyo, Japan',
|
||||
latitude: 35.66,
|
||||
longitude: 139.7,
|
||||
},
|
||||
],
|
||||
});
|
||||
assert.equal(rows[0].source, 'photon');
|
||||
});
|
||||
|
||||
test('coordinates named as the place are flown to, never refused or looked up', () => {
|
||||
const omnibar = createOmnibar({ layers: layers() });
|
||||
for (const text of [
|
||||
'go to 30.27, -97.74',
|
||||
'go to 48.85 2.35',
|
||||
'go to 14R PU 2090 4906',
|
||||
]) {
|
||||
const { rows, defaultIndex } = omnibar.rows(text);
|
||||
assert.equal(rows[defaultIndex]?.kind, 'place', text);
|
||||
assert.match(rows[defaultIndex].label, /°[NS] .*°[EW]/, text);
|
||||
assert.equal(omnibar.placeQuery(text), null, text);
|
||||
}
|
||||
const { rows, defaultIndex } = omnibar.rows(
|
||||
'show flights near 30.27, -97.74',
|
||||
);
|
||||
assert.equal(rows[defaultIndex].kind, 'plan');
|
||||
assert.equal(omnibar.placeQuery('show flights near 30.27, -97.74'), null);
|
||||
// A card number is still no spot.
|
||||
assert.equal(omnibar.rows('go to 4111 1111 1111 1111').defaultIndex, -1);
|
||||
assert.equal(omnibar.placeQuery('go to ,'), null);
|
||||
});
|
||||
|
||||
test('only a layer in or near a place is counted, never a name', () => {
|
||||
const omnibar = createOmnibar({
|
||||
layers: [...layers(), { id: 'ships', name: 'Ships', enabled: false }],
|
||||
});
|
||||
assert.ok(omnibar.countRequest('flights over Texas'));
|
||||
assert.ok(omnibar.countRequest('quakes above M5 in Japan'));
|
||||
for (const text of [
|
||||
'Ship Bottom',
|
||||
'Radio City Music Hall',
|
||||
'radio settings',
|
||||
'show me how to turn off flights',
|
||||
])
|
||||
assert.equal(omnibar.countRequest(text), null, text);
|
||||
});
|
||||
|
||||
test('a place named Left or Right is no panel to close', () => {
|
||||
const omnibar = createOmnibar({ layers: layers(['flights']) });
|
||||
const { rows, defaultIndex } = omnibar.rows(
|
||||
'hide flights near Left Bank, Paris',
|
||||
);
|
||||
assert.equal(rows[defaultIndex].kind, 'plan');
|
||||
assert.ok(rows[defaultIndex].steps.every((step) => step.kind !== 'panel'));
|
||||
for (const text of ['hide the left panel', 'close right side']) {
|
||||
const read = omnibar.rows(text);
|
||||
assert.ok(
|
||||
read.rows[read.defaultIndex].steps.some((step) => step.kind === 'panel'),
|
||||
text,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('the place service gets the whole place, however it is asked', () => {
|
||||
const omnibar = createOmnibar({ layers: layers() });
|
||||
assert.equal(
|
||||
omnibar.placeQuery('flights near Trinidad and Tobago'),
|
||||
'trinidad and tobago',
|
||||
);
|
||||
assert.equal(
|
||||
omnibar.placeQuery('take me to New York City NY'),
|
||||
'New York City NY',
|
||||
);
|
||||
// A signed longitude or a semicolon stays inside the coordinates.
|
||||
for (const text of [
|
||||
'show flights near 30.27, +97.74',
|
||||
'go to 30.27; -97.74',
|
||||
]) {
|
||||
const { rows, defaultIndex } = omnibar.rows(text);
|
||||
assert.ok(defaultIndex >= 0, text);
|
||||
assert.equal(omnibar.placeQuery(text), null, text);
|
||||
assert.notEqual(rows[defaultIndex].kind, 'none', text);
|
||||
}
|
||||
});
|
||||
|
||||
test('several switches in one line are one plan', () => {
|
||||
const omnibar = createOmnibar({ layers: layers(['flights']) });
|
||||
for (const text of ['hide flights, show radio', 'hide flights; show radio']) {
|
||||
const { rows, defaultIndex } = omnibar.rows(text);
|
||||
assert.equal(rows[defaultIndex].kind, 'plan', text);
|
||||
}
|
||||
});
|
||||
@@ -2,7 +2,6 @@ import { UiLifetime } from './uiLifetime.js';
|
||||
import { prefersCollapsed, readPanelState } from './rail/panelState.js';
|
||||
import { usePanelChromeStore } from './stores/panelChrome.js';
|
||||
import { applicationPinia } from './vueRuntime.js';
|
||||
import { displayPanelScroller } from './displayPanelScroll.js';
|
||||
import { PanelPositionControls } from './panelPositionControls.js';
|
||||
import { PanelLayoutController } from './panelLayoutController.js';
|
||||
import {
|
||||
@@ -23,6 +22,7 @@ const SHARE_PANEL_STATE_SPECS = Object.freeze([
|
||||
{ id: 'radio-panel' },
|
||||
{ id: 'scene-panel' },
|
||||
{ id: 'global-context-panel' },
|
||||
{ id: 'space-missions-panel' },
|
||||
{ id: 'pp-toggles' },
|
||||
{ id: 'param-slider-panel' },
|
||||
]);
|
||||
@@ -49,6 +49,7 @@ const COCKPIT_ENTRY_COLLAPSE_PANEL_IDS = Object.freeze([
|
||||
'utilities-panel',
|
||||
'pp-toggles',
|
||||
'global-context-panel',
|
||||
'space-missions-panel',
|
||||
'radio-panel',
|
||||
]);
|
||||
|
||||
@@ -121,7 +122,7 @@ export class PanelChrome {
|
||||
readDisplayScrollTop: () =>
|
||||
this._displayPortalScrollRestoreOwner === 'standard'
|
||||
? this._standardDisplayScrollTop
|
||||
: displayPanelScroller(this._ppToggles)?.scrollTop || 0,
|
||||
: this._ppToggles?.scrollTop || 0,
|
||||
});
|
||||
}
|
||||
get hud() {
|
||||
|
||||
@@ -427,6 +427,31 @@ test('destroying the chrome inside Cockpit puts back the panels its entry closed
|
||||
assert.equal(data.classList.contains('collapsed'), false);
|
||||
});
|
||||
|
||||
test('Cockpit entry folds the Space Missions panel away and exit brings it back', () => {
|
||||
document.body.innerHTML = `<div id="space-missions-panel"></div>`;
|
||||
const store = usePanelChromeStore(createPinia());
|
||||
const chrome = panelChrome(store);
|
||||
const missions = document.getElementById('space-missions-panel');
|
||||
followPanelState(store, 'space-missions-panel', missions);
|
||||
chrome.enterCockpit();
|
||||
assert.equal(missions.classList.contains('collapsed'), true);
|
||||
chrome.exitCockpit();
|
||||
assert.equal(missions.classList.contains('collapsed'), false);
|
||||
chrome.destroy();
|
||||
});
|
||||
|
||||
test('a share link records whether the Space Missions panel is open', () => {
|
||||
document.body.innerHTML = `<div id="space-missions-panel"></div>`;
|
||||
const store = usePanelChromeStore(createPinia());
|
||||
const chrome = panelChrome(store);
|
||||
const state = chrome._buildSharePanelState();
|
||||
assert.deepEqual(
|
||||
state.specs.filter((spec) => spec.id === 'space-missions-panel'),
|
||||
[{ id: 'space-missions-panel', collapsed: false }],
|
||||
);
|
||||
chrome.destroy();
|
||||
});
|
||||
|
||||
test('the accordion closes peers through the real store, and opens them again', () => {
|
||||
document.body.innerHTML = `
|
||||
<div id="data-panel" data-panel-id="data-panel"></div>
|
||||
|
||||
@@ -57,6 +57,9 @@ const RIGHT_STACK_OBSTACLE_SELECTOR = [
|
||||
'#intel-hud .hud-right-edge',
|
||||
'#cockpit-context',
|
||||
'#cockpit-signal-stream',
|
||||
// The "NEW: GEV Stories" card under the Stories button: panels start below
|
||||
// it while it is up, so its buttons never sit over a panel's controls.
|
||||
'#hPop',
|
||||
'#cesium-credits .cesium-credit-logoContainer',
|
||||
'#cesium-credits .cesium-credit-textContainer',
|
||||
'#gev-credits',
|
||||
@@ -64,6 +67,29 @@ const RIGHT_STACK_OBSTACLE_SELECTOR = [
|
||||
'#gev-voice-control',
|
||||
'#world-timeline',
|
||||
].join(', ');
|
||||
/** The body class the welcome sets while BROWSE STORIES loads. */
|
||||
const OPENING_STORIES = 'first-run-opening-stories';
|
||||
/**
|
||||
* True when a mutation can show or hide the Stories card (`#hPop`): the card
|
||||
* itself coming or going, or the welcome that hides it (`#first-run-launcher`,
|
||||
* and the body class it sets while BROWSE STORIES loads) ending.
|
||||
*/
|
||||
export function movesStoriesCard(record) {
|
||||
if (record.type === 'attributes')
|
||||
return (
|
||||
(record.oldValue || '').split(/\s+/).includes(OPENING_STORIES) !==
|
||||
record.target.classList.contains(OPENING_STORIES)
|
||||
);
|
||||
for (const list of [record.addedNodes, record.removedNodes])
|
||||
for (const node of list)
|
||||
if (
|
||||
['hPop', 'first-run-launcher'].includes(node.id) ||
|
||||
node.querySelector?.('#hPop, #first-run-launcher')
|
||||
)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
export class PanelLayoutController {
|
||||
constructor({
|
||||
readHud,
|
||||
@@ -92,6 +118,9 @@ export class PanelLayoutController {
|
||||
this._rightStackPreferredPanelId = null;
|
||||
this._rightStackReconsiderAutoCollapse = false;
|
||||
this._rightStackResizeObserver = null;
|
||||
this._storiesCardObserver = null;
|
||||
this._storiesCardShownHandler = null;
|
||||
this._storiesHost = null;
|
||||
this._cockpitLayoutFrame = null;
|
||||
this._cockpitLayoutTimer = null;
|
||||
this._leftPanelStack = document.getElementById('left-panel-stack');
|
||||
@@ -223,6 +252,7 @@ export class PanelLayoutController {
|
||||
this._recentImageryPanel,
|
||||
this._streetLevelPanel,
|
||||
globalContextPanel,
|
||||
document.getElementById('space-missions-panel'),
|
||||
document.getElementById('radio-panel'),
|
||||
]) {
|
||||
if (panel) this._rightStackResizeObserver.observe(panel);
|
||||
@@ -246,6 +276,41 @@ export class PanelLayoutController {
|
||||
attributes: true,
|
||||
attributeFilter: ['class', 'hidden', 'data-variant'],
|
||||
});
|
||||
// The Stories card comes and goes inside the Stories view; only its
|
||||
// arrival or departure moves the rail, not the view's other changes.
|
||||
// It fades in from transparent, which the layout skips, so the end of
|
||||
// that fade (also replayed when the card is shown again after being
|
||||
// hidden) lays the rail out once more.
|
||||
const storiesHost = document.getElementById('gev-stories-host');
|
||||
if (storiesHost) {
|
||||
this._storiesHost = storiesHost;
|
||||
this._storiesCardObserver = new MutationObserver((records) => {
|
||||
if (records.some(movesStoriesCard)) this._scheduleRightPanelLayout();
|
||||
});
|
||||
this._storiesCardObserver.observe(storiesHost, {
|
||||
subtree: true,
|
||||
childList: true,
|
||||
});
|
||||
const welcomeHost = document.querySelector('[data-gev-view="welcome"]');
|
||||
if (welcomeHost)
|
||||
this._storiesCardObserver.observe(welcomeHost, {
|
||||
subtree: true,
|
||||
childList: true,
|
||||
});
|
||||
if (document.body)
|
||||
this._storiesCardObserver.observe(document.body, {
|
||||
attributes: true,
|
||||
attributeFilter: ['class'],
|
||||
attributeOldValue: true,
|
||||
});
|
||||
this._storiesCardShownHandler = (event) => {
|
||||
if (event.target?.id === 'hPop') this._scheduleRightPanelLayout();
|
||||
};
|
||||
storiesHost.addEventListener(
|
||||
'animationend',
|
||||
this._storiesCardShownHandler,
|
||||
);
|
||||
}
|
||||
const hud = document.getElementById('intel-hud');
|
||||
if (hud) {
|
||||
this._rightStackMutationObserver.observe(hud, {
|
||||
@@ -464,10 +529,16 @@ export class PanelLayoutController {
|
||||
'_leftStackMutationObserver',
|
||||
'_rightStackResizeObserver',
|
||||
'_rightStackMutationObserver',
|
||||
'_storiesCardObserver',
|
||||
]) {
|
||||
this[field]?.disconnect();
|
||||
this[field] = null;
|
||||
}
|
||||
this._storiesHost?.removeEventListener(
|
||||
'animationend',
|
||||
this._storiesCardShownHandler,
|
||||
);
|
||||
this._storiesHost = this._storiesCardShownHandler = null;
|
||||
for (const field of [
|
||||
'_leftStackHudTransitionHandler',
|
||||
'_rightStackHudTransitionHandler',
|
||||
|
||||
@@ -31,6 +31,10 @@ export const PANEL_RAIL_ITEMS = Object.freeze({
|
||||
},
|
||||
'street-level-panel': { icon: 'streetview', label: msg('STREET LEVEL') },
|
||||
'global-context-panel': { icon: 'radar', label: msg('CONTEXT') },
|
||||
'space-missions-panel': {
|
||||
icon: 'rocket_launch',
|
||||
label: msg('Space Missions'),
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
+84
-22
@@ -1,5 +1,4 @@
|
||||
import { readStylesheet } from '../testSupport/readStylesheet.mjs';
|
||||
import { displayPanelScroller } from './displayPanelScroll.js';
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import {
|
||||
@@ -9,21 +8,9 @@ import {
|
||||
} from './panelRails.js';
|
||||
import { applyPanelState, readPanelState } from './rail/panelState.js';
|
||||
|
||||
test('Display uses an inner scroll body only in Cyber', () => {
|
||||
const body = { scrollTop: 95 };
|
||||
const panel = {
|
||||
ownerDocument: { documentElement: { dataset: { uiTheme: 'cyber' } } },
|
||||
querySelector: () => body,
|
||||
};
|
||||
assert.equal(displayPanelScroller(panel), body);
|
||||
panel.ownerDocument.documentElement.dataset.uiTheme = 'tactical';
|
||||
assert.equal(displayPanelScroller(panel), panel);
|
||||
assert.equal(displayPanelScroller(null), null);
|
||||
});
|
||||
|
||||
for (const side of ['left', 'right']) {
|
||||
test(`${side} desktop rail keeps one expanded owner in every HUD layout`, () => {
|
||||
for (const variant of ['tactical', 'minimal', 'cyber']) {
|
||||
for (const variant of ['tactical', 'minimal']) {
|
||||
const f = fixture(side, { hud: { visible: true, variant } });
|
||||
f.expand(f.first, 250);
|
||||
f.expand(f.second, 250);
|
||||
@@ -232,6 +219,48 @@ test('left corridor respects a lower obstacle but ignores an obstacle hidden by
|
||||
assert.equal(Number(f.stack.dataset.safeBottomPct), 65.47);
|
||||
});
|
||||
|
||||
test('a centered timeline only shortens the corridor when it reaches a laid-out panel', () => {
|
||||
const f = fixture('left');
|
||||
f.stack.rect.width = 360;
|
||||
f.stack.rect.right = f.stack.rect.left + 360;
|
||||
f.expand(f.first, 850);
|
||||
const timeline = element('world-timeline', { top: 650, left: 320 });
|
||||
f.options.obstacles = [timeline];
|
||||
f.run();
|
||||
const clear = Number(f.stack.dataset.safeBottomPct);
|
||||
timeline.rect.left = 280;
|
||||
f.run();
|
||||
assert(clear > 85);
|
||||
assert(Number(f.stack.dataset.safeBottomPct) < 73);
|
||||
// Any other obstacle in the same gutter still bounds the corridor.
|
||||
const blocker = element('blocker', { top: 650, left: 320 });
|
||||
f.options.obstacles = [blocker];
|
||||
f.run();
|
||||
assert(Number(f.stack.dataset.safeBottomPct) < 73);
|
||||
});
|
||||
|
||||
test('Data Layers extends to the HUD even if its list is currently short', () => {
|
||||
const f = fixture('left');
|
||||
f.first.id = 'data-panel';
|
||||
const dock = { id: 'command-dock' };
|
||||
f.options.documentRef.getElementById = (id) =>
|
||||
id === 'gev-omnibar'
|
||||
? {}
|
||||
: id === 'gev-voice-control'
|
||||
? { parentElement: dock }
|
||||
: null;
|
||||
f.expand(f.first, 250);
|
||||
f.options.obstacles = [element('hud', { top: 760, height: 45 })];
|
||||
f.run();
|
||||
assert.equal(f.stack.dataset.layoutMode, 'focus');
|
||||
assert(Number(f.stack.dataset.safeBottomPct) > 80);
|
||||
assert(
|
||||
parseFloat(
|
||||
f.first.style.getPropertyValue('--left-panel-allocated-height'),
|
||||
) > 500,
|
||||
);
|
||||
});
|
||||
|
||||
for (const side of ['left', 'right']) {
|
||||
test(`${side} mobile layout releases desktop height/position styles and labels`, () => {
|
||||
const f = fixture(side, { mobile: true });
|
||||
@@ -376,12 +405,6 @@ test('left rail buttons hold still whether the open panel is short or tall', ()
|
||||
assert.equal(f.stack.dataset.layoutMode, 'focus');
|
||||
assert.notEqual(short.stack.dataset.layoutMode, 'focus');
|
||||
assert.ok(Math.abs(railTop(f.stack) - railTop(short.stack)) < 0.2);
|
||||
|
||||
// A theme that pins the stack's top (Cyber) leaves nothing to offset.
|
||||
f.stack.computed.getPropertyValue = (name) =>
|
||||
name === '--panel-stack-top-pinned' ? ' 1' : '';
|
||||
f.run();
|
||||
assert.equal(f.stack.style.getPropertyValue('--panel-rail-offset'), '0.0px');
|
||||
});
|
||||
|
||||
// The left rail's `top` animates after the right pass runs, and nothing
|
||||
@@ -422,9 +445,9 @@ test('right rail falls back to the committed left target when the transition end
|
||||
});
|
||||
|
||||
test('right rail follows a settled left rail whose CSS overrides the committed target', () => {
|
||||
// Cyber pins the left rail with `top: ... !important`, so the committed
|
||||
// A stylesheet that pins the left rail's `top` means the committed
|
||||
// percentage is not where it renders and no `top` transition runs.
|
||||
const f = fixture('right', { hud: { visible: true, variant: 'cyber' } });
|
||||
const f = fixture('right', { hud: { visible: true, variant: 'minimal' } });
|
||||
f.options.leftStack.rect.top = 220;
|
||||
f.options.leftStack.dataset.safeTopPct = '26.00';
|
||||
f.options.leftStack.getAnimations = () => [];
|
||||
@@ -855,3 +878,42 @@ test('left rail keeps collapsed panels shown beside Cockpit, still one open', ()
|
||||
assert.equal(f.stack.classList.contains('layout-exclusive'), false);
|
||||
assert.equal(f.first.getAttribute('aria-hidden'), undefined);
|
||||
});
|
||||
|
||||
test('the right rail is laid out again when the Stories card can appear or go', async () => {
|
||||
const { movesStoriesCard } = await import('./panelLayoutController.js');
|
||||
const node = (id, inner = null) => ({
|
||||
id,
|
||||
querySelector: (selector) =>
|
||||
inner && selector.split(', ').includes(`#${inner}`) ? {} : null,
|
||||
});
|
||||
const childList = (added = [], removed = []) => ({
|
||||
type: 'childList',
|
||||
addedNodes: added,
|
||||
removedNodes: removed,
|
||||
});
|
||||
const bodyClass = (oldValue, now) => ({
|
||||
type: 'attributes',
|
||||
oldValue,
|
||||
target: { classList: { contains: (name) => now.includes(name) } },
|
||||
});
|
||||
// The card itself, or a wrapper holding it, comes or goes.
|
||||
assert.equal(movesStoriesCard(childList([node('hPop')])), true);
|
||||
assert.equal(movesStoriesCard(childList([], [node('', 'hPop')])), true);
|
||||
// The welcome, which hides the card, is removed.
|
||||
assert.equal(
|
||||
movesStoriesCard(childList([], [node('first-run-launcher')])),
|
||||
true,
|
||||
);
|
||||
// Story playback's own changes do not lay the rail out.
|
||||
assert.equal(movesStoriesCard(childList([node('story-frame')])), false);
|
||||
// Only the welcome's loading class coming or going counts.
|
||||
assert.equal(
|
||||
movesStoriesCard(bodyClass('first-run-opening-stories', ['stories-mode'])),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
movesStoriesCard(bodyClass('', ['first-run-opening-stories'])),
|
||||
true,
|
||||
);
|
||||
assert.equal(movesStoriesCard(bodyClass('a', ['b'])), false);
|
||||
});
|
||||
@@ -329,18 +329,14 @@ test('while the OAuth check runs, the toggle is busy and repeat presses are igno
|
||||
localStorage.removeItem(CLOUD_VOICE_AUTH_STORAGE_KEY);
|
||||
});
|
||||
|
||||
test('Cyber moves the chip into the top toolbar and other themes return it to the corner', async (t) => {
|
||||
test('the chip stays first in the corner row whatever the HUD layout', async (t) => {
|
||||
const { $, toolbar } = await fixture(t);
|
||||
const corner = $('#corner-actions');
|
||||
assert.equal(corner.firstElementChild?.id, 'key-setup-chip');
|
||||
// The removed Cyber skin no longer moves it into the top toolbar.
|
||||
document.documentElement.dataset.uiTheme = 'cyber';
|
||||
await wait();
|
||||
await nextTick();
|
||||
assert.equal(toolbar.lastElementChild?.id, 'key-setup-chip');
|
||||
assert.equal(corner.querySelector('#key-setup-chip') === null, true);
|
||||
document.documentElement.dataset.uiTheme = 'tactical';
|
||||
await wait();
|
||||
await nextTick();
|
||||
assert.equal(corner.firstElementChild?.id, 'key-setup-chip');
|
||||
assert.equal(toolbar.querySelector('#key-setup-chip') === null, true);
|
||||
delete document.documentElement.dataset.uiTheme;
|
||||
|
||||
@@ -91,10 +91,7 @@ export class RadioControls {
|
||||
*/
|
||||
async _revealRadioControlsAfterExplicitEnable(trigger) {
|
||||
const contextPanel = document.getElementById('global-context-panel');
|
||||
const scroller =
|
||||
(document.documentElement?.dataset.uiTheme === 'cyber' &&
|
||||
contextPanel?.querySelector('.cyber-panel-body')) ||
|
||||
contextPanel?.querySelector('.global-context-panel-inner');
|
||||
const scroller = contextPanel?.querySelector('.global-context-panel-inner');
|
||||
const directory = this._radioPanel?.querySelector('.radio-directory-row');
|
||||
const transport = this._radioPanel?.querySelector('.radio-transport');
|
||||
if (
|
||||
|
||||
@@ -140,7 +140,7 @@ test('a collapsed launcher drops its divider so English titles fit whole', () =>
|
||||
);
|
||||
});
|
||||
|
||||
test('the default theme geometry change leaves cyber gutters alone', () => {
|
||||
test('the default theme geometry change leaves the base gutters alone', () => {
|
||||
for (const surface of [
|
||||
'.data-panel-inner',
|
||||
'.utilities-panel-inner',
|
||||
@@ -164,6 +164,17 @@ test('the default theme geometry change leaves cyber gutters alone', () => {
|
||||
assert.match(display?.body || '', /font-size:\s*12px/);
|
||||
});
|
||||
|
||||
test('Data Layers, Context and Space Missions share the 14px side gutters', () => {
|
||||
const gutters = rules.find(
|
||||
({ selector, body }) =>
|
||||
/:is\(\s*\.data-panel-inner,\s*\.global-context-panel-inner,\s*\.space-missions-panel-inner\s*\)$/.test(
|
||||
selector,
|
||||
) && /padding-left:\s*14px/.test(body),
|
||||
);
|
||||
assert.ok(gutters, 'one rule sets the shared gutters');
|
||||
assert.match(gutters.body, /padding-right:\s*14px/);
|
||||
});
|
||||
|
||||
test('rail titles and dock labels share one set of label tokens', () => {
|
||||
// command-dock-trays.css sets the dock's label type; earlier dock rules
|
||||
// for the same selector are overridden by it.
|
||||
@@ -193,39 +204,6 @@ test('rail titles and dock labels share one set of label tokens', () => {
|
||||
);
|
||||
});
|
||||
|
||||
test('default theme overrides never reach the cyber theme', () => {
|
||||
const notCyber = ":root:not([data-ui-theme='cyber'])";
|
||||
const padding = rules.find(
|
||||
({ selector, body }) =>
|
||||
selector.endsWith(
|
||||
':is(.data-panel-inner, .global-context-panel-inner)',
|
||||
) && /padding-left:\s*14px/.test(body),
|
||||
);
|
||||
assert.ok(
|
||||
padding?.selector.startsWith(notCyber),
|
||||
'the 14px gutters must skip cyber',
|
||||
);
|
||||
const display = rules.find(
|
||||
({ selector, body }) =>
|
||||
selector.endsWith('#pp-toggles > .pp-header-row .pp-collapse-btn') &&
|
||||
/font-size:\s*13px/.test(body),
|
||||
);
|
||||
assert.ok(
|
||||
display?.selector.startsWith(notCyber),
|
||||
"Display's 22px toggle must skip cyber",
|
||||
);
|
||||
// Cyber draws its title marker at left: -8px; a clip on the title would cut it.
|
||||
for (const { selector, body } of rules) {
|
||||
if (!/\.panel-title/.test(selector) || !/overflow:\s*hidden/.test(body))
|
||||
continue;
|
||||
if (!/#left-panel-stack|#right-context-rail/.test(selector)) continue;
|
||||
assert.ok(
|
||||
selector.startsWith(notCyber),
|
||||
`${selector} clips the cyber title marker`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('launcher compaction and header colour stay on the rail panels themselves', () => {
|
||||
// The divider, gap and toggle rules; the translated type rule is checked
|
||||
// above.
|
||||
|
||||
@@ -4,7 +4,6 @@ import {
|
||||
} from '../panelStackLayout.js';
|
||||
import { resolveHudRailLayout } from './panelRailGeometry.js';
|
||||
|
||||
import { displayPanelScroller } from './displayPanelScroll.js';
|
||||
import { settleSideAccordion } from './panelAccordion.js';
|
||||
|
||||
const pendingCollapseRetries = new WeakSet();
|
||||
@@ -356,7 +355,7 @@ export function layoutRightPanelRail({
|
||||
stack.dataset.expandedCount = String(expandedPanels.length);
|
||||
|
||||
if (displayPanel && expandedPanels.includes(displayPanel)) {
|
||||
const scroller = displayPanelScroller(displayPanel);
|
||||
const scroller = displayPanel;
|
||||
const maxScrollTop = Math.max(
|
||||
0,
|
||||
scroller.scrollHeight - scroller.clientHeight,
|
||||
|
||||
@@ -52,18 +52,6 @@ test('the dock trays open from their own wing in right-to-left', () => {
|
||||
);
|
||||
});
|
||||
|
||||
test('the Cyber cockpit keeps Data Layers on the left edge in every language', () => {
|
||||
const body = ruleBody(
|
||||
sheet('cyber.css'),
|
||||
":root[data-ui-theme='cyber'] body.cockpit-mode #left-panel-stack",
|
||||
);
|
||||
// inset-inline-start would become right: 30px in Arabic and beat
|
||||
// rtl.css's reset, landing the stack on the utility controls.
|
||||
assert.doesNotMatch(body, /inset-inline-start/);
|
||||
assert.match(body, /left: 30px;/);
|
||||
assert.match(body, /right: auto;/);
|
||||
});
|
||||
|
||||
test('the panel rails stay on the outer side of their stacks in right-to-left', () => {
|
||||
const layers = sheet('layers.css');
|
||||
// Each rail is placed by its screen-side edge; a physical side would put
|
||||
@@ -90,11 +78,6 @@ test('the panel rails stay on the outer side of their stacks in right-to-left',
|
||||
ruleBody(kit, '.ui-tooltip__tip--left'),
|
||||
/inset-inline-end: calc\(100% \+ 10px\);/,
|
||||
);
|
||||
// Cyber's right stack keeps its rail clearance on the left edge.
|
||||
assert.match(
|
||||
sheet('rtl.css'),
|
||||
/html\[dir='rtl'\]\[data-ui-theme='cyber'\] #right-context-rail \{\s*right: auto;\s*left: calc\(51px \+ var\(--panel-rail-clearance\)\);/,
|
||||
);
|
||||
});
|
||||
|
||||
test('phone top-bar actions mirror with the logo', () => {
|
||||
|
||||
@@ -48,6 +48,8 @@ export class SceneControls {
|
||||
this.run('renameShot', sceneId, shotId, title),
|
||||
load: (sceneId, shotId) => this.run('load', sceneId, shotId),
|
||||
remove: (sceneId, shotId) => this.deleteShot(sceneId, shotId),
|
||||
move: (sceneId, shotId, index) =>
|
||||
this.run('moveShot', sceneId, shotId, index),
|
||||
create: () => this.createScene(),
|
||||
deleteScene: () => this.deleteSelectedScene(),
|
||||
stories: () => this.run('stories'),
|
||||
@@ -110,6 +112,7 @@ export class SceneControls {
|
||||
'shot-captured',
|
||||
'shot-updated',
|
||||
'shot-renamed',
|
||||
'shot-moved',
|
||||
'shot-deleted',
|
||||
'project-imported',
|
||||
].includes(type)
|
||||
|
||||
@@ -98,6 +98,7 @@ function fixture() {
|
||||
'download',
|
||||
'load',
|
||||
'deleteShot',
|
||||
'moveShot',
|
||||
].map((name) => [
|
||||
name,
|
||||
(...args) => {
|
||||
@@ -219,22 +220,30 @@ test('Scene controls dispatch panel and shot-row actions, and rows outlive repub
|
||||
await nextTick();
|
||||
const row = f.elements.shots.children[0];
|
||||
const label = f.label();
|
||||
const load = row.children[0].children[1].children[0];
|
||||
const [up, down, del] = row.children[0].children[1].children;
|
||||
f.elements.capture.click();
|
||||
f.elements.start.click();
|
||||
// A click on the row goes to the shot: selected and loaded.
|
||||
label.click();
|
||||
label.dispatchEvent(new Event('dblclick'));
|
||||
await nextTick();
|
||||
label.children[0].value = 'Renamed';
|
||||
// A click in the name being typed goes nowhere.
|
||||
label.children[0].click();
|
||||
label.children[0].dispatchEvent(new Event('blur'));
|
||||
load.click();
|
||||
assert.deepEqual(f.calls, [
|
||||
['capture'],
|
||||
['start', 'scene-a'],
|
||||
['selectShot', 'shot-a'],
|
||||
['renameShot', 'scene-a', 'shot-a', 'Renamed'],
|
||||
['load', 'scene-a', 'shot-a'],
|
||||
['renameShot', 'scene-a', 'shot-a', 'Renamed'],
|
||||
]);
|
||||
// A lone shot has nowhere to move; the buttons never load it.
|
||||
assert.equal(up.disabled, true);
|
||||
assert.equal(down.disabled, true);
|
||||
window.confirm = () => false;
|
||||
del.click();
|
||||
assert.equal(f.calls.length, 5);
|
||||
f.owner.renderShotList();
|
||||
await nextTick();
|
||||
assertSameNode(f.elements.shots.children[0], row);
|
||||
@@ -246,7 +255,10 @@ test('Scene controls dispatch panel and shot-row actions, and rows outlive repub
|
||||
f.owner.destroy();
|
||||
await nextTick();
|
||||
f.label().click();
|
||||
assert.deepEqual(f.calls.at(-1), ['selectShot', 'shot-a']);
|
||||
assert.deepEqual(f.calls.slice(-2), [
|
||||
['selectShot', 'shot-a'],
|
||||
['load', 'scene-a', 'shot-a'],
|
||||
]);
|
||||
newer.destroy();
|
||||
await nextTick();
|
||||
assert.equal(f.elements.shots.children.length, 0);
|
||||
@@ -255,6 +267,68 @@ test('Scene controls dispatch panel and shot-row actions, and rows outlive repub
|
||||
}
|
||||
});
|
||||
|
||||
test('a shot row goes to its shot from the keyboard, and its up and down buttons swap it with a neighbour', async () => {
|
||||
const f = fixture();
|
||||
try {
|
||||
f.state.scenes[0].shots.push(
|
||||
{ id: 'shot-b', title: 'Shot B', durationSec: 4, holdSec: 0 },
|
||||
{ id: 'shot-c', title: 'Shot C', durationSec: 4, holdSec: 0 },
|
||||
);
|
||||
f.owner.renderShotList();
|
||||
await nextTick();
|
||||
const rows = () => [...f.elements.shots.children];
|
||||
const buttons = (index) => rows()[index].querySelectorAll('button');
|
||||
const label = (index) => rows()[index].querySelector('.scene-shot-label');
|
||||
|
||||
// The title is the row's keyboard control, described by its summary.
|
||||
const second = label(1);
|
||||
assert.equal(second.getAttribute('role'), 'button');
|
||||
assert.equal(second.getAttribute('tabindex'), '0');
|
||||
const meta = document.getElementById(
|
||||
second.getAttribute('aria-describedby'),
|
||||
);
|
||||
assert.ok(meta.classList.contains('scene-shot-meta'));
|
||||
for (const key of ['Enter', ' '])
|
||||
second.dispatchEvent(
|
||||
Object.assign(new Event('keydown', { bubbles: true }), { key }),
|
||||
);
|
||||
second.dispatchEvent(
|
||||
Object.assign(new Event('keydown', { bubbles: true }), { key: 'a' }),
|
||||
);
|
||||
assert.deepEqual(f.calls, [
|
||||
['selectShot', 'shot-b'],
|
||||
['load', 'scene-a', 'shot-b'],
|
||||
['selectShot', 'shot-b'],
|
||||
['load', 'scene-a', 'shot-b'],
|
||||
]);
|
||||
|
||||
// Up and down, labelled, disabled at the ends; neither loads the shot.
|
||||
f.calls.length = 0;
|
||||
const [firstUp, firstDown] = buttons(0);
|
||||
assert.equal(firstUp.getAttribute('aria-label'), 'Move up');
|
||||
assert.equal(firstDown.getAttribute('aria-label'), 'Move down');
|
||||
assert.equal(firstUp.disabled, true);
|
||||
assert.equal(firstDown.disabled, false);
|
||||
assert.equal(buttons(2)[1].disabled, true);
|
||||
assert.equal(buttons(2)[0].disabled, false);
|
||||
buttons(1)[0].click();
|
||||
buttons(1)[1].click();
|
||||
assert.deepEqual(f.calls, [
|
||||
['moveShot', 'scene-a', 'shot-b', 0],
|
||||
['moveShot', 'scene-a', 'shot-b', 2],
|
||||
]);
|
||||
|
||||
// Not while the scene plays.
|
||||
f.state.running = true;
|
||||
f.owner.setButtons(true);
|
||||
await nextTick();
|
||||
assert.ok(rows().every((_, index) => buttons(index)[0].disabled));
|
||||
assert.ok(rows().every((_, index) => buttons(index)[1].disabled));
|
||||
} finally {
|
||||
f.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test('Scene Escape and recording presentation follow playback and release on destruction', async () => {
|
||||
const f = fixture();
|
||||
const escape = () =>
|
||||
|
||||
@@ -35,9 +35,6 @@ export function readShellElements(document = globalThis.document) {
|
||||
_globalContextFlightsBtn: document.getElementById(
|
||||
'global-context-flights-btn',
|
||||
),
|
||||
_globalContextMissionsBtn: document.getElementById(
|
||||
'global-context-missions-btn',
|
||||
),
|
||||
_installationsSearchBtn: document.getElementById(
|
||||
'installations-search-btn',
|
||||
),
|
||||
|
||||
+10
-4
@@ -1038,15 +1038,16 @@ export class ShellFacade {
|
||||
|
||||
/**
|
||||
* Reads global context mode state for voice/state-sync consumers.
|
||||
* @returns {{mode: 'flights'|'space-missions'|null, active: boolean, changing: boolean, entering: 'flights'|'space-missions'|null, snapshotCaptured: boolean}}
|
||||
* @returns {{mode: 'flights'|null, active: boolean, changing: boolean, entering: 'flights'|null, snapshotCaptured: boolean}}
|
||||
*/
|
||||
getContextModeState(...args) {
|
||||
return this._contextControls?.getContextModeState(...args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets global context mode (Contacts / Space Missions / off) for voice.
|
||||
* @param {'contacts'|'space-missions'|'off'|null} mode - Requested context target.
|
||||
* Sets global context mode (Contacts / off) for voice. Space Missions is
|
||||
* an ordinary layer, not a Context mode.
|
||||
* @param {'contacts'|'off'|null} mode - Requested context target.
|
||||
* @param {object} [options]
|
||||
* @param {string|Symbol|null} [options.notificationToken]
|
||||
* @param {AbortSignal|null} [options.signal]
|
||||
@@ -1056,7 +1057,7 @@ export class ShellFacade {
|
||||
* lane. Cockpit choreography calls this facade INTERNALLY for its own
|
||||
* enter/rollback steps; those transitions are not a Context request by the
|
||||
* operator and must stay inert, so they pass `false`.
|
||||
* @returns {Promise<{ok:boolean, mode:'flights'|'space-missions'|null, active:boolean, action:string, error?:string}>}
|
||||
* @returns {Promise<{ok:boolean, mode:'flights'|null, active:boolean, action:string, error?:string}>}
|
||||
*/
|
||||
setContextMode(...args) {
|
||||
return this._contextControls?.setContextMode(...args);
|
||||
@@ -1294,6 +1295,11 @@ export class ShellFacade {
|
||||
return this._locationNavigation.resetToGlobeView(...args);
|
||||
}
|
||||
|
||||
/** Back to live, at the view the app started from (the title's logo). */
|
||||
returnToStart() {
|
||||
return this._locationNavigation.returnToStart();
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a temporary toast notification for 2 seconds.
|
||||
* @param {string} message - Text to show in the toast.
|
||||
|
||||
@@ -3,6 +3,7 @@ import test from 'node:test';
|
||||
import { LocationNavigation } from './locationNavigation.js';
|
||||
import { LayerBindings } from './layerBindings.js';
|
||||
import { bindRenderer } from '../render/rendererOf.js';
|
||||
import { worldClock } from '../time/worldClock.js';
|
||||
|
||||
function replaceWindow(t, value) {
|
||||
const previous = Object.getOwnPropertyDescriptor(globalThis, 'window');
|
||||
@@ -13,12 +14,13 @@ function replaceWindow(t, value) {
|
||||
});
|
||||
}
|
||||
|
||||
function location(t) {
|
||||
function location(t, { homeView = null } = {}) {
|
||||
t.mock.timers.enable({ apis: ['setTimeout'] });
|
||||
replaceWindow(t, { setTimeout });
|
||||
const calls = [];
|
||||
let hooks;
|
||||
const owner = new LocationNavigation({
|
||||
homeView,
|
||||
viewer: { camera: {
|
||||
cancelFlight() {}, lookAtTransform() {},
|
||||
positionCartographic: { latitude: 0, longitude: 0, height: 20000000 },
|
||||
@@ -26,7 +28,11 @@ function location(t) {
|
||||
services: {
|
||||
OrbitController: class { stop() { calls.push('orbit-stop'); } },
|
||||
GLOBE_VIEW: { heightM: 20000000 },
|
||||
flyToGlobeView(_viewer, callbacks) { hooks = callbacks; return {}; },
|
||||
flyToGlobeView(_viewer, callbacks) {
|
||||
hooks = callbacks;
|
||||
calls.push(callbacks.view ? `fly ${callbacks.view.lat},${callbacks.view.lon}` : 'fly here');
|
||||
return {};
|
||||
},
|
||||
interruptCameraMotion() {},
|
||||
militaryAwarenessLayer: {}, satellitesLayer: {}, rocketLaunchesLayer: {},
|
||||
trafficLayer: {
|
||||
@@ -60,6 +66,24 @@ test('shell disposal settles a pending globe reset once and revokes its timeout'
|
||||
assert.equal((await owner.resetToGlobeView()).cancelled, true);
|
||||
});
|
||||
|
||||
test('the logo goes live and flies to the home view, replacing a globe reset under way', async (t) => {
|
||||
const { owner, calls, readHooks } = location(t, {
|
||||
homeView: { lon: -82.5, lat: 35, height: 23000000 },
|
||||
});
|
||||
worldClock.seek(Date.now() - 3 * 3600 * 1000);
|
||||
assert.equal(worldClock.isLive(), false);
|
||||
const reset = owner.resetToGlobeView();
|
||||
const home = owner.returnToStart();
|
||||
assert.notEqual(home, reset);
|
||||
assert.equal((await reset).cancelled, true);
|
||||
assert.equal(worldClock.isLive(), true);
|
||||
assert.deepEqual(calls.filter((c) => c.startsWith('fly')), ['fly here', 'fly 35,-82.5']);
|
||||
readHooks().onComplete();
|
||||
assert.equal((await home).cancelled, false);
|
||||
assert.equal((await home).heightKm, 23000);
|
||||
owner.destroy();
|
||||
});
|
||||
|
||||
test('world jump completion cannot revive navigation after shell disposal', (t) => {
|
||||
const { owner, calls } = location(t);
|
||||
let complete;
|
||||
|
||||
@@ -4,7 +4,7 @@ import { PanelChrome } from './panelChrome.js';
|
||||
import { presentPanelLocally } from '../testSupport/panelState.mjs';
|
||||
import { readPanelState } from './rail/panelState.js';
|
||||
|
||||
function fixture(theme = 'cyber') {
|
||||
function fixture(theme = 'tactical') {
|
||||
const nodes = new Map();
|
||||
const node = (id, collapsed = true) => {
|
||||
const classes = new Set(collapsed ? ['collapsed'] : []);
|
||||
@@ -27,7 +27,8 @@ function fixture(theme = 'cyber') {
|
||||
for (const panel of left.children) panel.parentElement = left;
|
||||
const rail = node('rail');
|
||||
const display = node('pp-toggles'), context = node('global-context-panel'), cctv = node('cctv-panel'), radio = node('radio-panel');
|
||||
rail.children = [display, context, cctv];
|
||||
const missions = node('space-missions-panel');
|
||||
rail.children = [display, context, missions, cctv];
|
||||
for (const panel of rail.children) panel.parentElement = rail;
|
||||
context.children = [radio];
|
||||
radio.parentElement = context;
|
||||
@@ -43,13 +44,13 @@ function fixture(theme = 'cyber') {
|
||||
shareLinkManager: { claimRestoreLane: (...args) => claimed.push(args), onPanelStateChange() {} },
|
||||
};
|
||||
owner.setPanelCollapsed = PanelChrome.prototype.setPanelCollapsed.bind(owner);
|
||||
return { layers, scenes, display, context, cctv, radio, owner, saved, claimed,
|
||||
return { layers, scenes, display, context, missions, cctv, radio, owner, saved, claimed,
|
||||
doc: { documentElement: { dataset: { uiTheme: theme } }, getElementById: (id) => nodes.get(id) },
|
||||
};
|
||||
}
|
||||
|
||||
test('explicit opening collapses side peers and claims their restoration lanes in every theme', () => {
|
||||
for (const theme of ['tactical', 'minimal', 'cyber']) {
|
||||
for (const theme of ['tactical', 'minimal']) {
|
||||
const f = fixture(theme), prior = globalThis.document;
|
||||
globalThis.document = f.doc;
|
||||
try {
|
||||
@@ -71,6 +72,25 @@ test('explicit opening collapses side peers and claims their restoration lanes i
|
||||
}
|
||||
});
|
||||
|
||||
test('the Context and Space Missions panels close each other on desktop', () => {
|
||||
const f = fixture('tactical'), prior = globalThis.document;
|
||||
globalThis.document = f.doc;
|
||||
try {
|
||||
f.owner.setPanelCollapsed('global-context-panel', false, { explicit: true });
|
||||
f.owner.setPanelCollapsed('space-missions-panel', false, { explicit: true });
|
||||
assert.equal(f.missions.classList.contains('collapsed'), false);
|
||||
assert.equal(f.context.classList.contains('collapsed'), true, 'opening Space Missions closes Context');
|
||||
f.owner.setPanelCollapsed('global-context-panel', false, { explicit: true });
|
||||
assert.equal(f.context.classList.contains('collapsed'), false);
|
||||
assert.equal(f.missions.classList.contains('collapsed'), true, 'opening Context closes Space Missions');
|
||||
// Radio lives inside Context, so opening it closes Space Missions too.
|
||||
f.owner.setPanelCollapsed('space-missions-panel', false, { explicit: true });
|
||||
f.owner.setPanelCollapsed('radio-panel', false, { explicit: true });
|
||||
assert.equal(f.context.classList.contains('collapsed'), false);
|
||||
assert.equal(f.missions.classList.contains('collapsed'), true);
|
||||
} finally { globalThis.document = prior; }
|
||||
});
|
||||
|
||||
test('opening already-expanded Radio reveals Context and closes Display', () => {
|
||||
const f = fixture('tactical'), prior = globalThis.document;
|
||||
globalThis.document = f.doc;
|
||||
@@ -86,7 +106,7 @@ test('opening already-expanded Radio reveals Context and closes Display', () =>
|
||||
});
|
||||
|
||||
test('restored preferences keep every saved panel open for the layout to normalize', () => {
|
||||
for (const theme of ['tactical', 'minimal', 'cyber']) {
|
||||
for (const theme of ['tactical', 'minimal']) {
|
||||
const f = fixture(theme), prior = globalThis.document;
|
||||
globalThis.document = f.doc;
|
||||
try {
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
const LAYER_ID = 'rocket-launches';
|
||||
const PANEL_ID = 'space-missions-panel';
|
||||
|
||||
/**
|
||||
* The Space Missions panel's wiring. Space Missions is an ordinary layer: the
|
||||
* layer owns its data and Satellites dependency, and this connects it to its
|
||||
* panel. The panel shows while the layer is on, and opens when the person
|
||||
* turns the layer on (by hand or by voice) or picks a mission on the globe. Opening it closes the
|
||||
* other right-side panels, Context among them (see setPanelCollapsed).
|
||||
*/
|
||||
export class SpaceMissionsControls {
|
||||
/**
|
||||
* @param {object} options
|
||||
* @param {?object} options.layer The Space Missions layer.
|
||||
* @param {object} options.store The Space Missions store.
|
||||
* @param {object} options.actions
|
||||
* @param {(panelId: string, collapsed: boolean, options?: object) => void} options.actions.setPanelCollapsed
|
||||
* @param {() => boolean} options.actions.isCockpitActive
|
||||
* @param {() => void} [options.actions.revealPanel] Opens the phone sheet that
|
||||
* holds the panel; does nothing on desktop.
|
||||
*/
|
||||
constructor({ layer, store, actions }) {
|
||||
this._layer = layer || null;
|
||||
this._store = store;
|
||||
this._actions = actions;
|
||||
this._manager = null;
|
||||
this._unsubscribeManager = null;
|
||||
this.destroyed = false;
|
||||
store.connect(this._layer);
|
||||
store.publish(null);
|
||||
store.setEnabled(false);
|
||||
this._unsubscribePanel =
|
||||
this._layer?.subscribePanel?.((view) => store.publish(view)) ?? null;
|
||||
this._unsubscribeGlobePick =
|
||||
this._layer?.subscribeGlobePick?.(() => this._reveal()) ?? null;
|
||||
}
|
||||
|
||||
/** Follow a data manager's Space Missions visibility; null disconnects. */
|
||||
connect(manager) {
|
||||
this._unsubscribeManager?.();
|
||||
this._unsubscribeManager = null;
|
||||
this._manager = manager || null;
|
||||
if (this.destroyed) return;
|
||||
this._syncEnabled();
|
||||
this._unsubscribeManager =
|
||||
this._manager?.subscribe?.((change) => this._handleChange(change)) ??
|
||||
null;
|
||||
}
|
||||
|
||||
_syncEnabled() {
|
||||
this._store.setEnabled(Boolean(this._manager?.isEnabled?.(LAYER_ID)));
|
||||
}
|
||||
|
||||
_handleChange(change) {
|
||||
if (this.destroyed || change?.layerId !== LAYER_ID) return;
|
||||
if (!String(change.type || '').startsWith('visibility')) return;
|
||||
this._syncEnabled();
|
||||
if (
|
||||
change.type === 'visibility' &&
|
||||
change.enabled &&
|
||||
(change.origin === 'user' || change.origin === 'voice')
|
||||
)
|
||||
this._reveal();
|
||||
}
|
||||
|
||||
/** Open the panel, unless the Cockpit owns the screen. */
|
||||
_reveal() {
|
||||
if (this.destroyed || this._actions.isCockpitActive?.()) return;
|
||||
this._actions.setPanelCollapsed(PANEL_ID, false, { explicit: true });
|
||||
// A phone shows the rail only as tab sheets: open the Missions sheet too.
|
||||
this._actions.revealPanel?.();
|
||||
}
|
||||
|
||||
destroy() {
|
||||
if (this.destroyed) return;
|
||||
this.destroyed = true;
|
||||
this._unsubscribeManager?.();
|
||||
this._unsubscribeManager = null;
|
||||
this._unsubscribePanel?.();
|
||||
this._unsubscribePanel = null;
|
||||
this._unsubscribeGlobePick?.();
|
||||
this._unsubscribeGlobePick = null;
|
||||
this._store.connect(null);
|
||||
this._store.publish(null);
|
||||
this._store.setEnabled(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
// The Space Missions panel's wiring, apart from Context.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createPinia, setActivePinia } from 'pinia';
|
||||
import { useSpaceMissionsStore } from './stores/spaceMissions.js';
|
||||
import { SpaceMissionsControls } from './spaceMissionsControls.js';
|
||||
|
||||
function layerDouble() {
|
||||
const panelListeners = new Set();
|
||||
const pickListeners = new Set();
|
||||
return {
|
||||
panelListeners,
|
||||
pickListeners,
|
||||
subscribePanel(listener) {
|
||||
panelListeners.add(listener);
|
||||
return () => panelListeners.delete(listener);
|
||||
},
|
||||
subscribeGlobePick(listener) {
|
||||
pickListeners.add(listener);
|
||||
return () => pickListeners.delete(listener);
|
||||
},
|
||||
publish(view) {
|
||||
for (const listener of panelListeners) listener(view);
|
||||
},
|
||||
pick(id) {
|
||||
for (const listener of pickListeners) listener(id);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function managerDouble() {
|
||||
const listeners = new Set();
|
||||
const enabled = new Set();
|
||||
return {
|
||||
listeners,
|
||||
enabled,
|
||||
isEnabled: (id) => enabled.has(id),
|
||||
subscribe(listener) {
|
||||
listeners.add(listener);
|
||||
return () => listeners.delete(listener);
|
||||
},
|
||||
emit(change) {
|
||||
if (change.type === 'visibility') {
|
||||
if (change.enabled) enabled.add(change.layerId);
|
||||
else enabled.delete(change.layerId);
|
||||
}
|
||||
for (const listener of listeners) listener(change);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function rig({ cockpit = false } = {}) {
|
||||
setActivePinia(createPinia());
|
||||
const store = useSpaceMissionsStore();
|
||||
const layer = layerDouble();
|
||||
const manager = managerDouble();
|
||||
const reveals = [];
|
||||
const sheets = [];
|
||||
const state = { cockpit };
|
||||
const controls = new SpaceMissionsControls({
|
||||
layer,
|
||||
store,
|
||||
actions: {
|
||||
setPanelCollapsed: (...args) => reveals.push(args),
|
||||
isCockpitActive: () => state.cockpit,
|
||||
revealPanel: () => sheets.push('space-missions-panel'),
|
||||
},
|
||||
});
|
||||
controls.connect(manager);
|
||||
return { controls, store, layer, manager, reveals, sheets, state };
|
||||
}
|
||||
|
||||
const userOn = {
|
||||
type: 'visibility',
|
||||
layerId: 'rocket-launches',
|
||||
enabled: true,
|
||||
origin: 'user',
|
||||
};
|
||||
|
||||
test('the layer publishes its roster and mission to its own store', () => {
|
||||
const r = rig();
|
||||
assert.equal(r.store.layer, r.layer);
|
||||
assert.equal(r.store.roster, null);
|
||||
const view = { roster: { entries: [] }, mission: { id: 'L1' } };
|
||||
r.layer.publish(view);
|
||||
assert.equal(r.store.roster, view.roster);
|
||||
assert.equal(r.store.mission, view.mission);
|
||||
});
|
||||
|
||||
test('the panel shows while the layer is on', () => {
|
||||
const r = rig();
|
||||
assert.equal(r.store.enabled, false);
|
||||
r.manager.emit({ ...userOn, origin: 'programmatic' });
|
||||
assert.equal(r.store.enabled, true);
|
||||
r.manager.emit({ ...userOn, enabled: false });
|
||||
assert.equal(r.store.enabled, false);
|
||||
// Another layer's change says nothing about Space Missions.
|
||||
r.manager.enabled.add('rocket-launches');
|
||||
r.manager.emit({ ...userOn, layerId: 'satellites' });
|
||||
assert.equal(r.store.enabled, false);
|
||||
});
|
||||
|
||||
test('a person switching the layer on opens its panel; a restore does not', () => {
|
||||
const r = rig();
|
||||
r.manager.emit({ ...userOn, origin: 'share-restore' });
|
||||
r.manager.emit({ ...userOn, type: 'visibility-requested' });
|
||||
assert.deepEqual(r.reveals, []);
|
||||
r.manager.emit(userOn);
|
||||
assert.deepEqual(r.reveals, [
|
||||
['space-missions-panel', false, { explicit: true }],
|
||||
]);
|
||||
// On a phone the rail shows only as tab sheets: the Missions sheet opens too.
|
||||
assert.deepEqual(r.sheets, ['space-missions-panel']);
|
||||
});
|
||||
|
||||
test('a mission picked on the globe opens the panel', () => {
|
||||
const r = rig();
|
||||
r.layer.pick('L1');
|
||||
assert.deepEqual(r.reveals, [
|
||||
['space-missions-panel', false, { explicit: true }],
|
||||
]);
|
||||
assert.deepEqual(r.sheets, ['space-missions-panel']);
|
||||
});
|
||||
|
||||
test('the Cockpit keeps the screen: no reveal while it is on', () => {
|
||||
const r = rig({ cockpit: true });
|
||||
r.layer.pick('L1');
|
||||
r.manager.emit(userOn);
|
||||
r.manager.emit({ ...userOn, origin: 'voice' });
|
||||
assert.deepEqual(r.reveals, []);
|
||||
assert.deepEqual(r.sheets, [], 'no phone sheet over the Cockpit either');
|
||||
r.state.cockpit = false;
|
||||
r.layer.pick('L1');
|
||||
assert.equal(r.reveals.length, 1);
|
||||
});
|
||||
|
||||
test('reconnecting and destroy release every subscription and clear the store', () => {
|
||||
const r = rig();
|
||||
r.controls.connect(r.manager);
|
||||
assert.equal(r.manager.listeners.size, 1, 'no duplicate subscription');
|
||||
r.layer.publish({ roster: { entries: [] }, mission: null });
|
||||
r.manager.emit(userOn);
|
||||
r.controls.destroy();
|
||||
assert.equal(r.manager.listeners.size, 0);
|
||||
assert.equal(r.layer.panelListeners.size, 0);
|
||||
assert.equal(r.layer.pickListeners.size, 0);
|
||||
assert.equal(r.store.layer, null);
|
||||
assert.equal(r.store.roster, null);
|
||||
assert.equal(r.store.enabled, false);
|
||||
r.layer.pick('L1');
|
||||
assert.equal(r.reveals.length, 1, 'a destroyed control reveals nothing');
|
||||
});
|
||||
+49
-1
@@ -242,9 +242,57 @@ const STATUS_PIECE_PATTERNS = [
|
||||
],
|
||||
];
|
||||
|
||||
// Shapes of installationFeedback() (data/installationFeedback.js), which stays
|
||||
// English for the analyst. Keep them in step with its wording.
|
||||
const MAPPED_SITE_PATTERNS = [
|
||||
[
|
||||
/^(.+) — retrying in (\d+)s$/,
|
||||
([, reason, seconds]) =>
|
||||
t('{reason} — retrying in {seconds}s', {
|
||||
reason: translateKnown(reason),
|
||||
seconds,
|
||||
}),
|
||||
],
|
||||
[
|
||||
/^(.+) — retry pending$/,
|
||||
([, reason]) =>
|
||||
t('{reason} — retry pending', { reason: translateKnown(reason) }),
|
||||
],
|
||||
[/^No mapped sites in view$/, () => t('No mapped sites in view')],
|
||||
[
|
||||
/^(\d+) mapped sites? in view$/,
|
||||
([, count]) =>
|
||||
tn(
|
||||
Number(count),
|
||||
'{count} mapped site in view',
|
||||
'{count} mapped sites in view',
|
||||
),
|
||||
],
|
||||
[
|
||||
/^No mapped sites within (\d+) km of the contact$/,
|
||||
([, km]) =>
|
||||
t('No mapped sites within {km} km of the contact', {
|
||||
km: formatNumber(Number(km)),
|
||||
}),
|
||||
],
|
||||
[
|
||||
/^(\d+) mapped sites? within (\d+) km of the contact$/,
|
||||
([, count, km]) =>
|
||||
tn(
|
||||
Number(count),
|
||||
'{count} mapped site within {km} km of the contact',
|
||||
'{count} mapped sites within {km} km of the contact',
|
||||
{ km: formatNumber(Number(km)) },
|
||||
),
|
||||
],
|
||||
];
|
||||
|
||||
// First match wins.
|
||||
const STATUS_SHAPES = [...STATUS_PIECE_PATTERNS, ...MAPPED_SITE_PATTERNS];
|
||||
|
||||
/** A status piece by its shape in the UI language, or null. */
|
||||
function statusPatternText(piece) {
|
||||
for (const [pattern, format] of STATUS_PIECE_PATTERNS) {
|
||||
for (const [pattern, format] of STATUS_SHAPES) {
|
||||
const match = pattern.exec(piece);
|
||||
if (match) return format(match);
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ import { markRaw, shallowRef } from 'vue';
|
||||
* The Context panel's mode switch as its view renders it. ContextControls
|
||||
* presents the selected mode, the transition busy state and the nearby
|
||||
* sites search (`_presentContext()`) and publishes them here; it
|
||||
* keeps its listeners and transactions. The Contacts and Space Missions
|
||||
* layers publish their panels beside it, and the app connects each layer's
|
||||
* commands.
|
||||
* keeps its listeners and transactions. The Contacts layer publishes its
|
||||
* panel beside it, and the app connects the layer's commands. Space Missions
|
||||
* has its own store (stores/spaceMissions.js).
|
||||
*/
|
||||
export const useContextStore = defineStore('gev-context', () => {
|
||||
/** The presented mode switch; null until the controls first render. */
|
||||
@@ -37,29 +37,6 @@ export const useContextStore = defineStore('gev-context', () => {
|
||||
awarenessLayer.value = layer && markRaw(layer);
|
||||
}
|
||||
|
||||
/** The Space Missions roster; null until the layer first presents it. */
|
||||
const missionRoster = shallowRef(null);
|
||||
|
||||
/** The selected space mission; null while none is selected. */
|
||||
const mission = shallowRef(null);
|
||||
|
||||
/**
|
||||
* @param {?{roster: ?object, mission: ?object}} next The layer's view. The
|
||||
* layer keeps an unchanged roster's object, which re-renders nothing.
|
||||
*/
|
||||
function publishMissions(next) {
|
||||
missionRoster.value = next?.roster ? markRaw(next.roster) : null;
|
||||
mission.value = next?.mission ? markRaw(next.mission) : null;
|
||||
}
|
||||
|
||||
/** The Space Missions layer whose panel commands the components call. */
|
||||
const missionsLayer = shallowRef(null);
|
||||
|
||||
/** @param {?object} layer The Space Missions layer, or null to disconnect. */
|
||||
function connectMissions(layer) {
|
||||
missionsLayer.value = layer && markRaw(layer);
|
||||
}
|
||||
|
||||
return {
|
||||
view,
|
||||
publish,
|
||||
@@ -67,10 +44,5 @@ export const useContextStore = defineStore('gev-context', () => {
|
||||
publishAwareness,
|
||||
awarenessLayer,
|
||||
connectAwareness,
|
||||
missionRoster,
|
||||
mission,
|
||||
publishMissions,
|
||||
missionsLayer,
|
||||
connectMissions,
|
||||
};
|
||||
});
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
describeEntity,
|
||||
layerBreakdown,
|
||||
nearbyByKind,
|
||||
nearbyEntities,
|
||||
layerMatches,
|
||||
searchEntities,
|
||||
viewSummary,
|
||||
@@ -204,6 +205,10 @@ export const useEntityCardStore = defineStore('gev-entity-card', () => {
|
||||
return nearbyByKind(shell.value?.dataManager?.(), { lat, lon }, options);
|
||||
}
|
||||
|
||||
function nearbySelected() {
|
||||
return nearbyEntities(dataManager(), card.value);
|
||||
}
|
||||
|
||||
/** Whether a card's layer is known to the layer manager and switched off. */
|
||||
function layerOff(layerId) {
|
||||
const dm = dataManager();
|
||||
@@ -333,6 +338,7 @@ export const useEntityCardStore = defineStore('gev-entity-card', () => {
|
||||
following,
|
||||
search,
|
||||
nearbyGroups,
|
||||
nearbySelected,
|
||||
alertsAt,
|
||||
liveLayers,
|
||||
breakdown,
|
||||
|
||||
@@ -8,7 +8,7 @@ import { markRaw, shallowRef } from 'vue';
|
||||
*/
|
||||
export const useFirstRunStore = defineStore('gev-first-run', () => {
|
||||
/**
|
||||
* `{removed, shown, visible, closing, state, busy, status, description,
|
||||
* `{removed, shown, visible, closing, state, busy, status,
|
||||
* environmentalTitle, environmentalSub, scrollable}`, or null until the
|
||||
* launcher is initialized (the card stays hidden).
|
||||
*/
|
||||
@@ -19,7 +19,7 @@ export const useFirstRunStore = defineStore('gev-first-run', () => {
|
||||
launcher.value = next && markRaw(next);
|
||||
}
|
||||
|
||||
/** `{choose(choice), dismiss(), suppress(wanted) → boolean}`, or null. */
|
||||
/** `{choose(choice), dismiss(), suppress(wanted) → boolean, refreshLayout()}`, or null. */
|
||||
const controls = shallowRef(null);
|
||||
|
||||
/** @param {?object} next The launcher's controls, or null to disconnect. */
|
||||
|
||||
@@ -79,6 +79,8 @@ export const useGlobeActionsStore = defineStore('gev-globe-actions', () => {
|
||||
}
|
||||
|
||||
const { act, owns } = owners;
|
||||
/** Whether a connected owner answers this action at all. */
|
||||
const answers = (name) => Boolean(owners.ownerOf(name));
|
||||
|
||||
return {
|
||||
clearBusy,
|
||||
@@ -91,5 +93,6 @@ export const useGlobeActionsStore = defineStore('gev-globe-actions', () => {
|
||||
detach,
|
||||
act,
|
||||
owns,
|
||||
answers,
|
||||
};
|
||||
});
|
||||
@@ -5,11 +5,14 @@ import { markRaw, shallowRef } from 'vue';
|
||||
* The top-bar omnibar's link to the shell. The shell connects the actions
|
||||
* the omnibar offers: `layers()` lists the data layers as `{id, name,
|
||||
* enabled}`, and `setLayer(id, enabled)` turns one on or off as a user click
|
||||
* would. Place search runs through the location controls and Ask GEV through
|
||||
* the voice controls, so neither is repeated here.
|
||||
* would. `creditPlaces()`, optional, credits the bundled Wikidata place
|
||||
* packs once a name from them is shown, and `creditSuggestions(shown)`,
|
||||
* optional, shows the OpenStreetMap credit while Photon's suggestions are. Place search runs through the
|
||||
* location controls and Ask GEV through the voice controls, so neither is
|
||||
* repeated here.
|
||||
*/
|
||||
export const useOmnibarStore = defineStore('gev-omnibar', () => {
|
||||
/** `{layers(), setLayer(id, enabled)}`, or null while disconnected. */
|
||||
/** `{layers(), setLayer(id, enabled), creditPlaces?()}`, or null while disconnected. */
|
||||
const controls = shallowRef(null);
|
||||
|
||||
/** @param {?object} next The shell's omnibar actions, or null. */
|
||||
|
||||
@@ -8,6 +8,8 @@ import { computed, markRaw, shallowRef } from 'vue';
|
||||
* @property {(sceneId: string, shotId: string, title: string) => void} rename
|
||||
* @property {(sceneId: string, shotId: string) => void} load
|
||||
* @property {(sceneId: string, shotId: string) => void} remove
|
||||
* @property {(sceneId: string, shotId: string, index: number) => void} move
|
||||
* Move a shot to `index` in its scene's playback order.
|
||||
* @property {(file: File) => Promise<void>|void} importFile A chosen file.
|
||||
* @property {() => void} create, deleteScene, stories, thumb, capture, update,
|
||||
* start, stop, next, export, download The panel's buttons.
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { markRaw, shallowRef } from 'vue';
|
||||
|
||||
/**
|
||||
* The Space Missions panel as its views render it. The Space Missions layer
|
||||
* publishes its roster and selected mission here, and SpaceMissionsControls
|
||||
* publishes whether the layer is on. Nothing here belongs to Context.
|
||||
*/
|
||||
export const useSpaceMissionsStore = defineStore('gev-space-missions', () => {
|
||||
/** Whether the Space Missions layer is on or starting. */
|
||||
const enabled = shallowRef(false);
|
||||
|
||||
/** @param {boolean} next Whether the layer is on or starting. */
|
||||
function setEnabled(next) {
|
||||
enabled.value = Boolean(next);
|
||||
}
|
||||
|
||||
/** The roster; null until the layer first presents it. */
|
||||
const roster = shallowRef(null);
|
||||
|
||||
/** The selected space mission; null while none is selected. */
|
||||
const mission = shallowRef(null);
|
||||
|
||||
/**
|
||||
* @param {?{roster: ?object, mission: ?object}} next The layer's view. The
|
||||
* layer keeps an unchanged roster's object, which re-renders nothing.
|
||||
*/
|
||||
function publish(next) {
|
||||
roster.value = next?.roster ? markRaw(next.roster) : null;
|
||||
mission.value = next?.mission ? markRaw(next.mission) : null;
|
||||
}
|
||||
|
||||
/** The Space Missions layer whose panel commands the components call. */
|
||||
const layer = shallowRef(null);
|
||||
|
||||
/** @param {?object} next The Space Missions layer, or null to disconnect. */
|
||||
function connect(next) {
|
||||
layer.value = next && markRaw(next);
|
||||
}
|
||||
|
||||
return { enabled, setEnabled, roster, mission, publish, layer, connect };
|
||||
});
|
||||
+19
-15
@@ -366,15 +366,12 @@
|
||||
flex-basis: 1.25rem;
|
||||
}
|
||||
/* At this width main shows the wings' icons only (command-dock-trays.css);
|
||||
centre them in the slim wings. Cyber keeps its labels. */
|
||||
centre them in the slim wings. */
|
||||
@media (max-width: 900px) {
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
#command-dock
|
||||
> :is(#location-bar, #control-panel)
|
||||
.dock-tray-toggle {
|
||||
:root #command-dock > :is(#location-bar, #control-panel) .dock-tray-toggle {
|
||||
justify-content: center;
|
||||
}
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
#command-dock
|
||||
:is(#location-bar, #control-panel)
|
||||
:is(.location-toolbar-label, .panel-title) {
|
||||
@@ -382,7 +379,7 @@
|
||||
min-width: 0;
|
||||
justify-content: center;
|
||||
}
|
||||
:root:not([data-ui-theme='cyber']) #command-dock .dock-label-icon {
|
||||
:root #command-dock .dock-label-icon {
|
||||
width: 1.25rem;
|
||||
height: 1.25rem;
|
||||
flex-basis: 1.25rem;
|
||||
@@ -1448,16 +1445,15 @@ body[data-assistant-docked='true'] #right-context-rail {
|
||||
box-shadow: 0 0 0 1px currentColor;
|
||||
}
|
||||
|
||||
/* Assistant panels share the left panels' glass surface (layers.css). Cyber
|
||||
keeps its own surfaces. */
|
||||
:root:not([data-ui-theme='cyber']) #gev-voice-control {
|
||||
/* Assistant panels share the left panels' glass surface (layers.css). */
|
||||
:root #gev-voice-control {
|
||||
--assistant-glass: var(--glass-bg);
|
||||
--assistant-glass-border: var(--glass-border);
|
||||
--assistant-glass-shadow:
|
||||
0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.03) inset,
|
||||
0 1px 0 rgba(255, 255, 255, 0.06) inset;
|
||||
}
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
#command-dock
|
||||
#gev-voice-control
|
||||
:is(
|
||||
@@ -1472,14 +1468,14 @@ body[data-assistant-docked='true'] #right-context-rail {
|
||||
}
|
||||
/* The mini reply sits inside the chat panel, whose own blur makes it the
|
||||
backdrop root: a blur on the reply could not reach the map. */
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
#command-dock
|
||||
#gev-voice-control
|
||||
:is(#gev-chat-panel, #gev-voice-panel, #gev-voice-panel[data-minimized]) {
|
||||
-webkit-backdrop-filter: blur(24px) saturate(1.4);
|
||||
backdrop-filter: blur(24px) saturate(1.4);
|
||||
}
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
#command-dock
|
||||
#gev-voice-control
|
||||
#gev-chat-panel[data-minimized='true']:focus-within {
|
||||
@@ -1488,12 +1484,12 @@ body[data-assistant-docked='true'] #right-context-rail {
|
||||
|
||||
/* A backdrop-filter on the voice control would stop the panels inside it
|
||||
from blurring the map, so its own blur moves to a layer behind it. */
|
||||
:root:not([data-ui-theme='cyber']) #command-dock > #gev-voice-control {
|
||||
:root #command-dock > #gev-voice-control {
|
||||
isolation: isolate;
|
||||
-webkit-backdrop-filter: none;
|
||||
backdrop-filter: none;
|
||||
}
|
||||
:root:not([data-ui-theme='cyber']) #command-dock > #gev-voice-control::before {
|
||||
:root #command-dock > #gev-voice-control::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
@@ -1698,3 +1694,11 @@ body[data-assistant-docked='true'] #right-context-rail {
|
||||
--dock-side-compact: 3.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
/* From 1200px the dock sits 74px up (command-dock.css), 74px - 2vh higher
|
||||
than the bottom-edge dock this height budget was written for. */
|
||||
@media (min-width: 1200px) {
|
||||
#gev-chat-panel {
|
||||
max-height: min(34rem, calc(100dvh - 10rem - 74px + 2vh));
|
||||
}
|
||||
}
|
||||
@@ -123,7 +123,7 @@
|
||||
}
|
||||
|
||||
/* Display / Radio: the closed launchers and the open panels match too. */
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-control.is-expanded {
|
||||
border-color: rgba(255, 255, 255, 0.08);
|
||||
@@ -139,14 +139,14 @@
|
||||
person, Utilities has nothing to do there, and the cockpit's own Display
|
||||
panel stands in for Visual), one panel opens beside it, and the collapsed
|
||||
header strips the cockpit used instead are hidden. */
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
#left-panel-stack
|
||||
> .gev-panel-rail--left {
|
||||
display: block;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
#left-panel-stack
|
||||
> .gev-panel-rail--left
|
||||
@@ -155,7 +155,7 @@
|
||||
[data-rail-item='utilities-panel'],
|
||||
[data-rail-item='pp-toggles']
|
||||
),
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
#left-panel-stack
|
||||
> .gev-panel-rail--left
|
||||
@@ -171,7 +171,7 @@
|
||||
|
||||
/* With some icons hidden, the runs between them break up: with a panel
|
||||
open, each icon left is its own island. */
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
#left-panel-stack
|
||||
> .gev-panel-rail--left
|
||||
@@ -184,7 +184,7 @@
|
||||
|
||||
/* Authoring, Utilities or Visual may still be open underneath; its hidden icon must
|
||||
not split the rail into islands. */
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
#left-panel-stack
|
||||
> .gev-panel-rail--left
|
||||
@@ -196,7 +196,7 @@
|
||||
)[aria-pressed='true']
|
||||
)
|
||||
> .ui-tooltip::before,
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
#left-panel-stack
|
||||
> .gev-panel-rail--left
|
||||
@@ -211,7 +211,7 @@
|
||||
display: none;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
#left-panel-stack
|
||||
> .gev-panel-rail--left
|
||||
@@ -229,11 +229,11 @@
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
#left-panel-stack
|
||||
> [data-panel-id].collapsed,
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
#left-panel-stack
|
||||
> :is(
|
||||
@@ -247,9 +247,7 @@
|
||||
/* Both rails start at one height, just under the top HUD text, so their top
|
||||
edges line up; the cockpit layout pass places Display and Radio at the
|
||||
same height (COCKPIT_UTILITY_MIN_TOP_PX / _RATIO in cockpitPresentation.js). */
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
#left-panel-stack {
|
||||
:root body.cockpit-mode:not(.mobile-shell) #left-panel-stack {
|
||||
top: max(206px, 22vh) !important;
|
||||
}
|
||||
|
||||
@@ -415,14 +413,14 @@ body.cockpit-mode #intel-hud .hud-bottom-right {
|
||||
}
|
||||
|
||||
/* ── Open Display / Radio panels: the main panels' header and size ───── */
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-control.is-expanded {
|
||||
min-width: 295px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-control.is-expanded
|
||||
.cockpit-utility-launcher {
|
||||
@@ -435,7 +433,7 @@ body.cockpit-mode #intel-hud .hud-bottom-right {
|
||||
letter-spacing: 0.22em;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-control.is-expanded
|
||||
.cockpit-utility-divider {
|
||||
@@ -448,16 +446,14 @@ body.cockpit-mode #intel-hud .hud-bottom-right {
|
||||
|
||||
/* The launcher's own toggle steps aside: the rail and "−" open and close
|
||||
the panel instead. */
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-control.is-expanded
|
||||
.cockpit-utility-glyph {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-collapse {
|
||||
:root body.cockpit-mode:not(.mobile-shell) .cockpit-utility-collapse {
|
||||
display: grid;
|
||||
flex: none;
|
||||
place-items: center;
|
||||
@@ -472,10 +468,8 @@ body.cockpit-mode #intel-hud .hud-bottom-right {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-collapse:hover,
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root body.cockpit-mode:not(.mobile-shell) .cockpit-utility-collapse:hover,
|
||||
:root
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-collapse:focus-visible {
|
||||
border-color: rgba(0, 212, 255, 0.45);
|
||||
@@ -486,9 +480,7 @@ body.cockpit-mode #intel-hud .hud-bottom-right {
|
||||
/* ── Right rail as on the left: an icon column that stays, labels beside it
|
||||
while nothing is open, and the open panel to its left. The launchers'
|
||||
own strips give way to it. ─────────────────────────────────────────── */
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-controls {
|
||||
:root body.cockpit-mode:not(.mobile-shell) .cockpit-utility-controls {
|
||||
display: grid;
|
||||
grid-template-columns: auto auto;
|
||||
align-items: start;
|
||||
@@ -496,13 +488,13 @@ body.cockpit-mode #intel-hud .hud-bottom-right {
|
||||
column-gap: 6px;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-control:not(.is-expanded) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-control.is-expanded {
|
||||
grid-column: 1;
|
||||
@@ -510,16 +502,14 @@ body.cockpit-mode #intel-hud .hud-bottom-right {
|
||||
margin-top: 0 !important;
|
||||
}
|
||||
|
||||
/* Cyber and the phone keep the launchers' own toggles, so the rail and "−"
|
||||
are for the desktop look only. */
|
||||
/* The phone keeps the launchers' own toggles, so the rail and "−" are for
|
||||
the desktop look only. */
|
||||
.cockpit-utility-rail,
|
||||
.cockpit-utility-collapse {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-rail {
|
||||
:root body.cockpit-mode:not(.mobile-shell) .cockpit-utility-rail {
|
||||
grid-column: 2;
|
||||
grid-row: 1;
|
||||
display: flex;
|
||||
@@ -528,7 +518,7 @@ body.cockpit-mode #intel-hud .hud-bottom-right {
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
:is(.cockpit-utility-rail__labels, .cockpit-utility-rail__icons) {
|
||||
display: flex;
|
||||
@@ -545,15 +535,13 @@ body.cockpit-mode #intel-hud .hud-bottom-right {
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-rail__labels {
|
||||
:root body.cockpit-mode:not(.mobile-shell) .cockpit-utility-rail__labels {
|
||||
box-sizing: border-box;
|
||||
width: 170px;
|
||||
padding-inline: 14px;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-rail__labels
|
||||
> span {
|
||||
@@ -569,16 +557,14 @@ body.cockpit-mode #intel-hud .hud-bottom-right {
|
||||
letter-spacing: 2.08px;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-rail.is-open
|
||||
.cockpit-utility-rail__labels {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-rail__item {
|
||||
:root body.cockpit-mode:not(.mobile-shell) .cockpit-utility-rail__item {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 32px;
|
||||
@@ -595,24 +581,20 @@ body.cockpit-mode #intel-hud .hud-bottom-right {
|
||||
border-color var(--transition-fast, 120ms);
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-rail__item
|
||||
.material-symbols-outlined {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-rail__item:hover {
|
||||
:root body.cockpit-mode:not(.mobile-shell) .cockpit-utility-rail__item:hover {
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
color: var(--text-primary, #fff);
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-rail__item.is-on,
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root body.cockpit-mode:not(.mobile-shell) .cockpit-utility-rail__item.is-on,
|
||||
:root
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-rail__item.is-on:hover {
|
||||
border-color: rgba(0, 212, 255, 0.15);
|
||||
@@ -621,7 +603,7 @@ body.cockpit-mode #intel-hud .hud-bottom-right {
|
||||
}
|
||||
|
||||
/* With a panel open, each icon is its own island, as on the main rails. */
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-rail.is-open
|
||||
.cockpit-utility-rail__icons {
|
||||
@@ -632,14 +614,14 @@ body.cockpit-mode #intel-hud .hud-bottom-right {
|
||||
-webkit-backdrop-filter: none;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-rail.is-open
|
||||
.cockpit-utility-rail__item {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-rail.is-open
|
||||
.cockpit-utility-rail__item::before {
|
||||
@@ -657,12 +639,12 @@ body.cockpit-mode #intel-hud .hud-bottom-right {
|
||||
}
|
||||
|
||||
/* Hovering an icon lights its label too, as on the left. */
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-rail:has(.cockpit-utility-rail__item:nth-child(1):hover)
|
||||
.cockpit-utility-rail__labels
|
||||
> span:nth-child(1),
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-rail:has(.cockpit-utility-rail__item:nth-child(2):hover)
|
||||
.cockpit-utility-rail__labels
|
||||
@@ -671,22 +653,18 @@ body.cockpit-mode #intel-hud .hud-bottom-right {
|
||||
}
|
||||
|
||||
/* Mirror the left rail's 52px inset, clear of the HUD's vertical readouts. */
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-controls {
|
||||
:root body.cockpit-mode:not(.mobile-shell) .cockpit-utility-controls {
|
||||
right: 52px;
|
||||
}
|
||||
|
||||
/* Like the cockpit's other windows (rtl.css), the rail keeps its physical
|
||||
side in a right-to-left language: icons at the screen edge, the open panel
|
||||
inside them. Only the text reads right to left. */
|
||||
html[dir='rtl']:not([data-ui-theme='cyber'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-controls {
|
||||
html[dir='rtl'] body.cockpit-mode:not(.mobile-shell) .cockpit-utility-controls {
|
||||
direction: ltr;
|
||||
}
|
||||
|
||||
html[dir='rtl']:not([data-ui-theme='cyber'])
|
||||
html[dir='rtl']
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
:is(.cockpit-utility-control.is-expanded, .cockpit-utility-rail__labels) {
|
||||
direction: rtl;
|
||||
|
||||
@@ -15,13 +15,8 @@
|
||||
var(--cockpit-radar-label-height) + 14px
|
||||
);
|
||||
}
|
||||
:root[data-ui-theme='cyber'] #cockpit-hud[data-subject='vessel'] {
|
||||
--cockpit-radar-right: 30px;
|
||||
}
|
||||
:root[data-ui-theme='cyber'] #cockpit-hud[data-subject='vessel']::before {
|
||||
clip-path: none;
|
||||
}
|
||||
:root:not([data-ui-theme='cyber']) body.cockpit-bridge {
|
||||
|
||||
:root body.cockpit-bridge {
|
||||
--panel-radius: 2px;
|
||||
--btn-radius: 2px;
|
||||
}
|
||||
@@ -252,25 +247,6 @@ body.cockpit-bridge #view-switcher button {
|
||||
border-radius: 2px;
|
||||
transform: none;
|
||||
}
|
||||
/* Cyber anchors the card's top from the layout pass; bound its height. */
|
||||
:root[data-ui-theme='cyber']
|
||||
#cockpit-hud[data-subject='vessel']
|
||||
.cockpit-signal-window {
|
||||
bottom: auto;
|
||||
max-height: max(
|
||||
44px,
|
||||
min(
|
||||
30vh,
|
||||
280px,
|
||||
calc(
|
||||
100vh - var(--cockpit-signal-top, clamp(255px, 28vh, 300px)) -
|
||||
var(--cockpit-radar-clearance)
|
||||
)
|
||||
)
|
||||
);
|
||||
clip-path: none;
|
||||
}
|
||||
|
||||
/* The radar console: CockpitRadar fills it, label row included. */
|
||||
#cockpit-hud[data-subject='vessel'] .cockpit-radar-console {
|
||||
position: absolute;
|
||||
@@ -296,15 +272,6 @@ body.cockpit-bridge #view-switcher button {
|
||||
.cockpit-radar-console:has(> .cockpit-radar[hidden]) {
|
||||
display: none;
|
||||
}
|
||||
:root[data-ui-theme='cyber']
|
||||
#cockpit-hud[data-subject='vessel']
|
||||
.cockpit-radar-console {
|
||||
border-color: rgba(105, 203, 209, 0.34);
|
||||
border-top-color: rgba(196, 84, 84, 0.82);
|
||||
background:
|
||||
linear-gradient(135deg, rgba(105, 203, 209, 0.07), transparent 38%),
|
||||
rgba(8, 23, 27, 0.78);
|
||||
}
|
||||
|
||||
@media (min-width: 761px) {
|
||||
/* The heading tape narrows to stay clear of the console. */
|
||||
@@ -318,18 +285,6 @@ body.cockpit-bridge #view-switcher button {
|
||||
)
|
||||
);
|
||||
}
|
||||
:root[data-ui-theme='cyber']
|
||||
#cockpit-hud[data-subject='vessel']
|
||||
.cockpit-compass {
|
||||
width: min(
|
||||
650px,
|
||||
56vw,
|
||||
calc(
|
||||
100vw - 2 *
|
||||
(var(--cockpit-radar-right) + var(--cockpit-radar-size) + 24px)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@media (min-width: 761px) and (min-height: 601px) {
|
||||
/* The console takes the intel HUD's bottom-right corner. */
|
||||
|
||||
@@ -489,10 +489,8 @@
|
||||
#cockpit-hud[data-subject='satellite'] .cockpit-topline > div:first-child {
|
||||
visibility: hidden;
|
||||
}
|
||||
:root[data-ui-theme='cyber'] #cockpit-hud[data-subject='satellite']::before {
|
||||
clip-path: none;
|
||||
}
|
||||
:root:not([data-ui-theme='cyber']) body.cockpit-orbit {
|
||||
|
||||
:root body.cockpit-orbit {
|
||||
--panel-radius: 2px;
|
||||
--btn-radius: 2px;
|
||||
}
|
||||
|
||||
@@ -448,14 +448,18 @@
|
||||
letter-spacing: 0.035rem;
|
||||
}
|
||||
|
||||
/* Keep the complete inline attribution row above the command dock. */
|
||||
/* From 1200px the attribution row sits on the bottom edge, on the Power Up
|
||||
baseline, below the raised command dock (command-dock.css). It stops 26rem
|
||||
short of the right edge, clear of the corner row (Power Up and the language
|
||||
picker), and wraps rather than running under it. Below 1200px the dock
|
||||
keeps to the bottom edge and the row sits above it. */
|
||||
body:not(.ui-clean-view):not(.recording-mode) #cesium-credits,
|
||||
body:not(.ui-clean-view):not(.recording-mode):has(
|
||||
#intel-hud[data-variant='minimal'].active
|
||||
)
|
||||
#cesium-credits {
|
||||
right: auto;
|
||||
bottom: calc(2vh + 5rem + var(--world-timeline-lift, 0px));
|
||||
bottom: 1rem;
|
||||
left: 1.5rem;
|
||||
width: auto !important;
|
||||
max-width: calc(100vw - 3rem);
|
||||
@@ -468,10 +472,11 @@ body:not(.ui-clean-view):not(.recording-mode):has(
|
||||
)
|
||||
#gev-credits {
|
||||
right: auto;
|
||||
bottom: calc(2vh + 5rem + var(--world-timeline-lift, 0px));
|
||||
bottom: 1rem;
|
||||
left: 1.5rem;
|
||||
width: auto !important;
|
||||
max-width: calc(100vw - 3rem);
|
||||
width: max-content !important;
|
||||
max-width: calc(100vw - 1.5rem - 26rem);
|
||||
white-space: normal;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
@@ -494,6 +499,71 @@ body:not(.ui-clean-view):not(.recording-mode):has(
|
||||
bottom: calc(2vh + 9rem + var(--world-timeline-lift, 0px));
|
||||
}
|
||||
|
||||
/* The coordinate readout shares the bottom-left corner with the attribution
|
||||
row below 1200px: it sits clear of the row's 28px logo line, with a 6px gap
|
||||
(from 1200px, rail-split.css). */
|
||||
#intel-hud:is([data-variant='tactical'], [data-variant='minimal'])
|
||||
.hud-bottom-left,
|
||||
:root[data-scope-mask='off']
|
||||
#intel-hud[data-variant='minimal']
|
||||
.hud-bottom-left {
|
||||
bottom: calc(2vh + 7.125rem + var(--world-timeline-lift, 0px));
|
||||
}
|
||||
|
||||
@media (max-width: 1199px) {
|
||||
body:not(.ui-clean-view):not(.recording-mode) #cesium-credits,
|
||||
body:not(.ui-clean-view):not(.recording-mode):has(
|
||||
#intel-hud[data-variant='minimal'].active
|
||||
)
|
||||
#cesium-credits,
|
||||
body:not(.ui-clean-view):not(.recording-mode) #gev-credits,
|
||||
body:not(.ui-clean-view):not(.recording-mode):has(
|
||||
#intel-hud[data-variant='minimal'].active
|
||||
)
|
||||
#gev-credits {
|
||||
bottom: calc(2vh + 5rem + var(--world-timeline-lift, 0px));
|
||||
width: auto !important;
|
||||
max-width: calc(100vw - 3rem);
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1200px) {
|
||||
/* Cesium draws the line in an absolutely placed box inside the empty
|
||||
#cesium-credits anchor, so the cap and the wrapping go on that box. */
|
||||
#cesium-credits .cesium-widget-credits {
|
||||
width: max-content;
|
||||
max-width: calc(100vw - 1.5rem - 26rem);
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
/* Right to left, the corner row sits at the bottom left
|
||||
(locale-picker.css), so the attribution row takes the bottom right.
|
||||
Expanded Context places it itself (context-dock.css). */
|
||||
/* The Minimal HUD's placement above names #intel-hud too: matched here,
|
||||
so right to left wins over it. */
|
||||
html[dir='rtl']
|
||||
body:not(.context-docked):not(.ui-clean-view):not(.recording-mode)
|
||||
:is(#cesium-credits, #gev-credits),
|
||||
html[dir='rtl']
|
||||
body:not(.context-docked):not(.ui-clean-view):not(.recording-mode):has(
|
||||
#intel-hud[data-variant='minimal'].active
|
||||
)
|
||||
:is(#cesium-credits, #gev-credits) {
|
||||
right: 1.5rem;
|
||||
left: auto;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
html[dir='rtl']
|
||||
body:not(.context-docked):not(.ui-clean-view):not(.recording-mode)
|
||||
#cesium-credits
|
||||
.cesium-widget-credits {
|
||||
right: 0;
|
||||
left: auto;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
body:not(.ui-clean-view):not(.recording-mode) #cesium-credits,
|
||||
body:not(.ui-clean-view):not(.recording-mode):has(
|
||||
@@ -522,13 +592,9 @@ body:not(.ui-clean-view):not(.recording-mode):has(
|
||||
/* The wings shrink to --dock-side-compact at this width, open or closed (an
|
||||
open tray pops out above the dock), which is too narrow for the text
|
||||
labels; they would spill over the voice control and take its taps. The
|
||||
wings show only their icon; the toggles keep their aria-label. Cyber sets
|
||||
a wider --dock-side-compact that fits its labels, so it keeps them. */
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
#command-dock
|
||||
:is(#location-bar, #control-panel)
|
||||
.panel-title,
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
wings show only their icon; the toggles keep their aria-label. */
|
||||
:root #command-dock :is(#location-bar, #control-panel) .panel-title,
|
||||
:root
|
||||
#command-dock
|
||||
:is(#location-bar, #control-panel)
|
||||
.location-toolbar-label {
|
||||
@@ -538,11 +604,8 @@ body:not(.ui-clean-view):not(.recording-mode):has(
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
#command-dock
|
||||
:is(#location-bar, #control-panel)
|
||||
.panel-title::after,
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root #command-dock :is(#location-bar, #control-panel) .panel-title::after,
|
||||
:root
|
||||
#command-dock
|
||||
:is(#location-bar, #control-panel)
|
||||
.location-toolbar-label::after {
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
#command-dock {
|
||||
position: fixed;
|
||||
right: auto;
|
||||
/* Above the world timeline while it shows (world-timeline.css). */
|
||||
bottom: calc(2vh + var(--world-timeline-lift, 0px));
|
||||
/* 74px up from 1200px, leaving the bottom row to the map credits and
|
||||
Power Up; above the world timeline while it shows (world-timeline.css). */
|
||||
bottom: calc(74px + var(--world-timeline-lift, 0px));
|
||||
left: 50%;
|
||||
z-index: 145;
|
||||
display: grid;
|
||||
@@ -273,6 +274,14 @@ body.recording-mode #gev-credits {
|
||||
bottom: calc(2vh + 11.5rem + var(--world-timeline-lift, 0px));
|
||||
}
|
||||
|
||||
/* Below 1200px the dock reaches the bottom corners, so it keeps to the
|
||||
bottom edge and the credits and coordinates sit above it. */
|
||||
@media (max-width: 1199px) {
|
||||
#command-dock {
|
||||
bottom: calc(2vh + var(--world-timeline-lift, 0px));
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 980px) {
|
||||
#command-dock {
|
||||
grid-template-areas:
|
||||
|
||||
+18
-33
@@ -97,7 +97,7 @@
|
||||
|
||||
/* A hovered panel sets --rail-label-hover on itself (see below); its own
|
||||
header picks it up. Radio sits inside Context and keeps its own colour. */
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
:is(#left-panel-stack, #right-context-rail)
|
||||
:is(
|
||||
.panel-header > .panel-title,
|
||||
@@ -112,9 +112,8 @@
|
||||
}
|
||||
|
||||
/* A title never pushes its toggle out of the card: one that does not fit
|
||||
ends in an ellipsis. Cyber draws a marker left of the title, which a clip
|
||||
would cut, and keeps its own header layout. */
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
ends in an ellipsis. */
|
||||
:root
|
||||
:is(#left-panel-stack, #right-context-rail)
|
||||
:is(.panel-header > .panel-title, .pp-header-label) {
|
||||
min-width: 0;
|
||||
@@ -126,25 +125,25 @@
|
||||
so the header drops it and packs closer. English titles such as Recent
|
||||
Imagery then fit whole. Only the rail's own launchers: Radio, nested in
|
||||
Context, keeps its divider. */
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
:is(#left-panel-stack, #right-context-rail)
|
||||
> .panel-collapsible.collapsed
|
||||
> [class$='-panel-inner']
|
||||
> .panel-header,
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
:is(#left-panel-stack, #right-context-rail)
|
||||
> #pp-toggles.collapsed
|
||||
> .pp-header-row {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
:is(#left-panel-stack, #right-context-rail)
|
||||
> .panel-collapsible.collapsed
|
||||
> [class$='-panel-inner']
|
||||
> .panel-header
|
||||
> .panel-divider,
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
:is(#left-panel-stack, #right-context-rail)
|
||||
> #pp-toggles.collapsed
|
||||
> .pp-header-row
|
||||
@@ -152,13 +151,13 @@
|
||||
display: none;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
:is(#left-panel-stack, #right-context-rail)
|
||||
> .panel-collapsible.collapsed
|
||||
> [class$='-panel-inner']
|
||||
> .panel-header
|
||||
> .panel-collapse-btn,
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
:is(#left-panel-stack, #right-context-rail)
|
||||
> #pp-toggles.collapsed
|
||||
> .pp-header-row
|
||||
@@ -216,7 +215,7 @@ html:not([lang='en']):not(:lang(zh)):not(:lang(ja))
|
||||
brighter edge and an accent title and toggle. Touch screens have no hover,
|
||||
so a tap must not leave a panel lit. */
|
||||
@media (hover: hover) and (pointer: fine) {
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
:is(#left-panel-stack, #right-context-rail)
|
||||
:where(
|
||||
.data-panel-inner,
|
||||
@@ -227,13 +226,14 @@ html:not([lang='en']):not(:lang(zh)):not(:lang(ja))
|
||||
.recent-imagery-panel-inner,
|
||||
.street-level-panel-inner,
|
||||
.global-context-panel-inner,
|
||||
.space-missions-panel-inner,
|
||||
#pp-toggles:not(.collapsed),
|
||||
#pp-toggles.collapsed > .pp-header-row
|
||||
) {
|
||||
transition: border-color var(--transition-fast);
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:root
|
||||
:is(#left-panel-stack, #right-context-rail)
|
||||
:where(
|
||||
.data-panel-inner,
|
||||
@@ -244,6 +244,7 @@ html:not([lang='en']):not(:lang(zh)):not(:lang(ja))
|
||||
.recent-imagery-panel-inner,
|
||||
.street-level-panel-inner,
|
||||
.global-context-panel-inner,
|
||||
.space-missions-panel-inner,
|
||||
#pp-toggles:not(.collapsed),
|
||||
#pp-toggles.collapsed > .pp-header-row
|
||||
):hover {
|
||||
@@ -560,14 +561,12 @@ html:not([lang='en']):not(:lang(zh)):not(:lang(ja))
|
||||
}
|
||||
|
||||
/* Display's title and toggle sit where the other panels' do: 14px of panel
|
||||
padding plus a 4px header inset. The cyber theme sets its own insets. */
|
||||
:root:not([data-ui-theme='cyber']) #pp-toggles.collapsed > .pp-header-row {
|
||||
padding plus a 4px header inset. */
|
||||
:root #pp-toggles.collapsed > .pp-header-row {
|
||||
padding: 8px 18px;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
#pp-toggles:not(.collapsed)
|
||||
> .pp-header-row {
|
||||
:root #pp-toggles:not(.collapsed) > .pp-header-row {
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
@@ -580,10 +579,7 @@ html:not([lang='en']):not(:lang(zh)):not(:lang(ja))
|
||||
}
|
||||
|
||||
/* In the default theme Display's toggle matches the other panels' 22px. */
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
#pp-toggles
|
||||
> .pp-header-row
|
||||
.pp-collapse-btn {
|
||||
:root #pp-toggles > .pp-header-row .pp-collapse-btn {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
font-size: 13px;
|
||||
@@ -746,14 +742,6 @@ html:not([lang='en']) .pp-slider-row > .pp-slider-mini-label {
|
||||
min-width: 200px;
|
||||
}
|
||||
|
||||
.cyber-sonar-control {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:root[data-ui-theme='cyber'] .cyber-sonar-control {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.cyber-sonar-toggle-row,
|
||||
.cyber-sonar-setting {
|
||||
min-width: 200px;
|
||||
@@ -764,10 +752,6 @@ html:not([lang='en']) .pp-slider-row > .pp-slider-mini-label {
|
||||
min-width: 48px;
|
||||
}
|
||||
|
||||
:root[data-cyber-sonar='off'] .cyber-sonar-setting {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Map Source tiles live with Visual Presets in the bottom command tray. */
|
||||
.map-source-section {
|
||||
display: grid;
|
||||
@@ -1193,6 +1177,7 @@ body.ui-clean-view #data-panel,
|
||||
body.ui-clean-view #cctv-panel,
|
||||
body.ui-clean-view #radio-panel,
|
||||
body.ui-clean-view #global-context-panel,
|
||||
body.ui-clean-view #space-missions-panel,
|
||||
body.ui-clean-view #utilities-panel,
|
||||
body.ui-clean-view #scene-panel {
|
||||
opacity: 0 !important;
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
+1559
-95
File diff suppressed because it is too large.
Load diff
Vendored
+17
@@ -632,6 +632,23 @@ body.cockpit-mode #cockpit-cloud-effects.active {
|
||||
filter: drop-shadow(0 0 12px rgba(0, 246, 255, 0.5));
|
||||
}
|
||||
|
||||
/* The logo is a button: back to live at the start view. */
|
||||
#title-bar button.title-logo {
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: none;
|
||||
color: inherit;
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
#title-bar button.title-logo:focus-visible {
|
||||
outline: 2px solid var(--accent);
|
||||
outline-offset: 4px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
#title-bar .title-logo::before,
|
||||
#title-bar .title-logo::after {
|
||||
--radio-broadcast-opacity: 0.28;
|
||||
|
||||
@@ -0,0 +1,413 @@
|
||||
/* ── "Show me how" guide ───────────────────────────────────────────────
|
||||
A spotlight dims everything but the control to press and frames it with
|
||||
tactical corner brackets; a second frame marks a part of it (a layer's
|
||||
switch). A glass callout beside it, with an arrow to the target, says
|
||||
what to do and how far along the walk is. Clicks pass through to the
|
||||
app: the guide only points. */
|
||||
.gev-guide {
|
||||
--gev-guide-accent: #ff9f43;
|
||||
--gev-guide-accent-soft: rgba(255, 159, 67, 0.5);
|
||||
position: fixed;
|
||||
z-index: 400;
|
||||
inset: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* ── Spotlight ── */
|
||||
.gev-guide-ring {
|
||||
position: fixed;
|
||||
border: 1px solid rgba(255, 159, 67, 0.28);
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 0 0 200vmax rgba(3, 8, 14, 0.55);
|
||||
opacity: 0;
|
||||
transition:
|
||||
left 280ms cubic-bezier(0.2, 0.8, 0.2, 1),
|
||||
top 280ms cubic-bezier(0.2, 0.8, 0.2, 1),
|
||||
width 280ms cubic-bezier(0.2, 0.8, 0.2, 1),
|
||||
height 280ms cubic-bezier(0.2, 0.8, 0.2, 1),
|
||||
opacity 160ms ease;
|
||||
}
|
||||
|
||||
/* Corner brackets, drawn as eight short gradient strokes. */
|
||||
.gev-guide-ring::before {
|
||||
position: absolute;
|
||||
inset: -3px;
|
||||
background:
|
||||
linear-gradient(var(--gev-guide-accent) 0 0) top left / 12px 2px,
|
||||
linear-gradient(var(--gev-guide-accent) 0 0) top left / 2px 12px,
|
||||
linear-gradient(var(--gev-guide-accent) 0 0) top right / 12px 2px,
|
||||
linear-gradient(var(--gev-guide-accent) 0 0) top right / 2px 12px,
|
||||
linear-gradient(var(--gev-guide-accent) 0 0) bottom left / 12px 2px,
|
||||
linear-gradient(var(--gev-guide-accent) 0 0) bottom left / 2px 12px,
|
||||
linear-gradient(var(--gev-guide-accent) 0 0) bottom right / 12px 2px,
|
||||
linear-gradient(var(--gev-guide-accent) 0 0) bottom right / 2px 12px;
|
||||
background-repeat: no-repeat;
|
||||
content: '';
|
||||
filter: drop-shadow(0 0 4px rgba(255, 159, 67, 0.6));
|
||||
}
|
||||
|
||||
/* A soft ping that grows out of the frame: "press here". */
|
||||
.gev-guide-ring > i {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
border: 1px solid var(--gev-guide-accent-soft);
|
||||
border-radius: inherit;
|
||||
animation: gev-guide-ping 1.8s cubic-bezier(0.2, 0.7, 0.3, 1) infinite;
|
||||
}
|
||||
|
||||
/* A second frame inside the spotlight does not dim the screen again. */
|
||||
.gev-guide-ring--sub {
|
||||
border-color: rgba(255, 159, 67, 0.4);
|
||||
border-radius: 6px;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.gev-guide-ring--sub::before {
|
||||
inset: -2px;
|
||||
background-size:
|
||||
8px 2px,
|
||||
2px 8px,
|
||||
8px 2px,
|
||||
2px 8px,
|
||||
8px 2px,
|
||||
2px 8px,
|
||||
8px 2px,
|
||||
2px 8px;
|
||||
}
|
||||
|
||||
/* ── Callout ── */
|
||||
.gev-guide-callout {
|
||||
position: fixed;
|
||||
width: 280px;
|
||||
padding: 0.7rem 0.8rem 0.65rem;
|
||||
color: rgba(232, 238, 242, 0.95);
|
||||
background: rgba(40, 44, 52, 0.9);
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
border-radius: 12px;
|
||||
box-shadow:
|
||||
0 16px 40px rgba(0, 0, 0, 0.55),
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.06);
|
||||
backdrop-filter: blur(22px) saturate(1.3);
|
||||
-webkit-backdrop-filter: blur(22px) saturate(1.3);
|
||||
opacity: 0;
|
||||
transform: translateY(4px);
|
||||
transition:
|
||||
left 280ms cubic-bezier(0.2, 0.8, 0.2, 1),
|
||||
top 280ms cubic-bezier(0.2, 0.8, 0.2, 1),
|
||||
opacity 180ms ease,
|
||||
transform 180ms ease;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.gev-guide.visible .gev-guide-callout {
|
||||
opacity: 1;
|
||||
transform: none;
|
||||
}
|
||||
|
||||
/* A leader line from the callout to the target's frame, ending in a dot. */
|
||||
.gev-guide-callout::before,
|
||||
.gev-guide-callout::after {
|
||||
position: absolute;
|
||||
top: var(--gev-guide-arrow-y, 50%);
|
||||
content: '';
|
||||
transition: top 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
|
||||
}
|
||||
|
||||
.gev-guide-callout::before {
|
||||
width: 18px;
|
||||
height: 1px;
|
||||
background: var(--gev-guide-accent);
|
||||
box-shadow: 0 0 6px rgba(255, 159, 67, 0.7);
|
||||
}
|
||||
|
||||
.gev-guide-callout::after {
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
margin-top: -2px;
|
||||
background: var(--gev-guide-accent);
|
||||
border-radius: 50%;
|
||||
box-shadow: 0 0 6px rgba(255, 159, 67, 0.9);
|
||||
}
|
||||
|
||||
.gev-guide-callout[data-side='right']::before {
|
||||
right: 100%;
|
||||
}
|
||||
|
||||
.gev-guide-callout[data-side='right']::after {
|
||||
right: calc(100% + 15px);
|
||||
}
|
||||
|
||||
.gev-guide-callout[data-side='left']::before {
|
||||
left: 100%;
|
||||
}
|
||||
|
||||
.gev-guide-callout[data-side='left']::after {
|
||||
left: calc(100% + 15px);
|
||||
}
|
||||
|
||||
.gev-guide-callout[data-side='none']::before,
|
||||
.gev-guide-callout[data-side='none']::after {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* The edge the line leaves from picks up the accent. */
|
||||
.gev-guide-callout[data-side='right'] {
|
||||
border-left-color: rgba(255, 159, 67, 0.55);
|
||||
}
|
||||
|
||||
.gev-guide-callout[data-side='left'] {
|
||||
border-right-color: rgba(255, 159, 67, 0.55);
|
||||
}
|
||||
|
||||
/* Header: what this walk is about, how far along, and a close. */
|
||||
.gev-guide-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.gev-guide-title,
|
||||
.gev-guide-count {
|
||||
margin: 0;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.56rem;
|
||||
letter-spacing: 0.12rem;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.gev-guide-title {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
color: var(--gev-guide-accent);
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.gev-guide-count {
|
||||
color: rgba(214, 220, 226, 0.55);
|
||||
font-variant-numeric: tabular-nums;
|
||||
letter-spacing: 0.06rem;
|
||||
}
|
||||
|
||||
.gev-guide-close {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
margin: -2px -4px 0 0;
|
||||
padding: 0;
|
||||
color: rgba(214, 220, 226, 0.55);
|
||||
font-size: 0.95rem;
|
||||
line-height: 1;
|
||||
background: none;
|
||||
border: 0;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.gev-guide-close:hover,
|
||||
.gev-guide-close:focus-visible {
|
||||
color: #fff;
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
}
|
||||
|
||||
/* Progress: one segment per step. */
|
||||
.gev-guide-progress {
|
||||
display: flex;
|
||||
gap: 3px;
|
||||
margin: 0.45rem 0 0.6rem;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.gev-guide-progress li {
|
||||
flex: 1;
|
||||
height: 2px;
|
||||
background: rgba(214, 220, 226, 0.16);
|
||||
border-radius: 2px;
|
||||
transition: background 220ms ease;
|
||||
}
|
||||
|
||||
.gev-guide-progress li.done {
|
||||
background: rgba(255, 159, 67, 0.55);
|
||||
}
|
||||
|
||||
.gev-guide-progress li.current {
|
||||
background: var(--gev-guide-accent);
|
||||
box-shadow: 0 0 6px rgba(255, 159, 67, 0.6);
|
||||
}
|
||||
|
||||
.gev-guide-callout.swap .gev-guide-body {
|
||||
animation: gev-guide-swap 260ms ease both;
|
||||
}
|
||||
|
||||
.gev-guide-text {
|
||||
margin: 0;
|
||||
font-size: 0.84rem;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
/* "Press the highlighted control", with a live dot. */
|
||||
.gev-guide-hint {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.45rem;
|
||||
margin: 0.4rem 0 0;
|
||||
color: rgba(214, 220, 226, 0.6);
|
||||
font-size: 0.68rem;
|
||||
}
|
||||
|
||||
.gev-guide-hint[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.gev-guide-hint-dot {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
flex: none;
|
||||
background: var(--gev-guide-accent);
|
||||
border-radius: 50%;
|
||||
animation: gev-guide-blink 1.4s ease-in-out infinite;
|
||||
}
|
||||
|
||||
/* Footer: the Esc hint on the left, the buttons on the right. */
|
||||
.gev-guide-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.4rem;
|
||||
margin-top: 0.7rem;
|
||||
padding-top: 0.55rem;
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.07);
|
||||
}
|
||||
|
||||
.gev-guide-actions > span {
|
||||
display: flex;
|
||||
gap: 0.4rem;
|
||||
}
|
||||
|
||||
.gev-guide-keys {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.35rem;
|
||||
margin: 0;
|
||||
color: rgba(214, 220, 226, 0.45);
|
||||
font-size: 0.62rem;
|
||||
}
|
||||
|
||||
.gev-guide-keys[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* With the Esc hint gone, the offer's buttons sit on the right. */
|
||||
.gev-guide-actions > span:only-of-type {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.gev-guide-keys kbd {
|
||||
padding: 0.05rem 0.3rem;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.54rem;
|
||||
border: 1px solid rgba(214, 220, 226, 0.22);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.gev-guide-actions button {
|
||||
padding: 0.28rem 0.6rem;
|
||||
color: #1a1206;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.58rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.1rem;
|
||||
text-transform: uppercase;
|
||||
white-space: nowrap;
|
||||
background: var(--gev-guide-accent);
|
||||
border: 1px solid var(--gev-guide-accent);
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
background 140ms ease,
|
||||
color 140ms ease,
|
||||
border-color 140ms ease;
|
||||
}
|
||||
|
||||
.gev-guide-actions button[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.gev-guide-actions button:hover,
|
||||
.gev-guide-actions button:focus-visible {
|
||||
background: #ffb36b;
|
||||
border-color: #ffb36b;
|
||||
}
|
||||
|
||||
/* Secondary buttons: skip a step that waits, or decline the offer. */
|
||||
.gev-guide-actions button.quiet,
|
||||
.gev-guide-actions .gev-guide-skip {
|
||||
color: rgba(214, 220, 226, 0.75);
|
||||
font-weight: 400;
|
||||
background: none;
|
||||
border-color: rgba(214, 220, 226, 0.2);
|
||||
}
|
||||
|
||||
.gev-guide-actions button.quiet:hover,
|
||||
.gev-guide-actions button.quiet:focus-visible,
|
||||
.gev-guide-actions .gev-guide-skip:hover,
|
||||
.gev-guide-actions .gev-guide-skip:focus-visible {
|
||||
color: #fff;
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
border-color: rgba(255, 159, 67, 0.6);
|
||||
}
|
||||
|
||||
@keyframes gev-guide-ping {
|
||||
0% {
|
||||
opacity: 0.9;
|
||||
transform: scale(1);
|
||||
}
|
||||
|
||||
100% {
|
||||
opacity: 0;
|
||||
transform: scale(1.12);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes gev-guide-blink {
|
||||
50% {
|
||||
opacity: 0.3;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes gev-guide-swap {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(3px);
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.gev-guide-ring,
|
||||
.gev-guide-callout,
|
||||
.gev-guide-callout::before {
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.gev-guide-ring > i,
|
||||
.gev-guide-hint-dot,
|
||||
.gev-guide-callout.swap .gev-guide-body {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* The guide's live status: read by screen readers, not shown. */
|
||||
.gev-guide-status {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
margin: -1px;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
clip-path: inset(50%);
|
||||
white-space: nowrap;
|
||||
border: 0;
|
||||
}
|
||||
+57
-21
@@ -318,21 +318,54 @@ body.recording-mode .gev-panel-rail {
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
#right-context-rail #context-missions-view:not([hidden]),
|
||||
#right-context-rail #space-mission-panel-host,
|
||||
#right-context-rail .space-mission-roster {
|
||||
/* Keep the mission cycler directly beneath its Data Layers entry. */
|
||||
[data-layer-id='rocket-launches'] .data-toggle-controls:not([hidden]) {
|
||||
display: grid;
|
||||
grid-template-columns: auto minmax(0, 1fr) auto;
|
||||
gap: 6px;
|
||||
padding: 5px;
|
||||
border: 1px solid var(--glass-border);
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
[data-layer-id='rocket-launches'] .data-toggle-controls-info {
|
||||
grid-column: 2;
|
||||
grid-row: 1;
|
||||
padding-top: 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
[data-layer-id='rocket-launches'] [data-chip-id='next-mission'] {
|
||||
grid-column: 3;
|
||||
grid-row: 1;
|
||||
}
|
||||
|
||||
:root[dir='rtl']
|
||||
[data-layer-id='rocket-launches']
|
||||
.chip-icon
|
||||
.material-symbols-outlined {
|
||||
transform: scaleX(-1);
|
||||
}
|
||||
|
||||
#space-missions-panel {
|
||||
width: min(100%, 330px);
|
||||
min-height: 0;
|
||||
max-height: var(--right-panel-allocated-height, 100%);
|
||||
pointer-events: auto;
|
||||
}
|
||||
#right-context-rail.layout-focus #context-missions-view:not([hidden]),
|
||||
#right-context-rail.layout-focus #space-mission-panel-host,
|
||||
#right-context-rail.layout-focus .space-mission-roster {
|
||||
display: flex;
|
||||
flex: 1 1 auto;
|
||||
flex-direction: column;
|
||||
|
||||
#space-missions-panel[hidden] {
|
||||
display: none;
|
||||
}
|
||||
#right-context-rail.layout-focus .space-mission-roster-list {
|
||||
flex: 1 1 auto;
|
||||
max-height: none;
|
||||
|
||||
.space-missions-panel-inner {
|
||||
max-height: inherit;
|
||||
overflow-y: auto;
|
||||
scrollbar-gutter: stable;
|
||||
}
|
||||
|
||||
#space-missions-panel.collapsed #space-mission-panel-host {
|
||||
display: none;
|
||||
}
|
||||
/* Synchronous intrinsic measurement, independent of focus and allocation.
|
||||
This attribute is not observed by the rail's layout scheduler. */
|
||||
@@ -379,8 +412,6 @@ body.recording-mode .gev-panel-rail {
|
||||
margin-top: 8px;
|
||||
pointer-events: auto;
|
||||
}
|
||||
#space-mission-panel-host:has(#space-mission-panel:not([hidden]))
|
||||
> .context-mode-standby,
|
||||
#space-mission-panel-host:has(#space-mission-panel:not([hidden]))
|
||||
> .space-mission-roster {
|
||||
display: none;
|
||||
@@ -1003,7 +1034,8 @@ body.recording-mode .gev-panel-rail {
|
||||
#global-context-panel .panel-glow {
|
||||
display: none;
|
||||
}
|
||||
.global-context-panel-inner {
|
||||
.global-context-panel-inner,
|
||||
.space-missions-panel-inner {
|
||||
position: relative;
|
||||
display: flex;
|
||||
min-height: 0;
|
||||
@@ -1019,11 +1051,15 @@ body.recording-mode .gev-panel-rail {
|
||||
-webkit-backdrop-filter: blur(24px) saturate(1.4);
|
||||
}
|
||||
|
||||
/* Data Layers and Context share the 14px side padding of the other default
|
||||
theme panels, so every title and toggle sits 19px from its edge. Cyber
|
||||
keeps its own gutters. */
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
:is(.data-panel-inner, .global-context-panel-inner) {
|
||||
/* Data Layers, Context and Space Missions share the 14px side padding of the
|
||||
other default theme panels, so every title and toggle sits 19px from its
|
||||
edge. */
|
||||
:root
|
||||
:is(
|
||||
.data-panel-inner,
|
||||
.global-context-panel-inner,
|
||||
.space-missions-panel-inner
|
||||
) {
|
||||
padding-right: 14px;
|
||||
padding-left: 14px;
|
||||
}
|
||||
@@ -1328,7 +1364,7 @@ body.recording-mode #right-context-rail > [data-panel-id] {
|
||||
}
|
||||
|
||||
/* Draw marks its on state with an accent edge, like an active DISPLAY
|
||||
button; Cyber swaps in its red edge (cyber.css). */
|
||||
button. */
|
||||
#utilities-panel
|
||||
.utilities-tools
|
||||
.pp-toggle-btn:is([aria-pressed='true'], .active) {
|
||||
|
||||
@@ -47,8 +47,8 @@
|
||||
color: var(--text-primary);
|
||||
-webkit-backdrop-filter: blur(22px) saturate(1.3);
|
||||
backdrop-filter: blur(22px) saturate(1.3);
|
||||
/* The blur follows the surface's shape (Cyber's cut corners). The dialog
|
||||
has no outward popups for a clip to hide. */
|
||||
/* The blur follows the surface's shape. The dialog has no outward popups
|
||||
for a clip to hide. */
|
||||
clip-path: var(--panel-surface-frame);
|
||||
}
|
||||
|
||||
@@ -102,14 +102,6 @@
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
:root[data-ui-theme='cyber'] .data-library-stat {
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
:root[data-ui-theme='cyber'] .data-library-stat-value {
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
|
||||
.data-library-intro {
|
||||
margin: 0 0 10px;
|
||||
color: rgba(232, 234, 237, 0.72);
|
||||
@@ -321,21 +313,6 @@
|
||||
font: 10px/1.5 var(--font-mono);
|
||||
}
|
||||
|
||||
:root[data-ui-theme='cyber'] .data-library-dialog {
|
||||
--glass-bg: rgba(18, 24, 27, 0.62);
|
||||
width: min(600px, calc(100vw - 32px));
|
||||
}
|
||||
|
||||
:root[data-ui-theme='cyber'] .data-library-item {
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
:root[data-ui-theme='cyber']
|
||||
:is(.data-library-icon, .data-library-badge--good) {
|
||||
color: var(--cyber-red-bright);
|
||||
border-color: var(--cyber-red-bright);
|
||||
}
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.data-library-stats {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
|
||||
@@ -36,7 +36,8 @@ body.mobile-shell #mobile-tab-bar {
|
||||
left: 0;
|
||||
z-index: 170;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(5, 1fr);
|
||||
grid-auto-flow: column;
|
||||
grid-auto-columns: minmax(0, 1fr);
|
||||
height: var(--mobile-tab-space);
|
||||
padding: 0 max(4px, env(safe-area-inset-right, 0px))
|
||||
var(--mobile-bottom-inset) max(4px, env(safe-area-inset-left, 0px));
|
||||
@@ -62,6 +63,14 @@ body.mobile-shell .mobile-tab {
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
|
||||
/* Long locales clip to one line instead of widening their column. */
|
||||
body.mobile-shell .mobile-tab-label {
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
body.mobile-shell .mobile-tab-icon {
|
||||
font-size: 24px;
|
||||
line-height: 1;
|
||||
@@ -129,6 +138,7 @@ body.mobile-shell #right-context-rail {
|
||||
body.mobile-shell[data-mobile-sheet='layers'] #left-panel-stack,
|
||||
body.mobile-shell[data-mobile-sheet='cameras'] #right-context-rail,
|
||||
body.mobile-shell[data-mobile-sheet='context'] #right-context-rail,
|
||||
body.mobile-shell[data-mobile-sheet='missions'] #right-context-rail,
|
||||
/* Visual opens from the left rail on wider screens, so it lives in the left
|
||||
stack and the More sheet is that stack showing Visual alone. */
|
||||
body.mobile-shell[data-mobile-sheet='more'] #left-panel-stack {
|
||||
@@ -191,6 +201,9 @@ body.mobile-shell[data-mobile-sheet='context']
|
||||
body.mobile-shell[data-mobile-sheet='context']
|
||||
#right-context-rail
|
||||
> #recent-imagery-panel:not([hidden]),
|
||||
body.mobile-shell[data-mobile-sheet='missions']
|
||||
#right-context-rail
|
||||
> #space-missions-panel:not([hidden]),
|
||||
body.mobile-shell[data-mobile-sheet='more'] #left-panel-stack > #pp-toggles {
|
||||
position: relative;
|
||||
inset: auto;
|
||||
|
||||
@@ -94,11 +94,6 @@
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
:root[data-ui-theme='cyber'] .news-panel-inner {
|
||||
border-radius: 0;
|
||||
clip-path: var(--cyber-panel-frame);
|
||||
box-shadow: var(--cyber-panel-shadow);
|
||||
}
|
||||
|
||||
.news-readout {
|
||||
display: flex;
|
||||
|
||||
@@ -0,0 +1,371 @@
|
||||
/* Shared desktop command surface. Mobile and exclusive owners keep their layout. */
|
||||
body:not(.mobile-shell):not(.cockpit-mode):not(.scene-playback-mode):not(
|
||||
.ui-clean-view
|
||||
):not(.recording-mode):where(
|
||||
:has(#gev-omnibar):has(#command-dock > #gev-voice-control)
|
||||
) {
|
||||
--omnibar-dock-width: clamp(400px, 32vw, 460px);
|
||||
--omnibar-dock-bottom: 74px;
|
||||
--omnibar-coordinates-bottom: 4.25rem;
|
||||
--world-timeline-lift: 0px;
|
||||
|
||||
#intel-hud:is([data-variant='tactical'], [data-variant='minimal'])
|
||||
:is(.hud-top-left, .hud-top-right) {
|
||||
top: clamp(92px, 10vh, 112px);
|
||||
}
|
||||
|
||||
#intel-hud:is([data-variant='tactical'], [data-variant='minimal'])
|
||||
.hud-top-left
|
||||
.hud-readout:has(> #hud-mode) {
|
||||
display: none;
|
||||
}
|
||||
#top-center-actions {
|
||||
top: clamp(86px, 9.55vh, 108px);
|
||||
}
|
||||
#left-panel-stack.layout-focus {
|
||||
bottom: var(--left-stack-safe-bottom, 4vh);
|
||||
}
|
||||
|
||||
#world-timeline {
|
||||
bottom: calc(var(--omnibar-dock-bottom) + 66px);
|
||||
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);
|
||||
z-index: 149;
|
||||
width: var(--omnibar-dock-width);
|
||||
max-width: none;
|
||||
height: 56px;
|
||||
min-height: 0;
|
||||
overflow: visible;
|
||||
align-items: center;
|
||||
padding: 0;
|
||||
}
|
||||
#command-dock > #gev-voice-control {
|
||||
box-sizing: border-box;
|
||||
flex: none;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
max-width: none;
|
||||
height: 56px;
|
||||
margin: 0;
|
||||
padding: 0 8px;
|
||||
gap: 0;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
border: 1px solid rgba(120, 220, 255, 0.16);
|
||||
border-radius: 18px;
|
||||
background: linear-gradient(
|
||||
180deg,
|
||||
rgba(16, 28, 36, 0.9),
|
||||
rgba(6, 14, 20, 0.94)
|
||||
);
|
||||
box-shadow:
|
||||
inset 0 1px 0 rgba(200, 245, 255, 0.07),
|
||||
0 12px 32px rgba(0, 0, 0, 0.45);
|
||||
backdrop-filter: none;
|
||||
}
|
||||
&:has(#gev-omnibar:focus-within) #command-dock > #gev-voice-control {
|
||||
border-color: rgba(54, 220, 255, 0.5);
|
||||
box-shadow:
|
||||
0 12px 32px rgba(0, 0, 0, 0.45),
|
||||
0 0 0 3px rgba(54, 220, 255, 0.1);
|
||||
}
|
||||
#command-dock > #gev-voice-control::before,
|
||||
#command-dock > #gev-voice-control::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 16px;
|
||||
bottom: 16px;
|
||||
width: 1px;
|
||||
height: auto;
|
||||
transform: none;
|
||||
background: rgba(120, 220, 255, 0.12);
|
||||
pointer-events: none;
|
||||
}
|
||||
#command-dock > #gev-voice-control::before {
|
||||
inset-inline-start: 54px;
|
||||
inset-inline-end: auto;
|
||||
}
|
||||
#command-dock > #gev-voice-control::after {
|
||||
inset-inline-start: auto;
|
||||
inset-inline-end: 54px;
|
||||
}
|
||||
#gev-voice-control > :is(#gev-voice-button, #gev-chat-button):focus-visible {
|
||||
outline: 2px solid #7bd3ef;
|
||||
outline-offset: 2px;
|
||||
}
|
||||
#gev-voice-control > :is(#gev-voice-button, #gev-chat-button) {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
flex: none;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
min-width: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 1px solid rgba(120, 220, 255, 0.18);
|
||||
border-radius: 50%;
|
||||
background: rgba(5, 17, 24, 0.48);
|
||||
box-shadow:
|
||||
inset 0 2px 4px rgba(0, 0, 0, 0.58),
|
||||
inset 0 -1px 0 rgba(169, 226, 245, 0.12),
|
||||
0 1px 0 rgba(169, 226, 245, 0.1);
|
||||
transform: none;
|
||||
}
|
||||
#gev-voice-control
|
||||
> :is(#gev-voice-button, #gev-chat-button):is(
|
||||
:hover,
|
||||
[aria-pressed='true'],
|
||||
[aria-expanded='true']
|
||||
) {
|
||||
background: rgba(54, 220, 255, 0.14);
|
||||
border-color: rgba(54, 220, 255, 0.6);
|
||||
}
|
||||
#command-dock #gev-voice-control .gev-mic-orbit,
|
||||
#command-dock #gev-chat-button > svg {
|
||||
box-sizing: border-box;
|
||||
width: 19px;
|
||||
height: 19px;
|
||||
padding: 0;
|
||||
background: none;
|
||||
border: 0;
|
||||
box-shadow: none;
|
||||
}
|
||||
#gev-voice-button .gev-mic-orbit img {
|
||||
width: 19px;
|
||||
height: 19px;
|
||||
filter: saturate(0.35) brightness(1.25);
|
||||
}
|
||||
#gev-voice-button .gev-mic-orbit::before,
|
||||
#gev-voice-button .gev-mic-orbit::after {
|
||||
display: none;
|
||||
}
|
||||
#gev-voice-control :is(.gev-mic-label, .gev-chat-label) {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
clip-path: inset(50%);
|
||||
white-space: nowrap;
|
||||
}
|
||||
/* Status remains readable while live; idle meter is decorative. */
|
||||
#command-dock
|
||||
#gev-voice-control:not([data-assistant-mode='voice'])
|
||||
> .gev-voice-visualizer,
|
||||
#command-dock
|
||||
#gev-voice-control:not([data-chat-busy='true'])
|
||||
> .gev-chat-thinking {
|
||||
display: none;
|
||||
}
|
||||
#command-dock #gev-voice-control[data-chat-busy='true'] > .gev-chat-thinking {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
left: 50%;
|
||||
height: 0;
|
||||
transform: translateX(-50%);
|
||||
pointer-events: none;
|
||||
z-index: 151;
|
||||
}
|
||||
#gev-voice-control > .gev-voice-readout {
|
||||
position: absolute;
|
||||
inset-inline: 0;
|
||||
top: auto;
|
||||
bottom: calc(100% + 8px);
|
||||
pointer-events: none;
|
||||
}
|
||||
#gev-voice-control[data-assistant-mode='idle'] > .gev-voice-readout {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
#gev-omnibar {
|
||||
top: auto;
|
||||
bottom: calc(var(--omnibar-dock-bottom) + 11px);
|
||||
left: 50%;
|
||||
width: calc(var(--omnibar-dock-width) - 120px);
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
#gev-omnibar .omnibar-field {
|
||||
height: 34px;
|
||||
padding-inline: 9px 6px;
|
||||
border: 1px solid rgba(151, 213, 231, 0.27);
|
||||
border-radius: 9px;
|
||||
background: rgba(172, 219, 239, 0.07);
|
||||
box-shadow: none;
|
||||
backdrop-filter: none;
|
||||
}
|
||||
#gev-omnibar-input {
|
||||
font-size: 0.86rem;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
#gev-omnibar-input::placeholder {
|
||||
color: #b6cbd4;
|
||||
}
|
||||
#gev-omnibar .omnibar-field:focus-within {
|
||||
border-color: rgba(95, 230, 255, 0.66);
|
||||
background: rgba(109, 206, 232, 0.1);
|
||||
}
|
||||
#gev-omnibar .omnibar-search-icon {
|
||||
color: #a9cfda;
|
||||
}
|
||||
#gev-omnibar :is(.omnibar-mic, .omnibar-edge) {
|
||||
display: none;
|
||||
}
|
||||
#gev-omnibar .omnibar-results {
|
||||
position: absolute;
|
||||
inset-inline: -60px;
|
||||
top: auto;
|
||||
bottom: calc(100% + 11px);
|
||||
max-height: min(
|
||||
360px,
|
||||
max(0px, calc(100dvh - var(--omnibar-dock-bottom) - 144px))
|
||||
);
|
||||
overflow: auto;
|
||||
border-radius: 18px 18px 0 0;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
background: rgba(50, 54, 62, 0.86);
|
||||
backdrop-filter: blur(26px) saturate(1.2);
|
||||
-webkit-backdrop-filter: blur(26px) saturate(1.2);
|
||||
box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45);
|
||||
}
|
||||
&:has(#gev-omnibar.has-results):not(
|
||||
:has(#gev-voice-control[data-assistant-mode='voice'])
|
||||
)
|
||||
#command-dock
|
||||
> #gev-voice-control {
|
||||
border-start-start-radius: 0;
|
||||
border-start-end-radius: 0;
|
||||
}
|
||||
#command-dock
|
||||
#gev-voice-control[data-assistant-mode='voice']
|
||||
> .gev-voice-visualizer {
|
||||
position: absolute;
|
||||
display: block;
|
||||
inset: auto 64px 10px;
|
||||
width: auto;
|
||||
height: 28px;
|
||||
opacity: 1;
|
||||
transform: none;
|
||||
pointer-events: none;
|
||||
}
|
||||
#gev-voice-control > .gev-voice-visualizer > span {
|
||||
display: none;
|
||||
}
|
||||
#gev-voice-control > .gev-voice-visualizer > .gev-voice-wave {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: visible;
|
||||
mask-image: linear-gradient(
|
||||
90deg,
|
||||
transparent,
|
||||
#000 16%,
|
||||
#000 84%,
|
||||
transparent
|
||||
);
|
||||
}
|
||||
.gev-voice-wave path {
|
||||
fill: none;
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
}
|
||||
.gev-voice-wave__main {
|
||||
stroke: #5fe6ff;
|
||||
stroke-width: 2;
|
||||
filter: drop-shadow(0 0 4px rgba(54, 220, 255, 0.55));
|
||||
}
|
||||
.gev-voice-wave__echo {
|
||||
stroke: #36dcff;
|
||||
stroke-width: 1.2;
|
||||
opacity: 0.35;
|
||||
}
|
||||
.gev-voice-wave__soft {
|
||||
stroke: #9ff1ff;
|
||||
stroke-width: 1;
|
||||
opacity: 0.6;
|
||||
}
|
||||
&:has(#gev-voice-control[data-assistant-mode='voice']) #gev-omnibar {
|
||||
.omnibar-field {
|
||||
background: transparent;
|
||||
}
|
||||
:is(input, .omnibar-kbd, .omnibar-search-icon) {
|
||||
visibility: hidden;
|
||||
}
|
||||
/* Suggestions give way to the waveform; an error stays in view. */
|
||||
.omnibar-results:not(.has-feedback),
|
||||
.omnibar-results .omnibar-list {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
#command-dock #gev-voice-control[data-assistant-mode='voice'] {
|
||||
animation: omnibar-listening 2.4s ease-in-out infinite;
|
||||
}
|
||||
}
|
||||
|
||||
/* Desktop uses Omnibar for search and the Visual rail for presets. */
|
||||
#command-dock > :is(#location-bar, #control-panel) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Align the plain credits with Power Up. */
|
||||
:is(#cesium-credits, #gev-credits),
|
||||
&:has(#intel-hud[data-variant='minimal'].active)
|
||||
:is(#cesium-credits, #gev-credits) {
|
||||
bottom: 1rem;
|
||||
}
|
||||
/* 8px above the bottom-right corner row (Power Up and the language picker:
|
||||
32px tall, 14px up), as outside the Omnibar layout. */
|
||||
#intel-hud[data-variant='tactical'] .hud-bottom-right {
|
||||
bottom: 3.375rem;
|
||||
}
|
||||
/* Right to left the attribution row takes the bottom right: the readout
|
||||
clears two lines of it (rail-split.css). */
|
||||
@media (min-width: 1200px) {
|
||||
&:where(html[dir='rtl'] *)
|
||||
#intel-hud[data-variant='tactical']
|
||||
.hud-bottom-right {
|
||||
bottom: calc(3.375rem + 1.5rem);
|
||||
}
|
||||
}
|
||||
#intel-hud:is([data-variant='tactical'], [data-variant='minimal'])
|
||||
.hud-bottom-left {
|
||||
bottom: var(--omnibar-coordinates-bottom);
|
||||
}
|
||||
&:not(.context-docked):has(#intel-hud[data-variant='minimal'].active)
|
||||
#right-context-rail {
|
||||
--omnibar-minimal-rail-height: min(
|
||||
var(--right-stack-max-height, 70vh),
|
||||
calc(
|
||||
100dvh - var(--right-stack-safe-top, 26vh) -
|
||||
var(--omnibar-coordinates-bottom) - 3.1rem - 1.2vh
|
||||
)
|
||||
);
|
||||
max-height: var(--omnibar-minimal-rail-height);
|
||||
> [data-panel-id]:not(.collapsed) {
|
||||
max-height: var(--omnibar-minimal-rail-height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes omnibar-listening {
|
||||
0%,
|
||||
100% {
|
||||
border-color: rgba(54, 220, 255, 0.35);
|
||||
}
|
||||
50% {
|
||||
border-color: rgba(54, 220, 255, 0.75);
|
||||
}
|
||||
}
|
||||
@@ -329,7 +329,7 @@
|
||||
:root[data-scope-mask='off']
|
||||
#intel-hud:is([data-variant='minimal'], [data-variant='tactical'])
|
||||
.hud-readout,
|
||||
:root[data-scope-mask='off']:not([data-ui-theme='cyber']) .scene-text-holdout {
|
||||
:root[data-scope-mask='off'] .scene-text-holdout {
|
||||
background: rgba(0, 0, 0, 0.7);
|
||||
box-shadow: none;
|
||||
border-radius: 2px;
|
||||
@@ -357,9 +357,7 @@
|
||||
#intel-hud:is([data-variant='minimal'], [data-variant='tactical'])
|
||||
:is(.hud-top-right, .hud-bottom-right)
|
||||
.hud-readout,
|
||||
:root[data-scope-mask='off']:not([data-ui-theme='cyber'])
|
||||
#style-indicator
|
||||
.scene-text-holdout {
|
||||
:root[data-scope-mask='off'] #style-indicator .scene-text-holdout {
|
||||
margin-inline-start: auto;
|
||||
}
|
||||
|
||||
@@ -399,9 +397,7 @@
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
:root[data-scope-mask='off']:not([data-ui-theme='cyber'])
|
||||
#title-bar
|
||||
h1::before {
|
||||
:root[data-scope-mask='off'] #title-bar h1::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: -0.12em -6px;
|
||||
@@ -410,18 +406,16 @@
|
||||
background: rgba(0, 0, 0, 0.7);
|
||||
}
|
||||
|
||||
:root[data-scope-mask='off']:not([data-ui-theme='cyber'])
|
||||
:root[data-scope-mask='off']
|
||||
:is(#title-bar .subtitle, #style-indicator .indicator-label) {
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
:root[data-scope-mask='off']:not([data-ui-theme='cyber']) #title-bar .subtitle {
|
||||
:root[data-scope-mask='off'] #title-bar .subtitle {
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
:root[data-scope-mask='off']:not([data-ui-theme='cyber'])
|
||||
#style-indicator
|
||||
.indicator-value {
|
||||
:root[data-scope-mask='off'] #style-indicator .indicator-value {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
@@ -431,8 +425,6 @@
|
||||
display: none;
|
||||
}
|
||||
|
||||
:root[data-scope-mask='off']:not([data-ui-theme='cyber'])
|
||||
#title-bar
|
||||
.frame-rate-readout {
|
||||
:root[data-scope-mask='off'] #title-bar .frame-rate-readout {
|
||||
margin-top: 6px;
|
||||
}
|
||||
@@ -42,23 +42,6 @@
|
||||
--panel-surface-collapsed-width: var(--left-collapsed-width);
|
||||
}
|
||||
|
||||
:root[data-ui-theme='cyber'] {
|
||||
--panel-surface-font: var(--font-mono);
|
||||
--panel-surface-detail: var(--cyber-panel-surface-detail);
|
||||
--panel-surface-frame: var(--cyber-panel-frame);
|
||||
--panel-surface-shadow: var(--cyber-panel-shadow);
|
||||
--panel-surface-title: var(--cyber-red-bright);
|
||||
--panel-surface-error: var(--cyber-red-bright);
|
||||
--panel-surface-width: var(--cyber-panel-width);
|
||||
--panel-surface-collapsed-width: var(--cyber-panel-collapsed-width);
|
||||
}
|
||||
|
||||
:root[data-ui-theme='cyber']
|
||||
#right-context-rail
|
||||
> [data-panel-id]:has(> [data-panel-surface]) {
|
||||
--panel-surface-width: var(--cyber-right-panel-width);
|
||||
}
|
||||
|
||||
:is([data-panel-surface], [data-panel-popup]) {
|
||||
isolation: isolate;
|
||||
min-width: 0;
|
||||
|
||||
@@ -104,8 +104,8 @@
|
||||
|
||||
/* In clean view the screen-edge gutters stay empty: the HUD's vertical edge
|
||||
readouts (ONA / COLL on the left, BAND / BITS / LVL on the right) are not
|
||||
shown. Cyber lays its HUD out differently and keeps them. */
|
||||
:root:not([data-ui-theme='cyber']) body.ui-clean-view #intel-hud .hud-edge {
|
||||
shown. */
|
||||
:root body.ui-clean-view #intel-hud .hud-edge {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
@@ -116,9 +116,49 @@
|
||||
bottom: calc(2vh + 6.5rem - 26px);
|
||||
}
|
||||
|
||||
/* From 1200px the dock sits 74px up (command-dock.css) and clears both
|
||||
corners, which are at most ~340px wide beside a ~500px dock. The readout
|
||||
sits 8px above the bottom-right corner row (Power Up and the language
|
||||
picker: 32px tall, 14px up) and the coordinates start level with it. The
|
||||
World Timeline sits on the dock's floor between the corners (44rem
|
||||
narrower than the screen), so the corners stay put while it shows. */
|
||||
@media (min-width: 1200px) {
|
||||
#intel-hud[data-variant='tactical'] .hud-bottom-right {
|
||||
bottom: calc(4.2rem - 26px);
|
||||
bottom: 3.375rem;
|
||||
}
|
||||
|
||||
/* Right to left the attribution row takes the bottom right
|
||||
(command-dock-trays.css): the readout clears two lines of it. */
|
||||
html[dir='rtl'] #intel-hud[data-variant='tactical'] .hud-bottom-right {
|
||||
bottom: calc(3.375rem + 1.5rem);
|
||||
}
|
||||
|
||||
#intel-hud:is([data-variant='tactical'], [data-variant='minimal'])
|
||||
.hud-bottom-left,
|
||||
:root[data-scope-mask='off']
|
||||
#intel-hud[data-variant='minimal']
|
||||
.hud-bottom-left {
|
||||
bottom: calc(3.375rem + 26px);
|
||||
}
|
||||
|
||||
#world-timeline {
|
||||
width: min(820px, calc(100vw - 44rem));
|
||||
}
|
||||
|
||||
/* The raised dock is 74px - 2vh higher than the bottom-edge dock these
|
||||
height budgets were written for. Toasts keep 12px above the 62px dock. */
|
||||
#gev-voice-control .gev-voice-panel {
|
||||
max-height: min(
|
||||
28rem,
|
||||
max(
|
||||
7.5rem,
|
||||
calc(100dvh - 12rem - 74px + 2vh - var(--gev-provider-lift, 0px))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
body:not(.ui-clean-view):not(.recording-mode):not(.cockpit-mode) #toast {
|
||||
bottom: calc(148px + var(--world-timeline-lift, 0px));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loaded 100 of 1337 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user