dsh-remote-go 0.2.0 → 0.3.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/README.md +11 -3
- package/{client.js → dist/client.js} +7144 -8367
- package/dist/index.js +4 -0
- package/dist/src/admission.js +21 -0
- package/dist/src/api.js +380 -0
- package/dist/src/atomic-json.js +201 -0
- package/dist/src/bootstrap.js +96 -0
- package/dist/src/connect/attach.js +21 -0
- package/dist/src/connect/bootstrap.js +8 -0
- package/dist/src/connect/failures.js +29 -0
- package/dist/src/connect/guards.js +36 -0
- package/dist/src/connect/launch.js +70 -0
- package/dist/src/connect/links.js +54 -0
- package/dist/src/connect/ownership.js +139 -0
- package/dist/src/connect/pipeline.js +376 -0
- package/dist/src/connect/reattach.js +191 -0
- package/dist/src/connect/registry.js +10 -0
- package/dist/src/connect/repair.js +97 -0
- package/dist/src/connect/restart.js +255 -0
- package/dist/src/connect/stop.js +164 -0
- package/dist/src/connect/transport.js +101 -0
- package/dist/src/connect/verify.js +30 -0
- package/dist/src/connect/watchdog.js +44 -0
- package/dist/src/connect-log.js +137 -0
- package/dist/src/connect-progress.js +110 -0
- package/dist/src/constants.js +29 -0
- package/dist/src/context.js +96 -0
- package/dist/src/diagnostics.js +133 -0
- package/dist/src/download-jobs.js +221 -0
- package/dist/src/errors.js +228 -0
- package/dist/src/events.js +326 -0
- package/dist/src/host-lifecycle.js +368 -0
- package/dist/src/host-registry.js +181 -0
- package/dist/src/host-runtime.js +77 -0
- package/dist/src/host-view.js +52 -0
- package/dist/src/index.js +196 -0
- package/dist/src/kernel-adapter.js +388 -0
- package/dist/src/key-files.js +39 -0
- package/dist/src/known-hosts.js +104 -0
- package/dist/src/layout.js +26 -0
- package/dist/src/local-download.js +311 -0
- package/dist/src/local-ssh.js +23 -0
- package/dist/src/local-version.js +87 -0
- package/dist/src/node/download.js +157 -0
- package/dist/src/node-runtime.js +327 -0
- package/dist/src/probe.js +95 -0
- package/dist/src/prompts.js +198 -0
- package/dist/src/proxy/cookies.js +102 -0
- package/dist/src/proxy/headers.js +167 -0
- package/dist/src/proxy/http.js +134 -0
- package/dist/src/proxy/index.js +121 -0
- package/dist/src/proxy/limits.js +6 -0
- package/dist/src/proxy/routes.js +32 -0
- package/dist/src/proxy/upgrade.js +160 -0
- package/dist/src/redact.js +85 -0
- package/dist/src/remote-files.js +60 -0
- package/dist/src/remote-path.js +82 -0
- package/dist/src/remote-proc.js +271 -0
- package/dist/src/remote-web/registry.js +107 -0
- package/dist/src/remote-web/resolve.js +229 -0
- package/dist/src/remote-web/start.js +190 -0
- package/dist/src/remote-web/stop.js +74 -0
- package/dist/src/request-trust.js +70 -0
- package/dist/src/runtime/dispatch.js +200 -0
- package/dist/src/runtime/effects.js +81 -0
- package/dist/src/runtime/events.js +35 -0
- package/dist/src/runtime/fsm.js +70 -0
- package/dist/src/runtime/rules.js +480 -0
- package/dist/src/secrets.js +119 -0
- package/dist/src/service.js +300 -0
- package/dist/src/settings.js +143 -0
- package/dist/src/ssh-config.js +257 -0
- package/dist/src/ssh-failures.js +71 -0
- package/dist/src/ssh-port.js +4 -0
- package/dist/src/ssh-sftp.js +258 -0
- package/dist/src/ssh.js +395 -0
- package/dist/src/store.js +174 -0
- package/dist/src/tool-shared.js +146 -0
- package/dist/src/tools-exec-policy.js +121 -0
- package/dist/src/tools-exec.js +307 -0
- package/dist/src/tools-report.js +357 -0
- package/dist/src/tools.js +337 -0
- package/dist/src/tunnel.js +111 -0
- package/dist/src/util.js +112 -0
- package/dist/src/version.js +108 -0
- package/dist/src/watchdog-bus.js +21 -0
- package/dist/src/watchdog.js +116 -0
- package/index.js +5 -4
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +37 -19
- package/src/admission.js +0 -43
- package/src/api.js +0 -536
- package/src/atomic-json.js +0 -225
- package/src/bootstrap.js +0 -113
- package/src/connect-log.js +0 -176
- package/src/connect-pipeline.js +0 -1900
- package/src/connect-progress.js +0 -155
- package/src/constants.js +0 -93
- package/src/diagnostics.js +0 -160
- package/src/download-jobs.js +0 -234
- package/src/errors.js +0 -412
- package/src/host-lifecycle.js +0 -604
- package/src/host-registry.js +0 -217
- package/src/host-runtime.js +0 -127
- package/src/host-view.js +0 -75
- package/src/index.js +0 -206
- package/src/key-files.js +0 -54
- package/src/known-hosts.js +0 -133
- package/src/layout.js +0 -53
- package/src/local-download.js +0 -381
- package/src/local-ssh.js +0 -27
- package/src/local-version.js +0 -88
- package/src/node-runtime.js +0 -521
- package/src/probe.js +0 -101
- package/src/prompts.js +0 -229
- package/src/redact.js +0 -68
- package/src/remote-files.js +0 -71
- package/src/remote-path.js +0 -137
- package/src/remote-proc.js +0 -343
- package/src/remote-proxy.js +0 -815
- package/src/remote-web.js +0 -751
- package/src/request-trust.js +0 -89
- package/src/secrets.js +0 -109
- package/src/service.js +0 -459
- package/src/settings.js +0 -163
- package/src/ssh-config.js +0 -271
- package/src/ssh.js +0 -731
- package/src/store.js +0 -193
- package/src/tools.js +0 -386
- package/src/tunnel.js +0 -132
- package/src/util.js +0 -153
- package/src/version.js +0 -103
- package/src/webapp.js +0 -43
- /package/{vendor → dist/vendor}/ssh2.bundle.cjs +0 -0
package/src/tunnel.js
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Local loopback TCP listener piped through the SSH transport; the guest points at it, so its cookies never mix with the local GUI's.
|
|
3
|
-
*/
|
|
4
|
-
import http from 'node:http'
|
|
5
|
-
import net from 'node:net'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Ask the *local* listener whether it still serves, without trusting the SSH-side probe:
|
|
9
|
-
* any HTTP answer (even 401/404) proves the tunnel forwards, while a refused/destroyed
|
|
10
|
-
* socket means it is broken. Used before rebuilding a tunnel for a transient proxy failure.
|
|
11
|
-
* @param {number | null} localPort - tunnel's local port, if any.
|
|
12
|
-
* @param {{ timeoutMs?: number }} [options]
|
|
13
|
-
* @returns {Promise<boolean>} whether the listener answered.
|
|
14
|
-
*/
|
|
15
|
-
export function probeLoopback(localPort, options = {}) {
|
|
16
|
-
const port = Number(localPort)
|
|
17
|
-
if (!Number.isInteger(port) || port <= 0 || port > 65535) return Promise.resolve(false)
|
|
18
|
-
return new Promise((resolve) => {
|
|
19
|
-
let settled = false
|
|
20
|
-
const finish = (ok) => {
|
|
21
|
-
if (settled) return
|
|
22
|
-
settled = true
|
|
23
|
-
resolve(ok)
|
|
24
|
-
}
|
|
25
|
-
const request = http.get(
|
|
26
|
-
{ host: '127.0.0.1', port, path: '/', timeout: options.timeoutMs ?? 1_500 },
|
|
27
|
-
(response) => {
|
|
28
|
-
response.resume()
|
|
29
|
-
finish(true)
|
|
30
|
-
},
|
|
31
|
-
)
|
|
32
|
-
request.on('timeout', () => {
|
|
33
|
-
request.destroy()
|
|
34
|
-
finish(false)
|
|
35
|
-
})
|
|
36
|
-
request.on('error', () => finish(false))
|
|
37
|
-
})
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export async function createTunnel(options) {
|
|
41
|
-
const remoteHost = options.remoteHost ?? '127.0.0.1'
|
|
42
|
-
const listenHost = options.listenHost ?? '127.0.0.1'
|
|
43
|
-
const sockets = new Set()
|
|
44
|
-
// The forwarded SSH channels this listener opened: a closed listener must destroy them too,
|
|
45
|
-
// otherwise an established pipe keeps the (already released) SSH transport busy.
|
|
46
|
-
const streams = new Set()
|
|
47
|
-
let closed = false
|
|
48
|
-
|
|
49
|
-
const server = net.createServer((socket) => {
|
|
50
|
-
if (closed) {
|
|
51
|
-
socket.destroy()
|
|
52
|
-
return
|
|
53
|
-
}
|
|
54
|
-
sockets.add(socket)
|
|
55
|
-
const cleanup = () => {
|
|
56
|
-
sockets.delete(socket)
|
|
57
|
-
}
|
|
58
|
-
socket.once('close', cleanup)
|
|
59
|
-
socket.once('error', cleanup)
|
|
60
|
-
const ssh = options.ssh
|
|
61
|
-
if (!ssh) {
|
|
62
|
-
// A listener can outlive its transport if a caller leaks it; never throw from a net
|
|
63
|
-
// connection callback (an uncaught exception there ends the whole host process).
|
|
64
|
-
socket.destroy()
|
|
65
|
-
return
|
|
66
|
-
}
|
|
67
|
-
ssh
|
|
68
|
-
.forwardOut(remoteHost, options.remotePort, '127.0.0.1', socket.remotePort ?? 0)
|
|
69
|
-
.then((stream) => {
|
|
70
|
-
if (closed) {
|
|
71
|
-
stream.destroy()
|
|
72
|
-
socket.destroy()
|
|
73
|
-
return
|
|
74
|
-
}
|
|
75
|
-
streams.add(stream)
|
|
76
|
-
const forget = () => {
|
|
77
|
-
streams.delete(stream)
|
|
78
|
-
}
|
|
79
|
-
stream.once('close', forget)
|
|
80
|
-
stream.once('error', forget)
|
|
81
|
-
socket.pipe(stream).pipe(socket)
|
|
82
|
-
stream.once('close', () => {
|
|
83
|
-
if (!socket.destroyed) socket.end()
|
|
84
|
-
})
|
|
85
|
-
stream.once('error', () => {
|
|
86
|
-
socket.destroy()
|
|
87
|
-
})
|
|
88
|
-
})
|
|
89
|
-
.catch((error) => {
|
|
90
|
-
options.onError?.(error instanceof Error ? error : new Error(String(error)))
|
|
91
|
-
socket.destroy()
|
|
92
|
-
})
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
await new Promise((resolve, reject) => {
|
|
96
|
-
server.once('error', reject)
|
|
97
|
-
server.listen(options.listenPort ?? 0, listenHost, () => {
|
|
98
|
-
server.removeListener('error', reject)
|
|
99
|
-
resolve(undefined)
|
|
100
|
-
})
|
|
101
|
-
})
|
|
102
|
-
const address = server.address()
|
|
103
|
-
if (!address || typeof address === 'string') {
|
|
104
|
-
server.close()
|
|
105
|
-
throw new Error('tunnel listener did not expose a TCP address')
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return {
|
|
109
|
-
localPort: address.port,
|
|
110
|
-
listenHost,
|
|
111
|
-
urlHost: listenHost.includes(':') ? `[${listenHost}]` : listenHost,
|
|
112
|
-
get connections() {
|
|
113
|
-
return sockets.size
|
|
114
|
-
},
|
|
115
|
-
async close() {
|
|
116
|
-
if (closed) return
|
|
117
|
-
closed = true
|
|
118
|
-
for (const socket of sockets) socket.destroy()
|
|
119
|
-
sockets.clear()
|
|
120
|
-
// Destroy the forwarded channels as well: the SSH session may already be disposed.
|
|
121
|
-
for (const stream of streams) {
|
|
122
|
-
try {
|
|
123
|
-
stream.destroy()
|
|
124
|
-
} catch {
|
|
125
|
-
/* the channel may already be gone */
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
streams.clear()
|
|
129
|
-
await new Promise((resolve) => server.close(() => resolve(undefined)))
|
|
130
|
-
},
|
|
131
|
-
}
|
|
132
|
-
}
|
package/src/util.js
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Small pure helpers shared by the host half, unit-tested with node:test.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export function sleep(ms) {
|
|
6
|
-
return new Promise((resolve) => setTimeout(resolve, ms))
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function randomDelay(min, max) {
|
|
10
|
-
return Math.round(min + Math.random() * Math.max(0, max - min))
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const ID_ALPHABET = 'abcdefghijklmnopqrstuvwxyz0123456789'
|
|
14
|
-
|
|
15
|
-
export function randomId(prefix = 'h') {
|
|
16
|
-
let out = ''
|
|
17
|
-
for (let i = 0; i < 10; i += 1) out += ID_ALPHABET[Math.floor(Math.random() * ID_ALPHABET.length)]
|
|
18
|
-
return `${prefix}_${out}`
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function nowIso() {
|
|
22
|
-
return new Date().toISOString()
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function isPlainObject(value) {
|
|
26
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const LOG_LEVELS = { error: 0, warn: 1, info: 2, debug: 3 }
|
|
30
|
-
|
|
31
|
-
/** Prototype-chain names that must never be written by a merge. */
|
|
32
|
-
const UNSAFE_KEYS = new Set(['__proto__', 'constructor', 'prototype'])
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Recursively merge `patch` into `base` (arrays and scalars replace). Only keys
|
|
36
|
-
* `base` declares are written, so untrusted input can change known values but
|
|
37
|
-
* never invent a property or poison the prototype.
|
|
38
|
-
*/
|
|
39
|
-
export function deepMerge(base, patch) {
|
|
40
|
-
if (!isPlainObject(base) || !isPlainObject(patch)) return /** @type {T} */ (patch === undefined ? base : patch)
|
|
41
|
-
const out = { ...base }
|
|
42
|
-
for (const key of Object.keys(base)) {
|
|
43
|
-
if (UNSAFE_KEYS.has(key)) continue
|
|
44
|
-
const value = patch[key]
|
|
45
|
-
if (value === undefined) continue
|
|
46
|
-
out[key] = isPlainObject(value) && isPlainObject(base[key]) ? deepMerge(base[key], value) : value
|
|
47
|
-
}
|
|
48
|
-
return out
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export function clamp(value, min, max) {
|
|
52
|
-
return Math.min(max, Math.max(min, value))
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export function expandHome(value, home) {
|
|
56
|
-
const text = typeof value === 'string' ? value.trim() : ''
|
|
57
|
-
if (text === '') return ''
|
|
58
|
-
if (text === '~') return home
|
|
59
|
-
if (text.startsWith('~/') || text.startsWith('~\\')) return home.replace(/[\\/]+$/, '') + text.slice(1)
|
|
60
|
-
return text
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export function parseSshDestination(raw) {
|
|
64
|
-
const text = String(raw ?? '').trim()
|
|
65
|
-
if (text === '') return { user: null, host: '', port: null }
|
|
66
|
-
let user = null
|
|
67
|
-
let rest = text
|
|
68
|
-
const at = rest.lastIndexOf('@')
|
|
69
|
-
if (at >= 0) {
|
|
70
|
-
user = rest.slice(0, at)
|
|
71
|
-
rest = rest.slice(at + 1)
|
|
72
|
-
}
|
|
73
|
-
let host = rest
|
|
74
|
-
let port = null
|
|
75
|
-
if (rest.startsWith('[')) {
|
|
76
|
-
const close = rest.indexOf(']')
|
|
77
|
-
if (close > 0) {
|
|
78
|
-
host = rest.slice(1, close)
|
|
79
|
-
const tail = rest.slice(close + 1)
|
|
80
|
-
if (/^:\d+$/.test(tail)) port = Number(tail.slice(1))
|
|
81
|
-
}
|
|
82
|
-
} else {
|
|
83
|
-
const colon = rest.lastIndexOf(':')
|
|
84
|
-
if (colon > 0 && rest.indexOf(':') === colon) {
|
|
85
|
-
const maybePort = rest.slice(colon + 1)
|
|
86
|
-
if (/^\d{1,5}$/.test(maybePort)) {
|
|
87
|
-
host = rest.slice(0, colon)
|
|
88
|
-
port = Number(maybePort)
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return { user: user || null, host, port }
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export function isLoopbackHost(host) {
|
|
96
|
-
if (!host) return false
|
|
97
|
-
const normalized = host
|
|
98
|
-
.trim()
|
|
99
|
-
.toLowerCase()
|
|
100
|
-
.replace(/^\[|\]$/g, '')
|
|
101
|
-
if (normalized === 'localhost' || normalized === '::1') return true
|
|
102
|
-
if (normalized === '::ffff:127.0.0.1') return true
|
|
103
|
-
return /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(normalized)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export function shellQuote(value) {
|
|
107
|
-
return `'${String(value).replaceAll("'", `'\\''`)}'`
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export function headTail(text, max = 4000) {
|
|
111
|
-
const value = String(text ?? '')
|
|
112
|
-
if (value.length <= max) return value
|
|
113
|
-
const head = value.slice(0, Math.floor(max / 2))
|
|
114
|
-
const tail = value.slice(-Math.floor(max / 2))
|
|
115
|
-
return `${head}\n…\n${tail}`
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export function logVisible(level, threshold = 'info') {
|
|
119
|
-
const rank = LOG_LEVELS[level] ?? LOG_LEVELS.info
|
|
120
|
-
const floor = LOG_LEVELS[threshold] ?? LOG_LEVELS.info
|
|
121
|
-
return rank >= floor
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/** Message of an unknown thrown value, so catch blocks need not spell the ternary. */
|
|
125
|
-
export function messageOf(error) {
|
|
126
|
-
return String(error?.message ?? error)
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/** A positive integer — the only shape `kill`, `/proc` and a TCP port accept. */
|
|
130
|
-
export function isPid(value) {
|
|
131
|
-
return Number.isInteger(value) && value > 0
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* A promise that resolves at most once: through `settle`, or with `onTimeout()`
|
|
136
|
-
* when the deadline passes first. `onSettled` runs before the promise resolves so
|
|
137
|
-
* a caller can clear the pending slot it installed on both paths.
|
|
138
|
-
*/
|
|
139
|
-
export function createDecision(timeoutMs, onTimeout, onSettled) {
|
|
140
|
-
let settle
|
|
141
|
-
const promise = new Promise((resolve) => {
|
|
142
|
-
let done = false
|
|
143
|
-
const timer = setTimeout(() => settle(onTimeout?.()), timeoutMs)
|
|
144
|
-
settle = (value) => {
|
|
145
|
-
if (done) return
|
|
146
|
-
done = true
|
|
147
|
-
clearTimeout(timer)
|
|
148
|
-
onSettled?.(value)
|
|
149
|
-
resolve(value)
|
|
150
|
-
}
|
|
151
|
-
})
|
|
152
|
-
return { promise, settle }
|
|
153
|
-
}
|
package/src/version.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Version parsing/comparison and the exact-version parity rule, covering the shapes DSH and Node publish (`0.2.2-rc.1`, `24.22.2`, optional `v`).
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const VERSION_RE = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+([0-9A-Za-z.-]+))?$/
|
|
6
|
-
|
|
7
|
-
export function parseVersion(input) {
|
|
8
|
-
if (typeof input !== 'string') return null
|
|
9
|
-
const match = VERSION_RE.exec(input.trim())
|
|
10
|
-
if (!match) return null
|
|
11
|
-
const [, major, minor, patch, prerelease, build] = match
|
|
12
|
-
return {
|
|
13
|
-
raw: input.trim(),
|
|
14
|
-
major: Number(major),
|
|
15
|
-
minor: Number(minor),
|
|
16
|
-
patch: Number(patch),
|
|
17
|
-
prerelease: prerelease ? prerelease.split('.').map((part) => (/^\d+$/.test(part) ? Number(part) : part)) : [],
|
|
18
|
-
build: build ?? null,
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function normalizeVersion(input) {
|
|
23
|
-
const parsed = parseVersion(input)
|
|
24
|
-
if (!parsed) return String(input ?? '').trim()
|
|
25
|
-
const core = `${parsed.major}.${parsed.minor}.${parsed.patch}`
|
|
26
|
-
return parsed.prerelease.length > 0 ? `${core}-${parsed.prerelease.join('.')}` : core
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function compareIdentifiers(a, b) {
|
|
30
|
-
const aNum = typeof a === 'number'
|
|
31
|
-
const bNum = typeof b === 'number'
|
|
32
|
-
if (aNum && bNum) return a === b ? 0 : a < b ? -1 : 1
|
|
33
|
-
if (aNum) return -1 // numeric identifiers sort before alphanumeric ones
|
|
34
|
-
if (bNum) return 1
|
|
35
|
-
return a === b ? 0 : String(a) < String(b) ? -1 : 1
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function compareVersions(a, b) {
|
|
39
|
-
const pa = parseVersion(a)
|
|
40
|
-
const pb = parseVersion(b)
|
|
41
|
-
if (!pa || !pb) {
|
|
42
|
-
const sa = String(a ?? '')
|
|
43
|
-
const sb = String(b ?? '')
|
|
44
|
-
return sa === sb ? 0 : sa < sb ? -1 : 1
|
|
45
|
-
}
|
|
46
|
-
for (const key of ['major', 'minor', 'patch']) {
|
|
47
|
-
if (pa[key] !== pb[key]) return pa[key] < pb[key] ? -1 : 1
|
|
48
|
-
}
|
|
49
|
-
if (pa.prerelease.length === 0 && pb.prerelease.length === 0) return 0
|
|
50
|
-
if (pa.prerelease.length === 0) return 1
|
|
51
|
-
if (pb.prerelease.length === 0) return -1
|
|
52
|
-
const length = Math.max(pa.prerelease.length, pb.prerelease.length)
|
|
53
|
-
for (let i = 0; i < length; i += 1) {
|
|
54
|
-
const left = pa.prerelease[i]
|
|
55
|
-
const right = pb.prerelease[i]
|
|
56
|
-
if (left === undefined) return -1
|
|
57
|
-
if (right === undefined) return 1
|
|
58
|
-
const result = compareIdentifiers(left, right)
|
|
59
|
-
if (result !== 0) return result
|
|
60
|
-
}
|
|
61
|
-
return 0
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function versionsEqual(a, b) {
|
|
65
|
-
return compareVersions(normalizeVersion(a), normalizeVersion(b)) === 0
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function versionParity(localVersion, remoteVersion) {
|
|
69
|
-
if (!localVersion || !remoteVersion) {
|
|
70
|
-
return {
|
|
71
|
-
status: /** @type {'unknown'} */ ('unknown'),
|
|
72
|
-
local: localVersion ?? null,
|
|
73
|
-
remote: remoteVersion ?? null,
|
|
74
|
-
same: false,
|
|
75
|
-
message: {
|
|
76
|
-
zh: '无法确定版本一致性(缺少本机或远端版本)。',
|
|
77
|
-
en: 'Version parity is unknown (a local or remote version is missing).',
|
|
78
|
-
},
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
const same = versionsEqual(localVersion, remoteVersion)
|
|
82
|
-
return {
|
|
83
|
-
status: /** @type {'same' | 'different'} */ (same ? 'same' : 'different'),
|
|
84
|
-
local: normalizeVersion(localVersion),
|
|
85
|
-
remote: normalizeVersion(remoteVersion),
|
|
86
|
-
same,
|
|
87
|
-
message: same
|
|
88
|
-
? { zh: '远端与本机 DSH 版本一致。', en: 'The remote DSH version matches this machine.' }
|
|
89
|
-
: {
|
|
90
|
-
zh: `远端 DSH(${normalizeVersion(remoteVersion)})与本机(${normalizeVersion(localVersion)})不一致。`,
|
|
91
|
-
en: `Remote DSH (${normalizeVersion(remoteVersion)}) differs from this machine (${normalizeVersion(localVersion)}).`,
|
|
92
|
-
},
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export const MIN_NODE_VERSION = '24.9.0'
|
|
97
|
-
|
|
98
|
-
export function isNodeVersionSupported(version) {
|
|
99
|
-
if (!version) return false
|
|
100
|
-
// node -v prints "v24.22.2"; a bare "24" from a fallback should not pass.
|
|
101
|
-
if (!parseVersion(version)) return false
|
|
102
|
-
return compareVersions(normalizeVersion(version), MIN_NODE_VERSION) >= 0
|
|
103
|
-
}
|
package/src/webapp.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Remote DSH web lifecycle — the surface callers import: `remote-web.js` owns start/stop/adopt, `remote-proc.js` the scan and reachability primitives.
|
|
3
|
-
*/
|
|
4
|
-
export {
|
|
5
|
-
LAUNCH_MARKER,
|
|
6
|
-
BROWSER_CARRIER_PATCH_FILE,
|
|
7
|
-
parseWebLine,
|
|
8
|
-
buildStartCommand,
|
|
9
|
-
buildBrowserCarrierProbe,
|
|
10
|
-
ensureBrowserCarrier,
|
|
11
|
-
buildStartScript,
|
|
12
|
-
parseLaunchedPid,
|
|
13
|
-
startRemoteWeb,
|
|
14
|
-
stopRemoteWeb,
|
|
15
|
-
clearRunRegistry,
|
|
16
|
-
parseRunRegistry,
|
|
17
|
-
readRunRegistry,
|
|
18
|
-
readWebLineFromLog,
|
|
19
|
-
remotePidAlive,
|
|
20
|
-
adoptRemoteWeb,
|
|
21
|
-
buildRunRegistryRecord,
|
|
22
|
-
writeRunRegistry,
|
|
23
|
-
commandMatchesProfile,
|
|
24
|
-
versionFromCommand,
|
|
25
|
-
dshPackageDirFromCommand,
|
|
26
|
-
remoteDshVersion,
|
|
27
|
-
resolveRemoteWeb,
|
|
28
|
-
} from './remote-web.js'
|
|
29
|
-
|
|
30
|
-
export {
|
|
31
|
-
buildForeignDshCommand,
|
|
32
|
-
parseForeignDshOutput,
|
|
33
|
-
findForeignDshProcesses,
|
|
34
|
-
stopForeignDshProcesses,
|
|
35
|
-
parseListenPorts,
|
|
36
|
-
remoteListenPorts,
|
|
37
|
-
remotePortOwnerPid,
|
|
38
|
-
parseProcessIdentity,
|
|
39
|
-
remoteProcessIdentity,
|
|
40
|
-
remoteHttpStatus,
|
|
41
|
-
waitForRemoteUi,
|
|
42
|
-
exchangeTokenOverTunnel,
|
|
43
|
-
} from './remote-proc.js'
|
|
File without changes
|