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.
Files changed (108) 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 +3 -0
  41. package/dist/fe/components/Replay/_hooks/index.js +3 -0
  42. package/dist/fe/components/Replay/_hooks/useReplayPlayer.d.ts +6 -0
  43. package/dist/fe/components/Replay/_hooks/useReplayPlayer.js +63 -0
  44. package/dist/fe/components/Replay/_hooks/useShimmer.d.ts +3 -0
  45. package/dist/fe/components/Replay/_hooks/useShimmer.js +31 -0
  46. package/dist/fe/components/Replay/_hooks/useStageScale.d.ts +5 -0
  47. package/dist/fe/components/Replay/_hooks/useStageScale.js +24 -0
  48. package/dist/fe/components/Replay/_store/index.d.ts +1 -0
  49. package/dist/fe/components/Replay/_store/index.js +1 -0
  50. package/dist/fe/components/Replay/_store/replayStore.d.ts +13 -0
  51. package/dist/fe/components/Replay/_store/replayStore.js +74 -0
  52. package/dist/fe/components/Replay/_types/index.d.ts +1 -0
  53. package/dist/fe/components/Replay/_types/index.js +1 -0
  54. package/dist/fe/components/Replay/_types/player.d.ts +105 -0
  55. package/dist/fe/components/Replay/_types/player.js +1 -0
  56. package/dist/fe/components/Replay/_utils/controller.d.ts +10 -0
  57. package/dist/fe/components/Replay/_utils/controller.js +208 -0
  58. package/dist/fe/components/Replay/_utils/controllerReports.d.ts +18 -0
  59. package/dist/fe/components/Replay/_utils/controllerReports.js +70 -0
  60. package/dist/fe/components/Replay/_utils/copy.d.ts +29 -0
  61. package/dist/fe/components/Replay/_utils/copy.js +75 -0
  62. package/dist/fe/components/Replay/_utils/cursorMotion.d.ts +38 -0
  63. package/dist/fe/components/Replay/_utils/cursorMotion.js +98 -0
  64. package/dist/fe/components/Replay/_utils/frameBridge.d.ts +40 -0
  65. package/dist/fe/components/Replay/_utils/frameBridge.js +167 -0
  66. package/dist/fe/components/Replay/_utils/framePoints.d.ts +17 -0
  67. package/dist/fe/components/Replay/_utils/framePoints.js +24 -0
  68. package/dist/fe/components/Replay/_utils/frameUrl.d.ts +21 -0
  69. package/dist/fe/components/Replay/_utils/frameUrl.js +23 -0
  70. package/dist/fe/components/Replay/_utils/index.d.ts +7 -0
  71. package/dist/fe/components/Replay/_utils/index.js +7 -0
  72. package/dist/fe/components/Replay/_utils/replayCss.d.ts +2 -0
  73. package/dist/fe/components/Replay/_utils/replayCss.js +4 -0
  74. package/dist/fe/components/Replay/_utils/replayLayout.d.ts +2 -0
  75. package/dist/fe/components/Replay/_utils/replayLayout.js +20 -0
  76. package/dist/fe/components/Replay/_utils/replayPalette.d.ts +1 -0
  77. package/dist/fe/components/Replay/_utils/replayPalette.js +8 -0
  78. package/dist/fe/components/Replay/_utils/replayParts.d.ts +1 -0
  79. package/dist/fe/components/Replay/_utils/replayParts.js +56 -0
  80. package/dist/fe/components/Replay/_utils/replayProgress.d.ts +14 -0
  81. package/dist/fe/components/Replay/_utils/replayProgress.js +39 -0
  82. package/dist/fe/components/Replay/index.d.ts +5 -0
  83. package/dist/fe/components/Replay/index.js +5 -0
  84. package/dist/src/Client/Replay/index.d.ts +1 -0
  85. package/dist/src/Client/Replay/index.js +1 -0
  86. package/dist/src/Client/Replay/recorder/anchors.d.ts +18 -0
  87. package/dist/src/Client/Replay/recorder/anchors.js +39 -0
  88. package/dist/src/Client/Replay/recorder/bundle.d.ts +60 -0
  89. package/dist/src/Client/Replay/recorder/bundle.js +103 -0
  90. package/dist/src/Client/Replay/recorder/clock.d.ts +13 -0
  91. package/dist/src/Client/Replay/recorder/clock.js +9 -0
  92. package/dist/src/Client/Replay/recorder/factoryTap.d.ts +22 -0
  93. package/dist/src/Client/Replay/recorder/factoryTap.js +24 -0
  94. package/dist/src/Client/Replay/recorder/fetchTee.d.ts +37 -0
  95. package/dist/src/Client/Replay/recorder/fetchTee.js +121 -0
  96. package/dist/src/Client/Replay/recorder/index.d.ts +9 -0
  97. package/dist/src/Client/Replay/recorder/index.js +9 -0
  98. package/dist/src/Client/Replay/recorder/privacy.d.ts +27 -0
  99. package/dist/src/Client/Replay/recorder/privacy.js +115 -0
  100. package/dist/src/Client/Replay/recorder/redact.d.ts +8 -0
  101. package/dist/src/Client/Replay/recorder/redact.js +100 -0
  102. package/dist/src/Client/Replay/recorder/socketTap.d.ts +21 -0
  103. package/dist/src/Client/Replay/recorder/socketTap.js +43 -0
  104. package/dist/src/Client/Replay/recorder/sse.d.ts +15 -0
  105. package/dist/src/Client/Replay/recorder/sse.js +56 -0
  106. package/dist/src/Client/Replay/recorder/steps.d.ts +27 -0
  107. package/dist/src/Client/Replay/recorder/steps.js +152 -0
  108. package/package.json +5 -1
