astraeus 0.1.1 → 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 (112) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.md +76 -7
  3. package/package.json +10 -6
  4. package/src/api/AstraeusScene.d.ts +27 -0
  5. package/src/api/AstraeusScene.js +38 -0
  6. package/src/api/AstraeusScene.node.js +37 -0
  7. package/src/api/activity.d.ts +50 -0
  8. package/src/api/activity.js +62 -0
  9. package/src/api/bodies.d.ts +24 -0
  10. package/src/api/bodies.js +24 -0
  11. package/src/api/errors.d.ts +1 -1
  12. package/src/api/group.d.ts +89 -0
  13. package/src/api/group.js +121 -0
  14. package/src/api/index.d.ts +6 -1
  15. package/src/api/index.js +3 -1
  16. package/src/api/index.node.js +8 -0
  17. package/src/api/mount.d.ts +10 -1
  18. package/src/api/mount.js +15 -4
  19. package/src/api/mount.node.js +36 -0
  20. package/src/api/prepared.d.ts +10 -0
  21. package/src/api/prepared.js +5 -0
  22. package/src/api/scene.d.ts +148 -9
  23. package/src/api/scene.js +563 -59
  24. package/src/api/story.d.ts +69 -0
  25. package/src/api/story.js +63 -0
  26. package/src/api/sunOrbit.d.ts +20 -0
  27. package/src/api/sunOrbit.js +85 -0
  28. package/src/api/switches.d.ts +14 -0
  29. package/src/api/switches.js +19 -0
  30. package/src/api/time.d.ts +4 -0
  31. package/src/api/time.js +8 -0
  32. package/src/app/App.d.ts +6 -2
  33. package/src/app/App.js +43 -21
  34. package/src/app/App.node.js +401 -0
  35. package/src/app/AstraeusScene.d.ts +1 -1
  36. package/src/app/DebugOverlay.d.ts +3 -52
  37. package/src/app/DebugOverlay.js +2 -29
  38. package/src/app/PanelLoadBoundary.d.ts +19 -0
  39. package/src/app/PanelLoadBoundary.js +17 -0
  40. package/src/app/SkyView.d.ts +3 -3
  41. package/src/app/SkyView.js +19 -10
  42. package/src/app/debugReadout.d.ts +53 -0
  43. package/src/app/debugReadout.js +30 -0
  44. package/src/app/developerPanels.d.ts +6 -0
  45. package/src/app/developerPanels.js +11 -0
  46. package/src/app/displaySwitches.d.ts +54 -0
  47. package/src/app/displaySwitches.js +48 -0
  48. package/src/app/experienceDefinition.d.ts +13 -1
  49. package/src/app/listSwitch.d.ts +16 -0
  50. package/src/{experiences/showers/showerChoice.js → app/listSwitch.js} +1 -9
  51. package/src/app/metricReadouts.d.ts +1 -1
  52. package/src/app/metricReadouts.js +1 -1
  53. package/src/app/openClock.d.ts +7 -0
  54. package/src/app/openClock.js +14 -0
  55. package/src/app/sceneContentsHooks.d.ts +3 -3
  56. package/src/app/sceneContentsHooks.js +2 -2
  57. package/src/app/sceneDebug.d.ts +1 -1
  58. package/src/app/sceneDebug.js +1 -1
  59. package/src/app/sceneFrame.js +4 -3
  60. package/src/app/sceneFraming.d.ts +13 -0
  61. package/src/app/sceneFraming.js +22 -0
  62. package/src/app/skyModel.js +3 -1
  63. package/src/app/trackedMetrics.d.ts +53 -0
  64. package/src/{experiences/apollo11/spacecraftMetrics.js → app/trackedMetrics.js} +40 -56
  65. package/src/assets/licence.d.ts +1 -0
  66. package/src/assets/pictures.d.ts +1 -1
  67. package/src/assets/sky.d.ts +4 -4
  68. package/src/assets/sky.js +12 -13
  69. package/src/core/bodies/index.d.ts +3 -0
  70. package/src/core/bodies/index.js +3 -1
  71. package/src/core/bodies/io.js +1 -1
  72. package/src/core/bodies/jupiterData.js +2 -2
  73. package/src/core/bodies/jupiterMoons.js +8 -12
  74. package/src/core/bodies/moon.d.ts +8 -0
  75. package/src/core/bodies/moon.js +28 -5
  76. package/src/core/bodies/outerPlanetData.js +7 -7
  77. package/src/core/bodies/planetMoons.js +18 -27
  78. package/src/core/bodies/swiftTuttle.js +2 -0
  79. package/src/core/elementsBody.d.ts +2 -0
  80. package/src/core/elementsBody.js +3 -0
  81. package/src/core/moonTrajectory.js +3 -5
  82. package/src/core/planetModels.js +1 -1
  83. package/src/core/planetSeries.d.ts +2 -0
  84. package/src/core/planetSeries.js +4 -0
  85. package/src/core/provenance.d.ts +7 -2
  86. package/src/core/provenance.js +3 -1
  87. package/src/core/scalePolicy.d.ts +3 -0
  88. package/src/core/scalePolicy.js +2 -0
  89. package/src/core/state.d.ts +1 -0
  90. package/src/shell/AstraeusShell.d.ts +4 -1
  91. package/src/shell/AstraeusShell.js +12 -6
  92. package/src/shell/AstraeusShell.node.js +225 -0
  93. package/src/shell/DisplaySwitches.d.ts +16 -0
  94. package/src/shell/DisplaySwitches.js +31 -0
  95. package/src/shell/StoryPanelView.js +3 -1
  96. package/src/shell/TimelineBar.css +4 -0
  97. package/src/shell/TimelineBar.node.js +75 -0
  98. package/src/shell/TopBar.css +20 -0
  99. package/src/shell/TopBar.d.ts +4 -1
  100. package/src/shell/TopBar.js +3 -2
  101. package/src/shell/TopBar.node.js +14 -0
  102. package/src/shell/experience.d.ts +4 -0
  103. package/src/shell/infoModel.js +3 -1
  104. package/src/shell/phone.css +4 -1
  105. package/src/shell/topBarIcons.d.ts +1 -0
  106. package/src/shell/topBarIcons.js +1 -0
  107. package/src/shell/useDrawers.js +1 -1
  108. package/src/shell/useZoomThrough.d.ts +7 -0
  109. package/src/shell/useZoomThrough.js +51 -0
  110. package/src/synthetic/syntheticDefinition.js +3 -3
  111. package/src/experiences/apollo11/spacecraftMetrics.d.ts +0 -34
  112. package/src/experiences/showers/showerChoice.d.ts +0 -25
