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.
- package/CHANGELOG.md +176 -0
- package/README.md +185 -37
- package/package.json +5 -4
- package/src/api/AstraeusScene.d.ts +21 -5
- package/src/api/AstraeusScene.js +34 -10
- package/src/api/AstraeusScene.node.js +34 -10
- package/src/api/assembleScene.d.ts +36 -0
- package/src/api/assembleScene.js +175 -0
- package/src/api/bodySetChecks.d.ts +10 -0
- package/src/api/bodySetChecks.js +117 -0
- package/src/api/bodySetInput.d.ts +81 -0
- package/src/api/bodySetInput.js +1 -0
- package/src/api/containingBlock.d.ts +6 -0
- package/src/api/containingBlock.js +16 -0
- package/src/api/data.d.ts +17 -5
- package/src/api/data.js +28 -10
- package/src/api/definitionOf.d.ts +16 -0
- package/src/api/definitionOf.js +20 -0
- package/src/api/errors.d.ts +61 -1
- package/src/api/frozenCopy.d.ts +6 -0
- package/src/api/frozenCopy.js +26 -0
- package/src/api/group.d.ts +8 -2
- package/src/api/group.js +24 -5
- package/src/api/index.d.ts +18 -7
- package/src/api/index.js +2 -2
- package/src/api/index.node.js +2 -2
- package/src/api/listeners.d.ts +5 -0
- package/src/api/listeners.js +25 -0
- package/src/api/look.d.ts +47 -0
- package/src/api/look.js +1 -0
- package/src/api/lookInput.d.ts +3 -0
- package/src/api/lookInput.js +41 -0
- package/src/api/moonPanelInput.d.ts +60 -0
- package/src/api/moonPanelInput.js +1 -0
- package/src/api/mount.d.ts +9 -19
- package/src/api/mount.js +27 -13
- package/src/api/mount.node.js +27 -13
- package/src/api/pathProvenance.js +1 -1
- package/src/api/pickerInput.d.ts +25 -0
- package/src/api/pickerInput.js +1 -0
- package/src/api/planBodies.d.ts +72 -0
- package/src/api/planBodies.js +300 -0
- package/src/api/planBodySets.d.ts +68 -0
- package/src/api/planBodySets.js +234 -0
- package/src/api/planCamera.d.ts +83 -0
- package/src/api/planCamera.js +184 -0
- package/src/api/planGroups.d.ts +36 -0
- package/src/api/planGroups.js +103 -0
- package/src/api/planMoonPanel.d.ts +19 -0
- package/src/api/planMoonPanel.js +104 -0
- package/src/api/planPaths.d.ts +40 -0
- package/src/api/planPaths.js +212 -0
- package/src/api/planPicker.d.ts +12 -0
- package/src/api/planPicker.js +40 -0
- package/src/api/planPlaces.d.ts +16 -0
- package/src/api/planPlaces.js +99 -0
- package/src/api/planStory.d.ts +26 -0
- package/src/api/planStory.js +66 -0
- package/src/api/planTimeline.d.ts +27 -0
- package/src/api/planTimeline.js +68 -0
- package/src/api/planViews.d.ts +25 -0
- package/src/api/planViews.js +35 -0
- package/src/api/prepared.js +4 -1
- package/src/api/renamedInputs.d.ts +15 -0
- package/src/api/renamedInputs.js +39 -0
- package/src/api/scene.d.ts +162 -68
- package/src/api/scene.js +247 -793
- package/src/api/sceneFreeze.d.ts +4 -0
- package/src/api/sceneFreeze.js +10 -0
- package/src/api/sceneReads.d.ts +171 -0
- package/src/api/sceneReads.js +6 -0
- package/src/api/story.d.ts +49 -19
- package/src/api/story.js +54 -22
- package/src/api/sunOrbit.js +9 -11
- package/src/api/time.d.ts +2 -1
- package/src/api/time.js +2 -1
- package/src/api/viewerCamera.d.ts +22 -0
- package/src/api/viewerCamera.js +84 -0
- package/src/api/viewerClock.d.ts +30 -0
- package/src/api/viewerClock.js +85 -0
- package/src/api/viewerFirstDraw.d.ts +14 -0
- package/src/api/viewerFirstDraw.js +26 -0
- package/src/api/viewerHandle.d.ts +79 -0
- package/src/api/viewerHandle.js +31 -0
- package/src/api/viewerLink.d.ts +87 -15
- package/src/api/viewerLink.js +111 -75
- package/src/api/viewerLooks.d.ts +19 -0
- package/src/api/viewerLooks.js +37 -0
- package/src/api/viewerPicker.d.ts +22 -0
- package/src/api/viewerPicker.js +49 -0
- package/src/api/viewerSelection.d.ts +25 -0
- package/src/api/viewerSelection.js +31 -0
- package/src/api/viewerViews.d.ts +10 -0
- package/src/api/viewerViews.js +18 -0
- package/src/api/viewerZones.d.ts +20 -0
- package/src/api/viewerZones.js +47 -0
- package/src/api/views.d.ts +4 -5
- package/src/api/views.js +7 -5
- package/src/app/App.d.ts +5 -3
- package/src/app/App.js +191 -82
- package/src/app/App.node.js +191 -82
- package/src/app/AstraeusScene.d.ts +16 -2
- package/src/app/AstraeusScene.js +4 -4
- package/src/app/BodyView.d.ts +4 -1
- package/src/app/BodyView.js +2 -2
- package/src/app/CameraController.d.ts +6 -0
- package/src/app/DeveloperSettings.d.ts +1 -4
- package/src/app/DeveloperSettings.js +6 -10
- package/src/app/FeatureMarkers.d.ts +4 -3
- package/src/app/FeatureMarkers.js +8 -13
- package/src/app/FrameRateSection.js +2 -1
- package/src/app/OrbitSetView.js +1 -1
- package/src/app/SettingControls.d.ts +11 -3
- package/src/app/SettingControls.js +10 -2
- package/src/app/SkyView.d.ts +3 -10
- package/src/app/SkyView.js +6 -28
- package/src/app/address.d.ts +16 -0
- package/src/app/address.js +31 -0
- package/src/app/bodyDraw.d.ts +10 -7
- package/src/app/bodyDraw.js +12 -32
- package/src/app/bodyMetrics.js +2 -2
- package/src/app/bodySet.d.ts +4 -20
- package/src/app/bodySet.js +5 -16
- package/src/app/debugReadout.js +1 -1
- package/src/app/displaySwitches.d.ts +4 -0
- package/src/app/displaySwitches.js +6 -0
- package/src/app/experienceDefinition.d.ts +11 -23
- package/src/app/listSwitch.d.ts +8 -14
- package/src/app/listSwitch.js +3 -10
- package/src/app/liveLook.d.ts +39 -0
- package/src/app/liveLook.js +66 -0
- package/src/app/look.d.ts +36 -0
- package/src/app/look.js +61 -0
- package/src/app/mission.d.ts +1 -1
- package/src/app/mission.js +1 -1
- package/src/app/openClock.d.ts +3 -2
- package/src/app/openClock.js +3 -3
- package/src/app/sceneCamera.js +9 -0
- package/src/app/sceneFrame.d.ts +4 -4
- package/src/app/sceneFrame.js +13 -8
- package/src/app/sceneHooks.js +3 -2
- package/src/app/style.css +114 -139
- package/src/app/trackedMetrics.d.ts +10 -3
- package/src/app/trackedMetrics.js +22 -11
- package/src/app/viewLink.d.ts +10 -32
- package/src/app/viewLink.js +10 -49
- package/src/app/viewerPort.d.ts +50 -0
- package/src/app/views.d.ts +1 -0
- package/src/assets/bodies/galileanMoons.js +1 -2
- package/src/assets/bodies/io.js +2 -2
- package/src/assets/bodies/listedMoons.d.ts +1 -1
- package/src/assets/bodies/listedMoons.js +2 -3
- package/src/assets/bodies/planetSystemMaps.js +2 -3
- package/src/assets/bodies/venus.js +2 -6
- package/src/assets/catalogue.js +1 -2
- package/src/assets/licence.d.ts +3 -3
- package/src/assets/licence.js +3 -3
- package/src/assets/pictures.d.ts +15 -12
- package/src/assets/pictures.js +24 -20
- package/src/assets/sky.d.ts +6 -5
- package/src/assets/sky.js +6 -9
- package/src/assets/visual.d.ts +4 -0
- package/src/core/bodies/index.d.ts +0 -4
- package/src/core/bodies/index.js +1 -6
- package/src/core/bodies/jupiterData.d.ts +0 -1
- package/src/core/bodies/jupiterData.js +2 -5
- package/src/core/bodies/moonSystem.d.ts +1 -1
- package/src/core/bodies/moonSystem.js +102 -55
- package/src/core/bodies/outerPlanetRingData.js +2 -2
- package/src/core/bodies/planetTrajectory.js +1 -1
- package/src/core/bodySetFamilies.d.ts +20 -0
- package/src/core/bodySetFamilies.js +14 -0
- package/src/core/chebyshevEphemeris.js +1 -1
- package/src/core/elementsBody.d.ts +8 -4
- package/src/core/elementsBody.js +32 -11
- package/src/core/elementsGroup.d.ts +27 -0
- package/src/core/elementsGroup.js +85 -0
- package/src/core/events.d.ts +2 -0
- package/src/core/events.js +2 -0
- package/src/core/illumination.js +1 -1
- package/src/core/listedOrbitGroup.d.ts +2 -0
- package/src/core/listedOrbitGroup.js +11 -7
- package/src/core/moonListText.d.ts +6 -0
- package/src/core/moonListText.js +19 -0
- package/src/core/moonTrajectory.js +1 -1
- package/src/core/pacing.d.ts +38 -3
- package/src/core/pacing.js +55 -4
- package/src/core/planetModels.js +2 -2
- package/src/core/planetSeries.d.ts +8 -0
- package/src/core/planetSeries.js +16 -2
- package/src/core/pointGroup.js +1 -1
- package/src/core/provenance.d.ts +2 -1
- package/src/core/provenance.js +2 -2
- package/src/core/referenceCenters.js +5 -5
- package/src/core/sampledTrajectory.js +1 -1
- package/src/core/scalePolicy.d.ts +1 -0
- package/src/core/startView.d.ts +19 -0
- package/src/core/startView.js +28 -0
- package/src/core/state.d.ts +6 -2
- package/src/core/state.js +3 -3
- package/src/core/storyPanels.d.ts +63 -0
- package/src/core/storyPanels.js +111 -0
- package/src/core/sunCentredSources.d.ts +4 -0
- package/src/core/sunCentredSources.js +9 -2
- package/src/core/timeInput.d.ts +4 -0
- package/src/core/timeInput.js +4 -0
- package/src/shell/AstraeusShell.d.ts +5 -1
- package/src/shell/AstraeusShell.js +20 -11
- package/src/shell/AstraeusShell.node.js +20 -11
- package/src/shell/Collapsible.d.ts +4 -3
- package/src/shell/Collapsible.js +5 -5
- package/src/shell/ControlsDrawer.d.ts +1 -1
- package/src/shell/ControlsDrawer.js +3 -1
- package/src/shell/DisplaySwitches.js +2 -1
- package/src/shell/InfoPanel.d.ts +3 -1
- package/src/shell/InfoPanel.js +5 -4
- package/src/shell/MoonFamilyPanel.js +1 -1
- package/src/shell/ObjectControls.d.ts +3 -1
- package/src/shell/ObjectControls.js +2 -2
- package/src/shell/Sources.d.ts +5 -3
- package/src/shell/Sources.js +5 -5
- package/src/shell/StoryPanelView.d.ts +4 -3
- package/src/shell/StoryPanelView.js +8 -6
- package/src/shell/SwitchControl.d.ts +5 -11
- package/src/shell/SwitchControl.js +2 -20
- package/src/shell/TimelineBar.css +81 -81
- package/src/shell/TimelineBar.d.ts +5 -2
- package/src/shell/TimelineBar.js +9 -8
- package/src/shell/TimelineBar.node.js +9 -8
- package/src/shell/TopBar.css +22 -22
- package/src/shell/TopBar.d.ts +5 -1
- package/src/shell/TopBar.js +2 -2
- package/src/shell/TopBar.node.js +2 -2
- package/src/shell/bootLoader.d.ts +4 -10
- package/src/shell/bootLoader.js +6 -52
- package/src/shell/embedded.css +18 -18
- package/src/shell/experience.d.ts +1 -1
- package/src/shell/moonFamilies.d.ts +2 -6
- package/src/shell/moonFamilies.js +2 -18
- package/src/shell/phone.css +58 -58
- package/src/shell/storyPanels.d.ts +2 -53
- package/src/shell/storyPanels.js +1 -106
- package/src/shell/style.css +153 -134
- package/src/shell/useDrawers.d.ts +3 -2
- package/src/shell/useDrawers.js +4 -3
- package/src/shell/viewerKeys.d.ts +8 -0
- package/src/shell/viewerKeys.js +16 -0
- package/src/synthetic/syntheticDefinition.js +20 -24
- package/src/synthetic/syntheticJourneyScene.js +3 -3
- package/src/synthetic/syntheticProbeDefinition.js +2 -1
- package/src/synthetic/syntheticViewsDefinition.d.ts +0 -3
- package/src/synthetic/syntheticViewsDefinition.js +10 -16
- package/data/moons/jupiter.json +0 -3333
- package/data/moons/neptune.json +0 -555
- package/data/moons/pluto.json +0 -205
- package/data/moons/saturn.json +0 -8267
- package/data/moons/uranus.json +0 -887
- package/src/app/addressNavigation.d.ts +0 -17
- package/src/app/addressNavigation.js +0 -16
- package/src/assets/bodies/jupiterMoonCatalogue.d.ts +0 -3
- package/src/assets/bodies/jupiterMoonCatalogue.js +0 -4
- package/src/assets/bodies/outerPlanetCatalogues.d.ts +0 -7
- package/src/assets/bodies/outerPlanetCatalogues.js +0 -8
- package/src/assets/bodies/swiftTuttle.d.ts +0 -12
- package/src/assets/bodies/swiftTuttle.js +0 -13
- package/src/assets/moonCatalogue.d.ts +0 -49
- package/src/assets/moonCatalogue.js +0 -80
- package/src/core/bodies/outerPlanetData.d.ts +0 -4
- package/src/core/bodies/outerPlanetData.js +0 -13
- package/src/core/bodies/swiftTuttle.d.ts +0 -46
- package/src/core/bodies/swiftTuttle.js +0 -106
|
@@ -15,6 +15,8 @@ import "./phone.css";
|
|
|
15
15
|
import "./embedded.css";
|
|
16
16
|
/** The object selected when the shell opens: the first one available at the clock time, else the first listed. */
|
|
17
17
|
export declare function initialObjectId(experience: ExperienceConfig, timeUtcMs: number): string;
|
|
18
|
+
/** Who moved the selection: the visitor, or a move of time or the view (named by whatever last moved them). */
|
|
19
|
+
export type SelectionOrigin = "visitor" | "move";
|
|
18
20
|
interface Props {
|
|
19
21
|
readonly experience: ExperienceConfig;
|
|
20
22
|
readonly snapshot: ClockSnapshot;
|
|
@@ -28,7 +30,8 @@ interface Props {
|
|
|
28
30
|
readonly onCameraRequest: (request: ExperienceCameraPreset["request"]) => void;
|
|
29
31
|
/** Holds the camera where it is, its target fixed in the scene (a view's `stay` rule); a later camera request replaces it. */
|
|
30
32
|
readonly onCameraHold?: () => void;
|
|
31
|
-
|
|
33
|
+
/** `origin` is required so a new selection path must say who chose: "visitor" (a menu choice, pick, preset or marker) or "move" (time or the view moved and the selection followed). */
|
|
34
|
+
readonly onSelectionChange: (objectId: string, origin: SelectionOrigin) => void;
|
|
32
35
|
readonly scaleId: ScaleId;
|
|
33
36
|
readonly onScaleChange: (id: ScaleId) => void;
|
|
34
37
|
readonly scaleChoices?: readonly ScaleChoice[];
|
|
@@ -45,6 +48,7 @@ interface Props {
|
|
|
45
48
|
};
|
|
46
49
|
/** Live measurements for an object's info panel, from the app's own State; empty when it has none. */
|
|
47
50
|
readonly metricsFor?: (objectId: string, timeUtcMs: number) => readonly Metric[];
|
|
51
|
+
/** The Developer drawer's content; absent: the shell shows no Developer toggle and no drawer (the host did not ask for developer tools). */
|
|
48
52
|
readonly developerTools?: ReactNode;
|
|
49
53
|
/** The live story-panel settings (auto-open, pause length); absent: the experience's own defaults. */
|
|
50
54
|
readonly storyPanelSettings?: StoryPanelSettings;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { lazy, Suspense, useEffect, useRef, useState } from "react";
|
|
2
|
+
import { lazy, Suspense, useEffect, useId, 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";
|
|
@@ -47,9 +47,17 @@ function ownStorySettings(storySet) {
|
|
|
47
47
|
function ShellTimeline({ hidden, ...bar }) {
|
|
48
48
|
return hidden ? null : _jsx(TimelineBar, { ...bar });
|
|
49
49
|
}
|
|
50
|
+
/** The Developer cog and its drawer; drawn only when the host gave the drawer's content (absent: neither, so an outside page never sees a developer cog). */
|
|
51
|
+
function DeveloperDrawer({ developerMode, onDeveloperModeChange, children }) {
|
|
52
|
+
const drawerId = `${useId()}-developer-tools`;
|
|
53
|
+
if (children === undefined)
|
|
54
|
+
return null;
|
|
55
|
+
return (_jsxs(_Fragment, { children: [_jsx(DeveloperToggle, { developerMode: developerMode, onDeveloperModeChange: onDeveloperModeChange, drawerId: drawerId }), _jsx("aside", { className: "developer-tools", id: drawerId, "data-developer-panel": "", "aria-label": "Developer diagnostics", hidden: !developerMode, children: developerMode ? children : null })] }));
|
|
56
|
+
}
|
|
50
57
|
/** The wide-screen moons toggle and the sheet it opens under the toolbar. */
|
|
51
58
|
function MoonsSheet({ planetLabel, open, onToggle, onClose, children }) {
|
|
52
|
-
|
|
59
|
+
const sheetId = `${useId()}-moons-panel`;
|
|
60
|
+
return (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: "moons-toggle ui-pill", "aria-expanded": open, "aria-controls": sheetId, onClick: onToggle, children: [planetLabel, " moons"] }), _jsx("aside", { id: sheetId, className: "moons-sheet", "data-open": open, "aria-label": "Moons by family", onKeyDown: (event) => { if (event.key === "Escape")
|
|
53
61
|
onClose(); }, children: children })] }));
|
|
54
62
|
}
|
|
55
63
|
/** The serial of a request that is asked again by sending a new one; absent request: undefined. */
|
|
@@ -85,13 +93,14 @@ function infoContent(experience, info, selectedObjectId, timeUtcMs, metricsFor)
|
|
|
85
93
|
const MoonFamilyPanel = lazy(() => import("./MoonFamilyPanel.js").then((module) => ({ default: module.MoonFamilyPanel })));
|
|
86
94
|
/** Canvas-first layout shared by astronomy experiences. Scene and diagnostics stay app-owned. */
|
|
87
95
|
export function AstraeusShell({ experience, snapshot, developerMode, onDeveloperModeChange, onTogglePlayback, onRateChange, paceAuto, onSeek, onCameraRequest, onCameraHold, onSelectionChange, scaleId, onScaleChange, scaleChoices, switcher, displaySwitches, viewChoice, viewCamera, metricsFor, developerTools, storyPanelSettings, timelineGlow, phoneLayout = DEFAULT_PHONE_LAYOUT, highlightedFamily = null, onHighlightFamily, onSetPlaying, panelRequest, onOpenPanelChange, featureRequest, onOpenFeatureChange, pickRequest, children, }) {
|
|
96
|
+
const infoPanelId = `${useId()}-info-panel`;
|
|
88
97
|
const [selectedObjectId, setSelectedObjectId] = useState(() => initialObjectId(experience, snapshot.timeUtcMs));
|
|
89
98
|
const phone = usePhone();
|
|
90
99
|
/** Fixed for the page: a frame does not appear or vanish while the app runs. */
|
|
91
100
|
const [embedded] = useState(isEmbedded);
|
|
92
101
|
const root = useRef(null);
|
|
93
102
|
// 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.
|
|
94
|
-
const { controlsOpen, timelineOpen, openControls, openTimeline } = useDrawers(phone, () => {
|
|
103
|
+
const { controlsOpen, timelineOpen, openControls, openTimeline } = useDrawers(phone, root, () => {
|
|
95
104
|
if (experience.moonFamilies !== undefined) {
|
|
96
105
|
setInfo(null);
|
|
97
106
|
story.close();
|
|
@@ -132,7 +141,7 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
132
141
|
story.open(panel.id);
|
|
133
142
|
};
|
|
134
143
|
useEffect(() => {
|
|
135
|
-
onSelectionChange(selectedObjectId);
|
|
144
|
+
onSelectionChange(selectedObjectId, "visitor");
|
|
136
145
|
}, [onSelectionChange, selectedObjectId]);
|
|
137
146
|
// A view switch is told from other changes of the experience by the view's id changing.
|
|
138
147
|
const { viewId, takeSwitchRule } = useViewSwitch(viewCamera);
|
|
@@ -142,7 +151,7 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
142
151
|
if (selected === undefined || !isObjectAvailable(selected, snapshot.timeUtcMs)) {
|
|
143
152
|
const fallbackId = firstAvailableObject(experience, snapshot.timeUtcMs)?.id ?? "";
|
|
144
153
|
setSelectedObjectId(fallbackId);
|
|
145
|
-
onSelectionChange(fallbackId);
|
|
154
|
+
onSelectionChange(fallbackId, "move");
|
|
146
155
|
// The card of an object the view took away closes with it.
|
|
147
156
|
if (switchRule !== undefined && selected === undefined)
|
|
148
157
|
setInfo((now) => (now?.kind === "object" ? null : now));
|
|
@@ -172,7 +181,7 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
172
181
|
const preset = asked !== undefined && asked.request.kind !== "overview" && target === undefined ? findCameraPreset(experience, "overview") : asked;
|
|
173
182
|
if (target !== undefined) {
|
|
174
183
|
setSelectedObjectId(target.id);
|
|
175
|
-
onSelectionChange(target.id);
|
|
184
|
+
onSelectionChange(target.id, "move"); // only the move-driven effect applies a view rule
|
|
176
185
|
}
|
|
177
186
|
setActivePresetId(preset?.id ?? null);
|
|
178
187
|
if (preset !== undefined)
|
|
@@ -212,7 +221,7 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
212
221
|
if (object === undefined)
|
|
213
222
|
return;
|
|
214
223
|
setSelectedObjectId(id);
|
|
215
|
-
onSelectionChange(id);
|
|
224
|
+
onSelectionChange(id, "visitor");
|
|
216
225
|
setInfo({ kind: "object" });
|
|
217
226
|
const active = experience.cameraPresets.find((preset) => preset.id === activePresetId);
|
|
218
227
|
if (active?.request.kind === "focus" || active?.request.kind === "follow") {
|
|
@@ -236,14 +245,14 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
236
245
|
if (target === undefined)
|
|
237
246
|
return;
|
|
238
247
|
setSelectedObjectId(target.id);
|
|
239
|
-
onSelectionChange(target.id);
|
|
248
|
+
onSelectionChange(target.id, "visitor");
|
|
240
249
|
}
|
|
241
250
|
setActivePresetId(preset.id);
|
|
242
251
|
onCameraRequest(preset.request);
|
|
243
252
|
};
|
|
244
253
|
const seekToEvent = (event) => {
|
|
245
254
|
seek(event.timeUtcMs);
|
|
246
|
-
// The event's own object, framed as the picker's Focus does (and `camera.
|
|
255
|
+
// The event's own object, framed as the picker's Focus does (and `camera.focus` opens): the event, never a default body, names it.
|
|
247
256
|
const object = event.object === undefined ? undefined : availableObjectById(experience, event.object, event.timeUtcMs);
|
|
248
257
|
if (object !== undefined)
|
|
249
258
|
activatePreset(focusPresetFor(experience, object), event.timeUtcMs);
|
|
@@ -265,7 +274,7 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
265
274
|
useEffect(() => { if (info !== null)
|
|
266
275
|
setMoonsOpen(false); }, [info]);
|
|
267
276
|
const selectedLabel = objectLabelOr(experience, selectedObjectId, "Controls");
|
|
268
|
-
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, viewChoice: viewChoice }));
|
|
277
|
+
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" }), infoPanelId: infoPanelId, scaleId: scaleId, onScaleChange: onScaleChange, scaleChoices: scaleChoices, switcher: switcher, displaySwitches: displaySwitches, viewChoice: viewChoice }));
|
|
269
278
|
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 }) }) }));
|
|
270
|
-
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(
|
|
279
|
+
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), id: infoPanelId })] }), story.openPanel !== null && (_jsx(StoryPanelView, { panel: story.openPanel, holding: story.holding, onClose: story.close, onContinue: story.continuePlayback })), _jsx(DeveloperDrawer, { developerMode: developerMode, onDeveloperModeChange: onDeveloperModeChange, children: developerTools }), _jsx(ShellTimeline, { hidden: experience.hideTimeline === true, experience: experience, snapshot: snapshot, onTogglePlayback: onTogglePlayback, onRateChange: onRateChange, paceAuto: paceAuto, 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, infoPanelId: infoPanelId, drawer: phone ? { open: timelineOpen, onOpenChange: openTimeline, swipeThresholdPx: phoneLayout.swipeThresholdPx } : undefined })] }));
|
|
271
280
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { lazy, Suspense, useEffect, useRef, useState } from "react";
|
|
2
|
+
import { lazy, Suspense, useEffect, useId, 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";
|
|
@@ -43,9 +43,17 @@ function ownStorySettings(storySet) {
|
|
|
43
43
|
function ShellTimeline({ hidden, ...bar }) {
|
|
44
44
|
return hidden ? null : _jsx(TimelineBar, { ...bar });
|
|
45
45
|
}
|
|
46
|
+
/** The Developer cog and its drawer; drawn only when the host gave the drawer's content (absent: neither, so an outside page never sees a developer cog). */
|
|
47
|
+
function DeveloperDrawer({ developerMode, onDeveloperModeChange, children }) {
|
|
48
|
+
const drawerId = `${useId()}-developer-tools`;
|
|
49
|
+
if (children === undefined)
|
|
50
|
+
return null;
|
|
51
|
+
return (_jsxs(_Fragment, { children: [_jsx(DeveloperToggle, { developerMode: developerMode, onDeveloperModeChange: onDeveloperModeChange, drawerId: drawerId }), _jsx("aside", { className: "developer-tools", id: drawerId, "data-developer-panel": "", "aria-label": "Developer diagnostics", hidden: !developerMode, children: developerMode ? children : null })] }));
|
|
52
|
+
}
|
|
46
53
|
/** The wide-screen moons toggle and the sheet it opens under the toolbar. */
|
|
47
54
|
function MoonsSheet({ planetLabel, open, onToggle, onClose, children }) {
|
|
48
|
-
|
|
55
|
+
const sheetId = `${useId()}-moons-panel`;
|
|
56
|
+
return (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: "moons-toggle ui-pill", "aria-expanded": open, "aria-controls": sheetId, onClick: onToggle, children: [planetLabel, " moons"] }), _jsx("aside", { id: sheetId, className: "moons-sheet", "data-open": open, "aria-label": "Moons by family", onKeyDown: (event) => { if (event.key === "Escape")
|
|
49
57
|
onClose(); }, children: children })] }));
|
|
50
58
|
}
|
|
51
59
|
/** The serial of a request that is asked again by sending a new one; absent request: undefined. */
|
|
@@ -81,13 +89,14 @@ function infoContent(experience, info, selectedObjectId, timeUtcMs, metricsFor)
|
|
|
81
89
|
const MoonFamilyPanel = lazy(() => import("./MoonFamilyPanel.js").then((module) => ({ default: module.MoonFamilyPanel })));
|
|
82
90
|
/** Canvas-first layout shared by astronomy experiences. Scene and diagnostics stay app-owned. */
|
|
83
91
|
export function AstraeusShell({ experience, snapshot, developerMode, onDeveloperModeChange, onTogglePlayback, onRateChange, paceAuto, onSeek, onCameraRequest, onCameraHold, onSelectionChange, scaleId, onScaleChange, scaleChoices, switcher, displaySwitches, viewChoice, viewCamera, metricsFor, developerTools, storyPanelSettings, timelineGlow, phoneLayout = DEFAULT_PHONE_LAYOUT, highlightedFamily = null, onHighlightFamily, onSetPlaying, panelRequest, onOpenPanelChange, featureRequest, onOpenFeatureChange, pickRequest, children, }) {
|
|
92
|
+
const infoPanelId = `${useId()}-info-panel`;
|
|
84
93
|
const [selectedObjectId, setSelectedObjectId] = useState(() => initialObjectId(experience, snapshot.timeUtcMs));
|
|
85
94
|
const phone = usePhone();
|
|
86
95
|
/** Fixed for the page: a frame does not appear or vanish while the app runs. */
|
|
87
96
|
const [embedded] = useState(isEmbedded);
|
|
88
97
|
const root = useRef(null);
|
|
89
98
|
// 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.
|
|
90
|
-
const { controlsOpen, timelineOpen, openControls, openTimeline } = useDrawers(phone, () => {
|
|
99
|
+
const { controlsOpen, timelineOpen, openControls, openTimeline } = useDrawers(phone, root, () => {
|
|
91
100
|
if (experience.moonFamilies !== undefined) {
|
|
92
101
|
setInfo(null);
|
|
93
102
|
story.close();
|
|
@@ -128,7 +137,7 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
128
137
|
story.open(panel.id);
|
|
129
138
|
};
|
|
130
139
|
useEffect(() => {
|
|
131
|
-
onSelectionChange(selectedObjectId);
|
|
140
|
+
onSelectionChange(selectedObjectId, "visitor");
|
|
132
141
|
}, [onSelectionChange, selectedObjectId]);
|
|
133
142
|
// A view switch is told from other changes of the experience by the view's id changing.
|
|
134
143
|
const { viewId, takeSwitchRule } = useViewSwitch(viewCamera);
|
|
@@ -138,7 +147,7 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
138
147
|
if (selected === undefined || !isObjectAvailable(selected, snapshot.timeUtcMs)) {
|
|
139
148
|
const fallbackId = firstAvailableObject(experience, snapshot.timeUtcMs)?.id ?? "";
|
|
140
149
|
setSelectedObjectId(fallbackId);
|
|
141
|
-
onSelectionChange(fallbackId);
|
|
150
|
+
onSelectionChange(fallbackId, "move");
|
|
142
151
|
// The card of an object the view took away closes with it.
|
|
143
152
|
if (switchRule !== undefined && selected === undefined)
|
|
144
153
|
setInfo((now) => (now?.kind === "object" ? null : now));
|
|
@@ -168,7 +177,7 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
168
177
|
const preset = asked !== undefined && asked.request.kind !== "overview" && target === undefined ? findCameraPreset(experience, "overview") : asked;
|
|
169
178
|
if (target !== undefined) {
|
|
170
179
|
setSelectedObjectId(target.id);
|
|
171
|
-
onSelectionChange(target.id);
|
|
180
|
+
onSelectionChange(target.id, "move"); // only the move-driven effect applies a view rule
|
|
172
181
|
}
|
|
173
182
|
setActivePresetId(preset?.id ?? null);
|
|
174
183
|
if (preset !== undefined)
|
|
@@ -208,7 +217,7 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
208
217
|
if (object === undefined)
|
|
209
218
|
return;
|
|
210
219
|
setSelectedObjectId(id);
|
|
211
|
-
onSelectionChange(id);
|
|
220
|
+
onSelectionChange(id, "visitor");
|
|
212
221
|
setInfo({ kind: "object" });
|
|
213
222
|
const active = experience.cameraPresets.find((preset) => preset.id === activePresetId);
|
|
214
223
|
if (active?.request.kind === "focus" || active?.request.kind === "follow") {
|
|
@@ -232,14 +241,14 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
232
241
|
if (target === undefined)
|
|
233
242
|
return;
|
|
234
243
|
setSelectedObjectId(target.id);
|
|
235
|
-
onSelectionChange(target.id);
|
|
244
|
+
onSelectionChange(target.id, "visitor");
|
|
236
245
|
}
|
|
237
246
|
setActivePresetId(preset.id);
|
|
238
247
|
onCameraRequest(preset.request);
|
|
239
248
|
};
|
|
240
249
|
const seekToEvent = (event) => {
|
|
241
250
|
seek(event.timeUtcMs);
|
|
242
|
-
// The event's own object, framed as the picker's Focus does (and `camera.
|
|
251
|
+
// The event's own object, framed as the picker's Focus does (and `camera.focus` opens): the event, never a default body, names it.
|
|
243
252
|
const object = event.object === undefined ? undefined : availableObjectById(experience, event.object, event.timeUtcMs);
|
|
244
253
|
if (object !== undefined)
|
|
245
254
|
activatePreset(focusPresetFor(experience, object), event.timeUtcMs);
|
|
@@ -261,7 +270,7 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
261
270
|
useEffect(() => { if (info !== null)
|
|
262
271
|
setMoonsOpen(false); }, [info]);
|
|
263
272
|
const selectedLabel = objectLabelOr(experience, selectedObjectId, "Controls");
|
|
264
|
-
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, viewChoice: viewChoice }));
|
|
273
|
+
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" }), infoPanelId: infoPanelId, scaleId: scaleId, onScaleChange: onScaleChange, scaleChoices: scaleChoices, switcher: switcher, displaySwitches: displaySwitches, viewChoice: viewChoice }));
|
|
265
274
|
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 }) }) }));
|
|
266
|
-
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(
|
|
275
|
+
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), id: infoPanelId })] }), story.openPanel !== null && (_jsx(StoryPanelView, { panel: story.openPanel, holding: story.holding, onClose: story.close, onContinue: story.continuePlayback })), _jsx(DeveloperDrawer, { developerMode: developerMode, onDeveloperModeChange: onDeveloperModeChange, children: developerTools }), _jsx(ShellTimeline, { hidden: experience.hideTimeline === true, experience: experience, snapshot: snapshot, onTogglePlayback: onTogglePlayback, onRateChange: onRateChange, paceAuto: paceAuto, 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, infoPanelId: infoPanelId, drawer: phone ? { open: timelineOpen, onOpenChange: openTimeline, swipeThresholdPx: phoneLayout.swipeThresholdPx } : undefined })] }));
|
|
267
276
|
}
|
|
@@ -6,10 +6,11 @@ export declare function writeStoredOpen(storage: Pick<Storage, "setItem"> | unde
|
|
|
6
6
|
/**
|
|
7
7
|
* The one folding section (STYLE-07): a heading that is a real button with `aria-expanded`, over a body that is not drawn while closed.
|
|
8
8
|
* The body is named by its heading, so it is a labelled group for assistive technology. Open or closed is remembered per viewer in
|
|
9
|
-
* browser storage under `
|
|
9
|
+
* browser storage under `fold`, and works without it. `level` is the heading level; `nested` draws a lighter fold inside another.
|
|
10
10
|
*/
|
|
11
|
-
export declare function Collapsible({
|
|
12
|
-
|
|
11
|
+
export declare function Collapsible({ fold, title, defaultOpen, level, nested, className, remember, onOpenChange, children }: {
|
|
12
|
+
/** The fold's name: its storage key and its `data-fold` hook (not a DOM id). */
|
|
13
|
+
readonly fold: string;
|
|
13
14
|
readonly title: string;
|
|
14
15
|
readonly defaultOpen?: boolean;
|
|
15
16
|
readonly level?: 3 | 4;
|
package/src/shell/Collapsible.js
CHANGED
|
@@ -29,15 +29,15 @@ function browserStorage() {
|
|
|
29
29
|
/**
|
|
30
30
|
* The one folding section (STYLE-07): a heading that is a real button with `aria-expanded`, over a body that is not drawn while closed.
|
|
31
31
|
* The body is named by its heading, so it is a labelled group for assistive technology. Open or closed is remembered per viewer in
|
|
32
|
-
* browser storage under `
|
|
32
|
+
* browser storage under `fold`, and works without it. `level` is the heading level; `nested` draws a lighter fold inside another.
|
|
33
33
|
*/
|
|
34
|
-
export function Collapsible({
|
|
34
|
+
export function Collapsible({ fold, title, defaultOpen = false, level = 3, nested = false, className = "", remember = true, onOpenChange, children }) {
|
|
35
35
|
const uid = useId();
|
|
36
|
-
const [open, setOpen] = useState(() => (remember ? readStoredOpen(browserStorage(),
|
|
36
|
+
const [open, setOpen] = useState(() => (remember ? readStoredOpen(browserStorage(), fold, defaultOpen) : defaultOpen));
|
|
37
37
|
useEffect(() => { if (remember)
|
|
38
|
-
writeStoredOpen(browserStorage(),
|
|
38
|
+
writeStoredOpen(browserStorage(), fold, open); }, [fold, open, remember]);
|
|
39
39
|
const Heading = level === 3 ? "h3" : "h4";
|
|
40
40
|
const buttonId = `${uid}-toggle`;
|
|
41
41
|
const bodyId = `${uid}-body`;
|
|
42
|
-
return (_jsxs("section", { className: `collapsible${nested ? " collapsible-nested" : ""}${className === "" ? "" : ` ${className}`}`, "data-fold":
|
|
42
|
+
return (_jsxs("section", { className: `collapsible${nested ? " collapsible-nested" : ""}${className === "" ? "" : ` ${className}`}`, "data-fold": fold, children: [_jsx(Heading, { className: "collapsible-heading", children: _jsxs("button", { type: "button", id: buttonId, className: "ui-row collapsible-toggle", "data-fold-toggle": fold, "aria-expanded": open, "aria-controls": bodyId, onClick: () => { setOpen(!open); onOpenChange?.(!open); }, children: [_jsx("span", { children: title }), _jsx("svg", { width: "14", height: "14", viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: "1.6", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "M2 4l4 4 4-4" }) })] }) }), _jsx("div", { id: bodyId, className: "collapsible-body", role: "group", "aria-labelledby": buttonId, hidden: !open, children: open ? children : null })] }));
|
|
43
43
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
2
3
|
import { ChevronIcon } from "./topBarIcons.js";
|
|
3
4
|
import { useDrawerSwipe } from "./useDrawerSwipe.js";
|
|
4
5
|
/**
|
|
@@ -6,11 +7,12 @@ import { useDrawerSwipe } from "./useDrawerSwipe.js";
|
|
|
6
7
|
* under it closes it by a tap or a swipe up. The controls stay mounted while it is closed (state survives) but are hidden from sight and focus.
|
|
7
8
|
*/
|
|
8
9
|
export function ControlsDrawer({ label, open, onOpenChange, swipeThresholdPx, children }) {
|
|
10
|
+
const drawerId = `${useId()}-controls-drawer`;
|
|
9
11
|
const opening = useDrawerSwipe({ thresholdPx: swipeThresholdPx, onTap: () => onOpenChange(true), onSwipe: (direction) => { if (direction === "down")
|
|
10
12
|
onOpenChange(true); } });
|
|
11
13
|
const closing = useDrawerSwipe({ thresholdPx: swipeThresholdPx, onTap: () => onOpenChange(false), onSwipe: (direction) => { if (direction === "up")
|
|
12
14
|
onOpenChange(false); } });
|
|
13
|
-
return (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: "controls-pill ui-pill", "aria-label": `Show controls: ${label}`, "aria-expanded": open, "aria-controls":
|
|
15
|
+
return (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: "controls-pill ui-pill", "aria-label": `Show controls: ${label}`, "aria-expanded": open, "aria-controls": drawerId, ...opening, children: [_jsx("span", { className: "controls-pill-name", children: label }), _jsx(ChevronIcon, {})] }), _jsxs("div", { id: drawerId, className: "controls-drawer", role: "region", "aria-label": "Controls", "data-open": open,
|
|
14
16
|
// A dropdown closes the drawer on its change, not on the tap that opens it (owner bug, 2026-10-18: the drawer shut as the picker opened).
|
|
15
17
|
onClick: (event) => { const closer = event.target.closest("[data-closes-drawer]"); if (closer !== null && closer.tagName !== "SELECT")
|
|
16
18
|
onOpenChange(false); }, onChange: (event) => { if (event.target.closest("[data-closes-drawer]") !== null)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useId, useRef, useState } from "react";
|
|
3
|
+
import { keyIsForViewer } from "./viewerKeys.js";
|
|
3
4
|
import { ButtonText, OrbitIcon, SwitchesIcon } from "./topBarIcons.js";
|
|
4
5
|
/** The view choice as a button group in the bar (and the phone drawer's grid), with the look of the experience switch's options. Fewer than two views: nothing to choose. */
|
|
5
6
|
export function ViewButtons({ choice }) {
|
|
@@ -33,7 +34,7 @@ function SwitchPanel({ switches, viewChoice }) {
|
|
|
33
34
|
return undefined;
|
|
34
35
|
const outside = (event) => { if (!root.current?.contains(event.target))
|
|
35
36
|
setOpen(false); };
|
|
36
|
-
const escape = (event) => { if (!event.defaultPrevented && event.key === "Escape")
|
|
37
|
+
const escape = (event) => { if (!event.defaultPrevented && event.key === "Escape" && keyIsForViewer(event, root.current))
|
|
37
38
|
setOpen(false); };
|
|
38
39
|
document.addEventListener("pointerdown", outside);
|
|
39
40
|
document.addEventListener("keydown", escape);
|
package/src/shell/InfoPanel.d.ts
CHANGED
|
@@ -4,10 +4,12 @@ interface Props {
|
|
|
4
4
|
readonly view: InfoView;
|
|
5
5
|
readonly metrics: readonly Metric[];
|
|
6
6
|
readonly onClose: () => void;
|
|
7
|
+
/** The panel's id, made once per viewer by the shell so the buttons that open it can name it. */
|
|
8
|
+
readonly id: string;
|
|
7
9
|
}
|
|
8
10
|
/**
|
|
9
11
|
* On-demand detail for one object or event; on a phone a bottom sheet with swipe to dismiss. Non-modal: the canvas and controls stay usable around it, and
|
|
10
12
|
* focus stays where the viewer is (choosing in the object picker must not jump into the panel).
|
|
11
13
|
*/
|
|
12
|
-
export declare function InfoPanel({ view, metrics, onClose }: Props): import("react").JSX.Element;
|
|
14
|
+
export declare function InfoPanel({ view, metrics, onClose, id }: Props): import("react").JSX.Element;
|
|
13
15
|
export {};
|
package/src/shell/InfoPanel.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useRef } from "react";
|
|
2
|
+
import { useId, useRef } from "react";
|
|
3
3
|
import { MetricVisual } from "./MetricVisual.js";
|
|
4
4
|
import { ProvenanceBadge } from "./ProvenanceBadge.js";
|
|
5
5
|
import { useSwipeToDismiss } from "./useSwipeToDismiss.js";
|
|
@@ -7,14 +7,15 @@ import { useSwipeToDismiss } from "./useSwipeToDismiss.js";
|
|
|
7
7
|
* On-demand detail for one object or event; on a phone a bottom sheet with swipe to dismiss. Non-modal: the canvas and controls stay usable around it, and
|
|
8
8
|
* focus stays where the viewer is (choosing in the object picker must not jump into the panel).
|
|
9
9
|
*/
|
|
10
|
-
export function InfoPanel({ view, metrics, onClose }) {
|
|
10
|
+
export function InfoPanel({ view, metrics, onClose, id }) {
|
|
11
|
+
const titleId = `${useId()}-title`;
|
|
11
12
|
const targetKey = `${view.target.kind}:${view.target.id}`;
|
|
12
13
|
const sheet = useRef(null);
|
|
13
14
|
useSwipeToDismiss(sheet, onClose);
|
|
14
|
-
return (_jsxs("aside", { id:
|
|
15
|
+
return (_jsxs("aside", { id: id, className: "info-panel", ref: sheet, "aria-labelledby": titleId, "data-info-kind": view.target.kind, "data-info-id": view.target.id, onKeyDown: (event) => {
|
|
15
16
|
if (event.key !== "Escape")
|
|
16
17
|
return;
|
|
17
18
|
event.stopPropagation();
|
|
18
19
|
onClose();
|
|
19
|
-
}, children: [_jsx("div", { className: "sheet-handle", "aria-hidden": "true" }), _jsxs("header", { className: "info-panel-header", children: [_jsx("h2", { id:
|
|
20
|
+
}, children: [_jsx("div", { className: "sheet-handle", "aria-hidden": "true" }), _jsxs("header", { className: "info-panel-header", children: [_jsx("h2", { id: titleId, children: view.title }), _jsx("button", { type: "button", className: "info-panel-close ui-pill", "aria-label": "Close information", onClick: onClose, children: "Close" })] }), view.subtitle !== undefined && _jsx("p", { className: "info-panel-subtitle", children: _jsx("span", { className: "info-panel-badge", children: view.subtitle }) }), view.provenance !== null && _jsx(ProvenanceBadge, { provenance: view.provenance }, targetKey), view.description !== undefined && _jsx("p", { className: "info-panel-description", children: view.description }), view.facts !== undefined && (_jsx("dl", { className: "info-panel-facts", children: view.facts.map((fact) => _jsxs("div", { className: "info-panel-fact", children: [_jsx("dt", { children: fact.label }), _jsx("dd", { children: fact.value })] }, fact.label)) })), metrics.length > 0 && (_jsx("div", { className: "info-panel-metrics", children: metrics.map((metric) => _jsx(MetricVisual, { metric: metric }, metric.id)) }))] }));
|
|
20
21
|
}
|
|
@@ -23,6 +23,6 @@ export function MoonFamilyPanel({ list, highlightedFamily, onHighlight, onSelect
|
|
|
23
23
|
const folded = list.families.filter((family) => family !== featured);
|
|
24
24
|
return (_jsxs("section", { className: "moon-panel", "aria-label": `${list.planetLabel}'s moons`, "data-highlight": highlightedFamily ?? "", children: [_jsx("p", { className: "moon-note moon-summary", "data-moon-summary": moonFamilyListSummary(list), children: moonFamilyListSummary(list) }), _jsxs("label", { className: "moon-search", htmlFor: searchId, children: [_jsx("span", { className: "moon-search-label", children: "Find a moon" }), _jsx("input", { id: searchId, type: "search", className: "moon-search-input", value: query, placeholder: "Name or designation", autoComplete: "off", spellCheck: false, onChange: (event) => setQuery(event.target.value) })] }), searching && (_jsx("div", { className: "moon-results", role: "group", "aria-label": "Search results", "aria-live": "polite", children: matches.length === 0 ? _jsxs("p", { className: "moon-note", children: ["No moon matches \u201C", query.trim(), "\u201D."] }) : (_jsx("ul", { className: "moon-list", children: matches.map(({ moon, familyLabel }) => moonButton(moon, familyLabel)) })) })), _jsxs("div", { className: "moon-families", hidden: searching, children: [featured !== undefined && (_jsxs("div", { className: "moon-featured", "data-moon-family": featured.id, "data-lit": highlightedFamily === featured.id, children: [_jsx("h3", { className: "moon-featured-heading", children: _jsxs("button", { type: "button", className: "ui-row", "aria-pressed": highlightedFamily === featured.id, "data-moon-light": featured.id, onClick: () => onHighlight(highlightedFamily === featured.id ? null : featured.id), children: [_jsx("span", { children: featured.label }), _jsx("span", { className: "moon-count", children: moonCountText(featured.moons.length) })] }) }), _jsx("p", { className: "moon-note", children: featured.description }), _jsx("ul", { className: "moon-pictures", children: featured.moons.map((moon) => (_jsx("li", { children: _jsxs("button", { type: "button", className: "ui-row moon-picture", "data-moon": moon.id, "data-closes-drawer": "", onClick: () => onSelectMoon(moon.id), children: [moon.pictureUrl !== undefined && _jsx("span", { className: "moon-disc", style: { backgroundImage: `url(${moon.pictureUrl})` }, "aria-hidden": "true" }), _jsx("span", { children: moon.label })] }) }, moon.id))) })] })), folded.map((family) => {
|
|
25
25
|
const { named, unnamed } = splitNamed(family.moons);
|
|
26
|
-
return (_jsx("div", { className: "moon-family", "data-moon-family": family.id, "data-lit": highlightedFamily === family.id, children: _jsxs(Collapsible, {
|
|
26
|
+
return (_jsx("div", { className: "moon-family", "data-moon-family": family.id, "data-lit": highlightedFamily === family.id, children: _jsxs(Collapsible, { fold: `moons-${family.id}`, title: `${family.label} (${family.moons.length})`, remember: false, nested: true, onOpenChange: (open) => toggleLight(family, open), children: [_jsx("p", { className: "moon-note", children: family.description }), named.length > 0 && _jsx("ul", { className: "moon-list", children: named.map((moon) => moonButton(moon)) }), unnamed.length > 0 && (_jsx(Collapsible, { fold: `moons-${family.id}-unnamed`, title: `+${unnamed.length} unnamed`, remember: false, level: 4, nested: true, children: _jsx("ul", { className: "moon-list", children: unnamed.map((moon) => moonButton(moon)) }) }))] }) }, family.id));
|
|
27
27
|
})] })] }));
|
|
28
28
|
}
|
|
@@ -8,6 +8,8 @@ interface Props {
|
|
|
8
8
|
readonly onCameraPreset: (preset: ExperienceCameraPreset) => void;
|
|
9
9
|
readonly infoOpen: boolean;
|
|
10
10
|
readonly onToggleInfo: () => void;
|
|
11
|
+
/** The id of the information panel the Info button opens, made once per viewer by the shell. */
|
|
12
|
+
readonly infoPanelId: string;
|
|
11
13
|
}
|
|
12
|
-
export declare function ObjectControls({ experience, timeUtcMs, selectedObjectId, activePresetId, onSelectObject, onCameraPreset, infoOpen, onToggleInfo, }: Props): import("react").JSX.Element;
|
|
14
|
+
export declare function ObjectControls({ experience, timeUtcMs, selectedObjectId, activePresetId, onSelectObject, onCameraPreset, infoOpen, onToggleInfo, infoPanelId, }: Props): import("react").JSX.Element;
|
|
13
15
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { findCameraPreset, focusPresetFor, isObjectAvailable, listedObjects, relatedObjects } from "./objectModel.js";
|
|
3
3
|
import { ButtonText, FocusIcon, FollowIcon, InfoIcon, OrbitIcon, OverviewIcon } from "./topBarIcons.js";
|
|
4
|
-
export function ObjectControls({ experience, timeUtcMs, selectedObjectId, activePresetId, onSelectObject, onCameraPreset, infoOpen, onToggleInfo, }) {
|
|
4
|
+
export function ObjectControls({ experience, timeUtcMs, selectedObjectId, activePresetId, onSelectObject, onCameraPreset, infoOpen, onToggleInfo, infoPanelId, }) {
|
|
5
5
|
const selected = experience.objects.find((object) => object.id === selectedObjectId);
|
|
6
6
|
const selectedAvailable = selected !== undefined && isObjectAvailable(selected, timeUtcMs);
|
|
7
7
|
const overview = findCameraPreset(experience, "overview");
|
|
@@ -14,5 +14,5 @@ export function ObjectControls({ experience, timeUtcMs, selectedObjectId, active
|
|
|
14
14
|
return (_jsxs("section", { className: "object-controls", "aria-label": "Object and camera controls", children: [_jsx("select", { className: "object-picker", "data-closes-drawer": "", "aria-label": "Select object", value: selectedObjectId, onChange: (event) => onSelectObject(event.target.value), children: listedObjects(experience, selectedObjectId).map((object) => {
|
|
15
15
|
const available = isObjectAvailable(object, timeUtcMs);
|
|
16
16
|
return (_jsxs("option", { value: object.id, disabled: !available, "data-available": available, "data-available-from": object.availability?.startUtcMs, "data-available-to": object.availability?.endUtcMs, children: [object.label, available ? "" : " (Unavailable)"] }, object.id));
|
|
17
|
-
}) }), _jsxs("button", { type: "button", className: "top-bar-button ui-icon object-info-toggle", "data-closes-drawer": "", "aria-label": selected === undefined ? "Information" : `Information about ${selected.label}`, title: selected === undefined ? "Information" : `Information about ${selected.label}`, "aria-expanded": infoOpen, "aria-controls":
|
|
17
|
+
}) }), _jsxs("button", { type: "button", className: "top-bar-button ui-icon object-info-toggle", "data-closes-drawer": "", "aria-label": selected === undefined ? "Information" : `Information about ${selected.label}`, title: selected === undefined ? "Information" : `Information about ${selected.label}`, "aria-expanded": infoOpen, "aria-controls": infoPanelId, disabled: !selectedAvailable, onClick: onToggleInfo, children: [_jsx(InfoIcon, {}), _jsx(ButtonText, { children: "Info" })] }), _jsxs("div", { className: "object-camera-actions", children: [renderPreset(focus), renderPreset(follow), renderPreset(overview), related.map((object) => (_jsxs("button", { type: "button", className: "top-bar-button ui-icon object-related", "aria-label": object.label, title: object.label, "data-related-object": object.id, disabled: !isObjectAvailable(object, timeUtcMs), onClick: () => onSelectObject(object.id), children: [_jsx(OrbitIcon, {}), _jsx(ButtonText, { children: object.label })] }, object.id)))] })] }));
|
|
18
18
|
}
|
package/src/shell/Sources.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A collapsible section, closed until tapped (O-020 Decision 4). The credits stay complete and one tap away (PROV-01).
|
|
3
|
-
* Shared by the information and story panels. With `details` it is "The details and sources" (O-015 Decision 5)
|
|
4
|
-
* details paragraphs
|
|
3
|
+
* Shared by the information and story panels. With `details` it is "The details and sources" (O-015 Decision 5); without, it is "Sources".
|
|
4
|
+
* Inside: the details paragraphs, then the `accuracy` and `notes` when given, then the sources.
|
|
5
5
|
*/
|
|
6
|
-
export declare function Sources({ sources, details }: {
|
|
6
|
+
export declare function Sources({ sources, details, accuracy, notes }: {
|
|
7
7
|
readonly sources: readonly string[];
|
|
8
8
|
readonly details?: readonly string[];
|
|
9
|
+
readonly accuracy?: string;
|
|
10
|
+
readonly notes?: string;
|
|
9
11
|
}): import("react").JSX.Element;
|
package/src/shell/Sources.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/**
|
|
3
3
|
* A collapsible section, closed until tapped (O-020 Decision 4). The credits stay complete and one tap away (PROV-01).
|
|
4
|
-
* Shared by the information and story panels. With `details` it is "The details and sources" (O-015 Decision 5)
|
|
5
|
-
* details paragraphs
|
|
4
|
+
* Shared by the information and story panels. With `details` it is "The details and sources" (O-015 Decision 5); without, it is "Sources".
|
|
5
|
+
* Inside: the details paragraphs, then the `accuracy` and `notes` when given, then the sources.
|
|
6
6
|
*/
|
|
7
|
-
export function Sources({ sources, details = [] }) {
|
|
8
|
-
return (_jsxs("details", { className: "sources-section", children: [_jsxs("summary", { className: "ui-button ui-row", children: [details.length > 0 ? _jsx("span", { children: "The details and sources" }) : _jsxs("span", { children: ["Sources ", _jsxs("span", { className: "sources-count", children: ["\u00B7 ", sources.length] })] }), _jsx("svg", { width: "14", height: "14", viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: "1.6", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "M2 4l4 4 4-4" }) })] }), details.length > 0 && _jsx("div", { className: "sources-details", children: details.map((paragraph) => _jsx("p", { children: paragraph }, paragraph)) }), _jsx("ul", { children: sources.map((source) => _jsx("li", { children: source }, source)) })] }));
|
|
7
|
+
export function Sources({ sources, details = [], accuracy, notes = "" }) {
|
|
8
|
+
return (_jsxs("details", { className: "sources-section", children: [_jsxs("summary", { className: "ui-button ui-row", children: [details.length > 0 ? _jsx("span", { children: "The details and sources" }) : _jsxs("span", { children: ["Sources ", _jsxs("span", { className: "sources-count", children: ["\u00B7 ", sources.length] })] }), _jsx("svg", { width: "14", height: "14", viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: "1.6", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "M2 4l4 4 4-4" }) })] }), details.length > 0 && _jsx("div", { className: "sources-details", children: details.map((paragraph) => _jsx("p", { children: paragraph }, paragraph)) }), accuracy !== undefined && (_jsxs("dl", { className: "provenance-detail sources-trust", children: [_jsx("dt", { children: "Accuracy" }), _jsx("dd", { children: accuracy }), notes.length > 0 && _jsxs(_Fragment, { children: [_jsx("dt", { children: "Notes" }), _jsx("dd", { children: notes })] })] })), _jsx("ul", { children: sources.map((source) => _jsx("li", { children: source }, source)) })] }));
|
|
9
9
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { ProvenanceSourceType } from "../core/provenance.js";
|
|
2
|
+
import type { StoryPanel } from "./storyPanels.js";
|
|
2
3
|
/** A small pill saying how far to trust a panel's facts, after Planetary Explorer's Badge. */
|
|
3
|
-
export declare function StoryBadge({
|
|
4
|
-
readonly
|
|
4
|
+
export declare function StoryBadge({ sourceType }: {
|
|
5
|
+
readonly sourceType: ProvenanceSourceType;
|
|
5
6
|
}): import("react").JSX.Element;
|
|
6
7
|
interface Props {
|
|
7
8
|
readonly panel: StoryPanel;
|
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useRef } from "react";
|
|
2
|
+
import { useEffect, useId, useRef } from "react";
|
|
3
|
+
import { keyIsForViewer } from "./viewerKeys.js";
|
|
3
4
|
import { Sources } from "./Sources.js";
|
|
4
|
-
import {
|
|
5
|
+
import { PROVENANCE_STATUS } from "./infoModel.js";
|
|
5
6
|
import { useSwipeToDismiss } from "./useSwipeToDismiss.js";
|
|
6
7
|
import { useZoomThrough } from "./useZoomThrough.js";
|
|
7
8
|
/** A small pill saying how far to trust a panel's facts, after Planetary Explorer's Badge. */
|
|
8
|
-
export function StoryBadge({
|
|
9
|
-
return _jsx("span", { className: "story-badge", "data-badge":
|
|
9
|
+
export function StoryBadge({ sourceType }) {
|
|
10
|
+
return _jsx("span", { className: "story-badge", "data-badge": sourceType, children: PROVENANCE_STATUS[sourceType] });
|
|
10
11
|
}
|
|
11
12
|
/**
|
|
12
13
|
* One story panel: a side panel beside the scene on a wide screen, a bottom sheet with a grab handle on a phone
|
|
13
14
|
* (the stylesheet chooses). Closing, Escape and a swipe down all dismiss it.
|
|
14
15
|
*/
|
|
15
16
|
export function StoryPanelView({ panel, holding, onClose, onContinue }) {
|
|
17
|
+
const titleId = `${useId()}-title`;
|
|
16
18
|
const sheet = useRef(null);
|
|
17
19
|
useSwipeToDismiss(sheet, onClose);
|
|
18
20
|
useZoomThrough(sheet);
|
|
19
21
|
useEffect(() => {
|
|
20
|
-
const onKey = (event) => { if (!event.defaultPrevented && event.key === "Escape")
|
|
22
|
+
const onKey = (event) => { if (!event.defaultPrevented && event.key === "Escape" && keyIsForViewer(event, sheet.current))
|
|
21
23
|
onClose(); };
|
|
22
24
|
document.addEventListener("keydown", onKey);
|
|
23
25
|
return () => document.removeEventListener("keydown", onKey);
|
|
24
26
|
}, [onClose]);
|
|
25
|
-
return (_jsxs("aside", { className: "story-panel", ref: sheet, role: "dialog", "aria-modal": "false", "aria-labelledby":
|
|
27
|
+
return (_jsxs("aside", { className: "story-panel", ref: sheet, role: "dialog", "aria-modal": "false", "aria-labelledby": titleId, "data-panel-id": panel.id, children: [_jsx("div", { className: "sheet-handle", "aria-hidden": "true" }), _jsxs("header", { className: "story-panel-header", children: [_jsx(StoryBadge, { sourceType: panel.provenance.sourceType }), _jsx("button", { type: "button", className: "story-panel-close ui-icon", "aria-label": "Close story panel", onClick: onClose, children: "\u00D7" })] }), _jsx("h2", { id: titleId, children: panel.title }), _jsx("div", { className: "story-panel-body", children: panel.body.map((paragraph) => _jsx("p", { children: paragraph }, paragraph)) }), _jsx(Sources, { sources: panel.provenance.sources, details: panel.details, accuracy: panel.provenance.accuracy, notes: panel.provenance.notes }), holding && _jsx("button", { type: "button", className: "story-panel-continue ui-accent", onClick: onContinue, children: "Continue playback" })] }));
|
|
26
28
|
}
|
|
@@ -1,24 +1,18 @@
|
|
|
1
|
-
/** A choice
|
|
1
|
+
/** A choice a host offers between versions of its scene (a host's picker, `Scene.setPicker`): the control only reports a press, it never reads or writes the address. Names come from the host's data, never from the shell. */
|
|
2
2
|
export interface ExperienceSwitch {
|
|
3
3
|
/** The accessible name of the group. */
|
|
4
4
|
readonly label: string;
|
|
5
|
-
/**
|
|
5
|
+
/** Names the choice; drawn as `data-switch-param`. */
|
|
6
6
|
readonly param: string;
|
|
7
|
-
/**
|
|
8
|
-
readonly
|
|
9
|
-
/** The clock's time now, in UTC ms: when `keep` names `t`, the switch carries this time, not the one the address was opened with. Given by the app, which owns the clock. */
|
|
10
|
-
readonly currentTimeUtcMs?: () => number;
|
|
11
|
-
/** Opens the address a choice leads to inside the running page (the entry pushes it into history and rebuilds); absent: the page navigates to it. Given by the entry through the app. */
|
|
12
|
-
readonly open?: (address: string) => void;
|
|
7
|
+
/** A press of an option other than the pressed one calls this with the option's value and does nothing else. */
|
|
8
|
+
readonly choose: (value: string) => void;
|
|
13
9
|
readonly options: readonly {
|
|
14
10
|
readonly label: string;
|
|
15
11
|
readonly value: string;
|
|
16
12
|
readonly active: boolean;
|
|
17
13
|
}[];
|
|
18
14
|
}
|
|
19
|
-
/**
|
|
20
|
-
export declare function switchAddress(href: string, param: string, value: string, keep?: readonly string[], timeUtcMs?: number): string;
|
|
21
|
-
/** One button per option in the top bar (and the phone drawer); choosing one asks for the new address to be opened. Fewer than two options: nothing to choose, no control. */
|
|
15
|
+
/** One button per option in the top bar (and the phone drawer); choosing one reports it to the host. Fewer than two options: nothing to choose, no control. */
|
|
22
16
|
export declare function SwitchControl({ choice }: {
|
|
23
17
|
readonly choice: ExperienceSwitch;
|
|
24
18
|
}): import("react").JSX.Element | null;
|
|
@@ -1,26 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/**
|
|
3
|
-
export function switchAddress(href, param, value, keep = [], timeUtcMs) {
|
|
4
|
-
const url = new URL(href);
|
|
5
|
-
url.searchParams.set(param, value);
|
|
6
|
-
// The clock's time at the press (whole seconds, as the view link writes it) replaces whatever `t` the address was opened with.
|
|
7
|
-
if (keep.includes("t") && timeUtcMs !== undefined)
|
|
8
|
-
url.searchParams.set("t", new Date(Math.round(timeUtcMs / 1000) * 1000).toISOString());
|
|
9
|
-
for (const own of ["view", "t"])
|
|
10
|
-
if (!keep.includes(own))
|
|
11
|
-
url.searchParams.delete(own);
|
|
12
|
-
return url.toString();
|
|
13
|
-
}
|
|
14
|
-
function openAddress(choice, address) {
|
|
15
|
-
if (choice.open !== undefined)
|
|
16
|
-
choice.open(address);
|
|
17
|
-
else
|
|
18
|
-
window.location.assign(address);
|
|
19
|
-
}
|
|
20
|
-
/** One button per option in the top bar (and the phone drawer); choosing one asks for the new address to be opened. Fewer than two options: nothing to choose, no control. */
|
|
2
|
+
/** One button per option in the top bar (and the phone drawer); choosing one reports it to the host. Fewer than two options: nothing to choose, no control. */
|
|
21
3
|
export function SwitchControl({ choice }) {
|
|
22
4
|
if (choice.options.length < 2)
|
|
23
5
|
return null;
|
|
24
6
|
return (_jsx("section", { className: "switch-control", role: "group", "aria-label": choice.label, "data-switch-param": choice.param, children: choice.options.map((option) => (_jsx("button", { type: "button", className: `switch-option top-bar-button ${option.active ? "ui-accent" : ""}`, "aria-pressed": option.active, "data-switch-value": option.value, onClick: () => { if (!option.active)
|
|
25
|
-
|
|
7
|
+
choice.choose(option.value); }, children: _jsx("span", { children: option.label }) }, option.value))) }));
|
|
26
8
|
}
|