lianrouter 2.2.2 → 2.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.
Files changed (3) hide show
  1. package/dist/cli.js +119 -32
  2. package/dist/tray.js +76 -31
  3. package/package.json +2 -2
package/dist/cli.js CHANGED
@@ -17,11 +17,11 @@ var package_default;
17
17
  var init_package = __esm(() => {
18
18
  package_default = {
19
19
  name: "lianrouter",
20
- version: "2.2.2",
20
+ version: "2.3.1",
21
21
  description: "LianRouter launcher: install, run and control the gateway from one command",
22
22
  type: "module",
23
23
  bin: {
24
- lianrouter: "./dist/cli.js"
24
+ lianrouter: "dist/cli.js"
25
25
  },
26
26
  engines: {
27
27
  bun: ">=1.4.2"
@@ -228,22 +228,28 @@ function compareVersions(a, b) {
228
228
  }
229
229
 
230
230
  // cli/update/extract.ts
231
+ import { existsSync, realpathSync } from "fs";
231
232
  import { lstat, mkdir, readdir, rm as rm2 } from "fs/promises";
232
233
  import { isAbsolute, join, normalize, resolve, sep } from "path";
233
234
  function extractionArgv(kind, archivePath, stagingDir) {
234
235
  const tar = Bun.which("tar");
235
236
  const unzip = Bun.which("unzip");
237
+ const systemTar = process.platform === "win32" && existsSync("C:\\Windows\\System32\\tar.exe") ? "C:\\Windows\\System32\\tar.exe" : null;
238
+ const tarRealPath = tar !== null ? realpathSync(tar).toLowerCase() : "";
239
+ const isGitGnuTar = tarRealPath.includes("\\git") || tarRealPath.includes("/git/");
240
+ const resolvedTar = systemTar ?? tar;
241
+ const tarBase = resolvedTar === null ? null : systemTar === null && isGitGnuTar ? [resolvedTar, "--force-local"] : [resolvedTar];
236
242
  switch (kind) {
237
243
  case "zip": {
238
244
  const preferTar = process.platform === "win32" || unzip === null;
239
- if (preferTar && tar !== null) {
240
- return [tar, "-xf", archivePath, "-C", stagingDir];
245
+ if (preferTar && tarBase !== null) {
246
+ return [...tarBase, "-xf", archivePath, "-C", stagingDir];
241
247
  }
242
248
  if (unzip !== null) {
243
249
  return [unzip, "-o", "-q", archivePath, "-d", stagingDir];
244
250
  }
245
- if (tar !== null) {
246
- return [tar, "-xf", archivePath, "-C", stagingDir];
251
+ if (tarBase !== null) {
252
+ return [...tarBase, "-xf", archivePath, "-C", stagingDir];
247
253
  }
248
254
  throw new Error("cannot extract .zip: neither tar nor unzip is on PATH");
249
255
  }
@@ -256,10 +262,10 @@ function extractionArgv(kind, archivePath, stagingDir) {
256
262
  }
257
263
  case "tar":
258
264
  case "tgz": {
259
- if (tar === null) {
265
+ if (tarBase === null) {
260
266
  throw new Error(`cannot extract .${kind}: tar is not on PATH`);
261
267
  }
262
- return kind === "tgz" ? [tar, "-xzf", archivePath, "-C", stagingDir] : [tar, "-xf", archivePath, "-C", stagingDir];
268
+ return kind === "tgz" ? [...tarBase, "-xzf", archivePath, "-C", stagingDir] : [...tarBase, "-xf", archivePath, "-C", stagingDir];
263
269
  }
264
270
  }
265
271
  }
@@ -852,7 +858,7 @@ var init_engine = __esm(() => {
852
858
  });
853
859
 
854
860
  // cli/src/paths.ts
855
- import { existsSync, mkdirSync, readFileSync } from "fs";
861
+ import { existsSync as existsSync2, mkdirSync, readFileSync } from "fs";
856
862
  import { homedir } from "os";
857
863
  import { dirname as dirname2, join as join5, resolve as resolve3 } from "path";
858
864
  function resolveInstallRoot(env = process.env, platform = process.platform) {
@@ -930,14 +936,14 @@ function resolveDevRepoRoot(startDir = import.meta.dir) {
930
936
  }
931
937
  }
932
938
  function isRepoRoot(dir) {
933
- if (!existsSync(join5(dir, "src", "app.ts"))) {
939
+ if (!existsSync2(join5(dir, "src", "app.ts"))) {
934
940
  return false;
935
941
  }
936
- if (!existsSync(join5(dir, "src", "main.ts"))) {
942
+ if (!existsSync2(join5(dir, "src", "main.ts"))) {
937
943
  return false;
938
944
  }
939
945
  const manifestPath = join5(dir, "package.json");
940
- if (!existsSync(manifestPath)) {
946
+ if (!existsSync2(manifestPath)) {
941
947
  return false;
942
948
  }
943
949
  let parsed;
@@ -1584,7 +1590,7 @@ var init_app = __esm(async () => {
1584
1590
 
1585
1591
  // cli/src/launcher.ts
1586
1592
  init_version();
1587
- import { existsSync as existsSync4 } from "fs";
1593
+ import { existsSync as existsSync5 } from "fs";
1588
1594
  import { join as join8 } from "path";
1589
1595
 
1590
1596
  // cli/src/bootstrap.ts
@@ -1780,6 +1786,7 @@ import { mkdir as mkdir4, rename as rename2, rm as rm6, writeFile } from "fs/pro
1780
1786
  import { dirname as dirname3 } from "path";
1781
1787
  var CONTROL_TOKEN_HEADER = "x-lianrouter-control";
1782
1788
  var LOOPBACK_ADDRESSES = ["127.0.0.1", "::1", "::ffff:127.0.0.1"];
1789
+ var OPEN_WEB_DEDUPE_MS = 3000;
1783
1790
 
1784
1791
  class ControlServer {
1785
1792
  options;
@@ -1791,6 +1798,8 @@ class ControlServer {
1791
1798
  updateSnapshot = null;
1792
1799
  updateProgress = null;
1793
1800
  updateRunning = false;
1801
+ updateCheckInFlight;
1802
+ lastOpenWebAt;
1794
1803
  constructor(options) {
1795
1804
  this.options = options;
1796
1805
  }
@@ -1869,6 +1878,24 @@ class ControlServer {
1869
1878
  setUpdateRunning(running) {
1870
1879
  this.updateRunning = running;
1871
1880
  }
1881
+ checkUpdate() {
1882
+ const inFlight = this.updateCheckInFlight;
1883
+ if (inFlight !== undefined) {
1884
+ return inFlight;
1885
+ }
1886
+ const check = this.options.onCheckUpdate;
1887
+ if (check === undefined) {
1888
+ return Promise.reject(new Error("update checks are unavailable in this build"));
1889
+ }
1890
+ const pending = check().then((snapshot) => {
1891
+ this.publishUpdate(snapshot);
1892
+ return snapshot;
1893
+ }).finally(() => {
1894
+ this.updateCheckInFlight = undefined;
1895
+ });
1896
+ this.updateCheckInFlight = pending;
1897
+ return pending;
1898
+ }
1872
1899
  get updateState() {
1873
1900
  return {
1874
1901
  snapshot: this.updateSnapshot,
@@ -1908,13 +1935,32 @@ class ControlServer {
1908
1935
  return json(await this.options.supervisor.restart());
1909
1936
  }
1910
1937
  if (method === "POST" && pathname === "/open-web") {
1911
- this.openUrl(this.options.consoleUrl);
1938
+ const now = (this.options.now ?? Date.now)();
1939
+ if (this.lastOpenWebAt === undefined || now - this.lastOpenWebAt >= OPEN_WEB_DEDUPE_MS) {
1940
+ this.lastOpenWebAt = now;
1941
+ this.openUrl(this.options.consoleUrl);
1942
+ }
1912
1943
  return json({ ok: true, url: this.options.consoleUrl });
1913
1944
  }
1914
1945
  if (method === "POST" && pathname === "/tray/hide") {
1915
1946
  this.options.onTrayHide?.();
1916
1947
  return json({ ok: true });
1917
1948
  }
1949
+ if (method === "POST" && pathname === "/update/check") {
1950
+ const checkUpdate = this.options.onCheckUpdate;
1951
+ if (checkUpdate === undefined) {
1952
+ return json({ error: "update checks are unavailable in this build" }, 501);
1953
+ }
1954
+ if (this.updateRunning) {
1955
+ return json({ error: "an update is already running" }, 409);
1956
+ }
1957
+ try {
1958
+ return json(await this.checkUpdate());
1959
+ } catch (error) {
1960
+ const message = error instanceof Error ? error.message : String(error);
1961
+ return json({ error: `update check failed: ${message}` }, 502);
1962
+ }
1963
+ }
1918
1964
  if (method === "POST" && pathname === "/update/start") {
1919
1965
  const startUpdate = this.options.startUpdate;
1920
1966
  if (startUpdate === undefined) {
@@ -2634,7 +2680,7 @@ class GatewaySupervisor {
2634
2680
  // cli/src/install-config.ts
2635
2681
  init_paths();
2636
2682
  import { randomBytes } from "crypto";
2637
- import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync } from "fs";
2683
+ import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync } from "fs";
2638
2684
  var ALWAYS_REQUIRED = ["DATABASE_URL", "LIANROUTER_ENCRYPTION_KEY"];
2639
2685
  function parseEnvFile(text) {
2640
2686
  const values = {};
@@ -2664,7 +2710,7 @@ function parseEnvFile(text) {
2664
2710
  }
2665
2711
  function resolveGatewayConfig(installRoot, shellEnv = process.env) {
2666
2712
  const path = resolveConfigFile(installRoot);
2667
- const present = existsSync2(path);
2713
+ const present = existsSync3(path);
2668
2714
  const fileValues = present ? parseEnvFile(readFileSync2(path, "utf8")) : {};
2669
2715
  const env = {};
2670
2716
  for (const [key, value] of Object.entries(fileValues)) {
@@ -2898,11 +2944,11 @@ async function checkLauncherVersion(options) {
2898
2944
 
2899
2945
  // cli/src/tray-launcher.ts
2900
2946
  init_paths();
2901
- import { existsSync as existsSync3 } from "fs";
2947
+ import { existsSync as existsSync4 } from "fs";
2902
2948
  import { readFile as readFile2, rm as rm8, writeFile as writeFile3 } from "fs/promises";
2903
2949
  import { join as join7 } from "path";
2904
2950
  function resolveTrayEntry(options) {
2905
- return trayEntryCandidates(options).find((candidate) => existsSync3(candidate));
2951
+ return trayEntryCandidates(options).find((candidate) => existsSync4(candidate));
2906
2952
  }
2907
2953
  function trayEntryCandidates(options) {
2908
2954
  const bundleDir = options.bundleDir ?? import.meta.dir;
@@ -3024,6 +3070,16 @@ async function readTrayPid(installRoot) {
3024
3070
  return Number.isInteger(pid) && pid > 0 ? pid : undefined;
3025
3071
  }
3026
3072
 
3073
+ // cli/tray/connection.ts
3074
+ function isProcessAlive2(pid) {
3075
+ try {
3076
+ process.kill(pid, 0);
3077
+ return true;
3078
+ } catch {
3079
+ return false;
3080
+ }
3081
+ }
3082
+
3027
3083
  // cli/src/launcher.ts
3028
3084
  var USAGE = `lianrouter v${CLI_VERSION}
3029
3085
 
@@ -3146,7 +3202,7 @@ function readPortEnv() {
3146
3202
  }
3147
3203
  function resolveRuntime() {
3148
3204
  const repoRoot = resolveDevRepoRoot();
3149
- if (repoRoot !== undefined && existsSync4(join8(repoRoot, "src", "app.ts"))) {
3205
+ if (repoRoot !== undefined && existsSync5(join8(repoRoot, "src", "app.ts"))) {
3150
3206
  return {
3151
3207
  installRoot: resolveInstallRoot(),
3152
3208
  cwd: repoRoot,
@@ -3158,7 +3214,7 @@ function resolveRuntime() {
3158
3214
  return { installRoot, cwd: installRoot, command: undefined, devRepoRoot: undefined };
3159
3215
  }
3160
3216
  async function ensureInstalledGateway(installRoot) {
3161
- const present = existsSync4(resolveBinaryPath(installRoot));
3217
+ const present = existsSync5(resolveBinaryPath(installRoot));
3162
3218
  if (present) {
3163
3219
  await ensureGatewayInstalled({ installRoot, currentVersion: CLI_VERSION });
3164
3220
  return;
@@ -3283,7 +3339,7 @@ async function stopServer(supervisor) {
3283
3339
  await supervisor.dispose();
3284
3340
  return 0;
3285
3341
  }
3286
- async function openSession(supervisor, runtime, host) {
3342
+ async function openSession(supervisor, runtime, host, bootCheck) {
3287
3343
  ensureStateDirs(runtime.installRoot);
3288
3344
  const control = new ControlServer({
3289
3345
  installRoot: runtime.installRoot,
@@ -3296,6 +3352,7 @@ async function openSession(supervisor, runtime, host) {
3296
3352
  hideConsoleWindow();
3297
3353
  stopTray(runtime.installRoot);
3298
3354
  },
3355
+ onCheckUpdate: () => checkUpdateNow(runtime.installRoot),
3299
3356
  startUpdate: async () => {
3300
3357
  control.setUpdateRunning(true);
3301
3358
  try {
@@ -3321,6 +3378,11 @@ async function openSession(supervisor, runtime, host) {
3321
3378
  });
3322
3379
  const handshake = await control.start();
3323
3380
  activeControl = control;
3381
+ if (bootCheck && !updateCheckDisabled()) {
3382
+ control.checkUpdate().catch(() => {
3383
+ return;
3384
+ });
3385
+ }
3324
3386
  return { supervisor, control, handshake, installRoot: runtime.installRoot };
3325
3387
  }
3326
3388
  async function openWeb(supervisor, options) {
@@ -3364,7 +3426,7 @@ async function runInteractive(supervisor, options, runtime) {
3364
3426
  await ensureStarted(supervisor);
3365
3427
  const launcher = await launcherCheck;
3366
3428
  const launcherNotice = launcher?.status === "outdated" ? { launcher: { current: launcher.current, latest: launcher.latest } } : {};
3367
- const session = await openSession(supervisor, runtime, options.host);
3429
+ const session = await openSession(supervisor, runtime, options.host, options.headless);
3368
3430
  if (options.background) {
3369
3431
  supervisor.detach();
3370
3432
  await session.control.stop();
@@ -3374,7 +3436,10 @@ async function runInteractive(supervisor, options, runtime) {
3374
3436
  if (options.headless) {
3375
3437
  return await blockUntilTrayExit(supervisor, session, runtime);
3376
3438
  }
3377
- const update = checkDisabled ? null : await readUpdateInfo(runtime.installRoot);
3439
+ const update = checkDisabled ? null : await readUpdateInfo(runtime.installRoot).catch(() => null);
3440
+ if (update !== null) {
3441
+ session.control.publishUpdate(update);
3442
+ }
3378
3443
  for (const line of renderUpdateNotices({
3379
3444
  ...launcherNotice,
3380
3445
  ...update !== null && update.available ? { gateway: { current: update.current, latest: update.latest } } : {}
@@ -3457,11 +3522,30 @@ async function runUpdateWithProgress(supervisor, session, runtime) {
3457
3522
  async function startTrayHost(supervisor, session, runtime) {
3458
3523
  await ensureStarted(supervisor);
3459
3524
  const result = await startTray(runtime.devRepoRoot === undefined ? { installRoot: runtime.installRoot, control: session.handshake } : { installRoot: runtime.installRoot, control: session.handshake, devRepoRoot: runtime.devRepoRoot });
3460
- if (result.ok) {
3461
- hideConsoleWindow();
3525
+ if (!result.ok) {
3526
+ return result;
3527
+ }
3528
+ if (!await traySurvivedStartup(result.pid)) {
3529
+ return {
3530
+ ok: false,
3531
+ error: "The tray host exited while starting, so the console was left visible. Run `lianrouter tray` from a terminal to see why."
3532
+ };
3462
3533
  }
3534
+ hideConsoleWindow();
3463
3535
  return result;
3464
3536
  }
3537
+ var TRAY_STARTUP_GRACE_MS = 3000;
3538
+ var TRAY_STARTUP_POLL_MS = 150;
3539
+ async function traySurvivedStartup(pid, graceMs = TRAY_STARTUP_GRACE_MS) {
3540
+ const deadline = Date.now() + graceMs;
3541
+ while (Date.now() < deadline) {
3542
+ if (!isProcessAlive2(pid)) {
3543
+ return false;
3544
+ }
3545
+ await Bun.sleep(TRAY_STARTUP_POLL_MS);
3546
+ }
3547
+ return isProcessAlive2(pid);
3548
+ }
3465
3549
  async function blockUntilTrayExit(supervisor, session, runtime) {
3466
3550
  await new Promise((resolve) => {
3467
3551
  let settled = false;
@@ -3515,7 +3599,7 @@ async function shutdownAndExit(supervisor, control) {
3515
3599
  }
3516
3600
  async function enterTrayMode(supervisor, options, runtime) {
3517
3601
  await ensureStarted(supervisor);
3518
- const session = await openSession(supervisor, runtime, options.host);
3602
+ const session = await openSession(supervisor, runtime, options.host, true);
3519
3603
  const started = await startTrayHost(supervisor, session, runtime);
3520
3604
  if (!started.ok) {
3521
3605
  console.error(started.error);
@@ -3529,7 +3613,7 @@ async function enterTrayMode(supervisor, options, runtime) {
3529
3613
  }
3530
3614
  async function runTui2(supervisor, options, runtime) {
3531
3615
  await ensureStarted(supervisor);
3532
- const session = await openSession(supervisor, runtime, options.host);
3616
+ const session = await openSession(supervisor, runtime, options.host, true);
3533
3617
  await launchTui(supervisor, session);
3534
3618
  await shutdownSession(session, supervisor);
3535
3619
  return 0;
@@ -3567,13 +3651,16 @@ async function runUpdateFlow(supervisor, runtime) {
3567
3651
  console.log("Update complete.");
3568
3652
  return 0;
3569
3653
  }
3654
+ async function checkUpdateNow(installRoot) {
3655
+ const engine = await Promise.resolve().then(() => (init_engine(), {}));
3656
+ const info = await checkForUpdate({
3657
+ currentVersion: await resolveGatewayVersion(installRoot, CLI_VERSION)
3658
+ });
3659
+ return { current: info.current, latest: info.latest, available: info.available };
3660
+ }
3570
3661
  async function readUpdateInfo(installRoot) {
3571
3662
  try {
3572
- const engine = await Promise.resolve().then(() => (init_engine(), {}));
3573
- const info = await checkForUpdate({
3574
- currentVersion: await resolveGatewayVersion(installRoot, CLI_VERSION)
3575
- });
3576
- return { current: info.current, latest: info.latest, available: info.available };
3663
+ return await checkUpdateNow(installRoot);
3577
3664
  } catch {
3578
3665
  return null;
3579
3666
  }
package/dist/tray.js CHANGED
@@ -129,21 +129,11 @@ function createControlClient(port, token) {
129
129
  }
130
130
  return {
131
131
  status: () => call("/status", "GET", readStatus),
132
- restart: () => call("/server/restart", "POST", () => {
133
- return;
134
- }),
135
- stop: () => call("/server/stop", "POST", () => {
136
- return;
137
- }),
138
- shutdown: () => call("/shutdown", "POST", () => {
139
- return;
140
- }),
141
- openWeb: () => call("/open-web", "POST", () => {
142
- return;
143
- }),
144
- startUpdate: () => call("/update/start", "POST", () => {
145
- return;
146
- }),
132
+ restart: () => call("/server/restart", "POST", () => true),
133
+ stop: () => call("/server/stop", "POST", () => true),
134
+ shutdown: () => call("/shutdown", "POST", () => true),
135
+ openWeb: () => call("/open-web", "POST", () => true),
136
+ startUpdate: () => call("/update/start", "POST", () => true),
147
137
  updateState: () => call("/update/state", "GET", readUpdateState)
148
138
  };
149
139
  }
@@ -395,6 +385,43 @@ function readStalePid(installRoot) {
395
385
  return;
396
386
  }
397
387
 
388
+ // cli/tray/command-guard.ts
389
+ var OPEN_CONSOLE_GUARD_MS = 1500;
390
+ var MENU_REOPEN_GUARD_MS = 300;
391
+ function createCommandGuard(windowMs, now) {
392
+ const inFlight = new Set;
393
+ const lastStartedAt = new Map;
394
+ return {
395
+ async run(command, action) {
396
+ if (inFlight.has(command))
397
+ return false;
398
+ const last = lastStartedAt.get(command);
399
+ if (last !== undefined && now() - last < windowMs)
400
+ return false;
401
+ inFlight.add(command);
402
+ lastStartedAt.set(command, now());
403
+ try {
404
+ await action();
405
+ } finally {
406
+ inFlight.delete(command);
407
+ }
408
+ return true;
409
+ }
410
+ };
411
+ }
412
+ function createRepeatSuppressor(windowMs, now) {
413
+ let last = Number.NEGATIVE_INFINITY;
414
+ return {
415
+ allow() {
416
+ const at = now();
417
+ if (at - last < windowMs)
418
+ return false;
419
+ last = at;
420
+ return true;
421
+ }
422
+ };
423
+ }
424
+
398
425
  // cli/tray/pump.ts
399
426
  import { JSCallback, ptr as ptr2 } from "bun:ffi";
400
427
 
@@ -744,6 +771,7 @@ var WM_QUIT = 18;
744
771
  var WM_NULL = 0;
745
772
  var WM_NCCREATE = 129;
746
773
  var WM_RBUTTONUP = 517;
774
+ var WM_LBUTTONUP = 514;
747
775
  var WM_CONTEXTMENU = 123;
748
776
  var WM_LBUTTONDBLCLK = 515;
749
777
  var WM_APP = 32768;
@@ -811,9 +839,11 @@ function showContextMenu(window) {
811
839
  return command;
812
840
  }
813
841
  function decodeTrayEvent(mouseMessage) {
814
- if (mouseMessage === WM_RBUTTONUP || mouseMessage === WM_CONTEXTMENU)
842
+ if (mouseMessage === WM_RBUTTONUP)
815
843
  return "context";
816
- if (mouseMessage === WM_LBUTTONDBLCLK)
844
+ if (mouseMessage === WM_CONTEXTMENU)
845
+ return "context-alt";
846
+ if (mouseMessage === WM_LBUTTONUP || mouseMessage === WM_LBUTTONDBLCLK)
817
847
  return "activate";
818
848
  return "none";
819
849
  }
@@ -851,6 +881,8 @@ async function startTrayPump(options) {
851
881
  if (moduleHandle === undefined)
852
882
  throw new Error("GetModuleHandleW returned NULL");
853
883
  const state = { window: undefined, stopRequested: false, destroyed: false };
884
+ const menuGuard = createRepeatSuppressor(MENU_REOPEN_GUARD_MS, () => Date.now());
885
+ let menuOpen = false;
854
886
  const windowProc = new JSCallback((hWnd, message, wParam, lParam) => {
855
887
  if (message === WM_NCCREATE)
856
888
  return 1n;
@@ -859,8 +891,18 @@ async function startTrayPump(options) {
859
891
  const window = state.window;
860
892
  if (window === undefined)
861
893
  return 0n;
862
- if (event === "context") {
863
- const chosen = showContextMenu(window);
894
+ if (event === "context" || event === "context-alt") {
895
+ if (menuOpen)
896
+ return 0n;
897
+ if (!menuGuard.allow())
898
+ return 0n;
899
+ menuOpen = true;
900
+ let chosen = 0;
901
+ try {
902
+ chosen = showContextMenu(window);
903
+ } finally {
904
+ menuOpen = false;
905
+ }
864
906
  if (isTrayCommandId(chosen))
865
907
  options.onCommand(chosen);
866
908
  return 0n;
@@ -1175,6 +1217,7 @@ async function main() {
1175
1217
  sleep: (ms) => Bun.sleep(ms),
1176
1218
  now: () => Date.now()
1177
1219
  };
1220
+ const openConsoleGuard = createCommandGuard(OPEN_CONSOLE_GUARD_MS, () => Date.now());
1178
1221
  const runCommand = async (command) => {
1179
1222
  if (command === TRAY_COMMANDS.exit) {
1180
1223
  const result = await callRecovering({
@@ -1190,19 +1233,21 @@ async function main() {
1190
1233
  return;
1191
1234
  }
1192
1235
  if (command === TRAY_COMMANDS.openConsole) {
1193
- const result = await callRecovering({
1194
- installRoot,
1195
- startDir: import.meta.dir,
1196
- deps: recoveryDeps,
1197
- ...knownPort === undefined ? {} : { gatewayPort: knownPort },
1198
- call: (client) => client.openWeb()
1199
- });
1200
- if (result.result.ok) {
1236
+ await openConsoleGuard.run(command, async () => {
1237
+ const result = await callRecovering({
1238
+ installRoot,
1239
+ startDir: import.meta.dir,
1240
+ deps: recoveryDeps,
1241
+ ...knownPort === undefined ? {} : { gatewayPort: knownPort },
1242
+ call: (client) => client.openWeb()
1243
+ });
1244
+ if (result.result.ok) {
1245
+ refreshTooltip();
1246
+ return;
1247
+ }
1248
+ openConsoleDirectly();
1201
1249
  refreshTooltip();
1202
- return;
1203
- }
1204
- openConsoleDirectly();
1205
- refreshTooltip();
1250
+ });
1206
1251
  return;
1207
1252
  }
1208
1253
  if (command === TRAY_COMMANDS.checkUpdate) {
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "lianrouter",
3
- "version": "2.2.2",
3
+ "version": "2.3.1",
4
4
  "description": "LianRouter launcher: install, run and control the gateway from one command",
5
5
  "type": "module",
6
6
  "bin": {
7
- "lianrouter": "./dist/cli.js"
7
+ "lianrouter": "dist/cli.js"
8
8
  },
9
9
  "engines": {
10
10
  "bun": ">=1.4.2"