@@ -30,7 +30,9 @@ export class ReadableScalePolicy extends EarthRadiusScale {
30
30
  id = "readable-scale";
31
31
  distanceFactor = 0.1;
32
32
  }
33
+ /** Real proportions: distances and body sizes at the same scale, so planets are specks, as in space. */
33
34
  export const trueScale = Object.freeze(new TrueScalePolicy());
35
+ /** Distances shrunk to a tenth while body sizes are kept, so bodies are easier to see and pick. */
34
36
  export const readableScale = Object.freeze(new ReadableScalePolicy());
35
37
  function validateFactor(label, factor) {
36
38
  if (!Number.isFinite(factor) || factor < 1)
@@ -10,6 +10,7 @@ export interface CenteredPosition {
10
10
  readonly positionKm: Float64Array;
11
11
  readonly velocityKmS?: Float64Array;
12
12
  }
13
+ /** Where a body is at one moment, as the engine reports it: position (and velocity when known) in km about a centre, in the EQJ frame, with its attitude when modelled. */
13
14
  export interface State extends CenteredPosition {
14
15
  /** Body-fixed +X/+Y/+Z axes expressed in EQJ; null means this body's attitude is not modeled. */
15
16
  readonly orientation: Quaternion | null;
@@ -5,6 +5,7 @@ import type { TimelineGlowLook } from "./timelineGlow.js";
5
5
  import type { ExperienceCameraPreset, ExperienceConfig } from "./experience.js";
6
6
  import type { Metric } from "./metrics.js";
7
7
  import { type PhoneLayoutSettings } from "./phoneLayout.js";
8
+ import type { DisplaySwitchItem } from "./DisplaySwitches.js";
8
9
  import type { ExperienceSwitch } from "./SwitchControl.js";
9
10
  import type { ScaleChoice, ScaleId } from "./scaleModel.js";
10
11
  import "./controls.css";
@@ -26,6 +27,8 @@ interface Props {
26
27
  readonly scaleChoices?: readonly ScaleChoice[];
27
28
  /** A choice between versions of the experience (top bar and phone drawer); absent: none. */
28
29
  readonly switcher?: ExperienceSwitch;
30
+ /** Display switches a story placed in the top bar or its switch panel (also in the phone drawer); absent or empty: none. */
31
+ readonly displaySwitches?: readonly DisplaySwitchItem[];
29
32
  /** Live measurements for an object's info panel, from the app's own State; empty when it has none. */
30
33
  readonly metricsFor?: (objectId: string, timeUtcMs: number) => readonly Metric[];
31
34
  readonly developerTools?: ReactNode;
@@ -62,5 +65,5 @@ interface Props {
62
65
  readonly children: ReactNode;
63
66
  }
64
67
  /** Canvas-first layout shared by astronomy experiences. Scene and diagnostics stay app-owned. */
65
- export declare function AstraeusShell({ experience, snapshot, developerMode, onDeveloperModeChange, onTogglePlayback, onRateChange, onSeek, onCameraRequest, onSelectionChange, scaleId, onScaleChange, scaleChoices, switcher, metricsFor, developerTools, storyPanelSettings, timelineGlow, phoneLayout, highlightedFamily, onHighlightFamily, onSetPlaying, panelRequest, onOpenPanelChange, featureRequest, onOpenFeatureChange, pickRequest, children, }: Props): import("react").JSX.Element;
68
+ export declare function AstraeusShell({ experience, snapshot, developerMode, onDeveloperModeChange, onTogglePlayback, onRateChange, onSeek, onCameraRequest, onSelectionChange, scaleId, onScaleChange, scaleChoices, switcher, displaySwitches, metricsFor, developerTools, storyPanelSettings, timelineGlow, phoneLayout, highlightedFamily, onHighlightFamily, onSetPlaying, panelRequest, onOpenPanelChange, featureRequest, onOpenFeatureChange, pickRequest, children, }: Props): import("react").JSX.Element;
66
69
  export {};
@@ -1,12 +1,12 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useEffect, useRef, useState } from "react";
2
+ import { lazy, Suspense, useEffect, useRef, useState } from "react";
3
3
  import { StoryPanelView } from "./StoryPanelView.js";
4
4
  import { useDrawers } from "./useDrawers.js";
5
5
  import { useStoryPanels } from "./useStoryPanels.js";
6
6
  import { TimelineBar } from "./TimelineBar.js";
7
7
  import { InfoPanel } from "./InfoPanel.js";
8
8
  import { infoView } from "./infoModel.js";
9
- import { MoonFamilyPanel } from "./MoonFamilyPanel.js";
9
+ import { PanelLoadBoundary } from "../app/PanelLoadBoundary.js";
10
10
  import { ControlsDrawer } from "./ControlsDrawer.js";
11
11
  import { isEmbedded } from "./embedded.js";
12
12
  import { DEFAULT_PHONE_LAYOUT, phoneLayoutStyle, pickOpensInfo, usePhone } from "./phoneLayout.js";
@@ -42,6 +42,10 @@ function initialObjectId(experience, timeUtcMs) {
42
42
  function ownStorySettings(storySet) {
43
43
  return { autoOpen: storySet?.autoOpen ?? false, pauseSeconds: storySet?.pauseSeconds ?? 0 };
44
44
  }
45
+ /** The timeline bar, or nothing when the experience says it has no timeline. */
46
+ function ShellTimeline({ hidden, ...bar }) {
47
+ return hidden ? null : _jsx(TimelineBar, { ...bar });
48
+ }
45
49
  /** The wide-screen moons toggle and the sheet it opens under the toolbar. */
46
50
  function MoonsSheet({ planetLabel, open, onToggle, onClose, children }) {
47
51
  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")
@@ -65,8 +69,10 @@ function infoContent(experience, info, selectedObjectId, timeUtcMs, metricsFor)
65
69
  const metrics = view?.target.kind === "object" && metricsFor !== undefined ? metricsFor(view.target.id, timeUtcMs) : [];
66
70
  return { view, metrics };
67
71
  }
72
+ /** The moon families load on demand: only an experience with `moonFamilies` draws them (I-089). */
73
+ const MoonFamilyPanel = lazy(() => import("./MoonFamilyPanel.js").then((module) => ({ default: module.MoonFamilyPanel })));
68
74
  /** Canvas-first layout shared by astronomy experiences. Scene and diagnostics stay app-owned. */
69
- export function AstraeusShell({ experience, snapshot, developerMode, onDeveloperModeChange, onTogglePlayback, onRateChange, onSeek, onCameraRequest, onSelectionChange, scaleId, onScaleChange, scaleChoices, switcher, metricsFor, developerTools, storyPanelSettings, timelineGlow, phoneLayout = DEFAULT_PHONE_LAYOUT, highlightedFamily = null, onHighlightFamily, onSetPlaying, panelRequest, onOpenPanelChange, featureRequest, onOpenFeatureChange, pickRequest, children, }) {
75
+ 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, }) {
70
76
  const [selectedObjectId, setSelectedObjectId] = useState(() => initialObjectId(experience, snapshot.timeUtcMs));
71
77
  const phone = usePhone();
72
78
  /** Fixed for the page: a frame does not appear or vanish while the app runs. */
@@ -217,7 +223,7 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
217
223
  useEffect(() => { if (info !== null)
218
224
  setMoonsOpen(false); }, [info]);
219
225
  const selectedLabel = objectLabelOr(experience, selectedObjectId, "Controls");
220
- 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 }));
221
- const moonPanel = experience.moonFamilies === undefined ? null : (_jsx(MoonFamilyPanel, { list: experience.moonFamilies, highlightedFamily: highlightedFamily, onHighlight: (id) => onHighlightFamily?.(id), onSelectMoon: chooseMoon }));
222
- return (_jsxs("main", { className: "astraeus-shell", ref: root, "data-phone": phone, "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(TimelineBar, { 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 })] }));
226
+ 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 }));
227
+ 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 }) }) }));
228
+ 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 })] }));
223
229
  }
