astraeus 0.2.0 → 0.3.0

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.
Files changed (59) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +41 -5
  3. package/package.json +2 -1
  4. package/src/api/AstraeusScene.js +1 -1
  5. package/src/api/AstraeusScene.node.js +37 -0
  6. package/src/api/group.d.ts +7 -1
  7. package/src/api/index.d.ts +1 -0
  8. package/src/api/index.js +1 -0
  9. package/src/api/index.node.js +8 -0
  10. package/src/api/mount.js +3 -1
  11. package/src/api/mount.node.js +36 -0
  12. package/src/api/scene.d.ts +32 -6
  13. package/src/api/scene.js +123 -26
  14. package/src/api/story.d.ts +8 -2
  15. package/src/api/story.js +11 -0
  16. package/src/api/sunOrbit.d.ts +6 -0
  17. package/src/api/sunOrbit.js +24 -0
  18. package/src/app/App.d.ts +6 -2
  19. package/src/app/App.js +8 -4
  20. package/src/app/App.node.js +401 -0
  21. package/src/app/PanelLoadBoundary.d.ts +2 -1
  22. package/src/app/PanelLoadBoundary.js +2 -2
  23. package/src/app/SkyView.d.ts +3 -3
  24. package/src/app/SkyView.js +19 -10
  25. package/src/app/experienceDefinition.d.ts +8 -0
  26. package/src/app/sceneContentsHooks.js +2 -2
  27. package/src/app/sceneFrame.js +4 -3
  28. package/src/app/sceneFraming.d.ts +13 -0
  29. package/src/app/sceneFraming.js +22 -0
  30. package/src/app/skyModel.js +1 -1
  31. package/src/assets/pictures.d.ts +1 -1
  32. package/src/assets/sky.d.ts +4 -4
  33. package/src/assets/sky.js +12 -13
  34. package/src/core/bodies/io.js +1 -1
  35. package/src/core/bodies/jupiterData.js +2 -2
  36. package/src/core/bodies/jupiterMoons.js +8 -12
  37. package/src/core/bodies/moon.d.ts +8 -0
  38. package/src/core/bodies/moon.js +28 -5
  39. package/src/core/bodies/outerPlanetData.js +7 -7
  40. package/src/core/bodies/planetMoons.js +18 -27
  41. package/src/core/bodies/swiftTuttle.js +2 -0
  42. package/src/core/elementsBody.d.ts +2 -0
  43. package/src/core/elementsBody.js +3 -0
  44. package/src/core/moonTrajectory.js +3 -5
  45. package/src/core/planetModels.js +1 -1
  46. package/src/core/provenance.d.ts +6 -2
  47. package/src/core/provenance.js +3 -1
  48. package/src/shell/AstraeusShell.js +5 -3
  49. package/src/shell/AstraeusShell.node.js +225 -0
  50. package/src/shell/DisplaySwitches.js +1 -1
  51. package/src/shell/StoryPanelView.js +3 -1
  52. package/src/shell/TimelineBar.node.js +75 -0
  53. package/src/shell/TopBar.node.js +14 -0
  54. package/src/shell/experience.d.ts +2 -0
  55. package/src/shell/infoModel.js +3 -1
  56. package/src/shell/phone.css +1 -1
  57. package/src/shell/useDrawers.js +1 -1
  58. package/src/shell/useZoomThrough.d.ts +7 -0
  59. package/src/shell/useZoomThrough.js +51 -0
