@gnawbit/tabretake 0.5.0 → 0.5.1
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/CHANGELOG.md +6 -0
- package/README.md +8 -8
- package/SKILL.md +11 -13
- package/bin/tabretake.mjs +6 -1
- package/package.json +2 -3
- package/references/rendering.md +5 -5
- package/references/story.md +16 -22
- package/scripts/capture.mjs +6 -18
- package/scripts/cli.mjs +3 -1
- package/scripts/init.mjs +4 -13
- package/scripts/lib/browser.mjs +51 -11
- package/scripts/lib/config.mjs +1 -1
- package/scripts/lib/ffmpeg.mjs +9 -12
- package/scripts/lib/options.mjs +148 -138
- package/scripts/lib/themes.mjs +11 -0
- package/scripts/mark.mjs +26 -13
- package/scripts/plan.mjs +1 -1
- package/scripts/record.mjs +24 -83
- package/scripts/render.mjs +11 -35
- package/README.zh-CN.md +0 -523
- package/bin/demo-reel.mjs +0 -2
package/scripts/lib/options.mjs
CHANGED
|
@@ -1,138 +1,148 @@
|
|
|
1
|
-
import { parseArgs } from "node:util";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
},
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
json: { type: "boolean", default: false },
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
if (
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
1
|
+
import { parseArgs } from "node:util";
|
|
2
|
+
import { commandError } from "./report.mjs";
|
|
3
|
+
|
|
4
|
+
const authOptions = {
|
|
5
|
+
login: { type: "boolean", default: false },
|
|
6
|
+
"storage-state": { type: "string" },
|
|
7
|
+
"save-state": { type: "string" },
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const browserOptions = {
|
|
11
|
+
proxy: { type: "string" },
|
|
12
|
+
viewport: { type: "string" },
|
|
13
|
+
browser: { type: "string", default: "auto" },
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const renderStyleOptions = {
|
|
17
|
+
"no-gif": { type: "boolean", default: false },
|
|
18
|
+
"no-captions": { type: "boolean", default: false },
|
|
19
|
+
vertical: { type: "boolean", default: false },
|
|
20
|
+
zoom: { type: "string", default: "1.28" },
|
|
21
|
+
"vertical-zoom": { type: "string" },
|
|
22
|
+
"zoom-duration": { type: "string" },
|
|
23
|
+
"poster-at": { type: "string" },
|
|
24
|
+
preset: { type: "string" },
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const recordOptions = {
|
|
28
|
+
json: { type: "boolean", default: false },
|
|
29
|
+
config: { type: "string" },
|
|
30
|
+
url: { type: "string" },
|
|
31
|
+
out: { type: "string" },
|
|
32
|
+
...authOptions,
|
|
33
|
+
...browserOptions,
|
|
34
|
+
headed: { type: "boolean", default: false },
|
|
35
|
+
scale: { type: "string" },
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const commandOptions = {
|
|
39
|
+
setup: { "with-deps": { type: "boolean", default: false } },
|
|
40
|
+
init: {
|
|
41
|
+
json: { type: "boolean", default: false },
|
|
42
|
+
url: { type: "string" },
|
|
43
|
+
out: { type: "string", default: "demo.json" },
|
|
44
|
+
auto: { type: "boolean", default: false },
|
|
45
|
+
browser: { type: "string", default: "auto" },
|
|
46
|
+
preset: { type: "string" },
|
|
47
|
+
},
|
|
48
|
+
plan: {
|
|
49
|
+
json: { type: "boolean", default: false },
|
|
50
|
+
url: { type: "string" },
|
|
51
|
+
out: { type: "string", default: "plan.json" },
|
|
52
|
+
login: { type: "boolean", default: false },
|
|
53
|
+
"storage-state": { type: "string" },
|
|
54
|
+
...browserOptions,
|
|
55
|
+
headless: { type: "boolean", default: true },
|
|
56
|
+
},
|
|
57
|
+
record: recordOptions,
|
|
58
|
+
run: {
|
|
59
|
+
...recordOptions,
|
|
60
|
+
...renderStyleOptions,
|
|
61
|
+
},
|
|
62
|
+
capture: {
|
|
63
|
+
json: { type: "boolean", default: false },
|
|
64
|
+
url: { type: "string" },
|
|
65
|
+
out: { type: "string", default: "demo.json" },
|
|
66
|
+
...authOptions,
|
|
67
|
+
...browserOptions,
|
|
68
|
+
scale: { type: "string" },
|
|
69
|
+
force: { type: "boolean", default: false },
|
|
70
|
+
run: { type: "boolean", default: false },
|
|
71
|
+
"media-out": { type: "string" },
|
|
72
|
+
...renderStyleOptions,
|
|
73
|
+
},
|
|
74
|
+
mark: {
|
|
75
|
+
json: { type: "boolean", default: false },
|
|
76
|
+
video: { type: "string" },
|
|
77
|
+
out: { type: "string", default: "story-video.json" },
|
|
78
|
+
preset: { type: "string" },
|
|
79
|
+
port: { type: "string", default: "0" },
|
|
80
|
+
"media-out": { type: "string" },
|
|
81
|
+
"no-open": { type: "boolean", default: false },
|
|
82
|
+
},
|
|
83
|
+
render: {
|
|
84
|
+
json: { type: "boolean", default: false },
|
|
85
|
+
config: { type: "string" },
|
|
86
|
+
video: { type: "string" },
|
|
87
|
+
out: { type: "string" },
|
|
88
|
+
...renderStyleOptions,
|
|
89
|
+
},
|
|
90
|
+
serve: {
|
|
91
|
+
port: { type: "string", default: "4173" },
|
|
92
|
+
dir: { type: "string", default: "examples/site" },
|
|
93
|
+
},
|
|
94
|
+
demo: {
|
|
95
|
+
out: { type: "string", default: "demo" },
|
|
96
|
+
port: { type: "string", default: "4173" },
|
|
97
|
+
story: { type: "string", default: "onboarding" },
|
|
98
|
+
browser: { type: "string", default: "auto" },
|
|
99
|
+
preset: { type: "string" },
|
|
100
|
+
},
|
|
101
|
+
doctor: { json: { type: "boolean", default: false } },
|
|
102
|
+
capabilities: { json: { type: "boolean", default: false } },
|
|
103
|
+
validate: { config: { type: "string" }, json: { type: "boolean", default: false } },
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
commandOptions.preview = {
|
|
107
|
+
...commandOptions.record,
|
|
108
|
+
headless: { type: "boolean", default: false },
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export function parseCommand(command, argv) {
|
|
112
|
+
return parseArgs({ args: argv, options: commandOptions[command], strict: true, allowPositionals: false });
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function parseViewport(value, fallback = { width: 1440, height: 810 }) {
|
|
116
|
+
if (value === undefined) return fallback;
|
|
117
|
+
if (!/^[1-9]\d*x[1-9]\d*$/.test(value)) {
|
|
118
|
+
throw new Error("--viewport must be WIDTHxHEIGHT with positive integers");
|
|
119
|
+
}
|
|
120
|
+
const [width, height] = value.split("x").map(Number);
|
|
121
|
+
return { width, height };
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function parseHttpUrl(raw, missingMessage = "Provide --url https://your-app.com") {
|
|
125
|
+
if (!raw) throw new Error(missingMessage);
|
|
126
|
+
let url;
|
|
127
|
+
try {
|
|
128
|
+
url = new URL(raw);
|
|
129
|
+
} catch {
|
|
130
|
+
throw new Error("Use a complete http:// or https:// URL");
|
|
131
|
+
}
|
|
132
|
+
if (!["http:", "https:"].includes(url.protocol)) {
|
|
133
|
+
throw new Error("Use a complete http:// or https:// URL");
|
|
134
|
+
}
|
|
135
|
+
return url;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function parseScale(cliValue, fallback = 1) {
|
|
139
|
+
const scale = cliValue === undefined
|
|
140
|
+
? fallback
|
|
141
|
+
: (String(cliValue).trim() === "" ? NaN : Number(cliValue));
|
|
142
|
+
if (scale !== 1 && scale !== 2) {
|
|
143
|
+
throw commandError("INVALID_CONFIG", "scale / --scale must be 1 or 2", {
|
|
144
|
+
hint: "Choose 1 (standard) or 2 (HiDPI Retina).",
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
return scale;
|
|
148
|
+
}
|
package/scripts/lib/themes.mjs
CHANGED
|
@@ -111,6 +111,17 @@ export const BRAND_PRESETS = {
|
|
|
111
111
|
|
|
112
112
|
export const PRESET_NAMES = Object.keys(BRAND_PRESETS);
|
|
113
113
|
|
|
114
|
+
export function hexToRgb(hex, fallback = "#070a12") {
|
|
115
|
+
const parse = (value) => {
|
|
116
|
+
const clean = String(value || "").replace("#", "");
|
|
117
|
+
const full = clean.length === 3 ? clean.split("").map((c) => c + c).join("") : clean;
|
|
118
|
+
if (!/^[0-9a-fA-F]{6}$/.test(full)) return null;
|
|
119
|
+
const n = Number.parseInt(full, 16);
|
|
120
|
+
return { r: (n >> 16) & 255, g: (n >> 8) & 255, b: n & 255 };
|
|
121
|
+
};
|
|
122
|
+
return parse(hex) || parse(fallback) || { r: 7, g: 10, b: 18 };
|
|
123
|
+
}
|
|
124
|
+
|
|
114
125
|
export function resolveTheme(brand = {}, overridePreset) {
|
|
115
126
|
const presetName = overridePreset || brand?.preset || "midnight";
|
|
116
127
|
const base = BRAND_PRESETS[presetName];
|
package/scripts/mark.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { createServer } from "node:http";
|
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { parseCommand } from "./lib/options.mjs";
|
|
8
8
|
import { assertConfig, inspectConfig } from "./lib/config.mjs";
|
|
9
|
-
import {
|
|
9
|
+
import { probeVideoMeta } from "./lib/ffmpeg.mjs";
|
|
10
10
|
import { commandError, createReporter } from "./lib/report.mjs";
|
|
11
11
|
import { resolveTheme } from "./lib/themes.mjs";
|
|
12
12
|
import { executeRender } from "./render.mjs";
|
|
@@ -270,14 +270,30 @@ function renderMarkHtml({ token, duration, width, height, preset, videoName, ini
|
|
|
270
270
|
</html>`;
|
|
271
271
|
}
|
|
272
272
|
|
|
273
|
-
export function buildMarksConfig({ videoPath, outPath, displayUrl, preset, marks = [] }) {
|
|
273
|
+
export function buildMarksConfig({ videoPath, outPath, displayUrl, preset, marks = [], existing = null }) {
|
|
274
274
|
const rel = path.relative(path.dirname(outPath), videoPath);
|
|
275
275
|
const video = rel && !path.isAbsolute(rel) ? rel.replace(/\\/g, "/") : videoPath;
|
|
276
|
-
const
|
|
276
|
+
const existingBrand = existing?.brand || {};
|
|
277
|
+
const overridePreset = preset && preset !== existingBrand.preset ? preset : undefined;
|
|
278
|
+
const theme = resolveTheme(existingBrand, overridePreset);
|
|
279
|
+
const brand = {
|
|
280
|
+
preset: theme.preset,
|
|
281
|
+
background: theme.background,
|
|
282
|
+
accent: theme.accent,
|
|
283
|
+
...(existingBrand.frame ? { frame: existingBrand.frame } : {}),
|
|
284
|
+
};
|
|
277
285
|
const config = {
|
|
278
|
-
|
|
286
|
+
...(existing?.$schema ? { $schema: existing.$schema } : {}),
|
|
287
|
+
...(existing?.out ? { out: existing.out } : {}),
|
|
288
|
+
...(existing?.viewport ? { viewport: existing.viewport } : {}),
|
|
289
|
+
...(existing?.vertical ? { vertical: existing.vertical } : {}),
|
|
290
|
+
...(existing?.posterAt !== undefined ? { posterAt: existing.posterAt } : {}),
|
|
291
|
+
...(existing?.zoomDuration !== undefined ? { zoomDuration: existing.zoomDuration } : {}),
|
|
292
|
+
...(existing?.duration !== undefined ? { duration: existing.duration } : {}),
|
|
293
|
+
...(existing?.url ? { url: existing.url } : {}),
|
|
294
|
+
displayUrl: displayUrl || existing?.displayUrl || "your-app.com",
|
|
279
295
|
video,
|
|
280
|
-
brand
|
|
296
|
+
brand,
|
|
281
297
|
marks: marks.map((m) => ({
|
|
282
298
|
t: Number(m.t ?? 0),
|
|
283
299
|
...(m.duration !== undefined ? { duration: Number(m.duration) } : {}),
|
|
@@ -301,14 +317,7 @@ export async function startMarkServer({
|
|
|
301
317
|
} = {}) {
|
|
302
318
|
const resolvedVideo = path.resolve(videoPath);
|
|
303
319
|
const resolvedOut = path.resolve(outPath || "story-video.json");
|
|
304
|
-
const
|
|
305
|
-
const stream = (info.streams || []).find((s) => s.codec_type === "video");
|
|
306
|
-
const width = Number(stream?.width || 0);
|
|
307
|
-
const height = Number(stream?.height || 0);
|
|
308
|
-
const duration = Number(info.format?.duration || 0);
|
|
309
|
-
if (!width || !height || !duration) {
|
|
310
|
-
throw new Error(`Could not read video metadata: ${resolvedVideo}`);
|
|
311
|
-
}
|
|
320
|
+
const { width, height, duration } = await probeVideoMeta(resolvedVideo);
|
|
312
321
|
|
|
313
322
|
const token = crypto.randomBytes(16).toString("hex");
|
|
314
323
|
const artifacts = new Map();
|
|
@@ -318,9 +327,11 @@ export async function startMarkServer({
|
|
|
318
327
|
let initialMarks = [];
|
|
319
328
|
let initialDisplayUrl = "your-app.com";
|
|
320
329
|
let initialPreset = preset;
|
|
330
|
+
let existingConfig = null;
|
|
321
331
|
try {
|
|
322
332
|
const existing = JSON.parse(await readFile(resolvedOut, "utf8"));
|
|
323
333
|
if (inspectConfig(existing, { kind: "marks" }).ok) {
|
|
334
|
+
existingConfig = existing;
|
|
324
335
|
initialMarks = existing.marks || [];
|
|
325
336
|
if (existing.displayUrl) initialDisplayUrl = existing.displayUrl;
|
|
326
337
|
if (!initialPreset && existing.brand?.preset) initialPreset = existing.brand.preset;
|
|
@@ -337,9 +348,11 @@ export async function startMarkServer({
|
|
|
337
348
|
displayUrl: body.displayUrl,
|
|
338
349
|
preset: body.preset || preset,
|
|
339
350
|
marks: body.marks || [],
|
|
351
|
+
existing: existingConfig,
|
|
340
352
|
});
|
|
341
353
|
await mkdir(path.dirname(resolvedOut), { recursive: true });
|
|
342
354
|
await writeFile(resolvedOut, JSON.stringify(cfg, null, 2) + "\n", "utf8");
|
|
355
|
+
existingConfig = cfg;
|
|
343
356
|
artifacts.set(resolvedOut, { kind: "marks", path: resolvedOut });
|
|
344
357
|
return cfg;
|
|
345
358
|
};
|
package/scripts/plan.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { launchBrowser, loginAndSave, newContext } from "./lib/browser.mjs";
|
|
|
5
5
|
import { createReporter, requireInteractiveLogin } from "./lib/report.mjs";
|
|
6
6
|
import { navigate } from "./lib/navigation.mjs";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
async function collectElements(page, { includeHints = false } = {}) {
|
|
9
9
|
return page.evaluate((withHints) => {
|
|
10
10
|
function cssPath(el) {
|
|
11
11
|
if (!el || el.nodeType !== 1) return "";
|
package/scripts/record.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { copyFile, mkdir, rm, writeFile } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { parseCommand, parseViewport } from "./lib/options.mjs";
|
|
3
|
+
import { parseCommand, parseScale, parseViewport } from "./lib/options.mjs";
|
|
4
4
|
import {
|
|
5
5
|
clickAndType,
|
|
6
6
|
dragBy,
|
|
@@ -39,15 +39,7 @@ export async function executeRecord(values, { command = "record", reporter = cre
|
|
|
39
39
|
width: 1440,
|
|
40
40
|
height: 810,
|
|
41
41
|
});
|
|
42
|
-
const
|
|
43
|
-
? (config.scale ?? 1)
|
|
44
|
-
: (String(values.scale).trim() === "" ? NaN : Number(values.scale));
|
|
45
|
-
if (scaleInput !== 1 && scaleInput !== 2) {
|
|
46
|
-
throw commandError("INVALID_CONFIG", "scale / --scale must be 1 or 2", {
|
|
47
|
-
hint: "Choose 1 (standard) or 2 (HiDPI Retina).",
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
const scale = scaleInput;
|
|
42
|
+
const scale = parseScale(values.scale, config.scale ?? 1);
|
|
51
43
|
assertConfig({ ...config, url, viewport, scale }, { kind: "story" });
|
|
52
44
|
const steps = config.steps || [];
|
|
53
45
|
if (steps.length === 0) throw new Error("Config has no steps");
|
|
@@ -107,6 +99,18 @@ export async function executeRecord(values, { command = "record", reporter = cre
|
|
|
107
99
|
for (const [index, step] of steps.entries()) {
|
|
108
100
|
if (preview) reporter.log(`Step ${index + 1}/${steps.length}: ${step.action}`);
|
|
109
101
|
const t = Date.now() - startedAt;
|
|
102
|
+
const pushEvent = (action, point, extra = {}, timeEnd = Date.now() - startedAt) => {
|
|
103
|
+
events.push({
|
|
104
|
+
t,
|
|
105
|
+
tEnd: timeEnd,
|
|
106
|
+
zoom: step.zoom !== false,
|
|
107
|
+
action,
|
|
108
|
+
x: point.x,
|
|
109
|
+
y: point.y,
|
|
110
|
+
caption: step.caption || "",
|
|
111
|
+
...extra,
|
|
112
|
+
});
|
|
113
|
+
};
|
|
110
114
|
|
|
111
115
|
try {
|
|
112
116
|
switch (step.action) {
|
|
@@ -125,16 +129,7 @@ export async function executeRecord(values, { command = "record", reporter = cre
|
|
|
125
129
|
case "click": {
|
|
126
130
|
const locator = await resolveLocator(page, step);
|
|
127
131
|
const point = await moveAndClick(page, locator, 0, Number(step.timeout ?? 20000));
|
|
128
|
-
|
|
129
|
-
t,
|
|
130
|
-
tEnd: Date.now() - startedAt,
|
|
131
|
-
zoom: step.zoom !== false,
|
|
132
|
-
action: "click",
|
|
133
|
-
x: point.x,
|
|
134
|
-
y: point.y,
|
|
135
|
-
caption: step.caption || "",
|
|
136
|
-
label: step.text || step.name || step.selector || "",
|
|
137
|
-
});
|
|
132
|
+
pushEvent("click", point, { label: step.text || step.name || step.selector || "" });
|
|
138
133
|
await page.waitForTimeout(Number(step.pause ?? 700));
|
|
139
134
|
break;
|
|
140
135
|
}
|
|
@@ -143,16 +138,7 @@ export async function executeRecord(values, { command = "record", reporter = cre
|
|
|
143
138
|
const locator = await resolveLocator(page, step);
|
|
144
139
|
const value = String(step.value ?? step.text ?? "");
|
|
145
140
|
const point = await clickAndType(page, locator, value, 0);
|
|
146
|
-
|
|
147
|
-
t,
|
|
148
|
-
tEnd: Date.now() - startedAt,
|
|
149
|
-
zoom: step.zoom !== false,
|
|
150
|
-
action: "type",
|
|
151
|
-
x: point.x,
|
|
152
|
-
y: point.y,
|
|
153
|
-
caption: step.caption || "",
|
|
154
|
-
label: value,
|
|
155
|
-
});
|
|
141
|
+
pushEvent("type", point, { label: value });
|
|
156
142
|
await page.waitForTimeout(Number(step.pause ?? 400));
|
|
157
143
|
break;
|
|
158
144
|
}
|
|
@@ -161,16 +147,7 @@ export async function executeRecord(values, { command = "record", reporter = cre
|
|
|
161
147
|
const locator = await resolveLocator(page, step);
|
|
162
148
|
const value = String(step.value ?? step.text ?? "");
|
|
163
149
|
const point = await selectOption(page, locator, value, 0, Number(step.timeout ?? 20000));
|
|
164
|
-
|
|
165
|
-
t,
|
|
166
|
-
tEnd: Date.now() - startedAt,
|
|
167
|
-
zoom: step.zoom !== false,
|
|
168
|
-
action: "select",
|
|
169
|
-
x: point.x,
|
|
170
|
-
y: point.y,
|
|
171
|
-
caption: step.caption || "",
|
|
172
|
-
label: value,
|
|
173
|
-
});
|
|
150
|
+
pushEvent("select", point, { label: value });
|
|
174
151
|
await page.waitForTimeout(Number(step.pause ?? 500));
|
|
175
152
|
break;
|
|
176
153
|
}
|
|
@@ -178,16 +155,7 @@ export async function executeRecord(values, { command = "record", reporter = cre
|
|
|
178
155
|
case "hover": {
|
|
179
156
|
const locator = await resolveLocator(page, step);
|
|
180
157
|
const point = await hover(page, locator, 0);
|
|
181
|
-
|
|
182
|
-
t,
|
|
183
|
-
tEnd: Date.now() - startedAt,
|
|
184
|
-
zoom: step.zoom !== false,
|
|
185
|
-
action: "hover",
|
|
186
|
-
x: point.x,
|
|
187
|
-
y: point.y,
|
|
188
|
-
caption: step.caption || "",
|
|
189
|
-
label: step.text || step.selector || "",
|
|
190
|
-
});
|
|
158
|
+
pushEvent("hover", point, { label: step.text || step.selector || "" });
|
|
191
159
|
await page.waitForTimeout(Number(step.pause ?? 500));
|
|
192
160
|
break;
|
|
193
161
|
}
|
|
@@ -200,12 +168,10 @@ export async function executeRecord(values, { command = "record", reporter = cre
|
|
|
200
168
|
throw commandError("TARGET_NOT_FOUND", "The focus target has no visible area.");
|
|
201
169
|
}
|
|
202
170
|
const focusedAt = Date.now() - startedAt;
|
|
203
|
-
|
|
204
|
-
t: focusedAt,
|
|
205
|
-
x: box.x + box.width / 2, y: box.y + box.height / 2,
|
|
206
|
-
zoom: step.zoom !== false, caption: step.caption || "",
|
|
171
|
+
pushEvent("focus", { x: box.x + box.width / 2, y: box.y + box.height / 2 }, {
|
|
172
|
+
t: focusedAt,
|
|
207
173
|
label: step.text || step.name || step.selector || "",
|
|
208
|
-
});
|
|
174
|
+
}, focusedAt);
|
|
209
175
|
await page.waitForTimeout(Number(step.pause ?? 700));
|
|
210
176
|
break;
|
|
211
177
|
}
|
|
@@ -220,16 +186,7 @@ export async function executeRecord(values, { command = "record", reporter = cre
|
|
|
220
186
|
Number(step.steps || 24),
|
|
221
187
|
0,
|
|
222
188
|
);
|
|
223
|
-
|
|
224
|
-
t,
|
|
225
|
-
tEnd: Date.now() - startedAt,
|
|
226
|
-
zoom: step.zoom !== false,
|
|
227
|
-
action: "drag",
|
|
228
|
-
x: point.x,
|
|
229
|
-
y: point.y,
|
|
230
|
-
caption: step.caption || "",
|
|
231
|
-
label: step.selector || "",
|
|
232
|
-
});
|
|
189
|
+
pushEvent("drag", point, { label: step.selector || "" });
|
|
233
190
|
await page.waitForTimeout(Number(step.pause ?? 600));
|
|
234
191
|
break;
|
|
235
192
|
}
|
|
@@ -239,30 +196,14 @@ export async function executeRecord(values, { command = "record", reporter = cre
|
|
|
239
196
|
await page.evaluate((dy) => {
|
|
240
197
|
window.scrollBy({ top: dy, behavior: "smooth" });
|
|
241
198
|
}, y);
|
|
242
|
-
|
|
243
|
-
t,
|
|
244
|
-
tEnd: Date.now() - startedAt,
|
|
245
|
-
zoom: step.zoom !== false,
|
|
246
|
-
action: "scroll",
|
|
247
|
-
x: viewport.width / 2,
|
|
248
|
-
y: viewport.height / 2,
|
|
249
|
-
caption: step.caption || "",
|
|
250
|
-
});
|
|
199
|
+
pushEvent("scroll", { x: viewport.width / 2, y: viewport.height / 2 });
|
|
251
200
|
await page.waitForTimeout(Number(step.pause ?? 700));
|
|
252
201
|
break;
|
|
253
202
|
}
|
|
254
203
|
|
|
255
204
|
case "press": {
|
|
256
205
|
await page.keyboard.press(step.key || "Enter");
|
|
257
|
-
|
|
258
|
-
t,
|
|
259
|
-
tEnd: Date.now() - startedAt,
|
|
260
|
-
zoom: step.zoom !== false,
|
|
261
|
-
action: "press",
|
|
262
|
-
x: viewport.width / 2,
|
|
263
|
-
y: viewport.height / 2,
|
|
264
|
-
caption: step.caption || "",
|
|
265
|
-
});
|
|
206
|
+
pushEvent("press", { x: viewport.width / 2, y: viewport.height / 2 });
|
|
266
207
|
await page.waitForTimeout(Number(step.pause ?? 500));
|
|
267
208
|
break;
|
|
268
209
|
}
|