peachsim 0.1.795 → 0.1.797

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 (87) hide show
  1. package/cli/cloud-test-tunnel.ts +1 -1
  2. package/cli/outbound-endpoints.ts +6 -1
  3. package/dist-lib/agent-daemon-client.cjs +1 -1
  4. package/dist-lib/agent-events.cjs +1 -1
  5. package/dist-lib/agent-identity.cjs +1 -1
  6. package/dist-lib/agent-sessions.cjs +1 -1
  7. package/dist-lib/attached-projects.cjs +1 -1
  8. package/dist-lib/auth/shared-session.cjs +1 -1
  9. package/dist-lib/backend-origin.cjs +1 -1
  10. package/dist-lib/beta.cjs +1 -1
  11. package/dist-lib/beta.mjs +1 -1
  12. package/dist-lib/bridge-constants.cjs +1 -1
  13. package/dist-lib/bridge-contract-input.cjs +1 -1
  14. package/dist-lib/bridge-contract-input.mjs +1 -1
  15. package/dist-lib/bridge-contract.cjs +1 -1
  16. package/dist-lib/bridge-contract.mjs +1 -1
  17. package/dist-lib/bundle-channel.cjs +383 -355
  18. package/dist-lib/capture-contract.cjs +1 -1
  19. package/dist-lib/capture-contract.mjs +1 -1
  20. package/dist-lib/cli-constants.cjs +1 -1
  21. package/dist-lib/cloud-contract.cjs +1 -1
  22. package/dist-lib/cloud-contract.mjs +1 -1
  23. package/dist-lib/cloud-test-args.cjs +1 -1
  24. package/dist-lib/cloud-test-args.mjs +1 -1
  25. package/dist-lib/cloud.cjs +1 -1
  26. package/dist-lib/cloud.mjs +1 -1
  27. package/dist-lib/config.cjs +1 -1
  28. package/dist-lib/detox/index.cjs +1 -1
  29. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  30. package/dist-lib/expo-swift-bundle.cjs +357 -336
  31. package/dist-lib/expo-swift-metadata.cjs +1 -1
  32. package/dist-lib/expo-swift-metadata.mjs +1 -1
  33. package/dist-lib/home-paths.cjs +1 -1
  34. package/dist-lib/host/bridge-host.cjs +680 -575
  35. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  36. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  37. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  38. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  39. package/dist-lib/host/websocket-proxy.cjs +1 -1
  40. package/dist-lib/index.cjs +401 -178
  41. package/dist-lib/jump-to-source-babel.cjs +1 -1
  42. package/dist-lib/jump-to-source-native.cjs +1 -1
  43. package/dist-lib/kotlin-host.cjs +1 -1
  44. package/dist-lib/menu.cjs +1 -1
  45. package/dist-lib/menu.mjs +1 -1
  46. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  47. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  48. package/dist-lib/metro-production-bundle.cjs +1 -1
  49. package/dist-lib/metro-production-bundle.mjs +1 -1
  50. package/dist-lib/metro.cjs +1 -1
  51. package/dist-lib/native-app-identity.cjs +1 -1
  52. package/dist-lib/native-app-identity.mjs +1 -1
  53. package/dist-lib/native-firebase-metadata.cjs +1 -1
  54. package/dist-lib/native-firebase-metadata.mjs +1 -1
  55. package/dist-lib/plist.cjs +1 -1
  56. package/dist-lib/plist.mjs +1 -1
  57. package/dist-lib/profiles.cjs +1 -1
  58. package/dist-lib/public-brand.cjs +1 -1
  59. package/dist-lib/react-native-host-modules.cjs +1 -1
  60. package/dist-lib/react-native-host-modules.mjs +1 -1
  61. package/dist-lib/render-mode.cjs +1 -1
  62. package/dist-lib/scripts/dev-server-scanner.cjs +85 -1
  63. package/dist-lib/sdk.cjs +1 -1
  64. package/dist-lib/sdk.mjs +1 -1
  65. package/dist-lib/skills.cjs +976 -851
  66. package/dist-lib/swift-compile.cjs +18 -4
  67. package/dist-lib/swift-compile.mjs +18 -4
  68. package/dist-lib/swift-package.cjs +1 -1
  69. package/dist-lib/swift-package.mjs +1 -1
  70. package/dist-lib/swift-submit.cjs +1 -1
  71. package/dist-lib/swift-submit.mjs +1 -1
  72. package/dist-lib/swift-toolchain.cjs +1 -1
  73. package/dist-lib/swift.cjs +1 -1
  74. package/dist-lib/vite-swift.cjs +416 -368
  75. package/dist-lib/vite.cjs +240 -15
  76. package/package.json +1 -1
  77. package/scripts/dev-server-scanner.ts +16 -5
  78. package/src/expo-swift-host.ts +8 -4
  79. package/src/one-widget-discovery.ts +17 -0
  80. package/src/one-widget-metadata.ts +208 -0
  81. package/src/one-widget-package.ts +11 -165
  82. package/src/oneWidgetContract.ts +122 -0
  83. package/src/swift-compile.ts +21 -3
  84. package/src/swift-distribution.lock.json +11 -11
  85. package/src/swift-host.ts +2 -48
  86. package/src/swift-source-file.ts +48 -0
  87. package/src/vite-plugin-one.ts +18 -1
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.795 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.797 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -3816,8 +3816,8 @@ function metroIosAssetDestRelatives(httpServerLocation, filename) {
3816
3816
  }
3817
3817
  const out = [];
3818
3818
  for (const dir of dirs) {
3819
- const path24 = `${dir}/${filename}`;
3820
- if (!out.includes(path24)) out.push(path24);
3819
+ const path25 = `${dir}/${filename}`;
3820
+ if (!out.includes(path25)) out.push(path25);
3821
3821
  }
3822
3822
  if (!out.includes(filename)) out.push(filename);
3823
3823
  return out;
@@ -4771,13 +4771,13 @@ function readFactoryStringLiterals(factory) {
4771
4771
  return literals;
4772
4772
  }
