astraeus 0.7.0 → 0.8.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 (271) hide show
  1. package/CHANGELOG.md +176 -0
  2. package/README.md +185 -37
  3. package/package.json +5 -4
  4. package/src/api/AstraeusScene.d.ts +21 -5
  5. package/src/api/AstraeusScene.js +34 -10
  6. package/src/api/AstraeusScene.node.js +34 -10
  7. package/src/api/assembleScene.d.ts +36 -0
  8. package/src/api/assembleScene.js +175 -0
  9. package/src/api/bodySetChecks.d.ts +10 -0
  10. package/src/api/bodySetChecks.js +117 -0
  11. package/src/api/bodySetInput.d.ts +81 -0
  12. package/src/api/bodySetInput.js +1 -0
  13. package/src/api/containingBlock.d.ts +6 -0
  14. package/src/api/containingBlock.js +16 -0
  15. package/src/api/data.d.ts +17 -5
  16. package/src/api/data.js +28 -10
  17. package/src/api/definitionOf.d.ts +16 -0
  18. package/src/api/definitionOf.js +20 -0
  19. package/src/api/errors.d.ts +61 -1
  20. package/src/api/frozenCopy.d.ts +6 -0
  21. package/src/api/frozenCopy.js +26 -0
  22. package/src/api/group.d.ts +8 -2
  23. package/src/api/group.js +24 -5
  24. package/src/api/index.d.ts +18 -7
  25. package/src/api/index.js +2 -2
  26. package/src/api/index.node.js +2 -2
  27. package/src/api/listeners.d.ts +5 -0
  28. package/src/api/listeners.js +25 -0
  29. package/src/api/look.d.ts +47 -0
  30. package/src/api/look.js +1 -0
  31. package/src/api/lookInput.d.ts +3 -0
  32. package/src/api/lookInput.js +41 -0
  33. package/src/api/moonPanelInput.d.ts +60 -0
  34. package/src/api/moonPanelInput.js +1 -0
  35. package/src/api/mount.d.ts +9 -19
  36. package/src/api/mount.js +27 -13
  37. package/src/api/mount.node.js +27 -13
  38. package/src/api/pathProvenance.js +1 -1
  39. package/src/api/pickerInput.d.ts +25 -0
  40. package/src/api/pickerInput.js +1 -0
  41. package/src/api/planBodies.d.ts +72 -0
  42. package/src/api/planBodies.js +300 -0
  43. package/src/api/planBodySets.d.ts +68 -0
  44. package/src/api/planBodySets.js +234 -0
  45. package/src/api/planCamera.d.ts +83 -0
  46. package/src/api/planCamera.js +184 -0
  47. package/src/api/planGroups.d.ts +36 -0
  48. package/src/api/planGroups.js +103 -0
  49. package/src/api/planMoonPanel.d.ts +19 -0
  50. package/src/api/planMoonPanel.js +104 -0
  51. package/src/api/planPaths.d.ts +40 -0
  52. package/src/api/planPaths.js +212 -0
  53. package/src/api/planPicker.d.ts +12 -0
  54. package/src/api/planPicker.js +40 -0
  55. package/src/api/planPlaces.d.ts +16 -0
  56. package/src/api/planPlaces.js +99 -0
  57. package/src/api/planStory.d.ts +26 -0
  58. package/src/api/planStory.js +66 -0
  59. package/src/api/planTimeline.d.ts +27 -0
  60. package/src/api/planTimeline.js +68 -0
  61. package/src/api/planViews.d.ts +25 -0
  62. package/src/api/planViews.js +35 -0
  63. package/src/api/prepared.js +4 -1
  64. package/src/api/renamedInputs.d.ts +15 -0
  65. package/src/api/renamedInputs.js +39 -0
  66. package/src/api/scene.d.ts +162 -68
  67. package/src/api/scene.js +247 -793
  68. package/src/api/sceneFreeze.d.ts +4 -0
  69. package/src/api/sceneFreeze.js +10 -0
  70. package/src/api/sceneReads.d.ts +171 -0
  71. package/src/api/sceneReads.js +6 -0
  72. package/src/api/story.d.ts +49 -19
  73. package/src/api/story.js +54 -22
  74. package/src/api/sunOrbit.js +9 -11
  75. package/src/api/time.d.ts +2 -1
  76. package/src/api/time.js +2 -1
  77. package/src/api/viewerCamera.d.ts +22 -0
  78. package/src/api/viewerCamera.js +84 -0
  79. package/src/api/viewerClock.d.ts +30 -0
  80. package/src/api/viewerClock.js +85 -0
  81. package/src/api/viewerFirstDraw.d.ts +14 -0
  82. package/src/api/viewerFirstDraw.js +26 -0
  83. package/src/api/viewerHandle.d.ts +79 -0
  84. package/src/api/viewerHandle.js +31 -0
  85. package/src/api/viewerLink.d.ts +87 -15
  86. package/src/api/viewerLink.js +111 -75
  87. package/src/api/viewerLooks.d.ts +19 -0
  88. package/src/api/viewerLooks.js +37 -0
  89. package/src/api/viewerPicker.d.ts +22 -0
  90. package/src/api/viewerPicker.js +49 -0
  91. package/src/api/viewerSelection.d.ts +25 -0
  92. package/src/api/viewerSelection.js +31 -0
  93. package/src/api/viewerViews.d.ts +10 -0
  94. package/src/api/viewerViews.js +18 -0
  95. package/src/api/viewerZones.d.ts +20 -0
  96. package/src/api/viewerZones.js +47 -0
  97. package/src/api/views.d.ts +4 -5
  98. package/src/api/views.js +7 -5
  99. package/src/app/App.d.ts +5 -3
  100. package/src/app/App.js +191 -82
  101. package/src/app/App.node.js +191 -82
  102. package/src/app/AstraeusScene.d.ts +16 -2
  103. package/src/app/AstraeusScene.js +4 -4
  104. package/src/app/BodyView.d.ts +4 -1
  105. package/src/app/BodyView.js +2 -2
  106. package/src/app/CameraController.d.ts +6 -0
  107. package/src/app/DeveloperSettings.d.ts +1 -4
  108. package/src/app/DeveloperSettings.js +6 -10
  109. package/src/app/FeatureMarkers.d.ts +4 -3
  110. package/src/app/FeatureMarkers.js +8 -13
  111. package/src/app/FrameRateSection.js +2 -1
  112. package/src/app/OrbitSetView.js +1 -1
  113. package/src/app/SettingControls.d.ts +11 -3
  114. package/src/app/SettingControls.js +10 -2
  115. package/src/app/SkyView.d.ts +3 -10
  116. package/src/app/SkyView.js +6 -28
  117. package/src/app/address.d.ts +16 -0
  118. package/src/app/address.js +31 -0
  119. package/src/app/bodyDraw.d.ts +10 -7
  120. package/src/app/bodyDraw.js +12 -32
  121. package/src/app/bodyMetrics.js +2 -2
  122. package/src/app/bodySet.d.ts +4 -20
  123. package/src/app/bodySet.js +5 -16
  124. package/src/app/debugReadout.js +1 -1
  125. package/src/app/displaySwitches.d.ts +4 -0
  126. package/src/app/displaySwitches.js +6 -0
  127. package/src/app/experienceDefinition.d.ts +11 -23
  128. package/src/app/listSwitch.d.ts +8 -14
  129. package/src/app/listSwitch.js +3 -10
  130. package/src/app/liveLook.d.ts +39 -0
  131. package/src/app/liveLook.js +66 -0
  132. package/src/app/look.d.ts +36 -0
  133. package/src/app/look.js +61 -0
  134. package/src/app/mission.d.ts +1 -1
  135. package/src/app/mission.js +1 -1
  136. package/src/app/openClock.d.ts +3 -2
  137. package/src/app/openClock.js +3 -3
  138. package/src/app/sceneCamera.js +9 -0
  139. package/src/app/sceneFrame.d.ts +4 -4
  140. package/src/app/sceneFrame.js +13 -8
  141. package/src/app/sceneHooks.js +3 -2
  142. package/src/app/style.css +114 -139
  143. package/src/app/trackedMetrics.d.ts +10 -3
  144. package/src/app/trackedMetrics.js +22 -11
  145. package/src/app/viewLink.d.ts +10 -32
  146. package/src/app/viewLink.js +10 -49
  147. package/src/app/viewerPort.d.ts +50 -0
  148. package/src/app/views.d.ts +1 -0
  149. package/src/assets/bodies/galileanMoons.js +1 -2
  150. package/src/assets/bodies/io.js +2 -2
  151. package/src/assets/bodies/listedMoons.d.ts +1 -1
  152. package/src/assets/bodies/listedMoons.js +2 -3
  153. package/src/assets/bodies/planetSystemMaps.js +2 -3
  154. package/src/assets/bodies/venus.js +2 -6
  155. package/src/assets/catalogue.js +1 -2
  156. package/src/assets/licence.d.ts +3 -3
  157. package/src/assets/licence.js +3 -3
  158. package/src/assets/pictures.d.ts +15 -12
  159. package/src/assets/pictures.js +24 -20
  160. package/src/assets/sky.d.ts +6 -5
  161. package/src/assets/sky.js +6 -9
  162. package/src/assets/visual.d.ts +4 -0
  163. package/src/core/bodies/index.d.ts +0 -4
  164. package/src/core/bodies/index.js +1 -6
  165. package/src/core/bodies/jupiterData.d.ts +0 -1
  166. package/src/core/bodies/jupiterData.js +2 -5
  167. package/src/core/bodies/moonSystem.d.ts +1 -1
  168. package/src/core/bodies/moonSystem.js +102 -55
  169. package/src/core/bodies/outerPlanetRingData.js +2 -2
  170. package/src/core/bodies/planetTrajectory.js +1 -1
  171. package/src/core/bodySetFamilies.d.ts +20 -0
  172. package/src/core/bodySetFamilies.js +14 -0
  173. package/src/core/chebyshevEphemeris.js +1 -1
  174. package/src/core/elementsBody.d.ts +8 -4
  175. package/src/core/elementsBody.js +32 -11
  176. package/src/core/elementsGroup.d.ts +27 -0
  177. package/src/core/elementsGroup.js +85 -0
  178. package/src/core/events.d.ts +2 -0
  179. package/src/core/events.js +2 -0
  180. package/src/core/illumination.js +1 -1
  181. package/src/core/listedOrbitGroup.d.ts +2 -0
  182. package/src/core/listedOrbitGroup.js +11 -7
  183. package/src/core/moonListText.d.ts +6 -0
  184. package/src/core/moonListText.js +19 -0
  185. package/src/core/moonTrajectory.js +1 -1
  186. package/src/core/pacing.d.ts +38 -3
  187. package/src/core/pacing.js +55 -4
  188. package/src/core/planetModels.js +2 -2
  189. package/src/core/planetSeries.d.ts +8 -0
  190. package/src/core/planetSeries.js +16 -2
  191. package/src/core/pointGroup.js +1 -1
  192. package/src/core/provenance.d.ts +2 -1
  193. package/src/core/provenance.js +2 -2
  194. package/src/core/referenceCenters.js +5 -5
  195. package/src/core/sampledTrajectory.js +1 -1
  196. package/src/core/scalePolicy.d.ts +1 -0
  197. package/src/core/startView.d.ts +19 -0
  198. package/src/core/startView.js +28 -0
  199. package/src/core/state.d.ts +6 -2
  200. package/src/core/state.js +3 -3
  201. package/src/core/storyPanels.d.ts +63 -0
  202. package/src/core/storyPanels.js +111 -0
  203. package/src/core/sunCentredSources.d.ts +4 -0
  204. package/src/core/sunCentredSources.js +9 -2
  205. package/src/core/timeInput.d.ts +4 -0
  206. package/src/core/timeInput.js +4 -0
  207. package/src/shell/AstraeusShell.d.ts +5 -1
  208. package/src/shell/AstraeusShell.js +20 -11
  209. package/src/shell/AstraeusShell.node.js +20 -11
  210. package/src/shell/Collapsible.d.ts +4 -3
  211. package/src/shell/Collapsible.js +5 -5
  212. package/src/shell/ControlsDrawer.d.ts +1 -1
  213. package/src/shell/ControlsDrawer.js +3 -1
  214. package/src/shell/DisplaySwitches.js +2 -1
  215. package/src/shell/InfoPanel.d.ts +3 -1
  216. package/src/shell/InfoPanel.js +5 -4
  217. package/src/shell/MoonFamilyPanel.js +1 -1
  218. package/src/shell/ObjectControls.d.ts +3 -1
  219. package/src/shell/ObjectControls.js +2 -2
  220. package/src/shell/Sources.d.ts +5 -3
  221. package/src/shell/Sources.js +5 -5
  222. package/src/shell/StoryPanelView.d.ts +4 -3
  223. package/src/shell/StoryPanelView.js +8 -6
  224. package/src/shell/SwitchControl.d.ts +5 -11
  225. package/src/shell/SwitchControl.js +2 -20
  226. package/src/shell/TimelineBar.css +81 -81
  227. package/src/shell/TimelineBar.d.ts +5 -2
  228. package/src/shell/TimelineBar.js +9 -8
  229. package/src/shell/TimelineBar.node.js +9 -8
  230. package/src/shell/TopBar.css +22 -22
  231. package/src/shell/TopBar.d.ts +5 -1
  232. package/src/shell/TopBar.js +2 -2
  233. package/src/shell/TopBar.node.js +2 -2
  234. package/src/shell/bootLoader.d.ts +4 -10
  235. package/src/shell/bootLoader.js +6 -52
  236. package/src/shell/embedded.css +18 -18
  237. package/src/shell/experience.d.ts +1 -1
  238. package/src/shell/moonFamilies.d.ts +2 -6
  239. package/src/shell/moonFamilies.js +2 -18
  240. package/src/shell/phone.css +58 -58
  241. package/src/shell/storyPanels.d.ts +2 -53
  242. package/src/shell/storyPanels.js +1 -106
  243. package/src/shell/style.css +153 -134
  244. package/src/shell/useDrawers.d.ts +3 -2
  245. package/src/shell/useDrawers.js +4 -3
  246. package/src/shell/viewerKeys.d.ts +8 -0
  247. package/src/shell/viewerKeys.js +16 -0
  248. package/src/synthetic/syntheticDefinition.js +20 -24
  249. package/src/synthetic/syntheticJourneyScene.js +3 -3
  250. package/src/synthetic/syntheticProbeDefinition.js +2 -1
  251. package/src/synthetic/syntheticViewsDefinition.d.ts +0 -3
  252. package/src/synthetic/syntheticViewsDefinition.js +10 -16
  253. package/data/moons/jupiter.json +0 -3333
  254. package/data/moons/neptune.json +0 -555
  255. package/data/moons/pluto.json +0 -205
  256. package/data/moons/saturn.json +0 -8267
  257. package/data/moons/uranus.json +0 -887
  258. package/src/app/addressNavigation.d.ts +0 -17
  259. package/src/app/addressNavigation.js +0 -16
  260. package/src/assets/bodies/jupiterMoonCatalogue.d.ts +0 -3
  261. package/src/assets/bodies/jupiterMoonCatalogue.js +0 -4
  262. package/src/assets/bodies/outerPlanetCatalogues.d.ts +0 -7
  263. package/src/assets/bodies/outerPlanetCatalogues.js +0 -8
  264. package/src/assets/bodies/swiftTuttle.d.ts +0 -12
  265. package/src/assets/bodies/swiftTuttle.js +0 -13
  266. package/src/assets/moonCatalogue.d.ts +0 -49
  267. package/src/assets/moonCatalogue.js +0 -80
  268. package/src/core/bodies/outerPlanetData.d.ts +0 -4
  269. package/src/core/bodies/outerPlanetData.js +0 -13
  270. package/src/core/bodies/swiftTuttle.d.ts +0 -46
  271. package/src/core/bodies/swiftTuttle.js +0 -106