@@ -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
+ }
@@ -0,0 +1,16 @@
1
+ /** One display switch a story placed: where it shows, and whether it is on now. */
2
+ export interface DisplaySwitchItem {
3
+ readonly id: string;
4
+ readonly label: string;
5
+ /** "top-bar": its own button in the bar; "panel": a row in the switch panel opened from the bar. */
6
+ readonly place: "top-bar" | "panel";
7
+ readonly on: boolean;
8
+ readonly onToggle: () => void;
9
+ }
10
+ /**
11
+ * The switches a story placed. Top-bar ones are buttons in the bar (and in the phone drawer's grid); panel ones sit in one small panel opened by a "Display" button
12
+ * beside them. Nothing placed: nothing drawn, so the bar is exactly as it was. The panel closes on an outside press or Escape.
13
+ */
14
+ export declare function DisplaySwitches({ switches }: {
15
+ readonly switches: readonly DisplaySwitchItem[];
16
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useId, useRef, useState } from "react";
3
+ import { ButtonText, OrbitIcon, SwitchesIcon } from "./topBarIcons.js";
4
+ /**
5
+ * The switches a story placed. Top-bar ones are buttons in the bar (and in the phone drawer's grid); panel ones sit in one small panel opened by a "Display" button
6
+ * beside them. Nothing placed: nothing drawn, so the bar is exactly as it was. The panel closes on an outside press or Escape.
7
+ */
8
+ export function DisplaySwitches({ switches }) {
9
+ const barSwitches = switches.filter((item) => item.place === "top-bar");
10
+ const panelSwitches = switches.filter((item) => item.place === "panel");
11
+ if (switches.length === 0)
12
+ return null;
13
+ return (_jsxs("section", { className: "display-switches", role: "group", "aria-label": "Display switches", children: [barSwitches.map((item) => (_jsxs("button", { type: "button", className: "display-switch top-bar-button ui-icon", "aria-label": item.label, title: item.label, "aria-pressed": item.on, "data-display-switch": item.id, "data-closes-drawer": "", onClick: item.onToggle, children: [item.id === "orbitLines" ? _jsx(OrbitIcon, {}) : _jsx(SwitchesIcon, {}), _jsx(ButtonText, { children: item.label })] }, item.id))), panelSwitches.length > 0 && _jsx(SwitchPanel, { switches: panelSwitches })] }));
14
+ }
15
+ function SwitchPanel({ switches }) {
16
+ const [open, setOpen] = useState(false);
17
+ const panelId = useId();
18
+ const root = useRef(null);
19
+ useEffect(() => {
20
+ if (!open)
21
+ return undefined;
22
+ const outside = (event) => { if (!root.current?.contains(event.target))
23
+ setOpen(false); };
24
+ const escape = (event) => { if (!event.defaultPrevented && event.key === "Escape")
25
+ setOpen(false); };
26
+ document.addEventListener("pointerdown", outside);
27
+ document.addEventListener("keydown", escape);
28
+ return () => { document.removeEventListener("pointerdown", outside); document.removeEventListener("keydown", escape); };
29
+ }, [open]);
30
+ return (_jsxs("div", { className: "switch-panel-host", ref: root, children: [_jsxs("button", { type: "button", className: "switch-panel-toggle top-bar-button ui-icon", "aria-label": "Switch panel", title: "Switch panel", "aria-expanded": open, "aria-controls": panelId, onClick: () => setOpen(!open), children: [_jsx(SwitchesIcon, {}), _jsx(ButtonText, { children: "Display" })] }), _jsx("div", { id: panelId, className: "switch-panel", role: "group", "aria-label": "Switches in the panel", hidden: !open, children: switches.map((item) => (_jsx("button", { type: "button", className: "switch-panel-row ui-row", "aria-pressed": item.on, "data-display-switch": item.id, onClick: item.onToggle, children: item.label }, item.id))) })] }));
31
+ }
@@ -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);
@@ -118,3 +118,7 @@
118
118
  @media (prefers-reduced-motion: reduce) {
119
119
  .timeline-bar { scroll-behavior: auto; transition: none !important; }
120
120
  }
