@solidrt/cli 0.0.1-exp.7 → 0.0.1-exp.8
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 -4
- package/src/build.ts +1 -1
- package/src/client.ts +1 -1
- package/src/main.ts +1 -1
- package/src/repl.ts +8 -8
- package/src/server.ts +9 -9
- package/src/watcher.ts +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidrt/cli",
|
|
3
|
-
"version": "0.0.1-exp.
|
|
3
|
+
"version": "0.0.1-exp.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Antoine van Wel",
|
|
6
6
|
"type": "module",
|
|
@@ -19,13 +19,14 @@
|
|
|
19
19
|
"qrcode-generator": "^2.0.4"
|
|
20
20
|
},
|
|
21
21
|
"optionalDependencies": {
|
|
22
|
-
"@solidrt/darwin-arm64": "0.0.1-exp.
|
|
23
|
-
"@solidrt/linux-x64-gnu": "0.0.1-exp.
|
|
22
|
+
"@solidrt/darwin-arm64": "0.0.1-exp.8",
|
|
23
|
+
"@solidrt/linux-x64-gnu": "0.0.1-exp.8",
|
|
24
|
+
"@solidrt/win32-x64-msvc": "0.0.1-exp.8"
|
|
24
25
|
},
|
|
25
26
|
"peerDependencies": {
|
|
26
27
|
"@solidjs/signals": "2.0.0-beta.7",
|
|
27
28
|
"@solidjs/universal": "2.0.0-beta.7",
|
|
28
|
-
"@solidrt/core": "0.0.1-exp.
|
|
29
|
+
"@solidrt/core": "0.0.1-exp.8",
|
|
29
30
|
"typescript": "^5"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
package/src/build.ts
CHANGED
package/src/client.ts
CHANGED
|
@@ -31,6 +31,6 @@ export function spawnClient() {
|
|
|
31
31
|
state.server?.stop()
|
|
32
32
|
process.exit(0)
|
|
33
33
|
}
|
|
34
|
-
print(`[
|
|
34
|
+
print(`[cli] Local client exited, ${state.clients.size} remote client(s) still connected`)
|
|
35
35
|
})
|
|
36
36
|
}
|
package/src/main.ts
CHANGED
|
@@ -75,6 +75,6 @@ process.on("SIGINT", shutdown)
|
|
|
75
75
|
process.on("SIGTERM", shutdown)
|
|
76
76
|
|
|
77
77
|
let version = pkg.version === "0.0.0" ? "" : " version " + pkg.version
|
|
78
|
-
console.log(`Welcome to SolidRT${version}!`)
|
|
78
|
+
console.log(`[cli] Welcome to SolidRT${version}!`)
|
|
79
79
|
startRepl()
|
|
80
80
|
startWatcher()
|
package/src/repl.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { startWatcher } from "./watcher"
|
|
|
8
8
|
function cmdStop(args: string) {
|
|
9
9
|
if (!args) {
|
|
10
10
|
broadcastStop()
|
|
11
|
-
print("[
|
|
11
|
+
print("[cli] Sent stop to all clients")
|
|
12
12
|
return
|
|
13
13
|
}
|
|
14
14
|
let clientList = [...state.clients.keys()]
|
|
@@ -19,7 +19,7 @@ function cmdStop(args: string) {
|
|
|
19
19
|
continue
|
|
20
20
|
}
|
|
21
21
|
clientList[idx].send(JSON.stringify({ type: "stop" }))
|
|
22
|
-
print(`[
|
|
22
|
+
print(`[cli] Sent stop to client ${idx}`)
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -27,7 +27,7 @@ async function cmdReload(args: string) {
|
|
|
27
27
|
if (state.source && state.source.endsWith(".tsx")) {
|
|
28
28
|
let result = await bundle(state.source)
|
|
29
29
|
if (!result) {
|
|
30
|
-
printErr("[
|
|
30
|
+
printErr("[cli] Build failed, reload aborted")
|
|
31
31
|
return
|
|
32
32
|
}
|
|
33
33
|
for (let output of result.outputs) {
|
|
@@ -37,7 +37,7 @@ async function cmdReload(args: string) {
|
|
|
37
37
|
let msg = JSON.stringify({ type: "reload", code: state.currentCode })
|
|
38
38
|
if (!args) {
|
|
39
39
|
for (let ws of state.clients.keys()) ws.send(msg)
|
|
40
|
-
print("[
|
|
40
|
+
print("[cli] Sent reload to all clients")
|
|
41
41
|
return
|
|
42
42
|
}
|
|
43
43
|
let clientList = [...state.clients.keys()]
|
|
@@ -48,7 +48,7 @@ async function cmdReload(args: string) {
|
|
|
48
48
|
continue
|
|
49
49
|
}
|
|
50
50
|
clientList[idx].send(msg)
|
|
51
|
-
print(`[
|
|
51
|
+
print(`[cli] Sent reload to client ${idx}`)
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -73,7 +73,7 @@ async function cmdLoad(file: string) {
|
|
|
73
73
|
if (file.endsWith(".tsx")) {
|
|
74
74
|
let result = await bundle(path)
|
|
75
75
|
if (!result) {
|
|
76
|
-
printErr("[
|
|
76
|
+
printErr("[cli] Build failed")
|
|
77
77
|
return
|
|
78
78
|
}
|
|
79
79
|
for (let output of result.outputs) {
|
|
@@ -85,7 +85,7 @@ async function cmdLoad(file: string) {
|
|
|
85
85
|
let bytes = await Bun.file(path).arrayBuffer()
|
|
86
86
|
let msg = { type: "reload", bytecode: Buffer.from(bytes).toString("base64") }
|
|
87
87
|
for (let ws of state.clients.keys()) ws.send(JSON.stringify(msg))
|
|
88
|
-
print(`[
|
|
88
|
+
print(`[cli] Loaded ${file} (bytecode, ${bytes.byteLength} bytes)`)
|
|
89
89
|
return
|
|
90
90
|
} else {
|
|
91
91
|
print("Unsupported file type. Use .tsx, .srt.js, or .srt.bin")
|
|
@@ -97,7 +97,7 @@ async function cmdLoad(file: string) {
|
|
|
97
97
|
for (let ws of state.clients.keys()) {
|
|
98
98
|
ws.send(JSON.stringify({ type: "reload", code: state.currentCode }))
|
|
99
99
|
}
|
|
100
|
-
print(`[
|
|
100
|
+
print(`[cli] Loaded ${file}`)
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
let COMMANDS = ["load ", "stop", "reload", "list", "quit", "exit", "help"]
|
package/src/server.ts
CHANGED
|
@@ -14,7 +14,7 @@ export function startServer() {
|
|
|
14
14
|
let url = new URL(req.url)
|
|
15
15
|
let path = decodeURIComponent(url.pathname)
|
|
16
16
|
|
|
17
|
-
print("[
|
|
17
|
+
print("[cli] get", path)
|
|
18
18
|
|
|
19
19
|
let filePath = resolve(state.sourceDir, "." + path)
|
|
20
20
|
if (!filePath.startsWith(state.sourceDir)) {
|
|
@@ -24,7 +24,7 @@ export function startServer() {
|
|
|
24
24
|
try {
|
|
25
25
|
stat = await fsStat(filePath)
|
|
26
26
|
} catch {
|
|
27
|
-
print("[
|
|
27
|
+
print("[cli] file not found %s", path)
|
|
28
28
|
return new Response("Not found", { status: 404 })
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -52,7 +52,7 @@ export function startServer() {
|
|
|
52
52
|
websocket: {
|
|
53
53
|
open(ws) {
|
|
54
54
|
state.clients.set(ws, { platform: "unknown", version: "unknown" })
|
|
55
|
-
print(`[
|
|
55
|
+
print(`[cli] Client connected ${ws.remoteAddress}`)
|
|
56
56
|
if (state.currentCode) {
|
|
57
57
|
ws.send(JSON.stringify({ type: "reload", code: state.currentCode }))
|
|
58
58
|
}
|
|
@@ -60,9 +60,9 @@ export function startServer() {
|
|
|
60
60
|
close(ws) {
|
|
61
61
|
let info = state.clients.get(ws)
|
|
62
62
|
state.clients.delete(ws)
|
|
63
|
-
print(`[
|
|
63
|
+
print(`[cli] Client disconnected: ${info?.platform ?? "unknown"}`)
|
|
64
64
|
if (state.child && state.clients.size === 0 && state.child.exitCode !== null) {
|
|
65
|
-
print("[
|
|
65
|
+
print("[cli] All clients disconnected, shutting down")
|
|
66
66
|
state.server?.stop()
|
|
67
67
|
process.exit(0)
|
|
68
68
|
}
|
|
@@ -75,7 +75,7 @@ export function startServer() {
|
|
|
75
75
|
platform: data.platform ?? "unknown",
|
|
76
76
|
version: data.version ?? "unknown",
|
|
77
77
|
})
|
|
78
|
-
print(`[
|
|
78
|
+
print(`[cli] Client info ${ws.remoteAddress} ${data.platform} (${data.version})`)
|
|
79
79
|
}
|
|
80
80
|
} catch {}
|
|
81
81
|
},
|
|
@@ -107,19 +107,19 @@ export function startServer() {
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
console.log("")
|
|
110
|
-
console.log(`[
|
|
110
|
+
console.log(`[cli] WebSocket server on ws://${serverUrl}`)
|
|
111
111
|
|
|
112
112
|
// UDP discovery
|
|
113
113
|
let udp = createSocket("udp4")
|
|
114
114
|
udp.on("message", (msg, rinfo) => {
|
|
115
115
|
if (msg.toString() === "SRT_DISCOVER") {
|
|
116
|
-
print(`[
|
|
116
|
+
print(`[cli] Discovery request from ${rinfo.address}:${rinfo.port}`)
|
|
117
117
|
udp.send("SRT_SERVER", rinfo.port, rinfo.address)
|
|
118
118
|
}
|
|
119
119
|
})
|
|
120
120
|
udp.bind(DEV_PORT, () => {
|
|
121
121
|
udp.setBroadcast(true)
|
|
122
|
-
print("[
|
|
122
|
+
print("[cli] UDP discovery listener on port " + DEV_PORT)
|
|
123
123
|
})
|
|
124
124
|
|
|
125
125
|
// Keepalive
|
package/src/watcher.ts
CHANGED
|
@@ -11,15 +11,15 @@ export function startWatcher() {
|
|
|
11
11
|
|
|
12
12
|
if (currentWatcher) currentWatcher.close()
|
|
13
13
|
|
|
14
|
-
print(`[
|
|
14
|
+
print(`[cli] Watching ${watchDir} for changes...`)
|
|
15
15
|
currentWatcher = watch(watchDir, { recursive: true }, async (_event, filename) => {
|
|
16
16
|
if (!filename) return
|
|
17
17
|
if (!/\.(tsx?|jsx?)$/.test(filename)) return
|
|
18
18
|
|
|
19
|
-
print(`[
|
|
19
|
+
print(`[cli] Change detected: ${filename}`)
|
|
20
20
|
let result = await bundle(state.source)
|
|
21
21
|
if (!result) {
|
|
22
|
-
printErr("[
|
|
22
|
+
printErr("[cli] Build failed, waiting for changes...")
|
|
23
23
|
return
|
|
24
24
|
}
|
|
25
25
|
for (let output of result.outputs) {
|