peachsim 0.1.2793 → 0.1.2795

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 (137) 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 +1183 -1003
  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-Q5VJTSKK.mjs → acorn-75V3OBXH.mjs} +3 -3
  27. package/dist-lib/esm-chunks/{chunk-TADAJDSF.mjs → chunk-2RTQFMA3.mjs} +1 -1
  28. package/dist-lib/esm-chunks/{chunk-PTIDPELK.mjs → chunk-3E4ZLMXW.mjs} +2 -2
  29. package/dist-lib/esm-chunks/{chunk-JMR6F3DC.mjs → chunk-5DDUQYBY.mjs} +1 -1
  30. package/dist-lib/esm-chunks/{chunk-COIKWBXT.mjs → chunk-ASMHH2QN.mjs} +1 -1
  31. package/dist-lib/esm-chunks/{chunk-4P3IOCZK.mjs → chunk-ATM3HZDR.mjs} +5 -5
  32. package/dist-lib/esm-chunks/{chunk-YEBPOLJT.mjs → chunk-B5Q2MKHJ.mjs} +1 -1
  33. package/dist-lib/esm-chunks/{chunk-GVQYPMGV.mjs → chunk-BMIH6S26.mjs} +1 -1
  34. package/dist-lib/esm-chunks/{chunk-6YRIQX2Q.mjs → chunk-CZCT5EAJ.mjs} +3 -3
  35. package/dist-lib/esm-chunks/{chunk-BEO5Q2GJ.mjs → chunk-DGXGBF5N.mjs} +1 -1
  36. package/dist-lib/esm-chunks/{chunk-RVJCN7O6.mjs → chunk-DJXJO7YZ.mjs} +64 -21
  37. package/dist-lib/esm-chunks/{chunk-U23E4H6F.mjs → chunk-F4G4DEEZ.mjs} +1 -1
  38. package/dist-lib/esm-chunks/{chunk-ELHDFPTV.mjs → chunk-JKYNP3NX.mjs} +1 -1
  39. package/dist-lib/esm-chunks/{chunk-6LTBRJF4.mjs → chunk-JMGRUOXY.mjs} +1 -1
  40. package/dist-lib/esm-chunks/{chunk-XCBOY63C.mjs → chunk-K2ZBCAZ5.mjs} +4 -4
  41. package/dist-lib/esm-chunks/{chunk-SCUA4P4G.mjs → chunk-KJEDFVG6.mjs} +1116 -1056
  42. package/dist-lib/esm-chunks/{chunk-TS7JWC6Z.mjs → chunk-LQQMXMCV.mjs} +1 -1
  43. package/dist-lib/esm-chunks/{chunk-5LYBGU62.mjs → chunk-MNBUUJ2A.mjs} +1 -1
  44. package/dist-lib/esm-chunks/{chunk-6HQZNAEU.mjs → chunk-N5O5BB3F.mjs} +1 -1
  45. package/dist-lib/esm-chunks/{chunk-A2KA5HK7.mjs → chunk-OOXCOL63.mjs} +1 -1
  46. package/dist-lib/esm-chunks/{chunk-SSZA5C37.mjs → chunk-PHBFU273.mjs} +1 -1
  47. package/dist-lib/esm-chunks/{chunk-SQ3UKGNC.mjs → chunk-QRW6R5HX.mjs} +1 -1
  48. package/dist-lib/esm-chunks/{chunk-2V3WPUVP.mjs → chunk-RHM2LED4.mjs} +6 -6
  49. package/dist-lib/esm-chunks/{chunk-NMSKAQXB.mjs → chunk-US5W76OK.mjs} +1 -1
  50. package/dist-lib/esm-chunks/{chunk-ZU4TTBLM.mjs → chunk-UV2BL5ZA.mjs} +1 -1
  51. package/dist-lib/esm-chunks/{metro-layout-parser-26WDQMLR.mjs → metro-layout-parser-72VRHWZM.mjs} +3 -3
  52. package/dist-lib/esm-chunks/{swift-package-prebuilt-DOKKJSSS.mjs → swift-package-prebuilt-ZOQMKNDR.mjs} +16 -13
  53. package/dist-lib/esm-chunks/{swift-sdk-app-module-I4OZ7CGZ.mjs → swift-sdk-app-module-XC4QIMOI.mjs} +16 -16
  54. package/dist-lib/esm-chunks/{swift-sdk-image-IPXHOUXE.mjs → swift-sdk-image-P5NS5P7F.mjs} +16 -16
  55. package/dist-lib/esm-chunks/{swift-sdk-image-producer-6P6QZQGS.mjs → swift-sdk-image-producer-7VTOFOND.mjs} +5 -5
  56. package/dist-lib/expo-swift-bundle.cjs +1124 -944
  57. package/dist-lib/expo-swift-metadata.cjs +1 -1
  58. package/dist-lib/expo-swift-metadata.mjs +7 -7
  59. package/dist-lib/home-paths.cjs +1 -1
  60. package/dist-lib/host/bridge-host.cjs +3768 -3462
  61. package/dist-lib/host/fetch-proxy-handler.cjs +122 -118
  62. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  63. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
  64. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  65. package/dist-lib/host/websocket-proxy.cjs +1 -1
  66. package/dist-lib/index.cjs +1 -1
  67. package/dist-lib/kotlin-host.cjs +1 -1
  68. package/dist-lib/menu.cjs +1 -1
  69. package/dist-lib/menu.mjs +3 -3
  70. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  71. package/dist-lib/metro-fingerprint-registry.mjs +3 -3
  72. package/dist-lib/metro-production-bundle.cjs +1 -1
  73. package/dist-lib/metro-production-bundle.mjs +4 -4
  74. package/dist-lib/native-app-identity-project.cjs +3 -1
  75. package/dist-lib/native-app-identity-project.mjs +15 -15
  76. package/dist-lib/native-app-identity.cjs +1 -1
  77. package/dist-lib/native-app-identity.mjs +6 -6
  78. package/dist-lib/native-firebase-metadata.cjs +1 -1
  79. package/dist-lib/native-firebase-metadata.mjs +3 -3
  80. package/dist-lib/pdfium-raster.cjs +46 -27
  81. package/dist-lib/pdfium-raster.mjs +47 -28
  82. package/dist-lib/plist.cjs +1 -1
  83. package/dist-lib/plist.mjs +3 -3
  84. package/dist-lib/profiles.cjs +1 -1
  85. package/dist-lib/public-brand.cjs +1 -1
  86. package/dist-lib/public-origins-lib-esm.json +87 -86
  87. package/dist-lib/public-origins-lib.json +79 -77
  88. package/dist-lib/react-native-host-modules.cjs +1 -1
  89. package/dist-lib/react-native-host-modules.mjs +2 -2
  90. package/dist-lib/reap-browser.cjs +1 -1
  91. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  92. package/dist-lib/sdk.cjs +1 -1
  93. package/dist-lib/sdk.mjs +8 -8
  94. package/dist-lib/skills.cjs +2061 -1747
  95. package/dist-lib/swift-compile.cjs +1056 -963
  96. package/dist-lib/swift-compile.mjs +12 -12
  97. package/dist-lib/swift-package.cjs +1 -1
  98. package/dist-lib/swift-package.mjs +3 -3
  99. package/dist-lib/swift-submit.cjs +1 -1
  100. package/dist-lib/swift-submit.mjs +6 -6
  101. package/dist-lib/swift-svg-raster.cjs +1 -1
  102. package/dist-lib/swift-svg-raster.mjs +2 -2
  103. package/dist-lib/swift-toolchain.cjs +1 -1
  104. package/dist-lib/swift.cjs +1 -1
  105. package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
  106. package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
  107. package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
  108. package/dist-lib/vendor/acorn.cjs +1 -1
  109. package/dist-lib/vendor/magic-string.cjs +1 -1
  110. package/dist-lib/vendor/stream-json.cjs +1 -1
  111. package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
  112. package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
  113. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
  114. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
  115. package/dist-lib/vendor/sucrase.cjs +1 -1
  116. package/dist-lib/vendor/terser.cjs +1 -1
  117. package/dist-lib/vendor/valibot.cjs +1 -1
  118. package/dist-lib/vendor/ws.cjs +1 -1
  119. package/dist-lib/vendor/zod.cjs +1 -1
  120. package/dist-lib/worklet-executable.cjs +1 -1
  121. package/dist-lib/worklet-executable.mjs +3 -3
  122. package/dist-types/packages/peach-engine/core-abi/style/style-field-hash.d.ts +1 -1
  123. package/dist-types/packages/peach-engine/src/engine/scene-native-binding.d.ts +2 -2
  124. package/dist-types/packages/peach-engine/src/render-worker/native-hot-ops.d.ts +4 -4
  125. package/dist-types/packages/peach-engine/src/render-worker/scene-packet-feed.d.ts +2 -0
  126. package/dist-types/packages/peach-globals/src/fnv1a.d.ts +4 -0
  127. package/package.json +1 -1
  128. package/runtime-companion.json +1 -1
  129. package/src/expo-swift-host.ts +31 -9
  130. package/src/one-native-controls-package.ts +56 -54
  131. package/src/pdfium-raster.ts +1 -58
  132. package/src/swift-compile.ts +1029 -963
  133. package/src/swift-compiler-digest.ts +79 -4
  134. package/src/swift-host.ts +246 -91
  135. package/src/swift-package-prebuilt.ts +6 -3
  136. package/src/swift-sdk-surface.ts +75 -20
  137. package/src/swift-startup-split.ts +134 -12
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2793 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2795 | (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;
@@ -1299,7 +1299,7 @@ var init_src = __esm({
1299
1299
  var runtime_companion_default;
1300
1300
  var init_runtime_companion = __esm({
1301
1301
  "runtime-companion.json"() {
1302
- runtime_companion_default = { abi: 1, sha256: "071c14959a9e438ec9224e9b3dd25b339e98b326e3cf8b0ab0c6215a38d53c7a", file: "node/cli-071c14959a9e438ec9224e9b3dd25b339e98b326e3cf8b0ab0c6215a38d53c7a.cjs" };
1302
+ runtime_companion_default = { abi: 1, sha256: "e77d5ddde680218f8a31eae4a6849cd7b1a9f59511187936227956471351bca5", file: "node/cli-e77d5ddde680218f8a31eae4a6849cd7b1a9f59511187936227956471351bca5.cjs" };
1303
1303
  }
1304
1304
  });
1305
1305
 
@@ -10481,37 +10481,18 @@ var init_swift_compile_budget = __esm({
10481
10481
  }
10482
10482
  });
10483
10483
 
10484
- // src/swift-objc-sdk-tree.ts
10485
- function readIosSdkTree(root) {
10486
- return (0, import_node_fs19.readdirSync)(root, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) => {
10487
- const file = import_node_path16.default.join(entry.parentPath, entry.name);
10488
- return [
10489
- import_node_path16.default.relative(root, file).split(import_node_path16.default.sep).join("/"),
10490
- (0, import_node_fs19.readFileSync)(file, "utf8")
10491
- ];
10492
- }).sort(([a], [b]) => a < b ? -1 : 1);
10493
- }
10494
- var import_node_fs19, import_node_path16;
10495
- var init_swift_objc_sdk_tree = __esm({
10496
- "src/swift-objc-sdk-tree.ts"() {
10497
- "use strict";
10498
- import_node_fs19 = require("node:fs");
10499
- import_node_path16 = __toESM(require("node:path"), 1);
10500
- }
10501
- });
10502
-
10503
10484
  // src/swift-compiler-digest.ts
10504
10485
  function swiftArchiveCompilerDigestValue() {
10505
- return true ? "172ff559f9865fc0c2a93dedc423889fdbdc66399043a9cd46916c2168556ff2" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname, "archive");
10486
+ return true ? "9f3ce81119383c0a06504b3325d9b5dcd291f804e34d31b83428ee6fa494df7f" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname, "archive");
10506
10487
  }