121
+
122
+ /* No timeline (experience.hideTimeline): nothing sits at the bottom, so nothing is reserved for it on a wide or a phone screen. */
123
+ main.astraeus-shell[data-timeline-hidden="true"] { --timeline-space: 0px; }
124
+ main.astraeus-shell[data-timeline-hidden="true"] .shell-top { --shell-timeline-space: 0px; }
@@ -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
+ }
@@ -72,3 +72,23 @@
72
72
  @media (min-width: 701px) and (max-width: 900px) {
73
73
  .shell-toolbar { max-width: calc(100vw - 72px); }
74
74
  }
75
+
76
+ /* Display switches a story placed: buttons in the bar, and one small panel opened from a Display button (same look as the scale menu). */
77
+ .top-bar .display-switches,
78
+ .top-bar .switch-panel-host { display: contents; }
79
+ .switch-panel {
80
+ position: absolute;
81
+ z-index: 6;
82
+ top: calc(100% + 8px);
83
+ right: 0;
84
+ display: flex;
85
+ flex-direction: column;
86
+ gap: 4px;
87
+ min-width: 190px;
88
+ padding: 6px;
89
+ border: 1px solid var(--ui-border, rgba(240, 230, 218, .18));
90
+ border-radius: 12px;
91
+ background: rgba(13, 13, 13, .97);
92
+ box-shadow: 0 8px 24px rgba(0, 0, 0, .42);
93
+ }
94
+ .switch-panel[hidden] { display: none !important; }
@@ -1,4 +1,5 @@
1
1
  import type { ExperienceCameraPreset, ExperienceConfig } from "./experience.js";