@@ -0,0 +1,225 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { lazy, Suspense, useEffect, useRef, useState } from "react";
3
+ import { StoryPanelView } from "./StoryPanelView.js";
4
+ import { useDrawers } from "./useDrawers.js";
5
+ import { useStoryPanels } from "./useStoryPanels.js";
6
+ import { TimelineBar } from "./TimelineBar.node.js";
7
+ import { InfoPanel } from "./InfoPanel.js";
8
+ import { infoView } from "./infoModel.js";
9
+ import { PanelLoadBoundary } from "../app/PanelLoadBoundary.js";
10
+ import { ControlsDrawer } from "./ControlsDrawer.js";
11
+ import { isEmbedded } from "./embedded.js";
12
+ import { DEFAULT_PHONE_LAYOUT, phoneLayoutStyle, pickOpensInfo, usePhone } from "./phoneLayout.js";
13
+ import { DeveloperToggle, TopBar } from "./TopBar.node.js";
14
+ import { availableObjectById, findCameraPreset, firstAvailableObject, focusPresetFor, isObjectAvailable } from "./objectModel.js";
15
+ /** Keeps `--timeline-space` at the distance from the screen's bottom to the top of the timeline bar, so a phone sheet can sit above it. */
16
+ function useTimelineSpace(root, phone) {
17
+ useEffect(() => {
18
+ const shell = root.current;
19
+ const bar = shell?.querySelector(".timeline-bar") ?? null;
20
+ if (shell === null || bar === null || typeof ResizeObserver === "undefined")
21
+ return undefined;
22
+ const measure = () => shell.style.setProperty("--timeline-space", `${Math.ceil(window.innerHeight - bar.getBoundingClientRect().top)}px`);
23
+ measure();
24
+ const observer = new ResizeObserver(measure);
25
+ observer.observe(bar);
26
+ window.addEventListener("resize", measure);
27
+ return () => { observer.disconnect(); window.removeEventListener("resize", measure); shell.style.removeProperty("--timeline-space"); };
28
+ }, [root, phone]);
29
+ }
30
+ /** The object selected when the shell opens: the first one available at the clock time, else the first listed. */
31
+ function initialObjectId(experience, timeUtcMs) {
32
+ const start = experience.cameraPresets.find((preset) => preset.id === experience.startCameraPresetId)?.request;
33
+ if (start !== undefined && start.kind !== "overview" && experience.objects.some((object) => object.id === start.target))
34
+ return start.target;
35
+ return firstAvailableObject(experience, timeUtcMs)?.id ?? experience.objects[0]?.id ?? "";
36
+ }
37
+ /** The story-panel settings the experience carries itself, used when the app gives none live. */
38
+ function ownStorySettings(storySet) {
39
+ return { autoOpen: storySet?.autoOpen ?? false, pauseSeconds: storySet?.pauseSeconds ?? 0 };
40
+ }
41
+ /** The timeline bar, or nothing when the experience says it has no timeline. */
42
+ function ShellTimeline({ hidden, ...bar }) {
43
+ return hidden ? null : _jsx(TimelineBar, { ...bar });
44
+ }
45
+ /** The wide-screen moons toggle and the sheet it opens under the toolbar. */
46
+ function MoonsSheet({ planetLabel, open, onToggle, onClose, children }) {
47
+ return (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: "moons-toggle ui-pill", "aria-expanded": open, "aria-controls": "moons-panel", onClick: onToggle, children: [planetLabel, " moons"] }), _jsx("aside", { id: "moons-panel", className: "moons-sheet", "data-open": open, "aria-label": "Moons by family", onKeyDown: (event) => { if (event.key === "Escape")
48
+ onClose(); }, children: children })] }));
49
+ }
50
+ /** The serial of a request that is asked again by sending a new one; absent request: undefined. */
51
+ function serialOf(request) {
52
+ return request?.serial;
53
+ }
54
+ function panelsOf(storySet) {
55
+ return storySet?.panels ?? [];
56
+ }
57
+ function objectLabelOr(experience, objectId, fallback) {
58
+ return experience.objects.find((object) => object.id === objectId)?.label ?? fallback;
59
+ }
60
+ /** The information panel's content and, for an object, its live measurements. */
61
+ function infoContent(experience, info, selectedObjectId, timeUtcMs, metricsFor) {
62
+ const view = info === null
63
+ ? null
64
+ : infoView(experience, info.kind === "object" ? { kind: "object", id: selectedObjectId } : info, timeUtcMs);
65
+ const metrics = view?.target.kind === "object" && metricsFor !== undefined ? metricsFor(view.target.id, timeUtcMs) : [];
66
+ return { view, metrics };
67
+ }
68
+ /** The moon families load on demand: only an experience with `moonFamilies` draws them (I-089). */
69
+ const MoonFamilyPanel = lazy(() => import("./MoonFamilyPanel.js").then((module) => ({ default: module.MoonFamilyPanel })));
70
+ /** Canvas-first layout shared by astronomy experiences. Scene and diagnostics stay app-owned. */
71
+ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloperModeChange, onTogglePlayback, onRateChange, onSeek, onCameraRequest, onSelectionChange, scaleId, onScaleChange, scaleChoices, switcher, displaySwitches, metricsFor, developerTools, storyPanelSettings, timelineGlow, phoneLayout = DEFAULT_PHONE_LAYOUT, highlightedFamily = null, onHighlightFamily, onSetPlaying, panelRequest, onOpenPanelChange, featureRequest, onOpenFeatureChange, pickRequest, children, }) {
72
+ const [selectedObjectId, setSelectedObjectId] = useState(() => initialObjectId(experience, snapshot.timeUtcMs));
73
+ const phone = usePhone();
74
+ /** Fixed for the page: a frame does not appear or vanish while the app runs. */
75
+ const [embedded] = useState(isEmbedded);
76
+ const root = useRef(null);
77
+ // The drawer (with the moons in it) and the bottom sheets want the same screen: the drawer, being the one just asked for, takes it.
78
+ const { controlsOpen, timelineOpen, openControls, openTimeline } = useDrawers(phone, () => {
79
+ if (experience.moonFamilies !== undefined) {
80
+ setInfo(null);
81
+ story.close();
82
+ }
83
+ });
84
+ useTimelineSpace(root, phone);
85
+ const [activePresetId, setActivePresetId] = useState(experience.startCameraPresetId ?? null);
86
+ /** The object panel follows the selected object; an event panel names its event. */
87
+ const [info, setInfo] = useState(null);
88
+ const storySet = experience.storyPanels;
89
+ const storyPanels = panelsOf(storySet);
90
+ const story = useStoryPanels(storyPanels, storyPanelSettings ?? ownStorySettings(storySet), snapshot, onSetPlaying);
91
+ const openPanelId = story.openPanel?.id ?? null;
92
+ useEffect(() => { onOpenPanelChange?.(openPanelId); }, [onOpenPanelChange, openPanelId]);
93
+ const requestedSerial = serialOf(panelRequest);
94
+ useEffect(() => {
95
+ if (panelRequest !== null && panelRequest !== undefined)
96
+ story.open(panelRequest.id);
97
+ // Only a new request opens a panel; the open function is stable.
98
+ // eslint-disable-next-line react-hooks/exhaustive-deps
99
+ }, [requestedSerial]);
100
+ const requestedFeatureSerial = serialOf(featureRequest);
101
+ useEffect(() => {
102
+ if (featureRequest !== null && featureRequest !== undefined)
103
+ setInfo({ kind: "feature", id: featureRequest.key });
104
+ // Only a new request opens a place.
105
+ // eslint-disable-next-line react-hooks/exhaustive-deps
106
+ }, [requestedFeatureSerial]);
107
+ const openFeatureKey = info?.kind === "feature" ? info.id : null;
108
+ useEffect(() => { onOpenFeatureChange?.(openFeatureKey); }, [onOpenFeatureChange, openFeatureKey]);
109
+ /** Every time change a person makes goes through here, so a seek is never mistaken for playback crossing a panel. */
110
+ const seek = (timeUtcMs) => {
111
+ story.noteSeek(timeUtcMs);
112
+ onSeek(timeUtcMs);
113
+ };
114
+ const openPanelFromTimeline = (panel) => {
115
+ seek(panel.timeUtcMs);
116
+ story.open(panel.id);
117
+ };
118
+ useEffect(() => {
119
+ onSelectionChange(selectedObjectId);
120
+ }, [onSelectionChange, selectedObjectId]);
121
+ useEffect(() => {
122
+ const selected = experience.objects.find((object) => object.id === selectedObjectId);
123
+ if (selected === undefined || !isObjectAvailable(selected, snapshot.timeUtcMs)) {
124
+ const fallbackId = firstAvailableObject(experience, snapshot.timeUtcMs)?.id ?? "";
125
+ setSelectedObjectId(fallbackId);
126
+ onSelectionChange(fallbackId);
127
+ }
128
+ const active = experience.cameraPresets.find((preset) => preset.id === activePresetId);
129
+ const activeRequest = active?.request;
130
+ if (activeRequest !== undefined && activeRequest.kind !== "overview") {
131
+ const target = experience.objects.find((object) => object.id === activeRequest.target);
132
+ if (target === undefined || !isObjectAvailable(target, snapshot.timeUtcMs)) {
133
+ const overview = findCameraPreset(experience, "overview");
134
+ if (overview !== undefined) {
135
+ setActivePresetId(overview.id);
136
+ onCameraRequest(overview.request);
137
+ }
138
+ }
139
+ }
140
+ }, [activePresetId, experience, onCameraRequest, onSelectionChange, selectedObjectId, snapshot.timeUtcMs]);
141
+ const [moonsOpen, setMoonsOpen] = useState(false);
142
+ /** A moon chosen in the moon panel: flies to it (the same focus as the object picker) and opens its information. */
143
+ const chooseMoon = (id) => {
144
+ const object = availableObjectById(experience, id, snapshot.timeUtcMs);
145
+ if (object === undefined)
146
+ return;
147
+ activatePreset(focusPresetFor(experience, object));
148
+ setInfo({ kind: "object" });
149
+ };
150
+ /** An object tapped or clicked in the scene: the picker's focus; on a wide screen it also opens the card, on a phone it does not (T-138). A tapped body-set member that is no listed object just flies there. */
151
+ const pickObject = (id) => {
152
+ const object = availableObjectById(experience, id, snapshot.timeUtcMs);
153
+ if (object !== undefined) {
154
+ activatePreset(focusPresetFor(experience, object));
155
+ if (pickOpensInfo(phone))
156
+ setInfo({ kind: "object" });
157
+ }
158
+ else if (!experience.objects.some((candidate) => candidate.id === id))
159
+ onCameraRequest({ kind: "focus", target: id });
160
+ };
161
+ const requestedPickSerial = serialOf(pickRequest);
162
+ useEffect(() => {
163
+ if (pickRequest !== null && pickRequest !== undefined)
164
+ pickObject(pickRequest.id);
165
+ // Only a new request flies; the handler reads the current time and experience.
166
+ // eslint-disable-next-line react-hooks/exhaustive-deps
167
+ }, [requestedPickSerial]);
168
+ const selectObject = (id) => {
169
+ const object = availableObjectById(experience, id, snapshot.timeUtcMs);
170
+ if (object === undefined)
171
+ return;
172
+ setSelectedObjectId(id);
173
+ onSelectionChange(id);
174
+ setInfo({ kind: "object" });
175
+ const active = experience.cameraPresets.find((preset) => preset.id === activePresetId);
176
+ if (active?.request.kind === "focus" || active?.request.kind === "follow") {
177
+ const next = findCameraPreset(experience, active.request.kind, id)
178
+ ?? (active.request.kind === "follow" ? findCameraPreset(experience, "focus", id) : undefined);
179
+ if (next !== undefined) {
180
+ setActivePresetId(next.id);
181
+ onCameraRequest(next.request);
182
+ }
183
+ else {
184
+ const overview = findCameraPreset(experience, "overview");
185
+ setActivePresetId(overview?.id ?? null);
186
+ if (overview !== undefined)
187
+ onCameraRequest(overview.request);
188
+ }
189
+ }
190
+ };
191
+ const activatePreset = (preset) => {
192
+ if (preset.request.kind !== "overview") {
193
+ const target = availableObjectById(experience, preset.request.target, snapshot.timeUtcMs);
194
+ if (target === undefined)
195
+ return;
196
+ setSelectedObjectId(target.id);
197
+ onSelectionChange(target.id);
198
+ }
199
+ setActivePresetId(preset.id);
200
+ onCameraRequest(preset.request);
201
+ };
202
+ const seekToEvent = (event) => {
203
+ seek(event.timeUtcMs);
204
+ if (info?.kind === "event")
205
+ setInfo({ kind: "event", id: event.id });
206
+ };
207
+ const seekToWindow = (window, timeUtcMs) => {
208
+ seek(timeUtcMs);
209
+ if (info?.kind === "window")
210
+ setInfo({ kind: "window", id: window.id });
211
+ };
212
+ const { view, metrics } = infoContent(experience, info, selectedObjectId, snapshot.timeUtcMs, metricsFor);
213
+ // On a wide screen the moons sheet and the information panel share the left column under the toolbar: opening one closes the other.
214
+ const toggleMoons = () => {
215
+ if (!moonsOpen)
216
+ setInfo(null);
217
+ setMoonsOpen(!moonsOpen);
218
+ };
219
+ useEffect(() => { if (info !== null)
220
+ setMoonsOpen(false); }, [info]);
221
+ const selectedLabel = objectLabelOr(experience, selectedObjectId, "Controls");
222
+ const topBar = (_jsx(TopBar, { experience: experience, timeUtcMs: snapshot.timeUtcMs, selectedObjectId: selectedObjectId, activePresetId: activePresetId, onSelectObject: selectObject, onCameraPreset: activatePreset, infoOpen: info?.kind === "object", onToggleInfo: () => setInfo(info?.kind === "object" ? null : { kind: "object" }), scaleId: scaleId, onScaleChange: onScaleChange, scaleChoices: scaleChoices, switcher: switcher, displaySwitches: displaySwitches }));
223
+ const moonPanel = experience.moonFamilies === undefined ? null : (_jsx(PanelLoadBoundary, { message: "The moon list could not load. Reload the page to try again.", children: _jsx(Suspense, { fallback: null, children: _jsx(MoonFamilyPanel, { list: experience.moonFamilies, highlightedFamily: highlightedFamily, onHighlight: (id) => onHighlightFamily?.(id), onSelectMoon: chooseMoon }) }) }));
224
+ return (_jsxs("main", { className: "astraeus-shell", ref: root, "data-phone": phone, "data-timeline-hidden": experience.hideTimeline === true, "data-embedded": embedded, style: phoneLayoutStyle(phoneLayout), children: [_jsx("div", { className: "shell-canvas", children: children }), phone && _jsxs(ControlsDrawer, { label: selectedLabel, open: controlsOpen, onOpenChange: openControls, swipeThresholdPx: phoneLayout.swipeThresholdPx, children: [topBar, moonPanel] }), _jsxs("div", { className: "shell-top", children: [!phone && topBar, !phone && moonPanel !== null && _jsx(MoonsSheet, { planetLabel: experience.moonFamilies?.planetLabel, open: moonsOpen, onToggle: toggleMoons, onClose: () => setMoonsOpen(false), children: moonPanel }), view !== null && _jsx(InfoPanel, { view: view, metrics: metrics, onClose: () => setInfo(null) })] }), story.openPanel !== null && (_jsx(StoryPanelView, { panel: story.openPanel, holding: story.holding, onClose: story.close, onContinue: story.continuePlayback })), _jsx(DeveloperToggle, { developerMode: developerMode, onDeveloperModeChange: onDeveloperModeChange }), _jsx("aside", { className: "developer-tools", id: "developer-tools", "data-developer-panel": "", "aria-label": "Developer diagnostics", hidden: !developerMode, children: developerMode ? developerTools : null }), _jsx(ShellTimeline, { hidden: experience.hideTimeline === true, experience: experience, snapshot: snapshot, onTogglePlayback: onTogglePlayback, onRateChange: onRateChange, onSeek: seek, panels: storyPanels, openPanelId: openPanelId, onPanelOpen: openPanelFromTimeline, onEventSeek: seekToEvent, onEventInfo: (event) => setInfo({ kind: "event", id: event.id }), onWindowSeek: seekToWindow, onWindowInfo: (window) => setInfo({ kind: "window", id: window.id }), glowLook: timelineGlow, drawer: phone ? { open: timelineOpen, onOpenChange: openTimeline, swipeThresholdPx: phoneLayout.swipeThresholdPx } : undefined })] }));
225
+ }
@@ -21,7 +21,7 @@ function SwitchPanel({ switches }) {
21
21
  return undefined;
22
22
  const outside = (event) => { if (!root.current?.contains(event.target))
23
23
  setOpen(false); };
24
- const escape = (event) => { if (event.key === "Escape")
24
+ const escape = (event) => { if (!event.defaultPrevented && event.key === "Escape")
25
25
  setOpen(false); };
26
26
  document.addEventListener("pointerdown", outside);
27
27
  document.addEventListener("keydown", escape);
@@ -3,6 +3,7 @@ import { useEffect, useRef } from "react";
3
3
  import { Sources } from "./Sources.js";
4
4
  import { BADGE_LABELS } from "./storyPanels.js";
5
5
  import { useSwipeToDismiss } from "./useSwipeToDismiss.js";
6
+ import { useZoomThrough } from "./useZoomThrough.js";
6
7
  /** A small pill saying how far to trust a panel's facts, after Planetary Explorer's Badge. */
7
8
  export function StoryBadge({ badge }) {
8
9
  return _jsx("span", { className: "story-badge", "data-badge": badge, children: BADGE_LABELS[badge] });
@@ -14,8 +15,9 @@ export function StoryBadge({ badge }) {
14
15
  export function StoryPanelView({ panel, holding, onClose, onContinue }) {
15
16
  const sheet = useRef(null);
16
17
  useSwipeToDismiss(sheet, onClose);
18
+ useZoomThrough(sheet);
17
19
  useEffect(() => {
18
- const onKey = (event) => { if (event.key === "Escape")
20
+ const onKey = (event) => { if (!event.defaultPrevented && event.key === "Escape")
19
21
  onClose(); };
20
22
  document.addEventListener("keydown", onKey);
21
23
  return () => document.removeEventListener("keydown", onKey);
@@ -0,0 +1,75 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo, useState } from "react";
3
+ import { eventContextAt, eventPositionPercent, formatUtcTimestamp, formatWindowRate, navigationStops, windowContextAt, timePositionPercent, mergeSpeeds, DEFAULT_PLAYBACK_SPEEDS, TIMELINE_STEP_MS, clampToBounds, formatRateCompact } from "./timelineModel.js";
4
+ import { activityAt, DEFAULT_TIMELINE_GLOW, glowDescription, glowGradient, glowProfile, glowTooltip } from "./timelineGlow.js";
5
+ import { Label } from "./Label.js";
6
+ import { useDrawerSwipe } from "./useDrawerSwipe.js";
7
+ /** The seek slider's spoken value: the time, with the activity window and its rate when one is running. */
8
+ function seekValueText(timeUtcMs, activityNow) {
9
+ if (activityNow === null || activityNow.window.rate === undefined)
10
+ return formatUtcTimestamp(timeUtcMs);
11
+ return `${formatUtcTimestamp(timeUtcMs)}, ${activityNow.window.label}: ${formatWindowRate(activityNow.rate, activityNow.window.rate.unit)}`;
12
+ }
13
+ export function TimelineBar({ experience, snapshot, onTogglePlayback, onRateChange, onSeek, panels = [], openPanelId = null, onPanelOpen, onEventSeek, onEventInfo, onWindowSeek, onWindowInfo, glowLook = DEFAULT_TIMELINE_GLOW, drawer }) {
14
+ const windows = experience.windows ?? [];
15
+ const profile = useMemo(() => glowProfile(windows, experience.window), [windows, experience.window]);
16
+ const gradients = useMemo(() => ({ ahead: glowGradient(profile, glowLook, "ahead"), played: glowGradient(profile, glowLook, "played") }), [profile, glowLook]);
17
+ const description = glowDescription(windows);
18
+ const [hoverTitle, setHoverTitle] = useState(null);
19
+ const playedPercent = timePositionPercent(clampToBounds(snapshot.timeUtcMs, experience.window), experience.window);
20
+ const activityNow = activityAt(windows, snapshot.timeUtcMs);
21
+ const valueText = seekValueText(snapshot.timeUtcMs, activityNow);
22
+ const moveOnTrack = (event) => {
23
+ if (profile === null)
24
+ return;
25
+ const box = event.currentTarget.getBoundingClientRect();
26
+ const fraction = box.width > 16 ? Math.max(0, Math.min(1, (event.clientX - box.left - 8) / (box.width - 16))) : 0;
27
+ const text = glowTooltip(windows, experience.window.startUtcMs + (experience.window.endUtcMs - experience.window.startUtcMs) * fraction);
28
+ setHoverTitle((previous) => (previous === text ? previous : text));
29
+ };
30
+ const navigation = navigationStops(experience.events, windows, snapshot.timeUtcMs);
31
+ const goToStop = (stop) => {
32
+ if (stop.event !== undefined)
33
+ onEventSeek(stop.event);
34
+ else if (stop.window !== undefined)
35
+ onWindowSeek(stop.window, stop.timeUtcMs);
36
+ };
37
+ const stopLabel = (direction, stop) => windows.length === 0 || stop === null ? `${direction} event` : `${direction}: ${stop.label}`;
38
+ const speeds = mergeSpeeds(DEFAULT_PLAYBACK_SPEEDS, experience.rates);
39
+ const timestamp = formatUtcTimestamp(snapshot.timeUtcMs);
40
+ const handle = useDrawerSwipe({
41
+ thresholdPx: drawer?.swipeThresholdPx ?? 0,
42
+ onTap: () => drawer?.onOpenChange(!drawer.open),
43
+ onSwipe: (direction) => drawer?.onOpenChange(direction === "up"),
44
+ });
45
+ const speedIndex = Math.max(0, speeds.findIndex((speed) => speed.rate === snapshot.rate));
46
+ const scrubber = (_jsxs("div", { className: "timeline-scrubber", children: [_jsxs("div", { className: "timeline-track", title: profile === null ? undefined : hoverTitle ?? description, onPointerMove: moveOnTrack, onPointerLeave: () => setHoverTitle(null), children: [_jsxs("div", { className: "timeline-glow", ...(description === "" ? { "aria-hidden": true } : { role: "img", "aria-label": description }), style: {
47
+ "--glow-ahead": gradients.ahead,
48
+ "--glow-played": gradients.played,
49
+ "--glow-played-edge": `${(100 - playedPercent).toFixed(3)}%`,
50
+ "--glow-thickness": `${glowLook.thicknessPx}px`,
51
+ "--glow-halo": `${glowLook.haloPx}px`,
52
+ }, children: [_jsx("span", { className: "timeline-glow-ahead" }), _jsx("span", { className: "timeline-glow-played", children: _jsx("span", { className: "timeline-glow-line" }) })] }), _jsxs("div", { className: "timeline-markers", "aria-label": "Timeline event markers", children: [experience.events.map((event) => (_jsx("button", { className: "timeline-marker", type: "button", "aria-label": `Go to ${event.label}`, title: event.label, style: { left: `${eventPositionPercent(event, experience.window)}%` }, onClick: () => { onEventSeek(event); onEventInfo(event); }, children: _jsx(Label, { text: event.label, className: "timeline-marker-label" }) }, event.id))), panels.map((panel) => (_jsx("button", { className: "timeline-marker timeline-panel-marker", type: "button", "data-panel-id": panel.id, "aria-pressed": openPanelId === panel.id, "aria-label": `Open story panel: ${panel.title}`, title: panel.title, style: { left: `${timePositionPercent(panel.timeUtcMs, experience.window)}%` }, onClick: () => onPanelOpen?.(panel), children: _jsx(Label, { text: panel.title, className: "timeline-marker-label" }) }, panel.id))), windows.filter((window) => window.peakUtcMs !== undefined).map((window) => (_jsx("button", { type: "button", className: "timeline-marker timeline-window-peak", "aria-label": `Go to peak of ${window.label}`, title: `${window.label} peak`, "data-time-utc-ms": window.peakUtcMs, style: { left: `${timePositionPercent(window.peakUtcMs ?? 0, experience.window)}%` }, onClick: () => { if (window.peakUtcMs !== undefined)
53
+ onWindowSeek(window, window.peakUtcMs); onWindowInfo(window); } }, `peak-${window.id}`)))] }), _jsx("input", { type: "range", "aria-label": "Seek timeline", "aria-valuetext": valueText, min: experience.window.startUtcMs, max: experience.window.endUtcMs, step: TIMELINE_STEP_MS, value: clampToBounds(snapshot.timeUtcMs, experience.window), onChange: (event) => onSeek(Number(event.target.value)) })] }), _jsxs("div", { className: "timeline-bounds", "aria-hidden": "true", children: [_jsx("time", { dateTime: formatUtcTimestamp(experience.window.startUtcMs), children: formatUtcTimestamp(experience.window.startUtcMs).slice(0, 10) }), _jsx("time", { dateTime: formatUtcTimestamp(experience.window.endUtcMs), children: formatUtcTimestamp(experience.window.endUtcMs).slice(0, 10) })] })] }));
54
+ return (_jsxs("section", { className: "timeline-bar", "aria-label": "Timeline controls", "data-drawer-open": drawer?.open, children: [drawer !== undefined && (_jsx("button", { type: "button", className: "drawer-handle drawer-handle-top ui-bare", "aria-label": "Timeline drawer", "aria-expanded": drawer.open, "aria-controls": "timeline-drawer", ...handle, children: _jsx("span", {}) })), _jsxs("div", { className: "timeline-main-row", children: [_jsxs("div", { className: "timeline-transport", children: [_jsx("button", { type: "button", className: "timeline-play ui-icon ui-accent", title: snapshot.playing ? "Pause" : "Play", onClick: onTogglePlayback, "aria-label": snapshot.playing ? "Pause playback" : "Play playback", children: snapshot.playing ? _jsx(Symbol, { path: "M7 5h3.5v14H7zM13.5 5H17v14h-3.5z" }) : _jsx(Symbol, { path: "M7 5v14l12-7z" }) }), _jsx("button", { type: "button", className: "timeline-previous ui-icon ui-ghost", "aria-label": stopLabel("Previous", navigation.previous), title: stopLabel("Previous", navigation.previous), disabled: navigation.previous === null, onClick: () => { if (navigation.previous !== null)
55
+ goToStop(navigation.previous); }, children: _jsx(Symbol, { path: "M6 5h2v14H6zM19 5v14L9 12z" }) }), _jsx("button", { type: "button", className: "timeline-next ui-icon ui-ghost", "aria-label": stopLabel("Next", navigation.next), title: stopLabel("Next", navigation.next), disabled: navigation.next === null, onClick: () => { if (navigation.next !== null)
56
+ goToStop(navigation.next); }, children: _jsx(Symbol, { path: "M16 5h2v14h-2zM5 5v14l10-7z" }) })] }), _jsxs("time", { className: "timeline-time", dateTime: timestamp, "aria-label": timestamp, children: [_jsx("span", { className: "timeline-time-full", children: timestamp }), _jsx("span", { className: "timeline-time-short", "aria-hidden": "true", children: timestamp.slice(0, 16).replace("T", " ") })] }), _jsxs("label", { className: "timeline-speed", children: [_jsx("span", { children: "Playback rate" }), _jsx("select", { "aria-label": "Playback speed", title: "Playback speed", value: snapshot.rate, onChange: (event) => onRateChange(Number(event.target.value)), children: speeds.map((speed) => _jsx("option", { value: speed.rate, children: drawer === undefined ? speed.label : formatRateCompact(speed.rate) }, speed.rate)) })] }), scrubber, drawer === undefined && (_jsxs("details", { className: "timeline-event-list", children: [_jsxs("summary", { className: "ui-button", title: "Events: what just happened, what is next, and the full list", children: ["Events ", _jsxs("span", { children: ["(", experience.events.length, ")"] })] }), _jsx(TimelineExpanded, { experience: experience, snapshot: snapshot, onEventSeek: onEventSeek, onEventInfo: onEventInfo, onWindowInfo: onWindowInfo })] }))] }), drawer !== undefined && (_jsx("div", { id: "timeline-drawer", className: "timeline-drawer", role: "region", "aria-label": "Timeline details", "data-open": drawer.open, onClick: (event) => { const closer = event.target.closest("[data-closes-drawer]"); if (closer !== null && closer.tagName !== "SELECT")
57
+ drawer.onOpenChange(false); }, children: _jsxs("div", { className: "timeline-drawer-body", children: [_jsxs("div", { className: "timeline-speed-slider", children: [_jsx("span", { "aria-hidden": "true", children: "Playback speed" }), _jsx("input", { type: "range", "aria-label": "Speed slider", "aria-valuetext": speeds[speedIndex]?.label, min: 0, max: speeds.length - 1, step: 1, value: speedIndex, onChange: (event) => { const next = speeds[Number(event.target.value)]; if (next !== undefined)
58
+ onRateChange(next.rate); } }), _jsx("output", { children: speeds[speedIndex]?.label })] }), _jsx(TimelineExpanded, { experience: experience, snapshot: snapshot, onEventSeek: onEventSeek, onEventInfo: onEventInfo, onWindowInfo: onWindowInfo })] }) }))] }));
59
+ }
60
+ /** A 24x24 filled symbol; the button around it carries the accessible name and tooltip. */
61
+ function Symbol({ path }) {
62
+ return _jsx("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": "true", children: _jsx("path", { d: path }) });
63
+ }
64
+ /**
65
+ * The timeline's expanded content: "Just happened / Up next / Inside" and the full event list.
66
+ * On larger screens it opens from the Events button; the phone drawer shows the same content when expanded.
67
+ */
68
+ export function TimelineExpanded({ experience, snapshot, onEventSeek, onEventInfo, onWindowInfo }) {
69
+ const context = eventContextAt(experience.events, snapshot.timeUtcMs);
70
+ const inside = windowContextAt(experience.windows ?? [], snapshot.timeUtcMs);
71
+ return (_jsxs("div", { className: "timeline-expanded", children: [_jsxs("div", { className: "timeline-event-context", "aria-label": "Event context", children: [context.current === null
72
+ ? _jsxs("span", { children: [_jsx("strong", { children: "Just happened:" }), " No event yet"] })
73
+ : (_jsxs("button", { type: "button", className: "timeline-event-current ui-row", "data-closes-drawer": "", "aria-label": `Information about ${context.current.label}`, "aria-controls": "info-panel", onClick: () => { if (context.current !== null)
74
+ onEventInfo(context.current); }, children: [_jsx("strong", { children: "Just happened:" }), " ", context.current.label, " ", _jsx("span", { "aria-hidden": "true", children: "\u24D8" })] })), _jsxs("span", { children: [_jsx("strong", { children: "Up next:" }), " ", context.next?.label ?? "No upcoming event"] }), inside.map(({ window, rate }) => (_jsxs("button", { type: "button", className: "timeline-event-current timeline-window-current ui-row", "data-closes-drawer": "", "aria-label": `Information about ${window.label}`, "aria-controls": "info-panel", onClick: () => onWindowInfo(window), children: [_jsx("strong", { children: "Inside:" }), " ", window.label, rate !== null && window.rate !== undefined && _jsxs(_Fragment, { children: [" \u2014 ", formatWindowRate(rate, window.rate.unit)] }), " ", _jsx("span", { "aria-hidden": "true", children: "\u24D8" })] }, window.id)))] }), _jsx("ol", { children: experience.events.map((event) => (_jsx("li", { children: _jsxs("button", { type: "button", className: "ui-row", "data-closes-drawer": "", "aria-current": context.current?.id === event.id ? "time" : undefined, onClick: () => { onEventSeek(event); onEventInfo(event); }, children: [_jsx("time", { dateTime: formatUtcTimestamp(event.timeUtcMs), children: formatUtcTimestamp(event.timeUtcMs) }), _jsx("span", { children: event.label })] }) }, event.id))) })] }));
75
+ }
@@ -0,0 +1,14 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ObjectControls } from "./ObjectControls.js";
3
+ import { ScaleControl } from "./ScaleControl.js";
4
+ import { DisplaySwitches } from "./DisplaySwitches.js";
5
+ import { SwitchControl } from "./SwitchControl.js";
6
+ import { CogIcon } from "./topBarIcons.js";
7
+ /** The single compact bar: body picker, Info, camera buttons and Scale in one row. */
8
+ export function TopBar({ scaleId, onScaleChange, scaleChoices, switcher, displaySwitches = [], ...objectControls }) {
9
+ return (_jsx("div", { className: "shell-toolbar", children: _jsxs("div", { className: "top-bar", children: [switcher !== undefined && switcher.options.length > 1 && (_jsxs(_Fragment, { children: [_jsx(SwitchControl, { choice: switcher }), _jsx("span", { className: "top-bar-divider", "aria-hidden": "true" })] })), _jsx(ObjectControls, { ...objectControls }), _jsx("span", { className: "top-bar-divider", "aria-hidden": "true" }), _jsx(ScaleControl, { scaleId: scaleId, onScaleChange: onScaleChange, choices: scaleChoices }), displaySwitches.length > 0 && (_jsxs(_Fragment, { children: [_jsx("span", { className: "top-bar-divider", "aria-hidden": "true" }), _jsx(DisplaySwitches, { switches: displaySwitches })] }))] }) }));
10
+ }
11
+ /** Developer mode stays public, as a cog on its own at the top right of the shell. */
12
+ export function DeveloperToggle({ developerMode, onDeveloperModeChange }) {
13
+ return (_jsx("button", { className: "developer-mode-toggle ui-icon ui-pill", type: "button", "aria-label": "Developer mode", title: "Developer mode", "aria-pressed": developerMode, "aria-expanded": developerMode, "aria-controls": "developer-tools", onClick: () => onDeveloperModeChange(!developerMode), children: _jsx(CogIcon, {}) }));
14
+ }
@@ -71,4 +71,6 @@ export interface ExperienceConfig {
71
71
  readonly bodyFeatures?: readonly BodyFeatureSet[];
72
72
  /** Where the event times come from, shown with every event. */
73
73
  readonly eventProvenance?: Provenance;
74
+ /** Provenance of single events by event id; an event listed here shows it instead of `eventProvenance`. */
75
+ readonly eventProvenanceById?: Readonly<Record<string, Provenance>>;
74
76
  }
@@ -6,6 +6,7 @@ export const PROVENANCE_STATUS = {
6
6
  ephemeris: "Ephemeris",
7
7
  observed: "Observed",
8
8
  reconstructed: "Reconstructed",
9
+ modelled: "Modelled",
9
10
  illustrative: "Illustrative",
10
11
  };
11
12
  export function provenanceView(provenance, knownLimitations = []) {
@@ -71,10 +72,11 @@ function eventInfo(experience, target) {
71
72
  const event = experience.events.find((candidate) => candidate.id === target.id);
72
73
  if (event === undefined)
73
74
  return null;
75
+ const source = experience.eventProvenanceById?.[event.id] ?? experience.eventProvenance;
74
76
  return {
75
77
  target,
76
78
  title: event.label,
77
79
  subtitle: formatUtcTimestamp(event.timeUtcMs),
78
- provenance: experience.eventProvenance === undefined ? null : provenanceView(experience.eventProvenance),
80
+ provenance: source === undefined ? null : provenanceView(source),
79
81
  };
80
82
  }
@@ -159,7 +159,7 @@
159
159
  animation: story-sheet-in var(--drawer-ms, 240ms) var(--drawer-ease);
160
160
  }
161
161
  [data-phone="true"] .info-panel { z-index: 8; background: #0e0e13; }
162
- [data-phone="true"] .story-panel { z-index: 4; }
162
+ [data-phone="true"] .story-panel { z-index: 4; touch-action: pan-y; } /* a pinch reaches the scene beneath (useZoomThrough); a vertical drag still scrolls or dismisses */
163
163
  [data-phone="true"] .info-panel-header h2 { margin: 0; font-size: 22px; }
164
164
 
165
165
  /* ---- The Developer panel below the pill, above the timeline ---- */
@@ -18,7 +18,7 @@ export function useDrawers(phone, onControlsOpened) {
18
18
  useEffect(() => {
19
19
  if (!phone || (!controlsOpen && !timelineOpen))
20
20
  return undefined;
21
- const onKey = (event) => { if (event.key === "Escape") {
21
+ const onKey = (event) => { if (!event.defaultPrevented && event.key === "Escape") {
22
22
  setControlsOpen(false);
23
23
  setTimelineOpen(false);
24
24
  } };
@@ -0,0 +1,7 @@
1
+ import { type RefObject } from "react";
2
+ /**
3
+ * Lets a phone bottom sheet pass zoom input to the scene beneath it: a wheel, or a two-finger pinch, over the sheet is forwarded to the canvas as a
4
+ * wheel event, which the camera control already turns into a zoom. A sheet with something to scroll keeps its wheel (reading wins); a pinch always zooms.
5
+ * Does nothing on a wide screen, where the panel sits beside the scene.
6
+ */
7
+ export declare function useZoomThrough(ref: RefObject<HTMLElement | null>): void;
@@ -0,0 +1,51 @@
1
+ import { useEffect } from "react";
2
+ /** A pinch's spread change (px) counts as this many wheel units, matching the camera's pinch (0.006) and wheel (0.0012) sensitivities. */
3
+ const PINCH_TO_WHEEL = 5;
4
+ /**
5
+ * Lets a phone bottom sheet pass zoom input to the scene beneath it: a wheel, or a two-finger pinch, over the sheet is forwarded to the canvas as a
6
+ * wheel event, which the camera control already turns into a zoom. A sheet with something to scroll keeps its wheel (reading wins); a pinch always zooms.
7
+ * Does nothing on a wide screen, where the panel sits beside the scene.
8
+ */
9
+ export function useZoomThrough(ref) {
10
+ useEffect(() => {
11
+ const sheet = ref.current;
12
+ if (sheet === null)
13
+ return undefined;
14
+ const shell = sheet.closest(".astraeus-shell");
15
+ const forward = (deltaY) => {
16
+ shell?.querySelector("canvas")?.dispatchEvent(new WheelEvent("wheel", { deltaY, bubbles: true, cancelable: true }));
17
+ };
18
+ const phone = () => shell?.dataset.phone === "true";
19
+ const onWheel = (event) => {
20
+ if (!phone() || sheet.scrollHeight > sheet.clientHeight)
21
+ return;
22
+ event.preventDefault();
23
+ forward(event.deltaY);
24
+ };
25
+ let spread = null;
26
+ const spreadOf = (touches) => {
27
+ const [a, b] = [touches[0], touches[1]];
28
+ return touches.length === 2 && a !== undefined && b !== undefined ? Math.hypot(a.clientX - b.clientX, a.clientY - b.clientY) : null;
29
+ };
30
+ const onTouch = (event) => {
31
+ const next = phone() ? spreadOf(event.touches) : null;
32
+ if (next !== null && spread !== null) {
33
+ event.preventDefault();
34
+ forward(-(next - spread) * PINCH_TO_WHEEL);
35
+ }
36
+ spread = next;
37
+ };
38
+ sheet.addEventListener("wheel", onWheel, { passive: false });
39
+ sheet.addEventListener("touchstart", onTouch, { passive: true });
40
+ sheet.addEventListener("touchmove", onTouch, { passive: false });
41
+ sheet.addEventListener("touchend", onTouch, { passive: true });
42
+ sheet.addEventListener("touchcancel", onTouch, { passive: true });
43
+ return () => {
44
+ sheet.removeEventListener("wheel", onWheel);
45
+ sheet.removeEventListener("touchstart", onTouch);
46
+ sheet.removeEventListener("touchmove", onTouch);
47
+ sheet.removeEventListener("touchend", onTouch);
48
+ sheet.removeEventListener("touchcancel", onTouch);
49
+ };
50
+ }, [ref]);
51
+ }