@@ -0,0 +1,40 @@
1
+ import { type ReplayChapter, type ReplayManifest, type Timeline, type VisibleCheck, type Win } from '../../../../src/Client/Replay';
2
+ import type { ReplayFrameTarget } from '../_types';
3
+ export interface ReplayFrameOptions {
4
+ /** The frame's own window: DOM for the driver, `message` events, timers. */
5
+ win: Win;
6
+ /** The embedding page's window: where messages go and the only source accepted. */
7
+ parent: ReplayFrameTarget;
8
+ origin: string;
9
+ /** The session nonce from the frame's URL (`readReplayNonce`). */
10
+ nonce: string;
11
+ manifest: ReplayManifest;
12
+ /** The realm's timeline: the one the clock, streams and `waitUntil` run on. */
13
+ timeline: Timeline;
14
+ /** Moves the product to a path of the app (its router); resolves true once it is there. */
15
+ navigate: (path: string) => Promise<boolean>;
16
+ /** Resolves when that frame of that stream has been delivered (the realm's streams own it). */
17
+ waitForFrame: (stream: string, seq: number) => Promise<void>;
18
+ /** Resolves when the page has settled between actions; defaults to one task. */
19
+ settle?: () => Promise<void>;
20
+ /** Subscribes to calls no recorded answer covered; the bridge reports each key to the parent. */
21
+ onUnanswered?: (listener: (key: string) => void) => () => void;
22
+ /** The parent asked for a chapter: the timeline already snapped; the app may reload the frame (`?chapter=`). */
23
+ onSeek?: (chapter: ReplayChapter) => void;
24
+ /** The chapter this frame was started at (`readReplayChapter`). */
25
+ startChapter?: string | null;
26
+ typingDelayMs?: number;
27
+ tickMs?: number;
28
+ pointTimeoutMs?: number;
29
+ targetTimeoutMs?: number;
30
+ visible?: VisibleCheck;
31
+ }
32
+ export interface ReplayFrameHandle {
33
+ stop: () => void;
34
+ }
35
+ /**
36
+ * The frame side of a replay: answers the parent's hello, forwards play, pause, rate and seek to the timeline, runs
37
+ * every step through the driver when the playhead reaches its `at`, and reports started, point, done, failed and
38
+ * ticks. Installing the realm itself is the app's job; this only wires the channel to the driver.
39
+ */
40
+ export declare function startReplayFrame(options: ReplayFrameOptions): ReplayFrameHandle;
@@ -0,0 +1,167 @@
1
+ import { envelopeFor, readParentMessage, runStep, sendMessage } from '../../../../src/Client/Replay';
2
+ import { createFramePoints } from './framePoints';
3
+ const TICK_MS = 250;
4
+ const POINT_TIMEOUT_MS = 8000;
5
+ const BASE_TYPING_DELAY_MS = 45;
6
+ const MAX_KEY_LENGTH = 200;
7
+ /**
8
+ * The frame side of a replay: answers the parent's hello, forwards play, pause, rate and seek to the timeline, runs
9
+ * every step through the driver when the playhead reaches its `at`, and reports started, point, done, failed and
10
+ * ticks. Installing the realm itself is the app's job; this only wires the channel to the driver.
11
+ */ export function startReplayFrame(options) {
12
+ const { win, manifest, timeline } = options;
13
+ const steps = [
14
+ ...manifest.steps
15
+ ].sort((a, b)=>a.at - b.at);
16
+ let generation = 0;
17
+ let abortWait = ()=>{};
18
+ const send = (build)=>{
19
+ sendMessage(options.parent, options.origin, build(envelopeFor(options.nonce)));
20
+ };
21
+ const announce = ()=>send((e)=>({
22
+ ...e,
23
+ type: 'ready',
24
+ recordingId: manifest.id
25
+ }));
26
+ const tick = ()=>send((e)=>({
27
+ ...e,
28
+ type: 'tick',
29
+ at: timeline.now(),
30
+ playing: timeline.isPlaying()
31
+ }));
32
+ const pointer = createFramePoints({
33
+ setTimeout: (run, ms)=>win.setTimeout(run, ms),
34
+ clearTimeout: (id)=>win.clearTimeout(id),
35
+ timeoutMs: options.pointTimeoutMs ?? POINT_TIMEOUT_MS,
36
+ report: (stepId, mark, box)=>send((e)=>({
37
+ ...e,
38
+ type: 'point',
39
+ stepId,
40
+ mark,
41
+ box
42
+ }))
43
+ });
44
+ const waitFor = (ms)=>new Promise((resolve)=>{
45
+ const off = timeline.at(ms, ()=>resolve(true));
46
+ abortWait = ()=>{
47
+ off();
48
+ resolve(false);
49
+ };
50
+ });
51
+ const execute = async (step, gen)=>{
52
+ send((e)=>({
53
+ ...e,
54
+ type: 'step-started',
55
+ stepId: step.id
56
+ }));
57
+ const base = options.typingDelayMs ?? BASE_TYPING_DELAY_MS;
58
+ const result = await runStep(step, {
59
+ win,
60
+ attribute: manifest.targetAttribute,
61
+ typingDelayMs: Math.round(base / timeline.getRate()),
62
+ targetTimeoutMs: options.targetTimeoutMs,
63
+ visible: options.visible,
64
+ onPoint: (box)=>pointer.point(step.id, box),
65
+ settle: options.settle ?? (()=>new Promise((resolve)=>void win.setTimeout(resolve, 0))),
66
+ navigate: options.navigate,
67
+ waitForFrame: options.waitForFrame,
68
+ waitUntil: (at)=>timeline.waitUntil(at)
69
+ });
70
+ if (gen !== generation) return false;
71
+ if (result.ok) {
72
+ send((e)=>({
73
+ ...e,
74
+ type: 'step-done',
75
+ stepId: step.id
76
+ }));
77
+ return true;
78
+ }
79
+ timeline.pause();
80
+ send((e)=>({
81
+ ...e,
82
+ type: 'step-failed',
83
+ stepId: step.id,
84
+ actionIndex: result.actionIndex,
85
+ reason: result.reason
86
+ }));
87
+ return false;
88
+ };
89
+ const runFrom = async (from, gen)=>{
90
+ for (const step of steps.slice(from)){
91
+ if (!await waitFor(step.at) || gen !== generation) return;
92
+ if (!await execute(step, gen)) return;
93
+ }
94
+ };
95
+ const restartAt = (chapter)=>{
96
+ generation += 1;
97
+ abortWait();
98
+ pointer.releaseAll();
99
+ timeline.seekChapter(chapter.id);
100
+ const first = steps.findIndex((step)=>step.at >= chapter.from);
101
+ if (first >= 0) void runFrom(first, generation);
102
+ };
103
+ const seek = (at)=>{
104
+ const chapter = manifest.chapters.filter((item)=>item.from <= at).pop();
105
+ if (!chapter) return;
106
+ restartAt(chapter);
107
+ options.onSeek?.(chapter);
108
+ };
109
+ const onMessage = (event)=>{
110
+ const message = readParentMessage({
111
+ origin: event.origin,
112
+ source: event.source,
113
+ data: event.data
114
+ }, {
115
+ origin: options.origin,
116
+ peer: options.parent,
117
+ nonce: options.nonce
118
+ });
119
+ if (!message) return;
120
+ switch(message.type){
121
+ case 'hello':
122
+ announce();
123
+ break;
124
+ case 'play':
125
+ timeline.play();
126
+ break;
127
+ case 'pause':
128
+ timeline.pause();
129
+ break;
130
+ case 'rate':
131
+ timeline.setRate(message.rate);
132
+ break;
133
+ case 'seek':
134
+ seek(message.at);
135
+ break;
136
+ case 'cursor-arrived':
137
+ pointer.arrived(message.mark);
138
+ break;
139
+ }
140
+ };
141
+ win.addEventListener('message', onMessage);
142
+ const ticker = win.setInterval(tick, options.tickMs ?? TICK_MS);
143
+ const unsubscribe = timeline.subscribe(tick);
144
+ const unanswered = options.onUnanswered?.((key)=>{
145
+ if (key.length > 0) send((e)=>({
146
+ ...e,
147
+ type: 'unanswered',
148
+ key: key.slice(0, MAX_KEY_LENGTH)
149
+ }));
150
+ });
151
+ const start = manifest.chapters.find((chapter)=>chapter.id === options.startChapter);
152
+ if (start) timeline.seekChapter(start.id);
153
+ const first = steps.findIndex((step)=>step.at >= (start?.from ?? 0));
154
+ if (first >= 0) void runFrom(first, generation);
155
+ announce();
156
+ return {
157
+ stop () {
158
+ generation += 1;
159
+ abortWait();
160
+ pointer.releaseAll();
161
+ win.removeEventListener('message', onMessage);
162
+ win.clearInterval(ticker);
163
+ unsubscribe();
164
+ unanswered?.();
165
+ }
166
+ };
167
+ }
@@ -0,0 +1,17 @@
1
+ import type { PointBox } from '../../../../src/Client/Replay';
2
+ export interface FramePoints {
3
+ /** Reports the box and resolves once the parent's cursor arrived (or the timeout passed). */
4
+ point: (stepId: string, box: PointBox) => Promise<void>;
5
+ /** The parent's `cursor-arrived` for a mark. */
6
+ arrived: (mark: number) => void;
7
+ /** Releases every waiting pointer action (a seek or a stop). */
8
+ releaseAll: () => void;
9
+ }
10
+ export interface FramePointsDeps {
11
+ setTimeout: (run: () => void, ms: number) => number;
12
+ clearTimeout: (id: number) => void;
13
+ timeoutMs: number;
14
+ report: (stepId: string, mark: number, box: PointBox) => void;
15
+ }
16
+ /** The handshake between the driver's pointer actions and the parent's drawn cursor. */
17
+ export declare function createFramePoints(deps: FramePointsDeps): FramePoints;
@@ -0,0 +1,24 @@
1
+ /** The handshake between the driver's pointer actions and the parent's drawn cursor. */ export function createFramePoints(deps) {
2
+ const waiting = new Map();
3
+ let marks = 0;
4
+ return {
5
+ point: (stepId, box)=>new Promise((resolve)=>{
6
+ marks += 1;
7
+ const mark = marks;
8
+ const timer = deps.setTimeout(release, deps.timeoutMs);
9
+ function release() {
10
+ deps.clearTimeout(timer);
11
+ waiting.delete(mark);
12
+ resolve();
13
+ }
14
+ waiting.set(mark, release);
15
+ deps.report(stepId, mark, box);
16
+ }),
17
+ arrived: (mark)=>waiting.get(mark)?.(),
18
+ releaseAll: ()=>{
19
+ for (const release of [
20
+ ...waiting.values()
21
+ ])release();
22
+ }
23
+ };
24
+ }
@@ -0,0 +1,21 @@
1
+ import type { Localized } from '../../../../src/Client/Replay';
2
+ export declare const REPLAY_PARAM = "replay";
3
+ export declare const REPLAY_NONCE_PARAM = "replayNonce";
4
+ export declare const REPLAY_CHAPTER_PARAM = "chapter";
5
+ export interface ReplayFrameUrlInput {
6
+ /** The manifest's `startPath`. */
7
+ startPath: string;
8
+ recordingId: string;
9
+ /** The session nonce the player's controller was created with. */
10
+ nonce: string;
11
+ /** Start the reloaded frame at this chapter (after a seek the app turns into a reload). */
12
+ chapter?: string;
13
+ }
14
+ /** The iframe URL: the product's start path with the recording id, the session nonce and an optional start chapter. */
15
+ export declare function replayFrameUrl(input: ReplayFrameUrlInput): string;
16
+ /** The nonce in the frame's own query string, or null when absent or malformed. */
17
+ export declare function readReplayNonce(search: string): string | null;
18
+ /** The chapter the frame was told to start at, or null. */
19
+ export declare function readReplayChapter(search: string): string | null;
20
+ /** One language of a localized text: the locale, its base language (`tr-TR` to `tr`), then English. */
21
+ export declare function pickLocalized(text: Localized | null, locale: string): string;
@@ -0,0 +1,23 @@
1
+ export const REPLAY_PARAM = 'replay';
2
+ export const REPLAY_NONCE_PARAM = 'replayNonce';
3
+ export const REPLAY_CHAPTER_PARAM = 'chapter';
4
+ const NONCE_SHAPE = /^[0-9a-f]{16,128}$/;
5
+ const PLACEHOLDER_BASE = 'http://replay.invalid';
6
+ /** The iframe URL: the product's start path with the recording id, the session nonce and an optional start chapter. */ export function replayFrameUrl(input) {
7
+ const url = new URL(input.startPath, PLACEHOLDER_BASE);
8
+ url.searchParams.set(REPLAY_PARAM, input.recordingId);
9
+ url.searchParams.set(REPLAY_NONCE_PARAM, input.nonce);
10
+ if (input.chapter) url.searchParams.set(REPLAY_CHAPTER_PARAM, input.chapter);
11
+ return `${url.pathname}${url.search}${url.hash}`;
12
+ }
13
+ /** The nonce in the frame's own query string, or null when absent or malformed. */ export function readReplayNonce(search) {
14
+ const value = new URLSearchParams(search).get(REPLAY_NONCE_PARAM);
15
+ return value !== null && NONCE_SHAPE.test(value) ? value : null;
16
+ }
17
+ /** The chapter the frame was told to start at, or null. */ export function readReplayChapter(search) {
18
+ return new URLSearchParams(search).get(REPLAY_CHAPTER_PARAM);
19
+ }
20
+ /** One language of a localized text: the locale, its base language (`tr-TR` to `tr`), then English. */ export function pickLocalized(text, locale) {
21
+ if (text === null) return '';
22
+ return text[locale] ?? text[locale.split('-')[0] ?? ''] ?? text.en;
23
+ }
@@ -0,0 +1,7 @@
1
+ export * from './controller';
2
+ export * from './copy';
3
+ export * from './cursorMotion';
4
+ export * from './frameBridge';
5
+ export * from './framePoints';
6
+ export * from './frameUrl';
7
+ export * from './replayProgress';
@@ -0,0 +1,7 @@
1
+ export * from './controller';
2
+ export * from './copy';
3
+ export * from './cursorMotion';
4
+ export * from './frameBridge';
5
+ export * from './framePoints';
6
+ export * from './frameUrl';
7
+ export * from './replayProgress';
@@ -0,0 +1,2 @@
1
+ /** The whole stylesheet of the player, scoped to `.nc-replay`; the root renders it once. */
2
+ export declare const REPLAY_CSS: string;
@@ -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;
@@ -0,0 +1,2 @@
1
+ /** Mobile-first layout: base is a small phone; each breakpoint (480, 640, 768, 1024, 1280) only overrides upward. */
2
+ export declare const REPLAY_LAYOUT_CSS = "\n.nc-replay{display:grid;grid-template-columns:minmax(0,1fr);gap:12px;padding:12px;box-sizing:border-box;width:100%;max-width:100%;\n background:var(--rp-bg);color:var(--rp-ink);font-family:var(--rp-sans);\n grid-template-areas:\"stage\" \"caption\" \"controls\" \"chapters\"}\n.nc-replay *,.nc-replay *::before,.nc-replay *::after{box-sizing:border-box}\n.nc-replay__stage{grid-area:stage}\n.nc-replay__caption{grid-area:caption}\n.nc-replay__controls{grid-area:controls}\n.nc-replay__chapters{grid-area:chapters}\n.nc-replay__chapter-list{display:grid;grid-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{grid-template-columns:minmax(0,1fr) 340px;grid-template-rows:auto auto 1fr;\n grid-template-areas:\"stage caption\" \"stage chapters\" \"controls chapters\"}\n .nc-replay__chapter-list{grid-template-columns:minmax(0,1fr)}}\n@media (min-width:1280px){.nc-replay{gap:20px;padding:28px;grid-template-columns:minmax(0,1fr) 380px}}\n";
@@ -0,0 +1,20 @@
1
+ /** Mobile-first layout: base is a small phone; each breakpoint (480, 640, 768, 1024, 1280) only overrides upward. */ export const REPLAY_LAYOUT_CSS = `
2
+ .nc-replay{display:grid;grid-template-columns:minmax(0,1fr);gap:12px;padding:12px;box-sizing:border-box;width:100%;max-width:100%;
3
+ background:var(--rp-bg);color:var(--rp-ink);font-family:var(--rp-sans);
4
+ grid-template-areas:"stage" "caption" "controls" "chapters"}
5
+ .nc-replay *,.nc-replay *::before,.nc-replay *::after{box-sizing:border-box}
6
+ .nc-replay__stage{grid-area:stage}
7
+ .nc-replay__caption{grid-area:caption}
8
+ .nc-replay__controls{grid-area:controls}
9
+ .nc-replay__chapters{grid-area:chapters}
10
+ .nc-replay__chapter-list{display:grid;grid-template-columns:minmax(0,1fr);gap:8px;margin:0;padding:0;list-style:none}
11
+ @media (min-width:480px){.nc-replay{gap:14px;padding:16px}}
12
+ @media (min-width:640px){.nc-replay__chapter-list{grid-template-columns:repeat(2,minmax(0,1fr))}}
13
+ @media (min-width:768px){.nc-replay{gap:16px;padding:20px;grid-template-columns:minmax(0,1fr) auto;
14
+ grid-template-areas:"stage stage" "caption controls" "chapters chapters"}
15
+ .nc-replay__chapter-list{grid-template-columns:repeat(3,minmax(0,1fr))}}
16
+ @media (min-width:1024px){.nc-replay{grid-template-columns:minmax(0,1fr) 340px;grid-template-rows:auto auto 1fr;
17
+ grid-template-areas:"stage caption" "stage chapters" "controls chapters"}
18
+ .nc-replay__chapter-list{grid-template-columns:minmax(0,1fr)}}
19
+ @media (min-width:1280px){.nc-replay{gap:20px;padding:28px;grid-template-columns:minmax(0,1fr) 380px}}
20
+ `;
@@ -0,0 +1 @@
1
+ export declare const REPLAY_PALETTE_CSS: string;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The player's palette. Every colour reads a host variable first (`--replay-*`, light; `--replay-*-dark`, dark)
3
+ * and falls back to the default: warm paper and ink with one vermilion accent. Fonts inherit from the host;
4
+ * `--replay-font-display` and `--replay-font-mono` pick the two accent faces.
5
+ */ const LIGHT = '--rp-bg:var(--replay-bg,#f3efe6);--rp-surface:var(--replay-surface,#fffdf8);--rp-surface2:var(--replay-surface2,#e9e3d5);' + '--rp-ink:var(--replay-ink,#1b1a17);--rp-soft:var(--replay-soft,#4a463d);--rp-faint:var(--replay-faint,#6b665a);' + '--rp-line:var(--replay-line,#d6cfbe);--rp-accent:var(--replay-accent,#c8401b);--rp-accent-ink:var(--replay-accent-ink,#a8320f);' + '--rp-on-accent:var(--replay-on-accent,#fffdf8);--rp-bezel:var(--replay-bezel,#1b1a17);' + '--rp-shadow:var(--replay-shadow,0 1px 0 rgb(27 26 23 / .06),0 18px 40px -20px rgb(27 26 23 / .4));';
6
+ const DARK = '--rp-bg:var(--replay-bg-dark,#14130f);--rp-surface:var(--replay-surface-dark,#1d1b16);--rp-surface2:var(--replay-surface2-dark,#2a2720);' + '--rp-ink:var(--replay-ink-dark,#efe9dc);--rp-soft:var(--replay-soft-dark,#c9c1b0);--rp-faint:var(--replay-faint-dark,#a39b88);' + '--rp-line:var(--replay-line-dark,#36322a);--rp-accent:var(--replay-accent-dark,#ff7a4d);--rp-accent-ink:var(--replay-accent-ink-dark,#ff9a73);' + '--rp-on-accent:var(--replay-on-accent-dark,#1b1a17);--rp-bezel:var(--replay-bezel-dark,#0a0908);' + '--rp-shadow:var(--replay-shadow-dark,0 1px 0 rgb(0 0 0 / .4),0 22px 48px -20px rgb(0 0 0 / .8));';
7
+ const FONTS = '--rp-sans:var(--replay-font,inherit);--rp-display:var(--replay-font-display,var(--replay-font,inherit));' + '--rp-mono:var(--replay-font-mono,ui-monospace,monospace);';
8
+ export const REPLAY_PALETTE_CSS = `.nc-replay{${FONTS}${LIGHT}color-scheme:light}` + `.nc-replay[data-theme="dark"],.dark .nc-replay:not([data-theme="light"]){${DARK}color-scheme:dark}`;
@@ -0,0 +1 @@
1
+ export declare const REPLAY_PARTS_CSS: string;
@@ -0,0 +1,56 @@
1
+ const STAGE = `
2
+ .nc-replay__stage{display:flex;flex-direction:column;min-width:0;border:1px solid var(--rp-line);border-radius:14px;overflow:hidden;
3
+ background:var(--rp-bezel);box-shadow:var(--rp-shadow)}
4
+ .nc-replay__bar{display:flex;align-items:center;gap:8px;min-width:0;padding:8px 12px;color:#efe9dc;font:500 12px/1 var(--rp-mono)}
5
+ .nc-replay__dots{display:flex;gap:5px;flex:none}
6
+ .nc-replay__dots i{width:8px;height:8px;border-radius:50%;background:#efe9dc;opacity:.28}
7
+ .nc-replay__title{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;opacity:.8}
8
+ .nc-replay__pill{flex:none;border:1px solid rgb(239 233 220 / .35);border-radius:999px;padding:4px 8px;font-size:10px;letter-spacing:.08em;text-transform:uppercase}
9
+ .nc-replay__view{position:relative;width:100%;overflow:hidden;background:var(--rp-surface)}
10
+ .nc-replay__frame{position:absolute;left:0;top:0;border:0;transform-origin:0 0;pointer-events:none;background:#fff}
11
+ .nc-replay__layer{position:absolute;inset:0;overflow:hidden;pointer-events:none}
12
+ .nc-replay__ring{position:absolute;left:0;top:0;opacity:0;border:2px solid var(--rp-accent);border-radius:8px;
13
+ background:color-mix(in srgb,var(--rp-accent) 12%,transparent);box-shadow:0 0 0 4px color-mix(in srgb,var(--rp-accent) 22%,transparent)}
14
+ .nc-replay__ripple{position:absolute;left:0;top:0;width:56px;height:56px;margin:-28px 0 0 -28px;opacity:0;border-radius:50%;
15
+ border:2px solid var(--rp-accent);background:color-mix(in srgb,var(--rp-accent) 30%,transparent)}
16
+ .nc-replay__cursor{position:absolute;left:0;top:0;width:24px;height:24px;opacity:0;filter:drop-shadow(0 2px 3px rgb(0 0 0 / .35))}
17
+ .nc-replay__veil,.nc-replay__overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding:16px}
18
+ .nc-replay__veil{background:var(--rp-surface);flex-direction:column;gap:10px;color:var(--rp-faint);font:500 13px/1.3 var(--rp-sans)}
19
+ .nc-replay__overlay{background:color-mix(in srgb,var(--rp-bg) 82%,transparent);backdrop-filter:blur(3px)}
20
+ `;
21
+ const TEXT = `
22
+ .nc-replay__panel{min-width:0;border:1px solid var(--rp-line);border-radius:14px;background:var(--rp-surface);padding:14px;box-shadow:var(--rp-shadow)}
23
+ .nc-replay__eyebrow{margin:0 0 6px;color:var(--rp-accent-ink);font:600 11px/1.2 var(--rp-mono);letter-spacing:.08em;text-transform:uppercase}
24
+ .nc-replay__text{margin:0;font:500 17px/1.3 var(--rp-display);letter-spacing:-.01em;overflow-wrap:anywhere}
25
+ .nc-replay__chapter-name{margin:8px 0 0;color:var(--rp-faint);font:500 13px/1.3 var(--rp-sans)}
26
+ .nc-replay__h{margin:0 0 8px;color:var(--rp-faint);font:600 11px/1.2 var(--rp-mono);letter-spacing:.08em;text-transform:uppercase}
27
+ .nc-replay__card{max-width:420px;display:grid;gap:10px;border:1px solid var(--rp-line);border-radius:14px;background:var(--rp-surface);
28
+ padding:18px;color:var(--rp-ink);box-shadow:var(--rp-shadow)}
29
+ .nc-replay__card h3{margin:0;font:600 18px/1.25 var(--rp-display)}
30
+ .nc-replay__card p{margin:0;color:var(--rp-soft);font:400 14px/1.45 var(--rp-sans)}
31
+ .nc-replay__card-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:4px}
32
+ @media (min-width:640px){.nc-replay__text{font-size:19px}}
33
+ @media (min-width:1280px){.nc-replay__text{font-size:21px}}
34
+ `;
35
+ const CONTROLS = `
36
+ .nc-replay__controls{display:flex;flex-wrap:wrap;align-items:center;gap:8px}
37
+ .nc-replay__btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:44px;min-width:44px;padding:0 14px;cursor:pointer;
38
+ border:1px solid var(--rp-line);border-radius:10px;background:var(--rp-surface);color:var(--rp-ink);font:600 14px/1 var(--rp-sans)}
39
+ .nc-replay__btn:hover{border-color:var(--rp-accent)}
40
+ .nc-replay__btn:focus-visible,.nc-replay__chapter button:focus-visible{outline:2px solid var(--rp-accent);outline-offset:2px}
41
+ .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))}
43
+ .nc-replay__seg{display:inline-flex;gap:4px;align-items:center}
44
+ .nc-replay__badge{display:inline-flex;align-items:center;min-height:28px;padding:0 10px;border-radius:999px;background:var(--rp-surface2);
45
+ color:var(--rp-soft);font:600 11px/1 var(--rp-mono)}
46
+ .nc-replay__chapter{border:1px solid var(--rp-line);border-radius:12px;background:var(--rp-surface);overflow:hidden}
47
+ .nc-replay__chapter[aria-current="step"]{border-color:var(--rp-accent)}
48
+ .nc-replay__chapter button{display:grid;gap:8px;width:100%;min-height:44px;padding:10px 12px;cursor:pointer;text-align:left;
49
+ border:0;background:transparent;color:var(--rp-ink);font:600 13px/1.3 var(--rp-sans)}
50
+ .nc-replay__chapter small{color:var(--rp-faint);font:500 11px/1 var(--rp-mono)}
51
+ .nc-replay__meter{height:4px;border-radius:2px;background:var(--rp-surface2);overflow:hidden}
52
+ .nc-replay__fill{display:block;height:100%;width:100%;background:var(--rp-accent);transform-origin:0 50%}
53
+ .nc-replay__skel{border-radius:8px;background:var(--rp-surface2)}
54
+ @media (prefers-reduced-motion:reduce){.nc-replay *{transition:none!important}}
55
+ `;
56
+ export const REPLAY_PARTS_CSS = STAGE + TEXT + CONTROLS;
@@ -0,0 +1,14 @@
1
+ import type { Ms, ReplayChapter, ReplayManifest } from '../../../../src/Client/Replay';
2
+ /** How far the playhead is through a chapter, 0 to 1. */
3
+ export declare function chapterProgress(chapter: ReplayChapter, playhead: Ms): number;
4
+ /** The 1-based position of a step among the recording's steps, or null when there is no current step. */
5
+ export declare function stepPosition(manifest: ReplayManifest, stepId: string | null): {
6
+ index: number;
7
+ count: number;
8
+ } | null;
9
+ /** Every language the recording has text in: English first, then the rest in alphabetical order. */
10
+ export declare function manifestLocales(manifest: ReplayManifest): string[];
11
+ /** The language's English name for a screen reader (`tr` to "Turkish"); the code itself when unknown. */
12
+ export declare function localeName(code: string): string;
13
+ /** The rate as the visitor reads it: `1x`, `2x`, `0.5x`. */
14
+ export declare function rateLabel(rate: number): string;
@@ -0,0 +1,39 @@
1
+ /** How far the playhead is through a chapter, 0 to 1. */ export function chapterProgress(chapter, playhead) {
2
+ const span = chapter.to - chapter.from;
3
+ if (span <= 0) return playhead >= chapter.to ? 1 : 0;
4
+ return Math.min(1, Math.max(0, (playhead - chapter.from) / span));
5
+ }
6
+ /** The 1-based position of a step among the recording's steps, or null when there is no current step. */ export function stepPosition(manifest, stepId) {
7
+ if (stepId === null) return null;
8
+ const at = manifest.steps.findIndex((step)=>step.id === stepId);
9
+ return at < 0 ? null : {
10
+ index: at + 1,
11
+ count: manifest.steps.length
12
+ };
13
+ }
14
+ /** Every language the recording has text in: English first, then the rest in alphabetical order. */ export function manifestLocales(manifest) {
15
+ const found = new Set();
16
+ for (const chapter of manifest.chapters)for (const key of Object.keys(chapter.title))found.add(key);
17
+ for (const step of manifest.steps)for (const key of Object.keys(step.caption))found.add(key);
18
+ found.delete('en');
19
+ return [
20
+ 'en',
21
+ ...[
22
+ ...found
23
+ ].sort()
24
+ ];
25
+ }
26
+ /** The language's English name for a screen reader (`tr` to "Turkish"); the code itself when unknown. */ export function localeName(code) {
27
+ try {
28
+ return new Intl.DisplayNames([
29
+ 'en-US'
30
+ ], {
31
+ type: 'language'
32
+ }).of(code) ?? code;
33
+ } catch {
34
+ return code;
35
+ }
36
+ }
37
+ /** The rate as the visitor reads it: `1x`, `2x`, `0.5x`. */ export function rateLabel(rate) {
38
+ return `${Number.isInteger(rate) ? rate : Number(rate.toFixed(2))}x`;
39
+ }
@@ -0,0 +1,5 @@
1
+ export * from './_components';
2
+ export * from './_hooks';
3
+ export * from './_store';
4
+ export * from './_types';
5
+ export * from './_utils';
@@ -0,0 +1,5 @@
1
+ export * from './_components';
2
+ export * from './_hooks';
3
+ export * from './_store';
4
+ export * from './_types';
5
+ export * from './_utils';
@@ -3,5 +3,6 @@ export * from './channel';
3
3
  export * from './contract';
