astraeus 0.8.1 → 0.9.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 (121) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/README.md +28 -15
  3. package/package.json +1 -1
  4. package/src/api/AstraeusScene.d.ts +1 -1
  5. package/src/api/AstraeusScene.js +4 -1
  6. package/src/api/AstraeusScene.node.js +4 -1
  7. package/src/api/assembleScene.d.ts +2 -0
  8. package/src/api/assembleScene.js +27 -5
  9. package/src/api/cameraRequest.d.ts +15 -0
  10. package/src/api/cameraRequest.js +89 -0
  11. package/src/api/errors.d.ts +9 -1
  12. package/src/api/index.d.ts +6 -3
  13. package/src/api/look.d.ts +49 -0
  14. package/src/api/lookInput.d.ts +1 -1
  15. package/src/api/lookInput.js +6 -1
  16. package/src/api/planCamera.d.ts +35 -7
  17. package/src/api/planCamera.js +94 -11
  18. package/src/api/planSkyFigures.d.ts +22 -0
  19. package/src/api/planSkyFigures.js +145 -0
  20. package/src/api/planStory.d.ts +2 -2
  21. package/src/api/planStory.js +14 -9
  22. package/src/api/planViews.js +1 -1
  23. package/src/api/scene.d.ts +17 -4
  24. package/src/api/scene.js +23 -5
  25. package/src/api/sceneReads.d.ts +21 -2
  26. package/src/api/skyFigureInput.d.ts +45 -0
  27. package/src/api/skyFigureInput.js +1 -0
  28. package/src/api/skyTraceInput.d.ts +33 -0
  29. package/src/api/skyTraceInput.js +45 -0
  30. package/src/api/story.d.ts +12 -3
  31. package/src/api/story.js +44 -1
  32. package/src/api/viewerCamera.d.ts +4 -3
  33. package/src/api/viewerCamera.js +10 -32
  34. package/src/api/viewerHandle.d.ts +27 -4
  35. package/src/api/viewerHandle.js +6 -0
  36. package/src/api/viewerLink.d.ts +49 -4
  37. package/src/api/viewerLink.js +25 -0
  38. package/src/api/viewerPanels.d.ts +26 -0
  39. package/src/api/viewerPanels.js +42 -0
  40. package/src/api/viewerSelection.d.ts +1 -1
  41. package/src/api/viewerSelection.js +3 -3
  42. package/src/app/App.js +100 -18
  43. package/src/app/App.node.js +100 -18
  44. package/src/app/AstraeusScene.d.ts +20 -5
  45. package/src/app/AstraeusScene.js +3 -3
  46. package/src/app/CameraController.d.ts +17 -0
  47. package/src/app/CameraController.js +34 -9
  48. package/src/app/DeveloperSettings.d.ts +11 -3
  49. package/src/app/DeveloperSettings.js +13 -3
  50. package/src/app/SceneLabels.d.ts +20 -2
  51. package/src/app/SceneLabels.js +46 -6
  52. package/src/app/SkyFiguresView.d.ts +56 -0
  53. package/src/app/SkyFiguresView.js +242 -0
  54. package/src/app/StoryMarkers.d.ts +2 -2
  55. package/src/app/StoryMarkers.js +2 -2
  56. package/src/app/displaySwitches.d.ts +13 -3
  57. package/src/app/displaySwitches.js +17 -3
  58. package/src/app/experienceDefinition.d.ts +9 -3
  59. package/src/app/experienceDefinition.js +4 -2
  60. package/src/app/labelStyle.d.ts +17 -0
  61. package/src/app/labelStyle.js +13 -0
  62. package/src/app/liveLook.js +8 -0
  63. package/src/app/look.d.ts +9 -5
  64. package/src/app/look.js +11 -0
  65. package/src/app/lookOut.d.ts +32 -0
  66. package/src/app/lookOut.js +50 -0
  67. package/src/app/sceneCamera.d.ts +5 -3
  68. package/src/app/sceneCamera.js +66 -3
  69. package/src/app/sceneContentsHooks.d.ts +2 -1
  70. package/src/app/sceneContentsHooks.js +3 -2
  71. package/src/app/sceneFrame.d.ts +10 -1
  72. package/src/app/sceneFrame.js +45 -10
  73. package/src/app/sceneFraming.d.ts +7 -0
  74. package/src/app/sceneFraming.js +12 -0
  75. package/src/app/sceneHooks.d.ts +2 -0
  76. package/src/app/sceneHooks.js +4 -1
  77. package/src/app/scenePicking.d.ts +20 -0
  78. package/src/app/scenePicking.js +49 -0
  79. package/src/app/scenePointer.d.ts +3 -1
  80. package/src/app/scenePointer.js +3 -2
  81. package/src/app/skyFigures.d.ts +73 -0
  82. package/src/app/skyFigures.js +50 -0
  83. package/src/app/style.css +2 -1
  84. package/src/app/viewHiding.d.ts +2 -0
  85. package/src/app/viewHiding.js +7 -1
  86. package/src/app/viewLink.d.ts +8 -8
  87. package/src/app/viewLink.js +24 -4
  88. package/src/app/viewerPort.d.ts +30 -3
  89. package/src/assets/sky.d.ts +13 -4
  90. package/src/assets/sky.js +33 -8
  91. package/src/assets/stars/hyg-v42-naked-eye.json +1 -1
  92. package/src/core/bodies/moonSystem.js +1 -15
  93. package/src/core/lookValues.d.ts +9 -0
  94. package/src/core/lookValues.js +24 -0
  95. package/src/core/readBytes.d.ts +1 -0
  96. package/src/core/readBytes.js +15 -0
  97. package/src/core/skyTrace.d.ts +49 -0
  98. package/src/core/skyTrace.js +39 -0
  99. package/src/core/startView.d.ts +39 -0
  100. package/src/core/startView.js +56 -0
  101. package/src/core/storyPanels.d.ts +51 -3
  102. package/src/core/storyPanels.js +52 -12
  103. package/src/shell/AstraeusShell.d.ts +15 -6
  104. package/src/shell/AstraeusShell.js +76 -20
  105. package/src/shell/AstraeusShell.node.js +76 -20
  106. package/src/shell/ObjectControls.js +11 -8
  107. package/src/shell/StoryPanelView.d.ts +12 -3
  108. package/src/shell/StoryPanelView.js +2 -2
  109. package/src/shell/experience.d.ts +24 -0
  110. package/src/shell/experience.js +4 -1
  111. package/src/shell/infoModel.js +9 -1
  112. package/src/shell/objectModel.d.ts +6 -2
  113. package/src/shell/objectModel.js +10 -1
  114. package/src/shell/phone.css +1 -1
  115. package/src/shell/storyPanels.d.ts +1 -1
  116. package/src/shell/storyPanels.js +1 -1
  117. package/src/shell/style.css +9 -1
  118. package/src/shell/topBarIcons.d.ts +1 -0
  119. package/src/shell/topBarIcons.js +1 -0
  120. package/src/shell/useStoryPanels.d.ts +9 -6
  121. package/src/shell/useStoryPanels.js +10 -6