2
+ import { type DisplaySwitchItem } from "./DisplaySwitches.js";
2
3
  import { type ExperienceSwitch } from "./SwitchControl.js";
3
4
  import type { ScaleChoice, ScaleId } from "./scaleModel.js";
4
5
  import "./TopBar.css";
@@ -16,13 +17,15 @@ interface Props {
16
17
  readonly scaleChoices?: readonly ScaleChoice[];
17
18
  /** A choice between versions of the experience, shown first in the bar; absent: none. */
18
19
  readonly switcher?: ExperienceSwitch;
20
+ /** Display switches a story placed in the bar or its panel; absent or empty: none, the bar as it was. */
21
+ readonly displaySwitches?: readonly DisplaySwitchItem[];
19
22
  }
20
23
  interface DeveloperProps {
21
24
  readonly developerMode: boolean;
22
25
  readonly onDeveloperModeChange: (enabled: boolean) => void;
23
26
  }
24
27
  /** The single compact bar: body picker, Info, camera buttons and Scale in one row. */
25
- export declare function TopBar({ scaleId, onScaleChange, scaleChoices, switcher, ...objectControls }: Props): import("react").JSX.Element;
28
+ export declare function TopBar({ scaleId, onScaleChange, scaleChoices, switcher, displaySwitches, ...objectControls }: Props): import("react").JSX.Element;
26
29
  /** Developer mode stays public, as a cog on its own at the top right of the shell. */
