nucleus-core-ts 0.10.255 → 0.10.257

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/.build-ok +1 -1
  2. package/dist/fe/components/Replay/_components/ReplayCaption/index.d.ts +1 -1
  3. package/dist/fe/components/Replay/_components/ReplayCaption/index.js +2 -2
  4. package/dist/fe/components/Replay/_components/ReplayCaption/types.d.ts +2 -0
  5. package/dist/fe/components/Replay/_components/ReplayChapters/index.js +2 -2
  6. package/dist/fe/components/Replay/_components/ReplayControls/index.js +5 -9
  7. package/dist/fe/components/Replay/_components/ReplayControls/types.d.ts +1 -2
  8. package/dist/fe/components/Replay/_components/ReplayPlayer/ReplayView.js +2 -3
  9. package/dist/fe/components/Replay/_components/ReplayStage/index.d.ts +5 -3
  10. package/dist/fe/components/Replay/_components/ReplayStage/index.js +62 -27
  11. package/dist/fe/components/Replay/_hooks/useCameraPan.d.ts +4 -0
  12. package/dist/fe/components/Replay/_hooks/useCameraPan.js +36 -0
  13. package/dist/fe/components/Replay/_hooks/useStageScale.d.ts +4 -1
  14. package/dist/fe/components/Replay/_hooks/useStageScale.js +6 -2
  15. package/dist/fe/components/Replay/_store/replayStore.js +1 -1
  16. package/dist/fe/components/Replay/_utils/controller.js +4 -2
  17. package/dist/fe/components/Replay/_utils/controllerReports.d.ts +2 -4
  18. package/dist/fe/components/Replay/_utils/controllerReports.js +3 -4
  19. package/dist/fe/components/Replay/_utils/copy.d.ts +4 -1
  20. package/dist/fe/components/Replay/_utils/copy.js +9 -6
  21. package/dist/fe/components/Replay/_utils/frameBridge.d.ts +6 -0
  22. package/dist/fe/components/Replay/_utils/frameBridge.js +2 -1
  23. package/dist/fe/components/Replay/_utils/replayLayout.d.ts +5 -3
  24. package/dist/fe/components/Replay/_utils/replayLayout.js +9 -10
  25. package/dist/fe/components/Replay/_utils/replayParts.js +4 -1
  26. package/dist/fe/components/Replay/_utils/replayProgress.d.ts +2 -0
  27. package/dist/fe/components/Replay/_utils/replayProgress.js +3 -0
  28. package/dist/fe/components/Replay/_utils/stageViewport.d.ts +20 -0
  29. package/dist/fe/components/Replay/_utils/stageViewport.js +28 -0
  30. package/dist/src/Client/Replay/driver/run.d.ts +12 -1
  31. package/dist/src/Client/Replay/driver/run.js +22 -6
  32. package/dist/src/Client/Replay/timeline/timeline.d.ts +2 -2
  33. package/dist/src/Client/Replay/timeline/timeline.js +6 -6
  34. package/package.json +1 -1
package/dist/.build-ok CHANGED
@@ -1 +1 @@
1
- 0.10.255
1
+ 0.10.257
@@ -1,3 +1,3 @@
1
1
  import type { ReplayCaptionProps } from './types';
2
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 }: ReplayCaptionProps): import("react/jsx-runtime").JSX.Element;
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 and its position; the player's live region, so a screen reader hears each step. */ export function ReplayCaption({ text, stepId, position }) {
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,7 +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
45
+ children: text || (loading ? REPLAY_COPY.loadingChapter : REPLAY_COPY.idle)
46
46
  })
47
47
  ]
48
48
  });
@@ -3,6 +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
+ /** Playing but no step has started yet (a chapter was just opened): show that, not the idle line. */
7
+ loading: boolean;
6
8
  /** 1-based position among the recording's steps; null before the first step. */
7
9
  position: {
8
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 { chapterProgress, rateLabel } from '../../_utils/replayProgress';
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: rateLabel(chapter.rate)
47
+ children: REPLAY_COPY.chapterLength(chapterMinutes(chapter))
48
48
  })
