@motionstudies/core 0.1.0-alpha.4 → 0.1.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -25,6 +25,16 @@ Build release candidates with `npm run build:packages`. Distribution manifests a
25
25
 
26
26
  Source workspace manifests always stay private. `npm run check:release` builds public candidates, tests their packed consumer and records the tested tarball hashes; `npm run release:dry-run` inspects the publication without writing to npm. The manual main-branch `release.yml` workflow publishes those same tarballs with public access and provenance. See [release instructions](https://github.com/emmettl/motionstudies/blob/main/docs/RELEASING.md) for bootstrap-token and trusted-publisher setup. All four shared packages are MIT-licensed; each distribution includes `LICENSE`.
27
27
 
28
+ ## Now and browser location
29
+
30
+ `useNowClock` from `@motionstudies/web/use-now-clock` follows the wall clock on each animation frame, so returning from a suspended tab catches up immediately. Call `start()` from a Now button, set the consumer's playback rate to 1, and render its `time` while `active`. With `NationalNetworkScene`, pass `isPlaying={false}` while this external clock owns time. Call `stop()` before pausing, seeking or changing speed, and retain the last clock time for ordinary playback. Clear moving vehicle selections on entry to keep the camera still; panning and zooming remain available.
31
+
32
+ Supply a resolver `(instant: Date) => number | null` that maps the instant into the edition's service-time coordinates. The edition owns timezone, service date, daylight-saving rules and source coverage. Now is appropriate when the data gives a meaningful sense of this place at this time; exact live vehicle positions are not required. An edition may explicitly map the current local clock onto a suitable representative weekday or seasonal timetable, with a quiet label such as “Typical weekday · realtime pace”. Historical or modelled sources need that same meaningful relationship to the present; merely having timestamps is insufficient. Return null outside the chosen data's coverage: the hook stops, retains the last valid time and exposes `unavailable`. Do not silently relabel a recording as live or wrap a partial study window. Timetable and observed-data labels remain the consumer's responsibility; 1× playback does not imply a live vehicle feed.
33
+
34
+ `useBrowserLocation` from `@motionstudies/web/use-browser-location` requests a single position only when `locate()` is called. It exposes `location`, `status` and `clear()`; it neither stores nor sends coordinates. Render localized messages for denied, timeout and unavailable states. Clearing or unmounting discards late responses. A secure browser context and user permission are required.
35
+
36
+ Pass an in-coverage position as `NationalNetworkScene`'s `userLocation` for a steady glowing dot. Use the existing `focus-location` camera command once after locating, with `[longitude, latitude]` and a suitable `distanceScale`. Validate coverage in the consumer and preserve the view when the user is outside it. Show the reported `accuracy` in accessible text; the dot is an approximate position. The marker hides in diagram layouts. The lab's **Now** specimen uses a clearly labelled synthetic UTC timetable and covers clock, permission and out-of-coverage behavior. Public editions still require independent adoption and releases.
37
+
28
38
  ## Selection labels
29
39
 
30
40
  `NationalNetworkScene` gives the selected station first label priority, followed by the selected route's terminal stops (including branches), then intermediate stops. Selected services use their own endpoints. Priority precedes retained labels and ordinary rank/tier admission; clearing selection restores edition ranking. This is built in for every consumer, including geographic and diagram layouts. Supply complete enabled infrastructure as `referenceSnapshot` to preserve endpoints through timetable gaps; its stop indexes need not match the active snapshot. See the [edition behaviour contract](https://github.com/emmettl/motionstudies/blob/main/docs/EDITIONS.md#selection-and-station-labels).
@@ -34,3 +44,42 @@ Source workspace manifests always stay private. `npm run check:release` builds p
34
44
  `mountMotionStudy` installs one shared tooltip surface. Independent consumers such as the lab can render `ButtonTooltips` from `@motionstudies/web/components/ButtonTooltips` once instead. Put concise, action-oriented help in each button’s `data-tooltip`; icon buttons fall back to their `aria-label`. An empty `data-tooltip` opts out. Avoid native `title` attributes on these buttons, which can also appear during touch interaction.
35
45
 
36
46
  Help appears after a short mouse hover or on keyboard focus when the primary pointer is fine and supports hover. Touch input suppresses it, including on hybrid devices. Escape, activation, scrolling and blur dismiss it. The tooltip stays inside the viewport, can itself be hovered, and temporarily extends `aria-describedby` without replacing existing descriptions. Copy and translations stay in the edition; rendering and input handling stay in this package. The Controls specimen and packed-consumer tests exercise this contract.
47
+
48
+ ## Airport heroes and split-flap boards
49
+
50
+ `AirportHeroCard` provides an airport identity header and switchable departure/arrival boards. `SplitFlapBoard` is the underlying transport-neutral widget, also suitable for rail stations. Both use scoped package styles, semantic tables, full accessible cell values, keyboard-operable selection, contained horizontal scrolling and reduced-motion support. Only changed characters remount for the flap animation.
51
+
52
+ ```tsx
53
+ import { AirportHeroCard } from '@motionstudies/web/components/AirportHeroCard'
54
+ import '@motionstudies/web/airport-hero-card.css'
55
+
56
+ <AirportHeroCard
57
+ key={airport.id}
58
+ airport={airport}
59
+ departures={departures}
60
+ arrivals={arrivals}
61
+ study={{ time, windowStart: metadata.windowStart, windowEnd: metadata.windowEnd }}
62
+ dateLabel={metadata.serviceDate}
63
+ note="Observed study · inferred directions; times are observations."
64
+ onSelectFlight={selectAirTrack}
65
+ selectedFlightId={selectedAirTrackId}
66
+ />
67
+ ```
68
+
69
+ Entries have a stable `id`, a `service` label, and optional numeric `time`, `place`, `stand`, `status` and `tone` (`neutral`, `accent` or `warning`). Movement times and `study.time`, `windowStart`, and `windowEnd` must use the same study-relative seconds and service date. Do not parse display strings or normalize numeric times at midnight: an event after 24:00 retains its value above 86,400. `formatTime` optionally controls display formatting; the default uses the study's `formatServiceTime` helper. The header clock is derived directly from `study.time`, with no independent wall clock.
70
+
71
+ The card sorts movements chronologically and shows up to eight rows per direction inside the intersection of the study bounds and a rolling window: ten minutes behind the playback clock and sixty minutes ahead, with inclusive endpoints. Override this with `horizon={{ lookBehindSeconds: 600, lookAheadSeconds: 3600 }}` and `maxRows`. Playback, backward seeking, changed study bounds and updated movement times all recalculate the rows. An out-of-study or invalid clock shows no movements; rows with missing or non-finite times are excluded because they cannot be placed in the window. Other unknown fields render as a dash. Labels include `studyTime`, `boardWindow` and `outsideWindow` for localization. Filtering does not infer operational statuses or clear the consumer's map selection when a row leaves the window.
72
+
73
+ Consumers still own time coordinates, source interpretation and data loading. Supply movements for the displayed horizon, not just aircraft active at the current second, and use the selected study's bounds rather than an individual progressive chunk's bounds. Do not turn an approach-envelope association into a confirmed departure/arrival: unclassified tracks should remain outside these direction lists. Current `AirTrack` data does not supply scheduled times, routes or gates; leave those fields absent, use observation times only when clearly labelled, and explain any inference in the required `note`.
74
+
75
+ Pass `labels` for edition translations, `loading`, or a localized `error` and `onRetry` for data states. The selected direction is local to each card; key the card by airport ID to reset it on selection changes. The Airports lab specimen exercises synthetic timetables, playback, scrubbing, study-window changes, incomplete observations, French labels, long destinations, updates and recovery. Edition adoption happens through their independently pinned package releases; adding this export does not update deployed studies.
76
+
77
+ For a custom rail or transport board, import `SplitFlapBoard` from `@motionstudies/web/components/SplitFlapBoard` and `@motionstudies/web/split-flap-board.css`. Supply `columns` (`key`, `label`, `characters`) and `rows` (`id`, `cells`, optional `tone`). Cell text longer than its flap count is visually ellipsized, with the full value retained for assistive technology and hover. `onSelectRow`, `selectedRowId` and `selectionColumn` optionally make one cell per row selectable.
78
+
79
+ The shared board also accepts `loading`, a localized `loadingMessage`, and `loadingRows` (default five). While loading, its decorative rows cycle through staggered letters and digits; they are hidden from assistive technology and cannot be selected. A single status message announces loading. When data arrives, characters flip through a short sequence and settle into their actual values; later changes animate only the changed characters. These CSS animations have no JavaScript timers and stop looping when loading ends or the board is removed. Reduced-motion users get static blank loading flaps and immediate final text. `AirportHeroCard` uses this shared loading treatment automatically. Use **Reload board** in the Airports lab to preview the complete loading-to-ready transition.
80
+
81
+ Empty messages also appear on the flaps, in the widest column (the destination/origin column in airport cards), with the other columns blank. Longer localized messages wrap across display rows instead of being truncated. They settle with the same animation as flight details, and one hidden status announces the complete message to assistive technology. This also applies when the study clock moves into a window with no movements.
82
+
83
+ Rail and other transport consumers can share the same time filtering through `movementBoardWindow(study, horizon)` and `movementsForBoard(entries, window, maxRows)` from `@motionstudies/core/domain/movement-board`. Format the returned numeric times when mapping them into `SplitFlapBoard` cells. The lab's rail board follows the same study clock and horizon as its airport card.
84
+
85
+ `@motionstudies/data/air-endpoints` provides offline `enrichAirEndpoints` for existing air manifests, chunks and opening snapshots. Supply cached same-date global ADSB.lol heatmaps, an OurAirports CSV and the service date's local UTC offset. It associates only unambiguous low-altitude endpoints near a reference airport; cruise-only traces and uncertain routes stay unknown. Optional `AirEndpoint` origin/destination fields carry airport identity, observed boundary time and `observed-endpoint` evidence. `airportBoardMovements` maps full manifest entries to board rows without confusing playback chunk boundaries with flight endpoints. Input hashes and source/licence attribution are recorded in fixture metadata. These fields describe inferred observations, never flight schedules, gates or live status.
package/air-search.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { AirEndpoint } from './domain/air.ts';
1
2
  export interface AirSearchTrack {
2
3
  readonly id: string;
3
4
  readonly icaoAddress?: string;
@@ -5,6 +6,8 @@ export interface AirSearchTrack {
5
6
  readonly start: number;
6
7
  readonly end: number;
7
8
  readonly airportIds?: readonly string[];
9
+ readonly origin?: AirEndpoint;
10
+ readonly destination?: AirEndpoint;
8
11
  }
9
12
  export declare function airTrackSearchText(track: AirSearchTrack): string;
10
13
  export declare function airTrackSearchValue(track: AirSearchTrack): string;
@@ -1,4 +1,4 @@
1
- import type { AirSnapshot, AirTrack } from './air.ts';
1
+ import type { AirEndpoint, AirSnapshot, AirTrack } from './air.ts';
2
2
  export interface AirDayAircraft {
3
3
  readonly id: string;
4
4
  readonly icaoAddress: string;
@@ -6,6 +6,8 @@ export interface AirDayAircraft {
6
6
  readonly start: number;
7
7
  readonly end: number;
8
8
  readonly airportIds?: readonly string[];
9
+ readonly origin?: AirEndpoint;
10
+ readonly destination?: AirEndpoint;
9
11
  readonly chunkIds: readonly string[];
10
12
  }
11
13
  export interface AirDayChunkDescriptor {
package/domain/air.d.ts CHANGED
@@ -5,6 +5,15 @@ export type AirSample = readonly [
5
5
  altitudeFeet: number,
6
6
  groundSpeedKnots: number
7
7
  ];
8
+ export interface AirEndpoint {
9
+ readonly icao: string;
10
+ readonly iata: string;
11
+ readonly name: string;
12
+ readonly city: string;
13
+ /** Study-local seconds at the observed approach/departure boundary; not a scheduled time. */
14
+ readonly time: number;
15
+ readonly evidence: 'observed-endpoint';
16
+ }
8
17
  export interface AirTrack {
9
18
  readonly id: string;
10
19
  readonly icaoAddress?: string;
@@ -12,6 +21,8 @@ export interface AirTrack {
12
21
  readonly start: number;
13
22
  readonly end: number;
14
23
  readonly airportIds?: readonly string[];
24
+ readonly origin?: AirEndpoint;
25
+ readonly destination?: AirEndpoint;
15
26
  readonly samples: readonly AirSample[];
16
27
  }
17
28
  export interface AirSnapshot {
@@ -1,4 +1,5 @@
1
1
  import type { AirTrack } from './air.ts';
2
+ import type { AirSearchTrack } from '../air-search.ts';
2
3
  export interface StudyAirport {
3
4
  readonly id: string;
4
5
  readonly name: string;
@@ -15,3 +16,18 @@ export declare function airportSearchText(airport: StudyAirport): string;
15
16
  export declare function searchAirports(airports: readonly StudyAirport[], searchQuery: string, limit?: number): readonly StudyAirport[];
16
17
  export declare function airTrackServesAirport(track: AirTrack, airport: StudyAirport): boolean;
17
18
  export declare function airportAirTrackIds(tracks: readonly AirTrack[], airport: StudyAirport): ReadonlySet<string>;
19
+ /** Board events come from full-flight endpoint evidence, not truncated playback chunks. */
20
+ export declare function airportBoardMovements(aircraft: readonly AirSearchTrack[], airport: StudyAirport): {
21
+ departures: {
22
+ id: string;
23
+ time: number;
24
+ service: string;
25
+ place?: string;
26
+ }[];
27
+ arrivals: {
28
+ id: string;
29
+ time: number;
30
+ service: string;
31
+ place?: string;
32
+ }[];
33
+ };
package/domain/airport.js CHANGED
@@ -39,3 +39,26 @@ export function airportAirTrackIds(tracks, airport) {
39
39
  .filter((track) => airTrackServesAirport(track, airport))
40
40
  .map((track) => track.id));
41
41
  }
42
+ /** Board events come from full-flight endpoint evidence, not truncated playback chunks. */
43
+ export function airportBoardMovements(aircraft, airport) {
44
+ const departures = [];
45
+ const arrivals = [];
46
+ const seen = new Set();
47
+ for (const track of aircraft) {
48
+ for (const direction of ['origin', 'destination']) {
49
+ const endpoint = track[direction];
50
+ if (!endpoint || endpoint.icao !== airport.icao || !Number.isFinite(endpoint.time))
51
+ continue;
52
+ const key = `${track.icaoAddress ?? track.id}:${direction}:${endpoint.time}`;
53
+ if (seen.has(key))
54
+ continue;
55
+ seen.add(key);
56
+ const other = direction === 'origin' ? track.destination : track.origin;
57
+ const row = { id: track.id, time: endpoint.time, service: track.callsign,
58
+ place: other ? `${other.city || other.name} ${other.iata || other.icao}` : undefined };
59
+ const rows = direction === 'origin' ? departures : arrivals;
60
+ rows.push(row);
61
+ }
62
+ }
63
+ return { departures, arrivals };
64
+ }
@@ -0,0 +1,21 @@
1
+ /** All values use the study's time coordinate, in seconds (including times beyond midnight). */
2
+ export interface MovementBoardStudy {
3
+ readonly time: number;
4
+ readonly windowStart: number;
5
+ readonly windowEnd: number;
6
+ }
7
+ export interface MovementBoardHorizon {
8
+ readonly lookBehindSeconds?: number;
9
+ readonly lookAheadSeconds?: number;
10
+ }
11
+ export interface MovementBoardWindow {
12
+ readonly start: number;
13
+ readonly end: number;
14
+ }
15
+ /** Keep recent movements briefly, then show the next hour, clipped to the selected study. */
16
+ export declare function movementBoardWindow(study: MovementBoardStudy, { lookBehindSeconds, lookAheadSeconds }?: MovementBoardHorizon): MovementBoardWindow | undefined;
17
+ /** Unknown times cannot be placed in a time-windowed board. Never mutate the caller's rows. */
18
+ export declare function movementsForBoard<T extends {
19
+ readonly id: string;
20
+ readonly time?: number;
21
+ }>(movements: readonly T[], window: MovementBoardWindow | undefined, maxRows?: number): readonly T[];
@@ -0,0 +1,23 @@
1
+ /** Keep recent movements briefly, then show the next hour, clipped to the selected study. */
2
+ export function movementBoardWindow(study, { lookBehindSeconds = 600, lookAheadSeconds = 3600 } = {}) {
3
+ const { time, windowStart, windowEnd } = study;
4
+ if (![time, windowStart, windowEnd, lookBehindSeconds, lookAheadSeconds].every(Number.isFinite)
5
+ || windowStart > windowEnd || time < windowStart || time > windowEnd
6
+ || lookBehindSeconds < 0 || lookAheadSeconds < 0)
7
+ return undefined;
8
+ return {
9
+ start: Math.max(windowStart, time - lookBehindSeconds),
10
+ end: Math.min(windowEnd, time + lookAheadSeconds),
11
+ };
12
+ }
13
+ /** Unknown times cannot be placed in a time-windowed board. Never mutate the caller's rows. */
14
+ export function movementsForBoard(movements, window, maxRows = 8) {
15
+ if (!window || ![window.start, window.end, maxRows].every(Number.isFinite)
16
+ || window.start > window.end || maxRows < 1)
17
+ return [];
18
+ return movements
19
+ .filter((entry) => entry.time !== undefined && Number.isFinite(entry.time)
20
+ && entry.time >= window.start && entry.time <= window.end)
21
+ .sort((first, second) => first.time - second.time || (first.id < second.id ? -1 : first.id > second.id ? 1 : 0))
22
+ .slice(0, Math.floor(maxRows));
23
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@motionstudies/core",
3
- "version": "0.1.0-alpha.4",
3
+ "version": "0.1.0-alpha.6",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Transport contracts and motion primitives for Motion Studies.",
@@ -65,6 +65,11 @@
65
65
  "import": "./domain/airport.js",
66
66
  "default": "./domain/airport.js"
67
67
  },
68
+ "./domain/movement-board": {
69
+ "types": "./domain/movement-board.d.ts",
70
+ "import": "./domain/movement-board.js",
71
+ "default": "./domain/movement-board.js"
72
+ },
68
73
  "./domain/boundary": {
69
74
  "types": "./domain/boundary.d.ts",
70
75
  "import": "./domain/boundary.js",