@gnawbit/tabretake 0.4.2 → 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 +14 -0
- package/README.md +32 -20
- package/SKILL.md +21 -17
- package/bin/tabretake.mjs +6 -1
- package/package.json +2 -3
- package/references/rendering.md +9 -6
- package/references/story.md +18 -23
- package/schemas/story.schema.json +30 -4
- package/scripts/capture.mjs +598 -0
- package/scripts/cli.mjs +23 -6
- package/scripts/init.mjs +74 -37
- package/scripts/lib/browser.mjs +146 -16
- package/scripts/lib/config.mjs +1 -1
- package/scripts/lib/ffmpeg.mjs +9 -12
- package/scripts/lib/options.mjs +148 -74
- package/scripts/lib/report.mjs +1 -0
- package/scripts/lib/themes.mjs +11 -0
- package/scripts/mark.mjs +516 -0
- package/scripts/plan.mjs +32 -33
- package/scripts/record.mjs +67 -101
- package/scripts/render.mjs +91 -56
- package/scripts/run.mjs +55 -0
- package/README.zh-CN.md +0 -511
- package/bin/demo-reel.mjs +0 -2
package/scripts/lib/options.mjs
CHANGED
|
@@ -1,74 +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
|
-
|
|
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/report.mjs
CHANGED
|
@@ -17,6 +17,7 @@ export function requireInteractiveLogin(values) {
|
|
|
17
17
|
export function createReporter(command, json) {
|
|
18
18
|
return {
|
|
19
19
|
log: (...args) => (json ? console.error : console.log)(...args),
|
|
20
|
+
warn: (...args) => console.error(...args),
|
|
20
21
|
async success({ artifacts, ...details }) {
|
|
21
22
|
if (!json) return;
|
|
22
23
|
const files = await Promise.all(artifacts.map(async (artifact) => {
|
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];
|