@@ -0,0 +1,103 @@
1
+ import { planActivity, rateMetricOf } from "./activity.js";
2
+ import { SceneError } from "./errors.js";
3
+ import { frozenCopy } from "./frozenCopy.js";
4
+ import { frozenList } from "./sceneReads.js";
5
+ import { buildGroupLayer, groupCardProvenance, groupDescription, groupLimitations, planGroup } from "./group.js";
6
+ /** Whether a group is built late, in `prepare`: a clump near a body reads its position, so needs the planet series, which are not in yet. */
7
+ export function lateGroups(seriesIn) {
8
+ return (plan) => !seriesIn && plan.input.clump !== undefined;
9
+ }
10
+ /** The scene's layers: the points layer and the groups only when a group was added. */
11
+ export function groupLayersEntry(layers, hasGroups, sunCentred) {
12
+ const sceneLayers = ["tracked-bodies", ...(hasGroups ? ["points"] : []), ...(sunCentred ? ["sun-centred"] : [])];
13
+ return hasGroups ? { sceneLayers, groups: layers } : { sceneLayers };
14
+ }
15
+ /** What a `Scene` has planned for its groups and activities. */
16
+ export class GroupPlan {
17
+ groups = new Map();
18
+ activities = new Map();
19
+ #catalogue;
20
+ #taken;
21
+ /** `catalogue` gives the scene's catalogue as it stands; `taken` says whether the scene already holds an id. */
22
+ constructor(catalogue, taken) {
23
+ this.#catalogue = catalogue;
24
+ this.#taken = taken;
25
+ }
26
+ addGroup(input) {
27
+ const plan = planGroup(input, this.#catalogue());
28
+ if (this.#taken(plan.id))
29
+ throw new SceneError("duplicate-id", `addGroup("${plan.id}"): that id is already in the scene`);
30
+ this.groups.set(plan.id, plan);
31
+ }
32
+ addActivity(input) {
33
+ const plan = planActivity(input);
34
+ if (this.activities.has(plan.window.id))
35
+ throw new SceneError("duplicate-id", `addActivity("${plan.window.id}"): an activity with that id is already in the scene`);
36
+ this.activities.set(plan.window.id, plan);
37
+ }
38
+ /** Checks the groups against the finished scene: each circles its centre (default the scene's first body), which and whose clump body the scene must hold. */
39
+ check(ids) {
40
+ for (const plan of this.groups.values()) {
41
+ const center = plan.input.center ?? ids[0];
42
+ const clump = plan.input.clump;
43
+ if (!ids.includes(center))
44
+ throw new SceneError("bad-group", `addGroup("${plan.id}"): the orbits circle "${center}", which has not been added to the scene`);
45
+ if (clump !== undefined && !ids.includes(clump.near))
46
+ throw new SceneError("bad-group", `addGroup("${plan.id}"): clump.near "${clump.near}" has not been added to the scene`);
47
+ if (clump !== undefined && clump.near === center)
48
+ throw new SceneError("bad-group", `addGroup("${plan.id}"): the clump cannot be near the body the orbits circle ("${center}")`);
49
+ }
50
+ }
51
+ /** The draw layers of the groups chosen by `which` (a clump near a planet reads its position, so needs the planet series). */
52
+ layers(ids, window, openUtcMs, which) {
53
+ return [...this.groups.values()].filter(which).map((plan) => buildGroupLayer(plan, this.#catalogue(), plan.input.center ?? ids[0], openUtcMs, window));
54
+ }
55
+ /** The activities in the order added, as the public list states them: fresh, frozen, nothing shared with the plan. */
56
+ activityReads() {
57
+ return frozenList([...this.activities.values()].map(({ window, peakValue, peakLabel }) => ({
58
+ id: window.id,
59
+ label: window.label,
60
+ unit: window.rate?.unit ?? "",
61
+ windowStartUtcMs: window.startUtcMs,
62
+ windowEndUtcMs: window.endUtcMs,
63
+ peak: Object.freeze({ label: peakLabel, value: peakValue, ...(window.peakUtcMs === undefined ? {} : { timeUtcMs: window.peakUtcMs }) }),
64
+ samples: frozenCopy((window.rate?.samples ?? []).map(({ timeUtcMs, value }) => ({ timeUtcMs, value }))),
65
+ ...(window.provenance === undefined ? {} : { provenance: frozenCopy(window.provenance.map(({ startUtcMs, endUtcMs, provenance }) => ({ stretchStartUtcMs: startUtcMs, stretchEndUtcMs: endUtcMs, provenance }))) }),
66
+ ...(window.type === undefined ? {} : { type: window.type }),
67
+ })));
68
+ }
69
+ /** The groups in the order added, as the public list states them; `first` is the scene's first body (the centre of a group that names none). */
70
+ reads(first) {
71
+ return frozenList([...this.groups.values()].map(({ id, label, input }) => ({
72
+ id,
73
+ label,
74
+ count: input.orbits.length,
75
+ center: input.center ?? first,
76
+ plane: input.plane,
77
+ provenance: groupCardProvenance(input),
78
+ description: groupDescription(input, input.orbits.length),
79
+ knownLimitations: Object.freeze(groupLimitations(input, this.#catalogue())),
80
+ })));
81
+ }
82
+ /** The activity windows, when any were added. */
83
+ windowsEntry() {
84
+ return this.activities.size === 0 ? {} : { windows: [...this.activities.values()].map((activity) => activity.window) };
85
+ }
86
+ /** The bars of a group's info card at a moment. */
87
+ metrics(id, timeUtcMs) {
88
+ return (this.groups.get(id)?.input.readouts ?? []).map((spec) => rateMetricOf(id, this.activities.get(spec.activity ?? this.#firstActivity()), timeUtcMs));
89
+ }
90
+ #firstActivity() {
91
+ return this.activities.keys().next().value;
92
+ }
93
+ /** A group's rate readout names an activity the scene holds. */
94
+ checkReadouts() {
95
+ for (const { id, input } of this.groups.values()) {
96
+ for (const spec of input.readouts ?? []) {
97
+ const named = spec.activity ?? (this.activities.size > 0 ? this.#firstActivity() : undefined);
98
+ if (named === undefined || !this.activities.has(named))
99
+ throw new SceneError("bad-readout", `addGroup("${id}"): readout rate ${named === undefined ? "needs an activity (addActivity)" : `names activity "${named}", which has not been added to the scene`}`);
100
+ }
101
+ }
102
+ }
103
+ }
@@ -0,0 +1,19 @@
1
+ import type { BodyCatalogue } from "../assets/catalogue.js";
2
+ import type { ExperienceDefinition } from "../app/experienceDefinition.js";
3
+ import type { MoonPanelInput } from "./moonPanelInput.js";
4
+ import { type SceneMoonPanelRead } from "./sceneReads.js";
5
+ type MoonFamilyList = NonNullable<ExperienceDefinition["experience"]["moonFamilies"]>;
6
+ /** What a `Scene` has planned for its moon panel. */
7
+ export declare class MoonPanelPlan {
8
+ #private;
9
+ set(input: MoonPanelInput): void;
10
+ get input(): MoonPanelInput | undefined;
11
+ /** The moon count and the line "115 moons in the JPL Horizons list of 18 October 2026"; undefined when no panel was set. */
12
+ read(): SceneMoonPanelRead | undefined;
13
+ /**
14
+ * The shell's list: each moon must be a body or body-set member of the scene (`labels` maps those ids to their labels); a moon that is a body gets the
15
+ * picture the viewer's data brings for it (`pictureOf`), a dot none.
16
+ */
17
+ list(labels: ReadonlyMap<string, string>, bodies: ReadonlySet<string>, catalogue: BodyCatalogue, pictureOf: (picture: string) => string | undefined): MoonFamilyList | undefined;
18
+ }
19
+ export {};
@@ -0,0 +1,104 @@
1
+ import { moonListSummary } from "../core/moonListText.js";
2
+ import { SceneError } from "./errors.js";
3
+ import { frozenCopy } from "./frozenCopy.js";
4
+ import { frozenList } from "./sceneReads.js";
5
+ import { toUtcMs } from "./time.js";
6
+ const bad = (message) => new SceneError("bad-moon-panel", `setMoonPanel: ${message}`);
7
+ const isText = (value) => typeof value === "string" && value !== "";
8
+ /** The `YYYY-MM-DD` day of a list date, or throws `bad-moon-panel` when it is not a moment. */
9
+ function dayOf(input) {
10
+ if (input.listDate === undefined)
11
+ return undefined;
12
+ try {
13
+ return new Date(toUtcMs(input.listDate, "listDate")).toISOString().slice(0, 10);
14
+ }
15
+ catch {
16
+ throw bad(`listDate "${String(input.listDate)}" is not a valid moment; use an ISO day such as "2026-10-18", a Date or Unix milliseconds`);
17
+ }
18
+ }
19
+ /** Checks one family and its moons; `families` and `moons` collect the ids seen so far. */
20
+ function checkFamily(family, families, moons) {
21
+ if (!isText(family?.id))
22
+ throw bad("every family needs a non-empty id");
23
+ if (families.has(family.id))
24
+ throw bad(`family "${family.id}" appears twice`);
25
+ families.add(family.id);
26
+ if (!isText(family.label))
27
+ throw bad(`family "${family.id}" needs a label`);
28
+ if (!isText(family.description))
29
+ throw bad(`family "${family.id}" needs a one-line description`);
30
+ if (!Array.isArray(family.moons))
31
+ throw bad(`family "${family.id}": moons must be a list`);
32
+ for (const moon of family.moons) {
33
+ if (!isText(moon?.id))
34
+ throw bad(`family "${family.id}": every moon needs a non-empty id`);
35
+ if (moons.has(moon.id))
36
+ throw bad(`moon "${moon.id}" appears twice`);
37
+ moons.add(moon.id);
38
+ if (moon.named !== undefined && typeof moon.named !== "boolean")
39
+ throw bad(`moon "${moon.id}": named must be true or false`);
40
+ }
41
+ }
42
+ /** Checks the panel's words, families, moons and list source and date; returns the list day. */
43
+ function checkInput(input) {
44
+ if (typeof input !== "object" || input === null)
45
+ throw bad("give a { label, families } object");
46
+ if (!isText(input.label))
47
+ throw bad("the panel needs a label");
48
+ if (!Array.isArray(input.families) || input.families.length === 0)
49
+ throw bad("the panel needs at least one family");
50
+ const families = new Set();
51
+ const moons = new Set();
52
+ for (const family of input.families)
53
+ checkFamily(family, families, moons);
54
+ if (input.featuredFamily !== undefined && !families.has(input.featuredFamily))
55
+ throw bad(`featuredFamily "${String(input.featuredFamily)}" is not one of the families`);
56
+ if (input.listSource !== undefined && !isText(input.listSource))
57
+ throw bad("listSource must be a non-empty text");
58
+ return dayOf(input);
59
+ }
60
+ /** What a `Scene` has planned for its moon panel. */
61
+ export class MoonPanelPlan {
62
+ #input;
63
+ #day;
64
+ set(input) {
65
+ this.#day = checkInput(input);
66
+ this.#input = frozenCopy(input);
67
+ }
68
+ get input() { return this.#input; }
69
+ /** The moon count and the line "115 moons in the JPL Horizons list of 18 October 2026"; undefined when no panel was set. */
70
+ read() {
71
+ const input = this.#input;
72
+ if (input === undefined)
73
+ return undefined;
74
+ const count = input.families.reduce((total, family) => total + family.moons.length, 0);
75
+ return Object.freeze({ count, summary: moonListSummary(count, input.listSource, this.#day) });
76
+ }
77
+ /**
78
+ * The shell's list: each moon must be a body or body-set member of the scene (`labels` maps those ids to their labels); a moon that is a body gets the
79
+ * picture the viewer's data brings for it (`pictureOf`), a dot none.
80
+ */
81
+ list(labels, bodies, catalogue, pictureOf) {
82
+ const input = this.#input;
83
+ if (input === undefined)
84
+ return undefined;
85
+ return {
86
+ planetLabel: input.label,
87
+ ...(input.featuredFamily === undefined ? {} : { featuredFamilyId: input.featuredFamily }),
88
+ families: frozenList(input.families.map((family) => ({
89
+ id: family.id,
90
+ label: family.label,
91
+ description: family.description,
92
+ moons: frozenList(family.moons.map((moon) => {
93
+ const label = labels.get(moon.id);
94
+ if (label === undefined)
95
+ throw bad(`moon "${moon.id}" in family "${family.id}" is not a body or body-set member of the scene`);
96
+ const picture = bodies.has(moon.id) ? pictureOf(catalogue.has(moon.id) ? catalogue.get(moon.id).visual.picture ?? moon.id : moon.id) : undefined;
97
+ return { id: moon.id, label, named: moon.named ?? true, ...(picture === undefined ? {} : { pictureUrl: picture }) };
98
+ })),
99
+ }))),
100
+ ...(input.listSource === undefined ? {} : { listSource: input.listSource }),
101
+ ...(this.#day === undefined ? {} : { listDate: this.#day }),
102
+ };
103
+ }
104
+ }
@@ -0,0 +1,40 @@
1
+ import type { BodyId } from "../core/body.js";
2
+ import type { WindowProvenanceSpan } from "../core/timeWindow.js";
3
+ import { type BodyCatalogue } from "../assets/catalogue.js";
4
+ import { type TrackedBody } from "../app/mission.js";
5
+ import { SceneError } from "./errors.js";
6
+ import type { ReadoutInput, TrajectoryInput } from "./scene.js";
7
+ import { type ScenePathRead } from "./sceneReads.js";
8
+ export interface Tracked {
9
+ readonly body: TrackedBody;
10
+ /** `lineFixedTo: "auto"`: the stretches are resolved from the samples once the planet series are in. */
11
+ readonly auto?: true;
12
+ readonly center: BodyId;
13
+ readonly description?: string;
14
+ readonly knownLimitations?: readonly string[];
15
+ readonly provenanceSpans?: readonly WindowProvenanceSpan[];
16
+ readonly readouts: readonly ReadoutInput[];
17
+ }
18
+ /** The paths in the order added, as the public list states them. */
19
+ export declare function pathReads(tracked: Iterable<Tracked>): readonly ScenePathRead[];
20
+ /** Validates and stores one path about `center`. */
21
+ export declare function buildTracked(input: TrajectoryInput, center: BodyId, labelReaches: Map<string, number>): Tracked;
22
+ /** Throws `error` unless `reach` is a positive finite number. */
23
+ export declare function checkLabelReach(reach: unknown, error: SceneError): void;
24
+ /** Checks each readout's kind and the catalogued body it names; whether the scene holds that body is checked when the definition is built. */
25
+ export declare function readoutsOf(id: string, readouts?: readonly ReadoutInput[], call?: string): readonly ReadoutInput[];
26
+ /**
27
+ * The distance the default zoom-out must cover for the scene's paths about the scene centre (I-114): a path reaching past the planets must fit whole whichever point of it the camera looks at,
28
+ * so twice its farthest distance from the centre (no two points of a path are farther apart than that). Sampled over each path's span; undefined when no path is about the centre.
29
+ */
30
+ export declare function pathCover(tracked: Iterable<Tracked>, sunCentred: boolean, centre: BodyId): (() => number) | undefined;
31
+ /** The `"auto"` paths' one resolution into `tracked`: `now` runs it (through the caller's guarded read) when the planet series are in; else `later` is true and `settle` runs it in `prepare`. */
32
+ export declare function autoPaths(catalogue: BodyCatalogue, entries: readonly Tracked[], tracked: TrackedBody[], ids: readonly BodyId[]): {
33
+ readonly later: boolean;
34
+ readonly now: (guard: (read: () => void) => void) => void;
35
+ readonly settle: (guard: (read: () => void) => void) => void;
36
+ };
37
+ /** A readout, or the body the line is fixed to, names a body the scene must hold. */
38
+ export declare function checkReadouts(entry: Tracked, ids: readonly BodyId[]): void;
39
+ /** The readouts of a path or a body name only bodies the scene holds. */
40
+ export declare function checkNamedReadouts(id: string, readouts: readonly ReadoutInput[], ids: readonly BodyId[], call: string): void;
@@ -0,0 +1,212 @@
1
+ import { createProvenance } from "../core/provenance.js";
2
+ import { SampledTrajectory } from "../core/sampledTrajectory.js";
3
+ import { createState } from "../core/state.js";
4
+ import { createOrbTwoBodyAdapter } from "../core/twoBodyAdapter.js";
5
+ import { createStateResolver } from "../core/stateResolver.js";
6
+ import { createOrbAstronomyAdapter } from "../core/astronomyAdapter.js";
7
+ import { planetSeriesLoaded } from "../core/planetSeries.js";
8
+ import { catalogue as builtInCatalogue } from "../assets/catalogue.js";
9
+ import { lineBodies } from "../app/mission.js";
10
+ import { planLineStretches, planPathProvenance } from "./pathProvenance.js";
11
+ import { influenceStretches, sphereOfInfluenceKm } from "./sphereOfInfluence.js";
12
+ import { SceneError } from "./errors.js";
13
+ import { rejectRenamed } from "./renamedInputs.js";
14
+ import { toUtcMs } from "./time.js";
15
+ import { frozenList } from "./sceneReads.js";
16
+ const DEFAULT_COLOR = "#ffd27a";
17
+ const PROVIDER_PATH_SAMPLES = 128;
18
+ /** Samples along a path when its farthest distance is read for the default zoom-out. */
19
+ const PATH_COVER_SAMPLES = 400;
20
+ /** The paths in the order added, as the public list states them. */
21
+ export function pathReads(tracked) {
22
+ return frozenList([...tracked].map(({ body, center, description, knownLimitations }) => ({ id: body.id, label: body.label, center, provenance: body.provenance, ...(description === undefined ? {} : { description }), knownLimitations: Object.freeze([...(knownLimitations ?? [])]) }))); // addTrajectory always sets a provenance
23
+ }
24
+ /** Validates and stores one path about `center`. */
25
+ export function buildTracked(input, center, labelReaches) {
26
+ const id = input.id;
27
+ rejectRenamed("TrajectoryInput", input, `addTrajectory("${id}")`);
28
+ if (!builtInCatalogue.has(center))
29
+ throw new SceneError("unknown-body", `addTrajectory("${id}"): centre "${center}" is not a catalogued body`);
30
+ const provenance = input.provenance ?? createProvenance({ sourceType: "illustrative", sources: ["Supplied by the caller"], accuracy: "As supplied; the engine makes no claim.", notes: "Positions were passed to addTrajectory." });
31
+ const common = { id, label: input.label ?? id, color: input.color ?? DEFAULT_COLOR, anchorTimesUtcMs: [], provenance };
32
+ const readouts = readoutsOf(id, input.readouts);
33
+ if (input.labelReachEarthRadii !== undefined) {
34
+ checkLabelReach(input.labelReachEarthRadii, new SceneError("bad-trajectory", `addTrajectory("${id}"): labelReachEarthRadii ${String(input.labelReachEarthRadii)} must be a positive finite number`));
35
+ labelReaches.set(id, input.labelReachEarthRadii);
36
+ }
37
+ if (input.plane !== undefined && input.plane !== "EQJ" && input.plane !== "ecliptic-j2000")
38
+ throw new SceneError("bad-trajectory", `addTrajectory("${id}"): plane "${String(input.plane)}" must be "EQJ" or "ecliptic-j2000"`);
39
+ const toEqj = input.plane === "ecliptic-j2000" ? createOrbTwoBodyAdapter().eclipticJ2000ToEqjMatrix() : null;
40
+ const body = "samples" in input ? sampledBody(common, input, center, toEqj) : providerBody(common, input, toEqj);
41
+ const span = { startUtcMs: body.trajectory.bounds.startUtcMs, endUtcMs: body.trajectory.bounds.endUtcMs };
42
+ const provenanceSpans = input.provenanceSpans === undefined ? undefined : planPathProvenance(id, input.provenanceSpans, span);
43
+ checkLineFixedToType(id, input.lineFixedTo);
44
+ const auto = input.lineFixedTo === "auto";
45
+ const lineFixedTo = typeof input.lineFixedTo === "object" ? planLineStretches(id, input.lineFixedTo, span) : auto ? undefined : input.lineFixedTo;
46
+ return { center, ...(auto ? { auto: true } : {}), body: withAnchors(lineFixedTo === undefined ? body : { ...body, lineFixedTo }, input.anchors), readouts, ...(provenanceSpans === undefined ? {} : { provenanceSpans }), ...(input.description === undefined ? {} : { description: input.description }), ...(input.knownLimitations === undefined ? {} : { knownLimitations: input.knownLimitations }) };
47
+ }
48
+ /** Rotates a vector by a row-major 3x3 matrix; a missing matrix leaves it as it is. Input that is not three numbers passes through for the State checks to refuse. */
49
+ function rotated(matrix, v) {
50
+ if (matrix === null || v === undefined || v.length !== 3)
51
+ return v;
52
+ return [0, 1, 2].map((row) => matrix[3 * row] * v[0] + matrix[3 * row + 1] * v[1] + matrix[3 * row + 2] * v[2]);
53
+ }
54
+ function sampledBody(common, input, center, toEqj) {
55
+ const samples = input.samples.map((sample, index) => {
56
+ const velocityKmS = rotated(toEqj, sample.velocityKmS);
57
+ return { positionKm: rotated(toEqj, sample.positionKm), ...(velocityKmS === undefined ? {} : { velocityKmS }), timeUtcMs: toUtcMs(sample.time, `addTrajectory("${common.id}") sample ${index} time`) };
58
+ });
59
+ try {
60
+ const trajectory = new SampledTrajectory({ body: common.id, center, samples });
61
+ return { ...common, trajectory, pathTimesUtcMs: samples.map((sample) => sample.timeUtcMs) };
62
+ }
63
+ catch (error) {
64
+ if (error instanceof SceneError)
65
+ throw error;
66
+ throw new SceneError("bad-trajectory", `addTrajectory("${common.id}"): ${error instanceof Error ? error.message : String(error)}`);
67
+ }
68
+ }
69
+ /** `lineFixedTo` is a body id, `"auto"` or a list; anything else is `bad-trajectory` (the list's own faults are named by `planLineStretches`). */
70
+ function checkLineFixedToType(id, value) {
71
+ if (value !== undefined && typeof value !== "string" && typeof value !== "object")
72
+ throw new SceneError("bad-trajectory", `addTrajectory("${id}"): lineFixedTo ${String(value)} must be a body id, "auto" or a list of stretches`);
73
+ }
74
+ function providerBody(common, input, toEqj) {
75
+ if (typeof input.provider?.stateAt !== "function")
76
+ throw new SceneError("bad-trajectory", `addTrajectory("${common.id}"): provider needs a stateAt(time) function`);
77
+ const bounds = { startUtcMs: toUtcMs(input.bounds?.start, `addTrajectory("${common.id}") bounds.start`), endUtcMs: toUtcMs(input.bounds?.end, `addTrajectory("${common.id}") bounds.end`) };
78
+ if (bounds.endUtcMs <= bounds.startUtcMs)
79
+ throw new SceneError("bad-trajectory", `addTrajectory("${common.id}"): bounds must end after they start`);
80
+ const trajectory = { body: common.id, bounds, stateAt: (timeUtcMs, center) => rotatedState(toEqj, input.provider.stateAt(timeUtcMs, center)) };
81
+ // Whole milliseconds, because the state resolver refuses a fractional time (the line is placed against another body at these times).
82
+ const step = (bounds.endUtcMs - bounds.startUtcMs) / (PROVIDER_PATH_SAMPLES - 1);
83
+ return { ...common, trajectory, pathTimesUtcMs: Array.from({ length: PROVIDER_PATH_SAMPLES }, (_, index) => Math.round(bounds.startUtcMs + index * step)) };
84
+ }
85
+ /** A provider's State with its position and velocity rotated into EQJ; unchanged for EQJ input. */
86
+ function rotatedState(matrix, state) {
87
+ if (matrix === null)
88
+ return state;
89
+ return createState({ body: state.body, center: state.center, timeUtcMs: state.timeUtcMs, positionKm: rotated(matrix, state.positionKm), ...(state.velocityKmS === undefined ? {} : { velocityKmS: rotated(matrix, state.velocityKmS) }), orientation: state.orientation });
90
+ }
91
+ /** Throws `error` unless `reach` is a positive finite number. */
92
+ export function checkLabelReach(reach, error) {
93
+ if (!(typeof reach === "number" && Number.isFinite(reach) && reach > 0))
94
+ throw error;
95
+ }
96
+ const READOUT_KINDS = ["range", "speed", "distance", "altitude"];
97
+ /** The body a readout names, if any. */
98
+ function readoutBody(spec) {
99
+ return spec.kind === "range" ? spec.marker : spec.kind === "distance" ? spec.to : spec.kind === "altitude" ? spec.above : undefined;
100
+ }
101
+ /** Checks each readout's kind and the catalogued body it names; whether the scene holds that body is checked when the definition is built. */
102
+ export function readoutsOf(id, readouts = [], call = "addTrajectory") {
103
+ if (!Array.isArray(readouts))
104
+ throw new SceneError("bad-readout", `${call}("${id}"): readouts must be a list`);
105
+ for (const spec of readouts) {
106
+ if (!READOUT_KINDS.includes(spec?.kind))
107
+ throw new SceneError("bad-readout", `${call}("${id}"): readout kind "${String(spec?.kind)}" is not one of ${READOUT_KINDS.join(", ")}`);
108
+ const named = readoutBody(spec);
109
+ if (spec.kind !== "range" && spec.kind !== "speed" && named === undefined)
110
+ throw new SceneError("bad-readout", `${call}("${id}"): readout ${spec.kind} needs ${spec.kind === "distance" ? "`to`" : "`above`"}, the body to measure against`);
111
+ if (named !== undefined && !builtInCatalogue.has(named))
112
+ throw new SceneError("bad-readout", `${call}("${id}"): readout ${spec.kind} names "${named}", which is not a catalogued body`);
113
+ }
114
+ return readouts;
115
+ }
116
+ /** The body with its anchors: sorted by time, each labelled with its id. Every anchor needs a distinct id and a moment inside the path. */
117
+ function withAnchors(body, anchors = []) {
118
+ if (!Array.isArray(anchors))
119
+ throw new SceneError("bad-anchor", `addTrajectory("${body.id}"): anchors must be a list`);
120
+ const { startUtcMs, endUtcMs } = body.trajectory.bounds;
121
+ const seen = new Set();
122
+ const placed = anchors.map((anchor) => {
123
+ if (typeof anchor?.id !== "string" || anchor.id === "")
124
+ throw new SceneError("bad-anchor", `addTrajectory("${body.id}"): every anchor needs a non-empty id`);
125
+ if (seen.has(anchor.id))
126
+ throw new SceneError("bad-anchor", `addTrajectory("${body.id}"): anchor "${anchor.id}" appears twice`);
127
+ seen.add(anchor.id);
128
+ const timeUtcMs = anchorTime(body.id, anchor);
129
+ if (timeUtcMs < startUtcMs || timeUtcMs > endUtcMs)
130
+ throw new SceneError("bad-anchor", `addTrajectory("${body.id}"): anchor "${anchor.id}" is outside the path (${new Date(startUtcMs).toISOString()} to ${new Date(endUtcMs).toISOString()})`);
131
+ return { id: anchor.id, timeUtcMs };
132
+ }).sort((a, b) => a.timeUtcMs - b.timeUtcMs);
133
+ return placed.length === 0 ? body : { ...body, anchorTimesUtcMs: placed.map((anchor) => anchor.timeUtcMs), anchorLabels: placed.map((anchor) => anchor.id) };
134
+ }
135
+ function anchorTime(path, anchor) {
136
+ try {
137
+ return toUtcMs(anchor.time);
138
+ }
139
+ catch {
140
+ throw new SceneError("bad-anchor", `addTrajectory("${path}"): anchor "${anchor.id}" has a time "${String(anchor.time)}" that is not a valid moment`);
141
+ }
142
+ }
143
+ /**
144
+ * The distance the default zoom-out must cover for the scene's paths about the scene centre (I-114): a path reaching past the planets must fit whole whichever point of it the camera looks at,
145
+ * so twice its farthest distance from the centre (no two points of a path are farther apart than that). Sampled over each path's span; undefined when no path is about the centre.
146
+ */
147
+ export function pathCover(tracked, sunCentred, centre) {
148
+ if (!sunCentred)
149
+ return undefined;
150
+ const about = [...tracked].filter((entry) => entry.center === centre);
151
+ if (about.length === 0)
152
+ return undefined;
153
+ return () => 2 * Math.max(...about.map(({ body }) => {
154
+ const { startUtcMs, endUtcMs } = body.trajectory.bounds;
155
+ let farthest = 0;
156
+ for (let k = 0; k < PATH_COVER_SAMPLES; k += 1)
157
+ farthest = Math.max(farthest, Math.hypot(...body.trajectory.stateAt(Math.round(startUtcMs + ((endUtcMs - startUtcMs) * k) / (PATH_COVER_SAMPLES - 1)), centre).positionKm));
158
+ return farthest;
159
+ }));
160
+ }
161
+ /** The stretches of a `lineFixedTo: "auto"` path: the innermost scene body whose sphere of influence holds each sample (`sphereOfInfluence.ts`). Reads body states, so the planet series must be loaded. */
162
+ function autoStretches(catalogue, entry, ids) {
163
+ const resolver = createStateResolver(catalogue.definitions(), catalogue.sources(), createOrbAstronomyAdapter());
164
+ const norm = (v) => Math.hypot(v[0], v[1], v[2]);
165
+ const candidates = [];
166
+ for (const id of ids) {
167
+ const { parentId, gmKm3S2 } = catalogue.get(id).definition;
168
+ if (parentId === undefined) {
169
+ candidates.push({ id, radiusKm: () => Infinity, probeDistanceKm: () => 0 });
170
+ continue;
171
+ }
172
+ const parentGm = catalogue.get(parentId).definition.gmKm3S2;
173
+ if (!(gmKm3S2 > 0 && parentGm > 0))
174
+ continue; // no published GM: this body cannot hold a probe
175
+ candidates.push({
176
+ id,
177
+ radiusKm: (t) => sphereOfInfluenceKm(gmKm3S2, parentGm, norm(resolver.stateOf(id, t, parentId).positionKm)),
178
+ probeDistanceKm: (t) => {
179
+ const probe = entry.body.trajectory.stateAt(t, entry.center).positionKm;
180
+ const body = resolver.stateOf(id, t, entry.center).positionKm;
181
+ return norm([probe[0] - body[0], probe[1] - body[1], probe[2] - body[2]]);
182
+ },
183
+ });
184
+ }
185
+ return influenceStretches(entry.body.pathTimesUtcMs, candidates);
186
+ }
187
+ /** The `"auto"` paths' one resolution into `tracked`: `now` runs it (through the caller's guarded read) when the planet series are in; else `later` is true and `settle` runs it in `prepare`. */
188
+ export function autoPaths(catalogue, entries, tracked, ids) {
189
+ const pending = entries.some((entry) => entry.auto === true);
190
+ const later = pending && !planetSeriesLoaded();
191
+ const resolve = () => entries.forEach((entry, index) => { if (entry.auto === true)
192
+ tracked[index] = { ...entry.body, lineFixedTo: autoStretches(catalogue, entry, ids) }; });
193
+ return { later, now: (guard) => { if (pending && !later)
194
+ guard(resolve); }, settle: (guard) => { if (later)
195
+ guard(resolve); } };
196
+ }
197
+ /** A readout, or the body the line is fixed to, names a body the scene must hold. */
198
+ export function checkReadouts(entry, ids) {
199
+ for (const { index, body } of lineBodies(entry.body.lineFixedTo)) {
200
+ if (!ids.includes(body))
201
+ throw new SceneError("bad-trajectory", `addTrajectory("${entry.body.id}"): lineFixedTo${index === null ? "" : `[${index}]`} names "${body}", which has not been added to the scene`);
202
+ }
203
+ checkNamedReadouts(entry.body.id, entry.readouts, ids, "addTrajectory");
204
+ }
205
+ /** The readouts of a path or a body name only bodies the scene holds. */
206
+ export function checkNamedReadouts(id, readouts, ids, call) {
207
+ for (const spec of readouts) {
208
+ const named = readoutBody(spec);
209
+ if (named !== undefined && !ids.includes(named))
210
+ throw new SceneError("bad-readout", `${call}("${id}"): readout ${spec.kind} names "${named}", which has not been added to the scene`);
211
+ }
212
+ }
@@ -0,0 +1,12 @@
1
+ import type { PickerInput } from "./pickerInput.js";
2
+ /** What a `Scene` has planned for its picker. */
3
+ export declare class PickerPlan {
4
+ #private;
5
+ set(input: PickerInput): void;
6
+ /** The picker as set (frozen); undefined when none was set. */
7
+ get input(): PickerInput | undefined;
8
+ /** The definition's entry; absent when none was set. */
9
+ entry(): {
10
+ readonly picker: PickerInput;
11
+ } | Record<string, never>;
12
+ }
@@ -0,0 +1,40 @@
1
+ import { SceneError } from "./errors.js";
2
+ const bad = (message) => new SceneError("bad-picker", `setPicker: ${message}`);
3
+ const isText = (value) => typeof value === "string" && value !== "";
4
+ /** Checks the picker's id, label, options and starting value; throws `bad-picker`. */
5
+ function checkInput(input) {
6
+ if (typeof input !== "object" || input === null)
7
+ throw bad("give an { id, label, options, value } object");
8
+ if (!isText(input.id))
9
+ throw bad("the picker needs a non-empty id");
10
+ if (!isText(input.label))
11
+ throw bad("the picker needs a label");
12
+ if (!Array.isArray(input.options))
13
+ throw bad("options must be a list");
14
+ const values = new Set();
15
+ for (const option of input.options) {
16
+ if (!isText(option?.value))
17
+ throw bad("every option needs a non-empty value");
18
+ if (!isText(option.label))
19
+ throw bad(`option "${option.value}" needs a label`);
20
+ if (values.has(option.value))
21
+ throw bad(`option "${option.value}" appears twice`);
22
+ values.add(option.value);
23
+ }
24
+ if (!values.has(input.value))
25
+ throw bad(`value "${String(input.value)}" is not one of the options`);
26
+ }
27
+ /** What a `Scene` has planned for its picker. */
28
+ export class PickerPlan {
29
+ #input;
30
+ set(input) {
31
+ checkInput(input);
32
+ this.#input = Object.freeze({ id: input.id, label: input.label, value: input.value, options: Object.freeze(input.options.map((option) => Object.freeze({ value: option.value, label: option.label }))) });
33
+ }
34
+ /** The picker as set (frozen); undefined when none was set. */
35
+ get input() { return this.#input; }
36
+ /** The definition's entry; absent when none was set. */
37
+ entry() {
38
+ return this.#input === undefined ? {} : { picker: this.#input };
39
+ }
40
+ }
@@ -0,0 +1,16 @@
1
+ import type { BodyId } from "../core/body.js";
2
+ import type { ExperienceDefinition } from "../app/experienceDefinition.js";
3
+ import type { BodyRef } from "./bodies.js";
4
+ import type { PlacesInput } from "./moonPanelInput.js";
5
+ import { type ScenePlacesRead } from "./sceneReads.js";
6
+ type BodyFeatureSet = NonNullable<ExperienceDefinition["experience"]["bodyFeatures"]>[number];
7
+ /** What a `Scene` has planned for its tagged surface places, by body. */
8
+ export declare class PlacesPlan {
9
+ readonly sets: Map<string, PlacesInput>;
10
+ add(body: BodyRef | BodyId, input: PlacesInput): void;
11
+ /** The places in the order added. */
12
+ reads(): readonly ScenePlacesRead[];
13
+ /** The shell's sets, once the finished scene says which bodies it holds (`labels` maps them to their labels). */
14
+ featureSets(labels: ReadonlyMap<string, string>): readonly BodyFeatureSet[];
15
+ }
16
+ export {};