10507
- var import_node_crypto10, import_node_fs20, import_node_path17, SWIFT_DIGEST_SOURCES, LINKED_IMAGE_SOURCES, SWIFT_ARCHIVE_DIGEST_SOURCES;
10488
+ var import_node_crypto10, import_node_fs19, import_node_os7, import_node_path16, SWIFT_DIGEST_SOURCES, LINKED_IMAGE_SOURCES, SWIFT_ARCHIVE_DIGEST_SOURCES;
10508
10489
  var init_swift_compiler_digest = __esm({
10509
10490
  "src/swift-compiler-digest.ts"() {
10510
10491
  "use strict";
10511
10492
  import_node_crypto10 = require("node:crypto");
10512
- import_node_fs20 = require("node:fs");
10513
- import_node_path17 = __toESM(require("node:path"), 1);
10514
- init_swift_objc_sdk_tree();
10493
+ import_node_fs19 = require("node:fs");
10494
+ import_node_os7 = __toESM(require("node:os"), 1);
10495
+ import_node_path16 = __toESM(require("node:path"), 1);
10515
10496
  SWIFT_DIGEST_SOURCES = [
10516
10497
  "swift-compile.ts",
10517
10498
  "swift-sdk-surface.ts",
@@ -10594,7 +10575,7 @@ function swiftObjCPlatformFlags(toolchainBin, minimum) {
10594
10575
  minimum % 100
10595
10576
  ].join(".");
10596
10577
  const result = (0, import_node_child_process11.spawnSync)(
10597
- import_node_path18.default.join(toolchainBin, "clang"),
10578
+ import_node_path17.default.join(toolchainBin, "clang"),
10598
10579
  [
10599
10580
  "-target",
10600
10581
  `arm64-apple-ios${version2}-simulator`,
@@ -10626,12 +10607,12 @@ function swiftObjCPlatformFlags(toolchainBin, minimum) {
10626
10607
  platforms.set(key2, flags);
10627
10608
  return flags;
10628
10609
  }
10629
- var import_node_child_process11, import_node_path18, platforms;
10610
+ var import_node_child_process11, import_node_path17, platforms;
10630
10611
  var init_swift_objc_platform = __esm({
10631
10612
  "src/swift-objc-platform.ts"() {
10632
10613
  "use strict";
10633
10614
  import_node_child_process11 = require("node:child_process");
10634
- import_node_path18 = __toESM(require("node:path"), 1);
10615
+ import_node_path17 = __toESM(require("node:path"), 1);
10635
10616
  init_swift_toolchain();
10636
10617
  platforms = /* @__PURE__ */ new Map();
10637
10618
  }
@@ -10653,42 +10634,42 @@ var init_swift_objc_runtime = __esm({
10653
10634
 
10654
10635
  // src/write-build-file.ts
10655
10636
  function writeBuildFile(file, contents2) {
10656
- const stat = (0, import_node_fs21.statSync)(file, { throwIfNoEntry: false });
10637
+ const stat = (0, import_node_fs20.statSync)(file, { throwIfNoEntry: false });
10657
10638
  if (stat?.isFile()) {
10658
10639
  if (typeof contents2 === "string") {
10659
- if ((0, import_node_fs21.readFileSync)(file, "utf8") === contents2) return;
10660
- } else if (stat.size === contents2.length && (0, import_node_fs21.readFileSync)(file).equals(contents2)) {
10640
+ if ((0, import_node_fs20.readFileSync)(file, "utf8") === contents2) return;
10641
+ } else if (stat.size === contents2.length && (0, import_node_fs20.readFileSync)(file).equals(contents2)) {
10661
10642
  return;
10662
10643
  }
10663
10644
  }
10664
- (0, import_node_fs21.mkdirSync)(import_node_path19.default.dirname(file), { recursive: true });
10665
- (0, import_node_fs21.writeFileSync)(file, contents2);
10645
+ (0, import_node_fs20.mkdirSync)(import_node_path18.default.dirname(file), { recursive: true });
10646
+ (0, import_node_fs20.writeFileSync)(file, contents2);
10666
10647
  }
10667
- var import_node_fs21, import_node_path19;
10648
+ var import_node_fs20, import_node_path18;
10668
10649
  var init_write_build_file = __esm({
10669
10650
  "src/write-build-file.ts"() {
10670
10651
  "use strict";
10671
- import_node_fs21 = require("node:fs");
10672
- import_node_path19 = __toESM(require("node:path"), 1);
10652
+ import_node_fs20 = require("node:fs");
10653
+ import_node_path18 = __toESM(require("node:path"), 1);
10673
10654
  }
10674
10655
  });
10675
10656
 
10676
10657
  // src/case-insensitive-header-overlay.ts
10677
10658
  function needsCaseOverlay(directory2) {
10678
10659
  if (process.platform !== "darwin") return true;
10679
- const device = import_node_fs22.default.statSync(directory2).dev;
10660
+ const device = import_node_fs21.default.statSync(directory2).dev;
10680
10661
  const known = volumeCaseSensitivity.get(device);
10681
10662
  if (known !== void 0) return known;
10682
10663
  let probed = false;
10683
- for (const name3 of import_node_fs22.default.readdirSync(directory2)) {
10664
+ for (const name3 of import_node_fs21.default.readdirSync(directory2)) {
10684
10665
  const alternate = name3.replace(
10685
10666
  /[a-zA-Z]/,
10686
10667
  (letter) => letter === letter.toLowerCase() ? letter.toUpperCase() : letter.toLowerCase()
10687
10668
  );
10688
10669
  if (alternate === name3) continue;
10689
- const original = import_node_fs22.default.lstatSync(import_node_path20.default.join(directory2, name3), { throwIfNoEntry: false });
10670
+ const original = import_node_fs21.default.lstatSync(import_node_path19.default.join(directory2, name3), { throwIfNoEntry: false });
10690
10671
  if (!original) continue;
10691
- const changed = import_node_fs22.default.lstatSync(import_node_path20.default.join(directory2, alternate), {
10672
+ const changed = import_node_fs21.default.lstatSync(import_node_path19.default.join(directory2, alternate), {
10692
10673
  throwIfNoEntry: false
10693
10674
  });
10694
10675
  if (!changed || original.ino !== changed.ino || original.dev !== changed.dev) {
@@ -10702,10 +10683,10 @@ function needsCaseOverlay(directory2) {
10702
10683
  }
10703
10684
  function scan(directory2, listed) {
10704
10685
  const node = { files: /* @__PURE__ */ new Map(), directories: /* @__PURE__ */ new Map() };
10705
- const entries2 = import_node_fs22.default.readdirSync(directory2, { withFileTypes: true }).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
10686
+ const entries2 = import_node_fs21.default.readdirSync(directory2, { withFileTypes: true }).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
10706
10687
  for (const entry of entries2) {
10707
- const full = import_node_path20.default.join(directory2, entry.name);
10708
- const stat = entry.isSymbolicLink() ? import_node_fs22.default.statSync(full, { throwIfNoEntry: false }) : entry;
10688
+ const full = import_node_path19.default.join(directory2, entry.name);
10689
+ const stat = entry.isSymbolicLink() ? import_node_fs21.default.statSync(full, { throwIfNoEntry: false }) : entry;
10709
10690
  if (!stat) continue;
10710
10691
  if (stat.isDirectory()) {
10711
10692
  const child = scan(full, listed);
@@ -10731,7 +10712,7 @@ function contents(node) {
10731
10712
  ];
10732
10713
  }
10733
10714
  function clearCaseInsensitiveHeaderOverlayCache(rootPrefix) {
10734
- const prefix = `${rootPrefix}${import_node_path20.default.sep}`;
10715
+ const prefix = `${rootPrefix}${import_node_path19.default.sep}`;
10735
10716
  for (const key2 of scans2.keys())
10736
10717
  if (key2 === rootPrefix || key2.startsWith(prefix)) scans2.delete(key2);
10737
10718
  }
@@ -10742,7 +10723,7 @@ function caseInsensitiveHeaderOverlay(directory2, roots, listed, fixedName) {
10742
10723
  listedScans.set(listed, known);
10743
10724
  }
10744
10725
  const existing = [...new Set(roots)].filter(
10745
- (root) => import_node_fs22.default.existsSync(root) && needsCaseOverlay(root)
10726
+ (root) => import_node_fs21.default.existsSync(root) && needsCaseOverlay(root)
10746
10727
  );
10747
10728
  if (existing.length === 0) return null;
10748
10729
  const unique2 = existing.filter(
@@ -10754,20 +10735,20 @@ function caseInsensitiveHeaderOverlay(directory2, roots, listed, fixedName) {
10754
10735
  return { name: root, type: "directory", contents: contents(node) };
10755
10736
  });
10756
10737
  const text7 = JSON.stringify({ "case-sensitive": "false", roots: roots_, version: 0 });
10757
- const file = import_node_path20.default.join(
10738
+ const file = import_node_path19.default.join(
10758
10739
  directory2,
10759
10740
  fixedName ?? `case-insensitive-${(0, import_node_crypto11.createHash)("sha256").update(text7).digest("hex").slice(0, 16)}.yaml`
10760
10741
  );
10761
10742
  writeBuildFile(file, text7);
10762
10743
  return file;
10763
10744
  }
10764
- var import_node_crypto11, import_node_fs22, import_node_path20, HEADER, volumeCaseSensitivity, scans2, listedScans;
10745
+ var import_node_crypto11, import_node_fs21, import_node_path19, HEADER, volumeCaseSensitivity, scans2, listedScans;
10765
10746
  var init_case_insensitive_header_overlay = __esm({
10766
10747
  "src/case-insensitive-header-overlay.ts"() {
10767
10748
  "use strict";
10768
10749
  import_node_crypto11 = require("node:crypto");
10769
- import_node_fs22 = __toESM(require("node:fs"), 1);
10770
- import_node_path20 = __toESM(require("node:path"), 1);
10750
+ import_node_fs21 = __toESM(require("node:fs"), 1);
10751
+ import_node_path19 = __toESM(require("node:path"), 1);
10771
10752
  init_write_build_file();
10772
10753
  HEADER = /\.(h|hh|hpp|hxx|inc|inl|def|modulemap|apinotes|tcc)$/i;
10773
10754
  volumeCaseSensitivity = /* @__PURE__ */ new Map();
@@ -10912,6 +10893,25 @@ var init_swift_interface_bodies = __esm({
10912
10893
  }
10913
10894
  });
10914
10895
 
10896
+ // src/swift-objc-sdk-tree.ts
10897
+ function readIosSdkTree(root) {
10898
+ return (0, import_node_fs22.readdirSync)(root, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) => {
10899
+ const file = import_node_path20.default.join(entry.parentPath, entry.name);
10900
+ return [
10901
+ import_node_path20.default.relative(root, file).split(import_node_path20.default.sep).join("/"),
10902
+ (0, import_node_fs22.readFileSync)(file, "utf8")
10903
+ ];
10904
+ }).sort(([a], [b]) => a < b ? -1 : 1);
10905
+ }
10906
+ var import_node_fs22, import_node_path20;
10907
+ var init_swift_objc_sdk_tree = __esm({
10908
+ "src/swift-objc-sdk-tree.ts"() {
10909
+ "use strict";
10910
+ import_node_fs22 = require("node:fs");
10911
+ import_node_path20 = __toESM(require("node:path"), 1);
10912
+ }
10913
+ });
10914
+
10915
10915
  // src/swift-objc-sdk.ts
10916
10916
  function iosSdk() {
10917
10917
  if (sdk) return sdk;
@@ -14964,7 +14964,7 @@ var init_swift_shared_sdk = __esm({
14964
14964
  // src/swift-darwin-records.ts
14965
14965
  function compileDarwinRecords(args) {
14966
14966
  const records = import_node_path24.default.join(args.packageRoot, "Sources/DarwinRecords");
14967
- const runtime = (0, import_node_fs25.mkdtempSync)(import_node_path24.default.join((0, import_node_os7.tmpdir)(), "peach-objc-runtime-"));
14967
+ const runtime = (0, import_node_fs25.mkdtempSync)(import_node_path24.default.join((0, import_node_os8.tmpdir)(), "peach-objc-runtime-"));
14968
14968
  (0, import_node_fs25.symlinkSync)(import_node_path24.default.join(args.darwin, "usr/include/objc"), import_node_path24.default.join(runtime, "objc"));
14969
14969
  const objects = (0, import_node_fs25.readdirSync)(records).filter((file) => file.endsWith(".c") || file.endsWith(".m")).sort((a, b) => a < b ? -1 : a > b ? 1 : 0).map((file) => {
14970
14970
  const object8 = import_node_path24.default.join(
@@ -15007,13 +15007,13 @@ function compileDarwinRecords(args) {
15007
15007
  (0, import_node_fs25.rmSync)(runtime, { recursive: true });
15008
15008
  return objects;
15009
15009
  }
15010
- var import_node_child_process14, import_node_fs25, import_node_os7, import_node_path24, DARWIN_RECORDS_PREFIX, darwinRecordsMinimum;
15010
+ var import_node_child_process14, import_node_fs25, import_node_os8, import_node_path24, DARWIN_RECORDS_PREFIX, darwinRecordsMinimum;
15011
15011
  var init_swift_darwin_records = __esm({
15012
15012
  "src/swift-darwin-records.ts"() {
15013
15013
  "use strict";
15014
15014
  import_node_child_process14 = require("node:child_process");
15015
15015
  import_node_fs25 = require("node:fs");
15016
- import_node_os7 = require("node:os");
15016
+ import_node_os8 = require("node:os");
15017
15017
  import_node_path24 = __toESM(require("node:path"), 1);
15018
15018
  init_swift_objc_platform();
15019
15019
  init_swift_objc_runtime();
@@ -28918,13 +28918,13 @@ var init_swift_lexical = __esm({
28918
28918
  // src/swift-sdk-surface.ts
28919
28919
  function swiftBuildJobs() {
28920
28920
  const admittedCores = windowAdmission()?.cores ?? Number(process.env.TM_EXEC_CPU_CORES);
28921
- const parallelism = Math.max(1, import_node_os8.default.availableParallelism());
28921
+ const parallelism = Math.max(1, import_node_os9.default.availableParallelism());
28922
28922
  if (!Number.isInteger(admittedCores) || admittedCores <= 0)
28923
28923
  return Math.min(4, Math.max(1, Math.floor(parallelism / 2)));
28924
28924
  const cores = Math.min(admittedCores, parallelism);
28925
28925
  if (process.platform === "darwin") return cores;
28926
28926
  const memory = process.env.TM_EXEC_ADMITTED === "1" && process.env.LINUX_BUILD_SCOPE ? Number(process.env.TM_EXEC_LINUX_MEMORY_MAX) : NaN;
28927
- const effectiveMemory = Number.isSafeInteger(memory) && memory > 0 ? memory : import_node_os8.default.totalmem();
28927
+ const effectiveMemory = Number.isSafeInteger(memory) && memory > 0 ? memory : import_node_os9.default.totalmem();
28928
28928
  const memoryJobs = Math.max(1, Math.floor(effectiveMemory / (2 * 1024 ** 3)));
28929
28929
  return Math.min(cores, memoryJobs);
28930
28930
  }
@@ -29255,6 +29255,16 @@ function swiftMacroPlugins(moduleRoot) {
29255
29255
  stale: [...libraries, ...executables, stamp].some((file) => !(0, import_node_fs40.existsSync)(file)) || (0, import_node_fs40.readFileSync)(stamp, "utf8").trim() !== release
29256
29256
  };
29257
29257
  }
29258
+ function withSwiftModuleDigestScope(fn) {
29259
+ if (moduleDigestScopes.getStore()) return fn();
29260
+ return moduleDigestScopes.run(/* @__PURE__ */ new Map(), fn);
29261
+ }
29262
+ function clearSwiftModuleDigestScope(root) {
29263
+ const scope2 = moduleDigestScopes.getStore();
29264
+ if (!scope2) return;
29265
+ if (root === void 0) scope2.clear();
29266
+ else scope2.delete(import_node_path39.default.resolve(root));
29267
+ }
29258
29268
  function gitCleanModuleInputsKey(root, files2) {
29259
29269
  if (swiftDistributionAt(root)) return null;
29260
29270
  const top = (0, import_node_child_process23.spawnSync)("git", ["-C", root, "rev-parse", "--show-toplevel"], {
@@ -29318,7 +29328,11 @@ function gitCleanModuleInputsKey(root, files2) {
29318
29328
  for (const file of files2) keyHash.update(file).update("\n");
29319
29329
  return keyHash.digest("hex");
29320
29330
  }
29321
- function swiftModuleDigest(root) {
29331
+ function swiftModuleEntry(root) {
29332
+ const scope2 = moduleDigestScopes.getStore();
29333
+ const key2 = import_node_path39.default.resolve(root);
29334
+ const scoped = scope2?.get(key2);
29335
+ if (scoped) return scoped;
29322
29336
  const files2 = swiftModuleInputFiles(root);
29323
29337
  const stampHash = (0, import_node_crypto25.createHash)("sha256");
29324
29338
  for (const file of files2) {
@@ -29331,7 +29345,10 @@ function swiftModuleDigest(root) {
29331
29345
  }
29332
29346
  const stamp = stampHash.digest("hex");
29333
29347
  const cached2 = linkedModuleDigests.get(root);
29334
- if (cached2?.stamp === stamp) return cached2.digest;
29348
+ if (cached2?.stamp === stamp) {
29349
+ scope2?.set(key2, cached2);
29350
+ return cached2;
29351
+ }
29335
29352
  const digestDir = import_node_path39.default.join(swiftCacheDir(), "swift-module-digests");
29336
29353
  const record5 = import_node_path39.default.join(
29337
29354
  digestDir,
@@ -29347,8 +29364,10 @@ function swiftModuleDigest(root) {
29347
29364
  const saved = JSON.parse((0, import_node_fs40.readFileSync)(record5, "utf8"));
29348
29365
  if (saved && typeof saved === "object" && Reflect.get(saved, "stamp") === stamp && typeof Reflect.get(saved, "digest") === "string") {
29349
29366
  const digest4 = Buffer.from(String(Reflect.get(saved, "digest")), "hex");
29350
- linkedModuleDigests.set(root, { stamp, digest: digest4 });
29351
- return digest4;
29367
+ const entry2 = { stamp, digest: digest4 };
29368
+ linkedModuleDigests.set(root, entry2);
29369
+ scope2?.set(key2, entry2);
29370
+ return entry2;
29352
29371
  }
29353
29372
  }
29354
29373
  const gitKey = gitCleanModuleInputsKey(root, files2);
@@ -29358,9 +29377,11 @@ function swiftModuleDigest(root) {
29358
29377
  if (saved && typeof saved === "object" && typeof Reflect.get(saved, "digest") === "string") {
29359
29378
  const hex2 = String(Reflect.get(saved, "digest"));
29360
29379
  const digest4 = Buffer.from(hex2, "hex");
29361
- linkedModuleDigests.set(root, { stamp, digest: digest4 });
29380
+ const entry2 = { stamp, digest: digest4 };
29381
+ linkedModuleDigests.set(root, entry2);
29382
+ scope2?.set(key2, entry2);
29362
29383
  writeRecord(record5, JSON.stringify({ stamp, digest: hex2 }));
29363
- return digest4;
29384
+ return entry2;
29364
29385
  }
29365
29386
  }
29366
29387
  const hash = (0, import_node_crypto25.createHash)("sha256");
@@ -29372,10 +29393,18 @@ function swiftModuleDigest(root) {
29372
29393
  }
29373
29394
  const digest3 = hash.digest();
29374
29395
  const hex = digest3.toString("hex");
29375
- linkedModuleDigests.set(root, { stamp, digest: digest3 });
29396
+ const entry = { stamp, digest: digest3 };
29397
+ linkedModuleDigests.set(root, entry);
29398
+ scope2?.set(key2, entry);
29376
29399
  writeRecord(record5, JSON.stringify({ stamp, digest: hex }));
29377
29400
  if (gitRecord) writeRecord(gitRecord, JSON.stringify({ digest: hex }));
29378
- return digest3;
29401
+ return entry;
29402
+ }
29403
+ function swiftModuleDigest(root) {
29404
+ return swiftModuleEntry(root).digest;
29405
+ }
29406
+ function swiftModuleStamp(root) {
29407
+ return swiftModuleEntry(root).stamp;
29379
29408
  }
29380
29409
  function swiftCompileSurfaceDigest(root) {
29381
29410
  const distribution = swiftDistributionAt(root);
@@ -29466,8 +29495,10 @@ function* swiftConditionalLines(contents2, available2, defines) {
29466
29495
  }
29467
29496
  }
29468
29497
  function swiftImportNames(contents2, available2, defines) {
29469
- if (available2 === void 0 && defines === void 0) {
29470
- const cached2 = importNamesCache.get(contents2);
29498
+ if (!contents2.includes("import")) return [];
29499
+ const definesKey = available2 === void 0 ? defines ? [...defines].sort().join("\0") : "" : void 0;
29500
+ if (definesKey !== void 0) {
29501
+ const cached2 = importNamesCache.get(definesKey)?.get(contents2);
29471
29502
  if (cached2 !== void 0) return cached2;
29472
29503
  }
29473
29504
  const names = [];
@@ -29476,8 +29507,14 @@ function swiftImportNames(contents2, available2, defines) {
29476
29507
  const name3 = SWIFT_IMPORT.exec(line)?.[1];
29477
29508
  if (name3) names.push(name3);
29478
29509
  }
29479
- if (available2 === void 0 && defines === void 0)
29480
- importNamesCache.set(contents2, names);
29510
+ if (definesKey !== void 0) {
29511
+ let bucket = importNamesCache.get(definesKey);
29512
+ if (!bucket) {
29513
+ bucket = /* @__PURE__ */ new Map();
29514
+ importNamesCache.set(definesKey, bucket);
29515
+ }
29516
+ bucket.set(contents2, names);
29517
+ }
29481
29518
  return names;
29482
29519
  }
29483
29520
  function swiftPeachModules(moduleRoot) {
@@ -29767,11 +29804,15 @@ function swiftCTakesReturnAddress(source) {
29767
29804
  cActiveCode(stripCCode(source), wasmMacroEnvironment)
29768
29805
  );
29769
29806
  }
29770
- function swiftModuleCompiler(root) {
29807
+ function swiftModuleRelease(root) {
29771
29808
  const pin2 = swiftDistributionAt(root) ?? JSON.parse((0, import_node_fs40.readFileSync)(import_node_path39.default.join(root, "toolchain.json"), "utf8"));
29809
+ return pin2.release;
29810
+ }
29811
+ function swiftModuleCompiler(root) {
29812
+ const release = swiftModuleRelease(root);
29772
29813
  return {
29773
- release: pin2.release,
29774
- toolchainBin: swiftCompiler(pin2.release)
29814
+ release,
29815
+ toolchainBin: swiftCompiler(release)
29775
29816
  };
29776
29817
  }
29777
29818
  function swiftModuleToolchain(root) {
@@ -29784,14 +29825,15 @@ function remoteSwiftCheckouts(root) {
29784
29825
  (0, import_node_fs40.mkdirSync)(cache, { recursive: true });
29785
29826
  return import_node_path39.default.join((0, import_node_fs40.realpathSync)(cache), "swift-packages", key2, "checkouts");
29786
29827
  }
29787
- var import_node_child_process23, import_node_crypto25, import_node_fs40, import_node_os8, import_node_path39, distributionManifests, distributionCompileViews, REACH_STAGED_FRAMEWORKS, objcEnumerations, clangDeclarationEnumCache, objcEnumForward, sdkDeclarationOwners, swiftInterfaceDeclarations, linkedModuleDigests, compileSurfaces, SWIFT_IMPORT, kleeneNot, kleeneAnd, kleeneOr, NON_IOS_MODULES, importNamesCache, sdkPaths, FOUNDATION_IMPLICIT_MODULES, FRAMEWORK_COMPANION_IMPORT, codeMasks, codeMaskChars, CODE_MASK_CACHE_CHARS, FOUNDATION_NETWORKING_TYPES, FOUNDATION_OVERLAY_TYPES, FOUNDATION_OVERLAY_GLOBALS, CORE_FOUNDATION_OVERLAY_GLOBALS, emptyMacroEnvironment, wasmMacroEnvironment, swiftBinaryOnDisk;
29828
+ var import_node_async_hooks2, import_node_child_process23, import_node_crypto25, import_node_fs40, import_node_os9, import_node_path39, distributionManifests, distributionCompileViews, REACH_STAGED_FRAMEWORKS, objcEnumerations, clangDeclarationEnumCache, objcEnumForward, sdkDeclarationOwners, swiftInterfaceDeclarations, linkedModuleDigests, moduleDigestScopes, compileSurfaces, SWIFT_IMPORT, kleeneNot, kleeneAnd, kleeneOr, NON_IOS_MODULES, importNamesCache, sdkPaths, FOUNDATION_IMPLICIT_MODULES, FRAMEWORK_COMPANION_IMPORT, codeMasks, codeMaskChars, CODE_MASK_CACHE_CHARS, FOUNDATION_NETWORKING_TYPES, FOUNDATION_OVERLAY_TYPES, FOUNDATION_OVERLAY_GLOBALS, CORE_FOUNDATION_OVERLAY_GLOBALS, emptyMacroEnvironment, wasmMacroEnvironment, swiftBinaryOnDisk;
29788
29829
  var init_swift_sdk_surface = __esm({
29789
29830
  "src/swift-sdk-surface.ts"() {
29790
29831
  "use strict";
29832
+ import_node_async_hooks2 = require("node:async_hooks");
29791
29833
  import_node_child_process23 = require("node:child_process");
29792
29834
  import_node_crypto25 = require("node:crypto");
29793
29835
  import_node_fs40 = require("node:fs");
29794
- import_node_os8 = __toESM(require("node:os"), 1);
29836
+ import_node_os9 = __toESM(require("node:os"), 1);
29795
29837
  import_node_path39 = __toESM(require("node:path"), 1);
29796
29838
  init_swift_source_mask();
29797
29839
  init_admitted_mac_build();
@@ -29825,6 +29867,7 @@ var init_swift_sdk_surface = __esm({
29825
29867
  ].map((m) => m[1])
29826
29868
  ]);
29827
29869
  linkedModuleDigests = /* @__PURE__ */ new Map();
29870
+ moduleDigestScopes = new import_node_async_hooks2.AsyncLocalStorage();
29828
29871
  compileSurfaces = /* @__PURE__ */ new WeakMap();
29829
29872
  SWIFT_IMPORT = /^\s*(?:@\w+(?:\([^)]*\))?\s+|(?:public|package|internal|fileprivate|private)\s+)*import\s+(?:(?:typealias|struct|class|enum|protocol|let|var|func)\s+)?([A-Za-z_][A-Za-z0-9_]*)/;
29830
29873
  kleeneNot = (value) => value === void 0 ? void 0 : !value;
@@ -30264,7 +30307,7 @@ function dumpInputs(dir, xcode) {
30264
30307
  swiftCodeScan(source).lineStarts,
30265
30308
  (line) => line.replace(
30266
30309
  MANIFEST_HOST_OS,
30267
- (match, os26) => (os26 === "macOS" ? "true" : "false").padEnd(match.length)
30310
+ (match, os27) => (os27 === "macOS" ? "true" : "false").padEnd(match.length)
30268
30311
  )
30269
30312
  );
30270
30313
  if (projected !== source) overlays.push({ name: name3, source: projected });
@@ -30711,7 +30754,7 @@ let package = Package(
30711
30754
  ]
30712
30755
  )
30713
30756
  `;
30714
- const dir = import_node_fs41.default.mkdtempSync(import_node_path40.default.join(import_node_os9.default.tmpdir(), "peach-resolve-"));
30757
+ const dir = import_node_fs41.default.mkdtempSync(import_node_path40.default.join(import_node_os10.default.tmpdir(), "peach-resolve-"));
30715
30758
  import_node_fs41.default.writeFileSync(import_node_path40.default.join(dir, "Package.swift"), manifest);
30716
30759
  const args = [
30717
30760
  "package",
@@ -30778,14 +30821,14 @@ function swiftTargetFiles(manifest, target) {
30778
30821
  }
30779
30822
  return [...new Set(files2)].sort();
30780
30823
  }
30781
- var import_node_child_process24, import_node_crypto26, import_node_fs41, import_node_os9, import_node_path40, import_node_util5, TARGET_TYPES, targetRelative, isTargetType, record, array4, string4, swiftCommand, cacheDir2, evaluated, execFileAsync2, cachedToolchain, SwiftManifestPreparationRequired, MANIFEST_HOST_OS, manifestPreparations, GUEST_PLATFORMS, within, requirementClause;
30824
+ var import_node_child_process24, import_node_crypto26, import_node_fs41, import_node_os10, import_node_path40, import_node_util5, TARGET_TYPES, targetRelative, isTargetType, record, array4, string4, swiftCommand, cacheDir2, evaluated, execFileAsync2, cachedToolchain, SwiftManifestPreparationRequired, MANIFEST_HOST_OS, manifestPreparations, GUEST_PLATFORMS, within, requirementClause;
30782
30825
  var init_swift_package_manifest = __esm({
30783
30826
  "src/swift-package-manifest.ts"() {
30784
30827
  "use strict";
30785
30828
  import_node_child_process24 = require("node:child_process");
30786
30829
  import_node_crypto26 = require("node:crypto");
30787
30830
  import_node_fs41 = __toESM(require("node:fs"), 1);
30788
- import_node_os9 = __toESM(require("node:os"), 1);
30831
+ import_node_os10 = __toESM(require("node:os"), 1);
30789
30832
  import_node_path40 = __toESM(require("node:path"), 1);
30790
30833
  import_node_util5 = require("node:util");
30791
30834
  init_git_repo_env();
@@ -30970,7 +31013,7 @@ function swiftHostLibraryView(root, executables) {
30970
31013
  }
30971
31014
  const triple = process.arch === "x64" ? "x86_64-linux-gnu" : "aarch64-linux-gnu";
30972
31015
  const libraries = import_node_path41.default.join(root, "usr/lib", triple);
30973
- const view = import_node_fs42.default.mkdtempSync(import_node_path41.default.join(import_node_os10.default.tmpdir(), "peach-swift-libraries-"));
31016
+ const view = import_node_fs42.default.mkdtempSync(import_node_path41.default.join(import_node_os11.default.tmpdir(), "peach-swift-libraries-"));
30974
31017
  const linked = /* @__PURE__ */ new Set();
30975
31018
  try {
30976
31019
  while (missing2.length) {
@@ -30993,7 +31036,7 @@ function swiftHostLibraryView(root, executables) {
30993
31036
  }
30994
31037
  async function installSwiftToolchain(release, sdk2, signal, compilerOnly = false) {
30995
31038
  const root = import_node_path41.default.resolve(swiftToolchainBin(release), "../..");
30996
- const owned = process.platform === "darwin" ? import_node_path41.default.join(import_node_os10.default.homedir(), "Library/Developer/Toolchains", `${release}.xctoolchain`) : import_node_path41.default.join(rnxHomeDir(), "swift", "toolchains", release);
31039
+ const owned = process.platform === "darwin" ? import_node_path41.default.join(import_node_os11.default.homedir(), "Library/Developer/Toolchains", `${release}.xctoolchain`) : import_node_path41.default.join(rnxHomeDir(), "swift", "toolchains", release);
30997
31040
  const selectedCompiler = process.platform === "darwin" && import_node_fs42.default.existsSync(import_node_path41.default.join(root, "usr/bin/swift"));
30998
31041
  const ownsCompiler = release.includes("-custom-") && root === owned && !selectedCompiler;
30999
31042
  const executables = ["swift", "swift-package", "swift-frontend", "wasm-ld"].map(
@@ -31108,13 +31151,13 @@ async function resolveSwiftPackageRequirementsAsync(requirements, destination, s
31108
31151
  import_node_fs42.default.rmSync(dir, { recursive: true, force: true });
31109
31152
  }
31110
31153
  }
31111
- var import_node_child_process25, import_node_fs42, import_node_os10, import_node_path41, import_node_util6, SWIFT_ENDPOINT_ENV, DEFAULT_SWIFT_ENDPOINT, installs, staleWarned, hostLibraryViews;
31154
+ var import_node_child_process25, import_node_fs42, import_node_os11, import_node_path41, import_node_util6, SWIFT_ENDPOINT_ENV, DEFAULT_SWIFT_ENDPOINT, installs, staleWarned, hostLibraryViews;
31112
31155
  var init_swift_distribution = __esm({
31113
31156
  "src/swift-distribution.ts"() {
31114
31157
  "use strict";
31115
31158
  import_node_child_process25 = require("node:child_process");
31116
31159
  import_node_fs42 = __toESM(require("node:fs"), 1);
31117
- import_node_os10 = __toESM(require("node:os"), 1);
31160
+ import_node_os11 = __toESM(require("node:os"), 1);
31118
31161
  import_node_path41 = __toESM(require("node:path"), 1);
31119
31162
  import_node_util6 = require("node:util");
31120
31163
  init_src();
@@ -31244,7 +31287,7 @@ function rootLockKey(root) {
31244
31287
  return import_node_path42.default.join(backingPath, ...missing2);
31245
31288
  }
31246
31289
  function swiftRootLocksDir() {
31247
- return import_node_path42.default.join((0, import_node_os11.homedir)(), ".peach", "cache", "swift-root-locks");
31290
+ return import_node_path42.default.join((0, import_node_os12.homedir)(), ".peach", "cache", "swift-root-locks");
31248
31291
  }
31249
31292
  function withSwiftRootReadHolds(work) {
31250
31293
  const holds = [];
@@ -31426,15 +31469,15 @@ async function withSwiftRootLock(root, work, signal, wait = true) {
31426
31469
  (0, import_node_fs43.writeFileSync)(import_node_path42.default.join(directory2, name(held, "released")), "");
31427
31470
  }
31428
31471
  }
31429
- var import_node_async_hooks2, import_node_child_process26, import_node_crypto27, import_node_fs43, import_node_os11, import_node_path42, POLL_MS, INSPECT_ATTEMPTS, START_TOLERANCE_MS, name, swiftRootReadHolds;
31472
+ var import_node_async_hooks3, import_node_child_process26, import_node_crypto27, import_node_fs43, import_node_os12, import_node_path42, POLL_MS, INSPECT_ATTEMPTS, START_TOLERANCE_MS, name, swiftRootReadHolds;
31430
31473
  var init_swift_root_lock = __esm({
31431
31474
  "src/swift-root-lock.ts"() {
31432
31475
  "use strict";
31433
- import_node_async_hooks2 = require("node:async_hooks");
31476
+ import_node_async_hooks3 = require("node:async_hooks");
31434
31477
  import_node_child_process26 = require("node:child_process");
31435
31478
  import_node_crypto27 = require("node:crypto");
31436
31479
  import_node_fs43 = require("node:fs");
31437
- import_node_os11 = require("node:os");
31480
+ import_node_os12 = require("node:os");
31438
31481
  import_node_path42 = __toESM(require("node:path"), 1);
31439
31482
  init_process_group();
31440
31483
  init_process_table();
@@ -31442,7 +31485,7 @@ var init_swift_root_lock = __esm({
31442
31485
  INSPECT_ATTEMPTS = 5;
31443
31486
  START_TOLERANCE_MS = 2e3;
31444
31487
  name = (number3, suffix) => `${String(number3).padStart(12, "0")}.${suffix}`;
31445
- swiftRootReadHolds = new import_node_async_hooks2.AsyncLocalStorage();
31488
+ swiftRootReadHolds = new import_node_async_hooks3.AsyncLocalStorage();
31446
31489
  }
31447
31490
  });
31448
31491
 
@@ -31587,7 +31630,7 @@ function producerSettled(directory2) {
31587
31630
  const value = JSON.parse((0, import_node_fs44.readFileSync)(receipt, "utf8"));
31588
31631
  return isRecord(value) && value.released === true;
31589
31632
  }
31590
- function swiftSdkProducerCores(admitted, platform2 = process.platform, hostCpus = import_node_os12.default.availableParallelism()) {
31633
+ function swiftSdkProducerCores(admitted, platform2 = process.platform, hostCpus = import_node_os13.default.availableParallelism()) {
31591
31634
  const floor = platform2 === "linux" && hostCpus >= 64 ? 24 : 4;
31592
31635
  return Number.isSafeInteger(admitted) && admitted > 0 ? Math.max(floor, admitted) : floor;
31593
31636
  }
@@ -31734,14 +31777,14 @@ async function produceSwiftSdkImage(input) {
31734
31777
  await (0, import_promises5.setTimeout)(2e3, void 0, { signal: input.signal });
31735
31778
  }
31736
31779
  }
31737
- var import_node_child_process27, import_node_crypto29, import_node_fs44, import_node_os12, import_node_path43, import_promises5, import_node_util7, run, environmentNames, launcher;
31780
+ var import_node_child_process27, import_node_crypto29, import_node_fs44, import_node_os13, import_node_path43, import_promises5, import_node_util7, run, environmentNames, launcher;
31738
31781
  var init_swift_sdk_image_producer = __esm({
31739
31782
  "src/swift-sdk-image-producer.ts"() {
31740
31783
  "use strict";
31741
31784
  import_node_child_process27 = require("node:child_process");
31742
31785
  import_node_crypto29 = require("node:crypto");
31743
31786
  import_node_fs44 = require("node:fs");
31744
- import_node_os12 = __toESM(require("node:os"), 1);
31787
+ import_node_os13 = __toESM(require("node:os"), 1);
31745
31788
  import_node_path43 = __toESM(require("node:path"), 1);
31746
31789
  import_promises5 = require("node:timers/promises");
31747
31790
  import_node_util7 = require("node:util");
@@ -35601,7 +35644,7 @@ function swiftIcuAddress(icu) {
35601
35644
  function swiftIcuPacked(icu) {
35602
35645
  return memo(packedFiles, icu.sha256, async () => {
35603
35646
  const file = import_node_path49.default.join(
35604
- import_node_os13.default.homedir(),
35647
+ import_node_os14.default.homedir(),
35605
35648
  ".peach",
35606
35649
  "cache",
35607
35650
  "swift-brotli",
@@ -35628,7 +35671,7 @@ async function swiftIcuBundleAsset(icu) {
35628
35671
  contentType: "application/octet-stream"
35629
35672
  };
35630
35673
  }
35631
- var import_node_child_process31, import_node_crypto33, import_node_fs49, import_promises6, import_node_os13, import_node_path49, import_node_util10, import_node_zlib6, run4, deflate, compressBrotli, inflateGzip, ARCHIVE, MEMBER, raw, assets, packedFiles;
35674
+ var import_node_child_process31, import_node_crypto33, import_node_fs49, import_promises6, import_node_os14, import_node_path49, import_node_util10, import_node_zlib6, run4, deflate, compressBrotli, inflateGzip, ARCHIVE, MEMBER, raw, assets, packedFiles;
35632
35675
  var init_swift_icu = __esm({
35633
35676
  "src/swift-icu.ts"() {
35634
35677
  "use strict";
@@ -35636,7 +35679,7 @@ var init_swift_icu = __esm({
35636
35679
  import_node_crypto33 = require("node:crypto");
35637
35680
  import_node_fs49 = require("node:fs");
35638
35681
  import_promises6 = require("node:fs/promises");
35639
- import_node_os13 = __toESM(require("node:os"), 1);
35682
+ import_node_os14 = __toESM(require("node:os"), 1);
35640
35683
  import_node_path49 = __toESM(require("node:path"), 1);
35641
35684
  import_node_util10 = require("node:util");
35642
35685
  import_node_zlib6 = require("node:zlib");
@@ -35943,7 +35986,7 @@ var init_swift_objc_prebuilt = __esm({
35943
35986
 
35944
35987
  // src/swift-reproducible.ts
35945
35988
  function canonicalHomeDir() {
35946
- const home = import_node_os14.default.homedir();
35989
+ const home = import_node_os15.default.homedir();
35947
35990
  const dotPeach = import_node_path52.default.join(home, ".peach");
35948
35991
  if ((0, import_node_fs52.existsSync)(dotPeach)) {
35949
35992
  const realHome = import_node_path52.default.dirname((0, import_node_fs52.realpathSync)(dotPeach));
@@ -35965,12 +36008,12 @@ function swiftReproducibleBuildFlags(roots) {
35965
36008
  `-ffile-prefix-map=${map2}`
35966
36009
  ]);
35967
36010
  }
35968
- var import_node_fs52, import_node_os14, import_node_path52;
36011
+ var import_node_fs52, import_node_os15, import_node_path52;
35969
36012
  var init_swift_reproducible = __esm({
35970
36013
  "src/swift-reproducible.ts"() {
35971
36014
  "use strict";
35972
36015
  import_node_fs52 = require("node:fs");
35973
- import_node_os14 = __toESM(require("node:os"), 1);
36016
+ import_node_os15 = __toESM(require("node:os"), 1);
35974
36017
  import_node_path52 = __toESM(require("node:path"), 1);
35975
36018
  }
35976
36019
  });
@@ -36246,7 +36289,10 @@ function swiftPackagePrebuiltEntries(input, moduleRoot, toolchainBin) {
36246
36289
  const calls = manifestCalls(manifest, ["target"]);
36247
36290
  const platform2 = /platforms:\s*\[\.iOS\("([\d.]+)"\)\]/.exec(manifest)?.[1];
36248
36291
  if (!platform2) return [];
36249
- const sdkModules = swiftAvailableModules(moduleRoot, toolchainBin);
36292
+ const sdkModules = swiftAvailableModules(
36293
+ moduleRoot,
36294
+ typeof toolchainBin === "function" ? toolchainBin() : toolchainBin
36295
+ );
36250
36296
  return selected.flatMap(([name3, modules]) => {
36251
36297
  const prefix = `${SWIFT_REMOTE_PACKAGES_DIR}/${name3}/`;
36252
36298
  const members2 = targets.filter(
@@ -36463,7 +36509,7 @@ async function runCompiler(command, args, options2, stream = false, quiet) {
36463
36509
  }
36464
36510
  }
36465
36511
  function swiftCompilerJobs() {
36466
- return Math.min(64, swiftBuildJobs(), Math.max(1, Math.floor(import_node_os15.default.totalmem() / 2 ** 31)));
36512
+ return Math.min(64, swiftBuildJobs(), Math.max(1, Math.floor(import_node_os16.default.totalmem() / 2 ** 31)));
36467
36513
  }
36468
36514
  function swiftCompilerBaseEnv(toolchainBin, sourceEnv, includePeachHome = false) {
36469
36515
  const env = {};
@@ -37819,6 +37865,8 @@ function swiftSourceClosure(files2, roots) {
37819
37865
  return collectSwiftSourceClosure(files2, roots, swiftCodeMask);
37820
37866
  }
37821
37867
  function swiftApplicationEntry(file, source) {
37868
+ if (!source.includes("@main") && !source.includes("@UIApplicationMain") && !(import_node_path56.default.basename(file) === "main.swift" && source.includes("UIApplicationMain")))
37869
+ return false;
37822
37870
  const code = [...swiftConditionalLines(swiftCodeMask(source))].map(({ line, active }) => active === false ? " ".repeat(line.length) : line).join("\n");
37823
37871
  const { tokens: tokens2 } = swiftCodeScan(code);
37824
37872
  let depth = 0;
@@ -40579,8 +40627,8 @@ function readFrameworkProductsReceipt(scratch2, receiptKey, planChangedAt = 0n)
40579
40627
  function resolveBunBinary() {
40580
40628
  if (import_node_path56.default.basename(process.execPath).startsWith("bun")) return process.execPath;
40581
40629
  for (const candidate of [
40582
- import_node_path56.default.join(import_node_os15.default.homedir(), "builders/bun/bin/bun"),
40583
- import_node_path56.default.join(import_node_os15.default.homedir(), ".bun/bin/bun"),
40630
+ import_node_path56.default.join(import_node_os16.default.homedir(), "builders/bun/bin/bun"),
40631
+ import_node_path56.default.join(import_node_os16.default.homedir(), ".bun/bin/bun"),
40584
40632
  "/opt/homebrew/bin/bun",
40585
40633
  "/usr/local/bin/bun",
40586
40634
  "bun"
@@ -40927,18 +40975,18 @@ ${args.frameworkKey}`,
40927
40975
  function swiftFrameworkSlotCount(unoptimized) {
40928
40976
  const base2 = unoptimized ? SWIFT_FRAMEWORK_UNOPTIMIZED_SLOTS : SWIFT_FRAMEWORK_SLOTS;
40929
40977
  if (process.platform === "darwin") {
40930
- const gib = import_node_os15.default.totalmem() / (1024 * 1024 * 1024);
40978
+ const gib = import_node_os16.default.totalmem() / (1024 * 1024 * 1024);
40931
40979
  if (gib >= 120) return unoptimized ? 8 : 16;
40932
40980
  if (gib >= 56) return unoptimized ? 6 : 12;
40933
40981
  return base2;
40934
40982
  }
40935
40983
  if (process.platform !== "linux") return base2;
40936
- const cores = import_node_os15.default.availableParallelism();
40984
+ const cores = import_node_os16.default.availableParallelism();
40937
40985
  return unoptimized ? Math.min(8, Math.max(base2, Math.floor(cores / 16))) : Math.min(16, Math.max(base2, Math.floor(cores / 8)));
40938
40986
  }
40939
40987
  function swiftBuildRootSlotCount() {
40940
40988
  if (process.platform !== "linux") return SWIFT_BUILD_ROOT_SLOTS;
40941
- return import_node_os15.default.availableParallelism() >= 64 ? 8 : SWIFT_BUILD_ROOT_SLOTS;
40989
+ return import_node_os16.default.availableParallelism() >= 64 ? 8 : SWIFT_BUILD_ROOT_SLOTS;
40942
40990
  }
40943
40991
  function swiftFrameworksDir(unoptimized = false) {
40944
40992
  return import_node_path56.default.join(
@@ -41336,818 +41384,865 @@ async function compileSwiftProjectUnit(input, options2) {
41336
41384
  }
41337
41385
  }
41338
41386
  async function compileSwiftProjectOnce(sources, options2) {
41339
- options2.signal?.throwIfAborted();
41340
- assertSwiftBuildCores();
41341
- (0, import_node_fs55.mkdirSync)(options2.buildRoot, { recursive: true });
41342
- const root = (0, import_node_fs55.realpathSync)(options2.buildRoot);
41343
- refreshSwiftCacheHold(root);
41344
- const moduleRoot = import_node_path56.default.resolve(options2.moduleRoot);
41345
- const distribution = swiftDistributionAt(moduleRoot);
41346
- const mirrorDistribution = options2.linkOnly || options2.project ? null : distribution;
41347
- if (distribution) refreshSwiftCacheHold(moduleRoot);
41348
- const input = distribution && !options2.intermediates ? (await Promise.resolve().then(() => (init_swift_package_prebuilt(), swift_package_prebuilt_exports))).useSwiftPackagePrebuilts(
41349
- sources,
41350
- moduleRoot,
41351
- options2.toolchainBin
41352
- ) : sources;
41353
- const guestGraph = distribution ? input.sourceLinkGraph : void 0;
41354
- if (options2.linkOnly && guestGraph)
41355
- throw new Error("swift-compile: link-only builds do not support guest image graphs");
41356
- const layout2 = {
41357
- root,
41358
- sources: import_node_path56.default.join(root, "Sources", "App"),
41359
- multi: compileTargets(input).length > 0
41360
- };
41361
- const sdkImage = options2.linkOnly ? void 0 : await (await Promise.resolve().then(() => (init_swift_sdk_image(), swift_sdk_image_exports))).buildSwiftSdkImage(
41362
- moduleRoot,
41363
- !!guestGraph,
41364
- distribution ? [] : linkedFrameworkTargets(moduleRoot, input).imports,
41365
- { signal: options2.signal }
41366
- );
41367
- const inputHash = swiftCompileInputHash(input, options2.release);
41368
- const moduleDigest = swiftModuleDigest(moduleRoot);
41369
- const sourceHash = inputHash.copy().update(moduleDigest).digest("hex");
41370
- const hash = sdkImage ? swiftSdkArtifactHash(sourceHash, sdkImage.key) : sourceHash;
41371
- const frameworkKey = swiftProjectBuildKey(moduleRoot, options2.release);
41372
- const sharedRoot = import_node_path56.default.join(swiftCacheDir(), "swift-projects", hash);
41373
- const report = (message) => {
41374
- console.error(`[swift-project ${hash.slice(0, 16)}] ${message}`);
41375
- options2.onStage?.(message);
41376
- };
41377
- return serialize(
41378
- root,
41379
- async () => {
41380
- if (!options2.intermediates) {
41381
- report("checking verified artifacts");
41382
- const retained = retainedArtifacts.get(root)?.find((old) => old.hash === hash);
41383
- if (retained) {
41384
- report("reusing memory artifact");
41385
- return retain(root, retained);
41386
- }
41387
- const cached2 = readCompiledArtifact(import_node_path56.default.join(sharedRoot, "artifact"), hash);
41388
- const previous = cached2 ?? (options2.project ? null : readCompiledArtifact(import_node_path56.default.join(root, "artifact"), hash));
41389
- if (previous) {
41390
- if (cached2) renewSharedArtifact(sharedRoot);
41391
- else saveSharedArtifact(sharedRoot, previous);
41392
- report("reusing verified disk artifact");
41393
- return retain(root, previous);
41394
- }
41395
- }
41396
- const baseRoot = root;
41397
- const canPoolBuildRoot = !options2.intermediates && !options2.project && !options2.linkOnly && import_node_path56.default.basename(import_node_path56.default.dirname(baseRoot)) === "swift-builds";
41398
- const compatShapeParts = canPoolBuildRoot ? [
41399
- distribution ? options2.release : frameworkKey,
41400
- compileTargets(input).map((target) => target.name).sort(),
41401
- input.oneModule === true,
41402
- input.optimize === true,
41403
- input.unoptimized === true
41404
- ] : null;
41405
- const compatShape = compatShapeParts ? (0, import_node_crypto36.createHash)("sha256").update(JSON.stringify(compatShapeParts)).digest("hex").slice(0, 16) : "";
41406
- const exactShape = compatShapeParts ? (0, import_node_crypto36.createHash)("sha256").update(
41407
- JSON.stringify([...compatShapeParts, Object.keys(input.files).sort()])
41408
- ).digest("hex").slice(0, 16) : "";
41409
- const buildShape = compatShapeParts ? `${exactShape}
41410
- ${compatShape}` : "";
41411
- return withSwiftCompileBudget(options2.timeoutMs, options2.signal, async (budget) => {
41412
- const stage = (message) => {
41413
- budget.progress();
41414
- report(message);
41415
- };
41416
- const runLocked = (work) => {
41417
- const runInBuildRoot = () => {
41418
- if (canPoolBuildRoot)
41419
- return withSwiftBuildRootSlot(
41420
- baseRoot,
41421
- exactShape,
41422
- compatShape,
41423
- budget.signal,
41424
- work
41425
- );
41426
- const waitStart = Date.now();
41427
- return withSwiftRootLock(
41428
- baseRoot,
41429
- (lease) => work(baseRoot, lease, Date.now() - waitStart),
41430
- budget.signal
41431
- );
41432
- };
41433
- if (options2.intermediates || baseRoot === sharedRoot) return runInBuildRoot();
41434
- return withSwiftRootLock(
41435
- sharedRoot,
41436
- async () => {
41437
- const built2 = readCompiledArtifact(import_node_path56.default.join(sharedRoot, "artifact"), hash);
41438
- if (built2) {
41439
- renewSharedArtifact(sharedRoot);
41440
- stage("reusing verified disk artifact");
41441
- return retain(baseRoot, built2);
41442
- }
41443
- return runInBuildRoot();
41444
- },
41445
- budget.signal
41446
- );
41447
- };
41448
- return runLocked(async (slotRoot, lease, waitedMs) => {
41449
- const root2 = slotRoot;
41450
- const layout3 = {
41451
- root: root2,
41452
- sources: import_node_path56.default.join(root2, "Sources", "App"),
41453
- multi: compileTargets(input).length > 0
41454
- };
41455
- if (!options2.intermediates) {
41456
- const built2 = readCompiledArtifact(import_node_path56.default.join(sharedRoot, "artifact"), hash);
41457
- if (built2) {
41458
- stage("reusing verified disk artifact");
41459
- return retain(baseRoot, built2);
41460
- }
41461
- }
41462
- if (waitedMs >= 1e3)
41463
- report(`acquired build root ${import_node_path56.default.basename(root2)} after ${waitedMs}ms`);
41464
- if (canPoolBuildRoot) {
41465
- refreshSwiftCacheHold(root2);
41466
- (0, import_node_fs55.writeFileSync)(import_node_path56.default.join(root2, SWIFT_BUILD_ROOT_SHAPE), buildShape);
41387
+ return withSwiftModuleDigestScope(async () => {
41388
+ options2.signal?.throwIfAborted();
41389
+ (0, import_node_fs55.mkdirSync)(options2.buildRoot, { recursive: true });
41390
+ const root = (0, import_node_fs55.realpathSync)(options2.buildRoot);
41391
+ refreshSwiftCacheHold(root);
41392
+ const moduleRoot = import_node_path56.default.resolve(options2.moduleRoot);
41393
+ const distribution = swiftDistributionAt(moduleRoot);
41394
+ const mirrorDistribution = options2.linkOnly || options2.project ? null : distribution;
41395
+ if (distribution) refreshSwiftCacheHold(moduleRoot);
41396
+ let resolvedToolchainBin = options2.toolchainBin;
41397
+ const resolveToolchainBin = () => {
41398
+ if (resolvedToolchainBin) return resolvedToolchainBin;
41399
+ if (!options2.resolveToolchain)
41400
+ throw new Error("swift-compile: missing toolchainBin");
41401
+ resolvedToolchainBin = options2.resolveToolchain();
41402
+ return resolvedToolchainBin;
41403
+ };
41404
+ const input = distribution && !options2.intermediates ? (await Promise.resolve().then(() => (init_swift_package_prebuilt(), swift_package_prebuilt_exports))).useSwiftPackagePrebuilts(
41405
+ sources,
41406
+ moduleRoot,
41407
+ resolveToolchainBin
41408
+ ) : sources;
41409
+ const guestGraph = distribution ? input.sourceLinkGraph : void 0;
41410
+ if (options2.linkOnly && guestGraph)
41411
+ throw new Error("swift-compile: link-only builds do not support guest image graphs");
41412
+ const layout2 = {
41413
+ root,
41414
+ sources: import_node_path56.default.join(root, "Sources", "App"),
41415
+ multi: compileTargets(input).length > 0
41416
+ };
41417
+ const sdkImage = options2.linkOnly ? void 0 : await (await Promise.resolve().then(() => (init_swift_sdk_image(), swift_sdk_image_exports))).buildSwiftSdkImage(
41418
+ moduleRoot,
41419
+ !!guestGraph,
41420
+ distribution ? [] : linkedFrameworkTargets(moduleRoot, input).imports,
41421
+ { signal: options2.signal }
41422
+ );
41423
+ const inputHash = swiftCompileInputHash(input, options2.release);
41424
+ const moduleDigest = swiftModuleDigest(moduleRoot);
41425
+ const sourceHash = inputHash.copy().update(moduleDigest).digest("hex");
41426
+ const hash = sdkImage ? swiftSdkArtifactHash(sourceHash, sdkImage.key) : sourceHash;
41427
+ const sharedRoot = import_node_path56.default.join(swiftCacheDir(), "swift-projects", hash);
41428
+ const report = (message) => {
41429
+ console.error(`[swift-project ${hash.slice(0, 16)}] ${message}`);
41430
+ options2.onStage?.(message);
41431
+ };
41432
+ return serialize(
41433
+ root,
41434
+ async () => {
41435
+ if (!options2.intermediates) {
41436
+ report("checking verified artifacts");
41437
+ const retained = retainedArtifacts.get(root)?.find((old) => old.hash === hash);
41438
+ if (retained) {
41439
+ report("reusing memory artifact");
41440
+ return retain(root, retained);
41467
41441
  }
41468
- const swift = import_node_path56.default.join(options2.toolchainBin, "swift");
41469
- if (!(0, import_node_fs55.existsSync)(swift)) {
41470
- throw new Error(
41471
- `swift-compile: no swift.org toolchain at ${options2.toolchainBin}; install ${options2.release} and its matching wasm sdk`
41472
- );
41442
+ const cached2 = readCompiledArtifact(import_node_path56.default.join(sharedRoot, "artifact"), hash);
41443
+ const previous = cached2 ?? (options2.project ? null : readCompiledArtifact(import_node_path56.default.join(root, "artifact"), hash));
41444
+ if (previous) {
41445
+ if (cached2) renewSharedArtifact(sharedRoot);
41446
+ else saveSharedArtifact(sharedRoot, previous);
41447
+ report("reusing verified disk artifact");
41448
+ return retain(root, previous);
41473
41449
  }
41474
- const unoptimized = input.unoptimized === true;
41475
- const baseBuildEnv = options2.project?.env ? {
41476
- ...options2.project.env,
41477
- // shipped host plugins resolve against the selected compiler's runtime.
41478
- ...process.platform === "linux" ? {
41479
- LD_LIBRARY_PATH: [
41480
- import_node_path56.default.resolve(options2.toolchainBin, "../lib/swift/linux"),
41481
- import_node_path56.default.resolve(options2.toolchainBin, "../lib/swift/host"),
41482
- process.env.LD_LIBRARY_PATH
41483
- ].filter(Boolean).join(":")
41484
- } : {},
41485
- PEACH_DEFER_WASM_LINK: "1"
41486
- } : swiftCompilerBaseEnv(options2.toolchainBin, process.env);
41487
- const prepareFrameworks = async (slot, frameworkLease, allowWrite = true) => {
41488
- if (allowWrite) budget.startCompile();
41489
- const frameworkRoot2 = mirrorDistribution ? syncSwiftDistributionMirror(root2, moduleRoot, mirrorDistribution) : distribution ? moduleRoot : stageFrameworkSource(moduleRoot, slot, frameworkKey, options2.release);
41490
- if (!swiftModuleDigest(frameworkRoot2).equals(moduleDigest))
41491
- throw new Error("Swift staged project source differs from the caller");
41492
- if (!allowWrite && swiftMacroPlugins(frameworkRoot2).stale) return;
41493
- if (allowWrite) stage("preparing compiler plugins");
41494
- const macroPlugins2 = await ensureMacroPlugins(
41495
- frameworkRoot2,
41496
- options2.toolchainBin,
41497
- options2.release,
41498
- budget.signal,
41499
- frameworkLease
41500
- );
41501
- const compileFrameworkRoot2 = distribution ? swiftDistributionCompileView(frameworkRoot2, distribution) : frameworkRoot2;
41502
- const sdk2 = swiftModuleSdk(frameworkRoot2).wasmSdkId;
41503
- const compileSdk2 = mirrorDistribution ? syncSwiftSdkMirror(root2, frameworkRoot2, options2.toolchainBin, sdk2) : {
41504
- id: sdk2,
41505
- options: swiftCompileSdkOptions(frameworkRoot2, options2.toolchainBin),
41506
- toolsetChanged: false
41450
+ }
41451
+ assertSwiftBuildCores();
41452
+ const toolchainBin = resolveToolchainBin();
41453
+ await options2.beforeCompile?.(toolchainBin);
41454
+ clearSwiftModuleDigestScope(moduleRoot);
41455
+ const frameworkKey = swiftProjectBuildKey(moduleRoot, options2.release);
41456
+ const baseRoot = root;
41457
+ const canPoolBuildRoot = !options2.intermediates && !options2.project && !options2.linkOnly && import_node_path56.default.basename(import_node_path56.default.dirname(baseRoot)) === "swift-builds";
41458
+ const compatShapeParts = canPoolBuildRoot ? [
41459
+ distribution ? options2.release : frameworkKey,
41460
+ compileTargets(input).map((target) => target.name).sort(),
41461
+ input.oneModule === true,
41462
+ input.optimize === true,
41463
+ input.unoptimized === true
41464
+ ] : null;
41465
+ const compatShape = compatShapeParts ? (0, import_node_crypto36.createHash)("sha256").update(JSON.stringify(compatShapeParts)).digest("hex").slice(0, 16) : "";
41466
+ const exactShape = compatShapeParts ? (0, import_node_crypto36.createHash)("sha256").update(
41467
+ JSON.stringify([...compatShapeParts, Object.keys(input.files).sort()])
41468
+ ).digest("hex").slice(0, 16) : "";
41469
+ const buildShape = compatShapeParts ? `${exactShape}
41470
+ ${compatShape}` : "";
41471
+ return withSwiftCompileBudget(
41472
+ options2.timeoutMs,
41473
+ options2.signal,
41474
+ async (budget) => {
41475
+ const stage = (message) => {
41476
+ budget.progress();
41477
+ report(message);
41507
41478
  };
41508
- if (mirrorDistribution && compileSdk2.toolsetChanged)
41509
- clearSwiftSdkPathsCache(import_node_path56.default.join(root2, SWIFT_SDK_MIRROR));
41510
- const icu2 = options2.linkOnly ? null : swiftIcuAsset(options2.toolchainBin, sdk2);
41511
- let prebuilt2;
41512
- if (!distribution) {
41513
- if (allowWrite) stage("compiling framework products");
41514
- prebuilt2 = await buildFrameworkProducts(
41515
- slot,
41516
- {
41517
- moduleRoot: frameworkRoot2,
41518
- frameworkKey,
41519
- input,
41520
- swift,
41521
- sdk: sdk2,
41522
- toolchainBin: options2.toolchainBin,
41523
- plugins: macroPlugins2,
41524
- buildOptions: {
41525
- env: baseBuildEnv,
41526
- maxBuffer: 64 * 1024 * 1024,
41527
- signal: budget.signal,
41528
- onOutput: budget.progress,
41529
- lease,
41530
- frameworkLease
41479
+ const runLocked = (work) => {
41480
+ const runInBuildRoot = () => {
41481
+ if (canPoolBuildRoot)
41482
+ return withSwiftBuildRootSlot(
41483
+ baseRoot,
41484
+ exactShape,
41485
+ compatShape,
41486
+ budget.signal,
41487
+ work
41488
+ );
41489
+ const waitStart = Date.now();
41490
+ return withSwiftRootLock(
41491
+ baseRoot,
41492
+ (lease) => work(baseRoot, lease, Date.now() - waitStart),
41493
+ budget.signal
41494
+ );
41495
+ };
41496
+ if (options2.intermediates || baseRoot === sharedRoot)
41497
+ return runInBuildRoot();
41498
+ return withSwiftRootLock(
41499
+ sharedRoot,
41500
+ async () => {
41501
+ const built2 = readCompiledArtifact(
41502
+ import_node_path56.default.join(sharedRoot, "artifact"),
41503
+ hash
41504
+ );
41505
+ if (built2) {
41506
+ renewSharedArtifact(sharedRoot);
41507
+ stage("reusing verified disk artifact");
41508
+ return retain(baseRoot, built2);
41531
41509
  }
41510
+ return runInBuildRoot();
41532
41511
  },
41533
- allowWrite
41512
+ budget.signal
41534
41513
  );
41535
- if (!prebuilt2) return;
41536
- if (!allowWrite) {
41537
- budget.startCompile();
41538
- stage("reusing verified framework products");
41539
- }
41540
- }
41541
- const readHold2 = slot ? acquireSwiftRootReadHold(slot) : void 0;
41542
- return {
41543
- frameworkRoot: frameworkRoot2,
41544
- compileFrameworkRoot: compileFrameworkRoot2,
41545
- macroPlugins: macroPlugins2,
41546
- sdk: sdk2,
41547
- compileSdk: compileSdk2,
41548
- icu: icu2,
41549
- prebuilt: prebuilt2,
41550
- readHold: readHold2
41551
41514
  };
41552
- };
41553
- const frameworks = distribution ? await prepareFrameworks(null) : await withSwiftFrameworkSlot(
41554
- frameworkKey,
41555
- options2.release,
41556
- moduleRoot,
41557
- budget.signal,
41558
- prepareFrameworks,
41559
- unoptimized,
41560
- options2.linkOnly === true
41561
- );
41562
- if (!frameworks)
41563
- throw new Error("Swift distribution did not provide its frameworks");
41564
- const {
41565
- frameworkRoot,
41566
- compileFrameworkRoot,
41567
- macroPlugins,
41568
- compileSdk,
41569
- icu,
41570
- prebuilt
41571
- } = frameworks;
41572
- let readHold = frameworks.readHold;
41573
- const buildOptions = {
41574
- env: baseBuildEnv,
41575
- maxBuffer: 64 * 1024 * 1024,
41576
- signal: budget.signal,
41577
- onOutput: budget.progress,
41578
- lease
41579
- };
41580
- try {
41581
- if (options2.project) removeProjectLinks(root2);
41582
- const packageHostMacros = process.platform === "linux" ? input.packageHostMacros : void 0;
41583
- if (retireStaleSwiftLink(
41584
- root2,
41585
- swiftLinkStamp({
41586
- frameworkKey: mirrorDistribution ? `${options2.release}\0mirror` : `${options2.release}\0${Boolean(distribution)}\0${swiftModuleSdk(frameworkRoot).wasmSdkId}`,
41587
- packageHostMacros
41588
- }),
41589
- swiftLinkStamp({
41590
- // mirrored distributions and their WASI SDK mirror invalidate
41591
- // dependents per changed file instead of wiping every Clang object.
41592
- frameworkKey: mirrorDistribution ? `${options2.release}\0mirror` : distribution ? `${options2.release}\0${distribution.wasmSdkChecksum}` : frameworkKey,
41593
- prebuilt,
41594
- packageHostMacros
41595
- }),
41596
- Boolean(options2.linkOnly)
41597
- ))
41598
- stage("framework revision changed; rebuilding the app link");
41599
- const nativeToolset = needsNativeToolset(input, prebuilt);
41600
- const preparation = writeSwiftProject(
41601
- layout3,
41602
- input,
41603
- frameworkRoot,
41604
- prebuilt,
41605
- !options2.project,
41606
- options2.project ? false : options2.objcPrebuiltStage ?? (options2.intermediates ? false : void 0),
41607
- compileSdk
41608
- );
41609
- const productFile = import_node_path56.default.join(frameworkRoot, SWIFT_FRAMEWORK_PRODUCT_FILE);
41610
- writeSwiftAutolinkLinker(
41611
- root2,
41612
- options2.toolchainBin,
41613
- (0, import_node_fs55.existsSync)(productFile) ? [
41614
- v6.parse(
41615
- swiftFrameworkProductSchema,
41616
- JSON.parse((0, import_node_fs55.readFileSync)(productFile, "utf8"))
41617
- ).product.name
41618
- ] : []
41619
- );
41620
- const compiler = preparation.targetToolset ? { CC: import_node_path56.default.join(root2, CLANG_TARGET_MODULE_WRAPPER) } : {};
41621
- if (packageHostMacros?.length) {
41622
- const swiftc = import_node_path56.default.join(root2, SWIFT_HOST_COMPILER_WRAPPER);
41623
- writeBuildFile(
41624
- swiftc,
41625
- [
41626
- "#!/bin/sh",
41627
- "target=",
41628
- "module=",
41629
- "compile=",
41630
- "previous=",
41631
- "for argument do",
41632
- ' case "$previous" in -target) target=$argument ;; -module-name) module=$argument ;; esac',
41633
- ' case "$argument" in -c|-emit-module|-scan-dependencies|-typecheck) compile=1 ;; esac',
41634
- " previous=$argument",
41635
- "done",
41636
- 'case "$target/$compile" in',
41637
- " *-*-linux*/1)",
41638
- ' case ",$PEACH_SWIFT_HOST_MACROS," in',
41639
- ' *",$module,"*) set -- "$@" -Xfrontend -import-module -Xfrontend Foundation ;;',
41640
- " esac ;;",
41641
- "esac",
41642
- 'exec "$PEACH_SWIFTC" "$@"',
41643
- ""
41644
- ].join("\n")
41645
- );
41646
- (0, import_node_fs55.chmodSync)(swiftc, 493);
41647
- compiler.SWIFT_EXEC = swiftc;
41648
- compiler.PEACH_SWIFT_HOST_MACROS = packageHostMacros.join(",");
41649
- compiler.PEACH_SWIFTC = import_node_path56.default.join(options2.toolchainBin, "swiftc");
41650
- }
41651
- const projectProcess = options2.project ? prepareSwiftProjectProcess(root2, options2.project) : void 0;
41652
- const temporaryDirectory = projectProcess ? void 0 : import_node_path56.default.join(root2, ".build", "peach-compiler-tmp");
41653
- const appOptions = projectProcess ? {
41654
- ...buildOptions,
41655
- uid: projectProcess.uid,
41656
- gid: projectProcess.gid,
41657
- confined: { ...projectProcess.env, ...compiler }
41658
- } : {
41659
- ...buildOptions,
41660
- temporaryDirectory,
41661
- env: {
41662
- ...buildOptions.env,
41663
- ...preparation.usesObjcPrebuilt && process.env.PEACH_HOME !== void 0 ? { PEACH_HOME: process.env.PEACH_HOME } : {},
41664
- ...compiler
41665
- }
41666
- };
41667
- const unprepared = preparation.targetFailures.map(
41668
- (failure2) => `error: target ${failure2}`
41669
- );
41670
- const forwarders = /* @__PURE__ */ new Map();
41671
- for (const [file, text7] of Object.entries(input.files)) {
41672
- const parents = /^#include "((?:\.\.\/)+)[^"\n]+"\n$/.exec(text7)?.[1];
41673
- if (!parents) continue;
41674
- const directory2 = import_node_path56.default.posix.dirname(file);
41675
- forwarders.set(
41676
- `${import_node_path56.default.join(root2, directory2)}/${parents.slice(0, -1)}`,
41677
- import_node_path56.default.posix.join("build", directory2, parents).replace(/\/$/, "")
41678
- );
41679
- }
41680
- const jobs = swiftCompilerJobs();
41681
- const incrementalPreview = sdkImage !== void 0 && !guestGraph && !options2.project && !input.optimize && !input.unoptimized;
41682
- const batchGuest = guestGraph !== void 0 && !options2.project && !input.unoptimized;
41683
- const guestDriverJobs = Math.min(8, jobs);
41684
- const singleProducerJobs = Math.min(16, Math.floor(jobs / 2));
41685
- const batch = incrementalPreview || batchGuest;
41686
- const perFile = input.unoptimized || batch;
41687
- const reproducibleFrameworkRoot = mirrorDistribution ? frameworkRoot : compileFrameworkRoot;
41688
- const buildArgs = [
41689
- "build",
41690
- ...projectProcess?.cacheOptions ?? swiftPackageCacheOptions(),
41691
- "--build-system",
41692
- "native",
41693
- "-j",
41694
- String(jobs),
41695
- "--package-path",
41696
- root2,
41697
- ...compileSdk.options,
41698
- ...swiftObjCSelectorOptions(frameworkRoot),
41699
- "--swift-sdk",
41700
- compileSdk.id,
41701
- ...preparation.targetToolset ? ["--toolset", import_node_path56.default.join(root2, ".peach-target-toolset.json")] : [],
41702
- "-c",
41703
- "release",
41704
- ...input.unoptimized ? ["-Xswiftc", "-Onone"] : [],
41705
- ...perFile ? [
41706
- "-Xswiftc",
41707
- "-no-whole-module-optimization",
41708
- "-Xswiftc",
41709
- "-j",
41710
- "-Xswiftc",
41711
- String(batchGuest ? guestDriverJobs : jobs)
41712
- ] : [],
41713
- // optimized batches can move specialized definitions between objects.
41714
- ...incrementalPreview ? ["-Xswiftc", "-incremental"] : [],
41715
- ...batch ? ["-Xswiftc", "-enable-batch-mode"] : [],
41716
- // the mirror finds a changed sdk header's readers in their
41717
- // dependency files, which omit system headers by default
41718
- ...mirrorDistribution ? ["-Xswiftc", "-track-system-dependencies"] : [],
41719
- // the link strips debug info, so none is generated (as for the framework).
41720
- // keep -num-threads fixed across caller core caps so llbuild does not
41721
- // rebuild every target when callers alternate --cores, and bound backend
41722
- // fan-out under high -j.
41723
- "-Xswiftc",
41724
- "-gnone",
41725
- "-Xcc",
41726
- "-g0",
41727
- "-Xcxx",
41728
- "-g0",
41729
- ...batch ? [] : [
41730
- "-Xswiftc",
41731
- "-num-threads",
41732
- "-Xswiftc",
41733
- String(perFile ? 1 : Math.min(8, import_node_os15.default.availableParallelism()))
41734
- ],
41735
- ...swiftReproducibleBuildFlags([
41736
- [import_node_path56.default.dirname(options2.toolchainBin), "toolchain"],
41737
- [reproducibleFrameworkRoot, "framework"],
41738
- [root2, "build"],
41739
- ...forwarders
41740
- ]).flatMap((flag, index, flags) => {
41741
- if (!nativeToolset || !flag.startsWith("-ffile-prefix-map="))
41742
- return [flag];
41743
- const toolchainDir = import_node_path56.default.dirname(options2.toolchainBin);
41744
- let mapped = flag;
41745
- for (const [dir, target] of [
41746
- [root2, "/peach/build"],
41747
- [reproducibleFrameworkRoot, "/peach/framework"],
41748
- [(0, import_node_fs55.realpathSync)(reproducibleFrameworkRoot), "/peach/framework"],
41749
- [toolchainDir, "/peach/toolchain"],
41750
- [(0, import_node_fs55.realpathSync)(toolchainDir), "/peach/toolchain"]
41751
- ]) {
41752
- mapped = mapped.replaceAll(dir, target);
41515
+ return runLocked(async (slotRoot, lease, waitedMs) => {
41516
+ const root2 = slotRoot;
41517
+ const layout3 = {
41518
+ root: root2,
41519
+ sources: import_node_path56.default.join(root2, "Sources", "App"),
41520
+ multi: compileTargets(input).length > 0
41521
+ };
41522
+ if (!options2.intermediates) {
41523
+ const built2 = readCompiledArtifact(
41524
+ import_node_path56.default.join(sharedRoot, "artifact"),
41525
+ hash
41526
+ );
41527
+ if (built2) {
41528
+ stage("reusing verified disk artifact");
41529
+ return retain(baseRoot, built2);
41753
41530
  }
41754
- const [, from, to] = /^-ffile-prefix-map=([^=]+)=(.+)$/.exec(mapped) ?? [];
41755
- const tool = flags[index - 1];
41756
- return mapped !== flag && from !== to ? [flag, tool, mapped] : [flag];
41757
- }),
41758
- ...macroPlugins.libraries.flatMap((plugin) => [
41759
- "-Xswiftc",
41760
- "-load-plugin-library",
41761
- "-Xswiftc",
41762
- plugin
41763
- ]),
41764
- ...macroPlugins.executables.flatMap((plugin) => [
41765
- "-Xswiftc",
41766
- "-load-plugin-executable",
41767
- "-Xswiftc",
41768
- `${plugin}#ExpoModulesMacros`
41769
- ])
41770
- ];
41771
- const linked = builtArtifact(layout3);
41772
- (0, import_node_fs55.rmSync)(import_node_path56.default.join(root2, ".peach-link.rsp"), { force: true });
41773
- if (options2.linkOnly || (0, import_node_fs55.existsSync)(linked) && (0, import_node_fs55.statSync)(linked).size <= 8)
41774
- (0, import_node_fs55.rmSync)(linked, { force: true });
41775
- stage("compiling and linking Swift modules");
41776
- const frameworkInterfaces = /* @__PURE__ */ new Map();
41777
- const compileSdkPaths = swiftSdkPaths(
41778
- frameworkRoot,
41779
- options2.toolchainBin,
41780
- compileSdk.options,
41781
- compileSdk.id
41782
- );
41783
- const sdkFrameworks = import_node_path56.default.join(
41784
- compileSdkPaths.darwin,
41785
- "System/Library/Frameworks"
41786
- );
41787
- const generatedInterface = (source) => withoutImportedSdkEnumForwards(
41788
- clangInterfaceHeader((0, import_node_fs55.readFileSync)(source, "utf8"), frameworkRoot),
41789
- sdkObjCDeclarationOwners(sdkFrameworks)
41790
- );
41791
- const nativeDeclarations = /* @__PURE__ */ new Map();
41792
- const nativeHeaders = Object.entries(input.files).filter(([name3]) => name3.endsWith(".h") && !name3.endsWith("-Swift.h")).map(([, source]) => source);
41793
- for (const [file, contents2] of Object.entries(input.files)) {
41794
- if (!file.endsWith(".modulemap")) continue;
41795
- const name3 = moduleMapName(contents2);
41796
- const umbrella = /\bumbrella\s+header\s+"([^"]+)"/.exec(contents2)?.[1];
41797
- if (!name3 || !umbrella) continue;
41798
- const header = input.files[import_node_path56.default.posix.join(import_node_path56.default.posix.dirname(file), umbrella)];
41799
- if (header === void 0) continue;
41800
- const included = new Set(
41801
- [
41802
- ...header.matchAll(/^\s*#\s*(?:import|include)\s*[<"]([^">]+)[">]/gm)
41803
- ].map((match) => import_node_path56.default.posix.basename(match[1]))
41804
- );
41805
- const declarations = nativeDeclarations.get(name3) ?? /* @__PURE__ */ new Set();
41806
- for (const declaration of swiftInterfaceDeclarations(header))
41807
- declarations.add(declaration);
41808
- for (const [candidate, source] of Object.entries(input.files))
41809
- if (included.has(import_node_path56.default.posix.basename(candidate)))
41810
- for (const declaration of swiftInterfaceDeclarations(source))
41811
- declarations.add(declaration);
41812
- nativeDeclarations.set(name3, declarations);
41813
- }
41814
- const frameworkInterface = (name3) => {
41815
- if (frameworkInterfaces.has(name3)) return frameworkInterfaces.get(name3);
41816
- const source = distribution ? import_node_path56.default.join(frameworkRoot, "modules", `${name3}-Swift.h`) : prebuilt.objcHeaders.get(name3);
41817
- if (!source || !(0, import_node_fs55.existsSync)(source)) {
41818
- frameworkInterfaces.set(name3, null);
41819
- return null;
41820
41531
  }
41821
- const headers = import_node_path56.default.join(sdkFrameworks, `${name3}.framework/Headers`);
41822
- const declared = /* @__PURE__ */ new Set();
41823
- if ((0, import_node_fs55.existsSync)(headers)) {
41824
- for (const file of (0, import_node_fs55.readdirSync)(headers, {
41825
- recursive: true,
41826
- encoding: "utf8"
41827
- }))
41828
- if (file.endsWith(".h"))
41829
- for (const name4 of swiftInterfaceDeclarations(
41830
- (0, import_node_fs55.readFileSync)(import_node_path56.default.join(headers, file), "utf8")
41831
- ))
41832
- declared.add(name4);
41532
+ if (waitedMs >= 1e3)
41533
+ report(`acquired build root ${import_node_path56.default.basename(root2)} after ${waitedMs}ms`);
41534
+ if (canPoolBuildRoot) {
41535
+ refreshSwiftCacheHold(root2);
41536
+ (0, import_node_fs55.writeFileSync)(import_node_path56.default.join(root2, SWIFT_BUILD_ROOT_SHAPE), buildShape);
41833
41537
  }
41834
- for (const declaration of nativeDeclarations.get(name3) ?? [])
41835
- declared.add(declaration);
41836
- const own2 = withoutSwiftDeclarations(
41837
- generatedInterface(source),
41838
- declared,
41839
- nativeDeclarations.has(name3) ? `@import ${name3};` : `#import <${name3}/${name3}.h>`
41840
- );
41841
- const owners = sdkObjCDeclarationOwners(sdkFrameworks);
41842
- const foreign = /* @__PURE__ */ new Map();
41843
- for (const declaration of [
41844
- ...swiftInterfaceDeclarations(own2),
41845
- ...objcEnumerations(own2),
41846
- ...[...own2.matchAll(/^\s*SWIFT_EXTERN\b[^(\n]*?\b(\w+)\s*\(/gm)].map(
41847
- (match) => match[1]
41848
- )
41849
- ]) {
41850
- const owner = owners.get(declaration);
41851
- if (owner && owner !== name3) foreign.set(declaration, owner);
41538
+ const swift = import_node_path56.default.join(toolchainBin, "swift");
41539
+ if (!(0, import_node_fs55.existsSync)(swift)) {
41540
+ throw new Error(
41541
+ `swift-compile: no swift.org toolchain at ${toolchainBin}; install ${options2.release} and its matching wasm sdk`
41542
+ );
41852
41543
  }
41853
- const header = foreign.size ? withoutSwiftDeclarations(
41854
- own2,
41855
- new Set(foreign.keys()),
41856
- [...new Set(foreign.values())].map((owner) => `#import <${owner}/${owner}.h>`).join("\n")
41857
- ) : own2;
41858
- const value = {
41859
- file: import_node_path56.default.join(root2, ".build/peach-framework-objc", `${name3}-Swift.h`),
41860
- header,
41861
- module: (0, import_node_fs55.existsSync)(headers)
41544
+ const unoptimized = input.unoptimized === true;
41545
+ const baseBuildEnv = options2.project?.env ? {
41546
+ ...options2.project.env,
41547
+ // shipped host plugins resolve against the selected compiler's runtime.
41548
+ ...process.platform === "linux" ? {
41549
+ LD_LIBRARY_PATH: [
41550
+ import_node_path56.default.resolve(toolchainBin, "../lib/swift/linux"),
41551
+ import_node_path56.default.resolve(toolchainBin, "../lib/swift/host"),
41552
+ process.env.LD_LIBRARY_PATH
41553
+ ].filter(Boolean).join(":")
41554
+ } : {},
41555
+ PEACH_DEFER_WASM_LINK: "1"
41556
+ } : swiftCompilerBaseEnv(toolchainBin, process.env);
41557
+ const prepareFrameworks = async (slot, frameworkLease, allowWrite = true) => {
41558
+ if (allowWrite) budget.startCompile();
41559
+ const frameworkRoot2 = mirrorDistribution ? syncSwiftDistributionMirror(root2, moduleRoot, mirrorDistribution) : distribution ? moduleRoot : stageFrameworkSource(
41560
+ moduleRoot,
41561
+ slot,
41562
+ frameworkKey,
41563
+ options2.release
41564
+ );
41565
+ if (!swiftModuleDigest(frameworkRoot2).equals(moduleDigest))
41566
+ throw new Error("Swift staged project source differs from the caller");
41567
+ if (!allowWrite && swiftMacroPlugins(frameworkRoot2).stale) return;
41568
+ if (allowWrite) stage("preparing compiler plugins");
41569
+ const macroPlugins2 = await ensureMacroPlugins(
41570
+ frameworkRoot2,
41571
+ toolchainBin,
41572
+ options2.release,
41573
+ budget.signal,
41574
+ frameworkLease
41575
+ );
41576
+ const compileFrameworkRoot2 = distribution ? swiftDistributionCompileView(frameworkRoot2, distribution) : frameworkRoot2;
41577
+ const sdk2 = swiftModuleSdk(frameworkRoot2).wasmSdkId;
41578
+ const compileSdk2 = mirrorDistribution ? syncSwiftSdkMirror(root2, frameworkRoot2, toolchainBin, sdk2) : {
41579
+ id: sdk2,
41580
+ options: swiftCompileSdkOptions(frameworkRoot2, toolchainBin),
41581
+ toolsetChanged: false
41582
+ };
41583
+ if (mirrorDistribution && compileSdk2.toolsetChanged)
41584
+ clearSwiftSdkPathsCache(import_node_path56.default.join(root2, SWIFT_SDK_MIRROR));
41585
+ const icu2 = options2.linkOnly ? null : swiftIcuAsset(toolchainBin, sdk2);
41586
+ let prebuilt2;
41587
+ if (!distribution) {
41588
+ if (allowWrite) stage("compiling framework products");
41589
+ prebuilt2 = await buildFrameworkProducts(
41590
+ slot,
41591
+ {
41592
+ moduleRoot: frameworkRoot2,
41593
+ frameworkKey,
41594
+ input,
41595
+ swift,
41596
+ sdk: sdk2,
41597
+ toolchainBin,
41598
+ plugins: macroPlugins2,
41599
+ buildOptions: {
41600
+ env: baseBuildEnv,
41601
+ maxBuffer: 64 * 1024 * 1024,
41602
+ signal: budget.signal,
41603
+ onOutput: budget.progress,
41604
+ lease,
41605
+ frameworkLease
41606
+ }
41607
+ },
41608
+ allowWrite
41609
+ );
41610
+ if (!prebuilt2) return;
41611
+ if (!allowWrite) {
41612
+ budget.startCompile();
41613
+ stage("reusing verified framework products");
41614
+ }
41615
+ }
41616
+ const readHold2 = slot ? acquireSwiftRootReadHold(slot) : void 0;
41617
+ return {
41618
+ frameworkRoot: frameworkRoot2,
41619
+ compileFrameworkRoot: compileFrameworkRoot2,
41620
+ macroPlugins: macroPlugins2,
41621
+ sdk: sdk2,
41622
+ compileSdk: compileSdk2,
41623
+ icu: icu2,
41624
+ prebuilt: prebuilt2,
41625
+ readHold: readHold2
41626
+ };
41862
41627
  };
41863
- frameworkInterfaces.set(name3, value);
41864
- writeBuildFile(
41865
- value.file,
41866
- ((0, import_node_fs55.existsSync)(import_node_path56.default.join(headers, `${name3}.h`)) ? `#import <${name3}/${name3}.h>
41867
- ` : "") + swiftHeaderWithSuperclassImports(header, frameworkInterface)
41868
- );
41869
- return value;
41870
- };
41871
- const headerPaths = (producer) => {
41872
- const stem2 = import_node_path56.default.join(
41873
- root2,
41874
- ".build",
41875
- "peach-cxx-headers",
41876
- `${producer}-Swift`
41877
- );
41878
- return { producer, original: `${stem2}.original.h`, emitted: `${stem2}.h` };
41879
- };
41880
- const publishHeader = ({
41881
- producer,
41882
- original,
41883
- emitted
41884
- }) => {
41885
- const generated = generatedInterface(original);
41886
- writeBuildFile(
41887
- emitted,
41888
- withoutSwiftDeclarations(
41889
- swiftHeaderWithSuperclassImports(generated, frameworkInterface),
41890
- /* @__PURE__ */ new Set([
41891
- ...preparation.nativeHeaderDeclarations[producer] ?? [],
41892
- ...nativelyDeclaredFunctions(generated, nativeHeaders)
41893
- ]),
41894
- `#import <${producer}/${producer}.h>`
41895
- )
41628
+ const frameworks = distribution ? await prepareFrameworks(null) : await withSwiftFrameworkSlot(
41629
+ frameworkKey,
41630
+ options2.release,
41631
+ moduleRoot,
41632
+ budget.signal,
41633
+ prepareFrameworks,
41634
+ unoptimized,
41635
+ options2.linkOnly === true
41896
41636
  );
41897
- };
41898
- const recipe2 = inputHash.copy().update(
41899
- distribution ? swiftCompileSurfaceDigest(frameworkRoot) : moduleDigest
41900
- ).update((0, import_node_fs55.readFileSync)(import_node_path56.default.join(root2, "Package.swift"))).update(JSON.stringify(buildArgs)).digest("hex");
41901
- const runApp = async (compiler2) => {
41902
- const optionsWithCompiler = compiler2 ? { ...appOptions, env: { ...appOptions.env, ...compiler2 } } : appOptions;
41903
- const stages = [
41904
- ...(preparation.nativePrerequisiteTargets ?? []).map((target) => ({
41905
- target,
41906
- producers: []
41907
- })),
41908
- ...preparation.headerBuilds,
41909
- ...(preparation.nativeProductTargets ?? []).map((target) => ({
41910
- target,
41911
- producers: []
41912
- }))
41913
- ];
41914
- const checkpoints = import_node_path56.default.join(root2, ".build", "peach-product-checkpoints");
41915
- const buildDbExists = (0, import_node_fs55.existsSync)(import_node_path56.default.join(root2, ".build", "build.db"));
41916
- const releaseDir = import_node_path56.default.dirname(linked);
41917
- for (const { target, producers } of stages) {
41918
- if (!options2.project && producers.length === 0 && buildDbExists) {
41919
- const expectedObjects = preparation.nativeStageObjects.get(target);
41920
- if (expectedObjects && expectedObjects.length > 0 && expectedObjects.every(
41921
- (relative4) => (0, import_node_fs55.statSync)(import_node_path56.default.join(releaseDir, relative4), {
41922
- throwIfNoEntry: false
41923
- })?.isFile()
41924
- ))
41925
- continue;
41926
- }
41927
- const receipt = import_node_path56.default.join(
41928
- checkpoints,
41929
- (0, import_node_crypto36.createHash)("sha256").update(target).digest("hex")
41637
+ if (!frameworks)
41638
+ throw new Error("Swift distribution did not provide its frameworks");
41639
+ const {
41640
+ frameworkRoot,
41641
+ compileFrameworkRoot,
41642
+ macroPlugins,
41643
+ compileSdk,
41644
+ icu,
41645
+ prebuilt
41646
+ } = frameworks;
41647
+ let readHold = frameworks.readHold;
41648
+ const buildOptions = {
41649
+ env: baseBuildEnv,
41650
+ maxBuffer: 64 * 1024 * 1024,
41651
+ signal: budget.signal,
41652
+ onOutput: budget.progress,
41653
+ lease
41654
+ };
41655
+ try {
41656
+ if (options2.project) removeProjectLinks(root2);
41657
+ const packageHostMacros = process.platform === "linux" ? input.packageHostMacros : void 0;
41658
+ if (retireStaleSwiftLink(
41659
+ root2,
41660
+ swiftLinkStamp({
41661
+ frameworkKey: mirrorDistribution ? `${options2.release}\0mirror` : `${options2.release}\0${Boolean(distribution)}\0${swiftModuleSdk(frameworkRoot).wasmSdkId}`,
41662
+ packageHostMacros
41663
+ }),
41664
+ swiftLinkStamp({
41665
+ // mirrored distributions and their WASI SDK mirror invalidate
41666
+ // dependents per changed file instead of wiping every Clang object.
41667
+ frameworkKey: mirrorDistribution ? `${options2.release}\0mirror` : distribution ? `${options2.release}\0${distribution.wasmSdkChecksum}` : frameworkKey,
41668
+ prebuilt,
41669
+ packageHostMacros
41670
+ }),
41671
+ Boolean(options2.linkOnly)
41672
+ ))
41673
+ stage("framework revision changed; rebuilding the app link");
41674
+ const nativeToolset = needsNativeToolset(input, prebuilt);
41675
+ const preparation = writeSwiftProject(
41676
+ layout3,
41677
+ input,
41678
+ frameworkRoot,
41679
+ prebuilt,
41680
+ !options2.project,
41681
+ options2.project ? false : options2.objcPrebuiltStage ?? (options2.intermediates ? false : void 0),
41682
+ compileSdk
41930
41683
  );
41931
- const headers = producers.map(headerPaths);
41932
- for (const header of headers)
41933
- if ((0, import_node_fs55.existsSync)(header.original)) publishHeader(header);
41934
- const fingerprint = () => {
41935
- const digest3 = (0, import_node_crypto36.createHash)("sha256").update(recipe2);
41936
- for (const { original, emitted } of headers) {
41937
- if (!(0, import_node_fs55.existsSync)(original) || !(0, import_node_fs55.existsSync)(emitted)) return;
41938
- digest3.update(
41939
- (0, import_node_crypto36.createHash)("sha256").update((0, import_node_fs55.readFileSync)(emitted)).digest()
41940
- );
41684
+ const productFile = import_node_path56.default.join(frameworkRoot, SWIFT_FRAMEWORK_PRODUCT_FILE);
41685
+ writeSwiftAutolinkLinker(
41686
+ root2,
41687
+ toolchainBin,
41688
+ (0, import_node_fs55.existsSync)(productFile) ? [
41689
+ v6.parse(
41690
+ swiftFrameworkProductSchema,
41691
+ JSON.parse((0, import_node_fs55.readFileSync)(productFile, "utf8"))
41692
+ ).product.name
41693
+ ] : []
41694
+ );
41695
+ const compiler = preparation.targetToolset ? { CC: import_node_path56.default.join(root2, CLANG_TARGET_MODULE_WRAPPER) } : {};
41696
+ if (packageHostMacros?.length) {
41697
+ const swiftc = import_node_path56.default.join(root2, SWIFT_HOST_COMPILER_WRAPPER);
41698
+ writeBuildFile(
41699
+ swiftc,
41700
+ [
41701
+ "#!/bin/sh",
41702
+ "target=",
41703
+ "module=",
41704
+ "compile=",
41705
+ "previous=",
41706
+ "for argument do",
41707
+ ' case "$previous" in -target) target=$argument ;; -module-name) module=$argument ;; esac',
41708
+ ' case "$argument" in -c|-emit-module|-scan-dependencies|-typecheck) compile=1 ;; esac',
41709
+ " previous=$argument",
41710
+ "done",
41711
+ 'case "$target/$compile" in',
41712
+ " *-*-linux*/1)",
41713
+ ' case ",$PEACH_SWIFT_HOST_MACROS," in',
41714
+ ' *",$module,"*) set -- "$@" -Xfrontend -import-module -Xfrontend Foundation ;;',
41715
+ " esac ;;",
41716
+ "esac",
41717
+ 'exec "$PEACH_SWIFTC" "$@"',
41718
+ ""
41719
+ ].join("\n")
41720
+ );
41721
+ (0, import_node_fs55.chmodSync)(swiftc, 493);
41722
+ compiler.SWIFT_EXEC = swiftc;
41723
+ compiler.PEACH_SWIFT_HOST_MACROS = packageHostMacros.join(",");
41724
+ compiler.PEACH_SWIFTC = import_node_path56.default.join(toolchainBin, "swiftc");
41725
+ }
41726
+ const projectProcess = options2.project ? prepareSwiftProjectProcess(root2, options2.project) : void 0;
41727
+ const temporaryDirectory = projectProcess ? void 0 : import_node_path56.default.join(root2, ".build", "peach-compiler-tmp");
41728
+ const appOptions = projectProcess ? {
41729
+ ...buildOptions,
41730
+ uid: projectProcess.uid,
41731
+ gid: projectProcess.gid,
41732
+ confined: { ...projectProcess.env, ...compiler }
41733
+ } : {
41734
+ ...buildOptions,
41735
+ temporaryDirectory,
41736
+ env: {
41737
+ ...buildOptions.env,
41738
+ ...preparation.usesObjcPrebuilt && process.env.PEACH_HOME !== void 0 ? { PEACH_HOME: process.env.PEACH_HOME } : {},
41739
+ ...compiler
41941
41740
  }
41942
- return digest3.digest("hex");
41943
41741
  };
41944
- if (!options2.project && (0, import_node_fs55.existsSync)(receipt) && (0, import_node_fs55.readFileSync)(receipt, "utf8") === fingerprint())
41945
- continue;
41946
- if (!options2.project) (0, import_node_fs55.rmSync)(receipt, { force: true });
41947
- for (const header of headers) {
41948
- if (!(0, import_node_fs55.existsSync)(header.original))
41949
- (0, import_node_fs55.rmSync)(
41950
- import_node_path56.default.join(
41951
- import_node_path56.default.dirname(linked),
41952
- "Modules",
41953
- `${swiftTargetModuleName(header.producer)}.swiftmodule`
41954
- ),
41955
- { force: true }
41956
- );
41742
+ const unprepared = preparation.targetFailures.map(
41743
+ (failure2) => `error: target ${failure2}`
41744
+ );
41745
+ const forwarders = /* @__PURE__ */ new Map();
41746
+ for (const [file, text7] of Object.entries(input.files)) {
41747
+ const parents = /^#include "((?:\.\.\/)+)[^"\n]+"\n$/.exec(text7)?.[1];
41748
+ if (!parents) continue;
41749
+ const directory2 = import_node_path56.default.posix.dirname(file);
41750
+ forwarders.set(
41751
+ `${import_node_path56.default.join(root2, directory2)}/${parents.slice(0, -1)}`,
41752
+ import_node_path56.default.posix.join("build", directory2, parents).replace(/\/$/, "")
41753
+ );
41957
41754
  }
41958
- await runCompiler(
41959
- swift,
41960
- [...buildArgs, "--target", target],
41961
- optionsWithCompiler,
41962
- /^(?:\[swift-prebuilt\]|\[\d+\/\d+\] )/,
41963
- SWIFTPM_NOISE
41755
+ const jobs = swiftCompilerJobs();
41756
+ const incrementalPreview = sdkImage !== void 0 && !guestGraph && !options2.project && !input.optimize && !input.unoptimized;
41757
+ const batchGuest = guestGraph !== void 0 && !options2.project && !input.unoptimized;
41758
+ const guestDriverJobs = Math.min(8, jobs);
41759
+ const singleProducerJobs = Math.min(16, Math.floor(jobs / 2));
41760
+ const batch = incrementalPreview || batchGuest;
41761
+ const perFile = input.unoptimized || batch;
41762
+ const reproducibleFrameworkRoot = mirrorDistribution ? frameworkRoot : compileFrameworkRoot;
41763
+ const buildArgs = [
41764
+ "build",
41765
+ ...projectProcess?.cacheOptions ?? swiftPackageCacheOptions(),
41766
+ "--build-system",
41767
+ "native",
41768
+ "-j",
41769
+ String(jobs),
41770
+ "--package-path",
41771
+ root2,
41772
+ ...compileSdk.options,
41773
+ ...swiftObjCSelectorOptions(frameworkRoot),
41774
+ "--swift-sdk",
41775
+ compileSdk.id,
41776
+ ...preparation.targetToolset ? ["--toolset", import_node_path56.default.join(root2, ".peach-target-toolset.json")] : [],
41777
+ "-c",
41778
+ "release",
41779
+ ...input.unoptimized ? ["-Xswiftc", "-Onone"] : [],
41780
+ ...perFile ? [
41781
+ "-Xswiftc",
41782
+ "-no-whole-module-optimization",
41783
+ "-Xswiftc",
41784
+ "-j",
41785
+ "-Xswiftc",
41786
+ String(batchGuest ? guestDriverJobs : jobs)
41787
+ ] : [],
41788
+ // optimized batches can move specialized definitions between objects.
41789
+ ...incrementalPreview ? ["-Xswiftc", "-incremental"] : [],
41790
+ ...batch ? ["-Xswiftc", "-enable-batch-mode"] : [],
41791
+ // the mirror finds a changed sdk header's readers in their
41792
+ // dependency files, which omit system headers by default
41793
+ ...mirrorDistribution ? ["-Xswiftc", "-track-system-dependencies"] : [],
41794
+ // the link strips debug info, so none is generated (as for the framework).
41795
+ // keep -num-threads fixed across caller core caps so llbuild does not
41796
+ // rebuild every target when callers alternate --cores, and bound backend
41797
+ // fan-out under high -j.
41798
+ "-Xswiftc",
41799
+ "-gnone",
41800
+ "-Xcc",
41801
+ "-g0",
41802
+ "-Xcxx",
41803
+ "-g0",
41804
+ ...batch ? [] : [
41805
+ "-Xswiftc",
41806
+ "-num-threads",
41807
+ "-Xswiftc",
41808
+ String(perFile ? 1 : Math.min(8, import_node_os16.default.availableParallelism()))
41809
+ ],
41810
+ ...swiftReproducibleBuildFlags([
41811
+ [import_node_path56.default.dirname(toolchainBin), "toolchain"],
41812
+ [reproducibleFrameworkRoot, "framework"],
41813
+ [root2, "build"],
41814
+ ...forwarders
41815
+ ]).flatMap((flag, index, flags) => {
41816
+ if (!nativeToolset || !flag.startsWith("-ffile-prefix-map="))
41817
+ return [flag];
41818
+ const toolchainDir = import_node_path56.default.dirname(toolchainBin);
41819
+ let mapped = flag;
41820
+ for (const [dir, target] of [
41821
+ [root2, "/peach/build"],
41822
+ [reproducibleFrameworkRoot, "/peach/framework"],
41823
+ [(0, import_node_fs55.realpathSync)(reproducibleFrameworkRoot), "/peach/framework"],
41824
+ [toolchainDir, "/peach/toolchain"],
41825
+ [(0, import_node_fs55.realpathSync)(toolchainDir), "/peach/toolchain"]
41826
+ ]) {
41827
+ mapped = mapped.replaceAll(dir, target);
41828
+ }
41829
+ const [, from, to] = /^-ffile-prefix-map=([^=]+)=(.+)$/.exec(mapped) ?? [];
41830
+ const tool = flags[index - 1];
41831
+ return mapped !== flag && from !== to ? [flag, tool, mapped] : [flag];
41832
+ }),
41833
+ ...macroPlugins.libraries.flatMap((plugin) => [
41834
+ "-Xswiftc",
41835
+ "-load-plugin-library",
41836
+ "-Xswiftc",
41837
+ plugin
41838
+ ]),
41839
+ ...macroPlugins.executables.flatMap((plugin) => [
41840
+ "-Xswiftc",
41841
+ "-load-plugin-executable",
41842
+ "-Xswiftc",
41843
+ `${plugin}#ExpoModulesMacros`
41844
+ ])
41845
+ ];
41846
+ const linked = builtArtifact(layout3);
41847
+ (0, import_node_fs55.rmSync)(import_node_path56.default.join(root2, ".peach-link.rsp"), { force: true });
41848
+ if (options2.linkOnly || (0, import_node_fs55.existsSync)(linked) && (0, import_node_fs55.statSync)(linked).size <= 8)
41849
+ (0, import_node_fs55.rmSync)(linked, { force: true });
41850
+ stage("compiling and linking Swift modules");
41851
+ const frameworkInterfaces = /* @__PURE__ */ new Map();
41852
+ const compileSdkPaths = swiftSdkPaths(
41853
+ frameworkRoot,
41854
+ toolchainBin,
41855
+ compileSdk.options,
41856
+ compileSdk.id
41857
+ );
41858
+ const sdkFrameworks = import_node_path56.default.join(
41859
+ compileSdkPaths.darwin,
41860
+ "System/Library/Frameworks"
41964
41861
  );
41965
- if (!compiler2) for (const header of headers) publishHeader(header);
41966
- if (!options2.project) {
41967
- const checkpoint = fingerprint();
41968
- if (checkpoint === void 0)
41969
- throw new Error(`missing Swift headers after building ${target}`);
41970
- (0, import_node_fs55.mkdirSync)(checkpoints, { recursive: true });
41971
- (0, import_node_fs55.writeFileSync)(`${receipt}.partial`, checkpoint);
41972
- (0, import_node_fs55.renameSync)(`${receipt}.partial`, receipt);
41862
+ const generatedInterface = (source) => withoutImportedSdkEnumForwards(
41863
+ clangInterfaceHeader((0, import_node_fs55.readFileSync)(source, "utf8"), frameworkRoot),
41864
+ sdkObjCDeclarationOwners(sdkFrameworks)
41865
+ );
41866
+ const nativeDeclarations = /* @__PURE__ */ new Map();
41867
+ const nativeHeaders = Object.entries(input.files).filter(([name3]) => name3.endsWith(".h") && !name3.endsWith("-Swift.h")).map(([, source]) => source);
41868
+ for (const [file, contents2] of Object.entries(input.files)) {
41869
+ if (!file.endsWith(".modulemap")) continue;
41870
+ const name3 = moduleMapName(contents2);
41871
+ const umbrella = /\bumbrella\s+header\s+"([^"]+)"/.exec(contents2)?.[1];
41872
+ if (!name3 || !umbrella) continue;
41873
+ const header = input.files[import_node_path56.default.posix.join(import_node_path56.default.posix.dirname(file), umbrella)];
41874
+ if (header === void 0) continue;
41875
+ const included = new Set(
41876
+ [
41877
+ ...header.matchAll(
41878
+ /^\s*#\s*(?:import|include)\s*[<"]([^">]+)[">]/gm
41879
+ )
41880
+ ].map((match) => import_node_path56.default.posix.basename(match[1]))
41881
+ );
41882
+ const declarations = nativeDeclarations.get(name3) ?? /* @__PURE__ */ new Set();
41883
+ for (const declaration of swiftInterfaceDeclarations(header))
41884
+ declarations.add(declaration);
41885
+ for (const [candidate, source] of Object.entries(input.files))
41886
+ if (included.has(import_node_path56.default.posix.basename(candidate)))
41887
+ for (const declaration of swiftInterfaceDeclarations(source))
41888
+ declarations.add(declaration);
41889
+ nativeDeclarations.set(name3, declarations);
41973
41890
  }
41974
- }
41975
- await runCompiler(
41976
- swift,
41977
- buildArgs,
41978
- optionsWithCompiler,
41979
- SWIFTPM_PROGRESS,
41980
- SWIFTPM_NOISE
41981
- );
41982
- };
41983
- const compileApp = () => preparation.headerCompiler ? withSwiftHeaderCompiler(
41984
- root2,
41985
- options2.toolchainBin,
41986
- recipe2,
41987
- new Map(
41988
- preparation.headerBuilds.flatMap(({ producers }) => {
41989
- const driverJobs = batchGuest && producers.length === 1 && singleProducerJobs > guestDriverJobs ? singleProducerJobs : void 0;
41990
- return producers.map((producer) => {
41991
- const paths = headerPaths(producer);
41992
- return [
41993
- swiftTargetModuleName(producer),
41994
- {
41995
- header: paths.original,
41996
- publish: () => publishHeader(paths),
41997
- jobs: driverJobs
41891
+ const frameworkInterface = (name3) => {
41892
+ if (frameworkInterfaces.has(name3)) return frameworkInterfaces.get(name3);
41893
+ const source = distribution ? import_node_path56.default.join(frameworkRoot, "modules", `${name3}-Swift.h`) : prebuilt.objcHeaders.get(name3);
41894
+ if (!source || !(0, import_node_fs55.existsSync)(source)) {
41895
+ frameworkInterfaces.set(name3, null);
41896
+ return null;
41897
+ }
41898
+ const headers = import_node_path56.default.join(sdkFrameworks, `${name3}.framework/Headers`);
41899
+ const declared = /* @__PURE__ */ new Set();
41900
+ if ((0, import_node_fs55.existsSync)(headers)) {
41901
+ for (const file of (0, import_node_fs55.readdirSync)(headers, {
41902
+ recursive: true,
41903
+ encoding: "utf8"
41904
+ }))
41905
+ if (file.endsWith(".h"))
41906
+ for (const name4 of swiftInterfaceDeclarations(
41907
+ (0, import_node_fs55.readFileSync)(import_node_path56.default.join(headers, file), "utf8")
41908
+ ))
41909
+ declared.add(name4);
41910
+ }
41911
+ for (const declaration of nativeDeclarations.get(name3) ?? [])
41912
+ declared.add(declaration);
41913
+ const own2 = withoutSwiftDeclarations(
41914
+ generatedInterface(source),
41915
+ declared,
41916
+ nativeDeclarations.has(name3) ? `@import ${name3};` : `#import <${name3}/${name3}.h>`
41917
+ );
41918
+ const owners = sdkObjCDeclarationOwners(sdkFrameworks);
41919
+ const foreign = /* @__PURE__ */ new Map();
41920
+ for (const declaration of [
41921
+ ...swiftInterfaceDeclarations(own2),
41922
+ ...objcEnumerations(own2),
41923
+ ...[...own2.matchAll(/^\s*SWIFT_EXTERN\b[^(\n]*?\b(\w+)\s*\(/gm)].map(
41924
+ (match) => match[1]
41925
+ )
41926
+ ]) {
41927
+ const owner = owners.get(declaration);
41928
+ if (owner && owner !== name3) foreign.set(declaration, owner);
41929
+ }
41930
+ const header = foreign.size ? withoutSwiftDeclarations(
41931
+ own2,
41932
+ new Set(foreign.keys()),
41933
+ [...new Set(foreign.values())].map((owner) => `#import <${owner}/${owner}.h>`).join("\n")
41934
+ ) : own2;
41935
+ const value = {
41936
+ file: import_node_path56.default.join(
41937
+ root2,
41938
+ ".build/peach-framework-objc",
41939
+ `${name3}-Swift.h`
41940
+ ),
41941
+ header,
41942
+ module: (0, import_node_fs55.existsSync)(headers)
41943
+ };
41944
+ frameworkInterfaces.set(name3, value);
41945
+ writeBuildFile(
41946
+ value.file,
41947
+ ((0, import_node_fs55.existsSync)(import_node_path56.default.join(headers, `${name3}.h`)) ? `#import <${name3}/${name3}.h>
41948
+ ` : "") + swiftHeaderWithSuperclassImports(header, frameworkInterface)
41949
+ );
41950
+ return value;
41951
+ };
41952
+ const headerPaths = (producer) => {
41953
+ const stem2 = import_node_path56.default.join(
41954
+ root2,
41955
+ ".build",
41956
+ "peach-cxx-headers",
41957
+ `${producer}-Swift`
41958
+ );
41959
+ return {
41960
+ producer,
41961
+ original: `${stem2}.original.h`,
41962
+ emitted: `${stem2}.h`
41963
+ };
41964
+ };
41965
+ const publishHeader = ({
41966
+ producer,
41967
+ original,
41968
+ emitted
41969
+ }) => {
41970
+ const generated = generatedInterface(original);
41971
+ writeBuildFile(
41972
+ emitted,
41973
+ withoutSwiftDeclarations(
41974
+ swiftHeaderWithSuperclassImports(generated, frameworkInterface),
41975
+ /* @__PURE__ */ new Set([
41976
+ ...preparation.nativeHeaderDeclarations[producer] ?? [],
41977
+ ...nativelyDeclaredFunctions(generated, nativeHeaders)
41978
+ ]),
41979
+ `#import <${producer}/${producer}.h>`
41980
+ )
41981
+ );
41982
+ };
41983
+ const recipe2 = inputHash.copy().update(
41984
+ distribution ? swiftCompileSurfaceDigest(frameworkRoot) : moduleDigest
41985
+ ).update((0, import_node_fs55.readFileSync)(import_node_path56.default.join(root2, "Package.swift"))).update(JSON.stringify(buildArgs)).digest("hex");
41986
+ const runApp = async (compiler2) => {
41987
+ const optionsWithCompiler = compiler2 ? { ...appOptions, env: { ...appOptions.env, ...compiler2 } } : appOptions;
41988
+ const stages = [
41989
+ ...(preparation.nativePrerequisiteTargets ?? []).map((target) => ({
41990
+ target,
41991
+ producers: []
41992
+ })),
41993
+ ...preparation.headerBuilds,
41994
+ ...(preparation.nativeProductTargets ?? []).map((target) => ({
41995
+ target,
41996
+ producers: []
41997
+ }))
41998
+ ];
41999
+ const checkpoints = import_node_path56.default.join(
42000
+ root2,
42001
+ ".build",
42002
+ "peach-product-checkpoints"
42003
+ );
42004
+ const buildDbExists = (0, import_node_fs55.existsSync)(import_node_path56.default.join(root2, ".build", "build.db"));
42005
+ const releaseDir = import_node_path56.default.dirname(linked);
42006
+ for (const { target, producers } of stages) {
42007
+ if (!options2.project && producers.length === 0 && buildDbExists) {
42008
+ const expectedObjects = preparation.nativeStageObjects.get(target);
42009
+ if (expectedObjects && expectedObjects.length > 0 && expectedObjects.every(
42010
+ (relative4) => (0, import_node_fs55.statSync)(import_node_path56.default.join(releaseDir, relative4), {
42011
+ throwIfNoEntry: false
42012
+ })?.isFile()
42013
+ ))
42014
+ continue;
42015
+ }
42016
+ const receipt = import_node_path56.default.join(
42017
+ checkpoints,
42018
+ (0, import_node_crypto36.createHash)("sha256").update(target).digest("hex")
42019
+ );
42020
+ const headers = producers.map(headerPaths);
42021
+ for (const header of headers)
42022
+ if ((0, import_node_fs55.existsSync)(header.original)) publishHeader(header);
42023
+ const fingerprint = () => {
42024
+ const digest3 = (0, import_node_crypto36.createHash)("sha256").update(recipe2);
42025
+ for (const { original, emitted } of headers) {
42026
+ if (!(0, import_node_fs55.existsSync)(original) || !(0, import_node_fs55.existsSync)(emitted)) return;
42027
+ digest3.update(
42028
+ (0, import_node_crypto36.createHash)("sha256").update((0, import_node_fs55.readFileSync)(emitted)).digest()
42029
+ );
41998
42030
  }
41999
- ];
42000
- });
42001
- })
42002
- ),
42003
- runApp
42004
- ) : runApp();
42005
- try {
42006
- if (temporaryDirectory) (0, import_node_fs55.mkdirSync)(temporaryDirectory, { recursive: true });
42007
- await compileApp();
42008
- } catch (error) {
42009
- const output2 = outputOf(error);
42010
- const moduleCache = import_node_path56.default.join(
42011
- root2,
42012
- ".build",
42013
- WASM_TRIPLE,
42014
- "release",
42015
- "ModuleCache"
42016
- );
42017
- if (output2.includes("was compiled with module cache path") && (0, import_node_fs55.existsSync)(moduleCache)) {
42018
- (0, import_node_fs55.rmSync)(moduleCache, { recursive: true, force: true });
42031
+ return digest3.digest("hex");
42032
+ };
42033
+ if (!options2.project && (0, import_node_fs55.existsSync)(receipt) && (0, import_node_fs55.readFileSync)(receipt, "utf8") === fingerprint())
42034
+ continue;
42035
+ if (!options2.project) (0, import_node_fs55.rmSync)(receipt, { force: true });
42036
+ for (const header of headers) {
42037
+ if (!(0, import_node_fs55.existsSync)(header.original))
42038
+ (0, import_node_fs55.rmSync)(
42039
+ import_node_path56.default.join(
42040
+ import_node_path56.default.dirname(linked),
42041
+ "Modules",
42042
+ `${swiftTargetModuleName(header.producer)}.swiftmodule`
42043
+ ),
42044
+ { force: true }
42045
+ );
42046
+ }
42047
+ await runCompiler(
42048
+ swift,
42049
+ [...buildArgs, "--target", target],
42050
+ optionsWithCompiler,
42051
+ /^(?:\[swift-prebuilt\]|\[\d+\/\d+\] )/,
42052
+ SWIFTPM_NOISE
42053
+ );
42054
+ if (!compiler2) for (const header of headers) publishHeader(header);
42055
+ if (!options2.project) {
42056
+ const checkpoint = fingerprint();
42057
+ if (checkpoint === void 0)
42058
+ throw new Error(`missing Swift headers after building ${target}`);
42059
+ (0, import_node_fs55.mkdirSync)(checkpoints, { recursive: true });
42060
+ (0, import_node_fs55.writeFileSync)(`${receipt}.partial`, checkpoint);
42061
+ (0, import_node_fs55.renameSync)(`${receipt}.partial`, receipt);
42062
+ }
42063
+ }
42064
+ await runCompiler(
42065
+ swift,
42066
+ buildArgs,
42067
+ optionsWithCompiler,
42068
+ SWIFTPM_PROGRESS,
42069
+ SWIFTPM_NOISE
42070
+ );
42071
+ };
42072
+ const compileApp = () => preparation.headerCompiler ? withSwiftHeaderCompiler(
42073
+ root2,
42074
+ toolchainBin,
42075
+ recipe2,
42076
+ new Map(
42077
+ preparation.headerBuilds.flatMap(({ producers }) => {
42078
+ const driverJobs = batchGuest && producers.length === 1 && singleProducerJobs > guestDriverJobs ? singleProducerJobs : void 0;
42079
+ return producers.map((producer) => {
42080
+ const paths = headerPaths(producer);
42081
+ return [
42082
+ swiftTargetModuleName(producer),
42083
+ {
42084
+ header: paths.original,
42085
+ publish: () => publishHeader(paths),
42086
+ jobs: driverJobs
42087
+ }
42088
+ ];
42089
+ });
42090
+ })
42091
+ ),
42092
+ runApp
42093
+ ) : runApp();
42019
42094
  try {
42095
+ if (temporaryDirectory)
42096
+ (0, import_node_fs55.mkdirSync)(temporaryDirectory, { recursive: true });
42020
42097
  await compileApp();
42021
- } catch (retryError) {
42098
+ } catch (error) {
42099
+ const output2 = outputOf(error);
42100
+ const moduleCache = import_node_path56.default.join(
42101
+ root2,
42102
+ ".build",
42103
+ WASM_TRIPLE,
42104
+ "release",
42105
+ "ModuleCache"
42106
+ );
42107
+ if (output2.includes("was compiled with module cache path") && (0, import_node_fs55.existsSync)(moduleCache)) {
42108
+ (0, import_node_fs55.rmSync)(moduleCache, { recursive: true, force: true });
42109
+ try {
42110
+ await compileApp();
42111
+ } catch (retryError) {
42112
+ throw new Error(
42113
+ [
42114
+ ...unprepared,
42115
+ projectDiagnostic(outputOf(retryError), layout3, input.files)
42116
+ ].join("\n"),
42117
+ { cause: retryError }
42118
+ );
42119
+ }
42120
+ } else {
42121
+ throw new Error(
42122
+ [
42123
+ ...unprepared,
42124
+ projectDiagnostic(output2, layout3, input.files)
42125
+ ].join("\n"),
42126
+ { cause: error }
42127
+ );
42128
+ }
42129
+ } finally {
42130
+ if (temporaryDirectory)
42131
+ (0, import_node_fs55.rmSync)(temporaryDirectory, { recursive: true, force: true });
42132
+ if (options2.project) endSwiftProjectProcesses(options2.project);
42133
+ }
42134
+ if (unprepared.length) throw new Error(unprepared.join("\n"));
42135
+ if (!(0, import_node_fs55.existsSync)(linked)) {
42136
+ const binDir = import_node_path56.default.dirname(linked);
42137
+ const found = (0, import_node_fs55.existsSync)(binDir) ? (0, import_node_fs55.readdirSync)(binDir).filter((name3) => name3.endsWith(".wasm")).sort() : [];
42022
42138
  throw new Error(
42023
- [
42024
- ...unprepared,
42025
- projectDiagnostic(outputOf(retryError), layout3, input.files)
42026
- ].join("\n"),
42027
- { cause: retryError }
42139
+ `swift-compile: the build produced no ${import_node_path56.default.basename(linked)} (found: ${found.join(", ") || "none"})`
42028
42140
  );
42029
42141
  }
42030
- } else {
42031
- throw new Error(
42032
- [...unprepared, projectDiagnostic(output2, layout3, input.files)].join(
42033
- "\n"
42034
- ),
42035
- { cause: error }
42142
+ if (options2.project) removeProjectLinks(root2);
42143
+ const resourceReferences = Object.values(input.resources ?? {}).map(
42144
+ (value) => Buffer.from(value, "base64")
42036
42145
  );
42037
- }
42038
- } finally {
42039
- if (temporaryDirectory)
42040
- (0, import_node_fs55.rmSync)(temporaryDirectory, { recursive: true, force: true });
42041
- if (options2.project) endSwiftProjectProcesses(options2.project);
42042
- }
42043
- if (unprepared.length) throw new Error(unprepared.join("\n"));
42044
- if (!(0, import_node_fs55.existsSync)(linked)) {
42045
- const binDir = import_node_path56.default.dirname(linked);
42046
- const found = (0, import_node_fs55.existsSync)(binDir) ? (0, import_node_fs55.readdirSync)(binDir).filter((name3) => name3.endsWith(".wasm")).sort() : [];
42047
- throw new Error(
42048
- `swift-compile: the build produced no ${import_node_path56.default.basename(linked)} (found: ${found.join(", ") || "none"})`
42049
- );
42050
- }
42051
- if (options2.project) removeProjectLinks(root2);
42052
- const resourceReferences = Object.values(input.resources ?? {}).map(
42053
- (value) => Buffer.from(value, "base64")
42054
- );
42055
- if (!guestGraph)
42056
- pruneSwiftWasmLink(
42057
- root2,
42058
- options2.toolchainBin,
42059
- prebuilt?.root ?? frameworkRoot,
42060
- input.staticClangTargets,
42061
- options2.project,
42062
- void 0,
42063
- resourceReferences
42064
- );
42065
- if (options2.linkOnly) {
42066
- if ((0, import_node_fs55.statSync)(linked).size <= 8)
42067
- throw new Error("swift-compile: deferred linker produced no executable");
42068
- stage("project link verified");
42069
- if (readHold && retainSwiftRootReadHold(readHold)) readHold = void 0;
42070
- return;
42071
- }
42072
- const output = options2.project ? projectOutputFile(root2, linked, options2.project) : linked;
42073
- const optimized = `${output}.optimized`;
42074
- if (!sdkImage) throw new Error("swift-compile: missing shared SDK image");
42075
- if (options2.project) (0, import_node_fs55.rmSync)(optimized, { force: true });
42076
- let sdkAsset;
42077
- stage("linking the app image");
42078
- if (guestGraph) {
42079
- const binding = await compileGuestLink({
42080
- graph: guestGraph,
42081
- buildDirectory: root2,
42082
- releaseDirectory: import_node_path56.default.dirname(linked),
42083
- moduleRoot: frameworkRoot,
42084
- toolchainBin: options2.toolchainBin,
42085
- swiftCompiler: preparation.headerCompiler ? import_node_path56.default.join(root2, SWIFT_HEADER_COMPILER_WRAPPER) : compiler.SWIFT_EXEC ?? import_node_path56.default.join(options2.toolchainBin, "swiftc"),
42086
- sysroot: compileSdkPaths.sysroot,
42087
- sdk: swiftModuleSdk(frameworkRoot),
42088
- sdkImage,
42089
- compilerDigest: compilerSourceDigest,
42090
- project: options2.project && {
42091
- ...options2.project,
42092
- env: { ...options2.project.env, ...projectProcess?.env }
42093
- },
42094
- staticClangTargets: input.staticClangTargets ?? [],
42095
- resourceReferences,
42096
- resourceBundles: input.resourceBundles ?? [],
42097
- generatedOwners: preparation.generatedOwners,
42098
- output,
42099
- optimized,
42100
- optimize: input.optimize === true,
42101
- jobs: swiftBuildJobs(),
42102
- onStage: stage
42103
- });
42104
- sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
42105
- } else {
42106
- const { buildSwiftAppModule: buildSwiftAppModule2 } = await Promise.resolve().then(() => (init_swift_sdk_app_module(), swift_sdk_app_module_exports));
42107
- const binding = await buildSwiftAppModule2({
42108
- buildRoot: root2,
42109
- toolchainBin: options2.toolchainBin,
42110
- sdk: sdkImage,
42111
- output: optimized,
42112
- optimize: input.optimize === true,
42113
- project: options2.project && {
42114
- ...options2.project,
42115
- env: { ...options2.project.env, ...projectProcess?.env },
42116
- sdkRoot: import_node_path56.default.dirname(compileSdkPaths.sysroot),
42117
- linked: output
42146
+ if (!guestGraph)
42147
+ pruneSwiftWasmLink(
42148
+ root2,
42149
+ toolchainBin,
42150
+ prebuilt?.root ?? frameworkRoot,
42151
+ input.staticClangTargets,
42152
+ options2.project,
42153
+ void 0,
42154
+ resourceReferences
42155
+ );
42156
+ if (options2.linkOnly) {
42157
+ if ((0, import_node_fs55.statSync)(linked).size <= 8)
42158
+ throw new Error(
42159
+ "swift-compile: deferred linker produced no executable"
42160
+ );
42161
+ stage("project link verified");
42162
+ if (readHold && retainSwiftRootReadHold(readHold)) readHold = void 0;
42163
+ return;
42118
42164
  }
42119
- });
42120
- sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
42121
- }
42122
- const artifact = {
42123
- hash,
42124
- bytes: (0, import_node_fs55.readFileSync)(optimized),
42125
- icu: await icu,
42126
- sdk: sdkAsset
42127
- };
42128
- if (artifact.bytes.length <= 8)
42129
- throw new Error("swift-compile: deferred linker produced no executable");
42130
- if (!options2.project) saveCompiledArtifact(root2, artifact);
42131
- saveSharedArtifact(sharedRoot, artifact);
42132
- stage("compiled artifact verified");
42133
- return retain(baseRoot, artifact);
42134
- } finally {
42135
- readHold?.release();
42165
+ const output = options2.project ? projectOutputFile(root2, linked, options2.project) : linked;
42166
+ const optimized = `${output}.optimized`;
42167
+ if (!sdkImage) throw new Error("swift-compile: missing shared SDK image");
42168
+ if (options2.project) (0, import_node_fs55.rmSync)(optimized, { force: true });
42169
+ let sdkAsset;
42170
+ stage("linking the app image");
42171
+ if (guestGraph) {
42172
+ const binding = await compileGuestLink({
42173
+ graph: guestGraph,
42174
+ buildDirectory: root2,
42175
+ releaseDirectory: import_node_path56.default.dirname(linked),
42176
+ moduleRoot: frameworkRoot,
42177
+ toolchainBin,
42178
+ swiftCompiler: preparation.headerCompiler ? import_node_path56.default.join(root2, SWIFT_HEADER_COMPILER_WRAPPER) : compiler.SWIFT_EXEC ?? import_node_path56.default.join(toolchainBin, "swiftc"),
42179
+ sysroot: compileSdkPaths.sysroot,
42180
+ sdk: swiftModuleSdk(frameworkRoot),
42181
+ sdkImage,
42182
+ compilerDigest: compilerSourceDigest,
42183
+ project: options2.project && {
42184
+ ...options2.project,
42185
+ env: { ...options2.project.env, ...projectProcess?.env }
42186
+ },
42187
+ staticClangTargets: input.staticClangTargets ?? [],
42188
+ resourceReferences,
42189
+ resourceBundles: input.resourceBundles ?? [],
42190
+ generatedOwners: preparation.generatedOwners,
42191
+ output,
42192
+ optimized,
42193
+ optimize: input.optimize === true,
42194
+ jobs: swiftBuildJobs(),
42195
+ onStage: stage
42196
+ });
42197
+ sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
42198
+ } else {
42199
+ const { buildSwiftAppModule: buildSwiftAppModule2 } = await Promise.resolve().then(() => (init_swift_sdk_app_module(), swift_sdk_app_module_exports));
42200
+ const binding = await buildSwiftAppModule2({
42201
+ buildRoot: root2,
42202
+ toolchainBin,
42203
+ sdk: sdkImage,
42204
+ output: optimized,
42205
+ optimize: input.optimize === true,
42206
+ project: options2.project && {
42207
+ ...options2.project,
42208
+ env: { ...options2.project.env, ...projectProcess?.env },
42209
+ sdkRoot: import_node_path56.default.dirname(compileSdkPaths.sysroot),
42210
+ linked: output
42211
+ }
42212
+ });
42213
+ sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
42214
+ }
42215
+ const artifact = {
42216
+ hash,
42217
+ bytes: (0, import_node_fs55.readFileSync)(optimized),
42218
+ icu: await icu,
42219
+ sdk: sdkAsset
42220
+ };
42221
+ if (artifact.bytes.length <= 8)
42222
+ throw new Error("swift-compile: deferred linker produced no executable");
42223
+ if (!options2.project) saveCompiledArtifact(root2, artifact);
42224
+ saveSharedArtifact(sharedRoot, artifact);
42225
+ stage("compiled artifact verified");
42226
+ return retain(baseRoot, artifact);
42227
+ } finally {
42228
+ readHold?.release();
42229
+ }
42230
+ });
42136
42231
  }
42137
- });
42138
- });
42139
- },
42140
- options2.signal
42141
- );
42232
+ );
42233
+ },
42234
+ options2.signal
42235
+ );
42236
+ });
42142
42237
  }
42143
- var import_node_child_process35, import_node_crypto36, import_node_fs55, import_node_os15, import_node_path56, import_promises7, v6, WASM_TRIPLE, SWIFTPM_PROGRESS, SWIFTPM_NOISE, SWIFT_COMPILER_ENV_KEYS, SYSTEM_MODULE_LIBRARIES, SYSTEM_MODULE_IMPORT, lastPartition, OPTIONAL_FRAMEWORK_DEPENDENCIES, OPTIONAL_FRAMEWORKS, availableModules, sdkOverlayFrameworks, DISTRIBUTION_CLANG_MODULES, CLANG_DISTRIBUTION_MODULES, ONE_PRODUCT, GAME_FAMILY, gameProducts, gameProduct, GAME_REACH, 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, CORE_FOUNDATION_GEOMETRY_TYPES, CORE_FOUNDATION_GRAPHICS_TYPES, CORE_FOUNDATION_HANDLE_IMPORTS, 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, SWIFT_FRAMEWORK_SLOT_RELEASE, SWIFT_FRAMEWORK_SLOT_HANDOFF, SWIFT_BUILD_ROOT_SLOTS, SWIFT_BUILD_ROOT_SHAPE, SWIFT_FRAMEWORK_HANDOFF_MS;
42238
+ var import_node_child_process35, import_node_crypto36, import_node_fs55, import_node_os16, import_node_path56, import_promises7, v6, WASM_TRIPLE, SWIFTPM_PROGRESS, SWIFTPM_NOISE, SWIFT_COMPILER_ENV_KEYS, SYSTEM_MODULE_LIBRARIES, SYSTEM_MODULE_IMPORT, lastPartition, OPTIONAL_FRAMEWORK_DEPENDENCIES, OPTIONAL_FRAMEWORKS, availableModules, sdkOverlayFrameworks, DISTRIBUTION_CLANG_MODULES, CLANG_DISTRIBUTION_MODULES, ONE_PRODUCT, GAME_FAMILY, gameProducts, gameProduct, GAME_REACH, 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, CORE_FOUNDATION_GEOMETRY_TYPES, CORE_FOUNDATION_GRAPHICS_TYPES, CORE_FOUNDATION_HANDLE_IMPORTS, 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, SWIFT_FRAMEWORK_SLOT_RELEASE, SWIFT_FRAMEWORK_SLOT_HANDOFF, SWIFT_BUILD_ROOT_SLOTS, SWIFT_BUILD_ROOT_SHAPE, SWIFT_FRAMEWORK_HANDOFF_MS;
42144
42239
  var init_swift_compile = __esm({
42145
42240
  "src/swift-compile.ts"() {
42146
42241
  "use strict";
42147
42242
  import_node_child_process35 = require("node:child_process");
42148
42243
  import_node_crypto36 = require("node:crypto");
42149
42244
  import_node_fs55 = require("node:fs");
42150
- import_node_os15 = __toESM(require("node:os"), 1);
42245
+ import_node_os16 = __toESM(require("node:os"), 1);
42151
42246
  import_node_path56 = __toESM(require("node:path"), 1);
42152
42247
  import_promises7 = require("node:timers/promises");
42153
42248
  v6 = __toESM(require("peachsim/vendor/valibot"), 1);
@@ -42374,7 +42469,7 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
42374
42469
  REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
42375
42470
  MULTI_MANIFEST_VERSION = 76;
42376
42471
  SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
42377
- compilerSourceDigest = true ? "f7ecc0786fdd1632d1059f2c6c56bd5083a84c871afe2865af4bf2cf65ee6502" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
42472
+ compilerSourceDigest = true ? "0c6bac10641208c362185255fa7a630f4699656735409862a61a2e125ad2e84b" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
42378
42473
  nativeCxxCompilerFlags = ["-fno-cxx-modules"];
42379
42474
  MODULE_MAP_RESPONSE_FILE_RUN = 16;
42380
42475
  cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
@@ -42876,7 +42971,7 @@ async function downloadFile(pod, url, headers, file, algorithm) {
42876
42971
  return hash ? hash.digest("hex") : null;
42877
42972
  }
42878
42973
  function netrcCredentials(host2) {
42879
- const file = import_node_path58.default.join(import_node_os16.default.homedir(), ".netrc");
42974
+ const file = import_node_path58.default.join(import_node_os17.default.homedir(), ".netrc");
42880
42975
  if (!import_node_fs57.default.existsSync(file)) return null;
42881
42976
  const tokens2 = import_node_fs57.default.readFileSync(file, "utf8").split(/\s+/).filter(Boolean);
42882
42977
  let current2 = null;
@@ -43119,14 +43214,14 @@ function cleanInstalledPod(spec, root, used) {
43119
43214
  (node) => used.filter((entry) => entry.specs.includes(node.name)).map((entry) => entry.platform)
43120
43215
  );
43121
43216
  }
43122
- var import_node_child_process36, import_node_crypto38, import_node_fs57, import_node_os16, import_node_path58, COCOAPODS_VERSION, USER_AGENT, PLATFORMS, HEADER_EXTENSIONS, SOURCE_EXTENSIONS, SOURCE_FILES_PATTERN, STRATEGIES, OPTIONS, ARCHIVE_TYPES, object4, RETRY_STATUSES, chomp, stringList, bracketEnd, escapeRegex;
43217
+ var import_node_child_process36, import_node_crypto38, import_node_fs57, import_node_os17, import_node_path58, COCOAPODS_VERSION, USER_AGENT, PLATFORMS, HEADER_EXTENSIONS, SOURCE_EXTENSIONS, SOURCE_FILES_PATTERN, STRATEGIES, OPTIONS, ARCHIVE_TYPES, object4, RETRY_STATUSES, chomp, stringList, bracketEnd, escapeRegex;
43123
43218
  var init_pod_sources = __esm({
43124
43219
  "src/pod-sources.ts"() {
43125
43220
  "use strict";
43126
43221
  import_node_child_process36 = require("node:child_process");
43127
43222
  import_node_crypto38 = require("node:crypto");
43128
43223
  import_node_fs57 = __toESM(require("node:fs"), 1);
43129
- import_node_os16 = __toESM(require("node:os"), 1);
43224
+ import_node_os17 = __toESM(require("node:os"), 1);
43130
43225
  import_node_path58 = __toESM(require("node:path"), 1);
43131
43226
  init_home_paths();
43132
43227
  init_pod_prepare_toolchain();
@@ -55348,7 +55443,7 @@ function text4(interp, value) {
55348
55443
  );
55349
55444
  }
55350
55445
  function expandHome(p) {
55351
- return p === "~" || p.startsWith("~/") ? import_node_path61.default.join(import_node_os17.default.homedir(), p.slice(1)) : p;
55446
+ return p === "~" || p.startsWith("~/") ? import_node_path61.default.join(import_node_os18.default.homedir(), p.slice(1)) : p;
55352
55447
  }
55353
55448
  function joinPaths(parts) {
55354
55449
  let out = "";
@@ -55899,12 +55994,12 @@ function installStdlib(interp) {
55899
55994
  const dir = interp.defineModule("Dir", object8, true);
55900
55995
  def(dir, "pwd", () => str2(host2.cwd));
55901
55996
  def(dir, "getwd", () => str2(host2.cwd));
55902
- def(dir, "home", () => str2(import_node_os17.default.homedir()));
55997
+ def(dir, "home", () => str2(import_node_os18.default.homedir()));
55903
55998
  def(dir, "exist?", (c) => isDirectory(resolve4(text4(interp, c.args[0]))));
55904
55999
  def(dir, "exists?", (c) => isDirectory(resolve4(text4(interp, c.args[0]))));
55905
56000
  def(dir, "chdir", (c) => {
55906
56001
  const previous = host2.cwd;
55907
- host2.cwd = c.args[0] === void 0 ? import_node_os17.default.homedir() : resolve4(text4(interp, c.args[0]));
56002
+ host2.cwd = c.args[0] === void 0 ? import_node_os18.default.homedir() : resolve4(text4(interp, c.args[0]));
55908
56003
  if (!c.block) return 0;
55909
56004
  try {
55910
56005
  return interp.callProc(c.block, [str2(host2.cwd)]);
@@ -56485,7 +56580,7 @@ function installStdlib(interp) {
56485
56580
  (c) => c.self instanceof RObject && typeof c.self.data === "number" ? c.self.data : 0
56486
56581
  );
56487
56582
  const etc = interp.defineModule("Etc", object8);
56488
- def(etc, "nprocessors", () => import_node_os17.default.cpus().length);
56583
+ def(etc, "nprocessors", () => import_node_os18.default.cpus().length);
56489
56584
  const rbConfig = interp.defineModule("RbConfig", object8);
56490
56585
  rbConfig.consts.set(
56491
56586
  "CONFIG",
@@ -56585,14 +56680,14 @@ function fnmatch(pattern, subject, flags) {
56585
56680
  return !leadingDot && new RegExp(`^${source}$`, casefold ? "is" : "s").test(subject);
56586
56681
  });
56587
56682
  }
56588
- var import_node_child_process39, import_node_crypto42, import_node_fs62, import_node_os17, import_node_path61, segment, FileHandle, WriteHandle, DownloadHandle, GemRequirement, TimeValue, SetData;
56683
+ var import_node_child_process39, import_node_crypto42, import_node_fs62, import_node_os18, import_node_path61, segment, FileHandle, WriteHandle, DownloadHandle, GemRequirement, TimeValue, SetData;
56589
56684
  var init_podspec_ruby_stdlib = __esm({
56590
56685
  "src/podspec-ruby-stdlib.ts"() {
56591
56686
  "use strict";
56592
56687
  import_node_child_process39 = require("node:child_process");
56593
56688
  import_node_crypto42 = require("node:crypto");
56594
56689
  import_node_fs62 = __toESM(require("node:fs"), 1);
56595
- import_node_os17 = __toESM(require("node:os"), 1);
56690
+ import_node_os18 = __toESM(require("node:os"), 1);
56596
56691
  import_node_path61 = __toESM(require("node:path"), 1);
56597
56692
  init_podspec_ruby();
56598
56693
  segment = (s) => typeof s === "number" ? s : str2(s);
@@ -56743,7 +56838,7 @@ function cocoapodsInterpreter(app, writable, env) {
56743
56838
  loaded: /* @__PURE__ */ new Set(),
56744
56839
  // cocoapods and the podspecs it evaluates keep caches shared across
56745
56840
  // projects in the user's caches directory, as sentry's xcframework does
56746
- writable: [...writable, import_node_path62.default.join(import_node_os18.default.homedir(), "Library", "Caches")]
56841
+ writable: [...writable, import_node_path62.default.join(import_node_os19.default.homedir(), "Library", "Caches")]
56747
56842
  });
56748
56843
  installStdlib(interp);
56749
56844
  interp.evalString(PRELUDE, "cocoapods-core");
@@ -56870,14 +56965,14 @@ function evaluatePodspec(file, app, writable, env, installed) {
56870
56965
  return toJson(interp, call(pod, "peach_evaluated", [spec]));
56871
56966
  });
56872
56967
  }
56873
- var import_node_child_process40, import_node_fs63, import_node_module4, import_node_os18, import_node_path62, PRELUDE, PodspecEvaluationError, HOST_PROBES, hostProbe, SOURCE_BUILD_ENV, XCODE_TOOLCHAIN_BIN, XCODE_TOOLCHAIN_TOOLS;
56968
+ var import_node_child_process40, import_node_fs63, import_node_module4, import_node_os19, import_node_path62, PRELUDE, PodspecEvaluationError, HOST_PROBES, hostProbe, SOURCE_BUILD_ENV, XCODE_TOOLCHAIN_BIN, XCODE_TOOLCHAIN_TOOLS;
56874
56969
  var init_podspec_cocoapods = __esm({
56875
56970
  "src/podspec-cocoapods.ts"() {
56876
56971
  "use strict";
56877
56972
  import_node_child_process40 = require("node:child_process");
56878
56973
  import_node_fs63 = __toESM(require("node:fs"), 1);
56879
56974
  import_node_module4 = require("node:module");
56880
- import_node_os18 = __toESM(require("node:os"), 1);
56975
+ import_node_os19 = __toESM(require("node:os"), 1);
56881
56976
  import_node_path62 = __toESM(require("node:path"), 1);
56882
56977
  init_podspec_ruby();
56883
56978
  init_podspec_ruby_stdlib();
@@ -68368,10 +68463,10 @@ function bazelBinary(root) {
68368
68463
  const pinned = import_node_path74.default.join(root, ".bazelversion");
68369
68464
  if (!import_node_fs73.default.existsSync(pinned)) return "bazel";
68370
68465
  const version2 = import_node_fs73.default.readFileSync(pinned, "utf8").trim();
68371
- const platform2 = import_node_os19.default.platform() === "darwin" ? "darwin" : "linux";
68372
- const arch = import_node_os19.default.arch() === "arm64" ? "arm64" : "x86_64";
68466
+ const platform2 = import_node_os20.default.platform() === "darwin" ? "darwin" : "linux";
68467
+ const arch = import_node_os20.default.arch() === "arm64" ? "arm64" : "x86_64";
68373
68468
  const name3 = `bazel-${version2}-${platform2}-${arch}`;
68374
- const binary2 = import_node_path74.default.join(import_node_os19.default.homedir(), ".peach", "cache", "bazel", name3);
68469
+ const binary2 = import_node_path74.default.join(import_node_os20.default.homedir(), ".peach", "cache", "bazel", name3);
68375
68470
  if (import_node_fs73.default.existsSync(binary2)) return binary2;
68376
68471
  const url = `https://github.com/bazelbuild/bazel/releases/download/${version2}/${name3}`;
68377
68472
  import_node_fs73.default.mkdirSync(import_node_path74.default.dirname(binary2), { recursive: true });
@@ -69267,14 +69362,14 @@ function shellTokens(options2) {
69267
69362
  return words2;
69268
69363
  });
69269
69364
  }
69270
- var import_node_child_process41, import_node_crypto44, import_node_fs73, import_node_os19, import_node_path74, LIBRARY_RULES, QUERIED_RULES, NATIVE_SOURCE, HEADER3, PRODUCTS, graphs, CLANG_CONFIGURATION_FLAGS, GRAPH_FORMAT, BazelFiles, CXX_STANDARD;
69365
+ var import_node_child_process41, import_node_crypto44, import_node_fs73, import_node_os20, import_node_path74, LIBRARY_RULES, QUERIED_RULES, NATIVE_SOURCE, HEADER3, PRODUCTS, graphs, CLANG_CONFIGURATION_FLAGS, GRAPH_FORMAT, BazelFiles, CXX_STANDARD;
69271
69366
  var init_bazel_project = __esm({
69272
69367
  "src/bazel-project.ts"() {
69273
69368
  "use strict";
69274
69369
  import_node_child_process41 = require("node:child_process");
69275
69370
  import_node_crypto44 = require("node:crypto");
69276
69371
  import_node_fs73 = __toESM(require("node:fs"), 1);
69277
- import_node_os19 = __toESM(require("node:os"), 1);
69372
+ import_node_os20 = __toESM(require("node:os"), 1);
69278
69373
  import_node_path74 = __toESM(require("node:path"), 1);
69279
69374
  init_is_record();
69280
69375
  init_plist();
@@ -76138,7 +76233,7 @@ function nativeWorkspacesDir(root) {
76138
76233
  for (const cache of [
76139
76234
  sharedCacheDir(cacheDir()),
76140
76235
  cacheDir(),
76141
- import_node_path84.default.join(import_node_os20.default.homedir(), ".peach-cache")
76236
+ import_node_path84.default.join(import_node_os21.default.homedir(), ".peach-cache")
76142
76237
  ]) {
76143
76238
  let existing = cache;
76144
76239
  while (!import_node_fs82.default.existsSync(existing)) existing = import_node_path84.default.dirname(existing);
@@ -76148,7 +76243,7 @@ function nativeWorkspacesDir(root) {
76148
76243
  let mount = import_node_fs82.default.realpathSync(root);
76149
76244
  while (import_node_path84.default.dirname(mount) !== mount && import_node_fs82.default.statSync(import_node_path84.default.dirname(mount)).dev === device)
76150
76245
  mount = import_node_path84.default.dirname(mount);
76151
- const tmpRoots = /* @__PURE__ */ new Set(["/tmp", "/var/tmp", import_node_fs82.default.realpathSync(import_node_os20.default.tmpdir())]);
76246
+ const tmpRoots = /* @__PURE__ */ new Set(["/tmp", "/var/tmp", import_node_fs82.default.realpathSync(import_node_os21.default.tmpdir())]);
76152
76247
  if (tmpRoots.has(mount))
76153
76248
  return import_node_path84.default.join(sharedCacheDir(cacheDir()), "expo-native-workspaces");
76154
76249
  return import_node_path84.default.join(mount, ".peach-cache", "expo-native-workspaces");
@@ -76489,7 +76584,7 @@ ${failedOutputLine(command, cwd, bytes)}`
76489
76584
  });
76490
76585
  });
76491
76586
  }
76492
- var import_node_child_process43, import_node_crypto50, import_node_fs82, import_node_module6, import_node_os20, import_node_path84, import_node_util11, isolatedGitEnv, EXACT_VERSION, NATIVE_CONFIG_FILE, NATIVE_SOURCE_FILE, fileDigests, NATIVE_PACKAGE_ENTRY, hashing, KEPT_WORKSPACES, WORKSPACE_GRACE_MS, ABANDONED_WORKSPACE_MS, RETIRED_PREFIX2, preparing, watches, current, CLONE_ENTRIES;
76587
+ var import_node_child_process43, import_node_crypto50, import_node_fs82, import_node_module6, import_node_os21, import_node_path84, import_node_util11, isolatedGitEnv, EXACT_VERSION, NATIVE_CONFIG_FILE, NATIVE_SOURCE_FILE, fileDigests, NATIVE_PACKAGE_ENTRY, hashing, KEPT_WORKSPACES, WORKSPACE_GRACE_MS, ABANDONED_WORKSPACE_MS, RETIRED_PREFIX2, preparing, watches, current, CLONE_ENTRIES;
76493
76588
  var init_expo_native_workspace = __esm({
76494
76589
  "src/expo-native-workspace.ts"() {
76495
76590
  "use strict";
@@ -76497,7 +76592,7 @@ var init_expo_native_workspace = __esm({
76497
76592
  import_node_crypto50 = require("node:crypto");
76498
76593
  import_node_fs82 = __toESM(require("node:fs"), 1);
76499
76594
  import_node_module6 = require("node:module");
76500
- import_node_os20 = __toESM(require("node:os"), 1);
76595
+ import_node_os21 = __toESM(require("node:os"), 1);
76501
76596
  import_node_path84 = __toESM(require("node:path"), 1);
76502
76597
  import_node_util11 = require("node:util");
76503
76598
  init_detect();
@@ -88479,7 +88574,7 @@ var init_swift_standin_digest = __esm({
88479
88574
  ];
88480
88575
  RUNTIME_IMPORT = /(?:^|[;\n])[ \t]*(?:import|export)\s+(?!type(?:\s|\{))([\s\S]*?)\s+from\s*['"]([^'"]+)['"]|(?:^|[;\n])[ \t]*import\s+['"]([^'"]+)['"]|import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
88481
88576
  standinSourceDigest = (srcDir = __sootsim_import_meta_dirname) => sourceClosureDigest(srcDir, STANDIN_DIGEST_ENTRYPOINTS, STANDIN_DIGEST_EXCLUDED_FILES);
88482
- STANDIN_SOURCE_DIGEST = true ? "8b7dccbe4ecedba9dc6511eb4ab2e02ce2922969fcd9eebc93f3280c6529a48b" : standinSourceDigest();
88577
+ STANDIN_SOURCE_DIGEST = true ? "3f378daefc4c950a9d25cfd3184475a07f63966495c86443c5058ef8f9dd3ac9" : standinSourceDigest();
88483
88578
  }
88484
88579
  });
88485
88580
 
@@ -89657,7 +89752,7 @@ function genruleToolchain(moduleRoot) {
89657
89752
  ranlib: bin("llvm-ranlib"),
89658
89753
  jobs: Math.min(
89659
89754
  32,
89660
- Number(process.env.TM_EXEC_CPU_CORES) || import_node_os21.default.availableParallelism()
89755
+ Number(process.env.TM_EXEC_CPU_CORES) || import_node_os22.default.availableParallelism()
89661
89756
  ),
89662
89757
  frameworkIdentity: () => frameworkProbeIdentity(moduleRoot, compiler.toolchainBin),
89663
89758
  frameworks: () => frameworks ??= nativeFrameworkCompiler(
@@ -89813,14 +89908,14 @@ function genruleArchive(declaration, library, moduleRoot) {
89813
89908
  }
89814
89909
  return combined;
89815
89910
  }
89816
- var import_node_child_process51, import_node_crypto63, import_node_fs103, import_node_os21, import_node_path107, v8, BUILDERS, cacheDir4, toolIdentities, sysrootIdentities, GENRULE_RECIPE, GENRULE_BUNDLE;
89911
+ var import_node_child_process51, import_node_crypto63, import_node_fs103, import_node_os22, import_node_path107, v8, BUILDERS, cacheDir4, toolIdentities, sysrootIdentities, GENRULE_RECIPE, GENRULE_BUNDLE;
89817
89912
  var init_genrule_archives = __esm({
89818
89913
  "src/genrule-archives.ts"() {
89819
89914
  "use strict";
89820
89915
  import_node_child_process51 = require("node:child_process");
89821
89916
  import_node_crypto63 = require("node:crypto");
89822
89917
  import_node_fs103 = __toESM(require("node:fs"), 1);
89823
- import_node_os21 = __toESM(require("node:os"), 1);
89918
+ import_node_os22 = __toESM(require("node:os"), 1);
89824
89919
  import_node_path107 = __toESM(require("node:path"), 1);
89825
89920
  v8 = __toESM(require("peachsim/vendor/valibot"), 1);
89826
89921
  init_ffmpeg_source_build();
@@ -89906,7 +90001,7 @@ function privateSentrySlice(entry, moduleRoot) {
89906
90001
  throw new Error(
89907
90002
  "the Sentry slice for a private Swift distribution builds from a Contrast source checkout"
89908
90003
  );
89909
- const staging = import_node_fs104.default.mkdtempSync(import_node_path108.default.join(import_node_fs104.default.realpathSync(import_node_os22.default.tmpdir()), "sentry-slice-"));
90004
+ const staging = import_node_fs104.default.mkdtempSync(import_node_path108.default.join(import_node_fs104.default.realpathSync(import_node_os23.default.tmpdir()), "sentry-slice-"));
89910
90005
  try {
89911
90006
  process.stderr.write("peach: building the Sentry slice for a private distribution\u2026\n");
89912
90007
  (0, import_node_child_process52.execFileSync)("bun", [script, "--output", staging, "--module-root", moduleRoot], {
@@ -89984,14 +90079,14 @@ function nativeSwiftSlice(standin, moduleRoot, generator, configured, artifact)
89984
90079
  }
89985
90080
  };
89986
90081
  }
89987
- var import_node_child_process52, import_node_crypto64, import_node_fs104, import_node_os22, import_node_path108, SENTRY_SWIFT_SLICE;
90082
+ var import_node_child_process52, import_node_crypto64, import_node_fs104, import_node_os23, import_node_path108, SENTRY_SWIFT_SLICE;
89988
90083
  var init_native_swift_slices = __esm({
89989
90084
  "src/native-swift-slices.ts"() {
89990
90085
  "use strict";
89991
90086
  import_node_child_process52 = require("node:child_process");
89992
90087
  import_node_crypto64 = require("node:crypto");
89993
90088
  import_node_fs104 = __toESM(require("node:fs"), 1);
89994
- import_node_os22 = __toESM(require("node:os"), 1);
90089
+ import_node_os23 = __toESM(require("node:os"), 1);
89995
90090
  import_node_path108 = __toESM(require("node:path"), 1);
89996
90091
  init_native_prebuilt();
89997
90092
  init_swift_sdk_surface();
@@ -95064,7 +95159,7 @@ function build(checkout, output, toolchainBin, common2, objc) {
95064
95159
  import_node_fs110.default.cpSync(import_node_path113.default.join(runtime, "include"), import_node_path113.default.join(includes, "rive", "include"), {
95065
95160
  recursive: true
95066
95161
  });
95067
- const jobs = String(Number(process.env.TM_EXEC_CPU_CORES) || import_node_os23.default.availableParallelism());
95162
+ const jobs = String(Number(process.env.TM_EXEC_CPU_CORES) || import_node_os24.default.availableParallelism());
95068
95163
  const component = (directory2, target, args, headers) => {
95069
95164
  const cwd = import_node_path113.default.join(runtime, directory2);
95070
95165
  const out = `out/iphonesimulator_${CONFIG}`;
@@ -95174,14 +95269,14 @@ exec ${quote3(import_node_path113.default.join(toolchainBin, "llvm-ar"))} rcs "$
95174
95269
  );
95175
95270
  return directory2;
95176
95271
  }
95177
- var import_node_child_process56, import_node_crypto67, import_node_fs110, import_node_os23, import_node_path113, import_promises10, RECIPE, CONFIG, RUNTIME_LIBRARIES;
95272
+ var import_node_child_process56, import_node_crypto67, import_node_fs110, import_node_os24, import_node_path113, import_promises10, RECIPE, CONFIG, RUNTIME_LIBRARIES;
95178
95273
  var init_rive_runtime_dependencies = __esm({
95179
95274
  "src/rive-runtime-dependencies.ts"() {
95180
95275
  "use strict";
95181
95276
  import_node_child_process56 = require("node:child_process");
95182
95277
  import_node_crypto67 = require("node:crypto");
95183
95278
  import_node_fs110 = __toESM(require("node:fs"), 1);
95184
- import_node_os23 = __toESM(require("node:os"), 1);
95279
+ import_node_os24 = __toESM(require("node:os"), 1);
95185
95280
  import_node_path113 = __toESM(require("node:path"), 1);
95186
95281
  import_promises10 = require("node:timers/promises");
95187
95282
  init_home_paths();
@@ -96293,7 +96388,7 @@ function rasterizePdfFiles(inputs2, { imageBytes, imageTotalBytes } = { imageByt
96293
96388
  record5(input, bytes);
96294
96389
  }
96295
96390
  if (!pending2.size) return rendered;
96296
- const work = import_node_fs113.default.mkdtempSync(import_node_path116.default.join(import_node_os24.default.tmpdir(), "swift-pdf-png-"));
96391
+ const work = import_node_fs113.default.mkdtempSync(import_node_path116.default.join(import_node_os25.default.tmpdir(), "swift-pdf-png-"));
96297
96392
  let cacheWork;
96298
96393
  let writeCache = true;
96299
96394
  try {
@@ -96346,13 +96441,13 @@ function rasterizePdfFiles(inputs2, { imageBytes, imageTotalBytes } = { imageByt
96346
96441
  }
96347
96442
  return rendered;
96348
96443
  }
96349
- var import_node_child_process59, import_node_fs113, import_node_os24, import_node_path116, RASTER_PDF;
96444
+ var import_node_child_process59, import_node_fs113, import_node_os25, import_node_path116, RASTER_PDF;
96350
96445
  var init_swift_pdf_raster = __esm({
96351
96446
  "src/swift-pdf-raster.ts"() {
96352
96447
  "use strict";
96353
96448
  import_node_child_process59 = require("node:child_process");
96354
96449
  import_node_fs113 = __toESM(require("node:fs"), 1);
96355
- import_node_os24 = __toESM(require("node:os"), 1);
96450
+ import_node_os25 = __toESM(require("node:os"), 1);
96356
96451
  import_node_path116 = __toESM(require("node:path"), 1);
96357
96452
  init_internal_child_contract();
96358
96453
  init_self_invocation();
@@ -96895,6 +96990,15 @@ var init_swift_sdk_later_data = __esm({
96895
96990
  });
96896
96991
 
96897
96992
  // src/swift-host.ts
96993
+ function readPackageFileScoped(packagePath, file, maxBytes) {
96994
+ const scope2 = packageReadScopes.getStore();
96995
+ const key2 = `${packagePath}\0${file}`;
96996
+ const cached2 = scope2?.get(key2);
96997
+ if (cached2) return cached2;
96998
+ const bytes = readPackageFile2(packagePath, file, maxBytes);
96999
+ scope2?.set(key2, bytes);
97000
+ return bytes;
97001
+ }
96898
97002
  function swiftPackageId(packagePath) {
96899
97003
  return import_node_path117.default.basename(packagePath).replace(/[^A-Za-z0-9_]/g, "_").replace(/^(\d)/, "_$1");
96900
97004
  }
@@ -98518,7 +98622,7 @@ function buildSwiftBundleFiles(packagePath, hosted, inputs2, resourceBundles) {
98518
98622
  }
98519
98623
  }
98520
98624
  if (xcode?.app.postBundleScripts.length) {
98521
- const dir = import_node_fs114.default.mkdtempSync(import_node_path117.default.join(import_node_os25.default.tmpdir(), "peach-xcode-bundle-"));
98625
+ const dir = import_node_fs114.default.mkdtempSync(import_node_path117.default.join(import_node_os26.default.tmpdir(), "peach-xcode-bundle-"));
98522
98626
  const wrapper = import_node_path117.default.basename(xcode.app.settings("UNLOCALIZED_RESOURCES_FOLDER_PATH")) || `${xcode.app.name}.app`;
98523
98627
  const bundle = import_node_path117.default.join(dir, wrapper);
98524
98628
  try {
@@ -98696,13 +98800,7 @@ function moduleStamp(packagePath, moduleRootOverride, hosted) {
98696
98800
  (root) => import_node_fs114.default.existsSync(import_node_path117.default.join(root, "toolchain.json"))
98697
98801
  );
98698
98802
  if (!moduleRoot) return "";
98699
- const hash = (0, import_node_crypto70.createHash)("sha256");
98700
- hash.update(moduleRoot);
98701
- for (const relative4 of swiftModuleInputFiles(moduleRoot)) {
98702
- hash.update(relative4);
98703
- hash.update(String(import_node_fs114.default.statSync(import_node_path117.default.join(moduleRoot, relative4)).mtimeMs));
98704
- }
98705
- return hash.digest("hex");
98803
+ return `${moduleRoot}\0${swiftModuleStamp(moduleRoot)}`;
98706
98804
  }
98707
98805
  function otherInputs(input) {
98708
98806
  const { files: _files, ...rest } = input;
@@ -98822,7 +98920,7 @@ function packageSources(packagePath, hosted = false, linked = /* @__PURE__ */ ne
98822
98920
  for (const file of sourceFiles(packagePath)) {
98823
98921
  const relative4 = import_node_path117.default.relative(packagePath, file).split(import_node_path117.default.sep).join(import_node_path117.default.posix.sep);
98824
98922
  if (manifests.has(file) || xcode?.packageFiles.has(file)) continue;
98825
- files2[xcode ? xcodeInputKey(xcode, file, relative4) : relative4] = (xcode?.nativeFiles.get(file) ?? readPackageFile2(packagePath, file, limits.sourceBytes)).toString("utf8");
98923
+ files2[xcode ? xcodeInputKey(xcode, file, relative4) : relative4] = (xcode?.nativeFiles.get(file) ?? readPackageFileScoped(packagePath, file, limits.sourceBytes)).toString("utf8");
98826
98924
  }
98827
98925
  if (xcode) {
98828
98926
  for (const [file, contents2] of xcode.nativeFiles)
@@ -99117,48 +99215,52 @@ async function compile(packagePath, stamp, moduleRootOverride, hosted, snapshot,
99117
99215
  const moduleRoot = moduleRootOverride ?? linkedModuleRoots(packagePath).find(
99118
99216
  (root) => import_node_fs114.default.existsSync(import_node_path117.default.join(root, "toolchain.json"))
99119
99217
  ) ?? await swiftDistributionRoot(signal);
99120
- const toolchain = swiftModuleToolchain(moduleRoot);
99218
+ const release = swiftModuleRelease(moduleRoot);
99121
99219
  const input = snapshotCompileInput(snapshot);
99122
99220
  const compiled = {
99123
99221
  files: input.files,
99124
99222
  inputs: otherInputs(input),
99125
99223
  module: moduleStamp(packagePath, moduleRootOverride, false)
99126
99224
  };
99127
- const parsed2 = compileTargets(input);
99128
- const targets = parsed2.map((target) => swiftTargetModuleName(target.name));
99129
- const byPath = [...parsed2].sort((left, right) => right.path.length - left.path.length);
99130
- const clangModulesByTarget = new Map(
99131
- (input.nativeTargets ?? []).map(({ name: name3, headerSearchPaths }) => [
99132
- name3,
99133
- headerSearchPaths.flatMap((directory2) => {
99134
- const map2 = input.files[import_node_path117.default.posix.join(directory2, "module.modulemap")] ?? input.files[import_node_path117.default.posix.join(directory2, "module.map")];
99135
- return map2 === void 0 ? [] : moduleMapModules(map2).map(({ name: name4 }) => name4);
99136
- })
99137
- ])
99138
- );
99139
- const providedByFile = (file) => {
99140
- const owner = byPath.find(
99141
- (target) => target.path === "." ? true : file.startsWith(`${target.path}/`)
99225
+ const verifyMissingModules = async (toolchainBin) => {
99226
+ const parsed2 = compileTargets(input);
99227
+ const targets = parsed2.map((target) => swiftTargetModuleName(target.name));
99228
+ const byPath = [...parsed2].sort((left, right) => right.path.length - left.path.length);
99229
+ const clangModulesByTarget = new Map(
99230
+ (input.nativeTargets ?? []).map(({ name: name3, headerSearchPaths }) => [
99231
+ name3,
99232
+ headerSearchPaths.flatMap((directory2) => {
99233
+ const map2 = input.files[import_node_path117.default.posix.join(directory2, "module.modulemap")] ?? input.files[import_node_path117.default.posix.join(directory2, "module.map")];
99234
+ return map2 === void 0 ? [] : moduleMapModules(map2).map(({ name: name4 }) => name4);
99235
+ })
99236
+ ])
99142
99237
  );
99143
- if (!owner) return [];
99144
- const clangModules = clangModulesByTarget.get(owner.name) ?? [];
99145
- return owner.experimentalFeatures?.includes("BuiltinModule") ? [...clangModules, "Builtin"] : clangModules;
99238
+ const providedByFile = (file) => {
99239
+ const owner = byPath.find(
99240
+ (target) => target.path === "." ? true : file.startsWith(`${target.path}/`)
99241
+ );
99242
+ if (!owner) return [];
99243
+ const clangModules = clangModulesByTarget.get(owner.name) ?? [];
99244
+ return owner.experimentalFeatures?.includes("BuiltinModule") ? [...clangModules, "Builtin"] : clangModules;
99245
+ };
99246
+ const missing2 = missingSwiftModules(
99247
+ input.files,
99248
+ /* @__PURE__ */ new Set([
99249
+ ...swiftAvailableModules(moduleRoot, toolchainBin),
99250
+ // a project without a manifest compiles as the template's one App target
99251
+ ...targets.length > 0 ? targets : ["App"],
99252
+ // a system target's clang module name need not match its target name
99253
+ ...swiftSystemLibrarySurface(input.files, parsed2).modules,
99254
+ ...Object.keys(input.binaryModules ?? {}),
99255
+ ...snapshot.nativeModules
99256
+ ]),
99257
+ providedByFile
99258
+ );
99259
+ if (missing2.size > 0)
99260
+ throw new SwiftMissingModulesError(
99261
+ await missingModulesMessage(packagePath, missing2)
99262
+ );
99146
99263
  };
99147
- const missing2 = missingSwiftModules(
99148
- input.files,
99149
- /* @__PURE__ */ new Set([
99150
- ...swiftAvailableModules(moduleRoot, toolchain.toolchainBin),
99151
- // a project without a manifest compiles as the template's one App target
99152
- ...targets.length > 0 ? targets : ["App"],
99153
- // a system target's clang module name need not match its target name
99154
- ...swiftSystemLibrarySurface(input.files, parsed2).modules,
99155
- ...Object.keys(input.binaryModules ?? {}),
99156
- ...snapshot.nativeModules
99157
- ]),
99158
- providedByFile
99159
- );
99160
- if (missing2.size > 0)
99161
- throw new SwiftMissingModulesError(await missingModulesMessage(packagePath, missing2));
99162
99264
  const artifact = await compileSwiftProjectUnit(input, {
99163
99265
  // the compile rewrites Sources/App in its root before swiftpm builds, and
99164
99266
  // a root lock orders every process using it, so two vites on one root
@@ -99168,7 +99270,9 @@ async function compile(packagePath, stamp, moduleRootOverride, hosted, snapshot,
99168
99270
  // incremental build across restarts.
99169
99271
  buildRoot: swiftBuildRoot(packagePath, moduleRoot),
99170
99272
  moduleRoot,
99171
- ...toolchain,
99273
+ release,
99274
+ resolveToolchain: () => swiftModuleToolchain(moduleRoot).toolchainBin,
99275
+ beforeCompile: verifyMissingModules,
99172
99276
  signal
99173
99277
  }).catch((error) => {
99174
99278
  const report = error instanceof Error ? swiftApiGapReport(error.message) : null;
@@ -99379,9 +99483,11 @@ function currentStamp(project2, moduleRoot) {
99379
99483
  );
99380
99484
  }
99381
99485
  function artifactFor(project2, entry, moduleRoot, signal = project2.signal) {
99382
- return withXcodeLayout(
99383
- project2.packagePath,
99384
- () => scopedArtifact(project2, entry, moduleRoot, signal)
99486
+ return withSwiftModuleDigestScope(
99487
+ () => withXcodeLayout(
99488
+ project2.packagePath,
99489
+ () => scopedArtifact(project2, entry, moduleRoot, signal)
99490
+ )
99385
99491
  );
99386
99492
  }
99387
99493
  function scopedArtifact(project2, entry, moduleRoot, signal) {
@@ -99442,6 +99548,48 @@ function scopedArtifact(project2, entry, moduleRoot, signal) {
99442
99548
  project2.building = { stamp, promise: fresh, signal };
99443
99549
  return fresh;
99444
99550
  }
99551
+ function readCachedSplitBinding(cacheDir6) {
99552
+ const receiptFile2 = import_node_path117.default.join(cacheDir6, "receipt.json");
99553
+ if (!import_node_fs114.default.existsSync(receiptFile2)) return null;
99554
+ try {
99555
+ const receipt = JSON.parse(import_node_fs114.default.readFileSync(receiptFile2, "utf8"));
99556
+ if (!receipt || typeof receipt !== "object" || !("digest" in receipt) || typeof receipt.digest !== "string" || !("later" in receipt) || !Array.isArray(receipt.later) || !receipt.later.every((item) => typeof item === "string"))
99557
+ return null;
99558
+ const binding = import_node_fs114.default.readFileSync(import_node_path117.default.join(cacheDir6, "binding.bin"));
99559
+ if ((0, import_node_crypto70.createHash)("sha256").update(binding).digest("hex") !== receipt.digest) return null;
99560
+ const later = receipt.later.map((sha2564, index) => {
99561
+ const bytes = import_node_fs114.default.readFileSync(import_node_path117.default.join(cacheDir6, `later-${index}.bin`));
99562
+ if ((0, import_node_crypto70.createHash)("sha256").update(bytes).digest("hex") !== sha2564)
99563
+ throw new SyntaxError("digest mismatch");
99564
+ return { sha256: sha2564, bytes };
99565
+ });
99566
+ return { digest: receipt.digest, binding, later };
99567
+ } catch {
99568
+ return null;
99569
+ }
99570
+ }
99571
+ function writeCachedSplitBinding(cacheDir6, digest3, binding, later) {
99572
+ const parent = import_node_path117.default.dirname(cacheDir6);
99573
+ import_node_fs114.default.mkdirSync(parent, { recursive: true });
99574
+ const staging = `${cacheDir6}.${process.pid}.${(0, import_node_crypto70.randomUUID)()}.tmp`;
99575
+ try {
99576
+ import_node_fs114.default.mkdirSync(staging, { recursive: true });
99577
+ import_node_fs114.default.writeFileSync(import_node_path117.default.join(staging, "binding.bin"), binding);
99578
+ for (let index = 0; index < later.length; index++)
99579
+ import_node_fs114.default.writeFileSync(import_node_path117.default.join(staging, `later-${index}.bin`), later[index].bytes);
99580
+ import_node_fs114.default.writeFileSync(
99581
+ import_node_path117.default.join(staging, "receipt.json"),
99582
+ JSON.stringify({ digest: digest3, later: later.map(({ sha256: sha2564 }) => sha2564) })
99583
+ );
99584
+ try {
99585
+ import_node_fs114.default.renameSync(staging, cacheDir6);
99586
+ } catch {
99587
+ if (!import_node_fs114.default.existsSync(cacheDir6)) throw new Error(`failed to store ${cacheDir6}`);
99588
+ }
99589
+ } finally {
99590
+ import_node_fs114.default.rmSync(staging, { recursive: true, force: true });
99591
+ }
99592
+ }
99445
99593
  async function splitSdkBinding(sdk2, splitKey, plan) {
99446
99594
  const key2 = `${sdk2.binding.sha256}:${splitKey}`;
99447
99595
  if (sdkSplitBindings.has(key2)) return;
@@ -99449,15 +99597,29 @@ async function splitSdkBinding(sdk2, splitKey, plan) {
99449
99597
  Promise.resolve().then(() => (init_swift_sdk_later_data(), swift_sdk_later_data_exports)),
99450
99598
  Promise.resolve().then(() => (init_swift_sdk_image(), swift_sdk_image_exports))
99451
99599
  ]);
99452
- const split = splitSwiftSdkLaterData2(
99453
- import_node_path117.default.dirname(swiftSdkImageFile2(sdk2.key)),
99454
- sdk2.binding.bytes,
99455
- plan
99456
- );
99600
+ const sdkDirectory = import_node_path117.default.dirname(swiftSdkImageFile2(sdk2.key));
99601
+ const planDigest = (0, import_node_crypto70.createHash)("sha256").update(plan).digest("hex");
99602
+ const cacheDir6 = import_node_path117.default.join(
99603
+ sdkDirectory,
99604
+ "split-bindings-v1",
99605
+ (0, import_node_crypto70.createHash)("sha256").update(`${sdk2.binding.sha256}\0${planDigest}`).digest("hex").slice(0, 32)
99606
+ );
99607
+ const cached2 = readCachedSplitBinding(cacheDir6);
99608
+ if (cached2) {
99609
+ sdkBindingFiles.set(cached2.digest, cached2.binding);
99610
+ for (const { sha256: sha2564, bytes } of cached2.later) sdkBindingFiles.set(sha2564, bytes);
99611
+ sdkSplitBindings.set(key2, cached2.digest);
99612
+ return;
99613
+ }
99614
+ const split = splitSwiftSdkLaterData2(sdkDirectory, sdk2.binding.bytes, plan);
99457
99615
  const digest3 = (0, import_node_crypto70.createHash)("sha256").update(split.binding).digest("hex");
99616
+ const later = split.later.map((bytes) => ({
99617
+ sha256: (0, import_node_crypto70.createHash)("sha256").update(bytes).digest("hex"),
99618
+ bytes
99619
+ }));
99620
+ writeCachedSplitBinding(cacheDir6, digest3, split.binding, later);
99458
99621
  sdkBindingFiles.set(digest3, split.binding);
99459
- for (const later of split.later)
99460
- sdkBindingFiles.set((0, import_node_crypto70.createHash)("sha256").update(later).digest("hex"), later);
99622
+ for (const { sha256: sha2564, bytes } of later) sdkBindingFiles.set(sha2564, bytes);
99461
99623
  sdkSplitBindings.set(key2, digest3);
99462
99624
  }
99463
99625
  function swiftSdkEntryAssets(origin, image, sdkDigest = image.sdk?.sha256) {
@@ -99547,15 +99709,15 @@ async function swiftArtifactAssets(artifact, { sdkUrl, sdkBindingUrl }) {
99547
99709
  }
99548
99710
  return assets2;
99549
99711
  }
99550
- var import_node_async_hooks3, import_node_child_process60, import_node_crypto70, import_node_fs114, import_node_os25, import_node_path117, ARTIFACT_PATH, RESOURCE_PATH, ICU_PATH, SDK_PATH, SDK_BINDING_PATH, SKIP_ROOT_DIRS, NATIVE_DESCRIPTOR, NATIVE_GLUE, SwiftMissingModulesError, swiftArtifactDigests, sharedProjects, projectScope, projects, sharedSourceEntries, sourceEntries, sharedXcodeProjects, xcodeProjects, preparedScriptInputs, emptyWasmAssembly, XCODE_APP_DIR, XCODE_FRAMEWORKS_DIR, XCODE_PACKAGES_DIR, layoutScope, HOSTED_LIMITS, LOCAL_LIMITS, inputLimits, RESOURCE_CONTENT_TYPES, API_GAP_PATTERNS, IOS_SDK_FRAMEWORKS, sdkStartupParts, sdkPieces2, sdkSplitBindings, sdkBindingFiles, servedSdkBinding;
99712
+ var import_node_async_hooks4, import_node_child_process60, import_node_crypto70, import_node_fs114, import_node_os26, import_node_path117, ARTIFACT_PATH, RESOURCE_PATH, ICU_PATH, SDK_PATH, SDK_BINDING_PATH, SKIP_ROOT_DIRS, NATIVE_DESCRIPTOR, NATIVE_GLUE, packageReadScopes, SwiftMissingModulesError, swiftArtifactDigests, sharedProjects, projectScope, projects, sharedSourceEntries, sourceEntries, sharedXcodeProjects, xcodeProjects, preparedScriptInputs, emptyWasmAssembly, XCODE_APP_DIR, XCODE_FRAMEWORKS_DIR, XCODE_PACKAGES_DIR, layoutScope, HOSTED_LIMITS, LOCAL_LIMITS, inputLimits, RESOURCE_CONTENT_TYPES, API_GAP_PATTERNS, IOS_SDK_FRAMEWORKS, sdkStartupParts, sdkPieces2, sdkSplitBindings, sdkBindingFiles, servedSdkBinding;
99551
99713
  var init_swift_host = __esm({
99552
99714
  "src/swift-host.ts"() {
99553
99715
  "use strict";
99554
- import_node_async_hooks3 = require("node:async_hooks");
99716
+ import_node_async_hooks4 = require("node:async_hooks");
99555
99717
  import_node_child_process60 = require("node:child_process");
99556
99718
  import_node_crypto70 = require("node:crypto");
99557
99719
  import_node_fs114 = __toESM(require("node:fs"), 1);
99558
- import_node_os25 = __toESM(require("node:os"), 1);
99720
+ import_node_os26 = __toESM(require("node:os"), 1);
99559
99721
  import_node_path117 = __toESM(require("node:path"), 1);
99560
99722
  init_pngHeader();
99561
99723
  init_nativeSdkBindingContract();
@@ -99585,6 +99747,7 @@ var init_swift_host = __esm({
99585
99747
  init_swift_packages();
99586
99748
  init_swift_pdf_raster();
99587
99749
  init_swift_sdk_image_wasm();
99750
+ init_swift_sdk_surface();
99588
99751
  init_swift_shipped_binaries();
99589
99752
  init_swift_source_file();
99590
99753
  init_swift_standin_config();
@@ -99605,11 +99768,12 @@ var init_swift_host = __esm({
99605
99768
  SKIP_ROOT_DIRS = /* @__PURE__ */ new Set(["dist", "types", "build", "ios", "android"]);
99606
99769
  NATIVE_DESCRIPTOR = ".one-native-source.json";
99607
99770
  NATIVE_GLUE = ".one-native-source.swift.txt";
99771
+ packageReadScopes = new import_node_async_hooks4.AsyncLocalStorage();
99608
99772
  SwiftMissingModulesError = class extends Error {
99609
99773
  };
99610
99774
  swiftArtifactDigests = /* @__PURE__ */ new WeakMap();
99611
99775
  sharedProjects = /* @__PURE__ */ new Map();
99612
- projectScope = new import_node_async_hooks3.AsyncLocalStorage();
99776
+ projectScope = new import_node_async_hooks4.AsyncLocalStorage();
99613
99777
  projects = () => projectScope.getStore()?.projects ?? sharedProjects;
99614
99778
  sharedSourceEntries = /* @__PURE__ */ new Map();
99615
99779
  sourceEntries = () => projectScope.getStore()?.sourceEntries ?? sharedSourceEntries;
@@ -99620,7 +99784,7 @@ var init_swift_host = __esm({
99620
99784
  XCODE_APP_DIR = "__app__";
99621
99785
  XCODE_FRAMEWORKS_DIR = "__frameworks__";
99622
99786
  XCODE_PACKAGES_DIR = SWIFT_REMOTE_PACKAGES_DIR;
99623
- layoutScope = new import_node_async_hooks3.AsyncLocalStorage();
99787
+ layoutScope = new import_node_async_hooks4.AsyncLocalStorage();
99624
99788
  HOSTED_LIMITS = {
99625
99789
  sourceBytes: MAX_SWIFT_COMPILE_SOURCE_BYTES,
99626
99790
  resources: MAX_SWIFT_COMPILE_RESOURCES,
@@ -105510,7 +105674,7 @@ function retainInstalledReactNativeDeclarations(snapshot, options2, skipped, cor
105510
105674
  async function prepareTurboCompileInput(options2) {
105511
105675
  await prepareTurboSourceDependencies(options2.reactNativeRoot);
105512
105676
  const key2 = (0, import_node_crypto73.createHash)("sha256").update(options2.providers.map(({ root }) => import_node_fs119.default.realpathSync(root)).join("\0")).update("\0").update(import_node_fs119.default.realpathSync(options2.moduleRoot)).digest("hex");
105513
- const scratch2 = import_node_path122.default.join(import_node_os26.default.tmpdir(), "peach-turbo-swift", key2);
105677
+ const scratch2 = import_node_path122.default.join(import_node_os27.default.tmpdir(), "peach-turbo-swift", key2);
105514
105678
  import_node_fs119.default.mkdirSync(scratch2, { recursive: true });
105515
105679
  const codegenDir = import_node_fs119.default.mkdtempSync(import_node_path122.default.join(scratch2, "codegen-"));
105516
105680
  const collection = await collectTurboSources({
@@ -105751,14 +105915,14 @@ async function compileTurboModule(options2) {
105751
105915
  collection
105752
105916
  };
105753
105917
  }
105754
- var import_node_crypto73, import_node_fs119, import_node_module15, import_node_os26, import_node_path122;
105918
+ var import_node_crypto73, import_node_fs119, import_node_module15, import_node_os27, import_node_path122;
105755
105919
  var init_turbo_compile = __esm({
105756
105920
  "src/turbo-compile.ts"() {
105757
105921
  "use strict";
105758
105922
  import_node_crypto73 = require("node:crypto");
105759
105923
  import_node_fs119 = __toESM(require("node:fs"), 1);
105760
105924
  import_node_module15 = require("node:module");
105761
- import_node_os26 = __toESM(require("node:os"), 1);
105925
+ import_node_os27 = __toESM(require("node:os"), 1);
105762
105926
  import_node_path122 = __toESM(require("node:path"), 1);
105763
105927
  init_native_app_identity_project();
105764
105928
  init_nitro_adapter();
@@ -106907,7 +107071,7 @@ async function prepareNitroCompileInput(options2) {
106907
107071
  );
106908
107072
  if (reactProviders.length > 0 || usesReactHeaders) {
106909
107073
  const nitroReactCodegenDir = import_node_fs123.default.mkdtempSync(
106910
- import_node_path126.default.join(import_node_os27.default.tmpdir(), "peach-nitro-react-")
107074
+ import_node_path126.default.join(import_node_os28.default.tmpdir(), "peach-nitro-react-")
106911
107075
  );
106912
107076
  let support;
106913
107077
  try {
@@ -106998,7 +107162,7 @@ async function prepareNitroCompileInput(options2) {
106998
107162
  const key2 = (0, import_node_crypto76.createHash)("sha256").update(
106999
107163
  collection.providers.map(({ root, hybridObjects }) => `${root}\0${hybridObjects.join(",")}`).join("\0")
107000
107164
  ).update("\0").update(import_node_fs123.default.realpathSync(options2.moduleRoot)).update("\0").update(options2.configuration).digest("hex");
107001
- const packagePath = import_node_path126.default.join(import_node_os27.default.tmpdir(), "peach-nitro-swift", key2, `p${process.pid}`);
107165
+ const packagePath = import_node_path126.default.join(import_node_os28.default.tmpdir(), "peach-nitro-swift", key2, `p${process.pid}`);
107002
107166
  const sharedLibrary = [...nativeLibraries.values()].find(
107003
107167
  (pod) => pod.sharedLibrary
107004
107168
  )?.sharedLibrary;
@@ -107051,13 +107215,13 @@ function nitrogenGeneratedSources(podDirectory) {
107051
107215
  ...sources(import_node_path126.default.join(generated, "ios"), /\.(h|hpp|c|cpp|mm|swift)$/)
107052
107216
  ];
107053
107217
  }
107054
- var import_node_crypto76, import_node_fs123, import_node_os27, import_node_path126, BUNDLED_CXX_NAMESPACES, REACT_INCLUDE_PATTERN, REACT_LINKING_PATTERN, REACT_VERSION_PATTERN, RN_HEADER_DIR_MAP, RN_COMMON_ROOTS;
107218
+ var import_node_crypto76, import_node_fs123, import_node_os28, import_node_path126, BUNDLED_CXX_NAMESPACES, REACT_INCLUDE_PATTERN, REACT_LINKING_PATTERN, REACT_VERSION_PATTERN, RN_HEADER_DIR_MAP, RN_COMMON_ROOTS;
107055
107219
  var init_nitro_compile = __esm({
107056
107220
  "src/nitro-compile.ts"() {
107057
107221
  "use strict";
107058
107222
  import_node_crypto76 = require("node:crypto");
107059
107223
  import_node_fs123 = __toESM(require("node:fs"), 1);
107060
- import_node_os27 = __toESM(require("node:os"), 1);
107224
+ import_node_os28 = __toESM(require("node:os"), 1);
107061
107225
  import_node_path126 = __toESM(require("node:path"), 1);
107062
107226
  init_answeredNativePackages();
107063
107227
  init_installed_native_libraries();
@@ -107315,7 +107479,7 @@ var init_nitro_superset = __esm({
107315
107479
  init_nitroContract();
107316
107480
  init_swift_standin_digest();
107317
107481
  NITRO_SUPERSET_ENTRY_NAME = "superset";
107318
- NITRO_COMPILER_DIGEST = true ? "f80b001abb12451680ce50211537f58ece77da31c3c32d2580b97d068226cbdd" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
107482
+ NITRO_COMPILER_DIGEST = true ? "f6a7a95d8b94acf3b85a06a8646dd3fa62a10b41bd72c1a91c9cfd465a4020e8" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
107319
107483
  nitroSupersetLock = parseLock(nitro_superset_lock_default);
107320
107484
  nitroSupersetKey = (inputs2) => nativeEntryKey({ ...inputs2, compiler: NITRO_COMPILER_DIGEST });
107321
107485
  published = /* @__PURE__ */ new Map();
@@ -108019,7 +108183,7 @@ var init_expo_eager_seam_contract = __esm({
108019
108183
 
108020
108184
  // src/expo-native-compiler-digest.ts
108021
108185
  function expoNativeCompilerDigestValue() {
108022
- return true ? "f47a7fb76e44a6b1c3e603ce0ec1ad8918050fb76250fa190bf2af1845a9fc13" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
108186
+ return true ? "927f2783b6582945ba64b325089d8caee6e1cc9bfab0c71dda18dcd4671c8bd0" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
108023
108187
  }
108024
108188
  var import_node_crypto80;
108025
108189
  var init_expo_native_compiler_digest = __esm({
@@ -108578,14 +108742,14 @@ async function readExpoConfigAsync(projectRoot) {
108578
108742
  import_node_fs130.default.rmSync(directory2, { recursive: true, force: true });
108579
108743
  }
108580
108744
  }
108581
- var import_node_child_process63, import_node_fs130, import_node_module18, import_node_os28, import_node_path133, EXPO_CONFIG_SCRIPT, EXPO_CONFIG_TIMEOUT_MS, resultDirectory;
108745
+ var import_node_child_process63, import_node_fs130, import_node_module18, import_node_os29, import_node_path133, EXPO_CONFIG_SCRIPT, EXPO_CONFIG_TIMEOUT_MS, resultDirectory;
108582
108746
  var init_native_firebase_config = __esm({
108583
108747
  "src/native-firebase-config.ts"() {
108584
108748
  "use strict";
108585
108749
  import_node_child_process63 = require("node:child_process");
108586
108750
  import_node_fs130 = __toESM(require("node:fs"), 1);
108587
108751
  import_node_module18 = require("node:module");
108588
- import_node_os28 = __toESM(require("node:os"), 1);
108752
+ import_node_os29 = __toESM(require("node:os"), 1);
108589
108753
  import_node_path133 = __toESM(require("node:path"), 1);
108590
108754
  init_is_record();
108591
108755
  init_plist();
@@ -108607,7 +108771,7 @@ const result = JSON.stringify(getConfig(root, { skipSDKVersionRequirement: true
108607
108771
  if (Buffer.byteLength(result) > 1024 * 1024) throw new Error('Expo native configuration exceeds 1 MiB.');
108608
108772
  writeFileSync(process.argv[2], result, { mode: 0o600 });`;
108609
108773
  EXPO_CONFIG_TIMEOUT_MS = 3e4;
108610
- resultDirectory = () => import_node_fs130.default.mkdtempSync(import_node_path133.default.join(import_node_os28.default.tmpdir(), "peach-expo-config-"));
108774
+ resultDirectory = () => import_node_fs130.default.mkdtempSync(import_node_path133.default.join(import_node_os29.default.tmpdir(), "peach-expo-config-"));
108611
108775
  }
108612
108776
  });
108613
108777
 
@@ -111282,7 +111446,7 @@ function expoUnitAppPaths(unit2) {
111282
111446
  });
111283
111447
  }
111284
111448
  function expoSwiftPackage(appKey, name3) {
111285
- return import_node_path137.default.join(import_node_os29.default.tmpdir(), "peach-expo-swift", appKey, `p${process.pid}`, name3);
111449
+ return import_node_path137.default.join(import_node_os30.default.tmpdir(), "peach-expo-swift", appKey, `p${process.pid}`, name3);
111286
111450
  }
111287
111451
  function failureRecordPath(packagePath) {
111288
111452
  const app = import_node_path137.default.dirname(import_node_path137.default.dirname(packagePath));
@@ -111382,6 +111546,7 @@ async function compileExpoSwiftModulesTraced(root, base2, publishArtifact, optio
111382
111546
  settings
111383
111547
  );
111384
111548
  const provider = linked2.some((unit2) => unit2.reactNativeProvider) ? reactProvider : void 0;
111549
+ const providerTargets = provider ? swiftManifestTargets(provider.files["Package.swift"]) : [];
111385
111550
  if (provider) {
111386
111551
  for (const [file, source] of Object.entries(provider.files)) {
111387
111552
  if (file === "Package.swift" || file === provider.entry) continue;
@@ -111393,7 +111558,7 @@ async function compileExpoSwiftModulesTraced(root, base2, publishArtifact, optio
111393
111558
  "target",
111394
111559
  "systemLibrary"
111395
111560
  ]).map(({ kind, call }) => `.${kind}(${call},`);
111396
- const names = swiftManifestTargets(provider.files["Package.swift"]).filter((target) => !target.executable).map((target) => JSON.stringify(target.name));
111561
+ const names = providerTargets.filter((target) => !target.executable).map((target) => JSON.stringify(target.name));
111397
111562
  const floor = inheritExecutableFloor(
111398
111563
  linked2.flatMap((unit2) => unit2.nativeTargets ?? [])
111399
111564
  )?.find((target) => target.name === "PeachExpoApp")?.deploymentTarget;
@@ -111440,14 +111605,29 @@ async function compileExpoSwiftModulesTraced(root, base2, publishArtifact, optio
111440
111605
  ...linked2.flatMap((unit2) => Object.entries(binaryModules.get(unit2) ?? {}))
111441
111606
  ]);
111442
111607
  projectFor(packagePath).libraries = linkedLibraries.size > 0 ? Object.fromEntries(linkedLibraries) : void 0;
111443
- projectFor(packagePath).nativeTargets = inheritExecutableFloor([
111444
- ...new Map(
111445
- [
111446
- ...linked2.flatMap((unit2) => unit2.nativeTargets ?? []),
111447
- ...provider?.nativeTargets ?? []
111448
- ].map((target) => [target.name, target])
111449
- ).values()
111450
- ]);
111608
+ const releaseFabric = providerTargets.some(
111609
+ (target) => target.name === "TurboCore" && target.cxxDefines?.includes("NDEBUG")
111610
+ );
111611
+ const releaseTargets = new Set(
111612
+ linked2.filter((unit2) => releaseFabric && unit2.reactNativeProvider).flatMap((unit2) => (unit2.nativeTargets ?? []).map((target) => target.name))
111613
+ );
111614
+ const nativeTargets2 = [
111615
+ ...linked2.flatMap((unit2) => unit2.nativeTargets ?? []),
111616
+ ...provider?.nativeTargets ?? []
111617
+ ];
111618
+ const nativeTargetsByName = new Map(
111619
+ nativeTargets2.map((target) => [target.name, target])
111620
+ );
111621
+ projectFor(packagePath).nativeTargets = inheritExecutableFloor(
111622
+ Array.from(
111623
+ nativeTargetsByName.values(),
111624
+ (target) => releaseTargets.has(target.name) ? {
111625
+ ...target,
111626
+ cxxFlags: [...target.cxxFlags, "-DNDEBUG"],
111627
+ importerFlags: [...target.importerFlags, "-DNDEBUG"]
111628
+ } : target
111629
+ )
111630
+ );
111451
111631
  projectFor(packagePath).nativeFiles = Object.assign(
111452
111632
  {},
111453
111633
  ...linked2.map((unit2) => unit2.nativeFiles),
@@ -111986,16 +112166,16 @@ async function compileExpoSwiftModulesTraced(root, base2, publishArtifact, optio
111986
112166
  throw failure2;
111987
112167
  }
111988
112168
  }
111989
- var import_node_async_hooks4, import_node_child_process65, import_node_crypto84, import_node_fs134, import_node_module21, import_node_os29, import_node_path137, import_node_url4, import_node_util18, run11, scriptEnv, EXPO_SWIFT_ENTRY, WITNESS_BATCH, traceStore, discoveryCache, preparedCache, savedFs, ignoredRoots, ownTemporaryRoots, EXPO_MODULE_SCAN_TIMEOUT_MS, preparedExpoSwift, openPreparations, ExpoSwiftLinkRefusal;
112169
+ var import_node_async_hooks5, import_node_child_process65, import_node_crypto84, import_node_fs134, import_node_module21, import_node_os30, import_node_path137, import_node_url4, import_node_util18, run11, scriptEnv, EXPO_SWIFT_ENTRY, WITNESS_BATCH, traceStore, discoveryCache, preparedCache, savedFs, ignoredRoots, ownTemporaryRoots, EXPO_MODULE_SCAN_TIMEOUT_MS, preparedExpoSwift, openPreparations, ExpoSwiftLinkRefusal;
111990
112170
  var init_expo_swift_host = __esm({
111991
112171
  "src/expo-swift-host.ts"() {
111992
112172
  "use strict";
111993
- import_node_async_hooks4 = require("node:async_hooks");
112173
+ import_node_async_hooks5 = require("node:async_hooks");
111994
112174
  import_node_child_process65 = require("node:child_process");
111995
112175
  import_node_crypto84 = require("node:crypto");
111996
112176
  import_node_fs134 = __toESM(require("node:fs"), 1);
111997
112177
  import_node_module21 = require("node:module");
111998
- import_node_os29 = __toESM(require("node:os"), 1);
112178
+ import_node_os30 = __toESM(require("node:os"), 1);
111999
112179
  import_node_path137 = __toESM(require("node:path"), 1);
112000
112180
  import_node_url4 = require("node:url");
112001
112181
  import_node_util18 = require("node:util");
@@ -112033,7 +112213,7 @@ var init_expo_swift_host = __esm({
112033
112213
  scriptEnv = { ...process.env, [PEACH_FORKED_SCRIPT_ENV]: "1" };
112034
112214
  EXPO_SWIFT_ENTRY = "Sources/PeachExpoApp/PeachExpoEntry.swift";
112035
112215
  WITNESS_BATCH = 200;
112036
- traceStore = new import_node_async_hooks4.AsyncLocalStorage();
112216
+ traceStore = new import_node_async_hooks5.AsyncLocalStorage();
112037
112217
  discoveryCache = /* @__PURE__ */ new Map();
112038
112218
  preparedCache = /* @__PURE__ */ new Map();
112039
112219
  savedFs = null;
@@ -113618,7 +113798,7 @@ function extract(bytes, where) {
113618
113798
  const cached2 = pending.get(key2);
113619
113799
  if (cached2) return cached2;
113620
113800
  const request = (async () => {
113621
- const dest = import_node_path147.default.join(import_node_os30.default.tmpdir(), "peach-maven-sources", key2);
113801
+ const dest = import_node_path147.default.join(import_node_os31.default.tmpdir(), "peach-maven-sources", key2);
113622
113802
  const marker = import_node_path147.default.join(dest, ".complete");
113623
113803
  if (!import_node_fs143.default.existsSync(marker)) {
113624
113804
  const sources = zipSources(bytes, where);
@@ -113663,13 +113843,13 @@ function readSourcesJar(archive, where) {
113663
113843
  function readMavenSourcesArchive(archive) {
113664
113844
  return extract(readSourcesJar(archive, archive), archive);
113665
113845
  }
113666
- var import_node_crypto89, import_node_fs143, import_node_os30, import_node_path147, import_node_zlib9, pending, MAX_SOURCES_JAR_BYTES, MAX_SOURCE_ENTRY_BYTES, MAX_TOTAL_EXTRACTED_BYTES;
113846
+ var import_node_crypto89, import_node_fs143, import_node_os31, import_node_path147, import_node_zlib9, pending, MAX_SOURCES_JAR_BYTES, MAX_SOURCE_ENTRY_BYTES, MAX_TOTAL_EXTRACTED_BYTES;
113667
113847
  var init_kotlin_maven_sources = __esm({
113668
113848
  "src/kotlin-maven-sources.ts"() {
113669
113849
  "use strict";
113670
113850
  import_node_crypto89 = require("node:crypto");
113671
113851
  import_node_fs143 = __toESM(require("node:fs"), 1);
113672
- import_node_os30 = __toESM(require("node:os"), 1);
113852
+ import_node_os31 = __toESM(require("node:os"), 1);
113673
113853
  import_node_path147 = __toESM(require("node:path"), 1);
113674
113854
  import_node_zlib9 = require("node:zlib");
113675
113855
  pending = /* @__PURE__ */ new Map();
@@ -116243,7 +116423,7 @@ init_bundleAssets();
116243
116423
  init_expo_native_workspace();
116244
116424
 
116245
116425
  // src/host/staged-host-files.ts
116246
- var import_node_async_hooks5 = require("node:async_hooks");
116426
+ var import_node_async_hooks6 = require("node:async_hooks");
116247
116427
  var import_node_crypto92 = require("node:crypto");
116248
116428
  var import_node_fs148 = __toESM(require("node:fs"), 1);
116249
116429
  var import_node_path152 = __toESM(require("node:path"), 1);
@@ -116352,7 +116532,7 @@ function readPackageManifest() {
116352
116532
  var { routes, bundledFiles } = readPackageManifest();
116353
116533
 
116354
116534
  // src/host/staged-host-files.ts
116355
- var stagedCapture = new import_node_async_hooks5.AsyncLocalStorage();
116535
+ var stagedCapture = new import_node_async_hooks6.AsyncLocalStorage();
116356
116536
  async function captureStagedHostFiles(prepare3) {
116357
116537
  const names = /* @__PURE__ */ new Set();
116358
116538
  const value = await stagedCapture.run(names, prepare3);