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

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
@@ -34,3 +34,42 @@ Source workspace manifests always stay private. `npm run check:release` builds p
34
34
  `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
35
 
36
36
  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.
37
+
38
+ ## Airport heroes and split-flap boards
39
+
40
+ `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.
41
+
42
+ ```tsx
43
+ import { AirportHeroCard } from '@motionstudies/web/components/AirportHeroCard'
44
+ import '@motionstudies/web/airport-hero-card.css'
45
+
46
+ <AirportHeroCard
47
+ key={airport.id}
48
+ airport={airport}
49
+ departures={departures}
50
+ arrivals={arrivals}
51
+ study={{ time, windowStart: metadata.windowStart, windowEnd: metadata.windowEnd }}
52
+ dateLabel={metadata.serviceDate}
53
+ note="Observed study · inferred directions; times are observations."
54
+ onSelectFlight={selectAirTrack}
55
+ selectedFlightId={selectedAirTrackId}
56
+ />
57
+ ```
58
+
59
+ 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.
60
+
61
+ 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.
62
+
63
+ 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`.
64
+
65
+ 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.
66
+
67
+ 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.
68
+
69
+ 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.
70
+
71
+ 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.
72
+
73
+ 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.
74
+
75
+ `@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.5",
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",