nucleus-core-ts 0.10.238 → 0.10.239

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 (64) hide show
  1. package/dist/.build-ok +1 -1
  2. package/dist/fe/components/Replay/_components/ReplayCaption/index.d.ts +3 -0
  3. package/dist/fe/components/Replay/_components/ReplayCaption/index.js +53 -0
  4. package/dist/fe/components/Replay/_components/ReplayCaption/types.d.ts +12 -0
  5. package/dist/fe/components/Replay/_components/ReplayCaption/types.js +1 -0
  6. package/dist/fe/components/Replay/_components/ReplayChapters/index.d.ts +3 -0
  7. package/dist/fe/components/Replay/_components/ReplayChapters/index.js +56 -0
  8. package/dist/fe/components/Replay/_components/ReplayChapters/types.d.ts +8 -0
  9. package/dist/fe/components/Replay/_components/ReplayChapters/types.js +1 -0
  10. package/dist/fe/components/Replay/_components/ReplayControls/index.d.ts +3 -0
  11. package/dist/fe/components/Replay/_components/ReplayControls/index.js +88 -0
  12. package/dist/fe/components/Replay/_components/ReplayControls/types.d.ts +15 -0
  13. package/dist/fe/components/Replay/_components/ReplayControls/types.js +1 -0
  14. package/dist/fe/components/Replay/_components/ReplayCursor/index.d.ts +6 -0
  15. package/dist/fe/components/Replay/_components/ReplayCursor/index.js +91 -0
  16. package/dist/fe/components/Replay/_components/ReplayCursor/types.d.ts +11 -0
  17. package/dist/fe/components/Replay/_components/ReplayCursor/types.js +1 -0
  18. package/dist/fe/components/Replay/_components/ReplayEnded/index.d.ts +9 -0
  19. package/dist/fe/components/Replay/_components/ReplayEnded/index.js +36 -0
  20. package/dist/fe/components/Replay/_components/ReplayFailure/index.d.ts +3 -0
  21. package/dist/fe/components/Replay/_components/ReplayFailure/index.js +32 -0
  22. package/dist/fe/components/Replay/_components/ReplayFailure/types.d.ts +6 -0
  23. package/dist/fe/components/Replay/_components/ReplayFailure/types.js +1 -0
  24. package/dist/fe/components/Replay/_components/ReplayPlayer/ReplayView.d.ts +10 -0
  25. package/dist/fe/components/Replay/_components/ReplayPlayer/ReplayView.js +100 -0
  26. package/dist/fe/components/Replay/_components/ReplayPlayer/index.d.ts +6 -0
  27. package/dist/fe/components/Replay/_components/ReplayPlayer/index.js +28 -0
  28. package/dist/fe/components/Replay/_components/ReplayPlayer/types.d.ts +9 -0
  29. package/dist/fe/components/Replay/_components/ReplayPlayer/types.js +1 -0
  30. package/dist/fe/components/Replay/_components/ReplaySkeleton/index.d.ts +4 -0
  31. package/dist/fe/components/Replay/_components/ReplaySkeleton/index.js +148 -0
  32. package/dist/fe/components/Replay/_components/ReplayStage/ReplayVeil.d.ts +2 -0
  33. package/dist/fe/components/Replay/_components/ReplayStage/ReplayVeil.js +34 -0
  34. package/dist/fe/components/Replay/_components/ReplayStage/index.d.ts +6 -0
  35. package/dist/fe/components/Replay/_components/ReplayStage/index.js +76 -0
  36. package/dist/fe/components/Replay/_components/ReplayStage/types.d.ts +18 -0
  37. package/dist/fe/components/Replay/_components/ReplayStage/types.js +1 -0
  38. package/dist/fe/components/Replay/_components/index.d.ts +11 -0
  39. package/dist/fe/components/Replay/_components/index.js +10 -0
  40. package/dist/fe/components/Replay/_hooks/index.d.ts +2 -0
  41. package/dist/fe/components/Replay/_hooks/index.js +2 -0
  42. package/dist/fe/components/Replay/_hooks/useShimmer.d.ts +3 -0
  43. package/dist/fe/components/Replay/_hooks/useShimmer.js +31 -0
  44. package/dist/fe/components/Replay/_hooks/useStageScale.d.ts +5 -0
  45. package/dist/fe/components/Replay/_hooks/useStageScale.js +24 -0
  46. package/dist/fe/components/Replay/_utils/copy.d.ts +29 -0
  47. package/dist/fe/components/Replay/_utils/copy.js +75 -0
  48. package/dist/fe/components/Replay/_utils/cursorMotion.d.ts +38 -0
  49. package/dist/fe/components/Replay/_utils/cursorMotion.js +98 -0
  50. package/dist/fe/components/Replay/_utils/index.d.ts +3 -0
  51. package/dist/fe/components/Replay/_utils/index.js +3 -0
  52. package/dist/fe/components/Replay/_utils/replayCss.d.ts +2 -0
  53. package/dist/fe/components/Replay/_utils/replayCss.js +4 -0
  54. package/dist/fe/components/Replay/_utils/replayLayout.d.ts +2 -0
  55. package/dist/fe/components/Replay/_utils/replayLayout.js +20 -0
  56. package/dist/fe/components/Replay/_utils/replayPalette.d.ts +1 -0
  57. package/dist/fe/components/Replay/_utils/replayPalette.js +8 -0
  58. package/dist/fe/components/Replay/_utils/replayParts.d.ts +1 -0
  59. package/dist/fe/components/Replay/_utils/replayParts.js +56 -0
  60. package/dist/fe/components/Replay/_utils/replayProgress.d.ts +14 -0
  61. package/dist/fe/components/Replay/_utils/replayProgress.js +39 -0
  62. package/dist/fe/components/Replay/index.d.ts +1 -0
  63. package/dist/fe/components/Replay/index.js +1 -0
  64. package/package.json +5 -1
