@livedesk/client 0.1.140 → 0.1.142
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/bin/livedesk-client-node.js +25 -9
- package/fast/linux-x64/livedesk-client-fast.dll +0 -0
- package/fast/linux-x64/livedesk-client-fast.pdb +0 -0
- package/fast/osx-arm64/livedesk-client-fast.dll +0 -0
- package/fast/osx-arm64/livedesk-client-fast.pdb +0 -0
- package/fast/osx-x64/livedesk-client-fast.dll +0 -0
- package/fast/osx-x64/livedesk-client-fast.pdb +0 -0
- package/fast/win-x64/livedesk-client-fast.dll +0 -0
- package/fast/win-x64/livedesk-client-fast.pdb +0 -0
- package/package.json +1 -1
|
@@ -1310,6 +1310,27 @@ function remotePolicyAllows(options, command) {
|
|
|
1310
1310
|
return denied ? { ok: false, error: `${denied}-blocked-by-settings` } : { ok: true };
|
|
1311
1311
|
}
|
|
1312
1312
|
|
|
1313
|
+
function buildClientUpdateBootstrapScript() {
|
|
1314
|
+
return [
|
|
1315
|
+
'const { spawn } = require("node:child_process");',
|
|
1316
|
+
'const fs = require("node:fs");',
|
|
1317
|
+
'const path = require("node:path");',
|
|
1318
|
+
'const waitPid = Number(process.env.LIVEDESK_UPDATE_WAIT_PID || 0);',
|
|
1319
|
+
'const isAlive = pid => { try { process.kill(pid, 0); return true; } catch (error) { return error?.code !== "ESRCH"; } };',
|
|
1320
|
+
'const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));',
|
|
1321
|
+
'const waitForExit = async pid => { for (let attempt = 0; attempt < 360 && pid > 1; attempt += 1) { if (!isAlive(pid)) return; await sleep(500); } if (pid > 1 && isAlive(pid)) throw new Error("LiveDesk client launcher did not exit before update installation."); };',
|
|
1322
|
+
'const nodeDir = path.dirname(process.execPath);',
|
|
1323
|
+
'const npxCandidates = process.platform === "win32" ? [process.env.LIVEDESK_NPX_EXECUTABLE, path.join(nodeDir, "npx.cmd"), path.join(nodeDir, "npx.exe"), "npx.cmd"] : [process.env.LIVEDESK_NPX_EXECUTABLE, path.join(nodeDir, "npx"), "npx"];',
|
|
1324
|
+
'const npx = npxCandidates.find(candidate => candidate && (!path.isAbsolute(candidate) || fs.existsSync(candidate)));',
|
|
1325
|
+
'if (!npx) throw new Error("LiveDesk npx executable was not found.");',
|
|
1326
|
+
'const npxArgs = ["-y", "--prefer-online", "livedesk@latest", "client", "--no-login"];',
|
|
1327
|
+
'const command = process.platform === "win32" ? (process.env.ComSpec || "cmd.exe") : npx;',
|
|
1328
|
+
'const commandArgs = process.platform === "win32" ? ["/d", "/s", "/c", `call "${npx}" ${npxArgs.join(" ")}`] : npxArgs;',
|
|
1329
|
+
'(async () => { await waitForExit(waitPid); const updater = spawn(command, commandArgs, { detached: true, stdio: "ignore", windowsHide: true, env: process.env }); updater.once("error", error => { console.error("LiveDesk updater failed to start: " + error.message); process.exitCode = 1; }); updater.once("spawn", () => updater.unref()); })().catch(error => { console.error("LiveDesk updater failed: " + error.message); process.exitCode = 1; });',
|
|
1330
|
+
''
|
|
1331
|
+
].join('\n');
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1313
1334
|
function scheduleClientUpdate(options, payload = {}) {
|
|
1314
1335
|
const configuredParentPid = Number(process.env.LIVEDESK_CLIENT_PARENT_PID || process.ppid);
|
|
1315
1336
|
const parentPid = Number.isInteger(configuredParentPid) && configuredParentPid > 1
|
|
@@ -1327,17 +1348,12 @@ function scheduleClientUpdate(options, payload = {}) {
|
|
|
1327
1348
|
return Promise.reject(new Error('LiveDesk npx executable was not found.'));
|
|
1328
1349
|
}
|
|
1329
1350
|
return new Promise((resolve, reject) => {
|
|
1330
|
-
const child = spawn(
|
|
1331
|
-
'-y',
|
|
1332
|
-
'--prefer-online',
|
|
1333
|
-
'livedesk@latest',
|
|
1334
|
-
'client',
|
|
1335
|
-
'--no-login',
|
|
1336
|
-
'--update-wait-pid',
|
|
1337
|
-
String(parentPid)
|
|
1338
|
-
], {
|
|
1351
|
+
const child = spawn(process.execPath, ['-e', buildClientUpdateBootstrapScript()], {
|
|
1339
1352
|
env: {
|
|
1340
1353
|
...process.env,
|
|
1354
|
+
LIVEDESK_NODE_EXECUTABLE: process.execPath,
|
|
1355
|
+
LIVEDESK_NPX_EXECUTABLE: command,
|
|
1356
|
+
LIVEDESK_UPDATE_WAIT_PID: String(parentPid),
|
|
1341
1357
|
LIVEDESK_CLIENT_UPDATE_TARGET_VERSION: String(payload.targetVersion || process.env.LIVEDESK_CLIENT_UPDATE_TARGET_VERSION || '')
|
|
1342
1358
|
},
|
|
1343
1359
|
detached: true,
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|