@solidrt/cli 0.0.4 → 0.0.5
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 +5 -5
- package/src/args.ts +2 -0
- package/src/client.ts +2 -1
- package/src/main.ts +1 -1
- package/src/repl.ts +6 -5
- package/src/server.ts +2 -2
- package/src/util.ts +5 -0
- package/src/watcher.ts +3 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidrt/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
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.
|
|
23
|
-
"@solidrt/linux-x64-gnu": "0.0.
|
|
24
|
-
"@solidrt/win32-x64-msvc": "0.0.
|
|
22
|
+
"@solidrt/darwin-arm64": "0.0.5",
|
|
23
|
+
"@solidrt/linux-x64-gnu": "0.0.5",
|
|
24
|
+
"@solidrt/win32-x64-msvc": "0.0.5"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@solidrt/core": "0.0.
|
|
27
|
+
"@solidrt/core": "0.0.5",
|
|
28
28
|
"typescript": "^5"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
package/src/args.ts
CHANGED
|
@@ -9,6 +9,7 @@ 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
|
+
proxy: { type: "boolean", default: false },
|
|
12
13
|
fps: { type: "string" },
|
|
13
14
|
duration: { type: "string" },
|
|
14
15
|
size: { type: "string" },
|
|
@@ -35,6 +36,7 @@ run options:
|
|
|
35
36
|
--client Run client only
|
|
36
37
|
--server Run server only
|
|
37
38
|
--cache Enable HTTP cache
|
|
39
|
+
--proxy Tell connected clients to route file/dir/fetch through the dev server
|
|
38
40
|
--size <WxH> Window size (default: 1280x720)
|
|
39
41
|
|
|
40
42
|
build options:
|
package/src/client.ts
CHANGED
|
@@ -16,7 +16,8 @@ function pipeAbovePrompt(stream: ReadableStream<Uint8Array>, out: NodeJS.WriteSt
|
|
|
16
16
|
|
|
17
17
|
export function spawnClient() {
|
|
18
18
|
let runner = requireBinary("solidrt-go")
|
|
19
|
-
let args
|
|
19
|
+
let args: string[] = []
|
|
20
|
+
if (values.size) args.push("--size", values.size)
|
|
20
21
|
state.child = Bun.spawn([runner, ...args], {
|
|
21
22
|
//TODO implement dev server connection
|
|
22
23
|
// state.child = Bun.spawn([runner, "--dev-server", `${DEV_HOST}:${DEV_PORT}`], {
|
package/src/main.ts
CHANGED
|
@@ -78,7 +78,7 @@ state.sourceDir = source ? dirname(resolve(source)) : process.cwd()
|
|
|
78
78
|
|
|
79
79
|
if (values.cache) {
|
|
80
80
|
cache.initCache({ dir: process.cwd() })
|
|
81
|
-
console.log("[cli] HTTP cache enabled
|
|
81
|
+
console.log("[cli] HTTP cache enabled")
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
startServer()
|
package/src/repl.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createInterface } from "node:readline"
|
|
2
2
|
import { resolve, dirname } from "path"
|
|
3
3
|
import { readdirSync } from "node:fs"
|
|
4
|
-
import { state, print, printErr, broadcastStop, shutdown } from "./util"
|
|
4
|
+
import { state, print, printErr, broadcastStop, buildReload, shutdown } from "./util"
|
|
5
5
|
import { bundle } from "./build"
|
|
6
6
|
import { startWatcher, stopWatcher } from "./watcher"
|
|
7
7
|
|
|
@@ -37,7 +37,7 @@ async function cmdReload(args: string) {
|
|
|
37
37
|
state.currentCode = await output.text()
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
let msg =
|
|
40
|
+
let msg = buildReload({ code: state.currentCode })
|
|
41
41
|
if (!args) {
|
|
42
42
|
for (let ws of state.clients.keys()) ws.send(msg)
|
|
43
43
|
print("[cli] Sent reload to all clients")
|
|
@@ -86,8 +86,8 @@ async function cmdLoad(file: string) {
|
|
|
86
86
|
state.currentCode = await Bun.file(path).text()
|
|
87
87
|
} else if (file.endsWith(".srt.bin")) {
|
|
88
88
|
let bytes = await Bun.file(path).arrayBuffer()
|
|
89
|
-
let msg = {
|
|
90
|
-
for (let ws of state.clients.keys()) ws.send(
|
|
89
|
+
let msg = buildReload({ bytecode: Buffer.from(bytes).toString("base64") })
|
|
90
|
+
for (let ws of state.clients.keys()) ws.send(msg)
|
|
91
91
|
print(`[cli] Loaded ${file} (bytecode, ${bytes.byteLength} bytes)`)
|
|
92
92
|
return
|
|
93
93
|
} else {
|
|
@@ -97,8 +97,9 @@ async function cmdLoad(file: string) {
|
|
|
97
97
|
state.source = path
|
|
98
98
|
state.sourceDir = dirname(path)
|
|
99
99
|
startWatcher()
|
|
100
|
+
let reloadMsg = buildReload({ code: state.currentCode })
|
|
100
101
|
for (let ws of state.clients.keys()) {
|
|
101
|
-
ws.send(
|
|
102
|
+
ws.send(reloadMsg)
|
|
102
103
|
}
|
|
103
104
|
print(`[cli] Loaded ${file}`)
|
|
104
105
|
}
|
package/src/server.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { stat as fsStat, readdir } from "node:fs/promises"
|
|
|
3
3
|
import { networkInterfaces } from "node:os"
|
|
4
4
|
import { createSocket } from "node:dgram"
|
|
5
5
|
import qrcode from "qrcode-generator"
|
|
6
|
-
import { DEV_HOST, DEV_PORT, state, print } from "./util"
|
|
6
|
+
import { DEV_HOST, DEV_PORT, state, print, buildReload } from "./util"
|
|
7
7
|
import * as cache from "./cache"
|
|
8
8
|
|
|
9
9
|
function headersToObject(h: Headers): Record<string, string> {
|
|
@@ -142,7 +142,7 @@ export function startServer() {
|
|
|
142
142
|
state.clients.set(ws, { platform: "unknown", version: "unknown" })
|
|
143
143
|
print(`[cli] Client connected ${ws.remoteAddress}`)
|
|
144
144
|
if (state.currentCode) {
|
|
145
|
-
ws.send(
|
|
145
|
+
ws.send(buildReload({ code: state.currentCode }))
|
|
146
146
|
}
|
|
147
147
|
},
|
|
148
148
|
close(ws) {
|
package/src/util.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { resolveBinary } from "./native"
|
|
2
|
+
import { values } from "./args"
|
|
2
3
|
import type { Interface as ReadlineInterface } from "node:readline"
|
|
3
4
|
import type { Server as BunServer } from "bun"
|
|
4
5
|
|
|
@@ -41,6 +42,10 @@ export function printErr(...args: any[]) {
|
|
|
41
42
|
state.rl?.prompt(true)
|
|
42
43
|
}
|
|
43
44
|
|
|
45
|
+
export function buildReload(payload: { code?: string | null; bytecode?: string }) {
|
|
46
|
+
return JSON.stringify({ type: "reload", proxy: values.proxy, ...payload })
|
|
47
|
+
}
|
|
48
|
+
|
|
44
49
|
export function broadcastStop() {
|
|
45
50
|
for (let ws of state.clients.keys()) {
|
|
46
51
|
ws.send(JSON.stringify({ type: "stop" }))
|
package/src/watcher.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { watch } from "node:fs"
|
|
2
2
|
import { resolve, dirname } from "path"
|
|
3
|
-
import { state, print, printErr } from "./util"
|
|
3
|
+
import { state, print, printErr, buildReload } from "./util"
|
|
4
4
|
import { bundle } from "./build"
|
|
5
5
|
|
|
6
6
|
let currentWatcher: ReturnType<typeof watch> | null = null
|
|
@@ -32,8 +32,9 @@ export function startWatcher() {
|
|
|
32
32
|
for (let output of result.outputs) {
|
|
33
33
|
state.currentCode = await output.text()
|
|
34
34
|
}
|
|
35
|
+
let msg = buildReload({ code: state.currentCode })
|
|
35
36
|
for (let ws of state.clients.keys()) {
|
|
36
|
-
ws.send(
|
|
37
|
+
ws.send(msg)
|
|
37
38
|
}
|
|
38
39
|
})
|
|
39
40
|
}
|