dsh-wechat-remote 1.7.0 → 1.7.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/assets/plugin.tgz +0 -0
- package/assets/release.json +8 -8
- package/bin/native-control.mjs +15 -0
- package/bin/setup.mjs +22 -9
- package/package.json +1 -1
package/assets/plugin.tgz
CHANGED
|
Binary file
|
package/assets/release.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.7.
|
|
2
|
+
"version": "1.7.1",
|
|
3
3
|
"catalog": {
|
|
4
4
|
"schemaVersion": 1,
|
|
5
|
-
"revision": "installer-1.7.
|
|
6
|
-
"issuedAt":
|
|
7
|
-
"expiresAt":
|
|
5
|
+
"revision": "installer-1.7.1",
|
|
6
|
+
"issuedAt": 1788979000679,
|
|
7
|
+
"expiresAt": 1791398200679,
|
|
8
8
|
"releases": [
|
|
9
9
|
{
|
|
10
|
-
"version": "1.7.
|
|
10
|
+
"version": "1.7.1",
|
|
11
11
|
"channel": "stable",
|
|
12
12
|
"dsh": [
|
|
13
13
|
"0.1.1-rc.2",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"x64"
|
|
23
23
|
],
|
|
24
24
|
"asset": {
|
|
25
|
-
"url": "https://github.com/martinbear1/dsh-wechat-remote/releases/download/v1.7.
|
|
26
|
-
"sha256": "
|
|
27
|
-
"bytes":
|
|
25
|
+
"url": "https://github.com/martinbear1/dsh-wechat-remote/releases/download/v1.7.1/harness-remote-dsh-wechat-remote-1.7.1.tgz",
|
|
26
|
+
"sha256": "5274a6d5beb513124a6d1a916ddd6df7d3e236a7a970e48515d902fa4d8c94d0",
|
|
27
|
+
"bytes": 9526754
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
],
|
package/bin/native-control.mjs
CHANGED
|
@@ -53,3 +53,18 @@ export async function waitForJson(filename, accept, timeout = 20000) {
|
|
|
53
53
|
}
|
|
54
54
|
throw new Error('DSH 没有完成安装握手;原插件未替换。请确认 DSH WebUI 正在运行且允许原生插件热加载。')
|
|
55
55
|
}
|
|
56
|
+
|
|
57
|
+
/** One bounded native handshake, including a possible offline host start.
|
|
58
|
+
* A listening WebUI is not proof that the asynchronous profile reload finished.
|
|
59
|
+
* Keep the same control entry/token while waiting; never restart a live host. */
|
|
60
|
+
export async function waitForInstallControl(filename, {
|
|
61
|
+
accept, ensureRunning, onWaiting = () => {}, timeoutMs = 60000, initialWaitMs = 5000,
|
|
62
|
+
}) {
|
|
63
|
+
const deadline = Date.now() + timeoutMs
|
|
64
|
+
try { return await waitForJson(filename, accept, Math.min(initialWaitMs, timeoutMs)) }
|
|
65
|
+
catch {
|
|
66
|
+
onWaiting()
|
|
67
|
+
if (Date.now() < deadline) await ensureRunning()
|
|
68
|
+
return await waitForJson(filename, accept, Math.max(0, deadline - Date.now()))
|
|
69
|
+
}
|
|
70
|
+
}
|
package/bin/setup.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import net from 'node:net'
|
|
|
6
6
|
import { spawn } from 'node:child_process'
|
|
7
7
|
import { randomBytes, createHash } from 'node:crypto'
|
|
8
8
|
import { fileURLToPath } from 'node:url'
|
|
9
|
-
import { attachControl, waitForJson } from './native-control.mjs'
|
|
9
|
+
import { attachControl, waitForJson, waitForInstallControl } from './native-control.mjs'
|
|
10
10
|
import { resolveInstallRuntime, verifyInstallRuntime } from '../lib/install-runtime.js'
|
|
11
11
|
import { validateCatalog, releaseMatches, compareVersions } from '../lib/update-policy.js'
|
|
12
12
|
import { boundedFetch, downloadRelease, auditArchive } from '../lib/update-download.js'
|
|
@@ -89,14 +89,27 @@ export async function install({ profileName = 'web', cli = findDsh(), assetsRoot
|
|
|
89
89
|
fs.copyFileSync(path.join(root, 'lib/install-control.js'), helper)
|
|
90
90
|
writePrivateJsonAtomic(path.join(directory, 'package.json'), { type: 'module' })
|
|
91
91
|
remove = attachControl(profile, helper, { directory, token, pnpm: runtime.cli })
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
92
|
+
const handshakeStarted = Date.now()
|
|
93
|
+
try {
|
|
94
|
+
ref = await waitForInstallControl(path.join(directory, 'control-ready.json'), {
|
|
95
|
+
accept: v => Number.isInteger(v.pid) && v.pid > 0 && (!launched || v.pid === launched.pid),
|
|
96
|
+
onWaiting: () => console.log('正在等待 DSH 完成安装准备,请勿重复执行命令…'),
|
|
97
|
+
ensureRunning: async () => {
|
|
98
|
+
if (launched || await portBusy(Number(process.env.DSH_PORT || 3080))) return
|
|
99
|
+
const log = fs.openSync(path.join(directory, 'startup.log'), 'a', 0o600)
|
|
100
|
+
launched = spawn(process.execPath, [cli, 'web', '--profile', profileName, '--no-open'], {
|
|
101
|
+
cwd: process.cwd(), env: process.env, detached: true, windowsHide: true, stdio: ['ignore', log, log] })
|
|
102
|
+
fs.closeSync(log); launched.on('error', () => {}); launched.unref()
|
|
103
|
+
},
|
|
104
|
+
})
|
|
105
|
+
writePrivateJsonAtomic(path.join(directory, 'handshake.json'), {
|
|
106
|
+
state: 'ready', elapsedMs: Date.now() - handshakeStarted, startedHost: Boolean(launched),
|
|
107
|
+
})
|
|
108
|
+
} catch {
|
|
109
|
+
writePrivateJsonAtomic(path.join(directory, 'handshake.json'), {
|
|
110
|
+
state: 'timeout', elapsedMs: Date.now() - handshakeStarted, startedHost: Boolean(launched),
|
|
111
|
+
})
|
|
112
|
+
throw new Error('DSH 安装准备超时,原插件未替换。本机安装记录:' + path.join(directory, 'handshake.json'))
|
|
100
113
|
}
|
|
101
114
|
job = { controlOrigin: ref.origin, statusToken: token }
|
|
102
115
|
const host = await control(job, 'describe')
|