49
49
  ]
50
50
  })
@@ -10,9 +10,10 @@ 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, chapterRate, locales, locale, onPlay, onPause, onRate, onLocale, onRestart } = props;
13
+ const { status, rate, locales, locale, onPlay, onPause, onRate, onLocale, onRestart } = props;
14
14
  const playing = status === 'playing';
15
- const idle = status === 'loading' || status === 'failed';
15
+ const idle = status === 'loading';
16
+ const noPlay = idle || status === 'failed';
16
17
  return /*#__PURE__*/ _jsxs("div", {
17
18
  className: "nc-replay__controls",
18
19
  role: "group",
@@ -23,7 +24,7 @@ const ICON = {
23
24
  type: "button",
24
25
  className: "nc-replay__btn",
25
26
  "data-primary": "",
26
- disabled: idle,
27
+ disabled: noPlay,
27
28
  onClick: playing ? onPause : onPlay,
28
29
  children: [
29
30
  /*#__PURE__*/ _jsx("svg", {
@@ -60,16 +61,11 @@ const ICON = {
60
61
  type: "button",
61
62
  className: "nc-replay__btn",
62
63
  "aria-pressed": rate === choice,
63
- disabled: idle,
64
+ disabled: noPlay,
64
65
  onClick: ()=>onRate(choice),
65
66
  children: rateLabel(choice)
66
67
  }, choice))
67
68
  }),
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
69
  locales.length > 1 && /*#__PURE__*/ _jsx("span", {
74
70
  className: "nc-replay__seg",
75
71
  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,12 +72,12 @@ import { ReplayStage } from '../ReplayStage';
73
72
  /*#__PURE__*/ _jsx(ReplayCaption, {
74
73
  text: pickLocalized(state.caption, locale),
75
74
  stepId: state.stepId,
76
- position: stepPosition(manifest, state.stepId)
75
+ position: stepPosition(manifest, state.stepId),
76
+ loading: status === 'playing'
77
77
  }),
78
78
  /*#__PURE__*/ _jsx(ReplayControls, {
79
79
  status: status,
80
80
  rate: state.rate,
81
- chapterRate: chapter?.rate ?? null,
82
81
  locales: manifestLocales(manifest),
83
82
  locale: locale,
84
83
  onPlay: player.play,
@@ -2,8 +2,10 @@ 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
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. The frame takes no pointer events: the
6
- * visitor watches, the cursor and highlight layers above it show what happens. The cursor layer shares the view's box
7
- * and the frame's scale, so a point of the frame lands on the same spot of the layer.
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.
8
10
  */
9
11
  export declare function ReplayStage(props: ReplayStageProps): import("react/jsx-runtime").JSX.Element;
@@ -1,26 +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
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
12
- * the caption and the controls. The view is letterboxed (centred) in the slot. The frame takes no pointer events: the
13
- * visitor watches, the cursor and highlight layers above it show what happens. The cursor layer shares the view's box
14
- * and the frame's scale, so a point of the frame lands on the same spot of the layer.
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.
15
19
  */ export function ReplayStage(props) {
16
20
  const { manifest, locale, frameSrc, frameRef, cursor, rate, onArrive, loading, children } = props;
17
21
  const frame = stageViewport(manifest.viewport);
18
- const { boxRef, scale, width: shownWidth, height: shownHeight } = useStageScale(frame);
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);
19
34
  const title = pickLocalized(manifest.title, locale);
20
- const measured = shownWidth > 0;
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;
21
39
  return /*#__PURE__*/ _jsxs("div", {
22
40
  className: "nc-replay__stage",
23
41
  "data-replay-stage": true,
42
+ "data-replay-camera": camera ? '' : undefined,
24
43
  children: [
25
44
  /*#__PURE__*/ _jsxs("div", {
26
45
  className: "nc-replay__bar",
@@ -38,40 +57,56 @@ import { ReplayVeil } from './ReplayVeil';
38
57
  className: "nc-replay__title",
39
58
  children: title
40
59
  }),
41
- /*#__PURE__*/ _jsx("span", {
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", {
42
67
  className: "nc-replay__pill",
43
68
  children: REPLAY_COPY.watchOnly
44
69
  })
45
70
  ]
46
71
  }),
47
72
  /*#__PURE__*/ _jsx("div", {
48
- ref: boxRef,
73
+ ref: fit.boxRef,
49
74
  className: "nc-replay__slot",
50
75
  children: /*#__PURE__*/ _jsxs("div", {
51
76
  className: "nc-replay__view",
52
77
  style: {
53
- aspectRatio: `${frame.width} / ${frame.height}`,
54
- width: measured ? shownWidth : '100%',
55
- height: measured ? shownHeight : undefined
78
+ aspectRatio: camera ? undefined : `${frame.width} / ${frame.height}`,
79
+ width: measured ? viewWidth : '100%',
80
+ height: measured ? viewHeight : undefined
56
81
  },
57
82
  children: [
58
- frameSrc !== null && /*#__PURE__*/ _jsx("iframe", {
59
- ref: frameRef,
60
- className: "nc-replay__frame",
61
- src: frameSrc,
62
- title: title,
63
- tabIndex: -1,
83
+ /*#__PURE__*/ _jsxs("div", {
84
+ ref: world,
85
+ className: "nc-replay__world",
64
86
  style: {
65
- width: frame.width,
66
- height: frame.height,
67
- transform: `scale(${scale})`
68
- }
69
- }),
70
- /*#__PURE__*/ _jsx(ReplayCursorLayer, {
71
- cursor: cursor,
72
- scale: scale,
73
- rate: rate,
74
- onArrive: onArrive
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
+ ]
75
110
  }),
76
111
  loading && /*#__PURE__*/ _jsx(ReplayVeil, {}),
77
112
  children && /*#__PURE__*/ _jsx("div", {
@@ -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,11 +1,14 @@
1
1
  import { type StageViewport } from '../_utils/stageViewport';
2
2
  /**
3
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.
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`).
5
6
  */
6
7
  export declare function useStageScale(frame: StageViewport): {
7
8
  scale: number;
8
9
  width: number;
9
10
  height: number;
10
11
  boxRef: import("react").RefObject<HTMLDivElement | null>;
12
+ boxWidth: number;
13
+ narrow: boolean;
11
14
  };
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import { useEffect, useEffectEvent, useRef, useState } from 'react';
3
- import { fitFrame } from '../_utils/stageViewport';
3
+ import { CAMERA_BELOW_WIDTH, fitFrame } from '../_utils/stageViewport';
4
4
  const FIT_HEIGHT_QUERY = '(min-width:1024px)';
5
5
  const FIT_GAP = 4;
6
6
  /** The height left for the frame: the window minus everything else of the player, minus the host's own offset. */ function roomHeight(box) {
@@ -13,7 +13,8 @@ const FIT_GAP = 4;
13
13
  }
14
14
  /**
15
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.
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`).
17
18
  */ export function useStageScale(frame) {
18
19
  const boxRef = useRef(null);
19
20
  const [room, setRoom] = useState({
@@ -42,8 +43,11 @@ const FIT_GAP = 4;
42
43
  window.removeEventListener('resize', measure);
43
44
  };
44
45
  }, []);
46
+ const narrow = room.width > 0 && room.width < CAMERA_BELOW_WIDTH;
45
47
  return {
46
48
  boxRef,
49
+ boxWidth: room.width,
50
+ narrow,
47
51
  ...fitFrame(room.width, room.height, frame)
48
52
  };
49
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 = manifest.chapters[0]?.rate ?? 1;
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, wants.rate);
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; the chapter's rate shows unless the visitor chose one. */
16
- export declare function enterChapter(store: ReplayStoreApi, chapter: ReplayChapter | null, chosenRate: number | null): void;
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; the chapter's rate shows unless the visitor chose one. */ export function enterChapter(store, chapter, chosenRate) {
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), deps.chosenRate());
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, deps.chosenRate());
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
- chapterPace: (label: string) => string;
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;
@@ -1,15 +1,15 @@
1
- const RETRY_OR_RERECORD = 'Try again from this chapter. If it repeats, the site owner has to record it again.';
1
+ const RETRY_OR_RERECORD = 'Try again from this chapter, or pick another chapter below.';
2
2
  const STOPPED = 'The walkthrough stopped at this step.';
3
3
  const FAILURES = {
4
4
  manifest_unreachable: {
5
5
  what: 'The recording could not be loaded.',
6
6
  means: 'There is nothing to play yet.',
7
- next: 'Check your connection and try again. If it keeps failing, the site owner has to republish the recording.'
7
+ next: 'Check your connection and try again. If it keeps failing, come back a little later.'
8
8
  },
9
9
  manifest_invalid: {
10
10
  what: 'The recording file is not in a format this player understands.',
11
11
  means: 'It cannot be played, and trying again will not change that.',
12
- next: 'The site owner has to record and publish it again.'
12
+ next: 'Reload the page. If it keeps failing, come back a little later.'
13
13
  },
14
14
  frame_timeout: {
15
15
  what: 'The product screen did not start in time.',
@@ -24,7 +24,7 @@ const FAILURES = {
24
24
  target_unsupported: {
25
25
  what: 'This step points at an element the player cannot operate.',
26
26
  means: STOPPED,
27
- next: 'The site owner has to record this step again.'
27
+ next: 'Try another chapter below, or reload the page.'
28
28
  },
29
29
  option_not_found: {
30
30
  what: 'A choice in this step is missing from the screen.',
@@ -44,7 +44,7 @@ const FAILURES = {
44
44
  step_unknown: {
45
45
  what: 'The recording refers to a step it does not contain.',
46
46
  means: 'It cannot be played to the end.',
47
- next: 'The site owner has to record and publish it again.'
47
+ next: 'Reload the page. If it keeps failing, come back a little later.'
48
48
  }
49
49
  };
50
50
  export function failureCopy(reason) {
@@ -60,7 +60,10 @@ export const REPLAY_COPY = {
60
60
  speed: 'Speed',
61
61
  language: 'Language',
62
62
  chapters: 'Chapters',
63
- chapterPace: (label)=>`Chapter pace ${label}`,
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.',
@@ -28,6 +28,12 @@ export interface ReplayFrameOptions {
28
28
  pointTimeoutMs?: number;
29
29
  targetTimeoutMs?: number;
30
30
  visible?: VisibleCheck;
31
+ /**
32
+ * A step whose pointer action cannot be shown (the element is not on the screen) is skipped, logged to the console, and the
33
+ * tape plays on. Default true: a public page never stops its tour and never tells a visitor to contact the site owner.
34
+ * Set false to stop and report `step-failed` instead (a recorder's own check).
35
+ */
36
+ skipFailedSteps?: boolean;
31
37
  }
32
38
  export interface ReplayFrameHandle {
33
39
  stop: () => void;
@@ -79,7 +79,8 @@ const MAX_KEY_LENGTH = 200;
79
79
  navigate: options.navigate,
80
80
  waitForFrame: options.waitForFrame,
81
81
  waitUntil: (at)=>timeline.waitUntil(at),
82
- hold
82
+ hold,
83
+ onSkip: options.skipFailedSteps === false ? undefined : ({ actionIndex, reason })=>win.console?.warn(`[replay] step ${step.id} action ${actionIndex} skipped: ${reason}`)
83
84
  });
84
85
  if (gen !== generation) return false;
85
86
  if (result.ok) {
@@ -1,8 +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
- * From 1024 px up the player is compact so stage, caption, controls and chapters fit one screen (the stage scales by
5
- * height too, see useStageScale): the caption and controls share one row and the chapters are one scrolling row.
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.
6
8
  * A host that has a header above the player sets `--replay-fit-offset` (px) so the stage leaves room for it.
7
9
  */
8
- 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-template-columns:minmax(0,1fr);gap:8px;margin:0;padding:0;list-style:none}\n@media (min-width:480px){.nc-replay{gap:14px;padding:16px}}\n@media (min-width:640px){.nc-replay__chapter-list{grid-template-columns:repeat(2,minmax(0,1fr))}}\n@media (min-width:768px){.nc-replay{gap:16px;padding:20px;grid-template-columns:minmax(0,1fr) auto;\n grid-template-areas:\"stage stage\" \"caption controls\" \"chapters chapters\"}\n .nc-replay__chapter-list{grid-template-columns:repeat(3,minmax(0,1fr))}}\n@media (min-width:1024px){.nc-replay{gap:10px;padding:12px 16px}\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-list{display:grid;grid-template-columns:none;grid-auto-flow:column;grid-auto-columns:minmax(150px,1fr);\n overflow-x:auto;scroll-snap-type:x proximity;gap:8px;padding-bottom:2px}\n .nc-replay__chapter{scroll-snap-align:start}\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";
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,8 +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
- * From 1024 px up the player is compact so stage, caption, controls and chapters fit one screen (the stage scales by
5
- * height too, see useStageScale): the caption and controls share one row and the chapters are one scrolling row.
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.
6
8
  * A host that has a header above the player sets `--replay-fit-offset` (px) so the stage leaves room for it.
7
9
  */ export const REPLAY_LAYOUT_CSS = `
8
10
  .nc-replay{display:grid;grid-template-columns:minmax(0,1fr);gap:12px;padding:12px;box-sizing:border-box;width:100%;max-width:100%;
@@ -13,21 +15,18 @@
13
15
  .nc-replay__caption{grid-area:caption}
14
16
  .nc-replay__controls{grid-area:controls}
15
17
  .nc-replay__chapters{grid-area:chapters;min-width:0}
16
- .nc-replay__chapter-list{display:grid;grid-template-columns:minmax(0,1fr);gap:8px;margin:0;padding:0;list-style:none}
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}
17
21
  @media (min-width:480px){.nc-replay{gap:14px;padding:16px}}
18
- @media (min-width:640px){.nc-replay__chapter-list{grid-template-columns:repeat(2,minmax(0,1fr))}}
19
- @media (min-width:768px){.nc-replay{gap:16px;padding:20px;grid-template-columns:minmax(0,1fr) auto;
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;
20
24
  grid-template-areas:"stage stage" "caption controls" "chapters chapters"}
21
- .nc-replay__chapter-list{grid-template-columns:repeat(3,minmax(0,1fr))}}
22
- @media (min-width:1024px){.nc-replay{gap:10px;padding:12px 16px}
23
25
  .nc-replay__h{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
24
26
  .nc-replay__caption{display:flex;align-items:baseline;gap:12px;padding:8px 14px}
25
27
  .nc-replay__caption .nc-replay__eyebrow{margin:0;flex:none}
26
28
  .nc-replay__caption .nc-replay__text{font-size:16px}
27
29
  .nc-replay__controls{align-self:center}
28
- .nc-replay__chapter-list{display:grid;grid-template-columns:none;grid-auto-flow:column;grid-auto-columns:minmax(150px,1fr);
29
- overflow-x:auto;scroll-snap-type:x proximity;gap:8px;padding-bottom:2px}
30
- .nc-replay__chapter{scroll-snap-align:start}
31
30
  .nc-replay__chapter button{gap:6px;padding:8px 10px;min-height:44px}}
32
31
  @media (min-width:1280px){.nc-replay{gap:12px;padding:12px 20px}}
33
32
  `;
@@ -8,6 +8,9 @@ const STAGE = `
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
9
  .nc-replay__slot{display:flex;justify-content:center;min-width:0;width:100%;background:var(--rp-bezel)}
10
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)}
11
14
  .nc-replay__frame{position:absolute;left:0;top:0;border:0;transform-origin:0 0;pointer-events:none;background:#fff}
12
15
  .nc-replay__layer{position:absolute;inset:0;overflow:hidden;pointer-events:none}
13
16
  .nc-replay__ring{position:absolute;left:0;top:0;opacity:0;border:2px solid var(--rp-accent);border-radius:8px;
@@ -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-accent);color:var(--rp-accent-ink);background:color-mix(in srgb,var(--rp-accent) 10%,var(--rp-surface))}
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
+ }
@@ -28,3 +28,23 @@ export interface FrameFit {
28
28
  * The result is letterboxed by the caller: it is never wider than the box and never taller than the room.
29
29
  */
30
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;
@@ -29,3 +29,31 @@
29
29
  height: frame.height * scale
30
30
  };
31
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
+ }
@@ -24,6 +24,14 @@ export interface RunDeps {
24
24
  * those seconds (the server's answer to that very click) would otherwise take the control away first.
25
25
  */
26
26
  hold?: () => () => void;
27
+ /**
28
+ * Called when an action cannot be done on the screen (its target never appeared, a choice is missing, the action threw).
29
+ * When given, the step carries on with its next action instead of stopping: a public tour keeps playing without that pointer.
30
+ */
31
+ onSkip?: (skipped: {
32
+ actionIndex: number;
33
+ reason: FailureReason;
34
+ }) => void;
27
35
  }
28
36
  export type RunResult = {
29
37
  ok: true;
@@ -32,5 +40,8 @@ export type RunResult = {
32
40
  actionIndex: number;
33
41
  reason: FailureReason;
34
42
  };
35
- /** Runs a step's actions in order, settling after each, and stops at the first failure with its index and reason. */
43
+ /**
44
+ * Runs a step's actions in order, settling after each. A failure stops the step with its index and reason, unless
45
+ * `deps.onSkip` is set and the reason is skippable: then it is reported there and the next action runs.
46
+ */
36
47
  export declare function runStep(step: ReplayStep, deps: RunDeps): Promise<RunResult>;
@@ -53,7 +53,16 @@ async function runAction(deps, action) {
53
53
  return runTargeted(deps, action);
54
54
  }
55
55
  }
56
- /** Runs a step's actions in order, settling after each, and stops at the first failure with its index and reason. */ export async function runStep(step, deps) {
56
+ /** Reasons that mean "this pointer action cannot be shown"; the tape itself is fine, so a step may go on without it. */ const SKIPPABLE = [
57
+ 'target_timeout',
58
+ 'target_unsupported',
59
+ 'option_not_found',
60
+ 'action_error'
61
+ ];
62
+ /**
63
+ * Runs a step's actions in order, settling after each. A failure stops the step with its index and reason, unless
64
+ * `deps.onSkip` is set and the reason is skippable: then it is reported there and the next action runs.
65
+ */ export async function runStep(step, deps) {
57
66
  for (const [actionIndex, action] of step.actions.entries()){
58
67
  let reason;
59
68
  try {
@@ -61,11 +70,18 @@ async function runAction(deps, action) {
61
70
  } catch {
62
71
  reason = 'action_error';
63
72
  }
64
- if (reason !== null) return {
65
- ok: false,
66
- actionIndex,
67
- reason
68
- };
73
+ if (reason !== null) {
74
+ if (deps.onSkip === undefined || !SKIPPABLE.includes(reason)) return {
75
+ ok: false,
76
+ actionIndex,
77
+ reason
78
+ };
79
+ deps.onSkip({
80
+ actionIndex,
81
+ reason
82
+ });
83
+ continue;
84
+ }
69
85
  await deps.settle();
70
86
  }
71
87
  return {
@@ -18,8 +18,8 @@ export interface Timeline {
18
18
  readonly clock: Clock;
19
19
  play(): void;
20
20
  pause(): void;
21
- /** Overrides the chapter rate for the rest of this timeline's life. */
22
- setRate(rate: number): void;
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 rate = chapters.find((chapter)=>chapter.from <= 0)?.rate ?? 1;
15
- let overridden = false;
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 && !overridden && chapter.rate !== rate) {
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
- rate = next;
122
- overridden = true;
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.255",
3
+ "version": "0.10.257",
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",