nucleus-core-ts 0.10.237 → 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.
- package/dist/.build-ok +1 -1
- package/dist/fe/components/Replay/_components/ReplayCaption/index.d.ts +3 -0
- package/dist/fe/components/Replay/_components/ReplayCaption/index.js +53 -0
- package/dist/fe/components/Replay/_components/ReplayCaption/types.d.ts +12 -0
- package/dist/fe/components/Replay/_components/ReplayCaption/types.js +1 -0
- package/dist/fe/components/Replay/_components/ReplayChapters/index.d.ts +3 -0
- package/dist/fe/components/Replay/_components/ReplayChapters/index.js +56 -0
- package/dist/fe/components/Replay/_components/ReplayChapters/types.d.ts +8 -0
- package/dist/fe/components/Replay/_components/ReplayChapters/types.js +1 -0
- package/dist/fe/components/Replay/_components/ReplayControls/index.d.ts +3 -0
- package/dist/fe/components/Replay/_components/ReplayControls/index.js +88 -0
- package/dist/fe/components/Replay/_components/ReplayControls/types.d.ts +15 -0
- package/dist/fe/components/Replay/_components/ReplayControls/types.js +1 -0
- package/dist/fe/components/Replay/_components/ReplayCursor/index.d.ts +6 -0
- package/dist/fe/components/Replay/_components/ReplayCursor/index.js +91 -0
- package/dist/fe/components/Replay/_components/ReplayCursor/types.d.ts +11 -0
- package/dist/fe/components/Replay/_components/ReplayCursor/types.js +1 -0
- package/dist/fe/components/Replay/_components/ReplayEnded/index.d.ts +9 -0
- package/dist/fe/components/Replay/_components/ReplayEnded/index.js +36 -0
- package/dist/fe/components/Replay/_components/ReplayFailure/index.d.ts +3 -0
- package/dist/fe/components/Replay/_components/ReplayFailure/index.js +32 -0
- package/dist/fe/components/Replay/_components/ReplayFailure/types.d.ts +6 -0
- package/dist/fe/components/Replay/_components/ReplayFailure/types.js +1 -0
- package/dist/fe/components/Replay/_components/ReplayPlayer/ReplayView.d.ts +10 -0
- package/dist/fe/components/Replay/_components/ReplayPlayer/ReplayView.js +100 -0
- package/dist/fe/components/Replay/_components/ReplayPlayer/index.d.ts +6 -0
- package/dist/fe/components/Replay/_components/ReplayPlayer/index.js +28 -0
- package/dist/fe/components/Replay/_components/ReplayPlayer/types.d.ts +9 -0
- package/dist/fe/components/Replay/_components/ReplayPlayer/types.js +1 -0
- package/dist/fe/components/Replay/_components/ReplaySkeleton/index.d.ts +4 -0
- package/dist/fe/components/Replay/_components/ReplaySkeleton/index.js +148 -0
- package/dist/fe/components/Replay/_components/ReplayStage/ReplayVeil.d.ts +2 -0
- package/dist/fe/components/Replay/_components/ReplayStage/ReplayVeil.js +34 -0
- package/dist/fe/components/Replay/_components/ReplayStage/index.d.ts +6 -0
- package/dist/fe/components/Replay/_components/ReplayStage/index.js +76 -0
- package/dist/fe/components/Replay/_components/ReplayStage/types.d.ts +18 -0
- package/dist/fe/components/Replay/_components/ReplayStage/types.js +1 -0
- package/dist/fe/components/Replay/_components/index.d.ts +11 -0
- package/dist/fe/components/Replay/_components/index.js +10 -0
- package/dist/fe/components/Replay/_hooks/index.d.ts +3 -0
- package/dist/fe/components/Replay/_hooks/index.js +3 -0
- package/dist/fe/components/Replay/_hooks/useReplayPlayer.d.ts +6 -0
- package/dist/fe/components/Replay/_hooks/useReplayPlayer.js +63 -0
- package/dist/fe/components/Replay/_hooks/useShimmer.d.ts +3 -0
- package/dist/fe/components/Replay/_hooks/useShimmer.js +31 -0
- package/dist/fe/components/Replay/_hooks/useStageScale.d.ts +5 -0
- package/dist/fe/components/Replay/_hooks/useStageScale.js +24 -0
- package/dist/fe/components/Replay/_store/index.d.ts +1 -0
- package/dist/fe/components/Replay/_store/index.js +1 -0
- package/dist/fe/components/Replay/_store/replayStore.d.ts +13 -0
- package/dist/fe/components/Replay/_store/replayStore.js +74 -0
- package/dist/fe/components/Replay/_types/index.d.ts +1 -0
- package/dist/fe/components/Replay/_types/index.js +1 -0
- package/dist/fe/components/Replay/_types/player.d.ts +105 -0
- package/dist/fe/components/Replay/_types/player.js +1 -0
- package/dist/fe/components/Replay/_utils/controller.d.ts +10 -0
- package/dist/fe/components/Replay/_utils/controller.js +208 -0
- package/dist/fe/components/Replay/_utils/controllerReports.d.ts +18 -0
- package/dist/fe/components/Replay/_utils/controllerReports.js +70 -0
- package/dist/fe/components/Replay/_utils/copy.d.ts +29 -0
- package/dist/fe/components/Replay/_utils/copy.js +75 -0
- package/dist/fe/components/Replay/_utils/cursorMotion.d.ts +38 -0
- package/dist/fe/components/Replay/_utils/cursorMotion.js +98 -0
- package/dist/fe/components/Replay/_utils/frameBridge.d.ts +40 -0
- package/dist/fe/components/Replay/_utils/frameBridge.js +167 -0
- package/dist/fe/components/Replay/_utils/framePoints.d.ts +17 -0
- package/dist/fe/components/Replay/_utils/framePoints.js +24 -0
- package/dist/fe/components/Replay/_utils/frameUrl.d.ts +21 -0
- package/dist/fe/components/Replay/_utils/frameUrl.js +23 -0
- package/dist/fe/components/Replay/_utils/index.d.ts +7 -0
- package/dist/fe/components/Replay/_utils/index.js +7 -0
- package/dist/fe/components/Replay/_utils/replayCss.d.ts +2 -0
- package/dist/fe/components/Replay/_utils/replayCss.js +4 -0
- package/dist/fe/components/Replay/_utils/replayLayout.d.ts +2 -0
- package/dist/fe/components/Replay/_utils/replayLayout.js +20 -0
- package/dist/fe/components/Replay/_utils/replayPalette.d.ts +1 -0
- package/dist/fe/components/Replay/_utils/replayPalette.js +8 -0
- package/dist/fe/components/Replay/_utils/replayParts.d.ts +1 -0
- package/dist/fe/components/Replay/_utils/replayParts.js +56 -0
- package/dist/fe/components/Replay/_utils/replayProgress.d.ts +14 -0
- package/dist/fe/components/Replay/_utils/replayProgress.js +39 -0
- package/dist/fe/components/Replay/index.d.ts +5 -0
- package/dist/fe/components/Replay/index.js +5 -0
- package/dist/src/Client/Replay/index.d.ts +1 -0
- package/dist/src/Client/Replay/index.js +1 -0
- package/dist/src/Client/Replay/recorder/anchors.d.ts +18 -0
- package/dist/src/Client/Replay/recorder/anchors.js +39 -0
- package/dist/src/Client/Replay/recorder/bundle.d.ts +60 -0
- package/dist/src/Client/Replay/recorder/bundle.js +103 -0
- package/dist/src/Client/Replay/recorder/clock.d.ts +13 -0
- package/dist/src/Client/Replay/recorder/clock.js +9 -0
- package/dist/src/Client/Replay/recorder/factoryTap.d.ts +22 -0
- package/dist/src/Client/Replay/recorder/factoryTap.js +24 -0
- package/dist/src/Client/Replay/recorder/fetchTee.d.ts +37 -0
- package/dist/src/Client/Replay/recorder/fetchTee.js +121 -0
- package/dist/src/Client/Replay/recorder/index.d.ts +9 -0
- package/dist/src/Client/Replay/recorder/index.js +9 -0
- package/dist/src/Client/Replay/recorder/privacy.d.ts +27 -0
- package/dist/src/Client/Replay/recorder/privacy.js +115 -0
- package/dist/src/Client/Replay/recorder/redact.d.ts +8 -0
- package/dist/src/Client/Replay/recorder/redact.js +100 -0
- package/dist/src/Client/Replay/recorder/socketTap.d.ts +21 -0
- package/dist/src/Client/Replay/recorder/socketTap.js +43 -0
- package/dist/src/Client/Replay/recorder/sse.d.ts +15 -0
- package/dist/src/Client/Replay/recorder/sse.js +56 -0
- package/dist/src/Client/Replay/recorder/steps.d.ts +27 -0
- package/dist/src/Client/Replay/recorder/steps.js +152 -0
- package/package.json +5 -1
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useRef } from 'react';
|
|
4
|
+
import { useShimmer } from '../../_hooks/useShimmer';
|
|
5
|
+
import { REPLAY_CSS } from '../../_utils/replayCss';
|
|
6
|
+
function Bar({ w, h }) {
|
|
7
|
+
return /*#__PURE__*/ _jsx("span", {
|
|
8
|
+
"data-shimmer": true,
|
|
9
|
+
className: "nc-replay__skel",
|
|
10
|
+
style: {
|
|
11
|
+
display: 'block',
|
|
12
|
+
width: w,
|
|
13
|
+
height: h
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
/** The player's loading state: the same grid as the loaded player (stage, caption, controls, chapters), breathing. */ export function ReplaySkeleton({ aspect = '16 / 10' }) {
|
|
18
|
+
const root = useRef(null);
|
|
19
|
+
useShimmer(root);
|
|
20
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
21
|
+
ref: root,
|
|
22
|
+
className: "nc-replay",
|
|
23
|
+
role: "status",
|
|
24
|
+
"aria-busy": "true",
|
|
25
|
+
"aria-label": "Loading the recording",
|
|
26
|
+
children: [
|
|
27
|
+
/*#__PURE__*/ _jsx("style", {
|
|
28
|
+
children: REPLAY_CSS
|
|
29
|
+
}),
|
|
30
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
31
|
+
className: "nc-replay__stage",
|
|
32
|
+
children: [
|
|
33
|
+
/*#__PURE__*/ _jsx("div", {
|
|
34
|
+
className: "nc-replay__bar",
|
|
35
|
+
"aria-hidden": "true",
|
|
36
|
+
children: /*#__PURE__*/ _jsxs("span", {
|
|
37
|
+
className: "nc-replay__dots",
|
|
38
|
+
children: [
|
|
39
|
+
/*#__PURE__*/ _jsx("i", {}),
|
|
40
|
+
/*#__PURE__*/ _jsx("i", {}),
|
|
41
|
+
/*#__PURE__*/ _jsx("i", {})
|
|
42
|
+
]
|
|
43
|
+
})
|
|
44
|
+
}),
|
|
45
|
+
/*#__PURE__*/ _jsx("div", {
|
|
46
|
+
className: "nc-replay__view",
|
|
47
|
+
style: {
|
|
48
|
+
aspectRatio: aspect
|
|
49
|
+
},
|
|
50
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
51
|
+
className: "nc-replay__veil",
|
|
52
|
+
children: [
|
|
53
|
+
/*#__PURE__*/ _jsx(Bar, {
|
|
54
|
+
w: "55%",
|
|
55
|
+
h: 14
|
|
56
|
+
}),
|
|
57
|
+
/*#__PURE__*/ _jsx(Bar, {
|
|
58
|
+
w: "35%",
|
|
59
|
+
h: 14
|
|
60
|
+
})
|
|
61
|
+
]
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
]
|
|
65
|
+
}),
|
|
66
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
67
|
+
className: "nc-replay__caption nc-replay__panel",
|
|
68
|
+
children: [
|
|
69
|
+
/*#__PURE__*/ _jsx(Bar, {
|
|
70
|
+
w: "30%",
|
|
71
|
+
h: 10
|
|
72
|
+
}),
|
|
73
|
+
/*#__PURE__*/ _jsx("div", {
|
|
74
|
+
style: {
|
|
75
|
+
height: 10
|
|
76
|
+
}
|
|
77
|
+
}),
|
|
78
|
+
/*#__PURE__*/ _jsx(Bar, {
|
|
79
|
+
w: "90%",
|
|
80
|
+
h: 18
|
|
81
|
+
}),
|
|
82
|
+
/*#__PURE__*/ _jsx("div", {
|
|
83
|
+
style: {
|
|
84
|
+
height: 6
|
|
85
|
+
}
|
|
86
|
+
}),
|
|
87
|
+
/*#__PURE__*/ _jsx(Bar, {
|
|
88
|
+
w: "60%",
|
|
89
|
+
h: 18
|
|
90
|
+
})
|
|
91
|
+
]
|
|
92
|
+
}),
|
|
93
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
94
|
+
className: "nc-replay__controls",
|
|
95
|
+
children: [
|
|
96
|
+
/*#__PURE__*/ _jsx(Bar, {
|
|
97
|
+
w: "96px",
|
|
98
|
+
h: 44
|
|
99
|
+
}),
|
|
100
|
+
/*#__PURE__*/ _jsx(Bar, {
|
|
101
|
+
w: "112px",
|
|
102
|
+
h: 44
|
|
103
|
+
}),
|
|
104
|
+
/*#__PURE__*/ _jsx(Bar, {
|
|
105
|
+
w: "144px",
|
|
106
|
+
h: 44
|
|
107
|
+
})
|
|
108
|
+
]
|
|
109
|
+
}),
|
|
110
|
+
/*#__PURE__*/ _jsx("div", {
|
|
111
|
+
className: "nc-replay__chapters",
|
|
112
|
+
children: /*#__PURE__*/ _jsx("ul", {
|
|
113
|
+
className: "nc-replay__chapter-list",
|
|
114
|
+
style: {
|
|
115
|
+
padding: 0,
|
|
116
|
+
margin: 0,
|
|
117
|
+
listStyle: 'none'
|
|
118
|
+
},
|
|
119
|
+
children: [
|
|
120
|
+
0,
|
|
121
|
+
1,
|
|
122
|
+
2
|
|
123
|
+
].map((i)=>/*#__PURE__*/ _jsxs("li", {
|
|
124
|
+
className: "nc-replay__chapter",
|
|
125
|
+
style: {
|
|
126
|
+
padding: 12
|
|
127
|
+
},
|
|
128
|
+
children: [
|
|
129
|
+
/*#__PURE__*/ _jsx(Bar, {
|
|
130
|
+
w: "70%",
|
|
131
|
+
h: 14
|
|
132
|
+
}),
|
|
133
|
+
/*#__PURE__*/ _jsx("div", {
|
|
134
|
+
style: {
|
|
135
|
+
height: 8
|
|
136
|
+
}
|
|
137
|
+
}),
|
|
138
|
+
/*#__PURE__*/ _jsx(Bar, {
|
|
139
|
+
w: "100%",
|
|
140
|
+
h: 4
|
|
141
|
+
})
|
|
142
|
+
]
|
|
143
|
+
}, i))
|
|
144
|
+
})
|
|
145
|
+
})
|
|
146
|
+
]
|
|
147
|
+
});
|
|
148
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useRef } from 'react';
|
|
4
|
+
import { useShimmer } from '../../_hooks/useShimmer';
|
|
5
|
+
import { REPLAY_COPY } from '../../_utils/copy';
|
|
6
|
+
/** Covers the frame until the product has reported it is ready. */ export function ReplayVeil() {
|
|
7
|
+
const veil = useRef(null);
|
|
8
|
+
useShimmer(veil);
|
|
9
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
10
|
+
ref: veil,
|
|
11
|
+
className: "nc-replay__veil",
|
|
12
|
+
role: "status",
|
|
13
|
+
"data-replay-veil": true,
|
|
14
|
+
children: [
|
|
15
|
+
/*#__PURE__*/ _jsx("span", {
|
|
16
|
+
"data-shimmer": true,
|
|
17
|
+
className: "nc-replay__skel",
|
|
18
|
+
style: {
|
|
19
|
+
width: '60%',
|
|
20
|
+
height: 14
|
|
21
|
+
}
|
|
22
|
+
}),
|
|
23
|
+
/*#__PURE__*/ _jsx("span", {
|
|
24
|
+
"data-shimmer": true,
|
|
25
|
+
className: "nc-replay__skel",
|
|
26
|
+
style: {
|
|
27
|
+
width: '40%',
|
|
28
|
+
height: 14
|
|
29
|
+
}
|
|
30
|
+
}),
|
|
31
|
+
REPLAY_COPY.loadingFrame
|
|
32
|
+
]
|
|
33
|
+
});
|
|
34
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ReplayStageProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* The product in a same-origin iframe at the recording's viewport size, scaled down to fit the box it sits in. The
|
|
4
|
+
* frame takes no pointer events: the visitor watches, the cursor and highlight layers above it show what happens.
|
|
5
|
+
*/
|
|
6
|
+
export declare function ReplayStage(props: ReplayStageProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useStageScale } from '../../_hooks/useStageScale';
|
|
4
|
+
import { REPLAY_COPY } from '../../_utils/copy';
|
|
5
|
+
import { pickLocalized } from '../../_utils/frameUrl';
|
|
6
|
+
import { ReplayCursorLayer } from '../ReplayCursor';
|
|
7
|
+
import { ReplayVeil } from './ReplayVeil';
|
|
8
|
+
/**
|
|
9
|
+
* The product in a same-origin iframe at the recording's viewport size, scaled down to fit the box it sits in. The
|
|
10
|
+
* frame takes no pointer events: the visitor watches, the cursor and highlight layers above it show what happens.
|
|
11
|
+
*/ export function ReplayStage(props) {
|
|
12
|
+
const { manifest, locale, frameSrc, frameRef, cursor, rate, onArrive, loading, children } = props;
|
|
13
|
+
const { width, height } = manifest.viewport;
|
|
14
|
+
const { boxRef, scale } = useStageScale(width);
|
|
15
|
+
const title = pickLocalized(manifest.title, locale);
|
|
16
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
17
|
+
className: "nc-replay__stage",
|
|
18
|
+
"data-replay-stage": true,
|
|
19
|
+
children: [
|
|
20
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
21
|
+
className: "nc-replay__bar",
|
|
22
|
+
children: [
|
|
23
|
+
/*#__PURE__*/ _jsxs("span", {
|
|
24
|
+
className: "nc-replay__dots",
|
|
25
|
+
"aria-hidden": "true",
|
|
26
|
+
children: [
|
|
27
|
+
/*#__PURE__*/ _jsx("i", {}),
|
|
28
|
+
/*#__PURE__*/ _jsx("i", {}),
|
|
29
|
+
/*#__PURE__*/ _jsx("i", {})
|
|
30
|
+
]
|
|
31
|
+
}),
|
|
32
|
+
/*#__PURE__*/ _jsx("span", {
|
|
33
|
+
className: "nc-replay__title",
|
|
34
|
+
children: title
|
|
35
|
+
}),
|
|
36
|
+
/*#__PURE__*/ _jsx("span", {
|
|
37
|
+
className: "nc-replay__pill",
|
|
38
|
+
children: REPLAY_COPY.watchOnly
|
|
39
|
+
})
|
|
40
|
+
]
|
|
41
|
+
}),
|
|
42
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
43
|
+
ref: boxRef,
|
|
44
|
+
className: "nc-replay__view",
|
|
45
|
+
style: {
|
|
46
|
+
aspectRatio: `${width} / ${height}`
|
|
47
|
+
},
|
|
48
|
+
children: [
|
|
49
|
+
frameSrc !== null && /*#__PURE__*/ _jsx("iframe", {
|
|
50
|
+
ref: frameRef,
|
|
51
|
+
className: "nc-replay__frame",
|
|
52
|
+
src: frameSrc,
|
|
53
|
+
title: title,
|
|
54
|
+
tabIndex: -1,
|
|
55
|
+
style: {
|
|
56
|
+
width,
|
|
57
|
+
height,
|
|
58
|
+
transform: `scale(${scale})`
|
|
59
|
+
}
|
|
60
|
+
}),
|
|
61
|
+
/*#__PURE__*/ _jsx(ReplayCursorLayer, {
|
|
62
|
+
cursor: cursor,
|
|
63
|
+
scale: scale,
|
|
64
|
+
rate: rate,
|
|
65
|
+
onArrive: onArrive
|
|
66
|
+
}),
|
|
67
|
+
loading && /*#__PURE__*/ _jsx(ReplayVeil, {}),
|
|
68
|
+
children && /*#__PURE__*/ _jsx("div", {
|
|
69
|
+
className: "nc-replay__overlay",
|
|
70
|
+
children: children
|
|
71
|
+
})
|
|
72
|
+
]
|
|
73
|
+
})
|
|
74
|
+
]
|
|
75
|
+
});
|
|
76
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ReactNode, RefObject } from 'react';
|
|
2
|
+
import type { ReplayManifest } from '../../../../../src/Client/Replay';
|
|
3
|
+
import type { ReplayCursor } from '../../_types';
|
|
4
|
+
export interface ReplayStageProps {
|
|
5
|
+
manifest: ReplayManifest;
|
|
6
|
+
locale: string;
|
|
7
|
+
/** The iframe URL; the stage mounts the frame once it is known. */
|
|
8
|
+
frameSrc: string | null;
|
|
9
|
+
/** Where the player finds the frame's window. */
|
|
10
|
+
frameRef: RefObject<HTMLIFrameElement | null>;
|
|
11
|
+
cursor: ReplayCursor | null;
|
|
12
|
+
rate: number;
|
|
13
|
+
onArrive: (mark: number) => void;
|
|
14
|
+
/** Shows the loading veil over the frame. */
|
|
15
|
+
loading: boolean;
|
|
16
|
+
/** An overlay card (failure, ended) drawn over the frame. */
|
|
17
|
+
children?: ReactNode;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './ReplayCaption';
|
|
2
|
+
export * from './ReplayChapters';
|
|
3
|
+
export * from './ReplayControls';
|
|
4
|
+
export * from './ReplayCursor';
|
|
5
|
+
export * from './ReplayEnded';
|
|
6
|
+
export * from './ReplayFailure';
|
|
7
|
+
export * from './ReplayPlayer';
|
|
8
|
+
export * from './ReplaySkeleton';
|
|
9
|
+
export * from './ReplayStage';
|
|
10
|
+
export * from './ReplayPlayer/ReplayView';
|
|
11
|
+
export type { ReplayPlayerProps } from './ReplayPlayer/types';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './ReplayCaption';
|
|
2
|
+
export * from './ReplayChapters';
|
|
3
|
+
export * from './ReplayControls';
|
|
4
|
+
export * from './ReplayCursor';
|
|
5
|
+
export * from './ReplayEnded';
|
|
6
|
+
export * from './ReplayFailure';
|
|
7
|
+
export * from './ReplayPlayer';
|
|
8
|
+
export * from './ReplaySkeleton';
|
|
9
|
+
export * from './ReplayStage';
|
|
10
|
+
export * from './ReplayPlayer/ReplayView';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ReplayPlayer, ReplayPlayerOptions } from '../_types';
|
|
2
|
+
/**
|
|
3
|
+
* Runs one replay in the page: loads the manifest, hands out the iframe URL, and keeps the player store in step
|
|
4
|
+
* with the frame. The stage renders `<iframe ref={frameRef} src={frameSrc}>`; controls call the returned functions.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useReplayPlayer(options: ReplayPlayerOptions): ReplayPlayer;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useEffectEvent, useRef, useState } from 'react';
|
|
3
|
+
import { useReplayStore } from '../_store';
|
|
4
|
+
import { createReplayController, createReplayNonce } from '../_utils/controller';
|
|
5
|
+
import { replayFrameUrl } from '../_utils/frameUrl';
|
|
6
|
+
/**
|
|
7
|
+
* Runs one replay in the page: loads the manifest, hands out the iframe URL, and keeps the player store in step
|
|
8
|
+
* with the frame. The stage renders `<iframe ref={frameRef} src={frameSrc}>`; controls call the returned functions.
|
|
9
|
+
*/ export function useReplayPlayer(options) {
|
|
10
|
+
const { manifestUrl, locale, autoplay } = options;
|
|
11
|
+
const state = useReplayStore();
|
|
12
|
+
const frameRef = useRef(null);
|
|
13
|
+
const controllerRef = useRef(null);
|
|
14
|
+
const [nonce] = useState(createReplayNonce);
|
|
15
|
+
const open = useEffectEvent(()=>{
|
|
16
|
+
state.reset();
|
|
17
|
+
if (locale) state.setLocale(locale);
|
|
18
|
+
const controller = createReplayController({
|
|
19
|
+
frameWindow: ()=>frameRef.current?.contentWindow ?? null,
|
|
20
|
+
origin: window.location.origin,
|
|
21
|
+
manifestUrl,
|
|
22
|
+
nonce,
|
|
23
|
+
store: state
|
|
24
|
+
});
|
|
25
|
+
controllerRef.current = controller;
|
|
26
|
+
return ()=>{
|
|
27
|
+
controller.dispose();
|
|
28
|
+
controllerRef.current = null;
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
const applyLocale = useEffectEvent((next)=>controllerRef.current?.setLocale(next));
|
|
32
|
+
const autoStart = useEffectEvent(()=>controllerRef.current?.play());
|
|
33
|
+
useEffect(()=>open(), [
|
|
34
|
+
manifestUrl
|
|
35
|
+
]);
|
|
36
|
+
useEffect(()=>{
|
|
37
|
+
if (locale) applyLocale(locale);
|
|
38
|
+
}, [
|
|
39
|
+
locale
|
|
40
|
+
]);
|
|
41
|
+
useEffect(()=>{
|
|
42
|
+
if (autoplay && state.status === 'ready') autoStart();
|
|
43
|
+
}, [
|
|
44
|
+
autoplay,
|
|
45
|
+
state.status
|
|
46
|
+
]);
|
|
47
|
+
const manifest = state.manifest;
|
|
48
|
+
return {
|
|
49
|
+
frameRef,
|
|
50
|
+
frameSrc: manifest ? replayFrameUrl({
|
|
51
|
+
startPath: manifest.startPath,
|
|
52
|
+
recordingId: manifest.id,
|
|
53
|
+
nonce
|
|
54
|
+
}) : null,
|
|
55
|
+
state,
|
|
56
|
+
play: ()=>controllerRef.current?.play(),
|
|
57
|
+
pause: ()=>controllerRef.current?.pause(),
|
|
58
|
+
setRate: (rate)=>controllerRef.current?.setRate(rate),
|
|
59
|
+
seekChapter: (chapterId)=>controllerRef.current?.seekChapter(chapterId),
|
|
60
|
+
setLocale: (next)=>controllerRef.current?.setLocale(next),
|
|
61
|
+
cursorArrived: (mark)=>controllerRef.current?.cursorArrived(mark)
|
|
62
|
+
};
|
|
63
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
/** A slow breathing pulse on every `[data-shimmer]` inside the scope; still under reduced motion. */ export function useShimmer(scope) {
|
|
8
|
+
const reduced = useReducedMotion();
|
|
9
|
+
const run = useEffectEvent(()=>{
|
|
10
|
+
if (reduced) return;
|
|
11
|
+
gsap.fromTo('[data-shimmer]', {
|
|
12
|
+
opacity: 0.45
|
|
13
|
+
}, {
|
|
14
|
+
opacity: 1,
|
|
15
|
+
duration: 0.9,
|
|
16
|
+
ease: 'sine.inOut',
|
|
17
|
+
yoyo: true,
|
|
18
|
+
repeat: -1,
|
|
19
|
+
stagger: {
|
|
20
|
+
each: 0.08,
|
|
21
|
+
from: 'start'
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
useGSAP(()=>run(), {
|
|
26
|
+
scope,
|
|
27
|
+
dependencies: [
|
|
28
|
+
reduced
|
|
29
|
+
]
|
|
30
|
+
});
|
|
31
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useEffectEvent, useRef, useState } from 'react';
|
|
3
|
+
/** The scale that fits a stage of `viewportWidth` px into the width of the element the returned ref points at. */ export function useStageScale(viewportWidth) {
|
|
4
|
+
const boxRef = useRef(null);
|
|
5
|
+
const [width, setWidth] = useState(0);
|
|
6
|
+
const measure = useEffectEvent(()=>{
|
|
7
|
+
const box = boxRef.current;
|
|
8
|
+
if (box) setWidth(box.clientWidth);
|
|
9
|
+
});
|
|
10
|
+
useEffect(()=>{
|
|
11
|
+
const box = boxRef.current;
|
|
12
|
+
if (!box) return;
|
|
13
|
+
measure();
|
|
14
|
+
if (typeof ResizeObserver === 'undefined') return;
|
|
15
|
+
const observer = new ResizeObserver(()=>measure());
|
|
16
|
+
observer.observe(box);
|
|
17
|
+
return ()=>observer.disconnect();
|
|
18
|
+
}, []);
|
|
19
|
+
const scale = width > 0 && viewportWidth > 0 ? width / viewportWidth : 1;
|
|
20
|
+
return {
|
|
21
|
+
boxRef,
|
|
22
|
+
scale
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './replayStore';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './replayStore';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ReplayPlayerMethods, ReplayPlayerState } from '../_types';
|
|
2
|
+
export declare const initialReplayState: ReplayPlayerState;
|
|
3
|
+
type Creators = {
|
|
4
|
+
[K in keyof ReplayPlayerMethods]: (s: ReplayPlayerState) => ReplayPlayerMethods[K];
|
|
5
|
+
};
|
|
6
|
+
/** The store's methods as creators over a plain state object, so tests can run them without React. */
|
|
7
|
+
export declare const replayMethodCreators: Creators;
|
|
8
|
+
/**
|
|
9
|
+
* The one active replay: the controller writes it from the frame's messages, the stage and controls read it.
|
|
10
|
+
* The hook passes the live store object (`useReplayStore()`) to the controller.
|
|
11
|
+
*/
|
|
12
|
+
export declare const useReplayStore: () => import("h-state").StoreType<ReplayPlayerState, ReplayPlayerMethods>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { createStore } from 'h-state';
|
|
3
|
+
export const initialReplayState = {
|
|
4
|
+
status: 'loading',
|
|
5
|
+
manifest: null,
|
|
6
|
+
chapterId: null,
|
|
7
|
+
stepId: null,
|
|
8
|
+
caption: null,
|
|
9
|
+
playhead: 0,
|
|
10
|
+
rate: 1,
|
|
11
|
+
locale: 'en',
|
|
12
|
+
cursor: null,
|
|
13
|
+
unanswered: [],
|
|
14
|
+
failure: null
|
|
15
|
+
};
|
|
16
|
+
/** The store's methods as creators over a plain state object, so tests can run them without React. */ export const replayMethodCreators = {
|
|
17
|
+
reset: (s)=>()=>{
|
|
18
|
+
Object.assign(s, {
|
|
19
|
+
...initialReplayState,
|
|
20
|
+
unanswered: [],
|
|
21
|
+
locale: s.locale
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
setManifest: (s)=>(manifest)=>{
|
|
25
|
+
s.manifest = manifest;
|
|
26
|
+
s.chapterId = manifest.chapters[0]?.id ?? null;
|
|
27
|
+
s.rate = manifest.chapters[0]?.rate ?? 1;
|
|
28
|
+
},
|
|
29
|
+
setStatus: (s)=>(status)=>{
|
|
30
|
+
s.status = status;
|
|
31
|
+
},
|
|
32
|
+
setChapter: (s)=>(chapterId)=>{
|
|
33
|
+
s.chapterId = chapterId;
|
|
34
|
+
},
|
|
35
|
+
startStep: (s)=>(stepId, caption)=>{
|
|
36
|
+
s.stepId = stepId;
|
|
37
|
+
s.caption = caption;
|
|
38
|
+
},
|
|
39
|
+
clearStep: (s)=>()=>{
|
|
40
|
+
s.stepId = null;
|
|
41
|
+
s.caption = null;
|
|
42
|
+
s.cursor = null;
|
|
43
|
+
},
|
|
44
|
+
setPlayhead: (s)=>(playhead)=>{
|
|
45
|
+
s.playhead = playhead;
|
|
46
|
+
},
|
|
47
|
+
setRate: (s)=>(rate)=>{
|
|
48
|
+
s.rate = rate;
|
|
49
|
+
},
|
|
50
|
+
setLocale: (s)=>(locale)=>{
|
|
51
|
+
s.locale = locale;
|
|
52
|
+
},
|
|
53
|
+
setCursor: (s)=>(cursor)=>{
|
|
54
|
+
s.cursor = cursor;
|
|
55
|
+
},
|
|
56
|
+
reportUnanswered: (s)=>(key)=>{
|
|
57
|
+
if (!s.unanswered.includes(key)) s.unanswered = [
|
|
58
|
+
...s.unanswered,
|
|
59
|
+
key
|
|
60
|
+
];
|
|
61
|
+
},
|
|
62
|
+
fail: (s)=>(failure)=>{
|
|
63
|
+
s.failure = failure;
|
|
64
|
+
s.status = 'failed';
|
|
65
|
+
s.cursor = null;
|
|
66
|
+
},
|
|
67
|
+
clearFailure: (s)=>()=>{
|
|
68
|
+
s.failure = null;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* The one active replay: the controller writes it from the frame's messages, the stage and controls read it.
|
|
73
|
+
* The hook passes the live store object (`useReplayStore()`) to the controller.
|
|
74
|
+
*/ export const { useStore: useReplayStore } = createStore(initialReplayState, replayMethodCreators);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './player';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './player';
|