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,7 +1,10 @@
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
 
3
3
  // src/swift-compile.ts
4
- import { spawn as spawn2, execFileSync as execFileSync3 } from "node:child_process";
4
+ import {
5
+ spawn as spawn3,
6
+ execFileSync as execFileSync2
7
+ } from "node:child_process";
5
8
  import { createHash as createHash5 } from "node:crypto";
6
9
  import {
7
10
  cpSync,
@@ -9,9 +12,9 @@ import {
9
12
  mkdirSync as mkdirSync2,
10
13
  mkdtempSync as mkdtempSync2,
11
14
  readFileSync as readFileSync5,
12
- readdirSync as readdirSync2,
15
+ readdirSync as readdirSync3,
13
16
  realpathSync,
14
- renameSync as renameSync2,
17
+ renameSync,
15
18
  rmSync as rmSync3,
16
19
  statSync,
17
20
  writeFileSync as writeFileSync3
@@ -61,9 +64,9 @@ function cacheDir() {
61
64
  }
62
65
  function swiftPackageCacheOptions() {
63
66
  const root = path.join(cacheDir(), "swiftpm");
64
- return ["cache", "config", "security"].flatMap((name) => [
65
- `--${name}-path`,
66
- path.join(root, name)
67
+ return ["cache", "config", "security"].flatMap((name2) => [
68
+ `--${name2}-path`,
69
+ path.join(root, name2)
67
70
  ]);
68
71
  }
69
72
  var DAEMON_LOCKFILE_MAX_BYTES = 16 * 1024;
@@ -735,7 +738,7 @@ function designTimeDiagnostic(output, files) {
735
738
  const rewritten = /* @__PURE__ */ new Map();
736
739
  const linesOf = (path7) => {
737
740
  const file = Object.keys(files).find(
738
- (name) => name.endsWith(".swift") && (path7 === name || path7.endsWith(`/${name}`))
741
+ (name2) => name2.endsWith(".swift") && (path7 === name2 || path7.endsWith(`/${name2}`))
739
742
  );
740
743
  if (file === void 0) return null;
741
744
  let lines = rewritten.get(file);
@@ -900,7 +903,7 @@ async function load(toolchainBin, sdk) {
900
903
  icuSegment(archiveMember(readFileSync3(path4.join(resources, ARCHIVE)), MEMBER))
901
904
  );
902
905
  }
903
- function archiveMember(archive, name) {
906
+ function archiveMember(archive, name2) {
904
907
  if (archive.toString("latin1", 0, 8) !== "!<arch>\n")
905
908
  throw new Error("swift-icu: not an ar archive");
906
909
  let names = "";
@@ -910,10 +913,10 @@ function archiveMember(archive, name) {
910
913
  const body = archive.subarray(at + 60, at + 60 + size);
911
914
  if (raw2 === "//") names = body.toString("latin1");
912
915
  const member = /^\/\d+$/.test(raw2) ? names.slice(Number(raw2.slice(1)), names.indexOf("/\n", Number(raw2.slice(1)))) : raw2.replace(/\/$/, "");
913
- if (member === name) return body;
916
+ if (member === name2) return body;
914
917
  at += 60 + size + size % 2;
915
918
  }
916
- throw new Error(`swift-icu: ${name} is not in the sdk's icu archive`);
919
+ throw new Error(`swift-icu: ${name2} is not in the sdk's icu archive`);
917
920
  }
918
921
  function icuSegment(object) {
919
922
  let at = 8;
@@ -1047,8 +1050,8 @@ function splitManifestArguments(source) {
1047
1050
  if (final) arguments_.push(final);
1048
1051
  return arguments_;
1049
1052
  }
1050
- function swiftTargetModuleName(name) {
1051
- return name.replace(/[^A-Za-z0-9_]/g, "_").replace(/^[0-9]/, "_");
1053
+ function swiftTargetModuleName(name2) {
1054
+ return name2.replace(/[^A-Za-z0-9_]/g, "_").replace(/^[0-9]/, "_");
1052
1055
  }
1053
1056
  function swiftManifestTargets(manifest, resourcePaths = []) {
1054
1057
  const implicitResources = swiftImplicitResourcePaths(resourcePaths);
@@ -1060,16 +1063,16 @@ function swiftManifestTargets(manifest, resourcePaths = []) {
1060
1063
  ]);
1061
1064
  const targetNames = new Set(
1062
1065
  declarations.flatMap(({ flat }) => {
1063
- const name = /\bname\s*:\s*"([^"]+)"/.exec(flat)?.[1];
1064
- return name ? [name] : [];
1066
+ const name2 = /\bname\s*:\s*"([^"]+)"/.exec(flat)?.[1];
1067
+ return name2 ? [name2] : [];
1065
1068
  })
1066
1069
  );
1067
1070
  for (const { kind, flat, call } of declarations) {
1068
1071
  const executable = kind === "executableTarget";
1069
- const name = /\bname\s*:\s*"([^"]+)"/.exec(flat)?.[1];
1070
- if (!name) continue;
1072
+ const name2 = /\bname\s*:\s*"([^"]+)"/.exec(flat)?.[1];
1073
+ if (!name2) continue;
1071
1074
  const rawPath = /\bpath\s*:\s*"([^"]*)"/.exec(flat)?.[1];
