mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Main brings the reviewed one-time-control and timeline-mark changes. They keep this branch's renderer work: earthquakes draw through the draw port and register their strong quakes as marks; the weather clock keeps `follows` beside `world`; the weather layer measures ages and delays from the timeline time; the Visual panel keeps its sky and weather groups under Effects. Tests that moved time through the weather clock now move it on the world clock.
This commit is contained in:
commit
0ecbfbecd0
123 files changed
+5917
-1471
No files matched your search
@@ -227,7 +227,7 @@ test('outline upgrade preserves the existing SVG group identity', async (t) => {
|
||||
assert.ok(after === before, 'the rendered group is mutated, not replaced');
|
||||
assert.deepEqual(sampledAnchors.at(-1), [-97.5, 31.2], 'the existing group projects from the re-seated anchor');
|
||||
assert.equal(groups().length, 1);
|
||||
assert.equal(after.querySelector('.gev-anno-ring'), null, 'reticle rings are removed in place');
|
||||
assert.equal(after.querySelector('.gev-anno-ring') === null, true, 'reticle rings are removed in place');
|
||||
assert.ok(after.querySelector('.gev-anno-callout') === callout, 'the original callout remains in the group');
|
||||
assert.ok(after.querySelector('.gev-anno-dot') === dot, 'the anchor dot remains in the group');
|
||||
assert.ok(svg());
|
||||
@@ -341,7 +341,7 @@ test('a removed mark fades out, then leaves the board', async (t) => {
|
||||
assert.equal(group.isConnected, false);
|
||||
renderer.destroy();
|
||||
await settle();
|
||||
assert.equal(document.querySelector('.gev-screen-whiteboard'), null);
|
||||
assert.equal(document.querySelector('.gev-screen-whiteboard') === null, true);
|
||||
});
|
||||
|
||||
// ── Partial-add unwind (review round 2) ───────────────────────────────────────
|
||||
|
||||
@@ -6,6 +6,11 @@ import { createStandaloneLayerSources } from '../standalone/layerSources.js';
|
||||
import { catalogControlServices } from './catalog.js';
|
||||
import { LayerLifecycle } from '../data/lifecycle.js';
|
||||
import { fakeStreetLevelProvider } from '../testSupport/streetLevelFakes.mjs';
|
||||
import { worldClock } from '../time/worldClock.js';
|
||||
|
||||
const flush = async () => {
|
||||
for (let i = 0; i < 20; i++) await Promise.resolve();
|
||||
};
|
||||
|
||||
function fixtureSources(ids, calls) {
|
||||
const sources = createStandaloneLayerSources();
|
||||
@@ -27,6 +32,7 @@ test('catalogs construct distinct layers and classification from their supplied
|
||||
t.after(() => {
|
||||
a.abort();
|
||||
b.abort();
|
||||
worldClock.goLive();
|
||||
});
|
||||
const callsA = [];
|
||||
const callsB = [];
|
||||
@@ -53,7 +59,10 @@ test('catalogs construct distinct layers and classification from their supplied
|
||||
'the hardware-local layer is never serialized into links',
|
||||
);
|
||||
assert.notEqual(first.weatherClock, second.weatherClock);
|
||||
await first.weatherClock.setTarget('2026-09-21T12:00:00.000Z');
|
||||
// Time moves on the world clock, which the catalog's weather clock follows.
|
||||
assert.equal(first.weatherClock.world, worldClock);
|
||||
worldClock.seek(Date.parse('2026-09-21T12:00:00.000Z'));
|
||||
await flush();
|
||||
assert.match(
|
||||
first.get('wind').getRowControls().info,
|
||||
/Forecast · does not follow history/,
|
||||
@@ -111,9 +120,16 @@ test('catalogs construct distinct layers and classification from their supplied
|
||||
assert.equal(first.militaryRegistry.isMilitaryIcao('def456'), false);
|
||||
assert.equal(second.militaryRegistry.isMilitaryIcao('def456'), true);
|
||||
a.abort();
|
||||
worldClock.seek(Date.parse('2026-09-21T13:00:00.000Z'));
|
||||
await flush();
|
||||
assert.equal(
|
||||
await first.weatherClock.setTarget('2026-09-21T13:00:00.000Z'),
|
||||
false,
|
||||
first.weatherClock.getState().target,
|
||||
'2026-09-21T12:00:00.000Z',
|
||||
'an aborted catalog no longer follows the world clock',
|
||||
);
|
||||
assert.equal(
|
||||
second.weatherClock.getState().target,
|
||||
'2026-09-21T13:00:00.000Z',
|
||||
);
|
||||
assert.equal(callsA[0].aborted, true);
|
||||
assert.equal(first.militaryRegistry.isMilitaryIcao('abc123'), false);
|
||||
|
||||
@@ -435,7 +435,7 @@ test('Cockpit owns a focused shared Display portal and compact Radio controls',
|
||||
/data-cockpit-launcher="radio"[\s\S]*?id="cockpit-radio-toggle-btn"/,
|
||||
);
|
||||
const cockpitRadio = html.match(
|
||||
/id="cockpit-radio-panel"[\s\S]*?<\/div>\s*<\/div>\s*<\/aside>/,
|
||||
/id="cockpit-radio-panel"[\s\S]*?<\/div>\s*<\/div>\s*<div class="cockpit-utility-rail/,
|
||||
);
|
||||
assert.ok(cockpitRadio, 'Cockpit compact Radio controls are missing');
|
||||
assert.doesNotMatch(cockpitRadio[0], /radio-filter|radio-tuner/);
|
||||
@@ -524,12 +524,12 @@ test('Cockpit owns a focused shared Display portal and compact Radio controls',
|
||||
);
|
||||
});
|
||||
|
||||
test('Display orders 3D above Celestial, Clean UI below it, and Parameters below Detection', () => {
|
||||
test('Visual orders Parameters below Detection, 3D below them, and Clean UI above the Effects', () => {
|
||||
const display = html.match(/id="pp-toggles"[\s\S]*?id="clean-view-exit"/);
|
||||
assert.ok(display, 'Display markup is missing');
|
||||
assert.match(
|
||||
display[0],
|
||||
/id="detection-toggle"[\s\S]*?id="param-slider-panel"[\s\S]*?id="models3d-toggle"[\s\S]*?id="celestial-toggle"[\s\S]*?id="clean-view-toggle"/,
|
||||
/id="detection-toggle"[\s\S]*?id="param-slider-panel"[\s\S]*?id="models3d-toggle"[\s\S]*?id="scope-toggle"[\s\S]*?id="clean-view-toggle"[\s\S]*?class="pp-section-heading">Effects<[\s\S]*?id="celestial-toggle"/,
|
||||
);
|
||||
assert.equal(
|
||||
(html.match(/id="param-slider-panel"/g) || []).length,
|
||||
|
||||
@@ -209,7 +209,7 @@ test('rows render the signals the controller presents', async (t) => {
|
||||
);
|
||||
assert.equal(status.className, 'warning');
|
||||
assert.equal(status.querySelector('div > strong').textContent, 'UNKNOWN');
|
||||
assert.equal(status.querySelector('button'), null);
|
||||
assert.equal(status.querySelector('button') === null, true);
|
||||
});
|
||||
|
||||
test('actual Context refresh retains the focused signal button across unchanged and changed details', async (t) => {
|
||||
@@ -315,7 +315,7 @@ test('removing the focused identity uses the shown briefing tab once and permits
|
||||
assert.equal(document.activeElement === f.signalTab(), true);
|
||||
assert.equal(f.focusCalls(), calls + 1);
|
||||
assert.equal(f.losses(), 0);
|
||||
assert.equal(f.signalTab().closest('[hidden]'), null);
|
||||
assert.equal(f.signalTab().closest('[hidden]') === null, true);
|
||||
// Traversal carries on forward from the footer tab.
|
||||
f.tab();
|
||||
assert.equal(document.activeElement === f.pageTab(1), true);
|
||||
|
||||
@@ -705,6 +705,15 @@ export const NATURAL_EARTH_CREDIT = {
|
||||
'<a href="https://www.naturalearthdata.com" target="_blank" rel="noopener">Natural Earth</a> (public domain)',
|
||||
};
|
||||
|
||||
/** Registered when a name from the bundled Wikidata places packs is first
|
||||
* shown (CC0 — no attribution required; credited as a courtesy). */
|
||||
export const WIKIDATA_PLACES_CREDIT = {
|
||||
key: 'wikidata-places',
|
||||
html:
|
||||
'City, town and village names from ' +
|
||||
'<a href="https://www.wikidata.org" target="_blank" rel="noopener">Wikidata</a> (CC0)',
|
||||
};
|
||||
|
||||
/** Registered when the first bundled US county or place outline resolves
|
||||
* (public domain — credited as a courtesy). */
|
||||
export const US_CENSUS_CREDIT = {
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
# Wikidata cities pack
|
||||
|
||||
World cities and towns for naming a spot (the nearest city), the places
|
||||
around it and finding a place by name, read by `src/data/wikidataCities.js`. The app reads this file; it
|
||||
does not call Wikidata or any place service for these.
|
||||
|
||||
| File | Contents |
|
||||
|------|----------|
|
||||
| `cities.json` | Human settlements with coordinates and a population at or above the cut-off (see `meta.minPopulation`), largest first |
|
||||
|
||||
Each row is `[name, lat, lon, population, country, wikidata]`: the English
|
||||
label, coordinates to three decimals, the largest stated population, the
|
||||
ISO 3166-1 alpha-2 country code (empty when Wikidata gives none) and the
|
||||
Wikidata id.
|
||||
|
||||
**Source:** Wikidata, read once from the Wikidata Query Service by
|
||||
`scripts/build-wikidata-cities.mjs`. The build time and row count are in the
|
||||
file's `meta` header.
|
||||
|
||||
**License:** CC0 1.0 (https://www.wikidata.org/wiki/Wikidata:Licensing). No
|
||||
attribution is legally required.
|
||||
|
||||
**What is left out:** metropolitan areas, urban agglomerations, conurbations
|
||||
and similar groupings of settlements, so a view is named after the city
|
||||
rather than the area around it (an item of a narrower grouping kind that is
|
||||
also a city stays: Istanbul is a metropolitan municipality and a megacity);
|
||||
places that no longer stand (former entities, ghost towns, abandoned
|
||||
villages, archaeological sites) unless they are also a living settlement;
|
||||
and places Wikidata states as dissolved or abolished (P576) where another
|
||||
place within 15 km still names the spot. A dissolved unit with nothing
|
||||
else near it stays: many of Vietnam's provincial cities ended as units in
|
||||
2025 and still stand under their names. Also left out: places below the population cut-off and
|
||||
places without an English label.
|
||||
|
||||
**Rebuild:** `node scripts/build-wikidata-cities.mjs [--min-population 15000]`.
|
||||
The build runs one query at a time with pauses and honours the service's
|
||||
Retry-After; it takes about ten minutes. It fails if a short list of
|
||||
well-known cities is missing from the result, or a known grouping gets in.
|
||||
|
||||
**Limits:** populations are whatever Wikidata states and differ in date and
|
||||
definition between places (city proper, municipality, urban district). Some
|
||||
districts and suburbs appear as their own rows.
|
||||
@@ -0,0 +1 @@
|
||||
{"meta":{"source":"Wikidata (https://www.wikidata.org), via the Wikidata Query Service","license":"CC0 1.0","built":"2026-11-15T02:59:26.673Z","minPopulation":15000,"count":31827,"columns":["name","lat","lon","population","country","wikidata"]},"rows":[["Chongqing",29.55,106.507,32054159,"CN","Q11725"],["Delhi",28.667,77.217,26495000,"IN","Q1353"],["Shanghai",31.233,121.469,24870895,"CN","Q8686"],["Beijing",39.904,116.408,21893095,"CN","Q956"],["Chengdu",30.66,104.063,20937757,"CN","Q30002"],["Guangzhou",23.13,113.26,18676605,"CN","Q16572"],["Shenzhen",22.547,114.054,17494398,"CN","Q15174"],["Dhaka",23.729,90.394,16800000,"BD","Q1354"],["Istanbul",41.01,28.96,15655924,"TR","Q406"],["Mumbai",19.076,72.877,15414288,"IN","Q1156"],["Karachi",24.86,67.01,14910352,"PK","Q8660"],["Kinshasa",-4.322,15.312,14565700,"CD","Q3838"],["Tokyo",35.689,139.692,14264798,"JP","Q1490"],["Ho Chi Minh City",10.776,106.702,14002598,"VN","Q1854"],["Tianjin",39.147,117.206,13866009,"CN","Q11736"],["Moscow",55.751,37.617,13274285,"RU","Q649"],["Xi'an",34.261,108.942,12952907,"CN","Q5826"],["Suzhou",31.3,120.619,12748262,"CN","Q42622"],["Zhengzhou",34.749,113.661,12600574,"CN","Q30340"],["Bengaluru",12.979,77.591,12327000,"IN","Q1355"],["Wuhan",30.595,114.297,12326518,"CN","Q11746"],["Hangzhou",30.25,120.168,11936010,"CN","Q4970"],["Baoding",38.867,115.485,11544036,"CN","Q58584"],["São Paulo",-23.55,-46.634,11451999,"BR","Q174"],["Jakarta",-6.175,106.827,11135191,"ID","Q3630"],["Lahore",31.55,74.344,11126285,"PK","Q11739"],["Linyi",35.104,118.35,11018365,"CN","Q373346"],["Shijiazhuang",38.042,114.51,10640458,"CN","Q58401"],["Dongguan",23.047,113.749,10466625,"CN","Q59218"],["Qingdao",36.117,120.4,10071722,"CN","Q170322"],["Changsha",28.199,112.971,10047914,"CN","Q174091"],["Harbin",45.75,126.633,10009854,"CN","Q42956"],["Lima",-12.06,-77.037,9943800,"PE","Q2868"],["Cairo",30.044,31.236,9801536,"EG","Q85"],["Nanyang",32.999,112.529,9713112,"CN","Q404763"],["Seoul",37.56,126.99,9668465,"KR","Q8684"],["Tokyo",35.684,139.774,9640742,"JP","Q7473516"],["Wenzhou",27.999,120.656,9572903,"CN","Q42635"],["Foshan",23.029,113.106,9498863,"CN","Q34412"],["Handan",36.612,114.489,9413990,"CN","Q58570"],["Ningbo",29.875,121.549,9404283,"CN","Q42780"],["Weifang",36.717,119.1,9386705,"CN","Q217698"],["Hefei",31.864,117.281,9369881,"CN","Q185684"],["Nanjing",32.061,118.779,9314685,"CN","Q16666"],["Mexico City",19.354,-99.136,9209944,"MX","Q1489"],["Jinan",36.667,116.983,9202432,"CN","Q170247"],["Hyderabad",17.362,78.475,9191000,"IN","Q1361"],["Xuzhou",34.261,117.186,9083790,"CN","Q57719"],["Shenyang",41.803,123.428,9070093,"CN","Q11720"],["Changchun",43.88,125.323,9066906,"CN","Q92161"],["Zhoukou",33.625,114.642,9026015,"CN","Q198061"],["Kuala Lumpur",3.148,101.695,9000280,"MY","Q1865"],["Ganzhou",25.829,114.934,8970014,"CN","Q363166"],["New York City",40.713,-74.006,8804190,"US","Q60"],["London",51.507,-0.128,8799728,"GB","Q84"],["Heze",35.233,115.433,8795939,"CN","Q332753"],["Quanzhou",24.914,118.586,8782285,"CN","Q68695"],["Nanning",22.819,108.315,8741584,"CN","Q179608"],["Hanoi",21.024,105.841,8717600,"VN","Q1858"],["Tehran",35.689,51.39,8693706,"IR","Q3616"],["Kunming",25.043,102.706,8460088,"CN","Q182852"],["Jining",35.4,116.567,8357897,"CN","Q372791"],["Fuzhou",26.077,119.292,8291268,"CN","Q68481"],["Fuyang",32.899,115.804,8200264,"CN","Q360584"],["Baghdad",33.315,44.366,8126755,"IQ","Q1530"],["Veracruz",19.19,-96.153,8062579,"MX","Q173270"],["Bogotá",4.61,-74.082,8034649,"CO","Q2841"],["Shangqiu",34.426,115.647,7816831,"CN","Q404817"],["Nantong",31.983,120.887,7726635,"CN","Q57947"],["Tangshan",39.629,118.174,7717983,"CN","Q58422"],["Ahmedabad",23.022,72.58,7645000,"IN","Q1070"],["Wuxi",31.567,120.283,7462135,"CN","Q42651"],["Dalian",38.9,121.6,7450785,"CN","Q74881"],["Hong Kong",22.278,114.159,7413070,"CN","Q8646"],["Cangzhou",38.304,116.845,7300783,"CN","Q58695"],["Xingtai",37.066,114.475,7111106,"CN","Q58576"],["Yantai",37.464,121.448,7102116,"CN","Q210493"],["Luoyang",34.659,112.424,7056699,"CN","Q187136"],["Jinhua",29.105,119.649,7050683,"CN","Q58210"],["Riyadh",24.638,46.715,7009100,"SA","Q3692"],["Zhumadian",32.977,114.025,7008427,"CN","Q198240"],["Zhanjiang",21.197,110.403,6981236,"CN","Q59144"],["Bijie",27.302,105.286,6899636,"CN","Q486319"],["Yangon",16.795,96.16,6874000,"MM","Q37995"],["Yancheng",33.35,120.157,6709629,"CN","Q57866"],["Hengyang",26.897,112.586,6645243,"CN","Q144663"],["Taizhou",28.658,121.422,6622888,"CN","Q58273"],["Zunyi",27.705,106.934,6606675,"CN","Q28994"],["Chennai",13.082,80.275,6599000,"IN","Q1352"],["Shaoyang",27.242,111.472,6563520,"CN","Q194531"],["Shangrao",28.442,117.963,6491088,"CN","Q363479"],["Huanggang",30.45,114.875,6333000,"CN","Q71355"],["Moro",-6,144,6310129,"PG","Q103927888"],["Santiago",-33.438,-70.65,6257516,"CL","Q2887"],["Nanchang",28.684,115.887,6255007,"CN","Q171943"],["Xinxiang",35.299,113.885,6251929,"CN","Q404362"],["Xinyang",32.126,114.067,6234401,"CN","Q404873"],["Rio de Janeiro",-2Line truncated
|
||||
@@ -1247,7 +1247,15 @@ test('real mission build, select, refresh, deselect, disable, and destroy paths
|
||||
assert.equal(worldClock.coverage(), null, 'nothing loaded, no time to show');
|
||||
await rocketLaunchesLayer.update();
|
||||
const at = Date.parse(launchTime);
|
||||
assert.deepEqual(worldClock.coverage(), { start: at, end: at, marks: [at] });
|
||||
// The launch is a mark labelled with its mission's name.
|
||||
assert.deepEqual(worldClock.coverage(), {
|
||||
start: at,
|
||||
end: at,
|
||||
marks: [at],
|
||||
markDetails: [
|
||||
{ time: at, label: 'GAUNTLET PAYLOAD', id: 'mission-runtime', kind: 'launch' },
|
||||
],
|
||||
});
|
||||
assert.equal(worldClock.isSupported(), true, 'loaded launches bring up the timeline');
|
||||
|
||||
assert.ok(missionItems().size >= 7, 'runtime guard requires the populated mission build path');
|
||||
|
||||
@@ -0,0 +1,244 @@
|
||||
/**
|
||||
* The bundled world cities pack (Wikidata, CC0), read from
|
||||
* `local_data/wikidata_cities/cities.json` (built by
|
||||
* scripts/build-wikidata-cities.mjs). The file loads once, on first use, and
|
||||
* every answer comes from it: no place service is called.
|
||||
*
|
||||
* Rows are `[name, lat, lon, population, country, wikidata]`, largest first.
|
||||
*/
|
||||
|
||||
const CELL_DEG = 1;
|
||||
|
||||
// Letters that are not a base letter plus an accent, so NFD leaves them.
|
||||
const PLAIN_LETTERS = {
|
||||
ł: 'l',
|
||||
ø: 'o',
|
||||
đ: 'd',
|
||||
ð: 'd',
|
||||
ı: 'i',
|
||||
ß: 'ss',
|
||||
æ: 'ae',
|
||||
œ: 'oe',
|
||||
þ: 'th',
|
||||
};
|
||||
|
||||
/**
|
||||
* A name as the lookups compare it: lower case, without accents, so
|
||||
* "sao paulo" finds São Paulo, "zurich" Zürich, "lodz" Łódź and "tromso"
|
||||
* Tromsø.
|
||||
*/
|
||||
export const foldName = (name) =>
|
||||
String(name || '')
|
||||
.normalize('NFD')
|
||||
.replace(/\p{M}/gu, '')
|
||||
.toLocaleLowerCase('en')
|
||||
.replace(/[łøđðıßæœþ]/g, (letter) => PLAIN_LETTERS[letter])
|
||||
.trim();
|
||||
const EARTH_KM = 6371;
|
||||
const rad = (deg) => (deg * Math.PI) / 180;
|
||||
|
||||
function distanceKm(lat1, lon1, lat2, lon2) {
|
||||
const a =
|
||||
Math.sin(rad(lat2 - lat1) / 2) ** 2 +
|
||||
Math.cos(rad(lat1)) *
|
||||
Math.cos(rad(lat2)) *
|
||||
Math.sin(rad(lon2 - lon1) / 2) ** 2;
|
||||
return 2 * EARTH_KM * Math.asin(Math.min(1, Math.sqrt(a)));
|
||||
}
|
||||
|
||||
const cellKey = (lat, lon) =>
|
||||
`${Math.floor(lat / CELL_DEG)},${Math.floor(((((lon % 360) + 540) % 360) - 180) / CELL_DEG)}`;
|
||||
|
||||
/** Group rows by one-degree cell so a lookup reads only the cells near it. */
|
||||
export function indexCities(rows) {
|
||||
const cells = new Map();
|
||||
for (const row of rows) {
|
||||
const key = cellKey(row[1], row[2]);
|
||||
const cell = cells.get(key);
|
||||
if (cell) cell.push(row);
|
||||
else cells.set(key, [row]);
|
||||
}
|
||||
return cells;
|
||||
}
|
||||
|
||||
/** Rows by folded name, each list in the rows' own order (largest first). */
|
||||
export function indexNames(rows) {
|
||||
const names = new Map();
|
||||
for (const row of rows) {
|
||||
const key = foldName(row[0]);
|
||||
const list = names.get(key);
|
||||
if (list) list.push(row);
|
||||
else names.set(key, [row]);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
function toCity(row, km) {
|
||||
return {
|
||||
name: row[0],
|
||||
latitude: row[1],
|
||||
longitude: row[2],
|
||||
population: row[3],
|
||||
country: row[4] || null,
|
||||
wikidata: row[5],
|
||||
distanceKm: km,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Half the longitude a circle spans, in degrees: 180 when it reaches a pole,
|
||||
* where every meridian passes through it.
|
||||
*/
|
||||
export function lonHalfSpan(latitude, radiusKm) {
|
||||
const angle = radiusKm / EARTH_KM;
|
||||
const fromPole = Math.PI / 2 - Math.abs(rad(latitude));
|
||||
if (angle >= fromPole) return 180;
|
||||
return (Math.asin(Math.sin(angle) / Math.cos(rad(latitude))) * 180) / Math.PI;
|
||||
}
|
||||
const latHalfSpan = (radiusKm) => ((radiusKm / EARTH_KM) * 180) / Math.PI;
|
||||
|
||||
/** Rows within `radiusKm` of a point, each with its distance. */
|
||||
export function citiesWithin(cells, latitude, longitude, radiusKm) {
|
||||
const latSpan = Math.ceil(latHalfSpan(radiusKm) / CELL_DEG);
|
||||
const lonSpan = Math.ceil(lonHalfSpan(latitude, radiusKm) / CELL_DEG);
|
||||
const found = [];
|
||||
const seen = new Set();
|
||||
for (let dLat = -latSpan; dLat <= latSpan; dLat++) {
|
||||
const lat = latitude + dLat * CELL_DEG;
|
||||
if (lat < -90 - CELL_DEG || lat > 90 + CELL_DEG) continue;
|
||||
for (
|
||||
let dLon = -Math.min(lonSpan, 180);
|
||||
dLon <= Math.min(lonSpan, 180);
|
||||
dLon++
|
||||
) {
|
||||
const key = cellKey(lat, longitude + dLon * CELL_DEG);
|
||||
if (seen.has(key)) continue;
|
||||
seen.add(key);
|
||||
for (const row of cells.get(key) || []) {
|
||||
const km = distanceKm(latitude, longitude, row[1], row[2]);
|
||||
if (km <= radiusKm) found.push(toCity(row, km));
|
||||
}
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
// Each country in the pack by what a qualifier may call it: its code, its
|
||||
// English name and its name in the page language, folded.
|
||||
function countryNames(rows) {
|
||||
const names = new Map();
|
||||
for (const code of new Set(rows.map((row) => row[4]).filter(Boolean))) {
|
||||
for (const name of [code, countryName(code, 'en'), countryName(code)])
|
||||
names.set(foldName(name), code);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
let loading = null;
|
||||
/** The indexed pack; a failed load is retried on the next call. */
|
||||
export function loadCities(fetchImpl = (...args) => globalThis.fetch(...args)) {
|
||||
loading ??= fetchImpl(
|
||||
new URL('./local_data/wikidata_cities/cities.json', import.meta.url),
|
||||
)
|
||||
.then((response) => {
|
||||
if (!response.ok) throw new Error(`cities pack: HTTP ${response.status}`);
|
||||
return response.json();
|
||||
})
|
||||
.then((pack) => ({
|
||||
meta: pack.meta,
|
||||
rows: pack.rows,
|
||||
cells: indexCities(pack.rows),
|
||||
names: indexNames(pack.rows),
|
||||
countries: countryNames(pack.rows),
|
||||
}))
|
||||
.catch((error) => {
|
||||
loading = null;
|
||||
throw error;
|
||||
});
|
||||
return loading;
|
||||
}
|
||||
|
||||
/**
|
||||
* The city a point is in or nearest to: the largest within `nearKm`, else the
|
||||
* nearest within `radiusKm`, else null. Preferring the largest nearby keeps a
|
||||
* view over a metropolis from being named after one of its suburbs.
|
||||
*/
|
||||
export async function nearestCity(
|
||||
latitude,
|
||||
longitude,
|
||||
{ radiusKm = 60, nearKm = 12 } = {},
|
||||
) {
|
||||
if (!Number.isFinite(latitude) || !Number.isFinite(longitude)) return null;
|
||||
const { cells } = await loadCities();
|
||||
const found = citiesWithin(cells, latitude, longitude, radiusKm);
|
||||
if (!found.length) return null;
|
||||
const near = found.filter((city) => city.distanceKm <= nearKm);
|
||||
if (near.length)
|
||||
return near.reduce((a, b) => (b.population > a.population ? b : a));
|
||||
return found.reduce((a, b) => (b.distanceKm < a.distanceKm ? b : a));
|
||||
}
|
||||
|
||||
/** Cities around a point, most populous first. */
|
||||
export async function citiesAround({
|
||||
latitude,
|
||||
longitude,
|
||||
radiusKm = 50,
|
||||
limit = 8,
|
||||
minPopulation = 0,
|
||||
}) {
|
||||
if (!Number.isFinite(latitude) || !Number.isFinite(longitude)) return [];
|
||||
const { cells } = await loadCities();
|
||||
return citiesWithin(cells, latitude, longitude, radiusKm)
|
||||
.filter((city) => city.population >= minPopulation)
|
||||
.sort((a, b) => b.population - a.population || a.distanceKm - b.distanceKm)
|
||||
.slice(0, limit);
|
||||
}
|
||||
|
||||
/** A country's name in the page language, from its ISO code. */
|
||||
export function countryName(
|
||||
code,
|
||||
language = globalThis.document?.documentElement?.lang || 'en',
|
||||
) {
|
||||
if (!code) return null;
|
||||
try {
|
||||
return (
|
||||
new Intl.DisplayNames([language], { type: 'region' }).of(code) || code
|
||||
);
|
||||
} catch {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The city with this name, or null. A qualifier after a comma that names a
|
||||
* country ("Paris, France", "Paris, US") keeps only cities there, and finds
|
||||
* nothing when none is; one that names no country ("Paris, Texas") is
|
||||
* ignored. A city of that name within `radiusKm` of `near` (the view) wins,
|
||||
* the nearest first, else the largest city of that name anywhere.
|
||||
*/
|
||||
export async function findPlace(
|
||||
name,
|
||||
{ near = null, radiusKm = 150 } = {},
|
||||
fetchImpl = (...args) => globalThis.fetch(...args),
|
||||
) {
|
||||
const [head, ...rest] = String(name || '').split(',');
|
||||
const wanted = foldName(head);
|
||||
if (!wanted) return null;
|
||||
const qualifier = foldName(rest.join(','));
|
||||
const { names, countries } = await loadCities(fetchImpl);
|
||||
const country = qualifier ? countries.get(qualifier) : undefined;
|
||||
const cities = (names.get(wanted) || []).filter(
|
||||
(row) => !country || row[4] === country,
|
||||
);
|
||||
if (!cities.length) return null;
|
||||
if (Number.isFinite(near?.latitude) && Number.isFinite(near?.longitude)) {
|
||||
let best = null;
|
||||
for (const row of cities) {
|
||||
const km = distanceKm(near.latitude, near.longitude, row[1], row[2]);
|
||||
if (km <= radiusKm && (!best || km < best.distanceKm))
|
||||
best = toCity(row, km);
|
||||
}
|
||||
if (best) return best;
|
||||
}
|
||||
return toCity(cities[0], 0);
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
// src/data/wikidataCities.test.mjs — lookups over the bundled Wikidata
|
||||
// places packs, with the packs served from memory.
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
citiesWithin,
|
||||
foldName,
|
||||
indexCities,
|
||||
lonHalfSpan,
|
||||
} from './wikidataCities.js';
|
||||
|
||||
const ROWS = [
|
||||
['São Paulo', -23.55, -46.633, 11451999, 'BR', 'Q174'],
|
||||
['Austin', 30.267, -97.743, 961855, 'US', 'Q16559'],
|
||||
['Round Rock', 30.508, -97.679, 119468, 'US', 'Q128269'],
|
||||
['Zürich', 47.374, 8.541, 421878, 'CH', 'Q72'],
|
||||
];
|
||||
|
||||
test('names compare without case or accents', () => {
|
||||
assert.equal(foldName('São Paulo'), 'sao paulo');
|
||||
assert.equal(foldName(' ZÜRICH '), 'zurich');
|
||||
assert.equal(foldName(null), '');
|
||||
});
|
||||
|
||||
test('a lookup reads the cells around a point and measures each place', () => {
|
||||
const cells = indexCities(ROWS);
|
||||
const near = citiesWithin(cells, 30.27, -97.74, 40).sort(
|
||||
(a, b) => a.distanceKm - b.distanceKm,
|
||||
);
|
||||
assert.deepEqual(
|
||||
near.map((city) => city.name),
|
||||
['Austin', 'Round Rock'],
|
||||
);
|
||||
assert.ok(near[0].distanceKm < 1);
|
||||
assert.equal(near[1].country, 'US');
|
||||
assert.deepEqual(citiesWithin(cells, 0, 0, 50), []);
|
||||
});
|
||||
|
||||
test('findPlace finds a city by its name without accents', async () => {
|
||||
// A fresh module, so its pack cache starts empty.
|
||||
const { findPlace } = await import(`./wikidataCities.js?case=${Date.now()}`);
|
||||
const fetchImpl = async (url) => ({
|
||||
ok: true,
|
||||
json: async () =>
|
||||
String(url).includes('cities.json') ? { meta: {}, rows: ROWS } : null,
|
||||
});
|
||||
const found = await findPlace('sao paulo, Brazil', {}, fetchImpl);
|
||||
assert.equal(found?.wikidata, 'Q174');
|
||||
assert.equal(await findPlace('Atlantis', {}, fetchImpl), null);
|
||||
});
|
||||
|
||||
test('names fold letters that carry no separate accent', () => {
|
||||
assert.equal(foldName('Łódź'), 'lodz');
|
||||
assert.equal(foldName('Tromsø'), 'tromso');
|
||||
assert.equal(foldName('Đà Nẵng'), 'da nang');
|
||||
assert.equal(foldName('Diyarbakır'), 'diyarbakir');
|
||||
assert.equal(foldName('Straße'), 'strasse');
|
||||
});
|
||||
|
||||
const PARIS = [
|
||||
['Paris', 48.857, 2.352, 2145906, 'FR', 'Q90'],
|
||||
['Paris', 33.661, -95.556, 24476, 'US', 'Q830149'],
|
||||
];
|
||||
|
||||
async function freshPack(rows) {
|
||||
const module = await import(
|
||||
`./wikidataCities.js?case=${Date.now()}-${Math.random()}`
|
||||
);
|
||||
const fetchImpl = async () => ({
|
||||
ok: true,
|
||||
json: async () => ({ meta: {}, rows }),
|
||||
});
|
||||
return { ...module, fetchImpl };
|
||||
}
|
||||
|
||||
test('findPlace takes a country qualifier and prefers a namesake in view', async () => {
|
||||
const { findPlace, fetchImpl } = await freshPack(PARIS);
|
||||
const texas = { latitude: 33.2, longitude: -96.0 };
|
||||
assert.equal((await findPlace('Paris', {}, fetchImpl)).wikidata, 'Q90');
|
||||
assert.equal(
|
||||
(await findPlace('Paris', { near: texas }, fetchImpl)).wikidata,
|
||||
'Q830149',
|
||||
);
|
||||
assert.equal(
|
||||
(await findPlace('Paris, United States', {}, fetchImpl)).wikidata,
|
||||
'Q830149',
|
||||
);
|
||||
assert.equal(
|
||||
(await findPlace('paris, us', {}, fetchImpl)).wikidata,
|
||||
'Q830149',
|
||||
);
|
||||
// A qualifier the packs cannot place is ignored.
|
||||
assert.equal(
|
||||
(await findPlace('Paris, Texas', { near: texas }, fetchImpl)).wikidata,
|
||||
'Q830149',
|
||||
);
|
||||
});
|
||||
|
||||
test('a circle that reaches a pole spans every longitude', () => {
|
||||
assert.equal(lonHalfSpan(89, 150), 180);
|
||||
assert.ok(lonHalfSpan(60, 150) < 3);
|
||||
const cells = indexCities([['Pole camp', 89.9, 179, 1, '', 'Q1']]);
|
||||
assert.equal(citiesWithin(cells, 89, 0, 150).length, 1);
|
||||
});
|
||||
|
||||
test('a country qualifier that matches no namesake finds nothing', async () => {
|
||||
const { findPlace, fetchImpl } = await freshPack([
|
||||
...PARIS,
|
||||
['Berlin', 52.52, 13.405, 3755251, 'DE', 'Q64'],
|
||||
]);
|
||||
assert.equal(await findPlace('Paris, Germany', {}, fetchImpl), null);
|
||||
assert.equal(
|
||||
(await findPlace('Paris, France', {}, fetchImpl)).wikidata,
|
||||
'Q90',
|
||||
);
|
||||
});
|
||||
|
||||
test('a lookup wraps at the antimeridian', () => {
|
||||
const cells = indexCities([['Taveuni', -16.8, -179.9, 15000, 'FJ', 'Q2']]);
|
||||
assert.equal(citiesWithin(cells, -16.8, 179.9, 40).length, 1);
|
||||
});
|
||||
@@ -165,7 +165,7 @@ test('the DISMISS button closes the card the way ESC does', async (t) => {
|
||||
assert.notEqual(sessionStorageRef.read(), null, 'dismissed for the session');
|
||||
root.dispatchEvent(new Event('transitionend'));
|
||||
await nextTick();
|
||||
assert.equal(document.getElementById('first-run-launcher'), null);
|
||||
assert.equal(document.getElementById('first-run-launcher') === null, true);
|
||||
});
|
||||
|
||||
test('the scroll fade clears when the tiles fit after a resize', async (t) => {
|
||||
@@ -191,5 +191,5 @@ test('ESC closes the card, returns focus, and removes it without a transition',
|
||||
// Reduced motion: no transitionend, so the bounded fallback removes it.
|
||||
t.mock.timers.tick(400);
|
||||
await nextTick();
|
||||
assert.equal(document.getElementById('first-run-launcher'), null);
|
||||
assert.equal(document.getElementById('first-run-launcher') === null, true);
|
||||
});
|
||||
+74
-2
@@ -177,7 +177,69 @@ function interpolate(pattern, values) {
|
||||
/** A catalog string with something to show; an empty one counts as missing. */
|
||||
const filled = (value) => typeof value === 'string' && value.trim() !== '';
|
||||
|
||||
// A host application's own text for messages Core shows (setMessageOverrides),
|
||||
// by locale: { en: { 'English key': 'Its text' }, de: { … } }.
|
||||
let overrides = Object.freeze({});
|
||||
|
||||
/**
|
||||
* Show a host application's own text for Core's messages. `messages` maps a
|
||||
* locale (`en` included) to entries keyed as the catalogs are: the English
|
||||
* text, `context|text` for a t() context, the English plural for tn() (whose
|
||||
* entry is a `{one, other, …}` object). An overridden message shows the host's
|
||||
* text in the active locale, else the host's English, else Core's. Each call
|
||||
* replaces the previous overrides; `{}` removes them. Call it before views
|
||||
* render: onLocaleChange listeners word their text again at once, but a view
|
||||
* already drawn keeps its text until it next renders. A t() entry is text, a
|
||||
* tn() entry `{one, other, …}` forms worded in its locale; any other entry is
|
||||
* ignored.
|
||||
* @param {Record<string, Record<string, string|Record<string, string>>>} messages
|
||||
*/
|
||||
export function setMessageOverrides(messages) {
|
||||
const next = {};
|
||||
for (const [locale, entries] of Object.entries(messages ?? {})) {
|
||||
const code = normalizeLocale(locale);
|
||||
if (!code || !entries || typeof entries !== 'object') continue;
|
||||
const own = Object.fromEntries(
|
||||
Object.entries(entries).map(([key, entry]) => [
|
||||
key,
|
||||
entry && typeof entry === 'object'
|
||||
? Object.freeze({ ...entry })
|
||||
: entry,
|
||||
]),
|
||||
);
|
||||
next[code] = Object.freeze({ ...next[code], ...own });
|
||||
}
|
||||
overrides = Object.freeze(next);
|
||||
notifyLocaleChange();
|
||||
}
|
||||
|
||||
/** A host's entry for t() is text; for tn() plural forms with an `other`. */
|
||||
const usable = (entry, plural) =>
|
||||
plural
|
||||
? Boolean(entry) && typeof entry === 'object' && filled(entry.other)
|
||||
: filled(entry);
|
||||
|
||||
/**
|
||||
* The host's entry for a message, in the active locale or else in English,
|
||||
* with the locale it is worded in (whose plural rules pick its form).
|
||||
*/
|
||||
function overridden(text, plural = false) {
|
||||
for (const locale of new Set([getLocale(), DEFAULT_LOCALE])) {
|
||||
const entries = overrides[locale];
|
||||
const entry =
|
||||
entries && Object.hasOwn(entries, text) ? entries[text] : undefined;
|
||||
if (usable(entry, plural)) return { entry, locale };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function lookup(text) {
|
||||
const host = overridden(text);
|
||||
return host ? host.entry : catalogEntry(text);
|
||||
}
|
||||
|
||||
/** Core's own catalog entry for a message in the active locale. */
|
||||
function catalogEntry(text) {
|
||||
const catalog = CATALOGS[getLocale()];
|
||||
if (!catalog) return undefined;
|
||||
const entry = Object.hasOwn(catalog, text) ? catalog[text] : undefined;
|
||||
@@ -212,7 +274,14 @@ export function t(text, values) {
|
||||
* @returns {string}
|
||||
*/
|
||||
export function tn(count, one, other, values) {
|
||||
const entry = lookup(other);
|
||||
const host = overridden(other, true);
|
||||
if (host) {
|
||||
const forms = host.entry;
|
||||
const category = pluralRules(host.locale).select(count);
|
||||
const pattern = filled(forms[category]) ? forms[category] : forms.other;
|
||||
return interpolate(pattern, { count, ...values });
|
||||
}
|
||||
const entry = catalogEntry(other);
|
||||
const category = pluralRules(getLocale()).select(count);
|
||||
let pattern;
|
||||
const forms = entry && typeof entry === 'object' ? entry : null;
|
||||
@@ -230,8 +299,11 @@ export function tn(count, one, other, values) {
|
||||
* missing-translation warning.
|
||||
*/
|
||||
export function translateKnown(text) {
|
||||
if (typeof text !== 'string') return text;
|
||||
const host = overridden(text);
|
||||
if (host) return host.entry;
|
||||
const catalog = CATALOGS[getLocale()];
|
||||
if (!catalog || typeof text !== 'string') return text;
|
||||
if (!catalog) return text;
|
||||
const entry = Object.hasOwn(catalog, text) ? catalog[text] : undefined;
|
||||
return filled(entry) ? entry : text;
|
||||
}
|
||||
|
||||
@@ -2031,7 +2031,6 @@
|
||||
"60°S–60°N · typically 2–3 h delayed": "60° ج–60° ش · بتأخير 2–3 س عادةً",
|
||||
"North America · infrared imagery": "أمريكا الشمالية · صور بالأشعة تحت الحمراء",
|
||||
"Reduced motion · history playback unavailable": "تقليل الحركة · تشغيل السجل غير متاح",
|
||||
"Reduced motion · manual history available": "تقليل الحركة · التصفح اليدوي للسجل متاح",
|
||||
"Rain radar · US": "رادار الأمطار · الولايات المتحدة",
|
||||
"Lightning density · 15 min": "كثافة البرق · 15 د",
|
||||
"Satellite clouds": "الغيوم من الأقمار الصناعية",
|
||||
@@ -2541,12 +2540,8 @@
|
||||
"PAUSE": "إيقاف مؤقت",
|
||||
"RESUME": "استئناف",
|
||||
"Clear reading": "مسح القراءة",
|
||||
"Earlier observation": "رصد أسبق",
|
||||
"Observed history": "سجل الأرصاد",
|
||||
"Later observation": "رصد لاحق",
|
||||
"Latest": "الأحدث",
|
||||
"Newest frame per product": "أحدث إطار لكل منتج",
|
||||
"Replay observed history": "إعادة تشغيل سجل الأرصاد",
|
||||
"Imagery on Esri · Google 3D returns when cleared": "الصور على Esri · تعود Google 3D عند المسح",
|
||||
"Point the camera at the ground to use the view": "وجّه الكاميرا نحو الأرض لاستخدام العرض",
|
||||
"That point cannot anchor a box": "لا يمكن تثبيت منطقة على تلك النقطة",
|
||||
@@ -2847,7 +2842,6 @@
|
||||
"dB": "dB",
|
||||
"{time} · {minutes} min ago": "{time} · قبل {minutes} د",
|
||||
"Active weather": "الطقس النشط",
|
||||
"LATEST · newest per product": "الأحدث · آخر إطار لكل منتج",
|
||||
"Forecast · valid {valid} · issued {issued}": "توقع عند {valid} · صدر {issued}",
|
||||
"{detail} · Does not follow history": "{detail} · لا يتبع السجل",
|
||||
"Forecast · valid {valid}": "توقع عند {valid}",
|
||||
@@ -3980,5 +3974,23 @@
|
||||
"Funicular": "قطار جبلي مائل",
|
||||
"Gondola": "تلفريك",
|
||||
"Move panels back beside the rail": "إعادة اللوحات إلى جانب الشريط",
|
||||
"Move panels over the rail, to the edge": "نقل اللوحات فوق الشريط إلى الحافة"
|
||||
"Move panels over the rail, to the edge": "نقل اللوحات فوق الشريط إلى الحافة",
|
||||
"panel|VISUAL": "المرئيات",
|
||||
"Look": "المظهر",
|
||||
"Overlay": "التراكب",
|
||||
"Effects": "المؤثرات",
|
||||
"Scope opacity": "عتامة المنظار",
|
||||
"How dark the scope shades the view outside the keyhole": "مدى تعتيم المنظار للعرض خارج الفتحة",
|
||||
"Reset to default": "إعادة التعيين إلى الافتراضي",
|
||||
"Reset Visual to its defaults: Normal look, HUD, scope, labels and effects": "إعادة المرئيات إلى إعداداتها الافتراضية: المظهر العادي وHUD والمنظار والتسميات والمؤثرات",
|
||||
"All layers": "كل الطبقات",
|
||||
"On": "تشغيل",
|
||||
"Off": "إيقاف",
|
||||
"Search layers": "البحث في الطبقات",
|
||||
"Filter layers": "تصفية الطبقات",
|
||||
"Status": "الحالة",
|
||||
"Search layers…": "ابحث في الطبقات…",
|
||||
"Layer groups": "مجموعات الطبقات",
|
||||
"Jump to {name}": "الانتقال إلى {name}",
|
||||
"No layers match": "لا توجد طبقات مطابقة"
|
||||
}
|
||||
@@ -1935,7 +1935,6 @@
|
||||
"60°S–60°N · typically 2–3 h delayed": "60°S–60°N · meist 2–3 h verzögert",
|
||||
"North America · infrared imagery": "Nordamerika · Infrarotbilder",
|
||||
"Reduced motion · history playback unavailable": "Reduzierte Bewegung · Verlaufswiedergabe nicht verfügbar",
|
||||
"Reduced motion · manual history available": "Reduzierte Bewegung · manueller Verlauf verfügbar",
|
||||
"Rain radar · US": "Regenradar · USA",
|
||||
"Lightning density · 15 min": "Blitzdichte · 15 min",
|
||||
"Satellite clouds": "Wolken (Satellit)",
|
||||
@@ -2401,12 +2400,8 @@
|
||||
"PAUSE": "PAUSE",
|
||||
"RESUME": "FORTSETZEN",
|
||||
"Clear reading": "Wert ausblenden",
|
||||
"Earlier observation": "Frühere Beobachtung",
|
||||
"Observed history": "Beobachteter Verlauf",
|
||||
"Later observation": "Spätere Beobachtung",
|
||||
"Latest": "Neueste",
|
||||
"Newest frame per product": "Neuester Frame je Produkt",
|
||||
"Replay observed history": "Beobachteten Verlauf abspielen",
|
||||
"Imagery on Esri · Google 3D returns when cleared": "Bilder auf Esri · nach LÖSCHEN wieder Google 3D",
|
||||
"Point the camera at the ground to use the view": "Kamera auf den Boden richten, um die Ansicht zu verwenden",
|
||||
"That point cannot anchor a box": "Dieser Punkt kann keinen Bereich verankern",
|
||||
@@ -2655,7 +2650,6 @@
|
||||
"dB": "dB",
|
||||
"{time} · {minutes} min ago": "{time} · vor {minutes} min",
|
||||
"Active weather": "Aktives Wetter",
|
||||
"LATEST · newest per product": "NEUESTE · je Produkt",
|
||||
"Forecast · valid {valid} · issued {issued}": "Vorhersage · gültig {valid} · ausgegeben {issued}",
|
||||
"{detail} · Does not follow history": "{detail} · Folgt nicht dem Verlauf",
|
||||
"Forecast · valid {valid}": "Vorhersage · gültig {valid}",
|
||||
@@ -3632,5 +3626,23 @@
|
||||
"Funicular": "Standseilbahn",
|
||||
"Gondola": "Gondelbahn",
|
||||
"Move panels back beside the rail": "Bedienfelder zurück neben die Leiste",
|
||||
"Move panels over the rail, to the edge": "Bedienfelder über die Leiste an den Rand verschieben"
|
||||
"Move panels over the rail, to the edge": "Bedienfelder über die Leiste an den Rand verschieben",
|
||||
"panel|VISUAL": "DARSTELLUNG",
|
||||
"Look": "Look",
|
||||
"Overlay": "Overlay",
|
||||
"Effects": "Effekte",
|
||||
"Scope opacity": "Scope-Deckkraft",
|
||||
"How dark the scope shades the view outside the keyhole": "Wie stark der Scope die Ansicht außerhalb des Schlüssellochs abdunkelt",
|
||||
"Reset to default": "Auf Standard zurücksetzen",
|
||||
"Reset Visual to its defaults: Normal look, HUD, scope, labels and effects": "Darstellung auf die Standardwerte zurücksetzen: normaler Look, HUD, Scope, Beschriftungen und Effekte",
|
||||
"All layers": "Alle Ebenen",
|
||||
"On": "An",
|
||||
"Off": "Aus",
|
||||
"Search layers": "Ebenen suchen",
|
||||
"Filter layers": "Ebenen filtern",
|
||||
"Status": "Status",
|
||||
"Search layers…": "Ebenen suchen…",
|
||||
"Layer groups": "Ebenengruppen",
|
||||
"Jump to {name}": "Zu {name} springen",
|
||||
"No layers match": "Keine passenden Ebenen"
|
||||
}
|
||||
@@ -1437,7 +1437,6 @@
|
||||
"60°S–60°N · typically 2–3 h delayed": "60°S–60°N · normalmente con 2–3 h de retraso",
|
||||
"North America · infrared imagery": "Norteamérica · imágenes infrarrojas",
|
||||
"Reduced motion · history playback unavailable": "Movimiento reducido · reproducción del historial no disponible",
|
||||
"Reduced motion · manual history available": "Movimiento reducido · puedes recorrer el historial a mano",
|
||||
"Rain radar · US": "Radar de lluvia · EE. UU.",
|
||||
"Lightning density · 15 min": "Densidad de rayos · 15 min",
|
||||
"Satellite clouds": "Nubes por satélite",
|
||||
@@ -1668,12 +1667,8 @@
|
||||
"CH {index} / {total}": "CANAL {index} / {total}",
|
||||
"Station unavailable after directory refresh": "Emisora no disponible tras actualizar el directorio",
|
||||
"Clear reading": "Borrar lectura",
|
||||
"Earlier observation": "Observación anterior",
|
||||
"Observed history": "Historial observado",
|
||||
"Later observation": "Observación posterior",
|
||||
"Latest": "Último",
|
||||
"Newest frame per product": "Fotograma más reciente por producto",
|
||||
"Replay observed history": "Reproducir el historial observado",
|
||||
"S on another day replaces it · × unpins": "S en otro día lo reemplaza · × quita la fijación",
|
||||
"← → preview · S shows the focused day": "← → vista previa · S muestra el día enfocado",
|
||||
"Recent imagery": "Imágenes recientes",
|
||||
@@ -1837,7 +1832,6 @@
|
||||
"Reset map bearing to north": "Restablecer la orientación del mapa al norte",
|
||||
"Rain radar": "Radar de lluvia",
|
||||
"Lightning density": "Densidad de rayos",
|
||||
"LATEST · newest per product": "ÚLTIMO · más reciente por producto",
|
||||
"Forecast · valid {valid} · issued {issued}": "Pronóstico · válido {valid} · emitido {issued}",
|
||||
"{detail} · Does not follow history": "{detail} · No sigue el historial",
|
||||
"Forecast · valid {valid}": "Pronóstico · válido {valid}",
|
||||
@@ -3719,5 +3713,23 @@
|
||||
"Funicular": "Funicular",
|
||||
"Gondola": "Góndola",
|
||||
"Move panels back beside the rail": "Devolver los paneles junto a la barra",
|
||||
"Move panels over the rail, to the edge": "Mover los paneles sobre la barra, hasta el borde"
|
||||
"Move panels over the rail, to the edge": "Mover los paneles sobre la barra, hasta el borde",
|
||||
"panel|VISUAL": "VISUAL",
|
||||
"Look": "Aspecto",
|
||||
"Overlay": "Superposición",
|
||||
"Effects": "Efectos",
|
||||
"Scope opacity": "Opacidad de la mirilla",
|
||||
"How dark the scope shades the view outside the keyhole": "Cuánto oscurece la mirilla la vista fuera del ojo de cerradura",
|
||||
"Reset to default": "Restablecer valores predeterminados",
|
||||
"Reset Visual to its defaults: Normal look, HUD, scope, labels and effects": "Restablecer Visual a sus valores predeterminados: aspecto Normal, HUD, mirilla, etiquetas y efectos",
|
||||
"All layers": "Todas las capas",
|
||||
"On": "Activadas",
|
||||
"Off": "Desactivadas",
|
||||
"Search layers": "Buscar capas",
|
||||
"Filter layers": "Filtrar capas",
|
||||
"Status": "Estado",
|
||||
"Search layers…": "Buscar capas…",
|
||||
"Layer groups": "Grupos de capas",
|
||||
"Jump to {name}": "Ir a {name}",
|
||||
"No layers match": "Ninguna capa coincide"
|
||||
}
|
||||
@@ -1349,7 +1349,6 @@
|
||||
"60°S–60°N · typically 2–3 h delayed": "60°S–60°N · retard habituel de 2 à 3 h",
|
||||
"North America · infrared imagery": "Amérique du Nord · imagerie infrarouge",
|
||||
"Reduced motion · history playback unavailable": "Animations réduites · lecture de l'historique indisponible",
|
||||
"Reduced motion · manual history available": "Animations réduites · historique parcourable manuellement",
|
||||
"Rain radar · US": "Radar de pluie · États-Unis",
|
||||
"Lightning density · 15 min": "Densité de foudre · 15 min",
|
||||
"Satellite clouds": "Nuages par satellite",
|
||||
@@ -2149,12 +2148,8 @@
|
||||
"Radio is disabling…": "Désactivation de la Radio…",
|
||||
"Radio lifecycle is uncertain — use Enable or Disable to reconcile": "État de la Radio incertain — utilisez Activer ou Désactiver pour le rétablir",
|
||||
"Clear reading": "Effacer le relevé",
|
||||
"Earlier observation": "Observation précédente",
|
||||
"Observed history": "Historique des observations",
|
||||
"Later observation": "Observation suivante",
|
||||
"Latest": "Dernière",
|
||||
"Newest frame per product": "Image la plus récente par produit",
|
||||
"Replay observed history": "Rejouer l'historique des observations",
|
||||
"Imagery on Esri · Google 3D returns when cleared": "Sur Esri · EFFACER rétablit Google 3D",
|
||||
"Point the camera at the ground to use the view": "Orientez la caméra vers le sol pour utiliser la vue",
|
||||
"That point cannot anchor a box": "Ce point ne peut pas ancrer une zone",
|
||||
@@ -2445,7 +2440,6 @@
|
||||
"DETECT": "DÉTECT.",
|
||||
"{time} · {minutes} min ago": "{time} · il y a {minutes} min",
|
||||
"Active weather": "Couches météo actives",
|
||||
"LATEST · newest per product": "DERNIÈRE · la plus récente par produit",
|
||||
"Forecast · valid {valid} · issued {issued}": "Prévision · valide {valid} · émise {issued}",
|
||||
"{detail} · Does not follow history": "{detail} · Ne suit pas l'historique",
|
||||
"Forecast · valid {valid}": "Prévision · valide {valid}",
|
||||
@@ -3719,5 +3713,23 @@
|
||||
"Funicular": "Funiculaire",
|
||||
"Gondola": "Télécabine",
|
||||
"Move panels back beside the rail": "Remettre les panneaux à côté de la barre",
|
||||
"Move panels over the rail, to the edge": "Déplacer les panneaux par-dessus la barre, jusqu’au bord"
|
||||
"Move panels over the rail, to the edge": "Déplacer les panneaux par-dessus la barre, jusqu’au bord",
|
||||
"panel|VISUAL": "VISUEL",
|
||||
"Look": "Aspect",
|
||||
"Overlay": "Surcouche",
|
||||
"Effects": "Effets",
|
||||
"Scope opacity": "Opacité de la lunette",
|
||||
"How dark the scope shades the view outside the keyhole": "À quel point la lunette assombrit la vue hors de l'ouverture",
|
||||
"Reset to default": "Rétablir les valeurs par défaut",
|
||||
"Reset Visual to its defaults: Normal look, HUD, scope, labels and effects": "Rétablir les valeurs par défaut de Visuel : aspect Normal, HUD, lunette, libellés et effets",
|
||||
"All layers": "Toutes les couches",
|
||||
"On": "Actives",
|
||||
"Off": "Inactives",
|
||||
"Search layers": "Rechercher des couches",
|
||||
"Filter layers": "Filtrer les couches",
|
||||
"Status": "État",
|
||||
"Search layers…": "Rechercher des couches…",
|
||||
"Layer groups": "Groupes de couches",
|
||||
"Jump to {name}": "Aller à {name}",
|
||||
"No layers match": "Aucune couche ne correspond"
|
||||
}
|
||||
@@ -1207,7 +1207,6 @@
|
||||
"Color: strikes/km²/min ×10³": "צבע: פגיעות ברק/קמ\"ר/דק׳ ×10³",
|
||||
"Color: {units}": "צבע: {units}",
|
||||
"Reduced motion · history playback unavailable": "תנועה מופחתת · הצגת ההיסטוריה אינה זמינה",
|
||||
"Reduced motion · manual history available": "תנועה מופחתת · היסטוריה ידנית זמינה",
|
||||
"Rain radar · US": "רדאר גשם · ארה\"ב",
|
||||
"Lightning density · 15 min": "צפיפות ברקים · 15 דק׳",
|
||||
"Satellite clouds": "עננים מלוויין",
|
||||
@@ -1995,11 +1994,7 @@
|
||||
"READY": "מוכן",
|
||||
"Clear reading": "ניקוי הקריאה",
|
||||
"Observed history": "היסטוריה נצפית",
|
||||
"Earlier observation": "תצפית קודמת",
|
||||
"Later observation": "תצפית מאוחרת",
|
||||
"Newest frame per product": "השקופית החדשה לכל מוצר",
|
||||
"Latest": "האחרונה",
|
||||
"Replay observed history": "הצגת ההיסטוריה הנצפית שוב",
|
||||
"Imagery on Esri · Google 3D returns when cleared": "צילומים ב-Esri · Google 3D חוזר כשמנקים",
|
||||
"Point the camera at the ground to use the view": "כוון את המצלמה אל הקרקע כדי להשתמש בתצוגה",
|
||||
"That point cannot anchor a box": "אין אפשרות לעגן תיבה באותה נקודה",
|
||||
@@ -2782,7 +2777,6 @@
|
||||
"Detection overlay: off": "שכבת הזיהוי: כבויה",
|
||||
"Active weather": "מזג אוויר פעיל",
|
||||
"{time} · {minutes} min ago": "{time} · לפני {minutes} דק׳",
|
||||
"LATEST · newest per product": "האחרון · החדש ביותר לכל מוצר",
|
||||
"Forecast · valid {valid} · issued {issued}": "תחזית · תקפה {valid} · פורסמה {issued}",
|
||||
"{detail} · Does not follow history": "{detail} · אינו נע עם ההיסטוריה",
|
||||
"Forecast · valid {valid}": "תחזית · תקפה {valid}",
|
||||
@@ -3719,5 +3713,23 @@
|
||||
"Funicular": "פוניקולר",
|
||||
"Gondola": "רכבל",
|
||||
"Move panels back beside the rail": "החזרת הלוחות לצד הסרגל",
|
||||
"Move panels over the rail, to the edge": "הזזת הלוחות מעל הסרגל, אל הקצה"
|
||||
"Move panels over the rail, to the edge": "הזזת הלוחות מעל הסרגל, אל הקצה",
|
||||
"panel|VISUAL": "חזותי",
|
||||
"Look": "מראה",
|
||||
"Overlay": "שכבת על",
|
||||
"Effects": "אפקטים",
|
||||
"Scope opacity": "אטימות הסקופ",
|
||||
"How dark the scope shades the view outside the keyhole": "עד כמה הסקופ מכהה את התצוגה מחוץ לחור המנעול",
|
||||
"Reset to default": "איפוס לברירת המחדל",
|
||||
"Reset Visual to its defaults: Normal look, HUD, scope, labels and effects": "איפוס החזותי לברירות המחדל: מראה רגיל, HUD, סקופ, תוויות ואפקטים",
|
||||
"All layers": "כל השכבות",
|
||||
"On": "פעילות",
|
||||
"Off": "כבויות",
|
||||
"Search layers": "חיפוש שכבות",
|
||||
"Filter layers": "סינון שכבות",
|
||||
"Status": "מצב",
|
||||
"Search layers…": "חיפוש שכבות…",
|
||||
"Layer groups": "קבוצות שכבות",
|
||||
"Jump to {name}": "מעבר אל {name}",
|
||||
"No layers match": "אין שכבות תואמות"
|
||||
}
|
||||
@@ -1349,7 +1349,6 @@
|
||||
"60°S–60°N · typically 2–3 h delayed": "60°S–60°N · di solito 2–3 h di ritardo",
|
||||
"North America · infrared imagery": "Nord America · immagini all'infrarosso",
|
||||
"Reduced motion · history playback unavailable": "Movimento ridotto · riproduzione dello storico non disponibile",
|
||||
"Reduced motion · manual history available": "Movimento ridotto · storico manuale disponibile",
|
||||
"Rain radar · US": "Radar pioggia · USA",
|
||||
"Lightning density · 15 min": "Densità di fulmini · 15 min",
|
||||
"Satellite clouds": "Nuvole da satellite",
|
||||
@@ -2149,12 +2148,8 @@
|
||||
"Radio is disabling…": "Disattivazione della Radio…",
|
||||
"Radio lifecycle is uncertain — use Enable or Disable to reconcile": "Il ciclo di vita della Radio è incerto: usa Attiva o Disattiva per riconciliare",
|
||||
"Clear reading": "Cancella la lettura",
|
||||
"Earlier observation": "Osservazione precedente",
|
||||
"Observed history": "Storico osservato",
|
||||
"Later observation": "Osservazione successiva",
|
||||
"Latest": "Più recente",
|
||||
"Newest frame per product": "Fotogramma più recente per prodotto",
|
||||
"Replay observed history": "Rivedi lo storico osservato",
|
||||
"Imagery on Esri · Google 3D returns when cleared": "Immagini su Esri · Google 3D torna con CANCELLA",
|
||||
"Point the camera at the ground to use the view": "Punta la camera verso il suolo per usare la vista",
|
||||
"That point cannot anchor a box": "Quel punto non può ancorare un riquadro",
|
||||
@@ -2445,7 +2440,6 @@
|
||||
"DETECT": "RILEV.",
|
||||
"{time} · {minutes} min ago": "{time} · {minutes} min fa",
|
||||
"Active weather": "Meteo attivo",
|
||||
"LATEST · newest per product": "ULTIMO · il più recente per prodotto",
|
||||
"Forecast · valid {valid} · issued {issued}": "Previsione · valida {valid} · emessa {issued}",
|
||||
"{detail} · Does not follow history": "{detail} · Non segue lo storico",
|
||||
"Forecast · valid {valid}": "Previsione · valida {valid}",
|
||||
@@ -3719,5 +3713,23 @@
|
||||
"Funicular": "Funicolare",
|
||||
"Gondola": "Cabinovia",
|
||||
"Move panels back beside the rail": "Riporta i pannelli accanto alla barra",
|
||||
"Move panels over the rail, to the edge": "Sposta i pannelli sopra la barra, fino al bordo"
|
||||
"Move panels over the rail, to the edge": "Sposta i pannelli sopra la barra, fino al bordo",
|
||||
"panel|VISUAL": "VISUALE",
|
||||
"Look": "Aspetto",
|
||||
"Overlay": "Overlay",
|
||||
"Effects": "Effetti",
|
||||
"Scope opacity": "Opacità dello scope",
|
||||
"How dark the scope shades the view outside the keyhole": "Quanto lo scope scurisce la vista fuori dal foro",
|
||||
"Reset to default": "Ripristina predefiniti",
|
||||
"Reset Visual to its defaults: Normal look, HUD, scope, labels and effects": "Ripristina Visuale ai valori predefiniti: aspetto Normale, HUD, scope, etichette ed effetti",
|
||||
"All layers": "Tutti i livelli",
|
||||
"On": "Attivi",
|
||||
"Off": "Disattivati",
|
||||
"Search layers": "Cerca livelli",
|
||||
"Filter layers": "Filtra livelli",
|
||||
"Status": "Stato",
|
||||
"Search layers…": "Cerca livelli…",
|
||||
"Layer groups": "Gruppi di livelli",
|
||||
"Jump to {name}": "Vai a {name}",
|
||||
"No layers match": "Nessun livello corrisponde"
|
||||
}
|
||||
@@ -1311,7 +1311,6 @@
|
||||
"60°S–60°N · typically 2–3 h delayed": "60°S–60°N · 通常2–3時間遅れ",
|
||||
"North America · infrared imagery": "北米 · 赤外画像",
|
||||
"Reduced motion · history playback unavailable": "動きを減らす設定 · 履歴再生は利用不可",
|
||||
"Reduced motion · manual history available": "動きを減らす設定 · 履歴は手動で表示可能",
|
||||
"Rain radar · US": "降水レーダー · 米国",
|
||||
"Lightning density · 15 min": "雷密度 · 15分",
|
||||
"Satellite clouds": "衛星雲画像",
|
||||
@@ -2075,12 +2074,8 @@
|
||||
"Radio is disabling…": "ラジオを無効化しています…",
|
||||
"Radio lifecycle is uncertain — use Enable or Disable to reconcile": "ラジオのライフサイクルが不明確です。有効化または無効化で再調整してください",
|
||||
"Clear reading": "読み取り値を消去",
|
||||
"Earlier observation": "前の観測",
|
||||
"Observed history": "観測履歴",
|
||||
"Later observation": "次の観測",
|
||||
"Latest": "最新",
|
||||
"Newest frame per product": "プロダクトごとの最新フレーム",
|
||||
"Replay observed history": "観測履歴を再生",
|
||||
"Imagery on Esri · Google 3D returns when cleared": "画像はEsri上に表示 · 消去するとGoogle 3Dに戻ります",
|
||||
"Point the camera at the ground to use the view": "このビューを使うにはカメラを地面に向けてください",
|
||||
"That point cannot anchor a box": "その地点は範囲の基点にできません",
|
||||
@@ -2345,7 +2340,6 @@
|
||||
"DETECT": "検出",
|
||||
"{time} · {minutes} min ago": "{time} · {minutes}分前",
|
||||
"Active weather": "有効な気象レイヤー",
|
||||
"LATEST · newest per product": "最新 · プロダクトごとの最新",
|
||||
"Forecast · valid {valid} · issued {issued}": "予報 · 対象時刻 {valid} · 発表 {issued}",
|
||||
"{detail} · Does not follow history": "{detail} · 履歴とは連動しません",
|
||||
"Forecast · valid {valid}": "予報 · 対象時刻 {valid}",
|
||||
@@ -3545,5 +3539,23 @@
|
||||
"Funicular": "ケーブルカー",
|
||||
"Gondola": "ゴンドラ",
|
||||
"Move panels back beside the rail": "パネルをレールの横に戻す",
|
||||
"Move panels over the rail, to the edge": "パネルをレールの上、画面端へ移動"
|
||||
"Move panels over the rail, to the edge": "パネルをレールの上、画面端へ移動",
|
||||
"panel|VISUAL": "ビジュアル",
|
||||
"Look": "見た目",
|
||||
"Overlay": "オーバーレイ",
|
||||
"Effects": "エフェクト",
|
||||
"Scope opacity": "スコープの不透明度",
|
||||
"How dark the scope shades the view outside the keyhole": "キーホール外のビューをスコープがどれだけ暗くするか",
|
||||
"Reset to default": "既定に戻す",
|
||||
"Reset Visual to its defaults: Normal look, HUD, scope, labels and effects": "ビジュアルを既定に戻す:標準の見た目、HUD、スコープ、ラベル、エフェクト",
|
||||
"All layers": "すべてのレイヤー",
|
||||
"On": "オン",
|
||||
"Off": "オフ",
|
||||
"Search layers": "レイヤーを検索",
|
||||
"Filter layers": "レイヤーを絞り込む",
|
||||
"Status": "状態",
|
||||
"Search layers…": "レイヤーを検索…",
|
||||
"Layer groups": "レイヤーのグループ",
|
||||
"Jump to {name}": "{name} へ移動",
|
||||
"No layers match": "一致するレイヤーはありません"
|
||||
}
|
||||
@@ -1347,7 +1347,6 @@
|
||||
"60°S–60°N · typically 2–3 h delayed": "60°S–60°N · normalmente com 2–3 h de atraso",
|
||||
"North America · infrared imagery": "América do Norte · imagens infravermelhas",
|
||||
"Reduced motion · history playback unavailable": "Movimento reduzido · reprodução do histórico indisponível",
|
||||
"Reduced motion · manual history available": "Movimento reduzido · é possível percorrer o histórico manualmente",
|
||||
"Rain radar · US": "Radar de chuva · EUA",
|
||||
"Lightning density · 15 min": "Densidade de raios · 15 min",
|
||||
"Satellite clouds": "Nuvens por satélite",
|
||||
@@ -2149,12 +2148,8 @@
|
||||
"Radio is disabling…": "O rádio está sendo desativado…",
|
||||
"Radio lifecycle is uncertain — use Enable or Disable to reconcile": "O ciclo de vida do rádio é incerto — use Ativar ou Desativar para reconciliar",
|
||||
"Clear reading": "Limpar leitura",
|
||||
"Earlier observation": "Observação anterior",
|
||||
"Observed history": "Histórico observado",
|
||||
"Later observation": "Observação posterior",
|
||||
"Latest": "Mais recente",
|
||||
"Newest frame per product": "Quadro mais recente por produto",
|
||||
"Replay observed history": "Reproduzir o histórico observado",
|
||||
"Imagery on Esri · Google 3D returns when cleared": "Imagens sobre o Esri · LIMPAR restaura o Google 3D",
|
||||
"Point the camera at the ground to use the view": "Aponte a câmera para o chão para usar a vista",
|
||||
"That point cannot anchor a box": "Esse ponto não pode ancorar uma área",
|
||||
@@ -2445,7 +2440,6 @@
|
||||
"DETECT": "DETECÇÃO",
|
||||
"{time} · {minutes} min ago": "{time} · há {minutes} min",
|
||||
"Active weather": "Camadas de clima ativas",
|
||||
"LATEST · newest per product": "MAIS RECENTE · último por produto",
|
||||
"Forecast · valid {valid} · issued {issued}": "Previsão · válida para {valid} · emitida em {issued}",
|
||||
"{detail} · Does not follow history": "{detail} · Não acompanha o histórico",
|
||||
"Forecast · valid {valid}": "Previsão · válida para {valid}",
|
||||
@@ -3719,5 +3713,23 @@
|
||||
"Funicular": "Funicular",
|
||||
"Gondola": "Teleférico",
|
||||
"Move panels back beside the rail": "Voltar os painéis para junto da barra",
|
||||
"Move panels over the rail, to the edge": "Mover os painéis sobre a barra, até a borda"
|
||||
"Move panels over the rail, to the edge": "Mover os painéis sobre a barra, até a borda",
|
||||
"panel|VISUAL": "VISUAL",
|
||||
"Look": "Aparência",
|
||||
"Overlay": "Sobreposição",
|
||||
"Effects": "Efeitos",
|
||||
"Scope opacity": "Opacidade da mira",
|
||||
"How dark the scope shades the view outside the keyhole": "Quanto a mira escurece a vista fora do visor",
|
||||
"Reset to default": "Redefinir para o padrão",
|
||||
"Reset Visual to its defaults: Normal look, HUD, scope, labels and effects": "Redefinir o Visual para o padrão: aparência Normal, HUD, mira, rótulos e efeitos",
|
||||
"All layers": "Todas as camadas",
|
||||
"On": "Ativadas",
|
||||
"Off": "Desativadas",
|
||||
"Search layers": "Pesquisar camadas",
|
||||
"Filter layers": "Filtrar camadas",
|
||||
"Status": "Estado",
|
||||
"Search layers…": "Pesquisar camadas…",
|
||||
"Layer groups": "Grupos de camadas",
|
||||
"Jump to {name}": "Ir para {name}",
|
||||
"No layers match": "Nenhuma camada corresponde"
|
||||
}
|
||||
@@ -1459,7 +1459,6 @@
|
||||
"60°S–60°N · typically 2–3 h delayed": "60° ю. ш.–60° с. ш. · обычно задержка 2–3 ч",
|
||||
"North America · infrared imagery": "Северная Америка · ИК-снимки",
|
||||
"Reduced motion · history playback unavailable": "Уменьшение движения · воспроизведение истории недоступно",
|
||||
"Reduced motion · manual history available": "Уменьшение движения · историю можно листать вручную",
|
||||
"Rain radar · US": "Радар осадков · США",
|
||||
"Lightning density · 15 min": "Плотность молний · 15 мин",
|
||||
"Satellite clouds": "Спутниковая облачность",
|
||||
@@ -1698,12 +1697,8 @@
|
||||
"CH {index} / {total}": "КАН. {index} / {total}",
|
||||
"Station unavailable after directory refresh": "Станция недоступна после обновления каталога",
|
||||
"Clear reading": "Очистить показания",
|
||||
"Earlier observation": "Более раннее наблюдение",
|
||||
"Observed history": "История наблюдений",
|
||||
"Later observation": "Более позднее наблюдение",
|
||||
"Latest": "Последние",
|
||||
"Newest frame per product": "Самый свежий кадр каждого продукта",
|
||||
"Replay observed history": "Воспроизвести историю наблюдений",
|
||||
"S on another day replaces it · × unpins": "S в другой день заменяет его · × открепляет",
|
||||
"← → preview · S shows the focused day": "← → просмотр · S показывает выбранный день",
|
||||
"Recent imagery": "Свежие снимки",
|
||||
@@ -1868,7 +1863,6 @@
|
||||
"Reset map bearing to north": "Сбросить азимут карты на север",
|
||||
"Rain radar": "Радар осадков",
|
||||
"Lightning density": "Плотность молний",
|
||||
"LATEST · newest per product": "ПОСЛЕДНИЕ · самые свежие по каждому продукту",
|
||||
"Forecast · valid {valid} · issued {issued}": "Прогноз · действует на {valid} · выпущен {issued}",
|
||||
"{detail} · Does not follow history": "{detail} · не следует за историей",
|
||||
"Forecast · valid {valid}": "Прогноз · действует на {valid}",
|
||||
@@ -3806,5 +3800,23 @@
|
||||
"Funicular": "Фуникулёр",
|
||||
"Gondola": "Канатная дорога",
|
||||
"Move panels back beside the rail": "Вернуть панели к боковой панели",
|
||||
"Move panels over the rail, to the edge": "Переместить панели поверх боковой панели к краю"
|
||||
"Move panels over the rail, to the edge": "Переместить панели поверх боковой панели к краю",
|
||||
"panel|VISUAL": "ВИЗУАЛ",
|
||||
"Look": "Вид",
|
||||
"Overlay": "Наложение",
|
||||
"Effects": "Эффекты",
|
||||
"Scope opacity": "Непрозрачность прицела",
|
||||
"How dark the scope shades the view outside the keyhole": "Насколько прицел затемняет вид за пределами маски",
|
||||
"Reset to default": "Сбросить по умолчанию",
|
||||
"Reset Visual to its defaults: Normal look, HUD, scope, labels and effects": "Сбросить «Визуал» к настройкам по умолчанию: обычный вид, HUD, прицел, подписи и эффекты",
|
||||
"All layers": "Все слои",
|
||||
"On": "Включены",
|
||||
"Off": "Выключены",
|
||||
"Search layers": "Поиск слоёв",
|
||||
"Filter layers": "Фильтр слоёв",
|
||||
"Status": "Состояние",
|
||||
"Search layers…": "Поиск слоёв…",
|
||||
"Layer groups": "Группы слоёв",
|
||||
"Jump to {name}": "Перейти к «{name}»",
|
||||
"No layers match": "Нет подходящих слоёв"
|
||||
}
|
||||
@@ -1857,7 +1857,6 @@
|
||||
"60°S–60°N · typically 2–3 h delayed": "60° S–60° N · oftast 2–3 h fördröjning",
|
||||
"North America · infrared imagery": "Nordamerika · infraröda bilder",
|
||||
"Reduced motion · history playback unavailable": "Minskad rörelse · uppspelning av historik otillgänglig",
|
||||
"Reduced motion · manual history available": "Minskad rörelse · manuell historik tillgänglig",
|
||||
"Rain radar · US": "Regnradar · USA",
|
||||
"Lightning density · 15 min": "Blixttäthet · 15 min",
|
||||
"Satellite clouds": "Satellitmoln",
|
||||
@@ -2323,12 +2322,8 @@
|
||||
"PAUSE": "PAUSA",
|
||||
"RESUME": "FORTSÄTT",
|
||||
"Clear reading": "Rensa avläsningen",
|
||||
"Earlier observation": "Tidigare observation",
|
||||
"Observed history": "Observerad historik",
|
||||
"Later observation": "Senare observation",
|
||||
"Latest": "Senaste",
|
||||
"Newest frame per product": "Senaste bildruta per produkt",
|
||||
"Replay observed history": "Spela upp observerad historik",
|
||||
"Imagery on Esri · Google 3D returns when cleared": "Bilder på Esri · Google 3D återkommer när de rensas",
|
||||
"Point the camera at the ground to use the view": "Rikta kameran mot marken för att använda vyn",
|
||||
"That point cannot anchor a box": "Den punkten kan inte förankra ett område",
|
||||
@@ -2577,7 +2572,6 @@
|
||||
"dB": "dB",
|
||||
"{time} · {minutes} min ago": "{time} · för {minutes} min sedan",
|
||||
"Active weather": "Aktuellt väder",
|
||||
"LATEST · newest per product": "SENASTE · nyaste per produkt",
|
||||
"Forecast · valid {valid} · issued {issued}": "Prognos · gäller {valid} · utfärdad {issued}",
|
||||
"{detail} · Does not follow history": "{detail} · Följer inte historiken",
|
||||
"Forecast · valid {valid}": "Prognos · gäller {valid}",
|
||||
@@ -3632,5 +3626,23 @@
|
||||
"Funicular": "Bergbana",
|
||||
"Gondola": "Kabinbana",
|
||||
"Move panels back beside the rail": "Flytta tillbaka panelerna bredvid listen",
|
||||
"Move panels over the rail, to the edge": "Flytta panelerna över listen, till kanten"
|
||||
"Move panels over the rail, to the edge": "Flytta panelerna över listen, till kanten",
|
||||
"panel|VISUAL": "VISUELLT",
|
||||
"Look": "Utseende",
|
||||
"Overlay": "Överlägg",
|
||||
"Effects": "Effekter",
|
||||
"Scope opacity": "Scope-opacitet",
|
||||
"How dark the scope shades the view outside the keyhole": "Hur mycket scopet mörkar vyn utanför nyckelhålet",
|
||||
"Reset to default": "Återställ till standard",
|
||||
"Reset Visual to its defaults: Normal look, HUD, scope, labels and effects": "Återställ Visuellt till standard: Normal stil, HUD, scope, etiketter och effekter",
|
||||
"All layers": "Alla lager",
|
||||
"On": "På",
|
||||
"Off": "Av",
|
||||
"Search layers": "Sök lager",
|
||||
"Filter layers": "Filtrera lager",
|
||||
"Status": "Status",
|
||||
"Search layers…": "Sök lager…",
|
||||
"Layer groups": "Lagergrupper",
|
||||
"Jump to {name}": "Gå till {name}",
|
||||
"No layers match": "Inga lager matchar"
|
||||
}
|
||||
@@ -1367,7 +1367,6 @@
|
||||
"60°S–60°N · typically 2–3 h delayed": "60° пд. ш.–60° пн. ш. · зазвичай затримка 2–3 год",
|
||||
"North America · infrared imagery": "Північна Америка · ІЧ-знімки",
|
||||
"Reduced motion · history playback unavailable": "Зменшення руху · відтворення історії недоступне",
|
||||
"Reduced motion · manual history available": "Зменшення руху · історію можна гортати вручну",
|
||||
"Rain radar · US": "Радар опадів · США",
|
||||
"Lightning density · 15 min": "Щільність блискавок · 15 хв",
|
||||
"Satellite clouds": "Супутникова хмарність",
|
||||
@@ -2185,12 +2184,8 @@
|
||||
"Radio is disabling…": "Радіо вимикається…",
|
||||
"Radio lifecycle is uncertain — use Enable or Disable to reconcile": "Стан радіо невизначений — звірте через «Увімкнути» або «Вимкнути»",
|
||||
"Clear reading": "Очистити покази",
|
||||
"Earlier observation": "Попереднє спостереження",
|
||||
"Observed history": "Історія спостережень",
|
||||
"Later observation": "Наступне спостереження",
|
||||
"Latest": "Останні",
|
||||
"Newest frame per product": "Найсвіжіший кадр кожного продукту",
|
||||
"Replay observed history": "Відтворити історію спостережень",
|
||||
"Imagery on Esri · Google 3D returns when cleared": "Підкладка: Esri · скидання поверне Google 3D",
|
||||
"Point the camera at the ground to use the view": "Наведіть камеру на землю, щоб вибрати видиму область",
|
||||
"That point cannot anchor a box": "Від цієї точки не можна побудувати область",
|
||||
@@ -2494,7 +2489,6 @@
|
||||
"DETECT": "ВИЯВЛЕННЯ",
|
||||
"{time} · {minutes} min ago": "{time} · {minutes} хв тому",
|
||||
"Active weather": "Активні погодні шари",
|
||||
"LATEST · newest per product": "ОСТАННІ · найсвіжіші для кожного продукту",
|
||||
"Forecast · valid {valid} · issued {issued}": "Прогноз · чинний на {valid} · випущено {issued}",
|
||||
"{detail} · Does not follow history": "{detail} · не синхронізується з історією",
|
||||
"Forecast · valid {valid}": "Прогноз · чинний на {valid}",
|
||||
@@ -3806,5 +3800,23 @@
|
||||
"Funicular": "Фунікулер",
|
||||
"Gondola": "Канатна дорога",
|
||||
"Move panels back beside the rail": "Повернути панелі до бічної смуги",
|
||||
"Move panels over the rail, to the edge": "Перемістити панелі поверх бічної смуги до краю"
|
||||
"Move panels over the rail, to the edge": "Перемістити панелі поверх бічної смуги до краю",
|
||||
"panel|VISUAL": "ВІЗУАЛ",
|
||||
"Look": "Вигляд",
|
||||
"Overlay": "Накладка",
|
||||
"Effects": "Ефекти",
|
||||
"Scope opacity": "Непрозорість прицілу",
|
||||
"How dark the scope shades the view outside the keyhole": "Наскільки приціл затемнює вигляд за межами прицілу",
|
||||
"Reset to default": "Скинути до типових",
|
||||
"Reset Visual to its defaults: Normal look, HUD, scope, labels and effects": "Скинути «Візуал» до типових налаштувань: звичайний вигляд, HUD, приціл, підписи та ефекти",
|
||||
"All layers": "Усі шари",
|
||||
"On": "Увімкнені",
|
||||
"Off": "Вимкнені",
|
||||
"Search layers": "Пошук шарів",
|
||||
"Filter layers": "Фільтр шарів",
|
||||
"Status": "Стан",
|
||||
"Search layers…": "Пошук шарів…",
|
||||
"Layer groups": "Групи шарів",
|
||||
"Jump to {name}": "Перейти до «{name}»",
|
||||
"No layers match": "Немає відповідних шарів"
|
||||
}
|
||||
@@ -1287,7 +1287,6 @@
|
||||
"60°S–60°N · typically 2–3 h delayed": "60°S–60°N · 通常延迟 2–3 小时",
|
||||
"North America · infrared imagery": "北美洲 · 红外影像",
|
||||
"Reduced motion · history playback unavailable": "减弱动效 · 历史回放不可用",
|
||||
"Reduced motion · manual history available": "减弱动效 · 可手动浏览历史",
|
||||
"Rain radar · US": "降雨雷达 · 美国",
|
||||
"Lightning density · 15 min": "闪电密度 · 15 分钟",
|
||||
"Satellite clouds": "卫星云图",
|
||||
@@ -2045,12 +2044,8 @@
|
||||
"Radio is disabling…": "电台正在停用…",
|
||||
"Radio lifecycle is uncertain — use Enable or Disable to reconcile": "电台生命周期状态不确定——请使用“启用”或“停用”进行核对",
|
||||
"Clear reading": "清除读数",
|
||||
"Earlier observation": "较早观测",
|
||||
"Observed history": "观测历史",
|
||||
"Later observation": "较晚观测",
|
||||
"Latest": "最新",
|
||||
"Newest frame per product": "每个产品的最新一帧",
|
||||
"Replay observed history": "回放观测历史",
|
||||
"Imagery on Esri · Google 3D returns when cleared": "影像显示在 Esri 底图上 · 清除后恢复 Google 3D",
|
||||
"Point the camera at the ground to use the view": "将相机对准地面才能使用当前视野",
|
||||
"That point cannot anchor a box": "该点无法作为框选锚点",
|
||||
@@ -2309,7 +2304,6 @@
|
||||
"DETECT": "探测",
|
||||
"{time} · {minutes} min ago": "{time} · {minutes} 分钟前",
|
||||
"Active weather": "已启用的天气图层",
|
||||
"LATEST · newest per product": "最新 · 每个产品的最新一帧",
|
||||
"Forecast · valid {valid} · issued {issued}": "预报 · 有效时间 {valid} · 发布时间 {issued}",
|
||||
"{detail} · Does not follow history": "{detail} · 不随观测历史变化",
|
||||
"Forecast · valid {valid}": "预报 · 有效时间 {valid}",
|
||||
@@ -3545,5 +3539,23 @@
|
||||
"Funicular": "缆索铁路",
|
||||
"Gondola": "缆车",
|
||||
"Move panels back beside the rail": "将面板移回侧栏旁",
|
||||
"Move panels over the rail, to the edge": "将面板移到侧栏上方,贴靠边缘"
|
||||
"Move panels over the rail, to the edge": "将面板移到侧栏上方,贴靠边缘",
|
||||
"panel|VISUAL": "视觉",
|
||||
"Look": "外观",
|
||||
"Overlay": "叠加层",
|
||||
"Effects": "效果",
|
||||
"Scope opacity": "视域不透明度",
|
||||
"How dark the scope shades the view outside the keyhole": "视域遮罩使视域之外的画面变暗的程度",
|
||||
"Reset to default": "恢复默认",
|
||||
"Reset Visual to its defaults: Normal look, HUD, scope, labels and effects": "将视觉恢复为默认设置:常规外观、HUD、视域、标签和效果",
|
||||
"All layers": "全部图层",
|
||||
"On": "已开启",
|
||||
"Off": "已关闭",
|
||||
"Search layers": "搜索图层",
|
||||
"Filter layers": "筛选图层",
|
||||
"Status": "状态",
|
||||
"Search layers…": "搜索图层…",
|
||||
"Layer groups": "图层分组",
|
||||
"Jump to {name}": "跳转到{name}",
|
||||
"No layers match": "没有匹配的图层"
|
||||
}
|
||||
@@ -1282,7 +1282,6 @@
|
||||
"60°S–60°N · typically 2–3 h delayed": "60°S–60°N · 通常延遲 2–3 小時",
|
||||
"North America · infrared imagery": "北美洲 · 紅外影像",
|
||||
"Reduced motion · history playback unavailable": "減弱動效 · 歷史回放不可用",
|
||||
"Reduced motion · manual history available": "減弱動效 · 可手動瀏覽歷史",
|
||||
"Rain radar · US": "降雨雷達 · 美國",
|
||||
"Lightning density · 15 min": "閃電密度 · 15 分鐘",
|
||||
"Satellite clouds": "衛星雲圖",
|
||||
@@ -2035,12 +2034,8 @@
|
||||
"Radio is disabling…": "電臺正在停用…",
|
||||
"Radio lifecycle is uncertain — use Enable or Disable to reconcile": "電臺生命週期狀態不確定——請使用“啟用”或“停用”進行核對",
|
||||
"Clear reading": "清除讀數",
|
||||
"Earlier observation": "較早觀測",
|
||||
"Observed history": "觀測歷史",
|
||||
"Later observation": "較晚觀測",
|
||||
"Latest": "最新",
|
||||
"Newest frame per product": "每個產品的最新一幀",
|
||||
"Replay observed history": "回放觀測歷史",
|
||||
"Imagery on Esri · Google 3D returns when cleared": "影像顯示在 Esri 底圖上 · 清除後恢復 Google 3D",
|
||||
"Point the camera at the ground to use the view": "將相機對準地面才能使用當前視野",
|
||||
"That point cannot anchor a box": "該點無法作為框選錨點",
|
||||
@@ -2299,7 +2294,6 @@
|
||||
"DETECT": "探測",
|
||||
"{time} · {minutes} min ago": "{time} · {minutes} 分鐘前",
|
||||
"Active weather": "已啟用的天氣圖層",
|
||||
"LATEST · newest per product": "最新 · 每個產品的最新一幀",
|
||||
"Forecast · valid {valid} · issued {issued}": "預報 · 有效時間 {valid} · 發布時間 {issued}",
|
||||
"{detail} · Does not follow history": "{detail} · 不隨觀測歷史變化",
|
||||
"Forecast · valid {valid}": "預報 · 有效時間 {valid}",
|
||||
@@ -3545,5 +3539,23 @@
|
||||
"Funicular": "纜索鐵路",
|
||||
"Gondola": "纜車",
|
||||
"Move panels back beside the rail": "將面板移回側欄旁",
|
||||
"Move panels over the rail, to the edge": "將面板移到側欄上方,貼齊邊緣"
|
||||
"Move panels over the rail, to the edge": "將面板移到側欄上方,貼齊邊緣",
|
||||
"panel|VISUAL": "視覺",
|
||||
"Look": "外觀",
|
||||
"Overlay": "疊加層",
|
||||
"Effects": "效果",
|
||||
"Scope opacity": "視域不透明度",
|
||||
"How dark the scope shades the view outside the keyhole": "視域遮罩使視域之外的畫面變暗的程度",
|
||||
"Reset to default": "還原預設",
|
||||
"Reset Visual to its defaults: Normal look, HUD, scope, labels and effects": "將視覺還原為預設設定:常規外觀、HUD、視域、標籤和效果",
|
||||
"All layers": "全部圖層",
|
||||
"On": "已開啟",
|
||||
"Off": "已關閉",
|
||||
"Search layers": "搜尋圖層",
|
||||
"Filter layers": "篩選圖層",
|
||||
"Status": "狀態",
|
||||
"Search layers…": "搜尋圖層…",
|
||||
"Layer groups": "圖層分組",
|
||||
"Jump to {name}": "跳至{name}",
|
||||
"No layers match": "沒有符合的圖層"
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
import { test, afterEach } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
|
||||
import {
|
||||
onLocaleChange,
|
||||
setLocale,
|
||||
setMessageOverrides,
|
||||
t,
|
||||
tn,
|
||||
translateKnown,
|
||||
} from './index.js';
|
||||
import * as page from './page.js';
|
||||
|
||||
afterEach(() => {
|
||||
setMessageOverrides({});
|
||||
setLocale('en');
|
||||
});
|
||||
|
||||
test('a host shows its own text for a Core message, in English and each locale', () => {
|
||||
setMessageOverrides({
|
||||
en: { 'Download scene JSON': 'Download scene file' },
|
||||
de: { 'Download scene JSON': 'Szenendatei herunterladen' },
|
||||
});
|
||||
assert.equal(t('Download scene JSON'), 'Download scene file');
|
||||
setLocale('de');
|
||||
assert.equal(t('Download scene JSON'), 'Szenendatei herunterladen');
|
||||
// A locale the host did not word shows the host's English, not Core's text.
|
||||
setLocale('fr');
|
||||
assert.equal(t('Download scene JSON'), 'Download scene file');
|
||||
// Messages it does not name stay Core's.
|
||||
assert.equal(t('Share selected scene'), 'Partager la scène sélectionnée');
|
||||
});
|
||||
|
||||
test('overrides interpolate, take contexts and plurals, and reach translateKnown', () => {
|
||||
setMessageOverrides({
|
||||
en: {
|
||||
'Imported {file}': 'Opened {file}',
|
||||
'action|CLEAR': 'WIPE',
|
||||
'{count} cameras': { one: '{count} feed', other: '{count} feeds' },
|
||||
},
|
||||
});
|
||||
assert.equal(t('Imported {file}', { file: 'a.zip' }), 'Opened a.zip');
|
||||
assert.equal(t('CLEAR', { context: 'action' }), 'WIPE');
|
||||
assert.equal(t('CLEAR'), 'CLEAR');
|
||||
assert.equal(tn(1, '{count} camera', '{count} cameras'), '1 feed');
|
||||
assert.equal(tn(3, '{count} camera', '{count} cameras'), '3 feeds');
|
||||
assert.equal(translateKnown('Imported {file}'), 'Opened {file}');
|
||||
// English forms follow English plural rules in any locale.
|
||||
for (const locale of ['ru', 'zh-CN', 'fr']) {
|
||||
setLocale(locale);
|
||||
assert.equal(tn(1, '{count} camera', '{count} cameras'), '1 feed');
|
||||
assert.equal(tn(21, '{count} camera', '{count} cameras'), '21 feeds');
|
||||
assert.equal(tn(0, '{count} camera', '{count} cameras'), '0 feeds');
|
||||
}
|
||||
});
|
||||
|
||||
test('an entry of the wrong kind is ignored, and Core translates', () => {
|
||||
setLocale('ru');
|
||||
const core = {
|
||||
t: t('Share selected scene'),
|
||||
tn: tn(3, '{count} camera', '{count} cameras'),
|
||||
};
|
||||
setMessageOverrides({
|
||||
en: { 'Share selected scene': {}, '{count} cameras': 'cams' },
|
||||
});
|
||||
assert.equal(t('Share selected scene'), core.t);
|
||||
assert.equal(tn(3, '{count} camera', '{count} cameras'), core.tn);
|
||||
});
|
||||
|
||||
test('each call replaces the overrides, words listeners again, and ignores junk', () => {
|
||||
let calls = 0;
|
||||
const stop = onLocaleChange(() => calls++);
|
||||
setMessageOverrides({
|
||||
en: { EXPORT: 'SAVE' },
|
||||
xx: { EXPORT: 'no' },
|
||||
de: null,
|
||||
});
|
||||
assert.equal(t('EXPORT'), 'SAVE');
|
||||
setMessageOverrides({ en: { IMPORT: 'OPEN' } });
|
||||
assert.equal(t('EXPORT'), 'EXPORT');
|
||||
assert.equal(t('IMPORT'), 'OPEN');
|
||||
// An empty entry counts as none.
|
||||
setMessageOverrides({ en: { IMPORT: '' } });
|
||||
assert.equal(t('IMPORT'), 'IMPORT');
|
||||
assert.equal(calls, 3);
|
||||
stop();
|
||||
});
|
||||
|
||||
test('the package entry exports the translator and the overrides', () => {
|
||||
for (const name of [
|
||||
't',
|
||||
'tn',
|
||||
'msg',
|
||||
'translateKnown',
|
||||
'setMessageOverrides',
|
||||
'formatNumber',
|
||||
])
|
||||
assert.equal(typeof page[name], 'function', name);
|
||||
});
|
||||
+15
-1
@@ -5,7 +5,9 @@
|
||||
* page) instead of the globe picker. It starts the language the standalone
|
||||
* application starts, keeps `<html lang>`/`<html dir>` and the page's
|
||||
* `data-i18n` markup in step, and switches in place, stored for the next
|
||||
* visit, exactly as the picker does. Guide: docs/I18N.md.
|
||||
* visit, exactly as the picker does. It also exports the translator itself,
|
||||
* and lets the application show its own text for Core's messages
|
||||
* (`setMessageOverrides`). Guide: docs/I18N.md.
|
||||
*/
|
||||
import {
|
||||
DEFAULT_LOCALE,
|
||||
@@ -33,6 +35,18 @@ export {
|
||||
isRtlLocale,
|
||||
onLocaleChange,
|
||||
};
|
||||
// The translator Core's own text goes through, for an application's text and
|
||||
// for showing its own wording of Core's messages (setMessageOverrides).
|
||||
export {
|
||||
formatDate,
|
||||
formatNumber,
|
||||
formatRelativeTime,
|
||||
msg,
|
||||
setMessageOverrides,
|
||||
t,
|
||||
tn,
|
||||
translateKnown,
|
||||
} from './index.js';
|
||||
|
||||
/**
|
||||
* Start the page in its language: `?lang=`, then the stored choice, then the
|
||||
|
||||
@@ -113,6 +113,7 @@
|
||||
"Layout",
|
||||
"Live",
|
||||
"London",
|
||||
"Look",
|
||||
"Los Angeles",
|
||||
"MIL",
|
||||
"MINI",
|
||||
@@ -140,6 +141,7 @@
|
||||
"Oldies",
|
||||
"OpenStreetMap + optional Google Maps Places",
|
||||
"Operator",
|
||||
"Overlay",
|
||||
"PAUSE",
|
||||
"PLAY",
|
||||
"POS: LIVE",
|
||||
@@ -249,7 +251,8 @@
|
||||
"Regional",
|
||||
"OPT-IN",
|
||||
"{minutes} min",
|
||||
"1 min/s"
|
||||
"1 min/s",
|
||||
"Status"
|
||||
],
|
||||
"es": [
|
||||
"1 min/s",
|
||||
@@ -383,6 +386,7 @@
|
||||
"mph",
|
||||
"nominal",
|
||||
"panel",
|
||||
"panel|VISUAL",
|
||||
"view band|GLOBAL",
|
||||
"voice|ERROR",
|
||||
"{hours} h",
|
||||
@@ -732,6 +736,7 @@
|
||||
"ON",
|
||||
"ON/OFF",
|
||||
"Oldies",
|
||||
"Overlay",
|
||||
"PAYLOAD",
|
||||
"PLAY",
|
||||
"POS: LIVE",
|
||||
@@ -1047,6 +1052,7 @@
|
||||
"mini",
|
||||
"mph",
|
||||
"nominal",
|
||||
"panel|VISUAL",
|
||||
"via {source}",
|
||||
"view band|GLOBAL",
|
||||
"{hours} h",
|
||||
@@ -1270,7 +1276,8 @@
|
||||
"Period",
|
||||
"ICAO: {id}",
|
||||
"NORAD: {id}",
|
||||
"MMSI: {id}"
|
||||
"MMSI: {id}",
|
||||
"Status"
|
||||
],
|
||||
"uk": [
|
||||
"1900–1945",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { fromDegrees } from '../../geo/ellipsoid.js';
|
||||
import { drawOf } from '../../render/rendererOf.js';
|
||||
import { worldClock } from '../../time/worldClock.js';
|
||||
import {
|
||||
EARTHQUAKE_OVERLAY_SOURCE_ID,
|
||||
EARTHQUAKE_OVERLAY_COHORT_LIMIT,
|
||||
@@ -9,6 +10,7 @@ import {
|
||||
createEarthquakeOverlayEntry,
|
||||
selectEarthquakeOverlayCohort,
|
||||
mapAnalystRecord,
|
||||
earthquakeCoverage,
|
||||
} from './model.js';
|
||||
export * from './model.js';
|
||||
export { createUsgsEarthquakeSource } from './source.js';
|
||||
@@ -39,12 +41,25 @@ export function createEarthquakesLayer({ source, overlayHost } = {}) {
|
||||
let _viewer = null;
|
||||
let _request = null;
|
||||
let _discs = null;
|
||||
// What the discs were drawn from, so analyst reads come from the app, not the drawing.
|
||||
let _events = [];
|
||||
let _count = 0;
|
||||
let _lastUpdate = null;
|
||||
let _lastError = null;
|
||||
let _enabled = false;
|
||||
// What the discs were drawn from, so analyst reads come from the layer, not the
|
||||
// drawing, and the timeline reads its marks ({ mag, time, place, usgsId }).
|
||||
let _events = [];
|
||||
let _uncover = null;
|
||||
// The marks last told to the clock, so a refresh with the same strong
|
||||
// quakes does not tell it again.
|
||||
let _marksKey = null;
|
||||
const coverage = () => (_enabled ? earthquakeCoverage(_events) : null);
|
||||
const coverageChanged = () => {
|
||||
const covered = coverage();
|
||||
const key = covered ? JSON.stringify(covered.marks) : null;
|
||||
if (key === _marksKey) return;
|
||||
_marksKey = key;
|
||||
worldClock.coverageChanged();
|
||||
};
|
||||
|
||||
const layer = {
|
||||
id: 'earthquakes',
|
||||
@@ -60,6 +75,10 @@ export function createEarthquakesLayer({ source, overlayHost } = {}) {
|
||||
show: false,
|
||||
});
|
||||
_viewer = viewer;
|
||||
// While on, the strong quakes are marks on the world clock's timeline.
|
||||
// Registered once; off, the layer has no time to show.
|
||||
_marksKey = null;
|
||||
_uncover = worldClock.register({ id: 'earthquakes', coverage });
|
||||
_count = 0;
|
||||
_lastUpdate = null;
|
||||
_lastError = null;
|
||||
@@ -74,6 +93,7 @@ export function createEarthquakesLayer({ source, overlayHost } = {}) {
|
||||
// layer has no per-frame animator to keep the render loop alive for.
|
||||
if (_discs) _discs.show = true;
|
||||
overlayHost.setVisible(EARTHQUAKE_OVERLAY_SOURCE_ID, true);
|
||||
coverageChanged();
|
||||
},
|
||||
|
||||
disable(viewer) {
|
||||
@@ -83,6 +103,7 @@ export function createEarthquakesLayer({ source, overlayHost } = {}) {
|
||||
if (_discs) _discs.show = false;
|
||||
overlayHost.clearSource(EARTHQUAKE_OVERLAY_SOURCE_ID);
|
||||
overlayHost.setVisible(EARTHQUAKE_OVERLAY_SOURCE_ID, false);
|
||||
coverageChanged();
|
||||
},
|
||||
|
||||
async update(viewer) {
|
||||
@@ -146,6 +167,7 @@ export function createEarthquakesLayer({ source, overlayHost } = {}) {
|
||||
|
||||
_discs.set(nextDiscs);
|
||||
_events = nextEvents;
|
||||
coverageChanged();
|
||||
if (_enabled) {
|
||||
overlayHost.setEntries(
|
||||
EARTHQUAKE_OVERLAY_SOURCE_ID,
|
||||
@@ -184,6 +206,9 @@ export function createEarthquakesLayer({ source, overlayHost } = {}) {
|
||||
_discs?.dispose();
|
||||
_discs = null;
|
||||
_events = [];
|
||||
_uncover?.();
|
||||
_uncover = null;
|
||||
_marksKey = null;
|
||||
_count = 0;
|
||||
_lastUpdate = null;
|
||||
_lastError = null;
|
||||
|
||||
@@ -14,6 +14,64 @@ const DEEP = Object.freeze({ rgba: [1, 1, 0, 1], css: 'rgb(255,255,0)' });
|
||||
const depthBand = (depthKm) =>
|
||||
depthKm < 70 ? SHALLOW : depthKm < 300 ? INTERMEDIATE : DEEP;
|
||||
|
||||
/**
|
||||
* The smallest magnitude the timeline marks. Most quakes are small shakes;
|
||||
* M6 and up come about once every two days worldwide, so each is an event
|
||||
* worth stepping to. The map still draws every quake.
|
||||
*/
|
||||
export const EARTHQUAKE_MARK_MAGNITUDE = 6;
|
||||
|
||||
/** The longest place a timeline mark's label carries, ellipsis and all. */
|
||||
const MARK_PLACE_LENGTH = 40;
|
||||
|
||||
/** A magnitude as the map's labels show it: `M6.4`. */
|
||||
export const earthquakeMagnitudeTitle = (magnitude) =>
|
||||
`M${Number(magnitude).toFixed(1)}`;
|
||||
|
||||
/**
|
||||
* A strong quake's timeline label: its magnitude and, where the feed names
|
||||
* one, its place, cut short (`M6.4 · 113 km SSE of Lata, Solomon Islands`).
|
||||
* @param {{mag: number, place?: string | null}} event
|
||||
* @returns {string}
|
||||
*/
|
||||
export function earthquakeMarkLabel({ mag, place }) {
|
||||
const title = earthquakeMagnitudeTitle(mag);
|
||||
const where =
|
||||
typeof place === 'string' ? place.replace(/\s+/g, ' ').trim() : '';
|
||||
if (!where) return title;
|
||||
const short =
|
||||
where.length > MARK_PLACE_LENGTH
|
||||
? `${where.slice(0, MARK_PLACE_LENGTH - 1).trimEnd()}…`
|
||||
: where;
|
||||
return `${title} · ${short}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* The time a world clock's timeline can show for `events` (`{mag, time,
|
||||
* place?, usgsId?}`, time in ms): the span of the quakes of
|
||||
* EARTHQUAKE_MARK_MAGNITUDE and up, each one a mark labelled with its
|
||||
* magnitude and place, or null with none, so the layer never stretches the
|
||||
* timeline past what its feed covers.
|
||||
* @returns {{start: number, end: number, marks: Array<{time: number, label: string, id?: string, kind: string}>} | null}
|
||||
*/
|
||||
export function earthquakeCoverage(events) {
|
||||
const marks = events
|
||||
.filter(
|
||||
({ mag, time }) =>
|
||||
mag >= EARTHQUAKE_MARK_MAGNITUDE && Number.isFinite(time),
|
||||
)
|
||||
.map((event) => ({
|
||||
time: event.time,
|
||||
label: earthquakeMarkLabel(event),
|
||||
...(event.usgsId ? { id: String(event.usgsId) } : {}),
|
||||
kind: 'earthquake',
|
||||
}))
|
||||
.sort((a, b) => a.time - b.time);
|
||||
return marks.length
|
||||
? { start: marks[0].time, end: marks.at(-1).time, marks }
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Color by depth, as a renderer colour `[r, g, b, a]` (0..1):
|
||||
* - Shallow (<70km): Red
|
||||
@@ -50,7 +108,7 @@ export function createEarthquakeOverlayEntry({
|
||||
id: String(id),
|
||||
position,
|
||||
variant: 'label',
|
||||
title: `M${mag.toFixed(1)}`,
|
||||
title: earthquakeMagnitudeTitle(mag),
|
||||
accent,
|
||||
priority: Math.round(mag * 1000),
|
||||
collisionGroup: 'ambient-label',
|
||||
|
||||
@@ -3,6 +3,8 @@ import test from 'node:test';
|
||||
import { createEarthquakesLayer } from './index.js';
|
||||
import { createUsgsEarthquakeSource } from './source.js';
|
||||
import { bindFakeDraw } from '../../testSupport/fakeDrawPort.mjs';
|
||||
import { EARTHQUAKE_MARK_MAGNITUDE, earthquakeMarkLabel } from './model.js';
|
||||
import { worldClock } from '../../time/worldClock.js';
|
||||
function harness(source) {
|
||||
const events = [];
|
||||
const viewer = {};
|
||||
@@ -168,3 +170,72 @@ test('a viewer with nothing to draw with is refused at init, and init can be ret
|
||||
layer.destroy();
|
||||
unbind();
|
||||
});
|
||||
|
||||
test('the timeline marks only strong quakes, while the layer is on', async () => {
|
||||
assert.equal(EARTHQUAKE_MARK_MAGNITUDE, 6);
|
||||
const rows = [
|
||||
{ ...row, stableId: 'small', mag: 4.5, time: 1_000 },
|
||||
{ ...row, stableId: 'strong', usgsId: 'us-strong', mag: 6, time: 5_000 },
|
||||
{
|
||||
...row,
|
||||
stableId: 'great',
|
||||
usgsId: 'us-great',
|
||||
mag: 7.2,
|
||||
place: ' 113 km SSE of Lata, Solomon Islands region of the Pacific ',
|
||||
time: 3_000,
|
||||
},
|
||||
{ ...row, stableId: 'untimed', mag: 6.5, time: null },
|
||||
];
|
||||
let snapshot = rows;
|
||||
const h = harness({ getSnapshot: async () => snapshot });
|
||||
assert.equal(worldClock.coverage(), null, 'nothing loaded, no time to show');
|
||||
let changes = 0;
|
||||
const unsubscribe = worldClock.subscribe(() => changes++);
|
||||
await h.layer.update(h.viewer);
|
||||
// Every quake is drawn; only M6 and up are marks, spanning their own time.
|
||||
assert.equal(h.draw.find('earthquakes:').items.size, 4);
|
||||
// Each labelled with its magnitude and, cut short, its place.
|
||||
assert.deepEqual(worldClock.coverage(), {
|
||||
start: 3_000,
|
||||
end: 5_000,
|
||||
marks: [3_000, 5_000],
|
||||
markDetails: [
|
||||
{
|
||||
time: 3_000,
|
||||
label: 'M7.2 · 113 km SSE of Lata, Solomon Islands reg…',
|
||||
id: 'us-great',
|
||||
kind: 'earthquake',
|
||||
},
|
||||
{
|
||||
time: 5_000,
|
||||
label: 'M6.0 · Fixture',
|
||||
id: 'us-strong',
|
||||
kind: 'earthquake',
|
||||
},
|
||||
],
|
||||
});
|
||||
const told = changes;
|
||||
await h.layer.update(h.viewer);
|
||||
assert.equal(changes, told, 'the same strong quakes are not told again');
|
||||
snapshot = rows.slice(0, 1);
|
||||
await h.layer.update(h.viewer);
|
||||
assert.equal(worldClock.coverage(), null, 'small shakes alone cover no time');
|
||||
snapshot = rows;
|
||||
await h.layer.update(h.viewer);
|
||||
h.layer.disable(h.viewer);
|
||||
assert.equal(worldClock.coverage(), null, 'off, no time to show');
|
||||
h.layer.enable(h.viewer);
|
||||
assert.deepEqual(worldClock.coverage().marks, [3_000, 5_000]);
|
||||
h.layer.destroy();
|
||||
assert.equal(worldClock.coverage(), null);
|
||||
unsubscribe();
|
||||
});
|
||||
|
||||
test('a strong quake with no place is labelled with its magnitude alone', () => {
|
||||
assert.equal(earthquakeMarkLabel({ mag: 6.44, place: null }), 'M6.4');
|
||||
assert.equal(earthquakeMarkLabel({ mag: 6, place: ' ' }), 'M6.0');
|
||||
assert.equal(
|
||||
earthquakeMarkLabel({ mag: 8.1, place: 'Off the coast' }),
|
||||
'M8.1 · Off the coast',
|
||||
);
|
||||
});
|
||||
@@ -147,6 +147,9 @@ function restoreCameraView(viewer, view, landedView) {
|
||||
camera.setView(view);
|
||||
}
|
||||
|
||||
/** The longest name a timeline mark carries, as in the mission index. */
|
||||
const MARK_LABEL_LENGTH = 27;
|
||||
|
||||
export function createLifecycle({
|
||||
state: layerState,
|
||||
services,
|
||||
@@ -156,18 +159,30 @@ export function createLifecycle({
|
||||
const { holdContinuousRender, releaseContinuousRender } = services.render;
|
||||
let hover = null;
|
||||
// While on, the launches loaded span the time from the first to the last,
|
||||
// each one a mark. Registered once; off, the layer has no time to show, and
|
||||
// each step tells the clock once it has settled.
|
||||
// each one a mark labelled with its mission's name (the launch's where it
|
||||
// has none), cut short and in capitals as the mission index shows names.
|
||||
// Registered once; off, the layer has no time to show, and each step tells
|
||||
// the clock once it has settled.
|
||||
worldClock.register({
|
||||
id: 'rocket-launches',
|
||||
coverage: () => {
|
||||
if (!layerState._enabled) return null;
|
||||
const marks = layerState._launches
|
||||
.map((launch) => Date.parse(launch.launchTime))
|
||||
.filter(Number.isFinite)
|
||||
.sort((a, b) => a - b);
|
||||
.map((launch) => ({
|
||||
time: Date.parse(launch.launchTime),
|
||||
label: parts.overlays
|
||||
.shortMissionLabel(
|
||||
launch.missionName || launch.name,
|
||||
MARK_LABEL_LENGTH,
|
||||
)
|
||||
.toUpperCase(),
|
||||
...(launch.id != null ? { id: String(launch.id) } : {}),
|
||||
kind: 'launch',
|
||||
}))
|
||||
.filter(({ time }) => Number.isFinite(time))
|
||||
.sort((a, b) => a.time - b.time);
|
||||
if (!marks.length) return null;
|
||||
return { start: marks[0], end: marks.at(-1), marks };
|
||||
return { start: marks[0].time, end: marks.at(-1).time, marks };
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
+45
-155
@@ -59,34 +59,36 @@ export const PLAY_WAIT_MS = 8_000;
|
||||
// costs play nothing.
|
||||
|
||||
let clocks = 0;
|
||||
// How many weather clocks follow each world clock.
|
||||
const followers = new WeakMap();
|
||||
|
||||
/**
|
||||
* Transient observed time. Products must honor the signal before installing a
|
||||
* frame. Its time is the world clock's: latest while the world is live,
|
||||
* history at the world's time otherwise. Replay steps the observed frames and
|
||||
* moves the world clock as it goes, as the world clock's driver.
|
||||
* history at the world's time otherwise. It never moves the world clock
|
||||
* itself; the world's own controls (its timeline) move time, and while the
|
||||
* world plays it stops at each next frame until that frame loads.
|
||||
*
|
||||
* `shared` (the default) is a clock several layers share, such as the
|
||||
* catalog's: the last shared clock destroyed leaves the world live. A clock
|
||||
* one layer keeps for itself (`shared: false`) leaves the world's time where
|
||||
* it is.
|
||||
*/
|
||||
export function createWeatherClock({
|
||||
now = Date.now,
|
||||
setTimeout = globalThis.setTimeout,
|
||||
clearTimeout = globalThis.clearTimeout,
|
||||
world = createWorldClock({ now }),
|
||||
shared = true,
|
||||
} = {}) {
|
||||
const registry = new Map();
|
||||
const listeners = new Set();
|
||||
let mode = 'latest';
|
||||
let target = null;
|
||||
let playing = false;
|
||||
// The world time last applied; while this clock moves the world, the
|
||||
// transition its move started.
|
||||
// The world time last applied.
|
||||
let seen = 'latest';
|
||||
let moving = false;
|
||||
let moved = null;
|
||||
const releases = new Map();
|
||||
// Attached at the end, once the API exists.
|
||||
let driver = null;
|
||||
let generation = 0;
|
||||
let timer = null;
|
||||
let pending = null;
|
||||
// This clock's name on the world, for its holds and its gate.
|
||||
const holdId = `weather:${++clocks}`;
|
||||
@@ -147,10 +149,9 @@ export function createWeatherClock({
|
||||
const getState = () => ({
|
||||
mode,
|
||||
target,
|
||||
playing,
|
||||
// Frames come on one after another: this clock replays them, or the world
|
||||
// plays on through them, so the next is worth loading ahead.
|
||||
advancing: playing || worldPlaysOn(),
|
||||
// Frames come on one after another as the world plays on through them,
|
||||
// so the next is worth loading ahead.
|
||||
advancing: worldPlaysOn(),
|
||||
timeline: getTimeline(),
|
||||
products: [...registry.values()].map(({ product }) => ({
|
||||
id: product.id,
|
||||
@@ -162,60 +163,12 @@ export function createWeatherClock({
|
||||
const notify = () => {
|
||||
if (!destroyed) for (const listener of listeners) listener(getState());
|
||||
};
|
||||
const cancelTimer = () => {
|
||||
if (timer !== null) clearTimeout(timer);
|
||||
timer = null;
|
||||
};
|
||||
const canPlay = () => getTimeline().length >= 2;
|
||||
const stopPlaying = () => {
|
||||
if (!playing) return;
|
||||
playing = false;
|
||||
driver?.driven(false);
|
||||
};
|
||||
// Move the world clock; the change comes back through followWorld. Returns
|
||||
// the transition the move started, if it started one.
|
||||
const move = (fn) => {
|
||||
const outer = [moving, moved];
|
||||
moving = true;
|
||||
moved = null;
|
||||
try {
|
||||
fn();
|
||||
return moved;
|
||||
} finally {
|
||||
[moving, moved] = outer;
|
||||
}
|
||||
};
|
||||
const selections = () =>
|
||||
[...registry.values()].map(({ product }) => selectedFor(product)).join();
|
||||
let applied = null;
|
||||
function schedule() {
|
||||
cancelTimer();
|
||||
if (!playing || destroyed || pending) return;
|
||||
if (!canPlay()) {
|
||||
stopPlaying();
|
||||
notify();
|
||||
return;
|
||||
}
|
||||
const owner = generation;
|
||||
timer = setTimeout(() => {
|
||||
timer = null;
|
||||
if (destroyed || !playing || owner !== generation) return;
|
||||
const timeline = getTimeline();
|
||||
if (timeline.length < 2) {
|
||||
api.pause();
|
||||
return;
|
||||
}
|
||||
const next = timeline.find(
|
||||
(time) => Date.parse(time) > Date.parse(target),
|
||||
);
|
||||
void api.setTarget(next ?? timeline[0]);
|
||||
}, 2000);
|
||||
}
|
||||
function transition() {
|
||||
if (destroyed) return Promise.resolve(false);
|
||||
cancelTimer();
|
||||
const owner = ++generation;
|
||||
if (!canPlay()) stopPlaying();
|
||||
// A scrub drops what loads and moves on; play goes on as this loads.
|
||||
applied = selections();
|
||||
deferred = false;
|
||||
@@ -235,15 +188,12 @@ export function createWeatherClock({
|
||||
if (destroyed || owner !== generation) return false;
|
||||
stopWaiting();
|
||||
pending = null;
|
||||
if (!canPlay()) stopPlaying();
|
||||
notify();
|
||||
schedule();
|
||||
// Play held at the next frame for this one goes on to it.
|
||||
if (deferred) void transition();
|
||||
return true;
|
||||
});
|
||||
pending = result;
|
||||
if (moving) moved ??= result;
|
||||
notify();
|
||||
return result;
|
||||
}
|
||||
@@ -254,11 +204,13 @@ export function createWeatherClock({
|
||||
throw new Error(`Duplicate weather product: ${product.id}`);
|
||||
const entry = { product, controller: null };
|
||||
registry.set(product.id, entry);
|
||||
// The product moves with the world clock, and its frames are time the
|
||||
// world clock's timeline can show while it is on, suspended or not, so
|
||||
// the way back to live stays on screen. Both calls notify the world's
|
||||
// listeners, which may destroy this clock: the release is in place
|
||||
// first, and anything acquired after a destroy is let go at once.
|
||||
// The product moves with the world clock, and the span of its frames is
|
||||
// time the world clock's timeline can show while it is on, suspended or
|
||||
// not, so the way back to live stays on screen. The frames are not
|
||||
// marks: they come every few minutes, and the timeline marks only
|
||||
// events. Both calls notify the world's listeners, which may destroy
|
||||
// this clock: the release is in place first, and anything acquired
|
||||
// after a destroy is let go at once.
|
||||
let unhold = null;
|
||||
let uncover = null;
|
||||
const release = () => {
|
||||
@@ -272,9 +224,12 @@ export function createWeatherClock({
|
||||
uncover = world.register({
|
||||
id: product.id,
|
||||
coverage: () => {
|
||||
const marks = timesFor(product).map((time) => Date.parse(time));
|
||||
return marks.length
|
||||
? { start: marks[0], end: marks.at(-1), marks }
|
||||
const times = timesFor(product);
|
||||
return times.length
|
||||
? {
|
||||
start: Date.parse(times[0]),
|
||||
end: Date.parse(times.at(-1)),
|
||||
}
|
||||
: null;
|
||||
},
|
||||
});
|
||||
@@ -300,81 +255,17 @@ export function createWeatherClock({
|
||||
* wind, gives that layer the timeline time rather than the live edge.
|
||||
*/
|
||||
follows: (id) => world.follows(id),
|
||||
setTarget(time) {
|
||||
if (destroyed) return Promise.resolve(false);
|
||||
if (!Number.isFinite(Date.parse(time)))
|
||||
throw new TypeError('Weather target must be a UTC time');
|
||||
const normalized = new Date(time).toISOString();
|
||||
if (mode === 'history' && target === normalized)
|
||||
return pending ?? Promise.resolve(true);
|
||||
return (
|
||||
move(() => world.seek(Date.parse(normalized))) ??
|
||||
pending ??
|
||||
Promise.resolve(true)
|
||||
);
|
||||
},
|
||||
step(direction) {
|
||||
if (destroyed || ![-1, 1].includes(direction))
|
||||
return Promise.resolve(false);
|
||||
api.pause();
|
||||
const timeline = getTimeline();
|
||||
if (!timeline.length) return Promise.resolve(false);
|
||||
const at = Date.parse(target ?? timeline.at(-1));
|
||||
const next =
|
||||
direction < 0
|
||||
? (timeline.findLast((time) => Date.parse(time) < at) ?? timeline[0])
|
||||
: (timeline.find((time) => Date.parse(time) > at) ?? timeline.at(-1));
|
||||
return api.setTarget(next);
|
||||
},
|
||||
latest() {
|
||||
if (destroyed) return Promise.resolve(false);
|
||||
stopPlaying();
|
||||
if (mode === 'latest') return transition();
|
||||
return move(() => world.goLive()) ?? pending ?? Promise.resolve(true);
|
||||
},
|
||||
play() {
|
||||
if (destroyed || playing || !canPlay())
|
||||
return pending ?? Promise.resolve(false);
|
||||
playing = true;
|
||||
if (mode === 'latest') {
|
||||
const timeline = getTimeline();
|
||||
const start =
|
||||
timeline.findLast((time) => Date.parse(time) <= now()) ?? timeline[0];
|
||||
// Playing and at the first frame in one move of the world.
|
||||
return (
|
||||
move(() => driver.driven(true, Date.parse(start))) ??
|
||||
pending ??
|
||||
Promise.resolve(true)
|
||||
);
|
||||
}
|
||||
driver.driven(true);
|
||||
notify();
|
||||
schedule();
|
||||
return pending ?? Promise.resolve(true);
|
||||
},
|
||||
pause() {
|
||||
cancelTimer();
|
||||
if (!playing) {
|
||||
// The world may be playing on its own; a pause or step here holds it.
|
||||
if (world.isPlaying()) world.pause();
|
||||
return;
|
||||
}
|
||||
stopPlaying();
|
||||
notify();
|
||||
},
|
||||
togglePlay() {
|
||||
return playing ? api.pause() : api.play();
|
||||
},
|
||||
/**
|
||||
* The world clock this clock follows. Time moves there, through the same
|
||||
* seek, play and live the world's timeline uses, never through this clock.
|
||||
*/
|
||||
world,
|
||||
refresh() {
|
||||
if (destroyed) return Promise.resolve(false);
|
||||
// New frames, or products added or dropped, and with them the next.
|
||||
world.coverageChanged();
|
||||
gated = undefined;
|
||||
gateNext(world.getState());
|
||||
if (!canPlay()) {
|
||||
stopPlaying();
|
||||
cancelTimer();
|
||||
}
|
||||
if (mode === 'history') return transition();
|
||||
notify();
|
||||
return Promise.resolve(true);
|
||||
@@ -386,15 +277,18 @@ export function createWeatherClock({
|
||||
},
|
||||
destroy() {
|
||||
if (destroyed) return;
|
||||
stopPlaying();
|
||||
destroyed = true;
|
||||
++generation;
|
||||
stopWaiting();
|
||||
world.gate(holdId, null);
|
||||
cancelTimer();
|
||||
unfollowWorld();
|
||||
// The last weather clock leaves the world live, as a new one expects.
|
||||
if (driver.detach() === 0) world.goLive();
|
||||
// The last shared weather clock leaves the world live, as a new one
|
||||
// expects.
|
||||
if (shared) {
|
||||
const left = followers.get(world) - 1;
|
||||
followers.set(world, left);
|
||||
if (left === 0) world.goLive();
|
||||
}
|
||||
for (const release of releases.values()) release();
|
||||
releases.clear();
|
||||
for (const entry of registry.values()) entry.controller?.abort();
|
||||
@@ -403,9 +297,8 @@ export function createWeatherClock({
|
||||
pending = null;
|
||||
},
|
||||
};
|
||||
// Follow the world clock. A move of this clock's own always applies; one
|
||||
// from elsewhere (a host's seek, continuous play) applies only when it
|
||||
// changes the mode or a product's frame.
|
||||
// Follow the world clock. A move (a seek, play going on) applies only when
|
||||
// it changes the mode or a product's frame.
|
||||
function followWorld(state) {
|
||||
if (destroyed) return;
|
||||
gateNext(state);
|
||||
@@ -426,7 +319,7 @@ export function createWeatherClock({
|
||||
const modeChanged = nextMode !== mode;
|
||||
mode = nextMode;
|
||||
target = nextTarget;
|
||||
if (!moving && !modeChanged && selections() === applied) {
|
||||
if (!modeChanged && selections() === applied) {
|
||||
// Back at the frame that loads, play need not hold for it.
|
||||
if (deferred) {
|
||||
deferred = false;
|
||||
@@ -439,7 +332,7 @@ export function createWeatherClock({
|
||||
}
|
||||
// Playing on into the next frame while the one before it loads, the
|
||||
// world holds here until that one shows.
|
||||
if (!moving && !modeChanged && pending && playsOn) {
|
||||
if (!modeChanged && pending && playsOn) {
|
||||
deferred = true;
|
||||
startWaiting();
|
||||
notify();
|
||||
@@ -462,10 +355,7 @@ export function createWeatherClock({
|
||||
world.gate(holdId, next);
|
||||
}
|
||||
const unfollowWorld = world.subscribe(followWorld);
|
||||
driver = world.attachDriver({
|
||||
play: () => (canPlay() ? void api.play() : false),
|
||||
pause: () => api.pause(),
|
||||
});
|
||||
if (shared) followers.set(world, (followers.get(world) ?? 0) + 1);
|
||||
followWorld(world.getState());
|
||||
return api;
|
||||
}
|
||||
@@ -158,13 +158,16 @@ test('a product’s gap is at least one and a half of its feed’s frame spacing
|
||||
assert.equal(clock.selectFor('clouds', time(211)), null);
|
||||
});
|
||||
|
||||
test('history applies per-product selections, including null; latest restores unequal newest times', async (t) => {
|
||||
const { clock } = harness(t);
|
||||
const at = (minutes) => Date.parse(time(minutes));
|
||||
|
||||
test('history applies per-product selections, including null; live restores unequal newest times', async (t) => {
|
||||
const { clock, world } = harness(t);
|
||||
const radar = product('radar', [0, 10, 20]);
|
||||
const satellite = product('satellite', [5, 15]);
|
||||
const lightning = product('lightning', [15]);
|
||||
for (const p of [radar, satellite, lightning]) clock.register(p);
|
||||
await clock.setTarget(time(10));
|
||||
world.seek(at(10));
|
||||
await flush();
|
||||
assert.deepEqual(
|
||||
[radar.shown, satellite.shown, lightning.shown],
|
||||
[time(10), time(5), null],
|
||||
@@ -173,18 +176,19 @@ test('history applies per-product selections, including null; latest restores un
|
||||
clock.getState().products.map(({ selected }) => selected),
|
||||
[time(10), time(5), null],
|
||||
);
|
||||
await clock.latest();
|
||||
world.goLive();
|
||||
await flush();
|
||||
assert.deepEqual(
|
||||
[radar.shown, satellite.shown, lightning.shown],
|
||||
[time(20), time(15), time(15)],
|
||||
);
|
||||
assert.equal(clock.getState().mode, 'latest');
|
||||
assert.equal(clock.getState().target, null);
|
||||
assert.equal(clock.getState().playing, false);
|
||||
assert.equal(clock.getState().advancing, false);
|
||||
});
|
||||
|
||||
test('superseded completions cannot commit, notify or schedule a new playback advance', async (t) => {
|
||||
const { clock, timers } = harness(t);
|
||||
test('superseded completions cannot commit or notify', async (t) => {
|
||||
const { clock, world, timers } = harness(t);
|
||||
const p = product('radar', [0, 10, 20]);
|
||||
const loads = [];
|
||||
p.apply = (selected, { signal }) =>
|
||||
@@ -201,113 +205,44 @@ test('superseded completions cannot commit, notify or schedule a new playback ad
|
||||
clock.register(p);
|
||||
let notifications = 0;
|
||||
clock.subscribe(() => notifications++);
|
||||
const old = clock.setTarget(time(0));
|
||||
world.seek(at(0));
|
||||
await flush();
|
||||
const current = clock.setTarget(time(10));
|
||||
world.seek(at(10));
|
||||
await flush();
|
||||
assert.equal(loads[0].signal.aborted, true);
|
||||
loads[1].finish();
|
||||
assert.equal(await current, true);
|
||||
await flush();
|
||||
const count = notifications;
|
||||
loads[0].finish();
|
||||
assert.equal(await old, false);
|
||||
await flush();
|
||||
assert.equal(notifications, count);
|
||||
assert.equal(p.shown, time(10));
|
||||
assert.equal(clock.getState().target, time(10));
|
||||
assert.equal(timers.size, 0);
|
||||
});
|
||||
|
||||
test('steps use strict union neighbours from arbitrary targets and clamp at endpoints', async (t) => {
|
||||
const { clock } = harness(t);
|
||||
clock.register(product('radar', [0, 10, 20]));
|
||||
clock.register(product('satellite', [5, 15]));
|
||||
await clock.step(-1);
|
||||
assert.equal(clock.getState().target, time(15));
|
||||
await clock.setTarget(time(12));
|
||||
await clock.step(-1);
|
||||
assert.equal(clock.getState().target, time(10));
|
||||
await clock.setTarget(time(12));
|
||||
await clock.step(1);
|
||||
assert.equal(clock.getState().target, time(15));
|
||||
await clock.setTarget(time(0));
|
||||
await clock.step(-1);
|
||||
assert.equal(clock.getState().target, time(0));
|
||||
await clock.setTarget(time(20));
|
||||
await clock.step(1);
|
||||
assert.equal(clock.getState().target, time(20));
|
||||
});
|
||||
|
||||
test('playback waits for every product to settle, including rejection, then waits 2000 ms and wraps', async (t) => {
|
||||
const { clock, tick, timers } = harness(t);
|
||||
const a = product('radar', [0, 10]);
|
||||
const b = product('satellite', [5]);
|
||||
const loads = [];
|
||||
b.apply = () =>
|
||||
new Promise((resolve, reject) => loads.push({ resolve, reject }));
|
||||
clock.register(a);
|
||||
clock.register(b);
|
||||
const start = clock.play();
|
||||
await flush();
|
||||
assert.equal(clock.getState().target, time(10));
|
||||
tick(10_000);
|
||||
assert.equal(timers.size, 0);
|
||||
assert.equal(a.calls.length, 1);
|
||||
loads[0].reject(new Error('unavailable'));
|
||||
await start;
|
||||
assert.equal(timers.size, 1);
|
||||
tick(1999);
|
||||
assert.equal(clock.getState().target, time(10));
|
||||
tick(1);
|
||||
await flush();
|
||||
assert.equal(clock.getState().target, time(0));
|
||||
assert.equal(timers.size, 0);
|
||||
tick(10_000);
|
||||
assert.equal(clock.getState().target, time(0));
|
||||
loads[1].resolve(true);
|
||||
await flush();
|
||||
tick(2000);
|
||||
await flush();
|
||||
assert.equal(clock.getState().target, time(5));
|
||||
clock.pause();
|
||||
loads[2].resolve(false);
|
||||
await flush();
|
||||
assert.equal(timers.size, 0, 'pausing during a load prevents rescheduling');
|
||||
});
|
||||
|
||||
test('pause cancels a pending advance; playback stops with one time or all products suspended', async (t) => {
|
||||
const { clock, tick, timers } = harness(t);
|
||||
const p = product('radar', [0, 10]);
|
||||
clock.register(p);
|
||||
await clock.play();
|
||||
await clock.play();
|
||||
assert.equal(timers.size, 1);
|
||||
clock.pause();
|
||||
tick(2000);
|
||||
assert.equal(clock.getState().target, time(10));
|
||||
assert.equal(timers.size, 0);
|
||||
await clock.togglePlay();
|
||||
p.times = [time(0)];
|
||||
await clock.refresh();
|
||||
assert.equal(clock.getState().playing, false);
|
||||
await clock.play();
|
||||
assert.equal(clock.getState().playing, false);
|
||||
p.times = [time(0), time(10)];
|
||||
await clock.refresh();
|
||||
await clock.play();
|
||||
p.suspended = true;
|
||||
await clock.refresh();
|
||||
assert.equal(clock.getState().playing, false);
|
||||
assert.deepEqual(clock.getTimeline(), []);
|
||||
assert.equal(timers.size, 0);
|
||||
test('the clock has no time controls of its own; the world clock moves time', (t) => {
|
||||
const { clock, world } = harness(t);
|
||||
for (const name of [
|
||||
'setTarget',
|
||||
'step',
|
||||
'latest',
|
||||
'play',
|
||||
'pause',
|
||||
'togglePlay',
|
||||
])
|
||||
assert.equal(clock[name], undefined, name);
|
||||
assert.equal(clock.world, world);
|
||||
});
|
||||
|
||||
test('refresh does not apply in latest; history retains its target as expired frames disappear', async (t) => {
|
||||
const { clock } = harness(t);
|
||||
const { clock, world } = harness(t);
|
||||
const p = product('radar', [0, 10]);
|
||||
clock.register(p);
|
||||
await clock.refresh();
|
||||
assert.equal(p.calls.length, 0);
|
||||
await clock.setTarget(time(10));
|
||||
world.seek(at(10));
|
||||
await flush();
|
||||
p.times = [time(0), time(20)];
|
||||
await clock.refresh();
|
||||
assert.equal(p.shown, time(0));
|
||||
@@ -318,15 +253,16 @@ test('refresh does not apply in latest; history retains its target as expired fr
|
||||
});
|
||||
|
||||
test('registration joins history; unregister and destroy abort work and release subscriptions/timers', async (t) => {
|
||||
const { clock, timers, tick } = harness(t);
|
||||
const { clock, world, timers } = harness(t);
|
||||
const p = product('radar', [0, 10]);
|
||||
const unregister = clock.register(p);
|
||||
await clock.setTarget(time(0));
|
||||
world.seek(at(0));
|
||||
await flush();
|
||||
const b = product('satellite', [0, 5]);
|
||||
clock.register(b);
|
||||
await flush();
|
||||
assert.equal(b.shown, time(0));
|
||||
await clock.play();
|
||||
world.seek(at(5));
|
||||
unregister();
|
||||
unregister();
|
||||
await flush();
|
||||
@@ -337,31 +273,27 @@ test('registration joins history; unregister and destroy abort work and release
|
||||
);
|
||||
let notifications = 0;
|
||||
const off = clock.subscribe(() => notifications++);
|
||||
clock.pause();
|
||||
off();
|
||||
const before = notifications;
|
||||
await clock.play();
|
||||
assert.equal(notifications, before);
|
||||
world.seek(at(0));
|
||||
await flush();
|
||||
assert.equal(notifications, 0);
|
||||
world.seek(at(5));
|
||||
clock.destroy();
|
||||
clock.destroy();
|
||||
tick(2000);
|
||||
await flush();
|
||||
assert.equal(timers.size, 0);
|
||||
assert.equal(b.calls.at(-1).signal.aborted, true);
|
||||
assert.equal(clock.getState().playing, false);
|
||||
assert.deepEqual(clock.getTimeline(), []);
|
||||
assert.equal(await clock.setTarget(time(5)), false);
|
||||
});
|
||||
|
||||
test('the weather time is the world time, both ways', async (t) => {
|
||||
test('the weather time is the world time', async (t) => {
|
||||
const { clock, world } = harness(t);
|
||||
const radar = product('radar', [0, 10, 20]);
|
||||
clock.register(radar);
|
||||
assert.equal(world.follows('radar'), true);
|
||||
await clock.setTarget(time(10));
|
||||
assert.equal(world.isLive(), false);
|
||||
assert.equal(world.now(), Date.parse(time(10)));
|
||||
world.seek(Date.parse(time(3)));
|
||||
world.seek(at(3));
|
||||
await flush();
|
||||
assert.equal(clock.getState().mode, 'history');
|
||||
assert.equal(clock.getState().target, time(3));
|
||||
assert.equal(radar.shown, time(0));
|
||||
world.goLive();
|
||||
@@ -370,30 +302,22 @@ test('the weather time is the world time, both ways', async (t) => {
|
||||
assert.equal(radar.shown, time(20));
|
||||
});
|
||||
|
||||
test('world play and pause drive the weather replay', async (t) => {
|
||||
test('world play runs the world on its own at its rate; weather does not drive it', async (t) => {
|
||||
const { clock, world, tick } = harness(t);
|
||||
const radar = product('radar', [0, 10, 20]);
|
||||
clock.register(radar);
|
||||
world.seek(Date.parse(time(0)));
|
||||
world.seek(at(0));
|
||||
await flush();
|
||||
world.play();
|
||||
assert.equal(clock.getState().playing, true);
|
||||
assert.equal(world.isPlaying(), true);
|
||||
tick(2000);
|
||||
world.play({ rate: 60 });
|
||||
assert.equal(world.getState().stepping, false);
|
||||
assert.equal(clock.getState().advancing, true);
|
||||
tick(5_000);
|
||||
assert.equal(world.now(), at(5), 'five minutes on at a minute a second');
|
||||
tick(10_000);
|
||||
await flush();
|
||||
assert.equal(radar.shown, time(10));
|
||||
assert.equal(world.now(), Date.parse(time(10)));
|
||||
assert.equal(world.now(), at(10), 'held at the next frame');
|
||||
world.pause();
|
||||
assert.equal(clock.getState().playing, false);
|
||||
clock.play();
|
||||
assert.equal(world.isPlaying(), true);
|
||||
clock.pause();
|
||||
assert.equal(world.isPlaying(), false);
|
||||
clock.play();
|
||||
world.goLive();
|
||||
await flush();
|
||||
assert.equal(clock.getState().playing, false);
|
||||
assert.equal(clock.getState().mode, 'latest');
|
||||
assert.equal(clock.getState().advancing, false);
|
||||
});
|
||||
|
||||
test('a moving world re-applies frames only when a product changes frame', async (t) => {
|
||||
@@ -416,15 +340,6 @@ test('a moving world re-applies frames only when a product changes frame', async
|
||||
assert.equal(radar.shown, time(10));
|
||||
});
|
||||
|
||||
test('a world without frames to step plays on its own', async (t) => {
|
||||
const { clock, world, tick } = harness(t);
|
||||
world.seek(Date.parse(time(0)));
|
||||
world.play();
|
||||
assert.equal(clock.getState().playing, false);
|
||||
tick(1000);
|
||||
assert.equal(world.now(), Date.parse(time(0)) + 1000);
|
||||
});
|
||||
|
||||
function worldAt(at) {
|
||||
return createWorldClock({
|
||||
now: () => at,
|
||||
@@ -434,74 +349,25 @@ function worldAt(at) {
|
||||
});
|
||||
}
|
||||
|
||||
test('weather clocks sharing a world hand play over, and the last leaves it live', async () => {
|
||||
test('weather clocks sharing a world: the last one destroyed leaves it live', () => {
|
||||
const world = worldAt(Date.parse(time(20)));
|
||||
const a = createWeatherClock({ world, now: () => Date.parse(time(20)) });
|
||||
const b = createWeatherClock({ world, now: () => Date.parse(time(20)) });
|
||||
const radarA = product('radar', [0, 10, 20]);
|
||||
const radarB = product('radar', [0, 10, 20]);
|
||||
a.register(radarA);
|
||||
b.register(radarB);
|
||||
await a.play();
|
||||
assert.equal(world.isPlaying(), true);
|
||||
world.pause();
|
||||
assert.equal(a.getState().playing, false);
|
||||
assert.equal(world.isPlaying(), false);
|
||||
await a.play();
|
||||
world.goLive();
|
||||
assert.equal(a.getState().playing, false);
|
||||
b.destroy();
|
||||
assert.equal(world.follows('radar'), true);
|
||||
a.register(product('radar', [0, 10, 20]));
|
||||
b.register(product('radar', [0, 10, 20]));
|
||||
world.seek(Date.parse(time(0)));
|
||||
world.play();
|
||||
assert.equal(a.getState().playing, true);
|
||||
b.destroy();
|
||||
assert.equal(world.follows('radar'), true);
|
||||
assert.equal(world.isLive(), false);
|
||||
assert.equal(world.isPlaying(), true);
|
||||
a.destroy();
|
||||
assert.equal(world.follows('radar'), false);
|
||||
assert.equal(world.isLive(), true);
|
||||
assert.equal(world.isPlaying(), false);
|
||||
});
|
||||
|
||||
test('pausing from inside the first playing notice stops the world too', async (t) => {
|
||||
const { clock, world } = harness(t);
|
||||
clock.register(product('radar', [0, 10, 20]));
|
||||
const off = clock.subscribe((state) => {
|
||||
if (state.playing) {
|
||||
off();
|
||||
clock.pause();
|
||||
}
|
||||
});
|
||||
await clock.play();
|
||||
assert.equal(clock.getState().playing, false);
|
||||
assert.equal(world.isPlaying(), false);
|
||||
});
|
||||
|
||||
test('a step holds a world that was playing on its own', async (t) => {
|
||||
const { clock, world } = harness(t);
|
||||
world.seek(Date.parse(time(0)));
|
||||
world.play();
|
||||
clock.register(product('radar', [0, 10, 20]));
|
||||
await clock.step(1);
|
||||
assert.equal(world.isPlaying(), false);
|
||||
assert.equal(world.now(), Date.parse(time(10)));
|
||||
});
|
||||
|
||||
test('a target superseded from a listener resolves false', async (t) => {
|
||||
const { clock } = harness(t);
|
||||
const radar = product('radar', [0, 10, 20]);
|
||||
clock.register(radar);
|
||||
await flush();
|
||||
let redirected = false;
|
||||
clock.subscribe((state) => {
|
||||
if (state.target === time(0) && !redirected) {
|
||||
redirected = true;
|
||||
void clock.setTarget(time(10));
|
||||
}
|
||||
});
|
||||
assert.equal(await clock.setTarget(time(0)), false);
|
||||
assert.equal(radar.shown, time(10));
|
||||
});
|
||||
|
||||
test('each product’s frames are world clock coverage, and support the timeline while shown', (t) => {
|
||||
test('each product’s frames span world clock coverage, with no marks, and support the timeline while shown', (t) => {
|
||||
const { clock, world } = harness(t);
|
||||
assert.equal(world.coverage(), null);
|
||||
assert.equal(world.getState().supported, false);
|
||||
@@ -511,11 +377,17 @@ test('each product’s frames are world clock coverage, and support the timeline
|
||||
assert.deepEqual(world.coverage(), {
|
||||
start: Date.parse(time(0)),
|
||||
end: Date.parse(time(10)),
|
||||
marks: [0, 5, 10].map((m) => Date.parse(time(m))),
|
||||
marks: [],
|
||||
markDetails: [],
|
||||
});
|
||||
assert.equal(world.getState().supported, true);
|
||||
unregister();
|
||||
assert.deepEqual(world.coverage().marks, [Date.parse(time(5))]);
|
||||
assert.deepEqual(world.coverage(), {
|
||||
start: Date.parse(time(5)),
|
||||
end: Date.parse(time(5)),
|
||||
marks: [],
|
||||
markDetails: [],
|
||||
});
|
||||
clock.destroy();
|
||||
assert.equal(world.coverage(), null);
|
||||
assert.equal(world.getState().supported, false);
|
||||
@@ -528,10 +400,12 @@ test('a suspended product keeps its coverage, so the way back to live stays', (t
|
||||
radar.suspended = true;
|
||||
void clock.refresh();
|
||||
assert.equal(world.getState().supported, true);
|
||||
assert.deepEqual(
|
||||
world.coverage().marks,
|
||||
[0, 10].map((m) => Date.parse(time(m))),
|
||||
);
|
||||
assert.deepEqual(world.coverage(), {
|
||||
start: Date.parse(time(0)),
|
||||
end: Date.parse(time(10)),
|
||||
marks: [],
|
||||
markDetails: [],
|
||||
});
|
||||
});
|
||||
|
||||
test('new frames reach the world clock through refresh', (t) => {
|
||||
|
||||
@@ -39,6 +39,15 @@ function text(value, max) {
|
||||
: undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* A source name a weather feed supplies itself (`sourceName` on the feed),
|
||||
* held to the same rule as a manifest's `display.source`; undefined when it
|
||||
* is not a fit name.
|
||||
*/
|
||||
export function weatherSourceName(value) {
|
||||
return text(value, TEXT_LIMITS.source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a label the legend formats as a number reads back exactly as given:
|
||||
* within the safe integer range and with no digits lost to rounding, so
|
||||
|
||||
+145
-162
@@ -2,14 +2,16 @@ import { createWeatherRendering } from './rendering.js';
|
||||
import { createWeatherShell, globeImageryHost } from './shellRendering.js';
|
||||
import { weatherFrameSource } from './source.js';
|
||||
import { imageryHostStatus } from './imageryHost.js';
|
||||
import { weatherDisplay, insideExtent } from './display.js';
|
||||
import { weatherDisplay, weatherSourceName, insideExtent } from './display.js';
|
||||
import {
|
||||
RADAR_MAX_GAP_MS,
|
||||
REGIONAL_INFRARED_MAX_GAP_MS,
|
||||
GLOBAL_INFRARED_MAX_GAP_MS,
|
||||
LIGHTNING_MAX_GAP_MS,
|
||||
atLeastFrameSpacing,
|
||||
createWeatherClock,
|
||||
} from './clock.js';
|
||||
import { worldClock } from '../../time/worldClock.js';
|
||||
import { formatUtcDayMonth, t, msg } from '../../i18n/index.js';
|
||||
import { formatScaleLabel } from '../../ui/unitLabels.js';
|
||||
import { toLonLatH } from '../../geo/ellipsoid.js';
|
||||
@@ -60,12 +62,68 @@ const utc = (value) =>
|
||||
? `${formatUtcDayMonth(value)} ${value.slice(11, 16)} UTC`
|
||||
: t('Unavailable');
|
||||
|
||||
/**
|
||||
* Move `world`, the world clock, as its timeline does: `play` toggles play at
|
||||
* the world clock's rate (the speed the timeline chose), from the start of the
|
||||
* covered time when live or at its end, unless `canPlay` is false or there
|
||||
* is no covered time (no timeline to play); `latest` goes live. `step` (-1 or 1) goes to the previous or next of `frames`, the
|
||||
* weather frames; the timeline does not mark them, so this is the row's own
|
||||
* way to step through them.
|
||||
*/
|
||||
function moveWorldTime(world, frames, { play, latest, step }, canPlay) {
|
||||
if (!world) return;
|
||||
if (play === true) {
|
||||
const state = world.getState();
|
||||
if (state.playing) world.pause();
|
||||
else {
|
||||
// With no time to show there is no timeline, and nothing to play.
|
||||
const covered = canPlay && state.supported ? world.coverage() : null;
|
||||
if (covered) {
|
||||
// The covered time reaches to now, as the timeline's track does.
|
||||
const end = Math.max(covered.end, world.wallNow());
|
||||
if (state.live || state.timeMs >= end)
|
||||
world.seek(Math.min(covered.start, state.timeMs));
|
||||
world.play({ continuous: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
if (latest === true) world.goLive();
|
||||
if (step === -1 || step === 1) {
|
||||
const at = world.getState().timeMs;
|
||||
const times = frames
|
||||
.map((time) => Date.parse(time))
|
||||
.filter(Number.isFinite)
|
||||
.sort((a, b) => a - b);
|
||||
const to =
|
||||
step < 0
|
||||
? times.findLast((frame) => frame < at)
|
||||
: times.find((frame) => frame > at);
|
||||
if (to === undefined) return;
|
||||
world.pause();
|
||||
world.seek(to);
|
||||
}
|
||||
}
|
||||
|
||||
// What a layer that has not built its own clock yet reads: live, no frames.
|
||||
const IDLE_CLOCK = Object.freeze({
|
||||
mode: 'latest',
|
||||
target: null,
|
||||
advancing: false,
|
||||
timeline: [],
|
||||
products: [],
|
||||
});
|
||||
|
||||
/** A per-application observation layer, using the existing layer lifecycle and
|
||||
* row controls. Its time is the world clock's, so a link made away from live
|
||||
* opens its imagery at that time; one made live opens the latest. */
|
||||
* opens its imagery at that time; one made live opens the latest. Its frames
|
||||
* follow `clock`, a weather clock several layers share; without one the layer
|
||||
* builds its own on the page's world clock when first enabled and keeps it
|
||||
* for its lifetime; that clock never sends the world live. The feed may also
|
||||
* name its source with `sourceName(kind)`, `kind` being 'radar', 'lightning'
|
||||
* or 'satellite'; NOAA nowCOAST is named otherwise. */
|
||||
export function createWeatherLayer({
|
||||
feed,
|
||||
clock,
|
||||
clock: sharedClock,
|
||||
id = 'weather-radar',
|
||||
createRendering = createWeatherRendering,
|
||||
documentRef = globalThis.document,
|
||||
@@ -74,10 +132,28 @@ export function createWeatherLayer({
|
||||
} = {}) {
|
||||
if (typeof feed?.getSnapshot !== 'function')
|
||||
throw new TypeError('Weather requires a snapshot source');
|
||||
// Without a shared clock the layer builds its own when first enabled, so a
|
||||
// layer never turned on leaves the world clock alone.
|
||||
let ownClock = null;
|
||||
let clock = sharedClock ?? null;
|
||||
// A feed may also supply decoded frames; see weatherFrameSource.
|
||||
const radar = id === 'weather-radar';
|
||||
const lightning = id === 'weather-lightning';
|
||||
const satellite = !radar && !lightning;
|
||||
// A feed may name the source behind each product ('radar', 'lightning' or
|
||||
// 'satellite'); its row then says so before a manifest names it. A name
|
||||
// that fails, like a manifest's, leaves the built-in one.
|
||||
let sourceName = null;
|
||||
try {
|
||||
sourceName =
|
||||
weatherSourceName(
|
||||
feed.sourceName?.(
|
||||
radar ? 'radar' : lightning ? 'lightning' : 'satellite',
|
||||
),
|
||||
) ?? null;
|
||||
} catch (cause) {
|
||||
console.warn('[weather] source name unavailable:', cause);
|
||||
}
|
||||
let product = radar ? 'radar' : lightning ? 'lightning' : 'clouds-regional';
|
||||
let opacity = 'strong';
|
||||
let infrared = 100;
|
||||
@@ -86,12 +162,10 @@ export function createWeatherLayer({
|
||||
manifest = null,
|
||||
request = null,
|
||||
listener = null;
|
||||
let destroyed = false;
|
||||
let enabled = false,
|
||||
loading = false,
|
||||
playing = false,
|
||||
followLatest = true;
|
||||
loading = false;
|
||||
let generation = 0,
|
||||
timer = null,
|
||||
error = null,
|
||||
removeCamera = null;
|
||||
let motion = null;
|
||||
@@ -131,39 +205,38 @@ export function createWeatherLayer({
|
||||
return spaced;
|
||||
};
|
||||
const maxGap = () => spacedTimes().gap;
|
||||
const isLatest = () =>
|
||||
clock ? clock.getState().mode === 'latest' : followLatest;
|
||||
const clockState = () => clock?.getState() ?? IDLE_CLOCK;
|
||||
const isLatest = () => clockState().mode === 'latest';
|
||||
const getHost = () => imageryHost?.() ?? globeImageryHost(viewer);
|
||||
const notify = () => listener?.();
|
||||
const shownTime = () => (noFrame ? null : rendering?.getDiagnostics().time);
|
||||
const unsubscribeClock = clock?.subscribe(() => {
|
||||
const onClock = () => {
|
||||
if (!clock.getState().advancing || suspended())
|
||||
rendering?.cancelPrefetch?.();
|
||||
notify();
|
||||
});
|
||||
};
|
||||
let unsubscribeClock = clock?.subscribe(onClock) ?? null;
|
||||
const ensureClock = () => {
|
||||
if (clock) return;
|
||||
ownClock = createWeatherClock({ world: worldClock, shared: false });
|
||||
clock = ownClock;
|
||||
unsubscribeClock = clock.subscribe(onClock);
|
||||
};
|
||||
// Ages and delays are measured from the time the layer shows: the world
|
||||
// clock's time at a past time, the wall clock while live.
|
||||
const worldNow = () => {
|
||||
const shared = clock?.getState();
|
||||
return shared?.mode === 'history' && shared.target
|
||||
const shared = clockState();
|
||||
return shared.mode === 'history' && shared.target
|
||||
? Date.parse(shared.target)
|
||||
: Date.now();
|
||||
};
|
||||
const observationDelayed = () =>
|
||||
manifest?.latest &&
|
||||
worldNow() - Date.parse(manifest.latest) > spacedTimes().delay;
|
||||
const stop = () => {
|
||||
if (clock) return;
|
||||
playing = false;
|
||||
rendering?.cancelPrefetch?.();
|
||||
clearTimeout(timer);
|
||||
timer = null;
|
||||
};
|
||||
const suspended = () => hostHidden || documentRef?.hidden || motion?.matches;
|
||||
const onVisibility = () => {
|
||||
if (suspended()) rendering?.cancelPrefetch?.();
|
||||
if (clock) void clock.refresh();
|
||||
else if (suspended()) stop();
|
||||
void clock?.refresh();
|
||||
notify();
|
||||
};
|
||||
|
||||
@@ -178,46 +251,15 @@ export function createWeatherLayer({
|
||||
if (!changed || !rendering) return;
|
||||
++generation;
|
||||
rendering.rehome?.();
|
||||
clearTimeout(timer);
|
||||
timer = null;
|
||||
loading = Boolean(request && !request.signal.aborted);
|
||||
if (clock && enabled) {
|
||||
if (resume) {
|
||||
void clock.refresh();
|
||||
if (!hostHidden && manifest && isLatest()) void show(manifest.latest);
|
||||
}
|
||||
notify();
|
||||
return;
|
||||
}
|
||||
if (resume && enabled && !hostHidden && manifest) {
|
||||
const time =
|
||||
followLatest || !manifest.times.includes(shownTime())
|
||||
? manifest.latest
|
||||
: shownTime();
|
||||
if (
|
||||
time !== shownTime() ||
|
||||
(satellite && rendering.getDiagnostics().infrared !== infrared)
|
||||
)
|
||||
void show(time);
|
||||
else schedule();
|
||||
if (enabled && resume) {
|
||||
void clock.refresh();
|
||||
if (!hostHidden && manifest && isLatest()) void show(manifest.latest);
|
||||
}
|
||||
notify();
|
||||
}
|
||||
const onMapStackChanged = () => checkHost();
|
||||
|
||||
function schedule() {
|
||||
if (clock) return;
|
||||
clearTimeout(timer);
|
||||
timer = null;
|
||||
if (!enabled || !playing || suspended()) return;
|
||||
timer = setTimeout(() => {
|
||||
timer = null;
|
||||
const times = manifest?.times || [];
|
||||
const next = (times.indexOf(shownTime()) + 1) % times.length;
|
||||
if (times[next]) void show(times[next]);
|
||||
else stop();
|
||||
}, 2000);
|
||||
}
|
||||
async function applyClockTime(time, { signal }) {
|
||||
if (!enabled || signal.aborted) return false;
|
||||
if (time !== null) return show(time, signal);
|
||||
@@ -231,7 +273,7 @@ export function createWeatherLayer({
|
||||
return true;
|
||||
}
|
||||
function registerClock() {
|
||||
if (!clock || unregisterClock || !rendering || !enabled) return;
|
||||
if (unregisterClock || !rendering || !enabled || !clock) return;
|
||||
unregisterClock = clock.register({
|
||||
id,
|
||||
get maxGapMs() {
|
||||
@@ -244,15 +286,11 @@ export function createWeatherLayer({
|
||||
});
|
||||
}
|
||||
async function warmNext(time) {
|
||||
if (
|
||||
!enabled ||
|
||||
suspended() ||
|
||||
!(clock ? clock.getState().advancing : playing)
|
||||
)
|
||||
return;
|
||||
if (!enabled || suspended() || !clockState().advancing) return;
|
||||
// The world plays on past the newest frame, never round to the first.
|
||||
const times = manifest?.times ?? [];
|
||||
const next = times[(times.indexOf(time) + 1) % times.length];
|
||||
if (!next || next === time) return;
|
||||
const next = times[times.indexOf(time) + 1];
|
||||
if (!next) return;
|
||||
try {
|
||||
await rendering.prefetch?.(manifest, next, { infrared });
|
||||
} catch {
|
||||
@@ -287,13 +325,10 @@ export function createWeatherLayer({
|
||||
error = ok
|
||||
? null
|
||||
: msg('Frame unavailable; previous observation retained');
|
||||
if (!ok) stop();
|
||||
return ok;
|
||||
} catch {
|
||||
if (owner === generation && !controller.signal.aborted) {
|
||||
if (owner === generation && !controller.signal.aborted)
|
||||
error = msg('Weather imagery unavailable');
|
||||
stop();
|
||||
}
|
||||
return false;
|
||||
} finally {
|
||||
signal?.removeEventListener('abort', abort);
|
||||
@@ -301,8 +336,7 @@ export function createWeatherLayer({
|
||||
if (owner === generation) {
|
||||
loading = Boolean(request && !request.signal.aborted);
|
||||
notify();
|
||||
if (clock && isLatest()) void clock.refresh();
|
||||
schedule();
|
||||
if (isLatest()) void clock?.refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -314,7 +348,7 @@ export function createWeatherLayer({
|
||||
? 'Lightning density'
|
||||
: 'Satellite clouds',
|
||||
icon: radar ? '◉' : lightning ? 'ϟ' : '☁',
|
||||
source: 'NOAA nowCOAST · OBSERVED',
|
||||
source: sourceName ?? 'NOAA nowCOAST · OBSERVED',
|
||||
updateInterval: lightning ? 600_000 : 120_000,
|
||||
init(nextViewer) {
|
||||
viewer = nextViewer;
|
||||
@@ -349,7 +383,10 @@ export function createWeatherLayer({
|
||||
notify();
|
||||
},
|
||||
enable() {
|
||||
// Destroyed, the layer stays off: no clock is built for it again.
|
||||
if (destroyed) return;
|
||||
enabled = true;
|
||||
ensureClock();
|
||||
if (!removeCamera) {
|
||||
removeCamera =
|
||||
findCamera(viewer)?.on('moveEnd', () => {
|
||||
@@ -371,26 +408,20 @@ export function createWeatherLayer({
|
||||
noFrame = false;
|
||||
request?.abort();
|
||||
request = null;
|
||||
stop();
|
||||
rendering?.cancelPrefetch?.();
|
||||
rendering?.clear();
|
||||
manifest = null;
|
||||
loading = false;
|
||||
error = null;
|
||||
followLatest = true;
|
||||
},
|
||||
async update(_viewer, { signal } = {}) {
|
||||
if (!enabled) return false;
|
||||
checkHost(false);
|
||||
clearTimeout(timer);
|
||||
timer = null;
|
||||
request?.abort();
|
||||
const controller = new AbortController();
|
||||
if (signal?.aborted) controller.abort(signal.reason);
|
||||
request = controller;
|
||||
const abort = () => {
|
||||
controller.abort(signal.reason);
|
||||
stop();
|
||||
};
|
||||
const abort = () => controller.abort(signal.reason);
|
||||
signal?.addEventListener('abort', abort, { once: true });
|
||||
loading = true;
|
||||
notify();
|
||||
@@ -406,36 +437,15 @@ export function createWeatherLayer({
|
||||
error = msg(
|
||||
'Weather source unavailable; previous observation retained',
|
||||
);
|
||||
stop();
|
||||
return true;
|
||||
}
|
||||
manifest = snapshot;
|
||||
error = null;
|
||||
// The shown frame may stay; its credit follows the refreshed manifest.
|
||||
rendering?.updateSnapshot?.(snapshot);
|
||||
if (clock) {
|
||||
await clock.refresh();
|
||||
if (
|
||||
isLatest() &&
|
||||
request === controller &&
|
||||
!controller.signal.aborted
|
||||
)
|
||||
await show(snapshot.latest, controller.signal);
|
||||
return (
|
||||
enabled &&
|
||||
!signal?.aborted &&
|
||||
(!controller.signal.aborted || request !== controller)
|
||||
);
|
||||
}
|
||||
const time =
|
||||
followLatest || !snapshot.times.includes(shownTime())
|
||||
? snapshot.latest
|
||||
: shownTime();
|
||||
if (
|
||||
shownTime() !== time ||
|
||||
(satellite && rendering.getDiagnostics().infrared !== infrared)
|
||||
)
|
||||
await show(time, controller.signal);
|
||||
await clock.refresh();
|
||||
if (isLatest() && request === controller && !controller.signal.aborted)
|
||||
await show(snapshot.latest, controller.signal);
|
||||
return (
|
||||
enabled &&
|
||||
!signal?.aborted &&
|
||||
@@ -445,7 +455,6 @@ export function createWeatherLayer({
|
||||
if (controller.signal.aborted || request !== controller)
|
||||
return enabled && !signal?.aborted && request !== controller;
|
||||
error = cause?.message || msg('Weather unavailable');
|
||||
stop();
|
||||
return true;
|
||||
} finally {
|
||||
signal?.removeEventListener('abort', abort);
|
||||
@@ -453,7 +462,6 @@ export function createWeatherLayer({
|
||||
request = null;
|
||||
loading = Boolean(rendering?.getDiagnostics().loading);
|
||||
notify();
|
||||
schedule();
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -488,19 +496,16 @@ export function createWeatherLayer({
|
||||
noFrame = false;
|
||||
request?.abort();
|
||||
request = null;
|
||||
stop();
|
||||
rendering?.cancelPrefetch?.();
|
||||
manifest = null;
|
||||
error = null;
|
||||
loading = false;
|
||||
followLatest = true;
|
||||
rendering?.clear();
|
||||
if (clock) void clock.refresh();
|
||||
void clock?.refresh();
|
||||
if (enabled) void layer.update(viewer);
|
||||
}
|
||||
if (infraredChanged && enabled && manifest) {
|
||||
clearTimeout(timer);
|
||||
timer = null;
|
||||
if (clock && !isLatest()) void clock.refresh();
|
||||
if (!isLatest()) void clock.refresh();
|
||||
else void show(shownTime() || manifest.latest);
|
||||
}
|
||||
if (
|
||||
@@ -528,38 +533,19 @@ export function createWeatherLayer({
|
||||
);
|
||||
});
|
||||
}
|
||||
if (clock && enabled) {
|
||||
if (params.play === true) void clock.togglePlay();
|
||||
if (params.latest === true) void clock.latest();
|
||||
if ([-1, 1].includes(params.step)) void clock.step(params.step);
|
||||
}
|
||||
if (
|
||||
!clock &&
|
||||
params.play === true &&
|
||||
enabled &&
|
||||
manifest?.times?.length > 1 &&
|
||||
!suspended()
|
||||
) {
|
||||
playing = !playing;
|
||||
followLatest = false;
|
||||
if (playing) schedule();
|
||||
else stop();
|
||||
}
|
||||
if (!clock && params.latest === true && manifest) {
|
||||
stop();
|
||||
followLatest = true;
|
||||
void show(manifest.latest);
|
||||
}
|
||||
if (!clock && [-1, 1].includes(params.step) && manifest && !loading) {
|
||||
stop();
|
||||
followLatest = false;
|
||||
const at = manifest.times.indexOf(shownTime());
|
||||
const next = Math.max(
|
||||
0,
|
||||
Math.min(manifest.times.length - 1, at + params.step),
|
||||
// Time is the world's: these move the world clock as its timeline
|
||||
// does, and every layer that follows it moves along. A step goes
|
||||
// through every shown observation's frames, and this row's own even
|
||||
// while it is suspended.
|
||||
// Play does nothing while every observation it would show is suspended
|
||||
// (reduced motion, a hidden page, no imagery host), as the row says.
|
||||
if (enabled)
|
||||
moveWorldTime(
|
||||
clock.world,
|
||||
[...clock.getTimeline(), ...(manifest?.times ?? [])],
|
||||
params,
|
||||
clock.getState().products.some(({ suspended }) => !suspended),
|
||||
);
|
||||
void show(manifest.times[next]);
|
||||
}
|
||||
notify();
|
||||
},
|
||||
getParams() {
|
||||
@@ -570,13 +556,13 @@ export function createWeatherLayer({
|
||||
: { product, opacity };
|
||||
},
|
||||
getRowControls() {
|
||||
const shared = clock?.getState();
|
||||
const shared = clockState();
|
||||
const followLatest = isLatest();
|
||||
// Source-described text is data: shown as is, never translated.
|
||||
const display = weatherDisplay(manifest);
|
||||
const missing =
|
||||
noFrame &&
|
||||
shared?.mode === 'history' &&
|
||||
shared.mode === 'history' &&
|
||||
shared.products.find((entry) => entry.id === id)?.selected === null
|
||||
? maxGap() / 60_000 < 60
|
||||
? t('No frame within {gap} min of {time}', {
|
||||
@@ -697,9 +683,7 @@ export function createWeatherLayer({
|
||||
const stops =
|
||||
display.legend ?? (radar ? STOPS : lightning ? LIGHTNING_STOPS : []);
|
||||
const infoMotion = motion?.matches
|
||||
? clock
|
||||
? t('Reduced motion · history playback unavailable')
|
||||
: t('Reduced motion · manual history available')
|
||||
? t('Reduced motion · history playback unavailable')
|
||||
: '';
|
||||
const controls = {
|
||||
readout: true,
|
||||
@@ -881,35 +865,34 @@ export function createWeatherLayer({
|
||||
loading,
|
||||
error: error || rendering?.getDiagnostics().error || null,
|
||||
stale: Boolean(manifest?.stale || observationDelayed()),
|
||||
...(source === undefined
|
||||
...(source === undefined && sourceName === null
|
||||
? { source: 'NOAA nowCOAST' }
|
||||
: // Source text is data: the panel shows it untranslated.
|
||||
{ source, sourceVerbatim: true }),
|
||||
{ source: source ?? sourceName, sourceVerbatim: true }),
|
||||
observedAt: shownTime(),
|
||||
};
|
||||
},
|
||||
getDiagnostics() {
|
||||
const shared = clock?.getState();
|
||||
const shared = clockState();
|
||||
return {
|
||||
...rendering?.getDiagnostics(),
|
||||
playing: shared ? shared.playing : playing && !hostHidden,
|
||||
playing: shared.advancing,
|
||||
followLatest: isLatest(),
|
||||
...(shared
|
||||
? {
|
||||
clock: {
|
||||
mode: shared.mode,
|
||||
target: shared.target,
|
||||
playing: shared.playing,
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
clock: {
|
||||
mode: shared.mode,
|
||||
target: shared.target,
|
||||
playing: shared.advancing,
|
||||
},
|
||||
historyFrames: manifest?.times?.length || 0,
|
||||
timerActive: timer !== null,
|
||||
};
|
||||
},
|
||||
destroy() {
|
||||
destroyed = true;
|
||||
layer.disable();
|
||||
unsubscribeClock?.();
|
||||
unsubscribeClock = null;
|
||||
ownClock?.destroy();
|
||||
if (ownClock) clock = ownClock = null;
|
||||
removeCamera?.();
|
||||
removeCamera = null;
|
||||
motion?.removeEventListener?.('change', onVisibility);
|
||||
|
||||
+311
-106
@@ -1,8 +1,9 @@
|
||||
import test from 'node:test';
|
||||
import test, { afterEach } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createWeatherRendering, READY_WAKE_MS } from './rendering.js';
|
||||
import { createWeatherLayer } from './index.js';
|
||||
import { createWeatherClock } from './clock.js';
|
||||
import { worldClock } from '../../time/worldClock.js';
|
||||
import * as Cesium from 'cesium';
|
||||
import { Color, ImageryLayerCollection, GeographicTilingScheme } from 'cesium';
|
||||
import { NO_IMAGERY_HOST } from './imageryHost.js';
|
||||
@@ -41,6 +42,16 @@ const deferred = () => {
|
||||
const flush = async () => {
|
||||
for (let i = 0; i < 30; i++) await Promise.resolve();
|
||||
};
|
||||
// Time moves on the world clock the weather clock follows, as the timeline
|
||||
// moves it.
|
||||
const seekTo = (clock, time) => {
|
||||
clock.world.seek(Date.parse(time));
|
||||
return flush();
|
||||
};
|
||||
const goLive = (clock) => {
|
||||
clock.world.goLive();
|
||||
return flush();
|
||||
};
|
||||
function event() {
|
||||
const listeners = new Set();
|
||||
return {
|
||||
@@ -557,12 +568,22 @@ test('failed and timed-out stages retain the previous observation; a healthy rep
|
||||
h.rendering.clear();
|
||||
});
|
||||
|
||||
// A layer built without a clock keeps its own on the page's world clock:
|
||||
// each test leaves that clock live, with no layer of its own on it.
|
||||
const harnessed = new Set();
|
||||
afterEach(() => {
|
||||
for (const layer of harnessed) layer.destroy();
|
||||
harnessed.clear();
|
||||
worldClock.goLive();
|
||||
worldClock.setRate(1);
|
||||
});
|
||||
function layerHarness({
|
||||
clock,
|
||||
reducedMotion = false,
|
||||
feed,
|
||||
id,
|
||||
eventTarget = target(),
|
||||
enable = true,
|
||||
} = {}) {
|
||||
const stages = [];
|
||||
const motion = target({ matches: reducedMotion });
|
||||
@@ -637,7 +658,8 @@ function layerHarness({
|
||||
createRendering: () => rendering,
|
||||
});
|
||||
layer.init(viewer);
|
||||
layer.enable();
|
||||
if (enable) layer.enable();
|
||||
harnessed.add(layer);
|
||||
return {
|
||||
layer,
|
||||
rendering,
|
||||
@@ -651,72 +673,189 @@ function layerHarness({
|
||||
};
|
||||
}
|
||||
|
||||
test('history has one owned timer, stops while hidden, and releases all work on disable/destroy', async (t) => {
|
||||
t.mock.timers.enable({ apis: ['setTimeout'] });
|
||||
test('without a clock the layer keeps one of its own on the world clock and lets it go on destroy', async () => {
|
||||
const h = layerHarness();
|
||||
const update = h.layer.update();
|
||||
await flush();
|
||||
h.stages[0].finish();
|
||||
await update;
|
||||
assert.equal(worldClock.follows('weather-radar'), true);
|
||||
// The frames span the timeline's time; they are not marks on it.
|
||||
assert.deepEqual(worldClock.coverage(), {
|
||||
start: Date.parse(times[0]),
|
||||
end: Date.parse(times.at(-1)),
|
||||
marks: [],
|
||||
markDetails: [],
|
||||
});
|
||||
h.layer.setParams({ play: true });
|
||||
assert.equal(h.layer.getDiagnostics().timerActive, true);
|
||||
t.mock.timers.tick(2000);
|
||||
assert.equal(h.stages.length, 2);
|
||||
assert.equal(
|
||||
h.layer.getDiagnostics().timerActive,
|
||||
false,
|
||||
'next timer waits for stage settlement',
|
||||
);
|
||||
h.stages[1].finish();
|
||||
await flush();
|
||||
assert.equal(h.layer.getDiagnostics().timerActive, true);
|
||||
assert.equal(worldClock.isPlaying(), true);
|
||||
assert.equal(worldClock.getState().stepping, false);
|
||||
assert.equal(h.layer.getDiagnostics().playing, true);
|
||||
h.documentRef.hidden = true;
|
||||
h.documentRef.emit('visibilitychange');
|
||||
assert.equal(h.layer.getDiagnostics().playing, false);
|
||||
assert.equal(h.layer.getDiagnostics().timerActive, false);
|
||||
t.mock.timers.tick(20_000);
|
||||
assert.equal(h.stages.length, 2);
|
||||
await flush();
|
||||
assert.equal(worldClock.isPlaying(), true, 'hiding suspends the layer only');
|
||||
h.documentRef.hidden = false;
|
||||
h.documentRef.emit('visibilitychange');
|
||||
h.layer.setParams({ play: true });
|
||||
assert.equal(worldClock.isPlaying(), false);
|
||||
h.layer.disable();
|
||||
assert.equal(h.layer.getDiagnostics().timerActive, false);
|
||||
assert.equal(h.layer.getDiagnostics().historyFrames, 0);
|
||||
t.mock.timers.tick(20_000);
|
||||
assert.equal(h.stages.length, 2);
|
||||
h.layer.destroy();
|
||||
assert.equal(worldClock.follows('weather-radar'), false);
|
||||
assert.equal(h.documentRef.size, 0);
|
||||
assert.equal(h.motion.size, 0);
|
||||
assert.equal(h.moveEnd.size, 0);
|
||||
assert.ok(h.clears() >= 1);
|
||||
});
|
||||
|
||||
test('reduced motion blocks autoplay but permits manual history and stops newly suspended playback', async (t) => {
|
||||
t.mock.timers.enable({ apis: ['setTimeout'] });
|
||||
test('a layer without a clock leaves the world clock alone until enabled, and never sends it live', async (t) => {
|
||||
const past = Date.parse(times[0]) - 3_600_000;
|
||||
worldClock.seek(past);
|
||||
const subscribe = t.mock.method(worldClock, 'subscribe');
|
||||
const gate = t.mock.method(worldClock, 'gate');
|
||||
const h = layerHarness({ enable: false });
|
||||
h.layer.getRowControls();
|
||||
h.layer.getDiagnostics();
|
||||
h.layer.setParams({ play: true, step: -1 });
|
||||
assert.equal(subscribe.mock.callCount(), 0, 'off, no clock is built');
|
||||
assert.equal(gate.mock.callCount(), 0);
|
||||
assert.equal(worldClock.isPlaying(), false);
|
||||
h.layer.destroy();
|
||||
harnessed.delete(h.layer);
|
||||
assert.equal(worldClock.now(), past, 'never on, the world is where it was');
|
||||
assert.equal(worldClock.isLive(), false);
|
||||
|
||||
const on = layerHarness({ enable: false });
|
||||
on.layer.enable();
|
||||
assert.equal(subscribe.mock.callCount(), 1, 'built on first enable');
|
||||
const update = on.layer.update();
|
||||
await flush();
|
||||
on.stages.at(-1)?.finish();
|
||||
await update;
|
||||
on.layer.disable();
|
||||
on.layer.enable();
|
||||
assert.equal(subscribe.mock.callCount(), 1, 'built once');
|
||||
on.layer.destroy();
|
||||
harnessed.delete(on.layer);
|
||||
assert.equal(
|
||||
worldClock.isLive(),
|
||||
false,
|
||||
'its own clock does not send it live',
|
||||
);
|
||||
assert.equal(worldClock.now(), past);
|
||||
});
|
||||
|
||||
test('destroyed, a layer without a clock stays off: enabling it builds no clock', (t) => {
|
||||
const subscribe = t.mock.method(worldClock, 'subscribe');
|
||||
const h = layerHarness();
|
||||
assert.equal(subscribe.mock.callCount(), 1, 'its clock, built on enable');
|
||||
h.layer.destroy();
|
||||
harnessed.delete(h.layer);
|
||||
h.layer.enable();
|
||||
assert.equal(subscribe.mock.callCount(), 1, 'no clock built after destroy');
|
||||
assert.equal(worldClock.follows('weather-radar'), false);
|
||||
h.layer.setParams({ play: true });
|
||||
assert.equal(worldClock.isPlaying(), false);
|
||||
});
|
||||
|
||||
test('with no frames yet there is no timeline, and a row plays nothing', () => {
|
||||
worldClock.setRate(604_800);
|
||||
const h = layerHarness({
|
||||
feed: { getSnapshot: () => new Promise(() => {}) },
|
||||
});
|
||||
void h.layer.update();
|
||||
assert.equal(worldClock.coverage(), null);
|
||||
h.layer.setParams({ play: true });
|
||||
assert.equal(worldClock.isLive(), true);
|
||||
assert.equal(worldClock.isPlaying(), false);
|
||||
});
|
||||
|
||||
test('a row plays at the speed the world clock keeps, from the start at the end of the covered time', async () => {
|
||||
const h = layerHarness();
|
||||
const update = h.layer.update();
|
||||
await flush();
|
||||
h.stages[0].finish();
|
||||
await update;
|
||||
// A speed chosen on the timeline, while live.
|
||||
worldClock.setRate(3_600);
|
||||
h.layer.setParams({ play: true });
|
||||
assert.equal(worldClock.isPlaying(), true);
|
||||
assert.equal(worldClock.getRate(), 3_600, 'played at the speed chosen');
|
||||
assert.ok(
|
||||
worldClock.now() - Date.parse(times[0]) < 3_600_000,
|
||||
'live, play starts at the start of the covered time',
|
||||
);
|
||||
h.layer.setParams({ play: true });
|
||||
assert.equal(worldClock.isPlaying(), false);
|
||||
// Paused at the end of the covered time (it reaches to now), play starts
|
||||
// again from the start, as the timeline's does.
|
||||
worldClock.seek(worldClock.wallNow() + 1_000);
|
||||
h.layer.setParams({ play: true });
|
||||
assert.equal(worldClock.isPlaying(), true);
|
||||
assert.ok(worldClock.now() - Date.parse(times[0]) < 3_600_000);
|
||||
assert.equal(worldClock.getRate(), 3_600);
|
||||
worldClock.pause();
|
||||
});
|
||||
|
||||
test('reduced motion offers no play; steps still move the world clock from frame to frame', async () => {
|
||||
const h = layerHarness({ reducedMotion: true });
|
||||
const update = h.layer.update();
|
||||
await flush();
|
||||
h.stages[0].finish();
|
||||
await update;
|
||||
h.layer.setParams({ play: true });
|
||||
assert.equal(h.layer.getDiagnostics().timerActive, false);
|
||||
assert.equal(
|
||||
h.layer.getRowControls().chips.some((chip) => chip.id === 'play'),
|
||||
false,
|
||||
);
|
||||
h.layer.setParams({ step: -1 });
|
||||
assert.equal(h.stages[1].time, times[1]);
|
||||
h.stages[1].finish();
|
||||
await flush();
|
||||
h.motion.matches = false;
|
||||
h.motion.emit('change');
|
||||
// Play, which the row does not offer, does nothing while it is suspended.
|
||||
h.layer.setParams({ play: true });
|
||||
assert.equal(h.layer.getDiagnostics().playing, true);
|
||||
h.motion.matches = true;
|
||||
h.motion.emit('change');
|
||||
assert.equal(h.layer.getDiagnostics().playing, false);
|
||||
assert.equal(h.layer.getDiagnostics().timerActive, false);
|
||||
h.layer.destroy();
|
||||
assert.equal(worldClock.isPlaying(), false);
|
||||
assert.equal(worldClock.isLive(), true);
|
||||
// A step back from live goes to the newest frame, and the next one back
|
||||
// to the frame before it.
|
||||
h.layer.setParams({ step: -1 });
|
||||
await flush();
|
||||
assert.equal(worldClock.now(), Date.parse(times[2]));
|
||||
h.layer.setParams({ step: -1 });
|
||||
await flush();
|
||||
assert.equal(worldClock.now(), Date.parse(times[1]));
|
||||
assert.equal(h.stages.at(-1).time, times[1]);
|
||||
});
|
||||
|
||||
test('a row steps forward and plays from a past time through the world clock', async () => {
|
||||
const h = layerHarness();
|
||||
const update = h.layer.update();
|
||||
await flush();
|
||||
h.stages[0].finish();
|
||||
await update;
|
||||
worldClock.seek(Date.parse(times[0]));
|
||||
await flush();
|
||||
h.layer.setParams({ step: 1 });
|
||||
assert.equal(worldClock.now(), Date.parse(times[1]));
|
||||
assert.equal(worldClock.isPlaying(), false);
|
||||
await flush();
|
||||
assert.equal(h.stages.at(-1).time, times[1]);
|
||||
h.layer.setParams({ step: 1 });
|
||||
assert.equal(worldClock.now(), Date.parse(times[2]));
|
||||
h.layer.setParams({ step: 1 });
|
||||
assert.equal(
|
||||
worldClock.now(),
|
||||
Date.parse(times[2]),
|
||||
'no frame after the newest',
|
||||
);
|
||||
worldClock.seek(Date.parse(times[1]));
|
||||
await flush();
|
||||
h.layer.setParams({ play: true });
|
||||
assert.equal(worldClock.isPlaying(), true);
|
||||
assert.equal(worldClock.getState().stepping, false);
|
||||
assert.ok(
|
||||
worldClock.now() - Date.parse(times[1]) < 1_000,
|
||||
'away from live, play goes on from the time shown',
|
||||
);
|
||||
h.layer.setParams({ step: 1 });
|
||||
assert.equal(worldClock.isPlaying(), false, 'a step holds play');
|
||||
assert.equal(worldClock.now(), Date.parse(times[2]));
|
||||
});
|
||||
|
||||
test('disable invalidates an abort-insensitive source result and an already staged frame', async (t) => {
|
||||
@@ -745,7 +884,6 @@ test('disable invalidates an abort-insensitive source result and an already stag
|
||||
await next;
|
||||
await flush();
|
||||
assert.equal(h.layer.getStats().count, 0);
|
||||
assert.equal(h.layer.getDiagnostics().timerActive, false);
|
||||
assert.equal(h.layer.getStats().loading, false);
|
||||
h.layer.destroy();
|
||||
});
|
||||
@@ -804,7 +942,6 @@ test('update cancellation reaches imagery after source acquisition has completed
|
||||
assert.equal(h.stages[0].signal.aborted, true);
|
||||
assert.equal(h.layer.getStats().count, 0);
|
||||
assert.equal(h.layer.getStats().loading, false);
|
||||
assert.equal(h.layer.getDiagnostics().timerActive, false);
|
||||
h.layer.destroy();
|
||||
});
|
||||
|
||||
@@ -912,21 +1049,22 @@ test('coverage navigation requires the shared shell handoff and detaches cleanly
|
||||
h.layer.destroy();
|
||||
});
|
||||
|
||||
test('manifest refresh during a manual history stage does not strand loading controls', async () => {
|
||||
test('manifest refresh during a history stage restages the same time and does not strand loading controls', async () => {
|
||||
const h = layerHarness();
|
||||
const first = h.layer.update();
|
||||
await flush();
|
||||
h.stages[0].finish();
|
||||
await first;
|
||||
h.layer.setParams({ step: -1 });
|
||||
worldClock.seek(Date.parse(times[1]));
|
||||
await flush();
|
||||
assert.equal(h.layer.getStats().loading, true);
|
||||
await h.layer.update();
|
||||
assert.equal(
|
||||
h.stages.length,
|
||||
2,
|
||||
'metadata refresh preserves the staged manual selection',
|
||||
);
|
||||
h.stages[1].finish();
|
||||
const refreshed = h.layer.update();
|
||||
await flush();
|
||||
assert.equal(h.stages.length, 3);
|
||||
assert.equal(h.stages[1].signal.aborted, true);
|
||||
assert.equal(h.stages[2].time, times[1], 'the refresh keeps the time');
|
||||
h.stages[2].finish();
|
||||
await refreshed;
|
||||
await flush();
|
||||
assert.equal(h.layer.getStats().loading, false);
|
||||
assert.equal(h.layer.getStats().observedAt, times[1]);
|
||||
@@ -956,7 +1094,8 @@ test('historical observations do not relabel a fresh lightning feed as stale', a
|
||||
await flush();
|
||||
h.stages[0].finish();
|
||||
await first;
|
||||
h.layer.setParams({ step: -1 });
|
||||
worldClock.seek(Date.parse(old));
|
||||
await flush();
|
||||
h.stages[1].finish();
|
||||
await flush();
|
||||
assert.equal(h.layer.getStats().stale, false);
|
||||
@@ -1313,8 +1452,7 @@ test('404 fails a frame without retry', async () => {
|
||||
h.rendering.clear();
|
||||
});
|
||||
|
||||
test('no host pauses history, refreshes metadata, and restores retained time and playback', async (t) => {
|
||||
t.mock.timers.enable({ apis: ['setTimeout'] });
|
||||
test('no host holds the shown history frame, refreshes metadata, and restores the retained time', async () => {
|
||||
let refreshes = 0;
|
||||
const h = layerHarness({
|
||||
feed: {
|
||||
@@ -1330,28 +1468,23 @@ test('no host pauses history, refreshes metadata, and restores retained time and
|
||||
await flush();
|
||||
h.stages[0].finish();
|
||||
await update;
|
||||
h.layer.setParams({ play: true });
|
||||
t.mock.timers.tick(2000);
|
||||
worldClock.seek(Date.parse(times[0]));
|
||||
await flush();
|
||||
assert.equal(h.stages.length, 2);
|
||||
h.stages[1].finish();
|
||||
await flush();
|
||||
host = { collection: null, kind: 'none' };
|
||||
h.eventTarget.emit('gev:map-stack-changed');
|
||||
await flush();
|
||||
assert.equal(h.layer.getDiagnostics().playing, false);
|
||||
assert.equal(h.layer.getDiagnostics().timerActive, false);
|
||||
assert.equal(h.layer.getRowControls().summary.status, NO_IMAGERY_HOST);
|
||||
assert.equal(h.layer.getRowControls().info, NO_IMAGERY_HOST);
|
||||
await h.layer.update();
|
||||
assert.equal(refreshes, 2);
|
||||
t.mock.timers.tick(10_000);
|
||||
assert.equal(h.stages.length, 2);
|
||||
assert.equal(h.layer.getDiagnostics().time, times[2]);
|
||||
assert.equal(h.stages.length, 2, 'nothing stages without a host');
|
||||
host = { collection: {}, kind: 'globe' };
|
||||
h.eventTarget.emit('gev:map-stack-changed');
|
||||
assert.equal(h.layer.getDiagnostics().playing, true);
|
||||
assert.equal(h.layer.getDiagnostics().timerActive, true);
|
||||
t.mock.timers.tick(2000);
|
||||
assert.equal(h.stages.length, 3);
|
||||
assert.equal(h.stages[2].time, times[0]);
|
||||
await flush();
|
||||
assert.equal(h.stages.at(-1).time, times[0], 'the retained time restages');
|
||||
h.layer.destroy();
|
||||
assert.equal(h.eventTarget.size, 0);
|
||||
});
|
||||
@@ -1465,25 +1598,21 @@ for (const [id, product] of [
|
||||
const [shell] = h.shells();
|
||||
assert.equal(shell.show, true);
|
||||
|
||||
layer.setParams({ play: true });
|
||||
t.mock.timers.tick(2000);
|
||||
worldClock.seek(Date.parse(times[0]));
|
||||
await flush();
|
||||
assert.equal(
|
||||
layer.getDiagnostics().time,
|
||||
times[0],
|
||||
'history advances at street level',
|
||||
'history moves at street level',
|
||||
);
|
||||
camera.positionCartographic.height = 59_999;
|
||||
camera.moveEnd.emit();
|
||||
assert.equal(shell.show, true, 'no height gate');
|
||||
assert.equal(layer.getDiagnostics().playing, true);
|
||||
assert.equal(layer.getDiagnostics().timerActive, true);
|
||||
|
||||
host = { collection: null, kind: 'none' };
|
||||
events.emit('gev:map-stack-changed');
|
||||
assert.equal(shell.show, false);
|
||||
assert.equal(layer.getRowControls().summary.status, NO_IMAGERY_HOST);
|
||||
assert.equal(layer.getDiagnostics().timerActive, false);
|
||||
host = { collection: h.viewer.imageryLayers, kind: 'globe' };
|
||||
events.emit('gev:map-stack-changed');
|
||||
assert.equal(shell.destroyed, true);
|
||||
@@ -1675,10 +1804,12 @@ test('satellite mode chips restage history without changing time or latest-follo
|
||||
await flush();
|
||||
h.stages[0].finish();
|
||||
await update;
|
||||
h.layer.setParams({ step: -1 });
|
||||
worldClock.seek(Date.parse(times[1]));
|
||||
await flush();
|
||||
h.stages[1].finish();
|
||||
await flush();
|
||||
h.layer.setParams({ infrared: 'full' });
|
||||
await flush();
|
||||
assert.equal(h.stages[2].time, times[1]);
|
||||
assert.equal(h.stages[2].infrared, 0);
|
||||
assert.equal(h.layer.getParams().infrared, 0);
|
||||
@@ -1802,7 +1933,7 @@ test('a delayed installation failure retains the replacement and does not throw
|
||||
h.rendering.clear();
|
||||
});
|
||||
|
||||
test('one row steps every registered observation; missing frames hide and latest restores each product', async (t) => {
|
||||
test('a row steps the world clock through every registered observation; missing frames hide and latest goes live', async (t) => {
|
||||
const clock = createWeatherClock();
|
||||
const radar = layerHarness({ clock });
|
||||
const satellite = layerHarness({
|
||||
@@ -1835,6 +1966,14 @@ test('one row steps every registered observation; missing frames hide and latest
|
||||
.chips.filter(({ id }) =>
|
||||
['previous', 'play', 'next', 'latest'].includes(id),
|
||||
);
|
||||
// A step back from live goes to the newest frame, and the next one back
|
||||
// to the frame before it.
|
||||
radar.layer.setParams({ step: -1 });
|
||||
await flush();
|
||||
assert.equal(clock.getState().target, times[2]);
|
||||
assert.equal(clock.world.isPlaying(), false);
|
||||
for (const h of [radar, satellite]) h.stages.at(-1)?.finish();
|
||||
await flush();
|
||||
radar.layer.setParams({ step: -1 });
|
||||
await flush();
|
||||
assert.equal(clock.getState().target, times[1]);
|
||||
@@ -1886,6 +2025,33 @@ test('one row steps every registered observation; missing frames hide and latest
|
||||
assert.equal(clock.getState().products.length, 1);
|
||||
});
|
||||
|
||||
test('a row’s play and latest move the world clock as its timeline does', async (t) => {
|
||||
const clock = createWeatherClock();
|
||||
const { world } = clock;
|
||||
const h = layerHarness({ clock });
|
||||
t.after(() => {
|
||||
h.layer.destroy();
|
||||
clock.destroy();
|
||||
});
|
||||
const update = h.layer.update();
|
||||
await flush();
|
||||
h.stages.at(-1).finish();
|
||||
await update;
|
||||
h.layer.setParams({ play: true });
|
||||
assert.equal(world.isPlaying(), true);
|
||||
assert.equal(world.getState().stepping, false, 'the world plays on its own');
|
||||
assert.ok(
|
||||
world.now() - Date.parse(times[0]) < 1_000,
|
||||
'from the start when live',
|
||||
);
|
||||
h.layer.setParams({ play: true });
|
||||
assert.equal(world.isPlaying(), false);
|
||||
h.layer.setParams({ latest: true });
|
||||
assert.equal(world.isLive(), true);
|
||||
await flush();
|
||||
assert.equal(clock.getState().mode, 'latest');
|
||||
});
|
||||
|
||||
test('history manifest expiry hides imagery without jumping to latest; host resume keeps the target', async (t) => {
|
||||
const clock = createWeatherClock();
|
||||
let value = snapshot;
|
||||
@@ -1898,7 +2064,7 @@ test('history manifest expiry hides imagery without jumping to latest; host resu
|
||||
await flush();
|
||||
h.stages.at(-1).finish();
|
||||
await update;
|
||||
const history = clock.setTarget(times[0]);
|
||||
const history = seekTo(clock, times[0]);
|
||||
await flush();
|
||||
h.stages.at(-1).finish();
|
||||
await history;
|
||||
@@ -1967,7 +2133,7 @@ test('satellite global selection uses the three-hour gap and preserves the share
|
||||
await flush();
|
||||
h.stages.at(-1).finish();
|
||||
await update;
|
||||
await clock.setTarget(times[0]);
|
||||
await seekTo(clock, times[0]);
|
||||
assert.equal(
|
||||
h.layer.getDiagnostics().hidden,
|
||||
true,
|
||||
@@ -2026,7 +2192,8 @@ test('satellite clouds from an hourly feed draw all through each hour and read l
|
||||
);
|
||||
|
||||
// Forty-five minutes past a frame, between it and the next, it still shows.
|
||||
const between = clock.setTarget(
|
||||
const between = seekTo(
|
||||
clock,
|
||||
new Date(Date.parse(hourly[0]) + 45 * 60_000).toISOString(),
|
||||
);
|
||||
await flush();
|
||||
@@ -2037,7 +2204,7 @@ test('satellite clouds from an hourly feed draw all through each hour and read l
|
||||
|
||||
// Live again (a past time judges delay from the timeline's time), past
|
||||
// one and a half hours it reads late.
|
||||
const live = clock.latest();
|
||||
const live = goLive(clock);
|
||||
await flush();
|
||||
h.stages.at(-1).finish();
|
||||
await live;
|
||||
@@ -2059,11 +2226,11 @@ test('switching to history cancels a still-loading latest refresh and a later ta
|
||||
const update = h.layer.update();
|
||||
await flush();
|
||||
const latest = h.stages.at(-1);
|
||||
const oldHistory = clock.setTarget(times[0]);
|
||||
const oldHistory = seekTo(clock, times[0]);
|
||||
await flush();
|
||||
assert.equal(latest.signal.aborted, true);
|
||||
const oldStage = h.stages.at(-1);
|
||||
const current = clock.setTarget(times[1]);
|
||||
const current = seekTo(clock, times[1]);
|
||||
await flush();
|
||||
assert.equal(oldStage.signal.aborted, true);
|
||||
h.stages.at(-1).finish();
|
||||
@@ -2373,8 +2540,9 @@ test('failed prefetch leaves the current frame and errors unchanged and releases
|
||||
assert.deepEqual(h.rendering.getDiagnostics(), before);
|
||||
});
|
||||
|
||||
test('layer warms the next advertised observation only after a successful playing frame, wrapping at the end', async (t) => {
|
||||
test('as the world plays, the layer warms the next advertised observation after each frame that shows', async (t) => {
|
||||
const clock = createWeatherClock();
|
||||
const { world } = clock;
|
||||
const h = layerHarness({ clock });
|
||||
const warmed = [];
|
||||
let cancels = 0;
|
||||
@@ -2392,45 +2560,45 @@ test('layer warms the next advertised observation only after a successful playin
|
||||
await flush();
|
||||
h.stages.at(-1).finish();
|
||||
await updated;
|
||||
assert.equal(warmed.length, 0);
|
||||
const play = clock.play();
|
||||
await seekTo(clock, times[0]);
|
||||
h.stages.at(-1).finish();
|
||||
await flush();
|
||||
assert.equal(warmed.length, 0, 'paused, nothing is warmed');
|
||||
world.play({ rate: 1e-9, continuous: true });
|
||||
assert.equal(clock.getState().advancing, true);
|
||||
await seekTo(clock, times[1]);
|
||||
assert.equal(warmed.length, 0, 'still staging');
|
||||
h.stages.at(-1).finish();
|
||||
await play;
|
||||
await flush();
|
||||
assert.deepEqual(
|
||||
warmed.map(({ time }) => time),
|
||||
[times[0]],
|
||||
[times[2]],
|
||||
);
|
||||
assert.deepEqual(warmed[0].options, { infrared: 100 });
|
||||
const next = clock.setTarget(times[0]);
|
||||
await flush();
|
||||
h.stages.at(-1).finish();
|
||||
await next;
|
||||
assert.deepEqual(
|
||||
warmed.map(({ time }) => time),
|
||||
[times[0], times[1]],
|
||||
);
|
||||
const failed = clock.setTarget(times[1]);
|
||||
await flush();
|
||||
await seekTo(clock, times[0]);
|
||||
h.stages.at(-1).finish(false);
|
||||
await failed;
|
||||
assert.equal(warmed.length, 2);
|
||||
const priorCancels = cancels;
|
||||
clock.pause();
|
||||
assert.ok(cancels > priorCancels);
|
||||
const paused = clock.setTarget(times[2]);
|
||||
await flush();
|
||||
assert.equal(warmed.length, 1, 'a failed frame warms nothing');
|
||||
await seekTo(clock, times[2]);
|
||||
h.stages.at(-1).finish();
|
||||
await paused;
|
||||
assert.equal(warmed.length, 2);
|
||||
await clock.play();
|
||||
await flush();
|
||||
assert.equal(warmed.length, 1, 'the world plays on past the newest frame');
|
||||
const priorCancels = cancels;
|
||||
world.pause();
|
||||
await flush();
|
||||
assert.ok(cancels > priorCancels);
|
||||
await seekTo(clock, times[1]);
|
||||
h.stages.at(-1).finish();
|
||||
await flush();
|
||||
assert.equal(warmed.length, 1);
|
||||
world.play({ rate: 1e-9, continuous: true });
|
||||
h.documentRef.hidden = true;
|
||||
h.documentRef.emit('visibilitychange');
|
||||
await flush();
|
||||
h.stages.at(-1).finish();
|
||||
h.stages.at(-1)?.finish();
|
||||
await flush();
|
||||
assert.equal(warmed.length, 2, 'hidden products do not prefetch');
|
||||
assert.equal(warmed.length, 1, 'hidden products do not prefetch');
|
||||
world.goLive();
|
||||
});
|
||||
|
||||
for (const product of ['radar', 'clouds-regional', 'lightning']) {
|
||||
@@ -2767,7 +2935,7 @@ test('at a past time a frame is aged and its source judged delayed from the time
|
||||
|
||||
// Years later, the world clock is moved back to the newest frame.
|
||||
Date.now.mock.mockImplementation(() => Date.parse('2032-01-01T00:00:00Z'));
|
||||
void clock.setTarget(times[2]);
|
||||
void seekTo(clock, times[2]);
|
||||
await flush();
|
||||
h.stages.at(-1)?.finish();
|
||||
await flush();
|
||||
@@ -2778,10 +2946,47 @@ test('at a past time a frame is aged and its source judged delayed from the time
|
||||
assert.equal(h.layer.getStats().stale, false);
|
||||
|
||||
// Ten minutes after the newest frame, the frame is ten minutes old.
|
||||
void clock.setTarget('2026-09-15T20:20:00.000Z');
|
||||
void seekTo(clock, '2026-09-15T20:20:00.000Z');
|
||||
await flush();
|
||||
h.stages.at(-1)?.finish();
|
||||
await flush();
|
||||
assert.match(h.layer.getRowControls().summary.detail, /10m ago · nearest/);
|
||||
assert.equal(h.layer.getRowControls().summary.status, null);
|
||||
});
|
||||
|
||||
test('a feed names the source behind each product, before any manifest does', (t) => {
|
||||
t.mock.method(console, 'warn', () => {});
|
||||
const quiet = {
|
||||
documentRef: target({ hidden: false }),
|
||||
eventTarget: target(),
|
||||
matchMedia: () => target({ matches: false }),
|
||||
};
|
||||
const asked = [];
|
||||
const feed = {
|
||||
getSnapshot: async () => snapshot,
|
||||
sourceName(kind) {
|
||||
asked.push(kind);
|
||||
if (kind === 'satellite') throw new Error('no name');
|
||||
return kind === 'radar' ? ' NOAA MRMS ' : 'NOAA\u200b GLM';
|
||||
},
|
||||
};
|
||||
const radar = createWeatherLayer({ ...quiet, feed, id: 'weather-radar' });
|
||||
assert.equal(radar.source, 'NOAA MRMS');
|
||||
const stats = radar.getStats();
|
||||
assert.equal(stats.source, 'NOAA MRMS');
|
||||
assert.equal(stats.sourceVerbatim, true);
|
||||
// A name a manifest could not carry, or a failing call, leaves nowCOAST, as
|
||||
// does a feed with no names.
|
||||
for (const id of ['weather-lightning', 'weather-satellite']) {
|
||||
const layer = createWeatherLayer({ ...quiet, feed, id });
|
||||
assert.equal(layer.source, 'NOAA nowCOAST · OBSERVED', id);
|
||||
assert.equal(layer.getStats().source, 'NOAA nowCOAST', id);
|
||||
assert.equal(layer.getStats().sourceVerbatim, undefined, id);
|
||||
}
|
||||
assert.deepEqual(asked, ['radar', 'lightning', 'satellite']);
|
||||
const unnamed = createWeatherLayer({
|
||||
...quiet,
|
||||
feed: { getSnapshot: async () => snapshot },
|
||||
});
|
||||
assert.equal(unnamed.source, 'NOAA nowCOAST · OBSERVED');
|
||||
});
|
||||
@@ -390,20 +390,24 @@ test('sample stays fixed across model, field and unit changes; dismissal and dis
|
||||
test('observed history labels wind as a forecast without changing its data or parameters', async () => {
|
||||
const { createWeatherClock } = await import('../weather/clock.js');
|
||||
const clock = createWeatherClock();
|
||||
const { world } = clock;
|
||||
const layer = createWindLayer({ feed: { getSnapshot: async () => snapshot('gfs') }, clock });
|
||||
let changes = 0;
|
||||
layer.setRowControlsListener(() => changes++);
|
||||
const params = layer.getParams();
|
||||
await clock.setTarget('2026-09-14T12:00:00.000Z');
|
||||
world.seek(Date.parse('2026-09-14T12:00:00.000Z'));
|
||||
await Promise.resolve();
|
||||
assert.equal(layer.getRowControls().summary.status, null, 'history does not mask source status');
|
||||
assert.ok(changes > 0);
|
||||
assert.match(layer.getRowControls().info, /Forecast · does not follow history/);
|
||||
assert.deepEqual(layer.getParams(), params);
|
||||
await clock.latest();
|
||||
world.goLive();
|
||||
await Promise.resolve();
|
||||
assert.equal(layer.getRowControls().summary.status, null);
|
||||
layer.destroy();
|
||||
const before = changes;
|
||||
await clock.setTarget('2026-09-14T12:00:00.000Z');
|
||||
world.seek(Date.parse('2026-09-14T12:00:00.000Z'));
|
||||
await Promise.resolve();
|
||||
assert.equal(changes, before);
|
||||
clock.destroy();
|
||||
});
|
||||
@@ -462,7 +466,8 @@ test('wind whose source follows the timeline drops the note that it does not fol
|
||||
const clock = createWeatherClock({ world });
|
||||
const layer = createWindLayer({ feed: { getSnapshot: async () => snapshot('gfs') }, clock });
|
||||
world.follow('wind');
|
||||
await clock.setTarget('2026-09-14T12:00:00.000Z');
|
||||
world.seek(Date.parse('2026-09-14T12:00:00.000Z'));
|
||||
for (let i = 0; i < 10; i++) await Promise.resolve();
|
||||
assert.equal(clock.getState().mode, 'history');
|
||||
assert.doesNotMatch(layer.getRowControls().info, /does not follow history/);
|
||||
world.follow('wind', false);
|
||||
|
||||
@@ -286,7 +286,7 @@ test('expanded right panels highlight the title divider without changing collaps
|
||||
|
||||
assert.match(
|
||||
html,
|
||||
/class="compact pp-header-row"[\s\S]*?class="pp-header-label">DISPLAY<\/span>[\s\S]*?class="panel-divider"/,
|
||||
/class="compact pp-header-row"[\s\S]*?class="pp-header-label">VISUAL<\/span>[\s\S]*?class="panel-divider"/,
|
||||
);
|
||||
assert.match(
|
||||
css,
|
||||
|
||||
@@ -254,7 +254,7 @@ test('detection-on-by-default is a default, not an operator override', () => {
|
||||
// A factory default is not that. If applying the baseline set the flag, a
|
||||
// fresh session would silently lose the style auto-enable behaviour — a
|
||||
// separate landed feature, taken out by an unrelated change.
|
||||
const applyDefaults = uiBlock(' _applyGlobalPostDefaults() {', '\n }\n');
|
||||
const applyDefaults = uiBlock(' _applyGlobalPostDefaults({ keepHudVariant = false } = {}) {', '\n }\n');
|
||||
assert.match(applyDefaults, /this\._setDetectionMode\(defaults\.detectionMode\)/,
|
||||
'the baseline still goes through the real detection path');
|
||||
assert.doesNotMatch(applyDefaults, /_detectionUserOverridden/,
|
||||
|
||||
@@ -72,7 +72,11 @@ test('a loaded pack shows its attribution card in the viewer container', async (
|
||||
card.querySelector('div').textContent,
|
||||
'clip · Synthetic · CC0-1.0',
|
||||
);
|
||||
assert.equal(card.querySelector('a'), null, 'no link without a source URL');
|
||||
assert.equal(
|
||||
card.querySelector('a') === null,
|
||||
true,
|
||||
'no link without a source URL',
|
||||
);
|
||||
const video = card.querySelector('video');
|
||||
assert.equal(video.controls, true);
|
||||
assert.equal(video.preload, 'none');
|
||||
|
||||
@@ -90,6 +90,12 @@ let _container = null;
|
||||
let _viewer = null;
|
||||
let _enabled = true;
|
||||
let _featherRatio = SCOPE_FEATHER_RATIO_DEFAULT;
|
||||
/**
|
||||
* How strongly the whole mask shows, from the Display panel's Opacity slider:
|
||||
* a fade over the painted mask, separate from the altitude terminus above,
|
||||
* so the terminus band and its repaint gate stay as they are.
|
||||
*/
|
||||
let _maskOpacity = 1;
|
||||
let _resizeObserver = null;
|
||||
let _dprQuery = null;
|
||||
let _dprListener = null;
|
||||
@@ -434,6 +440,7 @@ export function installScopeMask(viewer) {
|
||||
_canvas = document.createElement('canvas');
|
||||
_canvas.id = 'scope-mask';
|
||||
_canvas.setAttribute('aria-hidden', 'true');
|
||||
_canvas.style.opacity = String(_maskOpacity);
|
||||
_container.appendChild(_canvas);
|
||||
_resizeObserver = new ResizeObserver(() => draw());
|
||||
_resizeObserver.observe(_container);
|
||||
@@ -538,6 +545,23 @@ export function getScopeMaskFeather() {
|
||||
return _featherRatio;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} ratio - How strongly the mask shows, 0 (clear) to 1.
|
||||
* @returns {void}
|
||||
*/
|
||||
export function setScopeMaskOpacity(ratio) {
|
||||
_maskOpacity = Math.max(
|
||||
0,
|
||||
Math.min(1, Number.isFinite(Number(ratio)) ? Number(ratio) : 1),
|
||||
);
|
||||
if (_canvas) _canvas.style.opacity = String(_maskOpacity);
|
||||
}
|
||||
|
||||
/** @returns {number} */
|
||||
export function getScopeMaskOpacity() {
|
||||
return _maskOpacity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tear the mask down (canvas + observer). Reinstall with installScopeMask.
|
||||
* @returns {void}
|
||||
@@ -568,6 +592,7 @@ export function _resetScopeMaskForTest() {
|
||||
_viewer = null;
|
||||
_enabled = true;
|
||||
_featherRatio = SCOPE_FEATHER_RATIO_DEFAULT;
|
||||
_maskOpacity = 1;
|
||||
_terminusAlpha = SCOPE_OUTSIDE_ALPHA;
|
||||
_terminusOverride = null;
|
||||
_terminusRepaints = 0;
|
||||
|
||||
@@ -19,6 +19,8 @@ import {
|
||||
SCOPE_TERMINUS_MAX_PCT,
|
||||
SCOPE_FEATHER_RATIO_DEFAULT,
|
||||
getScopeMaskFeather,
|
||||
setScopeMaskOpacity,
|
||||
getScopeMaskOpacity,
|
||||
SCOPE_OUTSIDE_ALPHA,
|
||||
SCOPE_TERMINUS_ALPHA_NEAR,
|
||||
SCOPE_TERMINUS_FAR_M,
|
||||
@@ -206,6 +208,37 @@ test('scope appearance follows direct state changes and install/destroy lifecycl
|
||||
}
|
||||
});
|
||||
|
||||
test('scope opacity fades the painted mask without repainting it', () => {
|
||||
const dom = stubScopeMaskDom();
|
||||
try {
|
||||
assert.equal(getScopeMaskOpacity(), 1, 'full by default');
|
||||
setScopeMaskOpacity(0.4);
|
||||
installScopeMask({ container: dom.container });
|
||||
assert.equal(dom.canvas.style.opacity, '0.4', 'a choice made before install applies');
|
||||
const paints = { ...dom.ops };
|
||||
const terminus = getScopeTerminusAlpha();
|
||||
setScopeMaskOpacity(0.25);
|
||||
assert.equal(dom.canvas.style.opacity, '0.25');
|
||||
assert.deepEqual(dom.ops, paints, 'the mask is not repainted');
|
||||
assert.equal(getScopeTerminusAlpha(), terminus, 'the terminus is its own setting');
|
||||
setScopeMaskOpacity(3);
|
||||
assert.equal(getScopeMaskOpacity(), 1);
|
||||
setScopeMaskOpacity(-1);
|
||||
assert.equal(getScopeMaskOpacity(), 0);
|
||||
setScopeMaskOpacity('soft');
|
||||
assert.equal(getScopeMaskOpacity(), 1, 'not a number is full');
|
||||
setScopeMaskOpacity(0.5);
|
||||
destroyScopeMask();
|
||||
installScopeMask({ container: dom.container });
|
||||
assert.equal(dom.canvas.style.opacity, '0.5', 'reinstall keeps it');
|
||||
_resetScopeMaskForTest();
|
||||
assert.equal(getScopeMaskOpacity(), 1, 'test reset restores full');
|
||||
} finally {
|
||||
destroyScopeMask();
|
||||
dom.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test('a DPR change with no resize still repaints the backing store', () => {
|
||||
const dom = stubScopeMaskDom({ width: 1000, height: 800, dpr: 1 });
|
||||
try {
|
||||
|
||||
@@ -43,6 +43,7 @@ export const LEGACY_SHARE_STATE_KEYS = Object.freeze([
|
||||
'celestialRing',
|
||||
'scopeEnabled',
|
||||
'scopeFeatherPct',
|
||||
'scopeOpacityPct',
|
||||
'scopeTerminusPct',
|
||||
'mapStack',
|
||||
'layerState',
|
||||
|
||||
@@ -393,6 +393,7 @@ export const SHARE_VIEW_FIELDS = freezeAll([
|
||||
// Data Library entries switched on, as their two-character ledger tokens
|
||||
// concatenated (src/library/ledger.json). Absent means none.
|
||||
{ number: 29, key: 'library', type: 'bytes', default: null },
|
||||
{ number: 30, key: 'scopeOpacityPct', type: 'uint', default: 100 },
|
||||
]);
|
||||
const FIELD_BY_KEY = new Map(SHARE_VIEW_FIELDS.map((f) => [f.key, f]));
|
||||
const fieldNumber = (key) => FIELD_BY_KEY.get(key).number;
|
||||
@@ -780,6 +781,12 @@ export function normalizeShareViewState(input = {}) {
|
||||
state.scopeFeatherPct = finite(source.scopeFeatherPct)
|
||||
? clampScopeFeatherPct(Number(source.scopeFeatherPct))
|
||||
: d.scopeFeatherPct;
|
||||
state.scopeOpacityPct = intOr(
|
||||
source.scopeOpacityPct,
|
||||
d.scopeOpacityPct,
|
||||
0,
|
||||
100,
|
||||
);
|
||||
state.scopeTerminusPct = intOr(
|
||||
source.scopeTerminusPct,
|
||||
null,
|
||||
|
||||
@@ -119,6 +119,7 @@ function randomState(random) {
|
||||
detectionFadePct: maybe(0.5, int(0, 40)),
|
||||
detectionOutsideOpacityPct: maybe(0.5, int(0, 100)),
|
||||
scopeFeatherPct: maybe(0.5, int(0, 200)),
|
||||
scopeOpacityPct: maybe(0.5, int(0, 100)),
|
||||
scopeTerminusPct: maybe(
|
||||
0.3,
|
||||
int(SCOPE_TERMINUS_MIN_PCT, SCOPE_TERMINUS_MAX_PCT),
|
||||
@@ -210,6 +211,7 @@ test('each setting costs bytes only when it differs from its default', () => {
|
||||
detectionFadePct: 8,
|
||||
detectionOutsideOpacityPct: 2,
|
||||
scopeFeatherPct: 99,
|
||||
scopeOpacityPct: 40,
|
||||
scopeTerminusPct: 95,
|
||||
};
|
||||
const defaults = createDefaultShareViewState();
|
||||
@@ -355,6 +357,7 @@ test('every registered field round-trips at once', () => {
|
||||
celestialRing: true,
|
||||
scopeEnabled: false,
|
||||
scopeFeatherPct: 35,
|
||||
scopeOpacityPct: 60,
|
||||
scopeTerminusPct: 97,
|
||||
mapStack: 'esri-imagery',
|
||||
layerState,
|
||||
@@ -509,6 +512,7 @@ test('the field registry is well formed and permanent', () => {
|
||||
[27, 'styleParams', BY_STYLE],
|
||||
[28, 'worldTime', null],
|
||||
[29, 'library', null],
|
||||
[30, 'scopeOpacityPct', 100],
|
||||
],
|
||||
);
|
||||
assert.deepEqual(
|
||||
@@ -1586,3 +1590,50 @@ test('Data Library tokens round-trip and malformed ones are skipped', () => {
|
||||
assert.equal(normalizeLibraryTokens(null), null);
|
||||
assert.deepEqual(normalizeLibraryTokens('x'.repeat(500)), []);
|
||||
});
|
||||
|
||||
test('scope opacity is field 30; a link made before it opens at full opacity', () => {
|
||||
// Made before field 30 existed: thermal, Cyber, Scope off at 35% feather
|
||||
// and a pinned terminus.
|
||||
const before = 'ARD-7j4YuxMguBcoUEgQcAOAAQPIASPQAWGa';
|
||||
const old = decodeOk(before).state;
|
||||
assert.equal(old.scopeOpacityPct, 100);
|
||||
assert.equal(old.scopeFeatherPct, 35);
|
||||
assert.equal(encodeShareView(old), before, 'it still encodes to itself');
|
||||
const state = {
|
||||
lat: 51.5007,
|
||||
lon: -0.1246,
|
||||
alt: 1500,
|
||||
heading: 40,
|
||||
style: 'thermal',
|
||||
scopeEnabled: false,
|
||||
scopeFeatherPct: 35,
|
||||
scopeTerminusPct: 97,
|
||||
hudVariant: 'cyber',
|
||||
};
|
||||
assert.equal(encodeShareView(state), before);
|
||||
assert.equal(encodeShareView({ ...state, scopeOpacityPct: 100 }), before);
|
||||
const faded = assertRoundTrip({ ...state, scopeOpacityPct: 45 });
|
||||
assert.notEqual(faded, before);
|
||||
assert.equal(decodeOk(faded).state.scopeOpacityPct, 45);
|
||||
assert.equal(
|
||||
decodeOk(assertRoundTrip({ scopeOpacityPct: 0 })).state.scopeOpacityPct,
|
||||
0,
|
||||
);
|
||||
// Out of range is clamped; anything not a number is the default.
|
||||
assert.equal(
|
||||
normalizeShareViewState({ scopeOpacityPct: 150 }).scopeOpacityPct,
|
||||
100,
|
||||
);
|
||||
assert.equal(
|
||||
normalizeShareViewState({ scopeOpacityPct: -5 }).scopeOpacityPct,
|
||||
0,
|
||||
);
|
||||
assert.equal(
|
||||
normalizeShareViewState({ scopeOpacityPct: 33.6 }).scopeOpacityPct,
|
||||
34,
|
||||
);
|
||||
assert.equal(
|
||||
normalizeShareViewState({ scopeOpacityPct: 'x' }).scopeOpacityPct,
|
||||
100,
|
||||
);
|
||||
});
|
||||
@@ -122,6 +122,29 @@ test('scope feather above 100% survives share parsing and serialization', () =>
|
||||
clearTimeout(manager._debounceTimer);
|
||||
});
|
||||
|
||||
test('scope opacity rides as sco only below full, and through the compact link', () => {
|
||||
// Links without `sco`, every link made before it, open at full opacity.
|
||||
assert.equal(makeManager('#v=2&lat=10&lon=20&scf=35').parseInitialHash().scopeOpacityPct, 100);
|
||||
assert.equal(makeManager('#v=2&lat=10&lon=20&sco=40').parseInitialHash().scopeOpacityPct, 40);
|
||||
assert.equal(makeManager('#v=2&lat=10&lon=20&sco=250').parseInitialHash().scopeOpacityPct, 100);
|
||||
assert.equal(makeManager('#v=2&lat=10&lon=20&sco=-3').parseInitialHash().scopeOpacityPct, 0);
|
||||
assert.equal(makeManager('#v=2&lat=10&lon=20&sco=x').parseInitialHash().scopeOpacityPct, 100);
|
||||
|
||||
const manager = makeManager();
|
||||
manager.onToggleChange(false, true, {});
|
||||
const before = manager._buildHashParams().toString();
|
||||
assert.equal(manager._buildHashParams().has('sco'), false, 'full opacity writes nothing');
|
||||
manager.onToggleChange(false, true, { scopeOpacityPct: 100 });
|
||||
assert.equal(manager._buildHashParams().toString(), before);
|
||||
manager.onToggleChange(false, true, { scopeOpacityPct: 45.4 });
|
||||
assert.equal(manager._buildHashParams().get('sco'), '45');
|
||||
assert.equal(sharedState(manager.buildLink()).scopeOpacityPct, 45);
|
||||
manager.onToggleChange(false, true, { scopeOpacityPct: 100 });
|
||||
assert.equal(manager._buildHashParams().has('sco'), false);
|
||||
assert.equal(sharedState(manager.buildLink()).scopeOpacityPct, 100);
|
||||
clearTimeout(manager._debounceTimer);
|
||||
});
|
||||
|
||||
test('share-link serialization emits the current celestial state', () => {
|
||||
const manager = makeManager();
|
||||
manager.onToggleChange(false, false, { celestialRingEnabled: false });
|
||||
|
||||
@@ -108,6 +108,9 @@ export class ShareLinkManager {
|
||||
this._celestialRingEnabled = false;
|
||||
this._scopeEnabled = true;
|
||||
this._scopeFeatherPct = 100;
|
||||
// How strongly the scope mask shows, 0..100; 100 (the full mask) is the
|
||||
// default and leaves `sco` out of the link.
|
||||
this._scopeOpacityPct = 100;
|
||||
// null = the altitude-adaptive terminus (the default). A number pins the
|
||||
// outside-fill opacity as a percent, 94..100. (`sce`, 2026-08-17)
|
||||
this._scopeTerminusPct = null;
|
||||
@@ -291,6 +294,10 @@ export class ShareLinkManager {
|
||||
// mirrors live state for the link this session generates, so it must match
|
||||
// the mask, not the archive.)
|
||||
scopeFeatherPct: clampScopeFeatherPct(parseOr(params.get('scf'), 35)),
|
||||
scopeOpacityPct: Math.max(
|
||||
0,
|
||||
Math.min(100, Math.round(parseOr(params.get('sco'), 100))),
|
||||
),
|
||||
// Absent (or non-numeric) `sce` = adaptive (null), the default behavior;
|
||||
// a value pins the terminus opacity percent, clamped into the SUPPORTED
|
||||
// 94..100 band. `sce=0` used to survive as a sub-94 terminus — a hole in
|
||||
@@ -459,6 +466,7 @@ export class ShareLinkManager {
|
||||
celestialRing: visualCurrent ? state.celestialRing : undefined,
|
||||
scopeEnabled: visualCurrent ? state.scopeEnabled : undefined,
|
||||
scopeFeatherPct: visualCurrent ? state.scopeFeatherPct : undefined,
|
||||
scopeOpacityPct: visualCurrent ? state.scopeOpacityPct : undefined,
|
||||
scopeTerminusPct: visualCurrent ? state.scopeTerminusPct : undefined,
|
||||
mapStack: mapCurrent ? state.mapStack : undefined,
|
||||
panelState,
|
||||
@@ -625,6 +633,12 @@ export class ShareLinkManager {
|
||||
if (typeof extras.scopeFeatherPct === 'number') {
|
||||
this._scopeFeatherPct = clampScopeFeatherPct(extras.scopeFeatherPct);
|
||||
}
|
||||
if (typeof extras.scopeOpacityPct === 'number') {
|
||||
this._scopeOpacityPct = Math.max(
|
||||
0,
|
||||
Math.min(100, Math.round(extras.scopeOpacityPct)),
|
||||
);
|
||||
}
|
||||
if (extras.scopeTerminusPct === null) this._scopeTerminusPct = null;
|
||||
else if (typeof extras.scopeTerminusPct === 'number') {
|
||||
this._scopeTerminusPct = clampScopeTerminusPct(extras.scopeTerminusPct);
|
||||
@@ -730,6 +744,8 @@ export class ShareLinkManager {
|
||||
params.set('cr', this._celestialRingEnabled ? '1' : '0');
|
||||
params.set('sc', this._scopeEnabled ? '1' : '0');
|
||||
params.set('scf', Math.round(this._scopeFeatherPct).toString());
|
||||
if (this._scopeOpacityPct !== 100)
|
||||
params.set('sco', String(this._scopeOpacityPct));
|
||||
// Only written when pinned — an absent `sce` IS the adaptive default, so a
|
||||
// shared link never freezes the ramp for the recipient by accident. The
|
||||
// same 94..100 clamp applies on the way OUT, so a link can never carry an
|
||||
|
||||
@@ -119,6 +119,7 @@ test('at the live edge a layer with a timeline only follows and registers', asyn
|
||||
start: WALL - 3_600_000,
|
||||
end: WALL,
|
||||
marks: [],
|
||||
markDetails: [],
|
||||
});
|
||||
assert.equal(h.follower.active(), false);
|
||||
assert.deepEqual(h.calls, []);
|
||||
|
||||
+128
-12
@@ -14,11 +14,85 @@
|
||||
* src/time/snapshotTimeline.js); otherwise they stay live.
|
||||
*
|
||||
* Playback is continuous (`cursor + elapsed × rate`) unless a driver takes
|
||||
* it: weather replay steps its observed frames itself and moves the clock as
|
||||
* it goes, so play and pause hand over to it. Several drivers may be attached;
|
||||
* play goes to the newest that can play, pause to the one playing.
|
||||
* it: a driver steps the clock itself and moves it as it goes, so play and
|
||||
* pause hand over to it. Several drivers may be attached; play goes to the
|
||||
* newest that can play, pause to the one playing. Layers that load frames
|
||||
* (weather) do not drive it: they gate continuous play at their next frame.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A timeline mark as a layer gives it: its time in epoch ms, and optionally
|
||||
* a short label to show for it, the layer's own id for it and its kind.
|
||||
* @typedef {{time: number, label?: string, id?: string, kind?: string}} WorldClockMarkInput
|
||||
*/
|
||||
|
||||
/**
|
||||
* A timeline mark as `coverage().markDetails` returns it: a finite time, and
|
||||
* only those of `label`, `id` and `kind` that are non-empty strings.
|
||||
* @typedef {Readonly<{time: number, label?: string, id?: string, kind?: string}>} WorldClockMark
|
||||
*/
|
||||
|
||||
const MARK_TEXT = ['label', 'id', 'kind'];
|
||||
/**
|
||||
* The longest label a mark carries, ellipsis and all, in characters as a
|
||||
* reader sees them (graphemes where the runtime can tell them, otherwise code
|
||||
* points), so an emoji or an accented letter is never split.
|
||||
*/
|
||||
export const WORLD_CLOCK_MARK_LABEL_LENGTH = 60;
|
||||
|
||||
const graphemes =
|
||||
typeof Intl?.Segmenter === 'function'
|
||||
? (() => {
|
||||
const segmenter = new Intl.Segmenter(undefined, {
|
||||
granularity: 'grapheme',
|
||||
});
|
||||
return (text) =>
|
||||
Array.from(segmenter.segment(text), ({ segment }) => segment);
|
||||
})()
|
||||
: (text) => Array.from(text);
|
||||
|
||||
/** `mark` with its label cut to WORLD_CLOCK_MARK_LABEL_LENGTH, ending in `…`. */
|
||||
function shownMark(mark) {
|
||||
if (!mark.label || mark.label.length <= WORLD_CLOCK_MARK_LABEL_LENGTH)
|
||||
return mark;
|
||||
const parts = graphemes(mark.label);
|
||||
if (parts.length <= WORLD_CLOCK_MARK_LABEL_LENGTH) return mark;
|
||||
const label = `${parts
|
||||
.slice(0, WORLD_CLOCK_MARK_LABEL_LENGTH - 1)
|
||||
.join('')
|
||||
.trimEnd()}…`;
|
||||
return Object.freeze({ ...mark, label });
|
||||
}
|
||||
|
||||
/**
|
||||
* A mark (a number, or `{time, label?, id?, kind?}`) in its one shape, or
|
||||
* null for one with no finite time.
|
||||
* @param {unknown} input
|
||||
* @returns {WorldClockMark | null}
|
||||
*/
|
||||
function readMark(input) {
|
||||
if (typeof input === 'number')
|
||||
return Number.isFinite(input) ? Object.freeze({ time: input }) : null;
|
||||
if (!input || typeof input !== 'object') return null;
|
||||
const { time } = input;
|
||||
if (typeof time !== 'number' || !Number.isFinite(time)) return null;
|
||||
const mark = { time };
|
||||
for (const key of MARK_TEXT) {
|
||||
const value = input[key];
|
||||
if (typeof value === 'string' && value.trim()) mark[key] = value.trim();
|
||||
}
|
||||
return Object.freeze(mark);
|
||||
}
|
||||
|
||||
// Marks in time order; at one time, by kind, label and id, so the order
|
||||
// never depends on which source registered first.
|
||||
const byText = (a = '', b = '') => (a < b ? -1 : a > b ? 1 : 0);
|
||||
const byMark = (a, b) =>
|
||||
a.time - b.time ||
|
||||
byText(a.kind, b.kind) ||
|
||||
byText(a.label, b.label) ||
|
||||
byText(a.id, b.id);
|
||||
|
||||
/** The span a JS Date can hold, either side of 1970. */
|
||||
const MAX_DATE_MS = 8.64e15;
|
||||
|
||||
@@ -191,15 +265,17 @@ export function createWorldClock({
|
||||
jumps += 1;
|
||||
changed();
|
||||
},
|
||||
/** Back to the wall clock; playback stops and its rate goes back to 1. */
|
||||
/**
|
||||
* Back to the wall clock; playback stops. The rate stays as chosen, so
|
||||
* the next play, from wherever it starts, runs at it.
|
||||
*/
|
||||
goLive() {
|
||||
if (live && !playing && rate === 1) return;
|
||||
if (live && !playing) return;
|
||||
const stepping = active;
|
||||
live = true;
|
||||
cursorMs = null;
|
||||
playing = false;
|
||||
active = null;
|
||||
rate = 1;
|
||||
jumps += 1;
|
||||
// Its driven(false) finds nothing left to stop.
|
||||
stepping?.driver.pause();
|
||||
@@ -270,7 +346,10 @@ export function createWorldClock({
|
||||
if (ms === null || ms === undefined) gates.delete(id);
|
||||
else if (isWorldTime(ms)) gates.set(id, ms);
|
||||
},
|
||||
/** Simulated ms per real ms for continuous playback. */
|
||||
/**
|
||||
* Simulated ms per real ms for continuous playback. It holds while paused
|
||||
* and live, so any play (`play()` with no rate) runs at the one chosen.
|
||||
*/
|
||||
setRate(nextRate) {
|
||||
if (!Number.isFinite(nextRate) || nextRate <= 0)
|
||||
throw new RangeError('World clock rate must be positive');
|
||||
@@ -371,7 +450,16 @@ export function createWorldClock({
|
||||
/**
|
||||
* A layer's span of time it can show, for a host's timeline; null while
|
||||
* it has none (off, or nothing loaded). Returns the unregister.
|
||||
* @param {{id: string, coverage: () => ({start: number, end: number, marks?: number[]} | null)}} source
|
||||
*
|
||||
* `marks` are the moments in that span worth going to (a launch, a strong
|
||||
* earthquake), drawn as ticks the timeline's arrow keys step to. Each is
|
||||
* an epoch ms number, or `{time, label?, id?, kind?}`: `label` is short
|
||||
* text the timeline shows for it (a name, `M6.4 · a place`; one longer
|
||||
* than WORLD_CLOCK_MARK_LABEL_LENGTH is cut to it, ending in `…`), `id` the
|
||||
* layer's own key for the event and `kind` what sort of event it is.
|
||||
* Numbers and objects may be mixed; a mark with no finite time is
|
||||
* ignored, as are a label, id or kind that is not a non-empty string.
|
||||
* @param {{id: string, coverage: () => ({start: number, end: number, marks?: Array<number | WorldClockMarkInput>} | null)}} source
|
||||
*/
|
||||
register(source) {
|
||||
// Each registration is its own, even under a shared id.
|
||||
@@ -386,20 +474,48 @@ export function createWorldClock({
|
||||
coverageChanged: () => changed(),
|
||||
/** Whether a followed layer has time to show; see getState().supported. */
|
||||
isSupported,
|
||||
/** The union of the registered sources' coverage, or null with none. */
|
||||
/**
|
||||
* The union of the registered sources' coverage, or null with none:
|
||||
* `{start, end, marks, markDetails}`. `marks` is every mark's time, once
|
||||
* each, in order, as numbers. `markDetails` is the marks themselves, in
|
||||
* time order, each `{time, label?, id?, kind?}` (frozen): a mark several
|
||||
* sources give alike is there once, and a bare time is dropped where a
|
||||
* mark with more to say shares it.
|
||||
* @returns {{start: number, end: number, marks: number[], markDetails: WorldClockMark[]} | null}
|
||||
*/
|
||||
coverage() {
|
||||
let start = Infinity;
|
||||
let end = -Infinity;
|
||||
const marks = new Set();
|
||||
const details = new Map();
|
||||
for (const { source } of sources) {
|
||||
const span = spanOf(source);
|
||||
if (!span) continue;
|
||||
start = Math.min(start, span.start);
|
||||
end = Math.max(end, span.end);
|
||||
for (const mark of span.marks ?? []) marks.add(mark);
|
||||
for (const input of span.marks ?? []) {
|
||||
const mark = readMark(input);
|
||||
if (!mark) continue;
|
||||
const key = JSON.stringify([
|
||||
mark.time,
|
||||
mark.label,
|
||||
mark.id,
|
||||
mark.kind,
|
||||
]);
|
||||
if (!details.has(key)) details.set(key, mark);
|
||||
}
|
||||
}
|
||||
if (start > end) return null;
|
||||
return { start, end, marks: [...marks].sort((a, b) => a - b) };
|
||||
const told = new Set();
|
||||
for (const mark of details.values())
|
||||
if (Object.keys(mark).length > 1) told.add(mark.time);
|
||||
// Marks merge on their whole label, and are cut for showing after, so
|
||||
// two whose labels only differ past the cut stay two.
|
||||
const markDetails = [...details.values()]
|
||||
.filter((mark) => Object.keys(mark).length > 1 || !told.has(mark.time))
|
||||
.sort(byMark)
|
||||
.map(shownMark);
|
||||
const marks = [...new Set(markDetails.map((mark) => mark.time))];
|
||||
return { start, end, marks, markDetails };
|
||||
},
|
||||
|
||||
getState,
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createWorldClock, WORLD_CLOCK_TICK_MS } from './worldClock.js';
|
||||
import {
|
||||
createWorldClock,
|
||||
WORLD_CLOCK_MARK_LABEL_LENGTH,
|
||||
WORLD_CLOCK_TICK_MS,
|
||||
} from './worldClock.js';
|
||||
|
||||
function fakeTime() {
|
||||
const t = {
|
||||
@@ -253,9 +257,60 @@ test('coverage is the union of the registered sources', () => {
|
||||
start: 50,
|
||||
end: 200,
|
||||
marks: [100, 150, 200],
|
||||
markDetails: [{ time: 100 }, { time: 150 }, { time: 200 }],
|
||||
});
|
||||
off();
|
||||
assert.deepEqual(clock.coverage(), { start: 50, end: 180, marks: [] });
|
||||
assert.deepEqual(clock.coverage(), {
|
||||
start: 50,
|
||||
end: 180,
|
||||
marks: [],
|
||||
markDetails: [],
|
||||
});
|
||||
});
|
||||
|
||||
test('marks may carry a label, an id and a kind, and merge in one order', () => {
|
||||
const clock = createWorldClock(fakeTime().options);
|
||||
clock.register({
|
||||
id: 'launches',
|
||||
coverage: () => ({
|
||||
start: 100,
|
||||
end: 300,
|
||||
marks: [
|
||||
{ time: 300, label: ' ARTEMIS II ', id: 'a2', kind: 'launch' },
|
||||
100,
|
||||
{ time: 200, label: 'M6.4 · Fiji', kind: 'earthquake', extra: 1 },
|
||||
],
|
||||
}),
|
||||
});
|
||||
clock.register({
|
||||
id: 'others',
|
||||
coverage: () => ({
|
||||
start: 100,
|
||||
end: 300,
|
||||
marks: [
|
||||
200,
|
||||
{ time: 200, label: 'M6.4 · Fiji', kind: 'earthquake' },
|
||||
{ time: 200, label: 'ALPHA', kind: 'launch' },
|
||||
{ time: 250, label: '', id: 7, kind: null },
|
||||
{ time: Number.NaN, label: 'never' },
|
||||
Number.POSITIVE_INFINITY,
|
||||
null,
|
||||
'soon',
|
||||
],
|
||||
}),
|
||||
});
|
||||
const covered = clock.coverage();
|
||||
assert.deepEqual(covered.marks, [100, 200, 250, 300], 'the times, once each');
|
||||
assert.deepEqual(covered.markDetails, [
|
||||
{ time: 100 },
|
||||
// A bare 200 says nothing a labelled mark there does not; alike marks
|
||||
// from two sources are one.
|
||||
{ time: 200, label: 'M6.4 · Fiji', kind: 'earthquake' },
|
||||
{ time: 200, label: 'ALPHA', kind: 'launch' },
|
||||
{ time: 250 },
|
||||
{ time: 300, label: 'ARTEMIS II', id: 'a2', kind: 'launch' },
|
||||
]);
|
||||
assert.ok(covered.markDetails.every(Object.isFrozen));
|
||||
});
|
||||
|
||||
test('seek refuses anything but epoch ms and rate must be positive', () => {
|
||||
@@ -306,7 +361,7 @@ test('a coverage that throws counts as none', (t) => {
|
||||
assert.equal(clock.coverage(), null);
|
||||
});
|
||||
|
||||
test('continuous play runs past every driver, and live resets the rate', () => {
|
||||
test('continuous play runs past every driver, and live keeps the rate chosen', () => {
|
||||
const t = fakeTime();
|
||||
const clock = createWorldClock(t.options);
|
||||
const calls = [];
|
||||
@@ -317,7 +372,13 @@ test('continuous play runs past every driver, and live resets the rate', () => {
|
||||
t.advance(1_000);
|
||||
assert.equal(clock.now(), t.wall - 61_000 + 30_000);
|
||||
clock.goLive();
|
||||
assert.equal(clock.getRate(), 1);
|
||||
assert.equal(clock.getRate(), 30);
|
||||
assert.equal(clock.now(), t.wall, 'live is the wall clock, whatever the rate');
|
||||
// Play with no rate given runs at the one chosen.
|
||||
clock.seek(t.wall - 60_000);
|
||||
clock.play({ continuous: true });
|
||||
t.advance(1_000);
|
||||
assert.equal(clock.now(), t.wall - 61_000 + 30_000);
|
||||
});
|
||||
|
||||
test('continuous play holds while a layer waits, and goes on from there', () => {
|
||||
@@ -408,3 +469,68 @@ test('a seek or a return to live counts as a jump; play does not', () => {
|
||||
clock.goLive();
|
||||
assert.equal(clock.getState().jumps, 2, 'already live is no jump');
|
||||
});
|
||||
|
||||
test('a mark label longer than the timeline shows is cut, ending in an ellipsis', () => {
|
||||
const clock = createWorldClock(fakeTime().options);
|
||||
const long = `${'A'.repeat(58)} BEYOND THE CUT`;
|
||||
clock.register({
|
||||
id: 'long',
|
||||
coverage: () => ({
|
||||
start: 1,
|
||||
end: 2,
|
||||
marks: [
|
||||
{ time: 1, label: long },
|
||||
{ time: 2, label: 'B'.repeat(WORLD_CLOCK_MARK_LABEL_LENGTH) },
|
||||
],
|
||||
}),
|
||||
});
|
||||
const [cut, whole] = clock.coverage().markDetails;
|
||||
assert.equal(cut.label, `${'A'.repeat(58)}…`);
|
||||
assert.ok(cut.label.length <= WORLD_CLOCK_MARK_LABEL_LENGTH);
|
||||
assert.equal(whole.label, 'B'.repeat(WORLD_CLOCK_MARK_LABEL_LENGTH));
|
||||
});
|
||||
|
||||
test('a cut label never splits an emoji, and counts it as one character', () => {
|
||||
const clock = createWorldClock(fakeTime().options);
|
||||
const a = 'A'.repeat(58);
|
||||
clock.register({
|
||||
id: 'emoji',
|
||||
coverage: () => ({
|
||||
start: 1,
|
||||
end: 3,
|
||||
marks: [
|
||||
{ time: 1, label: `${a}🚀 LIFTOFF` },
|
||||
{ time: 2, label: `${a}👩🚀 CREW` },
|
||||
// Sixty characters, though more UTF-16 units: whole.
|
||||
{ time: 3, label: `${'A'.repeat(59)}🚀` },
|
||||
],
|
||||
}),
|
||||
});
|
||||
const [rocket, crew, whole] = clock.coverage().markDetails;
|
||||
assert.equal(rocket.label, `${a}🚀…`);
|
||||
assert.equal(crew.label, `${a}👩🚀…`);
|
||||
assert.equal(whole.label, `${'A'.repeat(59)}🚀`);
|
||||
for (const { label } of [rocket, crew, whole])
|
||||
assert.equal(label.isWellFormed(), true, 'no lone surrogate');
|
||||
});
|
||||
|
||||
test('marks merge on their whole label, so labels alike up to the cut stay two', () => {
|
||||
const clock = createWorldClock(fakeTime().options);
|
||||
const stem = 'C'.repeat(WORLD_CLOCK_MARK_LABEL_LENGTH - 1);
|
||||
for (const id of ['one', 'two'])
|
||||
clock.register({
|
||||
id,
|
||||
coverage: () => ({
|
||||
start: 5,
|
||||
end: 5,
|
||||
marks: [{ time: 5, label: `${stem}${id === 'one' ? ' FIRST' : ' SECOND'}` }],
|
||||
}),
|
||||
});
|
||||
const covered = clock.coverage();
|
||||
assert.deepEqual(covered.marks, [5]);
|
||||
assert.equal(covered.markDetails.length, 2);
|
||||
for (const mark of covered.markDetails) {
|
||||
assert.equal(mark.label, `${stem}…`);
|
||||
assert.equal(Object.isFrozen(mark), true);
|
||||
}
|
||||
});
|
||||
@@ -25,7 +25,9 @@ const items = computed(() =>
|
||||
id: panel.id,
|
||||
icon: item?.icon ?? PANEL_RAIL_FALLBACK_ICON,
|
||||
// Static markup is translated at boot, so a host's title already is.
|
||||
label: item ? t(item.label) : panel.title,
|
||||
label: item
|
||||
? t(item.label, item.context && { context: item.context })
|
||||
: panel.title,
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -232,6 +232,7 @@ export class StyleManager extends ShellFacade {
|
||||
getDetectionTuning: services.getDetectionTuning,
|
||||
getKeyholeFadeTuning: services.getKeyholeFadeTuning,
|
||||
getScopeMaskFeather: services.getScopeMaskFeather,
|
||||
getScopeMaskOpacity: services.getScopeMaskOpacity,
|
||||
getScopeTerminusOverride: services.getScopeTerminusOverride,
|
||||
governorRequestRender: services.governorRequestRender,
|
||||
holdContinuousRender: services.holdContinuousRender,
|
||||
@@ -245,6 +246,7 @@ export class StyleManager extends ShellFacade {
|
||||
setKeyholeFadeTuning: services.setKeyholeFadeTuning,
|
||||
setScopeMaskEnabled: services.setScopeMaskEnabled,
|
||||
setScopeMaskFeather: services.setScopeMaskFeather,
|
||||
setScopeMaskOpacity: services.setScopeMaskOpacity,
|
||||
},
|
||||
elements: {
|
||||
_ppToggles: this._ppToggles,
|
||||
@@ -609,6 +611,10 @@ export class StyleManager extends ShellFacade {
|
||||
this._setDetectionAllocation(...args),
|
||||
_setDetectionFade: (...args) => this._setDetectionFade(...args),
|
||||
_setScope: (...args) => this._visualSettings._setScope(...args),
|
||||
_applyGlobalPostDefaults: (...args) =>
|
||||
this._applyGlobalPostDefaults(...args),
|
||||
_adoptDetectionAsRestore: () =>
|
||||
this._visualSettings.adoptDetectionAsRestore(),
|
||||
setCelestialRingEnabled: (...args) =>
|
||||
this.setCelestialRingEnabled(...args),
|
||||
_setModels3dEnabled: (...args) => this._setModels3dEnabled(...args),
|
||||
|
||||
@@ -280,7 +280,7 @@ test('a tracked flight’s photo shows under its name, credited and linked to it
|
||||
test('no photo renders without one', async (t) => {
|
||||
const { panel, publish } = fixture(t);
|
||||
await publish({ ...results(), photo: null });
|
||||
assert.equal(panel().querySelector('.military-awareness-photo'), null);
|
||||
assert.equal(panel().querySelector('.military-awareness-photo') === null, true);
|
||||
});
|
||||
|
||||
test('a photo whose image fails to load is hidden until another arrives', async (t) => {
|
||||
@@ -290,10 +290,10 @@ test('a photo whose image fails to load is hidden until another arrives', async
|
||||
.querySelector('.military-awareness-photo img')
|
||||
.dispatchEvent(new Event('error'));
|
||||
await nextTick();
|
||||
assert.equal(panel().querySelector('.military-awareness-photo'), null);
|
||||
assert.equal(panel().querySelector('.military-awareness-photo') === null, true);
|
||||
// A repaint with the same photo keeps it hidden.
|
||||
await publish({ ...results({ previousDisabled: false }), photo: photo() });
|
||||
assert.equal(panel().querySelector('.military-awareness-photo'), null);
|
||||
assert.equal(panel().querySelector('.military-awareness-photo') === null, true);
|
||||
// Another plane's photo shows.
|
||||
const next = photo({ src: 'https://t.plnspttrs.net/2/def456_280.jpg' });
|
||||
await publish({ ...results(), photo: next });
|
||||
|
||||
@@ -909,7 +909,7 @@ test('arrows do nothing new in an aircraft cockpit', async (t) => {
|
||||
near(after.pitchDeg, before.pitchDeg, 'the aircraft pitch', 1e-6);
|
||||
assert.deepEqual(cockpit.lookTarget, { yawDeg: 0, pitchDeg: -2 });
|
||||
assert.equal(store.instruments.look.offset, false);
|
||||
assert.equal(document.querySelector('.cockpit-look'), null);
|
||||
assert.equal(document.querySelector('.cockpit-look') === null, true);
|
||||
// The tape stays on the aircraft's heading, with no bow or stern marks.
|
||||
const centre = store.instruments.compass.find(
|
||||
(division) => division.slot === 0,
|
||||
@@ -919,7 +919,7 @@ test('arrows do nothing new in an aircraft cockpit', async (t) => {
|
||||
prograde: null,
|
||||
retrograde: null,
|
||||
});
|
||||
assert.equal(document.querySelector('.cockpit-compass-marker'), null);
|
||||
assert.equal(document.querySelector('.cockpit-compass-marker') === null, true);
|
||||
assert.doesNotMatch(
|
||||
document.querySelector('.cockpit-help').textContent,
|
||||
/ARROWS LOOK/,
|
||||
@@ -1323,7 +1323,7 @@ test('a ship with neither heading nor course makes up no direction', async (t) =
|
||||
prograde: null,
|
||||
retrograde: null,
|
||||
});
|
||||
assert.equal(document.querySelector('.cockpit-compass-marker'), null);
|
||||
assert.equal(document.querySelector('.cockpit-compass-marker') === null, true);
|
||||
assert.match(
|
||||
$('.cockpit-visor-status-right').textContent,
|
||||
/NO HEADING · AIS/,
|
||||
|
||||
@@ -310,6 +310,9 @@ export function onKeyDown(event) {
|
||||
if (event.target?.closest?.('.cesium-credit-lightbox')) return;
|
||||
// An open Display or Radio popover takes Escape itself.
|
||||
if (this.isUtilityDisclosureOpen?.()) return;
|
||||
// So do the Data Layers search field and filter menu.
|
||||
if (event.target?.closest?.('.layer-finder__field, .layer-finder__menu'))
|
||||
return;
|
||||
if (this.context?.contains(event.target) && !this.contextCollapsed) {
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
|
||||
@@ -45,7 +45,7 @@ function fixture(t) {
|
||||
test('the orbital HUD is hidden until a satellite view is published', async (t) => {
|
||||
const f = fixture(t);
|
||||
assert.equal(f.section().hidden, true);
|
||||
assert.equal(f.section().querySelector('#cockpit-orbital-zoom-in'), null);
|
||||
assert.equal(f.section().querySelector('#cockpit-orbital-zoom-in') === null, true);
|
||||
});
|
||||
|
||||
test('a published orbital view renders its readouts and zoom controls', async (t) => {
|
||||
@@ -97,7 +97,7 @@ test('an unknown velocity leaves its row out', async (t) => {
|
||||
const f = fixture(t);
|
||||
f.store.publishOrbital({ ...VIEW, velocityMps: null });
|
||||
await nextTick();
|
||||
assert.equal(f.section().querySelector('.cockpit-orbital-velocity'), null);
|
||||
assert.equal(f.section().querySelector('.cockpit-orbital-velocity') === null, true);
|
||||
assert.equal(f.text('.cockpit-orbital-altitude'), '418 KM');
|
||||
});
|
||||
|
||||
@@ -145,7 +145,7 @@ test('publishing null hides the orbital HUD again', async (t) => {
|
||||
f.store.publishOrbital(null);
|
||||
await nextTick();
|
||||
assert.equal(f.section().hidden, true);
|
||||
assert.equal(f.section().querySelector('.cockpit-orbital-name'), null);
|
||||
assert.equal(f.section().querySelector('.cockpit-orbital-name') === null, true);
|
||||
});
|
||||
|
||||
const ISS_TLE = Object.freeze({
|
||||
@@ -160,7 +160,7 @@ test('the place below shows at the top once known', async (t) => {
|
||||
const f = fixture(t);
|
||||
f.store.publishOrbital({ ...VIEW, place: undefined });
|
||||
await nextTick();
|
||||
assert.equal(f.section().querySelector('#cockpit-orbital-over'), null);
|
||||
assert.equal(f.section().querySelector('#cockpit-orbital-over') === null, true);
|
||||
const over = () =>
|
||||
f.section().querySelector('#cockpit-orbital-over strong')?.textContent;
|
||||
f.store.publishOrbital({
|
||||
@@ -195,7 +195,7 @@ test('the place below shows at the top once known', async (t) => {
|
||||
// says nothing rather than call land open ocean.
|
||||
f.store.publishOrbital({ ...VIEW, place: null });
|
||||
await nextTick();
|
||||
assert.equal(document.querySelector('#cockpit-orbital-over'), null);
|
||||
assert.equal(document.querySelector('#cockpit-orbital-over') === null, true);
|
||||
});
|
||||
|
||||
test('an owner country shows its flag from the sheet, or its code if the sheet will not load', async (t) => {
|
||||
@@ -216,7 +216,7 @@ test('an owner country shows its flag from the sheet, or its code if the sheet w
|
||||
owner: { countryCode: 'US', label: 'USA' },
|
||||
});
|
||||
await nextTick();
|
||||
assert.equal(f.section().querySelector('.cockpit-orbital-flag'), null);
|
||||
assert.equal(f.section().querySelector('.cockpit-orbital-flag') === null, true);
|
||||
assert.equal(images.length, 1, 'the sheet is asked for');
|
||||
images[0].onerror();
|
||||
await settle();
|
||||
@@ -244,7 +244,7 @@ test('an owner country shows its flag from the sheet, or its code if the sheet w
|
||||
flag.style.backgroundPosition,
|
||||
ownerFlagStyle('FR').backgroundPosition,
|
||||
);
|
||||
assert.equal(f.section().querySelector('.cockpit-orbital-owner-badge'), null);
|
||||
assert.equal(f.section().querySelector('.cockpit-orbital-owner-badge') === null, true);
|
||||
});
|
||||
|
||||
test('the readout names the owner, operator and element set', async (t) => {
|
||||
@@ -327,7 +327,7 @@ test('unknown identity fields leave their rows out', async (t) => {
|
||||
'.cockpit-orbital-ident',
|
||||
'#cockpit-orbital-tle',
|
||||
])
|
||||
assert.equal(f.section().querySelector(selector), null, selector);
|
||||
assert.equal(f.section().querySelector(selector) === null, true, selector);
|
||||
// An element set with no NORAD id still dates itself.
|
||||
f.store.publishOrbital({ ...VIEW, tle: ISS_TLE });
|
||||
await nextTick();
|
||||
|
||||
@@ -27,9 +27,11 @@ export const COCKPIT_UTILITY_REC_GAP_PX = 12;
|
||||
|
||||
export const COCKPIT_UTILITY_SIGNAL_GAP_PX = 8;
|
||||
|
||||
export const COCKPIT_UTILITY_MIN_TOP_PX = 96;
|
||||
// Display and Radio start where the left rail does (max(206px, 22vh) in
|
||||
// cockpit-panels.css), so the two rails' tops line up.
|
||||
export const COCKPIT_UTILITY_MIN_TOP_PX = 206;
|
||||
|
||||
export const COCKPIT_UTILITY_MIN_TOP_RATIO = 0.12;
|
||||
export const COCKPIT_UTILITY_MIN_TOP_RATIO = 0.22;
|
||||
|
||||
export const COCKPIT_UTILITY_LAUNCHER_MIN_HEIGHT_PX = 50;
|
||||
|
||||
|
||||
@@ -450,3 +450,42 @@ test('the real layout pass drives the mounted controls: compact hides the collap
|
||||
assert.equal(cockpit.utilityLayout.top, '120.00px');
|
||||
assert.equal(strip.classList.contains('layout-primary-only'), false);
|
||||
});
|
||||
|
||||
test('the rail opens one panel at a time and reads as a disclosure', async (t) => {
|
||||
const { $, controls } = fixture(t);
|
||||
const item = (kind) =>
|
||||
document.querySelector(`[data-cockpit-rail-item="${kind}"]`);
|
||||
item('display').click();
|
||||
await nextTick();
|
||||
assert.equal($('cockpit-display-panel').hidden, false);
|
||||
assert.equal(item('display').getAttribute('aria-expanded'), 'true');
|
||||
assert.equal(
|
||||
item('display').getAttribute('aria-controls'),
|
||||
'cockpit-display-panel',
|
||||
);
|
||||
item('radio').click();
|
||||
await nextTick();
|
||||
assert.equal($('cockpit-display-panel').hidden, true);
|
||||
assert.equal($('cockpit-radio-panel').hidden, false);
|
||||
assert.equal(item('display').getAttribute('aria-expanded'), 'false');
|
||||
assert.equal(item('radio').getAttribute('aria-expanded'), 'true');
|
||||
item('radio').click();
|
||||
await nextTick();
|
||||
assert.equal(controls._cockpitDisclosureOpen('radio'), false);
|
||||
assert.equal(controls._cockpitDisclosureOpen('display'), false);
|
||||
});
|
||||
|
||||
test('collapsing an open panel hands focus to the rail when its toggle is hidden', async (t) => {
|
||||
const { $, controls } = fixture(t);
|
||||
const railItem = document.querySelector('[data-cockpit-rail-item="radio"]');
|
||||
// happy-dom lays nothing out: show the rail and hide the launcher's toggle
|
||||
// as the desktop look does.
|
||||
railItem.getClientRects = () => [{ width: 32, height: 32 }];
|
||||
$('cockpit-radio-toggle-btn').getClientRects = () => [];
|
||||
controls._setCockpitDisclosure('radio', true);
|
||||
await nextTick();
|
||||
document.querySelector('.cockpit-utility-collapse').click();
|
||||
await nextTick();
|
||||
assert.equal($('cockpit-radio-panel').hidden, true);
|
||||
assert.equal(document.activeElement, railItem);
|
||||
});
|
||||
@@ -142,7 +142,7 @@ test('the map source row renders the published chips and selects through the con
|
||||
assert.equal(osm.classList.contains('active'), true);
|
||||
assert.equal(osm.getAttribute('aria-pressed'), 'true');
|
||||
assert.equal(osm.hasAttribute('aria-label'), false);
|
||||
assert.equal(esri.querySelector('.map-stack-chip-req'), null);
|
||||
assert.equal(esri.querySelector('.map-stack-chip-req') === null, true);
|
||||
bing.click();
|
||||
esri.click();
|
||||
assert.deepEqual(selected, ['esri-imagery']);
|
||||
|
||||
@@ -56,6 +56,8 @@ import {
|
||||
isScopeMaskEnabled,
|
||||
setScopeMaskFeather,
|
||||
getScopeMaskFeather,
|
||||
setScopeMaskOpacity,
|
||||
getScopeMaskOpacity,
|
||||
setScopeTerminusOverride,
|
||||
getScopeTerminusOverride,
|
||||
clampScopeTerminusPct,
|
||||
@@ -112,6 +114,8 @@ export class StyleManager extends ApplicationShell {
|
||||
isScopeMaskEnabled,
|
||||
setScopeMaskFeather,
|
||||
getScopeMaskFeather,
|
||||
setScopeMaskOpacity,
|
||||
getScopeMaskOpacity,
|
||||
setScopeTerminusOverride,
|
||||
getScopeTerminusOverride,
|
||||
clampScopeTerminusPct,
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
import { getScopeMaskFeather, isScopeMaskEnabled, setScopeMaskEnabled, setScopeMaskFeather } from '../scopeMask.js';
|
||||
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';
|
||||
@@ -283,7 +290,7 @@ test('scope choice and expanded feather survive every HUD layout and both restor
|
||||
let shown = null;
|
||||
owner.store = { publish: (view) => (shown = view.scope) };
|
||||
await owner.restoreShareState({ scopeEnabled: false, scopeFeatherPct: 200 });
|
||||
assert.deepEqual(shown, { enabled: false, featherPct: 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);
|
||||
@@ -293,10 +300,44 @@ test('scope choice and expanded feather survive every HUD layout and both restor
|
||||
await owner.applyVisualState({ scope: { enabled: true, featherPct: 175 } });
|
||||
assert.equal(isScopeMaskEnabled(), true);
|
||||
assert.equal(getScopeMaskFeather(), 1.75);
|
||||
assert.deepEqual(shown, { enabled: true, featherPct: 175 });
|
||||
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 });
|
||||
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) => {
|
||||
|
||||
@@ -105,6 +105,11 @@ export class DisplayBindings {
|
||||
this._setScope({ featherPct: value });
|
||||
this._syncShareState();
|
||||
},
|
||||
setScopeOpacity: (value) => {
|
||||
this.shareLinkManager?.claimRestoreLane?.('visual');
|
||||
this._setScope({ opacityPct: Number(value) });
|
||||
this._syncShareState();
|
||||
},
|
||||
setSharpenIntensity: (pct) => {
|
||||
this.shareLinkManager?.claimRestoreLane?.('visual');
|
||||
this._setSharpenIntensity(pct);
|
||||
@@ -168,6 +173,28 @@ export class DisplayBindings {
|
||||
this._syncModels3dModeRow();
|
||||
},
|
||||
setModelsMode: (mode) => this._setModels3dMode(mode),
|
||||
// Back to the out-of-the-box look: Normal style, the global post
|
||||
// defaults (bloom, sharpen, HUD, labels, celestial), scope on at full
|
||||
// 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._applyGlobalPostDefaults({ keepHudVariant: true });
|
||||
this._setDetectionAllocation('ELASTIC');
|
||||
this._setScope({ enabled: true, featherPct: 100, opacityPct: 100 });
|
||||
this._setModels3dEnabled(true);
|
||||
this._setModels3dMode('proximity');
|
||||
this._syncModels3dModeRow?.();
|
||||
// Inside Contacts the detection shown is lent for the session, and
|
||||
// leaving puts back the state from before. A reset there is the user's
|
||||
// choice, so the defaults become what leaving puts back and what a
|
||||
// share link carries.
|
||||
this.claimDetection();
|
||||
this._adoptDetectionAsRestore?.();
|
||||
this._syncShareState();
|
||||
},
|
||||
});
|
||||
this._detachDisplayControls = () => store.detach(token);
|
||||
}
|
||||
|
||||
@@ -108,7 +108,11 @@ test('bloom and sharpen render their state, slider and readout', async (t) => {
|
||||
await nextTick();
|
||||
assert.equal($('bloom-toggle').classList.contains('active'), false);
|
||||
assert.equal($('bloom-slider-row').classList.contains('visible'), false);
|
||||
assert.equal($('bloom-intensity-value').textContent, '140%', 'the amount stays');
|
||||
assert.equal(
|
||||
$('bloom-intensity-value').textContent,
|
||||
'140%',
|
||||
'the amount stays',
|
||||
);
|
||||
});
|
||||
|
||||
test('a publish never rewrites a slider the user is dragging', async (t) => {
|
||||
@@ -314,6 +318,73 @@ test('Scope and Celestial render what VisualSettings shows', async (t) => {
|
||||
assert.equal(celestial.title, 'Celestial ring — reveal the full globe');
|
||||
});
|
||||
|
||||
test('scope opacity renders what VisualSettings shows and sets the mask', async (t) => {
|
||||
const { store, $ } = fixture(t);
|
||||
const { owner } = settings(store);
|
||||
const mask = { opacity: 1 };
|
||||
owner.services = {
|
||||
...owner.services,
|
||||
setScopeMaskEnabled() {},
|
||||
setScopeMaskOpacity: (value) => (mask.opacity = value),
|
||||
};
|
||||
assert.equal($('scope-opacity-slider').value, '100');
|
||||
assert.equal($('scope-opacity-value').textContent, '100%');
|
||||
|
||||
owner._setScope({ opacityPct: 62.4 });
|
||||
await nextTick();
|
||||
assert.equal(mask.opacity, 0.62);
|
||||
assert.equal($('scope-opacity-slider').value, '62');
|
||||
assert.equal($('scope-opacity-value').textContent, '62%');
|
||||
assert.equal(store.view.scope.opacityPct, 62);
|
||||
|
||||
// No fainter than the floor, where the view would read as Scope off.
|
||||
owner._setScope({ opacityPct: 10 });
|
||||
await nextTick();
|
||||
assert.equal(mask.opacity, 0.5, 'floored');
|
||||
assert.equal($('scope-opacity-value').textContent, '50%');
|
||||
assert.equal($('scope-opacity-slider').min, '50');
|
||||
|
||||
// A value that is not a number changes nothing.
|
||||
owner._setScope({ opacityPct: Number.NaN });
|
||||
await nextTick();
|
||||
assert.equal($('scope-opacity-value').textContent, '50%');
|
||||
|
||||
owner._setScope({ opacityPct: 180 });
|
||||
await nextTick();
|
||||
assert.equal(mask.opacity, 1, 'clamped');
|
||||
assert.equal($('scope-opacity-value').textContent, '100%');
|
||||
|
||||
owner._setScope({ opacityPct: 70 }, { apply: false });
|
||||
await nextTick();
|
||||
assert.equal(mask.opacity, 1, 'only shown');
|
||||
assert.equal($('scope-opacity-value').textContent, '70%');
|
||||
|
||||
owner._setScope({ enabled: false });
|
||||
await nextTick();
|
||||
assert.equal($('scope-opacity-slider').disabled, true, 'off with the scope');
|
||||
assert.equal(store.view.scope.opacityPct, 70, 'kept while off');
|
||||
});
|
||||
|
||||
test('the Visual panel groups its controls and words its on/off pills', (t) => {
|
||||
const { $ } = fixture(t);
|
||||
const panel = $('pp-toggles');
|
||||
assert.deepEqual(
|
||||
[
|
||||
...panel.querySelectorAll(
|
||||
'.pp-section-heading, .visual-presets__heading',
|
||||
),
|
||||
].map((el) => el.textContent.trim()),
|
||||
['Look', 'MAP SOURCE 3D', 'Overlay', 'Effects'],
|
||||
);
|
||||
assert.equal(panel.querySelector('.pp-header-label').textContent, 'VISUAL');
|
||||
const body = panel.querySelector('.pp-panel-body');
|
||||
assert.equal(body.style.getPropertyValue('--pp-pill-on'), '"ON"');
|
||||
assert.equal(body.style.getPropertyValue('--pp-pill-off'), '"OFF"');
|
||||
const reset = panel.querySelector('.pp-reset-btn');
|
||||
assert.equal(reset, body.lastElementChild, 'the reset closes the panel');
|
||||
assert.equal(reset.textContent.trim(), 'restart_altReset to default');
|
||||
});
|
||||
|
||||
test('the 3D aircraft group renders what AircraftDisplay shows', async (t) => {
|
||||
const { store, $ } = fixture(t);
|
||||
const params = [];
|
||||
@@ -331,7 +402,10 @@ test('the 3D aircraft group renders what AircraftDisplay shows', async (t) => {
|
||||
assert.equal(coreClasses(button), 'pp-toggle-btn active');
|
||||
assert.equal(button.getAttribute('aria-pressed'), 'true');
|
||||
assert.equal(row.classList.contains('visible'), true);
|
||||
assert.equal($('models3d-mode-proximity').getAttribute('aria-checked'), 'true');
|
||||
assert.equal(
|
||||
$('models3d-mode-proximity').getAttribute('aria-checked'),
|
||||
'true',
|
||||
);
|
||||
|
||||
// The button leaves the row to its own sync.
|
||||
owner._setModels3dEnabled(false);
|
||||
@@ -347,7 +421,10 @@ test('the 3D aircraft group renders what AircraftDisplay shows', async (t) => {
|
||||
await nextTick();
|
||||
assert.equal(all.classList.contains('active'), true);
|
||||
assert.equal(all.getAttribute('aria-checked'), 'true');
|
||||
assert.equal($('models3d-mode-proximity').classList.contains('active'), false);
|
||||
assert.equal(
|
||||
$('models3d-mode-proximity').classList.contains('active'),
|
||||
false,
|
||||
);
|
||||
assert.deepEqual(params.at(-1), ['military', { models3dMode: 'all' }]);
|
||||
|
||||
owner._syncModels3dFromLayerState({
|
||||
@@ -376,12 +453,18 @@ test('the Draw controls render what the draw tool publishes', async (t) => {
|
||||
assert.equal(segment('area').getAttribute('aria-label'), 'Area');
|
||||
assert.equal(segment('area').title, 'Area');
|
||||
assert.equal(segment('area').textContent, 'pentagon');
|
||||
const swatch = (color) => document.querySelector(`#draw-colors [data-color="${color}"]`);
|
||||
const swatch = (color) =>
|
||||
document.querySelector(`#draw-colors [data-color="${color}"]`);
|
||||
assert.equal(swatch('primary').getAttribute('aria-checked'), 'true');
|
||||
assert.equal(swatch('amber').getAttribute('aria-label'), 'Amber');
|
||||
assert.equal($('draw-hint').textContent, '');
|
||||
|
||||
store.publishDraw({ active: true, shape: 'line', color: 'amber', hint: 'Click to add points.' });
|
||||
store.publishDraw({
|
||||
active: true,
|
||||
shape: 'line',
|
||||
color: 'amber',
|
||||
hint: 'Click to add points.',
|
||||
});
|
||||
await nextTick();
|
||||
assert.equal(swatch('amber').getAttribute('aria-checked'), 'true');
|
||||
assert.equal(swatch('primary').classList.contains('active'), false);
|
||||
@@ -476,7 +559,10 @@ test('the imported files render what the file import publishes and keep focus',
|
||||
assert.equal(document.activeElement === button(first, 'toggle'), true);
|
||||
assert.equal(button(first, 'toggle').getAttribute('aria-pressed'), 'true');
|
||||
assert.equal(button(first, 'fly').title, 'Fly to <b>a</b>.geojson');
|
||||
assert.equal(button(first, 'remove').getAttribute('aria-label'), 'Remove <b>a</b>.geojson');
|
||||
assert.equal(
|
||||
button(first, 'remove').getAttribute('aria-label'),
|
||||
'Remove <b>a</b>.geojson',
|
||||
);
|
||||
|
||||
await press(button(first, 'remove'));
|
||||
assert.equal(rowsNow().length, 1);
|
||||
@@ -592,7 +678,11 @@ test('VisualSettings publishes a style’s parameters and writes a moved slider
|
||||
assert.equal(store.parameters, null, 'the sliders go with their owner');
|
||||
assert.equal($('param-slider-panel').classList.contains('active'), false);
|
||||
assert.equal(store.act('setStyleParameter', 'grainAmt', 0.2), undefined);
|
||||
assert.equal(owner.stages.noir.uniforms.grainAmt, 0.3, 'a stopped owner no longer answers');
|
||||
assert.equal(
|
||||
owner.stages.noir.uniforms.grainAmt,
|
||||
0.3,
|
||||
'a stopped owner no longer answers',
|
||||
);
|
||||
// An older owner's stop leaves a newer owner's rows.
|
||||
const newer = { style: 'noir', rows: [] };
|
||||
owner._parameters = { style: 'noir', rows: [] };
|
||||
@@ -604,10 +694,16 @@ test('VisualSettings publishes a style’s parameters and writes a moved slider
|
||||
test('the four Cockpit groups teleport to the published slots and back to their places', async (t) => {
|
||||
const { store, $ } = fixture(t);
|
||||
const groupOf = (id) => $(id).closest('.pp-toggle-group') ?? $(id);
|
||||
const ids = ['hud-toggle', 'detection-toggle', 'param-slider-panel', 'models3d-toggle'];
|
||||
const ids = [
|
||||
'hud-toggle',
|
||||
'detection-toggle',
|
||||
'param-slider-panel',
|
||||
'models3d-toggle',
|
||||
];
|
||||
const body = $('pp-toggles').querySelector('.pp-panel-body');
|
||||
const order = () =>
|
||||
[...body.children].filter((el) => el.matches('.pp-toggle-group, #param-slider-panel'))
|
||||
[...body.children]
|
||||
.filter((el) => el.matches('.pp-toggle-group, #param-slider-panel'))
|
||||
.map((el) => el.id || el.querySelector('[id]')?.id);
|
||||
const home = order();
|
||||
const popover = document.body.appendChild(document.createElement('div'));
|
||||
|
||||
@@ -8,6 +8,7 @@ import { createApp, h, nextTick } from 'vue';
|
||||
import { createPinia } from 'pinia';
|
||||
import { useDisplayStore } from './stores/display.js';
|
||||
import { DisplayBindings } from './displayBindings.js';
|
||||
import { VisualSettings } from './visualSettings.js';
|
||||
import CommandDockView from './views/CommandDockView.vue';
|
||||
import DisplayControlsView from './views/DisplayControlsView.vue';
|
||||
import DrawControls from './views/panels/DrawControls.vue';
|
||||
@@ -231,3 +232,125 @@ test('several owners answer their own actions, the newest first', (t) => {
|
||||
['display', 'toggleBloom'],
|
||||
]);
|
||||
});
|
||||
|
||||
test('the Visual panel’s scope opacity, reset and presets call their actions', async (t) => {
|
||||
const store = mount(t);
|
||||
const { calls } = recorder(store);
|
||||
const selected = [];
|
||||
store.connectMapSource({ select: async (id) => selected.push(id) });
|
||||
store.publishMapSource({
|
||||
status: { text: 'OSM', warn: false },
|
||||
chips: [
|
||||
{ id: 'photoreal', label: 'Google 3D', available: false },
|
||||
{ id: 'osm', label: 'OSM', available: true, active: true },
|
||||
],
|
||||
});
|
||||
await nextTick();
|
||||
input($('scope-opacity-slider'), 60);
|
||||
document.querySelector('#pp-toggles .pp-reset-btn').click();
|
||||
const presets = document.querySelector('#pp-toggles .visual-presets');
|
||||
presets.querySelector('[data-style="noir"]').click();
|
||||
const chips = presets.querySelectorAll('.visual-presets__chip');
|
||||
chips[0].click();
|
||||
chips[1].click();
|
||||
assert.deepEqual(calls, [
|
||||
['setScopeOpacity', 60],
|
||||
['resetVisual'],
|
||||
['setStyle', 'noir'],
|
||||
]);
|
||||
assert.deepEqual(selected, ['osm'], 'an unavailable source is not selected');
|
||||
// The presets follow the published style, as the dock's do.
|
||||
assert.equal(
|
||||
presets.querySelector('[data-style="normal"]').getAttribute('aria-pressed'),
|
||||
'true',
|
||||
);
|
||||
store.publishStyle({ name: 'noir', label: 'NOIR' });
|
||||
await nextTick();
|
||||
assert.equal(
|
||||
presets.querySelector('[data-style="noir"]').getAttribute('aria-pressed'),
|
||||
'true',
|
||||
);
|
||||
assert.equal(
|
||||
presets.querySelector('[data-style="normal"]').getAttribute('aria-pressed'),
|
||||
'false',
|
||||
);
|
||||
// The dock keeps its own presets and map source beside them.
|
||||
assert.ok(
|
||||
document.querySelector('#control-panel .style-btn[data-style="noir"]'),
|
||||
);
|
||||
assert.ok($('map-stack-chips'));
|
||||
});
|
||||
|
||||
test('DisplayBindings sets the scope opacity and resets Visual to its defaults', (t) => {
|
||||
const store = mount(t);
|
||||
const calls = [];
|
||||
const bindings = new DisplayBindings({
|
||||
viewer: null,
|
||||
services: { isScopeMaskEnabled: () => true, cycleDetectionMode: () => {} },
|
||||
elements: { _locationSearch: document.createElement('input') },
|
||||
operations: {
|
||||
setStyle: (style, options) => calls.push(['style', style, options]),
|
||||
_applyGlobalPostDefaults: (options) =>
|
||||
calls.push(['postDefaults', options]),
|
||||
_setDetectionAllocation: (value) => calls.push(['allocation', value]),
|
||||
_setScope: (scope) => calls.push(['scope', scope]),
|
||||
_setModels3dEnabled: (on) => calls.push(['models3d', on]),
|
||||
_setModels3dMode: (mode) => calls.push(['models3dMode', mode]),
|
||||
_syncModels3dModeRow: () => calls.push(['models3dRow']),
|
||||
_syncShareState: () => calls.push(['share']),
|
||||
_adoptDetectionAsRestore: () => calls.push(['adoptDetection']),
|
||||
},
|
||||
readState: () => ({
|
||||
shareLinkManager: {
|
||||
claimRestoreLane: (lane) => calls.push(['claim', lane]),
|
||||
},
|
||||
}),
|
||||
claimDetection: () => calls.push(['claimDetection']),
|
||||
displayStore: store,
|
||||
});
|
||||
bindings._initUI();
|
||||
t.after(() => bindings.destroy());
|
||||
calls.length = 0;
|
||||
input($('scope-opacity-slider'), 65);
|
||||
assert.deepEqual(calls, [
|
||||
['claim', 'visual'],
|
||||
['scope', { opacityPct: 65 }],
|
||||
['share'],
|
||||
]);
|
||||
calls.length = 0;
|
||||
document.querySelector('#pp-toggles .pp-reset-btn').click();
|
||||
assert.deepEqual(calls, [
|
||||
['claim', 'visual'],
|
||||
['style', 'normal', { userInitiated: true }],
|
||||
['postDefaults', { keepHudVariant: true }],
|
||||
['allocation', 'ELASTIC'],
|
||||
['scope', { enabled: true, featherPct: 100, opacityPct: 100 }],
|
||||
['models3d', true],
|
||||
['models3dMode', 'proximity'],
|
||||
['models3dRow'],
|
||||
['claimDetection'],
|
||||
['adoptDetection'],
|
||||
['share'],
|
||||
]);
|
||||
});
|
||||
|
||||
test('a reset inside Contacts makes the shown detection what leaving puts back', () => {
|
||||
const adopt = VisualSettings.prototype.adoptDetectionAsRestore;
|
||||
const live = { detectionMode: 'DENSE', densityPct: 75 };
|
||||
const inContacts = {
|
||||
_contactsDetectionRestore: { mode: 'OFF', densityPct: 50 },
|
||||
getDetectionState: () => live,
|
||||
};
|
||||
adopt.call(inContacts);
|
||||
assert.deepEqual(inContacts._contactsDetectionRestore, {
|
||||
mode: 'DENSE',
|
||||
densityPct: 75,
|
||||
});
|
||||
// Outside Contacts there is no saved state to change.
|
||||
const outside = {
|
||||
_contactsDetectionRestore: null,
|
||||
getDetectionState: () => live,
|
||||
};
|
||||
adopt.call(outside);
|
||||
assert.equal(outside._contactsDetectionRestore, null);
|
||||
});
|
||||
@@ -0,0 +1,200 @@
|
||||
// src/ui/layerFinder.test.mjs — the Data Layers finder and section index work
|
||||
// on the rows LayerRows renders: search, the On/Off and category filter,
|
||||
// Escape, the clear request voice sends, and the group ticks.
|
||||
import '../testSupport/registerDom.mjs';
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createApp, h, nextTick } from 'vue';
|
||||
import LayerFinder, {
|
||||
LAYER_FINDER_CLEAR_EVENT,
|
||||
} from './views/panels/LayerFinder.vue';
|
||||
import LayerSectionIndex from './views/panels/LayerSectionIndex.vue';
|
||||
|
||||
const ROWS = [
|
||||
{ group: 'movement', heading: 'Movement' },
|
||||
{ id: 'flights', name: 'Live Flights', english: 'Live Flights', on: true },
|
||||
{ id: 'ships', name: 'Ships', english: 'Ships', on: false },
|
||||
{ group: 'weather', heading: 'Weather' },
|
||||
{ id: 'radar', name: 'Radar météo', english: 'Weather Radar', on: false },
|
||||
];
|
||||
|
||||
const flush = async () => {
|
||||
await nextTick();
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
await nextTick();
|
||||
};
|
||||
|
||||
function fixture(t) {
|
||||
document.body.replaceChildren();
|
||||
// Frames run at once, so the observers' batching does not hold a test up.
|
||||
globalThis.requestAnimationFrame = (fn) => setTimeout(fn, 0);
|
||||
globalThis.cancelAnimationFrame = (id) => clearTimeout(id);
|
||||
const panel = document.body.appendChild(document.createElement('section'));
|
||||
panel.id = 'data-panel';
|
||||
const header = panel.appendChild(document.createElement('div'));
|
||||
const bar = panel.appendChild(document.createElement('div'));
|
||||
const list = panel.appendChild(document.createElement('div'));
|
||||
list.id = 'data-toggles';
|
||||
for (const row of ROWS) {
|
||||
if (row.heading) {
|
||||
const heading = list.appendChild(document.createElement('h3'));
|
||||
heading.className = 'data-layer-group-heading';
|
||||
heading.dataset.group = row.group;
|
||||
heading.textContent = row.heading;
|
||||
continue;
|
||||
}
|
||||
const el = list.appendChild(document.createElement('div'));
|
||||
el.className = 'data-toggle-row';
|
||||
el.dataset.layerId = row.id;
|
||||
el.dataset.layerName = row.english;
|
||||
el.innerHTML = `<span class="data-name">${row.name}</span><button class="data-toggle-btn${row.on ? ' active' : ''}"></button>`;
|
||||
}
|
||||
const index = panel.appendChild(document.createElement('div'));
|
||||
const apps = [
|
||||
createApp(() => h(LayerFinder, { part: 'buttons' })),
|
||||
createApp(() => h(LayerFinder, { part: 'bar' })),
|
||||
createApp(LayerSectionIndex),
|
||||
];
|
||||
apps[0].mount(header);
|
||||
apps[1].mount(bar);
|
||||
apps[2].mount(index);
|
||||
t.after(async () => {
|
||||
document.dispatchEvent(new CustomEvent(LAYER_FINDER_CLEAR_EVENT));
|
||||
for (const app of apps) app.unmount();
|
||||
});
|
||||
const shown = () =>
|
||||
[...list.querySelectorAll('.data-toggle-row:not(.is-filtered)')].map(
|
||||
(row) => row.dataset.layerId,
|
||||
);
|
||||
const search = async (text) => {
|
||||
if (!document.getElementById('layer-finder-input')) {
|
||||
document.getElementById('layer-finder-search-btn').click();
|
||||
await flush();
|
||||
}
|
||||
const input = document.getElementById('layer-finder-input');
|
||||
input.value = text;
|
||||
input.dispatchEvent(new Event('input', { bubbles: true }));
|
||||
await flush();
|
||||
};
|
||||
const openFilter = async () => {
|
||||
document.querySelector('[aria-controls="layer-finder-menu"]').click();
|
||||
await flush();
|
||||
return document.getElementById('layer-finder-menu');
|
||||
};
|
||||
return { list, panel, shown, search, openFilter };
|
||||
}
|
||||
|
||||
test('search finds a layer by the name on screen or its English name', async (t) => {
|
||||
const { shown, search, list } = fixture(t);
|
||||
await search('météo');
|
||||
assert.deepEqual(shown(), ['radar']);
|
||||
await search('weather radar');
|
||||
assert.deepEqual(shown(), ['radar']);
|
||||
// The Movement heading has no rows left, so it is hidden too.
|
||||
assert.equal(
|
||||
list
|
||||
.querySelector('[data-group="movement"]')
|
||||
.classList.contains('is-filtered'),
|
||||
true,
|
||||
);
|
||||
await search('nothing like it');
|
||||
assert.deepEqual(shown(), []);
|
||||
assert.match(
|
||||
document.querySelector('.layer-finder__empty')?.textContent || '',
|
||||
/No layers match/,
|
||||
);
|
||||
});
|
||||
|
||||
test('On and Off follow whether the layer is enabled', async (t) => {
|
||||
const { shown, openFilter } = fixture(t);
|
||||
const menu = await openFilter();
|
||||
const on = [...menu.querySelectorAll('button')].find((b) =>
|
||||
b.textContent.trim().endsWith('On'),
|
||||
);
|
||||
on.click();
|
||||
await flush();
|
||||
assert.deepEqual(shown(), ['flights']);
|
||||
assert.equal(on.getAttribute('aria-pressed'), 'true');
|
||||
});
|
||||
|
||||
test('a chosen category survives its heading being translated', async (t) => {
|
||||
const { shown, openFilter, list } = fixture(t);
|
||||
const menu = await openFilter();
|
||||
[...menu.querySelectorAll('button')]
|
||||
.find((b) => b.textContent.trim().endsWith('Weather'))
|
||||
.click();
|
||||
await flush();
|
||||
assert.deepEqual(shown(), ['radar']);
|
||||
list.querySelector('[data-group="weather"]').textContent = 'Météo';
|
||||
await flush();
|
||||
assert.deepEqual(shown(), ['radar']);
|
||||
assert.match(
|
||||
document.querySelector('.layer-finder__chip').textContent,
|
||||
/Météo/,
|
||||
);
|
||||
});
|
||||
|
||||
test('Escape in the search field closes it without reaching the panel', async (t) => {
|
||||
const { search, panel } = fixture(t);
|
||||
let reached = false;
|
||||
panel.addEventListener('keydown', () => (reached = true));
|
||||
await search('ships');
|
||||
document
|
||||
.getElementById('layer-finder-input')
|
||||
.dispatchEvent(
|
||||
new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }),
|
||||
);
|
||||
await flush();
|
||||
assert.equal(reached, false);
|
||||
assert.equal(document.getElementById('layer-finder-input') === null, true);
|
||||
assert.equal(document.activeElement?.id, 'layer-finder-search-btn');
|
||||
});
|
||||
|
||||
test('the filter menu takes focus, moves with the arrows and closes on Escape', async (t) => {
|
||||
const { openFilter } = fixture(t);
|
||||
const menu = await openFilter();
|
||||
const buttons = [...menu.querySelectorAll('button')];
|
||||
assert.equal(document.activeElement, buttons[0]);
|
||||
menu.dispatchEvent(
|
||||
new KeyboardEvent('keydown', { key: 'ArrowDown', bubbles: true }),
|
||||
);
|
||||
assert.equal(document.activeElement, buttons[1]);
|
||||
menu.dispatchEvent(
|
||||
new KeyboardEvent('keydown', { key: 'End', bubbles: true }),
|
||||
);
|
||||
assert.equal(document.activeElement, buttons.at(-1));
|
||||
menu.dispatchEvent(
|
||||
new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }),
|
||||
);
|
||||
await flush();
|
||||
assert.equal(document.getElementById('layer-finder-menu') === null, true);
|
||||
assert.equal(
|
||||
document.activeElement,
|
||||
document.querySelector('[aria-controls="layer-finder-menu"]'),
|
||||
);
|
||||
});
|
||||
|
||||
test('a clear request shows every row again', async (t) => {
|
||||
const { shown, search } = fixture(t);
|
||||
await search('ships');
|
||||
assert.deepEqual(shown(), ['ships']);
|
||||
document.dispatchEvent(new CustomEvent(LAYER_FINDER_CLEAR_EVENT));
|
||||
await flush();
|
||||
assert.deepEqual(shown(), ['flights', 'ships', 'radar']);
|
||||
});
|
||||
|
||||
test('the section index has a tick per group and drops filtered groups', async (t) => {
|
||||
const { search } = fixture(t);
|
||||
await flush();
|
||||
assert.equal(
|
||||
document.querySelectorAll('.layer-section-index__tick').length,
|
||||
2,
|
||||
);
|
||||
await search('ships');
|
||||
await flush();
|
||||
// One group left: no index.
|
||||
assert.equal(
|
||||
document.querySelectorAll('.layer-section-index__tick').length,
|
||||
0,
|
||||
);
|
||||
});
|
||||
@@ -22,9 +22,11 @@ defineProps({
|
||||
|
||||
<template>
|
||||
<template v-for="item in items" :key="item.key"
|
||||
><h3 v-if="item.heading" class="data-layer-group-heading">{{
|
||||
item.heading
|
||||
}}</h3
|
||||
><h3
|
||||
v-if="item.heading"
|
||||
class="data-layer-group-heading"
|
||||
:data-group="item.key"
|
||||
>{{ item.heading }}</h3
|
||||
><div
|
||||
v-else
|
||||
class="data-toggle-row"
|
||||
|
||||
@@ -340,12 +340,12 @@ test('the provider settings corner shows the picker only while the shell publish
|
||||
app.mount(host);
|
||||
t.after(() => app.unmount());
|
||||
const store = useLocaleStore(pinia);
|
||||
assert.equal(document.getElementById('locale-picker'), null);
|
||||
assert.equal(document.getElementById('locale-picker') === null, true);
|
||||
store.publishPicker({ current: 'de', onSelect() {} });
|
||||
await nextTick();
|
||||
const code = document.querySelector('#corner-actions .locale-picker-code');
|
||||
assert.equal(code?.textContent, 'DE');
|
||||
store.publishPicker(null);
|
||||
await nextTick();
|
||||
assert.equal(document.getElementById('locale-picker'), null);
|
||||
assert.equal(document.getElementById('locale-picker') === null, true);
|
||||
});
|
||||
+11
-11
@@ -156,7 +156,7 @@ test('the panel shows the last 24 h as event cards and opens once', () => {
|
||||
assert.equal(img.getAttribute('referrerpolicy'), 'no-referrer');
|
||||
assert.equal(first.querySelector('.news-card__credit').textContent, 'A');
|
||||
// A lone report has no picture.
|
||||
assert.equal(second.querySelector('.news-card__thumb'), null);
|
||||
assert.equal(second.querySelector('.news-card__thumb') === null, true);
|
||||
// A later update does not reopen a panel the reader collapsed.
|
||||
panel.classList.add('collapsed');
|
||||
news.update(view());
|
||||
@@ -192,8 +192,8 @@ test('a card click flies there; open, it links the source and closes', () => {
|
||||
test('filters, the Local section and empty or failed reads', () => {
|
||||
const { news, panel, calls } = fixture();
|
||||
news.update(view());
|
||||
assert.equal(panel.querySelector('[aria-label="Local"]'), null);
|
||||
assert.equal(panel.querySelector('.news-toggle'), null);
|
||||
assert.equal(panel.querySelector('[aria-label="Local"]') === null, true);
|
||||
assert.equal(panel.querySelector('.news-toggle') === null, true);
|
||||
const severity = panel.querySelector('select[aria-label="Severity"]');
|
||||
assert.equal(severity.value, '2');
|
||||
severity.value = '3';
|
||||
@@ -214,7 +214,7 @@ test('filters, the Local section and empty or failed reads', () => {
|
||||
panel.textContent,
|
||||
/No news matches these filters in the last 24 h/,
|
||||
);
|
||||
assert.equal(panel.querySelector('.news-readout__footer button'), null);
|
||||
assert.equal(panel.querySelector('.news-readout__footer button') === null, true);
|
||||
|
||||
// Local: no hotspot chips or severity floor, and its own empty states.
|
||||
const localView = (inView) =>
|
||||
@@ -225,9 +225,9 @@ test('filters, the Local section and empty or failed reads', () => {
|
||||
news.update(localView({ active: false }));
|
||||
const section = panel.querySelector('[aria-label="Local"]');
|
||||
assert.match(section.textContent, /Zoom in to see local news/);
|
||||
assert.equal(panel.querySelector('[data-chip-id="ua-ru-war"]'), null);
|
||||
assert.equal(panel.querySelector('select[aria-label="Severity"]'), null);
|
||||
assert.equal(panel.querySelector('[aria-label="Latest news"]'), null);
|
||||
assert.equal(panel.querySelector('[data-chip-id="ua-ru-war"]') === null, true);
|
||||
assert.equal(panel.querySelector('select[aria-label="Severity"]') === null, true);
|
||||
assert.equal(panel.querySelector('[aria-label="Latest news"]') === null, true);
|
||||
assert.equal(document.getElementById('news-panel-count').textContent, '0');
|
||||
news.update(
|
||||
localView({ active: true, items: [feedCardView(report('near'), NOW)] }),
|
||||
@@ -320,7 +320,7 @@ test('a card credits the service its report came through', () => {
|
||||
credited.querySelector('.news-card__via').textContent,
|
||||
'via GDELT Project',
|
||||
);
|
||||
assert.equal(own.querySelector('.news-card__via'), null);
|
||||
assert.equal(own.querySelector('.news-card__via') === null, true);
|
||||
news.destroy();
|
||||
});
|
||||
|
||||
@@ -370,7 +370,7 @@ test('scrolling to the end asks once per page, again after a filter change or a
|
||||
test('the window choice offers shorter windows; the longest is the server window', () => {
|
||||
const { news, panel, calls } = fixture();
|
||||
news.update(view({ windowHours: 12, windowChoices: [12, 6, 3, 1] }));
|
||||
assert.equal(panel.querySelector('.news-readout__window'), null);
|
||||
assert.equal(panel.querySelector('.news-readout__window') === null, true);
|
||||
const choice = panel.querySelector('select[aria-label="Time window"]');
|
||||
assert.deepEqual(
|
||||
[...choice.options].map((option) => option.textContent),
|
||||
@@ -410,7 +410,7 @@ test('a clip waits behind its picture and plays, on request, in the open card',
|
||||
news.update(view({ items: [feedCardView(clipped, NOW)] }));
|
||||
const card = panel.querySelector('.news-card');
|
||||
assert.equal(card.querySelector('.news-card__play').textContent, '▶');
|
||||
assert.equal(card.querySelector('video'), null);
|
||||
assert.equal(card.querySelector('video') === null, true);
|
||||
news.update(
|
||||
view({
|
||||
items: [feedCardView(clipped, NOW)],
|
||||
@@ -436,6 +436,6 @@ test('a clip waits behind its picture and plays, on request, in the open card',
|
||||
selected: feedCardView(clipped, NOW),
|
||||
}),
|
||||
);
|
||||
assert.equal(panel.querySelector('.news-card.is-open video'), null);
|
||||
assert.equal(panel.querySelector('.news-card.is-open video') === null, true);
|
||||
news.destroy();
|
||||
});
|
||||
@@ -166,8 +166,8 @@ test('UiPanel without collapsible has no button, and glow is optional', (t) => {
|
||||
});
|
||||
const panel = document.getElementById('plain-panel');
|
||||
assert.equal(panel.tagName, 'SECTION');
|
||||
assert.equal(panel.querySelector('.panel-glow'), null);
|
||||
assert.equal(panel.querySelector('.panel-collapse-btn'), null);
|
||||
assert.equal(panel.querySelector('.panel-glow') === null, true);
|
||||
assert.equal(panel.querySelector('.panel-collapse-btn') === null, true);
|
||||
});
|
||||
|
||||
test('RailPanel follows the store, forwards clicks, and never restores a class its owner removed', async (t) => {
|
||||
|
||||
@@ -9,7 +9,7 @@ export const PANEL_RAIL_FALLBACK_ICON = 'more_horiz';
|
||||
/**
|
||||
* How each side panel appears on its rail. Labels are the panels' own titles.
|
||||
* `shownBy` names a class the panel needs to be shown at all (`f` toggles
|
||||
* Data Layers' `active`).
|
||||
* Data Layers' `active`). `context` is the label's translation context.
|
||||
*/
|
||||
export const PANEL_RAIL_ITEMS = Object.freeze({
|
||||
'data-panel': {
|
||||
@@ -19,7 +19,9 @@ export const PANEL_RAIL_ITEMS = Object.freeze({
|
||||
},
|
||||
'utilities-panel': { icon: 'handyman', label: msg('UTILITIES') },
|
||||
'scene-panel': { icon: 'movie', label: msg('AUTHORING') },
|
||||
'pp-toggles': { icon: 'palette', label: msg('VISUAL') },
|
||||
// `context` keeps the panel's name apart from the satellite class of the
|
||||
// same English word.
|
||||
'pp-toggles': { icon: 'palette', label: msg('VISUAL'), context: 'panel' },
|
||||
'cctv-panel': { icon: 'videocam', label: msg('CCTV') },
|
||||
'weather-panel': { icon: 'partly_cloudy_day', label: msg('WEATHER') },
|
||||
'news-panel': { icon: 'public', label: msg('NEWS') },
|
||||
|
||||
@@ -135,8 +135,8 @@ test('the chip counts what is missing and the rows render from the status', asyn
|
||||
);
|
||||
assert.equal(field.type, 'password');
|
||||
assert.equal(field.placeholder, 'paste GOOGLE_MAPS_API_KEY');
|
||||
assert.equal(google.querySelector('.key-setup-remove'), null);
|
||||
assert.equal(google.querySelector('.key-setup-cloud-auth'), null);
|
||||
assert.equal(google.querySelector('.key-setup-remove') === null, true);
|
||||
assert.equal(google.querySelector('.key-setup-cloud-auth') === null, true);
|
||||
|
||||
const openai = $('[data-key-id="openai"]');
|
||||
assert.equal(openai.dataset.managed, 'file');
|
||||
@@ -159,7 +159,7 @@ test('the chip counts what is missing and the rows render from the status', asyn
|
||||
firms.querySelector('.key-setup-external').textContent,
|
||||
'configured externally',
|
||||
);
|
||||
assert.equal(firms.querySelector('.key-setup-fields'), null);
|
||||
assert.equal(firms.querySelector('.key-setup-fields') === null, true);
|
||||
});
|
||||
|
||||
test('the chip opens the dialog onto its first field; closing fades it and restores the status line', async (t) => {
|
||||
@@ -337,12 +337,12 @@ test('Cyber moves the chip into the top toolbar and other themes return it to th
|
||||
await wait();
|
||||
await nextTick();
|
||||
assert.equal(toolbar.lastElementChild?.id, 'key-setup-chip');
|
||||
assert.equal(corner.querySelector('#key-setup-chip'), null);
|
||||
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);
|
||||
assert.equal(toolbar.querySelector('#key-setup-chip') === null, true);
|
||||
delete document.documentElement.dataset.uiTheme;
|
||||
});
|
||||
|
||||
|
||||
@@ -201,5 +201,5 @@ test('the refresh timer reloads with a cache-buster, skips hidden tabs, and stop
|
||||
ui.overlay.dispose();
|
||||
assert.equal(ui.intervals.size, 0);
|
||||
assert.equal(ui.renderListeners.size, 0);
|
||||
assert.equal(ui.window.document.querySelector('.qci-panel'), null);
|
||||
assert.equal(ui.window.document.querySelector('.qci-panel') === null, true);
|
||||
});
|
||||
+22
-4
@@ -27,10 +27,18 @@ export function bindRadioControls() {
|
||||
this.store?.publishUtility({ ...this._cockpitDisclosure });
|
||||
if (displayOpen) this.actions.revealStyleParameters();
|
||||
if (!expanded && returnFocus) {
|
||||
(kind === 'display'
|
||||
? this._cockpitDisplayToggleBtn
|
||||
: this._cockpitRadioToggleBtn
|
||||
)?.focus({ preventScroll: true });
|
||||
// The desktop cockpit hides the launchers' toggles behind its rail, so
|
||||
// focus goes to whichever of the two is shown.
|
||||
const toggle =
|
||||
kind === 'display'
|
||||
? this._cockpitDisplayToggleBtn
|
||||
: this._cockpitRadioToggleBtn;
|
||||
const railItem = toggle?.ownerDocument?.querySelector?.(
|
||||
`[data-cockpit-rail-item="${kind}"]`,
|
||||
);
|
||||
(toggle?.getClientRects?.().length ? toggle : railItem || toggle)?.focus({
|
||||
preventScroll: true,
|
||||
});
|
||||
}
|
||||
if (
|
||||
!displayOpen &&
|
||||
@@ -444,6 +452,16 @@ export function bindRadioControls() {
|
||||
),
|
||||
toggleCockpitRadio: () =>
|
||||
setCockpitDisclosure('radio', !this._cockpitDisclosureOpen('radio')),
|
||||
/**
|
||||
* Open or close the cockpit's Display or Radio panel; opening one closes
|
||||
* the other.
|
||||
* @param {'display'|'radio'} kind
|
||||
* @param {{ returnFocus?: boolean }} [options]
|
||||
*/
|
||||
toggleCockpitUtility: (kind, { returnFocus = false } = {}) => {
|
||||
const open = !this._cockpitDisclosureOpen(kind);
|
||||
setCockpitDisclosure(kind, open, { returnFocus: !open && returnFocus });
|
||||
},
|
||||
/**
|
||||
* @param {string} filter
|
||||
* @returns {string} The station tag the filter shows afterwards.
|
||||
|
||||
@@ -1,178 +0,0 @@
|
||||
<script setup>
|
||||
import { computed, onBeforeUnmount, shallowRef, watch } from 'vue';
|
||||
import { formatUtcDayMonth, t } from '../../i18n/index.js';
|
||||
import { utcClock } from './utcClock.js';
|
||||
import UiSlider from '../kit/UiSlider.js';
|
||||
|
||||
// Stable native transport with local preview and a coalesced 150 ms drag
|
||||
// commit. While the handle is dragged the slider keeps the ticks it was
|
||||
// dragged over; the owner's updates apply once the drag ends.
|
||||
const props = defineProps({
|
||||
state: { type: Object, required: true },
|
||||
sliderClassName: { type: String, default: '' },
|
||||
heading: { type: Boolean, default: true },
|
||||
onCommit: { type: Function, default: () => {} },
|
||||
onPreview: { type: Function, default: () => {} },
|
||||
onStep: { type: Function, default: () => {} },
|
||||
onLatest: { type: Function, default: () => {} },
|
||||
onPlay: { type: Function, default: () => {} },
|
||||
});
|
||||
|
||||
const utc = (tick) =>
|
||||
Number.isFinite(Date.parse(tick))
|
||||
? `${formatUtcDayMonth(tick)} ${utcClock(tick)}`
|
||||
: '';
|
||||
|
||||
// What the slider shows: the owner's ticks, index and readout, frozen while
|
||||
// dragging.
|
||||
const shown = shallowRef({ ticks: [], index: 0, readout: '' });
|
||||
let dragging = false;
|
||||
let timer = null;
|
||||
let pending = null;
|
||||
let live = true;
|
||||
|
||||
const cancel = () => {
|
||||
if (timer !== null) clearTimeout(timer);
|
||||
timer = null;
|
||||
};
|
||||
const sync = () => {
|
||||
if (dragging) return;
|
||||
const ticks = [...props.state.ticks];
|
||||
shown.value = {
|
||||
ticks,
|
||||
index: Math.max(0, Math.min(props.state.index, ticks.length - 1)),
|
||||
readout: props.state.readout || '',
|
||||
};
|
||||
};
|
||||
watch(
|
||||
() => props.state,
|
||||
(state) => {
|
||||
if (state.disabled) {
|
||||
cancel();
|
||||
pending = null;
|
||||
dragging = false;
|
||||
}
|
||||
sync();
|
||||
},
|
||||
{ immediate: true, flush: 'sync' },
|
||||
);
|
||||
onBeforeUnmount(() => {
|
||||
live = false;
|
||||
cancel();
|
||||
});
|
||||
|
||||
const disabled = computed(() => Boolean(props.state.disabled));
|
||||
const latestActive = computed(() => props.state.mode === 'latest');
|
||||
const playing = computed(() => Boolean(props.state.playing));
|
||||
|
||||
function commit() {
|
||||
cancel();
|
||||
const value = pending;
|
||||
pending = null;
|
||||
if (live && value && !props.state.disabled)
|
||||
props.onCommit(value.tick, value.index);
|
||||
}
|
||||
function preview(event) {
|
||||
if (props.state.disabled) return;
|
||||
dragging = true;
|
||||
const index = Number(event.target.value);
|
||||
const tick = shown.value.ticks[index];
|
||||
if (!tick) return;
|
||||
pending = { tick, index };
|
||||
// Shown before the owner hears of it: an update from inside onPreview
|
||||
// must not move the handle back.
|
||||
shown.value = { ...shown.value, index };
|
||||
const readout = props.onPreview(tick, index);
|
||||
// The owner may have ended the drag (disabled) from inside onPreview.
|
||||
if (!dragging) return;
|
||||
if (typeof readout === 'string') shown.value = { ...shown.value, readout };
|
||||
if (timer === null) timer = setTimeout(commit, 150);
|
||||
}
|
||||
// The handle shows the shown index again. A drag that ends where it began
|
||||
// (an input and a cancel, or a refused commit, before the next render)
|
||||
// leaves the slider's model unchanged, so it would not render.
|
||||
const place = (input) => {
|
||||
const index = String(shown.value.index);
|
||||
if (input && input.value !== index) input.value = index;
|
||||
};
|
||||
function change(event) {
|
||||
if (props.state.disabled) return;
|
||||
const index = Number(event.target.value);
|
||||
pending = { tick: shown.value.ticks[index], index };
|
||||
dragging = false;
|
||||
commit();
|
||||
sync();
|
||||
place(event.target);
|
||||
}
|
||||
function reset(event) {
|
||||
cancel();
|
||||
pending = null;
|
||||
dragging = false;
|
||||
sync();
|
||||
place(event?.target);
|
||||
}
|
||||
function blur(event) {
|
||||
if (dragging) change(event);
|
||||
}
|
||||
const act = (fn) => {
|
||||
reset();
|
||||
if (live && !props.state.disabled) fn();
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="rail-timeline"
|
||||
><div v-if="heading" class="panel-title">{{ t('Observed history') }}</div
|
||||
><div class="rail-timeline-track"
|
||||
><button
|
||||
type="button"
|
||||
class="data-toggle-chip"
|
||||
:title="t('Earlier observation')"
|
||||
:disabled="disabled || state.index <= 0"
|
||||
@click="act(() => onStep(-1))"
|
||||
>‹</button
|
||||
><UiSlider
|
||||
:class="sliderClassName || undefined"
|
||||
min="0"
|
||||
:max="String(Math.max(0, shown.ticks.length - 1))"
|
||||
step="1"
|
||||
:model-value="String(shown.index)"
|
||||
:disabled="disabled"
|
||||
:aria-label="t('Observed history')"
|
||||
:aria-valuetext="utc(shown.ticks[shown.index])"
|
||||
@input="preview"
|
||||
@change="change"
|
||||
@pointercancel="reset"
|
||||
@blur="blur"
|
||||
/><button
|
||||
type="button"
|
||||
class="data-toggle-chip"
|
||||
:title="t('Later observation')"
|
||||
:disabled="disabled || state.index >= state.ticks.length - 1"
|
||||
@click="act(() => onStep(1))"
|
||||
>›</button
|
||||
><div class="rail-timeline-endpoints"
|
||||
><span>{{ utcClock(shown.ticks[0]) }}</span
|
||||
><span>{{ utcClock(shown.ticks.at(-1)) }}</span></div
|
||||
></div
|
||||
><div class="rail-timeline-controls"
|
||||
><button
|
||||
type="button"
|
||||
:class="`data-toggle-chip${latestActive ? ' active' : ''}`"
|
||||
:title="t('Newest frame per product')"
|
||||
:disabled="disabled"
|
||||
:aria-pressed="String(latestActive)"
|
||||
@click="act(onLatest)"
|
||||
>{{ t('Latest') }}</button
|
||||
><button
|
||||
type="button"
|
||||
:class="`data-toggle-chip${playing ? ' active' : ''}`"
|
||||
:title="t('Replay observed history')"
|
||||
:disabled="disabled"
|
||||
:aria-pressed="String(playing)"
|
||||
@click="act(onPlay)"
|
||||
>{{ playing ? t('Pause') : t('Play') }}</button
|
||||
><span class="rail-timeline-readout">{{ shown.readout }}</span></div
|
||||
></section
|
||||
>
|
||||
</template>
|
||||
@@ -1,56 +0,0 @@
|
||||
import { h, render } from 'vue';
|
||||
import RailTimeline from './rail/RailTimeline.vue';
|
||||
|
||||
export { utcClock } from './rail/utcClock.js';
|
||||
|
||||
/**
|
||||
* Stable native transport with local preview and a coalesced 150 ms drag
|
||||
* commit. Renders the RailTimeline component into `container` and patches it
|
||||
* synchronously on every update.
|
||||
*/
|
||||
export function createRailTimeline({
|
||||
container,
|
||||
document = container?.ownerDocument,
|
||||
sliderClassName = '',
|
||||
heading = true,
|
||||
onCommit = () => {},
|
||||
onPreview = () => {},
|
||||
onStep = () => {},
|
||||
onLatest = () => {},
|
||||
onPlay = () => {},
|
||||
} = {}) {
|
||||
if (!document?.createElement || !container) return null;
|
||||
let destroyed = false;
|
||||
const paint = (state) =>
|
||||
render(
|
||||
h(RailTimeline, {
|
||||
state,
|
||||
sliderClassName,
|
||||
heading,
|
||||
onCommit,
|
||||
onPreview,
|
||||
onStep,
|
||||
onLatest,
|
||||
onPlay,
|
||||
}),
|
||||
container,
|
||||
);
|
||||
paint({
|
||||
ticks: [],
|
||||
index: 0,
|
||||
mode: 'latest',
|
||||
playing: false,
|
||||
readout: '',
|
||||
disabled: true,
|
||||
});
|
||||
return {
|
||||
update(state) {
|
||||
if (!destroyed) paint(state);
|
||||
},
|
||||
destroy() {
|
||||
if (destroyed) return;
|
||||
destroyed = true;
|
||||
render(null, container);
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -1,178 +0,0 @@
|
||||
import '../testSupport/registerDom.mjs';
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { assertSameNode } from '../testSupport/domAssert.mjs';
|
||||
import { nextTick } from 'vue';
|
||||
import { createRailTimeline } from './railTimeline.js';
|
||||
import { railDocumentFixture as railFixture } from './railTestFixture.mjs';
|
||||
const ticks = [
|
||||
'2026-09-22T01:00:00Z',
|
||||
'2026-09-22T01:05:00Z',
|
||||
'2026-09-22T01:10:00Z',
|
||||
];
|
||||
const props = {
|
||||
ticks,
|
||||
index: 2,
|
||||
mode: 'latest',
|
||||
playing: false,
|
||||
readout: 'Latest',
|
||||
disabled: false,
|
||||
};
|
||||
test('preview is immediate, commits are coalesced and the drag DOM and tick mapping stay stable', async (t) => {
|
||||
t.mock.timers.enable({ apis: ['setTimeout'] });
|
||||
const f = railFixture();
|
||||
const previews = [];
|
||||
const commits = [];
|
||||
const view = createRailTimeline({
|
||||
...f,
|
||||
onPreview: (tick) => {
|
||||
previews.push(tick);
|
||||
return tick;
|
||||
},
|
||||
onCommit: (tick) => commits.push(tick),
|
||||
});
|
||||
view.update(props);
|
||||
const slider = f.find((n) => n.tagName === 'INPUT');
|
||||
const row = slider.parentElement;
|
||||
assert.equal(slider.getAttribute('aria-label'), 'Observed history');
|
||||
slider.value = '0';
|
||||
slider.dispatchEvent(new Event('input'));
|
||||
assert.deepEqual(commits, []);
|
||||
assert.deepEqual(previews, [ticks[0]]);
|
||||
await nextTick();
|
||||
assert.equal(slider.getAttribute('aria-valuetext'), '09-22 01:00 UTC');
|
||||
view.update({
|
||||
...props,
|
||||
ticks: ticks.slice(1),
|
||||
index: 1,
|
||||
readout: 'Refresh',
|
||||
});
|
||||
assertSameNode(slider.parentElement, row);
|
||||
assertSameNode(row.children[1], slider);
|
||||
assert.equal(slider.value, '0');
|
||||
assert.equal(slider.max, '2');
|
||||
assert.equal(
|
||||
f.find((n) => n.className === 'rail-timeline-readout').textContent,
|
||||
ticks[0],
|
||||
);
|
||||
t.mock.timers.tick(149);
|
||||
assert.equal(commits.length, 0);
|
||||
slider.value = '1';
|
||||
slider.dispatchEvent(new Event('input'));
|
||||
t.mock.timers.tick(1);
|
||||
assert.deepEqual(commits, [ticks[1]]);
|
||||
slider.value = '2';
|
||||
slider.dispatchEvent(new Event('input'));
|
||||
slider.dispatchEvent(new Event('change'));
|
||||
assert.deepEqual(commits, [ticks[1], ticks[2]]);
|
||||
t.mock.timers.tick(150);
|
||||
assert.equal(commits.length, 2);
|
||||
await nextTick();
|
||||
assert.equal(slider.max, '1', 'release applies the latest update');
|
||||
view.destroy();
|
||||
});
|
||||
test('identical updates write nothing; controls call actions and destruction cancels commits', (t) => {
|
||||
t.mock.timers.enable({ apis: ['setTimeout'] });
|
||||
const f = railFixture();
|
||||
const calls = [];
|
||||
const view = createRailTimeline({
|
||||
...f,
|
||||
onCommit: () => calls.push('commit'),
|
||||
onStep: (n) => calls.push(n),
|
||||
onLatest: () => calls.push('latest'),
|
||||
onPlay: () => calls.push('play'),
|
||||
});
|
||||
view.update({ ...props, index: 1 });
|
||||
f.writes();
|
||||
view.update({ ...props, index: 1 });
|
||||
assert.equal(f.writes(), 0);
|
||||
for (const label of ['‹', '›', 'Latest', 'Play'])
|
||||
f.find((n) => n.textContent === label).click();
|
||||
assert.deepEqual(calls, [-1, 1, 'latest', 'play']);
|
||||
view.update({ ...props, playing: true });
|
||||
assert.ok(f.find((n) => n.textContent === 'Pause'));
|
||||
const slider = f.find((n) => n.tagName === 'INPUT');
|
||||
slider.value = '0';
|
||||
slider.dispatchEvent(new Event('change'));
|
||||
assert.equal(calls.at(-1), 'commit');
|
||||
slider.dispatchEvent(new Event('input'));
|
||||
view.destroy();
|
||||
t.mock.timers.tick(150);
|
||||
assert.equal(calls.length, 5);
|
||||
assert.equal(f.container.children.length, 0);
|
||||
});
|
||||
|
||||
test('observed history label and endpoint times track the advertised tick range', () => {
|
||||
const f = railFixture();
|
||||
const view = createRailTimeline(f);
|
||||
view.update(props);
|
||||
assert.equal(
|
||||
f.find((n) => n.className === 'panel-title').textContent,
|
||||
'Observed history',
|
||||
);
|
||||
const endpoints = f.find((n) => n.className === 'rail-timeline-endpoints');
|
||||
assert.equal(endpoints.parentElement.className, 'rail-timeline-track');
|
||||
assert.deepEqual(
|
||||
[...endpoints.children].map((n) => n.textContent),
|
||||
['01:00 UTC', '01:10 UTC'],
|
||||
);
|
||||
view.update({ ...props, ticks: ticks.slice(1) });
|
||||
assert.equal(endpoints.children[0].textContent, '01:05 UTC');
|
||||
view.destroy();
|
||||
});
|
||||
|
||||
test('an update from inside the preview neither moves the handle back nor survives a disable', async () => {
|
||||
const f = railFixture();
|
||||
let view;
|
||||
let next = null;
|
||||
const commits = [];
|
||||
view = createRailTimeline({
|
||||
...f,
|
||||
onPreview: () => {
|
||||
if (next) view.update(next);
|
||||
return 'preview';
|
||||
},
|
||||
onCommit: (tick, index) => commits.push(index),
|
||||
});
|
||||
view.update(props);
|
||||
const slider = f.find((n) => n.tagName === 'INPUT');
|
||||
next = { ...props, readout: 'Refresh' };
|
||||
slider.value = '0';
|
||||
slider.dispatchEvent(new Event('input'));
|
||||
assert.equal(slider.value, '0');
|
||||
slider.dispatchEvent(new Event('change'));
|
||||
assert.deepEqual(commits, [0]);
|
||||
next = { ...props, disabled: true };
|
||||
slider.value = '1';
|
||||
slider.dispatchEvent(new Event('input'));
|
||||
await nextTick();
|
||||
assert.equal(slider.value, '2', 'the disabled owner keeps its position');
|
||||
assert.equal(slider.getAttribute('aria-valuetext'), '09-22 01:10 UTC');
|
||||
view.destroy();
|
||||
});
|
||||
test('a drag that ends where it began puts the handle back on the shown index', async (t) => {
|
||||
t.mock.timers.enable({ apis: ['setTimeout'] });
|
||||
const f = railFixture();
|
||||
const commits = [];
|
||||
const view = createRailTimeline({
|
||||
...f,
|
||||
onCommit: (tick) => commits.push(tick),
|
||||
});
|
||||
view.update(props);
|
||||
await nextTick();
|
||||
const slider = f.find((n) => n.tagName === 'INPUT');
|
||||
slider.value = '0';
|
||||
slider.dispatchEvent(new Event('input'));
|
||||
slider.dispatchEvent(new Event('pointercancel'));
|
||||
await nextTick();
|
||||
assert.equal(slider.value, '2', 'a cancelled drag');
|
||||
assert.deepEqual(commits, []);
|
||||
// A refused commit: the owner keeps its index.
|
||||
slider.value = '1';
|
||||
slider.dispatchEvent(new Event('input'));
|
||||
slider.dispatchEvent(new Event('change'));
|
||||
await nextTick();
|
||||
assert.deepEqual(commits, [ticks[1]]);
|
||||
assert.equal(slider.value, '2', 'a refused commit');
|
||||
view.destroy();
|
||||
});
|
||||
@@ -72,7 +72,7 @@ test('a lost context offers Reload, and a panel that cannot reload offers nothin
|
||||
document.getElementById('render-failure-message').textContent,
|
||||
/3D graphics/,
|
||||
);
|
||||
assert.equal(notice().querySelector('.render-failure-detail'), null);
|
||||
assert.equal(notice().querySelector('.render-failure-detail') === null, true);
|
||||
assert.deepEqual(buttons(), ['Reload', 'Reset view']);
|
||||
store.publishRenderFailure({
|
||||
reason: 'context-lost',
|
||||
@@ -82,7 +82,7 @@ test('a lost context offers Reload, and a panel that cannot reload offers nothin
|
||||
});
|
||||
await nextTick();
|
||||
assert.deepEqual(buttons(), []);
|
||||
assert.equal(notice().querySelector('.render-failure-hint'), null);
|
||||
assert.equal(notice().querySelector('.render-failure-hint') === null, true);
|
||||
});
|
||||
|
||||
const failure = () => ({
|
||||
|
||||
+33
-12
@@ -27,7 +27,8 @@ export const WORLD_TIME_SPEEDS = Object.freeze({
|
||||
* buffering, timeMs, supported, span}`, where `supported` says a layer that moves with the clock
|
||||
* has time to show and `span` is the stretch the timeline runs over: the
|
||||
* time those layers cover, reaching to now and to the world time, with their
|
||||
* marks. It follows the page's world clock, which tells it of every move, and
|
||||
* marks (`marks`, their times; `markDetails`, each `{time, label?, id?,
|
||||
* kind?}`, as the world clock's coverage gives them). It follows the page's world clock, which tells it of every move, and
|
||||
* of the time a few times a second while it plays on its own. While a
|
||||
* timeline shows, it reads the clock each second itself, so live and the
|
||||
* track's end keep up with now.
|
||||
@@ -42,6 +43,7 @@ export const useWorldTimeStore = defineStore('gev-world-time', () => {
|
||||
start: Math.min(coverage.start, now),
|
||||
end: Math.max(coverage.end, now),
|
||||
marks: coverage.marks,
|
||||
markDetails: coverage.markDetails,
|
||||
};
|
||||
};
|
||||
const spanOf = (state) => {
|
||||
@@ -52,6 +54,7 @@ export const useWorldTimeStore = defineStore('gev-world-time', () => {
|
||||
start: Math.min(covered.start, state.timeMs),
|
||||
end: Math.max(covered.end, state.timeMs),
|
||||
marks: covered.marks,
|
||||
markDetails: covered.markDetails,
|
||||
});
|
||||
};
|
||||
const nearNow = (ms, length) =>
|
||||
@@ -93,8 +96,20 @@ export const useWorldTimeStore = defineStore('gev-world-time', () => {
|
||||
span: spanOf(state),
|
||||
});
|
||||
const time = shallowRef(read());
|
||||
const speed = shallowRef('real');
|
||||
const rate = () => WORLD_TIME_SPEEDS[speed.value];
|
||||
// The speed shown follows the world clock's rate, whoever set it: a rate
|
||||
// not among those offered shows as the nearest that is (by ratio), while
|
||||
// play still runs at the clock's own rate.
|
||||
const speedFor = (clockRate) => {
|
||||
let best = 'real';
|
||||
for (const key of Object.keys(WORLD_TIME_SPEEDS))
|
||||
if (
|
||||
Math.abs(Math.log(WORLD_TIME_SPEEDS[key] / clockRate)) <
|
||||
Math.abs(Math.log(WORLD_TIME_SPEEDS[best] / clockRate))
|
||||
)
|
||||
best = key;
|
||||
return best;
|
||||
};
|
||||
const speed = shallowRef(speedFor(worldClock.getRate()));
|
||||
let ticker = null;
|
||||
const syncTicker = () => {
|
||||
// Playing, the clock tells of the time itself.
|
||||
@@ -109,6 +124,8 @@ export const useWorldTimeStore = defineStore('gev-world-time', () => {
|
||||
}
|
||||
};
|
||||
const unsubscribe = worldClock.subscribe((state) => {
|
||||
if (speed.value !== speedFor(state.rate))
|
||||
speed.value = speedFor(state.rate);
|
||||
if (stopAtEnd(state)) return;
|
||||
time.value = read(state);
|
||||
syncTicker();
|
||||
@@ -123,10 +140,11 @@ export const useWorldTimeStore = defineStore('gev-world-time', () => {
|
||||
return {
|
||||
time,
|
||||
/**
|
||||
* Play runs the track at the speed chosen, from the start when it is at
|
||||
* Play runs the track at the world clock's rate (the speed chosen, which
|
||||
* sets it), from the start when it is at
|
||||
* its end (at live, say), as a video plays again from the top. It runs
|
||||
* the clock itself, past weather's own replay: weather follows the time
|
||||
* frame by frame like every other layer the track covers.
|
||||
* the clock itself: weather follows the time frame by frame like every
|
||||
* other layer the track covers.
|
||||
*/
|
||||
togglePlay() {
|
||||
const { playing, live, timeMs, span } = time.value;
|
||||
@@ -134,22 +152,25 @@ export const useWorldTimeStore = defineStore('gev-world-time', () => {
|
||||
const covered = reach();
|
||||
if (span && covered && (live || timeMs >= covered.end))
|
||||
worldClock.seek(span.start);
|
||||
worldClock.play({ rate: rate(), continuous: true });
|
||||
// At the clock's rate: the speed chosen, or a host's own.
|
||||
worldClock.play({ continuous: true });
|
||||
},
|
||||
speed,
|
||||
/**
|
||||
* Choose how fast play runs; playing, it changes at once. Weather's own
|
||||
* replay steps at its own pace, so a speed chosen while it plays takes
|
||||
* Choose how fast play runs: the world clock keeps it, so any play runs
|
||||
* at it (a layer's own Play too), and playing, it changes at once. A
|
||||
* driver steps at its own pace, so a speed chosen while one plays takes
|
||||
* playback over from where it is.
|
||||
*/
|
||||
setSpeed(next) {
|
||||
if (!Object.hasOwn(WORLD_TIME_SPEEDS, next)) return;
|
||||
speed.value = next;
|
||||
// The clock's rate first: the speed shown follows it from here on.
|
||||
worldClock.setRate(WORLD_TIME_SPEEDS[next]);
|
||||
const { playing, stepping } = worldClock.getState();
|
||||
if (!playing) return;
|
||||
if (!stepping) return worldClock.setRate(rate());
|
||||
if (!playing || !stepping) return;
|
||||
worldClock.pause();
|
||||
worldClock.play({ rate: rate(), continuous: true });
|
||||
worldClock.play({ continuous: true });
|
||||
},
|
||||
goLive: () => worldClock.goLive(),
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,693 @@
|
||||
/* ── Cockpit side windows in the app's panel look ───────────────────────
|
||||
Contact (left), the briefing carousel (right) and the Display / Radio
|
||||
controls get the same smoked glass, 16px corners and card rows as the
|
||||
main panels. They keep cockpit.css's slight 3D slant toward the centre,
|
||||
and stand the same height. The text glow goes; the state colours on the
|
||||
top edge (uncertain, lost) stay. */
|
||||
|
||||
.cockpit-context-window,
|
||||
.cockpit-signal-window {
|
||||
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||
border-top-color: rgba(255, 255, 255, 0.14);
|
||||
border-radius: 16px;
|
||||
background: rgba(12, 12, 20, 0.72);
|
||||
box-shadow:
|
||||
0 8px 32px rgba(0, 0, 0, 0.42),
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.04);
|
||||
backdrop-filter: blur(24px) saturate(1.4);
|
||||
-webkit-backdrop-filter: blur(24px) saturate(1.4);
|
||||
text-shadow: none;
|
||||
scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
|
||||
}
|
||||
|
||||
/* Open, both windows share one compact size; their lists scroll. */
|
||||
.cockpit-context-window:not([data-collapsed='true']),
|
||||
.cockpit-signal-window:not([data-collapsed='true']) {
|
||||
width: min(280px, 23vw);
|
||||
height: min(27vh, 260px);
|
||||
}
|
||||
|
||||
/* Contact's header: the buttons share the kicker's row, so the subject runs
|
||||
the full width on at most two lines instead of wrapping beside them. */
|
||||
.cockpit-context-window:not([data-collapsed='true'])
|
||||
.cockpit-context-header
|
||||
> div {
|
||||
display: contents;
|
||||
}
|
||||
|
||||
.cockpit-context-window:not([data-collapsed='true']) .cockpit-context-kicker {
|
||||
grid-column: 1;
|
||||
grid-row: 1;
|
||||
}
|
||||
|
||||
.cockpit-context-window:not([data-collapsed='true']) .cockpit-context-actions {
|
||||
grid-column: 2;
|
||||
grid-row: 1;
|
||||
}
|
||||
|
||||
.cockpit-context-window:not([data-collapsed='true']) #cockpit-context-subject {
|
||||
display: -webkit-box;
|
||||
grid-column: 1 / -1;
|
||||
grid-row: 2;
|
||||
overflow: hidden;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
line-clamp: 2;
|
||||
}
|
||||
|
||||
/* Their foot sits just above the bottom HUD readouts (MGRS / GSD), which
|
||||
stand at clamp(84px, 11vh, 118px) and are about 38px tall. */
|
||||
.cockpit-context-window,
|
||||
.cockpit-signal-window {
|
||||
bottom: calc(clamp(84px, 11vh, 118px) + 54px);
|
||||
}
|
||||
|
||||
.cockpit-context-window[data-state='uncertain'] {
|
||||
border-top-color: rgba(116, 219, 255, 0.72);
|
||||
}
|
||||
|
||||
.cockpit-context-window[data-state='lost'] {
|
||||
border-top-color: rgba(213, 168, 99, 0.72);
|
||||
}
|
||||
|
||||
.cockpit-context-window[data-collapsed='true'],
|
||||
.cockpit-signal-window[data-collapsed='true'] {
|
||||
border-radius: 12px;
|
||||
background: rgba(12, 12, 20, 0.66);
|
||||
}
|
||||
|
||||
/* Headers: a quiet hairline like the panel headers. */
|
||||
.cockpit-card-header {
|
||||
border-bottom-color: rgba(255, 255, 255, 0.08);
|
||||
}
|
||||
|
||||
.cockpit-card-actions button {
|
||||
border-color: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 6px;
|
||||
background: rgba(255, 255, 255, 0.04);
|
||||
color: rgba(224, 236, 242, 0.82);
|
||||
}
|
||||
|
||||
.cockpit-card-actions button:hover,
|
||||
.cockpit-card-actions button:focus-visible {
|
||||
border-color: rgba(0, 212, 255, 0.45);
|
||||
background: rgba(0, 212, 255, 0.1);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
/* Rows and tiles inside: the card style used in Context and Visual. */
|
||||
.cockpit-context-cohorts > div,
|
||||
.cockpit-signal-list li,
|
||||
.cockpit-news-list li,
|
||||
.cockpit-local-grid > div {
|
||||
border: 1px solid rgba(255, 255, 255, 0.06);
|
||||
border-radius: 10px;
|
||||
background: rgba(255, 255, 255, 0.035);
|
||||
}
|
||||
|
||||
/* The weather tiles stand apart as cards, with no lit grid behind them,
|
||||
and are short enough to fit the shorter window. */
|
||||
.cockpit-local-grid {
|
||||
gap: 5px;
|
||||
background: none;
|
||||
}
|
||||
|
||||
.cockpit-local-grid > div {
|
||||
min-height: 0;
|
||||
gap: 2px;
|
||||
padding: 6px 9px;
|
||||
}
|
||||
|
||||
.cockpit-route-card {
|
||||
border-bottom-color: rgba(255, 255, 255, 0.08);
|
||||
}
|
||||
|
||||
/* Display / Radio: the closed launchers and the open panels match too. */
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-control.is-expanded {
|
||||
border-color: rgba(255, 255, 255, 0.08);
|
||||
border-radius: 16px;
|
||||
background: rgba(12, 12, 20, 0.72);
|
||||
box-shadow:
|
||||
0 8px 32px rgba(0, 0, 0, 0.42),
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.04);
|
||||
}
|
||||
|
||||
/* ── Cockpit uses the main page's rails ───────────────────────────────
|
||||
The left rail shows Data Layers only (Authoring has no place in first
|
||||
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'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
#left-panel-stack
|
||||
> .gev-panel-rail--left {
|
||||
display: block;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
#left-panel-stack
|
||||
> .gev-panel-rail--left
|
||||
:is(
|
||||
[data-rail-item='scene-panel'],
|
||||
[data-rail-item='utilities-panel'],
|
||||
[data-rail-item='pp-toggles']
|
||||
),
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
#left-panel-stack
|
||||
> .gev-panel-rail--left
|
||||
.ui-tooltip:has(
|
||||
> :is(
|
||||
[data-rail-item='scene-panel'],
|
||||
[data-rail-item='utilities-panel'],
|
||||
[data-rail-item='pp-toggles']
|
||||
)
|
||||
) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* 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'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
#left-panel-stack
|
||||
> .gev-panel-rail--left
|
||||
.ui-rail--collapsible:not(.ui-rail--expanded):has(.ui-rail__item--on)
|
||||
> .ui-tooltip::before {
|
||||
inset: -4px -5px;
|
||||
border-width: 1px;
|
||||
border-radius: 14px;
|
||||
}
|
||||
|
||||
/* 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'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
#left-panel-stack
|
||||
> .gev-panel-rail--left
|
||||
.ui-rail:has(
|
||||
:is(
|
||||
[data-rail-item='scene-panel'],
|
||||
[data-rail-item='utilities-panel'],
|
||||
[data-rail-item='pp-toggles']
|
||||
)[aria-pressed='true']
|
||||
)
|
||||
> .ui-tooltip::before,
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
#left-panel-stack
|
||||
> .gev-panel-rail--left
|
||||
.ui-rail:has(
|
||||
:is(
|
||||
[data-rail-item='scene-panel'],
|
||||
[data-rail-item='utilities-panel'],
|
||||
[data-rail-item='pp-toggles']
|
||||
)[aria-pressed='true']
|
||||
)::before {
|
||||
/* Nor may the sliding highlight stay where the hidden icon was. */
|
||||
display: none;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
#left-panel-stack
|
||||
> .gev-panel-rail--left
|
||||
.ui-rail:has(
|
||||
:is(
|
||||
[data-rail-item='scene-panel'],
|
||||
[data-rail-item='utilities-panel'],
|
||||
[data-rail-item='pp-toggles']
|
||||
)[aria-pressed='true']
|
||||
) {
|
||||
background: rgba(16, 20, 28, 0.82) !important;
|
||||
border-color: rgba(255, 255, 255, 0.14) !important;
|
||||
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45) !important;
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
#left-panel-stack
|
||||
> [data-panel-id].collapsed,
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
#left-panel-stack
|
||||
> :is(
|
||||
[data-panel-id='scene-panel'],
|
||||
[data-panel-id='utilities-panel'],
|
||||
[data-panel-id='pp-toggles']
|
||||
) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* 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 {
|
||||
top: max(206px, 22vh) !important;
|
||||
}
|
||||
|
||||
/* Bottom HUD readouts: scale from their foot, and drop the three-line right
|
||||
block (GSD / ALT / AIS) by one scaled line so both start level, as on the
|
||||
main page. */
|
||||
body.cockpit-mode #intel-hud .hud-bottom-left {
|
||||
transform-origin: left bottom;
|
||||
}
|
||||
|
||||
body.cockpit-mode #intel-hud .hud-bottom-right {
|
||||
bottom: calc(clamp(84px, 11vh, 118px) - 20px);
|
||||
transform-origin: right bottom;
|
||||
}
|
||||
|
||||
/* ── Live signals rows ──────────────────────────────────────────────────
|
||||
Callsign on the left, time small at the top right, the detail under it.
|
||||
The status colour is a slim inset bar (cyan for the aircraft you ride,
|
||||
white for nearby, amber for military / warnings), not a bent border. */
|
||||
.cockpit-signal-list {
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.cockpit-signal-list li {
|
||||
position: relative;
|
||||
display: block;
|
||||
padding: 5px 10px 5px 12px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.06);
|
||||
box-shadow: inset 2px 0 0 rgba(244, 251, 255, 0.22);
|
||||
}
|
||||
|
||||
.cockpit-signal-list li:is(.track, .current) {
|
||||
border-color: rgba(0, 212, 255, 0.22);
|
||||
background: rgba(0, 212, 255, 0.06);
|
||||
box-shadow: inset 2px 0 0 var(--cockpit-accent, #00d4ff);
|
||||
}
|
||||
|
||||
.cockpit-signal-list li:is(.nearby) {
|
||||
border-color: rgba(255, 255, 255, 0.06);
|
||||
box-shadow: inset 2px 0 0 rgba(244, 251, 255, 0.55);
|
||||
}
|
||||
|
||||
.cockpit-signal-list li:is(.military, .warning) {
|
||||
border-color: rgba(255, 255, 255, 0.06);
|
||||
box-shadow: inset 2px 0 0 #d5a863;
|
||||
}
|
||||
|
||||
.cockpit-signal-list li.actionable:is(:hover, :focus-within) {
|
||||
border-color: rgba(0, 212, 255, 0.3);
|
||||
background: rgba(0, 212, 255, 0.08);
|
||||
}
|
||||
|
||||
.cockpit-signal-list time {
|
||||
position: absolute;
|
||||
top: 6px;
|
||||
inset-inline-end: 28px;
|
||||
color: rgba(224, 236, 242, 0.4);
|
||||
font: 7px/1 var(--font-mono);
|
||||
letter-spacing: 0.06em;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.cockpit-signal-list li > div {
|
||||
gap: 1px;
|
||||
}
|
||||
|
||||
.cockpit-signal-target {
|
||||
grid-template-columns: minmax(0, 1fr) 14px;
|
||||
gap: 8px;
|
||||
font-size: 10.5px;
|
||||
letter-spacing: 0.1em;
|
||||
}
|
||||
|
||||
.cockpit-signal-target-rule {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.cockpit-signal-target-chevron {
|
||||
justify-self: end;
|
||||
color: rgba(224, 236, 242, 0.5) !important;
|
||||
}
|
||||
|
||||
.cockpit-signal-list
|
||||
li.actionable:is(:hover, :focus-within)
|
||||
.cockpit-signal-target-chevron {
|
||||
color: #fff !important;
|
||||
}
|
||||
|
||||
.cockpit-signal-list span:not([class]) {
|
||||
color: rgba(224, 236, 242, 0.62);
|
||||
font-size: 8px;
|
||||
letter-spacing: 0.08em;
|
||||
}
|
||||
|
||||
/* Keep a long callsign clear of the time at the row's end. */
|
||||
.cockpit-signal-list .cockpit-signal-target-label {
|
||||
margin-inline-end: 50px;
|
||||
}
|
||||
|
||||
/* ── Briefing content fits the narrower window ────────────────────────── */
|
||||
.cockpit-signal-window {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.cockpit-signal-window > *,
|
||||
.cockpit-brief-stage,
|
||||
.cockpit-brief-stage > section,
|
||||
.cockpit-signal-list,
|
||||
.cockpit-signal-list li {
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* Route: a quiet heading, endpoints that truncate. */
|
||||
.cockpit-route-card {
|
||||
padding-inline: 4px;
|
||||
}
|
||||
|
||||
.cockpit-route-heading {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
#cockpit-route-status {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.cockpit-route-airport strong {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* Header: the title on one line, the controls on the row under it. */
|
||||
.cockpit-signal-window:not([data-collapsed='true']) .cockpit-signal-header {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
gap: 6px;
|
||||
padding-inline: 4px;
|
||||
}
|
||||
|
||||
.cockpit-signal-window:not([data-collapsed='true']) .cockpit-brief-heading {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: baseline;
|
||||
gap: 2px 8px;
|
||||
}
|
||||
|
||||
.cockpit-signal-window:not([data-collapsed='true']) .cockpit-signal-kicker {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.cockpit-signal-window:not([data-collapsed='true']) .cockpit-brief-actions {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.cockpit-signal-window:not([data-collapsed='true']) #cockpit-signal-toggle {
|
||||
margin-inline-start: auto;
|
||||
}
|
||||
|
||||
/* ── Open Display / Radio panels: the main panels' header and size ───── */
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-control.is-expanded {
|
||||
min-width: 295px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-control.is-expanded
|
||||
.cockpit-utility-launcher {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 4px 4px 10px 8px;
|
||||
color: rgba(224, 236, 242, 0.78);
|
||||
font: 9px/1 var(--font-mono);
|
||||
letter-spacing: 0.22em;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-control.is-expanded
|
||||
.cockpit-utility-divider {
|
||||
flex: 0 1 22px;
|
||||
height: 1px;
|
||||
margin-right: auto;
|
||||
background: rgba(255, 255, 255, 0.18);
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
/* The launcher's own toggle steps aside: the rail and "−" open and close
|
||||
the panel instead. */
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
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 {
|
||||
display: grid;
|
||||
flex: none;
|
||||
place-items: center;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
padding: 0;
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
border-radius: 6px;
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
color: rgba(206, 232, 239, 0.75);
|
||||
font: 13px/1 var(--font-mono);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-collapse:hover,
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-collapse:focus-visible {
|
||||
border-color: rgba(0, 212, 255, 0.45);
|
||||
color: #fff;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
/* ── 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 {
|
||||
display: grid;
|
||||
grid-template-columns: auto auto;
|
||||
align-items: start;
|
||||
justify-content: end;
|
||||
column-gap: 6px;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-control:not(.is-expanded) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-control.is-expanded {
|
||||
grid-column: 1;
|
||||
grid-row: 1;
|
||||
margin-top: 0 !important;
|
||||
}
|
||||
|
||||
/* Cyber and the phone keep 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 {
|
||||
grid-column: 2;
|
||||
grid-row: 1;
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
align-items: stretch;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
:is(.cockpit-utility-rail__labels, .cockpit-utility-rail__icons) {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
padding: 4px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.14);
|
||||
border-radius: 14px;
|
||||
background: rgba(16, 20, 28, 0.82);
|
||||
box-shadow:
|
||||
0 6px 20px rgba(0, 0, 0, 0.45),
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.05);
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
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'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-rail__labels
|
||||
> span {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 32px;
|
||||
color: rgba(225, 236, 242, 0.82);
|
||||
font:
|
||||
500 9.28px/1 Inter,
|
||||
-apple-system,
|
||||
system-ui,
|
||||
sans-serif;
|
||||
letter-spacing: 2.08px;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
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 {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
padding: 0;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 10px;
|
||||
background: transparent;
|
||||
color: var(--text-secondary, rgba(206, 232, 239, 0.75));
|
||||
cursor: pointer;
|
||||
transition:
|
||||
color var(--transition-fast, 120ms),
|
||||
background var(--transition-fast, 120ms),
|
||||
border-color var(--transition-fast, 120ms);
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
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 {
|
||||
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'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-rail__item.is-on:hover {
|
||||
border-color: rgba(0, 212, 255, 0.15);
|
||||
background: rgba(0, 212, 255, 0.15);
|
||||
color: #00d4ff;
|
||||
}
|
||||
|
||||
/* With a panel open, each icon is its own island, as on the main rails. */
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-rail.is-open
|
||||
.cockpit-utility-rail__icons {
|
||||
border-color: transparent;
|
||||
background: none;
|
||||
box-shadow: none;
|
||||
backdrop-filter: none;
|
||||
-webkit-backdrop-filter: none;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-rail.is-open
|
||||
.cockpit-utility-rail__item {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-rail.is-open
|
||||
.cockpit-utility-rail__item::before {
|
||||
position: absolute;
|
||||
inset: -5px;
|
||||
z-index: -1;
|
||||
border: 1px solid rgba(255, 255, 255, 0.14);
|
||||
border-radius: 14px;
|
||||
background: rgba(16, 20, 28, 0.82);
|
||||
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
content: '';
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* Hovering an icon lights its label too, as on the left. */
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
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'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
.cockpit-utility-rail:has(.cockpit-utility-rail__item:nth-child(2):hover)
|
||||
.cockpit-utility-rail__labels
|
||||
> span:nth-child(2) {
|
||||
color: var(--text-primary, #fff);
|
||||
}
|
||||
|
||||
/* 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 {
|
||||
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 {
|
||||
direction: ltr;
|
||||
}
|
||||
|
||||
html[dir='rtl']:not([data-ui-theme='cyber'])
|
||||
body.cockpit-mode:not(.mobile-shell)
|
||||
:is(.cockpit-utility-control.is-expanded, .cockpit-utility-rail__labels) {
|
||||
direction: rtl;
|
||||
}
|
||||
@@ -599,7 +599,10 @@ html:not([lang='en']):not(:lang(zh)):not(:lang(ja))
|
||||
|
||||
#pp-toggles.collapsed .pp-toggle-group,
|
||||
#pp-toggles.collapsed #clean-view-toggle,
|
||||
#pp-toggles.collapsed #param-slider-panel {
|
||||
#pp-toggles.collapsed #param-slider-panel,
|
||||
#pp-toggles.collapsed .visual-presets,
|
||||
#pp-toggles.collapsed .pp-section-heading,
|
||||
#pp-toggles.collapsed .pp-reset-btn {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
/* ── Data Layers search and filter ── */
|
||||
.layer-finder__btn {
|
||||
display: grid;
|
||||
flex: none;
|
||||
place-items: center;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
padding: 0;
|
||||
color: rgba(206, 232, 239, 0.65);
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.layer-finder__btn .material-symbols-outlined {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.layer-finder__btn:hover,
|
||||
.layer-finder__btn:focus-visible {
|
||||
color: #fff;
|
||||
border-color: rgba(255, 255, 255, 0.24);
|
||||
}
|
||||
|
||||
.layer-finder__btn.active {
|
||||
color: #36dcff;
|
||||
background: rgba(54, 220, 255, 0.12);
|
||||
border-color: rgba(54, 220, 255, 0.45);
|
||||
}
|
||||
|
||||
.layer-finder__filter {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
.layer-finder__menu {
|
||||
position: absolute;
|
||||
top: calc(100% + 6px);
|
||||
right: 0;
|
||||
z-index: 20;
|
||||
display: grid;
|
||||
min-width: 140px;
|
||||
padding: 4px;
|
||||
background: rgba(16, 20, 28, 0.96);
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.layer-finder__menu button {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.45rem;
|
||||
padding: 0.4rem 0.55rem;
|
||||
color: rgba(225, 236, 242, 0.85);
|
||||
font-size: 0.72rem;
|
||||
text-align: start;
|
||||
background: none;
|
||||
border: 0;
|
||||
border-radius: 7px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.layer-finder__menu button .material-symbols-outlined {
|
||||
font-size: 14px;
|
||||
color: rgba(199, 214, 222, 0.6);
|
||||
}
|
||||
|
||||
.layer-finder__menu button:hover {
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
}
|
||||
|
||||
.layer-finder__menu button.active,
|
||||
.layer-finder__menu button.active .material-symbols-outlined {
|
||||
color: #7af0ff;
|
||||
}
|
||||
|
||||
.layer-finder__bar {
|
||||
display: flex;
|
||||
flex: none;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
margin: 0.2rem 0 0.5rem;
|
||||
}
|
||||
|
||||
.layer-finder__field {
|
||||
display: flex;
|
||||
flex: 1 1 auto;
|
||||
align-items: center;
|
||||
gap: 0.35rem;
|
||||
padding: 0 0.55rem;
|
||||
height: 30px;
|
||||
background: rgba(255, 255, 255, 0.04);
|
||||
border: 1px solid rgba(54, 220, 255, 0.3);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.layer-finder__field .material-symbols-outlined {
|
||||
color: rgba(199, 214, 222, 0.6);
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.layer-finder__field input {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
color: rgba(236, 244, 248, 0.95);
|
||||
font-size: 0.75rem;
|
||||
background: none;
|
||||
border: 0;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
/* Focus shows on the field's frame, as a soft ring, in place of the hard
|
||||
keyboard outline round the bare input. */
|
||||
.layer-finder__field input:focus,
|
||||
.layer-finder__field input:focus-visible {
|
||||
outline: none !important;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.layer-finder__field:focus-within {
|
||||
border-color: rgba(54, 220, 255, 0.7);
|
||||
box-shadow: 0 0 0 3px rgba(54, 220, 255, 0.1);
|
||||
}
|
||||
|
||||
.layer-finder__chip {
|
||||
display: inline-flex;
|
||||
flex: none;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
height: 26px;
|
||||
padding: 0 0.5rem;
|
||||
color: #7af0ff;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.56rem;
|
||||
letter-spacing: 0.1rem;
|
||||
text-transform: uppercase;
|
||||
background: rgba(54, 220, 255, 0.12);
|
||||
border: 1px solid rgba(54, 220, 255, 0.45);
|
||||
border-radius: 999px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.layer-finder__chip .material-symbols-outlined {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* Rows and group headings the search or filter leaves out. */
|
||||
#data-toggles .is-filtered {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.layer-finder__empty {
|
||||
flex-basis: 100%;
|
||||
margin: 0;
|
||||
padding: 0.6rem 0.5rem;
|
||||
color: rgba(199, 214, 222, 0.5);
|
||||
font-size: 0.72rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.layer-finder__menu {
|
||||
max-height: 60vh;
|
||||
box-sizing: border-box;
|
||||
overflow-y: auto;
|
||||
min-width: 170px;
|
||||
}
|
||||
|
||||
.layer-finder__menu-head {
|
||||
padding: 0.45rem 0.55rem 0.2rem;
|
||||
color: rgba(199, 214, 222, 0.5);
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.52rem;
|
||||
letter-spacing: 0.14rem;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
/* Each group of options lays out as part of the menu's grid. */
|
||||
.layer-finder__menu > span {
|
||||
display: contents;
|
||||
}
|
||||
|
||||
.layer-finder__menu > span + span > .layer-finder__menu-head {
|
||||
margin-top: 0.2rem;
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.08);
|
||||
}
|
||||
|
||||
/* Several chips can show at once. */
|
||||
.layer-finder__bar {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
/* Chips sized like the rows' ON/OFF switches: small and square. */
|
||||
.layer-finder__chip {
|
||||
height: 20px;
|
||||
gap: 0.2rem;
|
||||
padding: 0 6px 0 8px;
|
||||
font-size: 9px;
|
||||
letter-spacing: 0.08rem;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.layer-finder__chip .material-symbols-outlined {
|
||||
font-size: 11px;
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
/* ── Data Layers group index: ticks along the panel's right edge ─────── */
|
||||
#data-panel {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.layer-section-index {
|
||||
position: absolute;
|
||||
top: 64px;
|
||||
inset-inline-end: 2px;
|
||||
bottom: 24px;
|
||||
z-index: 2;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
width: 10px;
|
||||
}
|
||||
|
||||
#data-panel.collapsed .layer-section-index {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.layer-section-index__tick {
|
||||
position: relative;
|
||||
width: 10px;
|
||||
height: 16px;
|
||||
padding: 0;
|
||||
background: none;
|
||||
border: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.layer-section-index__tick::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
bottom: 2px;
|
||||
left: 4px;
|
||||
width: 2px;
|
||||
border-radius: 2px;
|
||||
background: rgba(199, 214, 222, 0.32);
|
||||
transition:
|
||||
background 140ms ease,
|
||||
box-shadow 140ms ease,
|
||||
transform 140ms ease;
|
||||
}
|
||||
|
||||
.layer-section-index__tick:hover::before,
|
||||
.layer-section-index__tick:focus-visible::before {
|
||||
background: rgba(236, 244, 248, 0.85);
|
||||
transform: scaleX(1.5);
|
||||
}
|
||||
|
||||
.layer-section-index__tick.is-current::before {
|
||||
background: #36dcff;
|
||||
box-shadow: 0 0 6px rgba(54, 220, 255, 0.6);
|
||||
}
|
||||
|
||||
.layer-section-index__tick:focus-visible {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
/* The group's name, drawn on the page just outside the panel's edge while a
|
||||
tick is pointed at or focused, so it covers none of the rows. */
|
||||
.layer-section-index__label {
|
||||
position: fixed;
|
||||
z-index: 30;
|
||||
padding: 0.25rem 0.5rem;
|
||||
color: rgba(236, 244, 248, 0.92);
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.56rem;
|
||||
letter-spacing: 0.12rem;
|
||||
text-transform: uppercase;
|
||||
white-space: nowrap;
|
||||
background: rgba(12, 12, 20, 0.88);
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
border-radius: 6px;
|
||||
transform: translateY(-50%);
|
||||
pointer-events: none;
|
||||
animation: layer-section-index-label 120ms ease both;
|
||||
}
|
||||
|
||||
/* Drawn before the tick when there is no room after it. */
|
||||
.layer-section-index__label--before {
|
||||
transform: translate(-100%, -50%);
|
||||
}
|
||||
|
||||
@keyframes layer-section-index-label {
|
||||
from {
|
||||
opacity: 0;
|
||||
translate: -4px 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
translate: 0 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.layer-section-index__label {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
|
||||
body.mobile-shell .layer-section-index {
|
||||
display: none;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/* With Scope off the map fills the whole screen. The HUD keeps its black
|
||||
plates (overlays.css); the glass chrome lifts off the map with a soft
|
||||
drop shadow. */
|
||||
:root[data-scope-mask='off'] {
|
||||
--scope-off-panel-shadow:
|
||||
0 10px 30px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.45);
|
||||
}
|
||||
|
||||
/* Glass surfaces (rails, the rails' name panels, open panels and
|
||||
the dock) get a lift so their edges hold against bright imagery. */
|
||||
:root[data-scope-mask='off'] .ui-rail,
|
||||
:root[data-scope-mask='off'] .gev-panel-rail .ui-rail--expanded::after,
|
||||
:root[data-scope-mask='off']
|
||||
:is(.data-panel-inner, .utilities-panel-inner, .ui-panel__inner),
|
||||
:root[data-scope-mask='off'] #left-panel-stack > #pp-toggles,
|
||||
:root[data-scope-mask='off']
|
||||
#right-context-rail
|
||||
> [data-panel-id]:not(.collapsed),
|
||||
:root[data-scope-mask='off'] #command-dock > * {
|
||||
box-shadow: var(--scope-off-panel-shadow);
|
||||
}
|
||||
|
||||
:root[data-scope-mask='off'] .ui-rail__label,
|
||||
:root[data-scope-mask='off'] .ui-rail__item .ui-icon {
|
||||
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
/* ── Visual panel: sections and one card style for every control ───────
|
||||
Look · Map source · Overlay (HUD, detection, 3D, Scope, Clean UI) ·
|
||||
Effects (Celestial, Bloom, Sharpen) · Reset. Each control is a card: a
|
||||
header row with its icon, name and an on/off pill, and its settings
|
||||
underneath. */
|
||||
|
||||
/* ── Presets and map source at the top of the panel ─────────────────── */
|
||||
.visual-presets {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
padding: 2px 0 12px;
|
||||
margin-bottom: 10px;
|
||||
border-bottom: 1px solid var(--glass-border);
|
||||
}
|
||||
|
||||
.visual-presets__heading {
|
||||
margin: 4px 0 0;
|
||||
color: var(--text-secondary);
|
||||
font: 600 10px/1.2 var(--font-mono);
|
||||
letter-spacing: 0.14em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.visual-presets__heading--row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.visual-presets__status {
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.visual-presets__status.warn {
|
||||
color: #ff9f43;
|
||||
}
|
||||
|
||||
.visual-presets__grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.visual-presets__style {
|
||||
position: relative;
|
||||
display: grid;
|
||||
justify-items: center;
|
||||
gap: 4px;
|
||||
padding: 9px 4px 7px;
|
||||
color: var(--text-secondary);
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
border: 1px solid var(--glass-border);
|
||||
border-radius: var(--btn-radius);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.visual-presets__style:hover {
|
||||
color: var(--text-primary);
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
}
|
||||
|
||||
.visual-presets__style.active {
|
||||
color: var(--accent);
|
||||
background: var(--accent-dim);
|
||||
border-color: var(--accent-dim);
|
||||
}
|
||||
|
||||
.visual-presets__icon {
|
||||
font-size: 15px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.visual-presets__label {
|
||||
font: 500 11px/1 var(--font-sans);
|
||||
}
|
||||
|
||||
.visual-presets__key {
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
inset-inline-end: 5px;
|
||||
color: var(--text-secondary);
|
||||
font: 9px/1 var(--font-mono);
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.visual-presets__chips {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.visual-presets__chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
padding: 5px 9px;
|
||||
color: var(--text-secondary);
|
||||
font: 500 11px/1.2 var(--font-sans);
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
border: 1px solid var(--glass-border);
|
||||
border-radius: 999px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.visual-presets__chip small {
|
||||
font-size: 9px;
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.visual-presets__chip:hover {
|
||||
color: var(--text-primary);
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
}
|
||||
|
||||
.visual-presets__chip.active {
|
||||
color: var(--accent);
|
||||
background: var(--accent-dim);
|
||||
border-color: var(--accent-dim);
|
||||
}
|
||||
|
||||
.visual-presets__chip.unavailable {
|
||||
opacity: 0.45;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
/* The phone's More sheet shows the dock's Visual Presets tray right above
|
||||
Visual, so the panel leaves out its own copy there. */
|
||||
body.mobile-shell #pp-toggles .visual-presets {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* The body is display: contents, so its children are the panel's own flex
|
||||
items: keep them full width and unshrunk. */
|
||||
#pp-toggles .pp-panel-body > * {
|
||||
flex: none !important;
|
||||
align-self: stretch !important;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
#pp-toggles .pp-panel-body > .pp-toggle-group,
|
||||
#pp-toggles .pp-panel-body > .pp-toggle-btn {
|
||||
margin-bottom: 0.4rem !important;
|
||||
}
|
||||
|
||||
#pp-toggles .pp-section-heading,
|
||||
#pp-toggles .visual-presets__heading {
|
||||
margin: 0.7rem 2px 0.35rem;
|
||||
text-align: start;
|
||||
color: rgba(199, 214, 222, 0.55);
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.56rem;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.14rem;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
#pp-toggles .visual-presets__heading:first-child {
|
||||
margin-top: 0.2rem;
|
||||
}
|
||||
|
||||
/* The card skin below is the default look; the Cyber HUD keeps its own red
|
||||
skin for these controls (cyber.css), so the skin stands aside there. */
|
||||
:root:not([data-ui-theme='cyber']) #pp-toggles .pp-toggle-group {
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
border: 1px solid rgba(255, 255, 255, 0.07);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
/* The header row of a card, and the lone Clean UI button. */
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
#pp-toggles
|
||||
.pp-toggle-group
|
||||
> .pp-toggle-btn,
|
||||
:root:not([data-ui-theme='cyber']) #pp-toggles .pp-panel-body > .pp-toggle-btn {
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
min-height: 38px;
|
||||
padding: 0 12px;
|
||||
gap: 10px;
|
||||
background: transparent !important;
|
||||
border: 0 !important;
|
||||
border-radius: 0 !important;
|
||||
box-shadow: none !important;
|
||||
backdrop-filter: none;
|
||||
-webkit-backdrop-filter: none;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber']) #pp-toggles .pp-panel-body > .pp-toggle-btn {
|
||||
background: rgba(255, 255, 255, 0.03) !important;
|
||||
border: 1px solid rgba(255, 255, 255, 0.07) !important;
|
||||
border-radius: 10px !important;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber']) #pp-toggles .pp-toggle-btn .pp-icon {
|
||||
width: 18px;
|
||||
font-size: 15px;
|
||||
text-align: center;
|
||||
color: rgba(199, 214, 222, 0.75);
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber']) #pp-toggles .pp-toggle-btn .pp-label {
|
||||
color: rgba(236, 244, 248, 0.9);
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.62rem;
|
||||
letter-spacing: 0.12rem;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
/* An on/off pill at the right of every button header (Scope keeps its
|
||||
checkbox, which already says it). */
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
#pp-toggles
|
||||
.pp-toggle-group
|
||||
> button.pp-toggle-btn::after,
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
#pp-toggles
|
||||
.pp-panel-body
|
||||
> button.pp-toggle-btn::after {
|
||||
/* The state is the button's own (aria-pressed); the pill only shows it. */
|
||||
content: var(--pp-pill-off, 'OFF') / '';
|
||||
margin-inline-start: auto;
|
||||
padding: 2px 8px;
|
||||
color: rgba(199, 214, 222, 0.5);
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.5rem;
|
||||
letter-spacing: 0.12rem;
|
||||
border: 1px solid rgba(255, 255, 255, 0.14);
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
#pp-toggles
|
||||
.pp-toggle-group
|
||||
> button.pp-toggle-btn.active::after,
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
#pp-toggles
|
||||
.pp-toggle-group
|
||||
> button.pp-toggle-btn[aria-pressed='true']::after,
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
#pp-toggles
|
||||
.pp-panel-body
|
||||
> button.pp-toggle-btn.active::after {
|
||||
content: var(--pp-pill-on, 'ON') / '';
|
||||
color: #7af0ff;
|
||||
border-color: rgba(54, 220, 255, 0.5);
|
||||
background: rgba(54, 220, 255, 0.1);
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber']) #pp-toggles .pp-toggle-btn.active .pp-icon,
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
#pp-toggles
|
||||
.pp-toggle-btn[aria-pressed='true']
|
||||
.pp-icon,
|
||||
:root:not([data-ui-theme='cyber']) #pp-toggles .pp-toggle-btn.active .pp-label,
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
#pp-toggles
|
||||
.pp-toggle-btn[aria-pressed='true']
|
||||
.pp-label {
|
||||
color: #7af0ff;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
#pp-toggles
|
||||
.pp-toggle-group
|
||||
> .pp-toggle-btn:hover,
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
#pp-toggles
|
||||
.pp-panel-body
|
||||
> .pp-toggle-btn:hover {
|
||||
background: rgba(255, 255, 255, 0.04) !important;
|
||||
}
|
||||
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
#pp-toggles
|
||||
.pp-scope-toggle
|
||||
input[type='checkbox'] {
|
||||
margin-inline-start: auto;
|
||||
}
|
||||
|
||||
/* Settings inside a card: separated by hairlines, no boxes of their own. */
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
#pp-toggles
|
||||
.pp-toggle-group
|
||||
.pp-slider-row.visible,
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
#pp-toggles
|
||||
.pp-toggle-group
|
||||
.pp-slider-row:not([class*='cyber-sonar']):is(
|
||||
.visible,
|
||||
#scope-slider-row,
|
||||
#scope-opacity-row
|
||||
) {
|
||||
margin: 0;
|
||||
padding: 7px 12px;
|
||||
background: transparent;
|
||||
border: 0;
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.05);
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
/* The Dense button lights green elsewhere; in a card it uses the shared pill. */
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
#pp-toggles
|
||||
.pp-toggle-group
|
||||
> .pp-toggle-btn.panoptic,
|
||||
:root:not([data-ui-theme='cyber'])
|
||||
#pp-toggles
|
||||
.pp-toggle-group
|
||||
> .pp-toggle-btn.active {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
/* Reset to default, at the foot of the Visual panel. */
|
||||
#pp-toggles .pp-reset-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.4rem;
|
||||
margin: 0.6rem 0 0.2rem !important;
|
||||
padding: 0.55rem;
|
||||
color: rgba(225, 236, 242, 0.85);
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.6rem;
|
||||
letter-spacing: 0.12rem;
|
||||
text-transform: uppercase;
|
||||
background: transparent;
|
||||
border: 1px dashed rgba(255, 255, 255, 0.18);
|
||||
border-radius: 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#pp-toggles .pp-reset-btn .material-symbols-outlined {
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
#pp-toggles .pp-reset-btn:hover,
|
||||
#pp-toggles .pp-reset-btn:focus-visible {
|
||||
color: #fff;
|
||||
border-color: rgba(54, 220, 255, 0.5);
|
||||
background: rgba(54, 220, 255, 0.06);
|
||||
}
|
||||
|
||||
/* Clean UI is an action, not a setting, so it has no on/off pill. */
|
||||
#pp-toggles #clean-view-toggle::after {
|
||||
content: none;
|
||||
}
|
||||
@@ -56,8 +56,7 @@
|
||||
}
|
||||
/* Card typography follows the layer rows and app tokens. */
|
||||
.weather-readout,
|
||||
.rail-card,
|
||||
.rail-timeline {
|
||||
.rail-card {
|
||||
min-width: 0;
|
||||
color: var(--text-dim);
|
||||
font: 9px/1.45 var(--font-mono);
|
||||
@@ -128,7 +127,7 @@
|
||||
text-align: right;
|
||||
}
|
||||
.rail-card-line,
|
||||
.rail-timeline-readout {
|
||||
.weather-frame-time {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 9px;
|
||||
letter-spacing: 0.5px;
|
||||
@@ -188,54 +187,13 @@ html:not([lang='en']) .weather-card [data-line-id='status'] {
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
.rail-card [hidden],
|
||||
.weather-timeline-block[hidden],
|
||||
.weather-frame-time[hidden],
|
||||
.weather-observed-group[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
.rail-timeline {
|
||||
.weather-frame-time {
|
||||
padding: 5px;
|
||||
border-bottom: 1px solid var(--weather-card-border);
|
||||
}
|
||||
.rail-timeline-track {
|
||||
display: grid;
|
||||
grid-template-columns: auto minmax(0, 1fr) auto;
|
||||
align-items: center;
|
||||
gap: 3px 8px;
|
||||
margin-top: 6px;
|
||||
}
|
||||
.rail-timeline-track input {
|
||||
min-width: 0;
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
.rail-timeline-endpoints {
|
||||
display: flex;
|
||||
grid-column: 2;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
gap: 3px 8px;
|
||||
font: 8px/1.45 var(--font-mono);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.rail-timeline-endpoints span {
|
||||
white-space: nowrap;
|
||||
}
|
||||
.rail-timeline-endpoints span:last-child {
|
||||
margin-left: auto;
|
||||
}
|
||||
.rail-timeline-controls .data-toggle-chip {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
.rail-timeline-controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
margin-top: 6px;
|
||||
}
|
||||
.rail-timeline-readout {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
overflow-wrap: anywhere;
|
||||
font-variant-numeric: tabular-nums;
|
||||
color: var(--text-secondary);
|
||||
|
||||
@@ -135,7 +135,7 @@ body.cockpit-mode #world-timeline {
|
||||
}
|
||||
}
|
||||
|
||||
/* The track: ticks for each launch or frame, the elapsed fill, and a native
|
||||
/* The track: ticks for each launch or strong earthquake, the elapsed fill, and a native
|
||||
range input on top for dragging and the keyboard. */
|
||||
#world-timeline .world-timeline-track {
|
||||
position: relative;
|
||||
@@ -194,6 +194,31 @@ body.cockpit-mode #world-timeline {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* A tick's label, shown over the time's bubble while the pointer is on the
|
||||
tick (or the handle rests on its mark). It slides across itself as the
|
||||
bubble does, so it stays within the track, and is never wider than the
|
||||
track: a long label ends in an ellipsis. */
|
||||
#world-timeline .world-timeline-mark-label {
|
||||
position: absolute;
|
||||
box-sizing: border-box;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
bottom: calc(100% + 30px);
|
||||
left: calc(100% * var(--at));
|
||||
z-index: 1;
|
||||
padding: 2px 8px;
|
||||
border: 1px solid rgba(0, 212, 255, 0.4);
|
||||
border-radius: 6px;
|
||||
background: var(--glass-bg);
|
||||
color: var(--text-primary);
|
||||
font-size: 11px;
|
||||
line-height: 1.4;
|
||||
white-space: pre;
|
||||
transform: translateX(calc(var(--at) * -100%));
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* Zoomed, the track drags along. */
|
||||
#world-timeline .world-timeline-track.is-zoomed {
|
||||
cursor: grab;
|
||||
|
||||
@@ -14,6 +14,8 @@ import StreetLevelPanel from './panels/StreetLevelPanel.vue';
|
||||
import DrawControls from './panels/DrawControls.vue';
|
||||
import GeoImport from './panels/GeoImport.vue';
|
||||
import UiSelect from '../kit/UiSelect.js';
|
||||
import LayerSectionIndex from './panels/LayerSectionIndex.vue';
|
||||
import LayerFinder from './panels/LayerFinder.vue';
|
||||
import DataLibraryBrowse from './panels/DataLibraryBrowse.vue';
|
||||
|
||||
// Scene sharing (src/scenes/sharing.js) offers its authoring bar and presents
|
||||
@@ -43,7 +45,10 @@ async function importChosen(event) {
|
||||
<div id="left-panel-stack" class="ui-scroll">
|
||||
<!-- Data Layer Toggle Panel -->
|
||||
<RailPanel id="data-panel" start-collapsed class="active" :title="t('DATA LAYERS')">
|
||||
<template #actions><LayerFinder part="buttons" /></template>
|
||||
<LayerFinder part="bar" />
|
||||
<div id="data-toggles" class="data-toggle-list ui-scroll"></div>
|
||||
<LayerSectionIndex />
|
||||
<!-- Data Library: Browse and its dialog (src/ui/libraryBrowser.js). -->
|
||||
<DataLibraryBrowse />
|
||||
</RailPanel>
|
||||
|
||||
@@ -25,7 +25,7 @@ test('omitted views lose their hosts and the rest render', () => {
|
||||
page(['welcome', 'provider-settings']);
|
||||
mountApplicationViews(document, { omit: ['provider-settings'] });
|
||||
assert.deepEqual(hostNames(), ['welcome']);
|
||||
assert.equal(document.getElementById('key-setup-chip'), null);
|
||||
assert.equal(document.getElementById('key-setup-chip') === null, true);
|
||||
assert.ok(
|
||||
document.querySelector('[data-gev-view="welcome"]').children.length,
|
||||
);
|
||||
@@ -37,7 +37,7 @@ test('a view an earlier call rendered is unmounted when a later call omits it',
|
||||
assert.ok(document.getElementById('key-setup-chip'));
|
||||
mountApplicationViews(document, { omit: ['provider-settings'] });
|
||||
assert.deepEqual(hostNames(), ['welcome']);
|
||||
assert.equal(document.getElementById('key-setup-chip'), null);
|
||||
assert.equal(document.getElementById('key-setup-chip') === null, true);
|
||||
});
|
||||
|
||||
test('unknown view names are refused, in the page or in the omit list', () => {
|
||||
|
||||
@@ -9,10 +9,12 @@ import { useCockpitStore } from '../../stores/cockpit.js';
|
||||
import { useDisplayStore } from '../../stores/display.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
|
||||
// The Cockpit's Display and Radio launchers and their popovers. RadioControls
|
||||
// presents which popover is open and the compact Radio controls; until it
|
||||
// does, both are closed and the controls show their initial state. The
|
||||
// controls call RadioControls through the store. The Display popover's slots
|
||||
// The Cockpit's Display and Radio launchers and their popovers, and the
|
||||
// desktop look's rail, whose icons stay at the edge and open one panel at a
|
||||
// time as the main page's rails do. RadioControls presents which popover is
|
||||
// open and the compact Radio controls; until it does, both are closed and the
|
||||
// controls show their initial state. The controls call RadioControls through
|
||||
// the store. The Display popover's slots
|
||||
// are static: the Display panel teleports its real controls into them while
|
||||
// the Cockpit display portal publishes them.
|
||||
const store = useRadioStore();
|
||||
@@ -52,6 +54,7 @@ const radioLabel = computed(() =>
|
||||
<div class="cockpit-utility-launcher" data-cockpit-launcher="display">
|
||||
<span>{{ t('DISPLAY') }}</span>
|
||||
<span class="cockpit-utility-divider" aria-hidden="true"></span>
|
||||
<button v-if="open.display" type="button" class="cockpit-utility-collapse" :aria-label="t('Collapse panel')" :title="t('Collapse panel')" @click="act('toggleCockpitUtility', 'display', { returnFocus: true })">−</button>
|
||||
<button id="cockpit-display-toggle-btn" class="cockpit-utility-glyph" type="button" :aria-expanded="String(open.display)" aria-controls="cockpit-display-panel" :aria-label="displayLabel" :title="displayLabel">{{ open.display ? '▶' : '◀' }}</button>
|
||||
</div>
|
||||
<div id="cockpit-display-panel" class="cockpit-utility-popover ui-scroll" v-class-toggle="{ 'uses-shared-display-controls': !!cockpitPortal }" role="group" :aria-label="t('Cockpit display options')" :hidden="!open.display">
|
||||
@@ -65,6 +68,7 @@ const radioLabel = computed(() =>
|
||||
<div class="cockpit-utility-launcher" data-cockpit-launcher="radio">
|
||||
<span>{{ t('RADIO') }}</span>
|
||||
<span class="cockpit-utility-divider" aria-hidden="true"></span>
|
||||
<button v-if="open.radio" type="button" class="cockpit-utility-collapse" :aria-label="t('Collapse panel')" :title="t('Collapse panel')" @click="act('toggleCockpitUtility', 'radio', { returnFocus: true })">−</button>
|
||||
<button id="cockpit-radio-toggle-btn" @click="act('toggleCockpitRadio')" class="cockpit-utility-glyph" type="button" :aria-expanded="String(open.radio)" aria-controls="cockpit-radio-panel" :aria-label="radioLabel" :title="radioLabel">{{ open.radio ? '▶' : '◀' }}</button>
|
||||
</div>
|
||||
<div id="cockpit-radio-panel" class="cockpit-utility-popover cockpit-radio-compact" role="group" :aria-label="t('Cockpit compact Radio controls')" :hidden="!open.radio">
|
||||
@@ -82,5 +86,15 @@ const radioLabel = computed(() =>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="cockpit-utility-rail" :class="{ 'is-open': open.display || open.radio }">
|
||||
<span class="cockpit-utility-rail__labels" aria-hidden="true">
|
||||
<span>{{ t('DISPLAY') }}</span>
|
||||
<span>{{ t('RADIO') }}</span>
|
||||
</span>
|
||||
<span class="cockpit-utility-rail__icons">
|
||||
<button type="button" class="cockpit-utility-rail__item" data-cockpit-rail-item="display" :class="{ 'is-on': open.display }" :aria-expanded="String(open.display)" aria-controls="cockpit-display-panel" :aria-label="displayLabel" :title="displayLabel" @click="act('toggleCockpitUtility', 'display')"><span class="material-symbols-outlined" aria-hidden="true">tune</span></button>
|
||||
<button type="button" class="cockpit-utility-rail__item" data-cockpit-rail-item="radio" :class="{ 'is-on': open.radio }" :aria-expanded="String(open.radio)" aria-controls="cockpit-radio-panel" :aria-label="radioLabel" :title="radioLabel" @click="act('toggleCockpitUtility', 'radio')"><span class="material-symbols-outlined" aria-hidden="true">radio</span></button>
|
||||
</span>
|
||||
</div>
|
||||
</aside>
|
||||
</template>
|
||||
@@ -5,12 +5,14 @@ import { t } from '../../../i18n/index.js';
|
||||
import { vPanelState } from '../../rail/panelState.js';
|
||||
import { vClassToggle } from '../../rail/classToggle.js';
|
||||
import PanelCollapseButton from '../../rail/PanelCollapseButton.vue';
|
||||
import UiPanelEdge from '../../kit/UiPanelEdge.vue';
|
||||
import UiSegmented from '../../kit/UiSegmented.vue';
|
||||
import UiSlider from '../../kit/UiSlider.js';
|
||||
import { useDisplayStore } from '../../stores/display.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import UiSelect from '../../kit/UiSelect.js';
|
||||
import { StyleParameterRows } from '../../styleParameters.js';
|
||||
import VisualPresets from './VisualPresets.vue';
|
||||
|
||||
// The Display panel. VisualSettings presents the HUD, Sonar, Scope,
|
||||
// Celestial, detection, bloom and sharpen and AircraftDisplay the 3D group,
|
||||
@@ -21,6 +23,12 @@ const { view, models3d, parameters, cockpitPortal, weather, sky } = storeToRefs(
|
||||
// A control's change goes to its owner (DisplayBindings).
|
||||
const act = (name, ...args) => display.act(name, ...args);
|
||||
const pct = (value) => `${value}%`;
|
||||
// The words of the on/off pill each card header draws (visual-panel.css), as
|
||||
// CSS strings.
|
||||
const pillWords = computed(() => ({
|
||||
'--pp-pill-on': JSON.stringify(t('ON')),
|
||||
'--pp-pill-off': JSON.stringify(t('OFF')),
|
||||
}));
|
||||
const hud = computed(() => view.value?.hud ?? null);
|
||||
const sonar = computed(() => view.value?.sonar ?? null);
|
||||
const sonarOn = computed(() => sonar.value?.enabled ?? true);
|
||||
@@ -29,6 +37,7 @@ const detectButton = computed(() => detection.value?.button ?? null);
|
||||
const allocation = computed(() => detection.value?.allocation ?? 'ELASTIC');
|
||||
const scopeOn = computed(() => view.value?.scope.enabled ?? true);
|
||||
const scopeFeather = computed(() => view.value?.scope.featherPct ?? 100);
|
||||
const scopeOpacity = computed(() => view.value?.scope.opacityPct ?? 100);
|
||||
const celestial = computed(() => view.value?.celestial ?? null);
|
||||
const celestialTitle = computed(() =>
|
||||
celestial.value && !celestial.value.supported
|
||||
@@ -64,15 +73,18 @@ const allocationOptions = computed(() => [
|
||||
<!-- Post-processing toggles (top-right) -->
|
||||
<div id="pp-toggles" v-panel-state="'pp-toggles'" class="panel-collapsible collapsed ui-scroll" data-panel-id="pp-toggles">
|
||||
<div class="compact pp-header-row">
|
||||
<span class="pp-header-label">{{ t('DISPLAY') }}</span>
|
||||
<span class="pp-header-label">{{ t('VISUAL', { context: 'panel' }) }}</span>
|
||||
<span class="panel-divider" aria-hidden="true"></span>
|
||||
<PanelCollapseButton class="pp-collapse-btn" target="pp-toggles" :name="t('DISPLAY')" sideways start-collapsed />
|
||||
<UiPanelEdge />
|
||||
<PanelCollapseButton class="pp-collapse-btn" target="pp-toggles" :name="t('VISUAL', { context: 'panel' })" sideways start-collapsed />
|
||||
</div>
|
||||
<div class="pp-panel-body ui-scroll" data-rail-scroller>
|
||||
<div class="pp-panel-body ui-scroll" data-rail-scroller :style="pillWords">
|
||||
<VisualPresets />
|
||||
<!-- Cockpit shows these four groups in its Display popover: each teleports to the slot the Cockpit display portal publishes. While disabled a Teleport stays in place; its 'body' target only keeps server rendering from dropping it. -->
|
||||
<p class="pp-section-heading">{{ t('Overlay') }}</p>
|
||||
<Teleport :to="cockpitPortal?.hud ?? 'body'" :disabled="!cockpitPortal?.hud">
|
||||
<div class="pp-toggle-group">
|
||||
<button class="pp-toggle-btn" :class="{ active: hud?.visible }" id="hud-toggle" @click="act('toggleHud')" :title="t('Intelligence HUD (H)')">
|
||||
<button class="pp-toggle-btn" :class="{ active: hud?.visible }" :aria-pressed="String(Boolean(hud?.visible))" id="hud-toggle" @click="act('toggleHud')" :title="t('Intelligence HUD (H)')">
|
||||
<span class="pp-icon">◎</span>
|
||||
<span class="pp-label" translate="no">HUD</span>
|
||||
</button>
|
||||
@@ -181,7 +193,17 @@ const allocationOptions = computed(() => [
|
||||
<UiSlider class="pp-slider" id="scope-feather-slider" @update:model-value="act('setScopeFeather', $event)" min="0" max="200" :model-value="scopeFeather" :disabled="!scopeOn" :aria-label="t('Scope edge feather')" :title="t('Scope edge feather as a percentage of the keyhole radius')" />
|
||||
<span class="pp-slider-value" id="scope-feather-value">{{ pct(scopeFeather) }}</span>
|
||||
</div>
|
||||
<div class="pp-slider-row visible" id="scope-opacity-row">
|
||||
<span class="pp-slider-mini-label">{{ t('Opacity') }}</span>
|
||||
<UiSlider class="pp-slider" id="scope-opacity-slider" @update:model-value="act('setScopeOpacity', $event)" min="50" max="100" :model-value="scopeOpacity" :disabled="!scopeOn" :aria-label="t('Scope opacity')" :title="t('How dark the scope shades the view outside the keyhole')" />
|
||||
<span class="pp-slider-value" id="scope-opacity-value">{{ pct(scopeOpacity) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<button class="pp-toggle-btn" id="clean-view-toggle" @click="act('toggleCleanView')" :title="t('Hide UI chrome')">
|
||||
<span class="pp-icon">□</span>
|
||||
<span class="pp-label">{{ t('Clean UI') }}</span>
|
||||
</button>
|
||||
<p class="pp-section-heading">{{ t('Effects') }}</p>
|
||||
<div class="pp-toggle-group">
|
||||
<UiButton class="pp-toggle-btn" :pressed="celestial?.active ?? false" pressed-class="active" id="celestial-toggle" @click="act('toggleCelestial')" :title="celestialTitle" :disabled="celestial ? !celestial.supported : undefined" :aria-disabled="celestial ? String(!celestial.supported) : undefined">
|
||||
<span class="pp-icon material-symbols-outlined" aria-hidden="true">flare</span>
|
||||
@@ -217,12 +239,8 @@ const allocationOptions = computed(() => [
|
||||
<span class="pp-slider-value">{{ pct(weather.values[row.key] ?? 0) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<button class="pp-toggle-btn" id="clean-view-toggle" @click="act('toggleCleanView')" :title="t('Hide UI chrome')">
|
||||
<span class="pp-icon">□</span>
|
||||
<span class="pp-label">{{ t('Clean UI') }}</span>
|
||||
</button>
|
||||
<div class="pp-toggle-group">
|
||||
<button class="pp-toggle-btn" :class="{ active: view?.bloom.active }" id="bloom-toggle" @click="act('toggleBloom')" :title="t('Bloom / Glow')">
|
||||
<button class="pp-toggle-btn" :class="{ active: view?.bloom.active }" :aria-pressed="String(Boolean(view?.bloom.active))" id="bloom-toggle" @click="act('toggleBloom')" :title="t('Bloom / Glow')">
|
||||
<span class="pp-icon">✨</span>
|
||||
<span class="pp-label">{{ t('Bloom') }}</span>
|
||||
</button>
|
||||
@@ -232,7 +250,7 @@ const allocationOptions = computed(() => [
|
||||
</div>
|
||||
</div>
|
||||
<div class="pp-toggle-group">
|
||||
<button class="pp-toggle-btn" :class="{ active: view?.sharpen.active }" id="sharpen-toggle" @click="act('toggleSharpen')" :title="t('Sharpening')">
|
||||
<button class="pp-toggle-btn" :class="{ active: view?.sharpen.active }" :aria-pressed="String(Boolean(view?.sharpen.active))" id="sharpen-toggle" @click="act('toggleSharpen')" :title="t('Sharpening')">
|
||||
<span class="pp-icon">🔍</span>
|
||||
<span class="pp-label">{{ t('Sharpen') }}</span>
|
||||
</button>
|
||||
@@ -241,6 +259,9 @@ const allocationOptions = computed(() => [
|
||||
<span class="pp-slider-value" id="sharpen-intensity-value">{{ pct(view?.sharpen.intensity ?? 49) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="pp-reset-btn" :title="t('Reset Visual to its defaults: Normal look, HUD, scope, labels and effects')" @click="act('resetVisual')">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">restart_alt</span>{{ t('Reset to default') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -77,7 +77,7 @@ test('an application\'s row actions sit before fly to, labelled, and act on thei
|
||||
const note = row('a1').querySelector('.draw-mark-note');
|
||||
assert.equal(note.getAttribute('role'), 'status');
|
||||
assert.equal(note.textContent, '');
|
||||
assert.equal(row('a2').querySelector('.draw-mark-note'), null, 'a row without actions has no note');
|
||||
assert.equal(row('a2').querySelector('.draw-mark-note') === null, true, 'a row without actions has no note');
|
||||
const line = { ...LINE, path: [[0, 0], [1, 0]] };
|
||||
store.publishDraw({ active: true, shape: 'area', color: 'primary', hint: '', marks: presentDrawMarks([line], drawMarkActions([tag]), new Map([['a1', { busy: true, text: '' }]])) });
|
||||
await nextTick();
|
||||
|
||||
@@ -0,0 +1,261 @@
|
||||
<script>
|
||||
import { ref as moduleRef } from 'vue';
|
||||
|
||||
/** Voice and other callers ask for this event to show every row again. */
|
||||
export const LAYER_FINDER_CLEAR_EVENT = 'gev:layer-finder-clear';
|
||||
|
||||
// The header buttons and the bar under the header are two instances that
|
||||
// share one finder.
|
||||
const finder = {
|
||||
query: moduleRef(''),
|
||||
show: moduleRef('all'),
|
||||
searching: moduleRef(false),
|
||||
filtering: moduleRef(false),
|
||||
// A group's stable key (LayerRows' `data-group`), not its translated name,
|
||||
// so a language change keeps the choice.
|
||||
category: moduleRef(''),
|
||||
categories: moduleRef([]),
|
||||
shown: moduleRef(0),
|
||||
};
|
||||
</script>
|
||||
|
||||
<script setup>
|
||||
import { nextTick, onBeforeUnmount, onMounted, ref, watch, computed } from 'vue';
|
||||
import { msg, t } from '../../../i18n/index.js';
|
||||
|
||||
// Search and filter for the Data Layers list. The rows are rendered elsewhere
|
||||
// (LayerRows), so this works on the list as it stands: it marks rows that
|
||||
// don't match as filtered out, hides a group heading when none of its rows
|
||||
// are left, and keeps doing so as rows update.
|
||||
const props = defineProps({
|
||||
/** 'buttons' for the header, 'bar' for the row under it. */
|
||||
part: { type: String, default: 'buttons' },
|
||||
});
|
||||
|
||||
const { query, show, searching, filtering, category, categories, shown } =
|
||||
finder;
|
||||
|
||||
const SHOWS = [
|
||||
{ id: 'all', label: msg('All layers') },
|
||||
{ id: 'on', label: msg('On') },
|
||||
{ id: 'off', label: msg('Off') },
|
||||
];
|
||||
|
||||
const narrowed = computed(
|
||||
() =>
|
||||
Boolean(query.value.trim()) || show.value !== 'all' || Boolean(category.value),
|
||||
);
|
||||
const categoryLabel = computed(
|
||||
() => categories.value.find((c) => c.key === category.value)?.label || '',
|
||||
);
|
||||
|
||||
function apply() {
|
||||
const list = document.getElementById('data-toggles');
|
||||
if (!list) return;
|
||||
const q = query.value.trim().toLocaleLowerCase();
|
||||
let heading = null;
|
||||
let headingHasRows = false;
|
||||
let count = 0;
|
||||
let group = '';
|
||||
const groups = [];
|
||||
const close = () =>
|
||||
heading?.classList.toggle('is-filtered', !headingHasRows);
|
||||
for (const el of list.children) {
|
||||
if (el.classList.contains('data-layer-group-heading')) {
|
||||
close();
|
||||
heading = el;
|
||||
headingHasRows = false;
|
||||
group = el.dataset.group || el.textContent.trim();
|
||||
groups.push({ key: group, label: el.textContent.trim() });
|
||||
continue;
|
||||
}
|
||||
if (!el.classList.contains('data-toggle-row')) continue;
|
||||
// The name on screen, in the UI language, and the English name too.
|
||||
const name = [el.querySelector('.data-name')?.textContent, el.dataset.layerName]
|
||||
.filter(Boolean)
|
||||
.join(' ')
|
||||
.toLocaleLowerCase();
|
||||
// On means the layer is enabled, whatever its feed is doing.
|
||||
const on = Boolean(
|
||||
el.querySelector('.data-toggle-btn')?.classList.contains('active'),
|
||||
);
|
||||
const match =
|
||||
(!q || name.includes(q)) &&
|
||||
(show.value === 'all' || (show.value === 'on') === on) &&
|
||||
(!category.value || group === category.value);
|
||||
el.classList.toggle('is-filtered', !match);
|
||||
if (match) {
|
||||
headingHasRows = true;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
close();
|
||||
list.classList.toggle('is-filtering', narrowed.value);
|
||||
const same =
|
||||
groups.length === categories.value.length &&
|
||||
groups.every(
|
||||
(g, i) =>
|
||||
g.key === categories.value[i].key && g.label === categories.value[i].label,
|
||||
);
|
||||
if (!same) categories.value = groups;
|
||||
// A group that went away takes its filter with it.
|
||||
if (category.value && !groups.some((g) => g.key === category.value))
|
||||
category.value = '';
|
||||
shown.value = count;
|
||||
}
|
||||
|
||||
function clearAll() {
|
||||
query.value = '';
|
||||
show.value = 'all';
|
||||
category.value = '';
|
||||
searching.value = false;
|
||||
filtering.value = false;
|
||||
apply();
|
||||
}
|
||||
|
||||
let observer = null;
|
||||
let frame = 0;
|
||||
if (props.part === 'bar') {
|
||||
onMounted(() => {
|
||||
const list = document.getElementById('data-toggles');
|
||||
if (!list) return;
|
||||
// Rows repaint many times a second; filter once per frame at most.
|
||||
observer = new MutationObserver(() => {
|
||||
if (frame) return;
|
||||
frame = requestAnimationFrame(() => {
|
||||
frame = 0;
|
||||
apply();
|
||||
});
|
||||
});
|
||||
observer.observe(list, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
characterData: true,
|
||||
attributes: true,
|
||||
attributeFilter: ['class', 'data-feed-state'],
|
||||
});
|
||||
apply();
|
||||
document.addEventListener(LAYER_FINDER_CLEAR_EVENT, clearAll);
|
||||
});
|
||||
onBeforeUnmount(() => {
|
||||
observer?.disconnect();
|
||||
cancelAnimationFrame(frame);
|
||||
document.removeEventListener(LAYER_FINDER_CLEAR_EVENT, clearAll);
|
||||
});
|
||||
watch([query, show, category], apply);
|
||||
}
|
||||
|
||||
const searchBtn = () => document.getElementById('layer-finder-search-btn');
|
||||
async function toggleSearch() {
|
||||
searching.value = !searching.value;
|
||||
if (!searching.value) query.value = '';
|
||||
await nextTick();
|
||||
if (searching.value) document.getElementById('layer-finder-input')?.focus();
|
||||
}
|
||||
// Escape in the field closes the search and stays there: it must not also
|
||||
// fold the panel or leave the cockpit.
|
||||
async function closeSearch() {
|
||||
searching.value = false;
|
||||
query.value = '';
|
||||
await nextTick();
|
||||
searchBtn()?.focus();
|
||||
}
|
||||
|
||||
// The filter is a disclosure of two groups of toggle buttons. Opening it moves
|
||||
// focus to the chosen option; Escape, or a press outside, closes it and gives
|
||||
// focus back to its button.
|
||||
const filterEl = ref(null);
|
||||
const menuEl = ref(null);
|
||||
const triggerEl = ref(null);
|
||||
const options = () => [...(menuEl.value?.querySelectorAll('button') || [])];
|
||||
async function toggleFilter() {
|
||||
filtering.value = !filtering.value;
|
||||
if (!filtering.value) return;
|
||||
await nextTick();
|
||||
const menu = menuEl.value;
|
||||
if (!menu) return;
|
||||
// Keep the menu inside the panel, which clips what leaves it.
|
||||
const panel = menu.closest('.ui-panel, [data-panel-id]');
|
||||
const room = panel
|
||||
? panel.getBoundingClientRect().bottom - menu.getBoundingClientRect().top - 8
|
||||
: 0;
|
||||
menu.style.maxHeight = room > 80 ? `${Math.floor(room)}px` : '';
|
||||
(menu.querySelector('[aria-pressed="true"]') || options()[0])?.focus();
|
||||
}
|
||||
function closeFilter({ refocus = false } = {}) {
|
||||
filtering.value = false;
|
||||
if (refocus) triggerEl.value?.focus();
|
||||
}
|
||||
function onMenuKey(event) {
|
||||
if (event.key === 'Escape') {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
closeFilter({ refocus: true });
|
||||
return;
|
||||
}
|
||||
const step = { ArrowDown: 1, ArrowUp: -1 }[event.key];
|
||||
const edge = { Home: 0, End: -1 }[event.key];
|
||||
if (step === undefined && edge === undefined) return;
|
||||
event.preventDefault();
|
||||
const all = options();
|
||||
const at = all.indexOf(document.activeElement);
|
||||
const next =
|
||||
step !== undefined
|
||||
? all[(at + step + all.length) % all.length]
|
||||
: all.at(edge);
|
||||
next?.focus();
|
||||
}
|
||||
function onOutside(e) {
|
||||
if (filtering.value && filterEl.value && !filterEl.value.contains(e.target))
|
||||
closeFilter();
|
||||
}
|
||||
function pickCategory(key) {
|
||||
category.value = category.value === key ? '' : key;
|
||||
}
|
||||
if (props.part === 'buttons') {
|
||||
onMounted(() => document.addEventListener('pointerdown', onOutside, true));
|
||||
onBeforeUnmount(() =>
|
||||
document.removeEventListener('pointerdown', onOutside, true),
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<template v-if="part === 'buttons'">
|
||||
<button id="layer-finder-search-btn" type="button" class="layer-finder__btn" :class="{ active: searching || query }" :aria-pressed="String(searching)" :aria-label="t('Search layers')" :title="t('Search layers')" @click="toggleSearch">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">search</span>
|
||||
</button>
|
||||
<span ref="filterEl" class="layer-finder__filter">
|
||||
<button ref="triggerEl" type="button" class="layer-finder__btn" :class="{ active: show !== 'all' || category }" :aria-expanded="String(filtering)" aria-controls="layer-finder-menu" :aria-label="t('Filter layers')" :title="t('Filter layers')" @click="toggleFilter">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">filter_list</span>
|
||||
</button>
|
||||
<span v-if="filtering" id="layer-finder-menu" ref="menuEl" class="layer-finder__menu" role="group" :aria-label="t('Filter layers')" @keydown="onMenuKey">
|
||||
<span role="group" :aria-label="t('Status')">
|
||||
<span class="layer-finder__menu-head" aria-hidden="true">{{ t('Status') }}</span>
|
||||
<button v-for="s in SHOWS" :key="s.id" type="button" :aria-pressed="String(show === s.id)" :class="{ active: show === s.id }" @click="show = s.id">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">{{ show === s.id ? 'radio_button_checked' : 'radio_button_unchecked' }}</span>{{ t(s.label) }}
|
||||
</button>
|
||||
</span>
|
||||
<span v-if="categories.length" role="group" :aria-label="t('Category')">
|
||||
<span class="layer-finder__menu-head" aria-hidden="true">{{ t('Category') }}</span>
|
||||
<button v-for="c in categories" :key="c.key" type="button" :aria-pressed="String(category === c.key)" :class="{ active: category === c.key }" @click="pickCategory(c.key)">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">{{ category === c.key ? 'radio_button_checked' : 'radio_button_unchecked' }}</span>{{ c.label }}
|
||||
</button>
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
</template>
|
||||
<div v-else-if="searching || narrowed" class="layer-finder__bar">
|
||||
<label v-if="searching" class="layer-finder__field">
|
||||
<span class="material-symbols-outlined" aria-hidden="true">search</span>
|
||||
<input id="layer-finder-input" v-model="query" type="search" :placeholder="t('Search layers…')" :aria-label="t('Search layers')" @keydown.esc.stop.prevent="closeSearch" />
|
||||
</label>
|
||||
<button v-if="show !== 'all'" type="button" class="layer-finder__chip" @click="show = 'all'">
|
||||
{{ show === 'on' ? t('On') : t('Off') }}<span class="material-symbols-outlined" aria-hidden="true">close</span>
|
||||
</button>
|
||||
<button v-if="category" type="button" class="layer-finder__chip" @click="category = ''">
|
||||
{{ categoryLabel }}<span class="material-symbols-outlined" aria-hidden="true">close</span>
|
||||
</button>
|
||||
<p v-if="narrowed && shown === 0" class="layer-finder__empty" role="status">{{ t('No layers match') }}</p>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,124 @@
|
||||
<script setup>
|
||||
import { onBeforeUnmount, onMounted, ref } from 'vue';
|
||||
import { t } from '../../../i18n/index.js';
|
||||
|
||||
// A slim index beside the Data Layers list: one tick per group (Movement,
|
||||
// Cameras, Infrastructure…). Hovering a tick names its group, clicking it
|
||||
// scrolls the list there, and the tick for the group in view is lit. It reads
|
||||
// the list's group headings, which LayerRows renders, so it follows whatever
|
||||
// groups the layers bring.
|
||||
const sections = ref([]);
|
||||
const current = ref(0);
|
||||
let list = null;
|
||||
let observer = null;
|
||||
let resize = null;
|
||||
|
||||
function headings() {
|
||||
return list ? [...list.querySelectorAll('.data-layer-group-heading:not(.is-filtered)')] : [];
|
||||
}
|
||||
function readSections() {
|
||||
const next = headings().map((h, i) => ({ i, label: h.textContent.trim() }));
|
||||
// Live counts repaint the rows all the time; keep the ticks unless the
|
||||
// groups themselves changed.
|
||||
const same =
|
||||
next.length === sections.value.length &&
|
||||
next.every((s, i) => s.label === sections.value[i].label);
|
||||
if (!same) sections.value = next;
|
||||
syncCurrent();
|
||||
}
|
||||
// Only headings matter: a heading added, removed, renamed (a language change)
|
||||
// or filtered out. Rows' counts and states change many times a second.
|
||||
const isHeading = (node) =>
|
||||
node?.classList?.contains('data-layer-group-heading') ||
|
||||
node?.parentElement?.classList?.contains('data-layer-group-heading');
|
||||
let frame = 0;
|
||||
function onMutations(mutations) {
|
||||
if (frame) return;
|
||||
const relevant = mutations.some(
|
||||
(m) =>
|
||||
(m.type === 'childList' && m.target === list) || isHeading(m.target),
|
||||
);
|
||||
if (!relevant) return;
|
||||
frame = requestAnimationFrame(() => {
|
||||
frame = 0;
|
||||
readSections();
|
||||
});
|
||||
}
|
||||
function syncCurrent() {
|
||||
if (!list) return;
|
||||
const top = list.getBoundingClientRect().top + 8;
|
||||
let index = 0;
|
||||
headings().forEach((h, i) => {
|
||||
if (h.getBoundingClientRect().top <= top + 4) index = i;
|
||||
});
|
||||
// At the very end of the list the last group is the one in view.
|
||||
const scrolls = list.clientHeight > 0 && list.scrollHeight > list.clientHeight + 2;
|
||||
if (scrolls && list.scrollTop + list.clientHeight >= list.scrollHeight - 2) index = sections.value.length - 1;
|
||||
current.value = Math.max(0, index);
|
||||
}
|
||||
// The name of the tick being pointed at or focused. It is drawn on the page
|
||||
// itself, just outside the panel's edge: the panel clips what leaves it, and a
|
||||
// label inside would cover the rows.
|
||||
const tip = ref(null);
|
||||
function showTip(event, section) {
|
||||
const box = event.currentTarget.getBoundingClientRect();
|
||||
// Beside the tick on whichever side has room: the stack sits on the right
|
||||
// in a right-to-left language.
|
||||
const before = window.innerWidth - box.right < 180;
|
||||
tip.value = {
|
||||
label: section.label,
|
||||
before,
|
||||
left: `${Math.round(before ? box.left - 10 : box.right + 10)}px`,
|
||||
top: `${Math.round(box.top + box.height / 2)}px`,
|
||||
};
|
||||
}
|
||||
const hideTip = () => {
|
||||
tip.value = null;
|
||||
};
|
||||
function jump(i) {
|
||||
const h = headings()[i];
|
||||
if (!h || !list) return;
|
||||
list.scrollTo({ top: h.offsetTop - list.offsetTop - 4, behavior: 'smooth' });
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
list = document.getElementById('data-toggles');
|
||||
if (!list) return;
|
||||
observer = new MutationObserver(onMutations);
|
||||
observer.observe(list, { childList: true, subtree: true, characterData: true, attributes: true, attributeFilter: ['class'] });
|
||||
list.addEventListener('scroll', syncCurrent, { passive: true });
|
||||
// The list is hidden while the panel is shut; read again when it opens.
|
||||
resize = new ResizeObserver(syncCurrent);
|
||||
resize.observe(list);
|
||||
readSections();
|
||||
});
|
||||
onBeforeUnmount(() => {
|
||||
observer?.disconnect();
|
||||
resize?.disconnect();
|
||||
cancelAnimationFrame(frame);
|
||||
list?.removeEventListener('scroll', syncCurrent);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<nav v-if="sections.length > 1" class="layer-section-index" :aria-label="t('Layer groups')">
|
||||
<button
|
||||
v-for="section in sections"
|
||||
:key="section.i"
|
||||
type="button"
|
||||
class="layer-section-index__tick"
|
||||
:class="{ 'is-current': section.i === current }"
|
||||
:aria-label="t('Jump to {name}', { name: section.label })"
|
||||
:aria-current="section.i === current ? 'true' : undefined"
|
||||
@click="jump(section.i)"
|
||||
@mouseenter="showTip($event, section)"
|
||||
@mouseleave="hideTip"
|
||||
@focus="showTip($event, section)"
|
||||
@blur="hideTip"
|
||||
></button>
|
||||
<Teleport to="body">
|
||||
<span v-if="tip" class="layer-section-index__label"
|
||||
:class="{ 'layer-section-index__label--before': tip.before }" :style="{ left: tip.left, top: tip.top }" aria-hidden="true">{{ tip.label }}</span>
|
||||
</Teleport>
|
||||
</nav>
|
||||
</template>
|
||||
@@ -0,0 +1,103 @@
|
||||
<script setup>
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { msg, t } from '../../../i18n/index.js';
|
||||
import UiButton from '../../kit/UiButton.vue';
|
||||
import { useDisplayStore } from '../../stores/display.js';
|
||||
|
||||
// The visual presets and map source at the top of the Visual panel. The same
|
||||
// choices the command dock's tray offers, through the same Display store
|
||||
// actions, so either surface stays in step with the other.
|
||||
const display = useDisplayStore();
|
||||
const { style, mapSource, mapSourceControls } = storeToRefs(display);
|
||||
|
||||
const STYLES = [
|
||||
{
|
||||
name: 'normal',
|
||||
icon: '◯',
|
||||
label: msg('Normal'),
|
||||
key: '1',
|
||||
title: msg('Show the globe without a visual filter.'),
|
||||
},
|
||||
{
|
||||
name: 'retro',
|
||||
icon: '▦',
|
||||
label: msg('CRT'),
|
||||
key: '2',
|
||||
title: msg('Emulate a green phosphor CRT with scanlines and screen curvature.'),
|
||||
},
|
||||
{
|
||||
name: 'surveillance',
|
||||
icon: '🌙',
|
||||
label: msg('NVG'),
|
||||
key: '3',
|
||||
title: msg('Simulate night-vision goggles with green intensification and a tube vignette.'),
|
||||
},
|
||||
{
|
||||
name: 'thermal',
|
||||
icon: '🌡️',
|
||||
label: msg('FLIR'),
|
||||
key: '4',
|
||||
title: msg('Simulate FLIR-style thermal contrast. Turn up Ironbow for color.'),
|
||||
},
|
||||
{
|
||||
name: 'anime',
|
||||
icon: '✦',
|
||||
label: msg('Anime'),
|
||||
key: '5',
|
||||
title: msg('Apply bright cel-shaded color and illustrated outlines.'),
|
||||
},
|
||||
{
|
||||
name: 'noir',
|
||||
icon: '◐',
|
||||
label: msg('Noir'),
|
||||
key: '6',
|
||||
title: msg('Apply high-contrast monochrome film-noir grading.'),
|
||||
},
|
||||
];
|
||||
|
||||
function selectMapSource(chip) {
|
||||
if (!chip.available) return;
|
||||
void mapSourceControls.value?.select(chip.id).catch(() => {});
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="visual-presets" :aria-label="t('VISUAL PRESETS')">
|
||||
<p class="visual-presets__heading">{{ t('Look') }}</p>
|
||||
<div class="visual-presets__grid">
|
||||
<UiButton
|
||||
v-for="preset in STYLES"
|
||||
:key="preset.name"
|
||||
class="visual-presets__style"
|
||||
:pressed="(style?.name ?? 'normal') === preset.name"
|
||||
pressed-class="active"
|
||||
:data-style="preset.name"
|
||||
:title="t(preset.title)"
|
||||
@click="display.act('setStyle', preset.name)"
|
||||
>
|
||||
<span class="visual-presets__icon" aria-hidden="true">{{ preset.icon }}</span>
|
||||
<span class="visual-presets__label">{{ t(preset.label) }}</span>
|
||||
<kbd class="visual-presets__key">{{ preset.key }}</kbd>
|
||||
</UiButton>
|
||||
</div>
|
||||
<div class="visual-presets__heading visual-presets__heading--row">
|
||||
<span>{{ t('MAP SOURCE') }}</span>
|
||||
<span class="visual-presets__status" :class="{ warn: !!mapSource?.status.warn }">{{ mapSource ? mapSource.status.text : '3D' }}</span>
|
||||
</div>
|
||||
<div class="visual-presets__chips" role="group" :aria-label="t('Map source')">
|
||||
<UiButton
|
||||
v-for="chip in mapSource?.chips"
|
||||
:key="chip.id"
|
||||
class="visual-presets__chip"
|
||||
:class="{ unavailable: !chip.available }"
|
||||
:pressed="Boolean(chip.active)"
|
||||
pressed-class="active"
|
||||
:title="chip.title"
|
||||
:aria-disabled="String(!chip.available)"
|
||||
:aria-label="chip.ariaLabel"
|
||||
@click="selectMapSource(chip)"
|
||||
>{{ chip.label }}<small v-if="chip.requirement">{{ chip.requirement }}</small></UiButton
|
||||
>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -19,6 +19,8 @@ function mount(t) {
|
||||
// The store outlives the view; dispose it with its clock subscription.
|
||||
useWorldTimeStore(pinia).$dispose();
|
||||
worldClock.goLive();
|
||||
// The clock keeps its rate; the next test starts at real time.
|
||||
worldClock.setRate(1);
|
||||
});
|
||||
return () => document.getElementById('world-timeline');
|
||||
}
|
||||
@@ -79,16 +81,16 @@ test('the timeline hides while no layer with time to show is on', async (t) => {
|
||||
const bar = mount(t);
|
||||
const at = Date.UTC(2026, 9, 30, 6, 15, 42);
|
||||
await nextTick();
|
||||
assert.equal(bar(), null, 'live, nothing to play');
|
||||
assert.equal(bar() === null, true, 'live, nothing to play');
|
||||
worldClock.seek(at);
|
||||
await nextTick();
|
||||
assert.equal(bar(), null, 'away from live, but nothing to play');
|
||||
assert.equal(bar() === null, true, 'away from live, but nothing to play');
|
||||
const remove = supportingLayer(t, at);
|
||||
await nextTick();
|
||||
assert.ok(bar());
|
||||
remove();
|
||||
await nextTick();
|
||||
assert.equal(bar(), null, 'the layer went off');
|
||||
assert.equal(bar() === null, true, 'the layer went off');
|
||||
});
|
||||
|
||||
test('the track runs over the time the layers show, to now, and scrubs', async (t) => {
|
||||
@@ -465,7 +467,7 @@ test('play held for a layer to load shows a spinner once the hold lasts', async
|
||||
// A clock tick (a quarter second) tells of the hold; the spinner waits on.
|
||||
await new Promise((resolve) => setTimeout(resolve, 250));
|
||||
await nextTick();
|
||||
assert.equal(bubble().querySelector('.world-timeline-spinner'), null, 'not for a quick frame');
|
||||
assert.equal(bubble().querySelector('.world-timeline-spinner') === null, true, 'not for a quick frame');
|
||||
// The clock tells of the hold on its next tick, and the bar shows it after.
|
||||
const until = async (shown) => {
|
||||
for (let waited = 0; waited < 3_000; waited += 50) {
|
||||
@@ -581,3 +583,194 @@ test('a pinch measures from where the fingers are, and a lifted finger ends it',
|
||||
assert.ok(Math.abs(length() - zoomedTo) < 1_000);
|
||||
on(input, 'pointercancel', 100, 1);
|
||||
});
|
||||
|
||||
test('a tick shows its label on hover, and a tap by it goes to its mark', async (t) => {
|
||||
const bar = mount(t);
|
||||
const now = Date.now();
|
||||
const start = now - 10 * 86_400_000;
|
||||
// Ticks a fifth and seven tenths along a 1000 px track.
|
||||
const launch = start + (now - start) * 0.2;
|
||||
const quake = start + (now - start) * 0.7;
|
||||
const release = worldClock.hold('test-launches');
|
||||
const unregister = worldClock.register({
|
||||
id: 'test-launches',
|
||||
coverage: () => ({
|
||||
start,
|
||||
end: now,
|
||||
marks: [
|
||||
start,
|
||||
{ time: launch, label: 'GAUNTLET PAYLOAD', id: 'l1', kind: 'launch' },
|
||||
{ time: quake, label: 'M6.4 · Fiji', kind: 'earthquake' },
|
||||
],
|
||||
}),
|
||||
});
|
||||
t.after(() => {
|
||||
unregister();
|
||||
release();
|
||||
});
|
||||
await nextTick();
|
||||
const track = bar().querySelector('.world-timeline-track');
|
||||
const input = bar().querySelector('input[type=range]');
|
||||
Object.defineProperty(track, 'clientWidth', { value: 1_000 });
|
||||
track.getBoundingClientRect = () => ({ left: 0, width: 1_000, top: 0, height: 24 });
|
||||
const press = (type, clientX, pointerId = 1) =>
|
||||
track.dispatchEvent(new PointerEvent(type, { bubbles: true, clientX, pointerId }));
|
||||
const tip = () => bar().querySelector('.world-timeline-mark-label');
|
||||
assert.equal(bar().querySelectorAll('.world-timeline-tick').length, 3, 'ticks stay ticks');
|
||||
assert.equal(tip()?.textContent ?? null, null);
|
||||
|
||||
// Hovering within 6 px of a tick shows its label, in place of the track's hint.
|
||||
press('pointermove', 205);
|
||||
await nextTick();
|
||||
assert.equal(tip()?.textContent, 'GAUNTLET PAYLOAD');
|
||||
assert.equal(track.hasAttribute('title'), false);
|
||||
press('pointermove', 698);
|
||||
await nextTick();
|
||||
assert.equal(tip()?.textContent, 'M6.4 · Fiji');
|
||||
// Further off, or on a tick with no label, nothing shows.
|
||||
press('pointermove', 690);
|
||||
await nextTick();
|
||||
assert.equal(tip()?.textContent ?? null, null);
|
||||
assert.equal(track.hasAttribute('title'), true);
|
||||
press('pointermove', 2);
|
||||
await nextTick();
|
||||
assert.equal(tip()?.textContent ?? null, null, 'an unlabelled mark has no label');
|
||||
press('pointermove', 205);
|
||||
track.dispatchEvent(new PointerEvent('pointerleave', { clientX: 1_100, pointerId: 1 }));
|
||||
await nextTick();
|
||||
assert.equal(tip()?.textContent ?? null, null, 'leaving the track hides it');
|
||||
|
||||
// A tap by a tick goes to its mark exactly; elsewhere, to the time there.
|
||||
press('pointerdown', 704);
|
||||
press('pointerup', 704);
|
||||
await nextTick();
|
||||
assert.equal(worldClock.now(), quake);
|
||||
assert.match(input.getAttribute('aria-valuetext'), / · M6\.4 · Fiji$/);
|
||||
press('pointerdown', 500);
|
||||
press('pointerup', 500);
|
||||
await nextTick();
|
||||
const middle = start + (now - start) / 2;
|
||||
assert.ok(Math.abs(worldClock.now() - middle) < 60_000, 'went to the middle');
|
||||
assert.notEqual(worldClock.now(), quake);
|
||||
assert.match(input.getAttribute('aria-valuetext'), /UTC$/, 'off a mark, the time alone');
|
||||
// A drag from a tick still scrubs.
|
||||
press('pointerdown', 200);
|
||||
press('pointermove', 300);
|
||||
press('pointerup', 300);
|
||||
await nextTick();
|
||||
assert.ok(Math.abs(worldClock.now() - (start + (now - start) * 0.3)) < 60_000);
|
||||
|
||||
// The arrows go to the marks and tell their labels; focused, the label shows.
|
||||
input.dispatchEvent(new Event('focus'));
|
||||
input.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowLeft' }));
|
||||
await nextTick();
|
||||
assert.equal(worldClock.now(), launch);
|
||||
assert.match(input.getAttribute('aria-valuetext'), / · GAUNTLET PAYLOAD$/);
|
||||
assert.equal(tip()?.textContent, 'GAUNTLET PAYLOAD');
|
||||
input.dispatchEvent(new Event('blur'));
|
||||
await nextTick();
|
||||
assert.equal(tip()?.textContent ?? null, null);
|
||||
});
|
||||
|
||||
test('the pointer shows the nearer of two ticks within 6 px, and a zoom or a pan clears it', async (t) => {
|
||||
const bar = mount(t);
|
||||
const now = Date.now();
|
||||
const start = now - 10 * 86_400_000;
|
||||
// Two ticks 8 px apart on a 1000 px track, at 200 and 208 px.
|
||||
const first = start + (now - start) * 0.2;
|
||||
const second = start + (now - start) * 0.208;
|
||||
const release = worldClock.hold('test-launches');
|
||||
const unregister = worldClock.register({
|
||||
id: 'test-launches',
|
||||
coverage: () => ({
|
||||
start,
|
||||
end: now,
|
||||
marks: [
|
||||
{ time: first, label: 'FIRST', kind: 'launch' },
|
||||
{ time: second, label: 'SECOND', kind: 'launch' },
|
||||
],
|
||||
}),
|
||||
});
|
||||
t.after(() => {
|
||||
unregister();
|
||||
release();
|
||||
});
|
||||
await nextTick();
|
||||
const track = bar().querySelector('.world-timeline-track');
|
||||
Object.defineProperty(track, 'clientWidth', { value: 1_000 });
|
||||
track.getBoundingClientRect = () => ({ left: 0, width: 1_000, top: 0, height: 24 });
|
||||
const pointer = (type, clientX) =>
|
||||
track.dispatchEvent(new PointerEvent(type, { bubbles: true, clientX, pointerId: 1 }));
|
||||
const tip = () => bar().querySelector('.world-timeline-mark-label');
|
||||
// Where the first tick sits now, in px along the track.
|
||||
const firstAt = () =>
|
||||
Number.parseFloat(bar().querySelector('.world-timeline-tick').style.left) * 10;
|
||||
// The handle between them, so a zoom keeps both in view.
|
||||
worldClock.seek((first + second) / 2);
|
||||
await nextTick();
|
||||
pointer('pointermove', 203);
|
||||
await nextTick();
|
||||
assert.equal(tip()?.textContent, 'FIRST');
|
||||
pointer('pointermove', 205);
|
||||
await nextTick();
|
||||
assert.equal(tip()?.textContent, 'SECOND', 'the nearer of the two');
|
||||
|
||||
// A wheel zoom moves the ticks from under the pointer: the label goes.
|
||||
track.dispatchEvent(new WheelEvent('wheel', { deltaY: -200, cancelable: true }));
|
||||
await nextTick();
|
||||
assert.equal(track.classList.contains('is-zoomed'), true);
|
||||
assert.equal(tip()?.textContent ?? null, null, 'a zoom clears the label');
|
||||
// So does a pan, by wheel or by drag.
|
||||
pointer('pointermove', firstAt());
|
||||
await nextTick();
|
||||
assert.equal(tip()?.textContent, 'FIRST');
|
||||
track.dispatchEvent(
|
||||
new WheelEvent('wheel', { deltaY: 40, shiftKey: true, cancelable: true }),
|
||||
);
|
||||
await nextTick();
|
||||
assert.equal(tip()?.textContent ?? null, null, 'a pan clears the label');
|
||||
|
||||
// A tap between them goes to the nearer mark.
|
||||
track.dispatchEvent(new MouseEvent('dblclick', { bubbles: true }));
|
||||
await nextTick();
|
||||
assert.equal(track.classList.contains('is-zoomed'), false);
|
||||
pointer('pointerdown', 205);
|
||||
pointer('pointerup', 205);
|
||||
await nextTick();
|
||||
assert.equal(worldClock.now(), second, 'a tap goes to the nearer mark');
|
||||
});
|
||||
|
||||
test('the speed shown follows the world clock, and Play runs at its rate', async (t) => {
|
||||
const bar = mount(t);
|
||||
const now = Date.now();
|
||||
const release = worldClock.hold('test-launches');
|
||||
const unregister = worldClock.register({
|
||||
id: 'test-launches',
|
||||
coverage: () => ({ start: now - 10 * 86_400_000, end: now - 86_400_000 }),
|
||||
});
|
||||
t.after(() => {
|
||||
unregister();
|
||||
release();
|
||||
});
|
||||
await nextTick();
|
||||
const select = () => bar().querySelector('select.world-timeline-speed');
|
||||
assert.equal(select().value, 'real');
|
||||
// A host sets the rate: the selector shows it.
|
||||
worldClock.setRate(86_400);
|
||||
await nextTick();
|
||||
assert.equal(select().value, 'day');
|
||||
// A rate not offered shows as the nearest offered speed, and Play keeps it.
|
||||
worldClock.setRate(5_000);
|
||||
await nextTick();
|
||||
assert.equal(select().value, 'hour');
|
||||
bar().querySelector('.world-timeline-play').click();
|
||||
assert.equal(worldClock.isPlaying(), true);
|
||||
assert.equal(worldClock.getRate(), 5_000, 'Play runs at the clock\'s own rate');
|
||||
worldClock.pause();
|
||||
// Chosen on the selector while paused, the clock takes it at once.
|
||||
select().value = 'week';
|
||||
select().dispatchEvent(new Event('change'));
|
||||
await nextTick();
|
||||
assert.equal(worldClock.getRate(), 604_800);
|
||||
assert.equal(select().value, 'week');
|
||||
});
|
||||
@@ -8,11 +8,12 @@ import UiIcon from '../../kit/UiIcon.vue';
|
||||
import UiSelect from '../../kit/UiSelect.js';
|
||||
|
||||
// The world timeline: play and pause and the speed on the left, a track
|
||||
// across the stretch the layers on can show (each launch or frame a tick)
|
||||
// with a handle to scrub and the time in a bubble over it, and the way back
|
||||
// to live on the right, lit while live. Scrolling or pinching the track
|
||||
// zooms it around the handle, dragging it moves along it, and a double-click
|
||||
// shows it all again. It shows
|
||||
// across the stretch the layers on can show (each mark, a launch or a strong
|
||||
// earthquake, a tick, its label shown over it on hover) with a handle to
|
||||
// scrub and the time in a bubble over it, and the way back to live on the
|
||||
// right, lit while live. Scrolling or pinching the track zooms it around the
|
||||
// handle, dragging it moves along it, a tap on or by a tick goes to its
|
||||
// mark's time exactly, and a double-click shows it all again. It shows
|
||||
// while a layer with a time of its own (weather, satellites, launches,
|
||||
// or one a host follows) is on with time to show; with only live feeds such
|
||||
// as flights on, the bar stays hidden.
|
||||
@@ -53,6 +54,8 @@ const ZOOM_STEP = 1.5;
|
||||
const WHEEL_ZOOM = 0.0025;
|
||||
// Two presses this close are a double-click.
|
||||
const DOUBLE_PRESS_MS = 500;
|
||||
// A tap or a hover this near a tick, in pixels, is on its mark.
|
||||
const MARK_HIT_PX = 6;
|
||||
|
||||
const readout = computed(() =>
|
||||
Number.isFinite(time.value.timeMs)
|
||||
@@ -109,8 +112,10 @@ const view = computed(() => {
|
||||
});
|
||||
const zoomed = computed(() => zoom.value !== null);
|
||||
const viewLength = () => view.value.end - view.value.start;
|
||||
// Show `length` of the span ending at `viewEnd`, held to the span.
|
||||
// Show `length` of the span ending at `viewEnd`, held to the span. A zoom
|
||||
// or a pan moves the ticks from under the pointer, so its label goes.
|
||||
function showView(length, viewEnd) {
|
||||
hovered.value = null;
|
||||
const { start, end } = span.value;
|
||||
if (length >= end - start) {
|
||||
showWhole();
|
||||
@@ -138,6 +143,7 @@ const follow = (ms) => {
|
||||
};
|
||||
const offView = (ms) => ms < view.value.start || ms > view.value.end;
|
||||
const showWhole = () => {
|
||||
hovered.value = null;
|
||||
zoom.value = null;
|
||||
panned = false;
|
||||
};
|
||||
@@ -212,6 +218,7 @@ let movedTime = false;
|
||||
const onPointerDown = (event) => {
|
||||
// Only the main button: a right-click is for the menu.
|
||||
if (event.button > 0) return;
|
||||
hovered.value = null;
|
||||
const onHandle = event.target instanceof HTMLInputElement;
|
||||
pointers.set(event.pointerId, { x: event.clientX, onHandle });
|
||||
if (pointers.size === 1) {
|
||||
@@ -241,6 +248,10 @@ const onPointerDown = (event) => {
|
||||
gesture = { kind: 'press', x: event.clientX, end: view.value.end };
|
||||
};
|
||||
const onPointerMove = (event) => {
|
||||
// A pointer hovering, none pressed, shows the label of the tick under it.
|
||||
hovered.value = pointers.size
|
||||
? null
|
||||
: (markNear(event.clientX, event.currentTarget)?.time ?? null);
|
||||
const pointer = pointers.get(event.pointerId);
|
||||
if (!pointer) return;
|
||||
pointer.x = event.clientX;
|
||||
@@ -266,8 +277,14 @@ const onPointerMove = (event) => {
|
||||
};
|
||||
const onPointerUp = (event) => {
|
||||
if (!pointers.delete(event.pointerId)) return;
|
||||
// A tap on or by a tick goes to its mark exactly; elsewhere, to the time
|
||||
// under it.
|
||||
if (gesture?.kind === 'press' && event.type === 'pointerup')
|
||||
store.scrub(timeAt(event.clientX, event.currentTarget), viewLength());
|
||||
store.scrub(
|
||||
markNear(event.clientX, event.currentTarget)?.time ??
|
||||
timeAt(event.clientX, event.currentTarget),
|
||||
viewLength(),
|
||||
);
|
||||
// A finger lifted from a pinch ends it; the other one moves nothing.
|
||||
gesture = null;
|
||||
};
|
||||
@@ -276,11 +293,66 @@ const place = (ms) => {
|
||||
const { start, end } = view.value;
|
||||
return end > start ? ((ms - start) / (end - start)) * 100 : 100;
|
||||
};
|
||||
// The labels of the marks at each time marked; a time may have none.
|
||||
const markLabels = computed(() => {
|
||||
const labels = new Map();
|
||||
for (const mark of span.value?.markDetails ?? []) {
|
||||
if (!labels.has(mark.time)) labels.set(mark.time, []);
|
||||
if (mark.label) labels.get(mark.time).push(mark.label);
|
||||
}
|
||||
return labels;
|
||||
});
|
||||
// A tick for each time marked in view: where it sits, as a share of the
|
||||
// track, and its marks' labels.
|
||||
const ticks = computed(() => {
|
||||
const { start, end } = view.value;
|
||||
return span.value.marks
|
||||
.filter((mark) => mark >= start && mark <= end)
|
||||
.map((mark) => `${place(mark)}%`);
|
||||
.map((mark) => ({
|
||||
time: mark,
|
||||
share: place(mark) / 100,
|
||||
labels: markLabels.value.get(mark) ?? [],
|
||||
}));
|
||||
});
|
||||
// The tick nearest `clientX` within MARK_HIT_PX of it, or null.
|
||||
function markNear(clientX, track) {
|
||||
if (!view.value) return null;
|
||||
const { left, width } = track.getBoundingClientRect();
|
||||
if (!(width > 0)) return null;
|
||||
let near = null;
|
||||
let nearest = MARK_HIT_PX;
|
||||
for (const tick of ticks.value) {
|
||||
const off = Math.abs(left + tick.share * width - clientX);
|
||||
if (off <= nearest) {
|
||||
near = tick;
|
||||
nearest = off;
|
||||
}
|
||||
}
|
||||
return near;
|
||||
}
|
||||
// The time of the tick the pointer hovers, and whether the handle has focus.
|
||||
const hovered = shallowRef(null);
|
||||
const focused = shallowRef(false);
|
||||
// The labels shown over the track: the hovered tick's, or with the handle
|
||||
// focused and paused on a mark (an arrow key or a tap took it there), that
|
||||
// mark's. Nothing for a mark with no label.
|
||||
const markTip = computed(() => {
|
||||
if (!view.value) return null;
|
||||
const onMark = !time.value.live && focused.value ? time.value.timeMs : null;
|
||||
const over = ticks.value.find((each) => each.time === hovered.value);
|
||||
const tick = over ?? ticks.value.find((each) => each.time === onMark);
|
||||
return tick?.labels.length
|
||||
? { share: tick.share, text: tick.labels.join('\n'), hover: Boolean(over) }
|
||||
: null;
|
||||
});
|
||||
// The time as the handle tells it, with the labels of the mark it is on.
|
||||
const valueText = computed(() => {
|
||||
const labels = time.value.live
|
||||
? null
|
||||
: markLabels.value.get(time.value.timeMs);
|
||||
return labels?.length
|
||||
? `${readout.value} · ${labels.join('; ')}`
|
||||
: readout.value;
|
||||
});
|
||||
const shown = computed(() =>
|
||||
Math.min(view.value.end, Math.max(view.value.start, at.value)),
|
||||
@@ -294,10 +366,11 @@ const scrub = (event) => {
|
||||
}
|
||||
store.scrub(Number(event.target.value), viewLength());
|
||||
};
|
||||
// Arrows go to the previous or next mark (a launch, a frame), or a step along
|
||||
// the track as shown; Page keys take a tenth of it; Home and End go to the
|
||||
// ends of all of it. Plus and minus zoom, and zero shows it all; with a
|
||||
// modifier they are the browser's own zoom.
|
||||
// Arrows go to the previous or next mark (a launch, a strong earthquake),
|
||||
// whose label the handle then tells with the time, or a step along the track
|
||||
// as shown where there is none; Page keys take a tenth
|
||||
// of it; Home and End go to the ends of all of it. Plus and minus zoom, and
|
||||
// zero shows it all; with a modifier they are the browser's own zoom.
|
||||
const ZOOM_KEYS = ['+', '=', '-', '0'];
|
||||
const onKey = (event) => {
|
||||
if (ZOOM_KEYS.includes(event.key)) {
|
||||
@@ -331,17 +404,18 @@ const onKey = (event) => {
|
||||
><UiButton class="world-timeline-play" :label="time.playing ? t('Pause') : t('Play')" @click="store.togglePlay()"
|
||||
><UiIcon :name="time.playing ? 'pause' : 'play_arrow'" :size="20" /></UiButton
|
||||
><UiSelect class="gev-field gev-field--compact world-timeline-speed" :aria-label="t('Play speed')" :title="t('Play speed')" :options="speeds" :model-value="speed" @update:model-value="store.setSpeed($event)"
|
||||
/><div class="world-timeline-track" :class="{ 'is-zoomed': zoomed }" :title="t('Scroll or pinch to zoom, drag to move along · double-click to see it all')" @wheel="onWheel" @dblclick="showAll" @pointerdown="onPointerDown" @pointermove="onPointerMove" @pointerup="onPointerUp" @pointercancel="onPointerUp"
|
||||
/><div class="world-timeline-track" :class="{ 'is-zoomed': zoomed }" :title="markTip?.hover ? undefined : t('Scroll or pinch to zoom, drag to move along · double-click to see it all')" @wheel="onWheel" @dblclick="showAll" @pointerdown="onPointerDown" @pointermove="onPointerMove" @pointerup="onPointerUp" @pointercancel="onPointerUp" @pointerleave="hovered = null"
|
||||
><time class="world-timeline-time" :class="{ 'is-waiting': waiting }" :style="{ '--at': place(shown) / 100 }" :datetime="new Date(time.timeMs).toISOString()" aria-live="off"
|
||||
><span v-if="waiting" class="world-timeline-spinner" aria-hidden="true"></span>{{ bubble }}</time
|
||||
><span v-for="(left, index) in ticks" :key="index" class="world-timeline-tick" :style="{ left }" aria-hidden="true"></span
|
||||
><span v-if="markTip" class="world-timeline-mark-label" :style="{ '--at': markTip.share }" aria-hidden="true">{{ markTip.text }}</span
|
||||
><span v-for="tick in ticks" :key="tick.time" class="world-timeline-tick" :style="{ left: `${tick.share * 100}%` }" aria-hidden="true"></span
|
||||
><span class="world-timeline-fill" :style="{ width: `${place(shown)}%` }" aria-hidden="true"></span
|
||||
><input
|
||||
class="world-timeline-scrub"
|
||||
:class="{ 'is-off-view': handleOff }"
|
||||
type="range"
|
||||
:aria-label="t('World time')"
|
||||
:aria-valuetext="readout"
|
||||
:aria-valuetext="valueText"
|
||||
:min="view.start"
|
||||
:max="view.end"
|
||||
step="any"
|
||||
@@ -349,6 +423,8 @@ const onKey = (event) => {
|
||||
@input="scrub"
|
||||
aria-keyshortcuts="+ - 0"
|
||||
@keydown="onKey"
|
||||
@focus="focused = true"
|
||||
@blur="focused = false"
|
||||
/></div
|
||||
><UiButton class="world-timeline-live" :label="time.live ? t('Live') : t('Back to live')" :pressed="time.live" pressed-class="is-live" :disabled="time.live" @click="store.goLive()">{{ t('Live') }}</UiButton
|
||||
></div>
|
||||
|
||||
@@ -52,6 +52,13 @@ import { cyberVisualDefaultsForHudTransition } from '../hudLayouts.js';
|
||||
const DETECTION_ALLOCATION_STORAGE_KEY = 'gev:detection-allocation:v1';
|
||||
|
||||
/** Own visual preferences, detection overrides and display-control state. */
|
||||
/**
|
||||
* The faintest the Scope mask goes. Below about half, the view reads as if
|
||||
* Scope were off while labels still fade outside the keyhole and the HUD gets
|
||||
* no backplates, so the slider stops here.
|
||||
*/
|
||||
export const SCOPE_OPACITY_MIN_PCT = 50;
|
||||
|
||||
export class VisualSettings {
|
||||
async restoreShareState(state) {
|
||||
const { setScopeTerminusOverride, clampScopeTerminusPct } = this.services;
|
||||
@@ -72,6 +79,7 @@ export class VisualSettings {
|
||||
celestialRing,
|
||||
scopeEnabled,
|
||||
scopeFeatherPct,
|
||||
scopeOpacityPct,
|
||||
scopeTerminusPct,
|
||||
mapStack,
|
||||
panelState,
|
||||
@@ -139,7 +147,12 @@ export class VisualSettings {
|
||||
focus: false,
|
||||
});
|
||||
}
|
||||
this._setScope({ enabled: scopeEnabled, featherPct: scopeFeatherPct });
|
||||
this._setScope({
|
||||
enabled: scopeEnabled,
|
||||
featherPct: scopeFeatherPct,
|
||||
opacityPct:
|
||||
typeof scopeOpacityPct === 'number' ? scopeOpacityPct : undefined,
|
||||
});
|
||||
// null restores the altitude-adaptive ramp; a number pins the terminus
|
||||
// (clamped to the supported 94..100 band, same as the `sce` hash key).
|
||||
if (scopeTerminusPct === null) setScopeTerminusOverride(null);
|
||||
@@ -227,6 +240,7 @@ export class VisualSettings {
|
||||
// What the Scope and Celestial controls show; null until first set.
|
||||
this._scopeEnabledShown = null;
|
||||
this._scopeFeatherShown = null;
|
||||
this._scopeOpacityShown = null;
|
||||
this._celestialShown = null;
|
||||
this.activeStyle = 'normal';
|
||||
this._preCyberStyle = null;
|
||||
@@ -356,6 +370,20 @@ export class VisualSettings {
|
||||
this._syncShareState();
|
||||
}
|
||||
|
||||
/**
|
||||
* While Contacts holds detection, make the detection shown now the state
|
||||
* leaving Contacts puts back (and a share link carries): the user chose it,
|
||||
* as with Reset in Visual. Nothing changes outside Contacts.
|
||||
*/
|
||||
adoptDetectionAsRestore() {
|
||||
if (!this._contactsDetectionRestore) return;
|
||||
const state = this.getDetectionState();
|
||||
this._contactsDetectionRestore = {
|
||||
mode: state.detectionMode,
|
||||
densityPct: state.densityPct,
|
||||
};
|
||||
}
|
||||
|
||||
_setCockpitVision(mode, active, { revealParameters = false } = {}) {
|
||||
const next = active ? normalizeCockpitVisionMode(mode) : 'optical';
|
||||
if (!this.stages) return;
|
||||
@@ -487,6 +515,7 @@ export class VisualSettings {
|
||||
scope: {
|
||||
enabled: this._scopeEnabledShown,
|
||||
featherPct: this._scopeFeatherShown,
|
||||
opacityPct: this._scopeOpacityShown ?? 100,
|
||||
},
|
||||
celestial: this._celestialShown,
|
||||
};
|
||||
@@ -496,7 +525,15 @@ export class VisualSettings {
|
||||
* Apply the Scope mask and show it on its controls; a field that is not
|
||||
* given stays as it is. `apply: false` only shows the mask's state.
|
||||
*/
|
||||
_setScope({ enabled, featherPct } = {}, { apply = true } = {}) {
|
||||
_setScope({ enabled, featherPct, opacityPct } = {}, { apply = true } = {}) {
|
||||
if (Number.isFinite(opacityPct)) {
|
||||
const pct = Math.max(
|
||||
SCOPE_OPACITY_MIN_PCT,
|
||||
Math.min(100, Math.round(opacityPct)),
|
||||
);
|
||||
if (apply) this.services.setScopeMaskOpacity?.(pct / 100);
|
||||
this._scopeOpacityShown = pct;
|
||||
}
|
||||
if (typeof enabled === 'boolean') {
|
||||
if (apply) this.services.setScopeMaskEnabled(enabled);
|
||||
this._scopeEnabledShown = enabled;
|
||||
@@ -827,7 +864,11 @@ export class VisualSettings {
|
||||
if (det.mode) this._setDetectionMode(String(det.mode).toUpperCase());
|
||||
}
|
||||
|
||||
_applyGlobalPostDefaults() {
|
||||
/**
|
||||
* @param {{keepHudVariant?: boolean}} [options] `keepHudVariant` leaves the
|
||||
* HUD layout to the style, as choosing a style does (Visual's reset).
|
||||
*/
|
||||
_applyGlobalPostDefaults({ keepHudVariant = false } = {}) {
|
||||
const defaults = GLOBAL_POST_DEFAULTS;
|
||||
if (typeof defaults.bloom?.intensity === 'number') {
|
||||
this._setBloomIntensity(clampBloomIntensity(defaults.bloom.intensity), {
|
||||
@@ -846,7 +887,7 @@ export class VisualSettings {
|
||||
this._setSharpenEnabled(defaults.sharpen.enabled);
|
||||
}
|
||||
|
||||
if (defaults.hudVariant) {
|
||||
if (defaults.hudVariant && !keepHudVariant) {
|
||||
this._setHudVariant(defaults.hudVariant);
|
||||
}
|
||||
if (typeof defaults.hudVisible === 'boolean') {
|
||||
@@ -891,6 +932,7 @@ export class VisualSettings {
|
||||
getDetectionTuning,
|
||||
isScopeMaskEnabled,
|
||||
getScopeMaskFeather,
|
||||
getScopeMaskOpacity,
|
||||
getScopeTerminusOverride,
|
||||
} = this.services;
|
||||
const detection = this._shareableDetectionState();
|
||||
@@ -911,6 +953,7 @@ export class VisualSettings {
|
||||
celestialRingEnabled: this.celestialRingEnabled,
|
||||
scopeEnabled: isScopeMaskEnabled(),
|
||||
scopeFeatherPct: Math.round(getScopeMaskFeather() * 100),
|
||||
scopeOpacityPct: Math.round((getScopeMaskOpacity?.() ?? 1) * 100),
|
||||
// null when adaptive — the share layer omits `sce` entirely in that case.
|
||||
scopeTerminusPct:
|
||||
getScopeTerminusOverride() == null
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
<script setup>
|
||||
import { t } from '../../i18n/index.js';
|
||||
import RailCards from '../rail/RailCards.vue';
|
||||
import RailTimeline from '../rail/RailTimeline.vue';
|
||||
|
||||
// Active weather: forecast and event cards, then the observed products with
|
||||
// their shared history timeline. The owner computes every value shown.
|
||||
// the time of the frame they show. The world timeline moves time; the owner
|
||||
// computes every value shown.
|
||||
defineProps({
|
||||
view: { type: Object, required: true },
|
||||
onParams: { type: Function, default: () => {} },
|
||||
onOpen: { type: Function, default: () => {} },
|
||||
transport: { type: Object, required: true },
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -31,16 +30,9 @@ defineProps({
|
||||
:aria-label="t('Observed history')"
|
||||
><h3 class="panel-title">{{ t('Observed history') }}</h3
|
||||
><div class="weather-observed-scope">{{ view.scope }}</div
|
||||
><div class="weather-timeline-block" :hidden="!view.observed"
|
||||
><RailTimeline
|
||||
:state="view.timeline"
|
||||
slider-class-name="weather-timeline"
|
||||
:heading="false"
|
||||
:on-commit="transport.onCommit"
|
||||
:on-preview="transport.onPreview"
|
||||
:on-step="transport.onStep"
|
||||
:on-latest="transport.onLatest"
|
||||
:on-play="transport.onPlay" /></div
|
||||
><div class="weather-frame-time" :hidden="!view.frameTime">{{
|
||||
view.frameTime
|
||||
}}</div
|
||||
><div class="weather-cards"
|
||||
><RailCards
|
||||
:cards="view.observedCards"
|
||||
|
||||
+21
-37
@@ -98,13 +98,6 @@ export function createWeatherPanel({
|
||||
openPanels.set(page, id);
|
||||
render();
|
||||
},
|
||||
transport: {
|
||||
onCommit: (tick) => clock?.setTarget(tick),
|
||||
onPreview: (time) => historyTime(time, clock?.getState()),
|
||||
onStep: (direction) => clock?.step(direction),
|
||||
onLatest: () => clock?.latest(),
|
||||
onPlay: () => clock?.togglePlay(),
|
||||
},
|
||||
};
|
||||
// The readout patches synchronously, so a newly opened card can be measured.
|
||||
const paint = (view) =>
|
||||
@@ -113,14 +106,7 @@ export function createWeatherPanel({
|
||||
hidden: true,
|
||||
observed: false,
|
||||
scope: '',
|
||||
timeline: {
|
||||
ticks: [],
|
||||
index: 0,
|
||||
mode: 'latest',
|
||||
playing: false,
|
||||
readout: '',
|
||||
disabled: true,
|
||||
},
|
||||
frameTime: '',
|
||||
cards: [],
|
||||
observedCards: [],
|
||||
});
|
||||
@@ -135,32 +121,30 @@ export function createWeatherPanel({
|
||||
.filter(({ summary }) => summary)
|
||||
.sort((a, b) => ORDER.indexOf(a.id) - ORDER.indexOf(b.id));
|
||||
const observed = active.filter(({ id }) => OBSERVED.has(id));
|
||||
const showTimeline = observed.length > 0;
|
||||
const showObserved = observed.length > 0;
|
||||
const names = {
|
||||
'weather-radar': t('Rain radar'),
|
||||
'weather-satellite': t('Satellite clouds'),
|
||||
'weather-lightning': t('Lightning density'),
|
||||
};
|
||||
const index =
|
||||
state.mode === 'latest'
|
||||
? state.timeline.length - 1
|
||||
: Math.max(
|
||||
0,
|
||||
state.timeline.findLastIndex(
|
||||
(tick) => Date.parse(tick) <= Date.parse(state.target),
|
||||
),
|
||||
);
|
||||
const timeline = {
|
||||
ticks: state.timeline,
|
||||
index,
|
||||
mode: state.mode,
|
||||
playing: Boolean(state.playing),
|
||||
disabled: !showTimeline || state.timeline.length < 2,
|
||||
readout:
|
||||
state.mode === 'latest'
|
||||
? t('LATEST · newest per product')
|
||||
: historyTime(state.target, state),
|
||||
// While live, the newest frame and its age; at a past time, the timeline
|
||||
// time alone. The world timeline moves the time. Live, each product's
|
||||
// newest frame counts, suspended or not (reduced motion, a hidden page),
|
||||
// as the timeline leaves those out.
|
||||
const newest = () => {
|
||||
const times = (state.products ?? [])
|
||||
.map(({ selected }) => selected)
|
||||
.filter((time) => Number.isFinite(Date.parse(time)))
|
||||
.sort((a, b) => Date.parse(a) - Date.parse(b));
|
||||
return times.at(-1) ?? state.timeline.at(-1);
|
||||
};
|
||||
const shownTime = state.mode === 'latest' ? newest() : state.target;
|
||||
const frameTime =
|
||||
showObserved && shownTime
|
||||
? state.mode === 'history'
|
||||
? clockTime(shownTime)
|
||||
: historyTime(shownTime)
|
||||
: '';
|
||||
const models = active.map((entry) => {
|
||||
const { id, icon, summary, legend = [], list } = entry;
|
||||
// Discrete classes (storm geometry, AQHI bands) list swatches, not a ramp.
|
||||
@@ -245,9 +229,9 @@ export function createWeatherPanel({
|
||||
const hidden = active.length === 0;
|
||||
paint({
|
||||
hidden,
|
||||
observed: showTimeline,
|
||||
observed: showObserved,
|
||||
scope: observed.map(({ id }) => names[id]).join(' · '),
|
||||
timeline,
|
||||
frameTime,
|
||||
cards: models.filter(({ id }) => !OBSERVED.has(id)),
|
||||
observedCards: models.filter(({ id }) => OBSERVED.has(id)),
|
||||
});
|
||||
|
||||
Loaded 100 of 123 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user