peachsim 0.1.759 → 0.1.761

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 (78) hide show
  1. package/dist-lib/agent-daemon-client.cjs +1 -1
  2. package/dist-lib/agent-events.cjs +1 -1
  3. package/dist-lib/agent-identity.cjs +1 -1
  4. package/dist-lib/agent-sessions.cjs +1 -1
  5. package/dist-lib/attached-projects.cjs +1 -1
  6. package/dist-lib/auth/shared-session.cjs +1 -1
  7. package/dist-lib/backend-origin.cjs +1 -1
  8. package/dist-lib/beta.cjs +1 -1
  9. package/dist-lib/beta.mjs +1 -1
  10. package/dist-lib/bridge-constants.cjs +1 -1
  11. package/dist-lib/bridge-contract-input.cjs +1 -1
  12. package/dist-lib/bridge-contract-input.mjs +1 -1
  13. package/dist-lib/bridge-contract.cjs +1 -1
  14. package/dist-lib/bridge-contract.mjs +1 -1
  15. package/dist-lib/capture-contract.cjs +1 -1
  16. package/dist-lib/capture-contract.mjs +1 -1
  17. package/dist-lib/cli-constants.cjs +1 -1
  18. package/dist-lib/cloud-contract.cjs +1 -1
  19. package/dist-lib/cloud-contract.mjs +1 -1
  20. package/dist-lib/cloud-test-args.cjs +1 -1
  21. package/dist-lib/cloud-test-args.mjs +1 -1
  22. package/dist-lib/cloud.cjs +1 -1
  23. package/dist-lib/cloud.mjs +1 -1
  24. package/dist-lib/config.cjs +1 -1
  25. package/dist-lib/detox/index.cjs +1 -1
  26. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  27. package/dist-lib/home-paths.cjs +1 -1
  28. package/dist-lib/host/bridge-host.cjs +888 -735
  29. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  30. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  31. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  32. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  33. package/dist-lib/host/websocket-proxy.cjs +1 -1
  34. package/dist-lib/index.cjs +37 -220
  35. package/dist-lib/jump-to-source-babel.cjs +1 -1
  36. package/dist-lib/jump-to-source-native.cjs +1 -1
  37. package/dist-lib/kotlin-host.cjs +1 -1
  38. package/dist-lib/menu.cjs +1 -1
  39. package/dist-lib/menu.mjs +1 -1
  40. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  41. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  42. package/dist-lib/metro-production-bundle.cjs +1 -1
  43. package/dist-lib/metro-production-bundle.mjs +1 -1
  44. package/dist-lib/metro.cjs +37 -220
  45. package/dist-lib/native-app-identity.cjs +1 -1
  46. package/dist-lib/native-app-identity.mjs +1 -1
  47. package/dist-lib/native-firebase-metadata.cjs +1 -1
  48. package/dist-lib/native-firebase-metadata.mjs +1 -1
  49. package/dist-lib/plist.cjs +1 -1
  50. package/dist-lib/plist.mjs +1 -1
  51. package/dist-lib/profiles.cjs +1 -1
  52. package/dist-lib/public-brand.cjs +1 -1
  53. package/dist-lib/react-native-host-modules.cjs +1 -1
  54. package/dist-lib/react-native-host-modules.mjs +1 -1
  55. package/dist-lib/render-mode.cjs +1 -1
  56. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  57. package/dist-lib/sdk.cjs +1 -1
  58. package/dist-lib/sdk.mjs +1 -1
  59. package/dist-lib/skills.cjs +1185 -1026
  60. package/dist-lib/swift-compile.cjs +66 -8
  61. package/dist-lib/swift-compile.mjs +66 -8
  62. package/dist-lib/swift-package.cjs +1 -110
  63. package/dist-lib/swift-package.mjs +1 -109
  64. package/dist-lib/swift-submit.cjs +1 -1
  65. package/dist-lib/swift-submit.mjs +1 -1
  66. package/dist-lib/swift-toolchain.cjs +1 -1
  67. package/dist-lib/swift.cjs +1 -1
  68. package/dist-lib/vite-swift.cjs +672 -519
  69. package/dist-lib/vite.cjs +1 -1
  70. package/package.json +1 -1
  71. package/src/native-seam-manifest.ts +8 -0
  72. package/src/swift-compile.ts +102 -12
  73. package/src/swift-host.ts +64 -64
  74. package/src/swift-package-manifest.ts +307 -0
  75. package/src/swift-package.ts +2 -135
  76. package/src/swift-packages.ts +341 -0
  77. package/src/xcode-project.ts +57 -70
  78. package/src/swift-remote-packages.ts +0 -255
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.759 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.761 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -2689,8 +2689,8 @@ function metroIosAssetDestRelatives(httpServerLocation, filename) {
2689
2689
  }
2690
2690
  const out = [];
2691
2691
  for (const dir of dirs) {
2692
- const path21 = `${dir}/${filename}`;
2693
- if (!out.includes(path21)) out.push(path21);
2692
+ const path22 = `${dir}/${filename}`;
2693
+ if (!out.includes(path22)) out.push(path22);
2694
2694
  }
2695
2695
  if (!out.includes(filename)) out.push(filename);
2696
2696
  return out;
@@ -3644,13 +3644,13 @@ function readFactoryStringLiterals(factory) {
3644
3644
  return literals;
3645
3645
  }
