@walkrstudio/cli 0.2.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.
- package/README.md +108 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +103 -0
- package/dist/cli.js.map +1 -0
- package/dist/dev.d.ts +2 -0
- package/dist/dev.d.ts.map +1 -0
- package/dist/dev.js +98 -0
- package/dist/dev.js.map +1 -0
- package/dist/export.d.ts +8 -0
- package/dist/export.d.ts.map +1 -0
- package/dist/export.js +63 -0
- package/dist/export.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/watch.d.ts +5 -0
- package/dist/watch.d.ts.map +1 -0
- package/dist/watch.js +60 -0
- package/dist/watch.js.map +1 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# @walkr/cli
|
|
2
|
+
|
|
3
|
+
CLI for running Walkr demos in Studio and exporting media.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @walkr/cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or run without global install:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx walkr
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Commands
|
|
18
|
+
|
|
19
|
+
### `walkr dev <script>`
|
|
20
|
+
|
|
21
|
+
Opens Walkr Studio with live reload.
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
walkr dev demo.ts
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### `walkr export <script> [options]`
|
|
28
|
+
|
|
29
|
+
Exports a walkthrough to `mp4`, `gif`, `webm`, or `embed`.
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
walkr export demo.ts --format mp4 --output demo.mp4
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### `walkr --help`
|
|
36
|
+
|
|
37
|
+
Shows command help and examples.
|
|
38
|
+
|
|
39
|
+
## `walkr export` options
|
|
40
|
+
|
|
41
|
+
| Option | Type | Default | Description |
|
|
42
|
+
| --- | --- | --- | --- |
|
|
43
|
+
| `--format` | `mp4 \| gif \| webm \| embed` | `mp4` | Output format. |
|
|
44
|
+
| `--output` | `string` | `output.<ext>` | Output path. For `embed`, extension is `.html`. |
|
|
45
|
+
| `--width` | `number` | `1920` | Render width in px. |
|
|
46
|
+
| `--height` | `number` | `1080` | Render height in px. |
|
|
47
|
+
|
|
48
|
+
## Example `demo.ts`
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import {
|
|
52
|
+
walkr,
|
|
53
|
+
moveTo,
|
|
54
|
+
click,
|
|
55
|
+
type,
|
|
56
|
+
highlight,
|
|
57
|
+
scroll,
|
|
58
|
+
wait,
|
|
59
|
+
sequence,
|
|
60
|
+
parallel,
|
|
61
|
+
zoom,
|
|
62
|
+
pan,
|
|
63
|
+
} from "@walkr/core";
|
|
64
|
+
|
|
65
|
+
export default walkr({
|
|
66
|
+
url: "https://example.com",
|
|
67
|
+
title: "Walkr CLI demo",
|
|
68
|
+
description: "A complete scripted walkthrough for local preview/export",
|
|
69
|
+
cursor: {
|
|
70
|
+
shape: "circle",
|
|
71
|
+
color: "#22d3ee",
|
|
72
|
+
size: 18,
|
|
73
|
+
shadow: true,
|
|
74
|
+
clickColor: "#0ea5e9",
|
|
75
|
+
},
|
|
76
|
+
steps: [
|
|
77
|
+
moveTo(620, 380, { duration: 700 }),
|
|
78
|
+
click(620, 380),
|
|
79
|
+
type("hello@example.com", { selector: "input[name=email]", delay: 35 }),
|
|
80
|
+
parallel(
|
|
81
|
+
highlight(".submit-btn", {
|
|
82
|
+
spotlight: true,
|
|
83
|
+
color: "#22d3ee",
|
|
84
|
+
duration: 1200,
|
|
85
|
+
backdropOpacity: 0.35,
|
|
86
|
+
}),
|
|
87
|
+
sequence(
|
|
88
|
+
wait(200),
|
|
89
|
+
moveTo(810, 505, { duration: 500 }),
|
|
90
|
+
),
|
|
91
|
+
),
|
|
92
|
+
click(810, 505),
|
|
93
|
+
sequence(
|
|
94
|
+
wait(300),
|
|
95
|
+
scroll(0, 700, { smooth: true }),
|
|
96
|
+
wait(200),
|
|
97
|
+
zoom(1.2, { x: 960, y: 500 }),
|
|
98
|
+
pan(960, 460, { duration: 500 }),
|
|
99
|
+
),
|
|
100
|
+
],
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Requirements
|
|
105
|
+
|
|
106
|
+
- Node.js `>=18`
|
|
107
|
+
- `pnpm`
|
|
108
|
+
- `@walkr/playwright` installed in your project for `walkr export`
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAIA,eAAO,MAAM,OAAO,UAAU,CAAC"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { devCommand } from "./dev.js";
|
|
3
|
+
import { exportCommand } from "./export.js";
|
|
4
|
+
export const VERSION = "0.1.0";
|
|
5
|
+
const USAGE = `\
|
|
6
|
+
Usage: walkr <command> [options]
|
|
7
|
+
|
|
8
|
+
Commands:
|
|
9
|
+
walkr dev <script> Start Walkr Studio with live script reload
|
|
10
|
+
walkr export <script> [options] Export walkthrough as video or embed
|
|
11
|
+
|
|
12
|
+
Export options:
|
|
13
|
+
--format mp4|gif|webm|embed Output format (default: mp4)
|
|
14
|
+
--output <path> Output file path (default: output.<ext>)
|
|
15
|
+
--width <n> Video width in px (default: 1920)
|
|
16
|
+
--height <n> Video height in px (default: 1080)
|
|
17
|
+
|
|
18
|
+
Examples:
|
|
19
|
+
walkr dev demo.ts
|
|
20
|
+
walkr export demo.ts --format gif --output demo.gif
|
|
21
|
+
walkr export demo.ts --format embed --output demo.html
|
|
22
|
+
`;
|
|
23
|
+
function parseArgs(argv) {
|
|
24
|
+
const args = argv.slice(2);
|
|
25
|
+
const result = {
|
|
26
|
+
command: null,
|
|
27
|
+
scriptPath: null,
|
|
28
|
+
exportOptions: {},
|
|
29
|
+
help: false,
|
|
30
|
+
version: false,
|
|
31
|
+
};
|
|
32
|
+
for (let i = 0; i < args.length; i++) {
|
|
33
|
+
const arg = args[i];
|
|
34
|
+
if (arg === "--help" || arg === "-h") {
|
|
35
|
+
result.help = true;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (arg === "--version" || arg === "-v") {
|
|
39
|
+
result.version = true;
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (arg === "--format") {
|
|
43
|
+
result.exportOptions.format = args[++i];
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (arg === "--output") {
|
|
47
|
+
result.exportOptions.output = args[++i];
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (arg === "--width") {
|
|
51
|
+
result.exportOptions.width = parseInt(args[++i], 10);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (arg === "--height") {
|
|
55
|
+
result.exportOptions.height = parseInt(args[++i], 10);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (!result.command) {
|
|
59
|
+
result.command = arg;
|
|
60
|
+
}
|
|
61
|
+
else if (!result.scriptPath) {
|
|
62
|
+
result.scriptPath = arg;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
async function main() {
|
|
68
|
+
const parsed = parseArgs(process.argv);
|
|
69
|
+
if (parsed.version) {
|
|
70
|
+
console.log(`walkr v${VERSION}`);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (parsed.help || !parsed.command) {
|
|
74
|
+
console.log(USAGE);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (parsed.command === "dev") {
|
|
78
|
+
if (!parsed.scriptPath) {
|
|
79
|
+
console.error("Error: walkr dev requires a script path.\n");
|
|
80
|
+
console.error(" Example: walkr dev demo.ts");
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
83
|
+
await devCommand(parsed.scriptPath);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (parsed.command === "export") {
|
|
87
|
+
if (!parsed.scriptPath) {
|
|
88
|
+
console.error("Error: walkr export requires a script path.\n");
|
|
89
|
+
console.error(" Example: walkr export demo.ts --format mp4");
|
|
90
|
+
process.exit(1);
|
|
91
|
+
}
|
|
92
|
+
await exportCommand(parsed.scriptPath, parsed.exportOptions);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
console.error(`Error: unknown command "${parsed.command}"\n`);
|
|
96
|
+
console.error(USAGE);
|
|
97
|
+
process.exit(1);
|
|
98
|
+
}
|
|
99
|
+
main().catch((error) => {
|
|
100
|
+
console.error("Fatal error:", error);
|
|
101
|
+
process.exit(1);
|
|
102
|
+
});
|
|
103
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAsB,aAAa,EAAE,MAAM,aAAa,CAAC;AAEhE,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAE/B,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;CAiBb,CAAC;AAUF,SAAS,SAAS,CAAC,IAAc;IAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3B,MAAM,MAAM,GAAe;QACzB,OAAO,EAAE,IAAI;QACb,UAAU,EAAE,IAAI;QAChB,aAAa,EAAE,EAAE;QACj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M,CAAC,OAAO,KAAK,CAAC,CAAC;IAC9D,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC9B,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/dev.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../src/dev.ts"],"names":[],"mappings":"AAgCA,wBAAsB,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAuFlE"}
|
package/dist/dev.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { dirname, resolve } from "node:path";
|
|
4
|
+
import { loadScriptWalkthrough, watchScript } from "./watch.js";
|
|
5
|
+
const STUDIO_PORT = 5174;
|
|
6
|
+
const PROXY_PREFIX = "/__target__";
|
|
7
|
+
function openBrowser(url) {
|
|
8
|
+
const start = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
|
|
9
|
+
spawn(start, [url], { detached: true, stdio: "ignore" }).unref();
|
|
10
|
+
}
|
|
11
|
+
function rewriteWalkthroughUrl(walkthrough, targetOrigin) {
|
|
12
|
+
return {
|
|
13
|
+
...walkthrough,
|
|
14
|
+
originalUrl: walkthrough.url,
|
|
15
|
+
url: walkthrough.url.replace(targetOrigin, PROXY_PREFIX),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function writeWalkthroughJson(path, walkthrough, targetOrigin) {
|
|
19
|
+
const proxied = targetOrigin ? rewriteWalkthroughUrl(walkthrough, targetOrigin) : walkthrough;
|
|
20
|
+
writeFileSync(path, JSON.stringify(proxied, null, 2));
|
|
21
|
+
}
|
|
22
|
+
export async function devCommand(scriptPath) {
|
|
23
|
+
const resolvedScript = resolve(process.cwd(), scriptPath);
|
|
24
|
+
// Resolve the studio package path (sibling in monorepo)
|
|
25
|
+
const studioRoot = new URL("../../studio", import.meta.url).pathname;
|
|
26
|
+
// Write loaded walkthrough JSON to Studio's public dir so it can fetch on startup
|
|
27
|
+
const walkthroughJsonPath = resolve(studioRoot, "public", "walkthrough.json");
|
|
28
|
+
mkdirSync(dirname(walkthroughJsonPath), { recursive: true });
|
|
29
|
+
console.log(`\nWalkr Studio starting…`);
|
|
30
|
+
console.log(`Script: ${scriptPath}\n`);
|
|
31
|
+
// Load the script first (awaited) to extract the target origin before Vite starts
|
|
32
|
+
const initialWalkthrough = await loadScriptWalkthrough(resolvedScript);
|
|
33
|
+
let targetOrigin = "";
|
|
34
|
+
try {
|
|
35
|
+
targetOrigin = new URL(initialWalkthrough.url).origin;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
console.error(`[walkr] Invalid walkthrough URL: ${initialWalkthrough.url}`);
|
|
39
|
+
}
|
|
40
|
+
console.log(`Target origin: ${targetOrigin}`);
|
|
41
|
+
writeWalkthroughJson(walkthroughJsonPath, initialWalkthrough, targetOrigin);
|
|
42
|
+
// Write proxy target file so the Vite config can read it (survives Vite restarts)
|
|
43
|
+
const proxyTargetPath = resolve(studioRoot, ".walkr-proxy-target");
|
|
44
|
+
writeFileSync(proxyTargetPath, targetOrigin);
|
|
45
|
+
// Watch for subsequent script changes
|
|
46
|
+
const stopWatcher = watchScript(resolvedScript, () => {
|
|
47
|
+
void (async () => {
|
|
48
|
+
try {
|
|
49
|
+
const walkthrough = await loadScriptWalkthrough(resolvedScript);
|
|
50
|
+
console.log("Script reloaded, writing walkthrough.json…");
|
|
51
|
+
writeWalkthroughJson(walkthroughJsonPath, walkthrough, targetOrigin);
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
console.error(`[walkr] Failed to reload script`, error);
|
|
55
|
+
}
|
|
56
|
+
})();
|
|
57
|
+
});
|
|
58
|
+
const vite = spawn("npx", ["vite", "--port", String(STUDIO_PORT)], {
|
|
59
|
+
cwd: studioRoot,
|
|
60
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
61
|
+
shell: false,
|
|
62
|
+
env: {
|
|
63
|
+
...process.env,
|
|
64
|
+
WALKR_PROXY_TARGET: targetOrigin,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
let ready = false;
|
|
68
|
+
const onData = (data) => {
|
|
69
|
+
const text = data.toString();
|
|
70
|
+
process.stdout.write(text);
|
|
71
|
+
if (!ready && (text.includes("Local:") || text.includes("localhost"))) {
|
|
72
|
+
ready = true;
|
|
73
|
+
const url = `http://localhost:${STUDIO_PORT}`;
|
|
74
|
+
console.log(`\nWalkr Studio running at ${url}\n`);
|
|
75
|
+
openBrowser(url);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
vite.stdout.on("data", onData);
|
|
79
|
+
vite.stderr.on("data", onData);
|
|
80
|
+
const cleanup = () => {
|
|
81
|
+
console.log("\nShutting down…");
|
|
82
|
+
stopWatcher();
|
|
83
|
+
try {
|
|
84
|
+
rmSync(proxyTargetPath, { force: true });
|
|
85
|
+
}
|
|
86
|
+
catch { }
|
|
87
|
+
vite.kill("SIGTERM");
|
|
88
|
+
process.exit(0);
|
|
89
|
+
};
|
|
90
|
+
process.on("SIGINT", cleanup);
|
|
91
|
+
process.on("SIGTERM", cleanup);
|
|
92
|
+
await new Promise((resolve) => {
|
|
93
|
+
vite.on("close", () => {
|
|
94
|
+
resolve();
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=dev.js.map
|
package/dist/dev.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.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,GAAG,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CAAC;IAEF,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE/B,MAAM,OAAO,GAAG,GAAS,EAAE;QACzB,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;QAChC,WAAW,EAAE,CAAC;QACd,IAAI,CAAC;YACH,MAAM,CAAC,eAAe,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAC3C,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;QACV,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC;IAEF,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC9B,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAE/B,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;QAClC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;YACpB,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/export.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface ExportOptions {
|
|
2
|
+
format?: "mp4" | "gif" | "webm" | "embed";
|
|
3
|
+
output?: string;
|
|
4
|
+
width?: number;
|
|
5
|
+
height?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function exportCommand(scriptPath: string, options: ExportOptions): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=export.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../src/export.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAwBD,wBAAsB,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAyD7F"}
|
package/dist/export.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { pathToFileURL } from "node:url";
|
|
2
|
+
function isWalkthrough(value) {
|
|
3
|
+
if (!value || typeof value !== "object")
|
|
4
|
+
return false;
|
|
5
|
+
const v = value;
|
|
6
|
+
return typeof v.url === "string" && Array.isArray(v.steps);
|
|
7
|
+
}
|
|
8
|
+
async function loadWalkthrough(scriptPath) {
|
|
9
|
+
const url = pathToFileURL(scriptPath);
|
|
10
|
+
url.searchParams.set("t", String(Date.now()));
|
|
11
|
+
const mod = (await import(url.toString()));
|
|
12
|
+
const wt = mod.default;
|
|
13
|
+
if (!isWalkthrough(wt)) {
|
|
14
|
+
throw new Error(`Script "${scriptPath}" must export a Walkthrough as default. Got: ${typeof wt}`);
|
|
15
|
+
}
|
|
16
|
+
return wt;
|
|
17
|
+
}
|
|
18
|
+
export async function exportCommand(scriptPath, options) {
|
|
19
|
+
const format = options.format ?? "mp4";
|
|
20
|
+
const ext = format === "embed" ? "html" : format;
|
|
21
|
+
const output = options.output ?? `output.${ext}`;
|
|
22
|
+
console.log(`\nWalkr Export`);
|
|
23
|
+
console.log(` Script: ${scriptPath}`);
|
|
24
|
+
console.log(` Format: ${format}`);
|
|
25
|
+
console.log(` Output: ${output}`);
|
|
26
|
+
console.log(` Size: ${options.width ?? 1920} × ${options.height ?? 1080}`);
|
|
27
|
+
console.log();
|
|
28
|
+
console.log("Loading script…");
|
|
29
|
+
const walkthrough = await loadWalkthrough(scriptPath);
|
|
30
|
+
console.log(` Steps: ${walkthrough.steps.length}`);
|
|
31
|
+
// Dynamic import of @walkrstudio/playwright (peer dep — must be installed)
|
|
32
|
+
let captureWalkthrough;
|
|
33
|
+
try {
|
|
34
|
+
const mod = (await import("@walkrstudio/playwright"));
|
|
35
|
+
captureWalkthrough = mod.captureWalkthrough;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
throw new Error("@walkrstudio/playwright is not installed. Run: pnpm add @walkrstudio/playwright");
|
|
39
|
+
}
|
|
40
|
+
console.log("Capturing frames…");
|
|
41
|
+
let lastPercent = -1;
|
|
42
|
+
const result = await captureWalkthrough(walkthrough, {
|
|
43
|
+
format,
|
|
44
|
+
output,
|
|
45
|
+
width: options.width ?? 1920,
|
|
46
|
+
height: options.height ?? 1080,
|
|
47
|
+
fps: 30,
|
|
48
|
+
onProgress: (percent) => {
|
|
49
|
+
const rounded = Math.round(percent);
|
|
50
|
+
if (rounded !== lastPercent && rounded % 5 === 0) {
|
|
51
|
+
lastPercent = rounded;
|
|
52
|
+
process.stdout.write(`\r Capturing frames… ${rounded}%`);
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
process.stdout.write("\n");
|
|
57
|
+
console.log("Encoding…");
|
|
58
|
+
console.log();
|
|
59
|
+
console.log(`Done: ${result.outputPath}`);
|
|
60
|
+
console.log(` Frames: ${result.frameCount}`);
|
|
61
|
+
console.log(` Duration: ${(result.duration / 1000).toFixed(2)}s`);
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=export.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.js","sourceRoot":"","sources":["../src/export.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAUzC,SAAS,aAAa,CAAC,KAAc;IACnC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,O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KACF,CAAC,CAAC;IAEH,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC3B,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACzB,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CAAC,SAAS,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;IAC1C,OAAO,CAAC,GAAG,CAAC,eAAe,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;IAChD,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AACrE,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,UAAU,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/watch.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Walkthrough } from "@walkrstudio/core";
|
|
2
|
+
export declare const loadScriptWalkthrough: (scriptPath: string) => Promise<Walkthrough>;
|
|
3
|
+
export declare const watchScript: (scriptPath: string, callback: () => void) => (() => void);
|
|
4
|
+
export declare const watch: (scriptPath: string, onChange: (walkthrough: Walkthrough) => void) => (() => void);
|
|
5
|
+
//# sourceMappingURL=watch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../src/watch.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAarD,eAAO,MAAM,qBAAqB,GAAU,YAAY,MAAM,KAAG,OAAO,CAAC,WAAW,CAUnF,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,YAAY,MAAM,EAAE,UAAU,MAAM,IAAI,KAAG,CAAC,MAAM,IAAI,CAuBjF,CAAC;AAEF,eAAO,MAAM,KAAK,GAChB,YAAY,MAAM,EAClB,UAAU,CAAC,WAAW,EAAE,WAAW,KAAK,IAAI,KAC3C,CAAC,MAAM,IAAI,CAqBb,CAAC"}
|
package/dist/watch.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { watch as fsWatch } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
const WATCH_DEBOUNCE_MS = 200;
|
|
5
|
+
const isWalkthrough = (value) => {
|
|
6
|
+
if (!value || typeof value !== "object") {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
const maybeWalkthrough = value;
|
|
10
|
+
return typeof maybeWalkthrough.url === "string" && Array.isArray(maybeWalkthrough.steps);
|
|
11
|
+
};
|
|
12
|
+
export const loadScriptWalkthrough = async (scriptPath) => {
|
|
13
|
+
const scriptUrl = pathToFileURL(scriptPath);
|
|
14
|
+
scriptUrl.searchParams.set("t", String(Date.now()));
|
|
15
|
+
const importedModule = (await import(scriptUrl.href));
|
|
16
|
+
if (!isWalkthrough(importedModule.default)) {
|
|
17
|
+
throw new Error("Script default export must be a Walkthrough");
|
|
18
|
+
}
|
|
19
|
+
return importedModule.default;
|
|
20
|
+
};
|
|
21
|
+
export const watchScript = (scriptPath, callback) => {
|
|
22
|
+
const absolutePath = resolve(scriptPath);
|
|
23
|
+
let debounceTimer = null;
|
|
24
|
+
const watcher = fsWatch(absolutePath, () => {
|
|
25
|
+
if (debounceTimer) {
|
|
26
|
+
clearTimeout(debounceTimer);
|
|
27
|
+
}
|
|
28
|
+
debounceTimer = setTimeout(() => {
|
|
29
|
+
console.log(`[walkr] File change detected: ${absolutePath}`);
|
|
30
|
+
callback();
|
|
31
|
+
}, WATCH_DEBOUNCE_MS);
|
|
32
|
+
});
|
|
33
|
+
return () => {
|
|
34
|
+
if (debounceTimer) {
|
|
35
|
+
clearTimeout(debounceTimer);
|
|
36
|
+
debounceTimer = null;
|
|
37
|
+
}
|
|
38
|
+
watcher.close();
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export const watch = (scriptPath, onChange) => {
|
|
42
|
+
const absolutePath = resolve(scriptPath);
|
|
43
|
+
const reload = async () => {
|
|
44
|
+
try {
|
|
45
|
+
const walkthrough = await loadScriptWalkthrough(absolutePath);
|
|
46
|
+
onChange(walkthrough);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
console.error(`[walkr] Failed to load script ${absolutePath}`, error);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
void reload();
|
|
53
|
+
const stopWatching = watchScript(absolutePath, () => {
|
|
54
|
+
void reload();
|
|
55
|
+
});
|
|
56
|
+
return () => {
|
|
57
|
+
stopWatching();
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=watch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch.js","sourceRoot":"","sources":["../src/watch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,MAAM,SAA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
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"walkr": "./dist/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@walkrstudio/core": "0.2.0"
|
|
18
|
+
},
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"@walkrstudio/playwright": "0.2.0"
|
|
21
|
+
},
|
|
22
|
+
"peerDependenciesMeta": {
|
|
23
|
+
"@walkrstudio/playwright": {
|
|
24
|
+
"optional": true
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/node": "^22.15.3",
|
|
29
|
+
"@walkrstudio/playwright": "0.2.0"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsc -p tsconfig.json",
|
|
33
|
+
"lint": "biome check src",
|
|
34
|
+
"type-check": "tsc -p tsconfig.json --noEmit",
|
|
35
|
+
"dev": "tsc -p tsconfig.json --watch"
|
|
36
|
+
}
|
|
37
|
+
}
|