@wallets-e2e/walkthrough 0.0.0-stage → 0.1.0

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.
@@ -0,0 +1,101 @@
1
+ // No runtime imports: `node --test` runs this file straight from source.
2
+ /** The longest a still frame is held: a page that does not repaint is one frame, however long it lasted. */
3
+ export const MAX_STILL_SECONDS = 12;
4
+ /** How long the cut over a pause lasts: a chain wait of minutes becomes this. */
5
+ export const PAUSE_SECONDS = 0.4;
6
+ /**
7
+ * How long each frame is shown. A frame lasts until the next one, capped; the frame before a pause
8
+ * lasts only `PAUSE_SECONDS`, which is how a long confirmation wait is shortened in the video.
9
+ */
10
+ export function frameDurations(frames, end) {
11
+ return frames.map((frame, index) => {
12
+ const next = frames[index + 1];
13
+ const raw = ((next ? next.at : end) - frame.at) / 1000;
14
+ const capped = next?.gapBefore ? Math.min(raw, PAUSE_SECONDS) : Math.min(raw, MAX_STILL_SECONDS);
15
+ return Math.max(capped, 0.02);
16
+ });
17
+ }
18
+ /**
19
+ * The video time of each chapter: the frames shown before its wall-clock instant, plus how far into
20
+ * the current frame it falls. A chapter noted before the first frame lands at 0.
21
+ */
22
+ export function placeChapters(chapters, frames, durations) {
23
+ let clock = 0;
24
+ const starts = durations.map((duration) => {
25
+ const start = clock;
26
+ clock += duration;
27
+ return start;
28
+ });
29
+ return chapters.map((chapter) => {
30
+ if (frames.length === 0)
31
+ return { ...chapter, at: 0 };
32
+ let index = -1;
33
+ for (let i = frames.length - 1; i >= 0; i--) {
34
+ if (frames[i].at <= chapter.wall) {
35
+ index = i;
36
+ break;
37
+ }
38
+ }
39
+ if (index < 0)
40
+ return { ...chapter, at: 0 };
41
+ const into = Math.min((chapter.wall - frames[index].at) / 1000, durations[index]);
42
+ return { ...chapter, at: Number(Math.max(0, starts[index] + into).toFixed(2)) };
43
+ });
44
+ }
45
+ /** The ffmpeg concat list for the frames: each file with its duration, the last one repeated as ffmpeg requires. */
46
+ export function concatList(files, durations) {
47
+ const lines = files.flatMap((file, index) => [`file '${file}'`, `duration ${durations[index].toFixed(3)}`]);
48
+ const last = files.at(-1);
49
+ if (last)
50
+ lines.push(`file '${last}'`);
51
+ return `ffconcat version 1.0\n${lines.join('\n')}\n`;
52
+ }
53
+ /** Each chapter as a subtitle cue that lasts until the next one, at least one second, never past the video's end. */
54
+ export function buildCues(chapters, seconds) {
55
+ return chapters.map((chapter, index) => {
56
+ const start = Math.max(0, chapter.at);
57
+ const end = Math.min(chapters[index + 1]?.at ?? seconds, seconds);
58
+ return {
59
+ start,
60
+ end: Math.max(end, start + 1),
61
+ text: chapter.step && chapter.kind === 'caption' ? `[${chapter.step}] ${chapter.text}` : chapter.text,
62
+ step: chapter.step,
63
+ kind: chapter.kind,
64
+ };
65
+ });
66
+ }
67
+ /** `HH:MM:SS.mmm` for WebVTT (`separator` "."), `HH:MM:SS,mmm` for SubRip (","). */
68
+ export function stamp(seconds, separator) {
69
+ const totalMs = Math.round(seconds * 1000);
70
+ const ms = totalMs % 1000;
71
+ const s = Math.floor(totalMs / 1000) % 60;
72
+ const m = Math.floor(totalMs / 60_000) % 60;
73
+ const h = Math.floor(totalMs / 3_600_000);
74
+ const pad = (value, width = 2) => String(value).padStart(width, '0');
75
+ return `${pad(h)}:${pad(m)}:${pad(s)}${separator}${pad(ms, 3)}`;
76
+ }
77
+ /** `M:SS`, as a video description lists chapters. */
78
+ export function shortStamp(seconds) {
79
+ return `${Math.floor(seconds / 60)}:${String(Math.floor(seconds % 60)).padStart(2, '0')}`;
80
+ }
81
+ export function toVtt(cues) {
82
+ return `WEBVTT\n\n${cues.map((cue) => `${stamp(cue.start, '.')} --> ${stamp(cue.end, '.')}\n${cue.text}\n`).join('\n')}`;
83
+ }
84
+ export function toSrt(cues) {
85
+ return cues.map((cue, index) => `${index + 1}\n${stamp(cue.start, ',')} --> ${stamp(cue.end, ',')}\n${cue.text}\n`).join('\n');
86
+ }
87
+ /** A chapter starts at each title card and at the first caption of each new step. The first one starts at 0. */
88
+ export function chapterMarks(cues) {
89
+ const marks = [];
90
+ for (const cue of cues) {
91
+ const key = cue.kind === 'card' ? `card:${cue.text}` : `step:${cue.step ?? ''}`;
92
+ if (marks.at(-1)?.key === key)
93
+ continue;
94
+ const label = cue.kind === 'card' ? (cue.step ? `${cue.step}: ${cue.text}` : cue.text) : (cue.step ?? cue.text);
95
+ marks.push({ at: cue.start, label, key });
96
+ }
97
+ if (marks.length > 0)
98
+ marks[0].at = 0;
99
+ return marks.map(({ at, label }) => ({ at, label }));
100
+ }
101
+ //# sourceMappingURL=timeline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeline.js","sourceRoot":"","sources":["../src/timeline.ts"],"names":[],"mappings":"AAAA,yEAAyE;AAiBzE,4GAA4G;AAC5G,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AACpC,iFAAiF;AACjF,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,CAAC;AAEjC;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,MAA4B,EAAE,GAAW;IACtE,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QACjC,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QAC/B,MAAM,GAAG,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;QACvD,MAAM,MAAM,GAAG,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC;QACjG,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AAC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,IAAI,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;IAC5C,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;QAAE,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACtC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;AACvD,CAAC"}
@@ -0,0 +1,139 @@
1
+ import type { Locator, Page } from '@playwright/test';
2
+ import { type WalkthroughTheme } from './theme.js';
3
+ import { type Chapter } from './timeline.js';
4
+ export interface WalkthroughOptions {
5
+ /** Where the run is written: `<outputDir>/frames/` holds the frames, `frames.ffconcat` and `chapters.json`. */
6
+ outputDir: string;
7
+ /** Colours and fonts of everything drawn over the page. Missing fields take the defaults. */
8
+ theme?: Partial<WalkthroughTheme>;
9
+ /** The page's size in CSS pixels. Default 1440×810, which the video shows at `videoWidth`. */
10
+ view?: {
11
+ width: number;
12
+ height: number;
13
+ };
14
+ /** Width of the recorded frames in pixels. Default 1920: a 1440×810 view recorded at 1920×1080. */
15
+ videoWidth?: number;
16
+ /** JPEG quality of the recorded frames, 0–100. Default 92. */
17
+ quality?: number;
18
+ }
19
+ /** A title card: a full-screen slide between parts of the demo. */
20
+ export interface CardOptions {
21
+ /** The small line above the title, e.g. "Live demo" or "Recap". */
22
+ kicker: string;
23
+ title: string;
24
+ body?: string;
25
+ /** A numbered list under the body. */
26
+ items?: string[];
27
+ /** How long the card stays, in ms. Default 5000. */
28
+ holdMs?: number;
29
+ }
30
+ /** What a wallet driver calls with its prompt open: the page of the prompt and the button it is about to press. */
31
+ export type PromptHook = (prompt: Page, button: Locator) => Promise<void>;
32
+ export interface WalletPromptOptions {
33
+ /** The wallet's name, shown on the mirrored prompt's title bar and as the caption chip: "MetaMask". */
34
+ label: string;
35
+ /** The colour of the dot on the title bar. Default: the theme's accent. */
36
+ accent?: string;
37
+ /** Captions shown one after the other while the viewer reads the prompt. */
38
+ explain?: string[];
39
+ /** How long each of those captions stays, in ms. Default 3800. */
40
+ explainHoldMs?: number;
41
+ /** The size the prompt is rendered at before it is mirrored. Default 380×620, an extension popup. */
42
+ promptSize?: {
43
+ width: number;
44
+ height: number;
45
+ };
46
+ /** The action on the page that makes the wallet open its prompt, usually `() => show.press(button)`. */
47
+ trigger: () => Promise<void>;
48
+ /**
49
+ * Hands the trigger and the hook to the wallet driver, e.g.
50
+ * `(trigger, beforeAnswer) => metamaskDriver.confirmTransaction(context, trigger, { beforeAnswer })`.
51
+ * The driver presses the wallet's button when the hook returns.
52
+ */
53
+ answer: (trigger: () => Promise<void>, beforeAnswer: PromptHook) => Promise<void>;
54
+ }
55
+ /** What `stop` leaves on disk. `wallets-e2e-walkthrough` (or `encodeWalkthrough`) turns it into the video. */
56
+ export interface WalkthroughRun {
57
+ outputDir: string;
58
+ framesDir: string;
59
+ concatFile: string;
60
+ chaptersFile: string;
61
+ frames: number;
62
+ chapters: Chapter[];
63
+ }
64
+ /**
65
+ * A presentation-quality recording of one page, for demos of a dapp driven by real wallets:
66
+ * the browser's own screencast, an animated cursor with click ripples, captions with a step chip,
67
+ * full-screen title cards, and each wallet prompt shown inside the same picture.
68
+ *
69
+ * Long waits are not recorded: `pause()` before waiting for a chain, `resume()` after, and the wait
70
+ * becomes a short cut. Captions and cards are logged with their time, which the encoder turns into
71
+ * subtitles and chapters.
72
+ *
73
+ * Record only what may be shown: set the wallets up (the recovery phrase, the password) before
74
+ * `start()`.
75
+ */
76
+ export declare class Walkthrough {
77
+ readonly page: Page;
78
+ readonly outputDir: string;
79
+ readonly theme: WalkthroughTheme;
80
+ private readonly view;
81
+ private readonly scale;
82
+ private readonly quality;
83
+ private readonly framesDir;
84
+ private readonly frames;
85
+ private readonly chapters;
86
+ private cdp;
87
+ private paused;
88
+ private resumed;
89
+ private started;
90
+ constructor(page: Page, options: WalkthroughOptions);
91
+ /** Sizes the page for the recording and mounts the cursor layer. Call once, before `start`. */
92
+ setup(): Promise<void>;
93
+ private applyMetrics;
94
+ /** Makes the page repaint, so the screencast emits a frame even when nothing on it changed. */
95
+ private nudge;
96
+ /** Starts recording. Reload the page first if it was open before `setup`, so the cursor layer is mounted. */
97
+ start(): Promise<void>;
98
+ /** Stops keeping frames: what happens until `resume` becomes a short cut in the video. */
99
+ pause(): void;
100
+ resume(): Promise<void>;
101
+ get isPaused(): boolean;
102
+ /** Re-applies the recording size: another tab taking focus can leave the page rendered at another scale. */
103
+ refresh(): Promise<void>;
104
+ /** Ends the recording and writes the frame list and the chapters next to the frames. */
105
+ stop(): Promise<WalkthroughRun>;
106
+ private mark;
107
+ /** A caption at the bottom of the page, with an optional step chip, held for `holdMs` (default 3200). */
108
+ caption(step: string | null, text: string, holdMs?: number): Promise<void>;
109
+ hideCaption(): Promise<void>;
110
+ /** A full-screen title card. It starts a chapter of the video. */
111
+ card(options: CardOptions): Promise<void>;
112
+ /** Scrolls smoothly to the top or until `target` is in the middle of the page. */
113
+ scrollTo(target: Locator | 'top'): Promise<void>;
114
+ /** Glides the drawn cursor to a point of the page. */
115
+ moveCursor(x: number, y: number): Promise<void>;
116
+ /** A click ripple where the drawn cursor is. */
117
+ ripple(): Promise<void>;
118
+ /** Scrolls `target` into view if needed, glides the cursor over it, ripples, clicks. */
119
+ press(target: Locator): Promise<void>;
120
+ /** Clicks a field and types into it at a human pace. */
121
+ type(target: Locator, text: string, delayMs?: number): Promise<void>;
122
+ /** Clicks a `<select>` and picks an option by value. */
123
+ choose(target: Locator, value: string): Promise<void>;
124
+ /**
125
+ * Shows a wallet's prompt inside the recording, then lets the driver answer it.
126
+ *
127
+ * The screencast records this page only, and a wallet's prompt is a page of its own. While the
128
+ * prompt is open it is screenshotted a few times a second into an overlay drawn like an extension
129
+ * popup at the top right, so the viewer sees exactly what the wallet shows: the account, the
130
+ * network, the fee. The captions in `explain` run meanwhile, then the drawn cursor glides onto the
131
+ * mirrored button and the driver presses the real one.
132
+ */
133
+ walletPrompt(options: WalletPromptOptions): Promise<void>;
134
+ private showWalletFrame;
135
+ private hideWalletFrame;
136
+ }
137
+ /** Creates a walkthrough for `page` and sets it up. Reload the page, then `start()`. */
138
+ export declare function createWalkthrough(page: Page, options: WalkthroughOptions): Promise<Walkthrough>;
139
+ //# sourceMappingURL=walkthrough.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"walkthrough.d.ts","sourceRoot":"","sources":["../src/walkthrough.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAA+B,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAChF,OAAO,EAA6C,KAAK,OAAO,EAAkB,MAAM,eAAe,CAAC;AAExG,MAAM,WAAW,kBAAkB;IACjC,+GAA+G;IAC/G,SAAS,EAAE,MAAM,CAAC;IAClB,6FAA6F;IAC7F,KAAK,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAClC,8FAA8F;IAC9F,IAAI,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACzC,mGAAmG;IACnG,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,mEAAmE;AACnE,MAAM,WAAW,WAAW;IAC1B,mEAAmE;IACnE,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,mHAAmH;AACnH,MAAM,MAAM,UAAU,GAAG,CA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AAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAa3C,wDAAwD;IAClD,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,SAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOvE,wDAAwD;IAClD,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAM3D;;;;;;;;OAQG;IACG,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;YAuDjD,eAAe;YAsBf,eAAe;CAU9B;AAED,wFAAwF;AACxF,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC,CAIrG"}
@@ -0,0 +1,372 @@
1
+ import { mkdirSync, writeFileSync } from 'node:fs';
2
+ import { basename, join } from 'node:path';
3
+ import { DEFAULT_THEME, overlayStyle } from './theme.js';
4
+ import { concatList, frameDurations, placeChapters } from './timeline.js';
5
+ const WALLET_OVERLAY = { right: 28, top: 70, headerHeight: 30 };
6
+ /**
7
+ * A presentation-quality recording of one page, for demos of a dapp driven by real wallets:
8
+ * the browser's own screencast, an animated cursor with click ripples, captions with a step chip,
9
+ * full-screen title cards, and each wallet prompt shown inside the same picture.
10
+ *
11
+ * Long waits are not recorded: `pause()` before waiting for a chain, `resume()` after, and the wait
12
+ * becomes a short cut. Captions and cards are logged with their time, which the encoder turns into
13
+ * subtitles and chapters.
14
+ *
15
+ * Record only what may be shown: set the wallets up (the recovery phrase, the password) before
16
+ * `start()`.
17
+ */
18
+ export class Walkthrough {
19
+ page;
20
+ outputDir;
21
+ theme;
22
+ view;
23
+ scale;
24
+ quality;
25
+ framesDir;
26
+ frames = [];
27
+ chapters = [];
28
+ cdp = null;
29
+ paused = true;
30
+ resumed = false;
31
+ started = false;
32
+ constructor(page, options) {
33
+ this.page = page;
34
+ this.outputDir = options.outputDir;
35
+ this.framesDir = join(options.outputDir, 'frames');
36
+ this.theme = { ...DEFAULT_THEME, ...options.theme };
37
+ this.view = options.view ?? { width: 1440, height: 810 };
38
+ this.scale = (options.videoWidth ?? 1920) / this.view.width;
39
+ this.quality = options.quality ?? 92;
40
+ }
41
+ /** Sizes the page for the recording and mounts the cursor layer. Call once, before `start`. */
42
+ async setup() {
43
+ const cdp = await this.page.context().newCDPSession(this.page);
44
+ this.cdp = cdp;
45
+ await this.page.setViewportSize(this.view);
46
+ await this.applyMetrics();
47
+ // The overlay layer survives navigations; the cursor position carries over in sessionStorage.
48
+ await this.page.addInitScript(({ style, paper, ink }) => {
49
+ const mount = () => {
50
+ if (document.getElementById('wt-cursor'))
51
+ return;
52
+ const css = document.createElement('style');
53
+ css.id = 'wt-style';
54
+ css.textContent = style;
55
+ document.head.append(css);
56
+ const cursor = document.createElement('div');
57
+ cursor.id = 'wt-cursor';
58
+ const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
59
+ svg.setAttribute('width', '24');
60
+ svg.setAttribute('height', '24');
61
+ svg.setAttribute('viewBox', '0 0 24 24');
62
+ const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
63
+ path.setAttribute('d', 'M4 2l16 10-7 1.5L9.5 21z');
64
+ path.setAttribute('fill', paper);
65
+ path.setAttribute('stroke', ink);
66
+ path.setAttribute('stroke-width', '1.6');
67
+ path.setAttribute('stroke-linejoin', 'round');
68
+ svg.append(path);
69
+ cursor.append(svg);
70
+ const [x, y] = (sessionStorage.getItem('wt-cursor') ?? '720,420').split(',').map(Number);
71
+ cursor.style.transition = 'none';
72
+ cursor.style.transform = `translate(${x}px,${y}px)`;
73
+ document.body.append(cursor);
74
+ requestAnimationFrame(() => { cursor.style.transition = ''; });
75
+ };
76
+ if (document.body)
77
+ mount();
78
+ else
79
+ document.addEventListener('DOMContentLoaded', mount);
80
+ }, { style: overlayStyle(this.theme), paper: this.theme.paper, ink: this.theme.ink });
81
+ cdp.on('Page.screencastFrame', (event) => {
82
+ void cdp.send('Page.screencastFrameAck', { sessionId: event.sessionId }).catch(() => undefined);
83
+ if (this.paused || !this.started)
84
+ return;
85
+ const file = join(this.framesDir, `${String(this.frames.length).padStart(6, '0')}.jpg`);
86
+ writeFileSync(file, Buffer.from(event.data, 'base64'));
87
+ this.frames.push({ file, at: Date.now(), gapBefore: this.resumed });
88
+ this.resumed = false;
89
+ });
90
+ }
91
+ async applyMetrics() {
92
+ await this.cdp?.send('Emulation.setDeviceMetricsOverride', { width: this.view.width, height: this.view.height, deviceScaleFactor: this.scale, mobile: false });
93
+ }
94
+ /** Makes the page repaint, so the screencast emits a frame even when nothing on it changed. */
95
+ async nudge() {
96
+ await this.page.evaluate(() => document.body.style.setProperty('--wt-tick', String(Date.now()))).catch(() => undefined);
97
+ }
98
+ /** Starts recording. Reload the page first if it was open before `setup`, so the cursor layer is mounted. */
99
+ async start() {
100
+ if (!this.cdp)
101
+ await this.setup();
102
+ mkdirSync(this.framesDir, { recursive: true });
103
+ this.started = true;
104
+ this.paused = false;
105
+ await this.cdp?.send('Page.startScreencast', { format: 'jpeg', quality: this.quality, everyNthFrame: 1 });
106
+ }
107
+ /** Stops keeping frames: what happens until `resume` becomes a short cut in the video. */
108
+ pause() {
109
+ this.paused = true;
110
+ }
111
+ async resume() {
112
+ this.paused = false;
113
+ this.resumed = true;
114
+ await this.nudge();
115
+ }
116
+ get isPaused() {
117
+ return this.paused;
118
+ }
119
+ /** Re-applies the recording size: another tab taking focus can leave the page rendered at another scale. */
120
+ async refresh() {
121
+ await this.applyMetrics();
122
+ await this.nudge();
123
+ await this.page.waitForTimeout(300);
124
+ }
125
+ /** Ends the recording and writes the frame list and the chapters next to the frames. */
126
+ async stop() {
127
+ this.paused = true;
128
+ await this.cdp?.send('Page.stopScreencast').catch(() => undefined);
129
+ const durations = frameDurations(this.frames, Date.now());
130
+ const chapters = placeChapters(this.chapters, this.frames, durations);
131
+ mkdirSync(this.framesDir, { recursive: true });
132
+ const concatFile = join(this.framesDir, 'frames.ffconcat');
133
+ const chaptersFile = join(this.framesDir, 'chapters.json');
134
+ writeFileSync(concatFile, concatList(this.frames.map((frame) => basename(frame.file)), durations));
135
+ writeFileSync(chaptersFile, `${JSON.stringify(chapters, null, 2)}\n`);
136
+ return { outputDir: this.outputDir, framesDir: this.framesDir, concatFile, chaptersFile, frames: this.frames.length, chapters };
137
+ }
138
+ mark(step, text, kind) {
139
+ this.chapters.push({ wall: Date.now(), at: 0, step, text, kind });
140
+ }
141
+ /** A caption at the bottom of the page, with an optional step chip, held for `holdMs` (default 3200). */
142
+ async caption(step, text, holdMs = 3200) {
143
+ this.mark(step, text, 'caption');
144
+ await this.page.evaluate(({ step, text }) => {
145
+ let el = document.getElementById('wt-caption');
146
+ if (!el) {
147
+ el = document.createElement('div');
148
+ el.id = 'wt-caption';
149
+ document.body.append(el);
150
+ }
151
+ el.classList.remove('show');
152
+ el.replaceChildren();
153
+ if (step) {
154
+ const chip = document.createElement('b');
155
+ chip.textContent = step;
156
+ el.append(chip);
157
+ }
158
+ const span = document.createElement('span');
159
+ span.textContent = text;
160
+ el.append(span);
161
+ requestAnimationFrame(() => el?.classList.add('show'));
162
+ }, { step, text });
163
+ await this.page.waitForTimeout(holdMs);
164
+ }
165
+ async hideCaption() {
166
+ await this.page.evaluate(() => document.getElementById('wt-caption')?.classList.remove('show')).catch(() => undefined);
167
+ }
168
+ /** A full-screen title card. It starts a chapter of the video. */
169
+ async card(options) {
170
+ const { kicker, title, body = '', items = [], holdMs = 5000 } = options;
171
+ this.mark(kicker, title, 'card');
172
+ await this.page.evaluate(({ kicker, title, body, items }) => {
173
+ document.getElementById('wt-card')?.remove();
174
+ const el = document.createElement('div');
175
+ el.id = 'wt-card';
176
+ const k = document.createElement('div');
177
+ k.className = 'k';
178
+ k.textContent = kicker;
179
+ const h = document.createElement('h1');
180
+ h.textContent = title;
181
+ el.append(k, h);
182
+ if (body) {
183
+ const p = document.createElement('p');
184
+ p.textContent = body;
185
+ el.append(p);
186
+ }
187
+ if (items.length > 0) {
188
+ const list = document.createElement('ol');
189
+ items.forEach((text, index) => {
190
+ const li = document.createElement('li');
191
+ const number = document.createElement('span');
192
+ number.textContent = String(index + 1).padStart(2, '0');
193
+ li.append(number, document.createTextNode(text));
194
+ list.append(li);
195
+ });
196
+ el.append(list);
197
+ }
198
+ document.body.append(el);
199
+ requestAnimationFrame(() => el.classList.add('show'));
200
+ }, { kicker, title, body, items });
201
+ await this.page.waitForTimeout(holdMs);
202
+ await this.page.evaluate(() => {
203
+ const el = document.getElementById('wt-card');
204
+ if (!el)
205
+ return;
206
+ el.classList.remove('show');
207
+ setTimeout(() => el.remove(), 600);
208
+ });
209
+ await this.page.waitForTimeout(700);
210
+ }
211
+ /** Scrolls smoothly to the top or until `target` is in the middle of the page. */
212
+ async scrollTo(target) {
213
+ if (target === 'top')
214
+ await this.page.evaluate(() => window.scrollTo({ top: 0, behavior: 'smooth' }));
215
+ else
216
+ await target.evaluate((el) => el.scrollIntoView({ behavior: 'smooth', block: 'center' }));
217
+ await this.page.waitForTimeout(1000);
218
+ }
219
+ /** Glides the drawn cursor to a point of the page. */
220
+ async moveCursor(x, y) {
221
+ await this.page.evaluate(({ x, y }) => {
222
+ const cursor = document.getElementById('wt-cursor');
223
+ if (cursor)
224
+ cursor.style.transform = `translate(${x}px,${y}px)`;
225
+ sessionStorage.setItem('wt-cursor', `${x},${y}`);
226
+ }, { x: Math.round(x), y: Math.round(y) });
227
+ await this.page.waitForTimeout(800);
228
+ }
229
+ /** A click ripple where the drawn cursor is. */
230
+ async ripple() {
231
+ await this.page.evaluate(() => {
232
+ const [x, y] = (sessionStorage.getItem('wt-cursor') ?? '0,0').split(',').map(Number);
233
+ const ring = document.createElement('div');
234
+ ring.className = 'wt-ripple';
235
+ ring.style.left = `${x}px`;
236
+ ring.style.top = `${y}px`;
237
+ document.body.append(ring);
238
+ setTimeout(() => ring.remove(), 700);
239
+ });
240
+ }
241
+ /** Scrolls `target` into view if needed, glides the cursor over it, ripples, clicks. */
242
+ async press(target) {
243
+ await target.evaluate((el) => {
244
+ const box = el.getBoundingClientRect();
245
+ if (box.top < 90 || box.bottom > window.innerHeight - 120)
246
+ el.scrollIntoView({ behavior: 'smooth', block: 'center' });
247
+ });
248
+ await this.page.waitForTimeout(700);
249
+ const box = await target.boundingBox();
250
+ if (box)
251
+ await this.moveCursor(box.x + Math.min(box.width / 2, 60), box.y + box.height / 2);
252
+ await this.ripple();
253
+ await target.click();
254
+ await this.page.waitForTimeout(400);
255
+ }
256
+ /** Clicks a field and types into it at a human pace. */
257
+ async type(target, text, delayMs = 110) {
258
+ await this.press(target);
259
+ await target.fill('');
260
+ await target.pressSequentially(text, { delay: delayMs });
261
+ await this.page.waitForTimeout(500);
262
+ }
263
+ /** Clicks a `<select>` and picks an option by value. */
264
+ async choose(target, value) {
265
+ await this.press(target);
266
+ await target.selectOption(value);
267
+ await this.page.waitForTimeout(700);
268
+ }
269
+ /**
270
+ * Shows a wallet's prompt inside the recording, then lets the driver answer it.
271
+ *
272
+ * The screencast records this page only, and a wallet's prompt is a page of its own. While the
273
+ * prompt is open it is screenshotted a few times a second into an overlay drawn like an extension
274
+ * popup at the top right, so the viewer sees exactly what the wallet shows: the account, the
275
+ * network, the fee. The captions in `explain` run meanwhile, then the drawn cursor glides onto the
276
+ * mirrored button and the driver presses the real one.
277
+ */
278
+ async walletPrompt(options) {
279
+ const { label, explain = [], explainHoldMs = 3800, promptSize = { width: 380, height: 620 } } = options;
280
+ const accent = options.accent ?? this.theme.accent;
281
+ let mirroring = false;
282
+ let loop = Promise.resolve();
283
+ // The wallet's window takes focus the moment it opens: frames from then on are left out, until
284
+ // this page is back in front with the prompt mirrored on it.
285
+ const trigger = async () => {
286
+ await options.trigger();
287
+ this.pause();
288
+ };
289
+ const beforeAnswer = async (prompt, button) => {
290
+ await prompt.setViewportSize(promptSize).catch(() => undefined);
291
+ await button.waitFor({ state: 'visible', timeout: 60_000 });
292
+ await this.page.bringToFront();
293
+ await this.refresh();
294
+ await this.resume();
295
+ mirroring = true;
296
+ loop = (async () => {
297
+ while (mirroring) {
298
+ const png = await prompt.screenshot({ type: 'png' }).catch(() => null);
299
+ if (png)
300
+ await this.showWalletFrame(png, label, accent, promptSize.width).catch(() => undefined);
301
+ await new Promise((resolve) => setTimeout(resolve, 280));
302
+ }
303
+ })();
304
+ await this.page.waitForTimeout(900);
305
+ for (const line of explain)
306
+ await this.caption(label, line, explainHoldMs);
307
+ // The mirror is drawn at the prompt's own width, so the button is where the prompt has it.
308
+ const box = await button.boundingBox().catch(() => null);
309
+ if (box) {
310
+ const left = this.view.width - WALLET_OVERLAY.right - promptSize.width;
311
+ await this.moveCursor(left + box.x + box.width / 2, WALLET_OVERLAY.top + WALLET_OVERLAY.headerHeight + box.y + box.height / 2);
312
+ await this.ripple();
313
+ }
314
+ };
315
+ try {
316
+ await options.answer(trigger, beforeAnswer);
317
+ if (mirroring)
318
+ await this.page.waitForTimeout(1200);
319
+ }
320
+ finally {
321
+ mirroring = false;
322
+ await loop;
323
+ await this.hideWalletFrame();
324
+ // A prompt that never came leaves the recording paused by the trigger: pick it up again.
325
+ if (this.started && this.paused) {
326
+ await this.page.bringToFront().catch(() => undefined);
327
+ await this.refresh().catch(() => undefined);
328
+ await this.resume();
329
+ }
330
+ }
331
+ }
332
+ async showWalletFrame(png, label, accent, width) {
333
+ await this.page.evaluate(({ src, label, accent, width, right, top }) => {
334
+ let el = document.getElementById('wt-wallet');
335
+ if (!el) {
336
+ el = document.createElement('div');
337
+ el.id = 'wt-wallet';
338
+ el.style.right = `${right}px`;
339
+ el.style.top = `${top}px`;
340
+ el.style.width = `${width}px`;
341
+ const header = document.createElement('header');
342
+ const dot = document.createElement('i');
343
+ dot.style.background = accent;
344
+ header.append(dot, document.createTextNode(label));
345
+ const img = document.createElement('img');
346
+ el.append(header, img);
347
+ document.body.append(el);
348
+ requestAnimationFrame(() => el?.classList.add('show'));
349
+ }
350
+ el.querySelector('img').src = src;
351
+ }, { src: `data:image/png;base64,${png.toString('base64')}`, label, accent, width, right: WALLET_OVERLAY.right, top: WALLET_OVERLAY.top });
352
+ }
353
+ async hideWalletFrame() {
354
+ const shown = await this.page.evaluate(() => {
355
+ const el = document.getElementById('wt-wallet');
356
+ if (!el)
357
+ return false;
358
+ el.classList.remove('show');
359
+ setTimeout(() => el.remove(), 400);
360
+ return true;
361
+ }).catch(() => false);
362
+ if (shown)
363
+ await this.page.waitForTimeout(450);
364
+ }
365
+ }
366
+ /** Creates a walkthrough for `page` and sets it up. Reload the page, then `start()`. */
367
+ export async function createWalkthrough(page, options) {
368
+ const walkthrough = new Walkthrough(page, options);
369
+ await walkthrough.setup();
370
+ return walkthrough;
371
+ }
372
+ //# sourceMappingURL=walkthrough.js.map