mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 09:42:21 +00:00
Compare commits
189
Commits
No files matched your search
@@ -287,6 +287,7 @@ The optional Local ADS-B layer and the broadcast-FM receiver use radio you recei
|
||||
- **Acartia.** Keyless. `/api/acartia/sightings` reads the current 7-day marine-mammal feed for ALL, MAMMALS and WHALES views intersecting 45.5–50.5° N, 126–121° W in the Salish Sea. WHALES accepts recognized cetaceans; other identified marine mammals appear under ALL/MAMMALS. The server rounds positions to 0.01° and drops comments before caching projected records (10 min fresh, stale ≤24 h); raw responses are not retained. Selected text cards credit the reporting provider under CC BY 4.0 and show Be Whale Wise guidance. `/sightings/current` answers without a key today, but Acartia's README asks API users to create an account and generate an API key on the [Acartia dashboard](https://acartia.io/) and to follow its [community guidelines](https://acartia.io/register). Attribution also appears in the layer row and Data attribution popover. Opportunistic sightings, not a census.
|
||||
- **Mapped installations.** OpenFreeMap military polygons use a bundled Overture/OSM name index; wide views show named points. Optional operator-configured Overpass and explicit Google Places searches keep their own source paths. Mapped data does not establish current activity or complete coverage.
|
||||
- **Place search.** Named-place fly-to uses Google Geocoding when a Maps key is configured, then Photon (`PHOTON_URL`; unset uses the public instance, empty disables it), then `/api/geocode` (Nominatim search) when neither answers. `/api/geocode` and the voice outline route `/api/geocode/outline` share one Nominatim queue (`NOMINATIM_URL`; unset, empty and invalid values disable it; an operator must explicitly select an authorized endpoint): one request at a time at least 1.1 s apart, an identifying `User-Agent` and `Referer`, a short queue that refuses a burst, a pause after 429/403/5xx answers (honouring `Retry-After` in full), at most one retry after a network failure, and a per-install daily cap on public-instance requests (`NOMINATIM_DAILY_CAP`, default 50). Processes using the same installation state file hold one lock through the actual fetch invocation and recording the next public start, with the daily slot persisted before invocation; restarts share that count, spacing and any pause. An unfinished dispatch marker fails closed until operator recovery; it is never automatically reclaimed. Public access fails closed if the state file cannot be read, locked, written or semantically validated. This coordination does not span independent installations or state directories and does not establish an application-wide public-service allowance or authorize public use. An operator-selected non-public endpoint is outside the public cap, spacing and durable-state requirement; an upstream cooldown is kept with the endpoint that returned it rather than leaking across operator URLs. Answers are cached on disk (outlines 90 days, places 30 days, no-results 24 hours); failures are not cached. Outlines are looked up only for an explicit ask, after bundled data and any configured Overpass, and only results whose type suits the ask are used. Administrative outline responses expose country/admin-1/admin-2 identity only when the selected Nominatim row has a recognized, unambiguous address type consistent with its own name; numeric rank, ambiguous types, missing fields and contradictory names do not manufacture identity. It is not used for systematic or bulk queries.
|
||||
- **Place suggestions.** The search box's suggester (`src/search/placeSuggestions.js`) asks Photon for a few candidates while a place is typed: at most one request every 500 ms per tab (shared by every search box), a six-second limit for the whole answer, none for a minute after a refusal, a failed request or a timeout, and text capped at 200 characters. Text that may be private is never sent: an email address, seven or more digits however separated (a street address's house number and postcode excepted, unless a word such as "card" or "phone" names the number), an IBAN shape, a password, PIN, token or key. An empty `PHOTON_URL` turns suggestions off along with the place search. Answers are cached in the tab.
|
||||
- **Street and building outlines.** Voice street highlights, pointed-at buildings and grounds use the OpenFreeMap vector tiles the traffic layer already loads. Traffic and outlines share one bounded pending fetch/decode owner per immutable XYZ tile; materialized outline geometry is charged to the retained-byte ceiling and capped by coordinate count. Consumer result caches and request lifetimes remain independent, while eviction or explicit teardown cancels queued idle projections and releases their decoded owner. No Overpass request is made unless `OVERPASS_UPSTREAMS` is configured. Named grounds require a returned name matching the selected place, except that an ask whose head noun names a kind of grounds (a school, university or college, hospital, cemetery, stadium or zoo) may use the part of the smallest unnamed tile area of that class that holds the resolved place; a differently named area never answers. Other anonymous landcover polygons cannot establish identity, so unsupported grounds stay unavailable rather than borrowing a nearby POI name.
|
||||
- **Voice areas and place search.** Voice areas (`resolve_area`) use the same outline sources as voice outlines. Voice place search (`osm_query`, `/api/osm/features`) runs only on an operator-configured Overpass: a fixed list of kinds, a bounded box and result count, one query at a time, answers cached for a day. It never uses Nominatim.
|
||||
- **Cockpit regional briefing.** `/api/regional-brief` rounds aircraft coordinates into 0.1° cache cells, caches results for five minutes, and resolves physical regions from bundled public-domain Natural Earth polygons without reverse-geocoding requests. Google News RSS is queried with the resolved locality/region first; GDELT is used only when that RSS query fails or is empty. Google's published Google News terms restrict that source to personal, noncommercial use, so commercial deployments must disable/replace it or obtain separate permission; GDELT permits commercial dataset use with citation. The Data attribution popover identifies the active headline sources; article links retain publisher attribution. Headlines are location-query matches, not verified incidents, risk rankings, or evidence that a location is safe. Empty, partial, stale, and unavailable source states remain distinct. Open-Meteo supplies current conditions independently of the news source. `WX OFF` disables cockpit weather rendering only; the Local Info briefing still fetches its source-backed weather values and displays the required linked Open-Meteo credit.
|
||||
@@ -424,6 +425,7 @@ The [Bhote Koshi event pack](public/events/bhote-koshi-2026/README.md), under `p
|
||||
| **Natural Earth disputed areas** (11 of the source's 99 features, hand-picked; [list](src/data/local_data/natural_earth/README.md#disputed-areas-disputed_areasjson)) | `natural_earth/` | **Public domain** | ✅ (no restrictions) | "Made with Natural Earth" (courtesy credit — not legally required) |
|
||||
| **Natural Earth populated places** (7,342 points: name, position, rank) | `natural_earth/` | **Public domain** | ✅ (no restrictions) | "Made with Natural Earth" (courtesy credit — not legally required) |
|
||||
| **Wikidata cities** (31,827 settlements of 15,000 people or more: name, position, population, country) | `wikidata_cities/` | **CC0 1.0** (public domain dedication) | ✅ (no restrictions) | "City, town and village names from Wikidata (CC0)" (courtesy credit — not legally required) |
|
||||
| **Wikidata places** (137,662 settlements of 1,000 to 14,999 people, none in the cities pack, in 732 tiles of 5°: name, position, population, country) | `wikidata_places/` | **CC0 1.0** (public domain dedication) | ✅ (no restrictions) | "City, town and village names from Wikidata (CC0)" (courtesy credit — not legally required) |
|
||||
| **US Census Bureau counties** (3,235 county polygons) | `us_census_counties/` | **Public domain** | ✅ (no restrictions) | "U.S. Census Bureau" (courtesy — not legally required) |
|
||||
| **US Census Bureau places** (32,629 city, town and CDP polygons) | `us_census_places/` | **Public domain** | ✅ (no restrictions) | "U.S. Census Bureau" (courtesy — not legally required) |
|
||||
| **Who's On First neighborhoods** (61,441 polygons) | `wof_neighborhoods/` | Per source: CC BY, ODC-By, Open Government licences, CC0, PDDL, public domain (folder `ATTRIBUTION.md`) | ✅ (attribution) | "Neighborhood boundaries: Who's On First and contributors"; per-source credits in the folder |
|
||||
@@ -537,6 +539,24 @@ CC0; credited "City, town and village names from Wikidata (CC0)" as a courtesy o
|
||||
the pack is shown. Rebuild: `node scripts/build-wikidata-cities.mjs`; provenance in the folder
|
||||
README. The app never calls Wikidata itself.
|
||||
|
||||
### Wikidata places (`wikidata_places/`)
|
||||
|
||||
Smaller settlements below the cities pack's cut-off: 137,662 places of 1,000 to 14,999 people
|
||||
that Wikidata states a population and coordinates for, read once from the Wikidata Query Service
|
||||
(built 2026-11-11), with the same columns as the cities pack. Items the cities pack already holds
|
||||
(1,084 with another stated population of 15,000 or more) are left out, and so are 1,272 second
|
||||
listings of one place (same name and country within 3 km). A lookup also prefers a city of the
|
||||
same name within 3 km over a smaller listing. They are split into 732
|
||||
tiles of 5 x 5 degrees (7,122,797 bytes of JSON, about 7.1 MB, with the index) named by their south-west corner, with an index of row counts.
|
||||
Nothing loads with the app: the Omnibar's "places near" strip, the places under a selected item
|
||||
and a small place found by name near the view read the index once and then only the tiles a
|
||||
lookup touches. CC0; credited "City, town and village names from Wikidata (CC0)" as a courtesy
|
||||
once a name from the packs is shown. Rebuild:
|
||||
`node scripts/build-wikidata-cities.mjs --tiles --min-population 1000 --max-population 15000`;
|
||||
the script that wrote the shipped tiles was not kept, and only the step from rows to files is
|
||||
checked offline (provenance and limits in the folder README). The app never calls Wikidata
|
||||
itself.
|
||||
|
||||
### Sky background (`sky/`)
|
||||
|
||||
Sources, licences, the changes CC BY asks to state, hashes and build commands
|
||||
|
||||
+7
-1
@@ -258,6 +258,12 @@ export function createBrowserViteConfig({
|
||||
mapillaryToken ?? '',
|
||||
),
|
||||
},
|
||||
build: { chunkSizeWarningLimit: 1500 },
|
||||
build: {
|
||||
chunkSizeWarningLimit: 1500,
|
||||
// The places pack's tiles stay files, read only when a lookup touches
|
||||
// them; inlined, the small ones would all load with the first lookup.
|
||||
assetsInlineLimit: (file) =>
|
||||
file.includes('/wikidata_places/') ? false : undefined,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
- `F` now collapses and reopens the Data Layers panel the way the panel's own
|
||||
button does, and its rail entry stays. Before, `F` hid the panel together
|
||||
with its rail entry, so only another `F` brought it back (asturksever,
|
||||
#1598).
|
||||
@@ -3,10 +3,11 @@
|
||||
heading and HUD (in the page's language, via `getLocale` and
|
||||
`onLocaleChange` from `./i18n`); the camera can follow it without the
|
||||
ground clamp, anchored exactly on it, and a generic HUD adds source rows, a
|
||||
banner, a veil (off under reduced motion) and a bottom progress line. The
|
||||
Rail and Transit layers expose read and hold APIs so a selected train or
|
||||
vehicle can be ridden, and `./layers/rail/paths` is exported; that export
|
||||
and the read APIs are experimental. `docs/APPLICATION.md` shows a minimal
|
||||
provider. GEV itself registers none, and entry to the built-in aircraft,
|
||||
satellite and vessel views is unchanged; a provider's subject takes entry
|
||||
when it was selected after them (Denis Groshev, @ZloyS, #1686).
|
||||
banner, a veil (its light streaks stand still under reduced motion) and a
|
||||
bottom progress line. The Rail and Transit layers expose read and hold APIs
|
||||
so a selected train or vehicle can be ridden, and `./layers/rail/paths` is
|
||||
exported; that export and the read APIs are experimental.
|
||||
`docs/APPLICATION.md` shows a minimal provider. GEV itself registers none,
|
||||
and entry to the built-in aircraft, satellite and vessel views is
|
||||
unchanged; a provider's subject takes entry when it was selected after them
|
||||
(Denis Groshev, @ZloyS, #1686).
|
||||
@@ -0,0 +1,7 @@
|
||||
- Make earthquake discs and magnitude labels selectable, with magnitude, USGS
|
||||
class, depth, location, time and source details. Labels also fly to the quake;
|
||||
the selected disc shows a fading gradient and bounded contour animation. A
|
||||
drag ending on a quake does nothing. The card or label painted on top now
|
||||
takes a click in every layer: what is drawn under it neither acts nor loses
|
||||
its selection, and the Context panel names nothing there
|
||||
(Manjunath, @manjunath22466, #1781).
|
||||
@@ -0,0 +1,5 @@
|
||||
- Fix application Cockpit rides on Rail trains and Transit vehicles: a held
|
||||
parked vehicle no longer leaves its icon under the view, turning Transit off
|
||||
ends a hold, a view waits for the ground instead of standing on the
|
||||
ellipsoid, and GPS jitter at a platform no longer turns a ride around
|
||||
(German, @gekh, #1786).
|
||||
@@ -0,0 +1,11 @@
|
||||
- Keep an application's Cockpit subject steady. A subject whose entry frame
|
||||
gives a height stands there until a later frame or the floor under it gives
|
||||
another, so the view no longer ends while the floor loads. The camera keeps
|
||||
up when the browser draws few frames: updated every frame at 5 frames a
|
||||
second, it used to fall 700 m behind a 30 m/s subject in a minute. A
|
||||
provider's Live Signals rows change where they stand, their tone included,
|
||||
and rows it drops leave before new ones come in, so a changing ETA or a
|
||||
replaced row no longer pushes a steady warning off the list. Progress labels
|
||||
give CJK, kana and Hangul names the width they need. Labels, entry face and
|
||||
look keep their last good words when a later read fails
|
||||
(German, @gekh, #1787).
|
||||
@@ -0,0 +1 @@
|
||||
- The world timeline's speed control names its real-time speed **Real-time** instead of `1×`, beside `1 min/s`, `1 h/s`, `1 d/s` and `1 wk/s` (Sameh Khamis, @samehkhamis, #1805).
|
||||
@@ -0,0 +1,4 @@
|
||||
- An application can ask the Data Library's catalog with its own fetch
|
||||
(`createApplicationTools({ library: { fetchImpl } })`), for a server that
|
||||
wants the application's credentials on its library routes (samehkhamis,
|
||||
#1810).
|
||||
@@ -0,0 +1,6 @@
|
||||
- The place suggester asks Photon for candidates while a place is typed: at
|
||||
most one request every 500 ms per tab, none for a minute after a refusal
|
||||
or a failed request, and never text that may be private (an email address,
|
||||
long numbers, an IBAN shape, a password, PIN, token or key). An empty
|
||||
`PHOTON_URL` turns it off along with the place search. The search box that
|
||||
uses it follows (manjunath22466, samehkhamis, #1814).
|
||||
@@ -0,0 +1,3 @@
|
||||
- An application built with `createApplicationTools` can leave the Data Library
|
||||
out with `library: false`: no catalog is asked and no Browse button is drawn
|
||||
(samehkhamis, #1815).
|
||||
@@ -0,0 +1,4 @@
|
||||
- Bundle a pack of 137,662 smaller Wikidata settlements (1,000 to 14,999
|
||||
people, CC0) in 5° tiles, read only for the tiles a lookup touches, so
|
||||
nearby places and small places by name can be found without a place
|
||||
service (manjunath22466, samehkhamis, #1816).
|
||||
@@ -0,0 +1,4 @@
|
||||
- An aircraft feed can mark estimated positions (`estimatedByIcao` beside state
|
||||
vectors, `estimated: true` on a readsb-style row). Such a position still
|
||||
places the aircraft, but stands in on the tracked trail only until the next
|
||||
received one, so oceanic trails no longer zigzag (samehkhamis, #1817).
|
||||
@@ -0,0 +1,4 @@
|
||||
- Read a typed search line into places, layers, actions and questions,
|
||||
and pick what Enter runs, ready for the search bar; coordinates after
|
||||
"go to" are flown to, and text that may be private never leaves the
|
||||
app (manjunath22466, samehkhamis, #1818).
|
||||
@@ -0,0 +1,4 @@
|
||||
- Place suggestions keep more private text to the browser (a capital
|
||||
after "@", keys after "=" or in quotes, letter codes after a code label,
|
||||
phone numbers that looked like a postcode), and a house is suggested by
|
||||
its number and street (manjunath22466, samehkhamis, #1819).
|
||||
@@ -0,0 +1,6 @@
|
||||
- The fleet model set and its loader, the aircraft and vessel model
|
||||
resolvers, the icon-to-model handover distances, model lighting and part
|
||||
posing, and the vessel hull sprites are part of the package's public entry
|
||||
points as `gods-eye-view/fleet`, with declarations, so contacts can be drawn
|
||||
exactly as the Flights and Vessels layers draw them (Sameh Khamis,
|
||||
@samehkhamis, #XXXX).
|
||||
@@ -0,0 +1,3 @@
|
||||
- The fire layer module exports the FRP and Confidence filter its markers use
|
||||
(`filterFires`, `DEFAULT_FIRE_FILTER`), so an application that draws the same
|
||||
detections another way can apply the same filter.
|
||||
@@ -0,0 +1,12 @@
|
||||
- Add the Omnibar: one field for places, coordinates, map items, layers
|
||||
and commands, with a strip of nearby places, guided walks through the
|
||||
real controls (found by everyday wording such as "how do I change the
|
||||
map style"), plans such as "go to Austin and show flights", and Ask GEV
|
||||
for questions. On desktop the dock rises to a bar above the bottom with
|
||||
the map credits below it on the Power Up row, World Time hides while
|
||||
suggestions or chat are open, and the dock's Location and Visual trays
|
||||
and the HUD's mode readout give way to the Omnibar and the Visual panel.
|
||||
Phones get the field too, with the HUD readout under it on short
|
||||
screens. The last 20 places you went to from the Omnibar are kept in
|
||||
this browser (`localStorage` `gev:omnibar:recent-places`)
|
||||
(manjunath22466, samehkhamis, #1824).
|
||||
@@ -0,0 +1,10 @@
|
||||
- Remove the Cyber HUD layout and keep its sonar as a visual style. Display >
|
||||
HUD > Sonar turns it on over Tactical or Minimal; it is off by default and
|
||||
ON reveals its five sliders. Share links, scenes and saved views that name
|
||||
Cyber open in Tactical with Sonar on, links and scene shots carry Tactical
|
||||
with Sonar the same way, and the `set_cyber_sonar` voice action works under
|
||||
any layout. A newer Sonar choice takes precedence over a pending share-link
|
||||
restore. From 1200px wide the command dock and World Timeline sit 74px up,
|
||||
the map attribution sits on the Power Up baseline, and the coordinates start
|
||||
level with the bottom-right readout instead of overlapping the attribution
|
||||
and Power Up (manjunath22466, samehkhamis, #1825).
|
||||
@@ -0,0 +1,16 @@
|
||||
- Space Missions moves out of the Context panel into its own right-rail panel,
|
||||
with its own tab on phones, and becomes an ordinary layer. It no longer
|
||||
switches other layers off or refuses them while it runs, and Context leaves
|
||||
it and Satellites alone, so it runs beside Contacts in either order
|
||||
(Contacts no longer switches Satellites off). On desktop, opening Context or
|
||||
Space Missions collapses the other. Mission labels on the globe are
|
||||
clickable and select their mission, even where they sit over aircraft or
|
||||
ships, and picking a mission on the globe opens the panel. The Data Layers
|
||||
row gets previous and next mission controls. Share links keep the panel
|
||||
open or closed (a short link made from an older long link, which does not
|
||||
mention the panel, is two bytes longer), voice can open it, and Cockpit
|
||||
folds it away like the other map panels. An explicit user or voice
|
||||
Satellites off request made after Space Missions was switched on ends it
|
||||
and keeps Satellites off afterwards; scene, story, preset and other
|
||||
programmatic Satellites changes leave Space Missions running
|
||||
(manjunath22466, samehkhamis, #1826).
|
||||
@@ -0,0 +1,5 @@
|
||||
- Replace the first-run launcher with a three-step welcome: an introduction to
|
||||
the modes, where to start (Space Missions, Environmental or Explore
|
||||
manually), then quick tips and links. The Live Contacts starting choice is
|
||||
gone. GEV Stories opens in the app from the last step, and a light tint (no
|
||||
blur) sits over the globe while the card is up (manjunath22466, samehkhamis, #1827).
|
||||
@@ -0,0 +1,5 @@
|
||||
- The fire layer takes a stand-in for its markers (`setMarkerStandIn`), for an
|
||||
application that draws the same detections another way: the markers,
|
||||
heatmap and ambient cards hide, and a click on a fire the application draws
|
||||
selects it and moves the camera to it, with its card, as a click on its
|
||||
marker does (samehkhamis, #1828).
|
||||
@@ -0,0 +1,9 @@
|
||||
- Space Missions going off no longer acts on a launch hovered, selected or
|
||||
replayed meanwhile, and Satellites keeps the state it was saved with when
|
||||
it is still busy (unless it was switched on or off by hand meanwhile); a
|
||||
Satellites setting changed during a mission, such as a place search ending
|
||||
tracking, is kept when the mission ends. A click on a mission label is a
|
||||
click on the card on top, so no layer selects, turns on, flies to or opens
|
||||
the link of what lies under it; in the cockpit a mission chosen by its
|
||||
label, its dot or the row's arrows is selected without moving the camera
|
||||
(manjunath22466, samehkhamis, #1829).
|
||||
@@ -0,0 +1,7 @@
|
||||
- More private text typed into the Omnibar or Location search stays off the
|
||||
place service: emails spelled out or spaced, IP addresses, wallet recovery
|
||||
phrases, door, alarm and lockbox numbers, codes after their labels,
|
||||
document and ID numbers, SSNs, more API token shapes and codes in links.
|
||||
More real places get through: "Boise ID 83702", house numbers in the
|
||||
order their country writes them, addresses of up to ten words, and long
|
||||
questions for Ask GEV (manjunath22466, samehkhamis, #1830).
|
||||
@@ -0,0 +1,7 @@
|
||||
- The Omnibar reads more lines the way they are meant: a country named with
|
||||
"and" stays whole ("flights near Trinidad and Tobago"), places show as they
|
||||
were typed, "hide everything except flights" switches off every other
|
||||
layer that is on, "remove flights from the map" and a doubled verb are
|
||||
understood, a grid reference after "near" is the place, and a layer word
|
||||
that begins a name ("Fire Island") no longer offers a plan to the rest of
|
||||
it (manjunath22466, samehkhamis, #1831).
|
||||
@@ -0,0 +1,3 @@
|
||||
- The fire layer's marker stand-in can set how far the camera stands from a
|
||||
fire it draws (`focusRangeM`), and a world focus request may carry its own
|
||||
range (samehkhamis, #1832).
|
||||
@@ -0,0 +1,4 @@
|
||||
- Keep the HUD's bottom corners, the Omnibar dock and the corner row clear of
|
||||
the map credits at every desktop width, also right to left and when the
|
||||
credits wrap onto several lines; and carry Sonar with the Minimal HUD layout
|
||||
in share links and scene shots (manjunath22466, samehkhamis, #1833).
|
||||
@@ -0,0 +1,5 @@
|
||||
- Renderer contract: a timed imagery source can be `decoded` (the
|
||||
`imageryDecoded` capability), tiles the application makes itself and hands
|
||||
over as finished images, slot by slot; the Cesium renderer draws each slot
|
||||
as an imagery layer of its own, and the check `globe.imagery.decoded` covers
|
||||
it (Sameh Khamis, #1834).
|
||||
@@ -0,0 +1,3 @@
|
||||
- Icons drawn over depth (aircraft, vessels) no longer vanish for a frame now
|
||||
and then in dense far-away clusters: they sit just past the near plane instead
|
||||
of exactly on it, where rounding could discard them (samehkhamis, #1835).
|
||||
@@ -0,0 +1,3 @@
|
||||
- The delayed-live aircraft icon test holds the clock still while it compares
|
||||
drawn and read positions, so it no longer fails on a busy machine
|
||||
(samehkhamis, #1836).
|
||||
@@ -0,0 +1,4 @@
|
||||
- Keep the left and right panel rails clear of obstacles across the middle
|
||||
of a short window, such as the World Timeline or a card: both rails put
|
||||
the panels on the side with more room, whatever order the obstacles come
|
||||
in (manjunath22466, samehkhamis, #1837).
|
||||
@@ -0,0 +1,4 @@
|
||||
- "Villages near" a name picks the place of that name in view over a far
|
||||
bigger namesake, a place lookup reads the detail tiles within 500 km at
|
||||
most, and rebuilding the places pack never leaves it half removed
|
||||
(manjunath22466, samehkhamis, #1838).
|
||||
@@ -0,0 +1,4 @@
|
||||
- The Vue kit's button, chip, badge, empty state and segmented control now
|
||||
carry Core's standard looks, so controls can be built from the kit without
|
||||
restyling them; nothing in the app changes look (manjunath22466,
|
||||
samehkhamis, #1839).
|
||||
+3
-1
@@ -396,7 +396,9 @@ their `this`; one that throws or returns a promise is treated as having
|
||||
failed. What a method returns may carry getters: one that throws when read
|
||||
makes a candidate none, a frame malformed (the view ends) and a HUD view keep
|
||||
the last; a worded member (labels, entry face, look) that throws keeps its
|
||||
last good words.
|
||||
last good words. An entry face's `icon` is a Material Symbols name whose glyph
|
||||
the application's page must load (GEV's own `index.html` loads a subset, its
|
||||
`icon_names`); a glyph the page does not load renders as its name.
|
||||
|
||||
```js
|
||||
import { getLocale, onLocaleChange } from 'gods-eye-view/i18n';
|
||||
|
||||
@@ -781,8 +781,7 @@ palettes use `--gev-field-background`, `--gev-field-border-color`,
|
||||
`--gev-field-color` and `--gev-field-disabled-opacity`. Radio retains its own
|
||||
compact density and arrow space. CCTV owns calibration editor width in
|
||||
`cctv.css`; the shared inline density does not impose a feature-specific width.
|
||||
Cyber supplies a shared-field palette explicitly and keeps its legacy native
|
||||
field rules separate, so Radio's palette remains an intentional exception.
|
||||
Radio's palette remains an intentional exception.
|
||||
|
||||
### Read-only status badges
|
||||
|
||||
|
||||
+653
-171
File diff suppressed because it is too large.
Load diff
@@ -28,7 +28,12 @@ own `.d.ts`:
|
||||
- `gods-eye-view/render/recession`: how a set that recedes shrinks and
|
||||
fades its items toward the limb;
|
||||
- `gods-eye-view/render/windStreamlines`: the wind field's streamlines;
|
||||
- `gods-eye-view/geo/screenCluster`: screen-space clustering.
|
||||
- `gods-eye-view/geo/screenCluster`: screen-space clustering;
|
||||
- `gods-eye-view/fleet`: fleet contacts as the Flights and Vessels layers
|
||||
draw them: the fleet model set and its loader, which model and size an
|
||||
aircraft or a vessel takes, the distances a contact's icon hands over to
|
||||
its model at, how a model is lit, tinted and posed, and the vessel hull
|
||||
sprites.
|
||||
|
||||
`src/render/neutralExports.test.mjs` checks that each is declared, that its
|
||||
names match what it exports, that it type-checks under strict TypeScript and
|
||||
@@ -356,6 +361,18 @@ names the nearest frame's time once every globe tile drawn shows that
|
||||
frame's own imagery (`src/render/cesium/imageryFrames.js`). The checks
|
||||
`globe.imagery.frames` and `globe.imagery.video` cover both.
|
||||
|
||||
It also draws `decoded` sources (`imageryDecoded`): tiles the application
|
||||
makes itself and hands over as finished images. Their slots are times: the
|
||||
source's `slotAt` names the slot a time shows and `prefetch` the slots held
|
||||
ahead, of which the first `prefetch` (the option, 1 by default) load unseen.
|
||||
Each slot is a Cesium imagery layer in the layer's tiling whose tiles are the
|
||||
images the source's `tile` answers, asked as `shown` or `prefetch`; a
|
||||
deferred tile is asked again on a later frame, a missing one draws its
|
||||
parent's, and a slot let go aborts the tiles it still waits on and closes an
|
||||
image that arrives after. A time with no slot draws nothing and announces
|
||||
nothing; `frameReady` names the slot shown once it is drawn. The check
|
||||
`globe.imagery.decoded` covers it.
|
||||
|
||||
Every Cesium draw set takes `setColumns` (`columns`): icon sets on the GPU,
|
||||
any other as the rows the columns make over the items it holds, each row the
|
||||
item of that id with the columns' fields over it, replacing every item as
|
||||
|
||||
@@ -54,8 +54,14 @@ fallback for zero; holds may be zero.
|
||||
|
||||
Visual fields are `style`, `mapStack`, `styleParams`, `bloom`, `sharpen`, `hud`, and
|
||||
`detection`, and `scope`. Bloom has `enabled`, `intensity`, `version`; sharpen has `enabled`,
|
||||
`intensity`; HUD has `visible`, `variant`; detection has `mode`, `density`,
|
||||
`intensity`; HUD has `visible`, `variant` and an optional `sonar`; detection has `mode`, `density`,
|
||||
`allocation`, `fadePct` and `outsideOpacityPct`. Scope has `enabled`, `featherPct`.
|
||||
HUD `sonar: true` is Sonar on beside a layout that cannot say it (Minimal); it
|
||||
is written only then, so Tactical with Sonar stays the variant `cyber` and a
|
||||
shot without Sonar has no `sonar`. A shot without it opens with Sonar on only
|
||||
when its variant is `cyber`. A build from before `sonar` refuses a project
|
||||
that has it, as it refuses any field it does not know; every other project
|
||||
still opens there.
|
||||
The latter settings were written by Update Shot but previously lost during
|
||||
normalization; they now survive import and capture.
|
||||
Version-1/2 bloom without an explicit scale version uses the original inverted
|
||||
|
||||
@@ -134,7 +134,7 @@ probability of about 255 in 256 (many of them already fail as base64url).
|
||||
| 13 | thing | LEN | none | sub-message, see thing views |
|
||||
| 14 | `style` | enum | `normal` | normal, retro, surveillance, thermal, anime, noir, snow (retired) |
|
||||
| 15 | `mapStack` | enum | `photoreal` | photoreal, bing-aerial, bing-labels, esri-imagery, osm |
|
||||
| 16 | `hudVariant` | enum | style | tactical, operator (retired), minimal, cyber |
|
||||
| 16 | `hudVariant` | enum | style | tactical, operator (retired), minimal, cyber (Tactical + Sonar) |
|
||||
| 17 | `bloomIntensity` | uint | style | |
|
||||
| 18 | `bloomVersion` | uint | 2 | |
|
||||
| 19 | `sharpenIntensity` | uint | style | |
|
||||
@@ -176,7 +176,11 @@ Opacity slider (the long form's `sco`). It is written only below 100, so a
|
||||
link made before it, which opens at full opacity, keeps its code.
|
||||
|
||||
Flag bits (field 9): 0 `bloom`, 1 `sharpen`, 2 `hudVisible`, 3
|
||||
`celestialRing` (each defaulting by style), 4 `scopeEnabled` (default on).
|
||||
`celestialRing` (each defaulting by style), 4 `scopeEnabled` (default on), 5
|
||||
`hudSonar` (default off). `hudSonar` is Sonar on beside a HUD layout whose code
|
||||
cannot say so, Minimal (the long form's `hs=1`); Tactical with Sonar stays the
|
||||
`cyber` layout code alone. A link made before the bit has it off, and opens
|
||||
with Sonar on only when it names `cyber`, as before.
|
||||
|
||||
### Style defaults
|
||||
|
||||
@@ -282,6 +286,7 @@ reserved: a decoder ignores that entry, as for collapsed 0.
|
||||
| 8 | `global-context-panel` | `g` | collapsed |
|
||||
| 9 | `pp-toggles` | `p` | collapsed |
|
||||
| 10 | `param-slider-panel` | `m` | expanded |
|
||||
| 11 | `space-missions-panel` | `n` | collapsed |
|
||||
|
||||
### Style parameters (field 27)
|
||||
|
||||
|
||||
+90
-13
@@ -37,14 +37,40 @@ one-panel rule too. Share links continue to record which panels are open.
|
||||
## Component kit
|
||||
|
||||
`src/ui/kit/` holds the generic components: `UiRail`, `UiTooltip`, `UiIcon`,
|
||||
`UiButton`, `UiPanel`, `UiSegmented`, `UiSlider`, `UiChip`, `UiSelect`,
|
||||
`UiBadge` and `UiEmpty` so far, with more joining as the controls they serve
|
||||
are converted. One component
|
||||
`UiButton`, `UiCloseButton`, `UiPanel`, `UiSegmented`, `UiSlider`, `UiChip`,
|
||||
`UiSelect`, `UiSearchField`, `UiCheckbox`, `UiDialog`, `UiBadge` and `UiEmpty` so far, with more
|
||||
joining as the controls they serve are converted. One component
|
||||
serves every use of a control, with props for the differences (`UiPanel`'s
|
||||
`sideways`, `glow`, `scroll`), rather than a copy per panel. The components
|
||||
are styled by the existing stylesheet and custom properties; a kit class such as
|
||||
`ui-button--icon` carries no Core style yet, and a converted control keeps
|
||||
its own classes beside it. They contain no application state.
|
||||
are styled by the existing stylesheet and custom properties, and they contain
|
||||
no application state. The kit's own classes wear Core's standard looks, each
|
||||
sharing one selector list with the Core skin it comes from, so the rules are
|
||||
never copied:
|
||||
|
||||
| Kit class | Look | Rules |
|
||||
| --- | --- | --- |
|
||||
| `UiButton` `variant="ghost"` (default) | none: the caller's classes style it | — |
|
||||
| `UiButton` `variant="action"` | the action surface (`gev-action-button`); `tone="danger"` hovers red, `size="compact"` is the shot-row footprint (on this variant only) | `src/ui/styles/action-button.css` |
|
||||
| `UiButton` `variant="primary"` | the action surface with a group's main-action accent | `src/ui/styles/action-button.css` |
|
||||
| `UiButton` `variant="icon"` | the 22px square glyph button of a panel's collapse toggle | `src/ui/styles/controls.css` |
|
||||
| `UiCloseButton` | a close, dismiss or clear button: a bare glyph (× with `glyph="times"`, the Material `close` symbol with `glyph="icon"`) with no padding, border or background of its own and a pointer; the site's feature class sets size, colour, hover and any surface, and `bare` leaves the look off for a skin that keeps the browser's padding | `src/ui/styles/close-button.css` |
|
||||
| `UiSearchField` | a search field: the Material `search` glyph and a search input in a flex row, the input bare (no border or background, free to shrink); the site's feature classes set the frame's size, surface and focus ring and the input's type and outline, and the browser's own cancel button is left to each skin | `src/ui/styles/search-field.css` |
|
||||
| `UiCheckbox` | a checkbox: a label wrapping a native box and its words in a centred flex row; the box keeps each site's size, margin and accent colour, and the site's feature class sets the row's gap, direction and colour | `src/ui/styles/checkbox.css` |
|
||||
| `UiDialog` | none: a native modal `<dialog>`; the site's feature class or inline style draws it | — |
|
||||
| `UiChip` | the read-only chip (a pill of uppercase mono text); `selected` takes the accent | `src/ui/styles/chip.css` |
|
||||
| `UiEmpty` | the one-line empty state (dim mono text), its hint on a line below | `src/ui/styles/empty-state.css` |
|
||||
| `UiBadge` | the read-only badge (`gev-status-badge`) | `src/ui/styles/status-badge.css` |
|
||||
| `UiSegmented` | the segmented control (`gev-segmented`, `gev-segment`) | `src/ui/styles/segmented-control.css` |
|
||||
|
||||
A pressed action, primary or icon button looks as a hovered regular one does
|
||||
(a compact action's quieter hover is for an unpressed button), and a disabled
|
||||
one dims and ignores hover and press. `tone` is `accent` or `danger`, and
|
||||
`size` styles the action variant only. Each look's resting rule selects one
|
||||
kit class; the button, chip and empty-state skins load before the feature
|
||||
stylesheets that restyle them, so a feature class still wins. The badge and
|
||||
segmented skins are the stylesheets their Core classes always used. A
|
||||
converted control keeps its own classes beside the kit's.
|
||||
`src/ui/kit/kitStyles.test.mjs` pins these rules.
|
||||
`UiPanel` takes a `title`, slots and `v-model:collapsed`, but its
|
||||
`collapsed` drives only the button and `ui-panel--collapsed`: the root's
|
||||
`collapsed` class, which hides the body, is drawn at once by `v-panel-state`
|
||||
@@ -74,9 +100,61 @@ gain) takes `hold`. Every select in the views is a `UiSelect`.
|
||||
density variants and colours stay caller classes, and it renders the CCTV
|
||||
source and calibration badges and the rail card badges. `UiEmpty` takes
|
||||
a `title` and `hint`, but Core's empty states are one line, so the title
|
||||
is the text itself rather than a bold heading; the Scene shot list, mission
|
||||
roster and imagery strip use it. The locale picker's and the mission tables'
|
||||
is the text itself rather than a bold heading; the News feed, Scene shot
|
||||
list, mission roster and imagery strip use it. The locale picker's and the mission tables'
|
||||
empty rows stay a paragraph and table cells.
|
||||
`UiCloseButton` is a `UiButton` with a fixed glyph, a required `label` and
|
||||
no tip unless the site passes a `title`; attributes and classes pass through,
|
||||
so each site keeps its id, feature class and look. Every close, dismiss and
|
||||
clear button in the views is one (`src/ui/kit/closeButtons.test.mjs` pins
|
||||
it); Street Level's and the space mission's keep `bare`, since their skins
|
||||
keep the browser's padding. The close buttons built in script (credits, the
|
||||
Quebec CCTV overlay, the guide) are not converted yet.
|
||||
`UiSearchField` takes `v-model`, a required `label` (the input's
|
||||
accessible name), `placeholder` and `tag` (`div`, given `role="search"` by
|
||||
the site, or `label`); attributes and classes go to the frame, and
|
||||
`inputId`, `inputClass`, `autocomplete` and `spellcheck` to the input. With
|
||||
`clearLabel` it shows a `UiCloseButton` (`clearClass`, its label as its tip)
|
||||
while text is typed, which empties the field and focuses the input again.
|
||||
Escape stops at the input and is emitted with its event, so a site that also
|
||||
keeps the browser from clearing the field prevents it there; `focus()`
|
||||
focuses the input. The Context search and the Layer Finder's are
|
||||
`UiSearchField`s; the locale picker's combobox, the Omnibar's location
|
||||
field and the Data Library's labelled search are other controls. Its kit rules hold the declarations both search
|
||||
skins had in common, moved rather than copied, and load before them.
|
||||
`UiCheckbox` is a `<label>` wrapping a native `<input type="checkbox">` and
|
||||
its default slot; `trailing` puts the box after the words, as the Visual
|
||||
panel's rows have it. It takes `v-model` (the change emits the checked state)
|
||||
and emits `change` with its event; without a `modelValue` the box is the
|
||||
browser's own, as the welcome card's "Don't show this again" is, whose
|
||||
owner puts a refused save back itself. `restore` puts the box back to
|
||||
`modelValue` once a change has rendered without the owner taking it, so the
|
||||
voice panel's quick commands and Voice Preview show the applied value after
|
||||
a refused change. Attributes and classes go to the label; `inputId` and
|
||||
`inputAttrs` (such as `aria-describedby` or a data hook) to the box. The
|
||||
Visual panel's Scope, sky and application toggles, the voice and chat
|
||||
preferences, the Data Library's filter and the welcome card's box are
|
||||
`UiCheckbox`es (`src/ui/kit/checkboxes.test.mjs` pins it); Story Explore's
|
||||
filters are not converted yet. Its kit rule holds the centred row the
|
||||
checkbox-only labels drew, moved rather than copied.
|
||||
`UiDialog` is a native `<dialog>` its owner opens and closes with `open`:
|
||||
true opens it with `showModal()` (on mount, for one mounted open), false
|
||||
closes it, and unmounting closes it. Each change is applied once the content
|
||||
has rendered and then emitted as `opened` or `closed`, so the Data Library
|
||||
focuses its search field on open and returns focus to Browse on close.
|
||||
Escape's `cancel` is prevented and emitted as `dismiss`, so the owner
|
||||
decides; `backdropDismiss` makes a click on the dialog itself, outside its
|
||||
content, a `dismiss` too. When the browser closes the dialog on its own
|
||||
while `open` is still true (an Escape the page may not cancel),
|
||||
`browserClose` tells the owner; closing on unmount reports nothing. A DOM
|
||||
without `showModal()` leaves it closed rather than failing. Attributes,
|
||||
classes, styles and listeners go to the dialog, and `element` is exposed.
|
||||
The Data Library and the scene sharing dialogs are `UiDialog`s
|
||||
(`src/ui/kit/dialogs.test.mjs` pins it); the panels drawn as
|
||||
`role="dialog"` (key setup, the welcome launcher, the CCTV popup, Story
|
||||
Explore's filter, the credits) and the render failure's `alertdialog` are
|
||||
other controls. The two dialogs share no declarations, so it has no kit
|
||||
rules.
|
||||
`UiSlider` keeps the native range input rather than drawing a
|
||||
`role="slider"` track, so Core's keyboard, form behaviour and styling stay;
|
||||
it takes `v-model`, `min`, `max`, `step` and `disabled`, emits a
|
||||
@@ -92,8 +170,7 @@ a functional component would not render again.
|
||||
|
||||
Controls share one skin, so every panel reads the same. Every scrolling
|
||||
surface carries the kit's `.ui-scroll`, which draws the thin
|
||||
themed scrollbar from `--scroll-thumb` and `--scroll-track`; the Cyber theme
|
||||
sets those two tokens, and Cockpit's HUD windows keep their accent tint. A
|
||||
themed scrollbar from `--scroll-thumb` and `--scroll-track`, and Cockpit's HUD windows keep their accent tint. A
|
||||
surface without it would draw the platform's light scrollbar, because the
|
||||
page declares no dark `color-scheme`. Selects and number fields are
|
||||
`.gev-field`, which draws its own chevron in place of the platform's arrow
|
||||
@@ -338,8 +415,8 @@ a feature supplying only its accent.
|
||||
records surface by surface; [Building UI](../CONTRIBUTING.md#building-ui)
|
||||
now requires the pattern for new UI. The page-level markup tests read
|
||||
`renderApplicationHtml()`, the real views rendered on the server, and new
|
||||
tests mount components; three tests still read a `.vue` file's source
|
||||
(`cyberTheme`, `panelStorageDocs`, `geoFileImport`). The views translate with `t()`
|
||||
tests mount components; two tests still read a `.vue` file's source
|
||||
(`panelStorageDocs`, `geoFileImport`). The views translate with `t()`
|
||||
while rendering, and vue-i18n holds the locale they read; the attribute
|
||||
translation pass is left for static page markup (the loading screen and a
|
||||
host's own markup). An explicit API for hosts to register panels and rail items is
|
||||
@@ -361,7 +438,7 @@ a feature supplying only its accent.
|
||||
- Panels lifted out of a view keep its verbatim markup in
|
||||
`src/ui/views/panels/`, which Prettier leaves alone like the views.
|
||||
- Visual parity: before/after screenshots of every panel at desktop and phone
|
||||
widths, in the default and Cyber themes, with the rail as the only expected
|
||||
widths, in the default theme, with the rail as the only expected
|
||||
difference.
|
||||
- Browser QA: the selector-based `scripts/qa-*.mjs` suites keep passing.
|
||||
- `npm run format:check`, `npm run check:boundaries`, `npm run i18n` and
|
||||
|
||||
+9
-11
@@ -1,9 +1,8 @@
|
||||
# Panel surface contract
|
||||
|
||||
`src/ui/styles/panel-surfaces.css` supplies an opt-in visual surface for new
|
||||
panels. It uses the application's default color, font, border and radius tokens;
|
||||
Cyber supplies its existing red/slate palette, monospace typography and shaped
|
||||
frame. This is CSS shared by the existing panel system, not a panel registry or
|
||||
panels. It uses the application's default color, font, border and radius tokens.
|
||||
This is CSS shared by the existing panel system, not a panel registry or
|
||||
a controller. A panel ID does not need a new theme selector.
|
||||
|
||||
## Markup
|
||||
@@ -57,13 +56,12 @@ fit when those contents should instead scroll.
|
||||
| Mount | Shared contract | Owner responsibilities |
|
||||
| ------------------------------------- | --------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Direct child of `#left-panel-stack` | An owner with a direct `[data-panel-surface]` child receives relative positioning and allocated height; inner surface/body skin | Add the wrapper shown above, use the existing layout/disclosure owners, and retain left-rail focus/auto-collapse rules. |
|
||||
| Direct child of `#right-context-rail` | The same hooks with right-rail allocation and intrinsic measurement | Keep `data-rail-scroller` on the body so measurement preserves its scroll position. Respect Cyber's one-expanded-panel policy. |
|
||||
| Direct child of `#right-context-rail` | The same hooks with right-rail allocation and intrinsic measurement | Keep `data-rail-scroller` on the body so measurement preserves its scroll position. |
|
||||
| Surface inside `#command-dock` | Surface, controls, popup decoration and inherited dock concealment | Supply geometry, stacking, disclosure, pin behavior if wanted, safe viewport bounds and dismissal. This CSS does not extend the existing Location/Visual Presets tray stack manager to arbitrary panels. |
|
||||
| `dialog[data-panel-surface]` | The same surface/body skin; a closed dialog remains hidden | Set width/max-height, use `showModal()` or `show()` and `close()`, and own labels, initial/return focus and dismissal. Do not put `panel-collapsible` on a dialog. |
|
||||
|
||||
For rails, `--panel-expanded-width` and `--panel-collapsed-width` customize
|
||||
the desired widths within the rail; otherwise Cyber uses its existing left,
|
||||
right and collapsed panel widths. `--left-panel-allocated-height` and
|
||||
the desired widths within the rail. `--left-panel-allocated-height` and
|
||||
`--right-panel-allocated-height` belong
|
||||
to the existing layout owner, not to individual panels. The surface must be
|
||||
the wrapper's first non-glow child because left-rail intrinsic measurement
|
||||
@@ -121,9 +119,9 @@ dismiss open popups/dialogs and restore focus before removing a dynamic panel.
|
||||
|
||||
## Decoration, popups and visibility
|
||||
|
||||
The shared surface reserves `::before` for its non-interactive background. The
|
||||
Cyber frame clips this pseudo-element only; the surface stays unclipped with
|
||||
visible overflow. This follows the existing Display and Global Context pattern.
|
||||
The shared surface reserves `::before` for its non-interactive background; the
|
||||
surface stays unclipped with visible overflow. This follows the existing
|
||||
Display and Global Context pattern.
|
||||
Putting the shape on an interactive ancestor clips all descendant popups even
|
||||
if their `z-index` is high. A scrolling body also clips descendants by design,
|
||||
so outward popups must be siblings of the body, or use an explicitly owned
|
||||
@@ -148,8 +146,8 @@ visible.
|
||||
|
||||
## Check an addition
|
||||
|
||||
Use the real application with the default and Cyber themes. Check open,
|
||||
collapsed, hidden, disabled/error, theme round trips, clean UI/recording and
|
||||
Use the real application with the Tactical and Minimal HUD layouts. Check open,
|
||||
collapsed, hidden, disabled/error, layout round trips, clean UI/recording and
|
||||
the intended Cockpit behavior. Exercise keyboard focus, Escape, pointer input,
|
||||
the last scrolling item, resize without reload and any pin/unpin controls.
|
||||
For an outward popup, test visible pixels and pointer hit-testing outside the
|
||||
|
||||
@@ -65,7 +65,6 @@ The `many` form is the `other` text with «de» after the number: «{count} de c
|
||||
| detection overlay | superposición de detección |
|
||||
| pin (Draw tool) | marcador |
|
||||
| Bloom / Glow (visual effect) | resplandor |
|
||||
| Cyber (HUD layout, effect) | Ciber |
|
||||
| heading, course / altitude / ground speed | rumbo / altitud / velocidad respecto al suelo (short: VEL. SUELO) |
|
||||
| HDG / BRG / CRS / FOV / DEST / SPD / RANGE | HDG / BRG / CRS / FOV / DEST / SPD / RANGE (unchanged) |
|
||||
| PREV / NEXT | ANT. / SIG. |
|
||||
|
||||
@@ -82,7 +82,6 @@ The `many` form is the `other` text with « de » (« d' » before a vowel) afte
|
||||
| Recent Imagery / box | imagerie récente / zone |
|
||||
| Daily overview / overview (Recent Imagery VIIRS product) | vue quotidienne (one name for the product, not « vue d'ensemble ») |
|
||||
| pin (Draw tool) / pin (Recent Imagery) | épingle / épingler |
|
||||
| Cyber (HUD layout, effect) | Cyber |
|
||||
| heading / course (ground track) / altitude / ground speed | cap / route / altitude / vitesse sol |
|
||||
| HDG / BRG / CRS / FOV / DEST / SPD / ALT | unchanged |
|
||||
| RANGE / PITCH / HGT (CCTV calibration chips) | PORTÉE / INCL. / HAUT. |
|
||||
|
||||
@@ -82,7 +82,7 @@ The `many` form is the `other` text with «di» after the number when a noun fol
|
||||
| briefing / panel / dock | briefing / pannello / dock |
|
||||
| cockpit | cockpit |
|
||||
| preset / visual preset | preset / preset visivo |
|
||||
| Tactical / Minimal / Cyber | Tattico / Minimale / Cyber |
|
||||
| Tactical / Minimal | Tattico / Minimale |
|
||||
| Scope (circular viewport mask) / keyhole | scope / foro |
|
||||
| feather / fade | sfumatura / dissolvenza |
|
||||
| detection overlay | overlay di rilevamento |
|
||||
|
||||
@@ -61,7 +61,7 @@ Translation source: abiyeenzo (#913).
|
||||
| scene / shot | シーン / ショット |
|
||||
| briefing / panel / dock | ブリーフィング / パネル / ドック |
|
||||
| preset / visual preset | プリセット / ビジュアルプリセット |
|
||||
| Tactical / Minimal / Cyber | タクティカル / ミニマル / サイバー |
|
||||
| Tactical / Minimal | タクティカル / ミニマル |
|
||||
| Scope (circular viewport mask) / keyhole | スコープ / キーホール |
|
||||
| Clean UI | クリーンUI |
|
||||
| cockpit | コックピット |
|
||||
|
||||
@@ -91,7 +91,6 @@ The `many` form is the `other` text with «de» after the number: «{count} de c
|
||||
| feather / fade | suavização / esmaecimento |
|
||||
| detection overlay | sobreposição de detecção |
|
||||
| pin (Draw tool) / box (Recent Imagery) | marcador / área |
|
||||
| Cyber (HUD layout, effect) | Ciber |
|
||||
| heading / course / altitude / ground speed | rumo / curso (a ship's course: rumo) / altitude / velocidade solo (VELOC. SOLO) |
|
||||
| map heading / bearing (compass, north up) | orientação (do mapa) |
|
||||
| HDG / BRG / CRS / FOV / DEST / SPD / RANGE | HDG / BRG / CRS / FOV / DEST / SPD / RANGE (unchanged) |
|
||||
|
||||
@@ -43,7 +43,7 @@ Translation sources: abiyeenzo (#914) and EDIT-Aeterna (#979).
|
||||
| briefing / panel / dock | 简报 / 面板 / 停靠栏 |
|
||||
| preset / visual preset | 预设 / 视觉预设 |
|
||||
| Display / HUD layout | 显示 / HUD 布局 |
|
||||
| Tactical / Minimal / Cyber | 战术 / 精简 / 赛博 |
|
||||
| Tactical / Minimal | 战术 / 精简 |
|
||||
| Scope (circular viewport mask) / keyhole | 视域 |
|
||||
| Clean UI | 纯净界面 |
|
||||
| cockpit | 座舱 |
|
||||
|
||||
@@ -350,6 +350,7 @@
|
||||
"./render/weather": "./src/render/weather.js",
|
||||
"./weather/effects": "./src/weatherEffectsMath.js",
|
||||
"./geo/screenCluster": "./src/geo/screenCluster.js",
|
||||
"./fleet": "./src/fleet/index.js",
|
||||
"./layers/wildlife-sightings": "./src/layers/wildlifeSightings/index.js",
|
||||
"./layers/wildlife-sightings/source": "./src/layers/wildlifeSightings/source.js"
|
||||
}
|
||||
|
||||
@@ -20,13 +20,31 @@
|
||||
* request runs at a time, with a pause between requests, and a refusal's
|
||||
* Retry-After is honoured.
|
||||
*
|
||||
* With `--tiles`, the same query between `--min-population` and
|
||||
* `--max-population` (1,000 and 15,000 by default) builds the detail tiles
|
||||
* instead, and writes only to:
|
||||
*
|
||||
* src/data/local_data/wikidata_places/
|
||||
*
|
||||
* replacing that folder's tiles, `index.json` and `files.js` (see
|
||||
* scripts/wikidataPlaceTiles.mjs). The checks that well-known cities are
|
||||
* present apply to the cities pack only.
|
||||
*
|
||||
* Usage:
|
||||
* node scripts/build-wikidata-cities.mjs [--min-population 15000]
|
||||
* node scripts/build-wikidata-cities.mjs --tiles [--min-population 1000] [--max-population 15000]
|
||||
*/
|
||||
|
||||
import { mkdir, writeFile } from 'node:fs/promises';
|
||||
import { mkdir, readdir, readFile, rm, writeFile } from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import {
|
||||
keepBuiltIfUnchanged,
|
||||
keepPackBuiltIfUnchanged,
|
||||
placeTileFiles,
|
||||
withoutCities,
|
||||
withoutNearTwins,
|
||||
} from './wikidataPlaceTiles.mjs';
|
||||
|
||||
const ENDPOINT = 'https://query.wikidata.org/sparql';
|
||||
const USER_AGENT =
|
||||
@@ -37,11 +55,23 @@ const LABEL_BATCH = 400;
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const flag = (name) =>
|
||||
args.includes(name) ? Number(args[args.indexOf(name) + 1]) : NaN;
|
||||
const minPopulation = flag('--min-population') || 15000;
|
||||
args.includes(name) ? Number(args[args.indexOf(name) + 1]) : undefined;
|
||||
const tilesMode = args.includes('--tiles');
|
||||
const minPopulation = flag('--min-population') ?? (tilesMode ? 1000 : 15000);
|
||||
const maxPopulation =
|
||||
flag('--max-population') ?? (tilesMode ? 15000 : Infinity);
|
||||
if (!(maxPopulation > minPopulation))
|
||||
throw new Error('--max-population must be above --min-population');
|
||||
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const outDir = path.join(root, 'src/data/local_data/wikidata_cities');
|
||||
const outDir = path.join(
|
||||
root,
|
||||
tilesMode
|
||||
? 'src/data/local_data/wikidata_places'
|
||||
: 'src/data/local_data/wikidata_cities',
|
||||
);
|
||||
|
||||
/** A file's text, or undefined when there is none yet. */
|
||||
const readIfThere = (file) => readFile(file, 'utf8').catch(() => undefined);
|
||||
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
const qid = (uri) => uri.slice(uri.lastIndexOf('/') + 1);
|
||||
|
||||
@@ -222,7 +252,7 @@ const grouped = new Set();
|
||||
const settled = new Set();
|
||||
|
||||
const places = new Map();
|
||||
for (const [low, high] of bands(minPopulation, Infinity)) {
|
||||
for (const [low, high] of bands(minPopulation, maxPopulation)) {
|
||||
console.log(`Population ${low}–${Number.isFinite(high) ? high : '∞'}…`);
|
||||
const rows = await bandRows(low, high);
|
||||
let kept = 0;
|
||||
@@ -434,7 +464,7 @@ if (intruders.length) {
|
||||
`Groupings got in: ${intruders.map(([id, name]) => `${name} (${id})`).join(', ')}`,
|
||||
);
|
||||
}
|
||||
if (missing.length) {
|
||||
if (missing.length && !tilesMode) {
|
||||
throw new Error(
|
||||
`Expected cities are missing: ${missing.map(([id, name]) => `${name} (${id})`).join(', ')}`,
|
||||
);
|
||||
@@ -450,6 +480,53 @@ const meta = {
|
||||
};
|
||||
|
||||
await mkdir(outDir, { recursive: true });
|
||||
if (tilesMode) {
|
||||
// Places the cities pack already has stay out of the tiles: an item with
|
||||
// one stated population under the cut-off and another over it is in both
|
||||
// query ranges. Build the cities pack first.
|
||||
const citiesFile = path.join(
|
||||
root,
|
||||
'src/data/local_data/wikidata_cities/cities.json',
|
||||
);
|
||||
const cityIds = JSON.parse(await readFile(citiesFile, 'utf8')).rows.map(
|
||||
(row) => row[5],
|
||||
);
|
||||
const outsideCities = withoutCities(rows, cityIds);
|
||||
console.log(
|
||||
`${rows.length - outsideCities.length} places left to the cities pack`,
|
||||
);
|
||||
// One place listed twice nearby under one name keeps its larger listing.
|
||||
const tileRows = withoutNearTwins(outsideCities);
|
||||
console.log(`${outsideCities.length - tileRows.length} near twins left out`);
|
||||
const files = placeTileFiles(tileRows, {
|
||||
...meta,
|
||||
count: tileRows.length,
|
||||
maxPopulation,
|
||||
});
|
||||
// The new files are all written before tiles from an earlier build that
|
||||
// this one has no rows for go, so a build that stops part way never leaves
|
||||
// an index naming a removed tile.
|
||||
const earlier = new Map();
|
||||
for (const name of await readdir(outDir))
|
||||
if (/^-?\d+_-?\d+\.json$|^index\.json$|^files\.js$/.test(name))
|
||||
earlier.set(name, await readFile(path.join(outDir, name), 'utf8'));
|
||||
keepPackBuiltIfUnchanged(files, earlier);
|
||||
for (const [name, text] of files)
|
||||
await writeFile(path.join(outDir, name), text);
|
||||
for (const name of await readdir(outDir))
|
||||
if (/^-?\d+_-?\d+\.json$/.test(name) && !files.has(name))
|
||||
await rm(path.join(outDir, name));
|
||||
console.log(
|
||||
`Wrote ${tileRows.length} places in ${files.size - 2} tiles to ${path.relative(root, outDir)}`,
|
||||
);
|
||||
process.exit(0);
|
||||
}
|
||||
const file = path.join(outDir, 'cities.json');
|
||||
await writeFile(file, `${JSON.stringify({ meta, rows })}\n`);
|
||||
await writeFile(
|
||||
file,
|
||||
keepBuiltIfUnchanged(
|
||||
`${JSON.stringify({ meta, rows })}\n`,
|
||||
await readIfThere(file),
|
||||
),
|
||||
);
|
||||
console.log(`Wrote ${rows.length} places to ${path.relative(root, file)}`);
|
||||
@@ -227,6 +227,7 @@
|
||||
"src/ui/panelMeasurement.js",
|
||||
"src/ui/panelRailGeometry.js",
|
||||
"src/ui/panelRails.test.mjs",
|
||||
"src/ui/hudSonarStyle.test.mjs",
|
||||
"src/panelStackLayout.js",
|
||||
"src/ui/applicationShortcuts.js",
|
||||
"src/ui/styleParameters.js",
|
||||
@@ -296,6 +297,9 @@
|
||||
"src/ui/contextControls.js",
|
||||
"src/ui/contextControls.test.mjs",
|
||||
"src/ui/contextLayerChanges.js",
|
||||
"src/ui/spaceMissionsControls.js",
|
||||
"src/ui/spaceMissionsControls.test.mjs",
|
||||
"src/ui/stores/spaceMissions.js",
|
||||
"src/ui/contextPresentation.js",
|
||||
"src/ui/contextSession.js",
|
||||
"src/ui/contextSubscriptions.js",
|
||||
@@ -437,6 +441,12 @@
|
||||
"src/layers/earthquakes/model.js",
|
||||
"src/layers/earthquakes/source.js",
|
||||
"src/layers/earthquakes/ownership.test.mjs",
|
||||
"src/layers/earthquakes/selection.test.mjs",
|
||||
"src/layers/submarineCables/interaction.test.mjs",
|
||||
"src/ui/entityContextBridge.test.mjs",
|
||||
"src/layers/launches/clickYield.test.mjs",
|
||||
"src/app/layers/earthquakeRipples.js",
|
||||
"src/app/layers/earthquakeRipples.test.mjs",
|
||||
"src/layers/perimeters/index.js",
|
||||
"src/layers/perimeters/records.js",
|
||||
"src/layers/perimeters/source.js",
|
||||
@@ -520,6 +530,10 @@
|
||||
"src/layers/launches/source.test.mjs",
|
||||
"src/layers/launches/ingestion.test.mjs",
|
||||
"src/layers/launches/failedEntry.test.mjs",
|
||||
"src/layers/launches/labelClick.test.mjs",
|
||||
"src/layers/launches/missionCycler.test.mjs",
|
||||
"src/layers/launches/satelliteIntents.js",
|
||||
"src/layers/launches/satelliteIntents.test.mjs",
|
||||
"src/layers/installations/lifecycle.js",
|
||||
"src/layers/installations/viewport.js",
|
||||
"src/layers/installations/controls.js",
|
||||
@@ -652,6 +666,7 @@
|
||||
"src/layers/alpr/model.js",
|
||||
"src/layers/alpr/policy.js",
|
||||
"src/layers/alpr/presentation.js",
|
||||
"src/layers/alpr/presentation.test.mjs",
|
||||
"src/layers/alpr/visuals.js",
|
||||
"src/layers/alpr/overlay.js",
|
||||
"src/layers/alpr/overlay.test.mjs",
|
||||
@@ -1313,6 +1328,23 @@
|
||||
"src/ui/kit/UiBadge.vue",
|
||||
"src/ui/kit/UiBadge.test.mjs",
|
||||
"src/ui/kit/UiEmpty.vue",
|
||||
"src/ui/kit/kitStyles.test.mjs",
|
||||
"src/ui/kit/UiCloseButton.vue",
|
||||
"src/ui/kit/UiCloseButton.test.mjs",
|
||||
"src/ui/kit/closeButtons.test.mjs",
|
||||
"src/ui/styles/close-button.css",
|
||||
"src/ui/kit/UiSearchField.vue",
|
||||
"src/ui/kit/UiSearchField.test.mjs",
|
||||
"src/ui/styles/search-field.css",
|
||||
"src/ui/kit/UiCheckbox.vue",
|
||||
"src/ui/kit/UiCheckbox.test.mjs",
|
||||
"src/ui/kit/checkboxes.test.mjs",
|
||||
"src/ui/styles/checkbox.css",
|
||||
"src/ui/kit/UiDialog.vue",
|
||||
"src/ui/kit/UiDialog.test.mjs",
|
||||
"src/ui/kit/dialogs.test.mjs",
|
||||
"src/ui/styles/chip.css",
|
||||
"src/ui/styles/empty-state.css",
|
||||
"src/ui/rail/RailChips.vue",
|
||||
"src/ui/displayPanelActions.test.mjs",
|
||||
"src/testSupport/vueDom.mjs",
|
||||
@@ -1476,7 +1508,7 @@
|
||||
"src/overlays/worldOverlayDraw.test.mjs",
|
||||
"src/sources/rateLimit.js",
|
||||
"src/ui/layerNames.js",
|
||||
"src/ui/styles/cyber.css",
|
||||
"src/ui/styles/sonar.css",
|
||||
"src/voice/layerManifest.js",
|
||||
"src/worldFocus.js",
|
||||
"src/worldFocus.test.mjs",
|
||||
@@ -1550,6 +1582,8 @@
|
||||
"dev/stub-app/main.js",
|
||||
"scripts/qa-stub-boot.mjs",
|
||||
"src/ui/creditsView.js",
|
||||
"src/ui/creditLineHeight.js",
|
||||
"src/ui/creditLineHeight.test.mjs",
|
||||
"src/ui/creditsView.test.mjs",
|
||||
"src/cockpitSubjectProviders.js",
|
||||
"src/cockpitSubjectProviders.test.mjs",
|
||||
@@ -1583,5 +1617,18 @@
|
||||
"src/ui/layerFinder.test.mjs",
|
||||
"src/data/wikidataCities.js",
|
||||
"src/data/wikidataCities.test.mjs",
|
||||
"scripts/build-wikidata-cities.mjs"
|
||||
"scripts/build-wikidata-cities.mjs",
|
||||
"src/search/bip39Words.js",
|
||||
"src/search/placeSuggestions.test.mjs",
|
||||
"scripts/wikidataPlaceTiles.mjs",
|
||||
"src/tooling/wikidataPlaceTiles.test.mjs",
|
||||
"src/ui/omnibarIntent.test.mjs",
|
||||
"src/ui/omnibarRows.test.mjs",
|
||||
"src/ui/styles/omnibar-dock.css",
|
||||
"src/ui/styles/guide.css",
|
||||
"src/ui/commandDock.test.mjs",
|
||||
"src/layers/firms/selection.test.mjs",
|
||||
"src/layers/vessels/selection.test.mjs",
|
||||
"src/layers/bikeshare/selection.test.mjs",
|
||||
"src/layers/satellites/interaction.test.mjs"
|
||||
]
|
||||
@@ -130,6 +130,7 @@
|
||||
"src/ui/radioTunerModel.js",
|
||||
"src/ui/views/panels/MissionDetail.vue",
|
||||
"src/ui/views/panels/MissionRoster.vue",
|
||||
"src/ui/views/panels/SpaceMissionsPanel.vue",
|
||||
"src/ui/views/panels/AwarenessPanel.vue",
|
||||
"src/ui/views/panels/AwarenessNames.vue",
|
||||
"src/ui/views/DisplayControlsView.vue",
|
||||
@@ -163,6 +164,7 @@
|
||||
"src/ui/stores/cctv.js",
|
||||
"src/ui/stores/radio.js",
|
||||
"src/ui/stores/context.js",
|
||||
"src/ui/stores/spaceMissions.js",
|
||||
"src/ui/stores/cockpit.js",
|
||||
"src/ui/stores/locale.js",
|
||||
"src/ui/stores/providerSettings.js",
|
||||
@@ -239,6 +241,10 @@
|
||||
"src/ui/kit/UiSelect.js",
|
||||
"src/ui/kit/UiEmpty.vue",
|
||||
"src/ui/kit/UiBadge.vue",
|
||||
"src/ui/kit/UiCloseButton.vue",
|
||||
"src/ui/kit/UiSearchField.vue",
|
||||
"src/ui/kit/UiCheckbox.vue",
|
||||
"src/ui/kit/UiDialog.vue",
|
||||
"src/ui/stores/globeActions.js",
|
||||
"src/ui/views/panels/GlobeActions.vue",
|
||||
"src/ui/views/panels/RenderFailure.vue",
|
||||
@@ -287,7 +293,26 @@
|
||||
"src/data/vesselTypes.js",
|
||||
"src/data/fleetModels.js",
|
||||
"src/render/modelParts.js",
|
||||
"src/ui/views/panels/AircraftModelHero.vue"
|
||||
"src/ui/views/panels/AircraftModelHero.vue",
|
||||
"src/data/retryableLoad.js",
|
||||
"src/data/local_data/wikidata_places/files.js",
|
||||
"src/ui/views/panels/Omnibar.vue",
|
||||
"src/exclusiveSurfaces.js",
|
||||
"src/geoDistance.js",
|
||||
"src/ui/omnibarGuide.js",
|
||||
"src/cityPois.js",
|
||||
"src/search/photonSetting.js",
|
||||
"src/sources/requestDeadline.js",
|
||||
"src/ui/omnibarEnter.js",
|
||||
"src/ui/omnibarIntent.js",
|
||||
"src/data/placeNames.js",
|
||||
"src/search/plusCode.js",
|
||||
"src/keylessGeocoder.js",
|
||||
"src/ui/omnibarRows.js",
|
||||
"src/search/gridReference.js",
|
||||
"src/search/coordinateParser.js",
|
||||
"src/search/placeSuggestions.js",
|
||||
"src/search/bip39Words.js"
|
||||
],
|
||||
"external": ["vue", "pinia", "vue-i18n"]
|
||||
},
|
||||
@@ -818,7 +843,6 @@
|
||||
"exports": ["./ui/layout"],
|
||||
"modules": [
|
||||
"src/ui/panelRails.js",
|
||||
"src/ui/displayPanelScroll.js",
|
||||
"src/ui/leftPanelRail.js",
|
||||
"src/ui/rightPanelRail.js",
|
||||
"src/ui/panelMeasurement.js",
|
||||
@@ -994,6 +1018,8 @@
|
||||
"src/ui/kit/UiSelect.js",
|
||||
"src/ui/kit/UiButton.vue",
|
||||
"src/ui/kit/UiBadge.vue",
|
||||
"src/ui/kit/UiCloseButton.vue",
|
||||
"src/ui/kit/UiIcon.vue",
|
||||
"src/ui/rail/fieldValue.js",
|
||||
"src/ui/kit/UiSlider.js",
|
||||
"src/ui/kit/UiSegmented.vue"
|
||||
@@ -1193,7 +1219,6 @@
|
||||
"src/ui/cockpitController.js",
|
||||
"src/data/followed.js",
|
||||
"src/ui/cockpitDisplayPortal.js",
|
||||
"src/ui/displayPanelScroll.js",
|
||||
"src/ui/cockpitInput.js",
|
||||
"src/ui/cockpitInstruments.js",
|
||||
"src/cockpitSubjectProviders.js",
|
||||
@@ -1416,7 +1441,6 @@
|
||||
"src/ui/cockpitContext.js",
|
||||
"src/ui/cockpitController.js",
|
||||
"src/ui/cockpitDisplayPortal.js",
|
||||
"src/ui/displayPanelScroll.js",
|
||||
"src/ui/cockpitInput.js",
|
||||
"src/ui/cockpitInstruments.js",
|
||||
"src/cockpitSubjectProviders.js",
|
||||
@@ -1434,6 +1458,7 @@
|
||||
"src/ui/contextSession.js",
|
||||
"src/ui/contextSubscriptions.js",
|
||||
"src/ui/contextTransactions.js",
|
||||
"src/ui/spaceMissionsControls.js",
|
||||
"src/ui/displayControls.js",
|
||||
"src/ui/effects.js",
|
||||
"src/ui/frameRateMonitor.js",
|
||||
@@ -1562,6 +1587,7 @@
|
||||
"src/ui/stores/cctv.js",
|
||||
"src/ui/stores/radio.js",
|
||||
"src/ui/stores/context.js",
|
||||
"src/ui/stores/spaceMissions.js",
|
||||
"src/ui/stores/cockpit.js",
|
||||
"src/ui/stores/locale.js",
|
||||
"src/ui/stores/providerSettings.js",
|
||||
@@ -1582,6 +1608,7 @@
|
||||
"src/ui/kit/UiSlider.js",
|
||||
"src/ui/kit/UiButton.vue",
|
||||
"src/ui/kit/UiBadge.vue",
|
||||
"src/ui/kit/UiCloseButton.vue",
|
||||
"src/ui/stores/globeActions.js",
|
||||
"src/ui/stores/recording.js",
|
||||
"src/ui/i18n.js",
|
||||
@@ -1655,7 +1682,8 @@
|
||||
"src/ui/entityContextBridge.js",
|
||||
"src/data/trackingClickGesture.js",
|
||||
"src/ui/stores/sceneSharing.js",
|
||||
"src/maps/attribution.js"
|
||||
"src/maps/attribution.js",
|
||||
"src/data/dataCredits.js"
|
||||
],
|
||||
"external": [
|
||||
"cesium",
|
||||
@@ -1888,6 +1916,7 @@
|
||||
"src/data/vesselTypes.js",
|
||||
"src/data/fleetTrailAnchors.js",
|
||||
"src/data/fleetModelInstances.js",
|
||||
"src/data/fleetModelDraw.js",
|
||||
"src/data/modelPartDrivers.js",
|
||||
"src/data/headingDegrees.js",
|
||||
"src/i18n/marker.js",
|
||||
@@ -2039,6 +2068,7 @@
|
||||
"src/data/vesselTypes.js",
|
||||
"src/data/fleetTrailAnchors.js",
|
||||
"src/data/fleetModelInstances.js",
|
||||
"src/data/fleetModelDraw.js",
|
||||
"src/data/modelPartDrivers.js",
|
||||
"src/data/headingDegrees.js",
|
||||
"src/i18n/marker.js",
|
||||
@@ -2222,6 +2252,7 @@
|
||||
"src/data/aircraftClass.js",
|
||||
"src/i18n/marker.js",
|
||||
"src/data/fleetModelInstances.js",
|
||||
"src/data/fleetModelDraw.js",
|
||||
"src/data/modelPartDrivers.js",
|
||||
"src/data/aircraftModelLighting.js",
|
||||
"src/data/modelEligibility.js",
|
||||
@@ -2567,7 +2598,8 @@
|
||||
"src/layers/earthquakes/model.js",
|
||||
"src/layers/earthquakes/source.js",
|
||||
"src/layers/earthquakes/records.js",
|
||||
"src/time/worldClock.js"
|
||||
"src/time/worldClock.js",
|
||||
"src/data/trackingClickGesture.js"
|
||||
],
|
||||
"external": ["cesium"]
|
||||
},
|
||||
@@ -2856,6 +2888,7 @@
|
||||
"src/data/entityRecords.js",
|
||||
"src/render/cesium/follow.js",
|
||||
"src/layers/launches/ingestion.js",
|
||||
"src/layers/launches/satelliteIntents.js",
|
||||
"src/layers/launches/launchPad.js",
|
||||
"src/layers/launches/lifecycle.js",
|
||||
"src/layers/launches/model.js",
|
||||
@@ -4118,6 +4151,7 @@
|
||||
"src/render/modelParts.js",
|
||||
"src/data/fleetTrailAnchors.js",
|
||||
"src/data/fleetModelInstances.js",
|
||||
"src/data/fleetModelDraw.js",
|
||||
"src/app/layers/fleetModels.js",
|
||||
"src/sources/adsbFields.js",
|
||||
"src/data/headingDegrees.js",
|
||||
@@ -4164,6 +4198,7 @@
|
||||
"src/app/layers/bikeshare.js",
|
||||
"src/app/layers/cctv.js",
|
||||
"src/app/layers/cyclones.js",
|
||||
"src/app/layers/earthquakeRipples.js",
|
||||
"src/app/layers/earthquakes.js",
|
||||
"src/app/layers/firms.js",
|
||||
"src/app/layers/flights.js",
|
||||
@@ -4514,6 +4549,7 @@
|
||||
"src/layers/launches/controls.js",
|
||||
"src/layers/launches/index.js",
|
||||
"src/layers/launches/ingestion.js",
|
||||
"src/layers/launches/satelliteIntents.js",
|
||||
"src/layers/launches/launchPad.js",
|
||||
"src/layers/launches/lifecycle.js",
|
||||
"src/layers/launches/model.js",
|
||||
@@ -4727,7 +4763,6 @@
|
||||
"src/ui/cockpitContext.js",
|
||||
"src/ui/cockpitController.js",
|
||||
"src/ui/cockpitDisplayPortal.js",
|
||||
"src/ui/displayPanelScroll.js",
|
||||
"src/ui/cockpitInput.js",
|
||||
"src/ui/cockpitInstruments.js",
|
||||
"src/cockpitSubjectProviders.js",
|
||||
@@ -4746,6 +4781,7 @@
|
||||
"src/ui/contextSession.js",
|
||||
"src/ui/contextSubscriptions.js",
|
||||
"src/ui/contextTransactions.js",
|
||||
"src/ui/spaceMissionsControls.js",
|
||||
"src/ui/displayControls.js",
|
||||
"src/ui/effects.js",
|
||||
"src/ui/frameRateMonitor.js",
|
||||
@@ -5308,6 +5344,7 @@
|
||||
"src/ui/stores/cctv.js",
|
||||
"src/ui/stores/radio.js",
|
||||
"src/ui/stores/context.js",
|
||||
"src/ui/stores/spaceMissions.js",
|
||||
"src/ui/stores/cockpit.js",
|
||||
"src/ui/stores/locale.js",
|
||||
"src/ui/stores/providerSettings.js",
|
||||
@@ -5340,6 +5377,7 @@
|
||||
"src/ui/kit/UiButton.vue",
|
||||
"src/ui/kit/UiEmpty.vue",
|
||||
"src/ui/kit/UiBadge.vue",
|
||||
"src/ui/kit/UiCloseButton.vue",
|
||||
"src/ui/stores/globeActions.js",
|
||||
"src/ui/stores/recording.js",
|
||||
"src/ui/i18n.js",
|
||||
@@ -5448,6 +5486,7 @@
|
||||
"src/render/applicationHooks.js",
|
||||
"src/maps/globeEngine.js",
|
||||
"src/render/cesium/viewers.js",
|
||||
"src/ui/creditLineHeight.js",
|
||||
"src/ui/creditsView.js",
|
||||
"src/data/planespottersPhoto.js",
|
||||
"src/maps/keylessTerrain.js",
|
||||
@@ -5519,6 +5558,7 @@
|
||||
"src/data/fleetModels.js",
|
||||
"src/data/fleetTrailAnchors.js",
|
||||
"src/data/fleetModelInstances.js",
|
||||
"src/data/fleetModelDraw.js",
|
||||
"src/app/layers/fleetModels.js",
|
||||
"src/data/feedState.js",
|
||||
"src/loadingFeedback.js",
|
||||
@@ -5576,6 +5616,7 @@
|
||||
"src/app/layers/bikeshare.js",
|
||||
"src/app/layers/cctv.js",
|
||||
"src/app/layers/cyclones.js",
|
||||
"src/app/layers/earthquakeRipples.js",
|
||||
"src/app/layers/earthquakes.js",
|
||||
"src/app/layers/firms.js",
|
||||
"src/app/layers/flights.js",
|
||||
@@ -5795,6 +5836,7 @@
|
||||
"src/layers/launches/controls.js",
|
||||
"src/layers/launches/index.js",
|
||||
"src/layers/launches/ingestion.js",
|
||||
"src/layers/launches/satelliteIntents.js",
|
||||
"src/layers/launches/launchPad.js",
|
||||
"src/layers/launches/lifecycle.js",
|
||||
"src/layers/launches/model.js",
|
||||
@@ -6674,7 +6716,6 @@
|
||||
"ui-panel-chrome": {
|
||||
"exports": ["./ui/panel-chrome"],
|
||||
"modules": [
|
||||
"src/ui/displayPanelScroll.js",
|
||||
"src/ui/radioPanelPlacement.js",
|
||||
"src/panelStackLayout.js",
|
||||
"src/ui/leftPanelRail.js",
|
||||
@@ -7260,6 +7301,7 @@
|
||||
"src/data/aircraftClass.js",
|
||||
"src/i18n/marker.js",
|
||||
"src/data/fleetModelInstances.js",
|
||||
"src/data/fleetModelDraw.js",
|
||||
"src/data/modelPartDrivers.js",
|
||||
"src/data/modelEligibility.js",
|
||||
"src/data/fleetTrailAnchors.js",
|
||||
@@ -7413,6 +7455,7 @@
|
||||
"src/render/modelParts.js",
|
||||
"src/data/vesselTypes.js",
|
||||
"src/data/fleetModelInstances.js",
|
||||
"src/data/fleetModelDraw.js",
|
||||
"src/data/modelPartDrivers.js",
|
||||
"src/data/aircraftClass.js",
|
||||
"src/data/aircraftModelLighting.js",
|
||||
@@ -8190,6 +8233,28 @@
|
||||
],
|
||||
"external": []
|
||||
},
|
||||
"fleet": {
|
||||
"exports": ["./fleet"],
|
||||
"modules": [
|
||||
"src/fleet/index.js",
|
||||
"src/data/fleetModels.js",
|
||||
"src/data/aircraftClass.js",
|
||||
"src/i18n/marker.js",
|
||||
"src/render/modelParts.js",
|
||||
"src/data/fleetTrailAnchors.js",
|
||||
"src/data/vesselTypes.js",
|
||||
"src/layers/flights/modelSpec.js",
|
||||
"src/layers/flights/policy.js",
|
||||
"src/data/aircraftEmergency.js",
|
||||
"src/render/color.js",
|
||||
"src/data/aircraftModelLighting.js",
|
||||
"src/data/modelPartDrivers.js",
|
||||
"src/data/modelEligibility.js",
|
||||
"src/data/fleetModelDraw.js",
|
||||
"src/data/vesselSprites.js"
|
||||
],
|
||||
"external": []
|
||||
},
|
||||
"sky": {
|
||||
"exports": ["./sky"],
|
||||
"modules": [
|
||||
|
||||
+108
-382
@@ -193,41 +193,74 @@ try {
|
||||
});
|
||||
const contactMissionHandoff = await page.evaluate(async () => {
|
||||
const { styleManager, dataManager } = window.__godsEyeView;
|
||||
// Launch Library is not contacted: the layer's own work is stubbed so the
|
||||
// check covers only how Space Missions sits beside Context.
|
||||
const stubMissions = (rocketEntry) => {
|
||||
const original = {
|
||||
initialized: rocketEntry.initialized,
|
||||
lifecycleState: rocketEntry.lifecycleState,
|
||||
init: rocketEntry.module.init,
|
||||
enable: rocketEntry.module.enable,
|
||||
update: rocketEntry.module.update,
|
||||
disable: rocketEntry.module.disable,
|
||||
};
|
||||
rocketEntry.initialized = true;
|
||||
rocketEntry.module.init = async () => true;
|
||||
rocketEntry.module.enable = async () => true;
|
||||
rocketEntry.module.update = async () => true;
|
||||
rocketEntry.module.disable = async () => true;
|
||||
return () => {
|
||||
rocketEntry.initialized = original.initialized;
|
||||
rocketEntry.lifecycleState = original.lifecycleState;
|
||||
rocketEntry.module.init = original.init;
|
||||
rocketEntry.module.enable = original.enable;
|
||||
rocketEntry.module.update = original.update;
|
||||
rocketEntry.module.disable = original.disable;
|
||||
};
|
||||
};
|
||||
const originalShowToast = styleManager._showToast;
|
||||
const toasts = [];
|
||||
styleManager._showToast = (message) => { toasts.push(String(message)); };
|
||||
const restoreMissions = stubMissions(dataManager.layers.get('rocket-launches'));
|
||||
try {
|
||||
if (styleManager._contextControls._contextMode) await styleManager._contextControls._selectContextMode(null);
|
||||
const contactsResult = await styleManager._contextControls._selectContextMode('flights');
|
||||
const missionResult = await styleManager._contextControls._selectContextMode('space-missions');
|
||||
const switched = {
|
||||
const missionResult = await dataManager.setEnabled('rocket-launches', true, { origin: 'user' });
|
||||
await styleManager._waitForContextLayerSettlement();
|
||||
const together = {
|
||||
contactsResult,
|
||||
missionResult,
|
||||
mode: styleManager._contextControls._contextMode,
|
||||
missionsEnabled: dataManager.isEnabled('rocket-launches'),
|
||||
toasts: [...toasts],
|
||||
};
|
||||
const missionOff = await dataManager.setEnabled('rocket-launches', false, { origin: 'user' });
|
||||
await styleManager._waitForContextLayerSettlement();
|
||||
const modeAfterMissions = styleManager._contextControls._contextMode;
|
||||
const exitResult = await styleManager._contextControls._selectContextMode(null);
|
||||
return {
|
||||
...switched,
|
||||
...together,
|
||||
missionOff,
|
||||
modeAfterMissions,
|
||||
exitResult,
|
||||
modeAfterExit: styleManager._contextControls._contextMode,
|
||||
missionsOffAfterExit: !dataManager.isEffectivelyEnabled('rocket-launches'),
|
||||
};
|
||||
} finally {
|
||||
restoreMissions();
|
||||
styleManager._showToast = originalShowToast;
|
||||
}
|
||||
});
|
||||
check(
|
||||
'Contacts hands off to Space Missions on the first request without a failure toast',
|
||||
'Space Missions runs beside Contacts, and switching it off leaves Contacts on',
|
||||
contactMissionHandoff.contactsResult === true
|
||||
&& contactMissionHandoff.missionResult === true
|
||||
&& contactMissionHandoff.mode === 'space-missions'
|
||||
&& contactMissionHandoff.mode === 'flights'
|
||||
&& contactMissionHandoff.missionsEnabled
|
||||
&& contactMissionHandoff.toasts?.length === 0
|
||||
&& contactMissionHandoff.missionOff === true
|
||||
&& contactMissionHandoff.modeAfterMissions === 'flights'
|
||||
&& contactMissionHandoff.exitResult === true
|
||||
&& contactMissionHandoff.modeAfterExit === null
|
||||
&& contactMissionHandoff.missionsOffAfterExit,
|
||||
&& contactMissionHandoff.modeAfterExit === null,
|
||||
JSON.stringify(contactMissionHandoff),
|
||||
);
|
||||
const cancelledMissionEntry = await page.evaluate(async () => {
|
||||
@@ -330,7 +363,7 @@ try {
|
||||
}
|
||||
});
|
||||
check(
|
||||
'cancelled direct Space Missions entry restores its exact isolated sibling state',
|
||||
'a cancelled Space Missions start leaves its sibling layer on and opens no Context session',
|
||||
cancelledMissionEntry.exercised
|
||||
&& cancelledMissionEntry.transitionResult === false
|
||||
&& !cancelledMissionEntry.timedOut
|
||||
@@ -341,214 +374,45 @@ try {
|
||||
JSON.stringify(cancelledMissionEntry),
|
||||
);
|
||||
check(
|
||||
'successful Space Missions cancellation rollback stays silent',
|
||||
'a cancelled Space Missions start stays silent',
|
||||
cancelledMissionEntry.exercised && cancelledMissionEntry.toasts?.length === 0,
|
||||
JSON.stringify(cancelledMissionEntry.toasts || []),
|
||||
);
|
||||
const replacementMissionEntry = await page.evaluate(async () => {
|
||||
const styleManager = window.__godsEyeView.styleManager;
|
||||
const dataManager = window.__godsEyeView.dataManager;
|
||||
const rocketEntry = dataManager.layers.get('rocket-launches');
|
||||
if (!rocketEntry || dataManager.isEffectivelyEnabled('rocket-launches')) {
|
||||
return { exercised: false, reason: 'Space Missions was not in a clean OFF state' };
|
||||
}
|
||||
const siblingId = 'qa-cockpit-replacement-sibling';
|
||||
window.__gevQaRegisterLayer(dataManager, {
|
||||
id: siblingId,
|
||||
name: 'QA replacement sibling',
|
||||
icon: 'science',
|
||||
source: 'QA',
|
||||
updateInterval: -1,
|
||||
async init() { return true; },
|
||||
async enable() { return true; },
|
||||
async update() { return true; },
|
||||
async disable() { return true; },
|
||||
async destroy() {},
|
||||
getStats() { return { count: 1, status: 'live' }; },
|
||||
});
|
||||
await dataManager.setEnabled(siblingId, true, { origin: 'programmatic' });
|
||||
const original = {
|
||||
siblingInitialized: dataManager.layers.get(siblingId)?.initialized,
|
||||
initialized: rocketEntry.initialized,
|
||||
lifecycleState: rocketEntry.lifecycleState,
|
||||
init: rocketEntry.module.init,
|
||||
enable: rocketEntry.module.enable,
|
||||
update: rocketEntry.module.update,
|
||||
disable: rocketEntry.module.disable,
|
||||
showToast: styleManager._showToast,
|
||||
};
|
||||
let firstUpdate = true;
|
||||
let releaseUpdate;
|
||||
let markUpdateStarted;
|
||||
const updateStarted = new Promise((resolve) => { markUpdateStarted = resolve; });
|
||||
const updateGate = new Promise((resolve) => { releaseUpdate = resolve; });
|
||||
const toasts = [];
|
||||
rocketEntry.initialized = true;
|
||||
rocketEntry.module.enable = async () => true;
|
||||
rocketEntry.module.update = async () => {
|
||||
if (!firstUpdate) return true;
|
||||
firstUpdate = false;
|
||||
markUpdateStarted();
|
||||
await updateGate;
|
||||
return true;
|
||||
};
|
||||
rocketEntry.module.disable = async () => true;
|
||||
styleManager._showToast = (message) => { toasts.push(String(message)); };
|
||||
try {
|
||||
const entry = styleManager._contextControls._selectContextMode('space-missions');
|
||||
await updateStarted;
|
||||
const replacement = dataManager.setEnabled('rocket-launches', true, { origin: 'programmatic' });
|
||||
releaseUpdate();
|
||||
const [entryResult, replacementResult] = await Promise.all([entry, replacement]);
|
||||
const committed = {
|
||||
entryResult,
|
||||
replacementResult,
|
||||
mode: styleManager._contextControls._contextMode,
|
||||
entering: styleManager._contextControls._contextModeEntering,
|
||||
snapshotRetained: Boolean(styleManager._contextControls._contextSessionSnapshot),
|
||||
siblingIsolated: !dataManager.isEffectivelyEnabled(siblingId),
|
||||
missionEnabled: dataManager.isEnabled('rocket-launches'),
|
||||
missionEffective: dataManager.isEffectivelyEnabled('rocket-launches'),
|
||||
toasts: [...toasts],
|
||||
};
|
||||
const exitResult = await styleManager._contextControls._selectContextMode(null);
|
||||
return {
|
||||
exercised: true,
|
||||
...committed,
|
||||
exitResult,
|
||||
siblingRestored: dataManager.isEnabled(siblingId),
|
||||
missionRestoredOff: !dataManager.isEffectivelyEnabled('rocket-launches'),
|
||||
};
|
||||
} finally {
|
||||
styleManager._showToast = original.showToast;
|
||||
rocketEntry.module.init = original.init;
|
||||
rocketEntry.module.enable = original.enable;
|
||||
rocketEntry.module.update = original.update;
|
||||
rocketEntry.module.disable = original.disable;
|
||||
rocketEntry.initialized = original.initialized;
|
||||
rocketEntry.lifecycleState = original.lifecycleState;
|
||||
await dataManager.setEnabled(siblingId, false, { origin: 'programmatic' });
|
||||
await window.__gevQaUnregisterLayer(dataManager, siblingId);
|
||||
}
|
||||
});
|
||||
check(
|
||||
'right-rail Space Missions adopts a newer authoritative ON without stale restoration',
|
||||
replacementMissionEntry.exercised
|
||||
&& replacementMissionEntry.entryResult === true
|
||||
&& replacementMissionEntry.replacementResult === true
|
||||
&& replacementMissionEntry.mode === 'space-missions'
|
||||
&& replacementMissionEntry.entering === null
|
||||
&& replacementMissionEntry.snapshotRetained
|
||||
&& replacementMissionEntry.siblingIsolated
|
||||
&& replacementMissionEntry.missionEnabled
|
||||
&& replacementMissionEntry.missionEffective
|
||||
&& replacementMissionEntry.toasts?.length === 0
|
||||
&& replacementMissionEntry.exitResult === true
|
||||
&& replacementMissionEntry.siblingRestored
|
||||
&& replacementMissionEntry.missionRestoredOff,
|
||||
JSON.stringify(replacementMissionEntry),
|
||||
);
|
||||
const supersededMissionEntry = await page.evaluate(async () => {
|
||||
const styleManager = window.__godsEyeView.styleManager;
|
||||
const dataManager = window.__godsEyeView.dataManager;
|
||||
const rocketEntry = dataManager.layers.get('rocket-launches');
|
||||
if (!rocketEntry || dataManager.isEffectivelyEnabled('rocket-launches')) {
|
||||
return { exercised: false, reason: 'Space Missions was not in a clean OFF state' };
|
||||
}
|
||||
const siblingId = 'qa-cockpit-superseded-sibling';
|
||||
window.__gevQaRegisterLayer(dataManager, {
|
||||
id: siblingId,
|
||||
name: 'QA superseded sibling',
|
||||
icon: 'science',
|
||||
source: 'QA',
|
||||
updateInterval: -1,
|
||||
async init() { return true; },
|
||||
async enable() { return true; },
|
||||
async update() { return true; },
|
||||
async disable() { return true; },
|
||||
async destroy() {},
|
||||
getStats() { return { count: 1, status: 'live' }; },
|
||||
});
|
||||
await dataManager.setEnabled(siblingId, true, { origin: 'programmatic' });
|
||||
const original = {
|
||||
initialized: rocketEntry.initialized,
|
||||
lifecycleState: rocketEntry.lifecycleState,
|
||||
init: rocketEntry.module.init,
|
||||
enable: rocketEntry.module.enable,
|
||||
update: rocketEntry.module.update,
|
||||
disable: rocketEntry.module.disable,
|
||||
showToast: styleManager._showToast,
|
||||
};
|
||||
let releaseUpdate;
|
||||
let markUpdateStarted;
|
||||
const updateStarted = new Promise((resolve) => { markUpdateStarted = resolve; });
|
||||
const updateGate = new Promise((resolve) => { releaseUpdate = resolve; });
|
||||
const toasts = [];
|
||||
rocketEntry.initialized = true;
|
||||
rocketEntry.module.enable = async () => true;
|
||||
rocketEntry.module.update = async () => {
|
||||
markUpdateStarted();
|
||||
await updateGate;
|
||||
return true;
|
||||
};
|
||||
rocketEntry.module.disable = async () => true;
|
||||
styleManager._showToast = (message) => { toasts.push(String(message)); };
|
||||
try {
|
||||
const entry = styleManager._runUserFacingContextAction(
|
||||
(notificationToken) => styleManager._contextControls._selectContextMode(
|
||||
'space-missions',
|
||||
{ notificationToken },
|
||||
),
|
||||
'Space Missions could not complete the requested transition; try again',
|
||||
);
|
||||
await updateStarted;
|
||||
const supersedingOff = dataManager.setEnabled('rocket-launches', false, {
|
||||
origin: 'programmatic',
|
||||
});
|
||||
releaseUpdate();
|
||||
const [entryResult, offResult] = await Promise.all([entry, supersedingOff]);
|
||||
return {
|
||||
exercised: true,
|
||||
entryResult,
|
||||
offResult,
|
||||
mode: styleManager._contextControls._contextMode,
|
||||
entering: styleManager._contextControls._contextModeEntering,
|
||||
snapshotRetained: Boolean(styleManager._contextControls._contextSessionSnapshot),
|
||||
siblingRestored: dataManager.isEnabled(siblingId),
|
||||
missionEffective: dataManager.isEffectivelyEnabled('rocket-launches'),
|
||||
toasts,
|
||||
};
|
||||
} finally {
|
||||
styleManager._showToast = original.showToast;
|
||||
rocketEntry.module.init = original.init;
|
||||
rocketEntry.module.enable = original.enable;
|
||||
rocketEntry.module.update = original.update;
|
||||
rocketEntry.module.disable = original.disable;
|
||||
rocketEntry.initialized = original.initialized;
|
||||
rocketEntry.lifecycleState = original.lifecycleState;
|
||||
await dataManager.setEnabled(siblingId, false, { origin: 'programmatic' });
|
||||
await window.__gevQaUnregisterLayer(dataManager, siblingId);
|
||||
}
|
||||
});
|
||||
check(
|
||||
'right-rail Space Missions superseded by OFF restores exactly without a failure toast',
|
||||
supersededMissionEntry.exercised
|
||||
&& supersededMissionEntry.entryResult === null
|
||||
&& supersededMissionEntry.mode === null
|
||||
&& supersededMissionEntry.entering === null
|
||||
&& !supersededMissionEntry.snapshotRetained
|
||||
&& supersededMissionEntry.siblingRestored
|
||||
&& !supersededMissionEntry.missionEffective
|
||||
&& supersededMissionEntry.toasts?.length === 0,
|
||||
JSON.stringify(supersededMissionEntry),
|
||||
);
|
||||
const voiceMissionEntry = await page.evaluate(async () => {
|
||||
const ordinaryMissionLayer = await page.evaluate(async () => {
|
||||
const { dataManager, styleManager } = window.__godsEyeView;
|
||||
const siblingId = '__qa_voice_context_sibling__';
|
||||
const rocketEntry = dataManager.layers.get('rocket-launches');
|
||||
if (!rocketEntry || dataManager.isEffectivelyEnabled('rocket-launches')) {
|
||||
return { exercised: false, reason: 'Space Missions was not in a clean OFF state' };
|
||||
}
|
||||
// Launch Library is not contacted: the layer's own work is stubbed so the
|
||||
// check covers only how Space Missions sits beside Context.
|
||||
const stubMissions = (rocketEntry) => {
|
||||
const original = {
|
||||
initialized: rocketEntry.initialized,
|
||||
lifecycleState: rocketEntry.lifecycleState,
|
||||
init: rocketEntry.module.init,
|
||||
enable: rocketEntry.module.enable,
|
||||
update: rocketEntry.module.update,
|
||||
disable: rocketEntry.module.disable,
|
||||
};
|
||||
rocketEntry.initialized = true;
|
||||
rocketEntry.module.init = async () => true;
|
||||
rocketEntry.module.enable = async () => true;
|
||||
rocketEntry.module.update = async () => true;
|
||||
rocketEntry.module.disable = async () => true;
|
||||
return () => {
|
||||
rocketEntry.initialized = original.initialized;
|
||||
rocketEntry.lifecycleState = original.lifecycleState;
|
||||
rocketEntry.module.init = original.init;
|
||||
rocketEntry.module.enable = original.enable;
|
||||
rocketEntry.module.update = original.update;
|
||||
rocketEntry.module.disable = original.disable;
|
||||
};
|
||||
};
|
||||
const siblingId = '__qa_space_missions_sibling__';
|
||||
window.__gevQaRegisterLayer(dataManager, {
|
||||
id: siblingId,
|
||||
name: 'QA voice Context sibling',
|
||||
name: 'QA Space Missions sibling',
|
||||
icon: 'science',
|
||||
source: 'QA',
|
||||
updateInterval: -1,
|
||||
@@ -559,94 +423,48 @@ try {
|
||||
async destroy() {},
|
||||
getStats() { return { count: 1, status: 'live' }; },
|
||||
});
|
||||
const original = {
|
||||
initialized: rocketEntry.initialized,
|
||||
lifecycleState: rocketEntry.lifecycleState,
|
||||
init: rocketEntry.module.init,
|
||||
enable: rocketEntry.module.enable,
|
||||
update: rocketEntry.module.update,
|
||||
disable: rocketEntry.module.disable,
|
||||
};
|
||||
const siblingLayerEntry = dataManager.layers.get(siblingId);
|
||||
siblingLayerEntry.initialized = true;
|
||||
await dataManager.setEnabled(siblingId, true, { origin: 'programmatic' });
|
||||
rocketEntry.initialized = true;
|
||||
rocketEntry.module.init = async () => true;
|
||||
rocketEntry.module.enable = async () => true;
|
||||
rocketEntry.module.update = async () => true;
|
||||
rocketEntry.module.disable = async () => true;
|
||||
const restoreMissions = stubMissions(rocketEntry);
|
||||
try {
|
||||
const voiceOn = await dataManager.setEnabled('rocket-launches', true, { origin: 'voice' });
|
||||
await new Promise((resolve) => setTimeout(resolve, 80));
|
||||
const voiceState = {
|
||||
voiceOn,
|
||||
mode: styleManager._contextControls._contextMode,
|
||||
entering: styleManager._contextControls._contextModeEntering,
|
||||
snapshotRetained: Boolean(styleManager._contextControls._contextSessionSnapshot),
|
||||
siblingIsolated: !dataManager.isEffectivelyEnabled(siblingId),
|
||||
};
|
||||
const snapshotBeforeOff = [...(styleManager._contextControls._contextSessionSnapshot?.enabledLayerIds || [])];
|
||||
const voiceOff = await dataManager.setEnabled('rocket-launches', false, { origin: 'voice' });
|
||||
const reactionCountAfterOff = styleManager._contextControls._contextLayerReactionPromises.size;
|
||||
await styleManager._waitForContextLayerSettlement();
|
||||
const restoredSiblingEntry = dataManager.layers.get(siblingId);
|
||||
const voiceExit = {
|
||||
voiceOff,
|
||||
snapshotBeforeOff,
|
||||
reactionCountAfterOff,
|
||||
mode: styleManager._contextControls._contextMode,
|
||||
entering: styleManager._contextControls._contextModeEntering,
|
||||
snapshotRetained: Boolean(styleManager._contextControls._contextSessionSnapshot),
|
||||
siblingRestored: dataManager.isEffectivelyEnabled(siblingId),
|
||||
siblingEnabled: restoredSiblingEntry?.enabled,
|
||||
siblingLifecycle: restoredSiblingEntry?.lifecycleState,
|
||||
restoreActive: Boolean(styleManager._contextControls._contextRestoreState),
|
||||
};
|
||||
|
||||
await dataManager.setEnabled('rocket-launches', true, { origin: 'programmatic' });
|
||||
await new Promise((resolve) => setTimeout(resolve, 40));
|
||||
const internalState = {
|
||||
mode: styleManager._contextControls._contextMode,
|
||||
entering: styleManager._contextControls._contextModeEntering,
|
||||
snapshotRetained: Boolean(styleManager._contextControls._contextSessionSnapshot),
|
||||
missionEnabled: dataManager.isEffectivelyEnabled('rocket-launches'),
|
||||
};
|
||||
await dataManager.setEnabled('rocket-launches', false, { origin: 'programmatic' });
|
||||
return { exercised: true, voiceState, voiceExit, internalState };
|
||||
const results = {};
|
||||
for (const origin of ['user', 'voice', 'programmatic']) {
|
||||
const on = await dataManager.setEnabled('rocket-launches', true, { origin });
|
||||
await styleManager._waitForContextLayerSettlement();
|
||||
const during = {
|
||||
on,
|
||||
mode: styleManager._contextControls._contextMode,
|
||||
snapshot: Boolean(styleManager._contextControls._contextSessionSnapshot),
|
||||
siblingOn: dataManager.isEffectivelyEnabled(siblingId),
|
||||
};
|
||||
const off = await dataManager.setEnabled('rocket-launches', false, { origin });
|
||||
await styleManager._waitForContextLayerSettlement();
|
||||
results[origin] = {
|
||||
...during,
|
||||
off,
|
||||
siblingOnAfter: dataManager.isEffectivelyEnabled(siblingId),
|
||||
snapshotAfter: Boolean(styleManager._contextControls._contextSessionSnapshot),
|
||||
};
|
||||
}
|
||||
return { exercised: true, results };
|
||||
} finally {
|
||||
rocketEntry.module.init = original.init;
|
||||
rocketEntry.module.enable = original.enable;
|
||||
rocketEntry.module.update = original.update;
|
||||
rocketEntry.module.disable = original.disable;
|
||||
rocketEntry.initialized = original.initialized;
|
||||
rocketEntry.lifecycleState = original.lifecycleState;
|
||||
restoreMissions();
|
||||
await dataManager.setEnabled(siblingId, false, { origin: 'programmatic' });
|
||||
siblingLayerEntry.initialized = original.siblingInitialized;
|
||||
await window.__gevQaUnregisterLayer(dataManager, siblingId);
|
||||
}
|
||||
});
|
||||
check(
|
||||
'voice Space Missions uses the same Context snapshot and exact-restore transaction as UI entry',
|
||||
voiceMissionEntry.exercised
|
||||
&& voiceMissionEntry.voiceState?.voiceOn
|
||||
&& voiceMissionEntry.voiceState.mode === 'space-missions'
|
||||
&& voiceMissionEntry.voiceState.entering === null
|
||||
&& voiceMissionEntry.voiceState.snapshotRetained
|
||||
&& voiceMissionEntry.voiceState.siblingIsolated
|
||||
&& voiceMissionEntry.voiceExit?.voiceOff
|
||||
&& voiceMissionEntry.voiceExit.mode === null
|
||||
&& voiceMissionEntry.voiceExit.entering === null
|
||||
&& !voiceMissionEntry.voiceExit.snapshotRetained
|
||||
&& voiceMissionEntry.voiceExit.siblingRestored,
|
||||
JSON.stringify(voiceMissionEntry),
|
||||
);
|
||||
check(
|
||||
'internal programmatic Space Missions activation does not create a user Context session',
|
||||
voiceMissionEntry.internalState?.missionEnabled
|
||||
&& voiceMissionEntry.internalState.mode === null
|
||||
&& voiceMissionEntry.internalState.entering === null
|
||||
&& !voiceMissionEntry.internalState.snapshotRetained,
|
||||
JSON.stringify(voiceMissionEntry),
|
||||
'Space Missions is an ordinary layer: no Context session, no isolation, from any origin',
|
||||
ordinaryMissionLayer.exercised
|
||||
&& Object.values(ordinaryMissionLayer.results || {}).length === 3
|
||||
&& Object.values(ordinaryMissionLayer.results).every((entry) =>
|
||||
entry.on === true
|
||||
&& entry.mode === null
|
||||
&& !entry.snapshot
|
||||
&& entry.siblingOn
|
||||
&& entry.off === true
|
||||
&& entry.siblingOnAfter
|
||||
&& !entry.snapshotAfter),
|
||||
JSON.stringify(ordinaryMissionLayer),
|
||||
);
|
||||
await page.evaluate(() => window.__godsEyeView.dataManager.setEnabled(
|
||||
'flights',
|
||||
@@ -1998,98 +1816,6 @@ try {
|
||||
}),
|
||||
);
|
||||
|
||||
// Cyber relocates its collapsed briefing header into the expanded utility
|
||||
// lane. Exercise actual height changes without reload and measure both cards.
|
||||
await page.evaluate(() => {
|
||||
const manager = window.__godsEyeView.styleManager;
|
||||
manager._setHudVariant('cyber');
|
||||
manager.hud.setMode('on');
|
||||
manager._setCockpitDisclosure('display', false);
|
||||
manager._setCockpitDisclosure('radio', true);
|
||||
});
|
||||
const cyberRadioOrder = await page.evaluate(() => {
|
||||
const manager = window.__godsEyeView.styleManager;
|
||||
manager.cockpitView.syncSignalLayout();
|
||||
const display = document
|
||||
.getElementById('cockpit-display-toggle-btn')
|
||||
.closest('.cockpit-utility-control');
|
||||
const radio = document
|
||||
.getElementById('cockpit-radio-toggle-btn')
|
||||
.closest('.cockpit-utility-control');
|
||||
const displayRect = display.getBoundingClientRect();
|
||||
const radioRect = radio.getBoundingClientRect();
|
||||
return {
|
||||
display: displayRect.toJSON(),
|
||||
radio: radioRect.toJSON(),
|
||||
displayExpanded: display.classList.contains('is-expanded'),
|
||||
radioExpanded: radio.classList.contains('is-expanded'),
|
||||
gap: radioRect.top - displayRect.bottom,
|
||||
};
|
||||
});
|
||||
check(
|
||||
'Cyber expanding Radio preserves the authored Display-then-Radio order',
|
||||
!cyberRadioOrder.displayExpanded
|
||||
&& cyberRadioOrder.radioExpanded
|
||||
&& cyberRadioOrder.display.height > 0
|
||||
&& cyberRadioOrder.radio.height > 0
|
||||
&& cyberRadioOrder.gap >= 7,
|
||||
JSON.stringify(cyberRadioOrder),
|
||||
);
|
||||
await page.screenshot({ path: path.join(shotsDir, 'cyber-radio-order.png') });
|
||||
await page.evaluate(() => {
|
||||
const manager = window.__godsEyeView.styleManager;
|
||||
manager._setCockpitDisclosure('radio', false);
|
||||
manager._setCockpitDisclosure('display', true);
|
||||
});
|
||||
const cyberStyleStates = await page.evaluate(() => {
|
||||
const manager = window.__godsEyeView.styleManager;
|
||||
const states = [];
|
||||
for (const style of ['normal', 'surveillance', 'thermal', 'retro']) {
|
||||
document.querySelector(`.style-btn[data-style="${style}"]`).click();
|
||||
states.push({
|
||||
requestedStyle: style,
|
||||
activeStyle: manager.activeStyle,
|
||||
hud: manager.hud.getVariant(),
|
||||
theme: document.documentElement.dataset.uiTheme,
|
||||
selector: document.getElementById('hud-layout-select').value,
|
||||
savedHud: manager.getVisualState().hud.variant,
|
||||
});
|
||||
}
|
||||
return states;
|
||||
});
|
||||
check('Cockpit visual-style controls retain Cyber HUD, selector, shell and saved layout',
|
||||
cyberStyleStates.every(state => state.activeStyle === state.requestedStyle
|
||||
&& state.hud === 'cyber' && state.theme === 'cyber'
|
||||
&& state.selector === 'cyber' && state.savedHud === 'cyber'),
|
||||
JSON.stringify(cyberStyleStates));
|
||||
for (const height of [987, 720, 640, 900]) {
|
||||
await page.setViewport({ width: 1440, height, deviceScaleFactor: 1 });
|
||||
await new Promise((resolve) => setTimeout(resolve, 400));
|
||||
const geometry = await page.evaluate(() => {
|
||||
const signal = document.getElementById('cockpit-signal-stream');
|
||||
const utility = document.getElementById('cockpit-utility-controls');
|
||||
const expanded = utility.querySelector('.cockpit-utility-control.is-expanded');
|
||||
const s = signal.getBoundingClientRect();
|
||||
const u = expanded.getBoundingClientRect();
|
||||
const toggle = document.getElementById('cockpit-signal-toggle');
|
||||
const t = toggle.getBoundingClientRect();
|
||||
const hit = document.elementFromPoint(t.x + t.width / 2, t.y + t.height / 2);
|
||||
return { height: innerHeight, theme: document.documentElement.dataset.uiTheme,
|
||||
collapsed: signal.dataset.collapsed, signal: s.toJSON(), utility: u.toJSON(),
|
||||
reachable: Boolean(hit && toggle.contains(hit)),
|
||||
contained: u.bottom <= s.top - 7 && s.bottom < innerHeight,
|
||||
};
|
||||
});
|
||||
check(`Cyber collapsed Live Signals remains visible and reachable after resize to ${height}px`,
|
||||
geometry.theme === 'cyber' && geometry.collapsed === 'true'
|
||||
&& geometry.signal.width > 0 && geometry.signal.height > 0
|
||||
&& geometry.reachable && geometry.contained, JSON.stringify(geometry));
|
||||
if (height === 640 || height === 900) {
|
||||
await page.screenshot({ path: path.join(shotsDir, `cyber-resize-${height}.png`) });
|
||||
}
|
||||
}
|
||||
await page.evaluate(() => window.__godsEyeView.styleManager._setHudVariant('tactical'));
|
||||
|
||||
const signalTransition = await page.evaluate(async () => {
|
||||
const manager = window.__godsEyeView.styleManager;
|
||||
const cockpit = manager.cockpitView;
|
||||
|
||||
@@ -276,21 +276,21 @@ const MUTATIONS = [
|
||||
},
|
||||
{
|
||||
defect: 'the tile stops promising the fires it actually turns on',
|
||||
file: 'html',
|
||||
file: 'module',
|
||||
from: " 'Live earthquakes and active fires, from USGS and NASA',",
|
||||
to: " 'Live earthquakes worldwide, straight from USGS',",
|
||||
},
|
||||
{
|
||||
defect: 'the owner-authored first-run line is quietly rewritten',
|
||||
defect: 'the maintainer-authored first-run line is quietly rewritten',
|
||||
file: 'html',
|
||||
from: 'It feels like a forbidden cockpit—then you realize the sources are public and the data is real.',
|
||||
to: "It feels like a forbidden cockpit. It isn't — every feed is public, and every contact is live.",
|
||||
to: 'A live 3D globe of public data. Pick a view to begin.',
|
||||
},
|
||||
{
|
||||
defect: 'the ledgered global-chip defect loses its pointer to the real fix',
|
||||
file: 'module',
|
||||
from: ' // means a KEY REQUIRED terminal state in src/loadingFeedback.js, a state',
|
||||
to: ' // (note removed)',
|
||||
from: ' // ends KEY REQUIRED (src/loadingFeedback.js), and the quakes half of the',
|
||||
to: ' // ends KEY REQUIRED, and the quakes half of the',
|
||||
},
|
||||
{
|
||||
defect: 'the globe missions never pull the camera out',
|
||||
@@ -307,14 +307,14 @@ const MUTATIONS = [
|
||||
{
|
||||
defect: 'a cancelled globe flight fails the whole mission',
|
||||
file: 'module',
|
||||
from: ' .catch(() => null);',
|
||||
to: ' .catch(() => { throw new Error("flight failed"); });',
|
||||
from: ' .catch(() => null)\n : null;',
|
||||
to: ' .catch(() => { throw new Error("flight failed"); })\n : null;',
|
||||
},
|
||||
{
|
||||
defect: 'Explore manually quietly runs a mission instead of nothing',
|
||||
file: 'module',
|
||||
from: "if (mission.kind === 'none') return { ok: true, choice };",
|
||||
to: "if (mission.kind === 'none') return { ok: true, choice, ran: await setContextMode('contacts') };",
|
||||
to: "if (mission.kind === 'none') return { ok: true, choice, ran: await setLayerEnabled('rocket-launches') };",
|
||||
},
|
||||
{
|
||||
defect: 'an unknown choice is treated as a success',
|
||||
@@ -348,15 +348,14 @@ const MUTATIONS = [
|
||||
{
|
||||
defect: 'a mission persists a 3D-models choice nobody made',
|
||||
file: 'module',
|
||||
from: ' const result = await styleManager.setContextMode(mode);',
|
||||
to: ' styleManager._setModels3dEnabled?.(true);\n const result = await styleManager.setContextMode(mode);',
|
||||
from: " setLayerEnabled: (layerId) =>\n dataManager.setEnabled(layerId, true, { origin: 'user' }),",
|
||||
to: " setLayerEnabled: (layerId) => {\n styleManager._setModels3dEnabled?.(true);\n return dataManager.setEnabled(layerId, true, { origin: 'user' });\n },",
|
||||
},
|
||||
{
|
||||
defect:
|
||||
'the Context panel is left collapsed, hiding the mode that just started',
|
||||
defect: 'a mission writes panel chrome nobody chose',
|
||||
file: 'module',
|
||||
from: " styleManager.setPanelCollapsed?.('global-context-panel', false, {\n explicit: true,\n });",
|
||||
to: ' // panel reveal removed',
|
||||
from: ' flyToGlobe: () => styleManager.resetToGlobeView(),',
|
||||
to: " flyToGlobe: () => {\n styleManager.setPanelCollapsed?.('global-context-panel', false, { explicit: true });\n return styleManager.resetToGlobeView();\n },",
|
||||
},
|
||||
{
|
||||
defect:
|
||||
@@ -371,8 +370,8 @@ const MUTATIONS = [
|
||||
defect:
|
||||
'disabling the focused tile drops the keyboard to <body> mid-flight',
|
||||
file: 'html',
|
||||
from: ':aria-disabled="launcher?.busy ?? undefined" @click="controls?.choose(\'contacts\')"',
|
||||
to: ':disabled="launcher?.busy === \'true\'" @click="controls?.choose(\'contacts\')"',
|
||||
from: ':aria-disabled="String(settling || launcher?.busy === \'true\')" @click="onPrimary"',
|
||||
to: ':disabled="launcher?.busy === \'true\'" @click="onPrimary"',
|
||||
},
|
||||
{
|
||||
defect: 'Tab escapes into an app the visitor has not seen yet',
|
||||
@@ -421,8 +420,8 @@ const MUTATIONS = [
|
||||
defect:
|
||||
'the card loses its viewport cap and clips on a short landscape phone',
|
||||
file: 'css',
|
||||
from: ' max-height: calc(100dvh - 1.5rem);',
|
||||
to: ' /* cap removed */',
|
||||
from: ' body.mobile-shell #first-run-launcher {\n bottom: 5.8rem;\n max-height: calc(100vh - 6.55rem);\n max-height: calc(100dvh - 6.55rem);\n }',
|
||||
to: ' body.mobile-shell #first-run-launcher {\n bottom: 5.8rem;\n /* cap removed */\n }',
|
||||
},
|
||||
{
|
||||
defect:
|
||||
@@ -437,7 +436,7 @@ const MUTATIONS = [
|
||||
// those instead and prove nothing about this feature.
|
||||
defect: "the launcher's reduced-motion opt-out is dropped",
|
||||
file: 'css',
|
||||
from: ' #first-run-launcher,\n .first-run-choices button,\n .first-run-arrow {\n transition: none;\n }\n /* Scrolling a tile into view must not animate either. */\n .first-run-choices {\n scroll-behavior: auto;\n }',
|
||||
from: ' #first-run-launcher,\n .first-run-backdrop,\n .first-run-back,\n .first-run-missions button,\n .first-run-link-card,\n .first-run-link-button,\n .first-run-enter {\n transition: none;\n }\n /* Scrolling a tile into view must not animate either. */\n .first-run-choices {\n scroll-behavior: auto;\n }',
|
||||
to: ' .first-run-nothing {\n transition: none;\n }',
|
||||
},
|
||||
|
||||
@@ -445,20 +444,20 @@ const MUTATIONS = [
|
||||
{
|
||||
defect: 'a mission tile is dropped from the menu',
|
||||
file: 'html',
|
||||
from: ' <button type="button" data-first-run-choice="space-missions"',
|
||||
to: ' <button type="button" data-first-run-choice-disabled="space-missions"',
|
||||
from: ' <button type="button" data-first-run-start="space-missions"',
|
||||
to: ' <button type="button" data-first-run-start-disabled="space-missions"',
|
||||
},
|
||||
{
|
||||
defect: "the menu order stops matching the owner's",
|
||||
file: 'html',
|
||||
from: '<button type="button" data-first-run-choice="environmental"',
|
||||
to: '<button type="button" data-first-run-choice="zzz-environmental"',
|
||||
from: '<button type="button" data-first-run-start="environmental"',
|
||||
to: '<button type="button" data-first-run-start="zzz-environmental"',
|
||||
},
|
||||
{
|
||||
defect: 'the "don\'t show again" checkbox is removed',
|
||||
defect: 'the "don\'t show again" checkbox loses its hook',
|
||||
file: 'html',
|
||||
from: '<input type="checkbox" data-first-run-suppress @change="onSuppress" />',
|
||||
to: '<span data-first-run-suppress-removed></span>',
|
||||
from: '<UiCheckbox class="first-run-suppress" :input-attrs="suppressBoxAttrs" @change="onSuppress">',
|
||||
to: '<UiCheckbox class="first-run-suppress" @change="onSuppress">',
|
||||
},
|
||||
{
|
||||
defect: 'the status line stops being a polite live region',
|
||||
|
||||
+108
-42
@@ -33,7 +33,7 @@ const TEETH = args.includes('--teeth');
|
||||
const HEADFUL = args.includes('--headful');
|
||||
|
||||
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const SHOT_DIR = path.join(ROOT, 'qa-shots', 'firstrun');
|
||||
const SHOT_DIR = process.env.QA_OUTPUT_DIR || path.join(ROOT, 'qa-shots', 'firstrun');
|
||||
|
||||
const CHROME_CANDIDATES = [
|
||||
process.env.PUPPETEER_EXECUTABLE_PATH,
|
||||
@@ -109,7 +109,7 @@ const appState = (page) => page.evaluate(() => {
|
||||
const gev = window.__godsEyeView || {};
|
||||
const sm = gev.styleManager;
|
||||
const dm = gev.dataManager;
|
||||
const carto = sm?.viewer?.camera?.positionCartographic;
|
||||
const carto = gev.viewer?.camera?.positionCartographic;
|
||||
const layers = {};
|
||||
const counts = {};
|
||||
const all = dm?.getAll?.() || [];
|
||||
@@ -170,8 +170,22 @@ async function watchLoadingChip(page) {
|
||||
|
||||
const readLoadingChip = (page) => page.evaluate(() => window.__chipSeen || []);
|
||||
|
||||
async function nextStep(page, readySelector) {
|
||||
await page.click('[data-first-run-next]');
|
||||
await page.waitForSelector(readySelector, { visible: true });
|
||||
await page.waitForFunction(() => {
|
||||
const steps = [...document.querySelectorAll('#first-run-launcher .first-run-step')];
|
||||
return steps.length === 1
|
||||
&& !/first-run-step-(forward|back)-(enter|leave)-/.test(steps[0].className)
|
||||
&& document.querySelector('[data-first-run-primary]')?.getAttribute('aria-disabled') !== 'true';
|
||||
});
|
||||
}
|
||||
|
||||
async function pick(page, choice, { timeout = 40000, settle = [] } = {}) {
|
||||
await page.click(`[data-first-run-choice="${choice}"]`);
|
||||
await nextStep(page, '[data-first-run-start]');
|
||||
await page.click(`[data-first-run-start="${choice}"]`);
|
||||
await nextStep(page, '[data-first-run-choice]');
|
||||
await page.click('[data-first-run-choice]');
|
||||
await page.waitForFunction(
|
||||
(sel) => !document.querySelector(sel) || !document.querySelector(sel).classList.contains('visible'),
|
||||
{ timeout },
|
||||
@@ -190,8 +204,8 @@ async function pick(page, choice, { timeout = 40000, settle = [] } = {}) {
|
||||
/** Every section the run is expected to reach; the teeth verdict requires all. */
|
||||
const EXPECTED_SECTIONS = [
|
||||
'show-policy', 'esc-arbitration',
|
||||
'mission-environmental', 'mission-contacts', 'mission-space', 'mission-explore',
|
||||
'viewports', 'console',
|
||||
'mission-environmental', 'mission-space', 'mission-explore',
|
||||
'stories-card', 'viewports', 'console',
|
||||
];
|
||||
|
||||
/*
|
||||
@@ -482,8 +496,8 @@ async function main() {
|
||||
record('a fresh session gets the launcher', freshVisible);
|
||||
if (freshVisible) shots.push(await shoot(page, 'launcher-desktop'));
|
||||
|
||||
const focused = await page.evaluate(() => document.activeElement?.dataset?.firstRunChoice ?? null);
|
||||
record('focus lands on the first mission tile', focused === 'contacts', `activeElement=${focused}`);
|
||||
const focused = await page.evaluate(() => document.activeElement?.hasAttribute('data-first-run-next') ?? false);
|
||||
record('focus lands on Next', focused === true, `activeElement=${focused}`);
|
||||
|
||||
// The card is a flex column (so its list can scroll on short viewports),
|
||||
// and an author `display` on this id outranks the UA's `[hidden]` rule.
|
||||
@@ -500,10 +514,11 @@ async function main() {
|
||||
record('the hidden attribute still hides the flex card', hiddenHonored === 'none',
|
||||
`computed display while hidden = ${hiddenHonored}`);
|
||||
|
||||
const tiles = await page.$$eval('[data-first-run-choice]', (nodes) => nodes.map((n) => n.dataset.firstRunChoice));
|
||||
await nextStep(page, '[data-first-run-start]');
|
||||
const tiles = await page.$$eval('[data-first-run-start]', (nodes) => nodes.map((n) => n.dataset.firstRunStart));
|
||||
record(
|
||||
'four tiles in the owner\'s order',
|
||||
JSON.stringify(tiles) === JSON.stringify(['contacts', 'space-missions', 'environmental', 'explore']),
|
||||
'three tiles in the owner\'s order',
|
||||
JSON.stringify(tiles) === JSON.stringify(['space-missions', 'environmental', 'explore']),
|
||||
tiles.join(' · '),
|
||||
);
|
||||
|
||||
@@ -558,7 +573,7 @@ async function main() {
|
||||
|
||||
// ── Mission outcomes ────────────────────────────────────────────────────
|
||||
// One section PER MISSION: a throw in one (a tile that never rendered under
|
||||
// --teeth, say) must not take the other four down with it, or the teeth
|
||||
// --teeth, say) must not take the other two down with it, or the teeth
|
||||
// tally reports "reached" for assertions that never ran.
|
||||
let state;
|
||||
let before;
|
||||
@@ -642,47 +657,93 @@ async function main() {
|
||||
shots.push(await shoot(page, 'mission-environmental'));
|
||||
});
|
||||
|
||||
await section('mission-contacts', async () => {
|
||||
await open(page, { query: "?welcome=1", errorSink: consoleErrors });
|
||||
await pick(page, 'contacts');
|
||||
state = await appState(page);
|
||||
record('LIVE CONTACTS activates the Contacts context mode', state.contextMode === 'flights',
|
||||
`contextMode=${state.contextMode}`);
|
||||
const panelOpen = await page.evaluate(() => {
|
||||
const panel = document.getElementById('global-context-panel');
|
||||
return !!panel && !panel.classList.contains('collapsed');
|
||||
});
|
||||
record('LIVE CONTACTS reveals the Context panel', panelOpen);
|
||||
record('LIVE CONTACTS still leaves the detection override untouched',
|
||||
state.detectionOverridden === false, `_detectionUserOverridden=${state.detectionOverridden}`);
|
||||
shots.push(await shoot(page, 'mission-contacts'));
|
||||
});
|
||||
|
||||
await section('mission-space', async () => {
|
||||
await open(page, { query: "?welcome=1", errorSink: consoleErrors });
|
||||
await pick(page, 'space-missions');
|
||||
state = await appState(page);
|
||||
record('SPACE MISSIONS activates its context mode', state.contextMode === 'space-missions',
|
||||
`contextMode=${state.contextMode}`);
|
||||
const missions = await page.evaluate(() => {
|
||||
const panel = document.getElementById('space-missions-panel');
|
||||
return {
|
||||
layerOn: window.__godsEyeView.dataManager.isEffectivelyEnabled('rocket-launches'),
|
||||
panelOpen: !!panel && !panel.hidden && !panel.classList.contains('collapsed'),
|
||||
};
|
||||
});
|
||||
record('SPACE MISSIONS switches its layer on without a Context mode',
|
||||
missions.layerOn && state.contextMode == null,
|
||||
`layerOn=${missions.layerOn} contextMode=${state.contextMode}`);
|
||||
record('SPACE MISSIONS opens its own panel', missions.panelOpen,
|
||||
`panelOpen=${missions.panelOpen}`);
|
||||
record('SPACE MISSIONS still leaves the detection override untouched',
|
||||
state.detectionOverridden === false, `_detectionUserOverridden=${state.detectionOverridden}`);
|
||||
shots.push(await shoot(page, 'mission-space-missions'));
|
||||
});
|
||||
|
||||
await section('mission-explore', async () => {
|
||||
await open(page, { query: "?welcome=1", errorSink: consoleErrors });
|
||||
// Start below the mission overview so an accidental overview flight is observable.
|
||||
await page.evaluate(() => {
|
||||
const camera = window.__godsEyeView.viewer.camera;
|
||||
camera.cancelFlight();
|
||||
camera.setView({ destination: camera.position.constructor.fromDegrees(-97.7431, 30.2672, 100000) });
|
||||
});
|
||||
const beforeExplore = await appState(page);
|
||||
await pick(page, 'explore');
|
||||
state = await appState(page);
|
||||
record('EXPLORE MANUALLY enables no layer and no context mode',
|
||||
Object.values(state.layers).every((on) => !on) && state.contextMode === null,
|
||||
Object.entries(state.layers).filter(([, on]) => on).map(([id]) => id).join(', ') || 'nothing enabled');
|
||||
// The real claim is that Explore issues no camera command of its own: the
|
||||
// arrival fly-in owns the camera and must still be heading down, not out.
|
||||
record('EXPLORE MANUALLY never commandeers the camera',
|
||||
(state.heightKm ?? 0) < 12000 && (state.heightKm ?? 1e9) <= (beforeExplore.heightKm ?? 1e9),
|
||||
`${beforeExplore.heightKm} → ${state.heightKm} km (globe would be 18000)`);
|
||||
beforeExplore.heightKm === 100 && state.heightKm === beforeExplore.heightKm,
|
||||
`${beforeExplore.heightKm} → ${state.heightKm} km (expected 100 → 100 km)`);
|
||||
shots.push(await shoot(page, 'mission-explore'));
|
||||
});
|
||||
|
||||
await section('stories-card', async () => {
|
||||
await open(page, { query: "?welcome=1", errorSink: consoleErrors });
|
||||
const backdrop = await page.evaluate(() => {
|
||||
const el = document.querySelector('.first-run-backdrop');
|
||||
if (!el) return null;
|
||||
const style = getComputedStyle(el);
|
||||
return {
|
||||
filter: style.backdropFilter || style.webkitBackdropFilter || 'none',
|
||||
background: style.backgroundColor,
|
||||
pointerEvents: style.pointerEvents,
|
||||
};
|
||||
});
|
||||
record('the welcome backdrop tints the globe without blurring it',
|
||||
!!backdrop && backdrop.filter === 'none' && backdrop.background !== 'rgba(0, 0, 0, 0)'
|
||||
&& backdrop.pointerEvents === 'none',
|
||||
JSON.stringify(backdrop));
|
||||
await nextStep(page, '[data-first-run-start]');
|
||||
await nextStep(page, '[data-first-run-choice]');
|
||||
const button = await page.evaluate(() => {
|
||||
const el = document.querySelector('#first-run-launcher [data-first-run-stories]');
|
||||
return el ? { tag: el.tagName, href: el.getAttribute('href'), target: el.getAttribute('target') } : null;
|
||||
});
|
||||
record('the GEV Stories card offers an in-app BROWSE STORIES button',
|
||||
button?.tag === 'BUTTON' && button.href === null && button.target === null,
|
||||
JSON.stringify(button));
|
||||
const pagesBefore = (await browser.pages()).length;
|
||||
await page.click('#first-run-launcher [data-first-run-stories]');
|
||||
const opened = await page.waitForFunction(
|
||||
() => document.body.classList.contains('stories-mode')
|
||||
&& !!document.querySelector('#gev-stories .app'),
|
||||
{ timeout: 30000 },
|
||||
).then(() => true, () => false);
|
||||
const after = await page.evaluate((sel) => ({
|
||||
launcherVisible: !!document.querySelector(sel)?.classList.contains('visible'),
|
||||
session: sessionStorage.getItem('gev:first-run-mission-session:v1'),
|
||||
query: location.search,
|
||||
}), LAUNCHER);
|
||||
record('BROWSE STORIES opens Stories Explore in this tab',
|
||||
opened && (await browser.pages()).length === pagesBefore,
|
||||
`stories-mode=${opened}, query=${after.query}`);
|
||||
record('BROWSE STORIES closes the welcome card for the session',
|
||||
!after.launcherVisible && after.session !== null,
|
||||
`visible=${after.launcherVisible}, session=${after.session}`);
|
||||
shots.push(await shoot(page, 'stories-card-explore'));
|
||||
});
|
||||
|
||||
// ── Viewports ───────────────────────────────────────────────────────────
|
||||
await section('viewports', async () => {
|
||||
// Portrait phone, LANDSCAPE phone (the short viewport that clipped the card
|
||||
@@ -695,6 +756,8 @@ async function main() {
|
||||
for (const vp of VIEWPORTS) {
|
||||
await page.setViewport({ width: vp.width, height: vp.height, deviceScaleFactor: vp.dpr });
|
||||
await open(page, { query: "?welcome=1", errorSink: consoleErrors });
|
||||
for (let step = 1; step <= 3; step++) {
|
||||
if (step > 1) await nextStep(page, step === 2 ? '[data-first-run-start]' : '[data-first-run-choice]');
|
||||
const box = await page.evaluate((sel) => {
|
||||
const node = document.querySelector(sel);
|
||||
if (!node) return null;
|
||||
@@ -715,22 +778,23 @@ async function main() {
|
||||
const fits = !!box && box.top >= 0 && box.bottom <= box.vh
|
||||
&& box.left >= 0 && box.right <= box.vw;
|
||||
record(
|
||||
`the launcher fits a ${vp.label} with no clipping`,
|
||||
`step ${step} fits a ${vp.label} with no clipping`,
|
||||
fits,
|
||||
box ? `${box.left},${box.top} → ${box.right},${box.bottom} in ${box.vw}x${box.vh}${box.listScrolls ? ' (list scrolls)' : ''}` : 'absent',
|
||||
);
|
||||
record(`"Don't show this again" stays on screen at ${vp.width}x${vp.height}`,
|
||||
record(`step ${step} checkbox stays on screen at ${vp.width}x${vp.height}`,
|
||||
!!box?.checkboxOnScreen);
|
||||
|
||||
// Discoverability: if the list scrolls, the LAST tile must still peek
|
||||
// above the fold. A fold that lands exactly between tiles looks like a
|
||||
// complete list of four, and the fifth mission is simply never found.
|
||||
// complete list, and the last mission is simply never found.
|
||||
if (step === 2) {
|
||||
const peek = await page.evaluate((sel) => {
|
||||
const node = document.querySelector(sel);
|
||||
const list = node?.querySelector('.first-run-choices');
|
||||
if (!list) return null;
|
||||
list.scrollTop = 0;
|
||||
const tiles = [...list.querySelectorAll('[data-first-run-choice]')];
|
||||
const tiles = [...list.querySelectorAll('[data-first-run-start]')];
|
||||
const last = tiles[tiles.length - 1];
|
||||
if (!last) return null;
|
||||
const listBox = list.getBoundingClientRect();
|
||||
@@ -739,7 +803,7 @@ async function main() {
|
||||
return {
|
||||
scrolls: list.scrollHeight > list.clientHeight + 1,
|
||||
fraction: lastBox.height ? visible / lastBox.height : 0,
|
||||
label: last.dataset.firstRunChoice,
|
||||
label: last.dataset.firstRunStart,
|
||||
};
|
||||
}, LAUNCHER);
|
||||
record(
|
||||
@@ -755,7 +819,7 @@ async function main() {
|
||||
const reach = await page.evaluate(async (sel) => {
|
||||
const node = document.querySelector(sel);
|
||||
if (!node) return null;
|
||||
const targets = [...node.querySelectorAll('[data-first-run-choice], [data-first-run-suppress]')];
|
||||
const targets = [...node.querySelectorAll('[data-first-run-start], [data-first-run-suppress]')];
|
||||
const offscreen = [];
|
||||
for (const target of targets) {
|
||||
target.focus();
|
||||
@@ -764,7 +828,7 @@ async function main() {
|
||||
const host = node.getBoundingClientRect();
|
||||
if (document.activeElement !== target
|
||||
|| rect.bottom <= host.top || rect.top >= host.bottom) {
|
||||
offscreen.push(target.dataset.firstRunChoice || 'suppress-checkbox');
|
||||
offscreen.push(target.dataset.firstRunStart || 'suppress-checkbox');
|
||||
}
|
||||
}
|
||||
return { count: targets.length, offscreen };
|
||||
@@ -773,7 +837,7 @@ async function main() {
|
||||
// A hardcoded count silently turns into a failure the day the menu
|
||||
// changes, which is exactly what it did when a tile was removed.
|
||||
const expectedFocusable = await page.$$eval(
|
||||
'[data-first-run-choice]', (nodes) => nodes.length,
|
||||
'[data-first-run-start]', (nodes) => nodes.length,
|
||||
) + 1;
|
||||
record(
|
||||
`every tile and the checkbox are keyboard-reachable at ${vp.width}x${vp.height}`,
|
||||
@@ -782,6 +846,7 @@ async function main() {
|
||||
? `${reach.count}/${expectedFocusable} focusable${reach.offscreen.length ? `, unreachable: ${reach.offscreen.join(', ')}` : ''}`
|
||||
: 'absent',
|
||||
);
|
||||
}
|
||||
// The reachability probe above tabs to the last tile and scrolls the list
|
||||
// with it. Put it back to the top so the taste-pass shot shows what a
|
||||
// visitor actually opens on.
|
||||
@@ -791,7 +856,8 @@ async function main() {
|
||||
document.activeElement?.blur?.();
|
||||
}, LAUNCHER);
|
||||
await sleep(250);
|
||||
shots.push(await shoot(page, `launcher-${vp.name}`));
|
||||
shots.push(await shoot(page, `launcher-${vp.name}-step-${step}`));
|
||||
}
|
||||
}
|
||||
await page.setViewport({ width: 1440, height: 900, deviceScaleFactor: 1 });
|
||||
});
|
||||
|
||||
@@ -111,7 +111,7 @@ await page.waitForFunction(() => window.__godsEyeView?.viewer && window.__godsEy
|
||||
{ timeout: 150000 });
|
||||
await sleep(12000); // let the boot fly-to settle before pinning
|
||||
await page.evaluate(() => {
|
||||
document.querySelector('#first-run-launcher:not([hidden]) [data-first-run-choice="explore"]')?.click();
|
||||
document.querySelector('#first-run-launcher:not([hidden]) [data-first-run-dismiss]')?.click();
|
||||
});
|
||||
await sleep(600); // let the launcher dismissal finish before taking evidence
|
||||
|
||||
|
||||
@@ -314,17 +314,7 @@ try {
|
||||
}
|
||||
await page.evaluate(() => {
|
||||
document.documentElement.lang = 'en';
|
||||
document.documentElement.dataset.uiTheme = 'cyber';
|
||||
});
|
||||
const cyber = await page.$eval(
|
||||
'#scene-select',
|
||||
(node) => getComputedStyle(node).backgroundColor,
|
||||
);
|
||||
check(
|
||||
'Cyber keeps its native field theme',
|
||||
cyber === 'rgba(26, 35, 39, 0.96)',
|
||||
cyber,
|
||||
);
|
||||
await begin('heading');
|
||||
await page.evaluate(() => {
|
||||
const owner = window.__godsEyeView.styleManager._cctvControls;
|
||||
|
||||
+9
-11
@@ -845,7 +845,7 @@ async function main() {
|
||||
params: {},
|
||||
};
|
||||
let failureUsed = false;
|
||||
const entryLayerId = mode === 'flights' ? 'military-awareness' : 'rocket-launches';
|
||||
const entryLayerId = 'military-awareness';
|
||||
dataManager.setEnabled = async (layerId, shouldEnable) => {
|
||||
const failsIsolation = phase === 'isolation' && layerId === 'local-datacenters' && !shouldEnable;
|
||||
const failsActivation = phase === 'activation' && layerId === entryLayerId && shouldEnable;
|
||||
@@ -872,7 +872,6 @@ async function main() {
|
||||
priorLayerRestored: enabled.has('local-datacenters'),
|
||||
entryEnabled: enabled.has(entryLayerId),
|
||||
flightsButtonDisabled: document.getElementById('global-context-flights-btn').disabled,
|
||||
missionsButtonDisabled: document.getElementById('global-context-missions-btn').disabled,
|
||||
message: document.getElementById('toast').textContent,
|
||||
};
|
||||
};
|
||||
@@ -893,7 +892,7 @@ async function main() {
|
||||
}
|
||||
};
|
||||
const contextFailures = [];
|
||||
for (const mode of ['flights', 'space-missions']) {
|
||||
for (const mode of ['flights']) {
|
||||
for (const phase of ['isolation', 'activation']) {
|
||||
for (const outcome of ['false', 'reject']) {
|
||||
contextFailures.push(await runContextFailure(mode, phase, outcome));
|
||||
@@ -902,7 +901,7 @@ async function main() {
|
||||
}
|
||||
|
||||
const directEntryFailures = [];
|
||||
for (const layerId of ['military-awareness', 'rocket-launches']) {
|
||||
for (const layerId of ['military-awareness']) {
|
||||
for (const outcome of ['false', 'reject']) {
|
||||
enabled.clear();
|
||||
enabled.add('local-datacenters');
|
||||
@@ -971,7 +970,7 @@ async function main() {
|
||||
styleManager._showToast = originalShowToast;
|
||||
|
||||
const directActivationFailures = [];
|
||||
for (const layerId of ['military-awareness', 'rocket-launches']) {
|
||||
for (const layerId of ['military-awareness']) {
|
||||
enabled.clear();
|
||||
styleManager._contextControls._contextMode = null;
|
||||
styleManager._contextControls._contextSessionSnapshot = {
|
||||
@@ -1001,7 +1000,7 @@ async function main() {
|
||||
}
|
||||
|
||||
const directActivationRollbackFailures = [];
|
||||
for (const layerId of ['military-awareness', 'rocket-launches']) {
|
||||
for (const layerId of ['military-awareness']) {
|
||||
enabled.clear();
|
||||
styleManager._contextControls._contextMode = null;
|
||||
styleManager._contextControls._contextSessionSnapshot = {
|
||||
@@ -1211,7 +1210,7 @@ async function main() {
|
||||
check(
|
||||
'user-facing chip, real Context entry rollback, and installation Search failures settle safely',
|
||||
userFacingFailures.semanticFalseMessage === 'Radio could not stop cleanly'
|
||||
&& userFacingFailures.contextFailures.length === 8
|
||||
&& userFacingFailures.contextFailures.length === 4
|
||||
&& userFacingFailures.contextFailures.every((failure) => (
|
||||
failure.result === false
|
||||
&& failure.visibleMode === null
|
||||
@@ -1219,10 +1218,9 @@ async function main() {
|
||||
&& failure.priorLayerRestored
|
||||
&& !failure.entryEnabled
|
||||
&& !failure.flightsButtonDisabled
|
||||
&& !failure.missionsButtonDisabled
|
||||
&& failure.message.includes('QA transition failed')
|
||||
))
|
||||
&& userFacingFailures.directEntryFailures.length === 4
|
||||
&& userFacingFailures.directEntryFailures.length === 2
|
||||
&& userFacingFailures.directEntryFailures.every((failure) => (
|
||||
failure.reason.includes('could not start')
|
||||
&& failure.retryReason === null
|
||||
@@ -1233,14 +1231,14 @@ async function main() {
|
||||
&& failure.priorLayerRestored
|
||||
&& !failure.modeChanging
|
||||
))
|
||||
&& userFacingFailures.directActivationFailures.length === 2
|
||||
&& userFacingFailures.directActivationFailures.length === 1
|
||||
&& userFacingFailures.directActivationFailures.every((failure) => (
|
||||
failure.mode === null
|
||||
&& failure.snapshotCleared
|
||||
&& failure.priorLayerRestored
|
||||
&& failure.failedLayerDisabled
|
||||
))
|
||||
&& userFacingFailures.directActivationRollbackFailures.length === 2
|
||||
&& userFacingFailures.directActivationRollbackFailures.length === 1
|
||||
&& userFacingFailures.directActivationRollbackFailures.every((failure) => (
|
||||
failure.toastMessages.length === 1
|
||||
&& failure.toastMessages[0] === `${failure.layerId} could not start cleanly`
|
||||
|
||||
@@ -345,7 +345,7 @@ try {
|
||||
(await readScope()).feather === 2,
|
||||
);
|
||||
await page.click('#scope-toggle');
|
||||
for (const layout of ['minimal', 'cyber', 'tactical']) {
|
||||
for (const layout of ['minimal', 'tactical']) {
|
||||
await page.select('#hud-layout-select', layout);
|
||||
const state = await readScope();
|
||||
check(
|
||||
|
||||
@@ -276,35 +276,6 @@ try {
|
||||
.every((group) => group.scrollWidth <= group.clientWidth + 1),
|
||||
),
|
||||
);
|
||||
const cyber = await page.evaluate(() => {
|
||||
const root = document.documentElement;
|
||||
const previous = root.getAttribute('data-ui-theme');
|
||||
root.setAttribute('data-ui-theme', 'cyber');
|
||||
const selected = [
|
||||
...document.querySelectorAll('.gev-segment[aria-checked="true"]'),
|
||||
];
|
||||
// Check the final theme colors, independent of software-GL frame cadence.
|
||||
for (const button of selected)
|
||||
for (const animation of button.getAnimations()) animation.finish();
|
||||
const backgrounds = selected.map(
|
||||
(button) => getComputedStyle(button).backgroundColor,
|
||||
);
|
||||
const radii = [...document.querySelectorAll('.gev-segmented')].map(
|
||||
(group) => getComputedStyle(group).borderRadius,
|
||||
);
|
||||
const consistent =
|
||||
selected.length === 6 &&
|
||||
backgrounds.every((color) => color === backgrounds[0]) &&
|
||||
radii.every((radius) => radius === '1px');
|
||||
if (previous === null) root.removeAttribute('data-ui-theme');
|
||||
else root.setAttribute('data-ui-theme', previous);
|
||||
return { consistent, count: selected.length, backgrounds, radii };
|
||||
});
|
||||
check(
|
||||
'Cyber theme styles every selected segment consistently',
|
||||
cyber.consistent,
|
||||
JSON.stringify(cyber),
|
||||
);
|
||||
await page.evaluate(async () => {
|
||||
const { dataManager, styleManager } = window.__godsEyeView;
|
||||
await dataManager.setEnabled('recent-imagery', true);
|
||||
|
||||
@@ -194,7 +194,7 @@ try {
|
||||
result,
|
||||
);
|
||||
}
|
||||
for (const theme of ['tactical', 'cyber']) {
|
||||
for (const theme of ['tactical', 'minimal']) {
|
||||
await page.evaluate(
|
||||
(theme) => window.__godsEyeView.styleManager._setHudVariant(theme),
|
||||
theme,
|
||||
|
||||
@@ -231,9 +231,6 @@ async function boot(page, url) {
|
||||
await page.waitForFunction(() => Boolean(window.__godsEyeView?.dataManager), {
|
||||
timeout: 150_000,
|
||||
});
|
||||
await page.evaluate(() =>
|
||||
document.querySelector('.first-run-explore')?.click(),
|
||||
);
|
||||
await page.keyboard.press('Escape');
|
||||
await page.evaluate(() => {
|
||||
for (const el of document.querySelectorAll(
|
||||
|
||||
+17
-17
@@ -1980,16 +1980,19 @@ try {
|
||||
await wait(12_000);
|
||||
check('leaving Contacts restores Transit', await isOn());
|
||||
|
||||
// SPACE MISSIONS
|
||||
await page.evaluate(() =>
|
||||
window.__godsEyeView.dataManager.setEnabled('transit', false, {
|
||||
origin: 'user',
|
||||
}),
|
||||
);
|
||||
await wait(2_000);
|
||||
await page.click('#global-context-missions-btn');
|
||||
// SPACE MISSIONS: an ordinary layer. It neither refuses nor puts away
|
||||
// Transit, so a Transit switched on while it runs stays on after it ends.
|
||||
const setMissions = (enabled) =>
|
||||
page.evaluate(
|
||||
(on) =>
|
||||
window.__godsEyeView.dataManager.setEnabled('rocket-launches', on, {
|
||||
origin: 'user',
|
||||
}),
|
||||
enabled,
|
||||
);
|
||||
await setMissions(true);
|
||||
await wait(20_000);
|
||||
const blocked = await page.evaluate(async () => {
|
||||
const beside = await page.evaluate(async () => {
|
||||
const settled = await window.__godsEyeView.dataManager.setEnabled(
|
||||
'transit',
|
||||
true,
|
||||
@@ -2001,16 +2004,13 @@ try {
|
||||
};
|
||||
});
|
||||
check(
|
||||
'Space Missions refuses to enable Transit while it isolates replay data',
|
||||
blocked.enabled === false,
|
||||
JSON.stringify(blocked),
|
||||
'Transit can be switched on while Space Missions runs',
|
||||
beside.settled !== false && beside.enabled === true,
|
||||
JSON.stringify(beside),
|
||||
);
|
||||
await page.click('#global-context-missions-btn');
|
||||
await setMissions(false);
|
||||
await wait(12_000);
|
||||
check(
|
||||
'leaving Space Missions leaves Transit off, as it was on entry',
|
||||
(await isOn()) === false,
|
||||
);
|
||||
check('switching Space Missions off leaves Transit on', await isOn());
|
||||
|
||||
check(
|
||||
'no uncaught page errors',
|
||||
|
||||
@@ -1637,19 +1637,48 @@ async function main() {
|
||||
// The fixture planes repeat one position, so the icon holds and draws no
|
||||
// head. Fly the tracked one east for this check; the display runs 30 s
|
||||
// behind, so give it time to reach the moving reports.
|
||||
await evalPage((icao) => {
|
||||
await evalPage(async (icao) => {
|
||||
const { rendererOf } = await import(`${window.__gevQaSourceBase || '/src'}/render/rendererOf.js`);
|
||||
const app = window.__godsEyeView;
|
||||
const fl = app.dataManager.layers.get('flights').module;
|
||||
// Observe this selection's actual draw-port submissions: trails no
|
||||
// longer live in viewer.entities. Disabling destroys the reused trail
|
||||
// set, so this selection creates one the probe can identify.
|
||||
await app.dataManager.setEnabled('flights', false);
|
||||
const draw = rendererOf(app.viewer).draw;
|
||||
const createLines = draw.lines;
|
||||
let head = null;
|
||||
let trail = null;
|
||||
draw.lines = function (spec) {
|
||||
const set = createLines.call(this, spec);
|
||||
if (!spec.id.startsWith('trail:')) return set;
|
||||
draw.lines = createLines;
|
||||
trail = set;
|
||||
const upsert = set.upsert;
|
||||
set.upsert = function (items) {
|
||||
const result = upsert.call(this, items);
|
||||
for (const item of items)
|
||||
if (/^gev-trail:\d+:head$/.test(item.id)) head = item;
|
||||
return result;
|
||||
};
|
||||
const clear = set.clear;
|
||||
set.clear = function () { head = null; return clear.call(this); };
|
||||
const dispose = set.dispose;
|
||||
set.dispose = function () { head = null; trail = null; return dispose.call(this); };
|
||||
return set;
|
||||
};
|
||||
window.__qaTrailHead = () => trail?.show && head?.show !== false ? head?.positions : null;
|
||||
window.__qaRestoreTrailProbe = () => { draw.lines = createLines; };
|
||||
await app.dataManager.setEnabled('flights', true);
|
||||
if (!fl.trackById(icao)) throw new Error('trail fixture could not reselect its aircraft');
|
||||
const f = window.__SYNTH.flights.find((p) => p.icao === icao);
|
||||
f.moveFromMs = Date.now();
|
||||
}, trackedIcao);
|
||||
await sleep(55_000);
|
||||
const headSamples = await sampleFrames(page, 40, (icao) => {
|
||||
const viewer = window.__godsEyeView.viewer;
|
||||
const fl = window.__godsEyeView.dataManager.layers.get('flights').module;
|
||||
const ent = viewer.trackedEntity;
|
||||
const time = viewer.clock.currentTime;
|
||||
const head = viewer.entities.values.find((e) => String(e.id).startsWith('gev-trail:fl-head-'));
|
||||
const line = head?.polyline?.positions?.getValue(time);
|
||||
const drawn = ent?.position?.getValue(time);
|
||||
const line = window.__qaTrailHead();
|
||||
const drawn = window.__qaFollowed()?.position?.();
|
||||
if (!line?.length || !drawn) return null;
|
||||
const end = line[line.length - 1];
|
||||
const dist = (a, b) => Math.hypot(a.x - b.x, a.y - b.y, a.z - b.z);
|
||||
@@ -1695,10 +1724,8 @@ async function main() {
|
||||
for (let i = 0; i < 8; i++) {
|
||||
await sleep(600);
|
||||
betweenFrames.push(await evalPage((icao) => {
|
||||
const viewer = window.__godsEyeView.viewer;
|
||||
const head = viewer.entities.values.find((e) => String(e.id).startsWith('gev-trail:fl-head-'));
|
||||
const line = head?.polyline?.positions?.getValue(viewer.clock.currentTime);
|
||||
const drawn = viewer.trackedEntity?.position?.getValue(viewer.clock.currentTime);
|
||||
const line = window.__qaTrailHead();
|
||||
const drawn = window.__qaFollowed()?.position?.();
|
||||
if (!line?.length || !drawn) return null;
|
||||
const end = line[line.length - 1];
|
||||
return Math.hypot(end.x - drawn.x, end.y - drawn.y, end.z - drawn.z);
|
||||
@@ -1712,10 +1739,11 @@ async function main() {
|
||||
f.lon += (f.vel * (Date.now() - f.moveFromMs)) / 1000
|
||||
/ (111320 * Math.cos((f.lat * Math.PI) / 180));
|
||||
delete f.moveFromMs;
|
||||
window.__qaRestoreTrailProbe();
|
||||
}, trackedIcao);
|
||||
const headUsable = headSamples.values.filter((v) => v != null);
|
||||
if (headUsable.length < 10) {
|
||||
skip('trail head: ends at the drawn icon on every frame',
|
||||
record('trail head: ends at the drawn icon on every frame', false,
|
||||
`only ${headUsable.length} frames with a drawn head (timedOut=${headSamples.timedOut})`);
|
||||
} else {
|
||||
const worst = Math.max(...headUsable.map((v) => v.end));
|
||||
@@ -3681,6 +3709,9 @@ async function main() {
|
||||
} while (Date.now() < fleetClampDeadline
|
||||
&& (!Number.isFinite(fleetH) || fleetH < seeded + 1));
|
||||
if (!fl.trackById('aaa097')) return { error: 'trackById(aaa097) failed' };
|
||||
// The tracked contact obeys the same 3D toggle as the fleet. Arm it
|
||||
// before testing the cold-ground gate and the warm model handoff.
|
||||
fl.setParams({ models3d: true });
|
||||
await window.__dfSettle(1500);
|
||||
// Read the tracked entity's rendered height plus the floor under it and
|
||||
// the sensor value the data APIs report, at whatever regime the camera
|
||||
@@ -3770,6 +3801,7 @@ async function main() {
|
||||
};
|
||||
const trackedEntity = window.__qaFollowed();
|
||||
const trackedModel = findOwnModel();
|
||||
if (!trackedModel) return { error: 'tracked model absent before exit' };
|
||||
const achievedOut = await window.__dfZoomAbove(window.__dfRegime.exit + 5000);
|
||||
const zoomedOut = await window.__dfObserveTrackedExit({
|
||||
scene: v.scene, trackedEntity, trackedModel, getTrackedModel: findOwnModel,
|
||||
@@ -3908,10 +3940,8 @@ async function main() {
|
||||
// the tracked billboard becomes the visual again. Gating the clamp on
|
||||
// model EXISTENCE put the burial straight back in exactly that state.
|
||||
//
|
||||
// This scenario also pins the toggle contract itself. The DISPLAY-rail
|
||||
// "3D" toggle stays OFF for the whole block on purpose: it governs the
|
||||
// FLEET's draw-call budget only, and the tracked contact must still take
|
||||
// its model on zoom without the operator arming anything.
|
||||
// The tracked contact obeys the shared 3D toggle. Keep it enabled
|
||||
// while zoom alone hands the visual between model and billboard.
|
||||
const dfRetained = await evalPage(async () => {
|
||||
const v = window.__godsEyeView.viewer;
|
||||
const Cesium = await import('/node_modules/cesium/Build/Cesium/index.js');
|
||||
@@ -3924,13 +3954,13 @@ async function main() {
|
||||
// and there would otherwise hand an open skin to the seeded scenarios
|
||||
// that follow; closing an already-closed skin is inert.
|
||||
try {
|
||||
// Toggle OFF throughout — the tracked model must not need it.
|
||||
fl.setParams({ models3d: false });
|
||||
const toggleOff = fl.getParams().models3d === false;
|
||||
// Arm the shared toggle so the zoom regime can retain a hidden model.
|
||||
fl.setParams({ models3d: true });
|
||||
const toggleOn = fl.getParams().models3d === true;
|
||||
if (!fl.trackById('aaa097')) return { error: 'trackById(aaa097) failed' };
|
||||
await window.__dfSettle(600);
|
||||
// Below the ENTER ceiling (trackById re-frames to the close follow
|
||||
// range): the tracked model arrives on zoom alone, toggle still off.
|
||||
// range): the tracked model arrives on zoom alone, 3D enabled.
|
||||
const belowH = await window.__dfZoomBelow(window.__dfRegime.enter - 20000);
|
||||
const withModel = await window.__dfAwaitTrackedModel('aaa097', 20000);
|
||||
// Same split as the regime scenario: a browser with no usable GLB
|
||||
@@ -3980,7 +4010,7 @@ async function main() {
|
||||
const ent2 = window.__qaFollowed()?.position?.();
|
||||
const c2 = ent2 ? window.__dfCarto(ent2) : null;
|
||||
const out = {
|
||||
toggleOff,
|
||||
toggleOn,
|
||||
enter: window.__dfRegime.enter,
|
||||
exit: window.__dfRegime.exit,
|
||||
belowH,
|
||||
@@ -4015,23 +4045,19 @@ async function main() {
|
||||
record('display-floor/T7: while the tracked MODEL is the visual, the clamp stands aside',
|
||||
!dfRetained.error && dfRetained.modelsRenderingBelow > 0,
|
||||
dfRetained.error
|
||||
|| `${dfRetained.modelsRenderingBelow} aaa097 model(s) rendering at ${(dfRetained.belowH / 1000).toFixed(0)} km with the 3D toggle OFF; entity at ${Number(dfRetained.withModelH).toFixed(1)} m (ground-snap owns it)`);
|
||||
|| `${dfRetained.modelsRenderingBelow} aaa097 model(s) rendering at ${(dfRetained.belowH / 1000).toFixed(0)} km with the 3D toggle ON; entity at ${Number(dfRetained.withModelH).toFixed(1)} m (ground-snap owns it)`);
|
||||
|
||||
// The toggle contract after auto-3D (2026-08-20): the DISPLAY-rail "3D"
|
||||
// switch owns the FLEET only. The tracked contact's model is default-on
|
||||
// and decided purely by camera distance, so with the toggle OFF it is
|
||||
// SHOWN below the enter ceiling and handed back above the exit ceiling —
|
||||
// and handed back by HIDING, not destroying, which is the retained state
|
||||
// the floor pin below depends on.
|
||||
record('display-floor/regime: the 3D toggle governs the FLEET only — the tracked model follows the zoom',
|
||||
!dfRetained.error && dfRetained.toggleOff === true
|
||||
// With 3D enabled, zooming out hides rather than destroys the
|
||||
// tracked model: the retained state the floor check depends on.
|
||||
record('display-floor/regime: with 3D enabled the tracked model follows the zoom',
|
||||
!dfRetained.error && dfRetained.toggleOn === true
|
||||
&& dfRetained.modelsRenderingBelow > 0
|
||||
&& dfRetained.belowH < dfRetained.enter
|
||||
&& dfRetained.shownModelsAbove === 0
|
||||
&& dfRetained.hiddenModelsAbove > 0
|
||||
&& dfRetained.aboveH > dfRetained.exit,
|
||||
dfRetained.error
|
||||
|| `toggle OFF throughout: at ${(dfRetained.belowH / 1000).toFixed(0)} km (< ${(dfRetained.enter / 1000).toFixed(0)} km enter) ${dfRetained.modelsRenderingBelow} aaa097 model(s) rendering; at ${(dfRetained.aboveH / 1000).toFixed(0)} km (> ${(dfRetained.exit / 1000).toFixed(1)} km exit) ${dfRetained.shownModelsAbove} shown / ${dfRetained.hiddenModelsAbove} retained-hidden`);
|
||||
|| `toggle ON throughout: at ${(dfRetained.belowH / 1000).toFixed(0)} km (< ${(dfRetained.enter / 1000).toFixed(0)} km enter) ${dfRetained.modelsRenderingBelow} aaa097 model(s) rendering; at ${(dfRetained.aboveH / 1000).toFixed(0)} km (> ${(dfRetained.exit / 1000).toFixed(1)} km exit) ${dfRetained.shownModelsAbove} shown / ${dfRetained.hiddenModelsAbove} retained-hidden`);
|
||||
|
||||
record('display-floor: a retained-but-hidden tracked model does NOT suppress the floor',
|
||||
Number.isFinite(dfRetained.afterSeedH)
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
/**
|
||||
* The files of the Wikidata places detail pack
|
||||
* (`src/data/local_data/wikidata_places/`), from its rows. Used by
|
||||
* `scripts/build-wikidata-cities.mjs --tiles`; kept apart from the query so
|
||||
* the tiling can be checked offline against the shipped pack.
|
||||
*
|
||||
* Rows are `[name, lat, lon, population, country, wikidata]`. Each goes into
|
||||
* the 5 x 5 degree tile named by its south-west corner (`30_-100` covers 30
|
||||
* to 35 N, 100 to 95 W). Rows keep the order they are given in, largest
|
||||
* first; tiles without a row get no file.
|
||||
*/
|
||||
|
||||
import { foldName } from '../src/data/wikidataCities.js';
|
||||
import { greatCircleKm } from '../src/geoDistance.js';
|
||||
|
||||
export const TILE_DEGREES = 5;
|
||||
/** How near two rows of one name in one country are taken as one, in km. */
|
||||
export const TWIN_KM = 3;
|
||||
|
||||
/**
|
||||
* The rows the cities pack does not already hold. An item with several
|
||||
* stated populations can fall in both packs (one figure under the cut-off,
|
||||
* another over it); the cities pack keeps it, so the detail tiles never name
|
||||
* a place twice.
|
||||
* @param {Array<Array>} rows Detail rows, `[name, lat, lon, population, country, wikidata]`.
|
||||
* @param {Iterable<string>} cityIds Wikidata ids in the cities pack.
|
||||
*/
|
||||
export function withoutCities(rows, cityIds) {
|
||||
const cities = new Set(cityIds);
|
||||
return rows.filter((row) => !cities.has(row[5]));
|
||||
}
|
||||
|
||||
/** The tile a point falls in, named by its south-west corner. */
|
||||
export function tileKey(lat, lon) {
|
||||
const corner = (value) => Math.floor(value / TILE_DEGREES) * TILE_DEGREES;
|
||||
// As the lookups read them: latitude 90 is in the top row of tiles, and
|
||||
// longitude 180 is longitude -180.
|
||||
const top = 90 - TILE_DEGREES;
|
||||
return `${Math.min(top, corner(lat))}_${corner((((lon % 360) + 540) % 360) - 180)}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Every file of the pack, by file name.
|
||||
* @param {Array<Array>} rows Largest first.
|
||||
* @param {object} meta The build's `source`, `license`, `built`,
|
||||
* `minPopulation`, `maxPopulation` and `columns`.
|
||||
* @returns {Map<string, string>}
|
||||
*/
|
||||
export function placeTileFiles(rows, meta) {
|
||||
const tiles = new Map();
|
||||
for (const row of rows) {
|
||||
const key = tileKey(row[1], row[2]);
|
||||
if (!tiles.has(key)) tiles.set(key, []);
|
||||
tiles.get(key).push(row);
|
||||
}
|
||||
// In locale order, as the shipped pack was written.
|
||||
const keys = [...tiles.keys()].sort((a, b) => a.localeCompare(b, 'en'));
|
||||
const files = new Map();
|
||||
for (const key of keys)
|
||||
files.set(`${key}.json`, `${JSON.stringify({ rows: tiles.get(key) })}\n`);
|
||||
const index = {
|
||||
meta: {
|
||||
source: meta.source,
|
||||
license: meta.license,
|
||||
built: meta.built,
|
||||
minPopulation: meta.minPopulation,
|
||||
maxPopulation: meta.maxPopulation,
|
||||
count: rows.length,
|
||||
columns: meta.columns,
|
||||
tileDegrees: TILE_DEGREES,
|
||||
tiles: keys.length,
|
||||
},
|
||||
tiles: Object.fromEntries(keys.map((key) => [key, tiles.get(key).length])),
|
||||
};
|
||||
files.set('index.json', `${JSON.stringify(index)}\n`);
|
||||
files.set(
|
||||
'files.js',
|
||||
[
|
||||
'// Generated by scripts/build-wikidata-cities.mjs --tiles; do not edit.',
|
||||
"export const INDEX_URL = () => new URL('./index.json', import.meta.url);",
|
||||
'export const TILE_URLS = {',
|
||||
...keys.map(
|
||||
(key) => ` '${key}': () => new URL('./${key}.json', import.meta.url),`,
|
||||
),
|
||||
'};',
|
||||
'',
|
||||
].join('\n'),
|
||||
);
|
||||
return files;
|
||||
}
|
||||
|
||||
/**
|
||||
* A pack file's new text, keeping the earlier build's `meta.built` when
|
||||
* nothing else in the file changed, so rebuilding unchanged data leaves the
|
||||
* file as it was. A file that does not hold all of its pack's data (the
|
||||
* places index) is passed through this only when the rest of the pack is
|
||||
* unchanged too.
|
||||
* @param {string} text The new file, JSON with a `meta.built` stamp.
|
||||
* @param {string | undefined} earlier The file as it is now, if there is one.
|
||||
*/
|
||||
export function keepBuiltIfUnchanged(text, earlier) {
|
||||
if (!earlier) return text;
|
||||
let before;
|
||||
try {
|
||||
before = JSON.parse(earlier);
|
||||
} catch {
|
||||
return text;
|
||||
}
|
||||
const after = JSON.parse(text);
|
||||
if (typeof before?.meta?.built !== 'string' || !after.meta) return text;
|
||||
const unstamped = (value) =>
|
||||
JSON.stringify({ ...value, meta: { ...value.meta, built: null } });
|
||||
if (unstamped(before) !== unstamped(after)) return text;
|
||||
return `${JSON.stringify({ ...after, meta: { ...after.meta, built: before.meta.built } })}\n`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Keeps the earlier build's `meta.built` in the places pack's index when the
|
||||
* rebuild changed nothing: every tile and `files.js` the same text, no tile
|
||||
* of the earlier build left out, and nothing else in the index changed. The
|
||||
* index holds only row counts, so it alone cannot tell.
|
||||
* @param {Map<string, string>} files The new pack, as placeTileFiles gives it; its index is replaced in place.
|
||||
* @param {Map<string, string>} earlier The pack's files on disk now, by name.
|
||||
*/
|
||||
export function keepPackBuiltIfUnchanged(files, earlier) {
|
||||
for (const name of earlier.keys())
|
||||
if (name !== 'index.json' && !files.has(name)) return files;
|
||||
for (const [name, text] of files)
|
||||
if (name !== 'index.json' && earlier.get(name) !== text) return files;
|
||||
files.set(
|
||||
'index.json',
|
||||
keepBuiltIfUnchanged(files.get('index.json'), earlier.get('index.json')),
|
||||
);
|
||||
return files;
|
||||
}
|
||||
|
||||
const kmBetween = (a, b) =>
|
||||
greatCircleKm({ lat: a[1], lon: a[2] }, { lat: b[1], lon: b[2] });
|
||||
|
||||
/**
|
||||
* The rows without a second listing of one place: a row whose name (folded,
|
||||
* as lookups compare names) and country match a row already kept within
|
||||
* TWIN_KM is left out, so the larger of the two, given first, stays.
|
||||
* Namesakes across a border both stay.
|
||||
* @param {Array<Array>} rows Largest first.
|
||||
*/
|
||||
export function withoutNearTwins(rows) {
|
||||
// Cells of 0.05 degrees (about 5 km of latitude), searched with their
|
||||
// neighbours. A cell narrows toward the poles, so as many longitude cells
|
||||
// are searched as TWIN_KM spans there, wrapping at the antimeridian.
|
||||
const CELLS = 20;
|
||||
const AROUND = 360 * CELLS;
|
||||
const kept = new Map();
|
||||
return rows.filter((row) => {
|
||||
const name = foldName(row[0]);
|
||||
const la = Math.floor(row[1] * CELLS);
|
||||
const lo = Math.floor(row[2] * CELLS);
|
||||
const cos = Math.cos(
|
||||
(Math.min(89.9, Math.abs(row[1]) + 0.1) * Math.PI) / 180,
|
||||
);
|
||||
const span = Math.min(
|
||||
AROUND / 2,
|
||||
Math.ceil((TWIN_KM / (111.32 * cos)) * CELLS) + 1,
|
||||
);
|
||||
for (let i = -1; i <= 1; i++)
|
||||
for (let j = -span; j <= span; j++)
|
||||
for (const other of kept.get(
|
||||
`${la + i}_${(((lo + j) % AROUND) + AROUND) % AROUND}`,
|
||||
) || [])
|
||||
if (
|
||||
other.name === name &&
|
||||
other.row[4] === row[4] &&
|
||||
kmBetween(other.row, row) <= TWIN_KM
|
||||
)
|
||||
return false;
|
||||
const key = `${la}_${((lo % AROUND) + AROUND) % AROUND}`;
|
||||
if (!kept.has(key)) kept.set(key, []);
|
||||
kept.get(key).push({ name, row });
|
||||
return true;
|
||||
});
|
||||
}
|
||||
@@ -58,8 +58,8 @@ function realtimeDirectives(
|
||||
'For visual filter requests, call set_visual_style with one of the allowed style IDs.',
|
||||
'SHIPS vs STYLES: "vessels" is easily heard as "visuals". "Show me vessels", "turn on vessels", "the vessels", "visuals" or "vestibules" said WITHOUT a style name means the ships layer: set_layer_visibility{layerId:"ais-live-vessels"}, exactly as "ships" or "boats" does. Call set_visual_style only when the user names a style (retro/CRT, surveillance/night vision, thermal, anime, noir, normal) or says filter, effect or look. Never turn on a different data layer (such as fires) for a ships request.',
|
||||
'Disambiguation table — basemap vs layer vs style: basemap switching requires an explicit stack name — "Bing aerial" means set_map_stack bing-aerial, "aerial with labels" means bing-labels, "OSM"/"road map" means osm, "Esri"/"Esri imagery" means esri-imagery, "Google 3D"/"photorealistic" means photoreal. Any other mention of "satellite" or "satellites" means the satellites DATA LAYER via set_layer_visibility, never a basemap — except "recent/latest satellite imagery" (the recent-imagery layer) and "weather satellite"/clouds (weather-satellite). "surveillance"/"night vision"/"thermal" are visual STYLES via set_visual_style.',
|
||||
'HUD requests ("hud on/off", "switch to minimal/tactical/cyber layout") use set_hud. Detection requests ("detection on", "dense mode", "balanced mode", "sparse mode", "set density to 25", "use weighted allocation") use set_detection. Density snaps to 0/25/50/75/100 and derives Sparse/Balanced/Dense; panoptic is a legacy alias for Dense.',
|
||||
'Cyber sonar requests use set_cyber_sonar: enabled, rings, rangePct, intensityPct (Power), opacityPct, sectorDeg. For settings questions read get_current_view_state.controls.hud.sonar. Sonar is not detection. Do not silently switch themes, reveal the HUD or enable sonar when changing a slider. If the user explicitly requests Cyber plus sonar settings, call set_hud first, wait for success, then set_cyber_sonar. Confirm returned values; mapSweepActive and contactSweepActive distinguish saved settings from active map effects, including in Cockpit or reduced motion. Do not claim visible contacts solely because enabled is true.',
|
||||
'HUD requests ("hud on/off", "switch to minimal/tactical layout") use set_hud. Detection requests ("detection on", "dense mode", "balanced mode", "sparse mode", "set density to 25", "use weighted allocation") use set_detection. Density snaps to 0/25/50/75/100 and derives Sparse/Balanced/Dense; panoptic is a legacy alias for Dense.',
|
||||
'Sonar is a visual style over any HUD layout. Sonar requests (including "cyber mode", which was replaced by sonar) use set_cyber_sonar: enabled, rings, rangePct, intensityPct (Power), opacityPct, sectorDeg. For settings questions read get_current_view_state.controls.hud.sonar. Sonar is not detection. Do not silently switch layouts, reveal the HUD or enable sonar when changing a slider. Confirm returned values; mapSweepActive and contactSweepActive distinguish saved settings from active map effects, including in Cockpit or reduced motion. Do not claim visible contacts solely because enabled is true.',
|
||||
'Bloom/sharpen requests use set_post_processing. Scene requests ("play orbital watch", "stop the scene", "what scenes are there") use control_scene. CCTV camera requests ("next camera", "nearest camera", "select the Congress camera", "show coverage") use control_cctv — the CCTV layer must be enabled first.',
|
||||
'Radio playback requests use control_radio. "Turn on/start the radio" means action=play; action=enable only reveals Radio markers and must be reserved for explicit "show/enable the Radio layer/markers" requests. After a prepared playback result, briefly confirm any other completed actions and say "Turning on the radio"—never claim it is already playing. The client keeps Radio muted until playback is verified, then closes voice before restoring Radio volume. Examples: "play news near Austin" → select category=news locationId=austin; "play US news" → select category=news country=US; "Radio volume 30" → volume; pause/resume/stop/next/previous use the matching action. Radio selection never moves the camera.',
|
||||
'"Track/follow <something specific>" (a callsign, ship name, satellite name) uses track_entity. "Take me to the biggest fire" uses track_entity with query "biggest fire" (the fires layer must be enabled). Bare "orbit" means camera orbit of the current landmark. "Stop following/tracking" uses stop_tracking.',
|
||||
|
||||
@@ -225,7 +225,7 @@ export const ACTION_DESCRIPTIONS = {
|
||||
},
|
||||
set_cyber_sonar: {
|
||||
description:
|
||||
'Adjust Cyber-only sonar controls. Requires the Cyber HUD layout; never switches layout or HUD visibility. Omitted fields stay unchanged. Returns actual settings and separate map/contact sweep activity. A saved setting does not mean the effect is active.',
|
||||
'Adjust the Sonar visual style, which works over any HUD layout. Never switches layout or HUD visibility. Omitted fields stay unchanged. Returns actual settings and separate map/contact sweep activity. A saved setting does not mean the effect is active.',
|
||||
$position: 1,
|
||||
parameters: {
|
||||
properties: {
|
||||
|
||||
@@ -0,0 +1,428 @@
|
||||
import { registerWorldOverlayPaintLane } from '../../overlays/worldOverlay.js';
|
||||
import { fromDegrees } from '../../geo/ellipsoid.js';
|
||||
import {
|
||||
earthquakeContourRings,
|
||||
earthquakeContourScale,
|
||||
earthquakeContourShape,
|
||||
earthquakeRippleRings,
|
||||
EARTHQUAKE_RIPPLE_PERIOD_MS,
|
||||
} from '../../layers/earthquakes/model.js';
|
||||
|
||||
/** Points around each contour line: smooth at the largest disc on screen. */
|
||||
export const RIPPLE_RING_SEGMENTS = 96;
|
||||
/** An index contour's width, and every other line's. */
|
||||
const INDEX_WIDTH_PX = 2;
|
||||
const LINE_WIDTH_PX = 1.1;
|
||||
/**
|
||||
* The overlay lane the lines paint in: the magnitude labels' own. A lane's
|
||||
* custom painters run before its entries, so the lines sit under the labels
|
||||
* and under the selected quake's card.
|
||||
*/
|
||||
export const RIPPLE_PAINT_LANE = 'ambient-label';
|
||||
/**
|
||||
* The selected disc's fill, [offset, alpha] from the epicentre (0) to its
|
||||
* outer circle (1): strongest in the middle, fading out to nothing at the
|
||||
* edge.
|
||||
*/
|
||||
export const DISC_FADE = Object.freeze([
|
||||
[0, 0.42],
|
||||
[0.35, 0.26],
|
||||
[0.75, 0.1],
|
||||
[1, 0],
|
||||
]);
|
||||
/**
|
||||
* Each contour wave's fill, out to its own line: clear inside, tinting
|
||||
* toward the line; times the wave's own fade.
|
||||
*/
|
||||
export const WAVE_FADE = Object.freeze([
|
||||
[0, 0],
|
||||
[0.55, 0],
|
||||
[1, 0.2],
|
||||
]);
|
||||
|
||||
/**
|
||||
* `rgb(r,g,b)` (or `rgba`) as a function of alpha, for gradient stops; any
|
||||
* other colour keeps its own alpha.
|
||||
*/
|
||||
export function cssWithAlpha(color) {
|
||||
const m = /^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/.exec(String(color));
|
||||
if (!m) return () => color;
|
||||
const rgb = `${m[1]},${m[2]},${m[3]}`;
|
||||
return (alpha) => `rgba(${rgb},${Math.max(0, Math.min(1, alpha))})`;
|
||||
}
|
||||
|
||||
/**
|
||||
* How many times the lines run out to the edge after a quake is selected
|
||||
* before they rest as still contours and stop asking for frames: earthquakes
|
||||
* otherwise hold no render (docs/CURRENT-STATE.md, "Earthquake discs are
|
||||
* STATIC geometry"), and a quake can stay selected for hours.
|
||||
*/
|
||||
export const RIPPLE_ACTIVE_CYCLES = 3;
|
||||
|
||||
let reducedMotionQuery;
|
||||
/**
|
||||
* The viewer's reduced-motion setting, live: the media query is kept, so a
|
||||
* change mid-session is read at the next paint and tick.
|
||||
*/
|
||||
const reducedMotion = () => {
|
||||
try {
|
||||
reducedMotionQuery ??=
|
||||
globalThis.matchMedia?.('(prefers-reduced-motion: reduce)') ?? null;
|
||||
return reducedMotionQuery?.matches === true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/** How often the rings re-read the ground height under the quake. */
|
||||
const HEIGHT_READ_INTERVAL_MS = 500;
|
||||
/**
|
||||
* A ground height the rings accept, in metres: the Dead Sea shore to above
|
||||
* Everest. Anything else is a bad sample (a hit on something drawn above
|
||||
* the ground, or a broken tile), and the rings stay where they are.
|
||||
*/
|
||||
const groundHeightOk = (h) => Number.isFinite(h) && h >= -500 && h <= 9000;
|
||||
|
||||
/**
|
||||
* The selected earthquake's contour lines, painted on the world overlay:
|
||||
* wavy closed lines, shaped by the quake's id (earthquakeContourShape), run
|
||||
* from the marker out to the disc's edge and fade there, one after another,
|
||||
* for RIPPLE_ACTIVE_CYCLES runs after a quake is selected and only while it
|
||||
* is on screen, then rest as still contours. They never cross, and every third is
|
||||
* a heavier index contour, as on a topographic map. Nothing is drawn, and no
|
||||
* frame is asked for, while no quake is selected. With reduced motion the
|
||||
* lines hold still.
|
||||
*
|
||||
* A line is drawn in the tangent plane at the epicentre: at the largest
|
||||
* disc (M6, 64 km) it sits about 320 m above the curved ground at its edge
|
||||
* (64² / 2R), about 1.5 px off the drawn disc at the 220 km, -45° framing a
|
||||
* label click flies to (900 px tall, 35° field of view); less for smaller
|
||||
* quakes, as the offset grows with the square of the radius.
|
||||
* @param {object} [deps]
|
||||
* @param {Function} [deps.registerLane] `registerWorldOverlayPaintLane`.
|
||||
* @param {() => number} [deps.now] Steady clock, ms.
|
||||
* @param {(cb: Function) => number} [deps.requestFrame]
|
||||
* @param {(handle: number) => void} [deps.cancelFrame]
|
||||
* @param {() => boolean} [deps.prefersReducedMotion]
|
||||
* @returns {{show: Function, hide: Function, dispose: Function}}
|
||||
*/
|
||||
export function createEarthquakeRipples({
|
||||
registerLane = registerWorldOverlayPaintLane,
|
||||
now = () => globalThis.performance?.now?.() ?? Date.now(),
|
||||
requestFrame = (cb) => globalThis.requestAnimationFrame?.(cb) ?? null,
|
||||
cancelFrame = (handle) => globalThis.cancelAnimationFrame?.(handle),
|
||||
prefersReducedMotion = reducedMotion,
|
||||
} = {}) {
|
||||
let lane = null;
|
||||
let target = null;
|
||||
let frameHandle = null;
|
||||
// When the running lines settle into still contours (the selection's
|
||||
// bound), and whether the last paint found the quake on screen.
|
||||
let startedAt = 0;
|
||||
let settlesAt = 0;
|
||||
let onScreen = false;
|
||||
/** Whether the lines run now: in the window, and motion allowed. */
|
||||
const running = () => now() < settlesAt && !prefersReducedMotion();
|
||||
// Unit offsets around the line in the epicentre's tangent plane, packed
|
||||
// x, y, z per point: north·cos + east·sin.
|
||||
const offsets = new Float64Array((RIPPLE_RING_SEGMENTS + 1) * 3);
|
||||
const angles = new Float64Array(RIPPLE_RING_SEGMENTS + 1);
|
||||
for (let i = 0; i <= RIPPLE_RING_SEGMENTS; i++)
|
||||
angles[i] = (2 * Math.PI * i) / RIPPLE_RING_SEGMENTS;
|
||||
|
||||
// Screen points, reused every frame.
|
||||
const at = { x: 0, y: 0 };
|
||||
const centerAt = { x: 0, y: 0 };
|
||||
const eastAt = { x: 0, y: 0 };
|
||||
const northAt = { x: 0, y: 0 };
|
||||
|
||||
/** Project an ECEF point to CSS pixels; false when it is behind the eye. */
|
||||
function project(frame, px, py, pz, out) {
|
||||
const m = frame.viewProjectionMatrix;
|
||||
const w = m[3] * px + m[7] * py + m[11] * pz + m[15];
|
||||
if (w <= 0) return false;
|
||||
out.x =
|
||||
((m[0] * px + m[4] * py + m[8] * pz + m[12]) / w / 2 + 0.5) * frame.width;
|
||||
out.y =
|
||||
(0.5 - (m[1] * px + m[5] * py + m[9] * pz + m[13]) / w / 2) *
|
||||
frame.height;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trace one closed line at `fraction` of the disc's radius (`shaped`:
|
||||
* as a contour, else the disc's own circle). True when all of it is in
|
||||
* front of the eye, so it can be filled.
|
||||
*/
|
||||
function trace(frame, fraction, shaped) {
|
||||
const { ctx } = frame;
|
||||
const center = target.center;
|
||||
const reach = fraction * target.radiusM;
|
||||
ctx.beginPath();
|
||||
let pen = false;
|
||||
let whole = true;
|
||||
for (let i = 0; i <= RIPPLE_RING_SEGMENTS; i++) {
|
||||
// The last point repeats the first angle, so the line closes.
|
||||
const r = shaped
|
||||
? reach * earthquakeContourScale(target.shape, angles[i], fraction)
|
||||
: reach;
|
||||
const visible = project(
|
||||
frame,
|
||||
center.x + offsets[i * 3] * r,
|
||||
center.y + offsets[i * 3 + 1] * r,
|
||||
center.z + offsets[i * 3 + 2] * r,
|
||||
at,
|
||||
);
|
||||
if (!visible) {
|
||||
pen = false;
|
||||
whole = false;
|
||||
continue;
|
||||
}
|
||||
if (pen) ctx.lineTo(at.x, at.y);
|
||||
else ctx.moveTo(at.x, at.y);
|
||||
pen = true;
|
||||
}
|
||||
return whole;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill the traced path with a radial gradient laid on the ground: the
|
||||
* canvas places a path when it is traced and a gradient when it fills, so
|
||||
* under the disc's ground-to-screen transform the gradient's circle
|
||||
* becomes the disc's ellipse on screen while the path stays exact.
|
||||
* @param {Array<[number, number]>} stops [offset, alpha], out to `reach`.
|
||||
*/
|
||||
function fillGround(ctx, reach, stops) {
|
||||
ctx.save();
|
||||
ctx.transform(
|
||||
eastAt.x - centerAt.x,
|
||||
eastAt.y - centerAt.y,
|
||||
northAt.x - centerAt.x,
|
||||
northAt.y - centerAt.y,
|
||||
centerAt.x,
|
||||
centerAt.y,
|
||||
);
|
||||
const gradient = ctx.createRadialGradient(0, 0, 0, 0, 0, reach);
|
||||
for (const [offset, alpha] of stops)
|
||||
gradient.addColorStop(offset, target.rgba(alpha));
|
||||
ctx.fillStyle = gradient;
|
||||
ctx.globalAlpha = 1;
|
||||
ctx.fill();
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether any of the disc is in the viewport: its centre's screen point,
|
||||
* padded by its larger screen radius (or, seen edge-on, the centre alone).
|
||||
*/
|
||||
function discOnScreen(frame, c, e, n) {
|
||||
if (!Number.isFinite(c.x) || !Number.isFinite(c.y)) return false;
|
||||
const pad = Math.max(
|
||||
Math.hypot(e.x - c.x, e.y - c.y) || 0,
|
||||
Math.hypot(n.x - c.x, n.y - c.y) || 0,
|
||||
);
|
||||
return (
|
||||
c.x + pad >= 0 &&
|
||||
c.x - pad <= frame.width &&
|
||||
c.y + pad >= 0 &&
|
||||
c.y - pad <= frame.height
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-read the ground height under the quake, at most twice a second while
|
||||
* painting: the ground loads and refines as the camera comes in, and the
|
||||
* rings move onto it once it differs by more than a metre.
|
||||
*/
|
||||
function settleHeight() {
|
||||
if (!target.heightAt) return;
|
||||
const at = now();
|
||||
if (at - target.heightReadAt < HEIGHT_READ_INTERVAL_MS) return;
|
||||
target.heightReadAt = at;
|
||||
let height = null;
|
||||
try {
|
||||
height = target.heightAt();
|
||||
} catch {
|
||||
height = null;
|
||||
}
|
||||
if (!groundHeightOk(height) || Math.abs(height - target.heightM) <= 1)
|
||||
return;
|
||||
target.heightM = height;
|
||||
target.center = fromDegrees(target.lon, target.lat, height);
|
||||
}
|
||||
|
||||
function paint(frame) {
|
||||
if (!target) return;
|
||||
const { ctx } = frame;
|
||||
settleHeight();
|
||||
const center = target.center;
|
||||
onScreen = false;
|
||||
if (frame.occluder?.isPointVisible?.(center) === false) return;
|
||||
const R = target.radiusM;
|
||||
// The disc's ground frame on screen: its centre, and a radius east and
|
||||
// north. Seen edge-on (or partly behind the eye) it is not filled.
|
||||
const centerOk = project(frame, center.x, center.y, center.z, centerAt);
|
||||
const eastOk = project(
|
||||
frame,
|
||||
center.x + target.east.x * R,
|
||||
center.y + target.east.y * R,
|
||||
center.z + target.east.z * R,
|
||||
eastAt,
|
||||
);
|
||||
const northOk = project(
|
||||
frame,
|
||||
center.x + target.north.x * R,
|
||||
center.y + target.north.y * R,
|
||||
center.z + target.north.z * R,
|
||||
northAt,
|
||||
);
|
||||
let fills = centerOk && eastOk && northOk;
|
||||
if (fills) {
|
||||
const area =
|
||||
(eastAt.x - centerAt.x) * (northAt.y - centerAt.y) -
|
||||
(eastAt.y - centerAt.y) * (northAt.x - centerAt.x);
|
||||
fills = Math.abs(area) > 1;
|
||||
}
|
||||
onScreen =
|
||||
centerOk &&
|
||||
discOnScreen(
|
||||
frame,
|
||||
centerAt,
|
||||
eastOk ? eastAt : centerAt,
|
||||
northOk ? northAt : centerAt,
|
||||
);
|
||||
// The disc: strongest at the epicentre, fading out to its outer circle.
|
||||
if (fills && trace(frame, 1, false)) fillGround(ctx, 1, DISC_FADE);
|
||||
const animate = running();
|
||||
const rings = animate
|
||||
? earthquakeRippleRings(now() - startedAt)
|
||||
: earthquakeContourRings();
|
||||
// Brought back into view while the window lasts: run again.
|
||||
if (animate && onScreen && frameHandle === null && lane)
|
||||
frameHandle = requestFrame(tick);
|
||||
ctx.strokeStyle = target.color;
|
||||
ctx.lineJoin = 'round';
|
||||
for (const { fraction, alpha, index } of rings) {
|
||||
if (!(alpha > 0.01)) continue;
|
||||
const whole = trace(frame, fraction, true);
|
||||
// Each wave: clear inside, tinting toward its own line, as it fades.
|
||||
if (fills && whole)
|
||||
fillGround(
|
||||
ctx,
|
||||
fraction,
|
||||
WAVE_FADE.map(([offset, a]) => [offset, a * alpha]),
|
||||
);
|
||||
ctx.lineWidth = index ? INDEX_WIDTH_PX : LINE_WIDTH_PX;
|
||||
ctx.globalAlpha = alpha;
|
||||
ctx.stroke();
|
||||
}
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
|
||||
/** Ask for one more frame while the lines run (one request at a time). */
|
||||
function tick() {
|
||||
frameHandle = null;
|
||||
if (!target || !lane) return;
|
||||
// Settled, or out of sight: one last paint draws the still contours
|
||||
// (or nothing), and no more frames are asked for. A paint that finds it
|
||||
// on screen again inside the window starts the frames again.
|
||||
if (!running() || !onScreen) {
|
||||
lane.requestPaint();
|
||||
return;
|
||||
}
|
||||
lane.requestPaint();
|
||||
frameHandle = requestFrame(tick);
|
||||
}
|
||||
|
||||
function stopFrames() {
|
||||
if (frameHandle !== null) cancelFrame(frameHandle);
|
||||
frameHandle = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the contour lines around one quake, replacing any other.
|
||||
* @param {{id: string, lon: number, lat: number, heightM?: number, heightAt?: () => number|null, radiusM: number, color: string}} next
|
||||
* @param {{restart?: boolean}} [options] `restart: false` updates the
|
||||
* same quake in place (a feed refresh) without running it again.
|
||||
*/
|
||||
function show(next, { restart = true } = {}) {
|
||||
if (
|
||||
!next ||
|
||||
!Number.isFinite(next.lon) ||
|
||||
!Number.isFinite(next.lat) ||
|
||||
!(next.radiusM > 0)
|
||||
) {
|
||||
hide();
|
||||
return;
|
||||
}
|
||||
const sameQuake = target?.id === next.id;
|
||||
const lon = (next.lon * Math.PI) / 180;
|
||||
const lat = (next.lat * Math.PI) / 180;
|
||||
const [sinLon, cosLon] = [Math.sin(lon), Math.cos(lon)];
|
||||
const [sinLat, cosLat] = [Math.sin(lat), Math.cos(lat)];
|
||||
for (let i = 0; i <= RIPPLE_RING_SEGMENTS; i++) {
|
||||
const [c, s] = [Math.cos(angles[i]), Math.sin(angles[i])];
|
||||
offsets[i * 3] = c * -sinLat * cosLon + s * -sinLon;
|
||||
offsets[i * 3 + 1] = c * -sinLat * sinLon + s * cosLon;
|
||||
offsets[i * 3 + 2] = c * cosLat;
|
||||
}
|
||||
target = {
|
||||
id: next.id,
|
||||
// On the ground the disc is draped on: the height known now, then
|
||||
// re-read while painting (see `settleHeight`), since a label's fly-to
|
||||
// starts from far away, before that ground has loaded.
|
||||
lon: next.lon,
|
||||
lat: next.lat,
|
||||
heightM: groundHeightOk(next.heightM) ? next.heightM : 0,
|
||||
heightAt: typeof next.heightAt === 'function' ? next.heightAt : null,
|
||||
heightReadAt: -Infinity,
|
||||
center: fromDegrees(
|
||||
next.lon,
|
||||
next.lat,
|
||||
groundHeightOk(next.heightM) ? next.heightM : 0,
|
||||
),
|
||||
radiusM: next.radiusM,
|
||||
color: next.color || 'rgb(255,165,0)',
|
||||
shape: earthquakeContourShape(next.id),
|
||||
rgba: cssWithAlpha(next.color || 'rgb(255,165,0)'),
|
||||
// Angle 0 is north and a quarter turn is east (see `offsets`).
|
||||
north: { x: offsets[0], y: offsets[1], z: offsets[2] },
|
||||
east: {
|
||||
x: offsets[(RIPPLE_RING_SEGMENTS / 4) * 3],
|
||||
y: offsets[(RIPPLE_RING_SEGMENTS / 4) * 3 + 1],
|
||||
z: offsets[(RIPPLE_RING_SEGMENTS / 4) * 3 + 2],
|
||||
},
|
||||
};
|
||||
if (restart || !sameQuake) {
|
||||
startedAt = now();
|
||||
settlesAt =
|
||||
startedAt + RIPPLE_ACTIVE_CYCLES * EARTHQUAKE_RIPPLE_PERIOD_MS;
|
||||
// Assume it is in view until a paint says otherwise.
|
||||
onScreen = true;
|
||||
}
|
||||
lane ??= registerLane(RIPPLE_PAINT_LANE, paint, {
|
||||
id: 'earthquake-ripples',
|
||||
});
|
||||
lane.setActive(true);
|
||||
lane.requestPaint();
|
||||
// A refresh while the disc is out of sight asks for no frame; a paint
|
||||
// that finds it on screen again starts them (a restart sets onScreen).
|
||||
if (running() && onScreen && frameHandle === null)
|
||||
frameHandle = requestFrame(tick);
|
||||
}
|
||||
|
||||
function hide() {
|
||||
stopFrames();
|
||||
if (!target) return;
|
||||
target = null;
|
||||
lane?.setActive(false);
|
||||
}
|
||||
|
||||
function dispose() {
|
||||
hide();
|
||||
lane?.unregister();
|
||||
lane = null;
|
||||
}
|
||||
|
||||
return { show, hide, dispose };
|
||||
}
|
||||
@@ -0,0 +1,452 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import {
|
||||
DISC_FADE,
|
||||
cssWithAlpha,
|
||||
RIPPLE_ACTIVE_CYCLES,
|
||||
RIPPLE_PAINT_LANE,
|
||||
RIPPLE_RING_SEGMENTS,
|
||||
createEarthquakeRipples,
|
||||
} from './earthquakeRipples.js';
|
||||
import {
|
||||
EARTHQUAKE_RIPPLE_PERIOD_MS,
|
||||
EARTHQUAKE_RIPPLE_RINGS,
|
||||
} from '../../layers/earthquakes/model.js';
|
||||
import { fromDegrees } from '../../geo/ellipsoid.js';
|
||||
|
||||
/** A paint lane, frame clock and canvas the test steps by hand. */
|
||||
function harness({ reducedMotion = false } = {}) {
|
||||
let motionReduced = reducedMotion;
|
||||
const lanes = [];
|
||||
const frames = new Map();
|
||||
let nextFrame = 1;
|
||||
let clock = 0;
|
||||
const ripples = createEarthquakeRipples({
|
||||
registerLane(laneId, painter, options) {
|
||||
const lane = {
|
||||
laneId,
|
||||
painter,
|
||||
options,
|
||||
active: false,
|
||||
paints: 0,
|
||||
unregistered: false,
|
||||
setActive(next) {
|
||||
lane.active = next;
|
||||
},
|
||||
requestPaint() {
|
||||
lane.paints++;
|
||||
},
|
||||
unregister() {
|
||||
lane.unregistered = true;
|
||||
},
|
||||
};
|
||||
lanes.push(lane);
|
||||
return lane;
|
||||
},
|
||||
now: () => clock,
|
||||
requestFrame(cb) {
|
||||
const handle = nextFrame++;
|
||||
frames.set(handle, cb);
|
||||
return handle;
|
||||
},
|
||||
cancelFrame: (handle) => frames.delete(handle),
|
||||
prefersReducedMotion: () => motionReduced,
|
||||
});
|
||||
const strokes = [];
|
||||
const fills = [];
|
||||
let path = null;
|
||||
const ctx = {
|
||||
globalAlpha: 1,
|
||||
beginPath() {
|
||||
path = { moves: 0, lines: 0 };
|
||||
},
|
||||
moveTo() {
|
||||
path.moves++;
|
||||
},
|
||||
lineTo() {
|
||||
path.lines++;
|
||||
},
|
||||
stroke() {
|
||||
strokes.push({
|
||||
...path,
|
||||
alpha: ctx.globalAlpha,
|
||||
color: ctx.strokeStyle,
|
||||
width: ctx.lineWidth,
|
||||
});
|
||||
},
|
||||
// Fills record their path, gradient and the transform they fill under.
|
||||
saved: 0,
|
||||
transformed: null,
|
||||
save() {
|
||||
ctx.saved++;
|
||||
},
|
||||
restore() {
|
||||
ctx.saved--;
|
||||
ctx.transformed = null;
|
||||
},
|
||||
transform(...args) {
|
||||
ctx.transformed = args;
|
||||
},
|
||||
createRadialGradient(...circles) {
|
||||
const gradient = { circles, stops: [] };
|
||||
gradient.addColorStop = (offset, color) =>
|
||||
gradient.stops.push([offset, color]);
|
||||
return gradient;
|
||||
},
|
||||
fill() {
|
||||
fills.push({
|
||||
...path,
|
||||
gradient: ctx.fillStyle,
|
||||
transform: ctx.transformed,
|
||||
});
|
||||
},
|
||||
};
|
||||
// w = 1 everywhere: every point is in front of the eye.
|
||||
const matrix = new Float64Array(16);
|
||||
matrix[0] = 1e-7;
|
||||
matrix[5] = 1e-7;
|
||||
matrix[15] = 1;
|
||||
const frame = (visible = true) => ({
|
||||
ctx,
|
||||
width: 800,
|
||||
height: 600,
|
||||
viewProjectionMatrix: matrix,
|
||||
occluder: { isPointVisible: () => visible },
|
||||
});
|
||||
return {
|
||||
ripples,
|
||||
lanes,
|
||||
frames,
|
||||
strokes,
|
||||
fills,
|
||||
frame,
|
||||
matrix,
|
||||
setReducedMotion(next) {
|
||||
motionReduced = next;
|
||||
},
|
||||
advance(ms) {
|
||||
clock += ms;
|
||||
},
|
||||
/** Run the pending animation frames once. */
|
||||
step() {
|
||||
const pending = [...frames.entries()];
|
||||
frames.clear();
|
||||
for (const [, cb] of pending) cb();
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const target = {
|
||||
id: 'ak1',
|
||||
lon: -153.3,
|
||||
lat: 60,
|
||||
radiusM: 32000,
|
||||
color: 'rgb(255,0,0)',
|
||||
};
|
||||
|
||||
test('nothing is registered or animated until a quake is selected', () => {
|
||||
const h = harness();
|
||||
assert.equal(h.lanes.length, 0);
|
||||
assert.equal(h.frames.size, 0);
|
||||
h.ripples.hide();
|
||||
assert.equal(h.frames.size, 0);
|
||||
});
|
||||
|
||||
test('a selected quake animates one ring set, one frame request at a time', () => {
|
||||
const h = harness();
|
||||
h.ripples.show(target);
|
||||
const [lane] = h.lanes;
|
||||
assert.equal(lane.laneId, RIPPLE_PAINT_LANE);
|
||||
assert.equal(RIPPLE_PAINT_LANE, 'ambient-label', 'under the labels');
|
||||
assert.equal(lane.active, true);
|
||||
assert.equal(h.frames.size, 1);
|
||||
h.ripples.show({ ...target, id: 'ak2' });
|
||||
assert.equal(h.lanes.length, 1, 'the lane is reused');
|
||||
assert.equal(h.frames.size, 1, 'still one frame loop');
|
||||
const before = lane.paints;
|
||||
h.step();
|
||||
h.step();
|
||||
assert.equal(lane.paints, before + 2, 'one repaint per frame');
|
||||
assert.equal(h.frames.size, 1);
|
||||
|
||||
h.advance(600);
|
||||
lane.painter(h.frame());
|
||||
// At 600 ms every line is between the marker and the edge, so all draw.
|
||||
assert.equal(h.strokes.length, EARTHQUAKE_RIPPLE_RINGS);
|
||||
assert.deepEqual(
|
||||
h.strokes.map((stroke) => stroke.width),
|
||||
[2, 1.1, 1.1, 2, 1.1, 1.1],
|
||||
'every third line is an index contour',
|
||||
);
|
||||
for (const stroke of h.strokes) {
|
||||
assert.equal(stroke.moves, 1, 'one unbroken ring');
|
||||
assert.equal(stroke.lines, RIPPLE_RING_SEGMENTS);
|
||||
assert.equal(stroke.color, 'rgb(255,0,0)');
|
||||
assert.ok(stroke.alpha > 0 && stroke.alpha <= 1);
|
||||
}
|
||||
|
||||
h.ripples.hide();
|
||||
assert.equal(lane.active, false);
|
||||
assert.equal(h.frames.size, 0, 'no frames asked for once hidden');
|
||||
h.strokes.length = 0;
|
||||
lane.painter(h.frame());
|
||||
assert.equal(h.strokes.length, 0);
|
||||
});
|
||||
|
||||
test('rings are skipped behind the globe and broken behind the eye', () => {
|
||||
const h = harness();
|
||||
h.ripples.show(target);
|
||||
h.advance(600);
|
||||
const [lane] = h.lanes;
|
||||
lane.painter(h.frame(false));
|
||||
assert.equal(h.strokes.length, 0, 'epicentre over the horizon');
|
||||
|
||||
// Points with negative x fall behind the eye: each ring breaks there.
|
||||
const frame = h.frame();
|
||||
frame.viewProjectionMatrix[3] = 1e-6;
|
||||
const center = fromDegrees(target.lon, target.lat);
|
||||
frame.viewProjectionMatrix[15] = -1e-6 * center.x;
|
||||
lane.painter(frame);
|
||||
assert.equal(h.strokes.length, EARTHQUAKE_RIPPLE_RINGS);
|
||||
for (const stroke of h.strokes)
|
||||
assert.ok(stroke.lines < RIPPLE_RING_SEGMENTS, 'part of each ring hidden');
|
||||
});
|
||||
|
||||
test('reduced motion draws still contour rings and asks for no frames', () => {
|
||||
const h = harness({ reducedMotion: true });
|
||||
h.ripples.show(target);
|
||||
assert.equal(h.frames.size, 0);
|
||||
assert.equal(h.lanes[0].paints, 1, 'painted once');
|
||||
h.lanes[0].painter(h.frame());
|
||||
assert.equal(h.strokes.length, EARTHQUAKE_RIPPLE_RINGS);
|
||||
assert.ok(h.strokes.every((stroke) => stroke.alpha === 0.7));
|
||||
});
|
||||
|
||||
test('an unusable target hides the rings; dispose releases the lane', () => {
|
||||
const h = harness();
|
||||
h.ripples.show(target);
|
||||
h.ripples.show({ ...target, radiusM: 0 });
|
||||
assert.equal(h.lanes[0].active, false);
|
||||
assert.equal(h.frames.size, 0);
|
||||
h.ripples.dispose();
|
||||
assert.equal(h.lanes[0].unregistered, true);
|
||||
// Shown again after dispose, it registers a fresh lane.
|
||||
h.ripples.show(target);
|
||||
assert.equal(h.lanes.length, 2);
|
||||
h.ripples.dispose();
|
||||
});
|
||||
|
||||
test('contour lines are wavy, the same for a quake every time, and inside the disc', () => {
|
||||
const h = harness();
|
||||
h.ripples.show(target);
|
||||
h.advance(600);
|
||||
// An identity-like projection: screen x, y follow ECEF y, z, so the
|
||||
// distance from the projected epicentre measures each point's radius.
|
||||
const frame = h.frame();
|
||||
const m = frame.viewProjectionMatrix;
|
||||
m[0] = 0;
|
||||
m[5] = 0;
|
||||
m[4] = 1e-6;
|
||||
m[9] = 1e-6;
|
||||
const points = [];
|
||||
const ctx = frame.ctx;
|
||||
const record = (x, y) => points.at(-1).push([x, y]);
|
||||
ctx.beginPath = () => points.push([]);
|
||||
ctx.moveTo = record;
|
||||
ctx.lineTo = record;
|
||||
ctx.stroke = () => {};
|
||||
h.lanes[0].painter(frame);
|
||||
const center = fromDegrees(target.lon, target.lat);
|
||||
const cx = (center.y * 1e-6 * 0.5 + 0.5) * 800;
|
||||
const cy = (0.5 - center.z * 1e-6 * 0.5) * 600;
|
||||
const spread = (line) => {
|
||||
const radii = line.map(([x, y]) => Math.hypot(x - cx, y - cy));
|
||||
return Math.max(...radii) / Math.min(...radii);
|
||||
};
|
||||
// The disc's outer circle first (filled, not stroked), then each line.
|
||||
assert.equal(points.length, EARTHQUAKE_RIPPLE_RINGS + 1);
|
||||
points.shift();
|
||||
assert.ok(
|
||||
points.every((line) => spread(line) > 1.05),
|
||||
'not circles: each line dents in and out',
|
||||
);
|
||||
for (const line of points) {
|
||||
const [first, last] = [line[0], line.at(-1)];
|
||||
assert.ok(
|
||||
Math.hypot(first[0] - last[0], first[1] - last[1]) < 1e-6,
|
||||
'closed',
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('the disc fades out to its outer circle; each wave fills with a fade', () => {
|
||||
const h = harness();
|
||||
h.ripples.show(target);
|
||||
h.advance(600);
|
||||
// A projection where east and north span the screen: the disc is seen
|
||||
// from above, so its ground frame can be filled.
|
||||
const frame = h.frame();
|
||||
const m = frame.viewProjectionMatrix;
|
||||
m[0] = 0;
|
||||
m[5] = 0;
|
||||
m[4] = 1e-6;
|
||||
m[9] = 1e-6;
|
||||
h.lanes[0].painter(frame);
|
||||
assert.equal(h.fills.length, 1 + EARTHQUAKE_RIPPLE_RINGS);
|
||||
const [disc, ...waves] = h.fills;
|
||||
assert.equal(disc.lines, RIPPLE_RING_SEGMENTS, 'the whole outer circle');
|
||||
assert.deepEqual(disc.gradient.circles, [0, 0, 0, 0, 0, 1]);
|
||||
assert.deepEqual(
|
||||
disc.gradient.stops,
|
||||
DISC_FADE.map(([offset, alpha]) => [offset, `rgba(255,0,0,${alpha})`]),
|
||||
);
|
||||
assert.equal(disc.gradient.stops.at(-1)[1], 'rgba(255,0,0,0)', 'fades out');
|
||||
assert.ok(disc.transform, 'filled under the ground-to-screen transform');
|
||||
assert.equal(h.fills.length, waves.length + 1);
|
||||
for (const wave of waves) {
|
||||
const reach = wave.gradient.circles[5];
|
||||
assert.ok(reach > 0 && reach < 1, 'out to its own line');
|
||||
assert.equal(wave.gradient.stops[0][1], 'rgba(255,0,0,0)', 'clear inside');
|
||||
}
|
||||
// The transforms were undone: nothing leaks into the labels' painting.
|
||||
assert.equal(frame.ctx.saved, 0);
|
||||
// Seen edge-on, the ground frame has no area: lines only, no fills.
|
||||
h.fills.length = 0;
|
||||
m[9] = 0;
|
||||
m[5] = 0;
|
||||
h.lanes[0].painter(frame);
|
||||
assert.equal(h.fills.length, 0);
|
||||
});
|
||||
|
||||
test('cssWithAlpha turns rgb into rgba stops', () => {
|
||||
assert.equal(cssWithAlpha('rgb(255,165,0)')(0.25), 'rgba(255,165,0,0.25)');
|
||||
assert.equal(cssWithAlpha('rgba(1, 2, 3, 0.5)')(2), 'rgba(1,2,3,1)');
|
||||
assert.equal(cssWithAlpha('red')(0.3), 'red');
|
||||
});
|
||||
|
||||
test('the lines run a bounded time after a selection, then rest without frames', () => {
|
||||
const h = harness();
|
||||
h.ripples.show(target);
|
||||
const [lane] = h.lanes;
|
||||
const window = RIPPLE_ACTIVE_CYCLES * EARTHQUAKE_RIPPLE_PERIOD_MS;
|
||||
assert.ok(window <= 15_000, 'about a quarter of a minute at most');
|
||||
let frames = 0;
|
||||
for (let t = 0; t < window * 3; t += 16) {
|
||||
if (!h.frames.size) break;
|
||||
lane.painter(h.frame());
|
||||
h.advance(16);
|
||||
h.step();
|
||||
frames++;
|
||||
}
|
||||
assert.equal(h.frames.size, 0, 'no frame asked for once settled');
|
||||
assert.ok(frames <= Math.ceil(window / 16) + 2, `bounded: ${frames} frames`);
|
||||
// At rest the lines hold still as readable contours.
|
||||
h.strokes.length = 0;
|
||||
lane.painter(h.frame());
|
||||
assert.equal(h.strokes.length, EARTHQUAKE_RIPPLE_RINGS);
|
||||
assert.ok(h.strokes.every((stroke) => stroke.alpha === 0.7));
|
||||
// A parked camera repainting the overlay does not start them again.
|
||||
lane.painter(h.frame());
|
||||
assert.equal(h.frames.size, 0);
|
||||
// A new selection runs again.
|
||||
h.ripples.show({ ...target, id: 'ak2' });
|
||||
assert.equal(h.frames.size, 1);
|
||||
h.ripples.dispose();
|
||||
});
|
||||
|
||||
test('off screen the frames stop; back in view inside the window they resume', () => {
|
||||
const h = harness();
|
||||
h.ripples.show(target);
|
||||
const [lane] = h.lanes;
|
||||
// Behind the globe.
|
||||
lane.painter(h.frame(false));
|
||||
const paints = lane.paints;
|
||||
h.step();
|
||||
assert.equal(h.frames.size, 0, 'stopped while out of sight');
|
||||
assert.equal(lane.paints, paints + 1, 'one last paint, then none');
|
||||
h.step();
|
||||
assert.equal(lane.paints, paints + 1);
|
||||
// Panned away: the disc is far off the viewport.
|
||||
h.ripples.show(target);
|
||||
const away = h.frame();
|
||||
away.viewProjectionMatrix[12] = 50;
|
||||
lane.painter(away);
|
||||
h.step();
|
||||
assert.equal(h.frames.size, 0);
|
||||
// The camera brings it back while the window lasts.
|
||||
away.viewProjectionMatrix[12] = 0;
|
||||
lane.painter(h.frame());
|
||||
assert.equal(h.frames.size, 1, 'resumed');
|
||||
h.ripples.dispose();
|
||||
});
|
||||
|
||||
test('turning reduced motion on mid-run stills the lines and stops the frames', () => {
|
||||
const h = harness();
|
||||
h.ripples.show(target);
|
||||
const [lane] = h.lanes;
|
||||
lane.painter(h.frame());
|
||||
h.setReducedMotion(true);
|
||||
h.step();
|
||||
assert.equal(h.frames.size, 0);
|
||||
h.strokes.length = 0;
|
||||
lane.painter(h.frame());
|
||||
assert.ok(
|
||||
h.strokes.every((stroke) => stroke.alpha === 0.7),
|
||||
'still',
|
||||
);
|
||||
// Turned off again within the window: the next paint runs them again.
|
||||
h.setReducedMotion(false);
|
||||
lane.painter(h.frame());
|
||||
assert.equal(h.frames.size, 1);
|
||||
h.ripples.dispose();
|
||||
});
|
||||
|
||||
test('a refresh of the same quake does not run a settled selection again', () => {
|
||||
const h = harness();
|
||||
h.ripples.show(target);
|
||||
const [lane] = h.lanes;
|
||||
h.advance(RIPPLE_ACTIVE_CYCLES * EARTHQUAKE_RIPPLE_PERIOD_MS + 1);
|
||||
lane.painter(h.frame());
|
||||
h.step();
|
||||
assert.equal(h.frames.size, 0, 'settled');
|
||||
h.ripples.show({ ...target, radiusM: 40000 }, { restart: false });
|
||||
assert.equal(h.frames.size, 0, 'a refresh keeps it at rest');
|
||||
lane.painter(h.frame());
|
||||
assert.equal(h.frames.size, 0);
|
||||
// A different quake, or a user's restart, runs again.
|
||||
h.ripples.show({ ...target, id: 'other' }, { restart: false });
|
||||
assert.equal(h.frames.size, 1);
|
||||
h.ripples.dispose();
|
||||
});
|
||||
|
||||
// The rings sit on the ground the disc is draped on. A label's fly-to starts
|
||||
// far away, before that ground loads, so the painter reads the height again
|
||||
// while it paints and moves the rings onto it.
|
||||
test('the rings move onto the ground height once it loads', () => {
|
||||
const h = harness();
|
||||
let ground = null;
|
||||
h.ripples.show({ ...target, heightM: 0, heightAt: () => ground });
|
||||
h.advance(600);
|
||||
const [lane] = h.lanes;
|
||||
lane.painter(h.frame());
|
||||
const atSea = h.fills.at(-1).transform;
|
||||
h.fills.length = 0;
|
||||
ground = 4000;
|
||||
h.advance(600);
|
||||
lane.painter(h.frame());
|
||||
const onGround = h.fills.at(-1).transform;
|
||||
assert.notDeepEqual(onGround, atSea, 'the centre moved up onto the ground');
|
||||
// A change of a metre or less, or an impossible height, leaves them put.
|
||||
for (const next of [4000.5, 25000, -2000]) {
|
||||
ground = next;
|
||||
h.advance(600);
|
||||
lane.painter(h.frame());
|
||||
assert.deepEqual(h.fills.at(-1).transform, onGround, String(next));
|
||||
}
|
||||
// Reads are bounded: a second paint within the interval does not ask again.
|
||||
let reads = 0;
|
||||
h.ripples.show({ ...target, id: 'ak2', heightAt: () => (reads++, 4000) });
|
||||
lane.painter(h.frame());
|
||||
lane.painter(h.frame());
|
||||
assert.equal(reads, 1);
|
||||
});
|
||||
@@ -1,6 +1,49 @@
|
||||
import { createEarthquakesLayer } from '../../layers/earthquakes/index.js';
|
||||
import { overlayHost } from './overlayHost.js';
|
||||
/** Wire earthquake observations to the application overlay host. */
|
||||
import { inputFor } from '../../input/dispatcher.js';
|
||||
import * as picking from '../../data/pickRegistry.js';
|
||||
import * as context from '../../data/contextStore.js';
|
||||
import { isPointerFree } from '../../data/inputOwnership.js';
|
||||
import { requestWorldFocus } from '../../worldFocus.js';
|
||||
import { createEarthquakeRipples } from './earthquakeRipples.js';
|
||||
import { heightsOf } from '../../queries/heights.js';
|
||||
import { formatDate, formatNumber, t } from '../../i18n/index.js';
|
||||
|
||||
const EVENT_TIME = Object.freeze({
|
||||
day: 'numeric',
|
||||
month: 'short',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
timeZone: 'UTC',
|
||||
timeZoneName: 'short',
|
||||
});
|
||||
|
||||
/** The clicked quake's card text, in the page's language. */
|
||||
export const earthquakeCardText = Object.freeze({
|
||||
t,
|
||||
formatTime: (time) => formatDate(time, EVENT_TIME),
|
||||
formatDepth: (km) => formatNumber(km, { maximumFractionDigits: 1 }),
|
||||
});
|
||||
|
||||
/**
|
||||
* Wire earthquake observations to the application overlay host, and its
|
||||
* discs to the globe's clicks: a clicked quake shows its detail card.
|
||||
*/
|
||||
export function createApplicationEarthquakes(options) {
|
||||
return createEarthquakesLayer({ overlayHost, ...options });
|
||||
return createEarthquakesLayer({
|
||||
overlayHost,
|
||||
input: (viewer) => inputFor(viewer),
|
||||
picking,
|
||||
context,
|
||||
pointer: { isPointerFree },
|
||||
openExternal: (url) => window.open(url, '_blank', 'noopener,noreferrer'),
|
||||
focus: { requestWorldFocus },
|
||||
ripples: createEarthquakeRipples(),
|
||||
// The loaded ground (terrain or tiles) the clamped disc is draped on.
|
||||
groundHeight: (viewer, lon, lat) =>
|
||||
viewer ? heightsOf(viewer).now({ lon, lat }) : null,
|
||||
text: earthquakeCardText,
|
||||
...options,
|
||||
});
|
||||
}
|
||||
@@ -2,11 +2,12 @@ import { createRocketLaunchesLayer } from '../../layers/launches/index.js';
|
||||
import * as geometry from '../../celestialRing.js';
|
||||
import * as overlays from '../../overlays/worldOverlay.js';
|
||||
import * as render from '../../renderGovernor.js';
|
||||
import * as picking from '../../data/pickRegistry.js';
|
||||
|
||||
/** Construct one layer using the application scene owners and a supplied source. */
|
||||
export function createApplicationLaunches({ source, satellites }) {
|
||||
return createRocketLaunchesLayer({
|
||||
source,
|
||||
services: { satellites, geometry, overlays, render },
|
||||
services: { satellites, geometry, overlays, render, picking },
|
||||
});
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
import { createSubmarineCableLayer } from '../../layers/submarineCables/index.js';
|
||||
import { overlayHost } from './overlayHost.js';
|
||||
import * as picking from '../../data/pickRegistry.js';
|
||||
/** Wire cable source geometry to the application overlay host. */
|
||||
export function createApplicationCables(options) {
|
||||
return createSubmarineCableLayer({
|
||||
overlayHost,
|
||||
picking,
|
||||
mapStackEventTarget: typeof window !== 'undefined' ? window : null,
|
||||
...options,
|
||||
});
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { createApplicationOperations } from './operations.js';
|
||||
import { registerDataCredits } from '../data/dataCredits.js';
|
||||
import { mountCreditsView } from '../ui/creditsView.js';
|
||||
import { trackCreditLineHeight } from '../ui/creditLineHeight.js';
|
||||
import { MapStackController } from '../mapStackController.js';
|
||||
import { mapEngineFor } from '../maps/engine.js';
|
||||
import { initLogoGaze } from '../logoGaze.js';
|
||||
@@ -173,6 +174,8 @@ export async function createApplicationScene({
|
||||
// The credits, in the application's own line, unless the renderer shows
|
||||
// them in a display of its own.
|
||||
if (!hooks.ownCreditDisplay) defer(mountCreditsView(viewer));
|
||||
// The HUD corners above the line clear it when it wraps.
|
||||
defer(trackCreditLineHeight(document));
|
||||
loaderStatus.textContent =
|
||||
googleApiKey || googleTokens || cesiumToken
|
||||
? t('Loading Google 3D Tiles...')
|
||||
|
||||
+58
-51
@@ -50,8 +50,11 @@ import { overlayHost } from './layers/overlayHost.js';
|
||||
* runs after each layer disable (a scene without one keeps that memory).
|
||||
* `library.fetchTile` and `library.fetchData` fetch the Data Library's tiles
|
||||
* and proxied datasets in place of the defaults (`createLibrarySource`).
|
||||
* `library.fetchImpl` asks the library server (its catalog) in place of the
|
||||
* page's fetch, for a server that wants the application's own credentials.
|
||||
* `library.requireCatalog` offers only what the server's library catalog
|
||||
* names, and nothing while it does not answer.
|
||||
* names, and nothing while it does not answer. `library: false` leaves the
|
||||
* Data Library out: no catalog is asked, and no Browse button is drawn.
|
||||
*/
|
||||
export function createApplicationTools({
|
||||
scene,
|
||||
@@ -153,56 +156,60 @@ export function createApplicationTools({
|
||||
connect: connectDisplay,
|
||||
});
|
||||
defer(() => geoFileImport?.destroy());
|
||||
// DATA ▸ Library: entries register their layers only when a viewer adds
|
||||
// them, after the core catalog is sealed. The browser dialog and the
|
||||
// controller share the application lifetime.
|
||||
const dataLibrary = createDataLibrary({
|
||||
dataManager,
|
||||
services: localGeoJsonServices,
|
||||
getTileset: () => tileset,
|
||||
mapStackController,
|
||||
shareLink: styleManager.shareLinkManager,
|
||||
requestRender: governorRequestRender,
|
||||
// An application's own tile and dataset fetches, when it keeps them in
|
||||
// its own cache.
|
||||
fetchTile: library.fetchTile ?? null,
|
||||
fetchData: library.fetchData ?? null,
|
||||
requireCatalog: library.requireCatalog === true,
|
||||
// Zoom to layer: an immediate navigation, so Cockpit can refuse it and
|
||||
// the current follow owner is released first (as for imported files).
|
||||
zoomTo: (extent) =>
|
||||
styleManager.runImmediateNavigation('layer', () =>
|
||||
flyToLibraryExtent(viewer, extent),
|
||||
) !== false,
|
||||
});
|
||||
defer(() => dataLibrary.destroy());
|
||||
// Browse: the owner presents the dialog through the store; LayerPanelsView
|
||||
// draws the Browse button and the dialog from it.
|
||||
const libraryStore = useDataLibraryStore(applicationPinia());
|
||||
const libraryBrowser = createLibraryBrowser({
|
||||
library: dataLibrary,
|
||||
publish: (view) => libraryStore.publish(view),
|
||||
});
|
||||
libraryStore.connect(libraryBrowser.controls);
|
||||
defer(() => {
|
||||
libraryBrowser.destroy();
|
||||
libraryStore.connect(null);
|
||||
});
|
||||
dataLibrary.start({ signal }).catch((error) => {
|
||||
if (!signal?.aborted) console.warn('[Library] start failed:', error);
|
||||
});
|
||||
// The live gate's handle (scripts/qa-data-library.mjs).
|
||||
const libraryHandle = {
|
||||
library: dataLibrary,
|
||||
browser: libraryBrowser,
|
||||
// What Copy Link would copy.
|
||||
buildShareLink: () => styleManager.shareLinkManager?.buildLink?.() ?? null,
|
||||
};
|
||||
window.__gevDataLibrary = libraryHandle;
|
||||
defer(() => {
|
||||
if (window.__gevDataLibrary === libraryHandle)
|
||||
delete window.__gevDataLibrary;
|
||||
});
|
||||
if (library !== false) {
|
||||
// DATA ▸ Library: entries register their layers only when a viewer adds
|
||||
// them, after the core catalog is sealed. The browser dialog and the
|
||||
// controller share the application lifetime.
|
||||
const dataLibrary = createDataLibrary({
|
||||
dataManager,
|
||||
services: localGeoJsonServices,
|
||||
getTileset: () => tileset,
|
||||
mapStackController,
|
||||
shareLink: styleManager.shareLinkManager,
|
||||
requestRender: governorRequestRender,
|
||||
// An application's own tile and dataset fetches, when it keeps them in
|
||||
// its own cache.
|
||||
fetchImpl: library.fetchImpl ?? undefined,
|
||||
fetchTile: library.fetchTile ?? null,
|
||||
fetchData: library.fetchData ?? null,
|
||||
requireCatalog: library.requireCatalog === true,
|
||||
// Zoom to layer: an immediate navigation, so Cockpit can refuse it and
|
||||
// the current follow owner is released first (as for imported files).
|
||||
zoomTo: (extent) =>
|
||||
styleManager.runImmediateNavigation('layer', () =>
|
||||
flyToLibraryExtent(viewer, extent),
|
||||
) !== false,
|
||||
});
|
||||
defer(() => dataLibrary.destroy());
|
||||
// Browse: the owner presents the dialog through the store; LayerPanelsView
|
||||
// draws the Browse button and the dialog from it.
|
||||
const libraryStore = useDataLibraryStore(applicationPinia());
|
||||
const libraryBrowser = createLibraryBrowser({
|
||||
library: dataLibrary,
|
||||
publish: (view) => libraryStore.publish(view),
|
||||
});
|
||||
libraryStore.connect(libraryBrowser.controls);
|
||||
defer(() => {
|
||||
libraryBrowser.destroy();
|
||||
libraryStore.connect(null);
|
||||
});
|
||||
dataLibrary.start({ signal }).catch((error) => {
|
||||
if (!signal?.aborted) console.warn('[Library] start failed:', error);
|
||||
});
|
||||
// The live gate's handle (scripts/qa-data-library.mjs).
|
||||
const libraryHandle = {
|
||||
library: dataLibrary,
|
||||
browser: libraryBrowser,
|
||||
// What Copy Link would copy.
|
||||
buildShareLink: () =>
|
||||
styleManager.shareLinkManager?.buildLink?.() ?? null,
|
||||
};
|
||||
window.__gevDataLibrary = libraryHandle;
|
||||
defer(() => {
|
||||
if (window.__gevDataLibrary === libraryHandle)
|
||||
delete window.__gevDataLibrary;
|
||||
});
|
||||
}
|
||||
// DATA ▸ Recent Imagery: the box tool claims the pointer like Draw and the
|
||||
// panel lives on the right rail, so both belong to the application
|
||||
// lifetime. The tileset lets the layer drape while the globe is hidden.
|
||||
|
||||
@@ -403,10 +403,11 @@ test('vessel and fire layers announce valid clicks and never fly cameras', () =>
|
||||
'vessel click',
|
||||
);
|
||||
ordered(vesselClick, [
|
||||
'clickCard?.(event)',
|
||||
'selectAndFocusVessel(carded)',
|
||||
"isOwnedByOtherLayer('ais-live-vessels', pickedId)",
|
||||
'_vesselOverlayHost.hitTest?.(',
|
||||
'selectAndFocusVessel(record)',
|
||||
], 'vessel sibling ownership');
|
||||
], 'vessel card on top, then sibling ownership');
|
||||
const vesselFocus = body(
|
||||
vessels,
|
||||
/function selectAndFocusVessel\(record\) \{([\s\S]*?)\n \}/,
|
||||
@@ -419,8 +420,9 @@ test('vessel and fire layers announce valid clicks and never fly cameras', () =>
|
||||
'fire click',
|
||||
);
|
||||
ordered(fireClick, [
|
||||
'isOwnedByOtherLayer(id, pickedId)',
|
||||
'overlayHost.hitTest?.(',
|
||||
'clickCard?.(event)',
|
||||
'selectAndFocusFire(carded)',
|
||||
], 'fire sibling ownership');
|
||||
'isOwnedByOtherLayer(id, pickedId)',
|
||||
'clearFireSelection()',
|
||||
], 'fire card on top, then sibling ownership');
|
||||
});
|
||||
@@ -595,7 +595,7 @@ test('Cockpit Display portal retains both scroll owners across round trips', ()
|
||||
const portal = CockpitDisplayPortal.toString();
|
||||
assert.match(
|
||||
portal,
|
||||
/this\.standardScrollTop =\s*displayPanelScroller\(standardPanel\)\?\.scrollTop \|\| 0/,
|
||||
/this\.standardScrollTop = standardPanel\?\.scrollTop \|\| 0/,
|
||||
);
|
||||
assert.match(
|
||||
portal,
|
||||
@@ -603,7 +603,7 @@ test('Cockpit Display portal retains both scroll owners across round trips', ()
|
||||
);
|
||||
assert.match(
|
||||
portal,
|
||||
/if \(!this\.active\)[\s\S]*?this\.standardScrollTop =\s*displayPanelScroller\(standardPanel\)\.scrollTop/,
|
||||
/if \(!this\.active\)[\s\S]*?this\.standardScrollTop = standardPanel\.scrollTop/,
|
||||
);
|
||||
assert.match(
|
||||
portal,
|
||||
@@ -611,7 +611,7 @@ test('Cockpit Display portal retains both scroll owners across round trips', ()
|
||||
);
|
||||
assert.match(
|
||||
portal,
|
||||
/this\.cockpitPanel\.scrollTop = this\.cockpitScrollTop[\s\S]*?displayPanelScroller\(this\.standardPanel\)\.scrollTop =\s*this\.standardScrollTop/,
|
||||
/this\.cockpitPanel\.scrollTop = this\.cockpitScrollTop[\s\S]*?this\.standardPanel\.scrollTop = this\.standardScrollTop/,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -680,6 +680,7 @@ test('fresh Cockpit entry temporarily collapses map panels and exit restores the
|
||||
'scene-panel',
|
||||
'pp-toggles',
|
||||
'global-context-panel',
|
||||
'space-missions-panel',
|
||||
'radio-panel',
|
||||
]) {
|
||||
assert.match(
|
||||
@@ -1261,14 +1262,15 @@ test('Global Context uses its dedicated right rail without a duplicate Data Laye
|
||||
);
|
||||
assert.match(html, /id="global-context-panel"/);
|
||||
assert.match(html, /id="global-context-flights-btn"/);
|
||||
assert.match(html, /id="global-context-missions-btn"/);
|
||||
assert.doesNotMatch(html, /id="global-context-missions-btn"/);
|
||||
assert.match(html, /id="space-missions-panel"/);
|
||||
});
|
||||
|
||||
test('Global Context standby describes both chooser modes', () => {
|
||||
test('Global Context standby describes Contacts', () => {
|
||||
const match = html.match(/<div id="context-mode-standby"[\s\S]*?<\/div>/);
|
||||
assert.ok(match, 'Global Context standby is missing');
|
||||
assert.match(match[0], /CONTACTS — nearest planes · vessels · sites/);
|
||||
assert.match(match[0], /SPACE MISSIONS — launches & orbital assets/);
|
||||
assert.doesNotMatch(match[0], /SPACE MISSIONS/);
|
||||
});
|
||||
|
||||
test('cockpit briefing cycle control keeps its state as the accessible name', () => {
|
||||
|
||||
+7
-4
@@ -58,12 +58,15 @@ export function cockpitAnchorCorrectionStep(
|
||||
return Math.min(distanceM, eased, correctionRateMps * dt);
|
||||
}
|
||||
|
||||
/** How late past its interval an update may come and still count in full. */
|
||||
const COCKPIT_SUBJECT_LATE_SEC = 1;
|
||||
|
||||
/**
|
||||
* The seconds an application subject's camera update advances its heading
|
||||
* slew, ground lift and anchor by: the time since the last update, at most
|
||||
* its update interval plus 0.1 s. A subject updated every 500 ms then turns
|
||||
* and eases at its configured rates, while a long stall (a hidden tab) still
|
||||
* moves it no further than one late update would.
|
||||
* its interval plus COCKPIT_SUBJECT_LATE_SEC. A subject updated every 500 ms,
|
||||
* or a browser drawing 5 frames a second, then keeps up, while a long stall
|
||||
* (a hidden tab) counts as one late update.
|
||||
* @param {number} elapsedMs Time since the last camera update.
|
||||
* @param {number} intervalMs The subject's update interval (0: every frame).
|
||||
* @returns {number}
|
||||
@@ -75,7 +78,7 @@ export function cockpitSubjectStepSec(elapsedMs, intervalMs) {
|
||||
const intervalSec = Number.isFinite(intervalMs)
|
||||
? Math.max(0, intervalMs) / 1000
|
||||
: 0;
|
||||
return Math.min(intervalSec + 0.1, elapsedSec);
|
||||
return Math.min(intervalSec + COCKPIT_SUBJECT_LATE_SEC, elapsedSec);
|
||||
}
|
||||
|
||||
/** Return whether a throttled cockpit presentation update is due. */
|
||||
|
||||
+145
-4
@@ -31,6 +31,7 @@ import {
|
||||
speedRulerStep,
|
||||
speedRulerTicks,
|
||||
} from './cockpitMath.js';
|
||||
import { bandBesideMidpointObstacles } from './ui/panelRailGeometry.js';
|
||||
|
||||
test('cockpit presentation updates are throttled independently of camera frames', () => {
|
||||
assert.equal(cockpitUiUpdateDue(1000, 0, 100), true);
|
||||
@@ -73,12 +74,15 @@ test('an application subject steps by its interval, never by a long stall', () =
|
||||
assert.equal(cockpitSubjectStepSec(16, 0), 0.016);
|
||||
assert.equal(cockpitSubjectStepSec(500, 500), 0.5);
|
||||
assert.equal(cockpitSubjectStepSec(520, 500), 0.52);
|
||||
// A hidden tab's minutes count as one late update.
|
||||
assert.equal(cockpitSubjectStepSec(60_000, 500), 0.6);
|
||||
assert.equal(cockpitSubjectStepSec(60_000, 0), 0.1);
|
||||
// Slow frames (5 a second) count in full...
|
||||
assert.equal(cockpitSubjectStepSec(200, 50), 0.2);
|
||||
assert.equal(cockpitSubjectStepSec(1000, 0), 1);
|
||||
// ...and a hidden tab's minutes as one late update.
|
||||
assert.equal(cockpitSubjectStepSec(60_000, 500), 1.5);
|
||||
assert.equal(cockpitSubjectStepSec(60_000, 0), 1);
|
||||
assert.equal(cockpitSubjectStepSec(-5, 500), 0);
|
||||
assert.equal(cockpitSubjectStepSec(Number.NaN, 500), 0);
|
||||
assert.equal(cockpitSubjectStepSec(1000, Number.NaN), 0.1);
|
||||
assert.equal(cockpitSubjectStepSec(1000, Number.NaN), 1);
|
||||
});
|
||||
|
||||
test('cockpit camera clearance never falls below the rendered ground floor', () => {
|
||||
@@ -283,6 +287,143 @@ test('HUD rail layout constrains an oversized panel to the safe corridor', () =>
|
||||
assert.equal(layout.constrained, true);
|
||||
});
|
||||
|
||||
test('HUD rail layout keeps a short window clear of an obstacle across its midpoint', () => {
|
||||
// 480px window: midpoint 240. Each obstacle is neither wholly above nor
|
||||
// wholly below the midpoint, and must still limit the band.
|
||||
const above = resolveHudRailLayout({
|
||||
viewportHeight: 480,
|
||||
panelHeight: 120,
|
||||
laneLeft: 20,
|
||||
laneRight: 340,
|
||||
baseTop: 40,
|
||||
baseBottom: 460,
|
||||
gap: 10,
|
||||
obstacles: [{ left: 0, right: 400, top: 200, bottom: 300 }],
|
||||
});
|
||||
// Room above: 200 - 10 - 40 = 150; below: 460 - 310 = 150. A tie keeps the
|
||||
// band above the obstacle.
|
||||
assert.equal(above.safeTop, 40);
|
||||
assert.equal(above.safeBottom, 190);
|
||||
assert(above.top + Math.min(120, above.maxHeight) <= 190);
|
||||
|
||||
const below = resolveHudRailLayout({
|
||||
viewportHeight: 480,
|
||||
panelHeight: 120,
|
||||
laneLeft: 20,
|
||||
laneRight: 340,
|
||||
baseTop: 40,
|
||||
baseBottom: 460,
|
||||
gap: 10,
|
||||
obstacles: [{ left: 0, right: 400, top: 120, bottom: 260 }],
|
||||
});
|
||||
// Room above: 70; below: 190. The band goes under the obstacle.
|
||||
assert.equal(below.safeTop, 270);
|
||||
assert.equal(below.safeBottom, 460);
|
||||
assert(below.top >= 270);
|
||||
});
|
||||
|
||||
test('HUD rail layout leaves the band as it is when an obstacle across the midpoint leaves no room', () => {
|
||||
const layout = resolveHudRailLayout({
|
||||
viewportHeight: 480,
|
||||
panelHeight: 120,
|
||||
laneLeft: 20,
|
||||
laneRight: 340,
|
||||
baseTop: 100,
|
||||
baseBottom: 400,
|
||||
gap: 10,
|
||||
obstacles: [{ left: 0, right: 400, top: 80, bottom: 420 }],
|
||||
});
|
||||
assert.equal(layout.safeTop, 100);
|
||||
assert.equal(layout.safeBottom, 400);
|
||||
});
|
||||
|
||||
test('HUD rail layout reads several obstacles across the midpoint the same in any order', () => {
|
||||
const a = { left: 0, right: 400, top: 100, bottom: 260 };
|
||||
const b = { left: 0, right: 400, top: 200, bottom: 470 };
|
||||
const layoutWith = (obstacles) =>
|
||||
resolveHudRailLayout({
|
||||
viewportHeight: 480,
|
||||
panelHeight: 120,
|
||||
laneLeft: 20,
|
||||
laneRight: 340,
|
||||
baseTop: 40,
|
||||
baseBottom: 460,
|
||||
gap: 10,
|
||||
obstacles,
|
||||
});
|
||||
// Together they cover 100 to 470: the only room is above, 40 to 90.
|
||||
for (const layout of [layoutWith([a, b]), layoutWith([b, a])]) {
|
||||
assert.equal(layout.safeTop, 40);
|
||||
assert.equal(layout.safeBottom, 90);
|
||||
assert.equal(layout.maxHeight, 50);
|
||||
}
|
||||
});
|
||||
|
||||
test('HUD rail layout counts obstacles beside those across the midpoint', () => {
|
||||
const band = (obstacles) => {
|
||||
const layout = resolveHudRailLayout({
|
||||
viewportHeight: 480,
|
||||
panelHeight: 120,
|
||||
laneLeft: 20,
|
||||
laneRight: 340,
|
||||
baseTop: 40,
|
||||
baseBottom: 460,
|
||||
gap: 10,
|
||||
obstacles: obstacles.map(([top, bottom]) => ({
|
||||
left: 0,
|
||||
right: 400,
|
||||
top,
|
||||
bottom,
|
||||
})),
|
||||
});
|
||||
return [layout.safeTop, layout.safeBottom];
|
||||
};
|
||||
// One inside the span below the midpoint: 150px below the span, 50 above.
|
||||
assert.deepEqual(band([[100, 300], [250, 280]]), [310, 460]);
|
||||
// One touching the midpoint from below: 190px below, 100 above.
|
||||
assert.deepEqual(band([[150, 260], [240, 250]]), [270, 460]);
|
||||
// One inside the span above the midpoint: 150px above, 50 below.
|
||||
assert.deepEqual(band([[200, 400], [210, 230]]), [40, 190]);
|
||||
// A lower obstacle past the span limits the room below it: 100px between
|
||||
// them against 70 above, and with a taller one only 60, so above.
|
||||
assert.deepEqual(band([[120, 260], [380, 420]]), [270, 370]);
|
||||
assert.deepEqual(band([[120, 260], [340, 420]]), [40, 110]);
|
||||
// Neighbours exactly two gaps away leave no room between: one block, 100
|
||||
// to 400, and a tie (50px a side) goes above.
|
||||
assert.deepEqual(band([[100, 180], [200, 300], [320, 400]]), [40, 90]);
|
||||
// A neighbour exactly two gaps below joins it too: 150 to 300, 100px
|
||||
// above against 150 below.
|
||||
assert.deepEqual(band([[150, 250], [270, 300]]), [310, 460]);
|
||||
// A side under 8% of the window (38.4px) is no room: 30px above, none
|
||||
// below, so the band stays as it is.
|
||||
assert.deepEqual(band([[80, 455]]), [40, 460]);
|
||||
// Exactly the minimum is enough.
|
||||
const exact = bandBesideMidpointObstacles({
|
||||
midpoint: 240,
|
||||
top: 40,
|
||||
bottom: 460,
|
||||
obstacles: [{ top: 90, bottom: 465 }],
|
||||
gap: 10,
|
||||
minimum: 40,
|
||||
});
|
||||
assert.deepEqual([exact?.top, exact?.bottom], [40, 80]);
|
||||
});
|
||||
|
||||
test('HUD rail layout keeps a band beside a midpoint obstacle inside its own edges', () => {
|
||||
const layout = resolveHudRailLayout({
|
||||
viewportHeight: 480,
|
||||
panelHeight: 80,
|
||||
laneLeft: 20,
|
||||
laneRight: 340,
|
||||
baseTop: 350,
|
||||
baseBottom: 460,
|
||||
gap: 10,
|
||||
obstacles: [{ left: 0, right: 400, top: 100, bottom: 260 }],
|
||||
});
|
||||
assert.equal(layout.safeTop, 350);
|
||||
assert.equal(layout.safeBottom, 460);
|
||||
});
|
||||
|
||||
test('HUD rail layout can anchor controls to the start of the safe corridor', () => {
|
||||
const layout = resolveHudRailLayout({
|
||||
viewportHeight: 1000,
|
||||
|
||||
+19
-6
@@ -30,13 +30,26 @@ const TONE_RANK = Object.freeze([
|
||||
const stronger = (a, b) =>
|
||||
TONE_RANK.indexOf(b) > TONE_RANK.indexOf(a) ? b : a;
|
||||
|
||||
/** A label's width estimate (px): its longer line in small capitals. */
|
||||
/** Full-width glyphs in the BMP: CJK, kana, Hangul, full-width forms. */
|
||||
const WIDE_GLYPHS =
|
||||
/[\u1100-\u115F\u2E80-\u303E\u3041-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uA960-\uA97F\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE4F\uFF00-\uFF60\uFFE0-\uFFE6]/g;
|
||||
|
||||
/**
|
||||
* One line's width (px) in `.cockpit-progress-label` type (cockpitSubject.css:
|
||||
* 10 px, 0.06 em spacing): 10.6 px a full-width glyph and 6.4 px each UTF-16
|
||||
* unit of any other, so an astral glyph (an emoji, a CJK extension) counts as
|
||||
* two and an emoji in the BMP (☕) as one, narrower than it is drawn. The
|
||||
* detail line's `<small>` draws smaller, so these widths only overestimate it.
|
||||
*/
|
||||
function lineWidthPx(line) {
|
||||
const text = String(line ?? '');
|
||||
const wide = text.match(WIDE_GLYPHS)?.length ?? 0;
|
||||
return wide * 10.6 + (text.length - wide) * 6.4;
|
||||
}
|
||||
|
||||
/** A label's width estimate (px): its wider line and 8 px of padding. */
|
||||
export function estimateProgressLabelPx(label) {
|
||||
const longest = Math.max(
|
||||
String(label?.text ?? '').length,
|
||||
String(label?.detail ?? '').length,
|
||||
);
|
||||
return longest * 6.4 + 8;
|
||||
return Math.max(lineWidthPx(label?.text), lineWidthPx(label?.detail)) + 8;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,10 @@
|
||||
// the travelled part.
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { cockpitProgressLayout } from './cockpitProgress.js';
|
||||
import {
|
||||
cockpitProgressLayout,
|
||||
estimateProgressLabelPx,
|
||||
} from './cockpitProgress.js';
|
||||
|
||||
const tick = (at, label = null, tone = 'normal') => ({ at, tone, label });
|
||||
const label = (text, priority, align = 'center', detail = '') => ({
|
||||
@@ -142,3 +145,59 @@ test('a long run of calls still lays out, every one a tick or part of one', () =
|
||||
assert.ok(narrow.ticks.length < wide.ticks.length);
|
||||
assert.equal(wide.ticks.length, 60);
|
||||
});
|
||||
|
||||
test('a CJK stop name gets the width its full-width glyphs need', () => {
|
||||
const text = '中央駅前広場東口'; // 8 full-width glyphs
|
||||
// 10 px type, 0.06 em apart.
|
||||
const needPx = text.length * (10 + 0.6);
|
||||
const givenPx = estimateProgressLabelPx({ text, detail: '' });
|
||||
assert.ok(
|
||||
givenPx >= needPx,
|
||||
`${givenPx} px given, about ${needPx} px needed`,
|
||||
);
|
||||
// As many Latin letters are narrower; half-width katakana are as narrow.
|
||||
assert.ok(givenPx > estimateProgressLabelPx({ text: 'CENTRALS' }));
|
||||
assert.equal(
|
||||
estimateProgressLabelPx({ text: 'カタカナ' }),
|
||||
estimateProgressLabelPx({ text: 'KANA' }),
|
||||
);
|
||||
});
|
||||
|
||||
test('astral glyphs (emoji outside the BMP, supplementary kana) in a progress label get at least 1 em each', () => {
|
||||
// About 1 em in 10 px type, 0.06 em apart.
|
||||
const emPx = 10 + 0.6;
|
||||
for (const [text, needPx] of [
|
||||
['🚉🚆🚇🚋', 4 * emPx],
|
||||
['🚆'.repeat(8), 8 * emPx],
|
||||
// Supplementary kana, outside the full-width ranges.
|
||||
['𛀁𛀂', 2 * emPx],
|
||||
// Mixed: four emoji, a space and two full-width glyphs.
|
||||
['🚆🚇🚌🚕 乗換', 4 * emPx + 6.4 + 2 * emPx],
|
||||
]) {
|
||||
const givenPx = estimateProgressLabelPx({ text, detail: '' });
|
||||
assert.ok(
|
||||
givenPx >= needPx + 8,
|
||||
`${text}: ${givenPx} px given, about ${needPx} px needed`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('a label is as wide as its wider line, its smaller detail line included', () => {
|
||||
assert.ok(
|
||||
estimateProgressLabelPx({ text: 'GATE', detail: '中央駅前' }) >
|
||||
estimateProgressLabelPx({ text: 'GATE', detail: '' }),
|
||||
'the wider detail line widens the label',
|
||||
);
|
||||
// As headless Chrome draws the detail's <small> (8.333 px JetBrains Mono,
|
||||
// 0.6 px apart): 'WWWWMMMMWWWW' at 67.2 px, '中央駅前広場東口' at 72.9 px.
|
||||
for (const [detail, needPx] of [
|
||||
['W'.repeat(64), 64 * (67.2 / 12)],
|
||||
['駅'.repeat(45), 45 * (72.9 / 8)],
|
||||
]) {
|
||||
const givenPx = estimateProgressLabelPx({ text: 'A', detail });
|
||||
assert.ok(
|
||||
givenPx >= needPx,
|
||||
`${detail.length} × ${detail[0]}: ${givenPx} px given, ${needPx} px needed`,
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -117,20 +117,27 @@ function lookOf(raw) {
|
||||
});
|
||||
}
|
||||
|
||||
/** Promises already given a catch: a pending one is read again on every use. */
|
||||
const caughtWords = new WeakSet();
|
||||
|
||||
/**
|
||||
* A provider's worded member `key` as it reads now, normalized: the value,
|
||||
* or what the function it is returns when called on `provider` (so it can
|
||||
* follow the page's language); null when it is malformed or a read throws.
|
||||
* Reading the member, and reading what it gives, runs provider code too (a
|
||||
* getter), so both are guarded as the call is.
|
||||
* A worded member as `read()` gives it, normalized: called on `provider`
|
||||
* when it is a function (so it can follow the page's language); null when it
|
||||
* is malformed (a promise too) or provider code throws, its getter included
|
||||
* (hence `read`).
|
||||
*/
|
||||
function wordedNow(provider, key, normalize) {
|
||||
function worded(provider, read, normalize) {
|
||||
try {
|
||||
const value = provider[key];
|
||||
return (
|
||||
normalize(typeof value === 'function' ? value.call(provider) : value) ??
|
||||
null
|
||||
);
|
||||
const value = read();
|
||||
const words = typeof value === 'function' ? value.call(provider) : value;
|
||||
if (typeof words?.then === 'function') {
|
||||
if (!caughtWords.has(words)) {
|
||||
caughtWords.add(words);
|
||||
Promise.resolve(words).catch(() => {});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return normalize(words) ?? null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
@@ -146,7 +153,7 @@ function providerName(provider, order) {
|
||||
return `#${order}`;
|
||||
}
|
||||
|
||||
/** Why `provider` cannot be kept, or null. */
|
||||
/** Why `provider` cannot be kept, its worded members aside, or null. */
|
||||
function refusal(provider, kinds) {
|
||||
if (!isObject(provider)) return 'not an object';
|
||||
if (typeof provider.kind !== 'string' || !KIND_PATTERN.test(provider.kind))
|
||||
@@ -165,14 +172,25 @@ function refusal(provider, kinds) {
|
||||
typeof provider.isEntryAllowed !== 'function'
|
||||
)
|
||||
return 'isEntryAllowed is not a function';
|
||||
if (!wordedNow(provider, 'entryFace', faceOf)) return 'malformed entry face';
|
||||
if (!wordedNow(provider, 'labels', labelsOf))
|
||||
return 'labels need view, exit and exitText';
|
||||
if (provider.look != null && !wordedNow(provider, 'look', lookOf))
|
||||
return 'look needs an aheadLabel';
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* A provider's worded members, each read once, to seed its copy (so one that
|
||||
* fails when read again cannot undo this check), or why one is malformed.
|
||||
* @returns {{face: object, labels: object, look: ?object}|string}
|
||||
*/
|
||||
function checkedWords(provider) {
|
||||
const face = worded(provider, () => provider.entryFace, faceOf);
|
||||
if (!face) return 'malformed entry face';
|
||||
const labels = worded(provider, () => provider.labels, labelsOf);
|
||||
if (!labels) return 'labels need view, exit and exitText';
|
||||
const lookValue = provider.look;
|
||||
if (lookValue == null) return { face, labels, look: null };
|
||||
const look = worded(provider, () => lookValue, lookOf);
|
||||
return look ? { face, labels, look } : 'look needs an aheadLabel';
|
||||
}
|
||||
|
||||
/**
|
||||
* The application's subject providers, checked once and frozen, in the order
|
||||
* entry asks them: ascending `priority`, ties in list order. Each has
|
||||
@@ -191,7 +209,8 @@ function refusal(provider, kinds) {
|
||||
* object: it is called on the provider again whenever they are shown and
|
||||
* when the page's language changes, so its words can follow it
|
||||
* (`./i18n`). A read that throws or is malformed keeps the last
|
||||
* good one; `look` is on or off and `restPitchDeg` fixed as first read;
|
||||
* good one; `look` is on or off and `restPitchDeg` fixed as read at
|
||||
* registration;
|
||||
* - `cameraIntervalMs` (optional): 0..1000, null for the Cockpit's default; 0
|
||||
* updates the camera every rendered frame;
|
||||
* - `headingSlewDps` (optional): how fast the view turns to a new heading,
|
||||
@@ -224,7 +243,11 @@ export function cockpitSubjectProviders(
|
||||
let copy = null;
|
||||
try {
|
||||
reason = refusal(provider, kinds);
|
||||
if (!reason) copy = keptProvider(provider, order);
|
||||
if (!reason) {
|
||||
const words = checkedWords(provider);
|
||||
if (typeof words === 'string') reason = words;
|
||||
else copy = keptProvider(provider, order, words);
|
||||
}
|
||||
} catch {
|
||||
reason = 'a member threw when read';
|
||||
}
|
||||
@@ -241,14 +264,12 @@ export function cockpitSubjectProviders(
|
||||
return Object.freeze(kept);
|
||||
}
|
||||
|
||||
/** The frozen copy the Cockpit keeps of a provider `refusal` passed. */
|
||||
function keptProvider(provider, order) {
|
||||
// Worded members are read again on each use (see above); the last good
|
||||
// read stands in for one that is malformed or throws.
|
||||
let face = wordedNow(provider, 'entryFace', faceOf);
|
||||
let labels = wordedNow(provider, 'labels', labelsOf);
|
||||
// On or off, and its rest pitch, as first read.
|
||||
let look = wordedNow(provider, 'look', lookOf);
|
||||
/**
|
||||
* The frozen copy the Cockpit keeps of a provider that passed `refusal`,
|
||||
* seeded with the worded members `checkedWords` read.
|
||||
*/
|
||||
function keptProvider(provider, order, words) {
|
||||
let { face, labels, look } = words;
|
||||
const restPitchDeg = look?.restPitchDeg ?? 0;
|
||||
return Object.freeze({
|
||||
kind: provider.kind,
|
||||
@@ -256,16 +277,16 @@ function keptProvider(provider, order) {
|
||||
priority: finite(provider.priority) ? provider.priority : 0,
|
||||
order,
|
||||
get entryFace() {
|
||||
face = wordedNow(provider, 'entryFace', faceOf) ?? face;
|
||||
face = worded(provider, () => provider.entryFace, faceOf) ?? face;
|
||||
return face;
|
||||
},
|
||||
get labels() {
|
||||
labels = wordedNow(provider, 'labels', labelsOf) ?? labels;
|
||||
labels = worded(provider, () => provider.labels, labelsOf) ?? labels;
|
||||
return labels;
|
||||
},
|
||||
get look() {
|
||||
if (!look) return null;
|
||||
const now = wordedNow(provider, 'look', lookOf);
|
||||
const now = worded(provider, () => provider.look, lookOf);
|
||||
if (now)
|
||||
look = Object.freeze({ restPitchDeg, aheadLabel: now.aheadLabel });
|
||||
return look;
|
||||
@@ -335,11 +356,11 @@ function candidateOf(raw) {
|
||||
* a position that is not finite, an eye with no valid `upM` (0..1000), or a
|
||||
* read of it that throws (a getter runs provider code).
|
||||
* A `heightM` that is not finite or lies outside
|
||||
* COCKPIT_SUBJECT_MIN_HEIGHT_M..COCKPIT_SUBJECT_MAX_HEIGHT_M reads as null:
|
||||
* the eye then stands on the shared floor, or where it last stood while that
|
||||
* is cold. The anchor is `'inertial'` only when asked for and the frame
|
||||
* gives a speed; otherwise it is `'exact'`. An id is compared with `heldId`
|
||||
* trimmed, as `cockpitSubjectCandidate` trims it.
|
||||
* COCKPIT_SUBJECT_MIN_HEIGHT_M..COCKPIT_SUBJECT_MAX_HEIGHT_M reads as null,
|
||||
* for the eye to stand on the shared floor (ui/cockpitCamera.js). The anchor
|
||||
* is `'inertial'` by default for a frame with a valid speed, and `'exact'`
|
||||
* when asked for or with no speed. An id is compared with `heldId` trimmed,
|
||||
* as `cockpitSubjectCandidate` trims it.
|
||||
* @param {unknown} raw What `read()` returned.
|
||||
* @param {string} heldId The subject the view holds.
|
||||
* @returns {object|null} `{id, name, latitude, longitude, heightM, headingDeg,
|
||||
@@ -356,49 +377,57 @@ export function cockpitSubjectFrame(raw, heldId) {
|
||||
}
|
||||
|
||||
function frameOf(raw, heldId) {
|
||||
if (!isObject(raw) || typeof raw.id !== 'string' || raw.id.trim() !== heldId)
|
||||
return null;
|
||||
const latitude = raw.latitude;
|
||||
const longitude = raw.longitude;
|
||||
if (!isObject(raw)) return null;
|
||||
// Each field read once: a getter on the frame runs provider code.
|
||||
const {
|
||||
id,
|
||||
name,
|
||||
latitude,
|
||||
longitude,
|
||||
heightM,
|
||||
headingDeg: rawHeadingDeg,
|
||||
courseDeg,
|
||||
speedMps: rawSpeedMps,
|
||||
stale,
|
||||
groundClamp,
|
||||
anchor,
|
||||
eye: rawEye,
|
||||
} = raw;
|
||||
if (typeof id !== 'string' || id.trim() !== heldId) return null;
|
||||
if (!finite(latitude) || !finite(longitude) || Math.abs(latitude) > 90)
|
||||
return null;
|
||||
const eye = isObject(raw.eye) ? raw.eye : null;
|
||||
if (!eye || !finite(eye.upM) || eye.upM < 0 || eye.upM > 1000) return null;
|
||||
if (!isObject(rawEye)) return null;
|
||||
const { upM, forwardM, pitchDeg, minClearanceM } = rawEye;
|
||||
if (!finite(upM) || upM < 0 || upM > 1000) return null;
|
||||
const heading = (value) =>
|
||||
finite(value) ? ((value % 360) + 360) % 360 : null;
|
||||
const headingDeg = heading(raw.headingDeg);
|
||||
const speedMps =
|
||||
finite(raw.speedMps) && raw.speedMps >= 0 ? raw.speedMps : null;
|
||||
const headingDeg = heading(rawHeadingDeg);
|
||||
const speedMps = finite(rawSpeedMps) && rawSpeedMps >= 0 ? rawSpeedMps : null;
|
||||
return {
|
||||
id: heldId,
|
||||
name: cockpitSubjectText(raw.name, 64) || cockpitSubjectText(heldId, 64),
|
||||
name: cockpitSubjectText(name, 64) || cockpitSubjectText(heldId, 64),
|
||||
latitude,
|
||||
longitude: ((((longitude + 180) % 360) + 360) % 360) - 180,
|
||||
heightM:
|
||||
finite(raw.heightM) &&
|
||||
raw.heightM >= COCKPIT_SUBJECT_MIN_HEIGHT_M &&
|
||||
raw.heightM <= COCKPIT_SUBJECT_MAX_HEIGHT_M
|
||||
? raw.heightM
|
||||
finite(heightM) &&
|
||||
heightM >= COCKPIT_SUBJECT_MIN_HEIGHT_M &&
|
||||
heightM <= COCKPIT_SUBJECT_MAX_HEIGHT_M
|
||||
? heightM
|
||||
: null,
|
||||
headingDeg,
|
||||
courseDeg: heading(raw.courseDeg) ?? headingDeg,
|
||||
courseDeg: heading(courseDeg) ?? headingDeg,
|
||||
speedMps,
|
||||
stale: raw.stale === true,
|
||||
groundClamp: raw.groundClamp !== false,
|
||||
stale: stale === true,
|
||||
groundClamp: groundClamp !== false,
|
||||
// An inertial anchor runs on at the frame's speed; with none it would
|
||||
// close on a moving subject at the correction's floor and fall behind.
|
||||
anchor: raw.anchor === 'exact' || speedMps === null ? 'exact' : 'inertial',
|
||||
anchor: anchor === 'exact' || speedMps === null ? 'exact' : 'inertial',
|
||||
eye: {
|
||||
upM: eye.upM,
|
||||
forwardM:
|
||||
finite(eye.forwardM) && Math.abs(eye.forwardM) <= 500
|
||||
? eye.forwardM
|
||||
: 0,
|
||||
pitchDeg: finite(eye.pitchDeg) ? clamp(eye.pitchDeg, -90, 90) : 0,
|
||||
upM,
|
||||
forwardM: finite(forwardM) && Math.abs(forwardM) <= 500 ? forwardM : 0,
|
||||
pitchDeg: finite(pitchDeg) ? clamp(pitchDeg, -90, 90) : 0,
|
||||
minClearanceM:
|
||||
finite(eye.minClearanceM) && eye.minClearanceM >= 0
|
||||
? eye.minClearanceM
|
||||
: 0,
|
||||
finite(minClearanceM) && minClearanceM >= 0 ? minClearanceM : 0,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -642,11 +642,15 @@ test('a provider whose getter throws is left out with one warning; the next is k
|
||||
]);
|
||||
});
|
||||
|
||||
test('a worded getter that starts throwing keeps the last good words', () => {
|
||||
let failing = false;
|
||||
const words = (value) => () => {
|
||||
if (failing) throw new Error('translations unavailable');
|
||||
return value;
|
||||
test('a worded getter that throws from its second read keeps the last good words', () => {
|
||||
// Registration reads each once: the second read is the first use.
|
||||
const once = (value) => {
|
||||
let read = false;
|
||||
return () => {
|
||||
if (read) throw new Error('translations unavailable');
|
||||
read = true;
|
||||
return value;
|
||||
};
|
||||
};
|
||||
const definition = provider();
|
||||
for (const [key, value] of Object.entries({
|
||||
@@ -654,22 +658,52 @@ test('a worded getter that starts throwing keeps the last good words', () => {
|
||||
entryFace: { icon: 'commute', label: 'RIDE' },
|
||||
look: { restPitchDeg: 10, aheadLabel: 'Look ahead' },
|
||||
}))
|
||||
Object.defineProperty(definition, key, { get: words(value) });
|
||||
Object.defineProperty(definition, key, { get: once(value) });
|
||||
const { kept, warnings } = keep([definition]);
|
||||
assert.deepEqual(warnings, []);
|
||||
const [ride] = kept;
|
||||
failing = true;
|
||||
assert.equal(ride.labels.view, 'Ride view');
|
||||
assert.equal(ride.entryFace.label, 'RIDE');
|
||||
assert.deepEqual(ride.look, { restPitchDeg: 10, aheadLabel: 'Look ahead' });
|
||||
// So does a worded object whose own member throws when read.
|
||||
failing = false;
|
||||
Object.defineProperty(definition, 'labels', {
|
||||
get: () => throwingGetter({ view: 'v', exit: 'e', exitText: 'x' }, 'view'),
|
||||
});
|
||||
assert.equal(ride.labels.view, 'Ride view');
|
||||
});
|
||||
|
||||
test('a worded member that returns a rejected promise keeps the last good words, the rejection caught', async () => {
|
||||
const definition = provider();
|
||||
const words = definition.labels;
|
||||
let reads = 0;
|
||||
definition.labels = () => {
|
||||
reads += 1;
|
||||
return reads === 1 ? words : Promise.reject(new Error('late words'));
|
||||
};
|
||||
const { kept, warnings } = keep([definition]);
|
||||
assert.deepEqual(warnings, []);
|
||||
assert.equal(kept[0].labels.view, words.view);
|
||||
// An unhandled rejection would fail this test once it surfaces.
|
||||
await new Promise((resolve) => setTimeout(resolve, 10));
|
||||
});
|
||||
|
||||
test('a frame field read through a getter is read once', () => {
|
||||
const frame = { id: 'a1', latitude: 1, longitude: 2, eye: { upM: 3 } };
|
||||
const once = (value) => {
|
||||
let read = false;
|
||||
return () => {
|
||||
const answer = read ? undefined : value;
|
||||
read = true;
|
||||
return answer;
|
||||
};
|
||||
};
|
||||
Object.defineProperty(frame, 'heightM', { get: once(420) });
|
||||
Object.defineProperty(frame, 'speedMps', { get: once(12) });
|
||||
const normalized = cockpitSubjectFrame(frame, 'a1');
|
||||
assert.equal(normalized.heightM, 420);
|
||||
assert.equal(normalized.speedMps, 12);
|
||||
});
|
||||
|
||||
test('a candidate, frame or HUD view whose getter throws reads as null', () => {
|
||||
assert.equal(
|
||||
cockpitSubjectCandidate(throwingGetter({ name: 'Example' }, 'id')),
|
||||
|
||||
@@ -17,11 +17,6 @@
|
||||
* @param {number} [input.signalGap] Clearance above the briefing card.
|
||||
* @param {number} [input.minTopFloor] Absolute ceiling for the strip, in px.
|
||||
* @param {number} [input.minTopRatio] Viewport-relative ceiling, 0..1.
|
||||
* @param {boolean} [input.signalCollapsed] Whether the briefing card is collapsed.
|
||||
* @param {boolean} [input.utilityExpanded] Whether Display or Radio is expanded.
|
||||
* @param {number} [input.bottomInset] Reserved viewport space below an expanded panel.
|
||||
* @param {number} [input.signalHeight] Collapsed briefing header reserved below the utility.
|
||||
* @param {boolean} [input.reserveViewportLane] Theme relocates the briefing below the expanded utility.
|
||||
* @returns {{ top: number, maxHeight: number }}
|
||||
*/
|
||||
export function resolveCockpitUtilityAnchor({
|
||||
@@ -34,29 +29,13 @@ export function resolveCockpitUtilityAnchor({
|
||||
signalGap = 8,
|
||||
minTopFloor = 96,
|
||||
minTopRatio = 0.12,
|
||||
signalCollapsed = false,
|
||||
utilityExpanded = false,
|
||||
bottomInset = 80,
|
||||
signalHeight = 0,
|
||||
reserveViewportLane = false,
|
||||
}) {
|
||||
const viewport = Math.max(0, Number(viewportHeight) || 0);
|
||||
const minTop = Math.max(minTopFloor, viewport * minTopRatio);
|
||||
const anchoredTop = Math.max(minTop, (Number(recBottom) || 0) + recGap);
|
||||
const strip = Math.max(0, Number(stripHeight) || 0);
|
||||
const signal = Number(signalTop);
|
||||
const expandedLaneBottom = Math.max(
|
||||
0,
|
||||
viewport -
|
||||
Math.max(0, Number(bottomInset) || 0) -
|
||||
Math.max(0, Number(signalHeight) || 0),
|
||||
);
|
||||
const lowerBound =
|
||||
reserveViewportLane && signalCollapsed && utilityExpanded
|
||||
? expandedLaneBottom
|
||||
: Number.isFinite(signal)
|
||||
? signal
|
||||
: viewport;
|
||||
const lowerBound = Number.isFinite(signal) ? signal : viewport;
|
||||
const clearedTop = lowerBound - signalGap - strip;
|
||||
const top = Math.max(minTop, Math.min(anchoredTop, clearedTop));
|
||||
const floor = Math.max(0, Number(collapsedHeight) || 0) || 50;
|
||||
@@ -100,25 +79,3 @@ export function resolveCockpitUtilityLayout({
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
/** Shared Cyber panel slot, with footer controls above the lower frame (83vh). */
|
||||
export function resolveCyberCockpitPanelLane({
|
||||
viewportHeight,
|
||||
top,
|
||||
launcherHeight = 60,
|
||||
signalHeight = 44,
|
||||
contactHeight = 64,
|
||||
}) {
|
||||
const gap = 8;
|
||||
const footerHeight = Math.max(
|
||||
contactHeight + gap,
|
||||
launcherHeight + signalHeight + gap * 2,
|
||||
);
|
||||
const bottom = viewportHeight * 0.82;
|
||||
const panelHeight = Math.max(120, bottom - top - footerHeight);
|
||||
return {
|
||||
panelHeight,
|
||||
utilityHeight: panelHeight + gap + launcherHeight,
|
||||
signalTop: top + panelHeight + launcherHeight + gap * 2,
|
||||
};
|
||||
}
|
||||
@@ -4,58 +4,11 @@ import assert from 'node:assert/strict';
|
||||
import {
|
||||
resolveCockpitUtilityAnchor,
|
||||
resolveCockpitUtilityLayout,
|
||||
resolveCyberCockpitPanelLane,
|
||||
} from './cockpitUtilityLayout.js';
|
||||
|
||||
// 1512x790, the height the strip used to collide with the briefing card at.
|
||||
const desktop = { viewportHeight: 790, stripHeight: 107, collapsedHeight: 50 };
|
||||
|
||||
test('Cyber shared panel slot reserves both footer lanes above the decorative frame', () => {
|
||||
for (const viewportHeight of [600, 673, 713, 986, 1376]) {
|
||||
for (const signalHeight of [44, 76]) {
|
||||
for (const contactHeight of [44, 84, 120]) {
|
||||
const top = Math.max(164, Math.min(204, viewportHeight * 0.19));
|
||||
const lane = resolveCyberCockpitPanelLane({ viewportHeight, top, signalHeight, contactHeight });
|
||||
assert.ok(lane.panelHeight >= 120);
|
||||
assert.ok(top + lane.panelHeight + 8 + contactHeight <= viewportHeight * 0.82 + .01);
|
||||
assert.ok(lane.signalTop + signalHeight <= viewportHeight * 0.82 + .01);
|
||||
assert.equal(lane.signalTop, top + lane.utilityHeight + 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('Cyber keeps the Data Layers top while reserving briefing clearance', () => {
|
||||
for (const viewportHeight of [673, 713, 986, 1376]) {
|
||||
const leftTop = Math.max(164, Math.min(204, viewportHeight * 0.19));
|
||||
const collapsed = resolveCockpitUtilityAnchor({
|
||||
viewportHeight, stripHeight: 128, collapsedHeight: 60, recBottom: 0,
|
||||
signalTop: leftTop + 128 + 28, minTopFloor: leftTop, minTopRatio: 0,
|
||||
});
|
||||
assert.equal(collapsed.top, leftTop);
|
||||
assert.ok(collapsed.maxHeight >= 128);
|
||||
const expanded = resolveCockpitUtilityAnchor({
|
||||
viewportHeight, stripHeight: 700, collapsedHeight: 60, recBottom: 0,
|
||||
signalTop: 255, minTopFloor: leftTop, minTopRatio: 0,
|
||||
signalCollapsed: true, utilityExpanded: true, reserveViewportLane: true, signalHeight: 44,
|
||||
});
|
||||
assert.equal(expanded.top, leftTop);
|
||||
assert.equal(expanded.top + expanded.maxHeight + 8 + 44 + 80, viewportHeight);
|
||||
}
|
||||
});
|
||||
|
||||
test('expanded utilities reserve the visible collapsed briefing header at every desktop height', () => {
|
||||
for (const viewportHeight of [640, 720, 987, 1376]) {
|
||||
for (const signalHeight of [48, 76, 100]) {
|
||||
const { top, maxHeight } = resolveCockpitUtilityAnchor({
|
||||
...desktop, viewportHeight, recBottom: 0, signalTop: 255,
|
||||
signalCollapsed: true, utilityExpanded: true, signalHeight, reserveViewportLane: true,
|
||||
});
|
||||
assert.equal(top + maxHeight + 8, viewportHeight - 80 - signalHeight);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('the strip hangs 12px under the REC readout when the briefing card leaves room', () => {
|
||||
const { top } = resolveCockpitUtilityAnchor({ ...desktop, recBottom: 148.1, signalTop: 420 });
|
||||
assert.equal(Number(top.toFixed(1)), 160.1);
|
||||
@@ -101,34 +54,11 @@ test('a missing REC readout leaves the strip on the viewport ceiling', () => {
|
||||
assert.equal(top, 96);
|
||||
});
|
||||
|
||||
test('an expanded utility claims the vertical lane released by a collapsed briefing', () => {
|
||||
const { top, maxHeight } = resolveCockpitUtilityAnchor({
|
||||
...desktop,
|
||||
recBottom: 148.1,
|
||||
signalTop: 265.4,
|
||||
signalCollapsed: true,
|
||||
utilityExpanded: true,
|
||||
reserveViewportLane: true,
|
||||
});
|
||||
assert.equal(Number(top.toFixed(1)), 160.1);
|
||||
assert.equal(Number(maxHeight.toFixed(1)), 541.9);
|
||||
});
|
||||
|
||||
test('non-relocating themes preserve the visible briefing boundary even when collapsed', () => {
|
||||
test('the visible briefing card bounds the utility strip, collapsed or not', () => {
|
||||
const { top, maxHeight } = resolveCockpitUtilityAnchor({
|
||||
...desktop, recBottom: 148.1, signalTop: 265.4,
|
||||
signalCollapsed: true, utilityExpanded: true,
|
||||
});
|
||||
assert.equal(Number((top + maxHeight).toFixed(1)), 257.4);
|
||||
});
|
||||
|
||||
test('a collapsed briefing still bounds the utility strip until a panel expands', () => {
|
||||
const { maxHeight } = resolveCockpitUtilityAnchor({
|
||||
...desktop,
|
||||
recBottom: 148.1,
|
||||
signalTop: 265.4,
|
||||
signalCollapsed: true,
|
||||
});
|
||||
assert.equal(Number(maxHeight.toFixed(1)), 107);
|
||||
});
|
||||
|
||||
|
||||
+19
-106
@@ -1,5 +1,3 @@
|
||||
import { msg } from './i18n/marker.js';
|
||||
|
||||
const CONTEXT_DEPENDENCIES = Object.freeze({
|
||||
flights: new Set([
|
||||
'military-awareness',
|
||||
@@ -8,15 +6,18 @@ const CONTEXT_DEPENDENCIES = Object.freeze({
|
||||
'ais-live-vessels',
|
||||
'military-installations',
|
||||
]),
|
||||
'space-missions': new Set(['rocket-launches', 'satellites']),
|
||||
});
|
||||
const CONTEXT_COMPANIONS = new Set(['radio']);
|
||||
/** The Space Missions refusal, with the blocked layer's name as {layer}. */
|
||||
export const SPACE_MISSIONS_LAYER_BLOCK_REASON = msg(
|
||||
'Space Missions isolates replay data. Exit the mode to enable {layer}.',
|
||||
);
|
||||
const [BLOCK_REASON_PREFIX, BLOCK_REASON_SUFFIX] =
|
||||
SPACE_MISSIONS_LAYER_BLOCK_REASON.split('{layer}');
|
||||
/**
|
||||
* Layers Context never touches: Space Missions and the Satellites layer it
|
||||
* depends on. Contacts neither switches them off on entry nor restores them
|
||||
* on exit, so they run beside it in either order and keep their own state
|
||||
* (the mission controller owns the Satellites dependency).
|
||||
*/
|
||||
export const CONTEXT_INDEPENDENT_LAYER_IDS = Object.freeze([
|
||||
'rocket-launches',
|
||||
'satellites',
|
||||
]);
|
||||
/** Return whether an origin represents a direct user choice on this route. */
|
||||
export function isExplicitUserIntentOrigin(origin, layerId = null) {
|
||||
return origin === 'user' || origin === 'voice';
|
||||
@@ -27,7 +28,8 @@ export function recordContextRestoreExplicitChange({ restoreState, change }) {
|
||||
if (
|
||||
!restoreState?.enabledLayerIds ||
|
||||
change?.type !== 'visibility' ||
|
||||
!isExplicitUserIntentOrigin(change.origin, change.layerId)
|
||||
!isExplicitUserIntentOrigin(change.origin, change.layerId) ||
|
||||
CONTEXT_INDEPENDENT_LAYER_IDS.includes(change.layerId)
|
||||
)
|
||||
return false;
|
||||
if (!restoreState.explicitLayerStates)
|
||||
@@ -121,10 +123,7 @@ export async function settleUserFacingContextAction({
|
||||
* one into `userAdded` makes exit restoration re-enable the mode layer the
|
||||
* user just turned off.
|
||||
*/
|
||||
export const CONTEXT_ENTRY_LAYER_IDS = Object.freeze([
|
||||
'military-awareness',
|
||||
'rocket-launches',
|
||||
]);
|
||||
export const CONTEXT_ENTRY_LAYER_IDS = Object.freeze(['military-awareness']);
|
||||
|
||||
/**
|
||||
* Leave a Context transaction: publish the settled coordination flag, then
|
||||
@@ -193,7 +192,8 @@ export function shouldExitContextForLayerChange({
|
||||
change?.type !== 'visibility' ||
|
||||
!isExplicitUserIntentOrigin(change.origin, change.layerId) ||
|
||||
change.layerId === 'military-awareness' ||
|
||||
CONTEXT_COMPANIONS.has(change.layerId)
|
||||
CONTEXT_COMPANIONS.has(change.layerId) ||
|
||||
CONTEXT_INDEPENDENT_LAYER_IDS.includes(change.layerId)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
@@ -215,6 +215,7 @@ export function contextAllowedLayerIds(contextMode) {
|
||||
return new Set([
|
||||
...(CONTEXT_DEPENDENCIES[contextMode] || ['military-awareness']),
|
||||
...CONTEXT_COMPANIONS,
|
||||
...CONTEXT_INDEPENDENT_LAYER_IDS,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -235,21 +236,6 @@ export function shouldCaptureContextSession(change) {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether one explicit mission intent superseded an in-flight Clear All
|
||||
* reservation and therefore needs deferred Context adoption.
|
||||
*/
|
||||
export function shouldDeferContextEntryDuringClear({ change, clearInFlight }) {
|
||||
return Boolean(
|
||||
clearInFlight &&
|
||||
change?.type === 'visibility-requested' &&
|
||||
change.layerId === 'rocket-launches' &&
|
||||
change.enabled === true &&
|
||||
isExplicitUserIntentOrigin(change.origin, change.layerId) &&
|
||||
Number.isInteger(change.intentEpoch),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bookkeep a user-owned layer change against the active Context session so
|
||||
* exit restoration can honor layers the user added mid-session. Two rules
|
||||
@@ -273,7 +259,8 @@ export function recordContextSessionUserChange({
|
||||
if (
|
||||
!snapshot?.userAdded ||
|
||||
change?.type !== 'visibility' ||
|
||||
!isExplicitUserIntentOrigin(change.origin, change.layerId)
|
||||
!isExplicitUserIntentOrigin(change.origin, change.layerId) ||
|
||||
CONTEXT_INDEPENDENT_LAYER_IDS.includes(change.layerId)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
@@ -319,83 +306,10 @@ export function contextSnapshotLayerIds(
|
||||
) {
|
||||
const snapshot = new Set(restoringLayerIds || currentEnabledLayerIds || []);
|
||||
for (const layerId of excludeLayerIds || []) snapshot.delete(layerId);
|
||||
for (const layerId of CONTEXT_INDEPENDENT_LAYER_IDS) snapshot.delete(layerId);
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Block layers that would mix unrelated live/current data into Space Missions.
|
||||
* The manager calls this before lifecycle work so a refused layer never starts.
|
||||
* @param {object} input Current mode and requested visibility transition.
|
||||
* @param {string|null} input.contextMode Active Context mode.
|
||||
* @param {object|null} input.change Requested visibility transition.
|
||||
* @param {string|null} [input.layerName] User-facing layer name.
|
||||
* @returns {string|null} Honest user-facing refusal reason, or null when allowed.
|
||||
*/
|
||||
export function contextLayerEnableBlockReason({
|
||||
contextMode,
|
||||
change,
|
||||
layerName = null,
|
||||
}) {
|
||||
if (
|
||||
contextMode !== 'space-missions' ||
|
||||
change?.enabled !== true ||
|
||||
contextAllowedLayerIds('space-missions').has(change.layerId)
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
const label = String(layerName || change.layerId || 'that layer');
|
||||
return SPACE_MISSIONS_LAYER_BLOCK_REASON.replace('{layer}', label);
|
||||
}
|
||||
|
||||
/**
|
||||
* The layer name from a Space Missions refusal, so the UI can rebuild the
|
||||
* sentence in its language.
|
||||
* @param {string} reason
|
||||
* @returns {{layer: string}|null} The blocked layer's name, or null when the
|
||||
* reason is not a Space Missions refusal.
|
||||
*/
|
||||
export function parseContextLayerBlockReason(reason) {
|
||||
if (
|
||||
typeof reason !== 'string' ||
|
||||
!reason.startsWith(BLOCK_REASON_PREFIX) ||
|
||||
!reason.endsWith(BLOCK_REASON_SUFFIX) ||
|
||||
reason.length <= BLOCK_REASON_PREFIX.length + BLOCK_REASON_SUFFIX.length
|
||||
)
|
||||
return null;
|
||||
return {
|
||||
layer: reason.slice(
|
||||
BLOCK_REASON_PREFIX.length,
|
||||
reason.length - BLOCK_REASON_SUFFIX.length,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve who owns a cancelled direct Space Missions entry. A newer ON keeps
|
||||
* the entry shell reserved for its replacement transaction; every other
|
||||
* cancellation must roll back the isolated pre-entry session.
|
||||
*
|
||||
* @param {object} input Cancellation and current manager intent state.
|
||||
* @param {object|null} input.change Manager visibility notification.
|
||||
* @returns {'ignore'|'replacement'|'restore'} Cancellation disposition.
|
||||
*/
|
||||
export function spaceMissionEntryCancellationDisposition({ change }) {
|
||||
if (
|
||||
change?.type !== 'visibility-cancelled' ||
|
||||
change.layerId !== 'rocket-launches' ||
|
||||
change.enabled !== true
|
||||
)
|
||||
return 'ignore';
|
||||
if (
|
||||
change.cancellationReason === 'superseded' &&
|
||||
Number.isInteger(change.successorIntentEpoch) &&
|
||||
change.successorIntentEpoch > change.intentEpoch &&
|
||||
change.successorEnabled === true
|
||||
)
|
||||
return 'replacement';
|
||||
return 'restore';
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge the pre-entry layer snapshot with layers the user enabled during the
|
||||
* Context session so both survive restoration.
|
||||
@@ -510,7 +424,6 @@ export function subjectEntryAllowed({
|
||||
*/
|
||||
export const CONTEXT_MODE_VOICE_NAMES = Object.freeze({
|
||||
flights: 'contacts',
|
||||
'space-missions': 'space-missions',
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
+63
-111
@@ -5,7 +5,6 @@ import {
|
||||
orbitEntryAllowed,
|
||||
cockpitEntryAllowed,
|
||||
contextAllowedLayerIds,
|
||||
contextLayerEnableBlockReason,
|
||||
contextRestoreLayerIds,
|
||||
isExplicitUserIntentOrigin,
|
||||
mergeContextTransitionErrors,
|
||||
@@ -17,9 +16,7 @@ import {
|
||||
settleContextIntentReplay,
|
||||
settleUserFacingContextAction,
|
||||
shouldCaptureContextSession,
|
||||
shouldDeferContextEntryDuringClear,
|
||||
shouldExitContextForLayerChange,
|
||||
spaceMissionEntryCancellationDisposition,
|
||||
} from './contextModePolicy.js';
|
||||
|
||||
test('Context transition errors preserve primary identity and aggregate failed layers', () => {
|
||||
@@ -119,11 +116,6 @@ test('user-enabled layers are additive and do not exit Context', () => {
|
||||
globalContextEnabled: true,
|
||||
change: userEnable('earthquakes'),
|
||||
}), false);
|
||||
assert.equal(shouldExitContextForLayerChange({
|
||||
contextMode: 'space-missions',
|
||||
globalContextEnabled: false,
|
||||
change: userEnable('traffic'),
|
||||
}), false);
|
||||
assert.equal(shouldExitContextForLayerChange({
|
||||
contextMode: null,
|
||||
globalContextEnabled: true,
|
||||
@@ -133,48 +125,16 @@ test('user-enabled layers are additive and do not exit Context', () => {
|
||||
|
||||
test('programmatic Context dependencies and direct mode setup remain allowed', () => {
|
||||
assert.equal(shouldExitContextForLayerChange({
|
||||
contextMode: 'space-missions',
|
||||
contextMode: 'flights',
|
||||
globalContextEnabled: true,
|
||||
change: { ...userEnable('satellites'), origin: 'programmatic' },
|
||||
change: { ...userEnable('military'), enabled: false, origin: 'programmatic' },
|
||||
}), false);
|
||||
});
|
||||
|
||||
test('Space Missions cancellation retains only a newer authoritative ON entry', () => {
|
||||
const cancelledEntry = {
|
||||
type: 'visibility-cancelled',
|
||||
layerId: 'rocket-launches',
|
||||
enabled: true,
|
||||
intentEpoch: 8,
|
||||
cancellationReason: 'superseded',
|
||||
successorIntentEpoch: 9,
|
||||
successorEnabled: true,
|
||||
successorOrigin: 'programmatic',
|
||||
};
|
||||
assert.equal(spaceMissionEntryCancellationDisposition({
|
||||
change: cancelledEntry,
|
||||
}), 'replacement');
|
||||
assert.equal(spaceMissionEntryCancellationDisposition({
|
||||
change: { ...cancelledEntry, successorEnabled: false },
|
||||
}), 'restore', 'a newer OFF releases the entry shell');
|
||||
assert.equal(spaceMissionEntryCancellationDisposition({
|
||||
change: {
|
||||
...cancelledEntry,
|
||||
cancellationReason: 'caller-abort',
|
||||
successorIntentEpoch: undefined,
|
||||
successorEnabled: undefined,
|
||||
},
|
||||
}), 'restore', 'caller abort at the same epoch restores the isolated session');
|
||||
assert.equal(spaceMissionEntryCancellationDisposition({
|
||||
change: { ...cancelledEntry, enabled: false },
|
||||
currentIntentEpoch: 9,
|
||||
effectivelyEnabled: true,
|
||||
}), 'ignore');
|
||||
});
|
||||
|
||||
test('only explicit user-owned shell enables capture a Context restoration snapshot', () => {
|
||||
const userMissionEnable = {
|
||||
type: 'visibility-requested',
|
||||
layerId: 'rocket-launches',
|
||||
layerId: 'military-awareness',
|
||||
enabled: true,
|
||||
origin: 'user',
|
||||
};
|
||||
@@ -186,40 +146,25 @@ test('only explicit user-owned shell enables capture a Context restoration snaps
|
||||
assert.equal(shouldCaptureContextSession({ ...userMissionEnable, origin: 'context-restore' }), false);
|
||||
assert.equal(shouldCaptureContextSession({ ...userMissionEnable, enabled: false }), false);
|
||||
assert.equal(shouldCaptureContextSession({ ...userMissionEnable, layerId: 'satellites' }), false);
|
||||
assert.equal(
|
||||
shouldCaptureContextSession({ ...userMissionEnable, layerId: 'rocket-launches' }),
|
||||
false,
|
||||
'Space Missions is an ordinary layer, not a Context entry',
|
||||
);
|
||||
});
|
||||
|
||||
test('voice dependency OFF exits Space Missions like the equivalent UI action', () => {
|
||||
test('voice dependency OFF exits Contacts like the equivalent UI action', () => {
|
||||
assert.equal(shouldExitContextForLayerChange({
|
||||
contextMode: 'space-missions',
|
||||
contextMode: 'flights',
|
||||
globalContextEnabled: false,
|
||||
change: { type: 'visibility', layerId: 'satellites', enabled: false, origin: 'voice' },
|
||||
change: { type: 'visibility', layerId: 'flights', enabled: false, origin: 'voice' },
|
||||
}), true);
|
||||
});
|
||||
|
||||
test('only a newer explicit mission request is deferred during Clear All', () => {
|
||||
const change = {
|
||||
type: 'visibility-requested',
|
||||
layerId: 'rocket-launches',
|
||||
enabled: true,
|
||||
origin: 'voice',
|
||||
intentEpoch: 12,
|
||||
};
|
||||
assert.equal(shouldDeferContextEntryDuringClear({ change, clearInFlight: true }), true);
|
||||
assert.equal(shouldDeferContextEntryDuringClear({ change, clearInFlight: false }), false);
|
||||
assert.equal(shouldDeferContextEntryDuringClear({
|
||||
change: { ...change, origin: 'programmatic' },
|
||||
clearInFlight: true,
|
||||
}), false);
|
||||
assert.equal(shouldDeferContextEntryDuringClear({
|
||||
change: { ...change, enabled: false },
|
||||
clearInFlight: true,
|
||||
}), false);
|
||||
});
|
||||
|
||||
test('a rapid re-entry snapshots the settled restore target, not partial manager state', () => {
|
||||
assert.deepEqual(
|
||||
[...contextSnapshotLayerIds(
|
||||
new Set(['rocket-launches', 'earthquakes']),
|
||||
new Set(['cctv', 'earthquakes']),
|
||||
new Set(['flights', 'traffic']),
|
||||
)],
|
||||
['flights', 'traffic'],
|
||||
@@ -230,31 +175,15 @@ test('a rapid re-entry snapshots the settled restore target, not partial manager
|
||||
);
|
||||
assert.deepEqual(
|
||||
[...contextSnapshotLayerIds(
|
||||
new Set(['rocket-launches', 'satellites']),
|
||||
new Set(['military-awareness', 'cctv']),
|
||||
null,
|
||||
['rocket-launches'],
|
||||
['military-awareness'],
|
||||
)],
|
||||
['satellites'],
|
||||
['cctv'],
|
||||
'the synchronous entry intent is not part of the pre-entry snapshot',
|
||||
);
|
||||
});
|
||||
|
||||
test('Space Missions blocks unrelated layer enables before replay data can mix', () => {
|
||||
const change = { layerId: 'flights', enabled: true, origin: 'user' };
|
||||
assert.match(
|
||||
contextLayerEnableBlockReason({ contextMode: 'space-missions', change, layerName: 'Live Flights' }),
|
||||
/Exit the mode to enable Live Flights/,
|
||||
);
|
||||
assert.equal(contextLayerEnableBlockReason({
|
||||
contextMode: 'space-missions',
|
||||
change: { ...change, layerId: 'satellites' },
|
||||
}), null);
|
||||
assert.equal(contextLayerEnableBlockReason({
|
||||
contextMode: 'flights',
|
||||
change,
|
||||
}), null, 'live cockpit keeps additive user layers');
|
||||
});
|
||||
|
||||
test('the Global Context shell and layers selected while Context is off remain allowed', () => {
|
||||
assert.equal(shouldExitContextForLayerChange({
|
||||
contextMode: null,
|
||||
@@ -275,14 +204,38 @@ test('manually disabling a mode dependency exits that Context bundle', () => {
|
||||
change: { ...userEnable('military'), enabled: false },
|
||||
}), true);
|
||||
assert.equal(shouldExitContextForLayerChange({
|
||||
contextMode: 'space-missions',
|
||||
contextMode: 'flights',
|
||||
globalContextEnabled: false,
|
||||
change: { ...userEnable('satellites'), enabled: false },
|
||||
}), true);
|
||||
}), false, 'Satellites is not a Contacts dependency');
|
||||
});
|
||||
|
||||
test('Context never isolates, snapshots, restores or bookkeeps Space Missions and Satellites', () => {
|
||||
for (const layerId of ['rocket-launches', 'satellites']) {
|
||||
assert.equal(contextAllowedLayerIds('flights').has(layerId), true);
|
||||
const snapshot = { userAdded: new Set(), userRemoved: new Set() };
|
||||
for (const enabled of [true, false]) {
|
||||
assert.equal(recordContextSessionUserChange({
|
||||
snapshot,
|
||||
change: { type: 'visibility', origin: 'user', layerId, enabled },
|
||||
effectiveContextMode: 'flights',
|
||||
}), false);
|
||||
const restoreState = { enabledLayerIds: new Set() };
|
||||
assert.equal(recordContextRestoreExplicitChange({
|
||||
restoreState,
|
||||
change: { type: 'visibility', origin: 'user', layerId, enabled },
|
||||
}), false);
|
||||
}
|
||||
assert.equal(snapshot.userAdded.size + snapshot.userRemoved.size, 0);
|
||||
}
|
||||
assert.deepEqual(
|
||||
[...contextSnapshotLayerIds(new Set(['rocket-launches', 'satellites', 'cctv']))],
|
||||
['cctv'],
|
||||
);
|
||||
});
|
||||
|
||||
test('Radio remains an independent companion across Context transitions', () => {
|
||||
for (const contextMode of ['flights', 'space-missions']) {
|
||||
for (const contextMode of ['flights', null]) {
|
||||
for (const enabled of [true, false]) {
|
||||
assert.equal(shouldExitContextForLayerChange({
|
||||
contextMode,
|
||||
@@ -292,21 +245,17 @@ test('Radio remains an independent companion across Context transitions', () =>
|
||||
}
|
||||
assert.equal(contextAllowedLayerIds(contextMode).has('radio'), true);
|
||||
}
|
||||
assert.equal(contextLayerEnableBlockReason({
|
||||
contextMode: 'space-missions',
|
||||
change: { type: 'visibility', origin: 'user', layerId: 'radio', enabled: true },
|
||||
layerName: 'Radio',
|
||||
}), null);
|
||||
});
|
||||
|
||||
test('each Context mode exposes only its shell and dependencies', () => {
|
||||
assert.deepEqual(
|
||||
[...contextAllowedLayerIds(null)],
|
||||
['military-awareness', 'radio'],
|
||||
['military-awareness', 'radio', 'rocket-launches', 'satellites'],
|
||||
);
|
||||
assert.deepEqual(
|
||||
[...contextAllowedLayerIds('space-missions')],
|
||||
['rocket-launches', 'satellites', 'radio'],
|
||||
['military-awareness', 'radio', 'rocket-launches', 'satellites'],
|
||||
'Space Missions is not a Context mode',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -332,7 +281,7 @@ test('Context restoration honors an explicit companion disable', () => {
|
||||
});
|
||||
|
||||
test('the latest explicit Radio state wins across a Context session', () => {
|
||||
for (const effectiveContextMode of [null, 'flights', 'space-missions']) {
|
||||
for (const effectiveContextMode of [null, 'flights']) {
|
||||
for (const origin of ['user', 'voice']) {
|
||||
const snapshot = { userAdded: new Set(), userRemoved: new Set() };
|
||||
const record = (enabled) => recordContextSessionUserChange({
|
||||
@@ -368,7 +317,7 @@ test('only direct UI and voice origins count as explicit Context intent', () =>
|
||||
assert.equal(recordContextSessionUserChange({
|
||||
snapshot,
|
||||
change: { type: 'visibility', origin, layerId: 'radio', enabled: true },
|
||||
effectiveContextMode: 'space-missions',
|
||||
effectiveContextMode: 'flights',
|
||||
}), false);
|
||||
assert.equal(snapshot.userAdded.size, 0);
|
||||
}
|
||||
@@ -526,16 +475,8 @@ test('the teardown guard re-publishes on the way out, so a mid-flight exit is no
|
||||
|
||||
test('the session-starting entry layer is never bookkept as user-added (chip ON→OFF restores exactly)', () => {
|
||||
const snapshot = { enabledLayerIds: new Set(['flights', 'ais-live-vessels']), userAdded: new Set() };
|
||||
// The exact left-panel regression: the rockets enable event lands while the
|
||||
// mode is still being entered (or even null); it must not survive its own exit.
|
||||
for (const effectiveContextMode of ['space-missions', null]) {
|
||||
recordContextSessionUserChange({
|
||||
snapshot,
|
||||
change: { type: 'visibility', layerId: 'rocket-launches', enabled: true, origin: 'user' },
|
||||
effectiveContextMode,
|
||||
});
|
||||
assert.equal(snapshot.userAdded.has('rocket-launches'), false);
|
||||
}
|
||||
// The entry layer's enable event lands while the mode is still being
|
||||
// entered; it must not survive its own exit.
|
||||
recordContextSessionUserChange({
|
||||
snapshot,
|
||||
change: { type: 'visibility', layerId: 'military-awareness', enabled: true, origin: 'user' },
|
||||
@@ -559,10 +500,21 @@ test('mid-session user additions are recorded, removed on disable, and judged ag
|
||||
// A dependency of the mode being ENTERED is not a user addition.
|
||||
recordContextSessionUserChange({
|
||||
snapshot,
|
||||
change: { type: 'visibility', layerId: 'satellites', enabled: true, origin: 'user' },
|
||||
effectiveContextMode: 'space-missions',
|
||||
change: { type: 'visibility', layerId: 'military', enabled: true, origin: 'user' },
|
||||
effectiveContextMode: 'flights',
|
||||
});
|
||||
assert.equal(snapshot.userAdded.has('satellites'), false);
|
||||
assert.equal(snapshot.userAdded.has('military'), false);
|
||||
// Space Missions is not Context's: it is never bookkept.
|
||||
recordContextSessionUserChange({
|
||||
snapshot,
|
||||
change: { type: 'visibility', layerId: 'rocket-launches', enabled: true, origin: 'user' },
|
||||
effectiveContextMode: 'flights',
|
||||
});
|
||||
assert.equal(
|
||||
snapshot.userAdded.has('rocket-launches'),
|
||||
false,
|
||||
'Space Missions is not Context state',
|
||||
);
|
||||
// Disabling a recorded addition removes it before any exit restore reads it.
|
||||
recordContextSessionUserChange({
|
||||
snapshot,
|
||||
|
||||
@@ -13,10 +13,7 @@ const radioControlsSource = readRadioSource(new URL('./ui/radioControls.js', imp
|
||||
// - session bookkeeping ran AFTER the exit early-return, so the compensating
|
||||
// userAdded.delete never ran on the left-panel chip exit and restoration
|
||||
// resurrected the mission layer the user just disabled;
|
||||
// - the effective mode was read AFTER the entering flag was cleared, so the
|
||||
// entry layer's own enable event was judged against a null mode;
|
||||
// - a failed Space Missions START from the chip route cleared siblings with
|
||||
// no rollback;
|
||||
// - a failed direct Contacts START cleared siblings with no rollback;
|
||||
// - the right-rail entry ignored the activation result entirely.
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
@@ -33,25 +30,20 @@ test('context handler: session bookkeeping runs before the exit early-return', (
|
||||
assert.ok(record < exit, 'bookkeeping must precede the exit check');
|
||||
});
|
||||
|
||||
test('context handler: effective mode is read before the entering flag is cleared', () => {
|
||||
const effective = handler.indexOf('this._contextModeEntering || this._contextMode');
|
||||
const clear = handler.indexOf('this._contextModeEntering = null');
|
||||
assert.ok(effective > 0, 'effective-mode read present');
|
||||
assert.ok(clear > 0, 'entering-flag clear present');
|
||||
assert.ok(effective < clear, 'effective mode must be captured first');
|
||||
test('Space Missions is an ordinary layer the Context handler never enters', () => {
|
||||
assert.doesNotMatch(handler, /'space-missions'/);
|
||||
assert.doesNotMatch(handler, /_contextModeEntering = /);
|
||||
const attach = connectContextManager.toString();
|
||||
assert.doesNotMatch(attach, /rocket-launches|space-missions/);
|
||||
});
|
||||
|
||||
test('cancelled Space Missions entry resolves ownership before settled bookkeeping', () => {
|
||||
test('a cancelled visibility request returns before settled bookkeeping', () => {
|
||||
const cancelled = handler.indexOf("change?.type === 'visibility-cancelled'");
|
||||
const bookkeeping = handler.indexOf('recordContextSessionUserChange(');
|
||||
assert.ok(cancelled > 0, 'cancellation branch present');
|
||||
assert.ok(cancelled < bookkeeping, 'cancellation returns before settled session bookkeeping');
|
||||
const branch = handler.slice(cancelled, handler.indexOf("change?.type === 'visibility-blocked'"));
|
||||
assert.match(branch, /spaceMissionEntryCancellationDisposition\(\{/);
|
||||
assert.match(branch, /cancellationDisposition === 'replacement'[\s\S]*?_contextModeEntering = 'space-missions'[\s\S]*?entryIntent\.intentEpoch === change\.intentEpoch[\s\S]*?_contextModeReplacementIntent = \{[\s\S]*?intentEpoch: change\.successorIntentEpoch/);
|
||||
assert.match(branch, /cancellationDisposition === 'restore'[\s\S]*?_contextModeEntering = null/);
|
||||
assert.match(branch, /_restoreContextSessionAfterLayerSettles\(/);
|
||||
assert.match(branch, /return;/);
|
||||
assert.match(branch, /this\._syncContextModeButtons\(\);\s*return;/);
|
||||
});
|
||||
|
||||
test('direct Context entry captures on the synchronous request boundary', () => {
|
||||
@@ -60,18 +52,29 @@ test('direct Context entry captures on the synchronous request boundary', () =>
|
||||
attach,
|
||||
/subscribeVisibilityRequests\(\(change\) => \{[\s\S]*?shouldCaptureContextSession\(change\)/,
|
||||
);
|
||||
assert.match(
|
||||
attach,
|
||||
/_captureContextSessionSnapshot\(\{\s*excludeLayerIds:\s*\[change\.layerId\],?\s*\}\)/,
|
||||
);
|
||||
});
|
||||
|
||||
test('Clear All defers a newer explicit mission guard until its batch settles', () => {
|
||||
const attach = connectContextManager.toString();
|
||||
assert.match(attach, /shouldDeferContextEntryDuringClear\(\{/);
|
||||
assert.match(attach, /_contextModeDeferredEntryIntent = \{/);
|
||||
assert.match(attach, /await this\._clearSelectedLayersManagerPromise/);
|
||||
assert.match(attach, /await this\._clearLayersOutsideContextMode\(entryMode/);
|
||||
test('only a direct Contacts entry request snapshots the layers', () => {
|
||||
let request;
|
||||
const controls = new ContextControls({
|
||||
elements: {},
|
||||
installations: {},
|
||||
actions: { getCockpit: () => null },
|
||||
});
|
||||
const captures = [];
|
||||
controls._captureContextSessionSnapshot = (options) => captures.push(options);
|
||||
controls._syncContextModeButtons = () => {};
|
||||
controls.connect({
|
||||
subscribe: () => () => {},
|
||||
subscribeVisibilityRequests(listener) {
|
||||
request = listener;
|
||||
return () => {};
|
||||
},
|
||||
});
|
||||
for (const layerId of ['rocket-launches', 'military-awareness'])
|
||||
request({ type: 'visibility-requested', layerId, enabled: true, origin: 'user', intentEpoch: 1 });
|
||||
controls.stop();
|
||||
assert.deepEqual(captures, [{ excludeLayerIds: ['military-awareness'] }]);
|
||||
});
|
||||
|
||||
test('context restore replays explicit companion intent after the stale restore queue drains', () => {
|
||||
@@ -91,7 +94,7 @@ test('context restore settles the Contacts coordinator before dependency fanout'
|
||||
assert.ok(settle > 0, 'Contacts coordinator settlement is present');
|
||||
assert.ok(coordinatorOff > settle, 'Contacts OFF is awaited');
|
||||
assert.ok(fanout > coordinatorOff, 'snapshot fanout starts after Contacts settles');
|
||||
assert.match(restore, /excludeLayerIds: settleContactsCoordinator[\s\S]*?contactsCoordinatorId/);
|
||||
assert.match(restore, /excludeLayerIds: \[[\s\S]*?CONTEXT_INDEPENDENT_LAYER_IDS[\s\S]*?settleContactsCoordinator \? \[contactsCoordinatorId\]/);
|
||||
});
|
||||
|
||||
test('Clear All during the Contacts settle stops the snapshot coming back', () => {
|
||||
@@ -116,7 +119,7 @@ test('context handler: either failed direct Context-shell start rolls the sessio
|
||||
handler.indexOf("change?.type === 'visibility-failed'"),
|
||||
handler.indexOf("change?.type === 'visibility-will-change'"),
|
||||
);
|
||||
assert.match(failedBranch, /\['military-awareness', 'rocket-launches'\]\.includes\(change\.layerId\)/);
|
||||
assert.match(failedBranch, /change\.layerId === 'military-awareness' &&/);
|
||||
assert.match(
|
||||
failedBranch,
|
||||
/_restoreContextSessionAfterLayerSettles\(\s*change\.layerId,\s*\{\s*notificationToken,?\s*\},?\s*\)/,
|
||||
@@ -154,14 +157,14 @@ test('wrapped visibility blocks leave the accessible toast to the wrapper token
|
||||
|
||||
test('every user-facing Context exit route settles through the failure surface', () => {
|
||||
const initPanel = _initGlobalContextPanel.toString();
|
||||
assert.equal((initPanel.match(/void this\._runUserFacingContextAction/g) || []).length, 3);
|
||||
assert.equal((initPanel.match(/void this\._runUserFacingContextAction/g) || []).length, 2);
|
||||
assert.doesNotMatch(initPanel, /falseIsFailure:\s*false/);
|
||||
assert.doesNotMatch(initPanel, /void this\._selectContextMode/);
|
||||
|
||||
const deactivationCalls = [...handler.matchAll(
|
||||
/void this\._trackContextLayerReaction\(\s*this\._runUserFacingContextAction\(\(notificationToken\) =>\s*this\._deactivateContextForLayerChange\(\{ notificationToken \}\),?\s*\),?\s*\)/g,
|
||||
)];
|
||||
assert.equal(deactivationCalls.length, 4, 'dependency and primary layer exits share the caught restore path');
|
||||
assert.equal(deactivationCalls.length, 3, 'dependency and primary layer exits share the caught restore path');
|
||||
assert.doesNotMatch(handler, /void this\._deactivateContextForLayerChange\(\)/);
|
||||
});
|
||||
|
||||
@@ -193,10 +196,7 @@ test('right-rail context entry is transactional: activation result gates the mod
|
||||
const failureBlock = select.slice(activation);
|
||||
assert.match(failureBlock, /activated = await activationIntent\.promise/);
|
||||
assert.match(failureBlock, /catch \(error\) \{\s*activationError = error;/);
|
||||
assert.match(failureBlock, /_contextModeReplacementIntent\?\.generation === generation/);
|
||||
assert.match(failureBlock, /await this\._dataManager\._waitForVisibilityIntent\?\.\(/);
|
||||
assert.match(failureBlock, /outcome\?\.intentEpoch === replacementIntent\.intentEpoch[\s\S]*?outcome\.succeeded === true/);
|
||||
assert.match(failureBlock, /outcome\?\.cancellationReason === 'superseded'[\s\S]*?outcome\.successorEnabled === true[\s\S]*?outcome\.successorIntentEpoch > replacementIntent\.intentEpoch/);
|
||||
assert.match(failureBlock, /activationError\s*\|\|\s*activated === false\s*\|\|\s*!this\._dataManager\.isEnabled\(entryLayerId\)/);
|
||||
assert.match(failureBlock, /cancelledAndSettled\s*=\s*terminalIntentOutcome\?\.succeeded === false/);
|
||||
assert.match(failureBlock, /\['caller-abort', 'resource-abort', 'superseded'\]/);
|
||||
@@ -216,9 +216,11 @@ test('Context entry awaits isolation and direct shell routes isolate in the visi
|
||||
// rests on Context OFF; the honesty lives in the REPORT, not in a racy
|
||||
// attempt to put the prior mode back (see the note above
|
||||
// _restoreContextSessionAfterLayerSettles).
|
||||
const capture = select.indexOf('this._captureContextSessionSnapshot(');
|
||||
assert.ok(capture > 0, 'Context snapshot capture is missing');
|
||||
const crossMode = select.slice(
|
||||
select.indexOf('const crossModeSwitch = Boolean('),
|
||||
select.indexOf('this._captureContextSessionSnapshot();'),
|
||||
capture,
|
||||
);
|
||||
assert.ok(crossMode, 'cross-mode teardown block is missing');
|
||||
assert.doesNotMatch(crossMode, /if \(signal\?\.aborted\)[\s\S]*?await this\._restoreContextSession/);
|
||||
@@ -242,10 +244,10 @@ test('Context entry awaits isolation and direct shell routes isolate in the visi
|
||||
assert.match(ContextControls.prototype.stop.toString(), /this\._contextModeGeneration\+\+/);
|
||||
|
||||
const guard = connectContextManager.toString();
|
||||
assert.match(guard, /\['military-awareness', 'rocket-launches'\]\.includes\(change\.layerId\)/);
|
||||
assert.match(guard, /change\.layerId !== 'military-awareness'/);
|
||||
assert.match(guard, /const notificationToken\s*=\s*change\.notificationToken\s*\|\|\s*Symbol\('direct-context-shell-entry'\)/);
|
||||
assert.match(guard, /this\._userFacingContextNotificationTokens\.add\(notificationToken\)/);
|
||||
assert.match(guard, /await this\._clearLayersOutsideContextMode\(entryMode,\s*\{\s*notificationToken,?\s*\}\)/);
|
||||
assert.match(guard, /await this\._clearLayersOutsideContextMode\(null,\s*\{\s*notificationToken,?\s*\}\)/);
|
||||
assert.match(
|
||||
guard,
|
||||
/await this\._restoreContextSession\(\{\s*excludeLayerIds: \[change\.layerId\],\s*notificationToken,\s*\}\)/,
|
||||
|
||||
@@ -2,7 +2,9 @@ import { renderApplicationHtml } from './testSupport/applicationHtml.mjs';
|
||||
import { readStylesheet } from './testSupport/readStylesheet.mjs';
|
||||
import { _selectContextMode } from './ui/contextTransactions.js';
|
||||
import { _initGlobalContextPanel } from './ui/contextBindings.js';
|
||||
import { ContextControls } from './ui/contextControls.js';
|
||||
import { clearSelectedLayers } from './ui/contextActions.js';
|
||||
import { PANEL_RAIL_ITEMS } from './ui/panelRailCatalog.js';
|
||||
import { readFileSync as readRadioSource } from 'node:fs';
|
||||
const radioBindings = readRadioSource(
|
||||
new URL('./ui/radioBindings.js', import.meta.url),
|
||||
@@ -21,43 +23,24 @@ const html = await renderApplicationHtml(
|
||||
);
|
||||
const css = readStylesheet(new URL('../style.css', import.meta.url));
|
||||
|
||||
test('Contacts and Space Missions both participate in the ordinary Tab sequence', () => {
|
||||
for (const id of [
|
||||
'global-context-flights-btn',
|
||||
'global-context-missions-btn',
|
||||
]) {
|
||||
const button = html.match(
|
||||
new RegExp(`<button id="${id}"[\\s\\S]*?</button>`),
|
||||
);
|
||||
assert.ok(button, `${id} is missing`);
|
||||
assert.match(button[0], /role="tab"/);
|
||||
assert.match(button[0], /tabindex="0"/);
|
||||
}
|
||||
|
||||
// The view keeps both tabs' tabindex static and never disables them; the
|
||||
// transition itself is covered over happy-dom in ui/contextPanel.test.mjs.
|
||||
for (const id of [
|
||||
'global-context-flights-btn',
|
||||
'global-context-missions-btn',
|
||||
]) {
|
||||
const tag = contextView.match(new RegExp(`<button id="${id}"[^>]*>`))?.[0];
|
||||
assert.ok(tag, `${id} is missing from the view`);
|
||||
assert.doesNotMatch(tag, /:tabindex|:disabled|\sdisabled/);
|
||||
}
|
||||
test('Contacts stays in the keyboard sequence and Space Missions owns its rail item', () => {
|
||||
const button = html.match(
|
||||
/<button id="global-context-flights-btn"[\s\S]*?<\/button>/,
|
||||
)?.[0];
|
||||
assert.ok(button, 'Contacts control is missing');
|
||||
assert.match(button, /role="tab"/);
|
||||
assert.match(button, /tabindex="0"/);
|
||||
const tag = contextView.match(/<button id="global-context-flights-btn"[^>]*>/)?.[0];
|
||||
assert.ok(tag, 'Contacts control is missing from the view');
|
||||
assert.doesNotMatch(tag, /:tabindex|:disabled|\sdisabled/);
|
||||
assert.doesNotMatch(html, /id="global-context-missions-btn"/);
|
||||
assert.match(html, /id="space-missions-panel"[^>]*data-panel-id="space-missions-panel"/);
|
||||
assert.equal(PANEL_RAIL_ITEMS['space-missions-panel'].icon, 'rocket_launch');
|
||||
});
|
||||
|
||||
test('Context activation and Clear All never native-disable tabs and guard repeated clicks', () => {
|
||||
const init = _initGlobalContextPanel.toString();
|
||||
const select = _selectContextMode.toString();
|
||||
const clear = clearSelectedLayers.toString();
|
||||
assert.equal(
|
||||
(
|
||||
init.match(
|
||||
/if \(\s*this\.destroyed\s*\|\|\s*this\._contextModeChanging\s*\|\|\s*this\._clearSelectedLayersPromise\s*\)\s*return;/g,
|
||||
) || []
|
||||
).length,
|
||||
2,
|
||||
);
|
||||
assert.doesNotMatch(
|
||||
select,
|
||||
/_globalContext(?:Flights|Missions)Btn\.disabled\s*=\s*true/,
|
||||
@@ -68,17 +51,29 @@ test('Context activation and Clear All never native-disable tabs and guard repea
|
||||
);
|
||||
});
|
||||
|
||||
test('Context tablist retains Left, Right, Home, and End keyboard navigation', () => {
|
||||
const initSource = _initGlobalContextPanel.toString();
|
||||
assert.match(initSource, /event\.key === 'ArrowRight'/);
|
||||
assert.match(initSource, /event\.key === 'ArrowLeft'/);
|
||||
assert.match(initSource, /event\.key === 'Home'/);
|
||||
assert.match(initSource, /event\.key === 'End'/);
|
||||
assert.match(
|
||||
initSource,
|
||||
/contextTabs\[nextIndex\]\.focus\(\{ preventScroll: true \}\)/,
|
||||
);
|
||||
assert.match(initSource, /contextTabs\[nextIndex\]\.click\(\)/);
|
||||
test('a Contacts click while Context is busy is ignored', () => {
|
||||
const button = new EventTarget();
|
||||
const controls = new ContextControls({
|
||||
elements: { _globalContextFlightsBtn: button },
|
||||
installations: {},
|
||||
actions: { getCockpit: () => null, claimVisualAuthority() {} },
|
||||
});
|
||||
const runs = [];
|
||||
controls._runUserFacingContextAction = (operation) => {
|
||||
runs.push(operation);
|
||||
return Promise.resolve(false);
|
||||
};
|
||||
const click = () => button.dispatchEvent(new Event('click'));
|
||||
controls._contextModeChanging = true;
|
||||
click();
|
||||
controls._contextModeChanging = false;
|
||||
controls._clearSelectedLayersPromise = Promise.resolve();
|
||||
click();
|
||||
assert.equal(runs.length, 0, 'a transition or Clear All in flight drops it');
|
||||
controls._clearSelectedLayersPromise = null;
|
||||
click();
|
||||
assert.equal(runs.length, 1, 'an idle panel takes the click');
|
||||
controls.stop();
|
||||
});
|
||||
|
||||
test('Context tabs draw a visible keyboard-focus outline including active tabs', () => {
|
||||
@@ -102,7 +97,6 @@ test('Context tabs draw a visible keyboard-focus outline including active tabs',
|
||||
});
|
||||
|
||||
test('Context async action buttons remain focused while busy', () => {
|
||||
const init = _initGlobalContextPanel.toString();
|
||||
const radio = radioBindings.slice(
|
||||
radioBindings.indexOf('const toggleRadio = async (trigger) => {'),
|
||||
radioBindings.indexOf('this._storeToken = this.store?.connect?.('),
|
||||
@@ -113,6 +107,7 @@ test('Context async action buttons remain focused while busy', () => {
|
||||
);
|
||||
const clear = clearSelectedLayers.toString();
|
||||
|
||||
const init = _initGlobalContextPanel.toString();
|
||||
assert.match(init, /if \(this\._installationsSearchBusy\) return;/);
|
||||
assert.doesNotMatch(init, /\.disabled\s*=\s*true/);
|
||||
const search = contextView.match(
|
||||
@@ -220,7 +215,7 @@ test('Context reads as one segmented control with legible type and no halo', ()
|
||||
// open Context title legible; no Context-only rule dims it again.
|
||||
assert.equal(
|
||||
rule(
|
||||
":root:not([data-ui-theme='cyber']) #global-context-panel:not(.collapsed) .panel-title",
|
||||
":root #global-context-panel:not(.collapsed) .panel-title",
|
||||
),
|
||||
'',
|
||||
);
|
||||
|
||||
+288
-38
@@ -6,6 +6,12 @@ import test from 'node:test';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
// The Omnibar's desktop footer (src/ui/styles/omnibar-dock.css) is part of
|
||||
// the cascade below like every other stylesheet; its rules carry the
|
||||
// Omnibar scope, so they are modelled as a layout of their own.
|
||||
const omnibarCss = readStylesheet(
|
||||
path.join(ROOT, 'src/ui/styles/omnibar-dock.css'),
|
||||
);
|
||||
const css = readStylesheet(path.join(ROOT, 'style.css'));
|
||||
|
||||
/*
|
||||
@@ -125,11 +131,56 @@ function specificity(selector) {
|
||||
return [ids, classes, types];
|
||||
}
|
||||
|
||||
/** Flatten style.css into rules carrying their raw media stack. */
|
||||
/** Collapse whitespace and the padding inside brackets of a selector. */
|
||||
const tidySelector = (part) =>
|
||||
part
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim()
|
||||
.replace(/\(\s+/g, '(')
|
||||
.replace(/\s+\)/g, ')');
|
||||
|
||||
/**
|
||||
* A nested selector resolved against its parent rule's selectors, as CSS
|
||||
* nesting does: `&` stands for the parent, and a selector without one is a
|
||||
* descendant of it.
|
||||
*/
|
||||
function nestSelectors(parents, head) {
|
||||
const own = splitTopLevel(head, ',').map(tidySelector).filter(Boolean);
|
||||
if (!parents) return own;
|
||||
return parents.flatMap((parent) =>
|
||||
own.map((part) =>
|
||||
part.includes('&') ? part.replaceAll('&', parent) : `${parent} ${part}`,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Flatten style.css into rules carrying their raw media stack. Nested style
|
||||
* rules (CSS nesting) and media queries nested in a rule are resolved to
|
||||
* full selectors, so a nested rule is modelled like any other.
|
||||
*/
|
||||
function flattenRules(source) {
|
||||
const src = source.replace(/\/\*[\s\S]*?\*\//g, '');
|
||||
const rules = [];
|
||||
const mediaStack = [];
|
||||
// Open blocks, innermost last: media queries and style rules.
|
||||
const stack = [];
|
||||
const mediaStack = () =>
|
||||
stack.filter((frame) => frame.media).map((frame) => frame.media);
|
||||
const parentRule = () =>
|
||||
[...stack].reverse().find((frame) => frame.rule)?.rule || null;
|
||||
const declare = (text) => {
|
||||
const rule = parentRule();
|
||||
const trimmed = text.trim();
|
||||
if (!rule || !trimmed) return;
|
||||
const colon = trimmed.indexOf(':');
|
||||
if (colon < 0) return;
|
||||
const value = trimmed.slice(colon + 1).trim();
|
||||
rule.decls.push({
|
||||
prop: trimmed.slice(0, colon).trim().toLowerCase(),
|
||||
value: value.replace(/\s*!important$/i, '').trim(),
|
||||
important: /!important\s*$/i.test(value),
|
||||
});
|
||||
};
|
||||
let index = 0;
|
||||
let prelude = '';
|
||||
while (index < src.length) {
|
||||
@@ -137,14 +188,13 @@ function flattenRules(source) {
|
||||
if (char === '{') {
|
||||
const head = prelude.replace(/\s+/g, ' ').trim();
|
||||
prelude = '';
|
||||
index += 1;
|
||||
if (head.startsWith('@media')) {
|
||||
mediaStack.push(head.slice('@media'.length).trim());
|
||||
index += 1;
|
||||
stack.push({ media: head.slice('@media'.length).trim() });
|
||||
continue;
|
||||
}
|
||||
if (head.startsWith('@')) {
|
||||
let level = 1;
|
||||
index += 1;
|
||||
while (index < src.length && level > 0) {
|
||||
if (src[index] === '{') level += 1;
|
||||
else if (src[index] === '}') level -= 1;
|
||||
@@ -152,43 +202,34 @@ function flattenRules(source) {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
const close = src.indexOf('}', index);
|
||||
assert.ok(close > index, `unterminated rule block for "${head}"`);
|
||||
const decls = [];
|
||||
for (const raw of src.slice(index + 1, close).split(';')) {
|
||||
const text = raw.trim();
|
||||
if (!text) continue;
|
||||
const colon = text.indexOf(':');
|
||||
if (colon < 0) continue;
|
||||
const value = text.slice(colon + 1).trim();
|
||||
decls.push({
|
||||
prop: text.slice(0, colon).trim().toLowerCase(),
|
||||
value: value.replace(/\s*!important$/i, '').trim(),
|
||||
important: /!important\s*$/i.test(value),
|
||||
});
|
||||
}
|
||||
rules.push({
|
||||
const rule = {
|
||||
order: rules.length,
|
||||
media: [...mediaStack],
|
||||
parts: splitTopLevel(head, ',')
|
||||
.map((part) =>
|
||||
part.trim().replace(/\(\s+/g, '(').replace(/\s+\)/g, ')'),
|
||||
)
|
||||
.filter(Boolean),
|
||||
decls,
|
||||
});
|
||||
index = close + 1;
|
||||
media: mediaStack(),
|
||||
parts: nestSelectors(parentRule()?.parts, head),
|
||||
decls: [],
|
||||
};
|
||||
rules.push(rule);
|
||||
stack.push({ rule });
|
||||
continue;
|
||||
}
|
||||
if (char === ';') {
|
||||
declare(prelude);
|
||||
prelude = '';
|
||||
index += 1;
|
||||
continue;
|
||||
}
|
||||
if (char === '}') {
|
||||
mediaStack.pop();
|
||||
// The last declaration of a block may omit its semicolon.
|
||||
declare(prelude);
|
||||
prelude = '';
|
||||
stack.pop();
|
||||
index += 1;
|
||||
continue;
|
||||
}
|
||||
prelude += char;
|
||||
index += 1;
|
||||
}
|
||||
assert.equal(stack.length, 0, 'unbalanced braces in style.css');
|
||||
return rules;
|
||||
}
|
||||
|
||||
@@ -227,6 +268,29 @@ const RECOGNIZED = new Set([
|
||||
]);
|
||||
|
||||
const DOCKED_RAIL = 'body.context-docked #right-context-rail';
|
||||
|
||||
// The desktop Omnibar layout: the scope its stylesheet nests every rule in.
|
||||
// It applies on the desktop shell (above the 720px phone breakpoint) while
|
||||
// the Omnibar and the voice control share the dock; outside it the legacy
|
||||
// layout below governs.
|
||||
const OMNIBAR_SCOPE =
|
||||
'body:not(.mobile-shell):not(.cockpit-mode):not(.scene-playback-mode):not(.ui-clean-view):not(.recording-mode):where(:has(#gev-omnibar):has(#command-dock > #gev-voice-control))';
|
||||
const OMNIBAR = Object.freeze({
|
||||
dock: `${OMNIBAR_SCOPE} #command-dock`,
|
||||
credit: `${OMNIBAR_SCOPE} :is(#cesium-credits, #gev-credits)`,
|
||||
minimalCredit: `${OMNIBAR_SCOPE}:has(#intel-hud[data-variant='minimal'].active) :is(#cesium-credits, #gev-credits)`,
|
||||
minimalRail: `${OMNIBAR_SCOPE}:not(.context-docked):has(#intel-hud[data-variant='minimal'].active) #right-context-rail`,
|
||||
trays: `${OMNIBAR_SCOPE} #command-dock > :is(#location-bar, #control-panel)`,
|
||||
});
|
||||
// What each Omnibar-scope rule may set on a modelled box; the Omnibar
|
||||
// clearance test resolves every one of them through the full cascade.
|
||||
const OMNIBAR_RECOGNIZED = new Map([
|
||||
[OMNIBAR.dock, new Set(['top', 'bottom', 'height', 'min-height'])],
|
||||
[OMNIBAR.credit, new Set(['bottom'])],
|
||||
[OMNIBAR.minimalCredit, new Set(['bottom'])],
|
||||
[OMNIBAR.minimalRail, new Set(['max-height'])],
|
||||
]);
|
||||
const OMNIBAR_MIN_WIDTH = 721;
|
||||
const ELEMENT_KEYS = [
|
||||
'#cesium-credits',
|
||||
'#command-dock',
|
||||
@@ -300,8 +364,11 @@ function ownBoxEntries() {
|
||||
// So is Stories, with GEV's chrome stepped aside; storiesCredit.test.mjs
|
||||
// pins its attribution placement.
|
||||
if (
|
||||
/^body\.stories-mode:not\(#gs-a\):not\(#gs-b\) #(cesium|gev)-credits$/.test(part)
|
||||
) continue;
|
||||
/^body\.stories-mode:not\(#gs-a\):not\(#gs-b\) #(cesium|gev)-credits$/.test(
|
||||
part,
|
||||
)
|
||||
)
|
||||
continue;
|
||||
entries.push({ rule, part });
|
||||
}
|
||||
}
|
||||
@@ -372,12 +439,21 @@ function resolve(candidates, prop, width, label) {
|
||||
/** Evaluate a length. Anything the model cannot resolve exactly fails loudly. */
|
||||
function toPx(value, viewportHeight, where) {
|
||||
const trimmed = value.trim();
|
||||
// The larger of its lengths, each resolved the same way.
|
||||
if (/^max\(.*\)$/.test(trimmed))
|
||||
return Math.max(
|
||||
...splitTopLevel(trimmed.slice(4, -1), ',').map((part) =>
|
||||
toPx(part, viewportHeight, where),
|
||||
),
|
||||
);
|
||||
const inner = /^calc\(/.test(trimmed) ? trimmed.slice(5, -1) : trimmed;
|
||||
assert.doesNotMatch(
|
||||
inner,
|
||||
/\bcalc\(/,
|
||||
`nested calc() in ${where}: "${value}"`,
|
||||
);
|
||||
// A calc() is a whole term of its own, resolved below; nowhere else.
|
||||
for (const term of splitTopLevel(inner, '+'))
|
||||
assert.doesNotMatch(
|
||||
term.trim().replace(/^calc\(.*\)$/, ''),
|
||||
/\bcalc\(/,
|
||||
`nested calc() in ${where}: "${value}"`,
|
||||
);
|
||||
assert.doesNotMatch(
|
||||
inner,
|
||||
/\b(min|max|clamp|env|attr|round|mod)\(/,
|
||||
@@ -398,6 +474,18 @@ function toPx(value, viewportHeight, where) {
|
||||
const term = raw.trim();
|
||||
if (!term) continue;
|
||||
if (term === '100%') continue; // the tray's own panel height, added separately
|
||||
// A calc() of its own, as a term ("calc(var(--omnibar-credits-clear) +
|
||||
// 2px)" once substituted).
|
||||
if (/^calc\(.*\)$/.test(term)) {
|
||||
total += toPx(term, viewportHeight, where);
|
||||
continue;
|
||||
}
|
||||
// The credit line's own height (src/ui/creditLineHeight.js), at the
|
||||
// height this pin models it at.
|
||||
if (/^var\(--credit-line-height\b/.test(term)) {
|
||||
total += CREDIT_HEIGHT_PX;
|
||||
continue;
|
||||
}
|
||||
if (term.startsWith('var(')) {
|
||||
const name = term.slice(4, term.lastIndexOf(')')).split(',')[0].trim();
|
||||
assert.ok(
|
||||
@@ -521,6 +609,22 @@ test('the model refuses every cascade construct it cannot resolve', () => {
|
||||
// Expanded Context covers the right edge top to bottom; the credit row
|
||||
// stops short of it instead (the docked-Context test below).
|
||||
if (part === DOCKED_RAIL) continue;
|
||||
if (part.startsWith(OMNIBAR_SCOPE)) {
|
||||
const allowed = OMNIBAR_RECOGNIZED.get(part);
|
||||
for (const decl of guarded) {
|
||||
if (!allowed?.has(decl.prop))
|
||||
complaints.push(
|
||||
`unrecognized Omnibar rule positions a modelled element: "${part}" (${decl.prop})`,
|
||||
);
|
||||
if (decl.important)
|
||||
complaints.push(`!important on ${decl.prop} of "${part}"`);
|
||||
}
|
||||
if (rule.media.length)
|
||||
complaints.push(
|
||||
`media query on Omnibar rule "${part}": ${rule.media.join(' && ')}`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
if (!RECOGNIZED.has(part)) {
|
||||
complaints.push(
|
||||
`unrecognized selector positions a modelled element: "${part}" (${guarded.map((d) => d.prop).join(', ')})`,
|
||||
@@ -771,6 +875,152 @@ test('right rail measurement cannot persist into a painted attribution layout',
|
||||
|
||||
// ── Clearance ───────────────────────────────────────────────────────────────
|
||||
|
||||
/** A custom property's value as the Omnibar scope declares it. */
|
||||
function omnibarVar(name) {
|
||||
const decls = RULES.filter((rule) => rule.parts.includes(OMNIBAR_SCOPE))
|
||||
.flatMap((rule) => rule.decls)
|
||||
.filter((decl) => decl.prop === name);
|
||||
assert.equal(
|
||||
decls.length,
|
||||
1,
|
||||
`${name} is declared once in the Omnibar scope`,
|
||||
);
|
||||
return decls[0].value;
|
||||
}
|
||||
|
||||
/** A length in the Omnibar layout, with its scope's own custom properties. */
|
||||
function omnibarPx(value, viewportHeight, where) {
|
||||
// The scope's properties may name each other ("--omnibar-dock-bottom"
|
||||
// clears "--omnibar-credits-clear"): substitute until none is left.
|
||||
let substituted = value;
|
||||
for (let pass = 0; /var\(--omnibar-/.test(substituted); pass += 1) {
|
||||
assert.ok(
|
||||
pass < 8,
|
||||
`Omnibar properties name each other in a loop: ${value}`,
|
||||
);
|
||||
substituted = substituted.replace(/var\((--omnibar-[\w-]+)\)/g, (_, name) =>
|
||||
omnibarVar(name),
|
||||
);
|
||||
}
|
||||
return toPx(substituted, viewportHeight, where);
|
||||
}
|
||||
|
||||
test('Omnibar reserves a non-overlapping desktop footer at native credit sizing', () => {
|
||||
// The Omnibar layout resolves through the same cascade as the legacy one:
|
||||
// every legacy rule that could still match competes with the scope's.
|
||||
const trayOpen = [
|
||||
'#command-dock:has(#location-bar:not(.collapsed))',
|
||||
'#command-dock:has(#control-panel:not(.collapsed))',
|
||||
];
|
||||
assert.equal(
|
||||
omnibarVar('--world-timeline-lift'),
|
||||
'0px',
|
||||
'the Omnibar layout holds the timeline lift at 0',
|
||||
);
|
||||
for (const width of WIDTHS.filter((w) => w >= OMNIBAR_MIN_WIDTH)) {
|
||||
for (const height of HEIGHTS) {
|
||||
for (const minimal of [false, true]) {
|
||||
const dock = resolve(
|
||||
['#command-dock', ...trayOpen, OMNIBAR.dock],
|
||||
'bottom',
|
||||
width,
|
||||
'Omnibar dock',
|
||||
);
|
||||
assert.equal(
|
||||
dock.part,
|
||||
OMNIBAR.dock,
|
||||
`the Omnibar owns the dock at ${width}px`,
|
||||
);
|
||||
// Its top and height too: a legacy top or height winning here would
|
||||
// move or stretch the dock the clearance below is measured from.
|
||||
for (const [prop, value] of [
|
||||
['top', 'auto'],
|
||||
['height', '56px'],
|
||||
]) {
|
||||
const own = resolve(
|
||||
['#command-dock', ...trayOpen, OMNIBAR.dock],
|
||||
prop,
|
||||
width,
|
||||
`Omnibar dock ${prop}`,
|
||||
);
|
||||
assert.equal(
|
||||
own.part,
|
||||
OMNIBAR.dock,
|
||||
`the Omnibar owns the dock ${prop} at ${width}px`,
|
||||
);
|
||||
assert.equal(
|
||||
own.decl.value,
|
||||
value,
|
||||
`Omnibar dock ${prop} at ${width}px`,
|
||||
);
|
||||
}
|
||||
const credit = resolve(
|
||||
[
|
||||
...CREDIT_SELECTORS,
|
||||
OMNIBAR.credit,
|
||||
...(minimal ? [MINIMAL_HUD_CREDIT, OMNIBAR.minimalCredit] : []),
|
||||
],
|
||||
'bottom',
|
||||
width,
|
||||
'Omnibar credit',
|
||||
);
|
||||
assert.ok(
|
||||
credit.part.startsWith(OMNIBAR_SCOPE),
|
||||
`the Omnibar owns the credit row at ${width}px`,
|
||||
);
|
||||
const dockBottom = omnibarPx(
|
||||
dock.decl.value,
|
||||
height,
|
||||
'Omnibar dock bottom',
|
||||
);
|
||||
const creditTop =
|
||||
omnibarPx(credit.decl.value, height, 'Omnibar credit bottom') +
|
||||
CREDIT_HEIGHT_PX;
|
||||
assert.ok(
|
||||
dockBottom - creditTop >= MIN_CLEARANCE_PX,
|
||||
`at ${width}x${height}${minimal ? ' (minimal HUD)' : ''} the Omnibar dock (${dockBottom}px) must clear the credit line (${creditTop}px)`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
// No legacy tray opens over the credit: both are hidden in this layout,
|
||||
// and no rule elsewhere forces them back.
|
||||
const trays = RULES.find((rule) => rule.parts.includes(OMNIBAR.trays));
|
||||
assert.ok(trays, 'the Omnibar layout hides the legacy trays');
|
||||
assert.equal(
|
||||
trays.decls.find((decl) => decl.prop === 'display')?.value,
|
||||
'none',
|
||||
);
|
||||
for (const rule of RULES) {
|
||||
for (const part of rule.parts) {
|
||||
if (!/#(location-bar|control-panel)$/.test(lastCompound(part))) continue;
|
||||
assert.ok(
|
||||
!rule.decls.some((decl) => decl.prop === 'display' && decl.important),
|
||||
`"${part}" forces a hidden tray back with !important`,
|
||||
);
|
||||
}
|
||||
}
|
||||
// The minimal-HUD rail cap only shortens the rail, which is anchored at
|
||||
// its top, so it can only add room above the credit.
|
||||
const rail = RULES.find((rule) => rule.parts.includes(OMNIBAR.minimalRail));
|
||||
const cap = rail.decls.find(
|
||||
(decl) => decl.prop === '--omnibar-minimal-rail-height',
|
||||
);
|
||||
assert.match(
|
||||
cap?.value || '',
|
||||
/^min\(\s*var\(--right-stack-max-height, 70vh\),/,
|
||||
);
|
||||
assert.equal(
|
||||
rail.decls.find((decl) => decl.prop === 'max-height')?.value,
|
||||
'var(--omnibar-minimal-rail-height)',
|
||||
);
|
||||
assert.doesNotMatch(
|
||||
omnibarCss,
|
||||
/\.cesium-widget-credits|\.cesium-credit-logoContainer|\.cesium-credit-textContainer/,
|
||||
'the footer uses the original credit text and logo sizing',
|
||||
);
|
||||
});
|
||||
|
||||
test('every open dock tray clears the required credit at every modelled viewport', () => {
|
||||
// Below 900px the tray widens to nearly the viewport and lands on the
|
||||
// bottom-left corner where the credit lives. The clearance is NOT one fixed
|
||||
|
||||
+8
-6
@@ -527,10 +527,15 @@ export function cyberSonarLabelIntensity(
|
||||
return labelDimFactor + (1 - labelDimFactor) * normalized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sonar is an opt-in visual style over any HUD layout: it is on only after
|
||||
* the Display panel's Sonar toggle, a voice request or a legacy Cyber link
|
||||
* turns it on.
|
||||
*/
|
||||
export function isCyberSonarEnabled(
|
||||
root = globalThis.document?.documentElement,
|
||||
) {
|
||||
return root?.dataset?.cyberSonar !== 'off';
|
||||
return root?.dataset?.cyberSonar === 'on';
|
||||
}
|
||||
|
||||
export function setCyberSonarEnabled(
|
||||
@@ -539,9 +544,7 @@ export function setCyberSonarEnabled(
|
||||
) {
|
||||
if (!root?.dataset) return false;
|
||||
root.dataset.cyberSonar = enabled ? 'on' : 'off';
|
||||
if (root.dataset.uiTheme === 'cyber') {
|
||||
applyCyberSonarThemePhase(root, enabled);
|
||||
}
|
||||
applyCyberSonarThemePhase(root, enabled);
|
||||
return enabled;
|
||||
}
|
||||
|
||||
@@ -566,7 +569,6 @@ export function isCyberSonarActive({
|
||||
globalThis.matchMedia?.('(prefers-reduced-motion: reduce)')?.matches ??
|
||||
false;
|
||||
return !!(
|
||||
root?.dataset?.uiTheme === 'cyber' &&
|
||||
isCyberSonarEnabled(root) &&
|
||||
(hudActive ?? hud?.classList?.contains?.('active')) &&
|
||||
!body?.classList?.contains?.('cockpit-mode') &&
|
||||
@@ -583,7 +585,7 @@ export function isCyberMapThemeActive({
|
||||
if (hud === undefined)
|
||||
hud = globalThis.document?.getElementById?.('intel-hud');
|
||||
return !!(
|
||||
root?.dataset?.uiTheme === 'cyber' &&
|
||||
isCyberSonarEnabled(root) &&
|
||||
(hudActive ?? hud?.classList?.contains?.('active')) &&
|
||||
!body?.classList?.contains?.('cockpit-mode')
|
||||
);
|
||||
|
||||
+13
-9
@@ -39,7 +39,7 @@ test('production-transformed sonar defaults retain the document method receiver'
|
||||
const previous = Object.getOwnPropertyDescriptor(globalThis, 'document');
|
||||
const hud = { classList: { contains: (name) => name === 'active' } };
|
||||
const document = {
|
||||
documentElement: { dataset: { uiTheme: 'cyber' } },
|
||||
documentElement: { dataset: { cyberSonar: 'on' } },
|
||||
body: { classList: { contains: () => false } },
|
||||
getElementById(id) {
|
||||
assert.equal(this, document);
|
||||
@@ -57,7 +57,7 @@ test('production-transformed sonar defaults retain the document method receiver'
|
||||
assert.ok(
|
||||
Number.isFinite(compiled.createCyberSonarSampler(800, 600).at(400, 300)),
|
||||
);
|
||||
document.documentElement.dataset.uiTheme = 'tactical';
|
||||
document.documentElement.dataset.cyberSonar = 'off';
|
||||
assert.equal(compiled.isCyberSonarActive(), false);
|
||||
assert.equal(compiled.isCyberMapThemeActive(), false);
|
||||
} finally {
|
||||
@@ -139,8 +139,8 @@ test('the sweep brightens contacts inside its sector and dims the remainder', ()
|
||||
);
|
||||
});
|
||||
|
||||
test('the sonar activates only for a visible Cyber map HUD with motion enabled', () => {
|
||||
const root = { dataset: { uiTheme: 'cyber' } };
|
||||
test('the sonar activates only while on, over a visible map HUD with motion enabled', () => {
|
||||
const root = { dataset: { cyberSonar: 'on' } };
|
||||
const classes = (...values) => ({
|
||||
contains: (value) => values.includes(value),
|
||||
});
|
||||
@@ -220,14 +220,18 @@ test('the opacity setting controls every contact floor and preserves brighter la
|
||||
);
|
||||
});
|
||||
|
||||
test('the sonar control defaults on and records explicit operator state', () => {
|
||||
test('the sonar control defaults off and records explicit operator state', () => {
|
||||
const root = { dataset: {} };
|
||||
assert.equal(isCyberSonarEnabled(root), false);
|
||||
// The removed Cyber theme no longer turns it on.
|
||||
root.dataset.uiTheme = 'cyber';
|
||||
assert.equal(isCyberSonarEnabled(root), false);
|
||||
assert.equal(setCyberSonarEnabled(true, root), true);
|
||||
assert.equal(root.dataset.cyberSonar, 'on');
|
||||
assert.equal(isCyberSonarEnabled(root), true);
|
||||
assert.equal(setCyberSonarEnabled(false, root), false);
|
||||
assert.equal(root.dataset.cyberSonar, 'off');
|
||||
assert.equal(isCyberSonarEnabled(root), false);
|
||||
assert.equal(setCyberSonarEnabled(true, root), true);
|
||||
assert.equal(root.dataset.cyberSonar, 'on');
|
||||
});
|
||||
|
||||
test('real Cesium points and billboards recover after repeated low/high opacity cycles', () => {
|
||||
@@ -349,10 +353,10 @@ test('the sweep corrects delayed starts and reacquires restarted animations with
|
||||
assert.doesNotThrow(() => syncCyberSonarAnimation({}));
|
||||
});
|
||||
|
||||
test('the selected Cyber theme seeds and releases the compositor sweep phase', () => {
|
||||
test('turning Sonar on seeds and releases the compositor sweep phase', () => {
|
||||
const values = new Map();
|
||||
const root = {
|
||||
dataset: {},
|
||||
dataset: { cyberSonar: 'on' },
|
||||
style: {
|
||||
setProperty: (name, value) => values.set(name, value),
|
||||
removeProperty: (name) => values.delete(name),
|
||||
|
||||
@@ -45,7 +45,7 @@ test('frame sampler matches reference without per-contact settings access', () =
|
||||
});
|
||||
|
||||
test('removed CSS mode cannot disable GPU contacts; unsupported renderers fail closed', () => {
|
||||
const root = { dataset: { uiTheme: 'cyber' }, style: { setProperty() {} } };
|
||||
const root = { dataset: { cyberSonar: 'on' }, style: { setProperty() {} } };
|
||||
const options = {
|
||||
root,
|
||||
body: { classList: { contains: () => false } },
|
||||
@@ -97,7 +97,7 @@ function fixture({ modulation = true, lists = true } = {}) {
|
||||
document: globalThis.document,
|
||||
matchMedia: globalThis.matchMedia,
|
||||
};
|
||||
const root = { dataset: { uiTheme: 'cyber', cyberSonar: 'on' } };
|
||||
const root = { dataset: { cyberSonar: 'on' } };
|
||||
const status = { textContent: '' };
|
||||
const state = { cockpit: false, reducedMotion: false };
|
||||
globalThis.document = {
|
||||
@@ -232,36 +232,47 @@ test('the sweep sets its sector on drawing ticks and at the cadence, and changes
|
||||
f.tick(false);
|
||||
assert.equal(f.sets.length, 4, 'a resize sets it at once');
|
||||
assert.deepEqual(f.sets[3].center, { x: 300, y: 400 });
|
||||
f.root.dataset.cyberSonar = 'off';
|
||||
f.root.dataset.cyberSonarOpacity = '50';
|
||||
f.tick(false);
|
||||
assert.equal(f.sets[4].radius, 0, 'Sonar OFF rests every contact');
|
||||
assert.equal(f.sets.length, 5, 'a setting change sets it at once');
|
||||
assert.equal(
|
||||
f.sets[4].floor,
|
||||
0.5,
|
||||
'while sweeping the floor is the opacity',
|
||||
);
|
||||
f.state.reducedMotion = true;
|
||||
f.tick(false);
|
||||
assert.equal(f.sets[5].radius, 0, 'reduced motion rests the sweep');
|
||||
assert.equal(f.sets[5].floor, 0.5 + 0.5 * 0.46, 'at rest it lifts');
|
||||
clock += 1000;
|
||||
f.tick(true);
|
||||
f.tick(false);
|
||||
assert.equal(f.sets.length, 5, 'at rest only changes set it');
|
||||
f.root.dataset.cyberSonarOpacity = '50';
|
||||
f.tick(false);
|
||||
assert.equal(f.sets.length, 6);
|
||||
assert.equal(f.sets[5].floor, 0.5 + 0.5 * 0.46);
|
||||
assert.equal(f.sets.length, 6, 'at rest only changes set it');
|
||||
f.state.reducedMotion = false;
|
||||
f.state.cockpit = true;
|
||||
f.tick(false);
|
||||
assert.equal(f.sets[6], null, 'out of the map theme it clears');
|
||||
assert.equal(f.sets[6], null, 'out of the map it clears');
|
||||
f.tick(true);
|
||||
assert.equal(f.sets.length, 7, 'cleared once');
|
||||
f.state.cockpit = false;
|
||||
f.root.dataset.cyberSonar = 'off';
|
||||
f.tick(false);
|
||||
assert.equal(f.sets.length, 7, 'Sonar OFF leaves contacts untreated');
|
||||
f.root.dataset.cyberSonar = 'on';
|
||||
f.state.reducedMotion = true;
|
||||
f.tick(false);
|
||||
assert.equal(f.sets[7].radius, 0, 'reduced motion rests the sweep');
|
||||
f.state.reducedMotion = false;
|
||||
f.root.dataset.uiTheme = 'tactical';
|
||||
assert.ok(f.sets[7]?.radius > 0, 'Sonar ON sweeps at once');
|
||||
f.root.dataset.cyberSonar = 'off';
|
||||
f.tick(false);
|
||||
assert.equal(f.sets[8], null, 'another HUD style clears it');
|
||||
assert.equal(f.sets[8], null, 'Sonar OFF clears it');
|
||||
f.tick(true);
|
||||
assert.equal(f.sets.length, 9);
|
||||
// The removed Cyber theme attribute alone does nothing.
|
||||
f.root.dataset.uiTheme = 'cyber';
|
||||
f.tick(false);
|
||||
assert.ok(f.sets[9]?.radius > 0, 'back in Cyber it sweeps at once');
|
||||
assert.equal(f.sets.length, 9);
|
||||
f.root.dataset.cyberSonar = 'on';
|
||||
f.tick(false);
|
||||
assert.ok(f.sets[9]?.radius > 0, 'back on, it sweeps at once');
|
||||
assert.deepEqual(f.requests, [], 'the scene itself never asks for frames');
|
||||
dispose();
|
||||
assert.equal(f.sets[10], null, 'disposal clears it');
|
||||
|
||||
@@ -32,7 +32,12 @@ import aisLiveVesselsLayer from './aisLiveVessels.js';
|
||||
import { registerEntityContext, selectEntityContext } from './contextStore.js';
|
||||
import { WORLD_FOCUS_REQUEST_EVENT } from '../worldFocus.js';
|
||||
import { ensureGeoidReady, geoidHeight } from './geoid.js';
|
||||
import { registerPickOwner, unregisterPickOwner } from './pickRegistry.js';
|
||||
import {
|
||||
isUnderOtherCard,
|
||||
registerPickOwner,
|
||||
setClickCardHitTest,
|
||||
unregisterPickOwner,
|
||||
} from './pickRegistry.js';
|
||||
import { applyVesselOverlayPolicy } from './vesselLabels.js';
|
||||
import { fakeInput } from '../input/testDoubles.mjs';
|
||||
import { layerFeedState } from './manager.js';
|
||||
@@ -490,7 +495,7 @@ test('first accepted position ends grace and warm data survives later open silen
|
||||
const clock = makeFakeAisRuntime(7000);
|
||||
const record = makeRecord();
|
||||
_setAisRuntimeForTest(clock.runtime);
|
||||
_setVesselOverlayHostForTest({
|
||||
useVesselHost({
|
||||
setEntries() {},
|
||||
setVisible() {},
|
||||
clearSource() {},
|
||||
@@ -540,7 +545,7 @@ test('first accepted position ends grace and warm data survives later open silen
|
||||
assert.equal(feed.error, 'awaiting usable AIS positions…');
|
||||
} finally {
|
||||
_setVesselStateForTest({ enabled: false });
|
||||
_setVesselOverlayHostForTest();
|
||||
useVesselHost();
|
||||
_setAisRuntimeForTest();
|
||||
}
|
||||
});
|
||||
@@ -1012,7 +1017,12 @@ function makeCesiumEvent() {
|
||||
};
|
||||
}
|
||||
|
||||
function installWireHarness(picked, stateOverrides = {}) {
|
||||
function installWireHarness(
|
||||
picked,
|
||||
stateOverrides = {},
|
||||
sceneExtras = {},
|
||||
firstClick = null,
|
||||
) {
|
||||
const hadWindow = Object.hasOwn(globalThis, 'window');
|
||||
const hadDocument = Object.hasOwn(globalThis, 'document');
|
||||
const priorWindow = globalThis.window;
|
||||
@@ -1038,9 +1048,11 @@ function installWireHarness(picked, stateOverrides = {}) {
|
||||
},
|
||||
};
|
||||
const viewer = {
|
||||
scene: { pick: () => picked },
|
||||
scene: { pick: () => picked, ...sceneExtras },
|
||||
};
|
||||
const input = fakeInput(viewer);
|
||||
// A subscriber that runs before the layer's own (an aircraft layer).
|
||||
if (firstClick) input.input.onClick(firstClick);
|
||||
// The camera port other layers follow through, with no pose to read; its
|
||||
// followChanged event counts who listens.
|
||||
const followChanged = makeCesiumEvent();
|
||||
@@ -1666,7 +1678,7 @@ test('vessel host publication preserves the shipped grid winner and separation s
|
||||
},
|
||||
},
|
||||
});
|
||||
_setVesselOverlayHostForTest({
|
||||
useVesselHost({
|
||||
setEntries(sourceId, entries, options) {
|
||||
publications.push({ sourceId, entries, options });
|
||||
},
|
||||
@@ -1690,7 +1702,7 @@ test('vessel host publication preserves the shipped grid winner and separation s
|
||||
} finally {
|
||||
unbind();
|
||||
_setVesselStateForTest({ enabled: false });
|
||||
_setVesselOverlayHostForTest();
|
||||
useVesselHost();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1717,7 +1729,7 @@ test('vessel real layer lifecycle publishes protected selection and leaves no st
|
||||
globalThis.window.addEventListener('gev:world-request-focus', (event) => {
|
||||
focusRequests.push(event.detail);
|
||||
});
|
||||
_setVesselOverlayHostForTest(host);
|
||||
useVesselHost(host);
|
||||
_setVesselStateForTest({
|
||||
viewer: {
|
||||
get canvas() {
|
||||
@@ -1766,7 +1778,7 @@ test('vessel real layer lifecycle publishes protected selection and leaves no st
|
||||
);
|
||||
} finally {
|
||||
_setVesselStateForTest({ enabled: false });
|
||||
_setVesselOverlayHostForTest();
|
||||
useVesselHost();
|
||||
if (hadWindow) globalThis.window = priorWindow;
|
||||
else delete globalThis.window;
|
||||
globalThis.document = priorDocument;
|
||||
@@ -1872,17 +1884,31 @@ test('vessel interaction wire: a vessel with an id and no MMSI is selected by cl
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Hand the vessel layer an overlay host, and answer the pick registry's
|
||||
* card-on-top question from the same host, as the application does.
|
||||
*/
|
||||
function useVesselHost(host) {
|
||||
_setVesselOverlayHostForTest(host);
|
||||
setClickCardHitTest(host ? (x, y) => host.hitTest(x, y) : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overlay-host recorder whose hitTest answers with one card id. The real host
|
||||
* only publishes rects for `interactive` entries, so a stub returning a hit is
|
||||
* the same contract a painted, actionable card presents.
|
||||
*/
|
||||
function hostWithCardHit(entryId) {
|
||||
function hostWithCardHit(entryId, topHit) {
|
||||
return {
|
||||
setEntries() {},
|
||||
setVisible() {},
|
||||
clearSource() {},
|
||||
hitTest: () => (entryId ? { sourceId: 'ais-live-vessels', entryId } : null),
|
||||
hitTest: (_x, _y, { sourceId } = {}) =>
|
||||
!sourceId && topHit
|
||||
? topHit
|
||||
: entryId
|
||||
? { sourceId: 'ais-live-vessels', entryId }
|
||||
: null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1898,9 +1924,7 @@ test('vessel interaction wire: clicking a card selects and transfers, like the s
|
||||
harness.windowTarget.addEventListener(WORLD_FOCUS_REQUEST_EVENT, (event) =>
|
||||
requests.push(event.detail),
|
||||
);
|
||||
_setVesselOverlayHostForTest(
|
||||
hostWithCardHit(`vessel:${harness.record.mmsi}`),
|
||||
);
|
||||
useVesselHost(hostWithCardHit(`vessel:${harness.record.mmsi}`));
|
||||
try {
|
||||
harness.handler.click({ position: { x: 10, y: 20 } });
|
||||
assert.equal(
|
||||
@@ -1911,7 +1935,7 @@ test('vessel interaction wire: clicking a card selects and transfers, like the s
|
||||
assert.equal(requests[0].kind, 'vessel');
|
||||
assert.equal(requests[0].id, harness.record.mmsi);
|
||||
} finally {
|
||||
_setVesselOverlayHostForTest(null);
|
||||
useVesselHost(null);
|
||||
harness.cleanup();
|
||||
}
|
||||
});
|
||||
@@ -1926,9 +1950,7 @@ test('vessel interaction wire: clicking the selected vessel card refocuses exact
|
||||
harness.windowTarget.addEventListener(WORLD_FOCUS_REQUEST_EVENT, (event) =>
|
||||
requests.push(event.detail),
|
||||
);
|
||||
_setVesselOverlayHostForTest(
|
||||
hostWithCardHit(`vessel:${harness.record.mmsi}`),
|
||||
);
|
||||
useVesselHost(hostWithCardHit(`vessel:${harness.record.mmsi}`));
|
||||
try {
|
||||
harness.handler.click({ position: { x: 10, y: 20 } });
|
||||
assert.equal(
|
||||
@@ -1939,11 +1961,36 @@ test('vessel interaction wire: clicking the selected vessel card refocuses exact
|
||||
assert.equal(requests[0].id, harness.record.mmsi);
|
||||
assert.equal(harness.trail.clearCalls, 0);
|
||||
} finally {
|
||||
_setVesselOverlayHostForTest(null);
|
||||
useVesselHost(null);
|
||||
harness.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
// Another layer's card on top takes the click from the vessel card under it
|
||||
// and from a vessel icon under it alike.
|
||||
test('vessel interaction wire: a covered card and a covered vessel pick both yield', () => {
|
||||
for (const ownPick of [false, true]) {
|
||||
const harness = installWireHarness(ownPick ? { id: makeRecord().mmsi } : null);
|
||||
const requests = [];
|
||||
harness.windowTarget.addEventListener(WORLD_FOCUS_REQUEST_EVENT, (event) =>
|
||||
requests.push(event.detail),
|
||||
);
|
||||
useVesselHost(
|
||||
hostWithCardHit(`vessel:${harness.record.mmsi}`, {
|
||||
sourceId: 'earthquakes', entryId: 'quake:cover',
|
||||
}),
|
||||
);
|
||||
try {
|
||||
harness.handler.click({ position: { x: 10, y: 20 } });
|
||||
assert.equal(requests.length, 0, `own pick: ${ownPick}`);
|
||||
assert.equal(aisLiveVesselsLayer.getSelectedInfo()?.mmsi, harness.record.mmsi);
|
||||
} finally {
|
||||
useVesselHost(null);
|
||||
harness.cleanup();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('vessel interaction wire: an unknown card id preserves selection and never flies', () => {
|
||||
const harness = installWireHarness({
|
||||
primitive: {},
|
||||
@@ -1955,7 +2002,7 @@ test('vessel interaction wire: an unknown card id preserves selection and never
|
||||
requests.push(event.detail),
|
||||
);
|
||||
// An evicted vessel's card id resolves to no live record.
|
||||
_setVesselOverlayHostForTest(hostWithCardHit('vessel:999999999'));
|
||||
useVesselHost(hostWithCardHit('vessel:999999999'));
|
||||
try {
|
||||
harness.handler.click({ position: { x: 10, y: 20 } });
|
||||
assert.equal(
|
||||
@@ -1964,37 +2011,135 @@ test('vessel interaction wire: an unknown card id preserves selection and never
|
||||
);
|
||||
assert.equal(requests.length, 0);
|
||||
} finally {
|
||||
_setVesselOverlayHostForTest(null);
|
||||
useVesselHost(null);
|
||||
harness.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test('vessel interaction wire: a sibling-owned pick wins without selection mutation', () => {
|
||||
// Another layer is already acting on this click; two camera commands is the
|
||||
// worse failure, so the card is not consulted.
|
||||
test('vessel interaction wire: the vessel card on top wins over a sibling-owned pick', () => {
|
||||
// The card painted on top takes the click; the sibling (an aircraft)
|
||||
// stands aside under it, so there is one camera command, not two.
|
||||
registerPickOwner('flights', (pickedId) => pickedId === 'a1b2c3');
|
||||
const harness = installWireHarness({ id: 'a1b2c3' });
|
||||
const requests = [];
|
||||
harness.windowTarget.addEventListener(WORLD_FOCUS_REQUEST_EVENT, (event) =>
|
||||
requests.push(event.detail),
|
||||
);
|
||||
_setVesselOverlayHostForTest(
|
||||
hostWithCardHit(`vessel:${harness.record.mmsi}`),
|
||||
);
|
||||
useVesselHost(hostWithCardHit(`vessel:${harness.record.mmsi}`));
|
||||
try {
|
||||
harness.handler.click({ position: { x: 10, y: 20 } });
|
||||
assert.equal(
|
||||
aisLiveVesselsLayer.getSelectedInfo()?.mmsi,
|
||||
harness.record.mmsi,
|
||||
);
|
||||
assert.equal(requests.length, 0);
|
||||
assert.equal(requests.length, 1);
|
||||
} finally {
|
||||
_setVesselOverlayHostForTest(null);
|
||||
useVesselHost(null);
|
||||
harness.cleanup();
|
||||
unregisterPickOwner('flights');
|
||||
}
|
||||
});
|
||||
|
||||
// The aircraft layer runs first. Under the vessel's card it stands aside, so
|
||||
// the card takes the click: one action.
|
||||
test('vessel interaction wire: a card over an aircraft takes the click; the aircraft does not track', (t) => {
|
||||
let tracked = null;
|
||||
registerPickOwner('test-planes', (pickedId) => pickedId === 'plane:9');
|
||||
t.after(() => unregisterPickOwner('test-planes'));
|
||||
const harness = installWireHarness(
|
||||
{ id: 'plane:9' },
|
||||
{ selectedRecord: null },
|
||||
{},
|
||||
(event) => {
|
||||
if (isUnderOtherCard(event)) return;
|
||||
if (event.hit?.id === 'plane:9') tracked = 'plane:9';
|
||||
},
|
||||
);
|
||||
const requests = [];
|
||||
harness.windowTarget.addEventListener(WORLD_FOCUS_REQUEST_EVENT, (event) =>
|
||||
requests.push(event.detail),
|
||||
);
|
||||
useVesselHost(hostWithCardHit(`vessel:${harness.record.mmsi}`));
|
||||
try {
|
||||
harness.handler.click({ position: { x: 10, y: 20 } });
|
||||
assert.equal(tracked, null, 'the aircraft does not track');
|
||||
assert.equal(requests.length, 1, 'the vessel card acts');
|
||||
assert.equal(
|
||||
aisLiveVesselsLayer.getSelectedInfo()?.mmsi,
|
||||
harness.record.mmsi,
|
||||
);
|
||||
} finally {
|
||||
useVesselHost(null);
|
||||
harness.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
// A trail acts for nobody: the vessel's card painted over it still selects,
|
||||
// and a bare trail pick stays a no-op that keeps the selection.
|
||||
test('vessel interaction wire: a card over a trail selects; a bare trail is a no-op', () => {
|
||||
for (const carded of [true, false]) {
|
||||
const harness = installWireHarness(
|
||||
{ id: 'gev-trail:fl-a1b2c3:head' },
|
||||
{ selectedRecord: null },
|
||||
);
|
||||
const requests = [];
|
||||
harness.windowTarget.addEventListener(WORLD_FOCUS_REQUEST_EVENT, (event) =>
|
||||
requests.push(event.detail),
|
||||
);
|
||||
useVesselHost(
|
||||
hostWithCardHit(carded ? `vessel:${harness.record.mmsi}` : null),
|
||||
);
|
||||
try {
|
||||
harness.handler.click({ position: { x: 10, y: 20 } });
|
||||
assert.equal(requests.length, carded ? 1 : 0, `card: ${carded}`);
|
||||
assert.equal(
|
||||
aisLiveVesselsLayer.getSelectedInfo()?.mmsi ?? null,
|
||||
carded ? harness.record.mmsi : null,
|
||||
);
|
||||
} finally {
|
||||
useVesselHost(null);
|
||||
harness.cleanup();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// A coarse tap on the vessel's card over a fire, nearby or exact: the card on
|
||||
// top keeps the tap.
|
||||
test('vessel interaction wire: the card keeps a tap over a nearby or exact fire', (t) => {
|
||||
const previous = globalThis.matchMedia;
|
||||
globalThis.matchMedia = () => ({ matches: true });
|
||||
t.after(() => {
|
||||
if (previous) globalThis.matchMedia = previous;
|
||||
else delete globalThis.matchMedia;
|
||||
});
|
||||
const fire = 'fire:near-miss';
|
||||
registerPickOwner('test-exact-fires', (pickedId) => pickedId === fire);
|
||||
t.after(() => unregisterPickOwner('test-exact-fires'));
|
||||
for (const exact of [false, true]) {
|
||||
const harness = installWireHarness(
|
||||
exact ? { id: fire } : null,
|
||||
{ selectedRecord: null },
|
||||
{ drillPick: () => [{ id: fire }] },
|
||||
);
|
||||
const requests = [];
|
||||
harness.windowTarget.addEventListener(WORLD_FOCUS_REQUEST_EVENT, (event) =>
|
||||
requests.push(event.detail),
|
||||
);
|
||||
useVesselHost(hostWithCardHit(`vessel:${harness.record.mmsi}`));
|
||||
try {
|
||||
harness.handler.click({ position: { x: 10, y: 20 } });
|
||||
assert.equal(requests.length, 1, `exact fire: ${exact}`);
|
||||
assert.equal(
|
||||
aisLiveVesselsLayer.getSelectedInfo()?.mmsi,
|
||||
harness.record.mmsi,
|
||||
);
|
||||
} finally {
|
||||
useVesselHost(null);
|
||||
harness.cleanup();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
for (const card of ['live', 'stale', 'absent', 'covered']) {
|
||||
test(`vessel interaction wire: ${card} foreground card over registered cyclone`, () => {
|
||||
const id = 'cyclone:fixture:cone:0';
|
||||
@@ -2020,7 +2165,7 @@ for (const card of ['live', 'stale', 'absent', 'covered']) {
|
||||
);
|
||||
return { sourceId: 'cctv', entryId: 'vessel:999999999' };
|
||||
};
|
||||
_setVesselOverlayHostForTest(host);
|
||||
useVesselHost(host);
|
||||
try {
|
||||
harness.handler.click({ position: { x: 10, y: 20 } });
|
||||
assert.equal(
|
||||
@@ -2029,7 +2174,7 @@ for (const card of ['live', 'stale', 'absent', 'covered']) {
|
||||
);
|
||||
assert.equal(requests.length, card === 'live' ? 1 : 0);
|
||||
} finally {
|
||||
_setVesselOverlayHostForTest(null);
|
||||
useVesselHost(null);
|
||||
harness.cleanup();
|
||||
unregisterPickOwner('weather-cyclones');
|
||||
}
|
||||
|
||||
@@ -2959,11 +2959,12 @@ export function createBhoteKoshiEventLayer({
|
||||
: Number.isFinite(clientY) && bounds
|
||||
? clientY - bounds.top
|
||||
: Number.NaN;
|
||||
const hit = overlayHost.hitTest?.(x, y, {
|
||||
sourceId: BHOTE_KOSHI_OVERLAY_SOURCE_ID,
|
||||
filter: (entry) => String(entry?.id || '').startsWith('evidence-card-'),
|
||||
});
|
||||
if (typeof hit?.entry?.activate !== 'function') return;
|
||||
// Only the card painted on top acts: an evidence card covered by
|
||||
// another layer's card or label leaves the click to that card.
|
||||
const hit = overlayHost.hitTest?.(x, y);
|
||||
if (hit?.sourceId !== BHOTE_KOSHI_OVERLAY_SOURCE_ID) return;
|
||||
if (!String(hit.entry?.id || '').startsWith('evidence-card-')) return;
|
||||
if (typeof hit.entry.activate !== 'function') return;
|
||||
hit.entry.activate();
|
||||
}
|
||||
|
||||
|
||||
@@ -2114,6 +2114,7 @@ test('Debris-Dammed Lake card opens its source and is armed for approved local v
|
||||
};
|
||||
const viewer = eventViewer();
|
||||
let activeCard = null;
|
||||
let coveredBy = null;
|
||||
const layer = createBhoteKoshiEventLayer({
|
||||
eventLoader: async () => event,
|
||||
imagerySpecFactory: async (url) => ({ url }),
|
||||
@@ -2131,9 +2132,11 @@ test('Debris-Dammed Lake card opens its source and is armed for approved local v
|
||||
},
|
||||
setVisible() {},
|
||||
clearSource() {},
|
||||
// As the host does: unfiltered, the topmost entry.
|
||||
hitTest(_x, _y, options) {
|
||||
if (coveredBy && !options?.sourceId) return coveredBy;
|
||||
if (!activeCard || options?.filter?.(activeCard) === false) return null;
|
||||
return { entry: activeCard };
|
||||
return { sourceId: 'bhote-koshi-witnesses', entry: activeCard };
|
||||
},
|
||||
},
|
||||
renderHost: { request() {}, hold() {}, release() {} },
|
||||
@@ -2160,6 +2163,11 @@ test('Debris-Dammed Lake card opens its source and is armed for approved local v
|
||||
} finally {
|
||||
releasePointer(lease);
|
||||
}
|
||||
// Another layer's card painted over the evidence card takes the click.
|
||||
coveredBy = { sourceId: 'earthquake-card', entryId: 'earthquake-card:q' };
|
||||
viewer._test.canvas.dispatch('click', { offsetX: 640, offsetY: 420 });
|
||||
assert.equal(opened.length, 0, 'a covered evidence card does not open');
|
||||
coveredBy = null;
|
||||
viewer._test.canvas.dispatch('click', { offsetX: 640, offsetY: 420 });
|
||||
assert.deepEqual(opened, [[
|
||||
event.evidenceSpine[1].media.sourceUrl,
|
||||
|
||||
@@ -2,6 +2,9 @@ import {
|
||||
clearOverlaySource,
|
||||
setOverlayEntries,
|
||||
} from '../overlays/worldOverlay.js';
|
||||
import { inputFor } from '../input/dispatcher.js';
|
||||
import { clickCard } from './pickRegistry.js';
|
||||
import { isTrackingSelectionGesture } from './trackingClickGesture.js';
|
||||
import { governorRequestRender } from '../renderGovernor.js';
|
||||
import { drawOf, findCamera } from '../render/rendererOf.js';
|
||||
import { hexColor } from '../render/color.js';
|
||||
@@ -279,8 +282,11 @@ export function createBhoteKoshiLocatorLayer({
|
||||
cancelFrame = (handle) => cancelAnimationFrame(handle),
|
||||
scheduleDelay = (callback, delayMs) => setTimeout(callback, delayMs),
|
||||
cancelDelay = (handle) => clearTimeout(handle),
|
||||
input = inputFor,
|
||||
} = {}) {
|
||||
let _viewer = null;
|
||||
// The globe click that opens an actionable callout of ours on top.
|
||||
let _removeClick = null;
|
||||
const _serial = ++layerSerial;
|
||||
// Whether the layer draws: from enable until it is let go.
|
||||
let _drawing = false;
|
||||
@@ -1107,6 +1113,7 @@ export function createBhoteKoshiLocatorLayer({
|
||||
renderPresentation();
|
||||
registerDynamicCredit(viewer, BHOTE_KOSHI_LOCATOR_CREDIT);
|
||||
showOsmCredit(viewer, BHOTE_KOSHI_LOCATOR_LAYER_ID);
|
||||
installCalloutClick(viewer);
|
||||
requestRender('bhote-koshi-locator-callout');
|
||||
|
||||
try {
|
||||
@@ -1141,8 +1148,34 @@ export function createBhoteKoshiLocatorLayer({
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An actionable callout of ours (the trigger record's) is a card painted
|
||||
* over the globe: a click on it opens its source, as its keyboard action
|
||||
* does. Like the other cards, it leaves a drag alone and, on top, takes the
|
||||
* click over whatever is drawn under it.
|
||||
*/
|
||||
function installCalloutClick(viewer) {
|
||||
if (_removeClick) return;
|
||||
let clicks = null;
|
||||
try {
|
||||
clicks = input?.(viewer) ?? null;
|
||||
} catch {
|
||||
clicks = null;
|
||||
}
|
||||
_removeClick =
|
||||
clicks?.onClick?.((event) => {
|
||||
if (!_enabled || !isTrackingSelectionGesture(event.gesture)) return;
|
||||
// The card painted on top, read once per click so every layer agrees.
|
||||
const top = clickCard(event);
|
||||
if (top?.sourceId !== BHOTE_KOSHI_LOCATOR_OVERLAY_SOURCE_ID) return;
|
||||
if (typeof top.entry?.activate === 'function') top.entry.activate();
|
||||
}) ?? null;
|
||||
}
|
||||
|
||||
async function disable() {
|
||||
hideOsmCredit(_viewer, BHOTE_KOSHI_LOCATOR_LAYER_ID);
|
||||
_removeClick?.();
|
||||
_removeClick = null;
|
||||
_enabled = false;
|
||||
_boundaryReady = false;
|
||||
_boundaryResolved = false;
|
||||
|
||||
@@ -11,6 +11,11 @@ import {
|
||||
import { BHOTE_KOSHI_FLOOD_PATH } from './bhoteKoshiFloodPath.js';
|
||||
import * as Cesium from 'cesium';
|
||||
import { setLocale } from '../i18n/index.js';
|
||||
import {
|
||||
registerPickOwner,
|
||||
setClickCardHitTest,
|
||||
unregisterPickOwner,
|
||||
} from './pickRegistry.js';
|
||||
import { SceneDirector } from '../scenes/director.js';
|
||||
import { createPlaybackClock } from '../director/clock.js';
|
||||
import { createDefaultScenePacks } from '../scenes/packs/defaults.js';
|
||||
@@ -1049,3 +1054,74 @@ test('Bhote Koshi locator layers draw sets of their own, and halos only as they
|
||||
assert.equal(await second.disable(), true);
|
||||
assert.equal(viewer._test.live().length, 0);
|
||||
});
|
||||
|
||||
// The trigger record's callout is an actionable card: the layers under it
|
||||
// stand aside for it, so a click on it opens its source, as its keyboard
|
||||
// action does; anything else on top is left alone.
|
||||
test('a click on the locator callout runs its action', async () => {
|
||||
const viewer = viewerFixture();
|
||||
let onClick = null;
|
||||
let top = null;
|
||||
const activated = [];
|
||||
const layer = createBhoteKoshiLocatorLayer({
|
||||
overlayHost: overlayHostFixture(),
|
||||
requestRender() {},
|
||||
...nonRunningAnimation(),
|
||||
input: () => ({
|
||||
onClick(callback) {
|
||||
onClick = callback;
|
||||
return () => {
|
||||
onClick = null;
|
||||
};
|
||||
},
|
||||
}),
|
||||
});
|
||||
// The card on top at a click, as the host answers the pick registry.
|
||||
setClickCardHitTest(() => top);
|
||||
await layer.init(viewer);
|
||||
await layer.enable(viewer);
|
||||
const click = (extra = {}) =>
|
||||
onClick?.({
|
||||
screenPosition: { x: 5, y: 5 },
|
||||
gesture: { travelPx: 0, durationMs: 80 },
|
||||
topHit: null,
|
||||
hit: null,
|
||||
...extra,
|
||||
});
|
||||
top = {
|
||||
sourceId: BHOTE_KOSHI_LOCATOR_OVERLAY_SOURCE_ID,
|
||||
entryId: 'bhote-koshi-trigger-record-callout',
|
||||
entry: { activate: () => activated.push('trigger') },
|
||||
};
|
||||
click();
|
||||
assert.deepEqual(activated, ['trigger']);
|
||||
top = {
|
||||
sourceId: 'earthquake-card',
|
||||
entry: { activate: () => activated.push('other') },
|
||||
};
|
||||
click();
|
||||
assert.deepEqual(activated, ['trigger'], 'another layer on top is its own');
|
||||
// A drag that ends on it is not a click on it.
|
||||
top = {
|
||||
sourceId: BHOTE_KOSHI_LOCATOR_OVERLAY_SOURCE_ID,
|
||||
entry: { activate: () => activated.push('trigger') },
|
||||
};
|
||||
click({ gesture: { travelPx: 30, durationMs: 80 } });
|
||||
assert.deepEqual(activated, ['trigger'], 'a drag does not open it');
|
||||
// On top, it takes the click over an aircraft or a camera under it, exact
|
||||
// or a touch contact: those layers stand aside under a card.
|
||||
registerPickOwner('test-planes', (id) => id === 'plane:1');
|
||||
try {
|
||||
const plane = { set: 'planes:1', id: 'plane:1' };
|
||||
const cam = { set: 'cams:1', id: 'cam:1' };
|
||||
click({ topHit: plane, hit: plane });
|
||||
click({ topHit: null, hit: plane });
|
||||
click({ topHit: cam, hit: cam });
|
||||
assert.equal(activated.length, 4, 'the callout on top acts each time');
|
||||
} finally {
|
||||
unregisterPickOwner('test-planes');
|
||||
setClickCardHitTest(null);
|
||||
}
|
||||
await layer.disable();
|
||||
assert.equal(onClick, null, 'disable removes the click handler');
|
||||
});
|
||||
+4
-11
@@ -1020,11 +1020,7 @@ test('CCTV repeated in-world clicks dispatch focus only for the one real activat
|
||||
);
|
||||
assert.match(
|
||||
componentFunctionSource(cctvLayer.init),
|
||||
/_cctvOverlayHost\.hitTest/,
|
||||
);
|
||||
assert.match(
|
||||
componentFunctionSource(cctvLayer.init),
|
||||
/sourceId: CCTV_OVERLAY_SOURCE_ID/,
|
||||
/clickCard\?\.\(event\)/,
|
||||
);
|
||||
assert.match(
|
||||
componentFunctionSource(cctvLayer.init),
|
||||
@@ -1032,7 +1028,7 @@ test('CCTV repeated in-world clicks dispatch focus only for the one real activat
|
||||
);
|
||||
assert.match(
|
||||
componentFunctionSource(cctvLayer.init),
|
||||
/activateCctvCameraFromWorldClick\(cardId, setActiveCamera\)/,
|
||||
/activateCctvCameraFromWorldClick\(\s*top\.entryId,/,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1157,11 +1153,8 @@ test('CCTV empty-click gate excludes every identified scene object, ADJUST, and
|
||||
);
|
||||
|
||||
const initSource = componentFunctionSource(cctvLayer.init);
|
||||
assert.ok(
|
||||
initSource.indexOf('if (pickedId !== null) return') <
|
||||
initSource.indexOf('_cctvOverlayHost.hitTest'),
|
||||
'every identified sibling must win before an overlapping CCTV card hit test',
|
||||
);
|
||||
// The real init-bound click route, including identified-object barriers,
|
||||
// is exercised in layers/cctv/lifecycle.test.mjs.
|
||||
assert.match(initSource, /activeCameraId: _activeCameraId/);
|
||||
assert.match(initSource, /calibrationMode: _calibrationMode/);
|
||||
});
|
||||
|
||||
@@ -53,7 +53,7 @@ test('the echo bracket pulses outward from the contact bracket and fades', (t) =
|
||||
assert.ok(half.spreadPx > echo.spreadPx * 0.5);
|
||||
assert.ok(half.spreadPx < echo.spreadPx);
|
||||
assert.ok(half.band < STEPS && half.band >= 1);
|
||||
// The bracket's own dimming (keyhole fade, Cyber sonar sweep) carries
|
||||
// The bracket's own dimming (keyhole fade, sonar sweep) carries
|
||||
// over, and the echo is never drawn brighter than its bracket: a bracket
|
||||
// too dim for even one band draws no echo.
|
||||
assert.equal(at(arrival, 0.25).band, 2);
|
||||
|
||||
@@ -941,13 +941,13 @@ test('a Global Context echo bracket is drawn outside its contact bracket and dim
|
||||
}
|
||||
});
|
||||
|
||||
test('under the Cyber sonar sweep an echo is never brighter than its own bracket', () => {
|
||||
test('under the sonar sweep an echo is never brighter than its own bracket', () => {
|
||||
const env = installEnvironment();
|
||||
// The cyber theme with its HUD open turns the contact sonar on; its sweep
|
||||
// dims brackets it is not passing over.
|
||||
// Sonar on with its HUD open turns the contact sonar on; its sweep dims
|
||||
// brackets it is not passing over.
|
||||
env.document.documentElement = {
|
||||
// The lowest sweep floor, so dimmed brackets drop a whole alpha band.
|
||||
dataset: { uiTheme: 'cyber', cyberSonarOpacity: '35' },
|
||||
dataset: { cyberSonar: 'on', cyberSonarOpacity: '35' },
|
||||
style: { setProperty() {}, removeProperty() {} },
|
||||
};
|
||||
const hud = env.document.createElement('div');
|
||||
|
||||
@@ -28,6 +28,8 @@ import {
|
||||
createApplicationDirectionsLayer,
|
||||
} from './directions.js';
|
||||
import { GROUND_FLOOR_LIFT_M } from './groundFloor.js';
|
||||
import { isOwnedByOtherLayer, setClickCardHitTest } from './pickRegistry.js';
|
||||
import { fakeInput } from '../input/testDoubles.mjs';
|
||||
import { instructionFor } from './routeSteps.js';
|
||||
import { setLocale } from '../i18n/index.js';
|
||||
import {
|
||||
@@ -465,6 +467,65 @@ function ownershipFixture(t) {
|
||||
});
|
||||
}
|
||||
|
||||
// Directions owns its route, markers and steps while enabled: none of them
|
||||
// is empty space to other layers.
|
||||
test('enabled, directions owns its picks', (t) => {
|
||||
ownershipFixture(t);
|
||||
const viewer = {
|
||||
scene: {
|
||||
pick: () => null,
|
||||
canvas: { clientWidth: 100, clientHeight: 100 },
|
||||
},
|
||||
};
|
||||
const input = fakeInput(viewer);
|
||||
t.after(() => input.destroy());
|
||||
directionsLayer.enable(viewer);
|
||||
try {
|
||||
for (const id of [
|
||||
'directions:route',
|
||||
'directions:marker:a',
|
||||
'directions:step:3',
|
||||
])
|
||||
assert.equal(isOwnedByOtherLayer('earthquakes', id), true, id);
|
||||
} finally {
|
||||
directionsLayer.disable(viewer);
|
||||
}
|
||||
assert.equal(isOwnedByOtherLayer('earthquakes', 'directions:route'), false);
|
||||
});
|
||||
|
||||
// The card or label painted on top takes the click: directions does not even
|
||||
// pick under another layer's card, so no step is selected or cleared there.
|
||||
test("another layer's card over directions keeps the click", (t) => {
|
||||
ownershipFixture(t);
|
||||
let picks = 0;
|
||||
const viewer = {
|
||||
scene: {
|
||||
pick: () => {
|
||||
picks++;
|
||||
return null;
|
||||
},
|
||||
canvas: { clientWidth: 100, clientHeight: 100 },
|
||||
},
|
||||
};
|
||||
const input = fakeInput(viewer);
|
||||
let top = { sourceId: 'earthquake-card', entryId: 'earthquake-card:ak1' };
|
||||
setClickCardHitTest(() => top);
|
||||
t.after(() => {
|
||||
setClickCardHitTest(null);
|
||||
input.destroy();
|
||||
});
|
||||
directionsLayer.enable(viewer);
|
||||
try {
|
||||
input.tap({ x: 10, y: 10 });
|
||||
assert.equal(picks, 0, 'covered: the scene under the card is not picked');
|
||||
top = null;
|
||||
input.tap({ x: 10, y: 10 });
|
||||
assert.ok(picks > 0, 'open map: the click reaches the scene');
|
||||
} finally {
|
||||
directionsLayer.disable(viewer);
|
||||
}
|
||||
});
|
||||
|
||||
test('placing an endpoint takes the pointer, and every exit path gives it back', (t) => {
|
||||
ownershipFixture(t);
|
||||
|
||||
|
||||
Loaded 100 of 1195 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user