@solidrt/cli 0.0.3 → 0.0.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solidrt/cli",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "license": "MIT",
5
5
  "author": "Antoine van Wel",
6
6
  "type": "module",
@@ -19,12 +19,12 @@
19
19
  "qrcode-generator": "^2.0.4"
20
20
  },
21
21
  "optionalDependencies": {
22
- "@solidrt/darwin-arm64": "0.0.3",
23
- "@solidrt/linux-x64-gnu": "0.0.3",
24
- "@solidrt/win32-x64-msvc": "0.0.3"
22
+ "@solidrt/darwin-arm64": "0.0.4",
23
+ "@solidrt/linux-x64-gnu": "0.0.4",
24
+ "@solidrt/win32-x64-msvc": "0.0.4"
25
25
  },
26
26
  "peerDependencies": {
27
- "@solidrt/core": "0.0.3",
27
+ "@solidrt/core": "0.0.4",
28
28
  "typescript": "^5"
29
29
  },
30
30
  "devDependencies": {
package/src/args.ts CHANGED
@@ -9,6 +9,9 @@ export let { values, positionals } = parseArgs({
9
9
  client: { type: "boolean", default: false },
10
10
  server: { type: "boolean", default: false },
11
11
  cache: { type: "boolean", default: false },
12
+ fps: { type: "string" },
13
+ duration: { type: "string" },
14
+ size: { type: "string" },
12
15
  },
13
16
  allowPositionals: true,
14
17
  })
@@ -19,18 +22,29 @@ export let isTsx = source?.endsWith(".tsx")
19
22
  export let isPrebuilt = source?.endsWith(".srt.js") || source?.endsWith(".srt.bin")
20
23
 
21
24
  export function printUsage() {
22
- console.error(`Usage: srt <build|run> [options] [entry.tsx]
25
+ console.error(`Usage: srt <command> [options] [file]
23
26
 
24
27
  Commands:
25
- run [file.tsx] Start dev server + client (no file = embedded default)
26
- run --client Start dev client only (connects to WS server)
27
- run --server [file] Start dev server only, no client
28
+ run [file.tsx] Start dev server + local solidrt-go client
29
+ run --client Start solidrt-go client only
30
+ run --server [file.tsx] Start dev server only
31
+ build <file.tsx> Bundle
32
+ record <file.tsx> Capture frames for video generation
28
33
 
29
- Options:
34
+ run options:
35
+ --client Run client only
36
+ --server Run server only
37
+ --cache Enable HTTP cache
38
+ --size <WxH> Window size (default: 1280x720)
39
+
40
+ build options:
30
41
  -m, --minify Minify the output
31
- -c, --compile Compile to bytecode (build only)
32
- -o, --output <name> Bundle filename (build only)
33
- --stdout Write bundle to stdout (build only)
34
- --cache Enable HTTP cache for fetch traffic; entries are
35
- kept in .srt-cache/. Delete that folder to reset.`)
42
+ -c, --compile Compile to bytecode
43
+ -o, --output <name> Output filename
44
+ --stdout Write bundle to stdout
45
+
46
+ record options:
47
+ --fps <N> Frames per second (default: 60)
48
+ --duration <N> Duration in seconds (default: 1)
49
+ --size <WxH> Frame size (default: 1280x720)`)
36
50
  }
package/src/client.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { DEV_HOST, DEV_PORT, state, print, requireBinary } from "./util"
2
+ import { values } from "./args"
2
3
 
3
4
  function pipeAbovePrompt(stream: ReadableStream<Uint8Array>, out: NodeJS.WriteStream) {
4
5
  let reader = stream.getReader()
@@ -15,7 +16,8 @@ function pipeAbovePrompt(stream: ReadableStream<Uint8Array>, out: NodeJS.WriteSt
15
16
 
16
17
  export function spawnClient() {
17
18
  let runner = requireBinary("solidrt-go")
18
- state.child = Bun.spawn([runner], {
19
+ let args = values.size ? ["--size", values.size] : []
20
+ state.child = Bun.spawn([runner, ...args], {
19
21
  //TODO implement dev server connection
20
22
  // state.child = Bun.spawn([runner, "--dev-server", `${DEV_HOST}:${DEV_PORT}`], {
21
23
  stdio: ["ignore", "pipe", "pipe"],
package/src/main.ts CHANGED
@@ -10,11 +10,12 @@
10
10
  // srt build examples/hello.tsx - bundle TSX to .srt.js
11
11
  // srt build -c examples/hello.tsx - bundle TSX to .srt.js + compile to .srt.bin
12
12
  // srt build examples/hello.srt.js - compile .srt.js to .srt.bin
13
+ // srt record examples/hello.tsx - bundle TSX and run with frame capture
13
14
 
14
15
  import pkg from "../package.json"
15
16
  import { values, command, source, isTsx, isPrebuilt, printUsage } from "./args"
16
17
  import { state, requireBinary, run, shutdown } from "./util"
17
- import { bundle, runBuildCommand } from "./build"
18
+ import { bundle, bundleTo, runBuildCommand } from "./build"
18
19
  import { startServer } from "./server"
19
20
  import { spawnClient } from "./client"
20
21
  import { startRepl } from "./repl"
@@ -24,7 +25,7 @@ import { resolve, dirname } from "path"
24
25
 
25
26
  // -- Validate args --
26
27
 
27
- if (!command || (command !== "build" && command !== "run")) {
28
+ if (!command || (command !== "build" && command !== "run" && command !== "record")) {
28
29
  printUsage()
29
30
  process.exit(1)
30
31
  }
@@ -34,17 +35,37 @@ if (command === "build" && (!source || (!isTsx && !isPrebuilt))) {
34
35
  process.exit(1)
35
36
  }
36
37
 
38
+ if (command === "record" && (!source || !isTsx)) {
39
+ console.error("Usage: srt record <entry.tsx>")
40
+ process.exit(1)
41
+ }
42
+
37
43
  // -- Build command --
38
44
 
39
45
  if (command === "build") {
40
46
  await runBuildCommand()
41
47
  }
42
48
 
49
+ // -- Record command --
50
+
51
+ if (command === "record") {
52
+ let jsOutfile = source!.replace(/\.tsx$/, "") + ".srt.js"
53
+ await bundleTo(jsOutfile)
54
+ let runner = requireBinary("solidrt-go")
55
+ let recordArgs = ["--record", resolve(jsOutfile)]
56
+ if (values.fps) recordArgs.push("--fps", values.fps)
57
+ if (values.duration) recordArgs.push("--duration", values.duration)
58
+ if (values.size) recordArgs.push("--size", values.size)
59
+ let exit = await run(runner, recordArgs)
60
+ process.exit(exit)
61
+ }
62
+
43
63
  // -- Run command --
44
64
 
45
65
  if (values.client) {
46
66
  let runner = requireBinary("solidrt-go")
47
- let args = []
67
+ let args: string[] = []
68
+ if (values.size) args.push("--size", values.size)
48
69
  //TODO add dev server connection
49
70
  // if (source) args.push("--dev-server", source)
50
71
  let exit = await run(runner, args)