@@ -1,5 +1,6 @@
1
1
  import { provenanceAt, rateAt, spanProvenanceAt } from "../core/timeWindow.js";
2
2
  import { findFeature } from "./bodyFeatures.js";
3
+ import { skyFigureById } from "./objectModel.js";
3
4
  import { formatUtcTimestamp, formatWindowRate } from "./timelineModel.js";
4
5
  /** The badge text for each provenance status. The status is always written, never shown by colour alone. */
5
6
  export const PROVENANCE_STATUS = {
@@ -59,7 +60,7 @@ function featureInfo(experience, target) {
59
60
  function objectInfo(experience, target, timeUtcMs) {
60
61
  const object = experience.objects.find((candidate) => candidate.id === target.id);
61
62
  if (object === undefined)
62
- return null;
63
+ return skyFigureInfo(experience, target);
63
64
  const source = (timeUtcMs === undefined || object.provenanceSpans === undefined ? null : spanProvenanceAt(object.provenanceSpans, timeUtcMs)) ?? object.provenance;
64
65
  return {
65
66
  target,
@@ -81,3 +82,10 @@ function eventInfo(experience, target) {
81
82
  provenance: source === undefined ? null : provenanceView(source),
82
83
  };
83
84
  }
85
+ /** The card of a selected sky figure: the same card a body has (description, facts, provenance), with the kind as its subtitle. */
86
+ function skyFigureInfo(experience, target) {
87
+ const figure = skyFigureById(experience, target.id);
88
+ if (figure === undefined)
89
+ return null;
90
+ return { target, title: figure.label, ...(figure.description === undefined ? {} : { description: figure.description }), ...(figure.facts === undefined ? {} : { facts: figure.facts }), provenance: provenanceView(figure.provenance) };
91
+ }
@@ -1,5 +1,5 @@
1
- import type { ExperienceCameraPreset, ExperienceConfig, ExperienceObject } from "./experience.js";
2
- export type CameraMode = "overview" | "focus" | "follow";
1
+ import { type ExperienceCameraPreset, type ExperienceConfig, type ExperienceObject, type SkyFigureCard } from "./experience.js";
2
+ export type CameraMode = "overview" | "focus" | "follow" | "lookOut";
3
3
  export declare function isObjectAvailable(object: ExperienceObject, timeUtcMs: number): boolean;
4
4
  export declare function availableObjectById(experience: ExperienceConfig, id: string, timeUtcMs: number): ExperienceObject | undefined;
5
5
  export declare function firstAvailableObject(experience: ExperienceConfig, timeUtcMs: number): ExperienceObject | undefined;
@@ -16,3 +16,7 @@ export declare function findCameraPreset(experience: ExperienceConfig, mode: Cam
16
16
  export declare function listedObjects(experience: ExperienceConfig, selectedId: string): readonly ExperienceObject[];
17
17
  /** Unlisted objects that belong to `id` (an orbit line to its body), for the related buttons in the top bar. */
18
18
  export declare function relatedObjects(experience: ExperienceConfig, id: string): readonly ExperienceObject[];
19
+ /** The sky figure a selected id names, or undefined (object ids and figure ids never collide: the scene checks it). */
20
+ export declare function skyFigureById(experience: ExperienceConfig, id: string): SkyFigureCard | undefined;
21
+ /** The sky figures the Object list offers, under the rule objects follow (`listed`): the listed ones, and the selected one even when unlisted. */
22
+ export declare function listedFigures(experience: ExperienceConfig, selectedId: string): readonly SkyFigureCard[];
@@ -1,3 +1,4 @@
1
+ import { requestObjectId } from "./experience.js";
1
2
  export function isObjectAvailable(object, timeUtcMs) {
2
3
  const bounds = object.availability;
3
4
  return bounds === undefined || (timeUtcMs >= bounds.startUtcMs && timeUtcMs <= bounds.endUtcMs);
@@ -21,7 +22,7 @@ export function findCameraPreset(experience, mode, target) {
21
22
  const request = preset.request;
22
23
  if (request.kind === "overview")
23
24
  return mode === "overview";
24
- return request.kind === mode && request.target === target;
25
+ return request.kind === mode && requestObjectId(request) === target;
25
26
  });
26
27
  }
27
28
  /** The objects the Object list offers: the listed ones, and the selected one even when unlisted so the list never shows a blank. */
@@ -32,3 +33,11 @@ export function listedObjects(experience, selectedId) {
32
33
  export function relatedObjects(experience, id) {
33
34
  return experience.objects.filter((object) => object.listed === false && object.partOf === id);
34
35
  }
36
+ /** The sky figure a selected id names, or undefined (object ids and figure ids never collide: the scene checks it). */
37
+ export function skyFigureById(experience, id) {
38
+ return experience.skyFigures?.find((figure) => figure.id === id);
39
+ }
40
+ /** The sky figures the Object list offers, under the rule objects follow (`listed`): the listed ones, and the selected one even when unlisted. */
41
+ export function listedFigures(experience, selectedId) {
42
+ return (experience.skyFigures ?? []).filter((figure) => figure.listed || figure.id === selectedId);
43
+ }
@@ -172,7 +172,7 @@
172
172
  padding: 9px;
173
173
  }
174
174
  .astraeus-shell[data-phone="true"] .shell-top { top: 8px; left: 8px; width: calc(100vw - 16px); max-width: calc(100vw - 16px); max-height: none; }
175
- .astraeus-shell[data-phone="true"] .astraeus-label { font-size: 12px; }
175
+ .astraeus-shell[data-phone="true"] .astraeus-label { font-size: var(--label-size, 12px); }
176
176
 
177
177
  @media (prefers-reduced-motion: reduce) {
178
178
  .astraeus-shell .controls-drawer,
@@ -1,5 +1,5 @@
1
1
  import type { StoryPanel } from "../core/storyPanels.js";
2
- export { checkPanelPlayback, checkStoryPanel, DEFAULT_PANEL_PAUSE_SECONDS, MAX_PANEL_PAUSE_SECONDS, resolveStoryPanels, StoryPanelError, type PanelLookup, type StoryPanel, type StoryPanelSet, } from "../core/storyPanels.js";
2
+ export { checkPanelPlayback, checkStoryPanel, DEFAULT_PANEL_PAUSE_SECONDS, MAX_PANEL_PAUSE_SECONDS, resolveStoryPanels, StoryPanelError, type PanelLookup, type StoryPanel, type StoryPanelSet, type StoryStep, neighbourStep, } from "../core/storyPanels.js";
3
3
  /**
4
4
  * The panels forward playback just passed: those with `previousMs < time <= currentMs`, in time order.
5
5
  * A backward step or no movement crosses nothing, so loops and rewinds never open a panel.
@@ -1,4 +1,4 @@
1
- export { checkPanelPlayback, checkStoryPanel, DEFAULT_PANEL_PAUSE_SECONDS, MAX_PANEL_PAUSE_SECONDS, resolveStoryPanels, StoryPanelError, } from "../core/storyPanels.js";
1
+ export { checkPanelPlayback, checkStoryPanel, DEFAULT_PANEL_PAUSE_SECONDS, MAX_PANEL_PAUSE_SECONDS, resolveStoryPanels, StoryPanelError, neighbourStep, } from "../core/storyPanels.js";
2
2
  /**
3
3
  * The panels forward playback just passed: those with `previousMs < time <= currentMs`, in time order.
4
4
  * A backward step or no movement crosses nothing, so loops and rewinds never open a panel.
@@ -94,7 +94,8 @@
94
94
  border-radius: 5px;
95
95
  background: rgba(13, 13, 13, .84);
96
96
  color: var(--label-color, #f0e6da);
97
- font-size: 12px;
97
+ font-family: var(--label-font, inherit);
98
+ font-size: var(--label-size, 12px);
98
99
  line-height: 1.35;
99
100
  text-overflow: ellipsis;
100
101
  white-space: nowrap;
@@ -250,6 +251,13 @@
250
251
  .astraeus-shell .sources-section li + li { margin-top: 3px; }
251
252
  .astraeus-shell :where(.story-panel-close) { font-size: 20px; line-height: 1; }
252
253
  .astraeus-shell :where(.story-panel-continue) { align-self: flex-start; }
254
+ /* Touch targets: Close, Back, Next and Continue are at least 44 px each way, at 375x667 and 1280x720 alike. */
255
+ .astraeus-shell :where(.story-panel-close, .story-panel-back, .story-panel-next, .story-panel-continue) { min-width: 44px; min-height: 44px; }
256
+ /* Steps: Back and Next stay at the foot of the panel as it scrolls; the count between them shrinks and wraps before either button does. */
257
+ .astraeus-shell .story-panel-steps { position: sticky; bottom: -14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 -14px -14px; padding: 6px 14px 14px; background: var(--ui-panel, rgba(13, 13, 13, .94)); }
258
+ .astraeus-shell .story-panel-step-count { flex: 1 1 auto; min-width: 0; text-align: center; color: var(--ui-subtle, #a99e94); font-size: 13px; overflow-wrap: anywhere; }
259
+ .astraeus-shell .story-panel-steps button { flex: 0 0 auto; }
260
+ .astraeus-shell .story-panel-steps button:disabled { opacity: .4; cursor: default; }
253
261
 
254
262
  /* The badge: monospace caps pill, tinted by how far to trust the facts. */
255
263
  .astraeus-shell .story-badge {
@@ -3,6 +3,7 @@ export declare const InfoIcon: () => import("react").JSX.Element;
3
3
  export declare const FocusIcon: () => import("react").JSX.Element;
4
4
  export declare const OverviewIcon: () => import("react").JSX.Element;
5
5
  export declare const FollowIcon: () => import("react").JSX.Element;
6
+ export declare const LookOutIcon: () => import("react").JSX.Element;
6
7
  export declare const OrbitIcon: () => import("react").JSX.Element;
7
8
  export declare const SwitchesIcon: () => import("react").JSX.Element;
8
9
  export declare const ScaleIcon: () => import("react").JSX.Element;
@@ -7,6 +7,7 @@ export const InfoIcon = () => _jsxs(Icon, { children: [_jsx("circle", { cx: "12"
7
7
  export const FocusIcon = () => _jsxs(Icon, { children: [_jsx("circle", { cx: "10.5", cy: "10.5", r: "6.5" }), _jsx("path", { d: "M15.5 15.5 21 21" })] });
8
8
  export const OverviewIcon = () => _jsx(Icon, { children: _jsx("path", { d: "M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5" }) });
9
9
  export const FollowIcon = () => _jsxs(Icon, { children: [_jsx("circle", { cx: "12", cy: "12", r: "4" }), _jsx("path", { d: "M12 3v4M12 17v4M3 12h4M17 12h4" })] });
10
+ export const LookOutIcon = () => _jsxs(Icon, { children: [_jsx("path", { d: "M3 17h18" }), _jsx("path", { d: "M12 14V5M8.5 8.5 12 5l3.5 3.5" })] });
10
11
  export const OrbitIcon = () => _jsxs(Icon, { children: [_jsx("ellipse", { cx: "12", cy: "12", rx: "9", ry: "5", transform: "rotate(-20 12 12)" }), _jsx("circle", { cx: "12", cy: "12", r: "1.4", fill: "currentColor" })] });
11
12
  export const SwitchesIcon = () => _jsxs(Icon, { children: [_jsx("path", { d: "M4 8h10M18 8h2M4 16h2M10 16h10" }), _jsx("circle", { cx: "16", cy: "8", r: "2" }), _jsx("circle", { cx: "8", cy: "16", r: "2" })] });
12
13
  export const ScaleIcon = () => _jsxs(Icon, { size: 16, children: [_jsx("circle", { cx: "7", cy: "12", r: "2.5" }), _jsx("circle", { cx: "16", cy: "12", r: "5.5" })] });
@@ -1,19 +1,22 @@
1
1
  import type { ClockSnapshot } from "../core/clock.js";
2
- import { type StoryPanel } from "./storyPanels.js";
2
+ import { type StoryPanel, type StoryStep } from "./storyPanels.js";
3
3
  export interface StoryPanelSettings {
4
4
  readonly autoOpen: boolean;
5
5
  readonly pauseSeconds: number;
6
6
  }
7
+ /** Who opened or closed the panel: the visitor, the host, playback crossing a panel, or a move (a view switch dropped it; the link names whatever last moved the view). */
8
+ export type PanelCause = "visitor" | "host" | "playback" | "move";
7
9
  /**
8
10
  * Which story panel is open and whether playback is held for it. A panel opens by itself only when forward playback
9
11
  * carries the clock across its time; a seek (slider, Previous, Next, a link) re-bases the crossing check and opens nothing.
10
- * Only one panel is open at a time: the newest replaces the one before.
12
+ * Only one panel is open at a time: the newest replaces the one before. A step never opens from playback; with steps and no moment panel the first step is open at the start.
11
13
  */
12
- export declare function useStoryPanels(panels: readonly StoryPanel[], settings: StoryPanelSettings, snapshot: ClockSnapshot, setPlaying: ((playing: boolean) => void) | undefined): {
13
- openPanel: StoryPanel | null;
14
+ export declare function useStoryPanels(panels: readonly StoryPanel[], steps: readonly StoryStep[], settings: StoryPanelSettings, snapshot: ClockSnapshot, setPlaying: ((playing: boolean) => void) | undefined): {
15
+ openPanel: StoryPanel | StoryStep | null;
14
16
  holding: boolean;
15
- open: (id: string) => void;
16
- close: () => void;
17
+ open: (id: string, by?: PanelCause) => void;
18
+ close: (by?: PanelCause) => void;
17
19
  continuePlayback: () => void;
18
20
  noteSeek: (timeUtcMs: number) => void;
21
+ cause: PanelCause;
19
22
  };
@@ -3,10 +3,11 @@ import { CrossingTracker } from "./storyPanels.js";
3
3
  /**
4
4
  * Which story panel is open and whether playback is held for it. A panel opens by itself only when forward playback
5
5
  * carries the clock across its time; a seek (slider, Previous, Next, a link) re-bases the crossing check and opens nothing.
6
- * Only one panel is open at a time: the newest replaces the one before.
6
+ * Only one panel is open at a time: the newest replaces the one before. A step never opens from playback; with steps and no moment panel the first step is open at the start.
7
7
  */
8
- export function useStoryPanels(panels, settings, snapshot, setPlaying) {
9
- const [openId, setOpenId] = useState(null);
8
+ export function useStoryPanels(panels, steps, settings, snapshot, setPlaying) {
9
+ const [openId, setOpenId] = useState(() => (panels.length === 0 ? steps[0]?.id ?? null : null));
10
+ const cause = useRef("visitor");
10
11
  const [holding, setHolding] = useState(false);
11
12
  const tracker = useRef(new CrossingTracker(snapshot.timeUtcMs));
12
13
  const latest = useRef({ panels, settings, snapshot, setPlaying, holding });
@@ -16,6 +17,7 @@ export function useStoryPanels(panels, settings, snapshot, setPlaying) {
16
17
  const newest = tracker.current.advance(list, shot.timeUtcMs, shot.playing, now.autoOpen);
17
18
  if (newest === null)
18
19
  return;
20
+ cause.current = "playback";
19
21
  setOpenId(newest.id);
20
22
  if (now.pauseSeconds > 0 && control !== undefined) {
21
23
  control(false);
@@ -40,8 +42,9 @@ export function useStoryPanels(panels, settings, snapshot, setPlaying) {
40
42
  tracker.current.rebase(timeUtcMs);
41
43
  setHolding(false);
42
44
  }, []);
43
- const open = useCallback((id) => setOpenId(id), []);
44
- const close = useCallback(() => {
45
+ const open = useCallback((id, by = "visitor") => { cause.current = by; setOpenId(id); }, []);
46
+ const close = useCallback((by = "visitor") => {
47
+ cause.current = by;
45
48
  setOpenId(null);
46
49
  if (latest.current.holding)
47
50
  latest.current.setPlaying?.(true);
@@ -51,5 +54,6 @@ export function useStoryPanels(panels, settings, snapshot, setPlaying) {
51
54
  setHolding(false);
52
55
  latest.current.setPlaying?.(true);
53
56
  }, []);
54
- return { openPanel: panels.find((panel) => panel.id === openId) ?? null, holding, open, close, continuePlayback, noteSeek };
57
+ const openPanel = panels.find((panel) => panel.id === openId) ?? steps.find((step) => step.id === openId) ?? null;
58
+ return { openPanel, holding, open, close, continuePlayback, noteSeek, cause: openPanel === null && openId !== null ? "move" : cause.current };
55
59
  }