@fungi.computer/oyster 0.12.1 → 0.13.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.
@@ -494,7 +494,7 @@ var require_react_development = __commonJS({
494
494
  * @param {?string} callerName name of the calling function in the public API.
495
495
  * @internal
496
496
  */
497
- enqueueForceUpdate: function(publicInstance, callback2, callerName) {
497
+ enqueueForceUpdate: function(publicInstance, callback3, callerName) {
498
498
  warnNoop(publicInstance, "forceUpdate");
499
499
  },
500
500
  /**
@@ -510,7 +510,7 @@ var require_react_development = __commonJS({
510
510
  * @param {?string} callerName name of the calling function in the public API.
511
511
  * @internal
512
512
  */
513
- enqueueReplaceState: function(publicInstance, completeState, callback2, callerName) {
513
+ enqueueReplaceState: function(publicInstance, completeState, callback3, callerName) {
514
514
  warnNoop(publicInstance, "replaceState");
515
515
  },
516
516
  /**
@@ -525,7 +525,7 @@ var require_react_development = __commonJS({
525
525
  * @param {?string} Name of the calling function in the public API.
526
526
  * @internal
527
527
  */
528
- enqueueSetState: function(publicInstance, partialState, callback2, callerName) {
528
+ enqueueSetState: function(publicInstance, partialState, callback3, callerName) {
529
529
  warnNoop(publicInstance, "setState");
530
530
  }
531
531
  };
@@ -541,14 +541,14 @@ var require_react_development = __commonJS({
541
541
  this.updater = updater || ReactNoopUpdateQueue;
542
542
  }
543
543
  Component.prototype.isReactComponent = {};
544
- Component.prototype.setState = function(partialState, callback2) {
544
+ Component.prototype.setState = function(partialState, callback3) {
545
545
  if (typeof partialState !== "object" && typeof partialState !== "function" && partialState != null) {
546
546
  throw new Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");
547
547
  }
548
- this.updater.enqueueSetState(this, partialState, callback2, "setState");
548
+ this.updater.enqueueSetState(this, partialState, callback3, "setState");
549
549
  };
550
- Component.prototype.forceUpdate = function(callback2) {
551
- this.updater.enqueueForceUpdate(this, callback2, "forceUpdate");
550
+ Component.prototype.forceUpdate = function(callback3) {
551
+ this.updater.enqueueForceUpdate(this, callback3, "forceUpdate");
552
552
  };
553
553
  {
554
554
  var deprecatedAPIs = {
@@ -952,7 +952,7 @@ var require_react_development = __commonJS({
952
952
  }
953
953
  return index.toString(36);
954
954
  }
955
- function mapIntoArray(children, array3, escapedPrefix, nameSoFar, callback2) {
955
+ function mapIntoArray(children, array3, escapedPrefix, nameSoFar, callback3) {
956
956
  var type2 = typeof children;
957
957
  if (type2 === "undefined" || type2 === "boolean") {
958
958
  children = null;
@@ -976,7 +976,7 @@ var require_react_development = __commonJS({
976
976
  }
977
977
  if (invokeCallback) {
978
978
  var _child = children;
979
- var mappedChild = callback2(_child);
979
+ var mappedChild = callback3(_child);
980
980
  var childKey = nameSoFar === "" ? SEPARATOR + getElementKey(_child, 0) : nameSoFar;
981
981
  if (isArray2(mappedChild)) {
982
982
  var escapedChildKey = "";
@@ -1017,7 +1017,7 @@ var require_react_development = __commonJS({
1017
1017
  for (var i2 = 0; i2 < children.length; i2++) {
1018
1018
  child = children[i2];
1019
1019
  nextName = nextNamePrefix + getElementKey(child, i2);
1020
- subtreeCount += mapIntoArray(child, array3, escapedPrefix, nextName, callback2);
1020
+ subtreeCount += mapIntoArray(child, array3, escapedPrefix, nextName, callback3);
1021
1021
  }
1022
1022
  } else {
1023
1023
  var iteratorFn = getIteratorFn(children);
@@ -1037,7 +1037,7 @@ var require_react_development = __commonJS({
1037
1037
  while (!(step = iterator.next()).done) {
1038
1038
  child = step.value;
1039
1039
  nextName = nextNamePrefix + getElementKey(child, ii++);
1040
- subtreeCount += mapIntoArray(child, array3, escapedPrefix, nextName, callback2);
1040
+ subtreeCount += mapIntoArray(child, array3, escapedPrefix, nextName, callback3);
1041
1041
  }
1042
1042
  } else if (type2 === "object") {
1043
1043
  var childrenString = String(children);
@@ -1404,9 +1404,9 @@ var require_react_development = __commonJS({
1404
1404
  var dispatcher = resolveDispatcher();
1405
1405
  return dispatcher.useLayoutEffect(create, deps);
1406
1406
  }
1407
- function useCallback(callback2, deps) {
1407
+ function useCallback(callback3, deps) {
1408
1408
  var dispatcher = resolveDispatcher();
1409
- return dispatcher.useCallback(callback2, deps);
1409
+ return dispatcher.useCallback(callback3, deps);
1410
1410
  }
1411
1411
  function useMemo(create, deps) {
1412
1412
  var dispatcher = resolveDispatcher();
@@ -1982,7 +1982,7 @@ var require_react_development = __commonJS({
1982
1982
  var nodeRequire = module && module[requireString];
1983
1983
  enqueueTaskImpl = nodeRequire.call(module, "timers").setImmediate;
1984
1984
  } catch (_err) {
1985
- enqueueTaskImpl = function(callback2) {
1985
+ enqueueTaskImpl = function(callback3) {
1986
1986
  {
1987
1987
  if (didWarnAboutMessageChannel === false) {
1988
1988
  didWarnAboutMessageChannel = true;
@@ -1992,7 +1992,7 @@ var require_react_development = __commonJS({
1992
1992
  }
1993
1993
  }
1994
1994
  var channel = new MessageChannel();
1995
- channel.port1.onmessage = callback2;
1995
+ channel.port1.onmessage = callback3;
1996
1996
  channel.port2.postMessage(void 0);
1997
1997
  };
1998
1998
  }
@@ -2001,7 +2001,7 @@ var require_react_development = __commonJS({
2001
2001
  }
2002
2002
  var actScopeDepth = 0;
2003
2003
  var didWarnNoAwaitAct = false;
2004
- function act(callback2) {
2004
+ function act(callback3) {
2005
2005
  {
2006
2006
  var prevActScopeDepth = actScopeDepth;
2007
2007
  actScopeDepth++;
@@ -2012,7 +2012,7 @@ var require_react_development = __commonJS({
2012
2012
  var result2;
2013
2013
  try {
2014
2014
  ReactCurrentActQueue.isBatchingLegacy = true;
2015
- result2 = callback2();
2015
+ result2 = callback3();
2016
2016
  if (!prevIsBatchingLegacy && ReactCurrentActQueue.didScheduleLegacyUpdate) {
2017
2017
  var queue = ReactCurrentActQueue.current;
2018
2018
  if (queue !== null) {
@@ -2126,10 +2126,10 @@ var require_react_development = __commonJS({
2126
2126
  var i2 = 0;
2127
2127
  try {
2128
2128
  for (; i2 < queue.length; i2++) {
2129
- var callback2 = queue[i2];
2129
+ var callback3 = queue[i2];
2130
2130
  do {
2131
- callback2 = callback2(true);
2132
- } while (callback2 !== null);
2131
+ callback3 = callback3(true);
2132
+ } while (callback3 !== null);
2133
2133
  }
2134
2134
  queue.length = 0;
2135
2135
  } catch (error3) {
@@ -7207,18 +7207,18 @@ var require_polyfills = __commonJS({
7207
7207
  }
7208
7208
  fs.read = typeof fs.read !== "function" ? fs.read : (function(fs$read) {
7209
7209
  function read(fd, buffer, offset, length, position, callback_) {
7210
- var callback2;
7210
+ var callback3;
7211
7211
  if (callback_ && typeof callback_ === "function") {
7212
7212
  var eagCounter = 0;
7213
- callback2 = function(er, _, __) {
7213
+ callback3 = function(er, _, __) {
7214
7214
  if (er && er.code === "EAGAIN" && eagCounter < 10) {
7215
7215
  eagCounter++;
7216
- return fs$read.call(fs, fd, buffer, offset, length, position, callback2);
7216
+ return fs$read.call(fs, fd, buffer, offset, length, position, callback3);
7217
7217
  }
7218
7218
  callback_.apply(this, arguments);
7219
7219
  };
7220
7220
  }
7221
- return fs$read.call(fs, fd, buffer, offset, length, position, callback2);
7221
+ return fs$read.call(fs, fd, buffer, offset, length, position, callback3);
7222
7222
  }
7223
7223
  if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
7224
7224
  return read;
@@ -7240,19 +7240,19 @@ var require_polyfills = __commonJS({
7240
7240
  };
7241
7241
  })(fs.readSync);
7242
7242
  function patchLchmod(fs2) {
7243
- fs2.lchmod = function(path, mode, callback2) {
7243
+ fs2.lchmod = function(path, mode, callback3) {
7244
7244
  fs2.open(
7245
7245
  path,
7246
7246
  constants.O_WRONLY | constants.O_SYMLINK,
7247
7247
  mode,
7248
7248
  function(err, fd) {
7249
7249
  if (err) {
7250
- if (callback2) callback2(err);
7250
+ if (callback3) callback3(err);
7251
7251
  return;
7252
7252
  }
7253
7253
  fs2.fchmod(fd, mode, function(err2) {
7254
7254
  fs2.close(fd, function(err22) {
7255
- if (callback2) callback2(err2 || err22);
7255
+ if (callback3) callback3(err2 || err22);
7256
7256
  });
7257
7257
  });
7258
7258
  }
@@ -7365,14 +7365,14 @@ var require_polyfills = __commonJS({
7365
7365
  cb = options;
7366
7366
  options = null;
7367
7367
  }
7368
- function callback2(er, stats) {
7368
+ function callback3(er, stats) {
7369
7369
  if (stats) {
7370
7370
  if (stats.uid < 0) stats.uid += 4294967296;
7371
7371
  if (stats.gid < 0) stats.gid += 4294967296;
7372
7372
  }
7373
7373
  if (cb) cb.apply(this, arguments);
7374
7374
  }
7375
- return options ? orig.call(fs, target, options, callback2) : orig.call(fs, target, callback2);
7375
+ return options ? orig.call(fs, target, options, callback3) : orig.call(fs, target, callback3);
7376
7376
  };
7377
7377
  }
7378
7378
  function statFixSync(orig) {
@@ -8286,18 +8286,18 @@ var require_lib2 = __commonJS({
8286
8286
  }
8287
8287
  }
8288
8288
  }
8289
- async function writeFile4(filename, data, options, callback2) {
8289
+ async function writeFile4(filename, data, options, callback3) {
8290
8290
  if (options instanceof Function) {
8291
- callback2 = options;
8291
+ callback3 = options;
8292
8292
  options = {};
8293
8293
  }
8294
8294
  const promise3 = writeFileAsync(filename, data, options);
8295
- if (callback2) {
8295
+ if (callback3) {
8296
8296
  try {
8297
8297
  const result2 = await promise3;
8298
- return callback2(result2);
8298
+ return callback3(result2);
8299
8299
  } catch (err) {
8300
- return callback2(err);
8300
+ return callback3(err);
8301
8301
  }
8302
8302
  }
8303
8303
  return promise3;
@@ -11365,9 +11365,9 @@ var iterateConcurrentImpl = (options) => {
11365
11365
  };
11366
11366
  var iterateConcurrent = () => (options) => iterateConcurrentImpl(options);
11367
11367
  var filterOrElse = /* @__PURE__ */ dual(3, (self, predicate, orElse) => flatMap(self, (a) => predicate(a) ? succeed3(a) : orElse(a)));
11368
- var forkUnsafe = (parent, effect, immediate = false, daemon = false, uninterruptible2 = false) => {
11368
+ var forkUnsafe = (parent, effect, immediate = false, daemon = false, uninterruptible3 = false) => {
11369
11369
  const parentRuntime = parent;
11370
- const interruptible2 = uninterruptible2 === "inherit" ? parentRuntime.interruptible : !uninterruptible2;
11370
+ const interruptible2 = uninterruptible3 === "inherit" ? parentRuntime.interruptible : !uninterruptible3;
11371
11371
  const child = new FiberImpl(parentRuntime.context, interruptible2);
11372
11372
  if (!daemon) {
11373
11373
  parentRuntime.children().add(child);
@@ -11532,7 +11532,7 @@ var tryPromise2 = tryPromise;
11532
11532
  var succeed5 = succeed3;
11533
11533
  var suspend2 = suspend;
11534
11534
  var sync2 = sync;
11535
- var void_3 = void_;
11535
+ var callback2 = callback;
11536
11536
  var gen2 = gen;
11537
11537
  var fail5 = fail3;
11538
11538
  var failCauseSync2 = failCauseSync;
@@ -11542,13 +11542,13 @@ var fromResult2 = fromResult;
11542
11542
  var flatMap2 = flatMap;
11543
11543
  var exit2 = exit;
11544
11544
  var map4 = map2;
11545
- var catch_2 = catch_;
11546
11545
  var catchCause2 = catchCause;
11547
11546
  var mapError3 = mapError2;
11548
11547
  var filterOrFail2 = filterOrFail;
11549
11548
  var scoped2 = scoped;
11550
11549
  var acquireRelease2 = acquireRelease;
11551
11550
  var acquireUseRelease2 = acquireUseRelease;
11551
+ var uninterruptible2 = uninterruptible;
11552
11552
  var runPromise2 = runPromise;
11553
11553
  var runSyncExit2 = runSyncExit;
11554
11554
  var mapEager2 = mapEager;
@@ -22578,7 +22578,76 @@ import { join as join6 } from "node:path";
22578
22578
  // src/build.ts
22579
22579
  init_snapshot_program_scripts();
22580
22580
 
22581
+ // src/build/process-group.ts
22582
+ import { setTimeout as delay2 } from "node:timers/promises";
22583
+ var CleanupError = class extends Error {
22584
+ };
22585
+ function processGroupExists(child) {
22586
+ if (child.pid === void 0) return false;
22587
+ try {
22588
+ process.kill(-child.pid, 0);
22589
+ return true;
22590
+ } catch (error2) {
22591
+ if (error2 instanceof Error && "code" in error2 && error2.code === "ESRCH")
22592
+ return false;
22593
+ throw error2;
22594
+ }
22595
+ }
22596
+ async function stopProcessGroup(child) {
22597
+ try {
22598
+ if (process.platform === "win32") await stopChild(child);
22599
+ else await stopGroup(child);
22600
+ } catch (cause) {
22601
+ throw new CleanupError("Owned process cleanup did not complete.", {
22602
+ cause
22603
+ });
22604
+ }
22605
+ }
22606
+ async function stopGroup(child) {
22607
+ if (!processGroupExists(child)) return;
22608
+ const deadline = Date.now() + 5e3;
22609
+ for (const [signal, until] of [
22610
+ ["SIGTERM", deadline - 1e3],
22611
+ ["SIGKILL", deadline]
22612
+ ]) {
22613
+ try {
22614
+ if (child.pid !== void 0) process.kill(-child.pid, signal);
22615
+ } catch (error2) {
22616
+ if (!(error2 instanceof Error && "code" in error2 && error2.code === "ESRCH"))
22617
+ throw error2;
22618
+ }
22619
+ while (processGroupExists(child) && Date.now() < until) await delay2(25);
22620
+ if (!processGroupExists(child)) return;
22621
+ }
22622
+ throw new Error("Owned process group survived its five-second cleanup bound");
22623
+ }
22624
+ async function stopChild(child) {
22625
+ if (child.pid === void 0 || child.exitCode !== null || child.signalCode !== null)
22626
+ return;
22627
+ let closed;
22628
+ let force;
22629
+ let deadline;
22630
+ try {
22631
+ await new Promise((resolve6, reject) => {
22632
+ closed = resolve6;
22633
+ child.once("close", closed);
22634
+ child.kill("SIGTERM");
22635
+ force = setTimeout(() => {
22636
+ child.kill("SIGKILL");
22637
+ }, 4e3);
22638
+ deadline = setTimeout(() => {
22639
+ reject(new Error("Owned child survived its five-second cleanup bound"));
22640
+ }, 5e3);
22641
+ });
22642
+ } finally {
22643
+ clearTimeout(force);
22644
+ clearTimeout(deadline);
22645
+ if (closed !== void 0) child.off("close", closed);
22646
+ }
22647
+ }
22648
+
22581
22649
  // src/build/local-build.ts
22650
+ import { addAbortListener } from "node:events";
22582
22651
  import { Buffer as Buffer2 } from "node:buffer";
22583
22652
 
22584
22653
  // src/build/definition-emission.ts
@@ -22781,7 +22850,8 @@ async function createDefinitionEmission(source, recipe) {
22781
22850
  );
22782
22851
  const file = join(source.snapshotPath, ".fungi-built-definition.mjs");
22783
22852
  await writeFile(file, declarationCode, { flag: "wx", mode: 384 });
22784
- const result2 = await promisify(execFile)(
22853
+ signal.throwIfAborted();
22854
+ const evaluation = promisify(execFile)(
22785
22855
  process.execPath,
22786
22856
  [
22787
22857
  "--input-type=module",
@@ -22796,9 +22866,21 @@ async function createDefinitionEmission(source, recipe) {
22796
22866
  timeout: 3e4,
22797
22867
  signal
22798
22868
  }
22799
- ).catch((cause) => {
22800
- throw evaluationFailure(cause);
22869
+ );
22870
+ const closed = new Promise((resolve6) => {
22871
+ evaluation.child.once("close", () => {
22872
+ resolve6();
22873
+ });
22801
22874
  });
22875
+ let result2;
22876
+ try {
22877
+ result2 = await evaluation.catch((cause) => {
22878
+ signal.throwIfAborted();
22879
+ throw evaluationFailure(cause);
22880
+ });
22881
+ } finally {
22882
+ await closed;
22883
+ }
22802
22884
  return decodeUnknownSync(
22803
22885
  fromJsonString2(appDeclarationSchema),
22804
22886
  { onExcessProperty: "error" }
@@ -32339,7 +32421,7 @@ async function readBundledHtml(snapshot, recipe) {
32339
32421
  // src/build/local-build.ts
32340
32422
  import { createHash as createHash3, randomBytes } from "node:crypto";
32341
32423
  import { spawn } from "node:child_process";
32342
- import { createReadStream, mkdtempSync, realpathSync } from "node:fs";
32424
+ import { createReadStream, mkdtempSync, realpathSync, rmSync } from "node:fs";
32343
32425
  import {
32344
32426
  access as access3,
32345
32427
  cp,
@@ -32361,7 +32443,6 @@ import {
32361
32443
  sep as sep4
32362
32444
  } from "node:path";
32363
32445
  import { pipeline } from "node:stream/promises";
32364
- import { setTimeout as delay2 } from "node:timers/promises";
32365
32446
  import * as esbuild from "esbuild";
32366
32447
 
32367
32448
  // ../../node_modules/.pnpm/@pnpm+crypto.hash@1100.0.8/node_modules/@pnpm/crypto.hash/lib/index.js
@@ -35430,15 +35511,6 @@ function repositoryEnvironment() {
35430
35511
  }
35431
35512
 
35432
35513
  // src/build/local-build.ts
35433
- function logEvent(operation, cause) {
35434
- console.error(
35435
- JSON.stringify({
35436
- source: "app-publisher",
35437
- operation,
35438
- failureKind: cause instanceof Error ? "Error" : "NonErrorThrown"
35439
- })
35440
- );
35441
- }
35442
35514
  var localConfigSchema = Struct({
35443
35515
  appId: appIdSchema,
35444
35516
  source: Struct({
@@ -35456,15 +35528,27 @@ async function sha256File(path, signal) {
35456
35528
  await pipeline(createReadStream(path), hash2, { signal });
35457
35529
  return parseSha256Digest(`sha256:${hash2.digest("hex")}`);
35458
35530
  }
35459
- function runGit(args2, cwd, signal, environment = repositoryEnvironment()) {
35460
- return new Promise((resolve6, reject) => {
35461
- const child = spawn("git", [...args2], {
35462
- cwd,
35463
- env: environment,
35464
- shell: false,
35465
- signal,
35466
- stdio: ["ignore", "pipe", "pipe"]
35467
- });
35531
+ var GitCommandError = class extends Error {
35532
+ constructor(message, exitCode) {
35533
+ super(message);
35534
+ this.exitCode = exitCode;
35535
+ }
35536
+ exitCode;
35537
+ };
35538
+ async function runGit(args2, cwd, signal, environment = repositoryEnvironment()) {
35539
+ signal.throwIfAborted();
35540
+ const child = spawn("git", [...args2], {
35541
+ cwd,
35542
+ env: environment,
35543
+ shell: false,
35544
+ detached: process.platform !== "win32",
35545
+ signal,
35546
+ stdio: ["ignore", "pipe", "pipe"]
35547
+ });
35548
+ let stopping;
35549
+ const stop = () => stopping ??= stopProcessGroup(child);
35550
+ let listener;
35551
+ const completion = new Promise((resolve6, reject) => {
35468
35552
  const stdout = [];
35469
35553
  const stderr = [];
35470
35554
  let spawnError;
@@ -35480,12 +35564,22 @@ function runGit(args2, cwd, signal, environment = repositoryEnvironment()) {
35480
35564
  }
35481
35565
  const detail = Buffer2.concat(stderr).toString("utf8").trim();
35482
35566
  reject(
35483
- spawnError ?? new Error(
35484
- detail.length > 0 ? `git exited unsuccessfully: ${detail}` : `git exited unsuccessfully (${String(code)} ${String(terminationSignal)})`
35567
+ spawnError ?? new GitCommandError(
35568
+ detail.length > 0 ? `git exited unsuccessfully: ${detail}` : `git exited unsuccessfully (${String(code)} ${String(terminationSignal)})`,
35569
+ code
35485
35570
  )
35486
35571
  );
35487
35572
  });
35573
+ listener = addAbortListener(signal, () => {
35574
+ void stop().catch(reject);
35575
+ });
35488
35576
  });
35577
+ try {
35578
+ return await completion;
35579
+ } finally {
35580
+ listener?.[Symbol.dispose]();
35581
+ await stop();
35582
+ }
35489
35583
  }
35490
35584
  function extractTar(archivePath, destination, signal) {
35491
35585
  return new Promise((resolve6, reject) => {
@@ -35606,27 +35700,52 @@ async function captureCommit(workdir, repositoryPath2, sourceRevision, signal) {
35606
35700
  function scopedSourceCapture(capture, failureMessage) {
35607
35701
  return {
35608
35702
  capture: () => acquireRelease2(
35609
- sync2(
35610
- () => (
35611
- // Canonical, so every path derived from the scratch matches the
35612
- // realpaths pnpm reports (macOS tmpdir is a symlink).
35613
- realpathSync(mkdtempSync(join5(tmpdir(), "app-publisher-")))
35614
- )
35615
- ),
35616
- (workdir) => tryPromise2({
35617
- try: () => rm(workdir, { recursive: true, force: true }),
35618
- catch: () => new Error("Local source cleanup failed")
35619
- }).pipe(
35620
- catch_2((cause) => {
35621
- logEvent("services/app-publisher/src/local.ts:289", cause);
35622
- return void_3;
35623
- })
35624
- )
35703
+ sync2(() => {
35704
+ const scratch = mkdtempSync(join5(tmpdir(), "app-publisher-"));
35705
+ try {
35706
+ return realpathSync(scratch);
35707
+ } catch (cause) {
35708
+ try {
35709
+ rmSync(scratch, { recursive: true, force: true });
35710
+ } catch (cleanupCause) {
35711
+ throw new CleanupError("Source snapshot cleanup failed", {
35712
+ cause: cleanupCause
35713
+ });
35714
+ }
35715
+ throw cause;
35716
+ }
35717
+ }),
35718
+ (workdir) => promise2(async () => {
35719
+ try {
35720
+ await rm(workdir, { recursive: true, force: true });
35721
+ } catch (cause) {
35722
+ throw new CleanupError("Source snapshot cleanup failed", {
35723
+ cause
35724
+ });
35725
+ }
35726
+ })
35625
35727
  ).pipe(
35626
35728
  flatMap2(
35627
- (workdir) => tryPromise2({
35628
- try: (signal) => capture(workdir, signal),
35629
- catch: () => new Error(failureMessage)
35729
+ (workdir) => callback2((resume, signal) => {
35730
+ const pending = capture(workdir, signal);
35731
+ pending.then(
35732
+ (source) => {
35733
+ resume(succeed5(source));
35734
+ },
35735
+ (cause) => {
35736
+ resume(
35737
+ cause instanceof CleanupError ? die3(cause) : fail5(new Error(failureMessage))
35738
+ );
35739
+ }
35740
+ );
35741
+ return promise2(
35742
+ () => pending.then(
35743
+ () => void 0,
35744
+ (cause) => {
35745
+ if (cause instanceof CleanupError) throw cause;
35746
+ }
35747
+ )
35748
+ );
35630
35749
  })
35631
35750
  )
35632
35751
  )
@@ -35661,35 +35780,6 @@ function capturedWorkspaceBuild(snapshot, entry, run2, backendEntry) {
35661
35780
  })
35662
35781
  );
35663
35782
  }
35664
- function htmlGroupExists(child) {
35665
- if (child.pid === void 0) return false;
35666
- try {
35667
- process.kill(-child.pid, 0);
35668
- return true;
35669
- } catch (error2) {
35670
- if (error2 instanceof Error && "code" in error2 && error2.code === "ESRCH")
35671
- return false;
35672
- throw error2;
35673
- }
35674
- }
35675
- async function stopHtmlGroup(child) {
35676
- if (!htmlGroupExists(child)) return;
35677
- const deadline = Date.now() + 5e3;
35678
- for (const [signal, until] of [
35679
- ["SIGTERM", deadline - 1e3],
35680
- ["SIGKILL", deadline]
35681
- ]) {
35682
- try {
35683
- if (child.pid !== void 0) process.kill(-child.pid, signal);
35684
- } catch (error2) {
35685
- if (!(error2 instanceof Error && "code" in error2 && error2.code === "ESRCH"))
35686
- throw error2;
35687
- }
35688
- while (htmlGroupExists(child) && Date.now() < until) await delay2(25);
35689
- if (!htmlGroupExists(child)) return;
35690
- }
35691
- throw new Error("HTML process group survived its five-second cleanup bound");
35692
- }
35693
35783
  function runHtmlCommand(args2, cwd, env, command = "pnpm", onOutput) {
35694
35784
  return acquireUseRelease2(
35695
35785
  sync2(() => {
@@ -35730,7 +35820,7 @@ function runHtmlCommand(args2, cwd, env, command = "pnpm", onOutput) {
35730
35820
  return { child, completion };
35731
35821
  }),
35732
35822
  ({ completion }) => tryPromise2({ try: () => completion, catch: (error2) => error2 }),
35733
- ({ child }) => promise2(() => stopHtmlGroup(child))
35823
+ ({ child }) => promise2(() => stopProcessGroup(child))
35734
35824
  );
35735
35825
  }
35736
35826
  function snapshotPrograms() {
@@ -35788,14 +35878,16 @@ function rebuildViteSnapshot(sourceSnapshotPath, recipe, options) {
35788
35878
  const appDirectory = join5(sourceSnapshotPath, html.directory);
35789
35879
  const dependencies = join5(appDirectory, ".publisher-dependencies.mjs");
35790
35880
  const program = join5(appDirectory, ".publisher-build.mjs");
35791
- yield* tryPromise2({
35792
- try: async () => {
35793
- const { dependencyBuildProgram: dependencyBuildProgram2, htmlBuildProgram: htmlBuildProgram2 } = await snapshotPrograms();
35794
- await writeFile2(dependencies, dependencyBuildProgram2, { flag: "wx" });
35795
- await writeFile2(program, htmlBuildProgram2, { flag: "wx" });
35796
- },
35797
- catch: (error2) => error2
35798
- });
35881
+ yield* uninterruptible2(
35882
+ tryPromise2({
35883
+ try: async () => {
35884
+ const { dependencyBuildProgram: dependencyBuildProgram2, htmlBuildProgram: htmlBuildProgram2 } = await snapshotPrograms();
35885
+ await writeFile2(dependencies, dependencyBuildProgram2, { flag: "wx" });
35886
+ await writeFile2(program, htmlBuildProgram2, { flag: "wx" });
35887
+ },
35888
+ catch: (error2) => error2
35889
+ })
35890
+ );
35799
35891
  const groups = [];
35800
35892
  for (const step of html.steps) {
35801
35893
  const last = groups.at(-1);
@@ -35981,11 +36073,13 @@ function rebuildNpmSnapshot(sourceSnapshotPath, recipe, options) {
35981
36073
  const globalConfig2 = join5(home, "global.npmrc");
35982
36074
  env.npm_config_userconfig = userConfig;
35983
36075
  env.npm_config_globalconfig = globalConfig2;
35984
- yield* tryPromise2(async () => {
35985
- await mkdir(home, { recursive: true });
35986
- await writeFile2(userConfig, "", { flag: "wx" });
35987
- await writeFile2(globalConfig2, "", { flag: "wx" });
35988
- });
36076
+ yield* uninterruptible2(
36077
+ tryPromise2(async () => {
36078
+ await mkdir(home, { recursive: true });
36079
+ await writeFile2(userConfig, "", { flag: "wx" });
36080
+ await writeFile2(globalConfig2, "", { flag: "wx" });
36081
+ })
36082
+ );
35989
36083
  if ((yield* runHtmlCommand(
35990
36084
  ["--version"],
35991
36085
  sourceSnapshotPath,
@@ -36004,10 +36098,12 @@ function rebuildNpmSnapshot(sourceSnapshotPath, recipe, options) {
36004
36098
  options.onOutput
36005
36099
  );
36006
36100
  const program = join5(sourceSnapshotPath, ".publisher-build.mjs");
36007
- yield* tryPromise2(async () => {
36008
- const { htmlBuildProgram: htmlBuildProgram2 } = await snapshotPrograms();
36009
- await writeFile2(program, htmlBuildProgram2, { flag: "wx" });
36010
- });
36101
+ yield* uninterruptible2(
36102
+ tryPromise2(async () => {
36103
+ const { htmlBuildProgram: htmlBuildProgram2 } = await snapshotPrograms();
36104
+ await writeFile2(program, htmlBuildProgram2, { flag: "wx" });
36105
+ })
36106
+ );
36011
36107
  yield* runHtmlCommand(
36012
36108
  [
36013
36109
  program,
@@ -36234,15 +36330,15 @@ function createLocalBuildExecutor(options = {}) {
36234
36330
  ),
36235
36331
  catch: (error2) => error2 instanceof Error ? error2 : new Error("Local snapshot build failed")
36236
36332
  }),
36237
- ({ context: context3 }) => tryPromise2({
36238
- try: () => context3.dispose(),
36239
- catch: () => new Error("Local build cleanup failed")
36240
- }).pipe(
36241
- catch_2((cause) => {
36242
- logEvent("services/app-publisher/src/local.ts:1262", cause);
36243
- return void_3;
36244
- })
36245
- )
36333
+ ({ context: context3 }) => promise2(async () => {
36334
+ try {
36335
+ await context3.dispose();
36336
+ } catch (cause) {
36337
+ throw new CleanupError("Local compiler cleanup failed", {
36338
+ cause
36339
+ });
36340
+ }
36341
+ })
36246
36342
  );
36247
36343
  }
36248
36344
  };
@@ -36259,10 +36355,29 @@ function createLocalBuildExecutor(options = {}) {
36259
36355
  });
36260
36356
  emissions.set(source, emission);
36261
36357
  const output = yield* compiler2.build(source, recipe);
36262
- const declaration3 = yield* tryPromise2({
36263
- try: (signal) => emission.declare(signal),
36264
- catch: (cause) => cause instanceof Error ? cause : new Error("App declaration emission failed", { cause })
36265
- });
36358
+ const declaration3 = yield* callback2(
36359
+ (resume, signal) => {
36360
+ const pending = emission.declare(signal);
36361
+ pending.then(
36362
+ (value) => {
36363
+ resume(succeed5(value));
36364
+ },
36365
+ (cause) => {
36366
+ resume(
36367
+ fail5(
36368
+ cause instanceof Error ? cause : new Error("App declaration emission failed", { cause })
36369
+ )
36370
+ );
36371
+ }
36372
+ );
36373
+ return promise2(
36374
+ () => pending.then(
36375
+ () => void 0,
36376
+ () => void 0
36377
+ )
36378
+ );
36379
+ }
36380
+ );
36266
36381
  declarations.set(source, declaration3);
36267
36382
  return output;
36268
36383
  }),