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.
- 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 +2 -0
- package/dist/fe/components/Replay/_hooks/index.js +2 -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/_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/index.d.ts +3 -0
- package/dist/fe/components/Replay/_utils/index.js +3 -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 +1 -0
- package/dist/fe/components/Replay/index.js +1 -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,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,29 @@
|
|
|
1
|
+
import type { ReplayFailureReason } from '../_types';
|
|
2
|
+
export interface FailureCopy {
|
|
3
|
+
/** What is not working. */
|
|
4
|
+
what: string;
|
|
5
|
+
/** What it means for the visitor. */
|
|
6
|
+
means: string;
|
|
7
|
+
/** What has to happen, and by whom. */
|
|
8
|
+
next: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function failureCopy(reason: ReplayFailureReason): FailureCopy;
|
|
11
|
+
export declare const REPLAY_COPY: {
|
|
12
|
+
watchOnly: string;
|
|
13
|
+
loadingFrame: string;
|
|
14
|
+
stepOf: (index: number, count: number) => string;
|
|
15
|
+
play: string;
|
|
16
|
+
pause: string;
|
|
17
|
+
restart: string;
|
|
18
|
+
speed: string;
|
|
19
|
+
language: string;
|
|
20
|
+
chapters: string;
|
|
21
|
+
chapterPace: (label: string) => string;
|
|
22
|
+
retry: string;
|
|
23
|
+
endedTitle: string;
|
|
24
|
+
endedBody: string;
|
|
25
|
+
watchAgain: string;
|
|
26
|
+
idle: string;
|
|
27
|
+
continue: string;
|
|
28
|
+
};
|
|
29
|
+
export declare const RATE_CHOICES: readonly number[];
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
const RETRY_OR_RERECORD = 'Try again from this chapter. If it repeats, the site owner has to record it again.';
|
|
2
|
+
const STOPPED = 'The walkthrough stopped at this step.';
|
|
3
|
+
const FAILURES = {
|
|
4
|
+
manifest_unreachable: {
|
|
5
|
+
what: 'The recording could not be loaded.',
|
|
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.'
|
|
8
|
+
},
|
|
9
|
+
manifest_invalid: {
|
|
10
|
+
what: 'The recording file is not in a format this player understands.',
|
|
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.'
|
|
13
|
+
},
|
|
14
|
+
frame_timeout: {
|
|
15
|
+
what: 'The product screen did not start in time.',
|
|
16
|
+
means: 'The recording is loaded, but nothing can be shown yet.',
|
|
17
|
+
next: 'Try again. If it keeps failing, reload the page.'
|
|
18
|
+
},
|
|
19
|
+
target_timeout: {
|
|
20
|
+
what: 'A screen element in this step never appeared.',
|
|
21
|
+
means: STOPPED,
|
|
22
|
+
next: RETRY_OR_RERECORD
|
|
23
|
+
},
|
|
24
|
+
target_unsupported: {
|
|
25
|
+
what: 'This step points at an element the player cannot operate.',
|
|
26
|
+
means: STOPPED,
|
|
27
|
+
next: 'The site owner has to record this step again.'
|
|
28
|
+
},
|
|
29
|
+
option_not_found: {
|
|
30
|
+
what: 'A choice in this step is missing from the screen.',
|
|
31
|
+
means: STOPPED,
|
|
32
|
+
next: RETRY_OR_RERECORD
|
|
33
|
+
},
|
|
34
|
+
navigate_failed: {
|
|
35
|
+
what: 'The product screen could not open the next page.',
|
|
36
|
+
means: STOPPED,
|
|
37
|
+
next: 'Try again. If it keeps failing, reload the page.'
|
|
38
|
+
},
|
|
39
|
+
action_error: {
|
|
40
|
+
what: 'This step failed while it was running.',
|
|
41
|
+
means: STOPPED,
|
|
42
|
+
next: RETRY_OR_RERECORD
|
|
43
|
+
},
|
|
44
|
+
step_unknown: {
|
|
45
|
+
what: 'The recording refers to a step it does not contain.',
|
|
46
|
+
means: 'It cannot be played to the end.',
|
|
47
|
+
next: 'The site owner has to record and publish it again.'
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
export function failureCopy(reason) {
|
|
51
|
+
return FAILURES[reason];
|
|
52
|
+
}
|
|
53
|
+
export const REPLAY_COPY = {
|
|
54
|
+
watchOnly: 'Watch only',
|
|
55
|
+
loadingFrame: 'Opening the product',
|
|
56
|
+
stepOf: (index, count)=>`Step ${index} of ${count}`,
|
|
57
|
+
play: 'Play',
|
|
58
|
+
pause: 'Pause',
|
|
59
|
+
restart: 'Restart',
|
|
60
|
+
speed: 'Speed',
|
|
61
|
+
language: 'Language',
|
|
62
|
+
chapters: 'Chapters',
|
|
63
|
+
chapterPace: (label)=>`Chapter pace ${label}`,
|
|
64
|
+
retry: 'Try again',
|
|
65
|
+
endedTitle: 'That is the whole tour.',
|
|
66
|
+
endedBody: 'Watch it again from the start, or carry on.',
|
|
67
|
+
watchAgain: 'Watch again',
|
|
68
|
+
idle: 'Press play to watch the tour.',
|
|
69
|
+
continue: 'Continue'
|
|
70
|
+
};
|
|
71
|
+
export const RATE_CHOICES = [
|
|
72
|
+
1,
|
|
73
|
+
2,
|
|
74
|
+
4
|
|
75
|
+
];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { PointBox } from '../../../../src/Client/Replay';
|
|
2
|
+
export interface CursorElements {
|
|
3
|
+
cursor: HTMLElement | SVGElement;
|
|
4
|
+
ring: HTMLElement;
|
|
5
|
+
ripple: HTMLElement;
|
|
6
|
+
}
|
|
7
|
+
export interface CursorTarget {
|
|
8
|
+
/** Centre of the target in stage pixels. */
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
/** The target's box in stage pixels, grown a little so the ring sits around it. */
|
|
12
|
+
box: {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/** The target's box scaled into the stage's pixels, with its centre. */
|
|
20
|
+
export declare function targetIn(box: PointBox, scale: number): CursorTarget;
|
|
21
|
+
/** How long a glide takes: longer for longer trips, shorter at a higher rate. */
|
|
22
|
+
export declare function glideSeconds(distance: number, rate: number): number;
|
|
23
|
+
export interface CursorMove {
|
|
24
|
+
target: CursorTarget;
|
|
25
|
+
/** Where the cursor is now; null on the first move, which starts at the target. */
|
|
26
|
+
from: {
|
|
27
|
+
x: number;
|
|
28
|
+
y: number;
|
|
29
|
+
} | null;
|
|
30
|
+
rate: number;
|
|
31
|
+
reduced: boolean;
|
|
32
|
+
onArrive: () => void;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Moves the drawn cursor and its ring to the target, presses, and calls `onArrive` once it rested there.
|
|
36
|
+
* Reduced motion jumps and calls `onArrive` at once. Returns the timeline so the caller can kill it.
|
|
37
|
+
*/
|
|
38
|
+
export declare function moveCursor(els: CursorElements, move: CursorMove): gsap.core.Timeline;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import gsap from 'gsap';
|
|
2
|
+
const RING_GROW = 6;
|
|
3
|
+
const GLIDE_MIN = 0.35;
|
|
4
|
+
const GLIDE_MAX = 1.1;
|
|
5
|
+
const REST = 0.18;
|
|
6
|
+
const MIN_RATE = 0.25;
|
|
7
|
+
/** The target's box scaled into the stage's pixels, with its centre. */ export function targetIn(box, scale) {
|
|
8
|
+
const x = box.x * scale;
|
|
9
|
+
const y = box.y * scale;
|
|
10
|
+
const width = box.width * scale;
|
|
11
|
+
const height = box.height * scale;
|
|
12
|
+
return {
|
|
13
|
+
x: x + width / 2,
|
|
14
|
+
y: y + height / 2,
|
|
15
|
+
box: {
|
|
16
|
+
x: x - RING_GROW,
|
|
17
|
+
y: y - RING_GROW,
|
|
18
|
+
width: width + RING_GROW * 2,
|
|
19
|
+
height: height + RING_GROW * 2
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/** How long a glide takes: longer for longer trips, shorter at a higher rate. */ export function glideSeconds(distance, rate) {
|
|
24
|
+
const base = Math.min(GLIDE_MAX, GLIDE_MIN + distance / 1600);
|
|
25
|
+
return base / Math.max(rate, MIN_RATE);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Moves the drawn cursor and its ring to the target, presses, and calls `onArrive` once it rested there.
|
|
29
|
+
* Reduced motion jumps and calls `onArrive` at once. Returns the timeline so the caller can kill it.
|
|
30
|
+
*/ export function moveCursor(els, move) {
|
|
31
|
+
const { target, from, rate, reduced } = move;
|
|
32
|
+
const timeline = gsap.timeline({
|
|
33
|
+
defaults: {
|
|
34
|
+
overwrite: 'auto',
|
|
35
|
+
ease: 'power3.inOut'
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
if (reduced) {
|
|
39
|
+
gsap.set(els.cursor, {
|
|
40
|
+
x: target.x,
|
|
41
|
+
y: target.y,
|
|
42
|
+
opacity: 1
|
|
43
|
+
});
|
|
44
|
+
gsap.set(els.ring, {
|
|
45
|
+
...target.box,
|
|
46
|
+
opacity: 1
|
|
47
|
+
});
|
|
48
|
+
move.onArrive();
|
|
49
|
+
return timeline;
|
|
50
|
+
}
|
|
51
|
+
const start = from ?? target;
|
|
52
|
+
if (from === null) {
|
|
53
|
+
gsap.set(els.cursor, {
|
|
54
|
+
x: start.x,
|
|
55
|
+
y: start.y
|
|
56
|
+
});
|
|
57
|
+
gsap.set(els.ring, {
|
|
58
|
+
...target.box,
|
|
59
|
+
opacity: 0
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
const speed = Math.max(rate, MIN_RATE);
|
|
63
|
+
const seconds = glideSeconds(Math.hypot(target.x - start.x, target.y - start.y), rate);
|
|
64
|
+
timeline.to(els.cursor, {
|
|
65
|
+
x: target.x,
|
|
66
|
+
y: target.y,
|
|
67
|
+
opacity: 1,
|
|
68
|
+
duration: seconds
|
|
69
|
+
}, 0);
|
|
70
|
+
timeline.to(els.ring, {
|
|
71
|
+
...target.box,
|
|
72
|
+
opacity: 1,
|
|
73
|
+
duration: seconds
|
|
74
|
+
}, 0);
|
|
75
|
+
timeline.call(move.onArrive, [], seconds + REST);
|
|
76
|
+
timeline.to(els.cursor, {
|
|
77
|
+
scale: 0.82,
|
|
78
|
+
duration: 0.09 / speed,
|
|
79
|
+
yoyo: true,
|
|
80
|
+
repeat: 1,
|
|
81
|
+
ease: 'power1.inOut',
|
|
82
|
+
transformOrigin: '0 0'
|
|
83
|
+
}, seconds + REST);
|
|
84
|
+
timeline.fromTo(els.ripple, {
|
|
85
|
+
x: target.x,
|
|
86
|
+
y: target.y,
|
|
87
|
+
scale: 0.2,
|
|
88
|
+
opacity: 0.55
|
|
89
|
+
}, {
|
|
90
|
+
x: target.x,
|
|
91
|
+
y: target.y,
|
|
92
|
+
scale: 1,
|
|
93
|
+
opacity: 0,
|
|
94
|
+
duration: 0.6 / speed,
|
|
95
|
+
ease: 'power2.out'
|
|
96
|
+
}, seconds + REST);
|
|
97
|
+
return timeline;
|
|
98
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { REPLAY_LAYOUT_CSS } from './replayLayout';
|
|
2
|
+
import { REPLAY_PALETTE_CSS } from './replayPalette';
|
|
3
|
+
import { REPLAY_PARTS_CSS } from './replayParts';
|
|
4
|
+
/** The whole stylesheet of the player, scoped to `.nc-replay`; the root renders it once. */ export const REPLAY_CSS = REPLAY_PALETTE_CSS + REPLAY_LAYOUT_CSS + REPLAY_PARTS_CSS;
|