@vibedeckx/darwin-arm64 0.3.54-win.1 → 0.3.54-win.3

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 (2) hide show
  1. package/dist/bin.js +56 -16
  2. package/package.json +1 -1
package/dist/bin.js CHANGED
@@ -271187,7 +271187,7 @@ function judgeLiveness(status, pid, now3 = /* @__PURE__ */ new Date()) {
271187
271187
  }
271188
271188
 
271189
271189
  // src/connect-service.ts
271190
- import { spawnSync as spawnSync2 } from "node:child_process";
271190
+ import { spawnSync as spawnSync3 } from "node:child_process";
271191
271191
  import { createHash as createHash14 } from "node:crypto";
271192
271192
  import fs14 from "node:fs";
271193
271193
  import os3 from "node:os";
@@ -271323,10 +271323,20 @@ function hashTree(root, relativeFiles) {
271323
271323
  }
271324
271324
  return result;
271325
271325
  }
271326
+ function openForFsync(filePath) {
271327
+ if (process.platform !== "win32") return fs12.openSync(filePath, "r");
271328
+ try {
271329
+ return fs12.openSync(filePath, "r+");
271330
+ } catch (error48) {
271331
+ if (error48.code !== "EPERM") throw error48;
271332
+ fs12.chmodSync(filePath, 420);
271333
+ return fs12.openSync(filePath, "r+");
271334
+ }
271335
+ }
271326
271336
  function fsyncTree(root) {
271327
271337
  const { files, dirs } = walk(root);
271328
271338
  for (const file2 of files) {
271329
- const fd = fs12.openSync(path28.join(root, file2), "r");
271339
+ const fd = openForFsync(path28.join(root, file2));
271330
271340
  try {
271331
271341
  fs12.fsyncSync(fd);
271332
271342
  } finally {
@@ -271535,7 +271545,7 @@ function pruneRuntimeVersions(dataDir, keep) {
271535
271545
  }
271536
271546
 
271537
271547
  // src/connect-windows-supervise.ts
271538
- import { spawn as spawn8 } from "node:child_process";
271548
+ import { spawn as spawn8, spawnSync as spawnSync2 } from "node:child_process";
271539
271549
  import { createHash as createHash13 } from "node:crypto";
271540
271550
  import fs13 from "node:fs";
271541
271551
  import net2 from "node:net";
@@ -271559,20 +271569,38 @@ function stopMarkerPath(dataDir) {
271559
271569
  function currentBootTimeMs(now3 = Date.now(), uptimeSeconds = os2.uptime()) {
271560
271570
  return now3 - uptimeSeconds * 1e3;
271561
271571
  }
271562
- function writeStopMarker(dataDir, bootTimeMs = currentBootTimeMs()) {
271563
- writeFileAtomic(stopMarkerPath(dataDir), `${JSON.stringify({ bootTimeMs })}
271572
+ function parseLogonId(whoamiOutput) {
271573
+ return /S-1-5-5-\d+-\d+/.exec(whoamiOutput)?.[0];
271574
+ }
271575
+ var cachedLogonId;
271576
+ function currentLogonId() {
271577
+ if (process.platform !== "win32") return void 0;
271578
+ if (cachedLogonId) return cachedLogonId;
271579
+ const result = spawnSync2("whoami", ["/logonid"], { encoding: "utf8", windowsHide: true, timeout: 15e3 });
271580
+ cachedLogonId = result.status === 0 ? parseLogonId(result.stdout ?? "") : void 0;
271581
+ return cachedLogonId;
271582
+ }
271583
+ function currentStopScope() {
271584
+ return { bootTimeMs: currentBootTimeMs(), logonId: currentLogonId() };
271585
+ }
271586
+ function writeStopMarker(dataDir, scope = currentStopScope()) {
271587
+ writeFileAtomic(stopMarkerPath(dataDir), `${JSON.stringify(scope)}
271564
271588
  `);
271565
271589
  }
271566
271590
  function clearStopMarker(dataDir) {
271567
271591
  fs13.rmSync(stopMarkerPath(dataDir), { force: true });
271568
271592
  }
271569
- function stoppedThisBoot(dataDir, bootTimeMs = currentBootTimeMs()) {
271593
+ function stopMarkerActive(dataDir, scope = currentStopScope()) {
271594
+ let marker25;
271570
271595
  try {
271571
- const parsed = JSON.parse(fs13.readFileSync(stopMarkerPath(dataDir), "utf8"));
271572
- return typeof parsed.bootTimeMs === "number" && Math.abs(parsed.bootTimeMs - bootTimeMs) < BOOT_TOLERANCE_MS;
271596
+ marker25 = JSON.parse(fs13.readFileSync(stopMarkerPath(dataDir), "utf8"));
271573
271597
  } catch {
271574
271598
  return false;
271575
271599
  }
271600
+ if (typeof marker25.bootTimeMs !== "number" || Math.abs(marker25.bootTimeMs - scope.bootTimeMs) >= BOOT_TOLERANCE_MS) {
271601
+ return false;
271602
+ }
271603
+ return !marker25.logonId || !scope.logonId || marker25.logonId === scope.logonId;
271576
271604
  }
271577
271605
  function sendSuperviseCommand(dataDir, command, timeoutMs = 3e4) {
271578
271606
  return new Promise((resolve3, reject) => {
@@ -271636,8 +271664,8 @@ async function runSupervise(options) {
271636
271664
  fs13.writeSync(logFd, `${(/* @__PURE__ */ new Date()).toISOString()} [${process.pid}] ${message}
271637
271665
  `);
271638
271666
  };
271639
- if (stoppedThisBoot(dataDir)) {
271640
- log("stopped by `connect stop` during this boot; not starting the worker");
271667
+ if (stopMarkerActive(dataDir)) {
271668
+ log("stopped by `connect stop` in this logon session; not starting the worker");
271641
271669
  return 0;
271642
271670
  }
271643
271671
  const server = net2.createServer();
@@ -271727,8 +271755,10 @@ async function runSupervise(options) {
271727
271755
  const command = buffer.slice(0, newline).trim();
271728
271756
  buffer = "";
271729
271757
  if (command === "ping") {
271730
- socket.end(`${JSON.stringify({ pid: process.pid, workerPid: worker?.pid ?? null })}
271731
- `);
271758
+ socket.end(
271759
+ `${JSON.stringify({ pid: process.pid, workerPid: worker?.pid ?? null, logonId: currentLogonId() ?? null })}
271760
+ `
271761
+ );
271732
271762
  return;
271733
271763
  }
271734
271764
  if (command === "quit") {
@@ -271757,7 +271787,7 @@ async function runSupervise(options) {
271757
271787
 
271758
271788
  // src/connect-service.ts
271759
271789
  var defaultExec = (command, args) => {
271760
- const result = spawnSync2(command, args, { encoding: "utf8", windowsHide: true });
271790
+ const result = spawnSync3(command, args, { encoding: "utf8", windowsHide: true });
271761
271791
  if (result.error) {
271762
271792
  return { status: null, stdout: "", stderr: result.error.message };
271763
271793
  }
@@ -272286,9 +272316,19 @@ var TaskSchedulerAdapter = class {
272286
272316
  `${this.name} was started but its supervisor did not come up; see logs\\supervise.log in ${this.dataDir}`
272287
272317
  );
272288
272318
  }
272289
- /** Stopped until the next boot (the marker) or `start`; auto-start is kept. */
272319
+ /**
272320
+ * Stopped until the next login or boot (the marker) or `start`; auto-start
272321
+ * is kept. The marker names the supervisor's logon session, which need not
272322
+ * be ours (e.g. `connect stop` over SSH).
272323
+ */
272290
272324
  async stop() {
272291
- writeStopMarker(this.dataDir);
272325
+ const scope = currentStopScope();
272326
+ try {
272327
+ const reply = JSON.parse(await this.client(this.dataDir, "ping") ?? "{}");
272328
+ if (typeof reply.logonId === "string") scope.logonId = reply.logonId;
272329
+ } catch {
272330
+ }
272331
+ writeStopMarker(this.dataDir, scope);
272292
272332
  await this.quit();
272293
272333
  }
272294
272334
  /** Restarts the supervisor too, so it picks up a new runtime. */
@@ -272693,7 +272733,7 @@ async function lifecycleStop(options) {
272693
272733
  if (adapter) {
272694
272734
  return runServiceAction(
272695
272735
  () => adapter.stop(),
272696
- `Stopped ${adapter.name}. It starts again at the next ${adapter.kind === "schtasks" ? "boot" : "boot/login"}; use \`vibedeckx connect disable\` to keep it off.`
272736
+ `Stopped ${adapter.name}. It starts again at the next boot/login; use \`vibedeckx connect disable\` to keep it off.`
272697
272737
  );
272698
272738
  }
272699
272739
  return stopConnectDaemon(options.dataDir);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibedeckx/darwin-arm64",
3
- "version": "0.3.54-win.1",
3
+ "version": "0.3.54-win.3",
4
4
  "description": "Vibedeckx platform binaries for macOS ARM64",
5
5
  "repository": {
6
6
  "type": "git",