nucleus-core-ts 0.10.254 → 0.10.256
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/dist/.build-ok +1 -1
- package/dist/fe/components/Replay/_components/ReplayCaption/index.d.ts +2 -2
- package/dist/fe/components/Replay/_components/ReplayCaption/index.js +2 -6
- package/dist/fe/components/Replay/_components/ReplayCaption/types.d.ts +2 -1
- package/dist/fe/components/Replay/_components/ReplayChapters/index.js +2 -2
- package/dist/fe/components/Replay/_components/ReplayControls/index.js +1 -6
- package/dist/fe/components/Replay/_components/ReplayControls/types.d.ts +1 -2
- package/dist/fe/components/Replay/_components/ReplayPlayer/ReplayView.js +2 -4
- package/dist/fe/components/Replay/_components/ReplayStage/index.d.ts +6 -2
- package/dist/fe/components/Replay/_components/ReplayStage/index.js +80 -37
- package/dist/fe/components/Replay/_hooks/useCameraPan.d.ts +4 -0
- package/dist/fe/components/Replay/_hooks/useCameraPan.js +36 -0
- package/dist/fe/components/Replay/_hooks/useStageScale.d.ts +12 -3
- package/dist/fe/components/Replay/_hooks/useStageScale.js +36 -8
- package/dist/fe/components/Replay/_store/replayStore.js +1 -1
- package/dist/fe/components/Replay/_utils/controller.js +4 -2
- package/dist/fe/components/Replay/_utils/controllerReports.d.ts +2 -4
- package/dist/fe/components/Replay/_utils/controllerReports.js +3 -4
- package/dist/fe/components/Replay/_utils/copy.d.ts +4 -1
- package/dist/fe/components/Replay/_utils/copy.js +4 -1
- package/dist/fe/components/Replay/_utils/cursorMotion.js +1 -1
- package/dist/fe/components/Replay/_utils/replayLayout.d.ts +6 -1
- package/dist/fe/components/Replay/_utils/replayLayout.js +18 -8
- package/dist/fe/components/Replay/_utils/replayParts.js +7 -4
- package/dist/fe/components/Replay/_utils/replayProgress.d.ts +2 -0
- package/dist/fe/components/Replay/_utils/replayProgress.js +3 -0
- package/dist/fe/components/Replay/_utils/stageViewport.d.ts +33 -0
- package/dist/fe/components/Replay/_utils/stageViewport.js +42 -0
- package/dist/src/Client/Replay/timeline/timeline.d.ts +2 -2
- package/dist/src/Client/Replay/timeline/timeline.js +6 -6
- package/package.json +1 -1
package/dist/.build-ok
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.10.
|
|
1
|
+
0.10.256
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ReplayCaptionProps } from './types';
|
|
2
|
-
/** The current step's caption
|
|
3
|
-
export declare function ReplayCaption({ text, stepId,
|
|
2
|
+
/** The current step's caption and its position; the player's live region, so a screen reader hears each step. */
|
|
3
|
+
export declare function ReplayCaption({ text, stepId, position, loading }: ReplayCaptionProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -6,7 +6,7 @@ import { useEffectEvent, useRef } from 'react';
|
|
|
6
6
|
import { useReducedMotion } from '../../../DemoFilm/_hooks/useReducedMotion';
|
|
7
7
|
import { REPLAY_COPY } from '../../_utils/copy';
|
|
8
8
|
gsap.registerPlugin(useGSAP);
|
|
9
|
-
/** The current step's caption
|
|
9
|
+
/** The current step's caption and its position; the player's live region, so a screen reader hears each step. */ export function ReplayCaption({ text, stepId, position, loading }) {
|
|
10
10
|
const reduced = useReducedMotion();
|
|
11
11
|
const body = useRef(null);
|
|
12
12
|
const enter = useEffectEvent(()=>{
|
|
@@ -42,11 +42,7 @@ gsap.registerPlugin(useGSAP);
|
|
|
42
42
|
/*#__PURE__*/ _jsx("p", {
|
|
43
43
|
ref: body,
|
|
44
44
|
className: "nc-replay__text",
|
|
45
|
-
children: text || REPLAY_COPY.idle
|
|
46
|
-
}),
|
|
47
|
-
/*#__PURE__*/ _jsx("p", {
|
|
48
|
-
className: "nc-replay__chapter-name",
|
|
49
|
-
children: chapterTitle
|
|
45
|
+
children: text || (loading ? REPLAY_COPY.loadingChapter : REPLAY_COPY.idle)
|
|
50
46
|
})
|
|
51
47
|
]
|
|
52
48
|
});
|
|
@@ -3,7 +3,8 @@ export interface ReplayCaptionProps {
|
|
|
3
3
|
text: string;
|
|
4
4
|
/** Identifies the step so the caption animates when it changes. */
|
|
5
5
|
stepId: string | null;
|
|
6
|
-
|
|
6
|
+
/** Playing but no step has started yet (a chapter was just opened): show that, not the idle line. */
|
|
7
|
+
loading: boolean;
|
|
7
8
|
/** 1-based position among the recording's steps; null before the first step. */
|
|
8
9
|
position: {
|
|
9
10
|
index: number;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { REPLAY_COPY } from '../../_utils/copy';
|
|
4
4
|
import { pickLocalized } from '../../_utils/frameUrl';
|
|
5
|
-
import {
|
|
5
|
+
import { chapterMinutes, chapterProgress } from '../../_utils/replayProgress';
|
|
6
6
|
/** The chapters as a list: each one seeks to its start; the current one is marked and shows how far the playhead is in it. */ export function ReplayChapters({ chapters, locale, chapterId, playhead, onSeek }) {
|
|
7
7
|
return /*#__PURE__*/ _jsxs("nav", {
|
|
8
8
|
className: "nc-replay__chapters",
|
|
@@ -44,7 +44,7 @@ import { chapterProgress, rateLabel } from '../../_utils/replayProgress';
|
|
|
44
44
|
})
|
|
45
45
|
}),
|
|
46
46
|
/*#__PURE__*/ _jsx("small", {
|
|
47
|
-
children:
|
|
47
|
+
children: REPLAY_COPY.chapterLength(chapterMinutes(chapter))
|
|
48
48
|
})
|
|
49
49
|
]
|
|
50
50
|
})
|
|
@@ -10,7 +10,7 @@ const ICON = {
|
|
|
10
10
|
'aria-hidden': true
|
|
11
11
|
};
|
|
12
12
|
/** Play or pause, restart, speed, and the language switch (only when the recording has more than one language). */ export function ReplayControls(props) {
|
|
13
|
-
const { status, rate,
|
|
13
|
+
const { status, rate, locales, locale, onPlay, onPause, onRate, onLocale, onRestart } = props;
|
|
14
14
|
const playing = status === 'playing';
|
|
15
15
|
const idle = status === 'loading' || status === 'failed';
|
|
16
16
|
return /*#__PURE__*/ _jsxs("div", {
|
|
@@ -65,11 +65,6 @@ const ICON = {
|
|
|
65
65
|
children: rateLabel(choice)
|
|
66
66
|
}, choice))
|
|
67
67
|
}),
|
|
68
|
-
chapterRate !== null && /*#__PURE__*/ _jsx("span", {
|
|
69
|
-
className: "nc-replay__badge",
|
|
70
|
-
"data-replay-chapter-rate": true,
|
|
71
|
-
children: REPLAY_COPY.chapterPace(rateLabel(chapterRate))
|
|
72
|
-
}),
|
|
73
68
|
locales.length > 1 && /*#__PURE__*/ _jsx("span", {
|
|
74
69
|
className: "nc-replay__seg",
|
|
75
70
|
role: "group",
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { ReplayStatus } from '../../_types';
|
|
2
2
|
export interface ReplayControlsProps {
|
|
3
3
|
status: ReplayStatus;
|
|
4
|
+
/** The visitor's speed, a multiplier on every chapter's own pace. */
|
|
4
5
|
rate: number;
|
|
5
|
-
/** The current chapter's own rate; shown as a badge. */
|
|
6
|
-
chapterRate: number | null;
|
|
7
6
|
/** Languages the recording has; the switch shows only when there is more than one. */
|
|
8
7
|
locales: string[];
|
|
9
8
|
locale: string;
|
|
@@ -37,7 +37,6 @@ import { ReplayStage } from '../ReplayStage';
|
|
|
37
37
|
]
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
-
const chapter = manifest.chapters.find((c)=>c.id === state.chapterId) ?? null;
|
|
41
40
|
const first = manifest.chapters[0];
|
|
42
41
|
const overlay = status === 'failed' && failure ? /*#__PURE__*/ _jsx(ReplayFailureCard, {
|
|
43
42
|
reason: failure.reason,
|
|
@@ -73,13 +72,12 @@ import { ReplayStage } from '../ReplayStage';
|
|
|
73
72
|
/*#__PURE__*/ _jsx(ReplayCaption, {
|
|
74
73
|
text: pickLocalized(state.caption, locale),
|
|
75
74
|
stepId: state.stepId,
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
position: stepPosition(manifest, state.stepId),
|
|
76
|
+
loading: status === 'playing'
|
|
78
77
|
}),
|
|
79
78
|
/*#__PURE__*/ _jsx(ReplayControls, {
|
|
80
79
|
status: status,
|
|
81
80
|
rate: state.rate,
|
|
82
|
-
chapterRate: chapter?.rate ?? null,
|
|
83
81
|
locales: manifestLocales(manifest),
|
|
84
82
|
locale: locale,
|
|
85
83
|
onPlay: player.play,
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { ReplayStageProps } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* The product in a same-origin iframe laid out at a virtual desktop viewport (see stageViewport) and scaled uniformly to
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* fit the slot it sits in: by width everywhere, and from 1024 px up by height too, so the whole frame is on screen with
|
|
5
|
+
* the caption and the controls. The view is letterboxed (centred) in the slot. On a narrow stage the whole frame would
|
|
6
|
+
* be an unreadable thumbnail, so a camera shows it at a readable scale and follows the pointer; a toggle shows the
|
|
7
|
+
* whole screen instead. The frame takes no pointer events: the visitor watches, the cursor and highlight layers above
|
|
8
|
+
* it show what happens. The cursor layer shares the world's box and the frame's scale, so a point of the frame lands
|
|
9
|
+
* on the same spot of the layer.
|
|
6
10
|
*/
|
|
7
11
|
export declare function ReplayStage(props: ReplayStageProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,23 +1,45 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useRef, useState } from 'react';
|
|
4
|
+
import { useCameraPan } from '../../_hooks/useCameraPan';
|
|
3
5
|
import { useStageScale } from '../../_hooks/useStageScale';
|
|
4
6
|
import { REPLAY_COPY } from '../../_utils/copy';
|
|
5
7
|
import { pickLocalized } from '../../_utils/frameUrl';
|
|
6
|
-
import { stageViewport } from '../../_utils/stageViewport';
|
|
8
|
+
import { cameraOffset, cameraShot, restingFocus, stageViewport } from '../../_utils/stageViewport';
|
|
7
9
|
import { ReplayCursorLayer } from '../ReplayCursor';
|
|
8
10
|
import { ReplayVeil } from './ReplayVeil';
|
|
9
11
|
/**
|
|
10
12
|
* The product in a same-origin iframe laid out at a virtual desktop viewport (see stageViewport) and scaled uniformly to
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
+
* fit the slot it sits in: by width everywhere, and from 1024 px up by height too, so the whole frame is on screen with
|
|
14
|
+
* the caption and the controls. The view is letterboxed (centred) in the slot. On a narrow stage the whole frame would
|
|
15
|
+
* be an unreadable thumbnail, so a camera shows it at a readable scale and follows the pointer; a toggle shows the
|
|
16
|
+
* whole screen instead. The frame takes no pointer events: the visitor watches, the cursor and highlight layers above
|
|
17
|
+
* it show what happens. The cursor layer shares the world's box and the frame's scale, so a point of the frame lands
|
|
18
|
+
* on the same spot of the layer.
|
|
13
19
|
*/ export function ReplayStage(props) {
|
|
14
20
|
const { manifest, locale, frameSrc, frameRef, cursor, rate, onArrive, loading, children } = props;
|
|
15
|
-
const
|
|
16
|
-
const
|
|
21
|
+
const frame = stageViewport(manifest.viewport);
|
|
22
|
+
const fit = useStageScale(frame);
|
|
23
|
+
const [whole, setWhole] = useState(false);
|
|
24
|
+
const world = useRef(null);
|
|
25
|
+
const focus = useRef(restingFocus(frame));
|
|
26
|
+
if (cursor) focus.current = {
|
|
27
|
+
x: cursor.box.x + cursor.box.width / 2,
|
|
28
|
+
y: cursor.box.y + cursor.box.height / 2
|
|
29
|
+
};
|
|
30
|
+
const camera = fit.narrow && !whole;
|
|
31
|
+
const shot = cameraShot(fit.boxWidth, frame);
|
|
32
|
+
const offset = cameraOffset(focus.current, shot, frame);
|
|
33
|
+
useCameraPan(world, offset, camera);
|
|
17
34
|
const title = pickLocalized(manifest.title, locale);
|
|
35
|
+
const measured = fit.width > 0;
|
|
36
|
+
const scale = camera ? shot.scale : fit.scale;
|
|
37
|
+
const viewWidth = camera ? shot.viewWidth : fit.width;
|
|
38
|
+
const viewHeight = camera ? shot.viewHeight : fit.height;
|
|
18
39
|
return /*#__PURE__*/ _jsxs("div", {
|
|
19
40
|
className: "nc-replay__stage",
|
|
20
41
|
"data-replay-stage": true,
|
|
42
|
+
"data-replay-camera": camera ? '' : undefined,
|
|
21
43
|
children: [
|
|
22
44
|
/*#__PURE__*/ _jsxs("div", {
|
|
23
45
|
className: "nc-replay__bar",
|
|
@@ -35,43 +57,64 @@ import { ReplayVeil } from './ReplayVeil';
|
|
|
35
57
|
className: "nc-replay__title",
|
|
36
58
|
children: title
|
|
37
59
|
}),
|
|
38
|
-
/*#__PURE__*/ _jsx("
|
|
60
|
+
fit.narrow ? /*#__PURE__*/ _jsx("button", {
|
|
61
|
+
type: "button",
|
|
62
|
+
className: "nc-replay__pill nc-replay__zoom",
|
|
63
|
+
"aria-pressed": whole,
|
|
64
|
+
onClick: ()=>setWhole(!whole),
|
|
65
|
+
children: whole ? REPLAY_COPY.followAction : REPLAY_COPY.wholeScreen
|
|
66
|
+
}) : /*#__PURE__*/ _jsx("span", {
|
|
39
67
|
className: "nc-replay__pill",
|
|
40
68
|
children: REPLAY_COPY.watchOnly
|
|
41
69
|
})
|
|
42
70
|
]
|
|
43
71
|
}),
|
|
44
|
-
/*#__PURE__*/
|
|
45
|
-
ref: boxRef,
|
|
46
|
-
className: "nc-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
/*#__PURE__*/ _jsx("div", {
|
|
73
|
+
ref: fit.boxRef,
|
|
74
|
+
className: "nc-replay__slot",
|
|
75
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
76
|
+
className: "nc-replay__view",
|
|
77
|
+
style: {
|
|
78
|
+
aspectRatio: camera ? undefined : `${frame.width} / ${frame.height}`,
|
|
79
|
+
width: measured ? viewWidth : '100%',
|
|
80
|
+
height: measured ? viewHeight : undefined
|
|
81
|
+
},
|
|
82
|
+
children: [
|
|
83
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
84
|
+
ref: world,
|
|
85
|
+
className: "nc-replay__world",
|
|
86
|
+
style: {
|
|
87
|
+
width: frame.width * scale,
|
|
88
|
+
height: frame.height * scale
|
|
89
|
+
},
|
|
90
|
+
children: [
|
|
91
|
+
frameSrc !== null && /*#__PURE__*/ _jsx("iframe", {
|
|
92
|
+
ref: frameRef,
|
|
93
|
+
className: "nc-replay__frame",
|
|
94
|
+
src: frameSrc,
|
|
95
|
+
title: title,
|
|
96
|
+
tabIndex: -1,
|
|
97
|
+
style: {
|
|
98
|
+
width: frame.width,
|
|
99
|
+
height: frame.height,
|
|
100
|
+
transform: `scale(${scale})`
|
|
101
|
+
}
|
|
102
|
+
}),
|
|
103
|
+
/*#__PURE__*/ _jsx(ReplayCursorLayer, {
|
|
104
|
+
cursor: cursor,
|
|
105
|
+
scale: scale,
|
|
106
|
+
rate: rate,
|
|
107
|
+
onArrive: onArrive
|
|
108
|
+
})
|
|
109
|
+
]
|
|
110
|
+
}),
|
|
111
|
+
loading && /*#__PURE__*/ _jsx(ReplayVeil, {}),
|
|
112
|
+
children && /*#__PURE__*/ _jsx("div", {
|
|
113
|
+
className: "nc-replay__overlay",
|
|
114
|
+
children: children
|
|
115
|
+
})
|
|
116
|
+
]
|
|
117
|
+
})
|
|
75
118
|
})
|
|
76
119
|
]
|
|
77
120
|
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
import type { FramePoint } from '../_utils/stageViewport';
|
|
3
|
+
/** Glides the camera's world to `offset`; with reduced motion, or when the camera is off, it jumps (or rests at 0). */
|
|
4
|
+
export declare function useCameraPan(world: RefObject<HTMLDivElement | null>, offset: FramePoint, on: boolean): void;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useGSAP } from '@gsap/react';
|
|
3
|
+
import gsap from 'gsap';
|
|
4
|
+
import { useEffectEvent } from 'react';
|
|
5
|
+
import { useReducedMotion } from '../../DemoFilm/_hooks/useReducedMotion';
|
|
6
|
+
gsap.registerPlugin(useGSAP);
|
|
7
|
+
/** Glides the camera's world to `offset`; with reduced motion, or when the camera is off, it jumps (or rests at 0). */ export function useCameraPan(world, offset, on) {
|
|
8
|
+
const reduced = useReducedMotion();
|
|
9
|
+
const pan = useEffectEvent(()=>{
|
|
10
|
+
const el = world.current;
|
|
11
|
+
if (!el) return;
|
|
12
|
+
const to = on ? offset : {
|
|
13
|
+
x: 0,
|
|
14
|
+
y: 0
|
|
15
|
+
};
|
|
16
|
+
if (reduced || !on) gsap.set(el, {
|
|
17
|
+
x: to.x,
|
|
18
|
+
y: to.y
|
|
19
|
+
});
|
|
20
|
+
else gsap.to(el, {
|
|
21
|
+
x: to.x,
|
|
22
|
+
y: to.y,
|
|
23
|
+
duration: 0.7,
|
|
24
|
+
ease: 'power3.inOut',
|
|
25
|
+
overwrite: 'auto'
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
useGSAP(()=>pan(), {
|
|
29
|
+
dependencies: [
|
|
30
|
+
offset.x,
|
|
31
|
+
offset.y,
|
|
32
|
+
on,
|
|
33
|
+
reduced
|
|
34
|
+
]
|
|
35
|
+
});
|
|
36
|
+
}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { type StageViewport } from '../_utils/stageViewport';
|
|
2
|
+
/**
|
|
3
|
+
* The scale that fits `frame` into the element the returned ref points at: by width everywhere, and from 1024 px up
|
|
4
|
+
* also by height, so the frame, the caption and the controls are on screen together. `narrow` says the box is too small
|
|
5
|
+
* for the whole frame to be readable (see `cameraShot`).
|
|
6
|
+
*/
|
|
7
|
+
export declare function useStageScale(frame: StageViewport): {
|
|
4
8
|
scale: number;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
boxRef: import("react").RefObject<HTMLDivElement | null>;
|
|
12
|
+
boxWidth: number;
|
|
13
|
+
narrow: boolean;
|
|
5
14
|
};
|
|
@@ -1,25 +1,53 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useEffect, useEffectEvent, useRef, useState } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { CAMERA_BELOW_WIDTH, fitFrame } from '../_utils/stageViewport';
|
|
4
|
+
const FIT_HEIGHT_QUERY = '(min-width:1024px)';
|
|
5
|
+
const FIT_GAP = 4;
|
|
6
|
+
/** The height left for the frame: the window minus everything else of the player, minus the host's own offset. */ function roomHeight(box) {
|
|
7
|
+
if (typeof window === 'undefined' || !window.matchMedia(FIT_HEIGHT_QUERY).matches) return 0;
|
|
8
|
+
const root = box.closest('.nc-replay');
|
|
9
|
+
const view = box.firstElementChild;
|
|
10
|
+
if (!root || !(view instanceof HTMLElement)) return 0;
|
|
11
|
+
const offset = Number.parseFloat(getComputedStyle(root).getPropertyValue('--replay-fit-offset')) || 0;
|
|
12
|
+
return Math.max(0, window.innerHeight - (root.offsetHeight - view.offsetHeight) - offset - FIT_GAP);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The scale that fits `frame` into the element the returned ref points at: by width everywhere, and from 1024 px up
|
|
16
|
+
* also by height, so the frame, the caption and the controls are on screen together. `narrow` says the box is too small
|
|
17
|
+
* for the whole frame to be readable (see `cameraShot`).
|
|
18
|
+
*/ export function useStageScale(frame) {
|
|
5
19
|
const boxRef = useRef(null);
|
|
6
|
-
const [
|
|
20
|
+
const [room, setRoom] = useState({
|
|
21
|
+
width: 0,
|
|
22
|
+
height: 0
|
|
23
|
+
});
|
|
7
24
|
const measure = useEffectEvent(()=>{
|
|
8
25
|
const box = boxRef.current;
|
|
9
|
-
if (box)
|
|
26
|
+
if (box) setRoom({
|
|
27
|
+
width: box.clientWidth,
|
|
28
|
+
height: roomHeight(box)
|
|
29
|
+
});
|
|
10
30
|
});
|
|
11
31
|
useEffect(()=>{
|
|
12
32
|
const box = boxRef.current;
|
|
13
33
|
if (!box) return;
|
|
14
34
|
measure();
|
|
15
|
-
|
|
35
|
+
window.addEventListener('resize', measure);
|
|
36
|
+
if (typeof ResizeObserver === 'undefined') return ()=>window.removeEventListener('resize', measure);
|
|
16
37
|
const observer = new ResizeObserver(()=>measure());
|
|
17
38
|
observer.observe(box);
|
|
18
|
-
|
|
39
|
+
const root = box.closest('.nc-replay');
|
|
40
|
+
if (root) observer.observe(root);
|
|
41
|
+
return ()=>{
|
|
42
|
+
observer.disconnect();
|
|
43
|
+
window.removeEventListener('resize', measure);
|
|
44
|
+
};
|
|
19
45
|
}, []);
|
|
20
|
-
const
|
|
46
|
+
const narrow = room.width > 0 && room.width < CAMERA_BELOW_WIDTH;
|
|
21
47
|
return {
|
|
22
48
|
boxRef,
|
|
23
|
-
|
|
49
|
+
boxWidth: room.width,
|
|
50
|
+
narrow,
|
|
51
|
+
...fitFrame(room.width, room.height, frame)
|
|
24
52
|
};
|
|
25
53
|
}
|
|
@@ -24,7 +24,7 @@ export const initialReplayState = {
|
|
|
24
24
|
setManifest: (s)=>(manifest)=>{
|
|
25
25
|
s.manifest = manifest;
|
|
26
26
|
s.chapterId = manifest.chapters[0]?.id ?? null;
|
|
27
|
-
s.rate =
|
|
27
|
+
s.rate = 1;
|
|
28
28
|
},
|
|
29
29
|
setStatus: (s)=>(status)=>{
|
|
30
30
|
s.status = status;
|
|
@@ -72,7 +72,6 @@ const realClock = {
|
|
|
72
72
|
store,
|
|
73
73
|
send,
|
|
74
74
|
isReady: ()=>ready,
|
|
75
|
-
chosenRate: ()=>wants.rate,
|
|
76
75
|
stopPlaying: ()=>{
|
|
77
76
|
wants.playing = false;
|
|
78
77
|
},
|
|
@@ -138,8 +137,11 @@ const realClock = {
|
|
|
138
137
|
if (!chapter) return;
|
|
139
138
|
store.clearFailure();
|
|
140
139
|
store.clearStep();
|
|
140
|
+
// Until the frame reports the first step, the target chapter's opening caption stays on screen.
|
|
141
|
+
const opening = store.manifest?.steps.find((step)=>step.chapter === chapter.id);
|
|
142
|
+
if (opening) store.startStep(opening.id, opening.caption);
|
|
141
143
|
store.setPlayhead(chapter.from);
|
|
142
|
-
enterChapter(store, chapter
|
|
144
|
+
enterChapter(store, chapter);
|
|
143
145
|
if (!ready) {
|
|
144
146
|
wants.seekAt = chapter.from;
|
|
145
147
|
return;
|
|
@@ -9,10 +9,8 @@ export interface ReportDeps {
|
|
|
9
9
|
isReady: () => boolean;
|
|
10
10
|
/** The visitor's intent to play ends with the run (failure, end). */
|
|
11
11
|
stopPlaying: () => void;
|
|
12
|
-
/** The rate the visitor chose, or null while the chapter's own rate shows. */
|
|
13
|
-
chosenRate: () => number | null;
|
|
14
12
|
}
|
|
15
|
-
/** Mirrors the chapter into the store
|
|
16
|
-
export declare function enterChapter(store: ReplayStoreApi, chapter: ReplayChapter | null
|
|
13
|
+
/** Mirrors the chapter into the store. The store's rate is the visitor's speed; the frame multiplies it by the chapter's own rate. */
|
|
14
|
+
export declare function enterChapter(store: ReplayStoreApi, chapter: ReplayChapter | null): void;
|
|
17
15
|
/** The reducer from what the frame reports to what the store shows. */
|
|
18
16
|
export declare function createReportHandler(deps: ReportDeps): (message: FrameMessage) => void;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
function chapterAt(manifest, at) {
|
|
2
2
|
return manifest.chapters.filter((chapter)=>chapter.from <= at).pop() ?? null;
|
|
3
3
|
}
|
|
4
|
-
/** Mirrors the chapter into the store
|
|
4
|
+
/** Mirrors the chapter into the store. The store's rate is the visitor's speed; the frame multiplies it by the chapter's own rate. */ export function enterChapter(store, chapter) {
|
|
5
5
|
if (!chapter || chapter.id === store.chapterId) return;
|
|
6
6
|
store.setChapter(chapter.id);
|
|
7
|
-
if (chosenRate === null) store.setRate(chapter.rate);
|
|
8
7
|
}
|
|
9
8
|
/** The reducer from what the frame reports to what the store shows. */ export function createReportHandler(deps) {
|
|
10
9
|
const { store, send } = deps;
|
|
11
10
|
const onTick = (manifest, at, playing)=>{
|
|
12
11
|
store.setPlayhead(at);
|
|
13
|
-
enterChapter(store, chapterAt(manifest, at)
|
|
12
|
+
enterChapter(store, chapterAt(manifest, at));
|
|
14
13
|
if (store.status === 'failed') return;
|
|
15
14
|
if (at >= manifest.clock.durationMs && !playing) {
|
|
16
15
|
deps.stopPlaying();
|
|
@@ -22,7 +21,7 @@ function chapterAt(manifest, at) {
|
|
|
22
21
|
const step = manifest.steps.find((item)=>item.id === stepId);
|
|
23
22
|
if (!step) return;
|
|
24
23
|
store.startStep(step.id, step.caption);
|
|
25
|
-
enterChapter(store, manifest.chapters.find((item)=>item.id === step.chapter) ?? null
|
|
24
|
+
enterChapter(store, manifest.chapters.find((item)=>item.id === step.chapter) ?? null);
|
|
26
25
|
};
|
|
27
26
|
return (message)=>{
|
|
28
27
|
const manifest = store.manifest;
|
|
@@ -18,7 +18,10 @@ export declare const REPLAY_COPY: {
|
|
|
18
18
|
speed: string;
|
|
19
19
|
language: string;
|
|
20
20
|
chapters: string;
|
|
21
|
-
|
|
21
|
+
loadingChapter: string;
|
|
22
|
+
wholeScreen: string;
|
|
23
|
+
followAction: string;
|
|
24
|
+
chapterLength: (minutes: number) => string;
|
|
22
25
|
retry: string;
|
|
23
26
|
endedTitle: string;
|
|
24
27
|
endedBody: string;
|
|
@@ -60,7 +60,10 @@ export const REPLAY_COPY = {
|
|
|
60
60
|
speed: 'Speed',
|
|
61
61
|
language: 'Language',
|
|
62
62
|
chapters: 'Chapters',
|
|
63
|
-
|
|
63
|
+
loadingChapter: 'Loading chapter…',
|
|
64
|
+
wholeScreen: 'Whole screen',
|
|
65
|
+
followAction: 'Follow the action',
|
|
66
|
+
chapterLength: (minutes)=>minutes < 1 ? 'Under 1 min' : `${minutes} min`,
|
|
64
67
|
retry: 'Try again',
|
|
65
68
|
endedTitle: 'That is the whole tour.',
|
|
66
69
|
endedBody: 'Watch it again from the start, or carry on.',
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Mobile-first layout: base is a small phone; each breakpoint (480, 640, 768, 1024, 1280) only overrides upward.
|
|
3
3
|
* The stage always takes the full width of the player; the caption, the controls and the chapter list sit below it.
|
|
4
|
+
* Below 1024 px the caption and the controls stack full width under the stage, so the caption never squeezes into a
|
|
5
|
+
* narrow column. From 1024 px up the player is compact so stage, caption, controls and chapters fit one screen (the
|
|
6
|
+
* stage scales by height too, see useStageScale): the caption and controls share one row. The chapters are always one
|
|
7
|
+
* row: it fits the width when the cards do and scrolls with snapping when they do not, so no card sits alone.
|
|
8
|
+
* A host that has a header above the player sets `--replay-fit-offset` (px) so the stage leaves room for it.
|
|
4
9
|
*/
|
|
5
|
-
export declare const REPLAY_LAYOUT_CSS = "\n.nc-replay{display:grid;grid-template-columns:minmax(0,1fr);gap:12px;padding:12px;box-sizing:border-box;width:100%;max-width:100%;\n background:var(--rp-bg);color:var(--rp-ink);font-family:var(--rp-sans);\n grid-template-areas:\"stage\" \"caption\" \"controls\" \"chapters\"}\n.nc-replay *,.nc-replay *::before,.nc-replay *::after{box-sizing:border-box}\n.nc-replay__stage{grid-area:stage}\n.nc-replay__caption{grid-area:caption}\n.nc-replay__controls{grid-area:controls}\n.nc-replay__chapters{grid-area:chapters}\n.nc-replay__chapter-list{display:grid;grid-
|
|
10
|
+
export declare const REPLAY_LAYOUT_CSS = "\n.nc-replay{display:grid;grid-template-columns:minmax(0,1fr);gap:12px;padding:12px;box-sizing:border-box;width:100%;max-width:100%;\n background:var(--rp-bg);color:var(--rp-ink);font-family:var(--rp-sans);\n grid-template-areas:\"stage\" \"caption\" \"controls\" \"chapters\"}\n.nc-replay *,.nc-replay *::before,.nc-replay *::after{box-sizing:border-box}\n.nc-replay__stage{grid-area:stage}\n.nc-replay__caption{grid-area:caption}\n.nc-replay__controls{grid-area:controls}\n.nc-replay__chapters{grid-area:chapters;min-width:0}\n.nc-replay__chapter-list{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(140px,1fr);gap:8px;margin:0;padding:0 0 2px;\n list-style:none;overflow-x:auto;scroll-snap-type:x proximity}\n.nc-replay__chapter{scroll-snap-align:start}\n@media (min-width:480px){.nc-replay{gap:14px;padding:16px}}\n@media (min-width:768px){.nc-replay{gap:16px;padding:20px}}\n@media (min-width:1024px){.nc-replay{gap:10px;padding:12px 16px;grid-template-columns:minmax(0,1fr) auto;\n grid-template-areas:\"stage stage\" \"caption controls\" \"chapters chapters\"}\n .nc-replay__h{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}\n .nc-replay__caption{display:flex;align-items:baseline;gap:12px;padding:8px 14px}\n .nc-replay__caption .nc-replay__eyebrow{margin:0;flex:none}\n .nc-replay__caption .nc-replay__text{font-size:16px}\n .nc-replay__controls{align-self:center}\n .nc-replay__chapter button{gap:6px;padding:8px 10px;min-height:44px}}\n@media (min-width:1280px){.nc-replay{gap:12px;padding:12px 20px}}\n";
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Mobile-first layout: base is a small phone; each breakpoint (480, 640, 768, 1024, 1280) only overrides upward.
|
|
3
3
|
* The stage always takes the full width of the player; the caption, the controls and the chapter list sit below it.
|
|
4
|
+
* Below 1024 px the caption and the controls stack full width under the stage, so the caption never squeezes into a
|
|
5
|
+
* narrow column. From 1024 px up the player is compact so stage, caption, controls and chapters fit one screen (the
|
|
6
|
+
* stage scales by height too, see useStageScale): the caption and controls share one row. The chapters are always one
|
|
7
|
+
* row: it fits the width when the cards do and scrolls with snapping when they do not, so no card sits alone.
|
|
8
|
+
* A host that has a header above the player sets `--replay-fit-offset` (px) so the stage leaves room for it.
|
|
4
9
|
*/ export const REPLAY_LAYOUT_CSS = `
|
|
5
10
|
.nc-replay{display:grid;grid-template-columns:minmax(0,1fr);gap:12px;padding:12px;box-sizing:border-box;width:100%;max-width:100%;
|
|
6
11
|
background:var(--rp-bg);color:var(--rp-ink);font-family:var(--rp-sans);
|
|
@@ -9,14 +14,19 @@
|
|
|
9
14
|
.nc-replay__stage{grid-area:stage}
|
|
10
15
|
.nc-replay__caption{grid-area:caption}
|
|
11
16
|
.nc-replay__controls{grid-area:controls}
|
|
12
|
-
.nc-replay__chapters{grid-area:chapters}
|
|
13
|
-
.nc-replay__chapter-list{display:grid;grid-
|
|
17
|
+
.nc-replay__chapters{grid-area:chapters;min-width:0}
|
|
18
|
+
.nc-replay__chapter-list{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(140px,1fr);gap:8px;margin:0;padding:0 0 2px;
|
|
19
|
+
list-style:none;overflow-x:auto;scroll-snap-type:x proximity}
|
|
20
|
+
.nc-replay__chapter{scroll-snap-align:start}
|
|
14
21
|
@media (min-width:480px){.nc-replay{gap:14px;padding:16px}}
|
|
15
|
-
@media (min-width:
|
|
16
|
-
@media (min-width:
|
|
22
|
+
@media (min-width:768px){.nc-replay{gap:16px;padding:20px}}
|
|
23
|
+
@media (min-width:1024px){.nc-replay{gap:10px;padding:12px 16px;grid-template-columns:minmax(0,1fr) auto;
|
|
17
24
|
grid-template-areas:"stage stage" "caption controls" "chapters chapters"}
|
|
18
|
-
.nc-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
.nc-
|
|
25
|
+
.nc-replay__h{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
|
|
26
|
+
.nc-replay__caption{display:flex;align-items:baseline;gap:12px;padding:8px 14px}
|
|
27
|
+
.nc-replay__caption .nc-replay__eyebrow{margin:0;flex:none}
|
|
28
|
+
.nc-replay__caption .nc-replay__text{font-size:16px}
|
|
29
|
+
.nc-replay__controls{align-self:center}
|
|
30
|
+
.nc-replay__chapter button{gap:6px;padding:8px 10px;min-height:44px}}
|
|
31
|
+
@media (min-width:1280px){.nc-replay{gap:12px;padding:12px 20px}}
|
|
22
32
|
`;
|
|
@@ -6,11 +6,15 @@ const STAGE = `
|
|
|
6
6
|
.nc-replay__dots i{width:8px;height:8px;border-radius:50%;background:#efe9dc;opacity:.28}
|
|
7
7
|
.nc-replay__title{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;opacity:.8}
|
|
8
8
|
.nc-replay__pill{flex:none;border:1px solid rgb(239 233 220 / .35);border-radius:999px;padding:4px 8px;font-size:10px;letter-spacing:.08em;text-transform:uppercase}
|
|
9
|
-
.nc-
|
|
9
|
+
.nc-replay__slot{display:flex;justify-content:center;min-width:0;width:100%;background:var(--rp-bezel)}
|
|
10
|
+
.nc-replay__view{position:relative;flex:none;max-width:100%;overflow:hidden;background:var(--rp-surface)}
|
|
11
|
+
.nc-replay__world{position:absolute;left:0;top:0}
|
|
12
|
+
.nc-replay__zoom{cursor:pointer;min-height:32px;background:transparent;color:inherit;font-family:inherit}
|
|
13
|
+
.nc-replay__zoom[aria-pressed="true"]{background:rgb(239 233 220 / .16)}
|
|
10
14
|
.nc-replay__frame{position:absolute;left:0;top:0;border:0;transform-origin:0 0;pointer-events:none;background:#fff}
|
|
11
15
|
.nc-replay__layer{position:absolute;inset:0;overflow:hidden;pointer-events:none}
|
|
12
16
|
.nc-replay__ring{position:absolute;left:0;top:0;opacity:0;border:2px solid var(--rp-accent);border-radius:8px;
|
|
13
|
-
background:color-mix(in srgb,var(--rp-accent) 12%,transparent)
|
|
17
|
+
background:color-mix(in srgb,var(--rp-accent) 12%,transparent)}
|
|
14
18
|
.nc-replay__ripple{position:absolute;left:0;top:0;width:56px;height:56px;margin:-28px 0 0 -28px;opacity:0;border-radius:50%;
|
|
15
19
|
border:2px solid var(--rp-accent);background:color-mix(in srgb,var(--rp-accent) 30%,transparent)}
|
|
16
20
|
.nc-replay__cursor{position:absolute;left:0;top:0;width:24px;height:24px;opacity:0;filter:drop-shadow(0 2px 3px rgb(0 0 0 / .35))}
|
|
@@ -22,7 +26,6 @@ const TEXT = `
|
|
|
22
26
|
.nc-replay__panel{min-width:0;border:1px solid var(--rp-line);border-radius:14px;background:var(--rp-surface);padding:14px;box-shadow:var(--rp-shadow)}
|
|
23
27
|
.nc-replay__eyebrow{margin:0 0 6px;color:var(--rp-accent-ink);font:600 11px/1.2 var(--rp-mono);letter-spacing:.08em;text-transform:uppercase}
|
|
24
28
|
.nc-replay__text{margin:0;font:500 17px/1.3 var(--rp-display);letter-spacing:-.01em;overflow-wrap:anywhere}
|
|
25
|
-
.nc-replay__chapter-name{margin:8px 0 0;color:var(--rp-faint);font:500 13px/1.3 var(--rp-sans)}
|
|
26
29
|
.nc-replay__h{margin:0 0 8px;color:var(--rp-faint);font:600 11px/1.2 var(--rp-mono);letter-spacing:.08em;text-transform:uppercase}
|
|
27
30
|
.nc-replay__card{max-width:420px;display:grid;gap:10px;border:1px solid var(--rp-line);border-radius:14px;background:var(--rp-surface);
|
|
28
31
|
padding:18px;color:var(--rp-ink);box-shadow:var(--rp-shadow)}
|
|
@@ -39,7 +42,7 @@ const CONTROLS = `
|
|
|
39
42
|
.nc-replay__btn:hover{border-color:var(--rp-accent)}
|
|
40
43
|
.nc-replay__btn:focus-visible,.nc-replay__chapter button:focus-visible{outline:2px solid var(--rp-accent);outline-offset:2px}
|
|
41
44
|
.nc-replay__btn[data-primary]{background:var(--rp-accent);border-color:var(--rp-accent);color:var(--rp-on-accent)}
|
|
42
|
-
.nc-replay__btn[aria-pressed="true"]{border-color:var(--rp-
|
|
45
|
+
.nc-replay__btn[aria-pressed="true"]{border-color:var(--rp-ink);color:var(--rp-bg);background:var(--rp-ink)}
|
|
43
46
|
.nc-replay__seg{display:inline-flex;gap:4px;align-items:center}
|
|
44
47
|
.nc-replay__badge{display:inline-flex;align-items:center;min-height:28px;padding:0 10px;border-radius:999px;background:var(--rp-surface2);
|
|
45
48
|
color:var(--rp-soft);font:600 11px/1 var(--rp-mono)}
|
|
@@ -12,3 +12,5 @@ export declare function manifestLocales(manifest: ReplayManifest): string[];
|
|
|
12
12
|
export declare function localeName(code: string): string;
|
|
13
13
|
/** The rate as the visitor reads it: `1x`, `2x`, `0.5x`. */
|
|
14
14
|
export declare function rateLabel(rate: number): string;
|
|
15
|
+
/** How long a chapter plays at normal speed, in whole minutes (its recorded span divided by its own pace). */
|
|
16
|
+
export declare function chapterMinutes(chapter: ReplayChapter): number;
|
|
@@ -37,3 +37,6 @@
|
|
|
37
37
|
/** The rate as the visitor reads it: `1x`, `2x`, `0.5x`. */ export function rateLabel(rate) {
|
|
38
38
|
return `${Number.isInteger(rate) ? rate : Number(rate.toFixed(2))}x`;
|
|
39
39
|
}
|
|
40
|
+
/** How long a chapter plays at normal speed, in whole minutes (its recorded span divided by its own pace). */ export function chapterMinutes(chapter) {
|
|
41
|
+
return Math.round((chapter.to - chapter.from) / Math.max(chapter.rate, 0.001) / 60000);
|
|
42
|
+
}
|
|
@@ -15,3 +15,36 @@ export interface StageViewport {
|
|
|
15
15
|
export declare function stageViewport(recorded: StageViewport): StageViewport;
|
|
16
16
|
/** The uniform scale that fits a frame of `frameWidth` px into a box `boxWidth` px wide; 1 until the box is measured. */
|
|
17
17
|
export declare function fitScale(boxWidth: number, frameWidth: number): number;
|
|
18
|
+
export interface FrameFit {
|
|
19
|
+
/** Uniform scale of the frame. */
|
|
20
|
+
scale: number;
|
|
21
|
+
/** The scaled frame's size in drawn pixels. */
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The scale that keeps the whole frame visible: the smaller of the width fit and the height fit. `availableHeight` is
|
|
27
|
+
* the height left for the frame (0 or less means the height is not limited, e.g. a phone, where the page scrolls).
|
|
28
|
+
* The result is letterboxed by the caller: it is never wider than the box and never taller than the room.
|
|
29
|
+
*/
|
|
30
|
+
export declare function fitFrame(boxWidth: number, availableHeight: number, frame: StageViewport): FrameFit;
|
|
31
|
+
/** The stage width under which the whole frame would be an unreadable thumbnail, so a camera follows the action. */
|
|
32
|
+
export declare const CAMERA_BELOW_WIDTH = 720;
|
|
33
|
+
/** The scale the camera shows the frame at: ACE text stays legible on a phone. */
|
|
34
|
+
export declare const CAMERA_SCALE = 0.75;
|
|
35
|
+
export interface CameraShot {
|
|
36
|
+
scale: number;
|
|
37
|
+
/** The window the camera looks through, in drawn pixels. */
|
|
38
|
+
viewWidth: number;
|
|
39
|
+
viewHeight: number;
|
|
40
|
+
}
|
|
41
|
+
export interface FramePoint {
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
}
|
|
45
|
+
/** A readable window onto the frame for a narrow stage: a fixed scale, a window as wide as the box and a bit taller. */
|
|
46
|
+
export declare function cameraShot(boxWidth: number, frame: StageViewport): CameraShot;
|
|
47
|
+
/** Where the scaled frame sits inside the camera window so `focus` (a frame point) is centred, never showing past the frame. */
|
|
48
|
+
export declare function cameraOffset(focus: FramePoint, shot: CameraShot, frame: StageViewport): FramePoint;
|
|
49
|
+
/** Where the camera rests before the first pointer action: the right-hand side, where ACE's conversation runs. */
|
|
50
|
+
export declare function restingFocus(frame: StageViewport): FramePoint;
|
|
@@ -15,3 +15,45 @@
|
|
|
15
15
|
/** The uniform scale that fits a frame of `frameWidth` px into a box `boxWidth` px wide; 1 until the box is measured. */ export function fitScale(boxWidth, frameWidth) {
|
|
16
16
|
return boxWidth > 0 && frameWidth > 0 ? boxWidth / frameWidth : 1;
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* The scale that keeps the whole frame visible: the smaller of the width fit and the height fit. `availableHeight` is
|
|
20
|
+
* the height left for the frame (0 or less means the height is not limited, e.g. a phone, where the page scrolls).
|
|
21
|
+
* The result is letterboxed by the caller: it is never wider than the box and never taller than the room.
|
|
22
|
+
*/ export function fitFrame(boxWidth, availableHeight, frame) {
|
|
23
|
+
const byWidth = fitScale(boxWidth, frame.width);
|
|
24
|
+
const byHeight = availableHeight > 0 && frame.height > 0 ? availableHeight / frame.height : Number.POSITIVE_INFINITY;
|
|
25
|
+
const scale = Math.min(byWidth, byHeight);
|
|
26
|
+
return {
|
|
27
|
+
scale,
|
|
28
|
+
width: frame.width * scale,
|
|
29
|
+
height: frame.height * scale
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/** The stage width under which the whole frame would be an unreadable thumbnail, so a camera follows the action. */ export const CAMERA_BELOW_WIDTH = 720;
|
|
33
|
+
/** The scale the camera shows the frame at: ACE text stays legible on a phone. */ export const CAMERA_SCALE = 0.75;
|
|
34
|
+
/** The camera window's height as a share of its width. */ const CAMERA_ASPECT = 1.1;
|
|
35
|
+
/** A readable window onto the frame for a narrow stage: a fixed scale, a window as wide as the box and a bit taller. */ export function cameraShot(boxWidth, frame) {
|
|
36
|
+
const scale = CAMERA_SCALE;
|
|
37
|
+
return {
|
|
38
|
+
scale,
|
|
39
|
+
viewWidth: boxWidth,
|
|
40
|
+
viewHeight: Math.min(Math.round(frame.height * scale), Math.round(boxWidth * CAMERA_ASPECT))
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function clamp(value, low, high) {
|
|
44
|
+
return Math.min(high, Math.max(low, value));
|
|
45
|
+
}
|
|
46
|
+
/** Where the scaled frame sits inside the camera window so `focus` (a frame point) is centred, never showing past the frame. */ export function cameraOffset(focus, shot, frame) {
|
|
47
|
+
const lowX = Math.min(0, shot.viewWidth - frame.width * shot.scale);
|
|
48
|
+
const lowY = Math.min(0, shot.viewHeight - frame.height * shot.scale);
|
|
49
|
+
return {
|
|
50
|
+
x: clamp(shot.viewWidth / 2 - focus.x * shot.scale, lowX, 0),
|
|
51
|
+
y: clamp(shot.viewHeight / 2 - focus.y * shot.scale, lowY, 0)
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/** Where the camera rests before the first pointer action: the right-hand side, where ACE's conversation runs. */ export function restingFocus(frame) {
|
|
55
|
+
return {
|
|
56
|
+
x: frame.width * 0.82,
|
|
57
|
+
y: frame.height * 0.6
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -18,8 +18,8 @@ export interface Timeline {
|
|
|
18
18
|
readonly clock: Clock;
|
|
19
19
|
play(): void;
|
|
20
20
|
pause(): void;
|
|
21
|
-
/**
|
|
22
|
-
setRate(
|
|
21
|
+
/** The visitor's speed: a multiplier on every chapter's own rate (a chapter recorded at 8x plays at 16x on 2). */
|
|
22
|
+
setRate(speed: number): void;
|
|
23
23
|
getRate(): number;
|
|
24
24
|
isPlaying(): boolean;
|
|
25
25
|
/** Chapter starts are the only seek points. Throws on an unknown id. */
|
|
@@ -11,8 +11,8 @@ export function createTimeline(options) {
|
|
|
11
11
|
let playing = false;
|
|
12
12
|
let head = 0;
|
|
13
13
|
let anchor = clock.now();
|
|
14
|
-
let
|
|
15
|
-
let
|
|
14
|
+
let speed = 1;
|
|
15
|
+
let rate = (chapters.find((chapter)=>chapter.from <= 0)?.rate ?? 1) * speed;
|
|
16
16
|
let timer = null;
|
|
17
17
|
let chapterId = null;
|
|
18
18
|
const now = ()=>{
|
|
@@ -40,9 +40,9 @@ export function createTimeline(options) {
|
|
|
40
40
|
const id = chapter?.id ?? null;
|
|
41
41
|
if (id === chapterId) return false;
|
|
42
42
|
chapterId = id;
|
|
43
|
-
if (chapter &&
|
|
43
|
+
if (chapter && chapter.rate * speed !== rate) {
|
|
44
44
|
reanchor();
|
|
45
|
-
rate = chapter.rate;
|
|
45
|
+
rate = chapter.rate * speed;
|
|
46
46
|
}
|
|
47
47
|
return true;
|
|
48
48
|
};
|
|
@@ -118,8 +118,8 @@ export function createTimeline(options) {
|
|
|
118
118
|
setRate (next) {
|
|
119
119
|
if (!Number.isFinite(next) || next <= 0) throw new RangeError('rate must be a positive number');
|
|
120
120
|
reanchor();
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
speed = next;
|
|
122
|
+
rate = (chapters.find((item)=>item.id === chapterId)?.rate ?? 1) * speed;
|
|
123
123
|
notify();
|
|
124
124
|
arm();
|
|
125
125
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nucleus-core-ts",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.256",
|
|
4
4
|
"description": "Production-ready, enterprise-grade TypeScript framework for building multi-tenant APIs",
|
|
5
5
|
"author": "Hidayet Can Özcan <hidayetcan@gmail.com>",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|