1072
- const targetPath = rawPath == null || rawPath === "" ? `Sources/${name}` : rawPath.replace(/^\.\//, "").replace(/\/+$/, "");
1075
+ const targetPath = rawPath == null || rawPath === "" ? `Sources/${name2}` : rawPath.replace(/^\.\//, "").replace(/\/+$/, "");
1073
1076
  const languageMode = Number(
1074
1077
  /\.swiftLanguageMode\(\s*\.v(\d+)\s*\)/.exec(call)?.[1] ?? "5"
1075
1078
  );
@@ -1109,12 +1112,12 @@ function swiftManifestTargets(manifest, resourcePaths = []) {
1109
1112
  dependencyNames.add(dependencyName);
1110
1113
  }
1111
1114
  }
1112
- const dependencies = [...dependencyNames].map((name2) => ({
1115
+ const dependencies = [...dependencyNames].map((name3) => ({
1113
1116
  kind: "target",
1114
- name: name2
1117
+ name: name3
1115
1118
  }));
1116
1119
  targets.push({
1117
- name,
1120
+ name: name2,
1118
1121
  path: targetPath,
1119
1122
  executable,
1120
1123
  ...kind === "systemLibrary" ? { systemLibrary: true } : {},
@@ -1142,50 +1145,70 @@ function swiftPackagePartition(manifest, resourcePaths = []) {
1142
1145
  }
1143
1146
 
1144
1147
  // src/swift-root-lock.ts
1145
- import { execFileSync as execFileSync2 } from "node:child_process";
1148
+ import {
1149
+ spawn as spawn2,
1150
+ spawnSync as spawnSync3
1151
+ } from "node:child_process";
1146
1152
  import { createHash as createHash4, randomUUID as randomUUID2 } from "node:crypto";
1147
1153
  import {
1148
1154
  linkSync,
1149
1155
  mkdirSync,
1156
+ readdirSync as readdirSync2,
1150
1157
  readFileSync as readFileSync4,
1151
- renameSync,
1152
1158
  rmSync as rmSync2,
1153
1159
  writeFileSync as writeFileSync2
1154
1160
  } from "node:fs";
1155
1161
  import path5 from "node:path";
1156
1162
  var POLL_MS = 250;
1157
- function processStart(pid) {
1158
- try {
1159
- return execFileSync2("ps", ["-o", "lstart=", "-p", String(pid)], {
1160
- encoding: "utf8",
1161
- stdio: ["ignore", "pipe", "ignore"]
1162
- }).trim() || null;
1163
- } catch {
1164
- return null;
1165
- }
1163
+ var START_TOLERANCE_MS = 2e3;
1164
+ function errorCode(error) {
1165
+ return error instanceof Error && "code" in error && typeof error.code === "string" ? error.code : void 0;
1166
1166
  }
1167
- function parseHolder(text2) {
1168
- try {
1169
- const value = JSON.parse(text2);
1170
- if (value && typeof value === "object" && "pid" in value && typeof value.pid === "number" && "start" in value && (typeof value.start === "string" || value.start === null))
1171
- return { pid: value.pid, start: value.start };
1172
- } catch {
1173
- }
1174
- return null;
1167
+ function parseStart(text2) {
1168
+ const start = Date.parse(`${text2} UTC`);
1169
+ if (Number.isNaN(start)) throw new Error(`unreadable process start time "${text2}"`);
1170
+ return start;
1175
1171
  }
1176
- function readLock(lock) {
1177
- try {
1178
- return readFileSync4(lock, "utf8");
1179
- } catch (error) {
1180
- if (error instanceof Error && "code" in error && error.code === "ENOENT") return null;
1181
- throw error;
1172
+ function processTable() {
1173
+ const result = spawnSync3("ps", ["-A", "-o", "pid=,pgid=,stat=,lstart="], {
1174
+ encoding: "utf8",
1175
+ env: { ...process.env, LC_ALL: "C", TZ: "UTC" },
1176
+ stdio: ["ignore", "pipe", "pipe"],
1177
+ timeout: 1e4,
1178
+ killSignal: "SIGKILL"
1179
+ });
1180
+ if (result.error || result.status !== 0) {
1181
+ throw new Error(
1182
+ `swift root lock cannot read the process table: ${result.error?.message || result.stderr.trim() || `ps exited ${result.status}`}`
1183
+ );
1182
1184
  }
1185
+ return result.stdout.split("\n").filter((line) => line.trim()).map((line) => {
1186
+ const match = /^\s*(\d+)\s+(\d+)\s+(\S+)\s+(.+?)\s*$/.exec(line);
1187
+ if (!match)
1188
+ throw new Error(`swift root lock cannot parse a process table row: ${line}`);
1189
+ return {
1190
+ pid: Number(match[1]),
1191
+ pgid: Number(match[2]),
1192
+ zombie: match[3].startsWith("Z"),
1193
+ start: parseStart(match[4])
1194
+ };
1195
+ });
1196
+ }
1197
+ function sameProcess(row, identity) {
1198
+ return row.pid === identity.pid && Math.abs(row.start - identity.start) <= START_TOLERANCE_MS;
1183
1199
  }
1184
- function holderAlive(text2) {
1185
- const holder = parseHolder(text2);
1186
- if (!holder) return false;
1187
- const start = processStart(holder.pid);
1188
- return start !== null && start === holder.start;
1200
+ function ownIdentity(pid) {
1201
+ const row = processTable().find(
1202
+ (candidate) => candidate.pid === pid && !candidate.zombie
1203
+ );
1204
+ if (!row) throw new Error(`swift root lock cannot find process ${pid}`);
1205
+ return { pid, start: row.start };
1206
+ }
1207
+ function parseIdentity(text2) {
1208
+ const value = JSON.parse(text2);
1209
+ if (value && typeof value === "object" && "pid" in value && typeof value.pid === "number" && "start" in value && typeof value.start === "number")
1210
+ return { pid: value.pid, start: value.start };
1211
+ throw new Error(`swift root lock record is not a process identity: ${text2}`);
1189
1212
  }
1190
1213
  function pause(ms, signal) {
1191
1214
  return new Promise((resolve) => {
@@ -1198,64 +1221,127 @@ function pause(ms, signal) {
1198
1221
  signal?.addEventListener("abort", done, { once: true });
1199
1222
  });
1200
1223
  }
1224
+ var name = (number, suffix) => `${String(number).padStart(12, "0")}.${suffix}`;
1225
+ function generationNumbers(directory) {
1226
+ const numbers = /* @__PURE__ */ new Set();
1227
+ for (const entry of readdirSync2(directory)) {
1228
+ const match = /^(\d{12})\./.exec(entry);
1229
+ if (match) numbers.add(Number(match[1]));
1230
+ }
1231
+ return [...numbers].sort((a, b) => a - b);
1232
+ }
1233
+ function readGeneration(directory, number) {
1234
+ let owner;
1235
+ try {
1236
+ owner = readFileSync4(path5.join(directory, name(number, "owner")), "utf8");
1237
+ } catch (error) {
1238
+ if (errorCode(error) === "ENOENT") return null;
1239
+ throw error;
1240
+ }
1241
+ return {
1242
+ number,
1243
+ holder: parseIdentity(owner),
1244
+ released: readdirSync2(directory).includes(name(number, "released"))
1245
+ };
1246
+ }
1247
+ function readChildren(directory, number) {
1248
+ const prefix = name(number, "child.");
1249
+ return readdirSync2(directory).filter((entry) => entry.startsWith(prefix)).map((entry) => parseIdentity(readFileSync4(path5.join(directory, entry), "utf8")));
1250
+ }
1251
+ function groupAlive(table, leader) {
1252
+ const row = table.find((candidate) => candidate.pid === leader.pid);
1253
+ if (row && !sameProcess(row, leader)) return false;
1254
+ return table.some((candidate) => candidate.pgid === leader.pid && !candidate.zombie);
1255
+ }
1201
1256
  async function withSwiftRootLock(root, work, signal) {
1202
- const directory = path5.join(rnxHomeDir(), "cache", "swift-root-locks");
1203
- mkdirSync(directory, { recursive: true });
1204
- const lock = path5.join(
1205
- directory,
1206
- `${createHash4("sha256").update(root).digest("hex").slice(0, 32)}.lock`
1257
+ const directory = path5.join(
1258
+ rnxHomeDir(),
1259
+ "cache",
1260
+ "swift-root-locks",
1261
+ createHash4("sha256").update(root).digest("hex").slice(0, 32)
1207
1262
  );
1263
+ mkdirSync(directory, { recursive: true });
1208
1264
  const token = randomUUID2();
1209
- const owner = JSON.stringify({
1210
- pid: process.pid,
1211
- start: processStart(process.pid),
1212
- token
1213
- });
1214
- const pending = `${lock}.${token}`;
1215
- writeFileSync2(pending, owner);
1216
- try {
1217
- for (; ; ) {
1218
- signal?.throwIfAborted();
1219
- try {
1220
- linkSync(pending, lock);
1221
- break;
1222
- } catch (error) {
1223
- if (!(error instanceof Error && "code" in error && error.code === "EEXIST"))
1224
- throw error;
1265
+ const owner = JSON.stringify(ownIdentity(process.pid));
1266
+ const pending = path5.join(directory, `pending.${token}`);
1267
+ let held = 0;
1268
+ for (; ; ) {
1269
+ signal?.throwIfAborted();
1270
+ const newest = generationNumbers(directory).at(-1) ?? 0;
1271
+ const current = newest > 0 ? readGeneration(directory, newest) : null;
1272
+ if (newest > 0 && !current) continue;
1273
+ if (current && !current.released) {
1274
+ const table = processTable();
1275
+ if (table.some((row) => !row.zombie && sameProcess(row, current.holder))) {
1276
+ await pause(POLL_MS, signal);
1277
+ continue;
1225
1278
  }
1226
- const held = readLock(lock);
1227
- if (held === null) continue;
1228
- if (holderAlive(held)) {
1279
+ const children2 = readChildren(directory, newest);
1280
+ if (children2.some((child) => groupAlive(table, child))) {
1229
1281
  await pause(POLL_MS, signal);
1230
1282
  continue;
1231
1283
  }
1232
- const dead = `${lock}.dead-${token}`;
1233
- try {
1234
- renameSync(lock, dead);
1235
- } catch (error) {
1236
- if (error instanceof Error && "code" in error && error.code === "ENOENT") continue;
1237
- throw error;
1284
+ }
1285
+ writeFileSync2(pending, owner);
1286
+ try {
1287
+ linkSync(pending, path5.join(directory, name(newest + 1, "owner")));
1288
+ } catch (error) {
1289
+ if (errorCode(error) === "EEXIST") continue;
1290
+ throw error;
1291
+ } finally {
1292
+ rmSync2(pending, { force: true });
1293
+ }
1294
+ const numbers = generationNumbers(directory);
1295
+ if (numbers.at(-1) !== newest + 1) {
1296
+ rmSync2(path5.join(directory, name(newest + 1, "owner")), { force: true });
1297
+ continue;
1298
+ }
1299
+ held = newest + 1;
1300
+ for (const number of numbers)
1301
+ if (number < held) {
1302
+ for (const entry of readdirSync2(directory))
1303
+ if (entry.startsWith(name(number, "")))
1304
+ rmSync2(path5.join(directory, entry), { force: true });
1238
1305
  }
1306
+ break;
1307
+ }
1308
+ const children = [];
1309
+ const lease = {
1310
+ spawn(command, args, options) {
1311
+ const child = spawn2(
1312
+ "/bin/sh",
1313
+ ["-c", 'IFS= read -r go || exit 1; exec "$@" </dev/null', "sh", command, ...args],
1314
+ { ...options, detached: true, stdio: ["pipe", "pipe", "pipe"] }
1315
+ );
1316
+ child.stdin.on("error", () => {
1317
+ });
1318
+ children.push(child);
1239
1319
  try {
1240
- if (readLock(dead) !== held) {
1241
- try {
1242
- linkSync(dead, lock);
1243
- } catch (error) {
1244
- if (!(error instanceof Error && "code" in error && error.code === "EEXIST"))
1245
- throw error;
1246
- }
1320
+ if (child.pid === void 0) {
1321
+ child.once("error", () => {
1322
+ });
1323
+ throw new Error(`could not start ${command}`);
1247
1324
  }
1248
- } finally {
1249
- rmSync2(dead, { force: true });
1325
+ const childPending = `${pending}.child.${child.pid}`;
1326
+ try {
1327
+ writeFileSync2(childPending, JSON.stringify(ownIdentity(child.pid)));
1328
+ linkSync(childPending, path5.join(directory, name(held, `child.${child.pid}`)));
1329
+ } finally {
1330
+ rmSync2(childPending, { force: true });
1331
+ }
1332
+ } catch (error) {
1333
+ child.stdin.destroy();
1334
+ throw error;
1250
1335
  }
1336
+ child.stdin.end("go\n");
1337
+ return child;
1251
1338
  }
1252
- } finally {
1253
- rmSync2(pending, { force: true });
1254
- }
1339
+ };
1255
1340
  try {
1256
- return await work();
1341
+ return await work(lease);
1257
1342
  } finally {
1258
- if (readLock(lock) === owner) rmSync2(lock, { force: true });
1343
+ await Promise.all(children.map((child) => terminateProcessGroup(child, "SIGKILL", 0)));
1344
+ writeFileSync2(path5.join(directory, name(held, "released")), "");
1259
1345
  }
1260
1346
  }
1261
1347
 
@@ -1276,12 +1362,13 @@ function isSwiftResourceBundles(value) {
1276
1362
  async function runCompiler(command, args, options, stream = false, quiet) {
1277
1363
  const { signal } = options;
1278
1364
  signal?.throwIfAborted();
1279
- const child = spawn2(command, args, {
1365
+ const launch = {
1280
1366
  cwd: options.cwd,
1281
1367
  env: swiftEnvironment(options.env),
1282
1368
  detached: true,
1283
1369
  stdio: ["ignore", "pipe", "pipe"]
1284
- });
1370
+ };
1371
+ const child = options.lease ? options.lease.spawn(command, args, launch) : spawn3(command, args, launch);
1285
1372
  let stopping;
1286
1373
  try {
1287
1374
  await new Promise((resolve, reject) => {
@@ -1295,20 +1382,20 @@ async function runCompiler(command, args, options, stream = false, quiet) {
1295
1382
  void stopping.catch(() => {
1296
1383
  });
1297
1384
  };
1298
- for (const name of ["stdout", "stderr"]) {
1299
- child[name].on("data", (bytes) => {
1300
- if (stream === true) process[name].write(bytes);
1385
+ for (const name2 of ["stdout", "stderr"]) {
1386
+ child[name2].on("data", (bytes) => {
1387
+ if (stream === true) process[name2].write(bytes);
1301
1388
  else if (stream) {
1302
- const lines = (partial[name] + bytes.toString()).split("\n");
1303
- partial[name] = lines.pop();
1389
+ const lines = (partial[name2] + bytes.toString()).split("\n");
1390
+ partial[name2] = lines.pop();
1304
1391
  for (const line of lines)
1305
- if (stream.test(line)) process[name].write(`${line}
1392
+ if (stream.test(line)) process[name2].write(`${line}
1306
1393
  `);
1307
1394
  }
1308
- sizes[name] += bytes.length;
1309
- if (sizes[name] <= (options.maxBuffer ?? 1024 * 1024)) chunks[name].push(bytes);
1395
+ sizes[name2] += bytes.length;
1396
+ if (sizes[name2] <= (options.maxBuffer ?? 1024 * 1024)) chunks[name2].push(bytes);
1310
1397
  else {
1311
- failure = new Error(`Swift compiler ${name} exceeded its output limit`);
1398
+ failure = new Error(`Swift compiler ${name2} exceeded its output limit`);
1312
1399
  stop();
1313
1400
  }
1314
1401
  });
@@ -1336,9 +1423,9 @@ async function runCompiler(command, args, options, stream = false, quiet) {
1336
1423
  );
1337
1424
  else {
1338
1425
  if (quiet) {
1339
- for (const name of ["stdout", "stderr"])
1340
- for (const line of Buffer.concat(chunks[name]).toString().split("\n"))
1341
- if (line && !quiet.test(line)) process[name].write(`${line}
1426
+ for (const name2 of ["stdout", "stderr"])
1427
+ for (const line of Buffer.concat(chunks[name2]).toString().split("\n"))
1428
+ if (line && !quiet.test(line)) process[name2].write(`${line}
1342
1429
  `);
1343
1430
  }
1344
1431
  resolve();
@@ -1393,7 +1480,7 @@ function swiftModuleInputFiles(root) {
1393
1480
  "toolchain.json"
1394
1481
  ];
1395
1482
  const walk = (dir) => {
1396
- for (const entry of readdirSync2(path6.join(root, dir), {
1483
+ for (const entry of readdirSync3(path6.join(root, dir), {
1397
1484
  withFileTypes: true
1398
1485
  })) {
1399
1486
  const relative = `${dir}/${entry.name}`;
@@ -1583,11 +1670,11 @@ function swiftCondition(text2, available) {
1583
1670
  if (token === "false") return false;
1584
1671
  const call = /^(\w+)\s*\(\s*([^,()]*?)\s*(?:,[^()]*)?\)$/.exec(token ?? "");
1585
1672
  if (!call) return void 0;
1586
- const [, name, argument] = call;
1587
- if (name === "os") return argument === "iOS" || argument === "WASI";
1588
- if (name === "canImport") return available.has(argument);
1589
- if (name === "targetEnvironment") return false;
1590
- if (name === "arch") return argument === "wasm32";
1673
+ const [, name2, argument] = call;
1674
+ if (name2 === "os") return argument === "iOS" || argument === "WASI";
1675
+ if (name2 === "canImport") return available.has(argument);
1676
+ if (name2 === "targetEnvironment") return false;
1677
+ if (name2 === "arch") return argument === "wasm32";
1591
1678
  return void 0;
1592
1679
  };
1593
1680
  const both = () => {
@@ -1631,8 +1718,8 @@ function swiftImportNames(contents, available) {
1631
1718
  continue;
1632
1719
  }
1633
1720
  if (available && frames.some((frame) => frame.active !== true)) continue;
1634
- const name = SWIFT_IMPORT.exec(line)?.[1];
1635
- if (name) names.push(name);
1721
+ const name2 = SWIFT_IMPORT.exec(line)?.[1];
1722
+ if (name2) names.push(name2);
1636
1723
  }
1637
1724
  return names;
1638
1725
  }
@@ -1650,7 +1737,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
1650
1737
  const key = JSON.stringify([toolchainBin, sdk, swiftSdkOptions()]);
1651
1738
  const cached = sdkPaths.get(key);
1652
1739
  if (cached) return cached;
1653
- const configuration = execFileSync3(
1740
+ const configuration = execFileSync2(
1654
1741
  path6.join(toolchainBin, "swift"),
1655
1742
  [
1656
1743
  "sdk",
@@ -1662,9 +1749,9 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
1662
1749
  ],
1663
1750
  { encoding: "utf8", env: swiftEnvironment(), stdio: ["ignore", "pipe", "pipe"] }
1664
1751
  );
1665
- const field = (name) => {
1666
- const value = new RegExp(`^${name}:\\s*(.+)$`, "m").exec(configuration)?.[1]?.trim();
1667
- if (!value) throw new Error(`swift sdk ${sdk} reports no ${name}`);
1752
+ const field = (name2) => {
1753
+ const value = new RegExp(`^${name2}:\\s*(.+)$`, "m").exec(configuration)?.[1]?.trim();
1754
+ if (!value) throw new Error(`swift sdk ${sdk} reports no ${name2}`);
1668
1755
  return value;
1669
1756
  };
1670
1757
  const paths = {
@@ -1682,11 +1769,11 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
1682
1769
  if (cached) return cached;
1683
1770
  const modules = new Set(swiftPeachModules(moduleRoot));
1684
1771
  const { resources } = swiftSdkPaths(moduleRoot, toolchainBin);
1685
- for (const entry of readdirSync2(path6.join(resources, "wasi"))) {
1772
+ for (const entry of readdirSync3(path6.join(resources, "wasi"))) {
1686
1773
  if (entry.endsWith(".swiftmodule"))
1687
1774
  modules.add(entry.slice(0, -".swiftmodule".length));
1688
1775
  }
1689
- for (const entry of readdirSync2(resources)) {
1776
+ for (const entry of readdirSync3(resources)) {
1690
1777
  const map = path6.join(resources, entry, "module.modulemap");
1691
1778
  if (!existsSync2(map)) continue;
1692
1779
  for (const match of readFileSync5(map, "utf8").matchAll(/^module\s+([A-Za-z_]\w*)/gm))
@@ -1699,9 +1786,9 @@ function missingSwiftModules(files, available) {
1699
1786
  const missing = /* @__PURE__ */ new Map();
1700
1787
  for (const [file, contents] of Object.entries(files)) {
1701
1788
  if (!file.endsWith(".swift") || file === "Package.swift") continue;
1702
- for (const name of new Set(swiftImportNames(contents, available))) {
1703
- if (available.has(name)) continue;
1704
- missing.set(name, [...missing.get(name) ?? [], file]);
1789
+ for (const name2 of new Set(swiftImportNames(contents, available))) {
1790
+ if (available.has(name2)) continue;
1791
+ missing.set(name2, [...missing.get(name2) ?? [], file]);
1705
1792
  }
1706
1793
  }
1707
1794
  return new Map([...missing].sort(([left], [right]) => left.localeCompare(right)));
@@ -1722,8 +1809,8 @@ function swiftTargetDependencies(files, targets) {
1722
1809
  (candidate) => candidate.name !== target.name && candidate.path !== "." && candidate.path.startsWith(prefix) && file.startsWith(`${candidate.path}/`)
1723
1810
  ))
1724
1811
  continue;
1725
- for (const name of swiftImportNames(contents)) {
1726
- if (names.has(name) && name !== target.name) deps.add(name);
1812
+ for (const name2 of swiftImportNames(contents)) {
1813
+ if (names.has(name2) && name2 !== target.name) deps.add(name2);
1727
1814
  }
1728
1815
  }
1729
1816
  siblings.set(target.name, [...deps].sort());
@@ -1753,7 +1840,7 @@ var EXECUTABLE_LINK_FLAGS = ` "-Xclang-linker", "-O0",
1753
1840
  `;
1754
1841
  var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
1755
1842
  var MULTI_MANIFEST_VERSION = 39;
1756
- var compilerSourceDigest = true ? "ee2738333bb81c79211d5bee8a503c539cf65f25c95fb024c45b840450b5359e" : swiftCompilerSourceDigest(import.meta.dirname);
1843
+ var compilerSourceDigest = true ? "c2ab17198fbe6328c75dc09bbe160fe6b0fd74d4b84a08e9f8dfcd2fcf4ca1f0" : swiftCompilerSourceDigest(import.meta.dirname);
1757
1844
  function swiftArtifactHash(input, release, moduleRoot) {
1758
1845
  const hash = createHash5("sha256");
1759
1846
  hash.update(`swift-compile
@@ -1779,10 +1866,10 @@ ${release}
1779
1866
  createHash5("sha256").update(input.resources?.[base] ?? "").digest()
1780
1867
  );
1781
1868
  }
1782
- for (const name of Object.keys(input.images ?? {}).sort()) {
1783
- const image = input.images?.[name];
1869
+ for (const name2 of Object.keys(input.images ?? {}).sort()) {
1870
+ const image = input.images?.[name2];
1784
1871
  if (!image) continue;
1785
- hash.update(createHash5("sha256").update(name).digest());
1872
+ hash.update(createHash5("sha256").update(name2).digest());
1786
1873
  hash.update(createHash5("sha256").update(image.file).digest());
1787
1874
  hash.update(createHash5("sha256").update(image.data).digest());
1788
1875
  }
@@ -1821,17 +1908,17 @@ ${target}
1821
1908
  function emitSwiftPackageManifest(args) {
1822
1909
  const { targets, siblings, moduleRoot, oneModule, spriteKit, distribution } = args;
1823
1910
  const reachedFrameworks = /* @__PURE__ */ new Set();
1824
- const reach = (name) => {
1825
- if (reachedFrameworks.has(name)) return;
1826
- reachedFrameworks.add(name);
1827
- for (const dependency of OPTIONAL_FRAMEWORK_DEPENDENCIES[name] ?? [])
1911
+ const reach = (name2) => {
1912
+ if (reachedFrameworks.has(name2)) return;
1913
+ reachedFrameworks.add(name2);
1914
+ for (const dependency of OPTIONAL_FRAMEWORK_DEPENDENCIES[name2] ?? [])
1828
1915
  reach(dependency);
1829
1916
  };
1830
- for (const name of [...siblings.values()].flat())
1831
- if (OPTIONAL_FRAMEWORKS.has(name) && !targets.some((target) => target.name === name))
1832
- reach(name);
1917
+ for (const name2 of [...siblings.values()].flat())
1918
+ if (OPTIONAL_FRAMEWORKS.has(name2) && !targets.some((target) => target.name === name2))
1919
+ reach(name2);
1833
1920
  if (spriteKit) {
1834
- for (const name of ["SpriteKit", "PeachBox2D", "simd", "GLKit"]) reach(name);
1921
+ for (const name2 of ["SpriteKit", "PeachBox2D", "simd", "GLKit"]) reach(name2);
1835
1922
  }
1836
1923
  const distributionLink = args.distributionLink;
1837
1924
  if (distribution && !distributionLink)
@@ -1841,7 +1928,7 @@ function emitSwiftPackageManifest(args) {
1841
1928
  if (distribution && distributionLink) {
1842
1929
  const objects = distribution.objects.filter(
1843
1930
  (object) => [...OPTIONAL_FRAMEWORKS, "SpriteKit", "PeachBox2D"].every(
1844
- (name) => !object.startsWith(`lib/${name}-`) || reachedFrameworks.has(name)
1931
+ (name2) => !object.startsWith(`lib/${name2}-`) || reachedFrameworks.has(name2)
1845
1932
  )
1846
1933
  );
1847
1934
  distributionLink.files.set(
@@ -1855,7 +1942,7 @@ function emitSwiftPackageManifest(args) {
1855
1942
  moduleRoot,
1856
1943
  distribution ? "modules" : "cross-import-overlays"
1857
1944
  );
1858
- const overlayFlags = readdirSync2(overlayRoot, { encoding: "utf8", recursive: true }).filter((file) => file.endsWith(".swiftoverlay")).sort((left, right) => left.localeCompare(right)).flatMap((file) => [
1945
+ const overlayFlags = readdirSync3(overlayRoot, { encoding: "utf8", recursive: true }).filter((file) => file.endsWith(".swiftoverlay")).sort((left, right) => left.localeCompare(right)).flatMap((file) => [
1859
1946
  "-Xfrontend",
1860
1947
  "-swift-module-cross-import",
1861
1948
  "-Xfrontend",
@@ -1870,11 +1957,11 @@ function emitSwiftPackageManifest(args) {
1870
1957
  return ` .systemLibrary(name: ${JSON.stringify(target.name)}, path: ${JSON.stringify(target.path)}),`;
1871
1958
  const isolation = target.mainActorIsolation ? " .defaultIsolation(MainActor.self)," : "";
1872
1959
  const interoperability = target.cxxInterop ? " .interoperabilityMode(.Cxx)," : "";
1873
- const defines = (target.defines ?? []).map((name) => ` .define(${JSON.stringify(name)}),`).join("");
1960
+ const defines = (target.defines ?? []).map((name2) => ` .define(${JSON.stringify(name2)}),`).join("");
1874
1961
  const imports = distribution ? `, "-I", ${JSON.stringify(path6.join(moduleRoot, "modules"))}` : "";
1875
1962
  const native = args.native?.get(target.name);
1876
- const nativeImports = (siblings.get(target.name) ?? []).filter((name) => args.native?.has(name)).map(
1877
- (name) => `, "-Xfrontend", "-import-module", "-Xfrontend", ${JSON.stringify(swiftTargetModuleName(name))}`
1963
+ const nativeImports = (siblings.get(target.name) ?? []).filter((name2) => args.native?.has(name2)).map(
1964
+ (name2) => `, "-Xfrontend", "-import-module", "-Xfrontend", ${JSON.stringify(swiftTargetModuleName(name2))}`
1878
1965
  ).join("");
1879
1966
  const header = args.headerDirectory && [...args.native?.values() ?? []].some(
1880
1967
  (value) => value.late?.producers.includes(target.name)
@@ -1896,7 +1983,7 @@ function emitSwiftPackageManifest(args) {
1896
1983
  const library = distribution && distributionLink ? ["-Xclang-linker", `--config=${distributionLink.path}`, ...distribution.link].map((flag) => `, ${JSON.stringify(flag)}`).join("") : "";
1897
1984
  const kind = target.executable ? ".executableTarget" : ".target";
1898
1985
  const linkedLibraries = (target.linkedLibraries ?? []).map(
1899
- (name) => `.linkedLibrary(${JSON.stringify(name)})`
1986
+ (name2) => `.linkedLibrary(${JSON.stringify(name2)})`
1900
1987
  );
1901
1988
  const librarySettings = [
1902
1989
  ...linkedLibraries,
@@ -1935,9 +2022,9 @@ function emitSwiftPackageManifest(args) {
1935
2022
  " targets: [",
1936
2023
  ...targets.map(stanza),
1937
2024
  ...[...args.native?.entries() ?? []].flatMap(
1938
- ([name, native]) => native.late ? [
2025
+ ([name2, native]) => native.late ? [
1939
2026
  ` .target(name: ${JSON.stringify(native.late.name)},`,
1940
- ` dependencies: ${JSON.stringify([name, ...native.late.producers])},`,
2027
+ ` dependencies: ${JSON.stringify([name2, ...native.late.producers])},`,
1941
2028
  ` path: ${JSON.stringify(native.path)},`,
1942
2029
  ` sources: ${JSON.stringify(native.lateSources)},`,
1943
2030
  ` publicHeadersPath: "include",`,
@@ -1953,7 +2040,7 @@ function emitSwiftPackageManifest(args) {
1953
2040
  function syncSwiftTree(base, files) {
1954
2041
  mkdirSync2(base, { recursive: true });
1955
2042
  const walk = (dir) => {
1956
- for (const entry of readdirSync2(dir, { withFileTypes: true })) {
2043
+ for (const entry of readdirSync3(dir, { withFileTypes: true })) {
1957
2044
  const full = path6.join(dir, entry.name);
1958
2045
  if (dir === base && entry.name === ".build") continue;
1959
2046
  if (entry.isDirectory()) walk(full);
@@ -2190,7 +2277,7 @@ function extensionOverrideEdits(source, extraObjCExtensions) {
2190
2277
  if (top?.kind !== "extension") continue;
2191
2278
  const func = OVERRIDE_FUNC.exec(rest);
2192
2279
  if (func) {
2193
- const name = func[2];
2280
+ const name2 = func[2];
2194
2281
  const open = at + func[0].length - 1;
2195
2282
  let depth = 0;
2196
2283
  let close = open;
@@ -2203,12 +2290,12 @@ function extensionOverrideEdits(source, extraObjCExtensions) {
2203
2290
  const clause = source.slice(close + 1, body).trim();
2204
2291
  const args = forwardedArguments(source.slice(open + 1, close));
2205
2292
  if (args === null) continue;
2206
- const call = (clause.includes("->") ? "return " : "") + (/\b(?:throws|rethrows)\b/.test(clause) ? "try " : "") + (/\basync\b/.test(clause) ? "await " : "") + `__peach_ext_${name}(${args})`;
2207
- const signature = `func ${name}${func[3] ?? ""}${source.slice(open, close + 1)}${clause ? ` ${clause}` : ""}`;
2208
- const nameAt = at + rest.indexOf(name, rest.indexOf("func", "override".length + func[1].length) + 4);
2293
+ const call = (clause.includes("->") ? "return " : "") + (/\b(?:throws|rethrows)\b/.test(clause) ? "try " : "") + (/\basync\b/.test(clause) ? "await " : "") + `__peach_ext_${name2}(${args})`;
2294
+ const signature = `func ${name2}${func[3] ?? ""}${source.slice(open, close + 1)}${clause ? ` ${clause}` : ""}`;
2295
+ const nameAt = at + rest.indexOf(name2, rest.indexOf("func", "override".length + func[1].length) + 4);
2209
2296
  lifted.push({
2210
2297
  type: top.name,
2211
- member: name,
2298
+ member: name2,
2212
2299
  at,
2213
2300
  modifiers,
2214
2301
  access,
@@ -2226,16 +2313,16 @@ function extensionOverrideEdits(source, extraObjCExtensions) {
2226
2313
  if (property) {
2227
2314
  const open = at + property[0].length - 1;
2228
2315
  if (/\b(?:set|willSet|didSet)\b/.test(source.slice(open, closing(open)))) continue;
2229
- const name = property[2];
2230
- const nameAt = at + rest.indexOf(name, rest.indexOf("var"));
2316
+ const name2 = property[2];
2317
+ const nameAt = at + rest.indexOf(name2, rest.indexOf("var"));
2231
2318
  lifted.push({
2232
2319
  type: top.name,
2233
- member: name,
2320
+ member: name2,
2234
2321
  at,
2235
2322
  modifiers,
2236
2323
  access,
2237
- decl: `var ${name}: ${property[3].trim()}`,
2238
- forward: `{ __peach_ext_${name} };`,
2324
+ decl: `var ${name2}: ${property[3].trim()}`,
2325
+ forward: `{ __peach_ext_${name2} };`,
2239
2326
  nameAt,
2240
2327
  edits: [
2241
2328
  [at, "override".length, " ".repeat("override".length)],
@@ -2373,15 +2460,15 @@ function objcRootedClasses(sources) {
2373
2460
  ))
2374
2461
  bases.set(match[1], match[2]);
2375
2462
  const rooted = /* @__PURE__ */ new Set();
2376
- for (const name of bases.keys()) {
2377
- const seen = /* @__PURE__ */ new Set([name]);
2378
- let base = bases.get(name);
2463
+ for (const name2 of bases.keys()) {
2464
+ const seen = /* @__PURE__ */ new Set([name2]);
2465
+ let base = bases.get(name2);
2379
2466
  while (bases.has(base) && !seen.has(base)) {
2380
2467
  seen.add(base);
2381
2468
  base = bases.get(base);
2382
2469
  }
2383
2470
  if (!bases.has(base) && APPLE_CLASS.test(base) && !APPLE_PROTOCOL.test(base) && !(base in SDK_OBJC_OPTIONAL))
2384
- rooted.add(name);
2471
+ rooted.add(name2);
2385
2472
  }
2386
2473
  return rooted;
2387
2474
  }
@@ -2524,8 +2611,8 @@ function inheritedTypes(sources) {
2524
2611
  if (colon === -1) continue;
2525
2612
  const inherited = parents.get(owner[1]) ?? /* @__PURE__ */ new Set();
2526
2613
  for (const type of splitTopLevel(header.slice(colon + 1).split(/\bwhere\b/)[0])) {
2527
- const name = /^\s*(?:[A-Za-z_]\w*\.)*([A-Za-z_]\w*)/.exec(type)?.[1];
2528
- if (name && !type.includes("<")) inherited.add(name);
2614
+ const name2 = /^\s*(?:[A-Za-z_]\w*\.)*([A-Za-z_]\w*)/.exec(type)?.[1];
2615
+ if (name2 && !type.includes("<")) inherited.add(name2);
2529
2616
  }
2530
2617
  parents.set(owner[1], inherited);
2531
2618
  }
@@ -2604,20 +2691,20 @@ var DECLARATION_MODIFIERS = /* @__PURE__ */ new Set([
2604
2691
  "unowned"
2605
2692
  ]);
2606
2693
  function objcSelectorName(base, labels, isAsync, isThrowing) {
2607
- let name = base;
2694
+ let name2 = base;
2608
2695
  labels.forEach((label, index) => {
2609
- if (index > 0) name += `${label === "_" ? "" : label}:`;
2696
+ if (index > 0) name2 += `${label === "_" ? "" : label}:`;
2610
2697
  else {
2611
2698
  if (label !== "_") {
2612
2699
  const firstWord = label[0] + /^[^A-Z_]*/.exec(label.slice(1))[0];
2613
- name += `${OBJC_PREPOSITIONS.has(firstWord) ? "" : "With"}${label[0].toUpperCase()}${label.slice(1)}`;
2700
+ name2 += `${OBJC_PREPOSITIONS.has(firstWord) ? "" : "With"}${label[0].toUpperCase()}${label.slice(1)}`;
2614
2701
  }
2615
- name += ":";
2702
+ name2 += ":";
2616
2703
  }
2617
2704
  });
2618
- if (isAsync) name += labels.length ? "completionHandler:" : "WithCompletionHandler:";
2619
- else if (isThrowing) name += labels.length ? "error:" : "AndReturnError:";
2620
- return name;
2705
+ if (isAsync) name2 += labels.length ? "completionHandler:" : "WithCompletionHandler:";
2706
+ else if (isThrowing) name2 += labels.length ? "error:" : "AndReturnError:";
2707
+ return name2;
2621
2708
  }
2622
2709
  function declarationStart(code, at, floor) {
2623
2710
  let start = at;
@@ -2679,22 +2766,22 @@ function objcOptionalProtocols(source) {
2679
2766
  ...(attributes.match(/@available\s*\((?:[^()"]|"(?:[^"\\]|\\.)*")*\)/g) ?? []).map((attribute) => attribute.replace(/\s*\n\s*/g, " ")),
2680
2767
  access ?? ""
2681
2768
  ].filter((word) => word !== "").join(" ");
2682
- const name = member[2];
2769
+ const name2 = member[2];
2683
2770
  const after = at + member[0].length;
2684
2771
  if (member[1] === "var") {
2685
2772
  const typed = /^\s*:\s*([^{\n]+?)\s*\{[^}]*\}/.exec(code.slice(after));
2686
2773
  if (!typed) continue;
2687
- const selector2 = explicit ?? name;
2774
+ const selector2 = explicit ?? name2;
2688
2775
  const typeMember2 = /\bstatic\b/.test(code.slice(start, at));
2689
2776
  members.push({
2690
- name,
2777
+ name: name2,
2691
2778
  labels: null,
2692
2779
  selector: selector2,
2693
2780
  start,
2694
2781
  end: after + typed[0].length,
2695
2782
  result: objcTypeName(typed[1]),
2696
2783
  typeMember: typeMember2,
2697
- helper: `${head} ${typeMember2 ? "static " : ""}var ${name}: ${optionalResult(typed[1])} { _objcOptionalSend(self, Selector(${JSON.stringify(selector2)}), [], default: nil) }`
2784
+ helper: `${head} ${typeMember2 ? "static " : ""}var ${name2}: ${optionalResult(typed[1])} { _objcOptionalSend(self, Selector(${JSON.stringify(selector2)}), [], default: nil) }`
2698
2785
  });
2699
2786
  continue;
2700
2787
  }
@@ -2706,10 +2793,10 @@ function objcOptionalProtocols(source) {
2706
2793
  const parameters = code.slice(paren + 1, shut);
2707
2794
  const names = parameterNames(parameters);
2708
2795
  const labels = names.map((parameter) => parameter.label);
2709
- const selector = explicit ?? objcSelectorName(name, labels, tail[1] !== void 0, tail[2] !== void 0);
2796
+ const selector = explicit ?? objcSelectorName(name2, labels, tail[1] !== void 0, tail[2] !== void 0);
2710
2797
  const typeMember = /\bstatic\b/.test(code.slice(start, at));
2711
2798
  members.push({
2712
- name,
2799
+ name: name2,
2713
2800
  labels,
2714
2801
  typeMember,
2715
2802
  selector,
@@ -2718,12 +2805,12 @@ function objcOptionalProtocols(source) {
2718
2805
  types: parameterTypes(parameters),
2719
2806
  result: objcTypeName(tail[3]?.trim() ?? "Void"),
2720
2807
  helper: typeMember && (tail[1] !== void 0 || tail[2] !== void 0) ? null : tail[1] !== void 0 ? objcAsyncOptionalHelper(
2721
- `${head} func ${name}(${parameters.replace(/\s*\n\s*/g, " ")})`,
2808
+ `${head} func ${name2}(${parameters.replace(/\s*\n\s*/g, " ")})`,
2722
2809
  parameters,
2723
2810
  selector,
2724
2811
  tail[3]?.trim() ?? "Void",
2725
2812
  tail[2] !== void 0
2726
- ) : 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)`)} }`
2813
+ ) : 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)`)} }`
2727
2814
  });
2728
2815
  }
2729
2816
  if (members.length) found.push({ name: declared[1], close, members });
@@ -2740,8 +2827,8 @@ function escapingSend(parameters, send, effects = "") {
2740
2827
  if (!named || !type?.startsWith("(")) return body;
2741
2828
  const shut = closingParen(type, 0);
2742
2829
  if (!/^\s*(?:async\b\s*)?(?:throws\b\s*)?->/.test(type.slice(shut + 1))) return body;
2743
- const name = named[2] ?? named[1];
2744
- return `${effects}withoutActuallyEscaping(${name}) { ${name} in ${body} }`;
2830
+ const name2 = named[2] ?? named[1];
2831
+ return `${effects}withoutActuallyEscaping(${name2}) { ${name2} in ${body} }`;
2745
2832
  }, send);
2746
2833
  }
2747
2834
  function objcAsyncOptionalHelper(declaration, parameters, selector, result, throwing) {
@@ -4191,10 +4278,10 @@ function objcTypeMethods(source, found) {
4191
4278
  function objcIndex(sources) {
4192
4279
  const requirements = /* @__PURE__ */ new Map();
4193
4280
  const callable = /* @__PURE__ */ new Map();
4194
- const callableAs = (name, member, labels) => {
4195
- const known = callable.get(name);
4281
+ const callableAs = (name2, member, labels) => {
4282
+ const known = callable.get(name2);
4196
4283
  if (known) known.labels.push(labels);
4197
- else callable.set(name, { member, labels: [labels] });
4284
+ else callable.set(name2, { member, labels: [labels] });
4198
4285
  };
4199
4286
  const typeMethods = /* @__PURE__ */ new Map();
4200
4287
  const sdkParents = /* @__PURE__ */ new Map();
@@ -4212,9 +4299,9 @@ function objcIndex(sources) {
4212
4299
  requirements.set(
4213
4300
  protocol,
4214
4301
  sdk.requirements.map(([signature, selector, typed, asyncSignature]) => {
4215
- const name = signature.slice(0, signature.indexOf("("));
4216
- const labels = signature.slice(name.length + 1, -1).split(":").slice(0, -1);
4217
- if (sdk.callers) callableAs(name, `_objcOptional_${name}`, labels);
4302
+ const name2 = signature.slice(0, signature.indexOf("("));
4303
+ const labels = signature.slice(name2.length + 1, -1).split(":").slice(0, -1);
4304
+ if (sdk.callers) callableAs(name2, `_objcOptional_${name2}`, labels);
4218
4305
  const arrow = typed?.lastIndexOf("->") ?? -1;
4219
4306
  const types = typed?.slice(0, arrow);
4220
4307
  const result = typed?.slice(arrow + 2);
@@ -4225,7 +4312,7 @@ function objcIndex(sources) {
4225
4312
  const values = handler ? splitTopLevel(handler[1]) : [];
4226
4313
  const asyncName = asyncSignature?.slice(0, asyncSignature.indexOf("("));
4227
4314
  return {
4228
- name,
4315
+ name: name2,
4229
4316
  labels,
4230
4317
  selector,
4231
4318
  ...parameters !== void 0 && { types: parameters },
@@ -4251,8 +4338,8 @@ function objcIndex(sources) {
4251
4338
  for (const protocol of objcOptionalProtocols(source)) {
4252
4339
  requirements.set(
4253
4340
  protocol.name,
4254
- protocol.members.map(({ name, labels, selector, types, result, typeMember }) => ({
4255
- name,
4341
+ protocol.members.map(({ name: name2, labels, selector, types, result, typeMember }) => ({
4342
+ name: name2,
4256
4343
  labels,
4257
4344
  selector,
4258
4345
  ...typeMember && { typeMember },
@@ -4282,18 +4369,18 @@ function objcIndex(sources) {
4282
4369
  const code = swiftCodeMask(source);
4283
4370
  const braces = [...code.matchAll(/[{}]/g)].map((match) => match.index);
4284
4371
  for (const protocol of code.matchAll(/\bprotocol\s+([A-Za-z_]\w*)[^{}]*\{/g)) {
4285
- const name = protocol[1];
4286
- protocols.add(name);
4372
+ const name2 = protocol[1];
4373
+ protocols.add(name2);
4287
4374
  const open = protocol.index + protocol[0].length - 1;
4288
4375
  if (/\binit\s*[?!]?\s*\(/.test(code.slice(open + 1, closingBrace(code, braces, open))))
4289
- initializers.add(name);
4376
+ initializers.add(name2);
4290
4377
  }
4291
4378
  }
4292
4379
  const rooted = conformingTypes(parents, /* @__PURE__ */ new Set(["NSObject"]));
4293
4380
  const initialized = conformingTypes(parents, initializers);
4294
4381
  const nsObjectTypes = /* @__PURE__ */ new Set([
4295
4382
  "NSObject",
4296
- ...[...protocols].filter((name) => rooted.has(name) && !initialized.has(name))
4383
+ ...[...protocols].filter((name2) => rooted.has(name2) && !initialized.has(name2))
4297
4384
  ]);
4298
4385
  return {
4299
4386
  requirements,
@@ -4320,8 +4407,8 @@ function objcAliases(sources) {
4320
4407
  }
4321
4408
  }
4322
4409
  const aliases = /* @__PURE__ */ new Map();
4323
- for (const [name, type] of declared) if (type !== null) aliases.set(name, type);
4324
- for (const [name, type] of aliases) aliases.set(name, resolveAliases(type, aliases));
4410
+ for (const [name2, type] of declared) if (type !== null) aliases.set(name2, type);
4411
+ for (const [name2, type] of aliases) aliases.set(name2, resolveAliases(type, aliases));
4325
4412
  return aliases;
4326
4413
  }
4327
4414
  function resolveAliases(type, aliases) {
@@ -4329,7 +4416,7 @@ function resolveAliases(type, aliases) {
4329
4416
  for (let pass = 0; pass < 8 && aliases.size; pass++) {
4330
4417
  const next = resolved.replace(
4331
4418
  /(?<![\w.])[A-Za-z_]\w*(?![\w.])/g,
4332
- (name) => aliases.get(name) ?? name
4419
+ (name2) => aliases.get(name2) ?? name2
4333
4420
  );
4334
4421
  if (next === resolved) break;
4335
4422
  resolved = next;
@@ -4435,17 +4522,17 @@ function lowerObjCOptionalRequirements(source, index) {
4435
4522
  `; extension ${protocol.name} { ${helpers.join("; ")} }`
4436
4523
  ]);
4437
4524
  }
4438
- for (const name of code.matchAll(
4525
+ for (const name2 of code.matchAll(
4439
4526
  /#selector\(\s*([A-Za-z_]\w*)\.([A-Za-z_]\w*)\(((?:\s*\w+\s*:)+)\s*\)\s*\)/g
4440
4527
  )) {
4441
- const signature = `${name[2]}(${name[3].replace(/\s+/g, "")})`;
4442
- const found = SDK_OBJC_OPTIONAL[name[1]]?.requirements.filter(
4528
+ const signature = `${name2[2]}(${name2[3].replace(/\s+/g, "")})`;
4529
+ const found = SDK_OBJC_OPTIONAL[name2[1]]?.requirements.filter(
4443
4530
  ([requirement]) => requirement === signature
4444
4531
  );
4445
4532
  if (found?.length === 1)
4446
4533
  edits.push([
4447
- name.index,
4448
- name[0].length,
4534
+ name2.index,
4535
+ name2[0].length,
4449
4536
  `NSSelectorFromString(${JSON.stringify(found[0][1])})`
4450
4537
  ]);
4451
4538
  }
@@ -4453,7 +4540,7 @@ function lowerObjCOptionalRequirements(source, index) {
4453
4540
  const receivesAsProtocol = (dot) => {
4454
4541
  const receiver = /([A-Za-z_]\w*)\s*[?!]?\s*$/.exec(code.slice(0, dot))?.[1];
4455
4542
  if (!receiver) return false;
4456
- const name = /^\.\s*([A-Za-z_]\w*)/.exec(code.slice(dot))?.[1];
4543
+ const name2 = /^\.\s*([A-Za-z_]\w*)/.exec(code.slice(dot))?.[1];
4457
4544
  let innermost;
4458
4545
  for (const declared of code.matchAll(
4459
4546
  new RegExp(
@@ -4466,7 +4553,7 @@ function lowerObjCOptionalRequirements(source, index) {
4466
4553
  if (dot > from && dot < to && (!innermost || from >= innermost.from))
4467
4554
  innermost = { from, type: declared[1] };
4468
4555
  }
4469
- return innermost?.type !== void 0 && !!index.requirements.get(resolveAliases(innermost.type, index.aliases))?.some((wanted) => wanted.name === name);
4556
+ return innermost?.type !== void 0 && !!index.requirements.get(resolveAliases(innermost.type, index.aliases))?.some((wanted) => wanted.name === name2);
4470
4557
  };
4471
4558
  for (const call of code.matchAll(/\.\s*([A-Za-z_]\w*)\s*\?(?=\s*[({])/g)) {
4472
4559
  const callable = index.callable.get(call[1]);
@@ -4483,8 +4570,8 @@ function lowerObjCOptionalRequirements(source, index) {
4483
4570
  continue;
4484
4571
  if (callable.member === call[1]) edits.push([mark, 1, " "]);
4485
4572
  else {
4486
- const name = call.index + call[0].indexOf(call[1]);
4487
- edits.push([name, mark + 1 - name, callable.member]);
4573
+ const name2 = call.index + call[0].indexOf(call[1]);
4574
+ edits.push([name2, mark + 1 - name2, callable.member]);
4488
4575
  }
4489
4576
  }
4490
4577
  for (const owner of code.matchAll(
@@ -4583,8 +4670,8 @@ function lowerObjCRuntimeCalls(source, index) {
4583
4670
  for (const declared of code.matchAll(
4584
4671
  /(?:\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
4585
4672
  )) {
4586
- const name = declared[1] ?? declared[4] ?? declared[5];
4587
- const list = declarations.get(name) ?? [];
4673
+ const name2 = declared[1] ?? declared[4] ?? declared[5];
4674
+ const list = declarations.get(name2) ?? [];
4588
4675
  let type = declared[3] ? "" : declared[2] ?? "";
4589
4676
  if (!type && declared[4]) {
4590
4677
  const lookup = /^\s*=\s*NSClassFromString\s*\(/.exec(
@@ -4599,7 +4686,7 @@ function lowerObjCRuntimeCalls(source, index) {
4599
4686
  }
4600
4687
  const resolved = type.endsWith(".Type") ? `${resolveAliases(type.slice(0, -5), index.aliases)}.Type` : resolveAliases(type, index.aliases);
4601
4688
  list.push({ at: declared.index, type: resolved });
4602
- declarations.set(name, list);
4689
+ declarations.set(name2, list);
4603
4690
  }
4604
4691
  for (const pattern of code.matchAll(/\b(?:let|var|for)\s*(?=\(|\.\s*\w+\s*\()/g)) {
4605
4692
  const open = code.indexOf("(", pattern.index + pattern[0].length);
@@ -4612,9 +4699,9 @@ function lowerObjCRuntimeCalls(source, index) {
4612
4699
  }
4613
4700
  for (const list of declarations.values()) list.sort((a, b) => a.at - b.at);
4614
4701
  const braces = [...code.matchAll(/[{}]/g)].map((match) => match.index);
4615
- const receiverType = (name, at) => {
4702
+ const receiverType = (name2, at) => {
4616
4703
  let innermost;
4617
- for (const declared of declarations.get(name) ?? []) {
4704
+ for (const declared of declarations.get(name2) ?? []) {
4618
4705
  if (declared.at > at) break;
4619
4706
  const [from, to] = declarationScope(code, braces, declared.at);
4620
4707
  if (at > from && at < to && (!innermost || from >= innermost.from))
@@ -5453,7 +5540,7 @@ var CORE_FOUNDATION_HANDLE_IMPORTS = [
5453
5540
  "CFSet",
5454
5541
  "CFString",
5455
5542
  "CFURL"
5456
- ].map((name) => `import class CoreFoundation.${name}`).concat([
5543
+ ].map((name2) => `import class CoreFoundation.${name2}`).concat([
5457
5544
  "import typealias CoreFoundation.CFPropertyList",
5458
5545
  "import typealias CoreFoundation.CFTypeRef",
5459
5546
  "import CoreGraphics"
@@ -5647,11 +5734,11 @@ function swiftSourceClosure(files, roots) {
5647
5734
  continue;
5648
5735
  }
5649
5736
  if (depth !== 0 || !match[2]) continue;
5650
- const name = match[2].split(".").pop();
5737
+ const name2 = match[2].split(".").pop();
5651
5738
  const index = match[1] === "extension" ? extensions : owners;
5652
- const set = index.get(name) ?? /* @__PURE__ */ new Set();
5739
+ const set = index.get(name2) ?? /* @__PURE__ */ new Set();
5653
5740
  set.add(file);
5654
- index.set(name, set);
5741
+ index.set(name2, set);
5655
5742
  }
5656
5743
  sources.set(file, references);
5657
5744
  }
@@ -5659,10 +5746,10 @@ function swiftSourceClosure(files, roots) {
5659
5746
  const pending = [...roots];
5660
5747
  const seen = /* @__PURE__ */ new Set();
5661
5748
  while (pending.length) {
5662
- const name = pending.pop();
5663
- if (seen.has(name)) continue;
5664
- seen.add(name);
5665
- for (const file of [...owners.get(name) ?? [], ...extensions.get(name) ?? []]) {
5749
+ const name2 = pending.pop();
5750
+ if (seen.has(name2)) continue;
5751
+ seen.add(name2);
5752
+ for (const file of [...owners.get(name2) ?? [], ...extensions.get(name2) ?? []]) {
5666
5753
  if (included.has(file)) continue;
5667
5754
  included.add(file);
5668
5755
  for (const reference of sources.get(file)) pending.push(reference);
@@ -5781,7 +5868,7 @@ function prepareSwiftDependency(source, destination) {
5781
5868
  rmSync3(destination, { recursive: true, force: true });
5782
5869
  const origins = {};
5783
5870
  const gather = (from) => {
5784
- for (const entry of readdirSync2(from, { withFileTypes: true })) {
5871
+ for (const entry of readdirSync3(from, { withFileTypes: true })) {
5785
5872
  if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
5786
5873
  continue;
5787
5874
  const file = path6.join(from, entry.name);
@@ -5796,7 +5883,7 @@ function prepareSwiftDependency(source, destination) {
5796
5883
  const compiled = compiledSwiftSources(origins, targets);
5797
5884
  const copy = (from, to) => {
5798
5885
  mkdirSync2(to, { recursive: true });
5799
- for (const entry of readdirSync2(from, { withFileTypes: true })) {
5886
+ for (const entry of readdirSync3(from, { withFileTypes: true })) {
5800
5887
  if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
5801
5888
  continue;
5802
5889
  const file = path6.join(from, entry.name);
@@ -5957,7 +6044,7 @@ function writeSwiftProject(layout, input, moduleRoot) {
5957
6044
  [
5958
6045
  product,
5959
6046
  ...optionalProducts.map(
5960
- (name) => `.product(name: "${name}", package: "sootsim-swift"),`
6047
+ (name2) => `.product(name: "${name2}", package: "sootsim-swift"),`
5961
6048
  )
5962
6049
  ].join("\n ")
5963
6050
  );
@@ -6072,7 +6159,7 @@ function builtArtifact(layout) {
6072
6159
  }
6073
6160
  const file = path6.join(binDir, `${executable.name}.wasm`);
6074
6161
  if (!existsSync2(file)) {
6075
- const found = existsSync2(binDir) ? readdirSync2(binDir).filter((name) => name.endsWith(".wasm")).sort() : [];
6162
+ const found = existsSync2(binDir) ? readdirSync3(binDir).filter((name2) => name2.endsWith(".wasm")).sort() : [];
6076
6163
  throw new Error(
6077
6164
  `swift-compile: the build produced no ${executable.name}.wasm (found: ${found.join(", ") || "none"})`
6078
6165
  );
@@ -6148,7 +6235,7 @@ function saveCompiledArtifact(root, artifact) {
6148
6235
  })
6149
6236
  );
6150
6237
  for (const file of ["app.wasm", "icu.gz", "artifact.json"]) {
6151
- renameSync2(path6.join(pending, file), path6.join(directory, file));
6238
+ renameSync(path6.join(pending, file), path6.join(directory, file));
6152
6239
  }
6153
6240
  } finally {
6154
6241
  rmSync3(pending, { recursive: true, force: true });
@@ -6252,7 +6339,7 @@ function compileSwiftProjectUnit(input, options) {
6252
6339
  }
6253
6340
  return withSwiftRootLock(
6254
6341
  root,
6255
- async () => {
6342
+ async (lease) => {
6256
6343
  const built = readCompiledArtifact(path6.join(sharedRoot, "artifact"), hash);
6257
6344
  if (built) {
6258
6345
  report("reusing verified disk artifact");
@@ -6315,7 +6402,8 @@ function compileSwiftProjectUnit(input, options) {
6315
6402
  },
6316
6403
  maxBuffer: 64 * 1024 * 1024,
6317
6404
  timeout: options.timeoutMs,
6318
- signal: options.signal
6405
+ signal: options.signal,
6406
+ lease
6319
6407
  };
6320
6408
  report("compiling and linking Swift modules");
6321
6409
  try {