4
4
  export * from './driver';
5
5
  export * from './realm';
6
+ export * from './recorder';
6
7
  export * from './streams';
7
8
  export * from './timeline';
@@ -3,5 +3,6 @@ export * from './channel';
3
3
  export * from './contract';
4
4
  export * from './driver';
5
5
  export * from './realm';
6
+ export * from './recorder';
6
7
  export * from './streams';
7
8
  export * from './timeline';
@@ -0,0 +1,18 @@
1
+ import type { ReplayTarget } from '../contract/types';
2
+ export interface UnanchoredReport {
3
+ /** `tag "name"`: what the element is, so a developer can find it. */
4
+ element: string;
5
+ /** The nearest ancestor that does carry the attribute, when there is one. */
6
+ nearestAnchor: ReplayTarget | null;
7
+ count: number;
8
+ }
9
+ /** The anchor id of an element: the attribute value, `name#2` when it is the second element carrying it. */
10
+ export declare function anchorOf(element: Element, attribute: string, root: Document): ReplayTarget | null;
11
+ /** The element a click belongs to: the operable one it landed in, else the nearest anchored one; null for plain surface. */
12
+ export declare function clickTarget(target: EventTarget | null, attribute: string): Element | null;
13
+ export declare function describeElement(element: Element): string;
14
+ /** Counts elements that were operated but carry no anchor, grouped by element and nearest anchored ancestor. */
15
+ export declare function createUnanchoredLog(root: Document, attribute: string): {
16
+ add(element: Element): void;
17
+ report: () => UnanchoredReport[];
18
+ };
@@ -0,0 +1,39 @@
1
+ /** Elements a person operates; a click on anything inside one is a click on it. */ const OPERABLE = 'button, a[href], summary, [role="button"], [role="tab"], [role="menuitem"], [role="option"], [role="switch"], input[type="button"], input[type="submit"], input[type="reset"]';
2
+ /** An element no plain click is recorded for: text fields, selects and checks record their own change instead. */ const FIELDS = 'input, textarea, select, option';
3
+ /** The anchor id of an element: the attribute value, `name#2` when it is the second element carrying it. */ export function anchorOf(element, attribute, root) {
4
+ const name = element.getAttribute(attribute);
5
+ if (name === null || name === '') return null;
6
+ const same = Array.from(root.querySelectorAll(`[${attribute}]`)).filter((candidate)=>candidate.getAttribute(attribute) === name);
7
+ const index = same.indexOf(element);
8
+ return index > 0 ? `${name}#${index + 1}` : name;
9
+ }
10
+ /** The element a click belongs to: the operable one it landed in, else the nearest anchored one; null for plain surface. */ export function clickTarget(target, attribute) {
11
+ if (!(target instanceof Element)) return null;
12
+ if (target.closest(FIELDS)) return null;
13
+ return target.closest(OPERABLE) ?? target.closest(`[${attribute}]`);
14
+ }
15
+ export function describeElement(element) {
16
+ const name = element.getAttribute('aria-label') ?? element.getAttribute('name') ?? element.textContent?.trim().slice(0, 40) ?? '';
17
+ return name === '' ? element.tagName.toLowerCase() : `${element.tagName.toLowerCase()} "${name}"`;
18
+ }
19
+ /** Counts elements that were operated but carry no anchor, grouped by element and nearest anchored ancestor. */ export function createUnanchoredLog(root, attribute) {
20
+ const groups = new Map();
21
+ return {
22
+ add (element) {
23
+ const parent = element.parentElement?.closest(`[${attribute}]`) ?? null;
24
+ const nearestAnchor = parent ? anchorOf(parent, attribute, root) : null;
25
+ const label = describeElement(element);
26
+ const key = `${label}|${nearestAnchor ?? ''}`;
27
+ const found = groups.get(key);
28
+ if (found) found.count++;
29
+ else groups.set(key, {
30
+ element: label,
31
+ nearestAnchor,
32
+ count: 1
33
+ });
34
+ },
35
+ report: ()=>[
36
+ ...groups.values()
37
+ ]
38
+ };
39
+ }
@@ -0,0 +1,60 @@
1
+ import type { ChapterChunk, Localized, Ms, RecordedAnswer, RecordedSocket, RecordedStream, ReplayAsset, ReplayManifest, ReplayStep } from '../contract/types';
2
+ import { type PrivacyHit, type PrivacyOptions } from './privacy';
3
+ export interface ChapterSpec {
4
+ id: string;
5
+ title: Localized;
6
+ from: Ms;
7
+ to: Ms;
8
+ /** Playback speed; default 1. */
9
+ rate?: number;
10
+ }
11
+ export interface RecordingMeta {
12
+ id: string;
13
+ title: Localized;
14
+ startPath: string;
15
+ viewport: {
16
+ width: number;
17
+ height: number;
18
+ };
19
+ /** Default `data-tour`. */
20
+ targetAttribute?: string;
21
+ clock: {
22
+ epochMs: number;
23
+ durationMs: Ms;
24
+ };
25
+ source: {
26
+ runId: string;
27
+ recordedAt: string;
28
+ appVersion: string;
29
+ };
30
+ /** What the first paint needs; the caller picks it, the writer invents nothing. */
31
+ boot?: RecordedAnswer[];
32
+ assets?: Record<string, ReplayAsset>;
33
+ privacy?: PrivacyOptions;
34
+ }
35
+ export interface BuildRecordingInput {
36
+ answers: RecordedAnswer[];
37
+ streams: RecordedStream[];
38
+ sockets: RecordedSocket[];
39
+ steps: ReplayStep[];
40
+ /** One chapter `main` over the whole clock when omitted. */
41
+ chapters?: ChapterSpec[];
42
+ meta: RecordingMeta;
43
+ }
44
+ export interface BuiltRecording {
45
+ manifest: ReplayManifest;
46
+ /** Chunk files by their path in the recording folder (`chapter-01.json`). */
47
+ chunks: Record<string, ChapterChunk>;
48
+ /** Sensitive strings found that the identity table did not map. They are removed from the output; fail the build on any. */
49
+ unresolved: PrivacyHit[];
50
+ /** Ids of steps whose English caption is still empty: captions are the one authored text, written before the demo ships. */
51
+ uncaptioned: string[];
52
+ /** Contract violations (`parseManifest` / `parseChapterChunk`); fail the build on any. */
53
+ problems: string[];
54
+ }
55
+ /**
56
+ * Turns what the taps and the step capture recorded into a contract v2 recording: a manifest and one chunk per
57
+ * chapter. Every string is scanned first (see `PrivacyOptions`); nothing is invented, and what a rule finds is
58
+ * removed or mapped and counted in `manifest.redactions`.
59
+ */
60
+ export declare function buildRecording(input: BuildRecordingInput): BuiltRecording;