astraeus 0.9.0 → 0.9.2
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 +40 -0
- package/README.md +102 -35
- package/package.json +1 -1
- package/src/api/assembleScene.js +5 -5
- package/src/api/errors.d.ts +1 -1
- package/src/api/index.d.ts +2 -2
- package/src/api/look.d.ts +14 -0
- package/src/api/lookInput.d.ts +1 -1
- package/src/api/lookInput.js +6 -2
- package/src/api/planBodies.d.ts +2 -1
- package/src/api/planBodies.js +6 -1
- package/src/api/planCamera.d.ts +19 -2
- package/src/api/planCamera.js +45 -6
- package/src/api/planPaths.d.ts +2 -0
- package/src/api/planPaths.js +13 -8
- package/src/api/planStory.d.ts +3 -1
- package/src/api/planStory.js +5 -0
- package/src/api/planTimeline.d.ts +1 -1
- package/src/api/planTimeline.js +10 -1
- package/src/api/planViews.d.ts +3 -1
- package/src/api/planViews.js +4 -0
- package/src/api/providerPathTimes.d.ts +10 -0
- package/src/api/providerPathTimes.js +109 -0
- package/src/api/scene.d.ts +17 -5
- package/src/api/scene.js +16 -2
- package/src/api/sceneReads.d.ts +31 -1
- package/src/api/shownDuring.d.ts +12 -0
- package/src/api/shownDuring.js +30 -0
- package/src/api/story.d.ts +10 -3
- package/src/api/story.js +11 -4
- package/src/api/switches.d.ts +1 -0
- package/src/api/switches.js +3 -1
- package/src/api/time.d.ts +1 -1
- package/src/api/time.js +4 -1
- package/src/app/App.js +58 -21
- package/src/app/App.node.js +58 -21
- package/src/app/AstraeusScene.d.ts +8 -1
- package/src/app/CameraController.d.ts +4 -1
- package/src/app/CameraController.js +15 -3
- package/src/app/SkyFiguresView.d.ts +2 -2
- package/src/app/SkyFiguresView.js +25 -14
- package/src/app/displaySwitches.d.ts +2 -0
- package/src/app/displaySwitches.js +1 -1
- package/src/app/liveLook.d.ts +4 -1
- package/src/app/liveLook.js +29 -1
- package/src/app/look.d.ts +5 -0
- package/src/app/look.js +8 -2
- package/src/app/sceneCamera.js +14 -2
- package/src/app/sceneContentsHooks.js +1 -1
- package/src/app/sceneFrame.d.ts +14 -5
- package/src/app/sceneFrame.js +31 -21
- package/src/app/scenePointer.d.ts +5 -1
- package/src/app/scenePointer.js +8 -3
- package/src/app/timeLook.d.ts +7 -0
- package/src/app/timeLook.js +8 -0
- package/src/app/viewHiding.d.ts +8 -1
- package/src/app/viewHiding.js +23 -0
- package/src/core/clock.js +2 -1
- package/src/core/lookValues.d.ts +13 -0
- package/src/core/lookValues.js +39 -0
- package/src/core/pacing.d.ts +38 -6
- package/src/core/pacing.js +141 -21
- package/src/core/state.d.ts +2 -0
- package/src/core/state.js +5 -1
- package/src/core/storyPanels.d.ts +8 -4
- package/src/core/storyPanels.js +17 -5
- package/src/shell/AstraeusShell.d.ts +7 -1
- package/src/shell/AstraeusShell.js +39 -14
- package/src/shell/AstraeusShell.node.js +39 -14
- package/src/shell/ObjectControls.js +2 -2
- package/src/shell/TimelineBar.d.ts +6 -2
- package/src/shell/TimelineBar.js +17 -12
- package/src/shell/TimelineBar.node.js +17 -12
- package/src/shell/experience.d.ts +9 -0
- package/src/shell/infoModel.d.ts +2 -1
- package/src/shell/infoModel.js +10 -10
- package/src/shell/objectModel.d.ts +3 -2
- package/src/shell/objectModel.js +6 -4
- package/src/shell/storyPanels.d.ts +19 -1
- package/src/shell/storyPanels.js +34 -2
- package/src/shell/timelineModel.d.ts +11 -0
- package/src/shell/timelineModel.js +28 -0
- package/src/shell/useStoryPanels.d.ts +4 -0
- package/src/shell/useStoryPanels.js +27 -6
|
@@ -15,6 +15,7 @@ import { labelStyleVars } from "../app/labelStyle.js";
|
|
|
15
15
|
import { DEFAULT_PHONE_LAYOUT, phoneLayoutStyle, pickOpensInfo, usePhone } from "./phoneLayout.js";
|
|
16
16
|
import { presetForViewRule } from "./viewCamera.js";
|
|
17
17
|
import { DeveloperToggle, TopBar } from "./TopBar.node.js";
|
|
18
|
+
import { shownAt } from "../app/viewHiding.js";
|
|
18
19
|
import { availableObjectById, findCameraPreset, firstAvailableObject, focusPresetFor, isObjectAvailable, skyFigureById } from "./objectModel.js";
|
|
19
20
|
/** Keeps `--timeline-space` at the distance from the screen's bottom to the top of the timeline bar, so a phone sheet can sit above it. */
|
|
20
21
|
function useTimelineSpace(root, phone) {
|
|
@@ -41,7 +42,7 @@ export function initialObjectId(experience, timeUtcMs) {
|
|
|
41
42
|
}
|
|
42
43
|
/** The story-panel settings the experience carries itself, used when the app gives none live. */
|
|
43
44
|
function ownStorySettings(storySet) {
|
|
44
|
-
return { autoOpen: storySet?.autoOpen ?? false, pauseSeconds: storySet?.pauseSeconds ?? 0 };
|
|
45
|
+
return { autoOpen: storySet?.autoOpen ?? false, pauseSeconds: storySet?.pauseSeconds ?? 0, ...(storySet?.closeAfterSeconds === undefined ? {} : { closeAfterSeconds: storySet.closeAfterSeconds }) };
|
|
45
46
|
}
|
|
46
47
|
/** The timeline bar, or nothing when the experience says it has no timeline. */
|
|
47
48
|
function ShellTimeline({ hidden, ...bar }) {
|
|
@@ -66,6 +67,12 @@ function selectionLost(selected, timeUtcMs, clearedByHost, isFigure) {
|
|
|
66
67
|
// A selected sky figure is never lost: it has no availability and no view hides it.
|
|
67
68
|
return !clearedByHost && !isFigure && (selected === undefined || !isObjectAvailable(selected, timeUtcMs));
|
|
68
69
|
}
|
|
70
|
+
/** What a camera preset's object asks of the camera at `timeUtcMs`: "hold" when its shown time has ended or not begun (keep the pose), "overview" when it is gone or unavailable, else undefined. */
|
|
71
|
+
function cameraTargetLoss(target, timeUtcMs) {
|
|
72
|
+
if (target !== undefined && !shownAt(target, timeUtcMs))
|
|
73
|
+
return "hold";
|
|
74
|
+
return target === undefined || !isObjectAvailable(target, timeUtcMs) ? "overview" : undefined;
|
|
75
|
+
}
|
|
69
76
|
function serialOf(request) {
|
|
70
77
|
return request?.serial;
|
|
71
78
|
}
|
|
@@ -110,17 +117,17 @@ function objectLabelOr(experience, objectId, fallback) {
|
|
|
110
117
|
return experience.objects.find((object) => object.id === objectId)?.label ?? skyFigureById(experience, objectId)?.label ?? fallback;
|
|
111
118
|
}
|
|
112
119
|
/** The information panel's content and, for an object, its live measurements. */
|
|
113
|
-
function infoContent(experience, info, selectedObjectId, timeUtcMs, metricsFor) {
|
|
120
|
+
function infoContent(experience, info, selectedObjectId, timeUtcMs, metricsFor, timeLook) {
|
|
114
121
|
const view = info === null
|
|
115
122
|
? null
|
|
116
|
-
: infoView(experience, info.kind === "object" ? { kind: "object", id: selectedObjectId } : info, timeUtcMs);
|
|
123
|
+
: infoView(experience, info.kind === "object" ? { kind: "object", id: selectedObjectId } : info, timeUtcMs, timeLook);
|
|
117
124
|
const metrics = view?.target.kind === "object" && metricsFor !== undefined && skyFigureById(experience, view.target.id) === undefined ? metricsFor(view.target.id, timeUtcMs) : [];
|
|
118
125
|
return { view, metrics };
|
|
119
126
|
}
|
|
120
127
|
/** The moon families load on demand: only an experience with `moonFamilies` draws them (I-089). */
|
|
121
128
|
const MoonFamilyPanel = lazy(() => import("./MoonFamilyPanel.js").then((module) => ({ default: module.MoonFamilyPanel })));
|
|
122
129
|
/** Canvas-first layout shared by astronomy experiences. Scene and diagnostics stay app-owned. */
|
|
123
|
-
export function AstraeusShell({ experience, snapshot, developerMode, onDeveloperModeChange, onTogglePlayback, onRateChange, paceAuto, onSeek, onCameraRequest, onTurnToFigure, onCameraHold, hostCameraSet, storySeekNote, onSelectionChange, scaleId, onScaleChange, scaleChoices, switcher, displaySwitches, viewChoice, viewCamera, metricsFor, developerTools, storyPanelSettings, timelineGlow, phoneLayout = DEFAULT_PHONE_LAYOUT, labelStyle, highlightedFamily = null, onHighlightFamily, onSetPlaying, panelRequest, onOpenPanelChange, featureRequest, onOpenFeatureChange, pickRequest, selectRequest, onSelectRequestApplied, children, }) {
|
|
130
|
+
export function AstraeusShell({ experience, snapshot, developerMode, onDeveloperModeChange, onTogglePlayback, onRateChange, paceAuto, onSeek, onCameraRequest, onTurnToFigure, onCameraHold, onTimeShown, hostCameraSet, storySeekNote, onSelectionChange, scaleId, onScaleChange, scaleChoices, switcher, displaySwitches, viewChoice, viewCamera, metricsFor, developerTools, storyPanelSettings, timelineGlow, phoneLayout = DEFAULT_PHONE_LAYOUT, labelStyle, timeLook, highlightedFamily = null, onHighlightFamily, onSetPlaying, panelRequest, onOpenPanelChange, featureRequest, onOpenFeatureChange, pickRequest, selectRequest, onSelectRequestApplied, children, }) {
|
|
124
131
|
const infoPanelId = `${useId()}-info-panel`;
|
|
125
132
|
const [selectedObjectId, setSelectedObjectId] = useState(() => initialObjectId(experience, snapshot.timeUtcMs));
|
|
126
133
|
const phone = usePhone();
|
|
@@ -198,6 +205,7 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
198
205
|
if (switchRule !== undefined && selected === undefined)
|
|
199
206
|
setInfo((now) => (now?.kind === "object" ? null : now));
|
|
200
207
|
}
|
|
208
|
+
onTimeShown?.(snapshot.timeUtcMs);
|
|
201
209
|
const active = experience.cameraPresets.find((preset) => preset.id === activePresetId);
|
|
202
210
|
const activeRequest = active?.request;
|
|
203
211
|
if (switchRule?.rule === "start" && switchRule.framing?.always === true) {
|
|
@@ -208,12 +216,8 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
208
216
|
if (switchRule !== undefined && target === undefined) {
|
|
209
217
|
applyViewRule(switchRule);
|
|
210
218
|
}
|
|
211
|
-
else
|
|
212
|
-
|
|
213
|
-
if (overview !== undefined) {
|
|
214
|
-
setActivePresetId(overview.id);
|
|
215
|
-
onCameraRequest(overview.request);
|
|
216
|
-
}
|
|
219
|
+
else {
|
|
220
|
+
loseCameraTarget(cameraTargetLoss(target, snapshot.timeUtcMs));
|
|
217
221
|
}
|
|
218
222
|
}
|
|
219
223
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -233,6 +237,20 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
233
237
|
// Only a new request applies.
|
|
234
238
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
235
239
|
}, [requestedSelectSerial]);
|
|
240
|
+
/** The camera's object is gone or not shown: "hold" keeps the pose and stops following (its shown time ended or has not begun, no jump); "overview" frames the overview. */
|
|
241
|
+
const loseCameraTarget = (loss) => {
|
|
242
|
+
if (loss === "hold") {
|
|
243
|
+
setActivePresetId(null);
|
|
244
|
+
onCameraHold?.();
|
|
245
|
+
}
|
|
246
|
+
else if (loss === "overview") {
|
|
247
|
+
const overview = findCameraPreset(experience, "overview");
|
|
248
|
+
if (overview !== undefined) {
|
|
249
|
+
setActivePresetId(overview.id);
|
|
250
|
+
onCameraRequest(overview.request);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
};
|
|
236
254
|
/** The view's camera rule for a followed or focused object the new view does not show: `stay` keeps the pose and stops following; otherwise the rule's framing is requested. */
|
|
237
255
|
const applyViewRule = (rule) => {
|
|
238
256
|
const asked = presetForViewRule(rule, experience);
|
|
@@ -261,11 +279,18 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
261
279
|
setInfo({ kind: "object" });
|
|
262
280
|
};
|
|
263
281
|
/** An object tapped or clicked in the scene: the picker's focus; on a wide screen it also opens the card, on a phone it does not (T-138). A tapped body-set member that is no listed object just flies there. */
|
|
264
|
-
const pickObject = (id) => {
|
|
282
|
+
const pickObject = (id, keepSky = false) => {
|
|
265
283
|
const object = availableObjectById(experience, id, snapshot.timeUtcMs);
|
|
266
284
|
if (skyFigureById(experience, id) !== undefined) {
|
|
267
285
|
selectFigure(id, pickOpensInfo(phone));
|
|
268
286
|
}
|
|
287
|
+
else if (object !== undefined && keepSky) {
|
|
288
|
+
// A tap from a look-out camera: select it and stay in the sky (owner, 2026-11-15); the menu's Focus and Follow still fly there.
|
|
289
|
+
setSelectedObjectId(object.id);
|
|
290
|
+
onSelectionChange(object.id, "visitor");
|
|
291
|
+
if (pickOpensInfo(phone))
|
|
292
|
+
setInfo({ kind: "object" });
|
|
293
|
+
}
|
|
269
294
|
else if (object !== undefined) {
|
|
270
295
|
activatePreset(focusPresetFor(experience, object));
|
|
271
296
|
if (pickOpensInfo(phone))
|
|
@@ -277,7 +302,7 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
277
302
|
const requestedPickSerial = serialOf(pickRequest);
|
|
278
303
|
useEffect(() => {
|
|
279
304
|
if (pickRequest !== null && pickRequest !== undefined)
|
|
280
|
-
pickObject(pickRequest.id);
|
|
305
|
+
pickObject(pickRequest.id, pickRequest.keepSky === true);
|
|
281
306
|
// Only a new request flies; the handler reads the current time and experience.
|
|
282
307
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
283
308
|
}, [requestedPickSerial]);
|
|
@@ -346,7 +371,7 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
346
371
|
if (info?.kind === "window")
|
|
347
372
|
setInfo({ kind: "window", id: window.id });
|
|
348
373
|
};
|
|
349
|
-
const { view, metrics } = infoContent(experience, info, selectedObjectId, snapshot.timeUtcMs, metricsFor);
|
|
374
|
+
const { view, metrics } = infoContent(experience, info, selectedObjectId, snapshot.timeUtcMs, metricsFor, timeLook);
|
|
350
375
|
// On a wide screen the moons sheet and the information panel share the left column under the toolbar: opening one closes the other.
|
|
351
376
|
const toggleMoons = () => {
|
|
352
377
|
if (!moonsOpen)
|
|
@@ -358,5 +383,5 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
358
383
|
const selectedLabel = objectLabelOr(experience, selectedObjectId, "Controls");
|
|
359
384
|
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 }));
|
|
360
385
|
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 }) }) }));
|
|
361
|
-
return (_jsxs("main", { className: "astraeus-shell", ref: root, "data-phone": phone, "data-timeline-hidden": experience.hideTimeline === true, "data-embedded": embedded, style: { ...phoneLayoutStyle(phoneLayout), ...labelStyleVars(labelStyle) }, 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: closePanel, onContinue: story.continuePlayback, step: stepNav })), _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 })] }));
|
|
386
|
+
return (_jsxs("main", { className: "astraeus-shell", ref: root, "data-phone": phone, "data-timeline-hidden": experience.hideTimeline === true, "data-embedded": embedded, style: { ...phoneLayoutStyle(phoneLayout), ...labelStyleVars(labelStyle) }, 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: closePanel, onContinue: story.continuePlayback, step: stepNav })), _jsx(DeveloperDrawer, { developerMode: developerMode, onDeveloperModeChange: onDeveloperModeChange, children: developerTools }), _jsx(ShellTimeline, { hidden: experience.hideTimeline === true, experience: experience, snapshot: snapshot, timeLook: timeLook, 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 })] }));
|
|
362
387
|
}
|
|
@@ -7,14 +7,14 @@ export function ObjectControls({ experience, timeUtcMs, selectedObjectId, active
|
|
|
7
7
|
const selectedAvailable = selected !== undefined && isObjectAvailable(selected, timeUtcMs);
|
|
8
8
|
const infoLabel = selected?.label ?? selectedFigure?.label;
|
|
9
9
|
const overview = findCameraPreset(experience, "overview");
|
|
10
|
-
const focus = selected === undefined ? undefined : focusPresetFor(experience, selected);
|
|
10
|
+
const focus = selected === undefined ? undefined : experience.focusListed === true ? findCameraPreset(experience, "focus", selected.id) : focusPresetFor(experience, selected);
|
|
11
11
|
const follow = selected === undefined ? undefined : findCameraPreset(experience, "follow", selected.id);
|
|
12
12
|
const lookOut = selected === undefined ? undefined : findCameraPreset(experience, "lookOut", selected.id);
|
|
13
13
|
const related = selected === undefined ? [] : relatedObjects(experience, selected.id);
|
|
14
14
|
const presetIcon = (preset) => preset.request.kind === "overview" ? _jsx(OverviewIcon, {}) : preset.request.kind === "follow" ? _jsx(FollowIcon, {}) : preset.request.kind === "lookOut" ? _jsx(LookOutIcon, {}) : _jsx(FocusIcon, {});
|
|
15
15
|
const presetText = (preset) => (preset.request.kind === "overview" ? "Overview" : preset.request.kind === "follow" ? "Follow" : preset.request.kind === "lookOut" ? "Look out" : "Focus");
|
|
16
16
|
const renderPreset = (preset) => preset && (_jsxs("button", { type: "button", className: "top-bar-button ui-icon", "data-closes-drawer": "", "aria-label": preset.label, title: preset.label, "aria-pressed": activePresetId === preset.id, "data-camera-preset": preset.id, onClick: () => onCameraPreset(preset), disabled: preset.request.kind !== "overview" && !selectedAvailable, children: [presetIcon(preset), _jsx(ButtonText, { children: presetText(preset) })] }, preset.id));
|
|
17
|
-
return (_jsxs("section", { className: "object-controls", "aria-label": "Object and camera controls", children: [_jsxs("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) => {
|
|
17
|
+
return (_jsxs("section", { className: "object-controls", "aria-label": "Object and camera controls", children: [_jsxs("select", { className: "object-picker", "data-closes-drawer": "", "aria-label": "Select object", value: selectedObjectId, onChange: (event) => onSelectObject(event.target.value), children: [listedObjects(experience, selectedObjectId, timeUtcMs).map((object) => {
|
|
18
18
|
const available = isObjectAvailable(object, timeUtcMs);
|
|
19
19
|
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));
|
|
20
20
|
}), listedFigures(experience, selectedObjectId).map((figure) => _jsx("option", { value: figure.id, "data-sky-figure": "", children: figure.label }, figure.id))] }), _jsxs("button", { type: "button", className: "top-bar-button ui-icon object-info-toggle", "data-closes-drawer": "", "aria-label": infoLabel === undefined ? "Information" : `Information about ${infoLabel}`, title: infoLabel === undefined ? "Information" : `Information about ${infoLabel}`, "aria-expanded": infoOpen, "aria-controls": infoPanelId, disabled: !selectedAvailable && selectedFigure === undefined, onClick: onToggleInfo, children: [_jsx(InfoIcon, {}), _jsx(ButtonText, { children: "Info" })] }), _jsxs("div", { className: "object-camera-actions", children: [renderPreset(focus), renderPreset(follow), renderPreset(lookOut), 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)))] })] }));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ClockSnapshot } from "../core/clock.js";
|
|
2
2
|
import type { TimelineEvent } from "../core/events.js";
|
|
3
3
|
import type { TimelineWindow } from "../core/timeWindow.js";
|
|
4
|
+
import { type TimeLook } from "./timelineModel.js";
|
|
4
5
|
import { type TimelineGlowLook } from "./timelineGlow.js";
|
|
5
6
|
import type { ExperienceConfig } from "./experience.js";
|
|
6
7
|
import type { StoryPanel } from "./storyPanels.js";
|
|
@@ -27,6 +28,8 @@ interface Props {
|
|
|
27
28
|
readonly onWindowInfo: (window: TimelineWindow) => void;
|
|
28
29
|
/** How the activity glow looks (live settings); absent: the defaults. */
|
|
29
30
|
readonly glowLook?: TimelineGlowLook;
|
|
31
|
+
/** The zone and precision every time reads in (the look `time`). Default UTC to the second. */
|
|
32
|
+
readonly timeLook?: TimeLook;
|
|
30
33
|
/** On a phone the timeline has a drawer (speed slider, events) under its two lines; absent: the larger-screen bar. */
|
|
31
34
|
readonly drawer?: {
|
|
32
35
|
readonly open: boolean;
|
|
@@ -36,10 +39,11 @@ interface Props {
|
|
|
36
39
|
/** The id of the information panel the event buttons open, made once per viewer by the shell. */
|
|
37
40
|
readonly infoPanelId: string;
|
|
38
41
|
}
|
|
39
|
-
export declare function TimelineBar({ experience, snapshot, onTogglePlayback, onRateChange, paceAuto, onSeek, panels, openPanelId, onPanelOpen, onEventSeek, onEventInfo, onWindowSeek, onWindowInfo, glowLook, drawer, infoPanelId }: Props): import("react").JSX.Element;
|
|
42
|
+
export declare function TimelineBar({ experience, snapshot, onTogglePlayback, onRateChange, paceAuto, onSeek, panels, openPanelId, onPanelOpen, onEventSeek, onEventInfo, onWindowSeek, onWindowInfo, glowLook, timeLook: timeLookProp, drawer, infoPanelId }: Props): import("react").JSX.Element;
|
|
40
43
|
interface ExpandedProps {
|
|
41
44
|
readonly experience: ExperienceConfig;
|
|
42
45
|
readonly snapshot: ClockSnapshot;
|
|
46
|
+
readonly timeLook?: TimeLook;
|
|
43
47
|
readonly onEventSeek: (event: TimelineEvent) => void;
|
|
44
48
|
readonly onEventInfo: (event: TimelineEvent) => void;
|
|
45
49
|
readonly onWindowInfo: (window: TimelineWindow) => void;
|
|
@@ -49,5 +53,5 @@ interface ExpandedProps {
|
|
|
49
53
|
* The timeline's expanded content: "Just happened / Up next / Inside" and the full event list.
|
|
50
54
|
* On larger screens it opens from the Events button; the phone drawer shows the same content when expanded.
|
|
51
55
|
*/
|
|
52
|
-
export declare function TimelineExpanded({ experience, snapshot, onEventSeek, onEventInfo, onWindowInfo, infoPanelId }: ExpandedProps): import("react").JSX.Element;
|
|
56
|
+
export declare function TimelineExpanded({ experience, snapshot, timeLook, onEventSeek, onEventInfo, onWindowInfo, infoPanelId }: ExpandedProps): import("react").JSX.Element;
|
|
53
57
|
export {};
|
package/src/shell/TimelineBar.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useId, useMemo, useRef, useState } from "react";
|
|
3
|
-
import { eventContextAt, formatUtcTimestamp, formatWindowRate, navigationStops, windowContextAt, timePositionPercent, speedsOf, TIMELINE_STEP_MS, clampToBounds, formatRateCompact, formatRate, groupMarkers } from "./timelineModel.js";
|
|
3
|
+
import { DEFAULT_TIME_LOOK, withDefaultTime, eventContextAt, formatTime, formatUtcTimestamp, formatWindowRate, navigationStops, windowContextAt, timePositionPercent, speedsOf, TIMELINE_STEP_MS, clampToBounds, formatRateCompact, formatRate, groupMarkers } from "./timelineModel.js";
|
|
4
4
|
import { activityAt, DEFAULT_TIMELINE_GLOW, glowDescription, glowGradient, glowProfile, glowTooltip } from "./timelineGlow.js";
|
|
5
5
|
import { Label } from "./Label.js";
|
|
6
6
|
import { useDrawerSwipe } from "./useDrawerSwipe.js";
|
|
@@ -13,13 +13,18 @@ function autoLabel(showRate, rate) {
|
|
|
13
13
|
function SpeedMenu({ speeds, rate, paceAuto, compact, onRateChange }) {
|
|
14
14
|
return (_jsxs("label", { className: "timeline-speed", children: [_jsx("span", { children: "Playback rate" }), _jsxs("select", { "aria-label": "Playback speed", title: "Playback speed", value: paceAuto === true ? "auto" : rate, onChange: (event) => onRateChange(event.target.value === "auto" ? "auto" : Number(event.target.value)), children: [paceAuto !== undefined && _jsx("option", { value: "auto", children: autoLabel(paceAuto && !compact, rate) }), speeds.map((speed) => _jsx("option", { value: speed.rate, children: compact ? formatRateCompact(speed.rate) : speed.label }, speed.rate))] })] }));
|
|
15
15
|
}
|
|
16
|
+
/** The timestamp as the narrow bar shows it: UTC ISO text without its seconds and `T`; a zone's text as it is. */
|
|
17
|
+
function shortTimestamp(timestamp, timeLook) {
|
|
18
|
+
return timeLook.zone === "UTC" ? timestamp.slice(0, 16).replace("T", " ") : timestamp;
|
|
19
|
+
}
|
|
16
20
|
/** The seek slider's spoken value: the time, with the activity window and its rate when one is running. */
|
|
17
|
-
function seekValueText(timeUtcMs, activityNow) {
|
|
21
|
+
function seekValueText(timeUtcMs, activityNow, timeLook) {
|
|
18
22
|
if (activityNow === null || activityNow.window.rate === undefined)
|
|
19
|
-
return
|
|
20
|
-
return `${
|
|
23
|
+
return formatTime(timeUtcMs, timeLook);
|
|
24
|
+
return `${formatTime(timeUtcMs, timeLook)}, ${activityNow.window.label}: ${formatWindowRate(activityNow.rate, activityNow.window.rate.unit)}`;
|
|
21
25
|
}
|
|
22
|
-
export function TimelineBar({ experience, snapshot, onTogglePlayback, onRateChange, paceAuto, onSeek, panels = [], openPanelId = null, onPanelOpen, onEventSeek, onEventInfo, onWindowSeek, onWindowInfo, glowLook = DEFAULT_TIMELINE_GLOW, drawer, infoPanelId }) {
|
|
26
|
+
export function TimelineBar({ experience, snapshot, onTogglePlayback, onRateChange, paceAuto, onSeek, panels = [], openPanelId = null, onPanelOpen, onEventSeek, onEventInfo, onWindowSeek, onWindowInfo, glowLook = DEFAULT_TIMELINE_GLOW, timeLook: timeLookProp, drawer, infoPanelId }) {
|
|
27
|
+
const timeLook = withDefaultTime(timeLookProp);
|
|
23
28
|
const drawerId = `${useId()}-timeline-drawer`;
|
|
24
29
|
const windows = experience.windows ?? [];
|
|
25
30
|
const profile = useMemo(() => glowProfile(windows, experience.window), [windows, experience.window]);
|
|
@@ -28,7 +33,7 @@ export function TimelineBar({ experience, snapshot, onTogglePlayback, onRateChan
|
|
|
28
33
|
const [hoverTitle, setHoverTitle] = useState(null);
|
|
29
34
|
const playedPercent = timePositionPercent(clampToBounds(snapshot.timeUtcMs, experience.window), experience.window);
|
|
30
35
|
const activityNow = activityAt(windows, snapshot.timeUtcMs);
|
|
31
|
-
const valueText = seekValueText(snapshot.timeUtcMs, activityNow);
|
|
36
|
+
const valueText = seekValueText(snapshot.timeUtcMs, activityNow, timeLook);
|
|
32
37
|
const moveOnTrack = (event) => {
|
|
33
38
|
if (profile === null)
|
|
34
39
|
return;
|
|
@@ -46,7 +51,7 @@ export function TimelineBar({ experience, snapshot, onTogglePlayback, onRateChan
|
|
|
46
51
|
};
|
|
47
52
|
const stopLabel = (direction, stop) => windows.length === 0 || stop === null ? `${direction} event` : `${direction}: ${stop.label}`;
|
|
48
53
|
const speeds = speedsOf(experience.rates);
|
|
49
|
-
const timestamp =
|
|
54
|
+
const timestamp = formatTime(snapshot.timeUtcMs, timeLook);
|
|
50
55
|
const handle = useDrawerSwipe({
|
|
51
56
|
thresholdPx: drawer?.swipeThresholdPx ?? 0,
|
|
52
57
|
onTap: () => drawer?.onOpenChange(!drawer.open),
|
|
@@ -86,12 +91,12 @@ export function TimelineBar({ experience, snapshot, onTogglePlayback, onRateChan
|
|
|
86
91
|
}, children: [_jsx("span", { className: "timeline-glow-ahead" }), _jsx("span", { className: "timeline-glow-played", children: _jsx("span", { className: "timeline-glow-line" }) })] }), _jsx("div", { className: "timeline-markers", ref: markersRef, "aria-label": "Timeline event markers", children: groups.map((group) => group.members.length === 1
|
|
87
92
|
? renderMarker(group.members[0], group.positionPercent)
|
|
88
93
|
: (_jsxs("div", { className: "timeline-marker-group", "data-align": group.positionPercent < 25 ? "start" : group.positionPercent > 75 ? "end" : "middle", style: { left: `${group.positionPercent}%` }, onKeyDown: (event) => { if (event.key === "Escape")
|
|
89
|
-
setOpenGroup(null); }, children: [_jsx("button", { type: "button", className: "timeline-marker timeline-group-toggle", "aria-expanded": openGroup === group.members[0].key, "aria-label": `${group.members.length} markers close together: show list`, title: `${group.members.length} markers`, onClick: () => setOpenGroup((open) => (open === group.members[0].key ? null : group.members[0].key)), children: _jsx("span", { className: "timeline-group-count", children: group.members.length }) }), openGroup === group.members[0].key && (_jsx("ul", { className: "timeline-group-list", "aria-label": "Markers close together", children: group.members.map((member) => (_jsx("li", { children: _jsx("button", { type: "button", className: "timeline-group-item", "aria-label": member.ariaLabel, "data-time-utc-ms": member.timeUtcMs, "data-panel-id": member.kind === "panel" ? member.key : undefined, onClick: () => { member.activate(); setOpenGroup(null); }, children: member.text }) }, member.key))) }))] }, `group-${group.members[0].key}`))) }), _jsx("input", { type: "range", "aria-label": "Seek timeline", "aria-valuetext": valueText, min: experience.window.startUtcMs, max: experience.window.endUtcMs, step: TIMELINE_STEP_MS, value: clampToBounds(snapshot.timeUtcMs, experience.window), onChange: (event) => onSeek(Number(event.target.value)) })] }), _jsxs("div", { className: "timeline-bounds", "aria-hidden": "true", children: [_jsx("time", { dateTime: formatUtcTimestamp(experience.window.startUtcMs), children:
|
|
94
|
+
setOpenGroup(null); }, children: [_jsx("button", { type: "button", className: "timeline-marker timeline-group-toggle", "aria-expanded": openGroup === group.members[0].key, "aria-label": `${group.members.length} markers close together: show list`, title: `${group.members.length} markers`, onClick: () => setOpenGroup((open) => (open === group.members[0].key ? null : group.members[0].key)), children: _jsx("span", { className: "timeline-group-count", children: group.members.length }) }), openGroup === group.members[0].key && (_jsx("ul", { className: "timeline-group-list", "aria-label": "Markers close together", children: group.members.map((member) => (_jsx("li", { children: _jsx("button", { type: "button", className: "timeline-group-item", "aria-label": member.ariaLabel, "data-time-utc-ms": member.timeUtcMs, "data-panel-id": member.kind === "panel" ? member.key : undefined, onClick: () => { member.activate(); setOpenGroup(null); }, children: member.text }) }, member.key))) }))] }, `group-${group.members[0].key}`))) }), _jsx("input", { type: "range", "aria-label": "Seek timeline", "aria-valuetext": valueText, min: experience.window.startUtcMs, max: experience.window.endUtcMs, step: TIMELINE_STEP_MS, value: clampToBounds(snapshot.timeUtcMs, experience.window), onChange: (event) => onSeek(Number(event.target.value)) })] }), _jsxs("div", { className: "timeline-bounds", "aria-hidden": "true", children: [_jsx("time", { dateTime: formatUtcTimestamp(experience.window.startUtcMs), children: formatTime(experience.window.startUtcMs, { ...timeLook, precision: "day" }) }), _jsx("time", { dateTime: formatUtcTimestamp(experience.window.endUtcMs), children: formatTime(experience.window.endUtcMs, { ...timeLook, precision: "day" }) })] })] }));
|
|
90
95
|
return (_jsxs("section", { className: "timeline-bar", "aria-label": "Timeline controls", "data-drawer-open": drawer?.open, children: [drawer !== undefined && (_jsx("button", { type: "button", className: "drawer-handle drawer-handle-top ui-bare", "aria-label": "Timeline drawer", "aria-expanded": drawer.open, "aria-controls": drawerId, ...handle, children: _jsx("span", {}) })), _jsxs("div", { className: "timeline-main-row", children: [_jsxs("div", { className: "timeline-transport", children: [_jsx("button", { type: "button", className: "timeline-play ui-icon ui-accent", title: snapshot.playing ? "Pause" : "Play", onClick: onTogglePlayback, "aria-label": snapshot.playing ? "Pause playback" : "Play playback", children: snapshot.playing ? _jsx(Symbol, { path: "M7 5h3.5v14H7zM13.5 5H17v14h-3.5z" }) : _jsx(Symbol, { path: "M7 5v14l12-7z" }) }), _jsx("button", { type: "button", className: "timeline-previous ui-icon ui-ghost", "aria-label": stopLabel("Previous", navigation.previous), title: stopLabel("Previous", navigation.previous), disabled: navigation.previous === null, onClick: () => { if (navigation.previous !== null)
|
|
91
96
|
goToStop(navigation.previous); }, children: _jsx(Symbol, { path: "M6 5h2v14H6zM19 5v14L9 12z" }) }), _jsx("button", { type: "button", className: "timeline-next ui-icon ui-ghost", "aria-label": stopLabel("Next", navigation.next), title: stopLabel("Next", navigation.next), disabled: navigation.next === null, onClick: () => { if (navigation.next !== null)
|
|
92
|
-
goToStop(navigation.next); }, children: _jsx(Symbol, { path: "M16 5h2v14h-2zM5 5v14l10-7z" }) })] }), _jsxs("time", { className: "timeline-time", dateTime:
|
|
97
|
+
goToStop(navigation.next); }, children: _jsx(Symbol, { path: "M16 5h2v14h-2zM5 5v14l10-7z" }) })] }), _jsxs("time", { className: "timeline-time", dateTime: formatUtcTimestamp(snapshot.timeUtcMs), "aria-label": timestamp, children: [_jsx("span", { className: "timeline-time-full", children: timestamp }), _jsx("span", { className: "timeline-time-short", "aria-hidden": "true", children: shortTimestamp(timestamp, timeLook) })] }), _jsx(SpeedMenu, { speeds: speeds, rate: snapshot.rate, paceAuto: paceAuto, compact: drawer !== undefined, onRateChange: onRateChange }), scrubber, drawer === undefined && (_jsxs("details", { className: "timeline-event-list", children: [_jsxs("summary", { className: "ui-button", title: "Events: what just happened, what is next, and the full list", children: ["Events ", _jsxs("span", { children: ["(", experience.events.length, ")"] })] }), _jsx(TimelineExpanded, { experience: experience, snapshot: snapshot, timeLook: timeLook, onEventSeek: onEventSeek, onEventInfo: onEventInfo, onWindowInfo: onWindowInfo, infoPanelId: infoPanelId })] }))] }), drawer !== undefined && (_jsx("div", { id: drawerId, className: "timeline-drawer", role: "region", "aria-label": "Timeline details", "data-open": drawer.open, onClick: (event) => { const closer = event.target.closest("[data-closes-drawer]"); if (closer !== null && closer.tagName !== "SELECT")
|
|
93
98
|
drawer.onOpenChange(false); }, children: _jsxs("div", { className: "timeline-drawer-body", children: [_jsxs("div", { className: "timeline-speed-slider", children: [_jsx("span", { "aria-hidden": "true", children: "Playback speed" }), _jsx("input", { type: "range", "aria-label": "Speed slider", "aria-valuetext": speedText, min: 0, max: speeds.length - 1, step: 1, value: speedIndex, onChange: (event) => { const next = speeds[Number(event.target.value)]; if (next !== undefined)
|
|
94
|
-
onRateChange(next.rate); } }), _jsx("output", { children: speedText })] }), _jsx(TimelineExpanded, { experience: experience, snapshot: snapshot, onEventSeek: onEventSeek, onEventInfo: onEventInfo, onWindowInfo: onWindowInfo, infoPanelId: infoPanelId })] }) }))] }));
|
|
99
|
+
onRateChange(next.rate); } }), _jsx("output", { children: speedText })] }), _jsx(TimelineExpanded, { experience: experience, snapshot: snapshot, timeLook: timeLook, onEventSeek: onEventSeek, onEventInfo: onEventInfo, onWindowInfo: onWindowInfo, infoPanelId: infoPanelId })] }) }))] }));
|
|
95
100
|
}
|
|
96
101
|
/** A 24x24 filled symbol; the button around it carries the accessible name and tooltip. */
|
|
97
102
|
function Symbol({ path }) {
|
|
@@ -101,11 +106,11 @@ function Symbol({ path }) {
|
|
|
101
106
|
* The timeline's expanded content: "Just happened / Up next / Inside" and the full event list.
|
|
102
107
|
* On larger screens it opens from the Events button; the phone drawer shows the same content when expanded.
|
|
103
108
|
*/
|
|
104
|
-
export function TimelineExpanded({ experience, snapshot, onEventSeek, onEventInfo, onWindowInfo, infoPanelId }) {
|
|
109
|
+
export function TimelineExpanded({ experience, snapshot, timeLook = DEFAULT_TIME_LOOK, onEventSeek, onEventInfo, onWindowInfo, infoPanelId }) {
|
|
105
110
|
const context = eventContextAt(experience.events, snapshot.timeUtcMs);
|
|
106
111
|
const inside = windowContextAt(experience.windows ?? [], snapshot.timeUtcMs);
|
|
107
112
|
return (_jsxs("div", { className: "timeline-expanded", children: [_jsxs("div", { className: "timeline-event-context", "aria-label": "Event context", children: [context.current === null
|
|
108
113
|
? _jsxs("span", { children: [_jsx("strong", { children: "Just happened:" }), " No event yet"] })
|
|
109
114
|
: (_jsxs("button", { type: "button", className: "timeline-event-current ui-row", "data-closes-drawer": "", "aria-label": `Information about ${context.current.label}`, "aria-controls": infoPanelId, onClick: () => { if (context.current !== null)
|
|
110
|
-
onEventInfo(context.current); }, children: [_jsx("strong", { children: "Just happened:" }), " ", context.current.label, " ", _jsx("span", { "aria-hidden": "true", children: "\u24D8" })] })), _jsxs("span", { children: [_jsx("strong", { children: "Up next:" }), " ", context.next?.label ?? "No upcoming event"] }), inside.map(({ window, rate }) => (_jsxs("button", { type: "button", className: "timeline-event-current timeline-window-current ui-row", "data-closes-drawer": "", "aria-label": `Information about ${window.label}`, "aria-controls": infoPanelId, onClick: () => onWindowInfo(window), children: [_jsx("strong", { children: "Inside:" }), " ", window.label, rate !== null && window.rate !== undefined && _jsxs(_Fragment, { children: [" \u2014 ", formatWindowRate(rate, window.rate.unit)] }), " ", _jsx("span", { "aria-hidden": "true", children: "\u24D8" })] }, window.id)))] }), _jsx("ol", { children: experience.events.map((event) => (_jsx("li", { children: _jsxs("button", { type: "button", className: "ui-row", "data-closes-drawer": "", "aria-current": context.current?.id === event.id ? "time" : undefined, onClick: () => { onEventSeek(event); onEventInfo(event); }, children: [_jsx("time", { dateTime: formatUtcTimestamp(event.timeUtcMs), children:
|
|
115
|
+
onEventInfo(context.current); }, children: [_jsx("strong", { children: "Just happened:" }), " ", context.current.label, " ", _jsx("span", { "aria-hidden": "true", children: "\u24D8" })] })), _jsxs("span", { children: [_jsx("strong", { children: "Up next:" }), " ", context.next?.label ?? "No upcoming event"] }), inside.map(({ window, rate }) => (_jsxs("button", { type: "button", className: "timeline-event-current timeline-window-current ui-row", "data-closes-drawer": "", "aria-label": `Information about ${window.label}`, "aria-controls": infoPanelId, onClick: () => onWindowInfo(window), children: [_jsx("strong", { children: "Inside:" }), " ", window.label, rate !== null && window.rate !== undefined && _jsxs(_Fragment, { children: [" \u2014 ", formatWindowRate(rate, window.rate.unit)] }), " ", _jsx("span", { "aria-hidden": "true", children: "\u24D8" })] }, window.id)))] }), _jsx("ol", { children: experience.events.map((event) => (_jsx("li", { children: _jsxs("button", { type: "button", className: "ui-row", "data-closes-drawer": "", "aria-current": context.current?.id === event.id ? "time" : undefined, onClick: () => { onEventSeek(event); onEventInfo(event); }, children: [_jsx("time", { dateTime: formatUtcTimestamp(event.timeUtcMs), children: formatTime(event.timeUtcMs, timeLook) }), _jsx("span", { children: event.label })] }) }, event.id))) })] }));
|
|
111
116
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useId, useMemo, useRef, useState } from "react";
|
|
3
|
-
import { eventContextAt, formatUtcTimestamp, formatWindowRate, navigationStops, windowContextAt, timePositionPercent, speedsOf, TIMELINE_STEP_MS, clampToBounds, formatRateCompact, formatRate, groupMarkers } from "./timelineModel.js";
|
|
3
|
+
import { DEFAULT_TIME_LOOK, withDefaultTime, eventContextAt, formatTime, formatUtcTimestamp, formatWindowRate, navigationStops, windowContextAt, timePositionPercent, speedsOf, TIMELINE_STEP_MS, clampToBounds, formatRateCompact, formatRate, groupMarkers } from "./timelineModel.js";
|
|
4
4
|
import { activityAt, DEFAULT_TIMELINE_GLOW, glowDescription, glowGradient, glowProfile, glowTooltip } from "./timelineGlow.js";
|
|
5
5
|
import { Label } from "./Label.js";
|
|
6
6
|
import { useDrawerSwipe } from "./useDrawerSwipe.js";
|
|
@@ -12,13 +12,18 @@ function autoLabel(showRate, rate) {
|
|
|
12
12
|
function SpeedMenu({ speeds, rate, paceAuto, compact, onRateChange }) {
|
|
13
13
|
return (_jsxs("label", { className: "timeline-speed", children: [_jsx("span", { children: "Playback rate" }), _jsxs("select", { "aria-label": "Playback speed", title: "Playback speed", value: paceAuto === true ? "auto" : rate, onChange: (event) => onRateChange(event.target.value === "auto" ? "auto" : Number(event.target.value)), children: [paceAuto !== undefined && _jsx("option", { value: "auto", children: autoLabel(paceAuto && !compact, rate) }), speeds.map((speed) => _jsx("option", { value: speed.rate, children: compact ? formatRateCompact(speed.rate) : speed.label }, speed.rate))] })] }));
|
|
14
14
|
}
|
|
15
|
+
/** The timestamp as the narrow bar shows it: UTC ISO text without its seconds and `T`; a zone's text as it is. */
|
|
16
|
+
function shortTimestamp(timestamp, timeLook) {
|
|
17
|
+
return timeLook.zone === "UTC" ? timestamp.slice(0, 16).replace("T", " ") : timestamp;
|
|
18
|
+
}
|
|
15
19
|
/** The seek slider's spoken value: the time, with the activity window and its rate when one is running. */
|
|
16
|
-
function seekValueText(timeUtcMs, activityNow) {
|
|
20
|
+
function seekValueText(timeUtcMs, activityNow, timeLook) {
|
|
17
21
|
if (activityNow === null || activityNow.window.rate === undefined)
|
|
18
|
-
return
|
|
19
|
-
return `${
|
|
22
|
+
return formatTime(timeUtcMs, timeLook);
|
|
23
|
+
return `${formatTime(timeUtcMs, timeLook)}, ${activityNow.window.label}: ${formatWindowRate(activityNow.rate, activityNow.window.rate.unit)}`;
|
|
20
24
|
}
|
|
21
|
-
export function TimelineBar({ experience, snapshot, onTogglePlayback, onRateChange, paceAuto, onSeek, panels = [], openPanelId = null, onPanelOpen, onEventSeek, onEventInfo, onWindowSeek, onWindowInfo, glowLook = DEFAULT_TIMELINE_GLOW, drawer, infoPanelId }) {
|
|
25
|
+
export function TimelineBar({ experience, snapshot, onTogglePlayback, onRateChange, paceAuto, onSeek, panels = [], openPanelId = null, onPanelOpen, onEventSeek, onEventInfo, onWindowSeek, onWindowInfo, glowLook = DEFAULT_TIMELINE_GLOW, timeLook: timeLookProp, drawer, infoPanelId }) {
|
|
26
|
+
const timeLook = withDefaultTime(timeLookProp);
|
|
22
27
|
const drawerId = `${useId()}-timeline-drawer`;
|
|
23
28
|
const windows = experience.windows ?? [];
|
|
24
29
|
const profile = useMemo(() => glowProfile(windows, experience.window), [windows, experience.window]);
|
|
@@ -27,7 +32,7 @@ export function TimelineBar({ experience, snapshot, onTogglePlayback, onRateChan
|
|
|
27
32
|
const [hoverTitle, setHoverTitle] = useState(null);
|
|
28
33
|
const playedPercent = timePositionPercent(clampToBounds(snapshot.timeUtcMs, experience.window), experience.window);
|
|
29
34
|
const activityNow = activityAt(windows, snapshot.timeUtcMs);
|
|
30
|
-
const valueText = seekValueText(snapshot.timeUtcMs, activityNow);
|
|
35
|
+
const valueText = seekValueText(snapshot.timeUtcMs, activityNow, timeLook);
|
|
31
36
|
const moveOnTrack = (event) => {
|
|
32
37
|
if (profile === null)
|
|
33
38
|
return;
|
|
@@ -45,7 +50,7 @@ export function TimelineBar({ experience, snapshot, onTogglePlayback, onRateChan
|
|
|
45
50
|
};
|
|
46
51
|
const stopLabel = (direction, stop) => windows.length === 0 || stop === null ? `${direction} event` : `${direction}: ${stop.label}`;
|
|
47
52
|
const speeds = speedsOf(experience.rates);
|
|
48
|
-
const timestamp =
|
|
53
|
+
const timestamp = formatTime(snapshot.timeUtcMs, timeLook);
|
|
49
54
|
const handle = useDrawerSwipe({
|
|
50
55
|
thresholdPx: drawer?.swipeThresholdPx ?? 0,
|
|
51
56
|
onTap: () => drawer?.onOpenChange(!drawer.open),
|
|
@@ -85,12 +90,12 @@ export function TimelineBar({ experience, snapshot, onTogglePlayback, onRateChan
|
|
|
85
90
|
}, children: [_jsx("span", { className: "timeline-glow-ahead" }), _jsx("span", { className: "timeline-glow-played", children: _jsx("span", { className: "timeline-glow-line" }) })] }), _jsx("div", { className: "timeline-markers", ref: markersRef, "aria-label": "Timeline event markers", children: groups.map((group) => group.members.length === 1
|
|
86
91
|
? renderMarker(group.members[0], group.positionPercent)
|
|
87
92
|
: (_jsxs("div", { className: "timeline-marker-group", "data-align": group.positionPercent < 25 ? "start" : group.positionPercent > 75 ? "end" : "middle", style: { left: `${group.positionPercent}%` }, onKeyDown: (event) => { if (event.key === "Escape")
|
|
88
|
-
setOpenGroup(null); }, children: [_jsx("button", { type: "button", className: "timeline-marker timeline-group-toggle", "aria-expanded": openGroup === group.members[0].key, "aria-label": `${group.members.length} markers close together: show list`, title: `${group.members.length} markers`, onClick: () => setOpenGroup((open) => (open === group.members[0].key ? null : group.members[0].key)), children: _jsx("span", { className: "timeline-group-count", children: group.members.length }) }), openGroup === group.members[0].key && (_jsx("ul", { className: "timeline-group-list", "aria-label": "Markers close together", children: group.members.map((member) => (_jsx("li", { children: _jsx("button", { type: "button", className: "timeline-group-item", "aria-label": member.ariaLabel, "data-time-utc-ms": member.timeUtcMs, "data-panel-id": member.kind === "panel" ? member.key : undefined, onClick: () => { member.activate(); setOpenGroup(null); }, children: member.text }) }, member.key))) }))] }, `group-${group.members[0].key}`))) }), _jsx("input", { type: "range", "aria-label": "Seek timeline", "aria-valuetext": valueText, min: experience.window.startUtcMs, max: experience.window.endUtcMs, step: TIMELINE_STEP_MS, value: clampToBounds(snapshot.timeUtcMs, experience.window), onChange: (event) => onSeek(Number(event.target.value)) })] }), _jsxs("div", { className: "timeline-bounds", "aria-hidden": "true", children: [_jsx("time", { dateTime: formatUtcTimestamp(experience.window.startUtcMs), children:
|
|
93
|
+
setOpenGroup(null); }, children: [_jsx("button", { type: "button", className: "timeline-marker timeline-group-toggle", "aria-expanded": openGroup === group.members[0].key, "aria-label": `${group.members.length} markers close together: show list`, title: `${group.members.length} markers`, onClick: () => setOpenGroup((open) => (open === group.members[0].key ? null : group.members[0].key)), children: _jsx("span", { className: "timeline-group-count", children: group.members.length }) }), openGroup === group.members[0].key && (_jsx("ul", { className: "timeline-group-list", "aria-label": "Markers close together", children: group.members.map((member) => (_jsx("li", { children: _jsx("button", { type: "button", className: "timeline-group-item", "aria-label": member.ariaLabel, "data-time-utc-ms": member.timeUtcMs, "data-panel-id": member.kind === "panel" ? member.key : undefined, onClick: () => { member.activate(); setOpenGroup(null); }, children: member.text }) }, member.key))) }))] }, `group-${group.members[0].key}`))) }), _jsx("input", { type: "range", "aria-label": "Seek timeline", "aria-valuetext": valueText, min: experience.window.startUtcMs, max: experience.window.endUtcMs, step: TIMELINE_STEP_MS, value: clampToBounds(snapshot.timeUtcMs, experience.window), onChange: (event) => onSeek(Number(event.target.value)) })] }), _jsxs("div", { className: "timeline-bounds", "aria-hidden": "true", children: [_jsx("time", { dateTime: formatUtcTimestamp(experience.window.startUtcMs), children: formatTime(experience.window.startUtcMs, { ...timeLook, precision: "day" }) }), _jsx("time", { dateTime: formatUtcTimestamp(experience.window.endUtcMs), children: formatTime(experience.window.endUtcMs, { ...timeLook, precision: "day" }) })] })] }));
|
|
89
94
|
return (_jsxs("section", { className: "timeline-bar", "aria-label": "Timeline controls", "data-drawer-open": drawer?.open, children: [drawer !== undefined && (_jsx("button", { type: "button", className: "drawer-handle drawer-handle-top ui-bare", "aria-label": "Timeline drawer", "aria-expanded": drawer.open, "aria-controls": drawerId, ...handle, children: _jsx("span", {}) })), _jsxs("div", { className: "timeline-main-row", children: [_jsxs("div", { className: "timeline-transport", children: [_jsx("button", { type: "button", className: "timeline-play ui-icon ui-accent", title: snapshot.playing ? "Pause" : "Play", onClick: onTogglePlayback, "aria-label": snapshot.playing ? "Pause playback" : "Play playback", children: snapshot.playing ? _jsx(Symbol, { path: "M7 5h3.5v14H7zM13.5 5H17v14h-3.5z" }) : _jsx(Symbol, { path: "M7 5v14l12-7z" }) }), _jsx("button", { type: "button", className: "timeline-previous ui-icon ui-ghost", "aria-label": stopLabel("Previous", navigation.previous), title: stopLabel("Previous", navigation.previous), disabled: navigation.previous === null, onClick: () => { if (navigation.previous !== null)
|
|
90
95
|
goToStop(navigation.previous); }, children: _jsx(Symbol, { path: "M6 5h2v14H6zM19 5v14L9 12z" }) }), _jsx("button", { type: "button", className: "timeline-next ui-icon ui-ghost", "aria-label": stopLabel("Next", navigation.next), title: stopLabel("Next", navigation.next), disabled: navigation.next === null, onClick: () => { if (navigation.next !== null)
|
|
91
|
-
goToStop(navigation.next); }, children: _jsx(Symbol, { path: "M16 5h2v14h-2zM5 5v14l10-7z" }) })] }), _jsxs("time", { className: "timeline-time", dateTime:
|
|
96
|
+
goToStop(navigation.next); }, children: _jsx(Symbol, { path: "M16 5h2v14h-2zM5 5v14l10-7z" }) })] }), _jsxs("time", { className: "timeline-time", dateTime: formatUtcTimestamp(snapshot.timeUtcMs), "aria-label": timestamp, children: [_jsx("span", { className: "timeline-time-full", children: timestamp }), _jsx("span", { className: "timeline-time-short", "aria-hidden": "true", children: shortTimestamp(timestamp, timeLook) })] }), _jsx(SpeedMenu, { speeds: speeds, rate: snapshot.rate, paceAuto: paceAuto, compact: drawer !== undefined, onRateChange: onRateChange }), scrubber, drawer === undefined && (_jsxs("details", { className: "timeline-event-list", children: [_jsxs("summary", { className: "ui-button", title: "Events: what just happened, what is next, and the full list", children: ["Events ", _jsxs("span", { children: ["(", experience.events.length, ")"] })] }), _jsx(TimelineExpanded, { experience: experience, snapshot: snapshot, timeLook: timeLook, onEventSeek: onEventSeek, onEventInfo: onEventInfo, onWindowInfo: onWindowInfo, infoPanelId: infoPanelId })] }))] }), drawer !== undefined && (_jsx("div", { id: drawerId, className: "timeline-drawer", role: "region", "aria-label": "Timeline details", "data-open": drawer.open, onClick: (event) => { const closer = event.target.closest("[data-closes-drawer]"); if (closer !== null && closer.tagName !== "SELECT")
|
|
92
97
|
drawer.onOpenChange(false); }, children: _jsxs("div", { className: "timeline-drawer-body", children: [_jsxs("div", { className: "timeline-speed-slider", children: [_jsx("span", { "aria-hidden": "true", children: "Playback speed" }), _jsx("input", { type: "range", "aria-label": "Speed slider", "aria-valuetext": speedText, min: 0, max: speeds.length - 1, step: 1, value: speedIndex, onChange: (event) => { const next = speeds[Number(event.target.value)]; if (next !== undefined)
|
|
93
|
-
onRateChange(next.rate); } }), _jsx("output", { children: speedText })] }), _jsx(TimelineExpanded, { experience: experience, snapshot: snapshot, onEventSeek: onEventSeek, onEventInfo: onEventInfo, onWindowInfo: onWindowInfo, infoPanelId: infoPanelId })] }) }))] }));
|
|
98
|
+
onRateChange(next.rate); } }), _jsx("output", { children: speedText })] }), _jsx(TimelineExpanded, { experience: experience, snapshot: snapshot, timeLook: timeLook, onEventSeek: onEventSeek, onEventInfo: onEventInfo, onWindowInfo: onWindowInfo, infoPanelId: infoPanelId })] }) }))] }));
|
|
94
99
|
}
|
|
95
100
|
/** A 24x24 filled symbol; the button around it carries the accessible name and tooltip. */
|
|
96
101
|
function Symbol({ path }) {
|
|
@@ -100,11 +105,11 @@ function Symbol({ path }) {
|
|
|
100
105
|
* The timeline's expanded content: "Just happened / Up next / Inside" and the full event list.
|
|
101
106
|
* On larger screens it opens from the Events button; the phone drawer shows the same content when expanded.
|
|
102
107
|
*/
|
|
103
|
-
export function TimelineExpanded({ experience, snapshot, onEventSeek, onEventInfo, onWindowInfo, infoPanelId }) {
|
|
108
|
+
export function TimelineExpanded({ experience, snapshot, timeLook = DEFAULT_TIME_LOOK, onEventSeek, onEventInfo, onWindowInfo, infoPanelId }) {
|
|
104
109
|
const context = eventContextAt(experience.events, snapshot.timeUtcMs);
|
|
105
110
|
const inside = windowContextAt(experience.windows ?? [], snapshot.timeUtcMs);
|
|
106
111
|
return (_jsxs("div", { className: "timeline-expanded", children: [_jsxs("div", { className: "timeline-event-context", "aria-label": "Event context", children: [context.current === null
|
|
107
112
|
? _jsxs("span", { children: [_jsx("strong", { children: "Just happened:" }), " No event yet"] })
|
|
108
113
|
: (_jsxs("button", { type: "button", className: "timeline-event-current ui-row", "data-closes-drawer": "", "aria-label": `Information about ${context.current.label}`, "aria-controls": infoPanelId, onClick: () => { if (context.current !== null)
|
|
109
|
-
onEventInfo(context.current); }, children: [_jsx("strong", { children: "Just happened:" }), " ", context.current.label, " ", _jsx("span", { "aria-hidden": "true", children: "\u24D8" })] })), _jsxs("span", { children: [_jsx("strong", { children: "Up next:" }), " ", context.next?.label ?? "No upcoming event"] }), inside.map(({ window, rate }) => (_jsxs("button", { type: "button", className: "timeline-event-current timeline-window-current ui-row", "data-closes-drawer": "", "aria-label": `Information about ${window.label}`, "aria-controls": infoPanelId, onClick: () => onWindowInfo(window), children: [_jsx("strong", { children: "Inside:" }), " ", window.label, rate !== null && window.rate !== undefined && _jsxs(_Fragment, { children: [" \u2014 ", formatWindowRate(rate, window.rate.unit)] }), " ", _jsx("span", { "aria-hidden": "true", children: "\u24D8" })] }, window.id)))] }), _jsx("ol", { children: experience.events.map((event) => (_jsx("li", { children: _jsxs("button", { type: "button", className: "ui-row", "data-closes-drawer": "", "aria-current": context.current?.id === event.id ? "time" : undefined, onClick: () => { onEventSeek(event); onEventInfo(event); }, children: [_jsx("time", { dateTime: formatUtcTimestamp(event.timeUtcMs), children:
|
|
114
|
+
onEventInfo(context.current); }, children: [_jsx("strong", { children: "Just happened:" }), " ", context.current.label, " ", _jsx("span", { "aria-hidden": "true", children: "\u24D8" })] })), _jsxs("span", { children: [_jsx("strong", { children: "Up next:" }), " ", context.next?.label ?? "No upcoming event"] }), inside.map(({ window, rate }) => (_jsxs("button", { type: "button", className: "timeline-event-current timeline-window-current ui-row", "data-closes-drawer": "", "aria-label": `Information about ${window.label}`, "aria-controls": infoPanelId, onClick: () => onWindowInfo(window), children: [_jsx("strong", { children: "Inside:" }), " ", window.label, rate !== null && window.rate !== undefined && _jsxs(_Fragment, { children: [" \u2014 ", formatWindowRate(rate, window.rate.unit)] }), " ", _jsx("span", { "aria-hidden": "true", children: "\u24D8" })] }, window.id)))] }), _jsx("ol", { children: experience.events.map((event) => (_jsx("li", { children: _jsxs("button", { type: "button", className: "ui-row", "data-closes-drawer": "", "aria-current": context.current?.id === event.id ? "time" : undefined, onClick: () => { onEventSeek(event); onEventInfo(event); }, children: [_jsx("time", { dateTime: formatUtcTimestamp(event.timeUtcMs), children: formatTime(event.timeUtcMs, timeLook) }), _jsx("span", { children: event.label })] }) }, event.id))) })] }));
|
|
110
115
|
}
|
|
@@ -5,12 +5,19 @@ import type { TimeBounds } from "../core/trajectory.js";
|
|
|
5
5
|
import type { BodyFeatureSet } from "./bodyFeatures.js";
|
|
6
6
|
import type { MoonFamilyList } from "./moonFamilies.js";
|
|
7
7
|
import type { StoryPanelSet } from "./storyPanels.js";
|
|
8
|
+
/** When an object is shown, in Unix milliseconds: `startUtcMs <= t < endUtcMs`; an absent end is unbounded. Presentation only (`shownDuring`); not the object's `availability`. */
|
|
9
|
+
export interface ShownSpan {
|
|
10
|
+
readonly startUtcMs?: number;
|
|
11
|
+
readonly endUtcMs?: number;
|
|
12
|
+
}
|
|
8
13
|
export interface ExperienceObject {
|
|
9
14
|
readonly id: string;
|
|
10
15
|
readonly label: string;
|
|
11
16
|
readonly color?: string;
|
|
12
17
|
/** Omit for objects that are always available. */
|
|
13
18
|
readonly availability?: TimeBounds;
|
|
19
|
+
/** Omit to show the object at every time. Outside the span the scene draws none of it (marker, line, label) and it cannot be picked; its state is unchanged. */
|
|
20
|
+
readonly shownDuring?: ShownSpan;
|
|
14
21
|
/** Higher values win when projected labels would overlap. */
|
|
15
22
|
readonly labelPriority?: number;
|
|
16
23
|
/**
|
|
@@ -78,6 +85,8 @@ export interface SkyFigureCard {
|
|
|
78
85
|
export interface ExperienceConfig {
|
|
79
86
|
readonly objects: readonly ExperienceObject[];
|
|
80
87
|
readonly cameraPresets: readonly ExperienceCameraPreset[];
|
|
88
|
+
/** True: a Focus button shows only for an object with a focus preset (the scene chose its Focus choices); absent: every listed object has one. */
|
|
89
|
+
readonly focusListed?: boolean;
|
|
81
90
|
/** The camera preset that is already in force when the shell opens (for example a Follow preset, so the scene starts following). Absent: none, as before. */
|
|
82
91
|
readonly startCameraPresetId?: string;
|
|
83
92
|
readonly events: readonly TimelineEvent[];
|
package/src/shell/infoModel.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Provenance, ProvenanceSourceType } from "../core/provenance.js";
|
|
2
2
|
import type { ExperienceConfig } from "./experience.js";
|
|
3
|
+
import { type TimeLook } from "./timelineModel.js";
|
|
3
4
|
/** The badge text for each provenance status. The status is always written, never shown by colour alone. */
|
|
4
5
|
export declare const PROVENANCE_STATUS: Readonly<Record<ProvenanceSourceType, string>>;
|
|
5
6
|
export interface ProvenanceView extends Provenance {
|
|
@@ -40,4 +41,4 @@ export declare function provenanceView(provenance: Provenance, knownLimitations?
|
|
|
40
41
|
* What the info panel shows for a configured object, event or window, or null when the id is not configured.
|
|
41
42
|
* A window's rate and source depend on `timeUtcMs`, the clock.
|
|
42
43
|
*/
|
|
43
|
-
export declare function infoView(experience: ExperienceConfig, target: InfoTarget, timeUtcMs?: number): InfoView | null;
|
|
44
|
+
export declare function infoView(experience: ExperienceConfig, target: InfoTarget, timeUtcMs?: number, timeLook?: TimeLook): InfoView | null;
|
package/src/shell/infoModel.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { provenanceAt, rateAt, spanProvenanceAt } from "../core/timeWindow.js";
|
|
2
2
|
import { findFeature } from "./bodyFeatures.js";
|
|
3
3
|
import { skyFigureById } from "./objectModel.js";
|
|
4
|
-
import {
|
|
4
|
+
import { DEFAULT_TIME_LOOK, formatTime, formatWindowRate } from "./timelineModel.js";
|
|
5
5
|
/** The badge text for each provenance status. The status is always written, never shown by colour alone. */
|
|
6
6
|
export const PROVENANCE_STATUS = {
|
|
7
7
|
ephemeris: "Ephemeris",
|
|
@@ -17,27 +17,27 @@ export function provenanceView(provenance, knownLimitations = []) {
|
|
|
17
17
|
* What the info panel shows for a configured object, event or window, or null when the id is not configured.
|
|
18
18
|
* A window's rate and source depend on `timeUtcMs`, the clock.
|
|
19
19
|
*/
|
|
20
|
-
export function infoView(experience, target, timeUtcMs) {
|
|
20
|
+
export function infoView(experience, target, timeUtcMs, timeLook = DEFAULT_TIME_LOOK) {
|
|
21
21
|
if (target.kind === "window")
|
|
22
|
-
return windowInfo(experience, target, timeUtcMs);
|
|
22
|
+
return windowInfo(experience, target, timeUtcMs, timeLook);
|
|
23
23
|
if (target.kind === "feature")
|
|
24
24
|
return featureInfo(experience, target);
|
|
25
25
|
if (target.kind === "object")
|
|
26
26
|
return objectInfo(experience, target, timeUtcMs);
|
|
27
|
-
return eventInfo(experience, target);
|
|
27
|
+
return eventInfo(experience, target, timeLook);
|
|
28
28
|
}
|
|
29
|
-
function windowInfo(experience, target, timeUtcMs) {
|
|
29
|
+
function windowInfo(experience, target, timeUtcMs, timeLook) {
|
|
30
30
|
const window = experience.windows?.find((candidate) => candidate.id === target.id);
|
|
31
31
|
if (window === undefined)
|
|
32
32
|
return null;
|
|
33
33
|
const rate = timeUtcMs === undefined ? null : rateAt(window, timeUtcMs);
|
|
34
34
|
const source = (timeUtcMs === undefined ? null : provenanceAt(window, timeUtcMs)) ?? experience.eventProvenance;
|
|
35
35
|
const facts = [
|
|
36
|
-
{ label: "Starts", value:
|
|
37
|
-
{ label: "Ends", value:
|
|
36
|
+
{ label: "Starts", value: formatTime(window.startUtcMs, timeLook) },
|
|
37
|
+
{ label: "Ends", value: formatTime(window.endUtcMs, timeLook) },
|
|
38
38
|
];
|
|
39
39
|
if (window.peakUtcMs !== undefined)
|
|
40
|
-
facts.push({ label: "Peak", value:
|
|
40
|
+
facts.push({ label: "Peak", value: formatTime(window.peakUtcMs, timeLook) });
|
|
41
41
|
if (window.rate !== undefined) {
|
|
42
42
|
facts.push({ label: "Rate now", value: rate === null ? "Not available at this time" : formatWindowRate(rate, window.rate.unit) });
|
|
43
43
|
}
|
|
@@ -70,7 +70,7 @@ function objectInfo(experience, target, timeUtcMs) {
|
|
|
70
70
|
provenance: source === undefined ? null : provenanceView(source, object.knownLimitations),
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
-
function eventInfo(experience, target) {
|
|
73
|
+
function eventInfo(experience, target, timeLook) {
|
|
74
74
|
const event = experience.events.find((candidate) => candidate.id === target.id);
|
|
75
75
|
if (event === undefined)
|
|
76
76
|
return null;
|
|
@@ -78,7 +78,7 @@ function eventInfo(experience, target) {
|
|
|
78
78
|
return {
|
|
79
79
|
target,
|
|
80
80
|
title: event.label,
|
|
81
|
-
subtitle:
|
|
81
|
+
subtitle: formatTime(event.timeUtcMs, timeLook),
|
|
82
82
|
provenance: source === undefined ? null : provenanceView(source),
|
|
83
83
|
};
|
|
84
84
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ExperienceCameraPreset, type ExperienceConfig, type ExperienceObject, type SkyFigureCard } from "./experience.js";
|
|
2
2
|
export type CameraMode = "overview" | "focus" | "follow" | "lookOut";
|
|
3
|
+
/** Whether the object can be used at `timeUtcMs`: shown by its `shownDuring` span (the one rule, `shownAt`) and inside its `availability`. */
|
|
3
4
|
export declare function isObjectAvailable(object: ExperienceObject, timeUtcMs: number): boolean;
|
|
4
5
|
export declare function availableObjectById(experience: ExperienceConfig, id: string, timeUtcMs: number): ExperienceObject | undefined;
|
|
5
6
|
export declare function firstAvailableObject(experience: ExperienceConfig, timeUtcMs: number): ExperienceObject | undefined;
|
|
@@ -12,8 +13,8 @@ export declare function focusPresetFor(experience: ExperienceConfig, object: {
|
|
|
12
13
|
readonly label: string;
|
|
13
14
|
}): ExperienceCameraPreset;
|
|
14
15
|
export declare function findCameraPreset(experience: ExperienceConfig, mode: CameraMode, target?: string): ExperienceCameraPreset | undefined;
|
|
15
|
-
/** The objects the Object list offers: the listed ones, and the selected one even when unlisted so the list never shows a blank. */
|
|
16
|
-
export declare function listedObjects(experience: ExperienceConfig, selectedId: string): readonly ExperienceObject[];
|
|
16
|
+
/** The objects the Object list offers: the listed ones shown at `timeUtcMs` (an object outside its `shownDuring` span is absent), and the selected one even when unlisted so the list never shows a blank. */
|
|
17
|
+
export declare function listedObjects(experience: ExperienceConfig, selectedId: string, timeUtcMs?: number): readonly ExperienceObject[];
|
|
17
18
|
/** Unlisted objects that belong to `id` (an orbit line to its body), for the related buttons in the top bar. */
|
|
18
19
|
export declare function relatedObjects(experience: ExperienceConfig, id: string): readonly ExperienceObject[];
|
|
19
20
|
/** The sky figure a selected id names, or undefined (object ids and figure ids never collide: the scene checks it). */
|
package/src/shell/objectModel.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { shownAt } from "../app/viewHiding.js";
|
|
1
2
|
import { requestObjectId } from "./experience.js";
|
|
3
|
+
/** Whether the object can be used at `timeUtcMs`: shown by its `shownDuring` span (the one rule, `shownAt`) and inside its `availability`. */
|
|
2
4
|
export function isObjectAvailable(object, timeUtcMs) {
|
|
3
5
|
const bounds = object.availability;
|
|
4
|
-
return bounds === undefined || (timeUtcMs >= bounds.startUtcMs && timeUtcMs <= bounds.endUtcMs);
|
|
6
|
+
return shownAt(object, timeUtcMs) && (bounds === undefined || (timeUtcMs >= bounds.startUtcMs && timeUtcMs <= bounds.endUtcMs));
|
|
5
7
|
}
|
|
6
8
|
export function availableObjectById(experience, id, timeUtcMs) {
|
|
7
9
|
const object = experience.objects.find((candidate) => candidate.id === id);
|
|
@@ -25,9 +27,9 @@ export function findCameraPreset(experience, mode, target) {
|
|
|
25
27
|
return request.kind === mode && requestObjectId(request) === target;
|
|
26
28
|
});
|
|
27
29
|
}
|
|
28
|
-
/** The objects the Object list offers: the listed ones, and the selected one even when unlisted so the list never shows a blank. */
|
|
29
|
-
export function listedObjects(experience, selectedId) {
|
|
30
|
-
return experience.objects.filter((object) => object.listed !== false || object
|
|
30
|
+
/** The objects the Object list offers: the listed ones shown at `timeUtcMs` (an object outside its `shownDuring` span is absent), and the selected one even when unlisted so the list never shows a blank. */
|
|
31
|
+
export function listedObjects(experience, selectedId, timeUtcMs) {
|
|
32
|
+
return experience.objects.filter((object) => object.id === selectedId || (object.listed !== false && (timeUtcMs === undefined || shownAt(object, timeUtcMs))));
|
|
31
33
|
}
|
|
32
34
|
/** Unlisted objects that belong to `id` (an orbit line to its body), for the related buttons in the top bar. */
|
|
33
35
|
export function relatedObjects(experience, id) {
|