package/dist/.build-ok CHANGED
@@ -1 +1 @@
1
- 0.10.238
1
+ 0.10.239
@@ -0,0 +1,3 @@
1
+ import type { ReplayCaptionProps } from './types';
2
+ /** The current step's caption, its chapter and its position; the player's live region, so a screen reader hears each step. */
3
+ export declare function ReplayCaption({ text, stepId, chapterTitle, position }: ReplayCaptionProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,53 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useGSAP } from '@gsap/react';
4
+ import gsap from 'gsap';
5
+ import { useEffectEvent, useRef } from 'react';
6
+ import { useReducedMotion } from '../../../DemoFilm/_hooks/useReducedMotion';
7
+ import { REPLAY_COPY } from '../../_utils/copy';
8
+ gsap.registerPlugin(useGSAP);
9
+ /** The current step's caption, its chapter and its position; the player's live region, so a screen reader hears each step. */ export function ReplayCaption({ text, stepId, chapterTitle, position }) {
10
+ const reduced = useReducedMotion();
11
+ const body = useRef(null);
12
+ const enter = useEffectEvent(()=>{
13
+ if (reduced || !body.current) return;
14
+ gsap.fromTo(body.current, {
15
+ opacity: 0,
16
+ y: 10
17
+ }, {
18
+ opacity: 1,
19
+ y: 0,
20
+ duration: 0.45,
21
+ ease: 'power3.out'
22
+ });
23
+ });
24
+ useGSAP(()=>enter(), {
25
+ dependencies: [
26
+ stepId,
27
+ text,
28
+ reduced
29
+ ]
30
+ });
31
+ return /*#__PURE__*/ _jsxs("section", {
32
+ className: "nc-replay__caption nc-replay__panel",
33
+ role: "status",
34
+ "aria-live": "polite",
35
+ "aria-atomic": "true",
36
+ "data-replay-caption": true,
37
+ children: [
38
+ /*#__PURE__*/ _jsx("p", {
39
+ className: "nc-replay__eyebrow",
40
+ children: position ? REPLAY_COPY.stepOf(position.index, position.count) : REPLAY_COPY.chapters
41
+ }),
42
+ /*#__PURE__*/ _jsx("p", {
43
+ ref: body,
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
50
+ })
51
+ ]
52
+ });
53
+ }
@@ -0,0 +1,12 @@
1
+ export interface ReplayCaptionProps {
2
+ /** The caption in the chosen language; empty before the first step. */
3
+ text: string;
4
+ /** Identifies the step so the caption animates when it changes. */
5
+ stepId: string | null;
6
+ chapterTitle: string;
7
+ /** 1-based position among the recording's steps; null before the first step. */
8
+ position: {
9
+ index: number;
10
+ count: number;
11
+ } | null;
12
+ }
@@ -0,0 +1,3 @@
1
+ import type { ReplayChaptersProps } from './types';
2
+ /** 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. */
3
+ export declare function ReplayChapters({ chapters, locale, chapterId, playhead, onSeek }: ReplayChaptersProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,56 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { REPLAY_COPY } from '../../_utils/copy';
4
+ import { pickLocalized } from '../../_utils/frameUrl';
5
+ import { chapterProgress, rateLabel } from '../../_utils/replayProgress';
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
+ return /*#__PURE__*/ _jsxs("nav", {
8
+ className: "nc-replay__chapters",
9
+ "aria-label": REPLAY_COPY.chapters,
10
+ "data-replay-chapters": true,
11
+ children: [
12
+ /*#__PURE__*/ _jsx("h2", {
13
+ className: "nc-replay__h",
14
+ children: REPLAY_COPY.chapters
15
+ }),
16
+ /*#__PURE__*/ _jsx("ol", {
17
+ className: "nc-replay__chapter-list",
18
+ children: chapters.map((chapter, i)=>{
19
+ const current = chapter.id === chapterId;
20
+ const progress = chapterProgress(chapter, playhead);
21
+ return /*#__PURE__*/ _jsx("li", {
22
+ className: "nc-replay__chapter",
23
+ "aria-current": current ? 'step' : undefined,
24
+ children: /*#__PURE__*/ _jsxs("button", {
25
+ type: "button",
26
+ onClick: ()=>onSeek(chapter.id),
27
+ children: [
28
+ /*#__PURE__*/ _jsxs("span", {
29
+ children: [
30
+ i + 1,
31
+ ". ",
32
+ pickLocalized(chapter.title, locale)
33
+ ]
34
+ }),
35
+ /*#__PURE__*/ _jsx("span", {
36
+ className: "nc-replay__meter",
37
+ role: "presentation",
38
+ children: /*#__PURE__*/ _jsx("span", {
39
+ className: "nc-replay__fill",
40
+ "data-replay-progress": progress.toFixed(3),
41
+ style: {
42
+ transform: `scaleX(${progress})`
43
+ }
44
+ })
45
+ }),
46
+ /*#__PURE__*/ _jsx("small", {
47
+ children: rateLabel(chapter.rate)
48
+ })
49
+ ]
50
+ })
51
+ }, chapter.id);
52
+ })
53
+ })
54
+ ]
55
+ });
56
+ }
@@ -0,0 +1,8 @@
1
+ import type { Ms, ReplayChapter } from '../../../../../src/Client/Replay';
2
+ export interface ReplayChaptersProps {
3
+ chapters: ReplayChapter[];
4
+ locale: string;
5
+ chapterId: string | null;
6
+ playhead: Ms;
7
+ onSeek: (chapterId: string) => void;
8
+ }
@@ -0,0 +1,3 @@
1
+ import type { ReplayControlsProps } from './types';
2
+ /** Play or pause, restart, speed, and the language switch (only when the recording has more than one language). */
3
+ export declare function ReplayControls(props: ReplayControlsProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,88 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { RATE_CHOICES, REPLAY_COPY } from '../../_utils/copy';
4
+ import { localeName, rateLabel } from '../../_utils/replayProgress';
5
+ const ICON = {
6
+ width: 18,
7
+ height: 18,
8
+ viewBox: '0 0 24 24',
9
+ fill: 'currentColor',
10
+ 'aria-hidden': true
11
+ };
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;
14
+ const playing = status === 'playing';
15
+ const idle = status === 'loading' || status === 'failed';
16
+ return /*#__PURE__*/ _jsxs("div", {
17
+ className: "nc-replay__controls",
18
+ role: "group",
19
+ "aria-label": "Playback",
20
+ "data-replay-controls": true,
21
+ children: [
22
+ /*#__PURE__*/ _jsxs("button", {
23
+ type: "button",
24
+ className: "nc-replay__btn",
25
+ "data-primary": "",
26
+ disabled: idle,
27
+ onClick: playing ? onPause : onPlay,
28
+ children: [
29
+ /*#__PURE__*/ _jsx("svg", {
30
+ ...ICON,
31
+ children: playing ? /*#__PURE__*/ _jsx("path", {
32
+ d: "M6 5h4v14H6zM14 5h4v14h-4z"
33
+ }) : /*#__PURE__*/ _jsx("path", {
34
+ d: "M7 4.5v15l12-7.5z"
35
+ })
36
+ }),
37
+ playing ? REPLAY_COPY.pause : REPLAY_COPY.play
38
+ ]
39
+ }),
40
+ /*#__PURE__*/ _jsxs("button", {
41
+ type: "button",
42
+ className: "nc-replay__btn",
43
+ disabled: idle,
44
+ onClick: onRestart,
45
+ children: [
46
+ /*#__PURE__*/ _jsx("svg", {
47
+ ...ICON,
48
+ children: /*#__PURE__*/ _jsx("path", {
49
+ d: "M12 5a7 7 0 1 1-6.7 9h2.1A5 5 0 1 0 12 7v3L7 6l5-4z"
50
+ })
51
+ }),
52
+ REPLAY_COPY.restart
53
+ ]
54
+ }),
55
+ /*#__PURE__*/ _jsx("span", {
56
+ className: "nc-replay__seg",
57
+ role: "group",
58
+ "aria-label": REPLAY_COPY.speed,
59
+ children: RATE_CHOICES.map((choice)=>/*#__PURE__*/ _jsx("button", {
60
+ type: "button",
61
+ className: "nc-replay__btn",
62
+ "aria-pressed": rate === choice,
63
+ disabled: idle,
64
+ onClick: ()=>onRate(choice),
65
+ children: rateLabel(choice)
66
+ }, choice))
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
+ locales.length > 1 && /*#__PURE__*/ _jsx("span", {
74
+ className: "nc-replay__seg",
75
+ role: "group",
76
+ "aria-label": REPLAY_COPY.language,
77
+ children: locales.map((code)=>/*#__PURE__*/ _jsx("button", {
78
+ type: "button",
79
+ className: "nc-replay__btn",
80
+ "aria-pressed": locale === code,
81
+ "aria-label": localeName(code),
82
+ onClick: ()=>onLocale(code),
83
+ children: code.toUpperCase()
84
+ }, code))
85
+ })
86
+ ]
87
+ });
88
+ }
@@ -0,0 +1,15 @@
1
+ import type { ReplayStatus } from '../../_types';
2
+ export interface ReplayControlsProps {
3
+ status: ReplayStatus;
4
+ rate: number;
5
+ /** The current chapter's own rate; shown as a badge. */
6
+ chapterRate: number | null;
7
+ /** Languages the recording has; the switch shows only when there is more than one. */
8
+ locales: string[];
9
+ locale: string;
10
+ onPlay: () => void;
11
+ onPause: () => void;
12
+ onRate: (rate: number) => void;
13
+ onLocale: (locale: string) => void;
14
+ onRestart: () => void;
15
+ }
@@ -0,0 +1,6 @@
1
+ import type { ReplayCursorLayerProps } from './types';
2
+ /**
3
+ * The drawn pointer, its highlight ring and the click ripple, in the stage's scaled pixels. It glides to the box the
4
+ * frame reported for the current pointer action and only then tells the player it arrived (the frame waits for that).
5
+ */
6
+ export declare function ReplayCursorLayer({ cursor, scale, rate, onArrive }: ReplayCursorLayerProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,91 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useGSAP } from '@gsap/react';
4
+ import gsap from 'gsap';
5
+ import { useEffectEvent, useRef } from 'react';
6
+ import { useReducedMotion } from '../../../DemoFilm/_hooks/useReducedMotion';
7
+ import { moveCursor, targetIn } from '../../_utils/cursorMotion';
8
+ gsap.registerPlugin(useGSAP);
9
+ /**
10
+ * The drawn pointer, its highlight ring and the click ripple, in the stage's scaled pixels. It glides to the box the
11
+ * frame reported for the current pointer action and only then tells the player it arrived (the frame waits for that).
12
+ */ export function ReplayCursorLayer({ cursor, scale, rate, onArrive }) {
13
+ const reduced = useReducedMotion();
14
+ const root = useRef(null);
15
+ const last = useRef(null);
16
+ const place = useEffectEvent(()=>{
17
+ const cursorEl = root.current?.querySelector('[data-replay-cursor]');
18
+ const ring = root.current?.querySelector('[data-replay-ring]');
19
+ const ripple = root.current?.querySelector('[data-replay-ripple]');
20
+ if (!cursorEl || !ring || !ripple) return;
21
+ if (!cursor) {
22
+ last.current = null;
23
+ gsap.to([
24
+ cursorEl,
25
+ ring
26
+ ], {
27
+ opacity: 0,
28
+ duration: 0.2,
29
+ overwrite: 'auto'
30
+ });
31
+ return;
32
+ }
33
+ const target = targetIn(cursor.box, scale);
34
+ const els = {
35
+ cursor: cursorEl,
36
+ ring,
37
+ ripple
38
+ };
39
+ const settled = cursor.arrived;
40
+ moveCursor(els, {
41
+ target,
42
+ from: last.current,
43
+ rate,
44
+ reduced: reduced || settled,
45
+ onArrive: ()=>{
46
+ if (!settled) onArrive(cursor.mark);
47
+ }
48
+ });
49
+ last.current = {
50
+ x: target.x,
51
+ y: target.y
52
+ };
53
+ });
54
+ useGSAP(()=>place(), {
55
+ scope: root,
56
+ dependencies: [
57
+ cursor?.stepId ?? null,
58
+ cursor?.mark ?? null,
59
+ scale,
60
+ reduced
61
+ ]
62
+ });
63
+ return /*#__PURE__*/ _jsxs("div", {
64
+ ref: root,
65
+ className: "nc-replay__layer",
66
+ "aria-hidden": "true",
67
+ children: [
68
+ /*#__PURE__*/ _jsx("span", {
69
+ "data-replay-ring": true,
70
+ className: "nc-replay__ring"
71
+ }),
72
+ /*#__PURE__*/ _jsx("span", {
73
+ "data-replay-ripple": true,
74
+ className: "nc-replay__ripple"
75
+ }),
76
+ /*#__PURE__*/ _jsx("svg", {
77
+ "data-replay-cursor": true,
78
+ className: "nc-replay__cursor",
79
+ viewBox: "0 0 24 24",
80
+ fill: "none",
81
+ children: /*#__PURE__*/ _jsx("path", {
82
+ d: "M3 2.5v17l4.6-4.2 3 6.7 3.1-1.4-3-6.6 6.3-.2L3 2.5Z",
83
+ fill: "var(--rp-accent)",
84
+ stroke: "var(--rp-surface)",
85
+ strokeWidth: "1.6",
86
+ strokeLinejoin: "round"
87
+ })
88
+ })
89
+ ]
90
+ });
91
+ }
@@ -0,0 +1,11 @@
1
+ import type { ReplayCursor } from '../../_types';
2
+ export interface ReplayCursorLayerProps {
3
+ /** What the frame reported for the current pointer action; null clears the cursor. */
4
+ cursor: ReplayCursor | null;
5
+ /** Stage scale: frame pixels to drawn pixels. */
6
+ scale: number;
7
+ /** The current playback rate; a faster rate glides faster. */
8
+ rate: number;
9
+ /** The drawn cursor reached the box of this mark. */
10
+ onArrive: (mark: number) => void;
11
+ }
@@ -0,0 +1,9 @@
1
+ interface ReplayEndedProps {
2
+ onWatchAgain: () => void;
3
+ /** Offered only when the host gave the player somewhere to go next. */
4
+ onContinue?: () => void;
5
+ continueLabel?: string;
6
+ }
7
+ /** The end of the tour: watch it again, or carry on. */
8
+ export declare function ReplayEnded({ onWatchAgain, onContinue, continueLabel }: ReplayEndedProps): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,36 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { REPLAY_COPY } from '../../_utils/copy';
4
+ /** The end of the tour: watch it again, or carry on. */ export function ReplayEnded({ onWatchAgain, onContinue, continueLabel }) {
5
+ return /*#__PURE__*/ _jsxs("div", {
6
+ className: "nc-replay__card",
7
+ role: "status",
8
+ "data-replay-ended": true,
9
+ children: [
10
+ /*#__PURE__*/ _jsx("h3", {
11
+ children: REPLAY_COPY.endedTitle
12
+ }),
13
+ /*#__PURE__*/ _jsx("p", {
14
+ children: REPLAY_COPY.endedBody
15
+ }),
16
+ /*#__PURE__*/ _jsxs("div", {
17
+ className: "nc-replay__card-actions",
18
+ children: [
19
+ onContinue && /*#__PURE__*/ _jsx("button", {
20
+ type: "button",
21
+ className: "nc-replay__btn",
22
+ "data-primary": "",
23
+ onClick: onContinue,
24
+ children: continueLabel ?? REPLAY_COPY.continue
25
+ }),
26
+ /*#__PURE__*/ _jsx("button", {
27
+ type: "button",
28
+ className: "nc-replay__btn",
29
+ onClick: onWatchAgain,
30
+ children: REPLAY_COPY.watchAgain
31
+ })
32
+ ]
33
+ })
34
+ ]
35
+ });
36
+ }
@@ -0,0 +1,3 @@
1
+ import type { ReplayFailureCardProps } from './types';
2
+ /** A failure said in three parts: what is not working, what it means for the visitor, what has to happen and by whom. */
3
+ export declare function ReplayFailureCard({ reason, onRetry }: ReplayFailureCardProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,32 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { REPLAY_COPY, failureCopy } from '../../_utils/copy';
4
+ /** A failure said in three parts: what is not working, what it means for the visitor, what has to happen and by whom. */ export function ReplayFailureCard({ reason, onRetry }) {
5
+ const copy = failureCopy(reason);
6
+ return /*#__PURE__*/ _jsxs("div", {
7
+ className: "nc-replay__card",
8
+ role: "alert",
9
+ "data-replay-failure": reason,
10
+ children: [
11
+ /*#__PURE__*/ _jsx("h3", {
12
+ children: copy.what
13
+ }),
14
+ /*#__PURE__*/ _jsx("p", {
15
+ children: copy.means
16
+ }),
17
+ /*#__PURE__*/ _jsx("p", {
18
+ children: copy.next
19
+ }),
20
+ onRetry && /*#__PURE__*/ _jsx("div", {
21
+ className: "nc-replay__card-actions",
22
+ children: /*#__PURE__*/ _jsx("button", {
23
+ type: "button",
24
+ className: "nc-replay__btn",
25
+ "data-primary": "",
26
+ onClick: onRetry,
27
+ children: REPLAY_COPY.retry
28
+ })
29
+ })
30
+ ]
31
+ });
32
+ }
@@ -0,0 +1,6 @@
1
+ import type { ReplayFailureReason } from '../../_types';
2
+ export interface ReplayFailureCardProps {
3
+ reason: ReplayFailureReason;
4
+ /** Offered when trying again can help. */
5
+ onRetry?: () => void;
6
+ }
@@ -0,0 +1,10 @@
1
+ import type { ReplayPlayer } from '../../_types';
2
+ import type { ReplayPlayerProps } from './types';
3
+ interface ReplayViewProps extends Pick<ReplayPlayerProps, 'theme' | 'onContinue' | 'continueLabel' | 'className'> {
4
+ player: ReplayPlayer;
5
+ /** Start over with a fresh manifest request (a failure before the manifest loaded). */
6
+ onReload: () => void;
7
+ }
8
+ /** The player's screen for one state of a `ReplayPlayer`: skeleton, stage with captions and controls, failure, end. */
9
+ export declare function ReplayView({ player, theme, onContinue, continueLabel, className, onReload }: ReplayViewProps): import("react/jsx-runtime").JSX.Element;
10
+ export {};
@@ -0,0 +1,100 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { REPLAY_CSS } from '../../_utils/replayCss';
4
+ import { manifestLocales, stepPosition } from '../../_utils/replayProgress';
5
+ import { pickLocalized } from '../../_utils/frameUrl';
6
+ import { ReplayCaption } from '../ReplayCaption';
7
+ import { ReplayChapters } from '../ReplayChapters';
8
+ import { ReplayControls } from '../ReplayControls';
9
+ import { ReplayEnded } from '../ReplayEnded';
10
+ import { ReplayFailureCard } from '../ReplayFailure';
11
+ import { ReplaySkeleton } from '../ReplaySkeleton';
12
+ import { ReplayStage } from '../ReplayStage';
13
+ /** The player's screen for one state of a `ReplayPlayer`: skeleton, stage with captions and controls, failure, end. */ export function ReplayView({ player, theme, onContinue, continueLabel, className, onReload }) {
14
+ const { state } = player;
15
+ const { manifest, status, failure, locale } = state;
16
+ if (manifest === null) {
17
+ if (failure === null) return /*#__PURE__*/ _jsx(ReplaySkeleton, {});
18
+ return /*#__PURE__*/ _jsxs("div", {
19
+ className: "nc-replay",
20
+ "data-theme": theme,
21
+ children: [
22
+ /*#__PURE__*/ _jsx("style", {
23
+ children: REPLAY_CSS
24
+ }),
25
+ /*#__PURE__*/ _jsx("div", {
26
+ style: {
27
+ gridColumn: '1 / -1',
28
+ display: 'grid',
29
+ placeItems: 'center',
30
+ padding: 16
31
+ },
32
+ children: /*#__PURE__*/ _jsx(ReplayFailureCard, {
33
+ reason: failure.reason,
34
+ onRetry: failure.reason === 'manifest_invalid' ? undefined : onReload
35
+ })
36
+ })
37
+ ]
38
+ });
39
+ }
40
+ const chapter = manifest.chapters.find((c)=>c.id === state.chapterId) ?? null;
41
+ const first = manifest.chapters[0];
42
+ const overlay = status === 'failed' && failure ? /*#__PURE__*/ _jsx(ReplayFailureCard, {
43
+ reason: failure.reason,
44
+ onRetry: player.play
45
+ }) : status === 'ended' ? /*#__PURE__*/ _jsx(ReplayEnded, {
46
+ onWatchAgain: restart,
47
+ onContinue: onContinue,
48
+ continueLabel: continueLabel
49
+ }) : null;
50
+ function restart() {
51
+ if (first) player.seekChapter(first.id);
52
+ player.play();
53
+ }
54
+ return /*#__PURE__*/ _jsxs("div", {
55
+ className: `nc-replay${className ? ` ${className}` : ''}`,
56
+ "data-theme": theme,
57
+ "data-replay-status": status,
58
+ children: [
59
+ /*#__PURE__*/ _jsx("style", {
60
+ children: REPLAY_CSS
61
+ }),
62
+ /*#__PURE__*/ _jsx(ReplayStage, {
63
+ manifest: manifest,
64
+ locale: locale,
65
+ frameSrc: player.frameSrc,
66
+ frameRef: player.frameRef,
67
+ cursor: state.cursor,
68
+ rate: state.rate,
69
+ onArrive: player.cursorArrived,
70
+ loading: status === 'loading',
71
+ children: overlay
72
+ }),
73
+ /*#__PURE__*/ _jsx(ReplayCaption, {
74
+ text: pickLocalized(state.caption, locale),
75
+ stepId: state.stepId,
76
+ chapterTitle: chapter ? pickLocalized(chapter.title, locale) : '',
77
+ position: stepPosition(manifest, state.stepId)
78
+ }),
79
+ /*#__PURE__*/ _jsx(ReplayControls, {
80
+ status: status,
81
+ rate: state.rate,
82
+ chapterRate: chapter?.rate ?? null,
83
+ locales: manifestLocales(manifest),
84
+ locale: locale,
85
+ onPlay: player.play,
86
+ onPause: player.pause,
87
+ onRate: player.setRate,
88
+ onLocale: player.setLocale,
89
+ onRestart: restart
90
+ }),
91
+ /*#__PURE__*/ _jsx(ReplayChapters, {
92
+ chapters: manifest.chapters,
93
+ locale: locale,
94
+ chapterId: state.chapterId,
95
+ playhead: state.playhead,
96
+ onSeek: player.seekChapter
97
+ })
98
+ ]
99
+ });
100
+ }
@@ -0,0 +1,6 @@
1
+ import type { ReplayPlayerProps } from './types';
2
+ /**
3
+ * The whole replay player for one recording: loads it, shows a skeleton while it does, then the product with a drawn
4
+ * cursor, captions, controls and chapters. A failure before the recording loads offers a fresh start.
5
+ */
6
+ export declare function ReplayPlayerWidget(props: ReplayPlayerProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,28 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useState } from 'react';
4
+ import { useReplayPlayer } from '../../_hooks/useReplayPlayer';
5
+ import { ReplayView } from './ReplayView';
6
+ function ReplayRun(props) {
7
+ const { manifestUrl, locale, autoplay, onReload, ...view } = props;
8
+ const player = useReplayPlayer({
9
+ manifestUrl,
10
+ locale,
11
+ autoplay
12
+ });
13
+ return /*#__PURE__*/ _jsx(ReplayView, {
14
+ player: player,
15
+ onReload: onReload,
16
+ ...view
17
+ });
18
+ }
19
+ /**
20
+ * The whole replay player for one recording: loads it, shows a skeleton while it does, then the product with a drawn
21
+ * cursor, captions, controls and chapters. A failure before the recording loads offers a fresh start.
22
+ */ export function ReplayPlayerWidget(props) {
23
+ const [attempt, setAttempt] = useState(0);
24
+ return /*#__PURE__*/ _jsx(ReplayRun, {
25
+ ...props,
26
+ onReload: ()=>setAttempt((n)=>n + 1)
27
+ }, attempt);
28
+ }
@@ -0,0 +1,9 @@
1
+ import type { ReplayPlayerOptions } from '../../_types';
2
+ export interface ReplayPlayerProps extends ReplayPlayerOptions {
3
+ /** Force a theme; without it the player follows a `.dark` class on an ancestor. */
4
+ theme?: 'light' | 'dark';
5
+ /** Shown beside "Watch again" at the end; omit it and the choice is just to watch again. */
6
+ onContinue?: () => void;
7
+ continueLabel?: string;
8
+ className?: string;
9
+ }
@@ -0,0 +1,4 @@
1
+ /** The player's loading state: the same grid as the loaded player (stage, caption, controls, chapters), breathing. */
2
+ export declare function ReplaySkeleton({ aspect }: {
3
+ aspect?: string;
4
+ }): import("react/jsx-runtime").JSX.Element;