peachsim 0.1.2591 → 0.1.2592

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 (139) hide show
  1. package/dist-lib/agent-daemon-client.cjs +1 -1
  2. package/dist-lib/agent-events.cjs +1 -1
  3. package/dist-lib/attached-projects.cjs +1 -1
  4. package/dist-lib/auth/shared-session.cjs +1 -1
  5. package/dist-lib/backend-origin.cjs +1 -1
  6. package/dist-lib/beta.cjs +1 -1
  7. package/dist-lib/beta.mjs +2 -2
  8. package/dist-lib/bridge-constants.cjs +1 -1
  9. package/dist-lib/bridge-contract-input.cjs +1 -1
  10. package/dist-lib/bridge-contract-input.mjs +5 -5
  11. package/dist-lib/bridge-contract.cjs +1 -1
  12. package/dist-lib/bridge-contract.mjs +3 -3
  13. package/dist-lib/bundle-channel.cjs +3872 -3531
  14. package/dist-lib/capture-contract.cjs +1 -1
  15. package/dist-lib/capture-contract.mjs +3 -3
  16. package/dist-lib/cloud-contract.cjs +1 -1
  17. package/dist-lib/cloud-contract.mjs +3 -3
  18. package/dist-lib/cloud-test-args.cjs +1 -1
  19. package/dist-lib/cloud-test-args.mjs +2 -2
  20. package/dist-lib/cloud.cjs +1 -1
  21. package/dist-lib/cloud.mjs +7 -7
  22. package/dist-lib/config.cjs +1 -1
  23. package/dist-lib/config.mjs +5 -5
  24. package/dist-lib/detox/index.cjs +2 -2
  25. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  26. package/dist-lib/esm-chunks/{acorn-EMX4WZ72.mjs → acorn-67PU73QE.mjs} +3 -3
  27. package/dist-lib/esm-chunks/{chunk-UYJXLDCG.mjs → chunk-5FTHILIE.mjs} +1 -1
  28. package/dist-lib/esm-chunks/{chunk-JHXDM3YU.mjs → chunk-6DB5FR7S.mjs} +1 -1
  29. package/dist-lib/esm-chunks/{chunk-EGKH2L6J.mjs → chunk-CF3MTPMY.mjs} +1 -1
  30. package/dist-lib/esm-chunks/{chunk-MC6NMYWY.mjs → chunk-D4LYKRRB.mjs} +1 -1
  31. package/dist-lib/esm-chunks/{chunk-QBMFX3J2.mjs → chunk-DFF5XZ5M.mjs} +1 -1
  32. package/dist-lib/esm-chunks/{chunk-Q4NA6PUR.mjs → chunk-EHRSWFTD.mjs} +3 -3
  33. package/dist-lib/esm-chunks/{chunk-4QHHRGO4.mjs → chunk-EITX573K.mjs} +1 -1
  34. package/dist-lib/esm-chunks/{chunk-J676B57D.mjs → chunk-EWHA6X3Z.mjs} +5 -5
  35. package/dist-lib/esm-chunks/{chunk-AKKHSVJ4.mjs → chunk-FYXXFYML.mjs} +1 -1
  36. package/dist-lib/esm-chunks/{chunk-ILWFGZWW.mjs → chunk-GQ3EO2UV.mjs} +107 -6
  37. package/dist-lib/esm-chunks/{chunk-VD27WNCT.mjs → chunk-GY6TE4B4.mjs} +4 -4
  38. package/dist-lib/esm-chunks/{chunk-NX23AMX4.mjs → chunk-KDI5YYQ6.mjs} +1 -1
  39. package/dist-lib/esm-chunks/{chunk-VYZ5DC3M.mjs → chunk-L5T3HBPO.mjs} +792 -514
  40. package/dist-lib/esm-chunks/{chunk-7627LKJK.mjs → chunk-M4QLI2SY.mjs} +1 -1
  41. package/dist-lib/esm-chunks/{chunk-UIVXVMS5.mjs → chunk-PITO2NI2.mjs} +2 -2
  42. package/dist-lib/esm-chunks/{chunk-SOAYP72T.mjs → chunk-QSFWBVUO.mjs} +1 -1
  43. package/dist-lib/esm-chunks/{chunk-TFG4LZ5T.mjs → chunk-R3WTQB5J.mjs} +1 -1
  44. package/dist-lib/esm-chunks/{chunk-ZL5N6ENT.mjs → chunk-RV4ACE6R.mjs} +1 -1
  45. package/dist-lib/esm-chunks/{chunk-YR6DNV76.mjs → chunk-SW4PSSTF.mjs} +1 -1
  46. package/dist-lib/esm-chunks/{chunk-VF5WVB3D.mjs → chunk-TJZPNFVF.mjs} +1 -1
  47. package/dist-lib/esm-chunks/{chunk-VRVXRZI4.mjs → chunk-XSQH4R5E.mjs} +48 -15
  48. package/dist-lib/esm-chunks/{chunk-RKQZGWX2.mjs → chunk-XZ3FX3HW.mjs} +1 -1
  49. package/dist-lib/esm-chunks/{metro-layout-parser-ANKZARNW.mjs → metro-layout-parser-EX65MARK.mjs} +3 -3
  50. package/dist-lib/esm-chunks/{swift-package-prebuilt-4N5CXBOZ.mjs → swift-package-prebuilt-3BPDQVA7.mjs} +10 -10
  51. package/dist-lib/esm-chunks/{swift-sdk-app-module-5IUSRXYA.mjs → swift-sdk-app-module-CRX6E3TR.mjs} +14 -14
  52. package/dist-lib/esm-chunks/{swift-sdk-image-7T2LMQS5.mjs → swift-sdk-image-EJD5TPQH.mjs} +14 -14
  53. package/dist-lib/esm-chunks/{swift-sdk-image-producer-7QJ3BF6E.mjs → swift-sdk-image-producer-QAZOSLTZ.mjs} +4 -4
  54. package/dist-lib/expo-swift-bundle.cjs +3243 -2905
  55. package/dist-lib/expo-swift-metadata.cjs +1 -1
  56. package/dist-lib/expo-swift-metadata.mjs +7 -7
  57. package/dist-lib/home-paths.cjs +1 -1
  58. package/dist-lib/host/bridge-host.cjs +5669 -4904
  59. package/dist-lib/host/fetch-proxy-handler.cjs +310 -298
  60. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  61. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
  62. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  63. package/dist-lib/host/websocket-proxy.cjs +1 -1
  64. package/dist-lib/index.cjs +1 -1
  65. package/dist-lib/kotlin-host.cjs +1 -1
  66. package/dist-lib/menu.cjs +1 -1
  67. package/dist-lib/menu.mjs +3 -3
  68. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  69. package/dist-lib/metro-fingerprint-registry.mjs +3 -3
  70. package/dist-lib/metro-production-bundle.cjs +1 -1
  71. package/dist-lib/metro-production-bundle.mjs +4 -4
  72. package/dist-lib/native-app-identity-project.cjs +238 -223
  73. package/dist-lib/native-app-identity-project.mjs +17 -17
  74. package/dist-lib/native-app-identity.cjs +1 -1
  75. package/dist-lib/native-app-identity.mjs +6 -6
  76. package/dist-lib/native-firebase-metadata.cjs +1 -1
  77. package/dist-lib/native-firebase-metadata.mjs +3 -3
  78. package/dist-lib/pdfium-raster.cjs +1 -1
  79. package/dist-lib/pdfium-raster.mjs +2 -2
  80. package/dist-lib/plist.cjs +1 -1
  81. package/dist-lib/plist.mjs +3 -3
  82. package/dist-lib/profiles.cjs +1 -1
  83. package/dist-lib/public-brand.cjs +1 -1
  84. package/dist-lib/public-origins-lib-esm.json +81 -81
  85. package/dist-lib/public-origins-lib.json +73 -71
  86. package/dist-lib/react-native-host-modules.cjs +1 -1
  87. package/dist-lib/react-native-host-modules.mjs +2 -2
  88. package/dist-lib/reap-browser.cjs +1 -1
  89. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  90. package/dist-lib/sdk.cjs +1 -1
  91. package/dist-lib/sdk.mjs +8 -8
  92. package/dist-lib/skills.cjs +6291 -5526
  93. package/dist-lib/swift-compile.cjs +1051 -696
  94. package/dist-lib/swift-compile.mjs +10 -10
  95. package/dist-lib/swift-package.cjs +1 -1
  96. package/dist-lib/swift-package.mjs +3 -3
  97. package/dist-lib/swift-submit.cjs +1 -1
  98. package/dist-lib/swift-submit.mjs +6 -6
  99. package/dist-lib/swift-svg-raster.cjs +1 -1
  100. package/dist-lib/swift-svg-raster.mjs +2 -2
  101. package/dist-lib/swift-toolchain.cjs +12 -6
  102. package/dist-lib/swift.cjs +1 -1
  103. package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
  104. package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
  105. package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
  106. package/dist-lib/vendor/@xmldom/xmldom.cjs +1 -1
  107. package/dist-lib/vendor/acorn.cjs +1 -1
  108. package/dist-lib/vendor/bplist-parser.cjs +1 -1
  109. package/dist-lib/vendor/ignore.cjs +1 -1
  110. package/dist-lib/vendor/magic-string.cjs +1 -1
  111. package/dist-lib/vendor/plist.cjs +1 -1
  112. package/dist-lib/vendor/smol-toml.cjs +1 -1
  113. package/dist-lib/vendor/stream-json.cjs +1 -1
  114. package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
  115. package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
  116. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
  117. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
  118. package/dist-lib/vendor/sucrase.cjs +1 -1
  119. package/dist-lib/vendor/terser.cjs +1 -1
  120. package/dist-lib/vendor/valibot.cjs +1 -1
  121. package/dist-lib/vendor/ws.cjs +1 -1
  122. package/dist-lib/vendor/zod.cjs +1 -1
  123. package/dist-lib/worklet-executable.cjs +1 -1
  124. package/dist-lib/worklet-executable.mjs +3 -3
  125. package/dist-types/packages/peach-engine/src/engine/native-node-queries.d.ts +1 -0
  126. package/package.json +1 -1
  127. package/runtime-companion.json +1 -1
  128. package/src/native-bundles.ts +2 -0
  129. package/src/one-native-controls-package.ts +141 -31
  130. package/src/one-sdk/source.ts +2 -1
  131. package/src/oneSdkContract.ts +13 -2
  132. package/src/swift-compile.ts +301 -48
  133. package/src/swift-host.ts +88 -16
  134. package/src/swift-reproducible.ts +16 -2
  135. package/src/swift-root-lock.ts +77 -5
  136. package/src/swift-sdk-image.ts +53 -10
  137. package/src/swift-startup-split.ts +65 -27
  138. package/src/swift-toolchain.ts +16 -5
  139. package/src/wasm-lazy-split.ts +46 -40
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2591 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2592 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -2779,7 +2779,8 @@ function swiftToolchainBin(release) {
2779
2779
  const dirs = [import_node_os3.default.homedir(), "/"].map(
2780
2780
  (base) => import_node_path5.default.join(base, `Library/Developer/Toolchains/${release}.xctoolchain/usr/bin`)
2781
2781
  );
2782
- return dirs.find((dir) => import_node_fs7.default.existsSync(import_node_path5.default.join(dir, "swift"))) ?? dirs[0];
2782
+ const found = dirs.find((dir) => import_node_fs7.default.existsSync(import_node_path5.default.join(dir, "swift")));
2783
+ return found ? import_node_fs7.default.realpathSync(found) : dirs[0];
2783
2784
  }
2784
2785
  if (process.env.CONTRAST_SWIFT_TOOLCHAINS) {
2785
2786
  return import_node_path5.default.join(process.env.CONTRAST_SWIFT_TOOLCHAINS, release, "usr/bin");
@@ -2822,17 +2823,57 @@ exec ${JSON.stringify(import_node_path5.default.join(toolchainBin, "wasm-ld"))}
2822
2823
  }
2823
2824
  function peachHome() {
2824
2825
  const override = process.env.PEACH_HOME;
2825
- return override ? import_node_path5.default.resolve(override) : import_node_path5.default.join(import_node_os3.default.homedir(), ".peach");
2826
+ if (override) return import_node_path5.default.resolve(override);
2827
+ const home = import_node_path5.default.join(import_node_os3.default.homedir(), ".peach");
2828
+ return import_node_fs7.default.existsSync(home) ? import_node_fs7.default.realpathSync(home) : home;
2826
2829
  }
2827
2830
  function peachSwiftSdksDir() {
2828
2831
  return process.env.PEACH_SWIFT_SDKS_PATH ?? import_node_path5.default.join(peachHome(), "swift", "sdks");
2829
2832
  }
2833
+ function agentSharedCacheRoot() {
2834
+ if (process.platform !== "darwin" || !process.env.TM_SESSION) return null;
2835
+ if (agentBuildersRoot) return agentBuildersRoot;
2836
+ const policy = JSON.parse(
2837
+ (0, import_node_child_process4.execFileSync)("tm", ["machine", "policy", "--json"], {
2838
+ encoding: "utf8",
2839
+ timeout: 3e4
2840
+ })
2841
+ );
2842
+ const mounts = policy.storage_mounts ?? [];
2843
+ if (!Array.isArray(mounts)) throw new Error("storage_mounts must be a list");
2844
+ const isMount = (directory) => {
2845
+ const lines = (0, import_node_child_process4.execFileSync)("/bin/df", ["-P", directory], {
2846
+ encoding: "utf8",
2847
+ timeout: 3e4
2848
+ }).trim().split("\n");
2849
+ const fields = lines[lines.length - 1].trim().split(/\s+/);
2850
+ const mount = fields.slice(5).join(" ");
2851
+ if (!import_node_path5.default.isAbsolute(mount))
2852
+ throw new Error("filesystem mount identity is unavailable");
2853
+ return import_node_fs7.default.realpathSync(directory) === import_node_fs7.default.realpathSync(mount);
2854
+ };
2855
+ for (const mount of mounts) {
2856
+ if (typeof mount !== "string" || !import_node_path5.default.isAbsolute(mount) || !isMount(mount))
2857
+ throw new Error(`configured storage is not mounted: ${mount}`);
2858
+ }
2859
+ const heavy = policy.heavy_data_dir;
2860
+ if (heavy == null) return agentBuildersRoot = import_node_path5.default.join(import_node_os3.default.homedir(), "builders");
2861
+ if (typeof heavy !== "string" || !import_node_path5.default.isAbsolute(heavy) || !import_node_fs7.default.statSync(heavy).isDirectory())
2862
+ throw new Error(`configured heavy_data_dir is unavailable: ${heavy}`);
2863
+ const mounted = isMount(heavy);
2864
+ if (import_node_path5.default.dirname(heavy) === "/Volumes" && !mounted)
2865
+ throw new Error(`configured storage is not mounted: ${heavy}`);
2866
+ return agentBuildersRoot = mounted && import_node_fs7.default.statSync(heavy).dev === import_node_fs7.default.statSync(import_node_os3.default.homedir()).dev ? import_node_path5.default.join(import_node_os3.default.homedir(), "builders") : import_node_path5.default.join(heavy, "builders");
2867
+ }
2830
2868
  function buildersRootEnv() {
2831
2869
  const root = process.env[BUILDERS_ROOT_ENV]?.trim();
2832
2870
  return root ? root : null;
2833
2871
  }
2872
+ function resolvedBuildersRoot() {
2873
+ return buildersRootEnv() ?? (process.env.PEACH_HOME ? null : agentSharedCacheRoot());
2874
+ }
2834
2875
  function swiftCacheDir() {
2835
- const root = buildersRootEnv();
2876
+ const root = resolvedBuildersRoot();
2836
2877
  return root ? import_node_path5.default.join(root, "peach-cache") : import_node_path5.default.join(peachHome(), "cache");
2837
2878
  }
