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;
@@ -19579,16 +19579,16 @@ var init_react_native_core_digest = __esm({
19579
19579
 
19580
19580
  // src/swift-compiler-digest.ts
19581
19581
  function swiftArchiveCompilerDigestValue() {
19582
- return true ? "172ff559f9865fc0c2a93dedc423889fdbdc66399043a9cd46916c2168556ff2" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname, "archive");
19582
+ return true ? "9f3ce81119383c0a06504b3325d9b5dcd291f804e34d31b83428ee6fa494df7f" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname, "archive");
19583
19583
  }
19584
- var import_node_crypto16, import_node_fs32, import_node_path31, SWIFT_DIGEST_SOURCES, LINKED_IMAGE_SOURCES, SWIFT_ARCHIVE_DIGEST_SOURCES;
19584
+ var import_node_crypto16, import_node_fs32, import_node_os8, import_node_path31, SWIFT_DIGEST_SOURCES, LINKED_IMAGE_SOURCES, SWIFT_ARCHIVE_DIGEST_SOURCES;
19585
19585
  var init_swift_compiler_digest = __esm({
19586
19586
  "src/swift-compiler-digest.ts"() {
19587
19587
  "use strict";
19588
19588
  import_node_crypto16 = require("node:crypto");
19589
19589
  import_node_fs32 = require("node:fs");
19590
+ import_node_os8 = __toESM(require("node:os"), 1);
19590
19591
  import_node_path31 = __toESM(require("node:path"), 1);
19591
- init_swift_objc_sdk_tree();
19592
19592
  SWIFT_DIGEST_SOURCES = [
19593
19593
  "swift-compile.ts",
19594
19594
  "swift-sdk-surface.ts",
@@ -19726,13 +19726,13 @@ var init_swift_standin_digest = __esm({
19726
19726
  ];
19727
19727
  RUNTIME_IMPORT = /(?:^|[;\n])[ \t]*(?:import|export)\s+(?!type(?:\s|\{))([\s\S]*?)\s+from\s*['"]([^'"]+)['"]|(?:^|[;\n])[ \t]*import\s+['"]([^'"]+)['"]|import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
19728
19728
  standinSourceDigest = (srcDir = __sootsim_import_meta_dirname) => sourceClosureDigest(srcDir, STANDIN_DIGEST_ENTRYPOINTS, STANDIN_DIGEST_EXCLUDED_FILES);
19729
- STANDIN_SOURCE_DIGEST = true ? "8b7dccbe4ecedba9dc6511eb4ab2e02ce2922969fcd9eebc93f3280c6529a48b" : standinSourceDigest();
19729
+ STANDIN_SOURCE_DIGEST = true ? "3f378daefc4c950a9d25cfd3184475a07f63966495c86443c5058ef8f9dd3ac9" : standinSourceDigest();
19730
19730
  }
19731
19731
  });
19732
19732
 
19733
19733
  // src/expo-native-compiler-digest.ts
19734
19734
  function expoNativeCompilerDigestValue() {
19735
- return true ? "f47a7fb76e44a6b1c3e603ce0ec1ad8918050fb76250fa190bf2af1845a9fc13" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
19735
+ return true ? "927f2783b6582945ba64b325089d8caee6e1cc9bfab0c71dda18dcd4671c8bd0" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
19736
19736
  }
19737
19737
  var import_node_crypto18;
19738
19738
  var init_expo_native_compiler_digest = __esm({
@@ -20279,7 +20279,7 @@ var init_oneSdkContract = __esm({
20279
20279
 
20280
20280
  // src/one-sdk-preparation.ts
20281
20281
  async function generateAppSdkInChild(generatorFile, frameworks, options2) {
20282
- const directory2 = import_node_fs37.default.mkdtempSync(import_node_path36.default.join(import_node_os8.default.tmpdir(), "peach-one-sdk-"));
20282
+ const directory2 = import_node_fs37.default.mkdtempSync(import_node_path36.default.join(import_node_os9.default.tmpdir(), "peach-one-sdk-"));
20283
20283
  const resultFile = import_node_path36.default.join(directory2, "result.json");
20284
20284
  try {
20285
20285
  const child = (0, import_node_child_process18.spawn)(
@@ -20466,7 +20466,7 @@ async function prepareOneSDKSources(appRoot, output) {
20466
20466
  if (!import_node_fs37.default.existsSync(localManifestPath)) throw error;
20467
20467
  }
20468
20468
  }
20469
- var import_node_child_process18, import_node_crypto20, import_node_fs37, import_node_module7, import_node_os8, import_node_path36, import_node_url2, import_sucrase2, GENERATE_SCRIPT;
20469
+ var import_node_child_process18, import_node_crypto20, import_node_fs37, import_node_module7, import_node_os9, import_node_path36, import_node_url2, import_sucrase2, GENERATE_SCRIPT;
20470
20470
  var init_one_sdk_preparation = __esm({
20471
20471
  "src/one-sdk-preparation.ts"() {
20472
20472
  "use strict";
@@ -20474,7 +20474,7 @@ var init_one_sdk_preparation = __esm({
20474
20474
  import_node_crypto20 = require("node:crypto");
20475
20475
  import_node_fs37 = __toESM(require("node:fs"), 1);
20476
20476
  import_node_module7 = require("node:module");
20477
- import_node_os8 = __toESM(require("node:os"), 1);
20477
+ import_node_os9 = __toESM(require("node:os"), 1);
20478
20478
  import_node_path36 = __toESM(require("node:path"), 1);
20479
20479
  import_node_url2 = require("node:url");
20480
20480
  import_sucrase2 = require("peachsim/vendor/sucrase");
@@ -23488,7 +23488,7 @@ var init_swift_shared_sdk = __esm({
23488
23488
  // src/swift-darwin-records.ts
23489
23489
  function compileDarwinRecords(args) {
23490
23490
  const records = import_node_path39.default.join(args.packageRoot, "Sources/DarwinRecords");
23491
- const runtime = (0, import_node_fs41.mkdtempSync)(import_node_path39.default.join((0, import_node_os9.tmpdir)(), "peach-objc-runtime-"));
23491
+ const runtime = (0, import_node_fs41.mkdtempSync)(import_node_path39.default.join((0, import_node_os10.tmpdir)(), "peach-objc-runtime-"));
23492
23492
  (0, import_node_fs41.symlinkSync)(import_node_path39.default.join(args.darwin, "usr/include/objc"), import_node_path39.default.join(runtime, "objc"));
23493
23493
  const objects = (0, import_node_fs41.readdirSync)(records).filter((file) => file.endsWith(".c") || file.endsWith(".m")).sort((a, b) => a < b ? -1 : a > b ? 1 : 0).map((file) => {
23494
23494
  const object8 = import_node_path39.default.join(
@@ -23531,13 +23531,13 @@ function compileDarwinRecords(args) {
23531
23531
  (0, import_node_fs41.rmSync)(runtime, { recursive: true });
23532
23532
  return objects;
23533
23533
  }
23534
- var import_node_child_process20, import_node_fs41, import_node_os9, import_node_path39, DARWIN_RECORDS_PREFIX, darwinRecordsMinimum;
23534
+ var import_node_child_process20, import_node_fs41, import_node_os10, import_node_path39, DARWIN_RECORDS_PREFIX, darwinRecordsMinimum;
23535
23535
  var init_swift_darwin_records = __esm({
23536
23536
  "src/swift-darwin-records.ts"() {
23537
23537
  "use strict";
23538
23538
  import_node_child_process20 = require("node:child_process");
23539
23539
  import_node_fs41 = require("node:fs");
23540
- import_node_os9 = require("node:os");
23540
+ import_node_os10 = require("node:os");
23541
23541
  import_node_path39 = __toESM(require("node:path"), 1);
23542
23542
  init_swift_objc_platform();
23543
23543
  init_swift_objc_runtime();
@@ -37111,13 +37111,13 @@ var init_swift_source_mask = __esm({
37111
37111
  // src/swift-sdk-surface.ts
37112
37112
  function swiftBuildJobs() {
37113
37113
  const admittedCores = windowAdmission()?.cores ?? Number(process.env.TM_EXEC_CPU_CORES);
37114
- const parallelism = Math.max(1, import_node_os10.default.availableParallelism());
37114
+ const parallelism = Math.max(1, import_node_os11.default.availableParallelism());
37115
37115
  if (!Number.isInteger(admittedCores) || admittedCores <= 0)
37116
37116
  return Math.min(4, Math.max(1, Math.floor(parallelism / 2)));
37117
37117
  const cores = Math.min(admittedCores, parallelism);
37118
37118
  if (process.platform === "darwin") return cores;
37119
37119
  const memory = process.env.TM_EXEC_ADMITTED === "1" && process.env.LINUX_BUILD_SCOPE ? Number(process.env.TM_EXEC_LINUX_MEMORY_MAX) : NaN;
37120
- const effectiveMemory = Number.isSafeInteger(memory) && memory > 0 ? memory : import_node_os10.default.totalmem();
37120
+ const effectiveMemory = Number.isSafeInteger(memory) && memory > 0 ? memory : import_node_os11.default.totalmem();
37121
37121
  const memoryJobs = Math.max(1, Math.floor(effectiveMemory / (2 * 1024 ** 3)));
37122
37122
  return Math.min(cores, memoryJobs);
37123
37123
  }
@@ -37448,6 +37448,16 @@ function swiftMacroPlugins(moduleRoot) {
37448
37448
  stale: [...libraries, ...executables, stamp].some((file) => !(0, import_node_fs55.existsSync)(file)) || (0, import_node_fs55.readFileSync)(stamp, "utf8").trim() !== release
37449
37449
  };
37450
37450
  }
37451
+ function withSwiftModuleDigestScope(fn) {
37452
+ if (moduleDigestScopes.getStore()) return fn();
37453
+ return moduleDigestScopes.run(/* @__PURE__ */ new Map(), fn);
37454
+ }
37455
+ function clearSwiftModuleDigestScope(root) {
37456
+ const scope2 = moduleDigestScopes.getStore();
37457
+ if (!scope2) return;
37458
+ if (root === void 0) scope2.clear();
37459
+ else scope2.delete(import_node_path53.default.resolve(root));
37460
+ }
37451
37461
  function gitCleanModuleInputsKey(root, files2) {
37452
37462
  if (swiftDistributionAt(root)) return null;
37453
37463
  const top = (0, import_node_child_process29.spawnSync)("git", ["-C", root, "rev-parse", "--show-toplevel"], {
@@ -37511,7 +37521,11 @@ function gitCleanModuleInputsKey(root, files2) {
37511
37521
  for (const file of files2) keyHash.update(file).update("\n");
37512
37522
  return keyHash.digest("hex");
37513
37523
  }
37514
- function swiftModuleDigest(root) {
37524
+ function swiftModuleEntry(root) {
37525
+ const scope2 = moduleDigestScopes.getStore();
37526
+ const key2 = import_node_path53.default.resolve(root);
37527
+ const scoped = scope2?.get(key2);
37528
+ if (scoped) return scoped;
37515
37529
  const files2 = swiftModuleInputFiles(root);
37516
37530
  const stampHash = (0, import_node_crypto34.createHash)("sha256");
37517
37531
  for (const file of files2) {
@@ -37524,7 +37538,10 @@ function swiftModuleDigest(root) {
37524
37538
  }
37525
37539
  const stamp = stampHash.digest("hex");
37526
37540
  const cached2 = linkedModuleDigests.get(root);
37527
- if (cached2?.stamp === stamp) return cached2.digest;
37541
+ if (cached2?.stamp === stamp) {
37542
+ scope2?.set(key2, cached2);
37543
+ return cached2;
37544
+ }
37528
37545
  const digestDir = import_node_path53.default.join(swiftCacheDir(), "swift-module-digests");
37529
37546
  const record5 = import_node_path53.default.join(
37530
37547
  digestDir,
@@ -37540,8 +37557,10 @@ function swiftModuleDigest(root) {
37540
37557
  const saved = JSON.parse((0, import_node_fs55.readFileSync)(record5, "utf8"));
37541
37558
  if (saved && typeof saved === "object" && Reflect.get(saved, "stamp") === stamp && typeof Reflect.get(saved, "digest") === "string") {
37542
37559
  const digest3 = Buffer.from(String(Reflect.get(saved, "digest")), "hex");
37543
- linkedModuleDigests.set(root, { stamp, digest: digest3 });
37544
- return digest3;
37560
+ const entry2 = { stamp, digest: digest3 };
37561
+ linkedModuleDigests.set(root, entry2);
37562
+ scope2?.set(key2, entry2);
37563
+ return entry2;
37545
37564
  }
37546
37565
  }
37547
37566
  const gitKey = gitCleanModuleInputsKey(root, files2);
@@ -37551,9 +37570,11 @@ function swiftModuleDigest(root) {
37551
37570
  if (saved && typeof saved === "object" && typeof Reflect.get(saved, "digest") === "string") {
37552
37571
  const hex2 = String(Reflect.get(saved, "digest"));
37553
37572
  const digest3 = Buffer.from(hex2, "hex");
37554
- linkedModuleDigests.set(root, { stamp, digest: digest3 });
37573
+ const entry2 = { stamp, digest: digest3 };
37574
+ linkedModuleDigests.set(root, entry2);
37575
+ scope2?.set(key2, entry2);
37555
37576
  writeRecord(record5, JSON.stringify({ stamp, digest: hex2 }));
37556
- return digest3;
37577
+ return entry2;
37557
37578
  }
37558
37579
  }
37559
37580
  const hash = (0, import_node_crypto34.createHash)("sha256");
@@ -37565,10 +37586,18 @@ function swiftModuleDigest(root) {
37565
37586
  }
37566
37587
  const digest2 = hash.digest();
37567
37588
  const hex = digest2.toString("hex");
37568
- linkedModuleDigests.set(root, { stamp, digest: digest2 });
37589
+ const entry = { stamp, digest: digest2 };
37590
+ linkedModuleDigests.set(root, entry);
37591
+ scope2?.set(key2, entry);
37569
37592
  writeRecord(record5, JSON.stringify({ stamp, digest: hex }));
37570
37593
  if (gitRecord) writeRecord(gitRecord, JSON.stringify({ digest: hex }));
37571
- return digest2;
37594
+ return entry;
37595
+ }
37596
+ function swiftModuleDigest(root) {
37597
+ return swiftModuleEntry(root).digest;
37598
+ }
37599
+ function swiftModuleStamp(root) {
37600
+ return swiftModuleEntry(root).stamp;
37572
37601
  }
37573
37602
  function swiftCompileSurfaceDigest(root) {
37574
37603
  const distribution = swiftDistributionAt(root);
@@ -37659,8 +37688,10 @@ function* swiftConditionalLines(contents2, available2, defines) {
37659
37688
  }
37660
37689
  }
37661
37690
  function swiftImportNames(contents2, available2, defines) {
37662
- if (available2 === void 0 && defines === void 0) {
37663
- const cached2 = importNamesCache.get(contents2);
37691
+ if (!contents2.includes("import")) return [];
37692
+ const definesKey = available2 === void 0 ? defines ? [...defines].sort().join("\0") : "" : void 0;
37693
+ if (definesKey !== void 0) {
37694
+ const cached2 = importNamesCache.get(definesKey)?.get(contents2);
37664
37695
  if (cached2 !== void 0) return cached2;
37665
37696
  }
37666
37697
  const names = [];
@@ -37669,8 +37700,14 @@ function swiftImportNames(contents2, available2, defines) {
37669
37700
  const name3 = SWIFT_IMPORT.exec(line)?.[1];
37670
37701
  if (name3) names.push(name3);
37671
37702
  }
37672
- if (available2 === void 0 && defines === void 0)
37673
- importNamesCache.set(contents2, names);
37703
+ if (definesKey !== void 0) {
37704
+ let bucket = importNamesCache.get(definesKey);
37705
+ if (!bucket) {
37706
+ bucket = /* @__PURE__ */ new Map();
37707
+ importNamesCache.set(definesKey, bucket);
37708
+ }
37709
+ bucket.set(contents2, names);
37710
+ }
37674
37711
  return names;
37675
37712
  }
37676
37713
  function swiftPeachModules(moduleRoot) {
@@ -37960,11 +37997,15 @@ function swiftCTakesReturnAddress(source) {
37960
37997
  cActiveCode(stripCCode(source), wasmMacroEnvironment)
37961
37998
  );
37962
37999
  }
37963
- function swiftModuleCompiler(root) {
38000
+ function swiftModuleRelease(root) {
37964
38001
  const pin2 = swiftDistributionAt(root) ?? JSON.parse((0, import_node_fs55.readFileSync)(import_node_path53.default.join(root, "toolchain.json"), "utf8"));
38002
+ return pin2.release;
38003
+ }
38004
+ function swiftModuleCompiler(root) {
38005
+ const release = swiftModuleRelease(root);
37965
38006
  return {
37966
- release: pin2.release,
37967
- toolchainBin: swiftCompiler(pin2.release)
38007
+ release,
38008
+ toolchainBin: swiftCompiler(release)
37968
38009
  };
37969
38010
  }
37970
38011
  function swiftModuleToolchain(root) {
@@ -37977,14 +38018,15 @@ function remoteSwiftCheckouts(root) {
37977
38018
  (0, import_node_fs55.mkdirSync)(cache, { recursive: true });
37978
38019
  return import_node_path53.default.join((0, import_node_fs55.realpathSync)(cache), "swift-packages", key2, "checkouts");
37979
38020
  }
37980
- var import_node_child_process29, import_node_crypto34, import_node_fs55, import_node_os10, import_node_path53, 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;
38021
+ var import_node_async_hooks2, import_node_child_process29, import_node_crypto34, import_node_fs55, import_node_os11, import_node_path53, 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;
37981
38022
  var init_swift_sdk_surface = __esm({
37982
38023
  "src/swift-sdk-surface.ts"() {
37983
38024
  "use strict";
38025
+ import_node_async_hooks2 = require("node:async_hooks");
37984
38026
  import_node_child_process29 = require("node:child_process");
37985
38027
  import_node_crypto34 = require("node:crypto");
37986
38028
  import_node_fs55 = require("node:fs");
37987
- import_node_os10 = __toESM(require("node:os"), 1);
38029
+ import_node_os11 = __toESM(require("node:os"), 1);
37988
38030
  import_node_path53 = __toESM(require("node:path"), 1);
37989
38031
  init_swift_source_mask();
37990
38032
  init_admitted_mac_build();
@@ -38018,6 +38060,7 @@ var init_swift_sdk_surface = __esm({
38018
38060
  ].map((m) => m[1])
38019
38061
  ]);
38020
38062
  linkedModuleDigests = /* @__PURE__ */ new Map();
38063
+ moduleDigestScopes = new import_node_async_hooks2.AsyncLocalStorage();
38021
38064
  compileSurfaces = /* @__PURE__ */ new WeakMap();
38022
38065
  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_]*)/;
38023
38066
  kleeneNot = (value) => value === void 0 ? void 0 : !value;
@@ -38457,7 +38500,7 @@ function dumpInputs(dir, xcode) {
38457
38500
  swiftCodeScan(source).lineStarts,
38458
38501
  (line) => line.replace(
38459
38502
  MANIFEST_HOST_OS,
38460
- (match, os25) => (os25 === "macOS" ? "true" : "false").padEnd(match.length)
38503
+ (match, os26) => (os26 === "macOS" ? "true" : "false").padEnd(match.length)
38461
38504
  )
38462
38505
  );
38463
38506
  if (projected !== source) overlays.push({ name: name3, source: projected });
@@ -38904,7 +38947,7 @@ let package = Package(
38904
38947
  ]
38905
38948
  )
38906
38949
  `;
38907
- const dir = import_node_fs56.default.mkdtempSync(import_node_path54.default.join(import_node_os11.default.tmpdir(), "peach-resolve-"));
38950
+ const dir = import_node_fs56.default.mkdtempSync(import_node_path54.default.join(import_node_os12.default.tmpdir(), "peach-resolve-"));
38908
38951
  import_node_fs56.default.writeFileSync(import_node_path54.default.join(dir, "Package.swift"), manifest);
38909
38952
  const args = [
38910
38953
  "package",
@@ -38971,14 +39014,14 @@ function swiftTargetFiles(manifest, target) {
38971
39014
  }
38972
39015
  return [...new Set(files2)].sort();
38973
39016
  }
38974
- var import_node_child_process30, import_node_crypto35, import_node_fs56, import_node_os11, import_node_path54, import_node_util7, TARGET_TYPES, targetRelative, isTargetType, record2, array5, string5, swiftCommand, cacheDir2, evaluated, execFileAsync2, cachedToolchain, SwiftManifestPreparationRequired, MANIFEST_HOST_OS, manifestPreparations, GUEST_PLATFORMS, within, requirementClause;
39017
+ var import_node_child_process30, import_node_crypto35, import_node_fs56, import_node_os12, import_node_path54, import_node_util7, TARGET_TYPES, targetRelative, isTargetType, record2, array5, string5, swiftCommand, cacheDir2, evaluated, execFileAsync2, cachedToolchain, SwiftManifestPreparationRequired, MANIFEST_HOST_OS, manifestPreparations, GUEST_PLATFORMS, within, requirementClause;
38975
39018
  var init_swift_package_manifest = __esm({
38976
39019
  "src/swift-package-manifest.ts"() {
38977
39020
  "use strict";
38978
39021
  import_node_child_process30 = require("node:child_process");
38979
39022
  import_node_crypto35 = require("node:crypto");
38980
39023
  import_node_fs56 = __toESM(require("node:fs"), 1);
38981
- import_node_os11 = __toESM(require("node:os"), 1);
39024
+ import_node_os12 = __toESM(require("node:os"), 1);
38982
39025
  import_node_path54 = __toESM(require("node:path"), 1);
38983
39026
  import_node_util7 = require("node:util");
38984
39027
  init_git_repo_env();
@@ -39163,7 +39206,7 @@ function swiftHostLibraryView(root, executables) {
39163
39206
  }
39164
39207
  const triple = process.arch === "x64" ? "x86_64-linux-gnu" : "aarch64-linux-gnu";
39165
39208
  const libraries = import_node_path55.default.join(root, "usr/lib", triple);
39166
- const view = import_node_fs57.default.mkdtempSync(import_node_path55.default.join(import_node_os12.default.tmpdir(), "peach-swift-libraries-"));
39209
+ const view = import_node_fs57.default.mkdtempSync(import_node_path55.default.join(import_node_os13.default.tmpdir(), "peach-swift-libraries-"));
39167
39210
  const linked = /* @__PURE__ */ new Set();
39168
39211
  try {
39169
39212
  while (missing.length) {
@@ -39186,7 +39229,7 @@ function swiftHostLibraryView(root, executables) {
39186
39229
  }
39187
39230
  async function installSwiftToolchain(release, sdk2, signal, compilerOnly = false) {
39188
39231
  const root = import_node_path55.default.resolve(swiftToolchainBin(release), "../..");
39189
- const owned = process.platform === "darwin" ? import_node_path55.default.join(import_node_os12.default.homedir(), "Library/Developer/Toolchains", `${release}.xctoolchain`) : import_node_path55.default.join(rnxHomeDir(), "swift", "toolchains", release);
39232
+ const owned = process.platform === "darwin" ? import_node_path55.default.join(import_node_os13.default.homedir(), "Library/Developer/Toolchains", `${release}.xctoolchain`) : import_node_path55.default.join(rnxHomeDir(), "swift", "toolchains", release);
39190
39233
  const selectedCompiler = process.platform === "darwin" && import_node_fs57.default.existsSync(import_node_path55.default.join(root, "usr/bin/swift"));
39191
39234
  const ownsCompiler = release.includes("-custom-") && root === owned && !selectedCompiler;
39192
39235
  const executables = ["swift", "swift-package", "swift-frontend", "wasm-ld"].map(
@@ -39301,13 +39344,13 @@ async function resolveSwiftPackageRequirementsAsync(requirements, destination, s
39301
39344
  import_node_fs57.default.rmSync(dir, { recursive: true, force: true });
39302
39345
  }
39303
39346
  }
39304
- var import_node_child_process31, import_node_fs57, import_node_os12, import_node_path55, import_node_util8, SWIFT_ENDPOINT_ENV, DEFAULT_SWIFT_ENDPOINT, installs, staleWarned, hostLibraryViews;
39347
+ var import_node_child_process31, import_node_fs57, import_node_os13, import_node_path55, import_node_util8, SWIFT_ENDPOINT_ENV, DEFAULT_SWIFT_ENDPOINT, installs, staleWarned, hostLibraryViews;
39305
39348
  var init_swift_distribution = __esm({
39306
39349
  "src/swift-distribution.ts"() {
39307
39350
  "use strict";
39308
39351
  import_node_child_process31 = require("node:child_process");
39309
39352
  import_node_fs57 = __toESM(require("node:fs"), 1);
39310
- import_node_os12 = __toESM(require("node:os"), 1);
39353
+ import_node_os13 = __toESM(require("node:os"), 1);
39311
39354
  import_node_path55 = __toESM(require("node:path"), 1);
39312
39355
  import_node_util8 = require("node:util");
39313
39356
  init_src();
@@ -39437,7 +39480,7 @@ function rootLockKey(root) {
39437
39480
  return import_node_path56.default.join(backingPath, ...missing);
39438
39481
  }
39439
39482
  function swiftRootLocksDir() {
39440
- return import_node_path56.default.join((0, import_node_os13.homedir)(), ".peach", "cache", "swift-root-locks");
39483
+ return import_node_path56.default.join((0, import_node_os14.homedir)(), ".peach", "cache", "swift-root-locks");
39441
39484
  }
39442
39485
  function withSwiftRootReadHolds(work) {
39443
39486
  const holds = [];
@@ -39619,15 +39662,15 @@ async function withSwiftRootLock(root, work, signal, wait = true) {
39619
39662
  (0, import_node_fs58.writeFileSync)(import_node_path56.default.join(directory2, name2(held, "released")), "");
39620
39663
  }
39621
39664
  }
39622
- var import_node_async_hooks2, import_node_child_process32, import_node_crypto36, import_node_fs58, import_node_os13, import_node_path56, POLL_MS, INSPECT_ATTEMPTS, START_TOLERANCE_MS, name2, swiftRootReadHolds;
39665
+ var import_node_async_hooks3, import_node_child_process32, import_node_crypto36, import_node_fs58, import_node_os14, import_node_path56, POLL_MS, INSPECT_ATTEMPTS, START_TOLERANCE_MS, name2, swiftRootReadHolds;
39623
39666
  var init_swift_root_lock = __esm({
39624
39667
  "src/swift-root-lock.ts"() {
39625
39668
  "use strict";
39626
- import_node_async_hooks2 = require("node:async_hooks");
39669
+ import_node_async_hooks3 = require("node:async_hooks");
39627
39670
  import_node_child_process32 = require("node:child_process");
39628
39671
  import_node_crypto36 = require("node:crypto");
39629
39672
  import_node_fs58 = require("node:fs");
39630
- import_node_os13 = require("node:os");
39673
+ import_node_os14 = require("node:os");
39631
39674
  import_node_path56 = __toESM(require("node:path"), 1);
39632
39675
  init_process_group();
39633
39676
  init_process_table();
@@ -39635,7 +39678,7 @@ var init_swift_root_lock = __esm({
39635
39678
  INSPECT_ATTEMPTS = 5;
39636
39679
  START_TOLERANCE_MS = 2e3;
39637
39680
  name2 = (number3, suffix) => `${String(number3).padStart(12, "0")}.${suffix}`;
39638
- swiftRootReadHolds = new import_node_async_hooks2.AsyncLocalStorage();
39681
+ swiftRootReadHolds = new import_node_async_hooks3.AsyncLocalStorage();
39639
39682
  }
39640
39683
  });
39641
39684
 
@@ -39780,7 +39823,7 @@ function producerSettled(directory2) {
39780
39823
  const value = JSON.parse((0, import_node_fs59.readFileSync)(receipt, "utf8"));
39781
39824
  return isRecord(value) && value.released === true;
39782
39825
  }
39783
- function swiftSdkProducerCores(admitted, platform = process.platform, hostCpus = import_node_os14.default.availableParallelism()) {
39826
+ function swiftSdkProducerCores(admitted, platform = process.platform, hostCpus = import_node_os15.default.availableParallelism()) {
39784
39827
  const floor = platform === "linux" && hostCpus >= 64 ? 24 : 4;
39785
39828
  return Number.isSafeInteger(admitted) && admitted > 0 ? Math.max(floor, admitted) : floor;
39786
39829
  }
@@ -39927,14 +39970,14 @@ async function produceSwiftSdkImage(input) {
39927
39970
  await (0, import_promises6.setTimeout)(2e3, void 0, { signal: input.signal });
39928
39971
  }
39929
39972
  }
39930
- var import_node_child_process33, import_node_crypto38, import_node_fs59, import_node_os14, import_node_path57, import_promises6, import_node_util9, run3, environmentNames, launcher;
39973
+ var import_node_child_process33, import_node_crypto38, import_node_fs59, import_node_os15, import_node_path57, import_promises6, import_node_util9, run3, environmentNames, launcher;
39931
39974
  var init_swift_sdk_image_producer = __esm({
39932
39975
  "src/swift-sdk-image-producer.ts"() {
39933
39976
  "use strict";
39934
39977
  import_node_child_process33 = require("node:child_process");
39935
39978
  import_node_crypto38 = require("node:crypto");
39936
39979
  import_node_fs59 = require("node:fs");
39937
- import_node_os14 = __toESM(require("node:os"), 1);
39980
+ import_node_os15 = __toESM(require("node:os"), 1);
39938
39981
  import_node_path57 = __toESM(require("node:path"), 1);
39939
39982
  import_promises6 = require("node:timers/promises");
39940
39983
  import_node_util9 = require("node:util");
@@ -43794,7 +43837,7 @@ function swiftIcuAddress(icu) {
43794
43837
  function swiftIcuPacked(icu) {
43795
43838
  return memo(packedFiles, icu.sha256, async () => {
43796
43839
  const file = import_node_path63.default.join(
43797
- import_node_os15.default.homedir(),
43840
+ import_node_os16.default.homedir(),
43798
43841
  ".peach",
43799
43842
  "cache",
43800
43843
  "swift-brotli",
@@ -43821,7 +43864,7 @@ async function swiftIcuBundleAsset(icu) {
43821
43864
  contentType: "application/octet-stream"
43822
43865
  };
43823
43866
  }
43824
- var import_node_child_process37, import_node_crypto42, import_node_fs64, import_promises7, import_node_os15, import_node_path63, import_node_util12, import_node_zlib5, run6, deflate, compressBrotli, inflateGzip, ARCHIVE, MEMBER, raw, assets, packedFiles;
43867
+ var import_node_child_process37, import_node_crypto42, import_node_fs64, import_promises7, import_node_os16, import_node_path63, import_node_util12, import_node_zlib5, run6, deflate, compressBrotli, inflateGzip, ARCHIVE, MEMBER, raw, assets, packedFiles;
43825
43868
  var init_swift_icu = __esm({
43826
43869
  "src/swift-icu.ts"() {
43827
43870
  "use strict";
@@ -43829,7 +43872,7 @@ var init_swift_icu = __esm({
43829
43872
  import_node_crypto42 = require("node:crypto");
43830
43873
  import_node_fs64 = require("node:fs");
43831
43874
  import_promises7 = require("node:fs/promises");
43832
- import_node_os15 = __toESM(require("node:os"), 1);
43875
+ import_node_os16 = __toESM(require("node:os"), 1);
43833
43876
  import_node_path63 = __toESM(require("node:path"), 1);
43834
43877
  import_node_util12 = require("node:util");
43835
43878
  import_node_zlib5 = require("node:zlib");
@@ -44118,7 +44161,7 @@ var init_swift_objc_prebuilt = __esm({
44118
44161
 
44119
44162
  // src/swift-reproducible.ts
44120
44163
  function canonicalHomeDir() {
44121
- const home = import_node_os16.default.homedir();
44164
+ const home = import_node_os17.default.homedir();
44122
44165
  const dotPeach = import_node_path66.default.join(home, ".peach");
44123
44166
  if ((0, import_node_fs67.existsSync)(dotPeach)) {
44124
44167
  const realHome = import_node_path66.default.dirname((0, import_node_fs67.realpathSync)(dotPeach));
@@ -44140,12 +44183,12 @@ function swiftReproducibleBuildFlags(roots) {
44140
44183
  `-ffile-prefix-map=${map2}`
44141
44184
  ]);
44142
44185
  }
44143
- var import_node_fs67, import_node_os16, import_node_path66;
44186
+ var import_node_fs67, import_node_os17, import_node_path66;
44144
44187
  var init_swift_reproducible = __esm({
44145
44188
  "src/swift-reproducible.ts"() {
44146
44189
  "use strict";
44147
44190
  import_node_fs67 = require("node:fs");
44148
- import_node_os16 = __toESM(require("node:os"), 1);
44191
+ import_node_os17 = __toESM(require("node:os"), 1);
44149
44192
  import_node_path66 = __toESM(require("node:path"), 1);
44150
44193
  }
44151
44194
  });
@@ -44421,7 +44464,10 @@ function swiftPackagePrebuiltEntries(input, moduleRoot, toolchainBin) {
44421
44464
  const calls = manifestCalls(manifest, ["target"]);
44422
44465
  const platform = /platforms:\s*\[\.iOS\("([\d.]+)"\)\]/.exec(manifest)?.[1];
44423
44466
  if (!platform) return [];
44424
- const sdkModules = swiftAvailableModules(moduleRoot, toolchainBin);
44467
+ const sdkModules = swiftAvailableModules(
44468
+ moduleRoot,
44469
+ typeof toolchainBin === "function" ? toolchainBin() : toolchainBin
44470
+ );
44425
44471
  return selected.flatMap(([name3, modules]) => {
44426
44472
  const prefix = `${SWIFT_REMOTE_PACKAGES_DIR}/${name3}/`;
44427
44473
  const members2 = targets.filter(
@@ -44638,7 +44684,7 @@ async function runCompiler(command, args, options2, stream = false, quiet) {
44638
44684
  }
44639
44685
  }
44640
44686
  function swiftCompilerJobs() {
44641
- return Math.min(64, swiftBuildJobs(), Math.max(1, Math.floor(import_node_os17.default.totalmem() / 2 ** 31)));
44687
+ return Math.min(64, swiftBuildJobs(), Math.max(1, Math.floor(import_node_os18.default.totalmem() / 2 ** 31)));
44642
44688
  }
44643
44689
  function swiftCompilerBaseEnv(toolchainBin, sourceEnv, includePeachHome = false) {
44644
44690
  const env = {};
@@ -45994,6 +46040,8 @@ function swiftSourceClosure(files2, roots) {
45994
46040
  return collectSwiftSourceClosure(files2, roots, swiftCodeMask);
45995
46041
  }
45996
46042
  function swiftApplicationEntry(file, source) {
46043
+ if (!source.includes("@main") && !source.includes("@UIApplicationMain") && !(import_node_path70.default.basename(file) === "main.swift" && source.includes("UIApplicationMain")))
46044
+ return false;
45997
46045
  const code = [...swiftConditionalLines(swiftCodeMask(source))].map(({ line, active }) => active === false ? " ".repeat(line.length) : line).join("\n");
45998
46046
  const { tokens: tokens2 } = swiftCodeScan(code);
45999
46047
  let depth = 0;
@@ -48754,8 +48802,8 @@ function readFrameworkProductsReceipt(scratch2, receiptKey, planChangedAt = 0n)
48754
48802
  function resolveBunBinary() {
48755
48803
  if (import_node_path70.default.basename(process.execPath).startsWith("bun")) return process.execPath;
48756
48804
  for (const candidate of [
48757
- import_node_path70.default.join(import_node_os17.default.homedir(), "builders/bun/bin/bun"),
48758
- import_node_path70.default.join(import_node_os17.default.homedir(), ".bun/bin/bun"),
48805
+ import_node_path70.default.join(import_node_os18.default.homedir(), "builders/bun/bin/bun"),
48806
+ import_node_path70.default.join(import_node_os18.default.homedir(), ".bun/bin/bun"),
48759
48807
  "/opt/homebrew/bin/bun",
48760
48808
  "/usr/local/bin/bun",
48761
48809
  "bun"
@@ -49102,18 +49150,18 @@ ${args.frameworkKey}`,
49102
49150
  function swiftFrameworkSlotCount(unoptimized) {
49103
49151
  const base = unoptimized ? SWIFT_FRAMEWORK_UNOPTIMIZED_SLOTS : SWIFT_FRAMEWORK_SLOTS;
49104
49152
  if (process.platform === "darwin") {
49105
- const gib = import_node_os17.default.totalmem() / (1024 * 1024 * 1024);
49153
+ const gib = import_node_os18.default.totalmem() / (1024 * 1024 * 1024);
49106
49154
  if (gib >= 120) return unoptimized ? 8 : 16;
49107
49155
  if (gib >= 56) return unoptimized ? 6 : 12;
49108
49156
  return base;
49109
49157
  }
49110
49158
  if (process.platform !== "linux") return base;
49111
- const cores = import_node_os17.default.availableParallelism();
49159
+ const cores = import_node_os18.default.availableParallelism();
49112
49160
  return unoptimized ? Math.min(8, Math.max(base, Math.floor(cores / 16))) : Math.min(16, Math.max(base, Math.floor(cores / 8)));
49113
49161
  }
49114
49162
  function swiftBuildRootSlotCount() {
49115
49163
  if (process.platform !== "linux") return SWIFT_BUILD_ROOT_SLOTS;
49116
- return import_node_os17.default.availableParallelism() >= 64 ? 8 : SWIFT_BUILD_ROOT_SLOTS;
49164
+ return import_node_os18.default.availableParallelism() >= 64 ? 8 : SWIFT_BUILD_ROOT_SLOTS;
49117
49165
  }
49118
49166
  function swiftFrameworksDir(unoptimized = false) {
49119
49167
  return import_node_path70.default.join(
@@ -49511,818 +49559,865 @@ async function compileSwiftProjectUnit(input, options2) {
49511
49559
  }
49512
49560
  }
49513
49561
  async function compileSwiftProjectOnce(sources, options2) {
49514
- options2.signal?.throwIfAborted();
49515
- assertSwiftBuildCores();
49516
- (0, import_node_fs70.mkdirSync)(options2.buildRoot, { recursive: true });
49517
- const root = (0, import_node_fs70.realpathSync)(options2.buildRoot);
49518
- refreshSwiftCacheHold(root);
49519
- const moduleRoot = import_node_path70.default.resolve(options2.moduleRoot);
49520
- const distribution = swiftDistributionAt(moduleRoot);
49521
- const mirrorDistribution = options2.linkOnly || options2.project ? null : distribution;
49522
- if (distribution) refreshSwiftCacheHold(moduleRoot);
49523
- const input = distribution && !options2.intermediates ? (await Promise.resolve().then(() => (init_swift_package_prebuilt(), swift_package_prebuilt_exports))).useSwiftPackagePrebuilts(
49524
- sources,
49525
- moduleRoot,
49526
- options2.toolchainBin
49527
- ) : sources;
49528
- const guestGraph = distribution ? input.sourceLinkGraph : void 0;
49529
- if (options2.linkOnly && guestGraph)
49530
- throw new Error("swift-compile: link-only builds do not support guest image graphs");
49531
- const layout2 = {
49532
- root,
49533
- sources: import_node_path70.default.join(root, "Sources", "App"),
49534
- multi: compileTargets(input).length > 0
49535
- };
49536
- const sdkImage = options2.linkOnly ? void 0 : await (await Promise.resolve().then(() => (init_swift_sdk_image(), swift_sdk_image_exports))).buildSwiftSdkImage(
49537
- moduleRoot,
49538
- !!guestGraph,
49539
- distribution ? [] : linkedFrameworkTargets(moduleRoot, input).imports,
49540
- { signal: options2.signal }
49541
- );
49542
- const inputHash = swiftCompileInputHash(input, options2.release);
49543
- const moduleDigest = swiftModuleDigest(moduleRoot);
49544
- const sourceHash = inputHash.copy().update(moduleDigest).digest("hex");
49545
- const hash = sdkImage ? swiftSdkArtifactHash(sourceHash, sdkImage.key) : sourceHash;
49546
- const frameworkKey = swiftProjectBuildKey(moduleRoot, options2.release);
49547
- const sharedRoot = import_node_path70.default.join(swiftCacheDir(), "swift-projects", hash);
49548
- const report = (message) => {
49549
- console.error(`[swift-project ${hash.slice(0, 16)}] ${message}`);
49550
- options2.onStage?.(message);
49551
- };
49552
- return serialize(
49553
- root,
49554
- async () => {
49555
- if (!options2.intermediates) {
49556
- report("checking verified artifacts");
49557
- const retained = retainedArtifacts.get(root)?.find((old) => old.hash === hash);
49558
- if (retained) {
49559
- report("reusing memory artifact");
49560
- return retain(root, retained);
49561
- }
49562
- const cached2 = readCompiledArtifact(import_node_path70.default.join(sharedRoot, "artifact"), hash);
49563
- const previous = cached2 ?? (options2.project ? null : readCompiledArtifact(import_node_path70.default.join(root, "artifact"), hash));
49564
- if (previous) {
49565
- if (cached2) renewSharedArtifact(sharedRoot);
49566
- else saveSharedArtifact(sharedRoot, previous);
49567
- report("reusing verified disk artifact");
49568
- return retain(root, previous);
49569
- }
49570
- }
49571
- const baseRoot = root;
49572
- const canPoolBuildRoot = !options2.intermediates && !options2.project && !options2.linkOnly && import_node_path70.default.basename(import_node_path70.default.dirname(baseRoot)) === "swift-builds";
49573
- const compatShapeParts = canPoolBuildRoot ? [
49574
- distribution ? options2.release : frameworkKey,
49575
- compileTargets(input).map((target) => target.name).sort(),
49576
- input.oneModule === true,
49577
- input.optimize === true,
49578
- input.unoptimized === true
49579
- ] : null;
49580
- const compatShape = compatShapeParts ? (0, import_node_crypto45.createHash)("sha256").update(JSON.stringify(compatShapeParts)).digest("hex").slice(0, 16) : "";
49581
- const exactShape = compatShapeParts ? (0, import_node_crypto45.createHash)("sha256").update(
49582
- JSON.stringify([...compatShapeParts, Object.keys(input.files).sort()])
49583
- ).digest("hex").slice(0, 16) : "";
49584
- const buildShape = compatShapeParts ? `${exactShape}
49585
- ${compatShape}` : "";
49586
- return withSwiftCompileBudget(options2.timeoutMs, options2.signal, async (budget) => {
49587
- const stage = (message) => {
49588
- budget.progress();
49589
- report(message);
49590
- };
49591
- const runLocked = (work) => {
49592
- const runInBuildRoot = () => {
49593
- if (canPoolBuildRoot)
49594
- return withSwiftBuildRootSlot(
49595
- baseRoot,
49596
- exactShape,
49597
- compatShape,
49598
- budget.signal,
49599
- work
49600
- );
49601
- const waitStart = Date.now();
49602
- return withSwiftRootLock(
49603
- baseRoot,
49604
- (lease) => work(baseRoot, lease, Date.now() - waitStart),
49605
- budget.signal
49606
- );
49607
- };
49608
- if (options2.intermediates || baseRoot === sharedRoot) return runInBuildRoot();
49609
- return withSwiftRootLock(
49610
- sharedRoot,
49611
- async () => {
49612
- const built2 = readCompiledArtifact(import_node_path70.default.join(sharedRoot, "artifact"), hash);
49613
- if (built2) {
49614
- renewSharedArtifact(sharedRoot);
49615
- stage("reusing verified disk artifact");
49616
- return retain(baseRoot, built2);
49617
- }
49618
- return runInBuildRoot();
49619
- },
49620
- budget.signal
49621
- );
49622
- };
49623
- return runLocked(async (slotRoot, lease, waitedMs) => {
49624
- const root2 = slotRoot;
49625
- const layout3 = {
49626
- root: root2,
49627
- sources: import_node_path70.default.join(root2, "Sources", "App"),
49628
- multi: compileTargets(input).length > 0
49629
- };
49630
- if (!options2.intermediates) {
49631
- const built2 = readCompiledArtifact(import_node_path70.default.join(sharedRoot, "artifact"), hash);
49632
- if (built2) {
49633
- stage("reusing verified disk artifact");
49634
- return retain(baseRoot, built2);
49635
- }
49636
- }
49637
- if (waitedMs >= 1e3)
49638
- report(`acquired build root ${import_node_path70.default.basename(root2)} after ${waitedMs}ms`);
49639
- if (canPoolBuildRoot) {
49640
- refreshSwiftCacheHold(root2);
49641
- (0, import_node_fs70.writeFileSync)(import_node_path70.default.join(root2, SWIFT_BUILD_ROOT_SHAPE), buildShape);
49562
+ return withSwiftModuleDigestScope(async () => {
49563
+ options2.signal?.throwIfAborted();
49564
+ (0, import_node_fs70.mkdirSync)(options2.buildRoot, { recursive: true });
49565
+ const root = (0, import_node_fs70.realpathSync)(options2.buildRoot);
49566
+ refreshSwiftCacheHold(root);
49567
+ const moduleRoot = import_node_path70.default.resolve(options2.moduleRoot);
49568
+ const distribution = swiftDistributionAt(moduleRoot);
49569
+ const mirrorDistribution = options2.linkOnly || options2.project ? null : distribution;
49570
+ if (distribution) refreshSwiftCacheHold(moduleRoot);
49571
+ let resolvedToolchainBin = options2.toolchainBin;
49572
+ const resolveToolchainBin = () => {
49573
+ if (resolvedToolchainBin) return resolvedToolchainBin;
49574
+ if (!options2.resolveToolchain)
49575
+ throw new Error("swift-compile: missing toolchainBin");
49576
+ resolvedToolchainBin = options2.resolveToolchain();
49577
+ return resolvedToolchainBin;
49578
+ };
49579
+ const input = distribution && !options2.intermediates ? (await Promise.resolve().then(() => (init_swift_package_prebuilt(), swift_package_prebuilt_exports))).useSwiftPackagePrebuilts(
49580
+ sources,
49581
+ moduleRoot,
49582
+ resolveToolchainBin
49583
+ ) : sources;
49584
+ const guestGraph = distribution ? input.sourceLinkGraph : void 0;
49585
+ if (options2.linkOnly && guestGraph)
49586
+ throw new Error("swift-compile: link-only builds do not support guest image graphs");
49587
+ const layout2 = {
49588
+ root,
49589
+ sources: import_node_path70.default.join(root, "Sources", "App"),
49590
+ multi: compileTargets(input).length > 0
49591
+ };
49592
+ const sdkImage = options2.linkOnly ? void 0 : await (await Promise.resolve().then(() => (init_swift_sdk_image(), swift_sdk_image_exports))).buildSwiftSdkImage(
49593
+ moduleRoot,
49594
+ !!guestGraph,
49595
+ distribution ? [] : linkedFrameworkTargets(moduleRoot, input).imports,
49596
+ { signal: options2.signal }
49597
+ );
49598
+ const inputHash = swiftCompileInputHash(input, options2.release);
49599
+ const moduleDigest = swiftModuleDigest(moduleRoot);
49600
+ const sourceHash = inputHash.copy().update(moduleDigest).digest("hex");
49601
+ const hash = sdkImage ? swiftSdkArtifactHash(sourceHash, sdkImage.key) : sourceHash;
49602
+ const sharedRoot = import_node_path70.default.join(swiftCacheDir(), "swift-projects", hash);
49603
+ const report = (message) => {
49604
+ console.error(`[swift-project ${hash.slice(0, 16)}] ${message}`);
49605
+ options2.onStage?.(message);
49606
+ };
49607
+ return serialize(
49608
+ root,
49609
+ async () => {
49610
+ if (!options2.intermediates) {
49611
+ report("checking verified artifacts");
49612
+ const retained = retainedArtifacts.get(root)?.find((old) => old.hash === hash);
49613
+ if (retained) {
49614
+ report("reusing memory artifact");
49615
+ return retain(root, retained);
49642
49616
  }
49643
- const swift = import_node_path70.default.join(options2.toolchainBin, "swift");
49644
- if (!(0, import_node_fs70.existsSync)(swift)) {
49645
- throw new Error(
49646
- `swift-compile: no swift.org toolchain at ${options2.toolchainBin}; install ${options2.release} and its matching wasm sdk`
49647
- );
49617
+ const cached2 = readCompiledArtifact(import_node_path70.default.join(sharedRoot, "artifact"), hash);
49618
+ const previous = cached2 ?? (options2.project ? null : readCompiledArtifact(import_node_path70.default.join(root, "artifact"), hash));
49619
+ if (previous) {
49620
+ if (cached2) renewSharedArtifact(sharedRoot);
49621
+ else saveSharedArtifact(sharedRoot, previous);
49622
+ report("reusing verified disk artifact");
49623
+ return retain(root, previous);
49648
49624
  }
49649
- const unoptimized = input.unoptimized === true;
49650
- const baseBuildEnv = options2.project?.env ? {
49651
- ...options2.project.env,
49652
- // shipped host plugins resolve against the selected compiler's runtime.
49653
- ...process.platform === "linux" ? {
49654
- LD_LIBRARY_PATH: [
49655
- import_node_path70.default.resolve(options2.toolchainBin, "../lib/swift/linux"),
49656
- import_node_path70.default.resolve(options2.toolchainBin, "../lib/swift/host"),
49657
- process.env.LD_LIBRARY_PATH
49658
- ].filter(Boolean).join(":")
49659
- } : {},
49660
- PEACH_DEFER_WASM_LINK: "1"
49661
- } : swiftCompilerBaseEnv(options2.toolchainBin, process.env);
49662
- const prepareFrameworks = async (slot, frameworkLease, allowWrite = true) => {
49663
- if (allowWrite) budget.startCompile();
49664
- const frameworkRoot2 = mirrorDistribution ? syncSwiftDistributionMirror(root2, moduleRoot, mirrorDistribution) : distribution ? moduleRoot : stageFrameworkSource(moduleRoot, slot, frameworkKey, options2.release);
49665
- if (!swiftModuleDigest(frameworkRoot2).equals(moduleDigest))
49666
- throw new Error("Swift staged project source differs from the caller");
49667
- if (!allowWrite && swiftMacroPlugins(frameworkRoot2).stale) return;
49668
- if (allowWrite) stage("preparing compiler plugins");
49669
- const macroPlugins2 = await ensureMacroPlugins(
49670
- frameworkRoot2,
49671
- options2.toolchainBin,
49672
- options2.release,
49673
- budget.signal,
49674
- frameworkLease
49675
- );
49676
- const compileFrameworkRoot2 = distribution ? swiftDistributionCompileView(frameworkRoot2, distribution) : frameworkRoot2;
49677
- const sdk2 = swiftModuleSdk(frameworkRoot2).wasmSdkId;
49678
- const compileSdk2 = mirrorDistribution ? syncSwiftSdkMirror(root2, frameworkRoot2, options2.toolchainBin, sdk2) : {
49679
- id: sdk2,
49680
- options: swiftCompileSdkOptions(frameworkRoot2, options2.toolchainBin),
49681
- toolsetChanged: false
49625
+ }
49626
+ assertSwiftBuildCores();
49627
+ const toolchainBin = resolveToolchainBin();
49628
+ await options2.beforeCompile?.(toolchainBin);
49629
+ clearSwiftModuleDigestScope(moduleRoot);
49630
+ const frameworkKey = swiftProjectBuildKey(moduleRoot, options2.release);
49631
+ const baseRoot = root;
49632
+ const canPoolBuildRoot = !options2.intermediates && !options2.project && !options2.linkOnly && import_node_path70.default.basename(import_node_path70.default.dirname(baseRoot)) === "swift-builds";
49633
+ const compatShapeParts = canPoolBuildRoot ? [
49634
+ distribution ? options2.release : frameworkKey,
49635
+ compileTargets(input).map((target) => target.name).sort(),
49636
+ input.oneModule === true,
49637
+ input.optimize === true,
49638
+ input.unoptimized === true
49639
+ ] : null;
49640
+ const compatShape = compatShapeParts ? (0, import_node_crypto45.createHash)("sha256").update(JSON.stringify(compatShapeParts)).digest("hex").slice(0, 16) : "";
49641
+ const exactShape = compatShapeParts ? (0, import_node_crypto45.createHash)("sha256").update(
49642
+ JSON.stringify([...compatShapeParts, Object.keys(input.files).sort()])
49643
+ ).digest("hex").slice(0, 16) : "";
49644
+ const buildShape = compatShapeParts ? `${exactShape}
49645
+ ${compatShape}` : "";
49646
+ return withSwiftCompileBudget(
49647
+ options2.timeoutMs,
49648
+ options2.signal,
49649
+ async (budget) => {
49650
+ const stage = (message) => {
49651
+ budget.progress();
49652
+ report(message);
49682
49653
  };
49683
- if (mirrorDistribution && compileSdk2.toolsetChanged)
49684
- clearSwiftSdkPathsCache(import_node_path70.default.join(root2, SWIFT_SDK_MIRROR));
49685
- const icu2 = options2.linkOnly ? null : swiftIcuAsset(options2.toolchainBin, sdk2);
49686
- let prebuilt2;
49687
- if (!distribution) {
49688
- if (allowWrite) stage("compiling framework products");
49689
- prebuilt2 = await buildFrameworkProducts(
49690
- slot,
49691
- {
49692
- moduleRoot: frameworkRoot2,
49693
- frameworkKey,
49694
- input,
49695
- swift,
49696
- sdk: sdk2,
49697
- toolchainBin: options2.toolchainBin,
49698
- plugins: macroPlugins2,
49699
- buildOptions: {
49700
- env: baseBuildEnv,
49701
- maxBuffer: 64 * 1024 * 1024,
49702
- signal: budget.signal,
49703
- onOutput: budget.progress,
49704
- lease,
49705
- frameworkLease
49654
+ const runLocked = (work) => {
49655
+ const runInBuildRoot = () => {
49656
+ if (canPoolBuildRoot)
49657
+ return withSwiftBuildRootSlot(
49658
+ baseRoot,
49659
+ exactShape,
49660
+ compatShape,
49661
+ budget.signal,
49662
+ work
49663
+ );
49664
+ const waitStart = Date.now();
49665
+ return withSwiftRootLock(
49666
+ baseRoot,
49667
+ (lease) => work(baseRoot, lease, Date.now() - waitStart),
49668
+ budget.signal
49669
+ );
49670
+ };
49671
+ if (options2.intermediates || baseRoot === sharedRoot)
49672
+ return runInBuildRoot();
49673
+ return withSwiftRootLock(
49674
+ sharedRoot,
49675
+ async () => {
49676
+ const built2 = readCompiledArtifact(
49677
+ import_node_path70.default.join(sharedRoot, "artifact"),
49678
+ hash
49679
+ );
49680
+ if (built2) {
49681
+ renewSharedArtifact(sharedRoot);
49682
+ stage("reusing verified disk artifact");
49683
+ return retain(baseRoot, built2);
49706
49684
  }
49685
+ return runInBuildRoot();
49707
49686
  },
49708
- allowWrite
49687
+ budget.signal
49709
49688
  );
49710
- if (!prebuilt2) return;
49711
- if (!allowWrite) {
49712
- budget.startCompile();
49713
- stage("reusing verified framework products");
49714
- }
49715
- }
49716
- const readHold2 = slot ? acquireSwiftRootReadHold(slot) : void 0;
49717
- return {
49718
- frameworkRoot: frameworkRoot2,
49719
- compileFrameworkRoot: compileFrameworkRoot2,
49720
- macroPlugins: macroPlugins2,
49721
- sdk: sdk2,
49722
- compileSdk: compileSdk2,
49723
- icu: icu2,
49724
- prebuilt: prebuilt2,
49725
- readHold: readHold2
49726
49689
  };
49727
- };
49728
- const frameworks = distribution ? await prepareFrameworks(null) : await withSwiftFrameworkSlot(
49729
- frameworkKey,
49730
- options2.release,
49731
- moduleRoot,
49732
- budget.signal,
49733
- prepareFrameworks,
49734
- unoptimized,
49735
- options2.linkOnly === true
49736
- );
49737
- if (!frameworks)
49738
- throw new Error("Swift distribution did not provide its frameworks");
49739
- const {
49740
- frameworkRoot,
49741
- compileFrameworkRoot,
49742
- macroPlugins,
49743
- compileSdk,
49744
- icu,
49745
- prebuilt
49746
- } = frameworks;
49747
- let readHold = frameworks.readHold;
49748
- const buildOptions = {
49749
- env: baseBuildEnv,
49750
- maxBuffer: 64 * 1024 * 1024,
49751
- signal: budget.signal,
49752
- onOutput: budget.progress,
49753
- lease
49754
- };
49755
- try {
49756
- if (options2.project) removeProjectLinks(root2);
49757
- const packageHostMacros = process.platform === "linux" ? input.packageHostMacros : void 0;
49758
- if (retireStaleSwiftLink(
49759
- root2,
49760
- swiftLinkStamp({
49761
- frameworkKey: mirrorDistribution ? `${options2.release}\0mirror` : `${options2.release}\0${Boolean(distribution)}\0${swiftModuleSdk(frameworkRoot).wasmSdkId}`,
49762
- packageHostMacros
49763
- }),
49764
- swiftLinkStamp({
49765
- // mirrored distributions and their WASI SDK mirror invalidate
49766
- // dependents per changed file instead of wiping every Clang object.
49767
- frameworkKey: mirrorDistribution ? `${options2.release}\0mirror` : distribution ? `${options2.release}\0${distribution.wasmSdkChecksum}` : frameworkKey,
49768
- prebuilt,
49769
- packageHostMacros
49770
- }),
49771
- Boolean(options2.linkOnly)
49772
- ))
49773
- stage("framework revision changed; rebuilding the app link");
49774
- const nativeToolset = needsNativeToolset(input, prebuilt);
49775
- const preparation = writeSwiftProject(
49776
- layout3,
49777
- input,
49778
- frameworkRoot,
49779
- prebuilt,
49780
- !options2.project,
49781
- options2.project ? false : options2.objcPrebuiltStage ?? (options2.intermediates ? false : void 0),
49782
- compileSdk
49783
- );
49784
- const productFile = import_node_path70.default.join(frameworkRoot, SWIFT_FRAMEWORK_PRODUCT_FILE);
49785
- writeSwiftAutolinkLinker(
49786
- root2,
49787
- options2.toolchainBin,
49788
- (0, import_node_fs70.existsSync)(productFile) ? [
49789
- v6.parse(
49790
- swiftFrameworkProductSchema,
49791
- JSON.parse((0, import_node_fs70.readFileSync)(productFile, "utf8"))
49792
- ).product.name
49793
- ] : []
49794
- );
49795
- const compiler = preparation.targetToolset ? { CC: import_node_path70.default.join(root2, CLANG_TARGET_MODULE_WRAPPER) } : {};
49796
- if (packageHostMacros?.length) {
49797
- const swiftc = import_node_path70.default.join(root2, SWIFT_HOST_COMPILER_WRAPPER);
49798
- writeBuildFile(
49799
- swiftc,
49800
- [
49801
- "#!/bin/sh",
49802
- "target=",
49803
- "module=",
49804
- "compile=",
49805
- "previous=",
49806
- "for argument do",
49807
- ' case "$previous" in -target) target=$argument ;; -module-name) module=$argument ;; esac',
49808
- ' case "$argument" in -c|-emit-module|-scan-dependencies|-typecheck) compile=1 ;; esac',
49809
- " previous=$argument",
49810
- "done",
49811
- 'case "$target/$compile" in',
49812
- " *-*-linux*/1)",
49813
- ' case ",$PEACH_SWIFT_HOST_MACROS," in',
49814
- ' *",$module,"*) set -- "$@" -Xfrontend -import-module -Xfrontend Foundation ;;',
49815
- " esac ;;",
49816
- "esac",
49817
- 'exec "$PEACH_SWIFTC" "$@"',
49818
- ""
49819
- ].join("\n")
49820
- );
49821
- (0, import_node_fs70.chmodSync)(swiftc, 493);
49822
- compiler.SWIFT_EXEC = swiftc;
49823
- compiler.PEACH_SWIFT_HOST_MACROS = packageHostMacros.join(",");
49824
- compiler.PEACH_SWIFTC = import_node_path70.default.join(options2.toolchainBin, "swiftc");
49825
- }
49826
- const projectProcess = options2.project ? prepareSwiftProjectProcess(root2, options2.project) : void 0;
49827
- const temporaryDirectory = projectProcess ? void 0 : import_node_path70.default.join(root2, ".build", "peach-compiler-tmp");
49828
- const appOptions = projectProcess ? {
49829
- ...buildOptions,
49830
- uid: projectProcess.uid,
49831
- gid: projectProcess.gid,
49832
- confined: { ...projectProcess.env, ...compiler }
49833
- } : {
49834
- ...buildOptions,
49835
- temporaryDirectory,
49836
- env: {
49837
- ...buildOptions.env,
49838
- ...preparation.usesObjcPrebuilt && process.env.PEACH_HOME !== void 0 ? { PEACH_HOME: process.env.PEACH_HOME } : {},
49839
- ...compiler
49840
- }
49841
- };
49842
- const unprepared = preparation.targetFailures.map(
49843
- (failure2) => `error: target ${failure2}`
49844
- );
49845
- const forwarders = /* @__PURE__ */ new Map();
49846
- for (const [file, text7] of Object.entries(input.files)) {
49847
- const parents = /^#include "((?:\.\.\/)+)[^"\n]+"\n$/.exec(text7)?.[1];
49848
- if (!parents) continue;
49849
- const directory2 = import_node_path70.default.posix.dirname(file);
49850
- forwarders.set(
49851
- `${import_node_path70.default.join(root2, directory2)}/${parents.slice(0, -1)}`,
49852
- import_node_path70.default.posix.join("build", directory2, parents).replace(/\/$/, "")
49853
- );
49854
- }
49855
- const jobs = swiftCompilerJobs();
49856
- const incrementalPreview = sdkImage !== void 0 && !guestGraph && !options2.project && !input.optimize && !input.unoptimized;
49857
- const batchGuest = guestGraph !== void 0 && !options2.project && !input.unoptimized;
49858
- const guestDriverJobs = Math.min(8, jobs);
49859
- const singleProducerJobs = Math.min(16, Math.floor(jobs / 2));
49860
- const batch = incrementalPreview || batchGuest;
49861
- const perFile = input.unoptimized || batch;
49862
- const reproducibleFrameworkRoot = mirrorDistribution ? frameworkRoot : compileFrameworkRoot;
49863
- const buildArgs = [
49864
- "build",
49865
- ...projectProcess?.cacheOptions ?? swiftPackageCacheOptions(),
49866
- "--build-system",
49867
- "native",
49868
- "-j",
49869
- String(jobs),
49870
- "--package-path",
49871
- root2,
49872
- ...compileSdk.options,
49873
- ...swiftObjCSelectorOptions(frameworkRoot),
49874
- "--swift-sdk",
49875
- compileSdk.id,
49876
- ...preparation.targetToolset ? ["--toolset", import_node_path70.default.join(root2, ".peach-target-toolset.json")] : [],
49877
- "-c",
49878
- "release",
49879
- ...input.unoptimized ? ["-Xswiftc", "-Onone"] : [],
49880
- ...perFile ? [
49881
- "-Xswiftc",
49882
- "-no-whole-module-optimization",
49883
- "-Xswiftc",
49884
- "-j",
49885
- "-Xswiftc",
49886
- String(batchGuest ? guestDriverJobs : jobs)
49887
- ] : [],
49888
- // optimized batches can move specialized definitions between objects.
49889
- ...incrementalPreview ? ["-Xswiftc", "-incremental"] : [],
49890
- ...batch ? ["-Xswiftc", "-enable-batch-mode"] : [],
49891
- // the mirror finds a changed sdk header's readers in their
49892
- // dependency files, which omit system headers by default
49893
- ...mirrorDistribution ? ["-Xswiftc", "-track-system-dependencies"] : [],
49894
- // the link strips debug info, so none is generated (as for the framework).
49895
- // keep -num-threads fixed across caller core caps so llbuild does not
49896
- // rebuild every target when callers alternate --cores, and bound backend
49897
- // fan-out under high -j.
49898
- "-Xswiftc",
49899
- "-gnone",
49900
- "-Xcc",
49901
- "-g0",
49902
- "-Xcxx",
49903
- "-g0",
49904
- ...batch ? [] : [
49905
- "-Xswiftc",
49906
- "-num-threads",
49907
- "-Xswiftc",
49908
- String(perFile ? 1 : Math.min(8, import_node_os17.default.availableParallelism()))
49909
- ],
49910
- ...swiftReproducibleBuildFlags([
49911
- [import_node_path70.default.dirname(options2.toolchainBin), "toolchain"],
49912
- [reproducibleFrameworkRoot, "framework"],
49913
- [root2, "build"],
49914
- ...forwarders
49915
- ]).flatMap((flag, index, flags) => {
49916
- if (!nativeToolset || !flag.startsWith("-ffile-prefix-map="))
49917
- return [flag];
49918
- const toolchainDir = import_node_path70.default.dirname(options2.toolchainBin);
49919
- let mapped = flag;
49920
- for (const [dir, target] of [
49921
- [root2, "/peach/build"],
49922
- [reproducibleFrameworkRoot, "/peach/framework"],
49923
- [(0, import_node_fs70.realpathSync)(reproducibleFrameworkRoot), "/peach/framework"],
49924
- [toolchainDir, "/peach/toolchain"],
49925
- [(0, import_node_fs70.realpathSync)(toolchainDir), "/peach/toolchain"]
49926
- ]) {
49927
- mapped = mapped.replaceAll(dir, target);
49690
+ return runLocked(async (slotRoot, lease, waitedMs) => {
49691
+ const root2 = slotRoot;
49692
+ const layout3 = {
49693
+ root: root2,
49694
+ sources: import_node_path70.default.join(root2, "Sources", "App"),
49695
+ multi: compileTargets(input).length > 0
49696
+ };
49697
+ if (!options2.intermediates) {
49698
+ const built2 = readCompiledArtifact(
49699
+ import_node_path70.default.join(sharedRoot, "artifact"),
49700
+ hash
49701
+ );
49702
+ if (built2) {
49703
+ stage("reusing verified disk artifact");
49704
+ return retain(baseRoot, built2);
49928
49705
  }
49929
- const [, from, to] = /^-ffile-prefix-map=([^=]+)=(.+)$/.exec(mapped) ?? [];
49930
- const tool = flags[index - 1];
49931
- return mapped !== flag && from !== to ? [flag, tool, mapped] : [flag];
49932
- }),
49933
- ...macroPlugins.libraries.flatMap((plugin) => [
49934
- "-Xswiftc",
49935
- "-load-plugin-library",
49936
- "-Xswiftc",
49937
- plugin
49938
- ]),
49939
- ...macroPlugins.executables.flatMap((plugin) => [
49940
- "-Xswiftc",
49941
- "-load-plugin-executable",
49942
- "-Xswiftc",
49943
- `${plugin}#ExpoModulesMacros`
49944
- ])
49945
- ];
49946
- const linked = builtArtifact(layout3);
49947
- (0, import_node_fs70.rmSync)(import_node_path70.default.join(root2, ".peach-link.rsp"), { force: true });
49948
- if (options2.linkOnly || (0, import_node_fs70.existsSync)(linked) && (0, import_node_fs70.statSync)(linked).size <= 8)
49949
- (0, import_node_fs70.rmSync)(linked, { force: true });
49950
- stage("compiling and linking Swift modules");
49951
- const frameworkInterfaces = /* @__PURE__ */ new Map();
49952
- const compileSdkPaths = swiftSdkPaths(
49953
- frameworkRoot,
49954
- options2.toolchainBin,
49955
- compileSdk.options,
49956
- compileSdk.id
49957
- );
49958
- const sdkFrameworks = import_node_path70.default.join(
49959
- compileSdkPaths.darwin,
49960
- "System/Library/Frameworks"
49961
- );
49962
- const generatedInterface = (source) => withoutImportedSdkEnumForwards(
49963
- clangInterfaceHeader((0, import_node_fs70.readFileSync)(source, "utf8"), frameworkRoot),
49964
- sdkObjCDeclarationOwners(sdkFrameworks)
49965
- );
49966
- const nativeDeclarations = /* @__PURE__ */ new Map();
49967
- const nativeHeaders = Object.entries(input.files).filter(([name3]) => name3.endsWith(".h") && !name3.endsWith("-Swift.h")).map(([, source]) => source);
49968
- for (const [file, contents2] of Object.entries(input.files)) {
49969
- if (!file.endsWith(".modulemap")) continue;
49970
- const name3 = moduleMapName(contents2);
49971
- const umbrella = /\bumbrella\s+header\s+"([^"]+)"/.exec(contents2)?.[1];
49972
- if (!name3 || !umbrella) continue;
49973
- const header = input.files[import_node_path70.default.posix.join(import_node_path70.default.posix.dirname(file), umbrella)];
49974
- if (header === void 0) continue;
49975
- const included = new Set(
49976
- [
49977
- ...header.matchAll(/^\s*#\s*(?:import|include)\s*[<"]([^">]+)[">]/gm)
49978
- ].map((match) => import_node_path70.default.posix.basename(match[1]))
49979
- );
49980
- const declarations = nativeDeclarations.get(name3) ?? /* @__PURE__ */ new Set();
49981
- for (const declaration of swiftInterfaceDeclarations(header))
49982
- declarations.add(declaration);
49983
- for (const [candidate, source] of Object.entries(input.files))
49984
- if (included.has(import_node_path70.default.posix.basename(candidate)))
49985
- for (const declaration of swiftInterfaceDeclarations(source))
49986
- declarations.add(declaration);
49987
- nativeDeclarations.set(name3, declarations);
49988
- }
49989
- const frameworkInterface = (name3) => {
49990
- if (frameworkInterfaces.has(name3)) return frameworkInterfaces.get(name3);
49991
- const source = distribution ? import_node_path70.default.join(frameworkRoot, "modules", `${name3}-Swift.h`) : prebuilt.objcHeaders.get(name3);
49992
- if (!source || !(0, import_node_fs70.existsSync)(source)) {
49993
- frameworkInterfaces.set(name3, null);
49994
- return null;
49995
49706
  }
49996
- const headers = import_node_path70.default.join(sdkFrameworks, `${name3}.framework/Headers`);
49997
- const declared = /* @__PURE__ */ new Set();
49998
- if ((0, import_node_fs70.existsSync)(headers)) {
49999
- for (const file of (0, import_node_fs70.readdirSync)(headers, {
50000
- recursive: true,
50001
- encoding: "utf8"
50002
- }))
50003
- if (file.endsWith(".h"))
50004
- for (const name4 of swiftInterfaceDeclarations(
50005
- (0, import_node_fs70.readFileSync)(import_node_path70.default.join(headers, file), "utf8")
50006
- ))
50007
- declared.add(name4);
49707
+ if (waitedMs >= 1e3)
49708
+ report(`acquired build root ${import_node_path70.default.basename(root2)} after ${waitedMs}ms`);
49709
+ if (canPoolBuildRoot) {
49710
+ refreshSwiftCacheHold(root2);
49711
+ (0, import_node_fs70.writeFileSync)(import_node_path70.default.join(root2, SWIFT_BUILD_ROOT_SHAPE), buildShape);
50008
49712
  }
50009
- for (const declaration of nativeDeclarations.get(name3) ?? [])
50010
- declared.add(declaration);
50011
- const own2 = withoutSwiftDeclarations(
50012
- generatedInterface(source),
50013
- declared,
50014
- nativeDeclarations.has(name3) ? `@import ${name3};` : `#import <${name3}/${name3}.h>`
50015
- );
50016
- const owners = sdkObjCDeclarationOwners(sdkFrameworks);
50017
- const foreign = /* @__PURE__ */ new Map();
50018
- for (const declaration of [
50019
- ...swiftInterfaceDeclarations(own2),
50020
- ...objcEnumerations(own2),
50021
- ...[...own2.matchAll(/^\s*SWIFT_EXTERN\b[^(\n]*?\b(\w+)\s*\(/gm)].map(
50022
- (match) => match[1]
50023
- )
50024
- ]) {
50025
- const owner = owners.get(declaration);
50026
- if (owner && owner !== name3) foreign.set(declaration, owner);
49713
+ const swift = import_node_path70.default.join(toolchainBin, "swift");
49714
+ if (!(0, import_node_fs70.existsSync)(swift)) {
49715
+ throw new Error(
49716
+ `swift-compile: no swift.org toolchain at ${toolchainBin}; install ${options2.release} and its matching wasm sdk`
49717
+ );
50027
49718
  }
50028
- const header = foreign.size ? withoutSwiftDeclarations(
50029
- own2,
50030
- new Set(foreign.keys()),
50031
- [...new Set(foreign.values())].map((owner) => `#import <${owner}/${owner}.h>`).join("\n")
50032
- ) : own2;
50033
- const value = {
50034
- file: import_node_path70.default.join(root2, ".build/peach-framework-objc", `${name3}-Swift.h`),
50035
- header,
50036
- module: (0, import_node_fs70.existsSync)(headers)
49719
+ const unoptimized = input.unoptimized === true;
49720
+ const baseBuildEnv = options2.project?.env ? {
49721
+ ...options2.project.env,
49722
+ // shipped host plugins resolve against the selected compiler's runtime.
49723
+ ...process.platform === "linux" ? {
49724
+ LD_LIBRARY_PATH: [
49725
+ import_node_path70.default.resolve(toolchainBin, "../lib/swift/linux"),
49726
+ import_node_path70.default.resolve(toolchainBin, "../lib/swift/host"),
49727
+ process.env.LD_LIBRARY_PATH
49728
+ ].filter(Boolean).join(":")
49729
+ } : {},
49730
+ PEACH_DEFER_WASM_LINK: "1"
49731
+ } : swiftCompilerBaseEnv(toolchainBin, process.env);
49732
+ const prepareFrameworks = async (slot, frameworkLease, allowWrite = true) => {
49733
+ if (allowWrite) budget.startCompile();
49734
+ const frameworkRoot2 = mirrorDistribution ? syncSwiftDistributionMirror(root2, moduleRoot, mirrorDistribution) : distribution ? moduleRoot : stageFrameworkSource(
49735
+ moduleRoot,
49736
+ slot,
49737
+ frameworkKey,
49738
+ options2.release
49739
+ );
49740
+ if (!swiftModuleDigest(frameworkRoot2).equals(moduleDigest))
49741
+ throw new Error("Swift staged project source differs from the caller");
49742
+ if (!allowWrite && swiftMacroPlugins(frameworkRoot2).stale) return;
49743
+ if (allowWrite) stage("preparing compiler plugins");
49744
+ const macroPlugins2 = await ensureMacroPlugins(
49745
+ frameworkRoot2,
49746
+ toolchainBin,
49747
+ options2.release,
49748
+ budget.signal,
49749
+ frameworkLease
49750
+ );
49751
+ const compileFrameworkRoot2 = distribution ? swiftDistributionCompileView(frameworkRoot2, distribution) : frameworkRoot2;
49752
+ const sdk2 = swiftModuleSdk(frameworkRoot2).wasmSdkId;
49753
+ const compileSdk2 = mirrorDistribution ? syncSwiftSdkMirror(root2, frameworkRoot2, toolchainBin, sdk2) : {
49754
+ id: sdk2,
49755
+ options: swiftCompileSdkOptions(frameworkRoot2, toolchainBin),
49756
+ toolsetChanged: false
49757
+ };
49758
+ if (mirrorDistribution && compileSdk2.toolsetChanged)
49759
+ clearSwiftSdkPathsCache(import_node_path70.default.join(root2, SWIFT_SDK_MIRROR));
49760
+ const icu2 = options2.linkOnly ? null : swiftIcuAsset(toolchainBin, sdk2);
49761
+ let prebuilt2;
49762
+ if (!distribution) {
49763
+ if (allowWrite) stage("compiling framework products");
49764
+ prebuilt2 = await buildFrameworkProducts(
49765
+ slot,
49766
+ {
49767
+ moduleRoot: frameworkRoot2,
49768
+ frameworkKey,
49769
+ input,
49770
+ swift,
49771
+ sdk: sdk2,
49772
+ toolchainBin,
49773
+ plugins: macroPlugins2,
49774
+ buildOptions: {
49775
+ env: baseBuildEnv,
49776
+ maxBuffer: 64 * 1024 * 1024,
49777
+ signal: budget.signal,
49778
+ onOutput: budget.progress,
49779
+ lease,
49780
+ frameworkLease
49781
+ }
49782
+ },
49783
+ allowWrite
49784
+ );
49785
+ if (!prebuilt2) return;
49786
+ if (!allowWrite) {
49787
+ budget.startCompile();
49788
+ stage("reusing verified framework products");
49789
+ }
49790
+ }
49791
+ const readHold2 = slot ? acquireSwiftRootReadHold(slot) : void 0;
49792
+ return {
49793
+ frameworkRoot: frameworkRoot2,
49794
+ compileFrameworkRoot: compileFrameworkRoot2,
49795
+ macroPlugins: macroPlugins2,
49796
+ sdk: sdk2,
49797
+ compileSdk: compileSdk2,
49798
+ icu: icu2,
49799
+ prebuilt: prebuilt2,
49800
+ readHold: readHold2
49801
+ };
50037
49802
  };
50038
- frameworkInterfaces.set(name3, value);
50039
- writeBuildFile(
50040
- value.file,
50041
- ((0, import_node_fs70.existsSync)(import_node_path70.default.join(headers, `${name3}.h`)) ? `#import <${name3}/${name3}.h>
50042
- ` : "") + swiftHeaderWithSuperclassImports(header, frameworkInterface)
50043
- );
50044
- return value;
50045
- };
50046
- const headerPaths = (producer) => {
50047
- const stem2 = import_node_path70.default.join(
50048
- root2,
50049
- ".build",
50050
- "peach-cxx-headers",
50051
- `${producer}-Swift`
50052
- );
50053
- return { producer, original: `${stem2}.original.h`, emitted: `${stem2}.h` };
50054
- };
50055
- const publishHeader = ({
50056
- producer,
50057
- original,
50058
- emitted
50059
- }) => {
50060
- const generated = generatedInterface(original);
50061
- writeBuildFile(
50062
- emitted,
50063
- withoutSwiftDeclarations(
50064
- swiftHeaderWithSuperclassImports(generated, frameworkInterface),
50065
- /* @__PURE__ */ new Set([
50066
- ...preparation.nativeHeaderDeclarations[producer] ?? [],
50067
- ...nativelyDeclaredFunctions(generated, nativeHeaders)
50068
- ]),
50069
- `#import <${producer}/${producer}.h>`
50070
- )
49803
+ const frameworks = distribution ? await prepareFrameworks(null) : await withSwiftFrameworkSlot(
49804
+ frameworkKey,
49805
+ options2.release,
49806
+ moduleRoot,
49807
+ budget.signal,
49808
+ prepareFrameworks,
49809
+ unoptimized,
49810
+ options2.linkOnly === true
50071
49811
  );
50072
- };
50073
- const recipe2 = inputHash.copy().update(
50074
- distribution ? swiftCompileSurfaceDigest(frameworkRoot) : moduleDigest
50075
- ).update((0, import_node_fs70.readFileSync)(import_node_path70.default.join(root2, "Package.swift"))).update(JSON.stringify(buildArgs)).digest("hex");
50076
- const runApp = async (compiler2) => {
50077
- const optionsWithCompiler = compiler2 ? { ...appOptions, env: { ...appOptions.env, ...compiler2 } } : appOptions;
50078
- const stages = [
50079
- ...(preparation.nativePrerequisiteTargets ?? []).map((target) => ({
50080
- target,
50081
- producers: []
50082
- })),
50083
- ...preparation.headerBuilds,
50084
- ...(preparation.nativeProductTargets ?? []).map((target) => ({
50085
- target,
50086
- producers: []
50087
- }))
50088
- ];
50089
- const checkpoints = import_node_path70.default.join(root2, ".build", "peach-product-checkpoints");
50090
- const buildDbExists = (0, import_node_fs70.existsSync)(import_node_path70.default.join(root2, ".build", "build.db"));
50091
- const releaseDir = import_node_path70.default.dirname(linked);
50092
- for (const { target, producers } of stages) {
50093
- if (!options2.project && producers.length === 0 && buildDbExists) {
50094
- const expectedObjects = preparation.nativeStageObjects.get(target);
50095
- if (expectedObjects && expectedObjects.length > 0 && expectedObjects.every(
50096
- (relative3) => (0, import_node_fs70.statSync)(import_node_path70.default.join(releaseDir, relative3), {
50097
- throwIfNoEntry: false
50098
- })?.isFile()
50099
- ))
50100
- continue;
50101
- }
50102
- const receipt = import_node_path70.default.join(
50103
- checkpoints,
50104
- (0, import_node_crypto45.createHash)("sha256").update(target).digest("hex")
49812
+ if (!frameworks)
49813
+ throw new Error("Swift distribution did not provide its frameworks");
49814
+ const {
49815
+ frameworkRoot,
49816
+ compileFrameworkRoot,
49817
+ macroPlugins,
49818
+ compileSdk,
49819
+ icu,
49820
+ prebuilt
49821
+ } = frameworks;
49822
+ let readHold = frameworks.readHold;
49823
+ const buildOptions = {
49824
+ env: baseBuildEnv,
49825
+ maxBuffer: 64 * 1024 * 1024,
49826
+ signal: budget.signal,
49827
+ onOutput: budget.progress,
49828
+ lease
49829
+ };
49830
+ try {
49831
+ if (options2.project) removeProjectLinks(root2);
49832
+ const packageHostMacros = process.platform === "linux" ? input.packageHostMacros : void 0;
49833
+ if (retireStaleSwiftLink(
49834
+ root2,
49835
+ swiftLinkStamp({
49836
+ frameworkKey: mirrorDistribution ? `${options2.release}\0mirror` : `${options2.release}\0${Boolean(distribution)}\0${swiftModuleSdk(frameworkRoot).wasmSdkId}`,
49837
+ packageHostMacros
49838
+ }),
49839
+ swiftLinkStamp({
49840
+ // mirrored distributions and their WASI SDK mirror invalidate
49841
+ // dependents per changed file instead of wiping every Clang object.
49842
+ frameworkKey: mirrorDistribution ? `${options2.release}\0mirror` : distribution ? `${options2.release}\0${distribution.wasmSdkChecksum}` : frameworkKey,
49843
+ prebuilt,
49844
+ packageHostMacros
49845
+ }),
49846
+ Boolean(options2.linkOnly)
49847
+ ))
49848
+ stage("framework revision changed; rebuilding the app link");
49849
+ const nativeToolset = needsNativeToolset(input, prebuilt);
49850
+ const preparation = writeSwiftProject(
49851
+ layout3,
49852
+ input,
49853
+ frameworkRoot,
49854
+ prebuilt,
49855
+ !options2.project,
49856
+ options2.project ? false : options2.objcPrebuiltStage ?? (options2.intermediates ? false : void 0),
49857
+ compileSdk
50105
49858
  );
50106
- const headers = producers.map(headerPaths);
50107
- for (const header of headers)
50108
- if ((0, import_node_fs70.existsSync)(header.original)) publishHeader(header);
50109
- const fingerprint = () => {
50110
- const digest2 = (0, import_node_crypto45.createHash)("sha256").update(recipe2);
50111
- for (const { original, emitted } of headers) {
50112
- if (!(0, import_node_fs70.existsSync)(original) || !(0, import_node_fs70.existsSync)(emitted)) return;
50113
- digest2.update(
50114
- (0, import_node_crypto45.createHash)("sha256").update((0, import_node_fs70.readFileSync)(emitted)).digest()
50115
- );
49859
+ const productFile = import_node_path70.default.join(frameworkRoot, SWIFT_FRAMEWORK_PRODUCT_FILE);
49860
+ writeSwiftAutolinkLinker(
49861
+ root2,
49862
+ toolchainBin,
49863
+ (0, import_node_fs70.existsSync)(productFile) ? [
49864
+ v6.parse(
49865
+ swiftFrameworkProductSchema,
49866
+ JSON.parse((0, import_node_fs70.readFileSync)(productFile, "utf8"))
49867
+ ).product.name
49868
+ ] : []
49869
+ );
49870
+ const compiler = preparation.targetToolset ? { CC: import_node_path70.default.join(root2, CLANG_TARGET_MODULE_WRAPPER) } : {};
49871
+ if (packageHostMacros?.length) {
49872
+ const swiftc = import_node_path70.default.join(root2, SWIFT_HOST_COMPILER_WRAPPER);
49873
+ writeBuildFile(
49874
+ swiftc,
49875
+ [
49876
+ "#!/bin/sh",
49877
+ "target=",
49878
+ "module=",
49879
+ "compile=",
49880
+ "previous=",
49881
+ "for argument do",
49882
+ ' case "$previous" in -target) target=$argument ;; -module-name) module=$argument ;; esac',
49883
+ ' case "$argument" in -c|-emit-module|-scan-dependencies|-typecheck) compile=1 ;; esac',
49884
+ " previous=$argument",
49885
+ "done",
49886
+ 'case "$target/$compile" in',
49887
+ " *-*-linux*/1)",
49888
+ ' case ",$PEACH_SWIFT_HOST_MACROS," in',
49889
+ ' *",$module,"*) set -- "$@" -Xfrontend -import-module -Xfrontend Foundation ;;',
49890
+ " esac ;;",
49891
+ "esac",
49892
+ 'exec "$PEACH_SWIFTC" "$@"',
49893
+ ""
49894
+ ].join("\n")
49895
+ );
49896
+ (0, import_node_fs70.chmodSync)(swiftc, 493);
49897
+ compiler.SWIFT_EXEC = swiftc;
49898
+ compiler.PEACH_SWIFT_HOST_MACROS = packageHostMacros.join(",");
49899
+ compiler.PEACH_SWIFTC = import_node_path70.default.join(toolchainBin, "swiftc");
49900
+ }
49901
+ const projectProcess = options2.project ? prepareSwiftProjectProcess(root2, options2.project) : void 0;
49902
+ const temporaryDirectory = projectProcess ? void 0 : import_node_path70.default.join(root2, ".build", "peach-compiler-tmp");
49903
+ const appOptions = projectProcess ? {
49904
+ ...buildOptions,
49905
+ uid: projectProcess.uid,
49906
+ gid: projectProcess.gid,
49907
+ confined: { ...projectProcess.env, ...compiler }
49908
+ } : {
49909
+ ...buildOptions,
49910
+ temporaryDirectory,
49911
+ env: {
49912
+ ...buildOptions.env,
49913
+ ...preparation.usesObjcPrebuilt && process.env.PEACH_HOME !== void 0 ? { PEACH_HOME: process.env.PEACH_HOME } : {},
49914
+ ...compiler
50116
49915
  }
50117
- return digest2.digest("hex");
50118
49916
  };
50119
- if (!options2.project && (0, import_node_fs70.existsSync)(receipt) && (0, import_node_fs70.readFileSync)(receipt, "utf8") === fingerprint())
50120
- continue;
50121
- if (!options2.project) (0, import_node_fs70.rmSync)(receipt, { force: true });
50122
- for (const header of headers) {
50123
- if (!(0, import_node_fs70.existsSync)(header.original))
50124
- (0, import_node_fs70.rmSync)(
50125
- import_node_path70.default.join(
50126
- import_node_path70.default.dirname(linked),
50127
- "Modules",
50128
- `${swiftTargetModuleName(header.producer)}.swiftmodule`
50129
- ),
50130
- { force: true }
50131
- );
49917
+ const unprepared = preparation.targetFailures.map(
49918
+ (failure2) => `error: target ${failure2}`
49919
+ );
49920
+ const forwarders = /* @__PURE__ */ new Map();
49921
+ for (const [file, text7] of Object.entries(input.files)) {
49922
+ const parents = /^#include "((?:\.\.\/)+)[^"\n]+"\n$/.exec(text7)?.[1];
49923
+ if (!parents) continue;
49924
+ const directory2 = import_node_path70.default.posix.dirname(file);
49925
+ forwarders.set(
49926
+ `${import_node_path70.default.join(root2, directory2)}/${parents.slice(0, -1)}`,
49927
+ import_node_path70.default.posix.join("build", directory2, parents).replace(/\/$/, "")
49928
+ );
50132
49929
  }
50133
- await runCompiler(
50134
- swift,
50135
- [...buildArgs, "--target", target],
50136
- optionsWithCompiler,
50137
- /^(?:\[swift-prebuilt\]|\[\d+\/\d+\] )/,
50138
- SWIFTPM_NOISE
49930
+ const jobs = swiftCompilerJobs();
49931
+ const incrementalPreview = sdkImage !== void 0 && !guestGraph && !options2.project && !input.optimize && !input.unoptimized;
49932
+ const batchGuest = guestGraph !== void 0 && !options2.project && !input.unoptimized;
49933
+ const guestDriverJobs = Math.min(8, jobs);
49934
+ const singleProducerJobs = Math.min(16, Math.floor(jobs / 2));
49935
+ const batch = incrementalPreview || batchGuest;
49936
+ const perFile = input.unoptimized || batch;
49937
+ const reproducibleFrameworkRoot = mirrorDistribution ? frameworkRoot : compileFrameworkRoot;
49938
+ const buildArgs = [
49939
+ "build",
49940
+ ...projectProcess?.cacheOptions ?? swiftPackageCacheOptions(),
49941
+ "--build-system",
49942
+ "native",
49943
+ "-j",
49944
+ String(jobs),
49945
+ "--package-path",
49946
+ root2,
49947
+ ...compileSdk.options,
49948
+ ...swiftObjCSelectorOptions(frameworkRoot),
49949
+ "--swift-sdk",
49950
+ compileSdk.id,
49951
+ ...preparation.targetToolset ? ["--toolset", import_node_path70.default.join(root2, ".peach-target-toolset.json")] : [],
49952
+ "-c",
49953
+ "release",
49954
+ ...input.unoptimized ? ["-Xswiftc", "-Onone"] : [],
49955
+ ...perFile ? [
49956
+ "-Xswiftc",
49957
+ "-no-whole-module-optimization",
49958
+ "-Xswiftc",
49959
+ "-j",
49960
+ "-Xswiftc",
49961
+ String(batchGuest ? guestDriverJobs : jobs)
49962
+ ] : [],
49963
+ // optimized batches can move specialized definitions between objects.
49964
+ ...incrementalPreview ? ["-Xswiftc", "-incremental"] : [],
49965
+ ...batch ? ["-Xswiftc", "-enable-batch-mode"] : [],
49966
+ // the mirror finds a changed sdk header's readers in their
49967
+ // dependency files, which omit system headers by default
49968
+ ...mirrorDistribution ? ["-Xswiftc", "-track-system-dependencies"] : [],
49969
+ // the link strips debug info, so none is generated (as for the framework).
49970
+ // keep -num-threads fixed across caller core caps so llbuild does not
49971
+ // rebuild every target when callers alternate --cores, and bound backend
49972
+ // fan-out under high -j.
49973
+ "-Xswiftc",
49974
+ "-gnone",
49975
+ "-Xcc",
49976
+ "-g0",
49977
+ "-Xcxx",
49978
+ "-g0",
49979
+ ...batch ? [] : [
49980
+ "-Xswiftc",
49981
+ "-num-threads",
49982
+ "-Xswiftc",
49983
+ String(perFile ? 1 : Math.min(8, import_node_os18.default.availableParallelism()))
49984
+ ],
49985
+ ...swiftReproducibleBuildFlags([
49986
+ [import_node_path70.default.dirname(toolchainBin), "toolchain"],
49987
+ [reproducibleFrameworkRoot, "framework"],
49988
+ [root2, "build"],
49989
+ ...forwarders
49990
+ ]).flatMap((flag, index, flags) => {
49991
+ if (!nativeToolset || !flag.startsWith("-ffile-prefix-map="))
49992
+ return [flag];
49993
+ const toolchainDir = import_node_path70.default.dirname(toolchainBin);
49994
+ let mapped = flag;
49995
+ for (const [dir, target] of [
49996
+ [root2, "/peach/build"],
49997
+ [reproducibleFrameworkRoot, "/peach/framework"],
49998
+ [(0, import_node_fs70.realpathSync)(reproducibleFrameworkRoot), "/peach/framework"],
49999
+ [toolchainDir, "/peach/toolchain"],
50000
+ [(0, import_node_fs70.realpathSync)(toolchainDir), "/peach/toolchain"]
50001
+ ]) {
50002
+ mapped = mapped.replaceAll(dir, target);
50003
+ }
50004
+ const [, from, to] = /^-ffile-prefix-map=([^=]+)=(.+)$/.exec(mapped) ?? [];
50005
+ const tool = flags[index - 1];
50006
+ return mapped !== flag && from !== to ? [flag, tool, mapped] : [flag];
50007
+ }),
50008
+ ...macroPlugins.libraries.flatMap((plugin) => [
50009
+ "-Xswiftc",
50010
+ "-load-plugin-library",
50011
+ "-Xswiftc",
50012
+ plugin
50013
+ ]),
50014
+ ...macroPlugins.executables.flatMap((plugin) => [
50015
+ "-Xswiftc",
50016
+ "-load-plugin-executable",
50017
+ "-Xswiftc",
50018
+ `${plugin}#ExpoModulesMacros`
50019
+ ])
50020
+ ];
50021
+ const linked = builtArtifact(layout3);
50022
+ (0, import_node_fs70.rmSync)(import_node_path70.default.join(root2, ".peach-link.rsp"), { force: true });
50023
+ if (options2.linkOnly || (0, import_node_fs70.existsSync)(linked) && (0, import_node_fs70.statSync)(linked).size <= 8)
50024
+ (0, import_node_fs70.rmSync)(linked, { force: true });
50025
+ stage("compiling and linking Swift modules");
50026
+ const frameworkInterfaces = /* @__PURE__ */ new Map();
50027
+ const compileSdkPaths = swiftSdkPaths(
50028
+ frameworkRoot,
50029
+ toolchainBin,
50030
+ compileSdk.options,
50031
+ compileSdk.id
50032
+ );
50033
+ const sdkFrameworks = import_node_path70.default.join(
50034
+ compileSdkPaths.darwin,
50035
+ "System/Library/Frameworks"
50139
50036
  );
50140
- if (!compiler2) for (const header of headers) publishHeader(header);
50141
- if (!options2.project) {
50142
- const checkpoint = fingerprint();
50143
- if (checkpoint === void 0)
50144
- throw new Error(`missing Swift headers after building ${target}`);
50145
- (0, import_node_fs70.mkdirSync)(checkpoints, { recursive: true });
50146
- (0, import_node_fs70.writeFileSync)(`${receipt}.partial`, checkpoint);
50147
- (0, import_node_fs70.renameSync)(`${receipt}.partial`, receipt);
50037
+ const generatedInterface = (source) => withoutImportedSdkEnumForwards(
50038
+ clangInterfaceHeader((0, import_node_fs70.readFileSync)(source, "utf8"), frameworkRoot),
50039
+ sdkObjCDeclarationOwners(sdkFrameworks)
50040
+ );
50041
+ const nativeDeclarations = /* @__PURE__ */ new Map();
50042
+ const nativeHeaders = Object.entries(input.files).filter(([name3]) => name3.endsWith(".h") && !name3.endsWith("-Swift.h")).map(([, source]) => source);
50043
+ for (const [file, contents2] of Object.entries(input.files)) {
50044
+ if (!file.endsWith(".modulemap")) continue;
50045
+ const name3 = moduleMapName(contents2);
50046
+ const umbrella = /\bumbrella\s+header\s+"([^"]+)"/.exec(contents2)?.[1];
50047
+ if (!name3 || !umbrella) continue;
50048
+ const header = input.files[import_node_path70.default.posix.join(import_node_path70.default.posix.dirname(file), umbrella)];
50049
+ if (header === void 0) continue;
50050
+ const included = new Set(
50051
+ [
50052
+ ...header.matchAll(
50053
+ /^\s*#\s*(?:import|include)\s*[<"]([^">]+)[">]/gm
50054
+ )
50055
+ ].map((match) => import_node_path70.default.posix.basename(match[1]))
50056
+ );
50057
+ const declarations = nativeDeclarations.get(name3) ?? /* @__PURE__ */ new Set();
50058
+ for (const declaration of swiftInterfaceDeclarations(header))
50059
+ declarations.add(declaration);
50060
+ for (const [candidate, source] of Object.entries(input.files))
50061
+ if (included.has(import_node_path70.default.posix.basename(candidate)))
50062
+ for (const declaration of swiftInterfaceDeclarations(source))
50063
+ declarations.add(declaration);
50064
+ nativeDeclarations.set(name3, declarations);
50148
50065
  }
50149
- }
50150
- await runCompiler(
50151
- swift,
50152
- buildArgs,
50153
- optionsWithCompiler,
50154
- SWIFTPM_PROGRESS,
50155
- SWIFTPM_NOISE
50156
- );
50157
- };
50158
- const compileApp = () => preparation.headerCompiler ? withSwiftHeaderCompiler(
50159
- root2,
50160
- options2.toolchainBin,
50161
- recipe2,
50162
- new Map(
50163
- preparation.headerBuilds.flatMap(({ producers }) => {
50164
- const driverJobs = batchGuest && producers.length === 1 && singleProducerJobs > guestDriverJobs ? singleProducerJobs : void 0;
50165
- return producers.map((producer) => {
50166
- const paths = headerPaths(producer);
50167
- return [
50168
- swiftTargetModuleName(producer),
50169
- {
50170
- header: paths.original,
50171
- publish: () => publishHeader(paths),
50172
- jobs: driverJobs
50066
+ const frameworkInterface = (name3) => {
50067
+ if (frameworkInterfaces.has(name3)) return frameworkInterfaces.get(name3);
50068
+ const source = distribution ? import_node_path70.default.join(frameworkRoot, "modules", `${name3}-Swift.h`) : prebuilt.objcHeaders.get(name3);
50069
+ if (!source || !(0, import_node_fs70.existsSync)(source)) {
50070
+ frameworkInterfaces.set(name3, null);
50071
+ return null;
50072
+ }
50073
+ const headers = import_node_path70.default.join(sdkFrameworks, `${name3}.framework/Headers`);
50074
+ const declared = /* @__PURE__ */ new Set();
50075
+ if ((0, import_node_fs70.existsSync)(headers)) {
50076
+ for (const file of (0, import_node_fs70.readdirSync)(headers, {
50077
+ recursive: true,
50078
+ encoding: "utf8"
50079
+ }))
50080
+ if (file.endsWith(".h"))
50081
+ for (const name4 of swiftInterfaceDeclarations(
50082
+ (0, import_node_fs70.readFileSync)(import_node_path70.default.join(headers, file), "utf8")
50083
+ ))
50084
+ declared.add(name4);
50085
+ }
50086
+ for (const declaration of nativeDeclarations.get(name3) ?? [])
50087
+ declared.add(declaration);
50088
+ const own2 = withoutSwiftDeclarations(
50089
+ generatedInterface(source),
50090
+ declared,
50091
+ nativeDeclarations.has(name3) ? `@import ${name3};` : `#import <${name3}/${name3}.h>`
50092
+ );
50093
+ const owners = sdkObjCDeclarationOwners(sdkFrameworks);
50094
+ const foreign = /* @__PURE__ */ new Map();
50095
+ for (const declaration of [
50096
+ ...swiftInterfaceDeclarations(own2),
50097
+ ...objcEnumerations(own2),
50098
+ ...[...own2.matchAll(/^\s*SWIFT_EXTERN\b[^(\n]*?\b(\w+)\s*\(/gm)].map(
50099
+ (match) => match[1]
50100
+ )
50101
+ ]) {
50102
+ const owner = owners.get(declaration);
50103
+ if (owner && owner !== name3) foreign.set(declaration, owner);
50104
+ }
50105
+ const header = foreign.size ? withoutSwiftDeclarations(
50106
+ own2,
50107
+ new Set(foreign.keys()),
50108
+ [...new Set(foreign.values())].map((owner) => `#import <${owner}/${owner}.h>`).join("\n")
50109
+ ) : own2;
50110
+ const value = {
50111
+ file: import_node_path70.default.join(
50112
+ root2,
50113
+ ".build/peach-framework-objc",
50114
+ `${name3}-Swift.h`
50115
+ ),
50116
+ header,
50117
+ module: (0, import_node_fs70.existsSync)(headers)
50118
+ };
50119
+ frameworkInterfaces.set(name3, value);
50120
+ writeBuildFile(
50121
+ value.file,
50122
+ ((0, import_node_fs70.existsSync)(import_node_path70.default.join(headers, `${name3}.h`)) ? `#import <${name3}/${name3}.h>
50123
+ ` : "") + swiftHeaderWithSuperclassImports(header, frameworkInterface)
50124
+ );
50125
+ return value;
50126
+ };
50127
+ const headerPaths = (producer) => {
50128
+ const stem2 = import_node_path70.default.join(
50129
+ root2,
50130
+ ".build",
50131
+ "peach-cxx-headers",
50132
+ `${producer}-Swift`
50133
+ );
50134
+ return {
50135
+ producer,
50136
+ original: `${stem2}.original.h`,
50137
+ emitted: `${stem2}.h`
50138
+ };
50139
+ };
50140
+ const publishHeader = ({
50141
+ producer,
50142
+ original,
50143
+ emitted
50144
+ }) => {
50145
+ const generated = generatedInterface(original);
50146
+ writeBuildFile(
50147
+ emitted,
50148
+ withoutSwiftDeclarations(
50149
+ swiftHeaderWithSuperclassImports(generated, frameworkInterface),
50150
+ /* @__PURE__ */ new Set([
50151
+ ...preparation.nativeHeaderDeclarations[producer] ?? [],
50152
+ ...nativelyDeclaredFunctions(generated, nativeHeaders)
50153
+ ]),
50154
+ `#import <${producer}/${producer}.h>`
50155
+ )
50156
+ );
50157
+ };
50158
+ const recipe2 = inputHash.copy().update(
50159
+ distribution ? swiftCompileSurfaceDigest(frameworkRoot) : moduleDigest
50160
+ ).update((0, import_node_fs70.readFileSync)(import_node_path70.default.join(root2, "Package.swift"))).update(JSON.stringify(buildArgs)).digest("hex");
50161
+ const runApp = async (compiler2) => {
50162
+ const optionsWithCompiler = compiler2 ? { ...appOptions, env: { ...appOptions.env, ...compiler2 } } : appOptions;
50163
+ const stages = [
50164
+ ...(preparation.nativePrerequisiteTargets ?? []).map((target) => ({
50165
+ target,
50166
+ producers: []
50167
+ })),
50168
+ ...preparation.headerBuilds,
50169
+ ...(preparation.nativeProductTargets ?? []).map((target) => ({
50170
+ target,
50171
+ producers: []
50172
+ }))
50173
+ ];
50174
+ const checkpoints = import_node_path70.default.join(
50175
+ root2,
50176
+ ".build",
50177
+ "peach-product-checkpoints"
50178
+ );
50179
+ const buildDbExists = (0, import_node_fs70.existsSync)(import_node_path70.default.join(root2, ".build", "build.db"));
50180
+ const releaseDir = import_node_path70.default.dirname(linked);
50181
+ for (const { target, producers } of stages) {
50182
+ if (!options2.project && producers.length === 0 && buildDbExists) {
50183
+ const expectedObjects = preparation.nativeStageObjects.get(target);
50184
+ if (expectedObjects && expectedObjects.length > 0 && expectedObjects.every(
50185
+ (relative3) => (0, import_node_fs70.statSync)(import_node_path70.default.join(releaseDir, relative3), {
50186
+ throwIfNoEntry: false
50187
+ })?.isFile()
50188
+ ))
50189
+ continue;
50190
+ }
50191
+ const receipt = import_node_path70.default.join(
50192
+ checkpoints,
50193
+ (0, import_node_crypto45.createHash)("sha256").update(target).digest("hex")
50194
+ );
50195
+ const headers = producers.map(headerPaths);
50196
+ for (const header of headers)
50197
+ if ((0, import_node_fs70.existsSync)(header.original)) publishHeader(header);
50198
+ const fingerprint = () => {
50199
+ const digest2 = (0, import_node_crypto45.createHash)("sha256").update(recipe2);
50200
+ for (const { original, emitted } of headers) {
50201
+ if (!(0, import_node_fs70.existsSync)(original) || !(0, import_node_fs70.existsSync)(emitted)) return;
50202
+ digest2.update(
50203
+ (0, import_node_crypto45.createHash)("sha256").update((0, import_node_fs70.readFileSync)(emitted)).digest()
50204
+ );
50173
50205
  }
50174
- ];
50175
- });
50176
- })
50177
- ),
50178
- runApp
50179
- ) : runApp();
50180
- try {
50181
- if (temporaryDirectory) (0, import_node_fs70.mkdirSync)(temporaryDirectory, { recursive: true });
50182
- await compileApp();
50183
- } catch (error) {
50184
- const output2 = outputOf(error);
50185
- const moduleCache = import_node_path70.default.join(
50186
- root2,
50187
- ".build",
50188
- WASM_TRIPLE,
50189
- "release",
50190
- "ModuleCache"
50191
- );
50192
- if (output2.includes("was compiled with module cache path") && (0, import_node_fs70.existsSync)(moduleCache)) {
50193
- (0, import_node_fs70.rmSync)(moduleCache, { recursive: true, force: true });
50206
+ return digest2.digest("hex");
50207
+ };
50208
+ if (!options2.project && (0, import_node_fs70.existsSync)(receipt) && (0, import_node_fs70.readFileSync)(receipt, "utf8") === fingerprint())
50209
+ continue;
50210
+ if (!options2.project) (0, import_node_fs70.rmSync)(receipt, { force: true });
50211
+ for (const header of headers) {
50212
+ if (!(0, import_node_fs70.existsSync)(header.original))
50213
+ (0, import_node_fs70.rmSync)(
50214
+ import_node_path70.default.join(
50215
+ import_node_path70.default.dirname(linked),
50216
+ "Modules",
50217
+ `${swiftTargetModuleName(header.producer)}.swiftmodule`
50218
+ ),
50219
+ { force: true }
50220
+ );
50221
+ }
50222
+ await runCompiler(
50223
+ swift,
50224
+ [...buildArgs, "--target", target],
50225
+ optionsWithCompiler,
50226
+ /^(?:\[swift-prebuilt\]|\[\d+\/\d+\] )/,
50227
+ SWIFTPM_NOISE
50228
+ );
50229
+ if (!compiler2) for (const header of headers) publishHeader(header);
50230
+ if (!options2.project) {
50231
+ const checkpoint = fingerprint();
50232
+ if (checkpoint === void 0)
50233
+ throw new Error(`missing Swift headers after building ${target}`);
50234
+ (0, import_node_fs70.mkdirSync)(checkpoints, { recursive: true });
50235
+ (0, import_node_fs70.writeFileSync)(`${receipt}.partial`, checkpoint);
50236
+ (0, import_node_fs70.renameSync)(`${receipt}.partial`, receipt);
50237
+ }
50238
+ }
50239
+ await runCompiler(
50240
+ swift,
50241
+ buildArgs,
50242
+ optionsWithCompiler,
50243
+ SWIFTPM_PROGRESS,
50244
+ SWIFTPM_NOISE
50245
+ );
50246
+ };
50247
+ const compileApp = () => preparation.headerCompiler ? withSwiftHeaderCompiler(
50248
+ root2,
50249
+ toolchainBin,
50250
+ recipe2,
50251
+ new Map(
50252
+ preparation.headerBuilds.flatMap(({ producers }) => {
50253
+ const driverJobs = batchGuest && producers.length === 1 && singleProducerJobs > guestDriverJobs ? singleProducerJobs : void 0;
50254
+ return producers.map((producer) => {
50255
+ const paths = headerPaths(producer);
50256
+ return [
50257
+ swiftTargetModuleName(producer),
50258
+ {
50259
+ header: paths.original,
50260
+ publish: () => publishHeader(paths),
50261
+ jobs: driverJobs
50262
+ }
50263
+ ];
50264
+ });
50265
+ })
50266
+ ),
50267
+ runApp
50268
+ ) : runApp();
50194
50269
  try {
50270
+ if (temporaryDirectory)
50271
+ (0, import_node_fs70.mkdirSync)(temporaryDirectory, { recursive: true });
50195
50272
  await compileApp();
50196
- } catch (retryError) {
50273
+ } catch (error) {
50274
+ const output2 = outputOf(error);
50275
+ const moduleCache = import_node_path70.default.join(
50276
+ root2,
50277
+ ".build",
50278
+ WASM_TRIPLE,
50279
+ "release",
50280
+ "ModuleCache"
50281
+ );
50282
+ if (output2.includes("was compiled with module cache path") && (0, import_node_fs70.existsSync)(moduleCache)) {
50283
+ (0, import_node_fs70.rmSync)(moduleCache, { recursive: true, force: true });
50284
+ try {
50285
+ await compileApp();
50286
+ } catch (retryError) {
50287
+ throw new Error(
50288
+ [
50289
+ ...unprepared,
50290
+ projectDiagnostic(outputOf(retryError), layout3, input.files)
50291
+ ].join("\n"),
50292
+ { cause: retryError }
50293
+ );
50294
+ }
50295
+ } else {
50296
+ throw new Error(
50297
+ [
50298
+ ...unprepared,
50299
+ projectDiagnostic(output2, layout3, input.files)
50300
+ ].join("\n"),
50301
+ { cause: error }
50302
+ );
50303
+ }
50304
+ } finally {
50305
+ if (temporaryDirectory)
50306
+ (0, import_node_fs70.rmSync)(temporaryDirectory, { recursive: true, force: true });
50307
+ if (options2.project) endSwiftProjectProcesses(options2.project);
50308
+ }
50309
+ if (unprepared.length) throw new Error(unprepared.join("\n"));
50310
+ if (!(0, import_node_fs70.existsSync)(linked)) {
50311
+ const binDir = import_node_path70.default.dirname(linked);
50312
+ const found = (0, import_node_fs70.existsSync)(binDir) ? (0, import_node_fs70.readdirSync)(binDir).filter((name3) => name3.endsWith(".wasm")).sort() : [];
50197
50313
  throw new Error(
50198
- [
50199
- ...unprepared,
50200
- projectDiagnostic(outputOf(retryError), layout3, input.files)
50201
- ].join("\n"),
50202
- { cause: retryError }
50314
+ `swift-compile: the build produced no ${import_node_path70.default.basename(linked)} (found: ${found.join(", ") || "none"})`
50203
50315
  );
50204
50316
  }
50205
- } else {
50206
- throw new Error(
50207
- [...unprepared, projectDiagnostic(output2, layout3, input.files)].join(
50208
- "\n"
50209
- ),
50210
- { cause: error }
50317
+ if (options2.project) removeProjectLinks(root2);
50318
+ const resourceReferences = Object.values(input.resources ?? {}).map(
50319
+ (value) => Buffer.from(value, "base64")
50211
50320
  );
50212
- }
50213
- } finally {
50214
- if (temporaryDirectory)
50215
- (0, import_node_fs70.rmSync)(temporaryDirectory, { recursive: true, force: true });
50216
- if (options2.project) endSwiftProjectProcesses(options2.project);
50217
- }
50218
- if (unprepared.length) throw new Error(unprepared.join("\n"));
50219
- if (!(0, import_node_fs70.existsSync)(linked)) {
50220
- const binDir = import_node_path70.default.dirname(linked);
50221
- const found = (0, import_node_fs70.existsSync)(binDir) ? (0, import_node_fs70.readdirSync)(binDir).filter((name3) => name3.endsWith(".wasm")).sort() : [];
50222
- throw new Error(
50223
- `swift-compile: the build produced no ${import_node_path70.default.basename(linked)} (found: ${found.join(", ") || "none"})`
50224
- );
50225
- }
50226
- if (options2.project) removeProjectLinks(root2);
50227
- const resourceReferences = Object.values(input.resources ?? {}).map(
50228
- (value) => Buffer.from(value, "base64")
50229
- );
50230
- if (!guestGraph)
50231
- pruneSwiftWasmLink(
50232
- root2,
50233
- options2.toolchainBin,
50234
- prebuilt?.root ?? frameworkRoot,
50235
- input.staticClangTargets,
50236
- options2.project,
50237
- void 0,
50238
- resourceReferences
50239
- );
50240
- if (options2.linkOnly) {
50241
- if ((0, import_node_fs70.statSync)(linked).size <= 8)
50242
- throw new Error("swift-compile: deferred linker produced no executable");
50243
- stage("project link verified");
50244
- if (readHold && retainSwiftRootReadHold(readHold)) readHold = void 0;
50245
- return;
50246
- }
50247
- const output = options2.project ? projectOutputFile(root2, linked, options2.project) : linked;
50248
- const optimized = `${output}.optimized`;
50249
- if (!sdkImage) throw new Error("swift-compile: missing shared SDK image");
50250
- if (options2.project) (0, import_node_fs70.rmSync)(optimized, { force: true });
50251
- let sdkAsset;
50252
- stage("linking the app image");
50253
- if (guestGraph) {
50254
- const binding = await compileGuestLink({
50255
- graph: guestGraph,
50256
- buildDirectory: root2,
50257
- releaseDirectory: import_node_path70.default.dirname(linked),
50258
- moduleRoot: frameworkRoot,
50259
- toolchainBin: options2.toolchainBin,
50260
- swiftCompiler: preparation.headerCompiler ? import_node_path70.default.join(root2, SWIFT_HEADER_COMPILER_WRAPPER) : compiler.SWIFT_EXEC ?? import_node_path70.default.join(options2.toolchainBin, "swiftc"),
50261
- sysroot: compileSdkPaths.sysroot,
50262
- sdk: swiftModuleSdk(frameworkRoot),
50263
- sdkImage,
50264
- compilerDigest: compilerSourceDigest,
50265
- project: options2.project && {
50266
- ...options2.project,
50267
- env: { ...options2.project.env, ...projectProcess?.env }
50268
- },
50269
- staticClangTargets: input.staticClangTargets ?? [],
50270
- resourceReferences,
50271
- resourceBundles: input.resourceBundles ?? [],
50272
- generatedOwners: preparation.generatedOwners,
50273
- output,
50274
- optimized,
50275
- optimize: input.optimize === true,
50276
- jobs: swiftBuildJobs(),
50277
- onStage: stage
50278
- });
50279
- sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
50280
- } else {
50281
- const { buildSwiftAppModule: buildSwiftAppModule2 } = await Promise.resolve().then(() => (init_swift_sdk_app_module(), swift_sdk_app_module_exports));
50282
- const binding = await buildSwiftAppModule2({
50283
- buildRoot: root2,
50284
- toolchainBin: options2.toolchainBin,
50285
- sdk: sdkImage,
50286
- output: optimized,
50287
- optimize: input.optimize === true,
50288
- project: options2.project && {
50289
- ...options2.project,
50290
- env: { ...options2.project.env, ...projectProcess?.env },
50291
- sdkRoot: import_node_path70.default.dirname(compileSdkPaths.sysroot),
50292
- linked: output
50321
+ if (!guestGraph)
50322
+ pruneSwiftWasmLink(
50323
+ root2,
50324
+ toolchainBin,
50325
+ prebuilt?.root ?? frameworkRoot,
50326
+ input.staticClangTargets,
50327
+ options2.project,
50328
+ void 0,
50329
+ resourceReferences
50330
+ );
50331
+ if (options2.linkOnly) {
50332
+ if ((0, import_node_fs70.statSync)(linked).size <= 8)
50333
+ throw new Error(
50334
+ "swift-compile: deferred linker produced no executable"
50335
+ );
50336
+ stage("project link verified");
50337
+ if (readHold && retainSwiftRootReadHold(readHold)) readHold = void 0;
50338
+ return;
50293
50339
  }
50294
- });
50295
- sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
50296
- }
50297
- const artifact = {
50298
- hash,
50299
- bytes: (0, import_node_fs70.readFileSync)(optimized),
50300
- icu: await icu,
50301
- sdk: sdkAsset
50302
- };
50303
- if (artifact.bytes.length <= 8)
50304
- throw new Error("swift-compile: deferred linker produced no executable");
50305
- if (!options2.project) saveCompiledArtifact(root2, artifact);
50306
- saveSharedArtifact(sharedRoot, artifact);
50307
- stage("compiled artifact verified");
50308
- return retain(baseRoot, artifact);
50309
- } finally {
50310
- readHold?.release();
50340
+ const output = options2.project ? projectOutputFile(root2, linked, options2.project) : linked;
50341
+ const optimized = `${output}.optimized`;
50342
+ if (!sdkImage) throw new Error("swift-compile: missing shared SDK image");
50343
+ if (options2.project) (0, import_node_fs70.rmSync)(optimized, { force: true });
50344
+ let sdkAsset;
50345
+ stage("linking the app image");
50346
+ if (guestGraph) {
50347
+ const binding = await compileGuestLink({
50348
+ graph: guestGraph,
50349
+ buildDirectory: root2,
50350
+ releaseDirectory: import_node_path70.default.dirname(linked),
50351
+ moduleRoot: frameworkRoot,
50352
+ toolchainBin,
50353
+ swiftCompiler: preparation.headerCompiler ? import_node_path70.default.join(root2, SWIFT_HEADER_COMPILER_WRAPPER) : compiler.SWIFT_EXEC ?? import_node_path70.default.join(toolchainBin, "swiftc"),
50354
+ sysroot: compileSdkPaths.sysroot,
50355
+ sdk: swiftModuleSdk(frameworkRoot),
50356
+ sdkImage,
50357
+ compilerDigest: compilerSourceDigest,
50358
+ project: options2.project && {
50359
+ ...options2.project,
50360
+ env: { ...options2.project.env, ...projectProcess?.env }
50361
+ },
50362
+ staticClangTargets: input.staticClangTargets ?? [],
50363
+ resourceReferences,
50364
+ resourceBundles: input.resourceBundles ?? [],
50365
+ generatedOwners: preparation.generatedOwners,
50366
+ output,
50367
+ optimized,
50368
+ optimize: input.optimize === true,
50369
+ jobs: swiftBuildJobs(),
50370
+ onStage: stage
50371
+ });
50372
+ sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
50373
+ } else {
50374
+ const { buildSwiftAppModule: buildSwiftAppModule2 } = await Promise.resolve().then(() => (init_swift_sdk_app_module(), swift_sdk_app_module_exports));
50375
+ const binding = await buildSwiftAppModule2({
50376
+ buildRoot: root2,
50377
+ toolchainBin,
50378
+ sdk: sdkImage,
50379
+ output: optimized,
50380
+ optimize: input.optimize === true,
50381
+ project: options2.project && {
50382
+ ...options2.project,
50383
+ env: { ...options2.project.env, ...projectProcess?.env },
50384
+ sdkRoot: import_node_path70.default.dirname(compileSdkPaths.sysroot),
50385
+ linked: output
50386
+ }
50387
+ });
50388
+ sdkAsset = { key: sdkImage.key, sha256: sdkImage.sha256, binding };
50389
+ }
50390
+ const artifact = {
50391
+ hash,
50392
+ bytes: (0, import_node_fs70.readFileSync)(optimized),
50393
+ icu: await icu,
50394
+ sdk: sdkAsset
50395
+ };
50396
+ if (artifact.bytes.length <= 8)
50397
+ throw new Error("swift-compile: deferred linker produced no executable");
50398
+ if (!options2.project) saveCompiledArtifact(root2, artifact);
50399
+ saveSharedArtifact(sharedRoot, artifact);
50400
+ stage("compiled artifact verified");
50401
+ return retain(baseRoot, artifact);
50402
+ } finally {
50403
+ readHold?.release();
50404
+ }
50405
+ });
50311
50406
  }
50312
- });
50313
- });
50314
- },
50315
- options2.signal
50316
- );
50407
+ );
50408
+ },
50409
+ options2.signal
50410
+ );
50411
+ });
50317
50412
  }
50318
- var import_node_child_process41, import_node_crypto45, import_node_fs70, import_node_os17, import_node_path70, import_promises8, 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;
50413
+ var import_node_child_process41, import_node_crypto45, import_node_fs70, import_node_os18, import_node_path70, import_promises8, 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;
50319
50414
  var init_swift_compile = __esm({
50320
50415
  "src/swift-compile.ts"() {
50321
50416
  "use strict";
50322
50417
  import_node_child_process41 = require("node:child_process");
50323
50418
  import_node_crypto45 = require("node:crypto");
50324
50419
  import_node_fs70 = require("node:fs");
50325
- import_node_os17 = __toESM(require("node:os"), 1);
50420
+ import_node_os18 = __toESM(require("node:os"), 1);
50326
50421
  import_node_path70 = __toESM(require("node:path"), 1);
50327
50422
  import_promises8 = require("node:timers/promises");
50328
50423
  v6 = __toESM(require("peachsim/vendor/valibot"), 1);
@@ -50549,7 +50644,7 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
50549
50644
  REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
50550
50645
  MULTI_MANIFEST_VERSION = 76;
50551
50646
  SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
50552
- compilerSourceDigest = true ? "f7ecc0786fdd1632d1059f2c6c56bd5083a84c871afe2865af4bf2cf65ee6502" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
50647
+ compilerSourceDigest = true ? "0c6bac10641208c362185255fa7a630f4699656735409862a61a2e125ad2e84b" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
50553
50648
  nativeCxxCompilerFlags = ["-fno-cxx-modules"];
50554
50649
  MODULE_MAP_RESPONSE_FILE_RUN = 16;
50555
50650
  cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
@@ -51051,7 +51146,7 @@ async function downloadFile(pod, url, headers, file, algorithm) {
51051
51146
  return hash ? hash.digest("hex") : null;
51052
51147
  }
51053
51148
  function netrcCredentials(host2) {
51054
- const file = import_node_path72.default.join(import_node_os18.default.homedir(), ".netrc");
51149
+ const file = import_node_path72.default.join(import_node_os19.default.homedir(), ".netrc");
51055
51150
  if (!import_node_fs72.default.existsSync(file)) return null;
51056
51151
  const tokens2 = import_node_fs72.default.readFileSync(file, "utf8").split(/\s+/).filter(Boolean);
51057
51152
  let current2 = null;
@@ -51294,14 +51389,14 @@ function cleanInstalledPod(spec, root, used) {
51294
51389
  (node) => used.filter((entry) => entry.specs.includes(node.name)).map((entry) => entry.platform)
51295
51390
  );
51296
51391
  }
51297
- var import_node_child_process42, import_node_crypto47, import_node_fs72, import_node_os18, import_node_path72, COCOAPODS_VERSION, USER_AGENT, PLATFORMS, HEADER_EXTENSIONS, SOURCE_EXTENSIONS2, SOURCE_FILES_PATTERN, STRATEGIES, OPTIONS, ARCHIVE_TYPES, object5, RETRY_STATUSES, chomp, stringList, bracketEnd, escapeRegex;
51392
+ var import_node_child_process42, import_node_crypto47, import_node_fs72, import_node_os19, import_node_path72, COCOAPODS_VERSION, USER_AGENT, PLATFORMS, HEADER_EXTENSIONS, SOURCE_EXTENSIONS2, SOURCE_FILES_PATTERN, STRATEGIES, OPTIONS, ARCHIVE_TYPES, object5, RETRY_STATUSES, chomp, stringList, bracketEnd, escapeRegex;
51298
51393
  var init_pod_sources = __esm({
51299
51394
  "src/pod-sources.ts"() {
51300
51395
  "use strict";
51301
51396
  import_node_child_process42 = require("node:child_process");
51302
51397
  import_node_crypto47 = require("node:crypto");
51303
51398
  import_node_fs72 = __toESM(require("node:fs"), 1);
51304
- import_node_os18 = __toESM(require("node:os"), 1);
51399
+ import_node_os19 = __toESM(require("node:os"), 1);
51305
51400
  import_node_path72 = __toESM(require("node:path"), 1);
51306
51401
  init_home_paths();
51307
51402
  init_pod_prepare_toolchain();
@@ -68810,10 +68905,10 @@ function bazelBinary(root) {
68810
68905
  const pinned = import_node_path83.default.join(root, ".bazelversion");
68811
68906
  if (!import_node_fs82.default.existsSync(pinned)) return "bazel";
68812
68907
  const version2 = import_node_fs82.default.readFileSync(pinned, "utf8").trim();
68813
- const platform = import_node_os19.default.platform() === "darwin" ? "darwin" : "linux";
68814
- const arch = import_node_os19.default.arch() === "arm64" ? "arm64" : "x86_64";
68908
+ const platform = import_node_os20.default.platform() === "darwin" ? "darwin" : "linux";
68909
+ const arch = import_node_os20.default.arch() === "arm64" ? "arm64" : "x86_64";
68815
68910
  const name3 = `bazel-${version2}-${platform}-${arch}`;
68816
- const binary2 = import_node_path83.default.join(import_node_os19.default.homedir(), ".peach", "cache", "bazel", name3);
68911
+ const binary2 = import_node_path83.default.join(import_node_os20.default.homedir(), ".peach", "cache", "bazel", name3);
68817
68912
  if (import_node_fs82.default.existsSync(binary2)) return binary2;
68818
68913
  const url = `https://github.com/bazelbuild/bazel/releases/download/${version2}/${name3}`;
68819
68914
  import_node_fs82.default.mkdirSync(import_node_path83.default.dirname(binary2), { recursive: true });
@@ -69709,14 +69804,14 @@ function shellTokens(options2) {
69709
69804
  return words2;
69710
69805
  });
69711
69806
  }
69712
- var import_node_child_process44, import_node_crypto49, import_node_fs82, import_node_os19, import_node_path83, LIBRARY_RULES, QUERIED_RULES, NATIVE_SOURCE, HEADER4, PRODUCTS, graphs, CLANG_CONFIGURATION_FLAGS, GRAPH_FORMAT, BazelFiles, CXX_STANDARD;
69807
+ var import_node_child_process44, import_node_crypto49, import_node_fs82, import_node_os20, import_node_path83, LIBRARY_RULES, QUERIED_RULES, NATIVE_SOURCE, HEADER4, PRODUCTS, graphs, CLANG_CONFIGURATION_FLAGS, GRAPH_FORMAT, BazelFiles, CXX_STANDARD;
69713
69808
  var init_bazel_project = __esm({
69714
69809
  "src/bazel-project.ts"() {
69715
69810
  "use strict";
69716
69811
  import_node_child_process44 = require("node:child_process");
69717
69812
  import_node_crypto49 = require("node:crypto");
69718
69813
  import_node_fs82 = __toESM(require("node:fs"), 1);
69719
- import_node_os19 = __toESM(require("node:os"), 1);
69814
+ import_node_os20 = __toESM(require("node:os"), 1);
69720
69815
  import_node_path83 = __toESM(require("node:path"), 1);
69721
69816
  init_is_record();
69722
69817
  init_plist();
@@ -76955,7 +77050,7 @@ function nativeWorkspacesDir(root) {
76955
77050
  for (const cache of [
76956
77051
  sharedCacheDir(cacheDir()),
76957
77052
  cacheDir(),
76958
- import_node_path92.default.join(import_node_os20.default.homedir(), ".peach-cache")
77053
+ import_node_path92.default.join(import_node_os21.default.homedir(), ".peach-cache")
76959
77054
  ]) {
76960
77055
  let existing = cache;
76961
77056
  while (!import_node_fs90.default.existsSync(existing)) existing = import_node_path92.default.dirname(existing);
@@ -76965,7 +77060,7 @@ function nativeWorkspacesDir(root) {
76965
77060
  let mount = import_node_fs90.default.realpathSync(root);
76966
77061
  while (import_node_path92.default.dirname(mount) !== mount && import_node_fs90.default.statSync(import_node_path92.default.dirname(mount)).dev === device)
76967
77062
  mount = import_node_path92.default.dirname(mount);
76968
- const tmpRoots = /* @__PURE__ */ new Set(["/tmp", "/var/tmp", import_node_fs90.default.realpathSync(import_node_os20.default.tmpdir())]);
77063
+ const tmpRoots = /* @__PURE__ */ new Set(["/tmp", "/var/tmp", import_node_fs90.default.realpathSync(import_node_os21.default.tmpdir())]);
76969
77064
  if (tmpRoots.has(mount))
76970
77065
  return import_node_path92.default.join(sharedCacheDir(cacheDir()), "expo-native-workspaces");
76971
77066
  return import_node_path92.default.join(mount, ".peach-cache", "expo-native-workspaces");
@@ -77306,7 +77401,7 @@ ${failedOutputLine(command, cwd, bytes)}`
77306
77401
  });
77307
77402
  });
77308
77403
  }
77309
- var import_node_child_process46, import_node_crypto55, import_node_fs90, import_node_module9, import_node_os20, import_node_path92, import_node_util13, isolatedGitEnv, EXACT_VERSION, NATIVE_CONFIG_FILE, NATIVE_SOURCE_FILE2, fileDigests, NATIVE_PACKAGE_ENTRY, hashing, KEPT_WORKSPACES, WORKSPACE_GRACE_MS, ABANDONED_WORKSPACE_MS, RETIRED_PREFIX2, preparing, watches, current, CLONE_ENTRIES;
77404
+ var import_node_child_process46, import_node_crypto55, import_node_fs90, import_node_module9, import_node_os21, import_node_path92, import_node_util13, isolatedGitEnv, EXACT_VERSION, NATIVE_CONFIG_FILE, NATIVE_SOURCE_FILE2, fileDigests, NATIVE_PACKAGE_ENTRY, hashing, KEPT_WORKSPACES, WORKSPACE_GRACE_MS, ABANDONED_WORKSPACE_MS, RETIRED_PREFIX2, preparing, watches, current, CLONE_ENTRIES;
77310
77405
  var init_expo_native_workspace = __esm({
77311
77406
  "src/expo-native-workspace.ts"() {
77312
77407
  "use strict";
@@ -77314,7 +77409,7 @@ var init_expo_native_workspace = __esm({
77314
77409
  import_node_crypto55 = require("node:crypto");
77315
77410
  import_node_fs90 = __toESM(require("node:fs"), 1);
77316
77411
  import_node_module9 = require("node:module");
77317
- import_node_os20 = __toESM(require("node:os"), 1);
77412
+ import_node_os21 = __toESM(require("node:os"), 1);
77318
77413
  import_node_path92 = __toESM(require("node:path"), 1);
77319
77414
  import_node_util13 = require("node:util");
77320
77415
  init_detect();
@@ -78141,14 +78236,14 @@ async function readExpoConfigAsync(projectRoot) {
78141
78236
  import_node_fs93.default.rmSync(directory2, { recursive: true, force: true });
78142
78237
  }
78143
78238
  }
78144
- var import_node_child_process47, import_node_fs93, import_node_module11, import_node_os21, import_node_path95, EXPO_CONFIG_SCRIPT, EXPO_CONFIG_TIMEOUT_MS, resultDirectory;
78239
+ var import_node_child_process47, import_node_fs93, import_node_module11, import_node_os22, import_node_path95, EXPO_CONFIG_SCRIPT, EXPO_CONFIG_TIMEOUT_MS, resultDirectory;
78145
78240
  var init_native_firebase_config = __esm({
78146
78241
  "src/native-firebase-config.ts"() {
78147
78242
  "use strict";
78148
78243
  import_node_child_process47 = require("node:child_process");
78149
78244
  import_node_fs93 = __toESM(require("node:fs"), 1);
78150
78245
  import_node_module11 = require("node:module");
78151
- import_node_os21 = __toESM(require("node:os"), 1);
78246
+ import_node_os22 = __toESM(require("node:os"), 1);
78152
78247
  import_node_path95 = __toESM(require("node:path"), 1);
78153
78248
  init_is_record();
78154
78249
  init_plist();
@@ -78170,7 +78265,7 @@ const result = JSON.stringify(getConfig(root, { skipSDKVersionRequirement: true
78170
78265
  if (Buffer.byteLength(result) > 1024 * 1024) throw new Error('Expo native configuration exceeds 1 MiB.');
78171
78266
  writeFileSync(process.argv[2], result, { mode: 0o600 });`;
78172
78267
  EXPO_CONFIG_TIMEOUT_MS = 3e4;
78173
- resultDirectory = () => import_node_fs93.default.mkdtempSync(import_node_path95.default.join(import_node_os21.default.tmpdir(), "peach-expo-config-"));
78268
+ resultDirectory = () => import_node_fs93.default.mkdtempSync(import_node_path95.default.join(import_node_os22.default.tmpdir(), "peach-expo-config-"));
78174
78269
  }
78175
78270
  });
78176
78271
 
@@ -80365,7 +80460,7 @@ function genruleToolchain(moduleRoot) {
80365
80460
  ranlib: bin("llvm-ranlib"),
80366
80461
  jobs: Math.min(
80367
80462
  32,
80368
- Number(process.env.TM_EXEC_CPU_CORES) || import_node_os22.default.availableParallelism()
80463
+ Number(process.env.TM_EXEC_CPU_CORES) || import_node_os23.default.availableParallelism()
80369
80464
  ),
80370
80465
  frameworkIdentity: () => frameworkProbeIdentity(moduleRoot, compiler.toolchainBin),
80371
80466
  frameworks: () => frameworks ??= nativeFrameworkCompiler(
@@ -80521,14 +80616,14 @@ function genruleArchive(declaration, library, moduleRoot) {
80521
80616
  }
80522
80617
  return combined;
80523
80618
  }
80524
- var import_node_child_process51, import_node_crypto64, import_node_fs102, import_node_os22, import_node_path105, v8, BUILDERS, cacheDir4, toolIdentities, sysrootIdentities, GENRULE_RECIPE, GENRULE_BUNDLE;
80619
+ var import_node_child_process51, import_node_crypto64, import_node_fs102, import_node_os23, import_node_path105, v8, BUILDERS, cacheDir4, toolIdentities, sysrootIdentities, GENRULE_RECIPE, GENRULE_BUNDLE;
80525
80620
  var init_genrule_archives = __esm({
80526
80621
  "src/genrule-archives.ts"() {
80527
80622
  "use strict";
80528
80623
  import_node_child_process51 = require("node:child_process");
80529
80624
  import_node_crypto64 = require("node:crypto");
80530
80625
  import_node_fs102 = __toESM(require("node:fs"), 1);
80531
- import_node_os22 = __toESM(require("node:os"), 1);
80626
+ import_node_os23 = __toESM(require("node:os"), 1);
80532
80627
  import_node_path105 = __toESM(require("node:path"), 1);
80533
80628
  v8 = __toESM(require("peachsim/vendor/valibot"), 1);
80534
80629
  init_ffmpeg_source_build();
@@ -80614,7 +80709,7 @@ function privateSentrySlice(entry, moduleRoot) {
80614
80709
  throw new Error(
80615
80710
  "the Sentry slice for a private Swift distribution builds from a Contrast source checkout"
80616
80711
  );
80617
- const staging = import_node_fs103.default.mkdtempSync(import_node_path106.default.join(import_node_fs103.default.realpathSync(import_node_os23.default.tmpdir()), "sentry-slice-"));
80712
+ const staging = import_node_fs103.default.mkdtempSync(import_node_path106.default.join(import_node_fs103.default.realpathSync(import_node_os24.default.tmpdir()), "sentry-slice-"));
80618
80713
  try {
80619
80714
  process.stderr.write("peach: building the Sentry slice for a private distribution\u2026\n");
80620
80715
  (0, import_node_child_process52.execFileSync)("bun", [script, "--output", staging, "--module-root", moduleRoot], {
@@ -80692,14 +80787,14 @@ function nativeSwiftSlice(standin, moduleRoot, generator, configured, artifact)
80692
80787
  }
80693
80788
  };
80694
80789
  }
80695
- var import_node_child_process52, import_node_crypto65, import_node_fs103, import_node_os23, import_node_path106, SENTRY_SWIFT_SLICE;
80790
+ var import_node_child_process52, import_node_crypto65, import_node_fs103, import_node_os24, import_node_path106, SENTRY_SWIFT_SLICE;
80696
80791
  var init_native_swift_slices = __esm({
80697
80792
  "src/native-swift-slices.ts"() {
80698
80793
  "use strict";
80699
80794
  import_node_child_process52 = require("node:child_process");
80700
80795
  import_node_crypto65 = require("node:crypto");
80701
80796
  import_node_fs103 = __toESM(require("node:fs"), 1);
80702
- import_node_os23 = __toESM(require("node:os"), 1);
80797
+ import_node_os24 = __toESM(require("node:os"), 1);
80703
80798
  import_node_path106 = __toESM(require("node:path"), 1);
80704
80799
  init_native_prebuilt();
80705
80800
  init_swift_sdk_surface();
@@ -92233,7 +92328,7 @@ function build(checkout, output, toolchainBin, common2, objc) {
92233
92328
  import_node_fs113.default.cpSync(import_node_path115.default.join(runtime, "include"), import_node_path115.default.join(includes, "rive", "include"), {
92234
92329
  recursive: true
92235
92330
  });
92236
- const jobs = String(Number(process.env.TM_EXEC_CPU_CORES) || import_node_os24.default.availableParallelism());
92331
+ const jobs = String(Number(process.env.TM_EXEC_CPU_CORES) || import_node_os25.default.availableParallelism());
92237
92332
  const component = (directory2, target, args, headers) => {
92238
92333
  const cwd = import_node_path115.default.join(runtime, directory2);
92239
92334
  const out = `out/iphonesimulator_${CONFIG}`;
@@ -92343,14 +92438,14 @@ exec ${quote3(import_node_path115.default.join(toolchainBin, "llvm-ar"))} rcs "$
92343
92438
  );
92344
92439
  return directory2;
92345
92440
  }
92346
- var import_node_child_process57, import_node_crypto69, import_node_fs113, import_node_os24, import_node_path115, import_promises11, RECIPE, CONFIG, RUNTIME_LIBRARIES;
92441
+ var import_node_child_process57, import_node_crypto69, import_node_fs113, import_node_os25, import_node_path115, import_promises11, RECIPE, CONFIG, RUNTIME_LIBRARIES;
92347
92442
  var init_rive_runtime_dependencies = __esm({
92348
92443
  "src/rive-runtime-dependencies.ts"() {
92349
92444
  "use strict";
92350
92445
  import_node_child_process57 = require("node:child_process");
92351
92446
  import_node_crypto69 = require("node:crypto");
92352
92447
  import_node_fs113 = __toESM(require("node:fs"), 1);
92353
- import_node_os24 = __toESM(require("node:os"), 1);
92448
+ import_node_os25 = __toESM(require("node:os"), 1);
92354
92449
  import_node_path115 = __toESM(require("node:path"), 1);
92355
92450
  import_promises11 = require("node:timers/promises");
92356
92451
  init_home_paths();
@@ -93462,7 +93557,7 @@ function rasterizePdfFiles(inputs2, { imageBytes, imageTotalBytes } = { imageByt
93462
93557
  record5(input, bytes);
93463
93558
  }
93464
93559
  if (!pending.size) return rendered;
93465
- const work = import_node_fs116.default.mkdtempSync(import_node_path118.default.join(import_node_os25.default.tmpdir(), "swift-pdf-png-"));
93560
+ const work = import_node_fs116.default.mkdtempSync(import_node_path118.default.join(import_node_os26.default.tmpdir(), "swift-pdf-png-"));
93466
93561
  let cacheWork;
93467
93562
  let writeCache = true;
93468
93563
  try {
@@ -93515,13 +93610,13 @@ function rasterizePdfFiles(inputs2, { imageBytes, imageTotalBytes } = { imageByt
93515
93610
  }
93516
93611
  return rendered;
93517
93612
  }
93518
- var import_node_child_process60, import_node_fs116, import_node_os25, import_node_path118, RASTER_PDF;
93613
+ var import_node_child_process60, import_node_fs116, import_node_os26, import_node_path118, RASTER_PDF;
93519
93614
  var init_swift_pdf_raster = __esm({
93520
93615
  "src/swift-pdf-raster.ts"() {
93521
93616
  "use strict";
93522
93617
  import_node_child_process60 = require("node:child_process");
93523
93618
  import_node_fs116 = __toESM(require("node:fs"), 1);
93524
- import_node_os25 = __toESM(require("node:os"), 1);
93619
+ import_node_os26 = __toESM(require("node:os"), 1);
93525
93620
  import_node_path118 = __toESM(require("node:path"), 1);
93526
93621
  init_internal_child_contract();
93527
93622
  init_self_invocation();
@@ -94064,6 +94159,15 @@ var init_swift_sdk_later_data = __esm({
94064
94159
  });
94065
94160
 
94066
94161
  // src/swift-host.ts
94162
+ function readPackageFileScoped(packagePath, file, maxBytes) {
94163
+ const scope2 = packageReadScopes.getStore();
94164
+ const key2 = `${packagePath}\0${file}`;
94165
+ const cached2 = scope2?.get(key2);
94166
+ if (cached2) return cached2;
94167
+ const bytes = readPackageFile2(packagePath, file, maxBytes);
94168
+ scope2?.set(key2, bytes);
94169
+ return bytes;
94170
+ }
94067
94171
  function swiftPackageId(packagePath) {
94068
94172
  return import_node_path119.default.basename(packagePath).replace(/[^A-Za-z0-9_]/g, "_").replace(/^(\d)/, "_$1");
94069
94173
  }
@@ -95687,7 +95791,7 @@ function buildSwiftBundleFiles(packagePath, hosted, inputs2, resourceBundles) {
95687
95791
  }
95688
95792
  }
95689
95793
  if (xcode?.app.postBundleScripts.length) {
95690
- const dir = import_node_fs117.default.mkdtempSync(import_node_path119.default.join(import_node_os26.default.tmpdir(), "peach-xcode-bundle-"));
95794
+ const dir = import_node_fs117.default.mkdtempSync(import_node_path119.default.join(import_node_os27.default.tmpdir(), "peach-xcode-bundle-"));
95691
95795
  const wrapper = import_node_path119.default.basename(xcode.app.settings("UNLOCALIZED_RESOURCES_FOLDER_PATH")) || `${xcode.app.name}.app`;
95692
95796
  const bundle = import_node_path119.default.join(dir, wrapper);
95693
95797
  try {
@@ -95865,13 +95969,7 @@ function moduleStamp(packagePath, moduleRootOverride, hosted) {
95865
95969
  (root) => import_node_fs117.default.existsSync(import_node_path119.default.join(root, "toolchain.json"))
95866
95970
  );
95867
95971
  if (!moduleRoot) return "";
95868
- const hash = (0, import_node_crypto72.createHash)("sha256");
95869
- hash.update(moduleRoot);
95870
- for (const relative3 of swiftModuleInputFiles(moduleRoot)) {
95871
- hash.update(relative3);
95872
- hash.update(String(import_node_fs117.default.statSync(import_node_path119.default.join(moduleRoot, relative3)).mtimeMs));
95873
- }
95874
- return hash.digest("hex");
95972
+ return `${moduleRoot}\0${swiftModuleStamp(moduleRoot)}`;
95875
95973
  }
95876
95974
  function otherInputs(input) {
95877
95975
  const { files: _files, ...rest } = input;
@@ -95991,7 +96089,7 @@ function packageSources(packagePath, hosted = false, linked = /* @__PURE__ */ ne
95991
96089
  for (const file of sourceFiles(packagePath)) {
95992
96090
  const relative3 = import_node_path119.default.relative(packagePath, file).split(import_node_path119.default.sep).join(import_node_path119.default.posix.sep);
95993
96091
  if (manifests.has(file) || xcode?.packageFiles.has(file)) continue;
95994
- files2[xcode ? xcodeInputKey(xcode, file, relative3) : relative3] = (xcode?.nativeFiles.get(file) ?? readPackageFile2(packagePath, file, limits.sourceBytes)).toString("utf8");
96092
+ files2[xcode ? xcodeInputKey(xcode, file, relative3) : relative3] = (xcode?.nativeFiles.get(file) ?? readPackageFileScoped(packagePath, file, limits.sourceBytes)).toString("utf8");
95995
96093
  }
95996
96094
  if (xcode) {
95997
96095
  for (const [file, contents2] of xcode.nativeFiles)
@@ -96286,48 +96384,52 @@ async function compile(packagePath, stamp, moduleRootOverride, hosted, snapshot,
96286
96384
  const moduleRoot = moduleRootOverride ?? linkedModuleRoots(packagePath).find(
96287
96385
  (root) => import_node_fs117.default.existsSync(import_node_path119.default.join(root, "toolchain.json"))
96288
96386
  ) ?? await swiftDistributionRoot(signal);
96289
- const toolchain = swiftModuleToolchain(moduleRoot);
96387
+ const release = swiftModuleRelease(moduleRoot);
96290
96388
  const input = snapshotCompileInput(snapshot);
96291
96389
  const compiled = {
96292
96390
  files: input.files,
96293
96391
  inputs: otherInputs(input),
96294
96392
  module: moduleStamp(packagePath, moduleRootOverride, false)
96295
96393
  };
96296
- const parsed2 = compileTargets(input);
96297
- const targets = parsed2.map((target) => swiftTargetModuleName(target.name));
96298
- const byPath = [...parsed2].sort((left, right) => right.path.length - left.path.length);
96299
- const clangModulesByTarget = new Map(
96300
- (input.nativeTargets ?? []).map(({ name: name3, headerSearchPaths }) => [
96301
- name3,
96302
- headerSearchPaths.flatMap((directory2) => {
96303
- const map2 = input.files[import_node_path119.default.posix.join(directory2, "module.modulemap")] ?? input.files[import_node_path119.default.posix.join(directory2, "module.map")];
96304
- return map2 === void 0 ? [] : moduleMapModules(map2).map(({ name: name4 }) => name4);
96305
- })
96306
- ])
96307
- );
96308
- const providedByFile = (file) => {
96309
- const owner = byPath.find(
96310
- (target) => target.path === "." ? true : file.startsWith(`${target.path}/`)
96394
+ const verifyMissingModules = async (toolchainBin) => {
96395
+ const parsed2 = compileTargets(input);
96396
+ const targets = parsed2.map((target) => swiftTargetModuleName(target.name));
96397
+ const byPath = [...parsed2].sort((left, right) => right.path.length - left.path.length);
96398
+ const clangModulesByTarget = new Map(
96399
+ (input.nativeTargets ?? []).map(({ name: name3, headerSearchPaths }) => [
96400
+ name3,
96401
+ headerSearchPaths.flatMap((directory2) => {
96402
+ const map2 = input.files[import_node_path119.default.posix.join(directory2, "module.modulemap")] ?? input.files[import_node_path119.default.posix.join(directory2, "module.map")];
96403
+ return map2 === void 0 ? [] : moduleMapModules(map2).map(({ name: name4 }) => name4);
96404
+ })
96405
+ ])
96406
+ );
96407
+ const providedByFile = (file) => {
96408
+ const owner = byPath.find(
96409
+ (target) => target.path === "." ? true : file.startsWith(`${target.path}/`)
96410
+ );
96411
+ if (!owner) return [];
96412
+ const clangModules = clangModulesByTarget.get(owner.name) ?? [];
96413
+ return owner.experimentalFeatures?.includes("BuiltinModule") ? [...clangModules, "Builtin"] : clangModules;
96414
+ };
96415
+ const missing = missingSwiftModules(
96416
+ input.files,
96417
+ /* @__PURE__ */ new Set([
96418
+ ...swiftAvailableModules(moduleRoot, toolchainBin),
96419
+ // a project without a manifest compiles as the template's one App target
96420
+ ...targets.length > 0 ? targets : ["App"],
96421
+ // a system target's clang module name need not match its target name
96422
+ ...swiftSystemLibrarySurface(input.files, parsed2).modules,
96423
+ ...Object.keys(input.binaryModules ?? {}),
96424
+ ...snapshot.nativeModules
96425
+ ]),
96426
+ providedByFile
96311
96427
  );
96312
- if (!owner) return [];
96313
- const clangModules = clangModulesByTarget.get(owner.name) ?? [];
96314
- return owner.experimentalFeatures?.includes("BuiltinModule") ? [...clangModules, "Builtin"] : clangModules;
96428
+ if (missing.size > 0)
96429
+ throw new SwiftMissingModulesError(
96430
+ await missingModulesMessage(packagePath, missing)
96431
+ );
96315
96432
  };
96316
- const missing = missingSwiftModules(
96317
- input.files,
96318
- /* @__PURE__ */ new Set([
96319
- ...swiftAvailableModules(moduleRoot, toolchain.toolchainBin),
96320
- // a project without a manifest compiles as the template's one App target
96321
- ...targets.length > 0 ? targets : ["App"],
96322
- // a system target's clang module name need not match its target name
96323
- ...swiftSystemLibrarySurface(input.files, parsed2).modules,
96324
- ...Object.keys(input.binaryModules ?? {}),
96325
- ...snapshot.nativeModules
96326
- ]),
96327
- providedByFile
96328
- );
96329
- if (missing.size > 0)
96330
- throw new SwiftMissingModulesError(await missingModulesMessage(packagePath, missing));
96331
96433
  const artifact = await compileSwiftProjectUnit(input, {
96332
96434
  // the compile rewrites Sources/App in its root before swiftpm builds, and
96333
96435
  // a root lock orders every process using it, so two vites on one root
@@ -96337,7 +96439,9 @@ async function compile(packagePath, stamp, moduleRootOverride, hosted, snapshot,
96337
96439
  // incremental build across restarts.
96338
96440
  buildRoot: swiftBuildRoot(packagePath, moduleRoot),
96339
96441
  moduleRoot,
96340
- ...toolchain,
96442
+ release,
96443
+ resolveToolchain: () => swiftModuleToolchain(moduleRoot).toolchainBin,
96444
+ beforeCompile: verifyMissingModules,
96341
96445
  signal
96342
96446
  }).catch((error) => {
96343
96447
  const report = error instanceof Error ? swiftApiGapReport(error.message) : null;
@@ -96548,9 +96652,11 @@ function currentStamp(project2, moduleRoot) {
96548
96652
  );
96549
96653
  }
96550
96654
  function artifactFor(project2, entry, moduleRoot, signal = project2.signal) {
96551
- return withXcodeLayout(
96552
- project2.packagePath,
96553
- () => scopedArtifact(project2, entry, moduleRoot, signal)
96655
+ return withSwiftModuleDigestScope(
96656
+ () => withXcodeLayout(
96657
+ project2.packagePath,
96658
+ () => scopedArtifact(project2, entry, moduleRoot, signal)
96659
+ )
96554
96660
  );
96555
96661
  }
96556
96662
  function scopedArtifact(project2, entry, moduleRoot, signal) {
@@ -96611,6 +96717,48 @@ function scopedArtifact(project2, entry, moduleRoot, signal) {
96611
96717
  project2.building = { stamp, promise: fresh, signal };
96612
96718
  return fresh;
96613
96719
  }
96720
+ function readCachedSplitBinding(cacheDir6) {
96721
+ const receiptFile2 = import_node_path119.default.join(cacheDir6, "receipt.json");
96722
+ if (!import_node_fs117.default.existsSync(receiptFile2)) return null;
96723
+ try {
96724
+ const receipt = JSON.parse(import_node_fs117.default.readFileSync(receiptFile2, "utf8"));
96725
+ 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"))
96726
+ return null;
96727
+ const binding = import_node_fs117.default.readFileSync(import_node_path119.default.join(cacheDir6, "binding.bin"));
96728
+ if ((0, import_node_crypto72.createHash)("sha256").update(binding).digest("hex") !== receipt.digest) return null;
96729
+ const later = receipt.later.map((sha2564, index) => {
96730
+ const bytes = import_node_fs117.default.readFileSync(import_node_path119.default.join(cacheDir6, `later-${index}.bin`));
96731
+ if ((0, import_node_crypto72.createHash)("sha256").update(bytes).digest("hex") !== sha2564)
96732
+ throw new SyntaxError("digest mismatch");
96733
+ return { sha256: sha2564, bytes };
96734
+ });
96735
+ return { digest: receipt.digest, binding, later };
96736
+ } catch {
96737
+ return null;
96738
+ }
96739
+ }
96740
+ function writeCachedSplitBinding(cacheDir6, digest2, binding, later) {
96741
+ const parent = import_node_path119.default.dirname(cacheDir6);
96742
+ import_node_fs117.default.mkdirSync(parent, { recursive: true });
96743
+ const staging = `${cacheDir6}.${process.pid}.${(0, import_node_crypto72.randomUUID)()}.tmp`;
96744
+ try {
96745
+ import_node_fs117.default.mkdirSync(staging, { recursive: true });
96746
+ import_node_fs117.default.writeFileSync(import_node_path119.default.join(staging, "binding.bin"), binding);
96747
+ for (let index = 0; index < later.length; index++)
96748
+ import_node_fs117.default.writeFileSync(import_node_path119.default.join(staging, `later-${index}.bin`), later[index].bytes);
96749
+ import_node_fs117.default.writeFileSync(
96750
+ import_node_path119.default.join(staging, "receipt.json"),
96751
+ JSON.stringify({ digest: digest2, later: later.map(({ sha256: sha2564 }) => sha2564) })
96752
+ );
96753
+ try {
96754
+ import_node_fs117.default.renameSync(staging, cacheDir6);
96755
+ } catch {
96756
+ if (!import_node_fs117.default.existsSync(cacheDir6)) throw new Error(`failed to store ${cacheDir6}`);
96757
+ }
96758
+ } finally {
96759
+ import_node_fs117.default.rmSync(staging, { recursive: true, force: true });
96760
+ }
96761
+ }
96614
96762
  async function splitSdkBinding(sdk2, splitKey, plan) {
96615
96763
  const key2 = `${sdk2.binding.sha256}:${splitKey}`;
96616
96764
  if (sdkSplitBindings.has(key2)) return;
@@ -96618,15 +96766,29 @@ async function splitSdkBinding(sdk2, splitKey, plan) {
96618
96766
  Promise.resolve().then(() => (init_swift_sdk_later_data(), swift_sdk_later_data_exports)),
96619
96767
  Promise.resolve().then(() => (init_swift_sdk_image(), swift_sdk_image_exports))
96620
96768
  ]);
96621
- const split = splitSwiftSdkLaterData2(
96622
- import_node_path119.default.dirname(swiftSdkImageFile2(sdk2.key)),
96623
- sdk2.binding.bytes,
96624
- plan
96625
- );
96769
+ const sdkDirectory = import_node_path119.default.dirname(swiftSdkImageFile2(sdk2.key));
96770
+ const planDigest = (0, import_node_crypto72.createHash)("sha256").update(plan).digest("hex");
96771
+ const cacheDir6 = import_node_path119.default.join(
96772
+ sdkDirectory,
96773
+ "split-bindings-v1",
96774
+ (0, import_node_crypto72.createHash)("sha256").update(`${sdk2.binding.sha256}\0${planDigest}`).digest("hex").slice(0, 32)
96775
+ );
96776
+ const cached2 = readCachedSplitBinding(cacheDir6);
96777
+ if (cached2) {
96778
+ sdkBindingFiles.set(cached2.digest, cached2.binding);
96779
+ for (const { sha256: sha2564, bytes } of cached2.later) sdkBindingFiles.set(sha2564, bytes);
96780
+ sdkSplitBindings.set(key2, cached2.digest);
96781
+ return;
96782
+ }
96783
+ const split = splitSwiftSdkLaterData2(sdkDirectory, sdk2.binding.bytes, plan);
96626
96784
  const digest2 = (0, import_node_crypto72.createHash)("sha256").update(split.binding).digest("hex");
96785
+ const later = split.later.map((bytes) => ({
96786
+ sha256: (0, import_node_crypto72.createHash)("sha256").update(bytes).digest("hex"),
96787
+ bytes
96788
+ }));
96789
+ writeCachedSplitBinding(cacheDir6, digest2, split.binding, later);
96627
96790
  sdkBindingFiles.set(digest2, split.binding);
96628
- for (const later of split.later)
96629
- sdkBindingFiles.set((0, import_node_crypto72.createHash)("sha256").update(later).digest("hex"), later);
96791
+ for (const { sha256: sha2564, bytes } of later) sdkBindingFiles.set(sha2564, bytes);
96630
96792
  sdkSplitBindings.set(key2, digest2);
96631
96793
  }
96632
96794
  function swiftSdkEntryAssets(origin, image, sdkDigest = image.sdk?.sha256) {
@@ -96716,15 +96878,15 @@ async function swiftArtifactAssets(artifact, { sdkUrl, sdkBindingUrl }) {
96716
96878
  }
96717
96879
  return assets2;
96718
96880
  }
96719
- var import_node_async_hooks3, import_node_child_process61, import_node_crypto72, import_node_fs117, import_node_os26, import_node_path119, 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;
96881
+ var import_node_async_hooks4, import_node_child_process61, import_node_crypto72, import_node_fs117, import_node_os27, import_node_path119, 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;
96720
96882
  var init_swift_host = __esm({
96721
96883
  "src/swift-host.ts"() {
96722
96884
  "use strict";
96723
- import_node_async_hooks3 = require("node:async_hooks");
96885
+ import_node_async_hooks4 = require("node:async_hooks");
96724
96886
  import_node_child_process61 = require("node:child_process");
96725
96887
  import_node_crypto72 = require("node:crypto");
96726
96888
  import_node_fs117 = __toESM(require("node:fs"), 1);
96727
- import_node_os26 = __toESM(require("node:os"), 1);
96889
+ import_node_os27 = __toESM(require("node:os"), 1);
96728
96890
  import_node_path119 = __toESM(require("node:path"), 1);
96729
96891
  init_pngHeader();
96730
96892
  init_nativeSdkBindingContract();
@@ -96754,6 +96916,7 @@ var init_swift_host = __esm({
96754
96916
  init_swift_packages();
96755
96917
  init_swift_pdf_raster();
96756
96918
  init_swift_sdk_image_wasm();
96919
+ init_swift_sdk_surface();
96757
96920
  init_swift_shipped_binaries();
96758
96921
  init_swift_source_file();
96759
96922
  init_swift_standin_config();
@@ -96774,11 +96937,12 @@ var init_swift_host = __esm({
96774
96937
  SKIP_ROOT_DIRS = /* @__PURE__ */ new Set(["dist", "types", "build", "ios", "android"]);
96775
96938
  NATIVE_DESCRIPTOR = ".one-native-source.json";
96776
96939
  NATIVE_GLUE = ".one-native-source.swift.txt";
96940
+ packageReadScopes = new import_node_async_hooks4.AsyncLocalStorage();
96777
96941
  SwiftMissingModulesError = class extends Error {
96778
96942
  };
96779
96943
  swiftArtifactDigests = /* @__PURE__ */ new WeakMap();
96780
96944
  sharedProjects = /* @__PURE__ */ new Map();
96781
- projectScope = new import_node_async_hooks3.AsyncLocalStorage();
96945
+ projectScope = new import_node_async_hooks4.AsyncLocalStorage();
96782
96946
  projects = () => projectScope.getStore()?.projects ?? sharedProjects;
96783
96947
  sharedSourceEntries = /* @__PURE__ */ new Map();
96784
96948
  sourceEntries = () => projectScope.getStore()?.sourceEntries ?? sharedSourceEntries;
@@ -96789,7 +96953,7 @@ var init_swift_host = __esm({
96789
96953
  XCODE_APP_DIR = "__app__";
96790
96954
  XCODE_FRAMEWORKS_DIR = "__frameworks__";
96791
96955
  XCODE_PACKAGES_DIR = SWIFT_REMOTE_PACKAGES_DIR;
96792
- layoutScope = new import_node_async_hooks3.AsyncLocalStorage();
96956
+ layoutScope = new import_node_async_hooks4.AsyncLocalStorage();
96793
96957
  HOSTED_LIMITS = {
96794
96958
  sourceBytes: MAX_SWIFT_COMPILE_SOURCE_BYTES,
96795
96959
  resources: MAX_SWIFT_COMPILE_RESOURCES,
@@ -102822,14 +102986,14 @@ function collectTurboCompileInput(collection, runtime, iosDeploymentTarget, depe
102822
102986
  resources: { ...dependencies?.resources, ...collection.resources }
102823
102987
  };
102824
102988
  }
102825
- var import_node_crypto75, import_node_fs122, import_node_module17, import_node_os27, import_node_path124;
102989
+ var import_node_crypto75, import_node_fs122, import_node_module17, import_node_os28, import_node_path124;
102826
102990
  var init_turbo_compile = __esm({
102827
102991
  "src/turbo-compile.ts"() {
102828
102992
  "use strict";
102829
102993
  import_node_crypto75 = require("node:crypto");
102830
102994
  import_node_fs122 = __toESM(require("node:fs"), 1);
102831
102995
  import_node_module17 = require("node:module");
102832
- import_node_os27 = __toESM(require("node:os"), 1);
102996
+ import_node_os28 = __toESM(require("node:os"), 1);
102833
102997
  import_node_path124 = __toESM(require("node:path"), 1);
102834
102998
  init_native_app_identity_project();
102835
102999
  init_nitro_adapter();
@@ -105018,7 +105182,7 @@ function expoUnitAppPaths(unit2) {
105018
105182
  });
105019
105183
  }
105020
105184
  function expoSwiftPackage(appKey, name3) {
105021
- return import_node_path128.default.join(import_node_os28.default.tmpdir(), "peach-expo-swift", appKey, `p${process.pid}`, name3);
105185
+ return import_node_path128.default.join(import_node_os29.default.tmpdir(), "peach-expo-swift", appKey, `p${process.pid}`, name3);
105022
105186
  }
105023
105187
  function failureRecordPath(packagePath) {
105024
105188
  const app = import_node_path128.default.dirname(import_node_path128.default.dirname(packagePath));
@@ -105118,6 +105282,7 @@ async function compileExpoSwiftModulesTraced(root, base, publishArtifact, option
105118
105282
  settings
105119
105283
  );
105120
105284
  const provider = linked2.some((unit2) => unit2.reactNativeProvider) ? reactProvider : void 0;
105285
+ const providerTargets = provider ? swiftManifestTargets(provider.files["Package.swift"]) : [];
105121
105286
  if (provider) {
105122
105287
  for (const [file, source] of Object.entries(provider.files)) {
105123
105288
  if (file === "Package.swift" || file === provider.entry) continue;
@@ -105129,7 +105294,7 @@ async function compileExpoSwiftModulesTraced(root, base, publishArtifact, option
105129
105294
  "target",
105130
105295
  "systemLibrary"
105131
105296
  ]).map(({ kind, call }) => `.${kind}(${call},`);
105132
- const names = swiftManifestTargets(provider.files["Package.swift"]).filter((target) => !target.executable).map((target) => JSON.stringify(target.name));
105297
+ const names = providerTargets.filter((target) => !target.executable).map((target) => JSON.stringify(target.name));
105133
105298
  const floor = inheritExecutableFloor(
105134
105299
  linked2.flatMap((unit2) => unit2.nativeTargets ?? [])
105135
105300
  )?.find((target) => target.name === "PeachExpoApp")?.deploymentTarget;
@@ -105176,14 +105341,29 @@ async function compileExpoSwiftModulesTraced(root, base, publishArtifact, option
105176
105341
  ...linked2.flatMap((unit2) => Object.entries(binaryModules.get(unit2) ?? {}))
105177
105342
  ]);
105178
105343
  projectFor(packagePath).libraries = linkedLibraries.size > 0 ? Object.fromEntries(linkedLibraries) : void 0;
105179
- projectFor(packagePath).nativeTargets = inheritExecutableFloor([
105180
- ...new Map(
105181
- [
105182
- ...linked2.flatMap((unit2) => unit2.nativeTargets ?? []),
105183
- ...provider?.nativeTargets ?? []
105184
- ].map((target) => [target.name, target])
105185
- ).values()
105186
- ]);
105344
+ const releaseFabric = providerTargets.some(
105345
+ (target) => target.name === "TurboCore" && target.cxxDefines?.includes("NDEBUG")
105346
+ );
105347
+ const releaseTargets = new Set(
105348
+ linked2.filter((unit2) => releaseFabric && unit2.reactNativeProvider).flatMap((unit2) => (unit2.nativeTargets ?? []).map((target) => target.name))
105349
+ );
105350
+ const nativeTargets2 = [
105351
+ ...linked2.flatMap((unit2) => unit2.nativeTargets ?? []),
105352
+ ...provider?.nativeTargets ?? []
105353
+ ];
105354
+ const nativeTargetsByName = new Map(
105355
+ nativeTargets2.map((target) => [target.name, target])
105356
+ );
105357
+ projectFor(packagePath).nativeTargets = inheritExecutableFloor(
105358
+ Array.from(
105359
+ nativeTargetsByName.values(),
105360
+ (target) => releaseTargets.has(target.name) ? {
105361
+ ...target,
105362
+ cxxFlags: [...target.cxxFlags, "-DNDEBUG"],
105363
+ importerFlags: [...target.importerFlags, "-DNDEBUG"]
105364
+ } : target
105365
+ )
105366
+ );
105187
105367
  projectFor(packagePath).nativeFiles = Object.assign(
105188
105368
  {},
105189
105369
  ...linked2.map((unit2) => unit2.nativeFiles),
@@ -105722,16 +105902,16 @@ async function compileExpoSwiftModulesTraced(root, base, publishArtifact, option
105722
105902
  throw failure2;
105723
105903
  }
105724
105904
  }
105725
- var import_node_async_hooks4, import_node_child_process65, import_node_crypto78, import_node_fs126, import_node_module19, import_node_os28, import_node_path128, 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;
105905
+ var import_node_async_hooks5, import_node_child_process65, import_node_crypto78, import_node_fs126, import_node_module19, import_node_os29, import_node_path128, 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;
105726
105906
  var init_expo_swift_host = __esm({
105727
105907
  "src/expo-swift-host.ts"() {
105728
105908
  "use strict";
105729
- import_node_async_hooks4 = require("node:async_hooks");
105909
+ import_node_async_hooks5 = require("node:async_hooks");
105730
105910
  import_node_child_process65 = require("node:child_process");
105731
105911
  import_node_crypto78 = require("node:crypto");
105732
105912
  import_node_fs126 = __toESM(require("node:fs"), 1);
105733
105913
  import_node_module19 = require("node:module");
105734
- import_node_os28 = __toESM(require("node:os"), 1);
105914
+ import_node_os29 = __toESM(require("node:os"), 1);
105735
105915
  import_node_path128 = __toESM(require("node:path"), 1);
105736
105916
  import_node_url4 = require("node:url");
105737
105917
  import_node_util18 = require("node:util");
@@ -105769,7 +105949,7 @@ var init_expo_swift_host = __esm({
105769
105949
  scriptEnv = { ...process.env, [PEACH_FORKED_SCRIPT_ENV]: "1" };
105770
105950
  EXPO_SWIFT_ENTRY = "Sources/PeachExpoApp/PeachExpoEntry.swift";
105771
105951
  WITNESS_BATCH = 200;
105772
- traceStore = new import_node_async_hooks4.AsyncLocalStorage();
105952
+ traceStore = new import_node_async_hooks5.AsyncLocalStorage();
105773
105953
  discoveryCache = /* @__PURE__ */ new Map();
105774
105954
  preparedCache = /* @__PURE__ */ new Map();
105775
105955
  savedFs = null;
@@ -105926,7 +106106,7 @@ var init_nitro_superset = __esm({
105926
106106
  init_nitroContract();
105927
106107
  init_swift_standin_digest();
105928
106108
  NITRO_SUPERSET_ENTRY_NAME = "superset";
105929
- NITRO_COMPILER_DIGEST = true ? "f80b001abb12451680ce50211537f58ece77da31c3c32d2580b97d068226cbdd" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
106109
+ NITRO_COMPILER_DIGEST = true ? "f6a7a95d8b94acf3b85a06a8646dd3fa62a10b41bd72c1a91c9cfd465a4020e8" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
105930
106110
  nitroSupersetLock = parseLock(nitro_superset_lock_default);
105931
106111
  nitroSupersetKey = (inputs2) => nativeEntryKey({ ...inputs2, compiler: NITRO_COMPILER_DIGEST });
105932
106112
  published2 = /* @__PURE__ */ new Map();
@@ -105989,7 +106169,7 @@ async function selectCompiledNitroProviders(appRoot, answered = peachAnsweredNat
105989
106169
  // src/nitro-compile.ts
105990
106170
  var import_node_crypto80 = require("node:crypto");
105991
106171
  var import_node_fs128 = __toESM(require("node:fs"), 1);
105992
- var import_node_os29 = __toESM(require("node:os"), 1);
106172
+ var import_node_os30 = __toESM(require("node:os"), 1);
105993
106173
  var import_node_path130 = __toESM(require("node:path"), 1);
105994
106174
  init_answeredNativePackages();
105995
106175
  init_installed_native_libraries();
@@ -106863,7 +107043,7 @@ async function prepareNitroCompileInput(options2) {
106863
107043
  );
106864
107044
  if (reactProviders.length > 0 || usesReactHeaders) {
106865
107045
  const nitroReactCodegenDir = import_node_fs128.default.mkdtempSync(
106866
- import_node_path130.default.join(import_node_os29.default.tmpdir(), "peach-nitro-react-")
107046
+ import_node_path130.default.join(import_node_os30.default.tmpdir(), "peach-nitro-react-")
106867
107047
  );
106868
107048
  let support;
106869
107049
  try {
@@ -106954,7 +107134,7 @@ async function prepareNitroCompileInput(options2) {
106954
107134
  const key2 = (0, import_node_crypto80.createHash)("sha256").update(
106955
107135
  collection.providers.map(({ root, hybridObjects }) => `${root}\0${hybridObjects.join(",")}`).join("\0")
106956
107136
  ).update("\0").update(import_node_fs128.default.realpathSync(options2.moduleRoot)).update("\0").update(options2.configuration).digest("hex");
106957
- const packagePath = import_node_path130.default.join(import_node_os29.default.tmpdir(), "peach-nitro-swift", key2, `p${process.pid}`);
107137
+ const packagePath = import_node_path130.default.join(import_node_os30.default.tmpdir(), "peach-nitro-swift", key2, `p${process.pid}`);
106958
107138
  const sharedLibrary = [...nativeLibraries.values()].find(
106959
107139
  (pod) => pod.sharedLibrary
106960
107140
  )?.sharedLibrary;