peachsim 0.1.1641 → 0.1.1644

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 (96) hide show
  1. package/cli/app-bundle-resources.ts +57 -0
  2. package/cli/commands/control.ts +12 -0
  3. package/cli/drivers/playwright.ts +39 -0
  4. package/cli/outbound-endpoints.ts +4 -2
  5. package/detox/motion-change.cjs +7 -5
  6. package/detox/motion-change.d.cts +1 -0
  7. package/detox/motion-leg-starts.cjs +20 -0
  8. package/detox/motion-leg-starts.d.cts +8 -0
  9. package/dist-lib/agent-daemon-client.cjs +1 -1
  10. package/dist-lib/agent-events.cjs +1 -1
  11. package/dist-lib/attached-projects.cjs +1 -1
  12. package/dist-lib/auth/shared-session.cjs +1 -1
  13. package/dist-lib/backend-origin.cjs +3 -3
  14. package/dist-lib/beta.cjs +1 -1
  15. package/dist-lib/beta.mjs +1 -1
  16. package/dist-lib/bridge-constants.cjs +1 -1
  17. package/dist-lib/bridge-contract-input.cjs +1 -1
  18. package/dist-lib/bridge-contract-input.mjs +1 -1
  19. package/dist-lib/bridge-contract.cjs +1 -1
  20. package/dist-lib/bridge-contract.mjs +1 -1
  21. package/dist-lib/bundle-channel.cjs +719 -572
  22. package/dist-lib/capture-contract.cjs +1 -1
  23. package/dist-lib/capture-contract.mjs +1 -1
  24. package/dist-lib/cloud-contract.cjs +1 -1
  25. package/dist-lib/cloud-contract.mjs +1 -1
  26. package/dist-lib/cloud-test-args.cjs +1 -1
  27. package/dist-lib/cloud-test-args.mjs +1 -1
  28. package/dist-lib/cloud.cjs +1 -1
  29. package/dist-lib/cloud.mjs +1 -1
  30. package/dist-lib/config.cjs +1 -1
  31. package/dist-lib/config.mjs +1 -1
  32. package/dist-lib/detox/index.cjs +7 -6
  33. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  34. package/dist-lib/expo-swift-bundle.cjs +656 -509
  35. package/dist-lib/expo-swift-metadata.cjs +1 -1
  36. package/dist-lib/expo-swift-metadata.mjs +1 -1
  37. package/dist-lib/home-paths.cjs +1 -1
  38. package/dist-lib/host/bridge-host.cjs +811 -658
  39. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  40. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  41. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  42. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  43. package/dist-lib/host/websocket-proxy.cjs +1 -1
  44. package/dist-lib/index.cjs +89 -41
  45. package/dist-lib/jump-to-source-babel.cjs +1 -1
  46. package/dist-lib/jump-to-source-native.cjs +1 -1
  47. package/dist-lib/kotlin-host.cjs +1 -1
  48. package/dist-lib/menu.cjs +14 -6
  49. package/dist-lib/menu.mjs +14 -6
  50. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  51. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  52. package/dist-lib/metro-production-bundle.cjs +1 -1
  53. package/dist-lib/metro-production-bundle.mjs +1 -1
  54. package/dist-lib/metro.cjs +88 -41
  55. package/dist-lib/native-app-identity-project.cjs +90 -41
  56. package/dist-lib/native-app-identity-project.mjs +89 -41
  57. package/dist-lib/native-app-identity.cjs +1 -1
  58. package/dist-lib/native-app-identity.mjs +1 -1
  59. package/dist-lib/native-firebase-metadata.cjs +1 -1
  60. package/dist-lib/native-firebase-metadata.mjs +1 -1
  61. package/dist-lib/plist.cjs +1 -1
  62. package/dist-lib/plist.mjs +1 -1
  63. package/dist-lib/profiles.cjs +1 -1
  64. package/dist-lib/public-brand.cjs +1 -1
  65. package/dist-lib/react-native-host-modules.cjs +1 -1
  66. package/dist-lib/react-native-host-modules.mjs +1 -1
  67. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  68. package/dist-lib/sdk.cjs +2 -1
  69. package/dist-lib/sdk.mjs +2 -1
  70. package/dist-lib/skills.cjs +1716 -1366
  71. package/dist-lib/swift-compile.cjs +297 -215
  72. package/dist-lib/swift-compile.mjs +315 -227
  73. package/dist-lib/swift-package.cjs +1 -1
  74. package/dist-lib/swift-package.mjs +1 -1
  75. package/dist-lib/swift-submit.cjs +1 -1
  76. package/dist-lib/swift-submit.mjs +1 -1
  77. package/dist-lib/swift-toolchain.cjs +1 -1
  78. package/dist-lib/swift.cjs +1 -1
  79. package/dist-lib/vite-swift.cjs +620 -473
  80. package/dist-lib/vite.cjs +1 -1
  81. package/dist-lib/worklet-executable.cjs +1 -1
  82. package/dist-lib/worklet-executable.mjs +1 -1
  83. package/package.json +1 -1
  84. package/src/appBundleResourcesContract.ts +51 -0
  85. package/src/backend-origin.ts +3 -1
  86. package/src/host/bridge-host.ts +17 -11
  87. package/src/host/staged-host-files.ts +28 -4
  88. package/src/launchMetadataContract.ts +1 -0
  89. package/src/menu.ts +12 -4
  90. package/src/native-app-identity-project.ts +47 -38
  91. package/src/runtime-delivery.ts +6 -7
  92. package/src/swift-compile.ts +18 -7
  93. package/src/swift-compiler-digest.ts +5 -3
  94. package/src/swift-objc-compile.ts +34 -4
  95. package/src/swift-root-lock.ts +241 -92
  96. package/src/xcode-project.ts +67 -4
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1641 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1644 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -8,8 +8,8 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
8
8
  var __getProtoOf = Object.getPrototypeOf;
9
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
10
10
  var __export = (target, all) => {
11
- for (var name in all)
12
- __defProp(target, name, { get: all[name], enumerable: true });
11
+ for (var name2 in all)
12
+ __defProp(target, name2, { get: all[name2], enumerable: true });
13
13
  };