27
30
  export declare function DeveloperToggle({ developerMode, onDeveloperModeChange }: DeveloperProps): import("react").JSX.Element;
28
31
  export {};
@@ -1,12 +1,13 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { ObjectControls } from "./ObjectControls.js";
3
3
  import { ScaleControl } from "./ScaleControl.js";
4
+ import { DisplaySwitches } from "./DisplaySwitches.js";
4
5
  import { SwitchControl } from "./SwitchControl.js";
5
6
  import { CogIcon } from "./topBarIcons.js";
6
7
  import "./TopBar.css";
7
8
  /** The single compact bar: body picker, Info, camera buttons and Scale in one row. */
8
- export function TopBar({ scaleId, onScaleChange, scaleChoices, switcher, ...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 })] }) }));
9
+ export function TopBar({ scaleId, onScaleChange, scaleChoices, switcher, displaySwitches = [], ...objectControls }) {
10
+ 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
  }
11
12
  /** Developer mode stays public, as a cog on its own at the top right of the shell. */
12
13
  export function DeveloperToggle({ developerMode, onDeveloperModeChange }) {
@@ -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
+ }
@@ -61,6 +61,8 @@ export interface ExperienceConfig {
61
61
  readonly windows?: readonly TimelineWindow[];
62
62
  readonly window: TimeBounds;
63
63
  readonly rates: readonly number[];
64
+ /** True draws no timeline bar (and no phone timeline drawer or reserved space); the clock then runs or stays frozen as the definition says. Absent: the bar is shown. */
65
+ readonly hideTimeline?: boolean;
64
66
  /** Short story panels that open as playback reaches their time; see `parseStoryPanels`. Omit for an experience with none. */
65
67
  readonly storyPanels?: StoryPanelSet;
66
68
  /** A planet's moons by family for the sliding moon panel; omit for an experience with none. Every moon listed must also be an object. */
@@ -69,4 +71,6 @@ export interface ExperienceConfig {
69
71
  readonly bodyFeatures?: readonly BodyFeatureSet[];
70
72
  /** Where the event times come from, shown with every event. */
71
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>>;
72
76
  }