livedesk 0.1.429 → 0.1.431

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.js CHANGED
@@ -5,7 +5,7 @@ import net from 'node:net';
5
5
  import { dirname, join, resolve } from 'node:path';
6
6
  import { fileURLToPath, pathToFileURL } from 'node:url';
7
7
  import { execFile, spawn } from 'node:child_process';
8
- import { createWriteStream, existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
8
+ import { createWriteStream, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from 'node:fs';
9
9
  import { randomBytes } from 'node:crypto';
10
10
  import os from 'node:os';
11
11
  import { resolveDeviceRole, writeRoleCache } from '../bootstrap/device-role.js';
@@ -62,17 +62,12 @@ function prepareUpdateNeutralCwd(kind, operationId) {
62
62
  `${safeUpdatePathSegment(kind, 'update')}-${safeUpdatePathSegment(operationId)}`
63
63
  );
64
64
  mkdirSync(neutralCwd, { recursive: true });
65
- for (let ancestor = neutralCwd; ; ancestor = dirname(ancestor)) {
66
- const shadowPath = ['package.json', join('node_modules', 'livedesk', 'package.json')]
67
- .map(relativePath => join(ancestor, relativePath))
68
- .find(candidate => existsSync(candidate));
69
- if (shadowPath) {
70
- throw new Error(
71
- `LiveDesk update neutral working directory is shadowed by ${shadowPath}: ${neutralCwd}`
72
- );
73
- }
74
- const parent = dirname(ancestor);
75
- if (parent === ancestor) break;
65
+ const unexpectedEntry = readdirSync(neutralCwd)[0];
66
+ if (unexpectedEntry) {
67
+ const shadowPath = join(neutralCwd, unexpectedEntry);
68
+ throw new Error(
69
+ `LiveDesk update neutral working directory is shadowed by ${shadowPath}: ${neutralCwd}`
70
+ );
76
71
  }
77
72
  return neutralCwd;
78
73
  }
@@ -94,6 +89,7 @@ function buildNeutralNpxEnvironment(baseEnv, neutralCwd) {
94
89
  }
95
90
  env.INIT_CWD = neutralCwd;
96
91
  env.npm_config_local_prefix = neutralCwd;
92
+ env.npm_config_workspaces = 'false';
97
93
  env.npm_config_include_workspace_root = 'false';
98
94
  return env;
99
95
  }
@@ -1037,7 +1033,7 @@ function resolveNpxInvocation(npxArgs) {
1037
1033
  function buildHubRestartBootstrapScript() {
1038
1034
  return [
1039
1035
  'const { execFile, spawn } = require("node:child_process");',
1040
- 'const { appendFileSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } = require("node:fs");',
1036
+ 'const { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } = require("node:fs");',
1041
1037
  'const { dirname, join } = require("node:path");',
1042
1038
  'const net = require("node:net");',
1043
1039
  'const waitPid = Number(process.env.LIVEDESK_RESTART_WAIT_PID || 0);',
@@ -1077,8 +1073,8 @@ function buildHubRestartBootstrapScript() {
1077
1073
  'const healthTimeoutMs = terminationFailureOperationId === operationId ? numberFromEnv("LIVEDESK_TEST_HUB_RESTART_TERMINATION_HEALTH_TIMEOUT_MS", 1000, 250) : configuredHealthTimeoutMs;',
1078
1074
  'const pollMs = numberFromEnv("LIVEDESK_RESTART_HEALTH_POLL_MS", 250, 50);',
1079
1075
  'const stabilityMs = numberFromEnv("LIVEDESK_RESTART_STABILITY_MS", 5000, 5000);',
1080
- 'const prepareNeutralCwd = () => { if (!neutralCwd) throw new Error("LiveDesk Hub update neutral working directory is unavailable"); mkdirSync(neutralCwd, { recursive: true }); for (let ancestor = neutralCwd; ; ancestor = dirname(ancestor)) { const shadow = [join(ancestor, "package.json"), join(ancestor, "node_modules", "livedesk", "package.json")].find(existsSync); if (shadow) throw new Error(`LiveDesk Hub update neutral working directory is shadowed by ${shadow}: ${neutralCwd}`); const parent = dirname(ancestor); if (parent === ancestor) break; } };',
1081
- 'const buildLaunchEnv = () => { const env = { ...process.env }; const isolated = new Set(["init_cwd", "npm_config_local_prefix", "npm_config_workspace", "npm_config_workspaces", "npm_config_include_workspace_root", "npm_package_json", "npm_lifecycle_event", "npm_lifecycle_script"]); for (const key of Object.keys(env)) if (isolated.has(key.toLowerCase())) delete env[key]; env.INIT_CWD = neutralCwd; env.npm_config_local_prefix = neutralCwd; env.npm_config_include_workspace_root = "false"; return env; };',
1076
+ 'const prepareNeutralCwd = () => { if (!neutralCwd) throw new Error("LiveDesk Hub update neutral working directory is unavailable"); mkdirSync(neutralCwd, { recursive: true }); const unexpectedEntry = readdirSync(neutralCwd)[0]; if (unexpectedEntry) { const shadow = join(neutralCwd, unexpectedEntry); throw new Error(`LiveDesk Hub update neutral working directory is shadowed by ${shadow}: ${neutralCwd}`); } };',
1077
+ 'const buildLaunchEnv = () => { const env = { ...process.env }; const isolated = new Set(["init_cwd", "npm_config_local_prefix", "npm_config_workspace", "npm_config_workspaces", "npm_config_include_workspace_root", "npm_package_json", "npm_lifecycle_event", "npm_lifecycle_script"]); for (const key of Object.keys(env)) if (isolated.has(key.toLowerCase())) delete env[key]; env.INIT_CWD = neutralCwd; env.npm_config_local_prefix = neutralCwd; env.npm_config_workspaces = "false"; env.npm_config_include_workspace_root = "false"; return env; };',
1082
1078
  'const requestJson = async path => { const response = await fetch(new URL(path, healthBaseUrl), { cache: "no-store", signal: AbortSignal.timeout(Math.min(2000, healthTimeoutMs)) }); if (!response.ok) throw new Error(`HTTP ${response.status} from ${path}`); return response.json(); };',
1083
1079
  'const probeRemotePort = () => new Promise((resolve, reject) => { const socket = net.createConnection({ host: remoteHost, port: remotePort }); const timer = setTimeout(() => socket.destroy(new Error("TCP probe timed out")), Math.min(1500, healthTimeoutMs)); timer.unref?.(); socket.once("connect", () => { clearTimeout(timer); socket.destroy(); resolve(); }); socket.once("error", error => { clearTimeout(timer); reject(error); }); });',
1084
1080
  'const probeReplacement = async requiredVersion => { const [status, health] = await Promise.all([requestJson("/api/runtime/status"), requestJson("/api/health")]); const runtimePid = Number(status?.runtimePid || 0); if (status?.role !== "hub" || status?.runtimeStarted !== true || runtimePid <= 1) throw new Error("replacement runtime status is not ready"); if (previousRuntimePid > 1 && runtimePid === previousRuntimePid) throw new Error(`old runtime pid=${runtimePid} is still answering`); if (requiredVersion && String(status?.appVersion || "") !== requiredVersion) throw new Error(`version mismatch expected=${requiredVersion} actual=${status?.appVersion || "unknown"}`); if (health?.ok !== true || health?.product !== "LiveDesk") throw new Error("replacement health response is invalid"); await probeRemotePort(); return { runtimePid, appVersion: String(status?.appVersion || "") }; };',
@@ -1192,7 +1188,18 @@ async function runManager(args, resolvedRole = null) {
1192
1188
  || prepareUpdateNeutralCwd('hub', operationId)
1193
1189
  );
1194
1190
  const packageTarget = `livedesk@${requestedVersion}`;
1195
- const nextArgs = ['-y', '--prefer-online', packageTarget, '--force-role', 'hub', '--no-open', ...args];
1191
+ const nextArgs = [
1192
+ '-y',
1193
+ '--prefer-online',
1194
+ '--prefix',
1195
+ neutralCwd,
1196
+ '--workspaces=false',
1197
+ packageTarget,
1198
+ '--force-role',
1199
+ 'hub',
1200
+ '--no-open',
1201
+ ...args
1202
+ ];
1196
1203
  const restartInvocation = resolveNpxInvocation(nextArgs);
1197
1204
  const fallbackInvocation = {
1198
1205
  command: process.execPath,
@@ -7,6 +7,7 @@ import {
7
7
  mkdirSync,
8
8
  openSync,
9
9
  readFileSync,
10
+ readdirSync,
10
11
  renameSync,
11
12
  rmSync,
12
13
  statSync,
@@ -138,18 +139,12 @@ function prepareNeutralCwd(cwd) {
138
139
  if (!configuredCwd) throw new Error('LiveDesk update neutral working directory is unavailable');
139
140
  const neutralCwd = resolve(configuredCwd);
140
141
  mkdirSync(neutralCwd, { recursive: true });
141
- for (let ancestor = neutralCwd; ; ancestor = dirname(ancestor)) {
142
- const shadowPath = [
143
- join(ancestor, 'package.json'),
144
- join(ancestor, 'node_modules', 'livedesk', 'package.json')
145
- ].find(candidate => existsSync(candidate));
146
- if (shadowPath) {
147
- throw new Error(
148
- `LiveDesk update neutral working directory is shadowed by ${shadowPath}: ${neutralCwd}`
149
- );
150
- }
151
- const parent = dirname(ancestor);
152
- if (parent === ancestor) break;
142
+ const unexpectedEntry = readdirSync(neutralCwd)[0];
143
+ if (unexpectedEntry) {
144
+ const shadowPath = join(neutralCwd, unexpectedEntry);
145
+ throw new Error(
146
+ `LiveDesk update neutral working directory is shadowed by ${shadowPath}: ${neutralCwd}`
147
+ );
153
148
  }
154
149
  return neutralCwd;
155
150
  }
@@ -171,10 +166,23 @@ export function buildLegacyClientUpdateNpxEnvironment(baseEnv, neutralCwd) {
171
166
  }
172
167
  env.INIT_CWD = neutralCwd;
173
168
  env.npm_config_local_prefix = neutralCwd;
169
+ env.npm_config_workspaces = 'false';
174
170
  env.npm_config_include_workspace_root = 'false';
175
171
  return env;
176
172
  }
177
173
 
174
+ function buildExactNpxArgs(neutralCwd, preference, version, args = []) {
175
+ return [
176
+ '-y',
177
+ preference,
178
+ '--prefix',
179
+ neutralCwd,
180
+ '--workspaces=false',
181
+ `livedesk@${version}`,
182
+ ...args
183
+ ];
184
+ }
185
+
178
186
  function positivePid(value) {
179
187
  const parsed = Number(value);
180
188
  return Number.isInteger(parsed) && parsed > 1 ? parsed : 0;
@@ -1011,11 +1019,11 @@ export function prefetchExactNpxRestore(config, env = process.env, options = {})
1011
1019
  if (!version) {
1012
1020
  throw new Error('LiveDesk cannot prefetch an exact restore without the current product version.');
1013
1021
  }
1022
+ const neutralCwd = prepareNeutralCwd(config?.neutralCwd);
1014
1023
  const invocation = resolveNpxInvocation(
1015
- ['-y', '--prefer-online', `livedesk@${version}`, '--version'],
1024
+ buildExactNpxArgs(neutralCwd, '--prefer-online', version, ['--version']),
1016
1025
  env
1017
1026
  );
1018
- const neutralCwd = prepareNeutralCwd(config?.neutralCwd);
1019
1027
  const result = (options.spawnSyncImpl || spawnSync)(
1020
1028
  invocation.command,
1021
1029
  invocation.args,
@@ -1067,12 +1075,12 @@ export function spawnReplacement(version, preference, env = process.env, restart
1067
1075
  const isLocalRestore = env.LIVEDESK_CLIENT_UPDATE_ATTEMPT_KIND === 'restore'
1068
1076
  && localRestoreLauncher
1069
1077
  && existsSync(localRestoreLauncher);
1070
- const invocation = isLocalRestore
1071
- ? { command: process.execPath, args: [localRestoreLauncher, ...roleArgs] }
1072
- : resolveNpxInvocation(['-y', preference, `livedesk@${version}`, ...roleArgs], env);
1073
1078
  const neutralCwd = isLocalRestore
1074
1079
  ? ''
1075
1080
  : prepareNeutralCwd(env.LIVEDESK_UPDATE_NEUTRAL_CWD);
1081
+ const invocation = isLocalRestore
1082
+ ? { command: process.execPath, args: [localRestoreLauncher, ...roleArgs] }
1083
+ : resolveNpxInvocation(buildExactNpxArgs(neutralCwd, preference, version, roleArgs), env);
1076
1084
  const replacementEnv = isLocalRestore
1077
1085
  ? { ...env }
1078
1086
  : buildLegacyClientUpdateNpxEnvironment(env, neutralCwd);
@@ -58,16 +58,10 @@ function getClientUpdateNeutralCwd(operationId) {
58
58
  async function prepareClientUpdateNeutralCwd(operationId) {
59
59
  const neutralCwd = path.resolve(getClientUpdateNeutralCwd(operationId));
60
60
  await fs.mkdir(neutralCwd, { recursive: true });
61
- for (let ancestor = neutralCwd; ; ancestor = path.dirname(ancestor)) {
62
- const shadowPath = [
63
- path.join(ancestor, 'package.json'),
64
- path.join(ancestor, 'node_modules', 'livedesk', 'package.json')
65
- ].find(candidate => existsSync(candidate));
66
- if (shadowPath) {
67
- throw new Error(`LiveDesk update neutral working directory is shadowed by ${shadowPath}: ${neutralCwd}`);
68
- }
69
- const parent = path.dirname(ancestor);
70
- if (parent === ancestor) break;
61
+ const unexpectedEntry = (await fs.readdir(neutralCwd))[0];
62
+ if (unexpectedEntry) {
63
+ const shadowPath = path.join(neutralCwd, unexpectedEntry);
64
+ throw new Error(`LiveDesk update neutral working directory is shadowed by ${shadowPath}: ${neutralCwd}`);
71
65
  }
72
66
  return neutralCwd;
73
67
  }
@@ -89,6 +83,7 @@ function buildClientUpdateNpxEnvironment(baseEnv, neutralCwd) {
89
83
  }
90
84
  env.INIT_CWD = neutralCwd;
91
85
  env.npm_config_local_prefix = neutralCwd;
86
+ env.npm_config_workspaces = 'false';
92
87
  env.npm_config_include_workspace_root = 'false';
93
88
  return env;
94
89
  }
@@ -1583,13 +1578,13 @@ function buildClientUpdateBootstrapScript() {
1583
1578
  'const terminateTree = async child => { const pid = Number(child?.pid || 0); if (pid <= 1) return; if (process.platform === "win32") { await new Promise(resolve => { const killer = spawn("taskkill.exe", ["/PID", String(pid), "/T", "/F"], { windowsHide: true, stdio: "ignore" }); let done = false; const finish = () => { if (done) return; done = true; clearTimeout(timer); resolve(); }; const timer = setTimeout(() => { try { killer.kill("SIGKILL"); } catch {} finish(); }, 10000); killer.once("error", finish); killer.once("exit", finish); }); if (isAlive(pid)) { try { child.kill("SIGKILL"); } catch {} } return; } try { process.kill(-pid, "SIGTERM"); } catch { try { child.kill("SIGTERM"); } catch {} } const gracefulDeadline = Date.now() + 2000; while (Date.now() < gracefulDeadline && (isGroupAlive(pid) || isAlive(pid))) await sleep(100); if (isGroupAlive(pid) || isAlive(pid)) { try { process.kill(-pid, "SIGKILL"); } catch { try { child.kill("SIGKILL"); } catch {} } } };',
1584
1579
  'const writeHandoffStarted = () => withStateLock(() => { if (deadlineExpired()) throw new Error("The absolute LiveDesk Client update deadline expired before handoff."); const previous = readState(); if (previous.operationId !== operationId) throw new Error("LiveDesk update handoff was superseded before exact-package launch."); const now = new Date().toISOString(); const next = { ...previous, operationId, stage: "handoff-started", starterPid: process.pid, updateDeadlineEpochMs, restartVerified: false, error: "", updatedAt: now }; const temporary = statePath + "." + process.pid + ".handoff-started.tmp"; fs.writeFileSync(temporary, JSON.stringify(next, null, 2), { encoding: "utf8", mode: 0o600 }); fs.renameSync(temporary, statePath); });',
1585
1580
  'const monitorPreflight = child => { let settled = false; const finish = (error, preserveFailure = false) => { if (settled) return; settled = true; clearInterval(poll); clearTimeout(timeout); child.unref(); if (preserveFailure) process.exitCode = 1; else if (error) writeFailure(error); }; const inspect = () => { const state = readState(); if (state.operationId !== operationId) return; if (state.stage === "preflight-ready" || state.stage === "waiting-for-shutdown") finish(); else if (state.stage === "failed") finish(null, true); }; const cancelTimedOutHandoff = async () => { const error = new Error(deadlineExpired() ? "The absolute LiveDesk Client update deadline expired before exact-package preflight." : "Timed out waiting for exact-package update preflight."); while (!settled) { inspect(); if (settled) return; let outcome; try { outcome = writeCancellation(error); } catch (lockError) { finish(lockError); return; } if (outcome === "ready" || outcome === "failed") { inspect(); if (settled) return; } else if (outcome === "cancelled" || outcome === "superseded") { await terminateTree(child); finish(null, true); return; } await sleep(25); } }; const poll = setInterval(inspect, 100); const timeoutMs = Math.max(1, Math.min(Math.max(1000, Number(process.env.LIVEDESK_CLIENT_UPDATE_HANDOFF_TIMEOUT_MS || 140000)), updateDeadlineEpochMs - Date.now())); const timeout = setTimeout(() => { void cancelTimedOutHandoff(); }, timeoutMs); child.once("exit", (code, signal) => { inspect(); if (!settled) finish(new Error("Exact-package update supervisor exited before preflight (code=" + (code ?? "none") + ", signal=" + (signal || "none") + ").")); }); inspect(); };',
1586
- 'const prepareNeutralCwd = () => { if (!neutralCwd) throw new Error("LiveDesk update neutral working directory is unavailable"); fs.mkdirSync(neutralCwd, { recursive: true }); for (let ancestor = neutralCwd; ; ancestor = path.dirname(ancestor)) { const shadow = [path.join(ancestor, "package.json"), path.join(ancestor, "node_modules", "livedesk", "package.json")].find(fs.existsSync); if (shadow) throw new Error("LiveDesk update neutral working directory is shadowed by " + shadow + ": " + neutralCwd); const parent = path.dirname(ancestor); if (parent === ancestor) break; } };',
1581
+ 'const prepareNeutralCwd = () => { if (!neutralCwd) throw new Error("LiveDesk update neutral working directory is unavailable"); fs.mkdirSync(neutralCwd, { recursive: true }); const unexpectedEntry = fs.readdirSync(neutralCwd)[0]; if (unexpectedEntry) { const shadow = path.join(neutralCwd, unexpectedEntry); throw new Error("LiveDesk update neutral working directory is shadowed by " + shadow + ": " + neutralCwd); } };',
1587
1582
  'if (!operationId || !versionPattern.test(targetProductVersion) || deadlineExpired()) { writeFailure(new Error("Invalid or expired LiveDesk exact-package update handoff."), true); } else { try { prepareNeutralCwd(); writeHandoffStarted();',
1588
- 'const env = { ...process.env, LIVEDESK_UPDATE_STARTER_PID: String(process.pid) }; const isolated = new Set(["init_cwd", "npm_config_local_prefix", "npm_config_workspace", "npm_config_workspaces", "npm_config_include_workspace_root", "npm_package_json", "npm_lifecycle_event", "npm_lifecycle_script"]); for (const key of Object.keys(env)) if (isolated.has(key.toLowerCase())) delete env[key]; env.INIT_CWD = neutralCwd; env.npm_config_local_prefix = neutralCwd; env.npm_config_include_workspace_root = "false";',
1583
+ 'const env = { ...process.env, LIVEDESK_UPDATE_STARTER_PID: String(process.pid) }; const isolated = new Set(["init_cwd", "npm_config_local_prefix", "npm_config_workspace", "npm_config_workspaces", "npm_config_include_workspace_root", "npm_package_json", "npm_lifecycle_event", "npm_lifecycle_script"]); for (const key of Object.keys(env)) if (isolated.has(key.toLowerCase())) delete env[key]; env.INIT_CWD = neutralCwd; env.npm_config_local_prefix = neutralCwd; env.npm_config_workspaces = "false"; env.npm_config_include_workspace_root = "false";',
1589
1584
  'const nodeDir = path.dirname(process.execPath);',
1590
1585
  'const npxCli = [env.LIVEDESK_NPX_CLI_PATH, env.npm_execpath ? path.join(path.dirname(env.npm_execpath), "npx-cli.js") : "", env.LIVEDESK_NPX_EXECUTABLE ? path.join(path.dirname(env.LIVEDESK_NPX_EXECUTABLE), "node_modules", "npm", "bin", "npx-cli.js") : "", path.join(nodeDir, "node_modules", "npm", "bin", "npx-cli.js")].find(value => value && fs.existsSync(value));',
1591
1586
  'const npx = env.LIVEDESK_NPX_EXECUTABLE || (process.platform === "win32" ? "npx.cmd" : "npx");',
1592
- 'const args = ["-y", "--prefer-online", "livedesk@" + targetProductVersion, "--internal-legacy-client-update"];',
1587
+ 'const args = ["-y", "--prefer-online", "--prefix", neutralCwd, "--workspaces=false", "livedesk@" + targetProductVersion, "--internal-legacy-client-update"];',
1593
1588
  'const quoteCmd = value => "\\"" + String(value).replaceAll("%", "%%").replaceAll("\\"", "\\"\\"") + "\\"";',
1594
1589
  'const invocation = npxCli ? { command: process.execPath, args: [npxCli, ...args] } : process.platform === "win32" ? { command: env.ComSpec || "cmd.exe", args: ["/d", "/s", "/c", "call " + quoteCmd(npx) + " " + args.map(quoteCmd).join(" ")] } : { command: npx, args };',
1595
1590
  'if (!npxCli && path.isAbsolute(npx) && !fs.existsSync(npx)) { writeFailure(new Error("LiveDesk npx executable was not found: " + npx)); } else { try { const child = spawn(invocation.command, invocation.args, { cwd: neutralCwd, env, detached: true, stdio: "ignore", windowsHide: true }); child.once("error", writeFailure); child.once("spawn", () => monitorPreflight(child)); } catch (error) { writeFailure(error); } }',
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livedesk/client",
3
- "version": "0.1.188",
3
+ "version": "0.1.189",
4
4
  "description": "LiveDesk local remote client",
5
5
  "type": "module",
6
6
  "bin": {
@@ -41,10 +41,10 @@
41
41
  "ws": "^8.18.3"
42
42
  },
43
43
  "optionalDependencies": {
44
- "@livedesk/fast-linux-x64": "0.1.395",
45
- "@livedesk/fast-osx-arm64": "0.1.395",
46
- "@livedesk/fast-osx-x64": "0.1.395",
47
- "@livedesk/fast-win-x64": "0.1.395"
44
+ "@livedesk/fast-linux-x64": "0.1.396",
45
+ "@livedesk/fast-osx-arm64": "0.1.396",
46
+ "@livedesk/fast-osx-x64": "0.1.396",
47
+ "@livedesk/fast-win-x64": "0.1.396"
48
48
  },
49
49
  "publishConfig": {
50
50
  "access": "public"
@@ -71,7 +71,7 @@ function encodePowerShell(value) {
71
71
 
72
72
  function buildLegacyPackageSupervisorStarterSource() {
73
73
  const source = [
74
- "const{spawn}=require('node:child_process'),f=require('node:fs'),p=require('node:path'),c=JSON.parse(Buffer.from(process.env.C,'base64')),e={...process.env,LIVEDESK_UPDATE_STARTER_PID:String(process.pid),LIVEDESK_UPDATE_ORIGINAL_CWD:process.cwd()},w=p.join(require('node:os').tmpdir(),'livedesk-update-cwd','client-'+c[0]),u=e.LIVEDESK_NPX_EXECUTABLE,s=process.platform,j=process.execPath,n=u||(s==='win32'?'npx.cmd':'npx'),x=[e.LIVEDESK_NPX_CLI_PATH,e.npm_execpath&&p.join(p.dirname(e.npm_execpath),'npx-cli.js'),u&&p.join(p.dirname(u),'node_modules/npm/bin/npx-cli.js'),p.join(p.dirname(j),'node_modules/npm/bin/npx-cli.js')].find(v=>v&&f.existsSync(v)),a=['-y','--prefer-online','livedesk@'+c[6],'--internal-legacy-client-update'],z=String.fromCharCode(32),q=v=>'\"'+String(v).replaceAll('\"','\"\"')+'\"';if(!(+c[7]>0))process.exit(1);c[7]=String(Date.now()+Number(c[7]));e.C=Buffer.from(JSON.stringify(c)).toString('base64');f.mkdirSync(w,{recursive:true});if(f.readdirSync(w)[0])process.exit(1);let/**/t=w;for(;;t=p.dirname(t)){if(['package.json','node_modules/livedesk/package.json'].some(v=>f.existsSync(p.join(t,v))))process.exit(1);if(p.dirname(t)===t)break}Object.keys(e).forEach(k=>/^(INIT_CWD|npm_config_(local_prefix|workspaces?|include_workspace_root))$/i.test(k)&&Reflect.deleteProperty(e,k));Object.assign(e,{INIT_CWD:w,npm_config_local_prefix:w,npm_config_include_workspace_root:'false',LIVEDESK_UPDATE_NEUTRAL_CWD:w});e.i=x?{c:j,a:[x,...a]}:s==='win32'?{c:e.ComSpec||'cmd.exe',a:['/d','/s','/c','call'+z+q(n)+z+a.map(q).join(z)]}:{c:n,a};e.r=spawn(e.i.c,e.i.a,{cwd:w,env:e,detached:true,stdio:'ignore',windowsHide:true});",
74
+ "const{spawn}=require('node:child_process'),f=require('node:fs'),p=require('node:path'),c=JSON.parse(Buffer.from(process.env.C,'base64')),e={...process.env,LIVEDESK_UPDATE_STARTER_PID:String(process.pid),LIVEDESK_UPDATE_ORIGINAL_CWD:process.cwd()},w=p.join(require('node:os').tmpdir(),'livedesk-update-cwd','client-'+c[0]),u=e.LIVEDESK_NPX_EXECUTABLE,s=process.platform,j=process.execPath,n=u||(s==='win32'?'npx.cmd':'npx'),x=[e.LIVEDESK_NPX_CLI_PATH,e.npm_execpath&&p.join(p.dirname(e.npm_execpath),'npx-cli.js'),u&&p.join(p.dirname(u),'node_modules/npm/bin/npx-cli.js'),p.join(p.dirname(j),'node_modules/npm/bin/npx-cli.js')].find(v=>v&&f.existsSync(v)),a=['-y','--prefer-online','--prefix',w,'--workspaces=false','livedesk@'+c[6],'--internal-legacy-client-update'],z=String.fromCharCode(32),q=v=>'\"'+String(v).replaceAll('\"','\"\"')+'\"';if(!(+c[7]>0))process.exit(1);c[7]=String(Date.now()+Number(c[7]));e.C=Buffer.from(JSON.stringify(c)).toString('base64');f.mkdirSync(w,{recursive:true});if(f.readdirSync(w)[0])process.exit(1);Object.keys(e).forEach(k=>/^(INIT_CWD|npm_config_(local_prefix|workspaces?|include_workspace_root))$/i.test(k)&&Reflect.deleteProperty(e,k));Object.assign(e,{INIT_CWD:w,npm_config_local_prefix:w,npm_config_workspaces:'false',npm_config_include_workspace_root:'false',LIVEDESK_UPDATE_NEUTRAL_CWD:w});e.i=x?{c:j,a:[x,...a]}:s==='win32'?{c:e.ComSpec||'cmd.exe',a:['/d','/s','/c','call'+z+q(n)+z+a.map(q).join(z)]}:{c:n,a};e.r=spawn(e.i.c,e.i.a,{cwd:w,env:e,detached:true,stdio:'ignore',windowsHide:true});",
75
75
  "e.r.on('error',()=>process.exit(1));e.r.unref();"
76
76
  ].join('');
77
77
  if (source.includes(' ')) throw new Error('LiveDesk legacy starter source must not contain spaces.');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "livedesk",
3
- "version": "0.1.429",
4
- "livedeskClientVersion": "0.1.188",
3
+ "version": "0.1.431",
4
+ "livedeskClientVersion": "0.1.189",
5
5
  "buildFlavor": "production",
6
6
  "description": "LiveDesk Hub and client launcher",
7
7
  "type": "module",
@@ -50,10 +50,10 @@
50
50
  "ws": "^8.18.3"
51
51
  },
52
52
  "optionalDependencies": {
53
- "@livedesk/fast-linux-x64": "0.1.395",
54
- "@livedesk/fast-osx-arm64": "0.1.395",
55
- "@livedesk/fast-osx-x64": "0.1.395",
56
- "@livedesk/fast-win-x64": "0.1.395"
53
+ "@livedesk/fast-linux-x64": "0.1.396",
54
+ "@livedesk/fast-osx-arm64": "0.1.396",
55
+ "@livedesk/fast-osx-x64": "0.1.396",
56
+ "@livedesk/fast-win-x64": "0.1.396"
57
57
  },
58
58
  "publishConfig": {
59
59
  "access": "public"