3646
3646
  function normalizeFingerprintLiteral(literal) {
3647
- const path21 = literal.replaceAll("\\\\", "/").replaceAll("\\/", "/");
3647
+ const path22 = literal.replaceAll("\\\\", "/").replaceAll("\\/", "/");
3648
3648
  const nodeModulesMarker = "/node_modules/";
3649
- const nodeModulesIndex = path21.lastIndexOf(nodeModulesMarker);
3649
+ const nodeModulesIndex = path22.lastIndexOf(nodeModulesMarker);
3650
3650
  if (nodeModulesIndex >= 0) {
3651
- return `node_modules/${path21.slice(nodeModulesIndex + nodeModulesMarker.length)}`;
3651
+ return `node_modules/${path22.slice(nodeModulesIndex + nodeModulesMarker.length)}`;
3652
3652
  }
3653
- if ((path21.startsWith("/") || /^[A-Za-z]:\//.test(path21) || path21.startsWith("file:/")) && /\.[cm]?[jt]sx?(?::\d+(?::\d+)?)?$/.test(path21)) {
3653
+ if ((path22.startsWith("/") || /^[A-Za-z]:\//.test(path22) || path22.startsWith("file:/")) && /\.[cm]?[jt]sx?(?::\d+(?::\d+)?)?$/.test(path22)) {
3654
3654
  return null;
3655
3655
  }
3656
3656
  return literal;
@@ -3888,10 +3888,10 @@ function templateAssignment(template, embeddings) {
3888
3888
  if (existingNode !== void 0 && existingNode !== nodeIndex) return null;
3889
3889
  nodesByModuleId.set(moduleId, nodeIndex);
3890
3890
  const node = template.nodes[nodeIndex];
3891
- const path21 = node.landmarkPath ?? `node_modules/${template.packageName}/__rnx_inferred__/${moduleId}.js`;
3891
+ const path22 = node.landmarkPath ?? `node_modules/${template.packageName}/__rnx_inferred__/${moduleId}.js`;
3892
3892
  const existingPath = pathsByModuleId.get(moduleId);
3893
- if (existingPath !== void 0 && existingPath !== path21) return null;
3894
- pathsByModuleId.set(moduleId, path21);
3893
+ if (existingPath !== void 0 && existingPath !== path22) return null;
3894
+ pathsByModuleId.set(moduleId, path22);
3895
3895
  }
3896
3896
  }
3897
3897
  return {
@@ -4053,14 +4053,14 @@ async function inferMetroModuleIdentity(args) {
4053
4053
  const packageClaims = claimsByPackage.values().next().value;
4054
4054
  if (!packageClaims) continue;
4055
4055
  const exactClaims = packageClaims.filter((assignment2) => {
4056
- const path21 = assignment2.pathsByModuleId.get(moduleId);
4057
- return path21 !== void 0 && !path21.includes("/__rnx_inferred__/");
4056
+ const path22 = assignment2.pathsByModuleId.get(moduleId);
4057
+ return path22 !== void 0 && !path22.includes("/__rnx_inferred__/");
4058
4058
  });
4059
4059
  const preferredClaims = exactClaims.length > 0 ? exactClaims : packageClaims;
4060
4060
  const routes = new Set(
4061
4061
  preferredClaims.flatMap((assignment2) => {
4062
- const path21 = assignment2.pathsByModuleId.get(moduleId);
4063
- return path21 ? [metroFingerprintModuleClaimRoute(assignment2.packageName, path21)] : [];
4062
+ const path22 = assignment2.pathsByModuleId.get(moduleId);
4063
+ return path22 ? [metroFingerprintModuleClaimRoute(assignment2.packageName, path22)] : [];
4064
4064
  })
4065
4065
  );
4066
4066
  if (routes.size !== 1) continue;
@@ -4260,8 +4260,8 @@ function detectFramework(deps) {
4260
4260
  return "unknown";
4261
4261
  }
4262
4262
  function detectProject(dir) {
4263
- const pkgPath = (0, import_node_path25.join)(dir, "package.json");
4264
- if (!(0, import_node_fs24.existsSync)(pkgPath)) return null;
4263
+ const pkgPath = (0, import_node_path26.join)(dir, "package.json");
4264
+ if (!(0, import_node_fs25.existsSync)(pkgPath)) return null;
4265
4265
  const pkg = readProjectManifest(dir);
4266
4266
  if (!pkg) return null;
4267
4267
  const deps = { ...pkg.dependencies, ...pkg.devDependencies };
@@ -4273,25 +4273,25 @@ function detectProject(dir) {
4273
4273
  if (framework === "unknown") return null;
4274
4274
  return {
4275
4275
  dir,
4276
- name: pkg.name || (0, import_node_path25.basename)(dir),
4276
+ name: pkg.name || (0, import_node_path26.basename)(dir),
4277
4277
  framework,
4278
4278
  // a config file is a config file whatever module system it declares. real
4279
4279
  // apps write .cjs as often as .js, and missing one reads as "this project
4280
4280
  // has no bundler config" and sends the user to create a second one.
4281
4281
  hasViteConfig: CONFIG_EXTENSIONS.some(
4282
- (ext) => (0, import_node_fs24.existsSync)((0, import_node_path25.join)(dir, `vite.config.${ext}`))
4282
+ (ext) => (0, import_node_fs25.existsSync)((0, import_node_path26.join)(dir, `vite.config.${ext}`))
4283
4283
  ),
4284
4284
  hasMetroConfig: CONFIG_EXTENSIONS.some(
4285
- (ext) => (0, import_node_fs24.existsSync)((0, import_node_path25.join)(dir, `metro.config.${ext}`))
4285
+ (ext) => (0, import_node_fs25.existsSync)((0, import_node_path26.join)(dir, `metro.config.${ext}`))
4286
4286
  ),
4287
4287
  devCommand: typeof devCommand === "string" ? devCommand : null
4288
4288
  };
4289
4289
  }
4290
- function readProjectMetadata(path21) {
4290
+ function readProjectMetadata(path22) {
4291
4291
  try {
4292
- const info = (0, import_node_fs24.lstatSync)(path21);
4292
+ const info = (0, import_node_fs25.lstatSync)(path22);
4293
4293
  if (!info.isFile() || info.size > 4 * 1024 * 1024) return null;
4294
- return (0, import_node_fs24.readFileSync)(path21, "utf8");
4294
+ return (0, import_node_fs25.readFileSync)(path22, "utf8");
4295
4295
  } catch {
4296
4296
  return null;
4297
4297
  }
@@ -4300,8 +4300,8 @@ function metadataValue(value, key) {
4300
4300
  if (!value || typeof value !== "object") return void 0;
4301
4301
  return Object.getOwnPropertyDescriptor(value, key)?.value;
4302
4302
  }
4303
- function readProjectJson(path21) {
4304
- const text2 = readProjectMetadata(path21);
4303
+ function readProjectJson(path22) {
4304
+ const text2 = readProjectMetadata(path22);
4305
4305
  if (text2 === null) return null;
4306
4306
  try {
4307
4307
  const value = JSON.parse(text2);
@@ -4311,9 +4311,9 @@ function readProjectJson(path21) {
4311
4311
  }
4312
4312
  }
4313
4313
  function readProjectManifest(dir) {
4314
- const parsed = readProjectJson((0, import_node_path25.join)(dir, "package.json"));
4314
+ const parsed = readProjectJson((0, import_node_path26.join)(dir, "package.json"));
4315
4315
  if (!parsed || typeof parsed !== "object") return null;
4316
- const record = (value) => {
4316
+ const record2 = (value) => {
4317
4317
  if (!value || typeof value !== "object") return {};
4318
4318
  return Object.fromEntries(
4319
4319
  Object.entries(value).filter(
@@ -4324,16 +4324,16 @@ function readProjectManifest(dir) {
4324
4324
  const name2 = metadataValue(parsed, "name");
4325
4325
  return {
4326
4326
  ...typeof name2 === "string" ? { name: name2 } : {},
4327
- dependencies: record(metadataValue(parsed, "dependencies")),
4328
- devDependencies: record(metadataValue(parsed, "devDependencies"))
4327
+ dependencies: record2(metadataValue(parsed, "dependencies")),
4328
+ devDependencies: record2(metadataValue(parsed, "devDependencies"))
4329
4329
  };
4330
4330
  }
4331
- var import_node_fs24, import_node_path25, import_json52, import_yaml, CONFIG_EXTENSIONS;
4331
+ var import_node_fs25, import_node_path26, import_json52, import_yaml, CONFIG_EXTENSIONS;
4332
4332
  var init_detect = __esm({
4333
4333
  "cli/commands/detect.ts"() {
4334
4334
  "use strict";
4335
- import_node_fs24 = require("node:fs");
4336
- import_node_path25 = require("node:path");
4335
+ import_node_fs25 = require("node:fs");
4336
+ import_node_path26 = require("node:path");
4337
4337
  import_json52 = __toESM(require("json5"), 1);
4338
4338
  import_yaml = require("yaml");
4339
4339
  CONFIG_EXTENSIONS = ["ts", "js", "cjs", "mjs", "mts", "cts"];
@@ -4370,21 +4370,21 @@ function resolveCloudOrigin(value) {
4370
4370
  return normalizeCloudOrigin(source);
4371
4371
  }
4372
4372
  function readImmutableBundleSource(bundlePath) {
4373
- const filepath = (0, import_node_path26.resolve)(bundlePath);
4374
- if ((0, import_node_path26.extname)(filepath) !== ".js") {
4373
+ const filepath = (0, import_node_path27.resolve)(bundlePath);
4374
+ if ((0, import_node_path27.extname)(filepath) !== ".js") {
4375
4375
  throw new Error(`${REMOTE_COMMAND} requires one local Metro .js bundle`);
4376
4376
  }
4377
- const descriptor = (0, import_node_fs25.openSync)(filepath, "r");
4377
+ const descriptor = (0, import_node_fs26.openSync)(filepath, "r");
4378
4378
  try {
4379
- const before = (0, import_node_fs25.fstatSync)(descriptor, { bigint: true });
4379
+ const before = (0, import_node_fs26.fstatSync)(descriptor, { bigint: true });
4380
4380
  if (!before.isFile()) {
4381
4381
  throw new Error(`${REMOTE_COMMAND} bundle must be a regular local file`);
4382
4382
  }
4383
4383
  if (before.size <= 0n) {
4384
4384
  throw new Error(`${REMOTE_COMMAND} bundle is empty`);
4385
4385
  }
4386
- const bytes = (0, import_node_fs25.readFileSync)(descriptor);
4387
- const after = (0, import_node_fs25.fstatSync)(descriptor, { bigint: true });
4386
+ const bytes = (0, import_node_fs26.readFileSync)(descriptor);
4387
+ const after = (0, import_node_fs26.fstatSync)(descriptor, { bigint: true });
4388
4388
  if (before.dev !== after.dev || before.ino !== after.ino || before.size !== after.size || before.mtimeNs !== after.mtimeNs || bytes.length !== Number(before.size)) {
4389
4389
  throw new Error(`${REMOTE_COMMAND} bundle changed while it was being read`);
4390
4390
  }
@@ -4399,7 +4399,7 @@ function readImmutableBundleSource(bundlePath) {
4399
4399
  }
4400
4400
  return source;
4401
4401
  } finally {
4402
- (0, import_node_fs25.closeSync)(descriptor);
4402
+ (0, import_node_fs26.closeSync)(descriptor);
4403
4403
  }
4404
4404
  }
4405
4405
  async function fetchBundleSource(bundleUrl) {
@@ -4446,15 +4446,15 @@ async function loadBundleSource(bundleInput) {
4446
4446
  return readImmutableBundleSource(bundleInput);
4447
4447
  }
4448
4448
  function listMetroAssetDest(assetsPath) {
4449
- const directory = (0, import_node_path26.resolve)(assetsPath);
4450
- if (!(0, import_node_fs25.existsSync)(directory)) return { directory, files: [], truncated: false };
4451
- const skipNested = (0, import_node_fs25.existsSync)((0, import_node_path26.join)(directory, "package.json"));
4449
+ const directory = (0, import_node_path27.resolve)(assetsPath);
4450
+ if (!(0, import_node_fs26.existsSync)(directory)) return { directory, files: [], truncated: false };
4451
+ const skipNested = (0, import_node_fs26.existsSync)((0, import_node_path27.join)(directory, "package.json"));
4452
4452
  const files = [];
4453
4453
  let truncated = false;
4454
4454
  const walk2 = (dir, prefix) => {
4455
4455
  let entries;
4456
4456
  try {
4457
- entries = (0, import_node_fs25.readdirSync)(dir, { withFileTypes: true });
4457
+ entries = (0, import_node_fs26.readdirSync)(dir, { withFileTypes: true });
4458
4458
  } catch {
4459
4459
  return;
4460
4460
  }
@@ -4466,7 +4466,7 @@ function listMetroAssetDest(assetsPath) {
4466
4466
  if (entry.isDirectory()) {
4467
4467
  if (entry.name === ".git") continue;
4468
4468
  if (skipNested && PROJECT_ONLY_DIRECTORIES.has(entry.name)) continue;
4469
- walk2((0, import_node_path26.join)(dir, entry.name), prefix ? `${prefix}/${entry.name}` : entry.name);
4469
+ walk2((0, import_node_path27.join)(dir, entry.name), prefix ? `${prefix}/${entry.name}` : entry.name);
4470
4470
  } else if (entry.isFile()) {
4471
4471
  files.push(prefix ? `${prefix}/${entry.name}` : entry.name);
4472
4472
  }
@@ -4476,7 +4476,7 @@ function listMetroAssetDest(assetsPath) {
4476
4476
  return { directory, files, truncated };
4477
4477
  }
4478
4478
  function metroDescriptorHash(scaleBytes) {
4479
- const hasher = (0, import_node_crypto11.createHash)("md5");
4479
+ const hasher = (0, import_node_crypto12.createHash)("md5");
4480
4480
  for (const bytes of scaleBytes) hasher.update(bytes);
4481
4481
  return hasher.digest("hex");
4482
4482
  }
@@ -4501,11 +4501,11 @@ function distinctByContent(directory, options) {
4501
4501
  for (const relative2 of options) {
4502
4502
  let bytes;
4503
4503
  try {
4504
- bytes = (0, import_node_fs25.readFileSync)((0, import_node_path26.join)(directory, relative2));
4504
+ bytes = (0, import_node_fs26.readFileSync)((0, import_node_path27.join)(directory, relative2));
4505
4505
  } catch {
4506
4506
  continue;
4507
4507
  }
4508
- const digest = (0, import_node_crypto11.createHash)("md5").update(bytes).digest("hex");
4508
+ const digest = (0, import_node_crypto12.createHash)("md5").update(bytes).digest("hex");
4509
4509
  if (!byContent.has(digest)) byContent.set(digest, relative2);
4510
4510
  }
4511
4511
  return [...byContent.values()];
@@ -4533,13 +4533,13 @@ function placeMetroDescriptor(listing, descriptor) {
4533
4533
  let bytes;
4534
4534
  try {
4535
4535
  bytes = combination.map(
4536
- (relative2) => (0, import_node_fs25.readFileSync)((0, import_node_path26.join)(listing.directory, relative2))
4536
+ (relative2) => (0, import_node_fs26.readFileSync)((0, import_node_path27.join)(listing.directory, relative2))
4537
4537
  );
4538
4538
  } catch {
4539
4539
  continue;
4540
4540
  }
4541
4541
  const identical = fileHashes ? bytes.every((file, index) => {
4542
- const digest = (0, import_node_crypto11.createHash)("md5").update(file).digest("hex");
4542
+ const digest = (0, import_node_crypto12.createHash)("md5").update(file).digest("hex");
4543
4543
  return descriptor.scales.some(
4544
4544
  (scale, declared) => scale === scales[index] && fileHashes[declared] === digest
4545
4545
  );
@@ -4561,10 +4561,10 @@ function unverifiedContentKey(dest, fileDigests) {
4561
4561
  return JSON.stringify(
4562
4562
  dest.placements.map(
4563
4563
  (placement) => placement.verified ? null : [...placement.files].map(([scale, relative2]) => {
4564
- const file = (0, import_node_path26.join)(dest.directory, relative2);
4564
+ const file = (0, import_node_path27.join)(dest.directory, relative2);
4565
4565
  let digest = fileDigests.get(file);
4566
4566
  if (digest === void 0) {
4567
- digest = (0, import_node_crypto11.createHash)("sha256").update((0, import_node_fs25.readFileSync)(file)).digest("hex");
4567
+ digest = (0, import_node_crypto12.createHash)("sha256").update((0, import_node_fs26.readFileSync)(file)).digest("hex");
4568
4568
  fileDigests.set(file, digest);
4569
4569
  }
4570
4570
  return [scale, digest];
@@ -4573,22 +4573,22 @@ function unverifiedContentKey(dest, fileDigests) {
4573
4573
  );
4574
4574
  }
4575
4575
  function searchMetroAssetDest(bundlePath, descriptors) {
4576
- const bundleDirectory = (0, import_node_path26.dirname)((0, import_node_path26.resolve)(bundlePath));
4576
+ const bundleDirectory = (0, import_node_path27.dirname)((0, import_node_path27.resolve)(bundlePath));
4577
4577
  const candidates = [
4578
- (0, import_node_path26.join)(bundleDirectory, "assets"),
4578
+ (0, import_node_path27.join)(bundleDirectory, "assets"),
4579
4579
  bundleDirectory,
4580
- (0, import_node_path26.resolve)(bundleDirectory, "..", "assets")
4580
+ (0, import_node_path27.resolve)(bundleDirectory, "..", "assets")
4581
4581
  ];
4582
4582
  const cwd = process.cwd();
4583
4583
  let projectDirectory = null;
4584
4584
  for (const start of [bundleDirectory, cwd]) {
4585
- let directory = (0, import_node_path26.resolve)(start);
4585
+ let directory = (0, import_node_path27.resolve)(start);
4586
4586
  while (true) {
4587
4587
  if (detectProject(directory)?.hasMetroConfig) {
4588
4588
  projectDirectory = directory;
4589
4589
  break;
4590
4590
  }
4591
- const parent = (0, import_node_path26.dirname)(directory);
4591
+ const parent = (0, import_node_path27.dirname)(directory);
4592
4592
  if (parent === directory) break;
4593
4593
  directory = parent;
4594
4594
  }
@@ -4596,11 +4596,11 @@ function searchMetroAssetDest(bundlePath, descriptors) {
4596
4596
  }
4597
4597
  if (projectDirectory) {
4598
4598
  candidates.push(
4599
- (0, import_node_path26.join)(projectDirectory, "assets"),
4600
- (0, import_node_path26.join)(projectDirectory, "dist"),
4601
- (0, import_node_path26.join)(projectDirectory, "dist", "assets"),
4602
- (0, import_node_path26.join)(projectDirectory, "build"),
4603
- (0, import_node_path26.join)(projectDirectory, "build", "assets")
4599
+ (0, import_node_path27.join)(projectDirectory, "assets"),
4600
+ (0, import_node_path27.join)(projectDirectory, "dist"),
4601
+ (0, import_node_path27.join)(projectDirectory, "dist", "assets"),
4602
+ (0, import_node_path27.join)(projectDirectory, "build"),
4603
+ (0, import_node_path27.join)(projectDirectory, "build", "assets")
4604
4604
  );
4605
4605
  }
4606
4606
  const searched = [];
@@ -4608,7 +4608,7 @@ function searchMetroAssetDest(bundlePath, descriptors) {
4608
4608
  const stale = [];
4609
4609
  let truncated = false;
4610
4610
  for (const candidate of candidates) {
4611
- const directory = (0, import_node_path26.resolve)(candidate);
4611
+ const directory = (0, import_node_path27.resolve)(candidate);
4612
4612
  if (searched.includes(directory)) continue;
4613
4613
  searched.push(directory);
4614
4614
  const listing = listMetroAssetDest(directory);
@@ -4717,7 +4717,7 @@ async function embedBundleAssets(bundlePath, command, assetPolicy) {
4717
4717
  );
4718
4718
  }
4719
4719
  const relative2 = placement?.files.get(variant.scale);
4720
- if (relative2 && dest) return (0, import_node_fs25.readFileSync)((0, import_node_path26.join)(dest.directory, relative2));
4720
+ if (relative2 && dest) return (0, import_node_fs26.readFileSync)((0, import_node_path27.join)(dest.directory, relative2));
4721
4721
  if (placement && placement.files.size > 0) return null;
4722
4722
  if (placement && placement.ambiguous.length > 0 && dest) {
4723
4723
  throw new Error(
@@ -4746,7 +4746,7 @@ async function embedBundleAssets(bundlePath, command, assetPolicy) {
4746
4746
  );
4747
4747
  const classic = metroIosAssetDestRelatives(variant.descriptor.httpServerLocation, filename)[0] ?? filename;
4748
4748
  throw new Error(
4749
- `${command} could not read ${(0, import_node_path26.join)(dest?.directory ?? ".", classic)} for ${variant.descriptor.name}.${variant.descriptor.type} at scale ${variant.scale}, and has no stand-in for a .${variant.descriptor.type} asset. Rebuild with \`react-native bundle --assets-dest\`.`
4749
+ `${command} could not read ${(0, import_node_path27.join)(dest?.directory ?? ".", classic)} for ${variant.descriptor.name}.${variant.descriptor.type} at scale ${variant.scale}, and has no stand-in for a .${variant.descriptor.type} asset. Rebuild with \`react-native bundle --assets-dest\`.`
4750
4750
  );
4751
4751
  });
4752
4752
  return {
@@ -4787,7 +4787,7 @@ async function produceArtifact(bundlePath, maxBytes, command, assetPolicy) {
4787
4787
  }
4788
4788
  return {
4789
4789
  bytes,
4790
- sha256: (0, import_node_crypto11.createHash)("sha256").update(bytes).digest("hex"),
4790
+ sha256: (0, import_node_crypto12.createHash)("sha256").update(bytes).digest("hex"),
4791
4791
  receipt: artifact.receipt,
4792
4792
  assetsDirectory: prepared.dest?.directory ?? null,
4793
4793
  warnings
@@ -4892,13 +4892,13 @@ async function createCloudBox(options) {
4892
4892
  warnings: artifact.warnings
4893
4893
  };
4894
4894
  }
4895
- var import_node_crypto11, import_node_fs25, import_node_path26, DEFAULT_RNX_CLOUD_ORIGIN, MAX_RNX_CLOUD_BUNDLE_BYTES, REMOTE_COMMAND, MAX_ASSET_DEST_FILES, ACCOUNT_CHOICE_REFUSALS, PROJECT_ONLY_DIRECTORIES, MAX_PLACEMENT_COMBINATIONS;
4895
+ var import_node_crypto12, import_node_fs26, import_node_path27, DEFAULT_RNX_CLOUD_ORIGIN, MAX_RNX_CLOUD_BUNDLE_BYTES, REMOTE_COMMAND, MAX_ASSET_DEST_FILES, ACCOUNT_CHOICE_REFUSALS, PROJECT_ONLY_DIRECTORIES, MAX_PLACEMENT_COMBINATIONS;
4896
4896
  var init_cloud_client = __esm({
4897
4897
  "cli/cloud-client.ts"() {
4898
4898
  "use strict";
4899
- import_node_crypto11 = require("node:crypto");
4900
- import_node_fs25 = require("node:fs");
4901
- import_node_path26 = require("node:path");
4899
+ import_node_crypto12 = require("node:crypto");
4900
+ import_node_fs26 = require("node:fs");
4901
+ import_node_path27 = require("node:path");
4902
4902
  init_metroAssetArtifact();
4903
4903
  init_metroCloudArtifact();
4904
4904
  init_metro_fingerprint_registry_client();
@@ -5336,9 +5336,9 @@ function safeChildPlistName(value) {
5336
5336
  name: file.toLowerCase().endsWith(".plist") ? file : `${file}.plist`
5337
5337
  };
5338
5338
  }
5339
- async function readableSettingsBundle(path21) {
5339
+ async function readableSettingsBundle(path22) {
5340
5340
  try {
5341
- const root = await (0, import_promises.stat)((0, import_node_path.join)(path21, "Root.plist"));
5341
+ const root = await (0, import_promises.stat)((0, import_node_path.join)(path22, "Root.plist"));
5342
5342
  return root.isFile() && root.size <= MAX_PLIST_BYTES;
5343
5343
  } catch {
5344
5344
  return false;
@@ -5383,11 +5383,11 @@ async function settingsBundleFingerprint(bundlePath) {
5383
5383
  return null;
5384
5384
  }
5385
5385
  }
5386
- async function parsePlistRecord(path21) {
5386
+ async function parsePlistRecord(path22) {
5387
5387
  try {
5388
- const metadata = await (0, import_promises.stat)(path21);
5388
+ const metadata = await (0, import_promises.stat)(path22);
5389
5389
  if (!metadata.isFile() || metadata.size > MAX_PLIST_BYTES) return null;
5390
- const source = await (0, import_promises.readFile)(path21, "utf8");
5390
+ const source = await (0, import_promises.readFile)(path22, "utf8");
5391
5391
  const parsed = parsePlistSource(source);
5392
5392
  return isRecord2(parsed) ? parsed : null;
5393
5393
  } catch {
@@ -5649,7 +5649,7 @@ async function tcpPing(port, timeout = TCP_GATE_MS) {
5649
5649
  return null;
5650
5650
  }
5651
5651
  }
5652
- function httpGet(hostname, port, path21, method = "GET", timeout = TIMEOUT_MS, headers = {}) {
5652
+ function httpGet(hostname, port, path22, method = "GET", timeout = TIMEOUT_MS, headers = {}) {
5653
5653
  return new Promise((resolve5) => {
5654
5654
  let settled = false;
5655
5655
  let killing = false;
@@ -5658,7 +5658,7 @@ function httpGet(hostname, port, path21, method = "GET", timeout = TIMEOUT_MS, h
5658
5658
  settled = true;
5659
5659
  resolve5(value);
5660
5660
  };
5661
- const req = import_http.default.request({ hostname, port, path: path21, method, headers }, (res) => {
5661
+ const req = import_http.default.request({ hostname, port, path: path22, method, headers }, (res) => {
5662
5662
  let body = "";
5663
5663
  res.on("data", (c) => body += c.toString());
5664
5664
  const contentType = (() => {
@@ -6337,12 +6337,12 @@ function getCliVersion() {
6337
6337
  }
6338
6338
 
6339
6339
  // src/expo-swift-host.ts
6340
- var import_node_child_process7 = require("node:child_process");
6341
- var import_node_crypto6 = require("node:crypto");
6342
- var import_node_fs16 = __toESM(require("node:fs"), 1);
6340
+ var import_node_child_process8 = require("node:child_process");
6341
+ var import_node_crypto7 = require("node:crypto");
6342
+ var import_node_fs17 = __toESM(require("node:fs"), 1);
6343
6343
  var import_node_module = require("node:module");
6344
- var import_node_os6 = __toESM(require("node:os"), 1);
6345
- var import_node_path17 = __toESM(require("node:path"), 1);
6344
+ var import_node_os7 = __toESM(require("node:os"), 1);
6345
+ var import_node_path18 = __toESM(require("node:path"), 1);
6346
6346
  var import_node_util3 = require("node:util");
6347
6347
 
6348
6348
  // cli/internal-child.ts
@@ -6580,116 +6580,9 @@ function manifestCalls(manifest, kinds) {
6580
6580
  }
6581
6581
  return calls;
6582
6582
  }
6583
- var NAME = /\bname\s*:\s*"([^"]+)"/;
6584
- function listArgument(call, label) {
6585
- const start = new RegExp(`\\b${label}\\s*:\\s*\\[`).exec(call);
6586
- if (!start) return [];
6587
- const items2 = [];
6588
- let depth = 0;
6589
- let inString = false;
6590
- let item = "";
6591
- for (let i = start.index + start[0].length; i < call.length; i++) {
6592
- const ch = call[i];
6593
- if (inString) {
6594
- item += ch;
6595
- if (ch === '"' && call[i - 1] !== "\\") inString = false;
6596
- continue;
6597
- }
6598
- if (ch === '"') inString = true;
6599
- else if (ch === "(" || ch === "[") depth++;
6600
- else if (ch === ")" || ch === "]") {
6601
- if (depth === 0) break;
6602
- depth--;
6603
- } else if (ch === "," && depth === 0) {
6604
- items2.push(item.trim());
6605
- item = "";
6606
- continue;
6607
- }
6608
- item += ch;
6609
- }
6610
- if (item.trim()) items2.push(item.trim());
6611
- return items2;
6612
- }
6613
6583
  function swiftPackageIdentity(url) {
6614
6584
  return (url.split("/").pop() ?? url).replace(/\.git$/, "").toLowerCase();
6615
6585
  }
6616
- function swiftManifestGraph(manifest) {
6617
- const graph = {
6618
- products: /* @__PURE__ */ new Map(),
6619
- dependencies: /* @__PURE__ */ new Map(),
6620
- binaryTargets: /* @__PURE__ */ new Set(),
6621
- systemLibraries: /* @__PURE__ */ new Set(),
6622
- packageURLs: /* @__PURE__ */ new Map(),
6623
- packagePaths: []
6624
- };
6625
- for (const { kind, flat, call } of manifestCalls(manifest, [
6626
- "library",
6627
- "executableTarget",
6628
- "target",
6629
- "binaryTarget",
6630
- "systemLibrary",
6631
- "package"
6632
- ])) {
6633
- if (kind === "package") {
6634
- const local = /\bpath\s*:\s*"([^"]+)"/.exec(flat)?.[1];
6635
- if (local) graph.packagePaths.push(local);
6636
- const url = /\burl\s*:\s*"([^"]+)"/.exec(flat)?.[1];
6637
- if (!url) continue;
6638
- graph.packageURLs.set(swiftPackageIdentity(url), url);
6639
- const name3 = NAME.exec(flat)?.[1];
6640
- if (name3) graph.packageURLs.set(name3.toLowerCase(), url);
6641
- continue;
6642
- }
6643
- const name2 = NAME.exec(flat)?.[1];
6644
- if (!name2) continue;
6645
- if (kind === "library") {
6646
- graph.products.set(
6647
- name2,
6648
- listArgument(call, "targets").flatMap(
6649
- (item) => /^"([^"]+)"$/.exec(item)?.[1] ?? []
6650
- )
6651
- );
6652
- continue;
6653
- }
6654
- if (kind === "binaryTarget") graph.binaryTargets.add(name2);
6655
- if (kind === "systemLibrary") graph.systemLibraries.add(name2);
6656
- const dependencies = [];
6657
- for (const item of listArgument(call, "dependencies")) {
6658
- const platforms = /condition\s*:\s*\.when\(\s*platforms\s*:\s*\[([^\]]*)\]/.exec(
6659
- item
6660
- )?.[1];
6661
- if (platforms !== void 0 && !/\.iOS\b/.test(platforms)) continue;
6662
- if (/condition\s*:\s*\.when\([^)]*\btraits\s*:/.test(item)) continue;
6663
- const plain = /^"([^"]+)"$/.exec(item)?.[1];
6664
- const product = /^\.product(?:Item)?\(\s*name\s*:\s*"([^"]+)"\s*,\s*package\s*:\s*"([^"]+)"/.exec(
6665
- item
6666
- );
6667
- const target = /^\.(?:target|byName)(?:Item)?\(\s*name\s*:\s*"([^"]+)"/.exec(
6668
- item
6669
- )?.[1];
6670
- if (plain) dependencies.push({ kind: "target", name: plain });
6671
- else if (product)
6672
- dependencies.push({
6673
- kind: "product",
6674
- name: product[1],
6675
- package: product[2].toLowerCase()
6676
- });
6677
- else if (target) dependencies.push({ kind: "target", name: target });
6678
- }
6679
- graph.dependencies.set(name2, dependencies);
6680
- }
6681
- for (const dependencies of graph.dependencies.values()) {
6682
- for (const [index, dependency] of dependencies.entries()) {
6683
- if (dependency.kind === "target" && !graph.dependencies.has(dependency.name))
6684
- dependencies[index] = {
6685
- kind: "product",
6686
- name: dependency.name,
6687
- package: dependency.name.toLowerCase()
6688
- };
6689
- }
6690
- }
6691
- return graph;
6692
- }
6693
6586
  function swiftManifestTargets(manifest, resourcePaths = []) {
6694
6587
  const implicitResources = swiftImplicitResourcePaths(resourcePaths);
6695
6588
  const targets = [];
@@ -6875,14 +6768,72 @@ var OPTIONAL_FRAMEWORK_DEPENDENCIES = {
6875
6768
  };
6876
6769
  var OPTIONAL_FRAMEWORKS = new Set(Object.keys(OPTIONAL_FRAMEWORK_DEPENDENCIES));
6877
6770
  var SWIFT_IMPORT = /^\s*(?:@\w+(?:\([^)]*\))?\s+)*import\s+(?:(?:typealias|struct|class|enum|protocol|let|var|func)\s+)?([A-Za-z_][A-Za-z0-9_]*)/;
6878
- function swiftImportNames(contents, unconditional = false) {
6771
+ function swiftCondition(text2, available) {
6772
+ const tokens = text2.match(/\w+\s*\([^()]*\)|&&|\|\||!|\(|\)|\w+/g) ?? [];
6773
+ let index = 0;
6774
+ const atom = () => {
6775
+ const token = tokens[index++];
6776
+ if (token === "!") {
6777
+ const value = atom();
6778
+ return value === void 0 ? void 0 : !value;
6779
+ }
6780
+ if (token === "(") {
6781
+ const value = either();
6782
+ index++;
6783
+ return value;
6784
+ }
6785
+ if (token === "true") return true;
6786
+ if (token === "false") return false;
6787
+ const call = /^(\w+)\s*\(\s*([^,()]*?)\s*(?:,[^()]*)?\)$/.exec(token ?? "");
6788
+ if (!call) return void 0;
6789
+ const [, name2, argument] = call;
6790
+ if (name2 === "os") return argument === "iOS" || argument === "WASI";
6791
+ if (name2 === "canImport") return available.has(argument);
6792
+ if (name2 === "targetEnvironment") return false;
6793
+ if (name2 === "arch") return argument === "wasm32";
6794
+ return void 0;
6795
+ };
6796
+ const both = () => {
6797
+ let value = atom();
6798
+ while (tokens[index] === "&&") {
6799
+ index++;
6800
+ const next = atom();
6801
+ value = value === false || next === false ? false : value && next ? true : void 0;
6802
+ }
6803
+ return value;
6804
+ };
6805
+ const either = () => {
6806
+ let value = both();
6807
+ while (tokens[index] === "||") {
6808
+ index++;
6809
+ const next = both();
6810
+ value = value === true || next === true ? true : value === false && next === false ? false : void 0;
6811
+ }
6812
+ return value;
6813
+ };
6814
+ return either();
6815
+ }
6816
+ function swiftImportNames(contents, available) {
6879
6817
  const names = [];
6880
- let depth = 0;
6818
+ const frames = [];
6881
6819
  for (const line of contents.split("\n")) {
6882
- const directive = /^\s*#(if|endif)\b/.exec(line)?.[1];
6883
- if (directive === "if") depth++;
6884
- else if (directive === "endif") depth = Math.max(0, depth - 1);
6885
- if (unconditional && depth > 0) continue;
6820
+ const directive = /^\s*#(if|elseif|else|endif)\b(.*)$/.exec(line);
6821
+ if (directive && available) {
6822
+ const [, kind, rest] = directive;
6823
+ const condition = (rest ?? "").replace(/\/\/.*$/, "").trim();
6824
+ if (kind === "if") {
6825
+ const active = swiftCondition(condition, available);
6826
+ frames.push({ active, taken: active });
6827
+ } else if (kind === "endif") frames.pop();
6828
+ else if (frames.length > 0) {
6829
+ const frame = frames[frames.length - 1];
6830
+ const holds = kind === "else" ? true : swiftCondition(condition, available);
6831
+ frame.active = frame.taken === true ? false : frame.taken === false ? holds : holds && void 0;
6832
+ frame.taken = frame.taken === true || holds === true ? true : frame.taken === false ? holds : void 0;
6833
+ }
6834
+ continue;
6835
+ }
6836
+ if (available && frames.some((frame) => frame.active !== true)) continue;
6886
6837
  const name2 = SWIFT_IMPORT.exec(line)?.[1];
6887
6838
  if (name2) names.push(name2);
6888
6839
  }
@@ -6927,7 +6878,7 @@ function missingSwiftModules(files, available) {
6927
6878
  const missing = /* @__PURE__ */ new Map();
6928
6879
  for (const [file, contents] of Object.entries(files)) {
6929
6880
  if (!file.endsWith(".swift") || file === "Package.swift") continue;
6930
- for (const name2 of new Set(swiftImportNames(contents, true))) {
6881
+ for (const name2 of new Set(swiftImportNames(contents, available))) {
6931
6882
  if (available.has(name2)) continue;
6932
6883
  missing.set(name2, [...missing.get(name2) ?? [], file]);
6933
6884
  }
@@ -7149,21 +7100,21 @@ function scanObjCExtensionMembers(source, tokens, records) {
7149
7100
  const masked = swiftCodeMask(source);
7150
7101
  const found = /* @__PURE__ */ new Map();
7151
7102
  const member = /\b(func|var)\s+([A-Za-z_]\w*)/g;
7152
- for (const record of records) {
7153
- const close = closingBrace(source, tokens, record.open);
7154
- const body = masked.slice(record.open, close);
7103
+ for (const record2 of records) {
7104
+ const close = closingBrace(source, tokens, record2.open);
7105
+ const body = masked.slice(record2.open, close);
7155
7106
  member.lastIndex = 0;
7156
7107
  for (let match = member.exec(body); match; match = member.exec(body)) {
7157
- const at = record.open + match.index + match[0].indexOf(match[1]);
7108
+ const at = record2.open + match.index + match[0].indexOf(match[1]);
7158
7109
  let depth = 0;
7159
7110
  for (const token of tokens) {
7160
- if (token <= record.open) continue;
7111
+ if (token <= record2.open) continue;
7161
7112
  if (token >= at) break;
7162
7113
  if (source[token] === "{") depth++;
7163
7114
  else if (source[token] === "}") depth--;
7164
7115
  }
7165
7116
  if (depth > 0) continue;
7166
- const head = masked.slice(record.open, at);
7117
+ const head = masked.slice(record2.open, at);
7167
7118
  const bound = Math.max(
7168
7119
  head.lastIndexOf(";"),
7169
7120
  head.lastIndexOf("{"),
@@ -7174,11 +7125,11 @@ function scanObjCExtensionMembers(source, tokens, records) {
7174
7125
  prefix
7175
7126
  ))
7176
7127
  continue;
7177
- if (!/@objc\b/.test(prefix) && !/@IBAction\b/.test(prefix) && !record.objcMembers)
7128
+ if (!/@objc\b/.test(prefix) && !/@IBAction\b/.test(prefix) && !record2.objcMembers)
7178
7129
  continue;
7179
- const members = found.get(record.type) ?? /* @__PURE__ */ new Set();
7130
+ const members = found.get(record2.type) ?? /* @__PURE__ */ new Set();
7180
7131
  members.add(match[2]);
7181
- found.set(record.type, members);
7132
+ found.set(record2.type, members);
7182
7133
  }
7183
7134
  }
7184
7135
  return found;
@@ -8646,10 +8597,10 @@ function swiftModuleToolchain(root) {
8646
8597
  }
8647
8598
 
8648
8599
  // src/swift-host.ts
8649
- var import_node_crypto5 = require("node:crypto");
8650
- var import_node_fs15 = __toESM(require("node:fs"), 1);
8651
- var import_node_os5 = __toESM(require("node:os"), 1);
8652
- var import_node_path16 = __toESM(require("node:path"), 1);
8600
+ var import_node_crypto6 = require("node:crypto");
8601
+ var import_node_fs16 = __toESM(require("node:fs"), 1);
8602
+ var import_node_os6 = __toESM(require("node:os"), 1);
8603
+ var import_node_path17 = __toESM(require("node:path"), 1);
8653
8604
 
8654
8605
  // ../sootsim-swift/src/bundleAssets.ts
8655
8606
  var import_svgpath = __toESM(require("svgpath"), 1);
@@ -8683,8 +8634,8 @@ function pickImagesetFile(images) {
8683
8634
  scale: pick.scale === "2x" ? 2 : pick.scale === "3x" ? 3 : 1
8684
8635
  };
8685
8636
  }
8686
- function flatScale(path21) {
8687
- const match = /@([23])x\.[^./]+$/.exec(path21);
8637
+ function flatScale(path22) {
8638
+ const match = /@([23])x\.[^./]+$/.exec(path22);
8688
8639
  return match ? Number(match[1]) : 1;
8689
8640
  }
8690
8641
  function providesNamespace(text2) {
@@ -8711,13 +8662,13 @@ function catalogEntryName(contentsPath, kind, readText) {
8711
8662
  }
8712
8663
  return segments.join("/");
8713
8664
  }
8714
- function isFlatResourceImage(path21) {
8715
- return path21.split("/").includes("Resources") && RASTER_EXTENSIONS.has(extOf(path21));
8665
+ function isFlatResourceImage(path22) {
8666
+ return path22.split("/").includes("Resources") && RASTER_EXTENSIONS.has(extOf(path22));
8716
8667
  }
8717
8668
  function enumerateBundleImages(paths, readText) {
8718
8669
  const table = [];
8719
8670
  const seen = /* @__PURE__ */ new Set();
8720
- const catalogs = paths.filter((path21) => baseOf(path21) === "Contents.json");
8671
+ const catalogs = paths.filter((path22) => baseOf(path22) === "Contents.json");
8721
8672
  for (const contentsPath of catalogs) {
8722
8673
  const name2 = catalogEntryName(contentsPath, ".imageset", readText);
8723
8674
  if (name2 === null || seen.has(name2)) continue;
@@ -8738,12 +8689,12 @@ function enumerateBundleImages(paths, readText) {
8738
8689
  seen.add(name2);
8739
8690
  table.push({ name: name2, file: `${dir}/${pick.filename}`, scale: pick.scale });
8740
8691
  }
8741
- for (const path21 of paths) {
8742
- if (!isFlatResourceImage(path21)) continue;
8743
- const name2 = baseOf(path21).slice(0, -extOf(path21).length);
8692
+ for (const path22 of paths) {
8693
+ if (!isFlatResourceImage(path22)) continue;
8694
+ const name2 = baseOf(path22).slice(0, -extOf(path22).length);
8744
8695
  if (name2 === "" || seen.has(name2)) continue;
8745
8696
  seen.add(name2);
8746
- table.push({ name: name2, file: path21, scale: flatScale(path21) });
8697
+ table.push({ name: name2, file: path22, scale: flatScale(path22) });
8747
8698
  }
8748
8699
  return table;
8749
8700
  }
@@ -8772,7 +8723,7 @@ function colorsetValue(color) {
8772
8723
  }
8773
8724
  function enumerateBundleColors(paths, readText) {
8774
8725
  const table = {};
8775
- for (const contentsPath of paths.filter((path21) => baseOf(path21) === "Contents.json")) {
8726
+ for (const contentsPath of paths.filter((path22) => baseOf(path22) === "Contents.json")) {
8776
8727
  const name2 = catalogEntryName(contentsPath, ".colorset", readText);
8777
8728
  if (name2 === null || name2 in table) continue;
8778
8729
  let colors;
@@ -8812,11 +8763,11 @@ var SYMBOL_CAP_HEIGHT_EM = 1443 / 2048;
8812
8763
  function axisExtremes(points) {
8813
8764
  const [a = 0, b = 0, c = 0, d] = points;
8814
8765
  const out = [a, d ?? c];
8815
- const within = (t) => t > 0 && t < 1;
8766
+ const within2 = (t) => t > 0 && t < 1;
8816
8767
  if (d === void 0) {
8817
8768
  const denom = a - 2 * b + c;
8818
8769
  const t = denom === 0 ? -1 : (a - b) / denom;
8819
- if (within(t)) out.push((1 - t) ** 2 * a + 2 * (1 - t) * t * b + t ** 2 * c);
8770
+ if (within2(t)) out.push((1 - t) ** 2 * a + 2 * (1 - t) * t * b + t ** 2 * c);
8820
8771
  return out;
8821
8772
  }
8822
8773
  const qa = 3 * (-a + 3 * b - 3 * c + d);
@@ -8828,7 +8779,7 @@ function axisExtremes(points) {
8828
8779
  const root = Math.sqrt(disc);
8829
8780
  return [(-qb + root) / (2 * qa), (-qb - root) / (2 * qa)];
8830
8781
  })();
8831
- for (const t of roots.filter(within))
8782
+ for (const t of roots.filter(within2))
8832
8783
  out.push(
8833
8784
  (1 - t) ** 3 * a + 3 * (1 - t) ** 2 * t * b + 3 * (1 - t) * t ** 2 * c + t ** 3 * d
8834
8785
  );
@@ -8837,8 +8788,8 @@ function axisExtremes(points) {
8837
8788
  function pathBounds(d) {
8838
8789
  const xs = [];
8839
8790
  const ys = [];
8840
- for (const path21 of d)
8841
- (0, import_svgpath.default)(path21).abs().unshort().unarc().iterate((segment, _index, x, y) => {
8791
+ for (const path22 of d)
8792
+ (0, import_svgpath.default)(path22).abs().unshort().unarc().iterate((segment, _index, x, y) => {
8842
8793
  const [command, ...args] = segment;
8843
8794
  if (command === "M" || command === "L") {
8844
8795
  xs.push(Number(args[0]));
@@ -8865,7 +8816,7 @@ function guide(svg, id, axis) {
8865
8816
  }
8866
8817
  function enumerateBundleSymbols(paths, readText) {
8867
8818
  const table = {};
8868
- for (const contentsPath of paths.filter((path21) => baseOf(path21) === "Contents.json")) {
8819
+ for (const contentsPath of paths.filter((path22) => baseOf(path22) === "Contents.json")) {
8869
8820
  const name2 = catalogEntryName(contentsPath, ".symbolset", readText);
8870
8821
  if (name2 === null || name2 in table) continue;
8871
8822
  let symbols;
@@ -8898,8 +8849,8 @@ function enumerateBundleSymbols(paths, readText) {
8898
8849
  viewBox: "0 0 24 24",
8899
8850
  advance,
8900
8851
  box: [12 - advance / 2, 12 - tall / 2, advance, tall],
8901
- layers: d.map((path21) => ({
8902
- d: (0, import_svgpath.default)(path21).abs().scale(scale).translate(translateX, translateY).round(3).toString()
8852
+ layers: d.map((path22) => ({
8853
+ d: (0, import_svgpath.default)(path22).abs().scale(scale).translate(translateX, translateY).round(3).toString()
8903
8854
  }))
8904
8855
  };
8905
8856
  }
@@ -8909,7 +8860,7 @@ function enumerateBundleJson(paths) {
8909
8860
  const found = [];
8910
8861
  const seen = /* @__PURE__ */ new Set();
8911
8862
  const ordered = [...paths].filter(
8912
- (path21) => path21.split("/").includes("Resources") && path21.split("/").every((segment) => segment !== "" && segment !== "..") && (extOf(path21) === ".json" || extOf(path21) === ".xcstrings")
8863
+ (path22) => path22.split("/").includes("Resources") && path22.split("/").every((segment) => segment !== "" && segment !== "..") && (extOf(path22) === ".json" || extOf(path22) === ".xcstrings")
8913
8864
  ).sort((a, b) => {
8914
8865
  const aDepth = a.split("/").length;
8915
8866
  const bDepth = b.split("/").length;
@@ -8928,14 +8879,225 @@ function enumerateBundleJson(paths) {
8928
8879
  init_auth();
8929
8880
  init_backend_origin();
8930
8881
 
8931
- // src/swift-remote-packages.ts
8882
+ // src/swift-packages.ts
8883
+ var import_node_child_process7 = require("node:child_process");
8884
+ var import_node_fs14 = __toESM(require("node:fs"), 1);
8885
+ var import_node_path14 = __toESM(require("node:path"), 1);
8886
+
8887
+ // src/swift-package-manifest.ts
8932
8888
  var import_node_child_process6 = require("node:child_process");
8889
+ var import_node_crypto5 = require("node:crypto");
8933
8890
  var import_node_fs13 = __toESM(require("node:fs"), 1);
8891
+ var import_node_os5 = __toESM(require("node:os"), 1);
8934
8892
  var import_node_path13 = __toESM(require("node:path"), 1);
8935
- var REMOTE_CHECKOUTS = import_node_path13.default.join(".build", "peach", "checkouts");
8893
+ var TARGET_TYPES = [
8894
+ "regular",
8895
+ "executable",
8896
+ "test",
8897
+ "binary",
8898
+ "system",
8899
+ "macro",
8900
+ "plugin"
8901
+ ];
8902
+ var isTargetType = (value) => TARGET_TYPES.some((type) => type === value);
8903
+ var record = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
8904
+ var array = (value) => Array.isArray(value) ? value : [];
8905
+ var string = (value) => typeof value === "string" ? value : void 0;
8906
+ function swiftCommand() {
8907
+ return process.platform === "darwin" ? { file: "xcrun", args: ["swift"] } : { file: import_node_path13.default.join(swiftToolchainBin(swift_distribution_lock_default.release), "swift"), args: [] };
8908
+ }
8909
+ var cacheDir2 = import_node_path13.default.join(import_node_os5.default.tmpdir(), "peach-swift-manifests");
8910
+ var evaluated = /* @__PURE__ */ new Map();
8911
+ function dump(dir) {
8912
+ const manifests = import_node_fs13.default.readdirSync(dir).filter((name2) => /^Package(@swift-[\d.]+)?\.swift$/.test(name2)).sort();
8913
+ const command = swiftCommand();
8914
+ const key = (0, import_node_crypto5.createHash)("sha256").update(JSON.stringify([command, import_node_path13.default.resolve(dir)])).update(
8915
+ manifests.map((name2) => `${name2}\0${import_node_fs13.default.readFileSync(import_node_path13.default.join(dir, name2), "utf8")}`).join("\0")
8916
+ ).digest("hex").slice(0, 32);
8917
+ const cached3 = import_node_path13.default.join(cacheDir2, `${key}.json`);
8918
+ if (import_node_fs13.default.existsSync(cached3))
8919
+ return { key, raw: record(JSON.parse(import_node_fs13.default.readFileSync(cached3, "utf8"))) };
8920
+ let output;
8921
+ try {
8922
+ output = (0, import_node_child_process6.execFileSync)(
8923
+ command.file,
8924
+ [
8925
+ ...command.args,
8926
+ "package",
8927
+ "--package-path",
8928
+ dir,
8929
+ // swiftpm's scratch files never land in the app's own package
8930
+ "--scratch-path",
8931
+ import_node_path13.default.join(cacheDir2, `${key}.build`),
8932
+ "dump-package"
8933
+ ],
8934
+ {
8935
+ encoding: "utf8",
8936
+ stdio: ["ignore", "pipe", "pipe"],
8937
+ maxBuffer: 64 * 1024 * 1024
8938
+ }
8939
+ );
8940
+ } catch (error) {
8941
+ const stderr = error instanceof Error && "stderr" in error ? String(error.stderr).trim() : "";
8942
+ throw new Error(
8943
+ `swiftpm could not evaluate ${import_node_path13.default.join(dir, "Package.swift")}${stderr ? `: ${stderr}` : ""}`
8944
+ );
8945
+ }
8946
+ import_node_fs13.default.mkdirSync(cacheDir2, { recursive: true });
8947
+ import_node_fs13.default.writeFileSync(cached3, output);
8948
+ return { key, raw: record(JSON.parse(output)) };
8949
+ }
8950
+ function defaultTraits(manifest) {
8951
+ const traits = new Map(
8952
+ array(manifest.traits).map((trait) => [
8953
+ string(record(trait).name) ?? "",
8954
+ array(record(trait).enabledTraits).flatMap((name2) => string(name2) ?? [])
8955
+ ])
8956
+ );
8957
+ const enabled = /* @__PURE__ */ new Set();
8958
+ const pending = [...traits.get("default") ?? []];
8959
+ while (pending.length > 0) {
8960
+ const name2 = pending.pop();
8961
+ if (enabled.has(name2)) continue;
8962
+ enabled.add(name2);
8963
+ pending.push(...traits.get(name2) ?? []);
8964
+ }
8965
+ return enabled;
8966
+ }
8967
+ function linksOnIOS(condition, traits) {
8968
+ const { platformNames, traits: needed } = record(condition);
8969
+ const platforms = array(platformNames);
8970
+ if (platforms.length > 0 && !platforms.includes("ios")) return false;
8971
+ const gates = array(needed);
8972
+ return gates.length === 0 || gates.some((name2) => traits.has(string(name2) ?? ""));
8973
+ }
8974
+ function swiftPackageManifest(dir) {
8975
+ dir = import_node_fs13.default.realpathSync(dir);
8976
+ const { key, raw: raw2 } = dump(dir);
8977
+ const known = evaluated.get(key);
8978
+ if (known) return known;
8979
+ const traits = defaultTraits(raw2);
8980
+ const tools = Number(
8981
+ /^(\d+)/.exec(string(record(raw2.toolsVersion)._version) ?? "5")?.[1] ?? 5
8982
+ );
8983
+ const declaredModes = array(raw2.swiftLanguageVersions).flatMap((mode) => {
8984
+ const major = Number(/^(\d+)/.exec(string(mode) ?? "")?.[1]);
8985
+ return Number.isFinite(major) ? [major] : [];
8986
+ });
8987
+ const packageMode = Math.max(
8988
+ 5,
8989
+ declaredModes.length > 0 ? Math.max(...declaredModes) : tools >= 6 ? 6 : 5
8990
+ );
8991
+ const packages = /* @__PURE__ */ new Map();
8992
+ for (const entry of array(raw2.dependencies)) {
8993
+ const { sourceControl, fileSystem } = record(entry);
8994
+ const source = record(array(sourceControl ?? fileSystem)[0]);
8995
+ const identity = string(source.identity);
8996
+ if (!identity) continue;
8997
+ const url = string(record(array(record(source.location).remote)[0]).urlString);
8998
+ const local = string(source.path);
8999
+ const value = url ? { url } : local ? { dir: local } : null;
9000
+ if (!value) continue;
9001
+ packages.set(identity, value);
9002
+ const alias = string(source.nameForTargetDependencyResolutionOnly);
9003
+ if (alias) packages.set(alias.toLowerCase(), value);
9004
+ }
9005
+ const products = /* @__PURE__ */ new Map();
9006
+ for (const product of array(raw2.products)) {
9007
+ const { name: name2, targets: targets2, type } = record(product);
9008
+ if (!string(name2) || !("library" in record(type))) continue;
9009
+ products.set(
9010
+ string(name2),
9011
+ array(targets2).flatMap((target) => string(target) ?? [])
9012
+ );
9013
+ }
9014
+ const targets = /* @__PURE__ */ new Map();
9015
+ const names = new Set(array(raw2.targets).map((target) => string(record(target).name)));
9016
+ for (const entry of array(raw2.targets)) {
9017
+ const target = record(entry);
9018
+ const name2 = string(target.name);
9019
+ const kind = string(target.type);
9020
+ if (!name2 || !isTargetType(kind)) continue;
9021
+ const declared = string(target.path);
9022
+ const roots = kind === "test" ? ["Tests"] : ["Sources", "Source", "src", "srcs"];
9023
+ const targetDir = declared ? import_node_path13.default.resolve(dir, declared) : roots.map((root) => import_node_path13.default.join(dir, root, name2)).find((candidate) => import_node_fs13.default.existsSync(candidate)) ?? import_node_path13.default.join(dir, roots[0], name2);
9024
+ const dependencies = [];
9025
+ for (const dependency of array(target.dependencies)) {
9026
+ const { target: local, product, byName } = record(dependency);
9027
+ const payload = array(local ?? product ?? byName);
9028
+ if (!linksOnIOS(payload[payload.length - 1], traits)) continue;
9029
+ const dependencyName = string(payload[0]);
9030
+ if (!dependencyName) continue;
9031
+ if (product)
9032
+ dependencies.push({
9033
+ kind: "product",
9034
+ name: dependencyName,
9035
+ package: (string(payload[1]) ?? "").toLowerCase()
9036
+ });
9037
+ else if (local || names.has(dependencyName))
9038
+ dependencies.push({ kind: "target", name: dependencyName });
9039
+ else
9040
+ dependencies.push({
9041
+ kind: "product",
9042
+ name: dependencyName,
9043
+ package: dependencyName.toLowerCase()
9044
+ });
9045
+ }
9046
+ let languageMode = packageMode;
9047
+ let mainActorIsolation = false;
9048
+ for (const setting of array(target.settings)) {
9049
+ const settingKind = record(record(setting).kind);
9050
+ const mode = string(record(settingKind.swiftLanguageMode)._0);
9051
+ if (mode)
9052
+ languageMode = Math.max(5, Number(/^(\d+)/.exec(mode)?.[1] ?? languageMode));
9053
+ if (string(record(settingKind.defaultIsolation)._0) === "MainActor")
9054
+ mainActorIsolation = true;
9055
+ }
9056
+ targets.set(name2, {
9057
+ name: name2,
9058
+ type: kind,
9059
+ dir: targetDir,
9060
+ sources: target.sources == null ? null : array(target.sources).flatMap((file) => string(file) ?? []),
9061
+ exclude: array(target.exclude).flatMap((file) => string(file) ?? []),
9062
+ dependencies,
9063
+ languageMode,
9064
+ mainActorIsolation,
9065
+ declaresResources: array(target.resources).length > 0
9066
+ });
9067
+ }
9068
+ const manifest = { dir, products, targets, packages };
9069
+ evaluated.set(key, manifest);
9070
+ return manifest;
9071
+ }
9072
+ var within = (file, roots) => roots.some((root) => file === root || file.startsWith(`${root}${import_node_path13.default.sep}`));
9073
+ function walk(dir) {
9074
+ if (!import_node_fs13.default.existsSync(dir)) return [];
9075
+ if (import_node_fs13.default.statSync(dir).isFile()) return [dir];
9076
+ const out = [];
9077
+ for (const entry of import_node_fs13.default.readdirSync(dir, { withFileTypes: true })) {
9078
+ if (entry.name.startsWith(".")) continue;
9079
+ const full = import_node_path13.default.join(dir, entry.name);
9080
+ if (entry.isDirectory()) out.push(...walk(full));
9081
+ else if (entry.isFile()) out.push(full);
9082
+ }
9083
+ return out;
9084
+ }
9085
+ function swiftTargetFiles(manifest, target) {
9086
+ const included = target.sources ? target.sources.map((source) => import_node_path13.default.resolve(target.dir, source)) : [target.dir];
9087
+ const excluded = [
9088
+ ...target.exclude.map((file) => import_node_path13.default.resolve(target.dir, file)),
9089
+ ...[...manifest.targets.values()].flatMap(
9090
+ (other) => other !== target && within(other.dir, [target.dir]) && other.dir !== target.dir ? [other.dir] : []
9091
+ )
9092
+ ];
9093
+ return included.flatMap(walk).filter((file) => !within(file, excluded)).sort();
9094
+ }
9095
+
9096
+ // src/swift-packages.ts
9097
+ var REMOTE_CHECKOUTS = import_node_path14.default.join(".build", "peach", "checkouts");
8936
9098
  var C_FAMILY = /\.(c|cc|cpp|cxx|m|mm|s|S)$/;
8937
9099
  function readPins(resolved) {
8938
- const data = JSON.parse(import_node_fs13.default.readFileSync(resolved, "utf8"));
9100
+ const data = JSON.parse(import_node_fs14.default.readFileSync(resolved, "utf8"));
8939
9101
  const pins = data && typeof data === "object" && "pins" in data && Array.isArray(data.pins) ? data.pins : null;
8940
9102
  if (!pins)
8941
9103
  throw new Error(`${resolved} has no pins; resolve packages in a current Xcode`);
@@ -8949,36 +9111,25 @@ function readPins(resolved) {
8949
9111
  }
8950
9112
  return out;
8951
9113
  }
8952
- function walk(dir) {
8953
- if (!import_node_fs13.default.existsSync(dir)) return [];
8954
- const out = [];
8955
- for (const entry of import_node_fs13.default.readdirSync(dir, { withFileTypes: true })) {
8956
- if (entry.name.startsWith(".")) continue;
8957
- const full = import_node_path13.default.join(dir, entry.name);
8958
- if (entry.isDirectory()) out.push(...walk(full));
8959
- else if (entry.isFile()) out.push(full);
8960
- }
8961
- return out.sort();
8962
- }
8963
9114
  var verified2 = /* @__PURE__ */ new Set();
8964
9115
  function checkout(checkouts, identity, pin) {
8965
- const dir = import_node_path13.default.join(checkouts, identity);
9116
+ const dir = import_node_path14.default.join(checkouts, identity);
8966
9117
  const key = `${dir}\0${pin.revision}`;
8967
9118
  if (verified2.has(key)) return dir;
8968
- const git = (...args) => (0, import_node_child_process6.execFileSync)("git", ["-C", dir, ...args], {
9119
+ const git = (...args) => (0, import_node_child_process7.execFileSync)("git", ["-C", dir, ...args], {
8969
9120
  encoding: "utf8",
8970
9121
  stdio: ["ignore", "pipe", "pipe"]
8971
9122
  }).trim();
8972
- const current = import_node_fs13.default.existsSync(import_node_path13.default.join(dir, ".git")) ? git("rev-parse", "HEAD") : "";
9123
+ const current = import_node_fs14.default.existsSync(import_node_path14.default.join(dir, ".git")) ? git("rev-parse", "HEAD") : "";
8973
9124
  if (current !== pin.revision) {
8974
- import_node_fs13.default.rmSync(dir, { recursive: true, force: true });
8975
- import_node_fs13.default.mkdirSync(dir, { recursive: true });
9125
+ import_node_fs14.default.rmSync(dir, { recursive: true, force: true });
9126
+ import_node_fs14.default.mkdirSync(dir, { recursive: true });
8976
9127
  try {
8977
9128
  git("init", "-q");
8978
9129
  git("fetch", "-q", "--depth", "1", pin.location, pin.revision);
8979
9130
  git("checkout", "-q", "FETCH_HEAD");
8980
9131
  } catch (error) {
8981
- import_node_fs13.default.rmSync(dir, { recursive: true, force: true });
9132
+ import_node_fs14.default.rmSync(dir, { recursive: true, force: true });
8982
9133
  const stderr = error instanceof Error && "stderr" in error ? String(error.stderr).trim() : "";
8983
9134
  throw new Error(
8984
9135
  `could not fetch ${pin.location} at ${pin.revision}${stderr ? `: ${stderr}` : ""}`
@@ -8988,127 +9139,153 @@ function checkout(checkouts, identity, pin) {
8988
9139
  verified2.add(key);
8989
9140
  return dir;
8990
9141
  }
8991
- function resolveRemotePackages(projectDir, resolved, products, provided) {
8992
- const result = { targets: [], unavailable: /* @__PURE__ */ new Map() };
8993
- const wanted = products.filter((entry) => !provided.has(entry.product));
8994
- if (wanted.length === 0) return result;
8995
- if (!resolved) {
8996
- for (const entry of wanted)
8997
- result.unavailable.set(entry.product, {
8998
- repositoryURL: entry.repositoryURL,
8999
- reason: "no Package.resolved pins it; resolve packages in Xcode once"
9000
- });
9001
- return result;
9002
- }
9003
- const pins = readPins(resolved);
9004
- const checkouts = import_node_path13.default.join(projectDir, REMOTE_CHECKOUTS);
9005
- import_node_fs13.default.mkdirSync(checkouts, { recursive: true });
9006
- import_node_fs13.default.writeFileSync(import_node_path13.default.join(import_node_path13.default.dirname(checkouts), ".gitignore"), "*\n");
9142
+ function resolveSwiftPackages(options) {
9143
+ const { rootDir, resolved, products, localDirs } = options;
9144
+ const provided = options.provided ?? /* @__PURE__ */ new Set();
9145
+ const result = {
9146
+ targets: [],
9147
+ unavailable: /* @__PURE__ */ new Map(),
9148
+ modules: /* @__PURE__ */ new Map()
9149
+ };
9150
+ const pins = resolved ? readPins(resolved) : null;
9151
+ const checkouts = import_node_path14.default.join(rootDir, REMOTE_CHECKOUTS);
9007
9152
  const packages = /* @__PURE__ */ new Map();
9008
- const load2 = (identity) => {
9009
- const cached3 = packages.get(identity);
9010
- if (cached3) return cached3;
9011
- const pin = pins.get(identity);
9012
- if (!pin) return null;
9013
- const dir = checkout(checkouts, identity, pin);
9014
- const manifest = import_node_fs13.default.readFileSync(import_node_path13.default.join(dir, "Package.swift"), "utf8");
9015
- const loaded2 = { dir, manifest, graph: swiftManifestGraph(manifest) };
9016
- packages.set(identity, loaded2);
9153
+ const load2 = (source) => {
9154
+ const key = source.kind === "local" ? import_node_path14.default.resolve(source.dir) : source.url;
9155
+ const cached3 = packages.get(key);
9156
+ if (cached3 !== void 0) return cached3;
9157
+ let loaded2;
9158
+ if (source.kind === "local") {
9159
+ loaded2 = { source: key, remote: false, manifest: swiftPackageManifest(key) };
9160
+ } else {
9161
+ const identity = swiftPackageIdentity(source.url);
9162
+ const pin = pins?.get(identity);
9163
+ if (!pin) {
9164
+ loaded2 = pins ? `package ${identity} is not pinned in Package.resolved` : "no Package.resolved pins it; resolve packages in Xcode once";
9165
+ } else {
9166
+ import_node_fs14.default.mkdirSync(checkouts, { recursive: true });
9167
+ import_node_fs14.default.writeFileSync(import_node_path14.default.join(import_node_path14.default.dirname(checkouts), ".gitignore"), "*\n");
9168
+ loaded2 = {
9169
+ source: source.url,
9170
+ remote: true,
9171
+ manifest: swiftPackageManifest(checkout(checkouts, identity, pin))
9172
+ };
9173
+ }
9174
+ }
9175
+ packages.set(key, loaded2);
9017
9176
  return loaded2;
9018
9177
  };
9019
9178
  const targets = /* @__PURE__ */ new Map();
9020
- const outcomes = /* @__PURE__ */ new Map();
9021
- const resolveProduct = (identity, product) => {
9022
- const key = `${identity}\0${product}`;
9023
- if (outcomes.has(key)) return outcomes.get(key);
9024
- outcomes.set(key, null);
9025
- const pkg = load2(identity);
9026
- if (!pkg) {
9027
- outcomes.set(key, `package ${identity} is not pinned in Package.resolved`);
9028
- return outcomes.get(key);
9029
- }
9030
- const roots = pkg.graph.products.get(product);
9031
- if (!roots) {
9032
- outcomes.set(key, `package ${identity} has no library ${product}`);
9033
- return outcomes.get(key);
9034
- }
9035
- const declared = new Map(
9036
- swiftManifestTargets(pkg.manifest).map((target) => [target.name, target])
9037
- );
9038
- const reached = [];
9039
- const seen = /* @__PURE__ */ new Set();
9040
- const pending = [...roots];
9041
- let reason = null;
9042
- while (pending.length > 0 && !reason) {
9043
- const name2 = pending.pop();
9044
- if (seen.has(name2) || provided.has(name2)) continue;
9045
- seen.add(name2);
9046
- if (pkg.graph.binaryTargets.has(name2)) {
9047
- reason = `${name2} is a binary framework`;
9048
- break;
9049
- }
9050
- if (pkg.graph.systemLibraries.has(name2)) {
9051
- reason = `${name2} is a system C library`;
9052
- break;
9053
- }
9054
- const target = declared.get(name2);
9055
- if (!target) {
9056
- reason = `${identity} declares no target ${name2}`;
9057
- break;
9058
- }
9059
- const files = walk(import_node_path13.default.join(pkg.dir, target.path));
9060
- if (files.some((file) => C_FAMILY.test(file))) {
9061
- reason = `${name2} is a C or Objective-C target`;
9062
- break;
9063
- }
9064
- reached.push(target);
9065
- for (const dependency of pkg.graph.dependencies.get(name2) ?? []) {
9066
- if (dependency.kind === "target") pending.push(dependency.name);
9067
- else if (!provided.has(dependency.name)) {
9068
- const url = pkg.graph.packageURLs.get(dependency.package);
9069
- const nested = resolveProduct(
9070
- url ? swiftPackageIdentity(url) : dependency.package,
9071
- dependency.name
9072
- );
9073
- if (nested) reason = `${dependency.name}: ${nested}`;
9179
+ const targetOutcomes = /* @__PURE__ */ new Map();
9180
+ const resolveTarget = (pkg, name2) => {
9181
+ const key = `${pkg.manifest.dir}\0${name2}`;
9182
+ if (targetOutcomes.has(key)) return targetOutcomes.get(key);
9183
+ targetOutcomes.set(key, null);
9184
+ const outcome = (() => {
9185
+ if (provided.has(name2)) return null;
9186
+ const target = pkg.manifest.targets.get(name2);
9187
+ if (!target) return `${import_node_path14.default.basename(pkg.manifest.dir)} declares no target ${name2}`;
9188
+ if (target.type === "binary") return `${name2} is a binary framework`;
9189
+ if (target.type === "system") return `${name2} is a system C library`;
9190
+ if (target.type !== "regular") return `${name2} is a ${target.type} target`;
9191
+ const files = swiftTargetFiles(pkg.manifest, target);
9192
+ if (files.some((file) => C_FAMILY.test(file)))
9193
+ return `${name2} is a C or Objective-C target`;
9194
+ for (const dependency of target.dependencies) {
9195
+ if (dependency.kind === "target") {
9196
+ const nested2 = resolveTarget(pkg, dependency.name);
9197
+ if (nested2) return nested2;
9198
+ continue;
9074
9199
  }
9200
+ const nested = resolveDependencyProduct(pkg, dependency.package, dependency.name);
9201
+ if (nested) return `${dependency.name}: ${nested}`;
9075
9202
  }
9076
- }
9077
- if (reason) {
9078
- outcomes.set(key, reason);
9079
- return reason;
9080
- }
9081
- const relative2 = reached.flatMap(
9082
- (target) => walk(import_node_path13.default.join(pkg.dir, target.path)).map(
9083
- (file) => import_node_path13.default.relative(pkg.dir, file).split(import_node_path13.default.sep).join(import_node_path13.default.posix.sep)
9084
- )
9085
- );
9086
- const withResources = new Map(
9087
- swiftManifestTargets(pkg.manifest, relative2).map((target) => [target.name, target])
9088
- );
9089
- for (const target of reached) {
9090
- const dir = import_node_path13.default.join(pkg.dir, target.path);
9091
- targets.set(target.name, {
9092
- ...withResources.get(target.name) ?? target,
9203
+ const relative2 = files.map((file) => import_node_path14.default.relative(target.dir, file));
9204
+ targets.set(`${pkg.manifest.dir}\0${name2}`, {
9205
+ name: name2,
9206
+ path: "",
9207
+ dir: target.dir,
9208
+ files,
9209
+ packageDir: pkg.manifest.dir,
9210
+ remote: pkg.remote,
9093
9211
  executable: false,
9094
- dir,
9095
- files: walk(dir)
9212
+ languageMode: target.languageMode,
9213
+ mainActorIsolation: target.mainActorIsolation,
9214
+ resources: target.declaresResources || swiftImplicitResourcePaths(relative2).length > 0
9096
9215
  });
9216
+ return null;
9217
+ })();
9218
+ targetOutcomes.set(key, outcome);
9219
+ return outcome;
9220
+ };
9221
+ const resolveProduct = (pkg, product) => {
9222
+ if (provided.has(product)) return null;
9223
+ const roots = pkg.manifest.products.get(product);
9224
+ if (!roots) return `${import_node_path14.default.basename(pkg.manifest.dir)} has no library ${product}`;
9225
+ for (const name2 of roots) {
9226
+ const reason = resolveTarget(pkg, name2);
9227
+ if (reason) return reason;
9097
9228
  }
9098
9229
  return null;
9099
9230
  };
9100
- for (const entry of wanted) {
9101
- const reason = resolveProduct(
9102
- swiftPackageIdentity(entry.repositoryURL),
9103
- entry.product
9104
- );
9231
+ const resolveDependencyProduct = (pkg, packageName, product) => {
9232
+ if (provided.has(product)) return null;
9233
+ const dependency = pkg.manifest.packages.get(packageName);
9234
+ if (!dependency)
9235
+ return `${import_node_path14.default.basename(pkg.manifest.dir)} names no package ${packageName}`;
9236
+ if ("dir" in dependency) {
9237
+ const loaded3 = load2({ kind: "local", dir: dependency.dir });
9238
+ return typeof loaded3 === "string" ? loaded3 : resolveProduct(loaded3, product);
9239
+ }
9240
+ if (!options.provided) return null;
9241
+ const loaded2 = load2({ kind: "remote", url: dependency.url });
9242
+ return typeof loaded2 === "string" ? loaded2 : resolveProduct(loaded2, product);
9243
+ };
9244
+ const unnamed = () => localDirs.map((dir) => load2({ kind: "local", dir })).filter((pkg) => typeof pkg !== "string");
9245
+ for (const { product, source } of products) {
9246
+ if (provided.has(product)) continue;
9247
+ if (source.kind === "remote" && !options.provided) continue;
9248
+ const pkg = source.kind === "unnamed" ? unnamed().find((candidate) => candidate.manifest.products.has(product)) : load2(source);
9249
+ const reason = pkg === void 0 ? "no package the workspace references vends it" : typeof pkg === "string" ? pkg : resolveProduct(pkg, product);
9105
9250
  if (reason)
9106
- result.unavailable.set(entry.product, {
9107
- repositoryURL: entry.repositoryURL,
9251
+ result.unavailable.set(product, {
9252
+ source: source.kind === "remote" ? source.url : typeof pkg === "object" ? pkg.source : source.kind === "local" ? source.dir : "the workspace",
9108
9253
  reason
9109
9254
  });
9110
9255
  }
9111
- result.targets = [...targets.values()];
9256
+ for (const pkg of packages.values()) {
9257
+ if (typeof pkg === "string") continue;
9258
+ for (const [name2, target] of pkg.manifest.targets) {
9259
+ if (target.type === "test" || target.type === "plugin" || target.type === "macro")
9260
+ continue;
9261
+ if (target.type === "executable") continue;
9262
+ const reason = resolveTarget(pkg, name2);
9263
+ if (reason && !result.modules.has(name2))
9264
+ result.modules.set(name2, { source: pkg.source, reason });
9265
+ }
9266
+ }
9267
+ const reached = /* @__PURE__ */ new Set();
9268
+ const reach = (pkg, name2) => {
9269
+ const key = `${pkg.manifest.dir}\0${name2}`;
9270
+ if (reached.has(key) || !targets.has(key)) return;
9271
+ reached.add(key);
9272
+ for (const dependency of pkg.manifest.targets.get(name2)?.dependencies ?? []) {
9273
+ if (dependency.kind === "target") reach(pkg, dependency.name);
9274
+ else {
9275
+ const source = pkg.manifest.packages.get(dependency.package);
9276
+ const nested = source && ("dir" in source ? packages.get(import_node_path14.default.resolve(source.dir)) : packages.get(source.url));
9277
+ if (nested && typeof nested !== "string")
9278
+ for (const root of nested.manifest.products.get(dependency.name) ?? [])
9279
+ reach(nested, root);
9280
+ }
9281
+ }
9282
+ };
9283
+ for (const { product, source } of products) {
9284
+ const pkg = source.kind === "unnamed" ? unnamed().find((candidate) => candidate.manifest.products.has(product)) : packages.get(source.kind === "local" ? import_node_path14.default.resolve(source.dir) : source.url);
9285
+ if (!pkg || typeof pkg === "string" || result.unavailable.has(product)) continue;
9286
+ for (const root of pkg.manifest.products.get(product) ?? []) reach(pkg, root);
9287
+ }
9288
+ result.targets = [...targets.entries()].filter(([key]) => reached.has(key)).map(([, target]) => target);
9112
9289
  return result;
9113
9290
  }
9114
9291
 
@@ -9239,12 +9416,12 @@ async function compileSwiftProject(submit, work, origin, signal) {
9239
9416
  }
9240
9417
 
9241
9418
  // src/xcode-project.ts
9242
- var import_node_fs14 = __toESM(require("node:fs"), 1);
9243
- var import_node_path15 = __toESM(require("node:path"), 1);
9419
+ var import_node_fs15 = __toESM(require("node:fs"), 1);
9420
+ var import_node_path16 = __toESM(require("node:path"), 1);
9244
9421
  var import_plist3 = __toESM(require_plist(), 1);
9245
9422
 
9246
9423
  // src/xcode-json-project.ts
9247
- var import_node_path14 = __toESM(require("node:path"), 1);
9424
+ var import_node_path15 = __toESM(require("node:path"), 1);
9248
9425
  var import_json5 = __toESM(require("json5"), 1);
9249
9426
  var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
9250
9427
  var text = (value) => typeof value === "string" ? value : void 0;
@@ -9260,7 +9437,7 @@ var PHASE_ISA = {
9260
9437
  function readXcodeJsonProject(xcodeproj, source) {
9261
9438
  const json = import_json5.default.parse(source);
9262
9439
  if (!isJsonObject(json)) throw new Error(`${xcodeproj}/project.xcproj is not an object`);
9263
- const projectDir = import_node_path14.default.dirname(xcodeproj);
9440
+ const projectDir = import_node_path15.default.dirname(xcodeproj);
9264
9441
  const objects = {};
9265
9442
  let next = 0;
9266
9443
  const add = (entry, id) => {
@@ -9273,7 +9450,7 @@ function readXcodeJsonProject(xcodeproj, source) {
9273
9450
  const base = /^<([A-Z]+)>\/(.*)$/.exec(raw2);
9274
9451
  if (base) {
9275
9452
  if (base[1] === "PROJECT")
9276
- return { sourceTree: "<absolute>", path: import_node_path14.default.join(projectDir, base[2]) };
9453
+ return { sourceTree: "<absolute>", path: import_node_path15.default.join(projectDir, base[2]) };
9277
9454
  if (base[1] === "PRODUCTS")
9278
9455
  return { sourceTree: "BUILT_PRODUCTS_DIR", path: base[2] };
9279
9456
  return null;
@@ -9281,7 +9458,7 @@ function readXcodeJsonProject(xcodeproj, source) {
9281
9458
  const unescaped = raw2.replaceAll("\\<", "<");
9282
9459
  if (unescaped.startsWith("/")) return { sourceTree: "<absolute>", path: unescaped };
9283
9460
  if (unescaped.startsWith("~")) return null;
9284
- return groupDir === null ? null : { sourceTree: "<absolute>", path: import_node_path14.default.join(groupDir, unescaped) };
9461
+ return groupDir === null ? null : { sourceTree: "<absolute>", path: import_node_path15.default.join(groupDir, unescaped) };
9285
9462
  };
9286
9463
  const memberships = [];
9287
9464
  const folders = [];
@@ -9292,7 +9469,7 @@ function readXcodeJsonProject(xcodeproj, source) {
9292
9469
  const kind = text(entry.kind) ?? "file-reference";
9293
9470
  const raw2 = text(entry.path) ?? "";
9294
9471
  const located = raw2 === "" ? null : locate(raw2, parent.dir);
9295
- const name2 = text(entry.name) ?? import_node_path14.default.basename(raw2);
9472
+ const name2 = text(entry.name) ?? import_node_path15.default.basename(raw2);
9296
9473
  const node = { id: "", name: name2, dir: null, parent, children: [] };
9297
9474
  if (kind === "group" || kind === "variant-group" || kind === "version-group") {
9298
9475
  node.dir = raw2 === "" ? parent.dir : located?.sourceTree === "<absolute>" ? located.path : null;
@@ -9407,7 +9584,7 @@ function readXcodeJsonProject(xcodeproj, source) {
9407
9584
  if (!isObject(entry)) continue;
9408
9585
  const repository = text(entry.repository);
9409
9586
  const local = text(entry.path);
9410
- const name2 = local !== void 0 ? import_node_path14.default.basename(import_node_path14.default.resolve(import_node_path14.default.dirname(xcodeproj), local)) : import_node_path14.default.basename(repository ?? "").replace(/\.git$/, "");
9587
+ const name2 = local !== void 0 ? import_node_path15.default.basename(import_node_path15.default.resolve(import_node_path15.default.dirname(xcodeproj), local)) : import_node_path15.default.basename(repository ?? "").replace(/\.git$/, "");
9411
9588
  const id = text(entry.kind) === "local" && local !== void 0 ? add({ isa: "XCLocalSwiftPackageReference", relativePath: local }) : add({ isa: "XCRemoteSwiftPackageReference", repositoryURL: repository ?? "" });
9412
9589
  packageIds.set(name2.toLowerCase(), id);
9413
9590
  }
@@ -9684,28 +9861,28 @@ var CONDITIONS = {
9684
9861
  variant: "normal"
9685
9862
  };
9686
9863
  function walkFiles(dir) {
9687
- if (!import_node_fs14.default.existsSync(dir)) return [];
9864
+ if (!import_node_fs15.default.existsSync(dir)) return [];
9688
9865
  const out = [];
9689
- for (const entry of import_node_fs14.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
9866
+ for (const entry of import_node_fs15.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
9690
9867
  if (entry.name.startsWith(".")) continue;
9691
- const full = import_node_path15.default.join(dir, entry.name);
9868
+ const full = import_node_path16.default.join(dir, entry.name);
9692
9869
  if (entry.isDirectory()) out.push(...walkFiles(full));
9693
9870
  else if (entry.isFile()) out.push(full);
9694
9871
  }
9695
9872
  return out;
9696
9873
  }
9697
- var isDirectory = (dir) => import_node_fs14.default.existsSync(dir) && import_node_fs14.default.statSync(dir).isDirectory();
9874
+ var isDirectory = (dir) => import_node_fs15.default.existsSync(dir) && import_node_fs15.default.statSync(dir).isDirectory();
9698
9875
  function readXcconfig(file, seen = /* @__PURE__ */ new Set()) {
9699
- if (seen.has(file) || !import_node_fs14.default.existsSync(file)) return {};
9876
+ if (seen.has(file) || !import_node_fs15.default.existsSync(file)) return {};
9700
9877
  seen.add(file);
9701
9878
  const settings = {};
9702
- for (const raw2 of import_node_fs14.default.readFileSync(file, "utf8").split("\n")) {
9879
+ for (const raw2 of import_node_fs15.default.readFileSync(file, "utf8").split("\n")) {
9703
9880
  const line = raw2.replace(/\/\/.*$/, "").trim();
9704
9881
  const include = /^#include\??\s+"([^"]+)"/.exec(line);
9705
9882
  if (include) {
9706
9883
  Object.assign(
9707
9884
  settings,
9708
- readXcconfig(import_node_path15.default.resolve(import_node_path15.default.dirname(file), include[1]), seen)
9885
+ readXcconfig(import_node_path16.default.resolve(import_node_path16.default.dirname(file), include[1]), seen)
9709
9886
  );
9710
9887
  continue;
9711
9888
  }
@@ -9755,22 +9932,22 @@ function decodeXml(text2) {
9755
9932
  return text2.replaceAll("&quot;", '"').replaceAll("&apos;", "'").replaceAll("&lt;", "<").replaceAll("&gt;", ">").replaceAll("&amp;", "&");
9756
9933
  }
9757
9934
  function workspaceReferences(workspace) {
9758
- const data = import_node_path15.default.join(workspace, "contents.xcworkspacedata");
9759
- if (!import_node_fs14.default.existsSync(data))
9935
+ const data = import_node_path16.default.join(workspace, "contents.xcworkspacedata");
9936
+ if (!import_node_fs15.default.existsSync(data))
9760
9937
  throw new Error(`${workspace} has no contents.xcworkspacedata`);
9761
- const container = import_node_path15.default.dirname(workspace);
9938
+ const container = import_node_path16.default.dirname(workspace);
9762
9939
  const locate = (location2, base) => {
9763
9940
  const colon = location2.indexOf(":");
9764
9941
  const kind = location2.slice(0, colon);
9765
9942
  const rest = location2.slice(colon + 1);
9766
- if (kind === "group") return import_node_path15.default.resolve(base, rest);
9767
- if (kind === "container" || kind === "self") return import_node_path15.default.resolve(container, rest);
9768
- if (kind === "absolute") return import_node_path15.default.resolve(rest);
9769
- throw new Error(`${import_node_path15.default.basename(workspace)} has an unsupported location ${location2}`);
9943
+ if (kind === "group") return import_node_path16.default.resolve(base, rest);
9944
+ if (kind === "container" || kind === "self") return import_node_path16.default.resolve(container, rest);
9945
+ if (kind === "absolute") return import_node_path16.default.resolve(rest);
9946
+ throw new Error(`${import_node_path16.default.basename(workspace)} has an unsupported location ${location2}`);
9770
9947
  };
9771
9948
  const groups = [container];
9772
9949
  const references = [];
9773
- for (const [, closing, tag, attributes, selfClosing] of import_node_fs14.default.readFileSync(data, "utf8").matchAll(/<(\/?)(Group|FileRef)\b([^>]*?)(\/?)>/g)) {
9950
+ for (const [, closing, tag, attributes, selfClosing] of import_node_fs15.default.readFileSync(data, "utf8").matchAll(/<(\/?)(Group|FileRef)\b([^>]*?)(\/?)>/g)) {
9774
9951
  if (closing) {
9775
9952
  if (tag === "Group") groups.pop();
9776
9953
  continue;
@@ -9786,8 +9963,8 @@ function workspaceReferences(workspace) {
9786
9963
  var loaded = /* @__PURE__ */ new Map();
9787
9964
  function xcodeProjectFile(xcodeproj) {
9788
9965
  for (const name2 of ["project.pbxproj", "project.xcproj"]) {
9789
- const file = import_node_path15.default.join(xcodeproj, name2);
9790
- if (import_node_fs14.default.existsSync(file)) return file;
9966
+ const file = import_node_path16.default.join(xcodeproj, name2);
9967
+ if (import_node_fs15.default.existsSync(file)) return file;
9791
9968
  }
9792
9969
  return null;
9793
9970
  }
@@ -9795,10 +9972,10 @@ function loadProject(xcodeproj) {
9795
9972
  const projectFile = xcodeProjectFile(xcodeproj);
9796
9973
  if (!projectFile)
9797
9974
  throw new Error(`${xcodeproj} has no project.pbxproj or project.xcproj`);
9798
- const mtimeMs = import_node_fs14.default.statSync(projectFile).mtimeMs;
9975
+ const mtimeMs = import_node_fs15.default.statSync(projectFile).mtimeMs;
9799
9976
  const cached3 = loaded.get(projectFile);
9800
9977
  if (cached3?.mtimeMs === mtimeMs) return cached3.project;
9801
- const source = import_node_fs14.default.readFileSync(projectFile, "utf8");
9978
+ const source = import_node_fs15.default.readFileSync(projectFile, "utf8");
9802
9979
  const root = projectFile.endsWith(".xcproj") ? readXcodeJsonProject(xcodeproj, source) : parseOpenStepPlist(source);
9803
9980
  if (!isDict(root) || !isDict(root.objects)) {
9804
9981
  throw new Error(`${projectFile} has no objects table`);
@@ -9812,8 +9989,8 @@ function loadProject(xcodeproj) {
9812
9989
  if (!project || project.isa !== "PBXProject") {
9813
9990
  throw new Error(`${projectFile} has no PBXProject root`);
9814
9991
  }
9815
- const projectDir = import_node_fs14.default.realpathSync(
9816
- import_node_path15.default.resolve(import_node_path15.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
9992
+ const projectDir = import_node_fs15.default.realpathSync(
9993
+ import_node_path16.default.resolve(import_node_path16.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
9817
9994
  );
9818
9995
  const parent = /* @__PURE__ */ new Map();
9819
9996
  for (const [id, entry] of Object.entries(objects)) {
@@ -9831,11 +10008,11 @@ function loadProject(xcodeproj) {
9831
10008
  const own = str(entry.path) ?? "";
9832
10009
  const tree = str(entry.sourceTree) ?? "<group>";
9833
10010
  if (tree === "<absolute>") result2 = own;
9834
- else if (tree === "SOURCE_ROOT") result2 = import_node_path15.default.join(projectDir, own);
10011
+ else if (tree === "SOURCE_ROOT") result2 = import_node_path16.default.join(projectDir, own);
9835
10012
  else if (tree === "<group>") {
9836
10013
  const up = parent.get(id);
9837
10014
  const base = up ? resolvePath(up) : projectDir;
9838
- result2 = base === null ? null : import_node_path15.default.join(base, own);
10015
+ result2 = base === null ? null : import_node_path16.default.join(base, own);
9839
10016
  }
9840
10017
  }
9841
10018
  resolvedPaths.set(id, result2);
@@ -9935,7 +10112,7 @@ function targetMembers(ref) {
9935
10112
  const addResource = (file) => {
9936
10113
  if (isDirectory(file)) {
9937
10114
  for (const inner of walkFiles(file)) resources.add(inner);
9938
- } else if (import_node_fs14.default.existsSync(file)) resources.add(file);
10115
+ } else if (import_node_fs15.default.existsSync(file)) resources.add(file);
9939
10116
  };
9940
10117
  const fileRefPaths = (refId) => {
9941
10118
  const entry = project.object(refId);
@@ -9956,7 +10133,7 @@ function targetMembers(ref) {
9956
10133
  for (const buildFileId of list(phase.files)) {
9957
10134
  for (const file of fileRefPaths(str(project.object(buildFileId)?.fileRef) ?? "")) {
9958
10135
  if (phase.isa === "PBXSourcesBuildPhase") {
9959
- if (!import_node_fs14.default.existsSync(file)) continue;
10136
+ if (!import_node_fs15.default.existsSync(file)) continue;
9960
10137
  allSources.add(file);
9961
10138
  if (file.endsWith(".swift")) sources.add(file);
9962
10139
  } else if (phase.isa === "PBXResourcesBuildPhase") addResource(file);
@@ -9964,7 +10141,7 @@ function targetMembers(ref) {
9964
10141
  }
9965
10142
  }
9966
10143
  const addSynchronized = (folder, relative2) => {
9967
- const file = import_node_path15.default.join(folder, relative2);
10144
+ const file = import_node_path16.default.join(folder, relative2);
9968
10145
  if (NEVER_MEMBER.test(relative2)) return;
9969
10146
  if (file.endsWith(".swift")) {
9970
10147
  if (!relative2.split("/").some((segment) => BUNDLE_DIR.test(segment))) {
@@ -9989,7 +10166,7 @@ function targetMembers(ref) {
9989
10166
  }
9990
10167
  if (owned.has(groupId)) {
9991
10168
  for (const file of walkFiles(folder)) {
9992
- const relative2 = import_node_path15.default.relative(folder, file).split(import_node_path15.default.sep).join("/");
10169
+ const relative2 = import_node_path16.default.relative(folder, file).split(import_node_path16.default.sep).join("/");
9993
10170
  if ([...exceptions].some(
9994
10171
  (exception) => relative2 === exception || relative2.startsWith(`${exception}/`)
9995
10172
  ))
@@ -9998,14 +10175,14 @@ function targetMembers(ref) {
9998
10175
  }
9999
10176
  } else {
10000
10177
  for (const relative2 of exceptions) {
10001
- const file = import_node_path15.default.join(folder, relative2);
10178
+ const file = import_node_path16.default.join(folder, relative2);
10002
10179
  if (isDirectory(file)) {
10003
10180
  for (const inner of walkFiles(file))
10004
10181
  addSynchronized(
10005
10182
  folder,
10006
- import_node_path15.default.relative(folder, inner).split(import_node_path15.default.sep).join("/")
10183
+ import_node_path16.default.relative(folder, inner).split(import_node_path16.default.sep).join("/")
10007
10184
  );
10008
- } else if (import_node_fs14.default.existsSync(file)) addSynchronized(folder, relative2);
10185
+ } else if (import_node_fs15.default.existsSync(file)) addSynchronized(folder, relative2);
10009
10186
  }
10010
10187
  }
10011
10188
  }
@@ -10018,8 +10195,8 @@ function targetMembers(ref) {
10018
10195
  function commonAncestor(dirs) {
10019
10196
  let common = dirs[0];
10020
10197
  for (const dir of dirs) {
10021
- while (common !== import_node_path15.default.dirname(common) && import_node_path15.default.relative(common, dir).startsWith(".."))
10022
- common = import_node_path15.default.dirname(common);
10198
+ while (common !== import_node_path16.default.dirname(common) && import_node_path16.default.relative(common, dir).startsWith(".."))
10199
+ common = import_node_path16.default.dirname(common);
10023
10200
  }
10024
10201
  return common;
10025
10202
  }
@@ -10028,8 +10205,8 @@ function workspaceProjects(xcodeprojOrWorkspace) {
10028
10205
  const projects2 = [];
10029
10206
  const projectAt = /* @__PURE__ */ new Map();
10030
10207
  const addProject = (xcodeproj) => {
10031
- const key = import_node_path15.default.resolve(xcodeproj);
10032
- if (projectAt.has(key) || key.split(import_node_path15.default.sep).includes("Pods")) return;
10208
+ const key = import_node_path16.default.resolve(xcodeproj);
10209
+ if (projectAt.has(key) || key.split(import_node_path16.default.sep).includes("Pods")) return;
10033
10210
  if (!xcodeProjectFile(key)) return;
10034
10211
  const project = loadProject(key);
10035
10212
  projectAt.set(key, project);
@@ -10046,7 +10223,7 @@ function workspaceProjects(xcodeprojOrWorkspace) {
10046
10223
  for (const reference of listed)
10047
10224
  if (reference.endsWith(".xcodeproj")) addProject(reference);
10048
10225
  if (projects2.length === 0) {
10049
- throw new Error(`${import_node_path15.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
10226
+ throw new Error(`${import_node_path16.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
10050
10227
  }
10051
10228
  return { listed, projects: projects2, projectAt };
10052
10229
  }
@@ -10068,7 +10245,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
10068
10245
  const allTargets = projects2.flatMap(nativeTargets);
10069
10246
  const appTargets = allTargets.filter((ref) => ref.target.productType === APPLICATION);
10070
10247
  const appTargetNames = appTargets.map((ref) => str(ref.target.name) ?? ref.id);
10071
- const container = import_node_path15.default.basename(xcodeprojOrWorkspace);
10248
+ const container = import_node_path16.default.basename(xcodeprojOrWorkspace);
10072
10249
  const named = targetName ? appTargets.filter((ref) => ref.target.name === targetName) : appTargets;
10073
10250
  if (named.length !== 1) {
10074
10251
  throw new Error(
@@ -10080,14 +10257,14 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
10080
10257
  for (const ref of allTargets) {
10081
10258
  const product = ref.project.object(str(ref.target.productReference));
10082
10259
  const file = str(product?.path);
10083
- if (file && !byProduct.has(import_node_path15.default.basename(file)))
10084
- byProduct.set(import_node_path15.default.basename(file), ref);
10260
+ if (file && !byProduct.has(import_node_path16.default.basename(file)))
10261
+ byProduct.set(import_node_path16.default.basename(file), ref);
10085
10262
  }
10086
10263
  const proxied = (project, proxyId) => {
10087
10264
  const proxy = project.object(proxyId);
10088
10265
  if (proxy?.isa !== "PBXContainerItemProxy") return void 0;
10089
10266
  const portal = str(proxy.containerPortal);
10090
- const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(import_node_path15.default.resolve(project.resolvePath(portal ?? "") ?? ""));
10267
+ const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(import_node_path16.default.resolve(project.resolvePath(portal ?? "") ?? ""));
10091
10268
  const remote = str(proxy.remoteGlobalIDString);
10092
10269
  if (!owner || !remote) return void 0;
10093
10270
  return nativeTargets(owner).find(
@@ -10108,7 +10285,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
10108
10285
  if (phase?.isa !== "PBXFrameworksBuildPhase") continue;
10109
10286
  for (const buildFileId of list(phase.files)) {
10110
10287
  const file = project.object(str(project.object(buildFileId)?.fileRef));
10111
- const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(import_node_path15.default.basename(str(file.path) ?? "")) : void 0;
10288
+ const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(import_node_path16.default.basename(str(file.path) ?? "")) : void 0;
10112
10289
  if (resolved) found.push(resolved);
10113
10290
  }
10114
10291
  }
@@ -10129,7 +10306,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
10129
10306
  const name2 = str(ref.target.name) ?? ref.id;
10130
10307
  const { get: settings2, keys } = targetSettings(ref, {
10131
10308
  TARGET_NAME: name2,
10132
- PROJECT_NAME: import_node_path15.default.basename(ref.project.xcodeproj, ".xcodeproj"),
10309
+ PROJECT_NAME: import_node_path16.default.basename(ref.project.xcodeproj, ".xcodeproj"),
10133
10310
  SRCROOT: ref.project.projectDir,
10134
10311
  SOURCE_ROOT: ref.project.projectDir,
10135
10312
  PROJECT_DIR: ref.project.projectDir,
@@ -10160,8 +10337,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
10160
10337
  }
10161
10338
  return value;
10162
10339
  };
10163
- const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path15.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
10164
- const sourceInfo = infoPlistFile ? import_plist3.default.parse(import_node_fs14.default.readFileSync(infoPlistFile, "utf8")) : {};
10340
+ const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path16.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
10341
+ const sourceInfo = infoPlistFile ? import_plist3.default.parse(import_node_fs15.default.readFileSync(infoPlistFile, "utf8")) : {};
10165
10342
  if (!sourceInfo || typeof sourceInfo !== "object" || Array.isArray(sourceInfo) || sourceInfo instanceof Date || Buffer.isBuffer(sourceInfo)) {
10166
10343
  throw new Error(`${module2.name} Info.plist must contain a dictionary`);
10167
10344
  }
@@ -10179,34 +10356,17 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
10179
10356
  };
10180
10357
  }
10181
10358
  const localPackageDirs = [
10182
- ...listed.filter((reference) => import_node_fs14.default.existsSync(import_node_path15.default.join(reference, "Package.swift"))),
10359
+ ...listed.filter((reference) => import_node_fs15.default.existsSync(import_node_path16.default.join(reference, "Package.swift"))),
10183
10360
  ...projects2.flatMap(
10184
10361
  (project) => Object.entries(project.objects).flatMap(([id, entry]) => {
10185
10362
  if (!isDict(entry)) return [];
10186
- const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path15.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
10187
- return candidate && import_node_fs14.default.existsSync(import_node_path15.default.join(candidate, "Package.swift")) ? [candidate] : [];
10363
+ const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path16.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
10364
+ return candidate && import_node_fs15.default.existsSync(import_node_path16.default.join(candidate, "Package.swift")) ? [candidate] : [];
10188
10365
  })
10189
10366
  )
10190
10367
  ];
10191
- const graphs = /* @__PURE__ */ new Map();
10192
- const graphOf = (dir) => {
10193
- const cached3 = graphs.get(dir);
10194
- if (cached3) return cached3;
10195
- const graph = swiftManifestGraph(
10196
- import_node_fs14.default.readFileSync(import_node_path15.default.join(dir, "Package.swift"), "utf8")
10197
- );
10198
- graphs.set(dir, graph);
10199
- return graph;
10200
- };
10201
- const localProducts = /* @__PURE__ */ new Map();
10202
- for (const dir of localPackageDirs) {
10203
- for (const product of graphOf(dir).products.keys()) {
10204
- if (!localProducts.has(product)) localProducts.set(product, dir);
10205
- }
10206
- }
10207
- const localPackages = /* @__PURE__ */ new Set();
10208
- const remoteProducts = [];
10209
- const unresolvedProducts = [];
10368
+ const linkedProducts = [];
10369
+ const binaryFrameworks = /* @__PURE__ */ new Set();
10210
10370
  for (const { project, target } of order) {
10211
10371
  const productDependencies = [
10212
10372
  ...list(target.packageProductDependencies),
@@ -10218,45 +10378,37 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
10218
10378
  for (const dependencyId of productDependencies) {
10219
10379
  const dependency = project.object(dependencyId);
10220
10380
  const product = str(dependency?.productName)?.replace(/^plugin:/, "");
10221
- if (!dependency || !product) continue;
10381
+ if (!dependency || !product || linkedProducts.some((entry) => entry.product === product))
10382
+ continue;
10222
10383
  const reference = project.object(str(dependency.package));
10223
- if (reference?.isa === "XCRemoteSwiftPackageReference") {
10224
- if (!remoteProducts.some((entry) => entry.product === product))
10225
- remoteProducts.push({
10226
- product,
10227
- repositoryURL: str(reference.repositoryURL) ?? ""
10228
- });
10229
- } else if (reference?.isa === "XCLocalSwiftPackageReference") {
10230
- localPackages.add(
10231
- import_node_path15.default.resolve(project.projectDir, str(reference.relativePath) ?? "")
10232
- );
10233
- } else if (localProducts.has(product)) {
10234
- localPackages.add(localProducts.get(product));
10235
- } else if (!unresolvedProducts.includes(product)) unresolvedProducts.push(product);
10384
+ linkedProducts.push({
10385
+ product,
10386
+ source: reference?.isa === "XCRemoteSwiftPackageReference" ? { kind: "remote", url: str(reference.repositoryURL) ?? "" } : reference?.isa === "XCLocalSwiftPackageReference" ? {
10387
+ kind: "local",
10388
+ dir: import_node_path16.default.resolve(
10389
+ project.projectDir,
10390
+ str(reference.relativePath) ?? ""
10391
+ )
10392
+ } : { kind: "unnamed" }
10393
+ });
10236
10394
  }
10237
- }
10238
- const pending = [...localPackages];
10239
- while (pending.length > 0) {
10240
- const dir = pending.pop();
10241
- const graph = graphOf(dir);
10242
- for (const relative2 of graph.packagePaths) {
10243
- const next = import_node_path15.default.resolve(dir, relative2);
10244
- if (localPackages.has(next) || !import_node_fs14.default.existsSync(import_node_path15.default.join(next, "Package.swift")))
10245
- continue;
10246
- localPackages.add(next);
10247
- pending.push(next);
10248
- }
10249
- for (const dependencies of graph.dependencies.values()) {
10250
- for (const dependency of dependencies) {
10251
- if (dependency.kind !== "product") continue;
10252
- const url = graph.packageURLs.get(dependency.package);
10253
- if (url && !remoteProducts.some((entry) => entry.product === dependency.name))
10254
- remoteProducts.push({ product: dependency.name, repositoryURL: url });
10395
+ for (const phaseId of list(target.buildPhases)) {
10396
+ const phase = project.object(phaseId);
10397
+ if (phase?.isa !== "PBXFrameworksBuildPhase") continue;
10398
+ for (const buildFileId of list(phase.files)) {
10399
+ const fileId = str(project.object(buildFileId)?.fileRef);
10400
+ const file = project.object(fileId);
10401
+ const tree = str(file?.sourceTree);
10402
+ const name2 = /([^/]+)\.(xc)?framework$/.exec(str(file?.path) ?? "")?.[1];
10403
+ if (file?.isa !== "PBXFileReference" || !name2) continue;
10404
+ if (tree === "BUILT_PRODUCTS_DIR" || tree === "SDKROOT" || tree === "DEVELOPER_DIR")
10405
+ continue;
10406
+ binaryFrameworks.add(name2);
10255
10407
  }
10256
10408
  }
10257
10409
  }
10258
- const resolvedFile = import_node_path15.default.join(
10259
- workspace ?? import_node_path15.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
10410
+ const resolvedFile = import_node_path16.default.join(
10411
+ workspace ?? import_node_path16.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
10260
10412
  "xcshareddata",
10261
10413
  "swiftpm",
10262
10414
  "Package.resolved"
@@ -10266,19 +10418,24 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
10266
10418
  ...module2,
10267
10419
  rootDir: commonAncestor(
10268
10420
  [
10269
- workspace ? import_node_path15.default.dirname(workspace) : app.project.projectDir,
10421
+ workspace ? import_node_path16.default.dirname(workspace) : app.project.projectDir,
10270
10422
  ...used.map((project) => project.projectDir),
10271
- ...localPackages
10272
- ].map((dir) => import_node_fs14.default.realpathSync(dir))
10423
+ ...localPackageDirs,
10424
+ ...linkedProducts.flatMap(
10425
+ ({ source }) => source.kind === "local" && import_node_fs15.default.existsSync(source.dir) ? [source.dir] : []
10426
+ )
10427
+ ].map((dir) => import_node_fs15.default.realpathSync(dir))
10273
10428
  ),
10274
10429
  projectFiles: [...new Set(used.map((project) => project.projectFile))].sort(),
10275
10430
  infoPlist: import_plist3.default.build(info),
10276
10431
  infoPlistFile,
10277
10432
  frameworks,
10278
- localPackages: [...localPackages].map((dir) => import_node_fs14.default.realpathSync(dir)).sort(),
10279
- remoteProducts,
10280
- packageResolved: import_node_fs14.default.existsSync(resolvedFile) ? resolvedFile : null,
10281
- unresolvedProducts,
10433
+ linkedProducts,
10434
+ localPackageDirs: [
10435
+ ...new Set(localPackageDirs.map((dir) => import_node_fs15.default.realpathSync(dir)))
10436
+ ].sort(),
10437
+ binaryFrameworks: [...binaryFrameworks].sort(),
10438
+ packageResolved: import_node_fs15.default.existsSync(resolvedFile) ? resolvedFile : null,
10282
10439
  appTargets: appTargetNames
10283
10440
  };
10284
10441
  }
@@ -10298,17 +10455,17 @@ var SKIP_SOURCE_DIRS = /* @__PURE__ */ new Set([
10298
10455
  var NATIVE_DESCRIPTOR = ".one-native-source.json";
10299
10456
  var NATIVE_GLUE = ".one-native-source.swift.txt";
10300
10457
  function swiftPackageId(packagePath) {
10301
- return import_node_path16.default.basename(packagePath).replace(/[^A-Za-z0-9_]/g, "_").replace(/^(\d)/, "_$1");
10458
+ return import_node_path17.default.basename(packagePath).replace(/[^A-Za-z0-9_]/g, "_").replace(/^(\d)/, "_$1");
10302
10459
  }
10303
10460
  function nativeSourceDescriptor(packagePath) {
10304
- packagePath = import_node_fs15.default.realpathSync(packagePath);
10305
- const file = import_node_path16.default.join(packagePath, NATIVE_DESCRIPTOR);
10306
- if (!import_node_fs15.default.existsSync(file)) return null;
10461
+ packagePath = import_node_fs16.default.realpathSync(packagePath);
10462
+ const file = import_node_path17.default.join(packagePath, NATIVE_DESCRIPTOR);
10463
+ if (!import_node_fs16.default.existsSync(file)) return null;
10307
10464
  const value = JSON.parse(
10308
10465
  readPackageFile(packagePath, file, MAX_SWIFT_COMPILE_SOURCE_BYTES).toString("utf8")
10309
10466
  );
10310
10467
  const invalid = () => new Error(`${file}: invalid One native source descriptor; run one typegen`);
10311
- if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !import_node_fs15.default.existsSync(import_node_path16.default.join(packagePath, NATIVE_GLUE))) {
10468
+ if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !import_node_fs16.default.existsSync(import_node_path17.default.join(packagePath, NATIVE_GLUE))) {
10312
10469
  throw invalid();
10313
10470
  }
10314
10471
  if (!isSwiftNativeModules(value) || value.packageId !== swiftPackageId(packagePath)) {
@@ -10318,7 +10475,7 @@ function nativeSourceDescriptor(packagePath) {
10318
10475
  }
10319
10476
  var projects = /* @__PURE__ */ new Map();
10320
10477
  function projectFor(packagePath, hosted) {
10321
- packagePath = import_node_fs15.default.realpathSync(packagePath);
10478
+ packagePath = import_node_fs16.default.realpathSync(packagePath);
10322
10479
  const existing = projects.get(packagePath);
10323
10480
  if (existing) {
10324
10481
  if (hosted && !existing.hosted) {
@@ -10339,34 +10496,39 @@ function projectFor(packagePath, hosted) {
10339
10496
  return created;
10340
10497
  }
10341
10498
  var xcodeProjects = /* @__PURE__ */ new Map();
10342
- function remotePackages(entry, app) {
10343
- if (!entry.provided) return { targets: [], unavailable: /* @__PURE__ */ new Map() };
10499
+ function swiftPackages(entry, app) {
10500
+ const stamp = (file) => file && import_node_fs16.default.existsSync(file) ? import_node_fs16.default.statSync(file).mtimeMs : 0;
10344
10501
  const key = JSON.stringify([
10345
- app.remoteProducts,
10502
+ app.linkedProducts,
10346
10503
  app.packageResolved,
10347
- app.packageResolved ? import_node_fs15.default.statSync(app.packageResolved).mtimeMs : 0
10504
+ stamp(app.packageResolved),
10505
+ app.localPackageDirs.map((dir) => stamp(import_node_path17.default.join(dir, "Package.swift"))),
10506
+ app.linkedProducts.map(
10507
+ ({ source }) => source.kind === "local" ? stamp(import_node_path17.default.join(source.dir, "Package.swift")) : 0
10508
+ )
10348
10509
  ]);
10349
- if (entry.remote?.key !== key) {
10350
- entry.remote = {
10510
+ if (entry.packages?.key !== key) {
10511
+ entry.packages = {
10351
10512
  key,
10352
- packages: resolveRemotePackages(
10353
- app.rootDir,
10354
- app.packageResolved,
10355
- app.remoteProducts,
10356
- entry.provided
10357
- )
10513
+ packages: resolveSwiftPackages({
10514
+ rootDir: app.rootDir,
10515
+ resolved: app.packageResolved,
10516
+ products: app.linkedProducts,
10517
+ localDirs: app.localPackageDirs,
10518
+ provided: entry.provided
10519
+ })
10358
10520
  };
10359
10521
  }
10360
- return entry.remote.packages;
10522
+ return entry.packages.packages;
10361
10523
  }
10362
10524
  var XCODE_APP_DIR = "__app__";
10363
10525
  var XCODE_FRAMEWORKS_DIR = "__frameworks__";
10364
10526
  var XCODE_PACKAGES_DIR = "__packages__";
10365
- var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(import_node_path16.default.sep).join(import_node_path16.default.posix.sep)}/`;
10527
+ var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(import_node_path17.default.sep).join(import_node_path17.default.posix.sep)}/`;
10366
10528
  function xcodeInputKey(layout, file, relative2) {
10367
10529
  const owner = layout.targetDirs.get(file);
10368
- if (owner) return import_node_path16.default.posix.join(owner, relative2);
10369
- return relative2.startsWith(CHECKOUTS_PREFIX) ? import_node_path16.default.posix.join(XCODE_PACKAGES_DIR, relative2.slice(CHECKOUTS_PREFIX.length)) : relative2;
10530
+ if (owner) return import_node_path17.default.posix.join(owner, relative2);
10531
+ return relative2.startsWith(CHECKOUTS_PREFIX) ? import_node_path17.default.posix.join(XCODE_PACKAGES_DIR, relative2.slice(CHECKOUTS_PREFIX.length)) : relative2;
10370
10532
  }
10371
10533
  function xcodeLayout(root) {
10372
10534
  const registered = xcodeProjects.get(root);
@@ -10377,7 +10539,7 @@ function xcodeLayout(root) {
10377
10539
  const targetDirs = new Map(app.sources.map((file) => [file, XCODE_APP_DIR]));
10378
10540
  const targets = [];
10379
10541
  for (const framework of app.frameworks) {
10380
- const dir = import_node_path16.default.posix.join(XCODE_FRAMEWORKS_DIR, framework.moduleName);
10542
+ const dir = import_node_path17.default.posix.join(XCODE_FRAMEWORKS_DIR, framework.moduleName);
10381
10543
  for (const file of framework.sources) {
10382
10544
  if (targetDirs.has(file)) continue;
10383
10545
  targetDirs.set(file, dir);
@@ -10388,44 +10550,35 @@ function xcodeLayout(root) {
10388
10550
  path: dir,
10389
10551
  executable: false,
10390
10552
  resources: false,
10553
+ exclude: [],
10391
10554
  languageMode: framework.languageMode,
10392
10555
  mainActorIsolation: framework.mainActorIsolation
10393
10556
  });
10394
10557
  }
10395
- for (const dir of app.localPackages) {
10396
- const manifestFile = import_node_path16.default.join(dir, "Package.swift");
10397
- files.add(manifestFile);
10398
- const manifest = import_node_fs15.default.readFileSync(manifestFile, "utf8");
10399
- const prefix = import_node_path16.default.relative(root, dir).split(import_node_path16.default.sep).join(import_node_path16.default.posix.sep);
10400
- const declared = swiftManifestTargets(manifest).filter((target) => !target.executable);
10401
- const all = declared.flatMap(
10402
- (target) => sourceTreeFiles(import_node_path16.default.join(dir, target.path), root).map(
10403
- (file) => import_node_path16.default.relative(dir, file).split(import_node_path16.default.sep).join(import_node_path16.default.posix.sep)
10404
- )
10558
+ const packages = swiftPackages(registered, app);
10559
+ for (const target of packages.targets) {
10560
+ const relative2 = import_node_path17.default.relative(
10561
+ target.remote ? import_node_path17.default.join(root, REMOTE_CHECKOUTS) : root,
10562
+ target.dir
10405
10563
  );
10406
- for (const target of swiftManifestTargets(manifest, all)) {
10407
- if (target.executable) continue;
10408
- targets.push({ ...target, path: import_node_path16.default.posix.join(prefix, target.path) });
10409
- for (const relative2 of all) {
10410
- if (relative2.startsWith(`${target.path}/`)) files.add(import_node_path16.default.join(dir, relative2));
10411
- }
10412
- }
10413
- }
10414
- const remote = remotePackages(registered, app);
10415
- for (const target of remote.targets) {
10564
+ if (relative2 === ".." || relative2.startsWith(`..${import_node_path17.default.sep}`) || import_node_path17.default.isAbsolute(relative2))
10565
+ throw new Error(`swift input escapes the selected package: ${target.dir}`);
10566
+ const posix2 = relative2.split(import_node_path17.default.sep).join(import_node_path17.default.posix.sep);
10416
10567
  targets.push({
10417
10568
  ...target,
10418
- path: import_node_path16.default.posix.join(
10419
- XCODE_PACKAGES_DIR,
10420
- import_node_path16.default.relative(import_node_path16.default.join(root, REMOTE_CHECKOUTS), target.dir).split(import_node_path16.default.sep).join(import_node_path16.default.posix.sep)
10421
- )
10569
+ path: target.remote ? import_node_path17.default.posix.join(XCODE_PACKAGES_DIR, posix2) : posix2,
10570
+ exclude: []
10422
10571
  });
10572
+ if (!target.remote) files.add(import_node_path17.default.join(target.packageDir, "Package.swift"));
10423
10573
  for (const file of target.files) files.add(file);
10424
10574
  }
10575
+ for (const target of targets) {
10576
+ target.exclude = targets.filter((other) => other.path.startsWith(`${target.path}/`)).map((other) => other.path.slice(target.path.length + 1));
10577
+ }
10425
10578
  return {
10426
10579
  app,
10427
10580
  targets,
10428
- unavailable: remote.unavailable,
10581
+ packages,
10429
10582
  targetDirs,
10430
10583
  files: [...files].sort()
10431
10584
  };
@@ -10438,32 +10591,32 @@ function xcodeManifest(layout) {
10438
10591
  'let package = Package(name: "app", targets: [',
10439
10592
  ` .executableTarget(name: "${layout.app.moduleName}", path: "${XCODE_APP_DIR}", ${settings(layout.app.languageMode, layout.app.mainActorIsolation)}),`,
10440
10593
  ...layout.targets.map(
10441
- (target) => ` .target(name: "${target.name}", path: "${target.path}", ${target.resources ? "resources: [], " : ""}${settings(target.languageMode, target.mainActorIsolation)}),`
10594
+ (target) => ` .target(name: "${target.name}", path: "${target.path}", ${target.exclude.length > 0 ? `exclude: ${JSON.stringify(target.exclude)}, ` : ""}${target.resources ? "resources: [], " : ""}${settings(target.languageMode, target.mainActorIsolation)}),`
10442
10595
  ),
10443
10596
  "])",
10444
10597
  ""
10445
10598
  ].join("\n");
10446
10599
  }
10447
10600
  function packageFiles(root) {
10448
- const canonicalRoot = import_node_fs15.default.realpathSync(root);
10601
+ const canonicalRoot = import_node_fs16.default.realpathSync(root);
10449
10602
  const xcode = xcodeLayout(canonicalRoot);
10450
10603
  return xcode ? xcode.files : sourceTreeFiles(canonicalRoot, canonicalRoot);
10451
10604
  }
10452
10605
  function sourceTreeFiles(dir, canonicalRoot) {
10453
10606
  const found = [];
10454
10607
  const walk2 = (dir2) => {
10455
- for (const entry of import_node_fs15.default.readdirSync(dir2, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
10608
+ for (const entry of import_node_fs16.default.readdirSync(dir2, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
10456
10609
  if (entry.name.startsWith(".") && entry.name !== NATIVE_DESCRIPTOR && entry.name !== NATIVE_GLUE || SKIP_SOURCE_DIRS.has(entry.name))
10457
10610
  continue;
10458
- const full = import_node_path16.default.join(dir2, entry.name);
10611
+ const full = import_node_path17.default.join(dir2, entry.name);
10459
10612
  if (entry.isSymbolicLink()) throw new Error(`swift input is a symlink: ${full}`);
10460
- const real = import_node_fs15.default.realpathSync(full);
10461
- const relative2 = import_node_path16.default.relative(canonicalRoot, real);
10462
- if (relative2.startsWith(`..${import_node_path16.default.sep}`) || relative2 === ".." || import_node_path16.default.isAbsolute(relative2)) {
10613
+ const real = import_node_fs16.default.realpathSync(full);
10614
+ const relative2 = import_node_path17.default.relative(canonicalRoot, real);
10615
+ if (relative2.startsWith(`..${import_node_path17.default.sep}`) || relative2 === ".." || import_node_path17.default.isAbsolute(relative2)) {
10463
10616
  throw new Error(`swift input escapes the selected package: ${full}`);
10464
10617
  }
10465
10618
  if (entry.isDirectory()) {
10466
- if (import_node_fs15.default.existsSync(import_node_path16.default.join(full, "Package.swift"))) continue;
10619
+ if (import_node_fs16.default.existsSync(import_node_path17.default.join(full, "Package.swift"))) continue;
10467
10620
  walk2(full);
10468
10621
  } else if (entry.isFile()) {
10469
10622
  found.push(full);
@@ -10471,29 +10624,29 @@ function sourceTreeFiles(dir, canonicalRoot) {
10471
10624
  }
10472
10625
  }
10473
10626
  };
10474
- if (import_node_fs15.default.existsSync(dir)) walk2(import_node_fs15.default.realpathSync(dir));
10627
+ if (import_node_fs16.default.existsSync(dir)) walk2(import_node_fs16.default.realpathSync(dir));
10475
10628
  return found;
10476
10629
  }
10477
10630
  function readPackageFile(root, file, maxBytes) {
10478
- const canonicalRoot = import_node_fs15.default.realpathSync(root);
10479
- const relative2 = import_node_path16.default.relative(canonicalRoot, import_node_fs15.default.realpathSync(file));
10480
- if (relative2 === ".." || relative2.startsWith(`..${import_node_path16.default.sep}`) || import_node_path16.default.isAbsolute(relative2)) {
10631
+ const canonicalRoot = import_node_fs16.default.realpathSync(root);
10632
+ const relative2 = import_node_path17.default.relative(canonicalRoot, import_node_fs16.default.realpathSync(file));
10633
+ if (relative2 === ".." || relative2.startsWith(`..${import_node_path17.default.sep}`) || import_node_path17.default.isAbsolute(relative2)) {
10481
10634
  throw new Error(`swift input escapes the selected package: ${file}`);
10482
10635
  }
10483
- let ancestor = import_node_path16.default.resolve(file);
10636
+ let ancestor = import_node_path17.default.resolve(file);
10484
10637
  while (ancestor !== canonicalRoot) {
10485
- if (import_node_fs15.default.lstatSync(ancestor).isSymbolicLink()) {
10638
+ if (import_node_fs16.default.lstatSync(ancestor).isSymbolicLink()) {
10486
10639
  throw new Error(`swift input is a symlink: ${ancestor}`);
10487
10640
  }
10488
- const parent = import_node_path16.default.dirname(ancestor);
10641
+ const parent = import_node_path17.default.dirname(ancestor);
10489
10642
  if (parent === ancestor)
10490
10643
  throw new Error(`swift input escapes the selected package: ${file}`);
10491
10644
  ancestor = parent;
10492
10645
  }
10493
- const expected = import_node_fs15.default.statSync(file);
10494
- const fd = import_node_fs15.default.openSync(file, import_node_fs15.default.constants.O_RDONLY | import_node_fs15.default.constants.O_NOFOLLOW);
10646
+ const expected = import_node_fs16.default.statSync(file);
10647
+ const fd = import_node_fs16.default.openSync(file, import_node_fs16.default.constants.O_RDONLY | import_node_fs16.default.constants.O_NOFOLLOW);
10495
10648
  try {
10496
- const stat2 = import_node_fs15.default.fstatSync(fd);
10649
+ const stat2 = import_node_fs16.default.fstatSync(fd);
10497
10650
  if (stat2.dev !== expected.dev || stat2.ino !== expected.ino) {
10498
10651
  throw new Error(`swift input changed while opening: ${file}`);
10499
10652
  }
@@ -10503,16 +10656,16 @@ function readPackageFile(root, file, maxBytes) {
10503
10656
  const bytes = Buffer.alloc(stat2.size + 1);
10504
10657
  let offset = 0;
10505
10658
  while (offset < bytes.length) {
10506
- const count = import_node_fs15.default.readSync(fd, bytes, offset, bytes.length - offset, null);
10659
+ const count = import_node_fs16.default.readSync(fd, bytes, offset, bytes.length - offset, null);
10507
10660
  if (count === 0) break;
10508
10661
  offset += count;
10509
10662
  }
10510
- if (offset !== stat2.size || import_node_fs15.default.fstatSync(fd).size !== stat2.size) {
10663
+ if (offset !== stat2.size || import_node_fs16.default.fstatSync(fd).size !== stat2.size) {
10511
10664
  throw new Error(`swift input changed while reading: ${file}`);
10512
10665
  }
10513
10666
  return bytes.subarray(0, offset);
10514
10667
  } finally {
10515
- import_node_fs15.default.closeSync(fd);
10668
+ import_node_fs16.default.closeSync(fd);
10516
10669
  }
10517
10670
  }
10518
10671
  function sourceFiles(root) {
@@ -10520,7 +10673,7 @@ function sourceFiles(root) {
10520
10673
  }
10521
10674
  function resourceCandidateFiles(root) {
10522
10675
  return packageFiles(root).filter(
10523
- (file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(import_node_path16.default.basename(file))
10676
+ (file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(import_node_path17.default.basename(file))
10524
10677
  );
10525
10678
  }
10526
10679
  var HOSTED_LIMITS = {
@@ -10554,7 +10707,7 @@ function buildSwiftResourceTable(project, baseUrl) {
10554
10707
  const limits = inputLimits(Boolean(project.hosted));
10555
10708
  const absolute = resourceCandidateFiles(project.packagePath);
10556
10709
  const relative2 = absolute.map(
10557
- (file) => import_node_path16.default.relative(project.packagePath, file).split(import_node_path16.default.sep).join(import_node_path16.default.posix.sep)
10710
+ (file) => import_node_path17.default.relative(project.packagePath, file).split(import_node_path17.default.sep).join(import_node_path17.default.posix.sep)
10558
10711
  );
10559
10712
  const byRelative = new Map(absolute.map((file, index) => [relative2[index], file]));
10560
10713
  const readContents = (candidate) => {
@@ -10576,16 +10729,16 @@ function buildSwiftResourceTable(project, baseUrl) {
10576
10729
  for (const { name: name2, file, scale } of found) {
10577
10730
  const disk = byRelative.get(file);
10578
10731
  if (!disk) continue;
10579
- if (Object.keys(images).length >= limits.images || imageBytes + import_node_fs15.default.statSync(disk).size > limits.imageTotalBytes) {
10732
+ if (Object.keys(images).length >= limits.images || imageBytes + import_node_fs16.default.statSync(disk).size > limits.imageTotalBytes) {
10580
10733
  throw new Error("swift image pack exceeds the compile service caps");
10581
10734
  }
10582
10735
  const bytes = readPackageFile(project.packagePath, disk, limits.imageBytes);
10583
10736
  imageBytes += bytes.length;
10584
- const hash = (0, import_node_crypto5.createHash)("sha256").update(bytes).digest("hex").slice(0, 16);
10585
- const ext = import_node_path16.default.posix.extname(file).toLowerCase();
10737
+ const hash = (0, import_node_crypto6.createHash)("sha256").update(bytes).digest("hex").slice(0, 16);
10738
+ const ext = import_node_path17.default.posix.extname(file).toLowerCase();
10586
10739
  table[name2] = { uri: `${baseUrl}${RESOURCE_PATH}${hash}${ext}`, scale };
10587
10740
  images[name2] = {
10588
- file: import_node_path16.default.posix.basename(file),
10741
+ file: import_node_path17.default.posix.basename(file),
10589
10742
  data: bytes.toString("base64")
10590
10743
  };
10591
10744
  watched.push(file);
@@ -10609,10 +10762,10 @@ function buildSwiftResourceTable(project, baseUrl) {
10609
10762
  return { table, images, colors, symbols, watched };
10610
10763
  }
10611
10764
  function buildSwiftBundleFiles(packagePath, hosted) {
10612
- packagePath = import_node_fs15.default.realpathSync(packagePath);
10765
+ packagePath = import_node_fs16.default.realpathSync(packagePath);
10613
10766
  const limits = inputLimits(hosted);
10614
10767
  const relative2 = resourceCandidateFiles(packagePath).map(
10615
- (file) => import_node_path16.default.relative(packagePath, file).split(import_node_path16.default.sep).join(import_node_path16.default.posix.sep)
10768
+ (file) => import_node_path17.default.relative(packagePath, file).split(import_node_path17.default.sep).join(import_node_path17.default.posix.sep)
10616
10769
  );
10617
10770
  const files = {};
10618
10771
  const watched = [];
@@ -10626,13 +10779,13 @@ function buildSwiftBundleFiles(packagePath, hosted) {
10626
10779
  total += bytes.length;
10627
10780
  if (xcode.app.infoPlistFile)
10628
10781
  watched.push(
10629
- import_node_path16.default.relative(packagePath, xcode.app.infoPlistFile).split(import_node_path16.default.sep).join("/")
10782
+ import_node_path17.default.relative(packagePath, xcode.app.infoPlistFile).split(import_node_path17.default.sep).join("/")
10630
10783
  );
10631
10784
  }
10632
10785
  for (const { base, file } of enumerateBundleJson(relative2)) {
10633
10786
  watched.push(file);
10634
- const disk = import_node_path16.default.join(packagePath, ...file.split("/"));
10635
- if (Object.keys(files).length >= limits.resources || total + import_node_fs15.default.statSync(disk).size > limits.resourceTotalBytes) {
10787
+ const disk = import_node_path17.default.join(packagePath, ...file.split("/"));
10788
+ if (Object.keys(files).length >= limits.resources || total + import_node_fs16.default.statSync(disk).size > limits.resourceTotalBytes) {
10636
10789
  throw new Error(
10637
10790
  `swift bundle pack exceeds ${limits.resources} files / ${limits.resourceTotalBytes} bytes`
10638
10791
  );
@@ -10647,12 +10800,12 @@ function serveSwiftResource(project, key) {
10647
10800
  return project.resourceFiles.get(key) ?? project.resourcesPrevious.get(key) ?? null;
10648
10801
  }
10649
10802
  function linkedModuleRoots(packagePath) {
10650
- packagePath = import_node_fs15.default.realpathSync(packagePath);
10803
+ packagePath = import_node_fs16.default.realpathSync(packagePath);
10651
10804
  let manifest;
10652
10805
  try {
10653
10806
  manifest = readPackageFile(
10654
10807
  packagePath,
10655
- import_node_path16.default.join(packagePath, "Package.swift"),
10808
+ import_node_path17.default.join(packagePath, "Package.swift"),
10656
10809
  MAX_SWIFT_COMPILE_SOURCE_BYTES
10657
10810
  ).toString("utf8");
10658
10811
  } catch {
@@ -10661,28 +10814,28 @@ function linkedModuleRoots(packagePath) {
10661
10814
  const roots = /* @__PURE__ */ new Set();
10662
10815
  const dependency = /\.package\(\s*path:\s*"([^"]+)"\s*\)/g;
10663
10816
  for (const match of manifest.replace(/^\s*\/\/.*$/gm, "").matchAll(dependency)) {
10664
- const root = import_node_path16.default.resolve(packagePath, match[1]);
10665
- if (import_node_fs15.default.existsSync(import_node_path16.default.join(root, "Package.swift"))) roots.add(root);
10817
+ const root = import_node_path17.default.resolve(packagePath, match[1]);
10818
+ if (import_node_fs16.default.existsSync(import_node_path17.default.join(root, "Package.swift"))) roots.add(root);
10666
10819
  }
10667
10820
  return [...roots].sort();
10668
10821
  }
10669
10822
  function sourceStamp(packagePath, moduleRootOverride, hosted = false) {
10670
- const hash = (0, import_node_crypto5.createHash)("sha256");
10823
+ const hash = (0, import_node_crypto6.createHash)("sha256");
10671
10824
  hash.update(packagePath);
10672
10825
  const projectInputs = new Set(packageFiles(packagePath));
10673
10826
  for (const file of [...projectInputs].sort()) {
10674
- hash.update(import_node_path16.default.relative(packagePath, file));
10675
- const stat2 = import_node_fs15.default.statSync(file);
10827
+ hash.update(import_node_path17.default.relative(packagePath, file));
10828
+ const stat2 = import_node_fs16.default.statSync(file);
10676
10829
  hash.update(`${stat2.mtimeMs}/${stat2.ctimeMs}/${stat2.size}`);
10677
10830
  }
10678
10831
  const moduleRoot = hosted ? void 0 : moduleRootOverride ?? linkedModuleRoots(packagePath).find(
10679
- (root) => import_node_fs15.default.existsSync(import_node_path16.default.join(root, "toolchain.json"))
10832
+ (root) => import_node_fs16.default.existsSync(import_node_path17.default.join(root, "toolchain.json"))
10680
10833
  );
10681
10834
  if (moduleRoot) {
10682
10835
  hash.update(moduleRoot);
10683
10836
  for (const relative2 of swiftModuleInputFiles(moduleRoot)) {
10684
10837
  hash.update(relative2);
10685
- hash.update(String(import_node_fs15.default.statSync(import_node_path16.default.join(moduleRoot, relative2)).mtimeMs));
10838
+ hash.update(String(import_node_fs16.default.statSync(import_node_path17.default.join(moduleRoot, relative2)).mtimeMs));
10686
10839
  }
10687
10840
  }
10688
10841
  return hash.digest("hex").slice(0, 16);
@@ -10694,8 +10847,8 @@ function packageSources(packagePath) {
10694
10847
  const xcode = xcodeLayout(packagePath);
10695
10848
  const files = {};
10696
10849
  for (const file of sourceFiles(packagePath)) {
10697
- const relative2 = import_node_path16.default.relative(packagePath, file).split(import_node_path16.default.sep).join(import_node_path16.default.posix.sep);
10698
- if (xcode && import_node_path16.default.basename(file) === "Package.swift") continue;
10850
+ const relative2 = import_node_path17.default.relative(packagePath, file).split(import_node_path17.default.sep).join(import_node_path17.default.posix.sep);
10851
+ if (xcode && import_node_path17.default.basename(file) === "Package.swift") continue;
10699
10852
  files[xcode ? xcodeInputKey(xcode, file, relative2) : relative2] = readPackageFile(
10700
10853
  packagePath,
10701
10854
  file,
@@ -10712,7 +10865,7 @@ function packageSnapshot(project) {
10712
10865
  files,
10713
10866
  resourcePaths: swiftImplicitResourcePaths(
10714
10867
  resourceCandidateFiles(project.packagePath).map(
10715
- (file) => import_node_path16.default.relative(project.packagePath, file).split(import_node_path16.default.sep).join(import_node_path16.default.posix.sep)
10868
+ (file) => import_node_path17.default.relative(project.packagePath, file).split(import_node_path17.default.sep).join(import_node_path17.default.posix.sep)
10716
10869
  )
10717
10870
  ),
10718
10871
  resources: buildSwiftResourceTable(project, ""),
@@ -10721,7 +10874,7 @@ function packageSnapshot(project) {
10721
10874
  ...native ? {
10722
10875
  glue: readPackageFile(
10723
10876
  project.packagePath,
10724
- import_node_path16.default.join(project.packagePath, NATIVE_GLUE),
10877
+ import_node_path17.default.join(project.packagePath, NATIVE_GLUE),
10725
10878
  MAX_SWIFT_COMPILE_SOURCE_BYTES
10726
10879
  ).toString("utf8")
10727
10880
  } : {}
@@ -10757,7 +10910,7 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
10757
10910
  package: content
10758
10911
  };
10759
10912
  const moduleRoot = moduleRootOverride ?? linkedModuleRoots(packagePath).find(
10760
- (root) => import_node_fs15.default.existsSync(import_node_path16.default.join(root, "toolchain.json"))
10913
+ (root) => import_node_fs16.default.existsSync(import_node_path17.default.join(root, "toolchain.json"))
10761
10914
  ) ?? await swiftDistributionRoot();
10762
10915
  if (!moduleRoot)
10763
10916
  return {
@@ -10783,10 +10936,10 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
10783
10936
  // server and a capture, or two checkouts) build each other's sources. so
10784
10937
  // each app and module checkout gets its own root, which keeps the same
10785
10938
  // app's incremental build across restarts.
10786
- buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ?? import_node_path16.default.join(
10787
- import_node_os5.default.tmpdir(),
10939
+ buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ?? import_node_path17.default.join(
10940
+ import_node_os6.default.tmpdir(),
10788
10941
  "contrast-swift-build",
10789
- (0, import_node_crypto5.createHash)("sha256").update(`${moduleRoot}\0${import_node_path16.default.resolve(packagePath)}`).digest("hex").slice(0, 16)
10942
+ (0, import_node_crypto6.createHash)("sha256").update(`${moduleRoot}\0${import_node_path17.default.resolve(packagePath)}`).digest("hex").slice(0, 16)
10790
10943
  ),
10791
10944
  moduleRoot,
10792
10945
  ...toolchain
@@ -10851,19 +11004,19 @@ function swiftApiGapReport(output) {
10851
11004
  }
10852
11005
  function missingModulesMessage(packagePath, missing) {
10853
11006
  const layout = xcodeLayout(packagePath);
10854
- const remote = new Map(
10855
- (layout?.app.remoteProducts ?? []).map((entry) => [
10856
- entry.product,
10857
- entry.repositoryURL
10858
- ])
10859
- );
11007
+ const gaps = new Map([
11008
+ ...(layout?.app.binaryFrameworks ?? []).map(
11009
+ (name2) => [name2, { source: "the project", reason: "a vendored binary framework" }]
11010
+ ),
11011
+ ...layout?.packages.modules ?? [],
11012
+ ...layout?.packages.unavailable ?? []
11013
+ ]);
10860
11014
  const width = Math.max(...[...missing.keys()].map((name2) => name2.length));
10861
11015
  return [
10862
11016
  `Peach does not provide ${missing.size} module${missing.size === 1 ? "" : "s"} this app imports:`,
10863
11017
  ...[...missing].map(([name2, files]) => {
10864
- const source = remote.get(name2);
10865
- const reason = layout?.unavailable.get(name2)?.reason;
10866
- return ` ${name2.padEnd(width)} ${files.length} file${files.length === 1 ? "" : "s"}${source ? `, package ${source}` : ""}${reason ? ` (${reason})` : ""}`;
11018
+ const gap = gaps.get(name2);
11019
+ return ` ${name2.padEnd(width)} ${files.length} file${files.length === 1 ? "" : "s"}${gap ? `, ${gap.source.includes("://") ? `package ${gap.source}` : gap.source.startsWith("/") ? `package ${import_node_path17.default.relative(packagePath, gap.source) || "."}` : gap.source} (${gap.reason})` : ""}`;
10867
11020
  })
10868
11021
  ].join("\n");
10869
11022
  }
@@ -10871,7 +11024,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
10871
11024
  const auth = hosted ? null : resolveCliAuth();
10872
11025
  if (!hosted && (!auth || auth.kind === "github")) {
10873
11026
  throw new Error(
10874
- `compiling ${import_node_path16.default.basename(packagePath)} for Peach needs \`peach login\` or PEACH_API_KEY: this peachsim has no local SwiftUI module, so Contrast compiles it`
11027
+ `compiling ${import_node_path17.default.basename(packagePath)} for Peach needs \`peach login\` or PEACH_API_KEY: this peachsim has no local SwiftUI module, so Contrast compiles it`
10875
11028
  );
10876
11029
  }
10877
11030
  const origin = hosted?.origin ?? resolveContrastBackendOrigin(auth?.kind === "session" ? auth.origin : null);
@@ -10890,7 +11043,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
10890
11043
  const bytes = sources.reduce((total2, text2) => total2 + Buffer.byteLength(text2), 0);
10891
11044
  if (sources.length > MAX_SWIFT_COMPILE_FILES || bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES) {
10892
11045
  throw new Error(
10893
- `${import_node_path16.default.basename(packagePath)} has ${sources.length} Swift files (${bytes} bytes), over Contrast's compile limits of ${MAX_SWIFT_COMPILE_FILES} files and ${MAX_SWIFT_COMPILE_SOURCE_BYTES} bytes; compile it on this machine with the Swift distribution instead`
11046
+ `${import_node_path17.default.basename(packagePath)} has ${sources.length} Swift files (${bytes} bytes), over Contrast's compile limits of ${MAX_SWIFT_COMPILE_FILES} files and ${MAX_SWIFT_COMPILE_SOURCE_BYTES} bytes; compile it on this machine with the Swift distribution instead`
10894
11047
  );
10895
11048
  }
10896
11049
  const descriptor = snapshot.native;
@@ -10909,7 +11062,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
10909
11062
  );
10910
11063
  if (descriptor && address.native?.hash !== descriptor.hash) {
10911
11064
  throw new Error(
10912
- `${import_node_path16.default.basename(packagePath)}: Contrast compiled native contract ${address.native?.hash ?? "none"} but one typegen wrote ${descriptor.hash}; the app's One and the compile host's differ, or the compile host is older than this peachsim`
11065
+ `${import_node_path17.default.basename(packagePath)}: Contrast compiled native contract ${address.native?.hash ?? "none"} but one typegen wrote ${descriptor.hash}; the app's One and the compile host's differ, or the compile host is older than this peachsim`
10913
11066
  );
10914
11067
  }
10915
11068
  const response = await fetch(address.url, { signal });
@@ -11028,13 +11181,13 @@ function serveSwiftPackageAsset(pathname, res) {
11028
11181
  }
11029
11182
 
11030
11183
  // src/expo-swift-host.ts
11031
- var run3 = (0, import_node_util3.promisify)(import_node_child_process7.execFile);
11184
+ var run3 = (0, import_node_util3.promisify)(import_node_child_process8.execFile);
11032
11185
  var scriptEnv = { ...process.env, [RNX_FORKED_SCRIPT_ENV]: "1" };
11033
11186
  var EXPO_SWIFT_ROUTE = "/__peach/expo-swift";
11034
11187
  var EXPO_SWIFT_ENTRY = "Sources/PeachExpoApp/PeachExpoEntry.swift";
11035
11188
  async function collectExpoSwiftSources(appRoot) {
11036
- appRoot = import_node_fs16.default.realpathSync(appRoot);
11037
- const appRequire = (0, import_node_module.createRequire)(import_node_path17.default.join(appRoot, "package.json"));
11189
+ appRoot = import_node_fs17.default.realpathSync(appRoot);
11190
+ const appRequire = (0, import_node_module.createRequire)(import_node_path18.default.join(appRoot, "package.json"));
11038
11191
  let autolinker;
11039
11192
  try {
11040
11193
  autolinker = appRequire.resolve("expo-modules-autolinking/package.json");
@@ -11048,7 +11201,7 @@ async function collectExpoSwiftSources(appRoot) {
11048
11201
  (command) => run3(
11049
11202
  process.execPath,
11050
11203
  [
11051
- import_node_path17.default.join(import_node_path17.default.dirname(autolinker), "bin/expo-modules-autolinking.js"),
11204
+ import_node_path18.default.join(import_node_path18.default.dirname(autolinker), "bin/expo-modules-autolinking.js"),
11052
11205
  command,
11053
11206
  "--platform",
11054
11207
  "apple",
@@ -11079,8 +11232,8 @@ async function collectExpoSwiftSources(appRoot) {
11079
11232
  const sourceRoot = Reflect.get(entry, "path");
11080
11233
  if (typeof sourceRoot !== "string")
11081
11234
  throw new Error("Expo autolinking entry has no path");
11082
- const canonical = import_node_fs16.default.realpathSync(sourceRoot);
11083
- if (canonical.split(import_node_path17.default.sep).includes("node_modules")) continue;
11235
+ const canonical = import_node_fs17.default.realpathSync(sourceRoot);
11236
+ if (canonical.split(import_node_path18.default.sep).includes("node_modules")) continue;
11084
11237
  const resolution = resolutions.find(
11085
11238
  (candidate) => candidate && typeof candidate === "object" && Reflect.get(candidate, "packageName") === Reflect.get(entry, "name")
11086
11239
  );
@@ -11106,12 +11259,12 @@ async function collectExpoSwiftSources(appRoot) {
11106
11259
  `(${className.includes(".") ? className : `${namespace}.${className}`}.self, ${name2 === null ? "nil" : JSON.stringify(name2)})`
11107
11260
  );
11108
11261
  }
11109
- const ios = import_node_path17.default.join(canonical, "ios");
11110
- if (import_node_fs16.default.lstatSync(ios).isSymbolicLink())
11262
+ const ios = import_node_path18.default.join(canonical, "ios");
11263
+ if (import_node_fs17.default.lstatSync(ios).isSymbolicLink())
11111
11264
  throw new Error(`Expo Swift source directory is a symlink: ${ios}`);
11112
11265
  const walk2 = (dir) => {
11113
- for (const child of import_node_fs16.default.readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
11114
- const file = import_node_path17.default.join(dir, child.name);
11266
+ for (const child of import_node_fs17.default.readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
11267
+ const file = import_node_path18.default.join(dir, child.name);
11115
11268
  if (child.isSymbolicLink())
11116
11269
  throw new Error(`Expo Swift source is a symlink: ${file}`);
11117
11270
  if (child.isDirectory()) {
@@ -11119,13 +11272,13 @@ async function collectExpoSwiftSources(appRoot) {
11119
11272
  continue;
11120
11273
  }
11121
11274
  if (!child.name.endsWith(".swift")) continue;
11122
- const size = import_node_fs16.default.statSync(file).size;
11275
+ const size = import_node_fs17.default.statSync(file).size;
11123
11276
  bytes += size;
11124
11277
  fileCount++;
11125
11278
  if (fileCount > MAX_SWIFT_COMPILE_FILES - 2 || bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES)
11126
11279
  throw new Error("Expo Swift sources exceed compile service caps");
11127
- files[`Sources/${namespace}/${import_node_path17.default.relative(ios, file).split(import_node_path17.default.sep).join("/")}`] = `#sourceLocation(file: ${JSON.stringify(file)}, line: 1)
11128
- ${import_node_fs16.default.readFileSync(file, "utf8")}`;
11280
+ files[`Sources/${namespace}/${import_node_path18.default.relative(ios, file).split(import_node_path18.default.sep).join("/")}`] = `#sourceLocation(file: ${JSON.stringify(file)}, line: 1)
11281
+ ${import_node_fs17.default.readFileSync(file, "utf8")}`;
11129
11282
  }
11130
11283
  };
11131
11284
  walk2(ios);
@@ -11210,7 +11363,7 @@ async function handleExpoSwiftRequest(req, res) {
11210
11363
  return true;
11211
11364
  }
11212
11365
  const root = url.searchParams.get("root");
11213
- if (!root || !import_node_path17.default.isAbsolute(root)) {
11366
+ if (!root || !import_node_path18.default.isAbsolute(root)) {
11214
11367
  res.writeHead(400);
11215
11368
  res.end("missing absolute app root");
11216
11369
  return true;
@@ -11227,7 +11380,7 @@ async function handleExpoSwiftRequest(req, res) {
11227
11380
  modules: [],
11228
11381
  failures: []
11229
11382
  };
11230
- const key = (0, import_node_crypto6.createHash)("sha256").update(import_node_fs16.default.realpathSync(root)).digest("hex");
11383
+ const key = (0, import_node_crypto7.createHash)("sha256").update(import_node_fs17.default.realpathSync(root)).digest("hex");
11231
11384
  const host2 = req.headers.host;
11232
11385
  if (!host2) throw new Error("Expo Swift request has no host");
11233
11386
  const base = `http://${host2}`;
@@ -11241,8 +11394,8 @@ async function handleExpoSwiftRequest(req, res) {
11241
11394
  continue;
11242
11395
  }
11243
11396
  try {
11244
- const packagePath = import_node_path17.default.join(
11245
- import_node_os6.default.tmpdir(),
11397
+ const packagePath = import_node_path18.default.join(
11398
+ import_node_os7.default.tmpdir(),
11246
11399
  "peach-expo-swift",
11247
11400
  key,
11248
11401
  unit.namespace
@@ -11251,7 +11404,7 @@ async function handleExpoSwiftRequest(req, res) {
11251
11404
  packagePath,
11252
11405
  new Map(
11253
11406
  Object.entries(unit.files).map(([name2, source]) => [
11254
- import_node_path17.default.join(packagePath, name2),
11407
+ import_node_path18.default.join(packagePath, name2),
11255
11408
  source
11256
11409
  ])
11257
11410
  )
@@ -11302,8 +11455,8 @@ async function handleExpoSwiftRequest(req, res) {
11302
11455
  import PackageDescription
11303
11456
  let package = Package(name: "PeachExpo", targets: [${targets.map((name2) => `.target(name: ${JSON.stringify(name2)}, path: ${JSON.stringify(`Sources/${name2}`)})`).join(", ")}, .executableTarget(name: "PeachExpoApp", path: "Sources/PeachExpoApp")])
11304
11457
  `;
11305
- const packagePath = import_node_path17.default.join(
11306
- import_node_os6.default.tmpdir(),
11458
+ const packagePath = import_node_path18.default.join(
11459
+ import_node_os7.default.tmpdir(),
11307
11460
  "peach-expo-swift",
11308
11461
  key,
11309
11462
  "linked-app"
@@ -11312,7 +11465,7 @@ let package = Package(name: "PeachExpo", targets: [${targets.map((name2) => `.ta
11312
11465
  packagePath,
11313
11466
  new Map(
11314
11467
  Object.entries(files).map(([name2, source]) => [
11315
- import_node_path17.default.join(packagePath, name2),
11468
+ import_node_path18.default.join(packagePath, name2),
11316
11469
  source
11317
11470
  ])
11318
11471
  )
@@ -11485,20 +11638,20 @@ var RNX_RUNTIME_PRODUCT = {
11485
11638
  var rnxRuntime = createRuntimeDelivery(RNX_RUNTIME_PRODUCT);
11486
11639
 
11487
11640
  // src/host/agent-host.ts
11641
+ var import_node_crypto10 = require("node:crypto");
11642
+ var import_node_fs21 = __toESM(require("node:fs"), 1);
11643
+ var import_node_path22 = __toESM(require("node:path"), 1);
11644
+
11645
+ // src/agent-sessions.ts
11646
+ var import_node_child_process9 = require("node:child_process");
11488
11647
  var import_node_crypto9 = require("node:crypto");
11489
11648
  var import_node_fs20 = __toESM(require("node:fs"), 1);
11490
11649
  var import_node_path21 = __toESM(require("node:path"), 1);
11491
-
11492
- // src/agent-sessions.ts
11493
- var import_node_child_process8 = require("node:child_process");
11494
- var import_node_crypto8 = require("node:crypto");
11495
- var import_node_fs19 = __toESM(require("node:fs"), 1);
11496
- var import_node_path20 = __toESM(require("node:path"), 1);
11497
11650
  var import_node_readline = __toESM(require("node:readline"), 1);
11498
11651
 
11499
11652
  // cli/self-invocation.ts
11500
- var import_node_fs17 = require("node:fs");
11501
- var import_node_path18 = require("node:path");
11653
+ var import_node_fs18 = require("node:fs");
11654
+ var import_node_path19 = require("node:path");
11502
11655
  var import_node_url3 = require("node:url");
11503
11656
  init_public_brand();
11504
11657
 
@@ -11508,14 +11661,14 @@ var IS_STANDALONE = typeof __SOOTSIM_STANDALONE__ !== "undefined" && __SOOTSIM_S
11508
11661
  // cli/self-invocation.ts
11509
11662
  function sourceEntryPath() {
11510
11663
  try {
11511
- const candidate = (0, import_node_path18.join)((0, import_node_path18.dirname)((0, import_node_url3.fileURLToPath)(__sootsim_import_meta_url)), "bin.ts");
11512
- return (0, import_node_fs17.existsSync)(candidate) ? candidate : null;
11664
+ const candidate = (0, import_node_path19.join)((0, import_node_path19.dirname)((0, import_node_url3.fileURLToPath)(__sootsim_import_meta_url)), "bin.ts");
11665
+ return (0, import_node_fs18.existsSync)(candidate) ? candidate : null;
11513
11666
  } catch {
11514
11667
  return null;
11515
11668
  }
11516
11669
  }
11517
- function isCliEntry(path21) {
11518
- const name2 = (0, import_node_path18.basename)(path21);
11670
+ function isCliEntry(path22) {
11671
+ const name2 = (0, import_node_path19.basename)(path22);
11519
11672
  return name2 === "bin.ts" || name2 === "bin.js";
11520
11673
  }
11521
11674
  function rnxSelfInvocation() {
@@ -11574,9 +11727,9 @@ function encodeAgentPromptEnvelope(input) {
11574
11727
  }
11575
11728
 
11576
11729
  // src/attached-projects.ts
11577
- var import_node_crypto7 = require("node:crypto");
11578
- var import_node_fs18 = __toESM(require("node:fs"), 1);
11579
- var import_node_path19 = __toESM(require("node:path"), 1);
11730
+ var import_node_crypto8 = require("node:crypto");
11731
+ var import_node_fs19 = __toESM(require("node:fs"), 1);
11732
+ var import_node_path20 = __toESM(require("node:path"), 1);
11580
11733
  init_home_paths();
11581
11734
  var overrideDir = null;
11582
11735
  function userDataDir() {
@@ -11589,7 +11742,7 @@ function getUserDataDir() {
11589
11742
  return userDataDir();
11590
11743
  }
11591
11744
  function storeFile() {
11592
- return import_node_path19.default.join(userDataDir(), "attached-projects.json");
11745
+ return import_node_path20.default.join(userDataDir(), "attached-projects.json");
11593
11746
  }
11594
11747
  function cloneEmpty() {
11595
11748
  return {
@@ -11603,7 +11756,7 @@ function loadStore() {
11603
11756
  const file = storeFile();
11604
11757
  let raw2;
11605
11758
  try {
11606
- raw2 = import_node_fs18.default.readFileSync(file, "utf8");
11759
+ raw2 = import_node_fs19.default.readFileSync(file, "utf8");
11607
11760
  } catch (err) {
11608
11761
  if (err.code === "ENOENT") return cloneEmpty();
11609
11762
  throw err;
@@ -11620,7 +11773,7 @@ function loadStore() {
11620
11773
  } catch (err) {
11621
11774
  const quarantine = `${file}.corrupt-${Date.now()}`;
11622
11775
  try {
11623
- import_node_fs18.default.renameSync(file, quarantine);
11776
+ import_node_fs19.default.renameSync(file, quarantine);
11624
11777
  console.warn(
11625
11778
  `[sootsim] attached-projects.json was unparseable; quarantined to ${quarantine}. original error: ${err.message}`
11626
11779
  );
@@ -11631,16 +11784,16 @@ function loadStore() {
11631
11784
  }
11632
11785
  function writeStore(store) {
11633
11786
  const file = storeFile();
11634
- import_node_fs18.default.mkdirSync(import_node_path19.default.dirname(file), { recursive: true });
11787
+ import_node_fs19.default.mkdirSync(import_node_path20.default.dirname(file), { recursive: true });
11635
11788
  const tmp = `${file}.tmp-${process.pid}-${Date.now()}`;
11636
- const fd = import_node_fs18.default.openSync(tmp, "w", 384);
11789
+ const fd = import_node_fs19.default.openSync(tmp, "w", 384);
11637
11790
  try {
11638
- import_node_fs18.default.writeFileSync(fd, JSON.stringify(store, null, 2));
11639
- import_node_fs18.default.fsyncSync(fd);
11791
+ import_node_fs19.default.writeFileSync(fd, JSON.stringify(store, null, 2));
11792
+ import_node_fs19.default.fsyncSync(fd);
11640
11793
  } finally {
11641
- import_node_fs18.default.closeSync(fd);
11794
+ import_node_fs19.default.closeSync(fd);
11642
11795
  }
11643
- import_node_fs18.default.renameSync(tmp, file);
11796
+ import_node_fs19.default.renameSync(tmp, file);
11644
11797
  }
11645
11798
  function mutateStore(fn) {
11646
11799
  const store = loadStore();
@@ -11649,13 +11802,13 @@ function mutateStore(fn) {
11649
11802
  return store;
11650
11803
  }
11651
11804
  function projectIdForCwd(cwd) {
11652
- return (0, import_node_crypto7.createHash)("sha256").update(import_node_path19.default.resolve(cwd)).digest("hex").slice(0, 16);
11805
+ return (0, import_node_crypto8.createHash)("sha256").update(import_node_path20.default.resolve(cwd)).digest("hex").slice(0, 16);
11653
11806
  }
11654
11807
  function newSessionId() {
11655
- return `s_${(0, import_node_crypto7.randomBytes)(10).toString("hex")}`;
11808
+ return `s_${(0, import_node_crypto8.randomBytes)(10).toString("hex")}`;
11656
11809
  }
11657
11810
  function upsertProject(input) {
11658
- const cwd = import_node_path19.default.resolve(input.cwd);
11811
+ const cwd = import_node_path20.default.resolve(input.cwd);
11659
11812
  const id = projectIdForCwd(cwd);
11660
11813
  let result;
11661
11814
  mutateStore((store) => {
@@ -11681,7 +11834,7 @@ function upsertProject(input) {
11681
11834
  const now = Date.now();
11682
11835
  const created = {
11683
11836
  id,
11684
- name: input.name ?? import_node_path19.default.basename(cwd),
11837
+ name: input.name ?? import_node_path20.default.basename(cwd),
11685
11838
  cwd,
11686
11839
  repoRoot: input.repoRoot,
11687
11840
  sourceRoots: input.sourceRoots ?? [cwd],
@@ -11827,8 +11980,8 @@ async function seedFromDemoAppRegistry() {
11827
11980
  if (apps.length === 0) return;
11828
11981
  mutateStore((store) => {
11829
11982
  for (const app of apps) {
11830
- if (!import_node_fs18.default.existsSync(app.dir)) continue;
11831
- const cwd = import_node_path19.default.resolve(app.dir);
11983
+ if (!import_node_fs19.default.existsSync(app.dir)) continue;
11984
+ const cwd = import_node_path20.default.resolve(app.dir);
11832
11985
  const id = projectIdForCwd(cwd);
11833
11986
  if (store.attachedProjects.some((p) => p.id === id)) continue;
11834
11987
  const now = Date.now();
@@ -11853,16 +12006,16 @@ async function seedFromDemoAppRegistry() {
11853
12006
  // src/agent-sessions.ts
11854
12007
  init_public_brand();
11855
12008
  function sessionDir(sessionId) {
11856
- return import_node_path20.default.join(getUserDataDir(), "sessions", sessionId);
12009
+ return import_node_path21.default.join(getUserDataDir(), "sessions", sessionId);
11857
12010
  }
11858
12011
  function promptFifoPath(sessionId) {
11859
- return import_node_path20.default.join(sessionDir(sessionId), "prompt.in");
12012
+ return import_node_path21.default.join(sessionDir(sessionId), "prompt.in");
11860
12013
  }
11861
12014
  function eventsFifoPath(sessionId) {
11862
- return import_node_path20.default.join(sessionDir(sessionId), "events.out");
12015
+ return import_node_path21.default.join(sessionDir(sessionId), "events.out");
11863
12016
  }
11864
12017
  function transcriptPath(sessionId) {
11865
- return import_node_path20.default.join(getUserDataDir(), "transcripts", `${sessionId}.log`);
12018
+ return import_node_path21.default.join(getUserDataDir(), "transcripts", `${sessionId}.log`);
11866
12019
  }
11867
12020
  function pidIsAlive(pid, sessionId) {
11868
12021
  if (!pid) return false;
@@ -11872,7 +12025,7 @@ function pidIsAlive(pid, sessionId) {
11872
12025
  return false;
11873
12026
  }
11874
12027
  if (sessionId) {
11875
- if (!import_node_fs19.default.existsSync(sessionDir(sessionId))) return false;
12028
+ if (!import_node_fs20.default.existsSync(sessionDir(sessionId))) return false;
11876
12029
  }
11877
12030
  return true;
11878
12031
  }
@@ -11885,11 +12038,11 @@ function resolveSootsimInvocation() {
11885
12038
  const resourcesPath = process.resourcesPath;
11886
12039
  if (resourcesPath) {
11887
12040
  const candidates = [
11888
- import_node_path20.default.join(resourcesPath, "bin", "sootsim"),
11889
- import_node_path20.default.join(resourcesPath, "bin", `sootsim-${process.platform}-${process.arch}`)
12041
+ import_node_path21.default.join(resourcesPath, "bin", "sootsim"),
12042
+ import_node_path21.default.join(resourcesPath, "bin", `sootsim-${process.platform}-${process.arch}`)
11890
12043
  ];
11891
12044
  for (const c of candidates) {
11892
- if (import_node_fs19.default.existsSync(c)) return { executable: c, prefixArgs: [] };
12045
+ if (import_node_fs20.default.existsSync(c)) return { executable: c, prefixArgs: [] };
11893
12046
  }
11894
12047
  }
11895
12048
  }
@@ -11908,15 +12061,15 @@ function tryWorkspaceSootsim() {
11908
12061
  const sootsimDir = resolveSootsimPackageDir();
11909
12062
  if (!sootsimDir) return null;
11910
12063
  const binaryName = `peach-${process.platform === "win32" ? "windows" : process.platform}-${process.arch}${process.platform === "win32" ? ".exe" : ""}`;
11911
- const distBinary = import_node_path20.default.join(sootsimDir, "dist-bin", binaryName);
11912
- if (import_node_fs19.default.existsSync(distBinary)) return { executable: distBinary, prefixArgs: [] };
11913
- const distBin = import_node_path20.default.join(sootsimDir, "dist-cli", "bin.js");
11914
- if (import_node_fs19.default.existsSync(distBin)) {
12064
+ const distBinary = import_node_path21.default.join(sootsimDir, "dist-bin", binaryName);
12065
+ if (import_node_fs20.default.existsSync(distBinary)) return { executable: distBinary, prefixArgs: [] };
12066
+ const distBin = import_node_path21.default.join(sootsimDir, "dist-cli", "bin.js");
12067
+ if (import_node_fs20.default.existsSync(distBin)) {
11915
12068
  try {
11916
- const src = import_node_path20.default.join(sootsimDir, "cli", "commands", "agent-wrapper.ts");
11917
- if (import_node_fs19.default.existsSync(src)) {
11918
- const srcMtime = import_node_fs19.default.statSync(src).mtimeMs;
11919
- const buildMtime = import_node_fs19.default.statSync(distBin).mtimeMs;
12069
+ const src = import_node_path21.default.join(sootsimDir, "cli", "commands", "agent-wrapper.ts");
12070
+ if (import_node_fs20.default.existsSync(src)) {
12071
+ const srcMtime = import_node_fs20.default.statSync(src).mtimeMs;
12072
+ const buildMtime = import_node_fs20.default.statSync(distBin).mtimeMs;
11920
12073
  if (buildMtime < srcMtime) {
11921
12074
  console.warn(
11922
12075
  `[peach] dist-cli/bin.js is older than agent-wrapper.ts \u2014 rebuild with \`bun run --cwd packages/peachsim build:cli\`.`
@@ -11935,22 +12088,22 @@ function tryWorkspaceSootsim() {
11935
12088
  function resolveSootsimPackageDir() {
11936
12089
  try {
11937
12090
  const resolved = require.resolve(`${rnxPublicBrand.packageName}/package.json`);
11938
- return import_node_path20.default.dirname(resolved);
12091
+ return import_node_path21.default.dirname(resolved);
11939
12092
  } catch {
11940
12093
  }
11941
12094
  const here = fileFromImportMeta();
11942
12095
  if (!here) return null;
11943
- let cur = import_node_path20.default.dirname(here);
12096
+ let cur = import_node_path21.default.dirname(here);
11944
12097
  for (let i = 0; i < 8; i++) {
11945
- const pkg = import_node_path20.default.join(cur, "package.json");
12098
+ const pkg = import_node_path21.default.join(cur, "package.json");
11946
12099
  try {
11947
- if (import_node_fs19.default.existsSync(pkg)) {
11948
- const parsed = JSON.parse(import_node_fs19.default.readFileSync(pkg, "utf8"));
12100
+ if (import_node_fs20.default.existsSync(pkg)) {
12101
+ const parsed = JSON.parse(import_node_fs20.default.readFileSync(pkg, "utf8"));
11949
12102
  if (parsed.name === rnxPublicBrand.packageName) return cur;
11950
12103
  }
11951
12104
  } catch {
11952
12105
  }
11953
- const parent = import_node_path20.default.dirname(cur);
12106
+ const parent = import_node_path21.default.dirname(cur);
11954
12107
  if (parent === cur) break;
11955
12108
  cur = parent;
11956
12109
  }
@@ -11966,28 +12119,28 @@ function fileFromImportMeta() {
11966
12119
  }
11967
12120
  }
11968
12121
  async function withStartLock(projectId, provider, fn) {
11969
- const lockDir = import_node_path20.default.join(getUserDataDir(), "locks");
11970
- import_node_fs19.default.mkdirSync(lockDir, { recursive: true });
12122
+ const lockDir = import_node_path21.default.join(getUserDataDir(), "locks");
12123
+ import_node_fs20.default.mkdirSync(lockDir, { recursive: true });
11971
12124
  try {
11972
- import_node_fs19.default.chmodSync(lockDir, 448);
12125
+ import_node_fs20.default.chmodSync(lockDir, 448);
11973
12126
  } catch {
11974
12127
  }
11975
- const lockPath = import_node_path20.default.join(lockDir, `start-${projectId}-${provider}.lock`);
12128
+ const lockPath = import_node_path21.default.join(lockDir, `start-${projectId}-${provider}.lock`);
11976
12129
  const deadline = Date.now() + 4e3;
11977
12130
  let fd = null;
11978
12131
  while (fd === null) {
11979
12132
  try {
11980
- fd = import_node_fs19.default.openSync(
12133
+ fd = import_node_fs20.default.openSync(
11981
12134
  lockPath,
11982
- import_node_fs19.constants.O_WRONLY | import_node_fs19.constants.O_CREAT | import_node_fs19.constants.O_EXCL,
12135
+ import_node_fs20.constants.O_WRONLY | import_node_fs20.constants.O_CREAT | import_node_fs20.constants.O_EXCL,
11983
12136
  384
11984
12137
  );
11985
12138
  } catch (err) {
11986
12139
  if (err.code !== "EEXIST") throw err;
11987
12140
  try {
11988
- const stale = Number(import_node_fs19.default.readFileSync(lockPath, "utf8").trim());
12141
+ const stale = Number(import_node_fs20.default.readFileSync(lockPath, "utf8").trim());
11989
12142
  if (stale && !isProcessAlive(stale)) {
11990
- import_node_fs19.default.unlinkSync(lockPath);
12143
+ import_node_fs20.default.unlinkSync(lockPath);
11991
12144
  continue;
11992
12145
  }
11993
12146
  } catch {
@@ -12001,15 +12154,15 @@ async function withStartLock(projectId, provider, fn) {
12001
12154
  }
12002
12155
  }
12003
12156
  try {
12004
- import_node_fs19.default.writeFileSync(fd, String(process.pid));
12157
+ import_node_fs20.default.writeFileSync(fd, String(process.pid));
12005
12158
  return await fn();
12006
12159
  } finally {
12007
12160
  try {
12008
- import_node_fs19.default.closeSync(fd);
12161
+ import_node_fs20.default.closeSync(fd);
12009
12162
  } catch {
12010
12163
  }
12011
12164
  try {
12012
- import_node_fs19.default.unlinkSync(lockPath);
12165
+ import_node_fs20.default.unlinkSync(lockPath);
12013
12166
  } catch {
12014
12167
  }
12015
12168
  }
@@ -12023,28 +12176,28 @@ function isProcessAlive(pid) {
12023
12176
  }
12024
12177
  }
12025
12178
  function mkfifoSync(p) {
12026
- const parent = import_node_path20.default.dirname(p);
12027
- import_node_fs19.default.mkdirSync(parent, { recursive: true });
12179
+ const parent = import_node_path21.default.dirname(p);
12180
+ import_node_fs20.default.mkdirSync(parent, { recursive: true });
12028
12181
  try {
12029
- import_node_fs19.default.chmodSync(parent, 448);
12182
+ import_node_fs20.default.chmodSync(parent, 448);
12030
12183
  } catch {
12031
12184
  }
12032
- if (import_node_fs19.default.existsSync(p)) {
12185
+ if (import_node_fs20.default.existsSync(p)) {
12033
12186
  try {
12034
- const stat2 = import_node_fs19.default.statSync(p);
12187
+ const stat2 = import_node_fs20.default.statSync(p);
12035
12188
  if (stat2.isFIFO()) {
12036
12189
  try {
12037
- import_node_fs19.default.chmodSync(p, 384);
12190
+ import_node_fs20.default.chmodSync(p, 384);
12038
12191
  } catch {
12039
12192
  }
12040
12193
  return;
12041
12194
  }
12042
- import_node_fs19.default.unlinkSync(p);
12195
+ import_node_fs20.default.unlinkSync(p);
12043
12196
  } catch {
12044
- import_node_fs19.default.unlinkSync(p);
12197
+ import_node_fs20.default.unlinkSync(p);
12045
12198
  }
12046
12199
  }
12047
- const result = (0, import_node_child_process8.spawnSync)("mkfifo", ["-m", "600", p]);
12200
+ const result = (0, import_node_child_process9.spawnSync)("mkfifo", ["-m", "600", p]);
12048
12201
  if (result.status !== 0) {
12049
12202
  throw new Error(
12050
12203
  `mkfifo(${p}) failed: ${result.stderr?.toString().trim() || "unknown error"}`
@@ -12074,7 +12227,7 @@ async function startSession(opts) {
12074
12227
  `session already running for project=${project.id} provider=${provider} (session ${existingLive.id}, pid ${existingLive.wrapperPid}). end it first with \`peach agent end <sessionId>\`.`
12075
12228
  );
12076
12229
  }
12077
- const claudeSessionUuid = provider === "claude" ? (0, import_node_crypto8.randomUUID)() : void 0;
12230
+ const claudeSessionUuid = provider === "claude" ? (0, import_node_crypto9.randomUUID)() : void 0;
12078
12231
  const session = upsertSession({
12079
12232
  projectId: project.id,
12080
12233
  provider,
@@ -12088,10 +12241,10 @@ async function startSession(opts) {
12088
12241
  const transcript = transcriptPath(session.id);
12089
12242
  mkfifoSync(promptIn);
12090
12243
  mkfifoSync(eventsOut);
12091
- const transcriptDir = import_node_path20.default.dirname(transcript);
12092
- import_node_fs19.default.mkdirSync(transcriptDir, { recursive: true });
12244
+ const transcriptDir = import_node_path21.default.dirname(transcript);
12245
+ import_node_fs20.default.mkdirSync(transcriptDir, { recursive: true });
12093
12246
  try {
12094
- import_node_fs19.default.chmodSync(transcriptDir, 448);
12247
+ import_node_fs20.default.chmodSync(transcriptDir, 448);
12095
12248
  } catch {
12096
12249
  }
12097
12250
  const { executable, prefixArgs } = resolveSootsimInvocation();
@@ -12119,7 +12272,7 @@ async function startSession(opts) {
12119
12272
  if (claudeSessionUuid) {
12120
12273
  wrapperArgs.push("--claude-session-uuid", claudeSessionUuid);
12121
12274
  }
12122
- const child = (0, import_node_child_process8.spawn)(executable, wrapperArgs, {
12275
+ const child = (0, import_node_child_process9.spawn)(executable, wrapperArgs, {
12123
12276
  detached: true,
12124
12277
  stdio: "ignore",
12125
12278
  env: {
@@ -12142,7 +12295,7 @@ async function startSession(opts) {
12142
12295
  }
12143
12296
  }
12144
12297
  try {
12145
- import_node_fs19.default.rmSync(sessionDir(session.id), { recursive: true, force: true });
12298
+ import_node_fs20.default.rmSync(sessionDir(session.id), { recursive: true, force: true });
12146
12299
  } catch {
12147
12300
  }
12148
12301
  updateSessionStatus(session.id, { status: "ended" });
@@ -12170,18 +12323,18 @@ async function sendPrompt(sessionId, prompt) {
12170
12323
  );
12171
12324
  }
12172
12325
  const fifo = promptFifoPath(sessionId);
12173
- if (!import_node_fs19.default.existsSync(fifo)) {
12326
+ if (!import_node_fs20.default.existsSync(fifo)) {
12174
12327
  throw new AgentSessionError("NO_FIFO", `prompt FIFO missing: ${fifo}`);
12175
12328
  }
12176
- const fd = import_node_fs19.default.openSync(fifo, import_node_fs19.constants.O_WRONLY);
12329
+ const fd = import_node_fs20.default.openSync(fifo, import_node_fs20.constants.O_WRONLY);
12177
12330
  try {
12178
12331
  const wireText = encodeAgentPromptEnvelope(prompt);
12179
12332
  if (!wireText) {
12180
12333
  throw new AgentSessionError("EMPTY_PROMPT", "prompt text is empty");
12181
12334
  }
12182
- import_node_fs19.default.writeSync(fd, wireText + "\n");
12335
+ import_node_fs20.default.writeSync(fd, wireText + "\n");
12183
12336
  } finally {
12184
- import_node_fs19.default.closeSync(fd);
12337
+ import_node_fs20.default.closeSync(fd);
12185
12338
  }
12186
12339
  updateSessionStatus(sessionId, {
12187
12340
  lastPrompt: prompt.displayText ?? prompt.text,
@@ -12203,7 +12356,7 @@ async function endSession(sessionId) {
12203
12356
  const base = getUserDataDir();
12204
12357
  if (dir.startsWith(base)) {
12205
12358
  try {
12206
- import_node_fs19.default.rmSync(dir, { recursive: true, force: true });
12359
+ import_node_fs20.default.rmSync(dir, { recursive: true, force: true });
12207
12360
  } catch {
12208
12361
  }
12209
12362
  }
@@ -12211,11 +12364,11 @@ async function endSession(sessionId) {
12211
12364
  }
12212
12365
  function subscribeEvents(sessionId, onEvent) {
12213
12366
  const fifo = eventsFifoPath(sessionId);
12214
- if (!import_node_fs19.default.existsSync(fifo)) {
12367
+ if (!import_node_fs20.default.existsSync(fifo)) {
12215
12368
  throw new AgentSessionError("NO_FIFO", `events FIFO missing: ${fifo}`);
12216
12369
  }
12217
- const fd = import_node_fs19.default.openSync(fifo, import_node_fs19.constants.O_RDWR);
12218
- const stream = import_node_fs19.default.createReadStream("", { fd, autoClose: true });
12370
+ const fd = import_node_fs20.default.openSync(fifo, import_node_fs20.constants.O_RDWR);
12371
+ const stream = import_node_fs20.default.createReadStream("", { fd, autoClose: true });
12219
12372
  const rl = import_node_readline.default.createInterface({ input: stream, crlfDelay: Infinity });
12220
12373
  rl.on("line", (line) => {
12221
12374
  const event = parseAgentEventLine(line);
@@ -12226,7 +12379,7 @@ function subscribeEvents(sessionId, onEvent) {
12226
12379
  if (closed) return;
12227
12380
  closed = true;
12228
12381
  try {
12229
- import_node_fs19.default.writeSync(fd, "\n");
12382
+ import_node_fs20.default.writeSync(fd, "\n");
12230
12383
  } catch {
12231
12384
  }
12232
12385
  try {
@@ -12240,7 +12393,7 @@ function subscribeEvents(sessionId, onEvent) {
12240
12393
  };
12241
12394
  }
12242
12395
  async function waitForFirstEvent(fifo, predicate, timeoutMs) {
12243
- const fd = import_node_fs19.default.openSync(fifo, import_node_fs19.constants.O_RDWR | import_node_fs19.constants.O_NONBLOCK);
12396
+ const fd = import_node_fs20.default.openSync(fifo, import_node_fs20.constants.O_RDWR | import_node_fs20.constants.O_NONBLOCK);
12244
12397
  const buf = Buffer.alloc(8192);
12245
12398
  let leftover = "";
12246
12399
  const deadline = Date.now() + timeoutMs;
@@ -12248,7 +12401,7 @@ async function waitForFirstEvent(fifo, predicate, timeoutMs) {
12248
12401
  while (Date.now() < deadline) {
12249
12402
  let n = 0;
12250
12403
  try {
12251
- n = import_node_fs19.default.readSync(fd, buf, 0, buf.length, null);
12404
+ n = import_node_fs20.default.readSync(fd, buf, 0, buf.length, null);
12252
12405
  } catch (err) {
12253
12406
  if (err.code !== "EAGAIN") throw err;
12254
12407
  n = 0;
@@ -12268,7 +12421,7 @@ async function waitForFirstEvent(fifo, predicate, timeoutMs) {
12268
12421
  }
12269
12422
  return null;
12270
12423
  } finally {
12271
- import_node_fs19.default.closeSync(fd);
12424
+ import_node_fs20.default.closeSync(fd);
12272
12425
  }
12273
12426
  }
12274
12427
 
@@ -12476,7 +12629,7 @@ var AgentHost = class {
12476
12629
  throw new AgentSessionError("EMPTY_PROMPT", "inspect message cannot be empty");
12477
12630
  }
12478
12631
  const message = {
12479
- id: `inspect-${(0, import_node_crypto9.randomUUID)()}`,
12632
+ id: `inspect-${(0, import_node_crypto10.randomUUID)()}`,
12480
12633
  simId,
12481
12634
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
12482
12635
  prompt
@@ -12522,7 +12675,7 @@ var AgentHost = class {
12522
12675
  );
12523
12676
  const project = upsertProject({
12524
12677
  cwd: match.cwd,
12525
- name: match.projectName ?? import_node_path21.default.basename(match.cwd),
12678
+ name: match.projectName ?? import_node_path22.default.basename(match.cwd),
12526
12679
  preferredProvider: input.provider ?? existing?.preferredProvider,
12527
12680
  sourceRoots: existing?.sourceRoots ?? [match.cwd],
12528
12681
  knownBundleUrls,
@@ -12533,18 +12686,18 @@ var AgentHost = class {
12533
12686
  }
12534
12687
  getTranscript(sessionId) {
12535
12688
  const p = transcriptPath(sessionId);
12536
- if (!import_node_fs20.default.existsSync(p)) {
12689
+ if (!import_node_fs21.default.existsSync(p)) {
12537
12690
  return { error: "transcript not found", code: "NO_TRANSCRIPT" };
12538
12691
  }
12539
- return import_node_fs20.default.readFileSync(p, "utf8");
12692
+ return import_node_fs21.default.readFileSync(p, "utf8");
12540
12693
  }
12541
12694
  getPaths() {
12542
12695
  const dir = getUserDataDir();
12543
12696
  return {
12544
12697
  userDataDir: dir,
12545
- storeFile: import_node_path21.default.join(dir, "attached-projects.json"),
12546
- sessionsDir: import_node_path21.default.join(dir, "sessions"),
12547
- transcriptsDir: import_node_path21.default.join(dir, "transcripts")
12698
+ storeFile: import_node_path22.default.join(dir, "attached-projects.json"),
12699
+ sessionsDir: import_node_path22.default.join(dir, "sessions"),
12700
+ transcriptsDir: import_node_path22.default.join(dir, "transcripts")
12548
12701
  };
12549
12702
  }
12550
12703
  // --- subscription management ---
@@ -13245,7 +13398,7 @@ function handleAppApiRequest(req, res) {
13245
13398
  }
13246
13399
 
13247
13400
  // src/host/fetch-proxy-transport.ts
13248
- var import_node_crypto10 = require("node:crypto");
13401
+ var import_node_crypto11 = require("node:crypto");
13249
13402
  var import_node_http22 = require("node:http2");
13250
13403
  var import_x509 = require("@peculiar/x509");
13251
13404
  async function startFetchProxyTransport() {
@@ -13253,7 +13406,7 @@ async function startFetchProxyTransport() {
13253
13406
  const keys = await crypto.subtle.generateKey(algorithm, true, ["sign", "verify"]);
13254
13407
  const certificate = await import_x509.X509CertificateGenerator.createSelfSigned(
13255
13408
  {
13256
- serialNumber: (0, import_node_crypto10.randomBytes)(16).toString("hex"),
13409
+ serialNumber: (0, import_node_crypto11.randomBytes)(16).toString("hex"),
13257
13410
  name: "CN=localhost",
13258
13411
  notBefore: new Date(Date.now() - 6e4),
13259
13412
  notAfter: new Date(Date.now() + 365 * 24 * 60 * 6e4),
@@ -13266,7 +13419,7 @@ async function startFetchProxyTransport() {
13266
13419
  crypto
13267
13420
  );
13268
13421
  const privateKey = Buffer.from(await crypto.subtle.exportKey("pkcs8", keys.privateKey));
13269
- const spki = (0, import_node_crypto10.createHash)("sha256").update(Buffer.from(await crypto.subtle.exportKey("spki", keys.publicKey))).digest("base64");
13422
+ const spki = (0, import_node_crypto11.createHash)("sha256").update(Buffer.from(await crypto.subtle.exportKey("spki", keys.publicKey))).digest("base64");
13270
13423
  const sessions = /* @__PURE__ */ new Set();
13271
13424
  const server = (0, import_node_http22.createSecureServer)(
13272
13425
  {
@@ -13388,8 +13541,8 @@ async function openUrl(url, options = {}) {
13388
13541
  }
13389
13542
 
13390
13543
  // src/host/plane-host.ts
13391
- var import_node_fs22 = __toESM(require("node:fs"), 1);
13392
- var import_node_path23 = __toESM(require("node:path"), 1);
13544
+ var import_node_fs23 = __toESM(require("node:fs"), 1);
13545
+ var import_node_path24 = __toESM(require("node:path"), 1);
13393
13546
 
13394
13547
  // ../peach-box/src/planeProtocol.ts
13395
13548
  var PLANE_FLAG_READ_ONLY = 1;
@@ -13468,9 +13621,9 @@ async function dispatchPlaneCommand(plane, type, msg, mutationOptions) {
13468
13621
  }
13469
13622
 
13470
13623
  // cli/commands/box/checkout-plane.ts
13471
- var import_node_child_process9 = require("node:child_process");
13472
- var import_node_fs21 = __toESM(require("node:fs"), 1);
13473
- var import_node_path22 = __toESM(require("node:path"), 1);
13624
+ var import_node_child_process10 = require("node:child_process");
13625
+ var import_node_fs22 = __toESM(require("node:fs"), 1);
13626
+ var import_node_path23 = __toESM(require("node:path"), 1);
13474
13627
  var CheckoutRequiresGitError = class extends Error {
13475
13628
  };
13476
13629
  var BINARY_SNIFF_BYTES = 8192;
@@ -13481,14 +13634,14 @@ function looksBinary(filePath, size) {
13481
13634
  if (size === 0) return false;
13482
13635
  let fd;
13483
13636
  try {
13484
- fd = import_node_fs21.default.openSync(filePath, "r");
13637
+ fd = import_node_fs22.default.openSync(filePath, "r");
13485
13638
  const buffer = Buffer.alloc(Math.min(BINARY_SNIFF_BYTES, size));
13486
- const read = import_node_fs21.default.readSync(fd, buffer, 0, buffer.length, 0);
13639
+ const read = import_node_fs22.default.readSync(fd, buffer, 0, buffer.length, 0);
13487
13640
  return buffer.subarray(0, read).includes(0);
13488
13641
  } catch {
13489
13642
  return false;
13490
13643
  } finally {
13491
- if (fd !== void 0) import_node_fs21.default.closeSync(fd);
13644
+ if (fd !== void 0) import_node_fs22.default.closeSync(fd);
13492
13645
  }
13493
13646
  }
13494
13647
  var CheckoutFilePlane = class {
@@ -13501,7 +13654,7 @@ var CheckoutFilePlane = class {
13501
13654
  listTimeoutMs;
13502
13655
  trackedOnly;
13503
13656
  constructor(root, options = {}) {
13504
- this.root = import_node_path22.default.resolve(root);
13657
+ this.root = import_node_path23.default.resolve(root);
13505
13658
  this.listTimeoutMs = options.listTimeoutMs ?? LIST_FILES_TIMEOUT_MS;
13506
13659
  this.trackedOnly = options.trackedOnly ?? false;
13507
13660
  }
@@ -13510,7 +13663,7 @@ var CheckoutFilePlane = class {
13510
13663
  }
13511
13664
  listFiles() {
13512
13665
  const args = this.trackedOnly ? ["ls-files", "-z"] : ["ls-files", "-co", "--exclude-standard", "-z"];
13513
- const stdout = (0, import_node_child_process9.execFileSync)("git", args, {
13666
+ const stdout = (0, import_node_child_process10.execFileSync)("git", args, {
13514
13667
  cwd: this.root,
13515
13668
  encoding: "utf8",
13516
13669
  maxBuffer: 64 * 1024 * 1024,
@@ -13563,13 +13716,13 @@ var CheckoutFilePlane = class {
13563
13716
  if (!relative2) continue;
13564
13717
  let stat2;
13565
13718
  try {
13566
- stat2 = import_node_fs21.default.statSync(import_node_path22.default.join(this.root, relative2));
13719
+ stat2 = import_node_fs22.default.statSync(import_node_path23.default.join(this.root, relative2));
13567
13720
  } catch {
13568
13721
  continue;
13569
13722
  }
13570
13723
  if (!stat2.isFile()) continue;
13571
13724
  const seen = this.sniffed.get(relative2);
13572
- const binary = seen && seen.size === stat2.size && seen.mtimeMs === stat2.mtimeMs ? seen.binary : looksBinary(import_node_path22.default.join(this.root, relative2), stat2.size);
13725
+ const binary = seen && seen.size === stat2.size && seen.mtimeMs === stat2.mtimeMs ? seen.binary : looksBinary(import_node_path23.default.join(this.root, relative2), stat2.size);
13573
13726
  nextSniffed.set(relative2, { size: stat2.size, mtimeMs: stat2.mtimeMs, binary });
13574
13727
  next.set(relative2, {
13575
13728
  size: stat2.size,
@@ -13583,22 +13736,22 @@ var CheckoutFilePlane = class {
13583
13736
  this.sniffed = nextSniffed;
13584
13737
  }
13585
13738
  absolute(planePath) {
13586
- const resolved = import_node_path22.default.resolve(this.root, planePath);
13587
- if (resolved !== this.root && !resolved.startsWith(`${this.root}${import_node_path22.default.sep}`)) {
13739
+ const resolved = import_node_path23.default.resolve(this.root, planePath);
13740
+ if (resolved !== this.root && !resolved.startsWith(`${this.root}${import_node_path23.default.sep}`)) {
13588
13741
  throw new Error(`path escapes the project: ${planePath}`);
13589
13742
  }
13590
13743
  return resolved;
13591
13744
  }
13592
13745
  async read(planePath) {
13593
- return import_node_fs21.default.promises.readFile(this.absolute(planePath), "utf8");
13746
+ return import_node_fs22.default.promises.readFile(this.absolute(planePath), "utf8");
13594
13747
  }
13595
13748
  async readBytes(planePath) {
13596
- return import_node_fs21.default.promises.readFile(this.absolute(planePath));
13749
+ return import_node_fs22.default.promises.readFile(this.absolute(planePath));
13597
13750
  }
13598
13751
  async write(planePath, content) {
13599
13752
  const absolute = this.absolute(planePath);
13600
- await import_node_fs21.default.promises.mkdir(import_node_path22.default.dirname(absolute), { recursive: true });
13601
- await import_node_fs21.default.promises.writeFile(absolute, content);
13753
+ await import_node_fs22.default.promises.mkdir(import_node_path23.default.dirname(absolute), { recursive: true });
13754
+ await import_node_fs22.default.promises.writeFile(absolute, content);
13602
13755
  this.entries.set(planePath, {
13603
13756
  size: content.byteLength,
13604
13757
  readOnly: false,
@@ -13607,7 +13760,7 @@ var CheckoutFilePlane = class {
13607
13760
  });
13608
13761
  }
13609
13762
  async delete(planePath) {
13610
- await import_node_fs21.default.promises.rm(this.absolute(planePath), { force: true });
13763
+ await import_node_fs22.default.promises.rm(this.absolute(planePath), { force: true });
13611
13764
  this.entries.delete(planePath);
13612
13765
  }
13613
13766
  };
@@ -13625,12 +13778,12 @@ var PlaneHost = class {
13625
13778
  /** handle a plane:* message. returns true iff it was one. */
13626
13779
  async handleMessage(ws, msg) {
13627
13780
  if (typeof msg !== "object" || msg === null) return false;
13628
- const record = { ...msg };
13629
- const type = record.type;
13781
+ const record2 = { ...msg };
13782
+ const type = record2.type;
13630
13783
  if (typeof type !== "string" || !type.startsWith("plane:")) return false;
13631
- const id = record.id;
13784
+ const id = record2.id;
13632
13785
  try {
13633
- this.respond(ws, id, await this.dispatch(ws, type, record));
13786
+ this.respond(ws, id, await this.dispatch(ws, type, record2));
13634
13787
  } catch (err) {
13635
13788
  const code = err instanceof PlaneNotRegisteredError ? "plane-not-registered" : void 0;
13636
13789
  this.respondError(ws, id, err instanceof Error ? err.message : String(err), code);
@@ -13733,14 +13886,14 @@ var PlaneHost = class {
13733
13886
  // root and an opened one cannot disagree about the same directory.
13734
13887
  realRoot(root) {
13735
13888
  if (!root) throw new Error("root is required");
13736
- const resolved = import_node_path23.default.resolve(root);
13889
+ const resolved = import_node_path24.default.resolve(root);
13737
13890
  let real;
13738
13891
  try {
13739
- real = import_node_fs22.default.realpathSync(resolved);
13892
+ real = import_node_fs23.default.realpathSync(resolved);
13740
13893
  } catch {
13741
13894
  throw new Error(`no such directory: ${resolved}`);
13742
13895
  }
13743
- if (!import_node_fs22.default.statSync(real).isDirectory()) throw new Error(`not a directory: ${real}`);
13896
+ if (!import_node_fs23.default.statSync(real).isDirectory()) throw new Error(`not a directory: ${real}`);
13744
13897
  return real;
13745
13898
  }
13746
13899
  respond(ws, id, result) {
@@ -13760,9 +13913,9 @@ var PlaneHost = class {
13760
13913
  };
13761
13914
 
13762
13915
  // src/host/replacement-module-handler.ts
13763
- var import_node_fs23 = require("node:fs");
13916
+ var import_node_fs24 = require("node:fs");
13764
13917
  var import_promises5 = __toESM(require("node:fs/promises"), 1);
13765
- var import_node_path24 = __toESM(require("node:path"), 1);
13918
+ var import_node_path25 = __toESM(require("node:path"), 1);
13766
13919
 
13767
13920
  // ../contrast-bundler/src/replacementModule.ts
13768
13921
  var import_dist = require("sucrase/dist/index.js");
@@ -14090,16 +14243,16 @@ function sendJavaScript(req, res, source) {
14090
14243
  res.end(req.method === "HEAD" ? void 0 : source);
14091
14244
  }
14092
14245
  function resolveReplacementModuleFile(fromFile, specifier) {
14093
- const base = import_node_path24.default.resolve(import_node_path24.default.dirname(fromFile), specifier);
14246
+ const base = import_node_path25.default.resolve(import_node_path25.default.dirname(fromFile), specifier);
14094
14247
  const candidates = [
14095
14248
  ...REPLACEMENT_MODULE_EXTENSIONS.some(
14096
- (ext) => ext === import_node_path24.default.extname(base).toLowerCase()
14249
+ (ext) => ext === import_node_path25.default.extname(base).toLowerCase()
14097
14250
  ) ? [base] : [],
14098
14251
  ...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => base + ext),
14099
- ...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => import_node_path24.default.join(base, `index${ext}`))
14252
+ ...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => import_node_path25.default.join(base, `index${ext}`))
14100
14253
  ];
14101
14254
  const found = candidates.find(
14102
- (candidate) => (0, import_node_fs23.statSync)(candidate, { throwIfNoEntry: false })?.isFile()
14255
+ (candidate) => (0, import_node_fs24.statSync)(candidate, { throwIfNoEntry: false })?.isFile()
14103
14256
  );
14104
14257
  if (!found) {
14105
14258
  throw new Error(
@@ -14154,13 +14307,13 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
14154
14307
  res.end("missing path param");
14155
14308
  return true;
14156
14309
  }
14157
- const extension = import_node_path24.default.extname(targetPath).toLowerCase();
14310
+ const extension = import_node_path25.default.extname(targetPath).toLowerCase();
14158
14311
  if (!REPLACEMENT_MODULE_EXTENSIONS.some((allowed) => allowed === extension)) {
14159
14312
  res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
14160
14313
  res.end(`replacement files must be ${REPLACEMENT_MODULE_EXTENSIONS.join(", ")}`);
14161
14314
  return true;
14162
14315
  }
14163
- if (!import_node_path24.default.isAbsolute(targetPath)) {
14316
+ if (!import_node_path25.default.isAbsolute(targetPath)) {
14164
14317
  res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
14165
14318
  res.end("replacement file path must be absolute");
14166
14319
  return true;
@@ -14168,10 +14321,10 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
14168
14321
  const runtimePackages = new Set(url.searchParams.getAll("runtimePackage"));
14169
14322
  let resolvedProjectRoot;
14170
14323
  if (options.projectRoot) {
14171
- const lexicalProjectRoot = import_node_path24.default.resolve(options.projectRoot);
14324
+ const lexicalProjectRoot = import_node_path25.default.resolve(options.projectRoot);
14172
14325
  resolvedProjectRoot = await import_promises5.default.realpath(options.projectRoot);
14173
- const lexicalTarget = import_node_path24.default.relative(lexicalProjectRoot, targetPath);
14174
- if (lexicalTarget.startsWith("..") || import_node_path24.default.isAbsolute(lexicalTarget)) {
14326
+ const lexicalTarget = import_node_path25.default.relative(lexicalProjectRoot, targetPath);
14327
+ if (lexicalTarget.startsWith("..") || import_node_path25.default.isAbsolute(lexicalTarget)) {
14175
14328
  res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
14176
14329
  res.end("replacement file must be inside the project root");
14177
14330
  return true;
@@ -14187,8 +14340,8 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
14187
14340
  return true;
14188
14341
  }
14189
14342
  if (resolvedProjectRoot) {
14190
- const relativeTarget = import_node_path24.default.relative(resolvedProjectRoot, resolvedTargetPath);
14191
- if (relativeTarget.startsWith("..") || import_node_path24.default.isAbsolute(relativeTarget)) {
14343
+ const relativeTarget = import_node_path25.default.relative(resolvedProjectRoot, resolvedTargetPath);
14344
+ if (relativeTarget.startsWith("..") || import_node_path25.default.isAbsolute(relativeTarget)) {
14192
14345
  res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
14193
14346
  res.end("replacement file must be inside the project root");
14194
14347
  return true;