@gnawbit/tabretake 0.4.1 → 0.4.2
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 +95 -89
- package/README.md +64 -87
- package/README.zh-CN.md +55 -76
- package/SKILL.md +39 -65
- package/examples/site/style.css +81 -71
- package/examples/story.json +1 -2
- package/package.json +9 -1
- package/references/rendering.md +3 -1
- package/schemas/story.schema.json +606 -616
- package/scripts/cli.mjs +5 -3
- package/scripts/demo.mjs +7 -1
- package/scripts/doctor.mjs +11 -3
- package/scripts/init.mjs +4 -2
- package/scripts/lib/browser.mjs +65 -3
- package/scripts/lib/captions.mjs +8 -3
- package/scripts/lib/options.mjs +7 -0
- package/scripts/lib/system-browser.mjs +30 -0
- package/scripts/lib/themes.mjs +125 -0
- package/scripts/plan.mjs +6 -5
- package/scripts/record.mjs +6 -4
- package/scripts/render.mjs +49 -35
package/scripts/cli.mjs
CHANGED
|
@@ -9,13 +9,13 @@ Usage:
|
|
|
9
9
|
tabretake capabilities [--json]
|
|
10
10
|
tabretake doctor [--json]
|
|
11
11
|
tabretake validate --config demo.json [--json]
|
|
12
|
-
tabretake init --url <url> [--out demo.json]
|
|
12
|
+
tabretake init --url <url> [--out demo.json] [--auto] [--preset midnight|daylight|paper|slate]
|
|
13
13
|
tabretake plan --url <url> [--out plan.json] [--login] [--storage-state auth.json]
|
|
14
14
|
tabretake record --config demo.json [--out demo] [--login] [--storage-state auth.json]
|
|
15
15
|
tabretake preview --config demo.json [--headless] [--json]
|
|
16
|
-
tabretake render --config demo.json [--out demo] [--video recording.mp4] [--vertical] [--no-gif]
|
|
16
|
+
tabretake render --config demo.json [--out demo] [--video recording.mp4] [--vertical] [--no-gif] [--preset <name>]
|
|
17
17
|
tabretake serve [--port 4173] [--dir examples/site]
|
|
18
|
-
tabretake demo [--story readme|onboarding|release] [--out demo]
|
|
18
|
+
tabretake demo [--story readme|onboarding|release] [--out demo] [--preset <name>]
|
|
19
19
|
|
|
20
20
|
Examples:
|
|
21
21
|
tabretake init --url https://your-app.com
|
|
@@ -36,6 +36,8 @@ Options:
|
|
|
36
36
|
--vertical-zoom Override portrait focus zoom (1–10; otherwise uses --zoom).
|
|
37
37
|
--video Use an existing screen recording; the config needs "marks".
|
|
38
38
|
--no-gif Skip GIF export.
|
|
39
|
+
--browser Browser channel: auto (default), chromium, chrome or msedge.
|
|
40
|
+
--preset Brand theme preset: midnight, daylight, paper or slate.
|
|
39
41
|
--poster-at Choose the poster time in output seconds, e.g. 4.5.
|
|
40
42
|
--zoom-duration Ease between click targets in seconds (default 0.35; 0 for cuts).
|
|
41
43
|
`;
|
package/scripts/demo.mjs
CHANGED
|
@@ -31,8 +31,14 @@ export async function demo(argv) {
|
|
|
31
31
|
server.url,
|
|
32
32
|
"--out",
|
|
33
33
|
values.out,
|
|
34
|
+
...(values.browser ? ["--browser", values.browser] : []),
|
|
35
|
+
]);
|
|
36
|
+
await render([
|
|
37
|
+
"--config",
|
|
38
|
+
path.join(values.out, "record.json"),
|
|
39
|
+
"--vertical",
|
|
40
|
+
...(values.preset ? ["--preset", values.preset] : []),
|
|
34
41
|
]);
|
|
35
|
-
await render(["--config", path.join(values.out, "record.json"), "--vertical"]);
|
|
36
42
|
} finally {
|
|
37
43
|
await server.close();
|
|
38
44
|
}
|
package/scripts/doctor.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { execFile } from "node:child_process";
|
|
3
3
|
import { promisify } from "node:util";
|
|
4
|
+
import { findSystemBrowser } from "./lib/system-browser.mjs";
|
|
4
5
|
import { findCjkFont, findFont } from "./lib/fonts.mjs";
|
|
5
6
|
import { parseCommand } from "./lib/options.mjs";
|
|
6
7
|
import { nodeRange, schemaVersion, supportsNodeVersion, version } from "./lib/metadata.mjs";
|
|
@@ -15,6 +16,7 @@ export async function diagnose({
|
|
|
15
16
|
exists = existsSync,
|
|
16
17
|
run = (file) => exec(file, ["-version"], { windowsHide: true, timeout: 10000 }),
|
|
17
18
|
fonts = { latin: findFont, cjk: findCjkFont },
|
|
19
|
+
systemBrowser = () => findSystemBrowser({ exists }),
|
|
18
20
|
} = {}) {
|
|
19
21
|
const checks = [];
|
|
20
22
|
async function check(id, required, hint, probe) {
|
|
@@ -37,11 +39,17 @@ export async function diagnose({
|
|
|
37
39
|
return (stdout || stderr).split("\n")[0].trim();
|
|
38
40
|
});
|
|
39
41
|
}
|
|
40
|
-
await check("chromium", true, "Run tabretake setup (
|
|
42
|
+
await check("chromium", true, "Run tabretake setup (or install Chrome/Edge for automatic fallback).", async () => {
|
|
41
43
|
const { chromium } = await load("playwright");
|
|
42
44
|
const file = chromium.executablePath();
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
+
if (exists(file)) {
|
|
46
|
+
return "Executable found; browser launch and system libraries are not tested.";
|
|
47
|
+
}
|
|
48
|
+
const fallback = systemBrowser();
|
|
49
|
+
if (fallback) {
|
|
50
|
+
return `Using system ${fallback.channel} fallback; run tabretake setup for pinned Chromium.`;
|
|
51
|
+
}
|
|
52
|
+
throw new Error("Chromium executable not found and no Chrome/Edge fallback detected");
|
|
45
53
|
});
|
|
46
54
|
await check("sharp", true, reinstall, async () => {
|
|
47
55
|
const { default: sharp } = await load("sharp");
|
package/scripts/init.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { mkdir, writeFile } from "node:fs/promises";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { parseCommand } from "./lib/options.mjs";
|
|
4
4
|
import { createReporter } from "./lib/report.mjs";
|
|
5
|
+
import { resolveTheme } from "./lib/themes.mjs";
|
|
5
6
|
import { extractPlan } from "./plan.mjs";
|
|
6
7
|
|
|
7
8
|
export function buildAutoSteps(elements) {
|
|
@@ -80,7 +81,7 @@ export async function init(argv) {
|
|
|
80
81
|
if (values.auto) {
|
|
81
82
|
reporter.log("Scanning page to generate interactive steps (--auto)...");
|
|
82
83
|
try {
|
|
83
|
-
const { elements } = await extractPlan(url.href);
|
|
84
|
+
const { elements } = await extractPlan(url.href, { browser: values.browser });
|
|
84
85
|
steps = buildAutoSteps(elements);
|
|
85
86
|
reporter.log(`Generated ${steps.length} step(s) from discovered interactive controls.`);
|
|
86
87
|
} catch (err) {
|
|
@@ -88,13 +89,14 @@ export async function init(argv) {
|
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
91
|
|
|
92
|
+
const theme = resolveTheme({}, values.preset);
|
|
91
93
|
const story = {
|
|
92
94
|
url: url.href,
|
|
93
95
|
displayUrl: url.host,
|
|
94
96
|
viewport: { width: 1440, height: 810 },
|
|
95
97
|
initialWait: 700,
|
|
96
98
|
tail: 1200,
|
|
97
|
-
brand: { background:
|
|
99
|
+
brand: { preset: theme.preset, background: theme.background, accent: theme.accent },
|
|
98
100
|
steps,
|
|
99
101
|
};
|
|
100
102
|
const outPath = path.resolve(values.out);
|
package/scripts/lib/browser.mjs
CHANGED
|
@@ -1,11 +1,47 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { chmod, copyFile, mkdir } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
1
4
|
import { chromium, errors } from "playwright";
|
|
5
|
+
import { FFMPEG } from "./ffmpeg.mjs";
|
|
6
|
+
import { VALID_BROWSERS, findSystemBrowser } from "./system-browser.mjs";
|
|
2
7
|
|
|
3
|
-
export
|
|
4
|
-
|
|
8
|
+
export { VALID_BROWSERS, findSystemBrowser };
|
|
9
|
+
|
|
10
|
+
export async function launchBrowser({
|
|
11
|
+
headless = true,
|
|
12
|
+
proxy,
|
|
13
|
+
browser = "auto",
|
|
14
|
+
launch = (opts) => chromium.launch(opts),
|
|
15
|
+
hasBundledChromium = () => existsSync(chromium.executablePath()),
|
|
16
|
+
} = {}) {
|
|
17
|
+
const mode = browser || "auto";
|
|
18
|
+
if (!VALID_BROWSERS.has(mode)) {
|
|
19
|
+
throw new Error(`Unsupported --browser "${mode}". Choose auto, chromium, chrome or msedge.`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const base = {
|
|
5
23
|
headless,
|
|
6
24
|
proxy: proxy ? { server: proxy } : undefined,
|
|
7
25
|
args: ["--disable-blink-features=AutomationControlled"],
|
|
8
|
-
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
if (mode === "chrome" || mode === "msedge") {
|
|
29
|
+
return launch({ ...base, channel: mode });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (mode === "chromium" || hasBundledChromium()) {
|
|
33
|
+
return launch(base);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
for (const channel of ["chrome", "msedge"]) {
|
|
37
|
+
try {
|
|
38
|
+
return await launch({ ...base, channel });
|
|
39
|
+
} catch {
|
|
40
|
+
// Continue trying next installed system browser channel.
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return launch(base);
|
|
9
45
|
}
|
|
10
46
|
|
|
11
47
|
export async function newContext(browser, options) {
|
|
@@ -29,6 +65,32 @@ export async function newContext(browser, options) {
|
|
|
29
65
|
return context;
|
|
30
66
|
}
|
|
31
67
|
|
|
68
|
+
export async function openRecordedPage(
|
|
69
|
+
browser,
|
|
70
|
+
contextOptions,
|
|
71
|
+
{ ffmpegPath = FFMPEG, makeContext = (opts) => newContext(browser, opts) } = {},
|
|
72
|
+
) {
|
|
73
|
+
let context = await makeContext(contextOptions);
|
|
74
|
+
try {
|
|
75
|
+
const page = await context.newPage();
|
|
76
|
+
return { context, page };
|
|
77
|
+
} catch (error) {
|
|
78
|
+
const match = /Executable doesn't exist at ([^\r\n]+)/.exec(String(error?.message || ""));
|
|
79
|
+
if (!match || !/Video rendering requires ffmpeg binary/.test(error.message) || !ffmpegPath || !existsSync(ffmpegPath)) {
|
|
80
|
+
await context.close().catch(() => {});
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
const targetPath = match[1].trim();
|
|
84
|
+
await context.close().catch(() => {});
|
|
85
|
+
await mkdir(path.dirname(targetPath), { recursive: true });
|
|
86
|
+
await copyFile(ffmpegPath, targetPath);
|
|
87
|
+
await chmod(targetPath, 0o755).catch(() => {});
|
|
88
|
+
context = await makeContext(contextOptions);
|
|
89
|
+
const page = await context.newPage();
|
|
90
|
+
return { context, page };
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
32
94
|
/**
|
|
33
95
|
* Draws a fake cursor + click ripple on top of the page, so the recording
|
|
34
96
|
* looks like a human is using it.
|
package/scripts/lib/captions.mjs
CHANGED
|
@@ -5,8 +5,13 @@ import { hasCjk } from "./fonts.mjs";
|
|
|
5
5
|
const escapeMarkup = (text) => String(text).replace(/&/g, "&")
|
|
6
6
|
.replace(/</g, "<").replace(/>/g, ">");
|
|
7
7
|
|
|
8
|
-
export async function createCaptionLayers({
|
|
8
|
+
export async function createCaptionLayers({
|
|
9
|
+
events, durationSec, font, cjkFont, layout, assetsDir,
|
|
10
|
+
theme = { caption: { fg: "white", bg: { r: 11, g: 15, b: 25, alpha: 0.74 } } },
|
|
11
|
+
}) {
|
|
9
12
|
if (!font) return [];
|
|
13
|
+
const fg = theme?.caption?.fg || "white";
|
|
14
|
+
const bg = theme?.caption?.bg || { r: 11, g: 15, b: 25, alpha: 0.74 };
|
|
10
15
|
const captions = events.map((event) => ({ text: String(event.caption || ""), start: (event.tEnd ?? event.t) / 1000 }))
|
|
11
16
|
.filter(({ text, start }) => text.trim() && Number.isFinite(start) && start >= 0 && start < durationSec)
|
|
12
17
|
.sort((a, b) => a.start - b.start);
|
|
@@ -17,7 +22,7 @@ export async function createCaptionLayers({ events, durationSec, font, cjkFont,
|
|
|
17
22
|
const end = Math.min(captions[i + 1]?.start ?? durationSec, start + 2.8, durationSec);
|
|
18
23
|
if (end <= start) continue;
|
|
19
24
|
const options = {
|
|
20
|
-
text: `<span foreground="
|
|
25
|
+
text: `<span foreground="${fg}">${escapeMarkup(text)}</span>`,
|
|
21
26
|
font: `sans-serif ${size}`, fontfile: hasCjk(text) ? cjkFont || font : font,
|
|
22
27
|
width: width - box * 2, align: "centre", rgba: true, wrap: "word-char",
|
|
23
28
|
};
|
|
@@ -31,7 +36,7 @@ export async function createCaptionLayers({ events, durationSec, font, cjkFont,
|
|
|
31
36
|
const file = path.join(assetsDir, `caption-${layout.key}-${i}.png`);
|
|
32
37
|
const info = await sharp({ create: {
|
|
33
38
|
width: rendered.info.width + box * 2, height: rendered.info.height + box * 2,
|
|
34
|
-
channels: 4, background:
|
|
39
|
+
channels: 4, background: bg,
|
|
35
40
|
} }).composite([{ input: rendered.data, top: box, left: box }]).png().toFile(file);
|
|
36
41
|
layers.push({ file, start, end, x: Math.floor((layout.width - info.width) / 2), y });
|
|
37
42
|
}
|
package/scripts/lib/options.mjs
CHANGED
|
@@ -7,6 +7,8 @@ export const commandOptions = {
|
|
|
7
7
|
url: { type: "string" },
|
|
8
8
|
out: { type: "string", default: "demo.json" },
|
|
9
9
|
auto: { type: "boolean", default: false },
|
|
10
|
+
browser: { type: "string", default: "auto" },
|
|
11
|
+
preset: { type: "string" },
|
|
10
12
|
},
|
|
11
13
|
plan: {
|
|
12
14
|
json: { type: "boolean", default: false },
|
|
@@ -17,6 +19,7 @@ export const commandOptions = {
|
|
|
17
19
|
proxy: { type: "string" },
|
|
18
20
|
viewport: { type: "string" },
|
|
19
21
|
headless: { type: "boolean", default: true },
|
|
22
|
+
browser: { type: "string", default: "auto" },
|
|
20
23
|
},
|
|
21
24
|
record: {
|
|
22
25
|
json: { type: "boolean", default: false },
|
|
@@ -29,6 +32,7 @@ export const commandOptions = {
|
|
|
29
32
|
proxy: { type: "string" },
|
|
30
33
|
viewport: { type: "string" },
|
|
31
34
|
headed: { type: "boolean", default: false },
|
|
35
|
+
browser: { type: "string", default: "auto" },
|
|
32
36
|
},
|
|
33
37
|
render: {
|
|
34
38
|
json: { type: "boolean", default: false },
|
|
@@ -42,6 +46,7 @@ export const commandOptions = {
|
|
|
42
46
|
"vertical-zoom": { type: "string" },
|
|
43
47
|
"zoom-duration": { type: "string" },
|
|
44
48
|
"poster-at": { type: "string" },
|
|
49
|
+
preset: { type: "string" },
|
|
45
50
|
},
|
|
46
51
|
serve: {
|
|
47
52
|
port: { type: "string", default: "4173" },
|
|
@@ -51,6 +56,8 @@ export const commandOptions = {
|
|
|
51
56
|
out: { type: "string", default: "demo" },
|
|
52
57
|
port: { type: "string", default: "4173" },
|
|
53
58
|
story: { type: "string", default: "onboarding" },
|
|
59
|
+
browser: { type: "string", default: "auto" },
|
|
60
|
+
preset: { type: "string" },
|
|
54
61
|
},
|
|
55
62
|
doctor: { json: { type: "boolean", default: false } },
|
|
56
63
|
capabilities: { json: { type: "boolean", default: false } },
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
export const VALID_BROWSERS = new Set(["auto", "chromium", "chrome", "msedge"]);
|
|
5
|
+
|
|
6
|
+
export function findSystemBrowser({
|
|
7
|
+
exists = existsSync,
|
|
8
|
+
platform = process.platform,
|
|
9
|
+
env = process.env,
|
|
10
|
+
} = {}) {
|
|
11
|
+
const candidates = [];
|
|
12
|
+
if (platform === "win32") {
|
|
13
|
+
const roots = [env.PROGRAMFILES, env["PROGRAMFILES(X86)"], env.LOCALAPPDATA].filter(Boolean);
|
|
14
|
+
for (const root of roots) {
|
|
15
|
+
candidates.push({ channel: "chrome", path: path.join(root, "Google", "Chrome", "Application", "chrome.exe") });
|
|
16
|
+
candidates.push({ channel: "msedge", path: path.join(root, "Microsoft", "Edge", "Application", "msedge.exe") });
|
|
17
|
+
}
|
|
18
|
+
} else if (platform === "darwin") {
|
|
19
|
+
candidates.push({ channel: "chrome", path: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" });
|
|
20
|
+
candidates.push({ channel: "msedge", path: "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge" });
|
|
21
|
+
} else {
|
|
22
|
+
for (const bin of ["/usr/bin/google-chrome", "/usr/bin/google-chrome-stable", "/opt/google/chrome/chrome"]) {
|
|
23
|
+
candidates.push({ channel: "chrome", path: bin });
|
|
24
|
+
}
|
|
25
|
+
for (const bin of ["/usr/bin/microsoft-edge", "/usr/bin/microsoft-edge-stable"]) {
|
|
26
|
+
candidates.push({ channel: "msedge", path: bin });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return candidates.find((candidate) => exists(candidate.path)) || null;
|
|
30
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
export const BRAND_PRESETS = {
|
|
2
|
+
midnight: {
|
|
3
|
+
preset: "midnight",
|
|
4
|
+
background: "#070a12",
|
|
5
|
+
accent: "#6c5ce7",
|
|
6
|
+
light: false,
|
|
7
|
+
frame: {
|
|
8
|
+
bar: "#0D1117",
|
|
9
|
+
border: "#2A3140",
|
|
10
|
+
divider: "#202634",
|
|
11
|
+
addressBg: "#161B23",
|
|
12
|
+
addressBorder: "#262D3A",
|
|
13
|
+
addressText: "#8A93A6",
|
|
14
|
+
shadowAlpha: 0.45,
|
|
15
|
+
edgeOpacity: 0.04,
|
|
16
|
+
},
|
|
17
|
+
caption: {
|
|
18
|
+
fg: "white",
|
|
19
|
+
bg: { r: 11, g: 15, b: 25, alpha: 0.74 },
|
|
20
|
+
},
|
|
21
|
+
chrome: {
|
|
22
|
+
text: "0xE9EDF5",
|
|
23
|
+
muted: "0x8A93A6",
|
|
24
|
+
watermark: "0x5D6678",
|
|
25
|
+
ctaText: "0xFFFFFF",
|
|
26
|
+
badgeBoxAlpha: 0.22,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
daylight: {
|
|
30
|
+
preset: "daylight",
|
|
31
|
+
background: "#f4f6fb",
|
|
32
|
+
accent: "#2563eb",
|
|
33
|
+
light: true,
|
|
34
|
+
frame: {
|
|
35
|
+
bar: "#FFFFFF",
|
|
36
|
+
border: "#D7DFEA",
|
|
37
|
+
divider: "#E6ECF4",
|
|
38
|
+
addressBg: "#F1F5F9",
|
|
39
|
+
addressBorder: "#DCE3EE",
|
|
40
|
+
addressText: "#475569",
|
|
41
|
+
shadowAlpha: 0.16,
|
|
42
|
+
edgeOpacity: 0.6,
|
|
43
|
+
},
|
|
44
|
+
caption: {
|
|
45
|
+
fg: "#0F172A",
|
|
46
|
+
bg: { r: 255, g: 255, b: 255, alpha: 0.92 },
|
|
47
|
+
},
|
|
48
|
+
chrome: {
|
|
49
|
+
text: "0x0F172A",
|
|
50
|
+
muted: "0x475569",
|
|
51
|
+
watermark: "0x64748B",
|
|
52
|
+
ctaText: "0xFFFFFF",
|
|
53
|
+
badgeBoxAlpha: 0.14,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
paper: {
|
|
57
|
+
preset: "paper",
|
|
58
|
+
background: "#f7f3eb",
|
|
59
|
+
accent: "#b45309",
|
|
60
|
+
light: true,
|
|
61
|
+
frame: {
|
|
62
|
+
bar: "#FFFDF9",
|
|
63
|
+
border: "#E4D8C6",
|
|
64
|
+
divider: "#EFE6D8",
|
|
65
|
+
addressBg: "#F5EFE4",
|
|
66
|
+
addressBorder: "#E5D8C5",
|
|
67
|
+
addressText: "#6B5B4B",
|
|
68
|
+
shadowAlpha: 0.15,
|
|
69
|
+
edgeOpacity: 0.55,
|
|
70
|
+
},
|
|
71
|
+
caption: {
|
|
72
|
+
fg: "#292018",
|
|
73
|
+
bg: { r: 255, g: 252, b: 245, alpha: 0.92 },
|
|
74
|
+
},
|
|
75
|
+
chrome: {
|
|
76
|
+
text: "0x292018",
|
|
77
|
+
muted: "0x6B5B4B",
|
|
78
|
+
watermark: "0x8C7B6A",
|
|
79
|
+
ctaText: "0xFFFFFF",
|
|
80
|
+
badgeBoxAlpha: 0.14,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
slate: {
|
|
84
|
+
preset: "slate",
|
|
85
|
+
background: "#0f172a",
|
|
86
|
+
accent: "#10b981",
|
|
87
|
+
light: false,
|
|
88
|
+
frame: {
|
|
89
|
+
bar: "#131C31",
|
|
90
|
+
border: "#2B3954",
|
|
91
|
+
divider: "#222E46",
|
|
92
|
+
addressBg: "#1A253D",
|
|
93
|
+
addressBorder: "#30405E",
|
|
94
|
+
addressText: "#94A3B8",
|
|
95
|
+
shadowAlpha: 0.42,
|
|
96
|
+
edgeOpacity: 0.05,
|
|
97
|
+
},
|
|
98
|
+
caption: {
|
|
99
|
+
fg: "white",
|
|
100
|
+
bg: { r: 15, g: 23, b: 42, alpha: 0.8 },
|
|
101
|
+
},
|
|
102
|
+
chrome: {
|
|
103
|
+
text: "0xF1F5F9",
|
|
104
|
+
muted: "0x94A3B8",
|
|
105
|
+
watermark: "0x64748B",
|
|
106
|
+
ctaText: "0xFFFFFF",
|
|
107
|
+
badgeBoxAlpha: 0.22,
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export const PRESET_NAMES = Object.keys(BRAND_PRESETS);
|
|
113
|
+
|
|
114
|
+
export function resolveTheme(brand = {}, overridePreset) {
|
|
115
|
+
const presetName = overridePreset || brand?.preset || "midnight";
|
|
116
|
+
const base = BRAND_PRESETS[presetName];
|
|
117
|
+
if (!base) {
|
|
118
|
+
throw new Error(`Unknown brand preset "${presetName}". Choose ${PRESET_NAMES.join(", ")}.`);
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
...base,
|
|
122
|
+
background: (!overridePreset && brand?.background) || base.background,
|
|
123
|
+
accent: (!overridePreset && brand?.accent) || base.accent,
|
|
124
|
+
};
|
|
125
|
+
}
|
package/scripts/plan.mjs
CHANGED
|
@@ -128,8 +128,8 @@ export async function collectElements(page) {
|
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
export async function extractPlan(url, { viewport = { width: 1440, height: 810 }, proxy, storageState, headless = true } = {}) {
|
|
132
|
-
const browser = await launchBrowser({ headless, proxy });
|
|
131
|
+
export async function extractPlan(url, { viewport = { width: 1440, height: 810 }, proxy, storageState, headless = true, browser: browserMode } = {}) {
|
|
132
|
+
const browser = await launchBrowser({ headless, proxy, browser: browserMode });
|
|
133
133
|
try {
|
|
134
134
|
const context = await newContext(browser, { viewport, storageState });
|
|
135
135
|
const page = await context.newPage();
|
|
@@ -160,12 +160,13 @@ export async function plan(argv) {
|
|
|
160
160
|
|
|
161
161
|
let storageState = values["storage-state"];
|
|
162
162
|
if (values.login) {
|
|
163
|
-
storageState = await loginAndSave(values.url, { proxy: values.proxy, viewport });
|
|
163
|
+
storageState = await loginAndSave(values.url, { proxy: values.proxy, viewport, browser: values.browser });
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
const browser = await launchBrowser({
|
|
167
167
|
headless: values.headless || !values.login,
|
|
168
168
|
proxy: values.proxy,
|
|
169
|
+
browser: values.browser,
|
|
169
170
|
});
|
|
170
171
|
|
|
171
172
|
let manifest;
|
|
@@ -216,8 +217,8 @@ export async function plan(argv) {
|
|
|
216
217
|
await reporter.success(manifest);
|
|
217
218
|
}
|
|
218
219
|
|
|
219
|
-
async function loginAndSave(url, { proxy, viewport }) {
|
|
220
|
-
const browser = await launchBrowser({ headless: false, proxy });
|
|
220
|
+
async function loginAndSave(url, { proxy, viewport, browser: browserMode }) {
|
|
221
|
+
const browser = await launchBrowser({ headless: false, proxy, browser: browserMode });
|
|
221
222
|
try {
|
|
222
223
|
const context = await newContext(browser, { viewport });
|
|
223
224
|
const page = await context.newPage();
|
package/scripts/record.mjs
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
launchBrowser,
|
|
10
10
|
moveAndClick,
|
|
11
11
|
newContext,
|
|
12
|
+
openRecordedPage,
|
|
12
13
|
resolveLocator,
|
|
13
14
|
} from "./lib/browser.mjs";
|
|
14
15
|
import { waitForEnter } from "./lib/tty.mjs";
|
|
@@ -65,6 +66,7 @@ export async function record(argv, command = "record") {
|
|
|
65
66
|
storageState = await loginAndSave(url, {
|
|
66
67
|
proxy: values.proxy,
|
|
67
68
|
viewport,
|
|
69
|
+
browser: values.browser,
|
|
68
70
|
statePath: path.resolve(values["save-state"] || "auth.json"),
|
|
69
71
|
});
|
|
70
72
|
}
|
|
@@ -72,6 +74,7 @@ export async function record(argv, command = "record") {
|
|
|
72
74
|
const browser = await launchBrowser({
|
|
73
75
|
headless: preview ? values.headless : !values.headed,
|
|
74
76
|
proxy: values.proxy,
|
|
77
|
+
browser: values.browser,
|
|
75
78
|
});
|
|
76
79
|
|
|
77
80
|
let videoPath = null;
|
|
@@ -81,12 +84,11 @@ export async function record(argv, command = "record") {
|
|
|
81
84
|
|
|
82
85
|
try {
|
|
83
86
|
const videoStartedAt = Date.now();
|
|
84
|
-
const context = await
|
|
87
|
+
const { context, page } = await openRecordedPage(browser, {
|
|
85
88
|
viewport,
|
|
86
89
|
videoDir: preview ? undefined : rawDir,
|
|
87
90
|
storageState,
|
|
88
91
|
});
|
|
89
|
-
const page = await context.newPage();
|
|
90
92
|
|
|
91
93
|
await installCursor(page);
|
|
92
94
|
|
|
@@ -334,8 +336,8 @@ export async function record(argv, command = "record") {
|
|
|
334
336
|
return record;
|
|
335
337
|
}
|
|
336
338
|
|
|
337
|
-
async function loginAndSave(url, { proxy, viewport, statePath }) {
|
|
338
|
-
const browser = await launchBrowser({ headless: false, proxy });
|
|
339
|
+
async function loginAndSave(url, { proxy, viewport, browser: browserMode, statePath }) {
|
|
340
|
+
const browser = await launchBrowser({ headless: false, proxy, browser: browserMode });
|
|
339
341
|
try {
|
|
340
342
|
const context = await newContext(browser, { viewport });
|
|
341
343
|
const page = await context.newPage();
|