Merge main and switch Cesium and Navara in place through Vue

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

No files matched your search

+66 -29
View File
@@ -1,15 +1,3 @@
import { DisplayBindings } from './ui/displayBindings.js';
import { LocationNavigation } from './ui/locationNavigation.js';
import { VisualSettings } from './ui/visualSettings.js';
import { readShellSource, shellMethod } from './testSupport/readShellSource.mjs';
import { StyleManager } from './ui/applicationShell.js';
import { _claimContextVisualAuthority, setContextMode } from './ui/contextActions.js';
import { _initGlobalContextPanel } from './ui/contextBindings.js';
import { test } from 'node:test';
import assert from 'node:assert/strict';
import fs from 'node:fs';
import { ShareLinkManager, decodeShareCreatedAtMs } from './sharelink.js';
import { createDefaultLayerState } from './data/layerState.js';
import { createFakeEngine } from './globe/testing/fakeEngine.js';
/**
* A globe engine standing in for the viewer double this test used to build:
@@ -35,6 +23,23 @@ function engineViewer({ camera = {}, scene = {} } = {}) {
}
import { DisplayBindings } from './ui/displayBindings.js';
import { LocationNavigation } from './ui/locationNavigation.js';
import { VisualSettings } from './ui/visualSettings.js';
import { readShellSource, shellMethod } from './testSupport/readShellSource.mjs';
import { _claimContextVisualAuthority, setContextMode } from './ui/contextActions.js';
import { _initGlobalContextPanel } from './ui/contextBindings.js';
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { ShareLinkManager, decodeShareCreatedAtMs } from './sharelink.js';
import { createDefaultLayerState } from './data/layerState.js';
import { parseSharePath } from './share/shareLinkPath.js';
import { decodeShareView } from './share/viewCodec.js';
/** The decoded view of a copied `/share/<code>` link. */
const sharedState = (href) =>
decodeShareView(parseSharePath(new URL(href).pathname).code).state;
const uiSource = readShellSource();
function sourceBlock(start, end) {
@@ -125,6 +130,22 @@ test('Nepal locator token is valid in v2 share links', () => {
assert.equal(parsed.layerStateInvalid, false);
});
test('scope feather above 100% survives share parsing and serialization', () => {
const manager = makeManager('#v=2&lat=10&lon=20&sc=0&scf=200');
const parsed = manager.parseInitialHash();
assert.equal(parsed.scopeEnabled, false);
assert.equal(parsed.scopeFeatherPct, 200);
assert.equal(makeManager('#lat=10&lon=20&scf=175').parseInitialHash().scopeFeatherPct, 175);
assert.equal(makeManager('#lat=10&lon=20&scf=999').parseInitialHash().scopeFeatherPct, 200);
manager.onToggleChange(false, true, { scopeEnabled: false, scopeFeatherPct: 200 });
const params = manager._buildHashParams();
assert.equal(params.get('sc'), '0');
assert.equal(params.get('scf'), '200');
manager.onToggleChange(false, true, { scopeFeatherPct: 999 });
assert.equal(manager._buildHashParams().get('scf'), '200');
clearTimeout(manager._debounceTimer);
});
test('share-link serialization emits the current celestial state', () => {
const manager = makeManager();
manager.onToggleChange(false, false, { celestialRingEnabled: false });
@@ -320,8 +341,8 @@ test('copy adds a fresh ephemeral timestamp without aging the live URL', async (
assert.equal(await manager.copyLink({ nowMs: 2_000_000 }), true);
assert.equal(await manager.copyLink({ nowMs: 2_002_000 }), true);
assert.equal(new URL(copied[0]).hash.includes('at=2000'), true);
assert.equal(new URL(copied[1]).hash.includes('at=2002'), true);
assert.equal(sharedState(copied[0]).sharedAtMs, 2_000_000);
assert.equal(sharedState(copied[1]).sharedAtMs, 2_002_000);
assert.equal(window.location.hash, liveHash);
assert.equal(new URLSearchParams(window.location.hash.slice(1)).has('at'), false);
});
@@ -333,8 +354,7 @@ test('copy snapshots current state while incoming hash writes are still suppress
manager.parseInitialHash();
assert.equal(manager._initialRestorePending, true);
assert.equal(await manager.copyLink({ nowMs: 3_000_000 }), true);
const params = new URL(copied).hash.slice(1);
assert.equal(new URLSearchParams(params).get('at'), '3000');
assert.equal(sharedState(copied).sharedAtMs, 3_000_000);
assert.equal(window.location.hash, '#v=2&lat=10&lon=20&l=e&at=100');
});
@@ -524,14 +544,14 @@ test('every explicit visual UI gesture claims restore authority before it mutate
['cycleDetection: () => {', 'toggleCctv: () =>', 'cycleDetectionMode()', 'detection hotkey'],
['toggleBloom:', 'setBloomIntensity:', 'this._setBloomEnabled(', 'toggleBloom control'],
['setBloomIntensity:', 'toggleSharpen:', 'this._setBloomIntensity(', 'setBloomIntensity control'],
['toggleSharpen:', 'toggleScope:', 'this._setSharpenEnabled(', 'toggleSharpen control'],
['toggleScope:', 'setScopeFeather:', 'setScopeMaskEnabled(', 'toggleScope control'],
['setScopeFeather:', 'setSharpenIntensity:', 'setScopeMaskFeather(', 'setScopeFeather control'],
['setSharpenIntensity:', 'setHudLayout:', 'this._applySharpenIntensity(', 'setSharpenIntensity control'],
['toggleSharpen:', 'setScopeEnabled:', 'this._setSharpenEnabled(', 'toggleSharpen control'],
['setScopeEnabled:', 'setScopeFeather:', 'this._setScope(', 'setScopeEnabled control'],
['setScopeFeather:', 'setSharpenIntensity:', 'this._setScope(', 'setScopeFeather control'],
['setSharpenIntensity:', 'setHudLayout:', 'this._setSharpenIntensity(', 'setSharpenIntensity control'],
['setHudLayout:', 'toggleCleanView:', 'this._setHudVariant(', 'setHudLayout control'],
['setDensity:', 'setAllocation:', 'this._applyDetectionDensityFromUi()', 'setDensity control'],
['setDensity:', 'setAllocation:', 'this._setDetectionDensity(', 'setDensity control'],
['setAllocation:', 'setFade:', 'this._setDetectionAllocation(', 'setAllocation control'],
['setFade:', 'toggleCelestial:', 'this._applyDetectionFadeFromUi()', 'setFade control'],
['setFade:', 'toggleCelestial:', 'this._setDetectionFade(', 'setFade control'],
];
for (const [start, end, mutation, label] of gestureRoutes) {
const startIndex = initUi.indexOf(start);
@@ -540,7 +560,7 @@ test('every explicit visual UI gesture claims restore authority before it mutate
assertClaimsBefore(initUi.slice(startIndex, endIndex), mutation, label);
}
const displayActions = initUi.slice(initUi.indexOf('this._displayControls ='));
const displayActions = initUi.slice(initUi.indexOf('const token = store.connect('));
assertClaimsBefore(displayActions.slice(displayActions.indexOf('toggleHud:'), displayActions.indexOf('cycleDetection:')), 'this.hud.toggle()', 'HUD button');
assertClaimsBefore(displayActions.slice(displayActions.indexOf('cycleDetection:'), displayActions.indexOf('toggleModels:')), 'cycleDetectionMode()', 'detection button');
@@ -637,7 +657,7 @@ test('every explicit visual control facade claims restore authority before mutat
[' setHudLayout(variantName) {', ' getDetectionState() {', 'this._setHudVariant(', 'setHudLayout'],
[' setDetection({ enabled, mode, densityPct, allocationStrategy, fadePct, outsideOpacityPct } = {}) {', ' async setMapStack(stackId) {', 'this._setDetectionAllocation(', 'setDetection'],
[' setBloom({ enabled, intensityPct } = {}) {', ' setSharpen({ enabled, intensityPct } = {}) {', 'this._setBloomIntensity(', 'setBloom'],
[' setSharpen({ enabled, intensityPct } = {}) {', ' get celestialRingEnabled() {', 'this._applySharpenIntensity(', 'setSharpen'],
[' setSharpen({ enabled, intensityPct } = {}) {', ' get celestialRingEnabled() {', 'this._setSharpenIntensity(', 'setSharpen'],
[' setCelestialRingEnabled(enabled, { syncShare = true, focus = false } = {}) {', ' setOrbit(enabled) {', 'this.celestialRing?.setEnabled(', 'setCelestialRingEnabled'],
];
for (const [start, end, mutation, label] of facadeRoutes) {
@@ -646,8 +666,8 @@ test('every explicit visual control facade claims restore authority before mutat
const style = sourceBlock(' setStyle(styleName, {', ' _startTransition(styleName, fromValue, toValue) {');
assertClaimsBefore(style, 'this.activeStyle = styleName', 'setStyle');
const sliders = sourceBlock(' _updateSliderPanel(styleName, { reveal = false } = {}) {', ' _revealStyleParameters() {');
assertClaimsBefore(sliders, 'this.stages[styleName].uniforms[uName] = val', 'style parameter slider');
const sliders = sourceBlock(' setStyleParameter(name, value) {', ' _revealStyleParameters() {');
assertClaimsBefore(sliders, 'this.stages[parameters.style].uniforms[name] = value', 'style parameter slider');
});
test('public visual facades reject the complete invalid request before authority or mutation', () => {
@@ -793,12 +813,29 @@ test('visual input listeners are revoked before asynchronous UI teardown', () =>
assert.match(synchronous, /this\._displayBindings\.destroy\(\)/);
assert.match(synchronous, /this\._visualSettings\.stop\(\)/);
assert.match(synchronous, /this\._mapSourceControls\?\.destroy\(\)/);
assert.match(synchronous, /this\._clearLayersControl\?\.destroy\(\)/);
assert.match(synchronous, /this\._releaseGlobeActions\(\)/);
assert.match(synchronous, /this\._locationNavigation\.destroy\(\)/);
assert.match(LocationNavigation.prototype.destroy.toString(), /this\._locationControls\?\.destroy\(\)/);
assert.match(LocationNavigation.prototype.destroy.toString(), /this\._locationLookup\?\.destroy\(\)/);
assert.match(DisplayBindings.prototype.destroy.toString(), /this\._displayControls\?\.destroy\(\)/);
assert.match(DisplayBindings.prototype.destroy.toString(), /this\._detachDisplayControls\?\.\(\)/);
assert.match(DisplayBindings.prototype.destroy.toString(), /this\._applicationShortcuts\?\.destroy\(\)/);
assert.match(VisualSettings.prototype.stop.toString(), /this\._styleParameters\?\.destroy\(\)/);
assert.match(VisualSettings.prototype.stop.toString(), /this\.store\.detach\(this\._parametersToken\)/);
assert.match(VisualSettings.prototype.stop.toString(), /this\._visualEffects\.stop\(\)/);
});
test('share restore rejects inherited styles while continuing later fields', () => {
for (const style of ['constructor', '__proto__', 'toString', 'hasOwnProperty', 'unknown']) {
const restored = makeManager(`#lat=10&lon=20&style=${style}&cr=1`).parseInitialHash();
assert.equal(restored.style, 'normal');
assert.equal(restored.celestialRing, true);
}
});
test('programmatic invalid styles are ignored before changing visual state', () => {
const target = { activeStyle: 'normal' };
for (const value of ['constructor', '__proto__', 'toString', 'hasOwnProperty', 'unknown', {}, null, () => {}]) {
assert.doesNotThrow(() => VisualSettings.prototype.setStyle.call(target, value));
assert.equal(target.activeStyle, 'normal');
}
});