2838
2879
  function refreshSwiftCacheHold(directory) {
@@ -2843,7 +2884,7 @@ function refreshSwiftCacheHold(directory) {
2843
2884
  const [kind, key] = relative.split(import_node_path5.default.sep);
2844
2885
  if (!key || kind === ".." || import_node_path5.default.isAbsolute(relative)) return;
2845
2886
  const entry = import_node_path5.default.join(cacheRoot, kind, key);
2846
- if (!buildersRootEnv()) {
2887
+ if (!resolvedBuildersRoot()) {
2847
2888
  const now = /* @__PURE__ */ new Date();
2848
2889
  import_node_fs7.default.utimesSync(entry, now, now);
2849
2890
  return;
@@ -3180,7 +3221,7 @@ function swiftCompilerInstall(release) {
3180
3221
  ]
3181
3222
  };
3182
3223
  }
3183
- var import_node_child_process4, import_node_crypto3, import_node_fs7, import_node_os3, import_node_path5, import_promises3, import_node_url, import_node_util, import_node_zlib, compilerArchives, SWIFT_PRIVATE_DISTRIBUTION_ENV, SWIFT_AUTOLINK_LINKER, BUILDERS_ROOT_ENV, SWIFT_CACHE_HOLD_MARKER, SWIFT_CACHE_HOLD_MS, scratch, linuxLibraryPath, linuxHostSdkRoot, listedSdks, sdkBundles, sdkFileHashes, sdkFilesHashed, loadedSdkHashFiles, verifiedCompilers;
3224
+ var import_node_child_process4, import_node_crypto3, import_node_fs7, import_node_os3, import_node_path5, import_promises3, import_node_url, import_node_util, import_node_zlib, compilerArchives, SWIFT_PRIVATE_DISTRIBUTION_ENV, SWIFT_AUTOLINK_LINKER, BUILDERS_ROOT_ENV, agentBuildersRoot, SWIFT_CACHE_HOLD_MARKER, SWIFT_CACHE_HOLD_MS, scratch, linuxLibraryPath, linuxHostSdkRoot, listedSdks, sdkBundles, sdkFileHashes, sdkFilesHashed, loadedSdkHashFiles, verifiedCompilers;
3184
3225
  var init_swift_toolchain = __esm({
3185
3226
  "src/swift-toolchain.ts"() {
3186
3227
  "use strict";
@@ -4702,7 +4743,7 @@ function compileDarwinRecords(args) {
4702
4743
  const runtime = (0, import_node_fs12.mkdtempSync)(import_node_path12.default.join((0, import_node_os4.tmpdir)(), "peach-objc-runtime-"));
4703
4744
  (0, import_node_fs12.symlinkSync)(import_node_path12.default.join(args.darwin, "usr/include/objc"), import_node_path12.default.join(runtime, "objc"));
4704
4745
  const objects = (0, import_node_fs12.readdirSync)(records).filter((file) => file.endsWith(".c") || file.endsWith(".m")).sort((a, b) => a < b ? -1 : a > b ? 1 : 0).map((file) => {
4705
- const object3 = import_node_path12.default.join(
4746
+ const object4 = import_node_path12.default.join(
4706
4747
  args.out,
4707
4748
  `${DARWIN_RECORDS_PREFIX}${file.replace(/\.[cm]$/, ".o")}`
4708
4749
  );
@@ -4733,11 +4774,11 @@ function compileDarwinRecords(args) {
4733
4774
  "-c",
4734
4775
  import_node_path12.default.join(records, file),
4735
4776
  "-o",
4736
- object3
4777
+ object4
4737
4778
  ],
4738
4779
  { stdio: ["ignore", "pipe", "inherit"] }
4739
4780
  );
4740
- return object3;
4781
+ return object4;
4741
4782
  });
4742
4783
  (0, import_node_fs12.rmSync)(runtime, { recursive: true });
4743
4784
  return objects;
@@ -5016,8 +5057,8 @@ function designTimeSites(source) {
5016
5057
  sites.push({ kind: "boolean", start: token.start, end: token.end, value: word });
5017
5058
  } else if (token.kind === "number") {
5018
5059
  const kind = numberKind(word);
5019
- const tuple = source[token.start - 1] === "." && source[token.start - 2] !== ".";
5020
- if (kind && !tuple) {
5060
+ const tuple2 = source[token.start - 1] === "." && source[token.start - 2] !== ".";
5061
+ if (kind && !tuple2) {
5021
5062
  const minus = tokens[t - 1];
5022
5063
  const negative = minus !== void 0 && text(source, minus) === "-" && minus.end === token.start && t - 1 >= from && !/[^\s([{,;:=]/.test(source[minus.start - 1] ?? " ");
5023
5064
  const start = negative ? minus.start : token.start;
@@ -5097,9 +5138,9 @@ function originalColumn(line, column) {
5097
5138
  }
5098
5139
  function designTimeDiagnostic(output, files) {
5099
5140
  const rewritten = /* @__PURE__ */ new Map();
5100
- const linesOf = (path42) => {
5141
+ const linesOf = (path43) => {
5101
5142
  const file = Object.keys(files).find(
5102
- (name3) => name3.endsWith(".swift") && (path42 === name3 || path42.endsWith(`/${name3}`))
5143
+ (name3) => name3.endsWith(".swift") && (path43 === name3 || path43.endsWith(`/${name3}`))
5103
5144
  );
5104
5145
  if (file === void 0) return null;
5105
5146
  let lines = rewritten.get(file);
@@ -5487,8 +5528,8 @@ function invalidateDependents(root, mirror, files) {
5487
5528
  (0, import_node_fs13.rmSync)(import_node_path13.default.join(modules, `${name3}.swiftmodule`), { force: true });
5488
5529
  break;
5489
5530
  }
5490
- const object3 = `${dependencies.slice(0, -".d".length)}.o`;
5491
- (0, import_node_fs13.rmSync)(object3, { force: true });
5531
+ const object4 = `${dependencies.slice(0, -".d".length)}.o`;
5532
+ (0, import_node_fs13.rmSync)(object4, { force: true });
5492
5533
  }
5493
5534
  }
5494
5535
  if (headersChanged)
@@ -5705,30 +5746,30 @@ function guestSourceObjects(graph, buildDirectory, objects, generatedOwners) {
5705
5746
  ]);
5706
5747
  const owned = [];
5707
5748
  const unowned = [];
5708
- for (const object3 of objects) {
5709
- const library = libraryArchiveTarget(object3);
5749
+ for (const object4 of objects) {
5750
+ const library = libraryArchiveTarget(object4);
5710
5751
  if (library !== null && names.has(library)) {
5711
5752
  owned.push({
5712
- path: object3,
5753
+ path: object4,
5713
5754
  kind: "archive",
5714
5755
  sourceTarget: library,
5715
5756
  instrumentDynamicLookups: false
5716
5757
  });
5717
5758
  continue;
5718
5759
  }
5719
- const prebuilt = prebuiltSourceObjectPath(object3);
5720
- const relative = prebuilt ?? import_node_path14.default.relative(buildDirectory, object3);
5760
+ const prebuilt = prebuiltSourceObjectPath(object4);
5761
+ const relative = prebuilt ?? import_node_path14.default.relative(buildDirectory, object4);
5721
5762
  const [directory] = relative.split(import_node_path14.default.sep);
5722
5763
  const generated = directory?.endsWith(".build") ? directory.slice(0, -6) : "";
5723
5764
  const target = owners.get(generated);
5724
- if (target && names.has(target) && object3.endsWith(".o")) {
5765
+ if (target && names.has(target) && object4.endsWith(".o")) {
5725
5766
  owned.push({
5726
- path: object3,
5767
+ path: object4,
5727
5768
  kind: "object",
5728
5769
  sourceTarget: target,
5729
- instrumentDynamicLookups: prebuilt === null || object3.endsWith(".swift.o")
5770
+ instrumentDynamicLookups: prebuilt === null || object4.endsWith(".swift.o")
5730
5771
  });
5731
- } else unowned.push(object3);
5772
+ } else unowned.push(object4);
5732
5773
  }
5733
5774
  return { owned, unowned };
5734
5775
  }
@@ -5924,12 +5965,12 @@ function swiftObjcRootObjects(id, root, objects) {
5924
5965
  const cached2 = rootsByDistribution.get(id);
5925
5966
  if (cached2) return cached2;
5926
5967
  const measured = objects.map(
5927
- (object3) => [object3, objcRootInfo(import_node_fs14.default.readFileSync(import_node_path15.default.join(root, object3)))]
5968
+ (object4) => [object4, objcRootInfo(import_node_fs14.default.readFileSync(import_node_path15.default.join(root, object4)))]
5928
5969
  );
5929
5970
  const roots = new Set(
5930
5971
  measured.filter(
5931
- ([object3, info]) => object3 !== "lib/FoundationNetworking-Session.o" && object3 !== "lib/Metal-MetalExecution.o" && object3 !== "lib/PeachICU-icu.c.o" && object3 !== "lib/SwiftUI-MetalExecution.o" && object3 !== "lib/UIKitCore-NativeStub.o" && (info.registration || info.exported)
5932
- ).map(([object3]) => object3)
5972
+ ([object4, info]) => object4 !== "lib/FoundationNetworking-Session.o" && object4 !== "lib/Metal-MetalExecution.o" && object4 !== "lib/PeachICU-icu.c.o" && object4 !== "lib/SwiftUI-MetalExecution.o" && object4 !== "lib/UIKitCore-NativeStub.o" && (info.registration || info.exported)
5973
+ ).map(([object4]) => object4)
5933
5974
  );
5934
5975
  rootsByDistribution.set(id, roots);
5935
5976
  return roots;
@@ -6133,7 +6174,7 @@ function layout(bytes, readData = true, requireExports = true) {
6133
6174
  pos = next;
6134
6175
  return value;
6135
6176
  };
6136
- const string4 = () => {
6177
+ const string5 = () => {
6137
6178
  const length = read();
6138
6179
  pos += length;
6139
6180
  if (pos > section2[1]) throw new Error("invalid wasm import");
@@ -6147,8 +6188,8 @@ function layout(bytes, readData = true, requireExports = true) {
6147
6188
  };
6148
6189
  const count = read();
6149
6190
  for (let i = 0; i < count; i++) {
6150
- string4();
6151
- string4();
6191
+ string5();
6192
+ string5();
6152
6193
  const kind = bytes[pos++];
6153
6194
  if (kind === 0) {
6154
6195
  imports++;
@@ -8956,9 +8997,9 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
8956
8997
  } else if (!inStartLib && t.endsWith(".a") && !t.endsWith("libclang_rt.builtins-wasm64.a") && import_node_fs16.default.existsSync(t)) {
8957
8998
  const members = readArMembers(new Uint8Array(import_node_fs16.default.readFileSync(t)));
8958
8999
  for (const m of members) {
8959
- const object3 = parseWasmObjectBytes(`${t}(${m.name})`, m.bytes, false);
8960
- extraArchiveObjs.push(object3);
8961
- objectBytes.set(object3, Buffer.from(m.bytes));
9000
+ const object4 = parseWasmObjectBytes(`${t}(${m.name})`, m.bytes, false);
9001
+ extraArchiveObjs.push(object4);
9002
+ objectBytes.set(object4, Buffer.from(m.bytes));
8962
9003
  }
8963
9004
  }
8964
9005
  }
@@ -9013,9 +9054,9 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
9013
9054
  ordinal,
9014
9055
  original: out
9015
9056
  });
9016
- const object3 = parseWasmObjectBytes(`${archive}(${m.name})`, m.bytes, false);
9017
- extraArchiveObjs.push(object3);
9018
- objectBytes.set(object3, Buffer.from(m.bytes));
9057
+ const object4 = parseWasmObjectBytes(`${archive}(${m.name})`, m.bytes, false);
9058
+ extraArchiveObjs.push(object4);
9059
+ objectBytes.set(object4, Buffer.from(m.bytes));
9019
9060
  }
9020
9061
  };
9021
9062
  for (const t of tokens) {
@@ -10643,7 +10684,7 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
10643
10684
  shift += 7;
10644
10685
  }
10645
10686
  };
10646
- const string4 = () => {
10687
+ const string5 = () => {
10647
10688
  const length = number3();
10648
10689
  const strEnd = offset + length;
10649
10690
  if (strEnd > end) throw new Error("invalid wasm string");
@@ -10671,8 +10712,8 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
10671
10712
  const importWriter = rewrite ? new ByteWriter(size + 64) : void 0;
10672
10713
  importWriter?.uleb(count);
10673
10714
  for (let i = 0; i < count; i++) {
10674
- const module2 = string4();
10675
- const name3 = string4();
10715
+ const module2 = string5();
10716
+ const name3 = string5();
10676
10717
  const kind = bytes[offset++];
10677
10718
  const typeStart = offset;
10678
10719
  let functionType = -1;
@@ -10733,7 +10774,7 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
10733
10774
  const count = number3();
10734
10775
  for (let i = 0; i < count; i++) functionTypes.push(number3());
10735
10776
  } else if (id === 0) {
10736
- const sectionName = string4();
10777
+ const sectionName = string5();
10737
10778
  if (sectionName === "linking") {
10738
10779
  const version2 = number3();
10739
10780
  if (version2 !== 2) throw new Error("unsupported wasm linking version");
@@ -10750,7 +10791,7 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
10750
10791
  const count = number3();
10751
10792
  comdatWriter.uleb(count);
10752
10793
  for (let i = 0; i < count; i++) {
10753
- const group = string4();
10794
+ const group = string5();
10754
10795
  const begin = offset;
10755
10796
  number3();
10756
10797
  const members = number3();
@@ -10781,12 +10822,12 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
10781
10822
  index = number3();
10782
10823
  if (!(flags & 16) || flags & 64) {
10783
10824
  nameStart = offset;
10784
- name3 = string4();
10825
+ name3 = string5();
10785
10826
  nameEnd = offset;
10786
10827
  }
10787
10828
  } else if (symbolKind === 1) {
10788
10829
  nameStart = offset;
10789
- name3 = string4();
10830
+ name3 = string5();
10790
10831
  nameEnd = offset;
10791
10832
  if (!(flags & 16)) {
10792
10833
  if ((flags & 3) !== 3) {
@@ -10981,8 +11022,8 @@ function createGuestImageLedger(input) {
10981
11022
  symbolIndices.set(name3, index);
10982
11023
  for (const image of input.images) {
10983
11024
  const productAliases = /* @__PURE__ */ new Map();
10984
- for (const object3 of image.objects) {
10985
- const product = object3.sdkProduct;
11025
+ for (const object4 of image.objects) {
11026
+ const product = object4.sdkProduct;
10986
11027
  const usedAliases = productAliases.get(product) ?? /* @__PURE__ */ new Map();
10987
11028
  productAliases.set(product, usedAliases);
10988
11029
  const aliases = {
@@ -10999,18 +11040,18 @@ function createGuestImageLedger(input) {
10999
11040
  }
11000
11041
  };
11001
11042
  const rewritten = rewriteObject(
11002
- object3.bytes,
11043
+ object4.bytes,
11003
11044
  aliases,
11004
11045
  `__peach_dlsym_caller_${image.id}`,
11005
11046
  void 0,
11006
- object3.instrumentDynamicLookups,
11047
+ object4.instrumentDynamicLookups,
11007
11048
  /* @__PURE__ */ new Set()
11008
11049
  );
11009
11050
  if (rewritten.usesDlsym) callersUsingDlsym.add(image.id);
11010
11051
  for (const name3 of rewritten.addressTaken) addressTaken.add(name3);
11011
11052
  units.push({
11012
11053
  image: image.id,
11013
- object: object3,
11054
+ object: object4,
11014
11055
  aliases,
11015
11056
  usedSymbols: rewritten.usedSymbols,
11016
11057
  functionImports: rewritten.functionImports
@@ -11021,7 +11062,7 @@ function createGuestImageLedger(input) {
11021
11062
  definitions.push({
11022
11063
  name: symbol.name,
11023
11064
  image: image.id,
11024
- object: object3.path,
11065
+ object: object4.path,
11025
11066
  alias: aliases.get(symbol.name),
11026
11067
  kind: symbol.kind,
11027
11068
  weak: symbol.weak,
@@ -11177,13 +11218,13 @@ function createGuestImageLedger(input) {
11177
11218
  }
11178
11219
  const sdkGlobalBindings = /* @__PURE__ */ new Map();
11179
11220
  if (input.sdkWeakReferences) {
11180
- const objects2 = new Map(units.map(({ object: object3 }) => [object3.path, object3]));
11221
+ const objects2 = new Map(units.map(({ object: object4 }) => [object4.path, object4]));
11181
11222
  const digests = /* @__PURE__ */ new Map();
11182
- const digest = ({ object: object3 }) => {
11183
- let value = digests.get(object3);
11223
+ const digest = ({ object: object4 }) => {
11224
+ let value = digests.get(object4);
11184
11225
  if (value === void 0) {
11185
- value = (0, import_node_crypto10.createHash)("sha256").update(objects2.get(object3).bytes).digest("hex");
11186
- digests.set(object3, value);
11226
+ value = (0, import_node_crypto10.createHash)("sha256").update(objects2.get(object4).bytes).digest("hex");
11227
+ digests.set(object4, value);
11187
11228
  }
11188
11229
  return value;
11189
11230
  };
@@ -11198,11 +11239,11 @@ function createGuestImageLedger(input) {
11198
11239
  sdkGlobalBindings.set(name3, first.alias);
11199
11240
  }
11200
11241
  }
11201
- const objects = units.map(({ image, object: object3, aliases, functionImports }) => {
11242
+ const objects = units.map(({ image, object: object4, aliases, functionImports }) => {
11202
11243
  const shared = sharedLookupByImage.get(image);
11203
- const own = startup.get(object3.path);
11244
+ const own = startup.get(object4.path);
11204
11245
  const bindings = new Map(own);
11205
- const weak = input.sdkWeakReferences?.get(object3.path);
11246
+ const weak = input.sdkWeakReferences?.get(object4.path);
11206
11247
  const binding = (name3) => bindings.get(name3) ?? shared(name3) ?? (weak?.has(name3) ? void 0 : sdkGlobalBindings.get(name3));
11207
11248
  for (const [name3, type] of functionImports) {
11208
11249
  const alias = binding(name3);
@@ -11222,17 +11263,17 @@ function createGuestImageLedger(input) {
11222
11263
  bindings.set(name3, wrapper.symbol);
11223
11264
  }
11224
11265
  return {
11225
- path: object3.path,
11226
- instrumentDynamicLookups: object3.instrumentDynamicLookups,
11227
- sdkProduct: object3.sdkProduct,
11266
+ path: object4.path,
11267
+ instrumentDynamicLookups: object4.instrumentDynamicLookups,
11268
+ sdkProduct: object4.sdkProduct,
11228
11269
  bytes: rewriteObject(
11229
- object3.bytes,
11270
+ object4.bytes,
11230
11271
  aliases,
11231
11272
  `__peach_dlsym_caller_${image}`,
11232
11273
  binding,
11233
- object3.instrumentDynamicLookups,
11274
+ object4.instrumentDynamicLookups,
11234
11275
  preserveCanonical,
11235
- { sdkProduct: object3.sdkProduct }
11276
+ { sdkProduct: object4.sdkProduct }
11236
11277
  ).bytes
11237
11278
  };
11238
11279
  });
@@ -12299,8 +12340,8 @@ function guestProjectionRegionCapacity(objects, generatedRanges) {
12299
12340
  if (!Number.isInteger(generatedRanges) || generatedRanges < 0)
12300
12341
  throw new Error("invalid generated guest range capacity");
12301
12342
  let capacity = generatedRanges;
12302
- for (const object3 of objects) {
12303
- if (Buffer.from(object3.subarray(0, 8)).toString("hex") !== "0061736d01000000")
12343
+ for (const object4 of objects) {
12344
+ if (Buffer.from(object4.subarray(0, 8)).toString("hex") !== "0061736d01000000")
12304
12345
  throw new Error("expected selected wasm object");
12305
12346
  let offset = 8;
12306
12347
  const number3 = (limit) => {
@@ -12308,17 +12349,17 @@ function guestProjectionRegionCapacity(objects, generatedRanges) {
12308
12349
  let shift = 0;
12309
12350
  for (; ; ) {
12310
12351
  if (offset >= limit || shift > 28) throw new Error("invalid wasm object integer");
12311
- const byte = object3[offset++];
12352
+ const byte = object4[offset++];
12312
12353
  value += (byte & 127) * 2 ** shift;
12313
12354
  if (!(byte & 128)) return value;
12314
12355
  shift += 7;
12315
12356
  }
12316
12357
  };
12317
- while (offset < object3.length) {
12318
- const section2 = object3[offset++];
12319
- const size = number3(object3.length);
12358
+ while (offset < object4.length) {
12359
+ const section2 = object4[offset++];
12360
+ const size = number3(object4.length);
12320
12361
  const end = offset + size;
12321
- if (end > object3.length) throw new Error("invalid wasm object section");
12362
+ if (end > object4.length) throw new Error("invalid wasm object section");
12322
12363
  if (section2 === 3 || section2 === 11) capacity += number3(end);
12323
12364
  offset = end;
12324
12365
  }
@@ -12674,14 +12715,14 @@ function guestRuntimeInputIdentities(options) {
12674
12715
  throw new Error(`ambiguous runtime input identity ${file}`);
12675
12716
  identities.set(file, identity);
12676
12717
  };
12677
- for (const object3 of options.framework.objects)
12718
+ for (const object4 of options.framework.objects)
12678
12719
  add(
12679
- import_node_path19.default.resolve(distributionRoot, object3.path),
12720
+ import_node_path19.default.resolve(distributionRoot, object4.path),
12680
12721
  JSON.stringify([
12681
12722
  "framework",
12682
12723
  options.framework.packageName,
12683
- object3.target,
12684
- object3.path
12724
+ object4.target,
12725
+ object4.path
12685
12726
  ])
12686
12727
  );
12687
12728
  for (const { product, root } of options.products) {
@@ -12711,8 +12752,8 @@ function guestFrameworkLinkArtifacts(product, root, inputs, rewritten, image) {
12711
12752
  const linked = new Set(inputs.map((input) => import_node_path19.default.resolve(input)));
12712
12753
  const seen = /* @__PURE__ */ new Set();
12713
12754
  const result = [];
12714
- for (const object3 of product.objects) {
12715
- const original = import_node_path19.default.resolve(root, object3.path);
12755
+ for (const object4 of product.objects) {
12756
+ const original = import_node_path19.default.resolve(root, object4.path);
12716
12757
  if (seen.has(original)) throw new Error(`duplicate framework object ${original}`);
12717
12758
  seen.add(original);
12718
12759
  if (!linked.has(import_node_path19.default.resolve(rewritten.get(original) ?? original))) continue;
@@ -12800,7 +12841,7 @@ function guestRuntimeProductsForInputs(options) {
12800
12841
  const frameworkId = options.framework ? frameworkRuntimeProductId(options.framework.product) : null;
12801
12842
  const frameworkObjects = new Set(
12802
12843
  options.framework?.product.objects.map(
12803
- (object3) => import_node_path19.default.resolve(options.framework.root, object3.path)
12844
+ (object4) => import_node_path19.default.resolve(options.framework.root, object4.path)
12804
12845
  ) ?? []
12805
12846
  );
12806
12847
  const linkedArchives = /* @__PURE__ */ new Set();
@@ -14200,19 +14241,19 @@ function linkGuestImages(options) {
14200
14241
  for (const [index, artifact] of plan.artifacts.entries()) {
14201
14242
  const prefix = `${artifact.path}(`;
14202
14243
  if (artifact.kind === "object") {
14203
- const object3 = ledgerObjects.get(artifact.path);
14204
- if (!object3) continue;
14244
+ const object4 = ledgerObjects.get(artifact.path);
14245
+ if (!object4) continue;
14205
14246
  const output2 = import_node_path24.default.join(directory, `object-${index}.o`);
14206
- import_node_fs24.default.writeFileSync(output2, object3.bytes);
14247
+ import_node_fs24.default.writeFileSync(output2, object4.bytes);
14207
14248
  replacements.set(artifact.path, output2);
14208
14249
  linkedOwners.set(output2, selectedGuestInputImage(artifact, null));
14209
14250
  const image = selectedGuestInputImage(artifact, null);
14210
- if (object3.sdkProduct === void 0) appObjects.set(output2, image);
14251
+ if (object4.sdkProduct === void 0) appObjects.set(output2, image);
14211
14252
  else
14212
14253
  sdkObjects.set(output2, {
14213
14254
  image,
14214
- product: object3.sdkProduct,
14215
- identity: sdkIdentities.get(object3.path)
14255
+ product: object4.sdkProduct,
14256
+ identity: sdkIdentities.get(object4.path)
14216
14257
  });
14217
14258
  continue;
14218
14259
  }
@@ -14251,7 +14292,7 @@ function linkGuestImages(options) {
14251
14292
  }
14252
14293
  const compileLedger = (name3, source) => {
14253
14294
  const irPath = import_node_path24.default.join(directory, `${name3}.ll`);
14254
- const object3 = import_node_path24.default.join(directory, `${name3}.o`);
14295
+ const object4 = import_node_path24.default.join(directory, `${name3}.o`);
14255
14296
  import_node_fs24.default.writeFileSync(irPath, source);
14256
14297
  (0, import_node_child_process14.execFileSync)(
14257
14298
  clang,
@@ -14261,11 +14302,11 @@ function linkGuestImages(options) {
14261
14302
  "-c",
14262
14303
  irPath,
14263
14304
  "-o",
14264
- object3
14305
+ object4
14265
14306
  ],
14266
14307
  { stdio: "pipe" }
14267
14308
  );
14268
- return object3;
14309
+ return object4;
14269
14310
  };
14270
14311
  const ledgerObject = compileLedger("ledger", ledger.llvmIR);
14271
14312
  const lazyExports = import_node_path24.default.join(directory, "lazy-exports.rsp");
@@ -14767,14 +14808,14 @@ function verifyGuestSymbolScopes(options) {
14767
14808
  };
14768
14809
  records.set(symbol, record);
14769
14810
  }
14770
- const object3 = line.slice(0, sep);
14771
- if (object3 === "<internal>") {
14811
+ const object4 = line.slice(0, sep);
14812
+ if (object4 === "<internal>") {
14772
14813
  if (!isRef) record.physicalModule = true;
14773
14814
  } else {
14774
- const image = options.owners.get(object3);
14815
+ const image = options.owners.get(object4);
14775
14816
  if (image === void 0)
14776
- throw new Error(`traced guest object has no owner ${object3}`);
14777
- (isRef ? record.references : record.providers).set(object3, image);
14817
+ throw new Error(`traced guest object has no owner ${object4}`);
14818
+ (isRef ? record.references : record.providers).set(object4, image);
14778
14819
  }
14779
14820
  }
14780
14821
  const callers = new Map(options.callers.map((caller) => [caller.image, caller.next]));
@@ -14791,13 +14832,13 @@ function verifyGuestSymbolScopes(options) {
14791
14832
  const startupReferences = [];
14792
14833
  const otherReferences = [];
14793
14834
  let allWeakRefs = true;
14794
- for (const [object3, caller] of record.references) {
14795
- const isWeakRef = options.weakReferences.get(object3)?.has(symbol) === true;
14835
+ for (const [object4, caller] of record.references) {
14836
+ const isWeakRef = options.weakReferences.get(object4)?.has(symbol) === true;
14796
14837
  if (!isWeakRef) allWeakRefs = false;
14797
- if (isWeakRef && options.startupObjects.has(object3)) {
14798
- startupReferences.push([object3, caller]);
14838
+ if (isWeakRef && options.startupObjects.has(object4)) {
14839
+ startupReferences.push([object4, caller]);
14799
14840
  } else {
14800
- otherReferences.push([object3, caller]);
14841
+ otherReferences.push([object4, caller]);
14801
14842
  }
14802
14843
  }
14803
14844
  for (const [, caller] of startupReferences)
@@ -14810,8 +14851,8 @@ function verifyGuestSymbolScopes(options) {
14810
14851
  throw new Error(`ambiguous startup provider ${symbol}`);
14811
14852
  let unproven = candidateSize !== record.providers.size;
14812
14853
  if (!unproven && candidates2) {
14813
- for (const object3 of record.providers.keys()) {
14814
- if (!candidates2.has(object3)) {
14854
+ for (const object4 of record.providers.keys()) {
14855
+ if (!candidates2.has(object4)) {
14815
14856
  unproven = true;
14816
14857
  break;
14817
14858
  }
@@ -14822,8 +14863,8 @@ function verifyGuestSymbolScopes(options) {
14822
14863
  const [providerObject, providerImage] = record.providers.entries().next().value;
14823
14864
  if (options.weakDefinitions.get(providerObject)?.has(symbol))
14824
14865
  throw new Error(`weak startup provider ${symbol}`);
14825
- for (const [object3] of startupReferences)
14826
- directBindings.push({ object: object3, symbol, providerObject, providerImage });
14866
+ for (const [object4] of startupReferences)
14867
+ directBindings.push({ object: object4, symbol, providerObject, providerImage });
14827
14868
  }
14828
14869
  if (!otherReferences.length) continue;
14829
14870
  }
@@ -14834,11 +14875,11 @@ function verifyGuestSymbolScopes(options) {
14834
14875
  const strongImages = /* @__PURE__ */ new Set();
14835
14876
  let weakDefinerImages;
14836
14877
  if (candidates) {
14837
- for (const object3 of candidates) {
14838
- const image = options.owners.get(object3);
14878
+ for (const object4 of candidates) {
14879
+ const image = options.owners.get(object4);
14839
14880
  if (image === void 0) continue;
14840
14881
  copyImages.add(image);
14841
- if (options.weakDefinitions.get(object3)?.has(symbol)) {
14882
+ if (options.weakDefinitions.get(object4)?.has(symbol)) {
14842
14883
  ;
14843
14884
  (weakDefinerImages ??= /* @__PURE__ */ new Set()).add(image);
14844
14885
  } else {
@@ -14855,7 +14896,7 @@ function verifyGuestSymbolScopes(options) {
14855
14896
  const firstProviderImage = providerImages.values().next().value;
14856
14897
  const uniqueProvider = strongImages.size > 1 ? void 0 : strongImages.values().next().value ?? firstProviderImage;
14857
14898
  let interposedByCaller;
14858
- for (const [object3, caller] of scopedReferences) {
14899
+ for (const [object4, caller] of scopedReferences) {
14859
14900
  const scope = callers.get(caller);
14860
14901
  if (!scope) throw new Error(`guest image has no caller scope ${caller}`);
14861
14902
  if (record.physicalModule) {
@@ -14885,7 +14926,7 @@ function verifyGuestSymbolScopes(options) {
14885
14926
  provider = firstProviderImage;
14886
14927
  }
14887
14928
  if (provider === void 0) {
14888
- if (options.weakReferences.get(object3)?.has(symbol)) continue;
14929
+ if (options.weakReferences.get(object4)?.has(symbol)) continue;
14889
14930
  throw new Error(`guest scope ${caller} omits every provider of ${symbol}`);
14890
14931
  }
14891
14932
  if (caller === provider) continue;
@@ -14896,7 +14937,7 @@ function verifyGuestSymbolScopes(options) {
14896
14937
  (definer) => !options.weakDefinitions.get(definer)?.has(symbol)
14897
14938
  );
14898
14939
  const providers = strongTraced.length === 1 ? strongTraced : traced;
14899
- if (options.weakReferences.get(object3)?.has(symbol) && !providers.some((provider2) => options.systemProviders.has(provider2)))
14940
+ if (options.weakReferences.get(object4)?.has(symbol) && !providers.some((provider2) => options.systemProviders.has(provider2)))
14900
14941
  continue;
14901
14942
  const candidateSet = candidates ?? /* @__PURE__ */ new Set();
14902
14943
  const equivalentCopies = providers.length === 1 && candidateSet.has(providers[0]) && [...candidateSet].every(
@@ -14908,12 +14949,12 @@ function verifyGuestSymbolScopes(options) {
14908
14949
  const soleCandidate = candidateSet.size === 1 || strongCandidates.length === 1 && strongCandidates[0] === providers[0];
14909
14950
  if (!equivalentCopies && (!soleCandidate || providers.length !== 1 || !candidateSet.has(providers[0]) || !(options.systemProviders.has(providers[0]) || // a strong undefined reference binds through the process global
14910
14951
  // scope, the root image and its dependency closure, as in elf.
14911
- provider === 0 || rootScope?.has(provider) || !options.weakReferences.get(object3)?.has(symbol) && options.frameworkProviders.get(object3)?.has(providers[0]))))
14952
+ provider === 0 || rootScope?.has(provider) || !options.weakReferences.get(object4)?.has(symbol) && options.frameworkProviders.get(object4)?.has(providers[0]))))
14912
14953
  throw new Error(
14913
14954
  `guest scope ${caller} omits traced provider ${provider} for ${symbol}`
14914
14955
  );
14915
14956
  directBindings.push({
14916
- object: object3,
14957
+ object: object4,
14917
14958
  symbol,
14918
14959
  providerObject: providers[0],
14919
14960
  providerImage: provider
@@ -14947,8 +14988,8 @@ function linkPrunedGuestImages(options) {
14947
14988
  const selectedObjects = prepared && new Set(
14948
14989
  prepared.selected.filter((item) => item.member === null).map((item) => import_node_path24.default.resolve(item.artifact))
14949
14990
  );
14950
- const selectedFramework = framework && (!prepared || framework.product.objects.some((object3) => {
14951
- const original = import_node_path24.default.resolve(framework.root, object3.path);
14991
+ const selectedFramework = framework && (!prepared || framework.product.objects.some((object4) => {
14992
+ const original = import_node_path24.default.resolve(framework.root, object4.path);
14952
14993
  const linked = import_node_path24.default.resolve(rewritten.get(original) ?? original);
14953
14994
  return selectedObjects?.has(linked) ?? false;
14954
14995
  }));
@@ -15386,25 +15427,25 @@ function sourceGuestInputIdentities(graph, buildDirectory, objects) {
15386
15427
  producers.has(target.sourceTarget) ? null : target.id
15387
15428
  );
15388
15429
  const identities = /* @__PURE__ */ new Map();
15389
- for (const object3 of objects) {
15390
- const target = producers.get(object3.sourceTarget);
15430
+ for (const object4 of objects) {
15431
+ const target = producers.get(object4.sourceTarget);
15391
15432
  if (target === null || target === void 0)
15392
- throw new Error(`ambiguous source producer ${object3.sourceTarget}`);
15393
- if (object3.kind === "archive") {
15433
+ throw new Error(`ambiguous source producer ${object4.sourceTarget}`);
15434
+ if (object4.kind === "archive") {
15394
15435
  identities.set(
15395
- object3.path,
15436
+ object4.path,
15396
15437
  JSON.stringify([
15397
15438
  "source",
15398
15439
  target,
15399
- `libraries/lib${libraryArchiveTarget(object3.path)}.a`
15440
+ `libraries/lib${libraryArchiveTarget(object4.path)}.a`
15400
15441
  ])
15401
15442
  );
15402
15443
  continue;
15403
15444
  }
15404
- const relative = (prebuiltSourceObjectPath(object3.path) ?? import_node_path25.default.relative(buildDirectory, object3.path)).split(import_node_path25.default.sep);
15445
+ const relative = (prebuiltSourceObjectPath(object4.path) ?? import_node_path25.default.relative(buildDirectory, object4.path)).split(import_node_path25.default.sep);
15405
15446
  if (!relative[0]?.endsWith(".build") || relative.length < 2)
15406
- throw new Error(`source object is outside its producer ${object3.path}`);
15407
- identities.set(object3.path, JSON.stringify(["source", target, relative.join("/")]));
15447
+ throw new Error(`source object is outside its producer ${object4.path}`);
15448
+ identities.set(object4.path, JSON.stringify(["source", target, relative.join("/")]));
15408
15449
  }
15409
15450
  return identities;
15410
15451
  }
@@ -15458,7 +15499,7 @@ function sourceGuestRuntimeLinks(options) {
15458
15499
  if (targets.size !== options.framework.product.targets.length)
15459
15500
  throw new Error("ambiguous packaged framework target");
15460
15501
  const objectTargets = new Set(
15461
- options.framework.product.objects.map((object3) => object3.target)
15502
+ options.framework.product.objects.map((object4) => object4.target)
15462
15503
  );
15463
15504
  const closure = (names) => {
15464
15505
  const linked = /* @__PURE__ */ new Set();
@@ -15511,7 +15552,7 @@ function sourceGuestRuntimeLinks(options) {
15511
15552
  { object: null, flags: autolink, autoLinked: true },
15512
15553
  ...image.clangLinkOptions.map((options2) => ({ ...options2, autoLinked: true }))
15513
15554
  ];
15514
- for (const { object: object3, flags, autoLinked } of optionGroups) {
15555
+ for (const { object: object4, flags, autoLinked } of optionGroups) {
15515
15556
  for (let index = 0; index < flags.length; index++) {
15516
15557
  const flag = flags[index];
15517
15558
  const artifact = artifacts.get(flag);
@@ -15533,7 +15574,7 @@ function sourceGuestRuntimeLinks(options) {
15533
15574
  throw new Error(
15534
15575
  `source image ${image.id} has unresolved framework linkage ${name4}`
15535
15576
  );
15536
- requests.push({ object: object3, provider });
15577
+ requests.push({ object: object4, provider });
15537
15578
  continue;
15538
15579
  }
15539
15580
  if (flag.startsWith("-weak") || flag.startsWith("-reexport") || flag.startsWith("-upward") || flag.startsWith("-lazy") || flag.startsWith("-Wl,"))
@@ -15725,8 +15766,8 @@ function swiftSdkGuestLookups(moduleRoot, sdkRoot, objects) {
15725
15766
  const catalogs = readGuestRuntimeCatalogs(sdkRoot, moduleRoot);
15726
15767
  const framework = frameworkRuntimeProductId(catalogs.framework.product);
15727
15768
  const productByObject = new Map(
15728
- catalogs.framework.product.objects.map((object3) => [
15729
- import_node_path27.default.join(catalogs.framework.root, object3.path),
15769
+ catalogs.framework.product.objects.map((object4) => [
15770
+ import_node_path27.default.join(catalogs.framework.root, object4.path),
15730
15771
  framework
15731
15772
  ])
15732
15773
  );
@@ -15817,8 +15858,8 @@ function swiftSdkGuestLookups(moduleRoot, sdkRoot, objects) {
15817
15858
  ]);
15818
15859
  const images = productImages.map((image) => ({
15819
15860
  ...image,
15820
- objects: (groups.get(byImage.get(image.id)) ?? []).map((object3) => ({
15821
- ...object3,
15861
+ objects: (groups.get(byImage.get(image.id)) ?? []).map((object4) => ({
15862
+ ...object4,
15822
15863
  sdkProduct: byImage.get(image.id)
15823
15864
  }))
15824
15865
  }));
@@ -15826,13 +15867,13 @@ function swiftSdkGuestLookups(moduleRoot, sdkRoot, objects) {
15826
15867
  const shared = /* @__PURE__ */ new Set();
15827
15868
  const sdkWeakReferences = /* @__PURE__ */ new Map();
15828
15869
  for (const objects2 of groups.values())
15829
- for (const { path: path42, bytes } of objects2) {
15870
+ for (const { path: path43, bytes } of objects2) {
15830
15871
  const defined = guestWasmSymbols(bytes);
15831
15872
  for (const name3 of defined.defined) symbols.add(name3);
15832
15873
  for (const name3 of defined.tags) shared.add(name3);
15833
15874
  for (const name3 of defined.globals) shared.add(name3);
15834
15875
  if (defined.weakUndefined.length)
15835
- sdkWeakReferences.set(path42, new Set(defined.weakUndefined));
15876
+ sdkWeakReferences.set(path43, new Set(defined.weakUndefined));
15836
15877
  }
15837
15878
  return createGuestImageLedger({
15838
15879
  images,
@@ -16238,12 +16279,68 @@ function rootLockKey(root) {
16238
16279
  function swiftRootLocksDir() {
16239
16280
  return import_node_path33.default.join((0, import_node_os8.homedir)(), ".peach", "cache", "swift-root-locks");
16240
16281
  }
16241
- async function withSwiftRootLock(root, work, signal, wait = true) {
16282
+ function lockDirectoryFor(root) {
16242
16283
  const directory = import_node_path33.default.join(
16243
16284
  swiftRootLocksDir(),
16244
16285
  (0, import_node_crypto21.createHash)("sha256").update(rootLockKey(root)).digest("hex").slice(0, 32)
16245
16286
  );
16246
16287
  (0, import_node_fs33.mkdirSync)(directory, { recursive: true });
16288
+ return directory;
16289
+ }
16290
+ function acquireSwiftRootReadHold(root) {
16291
+ const directory = lockDirectoryFor(root);
16292
+ const token = (0, import_node_crypto21.randomUUID)();
16293
+ const pending = import_node_path33.default.join(directory, `pending.reader.${token}`);
16294
+ const reader = import_node_path33.default.join(directory, `reader.${token}`);
16295
+ (0, import_node_fs33.writeFileSync)(pending, JSON.stringify(ownIdentity(process.pid)));
16296
+ try {
16297
+ (0, import_node_fs33.linkSync)(pending, reader);
16298
+ } finally {
16299
+ (0, import_node_fs33.rmSync)(pending, { force: true });
16300
+ }
16301
+ let released = false;
16302
+ return {
16303
+ release() {
16304
+ if (released) return;
16305
+ released = true;
16306
+ (0, import_node_fs33.rmSync)(reader, { force: true });
16307
+ }
16308
+ };
16309
+ }
16310
+ async function hasLiveSwiftRootReaders(root, signal) {
16311
+ const directory = lockDirectoryFor(root);
16312
+ const entries2 = (0, import_node_fs33.readdirSync)(directory).filter((entry) => entry.startsWith("reader."));
16313
+ if (entries2.length === 0) return false;
16314
+ for (const entry of entries2) {
16315
+ const file = import_node_path33.default.join(directory, entry);
16316
+ let text2;
16317
+ try {
16318
+ text2 = (0, import_node_fs33.readFileSync)(file, "utf8");
16319
+ } catch (error) {
16320
+ if (errorCode(error) === "ENOENT") continue;
16321
+ throw error;
16322
+ }
16323
+ const identity = parseIdentity(text2);
16324
+ const rows = await processTableWithRetry(identity.pid, signal);
16325
+ if (rows.some((row) => !row.zombie && sameProcess(row, identity))) return true;
16326
+ (0, import_node_fs33.rmSync)(file, { force: true });
16327
+ }
16328
+ return false;
16329
+ }
16330
+ async function waitForNoSwiftRootReaders(root, signal) {
16331
+ let announced = false;
16332
+ while (await hasLiveSwiftRootReaders(root, signal)) {
16333
+ signal?.throwIfAborted();
16334
+ if (!announced) {
16335
+ announced = true;
16336
+ process.stderr.write(`[swift-root-lock] waiting for readers of ${root}
16337
+ `);
16338
+ }
16339
+ await pause(POLL_MS, signal);
16340
+ }
16341
+ }
16342
+ async function withSwiftRootLock(root, work, signal, wait = true) {
16343
+ const directory = lockDirectoryFor(root);
16247
16344
  const token = (0, import_node_crypto21.randomUUID)();
16248
16345
  const ownRow = (await processTableWithRetry(process.pid, signal)).find(
16249
16346
  (candidate) => candidate.pid === process.pid && !candidate.zombie
@@ -16716,18 +16813,36 @@ function swiftSdkImageEntry(key, scopedLookups) {
16716
16813
  key: nativeEntryKey(inputs)
16717
16814
  };
16718
16815
  }
16816
+ function setBoundedCache(cache, key, value) {
16817
+ cache.delete(key);
16818
+ cache.set(key, value);
16819
+ while (cache.size > MAX_CACHED_SDK_IMAGES) {
16820
+ const oldest = cache.keys().next().value;
16821
+ if (oldest !== void 0) cache.delete(oldest);
16822
+ }
16823
+ return value;
16824
+ }
16719
16825
  function cached(directory, key) {
16720
- const sdkInterface = import_node_path35.default.join(directory, INTERFACE_FILE);
16826
+ const sdkInterfacePath = import_node_path35.default.join(directory, INTERFACE_FILE);
16721
16827
  const image = import_node_path35.default.join(directory, IMAGE_FILE);
16722
16828
  const address = import_node_path35.default.join(directory, IMAGE_DIGEST);
16723
- if (!(0, import_node_fs35.existsSync)(image) || !(0, import_node_fs35.existsSync)(address) || !(0, import_node_fs35.existsSync)(sdkInterface) || !(0, import_node_fs35.existsSync)(import_node_path35.default.join(directory, MANIFEST_FILE)) || !(0, import_node_fs35.existsSync)(import_node_path35.default.join(directory, MANIFEST_DATA_FILE)))
16829
+ if (!(0, import_node_fs35.existsSync)(image) || !(0, import_node_fs35.existsSync)(address) || !(0, import_node_fs35.existsSync)(sdkInterfacePath) || !(0, import_node_fs35.existsSync)(import_node_path35.default.join(directory, MANIFEST_FILE)) || !(0, import_node_fs35.existsSync)(import_node_path35.default.join(directory, MANIFEST_DATA_FILE)))
16724
16830
  return void 0;
16831
+ const sha2562 = (0, import_node_fs35.readFileSync)(address, "utf8");
16832
+ const cacheKey = `${directory}\0${sha2562}`;
16833
+ let loadedInterface;
16725
16834
  return {
16726
16835
  key,
16727
16836
  directory,
16728
16837
  image,
16729
- sha256: (0, import_node_fs35.readFileSync)(address, "utf8"),
16730
- sdkInterface: JSON.parse((0, import_node_fs35.readFileSync)(sdkInterface, "utf8"))
16838
+ sha256: sha2562,
16839
+ get sdkInterface() {
16840
+ if (loadedInterface) return loadedInterface;
16841
+ const memo2 = cachedSdkInterfaces.get(cacheKey);
16842
+ if (memo2) return loadedInterface = memo2;
16843
+ const parsed = JSON.parse((0, import_node_fs35.readFileSync)(sdkInterfacePath, "utf8"));
16844
+ return loadedInterface = setBoundedCache(cachedSdkInterfaces, cacheKey, parsed);
16845
+ }
16731
16846
  };
16732
16847
  }
16733
16848
  async function buildSwiftSdkImage(moduleRoot, scopedLookups = false, frameworkImports = [], options) {
@@ -16821,7 +16936,7 @@ async function linkSwiftSdkImage(moduleRoot, key, directory, work, scopedLookups
16821
16936
  const defined = /* @__PURE__ */ new Set();
16822
16937
  const libraries = new Set(link.libraries);
16823
16938
  const unpacked = new Set(
16824
- link.objects.map((object3) => /^lib(\w+?)__/.exec(import_node_path35.default.basename(object3))?.[1]).filter(Boolean)
16939
+ link.objects.map((object4) => /^lib(\w+?)__/.exec(import_node_path35.default.basename(object4))?.[1]).filter(Boolean)
16825
16940
  );
16826
16941
  const libraryDirectories = link.flags.filter((flag) => flag.startsWith("-L")).map((flag) => flag.slice(2));
16827
16942
  const strong = /* @__PURE__ */ new Set();
@@ -16829,23 +16944,23 @@ async function linkSwiftSdkImage(moduleRoot, key, directory, work, scopedLookups
16829
16944
  const lazy = [];
16830
16945
  const members = import_node_path35.default.join(work, "members");
16831
16946
  (0, import_node_fs35.mkdirSync)(members, { recursive: true });
16832
- const classify = (object3, bytes) => {
16947
+ const classify = (object4, bytes) => {
16833
16948
  const own = strongDefinitions(bytes);
16834
16949
  const redefines = own.some((name3) => strong.has(name3));
16835
16950
  for (const name3 of own) strong.add(name3);
16836
- if (redefines) return lazy.push(object3);
16837
- eager.push(object3);
16951
+ if (redefines) return lazy.push(object4);
16952
+ eager.push(object4);
16838
16953
  for (const name3 of guestWasmSymbols(bytes).defined) defined.add(name3);
16839
16954
  };
16840
16955
  const rewritten = import_node_path35.default.join(work, "guest-lookups");
16841
16956
  const guestObjects = /* @__PURE__ */ new Map();
16842
16957
  const guestInputs = /* @__PURE__ */ new Map();
16843
- const addObject = (object3, bytes, file, member) => {
16844
- if (!lookups) return classify(object3, bytes);
16958
+ const addObject = (object4, bytes, file, member) => {
16959
+ if (!lookups) return classify(object4, bytes);
16845
16960
  const product = lookups.productFor(file, member);
16846
- guestInputs.set(object3, { ...lookups.objectFor(file, member), product });
16961
+ guestInputs.set(object4, { ...lookups.objectFor(file, member), product });
16847
16962
  const objects = guestObjects.get(product) ?? [];
16848
- objects.push({ path: object3, bytes, instrumentDynamicLookups: false });
16963
+ objects.push({ path: object4, bytes, instrumentDynamicLookups: false });
16849
16964
  guestObjects.set(product, objects);
16850
16965
  };
16851
16966
  const classifyFile = (file) => {
@@ -16858,7 +16973,7 @@ async function linkSwiftSdkImage(moduleRoot, key, directory, work, scopedLookups
16858
16973
  (0, import_node_fs35.mkdirSync)(import_node_path35.default.join(members, archive));
16859
16974
  const ordinals = /* @__PURE__ */ new Map();
16860
16975
  readArMembers(bytes).forEach((member, index) => {
16861
- const object3 = import_node_path35.default.join(members, archive, `${index}-${import_node_path35.default.basename(member.name)}`);
16976
+ const object4 = import_node_path35.default.join(members, archive, `${index}-${import_node_path35.default.basename(member.name)}`);
16862
16977
  const ordinal = (ordinals.get(member.name) ?? 0) + 1;
16863
16978
  ordinals.set(member.name, ordinal);
16864
16979
  const origin = {
@@ -16867,13 +16982,13 @@ async function linkSwiftSdkImage(moduleRoot, key, directory, work, scopedLookups
16867
16982
  ordinal
16868
16983
  };
16869
16984
  const scoped = lookups?.rewrite(file, member.bytes, origin) ?? member.bytes;
16870
- if (!lookups) (0, import_node_fs35.writeFileSync)(object3, scoped);
16871
- addObject(object3, scoped, file, origin);
16985
+ if (!lookups) (0, import_node_fs35.writeFileSync)(object4, scoped);
16986
+ addObject(object4, scoped, file, origin);
16872
16987
  });
16873
16988
  };
16874
- for (const object3 of [...link.objects, ...link.providers]) {
16875
- classifyFile(object3);
16876
- for (const bytes of objectMembers(object3))
16989
+ for (const object4 of [...link.objects, ...link.providers]) {
16990
+ classifyFile(object4);
16991
+ for (const bytes of objectMembers(object4))
16877
16992
  for (const library of autolinkLibraries(bytes)) libraries.add(library);
16878
16993
  }
16879
16994
  for (const library of libraries) {
@@ -16908,13 +17023,13 @@ async function linkSwiftSdkImage(moduleRoot, key, directory, work, scopedLookups
16908
17023
  )
16909
17024
  ]);
16910
17025
  (0, import_node_fs35.mkdirSync)(rewritten);
16911
- for (const [index, object3] of ledger.objects.entries()) {
17026
+ for (const [index, object4] of ledger.objects.entries()) {
16912
17027
  const directory2 = import_node_path35.default.join(rewritten, String(index));
16913
17028
  (0, import_node_fs35.mkdirSync)(directory2);
16914
- const output = import_node_path35.default.join(directory2, import_node_path35.default.basename(object3.path));
16915
- (0, import_node_fs35.writeFileSync)(output, object3.bytes);
16916
- classify(output, object3.bytes);
16917
- guestMap.set(output, guestInputs.get(object3.path));
17029
+ const output = import_node_path35.default.join(directory2, import_node_path35.default.basename(object4.path));
17030
+ (0, import_node_fs35.writeFileSync)(output, object4.bytes);
17031
+ classify(output, object4.bytes);
17032
+ guestMap.set(output, guestInputs.get(object4.path));
16918
17033
  }
16919
17034
  for (const { alias, name: name3 } of ledger.definitions)
16920
17035
  if (name3.startsWith("._OBJC_CLASS_") || name3.startsWith("$s") && /C(?:N|Mn)$/.test(name3))
@@ -17079,11 +17194,11 @@ function sdkLinkInputs(appRoot) {
17079
17194
  else objects.add(token);
17080
17195
  }
17081
17196
  const providers = [];
17082
- for (const object3 of frameworks)
17083
- if (import_node_path35.default.basename(object3).startsWith(DARWIN_RECORDS_PREFIX)) {
17084
- if (!objects.has(object3)) providers.push(object3);
17085
- } else if (!object3.startsWith("-")) objects.add(object3);
17086
- const unpacked = [...objects].find((object3) => object3.includes("/sdk-objs-"));
17197
+ for (const object4 of frameworks)
17198
+ if (import_node_path35.default.basename(object4).startsWith(DARWIN_RECORDS_PREFIX)) {
17199
+ if (!objects.has(object4)) providers.push(object4);
17200
+ } else if (!object4.startsWith("-")) objects.add(object4);
17201
+ const unpacked = [...objects].find((object4) => object4.includes("/sdk-objs-"));
17087
17202
  if (!unpacked) throw new Error("the sdk image link found no unpacked sdk objects");
17088
17203
  const skip = /^lib(XCTest|Testing|_Testing|_TestDiscovery|_TestingInternals|_TestingInterop|_Testing_Foundation|CCryptoBoringSSL)__|^lib_FoundationICU__icu_packaged_data/;
17089
17204
  for (const name3 of (0, import_node_fs35.readdirSync)(import_node_path35.default.dirname(unpacked)))
@@ -17255,16 +17370,26 @@ function writeSdkManifest(work, map, linked, finished, withRelocs, functionSlots
17255
17370
  (0, import_node_fs35.writeFileSync)(import_node_path35.default.join(work, MANIFEST_FILE), JSON.stringify(manifest));
17256
17371
  }
17257
17372
  function readSwiftSdkManifestIndex(image) {
17258
- const manifest = JSON.parse(
17259
- (0, import_node_fs35.readFileSync)(import_node_path35.default.join(image.directory, MANIFEST_FILE), "utf8")
17260
- );
17373
+ const manifestPath = import_node_path35.default.join(image.directory, MANIFEST_FILE);
17374
+ const stat = (0, import_node_fs35.statSync)(manifestPath, { bigint: true });
17375
+ const cacheKey = `${manifestPath}\0${stat.size}:${stat.mtimeNs}`;
17376
+ const memo2 = cachedSdkManifestIndices.get(cacheKey);
17377
+ if (memo2) return memo2;
17378
+ const manifest = JSON.parse((0, import_node_fs35.readFileSync)(manifestPath, "utf8"));
17261
17379
  if (manifest.version !== SWIFT_SDK_IMAGE_VERSION)
17262
17380
  throw new Error(`sdk manifest version ${manifest.version}`);
17263
- return manifest;
17381
+ return setBoundedCache(cachedSdkManifestIndices, cacheKey, manifest);
17264
17382
  }
17265
17383
  function readSwiftSdkManifest(image) {
17384
+ const manifestPath = import_node_path35.default.join(image.directory, MANIFEST_FILE);
17385
+ const dataPath = import_node_path35.default.join(image.directory, MANIFEST_DATA_FILE);
17386
+ const mStat = (0, import_node_fs35.statSync)(manifestPath, { bigint: true });
17387
+ const dStat = (0, import_node_fs35.statSync)(dataPath, { bigint: true });
17388
+ const cacheKey = `${image.directory}\0${mStat.size}:${mStat.mtimeNs}\0${dStat.size}:${dStat.mtimeNs}`;
17389
+ const memo2 = cachedSdkManifests.get(cacheKey);
17390
+ if (memo2) return memo2;
17266
17391
  const manifest = readSwiftSdkManifestIndex(image);
17267
- const data = (0, import_node_fs35.readFileSync)(import_node_path35.default.join(image.directory, MANIFEST_DATA_FILE));
17392
+ const data = (0, import_node_fs35.readFileSync)(dataPath);
17268
17393
  const words = new Uint32Array(data.buffer, data.byteOffset, manifest.segmentBytes / 4);
17269
17394
  const blocks = /* @__PURE__ */ new Map();
17270
17395
  let at = 0;
@@ -17278,9 +17403,9 @@ function readSwiftSdkManifest(image) {
17278
17403
  ...segment,
17279
17404
  data: data.subarray(segment.bytes, segment.bytes + segment.length)
17280
17405
  }));
17281
- return { manifest, block, segments };
17406
+ return setBoundedCache(cachedSdkManifests, cacheKey, { manifest, block, segments });
17282
17407
  }
17283
- var import_node_child_process21, import_node_crypto23, import_node_fs35, import_node_path35, import_node_util4, run2, SWIFT_SDK_IMAGE_VERSION, SWIFT_SDK_APP_MEMORY_BASE, SWIFT_SDK_MEMORY_BASE, SWIFT_SDK_APP_TABLE_BASE, EMPTY_APP, IMAGE_TABLES, IMAGE_ENTRY, imageApp, IMAGE_FILE, IMAGE_DIGEST, swiftSdkImageFile, INTERFACE_FILE, MANIFEST_FILE, MANIFEST_DATA_FILE, SWIFT_SDK_IMAGE_FILES, SWIFT_SDK_IMAGE_BUNDLE, SWIFT_SDK_PIECE_FIELDS, MANIFEST_BLOCKS, isManifestBlock;
17408
+ var import_node_child_process21, import_node_crypto23, import_node_fs35, import_node_path35, import_node_util4, run2, SWIFT_SDK_IMAGE_VERSION, SWIFT_SDK_APP_MEMORY_BASE, SWIFT_SDK_MEMORY_BASE, SWIFT_SDK_APP_TABLE_BASE, EMPTY_APP, IMAGE_TABLES, IMAGE_ENTRY, imageApp, IMAGE_FILE, IMAGE_DIGEST, swiftSdkImageFile, INTERFACE_FILE, MANIFEST_FILE, MANIFEST_DATA_FILE, SWIFT_SDK_IMAGE_FILES, SWIFT_SDK_IMAGE_BUNDLE, MAX_CACHED_SDK_IMAGES, cachedSdkInterfaces, cachedSdkManifestIndices, cachedSdkManifests, SWIFT_SDK_PIECE_FIELDS, MANIFEST_BLOCKS, isManifestBlock;
17284
17409
  var init_swift_sdk_image = __esm({
17285
17410
  "src/swift-sdk-image.ts"() {
17286
17411
  "use strict";
@@ -17384,6 +17509,10 @@ void __peach_sdk_register(void) {
17384
17509
  MANIFEST_DATA_FILE
17385
17510
  ];
17386
17511
  SWIFT_SDK_IMAGE_BUNDLE = "image.tar.gz";
17512
+ MAX_CACHED_SDK_IMAGES = 4;
17513
+ cachedSdkInterfaces = /* @__PURE__ */ new Map();
17514
+ cachedSdkManifestIndices = /* @__PURE__ */ new Map();
17515
+ cachedSdkManifests = /* @__PURE__ */ new Map();
17387
17516
  SWIFT_SDK_PIECE_FIELDS = 7;
17388
17517
  MANIFEST_BLOCKS = [
17389
17518
  "pieces",
@@ -18289,16 +18418,16 @@ function readSwiftSdkUsage(mapFile, linkedFile, sdkObjects) {
18289
18418
  const map = readWasmLinkMap(mapFile, false);
18290
18419
  if (sdkObjects)
18291
18420
  for (const chunk of [...map.data, ...map.code]) {
18292
- const object3 = sdkObjects.get(chunk.inputFile);
18293
- if (object3 !== void 0) chunk.object = object3;
18421
+ const object4 = sdkObjects.get(chunk.inputFile);
18422
+ if (object4 !== void 0) chunk.object = object4;
18294
18423
  }
18295
18424
  return {
18296
- data: map.data.filter(({ segment }) => (sdkObjects || segment !== ".bss") && segment !== ".tdata").map(({ object: object3, section: section2, symbols }) => ({
18297
- object: object3,
18425
+ data: map.data.filter(({ segment }) => (sdkObjects || segment !== ".bss") && segment !== ".tdata").map(({ object: object4, section: section2, symbols }) => ({
18426
+ object: object4,
18298
18427
  section: section2,
18299
18428
  symbols: symbols.map(({ name: name3 }) => ({ name: name3 }))
18300
18429
  })),
18301
- functions: map.code.map(({ object: object3, section: section2 }) => ({ object: object3, section: section2 })),
18430
+ functions: map.code.map(({ object: object4, section: section2 }) => ({ object: object4, section: section2 })),
18302
18431
  constructors: [...new Set(constructorKeys(map, (0, import_node_fs36.readFileSync)(linkedFile)))]
18303
18432
  };
18304
18433
  }
@@ -18319,14 +18448,14 @@ function swiftSdkProjectionSpans(sdk, imageFor) {
18319
18448
  });
18320
18449
  }
18321
18450
  ordered.sort((a, b) => a.address - b.address);
18322
- const imageOf = (object3) => {
18323
- const product = guestObjects[object3]?.product;
18324
- return product === void 0 ? void 0 : imageFor(object3, product);
18451
+ const imageOf = (object4) => {
18452
+ const product = guestObjects[object4]?.product;
18453
+ return product === void 0 ? void 0 : imageFor(object4, product);
18325
18454
  };
18326
18455
  const spans = [];
18327
18456
  for (let index = 0; index < ordered.length; index++) {
18328
- const { object: object3, address, size } = ordered[index];
18329
- const image = imageOf(object3);
18457
+ const { object: object4, address, size } = ordered[index];
18458
+ const image = imageOf(object4);
18330
18459
  if (image === void 0) continue;
18331
18460
  let next = index + 1;
18332
18461
  while (next < ordered.length && ordered[next].address < address + size) next++;
@@ -18348,7 +18477,7 @@ function swiftSdkProjectionSpans(sdk, imageFor) {
18348
18477
  function selectSwiftSdkData(sdk, usage, linkage, projection) {
18349
18478
  const { manifest, block, segments } = readSwiftSdkManifest(sdk);
18350
18479
  const { strings } = manifest;
18351
- const familyOf = (object3) => manifest.guestObjects?.[object3]?.family ?? moduleFamily(object3);
18480
+ const familyOf = (object4) => manifest.guestObjects?.[object4]?.family ?? moduleFamily(object4);
18352
18481
  const metadataName = (name3) => manifest.guestMetadataNames?.[name3] ?? name3;
18353
18482
  const fields = block("pieces");
18354
18483
  const pieceSymbols = block("pieceSymbols");
@@ -18389,18 +18518,18 @@ function selectSwiftSdkData(sdk, usage, linkage, projection) {
18389
18518
  const appSections = /* @__PURE__ */ new Set();
18390
18519
  const appSymbols = /* @__PURE__ */ new Set();
18391
18520
  const appParentsByObject = /* @__PURE__ */ new Map();
18392
- for (const { object: object3, section: section2, symbols } of usage.data) {
18393
- const sections = appSectionsByObject.get(object3) ?? /* @__PURE__ */ new Set();
18521
+ for (const { object: object4, section: section2, symbols } of usage.data) {
18522
+ const sections = appSectionsByObject.get(object4) ?? /* @__PURE__ */ new Set();
18394
18523
  sections.add(section2);
18395
- appSectionsByObject.set(object3, sections);
18524
+ appSectionsByObject.set(object4, sections);
18396
18525
  appSections.add(section2);
18397
18526
  const name3 = symbols[0]?.name;
18398
18527
  if (name3 && !name3.startsWith(".L")) appSymbols.add(name3);
18399
18528
  const parent = partitionParent(section2);
18400
18529
  if (parent !== void 0) {
18401
- const parents = appParentsByObject.get(object3) ?? /* @__PURE__ */ new Set();
18530
+ const parents = appParentsByObject.get(object4) ?? /* @__PURE__ */ new Set();
18402
18531
  parents.add(parent);
18403
- appParentsByObject.set(object3, parents);
18532
+ appParentsByObject.set(object4, parents);
18404
18533
  }
18405
18534
  }
18406
18535
  const byKey = /* @__PURE__ */ new Map();
@@ -18414,10 +18543,10 @@ function selectSwiftSdkData(sdk, usage, linkage, projection) {
18414
18543
  };
18415
18544
  const sdkObjects = /* @__PURE__ */ new Set();
18416
18545
  for (const piece of pieces) {
18417
- const { object: object3, section: section2, symbols } = piece;
18418
- sdkObjects.add(object3);
18419
- if (appSectionsByObject.get(object3)?.has(section2)) {
18420
- const key = `${object3}:${section2}:`;
18546
+ const { object: object4, section: section2, symbols } = piece;
18547
+ sdkObjects.add(object4);
18548
+ if (appSectionsByObject.get(object4)?.has(section2)) {
18549
+ const key = `${object4}:${section2}:`;
18421
18550
  if (symbols.length)
18422
18551
  for (const symbol of symbols) indexPiece(byKey, key + symbol, piece);
18423
18552
  else indexPiece(byKey, key, piece);
@@ -18425,8 +18554,8 @@ function selectSwiftSdkData(sdk, usage, linkage, projection) {
18425
18554
  if (symbols[0] && appSymbols.has(symbols[0])) indexPiece(bySymbol, symbols[0], piece);
18426
18555
  if (appSections.has(section2))
18427
18556
  bySection.set(section2, bySection.has(section2) ? null : piece);
18428
- if (appParentsByObject.get(object3)?.has(section2))
18429
- indexPiece(byObjectSection, `${object3}:${section2}`, piece);
18557
+ if (appParentsByObject.get(object4)?.has(section2))
18558
+ indexPiece(byObjectSection, `${object4}:${section2}`, piece);
18430
18559
  }
18431
18560
  const appConstructors = new Set(usage.constructors);
18432
18561
  const live = /* @__PURE__ */ new Set();
@@ -18504,8 +18633,8 @@ function selectSwiftSdkData(sdk, usage, linkage, projection) {
18504
18633
  const classesSeen = /* @__PURE__ */ new Set();
18505
18634
  const families = /* @__PURE__ */ new Set();
18506
18635
  const pendingCategories = /* @__PURE__ */ new Map();
18507
- const markFamily = (object3) => {
18508
- const family = familyOf(object3);
18636
+ const markFamily = (object4) => {
18637
+ const family = familyOf(object4);
18509
18638
  if (families.has(family)) return;
18510
18639
  families.add(family);
18511
18640
  for (const category of pendingCategories.get(family) ?? []) visit(category.address);
@@ -18548,8 +18677,8 @@ function selectSwiftSdkData(sdk, usage, linkage, projection) {
18548
18677
  }
18549
18678
  }
18550
18679
  const slots = block("functionSlots");
18551
- for (const { object: object3, section: section2 } of usage.functions) {
18552
- appFunctions.add(`${object3}:${section2}:`);
18680
+ for (const { object: object4, section: section2 } of usage.functions) {
18681
+ appFunctions.add(`${object4}:${section2}:`);
18553
18682
  appFunctionNames.add(section2);
18554
18683
  }
18555
18684
  const nameCounts = /* @__PURE__ */ new Map();
@@ -18645,13 +18774,13 @@ function selectSwiftSdkData(sdk, usage, linkage, projection) {
18645
18774
  }
18646
18775
  }
18647
18776
  if (projection && manifest.guestObjects) {
18648
- const imageOf = (object3) => {
18649
- const product = manifest.guestObjects?.[object3]?.product;
18650
- return product === void 0 ? void 0 : projection.imageFor(object3, product);
18777
+ const imageOf = (object4) => {
18778
+ const product = manifest.guestObjects?.[object4]?.product;
18779
+ return product === void 0 ? void 0 : projection.imageFor(object4, product);
18651
18780
  };
18652
18781
  const ordered = pieces.filter(({ size }) => size).sort((a, b) => a.address - b.address);
18653
- for (const [index, { object: object3, address: address2, size }] of ordered.entries()) {
18654
- const image = imageOf(object3);
18782
+ for (const [index, { object: object4, address: address2, size }] of ordered.entries()) {
18783
+ const image = imageOf(object4);
18655
18784
  if (image === void 0) continue;
18656
18785
  let next = index + 1;
18657
18786
  while (next < ordered.length && ordered[next].address < address2 + size) next++;
@@ -18984,7 +19113,7 @@ async function compileGuestLink(options) {
18984
19113
  let lazyFunctions = [];
18985
19114
  let dyldSymbols = [];
18986
19115
  const bundlePaths = new Map(
18987
- options.resourceBundles.map(({ target, path: path42 }) => [target, path42])
19116
+ options.resourceBundles.map(({ target, path: path43 }) => [target, path43])
18988
19117
  );
18989
19118
  const imageMetadata = (products) => {
18990
19119
  const source = sourceImages.map((image) => {
@@ -19166,9 +19295,9 @@ async function compileGuestLink(options) {
19166
19295
  ])
19167
19296
  );
19168
19297
  frameworkObjects = new Map(
19169
- catalogs.framework.product.objects.map((object3) => {
19170
- const original2 = import_node_path37.default.resolve(catalogs.framework.root, object3.path);
19171
- return [import_node_path37.default.resolve(rewritten.get(original2) ?? original2), object3.target];
19298
+ catalogs.framework.product.objects.map((object4) => {
19299
+ const original2 = import_node_path37.default.resolve(catalogs.framework.root, object4.path);
19300
+ return [import_node_path37.default.resolve(rewritten.get(original2) ?? original2), object4.target];
19172
19301
  })
19173
19302
  );
19174
19303
  identities = guestRuntimeInputIdentities({
@@ -19224,9 +19353,9 @@ async function compileGuestLink(options) {
19224
19353
  memoryProtection: { initial: 3, maximum: 3 },
19225
19354
  tableProtection: { initial: 5, maximum: 5 },
19226
19355
  clangOptions,
19227
- onReserved: (value, object3) => {
19356
+ onReserved: (value, object4) => {
19228
19357
  reserved = value;
19229
- projectionObject = object3;
19358
+ projectionObject = object4;
19230
19359
  }
19231
19360
  };
19232
19361
  },
@@ -19265,13 +19394,13 @@ async function compileGuestLink(options) {
19265
19394
  }
19266
19395
  providers = selected2;
19267
19396
  }
19268
- for (const object3 of callers) {
19269
- if (scope.owners.get(object3) !== image)
19270
- throw new Error(`framework request has no selected source owner ${object3}`);
19271
- const allowed = frameworkProviders.get(object3);
19272
- if (!allowed) frameworkProviders.set(object3, providers);
19397
+ for (const object4 of callers) {
19398
+ if (scope.owners.get(object4) !== image)
19399
+ throw new Error(`framework request has no selected source owner ${object4}`);
19400
+ const allowed = frameworkProviders.get(object4);
19401
+ if (!allowed) frameworkProviders.set(object4, providers);
19273
19402
  else if (allowed !== providers && [...providers].some((provider) => !allowed.has(provider)))
19274
- frameworkProviders.set(object3, /* @__PURE__ */ new Set([...allowed, ...providers]));
19403
+ frameworkProviders.set(object4, /* @__PURE__ */ new Set([...allowed, ...providers]));
19275
19404
  }
19276
19405
  }
19277
19406
  }
@@ -19335,7 +19464,7 @@ async function compileGuestLink(options) {
19335
19464
  const linkedModule = import_node_path37.default.join(work, "app.wasm");
19336
19465
  const sdkSpans = swiftSdkProjectionSpans2(
19337
19466
  sdk,
19338
- (object3, product) => sdkObjectImages.get(object3) ?? sdkProductImages.get(product)
19467
+ (object4, product) => sdkObjectImages.get(object4) ?? sdkProductImages.get(product)
19339
19468
  );
19340
19469
  let storage = reserved;
19341
19470
  if (sdkSpans.length > 0) {
@@ -19971,22 +20100,22 @@ function archiveMember(archive, name3) {
19971
20100
  }
19972
20101
  throw new Error(`swift-icu: ${name3} is not in the sdk's icu archive`);
19973
20102
  }
19974
- function icuSegment(object3) {
20103
+ function icuSegment(object4) {
19975
20104
  let at = 8;
19976
20105
  const leb2 = () => {
19977
20106
  let result = 0;
19978
20107
  let shift = 0;
19979
20108
  let byte;
19980
20109
  do {
19981
- byte = object3[at++];
20110
+ byte = object4[at++];
19982
20111
  result += (byte & 127) * 2 ** shift;
19983
20112
  shift += 7;
19984
20113
  } while (byte & 128);
19985
20114
  return result;
19986
20115
  };
19987
20116
  const found = [];
19988
- while (at < object3.length) {
19989
- const id = object3[at++];
20117
+ while (at < object4.length) {
20118
+ const id = object4[at++];
19990
20119
  const size = leb2();
19991
20120
  const end = at + size;
19992
20121
  if (id === 11) {
@@ -19996,7 +20125,7 @@ function icuSegment(object3) {
19996
20125
  leb2();
19997
20126
  at++;
19998
20127
  const length = leb2();
19999
- const bytes = object3.subarray(at, at + length);
20128
+ const bytes = object4.subarray(at, at + length);
20000
20129
  if (bytes[2] === 218 && bytes[3] === 39) found.push(bytes);
20001
20130
  at += length;
20002
20131
  }
@@ -20384,8 +20513,8 @@ function sourceEntryPath() {
20384
20513
  return null;
20385
20514
  }
20386
20515
  }
20387
- function isCliEntry(path42) {
20388
- const name3 = (0, import_node_path41.basename)(path42);
20516
+ function isCliEntry(path43) {
20517
+ const name3 = (0, import_node_path41.basename)(path43);
20389
20518
  return name3 === "bin.ts" || name3 === "bin.js";
20390
20519
  }
20391
20520
  function rnxSelfInvocation() {
@@ -20474,8 +20603,17 @@ var init_swift_objc_prebuilt = __esm({
20474
20603
  });
20475
20604
 
20476
20605
  // src/swift-reproducible.ts
20606
+ function canonicalHomeDir() {
20607
+ const home = import_node_os10.default.homedir();
20608
+ const dotPeach = import_node_path43.default.join(home, ".peach");
20609
+ if ((0, import_node_fs42.existsSync)(dotPeach)) {
20610
+ const realHome = import_node_path43.default.dirname((0, import_node_fs42.realpathSync)(dotPeach));
20611
+ if (home === realHome || home.startsWith(`${realHome}${import_node_path43.default.sep}`)) return realHome;
20612
+ }
20613
+ return home;
20614
+ }
20477
20615
  function swiftReproducibleBuildFlags(roots) {
20478
- return [[import_node_os10.default.homedir(), "home"], ...roots].flatMap(
20616
+ return [[canonicalHomeDir(), "home"], ...roots].flatMap(
20479
20617
  ([root, name3]) => [.../* @__PURE__ */ new Set([root, (0, import_node_fs42.realpathSync)(root)])].map((from) => `${from}=/peach/${name3}`)
20480
20618
  ).flatMap((map) => [
20481
20619
  "-Xswiftc",
@@ -20488,12 +20626,13 @@ function swiftReproducibleBuildFlags(roots) {
20488
20626
  `-ffile-prefix-map=${map}`
20489
20627
  ]);
20490
20628
  }
20491
- var import_node_fs42, import_node_os10;
20629
+ var import_node_fs42, import_node_os10, import_node_path43;
20492
20630
  var init_swift_reproducible = __esm({
20493
20631
  "src/swift-reproducible.ts"() {
20494
20632
  "use strict";
20495
20633
  import_node_fs42 = require("node:fs");
20496
20634
  import_node_os10 = __toESM(require("node:os"), 1);
20635
+ import_node_path43 = __toESM(require("node:path"), 1);
20497
20636
  }
20498
20637
  });
20499
20638
 
@@ -20553,10 +20692,10 @@ var init_swift_source_closure = __esm({
20553
20692
 
20554
20693
  // src/swift-uniform-type-constants.ts
20555
20694
  function compileUniformTypeConstants(args) {
20556
- const source = import_node_path43.default.join(args.packageRoot, "runtime/UniformTypeIdentifiersConstants.m");
20557
- const object3 = import_node_path43.default.join(args.out, "UniformTypeIdentifiers-NativeConstants.o");
20695
+ const source = import_node_path44.default.join(args.packageRoot, "runtime/UniformTypeIdentifiersConstants.m");
20696
+ const object4 = import_node_path44.default.join(args.out, "UniformTypeIdentifiers-NativeConstants.o");
20558
20697
  (0, import_node_child_process27.execFileSync)(
20559
- import_node_path43.default.join(args.bin, "clang"),
20698
+ import_node_path44.default.join(args.bin, "clang"),
20560
20699
  [
20561
20700
  "--target=wasm64-unknown-wasip1-threads",
20562
20701
  ...wasmThreadFlags,
@@ -20566,23 +20705,23 @@ function compileUniformTypeConstants(args) {
20566
20705
  ...swiftObjCRuntimeFlags,
20567
20706
  "-fwasm-exceptions",
20568
20707
  "-F",
20569
- import_node_path43.default.resolve(args.packageRoot, "../peachsim/sdk/ios/System/Library/Frameworks"),
20708
+ import_node_path44.default.resolve(args.packageRoot, "../peachsim/sdk/ios/System/Library/Frameworks"),
20570
20709
  ...objcSdkIntakeFlags(args.darwin, args.bin, args.minimum),
20571
20710
  "-c",
20572
20711
  source,
20573
20712
  "-o",
20574
- object3
20713
+ object4
20575
20714
  ],
20576
20715
  { stdio: ["ignore", "pipe", "inherit"] }
20577
20716
  );
20578
- return object3;
20717
+ return object4;
20579
20718
  }
20580
- var import_node_child_process27, import_node_path43;
20719
+ var import_node_child_process27, import_node_path44;
20581
20720
  var init_swift_uniform_type_constants = __esm({
20582
20721
  "src/swift-uniform-type-constants.ts"() {
20583
20722
  "use strict";
20584
20723
  import_node_child_process27 = require("node:child_process");
20585
- import_node_path43 = __toESM(require("node:path"), 1);
20724
+ import_node_path44 = __toESM(require("node:path"), 1);
20586
20725
  init_swift_objc_runtime();
20587
20726
  init_swift_objc_standin();
20588
20727
  init_swiftTargetContract();
@@ -20594,7 +20733,7 @@ function coalescibleHeaderOverlays(files) {
20594
20733
  const aliases = /* @__PURE__ */ new Map();
20595
20734
  const key = (file) => file.replace(/[A-Z]/g, (letter) => letter.toLowerCase());
20596
20735
  const index = (directory, entry) => {
20597
- const name3 = import_node_path44.default.resolve(directory, entry.name);
20736
+ const name3 = import_node_path45.default.resolve(directory, entry.name);
20598
20737
  if (entry.type === "directory")
20599
20738
  return entry.contents.every((child) => index(name3, child));
20600
20739
  const source = entry["external-contents"];
@@ -20605,11 +20744,11 @@ function coalescibleHeaderOverlays(files) {
20605
20744
  };
20606
20745
  for (const file of files) {
20607
20746
  const overlay = JSON.parse(import_node_fs43.default.readFileSync(file, "utf8"));
20608
- if (!overlay.roots.every((entry) => index(import_node_path44.default.dirname(file), entry)))
20747
+ if (!overlay.roots.every((entry) => index(import_node_path45.default.dirname(file), entry)))
20609
20748
  return /* @__PURE__ */ new Set();
20610
20749
  }
20611
20750
  for (const file of [...files, ...aliases.values()]) {
20612
- const source = aliases.get(key(import_node_path44.default.normalize(file)));
20751
+ const source = aliases.get(key(import_node_path45.default.normalize(file)));
20613
20752
  if (source !== void 0 && source !== file) return /* @__PURE__ */ new Set();
20614
20753
  }
20615
20754
  return files;
@@ -20669,11 +20808,11 @@ function writeXcodeHeaderSearch(directory, targets, headerAliases = {}, listed)
20669
20808
  seen.add(file);
20670
20809
  file = headerAliases[file];
20671
20810
  }
20672
- const listed2 = productDirectories.get(import_node_path44.default.dirname(product)) ?? [];
20673
- productDirectories.set(import_node_path44.default.dirname(product), listed2);
20674
- listed2.push({ name: import_node_path44.default.basename(product), file });
20811
+ const listed2 = productDirectories.get(import_node_path45.default.dirname(product)) ?? [];
20812
+ productDirectories.set(import_node_path45.default.dirname(product), listed2);
20813
+ listed2.push({ name: import_node_path45.default.basename(product), file });
20675
20814
  }
20676
- const overlay = import_node_path44.default.join(directory, "all-product-headers.yaml");
20815
+ const overlay = import_node_path45.default.join(directory, "all-product-headers.yaml");
20677
20816
  writeBuildFile(
20678
20817
  overlay,
20679
20818
  JSON.stringify({
@@ -20693,7 +20832,7 @@ function writeXcodeHeaderSearch(directory, targets, headerAliases = {}, listed)
20693
20832
  const files = [overlay];
20694
20833
  const flags = targets.map((target, index) => {
20695
20834
  const maps = target.headerMaps.map((map, order) => {
20696
- const file = import_node_path44.default.join(directory, `${index}-${order}.hmap`);
20835
+ const file = import_node_path45.default.join(directory, `${index}-${order}.hmap`);
20697
20836
  writeBuildFile(file, headerMap(map.entries));
20698
20837
  files.push(file);
20699
20838
  return { flag: map.flag, file };
@@ -20715,12 +20854,12 @@ function writeXcodeHeaderSearch(directory, targets, headerAliases = {}, listed)
20715
20854
  });
20716
20855
  return { files, flags };
20717
20856
  }
20718
- var import_node_fs43, import_node_path44;
20857
+ var import_node_fs43, import_node_path45;
20719
20858
  var init_xcode_header_search = __esm({
20720
20859
  "src/xcode-header-search.ts"() {
20721
20860
  "use strict";
20722
20861
  import_node_fs43 = __toESM(require("node:fs"), 1);
20723
- import_node_path44 = __toESM(require("node:path"), 1);
20862
+ import_node_path45 = __toESM(require("node:path"), 1);
20724
20863
  init_case_insensitive_header_overlay();
20725
20864
  init_write_build_file();
20726
20865
  }
@@ -20843,9 +20982,9 @@ function useSwiftPackagePrebuilts(input, moduleRoot, toolchainBin) {
20843
20982
  const binaryModules = { ...resolved.binaryModules };
20844
20983
  let manifest = files["Package.swift"];
20845
20984
  for (const target of entry.targets) {
20846
- const library = import_node_path45.default.join(directory, `lib${target.name}.a`);
20985
+ const library = import_node_path46.default.join(directory, `lib${target.name}.a`);
20847
20986
  libraries[target.name] = import_node_fs44.default.readFileSync(library).toString("base64");
20848
- const module2 = import_node_path45.default.join(directory, `${target.name}.swiftmodule`);
20987
+ const module2 = import_node_path46.default.join(directory, `${target.name}.swiftmodule`);
20849
20988
  const targetPrefix = `${target.path}/`;
20850
20989
  const compiledSources = Object.keys(entry.files).filter(
20851
20990
  (file) => file.startsWith(targetPrefix) && /\.(?:swift|c)$/.test(file)
@@ -20871,13 +21010,13 @@ function useSwiftPackagePrebuilts(input, moduleRoot, toolchainBin) {
20871
21010
  }
20872
21011
  return resolved;
20873
21012
  }
20874
- var import_node_crypto28, import_node_fs44, import_node_path45, PACKAGE_RECIPE;
21013
+ var import_node_crypto28, import_node_fs44, import_node_path46, PACKAGE_RECIPE;
20875
21014
  var init_swift_package_prebuilt = __esm({
20876
21015
  "src/swift-package-prebuilt.ts"() {
20877
21016
  "use strict";
20878
21017
  import_node_crypto28 = require("node:crypto");
20879
21018
  import_node_fs44 = __toESM(require("node:fs"), 1);
20880
- import_node_path45 = __toESM(require("node:path"), 1);
21019
+ import_node_path46 = __toESM(require("node:path"), 1);
20881
21020
  init_native_prebuilt();
20882
21021
  init_swift_compile();
20883
21022
  init_swift_package();
@@ -21067,7 +21206,7 @@ function assertSwiftBuildCores() {
21067
21206
  );
21068
21207
  }
21069
21208
  function swiftDistributionAt(root) {
21070
- const file = import_node_path46.default.join(root, SWIFT_DISTRIBUTION_MANIFEST);
21209
+ const file = import_node_path47.default.join(root, SWIFT_DISTRIBUTION_MANIFEST);
21071
21210
  const stat = (0, import_node_fs45.statSync)(file, { bigint: true, throwIfNoEntry: false });
21072
21211
  if (!stat) return null;
21073
21212
  const identity = `${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}`;
@@ -21084,18 +21223,18 @@ function swiftDistributionCompileView(moduleRoot, distribution) {
21084
21223
  ([file]) => file.startsWith("host/") || file === SWIFT_DISTRIBUTION_OBJC_SELECTORS
21085
21224
  ).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0);
21086
21225
  const digest = (0, import_node_crypto29.createHash)("sha256").update(JSON.stringify(inputs)).digest("hex");
21087
- view = import_node_path46.default.join(swiftCacheDir(), "swift-sdk-views", `compile-${digest}`);
21226
+ view = import_node_path47.default.join(swiftCacheDir(), "swift-sdk-views", `compile-${digest}`);
21088
21227
  if (!(0, import_node_fs45.existsSync)(view)) {
21089
- (0, import_node_fs45.mkdirSync)(import_node_path46.default.dirname(view), { recursive: true });
21228
+ (0, import_node_fs45.mkdirSync)(import_node_path47.default.dirname(view), { recursive: true });
21090
21229
  const staging = (0, import_node_fs45.mkdtempSync)(`${view}-`);
21091
21230
  try {
21092
21231
  (0, import_node_fs45.chmodSync)(staging, 493);
21093
21232
  for (const [file] of inputs) {
21094
21233
  if (!isSwiftResourcePath(file))
21095
21234
  throw new Error(`invalid Swift distribution compile path ${file}`);
21096
- const destination = import_node_path46.default.join(staging, file);
21097
- (0, import_node_fs45.mkdirSync)(import_node_path46.default.dirname(destination), { recursive: true });
21098
- (0, import_node_fs45.copyFileSync)(import_node_path46.default.join(moduleRoot, file), destination);
21235
+ const destination = import_node_path47.default.join(staging, file);
21236
+ (0, import_node_fs45.mkdirSync)(import_node_path47.default.dirname(destination), { recursive: true });
21237
+ (0, import_node_fs45.copyFileSync)(import_node_path47.default.join(moduleRoot, file), destination);
21099
21238
  }
21100
21239
  try {
21101
21240
  (0, import_node_fs45.renameSync)(staging, view);
@@ -21116,19 +21255,19 @@ function swiftDistributionCompileView(moduleRoot, distribution) {
21116
21255
  function swiftModuleInterface(moduleRoot, name3) {
21117
21256
  if (REACH_STAGED_FRAMEWORKS.has(name3)) return null;
21118
21257
  if (swiftDistributionAt(moduleRoot)) {
21119
- const file = import_node_path46.default.join(moduleRoot, "modules", `${name3}-Swift.h`);
21258
+ const file = import_node_path47.default.join(moduleRoot, "modules", `${name3}-Swift.h`);
21120
21259
  if (!(0, import_node_fs45.existsSync)(file)) return null;
21121
21260
  const header = clangInterfaceHeader((0, import_node_fs45.readFileSync)(file, "utf8"), moduleRoot);
21122
21261
  return { declared: swiftInterfaceDeclarations(header), header };
21123
21262
  }
21124
- const sources = import_node_path46.default.join(moduleRoot, "Sources", name3);
21125
- const built = import_node_path46.default.join(moduleRoot, ".build/host", `${name3}-Swift.h`);
21263
+ const sources = import_node_path47.default.join(moduleRoot, "Sources", name3);
21264
+ const built = import_node_path47.default.join(moduleRoot, ".build/host", `${name3}-Swift.h`);
21126
21265
  if (!(0, import_node_fs45.existsSync)(sources) || !(0, import_node_fs45.existsSync)(built)) return null;
21127
21266
  const declared = /* @__PURE__ */ new Set();
21128
21267
  for (const file of (0, import_node_fs45.readdirSync)(sources, { recursive: true, encoding: "utf8" }))
21129
21268
  if (file.endsWith(".swift"))
21130
21269
  for (const [, objc, subclass] of (0, import_node_fs45.readFileSync)(
21131
- import_node_path46.default.join(sources, file),
21270
+ import_node_path47.default.join(sources, file),
21132
21271
  "utf8"
21133
21272
  ).matchAll(
21134
21273
  /@objc\((\w+)\)\s+(?:\w+\s+)*?(?:protocol|class)\s|^(?:public|open)\s+(?:final\s+)?class\s+(\w+)\s*:\s*NSObject\b/gm
@@ -21142,7 +21281,7 @@ function swiftModuleInterface(moduleRoot, name3) {
21142
21281
  }
21143
21282
  function clangInterfaceHeader(header, moduleRoot) {
21144
21283
  const distribution = swiftDistributionAt(moduleRoot) !== null;
21145
- const frameworks = import_node_path46.default.join(
21284
+ const frameworks = import_node_path47.default.join(
21146
21285
  swiftSharedSdkSourceRoot(moduleRoot, distribution),
21147
21286
  "System/Library/Frameworks"
21148
21287
  );
@@ -21155,7 +21294,7 @@ function clangInterfaceHeader(header, moduleRoot) {
21155
21294
  (_, module2, framework) => {
21156
21295
  const imports = [`@import ${framework};`];
21157
21296
  imported.add(framework);
21158
- const directory = distribution ? import_node_path46.default.join(moduleRoot, "modules", module2) : import_node_path46.default.join(moduleRoot, "Sources", module2, "include");
21297
+ const directory = distribution ? import_node_path47.default.join(moduleRoot, "modules", module2) : import_node_path47.default.join(moduleRoot, "Sources", module2, "include");
21159
21298
  if (!(0, import_node_fs45.existsSync)(directory)) return imports[0];
21160
21299
  if (!references) {
21161
21300
  references = new Set(header.match(/\b[A-Z]\w*\b/g));
@@ -21178,7 +21317,7 @@ function clangInterfaceHeader(header, moduleRoot) {
21178
21317
  function clangDeclarationEnums(directory) {
21179
21318
  const cached2 = clangDeclarationEnumCache.get(directory);
21180
21319
  if (cached2) return cached2;
21181
- const enums = (0, import_node_fs45.readdirSync)(directory).filter((file) => file.endsWith(".h")).flatMap((file) => objcEnumerations((0, import_node_fs45.readFileSync)(import_node_path46.default.join(directory, file), "utf8")));
21320
+ const enums = (0, import_node_fs45.readdirSync)(directory).filter((file) => file.endsWith(".h")).flatMap((file) => objcEnumerations((0, import_node_fs45.readFileSync)(import_node_path47.default.join(directory, file), "utf8")));
21182
21321
  clangDeclarationEnumCache.set(directory, enums);
21183
21322
  return enums;
21184
21323
  }
@@ -21211,11 +21350,11 @@ function sdkObjCDeclarationOwners(frameworks) {
21211
21350
  const owners = /* @__PURE__ */ new Map();
21212
21351
  for (const framework of (0, import_node_fs45.readdirSync)(frameworks))
21213
21352
  if (framework.endsWith(".framework")) {
21214
- const headers = import_node_path46.default.join(frameworks, framework, "Headers");
21353
+ const headers = import_node_path47.default.join(frameworks, framework, "Headers");
21215
21354
  if ((0, import_node_fs45.existsSync)(headers)) {
21216
21355
  for (const file of (0, import_node_fs45.readdirSync)(headers, { recursive: true, encoding: "utf8" }))
21217
21356
  if (file.endsWith(".h")) {
21218
- const header = (0, import_node_fs45.readFileSync)(import_node_path46.default.join(headers, file), "utf8");
21357
+ const header = (0, import_node_fs45.readFileSync)(import_node_path47.default.join(headers, file), "utf8");
21219
21358
  for (const name3 of [
21220
21359
  ...swiftInterfaceDeclarations(header),
21221
21360
  ...objcEnumerations(header),
@@ -21302,7 +21441,7 @@ function swiftCompileSdkOptions(moduleRoot, toolchainBin) {
21302
21441
  }
21303
21442
  function swiftObjCSelectorOptions(moduleRoot) {
21304
21443
  const distribution = swiftDistributionAt(moduleRoot);
21305
- let map = import_node_path46.default.join(
21444
+ let map = import_node_path47.default.join(
21306
21445
  distribution ? swiftDistributionCompileView(moduleRoot, distribution) : moduleRoot,
21307
21446
  SWIFT_DISTRIBUTION_OBJC_SELECTORS
21308
21447
  );
@@ -21312,18 +21451,21 @@ function swiftObjCSelectorOptions(moduleRoot) {
21312
21451
  for (const [name3, members] of Object.entries(
21313
21452
  JSON.parse(
21314
21453
  (0, import_node_fs45.readFileSync)(
21315
- import_node_path46.default.join(moduleRoot, "Sources", framework, "ObjCSelectors.json"),
21454
+ import_node_path47.default.join(moduleRoot, "Sources", framework, "ObjCSelectors.json"),
21316
21455
  "utf8"
21317
21456
  )
21318
21457
  ).classes
21319
21458
  ))
21320
21459
  classes[name3] = [...classes[name3] ?? [], ...members];
21321
- map = import_node_path46.default.join(moduleRoot, ".build", SWIFT_DISTRIBUTION_OBJC_SELECTORS);
21322
- (0, import_node_fs45.mkdirSync)(import_node_path46.default.dirname(map), { recursive: true });
21323
- const partial = `${map}.${(0, import_node_crypto29.randomUUID)()}`;
21324
- (0, import_node_fs45.writeFileSync)(partial, `${JSON.stringify({ classes }, null, 2)}
21325
- `);
21326
- (0, import_node_fs45.renameSync)(partial, map);
21460
+ map = import_node_path47.default.join(moduleRoot, ".build", SWIFT_DISTRIBUTION_OBJC_SELECTORS);
21461
+ const content = `${JSON.stringify({ classes }, null, 2)}
21462
+ `;
21463
+ if (!(0, import_node_fs45.existsSync)(map) || (0, import_node_fs45.readFileSync)(map, "utf8") !== content) {
21464
+ (0, import_node_fs45.mkdirSync)(import_node_path47.default.dirname(map), { recursive: true });
21465
+ const partial = `${map}.${(0, import_node_crypto29.randomUUID)()}`;
21466
+ (0, import_node_fs45.writeFileSync)(partial, content);
21467
+ (0, import_node_fs45.renameSync)(partial, map);
21468
+ }
21327
21469
  }
21328
21470
  return ["-Xswiftc", "-Xllvm", "-Xswiftc", `-peach-objc-selector-map=${map}`];
21329
21471
  }
@@ -21361,7 +21503,7 @@ function swiftModuleInputFiles(root) {
21361
21503
  "toolchain.json"
21362
21504
  ];
21363
21505
  const walk = (dir) => {
21364
- for (const entry of (0, import_node_fs45.readdirSync)(import_node_path46.default.join(root, dir), {
21506
+ for (const entry of (0, import_node_fs45.readdirSync)(import_node_path47.default.join(root, dir), {
21365
21507
  withFileTypes: true
21366
21508
  })) {
21367
21509
  const relative = `${dir}/${entry.name}`;
@@ -21377,40 +21519,40 @@ function swiftModuleInputFiles(root) {
21377
21519
  walk("ios-simulator-stdlib");
21378
21520
  return files.sort();
21379
21521
  }
21380
- function swiftMacroPlugins(moduleRoot, dir = import_node_path46.default.join(moduleRoot, ".build/host/RnxPreviewMacros")) {
21522
+ function swiftMacroPlugins(moduleRoot, dir = import_node_path47.default.join(moduleRoot, ".build/host/RnxPreviewMacros")) {
21381
21523
  const distribution = swiftDistributionAt(moduleRoot);
21382
21524
  if (distribution) {
21383
21525
  const view = swiftDistributionCompileView(moduleRoot, distribution);
21384
21526
  return {
21385
- libraries: distribution.plugins.filter((plugin) => import_node_path46.default.basename(plugin) !== "ExpoModulesMacros").map((plugin) => import_node_path46.default.join(view, plugin)),
21386
- executables: distribution.plugins.filter((plugin) => import_node_path46.default.basename(plugin) === "ExpoModulesMacros").map((plugin) => import_node_path46.default.join(view, plugin)),
21527
+ libraries: distribution.plugins.filter((plugin) => import_node_path47.default.basename(plugin) !== "ExpoModulesMacros").map((plugin) => import_node_path47.default.join(view, plugin)),
21528
+ executables: distribution.plugins.filter((plugin) => import_node_path47.default.basename(plugin) === "ExpoModulesMacros").map((plugin) => import_node_path47.default.join(view, plugin)),
21387
21529
  stale: false
21388
21530
  };
21389
21531
  }
21390
21532
  const release = JSON.parse(
21391
- (0, import_node_fs45.readFileSync)(import_node_path46.default.join(moduleRoot, "toolchain.json"), "utf8")
21533
+ (0, import_node_fs45.readFileSync)(import_node_path47.default.join(moduleRoot, "toolchain.json"), "utf8")
21392
21534
  ).release;
21393
- const compilerStamp = import_node_path46.default.join(dir, "compiler-release");
21394
- const pluginScript = import_node_path46.default.join(moduleRoot, "scripts/build-preview-plugin.sh");
21395
- const expoPlugin = import_node_path46.default.join(dir, "ExpoModulesMacros");
21535
+ const compilerStamp = import_node_path47.default.join(dir, "compiler-release");
21536
+ const pluginScript = import_node_path47.default.join(moduleRoot, "scripts/build-preview-plugin.sh");
21537
+ const expoPlugin = import_node_path47.default.join(dir, "ExpoModulesMacros");
21396
21538
  const ext = process.platform === "darwin" ? "dylib" : "so";
21397
21539
  const plugins = [
21398
21540
  {
21399
- library: import_node_path46.default.join(dir, `libRnxPreviewMacros.${ext}`),
21400
- sources: [import_node_path46.default.join(moduleRoot, "Sources/RnxPreviewMacros/PreviewMacro.swift")]
21541
+ library: import_node_path47.default.join(dir, `libRnxPreviewMacros.${ext}`),
21542
+ sources: [import_node_path47.default.join(moduleRoot, "Sources/RnxPreviewMacros/PreviewMacro.swift")]
21401
21543
  },
21402
21544
  {
21403
- library: import_node_path46.default.join(dir, `libFoundationMacros.${ext}`),
21545
+ library: import_node_path47.default.join(dir, `libFoundationMacros.${ext}`),
21404
21546
  sources: [
21405
- import_node_path46.default.join(moduleRoot, "Sources/FoundationMacros/PredicateMacro.swift"),
21406
- import_node_path46.default.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
21547
+ import_node_path47.default.join(moduleRoot, "Sources/FoundationMacros/PredicateMacro.swift"),
21548
+ import_node_path47.default.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
21407
21549
  ]
21408
21550
  },
21409
21551
  {
21410
- library: import_node_path46.default.join(dir, `libTipKitMacros.${ext}`),
21552
+ library: import_node_path47.default.join(dir, `libTipKitMacros.${ext}`),
21411
21553
  sources: [
21412
- import_node_path46.default.join(moduleRoot, "Sources/TipKitMacros/TipKitMacros.swift"),
21413
- import_node_path46.default.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
21554
+ import_node_path47.default.join(moduleRoot, "Sources/TipKitMacros/TipKitMacros.swift"),
21555
+ import_node_path47.default.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
21414
21556
  ]
21415
21557
  }
21416
21558
  ];
@@ -21428,14 +21570,14 @@ async function ensureMacroPlugins(moduleRoot, toolchainBin, release, signal, lea
21428
21570
  await runCompiler(
21429
21571
  "sh",
21430
21572
  [
21431
- import_node_path46.default.join(moduleRoot, "scripts/build-preview-plugin.sh"),
21573
+ import_node_path47.default.join(moduleRoot, "scripts/build-preview-plugin.sh"),
21432
21574
  toolchainBin,
21433
21575
  libraries[0]
21434
21576
  ],
21435
21577
  { signal, lease }
21436
21578
  );
21437
21579
  (0, import_node_fs45.writeFileSync)(
21438
- import_node_path46.default.join(import_node_path46.default.dirname(libraries[0]), "compiler-release"),
21580
+ import_node_path47.default.join(import_node_path47.default.dirname(libraries[0]), "compiler-release"),
21439
21581
  `${release}
21440
21582
  `
21441
21583
  );
@@ -21446,11 +21588,74 @@ function clearLinkedModuleDigests(root) {
21446
21588
  if (root === void 0) linkedModuleDigests.clear();
21447
21589
  else linkedModuleDigests.delete(root);
21448
21590
  }
21591
+ function gitCleanModuleInputsKey(root, files) {
21592
+ if (swiftDistributionAt(root)) return null;
21593
+ const top = (0, import_node_child_process28.spawnSync)("git", ["-C", root, "rev-parse", "--show-toplevel"], {
21594
+ encoding: "utf8",
21595
+ stdio: ["ignore", "pipe", "ignore"]
21596
+ });
21597
+ if (top.status !== 0) return null;
21598
+ const repoTop = top.stdout.trim();
21599
+ if (!repoTop) return null;
21600
+ const realTop = (0, import_node_fs45.realpathSync)(repoTop);
21601
+ const realRoot = (0, import_node_fs45.realpathSync)(root);
21602
+ const collapsedDirs = [
21603
+ import_node_path47.default.join(realRoot, "Sources"),
21604
+ import_node_path47.default.join(realRoot, "cross-import-overlays"),
21605
+ import_node_path47.default.join(realRoot, "ios-simulator-stdlib"),
21606
+ (0, import_node_fs45.realpathSync)(import_node_path47.default.resolve(realRoot, "../peachsim/sdk/ios"))
21607
+ ];
21608
+ const scoped = /* @__PURE__ */ new Set();
21609
+ for (const dir of collapsedDirs) {
21610
+ const rel = import_node_path47.default.relative(realTop, dir).split(import_node_path47.default.sep).join("/");
21611
+ if (!rel || rel.startsWith("../")) return null;
21612
+ scoped.add(rel);
21613
+ }
21614
+ for (const file of files) {
21615
+ const full = import_node_path47.default.resolve(realRoot, file);
21616
+ if (collapsedDirs.some((dir) => full.startsWith(dir + import_node_path47.default.sep))) continue;
21617
+ const rel = import_node_path47.default.relative(realTop, full).split(import_node_path47.default.sep).join("/");
21618
+ if (!rel || rel.startsWith("../")) return null;
21619
+ scoped.add(rel);
21620
+ }
21621
+ const paths = [...scoped].sort();
21622
+ const status = (0, import_node_child_process28.spawnSync)(
21623
+ "git",
21624
+ [
21625
+ "-C",
21626
+ realTop,
21627
+ "status",
21628
+ "--porcelain",
21629
+ "--untracked-files=all",
21630
+ "--ignored=matching",
21631
+ "--",
21632
+ ...paths
21633
+ ],
21634
+ {
21635
+ encoding: "utf8",
21636
+ stdio: ["ignore", "pipe", "ignore"],
21637
+ maxBuffer: 16 * 1024 * 1024
21638
+ }
21639
+ );
21640
+ if (status.status !== 0 || status.stdout.trim().length > 0) return null;
21641
+ const oids = (0, import_node_child_process28.spawnSync)(
21642
+ "git",
21643
+ ["-C", realTop, "rev-parse", ...paths.map((entry) => `HEAD:${entry}`)],
21644
+ { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }
21645
+ );
21646
+ if (oids.status !== 0) return null;
21647
+ const keyHash = (0, import_node_crypto29.createHash)("sha256");
21648
+ keyHash.update("git-module-digest/v1\n");
21649
+ keyHash.update(oids.stdout);
21650
+ keyHash.update("\n");
21651
+ for (const file of files) keyHash.update(file).update("\n");
21652
+ return keyHash.digest("hex");
21653
+ }
21449
21654
  function swiftModuleDigest(root) {
21450
21655
  const files = swiftModuleInputFiles(root);
21451
21656
  const stampHash = (0, import_node_crypto29.createHash)("sha256");
21452
21657
  for (const file of files) {
21453
- const stat = (0, import_node_fs45.statSync)(import_node_path46.default.join(root, file), { bigint: true });
21658
+ const stat = (0, import_node_fs45.statSync)(import_node_path47.default.join(root, file), { bigint: true });
21454
21659
  stampHash.update(file);
21455
21660
  stampHash.update(
21456
21661
  `${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}
@@ -21460,11 +21665,17 @@ function swiftModuleDigest(root) {
21460
21665
  const stamp = stampHash.digest("hex");
21461
21666
  const cached2 = linkedModuleDigests.get(root);
21462
21667
  if (cached2?.stamp === stamp) return cached2.digest;
21463
- const record = import_node_path46.default.join(
21464
- swiftCacheDir(),
21465
- "swift-module-digests",
21668
+ const digestDir = import_node_path47.default.join(swiftCacheDir(), "swift-module-digests");
21669
+ const record = import_node_path47.default.join(
21670
+ digestDir,
21466
21671
  `${(0, import_node_crypto29.createHash)("sha256").update(root).digest("hex")}.json`
21467
21672
  );
21673
+ const writeRecord = (target, body) => {
21674
+ (0, import_node_fs45.mkdirSync)(import_node_path47.default.dirname(target), { recursive: true });
21675
+ const partial = `${target}.${process.pid}.${(0, import_node_crypto29.randomUUID)()}`;
21676
+ (0, import_node_fs45.writeFileSync)(partial, body);
21677
+ (0, import_node_fs45.renameSync)(partial, target);
21678
+ };
21468
21679
  if ((0, import_node_fs45.existsSync)(record)) {
21469
21680
  const saved = JSON.parse((0, import_node_fs45.readFileSync)(record, "utf8"));
21470
21681
  if (saved && typeof saved === "object" && Reflect.get(saved, "stamp") === stamp && typeof Reflect.get(saved, "digest") === "string") {
@@ -21473,19 +21684,30 @@ function swiftModuleDigest(root) {
21473
21684
  return digest2;
21474
21685
  }
21475
21686
  }
21687
+ const gitKey = gitCleanModuleInputsKey(root, files);
21688
+ const gitRecord = gitKey ? import_node_path47.default.join(digestDir, `git-${gitKey}.json`) : null;
21689
+ if (gitRecord && (0, import_node_fs45.existsSync)(gitRecord)) {
21690
+ const saved = JSON.parse((0, import_node_fs45.readFileSync)(gitRecord, "utf8"));
21691
+ if (saved && typeof saved === "object" && typeof Reflect.get(saved, "digest") === "string") {
21692
+ const hex2 = String(Reflect.get(saved, "digest"));
21693
+ const digest2 = Buffer.from(hex2, "hex");
21694
+ linkedModuleDigests.set(root, { stamp, digest: digest2 });
21695
+ writeRecord(record, JSON.stringify({ stamp, digest: hex2 }));
21696
+ return digest2;
21697
+ }
21698
+ }
21476
21699
  const hash = (0, import_node_crypto29.createHash)("sha256");
21477
21700
  for (const file of files) {
21478
21701
  hash.update((0, import_node_crypto29.createHash)("sha256").update(file).digest());
21479
21702
  hash.update(
21480
- (0, import_node_crypto29.createHash)("sha256").update((0, import_node_fs45.readFileSync)(import_node_path46.default.join(root, file))).digest()
21703
+ (0, import_node_crypto29.createHash)("sha256").update((0, import_node_fs45.readFileSync)(import_node_path47.default.join(root, file))).digest()
21481
21704
  );
21482
21705
  }
21483
21706
  const digest = hash.digest();
21707
+ const hex = digest.toString("hex");
21484
21708
  linkedModuleDigests.set(root, { stamp, digest });
21485
- (0, import_node_fs45.mkdirSync)(import_node_path46.default.dirname(record), { recursive: true });
21486
- const partial = `${record}.${process.pid}.${(0, import_node_crypto29.randomUUID)()}`;
21487
- (0, import_node_fs45.writeFileSync)(partial, JSON.stringify({ stamp, digest: digest.toString("hex") }));
21488
- (0, import_node_fs45.renameSync)(partial, record);
21709
+ writeRecord(record, JSON.stringify({ stamp, digest: hex }));
21710
+ if (gitRecord) writeRecord(gitRecord, JSON.stringify({ digest: hex }));
21489
21711
  return digest;
21490
21712
  }
21491
21713
  function swiftCompileSurfaceDigest(root) {
@@ -21548,7 +21770,7 @@ function withNativeSourceGlue(input, glue) {
21548
21770
  ...input,
21549
21771
  files: {
21550
21772
  ...input.files,
21551
- [import_node_path46.default.posix.join(targetPath, "OneNativeSource.generated.swift")]: glue
21773
+ [import_node_path47.default.posix.join(targetPath, "OneNativeSource.generated.swift")]: glue
21552
21774
  },
21553
21775
  oneModule: true
21554
21776
  };
@@ -21636,7 +21858,7 @@ function swiftImportNames(contents2, available) {
21636
21858
  function swiftPeachModules(moduleRoot) {
21637
21859
  const distribution = swiftDistributionAt(moduleRoot);
21638
21860
  return distribution ? distribution.modules : swiftManifestDeclarations(
21639
- (0, import_node_fs45.readFileSync)(import_node_path46.default.join(moduleRoot, "Package.swift"), "utf8")
21861
+ (0, import_node_fs45.readFileSync)(import_node_path47.default.join(moduleRoot, "Package.swift"), "utf8")
21640
21862
  ).filter((target) => !target.executable && !target.path.startsWith("fixtures/")).map((target) => target.name);
21641
21863
  }
21642
21864
  function swiftSdkPaths(moduleRoot, toolchainBin, options = swiftCompileSdkOptions(moduleRoot, toolchainBin)) {
@@ -21645,7 +21867,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin, options = swiftCompileSdkOption
21645
21867
  const cached2 = sdkPaths.get(key);
21646
21868
  if (cached2) return cached2;
21647
21869
  const configuration = (0, import_node_child_process28.execFileSync)(
21648
- import_node_path46.default.join(toolchainBin, "swift"),
21870
+ import_node_path47.default.join(toolchainBin, "swift"),
21649
21871
  ["sdk", "configure", ...options, "--show-configuration", sdk, SWIFT_WASM_TRIPLE],
21650
21872
  { encoding: "utf8", env: swiftEnvironment(), stdio: ["ignore", "pipe", "pipe"] }
21651
21873
  );
@@ -21679,7 +21901,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin, options = swiftCompileSdkOption
21679
21901
  if (flag !== "-fwasm-exceptions") cFlags.push(flag);
21680
21902
  if (flag === "-iframeworkwithsysroot" && options2[index + 2] === "-Xcc" && typeof options2[index + 3] === "string") {
21681
21903
  cFlags.push(options2[index + 3]);
21682
- frameworks.push(import_node_path46.default.join(sysroot, options2[index + 3]));
21904
+ frameworks.push(import_node_path47.default.join(sysroot, options2[index + 3]));
21683
21905
  index += 3;
21684
21906
  continue;
21685
21907
  }
@@ -21696,7 +21918,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin, options = swiftCompileSdkOption
21696
21918
  }
21697
21919
  const paths = {
21698
21920
  sysroot,
21699
- darwin: import_node_path46.default.join(sysroot, "darwin"),
21921
+ darwin: import_node_path47.default.join(sysroot, "darwin"),
21700
21922
  resources: field("swiftResourcesPath"),
21701
21923
  frameworks,
21702
21924
  cFlags
@@ -21722,22 +21944,22 @@ function swiftOverlayFrameworks(moduleRoot, toolchainBin) {
21722
21944
  const { darwin, resources, frameworks } = swiftSdkPaths(moduleRoot, toolchainBin);
21723
21945
  const swiftModules = new Set(swiftPeachModules(moduleRoot));
21724
21946
  const result = /* @__PURE__ */ new Set();
21725
- const include = import_node_path46.default.join(darwin, "usr/include");
21947
+ const include = import_node_path47.default.join(darwin, "usr/include");
21726
21948
  for (const entry of (0, import_node_fs45.readdirSync)(include))
21727
21949
  if (entry.endsWith(".modulemap"))
21728
21950
  addSwiftOverlayFrameworks(
21729
- (0, import_node_fs45.readFileSync)(import_node_path46.default.join(include, entry), "utf8"),
21951
+ (0, import_node_fs45.readFileSync)(import_node_path47.default.join(include, entry), "utf8"),
21730
21952
  swiftModules,
21731
21953
  result
21732
21954
  );
21733
21955
  for (const entry of (0, import_node_fs45.readdirSync)(resources)) {
21734
- const map = import_node_path46.default.join(resources, entry, "module.modulemap");
21956
+ const map = import_node_path47.default.join(resources, entry, "module.modulemap");
21735
21957
  if ((0, import_node_fs45.existsSync)(map))
21736
21958
  addSwiftOverlayFrameworks((0, import_node_fs45.readFileSync)(map, "utf8"), swiftModules, result);
21737
21959
  }
21738
21960
  for (const directory of frameworks)
21739
21961
  for (const entry of (0, import_node_fs45.readdirSync)(directory)) {
21740
- const map = import_node_path46.default.join(directory, entry, "Modules/module.modulemap");
21962
+ const map = import_node_path47.default.join(directory, entry, "Modules/module.modulemap");
21741
21963
  if ((0, import_node_fs45.existsSync)(map))
21742
21964
  addSwiftOverlayFrameworks((0, import_node_fs45.readFileSync)(map, "utf8"), swiftModules, result);
21743
21965
  }
@@ -21755,10 +21977,10 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
21755
21977
  toolchainBin
21756
21978
  );
21757
21979
  const maps = /* @__PURE__ */ new Set([
21758
- import_node_path46.default.join(darwin, "usr/include/module.modulemap"),
21980
+ import_node_path47.default.join(darwin, "usr/include/module.modulemap"),
21759
21981
  ...cFlags.filter((flag) => flag.startsWith("-fmodule-map-file=")).map((flag) => {
21760
21982
  const file = flag.slice("-fmodule-map-file=".length);
21761
- return file.startsWith("=") ? import_node_path46.default.join(sysroot, file.slice(1)) : file;
21983
+ return file.startsWith("=") ? import_node_path47.default.join(sysroot, file.slice(1)) : file;
21762
21984
  })
21763
21985
  ]);
21764
21986
  for (const map of maps) {
@@ -21769,35 +21991,35 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
21769
21991
  ))
21770
21992
  modules.add(match[1]);
21771
21993
  for (const match of contents2.matchAll(/^\s*extern\s+module\s+\w+\s+"([^"]+)"/gm))
21772
- maps.add(import_node_path46.default.resolve(import_node_path46.default.dirname(map), match[1]));
21994
+ maps.add(import_node_path47.default.resolve(import_node_path47.default.dirname(map), match[1]));
21773
21995
  }
21774
- for (const entry of (0, import_node_fs45.readdirSync)(import_node_path46.default.join(resources, "wasi"))) {
21996
+ for (const entry of (0, import_node_fs45.readdirSync)(import_node_path47.default.join(resources, "wasi"))) {
21775
21997
  if (entry.endsWith(".swiftmodule"))
21776
21998
  modules.add(entry.slice(0, -".swiftmodule".length));
21777
21999
  }
21778
22000
  for (const entry of (0, import_node_fs45.readdirSync)(resources)) {
21779
- const map = import_node_path46.default.join(resources, entry, "module.modulemap");
22001
+ const map = import_node_path47.default.join(resources, entry, "module.modulemap");
21780
22002
  if (!(0, import_node_fs45.existsSync)(map)) continue;
21781
22003
  for (const match of (0, import_node_fs45.readFileSync)(map, "utf8").matchAll(/^module\s+([A-Za-z_]\w*)/gm))
21782
22004
  modules.add(match[1]);
21783
22005
  }
21784
22006
  for (const libc of [
21785
- import_node_path46.default.join(darwin, "usr/include"),
21786
- import_node_path46.default.join(
22007
+ import_node_path47.default.join(darwin, "usr/include"),
22008
+ import_node_path47.default.join(
21787
22009
  swiftSharedSdkRoot(moduleRoot, swiftDistributionAt(moduleRoot) !== null),
21788
22010
  "usr/include"
21789
22011
  )
21790
22012
  ])
21791
22013
  for (const entry of (0, import_node_fs45.readdirSync)(libc)) {
21792
22014
  if (!entry.endsWith(".modulemap")) continue;
21793
- for (const match of (0, import_node_fs45.readFileSync)(import_node_path46.default.join(libc, entry), "utf8").matchAll(
22015
+ for (const match of (0, import_node_fs45.readFileSync)(import_node_path47.default.join(libc, entry), "utf8").matchAll(
21794
22016
  /^module\s+([A-Za-z_]\w*)/gm
21795
22017
  ))
21796
22018
  modules.add(match[1]);
21797
22019
  }
21798
22020
  for (const directory of frameworks) {
21799
22021
  for (const entry of (0, import_node_fs45.readdirSync)(directory)) {
21800
- const map = import_node_path46.default.join(directory, entry, "Modules/module.modulemap");
22022
+ const map = import_node_path47.default.join(directory, entry, "Modules/module.modulemap");
21801
22023
  if (!(0, import_node_fs45.existsSync)(map)) continue;
21802
22024
  for (const match of (0, import_node_fs45.readFileSync)(map, "utf8").matchAll(
21803
22025
  /^framework\s+module\s+([A-Za-z_]\w*)/gm
@@ -21850,15 +22072,15 @@ function swiftSystemLibraryExclusions(files, targets, distributionModules) {
21850
22072
  );
21851
22073
  }
21852
22074
  function distributionClangModulePresent(modules, name3) {
21853
- return (0, import_node_fs45.existsSync)(import_node_path46.default.join(modules, `${name3}.swiftmodule`)) || (0, import_node_fs45.existsSync)(import_node_path46.default.join(modules, name3, "module.modulemap"));
22075
+ return (0, import_node_fs45.existsSync)(import_node_path47.default.join(modules, `${name3}.swiftmodule`)) || (0, import_node_fs45.existsSync)(import_node_path47.default.join(modules, name3, "module.modulemap"));
21854
22076
  }
21855
22077
  function distributionClangModuleMap(root, modules) {
21856
22078
  const missing = DISTRIBUTION_CLANG_MODULES.filter(
21857
22079
  (mod) => !distributionClangModulePresent(modules, mod.name)
21858
22080
  );
21859
22081
  if (missing.length === 0) return null;
21860
- const directory = import_node_path46.default.join(root, CLANG_DISTRIBUTION_MODULES);
21861
- const mapPath = import_node_path46.default.join(directory, "module.modulemap");
22082
+ const directory = import_node_path47.default.join(root, CLANG_DISTRIBUTION_MODULES);
22083
+ const mapPath = import_node_path47.default.join(directory, "module.modulemap");
21862
22084
  const map = missing.map(
21863
22085
  (mod) => `module ${mod.name} {
21864
22086
  requires objc
@@ -21869,7 +22091,7 @@ function distributionClangModuleMap(root, modules) {
21869
22091
  ).join("\n");
21870
22092
  if ((0, import_node_fs45.existsSync)(mapPath) && (0, import_node_fs45.readFileSync)(mapPath, "utf8") !== map)
21871
22093
  (0, import_node_fs45.rmSync)(directory, { recursive: true, force: true });
21872
- for (const mod of missing) writeBuildFile(import_node_path46.default.join(directory, mod.header), mod.source);
22094
+ for (const mod of missing) writeBuildFile(import_node_path47.default.join(directory, mod.header), mod.source);
21873
22095
  writeBuildFile(mapPath, map);
21874
22096
  return mapPath;
21875
22097
  }
@@ -21881,14 +22103,14 @@ function providedModulesPath(root, modules, excluded) {
21881
22103
  if (!excluded || excluded.size === 0) return modules;
21882
22104
  const entries2 = (0, import_node_fs45.readdirSync)(modules).filter((entry) => !excluded.has(entry.replace(/\..*$/, ""))).sort();
21883
22105
  const key = (0, import_node_crypto29.createHash)("sha256").update(JSON.stringify([modules, entries2])).update([...excluded].sort().join("\0")).digest("hex").slice(0, 16);
21884
- const directory = import_node_path46.default.join(root, `.peach-modules-${key}`);
21885
- const complete = import_node_path46.default.join(directory, ".complete");
22106
+ const directory = import_node_path47.default.join(root, `.peach-modules-${key}`);
22107
+ const complete = import_node_path47.default.join(directory, ".complete");
21886
22108
  if (!(0, import_node_fs45.existsSync)(complete)) {
21887
22109
  (0, import_node_fs45.mkdirSync)(directory, { recursive: true });
21888
22110
  for (const entry of (0, import_node_fs45.readdirSync)(directory))
21889
- (0, import_node_fs45.rmSync)(import_node_path46.default.join(directory, entry), { recursive: true, force: true });
22111
+ (0, import_node_fs45.rmSync)(import_node_path47.default.join(directory, entry), { recursive: true, force: true });
21890
22112
  for (const entry of entries2) {
21891
- (0, import_node_fs45.symlinkSync)(import_node_path46.default.join(modules, entry), import_node_path46.default.join(directory, entry));
22113
+ (0, import_node_fs45.symlinkSync)(import_node_path47.default.join(modules, entry), import_node_path47.default.join(directory, entry));
21892
22114
  }
21893
22115
  (0, import_node_fs45.writeFileSync)(complete, "");
21894
22116
  }
@@ -21902,7 +22124,7 @@ function swiftTargetDependencies(files, targets, frameworks = OPTIONAL_FRAMEWORK
21902
22124
  );
21903
22125
  const names = /* @__PURE__ */ new Set([...frameworks, ...targets.map((target) => target.name)]);
21904
22126
  const entriesByPrefix = new Map(
21905
- targets.map(({ path: path42 }) => [path42 === "." ? "" : `${path42}/`, []])
22127
+ targets.map(({ path: path43 }) => [path43 === "." ? "" : `${path43}/`, []])
21906
22128
  );
21907
22129
  for (const entry of Object.entries(files)) {
21908
22130
  const [file] = entry;
@@ -21937,7 +22159,7 @@ function swiftTargetDependencies(files, targets, frameworks = OPTIONAL_FRAMEWORK
21937
22159
  (excluded) => relative === excluded || relative.startsWith(`${excluded}/`)
21938
22160
  ))
21939
22161
  continue;
21940
- if (nested.some((path42) => file.startsWith(path42))) continue;
22162
+ if (nested.some((path43) => file.startsWith(path43))) continue;
21941
22163
  const imports = file.endsWith(".swift") ? swiftImportNames(contents2) : SWIFT_NATIVE_SOURCE_EXTENSIONS.some((extension) => file.endsWith(extension)) ? clangImportNames(contents2, ownsHeader) : [];
21942
22164
  for (const name3 of imports) {
21943
22165
  if (names.has(name3) && name3 !== target.name && !(target.dependencies !== void 0 && localNames.has(name3)))
@@ -22082,14 +22304,14 @@ ${target}
22082
22304
  }
22083
22305
  function swiftCrossImportFlags(moduleRoot, distribution) {
22084
22306
  const manifest = distribution ? swiftDistributionAt(moduleRoot) : null;
22085
- const overlayRoot = manifest ? import_node_path46.default.join(moduleRoot, "modules") : import_node_path46.default.join(moduleRoot, "cross-import-overlays");
22307
+ const overlayRoot = manifest ? import_node_path47.default.join(moduleRoot, "modules") : import_node_path47.default.join(moduleRoot, "cross-import-overlays");
22086
22308
  return (0, import_node_fs45.readdirSync)(overlayRoot, { encoding: "utf8", recursive: true }).filter((file) => file.endsWith(".swiftoverlay")).sort((left, right) => left.localeCompare(right)).flatMap((file) => [
22087
22309
  "-Xfrontend",
22088
22310
  "-swift-module-cross-import",
22089
22311
  "-Xfrontend",
22090
- import_node_path46.default.basename(import_node_path46.default.dirname(file), ".swiftcrossimport"),
22312
+ import_node_path47.default.basename(import_node_path47.default.dirname(file), ".swiftcrossimport"),
22091
22313
  "-Xfrontend",
22092
- import_node_path46.default.join(overlayRoot, file)
22314
+ import_node_path47.default.join(overlayRoot, file)
22093
22315
  ]);
22094
22316
  }
22095
22317
  function withoutWasmOverlayIsystem(flags) {
@@ -22119,7 +22341,7 @@ function emitSwiftPackageManifest(args) {
22119
22341
  distribution
22120
22342
  } = args;
22121
22343
  const prebuilt = args.prebuilt;
22122
- const distributionModules = distribution ? import_node_path46.default.join(moduleRoot, "modules") : void 0;
22344
+ const distributionModules = distribution ? import_node_path47.default.join(moduleRoot, "modules") : void 0;
22123
22345
  const linkedObjects = Boolean(distribution || prebuilt);
22124
22346
  const cxxFlagsFor = (flags) => args.deferDarwinOverlay ? withoutWasmOverlayIsystem(flags) : flags;
22125
22347
  const packageModules = new Set(
@@ -22152,7 +22374,7 @@ function emitSwiftPackageManifest(args) {
22152
22374
  let distributionLinkPath;
22153
22375
  const distributionLink = args.distributionLink;
22154
22376
  if (distribution && distributionLink) {
22155
- const isProvider = (object3) => object3.startsWith(`lib/${DARWIN_RECORDS_PREFIX}`);
22377
+ const isProvider = (object4) => object4.startsWith(`lib/${DARWIN_RECORDS_PREFIX}`);
22156
22378
  const sourceModules = new Set(
22157
22379
  targets.filter(
22158
22380
  (target) => args.sourceSwiftTargets?.has(target.name) && !args.native?.get(target.name)?.clang
@@ -22161,32 +22383,32 @@ function emitSwiftPackageManifest(args) {
22161
22383
  const product = v6.parse(
22162
22384
  swiftFrameworkProductSchema,
22163
22385
  JSON.parse(
22164
- (0, import_node_fs45.readFileSync)(import_node_path46.default.join(moduleRoot, SWIFT_FRAMEWORK_PRODUCT_FILE), "utf8")
22386
+ (0, import_node_fs45.readFileSync)(import_node_path47.default.join(moduleRoot, SWIFT_FRAMEWORK_PRODUCT_FILE), "utf8")
22165
22387
  )
22166
22388
  );
22167
22389
  const replacedObjects = new Set(
22168
- product.objects.filter((object3) => sourceModules.has(swiftTargetModuleName(object3.target))).map((object3) => object3.path)
22390
+ product.objects.filter((object4) => sourceModules.has(swiftTargetModuleName(object4.target))).map((object4) => object4.path)
22169
22391
  );
22170
22392
  const available = distribution.objects.filter(
22171
- (object3) => !isProvider(object3) && !replacedObjects.has(object3)
22393
+ (object4) => !isProvider(object4) && !replacedObjects.has(object4)
22172
22394
  );
22173
22395
  const objects = available.filter(
22174
- (object3) => !targets.some((target) => object3.startsWith(`lib/${target.name}-`)) && [...OPTIONAL_FRAMEWORKS, ...GAME_FAMILY, "PeachBox2D"].every(
22175
- (name3) => !object3.startsWith(`lib/${name3}-`) || reachedFrameworks.has(name3)
22396
+ (object4) => !targets.some((target) => object4.startsWith(`lib/${target.name}-`)) && [...OPTIONAL_FRAMEWORKS, ...GAME_FAMILY, "PeachBox2D"].every(
22397
+ (name3) => !object4.startsWith(`lib/${name3}-`) || reachedFrameworks.has(name3)
22176
22398
  )
22177
22399
  );
22178
- const quoted2 = (object3) => `"${import_node_path46.default.join(moduleRoot, object3).replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
22400
+ const quoted2 = (object4) => `"${import_node_path47.default.join(moduleRoot, object4).replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
22179
22401
  const categoryObjects = new Set(
22180
22402
  foundationCategoryObjects.map((name3) => `lib/Foundation-${name3}.o`)
22181
22403
  );
22182
22404
  const roots = swiftObjcRootObjects(distribution.id, moduleRoot, distribution.objects);
22183
22405
  const eager = new Set(
22184
- objects.filter((object3) => roots.has(object3) || categoryObjects.has(object3))
22406
+ objects.filter((object4) => roots.has(object4) || categoryObjects.has(object4))
22185
22407
  );
22186
22408
  const list = [
22187
22409
  ...[...eager].map(quoted2),
22188
22410
  "-Wl,--start-lib",
22189
- ...available.filter((object3) => !eager.has(object3)).map(quoted2),
22411
+ ...available.filter((object4) => !eager.has(object4)).map(quoted2),
22190
22412
  "-Wl,--end-lib",
22191
22413
  ...darwinRecordsRegion(distribution.objects.filter(isProvider).map(quoted2))
22192
22414
  ].join("\n") + "\n";
@@ -22214,7 +22436,7 @@ function emitSwiftPackageManifest(args) {
22214
22436
  if (run5.length >= MODULE_MAP_RESPONSE_FILE_RUN) {
22215
22437
  const lines = run5.map((flag) => JSON.stringify(flag)).join("\n") + "\n";
22216
22438
  const digest2 = (0, import_node_crypto29.createHash)("sha256").update(lines).digest("hex");
22217
- const file2 = import_node_path46.default.join(args.root, ".peach-clang-arguments", `${digest2}.rsp`);
22439
+ const file2 = import_node_path47.default.join(args.root, ".peach-clang-arguments", `${digest2}.rsp`);
22218
22440
  args.files.set(file2, lines);
22219
22441
  flags.push(`@${file2}`);
22220
22442
  } else flags.push(...run5);
@@ -22238,7 +22460,7 @@ function emitSwiftPackageManifest(args) {
22238
22460
  endRun();
22239
22461
  const content = JSON.stringify(flags);
22240
22462
  const digest = (0, import_node_crypto29.createHash)("sha256").update(content).digest("hex");
22241
- const file = import_node_path46.default.join(args.root, ".peach-manifest-arguments", `${digest}.json`);
22463
+ const file = import_node_path47.default.join(args.root, ".peach-manifest-arguments", `${digest}.json`);
22242
22464
  args.files.set(file, content);
22243
22465
  return `peachCompilerArguments(${JSON.stringify(file)})`;
22244
22466
  };
@@ -22250,7 +22472,7 @@ function emitSwiftPackageManifest(args) {
22250
22472
  const compact = args.coalescibleOverlays ? compactSwiftClangOverlays(macros, args.coalescibleOverlays) : macros;
22251
22473
  const content = compact.map((flag) => JSON.stringify(flag)).join("\n") + "\n";
22252
22474
  const digest = (0, import_node_crypto29.createHash)("sha256").update(content).digest("hex");
22253
- const file = import_node_path46.default.join(args.root, ".peach-swift-arguments", `${digest}.rsp`);
22475
+ const file = import_node_path47.default.join(args.root, ".peach-swift-arguments", `${digest}.rsp`);
22254
22476
  args.files.set(file, content);
22255
22477
  return JSON.stringify([`@${file}`]);
22256
22478
  };
@@ -22262,7 +22484,7 @@ function emitSwiftPackageManifest(args) {
22262
22484
  owner?.publicHeadersPath ?? ""
22263
22485
  );
22264
22486
  return [
22265
- ...owner && framework ? [import_node_path46.default.posix.join(args.root, owner.path, framework[1])] : [],
22487
+ ...owner && framework ? [import_node_path47.default.posix.join(args.root, owner.path, framework[1])] : [],
22266
22488
  ...frameworkDirectories(dependency, seen)
22267
22489
  ];
22268
22490
  });
@@ -22305,7 +22527,7 @@ function emitSwiftPackageManifest(args) {
22305
22527
  const stanza = (target) => {
22306
22528
  const native = args.native?.get(target.name);
22307
22529
  if (target.systemLibrary || native?.clang?.sources.length === 0)
22308
- return ` .systemLibrary(name: ${JSON.stringify(target.name)}, path: ${JSON.stringify(native?.clang ? import_node_path46.default.posix.dirname(native.clang.modulemap) : target.path)}),`;
22530
+ return ` .systemLibrary(name: ${JSON.stringify(target.name)}, path: ${JSON.stringify(native?.clang ? import_node_path47.default.posix.dirname(native.clang.modulemap) : target.path)}),`;
22309
22531
  const isolation = target.mainActorIsolation ? " .defaultIsolation(MainActor.self)," : "";
22310
22532
  const interoperability = target.cxxInterop ? " .interoperabilityMode(.Cxx)," : "";
22311
22533
  const defines = (target.defines ?? []).map((name3) => ` .define(${JSON.stringify(name3)}),`).join("");
@@ -22363,7 +22585,7 @@ function emitSwiftPackageManifest(args) {
22363
22585
  ].map((flag) => `, ${JSON.stringify(flag)}`).join("");
22364
22586
  const header = args.headerDirectory && (args.nativeHeaderDeclarations?.[target.name] || [...args.native?.values() ?? []].some(
22365
22587
  (value) => value.late?.producers.includes(target.name)
22366
- )) ? `, "-emit-objc-header-path", ${JSON.stringify(import_node_path46.default.join(args.headerDirectory, `${target.name}-Swift.original.h`))}` : "";
22588
+ )) ? `, "-emit-objc-header-path", ${JSON.stringify(import_node_path47.default.join(args.headerDirectory, `${target.name}-Swift.original.h`))}` : "";
22367
22589
  const clangMode = target.cxxInterop ? "" : ', "-Xcc", "-fno-cxx-modules"';
22368
22590
  const deployment = `, "-Xfrontend", "-peach-ios-deployment-target", "-Xfrontend", ${JSON.stringify(target.iosDeploymentTarget ?? SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET)}`;
22369
22591
  const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation}${interoperability}${defines}${features}${upcoming} .unsafeFlags(${swiftFlagArray(`["-Osize", "-Xfrontend", "-enable-cross-import-overlays"${overlayFlags}${oneModule ? ONE_IMPLICIT_FLAGS : ""}${imports}${nativeImportFlags}${objcFlags}${header}${clangMode}${deployment}${upstream}]`)})]`;
@@ -22567,7 +22789,7 @@ function syncSwiftTree(base, files) {
22567
22789
  for (const file of files.keys()) if ((0, import_node_fs45.existsSync)(file)) kept.add((0, import_node_fs45.statSync)(file).ino);
22568
22790
  const walk = (dir) => {
22569
22791
  for (const entry of (0, import_node_fs45.readdirSync)(dir, { withFileTypes: true })) {
22570
- const full = import_node_path46.default.join(dir, entry.name);
22792
+ const full = import_node_path47.default.join(dir, entry.name);
22571
22793
  if (dir === base && (entry.name === ".build" || entry.name === SWIFT_CACHE_HOLD_MARKER || entry.name.startsWith(".peach-modules-") || // distribution clang maps are written beside the project, so a sync
22572
22794
  // must not remove them.
22573
22795
  entry.name === CLANG_DISTRIBUTION_MODULES || entry.name === SWIFT_DISTRIBUTION_MIRROR || entry.name === SWIFT_LINK_STAMP))
@@ -22708,7 +22930,7 @@ function compiledSwiftSources(files, targets, overlayFrameworks, headers, native
22708
22930
  const { onWasm, withoutWasm } = swiftTargetArchitectures(targets, swiftSources, headers);
22709
22931
  return new Map(
22710
22932
  [...owners].map(([file, { source, owner }]) => {
22711
- if (nativeSourceGlue && import_node_path46.default.posix.basename(file) === "OneNativeSource.generated.swift")
22933
+ if (nativeSourceGlue && import_node_path47.default.posix.basename(file) === "OneNativeSource.generated.swift")
22712
22934
  return [file, source];
22713
22935
  const manifest = /(?:^|\/)Package(?:@swift-[\d.]+)?\.swift$/.test(file);
22714
22936
  if (manifest && (!owner || /^Package(?:@swift-[\d.]+)?\.swift$/.test(file)))
@@ -22975,7 +23197,7 @@ function swiftApplicationEntry(file, source) {
22975
23197
  else if (source[at] === "}") depth--;
22976
23198
  else if (depth === 0 && /^@(?:main|UIApplicationMain)\b/.test(source.slice(at)))
22977
23199
  return true;
22978
- else if (depth === 0 && import_node_path46.default.basename(file) === "main.swift" && /^UIApplicationMain\s*\(/.test(source.slice(at)))
23200
+ else if (depth === 0 && import_node_path47.default.basename(file) === "main.swift" && /^UIApplicationMain\s*\(/.test(source.slice(at)))
22979
23201
  return true;
22980
23202
  }
22981
23203
  return false;
@@ -23356,16 +23578,16 @@ function prepareSwiftDependency(source, destination, overlayFrameworks) {
23356
23578
  for (const entry of (0, import_node_fs45.readdirSync)(from, { withFileTypes: true })) {
23357
23579
  if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
23358
23580
  continue;
23359
- const file = import_node_path46.default.join(from, entry.name);
23581
+ const file = import_node_path47.default.join(from, entry.name);
23360
23582
  if (entry.isDirectory()) gather(file);
23361
23583
  else if (entry.isFile() && entry.name.endsWith(".swift"))
23362
- origins[import_node_path46.default.relative(source, file)] = (0, import_node_fs45.readFileSync)(file, "utf8");
23584
+ origins[import_node_path47.default.relative(source, file)] = (0, import_node_fs45.readFileSync)(file, "utf8");
23363
23585
  else if (entry.isFile() && entry.name.endsWith(".modulemap"))
23364
23586
  moduleMaps.push((0, import_node_fs45.readFileSync)(file, "utf8"));
23365
23587
  }
23366
23588
  };
23367
23589
  gather(source);
23368
- const manifest = import_node_path46.default.join(source, "Package.swift");
23590
+ const manifest = import_node_path47.default.join(source, "Package.swift");
23369
23591
  const targets = (0, import_node_fs45.existsSync)(manifest) ? swiftManifestTargets(
23370
23592
  (0, import_node_fs45.readFileSync)(manifest, "utf8"),
23371
23593
  [],
@@ -23397,11 +23619,11 @@ function prepareSwiftDependency(source, destination, overlayFrameworks) {
23397
23619
  for (const entry of (0, import_node_fs45.readdirSync)(from, { withFileTypes: true })) {
23398
23620
  if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
23399
23621
  continue;
23400
- const file = import_node_path46.default.join(from, entry.name);
23401
- const target = import_node_path46.default.join(to, entry.name);
23622
+ const file = import_node_path47.default.join(from, entry.name);
23623
+ const target = import_node_path47.default.join(to, entry.name);
23402
23624
  if (entry.isDirectory()) copy(file, target);
23403
23625
  else if (entry.isFile() && entry.name.endsWith(".swift"))
23404
- (0, import_node_fs45.writeFileSync)(target, compiled.get(import_node_path46.default.relative(source, file)));
23626
+ (0, import_node_fs45.writeFileSync)(target, compiled.get(import_node_path47.default.relative(source, file)));
23405
23627
  else (0, import_node_fs45.cpSync)(file, target, { verbatimSymlinks: true });
23406
23628
  }
23407
23629
  };
@@ -23456,18 +23678,18 @@ function withoutRepeatedClangFlags(flags) {
23456
23678
  }
23457
23679
  function clangImportModuleMapFlags(settings, layoutRoot, written, generated) {
23458
23680
  const searched = new Set(settings.headerSearchPaths);
23459
- const directory = import_node_path46.default.join(layoutRoot, ".build", "peach-clang-modulemaps");
23681
+ const directory = import_node_path47.default.join(layoutRoot, ".build", "peach-clang-modulemaps");
23460
23682
  return (settings.moduleMaps ?? []).flatMap((map) => {
23461
- const headers = import_node_path46.default.join(layoutRoot, map.headers);
23683
+ const headers = import_node_path47.default.join(layoutRoot, map.headers);
23462
23684
  if (!(0, import_node_fs45.existsSync)(headers)) return [];
23463
- const published = import_node_path46.default.join(headers, "module.modulemap");
23685
+ const published = import_node_path47.default.join(headers, "module.modulemap");
23464
23686
  if (searched.has(map.headers) && (0, import_node_fs45.existsSync)(published)) return [];
23465
23687
  if (!searched.has(map.headers) && (0, import_node_fs45.existsSync)(published))
23466
23688
  return [`-fmodule-map-file=${published}`];
23467
23689
  const cached2 = written.get(headers);
23468
23690
  if (cached2) return [cached2];
23469
23691
  (0, import_node_fs45.mkdirSync)(directory, { recursive: true });
23470
- const output = import_node_path46.default.join(directory, `module-${written.size}.modulemap`);
23692
+ const output = import_node_path47.default.join(directory, `module-${written.size}.modulemap`);
23471
23693
  writeBuildFile(
23472
23694
  output,
23473
23695
  swiftPackageClangModuleMap(swiftTargetModuleName(map.module), {
@@ -23527,11 +23749,11 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
23527
23749
  input.resourcePaths
23528
23750
  );
23529
23751
  const distribution = swiftDistributionAt(moduleRoot);
23530
- const distributionModules = distribution ? import_node_path46.default.join(moduleRoot, "modules") : void 0;
23752
+ const distributionModules = distribution ? import_node_path47.default.join(moduleRoot, "modules") : void 0;
23531
23753
  const targets = distribution && compileTargets(input).length === 0 ? [
23532
23754
  {
23533
23755
  name: "App",
23534
- path: import_node_path46.default.relative(layout2.root, layout2.sources),
23756
+ path: import_node_path47.default.relative(layout2.root, layout2.sources),
23535
23757
  executable: true,
23536
23758
  languageMode: 5,
23537
23759
  mainActorIsolation: false,
@@ -23557,12 +23779,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
23557
23779
  if (!file.endsWith(".swift")) continue;
23558
23780
  const target = bySourcePath.find(
23559
23781
  (candidate) => (candidate.path === "." || file.startsWith(`${candidate.path}/`)) && (candidate.sources === void 0 || candidate.sources.some((source) => {
23560
- const selected = import_node_path46.default.posix.join(candidate.path, source);
23782
+ const selected = import_node_path47.default.posix.join(candidate.path, source);
23561
23783
  return file === selected || file.startsWith(`${selected}/`);
23562
23784
  }))
23563
23785
  );
23564
23786
  const excluded = target?.exclude?.some(
23565
- (name3) => file === import_node_path46.default.posix.join(target.path, name3)
23787
+ (name3) => file === import_node_path47.default.posix.join(target.path, name3)
23566
23788
  );
23567
23789
  if (target && !excluded) swiftTargets.add(target.name);
23568
23790
  }
@@ -23588,23 +23810,23 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
23588
23810
  ([file, contents2]) => /\.(?:swift|h|m|mm)$/.test(file) ? [contents2.toString()] : []
23589
23811
  )
23590
23812
  );
23591
- const headerDirectory = import_node_path46.default.join(layout2.root, ".build", "peach-cxx-headers");
23813
+ const headerDirectory = import_node_path47.default.join(layout2.root, ".build", "peach-cxx-headers");
23592
23814
  if ((0, import_node_fs45.existsSync)(headerDirectory)) {
23593
23815
  for (const entry of (0, import_node_fs45.readdirSync)(headerDirectory, { withFileTypes: true }))
23594
23816
  if (entry.isDirectory() && !targets.some((target) => target.name === entry.name))
23595
- (0, import_node_fs45.rmSync)(import_node_path46.default.join(headerDirectory, entry.name), { recursive: true, force: true });
23817
+ (0, import_node_fs45.rmSync)(import_node_path47.default.join(headerDirectory, entry.name), { recursive: true, force: true });
23596
23818
  }
23597
23819
  let checkedToolchain;
23598
23820
  const nativeToolchain = () => {
23599
23821
  if (checkedToolchain) return checkedToolchain;
23600
- const pin = distribution ?? JSON.parse((0, import_node_fs45.readFileSync)(import_node_path46.default.join(moduleRoot, "toolchain.json"), "utf8"));
23822
+ const pin = distribution ?? JSON.parse((0, import_node_fs45.readFileSync)(import_node_path47.default.join(moduleRoot, "toolchain.json"), "utf8"));
23601
23823
  checkedToolchain = swiftToolchain(pin.release, swiftModuleSdk(moduleRoot));
23602
23824
  return checkedToolchain;
23603
23825
  };
23604
23826
  const deploymentTarget = (name3) => input.nativeTargets?.find((value) => value.name === name3)?.deploymentTarget ?? targets.find((value) => value.name === name3)?.iosDeploymentTarget ?? null;
23605
23827
  const targetStagedFiles = /* @__PURE__ */ new Map();
23606
23828
  const stageTargetFile = (target, file, contents2, options) => {
23607
- const relative = import_node_path46.default.relative(layout2.root, file).split(import_node_path46.default.sep).join(import_node_path46.default.posix.sep);
23829
+ const relative = import_node_path47.default.relative(layout2.root, file).split(import_node_path47.default.sep).join(import_node_path47.default.posix.sep);
23608
23830
  const prior = files.has(file) ? files.get(file) : Object.hasOwn(input.files, relative) ? input.files[relative] : void 0;
23609
23831
  if (!options?.allowExisting && prior !== void 0)
23610
23832
  throw new Error(`target ${target} already contains generated output ${relative}`);
@@ -23617,7 +23839,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
23617
23839
  const prefix = target.path === "." ? "" : `${target.path}/`;
23618
23840
  return Object.entries(input.files).filter(
23619
23841
  ([file]) => file.startsWith(prefix) && (target.sources === void 0 || !(file.endsWith(".swift") || isSwiftNativeTranslationUnit(file)) || target.sources.some((source) => {
23620
- const selected = import_node_path46.default.posix.join(prefix, source);
23842
+ const selected = import_node_path47.default.posix.join(prefix, source);
23621
23843
  return file === selected || file.startsWith(`${selected}/`);
23622
23844
  })) && !target.exclude?.some(
23623
23845
  (excluded) => file === `${prefix}${excluded}` || file.startsWith(`${prefix}${excluded}/`)
@@ -23638,7 +23860,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
23638
23860
  targetStagedFiles.delete(target.name);
23639
23861
  if (entries2.some(([file]) => isSwiftNativeTranslationUnit(file)) && (swift || input.nativeTargets?.some((value) => value.name === target.name))) {
23640
23862
  if (!swift) {
23641
- const unprepared = import_node_path46.default.join(
23863
+ const unprepared = import_node_path47.default.join(
23642
23864
  layout2.root,
23643
23865
  target.path,
23644
23866
  "PeachUnprepared.generated.swift"
@@ -23653,7 +23875,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
23653
23875
  native.set(target.name, {
23654
23876
  mixed: true,
23655
23877
  path: target.path,
23656
- includeDirectory: import_node_path46.default.join(layout2.root, target.path, "include"),
23878
+ includeDirectory: import_node_path47.default.join(layout2.root, target.path, "include"),
23657
23879
  sources: [],
23658
23880
  lateSources: [],
23659
23881
  exclude: entries2.filter(([file]) => !file.endsWith(".swift") && !file.endsWith(".metal")).map(([file]) => file.slice(prefix.length))
@@ -23675,15 +23897,15 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
23675
23897
  file
23676
23898
  )?.[1];
23677
23899
  if (owner)
23678
- podHeaders.set(import_node_path46.default.basename(file), [
23679
- ...podHeaders.get(import_node_path46.default.basename(file)) ?? [],
23900
+ podHeaders.set(import_node_path47.default.basename(file), [
23901
+ ...podHeaders.get(import_node_path47.default.basename(file)) ?? [],
23680
23902
  { owner, content: input.files[file] }
23681
23903
  ]);
23682
23904
  }
23683
- const podHeaderOwner = (file, content) => /\/Headers\/(?:Public|Private)\/([\w+-]+)\//.exec(file)?.[1] ?? podHeaders.get(import_node_path46.default.basename(file))?.find((header) => header.content === content)?.owner;
23905
+ const podHeaderOwner = (file, content) => /\/Headers\/(?:Public|Private)\/([\w+-]+)\//.exec(file)?.[1] ?? podHeaders.get(import_node_path47.default.basename(file))?.find((header) => header.content === content)?.owner;
23684
23906
  for (const settings of input.nativeTargets ?? []) {
23685
23907
  for (const file of settings.headers) {
23686
- const destination = import_node_path46.default.join(layout2.root, file);
23908
+ const destination = import_node_path47.default.join(layout2.root, file);
23687
23909
  if (files.has(destination)) continue;
23688
23910
  const interfaceModule = /(?:^|\/)(\w+)-Swift\.h$/.exec(file)?.[1];
23689
23911
  const frameworkHeader = !interfaceModule && /(?:^|\/)(\w+)\.framework\/Headers\/[\w+.-]+\.h$/.exec(file)?.[1];
@@ -23702,35 +23924,35 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
23702
23924
  }
23703
23925
  }
23704
23926
  const nativeTargets = input.nativeTargets ?? [];
23705
- const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ? import_node_path46.default.join(layout2.root, file.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1)) : file;
23706
- const inRoot = `${layout2.root}${import_node_path46.default.sep}`;
23707
- const binaryTree = `${import_node_path46.default.sep}${SWIFT_BINARY_TREES_DIR}${import_node_path46.default.sep}`;
23927
+ const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ? import_node_path47.default.join(layout2.root, file.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1)) : file;
23928
+ const inRoot = `${layout2.root}${import_node_path47.default.sep}`;
23929
+ const binaryTree = `${import_node_path47.default.sep}${SWIFT_BINARY_TREES_DIR}${import_node_path47.default.sep}`;
23708
23930
  const headerSearch = writeXcodeHeaderSearch(
23709
- import_node_path46.default.join(layout2.root, ".build", "peach-xcode-headers"),
23931
+ import_node_path47.default.join(layout2.root, ".build", "peach-xcode-headers"),
23710
23932
  nativeTargets.map((settings) => {
23711
23933
  const productHeaders = {};
23712
23934
  const publishedHeaders = /* @__PURE__ */ new Set();
23713
23935
  const moduleName = swiftTargetModuleName(settings.name);
23714
23936
  for (const [product, file] of Object.entries(settings.productHeaders)) {
23715
- const header = import_node_path46.default.join(layout2.root, file);
23716
- productHeaders[import_node_path46.default.join(layout2.root, product)] = header;
23937
+ const header = import_node_path47.default.join(layout2.root, file);
23938
+ productHeaders[import_node_path47.default.join(layout2.root, product)] = header;
23717
23939
  const framework = /^(.+\.framework)\/((?:Private)?Headers\/.+)$/.exec(product);
23718
23940
  if (framework && Object.hasOwn(
23719
23941
  settings.productHeaders,
23720
23942
  `${framework[1]}/Modules/module.modulemap`
23721
23943
  )) {
23722
- productHeaders[import_node_path46.default.join(layout2.root, framework[1], "Modules", framework[2])] = header;
23723
- if (import_node_path46.default.posix.basename(framework[1]) === `${moduleName}.framework` && framework[2] === `Headers/${import_node_path46.default.posix.basename(file)}`)
23944
+ productHeaders[import_node_path47.default.join(layout2.root, framework[1], "Modules", framework[2])] = header;
23945
+ if (import_node_path47.default.posix.basename(framework[1]) === `${moduleName}.framework` && framework[2] === `Headers/${import_node_path47.default.posix.basename(file)}`)
23724
23946
  publishedHeaders.add(file);
23725
23947
  }
23726
23948
  }
23727
23949
  if (settings.flattensPublicHeaders)
23728
23950
  for (const file of settings.publicHeaders) {
23729
23951
  if (publishedHeaders.has(file)) continue;
23730
- const alias = import_node_path46.default.join(headerDirectory, settings.name, import_node_path46.default.basename(file));
23952
+ const alias = import_node_path47.default.join(headerDirectory, settings.name, import_node_path47.default.basename(file));
23731
23953
  if (Object.hasOwn(productHeaders, alias))
23732
23954
  throw new Error(`duplicate product header ${alias}`);
23733
- productHeaders[alias] = import_node_path46.default.join(layout2.root, file);
23955
+ productHeaders[alias] = import_node_path47.default.join(layout2.root, file);
23734
23956
  }
23735
23957
  return {
23736
23958
  headerMaps: settings.headerMaps.map((map) => ({
@@ -23742,18 +23964,18 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
23742
23964
  })),
23743
23965
  productHeaders,
23744
23966
  userHeaderSearchPaths: settings.userHeaderSearchPaths.map(
23745
- (directory) => import_node_path46.default.join(layout2.root, directory)
23967
+ (directory) => import_node_path47.default.join(layout2.root, directory)
23746
23968
  ),
23747
23969
  searchDirectories: [
23748
23970
  ...settings.headerSearchPaths,
23749
23971
  ...settings.frameworkSearchPaths
23750
- ].map((directory) => import_node_path46.default.join(layout2.root, directory))
23972
+ ].map((directory) => import_node_path47.default.join(layout2.root, directory))
23751
23973
  };
23752
23974
  }),
23753
23975
  Object.fromEntries(
23754
23976
  Object.entries(input.headerAliases ?? {}).map(([alias, file]) => [
23755
- import_node_path46.default.join(layout2.root, alias),
23756
- import_node_path46.default.join(layout2.root, file)
23977
+ import_node_path47.default.join(layout2.root, alias),
23978
+ import_node_path47.default.join(layout2.root, file)
23757
23979
  ])
23758
23980
  ),
23759
23981
  (file) => !file.startsWith(inRoot) || files.has(file) || file.includes(binaryTree)
@@ -23797,9 +24019,9 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
23797
24019
  const producer = /(?:^|\/)([^/]+)-Swift\.h$/.exec(include)?.[1];
23798
24020
  if (producer && swiftTargets.has(producer)) producers2.add(producer);
23799
24021
  const local = [
23800
- import_node_path46.default.posix.join(import_node_path46.default.posix.dirname(file), include),
24022
+ import_node_path47.default.posix.join(import_node_path47.default.posix.dirname(file), include),
23801
24023
  `${includes}${include}`,
23802
- ...searchRoots.map((root) => import_node_path46.default.posix.join(root, include))
24024
+ ...searchRoots.map((root) => import_node_path47.default.posix.join(root, include))
23803
24025
  ].find((candidate) => input.files[candidate] !== void 0);
23804
24026
  if (local) {
23805
24027
  reverse.set(local, [...reverse.get(local) ?? [], file]);
@@ -23842,7 +24064,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
23842
24064
  );
23843
24065
  const roots2 = settings.bridgingHeader ? [settings.bridgingHeader] : entries2.some(([file]) => file.endsWith(".swift")) || importedModules.has(swiftTargetModuleName(target.name)) ? settings.publicHeaders : [];
23844
24066
  const search = [.../* @__PURE__ */ new Set([...settings?.headerSearchPaths ?? []])].flatMap(
23845
- (dir) => ["-I", import_node_path46.default.join(layout2.root, dir)]
24067
+ (dir) => ["-I", import_node_path47.default.join(layout2.root, dir)]
23846
24068
  );
23847
24069
  const toolchainBin = nativeToolchain();
23848
24070
  const stageFlags = (flags2, sdkInclude2) => flags2.map(
@@ -23854,7 +24076,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
23854
24076
  ...search,
23855
24077
  ...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
23856
24078
  "-F",
23857
- import_node_path46.default.join(layout2.root, dir)
24079
+ import_node_path47.default.join(layout2.root, dir)
23858
24080
  ]),
23859
24081
  "-I",
23860
24082
  headerDirectory
@@ -23865,7 +24087,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
23865
24087
  ...search,
23866
24088
  ...settings.frameworkSearchPaths.flatMap((dir) => [
23867
24089
  "-F",
23868
- import_node_path46.default.join(layout2.root, dir)
24090
+ import_node_path47.default.join(layout2.root, dir)
23869
24091
  ]),
23870
24092
  "-I",
23871
24093
  headerDirectory
@@ -23875,13 +24097,13 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
23875
24097
  const flag = settings.importerFlags[index];
23876
24098
  if (flag === "-I" || flag === "-iquote") {
23877
24099
  const directory = settings.importerFlags[index + 1];
23878
- if (directory === void 0 || !import_node_path46.default.isAbsolute(directory)) {
24100
+ if (directory === void 0 || !import_node_path47.default.isAbsolute(directory)) {
23879
24101
  index++;
23880
24102
  continue;
23881
24103
  }
23882
24104
  }
23883
24105
  const joined = /^-(?:I|iquote)(.+)$/.exec(flag);
23884
- if (joined && !import_node_path46.default.isAbsolute(joined[1])) continue;
24106
+ if (joined && !import_node_path47.default.isAbsolute(joined[1])) continue;
23885
24107
  kept.push(flag);
23886
24108
  }
23887
24109
  return [
@@ -23890,13 +24112,13 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
23890
24112
  ...search,
23891
24113
  ...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
23892
24114
  "-F",
23893
- import_node_path46.default.join(layout2.root, dir)
24115
+ import_node_path47.default.join(layout2.root, dir)
23894
24116
  ]),
23895
24117
  "-I",
23896
24118
  headerDirectory
23897
24119
  ];
23898
24120
  })();
23899
- const sdkInclude = import_node_path46.default.join(
24121
+ const sdkInclude = import_node_path47.default.join(
23900
24122
  swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
23901
24123
  "darwin/usr/include"
23902
24124
  );
@@ -23911,7 +24133,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
23911
24133
  ...dependencyModuleMaps,
23912
24134
  ...xcodeTarget && !target.defines?.includes("SWIFT_PACKAGE") ? ["-USWIFT_PACKAGE"] : []
23913
24135
  ];
23914
- const prefixHeader = settings?.prefixHeader ? ["-include", import_node_path46.default.join(layout2.root, settings.prefixHeader)] : [];
24136
+ const prefixHeader = settings?.prefixHeader ? ["-include", import_node_path47.default.join(layout2.root, settings.prefixHeader)] : [];
23915
24137
  const bundleName = entries2.some(([file]) => file.endsWith(".swift")) ? void 0 : swiftObjCResourceBundleName({
23916
24138
  target: target.name,
23917
24139
  path: target.path,
@@ -23922,7 +24144,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
23922
24144
  bundles: input.resourceBundles
23923
24145
  });
23924
24146
  const accessor = bundleName === void 0 ? void 0 : swiftObjCResourceAccessor(bundleName);
23925
- const accessorHeader = import_node_path46.default.join(
24147
+ const accessorHeader = import_node_path47.default.join(
23926
24148
  layout2.root,
23927
24149
  target.path,
23928
24150
  OBJC_RESOURCE_ACCESSOR_HEADER
@@ -23933,7 +24155,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
23933
24155
  const nativeUnits = accessor ? [...units, [accessorUnit, accessor.body]] : units;
23934
24156
  const unitSource = (file) => {
23935
24157
  const relative = file.slice(prefix.length);
23936
- return relative.split("/").some((part) => part.startsWith(".")) ? import_node_path46.default.posix.join(HIDDEN_UNITS, relative.replaceAll(/(^|\/)\./g, "$1%2E")) : relative;
24158
+ return relative.split("/").some((part) => part.startsWith(".")) ? import_node_path47.default.posix.join(HIDDEN_UNITS, relative.replaceAll(/(^|\/)\./g, "$1%2E")) : relative;
23937
24159
  };
23938
24160
  const accessorFlags = accessor ? ["-include", accessorHeader] : [];
23939
24161
  const nativeC = !entries2.some(([file]) => file.endsWith(".swift"));
@@ -23963,20 +24185,20 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
23963
24185
  )
23964
24186
  ].sort();
23965
24187
  const topHeaders = settings.publicHeaders.filter(
23966
- (file) => import_node_path46.default.posix.dirname(file) === headerDir
24188
+ (file) => import_node_path47.default.posix.dirname(file) === headerDir
23967
24189
  );
23968
24190
  if (input.files[custom] !== void 0) {
23969
24191
  swiftpmModuleMap = { path: custom, contents: input.files[custom] };
23970
24192
  } else if (input.files[umbrella] !== void 0) {
23971
24193
  if (siblingDirs.length > 0)
23972
24194
  throw new Error(
23973
- `target ${target.name} has invalid header layout: umbrella header found at '${import_node_path46.default.join(layout2.root, umbrella)}', but directories exist next to it: ${siblingDirs.map((name3) => import_node_path46.default.join(layout2.root, headerDir, name3)).join(", ")}; consider removing them`
24195
+ `target ${target.name} has invalid header layout: umbrella header found at '${import_node_path47.default.join(layout2.root, umbrella)}', but directories exist next to it: ${siblingDirs.map((name3) => import_node_path47.default.join(layout2.root, headerDir, name3)).join(", ")}; consider removing them`
23974
24196
  );
23975
24197
  swiftpmModuleMap = {
23976
24198
  path: custom,
23977
24199
  contents: swiftPackageClangModuleMap(moduleName, {
23978
24200
  kind: "header",
23979
- path: import_node_path46.default.join(layout2.root, umbrella)
24201
+ path: import_node_path47.default.join(layout2.root, umbrella)
23980
24202
  })
23981
24203
  };
23982
24204
  } else if (input.files[nestedUmbrella] !== void 0 && siblingDirs.length === 1 && siblingDirs[0] === moduleName && topHeaders.length === 0) {
@@ -23984,7 +24206,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
23984
24206
  path: custom,
23985
24207
  contents: swiftPackageClangModuleMap(moduleName, {
23986
24208
  kind: "header",
23987
- path: import_node_path46.default.join(layout2.root, nestedUmbrella)
24209
+ path: import_node_path47.default.join(layout2.root, nestedUmbrella)
23988
24210
  })
23989
24211
  };
23990
24212
  } else {
@@ -23992,12 +24214,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
23992
24214
  path: custom,
23993
24215
  contents: swiftPackageClangModuleMap(moduleName, {
23994
24216
  kind: "directory",
23995
- path: import_node_path46.default.join(layout2.root, headerDir)
24217
+ path: import_node_path47.default.join(layout2.root, headerDir)
23996
24218
  })
23997
24219
  };
23998
24220
  }
23999
24221
  }
24000
- const modulemap = (originalModuleMap ? originalModuleMap[0].endsWith("/Modules/module.modulemap") ? originalModuleMap[0] : originalModuleMap[1] : void 0) ?? swiftpmModuleMap?.path ?? packageModuleMap?.[0] ?? import_node_path46.default.posix.join(
24222
+ const modulemap = (originalModuleMap ? originalModuleMap[0].endsWith("/Modules/module.modulemap") ? originalModuleMap[0] : originalModuleMap[1] : void 0) ?? swiftpmModuleMap?.path ?? packageModuleMap?.[0] ?? import_node_path47.default.posix.join(
24001
24223
  ".build",
24002
24224
  "peach-objc-originals",
24003
24225
  target.name,
@@ -24005,59 +24227,59 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
24005
24227
  );
24006
24228
  const moduleContents = originalModuleMap ? input.files[originalModuleMap[1]] : swiftpmModuleMap?.contents ?? packageModuleMap?.[1] ?? swiftObjCModuleMap(
24007
24229
  swiftTargetModuleName(target.name),
24008
- roots2.map((file) => import_node_path46.default.join(layout2.root, file)),
24230
+ roots2.map((file) => import_node_path47.default.join(layout2.root, file)),
24009
24231
  submoduleImports2.get(swiftTargetModuleName(target.name))
24010
24232
  );
24011
24233
  if (moduleContents === void 0)
24012
24234
  throw new Error("missing original module map " + modulemap);
24013
24235
  const framework = nativeC && moduleMapTokens(moduleContents.toString())[0] === "framework" ? /^(.*)\/[^/]+\.framework\/Modules\/module\.modulemap$/.exec(modulemap) : null;
24014
- const frameworkDirectory = framework ? import_node_path46.default.join(layout2.root, framework[1]) : void 0;
24015
- stageTargetFile(target.name, import_node_path46.default.join(layout2.root, modulemap), moduleContents, {
24236
+ const frameworkDirectory = framework ? import_node_path47.default.join(layout2.root, framework[1]) : void 0;
24237
+ stageTargetFile(target.name, import_node_path47.default.join(layout2.root, modulemap), moduleContents, {
24016
24238
  allowExisting: true
24017
24239
  });
24018
24240
  sourceModuleMaps.set(swiftTargetModuleName(target.name), {
24019
- path: import_node_path46.default.join(layout2.root, modulemap),
24241
+ path: import_node_path47.default.join(layout2.root, modulemap),
24020
24242
  contents: moduleContents.toString()
24021
24243
  });
24022
- if (nativeC && import_node_path46.default.posix.basename(modulemap) !== "module.modulemap") {
24244
+ if (nativeC && import_node_path47.default.posix.basename(modulemap) !== "module.modulemap") {
24023
24245
  stageTargetFile(
24024
24246
  target.name,
24025
- import_node_path46.default.join(layout2.root, import_node_path46.default.posix.dirname(modulemap), "module.modulemap"),
24026
- `extern module ${swiftTargetModuleName(target.name)} ${JSON.stringify(import_node_path46.default.join(layout2.root, modulemap))}
24247
+ import_node_path47.default.join(layout2.root, import_node_path47.default.posix.dirname(modulemap), "module.modulemap"),
24248
+ `extern module ${swiftTargetModuleName(target.name)} ${JSON.stringify(import_node_path47.default.join(layout2.root, modulemap))}
24027
24249
  `
24028
24250
  );
24029
24251
  }
24030
24252
  const importFlags = [
24031
24253
  ...swiftClangImporterFlags(stageFlags(importOriginalFlags, sdkInclude)),
24032
- "-fmodule-map-file=" + import_node_path46.default.join(layout2.root, modulemap),
24254
+ "-fmodule-map-file=" + import_node_path47.default.join(layout2.root, modulemap),
24033
24255
  ...dependencyModuleMaps
24034
24256
  ];
24035
24257
  const groups = /* @__PURE__ */ new Map();
24036
24258
  for (const [file, contents2] of nativeUnits) {
24037
24259
  const origin = settings?.sourceDirectories[file];
24038
24260
  if (origin) {
24039
- const original = import_node_path46.default.join(layout2.root, origin, import_node_path46.default.posix.basename(file));
24040
- (0, import_node_fs45.mkdirSync)(import_node_path46.default.dirname(original), { recursive: true });
24261
+ const original = import_node_path47.default.join(layout2.root, origin, import_node_path47.default.posix.basename(file));
24262
+ (0, import_node_fs45.mkdirSync)(import_node_path47.default.dirname(original), { recursive: true });
24041
24263
  stageTargetFile(target.name, original, contents2, { allowExisting: true });
24042
24264
  }
24043
24265
  const source = unitSource(file);
24044
24266
  if (source !== file.slice(prefix.length))
24045
24267
  stageTargetFile(
24046
24268
  target.name,
24047
- import_node_path46.default.join(layout2.root, target.path, source),
24269
+ import_node_path47.default.join(layout2.root, target.path, source),
24048
24270
  contents2,
24049
24271
  {
24050
24272
  allowExisting: true
24051
24273
  }
24052
24274
  );
24053
- const stagedDir = import_node_path46.default.posix.dirname(file);
24275
+ const stagedDir = import_node_path47.default.posix.dirname(file);
24054
24276
  const quoteDirs = [
24055
24277
  ...stagedDir !== "." ? [stagedDir] : [],
24056
24278
  ...origin && origin !== stagedDir ? [origin] : []
24057
24279
  ];
24058
24280
  const quoteFlags = quoteDirs.flatMap((dir) => [
24059
24281
  "-iquote",
24060
- import_node_path46.default.join(layout2.root, dir)
24282
+ import_node_path47.default.join(layout2.root, dir)
24061
24283
  ]);
24062
24284
  const fileFlags = settings.fileFlags[file] ?? [];
24063
24285
  const objcCxx = fileFlags.includes(SWIFT_OBJCXX_LANGUAGE_FLAG);
@@ -24068,7 +24290,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
24068
24290
  .../\.mm?$/.test(file) ? ["-fobjc-exceptions"] : [],
24069
24291
  ...stageFlags(
24070
24292
  [...objcCxx ? settings.cxxFlags : [], ...fileFlags],
24071
- import_node_path46.default.join(
24293
+ import_node_path47.default.join(
24072
24294
  swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
24073
24295
  "darwin/usr/include"
24074
24296
  )
@@ -24079,17 +24301,17 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
24079
24301
  JSON.stringify([
24080
24302
  cxx,
24081
24303
  quoteDirs,
24082
- perFile.map((flag) => flag.replaceAll(layout2.root + import_node_path46.default.sep, "")),
24304
+ perFile.map((flag) => flag.replaceAll(layout2.root + import_node_path47.default.sep, "")),
24083
24305
  (consumers.get(file)?.size ?? 0) > 0
24084
24306
  ])
24085
24307
  ).digest("hex").slice(0, 12);
24086
24308
  const name3 = `${target.name}${nativeC ? "Native" : "Swift"}Implementation_${identity}`;
24087
- const groupPath = import_node_path46.default.posix.join("PeachNativeSources", name3);
24088
- const canonicalTargetPath = import_node_path46.default.posix.join("/peach/build", target.path);
24309
+ const groupPath = import_node_path47.default.posix.join("PeachNativeSources", name3);
24310
+ const canonicalTargetPath = import_node_path47.default.posix.join("/peach/build", target.path);
24089
24311
  const sourceIdentity = [
24090
- `-ffile-prefix-map=${import_node_path46.default.join(layout2.root, groupPath)}=${canonicalTargetPath}`,
24312
+ `-ffile-prefix-map=${import_node_path47.default.join(layout2.root, groupPath)}=${canonicalTargetPath}`,
24091
24313
  ...nativeToolset ? [
24092
- `-ffile-prefix-map=${import_node_path46.default.posix.join("/peach/build", groupPath)}=${canonicalTargetPath}`
24314
+ `-ffile-prefix-map=${import_node_path47.default.posix.join("/peach/build", groupPath)}=${canonicalTargetPath}`
24093
24315
  ] : []
24094
24316
  ];
24095
24317
  const group = groups.get(identity) ?? {
@@ -24113,7 +24335,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
24113
24335
  ...accessorFlags,
24114
24336
  ...stageFlags(
24115
24337
  cxx ? settings.cxxFlags : [],
24116
- import_node_path46.default.join(
24338
+ import_node_path47.default.join(
24117
24339
  swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
24118
24340
  "darwin/usr/include"
24119
24341
  )
@@ -24124,12 +24346,12 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
24124
24346
  };
24125
24347
  stageTargetFile(
24126
24348
  target.name,
24127
- import_node_path46.default.join(layout2.root, group.path, source),
24349
+ import_node_path47.default.join(layout2.root, group.path, source),
24128
24350
  contents2
24129
24351
  );
24130
24352
  stageTargetFile(
24131
24353
  target.name,
24132
- import_node_path46.default.join(layout2.root, group.path, "include/module.modulemap"),
24354
+ import_node_path47.default.join(layout2.root, group.path, "include/module.modulemap"),
24133
24355
  `module ${swiftTargetModuleName(group.name)} { export * }
24134
24356
  `,
24135
24357
  { allowExisting: true }
@@ -24147,7 +24369,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
24147
24369
  stageTargetFile(target.name, accessorHeader, accessor.header);
24148
24370
  stageTargetFile(
24149
24371
  target.name,
24150
- import_node_path46.default.join(layout2.root, accessorUnit),
24372
+ import_node_path47.default.join(layout2.root, accessorUnit),
24151
24373
  accessor.body
24152
24374
  );
24153
24375
  }
@@ -24162,7 +24384,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
24162
24384
  ].sort();
24163
24385
  native.set(target.name, {
24164
24386
  path: target.path,
24165
- includeDirectory: import_node_path46.default.dirname(import_node_path46.default.join(layout2.root, modulemap)),
24387
+ includeDirectory: import_node_path47.default.dirname(import_node_path47.default.join(layout2.root, modulemap)),
24166
24388
  importFlags,
24167
24389
  frameworkDirectory,
24168
24390
  sources: nativeUnits.map(([file]) => unitSource(file)),
@@ -24186,23 +24408,23 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
24186
24408
  throw new Error(`original module map declares no module: ${modulemap}`);
24187
24409
  stageTargetFile(
24188
24410
  target.name,
24189
- import_node_path46.default.join(layout2.root, owner.path, "include/module.modulemap"),
24190
- `extern module ${exportedModule} ${JSON.stringify(import_node_path46.default.join(layout2.root, modulemap))}
24411
+ import_node_path47.default.join(layout2.root, owner.path, "include/module.modulemap"),
24412
+ `extern module ${exportedModule} ${JSON.stringify(import_node_path47.default.join(layout2.root, modulemap))}
24191
24413
  `,
24192
24414
  { allowExisting: true }
24193
24415
  );
24194
24416
  }
24195
24417
  continue;
24196
24418
  }
24197
- const implementationHeaders = import_node_path46.default.posix.join(
24419
+ const implementationHeaders = import_node_path47.default.posix.join(
24198
24420
  ".build",
24199
24421
  "peach-objc-implementations",
24200
24422
  target.name
24201
24423
  );
24202
- const include = import_node_path46.default.join(layout2.root, implementationHeaders);
24424
+ const include = import_node_path47.default.join(layout2.root, implementationHeaders);
24203
24425
  stageTargetFile(
24204
24426
  target.name,
24205
- import_node_path46.default.join(include, "module.modulemap"),
24427
+ import_node_path47.default.join(include, "module.modulemap"),
24206
24428
  `module ${target.name}ImplementationDeclarations { export * }
24207
24429
  `
24208
24430
  );
@@ -24212,7 +24434,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
24212
24434
  includeDirectory: include,
24213
24435
  importFlags,
24214
24436
  swiftFlags: [
24215
- ...settings.bridgingHeader ? ["-import-objc-header", import_node_path46.default.join(layout2.root, settings.bridgingHeader)] : roots2.length ? ["-import-underlying-module"] : [],
24437
+ ...settings.bridgingHeader ? ["-import-objc-header", import_node_path47.default.join(layout2.root, settings.bridgingHeader)] : roots2.length ? ["-import-underlying-module"] : [],
24216
24438
  ...importFlags.flatMap((flag) => ["-Xcc", flag])
24217
24439
  ],
24218
24440
  sources: nativeUnits.map(([file]) => unitSource(file)),
@@ -24243,7 +24465,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
24243
24465
  const textualIncludes = entries2.map(([file]) => file).filter((file) => /\.(?:inc|inl|ipp|def)$/.test(file));
24244
24466
  native.set(target.name, {
24245
24467
  path: target.path,
24246
- includeDirectory: import_node_path46.default.join(layout2.root, includes),
24468
+ includeDirectory: import_node_path47.default.join(layout2.root, includes),
24247
24469
  sources: units.map(([file]) => file.slice(prefix.length)),
24248
24470
  lateSources: late.map(([file]) => file.slice(prefix.length)),
24249
24471
  exclude: [
@@ -24260,21 +24482,21 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
24260
24482
  } : {}
24261
24483
  });
24262
24484
  if (late.length === 0) {
24263
- const headers = import_node_path46.default.posix.join(target.path, target.publicHeadersPath ?? "include");
24485
+ const headers = import_node_path47.default.posix.join(target.path, target.publicHeadersPath ?? "include");
24264
24486
  const fragments = textualIncludes.filter(
24265
24487
  (file) => headers === "." || file.startsWith(`${headers}/`)
24266
24488
  );
24267
24489
  const name3 = swiftTargetModuleName(target.name);
24268
- const map = import_node_path46.default.posix.join(headers, "module.modulemap");
24269
- if (fragments.length > 0 && !Object.hasOwn(input.files, map) && !files.has(import_node_path46.default.join(layout2.root, map)) && !Object.hasOwn(input.files, import_node_path46.default.posix.join(headers, `${name3}.h`)) && !Object.hasOwn(input.files, import_node_path46.default.posix.join(headers, name3, `${name3}.h`)))
24490
+ const map = import_node_path47.default.posix.join(headers, "module.modulemap");
24491
+ if (fragments.length > 0 && !Object.hasOwn(input.files, map) && !files.has(import_node_path47.default.join(layout2.root, map)) && !Object.hasOwn(input.files, import_node_path47.default.posix.join(headers, `${name3}.h`)) && !Object.hasOwn(input.files, import_node_path47.default.posix.join(headers, name3, `${name3}.h`)))
24270
24492
  stageTargetFile(
24271
24493
  target.name,
24272
- import_node_path46.default.join(layout2.root, map),
24494
+ import_node_path47.default.join(layout2.root, map),
24273
24495
  [
24274
24496
  `module ${name3} {`,
24275
24497
  ' umbrella "."',
24276
24498
  ...fragments.map(
24277
- (file) => ` textual header ${JSON.stringify(import_node_path46.default.posix.relative(headers, file))}`
24499
+ (file) => ` textual header ${JSON.stringify(import_node_path47.default.posix.relative(headers, file))}`
24278
24500
  ),
24279
24501
  " export *",
24280
24502
  "}",
@@ -24284,7 +24506,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
24284
24506
  continue;
24285
24507
  }
24286
24508
  files.set(
24287
- import_node_path46.default.join(layout2.root, target.path, "PeachSwiftImplementation/module.modulemap"),
24509
+ import_node_path47.default.join(layout2.root, target.path, "PeachSwiftImplementation/module.modulemap"),
24288
24510
  `module ${swiftTargetModuleName(`${target.name}SwiftImplementation`)} { export * }
24289
24511
  `
24290
24512
  );
@@ -24296,7 +24518,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
24296
24518
  ([file]) => file.startsWith(includes) && /\.(?:h|hpp|hh|hxx)$/.test(file) && consumers.get(file).size === 0
24297
24519
  );
24298
24520
  files.set(
24299
- import_node_path46.default.join(layout2.root, includes, "module.modulemap"),
24521
+ import_node_path47.default.join(layout2.root, includes, "module.modulemap"),
24300
24522
  [
24301
24523
  `module ${target.name} {`,
24302
24524
  ...roots.map(
@@ -24311,7 +24533,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
24311
24533
  for (const map of generatedModuleMaps)
24312
24534
  if (files.has(map.published) || Object.hasOwn(
24313
24535
  input.files,
24314
- import_node_path46.default.relative(layout2.root, map.published).split(import_node_path46.default.sep).join(import_node_path46.default.posix.sep)
24536
+ import_node_path47.default.relative(layout2.root, map.published).split(import_node_path47.default.sep).join(import_node_path47.default.posix.sep)
24315
24537
  ))
24316
24538
  writeBuildFile(
24317
24539
  map.output,
@@ -24340,10 +24562,10 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
24340
24562
  [...native.values()].flatMap((value) => value.late?.producers ?? [])
24341
24563
  )) {
24342
24564
  files.set(
24343
- import_node_path46.default.join(headerDirectory, name3, name3 + "-Swift.h"),
24565
+ import_node_path47.default.join(headerDirectory, name3, name3 + "-Swift.h"),
24344
24566
  '#include "../' + name3 + '-Swift.h"\n'
24345
24567
  );
24346
- const modulemap = import_node_path46.default.join(
24568
+ const modulemap = import_node_path47.default.join(
24347
24569
  layout2.root,
24348
24570
  ".build",
24349
24571
  "peach-objc-swift-headers",
@@ -24353,7 +24575,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
24353
24575
  const moduleName = swiftTargetModuleName(name3);
24354
24576
  const originalMap = originalMaps.get(moduleName);
24355
24577
  const stagedMap = sourceModuleMaps.get(moduleName);
24356
- const originalPath = stagedMap?.path ?? (originalMap ? import_node_path46.default.join(layout2.root, originalMap) : void 0);
24578
+ const originalPath = stagedMap?.path ?? (originalMap ? import_node_path47.default.join(layout2.root, originalMap) : void 0);
24357
24579
  const originalContents = stagedMap?.contents ?? (originalMap && input.files[originalMap]);
24358
24580
  const originalTokens = originalContents ? moduleMapTokens(originalContents) : [];
24359
24581
  if (originalPath && originalTokens.some(
@@ -24367,20 +24589,20 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
24367
24589
  modulemap,
24368
24590
  originalPath ? `extern module ${moduleName} ${JSON.stringify(originalPath)}
24369
24591
  module ${moduleName}.Swift {
24370
- header ${JSON.stringify(import_node_path46.default.join(headerDirectory, name3 + "-Swift.h"))}
24592
+ header ${JSON.stringify(import_node_path47.default.join(headerDirectory, name3 + "-Swift.h"))}
24371
24593
  requires objc
24372
24594
  }
24373
24595
  ` : swiftObjCModuleMap(
24374
24596
  moduleName,
24375
- (input.nativeTargets?.find((target) => target.name === name3)?.publicHeaders ?? []).map((header) => import_node_path46.default.join(layout2.root, header)),
24597
+ (input.nativeTargets?.find((target) => target.name === name3)?.publicHeaders ?? []).map((header) => import_node_path47.default.join(layout2.root, header)),
24376
24598
  submoduleImports2.get(moduleName),
24377
- import_node_path46.default.join(headerDirectory, name3 + "-Swift.h")
24599
+ import_node_path47.default.join(headerDirectory, name3 + "-Swift.h")
24378
24600
  )
24379
24601
  );
24380
24602
  nativeHeaderFlags.push("-fmodule-map-file=" + modulemap);
24381
24603
  nativeSwiftHeaderMaps.set(name3, modulemap);
24382
24604
  }
24383
- const providedFrameworks = import_node_path46.default.join(layout2.root, ".build", "peach-provided-frameworks");
24605
+ const providedFrameworks = import_node_path47.default.join(layout2.root, ".build", "peach-provided-frameworks");
24384
24606
  const probedProducts = /* @__PURE__ */ new Set();
24385
24607
  if (distribution) {
24386
24608
  for (const [file, contents2] of Object.entries(input.files))
@@ -24406,10 +24628,10 @@ module ${moduleName}.Swift {
24406
24628
  continue;
24407
24629
  const providedInterface = moduleInterface(name3);
24408
24630
  if (!providedInterface) continue;
24409
- const framework = import_node_path46.default.join(providedFrameworks, `${name3}.framework`);
24410
- files.set(import_node_path46.default.join(framework, "Headers", `${name3}.h`), providedInterface.header);
24631
+ const framework = import_node_path47.default.join(providedFrameworks, `${name3}.framework`);
24632
+ files.set(import_node_path47.default.join(framework, "Headers", `${name3}.h`), providedInterface.header);
24411
24633
  files.set(
24412
- import_node_path46.default.join(framework, "Modules", "module.modulemap"),
24634
+ import_node_path47.default.join(framework, "Modules", "module.modulemap"),
24413
24635
  `framework module ${name3} {
24414
24636
  umbrella header "${name3}.h"
24415
24637
  export *
@@ -24421,7 +24643,7 @@ module ${moduleName}.Swift {
24421
24643
  if ((0, import_node_fs45.existsSync)(providedFrameworks)) {
24422
24644
  for (const entry of (0, import_node_fs45.readdirSync)(providedFrameworks))
24423
24645
  if (!stagedProducts.includes(entry.replace(/\.framework$/, "")))
24424
- (0, import_node_fs45.rmSync)(import_node_path46.default.join(providedFrameworks, entry), { recursive: true, force: true });
24646
+ (0, import_node_fs45.rmSync)(import_node_path47.default.join(providedFrameworks, entry), { recursive: true, force: true });
24425
24647
  }
24426
24648
  const providedFrameworkFlags = stagedProducts.length ? ["-F", providedFrameworks] : [];
24427
24649
  const frameworkSearch = JSON.stringify([
@@ -24430,15 +24652,15 @@ module ${moduleName}.Swift {
24430
24652
  ...new Set(nativeTargets.flatMap((settings) => settings.frameworkSearchPaths))
24431
24653
  ].sort()
24432
24654
  ]);
24433
- const frameworkSearchRecord = import_node_path46.default.join(
24655
+ const frameworkSearchRecord = import_node_path47.default.join(
24434
24656
  layout2.root,
24435
24657
  ".build",
24436
24658
  "peach-framework-search.json"
24437
24659
  );
24438
24660
  if (!(0, import_node_fs45.existsSync)(frameworkSearchRecord) || (0, import_node_fs45.readFileSync)(frameworkSearchRecord, "utf8") !== frameworkSearch)
24439
24661
  for (const cache of [
24440
- import_node_path46.default.join(layout2.root, ".build", "ModuleCache"),
24441
- import_node_path46.default.join(layout2.root, ".build", WASM_TRIPLE, "release", "ModuleCache")
24662
+ import_node_path47.default.join(layout2.root, ".build", "ModuleCache"),
24663
+ import_node_path47.default.join(layout2.root, ".build", WASM_TRIPLE, "release", "ModuleCache")
24442
24664
  ])
24443
24665
  (0, import_node_fs45.rmSync)(cache, { recursive: true, force: true });
24444
24666
  files.set(frameworkSearchRecord, frameworkSearch);
@@ -24446,7 +24668,7 @@ module ${moduleName}.Swift {
24446
24668
  swiftModuleInputFiles(moduleRoot).join("\n")
24447
24669
  );
24448
24670
  if (!distribution) {
24449
- modulePlan.update((0, import_node_fs45.readFileSync)(import_node_path46.default.join(moduleRoot, "Package.swift")));
24671
+ modulePlan.update((0, import_node_fs45.readFileSync)(import_node_path47.default.join(moduleRoot, "Package.swift")));
24450
24672
  }
24451
24673
  modulePlan.update(
24452
24674
  Object.keys(input.files).filter((file) => file.endsWith(".swift")).sort().join("\n")
@@ -24501,7 +24723,7 @@ module ${moduleName}.Swift {
24501
24723
  (target) => {
24502
24724
  const native2 = input.nativeTargets?.find(({ name: name3 }) => name3 === target.name);
24503
24725
  if (native2) return native2.publicHeaders.map((file) => input.files[file] ?? "");
24504
- const directory = import_node_path46.default.posix.join(
24726
+ const directory = import_node_path47.default.posix.join(
24505
24727
  target.path,
24506
24728
  target.publicHeadersPath ?? "include"
24507
24729
  );
@@ -24537,7 +24759,7 @@ module ${moduleName}.Swift {
24537
24759
  `;
24538
24760
  } else if (mains.length === 0) {
24539
24761
  const procedural = entries2.filter(
24540
- ([file, source]) => import_node_path46.default.basename(file) === "main.swift" && swiftApplicationEntry(file, source)
24762
+ ([file, source]) => import_node_path47.default.basename(file) === "main.swift" && swiftApplicationEntry(file, source)
24541
24763
  );
24542
24764
  const wrapped = procedural.length === 1 ? wrapUIApplicationMainEntry(procedural[0][1]) : null;
24543
24765
  if (wrapped) {
@@ -24558,22 +24780,22 @@ module ${moduleName}.Swift {
24558
24780
  `mixed executable ${target.name} requires one typed Swift application entry`
24559
24781
  );
24560
24782
  const [file, source] = nativeMains[0];
24561
- const original = import_node_path46.default.join(layout2.root, file);
24783
+ const original = import_node_path47.default.join(layout2.root, file);
24562
24784
  const entry = neutralizedNativeMain(source);
24563
24785
  files.set(original, entry);
24564
24786
  const implementation = executableNativeUnits.get(file);
24565
24787
  if (implementation) {
24566
24788
  const unit = implementation.sources[implementation.index];
24567
- const extension = import_node_path46.default.posix.extname(unit);
24568
- const staged = import_node_path46.default.posix.basename(unit, extension) === "main" ? import_node_path46.default.posix.join(
24569
- import_node_path46.default.posix.dirname(unit),
24789
+ const extension = import_node_path47.default.posix.extname(unit);
24790
+ const staged = import_node_path47.default.posix.basename(unit, extension) === "main" ? import_node_path47.default.posix.join(
24791
+ import_node_path47.default.posix.dirname(unit),
24570
24792
  `PeachApplicationEntry.generated${extension}`
24571
24793
  ) : unit;
24572
- const directory = import_node_path46.default.join(layout2.root, implementation.path);
24573
- const destination = import_node_path46.default.join(directory, staged);
24794
+ const directory = import_node_path47.default.join(layout2.root, implementation.path);
24795
+ const destination = import_node_path47.default.join(directory, staged);
24574
24796
  if (staged !== unit && files.has(destination))
24575
24797
  throw new Error(`mixed application entry conflicts with ${destination}`);
24576
- files.delete(import_node_path46.default.join(directory, unit));
24798
+ files.delete(import_node_path47.default.join(directory, unit));
24577
24799
  files.set(destination, `#line 1 ${JSON.stringify(original)}
24578
24800
  ${entry}`);
24579
24801
  implementation.sources[implementation.index] = staged;
@@ -24587,9 +24809,9 @@ ${entry}`);
24587
24809
  }
24588
24810
  if (!nativeEntry) {
24589
24811
  compiled.set(entryFile, entrySource);
24590
- if (import_node_path46.default.basename(entryFile) === "main.swift") {
24591
- const libraryEntry = import_node_path46.default.posix.join(
24592
- import_node_path46.default.posix.dirname(entryFile),
24812
+ if (import_node_path47.default.basename(entryFile) === "main.swift") {
24813
+ const libraryEntry = import_node_path47.default.posix.join(
24814
+ import_node_path47.default.posix.dirname(entryFile),
24593
24815
  "PeachApplicationEntry.generated.swift"
24594
24816
  );
24595
24817
  if (Object.hasOwn(input.files, libraryEntry))
@@ -24613,7 +24835,7 @@ ${entry}`);
24613
24835
  exclude: []
24614
24836
  });
24615
24837
  files.set(
24616
- import_node_path46.default.join(layout2.root, `PeachApplication/${name3}/Entry.swift`),
24838
+ import_node_path47.default.join(layout2.root, `PeachApplication/${name3}/Entry.swift`),
24617
24839
  !nativeEntry ? `import ${swiftTargetModuleName(target.name)}
24618
24840
  @main struct __PeachApplicationEntry { @MainActor static func main() { __peachRunApplication() } }
24619
24841
  ` : `import ${swiftTargetModuleName(target.name)}
@@ -24645,7 +24867,7 @@ ${entry}`);
24645
24867
  );
24646
24868
  if (nativeFlags) {
24647
24869
  const toolchainBin = nativeToolchain();
24648
- const headers = import_node_path46.default.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, "darwin");
24870
+ const headers = import_node_path47.default.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, "darwin");
24649
24871
  const dependencies2 = swiftTargetDependencies(input.files, targets);
24650
24872
  const reachesNative = (name3, seen = /* @__PURE__ */ new Set()) => {
24651
24873
  if (native.has(name3)) return true;
@@ -24691,10 +24913,10 @@ ${entry}`);
24691
24913
  if (targets.length === 0 && !prebuilt) {
24692
24914
  for (const [file, contents2] of Object.entries(input.files)) {
24693
24915
  if (file === "Package.swift") continue;
24694
- files.set(import_node_path46.default.join(layout2.sources, file), compiled.get(file) ?? contents2);
24916
+ files.set(import_node_path47.default.join(layout2.sources, file), compiled.get(file) ?? contents2);
24695
24917
  }
24696
24918
  let manifest2 = (0, import_node_fs45.readFileSync)(
24697
- import_node_path46.default.join(moduleRoot, "scripts/contrast-app-Package.swift"),
24919
+ import_node_path47.default.join(moduleRoot, "scripts/contrast-app-Package.swift"),
24698
24920
  "utf8"
24699
24921
  ).replaceAll("__SOOTSIM_SWIFT_PACKAGE__", moduleRoot);
24700
24922
  const reactor = ` ${REACTOR_FLAG}`;
@@ -24741,16 +24963,16 @@ ${entry}`);
24741
24963
  [anchor, ...games.map((name3) => `${gameProduct(name3)},`)].join("\n ")
24742
24964
  );
24743
24965
  }
24744
- files.set(import_node_path46.default.join(layout2.root, "Package.swift"), manifest2 + moduleFiles);
24966
+ files.set(import_node_path47.default.join(layout2.root, "Package.swift"), manifest2 + moduleFiles);
24745
24967
  } else {
24746
24968
  const base = layout2.multi ? layout2.root : layout2.sources;
24747
24969
  const libraries = /* @__PURE__ */ new Map();
24748
- const binaryModules = import_node_path46.default.join(layout2.root, ".peach-binary-modules");
24970
+ const binaryModules = import_node_path47.default.join(layout2.root, ".peach-binary-modules");
24749
24971
  for (const [name3, data] of Object.entries(input.binaryModules ?? {})) {
24750
24972
  if (!/^[A-Za-z_]\w*$/.test(name3) || !input.libraries?.[name3])
24751
24973
  throw new Error(`invalid native Swift module ${name3}: its library is required`);
24752
24974
  files.set(
24753
- import_node_path46.default.join(binaryModules, `${name3}.swiftmodule`),
24975
+ import_node_path47.default.join(binaryModules, `${name3}.swiftmodule`),
24754
24976
  Buffer.from(data, "base64")
24755
24977
  );
24756
24978
  }
@@ -24761,7 +24983,7 @@ ${entry}`);
24761
24983
  const bytes = Buffer.from(data, "base64");
24762
24984
  const digest = (0, import_node_crypto29.createHash)("sha256").update(bytes).digest("hex");
24763
24985
  if (input.binaryModules?.[target] && packageTargets.has(target)) {
24764
- const objects = import_node_path46.default.join(
24986
+ const objects = import_node_path47.default.join(
24765
24987
  layout2.root,
24766
24988
  NATIVE_ARCHIVE_OBJECTS_DIR,
24767
24989
  `${target}.build`
@@ -24772,13 +24994,13 @@ ${entry}`);
24772
24994
  libraries.set(
24773
24995
  target,
24774
24996
  members.map(({ name: name3, bytes: bytes2 }, index) => {
24775
- const file = import_node_path46.default.join(objects, `${index}-${digest}-${import_node_path46.default.basename(name3)}`);
24997
+ const file = import_node_path47.default.join(objects, `${index}-${digest}-${import_node_path47.default.basename(name3)}`);
24776
24998
  files.set(file, Buffer.from(bytes2));
24777
24999
  return file;
24778
25000
  })
24779
25001
  );
24780
25002
  } else {
24781
- const file = import_node_path46.default.join(
25003
+ const file = import_node_path47.default.join(
24782
25004
  layout2.root,
24783
25005
  ".peach-libraries",
24784
25006
  `lib${target}-${digest}.a`
@@ -24789,13 +25011,13 @@ ${entry}`);
24789
25011
  }
24790
25012
  for (const [file, contents2] of Object.entries(input.files)) {
24791
25013
  if (file === "Package.swift") continue;
24792
- const destination = import_node_path46.default.join(base, libraryEntryFiles.get(file) ?? file);
25014
+ const destination = import_node_path47.default.join(base, libraryEntryFiles.get(file) ?? file);
24793
25015
  const interfaceModule = /(?:^|\/)(\w+)-Swift\.h$/.exec(file)?.[1];
24794
25016
  const localInterface = interfaceModule && swiftTargets.has(interfaceModule) ? `#include ${JSON.stringify(
24795
- import_node_path46.default.relative(
24796
- import_node_path46.default.dirname(destination),
24797
- import_node_path46.default.join(headerDirectory, `${interfaceModule}-Swift.h`)
24798
- ).split(import_node_path46.default.sep).join("/")
25017
+ import_node_path47.default.relative(
25018
+ import_node_path47.default.dirname(destination),
25019
+ import_node_path47.default.join(headerDirectory, `${interfaceModule}-Swift.h`)
25020
+ ).split(import_node_path47.default.sep).join("/")
24799
25021
  )}
24800
25022
  ` : void 0;
24801
25023
  files.set(
@@ -24806,7 +25028,7 @@ ${entry}`);
24806
25028
  const manifestTargets2 = targets.length > 0 ? targets : [
24807
25029
  {
24808
25030
  name: "App",
24809
- path: import_node_path46.default.relative(layout2.root, layout2.sources).split(import_node_path46.default.sep).join("/"),
25031
+ path: import_node_path47.default.relative(layout2.root, layout2.sources).split(import_node_path47.default.sep).join("/"),
24810
25032
  executable: true,
24811
25033
  languageMode: 5,
24812
25034
  mainActorIsolation: false,
@@ -24817,12 +25039,12 @@ ${entry}`);
24817
25039
  ([file, source]) => file.endsWith(".swift") && file !== input.entry && file !== "Package.swift" || /\.mm?$/.test(file) || source.includes("dispatch_")
24818
25040
  ) || [...importedModules].some(
24819
25041
  (name3) => distribution.modules.includes(name3) && !targets.some((target) => target.name === name3) && !(clangImportedModules.has(name3) && !swiftImportedModules.has(name3) && (0, import_node_fs45.existsSync)(
24820
- import_node_path46.default.join(swiftSharedSdkRoot(moduleRoot, true), "usr/include", name3)
25042
+ import_node_path47.default.join(swiftSharedSdkRoot(moduleRoot, true), "usr/include", name3)
24821
25043
  ))
24822
25044
  );
24823
- const frameworkLink = prebuilt ? import_node_path46.default.join(layout2.root, ".peach-framework-objects.rsp") : void 0;
25045
+ const frameworkLink = prebuilt ? import_node_path47.default.join(layout2.root, ".peach-framework-objects.rsp") : void 0;
24824
25046
  if (prebuilt && frameworkLink) {
24825
- const quote2 = (object3) => `"${object3.replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
25047
+ const quote2 = (object4) => `"${object4.replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
24826
25048
  files.set(
24827
25049
  frameworkLink,
24828
25050
  [
@@ -24847,15 +25069,15 @@ ${entry}`);
24847
25069
  }
24848
25070
  }
24849
25071
  files.set(
24850
- import_node_path46.default.join(layout2.root, "Package.swift"),
25072
+ import_node_path47.default.join(layout2.root, "Package.swift"),
24851
25073
  emitSwiftPackageManifest({
24852
25074
  root: layout2.root,
24853
25075
  files,
24854
25076
  targets: manifestTargets2.map((target) => ({
24855
25077
  ...target,
24856
25078
  sources: target.sources?.map((source) => {
24857
- const entry = libraryEntryFiles.get(import_node_path46.default.posix.join(target.path, source));
24858
- return entry ? import_node_path46.default.posix.relative(target.path, entry) : source;
25079
+ const entry = libraryEntryFiles.get(import_node_path47.default.posix.join(target.path, source));
25080
+ return entry ? import_node_path47.default.posix.relative(target.path, entry) : source;
24859
25081
  })
24860
25082
  })),
24861
25083
  packages,
@@ -24889,7 +25111,7 @@ ${entry}`);
24889
25111
  ),
24890
25112
  ...reachesFrameworks ? {
24891
25113
  distributionLink: {
24892
- path: import_node_path46.default.join(layout2.root, ".peach-distribution-objects.rsp"),
25114
+ path: import_node_path47.default.join(layout2.root, ".peach-distribution-objects.rsp"),
24893
25115
  files
24894
25116
  }
24895
25117
  } : {},
@@ -24910,14 +25132,14 @@ ${entry}`);
24910
25132
  for (const [file, bytes] of Object.entries(input.packageFiles ?? {})) {
24911
25133
  const contents2 = Buffer.from(bytes, "base64");
24912
25134
  files.set(
24913
- import_node_path46.default.join(layout2.root, file),
25135
+ import_node_path47.default.join(layout2.root, file),
24914
25136
  file.endsWith(".swift") && !/(?:^|\/)Package(?:@swift-[\d.]+)?\.swift$/.test(file) ? withFrameworkCompanionImports(
24915
25137
  swiftPackageSourceAsIOS(contents2.toString("utf8"))
24916
25138
  ) : contents2
24917
25139
  );
24918
25140
  }
24919
25141
  for (const [file, bytes] of Object.entries(input.projectFiles ?? {})) {
24920
- const destination = import_node_path46.default.join(layout2.root, file);
25142
+ const destination = import_node_path47.default.join(layout2.root, file);
24921
25143
  if (files.has(destination)) continue;
24922
25144
  files.set(destination, Buffer.from(bytes, "base64"));
24923
25145
  }
@@ -24926,14 +25148,14 @@ ${entry}`);
24926
25148
  const nativeToolsetFlags = [
24927
25149
  ...headerAliasFlags,
24928
25150
  ...native.size > 0 ? [
24929
- "-fmodule-map-file=" + import_node_path46.default.join(
25151
+ "-fmodule-map-file=" + import_node_path47.default.join(
24930
25152
  swiftSdkPaths(moduleRoot, nativeToolchain()).sysroot,
24931
25153
  "darwin/wasm/include/module.modulemap"
24932
25154
  )
24933
25155
  ] : []
24934
25156
  ];
24935
- const clangWrapper2 = import_node_path46.default.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
24936
- const clang = import_node_path46.default.join(nativeToolchain(), "clang");
25157
+ const clangWrapper2 = import_node_path47.default.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
25158
+ const clang = import_node_path47.default.join(nativeToolchain(), "clang");
24937
25159
  const prebuiltCompiler = distribution && objcPrebuiltStage !== false ? swiftObjCPrebuiltCompiler(
24938
25160
  clang,
24939
25161
  layout2.root,
@@ -25017,14 +25239,14 @@ ${entry}`);
25017
25239
  ].join("\n")
25018
25240
  );
25019
25241
  files.set(
25020
- import_node_path46.default.join(layout2.root, ".peach-target-toolset.json"),
25242
+ import_node_path47.default.join(layout2.root, ".peach-target-toolset.json"),
25021
25243
  JSON.stringify({
25022
25244
  schemaVersion: "1.0",
25023
25245
  cCompiler: {
25024
25246
  extraCLIOptions: [
25025
25247
  ...nativeToolsetFlags,
25026
25248
  "-fmodules",
25027
- `-fmodules-cache-path=${import_node_path46.default.join(layout2.root, ".build", "ModuleCache")}`
25249
+ `-fmodules-cache-path=${import_node_path47.default.join(layout2.root, ".build", "ModuleCache")}`
25028
25250
  ]
25029
25251
  },
25030
25252
  ...nativeToolsetFlags.length > 0 ? { cxxCompiler: { extraCLIOptions: nativeToolsetFlags } } : {},
@@ -25032,7 +25254,7 @@ ${entry}`);
25032
25254
  extraCLIOptions: [
25033
25255
  ...headerAliasFlags.flatMap((flag) => ["-Xcc", flag]),
25034
25256
  distribution || prebuilt ? "-Isystem" : "-I",
25035
- distributionModules ? providedModulesPath(layout2.root, distributionModules, moduleExcludes) : prebuilt ? providedModulesPath(layout2.root, prebuilt.modules, moduleExcludes) : import_node_path46.default.join(layout2.root, ".build", WASM_TRIPLE, "release", "Modules"),
25257
+ distributionModules ? providedModulesPath(layout2.root, distributionModules, moduleExcludes) : prebuilt ? providedModulesPath(layout2.root, prebuilt.modules, moduleExcludes) : import_node_path47.default.join(layout2.root, ".build", WASM_TRIPLE, "release", "Modules"),
25036
25258
  ...distributionModules ? distributionClangModuleOptions(layout2.root, distributionModules) : [],
25037
25259
  ...prebuilt?.moduleMaps.flatMap((map) => [
25038
25260
  "-Xcc",
@@ -25056,9 +25278,9 @@ ${entry}`);
25056
25278
  throw new Error(
25057
25279
  `swift resource target ${target.name} has no matching bundle assignment`
25058
25280
  );
25059
- const directory = layout2.multi ? import_node_path46.default.join(layout2.root, target.path) : layout2.sources;
25281
+ const directory = layout2.multi ? import_node_path47.default.join(layout2.root, target.path) : layout2.sources;
25060
25282
  files.set(
25061
- import_node_path46.default.join(directory, "ResourceBundleAccessor.generated.swift"),
25283
+ import_node_path47.default.join(directory, "ResourceBundleAccessor.generated.swift"),
25062
25284
  [
25063
25285
  "import Foundation",
25064
25286
  "",
@@ -25075,7 +25297,7 @@ ${entry}`);
25075
25297
  }
25076
25298
  for (const [file, source] of compiled)
25077
25299
  if (!Object.hasOwn(input.files, file))
25078
- files.set(import_node_path46.default.join(layout2.multi ? layout2.root : layout2.sources, file), source);
25300
+ files.set(import_node_path47.default.join(layout2.multi ? layout2.root : layout2.sources, file), source);
25079
25301
  const producers = [
25080
25302
  .../* @__PURE__ */ new Set([...[...native.values()].flatMap((value) => value.late?.producers ?? [])])
25081
25303
  ];
@@ -25088,7 +25310,7 @@ ${entry}`);
25088
25310
  generatedOwners.set(group.name, owner);
25089
25311
  }
25090
25312
  }
25091
- const manifestPath = import_node_path46.default.join(layout2.root, "Package.swift");
25313
+ const manifestPath = import_node_path47.default.join(layout2.root, "Package.swift");
25092
25314
  let manifest = files.get(manifestPath).toString();
25093
25315
  const manifestTargets = swiftManifestTargets(manifest, [], (file) => {
25094
25316
  const contents2 = files.get(file);
@@ -25188,7 +25410,7 @@ package.targets.first(where: { $0.name == ${JSON.stringify(target)} })!.dependen
25188
25410
  if (members.length === 1) return members[0];
25189
25411
  if (dependencies.has(name3))
25190
25412
  throw new Error(`generated build target collides with ${name3}`);
25191
- files.set(import_node_path46.default.join(layout2.root, name3, "Products.swift"), "");
25413
+ files.set(import_node_path47.default.join(layout2.root, name3, "Products.swift"), "");
25192
25414
  manifest += `
25193
25415
  package.targets += [.target(name: ${JSON.stringify(name3)}, dependencies: ${JSON.stringify(members)}, path: ${JSON.stringify(name3)}, swiftSettings: [.swiftLanguageMode(.v5)])]
25194
25416
  `;
@@ -25298,8 +25520,8 @@ package.targets += [.target(name: ${JSON.stringify(name3)}, dependencies: ${JSON
25298
25520
  syncSwiftTree(layout2.root, files);
25299
25521
  if (layout2.multi)
25300
25522
  for (const target of targets)
25301
- (0, import_node_fs45.mkdirSync)(import_node_path46.default.join(layout2.root, target.path), { recursive: true });
25302
- const clangWrapper = import_node_path46.default.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
25523
+ (0, import_node_fs45.mkdirSync)(import_node_path47.default.join(layout2.root, target.path), { recursive: true });
25524
+ const clangWrapper = import_node_path47.default.join(layout2.root, CLANG_TARGET_MODULE_WRAPPER);
25303
25525
  if (files.has(clangWrapper) && ((0, import_node_fs45.statSync)(clangWrapper).mode & 4095) !== 493)
25304
25526
  (0, import_node_fs45.chmodSync)(clangWrapper, 493);
25305
25527
  return {
@@ -25330,8 +25552,8 @@ function outputOf(error) {
25330
25552
  return error instanceof Error ? error.message : String(error);
25331
25553
  }
25332
25554
  function builtArtifact(layout2) {
25333
- const binDir = import_node_path46.default.join(layout2.root, ".build", WASM_TRIPLE, "release");
25334
- const manifest = (0, import_node_fs45.readFileSync)(import_node_path46.default.join(layout2.root, "Package.swift"), "utf8");
25555
+ const binDir = import_node_path47.default.join(layout2.root, ".build", WASM_TRIPLE, "release");
25556
+ const manifest = (0, import_node_fs45.readFileSync)(import_node_path47.default.join(layout2.root, "Package.swift"), "utf8");
25335
25557
  const executable = swiftManifestTargets(
25336
25558
  manifest,
25337
25559
  [],
@@ -25340,11 +25562,11 @@ function builtArtifact(layout2) {
25340
25562
  if (executable === void 0) {
25341
25563
  throw new Error("swift-compile: the written manifest names no executable target");
25342
25564
  }
25343
- return import_node_path46.default.join(binDir, `${executable.name}.wasm`);
25565
+ return import_node_path47.default.join(binDir, `${executable.name}.wasm`);
25344
25566
  }
25345
25567
  function projectDiagnostic(output, layout2, files) {
25346
25568
  const base = layout2.multi ? layout2.root : layout2.sources;
25347
- const prefix = `${base}${import_node_path46.default.sep}`;
25569
+ const prefix = `${base}${import_node_path47.default.sep}`;
25348
25570
  return designTimeDiagnostic(output, files).split("\n").filter((line) => !SWIFTPM_NOISE.test(line)).map((line) => line.startsWith(prefix) ? line.slice(prefix.length) : line).join("\n").trim();
25349
25571
  }
25350
25572
  function serialize(root, work, signal) {
@@ -25377,12 +25599,12 @@ function serialize(root, work, signal) {
25377
25599
  function readCompiledArtifact(directory, hash) {
25378
25600
  try {
25379
25601
  const receipt = JSON.parse(
25380
- (0, import_node_fs45.readFileSync)(import_node_path46.default.join(directory, "artifact.json"), "utf8")
25602
+ (0, import_node_fs45.readFileSync)(import_node_path47.default.join(directory, "artifact.json"), "utf8")
25381
25603
  );
25382
25604
  if (!receipt || typeof receipt !== "object" || !("hash" in receipt) || receipt.hash !== hash || !("icu" in receipt) || typeof receipt.icu !== "string" || !("wasm" in receipt) || typeof receipt.wasm !== "string")
25383
25605
  return null;
25384
- const bytes = (0, import_node_fs45.readFileSync)(import_node_path46.default.join(directory, "app.wasm"));
25385
- const gzip2 = (0, import_node_fs45.readFileSync)(import_node_path46.default.join(directory, "icu.gz"));
25606
+ const bytes = (0, import_node_fs45.readFileSync)(import_node_path47.default.join(directory, "app.wasm"));
25607
+ const gzip2 = (0, import_node_fs45.readFileSync)(import_node_path47.default.join(directory, "icu.gz"));
25386
25608
  if ((0, import_node_crypto29.createHash)("sha256").update(bytes).digest("hex") !== receipt.wasm || (0, import_node_crypto29.createHash)("sha256").update(gzip2).digest("hex") !== receipt.icu || bytes.length <= 8 || bytes.readUInt32LE(0) !== 1836278016 || bytes.readUInt32LE(4) !== 1)
25387
25609
  return null;
25388
25610
  let sdk;
@@ -25390,7 +25612,7 @@ function readCompiledArtifact(directory, hash) {
25390
25612
  const image = receipt.sdk;
25391
25613
  if (!isRecord(image) || typeof image.key !== "string" || typeof image.sha256 !== "string" || typeof image.binding !== "string")
25392
25614
  return null;
25393
- const binding = (0, import_node_fs45.readFileSync)(import_node_path46.default.join(directory, "sdk-binding.bin"));
25615
+ const binding = (0, import_node_fs45.readFileSync)(import_node_path47.default.join(directory, "sdk-binding.bin"));
25394
25616
  if ((0, import_node_crypto29.createHash)("sha256").update(binding).digest("hex") !== image.binding)
25395
25617
  return null;
25396
25618
  sdk = {
@@ -25407,16 +25629,16 @@ function readCompiledArtifact(directory, hash) {
25407
25629
  }
25408
25630
  }
25409
25631
  function saveCompiledArtifact(root, artifact) {
25410
- const directory = import_node_path46.default.join(root, "artifact");
25632
+ const directory = import_node_path47.default.join(root, "artifact");
25411
25633
  (0, import_node_fs45.mkdirSync)(directory, { recursive: true });
25412
- const pending = (0, import_node_fs45.mkdtempSync)(import_node_path46.default.join(root, ".artifact-"));
25634
+ const pending = (0, import_node_fs45.mkdtempSync)(import_node_path47.default.join(root, ".artifact-"));
25413
25635
  try {
25414
- (0, import_node_fs45.writeFileSync)(import_node_path46.default.join(pending, "app.wasm"), artifact.bytes);
25415
- (0, import_node_fs45.writeFileSync)(import_node_path46.default.join(pending, "icu.gz"), artifact.icu.gzip);
25636
+ (0, import_node_fs45.writeFileSync)(import_node_path47.default.join(pending, "app.wasm"), artifact.bytes);
25637
+ (0, import_node_fs45.writeFileSync)(import_node_path47.default.join(pending, "icu.gz"), artifact.icu.gzip);
25416
25638
  if (artifact.sdk)
25417
- (0, import_node_fs45.writeFileSync)(import_node_path46.default.join(pending, "sdk-binding.bin"), artifact.sdk.binding.bytes);
25639
+ (0, import_node_fs45.writeFileSync)(import_node_path47.default.join(pending, "sdk-binding.bin"), artifact.sdk.binding.bytes);
25418
25640
  (0, import_node_fs45.writeFileSync)(
25419
- import_node_path46.default.join(pending, "artifact.json"),
25641
+ import_node_path47.default.join(pending, "artifact.json"),
25420
25642
  JSON.stringify({
25421
25643
  hash: artifact.hash,
25422
25644
  wasm: (0, import_node_crypto29.createHash)("sha256").update(artifact.bytes).digest("hex"),
@@ -25431,7 +25653,7 @@ function saveCompiledArtifact(root, artifact) {
25431
25653
  const outputs = ["app.wasm", "icu.gz"];
25432
25654
  if (artifact.sdk) outputs.push("sdk-binding.bin");
25433
25655
  for (const file of [...outputs, "artifact.json"]) {
25434
- (0, import_node_fs45.renameSync)(import_node_path46.default.join(pending, file), import_node_path46.default.join(directory, file));
25656
+ (0, import_node_fs45.renameSync)(import_node_path47.default.join(pending, file), import_node_path47.default.join(directory, file));
25435
25657
  }
25436
25658
  } finally {
25437
25659
  (0, import_node_fs45.rmSync)(pending, { recursive: true, force: true });
@@ -25450,19 +25672,19 @@ function renewSharedArtifact(sharedRoot) {
25450
25672
  function pruneSharedArtifacts(parent, keep) {
25451
25673
  const entries2 = [];
25452
25674
  for (const name3 of (0, import_node_fs45.readdirSync)(parent)) {
25453
- const directory = import_node_path46.default.join(parent, name3);
25675
+ const directory = import_node_path47.default.join(parent, name3);
25454
25676
  if (name3.startsWith(RETIRED_PREFIX)) {
25455
25677
  reapRetiredCacheDirectory(parent, name3);
25456
25678
  continue;
25457
25679
  }
25458
25680
  try {
25459
25681
  let bytes = 0;
25460
- for (const file of (0, import_node_fs45.readdirSync)(import_node_path46.default.join(directory, "artifact"), {
25682
+ for (const file of (0, import_node_fs45.readdirSync)(import_node_path47.default.join(directory, "artifact"), {
25461
25683
  recursive: true,
25462
25684
  encoding: "utf8"
25463
25685
  })) {
25464
25686
  try {
25465
- bytes += (0, import_node_fs45.statSync)(import_node_path46.default.join(directory, "artifact", file)).size;
25687
+ bytes += (0, import_node_fs45.statSync)(import_node_path47.default.join(directory, "artifact", file)).size;
25466
25688
  } catch (error) {
25467
25689
  if (!vanished(error)) throw error;
25468
25690
  }
@@ -25477,9 +25699,9 @@ function pruneSharedArtifacts(parent, keep) {
25477
25699
  if (total <= SHARED_ARTIFACT_BUDGET_BYTES) break;
25478
25700
  if (entry.directory === keep || Date.now() - entry.used < SHARED_ARTIFACT_GRACE_MS)
25479
25701
  continue;
25480
- const retired = import_node_path46.default.join(
25702
+ const retired = import_node_path47.default.join(
25481
25703
  parent,
25482
- `${RETIRED_PREFIX}${process.pid}-${import_node_path46.default.basename(entry.directory)}`
25704
+ `${RETIRED_PREFIX}${process.pid}-${import_node_path47.default.basename(entry.directory)}`
25483
25705
  );
25484
25706
  try {
25485
25707
  if ((0, import_node_fs45.statSync)(entry.directory).mtimeMs !== entry.used) continue;
@@ -25495,7 +25717,7 @@ function pruneSharedArtifacts(parent, keep) {
25495
25717
  function saveSharedArtifact(sharedRoot, artifact) {
25496
25718
  saveCompiledArtifact(sharedRoot, artifact);
25497
25719
  renewSharedArtifact(sharedRoot);
25498
- pruneSharedArtifacts(import_node_path46.default.dirname(sharedRoot), sharedRoot);
25720
+ pruneSharedArtifacts(import_node_path47.default.dirname(sharedRoot), sharedRoot);
25499
25721
  }
25500
25722
  function retain(root, artifact) {
25501
25723
  retainedArtifacts.set(
@@ -25521,7 +25743,7 @@ function frameworkLibraryTargets(manifest) {
25521
25743
  }
25522
25744
  function linkedFrameworkTargets(moduleRoot, input) {
25523
25745
  const libraries = frameworkLibraryTargets(
25524
- (0, import_node_fs45.readFileSync)(import_node_path46.default.join(moduleRoot, "Package.swift"), "utf8")
25746
+ (0, import_node_fs45.readFileSync)(import_node_path47.default.join(moduleRoot, "Package.swift"), "utf8")
25525
25747
  );
25526
25748
  const targets = compileTargets(input);
25527
25749
  const planning = targets.length > 0 ? targets : [{ name: "App", path: "." }];
@@ -25547,7 +25769,7 @@ function linkedFrameworkTargets(moduleRoot, input) {
25547
25769
  imports.add(name3);
25548
25770
  reach(name3);
25549
25771
  }
25550
- const manifest = (0, import_node_fs45.readFileSync)(import_node_path46.default.join(moduleRoot, "Package.swift"), "utf8");
25772
+ const manifest = (0, import_node_fs45.readFileSync)(import_node_path47.default.join(moduleRoot, "Package.swift"), "utf8");
25551
25773
  const targetDependencies = /* @__PURE__ */ new Map();
25552
25774
  for (const match of manifest.matchAll(
25553
25775
  /\.target\(\s*name:\s*"([^"]+)"\s*,\s*dependencies:\s*\[([^\]]*)\]/g
@@ -25564,11 +25786,11 @@ function linkedFrameworkTargets(moduleRoot, input) {
25564
25786
  };
25565
25787
  for (const name3 of reached)
25566
25788
  for (const member of libraries.get(name3) ?? []) build(member);
25567
- const overlays = import_node_path46.default.join(moduleRoot, "cross-import-overlays");
25789
+ const overlays = import_node_path47.default.join(moduleRoot, "cross-import-overlays");
25568
25790
  for (const directory of (0, import_node_fs45.readdirSync)(overlays)) {
25569
- const companion = import_node_path46.default.basename(directory, ".swiftcrossimport");
25791
+ const companion = import_node_path47.default.basename(directory, ".swiftcrossimport");
25570
25792
  if (!built.has(companion)) continue;
25571
- const declaration = import_node_path46.default.join(overlays, directory, "SwiftUI.swiftoverlay");
25793
+ const declaration = import_node_path47.default.join(overlays, directory, "SwiftUI.swiftoverlay");
25572
25794
  for (const match of (0, import_node_fs45.readFileSync)(declaration, "utf8").matchAll(
25573
25795
  /^\s*- name: ([A-Za-z_]\w*)\s*$/gm
25574
25796
  ))
@@ -25595,7 +25817,7 @@ function linkedFrameworkTargets(moduleRoot, input) {
25595
25817
  return { products: linked, targets: linkedMembers, imports: [...imports].sort() };
25596
25818
  }
25597
25819
  function writeFrameworkLinkPackage(linkRoot, moduleRoot, products) {
25598
- const identity = import_node_path46.default.basename(moduleRoot).toLowerCase();
25820
+ const identity = import_node_path47.default.basename(moduleRoot).toLowerCase();
25599
25821
  const swiftString = (value) => `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
25600
25822
  const dependencies = products.map(
25601
25823
  (name3) => ` .product(name: ${swiftString(name3)}, package: ${swiftString(identity)}),`
@@ -25617,12 +25839,12 @@ ${dependencies}
25617
25839
  ]
25618
25840
  )
25619
25841
  `;
25620
- const sourceDir = import_node_path46.default.join(linkRoot, "Sources", FRAMEWORK_LINK_TARGET);
25842
+ const sourceDir = import_node_path47.default.join(linkRoot, "Sources", FRAMEWORK_LINK_TARGET);
25621
25843
  (0, import_node_fs45.mkdirSync)(sourceDir, { recursive: true });
25622
- const manifestPath = import_node_path46.default.join(linkRoot, "Package.swift");
25844
+ const manifestPath = import_node_path47.default.join(linkRoot, "Package.swift");
25623
25845
  if (!(0, import_node_fs45.existsSync)(manifestPath) || (0, import_node_fs45.readFileSync)(manifestPath, "utf8") !== manifest)
25624
25846
  (0, import_node_fs45.writeFileSync)(manifestPath, manifest);
25625
- const source = import_node_path46.default.join(sourceDir, "Link.swift");
25847
+ const source = import_node_path47.default.join(sourceDir, "Link.swift");
25626
25848
  if (!(0, import_node_fs45.existsSync)(source)) (0, import_node_fs45.writeFileSync)(source, "");
25627
25849
  }
25628
25850
  function frameworkLinkClosure(scratch2, roots) {
@@ -25635,7 +25857,7 @@ function frameworkLinkClosure(scratch2, roots) {
25635
25857
  const objcHeaders = /* @__PURE__ */ new Map();
25636
25858
  let pending = null;
25637
25859
  let compiling = null;
25638
- for (const line of (0, import_node_fs45.readFileSync)(import_node_path46.default.join(scratch2, "release.yaml"), "utf8").split(
25860
+ for (const line of (0, import_node_fs45.readFileSync)(import_node_path47.default.join(scratch2, "release.yaml"), "utf8").split(
25639
25861
  "\n"
25640
25862
  )) {
25641
25863
  const phony = phonyHeader.exec(line);
@@ -25673,9 +25895,9 @@ function frameworkLinkClosure(scratch2, roots) {
25673
25895
  const deps = /* @__PURE__ */ new Set();
25674
25896
  for (const file of paths) {
25675
25897
  const module2 = /\/Modules\/([^/]+)\.swiftmodule$/.exec(file);
25676
- const object3 = /\/release\/([^/]+)\.build\/.+\.o$/.exec(file);
25898
+ const object4 = /\/release\/([^/]+)\.build\/.+\.o$/.exec(file);
25677
25899
  if (module2) deps.add(module2[1]);
25678
- else if (object3 && object3[1] !== pending.name) deps.add(object3[1]);
25900
+ else if (object4 && object4[1] !== pending.name) deps.add(object4[1]);
25679
25901
  }
25680
25902
  dependencies.set(pending.name, deps);
25681
25903
  }
@@ -25726,15 +25948,76 @@ function removeCaseCollidingModuleArtifacts(modulesDir, keep) {
25726
25948
  if (dot <= 0) continue;
25727
25949
  const module2 = name3.slice(0, dot);
25728
25950
  if (keep.has(module2) || !folded.has(module2.toLowerCase())) continue;
25729
- (0, import_node_fs45.rmSync)(import_node_path46.default.join(modulesDir, name3), { recursive: true, force: true });
25951
+ (0, import_node_fs45.rmSync)(import_node_path47.default.join(modulesDir, name3), { recursive: true, force: true });
25952
+ }
25953
+ }
25954
+ function readFrameworkProductsReceipt(scratch2, receiptKey) {
25955
+ const receiptFile = import_node_path47.default.join(scratch2, "products-ready", `${receiptKey}.json`);
25956
+ if (!(0, import_node_fs45.existsSync)(receiptFile)) return null;
25957
+ let parsed;
25958
+ try {
25959
+ parsed = v6.parse(
25960
+ frameworkProductsReceiptSchema,
25961
+ JSON.parse((0, import_node_fs45.readFileSync)(receiptFile, "utf8"))
25962
+ );
25963
+ } catch {
25964
+ return null;
25730
25965
  }
25966
+ const archive = import_node_path47.default.join(scratch2, "lib");
25967
+ const archiveStamp = import_node_path47.default.join(archive, ".receipt");
25968
+ const archiveMatches = (0, import_node_fs45.existsSync)(archiveStamp) && (0, import_node_fs45.readFileSync)(archiveStamp, "utf8") === receiptKey;
25969
+ if (!(0, import_node_fs45.existsSync)(parsed.modules)) return null;
25970
+ for (const [object4] of parsed.archived) if (!(0, import_node_fs45.existsSync)(object4)) return null;
25971
+ for (const file of parsed.providers) if (!(0, import_node_fs45.existsSync)(file)) return null;
25972
+ for (const file of parsed.moduleMaps) if (!(0, import_node_fs45.existsSync)(file)) return null;
25973
+ if (!archiveMatches) {
25974
+ (0, import_node_fs45.rmSync)(archive, { recursive: true, force: true });
25975
+ (0, import_node_fs45.mkdirSync)(archive, { recursive: true });
25976
+ for (const [object4, rel] of parsed.archived)
25977
+ (0, import_node_fs45.symlinkSync)(object4, import_node_path47.default.join(scratch2, rel));
25978
+ (0, import_node_fs45.writeFileSync)(archiveStamp, receiptKey);
25979
+ }
25980
+ for (const file of parsed.objects) if (!(0, import_node_fs45.existsSync)(file)) return null;
25981
+ for (const file of parsed.lazyObjects) if (!(0, import_node_fs45.existsSync)(file)) return null;
25982
+ return {
25983
+ root: scratch2,
25984
+ modules: parsed.modules,
25985
+ objects: parsed.objects,
25986
+ lazyObjects: parsed.lazyObjects,
25987
+ owners: new Map(parsed.owners),
25988
+ providers: parsed.providers,
25989
+ link: parsed.link,
25990
+ moduleMaps: parsed.moduleMaps,
25991
+ objcHeaders: new Map(parsed.objcHeaders)
25992
+ };
25731
25993
  }
25732
25994
  async function buildFrameworkProducts(scratch2, args) {
25733
25995
  const linkedTargets = linkedFrameworkTargets(args.moduleRoot, args.input);
25734
- const linkRoot = import_node_path46.default.join(scratch2, "link");
25996
+ const unoptimized = args.input.unoptimized === true;
25997
+ const sdkOptions = swiftCompileSdkOptions(args.moduleRoot, args.toolchainBin);
25998
+ const selectorOptions = swiftObjCSelectorOptions(args.moduleRoot);
25999
+ const receiptKey = (0, import_node_crypto29.createHash)("sha256").update(
26000
+ JSON.stringify([
26001
+ "framework-products/v1",
26002
+ args.frameworkKey,
26003
+ unoptimized,
26004
+ args.sdk,
26005
+ args.toolchainBin,
26006
+ [...linkedTargets.products].sort(),
26007
+ darwinRecordsMinimum(),
26008
+ args.plugins,
26009
+ sdkOptions,
26010
+ selectorOptions
26011
+ ])
26012
+ ).digest("hex").slice(0, 32);
26013
+ const ready = readFrameworkProductsReceipt(scratch2, receiptKey);
26014
+ if (ready) return ready;
26015
+ await waitForNoSwiftRootReaders(scratch2, args.buildOptions.signal);
26016
+ const linkRoot = import_node_path47.default.join(scratch2, "link");
25735
26017
  writeFrameworkLinkPackage(linkRoot, args.moduleRoot, linkedTargets.products);
26018
+ const frameworkTmp = import_node_path47.default.join(scratch2, "peach-compiler-tmp");
26019
+ (0, import_node_fs45.mkdirSync)(frameworkTmp, { recursive: true });
25736
26020
  const jobs = swiftCompilerJobs();
25737
- const unoptimized = args.input.unoptimized === true;
25738
26021
  const targetJobs = unoptimized ? jobs >= 4 ? 2 : 1 : jobs;
25739
26022
  const driverJobs = unoptimized ? Math.max(1, Math.floor(jobs / targetJobs)) : jobs;
25740
26023
  await runCompiler(
@@ -25752,8 +26035,8 @@ async function buildFrameworkProducts(scratch2, args) {
25752
26035
  scratch2,
25753
26036
  "--target",
25754
26037
  FRAMEWORK_LINK_TARGET,
25755
- ...swiftCompileSdkOptions(args.moduleRoot, args.toolchainBin),
25756
- ...swiftObjCSelectorOptions(args.moduleRoot),
26038
+ ...sdkOptions,
26039
+ ...selectorOptions,
25757
26040
  "--swift-sdk",
25758
26041
  args.sdk,
25759
26042
  "-c",
@@ -25772,15 +26055,17 @@ async function buildFrameworkProducts(scratch2, args) {
25772
26055
  "-Xswiftc",
25773
26056
  String(driverJobs)
25774
26057
  ] : ["-Xswiftc", "-Osize"],
25775
- // the release link strips all debug info, so none is generated
26058
+ // the release link strips all debug info, so none is generated. keep
26059
+ // -num-threads fixed across caller core caps so llbuild does not rebuild
26060
+ // every framework target when callers alternate --cores.
25776
26061
  "-Xswiftc",
25777
26062
  "-gnone",
25778
26063
  "-Xswiftc",
25779
26064
  "-num-threads",
25780
26065
  "-Xswiftc",
25781
- String(unoptimized ? 1 : jobs),
26066
+ String(unoptimized ? 1 : Math.min(4, import_node_os11.default.availableParallelism())),
25782
26067
  ...swiftReproducibleBuildFlags([
25783
- [import_node_path46.default.dirname(args.toolchainBin), "toolchain"],
26068
+ [import_node_path47.default.dirname(args.toolchainBin), "toolchain"],
25784
26069
  [args.moduleRoot, "framework"],
25785
26070
  [scratch2, "framework-scratch"]
25786
26071
  ]),
@@ -25797,21 +26082,26 @@ async function buildFrameworkProducts(scratch2, args) {
25797
26082
  `${plugin}#ExpoModulesMacros`
25798
26083
  ])
25799
26084
  ],
26085
+ // swiftpm hashes TMPDIR into its plan; keep one stable compiler scratch inside the locked slot.
25800
26086
  // the framework build's warnings alone pass the default 1 MiB cap, which kills
25801
26087
  // the build one step from the end.
25802
- { ...args.buildOptions, maxBuffer: 64 * 1024 * 1024 },
26088
+ {
26089
+ ...args.buildOptions,
26090
+ temporaryDirectory: frameworkTmp,
26091
+ maxBuffer: 64 * 1024 * 1024
26092
+ },
25803
26093
  SWIFTPM_PROGRESS,
25804
26094
  SWIFTPM_NOISE
25805
26095
  ).catch((error) => {
25806
26096
  throw new Error(outputOf(error), { cause: error });
25807
26097
  });
25808
- const release = import_node_path46.default.join(scratch2, WASM_TRIPLE, "release");
26098
+ const release = import_node_path47.default.join(scratch2, WASM_TRIPLE, "release");
25809
26099
  const linked = frameworkLinkClosure(scratch2, linkedTargets.targets);
25810
26100
  const objects = linked.objects;
25811
26101
  if (linked.modules.has("UniformTypeIdentifiers")) {
25812
- const constantsDir = import_node_path46.default.join(scratch2, "uniform-type-constants");
25813
- const constantsStamp = import_node_path46.default.join(constantsDir, ".complete");
25814
- const object3 = import_node_path46.default.join(constantsDir, "UniformTypeIdentifiers-NativeConstants.o");
26102
+ const constantsDir = import_node_path47.default.join(scratch2, "uniform-type-constants");
26103
+ const constantsStamp = import_node_path47.default.join(constantsDir, ".complete");
26104
+ const object4 = import_node_path47.default.join(constantsDir, "UniformTypeIdentifiers-NativeConstants.o");
25815
26105
  if (!(0, import_node_fs45.existsSync)(constantsStamp) || (0, import_node_fs45.readFileSync)(constantsStamp, "utf8") !== args.frameworkKey) {
25816
26106
  (0, import_node_fs45.rmSync)(constantsDir, { recursive: true, force: true });
25817
26107
  (0, import_node_fs45.mkdirSync)(constantsDir);
@@ -25826,14 +26116,14 @@ async function buildFrameworkProducts(scratch2, args) {
25826
26116
  });
25827
26117
  (0, import_node_fs45.writeFileSync)(constantsStamp, args.frameworkKey);
25828
26118
  }
25829
- objects.push(object3);
25830
- linked.owners.set(object3, "UniformTypeIdentifiers");
26119
+ objects.push(object4);
26120
+ linked.owners.set(object4, "UniformTypeIdentifiers");
25831
26121
  }
25832
- removeCaseCollidingModuleArtifacts(import_node_path46.default.join(release, "Modules"), linked.modules);
25833
- const response = import_node_path46.default.join(scratch2, "autolink-objects.rsp");
26122
+ removeCaseCollidingModuleArtifacts(import_node_path47.default.join(release, "Modules"), linked.modules);
26123
+ const response = import_node_path47.default.join(scratch2, "autolink-objects.rsp");
25834
26124
  (0, import_node_fs45.writeFileSync)(response, objects.map((file) => JSON.stringify(file)).join("\n") + "\n");
25835
26125
  const extracted = await runCompiler(
25836
- import_node_path46.default.join(args.toolchainBin, "swift-autolink-extract"),
26126
+ import_node_path47.default.join(args.toolchainBin, "swift-autolink-extract"),
25837
26127
  [`@${response}`, "-o", "-"],
25838
26128
  args.buildOptions
25839
26129
  );
@@ -25841,15 +26131,15 @@ async function buildFrameworkProducts(scratch2, args) {
25841
26131
  const link = extracted.split("\n").map((line) => line.trim()).filter((flag, index, all) => flag.length > 0 && all.indexOf(flag) === index);
25842
26132
  if (link.includes("-lFoundation"))
25843
26133
  for (const name3 of foundationCategoryObjects) {
25844
- const object3 = import_node_path46.default.join(
26134
+ const object4 = import_node_path47.default.join(
25845
26135
  swiftSdkPaths(args.moduleRoot, args.toolchainBin).resources,
25846
26136
  `wasi/${name3}.objc.o`
25847
26137
  );
25848
- objects.push(object3);
25849
- linked.owners.set(object3, "Foundation");
26138
+ objects.push(object4);
26139
+ linked.owners.set(object4, "Foundation");
25850
26140
  }
25851
- const providerDir = import_node_path46.default.join(scratch2, "darwin-records");
25852
- const providerStamp = import_node_path46.default.join(providerDir, ".complete");
26141
+ const providerDir = import_node_path47.default.join(scratch2, "darwin-records");
26142
+ const providerStamp = import_node_path47.default.join(providerDir, ".complete");
25853
26143
  if (!(0, import_node_fs45.existsSync)(providerStamp) || (0, import_node_fs45.readFileSync)(providerStamp, "utf8") !== args.frameworkKey) {
25854
26144
  (0, import_node_fs45.rmSync)(providerDir, { recursive: true, force: true });
25855
26145
  (0, import_node_fs45.mkdirSync)(providerDir);
@@ -25864,49 +26154,70 @@ async function buildFrameworkProducts(scratch2, args) {
25864
26154
  });
25865
26155
  (0, import_node_fs45.writeFileSync)(providerStamp, args.frameworkKey);
25866
26156
  }
25867
- const providers = (0, import_node_fs45.readdirSync)(providerDir).filter((file) => file.endsWith(".o")).sort().map((file) => import_node_path46.default.join(providerDir, file));
26157
+ const providers = (0, import_node_fs45.readdirSync)(providerDir).filter((file) => file.endsWith(".o")).sort().map((file) => import_node_path47.default.join(providerDir, file));
25868
26158
  for (const provider of providers) linked.owners.set(provider, "DarwinRecords");
25869
- const archive = import_node_path46.default.join(scratch2, "lib");
26159
+ const archive = import_node_path47.default.join(scratch2, "lib");
25870
26160
  (0, import_node_fs45.rmSync)(archive, { recursive: true, force: true });
25871
26161
  (0, import_node_fs45.mkdirSync)(archive);
25872
26162
  const archived = /* @__PURE__ */ new Map();
25873
- for (const object3 of objects) {
25874
- const target = linked.owners.get(object3);
25875
- const dir = import_node_path46.default.join(release, `${target}.build`);
25876
- if (!target || target === "Darwin" || !object3.startsWith(dir + import_node_path46.default.sep)) continue;
25877
- const name3 = `${target}-${import_node_path46.default.relative(dir, object3).replaceAll(import_node_path46.default.sep, "-").replace(/\.swift\.o$/, ".o")}`;
25878
- (0, import_node_fs45.symlinkSync)(object3, import_node_path46.default.join(archive, name3));
25879
- archived.set(object3, `lib/${name3}`);
26163
+ for (const object4 of objects) {
26164
+ const target = linked.owners.get(object4);
26165
+ const dir = import_node_path47.default.join(release, `${target}.build`);
26166
+ if (!target || target === "Darwin" || !object4.startsWith(dir + import_node_path47.default.sep)) continue;
26167
+ const name3 = `${target}-${import_node_path47.default.relative(dir, object4).replaceAll(import_node_path47.default.sep, "-").replace(/\.swift\.o$/, ".o")}`;
26168
+ (0, import_node_fs45.symlinkSync)(object4, import_node_path47.default.join(archive, name3));
26169
+ archived.set(object4, `lib/${name3}`);
25880
26170
  }
25881
26171
  const roots = swiftObjcRootObjects(`${scratch2}
25882
26172
  ${args.frameworkKey}`, scratch2, [
25883
26173
  ...archived.values()
25884
26174
  ]);
25885
- const linkedObjects = objects.map((object3) => {
25886
- const name3 = archived.get(object3);
25887
- return name3 ? { path: import_node_path46.default.join(scratch2, name3), lazy: !roots.has(name3) } : { path: object3, lazy: false };
26175
+ const linkedObjects = objects.map((object4) => {
26176
+ const name3 = archived.get(object4);
26177
+ return name3 ? { path: import_node_path47.default.join(scratch2, name3), lazy: !roots.has(name3) } : { path: object4, lazy: false };
25888
26178
  });
25889
- return {
26179
+ const result = {
25890
26180
  root: scratch2,
25891
- modules: import_node_path46.default.join(release, "Modules"),
25892
- objects: linkedObjects.filter((object3) => !object3.lazy).map((object3) => object3.path),
25893
- lazyObjects: linkedObjects.filter((object3) => object3.lazy).map((object3) => object3.path),
26181
+ modules: import_node_path47.default.join(release, "Modules"),
26182
+ objects: linkedObjects.filter((object4) => !object4.lazy).map((object4) => object4.path),
26183
+ lazyObjects: linkedObjects.filter((object4) => object4.lazy).map((object4) => object4.path),
25894
26184
  owners: linked.owners,
25895
26185
  providers,
25896
26186
  link,
25897
26187
  moduleMaps: linked.moduleMaps,
25898
26188
  objcHeaders: linked.objcHeaders
25899
26189
  };
26190
+ (0, import_node_fs45.writeFileSync)(import_node_path47.default.join(archive, ".receipt"), receiptKey);
26191
+ const receiptsDir = import_node_path47.default.join(scratch2, "products-ready");
26192
+ (0, import_node_fs45.mkdirSync)(receiptsDir, { recursive: true });
26193
+ const receiptFile = import_node_path47.default.join(receiptsDir, `${receiptKey}.json`);
26194
+ const partialReceipt = `${receiptFile}.${process.pid}.${(0, import_node_crypto29.randomUUID)()}`;
26195
+ (0, import_node_fs45.writeFileSync)(
26196
+ partialReceipt,
26197
+ JSON.stringify({
26198
+ modules: result.modules,
26199
+ objects: result.objects,
26200
+ lazyObjects: result.lazyObjects,
26201
+ owners: [...result.owners.entries()],
26202
+ providers: result.providers,
26203
+ link: result.link,
26204
+ moduleMaps: result.moduleMaps,
26205
+ objcHeaders: [...result.objcHeaders.entries()],
26206
+ archived: [...archived.entries()]
26207
+ })
26208
+ );
26209
+ (0, import_node_fs45.renameSync)(partialReceipt, receiptFile);
26210
+ return result;
25900
26211
  }
25901
26212
  function swiftFrameworksDir(unoptimized = false) {
25902
- return import_node_path46.default.join(
26213
+ return import_node_path47.default.join(
25903
26214
  swiftCacheDir(),
25904
26215
  unoptimized ? "swift-frameworks-unoptimized" : "swift-frameworks"
25905
26216
  );
25906
26217
  }
25907
26218
  function swiftFrameworkSlotRecord(slot, record) {
25908
26219
  try {
25909
- return (0, import_node_fs45.readFileSync)(import_node_path46.default.join(slot, record), "utf8").trim();
26220
+ return (0, import_node_fs45.readFileSync)(import_node_path47.default.join(slot, record), "utf8").trim();
25910
26221
  } catch (error) {
25911
26222
  if (!vanished(error)) throw error;
25912
26223
  return null;
@@ -25919,7 +26230,7 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work, un
25919
26230
  const slotCount = unoptimized ? SWIFT_FRAMEWORK_UNOPTIMIZED_SLOTS : SWIFT_FRAMEWORK_SLOTS;
25920
26231
  const slotsDir = swiftFrameworksDir(unoptimized);
25921
26232
  const slots = Array.from({ length: slotCount }, (_, index) => {
25922
- const slot = import_node_path46.default.join(slotsDir, `slot-${index}`);
26233
+ const slot = import_node_path47.default.join(slotsDir, `slot-${index}`);
25923
26234
  (0, import_node_fs45.mkdirSync)(slot, { recursive: true });
25924
26235
  return slot;
25925
26236
  });
@@ -25935,16 +26246,18 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work, un
25935
26246
  const inputs = new Map(
25936
26247
  swiftModuleInputFiles(moduleRoot).map((file) => [
25937
26248
  file,
25938
- (0, import_node_fs45.readFileSync)(import_node_path46.default.join(moduleRoot, file))
26249
+ (0, import_node_fs45.readFileSync)(import_node_path47.default.join(moduleRoot, file))
25939
26250
  ])
25940
26251
  );
25941
26252
  const ranked = slots.map((slot) => {
25942
26253
  let changes = 0;
25943
26254
  if (swiftFrameworkSlotKey(slot) === null) return { slot, changes: Infinity };
25944
- const source = import_node_path46.default.join(slot, "source", "packages", import_node_path46.default.basename(moduleRoot));
26255
+ const source = import_node_path47.default.join(slot, "source", "packages", import_node_path47.default.basename(moduleRoot));
25945
26256
  for (const [file, contents2] of inputs) {
25946
26257
  try {
25947
- if (!(0, import_node_fs45.readFileSync)(import_node_path46.default.join(source, file)).equals(contents2)) changes++;
26258
+ const candidate = import_node_path47.default.join(source, file);
26259
+ if ((0, import_node_fs45.statSync)(candidate).size !== contents2.length || !(0, import_node_fs45.readFileSync)(candidate).equals(contents2))
26260
+ changes++;
25948
26261
  } catch (error) {
25949
26262
  if (!vanished(error)) throw error;
25950
26263
  changes++;
@@ -25955,11 +26268,13 @@ async function withSwiftFrameworkSlot(frameworkKey, moduleRoot, signal, work, un
25955
26268
  (left, right) => left.changes - right.changes || Number(own(right.slot)) - Number(own(left.slot)) || (built.get(right.slot) ?? 0) - (built.get(left.slot) ?? 0)
25956
26269
  );
25957
26270
  for (const { slot, changes } of ranked) {
26271
+ if (await hasLiveSwiftRootReaders(slot, signal)) continue;
25958
26272
  const result = await withSwiftRootLock(
25959
26273
  slot,
25960
26274
  async (lease) => {
26275
+ if (await hasLiveSwiftRootReaders(slot, signal)) return void 0;
25961
26276
  console.error(
25962
- `[swift-framework-cache] ${import_node_path46.default.basename(slot)} changedInputs=${changes} totalInputs=${inputs.size}`
26277
+ `[swift-framework-cache] ${import_node_path47.default.basename(slot)} changedInputs=${changes} totalInputs=${inputs.size}`
25963
26278
  );
25964
26279
  return { value: await run5(slot)(lease) };
25965
26280
  },
@@ -25978,8 +26293,8 @@ function mirrorTree2(source, target, skip) {
25978
26293
  for (const entry of (0, import_node_fs45.readdirSync)(source, { withFileTypes: true })) {
25979
26294
  if (entry.name === skip) continue;
25980
26295
  wanted.add(entry.name);
25981
- const from = import_node_path46.default.join(source, entry.name);
25982
- const to = import_node_path46.default.join(target, entry.name);
26296
+ const from = import_node_path47.default.join(source, entry.name);
26297
+ const to = import_node_path47.default.join(target, entry.name);
25983
26298
  let existing = null;
25984
26299
  try {
25985
26300
  existing = (0, import_node_fs45.lstatSync)(to);
@@ -26008,47 +26323,49 @@ function mirrorTree2(source, target, skip) {
26008
26323
  }
26009
26324
  for (const name3 of (0, import_node_fs45.readdirSync)(target))
26010
26325
  if (!wanted.has(name3) && name3 !== skip) {
26011
- (0, import_node_fs45.rmSync)(import_node_path46.default.join(target, name3), { recursive: true, force: true });
26326
+ (0, import_node_fs45.rmSync)(import_node_path47.default.join(target, name3), { recursive: true, force: true });
26012
26327
  restructured = true;
26013
26328
  }
26014
26329
  return restructured;
26015
26330
  }
26016
26331
  function stageFrameworkSource(moduleRoot, slot, frameworkKey, release) {
26017
26332
  if (!slot) return moduleRoot;
26018
- const staged = import_node_path46.default.join(slot, "source");
26019
- const stagedModule = import_node_path46.default.join(staged, "packages", import_node_path46.default.basename(moduleRoot));
26333
+ const staged = import_node_path47.default.join(slot, "source");
26334
+ const stagedModule = import_node_path47.default.join(staged, "packages", import_node_path47.default.basename(moduleRoot));
26020
26335
  const hadKey = swiftFrameworkSlotKey(slot);
26021
26336
  if (hadKey !== frameworkKey) {
26022
- (0, import_node_fs45.rmSync)(import_node_path46.default.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), { force: true });
26337
+ (0, import_node_fs45.rmSync)(import_node_path47.default.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), { force: true });
26338
+ (0, import_node_fs45.rmSync)(import_node_path47.default.join(slot, "products-ready"), { recursive: true, force: true });
26339
+ (0, import_node_fs45.rmSync)(import_node_path47.default.join(slot, "lib", ".receipt"), { force: true });
26023
26340
  const moduleRestructured = mirrorTree2(moduleRoot, stagedModule, ".build");
26024
26341
  const sdkRestructured = mirrorTree2(
26025
26342
  swiftSharedSdkRoot(moduleRoot, false),
26026
- import_node_path46.default.join(staged, "packages/peachsim/sdk/ios")
26343
+ import_node_path47.default.join(staged, "packages/peachsim/sdk/ios")
26027
26344
  );
26028
26345
  if (moduleRestructured || sdkRestructured || hadKey === null) {
26029
- (0, import_node_fs45.rmSync)(import_node_path46.default.join(slot, "release.yaml"), { force: true });
26030
- (0, import_node_fs45.rmSync)(import_node_path46.default.join(slot, WASM_TRIPLE, "release", "description.json"), {
26346
+ (0, import_node_fs45.rmSync)(import_node_path47.default.join(slot, "release.yaml"), { force: true });
26347
+ (0, import_node_fs45.rmSync)(import_node_path47.default.join(slot, WASM_TRIPLE, "release", "description.json"), {
26031
26348
  force: true
26032
26349
  });
26033
26350
  }
26034
26351
  for (const file of swiftModuleInputFiles(moduleRoot)) {
26035
26352
  if (!file.startsWith("../")) continue;
26036
- const from = import_node_path46.default.resolve(moduleRoot, file);
26037
- const to = import_node_path46.default.resolve(stagedModule, file);
26353
+ const from = import_node_path47.default.resolve(moduleRoot, file);
26354
+ const to = import_node_path47.default.resolve(stagedModule, file);
26038
26355
  if ((0, import_node_fs45.existsSync)(to) && (0, import_node_fs45.readFileSync)(from).equals((0, import_node_fs45.readFileSync)(to))) continue;
26039
- (0, import_node_fs45.mkdirSync)(import_node_path46.default.dirname(to), { recursive: true });
26356
+ (0, import_node_fs45.mkdirSync)(import_node_path47.default.dirname(to), { recursive: true });
26040
26357
  (0, import_node_fs45.copyFileSync)(from, to);
26041
26358
  }
26042
26359
  if (swiftProjectBuildKey(stagedModule, release) !== frameworkKey)
26043
26360
  throw new Error("Swift staged framework source differs from the caller");
26044
- const modules = import_node_path46.default.join(staged, "node_modules");
26045
- const target = (0, import_node_fs45.realpathSync)(import_node_path46.default.join(moduleRoot, "../../node_modules"));
26361
+ const modules = import_node_path47.default.join(staged, "node_modules");
26362
+ const target = (0, import_node_fs45.realpathSync)(import_node_path47.default.join(moduleRoot, "../../node_modules"));
26046
26363
  if (!(0, import_node_fs45.existsSync)(modules) || (0, import_node_fs45.readlinkSync)(modules) !== target) {
26047
26364
  (0, import_node_fs45.rmSync)(modules, { recursive: true, force: true });
26048
26365
  (0, import_node_fs45.symlinkSync)(target, modules);
26049
26366
  }
26050
- (0, import_node_fs45.writeFileSync)(import_node_path46.default.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), frameworkKey);
26051
- (0, import_node_fs45.writeFileSync)(import_node_path46.default.join(slot, SWIFT_FRAMEWORK_SLOT_ORIGIN), moduleRoot);
26367
+ (0, import_node_fs45.writeFileSync)(import_node_path47.default.join(slot, SWIFT_FRAMEWORK_SLOT_KEY), frameworkKey);
26368
+ (0, import_node_fs45.writeFileSync)(import_node_path47.default.join(slot, SWIFT_FRAMEWORK_SLOT_ORIGIN), moduleRoot);
26052
26369
  }
26053
26370
  return stagedModule;
26054
26371
  }
@@ -26064,18 +26381,18 @@ ${args.frameworkKey}
26064
26381
  const stat = (0, import_node_fs45.statSync)(file, { bigint: true });
26065
26382
  return `${stat.size}:${stat.mtimeNs}`;
26066
26383
  };
26067
- for (const object3 of args.prebuilt.objects)
26384
+ for (const object4 of args.prebuilt.objects)
26068
26385
  hash.update(`object
26069
- ${object3}
26070
- ${statOf(object3)}`);
26071
- for (const object3 of args.prebuilt.lazyObjects)
26386
+ ${object4}
26387
+ ${statOf(object4)}`);
26388
+ for (const object4 of args.prebuilt.lazyObjects)
26072
26389
  hash.update(`lazy-object
26073
- ${object3}
26074
- ${statOf(object3)}`);
26075
- for (const object3 of args.prebuilt.providers)
26390
+ ${object4}
26391
+ ${statOf(object4)}`);
26392
+ for (const object4 of args.prebuilt.providers)
26076
26393
  hash.update(`provider
26077
- ${object3}
26078
- ${statOf(object3)}`);
26394
+ ${object4}
26395
+ ${statOf(object4)}`);
26079
26396
  for (const map of args.prebuilt.moduleMaps)
26080
26397
  hash.update(`module-map
26081
26398
  ${map}
@@ -26088,7 +26405,7 @@ ${args.prebuilt.modules}
26088
26405
  `);
26089
26406
  for (const entry of (0, import_node_fs45.readdirSync)(args.prebuilt.modules).sort())
26090
26407
  hash.update(`${entry}
26091
- ${statOf(import_node_path46.default.join(args.prebuilt.modules, entry))}`);
26408
+ ${statOf(import_node_path47.default.join(args.prebuilt.modules, entry))}`);
26092
26409
  return hash.digest("hex");
26093
26410
  }
26094
26411
  function retireSwiftLinkTargets(retired) {
@@ -26097,13 +26414,13 @@ function retireSwiftLinkTargets(retired) {
26097
26414
  "peach-product-checkpoints",
26098
26415
  "peach-swift-header-checkpoints"
26099
26416
  ]) {
26100
- (0, import_node_fs45.rmSync)(import_node_path46.default.join(retired, name3), { recursive: true, force: true });
26417
+ (0, import_node_fs45.rmSync)(import_node_path47.default.join(retired, name3), { recursive: true, force: true });
26101
26418
  }
26102
- const releaseLink = import_node_path46.default.join(retired, "release");
26419
+ const releaseLink = import_node_path47.default.join(retired, "release");
26103
26420
  if (!(0, import_node_fs45.existsSync)(releaseLink)) return;
26104
26421
  const releaseDir = (0, import_node_fs45.realpathSync)(releaseLink);
26105
26422
  for (const entry of (0, import_node_fs45.readdirSync)(releaseDir, { withFileTypes: true })) {
26106
- const targetPath = import_node_path46.default.join(releaseDir, entry.name);
26423
+ const targetPath = import_node_path47.default.join(releaseDir, entry.name);
26107
26424
  if (entry.name === "ModuleCache" || entry.name === "Modules" || entry.name.endsWith(".product") || entry.name.endsWith(".wasm")) {
26108
26425
  (0, import_node_fs45.rmSync)(targetPath, { recursive: true, force: true });
26109
26426
  continue;
@@ -26116,7 +26433,7 @@ function retireSwiftLinkTargets(retired) {
26116
26433
  }
26117
26434
  }
26118
26435
  function retireStaleSwiftLink(root, baseStamp, stamp, preserveClangObjects = false) {
26119
- const receipt = import_node_path46.default.join(root, SWIFT_LINK_STAMP);
26436
+ const receipt = import_node_path47.default.join(root, SWIFT_LINK_STAMP);
26120
26437
  let previous = null;
26121
26438
  try {
26122
26439
  previous = (0, import_node_fs45.readFileSync)(receipt, "utf8").trim();
@@ -26128,7 +26445,7 @@ function retireStaleSwiftLink(root, baseStamp, stamp, preserveClangObjects = fal
26128
26445
  ${stamp}`;
26129
26446
  (0, import_node_fs45.writeFileSync)(receipt, `${combined}
26130
26447
  `);
26131
- const retired = import_node_path46.default.join(root, ".build");
26448
+ const retired = import_node_path47.default.join(root, ".build");
26132
26449
  if (previous === combined || !(0, import_node_fs45.existsSync)(retired)) return false;
26133
26450
  const [previousBase] = previous?.split("\n") ?? [];
26134
26451
  if (preserveClangObjects && previousBase === baseStamp) {
@@ -26154,7 +26471,7 @@ async function compileSwiftProjectOnce(sources, options) {
26154
26471
  (0, import_node_fs45.mkdirSync)(options.buildRoot, { recursive: true });
26155
26472
  const root = (0, import_node_fs45.realpathSync)(options.buildRoot);
26156
26473
  refreshSwiftCacheHold(root);
26157
- const moduleRoot = import_node_path46.default.resolve(options.moduleRoot);
26474
+ const moduleRoot = import_node_path47.default.resolve(options.moduleRoot);
26158
26475
  const distribution = swiftDistributionAt(moduleRoot);
26159
26476
  const mirrorDistribution = options.linkOnly || options.project ? null : distribution;
26160
26477
  if (distribution) refreshSwiftCacheHold(moduleRoot);
@@ -26168,7 +26485,7 @@ async function compileSwiftProjectOnce(sources, options) {
26168
26485
  throw new Error("swift-compile: link-only builds do not support guest image graphs");
26169
26486
  const layout2 = {
26170
26487
  root,
26171
- sources: import_node_path46.default.join(root, "Sources", "App"),
26488
+ sources: import_node_path47.default.join(root, "Sources", "App"),
26172
26489
  multi: compileTargets(input).length > 0
26173
26490
  };
26174
26491
  const sdkModule = options.sdkModule && !options.linkOnly;
@@ -26184,7 +26501,7 @@ async function compileSwiftProjectOnce(sources, options) {
26184
26501
  const hash = sdkImage ? (0, import_node_crypto29.createHash)("sha256").update(`${sourceHash}
26185
26502
  sdk module ${sdkImage.key}`).digest("hex") : sourceHash;
26186
26503
  const frameworkKey = swiftProjectBuildKey(moduleRoot, options.release);
26187
- const sharedRoot = import_node_path46.default.join(swiftCacheDir(), "swift-projects", hash);
26504
+ const sharedRoot = import_node_path47.default.join(swiftCacheDir(), "swift-projects", hash);
26188
26505
  const report = (message) => {
26189
26506
  console.error(`[swift-project ${hash.slice(0, 16)}] ${message}`);
26190
26507
  options.onStage?.(message);
@@ -26199,8 +26516,8 @@ sdk module ${sdkImage.key}`).digest("hex") : sourceHash;
26199
26516
  report("reusing memory artifact");
26200
26517
  return retain(root, retained);
26201
26518
  }
26202
- const cached2 = readCompiledArtifact(import_node_path46.default.join(sharedRoot, "artifact"), hash);
26203
- const previous = cached2 ?? (options.project ? null : readCompiledArtifact(import_node_path46.default.join(root, "artifact"), hash));
26519
+ const cached2 = readCompiledArtifact(import_node_path47.default.join(sharedRoot, "artifact"), hash);
26520
+ const previous = cached2 ?? (options.project ? null : readCompiledArtifact(import_node_path47.default.join(root, "artifact"), hash));
26204
26521
  if (previous) {
26205
26522
  if (cached2) renewSharedArtifact(sharedRoot);
26206
26523
  else saveSharedArtifact(sharedRoot, previous);
@@ -26210,8 +26527,8 @@ sdk module ${sdkImage.key}`).digest("hex") : sourceHash;
26210
26527
  }
26211
26528
  if (!options.intermediates && !sdkImage && process.platform === "darwin" && process.env.TM_SESSION && !windowAdmission() && process.env.CI !== "true" && moduleRoot === sourceSwiftCheckout() && !swiftDistributionAt(moduleRoot)) {
26212
26529
  const requestRoot = (0, import_node_fs45.mkdtempSync)(`${root}.builder-request-`);
26213
- const output = import_node_path46.default.join(requestRoot, "output");
26214
- const request = import_node_path46.default.join(requestRoot, "request.json");
26530
+ const output = import_node_path47.default.join(requestRoot, "output");
26531
+ const request = import_node_path47.default.join(requestRoot, "request.json");
26215
26532
  (0, import_node_fs45.writeFileSync)(
26216
26533
  request,
26217
26534
  JSON.stringify({
@@ -26225,13 +26542,13 @@ sdk module ${sdkImage.key}`).digest("hex") : sourceHash;
26225
26542
  })
26226
26543
  );
26227
26544
  try {
26228
- const repo = import_node_path46.default.resolve(moduleRoot, "../..");
26545
+ const repo = import_node_path47.default.resolve(moduleRoot, "../..");
26229
26546
  const timeout = swiftBuilderHopTimeoutMs(options.timeoutMs);
26230
26547
  report("requesting builder admission or cached result");
26231
26548
  await runCompiler(
26232
26549
  "bun",
26233
26550
  [
26234
- import_node_path46.default.join(repo, "scripts/build/swift-project.ts"),
26551
+ import_node_path47.default.join(repo, "scripts/build/swift-project.ts"),
26235
26552
  "--request",
26236
26553
  request,
26237
26554
  "--output",
@@ -26281,13 +26598,13 @@ ${cap}` : "";
26281
26598
  root,
26282
26599
  async (lease) => {
26283
26600
  if (!options.intermediates) {
26284
- const built = readCompiledArtifact(import_node_path46.default.join(sharedRoot, "artifact"), hash);
26601
+ const built = readCompiledArtifact(import_node_path47.default.join(sharedRoot, "artifact"), hash);
26285
26602
  if (built) {
26286
26603
  report("reusing verified disk artifact");
26287
26604
  return retain(root, built);
26288
26605
  }
26289
26606
  }
26290
- const swift = import_node_path46.default.join(options.toolchainBin, "swift");
26607
+ const swift = import_node_path47.default.join(options.toolchainBin, "swift");
26291
26608
  if (!(0, import_node_fs45.existsSync)(swift)) {
26292
26609
  throw new Error(
26293
26610
  `swift-compile: no swift.org toolchain at ${options.toolchainBin}; install ${options.release} and its matching wasm sdk`
@@ -26301,54 +26618,82 @@ ${cap}` : "";
26301
26618
  work,
26302
26619
  unoptimized
26303
26620
  );
26304
- return withFrameworkLock(async (slot, frameworkLease) => {
26621
+ const baseBuildEnv = {
26622
+ ...options.project?.env ?? process.env,
26623
+ // shipped host plugins resolve against the selected compiler's runtime.
26624
+ ...process.platform === "linux" ? {
26625
+ LD_LIBRARY_PATH: [
26626
+ import_node_path47.default.resolve(options.toolchainBin, "../lib/swift/linux"),
26627
+ import_node_path47.default.resolve(options.toolchainBin, "../lib/swift/host"),
26628
+ process.env.LD_LIBRARY_PATH
26629
+ ].filter(Boolean).join(":")
26630
+ } : {},
26631
+ PEACH_DEFER_WASM_LINK: "1"
26632
+ };
26633
+ const {
26634
+ frameworkRoot,
26635
+ compileFrameworkRoot,
26636
+ macroPlugins,
26637
+ sdk,
26638
+ icu,
26639
+ prebuilt,
26640
+ readHold
26641
+ } = await withFrameworkLock(async (slot, frameworkLease) => {
26305
26642
  budget.startCompile();
26306
- const frameworkRoot = mirrorDistribution ? syncSwiftDistributionMirror(root, moduleRoot, mirrorDistribution) : distribution ? moduleRoot : stageFrameworkSource(moduleRoot, slot, frameworkKey, options.release);
26307
- if (!swiftModuleDigest(frameworkRoot).equals(moduleDigest))
26643
+ if (slot && swiftFrameworkSlotKey(slot) !== frameworkKey)
26644
+ await waitForNoSwiftRootReaders(slot, budget.signal);
26645
+ const frameworkRoot2 = mirrorDistribution ? syncSwiftDistributionMirror(root, moduleRoot, mirrorDistribution) : distribution ? moduleRoot : stageFrameworkSource(moduleRoot, slot, frameworkKey, options.release);
26646
+ if (!swiftModuleDigest(frameworkRoot2).equals(moduleDigest))
26308
26647
  throw new Error("Swift staged project source differs from the caller");
26309
26648
  report("preparing compiler plugins");
26310
- const macroPlugins = await ensureMacroPlugins(
26311
- frameworkRoot,
26649
+ const macroPlugins2 = await ensureMacroPlugins(
26650
+ frameworkRoot2,
26312
26651
  options.toolchainBin,
26313
26652
  options.release,
26314
26653
  budget.signal,
26315
26654
  frameworkLease
26316
26655
  );
26317
- const compileFrameworkRoot = distribution ? swiftDistributionCompileView(frameworkRoot, distribution) : frameworkRoot;
26318
- const sdk = swiftModuleSdk(frameworkRoot).wasmSdkId;
26319
- const icu = options.linkOnly ? null : swiftIcuAsset(options.toolchainBin, sdk);
26320
- const buildOptions = {
26321
- env: {
26322
- ...options.project?.env ?? process.env,
26323
- // shipped host plugins resolve against the selected compiler's runtime.
26324
- ...process.platform === "linux" ? {
26325
- LD_LIBRARY_PATH: [
26326
- import_node_path46.default.resolve(options.toolchainBin, "../lib/swift/linux"),
26327
- import_node_path46.default.resolve(options.toolchainBin, "../lib/swift/host"),
26328
- process.env.LD_LIBRARY_PATH
26329
- ].filter(Boolean).join(":")
26330
- } : {},
26331
- PEACH_DEFER_WASM_LINK: "1"
26332
- },
26333
- maxBuffer: 64 * 1024 * 1024,
26334
- signal: budget.signal,
26335
- lease,
26336
- frameworkLease
26337
- };
26338
- let prebuilt;
26656
+ const compileFrameworkRoot2 = distribution ? swiftDistributionCompileView(frameworkRoot2, distribution) : frameworkRoot2;
26657
+ const sdk2 = swiftModuleSdk(frameworkRoot2).wasmSdkId;
26658
+ const icu2 = options.linkOnly ? null : swiftIcuAsset(options.toolchainBin, sdk2);
26659
+ let prebuilt2;
26339
26660
  if (!distribution) {
26340
26661
  report("compiling framework products");
26341
- prebuilt = await buildFrameworkProducts(slot, {
26342
- moduleRoot: frameworkRoot,
26662
+ prebuilt2 = await buildFrameworkProducts(slot, {
26663
+ moduleRoot: frameworkRoot2,
26343
26664
  frameworkKey,
26344
26665
  input,
26345
26666
  swift,
26346
- sdk,
26667
+ sdk: sdk2,
26347
26668
  toolchainBin: options.toolchainBin,
26348
- plugins: macroPlugins,
26349
- buildOptions
26669
+ plugins: macroPlugins2,
26670
+ buildOptions: {
26671
+ env: baseBuildEnv,
26672
+ maxBuffer: 64 * 1024 * 1024,
26673
+ signal: budget.signal,
26674
+ lease,
26675
+ frameworkLease
26676
+ }
26350
26677
  });
26351
26678
  }
26679
+ const readHold2 = slot ? acquireSwiftRootReadHold(slot) : void 0;
26680
+ return {
26681
+ frameworkRoot: frameworkRoot2,
26682
+ compileFrameworkRoot: compileFrameworkRoot2,
26683
+ macroPlugins: macroPlugins2,
26684
+ sdk: sdk2,
26685
+ icu: icu2,
26686
+ prebuilt: prebuilt2,
26687
+ readHold: readHold2
26688
+ };
26689
+ });
26690
+ const buildOptions = {
26691
+ env: baseBuildEnv,
26692
+ maxBuffer: 64 * 1024 * 1024,
26693
+ signal: budget.signal,
26694
+ lease
26695
+ };
26696
+ try {
26352
26697
  if (options.project) removeProjectLinks(root);
26353
26698
  const packageHostMacros = process.platform === "linux" ? input.packageHostMacros : void 0;
26354
26699
  if (retireStaleSwiftLink(
@@ -26376,7 +26721,7 @@ ${cap}` : "";
26376
26721
  !options.project,
26377
26722
  options.project ? false : options.objcPrebuiltStage ?? (options.intermediates ? false : void 0)
26378
26723
  );
26379
- const productFile = import_node_path46.default.join(frameworkRoot, SWIFT_FRAMEWORK_PRODUCT_FILE);
26724
+ const productFile = import_node_path47.default.join(frameworkRoot, SWIFT_FRAMEWORK_PRODUCT_FILE);
26380
26725
  writeSwiftAutolinkLinker(
26381
26726
  root,
26382
26727
  options.toolchainBin,
@@ -26387,9 +26732,9 @@ ${cap}` : "";
26387
26732
  ).product.name
26388
26733
  ] : []
26389
26734
  );
26390
- const compiler = preparation.targetToolset ? { CC: import_node_path46.default.join(root, CLANG_TARGET_MODULE_WRAPPER) } : {};
26735
+ const compiler = preparation.targetToolset ? { CC: import_node_path47.default.join(root, CLANG_TARGET_MODULE_WRAPPER) } : {};
26391
26736
  if (packageHostMacros?.length) {
26392
- const swiftc = import_node_path46.default.join(root, SWIFT_HOST_COMPILER_WRAPPER);
26737
+ const swiftc = import_node_path47.default.join(root, SWIFT_HOST_COMPILER_WRAPPER);
26393
26738
  writeBuildFile(
26394
26739
  swiftc,
26395
26740
  [
@@ -26416,10 +26761,10 @@ ${cap}` : "";
26416
26761
  (0, import_node_fs45.chmodSync)(swiftc, 493);
26417
26762
  compiler.SWIFT_EXEC = swiftc;
26418
26763
  compiler.PEACH_SWIFT_HOST_MACROS = packageHostMacros.join(",");
26419
- compiler.PEACH_SWIFTC = import_node_path46.default.join(options.toolchainBin, "swiftc");
26764
+ compiler.PEACH_SWIFTC = import_node_path47.default.join(options.toolchainBin, "swiftc");
26420
26765
  }
26421
26766
  const projectProcess = options.project ? prepareSwiftProjectProcess(root, options.project) : void 0;
26422
- const temporaryDirectory = projectProcess ? void 0 : import_node_path46.default.join(root, ".build", "peach-compiler-tmp");
26767
+ const temporaryDirectory = projectProcess ? void 0 : import_node_path47.default.join(root, ".build", "peach-compiler-tmp");
26423
26768
  const appOptions = projectProcess ? {
26424
26769
  ...buildOptions,
26425
26770
  uid: projectProcess.uid,
@@ -26437,10 +26782,10 @@ ${cap}` : "";
26437
26782
  for (const [file, text2] of Object.entries(input.files)) {
26438
26783
  const parents = /^#include "((?:\.\.\/)+)[^"\n]+"\n$/.exec(text2)?.[1];
26439
26784
  if (!parents) continue;
26440
- const directory = import_node_path46.default.posix.dirname(file);
26785
+ const directory = import_node_path47.default.posix.dirname(file);
26441
26786
  forwarders.set(
26442
- `${import_node_path46.default.join(root, directory)}/${parents.slice(0, -1)}`,
26443
- import_node_path46.default.posix.join("build", directory, parents).replace(/\/$/, "")
26787
+ `${import_node_path47.default.join(root, directory)}/${parents.slice(0, -1)}`,
26788
+ import_node_path47.default.posix.join("build", directory, parents).replace(/\/$/, "")
26444
26789
  );
26445
26790
  }
26446
26791
  const jobs = swiftCompilerJobs();
@@ -26459,7 +26804,7 @@ ${cap}` : "";
26459
26804
  ...swiftObjCSelectorOptions(frameworkRoot),
26460
26805
  "--swift-sdk",
26461
26806
  sdk,
26462
- ...preparation.targetToolset ? ["--toolset", import_node_path46.default.join(root, ".peach-target-toolset.json")] : [],
26807
+ ...preparation.targetToolset ? ["--toolset", import_node_path47.default.join(root, ".peach-target-toolset.json")] : [],
26463
26808
  "-c",
26464
26809
  "release",
26465
26810
  ...input.unoptimized ? ["-Xswiftc", "-Onone"] : [],
@@ -26478,19 +26823,16 @@ ${cap}` : "";
26478
26823
  // the link strips debug info, so none is generated (as for the framework)
26479
26824
  "-Xswiftc",
26480
26825
  "-gnone",
26481
- "-Xswiftc",
26482
- "-num-threads",
26483
- "-Xswiftc",
26484
- String(perFile ? 1 : jobs),
26826
+ ...incrementalPreview ? [] : ["-Xswiftc", "-num-threads", "-Xswiftc", String(perFile ? 1 : jobs)],
26485
26827
  ...swiftReproducibleBuildFlags([
26486
- [import_node_path46.default.dirname(options.toolchainBin), "toolchain"],
26828
+ [import_node_path47.default.dirname(options.toolchainBin), "toolchain"],
26487
26829
  [compileFrameworkRoot, "framework"],
26488
26830
  [root, "build"],
26489
26831
  ...forwarders
26490
26832
  ]).flatMap((flag, index, flags) => {
26491
26833
  if (!nativeToolset || !flag.startsWith("-ffile-prefix-map="))
26492
26834
  return [flag];
26493
- const toolchainDir = import_node_path46.default.dirname(options.toolchainBin);
26835
+ const toolchainDir = import_node_path47.default.dirname(options.toolchainBin);
26494
26836
  let mapped = flag;
26495
26837
  for (const [dir, target] of [
26496
26838
  [root, "/peach/build"],
@@ -26519,12 +26861,12 @@ ${cap}` : "";
26519
26861
  ])
26520
26862
  ];
26521
26863
  const linked = builtArtifact(layout2);
26522
- (0, import_node_fs45.rmSync)(import_node_path46.default.join(root, ".peach-link.rsp"), { force: true });
26864
+ (0, import_node_fs45.rmSync)(import_node_path47.default.join(root, ".peach-link.rsp"), { force: true });
26523
26865
  if (options.linkOnly || (0, import_node_fs45.existsSync)(linked) && (0, import_node_fs45.statSync)(linked).size <= 8)
26524
26866
  (0, import_node_fs45.rmSync)(linked, { force: true });
26525
26867
  report("compiling and linking Swift modules");
26526
26868
  const frameworkInterfaces = /* @__PURE__ */ new Map();
26527
- const sdkFrameworks = import_node_path46.default.join(
26869
+ const sdkFrameworks = import_node_path47.default.join(
26528
26870
  swiftSdkPaths(frameworkRoot, options.toolchainBin).darwin,
26529
26871
  "System/Library/Frameworks"
26530
26872
  );
@@ -26539,30 +26881,30 @@ ${cap}` : "";
26539
26881
  const name3 = moduleMapName(contents2);
26540
26882
  const umbrella = /\bumbrella\s+header\s+"([^"]+)"/.exec(contents2)?.[1];
26541
26883
  if (!name3 || !umbrella) continue;
26542
- const header = input.files[import_node_path46.default.posix.join(import_node_path46.default.posix.dirname(file), umbrella)];
26884
+ const header = input.files[import_node_path47.default.posix.join(import_node_path47.default.posix.dirname(file), umbrella)];
26543
26885
  if (header === void 0) continue;
26544
26886
  const included = new Set(
26545
26887
  [
26546
26888
  ...header.matchAll(/^\s*#\s*(?:import|include)\s*[<"]([^">]+)[">]/gm)
26547
- ].map((match) => import_node_path46.default.posix.basename(match[1]))
26889
+ ].map((match) => import_node_path47.default.posix.basename(match[1]))
26548
26890
  );
26549
26891
  const declarations = nativeDeclarations.get(name3) ?? /* @__PURE__ */ new Set();
26550
26892
  for (const declaration of swiftInterfaceDeclarations(header))
26551
26893
  declarations.add(declaration);
26552
26894
  for (const [candidate, source] of Object.entries(input.files))
26553
- if (included.has(import_node_path46.default.posix.basename(candidate)))
26895
+ if (included.has(import_node_path47.default.posix.basename(candidate)))
26554
26896
  for (const declaration of swiftInterfaceDeclarations(source))
26555
26897
  declarations.add(declaration);
26556
26898
  nativeDeclarations.set(name3, declarations);
26557
26899
  }
26558
26900
  const frameworkInterface = (name3) => {
26559
26901
  if (frameworkInterfaces.has(name3)) return frameworkInterfaces.get(name3);
26560
- const source = distribution ? import_node_path46.default.join(frameworkRoot, "modules", `${name3}-Swift.h`) : prebuilt.objcHeaders.get(name3);
26902
+ const source = distribution ? import_node_path47.default.join(frameworkRoot, "modules", `${name3}-Swift.h`) : prebuilt.objcHeaders.get(name3);
26561
26903
  if (!source || !(0, import_node_fs45.existsSync)(source)) {
26562
26904
  frameworkInterfaces.set(name3, null);
26563
26905
  return null;
26564
26906
  }
26565
- const headers = import_node_path46.default.join(sdkFrameworks, `${name3}.framework/Headers`);
26907
+ const headers = import_node_path47.default.join(sdkFrameworks, `${name3}.framework/Headers`);
26566
26908
  const declared = /* @__PURE__ */ new Set();
26567
26909
  if ((0, import_node_fs45.existsSync)(headers)) {
26568
26910
  for (const file of (0, import_node_fs45.readdirSync)(headers, {
@@ -26571,7 +26913,7 @@ ${cap}` : "";
26571
26913
  }))
26572
26914
  if (file.endsWith(".h"))
26573
26915
  for (const name4 of swiftInterfaceDeclarations(
26574
- (0, import_node_fs45.readFileSync)(import_node_path46.default.join(headers, file), "utf8")
26916
+ (0, import_node_fs45.readFileSync)(import_node_path47.default.join(headers, file), "utf8")
26575
26917
  ))
26576
26918
  declared.add(name4);
26577
26919
  }
@@ -26600,20 +26942,20 @@ ${cap}` : "";
26600
26942
  [...new Set(foreign.values())].map((owner) => `#import <${owner}/${owner}.h>`).join("\n")
26601
26943
  ) : own;
26602
26944
  const value = {
26603
- file: import_node_path46.default.join(root, ".build/peach-framework-objc", `${name3}-Swift.h`),
26945
+ file: import_node_path47.default.join(root, ".build/peach-framework-objc", `${name3}-Swift.h`),
26604
26946
  header,
26605
26947
  module: (0, import_node_fs45.existsSync)(headers)
26606
26948
  };
26607
26949
  frameworkInterfaces.set(name3, value);
26608
26950
  writeBuildFile(
26609
26951
  value.file,
26610
- ((0, import_node_fs45.existsSync)(import_node_path46.default.join(headers, `${name3}.h`)) ? `#import <${name3}/${name3}.h>
26952
+ ((0, import_node_fs45.existsSync)(import_node_path47.default.join(headers, `${name3}.h`)) ? `#import <${name3}/${name3}.h>
26611
26953
  ` : "") + swiftHeaderWithSuperclassImports(header, frameworkInterface)
26612
26954
  );
26613
26955
  return value;
26614
26956
  };
26615
26957
  const headerPaths = (producer) => {
26616
- const stem = import_node_path46.default.join(
26958
+ const stem = import_node_path47.default.join(
26617
26959
  root,
26618
26960
  ".build",
26619
26961
  "peach-cxx-headers",
@@ -26641,7 +26983,7 @@ ${cap}` : "";
26641
26983
  };
26642
26984
  const recipe = inputHash.copy().update(
26643
26985
  distribution ? swiftCompileSurfaceDigest(frameworkRoot) : moduleDigest
26644
- ).update((0, import_node_fs45.readFileSync)(import_node_path46.default.join(root, "Package.swift"))).update(JSON.stringify(buildArgs)).digest("hex");
26986
+ ).update((0, import_node_fs45.readFileSync)(import_node_path47.default.join(root, "Package.swift"))).update(JSON.stringify(buildArgs)).digest("hex");
26645
26987
  const runApp = async (compiler2) => {
26646
26988
  const optionsWithCompiler = compiler2 ? { ...appOptions, env: { ...appOptions.env, ...compiler2 } } : appOptions;
26647
26989
  const stages = [
@@ -26655,9 +26997,9 @@ ${cap}` : "";
26655
26997
  producers: []
26656
26998
  }))
26657
26999
  ];
26658
- const checkpoints = import_node_path46.default.join(root, ".build", "peach-product-checkpoints");
27000
+ const checkpoints = import_node_path47.default.join(root, ".build", "peach-product-checkpoints");
26659
27001
  for (const { target, producers } of stages) {
26660
- const receipt = import_node_path46.default.join(
27002
+ const receipt = import_node_path47.default.join(
26661
27003
  checkpoints,
26662
27004
  (0, import_node_crypto29.createHash)("sha256").update(target).digest("hex")
26663
27005
  );
@@ -26680,8 +27022,8 @@ ${cap}` : "";
26680
27022
  for (const header of headers) {
26681
27023
  if (!(0, import_node_fs45.existsSync)(header.original))
26682
27024
  (0, import_node_fs45.rmSync)(
26683
- import_node_path46.default.join(
26684
- import_node_path46.default.dirname(linked),
27025
+ import_node_path47.default.join(
27026
+ import_node_path47.default.dirname(linked),
26685
27027
  "Modules",
26686
27028
  `${swiftTargetModuleName(header.producer)}.swiftmodule`
26687
27029
  ),
@@ -26736,7 +27078,7 @@ ${cap}` : "";
26736
27078
  await compileApp();
26737
27079
  } catch (error) {
26738
27080
  const output2 = outputOf(error);
26739
- const moduleCache = import_node_path46.default.join(
27081
+ const moduleCache = import_node_path47.default.join(
26740
27082
  root,
26741
27083
  ".build",
26742
27084
  WASM_TRIPLE,
@@ -26771,10 +27113,10 @@ ${cap}` : "";
26771
27113
  }
26772
27114
  if (unprepared.length) throw new Error(unprepared.join("\n"));
26773
27115
  if (!(0, import_node_fs45.existsSync)(linked)) {
26774
- const binDir = import_node_path46.default.dirname(linked);
27116
+ const binDir = import_node_path47.default.dirname(linked);
26775
27117
  const found = (0, import_node_fs45.existsSync)(binDir) ? (0, import_node_fs45.readdirSync)(binDir).filter((name3) => name3.endsWith(".wasm")).sort() : [];
26776
27118
  throw new Error(
26777
- `swift-compile: the build produced no ${import_node_path46.default.basename(linked)} (found: ${found.join(", ") || "none"})`
27119
+ `swift-compile: the build produced no ${import_node_path47.default.basename(linked)} (found: ${found.join(", ") || "none"})`
26778
27120
  );
26779
27121
  }
26780
27122
  if (options.project) removeProjectLinks(root);
@@ -26805,10 +27147,10 @@ ${cap}` : "";
26805
27147
  const binding = await compileGuestLink({
26806
27148
  graph: guestGraph,
26807
27149
  buildDirectory: root,
26808
- releaseDirectory: import_node_path46.default.dirname(linked),
27150
+ releaseDirectory: import_node_path47.default.dirname(linked),
26809
27151
  moduleRoot: frameworkRoot,
26810
27152
  toolchainBin: options.toolchainBin,
26811
- swiftCompiler: preparation.headerCompiler ? import_node_path46.default.join(root, SWIFT_HEADER_COMPILER_WRAPPER) : compiler.SWIFT_EXEC ?? import_node_path46.default.join(options.toolchainBin, "swiftc"),
27153
+ swiftCompiler: preparation.headerCompiler ? import_node_path47.default.join(root, SWIFT_HEADER_COMPILER_WRAPPER) : compiler.SWIFT_EXEC ?? import_node_path47.default.join(options.toolchainBin, "swiftc"),
26812
27154
  sysroot: swiftSdkPaths(frameworkRoot, options.toolchainBin).sysroot,
26813
27155
  sdk: swiftModuleSdk(frameworkRoot),
26814
27156
  sdkImage,
@@ -26839,7 +27181,7 @@ ${cap}` : "";
26839
27181
  project: options.project && {
26840
27182
  ...options.project,
26841
27183
  env: { ...options.project.env, ...projectProcess?.env },
26842
- sdkRoot: import_node_path46.default.dirname(
27184
+ sdkRoot: import_node_path47.default.dirname(
26843
27185
  swiftSdkPaths(frameworkRoot, options.toolchainBin).sysroot
26844
27186
  ),
26845
27187
  linked: output
@@ -26854,7 +27196,7 @@ ${cap}` : "";
26854
27196
  }
26855
27197
  if (!sdkImage)
26856
27198
  await runCompiler(
26857
- import_node_path46.default.join(options.toolchainBin, "llvm-objcopy"),
27199
+ import_node_path47.default.join(options.toolchainBin, "llvm-objcopy"),
26858
27200
  ["--remove-section=.swift1_autolink_entries", optimized],
26859
27201
  buildOptions
26860
27202
  );
@@ -26870,7 +27212,9 @@ ${cap}` : "";
26870
27212
  saveSharedArtifact(sharedRoot, artifact);
26871
27213
  report("compiled artifact verified");
26872
27214
  return retain(root, artifact);
26873
- });
27215
+ } finally {
27216
+ readHold?.release();
27217
+ }
26874
27218
  },
26875
27219
  budget.signal
26876
27220
  );
@@ -26879,14 +27223,14 @@ ${cap}` : "";
26879
27223
  options.signal
26880
27224
  );
26881
27225
  }
26882
- var import_node_child_process28, import_node_crypto29, import_node_fs45, import_node_os11, import_node_path46, v6, WASM_TRIPLE, SWIFTPM_PROGRESS, SWIFTPM_NOISE, distributionManifests, distributionCompileViews, REACH_STAGED_FRAMEWORKS, objcEnumerations, clangDeclarationEnumCache, objcEnumForward, sdkDeclarationOwners, swiftInterfaceDeclarations, linkedModuleDigests, compileSurfaces, SYSTEM_MODULE_LIBRARIES, SYSTEM_MODULE_IMPORT, OPTIONAL_FRAMEWORK_DEPENDENCIES, OPTIONAL_FRAMEWORKS, SWIFT_IMPORT, kleeneNot, kleeneAnd, kleeneOr, NON_IOS_MODULES, sdkPaths, availableModules, sdkOverlayFrameworks, DISTRIBUTION_CLANG_MODULES, CLANG_DISTRIBUTION_MODULES, ONE_PRODUCT, GAME_FAMILY, gameProducts, gameProduct, GAME_REACH, FOUNDATION_IMPLICIT_MODULES, FRAMEWORK_COMPANION_IMPORT, ONE_IMPLICIT_FLAGS, executableLinkFlags, darwinRecordsRegion, REACTOR_FLAG, MULTI_MANIFEST_VERSION, SWIFT_HEADER_PRODUCTS_TARGET, compilerSourceDigest, nativeCxxCompilerFlags, MODULE_MAP_RESPONSE_FILE_RUN, cFlagArray, cxxFlagArray, SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET, OS_IOS, ARCH_ARM64, NOT_ON_IOS, DELEGATE_CLASS, ARM64_MACRO, WASM_MACRO, ARCH_WASM32, C_WORDS, archEnvironments, codeMasks, codeMaskChars, CODE_MASK_CACHE_CHARS, FOUNDATION_NETWORKING_TYPES, FOUNDATION_OVERLAY_TYPES, FOUNDATION_OVERLAY_GLOBALS, CORE_FOUNDATION_OVERLAY_GLOBALS, CORE_FOUNDATION_GEOMETRY_TYPES, CORE_FOUNDATION_GRAPHICS_TYPES, CORE_FOUNDATION_HANDLE_IMPORTS, emptyMacroEnvironment, wasmMacroEnvironment, cPredefineTable, cPredefineCache, HIDDEN_UNITS, FIRST_WINS_PAIRS, LAST_WINS_PAIRS, VALUE_FLAGS, LIBXML_REFERENCE, LIBXML_SOURCE, ROOT_LOCKS, host, rootLocks, SHARED_ARTIFACT_BUDGET_BYTES, SHARED_ARTIFACT_GRACE_MS, RETIRED_PREFIX, retainedArtifacts, FRAMEWORK_LINK_TARGET, SWIFT_LINK_STAMP, SWIFT_HOST_COMPILER_WRAPPER, SWIFT_FRAMEWORK_SLOTS, SWIFT_FRAMEWORK_UNOPTIMIZED_SLOTS, SWIFT_FRAMEWORK_SLOT_KEY, SWIFT_FRAMEWORK_SLOT_ORIGIN;
27226
+ var import_node_child_process28, import_node_crypto29, import_node_fs45, import_node_os11, import_node_path47, v6, WASM_TRIPLE, SWIFTPM_PROGRESS, SWIFTPM_NOISE, distributionManifests, distributionCompileViews, REACH_STAGED_FRAMEWORKS, objcEnumerations, clangDeclarationEnumCache, objcEnumForward, sdkDeclarationOwners, swiftInterfaceDeclarations, linkedModuleDigests, compileSurfaces, SYSTEM_MODULE_LIBRARIES, SYSTEM_MODULE_IMPORT, OPTIONAL_FRAMEWORK_DEPENDENCIES, OPTIONAL_FRAMEWORKS, SWIFT_IMPORT, kleeneNot, kleeneAnd, kleeneOr, NON_IOS_MODULES, sdkPaths, availableModules, sdkOverlayFrameworks, DISTRIBUTION_CLANG_MODULES, CLANG_DISTRIBUTION_MODULES, ONE_PRODUCT, GAME_FAMILY, gameProducts, gameProduct, GAME_REACH, FOUNDATION_IMPLICIT_MODULES, FRAMEWORK_COMPANION_IMPORT, ONE_IMPLICIT_FLAGS, executableLinkFlags, darwinRecordsRegion, REACTOR_FLAG, MULTI_MANIFEST_VERSION, SWIFT_HEADER_PRODUCTS_TARGET, compilerSourceDigest, nativeCxxCompilerFlags, MODULE_MAP_RESPONSE_FILE_RUN, cFlagArray, cxxFlagArray, SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET, OS_IOS, ARCH_ARM64, NOT_ON_IOS, DELEGATE_CLASS, ARM64_MACRO, WASM_MACRO, ARCH_WASM32, C_WORDS, archEnvironments, codeMasks, codeMaskChars, CODE_MASK_CACHE_CHARS, FOUNDATION_NETWORKING_TYPES, FOUNDATION_OVERLAY_TYPES, FOUNDATION_OVERLAY_GLOBALS, CORE_FOUNDATION_OVERLAY_GLOBALS, CORE_FOUNDATION_GEOMETRY_TYPES, CORE_FOUNDATION_GRAPHICS_TYPES, CORE_FOUNDATION_HANDLE_IMPORTS, emptyMacroEnvironment, wasmMacroEnvironment, cPredefineTable, cPredefineCache, HIDDEN_UNITS, FIRST_WINS_PAIRS, LAST_WINS_PAIRS, VALUE_FLAGS, LIBXML_REFERENCE, LIBXML_SOURCE, ROOT_LOCKS, host, rootLocks, SHARED_ARTIFACT_BUDGET_BYTES, SHARED_ARTIFACT_GRACE_MS, RETIRED_PREFIX, retainedArtifacts, FRAMEWORK_LINK_TARGET, frameworkProductsReceiptSchema, SWIFT_LINK_STAMP, SWIFT_HOST_COMPILER_WRAPPER, SWIFT_FRAMEWORK_SLOTS, SWIFT_FRAMEWORK_UNOPTIMIZED_SLOTS, SWIFT_FRAMEWORK_SLOT_KEY, SWIFT_FRAMEWORK_SLOT_ORIGIN;
26883
27227
  var init_swift_compile = __esm({
26884
27228
  "src/swift-compile.ts"() {
26885
27229
  import_node_child_process28 = require("node:child_process");
26886
27230
  import_node_crypto29 = require("node:crypto");
26887
27231
  import_node_fs45 = require("node:fs");
26888
27232
  import_node_os11 = __toESM(require("node:os"), 1);
26889
- import_node_path46 = __toESM(require("node:path"), 1);
27233
+ import_node_path47 = __toESM(require("node:path"), 1);
26890
27234
  v6 = __toESM(require("peachsim/vendor/valibot"), 1);
26891
27235
  init_admitted_mac_build();
26892
27236
  init_swift_c_predefines();
@@ -27111,7 +27455,7 @@ int EXUpdatesApplyBSDiffPatch(const char * _Nonnull oldFilePath,
27111
27455
  FRAMEWORK_COMPANION_IMPORT = /^[ \t]*((?:(?:@\w+(?:\([^)]*\))?|public|package|internal|fileprivate|private)[ \t]+)*)import[ \t]+(Foundation|UIKit|SwiftUI|Photos|CoreData|SystemConfiguration|Dispatch)[ \t]*;?[ \t]*$/;
27112
27456
  ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One"';
27113
27457
  executableLinkFlags = (root) => ` "-Xclang-linker", "-O0",
27114
- "-Xclang-linker", ${JSON.stringify(`-fuse-ld=${import_node_path46.default.join(root, SWIFT_AUTOLINK_LINKER)}`)},
27458
+ "-Xclang-linker", ${JSON.stringify(`-fuse-ld=${import_node_path47.default.join(root, SWIFT_AUTOLINK_LINKER)}`)},
27115
27459
  "-Xlinker", "-z", "-Xlinker", "stack-size=8372224",
27116
27460
  "-Xlinker", "--stack-first",
27117
27461
  "-Xlinker", "--global-base=8372224",
@@ -27126,7 +27470,7 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
27126
27470
  REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
27127
27471
  MULTI_MANIFEST_VERSION = 76;
27128
27472
  SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
27129
- compilerSourceDigest = true ? "d4cf22b53d08266bf9bd0238bffe899805f62daeb3d628664ee351830e496cda" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
27473
+ compilerSourceDigest = true ? "57c5faa7bb7758647030422e32db0f4a53fbab724723e220c14fea1e41d2391e" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
27130
27474
  nativeCxxCompilerFlags = ["-fno-cxx-modules"];
27131
27475
  MODULE_MAP_RESPONSE_FILE_RUN = 16;
27132
27476
  cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
@@ -27549,6 +27893,17 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
27549
27893
  RETIRED_PREFIX = ".retired-";
27550
27894
  retainedArtifacts = /* @__PURE__ */ new Map();
27551
27895
  FRAMEWORK_LINK_TARGET = "PeachFrameworkLink";
27896
+ frameworkProductsReceiptSchema = v6.object({
27897
+ modules: v6.string(),
27898
+ objects: v6.array(v6.string()),
27899
+ lazyObjects: v6.array(v6.string()),
27900
+ owners: v6.array(v6.tuple([v6.string(), v6.string()])),
27901
+ providers: v6.array(v6.string()),
27902
+ link: v6.array(v6.string()),
27903
+ moduleMaps: v6.array(v6.string()),
27904
+ objcHeaders: v6.array(v6.tuple([v6.string(), v6.string()])),
27905
+ archived: v6.array(v6.tuple([v6.string(), v6.string()]))
27906
+ });
27552
27907
  SWIFT_LINK_STAMP = ".peach-link-stamp";
27553
27908
  SWIFT_HOST_COMPILER_WRAPPER = ".peach-swiftc";
27554
27909
  SWIFT_FRAMEWORK_SLOTS = 8;