14
14
  var __copyProps = (to, from, except, desc) => {
15
15
  if (from && typeof from === "object" || typeof from === "function") {
@@ -113,9 +113,9 @@ function cacheDir() {
113
113
  }
114
114
  function swiftPackageCacheOptions() {
115
115
  const root = import_node_path.default.join(cacheDir(), "swiftpm");
116
- return ["cache", "config", "security"].flatMap((name) => [
117
- `--${name}-path`,
118
- import_node_path.default.join(root, name)
116
+ return ["cache", "config", "security"].flatMap((name2) => [
117
+ `--${name2}-path`,
118
+ import_node_path.default.join(root, name2)
119
119
  ]);
120
120
  }
121
121
  var DAEMON_LOCKFILE_MAX_BYTES = 16 * 1024;
@@ -775,7 +775,7 @@ function designTimeDiagnostic(output, files) {
775
775
  const rewritten = /* @__PURE__ */ new Map();
776
776
  const linesOf = (path6) => {
777
777
  const file = Object.keys(files).find(
778
- (name) => name.endsWith(".swift") && (path6 === name || path6.endsWith(`/${name}`))
778
+ (name2) => name2.endsWith(".swift") && (path6 === name2 || path6.endsWith(`/${name2}`))
779
779
  );
780
780
  if (file === void 0) return null;
781
781
  let lines = rewritten.get(file);
@@ -935,7 +935,7 @@ async function load(toolchainBin, sdk) {
935
935
  icuSegment(archiveMember((0, import_node_fs2.readFileSync)(import_node_path4.default.join(resources, ARCHIVE)), MEMBER))
936
936
  );
937
937
  }
938
- function archiveMember(archive, name) {
938
+ function archiveMember(archive, name2) {
939
939
  if (archive.toString("latin1", 0, 8) !== "!<arch>\n")
940
940
  throw new Error("swift-icu: not an ar archive");
941
941
  let names = "";
@@ -945,10 +945,10 @@ function archiveMember(archive, name) {
945
945
  const body = archive.subarray(at + 60, at + 60 + size);
946
946
  if (raw2 === "//") names = body.toString("latin1");
947
947
  const member = /^\/\d+$/.test(raw2) ? names.slice(Number(raw2.slice(1)), names.indexOf("/\n", Number(raw2.slice(1)))) : raw2.replace(/\/$/, "");
948
- if (member === name) return body;
948
+ if (member === name2) return body;
949
949
  at += 60 + size + size % 2;
950
950
  }
951
- throw new Error(`swift-icu: ${name} is not in the sdk's icu archive`);
951
+ throw new Error(`swift-icu: ${name2} is not in the sdk's icu archive`);
952
952
  }
953
953
  function icuSegment(object) {
954
954
  let at = 8;
@@ -1082,8 +1082,8 @@ function splitManifestArguments(source) {
1082
1082
  if (final) arguments_.push(final);
1083
1083
  return arguments_;
1084
1084
  }
1085
- function swiftTargetModuleName(name) {
1086
- return name.replace(/[^A-Za-z0-9_]/g, "_").replace(/^[0-9]/, "_");
1085
+ function swiftTargetModuleName(name2) {
1086
+ return name2.replace(/[^A-Za-z0-9_]/g, "_").replace(/^[0-9]/, "_");
1087
1087
  }
1088
1088
  function swiftManifestTargets(manifest, resourcePaths = []) {
1089
1089
  const implicitResources = swiftImplicitResourcePaths(resourcePaths);
@@ -1095,16 +1095,16 @@ function swiftManifestTargets(manifest, resourcePaths = []) {
1095
1095
  ]);
1096
1096
  const targetNames = new Set(
1097
1097
  declarations.flatMap(({ flat }) => {
1098
- const name = /\bname\s*:\s*"([^"]+)"/.exec(flat)?.[1];
1099
- return name ? [name] : [];
1098
+ const name2 = /\bname\s*:\s*"([^"]+)"/.exec(flat)?.[1];
1099
+ return name2 ? [name2] : [];
1100
1100
  })
1101
1101
  );
1102
1102
  for (const { kind, flat, call } of declarations) {
1103
1103
  const executable = kind === "executableTarget";
1104
- const name = /\bname\s*:\s*"([^"]+)"/.exec(flat)?.[1];
1105
- if (!name) continue;
1104
+ const name2 = /\bname\s*:\s*"([^"]+)"/.exec(flat)?.[1];
1105
+ if (!name2) continue;
1106
1106
  const rawPath = /\bpath\s*:\s*"([^"]*)"/.exec(flat)?.[1];
