Merge upstream main into denis/rail-layer

This commit is contained in:
Denis Groshev committed 2026-11-11 18:02:52 +01:00
commit 13818d0b9f
87 files changed
+7438 -144

No files matched your search

+24 -2
View File
@@ -4,7 +4,11 @@ import { ShellFacade } from './shellFacade.js';
import { AircraftDisplay } from './aircraftDisplay.js';
import { LayerBindings } from './layerBindings.js';
import { PanelChrome } from './panelChrome.js';
import { initMobileShell } from './mobileShell.js';
import {
initMobileShell,
MOBILE_SHELL_MEDIA_QUERY,
sheetForPanelId,
} from './mobileShell.js';
import { VisualSettings } from './visualSettings.js';
import { NavigationController } from './navigationController.js';
import { ShareRestoration } from './shareRestoration.js';
@@ -1143,6 +1147,7 @@ export class StyleManager extends ShellFacade {
this._dataManager?.setLayerParams('street-level', params, options),
setPanelCollapsed: (collapsed, options) =>
this.setPanelCollapsed('street-level-panel', collapsed, options),
revealPanel: () => this.revealPanel('street-level-panel'),
showToast: (message) => this._showToast(message),
// Lets the panel open for a user, voice or tool switch-on, not a restore.
subscribeEnableRequests: (listener) =>
@@ -1258,6 +1263,20 @@ export class StyleManager extends ShellFacade {
return this._panelChrome.setPanelCollapsed(...arguments);
}
/**
* Bring a panel into view on a phone, where the rails show only as tab
* sheets: opens the sheet that holds it. Does nothing above 720px.
* @param {string} panelId - DOM id of the panel.
* @returns {void}
*/
revealPanel(panelId) {
const sheet = sheetForPanelId(panelId);
if (!globalThis.matchMedia?.(MOBILE_SHELL_MEDIA_QUERY)?.matches) return;
if (sheet) this._mobileShell?.setSheet(sheet);
// The sheet opens at its top; a panel lower in the rail is scrolled to.
document.getElementById(panelId)?.scrollIntoView?.({ block: 'nearest' });
}
/**
* Toggles "clean view" mode which hides all UI panels via a CSS body class.
* @param {boolean} [forceEnabled] - Explicit on/off. Omit to toggle.
@@ -1364,9 +1383,12 @@ export class StyleManager extends ShellFacade {
};
}
if (!target.available) {
// The controller knows why (Google 3D: no Maps key; others: no ion token).
return {
ok: false,
error: `${target.label} requires a Cesium ion token`,
error:
target.unavailableReason ||
`${target.label} requires a Cesium ion token`,
activeStack: this.mapStackController.getActiveId(),
};
}
+38
View File
@@ -0,0 +1,38 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { StyleManager } from './applicationShell.js';
function reveal({ phone }) {
const sheets = [];
const scrolls = [];
const panel = { scrollIntoView: (options) => scrolls.push(options) };
const saved = globalThis.document;
const savedMatchMedia = globalThis.matchMedia;
globalThis.document = {
getElementById: (id) => (id === 'street-level-panel' ? panel : null),
};
globalThis.matchMedia = (query) => ({
matches: phone && query === '(max-width: 720px)',
});
try {
StyleManager.prototype.revealPanel.call(
{ _mobileShell: { setSheet: (sheet) => sheets.push(sheet) } },
'street-level-panel',
);
} finally {
globalThis.document = saved;
globalThis.matchMedia = savedMatchMedia;
}
return { sheets, scrolls };
}
test('revealing a panel opens its phone sheet and scrolls the panel into view', () => {
const { sheets, scrolls } = reveal({ phone: true });
assert.deepEqual(sheets, ['cameras']);
// The panel sits below the sheet's first screen at 375×812.
assert.deepEqual(scrolls, [{ block: 'nearest' }]);
});
test('revealing a panel above 720px neither opens a sheet nor scrolls the rail', () => {
assert.deepEqual(reveal({ phone: false }), { sheets: [], scrolls: [] });
});
+33
View File
@@ -0,0 +1,33 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { StyleManager } from './applicationShell.js';
test('an unavailable map stack reports the controller’s own reason, not always an ion token', async () => {
const controller = {
getStacks: () => [
{
id: 'photoreal',
label: 'Google 3D',
available: false,
unavailableReason: 'Google 3D needs GOOGLE_MAPS_API_KEY',
},
{ id: 'bing-aerial', label: 'Bing aerial', available: false },
],
getActiveId: () => 'osm',
};
const shell = { mapStackController: controller };
const photoreal = await StyleManager.prototype.setMapStack.call(
shell,
'photoreal',
);
assert.deepEqual(photoreal, {
ok: false,
error: 'Google 3D needs GOOGLE_MAPS_API_KEY',
activeStack: 'osm',
});
const bing = await StyleManager.prototype.setMapStack.call(
shell,
'bing-aerial',
);
assert.equal(bing.error, 'Bing aerial requires a Cesium ion token');
});
+3 -1
View File
@@ -317,7 +317,9 @@ export class ShareRestoration {
// the shared flight having landed.
const vessel = this._sharedVessel(state);
if (vessel) void this._restoreSharedVessel(vessel, current);
settle({ status: 'settled', share, layers, tracking });
// The token tells listeners whether anyone navigated after the
// restore's flight landed (while the layers were still loading).
settle({ status: 'settled', share, layers, tracking, navigationToken });
} catch (error) {
if (!current()) return;
this.shareLinkManager.completeInitialRestore(state.restoreToken);
+9
View File
@@ -19,6 +19,8 @@ export const useStreetLevelStore = defineStore('gev-street-level', () => {
const expanded = shallowRef(null);
/** False on a page with neither element fullscreen nor popovers. */
const expandAvailable = shallowRef(true);
/** Whether the photo is shown over the globe on an embedded page. */
const embedOverlay = shallowRef(false);
/** @type {{handlers: StreetLevelHandlers}|null} */
let owner = null;
@@ -47,6 +49,11 @@ export const useStreetLevelStore = defineStore('gev-street-level', () => {
expandAvailable.value = Boolean(available);
}
/** @param {boolean} on */
function setEmbedOverlay(on) {
embedOverlay.value = Boolean(on);
}
/**
* Stop forwarding actions to the owner holding `token`. The panel keeps
* its last render, as the page did when its controls were wired by hand.
@@ -69,10 +76,12 @@ export const useStreetLevelStore = defineStore('gev-street-level', () => {
view,
expanded,
expandAvailable,
embedOverlay,
attach,
publish,
setExpanded,
setExpandAvailable,
setEmbedOverlay,
detach,
act,
describeSinceStop,
+56 -2
View File
@@ -11,6 +11,11 @@ const RENDER_MODE_KEY = 'gev:street-level:render-mode';
/** <body> classes of the modes that hide every panel; an expanded photo leaves with them. */
const PANEL_HIDING_MODES = ['ui-clean-view', 'recording-mode', 'cockpit-mode'];
/** True on an embedded page (`?embed=1` or the inline panel). */
function isEmbedPage() {
return globalThis.document?.body?.classList?.contains('ui-embed') === true;
}
/**
* Drives the Street Level panel body: provider chips, filters and viewer.
* The panel view renders what this presents (`gev-street-level` store); the
@@ -137,6 +142,15 @@ export class StreetLevelControls {
});
}
this.store.setExpandAvailable(Boolean(this._expandMode));
// Embed mode: Esc closes an open photo, since the rail it would go back to
// is hidden. Full screen keeps its own Esc (above), which leaves it first.
this.listen(document, 'keydown', (event) => {
if (event.key !== 'Escape' || !this._embedHome || this.isViewerExpanded())
return;
event.preventDefault();
event.stopPropagation();
this.layer.closeViewer?.();
});
try {
const stored = localStorage.getItem(RENDER_MODE_KEY);
if (stored === 'fill' || stored === 'letterbox')
@@ -271,8 +285,16 @@ export class StreetLevelControls {
this._modesObserver = null;
return;
}
// Embed mode keeps Clean View on for its globe while the photo is lifted
// over it: there only recording and the cockpit end EXPAND.
const leaveIfHiding = () => {
if (PANEL_HIDING_MODES.some((mode) => body.classList.contains(mode)))
if (
PANEL_HIDING_MODES.some(
(mode) =>
body.classList.contains(mode) &&
!(mode === 'ui-clean-view' && isEmbedPage()),
)
)
this._exitExpanded();
};
if (!this._modesObserver && typeof MutationObserver === 'function') {
@@ -293,6 +315,31 @@ export class StreetLevelControls {
this._requestResize();
}
/**
* Embed mode hides the right rail: an open photo moves to <body> as an
* overlay on the globe (`sl-viewer-wrap-embed`, embed.css) and goes back
* when it closes. Vue keeps patching the wrap there: its siblings are static.
*/
_syncEmbedOverlay(open) {
const wrap = this._elements.viewerWrap;
if (!wrap || !document.body) return;
const lift = open === true && isEmbedPage();
this.store.setEmbedOverlay(lift);
if (lift && !this._embedHome) {
this._embedHome = { parent: wrap.parentNode, next: wrap.nextSibling };
document.body.appendChild(wrap);
wrap.classList.add('sl-viewer-wrap-embed');
this._requestResize();
} else if (!lift && this._embedHome) {
wrap.classList.remove('sl-viewer-wrap-embed');
const { parent, next } = this._embedHome;
this._embedHome = null;
if (parent?.isConnected)
parent.insertBefore(wrap, next?.parentNode === parent ? next : null);
this._requestResize();
}
}
connect() {
this._unsubscribe?.();
this._unsubscribe = null;
@@ -348,8 +395,14 @@ export class StreetLevelControls {
// Other size changes reach the viewer through the ResizeObserver; opening
// asks for one resize because the element may not have a size yet.
const open = view.viewer.open;
if (open && !this._wasOpen) this.setCollapsed(false, { persist: false });
if (open && !this._wasOpen) {
this.setCollapsed(false, { persist: false });
// A phone shows the rail only as a tab sheet: open it, or the photo
// loads where nobody sees it. Embed mode lifts the photo instead.
if (!isEmbedPage()) this.actions.revealPanel?.();
}
this._wasOpen = open;
this._syncEmbedOverlay(open);
}
destroy() {
@@ -362,6 +415,7 @@ export class StreetLevelControls {
if (this._expandMode === 'popover')
this._elements.viewerWrap?.removeAttribute('popover');
this._watchPanelHidingModes(false);
this._syncEmbedOverlay(false);
this.listeners.abort();
this._resizeObserver?.disconnect();
this._resizeObserver = null;
+180
View File
@@ -622,6 +622,36 @@ for (const mode of ['ui-clean-view', 'recording-mode', 'cockpit-mode'])
}
}));
test('in embed mode, which keeps Clean View on for its globe, EXPAND stays; the cockpit still ends it', () =>
withDom(async (dom) => {
const saved = globalThis.MutationObserver;
const watch = fakeMutationObserver();
globalThis.MutationObserver = watch.FakeObserver;
try {
dom.document.body.classList.add('ui-embed');
dom.document.body.classList.add('ui-clean-view');
const { layer, controls } = await stubPanel(
dom,
uiState({ open: false }),
);
await layer.publish(uiState({ open: true }));
dom.document.querySelector('#sl-viewer-expand').click();
await settle();
await settle();
watch.fire();
await settle();
assert.equal(controls.isViewerExpanded(), true, 'EXPAND stays open');
dom.document.body.classList.toggle('cockpit-mode', true);
watch.fire();
await settle();
await settle();
assert.equal(controls.isViewerExpanded(), false);
controls.destroy();
} finally {
globalThis.MutationObserver = saved;
}
}));
/* ── Restores and keyboard rules ───────────────────────────────────────── */
test('only an explicit switch-on opens the panel, unstored; a restore never does (P2-1)', () =>
@@ -921,3 +951,153 @@ test('a window changed elsewhere under a focused SINCE thumb leaves its readout
assert.equal(since.getAttribute('aria-valuetext'), label());
controls.destroy();
}));
/** In embed mode, the viewer moved out of the hidden rail onto the globe. */
const overGlobe = (dom) =>
dom.wrap.parentNode === dom.document.body &&
dom.wrap.classList.contains('sl-viewer-wrap-embed');
const escape = () =>
document.dispatchEvent(
new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }),
);
test('in embed mode an open photo leaves the hidden rail for an overlay on the globe, and goes back when it closes', () =>
withDom(async (dom) => {
dom.document.body.classList.add('ui-embed');
const home = dom.wrap.parentNode;
const after = dom.wrap.nextSibling;
const { layer, controls } = await stubPanel(dom, uiState({ open: false }));
assert.equal(overGlobe(dom), false, 'nothing to show yet');
await layer.publish(uiState({ open: true }));
assert.equal(overGlobe(dom), true, 'shown over the globe');
assert.equal(dom.wrap.hidden, false, 'the panel view still renders it');
await layer.publish(uiState({ open: true, renderMode: 'fill' }));
assert.equal(overGlobe(dom), true, 'an update keeps it there');
assert.equal(
dom.wrap.querySelector('[aria-checked="true"]')?.textContent.trim(),
'FILL',
'and the panel view keeps patching it there',
);
await layer.publish(uiState({ open: false }));
assert.equal(overGlobe(dom), false);
assertSameNode(dom.wrap.parentNode, home, 'back in the panel');
assertSameNode(dom.wrap.nextSibling, after, 'in its own place');
assert.equal(dom.wrap.hidden, true);
controls.destroy();
}));
test('outside embed mode a photo stays in the panel', () =>
withDom(async (dom) => {
const home = dom.wrap.parentNode;
const { layer, controls } = await stubPanel(dom, uiState({ open: false }));
await layer.publish(uiState({ open: true }));
assert.equal(overGlobe(dom), false);
assertSameNode(dom.wrap.parentNode, home);
controls.destroy();
}));
test('an opening photo brings its panel into view (a phone’s tab sheet); embed mode lifts it instead', () =>
withDom(async (dom) => {
const revealed = [];
const { layer, controls } = await stubPanel(dom, uiState({ open: false }), {
revealPanel: () => revealed.push('street-level'),
});
await layer.publish(uiState({ open: true }));
assert.deepEqual(revealed, ['street-level'], 'once, as it opens');
await layer.publish(uiState({ open: true, renderMode: 'fill' }));
assert.equal(revealed.length, 1, 'not on every update');
await layer.publish(uiState({ open: false }));
dom.document.body.classList.add('ui-embed');
await layer.publish(uiState({ open: true }));
assert.equal(revealed.length, 1, 'embed mode shows it over the globe');
controls.destroy();
}));
test('in embed mode Esc closes the photo, and the next photo is shown over the globe again', () =>
withDom(async (dom) => {
dom.document.body.classList.add('ui-embed');
const { layer, controls } = await stubPanel(dom, uiState({ open: false }));
let closed = 0;
layer.closeViewer = () => {
closed++;
layer.publish(uiState({ open: false }));
};
await layer.publish(uiState({ open: true }));
escape();
await nextTick();
assert.equal(closed, 1, 'Esc closed the photo');
assert.equal(overGlobe(dom), false);
await layer.publish(uiState({ open: true }));
assert.equal(overGlobe(dom), true, 'the next photo is shown');
controls.destroy();
}));
test('in embed mode Esc in full screen leaves full screen and keeps the photo', () =>
withDom(async (dom) => {
dom.document.body.classList.add('ui-embed');
const { layer, controls } = await stubPanel(dom, uiState({ open: false }));
let closed = 0;
layer.closeViewer = () => closed++;
await layer.publish(uiState({ open: true }));
await dom.wrap.requestFullscreen();
await settle();
assert.equal(controls.isViewerExpanded(), true);
escape();
assert.equal(closed, 0, 'the photo stays open');
controls.destroy();
}));
test('outside embed mode Esc does not close a photo in the panel', () =>
withDom(async (dom) => {
const { layer, controls } = await stubPanel(dom, uiState({ open: true }));
let closed = 0;
layer.closeViewer = () => closed++;
escape();
assert.equal(closed, 0);
controls.destroy();
}));
test('destroying the panel in embed mode puts an open photo back in the panel', () =>
withDom(async (dom) => {
dom.document.body.classList.add('ui-embed');
const home = dom.wrap.parentNode;
const { layer, controls } = await stubPanel(dom, uiState({ open: false }));
await layer.publish(uiState({ open: true }));
controls.destroy();
assert.equal(overGlobe(dom), false);
assertSameNode(dom.wrap.parentNode, home);
}));
test('an embedded photo failure is shown inside the overlay, and only there', () =>
withDom(async (dom) => {
dom.document.body.classList.add('ui-embed');
const { layer, controls } = await stubPanel(dom, uiState({ open: false }));
const failed = uiState({ open: true });
Object.assign(failed.street, {
imageId: null,
error: 'Image could not be opened',
});
await layer.publish(failed);
assert.equal(overGlobe(dom), true);
const error = dom.wrap.querySelector('#sl-viewer-error');
assert.ok(error, 'the overlay contains an error region');
assert.equal(error.hidden, false);
assert.match(error.textContent, /Image could not be opened/);
assert.equal(dom.root.querySelector('#sl-error').hidden, true);
await layer.publish(uiState({ open: true }));
assert.equal(error.hidden, true, 'a successful retry clears the error');
controls.destroy();
}));
test('outside embed mode a photo failure stays in the panel error region', () =>
withDom(async (dom) => {
const failed = uiState({ open: true });
failed.street.error = 'Image could not be opened';
const { controls } = await stubPanel(dom, failed);
const error = dom.wrap.querySelector('#sl-viewer-error');
assert.ok(error);
assert.equal(error.hidden, true, 'no duplicate error inside the photo');
assert.equal(dom.root.querySelector('#sl-error').hidden, false);
controls.destroy();
}));
+24
View File
@@ -13,3 +13,27 @@ body.ui-embed #world-overlay-actions,
body.ui-embed #view-switcher {
display: none !important;
}
/* Street-level photos: the rail that holds the panel is hidden here, so an
open photo shows over the globe (streetLevelControls moves the viewer). */
body.ui-embed .sl-viewer-wrap-embed {
position: fixed;
inset: 12px;
z-index: 1000;
}
/* Cockpit, recording and scene playback own the screen, as they hide the
panel elsewhere: the lifted photo steps out of their way. */
body.ui-embed.cockpit-mode .sl-viewer-wrap-embed,
body.ui-embed.recording-mode .sl-viewer-wrap-embed,
body.ui-embed.scene-playback-mode .sl-viewer-wrap-embed {
display: none;
}
body.ui-embed .sl-viewer-wrap-embed .sl-viewer-stage,
body.ui-embed .sl-viewer-wrap-embed .sl-viewer {
flex: 1 1 auto;
height: auto;
min-height: 0;
aspect-ratio: auto;
}
+3 -2
View File
@@ -13,7 +13,7 @@ import UiSlider from '../../kit/UiSlider.js';
// Until it renders, the panel shows its initial markup. The viewer element
// belongs to the layer and EXPAND to the controls.
const store = useStreetLevelStore();
const { view, expanded, expandAvailable } = storeToRefs(store);
const { view, expanded, expandAvailable, embedOverlay } = storeToRefs(store);
const status = computed(
() =>
@@ -142,6 +142,7 @@ const vThumb = {
<button id="sl-viewer-close" class="sl-viewer-x" type="button" :title="t('Close the image and deselect it on the map')" :aria-label="t('Close the street-level image')">×</button>
</div>
</div>
<div id="sl-viewer-error" class="sl-error" role="alert" :hidden="!(embedOverlay || expanded) || !view?.error"><span aria-hidden="true">⚠</span> {{ view?.error || '' }}</div>
<div class="sl-viewer-stage">
<div id="sl-viewer-placeholder" class="sl-viewer-placeholder" :hidden="!viewer.loading"></div>
<div id="sl-viewer" class="sl-viewer" :aria-label="t('Street-level viewer')"></div>
@@ -158,7 +159,7 @@ const vThumb = {
<span class="cctv-summary-label">{{ t('PROVIDERS') }}</span>
<div id="sl-provider-chips" class="sl-chips"><RailChips :chips="view ? view.providers : []" /></div>
</div>
<div id="sl-error" class="sl-error" role="alert" :hidden="!view?.error"><span aria-hidden="true">⚠</span> <span id="sl-error-text">{{ view?.error || '' }}</span></div>
<div id="sl-error" class="sl-error" role="alert" :hidden="embedOverlay || expanded || !view?.error"><span aria-hidden="true">⚠</span> <span id="sl-error-text">{{ view?.error || '' }}</span></div>
<!-- A missing key gates the filters only: the chips above stay
focusable so their tooltip can say how to add the key. -->
<fieldset id="sl-controls" class="sl-controls" :disabled="Boolean(view?.controlsDisabled)" :hidden="!shows.pano && !shows.since">