4773
4773
  function normalizeFingerprintLiteral(literal) {
4774
- const path24 = literal.replaceAll("\\\\", "/").replaceAll("\\/", "/");
4774
+ const path25 = literal.replaceAll("\\\\", "/").replaceAll("\\/", "/");
4775
4775
  const nodeModulesMarker = "/node_modules/";
4776
- const nodeModulesIndex = path24.lastIndexOf(nodeModulesMarker);
4776
+ const nodeModulesIndex = path25.lastIndexOf(nodeModulesMarker);
4777
4777
  if (nodeModulesIndex >= 0) {
4778
- return `node_modules/${path24.slice(nodeModulesIndex + nodeModulesMarker.length)}`;
4778
+ return `node_modules/${path25.slice(nodeModulesIndex + nodeModulesMarker.length)}`;
4779
4779
  }
4780
- if ((path24.startsWith("/") || /^[A-Za-z]:\//.test(path24) || path24.startsWith("file:/")) && /\.[cm]?[jt]sx?(?::\d+(?::\d+)?)?$/.test(path24)) {
4780
+ if ((path25.startsWith("/") || /^[A-Za-z]:\//.test(path25) || path25.startsWith("file:/")) && /\.[cm]?[jt]sx?(?::\d+(?::\d+)?)?$/.test(path25)) {
4781
4781
  return null;
4782
4782
  }
4783
4783
  return literal;
@@ -5015,10 +5015,10 @@ function templateAssignment(template, embeddings) {
5015
5015
  if (existingNode !== void 0 && existingNode !== nodeIndex) return null;
5016
5016
  nodesByModuleId.set(moduleId, nodeIndex);
5017
5017
  const node = template.nodes[nodeIndex];
5018
- const path24 = node.landmarkPath ?? `node_modules/${template.packageName}/__rnx_inferred__/${moduleId}.js`;
5018
+ const path25 = node.landmarkPath ?? `node_modules/${template.packageName}/__rnx_inferred__/${moduleId}.js`;
5019
5019
  const existingPath = pathsByModuleId.get(moduleId);
5020
- if (existingPath !== void 0 && existingPath !== path24) return null;
5021
- pathsByModuleId.set(moduleId, path24);
5020
+ if (existingPath !== void 0 && existingPath !== path25) return null;
5021
+ pathsByModuleId.set(moduleId, path25);
5022
5022
  }
5023
5023
  }
5024
5024
  return {
@@ -5180,14 +5180,14 @@ async function inferMetroModuleIdentity(args) {
5180
5180
  const packageClaims = claimsByPackage.values().next().value;
5181
5181
  if (!packageClaims) continue;
5182
5182
  const exactClaims = packageClaims.filter((assignment2) => {
5183
- const path24 = assignment2.pathsByModuleId.get(moduleId);
5184
- return path24 !== void 0 && !path24.includes("/__rnx_inferred__/");
5183
+ const path25 = assignment2.pathsByModuleId.get(moduleId);
5184
+ return path25 !== void 0 && !path25.includes("/__rnx_inferred__/");
5185
5185
  });
5186
5186
  const preferredClaims = exactClaims.length > 0 ? exactClaims : packageClaims;
5187
5187
  const routes = new Set(
5188
5188
  preferredClaims.flatMap((assignment2) => {
5189
- const path24 = assignment2.pathsByModuleId.get(moduleId);
5190
- return path24 ? [metroFingerprintModuleClaimRoute(assignment2.packageName, path24)] : [];
5189
+ const path25 = assignment2.pathsByModuleId.get(moduleId);
5190
+ return path25 ? [metroFingerprintModuleClaimRoute(assignment2.packageName, path25)] : [];
5191
5191
  })
5192
5192
  );
5193
5193
  if (routes.size !== 1) continue;
@@ -5430,17 +5430,17 @@ function visit(node, visitor) {
5430
5430
  } else
5431
5431
  visit_(null, node, visitor_, Object.freeze([]));
5432
5432
  }
5433
- function visit_(key2, node, visitor, path24) {
5434
- const ctrl = callVisitor(key2, node, visitor, path24);
5433
+ function visit_(key2, node, visitor, path25) {
5434
+ const ctrl = callVisitor(key2, node, visitor, path25);
5435
5435
  if (isNode(ctrl) || isPair(ctrl)) {
5436
- replaceNode(key2, path24, ctrl);
5437
- return visit_(key2, ctrl, visitor, path24);
5436
+ replaceNode(key2, path25, ctrl);
5437
+ return visit_(key2, ctrl, visitor, path25);
5438
5438
  }
5439
5439
  if (typeof ctrl !== "symbol") {
5440
5440
  if (isCollection(node)) {
5441
- path24 = Object.freeze(path24.concat(node));
5441
+ path25 = Object.freeze(path25.concat(node));
5442
5442
  for (let i = 0; i < node.items.length; ++i) {
5443
- const ci = visit_(i, node.items[i], visitor, path24);
5443
+ const ci = visit_(i, node.items[i], visitor, path25);
5444
5444
  if (typeof ci === "number")
5445
5445
  i = ci - 1;
5446
5446
  else if (ci === BREAK)
@@ -5451,13 +5451,13 @@ function visit_(key2, node, visitor, path24) {
5451
5451
  }
5452
5452
  }
5453
5453
  } else if (isPair(node)) {
5454
- path24 = Object.freeze(path24.concat(node));
5455
- const ck = visit_("key", node.key, visitor, path24);
5454
+ path25 = Object.freeze(path25.concat(node));
5455
+ const ck = visit_("key", node.key, visitor, path25);
5456
5456
  if (ck === BREAK)
5457
5457
  return BREAK;
5458
5458
  else if (ck === REMOVE)
5459
5459
  node.key = null;
5460
- const cv = visit_("value", node.value, visitor, path24);
5460
+ const cv = visit_("value", node.value, visitor, path25);
5461
5461
  if (cv === BREAK)
5462
5462
  return BREAK;
5463
5463
  else if (cv === REMOVE)
@@ -5475,17 +5475,17 @@ async function visitAsync(node, visitor) {
5475
5475
  } else
5476
5476
  await visitAsync_(null, node, visitor_, Object.freeze([]));
5477
5477
  }
5478
- async function visitAsync_(key2, node, visitor, path24) {
5479
- const ctrl = await callVisitor(key2, node, visitor, path24);
5478
+ async function visitAsync_(key2, node, visitor, path25) {
5479
+ const ctrl = await callVisitor(key2, node, visitor, path25);
5480
5480
  if (isNode(ctrl) || isPair(ctrl)) {
5481
- replaceNode(key2, path24, ctrl);
5482
- return visitAsync_(key2, ctrl, visitor, path24);
5481
+ replaceNode(key2, path25, ctrl);
5482
+ return visitAsync_(key2, ctrl, visitor, path25);
5483
5483
  }
5484
5484
  if (typeof ctrl !== "symbol") {
5485
5485
  if (isCollection(node)) {
5486
- path24 = Object.freeze(path24.concat(node));
5486
+ path25 = Object.freeze(path25.concat(node));
5487
5487
  for (let i = 0; i < node.items.length; ++i) {
5488
- const ci = await visitAsync_(i, node.items[i], visitor, path24);
5488
+ const ci = await visitAsync_(i, node.items[i], visitor, path25);
5489
5489
  if (typeof ci === "number")
5490
5490
  i = ci - 1;
5491
5491
  else if (ci === BREAK)
@@ -5496,13 +5496,13 @@ async function visitAsync_(key2, node, visitor, path24) {
5496
5496
  }
5497
5497
  }
5498
5498
  } else if (isPair(node)) {
5499
- path24 = Object.freeze(path24.concat(node));
5500
- const ck = await visitAsync_("key", node.key, visitor, path24);
5499
+ path25 = Object.freeze(path25.concat(node));
5500
+ const ck = await visitAsync_("key", node.key, visitor, path25);
5501
5501
  if (ck === BREAK)
5502
5502
  return BREAK;
5503
5503
  else if (ck === REMOVE)
5504
5504
  node.key = null;
5505
- const cv = await visitAsync_("value", node.value, visitor, path24);
5505
+ const cv = await visitAsync_("value", node.value, visitor, path25);
5506
5506
  if (cv === BREAK)
5507
5507
  return BREAK;
5508
5508
  else if (cv === REMOVE)
@@ -5529,23 +5529,23 @@ function initVisitor(visitor) {
5529
5529
  }
5530
5530
  return visitor;
5531
5531
  }
5532
- function callVisitor(key2, node, visitor, path24) {
5532
+ function callVisitor(key2, node, visitor, path25) {
5533
5533
  if (typeof visitor === "function")
5534
- return visitor(key2, node, path24);
5534
+ return visitor(key2, node, path25);
5535
5535
  if (isMap(node))
5536
- return visitor.Map?.(key2, node, path24);
5536
+ return visitor.Map?.(key2, node, path25);
5537
5537
  if (isSeq(node))
5538
- return visitor.Seq?.(key2, node, path24);
5538
+ return visitor.Seq?.(key2, node, path25);
5539
5539
  if (isPair(node))
5540
- return visitor.Pair?.(key2, node, path24);
5540
+ return visitor.Pair?.(key2, node, path25);
5541
5541
  if (isScalar(node))
5542
- return visitor.Scalar?.(key2, node, path24);
5542
+ return visitor.Scalar?.(key2, node, path25);
5543
5543
  if (isAlias(node))
5544
- return visitor.Alias?.(key2, node, path24);
5544
+ return visitor.Alias?.(key2, node, path25);
5545
5545
  return void 0;
5546
5546
  }
5547
- function replaceNode(key2, path24, node) {
5548
- const parent = path24[path24.length - 1];
5547
+ function replaceNode(key2, path25, node) {
5548
+ const parent = path25[path25.length - 1];
5549
5549
  if (isCollection(parent)) {
5550
5550
  parent.items[key2] = node;
5551
5551
  } else if (isPair(parent)) {
@@ -6096,10 +6096,10 @@ var init_createNode = __esm({
6096
6096
  });
6097
6097
 
6098
6098
  // ../../node_modules/yaml/browser/dist/nodes/Collection.js
6099
- function collectionFromPath(schema4, path24, value) {
6099
+ function collectionFromPath(schema4, path25, value) {
6100
6100
  let v = value;
6101
- for (let i = path24.length - 1; i >= 0; --i) {
6102
- const k = path24[i];
6101
+ for (let i = path25.length - 1; i >= 0; --i) {
6102
+ const k = path25[i];
6103
6103
  if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
6104
6104
  const a = [];
6105
6105
  a[k] = v;
@@ -6124,7 +6124,7 @@ var init_Collection = __esm({
6124
6124
  init_createNode();
6125
6125
  init_identity();
6126
6126
  init_Node();
6127
- isEmptyPath = (path24) => path24 == null || typeof path24 === "object" && !!path24[Symbol.iterator]().next().done;
6127
+ isEmptyPath = (path25) => path25 == null || typeof path25 === "object" && !!path25[Symbol.iterator]().next().done;
6128
6128
  Collection = class extends NodeBase {
6129
6129
  constructor(type, schema4) {
6130
6130
  super(type);
@@ -6154,11 +6154,11 @@ var init_Collection = __esm({
6154
6154
  * be a Pair instance or a `{ key, value }` object, which may not have a key
6155
6155
  * that already exists in the map.
6156
6156
  */
6157
- addIn(path24, value) {
6158
- if (isEmptyPath(path24))
6157
+ addIn(path25, value) {
6158
+ if (isEmptyPath(path25))
6159
6159
  this.add(value);
6160
6160
  else {
6161
- const [key2, ...rest] = path24;
6161
+ const [key2, ...rest] = path25;
6162
6162
  const node = this.get(key2, true);
6163
6163
  if (isCollection(node))
6164
6164
  node.addIn(rest, value);
@@ -6172,8 +6172,8 @@ var init_Collection = __esm({
6172
6172
  * Removes a value from the collection.
6173
6173
  * @returns `true` if the item was found and removed.
6174
6174
  */
6175
- deleteIn(path24) {
6176
- const [key2, ...rest] = path24;
6175
+ deleteIn(path25) {
6176
+ const [key2, ...rest] = path25;
6177
6177
  if (rest.length === 0)
6178
6178
  return this.delete(key2);
6179
6179
  const node = this.get(key2, true);
@@ -6187,8 +6187,8 @@ var init_Collection = __esm({
6187
6187
  * scalar values from their surrounding node; to disable set `keepScalar` to
6188
6188
  * `true` (collections are always returned intact).
6189
6189
  */
6190
- getIn(path24, keepScalar) {
6191
- const [key2, ...rest] = path24;
6190
+ getIn(path25, keepScalar) {
6191
+ const [key2, ...rest] = path25;
6192
6192
  const node = this.get(key2, true);
6193
6193
  if (rest.length === 0)
6194
6194
  return !keepScalar && isScalar(node) ? node.value : node;
@@ -6206,8 +6206,8 @@ var init_Collection = __esm({
6206
6206
  /**
6207
6207
  * Checks if the collection includes a value with the key `key`.
6208
6208
  */
6209
- hasIn(path24) {
6210
- const [key2, ...rest] = path24;
6209
+ hasIn(path25) {
6210
+ const [key2, ...rest] = path25;
6211
6211
  if (rest.length === 0)
6212
6212
  return this.has(key2);
6213
6213
  const node = this.get(key2, true);
@@ -6217,8 +6217,8 @@ var init_Collection = __esm({
6217
6217
  * Sets a value in this collection. For `!!set`, `value` needs to be a
6218
6218
  * boolean to add/remove the item from the set.
6219
6219
  */
6220
- setIn(path24, value) {
6221
- const [key2, ...rest] = path24;
6220
+ setIn(path25, value) {
6221
+ const [key2, ...rest] = path25;
6222
6222
  if (rest.length === 0) {
6223
6223
  this.set(key2, value);
6224
6224
  } else {
@@ -8137,15 +8137,15 @@ function visit2(cst, visitor) {
8137
8137
  cst = { start: cst.start, value: cst.value };
8138
8138
  _visit(Object.freeze([]), cst, visitor);
8139
8139
  }
8140
- function _visit(path24, item, visitor) {
8141
- let ctrl = visitor(item, path24);
8140
+ function _visit(path25, item, visitor) {
8141
+ let ctrl = visitor(item, path25);
8142
8142
  if (typeof ctrl === "symbol")
8143
8143
  return ctrl;
8144
8144
  for (const field of ["key", "value"]) {
8145
8145
  const token = item[field];
8146
8146
  if (token && "items" in token) {
8147
8147
  for (let i = 0; i < token.items.length; ++i) {
8148
- const ci = _visit(Object.freeze(path24.concat([[field, i]])), token.items[i], visitor);
8148
+ const ci = _visit(Object.freeze(path25.concat([[field, i]])), token.items[i], visitor);
8149
8149
  if (typeof ci === "number")
8150
8150
  i = ci - 1;
8151
8151
  else if (ci === BREAK2)
@@ -8156,10 +8156,10 @@ function _visit(path24, item, visitor) {
8156
8156
  }
8157
8157
  }
8158
8158
  if (typeof ctrl === "function" && field === "key")
8159
- ctrl = ctrl(item, path24);
8159
+ ctrl = ctrl(item, path25);
8160
8160
  }
8161
8161
  }
8162
- return typeof ctrl === "function" ? ctrl(item, path24) : ctrl;
8162
+ return typeof ctrl === "function" ? ctrl(item, path25) : ctrl;
8163
8163
  }
8164
8164
  var BREAK2, SKIP2, REMOVE2;
8165
8165
  var init_cst_visit = __esm({
@@ -8170,9 +8170,9 @@ var init_cst_visit = __esm({
8170
8170
  visit2.BREAK = BREAK2;
8171
8171
  visit2.SKIP = SKIP2;
8172
8172
  visit2.REMOVE = REMOVE2;
8173
- visit2.itemAtPath = (cst, path24) => {
8173
+ visit2.itemAtPath = (cst, path25) => {
8174
8174
  let item = cst;
8175
- for (const [field, index] of path24) {
8175
+ for (const [field, index] of path25) {
8176
8176
  const tok = item?.[field];
8177
8177
  if (tok && "items" in tok) {
8178
8178
  item = tok.items[index];
@@ -8181,9 +8181,9 @@ var init_cst_visit = __esm({
8181
8181
  }
8182
8182
  return item;
8183
8183
  };
8184
- visit2.parentCollection = (cst, path24) => {
8185
- const parent = visit2.itemAtPath(cst, path24.slice(0, -1));
8186
- const field = path24[path24.length - 1][0];
8184
+ visit2.parentCollection = (cst, path25) => {
8185
+ const parent = visit2.itemAtPath(cst, path25.slice(0, -1));
8186
+ const field = path25[path25.length - 1][0];
8187
8187
  const coll = parent?.[field];
8188
8188
  if (coll && "items" in coll)
8189
8189
  return coll;
@@ -8278,8 +8278,8 @@ function detectFramework(deps) {
8278
8278
  return "unknown";
8279
8279
  }
8280
8280
  function detectProject(dir) {
8281
- const pkgPath = (0, import_node_path28.join)(dir, "package.json");
8282
- if (!(0, import_node_fs27.existsSync)(pkgPath)) return null;
8281
+ const pkgPath = (0, import_node_path29.join)(dir, "package.json");
8282
+ if (!(0, import_node_fs28.existsSync)(pkgPath)) return null;
8283
8283
  const pkg = readProjectManifest(dir);
8284
8284
  if (!pkg) return null;
8285
8285
  const deps = { ...pkg.dependencies, ...pkg.devDependencies };
@@ -8291,25 +8291,25 @@ function detectProject(dir) {
8291
8291
  if (framework === "unknown") return null;
8292
8292
  return {
8293
8293
  dir,
8294
- name: pkg.name || (0, import_node_path28.basename)(dir),
8294
+ name: pkg.name || (0, import_node_path29.basename)(dir),
8295
8295
  framework,
8296
8296
  // a config file is a config file whatever module system it declares. real
8297
8297
  // apps write .cjs as often as .js, and missing one reads as "this project
8298
8298
  // has no bundler config" and sends the user to create a second one.
8299
8299
  hasViteConfig: CONFIG_EXTENSIONS.some(
8300
- (ext) => (0, import_node_fs27.existsSync)((0, import_node_path28.join)(dir, `vite.config.${ext}`))
8300
+ (ext) => (0, import_node_fs28.existsSync)((0, import_node_path29.join)(dir, `vite.config.${ext}`))
8301
8301
  ),
8302
8302
  hasMetroConfig: CONFIG_EXTENSIONS.some(
8303
- (ext) => (0, import_node_fs27.existsSync)((0, import_node_path28.join)(dir, `metro.config.${ext}`))
8303
+ (ext) => (0, import_node_fs28.existsSync)((0, import_node_path29.join)(dir, `metro.config.${ext}`))
8304
8304
  ),
8305
8305
  devCommand: typeof devCommand === "string" ? devCommand : null
8306
8306
  };
8307
8307
  }
8308
- function readProjectMetadata(path24) {
8308
+ function readProjectMetadata(path25) {
8309
8309
  try {
8310
- const info = (0, import_node_fs27.lstatSync)(path24);
8310
+ const info = (0, import_node_fs28.lstatSync)(path25);
8311
8311
  if (!info.isFile() || info.size > 4 * 1024 * 1024) return null;
8312
- return (0, import_node_fs27.readFileSync)(path24, "utf8");
8312
+ return (0, import_node_fs28.readFileSync)(path25, "utf8");
8313
8313
  } catch {
8314
8314
  return null;
8315
8315
  }
@@ -8318,8 +8318,8 @@ function metadataValue(value, key2) {
8318
8318
  if (!value || typeof value !== "object") return void 0;
8319
8319
  return Object.getOwnPropertyDescriptor(value, key2)?.value;
8320
8320
  }
8321
- function readProjectJson(path24) {
8322
- const text3 = readProjectMetadata(path24);
8321
+ function readProjectJson(path25) {
8322
+ const text3 = readProjectMetadata(path25);
8323
8323
  if (text3 === null) return null;
8324
8324
  try {
8325
8325
  const value = JSON.parse(text3);
@@ -8329,7 +8329,7 @@ function readProjectJson(path24) {
8329
8329
  }
8330
8330
  }
8331
8331
  function readProjectManifest(dir) {
8332
- const parsed = readProjectJson((0, import_node_path28.join)(dir, "package.json"));
8332
+ const parsed = readProjectJson((0, import_node_path29.join)(dir, "package.json"));
8333
8333
  if (!parsed || typeof parsed !== "object") return null;
8334
8334
  const record2 = (value) => {
8335
8335
  if (!value || typeof value !== "object") return {};
@@ -8346,12 +8346,12 @@ function readProjectManifest(dir) {
8346
8346
  devDependencies: record2(metadataValue(parsed, "devDependencies"))
8347
8347
  };
8348
8348
  }
8349
- var import_node_fs27, import_node_path28, import_json52, CONFIG_EXTENSIONS;
8349
+ var import_node_fs28, import_node_path29, import_json52, CONFIG_EXTENSIONS;
8350
8350
  var init_detect = __esm({
8351
8351
  "cli/commands/detect.ts"() {
8352
8352
  "use strict";
8353
- import_node_fs27 = require("node:fs");
8354
- import_node_path28 = require("node:path");
8353
+ import_node_fs28 = require("node:fs");
8354
+ import_node_path29 = require("node:path");
8355
8355
  import_json52 = __toESM(require_lib(), 1);
8356
8356
  init_browser();
8357
8357
  CONFIG_EXTENSIONS = ["ts", "js", "cjs", "mjs", "mts", "cts"];
@@ -8388,21 +8388,21 @@ function resolveCloudOrigin(value) {
8388
8388
  return normalizeCloudOrigin(source);
8389
8389
  }
8390
8390
  function readImmutableBundleSource(bundlePath) {
8391
- const filepath = (0, import_node_path29.resolve)(bundlePath);
8392
- if ((0, import_node_path29.extname)(filepath) !== ".js") {
8391
+ const filepath = (0, import_node_path30.resolve)(bundlePath);
8392
+ if ((0, import_node_path30.extname)(filepath) !== ".js") {
8393
8393
  throw new Error(`${REMOTE_COMMAND} requires one local Metro .js bundle`);
8394
8394
  }
8395
- const descriptor = (0, import_node_fs28.openSync)(filepath, "r");
8395
+ const descriptor = (0, import_node_fs29.openSync)(filepath, "r");
8396
8396
  try {
8397
- const before = (0, import_node_fs28.fstatSync)(descriptor, { bigint: true });
8397
+ const before = (0, import_node_fs29.fstatSync)(descriptor, { bigint: true });
8398
8398
  if (!before.isFile()) {
8399
8399
  throw new Error(`${REMOTE_COMMAND} bundle must be a regular local file`);
8400
8400
  }
8401
8401
  if (before.size <= 0n) {
8402
8402
  throw new Error(`${REMOTE_COMMAND} bundle is empty`);
8403
8403
  }
8404
- const bytes = (0, import_node_fs28.readFileSync)(descriptor);
8405
- const after = (0, import_node_fs28.fstatSync)(descriptor, { bigint: true });
8404
+ const bytes = (0, import_node_fs29.readFileSync)(descriptor);
8405
+ const after = (0, import_node_fs29.fstatSync)(descriptor, { bigint: true });
8406
8406
  if (before.dev !== after.dev || before.ino !== after.ino || before.size !== after.size || before.mtimeNs !== after.mtimeNs || bytes.length !== Number(before.size)) {
8407
8407
  throw new Error(`${REMOTE_COMMAND} bundle changed while it was being read`);
8408
8408
  }
@@ -8417,7 +8417,7 @@ function readImmutableBundleSource(bundlePath) {
8417
8417
  }
8418
8418
  return source;
8419
8419
  } finally {
8420
- (0, import_node_fs28.closeSync)(descriptor);
8420
+ (0, import_node_fs29.closeSync)(descriptor);
8421
8421
  }
8422
8422
  }
8423
8423
  async function fetchBundleSource(bundleUrl) {
@@ -8464,15 +8464,15 @@ async function loadBundleSource(bundleInput) {
8464
8464
  return readImmutableBundleSource(bundleInput);
8465
8465
  }
8466
8466
  function listMetroAssetDest(assetsPath) {
8467
- const directory = (0, import_node_path29.resolve)(assetsPath);
8468
- if (!(0, import_node_fs28.existsSync)(directory)) return { directory, files: [], truncated: false };
8469
- const skipNested = (0, import_node_fs28.existsSync)((0, import_node_path29.join)(directory, "package.json"));
8467
+ const directory = (0, import_node_path30.resolve)(assetsPath);
8468
+ if (!(0, import_node_fs29.existsSync)(directory)) return { directory, files: [], truncated: false };
8469
+ const skipNested = (0, import_node_fs29.existsSync)((0, import_node_path30.join)(directory, "package.json"));
8470
8470
  const files2 = [];
8471
8471
  let truncated = false;
8472
8472
  const walk2 = (dir, prefix) => {
8473
8473
  let entries;
8474
8474
  try {
8475
- entries = (0, import_node_fs28.readdirSync)(dir, { withFileTypes: true });
8475
+ entries = (0, import_node_fs29.readdirSync)(dir, { withFileTypes: true });
8476
8476
  } catch {
8477
8477
  return;
8478
8478
  }
@@ -8484,7 +8484,7 @@ function listMetroAssetDest(assetsPath) {
8484
8484
  if (entry.isDirectory()) {
8485
8485
  if (entry.name === ".git") continue;
8486
8486
  if (skipNested && PROJECT_ONLY_DIRECTORIES.has(entry.name)) continue;
8487
- walk2((0, import_node_path29.join)(dir, entry.name), prefix ? `${prefix}/${entry.name}` : entry.name);
8487
+ walk2((0, import_node_path30.join)(dir, entry.name), prefix ? `${prefix}/${entry.name}` : entry.name);
8488
8488
  } else if (entry.isFile()) {
8489
8489
  files2.push(prefix ? `${prefix}/${entry.name}` : entry.name);
8490
8490
  }
@@ -8519,7 +8519,7 @@ function distinctByContent(directory, options) {
8519
8519
  for (const relative2 of options) {
8520
8520
  let bytes;
8521
8521
  try {
8522
- bytes = (0, import_node_fs28.readFileSync)((0, import_node_path29.join)(directory, relative2));
8522
+ bytes = (0, import_node_fs29.readFileSync)((0, import_node_path30.join)(directory, relative2));
8523
8523
  } catch {
8524
8524
  continue;
8525
8525
  }
@@ -8551,7 +8551,7 @@ function placeMetroDescriptor(listing, descriptor) {
8551
8551
  let bytes;
8552
8552
  try {
8553
8553
  bytes = combination.map(
8554
- (relative2) => (0, import_node_fs28.readFileSync)((0, import_node_path29.join)(listing.directory, relative2))
8554
+ (relative2) => (0, import_node_fs29.readFileSync)((0, import_node_path30.join)(listing.directory, relative2))
8555
8555
  );
8556
8556
  } catch {
8557
8557
  continue;
@@ -8579,10 +8579,10 @@ function unverifiedContentKey(dest, fileDigests) {
8579
8579
  return JSON.stringify(
8580
8580
  dest.placements.map(
8581
8581
  (placement) => placement.verified ? null : [...placement.files].map(([scale, relative2]) => {
8582
- const file = (0, import_node_path29.join)(dest.directory, relative2);
8582
+ const file = (0, import_node_path30.join)(dest.directory, relative2);
8583
8583
  let digest = fileDigests.get(file);
8584
8584
  if (digest === void 0) {
8585
- digest = (0, import_node_crypto14.createHash)("sha256").update((0, import_node_fs28.readFileSync)(file)).digest("hex");
8585
+ digest = (0, import_node_crypto14.createHash)("sha256").update((0, import_node_fs29.readFileSync)(file)).digest("hex");
8586
8586
  fileDigests.set(file, digest);
8587
8587
  }
8588
8588
  return [scale, digest];
@@ -8591,22 +8591,22 @@ function unverifiedContentKey(dest, fileDigests) {
8591
8591
  );
8592
8592
  }
8593
8593
  function searchMetroAssetDest(bundlePath, descriptors) {
8594
- const bundleDirectory = (0, import_node_path29.dirname)((0, import_node_path29.resolve)(bundlePath));
8594
+ const bundleDirectory = (0, import_node_path30.dirname)((0, import_node_path30.resolve)(bundlePath));
8595
8595
  const candidates = [
8596
- (0, import_node_path29.join)(bundleDirectory, "assets"),
8596
+ (0, import_node_path30.join)(bundleDirectory, "assets"),
8597
8597
  bundleDirectory,
8598
- (0, import_node_path29.resolve)(bundleDirectory, "..", "assets")
8598
+ (0, import_node_path30.resolve)(bundleDirectory, "..", "assets")
8599
8599
  ];
8600
8600
  const cwd = process.cwd();
8601
8601
  let projectDirectory = null;
8602
8602
  for (const start of [bundleDirectory, cwd]) {
8603
- let directory = (0, import_node_path29.resolve)(start);
8603
+ let directory = (0, import_node_path30.resolve)(start);
8604
8604
  while (true) {
8605
8605
  if (detectProject(directory)?.hasMetroConfig) {
8606
8606
  projectDirectory = directory;
8607
8607
  break;
8608
8608
  }
8609
- const parent = (0, import_node_path29.dirname)(directory);
8609
+ const parent = (0, import_node_path30.dirname)(directory);
8610
8610
  if (parent === directory) break;
8611
8611
  directory = parent;
8612
8612
  }
@@ -8614,11 +8614,11 @@ function searchMetroAssetDest(bundlePath, descriptors) {
8614
8614
  }
8615
8615
  if (projectDirectory) {
8616
8616
  candidates.push(
8617
- (0, import_node_path29.join)(projectDirectory, "assets"),
8618
- (0, import_node_path29.join)(projectDirectory, "dist"),
8619
- (0, import_node_path29.join)(projectDirectory, "dist", "assets"),
8620
- (0, import_node_path29.join)(projectDirectory, "build"),
8621
- (0, import_node_path29.join)(projectDirectory, "build", "assets")
8617
+ (0, import_node_path30.join)(projectDirectory, "assets"),
8618
+ (0, import_node_path30.join)(projectDirectory, "dist"),
8619
+ (0, import_node_path30.join)(projectDirectory, "dist", "assets"),
8620
+ (0, import_node_path30.join)(projectDirectory, "build"),
8621
+ (0, import_node_path30.join)(projectDirectory, "build", "assets")
8622
8622
  );
8623
8623
  }
8624
8624
  const searched = [];
@@ -8626,7 +8626,7 @@ function searchMetroAssetDest(bundlePath, descriptors) {
8626
8626
  const stale = [];
8627
8627
  let truncated = false;
8628
8628
  for (const candidate of candidates) {
8629
- const directory = (0, import_node_path29.resolve)(candidate);
8629
+ const directory = (0, import_node_path30.resolve)(candidate);
8630
8630
  if (searched.includes(directory)) continue;
8631
8631
  searched.push(directory);
8632
8632
  const listing = listMetroAssetDest(directory);
@@ -8735,7 +8735,7 @@ async function embedBundleAssets(bundlePath, command, assetPolicy) {
8735
8735
  );
8736
8736
  }
8737
8737
  const relative2 = placement?.files.get(variant.scale);
8738
- if (relative2 && dest) return (0, import_node_fs28.readFileSync)((0, import_node_path29.join)(dest.directory, relative2));
8738
+ if (relative2 && dest) return (0, import_node_fs29.readFileSync)((0, import_node_path30.join)(dest.directory, relative2));
8739
8739
  if (placement && placement.files.size > 0) return null;
8740
8740
  if (placement && placement.ambiguous.length > 0 && dest) {
8741
8741
  throw new Error(
@@ -8764,7 +8764,7 @@ async function embedBundleAssets(bundlePath, command, assetPolicy) {
8764
8764
  );
8765
8765
  const classic = metroIosAssetDestRelatives(variant.descriptor.httpServerLocation, filename)[0] ?? filename;
8766
8766
  throw new Error(
8767
- `${command} could not read ${(0, import_node_path29.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\`.`
8767
+ `${command} could not read ${(0, import_node_path30.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\`.`
8768
8768
  );
8769
8769
  });
8770
8770
  return {
@@ -8910,13 +8910,13 @@ async function createCloudBox(options) {
8910
8910
  warnings: artifact.warnings
8911
8911
  };
8912
8912
  }
8913
- var import_node_crypto14, import_node_fs28, import_node_path29, DEFAULT_RNX_CLOUD_ORIGIN, MAX_RNX_CLOUD_BUNDLE_BYTES, REMOTE_COMMAND, MAX_ASSET_DEST_FILES, ACCOUNT_CHOICE_REFUSALS, PROJECT_ONLY_DIRECTORIES, MAX_PLACEMENT_COMBINATIONS;
8913
+ var import_node_crypto14, import_node_fs29, import_node_path30, DEFAULT_RNX_CLOUD_ORIGIN, MAX_RNX_CLOUD_BUNDLE_BYTES, REMOTE_COMMAND, MAX_ASSET_DEST_FILES, ACCOUNT_CHOICE_REFUSALS, PROJECT_ONLY_DIRECTORIES, MAX_PLACEMENT_COMBINATIONS;
8914
8914
  var init_cloud_client = __esm({
8915
8915
  "cli/cloud-client.ts"() {
8916
8916
  "use strict";
8917
8917
  import_node_crypto14 = require("node:crypto");
8918
- import_node_fs28 = require("node:fs");
8919
- import_node_path29 = require("node:path");
8918
+ import_node_fs29 = require("node:fs");
8919
+ import_node_path30 = require("node:path");
8920
8920
  init_metroAssetArtifact();
8921
8921
  init_metroCloudArtifact();
8922
8922
  init_metro_fingerprint_registry_client();
@@ -9262,6 +9262,83 @@ function normalizeNativeDevBundleUrl(bundleUrl) {
9262
9262
  }
9263
9263
  }
9264
9264
 
9265
+ // src/oneWidgetContract.ts
9266
+ function configuredWidgetFromScan(value, bundleUrl) {
9267
+ if (!Array.isArray(value)) return null;
9268
+ const requested = new URL(bundleUrl);
9269
+ for (const entry of value) {
9270
+ if (!entry || typeof entry !== "object") continue;
9271
+ const widget = Reflect.get(entry, "widget");
9272
+ if (!widget || typeof widget !== "object") continue;
9273
+ const metadata = Reflect.get(widget, "metadata");
9274
+ const advertisedUrl = Reflect.get(widget, "bundleUrl");
9275
+ const packageUrl = Reflect.get(widget, "packageUrl");
9276
+ const projectRoot = Reflect.get(widget, "projectRoot");
9277
+ const appIdentity = Reflect.get(widget, "appIdentity");
9278
+ const urlSchemes = Reflect.get(widget, "urlSchemes");
9279
+ if (typeof advertisedUrl !== "string" || typeof packageUrl !== "string" || typeof projectRoot !== "string" || !projectRoot || typeof appIdentity !== "string" || !/^[a-f0-9]{64}$/.test(appIdentity) || !Array.isArray(urlSchemes) || !urlSchemes.every(
9280
+ (scheme) => typeof scheme === "string" && /^[A-Za-z][A-Za-z0-9+.-]*$/.test(scheme)
9281
+ ) || !metadata || typeof metadata !== "object")
9282
+ continue;
9283
+ const advertised = new URL(alignLoopbackBundleUrlWithProbe(advertisedUrl, bundleUrl));
9284
+ if (advertised.protocol !== requested.protocol || advertised.port !== requested.port || advertised.hostname !== requested.hostname || advertised.pathname !== requested.pathname)
9285
+ continue;
9286
+ if (["rnxProjectId", "rnxReplacementToken"].some(
9287
+ (key2) => requested.searchParams.has(key2) && requested.searchParams.get(key2) !== advertised.searchParams.get(key2)
9288
+ ))
9289
+ continue;
9290
+ if (new URL(packageUrl).origin !== new URL(advertisedUrl).origin || new URL(packageUrl).pathname !== "/__peach/swift-package/OneWidgets")
9291
+ continue;
9292
+ const appName = Reflect.get(metadata, "appName");
9293
+ const bundleId = Reflect.get(metadata, "bundleId");
9294
+ const kind = Reflect.get(metadata, "kind");
9295
+ const suite = Reflect.get(metadata, "suite");
9296
+ const displayName = Reflect.get(metadata, "displayName");
9297
+ const description = Reflect.get(metadata, "description");
9298
+ const sources = Reflect.get(metadata, "sources");
9299
+ if (typeof appName !== "string" || !/^[A-Za-z][A-Za-z0-9_]*$/.test(appName) || typeof bundleId !== "string" || !bundleId || typeof kind !== "string" || !kind || typeof suite !== "string" || !suite || typeof displayName !== "string" || !displayName || typeof description !== "string" || !description || !sources || typeof sources !== "object" || Array.isArray(sources))
9300
+ continue;
9301
+ const sourceHashes = {};
9302
+ for (const [file, hash] of Object.entries(sources)) {
9303
+ if (typeof hash !== "string" || !/^[a-f0-9]{64}$/.test(hash)) return null;
9304
+ sourceHashes[file] = hash;
9305
+ }
9306
+ if (Object.keys(sourceHashes).length !== 2 || !sourceHashes["ios/OneWidgets/OneWidget.swift"] || !sourceHashes[`ios/${appName}/OneWidgetContract.swift`])
9307
+ continue;
9308
+ return {
9309
+ metadata: {
9310
+ appName,
9311
+ bundleId,
9312
+ kind,
9313
+ suite,
9314
+ displayName,
9315
+ description,
9316
+ sources: sourceHashes
9317
+ },
9318
+ bundleUrl,
9319
+ packageUrl: new URL("/__peach/swift-package/OneWidgets", requested).href,
9320
+ projectRoot,
9321
+ appIdentity,
9322
+ urlSchemes
9323
+ };
9324
+ }
9325
+ return null;
9326
+ }
9327
+
9328
+ // src/one-widget-discovery.ts
9329
+ async function readConfiguredOneWidget(bundleUrl) {
9330
+ try {
9331
+ const response = await fetch(new URL("/__server-scan", bundleUrl).href, {
9332
+ signal: AbortSignal.timeout(3e4)
9333
+ });
9334
+ if (!response.ok || !response.headers.get("content-type")?.includes("json"))
9335
+ return null;
9336
+ return configuredWidgetFromScan(await response.json(), bundleUrl);
9337
+ } catch {
9338
+ return null;
9339
+ }
9340
+ }
9341
+
9265
9342
  // src/settings-bundle.ts
9266
9343
  var import_promises = require("node:fs/promises");
9267
9344
  var import_node_path = require("node:path");
@@ -9354,9 +9431,9 @@ function safeChildPlistName(value) {
9354
9431
  name: file.toLowerCase().endsWith(".plist") ? file : `${file}.plist`
9355
9432
  };
9356
9433
  }
9357
- async function readableSettingsBundle(path24) {
9434
+ async function readableSettingsBundle(path25) {
9358
9435
  try {
9359
- const root = await (0, import_promises.stat)((0, import_node_path.join)(path24, "Root.plist"));
9436
+ const root = await (0, import_promises.stat)((0, import_node_path.join)(path25, "Root.plist"));
9360
9437
  return root.isFile() && root.size <= MAX_PLIST_BYTES;
9361
9438
  } catch {
9362
9439
  return false;
@@ -9401,11 +9478,11 @@ async function settingsBundleFingerprint(bundlePath) {
9401
9478
  return null;
9402
9479
  }
9403
9480
  }
9404
- async function parsePlistRecord(path24) {
9481
+ async function parsePlistRecord(path25) {
9405
9482
  try {
9406
- const metadata = await (0, import_promises.stat)(path24);
9483
+ const metadata = await (0, import_promises.stat)(path25);
9407
9484
  if (!metadata.isFile() || metadata.size > MAX_PLIST_BYTES) return null;
9408
- const source = await (0, import_promises.readFile)(path24, "utf8");
9485
+ const source = await (0, import_promises.readFile)(path25, "utf8");
9409
9486
  const parsed = parsePlistSource(source);
9410
9487
  return isRecord2(parsed) ? parsed : null;
9411
9488
  } catch {
@@ -9667,7 +9744,7 @@ async function tcpPing(port, timeout = TCP_GATE_MS) {
9667
9744
  return null;
9668
9745
  }
9669
9746
  }
9670
- function httpGet(hostname, port, path24, method = "GET", timeout = TIMEOUT_MS, headers = {}) {
9747
+ function httpGet(hostname, port, path25, method = "GET", timeout = TIMEOUT_MS, headers = {}) {
9671
9748
  return new Promise((resolve5) => {
9672
9749
  let settled = false;
9673
9750
  let killing = false;
@@ -9676,7 +9753,7 @@ function httpGet(hostname, port, path24, method = "GET", timeout = TIMEOUT_MS, h
9676
9753
  settled = true;
9677
9754
  resolve5(value);
9678
9755
  };
9679
- const req = import_http.default.request({ hostname, port, path: path24, method, headers }, (res) => {
9756
+ const req = import_http.default.request({ hostname, port, path: path25, method, headers }, (res) => {
9680
9757
  let body = "";
9681
9758
  res.on("data", (c) => body += c.toString());
9682
9759
  const contentType = (() => {
@@ -10281,6 +10358,13 @@ async function scanDevServers(opts = {}) {
10281
10358
  if (result) results.push(result);
10282
10359
  });
10283
10360
  }
10361
+ await Promise.all(
10362
+ results.map(async (result) => {
10363
+ result.widget = null;
10364
+ if (result.framework !== "one" && result.framework !== "vxrn") return;
10365
+ result.widget = await readConfiguredOneWidget(result.bundleUrl);
10366
+ })
10367
+ );
10284
10368
  const pidByPort = /* @__PURE__ */ new Map();
10285
10369
  for (const { port, pid } of processes) {
10286
10370
  if (pid > 0) pidByPort.set(port, pid);
@@ -10357,10 +10441,10 @@ function getCliVersion() {
10357
10441
  // src/expo-swift-host.ts
10358
10442
  var import_node_child_process9 = require("node:child_process");
10359
10443
  var import_node_crypto9 = require("node:crypto");
10360
- var import_node_fs19 = __toESM(require("node:fs"), 1);
10444
+ var import_node_fs20 = __toESM(require("node:fs"), 1);
10361
10445
  var import_node_module = require("node:module");
10362
10446
  var import_node_os9 = __toESM(require("node:os"), 1);
10363
- var import_node_path20 = __toESM(require("node:path"), 1);
10447
+ var import_node_path21 = __toESM(require("node:path"), 1);
10364
10448
  var import_node_util3 = require("node:util");
10365
10449
 
10366
10450
  // cli/internal-child.ts
@@ -10970,7 +11054,7 @@ var importsSpriteKit = (files2) => Object.entries(files2).some(
10970
11054
  );
10971
11055
  var FOUNDATION_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "PeachObjC", "-Xfrontend", "-import-module", "-Xfrontend", "Dispatch", "-Xfrontend", "-import-module", "-Xfrontend", "FoundationNetworking", "-Xfrontend", "-import-module", "-Xfrontend", "WASILibc", "-Xfrontend", "-import-module", "-Xfrontend", "wasi_pthread"';
10972
11056
  var ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One"';
10973
- var MULTI_MANIFEST_VERSION = 11;
11057
+ var MULTI_MANIFEST_VERSION = 12;
10974
11058
  function swiftArtifactHash(input, release, moduleRoot) {
10975
11059
  const hash = (0, import_node_crypto3.createHash)("sha256");
10976
11060
  hash.update(`swift-compile/v18
@@ -11021,8 +11105,12 @@ function emitSwiftPackageManifest(args) {
11021
11105
  (name2) => OPTIONAL_FRAMEWORKS.has(name2) && !targets.some((target) => target.name === name2)
11022
11106
  ).flatMap((name2) => [name2, ...OPTIONAL_FRAMEWORK_DEPENDENCIES[name2] ?? []])
11023
11107
  );
11108
+ if (spriteKit) {
11109
+ reachedFrameworks.add("SpriteKit");
11110
+ reachedFrameworks.add("PeachBox2D");
11111
+ }
11024
11112
  const distributionObjects = distribution?.objects.filter(
11025
- (object) => [...OPTIONAL_FRAMEWORKS].every(
11113
+ (object) => [...OPTIONAL_FRAMEWORKS, "SpriteKit", "PeachBox2D"].every(
11026
11114
  (name2) => !object.startsWith(`lib/${name2}-`) || reachedFrameworks.has(name2)
11027
11115
  )
11028
11116
  );
@@ -12179,7 +12267,17 @@ function compileSwiftProjectUnit(input, options) {
12179
12267
  ])
12180
12268
  ],
12181
12269
  {
12182
- env: BUILD_ENV,
12270
+ env: {
12271
+ ...BUILD_ENV,
12272
+ // shipped host plugins resolve against the selected compiler's runtime.
12273
+ ...process.platform === "linux" ? {
12274
+ LD_LIBRARY_PATH: [
12275
+ import_node_path7.default.resolve(options.toolchainBin, "../lib/swift/linux"),
12276
+ import_node_path7.default.resolve(options.toolchainBin, "../lib/swift/host"),
12277
+ process.env.LD_LIBRARY_PATH
12278
+ ].filter(Boolean).join(":")
12279
+ } : {}
12280
+ },
12183
12281
  maxBuffer: 64 * 1024 * 1024,
12184
12282
  timeout: options.timeoutMs
12185
12283
  }
@@ -12652,24 +12750,24 @@ init_home_paths();
12652
12750
 
12653
12751
  // src/swift-distribution.lock.json
12654
12752
  var swift_distribution_lock_default = {
12655
- id: "487239d0e061dfaa",
12753
+ id: "1a431e89764e8cfa",
12656
12754
  release: "swift-6.3-RELEASE",
12657
- wasmSdkId: "swift-6.3-RELEASE_wasm-peach-41921598-peach-209157d6",
12658
- wasmSdkUrl: "https://r2.sootsim.com/swift-wasm-sdk/swift-6.3-RELEASE_wasm-peach-41921598-peach-209157d6.artifactbundle.tar.gz",
12659
- wasmSdkChecksum: "2b291ff21683ba1063c7362fd5a244fe22af704315f20563abd68c8b4a19b089",
12660
- source: "a3d70fe1a5bcc462e1362c11285327d180e54e28",
12755
+ wasmSdkId: "swift-6.3-RELEASE_wasm-peach-41921598-peach-f2d7f5d4",
12756
+ wasmSdkUrl: "https://r2.sootsim.com/swift-wasm-sdk/swift-6.3-RELEASE_wasm-peach-41921598-peach-f2d7f5d4.artifactbundle.tar.gz",
12757
+ wasmSdkChecksum: "7471b1c145aba62bb9f696aa4d0cd1657cbd9bc7637811b2e6bda1f650553f8d",
12758
+ source: "90d77cf86a77ba84839e5885e1c354a4976f825f",
12661
12759
  hosts: {
12662
12760
  "darwin-arm64": {
12663
- sha256: "361390f1d2f9fee9577fc2253ce67ad40b09bb7946e8e6f3e034f3dc6670fd5b",
12664
- size: 31682452
12761
+ sha256: "ae344e0c60631747c512785d3232be4bc3066d3edbc2916616d43f2a8ee9d759",
12762
+ size: 36453618
12665
12763
  },
12666
12764
  "linux-x64": {
12667
- sha256: "d36ab74f444591458f72dc1d0c3c4032ee1620585a12ce3635fbd6adb8c9a0c8",
12668
- size: 31688001
12765
+ sha256: "16d8f064eaec39e35ee969719481d1f709e9dd08b7112dd83c7c0b8c0b447922",
12766
+ size: 36458677
12669
12767
  },
12670
12768
  "linux-arm64": {
12671
- sha256: "b3f167eb3cbfcf06f1ccf43e3b2cdd94c1a949a0d5ffea03a065a724d306caea",
12672
- size: 31686984
12769
+ sha256: "942892104d80b351b2dc9b414ba72695542ed3b066e0fe9e98d8e42ac760c8df",
12770
+ size: 36457909
12673
12771
  }
12674
12772
  }
12675
12773
  };
@@ -12814,9 +12912,9 @@ function swiftModuleToolchain(root) {
12814
12912
 
12815
12913
  // src/swift-host.ts
12816
12914
  var import_node_crypto8 = require("node:crypto");
12817
- var import_node_fs18 = __toESM(require("node:fs"), 1);
12915
+ var import_node_fs19 = __toESM(require("node:fs"), 1);
12818
12916
  var import_node_os8 = __toESM(require("node:os"), 1);
12819
- var import_node_path19 = __toESM(require("node:path"), 1);
12917
+ var import_node_path20 = __toESM(require("node:path"), 1);
12820
12918
 
12821
12919
  // ../sootsim-swift/src/bundleAssets.ts
12822
12920
  var import_svgpath = __toESM(require("svgpath"), 1);
@@ -12850,8 +12948,8 @@ function pickImagesetFile(images) {
12850
12948
  scale: pick.scale === "2x" ? 2 : pick.scale === "3x" ? 3 : 1
12851
12949
  };
12852
12950
  }
12853
- function flatScale(path24) {
12854
- const match = /@([23])x\.[^./]+$/.exec(path24);
12951
+ function flatScale(path25) {
12952
+ const match = /@([23])x\.[^./]+$/.exec(path25);
12855
12953
  return match ? Number(match[1]) : 1;
12856
12954
  }
12857
12955
  function providesNamespace(text3) {
@@ -12878,13 +12976,13 @@ function catalogEntryName(contentsPath, kind, readText) {
12878
12976
  }
12879
12977
  return segments.join("/");
12880
12978
  }
12881
- function isFlatResourceImage(path24) {
12882
- return path24.split("/").includes("Resources") && RASTER_EXTENSIONS.has(extOf(path24));
12979
+ function isFlatResourceImage(path25) {
12980
+ return path25.split("/").includes("Resources") && RASTER_EXTENSIONS.has(extOf(path25));
12883
12981
  }
12884
12982
  function enumerateBundleImages(paths, readText) {
12885
12983
  const table = [];
12886
12984
  const seen = /* @__PURE__ */ new Set();
12887
- const catalogs = paths.filter((path24) => baseOf(path24) === "Contents.json");
12985
+ const catalogs = paths.filter((path25) => baseOf(path25) === "Contents.json");
12888
12986
  for (const contentsPath of catalogs) {
12889
12987
  const name2 = catalogEntryName(contentsPath, ".imageset", readText);
12890
12988
  if (name2 === null || seen.has(name2)) continue;
@@ -12905,12 +13003,12 @@ function enumerateBundleImages(paths, readText) {
12905
13003
  seen.add(name2);
12906
13004
  table.push({ name: name2, file: `${dir}/${pick.filename}`, scale: pick.scale });
12907
13005
  }
12908
- for (const path24 of paths) {
12909
- if (!isFlatResourceImage(path24)) continue;
12910
- const name2 = baseOf(path24).slice(0, -extOf(path24).length);
13006
+ for (const path25 of paths) {
13007
+ if (!isFlatResourceImage(path25)) continue;
13008
+ const name2 = baseOf(path25).slice(0, -extOf(path25).length);
12911
13009
  if (name2 === "" || seen.has(name2)) continue;
12912
13010
  seen.add(name2);
12913
- table.push({ name: name2, file: path24, scale: flatScale(path24) });
13011
+ table.push({ name: name2, file: path25, scale: flatScale(path25) });
12914
13012
  }
12915
13013
  return table;
12916
13014
  }
@@ -12939,7 +13037,7 @@ function colorsetValue(color) {
12939
13037
  }
12940
13038
  function enumerateBundleColors(paths, readText) {
12941
13039
  const table = {};
12942
- for (const contentsPath of paths.filter((path24) => baseOf(path24) === "Contents.json")) {
13040
+ for (const contentsPath of paths.filter((path25) => baseOf(path25) === "Contents.json")) {
12943
13041
  const name2 = catalogEntryName(contentsPath, ".colorset", readText);
12944
13042
  if (name2 === null || name2 in table) continue;
12945
13043
  let colors;
@@ -13004,8 +13102,8 @@ function axisExtremes(points) {
13004
13102
  function pathBounds(d) {
13005
13103
  const xs = [];
13006
13104
  const ys = [];
13007
- for (const path24 of d)
13008
- (0, import_svgpath.default)(path24).abs().unshort().unarc().iterate((segment, _index, x, y) => {
13105
+ for (const path25 of d)
13106
+ (0, import_svgpath.default)(path25).abs().unshort().unarc().iterate((segment, _index, x, y) => {
13009
13107
  const [command, ...args] = segment;
13010
13108
  if (command === "M" || command === "L") {
13011
13109
  xs.push(Number(args[0]));
@@ -13032,7 +13130,7 @@ function guide(svg, id, axis) {
13032
13130
  }
13033
13131
  function enumerateBundleSymbols(paths, readText) {
13034
13132
  const table = {};
13035
- for (const contentsPath of paths.filter((path24) => baseOf(path24) === "Contents.json")) {
13133
+ for (const contentsPath of paths.filter((path25) => baseOf(path25) === "Contents.json")) {
13036
13134
  const name2 = catalogEntryName(contentsPath, ".symbolset", readText);
13037
13135
  if (name2 === null || name2 in table) continue;
13038
13136
  let symbols;
@@ -13065,8 +13163,8 @@ function enumerateBundleSymbols(paths, readText) {
13065
13163
  viewBox: "0 0 24 24",
13066
13164
  advance,
13067
13165
  box: [12 - advance / 2, 12 - tall / 2, advance, tall],
13068
- layers: d.map((path24) => ({
13069
- d: (0, import_svgpath.default)(path24).abs().scale(scale).translate(translateX, translateY).round(3).toString()
13166
+ layers: d.map((path25) => ({
13167
+ d: (0, import_svgpath.default)(path25).abs().scale(scale).translate(translateX, translateY).round(3).toString()
13070
13168
  }))
13071
13169
  };
13072
13170
  }
@@ -13076,7 +13174,7 @@ function enumerateBundleJson(paths) {
13076
13174
  const found = [];
13077
13175
  const seen = /* @__PURE__ */ new Set();
13078
13176
  const ordered = [...paths].filter(
13079
- (path24) => path24.split("/").includes("Resources") && path24.split("/").every((segment) => segment !== "" && segment !== "..") && (extOf(path24) === ".json" || extOf(path24) === ".xcstrings")
13177
+ (path25) => path25.split("/").includes("Resources") && path25.split("/").every((segment) => segment !== "" && segment !== "..") && (extOf(path25) === ".json" || extOf(path25) === ".xcstrings")
13080
13178
  ).sort((a, b) => {
13081
13179
  const aDepth = a.split("/").length;
13082
13180
  const bDepth = b.split("/").length;
@@ -13903,12 +14001,57 @@ function resolveSwiftPackages(options) {
13903
14001
  return result;
13904
14002
  }
13905
14003
 
14004
+ // src/swift-source-file.ts
14005
+ var import_node_fs16 = __toESM(require("node:fs"), 1);
14006
+ var import_node_path16 = __toESM(require("node:path"), 1);
14007
+ function readPackageFile(root, file, maxBytes) {
14008
+ const canonicalRoot = import_node_fs16.default.realpathSync(root);
14009
+ const relative2 = import_node_path16.default.relative(canonicalRoot, import_node_fs16.default.realpathSync(file));
14010
+ if (relative2 === ".." || relative2.startsWith(`..${import_node_path16.default.sep}`) || import_node_path16.default.isAbsolute(relative2)) {
14011
+ throw new Error(`swift input escapes the selected package: ${file}`);
14012
+ }
14013
+ let ancestor = import_node_path16.default.resolve(file);
14014
+ while (ancestor !== canonicalRoot) {
14015
+ if (import_node_fs16.default.lstatSync(ancestor).isSymbolicLink()) {
14016
+ throw new Error(`swift input is a symlink: ${ancestor}`);
14017
+ }
14018
+ const parent = import_node_path16.default.dirname(ancestor);
14019
+ if (parent === ancestor)
14020
+ throw new Error(`swift input escapes the selected package: ${file}`);
14021
+ ancestor = parent;
14022
+ }
14023
+ const expected = import_node_fs16.default.statSync(file);
14024
+ const fd = import_node_fs16.default.openSync(file, import_node_fs16.default.constants.O_RDONLY | import_node_fs16.default.constants.O_NOFOLLOW);
14025
+ try {
14026
+ const stat2 = import_node_fs16.default.fstatSync(fd);
14027
+ if (stat2.dev !== expected.dev || stat2.ino !== expected.ino) {
14028
+ throw new Error(`swift input changed while opening: ${file}`);
14029
+ }
14030
+ if (!stat2.isFile() || stat2.size > maxBytes) {
14031
+ throw new Error(`swift input exceeds ${maxBytes} bytes: ${file}`);
14032
+ }
14033
+ const bytes = Buffer.alloc(stat2.size + 1);
14034
+ let offset = 0;
14035
+ while (offset < bytes.length) {
14036
+ const count = import_node_fs16.default.readSync(fd, bytes, offset, bytes.length - offset, null);
14037
+ if (count === 0) break;
14038
+ offset += count;
14039
+ }
14040
+ if (offset !== stat2.size || import_node_fs16.default.fstatSync(fd).size !== stat2.size) {
14041
+ throw new Error(`swift input changed while reading: ${file}`);
14042
+ }
14043
+ return bytes.subarray(0, offset);
14044
+ } finally {
14045
+ import_node_fs16.default.closeSync(fd);
14046
+ }
14047
+ }
14048
+
13906
14049
  // src/swift-standins.ts
13907
14050
  var import_node_child_process8 = require("node:child_process");
13908
14051
  var import_node_crypto7 = require("node:crypto");
13909
- var import_node_fs16 = __toESM(require("node:fs"), 1);
14052
+ var import_node_fs17 = __toESM(require("node:fs"), 1);
13910
14053
  var import_node_os7 = __toESM(require("node:os"), 1);
13911
- var import_node_path16 = __toESM(require("node:path"), 1);
14054
+ var import_node_path17 = __toESM(require("node:path"), 1);
13912
14055
 
13913
14056
  // src/swift-standin-emit.ts
13914
14057
  var STANDIN_EMIT_VERSION = "4";
@@ -13968,7 +14111,7 @@ var witnessKey = (symbol) => `${symbol.kind.identifier.startsWith("swift.type.")
13968
14111
  var sideLeaf = (symbol) => `${symbol.kind.identifier.startsWith("swift.type.") ? "type" : "instance"}|leaf|${leaf(symbol)}`;
13969
14112
  var isObjC = (symbol) => symbol.identifier.precise.startsWith("c:");
13970
14113
  var synthesizedEquality = (symbol, conforms) => conforms.includes("Hashable") ? ["==(_:_:)", "hash(into:)", "hashValue"].includes(leaf(symbol)) : conforms.includes("Equatable") && leaf(symbol) === "==(_:_:)";
13971
- var trap = (path24) => `fatalError("${path24} is a binary framework peach cannot run")`;
14114
+ var trap = (path25) => `fatalError("${path25} is a binary framework peach cannot run")`;
13972
14115
  function emitSwiftStandin(graphs, options) {
13973
14116
  const skipped = [];
13974
14117
  const behavior = options.behavior ?? /* @__PURE__ */ new Map();
@@ -14105,10 +14248,10 @@ function emitSwiftStandin(graphs, options) {
14105
14248
  owners.push(...physical.map(() => current));
14106
14249
  };
14107
14250
  const scoped = (body) => (symbol, ...rest) => {
14108
- const path24 = pathOf(symbol);
14109
- if (omit.has(path24)) return void skipped.push({ path: path24, reason: omit.get(path24) });
14251
+ const path25 = pathOf(symbol);
14252
+ if (omit.has(path25)) return void skipped.push({ path: path25, reason: omit.get(path25) });
14110
14253
  const previous = current;
14111
- current = path24;
14254
+ current = path25;
14112
14255
  try {
14113
14256
  body(symbol, ...rest);
14114
14257
  } finally {
@@ -14128,14 +14271,14 @@ function emitSwiftStandin(graphs, options) {
14128
14271
  const access = (symbol, openOwner) => symbol.accessLevel === "open" && openOwner ? "open" : "public";
14129
14272
  const emitMember = scoped(
14130
14273
  (member, indent, context) => {
14131
- const path24 = pathOf(member);
14274
+ const path25 = pathOf(member);
14132
14275
  if (TYPE_KINDS.has(member.kind.identifier)) {
14133
14276
  emitType(member, indent);
14134
14277
  return;
14135
14278
  }
14136
14279
  if (member.kind.identifier === "swift.enum.case") return;
14137
14280
  if (!MEMBER_KINDS.has(member.kind.identifier)) {
14138
- skipped.push({ path: path24, reason: `unhandled ${member.kind.identifier}` });
14281
+ skipped.push({ path: path25, reason: `unhandled ${member.kind.identifier}` });
14139
14282
  return;
14140
14283
  }
14141
14284
  const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(member));
@@ -14149,12 +14292,12 @@ function emitSwiftStandin(graphs, options) {
14149
14292
  const final = context.inClass && flags.has("final") ? "final " : "";
14150
14293
  const mutating = flags.has("mutating") ? "mutating " : flags.has("nonmutating") ? "nonmutating " : "";
14151
14294
  let core = `${flags.has("convenience") ? "convenience " : ""}${modifiers[2]}`;
14152
- const override = context.inClass && !options.plain?.has(path24) && (flags.has("override") || overrides.has(member.identifier.precise) || options.forcedOverride?.has(path24) || isObjC(member) && path24.endsWith(".init()")) ? "override " : "";
14295
+ const override = context.inClass && !options.plain?.has(path25) && (flags.has("override") || overrides.has(member.identifier.precise) || options.forcedOverride?.has(path25) || isObjC(member) && path25.endsWith(".init()")) ? "override " : "";
14153
14296
  const head = `${indent}${attrs}${access(member, context.openOwner)} ${required ? "required " : ""}${final}${override}${mutating}`;
14154
- const measured = behavior.get(path24);
14155
- if (measured) used.add(path24);
14297
+ const measured = behavior.get(path25);
14298
+ if (measured) used.add(path25);
14156
14299
  const overloadBody = /\basync\b/.test(core) ? measured?.asyncBody : /\bResult</.test(core) ? measured?.resultBody : void 0;
14157
- const body = overloadBody ?? measured?.body ?? trap(path24);
14300
+ const body = overloadBody ?? measured?.body ?? trap(path25);
14158
14301
  switch (member.kind.identifier) {
14159
14302
  case "swift.property":
14160
14303
  case "swift.type.property":
@@ -14175,7 +14318,7 @@ function emitSwiftStandin(graphs, options) {
14175
14318
  return;
14176
14319
  }
14177
14320
  emit(
14178
- `${head}${computed} { get${effects} { ${body} }${settable && !effects ? ` ${parsed.nonmutating ? "nonmutating " : ""}set { ${measured?.set ?? trap(path24)} }` : ""} }`
14321
+ `${head}${computed} { get${effects} { ${body} }${settable && !effects ? ` ${parsed.nonmutating ? "nonmutating " : ""}set { ${measured?.set ?? trap(path25)} }` : ""} }`
14179
14322
  );
14180
14323
  return;
14181
14324
  }
@@ -14228,7 +14371,7 @@ function emitSwiftStandin(graphs, options) {
14228
14371
  };
14229
14372
  const emitType = scoped(
14230
14373
  (symbol, indent) => {
14231
- const path24 = pathOf(symbol);
14374
+ const path25 = pathOf(symbol);
14232
14375
  const id = symbol.identifier.precise;
14233
14376
  const inner = `${indent} `;
14234
14377
  switch (symbol.kind.identifier) {
@@ -14240,10 +14383,10 @@ function emitSwiftStandin(graphs, options) {
14240
14383
  case "swift.class": {
14241
14384
  const shape = header(symbol, "class", indent);
14242
14385
  if (!shape)
14243
- return void skipped.push({ path: path24, reason: `unparsed class ${text(symbol)}` });
14244
- const parent = options.superclasses?.get(path24) ?? superclass.get(id);
14386
+ return void skipped.push({ path: path25, reason: `unparsed class ${text(symbol)}` });
14387
+ const parent = options.superclasses?.get(path25) ?? superclass.get(id);
14245
14388
  const blocked = classBlocked(id);
14246
- if (blocked) return void skipped.push({ path: path24, reason: blocked });
14389
+ if (blocked) return void skipped.push({ path: path25, reason: blocked });
14247
14390
  const ancestors = /* @__PURE__ */ new Set();
14248
14391
  for (let at = superId.get(id); at; at = superId.get(at))
14249
14392
  for (const name2 of conforms.get(at) ?? []) ancestors.add(name2);
@@ -14259,9 +14402,9 @@ function emitSwiftStandin(graphs, options) {
14259
14402
  `${indent}${shape.attrs}${open ? "open" : "public"} class ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${selfConforming(shape.where)} {`
14260
14403
  );
14261
14404
  const members = membersOf(id);
14262
- const extra = options.behavior?.get(path24)?.members;
14405
+ const extra = options.behavior?.get(path25)?.members;
14263
14406
  if (extra) {
14264
- used.add(path24);
14407
+ used.add(path25);
14265
14408
  emit(`${inner}${extra}`);
14266
14409
  }
14267
14410
  for (const member of members)
@@ -14314,13 +14457,13 @@ function emitSwiftStandin(graphs, options) {
14314
14457
  continue;
14315
14458
  have.add(witnessKey(member));
14316
14459
  have.add(sideLeaf(member));
14317
- emitWitness(member, inner, path24);
14460
+ emitWitness(member, inner, path25);
14318
14461
  }
14319
14462
  }
14320
14463
  const coder = members.some((member) => leaf(member) === "init(coder:)");
14321
14464
  if (designated && !coder && externalRoot(id) !== "NSObject" && externalRoot(id) !== null)
14322
14465
  emit(
14323
- `${inner}public required init?(coder: NSCoder) { ${trap(`${path24}.init(coder:)`)} }`
14466
+ `${inner}public required init?(coder: NSCoder) { ${trap(`${path25}.init(coder:)`)} }`
14324
14467
  );
14325
14468
  emit(`${indent}}`);
14326
14469
  return;
@@ -14328,7 +14471,7 @@ function emitSwiftStandin(graphs, options) {
14328
14471
  case "swift.struct": {
14329
14472
  const shape = header(symbol, "struct", indent);
14330
14473
  if (!shape)
14331
- return void skipped.push({ path: path24, reason: `unparsed struct ${text(symbol)}` });
14474
+ return void skipped.push({ path: path25, reason: `unparsed struct ${text(symbol)}` });
14332
14475
  const members = membersOf(id);
14333
14476
  const raw2 = rawType(members);
14334
14477
  const list2 = inheritance(id);
@@ -14379,7 +14522,7 @@ function emitSwiftStandin(graphs, options) {
14379
14522
  case "swift.enum": {
14380
14523
  const shape = header(symbol, "enum", indent);
14381
14524
  if (!shape)
14382
- return void skipped.push({ path: path24, reason: `unparsed enum ${text(symbol)}` });
14525
+ return void skipped.push({ path: path25, reason: `unparsed enum ${text(symbol)}` });
14383
14526
  const members = membersOf(id);
14384
14527
  const raw2 = rawType(members);
14385
14528
  const cases = (children.get(id) ?? []).filter(
@@ -14388,7 +14531,7 @@ function emitSwiftStandin(graphs, options) {
14388
14531
  const missing = raw2 ? cases.filter((member) => !values.has(member.identifier.precise)) : [];
14389
14532
  if (raw2 && isObjC(symbol) && missing.length > 0)
14390
14533
  return void skipped.push({
14391
- path: path24,
14534
+ path: path25,
14392
14535
  reason: `no header value for ${missing.map(leaf).join(", ")}`
14393
14536
  });
14394
14537
  const list2 = inheritance(id, raw2 ?? void 0).filter(
@@ -14429,7 +14572,7 @@ function emitSwiftStandin(graphs, options) {
14429
14572
  const shape = header(symbol, "protocol", indent);
14430
14573
  if (!shape)
14431
14574
  return void skipped.push({
14432
- path: path24,
14575
+ path: path25,
14433
14576
  reason: `unparsed protocol ${text(symbol)}`
14434
14577
  });
14435
14578
  const list2 = [...isObjC(symbol) ? ["AnyObject"] : [], ...inheritance(id)];
@@ -14454,7 +14597,7 @@ function emitSwiftStandin(graphs, options) {
14454
14597
  }
14455
14598
  emit(`${indent}}`);
14456
14599
  if (defaults.length > 0) {
14457
- emit(`${indent}extension ${path24} {`);
14600
+ emit(`${indent}extension ${path25} {`);
14458
14601
  for (const member of defaults) {
14459
14602
  const decl = text(member);
14460
14603
  if (optional.has(member.identifier.precise) && member.kind.identifier === "swift.method" && !decl.replace(/\([^)]*\)/g, "").includes("->") && !/ async\b/.test(decl))
@@ -14501,7 +14644,7 @@ function emitSwiftStandin(graphs, options) {
14501
14644
  return init ? /rawValue:\s*([^)]+)\)/.exec(text(init))?.[1]?.trim() ?? null : null;
14502
14645
  };
14503
14646
  const emitGlobal = scoped((symbol) => {
14504
- const path24 = pathOf(symbol);
14647
+ const path25 = pathOf(symbol);
14505
14648
  const kind = symbol.kind.identifier;
14506
14649
  if (kind === "swift.func" || kind === "swift.func.op" || kind === "swift.method" || kind === "swift.type.method") {
14507
14650
  const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(symbol));
@@ -14512,17 +14655,17 @@ function emitSwiftStandin(graphs, options) {
14512
14655
  if (fix && !/^(?:prefix|infix|postfix)\b/.test(spelled))
14513
14656
  spelled = `${fix} ${spelled}`;
14514
14657
  }
14515
- emit(`${attrs}public ${spelled} { ${trap(path24)} }`);
14658
+ emit(`${attrs}public ${spelled} { ${trap(path25)} }`);
14516
14659
  } else if (kind === "swift.var") {
14517
14660
  const parsed = splitAccessors(text(symbol).replace(/^let /, "var "));
14518
- const measured = behavior.get(path24);
14519
- if (measured) used.add(path24);
14520
- emit(`public ${parsed.decl} { ${measured?.body ?? trap(path24)} }`);
14521
- } else skipped.push({ path: path24, reason: `unhandled top-level ${kind}` });
14661
+ const measured = behavior.get(path25);
14662
+ if (measured) used.add(path25);
14663
+ emit(`public ${parsed.decl} { ${measured?.body ?? trap(path25)} }`);
14664
+ } else skipped.push({ path: path25, reason: `unhandled top-level ${kind}` });
14522
14665
  });
14523
14666
  const roots = [...byId.values()].filter((symbol) => !owner.has(symbol.identifier.precise) && !unavailable(symbol)).sort((a, b) => pathOf(a).localeCompare(pathOf(b)));
14524
14667
  for (const symbol of roots) {
14525
- const path24 = pathOf(symbol);
14668
+ const path25 = pathOf(symbol);
14526
14669
  if (TYPE_KINDS.has(symbol.kind.identifier)) emitType(symbol, "");
14527
14670
  else emitGlobal(symbol);
14528
14671
  }
@@ -14564,9 +14707,9 @@ function emitSwiftStandin(graphs, options) {
14564
14707
  ...imports.map((name2) => `import ${name2}`),
14565
14708
  ""
14566
14709
  ];
14567
- for (const path24 of behavior.keys())
14568
- if (!used.has(path24))
14569
- skipped.push({ path: path24, reason: "behavior names no emitted declaration" });
14710
+ for (const path25 of behavior.keys())
14711
+ if (!used.has(path25))
14712
+ skipped.push({ path: path25, reason: "behavior names no emitted declaration" });
14570
14713
  return {
14571
14714
  source: `${[...banner, ...lines].join("\n")}
14572
14715
  `,
@@ -14641,7 +14784,7 @@ function stripDefaults(decl) {
14641
14784
 
14642
14785
  // src/swift-standins.ts
14643
14786
  var TRIPLE = "wasm32-unknown-wasip1";
14644
- var cacheDir4 = import_node_path16.default.join(import_node_os7.default.tmpdir(), "peach-swift-standins");
14787
+ var cacheDir4 = import_node_path17.default.join(import_node_os7.default.tmpdir(), "peach-swift-standins");
14645
14788
  function exec(file, args, cwd) {
14646
14789
  return (0, import_node_child_process8.execFileSync)(file, args, {
14647
14790
  cwd,
@@ -14661,15 +14804,15 @@ var digests = /* @__PURE__ */ new Map();
14661
14804
  function treeDigest(root) {
14662
14805
  const names = [];
14663
14806
  const walk2 = (dir) => {
14664
- for (const entry of import_node_fs16.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name < right.name ? -1 : 1)) {
14665
- const full = import_node_path16.default.join(dir, entry.name);
14807
+ for (const entry of import_node_fs17.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name < right.name ? -1 : 1)) {
14808
+ const full = import_node_path17.default.join(dir, entry.name);
14666
14809
  if (entry.isDirectory()) walk2(full);
14667
- else if (entry.isFile()) names.push(import_node_path16.default.relative(root, full));
14810
+ else if (entry.isFile()) names.push(import_node_path17.default.relative(root, full));
14668
14811
  }
14669
14812
  };
14670
14813
  walk2(root);
14671
14814
  const stamp = names.map((name2) => {
14672
- const stat2 = import_node_fs16.default.statSync(import_node_path16.default.join(root, name2));
14815
+ const stat2 = import_node_fs17.default.statSync(import_node_path17.default.join(root, name2));
14673
14816
  return `${name2}\0${stat2.size}:${stat2.mtimeMs}`;
14674
14817
  }).join("\n");
14675
14818
  const memo2 = digests.get(`tree\0${root}`);
@@ -14677,7 +14820,7 @@ function treeDigest(root) {
14677
14820
  const hash = (0, import_node_crypto7.createHash)("sha256");
14678
14821
  for (const name2 of names) {
14679
14822
  hash.update(`${name2}\0`);
14680
- hash.update(import_node_fs16.default.readFileSync(import_node_path16.default.join(root, name2)));
14823
+ hash.update(import_node_fs17.default.readFileSync(import_node_path17.default.join(root, name2)));
14681
14824
  hash.update("\0");
14682
14825
  }
14683
14826
  const digest = hash.digest("hex");
@@ -14686,9 +14829,9 @@ function treeDigest(root) {
14686
14829
  }
14687
14830
  function locateXcframework(tree) {
14688
14831
  const find = (root, depth) => {
14689
- for (const entry of import_node_fs16.default.readdirSync(root, { withFileTypes: true })) {
14832
+ for (const entry of import_node_fs17.default.readdirSync(root, { withFileTypes: true })) {
14690
14833
  if (!entry.isDirectory() || entry.name === "__MACOSX") continue;
14691
- const full = import_node_path16.default.join(root, entry.name);
14834
+ const full = import_node_path17.default.join(root, entry.name);
14692
14835
  if (entry.name.endsWith(".xcframework")) return full;
14693
14836
  const nested = depth > 0 ? find(full, depth - 1) : null;
14694
14837
  if (nested) return nested;
@@ -14703,67 +14846,67 @@ function xcframework(binary2) {
14703
14846
  if (binary2.url && (!binary2.checksum || !/^[a-f0-9]{64}$/i.test(binary2.checksum)))
14704
14847
  throw new Error("remote binary archive requires its Package.swift SHA-256 checksum");
14705
14848
  const expected = binary2.checksum?.toLowerCase();
14706
- const dir = import_node_path16.default.join(cacheDir4, "archives", key(binary2.url ? expected : binary2.dir));
14707
- const archive = import_node_path16.default.join(dir, "archive.zip");
14708
- const fingerprint = import_node_path16.default.join(dir, ".fingerprint");
14849
+ const dir = import_node_path17.default.join(cacheDir4, "archives", key(binary2.url ? expected : binary2.dir));
14850
+ const archive = import_node_path17.default.join(dir, "archive.zip");
14851
+ const fingerprint = import_node_path17.default.join(dir, ".fingerprint");
14709
14852
  const stored = (() => {
14710
14853
  try {
14711
- const parsed = JSON.parse(import_node_fs16.default.readFileSync(fingerprint, "utf8"));
14854
+ const parsed = JSON.parse(import_node_fs17.default.readFileSync(fingerprint, "utf8"));
14712
14855
  return parsed && typeof parsed === "object" && "sha" in parsed ? parsed : null;
14713
14856
  } catch {
14714
14857
  return null;
14715
14858
  }
14716
14859
  })();
14717
14860
  if (!binary2.url) {
14718
- const stat2 = import_node_fs16.default.statSync(binary2.dir);
14861
+ const stat2 = import_node_fs17.default.statSync(binary2.dir);
14719
14862
  const stamp = `${stat2.size}:${stat2.mtimeMs}`;
14720
14863
  if (stored?.stamp === stamp) {
14721
- const found3 = locateXcframework(import_node_path16.default.join(dir, "tree"));
14864
+ const found3 = locateXcframework(import_node_path17.default.join(dir, "tree"));
14722
14865
  if (found3) return { dir: found3, digest: stored.sha };
14723
14866
  }
14724
- const sha2 = (0, import_node_crypto7.createHash)("sha256").update(import_node_fs16.default.readFileSync(binary2.dir)).digest("hex");
14725
- if (sha2 !== stored?.sha || !locateXcframework(import_node_path16.default.join(dir, "tree"))) {
14726
- import_node_fs16.default.rmSync(dir, { recursive: true, force: true });
14727
- import_node_fs16.default.mkdirSync(import_node_path16.default.join(dir, "tree"), { recursive: true });
14728
- exec("unzip", ["-q", binary2.dir, "-d", import_node_path16.default.join(dir, "tree")]);
14867
+ const sha2 = (0, import_node_crypto7.createHash)("sha256").update(import_node_fs17.default.readFileSync(binary2.dir)).digest("hex");
14868
+ if (sha2 !== stored?.sha || !locateXcframework(import_node_path17.default.join(dir, "tree"))) {
14869
+ import_node_fs17.default.rmSync(dir, { recursive: true, force: true });
14870
+ import_node_fs17.default.mkdirSync(import_node_path17.default.join(dir, "tree"), { recursive: true });
14871
+ exec("unzip", ["-q", binary2.dir, "-d", import_node_path17.default.join(dir, "tree")]);
14729
14872
  }
14730
- import_node_fs16.default.writeFileSync(fingerprint, JSON.stringify({ stamp, sha: sha2 }));
14731
- const found2 = locateXcframework(import_node_path16.default.join(dir, "tree"));
14873
+ import_node_fs17.default.writeFileSync(fingerprint, JSON.stringify({ stamp, sha: sha2 }));
14874
+ const found2 = locateXcframework(import_node_path17.default.join(dir, "tree"));
14732
14875
  if (!found2) throw new Error("its archive holds no .xcframework");
14733
14876
  return { dir: found2, digest: sha2 };
14734
14877
  }
14735
- if (stored && import_node_fs16.default.existsSync(archive)) {
14736
- const sha2 = (0, import_node_crypto7.createHash)("sha256").update(import_node_fs16.default.readFileSync(archive)).digest("hex");
14878
+ if (stored && import_node_fs17.default.existsSync(archive)) {
14879
+ const sha2 = (0, import_node_crypto7.createHash)("sha256").update(import_node_fs17.default.readFileSync(archive)).digest("hex");
14737
14880
  if (sha2 !== expected)
14738
14881
  throw new Error(`archive checksum ${sha2} is not the declared checksum ${expected}`);
14739
- const found2 = locateXcframework(import_node_path16.default.join(dir, "tree"));
14882
+ const found2 = locateXcframework(import_node_path17.default.join(dir, "tree"));
14740
14883
  if (found2) return { dir: found2, digest: sha2 };
14741
14884
  }
14742
- import_node_fs16.default.rmSync(dir, { recursive: true, force: true });
14743
- import_node_fs16.default.mkdirSync(import_node_path16.default.join(dir, "tree"), { recursive: true });
14885
+ import_node_fs17.default.rmSync(dir, { recursive: true, force: true });
14886
+ import_node_fs17.default.mkdirSync(import_node_path17.default.join(dir, "tree"), { recursive: true });
14744
14887
  exec("curl", ["-fsSL", "--retry", "2", "-o", archive, binary2.url]);
14745
- const sha = (0, import_node_crypto7.createHash)("sha256").update(import_node_fs16.default.readFileSync(archive)).digest("hex");
14888
+ const sha = (0, import_node_crypto7.createHash)("sha256").update(import_node_fs17.default.readFileSync(archive)).digest("hex");
14746
14889
  if (sha !== expected) {
14747
- import_node_fs16.default.rmSync(dir, { recursive: true, force: true });
14890
+ import_node_fs17.default.rmSync(dir, { recursive: true, force: true });
14748
14891
  throw new Error(`archive checksum ${sha} is not the declared checksum ${expected}`);
14749
14892
  }
14750
- exec("unzip", ["-q", archive, "-d", import_node_path16.default.join(dir, "tree")]);
14751
- import_node_fs16.default.writeFileSync(fingerprint, JSON.stringify({ sha }));
14752
- const found = locateXcframework(import_node_path16.default.join(dir, "tree"));
14893
+ exec("unzip", ["-q", archive, "-d", import_node_path17.default.join(dir, "tree")]);
14894
+ import_node_fs17.default.writeFileSync(fingerprint, JSON.stringify({ sha }));
14895
+ const found = locateXcframework(import_node_path17.default.join(dir, "tree"));
14753
14896
  if (!found) throw new Error("its archive holds no .xcframework");
14754
14897
  return { dir: found, digest: sha };
14755
14898
  }
14756
- var files = (dir, test) => import_node_fs16.default.existsSync(dir) ? import_node_fs16.default.readdirSync(dir, { recursive: true, encoding: "utf8" }).filter((file) => test(import_node_path16.default.basename(file))).sort() : [];
14899
+ var files = (dir, test) => import_node_fs17.default.existsSync(dir) ? import_node_fs17.default.readdirSync(dir, { recursive: true, encoding: "utf8" }).filter((file) => test(import_node_path17.default.basename(file))).sort() : [];
14757
14900
  function surfaces(xcframeworkDir) {
14758
- const slice = import_node_fs16.default.readdirSync(xcframeworkDir).filter((name2) => /^ios-.+-simulator$/.test(name2)).sort()[0];
14901
+ const slice = import_node_fs17.default.readdirSync(xcframeworkDir).filter((name2) => /^ios-.+-simulator$/.test(name2)).sort()[0];
14759
14902
  if (!slice) throw new Error("it has no iOS simulator slice");
14760
- const root = import_node_path16.default.join(xcframeworkDir, slice);
14903
+ const root = import_node_path17.default.join(xcframeworkDir, slice);
14761
14904
  const found = [];
14762
- for (const entry of import_node_fs16.default.readdirSync(root).sort()) {
14905
+ for (const entry of import_node_fs17.default.readdirSync(root).sort()) {
14763
14906
  if (!entry.endsWith(".framework")) continue;
14764
14907
  const module2 = entry.slice(0, -".framework".length);
14765
- const framework = import_node_path16.default.join(root, entry);
14766
- const swiftmodule = import_node_path16.default.join(framework, "Modules", `${module2}.swiftmodule`);
14908
+ const framework = import_node_path17.default.join(root, entry);
14909
+ const swiftmodule = import_node_path17.default.join(framework, "Modules", `${module2}.swiftmodule`);
14767
14910
  const interfaces = files(
14768
14911
  swiftmodule,
14769
14912
  (name2) => name2.endsWith(".swiftinterface") && !name2.endsWith(".private.swiftinterface") && !name2.endsWith(".package.swiftinterface")
@@ -14773,41 +14916,41 @@ function surfaces(xcframeworkDir) {
14773
14916
  found.push({
14774
14917
  kind: "swift",
14775
14918
  module: module2,
14776
- interface: import_node_path16.default.join(swiftmodule, chosen)
14919
+ interface: import_node_path17.default.join(swiftmodule, chosen)
14777
14920
  });
14778
14921
  continue;
14779
14922
  }
14780
- const modulemap = import_node_path16.default.join(framework, "Modules", "module.modulemap");
14781
- if (import_node_fs16.default.existsSync(modulemap))
14923
+ const modulemap = import_node_path17.default.join(framework, "Modules", "module.modulemap");
14924
+ if (import_node_fs17.default.existsSync(modulemap))
14782
14925
  found.push({
14783
14926
  kind: "c",
14784
14927
  module: module2,
14785
14928
  modulemap,
14786
- headers: import_node_path16.default.join(framework, "Headers")
14929
+ headers: import_node_path17.default.join(framework, "Headers")
14787
14930
  });
14788
14931
  }
14789
- const headers = import_node_path16.default.join(root, "Headers");
14932
+ const headers = import_node_path17.default.join(root, "Headers");
14790
14933
  for (const map2 of files(headers, (name2) => name2 === "module.modulemap")) {
14791
- const modulemap = import_node_path16.default.join(headers, map2);
14792
- const module2 = /(?:^|\s)module\s+(\w+)/.exec(import_node_fs16.default.readFileSync(modulemap, "utf8"))?.[1];
14934
+ const modulemap = import_node_path17.default.join(headers, map2);
14935
+ const module2 = /(?:^|\s)module\s+(\w+)/.exec(import_node_fs17.default.readFileSync(modulemap, "utf8"))?.[1];
14793
14936
  if (module2) found.push({ kind: "c", module: module2, modulemap, headers });
14794
14937
  }
14795
14938
  return found;
14796
14939
  }
14797
14940
  function peachModuleDirs(toolchain, imports) {
14798
14941
  const { moduleRoot, toolchainBin } = toolchain;
14799
- if (swiftDistributionAt(moduleRoot)) return [import_node_path16.default.join(moduleRoot, "modules")];
14942
+ if (swiftDistributionAt(moduleRoot)) return [import_node_path17.default.join(moduleRoot, "modules")];
14800
14943
  const peach = new Set(swiftPeachModules(moduleRoot));
14801
14944
  const plugins = swiftMacroPlugins(moduleRoot);
14802
14945
  if (plugins.stale)
14803
14946
  exec("sh", [
14804
- import_node_path16.default.join(moduleRoot, "scripts/build-preview-plugin.sh"),
14947
+ import_node_path17.default.join(moduleRoot, "scripts/build-preview-plugin.sh"),
14805
14948
  toolchainBin,
14806
14949
  plugins.libraries[0]
14807
14950
  ]);
14808
14951
  for (const target of imports.filter((name2) => peach.has(name2)))
14809
14952
  exec(
14810
- import_node_path16.default.join(toolchainBin, "swift"),
14953
+ import_node_path17.default.join(toolchainBin, "swift"),
14811
14954
  [
14812
14955
  "build",
14813
14956
  "--swift-sdk",
@@ -14827,7 +14970,7 @@ function peachModuleDirs(toolchain, imports) {
14827
14970
  ],
14828
14971
  moduleRoot
14829
14972
  );
14830
- return [import_node_path16.default.join(moduleRoot, ".build", TRIPLE, "release", "Modules")];
14973
+ return [import_node_path17.default.join(moduleRoot, ".build", TRIPLE, "release", "Modules")];
14831
14974
  }
14832
14975
  function swiftInterfaceForWasm(text3) {
14833
14976
  return text3.replace(
@@ -14839,11 +14982,11 @@ function swiftInterfaceForWasm(text3) {
14839
14982
  );
14840
14983
  }
14841
14984
  function swiftStandin(surface, binary2, toolchain, work) {
14842
- const text3 = swiftInterfaceForWasm(import_node_fs16.default.readFileSync(surface.interface, "utf8"));
14843
- const search = import_node_path16.default.join(work, "interfaces");
14844
- const moduleDir = import_node_path16.default.join(search, `${surface.module}.swiftmodule`);
14845
- import_node_fs16.default.mkdirSync(moduleDir, { recursive: true });
14846
- import_node_fs16.default.writeFileSync(import_node_path16.default.join(moduleDir, `${TRIPLE}.swiftinterface`), text3);
14985
+ const text3 = swiftInterfaceForWasm(import_node_fs17.default.readFileSync(surface.interface, "utf8"));
14986
+ const search = import_node_path17.default.join(work, "interfaces");
14987
+ const moduleDir = import_node_path17.default.join(search, `${surface.module}.swiftmodule`);
14988
+ import_node_fs17.default.mkdirSync(moduleDir, { recursive: true });
14989
+ import_node_fs17.default.writeFileSync(import_node_path17.default.join(moduleDir, `${TRIPLE}.swiftinterface`), text3);
14847
14990
  const imports = [
14848
14991
  ...text3.matchAll(
14849
14992
  /^(?:@_exported[ \t]+)?import[ \t]+(?:(?:struct|class|enum|protocol|typealias|func|var|let)[ \t]+)?(\w+)/gm
@@ -14855,9 +14998,9 @@ function swiftStandin(surface, binary2, toolchain, work) {
14855
14998
  );
14856
14999
  const target = ["-target", TRIPLE, "-sdk", sysroot, "-resource-dir", resources];
14857
15000
  const peach = peachModuleDirs(toolchain, imports).flatMap((dir) => ["-I", dir]);
14858
- const out = import_node_path16.default.join(work, "graphs");
14859
- import_node_fs16.default.mkdirSync(out, { recursive: true });
14860
- exec(import_node_path16.default.join(toolchain.toolchainBin, "swift-symbolgraph-extract"), [
15001
+ const out = import_node_path17.default.join(work, "graphs");
15002
+ import_node_fs17.default.mkdirSync(out, { recursive: true });
15003
+ exec(import_node_path17.default.join(toolchain.toolchainBin, "swift-symbolgraph-extract"), [
14861
15004
  "-module-name",
14862
15005
  surface.module,
14863
15006
  ...target,
@@ -14871,10 +15014,10 @@ function swiftStandin(surface, binary2, toolchain, work) {
14871
15014
  "-output-dir",
14872
15015
  out
14873
15016
  ]);
14874
- const graphs = import_node_fs16.default.readdirSync(out).filter((name2) => name2.endsWith(".symbols.json")).sort().map((name2) => JSON.parse(import_node_fs16.default.readFileSync(import_node_path16.default.join(out, name2), "utf8")));
15017
+ const graphs = import_node_fs17.default.readdirSync(out).filter((name2) => name2.endsWith(".symbols.json")).sort().map((name2) => JSON.parse(import_node_fs17.default.readFileSync(import_node_path17.default.join(out, name2), "utf8")));
14875
15018
  const omit = /* @__PURE__ */ new Map();
14876
15019
  const plain = /* @__PURE__ */ new Set();
14877
- const file = import_node_path16.default.join(work, `${surface.module}.swift`);
15020
+ const file = import_node_path17.default.join(work, `${surface.module}.swift`);
14878
15021
  for (; ; ) {
14879
15022
  const { source, owners } = emitSwiftStandin(graphs, {
14880
15023
  module: surface.module,
@@ -14882,9 +15025,9 @@ function swiftStandin(surface, binary2, toolchain, work) {
14882
15025
  omit,
14883
15026
  plain
14884
15027
  });
14885
- import_node_fs16.default.writeFileSync(file, source);
15028
+ import_node_fs17.default.writeFileSync(file, source);
14886
15029
  const check = (0, import_node_child_process8.spawnSync)(
14887
- import_node_path16.default.join(toolchain.toolchainBin, "swiftc"),
15030
+ import_node_path17.default.join(toolchain.toolchainBin, "swiftc"),
14888
15031
  [
14889
15032
  "-typecheck",
14890
15033
  "-parse-as-library",
@@ -15034,21 +15177,21 @@ function splitDeclarators(statement, names) {
15034
15177
  }
15035
15178
  function cStandin(surface, binary2, toolchain, work) {
15036
15179
  const named = [
15037
- ...import_node_fs16.default.readFileSync(surface.modulemap, "utf8").matchAll(/(?:umbrella\s+)?header\s+"([^"]+)"/g)
15180
+ ...import_node_fs17.default.readFileSync(surface.modulemap, "utf8").matchAll(/(?:umbrella\s+)?header\s+"([^"]+)"/g)
15038
15181
  ].map((match) => match[1]);
15039
15182
  const headers = files(surface.headers, (name2) => name2.endsWith(".h"));
15040
15183
  const texts = new Map(
15041
15184
  headers.map((file) => [
15042
15185
  file,
15043
- import_node_fs16.default.readFileSync(import_node_path16.default.join(surface.headers, file), "utf8")
15186
+ import_node_fs17.default.readFileSync(import_node_path17.default.join(surface.headers, file), "utf8")
15044
15187
  ])
15045
15188
  );
15046
15189
  const objc = headers.find((file) => OBJC.test(texts.get(file)));
15047
15190
  if (objc) throw new Error(`its header ${objc} is Objective-C`);
15048
- const include = import_node_path16.default.join(work, "include");
15191
+ const include = import_node_path17.default.join(work, "include");
15049
15192
  for (const [file, text3] of texts) {
15050
- import_node_fs16.default.mkdirSync(import_node_path16.default.dirname(import_node_path16.default.join(include, file)), { recursive: true });
15051
- import_node_fs16.default.writeFileSync(import_node_path16.default.join(include, file), text3);
15193
+ import_node_fs17.default.mkdirSync(import_node_path17.default.dirname(import_node_path17.default.join(include, file)), { recursive: true });
15194
+ import_node_fs17.default.writeFileSync(import_node_path17.default.join(include, file), text3);
15052
15195
  }
15053
15196
  const roots = named.length > 0 ? named : headers;
15054
15197
  const modulemap = `module ${surface.module} {
@@ -15056,12 +15199,12 @@ ${roots.map((file) => ` header "${file}"
15056
15199
  `).join("")} export *
15057
15200
  }
15058
15201
  `;
15059
- const probe = import_node_path16.default.join(work, "declarations.c");
15060
- import_node_fs16.default.writeFileSync(probe, roots.map((file) => `#include "${file}"
15202
+ const probe = import_node_path17.default.join(work, "declarations.c");
15203
+ import_node_fs17.default.writeFileSync(probe, roots.map((file) => `#include "${file}"
15061
15204
  `).join(""));
15062
15205
  const { sysroot } = swiftSdkPaths(toolchain.moduleRoot, toolchain.toolchainBin);
15063
15206
  const ast = JSON.parse(
15064
- exec(import_node_path16.default.join(toolchain.toolchainBin, "clang"), [
15207
+ exec(import_node_path17.default.join(toolchain.toolchainBin, "clang"), [
15065
15208
  "-target",
15066
15209
  TRIPLE,
15067
15210
  "--sysroot",
@@ -15074,7 +15217,7 @@ ${roots.map((file) => ` header "${file}"
15074
15217
  probe
15075
15218
  ])
15076
15219
  );
15077
- const byPath = new Map(headers.map((file) => [import_node_path16.default.join(include, file), file]));
15220
+ const byPath = new Map(headers.map((file) => [import_node_path17.default.join(include, file), file]));
15078
15221
  const declarations = functionDeclarations(ast, new Set(byPath.keys()));
15079
15222
  const groups = /* @__PURE__ */ new Map();
15080
15223
  for (const declaration of declarations) {
@@ -15121,10 +15264,10 @@ ${roots.map((file) => ` header "${file}"
15121
15264
  "",
15122
15265
  ...definitions
15123
15266
  ].join("\n");
15124
- const out = import_node_path16.default.join(work, `${surface.module}.c`);
15125
- import_node_fs16.default.writeFileSync(out, source);
15267
+ const out = import_node_path17.default.join(work, `${surface.module}.c`);
15268
+ import_node_fs17.default.writeFileSync(out, source);
15126
15269
  try {
15127
- exec(import_node_path16.default.join(toolchain.toolchainBin, "clang"), [
15270
+ exec(import_node_path17.default.join(toolchain.toolchainBin, "clang"), [
15128
15271
  "-target",
15129
15272
  TRIPLE,
15130
15273
  "--sysroot",
@@ -15206,25 +15349,25 @@ function binaryStandins(binary2, toolchain, provided) {
15206
15349
  for (const file of surface.kind === "swift" ? [surface.interface] : [
15207
15350
  surface.modulemap,
15208
15351
  ...files(surface.headers, (name2) => name2.endsWith(".h")).map(
15209
- (file2) => import_node_path16.default.join(surface.headers, file2)
15352
+ (file2) => import_node_path17.default.join(surface.headers, file2)
15210
15353
  )
15211
15354
  ])
15212
- hash.update(import_node_fs16.default.readFileSync(file));
15355
+ hash.update(import_node_fs17.default.readFileSync(file));
15213
15356
  }
15214
15357
  const id = hash.digest("hex").slice(0, 32);
15215
15358
  const memo2 = built.get(id);
15216
15359
  if (memo2) return memo2;
15217
- const cached3 = import_node_path16.default.join(cacheDir4, "standins", `${id}.json`);
15218
- if (import_node_fs16.default.existsSync(cached3)) {
15219
- const value = JSON.parse(import_node_fs16.default.readFileSync(cached3, "utf8"));
15360
+ const cached3 = import_node_path17.default.join(cacheDir4, "standins", `${id}.json`);
15361
+ if (import_node_fs17.default.existsSync(cached3)) {
15362
+ const value = JSON.parse(import_node_fs17.default.readFileSync(cached3, "utf8"));
15220
15363
  built.set(id, value);
15221
15364
  return value;
15222
15365
  }
15223
- const work = import_node_fs16.default.mkdtempSync(import_node_path16.default.join(import_node_os7.default.tmpdir(), "peach-standin-"));
15366
+ const work = import_node_fs17.default.mkdtempSync(import_node_path17.default.join(import_node_os7.default.tmpdir(), "peach-standin-"));
15224
15367
  let result;
15225
15368
  try {
15226
15369
  result = found.map((surface) => {
15227
- const dir = import_node_path16.default.join(work, surface.module);
15370
+ const dir = import_node_path17.default.join(work, surface.module);
15228
15371
  try {
15229
15372
  return surface.kind === "swift" ? swiftStandin(surface, binary2, toolchain, dir) : cStandin(surface, binary2, toolchain, dir);
15230
15373
  } catch (error) {
@@ -15233,13 +15376,13 @@ function binaryStandins(binary2, toolchain, provided) {
15233
15376
  );
15234
15377
  }
15235
15378
  });
15236
- import_node_fs16.default.mkdirSync(import_node_path16.default.dirname(cached3), { recursive: true });
15237
- import_node_fs16.default.writeFileSync(cached3, JSON.stringify(result));
15379
+ import_node_fs17.default.mkdirSync(import_node_path17.default.dirname(cached3), { recursive: true });
15380
+ import_node_fs17.default.writeFileSync(cached3, JSON.stringify(result));
15238
15381
  built.set(id, result);
15239
15382
  } catch (error) {
15240
15383
  result = error instanceof Error ? error.message : String(error);
15241
15384
  } finally {
15242
- import_node_fs16.default.rmSync(work, { recursive: true, force: true });
15385
+ import_node_fs17.default.rmSync(work, { recursive: true, force: true });
15243
15386
  }
15244
15387
  return result;
15245
15388
  }
@@ -15381,12 +15524,12 @@ async function compileSwiftProject(submit, work, origin, signal) {
15381
15524
  }
15382
15525
 
15383
15526
  // src/xcode-project.ts
15384
- var import_node_fs17 = __toESM(require("node:fs"), 1);
15385
- var import_node_path18 = __toESM(require("node:path"), 1);
15527
+ var import_node_fs18 = __toESM(require("node:fs"), 1);
15528
+ var import_node_path19 = __toESM(require("node:path"), 1);
15386
15529
  var import_plist3 = __toESM(require_plist(), 1);
15387
15530
 
15388
15531
  // src/xcode-json-project.ts
15389
- var import_node_path17 = __toESM(require("node:path"), 1);
15532
+ var import_node_path18 = __toESM(require("node:path"), 1);
15390
15533
  var import_json5 = __toESM(require_lib(), 1);
15391
15534
  var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
15392
15535
  var text2 = (value) => typeof value === "string" ? value : void 0;
@@ -15402,7 +15545,7 @@ var PHASE_ISA = {
15402
15545
  function readXcodeJsonProject(xcodeproj, source) {
15403
15546
  const json = import_json5.default.parse(source);
15404
15547
  if (!isJsonObject(json)) throw new Error(`${xcodeproj}/project.xcproj is not an object`);
15405
- const projectDir = import_node_path17.default.dirname(xcodeproj);
15548
+ const projectDir = import_node_path18.default.dirname(xcodeproj);
15406
15549
  const objects = {};
15407
15550
  let next = 0;
15408
15551
  const add = (entry, id) => {
@@ -15415,7 +15558,7 @@ function readXcodeJsonProject(xcodeproj, source) {
15415
15558
  const base = /^<([A-Z]+)>\/(.*)$/.exec(raw2);
15416
15559
  if (base) {
15417
15560
  if (base[1] === "PROJECT")
15418
- return { sourceTree: "<absolute>", path: import_node_path17.default.join(projectDir, base[2]) };
15561
+ return { sourceTree: "<absolute>", path: import_node_path18.default.join(projectDir, base[2]) };
15419
15562
  if (base[1] === "PRODUCTS")
15420
15563
  return { sourceTree: "BUILT_PRODUCTS_DIR", path: base[2] };
15421
15564
  return null;
@@ -15423,7 +15566,7 @@ function readXcodeJsonProject(xcodeproj, source) {
15423
15566
  const unescaped = raw2.replaceAll("\\<", "<");
15424
15567
  if (unescaped.startsWith("/")) return { sourceTree: "<absolute>", path: unescaped };
15425
15568
  if (unescaped.startsWith("~")) return null;
15426
- return groupDir === null ? null : { sourceTree: "<absolute>", path: import_node_path17.default.join(groupDir, unescaped) };
15569
+ return groupDir === null ? null : { sourceTree: "<absolute>", path: import_node_path18.default.join(groupDir, unescaped) };
15427
15570
  };
15428
15571
  const memberships = [];
15429
15572
  const folders = [];
@@ -15434,7 +15577,7 @@ function readXcodeJsonProject(xcodeproj, source) {
15434
15577
  const kind = text2(entry.kind) ?? "file-reference";
15435
15578
  const raw2 = text2(entry.path) ?? "";
15436
15579
  const located = raw2 === "" ? null : locate(raw2, parent.dir);
15437
- const name2 = text2(entry.name) ?? import_node_path17.default.basename(raw2);
15580
+ const name2 = text2(entry.name) ?? import_node_path18.default.basename(raw2);
15438
15581
  const node = { id: "", name: name2, dir: null, parent, children: [] };
15439
15582
  if (kind === "group" || kind === "variant-group" || kind === "version-group") {
15440
15583
  node.dir = raw2 === "" ? parent.dir : located?.sourceTree === "<absolute>" ? located.path : null;
@@ -15549,7 +15692,7 @@ function readXcodeJsonProject(xcodeproj, source) {
15549
15692
  if (!isObject(entry)) continue;
15550
15693
  const repository = text2(entry.repository);
15551
15694
  const local = text2(entry.path);
15552
- const name2 = local !== void 0 ? import_node_path17.default.basename(import_node_path17.default.resolve(import_node_path17.default.dirname(xcodeproj), local)) : import_node_path17.default.basename(repository ?? "").replace(/\.git$/, "");
15695
+ const name2 = local !== void 0 ? import_node_path18.default.basename(import_node_path18.default.resolve(import_node_path18.default.dirname(xcodeproj), local)) : import_node_path18.default.basename(repository ?? "").replace(/\.git$/, "");
15553
15696
  const id = text2(entry.kind) === "local" && local !== void 0 ? add({ isa: "XCLocalSwiftPackageReference", relativePath: local }) : add({ isa: "XCRemoteSwiftPackageReference", repositoryURL: repository ?? "" });
15554
15697
  packageIds.set(name2.toLowerCase(), id);
15555
15698
  }
@@ -15826,28 +15969,28 @@ var CONDITIONS = {
15826
15969
  variant: "normal"
15827
15970
  };
15828
15971
  function walkFiles(dir) {
15829
- if (!import_node_fs17.default.existsSync(dir)) return [];
15972
+ if (!import_node_fs18.default.existsSync(dir)) return [];
15830
15973
  const out = [];
15831
- for (const entry of import_node_fs17.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
15974
+ for (const entry of import_node_fs18.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
15832
15975
  if (entry.name.startsWith(".")) continue;
15833
- const full = import_node_path18.default.join(dir, entry.name);
15976
+ const full = import_node_path19.default.join(dir, entry.name);
15834
15977
  if (entry.isDirectory()) out.push(...walkFiles(full));
15835
15978
  else if (entry.isFile()) out.push(full);
15836
15979
  }
15837
15980
  return out;
15838
15981
  }
15839
- var isDirectory = (dir) => import_node_fs17.default.existsSync(dir) && import_node_fs17.default.statSync(dir).isDirectory();
15982
+ var isDirectory = (dir) => import_node_fs18.default.existsSync(dir) && import_node_fs18.default.statSync(dir).isDirectory();
15840
15983
  function readXcconfig(file, seen = /* @__PURE__ */ new Set()) {
15841
- if (seen.has(file) || !import_node_fs17.default.existsSync(file)) return {};
15984
+ if (seen.has(file) || !import_node_fs18.default.existsSync(file)) return {};
15842
15985
  seen.add(file);
15843
15986
  const settings = {};
15844
- for (const raw2 of import_node_fs17.default.readFileSync(file, "utf8").split("\n")) {
15987
+ for (const raw2 of import_node_fs18.default.readFileSync(file, "utf8").split("\n")) {
15845
15988
  const line = raw2.replace(/\/\/.*$/, "").trim();
15846
15989
  const include = /^#include\??\s+"([^"]+)"/.exec(line);
15847
15990
  if (include) {
15848
15991
  Object.assign(
15849
15992
  settings,
15850
- readXcconfig(import_node_path18.default.resolve(import_node_path18.default.dirname(file), include[1]), seen)
15993
+ readXcconfig(import_node_path19.default.resolve(import_node_path19.default.dirname(file), include[1]), seen)
15851
15994
  );
15852
15995
  continue;
15853
15996
  }
@@ -15897,22 +16040,22 @@ function decodeXml(text3) {
15897
16040
  return text3.replaceAll("&quot;", '"').replaceAll("&apos;", "'").replaceAll("&lt;", "<").replaceAll("&gt;", ">").replaceAll("&amp;", "&");
15898
16041
  }
15899
16042
  function workspaceReferences(workspace) {
15900
- const data = import_node_path18.default.join(workspace, "contents.xcworkspacedata");
15901
- if (!import_node_fs17.default.existsSync(data))
16043
+ const data = import_node_path19.default.join(workspace, "contents.xcworkspacedata");
16044
+ if (!import_node_fs18.default.existsSync(data))
15902
16045
  throw new Error(`${workspace} has no contents.xcworkspacedata`);
15903
- const container = import_node_path18.default.dirname(workspace);
16046
+ const container = import_node_path19.default.dirname(workspace);
15904
16047
  const locate = (location2, base) => {
15905
16048
  const colon = location2.indexOf(":");
15906
16049
  const kind = location2.slice(0, colon);
15907
16050
  const rest = location2.slice(colon + 1);
15908
- if (kind === "group") return import_node_path18.default.resolve(base, rest);
15909
- if (kind === "container" || kind === "self") return import_node_path18.default.resolve(container, rest);
15910
- if (kind === "absolute") return import_node_path18.default.resolve(rest);
15911
- throw new Error(`${import_node_path18.default.basename(workspace)} has an unsupported location ${location2}`);
16051
+ if (kind === "group") return import_node_path19.default.resolve(base, rest);
16052
+ if (kind === "container" || kind === "self") return import_node_path19.default.resolve(container, rest);
16053
+ if (kind === "absolute") return import_node_path19.default.resolve(rest);
16054
+ throw new Error(`${import_node_path19.default.basename(workspace)} has an unsupported location ${location2}`);
15912
16055
  };
15913
16056
  const groups = [container];
15914
16057
  const references = [];
15915
- for (const [, closing, tag, attributes, selfClosing] of import_node_fs17.default.readFileSync(data, "utf8").matchAll(/<(\/?)(Group|FileRef)\b([^>]*?)(\/?)>/g)) {
16058
+ for (const [, closing, tag, attributes, selfClosing] of import_node_fs18.default.readFileSync(data, "utf8").matchAll(/<(\/?)(Group|FileRef)\b([^>]*?)(\/?)>/g)) {
15916
16059
  if (closing) {
15917
16060
  if (tag === "Group") groups.pop();
15918
16061
  continue;
@@ -15928,8 +16071,8 @@ function workspaceReferences(workspace) {
15928
16071
  var loaded = /* @__PURE__ */ new Map();
15929
16072
  function xcodeProjectFile(xcodeproj) {
15930
16073
  for (const name2 of ["project.pbxproj", "project.xcproj"]) {
15931
- const file = import_node_path18.default.join(xcodeproj, name2);
15932
- if (import_node_fs17.default.existsSync(file)) return file;
16074
+ const file = import_node_path19.default.join(xcodeproj, name2);
16075
+ if (import_node_fs18.default.existsSync(file)) return file;
15933
16076
  }
15934
16077
  return null;
15935
16078
  }
@@ -15937,10 +16080,10 @@ function loadProject(xcodeproj) {
15937
16080
  const projectFile = xcodeProjectFile(xcodeproj);
15938
16081
  if (!projectFile)
15939
16082
  throw new Error(`${xcodeproj} has no project.pbxproj or project.xcproj`);
15940
- const mtimeMs = import_node_fs17.default.statSync(projectFile).mtimeMs;
16083
+ const mtimeMs = import_node_fs18.default.statSync(projectFile).mtimeMs;
15941
16084
  const cached3 = loaded.get(projectFile);
15942
16085
  if (cached3?.mtimeMs === mtimeMs) return cached3.project;
15943
- const source = import_node_fs17.default.readFileSync(projectFile, "utf8");
16086
+ const source = import_node_fs18.default.readFileSync(projectFile, "utf8");
15944
16087
  const root = projectFile.endsWith(".xcproj") ? readXcodeJsonProject(xcodeproj, source) : parseOpenStepPlist(source);
15945
16088
  if (!isDict(root) || !isDict(root.objects)) {
15946
16089
  throw new Error(`${projectFile} has no objects table`);
@@ -15954,8 +16097,8 @@ function loadProject(xcodeproj) {
15954
16097
  if (!project || project.isa !== "PBXProject") {
15955
16098
  throw new Error(`${projectFile} has no PBXProject root`);
15956
16099
  }
15957
- const projectDir = import_node_fs17.default.realpathSync(
15958
- import_node_path18.default.resolve(import_node_path18.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
16100
+ const projectDir = import_node_fs18.default.realpathSync(
16101
+ import_node_path19.default.resolve(import_node_path19.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
15959
16102
  );
15960
16103
  const parent = /* @__PURE__ */ new Map();
15961
16104
  for (const [id, entry] of Object.entries(objects)) {
@@ -15973,11 +16116,11 @@ function loadProject(xcodeproj) {
15973
16116
  const own = str(entry.path) ?? "";
15974
16117
  const tree = str(entry.sourceTree) ?? "<group>";
15975
16118
  if (tree === "<absolute>") result2 = own;
15976
- else if (tree === "SOURCE_ROOT") result2 = import_node_path18.default.join(projectDir, own);
16119
+ else if (tree === "SOURCE_ROOT") result2 = import_node_path19.default.join(projectDir, own);
15977
16120
  else if (tree === "<group>") {
15978
16121
  const up = parent.get(id);
15979
16122
  const base = up ? resolvePath(up) : projectDir;
15980
- result2 = base === null ? null : import_node_path18.default.join(base, own);
16123
+ result2 = base === null ? null : import_node_path19.default.join(base, own);
15981
16124
  }
15982
16125
  }
15983
16126
  resolvedPaths.set(id, result2);
@@ -16077,7 +16220,7 @@ function targetMembers(ref) {
16077
16220
  const addResource = (file) => {
16078
16221
  if (isDirectory(file)) {
16079
16222
  for (const inner of walkFiles(file)) resources.add(inner);
16080
- } else if (import_node_fs17.default.existsSync(file)) resources.add(file);
16223
+ } else if (import_node_fs18.default.existsSync(file)) resources.add(file);
16081
16224
  };
16082
16225
  const fileRefPaths = (refId) => {
16083
16226
  const entry = project.object(refId);
@@ -16098,7 +16241,7 @@ function targetMembers(ref) {
16098
16241
  for (const buildFileId of list(phase.files)) {
16099
16242
  for (const file of fileRefPaths(str(project.object(buildFileId)?.fileRef) ?? "")) {
16100
16243
  if (phase.isa === "PBXSourcesBuildPhase") {
16101
- if (!import_node_fs17.default.existsSync(file)) continue;
16244
+ if (!import_node_fs18.default.existsSync(file)) continue;
16102
16245
  allSources.add(file);
16103
16246
  if (file.endsWith(".swift")) sources.add(file);
16104
16247
  } else if (phase.isa === "PBXResourcesBuildPhase") addResource(file);
@@ -16106,7 +16249,7 @@ function targetMembers(ref) {
16106
16249
  }
16107
16250
  }
16108
16251
  const addSynchronized = (folder, relative2) => {
16109
- const file = import_node_path18.default.join(folder, relative2);
16252
+ const file = import_node_path19.default.join(folder, relative2);
16110
16253
  if (NEVER_MEMBER.test(relative2)) return;
16111
16254
  if (file.endsWith(".swift")) {
16112
16255
  if (!relative2.split("/").some((segment) => BUNDLE_DIR.test(segment))) {
@@ -16131,7 +16274,7 @@ function targetMembers(ref) {
16131
16274
  }
16132
16275
  if (owned.has(groupId)) {
16133
16276
  for (const file of walkFiles(folder)) {
16134
- const relative2 = import_node_path18.default.relative(folder, file).split(import_node_path18.default.sep).join("/");
16277
+ const relative2 = import_node_path19.default.relative(folder, file).split(import_node_path19.default.sep).join("/");
16135
16278
  if ([...exceptions].some(
16136
16279
  (exception) => relative2 === exception || relative2.startsWith(`${exception}/`)
16137
16280
  ))
@@ -16140,14 +16283,14 @@ function targetMembers(ref) {
16140
16283
  }
16141
16284
  } else {
16142
16285
  for (const relative2 of exceptions) {
16143
- const file = import_node_path18.default.join(folder, relative2);
16286
+ const file = import_node_path19.default.join(folder, relative2);
16144
16287
  if (isDirectory(file)) {
16145
16288
  for (const inner of walkFiles(file))
16146
16289
  addSynchronized(
16147
16290
  folder,
16148
- import_node_path18.default.relative(folder, inner).split(import_node_path18.default.sep).join("/")
16291
+ import_node_path19.default.relative(folder, inner).split(import_node_path19.default.sep).join("/")
16149
16292
  );
16150
- } else if (import_node_fs17.default.existsSync(file)) addSynchronized(folder, relative2);
16293
+ } else if (import_node_fs18.default.existsSync(file)) addSynchronized(folder, relative2);
16151
16294
  }
16152
16295
  }
16153
16296
  }
@@ -16160,8 +16303,8 @@ function targetMembers(ref) {
16160
16303
  function commonAncestor(dirs) {
16161
16304
  let common = dirs[0];
16162
16305
  for (const dir of dirs) {
16163
- while (common !== import_node_path18.default.dirname(common) && import_node_path18.default.relative(common, dir).startsWith(".."))
16164
- common = import_node_path18.default.dirname(common);
16306
+ while (common !== import_node_path19.default.dirname(common) && import_node_path19.default.relative(common, dir).startsWith(".."))
16307
+ common = import_node_path19.default.dirname(common);
16165
16308
  }
16166
16309
  return common;
16167
16310
  }
@@ -16170,8 +16313,8 @@ function workspaceProjects(xcodeprojOrWorkspace) {
16170
16313
  const projects2 = [];
16171
16314
  const projectAt = /* @__PURE__ */ new Map();
16172
16315
  const addProject = (xcodeproj) => {
16173
- const key2 = import_node_path18.default.resolve(xcodeproj);
16174
- if (projectAt.has(key2) || key2.split(import_node_path18.default.sep).includes("Pods")) return;
16316
+ const key2 = import_node_path19.default.resolve(xcodeproj);
16317
+ if (projectAt.has(key2) || key2.split(import_node_path19.default.sep).includes("Pods")) return;
16175
16318
  if (!xcodeProjectFile(key2)) return;
16176
16319
  const project = loadProject(key2);
16177
16320
  projectAt.set(key2, project);
@@ -16188,7 +16331,7 @@ function workspaceProjects(xcodeprojOrWorkspace) {
16188
16331
  for (const reference of listed)
16189
16332
  if (reference.endsWith(".xcodeproj")) addProject(reference);
16190
16333
  if (projects2.length === 0) {
16191
- throw new Error(`${import_node_path18.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
16334
+ throw new Error(`${import_node_path19.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
16192
16335
  }
16193
16336
  return { listed, projects: projects2, projectAt };
16194
16337
  }
@@ -16210,7 +16353,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
16210
16353
  const allTargets = projects2.flatMap(nativeTargets);
16211
16354
  const appTargets = allTargets.filter((ref) => ref.target.productType === APPLICATION);
16212
16355
  const appTargetNames = appTargets.map((ref) => str(ref.target.name) ?? ref.id);
16213
- const container = import_node_path18.default.basename(xcodeprojOrWorkspace);
16356
+ const container = import_node_path19.default.basename(xcodeprojOrWorkspace);
16214
16357
  const named = targetName ? appTargets.filter((ref) => ref.target.name === targetName) : appTargets;
16215
16358
  if (named.length !== 1) {
16216
16359
  throw new Error(
@@ -16222,14 +16365,14 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
16222
16365
  for (const ref of allTargets) {
16223
16366
  const product = ref.project.object(str(ref.target.productReference));
16224
16367
  const file = str(product?.path);
16225
- if (file && !byProduct.has(import_node_path18.default.basename(file)))
16226
- byProduct.set(import_node_path18.default.basename(file), ref);
16368
+ if (file && !byProduct.has(import_node_path19.default.basename(file)))
16369
+ byProduct.set(import_node_path19.default.basename(file), ref);
16227
16370
  }
16228
16371
  const proxied = (project, proxyId) => {
16229
16372
  const proxy = project.object(proxyId);
16230
16373
  if (proxy?.isa !== "PBXContainerItemProxy") return void 0;
16231
16374
  const portal = str(proxy.containerPortal);
16232
- const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(import_node_path18.default.resolve(project.resolvePath(portal ?? "") ?? ""));
16375
+ const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(import_node_path19.default.resolve(project.resolvePath(portal ?? "") ?? ""));
16233
16376
  const remote = str(proxy.remoteGlobalIDString);
16234
16377
  if (!owner || !remote) return void 0;
16235
16378
  return nativeTargets(owner).find(
@@ -16250,7 +16393,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
16250
16393
  if (phase?.isa !== "PBXFrameworksBuildPhase") continue;
16251
16394
  for (const buildFileId of list(phase.files)) {
16252
16395
  const file = project.object(str(project.object(buildFileId)?.fileRef));
16253
- const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(import_node_path18.default.basename(str(file.path) ?? "")) : void 0;
16396
+ const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(import_node_path19.default.basename(str(file.path) ?? "")) : void 0;
16254
16397
  if (resolved) found.push(resolved);
16255
16398
  }
16256
16399
  }
@@ -16271,7 +16414,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
16271
16414
  const name2 = str(ref.target.name) ?? ref.id;
16272
16415
  const { get: settings2, keys } = targetSettings(ref, {
16273
16416
  TARGET_NAME: name2,
16274
- PROJECT_NAME: import_node_path18.default.basename(ref.project.xcodeproj, ".xcodeproj"),
16417
+ PROJECT_NAME: import_node_path19.default.basename(ref.project.xcodeproj, ".xcodeproj"),
16275
16418
  SRCROOT: ref.project.projectDir,
16276
16419
  SOURCE_ROOT: ref.project.projectDir,
16277
16420
  PROJECT_DIR: ref.project.projectDir,
@@ -16302,8 +16445,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
16302
16445
  }
16303
16446
  return value;
16304
16447
  };
16305
- const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path18.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
16306
- const sourceInfo = infoPlistFile ? import_plist3.default.parse(import_node_fs17.default.readFileSync(infoPlistFile, "utf8")) : {};
16448
+ const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path19.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
16449
+ const sourceInfo = infoPlistFile ? import_plist3.default.parse(import_node_fs18.default.readFileSync(infoPlistFile, "utf8")) : {};
16307
16450
  if (!sourceInfo || typeof sourceInfo !== "object" || Array.isArray(sourceInfo) || sourceInfo instanceof Date || Buffer.isBuffer(sourceInfo)) {
16308
16451
  throw new Error(`${module2.name} Info.plist must contain a dictionary`);
16309
16452
  }
@@ -16321,12 +16464,12 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
16321
16464
  };
16322
16465
  }
16323
16466
  const localPackageDirs = [
16324
- ...listed.filter((reference) => import_node_fs17.default.existsSync(import_node_path18.default.join(reference, "Package.swift"))),
16467
+ ...listed.filter((reference) => import_node_fs18.default.existsSync(import_node_path19.default.join(reference, "Package.swift"))),
16325
16468
  ...projects2.flatMap(
16326
16469
  (project) => Object.entries(project.objects).flatMap(([id, entry]) => {
16327
16470
  if (!isDict(entry)) return [];
16328
- const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path18.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
16329
- return candidate && import_node_fs17.default.existsSync(import_node_path18.default.join(candidate, "Package.swift")) ? [candidate] : [];
16471
+ const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path19.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
16472
+ return candidate && import_node_fs18.default.existsSync(import_node_path19.default.join(candidate, "Package.swift")) ? [candidate] : [];
16330
16473
  })
16331
16474
  )
16332
16475
  ];
@@ -16350,7 +16493,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
16350
16493
  product,
16351
16494
  source: reference?.isa === "XCRemoteSwiftPackageReference" ? { kind: "remote", url: str(reference.repositoryURL) ?? "" } : reference?.isa === "XCLocalSwiftPackageReference" ? {
16352
16495
  kind: "local",
16353
- dir: import_node_path18.default.resolve(
16496
+ dir: import_node_path19.default.resolve(
16354
16497
  project.projectDir,
16355
16498
  str(reference.relativePath) ?? ""
16356
16499
  )
@@ -16372,8 +16515,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
16372
16515
  }
16373
16516
  }
16374
16517
  }
16375
- const resolvedFile = import_node_path18.default.join(
16376
- workspace ?? import_node_path18.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
16518
+ const resolvedFile = import_node_path19.default.join(
16519
+ workspace ?? import_node_path19.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
16377
16520
  "xcshareddata",
16378
16521
  "swiftpm",
16379
16522
  "Package.resolved"
@@ -16383,13 +16526,13 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
16383
16526
  ...module2,
16384
16527
  rootDir: commonAncestor(
16385
16528
  [
16386
- workspace ? import_node_path18.default.dirname(workspace) : app.project.projectDir,
16529
+ workspace ? import_node_path19.default.dirname(workspace) : app.project.projectDir,
16387
16530
  ...used.map((project) => project.projectDir),
16388
16531
  ...localPackageDirs,
16389
16532
  ...linkedProducts.flatMap(
16390
- ({ source }) => source.kind === "local" && import_node_fs17.default.existsSync(source.dir) ? [source.dir] : []
16533
+ ({ source }) => source.kind === "local" && import_node_fs18.default.existsSync(source.dir) ? [source.dir] : []
16391
16534
  )
16392
- ].map((dir) => import_node_fs17.default.realpathSync(dir))
16535
+ ].map((dir) => import_node_fs18.default.realpathSync(dir))
16393
16536
  ),
16394
16537
  projectFiles: [...new Set(used.map((project) => project.projectFile))].sort(),
16395
16538
  infoPlist: import_plist3.default.build(info),
@@ -16397,10 +16540,10 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
16397
16540
  frameworks,
16398
16541
  linkedProducts,
16399
16542
  localPackageDirs: [
16400
- ...new Set(localPackageDirs.map((dir) => import_node_fs17.default.realpathSync(dir)))
16543
+ ...new Set(localPackageDirs.map((dir) => import_node_fs18.default.realpathSync(dir)))
16401
16544
  ].sort(),
16402
16545
  binaryFrameworks: [...binaryFrameworks].sort(),
16403
- packageResolved: import_node_fs17.default.existsSync(resolvedFile) ? resolvedFile : null,
16546
+ packageResolved: import_node_fs18.default.existsSync(resolvedFile) ? resolvedFile : null,
16404
16547
  appTargets: appTargetNames
16405
16548
  };
16406
16549
  }
@@ -16420,17 +16563,17 @@ var SKIP_SOURCE_DIRS = /* @__PURE__ */ new Set([
16420
16563
  var NATIVE_DESCRIPTOR = ".one-native-source.json";
16421
16564
  var NATIVE_GLUE = ".one-native-source.swift.txt";
16422
16565
  function swiftPackageId(packagePath) {
16423
- return import_node_path19.default.basename(packagePath).replace(/[^A-Za-z0-9_]/g, "_").replace(/^(\d)/, "_$1");
16566
+ return import_node_path20.default.basename(packagePath).replace(/[^A-Za-z0-9_]/g, "_").replace(/^(\d)/, "_$1");
16424
16567
  }
16425
16568
  function nativeSourceDescriptor(packagePath) {
16426
- packagePath = import_node_fs18.default.realpathSync(packagePath);
16427
- const file = import_node_path19.default.join(packagePath, NATIVE_DESCRIPTOR);
16428
- if (!import_node_fs18.default.existsSync(file)) return null;
16569
+ packagePath = import_node_fs19.default.realpathSync(packagePath);
16570
+ const file = import_node_path20.default.join(packagePath, NATIVE_DESCRIPTOR);
16571
+ if (!import_node_fs19.default.existsSync(file)) return null;
16429
16572
  const value = JSON.parse(
16430
16573
  readPackageFile(packagePath, file, MAX_SWIFT_COMPILE_SOURCE_BYTES).toString("utf8")
16431
16574
  );
16432
16575
  const invalid = () => new Error(`${file}: invalid One native source descriptor; run one typegen`);
16433
- if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !import_node_fs18.default.existsSync(import_node_path19.default.join(packagePath, NATIVE_GLUE))) {
16576
+ if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !import_node_fs19.default.existsSync(import_node_path20.default.join(packagePath, NATIVE_GLUE))) {
16434
16577
  throw invalid();
16435
16578
  }
16436
16579
  if (!isSwiftNativeModules(value) || value.packageId !== swiftPackageId(packagePath)) {
@@ -16442,7 +16585,7 @@ var SwiftMissingModulesError = class extends Error {
16442
16585
  };
16443
16586
  var projects = /* @__PURE__ */ new Map();
16444
16587
  function projectFor(packagePath, hosted) {
16445
- packagePath = import_node_fs18.default.realpathSync(packagePath);
16588
+ packagePath = import_node_fs19.default.realpathSync(packagePath);
16446
16589
  const existing = projects.get(packagePath);
16447
16590
  if (existing) {
16448
16591
  if (hosted && !existing.hosted) {
@@ -16464,14 +16607,14 @@ function projectFor(packagePath, hosted) {
16464
16607
  }
16465
16608
  var xcodeProjects = /* @__PURE__ */ new Map();
16466
16609
  function swiftPackages(entry, app) {
16467
- const stamp = (file) => file && import_node_fs18.default.existsSync(file) ? import_node_fs18.default.statSync(file).mtimeMs : 0;
16610
+ const stamp = (file) => file && import_node_fs19.default.existsSync(file) ? import_node_fs19.default.statSync(file).mtimeMs : 0;
16468
16611
  const key2 = JSON.stringify([
16469
16612
  app.linkedProducts,
16470
16613
  app.packageResolved,
16471
16614
  stamp(app.packageResolved),
16472
- app.localPackageDirs.map((dir) => stamp(import_node_path19.default.join(dir, "Package.swift"))),
16615
+ app.localPackageDirs.map((dir) => stamp(import_node_path20.default.join(dir, "Package.swift"))),
16473
16616
  app.linkedProducts.map(
16474
- ({ source }) => source.kind === "local" ? stamp(import_node_path19.default.join(source.dir, "Package.swift")) : 0
16617
+ ({ source }) => source.kind === "local" ? stamp(import_node_path20.default.join(source.dir, "Package.swift")) : 0
16475
16618
  )
16476
16619
  ]);
16477
16620
  let cached3 = entry.packages;
@@ -16522,11 +16665,11 @@ var XCODE_APP_DIR = "__app__";
16522
16665
  var XCODE_FRAMEWORKS_DIR = "__frameworks__";
16523
16666
  var XCODE_PACKAGES_DIR = "__packages__";
16524
16667
  var XCODE_STANDINS_DIR = "__standins__";
16525
- var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(import_node_path19.default.sep).join(import_node_path19.default.posix.sep)}/`;
16668
+ var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(import_node_path20.default.sep).join(import_node_path20.default.posix.sep)}/`;
16526
16669
  function xcodeInputKey(layout, file, relative2) {
16527
16670
  const owner = layout.targetDirs.get(file);
16528
- if (owner) return import_node_path19.default.posix.join(owner, relative2);
16529
- return relative2.startsWith(CHECKOUTS_PREFIX) ? import_node_path19.default.posix.join(XCODE_PACKAGES_DIR, relative2.slice(CHECKOUTS_PREFIX.length)) : relative2;
16671
+ if (owner) return import_node_path20.default.posix.join(owner, relative2);
16672
+ return relative2.startsWith(CHECKOUTS_PREFIX) ? import_node_path20.default.posix.join(XCODE_PACKAGES_DIR, relative2.slice(CHECKOUTS_PREFIX.length)) : relative2;
16530
16673
  }
16531
16674
  function xcodeLayout(root) {
16532
16675
  const registered = xcodeProjects.get(root);
@@ -16537,7 +16680,7 @@ function xcodeLayout(root) {
16537
16680
  const targetDirs = new Map(app.sources.map((file) => [file, XCODE_APP_DIR]));
16538
16681
  const targets = [];
16539
16682
  for (const framework of app.frameworks) {
16540
- const dir = import_node_path19.default.posix.join(XCODE_FRAMEWORKS_DIR, framework.moduleName);
16683
+ const dir = import_node_path20.default.posix.join(XCODE_FRAMEWORKS_DIR, framework.moduleName);
16541
16684
  for (const file of framework.sources) {
16542
16685
  if (targetDirs.has(file)) continue;
16543
16686
  targetDirs.set(file, dir);
@@ -16557,7 +16700,7 @@ function xcodeLayout(root) {
16557
16700
  for (const standin of standins)
16558
16701
  targets.push({
16559
16702
  name: standin.module,
16560
- path: import_node_path19.default.posix.join(XCODE_STANDINS_DIR, standin.module),
16703
+ path: import_node_path20.default.posix.join(XCODE_STANDINS_DIR, standin.module),
16561
16704
  executable: false,
16562
16705
  resources: false,
16563
16706
  exclude: [],
@@ -16565,19 +16708,19 @@ function xcodeLayout(root) {
16565
16708
  mainActorIsolation: false
16566
16709
  });
16567
16710
  for (const target of packages.targets) {
16568
- const relative2 = import_node_path19.default.relative(
16569
- target.remote ? import_node_path19.default.join(root, REMOTE_CHECKOUTS) : root,
16711
+ const relative2 = import_node_path20.default.relative(
16712
+ target.remote ? import_node_path20.default.join(root, REMOTE_CHECKOUTS) : root,
16570
16713
  target.dir
16571
16714
  );
16572
- if (relative2 === ".." || relative2.startsWith(`..${import_node_path19.default.sep}`) || import_node_path19.default.isAbsolute(relative2))
16715
+ if (relative2 === ".." || relative2.startsWith(`..${import_node_path20.default.sep}`) || import_node_path20.default.isAbsolute(relative2))
16573
16716
  throw new Error(`swift input escapes the selected package: ${target.dir}`);
16574
- const posix2 = relative2.split(import_node_path19.default.sep).join(import_node_path19.default.posix.sep);
16717
+ const posix2 = relative2.split(import_node_path20.default.sep).join(import_node_path20.default.posix.sep);
16575
16718
  targets.push({
16576
16719
  ...target,
16577
- path: target.remote ? import_node_path19.default.posix.join(XCODE_PACKAGES_DIR, posix2) : posix2,
16720
+ path: target.remote ? import_node_path20.default.posix.join(XCODE_PACKAGES_DIR, posix2) : posix2,
16578
16721
  exclude: []
16579
16722
  });
16580
- if (!target.remote) files2.add(import_node_path19.default.join(target.packageDir, "Package.swift"));
16723
+ if (!target.remote) files2.add(import_node_path20.default.join(target.packageDir, "Package.swift"));
16581
16724
  for (const file of target.files) files2.add(file);
16582
16725
  }
16583
16726
  for (const target of targets) {
@@ -16607,25 +16750,25 @@ function xcodeManifest(layout) {
16607
16750
  ].join("\n");
16608
16751
  }
16609
16752
  function packageFiles(root) {
16610
- const canonicalRoot = import_node_fs18.default.realpathSync(root);
16753
+ const canonicalRoot = import_node_fs19.default.realpathSync(root);
16611
16754
  const xcode = xcodeLayout(canonicalRoot);
16612
16755
  return xcode ? xcode.files : sourceTreeFiles(canonicalRoot, canonicalRoot);
16613
16756
  }
16614
16757
  function sourceTreeFiles(dir, canonicalRoot) {
16615
16758
  const found = [];
16616
16759
  const walk2 = (dir2) => {
16617
- for (const entry of import_node_fs18.default.readdirSync(dir2, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
16760
+ for (const entry of import_node_fs19.default.readdirSync(dir2, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
16618
16761
  if (entry.name.startsWith(".") && entry.name !== NATIVE_DESCRIPTOR && entry.name !== NATIVE_GLUE || SKIP_SOURCE_DIRS.has(entry.name))
16619
16762
  continue;
16620
- const full = import_node_path19.default.join(dir2, entry.name);
16763
+ const full = import_node_path20.default.join(dir2, entry.name);
16621
16764
  if (entry.isSymbolicLink()) throw new Error(`swift input is a symlink: ${full}`);
16622
- const real = import_node_fs18.default.realpathSync(full);
16623
- const relative2 = import_node_path19.default.relative(canonicalRoot, real);
16624
- if (relative2.startsWith(`..${import_node_path19.default.sep}`) || relative2 === ".." || import_node_path19.default.isAbsolute(relative2)) {
16765
+ const real = import_node_fs19.default.realpathSync(full);
16766
+ const relative2 = import_node_path20.default.relative(canonicalRoot, real);
16767
+ if (relative2.startsWith(`..${import_node_path20.default.sep}`) || relative2 === ".." || import_node_path20.default.isAbsolute(relative2)) {
16625
16768
  throw new Error(`swift input escapes the selected package: ${full}`);
16626
16769
  }
16627
16770
  if (entry.isDirectory()) {
16628
- if (import_node_fs18.default.existsSync(import_node_path19.default.join(full, "Package.swift"))) continue;
16771
+ if (import_node_fs19.default.existsSync(import_node_path20.default.join(full, "Package.swift"))) continue;
16629
16772
  walk2(full);
16630
16773
  } else if (entry.isFile()) {
16631
16774
  found.push(full);
@@ -16633,56 +16776,15 @@ function sourceTreeFiles(dir, canonicalRoot) {
16633
16776
  }
16634
16777
  }
16635
16778
  };
16636
- if (import_node_fs18.default.existsSync(dir)) walk2(import_node_fs18.default.realpathSync(dir));
16779
+ if (import_node_fs19.default.existsSync(dir)) walk2(import_node_fs19.default.realpathSync(dir));
16637
16780
  return found;
16638
16781
  }
16639
- function readPackageFile(root, file, maxBytes) {
16640
- const canonicalRoot = import_node_fs18.default.realpathSync(root);
16641
- const relative2 = import_node_path19.default.relative(canonicalRoot, import_node_fs18.default.realpathSync(file));
16642
- if (relative2 === ".." || relative2.startsWith(`..${import_node_path19.default.sep}`) || import_node_path19.default.isAbsolute(relative2)) {
16643
- throw new Error(`swift input escapes the selected package: ${file}`);
16644
- }
16645
- let ancestor = import_node_path19.default.resolve(file);
16646
- while (ancestor !== canonicalRoot) {
16647
- if (import_node_fs18.default.lstatSync(ancestor).isSymbolicLink()) {
16648
- throw new Error(`swift input is a symlink: ${ancestor}`);
16649
- }
16650
- const parent = import_node_path19.default.dirname(ancestor);
16651
- if (parent === ancestor)
16652
- throw new Error(`swift input escapes the selected package: ${file}`);
16653
- ancestor = parent;
16654
- }
16655
- const expected = import_node_fs18.default.statSync(file);
16656
- const fd = import_node_fs18.default.openSync(file, import_node_fs18.default.constants.O_RDONLY | import_node_fs18.default.constants.O_NOFOLLOW);
16657
- try {
16658
- const stat2 = import_node_fs18.default.fstatSync(fd);
16659
- if (stat2.dev !== expected.dev || stat2.ino !== expected.ino) {
16660
- throw new Error(`swift input changed while opening: ${file}`);
16661
- }
16662
- if (!stat2.isFile() || stat2.size > maxBytes) {
16663
- throw new Error(`swift input exceeds ${maxBytes} bytes: ${file}`);
16664
- }
16665
- const bytes = Buffer.alloc(stat2.size + 1);
16666
- let offset = 0;
16667
- while (offset < bytes.length) {
16668
- const count = import_node_fs18.default.readSync(fd, bytes, offset, bytes.length - offset, null);
16669
- if (count === 0) break;
16670
- offset += count;
16671
- }
16672
- if (offset !== stat2.size || import_node_fs18.default.fstatSync(fd).size !== stat2.size) {
16673
- throw new Error(`swift input changed while reading: ${file}`);
16674
- }
16675
- return bytes.subarray(0, offset);
16676
- } finally {
16677
- import_node_fs18.default.closeSync(fd);
16678
- }
16679
- }
16680
16782
  function sourceFiles(root) {
16681
16783
  return packageFiles(root).filter((file) => file.endsWith(".swift"));
16682
16784
  }
16683
16785
  function resourceCandidateFiles(root) {
16684
16786
  return packageFiles(root).filter(
16685
- (file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(import_node_path19.default.basename(file))
16787
+ (file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(import_node_path20.default.basename(file))
16686
16788
  );
16687
16789
  }
16688
16790
  var HOSTED_LIMITS = {
@@ -16716,7 +16818,7 @@ function buildSwiftResourceTable(project, baseUrl) {
16716
16818
  const limits = inputLimits(Boolean(project.hosted));
16717
16819
  const absolute = resourceCandidateFiles(project.packagePath);
16718
16820
  const relative2 = absolute.map(
16719
- (file) => import_node_path19.default.relative(project.packagePath, file).split(import_node_path19.default.sep).join(import_node_path19.default.posix.sep)
16821
+ (file) => import_node_path20.default.relative(project.packagePath, file).split(import_node_path20.default.sep).join(import_node_path20.default.posix.sep)
16720
16822
  );
16721
16823
  const byRelative = new Map(absolute.map((file, index) => [relative2[index], file]));
16722
16824
  const readContents = (candidate) => {
@@ -16738,16 +16840,16 @@ function buildSwiftResourceTable(project, baseUrl) {
16738
16840
  for (const { name: name2, file, scale } of found) {
16739
16841
  const disk = byRelative.get(file);
16740
16842
  if (!disk) continue;
16741
- if (Object.keys(images).length >= limits.images || imageBytes + import_node_fs18.default.statSync(disk).size > limits.imageTotalBytes) {
16843
+ if (Object.keys(images).length >= limits.images || imageBytes + import_node_fs19.default.statSync(disk).size > limits.imageTotalBytes) {
16742
16844
  throw new Error("swift image pack exceeds the compile service caps");
16743
16845
  }
16744
16846
  const bytes = readPackageFile(project.packagePath, disk, limits.imageBytes);
16745
16847
  imageBytes += bytes.length;
16746
16848
  const hash = (0, import_node_crypto8.createHash)("sha256").update(bytes).digest("hex").slice(0, 16);
16747
- const ext = import_node_path19.default.posix.extname(file).toLowerCase();
16849
+ const ext = import_node_path20.default.posix.extname(file).toLowerCase();
16748
16850
  table[name2] = { uri: `${baseUrl}${RESOURCE_PATH}${hash}${ext}`, scale };
16749
16851
  images[name2] = {
16750
- file: import_node_path19.default.posix.basename(file),
16852
+ file: import_node_path20.default.posix.basename(file),
16751
16853
  data: bytes.toString("base64")
16752
16854
  };
16753
16855
  watched.push(file);
@@ -16771,10 +16873,10 @@ function buildSwiftResourceTable(project, baseUrl) {
16771
16873
  return { table, images, colors, symbols, watched };
16772
16874
  }
16773
16875
  function buildSwiftBundleFiles(packagePath, hosted) {
16774
- packagePath = import_node_fs18.default.realpathSync(packagePath);
16876
+ packagePath = import_node_fs19.default.realpathSync(packagePath);
16775
16877
  const limits = inputLimits(hosted);
16776
16878
  const relative2 = resourceCandidateFiles(packagePath).map(
16777
- (file) => import_node_path19.default.relative(packagePath, file).split(import_node_path19.default.sep).join(import_node_path19.default.posix.sep)
16879
+ (file) => import_node_path20.default.relative(packagePath, file).split(import_node_path20.default.sep).join(import_node_path20.default.posix.sep)
16778
16880
  );
16779
16881
  const files2 = {};
16780
16882
  const watched = [];
@@ -16788,13 +16890,13 @@ function buildSwiftBundleFiles(packagePath, hosted) {
16788
16890
  total += bytes.length;
16789
16891
  if (xcode.app.infoPlistFile)
16790
16892
  watched.push(
16791
- import_node_path19.default.relative(packagePath, xcode.app.infoPlistFile).split(import_node_path19.default.sep).join("/")
16893
+ import_node_path20.default.relative(packagePath, xcode.app.infoPlistFile).split(import_node_path20.default.sep).join("/")
16792
16894
  );
16793
16895
  }
16794
16896
  for (const { base, file } of enumerateBundleJson(relative2)) {
16795
16897
  watched.push(file);
16796
- const disk = import_node_path19.default.join(packagePath, ...file.split("/"));
16797
- if (Object.keys(files2).length >= limits.resources || total + import_node_fs18.default.statSync(disk).size > limits.resourceTotalBytes) {
16898
+ const disk = import_node_path20.default.join(packagePath, ...file.split("/"));
16899
+ if (Object.keys(files2).length >= limits.resources || total + import_node_fs19.default.statSync(disk).size > limits.resourceTotalBytes) {
16798
16900
  throw new Error(
16799
16901
  `swift bundle pack exceeds ${limits.resources} files / ${limits.resourceTotalBytes} bytes`
16800
16902
  );
@@ -16809,12 +16911,12 @@ function serveSwiftResource(project, key2) {
16809
16911
  return project.resourceFiles.get(key2) ?? project.resourcesPrevious.get(key2) ?? null;
16810
16912
  }
16811
16913
  function linkedModuleRoots(packagePath) {
16812
- packagePath = import_node_fs18.default.realpathSync(packagePath);
16914
+ packagePath = import_node_fs19.default.realpathSync(packagePath);
16813
16915
  let manifest;
16814
16916
  try {
16815
16917
  manifest = readPackageFile(
16816
16918
  packagePath,
16817
- import_node_path19.default.join(packagePath, "Package.swift"),
16919
+ import_node_path20.default.join(packagePath, "Package.swift"),
16818
16920
  MAX_SWIFT_COMPILE_SOURCE_BYTES
16819
16921
  ).toString("utf8");
16820
16922
  } catch {
@@ -16823,8 +16925,8 @@ function linkedModuleRoots(packagePath) {
16823
16925
  const roots = /* @__PURE__ */ new Set();
16824
16926
  const dependency = /\.package\(\s*path:\s*"([^"]+)"\s*\)/g;
16825
16927
  for (const match of manifest.replace(/^\s*\/\/.*$/gm, "").matchAll(dependency)) {
16826
- const root = import_node_path19.default.resolve(packagePath, match[1]);
16827
- if (import_node_fs18.default.existsSync(import_node_path19.default.join(root, "Package.swift"))) roots.add(root);
16928
+ const root = import_node_path20.default.resolve(packagePath, match[1]);
16929
+ if (import_node_fs19.default.existsSync(import_node_path20.default.join(root, "Package.swift"))) roots.add(root);
16828
16930
  }
16829
16931
  return [...roots].sort();
16830
16932
  }
@@ -16833,18 +16935,18 @@ function sourceStamp(packagePath, moduleRootOverride, hosted = false) {
16833
16935
  hash.update(packagePath);
16834
16936
  const projectInputs = new Set(packageFiles(packagePath));
16835
16937
  for (const file of [...projectInputs].sort()) {
16836
- hash.update(import_node_path19.default.relative(packagePath, file));
16837
- const stat2 = import_node_fs18.default.statSync(file);
16938
+ hash.update(import_node_path20.default.relative(packagePath, file));
16939
+ const stat2 = import_node_fs19.default.statSync(file);
16838
16940
  hash.update(`${stat2.mtimeMs}/${stat2.ctimeMs}/${stat2.size}`);
16839
16941
  }
16840
16942
  const moduleRoot = hosted ? void 0 : moduleRootOverride ?? linkedModuleRoots(packagePath).find(
16841
- (root) => import_node_fs18.default.existsSync(import_node_path19.default.join(root, "toolchain.json"))
16943
+ (root) => import_node_fs19.default.existsSync(import_node_path20.default.join(root, "toolchain.json"))
16842
16944
  );
16843
16945
  if (moduleRoot) {
16844
16946
  hash.update(moduleRoot);
16845
16947
  for (const relative2 of swiftModuleInputFiles(moduleRoot)) {
16846
16948
  hash.update(relative2);
16847
- hash.update(String(import_node_fs18.default.statSync(import_node_path19.default.join(moduleRoot, relative2)).mtimeMs));
16949
+ hash.update(String(import_node_fs19.default.statSync(import_node_path20.default.join(moduleRoot, relative2)).mtimeMs));
16848
16950
  }
16849
16951
  }
16850
16952
  return hash.digest("hex").slice(0, 16);
@@ -16856,8 +16958,8 @@ function packageSources(packagePath) {
16856
16958
  const xcode = xcodeLayout(packagePath);
16857
16959
  const files2 = {};
16858
16960
  for (const file of sourceFiles(packagePath)) {
16859
- const relative2 = import_node_path19.default.relative(packagePath, file).split(import_node_path19.default.sep).join(import_node_path19.default.posix.sep);
16860
- if (xcode && import_node_path19.default.basename(file) === "Package.swift") continue;
16961
+ const relative2 = import_node_path20.default.relative(packagePath, file).split(import_node_path20.default.sep).join(import_node_path20.default.posix.sep);
16962
+ if (xcode && import_node_path20.default.basename(file) === "Package.swift") continue;
16861
16963
  files2[xcode ? xcodeInputKey(xcode, file, relative2) : relative2] = readPackageFile(
16862
16964
  packagePath,
16863
16965
  file,
@@ -16868,7 +16970,7 @@ function packageSources(packagePath) {
16868
16970
  files2["Package.swift"] = xcodeManifest(xcode);
16869
16971
  for (const standin of xcode.standins)
16870
16972
  for (const [file, text3] of Object.entries(standin.files))
16871
- files2[import_node_path19.default.posix.join(XCODE_STANDINS_DIR, standin.module, file)] = text3;
16973
+ files2[import_node_path20.default.posix.join(XCODE_STANDINS_DIR, standin.module, file)] = text3;
16872
16974
  }
16873
16975
  return files2;
16874
16976
  }
@@ -16879,7 +16981,7 @@ function packageSnapshot(project) {
16879
16981
  files: files2,
16880
16982
  resourcePaths: swiftImplicitResourcePaths(
16881
16983
  resourceCandidateFiles(project.packagePath).map(
16882
- (file) => import_node_path19.default.relative(project.packagePath, file).split(import_node_path19.default.sep).join(import_node_path19.default.posix.sep)
16984
+ (file) => import_node_path20.default.relative(project.packagePath, file).split(import_node_path20.default.sep).join(import_node_path20.default.posix.sep)
16883
16985
  )
16884
16986
  ),
16885
16987
  resources: buildSwiftResourceTable(project, ""),
@@ -16888,7 +16990,7 @@ function packageSnapshot(project) {
16888
16990
  ...native ? {
16889
16991
  glue: readPackageFile(
16890
16992
  project.packagePath,
16891
- import_node_path19.default.join(project.packagePath, NATIVE_GLUE),
16993
+ import_node_path20.default.join(project.packagePath, NATIVE_GLUE),
16892
16994
  MAX_SWIFT_COMPILE_SOURCE_BYTES
16893
16995
  ).toString("utf8")
16894
16996
  } : {}
@@ -16924,7 +17026,7 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
16924
17026
  package: content
16925
17027
  };
16926
17028
  const moduleRoot = moduleRootOverride ?? linkedModuleRoots(packagePath).find(
16927
- (root) => import_node_fs18.default.existsSync(import_node_path19.default.join(root, "toolchain.json"))
17029
+ (root) => import_node_fs19.default.existsSync(import_node_path20.default.join(root, "toolchain.json"))
16928
17030
  ) ?? await swiftDistributionRoot();
16929
17031
  if (!moduleRoot)
16930
17032
  return {
@@ -16951,10 +17053,10 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
16951
17053
  // server and a capture, or two checkouts) build each other's sources. so
16952
17054
  // each app and module checkout gets its own root, which keeps the same
16953
17055
  // app's incremental build across restarts.
16954
- buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ?? import_node_path19.default.join(
17056
+ buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ?? import_node_path20.default.join(
16955
17057
  import_node_os8.default.tmpdir(),
16956
17058
  "contrast-swift-build",
16957
- (0, import_node_crypto8.createHash)("sha256").update(`${moduleRoot}\0${import_node_path19.default.resolve(packagePath)}`).digest("hex").slice(0, 16)
17059
+ (0, import_node_crypto8.createHash)("sha256").update(`${moduleRoot}\0${import_node_path20.default.resolve(packagePath)}`).digest("hex").slice(0, 16)
16958
17060
  ),
16959
17061
  moduleRoot,
16960
17062
  ...toolchain
@@ -17066,7 +17168,7 @@ async function missingModulesMessage(packagePath, missing) {
17066
17168
  `Peach does not provide ${missing.size} module${missing.size === 1 ? "" : "s"} this app imports:`,
17067
17169
  ...[...missing].map(([name2, files2]) => {
17068
17170
  const gap = gaps.get(name2);
17069
- return ` ${name2.padEnd(width)} ${files2.length} file${files2.length === 1 ? "" : "s"}${gap ? `, ${gap.source.includes("://") ? `package ${gap.source}` : gap.source.startsWith("/") ? `package ${import_node_path19.default.relative(packagePath, gap.source) || "."}` : gap.source} (${gap.reason})` : ""}`;
17171
+ return ` ${name2.padEnd(width)} ${files2.length} file${files2.length === 1 ? "" : "s"}${gap ? `, ${gap.source.includes("://") ? `package ${gap.source}` : gap.source.startsWith("/") ? `package ${import_node_path20.default.relative(packagePath, gap.source) || "."}` : gap.source} (${gap.reason})` : ""}`;
17070
17172
  })
17071
17173
  ].join("\n");
17072
17174
  }
@@ -17074,7 +17176,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
17074
17176
  const auth = hosted ? null : resolveCliAuth();
17075
17177
  if (!hosted && (!auth || auth.kind === "github")) {
17076
17178
  throw new Error(
17077
- `compiling ${import_node_path19.default.basename(packagePath)} for Peach needs \`peach login\` or PEACH_API_KEY: this peachsim has no local SwiftUI module, so Contrast compiles it`
17179
+ `compiling ${import_node_path20.default.basename(packagePath)} for Peach needs \`peach login\` or PEACH_API_KEY: this peachsim has no local SwiftUI module, so Contrast compiles it`
17078
17180
  );
17079
17181
  }
17080
17182
  const origin = hosted?.origin ?? resolveContrastBackendOrigin(auth?.kind === "session" ? auth.origin : null);
@@ -17093,7 +17195,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
17093
17195
  const bytes = sources.reduce((total2, text3) => total2 + Buffer.byteLength(text3), 0);
17094
17196
  if (sources.length > MAX_SWIFT_COMPILE_FILES || bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES) {
17095
17197
  throw new Error(
17096
- `${import_node_path19.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`
17198
+ `${import_node_path20.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`
17097
17199
  );
17098
17200
  }
17099
17201
  const descriptor = snapshot.native;
@@ -17112,7 +17214,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
17112
17214
  );
17113
17215
  if (descriptor && address.native?.hash !== descriptor.hash) {
17114
17216
  throw new Error(
17115
- `${import_node_path19.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`
17217
+ `${import_node_path20.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`
17116
17218
  );
17117
17219
  }
17118
17220
  const response = await fetch(address.url, { signal });
@@ -17236,8 +17338,8 @@ var scriptEnv = { ...process.env, [RNX_FORKED_SCRIPT_ENV]: "1" };
17236
17338
  var EXPO_SWIFT_ROUTE = "/__peach/expo-swift";
17237
17339
  var EXPO_SWIFT_ENTRY = "Sources/PeachExpoApp/PeachExpoEntry.swift";
17238
17340
  async function collectExpoSwiftSources(appRoot) {
17239
- appRoot = import_node_fs19.default.realpathSync(appRoot);
17240
- const appRequire = (0, import_node_module.createRequire)(import_node_path20.default.join(appRoot, "package.json"));
17341
+ appRoot = import_node_fs20.default.realpathSync(appRoot);
17342
+ const appRequire = (0, import_node_module.createRequire)(import_node_path21.default.join(appRoot, "package.json"));
17241
17343
  let autolinker;
17242
17344
  try {
17243
17345
  autolinker = appRequire.resolve("expo-modules-autolinking/package.json");
@@ -17251,7 +17353,7 @@ async function collectExpoSwiftSources(appRoot) {
17251
17353
  (command) => run3(
17252
17354
  process.execPath,
17253
17355
  [
17254
- import_node_path20.default.join(import_node_path20.default.dirname(autolinker), "bin/expo-modules-autolinking.js"),
17356
+ import_node_path21.default.join(import_node_path21.default.dirname(autolinker), "bin/expo-modules-autolinking.js"),
17255
17357
  command,
17256
17358
  "--platform",
17257
17359
  "apple",
@@ -17282,8 +17384,8 @@ async function collectExpoSwiftSources(appRoot) {
17282
17384
  const sourceRoot = Reflect.get(entry, "path");
17283
17385
  if (typeof sourceRoot !== "string")
17284
17386
  throw new Error("Expo autolinking entry has no path");
17285
- const canonical = import_node_fs19.default.realpathSync(sourceRoot);
17286
- if (canonical.split(import_node_path20.default.sep).includes("node_modules")) continue;
17387
+ const canonical = import_node_fs20.default.realpathSync(sourceRoot);
17388
+ if (canonical.split(import_node_path21.default.sep).includes("node_modules")) continue;
17287
17389
  const resolution = resolutions.find(
17288
17390
  (candidate) => candidate && typeof candidate === "object" && Reflect.get(candidate, "packageName") === Reflect.get(entry, "name")
17289
17391
  );
@@ -17310,12 +17412,12 @@ async function collectExpoSwiftSources(appRoot) {
17310
17412
  registration: `(${className.includes(".") ? className : `${namespace}.${className}`}.self, ${name2 === null ? "nil" : JSON.stringify(name2)})`
17311
17413
  });
17312
17414
  }
17313
- const ios = import_node_path20.default.join(canonical, "ios");
17314
- if (import_node_fs19.default.lstatSync(ios).isSymbolicLink())
17415
+ const ios = import_node_path21.default.join(canonical, "ios");
17416
+ if (import_node_fs20.default.lstatSync(ios).isSymbolicLink())
17315
17417
  throw new Error(`Expo Swift source directory is a symlink: ${ios}`);
17316
17418
  const walk2 = (dir) => {
17317
- for (const child of import_node_fs19.default.readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
17318
- const file = import_node_path20.default.join(dir, child.name);
17419
+ for (const child of import_node_fs20.default.readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
17420
+ const file = import_node_path21.default.join(dir, child.name);
17319
17421
  if (child.isSymbolicLink())
17320
17422
  throw new Error(`Expo Swift source is a symlink: ${file}`);
17321
17423
  if (child.isDirectory()) {
@@ -17323,13 +17425,13 @@ async function collectExpoSwiftSources(appRoot) {
17323
17425
  continue;
17324
17426
  }
17325
17427
  if (!child.name.endsWith(".swift")) continue;
17326
- const size = import_node_fs19.default.statSync(file).size;
17428
+ const size = import_node_fs20.default.statSync(file).size;
17327
17429
  bytes += size;
17328
17430
  fileCount++;
17329
17431
  if (fileCount > MAX_SWIFT_COMPILE_FILES - 2 || bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES)
17330
17432
  throw new Error("Expo Swift sources exceed compile service caps");
17331
- files2[`Sources/${namespace}/${import_node_path20.default.relative(ios, file).split(import_node_path20.default.sep).join("/")}`] = `#sourceLocation(file: ${JSON.stringify(file)}, line: 1)
17332
- ${import_node_fs19.default.readFileSync(file, "utf8")}`;
17433
+ files2[`Sources/${namespace}/${import_node_path21.default.relative(ios, file).split(import_node_path21.default.sep).join("/")}`] = `#sourceLocation(file: ${JSON.stringify(file)}, line: 1)
17434
+ ${import_node_fs20.default.readFileSync(file, "utf8")}`;
17333
17435
  }
17334
17436
  };
17335
17437
  walk2(ios);
@@ -17415,7 +17517,7 @@ async function compileExpoSwiftModules(root, base, publishArtifact) {
17415
17517
  modules: [],
17416
17518
  failures: []
17417
17519
  };
17418
- const key2 = (0, import_node_crypto9.createHash)("sha256").update(import_node_fs19.default.realpathSync(root)).digest("hex");
17520
+ const key2 = (0, import_node_crypto9.createHash)("sha256").update(import_node_fs20.default.realpathSync(root)).digest("hex");
17419
17521
  const linked = [];
17420
17522
  for (const unit of units) {
17421
17523
  if (!module2) {
@@ -17425,14 +17527,14 @@ async function compileExpoSwiftModules(root, base, publishArtifact) {
17425
17527
  });
17426
17528
  continue;
17427
17529
  }
17428
- const packagePath = import_node_path20.default.join(import_node_os9.default.tmpdir(), "peach-expo-swift", key2, unit.moduleId);
17530
+ const packagePath = import_node_path21.default.join(import_node_os9.default.tmpdir(), "peach-expo-swift", key2, unit.moduleId);
17429
17531
  let stamp;
17430
17532
  try {
17431
17533
  syncSwiftTree(
17432
17534
  packagePath,
17433
17535
  new Map(
17434
17536
  Object.entries(unit.files).map(([name2, source]) => [
17435
- import_node_path20.default.join(packagePath, name2),
17537
+ import_node_path21.default.join(packagePath, name2),
17436
17538
  source
17437
17539
  ])
17438
17540
  )
@@ -17457,10 +17559,13 @@ async function compileExpoSwiftModules(root, base, publishArtifact) {
17457
17559
  const file = JSON.parse(match[1]);
17458
17560
  return typeof file === "string" ? [file] : [];
17459
17561
  });
17460
- const sourceErrors = (diagnostic.match(/^.+:\d+(?::\d+)?: error:.*$/gm) ?? []).filter((line) => appPaths.some((file) => line.startsWith(`${file}:`)));
17461
- if (publishArtifact && sourceErrors.length === 0 && !(error instanceof SwiftMissingModulesError))
17562
+ const errors = diagnostic.match(/^.+:\d+(?::\d+)?: error:.*$/gm) ?? [];
17563
+ const sourceErrors = errors.filter(
17564
+ (line) => appPaths.some((file) => line.startsWith(`${file}:`)) && !/external macro implementation type|failed to load library plugin/.test(line)
17565
+ );
17566
+ if (publishArtifact && (sourceErrors.length === 0 || sourceErrors.length !== errors.length) && !(error instanceof SwiftMissingModulesError))
17462
17567
  throw error;
17463
- if (sourceErrors.length && module2 && stamp && sourceStamp(packagePath, module2.root) === stamp) {
17568
+ if (sourceErrors.length && sourceErrors.length === errors.length && module2 && stamp && sourceStamp(packagePath, module2.root) === stamp) {
17464
17569
  failedCompilations.set(packagePath, {
17465
17570
  stamp,
17466
17571
  diagnostic: sourceErrors.join("\n")
@@ -17490,12 +17595,12 @@ async function compileExpoSwiftModules(root, base, publishArtifact) {
17490
17595
  import PackageDescription
17491
17596
  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")])
17492
17597
  `;
17493
- const packagePath = import_node_path20.default.join(import_node_os9.default.tmpdir(), "peach-expo-swift", key2, "linked-app");
17598
+ const packagePath = import_node_path21.default.join(import_node_os9.default.tmpdir(), "peach-expo-swift", key2, "linked-app");
17494
17599
  syncSwiftTree(
17495
17600
  packagePath,
17496
17601
  new Map(
17497
17602
  Object.entries(files2).map(([name2, source]) => [
17498
- import_node_path20.default.join(packagePath, name2),
17603
+ import_node_path21.default.join(packagePath, name2),
17499
17604
  source
17500
17605
  ])
17501
17606
  )
@@ -17538,7 +17643,7 @@ async function handleExpoSwiftRequest(req, res) {
17538
17643
  return true;
17539
17644
  }
17540
17645
  const root = url.searchParams.get("root");
17541
- if (!root || !import_node_path20.default.isAbsolute(root)) {
17646
+ if (!root || !import_node_path21.default.isAbsolute(root)) {
17542
17647
  res.writeHead(400);
17543
17648
  res.end("missing absolute app root");
17544
17649
  return true;
@@ -17705,19 +17810,19 @@ var rnxRuntime = createRuntimeDelivery(RNX_RUNTIME_PRODUCT);
17705
17810
 
17706
17811
  // src/host/agent-host.ts
17707
17812
  var import_node_crypto12 = require("node:crypto");
17708
- var import_node_fs23 = __toESM(require("node:fs"), 1);
17709
- var import_node_path24 = __toESM(require("node:path"), 1);
17813
+ var import_node_fs24 = __toESM(require("node:fs"), 1);
17814
+ var import_node_path25 = __toESM(require("node:path"), 1);
17710
17815
 
17711
17816
  // src/agent-sessions.ts
17712
17817
  var import_node_child_process10 = require("node:child_process");
17713
17818
  var import_node_crypto11 = require("node:crypto");
17714
- var import_node_fs22 = __toESM(require("node:fs"), 1);
17715
- var import_node_path23 = __toESM(require("node:path"), 1);
17819
+ var import_node_fs23 = __toESM(require("node:fs"), 1);
17820
+ var import_node_path24 = __toESM(require("node:path"), 1);
17716
17821
  var import_node_readline = __toESM(require("node:readline"), 1);
17717
17822
 
17718
17823
  // cli/self-invocation.ts
17719
- var import_node_fs20 = require("node:fs");
17720
- var import_node_path21 = require("node:path");
17824
+ var import_node_fs21 = require("node:fs");
17825
+ var import_node_path22 = require("node:path");
17721
17826
  var import_node_url3 = require("node:url");
17722
17827
  init_public_brand();
17723
17828
 
@@ -17727,14 +17832,14 @@ var IS_STANDALONE = typeof __SOOTSIM_STANDALONE__ !== "undefined" && __SOOTSIM_S
17727
17832
  // cli/self-invocation.ts
17728
17833
  function sourceEntryPath() {
17729
17834
  try {
17730
- const candidate = (0, import_node_path21.join)((0, import_node_path21.dirname)((0, import_node_url3.fileURLToPath)(__sootsim_import_meta_url)), "bin.ts");
17731
- return (0, import_node_fs20.existsSync)(candidate) ? candidate : null;
17835
+ const candidate = (0, import_node_path22.join)((0, import_node_path22.dirname)((0, import_node_url3.fileURLToPath)(__sootsim_import_meta_url)), "bin.ts");
17836
+ return (0, import_node_fs21.existsSync)(candidate) ? candidate : null;
17732
17837
  } catch {
17733
17838
  return null;
17734
17839
  }
17735
17840
  }
17736
- function isCliEntry(path24) {
17737
- const name2 = (0, import_node_path21.basename)(path24);
17841
+ function isCliEntry(path25) {
17842
+ const name2 = (0, import_node_path22.basename)(path25);
17738
17843
  return name2 === "bin.ts" || name2 === "bin.js";
17739
17844
  }
17740
17845
  function rnxSelfInvocation() {
@@ -17794,8 +17899,8 @@ function encodeAgentPromptEnvelope(input) {
17794
17899
 
17795
17900
  // src/attached-projects.ts
17796
17901
  var import_node_crypto10 = require("node:crypto");
17797
- var import_node_fs21 = __toESM(require("node:fs"), 1);
17798
- var import_node_path22 = __toESM(require("node:path"), 1);
17902
+ var import_node_fs22 = __toESM(require("node:fs"), 1);
17903
+ var import_node_path23 = __toESM(require("node:path"), 1);
17799
17904
  init_home_paths();
17800
17905
  var overrideDir = null;
17801
17906
  function userDataDir() {
@@ -17808,7 +17913,7 @@ function getUserDataDir() {
17808
17913
  return userDataDir();
17809
17914
  }
17810
17915
  function storeFile() {
17811
- return import_node_path22.default.join(userDataDir(), "attached-projects.json");
17916
+ return import_node_path23.default.join(userDataDir(), "attached-projects.json");
17812
17917
  }
17813
17918
  function cloneEmpty() {
17814
17919
  return {
@@ -17822,7 +17927,7 @@ function loadStore() {
17822
17927
  const file = storeFile();
17823
17928
  let raw2;
17824
17929
  try {
17825
- raw2 = import_node_fs21.default.readFileSync(file, "utf8");
17930
+ raw2 = import_node_fs22.default.readFileSync(file, "utf8");
17826
17931
  } catch (err) {
17827
17932
  if (err.code === "ENOENT") return cloneEmpty();
17828
17933
  throw err;
@@ -17839,7 +17944,7 @@ function loadStore() {
17839
17944
  } catch (err) {
17840
17945
  const quarantine = `${file}.corrupt-${Date.now()}`;
17841
17946
  try {
17842
- import_node_fs21.default.renameSync(file, quarantine);
17947
+ import_node_fs22.default.renameSync(file, quarantine);
17843
17948
  console.warn(
17844
17949
  `[sootsim] attached-projects.json was unparseable; quarantined to ${quarantine}. original error: ${err.message}`
17845
17950
  );
@@ -17850,16 +17955,16 @@ function loadStore() {
17850
17955
  }
17851
17956
  function writeStore(store) {
17852
17957
  const file = storeFile();
17853
- import_node_fs21.default.mkdirSync(import_node_path22.default.dirname(file), { recursive: true });
17958
+ import_node_fs22.default.mkdirSync(import_node_path23.default.dirname(file), { recursive: true });
17854
17959
  const tmp = `${file}.tmp-${process.pid}-${Date.now()}`;
17855
- const fd = import_node_fs21.default.openSync(tmp, "w", 384);
17960
+ const fd = import_node_fs22.default.openSync(tmp, "w", 384);
17856
17961
  try {
17857
- import_node_fs21.default.writeFileSync(fd, JSON.stringify(store, null, 2));
17858
- import_node_fs21.default.fsyncSync(fd);
17962
+ import_node_fs22.default.writeFileSync(fd, JSON.stringify(store, null, 2));
17963
+ import_node_fs22.default.fsyncSync(fd);
17859
17964
  } finally {
17860
- import_node_fs21.default.closeSync(fd);
17965
+ import_node_fs22.default.closeSync(fd);
17861
17966
  }
17862
- import_node_fs21.default.renameSync(tmp, file);
17967
+ import_node_fs22.default.renameSync(tmp, file);
17863
17968
  }
17864
17969
  function mutateStore(fn) {
17865
17970
  const store = loadStore();
@@ -17868,13 +17973,13 @@ function mutateStore(fn) {
17868
17973
  return store;
17869
17974
  }
17870
17975
  function projectIdForCwd(cwd) {
17871
- return (0, import_node_crypto10.createHash)("sha256").update(import_node_path22.default.resolve(cwd)).digest("hex").slice(0, 16);
17976
+ return (0, import_node_crypto10.createHash)("sha256").update(import_node_path23.default.resolve(cwd)).digest("hex").slice(0, 16);
17872
17977
  }
17873
17978
  function newSessionId() {
17874
17979
  return `s_${(0, import_node_crypto10.randomBytes)(10).toString("hex")}`;
17875
17980
  }
17876
17981
  function upsertProject(input) {
17877
- const cwd = import_node_path22.default.resolve(input.cwd);
17982
+ const cwd = import_node_path23.default.resolve(input.cwd);
17878
17983
  const id = projectIdForCwd(cwd);
17879
17984
  let result;
17880
17985
  mutateStore((store) => {
@@ -17900,7 +18005,7 @@ function upsertProject(input) {
17900
18005
  const now = Date.now();
17901
18006
  const created = {
17902
18007
  id,
17903
- name: input.name ?? import_node_path22.default.basename(cwd),
18008
+ name: input.name ?? import_node_path23.default.basename(cwd),
17904
18009
  cwd,
17905
18010
  repoRoot: input.repoRoot,
17906
18011
  sourceRoots: input.sourceRoots ?? [cwd],
@@ -18046,8 +18151,8 @@ async function seedFromDemoAppRegistry() {
18046
18151
  if (apps.length === 0) return;
18047
18152
  mutateStore((store) => {
18048
18153
  for (const app of apps) {
18049
- if (!import_node_fs21.default.existsSync(app.dir)) continue;
18050
- const cwd = import_node_path22.default.resolve(app.dir);
18154
+ if (!import_node_fs22.default.existsSync(app.dir)) continue;
18155
+ const cwd = import_node_path23.default.resolve(app.dir);
18051
18156
  const id = projectIdForCwd(cwd);
18052
18157
  if (store.attachedProjects.some((p) => p.id === id)) continue;
18053
18158
  const now = Date.now();
@@ -18072,16 +18177,16 @@ async function seedFromDemoAppRegistry() {
18072
18177
  // src/agent-sessions.ts
18073
18178
  init_public_brand();
18074
18179
  function sessionDir(sessionId) {
18075
- return import_node_path23.default.join(getUserDataDir(), "sessions", sessionId);
18180
+ return import_node_path24.default.join(getUserDataDir(), "sessions", sessionId);
18076
18181
  }
18077
18182
  function promptFifoPath(sessionId) {
18078
- return import_node_path23.default.join(sessionDir(sessionId), "prompt.in");
18183
+ return import_node_path24.default.join(sessionDir(sessionId), "prompt.in");
18079
18184
  }
18080
18185
  function eventsFifoPath(sessionId) {
18081
- return import_node_path23.default.join(sessionDir(sessionId), "events.out");
18186
+ return import_node_path24.default.join(sessionDir(sessionId), "events.out");
18082
18187
  }
18083
18188
  function transcriptPath(sessionId) {
18084
- return import_node_path23.default.join(getUserDataDir(), "transcripts", `${sessionId}.log`);
18189
+ return import_node_path24.default.join(getUserDataDir(), "transcripts", `${sessionId}.log`);
18085
18190
  }
18086
18191
  function pidIsAlive(pid, sessionId) {
18087
18192
  if (!pid) return false;
@@ -18091,7 +18196,7 @@ function pidIsAlive(pid, sessionId) {
18091
18196
  return false;
18092
18197
  }
18093
18198
  if (sessionId) {
18094
- if (!import_node_fs22.default.existsSync(sessionDir(sessionId))) return false;
18199
+ if (!import_node_fs23.default.existsSync(sessionDir(sessionId))) return false;
18095
18200
  }
18096
18201
  return true;
18097
18202
  }
@@ -18104,11 +18209,11 @@ function resolveSootsimInvocation() {
18104
18209
  const resourcesPath = process.resourcesPath;
18105
18210
  if (resourcesPath) {
18106
18211
  const candidates = [
18107
- import_node_path23.default.join(resourcesPath, "bin", "sootsim"),
18108
- import_node_path23.default.join(resourcesPath, "bin", `sootsim-${process.platform}-${process.arch}`)
18212
+ import_node_path24.default.join(resourcesPath, "bin", "sootsim"),
18213
+ import_node_path24.default.join(resourcesPath, "bin", `sootsim-${process.platform}-${process.arch}`)
18109
18214
  ];
18110
18215
  for (const c of candidates) {
18111
- if (import_node_fs22.default.existsSync(c)) return { executable: c, prefixArgs: [] };
18216
+ if (import_node_fs23.default.existsSync(c)) return { executable: c, prefixArgs: [] };
18112
18217
  }
18113
18218
  }
18114
18219
  }
@@ -18127,15 +18232,15 @@ function tryWorkspaceSootsim() {
18127
18232
  const sootsimDir = resolveSootsimPackageDir();
18128
18233
  if (!sootsimDir) return null;
18129
18234
  const binaryName = `peach-${process.platform === "win32" ? "windows" : process.platform}-${process.arch}${process.platform === "win32" ? ".exe" : ""}`;
18130
- const distBinary = import_node_path23.default.join(sootsimDir, "dist-bin", binaryName);
18131
- if (import_node_fs22.default.existsSync(distBinary)) return { executable: distBinary, prefixArgs: [] };
18132
- const distBin = import_node_path23.default.join(sootsimDir, "dist-cli", "bin.js");
18133
- if (import_node_fs22.default.existsSync(distBin)) {
18235
+ const distBinary = import_node_path24.default.join(sootsimDir, "dist-bin", binaryName);
18236
+ if (import_node_fs23.default.existsSync(distBinary)) return { executable: distBinary, prefixArgs: [] };
18237
+ const distBin = import_node_path24.default.join(sootsimDir, "dist-cli", "bin.js");
18238
+ if (import_node_fs23.default.existsSync(distBin)) {
18134
18239
  try {
18135
- const src = import_node_path23.default.join(sootsimDir, "cli", "commands", "agent-wrapper.ts");
18136
- if (import_node_fs22.default.existsSync(src)) {
18137
- const srcMtime = import_node_fs22.default.statSync(src).mtimeMs;
18138
- const buildMtime = import_node_fs22.default.statSync(distBin).mtimeMs;
18240
+ const src = import_node_path24.default.join(sootsimDir, "cli", "commands", "agent-wrapper.ts");
18241
+ if (import_node_fs23.default.existsSync(src)) {
18242
+ const srcMtime = import_node_fs23.default.statSync(src).mtimeMs;
18243
+ const buildMtime = import_node_fs23.default.statSync(distBin).mtimeMs;
18139
18244
  if (buildMtime < srcMtime) {
18140
18245
  console.warn(
18141
18246
  `[peach] dist-cli/bin.js is older than agent-wrapper.ts \u2014 rebuild with \`bun run --cwd packages/peachsim build:cli\`.`
@@ -18154,22 +18259,22 @@ function tryWorkspaceSootsim() {
18154
18259
  function resolveSootsimPackageDir() {
18155
18260
  try {
18156
18261
  const resolved = require.resolve(`${rnxPublicBrand.packageName}/package.json`);
18157
- return import_node_path23.default.dirname(resolved);
18262
+ return import_node_path24.default.dirname(resolved);
18158
18263
  } catch {
18159
18264
  }
18160
18265
  const here = fileFromImportMeta();
18161
18266
  if (!here) return null;
18162
- let cur = import_node_path23.default.dirname(here);
18267
+ let cur = import_node_path24.default.dirname(here);
18163
18268
  for (let i = 0; i < 8; i++) {
18164
- const pkg = import_node_path23.default.join(cur, "package.json");
18269
+ const pkg = import_node_path24.default.join(cur, "package.json");
18165
18270
  try {
18166
- if (import_node_fs22.default.existsSync(pkg)) {
18167
- const parsed = JSON.parse(import_node_fs22.default.readFileSync(pkg, "utf8"));
18271
+ if (import_node_fs23.default.existsSync(pkg)) {
18272
+ const parsed = JSON.parse(import_node_fs23.default.readFileSync(pkg, "utf8"));
18168
18273
  if (parsed.name === rnxPublicBrand.packageName) return cur;
18169
18274
  }
18170
18275
  } catch {
18171
18276
  }
18172
- const parent = import_node_path23.default.dirname(cur);
18277
+ const parent = import_node_path24.default.dirname(cur);
18173
18278
  if (parent === cur) break;
18174
18279
  cur = parent;
18175
18280
  }
@@ -18185,28 +18290,28 @@ function fileFromImportMeta() {
18185
18290
  }
18186
18291
  }
18187
18292
  async function withStartLock(projectId, provider, fn) {
18188
- const lockDir = import_node_path23.default.join(getUserDataDir(), "locks");
18189
- import_node_fs22.default.mkdirSync(lockDir, { recursive: true });
18293
+ const lockDir = import_node_path24.default.join(getUserDataDir(), "locks");
18294
+ import_node_fs23.default.mkdirSync(lockDir, { recursive: true });
18190
18295
  try {
18191
- import_node_fs22.default.chmodSync(lockDir, 448);
18296
+ import_node_fs23.default.chmodSync(lockDir, 448);
18192
18297
  } catch {
18193
18298
  }
18194
- const lockPath = import_node_path23.default.join(lockDir, `start-${projectId}-${provider}.lock`);
18299
+ const lockPath = import_node_path24.default.join(lockDir, `start-${projectId}-${provider}.lock`);
18195
18300
  const deadline = Date.now() + 4e3;
18196
18301
  let fd = null;
18197
18302
  while (fd === null) {
18198
18303
  try {
18199
- fd = import_node_fs22.default.openSync(
18304
+ fd = import_node_fs23.default.openSync(
18200
18305
  lockPath,
18201
- import_node_fs22.constants.O_WRONLY | import_node_fs22.constants.O_CREAT | import_node_fs22.constants.O_EXCL,
18306
+ import_node_fs23.constants.O_WRONLY | import_node_fs23.constants.O_CREAT | import_node_fs23.constants.O_EXCL,
18202
18307
  384
18203
18308
  );
18204
18309
  } catch (err) {
18205
18310
  if (err.code !== "EEXIST") throw err;
18206
18311
  try {
18207
- const stale = Number(import_node_fs22.default.readFileSync(lockPath, "utf8").trim());
18312
+ const stale = Number(import_node_fs23.default.readFileSync(lockPath, "utf8").trim());
18208
18313
  if (stale && !isProcessAlive(stale)) {
18209
- import_node_fs22.default.unlinkSync(lockPath);
18314
+ import_node_fs23.default.unlinkSync(lockPath);
18210
18315
  continue;
18211
18316
  }
18212
18317
  } catch {
@@ -18220,15 +18325,15 @@ async function withStartLock(projectId, provider, fn) {
18220
18325
  }
18221
18326
  }
18222
18327
  try {
18223
- import_node_fs22.default.writeFileSync(fd, String(process.pid));
18328
+ import_node_fs23.default.writeFileSync(fd, String(process.pid));
18224
18329
  return await fn();
18225
18330
  } finally {
18226
18331
  try {
18227
- import_node_fs22.default.closeSync(fd);
18332
+ import_node_fs23.default.closeSync(fd);
18228
18333
  } catch {
18229
18334
  }
18230
18335
  try {
18231
- import_node_fs22.default.unlinkSync(lockPath);
18336
+ import_node_fs23.default.unlinkSync(lockPath);
18232
18337
  } catch {
18233
18338
  }
18234
18339
  }
@@ -18242,25 +18347,25 @@ function isProcessAlive(pid) {
18242
18347
  }
18243
18348
  }
18244
18349
  function mkfifoSync(p) {
18245
- const parent = import_node_path23.default.dirname(p);
18246
- import_node_fs22.default.mkdirSync(parent, { recursive: true });
18350
+ const parent = import_node_path24.default.dirname(p);
18351
+ import_node_fs23.default.mkdirSync(parent, { recursive: true });
18247
18352
  try {
18248
- import_node_fs22.default.chmodSync(parent, 448);
18353
+ import_node_fs23.default.chmodSync(parent, 448);
18249
18354
  } catch {
18250
18355
  }
18251
- if (import_node_fs22.default.existsSync(p)) {
18356
+ if (import_node_fs23.default.existsSync(p)) {
18252
18357
  try {
18253
- const stat2 = import_node_fs22.default.statSync(p);
18358
+ const stat2 = import_node_fs23.default.statSync(p);
18254
18359
  if (stat2.isFIFO()) {
18255
18360
  try {
18256
- import_node_fs22.default.chmodSync(p, 384);
18361
+ import_node_fs23.default.chmodSync(p, 384);
18257
18362
  } catch {
18258
18363
  }
18259
18364
  return;
18260
18365
  }
18261
- import_node_fs22.default.unlinkSync(p);
18366
+ import_node_fs23.default.unlinkSync(p);
18262
18367
  } catch {
18263
- import_node_fs22.default.unlinkSync(p);
18368
+ import_node_fs23.default.unlinkSync(p);
18264
18369
  }
18265
18370
  }
18266
18371
  const result = (0, import_node_child_process10.spawnSync)("mkfifo", ["-m", "600", p]);
@@ -18307,10 +18412,10 @@ async function startSession(opts) {
18307
18412
  const transcript = transcriptPath(session.id);
18308
18413
  mkfifoSync(promptIn);
18309
18414
  mkfifoSync(eventsOut);
18310
- const transcriptDir = import_node_path23.default.dirname(transcript);
18311
- import_node_fs22.default.mkdirSync(transcriptDir, { recursive: true });
18415
+ const transcriptDir = import_node_path24.default.dirname(transcript);
18416
+ import_node_fs23.default.mkdirSync(transcriptDir, { recursive: true });
18312
18417
  try {
18313
- import_node_fs22.default.chmodSync(transcriptDir, 448);
18418
+ import_node_fs23.default.chmodSync(transcriptDir, 448);
18314
18419
  } catch {
18315
18420
  }
18316
18421
  const { executable, prefixArgs } = resolveSootsimInvocation();
@@ -18361,7 +18466,7 @@ async function startSession(opts) {
18361
18466
  }
18362
18467
  }
18363
18468
  try {
18364
- import_node_fs22.default.rmSync(sessionDir(session.id), { recursive: true, force: true });
18469
+ import_node_fs23.default.rmSync(sessionDir(session.id), { recursive: true, force: true });
18365
18470
  } catch {
18366
18471
  }
18367
18472
  updateSessionStatus(session.id, { status: "ended" });
@@ -18389,18 +18494,18 @@ async function sendPrompt(sessionId, prompt) {
18389
18494
  );
18390
18495
  }
18391
18496
  const fifo = promptFifoPath(sessionId);
18392
- if (!import_node_fs22.default.existsSync(fifo)) {
18497
+ if (!import_node_fs23.default.existsSync(fifo)) {
18393
18498
  throw new AgentSessionError("NO_FIFO", `prompt FIFO missing: ${fifo}`);
18394
18499
  }
18395
- const fd = import_node_fs22.default.openSync(fifo, import_node_fs22.constants.O_WRONLY);
18500
+ const fd = import_node_fs23.default.openSync(fifo, import_node_fs23.constants.O_WRONLY);
18396
18501
  try {
18397
18502
  const wireText = encodeAgentPromptEnvelope(prompt);
18398
18503
  if (!wireText) {
18399
18504
  throw new AgentSessionError("EMPTY_PROMPT", "prompt text is empty");
18400
18505
  }
18401
- import_node_fs22.default.writeSync(fd, wireText + "\n");
18506
+ import_node_fs23.default.writeSync(fd, wireText + "\n");
18402
18507
  } finally {
18403
- import_node_fs22.default.closeSync(fd);
18508
+ import_node_fs23.default.closeSync(fd);
18404
18509
  }
18405
18510
  updateSessionStatus(sessionId, {
18406
18511
  lastPrompt: prompt.displayText ?? prompt.text,
@@ -18422,7 +18527,7 @@ async function endSession(sessionId) {
18422
18527
  const base = getUserDataDir();
18423
18528
  if (dir.startsWith(base)) {
18424
18529
  try {
18425
- import_node_fs22.default.rmSync(dir, { recursive: true, force: true });
18530
+ import_node_fs23.default.rmSync(dir, { recursive: true, force: true });
18426
18531
  } catch {
18427
18532
  }
18428
18533
  }
@@ -18430,11 +18535,11 @@ async function endSession(sessionId) {
18430
18535
  }
18431
18536
  function subscribeEvents(sessionId, onEvent) {
18432
18537
  const fifo = eventsFifoPath(sessionId);
18433
- if (!import_node_fs22.default.existsSync(fifo)) {
18538
+ if (!import_node_fs23.default.existsSync(fifo)) {
18434
18539
  throw new AgentSessionError("NO_FIFO", `events FIFO missing: ${fifo}`);
18435
18540
  }
18436
- const fd = import_node_fs22.default.openSync(fifo, import_node_fs22.constants.O_RDWR);
18437
- const stream = import_node_fs22.default.createReadStream("", { fd, autoClose: true });
18541
+ const fd = import_node_fs23.default.openSync(fifo, import_node_fs23.constants.O_RDWR);
18542
+ const stream = import_node_fs23.default.createReadStream("", { fd, autoClose: true });
18438
18543
  const rl = import_node_readline.default.createInterface({ input: stream, crlfDelay: Infinity });
18439
18544
  rl.on("line", (line) => {
18440
18545
  const event = parseAgentEventLine(line);
@@ -18445,7 +18550,7 @@ function subscribeEvents(sessionId, onEvent) {
18445
18550
  if (closed) return;
18446
18551
  closed = true;
18447
18552
  try {
18448
- import_node_fs22.default.writeSync(fd, "\n");
18553
+ import_node_fs23.default.writeSync(fd, "\n");
18449
18554
  } catch {
18450
18555
  }
18451
18556
  try {
@@ -18459,7 +18564,7 @@ function subscribeEvents(sessionId, onEvent) {
18459
18564
  };
18460
18565
  }
18461
18566
  async function waitForFirstEvent(fifo, predicate, timeoutMs) {
18462
- const fd = import_node_fs22.default.openSync(fifo, import_node_fs22.constants.O_RDWR | import_node_fs22.constants.O_NONBLOCK);
18567
+ const fd = import_node_fs23.default.openSync(fifo, import_node_fs23.constants.O_RDWR | import_node_fs23.constants.O_NONBLOCK);
18463
18568
  const buf = Buffer.alloc(8192);
18464
18569
  let leftover = "";
18465
18570
  const deadline = Date.now() + timeoutMs;
@@ -18467,7 +18572,7 @@ async function waitForFirstEvent(fifo, predicate, timeoutMs) {
18467
18572
  while (Date.now() < deadline) {
18468
18573
  let n = 0;
18469
18574
  try {
18470
- n = import_node_fs22.default.readSync(fd, buf, 0, buf.length, null);
18575
+ n = import_node_fs23.default.readSync(fd, buf, 0, buf.length, null);
18471
18576
  } catch (err) {
18472
18577
  if (err.code !== "EAGAIN") throw err;
18473
18578
  n = 0;
@@ -18487,7 +18592,7 @@ async function waitForFirstEvent(fifo, predicate, timeoutMs) {
18487
18592
  }
18488
18593
  return null;
18489
18594
  } finally {
18490
- import_node_fs22.default.closeSync(fd);
18595
+ import_node_fs23.default.closeSync(fd);
18491
18596
  }
18492
18597
  }
18493
18598
 
@@ -18741,7 +18846,7 @@ var AgentHost = class {
18741
18846
  );
18742
18847
  const project = upsertProject({
18743
18848
  cwd: match.cwd,
18744
- name: match.projectName ?? import_node_path24.default.basename(match.cwd),
18849
+ name: match.projectName ?? import_node_path25.default.basename(match.cwd),
18745
18850
  preferredProvider: input.provider ?? existing?.preferredProvider,
18746
18851
  sourceRoots: existing?.sourceRoots ?? [match.cwd],
18747
18852
  knownBundleUrls,
@@ -18752,18 +18857,18 @@ var AgentHost = class {
18752
18857
  }
18753
18858
  getTranscript(sessionId) {
18754
18859
  const p = transcriptPath(sessionId);
18755
- if (!import_node_fs23.default.existsSync(p)) {
18860
+ if (!import_node_fs24.default.existsSync(p)) {
18756
18861
  return { error: "transcript not found", code: "NO_TRANSCRIPT" };
18757
18862
  }
18758
- return import_node_fs23.default.readFileSync(p, "utf8");
18863
+ return import_node_fs24.default.readFileSync(p, "utf8");
18759
18864
  }
18760
18865
  getPaths() {
18761
18866
  const dir = getUserDataDir();
18762
18867
  return {
18763
18868
  userDataDir: dir,
18764
- storeFile: import_node_path24.default.join(dir, "attached-projects.json"),
18765
- sessionsDir: import_node_path24.default.join(dir, "sessions"),
18766
- transcriptsDir: import_node_path24.default.join(dir, "transcripts")
18869
+ storeFile: import_node_path25.default.join(dir, "attached-projects.json"),
18870
+ sessionsDir: import_node_path25.default.join(dir, "sessions"),
18871
+ transcriptsDir: import_node_path25.default.join(dir, "transcripts")
18767
18872
  };
18768
18873
  }
18769
18874
  // --- subscription management ---
@@ -19635,8 +19740,8 @@ async function openUrl(url, options = {}) {
19635
19740
  }
19636
19741
 
19637
19742
  // src/host/plane-host.ts
19638
- var import_node_fs25 = __toESM(require("node:fs"), 1);
19639
- var import_node_path26 = __toESM(require("node:path"), 1);
19743
+ var import_node_fs26 = __toESM(require("node:fs"), 1);
19744
+ var import_node_path27 = __toESM(require("node:path"), 1);
19640
19745
 
19641
19746
  // ../peach-box/src/planeProtocol.ts
19642
19747
  var PLANE_FLAG_READ_ONLY = 1;
@@ -19716,8 +19821,8 @@ async function dispatchPlaneCommand(plane, type, msg, mutationOptions) {
19716
19821
 
19717
19822
  // cli/commands/box/checkout-plane.ts
19718
19823
  var import_node_child_process11 = require("node:child_process");
19719
- var import_node_fs24 = __toESM(require("node:fs"), 1);
19720
- var import_node_path25 = __toESM(require("node:path"), 1);
19824
+ var import_node_fs25 = __toESM(require("node:fs"), 1);
19825
+ var import_node_path26 = __toESM(require("node:path"), 1);
19721
19826
  var CheckoutRequiresGitError = class extends Error {
19722
19827
  };
19723
19828
  var BINARY_SNIFF_BYTES = 8192;
@@ -19728,14 +19833,14 @@ function looksBinary(filePath, size) {
19728
19833
  if (size === 0) return false;
19729
19834
  let fd;
19730
19835
  try {
19731
- fd = import_node_fs24.default.openSync(filePath, "r");
19836
+ fd = import_node_fs25.default.openSync(filePath, "r");
19732
19837
  const buffer = Buffer.alloc(Math.min(BINARY_SNIFF_BYTES, size));
19733
- const read = import_node_fs24.default.readSync(fd, buffer, 0, buffer.length, 0);
19838
+ const read = import_node_fs25.default.readSync(fd, buffer, 0, buffer.length, 0);
19734
19839
  return buffer.subarray(0, read).includes(0);
19735
19840
  } catch {
19736
19841
  return false;
19737
19842
  } finally {
19738
- if (fd !== void 0) import_node_fs24.default.closeSync(fd);
19843
+ if (fd !== void 0) import_node_fs25.default.closeSync(fd);
19739
19844
  }
19740
19845
  }
19741
19846
  var CheckoutFilePlane = class {
@@ -19748,7 +19853,7 @@ var CheckoutFilePlane = class {
19748
19853
  listTimeoutMs;
19749
19854
  trackedOnly;
19750
19855
  constructor(root, options = {}) {
19751
- this.root = import_node_path25.default.resolve(root);
19856
+ this.root = import_node_path26.default.resolve(root);
19752
19857
  this.listTimeoutMs = options.listTimeoutMs ?? LIST_FILES_TIMEOUT_MS;
19753
19858
  this.trackedOnly = options.trackedOnly ?? false;
19754
19859
  }
@@ -19810,13 +19915,13 @@ var CheckoutFilePlane = class {
19810
19915
  if (!relative2) continue;
19811
19916
  let stat2;
19812
19917
  try {
19813
- stat2 = import_node_fs24.default.statSync(import_node_path25.default.join(this.root, relative2));
19918
+ stat2 = import_node_fs25.default.statSync(import_node_path26.default.join(this.root, relative2));
19814
19919
  } catch {
19815
19920
  continue;
19816
19921
  }
19817
19922
  if (!stat2.isFile()) continue;
19818
19923
  const seen = this.sniffed.get(relative2);
19819
- const binary2 = seen && seen.size === stat2.size && seen.mtimeMs === stat2.mtimeMs ? seen.binary : looksBinary(import_node_path25.default.join(this.root, relative2), stat2.size);
19924
+ const binary2 = seen && seen.size === stat2.size && seen.mtimeMs === stat2.mtimeMs ? seen.binary : looksBinary(import_node_path26.default.join(this.root, relative2), stat2.size);
19820
19925
  nextSniffed.set(relative2, { size: stat2.size, mtimeMs: stat2.mtimeMs, binary: binary2 });
19821
19926
  next.set(relative2, {
19822
19927
  size: stat2.size,
@@ -19830,22 +19935,22 @@ var CheckoutFilePlane = class {
19830
19935
  this.sniffed = nextSniffed;
19831
19936
  }
19832
19937
  absolute(planePath) {
19833
- const resolved = import_node_path25.default.resolve(this.root, planePath);
19834
- if (resolved !== this.root && !resolved.startsWith(`${this.root}${import_node_path25.default.sep}`)) {
19938
+ const resolved = import_node_path26.default.resolve(this.root, planePath);
19939
+ if (resolved !== this.root && !resolved.startsWith(`${this.root}${import_node_path26.default.sep}`)) {
19835
19940
  throw new Error(`path escapes the project: ${planePath}`);
19836
19941
  }
19837
19942
  return resolved;
19838
19943
  }
19839
19944
  async read(planePath) {
19840
- return import_node_fs24.default.promises.readFile(this.absolute(planePath), "utf8");
19945
+ return import_node_fs25.default.promises.readFile(this.absolute(planePath), "utf8");
19841
19946
  }
19842
19947
  async readBytes(planePath) {
19843
- return import_node_fs24.default.promises.readFile(this.absolute(planePath));
19948
+ return import_node_fs25.default.promises.readFile(this.absolute(planePath));
19844
19949
  }
19845
19950
  async write(planePath, content) {
19846
19951
  const absolute = this.absolute(planePath);
19847
- await import_node_fs24.default.promises.mkdir(import_node_path25.default.dirname(absolute), { recursive: true });
19848
- await import_node_fs24.default.promises.writeFile(absolute, content);
19952
+ await import_node_fs25.default.promises.mkdir(import_node_path26.default.dirname(absolute), { recursive: true });
19953
+ await import_node_fs25.default.promises.writeFile(absolute, content);
19849
19954
  this.entries.set(planePath, {
19850
19955
  size: content.byteLength,
19851
19956
  readOnly: false,
@@ -19854,7 +19959,7 @@ var CheckoutFilePlane = class {
19854
19959
  });
19855
19960
  }
19856
19961
  async delete(planePath) {
19857
- await import_node_fs24.default.promises.rm(this.absolute(planePath), { force: true });
19962
+ await import_node_fs25.default.promises.rm(this.absolute(planePath), { force: true });
19858
19963
  this.entries.delete(planePath);
19859
19964
  }
19860
19965
  };
@@ -19980,14 +20085,14 @@ var PlaneHost = class {
19980
20085
  // root and an opened one cannot disagree about the same directory.
19981
20086
  realRoot(root) {
19982
20087
  if (!root) throw new Error("root is required");
19983
- const resolved = import_node_path26.default.resolve(root);
20088
+ const resolved = import_node_path27.default.resolve(root);
19984
20089
  let real;
19985
20090
  try {
19986
- real = import_node_fs25.default.realpathSync(resolved);
20091
+ real = import_node_fs26.default.realpathSync(resolved);
19987
20092
  } catch {
19988
20093
  throw new Error(`no such directory: ${resolved}`);
19989
20094
  }
19990
- if (!import_node_fs25.default.statSync(real).isDirectory()) throw new Error(`not a directory: ${real}`);
20095
+ if (!import_node_fs26.default.statSync(real).isDirectory()) throw new Error(`not a directory: ${real}`);
19991
20096
  return real;
19992
20097
  }
19993
20098
  respond(ws, id, result) {
@@ -20007,9 +20112,9 @@ var PlaneHost = class {
20007
20112
  };
20008
20113
 
20009
20114
  // src/host/replacement-module-handler.ts
20010
- var import_node_fs26 = require("node:fs");
20115
+ var import_node_fs27 = require("node:fs");
20011
20116
  var import_promises5 = __toESM(require("node:fs/promises"), 1);
20012
- var import_node_path27 = __toESM(require("node:path"), 1);
20117
+ var import_node_path28 = __toESM(require("node:path"), 1);
20013
20118
 
20014
20119
  // ../contrast-bundler/src/replacementModule.ts
20015
20120
  var import_dist = require("sucrase/dist/index.js");
@@ -20337,16 +20442,16 @@ function sendJavaScript(req, res, source) {
20337
20442
  res.end(req.method === "HEAD" ? void 0 : source);
20338
20443
  }
20339
20444
  function resolveReplacementModuleFile(fromFile, specifier) {
20340
- const base = import_node_path27.default.resolve(import_node_path27.default.dirname(fromFile), specifier);
20445
+ const base = import_node_path28.default.resolve(import_node_path28.default.dirname(fromFile), specifier);
20341
20446
  const candidates = [
20342
20447
  ...REPLACEMENT_MODULE_EXTENSIONS.some(
20343
- (ext) => ext === import_node_path27.default.extname(base).toLowerCase()
20448
+ (ext) => ext === import_node_path28.default.extname(base).toLowerCase()
20344
20449
  ) ? [base] : [],
20345
20450
  ...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => base + ext),
20346
- ...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => import_node_path27.default.join(base, `index${ext}`))
20451
+ ...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => import_node_path28.default.join(base, `index${ext}`))
20347
20452
  ];
20348
20453
  const found = candidates.find(
20349
- (candidate) => (0, import_node_fs26.statSync)(candidate, { throwIfNoEntry: false })?.isFile()
20454
+ (candidate) => (0, import_node_fs27.statSync)(candidate, { throwIfNoEntry: false })?.isFile()
20350
20455
  );
20351
20456
  if (!found) {
20352
20457
  throw new Error(
@@ -20401,13 +20506,13 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
20401
20506
  res.end("missing path param");
20402
20507
  return true;
20403
20508
  }
20404
- const extension = import_node_path27.default.extname(targetPath).toLowerCase();
20509
+ const extension = import_node_path28.default.extname(targetPath).toLowerCase();
20405
20510
  if (!REPLACEMENT_MODULE_EXTENSIONS.some((allowed) => allowed === extension)) {
20406
20511
  res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
20407
20512
  res.end(`replacement files must be ${REPLACEMENT_MODULE_EXTENSIONS.join(", ")}`);
20408
20513
  return true;
20409
20514
  }
20410
- if (!import_node_path27.default.isAbsolute(targetPath)) {
20515
+ if (!import_node_path28.default.isAbsolute(targetPath)) {
20411
20516
  res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
20412
20517
  res.end("replacement file path must be absolute");
20413
20518
  return true;
@@ -20415,10 +20520,10 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
20415
20520
  const runtimePackages = new Set(url.searchParams.getAll("runtimePackage"));
20416
20521
  let resolvedProjectRoot;
20417
20522
  if (options.projectRoot) {
20418
- const lexicalProjectRoot = import_node_path27.default.resolve(options.projectRoot);
20523
+ const lexicalProjectRoot = import_node_path28.default.resolve(options.projectRoot);
20419
20524
  resolvedProjectRoot = await import_promises5.default.realpath(options.projectRoot);
20420
- const lexicalTarget = import_node_path27.default.relative(lexicalProjectRoot, targetPath);
20421
- if (lexicalTarget.startsWith("..") || import_node_path27.default.isAbsolute(lexicalTarget)) {
20525
+ const lexicalTarget = import_node_path28.default.relative(lexicalProjectRoot, targetPath);
20526
+ if (lexicalTarget.startsWith("..") || import_node_path28.default.isAbsolute(lexicalTarget)) {
20422
20527
  res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
20423
20528
  res.end("replacement file must be inside the project root");
20424
20529
  return true;
@@ -20434,8 +20539,8 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
20434
20539
  return true;
20435
20540
  }
20436
20541
  if (resolvedProjectRoot) {
20437
- const relativeTarget = import_node_path27.default.relative(resolvedProjectRoot, resolvedTargetPath);
20438
- if (relativeTarget.startsWith("..") || import_node_path27.default.isAbsolute(relativeTarget)) {
20542
+ const relativeTarget = import_node_path28.default.relative(resolvedProjectRoot, resolvedTargetPath);
20543
+ if (relativeTarget.startsWith("..") || import_node_path28.default.isAbsolute(relativeTarget)) {
20439
20544
  res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
20440
20545
  res.end("replacement file must be inside the project root");
20441
20546
  return true;