1107
- const targetPath = rawPath == null || rawPath === "" ? `Sources/${name}` : rawPath.replace(/^\.\//, "").replace(/\/+$/, "");
1107
+ const targetPath = rawPath == null || rawPath === "" ? `Sources/${name2}` : rawPath.replace(/^\.\//, "").replace(/\/+$/, "");
1108
1108
  const languageMode = Number(
1109
1109
  /\.swiftLanguageMode\(\s*\.v(\d+)\s*\)/.exec(call)?.[1] ?? "5"
1110
1110
  );
@@ -1144,12 +1144,12 @@ function swiftManifestTargets(manifest, resourcePaths = []) {
1144
1144
  dependencyNames.add(dependencyName);
1145
1145
  }
1146
1146
  }
1147
- const dependencies = [...dependencyNames].map((name2) => ({
1147
+ const dependencies = [...dependencyNames].map((name3) => ({
1148
1148
  kind: "target",
1149
- name: name2
1149
+ name: name3
1150
1150
  }));
1151
1151
  targets.push({
1152
- name,
1152
+ name: name2,
1153
1153
  path: targetPath,
1154
1154
  executable,
1155
1155
  ...kind === "systemLibrary" ? { systemLibrary: true } : {},
@@ -1182,38 +1182,55 @@ var import_node_crypto2 = require("node:crypto");
1182
1182
  var import_node_fs3 = require("node:fs");
1183
1183
  var import_node_path5 = __toESM(require("node:path"), 1);
1184
1184
  var POLL_MS = 250;
1185
- function processStart(pid) {
1186
- try {
1187
- return (0, import_node_child_process4.execFileSync)("ps", ["-o", "lstart=", "-p", String(pid)], {
1188
- encoding: "utf8",
1189
- stdio: ["ignore", "pipe", "ignore"]
1190
- }).trim() || null;
1191
- } catch {
1192
- return null;
1193
- }
1185
+ var START_TOLERANCE_MS = 2e3;
1186
+ function errorCode(error) {
1187
+ return error instanceof Error && "code" in error && typeof error.code === "string" ? error.code : void 0;
1194
1188
  }
1195
- function parseHolder(text2) {
1196
- try {
1197
- const value = JSON.parse(text2);
1198
- if (value && typeof value === "object" && "pid" in value && typeof value.pid === "number" && "start" in value && (typeof value.start === "string" || value.start === null))
1199
- return { pid: value.pid, start: value.start };
1200
- } catch {
1201
- }
1202
- return null;
1189
+ function parseStart(text2) {
1190
+ const start = Date.parse(`${text2} UTC`);
1191
+ if (Number.isNaN(start)) throw new Error(`unreadable process start time "${text2}"`);
1192
+ return start;
1203
1193
  }
1204
- function readLock(lock) {
1205
- try {
1206
- return (0, import_node_fs3.readFileSync)(lock, "utf8");
1207
- } catch (error) {
1208
- if (error instanceof Error && "code" in error && error.code === "ENOENT") return null;
1209
- throw error;
1194
+ function processTable() {
1195
+ const result = (0, import_node_child_process4.spawnSync)("ps", ["-A", "-o", "pid=,pgid=,stat=,lstart="], {
1196
+ encoding: "utf8",
1197
+ env: { ...process.env, LC_ALL: "C", TZ: "UTC" },
1198
+ stdio: ["ignore", "pipe", "pipe"],
1199
+ timeout: 1e4,
1200
+ killSignal: "SIGKILL"
1201
+ });
1202
+ if (result.error || result.status !== 0) {
1203
+ throw new Error(
1204
+ `swift root lock cannot read the process table: ${result.error?.message || result.stderr.trim() || `ps exited ${result.status}`}`
1205
+ );
1210
1206
  }
1207
+ return result.stdout.split("\n").filter((line) => line.trim()).map((line) => {
1208
+ const match = /^\s*(\d+)\s+(\d+)\s+(\S+)\s+(.+?)\s*$/.exec(line);
1209
+ if (!match)
1210
+ throw new Error(`swift root lock cannot parse a process table row: ${line}`);
1211
+ return {
1212
+ pid: Number(match[1]),
1213
+ pgid: Number(match[2]),
1214
+ zombie: match[3].startsWith("Z"),
1215
+ start: parseStart(match[4])
1216
+ };
1217
+ });
1218
+ }
1219
+ function sameProcess(row, identity) {
1220
+ return row.pid === identity.pid && Math.abs(row.start - identity.start) <= START_TOLERANCE_MS;
1211
1221
  }
1212
- function holderAlive(text2) {
1213
- const holder = parseHolder(text2);
1214
- if (!holder) return false;
1215
- const start = processStart(holder.pid);
1216
- return start !== null && start === holder.start;
1222
+ function ownIdentity(pid) {
1223
+ const row = processTable().find(
1224
+ (candidate) => candidate.pid === pid && !candidate.zombie
1225
+ );
1226
+ if (!row) throw new Error(`swift root lock cannot find process ${pid}`);
1227
+ return { pid, start: row.start };
1228
+ }
1229
+ function parseIdentity(text2) {
1230
+ const value = JSON.parse(text2);
1231
+ if (value && typeof value === "object" && "pid" in value && typeof value.pid === "number" && "start" in value && typeof value.start === "number")
1232
+ return { pid: value.pid, start: value.start };
1233
+ throw new Error(`swift root lock record is not a process identity: ${text2}`);
1217
1234
  }
1218
1235
  function pause(ms, signal) {
1219
1236
  return new Promise((resolve) => {
@@ -1226,64 +1243,127 @@ function pause(ms, signal) {
1226
1243
  signal?.addEventListener("abort", done, { once: true });
1227
1244
  });
1228
1245
  }
1246
+ var name = (number, suffix) => `${String(number).padStart(12, "0")}.${suffix}`;
1247
+ function generationNumbers(directory) {
1248
+ const numbers = /* @__PURE__ */ new Set();
1249
+ for (const entry of (0, import_node_fs3.readdirSync)(directory)) {
1250
+ const match = /^(\d{12})\./.exec(entry);
1251
+ if (match) numbers.add(Number(match[1]));
1252
+ }
1253
+ return [...numbers].sort((a, b) => a - b);
1254
+ }
1255
+ function readGeneration(directory, number) {
1256
+ let owner;
1257
+ try {
1258
+ owner = (0, import_node_fs3.readFileSync)(import_node_path5.default.join(directory, name(number, "owner")), "utf8");
1259
+ } catch (error) {
1260
+ if (errorCode(error) === "ENOENT") return null;
1261
+ throw error;
1262
+ }
1263
+ return {
1264
+ number,
1265
+ holder: parseIdentity(owner),
1266
+ released: (0, import_node_fs3.readdirSync)(directory).includes(name(number, "released"))
1267
+ };
1268
+ }
1269
+ function readChildren(directory, number) {
1270
+ const prefix = name(number, "child.");
1271
+ return (0, import_node_fs3.readdirSync)(directory).filter((entry) => entry.startsWith(prefix)).map((entry) => parseIdentity((0, import_node_fs3.readFileSync)(import_node_path5.default.join(directory, entry), "utf8")));
1272
+ }
1273
+ function groupAlive(table, leader) {
1274
+ const row = table.find((candidate) => candidate.pid === leader.pid);
1275
+ if (row && !sameProcess(row, leader)) return false;
1276
+ return table.some((candidate) => candidate.pgid === leader.pid && !candidate.zombie);
1277
+ }
1229
1278
  async function withSwiftRootLock(root, work, signal) {
1230
- const directory = import_node_path5.default.join(rnxHomeDir(), "cache", "swift-root-locks");
1231
- (0, import_node_fs3.mkdirSync)(directory, { recursive: true });
1232
- const lock = import_node_path5.default.join(
1233
- directory,
1234
- `${(0, import_node_crypto2.createHash)("sha256").update(root).digest("hex").slice(0, 32)}.lock`
1279
+ const directory = import_node_path5.default.join(
1280
+ rnxHomeDir(),
1281
+ "cache",
1282
+ "swift-root-locks",
1283
+ (0, import_node_crypto2.createHash)("sha256").update(root).digest("hex").slice(0, 32)
1235
1284
  );
1285
+ (0, import_node_fs3.mkdirSync)(directory, { recursive: true });
1236
1286
  const token = (0, import_node_crypto2.randomUUID)();
1237
- const owner = JSON.stringify({
1238
- pid: process.pid,
1239
- start: processStart(process.pid),
1240
- token
1241
- });
1242
- const pending = `${lock}.${token}`;
1243
- (0, import_node_fs3.writeFileSync)(pending, owner);
1244
- try {
1245
- for (; ; ) {
1246
- signal?.throwIfAborted();
1247
- try {
1248
- (0, import_node_fs3.linkSync)(pending, lock);
1249
- break;
1250
- } catch (error) {
1251
- if (!(error instanceof Error && "code" in error && error.code === "EEXIST"))
1252
- throw error;
1287
+ const owner = JSON.stringify(ownIdentity(process.pid));
1288
+ const pending = import_node_path5.default.join(directory, `pending.${token}`);
1289
+ let held = 0;
1290
+ for (; ; ) {
1291
+ signal?.throwIfAborted();
1292
+ const newest = generationNumbers(directory).at(-1) ?? 0;
1293
+ const current = newest > 0 ? readGeneration(directory, newest) : null;
1294
+ if (newest > 0 && !current) continue;
1295
+ if (current && !current.released) {
1296
+ const table = processTable();
1297
+ if (table.some((row) => !row.zombie && sameProcess(row, current.holder))) {
1298
+ await pause(POLL_MS, signal);
1299
+ continue;
1253
1300
  }
1254
- const held = readLock(lock);
1255
- if (held === null) continue;
1256
- if (holderAlive(held)) {
1301
+ const children2 = readChildren(directory, newest);
1302
+ if (children2.some((child) => groupAlive(table, child))) {
1257
1303
  await pause(POLL_MS, signal);
1258
1304
  continue;
1259
1305
  }
1260
- const dead = `${lock}.dead-${token}`;
1261
- try {
1262
- (0, import_node_fs3.renameSync)(lock, dead);
1263
- } catch (error) {
1264
- if (error instanceof Error && "code" in error && error.code === "ENOENT") continue;
1265
- throw error;
1306
+ }
1307
+ (0, import_node_fs3.writeFileSync)(pending, owner);
1308
+ try {
1309
+ (0, import_node_fs3.linkSync)(pending, import_node_path5.default.join(directory, name(newest + 1, "owner")));
1310
+ } catch (error) {
1311
+ if (errorCode(error) === "EEXIST") continue;
1312
+ throw error;
1313
+ } finally {
1314
+ (0, import_node_fs3.rmSync)(pending, { force: true });
1315
+ }
1316
+ const numbers = generationNumbers(directory);
1317
+ if (numbers.at(-1) !== newest + 1) {
1318
+ (0, import_node_fs3.rmSync)(import_node_path5.default.join(directory, name(newest + 1, "owner")), { force: true });
1319
+ continue;
1320
+ }
1321
+ held = newest + 1;
1322
+ for (const number of numbers)
1323
+ if (number < held) {
1324
+ for (const entry of (0, import_node_fs3.readdirSync)(directory))
1325
+ if (entry.startsWith(name(number, "")))
1326
+ (0, import_node_fs3.rmSync)(import_node_path5.default.join(directory, entry), { force: true });
1266
1327
  }
1328
+ break;
1329
+ }
1330
+ const children = [];
1331
+ const lease = {
1332
+ spawn(command, args, options) {
1333
+ const child = (0, import_node_child_process4.spawn)(
1334
+ "/bin/sh",
1335
+ ["-c", 'IFS= read -r go || exit 1; exec "$@" </dev/null', "sh", command, ...args],
1336
+ { ...options, detached: true, stdio: ["pipe", "pipe", "pipe"] }
1337
+ );
1338
+ child.stdin.on("error", () => {
1339
+ });
1340
+ children.push(child);
1267
1341
  try {
1268
- if (readLock(dead) !== held) {
1269
- try {
1270
- (0, import_node_fs3.linkSync)(dead, lock);
1271
- } catch (error) {
1272
- if (!(error instanceof Error && "code" in error && error.code === "EEXIST"))
1273
- throw error;
1274
- }
1342
+ if (child.pid === void 0) {
1343
+ child.once("error", () => {
1344
+ });
1345
+ throw new Error(`could not start ${command}`);
1346
+ }
1347
+ const childPending = `${pending}.child.${child.pid}`;
1348
+ try {
1349
+ (0, import_node_fs3.writeFileSync)(childPending, JSON.stringify(ownIdentity(child.pid)));
1350
+ (0, import_node_fs3.linkSync)(childPending, import_node_path5.default.join(directory, name(held, `child.${child.pid}`)));
1351
+ } finally {
1352
+ (0, import_node_fs3.rmSync)(childPending, { force: true });
1275
1353
  }
1276
- } finally {
1277
- (0, import_node_fs3.rmSync)(dead, { force: true });
1354
+ } catch (error) {
1355
+ child.stdin.destroy();
1356
+ throw error;
1278
1357
  }
1358
+ child.stdin.end("go\n");
1359
+ return child;
1279
1360
  }
1280
- } finally {
1281
- (0, import_node_fs3.rmSync)(pending, { force: true });
1282
- }
1361
+ };
1283
1362
  try {
1284
- return await work();
1363
+ return await work(lease);
1285
1364
  } finally {
1286
- if (readLock(lock) === owner) (0, import_node_fs3.rmSync)(lock, { force: true });
1365
+ await Promise.all(children.map((child) => terminateProcessGroup(child, "SIGKILL", 0)));
1366
+ (0, import_node_fs3.writeFileSync)(import_node_path5.default.join(directory, name(held, "released")), "");
1287
1367
  }
1288
1368
  }
1289
1369
 
@@ -1304,12 +1384,13 @@ function isSwiftResourceBundles(value) {
1304
1384
  async function runCompiler(command, args, options, stream = false, quiet) {
1305
1385
  const { signal } = options;
1306
1386
  signal?.throwIfAborted();
1307
- const child = (0, import_node_child_process5.spawn)(command, args, {
1387
+ const launch = {
1308
1388
  cwd: options.cwd,
1309
1389
  env: swiftEnvironment(options.env),
1310
1390
  detached: true,
1311
1391
  stdio: ["ignore", "pipe", "pipe"]
1312
- });
1392
+ };
1393
+ const child = options.lease ? options.lease.spawn(command, args, launch) : (0, import_node_child_process5.spawn)(command, args, launch);
1313
1394
  let stopping;
1314
1395
  try {
1315
1396
  await new Promise((resolve, reject) => {
@@ -1323,20 +1404,20 @@ async function runCompiler(command, args, options, stream = false, quiet) {
1323
1404
  void stopping.catch(() => {
1324
1405
  });
1325
1406
  };
1326
- for (const name of ["stdout", "stderr"]) {
1327
- child[name].on("data", (bytes) => {
1328
- if (stream === true) process[name].write(bytes);
1407
+ for (const name2 of ["stdout", "stderr"]) {
1408
+ child[name2].on("data", (bytes) => {
1409
+ if (stream === true) process[name2].write(bytes);
1329
1410
  else if (stream) {
1330
- const lines = (partial[name] + bytes.toString()).split("\n");
1331
- partial[name] = lines.pop();
1411
+ const lines = (partial[name2] + bytes.toString()).split("\n");
1412
+ partial[name2] = lines.pop();
1332
1413
  for (const line of lines)
1333
- if (stream.test(line)) process[name].write(`${line}
1414
+ if (stream.test(line)) process[name2].write(`${line}
1334
1415
  `);
1335
1416
  }
1336
- sizes[name] += bytes.length;
1337
- if (sizes[name] <= (options.maxBuffer ?? 1024 * 1024)) chunks[name].push(bytes);
1417
+ sizes[name2] += bytes.length;
1418
+ if (sizes[name2] <= (options.maxBuffer ?? 1024 * 1024)) chunks[name2].push(bytes);
1338
1419
  else {
1339
- failure = new Error(`Swift compiler ${name} exceeded its output limit`);
1420
+ failure = new Error(`Swift compiler ${name2} exceeded its output limit`);
1340
1421
  stop();
1341
1422
  }
1342
1423
  });
@@ -1364,9 +1445,9 @@ async function runCompiler(command, args, options, stream = false, quiet) {
1364
1445
  );
1365
1446
  else {
1366
1447
  if (quiet) {
1367
- for (const name of ["stdout", "stderr"])
1368
- for (const line of Buffer.concat(chunks[name]).toString().split("\n"))
1369
- if (line && !quiet.test(line)) process[name].write(`${line}
1448
+ for (const name2 of ["stdout", "stderr"])
1449
+ for (const line of Buffer.concat(chunks[name2]).toString().split("\n"))
1450
+ if (line && !quiet.test(line)) process[name2].write(`${line}
1370
1451
  `);
1371
1452
  }
1372
1453
  resolve();
@@ -1611,11 +1692,11 @@ function swiftCondition(text2, available) {
1611
1692
  if (token === "false") return false;
1612
1693
  const call = /^(\w+)\s*\(\s*([^,()]*?)\s*(?:,[^()]*)?\)$/.exec(token ?? "");
1613
1694
  if (!call) return void 0;
1614
- const [, name, argument] = call;
1615
- if (name === "os") return argument === "iOS" || argument === "WASI";
1616
- if (name === "canImport") return available.has(argument);
1617
- if (name === "targetEnvironment") return false;
1618
- if (name === "arch") return argument === "wasm32";
1695
+ const [, name2, argument] = call;
1696
+ if (name2 === "os") return argument === "iOS" || argument === "WASI";
1697
+ if (name2 === "canImport") return available.has(argument);
1698
+ if (name2 === "targetEnvironment") return false;
1699
+ if (name2 === "arch") return argument === "wasm32";
1619
1700
  return void 0;
1620
1701
  };
1621
1702
  const both = () => {
@@ -1659,8 +1740,8 @@ function swiftImportNames(contents, available) {
1659
1740
  continue;
1660
1741
  }
1661
1742
  if (available && frames.some((frame) => frame.active !== true)) continue;
1662
- const name = SWIFT_IMPORT.exec(line)?.[1];
1663
- if (name) names.push(name);
1743
+ const name2 = SWIFT_IMPORT.exec(line)?.[1];
1744
+ if (name2) names.push(name2);
1664
1745
  }
1665
1746
  return names;
1666
1747
  }
@@ -1690,9 +1771,9 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
1690
1771
  ],
1691
1772
  { encoding: "utf8", env: swiftEnvironment(), stdio: ["ignore", "pipe", "pipe"] }
1692
1773
  );
1693
- const field = (name) => {
1694
- const value = new RegExp(`^${name}:\\s*(.+)$`, "m").exec(configuration)?.[1]?.trim();
1695
- if (!value) throw new Error(`swift sdk ${sdk} reports no ${name}`);
1774
+ const field = (name2) => {
1775
+ const value = new RegExp(`^${name2}:\\s*(.+)$`, "m").exec(configuration)?.[1]?.trim();
1776
+ if (!value) throw new Error(`swift sdk ${sdk} reports no ${name2}`);
1696
1777
  return value;
1697
1778
  };
1698
1779
  const paths = {
@@ -1727,9 +1808,9 @@ function missingSwiftModules(files, available) {
1727
1808
  const missing = /* @__PURE__ */ new Map();
1728
1809
  for (const [file, contents] of Object.entries(files)) {
1729
1810
  if (!file.endsWith(".swift") || file === "Package.swift") continue;
1730
- for (const name of new Set(swiftImportNames(contents, available))) {
1731
- if (available.has(name)) continue;
1732
- missing.set(name, [...missing.get(name) ?? [], file]);
1811
+ for (const name2 of new Set(swiftImportNames(contents, available))) {
1812
+ if (available.has(name2)) continue;
1813
+ missing.set(name2, [...missing.get(name2) ?? [], file]);
1733
1814
  }
1734
1815
  }
1735
1816
  return new Map([...missing].sort(([left], [right]) => left.localeCompare(right)));
@@ -1750,8 +1831,8 @@ function swiftTargetDependencies(files, targets) {
1750
1831
  (candidate) => candidate.name !== target.name && candidate.path !== "." && candidate.path.startsWith(prefix) && file.startsWith(`${candidate.path}/`)
1751
1832
  ))
1752
1833
  continue;
1753
- for (const name of swiftImportNames(contents)) {
1754
- if (names.has(name) && name !== target.name) deps.add(name);
1834
+ for (const name2 of swiftImportNames(contents)) {
1835
+ if (names.has(name2) && name2 !== target.name) deps.add(name2);
1755
1836
  }
1756
1837
  }
1757
1838
  siblings.set(target.name, [...deps].sort());
@@ -1781,7 +1862,7 @@ var EXECUTABLE_LINK_FLAGS = ` "-Xclang-linker", "-O0",
1781
1862
  `;
1782
1863
  var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
1783
1864
  var MULTI_MANIFEST_VERSION = 39;
1784
- var compilerSourceDigest = true ? "ee2738333bb81c79211d5bee8a503c539cf65f25c95fb024c45b840450b5359e" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
1865
+ var compilerSourceDigest = true ? "c2ab17198fbe6328c75dc09bbe160fe6b0fd74d4b84a08e9f8dfcd2fcf4ca1f0" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
1785
1866
  function swiftArtifactHash(input, release, moduleRoot) {
1786
1867
  const hash = (0, import_node_crypto3.createHash)("sha256");
1787
1868
  hash.update(`swift-compile
@@ -1807,10 +1888,10 @@ ${release}
1807
1888
  (0, import_node_crypto3.createHash)("sha256").update(input.resources?.[base] ?? "").digest()
1808
1889
  );
1809
1890
  }
1810
- for (const name of Object.keys(input.images ?? {}).sort()) {
1811
- const image = input.images?.[name];
1891
+ for (const name2 of Object.keys(input.images ?? {}).sort()) {
1892
+ const image = input.images?.[name2];
1812
1893
  if (!image) continue;
1813
- hash.update((0, import_node_crypto3.createHash)("sha256").update(name).digest());
1894
+ hash.update((0, import_node_crypto3.createHash)("sha256").update(name2).digest());
1814
1895
  hash.update((0, import_node_crypto3.createHash)("sha256").update(image.file).digest());
1815
1896
  hash.update((0, import_node_crypto3.createHash)("sha256").update(image.data).digest());
1816
1897
  }
@@ -1849,17 +1930,17 @@ ${target}
1849
1930
  function emitSwiftPackageManifest(args) {
1850
1931
  const { targets, siblings, moduleRoot, oneModule, spriteKit, distribution } = args;
1851
1932
  const reachedFrameworks = /* @__PURE__ */ new Set();
1852
- const reach = (name) => {
1853
- if (reachedFrameworks.has(name)) return;
1854
- reachedFrameworks.add(name);
1855
- for (const dependency of OPTIONAL_FRAMEWORK_DEPENDENCIES[name] ?? [])
1933
+ const reach = (name2) => {
1934
+ if (reachedFrameworks.has(name2)) return;
1935
+ reachedFrameworks.add(name2);
1936
+ for (const dependency of OPTIONAL_FRAMEWORK_DEPENDENCIES[name2] ?? [])
1856
1937
  reach(dependency);
1857
1938
  };
1858
- for (const name of [...siblings.values()].flat())
1859
- if (OPTIONAL_FRAMEWORKS.has(name) && !targets.some((target) => target.name === name))
1860
- reach(name);
1939
+ for (const name2 of [...siblings.values()].flat())
1940
+ if (OPTIONAL_FRAMEWORKS.has(name2) && !targets.some((target) => target.name === name2))
1941
+ reach(name2);
1861
1942
  if (spriteKit) {
1862
- for (const name of ["SpriteKit", "PeachBox2D", "simd", "GLKit"]) reach(name);
1943
+ for (const name2 of ["SpriteKit", "PeachBox2D", "simd", "GLKit"]) reach(name2);
1863
1944
  }
1864
1945
  const distributionLink = args.distributionLink;
1865
1946
  if (distribution && !distributionLink)
@@ -1869,7 +1950,7 @@ function emitSwiftPackageManifest(args) {
1869
1950
  if (distribution && distributionLink) {
1870
1951
  const objects = distribution.objects.filter(
1871
1952
  (object) => [...OPTIONAL_FRAMEWORKS, "SpriteKit", "PeachBox2D"].every(
1872
- (name) => !object.startsWith(`lib/${name}-`) || reachedFrameworks.has(name)
1953
+ (name2) => !object.startsWith(`lib/${name2}-`) || reachedFrameworks.has(name2)
1873
1954
  )
1874
1955
  );
1875
1956
  distributionLink.files.set(
@@ -1898,11 +1979,11 @@ function emitSwiftPackageManifest(args) {
1898
1979
  return ` .systemLibrary(name: ${JSON.stringify(target.name)}, path: ${JSON.stringify(target.path)}),`;
1899
1980
  const isolation = target.mainActorIsolation ? " .defaultIsolation(MainActor.self)," : "";
1900
1981
  const interoperability = target.cxxInterop ? " .interoperabilityMode(.Cxx)," : "";
1901
- const defines = (target.defines ?? []).map((name) => ` .define(${JSON.stringify(name)}),`).join("");
1982
+ const defines = (target.defines ?? []).map((name2) => ` .define(${JSON.stringify(name2)}),`).join("");
1902
1983
  const imports = distribution ? `, "-I", ${JSON.stringify(import_node_path6.default.join(moduleRoot, "modules"))}` : "";
1903
1984
  const native = args.native?.get(target.name);
1904
- const nativeImports = (siblings.get(target.name) ?? []).filter((name) => args.native?.has(name)).map(
1905
- (name) => `, "-Xfrontend", "-import-module", "-Xfrontend", ${JSON.stringify(swiftTargetModuleName(name))}`
1985
+ const nativeImports = (siblings.get(target.name) ?? []).filter((name2) => args.native?.has(name2)).map(
1986
+ (name2) => `, "-Xfrontend", "-import-module", "-Xfrontend", ${JSON.stringify(swiftTargetModuleName(name2))}`
1906
1987
  ).join("");
1907
1988
  const header = args.headerDirectory && [...args.native?.values() ?? []].some(
1908
1989
  (value) => value.late?.producers.includes(target.name)
@@ -1924,7 +2005,7 @@ function emitSwiftPackageManifest(args) {
1924
2005
  const library = distribution && distributionLink ? ["-Xclang-linker", `--config=${distributionLink.path}`, ...distribution.link].map((flag) => `, ${JSON.stringify(flag)}`).join("") : "";
1925
2006
  const kind = target.executable ? ".executableTarget" : ".target";
1926
2007
  const linkedLibraries = (target.linkedLibraries ?? []).map(
1927
- (name) => `.linkedLibrary(${JSON.stringify(name)})`
2008
+ (name2) => `.linkedLibrary(${JSON.stringify(name2)})`
1928
2009
  );
1929
2010
  const librarySettings = [
1930
2011
  ...linkedLibraries,
@@ -1963,9 +2044,9 @@ function emitSwiftPackageManifest(args) {
1963
2044
  " targets: [",
1964
2045
  ...targets.map(stanza),
1965
2046
  ...[...args.native?.entries() ?? []].flatMap(
1966
- ([name, native]) => native.late ? [
2047
+ ([name2, native]) => native.late ? [
1967
2048
  ` .target(name: ${JSON.stringify(native.late.name)},`,
1968
- ` dependencies: ${JSON.stringify([name, ...native.late.producers])},`,
2049
+ ` dependencies: ${JSON.stringify([name2, ...native.late.producers])},`,
1969
2050
  ` path: ${JSON.stringify(native.path)},`,
1970
2051
  ` sources: ${JSON.stringify(native.lateSources)},`,
1971
2052
  ` publicHeadersPath: "include",`,
@@ -2218,7 +2299,7 @@ function extensionOverrideEdits(source, extraObjCExtensions) {
2218
2299
  if (top?.kind !== "extension") continue;
2219
2300
  const func = OVERRIDE_FUNC.exec(rest);
2220
2301
  if (func) {
2221
- const name = func[2];
2302
+ const name2 = func[2];
2222
2303
  const open = at + func[0].length - 1;
2223
2304
  let depth = 0;
2224
2305
  let close = open;
@@ -2231,12 +2312,12 @@ function extensionOverrideEdits(source, extraObjCExtensions) {
2231
2312
  const clause = source.slice(close + 1, body).trim();
2232
2313
  const args = forwardedArguments(source.slice(open + 1, close));
2233
2314
  if (args === null) continue;
2234
- const call = (clause.includes("->") ? "return " : "") + (/\b(?:throws|rethrows)\b/.test(clause) ? "try " : "") + (/\basync\b/.test(clause) ? "await " : "") + `__peach_ext_${name}(${args})`;
2235
- const signature = `func ${name}${func[3] ?? ""}${source.slice(open, close + 1)}${clause ? ` ${clause}` : ""}`;
2236
- const nameAt = at + rest.indexOf(name, rest.indexOf("func", "override".length + func[1].length) + 4);
2315
+ const call = (clause.includes("->") ? "return " : "") + (/\b(?:throws|rethrows)\b/.test(clause) ? "try " : "") + (/\basync\b/.test(clause) ? "await " : "") + `__peach_ext_${name2}(${args})`;
2316
+ const signature = `func ${name2}${func[3] ?? ""}${source.slice(open, close + 1)}${clause ? ` ${clause}` : ""}`;
2317
+ const nameAt = at + rest.indexOf(name2, rest.indexOf("func", "override".length + func[1].length) + 4);
2237
2318
  lifted.push({
2238
2319
  type: top.name,
2239
- member: name,
2320
+ member: name2,
2240
2321
  at,
2241
2322
  modifiers,
2242
2323
  access,
@@ -2254,16 +2335,16 @@ function extensionOverrideEdits(source, extraObjCExtensions) {
2254
2335
  if (property) {
2255
2336
  const open = at + property[0].length - 1;
2256
2337
  if (/\b(?:set|willSet|didSet)\b/.test(source.slice(open, closing(open)))) continue;
2257
- const name = property[2];
2258
- const nameAt = at + rest.indexOf(name, rest.indexOf("var"));
2338
+ const name2 = property[2];
2339
+ const nameAt = at + rest.indexOf(name2, rest.indexOf("var"));
2259
2340
  lifted.push({
2260
2341
  type: top.name,
2261
- member: name,
2342
+ member: name2,
2262
2343
  at,
2263
2344
  modifiers,
2264
2345
  access,
2265
- decl: `var ${name}: ${property[3].trim()}`,
2266
- forward: `{ __peach_ext_${name} };`,
2346
+ decl: `var ${name2}: ${property[3].trim()}`,
2347
+ forward: `{ __peach_ext_${name2} };`,
2267
2348
  nameAt,
2268
2349
  edits: [
2269
2350
  [at, "override".length, " ".repeat("override".length)],
@@ -2401,15 +2482,15 @@ function objcRootedClasses(sources) {
2401
2482
  ))
2402
2483
  bases.set(match[1], match[2]);
2403
2484
  const rooted = /* @__PURE__ */ new Set();
2404
- for (const name of bases.keys()) {
2405
- const seen = /* @__PURE__ */ new Set([name]);
2406
- let base = bases.get(name);
2485
+ for (const name2 of bases.keys()) {
2486
+ const seen = /* @__PURE__ */ new Set([name2]);
2487
+ let base = bases.get(name2);
2407
2488
  while (bases.has(base) && !seen.has(base)) {
2408
2489
  seen.add(base);
2409
2490
  base = bases.get(base);
2410
2491
  }
2411
2492
  if (!bases.has(base) && APPLE_CLASS.test(base) && !APPLE_PROTOCOL.test(base) && !(base in SDK_OBJC_OPTIONAL))
2412
- rooted.add(name);
2493
+ rooted.add(name2);
2413
2494
  }
2414
2495
  return rooted;
2415
2496
  }
@@ -2552,8 +2633,8 @@ function inheritedTypes(sources) {
2552
2633
  if (colon === -1) continue;
2553
2634
  const inherited = parents.get(owner[1]) ?? /* @__PURE__ */ new Set();
2554
2635
  for (const type of splitTopLevel(header.slice(colon + 1).split(/\bwhere\b/)[0])) {
2555
- const name = /^\s*(?:[A-Za-z_]\w*\.)*([A-Za-z_]\w*)/.exec(type)?.[1];
2556
- if (name && !type.includes("<")) inherited.add(name);
2636
+ const name2 = /^\s*(?:[A-Za-z_]\w*\.)*([A-Za-z_]\w*)/.exec(type)?.[1];
2637
+ if (name2 && !type.includes("<")) inherited.add(name2);
2557
2638
  }
2558
2639
  parents.set(owner[1], inherited);
2559
2640
  }
@@ -2632,20 +2713,20 @@ var DECLARATION_MODIFIERS = /* @__PURE__ */ new Set([
2632
2713
  "unowned"
2633
2714
  ]);
2634
2715
  function objcSelectorName(base, labels, isAsync, isThrowing) {
2635
- let name = base;
2716
+ let name2 = base;
2636
2717
  labels.forEach((label, index) => {
2637
- if (index > 0) name += `${label === "_" ? "" : label}:`;
2718
+ if (index > 0) name2 += `${label === "_" ? "" : label}:`;
2638
2719
  else {
2639
2720
  if (label !== "_") {
2640
2721
  const firstWord = label[0] + /^[^A-Z_]*/.exec(label.slice(1))[0];
2641
- name += `${OBJC_PREPOSITIONS.has(firstWord) ? "" : "With"}${label[0].toUpperCase()}${label.slice(1)}`;
2722
+ name2 += `${OBJC_PREPOSITIONS.has(firstWord) ? "" : "With"}${label[0].toUpperCase()}${label.slice(1)}`;
2642
2723
  }
2643
- name += ":";
2724
+ name2 += ":";
2644
2725
  }
2645
2726
  });
2646
- if (isAsync) name += labels.length ? "completionHandler:" : "WithCompletionHandler:";
2647
- else if (isThrowing) name += labels.length ? "error:" : "AndReturnError:";
2648
- return name;
2727
+ if (isAsync) name2 += labels.length ? "completionHandler:" : "WithCompletionHandler:";
2728
+ else if (isThrowing) name2 += labels.length ? "error:" : "AndReturnError:";
2729
+ return name2;
2649
2730
  }
2650
2731
  function declarationStart(code, at, floor) {
2651
2732
  let start = at;
@@ -2707,22 +2788,22 @@ function objcOptionalProtocols(source) {
2707
2788
  ...(attributes.match(/@available\s*\((?:[^()"]|"(?:[^"\\]|\\.)*")*\)/g) ?? []).map((attribute) => attribute.replace(/\s*\n\s*/g, " ")),
2708
2789
  access ?? ""
2709
2790
  ].filter((word) => word !== "").join(" ");
2710
- const name = member[2];
2791
+ const name2 = member[2];
2711
2792
  const after = at + member[0].length;
2712
2793
  if (member[1] === "var") {
2713
2794
  const typed = /^\s*:\s*([^{\n]+?)\s*\{[^}]*\}/.exec(code.slice(after));
2714
2795
  if (!typed) continue;
2715
- const selector2 = explicit ?? name;
2796
+ const selector2 = explicit ?? name2;
2716
2797
  const typeMember2 = /\bstatic\b/.test(code.slice(start, at));
2717
2798
  members.push({
2718
- name,
2799
+ name: name2,
2719
2800
  labels: null,
2720
2801
  selector: selector2,
2721
2802
  start,
2722
2803
  end: after + typed[0].length,
2723
2804
  result: objcTypeName(typed[1]),
2724
2805
  typeMember: typeMember2,
2725
- helper: `${head} ${typeMember2 ? "static " : ""}var ${name}: ${optionalResult(typed[1])} { _objcOptionalSend(self, Selector(${JSON.stringify(selector2)}), [], default: nil) }`
2806
+ helper: `${head} ${typeMember2 ? "static " : ""}var ${name2}: ${optionalResult(typed[1])} { _objcOptionalSend(self, Selector(${JSON.stringify(selector2)}), [], default: nil) }`
2726
2807
  });
2727
2808
  continue;
2728
2809
  }
@@ -2734,10 +2815,10 @@ function objcOptionalProtocols(source) {
2734
2815
  const parameters = code.slice(paren + 1, shut);
2735
2816
  const names = parameterNames(parameters);
2736
2817
  const labels = names.map((parameter) => parameter.label);
2737
- const selector = explicit ?? objcSelectorName(name, labels, tail[1] !== void 0, tail[2] !== void 0);
2818
+ const selector = explicit ?? objcSelectorName(name2, labels, tail[1] !== void 0, tail[2] !== void 0);
2738
2819
  const typeMember = /\bstatic\b/.test(code.slice(start, at));
2739
2820
  members.push({
2740
- name,
2821
+ name: name2,
2741
2822
  labels,
2742
2823
  typeMember,
2743
2824
  selector,
@@ -2746,12 +2827,12 @@ function objcOptionalProtocols(source) {
2746
2827
  types: parameterTypes(parameters),
2747
2828
  result: objcTypeName(tail[3]?.trim() ?? "Void"),
2748
2829
  helper: typeMember && (tail[1] !== void 0 || tail[2] !== void 0) ? null : tail[1] !== void 0 ? objcAsyncOptionalHelper(
2749
- `${head} func ${name}(${parameters.replace(/\s*\n\s*/g, " ")})`,
2830
+ `${head} func ${name2}(${parameters.replace(/\s*\n\s*/g, " ")})`,
2750
2831
  parameters,
2751
2832
  selector,
2752
2833
  tail[3]?.trim() ?? "Void",
2753
2834
  tail[2] !== void 0
2754
- ) : tail[2] !== void 0 ? null : `@discardableResult ${head} ${typeMember ? "static " : ""}func ${name}(${parameters.replace(/\s*\n\s*/g, " ")}) -> ${optionalResult(tail[3]?.trim() ?? "Void")} { ${escapingSend(parameters, `_objcOptionalSend(self, Selector(${JSON.stringify(selector)}), [${names.map((parameter) => parameter.name).join(", ")}], default: nil)`)} }`
2835
+ ) : tail[2] !== void 0 ? null : `@discardableResult ${head} ${typeMember ? "static " : ""}func ${name2}(${parameters.replace(/\s*\n\s*/g, " ")}) -> ${optionalResult(tail[3]?.trim() ?? "Void")} { ${escapingSend(parameters, `_objcOptionalSend(self, Selector(${JSON.stringify(selector)}), [${names.map((parameter) => parameter.name).join(", ")}], default: nil)`)} }`
2755
2836
  });
2756
2837
  }
2757
2838
  if (members.length) found.push({ name: declared[1], close, members });
@@ -2768,8 +2849,8 @@ function escapingSend(parameters, send, effects = "") {
2768
2849
  if (!named || !type?.startsWith("(")) return body;
2769
2850
  const shut = closingParen(type, 0);
2770
2851
  if (!/^\s*(?:async\b\s*)?(?:throws\b\s*)?->/.test(type.slice(shut + 1))) return body;
2771
- const name = named[2] ?? named[1];
2772
- return `${effects}withoutActuallyEscaping(${name}) { ${name} in ${body} }`;
2852
+ const name2 = named[2] ?? named[1];
2853
+ return `${effects}withoutActuallyEscaping(${name2}) { ${name2} in ${body} }`;
2773
2854
  }, send);
2774
2855
  }
2775
2856
  function objcAsyncOptionalHelper(declaration, parameters, selector, result, throwing) {
@@ -4219,10 +4300,10 @@ function objcTypeMethods(source, found) {
4219
4300
  function objcIndex(sources) {
4220
4301
  const requirements = /* @__PURE__ */ new Map();
4221
4302
  const callable = /* @__PURE__ */ new Map();
4222
- const callableAs = (name, member, labels) => {
4223
- const known = callable.get(name);
4303
+ const callableAs = (name2, member, labels) => {
4304
+ const known = callable.get(name2);
4224
4305
  if (known) known.labels.push(labels);
4225
- else callable.set(name, { member, labels: [labels] });
4306
+ else callable.set(name2, { member, labels: [labels] });
4226
4307
  };
4227
4308
  const typeMethods = /* @__PURE__ */ new Map();
4228
4309
  const sdkParents = /* @__PURE__ */ new Map();
@@ -4240,9 +4321,9 @@ function objcIndex(sources) {
4240
4321
  requirements.set(
4241
4322
  protocol,
4242
4323
  sdk.requirements.map(([signature, selector, typed, asyncSignature]) => {
4243
- const name = signature.slice(0, signature.indexOf("("));
4244
- const labels = signature.slice(name.length + 1, -1).split(":").slice(0, -1);
4245
- if (sdk.callers) callableAs(name, `_objcOptional_${name}`, labels);
4324
+ const name2 = signature.slice(0, signature.indexOf("("));
4325
+ const labels = signature.slice(name2.length + 1, -1).split(":").slice(0, -1);
4326
+ if (sdk.callers) callableAs(name2, `_objcOptional_${name2}`, labels);
4246
4327
  const arrow = typed?.lastIndexOf("->") ?? -1;
4247
4328
  const types = typed?.slice(0, arrow);
4248
4329
  const result = typed?.slice(arrow + 2);
@@ -4253,7 +4334,7 @@ function objcIndex(sources) {
4253
4334
  const values = handler ? splitTopLevel(handler[1]) : [];
4254
4335
  const asyncName = asyncSignature?.slice(0, asyncSignature.indexOf("("));
4255
4336
  return {
4256
- name,
4337
+ name: name2,
4257
4338
  labels,
4258
4339
  selector,
4259
4340
  ...parameters !== void 0 && { types: parameters },
@@ -4279,8 +4360,8 @@ function objcIndex(sources) {
4279
4360
  for (const protocol of objcOptionalProtocols(source)) {
4280
4361
  requirements.set(
4281
4362
  protocol.name,
4282
- protocol.members.map(({ name, labels, selector, types, result, typeMember }) => ({
4283
- name,
4363
+ protocol.members.map(({ name: name2, labels, selector, types, result, typeMember }) => ({
4364
+ name: name2,
4284
4365
  labels,
4285
4366
  selector,
4286
4367
  ...typeMember && { typeMember },
@@ -4310,18 +4391,18 @@ function objcIndex(sources) {
4310
4391
  const code = swiftCodeMask(source);
4311
4392
  const braces = [...code.matchAll(/[{}]/g)].map((match) => match.index);
4312
4393
  for (const protocol of code.matchAll(/\bprotocol\s+([A-Za-z_]\w*)[^{}]*\{/g)) {
4313
- const name = protocol[1];
4314
- protocols.add(name);
4394
+ const name2 = protocol[1];
4395
+ protocols.add(name2);
4315
4396
  const open = protocol.index + protocol[0].length - 1;
4316
4397
  if (/\binit\s*[?!]?\s*\(/.test(code.slice(open + 1, closingBrace(code, braces, open))))
4317
- initializers.add(name);
4398
+ initializers.add(name2);
4318
4399
  }
4319
4400
  }
4320
4401
  const rooted = conformingTypes(parents, /* @__PURE__ */ new Set(["NSObject"]));
4321
4402
  const initialized = conformingTypes(parents, initializers);
4322
4403
  const nsObjectTypes = /* @__PURE__ */ new Set([
4323
4404
  "NSObject",
4324
- ...[...protocols].filter((name) => rooted.has(name) && !initialized.has(name))
4405
+ ...[...protocols].filter((name2) => rooted.has(name2) && !initialized.has(name2))
4325
4406
  ]);
4326
4407
  return {
4327
4408
  requirements,
@@ -4348,8 +4429,8 @@ function objcAliases(sources) {
4348
4429
  }
4349
4430
  }
4350
4431
  const aliases = /* @__PURE__ */ new Map();
4351
- for (const [name, type] of declared) if (type !== null) aliases.set(name, type);
4352
- for (const [name, type] of aliases) aliases.set(name, resolveAliases(type, aliases));
4432
+ for (const [name2, type] of declared) if (type !== null) aliases.set(name2, type);
4433
+ for (const [name2, type] of aliases) aliases.set(name2, resolveAliases(type, aliases));
4353
4434
  return aliases;
4354
4435
  }
4355
4436
  function resolveAliases(type, aliases) {
@@ -4357,7 +4438,7 @@ function resolveAliases(type, aliases) {
4357
4438
  for (let pass = 0; pass < 8 && aliases.size; pass++) {
4358
4439
  const next = resolved.replace(
4359
4440
  /(?<![\w.])[A-Za-z_]\w*(?![\w.])/g,
4360
- (name) => aliases.get(name) ?? name
4441
+ (name2) => aliases.get(name2) ?? name2
4361
4442
  );
4362
4443
  if (next === resolved) break;
4363
4444
  resolved = next;
@@ -4463,17 +4544,17 @@ function lowerObjCOptionalRequirements(source, index) {
4463
4544
  `; extension ${protocol.name} { ${helpers.join("; ")} }`
4464
4545
  ]);
4465
4546
  }
4466
- for (const name of code.matchAll(
4547
+ for (const name2 of code.matchAll(
4467
4548
  /#selector\(\s*([A-Za-z_]\w*)\.([A-Za-z_]\w*)\(((?:\s*\w+\s*:)+)\s*\)\s*\)/g
4468
4549
  )) {
4469
- const signature = `${name[2]}(${name[3].replace(/\s+/g, "")})`;
4470
- const found = SDK_OBJC_OPTIONAL[name[1]]?.requirements.filter(
4550
+ const signature = `${name2[2]}(${name2[3].replace(/\s+/g, "")})`;
4551
+ const found = SDK_OBJC_OPTIONAL[name2[1]]?.requirements.filter(
4471
4552
  ([requirement]) => requirement === signature
4472
4553
  );
4473
4554
  if (found?.length === 1)
4474
4555
  edits.push([
4475
- name.index,
4476
- name[0].length,
4556
+ name2.index,
4557
+ name2[0].length,
4477
4558
  `NSSelectorFromString(${JSON.stringify(found[0][1])})`
4478
4559
  ]);
4479
4560
  }
@@ -4481,7 +4562,7 @@ function lowerObjCOptionalRequirements(source, index) {
4481
4562
  const receivesAsProtocol = (dot) => {
4482
4563
  const receiver = /([A-Za-z_]\w*)\s*[?!]?\s*$/.exec(code.slice(0, dot))?.[1];
4483
4564
  if (!receiver) return false;
4484
- const name = /^\.\s*([A-Za-z_]\w*)/.exec(code.slice(dot))?.[1];
4565
+ const name2 = /^\.\s*([A-Za-z_]\w*)/.exec(code.slice(dot))?.[1];
4485
4566
  let innermost;
4486
4567
  for (const declared of code.matchAll(
4487
4568
  new RegExp(
@@ -4494,7 +4575,7 @@ function lowerObjCOptionalRequirements(source, index) {
4494
4575
  if (dot > from && dot < to && (!innermost || from >= innermost.from))
4495
4576
  innermost = { from, type: declared[1] };
4496
4577
  }
4497
- return innermost?.type !== void 0 && !!index.requirements.get(resolveAliases(innermost.type, index.aliases))?.some((wanted) => wanted.name === name);
4578
+ return innermost?.type !== void 0 && !!index.requirements.get(resolveAliases(innermost.type, index.aliases))?.some((wanted) => wanted.name === name2);
4498
4579
  };
4499
4580
  for (const call of code.matchAll(/\.\s*([A-Za-z_]\w*)\s*\?(?=\s*[({])/g)) {
4500
4581
  const callable = index.callable.get(call[1]);
@@ -4511,8 +4592,8 @@ function lowerObjCOptionalRequirements(source, index) {
4511
4592
  continue;
4512
4593
  if (callable.member === call[1]) edits.push([mark, 1, " "]);
4513
4594
  else {
4514
- const name = call.index + call[0].indexOf(call[1]);
4515
- edits.push([name, mark + 1 - name, callable.member]);
4595
+ const name2 = call.index + call[0].indexOf(call[1]);
4596
+ edits.push([name2, mark + 1 - name2, callable.member]);
4516
4597
  }
4517
4598
  }
4518
4599
  for (const owner of code.matchAll(
@@ -4611,8 +4692,8 @@ function lowerObjCRuntimeCalls(source, index) {
4611
4692
  for (const declared of code.matchAll(
4612
4693
  /(?:\b(?:let|var)\s+|[(,]\s*(?:[A-Za-z_]\w*\s+)?)([A-Za-z_]\w*)\s*:\s*(?:(?:any\s+)?([A-Z]\w*(?:\.\w+)*)\s*([?!])?|[[(])|\b(?:let|var|for)\s+([A-Za-z_]\w*)\b(?!\s*:)|[{,]\s*([A-Za-z_]\w*)\s+in\b/g
4613
4694
  )) {
4614
- const name = declared[1] ?? declared[4] ?? declared[5];
4615
- const list = declarations.get(name) ?? [];
4695
+ const name2 = declared[1] ?? declared[4] ?? declared[5];
4696
+ const list = declarations.get(name2) ?? [];
4616
4697
  let type = declared[3] ? "" : declared[2] ?? "";
4617
4698
  if (!type && declared[4]) {
4618
4699
  const lookup = /^\s*=\s*NSClassFromString\s*\(/.exec(
@@ -4627,7 +4708,7 @@ function lowerObjCRuntimeCalls(source, index) {
4627
4708
  }
4628
4709
  const resolved = type.endsWith(".Type") ? `${resolveAliases(type.slice(0, -5), index.aliases)}.Type` : resolveAliases(type, index.aliases);
4629
4710
  list.push({ at: declared.index, type: resolved });
4630
- declarations.set(name, list);
4711
+ declarations.set(name2, list);
4631
4712
  }
4632
4713
  for (const pattern of code.matchAll(/\b(?:let|var|for)\s*(?=\(|\.\s*\w+\s*\()/g)) {
4633
4714
  const open = code.indexOf("(", pattern.index + pattern[0].length);
@@ -4640,9 +4721,9 @@ function lowerObjCRuntimeCalls(source, index) {
4640
4721
  }
4641
4722
  for (const list of declarations.values()) list.sort((a, b) => a.at - b.at);
4642
4723
  const braces = [...code.matchAll(/[{}]/g)].map((match) => match.index);
4643
- const receiverType = (name, at) => {
4724
+ const receiverType = (name2, at) => {
4644
4725
  let innermost;
4645
- for (const declared of declarations.get(name) ?? []) {
4726
+ for (const declared of declarations.get(name2) ?? []) {
4646
4727
  if (declared.at > at) break;
4647
4728
  const [from, to] = declarationScope(code, braces, declared.at);
4648
4729
  if (at > from && at < to && (!innermost || from >= innermost.from))
@@ -5481,7 +5562,7 @@ var CORE_FOUNDATION_HANDLE_IMPORTS = [
5481
5562
  "CFSet",
5482
5563
  "CFString",
5483
5564
  "CFURL"
5484
- ].map((name) => `import class CoreFoundation.${name}`).concat([
5565
+ ].map((name2) => `import class CoreFoundation.${name2}`).concat([
5485
5566
  "import typealias CoreFoundation.CFPropertyList",
5486
5567
  "import typealias CoreFoundation.CFTypeRef",
5487
5568
  "import CoreGraphics"
@@ -5675,11 +5756,11 @@ function swiftSourceClosure(files, roots) {
5675
5756
  continue;
5676
5757
  }
5677
5758
  if (depth !== 0 || !match[2]) continue;
5678
- const name = match[2].split(".").pop();
5759
+ const name2 = match[2].split(".").pop();
5679
5760
  const index = match[1] === "extension" ? extensions : owners;
5680
- const set = index.get(name) ?? /* @__PURE__ */ new Set();
5761
+ const set = index.get(name2) ?? /* @__PURE__ */ new Set();
5681
5762
  set.add(file);
5682
- index.set(name, set);
5763
+ index.set(name2, set);
5683
5764
  }
5684
5765
  sources.set(file, references);
5685
5766
  }
@@ -5687,10 +5768,10 @@ function swiftSourceClosure(files, roots) {
5687
5768
  const pending = [...roots];
5688
5769
  const seen = /* @__PURE__ */ new Set();
5689
5770
  while (pending.length) {
5690
- const name = pending.pop();
5691
- if (seen.has(name)) continue;
5692
- seen.add(name);
5693
- for (const file of [...owners.get(name) ?? [], ...extensions.get(name) ?? []]) {
5771
+ const name2 = pending.pop();
5772
+ if (seen.has(name2)) continue;
5773
+ seen.add(name2);
5774
+ for (const file of [...owners.get(name2) ?? [], ...extensions.get(name2) ?? []]) {
5694
5775
  if (included.has(file)) continue;
5695
5776
  included.add(file);
5696
5777
  for (const reference of sources.get(file)) pending.push(reference);
@@ -5985,7 +6066,7 @@ function writeSwiftProject(layout, input, moduleRoot) {
5985
6066
  [
5986
6067
  product,
5987
6068
  ...optionalProducts.map(
5988
- (name) => `.product(name: "${name}", package: "sootsim-swift"),`
6069
+ (name2) => `.product(name: "${name2}", package: "sootsim-swift"),`
5989
6070
  )
5990
6071
  ].join("\n ")
5991
6072
  );
@@ -6100,7 +6181,7 @@ function builtArtifact(layout) {
6100
6181
  }
6101
6182
  const file = import_node_path6.default.join(binDir, `${executable.name}.wasm`);
6102
6183
  if (!(0, import_node_fs4.existsSync)(file)) {
6103
- const found = (0, import_node_fs4.existsSync)(binDir) ? (0, import_node_fs4.readdirSync)(binDir).filter((name) => name.endsWith(".wasm")).sort() : [];
6184
+ const found = (0, import_node_fs4.existsSync)(binDir) ? (0, import_node_fs4.readdirSync)(binDir).filter((name2) => name2.endsWith(".wasm")).sort() : [];
6104
6185
  throw new Error(
6105
6186
  `swift-compile: the build produced no ${executable.name}.wasm (found: ${found.join(", ") || "none"})`
6106
6187
  );
@@ -6280,7 +6361,7 @@ function compileSwiftProjectUnit(input, options) {
6280
6361
  }
6281
6362
  return withSwiftRootLock(
6282
6363
  root,
6283
- async () => {
6364
+ async (lease) => {
6284
6365
  const built = readCompiledArtifact(import_node_path6.default.join(sharedRoot, "artifact"), hash);
6285
6366
  if (built) {
6286
6367
  report("reusing verified disk artifact");
@@ -6343,7 +6424,8 @@ function compileSwiftProjectUnit(input, options) {
6343
6424
  },
6344
6425
  maxBuffer: 64 * 1024 * 1024,
6345
6426
  timeout: options.timeoutMs,
6346
- signal: options.signal
6427
+ signal: options.signal,
6428
+ lease
6347
6429
  };
6348
6430
  report("compiling and linking Swift modules");
6349
6431
  try {