peachsim 0.1.2768 → 0.1.2770

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 (132) 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 +356 -77
  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 +1 -1
  25. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  26. package/dist-lib/esm-chunks/{acorn-4DR5UGFN.mjs → acorn-A3J4BCR3.mjs} +3 -3
  27. package/dist-lib/esm-chunks/{chunk-P4QFEMNW.mjs → chunk-25CEOCB7.mjs} +1 -1
  28. package/dist-lib/esm-chunks/{chunk-TNCPRFBQ.mjs → chunk-4IOWCCHS.mjs} +1 -1
  29. package/dist-lib/esm-chunks/{chunk-LMELFNFT.mjs → chunk-4LHY3IKU.mjs} +1 -1
  30. package/dist-lib/esm-chunks/{chunk-76RJVPS6.mjs → chunk-5YKVWHMS.mjs} +4 -4
  31. package/dist-lib/esm-chunks/{chunk-SBIBHVCU.mjs → chunk-CFWWQTJ5.mjs} +26 -13
  32. package/dist-lib/esm-chunks/{chunk-OASENKSR.mjs → chunk-CQBPQSRE.mjs} +1 -1
  33. package/dist-lib/esm-chunks/{chunk-LDBKSWMK.mjs → chunk-F3FQZ6SE.mjs} +1 -1
  34. package/dist-lib/esm-chunks/{chunk-NRFW2S2E.mjs → chunk-FBVGSJJE.mjs} +1 -1
  35. package/dist-lib/esm-chunks/{chunk-UP76RU63.mjs → chunk-FJZINSC2.mjs} +1 -1
  36. package/dist-lib/esm-chunks/{chunk-LW6EFCKB.mjs → chunk-JGCIXB77.mjs} +1 -1
  37. package/dist-lib/esm-chunks/{chunk-FM4IQKZR.mjs → chunk-JN4WVMT4.mjs} +2 -2
  38. package/dist-lib/esm-chunks/{chunk-IA466TSB.mjs → chunk-KSVTJ3JI.mjs} +1 -1
  39. package/dist-lib/esm-chunks/{chunk-IXCYOMAY.mjs → chunk-NJNU5MPO.mjs} +1 -1
  40. package/dist-lib/esm-chunks/{chunk-QS3CSXQR.mjs → chunk-PT3YJZI2.mjs} +1 -1
  41. package/dist-lib/esm-chunks/{chunk-K6H2SOFN.mjs → chunk-Q4BHHFX7.mjs} +1 -1
  42. package/dist-lib/esm-chunks/{chunk-FY6GYFKM.mjs → chunk-RBNIOLS5.mjs} +1 -1
  43. package/dist-lib/esm-chunks/{chunk-SZC5VUTW.mjs → chunk-RG5UROLK.mjs} +1 -1
  44. package/dist-lib/esm-chunks/{chunk-FSZC4K7L.mjs → chunk-RSRSOEDS.mjs} +5 -5
  45. package/dist-lib/esm-chunks/{chunk-CWLOVTXX.mjs → chunk-TTOBAW65.mjs} +3 -3
  46. package/dist-lib/esm-chunks/{chunk-PYVRYHRN.mjs → chunk-TXTIDFLT.mjs} +1 -1
  47. package/dist-lib/esm-chunks/{chunk-NNHQMYXA.mjs → chunk-USSIX7QH.mjs} +377 -106
  48. package/dist-lib/esm-chunks/{chunk-EP3OX3CJ.mjs → chunk-W4ZOHLQE.mjs} +6 -6
  49. package/dist-lib/esm-chunks/{chunk-MC3T7WXI.mjs → chunk-Y4DWEUO2.mjs} +1 -1
  50. package/dist-lib/esm-chunks/{chunk-6FVNWSDJ.mjs → chunk-YGXQSWWR.mjs} +1 -1
  51. package/dist-lib/esm-chunks/{metro-layout-parser-4TX56S4G.mjs → metro-layout-parser-QXJ7SU7Z.mjs} +3 -3
  52. package/dist-lib/esm-chunks/{swift-package-prebuilt-7PIYWUST.mjs → swift-package-prebuilt-3YL3XSX3.mjs} +12 -12
  53. package/dist-lib/esm-chunks/{swift-sdk-app-module-7NOBYKIE.mjs → swift-sdk-app-module-QSLP6GQS.mjs} +22 -17
  54. package/dist-lib/esm-chunks/{swift-sdk-image-FTSV6Y6Y.mjs → swift-sdk-image-XJV6ZFNG.mjs} +16 -16
  55. package/dist-lib/esm-chunks/{swift-sdk-image-producer-TDBFULDN.mjs → swift-sdk-image-producer-NFE2G4PN.mjs} +5 -5
  56. package/dist-lib/expo-swift-bundle.cjs +356 -77
  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 +356 -77
  61. package/dist-lib/host/fetch-proxy-handler.cjs +24 -20
  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 +1 -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 +1 -1
  81. package/dist-lib/pdfium-raster.mjs +2 -2
  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 +85 -85
  87. package/dist-lib/public-origins-lib.json +64 -64
  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 +356 -77
  95. package/dist-lib/swift-compile.cjs +336 -57
  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/src/render-worker/aux-pointer-native.d.ts +4 -0
  123. package/dist-types/packages/peach-engine/src/render-worker/auxPointerContract.d.ts +4 -0
  124. package/package.json +1 -1
  125. package/src/case-insensitive-header-overlay.ts +9 -1
  126. package/src/native-static-libraries.ts +16 -16
  127. package/src/swift-compile.ts +158 -42
  128. package/src/swift-distribution-mirror.ts +280 -10
  129. package/src/swift-objc-prebuilt.ts +10 -1
  130. package/src/swift-objc-standin.ts +6 -1
  131. package/src/swift-sdk-app-module.ts +10 -3
  132. package/src/swift-sdk-surface.ts +5 -1
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2768 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2770 | (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;
@@ -3712,7 +3712,12 @@ function contents(node) {
3712
3712
  }))
3713
3713
  ];
3714
3714
  }
3715
- function caseInsensitiveHeaderOverlay(directory, roots, listed) {
3715
+ function clearCaseInsensitiveHeaderOverlayCache(rootPrefix) {
3716
+ const prefix = `${rootPrefix}${import_node_path8.default.sep}`;
3717
+ for (const key of scans.keys())
3718
+ if (key === rootPrefix || key.startsWith(prefix)) scans.delete(key);
3719
+ }
3720
+ function caseInsensitiveHeaderOverlay(directory, roots, listed, fixedName) {
3716
3721
  let known = scans;
3717
3722
  if (listed) {
3718
3723
  known = listedScans.get(listed) ?? /* @__PURE__ */ new Map();
@@ -3733,7 +3738,7 @@ function caseInsensitiveHeaderOverlay(directory, roots, listed) {
3733
3738
  const text2 = JSON.stringify({ "case-sensitive": "false", roots: roots_, version: 0 });
3734
3739
  const file = import_node_path8.default.join(
3735
3740
  directory,
3736
- `case-insensitive-${(0, import_node_crypto4.createHash)("sha256").update(text2).digest("hex").slice(0, 16)}.yaml`
3741
+ fixedName ?? `case-insensitive-${(0, import_node_crypto4.createHash)("sha256").update(text2).digest("hex").slice(0, 16)}.yaml`
3737
3742
  );
3738
3743
  writeBuildFile(file, text2);
3739
3744
  return file;
@@ -4315,15 +4320,17 @@ var init_swift_standin_emit = __esm({
4315
4320
  });
4316
4321
 
4317
4322
  // src/swift-objc-standin.ts
4318
- function objcSdkIntakeFlags(headers, toolchainBin, minimum) {
4323
+ function objcSdkIntakeFlags(headers, toolchainBin, minimum, overlayDirectory) {
4319
4324
  const caseOverlay = caseInsensitiveHeaderOverlay(
4320
- import_node_path10.default.join(swiftCacheDir(), "swift-header-case"),
4325
+ overlayDirectory ?? import_node_path10.default.join(swiftCacheDir(), "swift-header-case"),
4321
4326
  [
4322
4327
  import_node_path10.default.join(headers, "System/Library/Frameworks"),
4323
4328
  import_node_path10.default.join(headers, "wasm/include"),
4324
4329
  import_node_path10.default.join(headers, "wasm/intrinsics"),
4325
4330
  import_node_path10.default.join(headers, "usr/include")
4326
- ]
4331
+ ],
4332
+ void 0,
4333
+ overlayDirectory ? SWIFT_SDK_HEADER_CASE_OVERLAY : void 0
4327
4334
  );
4328
4335
  return [
4329
4336
  ...swiftObjCPlatformFlags(toolchainBin, minimum),
@@ -4365,7 +4372,7 @@ function iosDeploymentMinimum(version2) {
4365
4372
  if (!parts) return void 0;
4366
4373
  return Number(parts[1]) * 1e4 + Number(parts[2] ?? 0) * 100 + Number(parts[3] ?? 0);
4367
4374
  }
4368
- var import_node_child_process6, import_node_crypto5, import_node_fs10, import_node_path10, NATIVE_GRAPH_SDK_VERSION, WASI_EMULATION, WASI_EMULATION_FLAGS, NATIVE_GRAPH_INPUTS, NATIVE_GRAPH_ID;
4375
+ var import_node_child_process6, import_node_crypto5, import_node_fs10, import_node_path10, NATIVE_GRAPH_SDK_VERSION, WASI_EMULATION, WASI_EMULATION_FLAGS, NATIVE_GRAPH_INPUTS, NATIVE_GRAPH_ID, SWIFT_SDK_HEADER_CASE_OVERLAY;
4369
4376
  var init_swift_objc_standin = __esm({
4370
4377
  "src/swift-objc-standin.ts"() {
4371
4378
  "use strict";
@@ -4396,6 +4403,7 @@ var init_swift_objc_standin = __esm({
4396
4403
  target: IOS_SDK_TARGET
4397
4404
  };
4398
4405
  NATIVE_GRAPH_ID = (0, import_node_crypto5.createHash)("sha256").update(JSON.stringify(NATIVE_GRAPH_INPUTS)).digest("hex");
4406
+ SWIFT_SDK_HEADER_CASE_OVERLAY = "sdk-header-case.yaml";
4399
4407
  }
4400
4408
  });
4401
4409
 
@@ -5554,9 +5562,179 @@ function syncSwiftDistributionMirror(root, source, manifest) {
5554
5562
  const partial = `${record}.${(0, import_node_crypto7.randomUUID)()}`;
5555
5563
  (0, import_node_fs13.writeFileSync)(partial, JSON.stringify(manifest.files));
5556
5564
  (0, import_node_fs13.renameSync)(partial, record);
5565
+ if ([...changed, ...removed].some(
5566
+ (file) => !file.startsWith("lib/") && !file.startsWith("modules/")
5567
+ )) {
5568
+ clearCaseInsensitiveHeaderOverlayCache(mirror);
5569
+ clearCaseInsensitiveHeaderOverlayCache(import_node_path13.default.join(root, SWIFT_SDK_MIRROR));
5570
+ }
5557
5571
  }
5558
5572
  return mirror;
5559
5573
  }
5574
+ function syncSwiftSdkMirror(root, frameworkRoot, toolchainBin, sourceSdkId) {
5575
+ const viewOptions = swiftSharedSdkViewOptions(
5576
+ frameworkRoot,
5577
+ true,
5578
+ toolchainBin,
5579
+ sourceSdkId
5580
+ );
5581
+ const sourceView = viewOptions[1];
5582
+ return syncSwiftSdkMirrorFromView(root, frameworkRoot, sourceView, sourceSdkId);
5583
+ }
5584
+ function syncSwiftSdkMirrorFromView(root, frameworkRoot, sourceView, sourceSdkId) {
5585
+ const mirror = import_node_path13.default.join(root, SWIFT_SDK_MIRROR);
5586
+ const bundle = import_node_path13.default.join(mirror, SWIFT_SDK_MIRROR_BUNDLE);
5587
+ const destTriple = import_node_path13.default.join(bundle, "sdk", SWIFT_WASM_TRIPLE);
5588
+ const bundleInfo = import_node_path13.default.join(bundle, "info.json");
5589
+ const recordFile = import_node_path13.default.join(mirror, SWIFT_SDK_MIRROR_RECORD);
5590
+ const syncingMarker = import_node_path13.default.join(mirror, SWIFT_SDK_MIRROR_SYNCING);
5591
+ const options = ["--swift-sdks-path", mirror];
5592
+ const interrupted = (0, import_node_fs13.existsSync)(syncingMarker);
5593
+ const previous = interrupted ? null : readSdkRecord(recordFile);
5594
+ if (previous && previous.sourceView === sourceView && previous.sourceSdkId === sourceSdkId && (0, import_node_fs13.existsSync)(bundleInfo) && (0, import_node_fs13.existsSync)(import_node_path13.default.join(destTriple, "swift-sdk.json"))) {
5595
+ return { id: SWIFT_SDK_MIRROR_ID, options, toolsetChanged: false };
5596
+ }
5597
+ const sourceTriple = resolveSdkViewTripleDir(sourceView, sourceSdkId);
5598
+ if (!previous) {
5599
+ if (!interrupted) (0, import_node_fs13.rmSync)(mirror, { recursive: true, force: true });
5600
+ (0, import_node_fs13.rmSync)(import_node_path13.default.join(root, ".build"), { recursive: true, force: true });
5601
+ }
5602
+ (0, import_node_fs13.mkdirSync)(mirror, { recursive: true });
5603
+ (0, import_node_fs13.writeFileSync)(syncingMarker, "1\n");
5604
+ const changed = [];
5605
+ const removed = [];
5606
+ const distributionPrefix = `${frameworkRoot}${import_node_path13.default.sep}`;
5607
+ syncSdkTree(sourceTriple, destTriple, "", distributionPrefix, changed, removed);
5608
+ const infoText = JSON.stringify(
5609
+ {
5610
+ artifacts: {
5611
+ [SWIFT_SDK_MIRROR_ID]: {
5612
+ type: "swiftSDK",
5613
+ variants: [{ path: `sdk/${SWIFT_WASM_TRIPLE}/swift-sdk.json` }],
5614
+ version: "0.0.1"
5615
+ }
5616
+ },
5617
+ schemaVersion: "1.0"
5618
+ },
5619
+ null,
5620
+ 2
5621
+ ) + "\n";
5622
+ if (!(0, import_node_fs13.existsSync)(bundleInfo) || (0, import_node_fs13.readFileSync)(bundleInfo, "utf8") !== infoText) {
5623
+ (0, import_node_fs13.mkdirSync)(bundle, { recursive: true });
5624
+ const partial = `${bundleInfo}.${(0, import_node_crypto7.randomUUID)()}`;
5625
+ (0, import_node_fs13.writeFileSync)(partial, infoText);
5626
+ (0, import_node_fs13.renameSync)(partial, bundleInfo);
5627
+ }
5628
+ const touched = [...changed, ...removed];
5629
+ const toolsetChanged = !previous || touched.some(
5630
+ (file) => file === "toolset.json" || file === "swift-sdk.json" || file.startsWith("swift.xctoolchain/usr/bin/")
5631
+ );
5632
+ if (previous) {
5633
+ if (toolsetChanged) {
5634
+ (0, import_node_fs13.rmSync)(import_node_path13.default.join(root, ".build"), { recursive: true, force: true });
5635
+ } else {
5636
+ const compileTouched = touched.filter(
5637
+ (file) => !file.endsWith(".a") && !file.endsWith(".o") && !file.startsWith("rust/") && file !== "runtime-products.json"
5638
+ );
5639
+ const headersChanged = compileTouched.some(
5640
+ (file) => !file.endsWith(".swiftmodule") && !file.endsWith(".swiftdoc") && !file.endsWith(".swiftsourceinfo") && !file.endsWith(".abi.json")
5641
+ );
5642
+ if (compileTouched.length > 0) {
5643
+ invalidateBuildDependents(
5644
+ root,
5645
+ [[Buffer.from(`${escapeDepPath(destTriple)}/`), ""]],
5646
+ new Set(compileTouched),
5647
+ headersChanged
5648
+ );
5649
+ }
5650
+ if (headersChanged) clearCaseInsensitiveHeaderOverlayCache(mirror);
5651
+ }
5652
+ } else {
5653
+ clearCaseInsensitiveHeaderOverlayCache(mirror);
5654
+ }
5655
+ const partialRecord = `${recordFile}.${(0, import_node_crypto7.randomUUID)()}`;
5656
+ (0, import_node_fs13.writeFileSync)(partialRecord, JSON.stringify({ version: 1, sourceView, sourceSdkId }));
5657
+ (0, import_node_fs13.renameSync)(partialRecord, recordFile);
5658
+ (0, import_node_fs13.rmSync)(syncingMarker, { force: true });
5659
+ return { id: SWIFT_SDK_MIRROR_ID, options, toolsetChanged };
5660
+ }
5661
+ function readSdkRecord(file) {
5662
+ if (!(0, import_node_fs13.existsSync)(file)) return null;
5663
+ const value = JSON.parse((0, import_node_fs13.readFileSync)(file, "utf8"));
5664
+ if (!isRecord(value) || value.version !== 1 || typeof value.sourceView !== "string" || typeof value.sourceSdkId !== "string")
5665
+ return null;
5666
+ return {
5667
+ version: value.version,
5668
+ sourceView: value.sourceView,
5669
+ sourceSdkId: value.sourceSdkId
5670
+ };
5671
+ }
5672
+ function resolveSdkViewTripleDir(sourceView, sourceSdkId) {
5673
+ for (const entry of (0, import_node_fs13.readdirSync)(sourceView, { withFileTypes: true })) {
5674
+ if (!entry.name.endsWith(".artifactbundle")) continue;
5675
+ const bundleDir = import_node_path13.default.join(sourceView, entry.name);
5676
+ const infoPath = import_node_path13.default.join(bundleDir, "info.json");
5677
+ if (!(0, import_node_fs13.existsSync)(infoPath)) continue;
5678
+ const info = JSON.parse((0, import_node_fs13.readFileSync)(infoPath, "utf8"));
5679
+ if (!isRecord(info) || !isRecord(info.artifacts)) continue;
5680
+ const artifact = info.artifacts[sourceSdkId];
5681
+ if (!isRecord(artifact) || !Array.isArray(artifact.variants)) continue;
5682
+ const first = artifact.variants[0];
5683
+ if (!isRecord(first) || typeof first.path !== "string") continue;
5684
+ return import_node_path13.default.dirname(import_node_path13.default.join(bundleDir, first.path));
5685
+ }
5686
+ throw new Error(`Swift SDK ${sourceSdkId} not found in view ${sourceView}`);
5687
+ }
5688
+ function collectRemovedFiles(dir, prefix, out) {
5689
+ for (const entry of (0, import_node_fs13.readdirSync)(dir, { withFileTypes: true })) {
5690
+ const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
5691
+ const full = import_node_path13.default.join(dir, entry.name);
5692
+ if (entry.isDirectory()) collectRemovedFiles(full, rel, out);
5693
+ else out.push(rel);
5694
+ }
5695
+ }
5696
+ function syncSdkTree(sourceDir, destDir, prefix, distributionPrefix, changed, removed) {
5697
+ (0, import_node_fs13.mkdirSync)(destDir, { recursive: true });
5698
+ const wanted = /* @__PURE__ */ new Set();
5699
+ for (const entry of (0, import_node_fs13.readdirSync)(sourceDir, { withFileTypes: true })) {
5700
+ wanted.add(entry.name);
5701
+ const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
5702
+ const src = import_node_path13.default.join(sourceDir, entry.name);
5703
+ const dest = import_node_path13.default.join(destDir, entry.name);
5704
+ const destLstat = (0, import_node_fs13.lstatSync)(dest, { throwIfNoEntry: false });
5705
+ if (entry.isSymbolicLink()) {
5706
+ const target = (0, import_node_fs13.readlinkSync)(src);
5707
+ if (target.startsWith(distributionPrefix)) {
5708
+ if (destLstat?.isSymbolicLink() && (0, import_node_fs13.readlinkSync)(dest) === target) continue;
5709
+ if (destLstat) (0, import_node_fs13.rmSync)(dest, { recursive: true, force: true });
5710
+ (0, import_node_fs13.symlinkSync)(target, dest);
5711
+ changed.push(rel);
5712
+ continue;
5713
+ }
5714
+ }
5715
+ const srcStat = (0, import_node_fs13.statSync)(src, { throwIfNoEntry: false });
5716
+ if (!srcStat) continue;
5717
+ if (srcStat.isDirectory()) {
5718
+ if (destLstat && (!destLstat.isDirectory() || destLstat.isSymbolicLink()))
5719
+ (0, import_node_fs13.rmSync)(dest, { recursive: true, force: true });
5720
+ syncSdkTree(src, dest, rel, distributionPrefix, changed, removed);
5721
+ continue;
5722
+ }
5723
+ if (destLstat?.isFile() && !destLstat.isSymbolicLink() && destLstat.size === srcStat.size && (0, import_node_fs13.readFileSync)(src).equals((0, import_node_fs13.readFileSync)(dest)))
5724
+ continue;
5725
+ if (destLstat?.isDirectory()) (0, import_node_fs13.rmSync)(dest, { recursive: true, force: true });
5726
+ place(src, dest, (srcStat.mode & 73) !== 0 ? srcStat.mode & 511 : void 0);
5727
+ changed.push(rel);
5728
+ }
5729
+ for (const entry of (0, import_node_fs13.readdirSync)(destDir, { withFileTypes: true })) {
5730
+ if (wanted.has(entry.name)) continue;
5731
+ const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
5732
+ const dest = import_node_path13.default.join(destDir, entry.name);
5733
+ if (entry.isDirectory()) collectRemovedFiles(dest, rel, removed);
5734
+ else removed.push(rel);
5735
+ (0, import_node_fs13.rmSync)(dest, { recursive: true, force: true });
5736
+ }
5737
+ }
5560
5738
  function readRecord(file) {
5561
5739
  if (!(0, import_node_fs13.existsSync)(file)) return null;
5562
5740
  const value = JSON.parse((0, import_node_fs13.readFileSync)(file, "utf8"));
@@ -5568,24 +5746,33 @@ function readRecord(file) {
5568
5746
  }
5569
5747
  return files;
5570
5748
  }
5571
- function place(from, to) {
5749
+ function place(from, to, mode) {
5572
5750
  (0, import_node_fs13.mkdirSync)(import_node_path13.default.dirname(to), { recursive: true });
5573
5751
  const partial = `${to}.${(0, import_node_crypto7.randomUUID)()}`;
5574
5752
  (0, import_node_fs13.copyFileSync)(from, partial, import_node_fs13.constants.COPYFILE_FICLONE);
5753
+ if (mode !== void 0) (0, import_node_fs13.chmodSync)(partial, mode);
5575
5754
  (0, import_node_fs13.renameSync)(partial, to);
5576
5755
  }
5577
- function invalidateDependents(root, mirror, files) {
5578
- const read = new Set(files.filter((file) => !file.startsWith("lib/")));
5579
- if (read.size === 0) return;
5580
- const escapedMirror = mirror.replace(
5756
+ function escapeDepPath(directory) {
5757
+ return directory.replace(
5581
5758
  /[\\ #$]/g,
5582
5759
  (character) => character === "$" ? "$$" : `\\${character}`
5583
5760
  );
5761
+ }
5762
+ function invalidateDependents(root, mirror, files) {
5763
+ const read = new Set(files.filter((file) => !file.startsWith("lib/")));
5764
+ if (read.size === 0) return;
5584
5765
  const spellings = [
5585
- [Buffer.from(`${escapedMirror}/`), ""]
5766
+ [Buffer.from(`${escapeDepPath(mirror)}/`), ""]
5586
5767
  ];
5587
5768
  if (files.some((file) => file.startsWith("sdk/ios/")))
5588
5769
  spellings.push([Buffer.from("/darwin/"), "sdk/ios/"]);
5770
+ const headersChanged = files.some(
5771
+ (file) => !file.startsWith("lib/") && !file.startsWith("modules/")
5772
+ );
5773
+ invalidateBuildDependents(root, spellings, read, headersChanged);
5774
+ }
5775
+ function invalidateBuildDependents(root, spellings, read, headersChanged) {
5589
5776
  const names = (text2) => spellings.some(([prefix, base]) => {
5590
5777
  let end = 0;
5591
5778
  for (let at = text2.indexOf(prefix); at !== -1; at = text2.indexOf(prefix, end)) {
@@ -5600,9 +5787,6 @@ function invalidateDependents(root, mirror, files) {
5600
5787
  });
5601
5788
  const scratch2 = import_node_path13.default.join(root, ".build");
5602
5789
  if (!(0, import_node_fs13.existsSync)(scratch2)) return;
5603
- const headersChanged = files.some(
5604
- (file) => !file.startsWith("lib/") && !file.startsWith("modules/")
5605
- );
5606
5790
  for (const triple of (0, import_node_fs13.readdirSync)(scratch2, { withFileTypes: true })) {
5607
5791
  const products = import_node_path13.default.join(scratch2, triple.name, "release");
5608
5792
  if (!triple.isDirectory() || !(0, import_node_fs13.existsSync)(products)) continue;
@@ -5642,18 +5826,25 @@ function invalidateDependents(root, mirror, files) {
5642
5826
  if (headersChanged)
5643
5827
  (0, import_node_fs13.rmSync)(import_node_path13.default.join(scratch2, "ModuleCache"), { recursive: true, force: true });
5644
5828
  }
5645
- var import_node_crypto7, import_node_fs13, import_node_path13, SWIFT_DISTRIBUTION_MIRROR;
5829
+ var import_node_crypto7, import_node_fs13, import_node_path13, SWIFT_DISTRIBUTION_MIRROR, SWIFT_SDK_MIRROR, SWIFT_SDK_MIRROR_ID, SWIFT_SDK_MIRROR_RECORD, SWIFT_SDK_MIRROR_SYNCING, SWIFT_SDK_MIRROR_BUNDLE;
5646
5830
  var init_swift_distribution_mirror = __esm({
5647
5831
  "src/swift-distribution-mirror.ts"() {
5648
5832
  "use strict";
5649
5833
  import_node_crypto7 = require("node:crypto");
5650
5834
  import_node_fs13 = require("node:fs");
5651
5835
  import_node_path13 = __toESM(require("node:path"), 1);
5836
+ init_case_insensitive_header_overlay();
5652
5837
  init_is_record();
5653
5838
  init_swift_distribution_contract();
5654
5839
  init_swift_shared_sdk();
5655
5840
  init_swiftContract();
5841
+ init_swiftTargetContract();
5656
5842
  SWIFT_DISTRIBUTION_MIRROR = ".peach-distribution";
5843
+ SWIFT_SDK_MIRROR = ".peach-sdk";
5844
+ SWIFT_SDK_MIRROR_ID = "peach-wasm-sdk";
5845
+ SWIFT_SDK_MIRROR_RECORD = ".peach-sdk-mirror.json";
5846
+ SWIFT_SDK_MIRROR_SYNCING = ".peach-sdk-syncing";
5847
+ SWIFT_SDK_MIRROR_BUNDLE = "peach-wasm.artifactbundle";
5657
5848
  }
5658
5849
  });
5659
5850
 
@@ -18102,8 +18293,10 @@ function swiftPeachModules(moduleRoot) {
18102
18293
  (0, import_node_fs32.readFileSync)(import_node_path32.default.join(moduleRoot, "Package.swift"), "utf8")
18103
18294
  ).filter((target) => !target.executable && !target.path.startsWith("fixtures/")).map((target) => target.name);
18104
18295
  }
18105
- function swiftSdkPaths(moduleRoot, toolchainBin, options = swiftCompileSdkOptions(moduleRoot, toolchainBin)) {
18106
- const sdk = swiftModuleSdk(moduleRoot).wasmSdkId;
18296
+ function clearSwiftSdkPathsCache(sdkDir) {
18297
+ for (const key of sdkPaths.keys()) if (key.includes(sdkDir)) sdkPaths.delete(key);
18298
+ }
18299
+ function swiftSdkPaths(moduleRoot, toolchainBin, options = swiftCompileSdkOptions(moduleRoot, toolchainBin), sdk = swiftModuleSdk(moduleRoot).wasmSdkId) {
18107
18300
  const key = JSON.stringify([toolchainBin, sdk, options]);
18108
18301
  const cached2 = sdkPaths.get(key);
18109
18302
  if (cached2) return cached2;
@@ -20470,7 +20663,10 @@ function finishSwiftAppModuleFile(file) {
20470
20663
  (0, import_node_fs38.appendFileSync)(file, Buffer.concat([header, nameBytes, thunks]));
20471
20664
  }
20472
20665
  function swiftAppModuleInputs(tokens, buildRoot, sdkLibraries) {
20473
- const owned = (token) => import_node_path38.default.resolve(token).startsWith(`${buildRoot}/`) && (!token.includes("/.peach-pruned-objs/") || token.endsWith("/swiftrt-patched.o"));
20666
+ const owned = (token) => {
20667
+ const resolved = import_node_path38.default.resolve(token);
20668
+ return resolved.startsWith(`${buildRoot}/`) && !resolved.startsWith(`${buildRoot}/${SWIFT_DISTRIBUTION_MIRROR}/`) && !resolved.startsWith(`${buildRoot}/${SWIFT_SDK_MIRROR}/`) && (!token.includes("/.peach-pruned-objs/") || token.endsWith("/swiftrt-patched.o"));
20669
+ };
20474
20670
  const inputs = [];
20475
20671
  for (const [index, token] of tokens.entries()) {
20476
20672
  if (token === "--start-lib") inputs.push(token);
@@ -21925,6 +22121,7 @@ var init_swift_sdk_app_module = __esm({
21925
22121
  import_node_zlib4 = require("node:zlib");
21926
22122
  init_nativeSdkBindingContract();
21927
22123
  init_nativeWasmContract();
22124
+ init_swift_distribution_mirror();
21928
22125
  init_swift_guest_dyld_functions();
21929
22126
  init_swift_guest_linked_spans();
21930
22127
  init_swift_project_user();
@@ -23456,7 +23653,9 @@ var init_swift_objc_prebuilt = __esm({
23456
23653
  init_internal_child_contract();
23457
23654
  init_self_invocation();
23458
23655
  init_native_prebuilt();
23656
+ init_swift_distribution_mirror();
23459
23657
  init_swift_objc_prebuilt_catalog();
23658
+ init_swift_objc_standin();
23460
23659
  init_swift_toolchain();
23461
23660
  quote = (value) => "'" + value.replaceAll("'", "'\\''") + "'";
23462
23661
  }
@@ -25108,7 +25307,7 @@ function syncSwiftTree(base, files, alreadySynced) {
25108
25307
  const full = import_node_path49.default.join(dir, entry.name);
25109
25308
  if (dir === base && (entry.name === ".build" || entry.name === SWIFT_CACHE_HOLD_MARKER || entry.name.startsWith(".peach-modules-") || // distribution clang maps are written beside the project, so a sync
25110
25309
  // must not remove them.
25111
- entry.name === CLANG_DISTRIBUTION_MODULES || entry.name === SWIFT_DISTRIBUTION_MIRROR || entry.name === SWIFT_LINK_STAMP || entry.name === SWIFT_BUILD_ROOT_SHAPE))
25310
+ entry.name === CLANG_DISTRIBUTION_MODULES || entry.name === SWIFT_DISTRIBUTION_MIRROR || entry.name === SWIFT_SDK_MIRROR || entry.name === SWIFT_LINK_STAMP || entry.name === SWIFT_BUILD_ROOT_SHAPE))
25112
25311
  continue;
25113
25312
  if (entry.isDirectory()) walk(full);
25114
25313
  else if (!files.has(full) && (!kept || !kept.has((0, import_node_fs47.lstatSync)(full).ino)))
@@ -25801,7 +26000,7 @@ function needsNativeToolset(input, prebuilt) {
25801
26000
  input.packageFiles || prebuilt || Object.keys(input.files).some(isSwiftNativeTranslationUnit)
25802
26001
  );
25803
26002
  }
25804
- function writeSwiftProject(layout2, input, moduleRoot, prebuilt, allowHeaderCompiler = false, objcPrebuiltStage) {
26003
+ function writeSwiftProject(layout2, input, moduleRoot, prebuilt, allowHeaderCompiler = false, objcPrebuiltStage, compileSdk) {
25805
26004
  const nativeToolset = needsNativeToolset(input, prebuilt);
25806
26005
  if (input.headerAliases !== void 0 && !isSwiftHeaderAliases(input.headerAliases))
25807
26006
  throw new Error("swift compile input has invalid original header aliases");
@@ -25930,6 +26129,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
25930
26129
  checkedToolchain = swiftToolchain(pin.release, swiftModuleSdk(moduleRoot));
25931
26130
  return checkedToolchain;
25932
26131
  };
26132
+ const resolvedSdkPaths = (toolchainBin) => swiftSdkPaths(moduleRoot, toolchainBin, compileSdk?.options, compileSdk?.id);
25933
26133
  const targetStagedFiles = /* @__PURE__ */ new Map();
25934
26134
  const stageTargetFile = (target, file, contents2, options) => {
25935
26135
  const relative = import_node_path49.default.relative(layout2.root, file).split(import_node_path49.default.sep).join(import_node_path49.default.posix.sep);
@@ -26056,9 +26256,25 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
26056
26256
  files.set(destination, contents2);
26057
26257
  }
26058
26258
  }
26259
+ const binaryTreePrefix = `${SWIFT_BINARY_TREES_DIR}/`;
26260
+ const binaryTreeSegment = `/${SWIFT_BINARY_TREES_DIR}/`;
26261
+ const isBinaryTreeFile = (file) => file.startsWith(binaryTreePrefix) || file.includes(binaryTreeSegment);
26262
+ const stageBinaryTreeFile = (file, contents2) => {
26263
+ const destination = import_node_path49.default.join(layout2.root, file);
26264
+ if (files.has(destination)) return;
26265
+ writeBuildFile(destination, contents2);
26266
+ alreadySynced.set(destination, contents2);
26267
+ files.set(destination, contents2);
26268
+ };
26269
+ for (const [file, contents2] of Object.entries(input.files))
26270
+ if (isBinaryTreeFile(file)) stageBinaryTreeFile(file, contents2);
26271
+ for (const [file, bytes] of Object.entries(input.packageFiles ?? {}))
26272
+ if (isBinaryTreeFile(file) && !file.endsWith(".swift"))
26273
+ stageBinaryTreeFile(file, Buffer.from(bytes, "base64"));
26274
+ for (const [file, bytes] of Object.entries(input.projectFiles ?? {}))
26275
+ if (isBinaryTreeFile(file)) stageBinaryTreeFile(file, Buffer.from(bytes, "base64"));
26059
26276
  const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ? import_node_path49.default.join(layout2.root, file.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1)) : file;
26060
26277
  const inRoot = `${layout2.root}${import_node_path49.default.sep}`;
26061
- const binaryTree = `${import_node_path49.default.sep}${SWIFT_BINARY_TREES_DIR}${import_node_path49.default.sep}`;
26062
26278
  const headerSearch = writeXcodeHeaderSearch(
26063
26279
  import_node_path49.default.join(layout2.root, ".build", "peach-xcode-headers"),
26064
26280
  nativeTargets.map((settings) => {
@@ -26110,7 +26326,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
26110
26326
  import_node_path49.default.join(layout2.root, file)
26111
26327
  ])
26112
26328
  ),
26113
- (file) => !file.startsWith(inRoot) || files.has(file) || file.includes(binaryTree)
26329
+ (file) => !file.startsWith(inRoot) || files.has(file)
26114
26330
  );
26115
26331
  const importModuleMaps = /* @__PURE__ */ new Map();
26116
26332
  const sourceModuleMaps = /* @__PURE__ */ new Map();
@@ -26253,7 +26469,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
26253
26469
  ];
26254
26470
  })();
26255
26471
  const sdkInclude = import_node_path49.default.join(
26256
- swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
26472
+ resolvedSdkPaths(toolchainBin).sysroot,
26257
26473
  "darwin/usr/include"
26258
26474
  );
26259
26475
  const dependencyModuleMaps = clangImportModuleMapFlags(
@@ -27000,7 +27216,8 @@ ${entry}`);
27000
27216
  );
27001
27217
  if (nativeFlags) {
27002
27218
  const toolchainBin = nativeToolchain();
27003
- const headers = import_node_path49.default.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, "darwin");
27219
+ const headers = import_node_path49.default.join(resolvedSdkPaths(toolchainBin).sysroot, "darwin");
27220
+ const sdkOverlayDirectory = compileSdk?.id === SWIFT_SDK_MIRROR_ID ? import_node_path49.default.join(layout2.root, SWIFT_SDK_MIRROR) : void 0;
27004
27221
  const dependencies2 = swiftTargetDependencies(input.files, targets);
27005
27222
  const reachesNative = (name3, seen = /* @__PURE__ */ new Set()) => {
27006
27223
  if (native.has(name3)) return true;
@@ -27018,7 +27235,12 @@ ${entry}`);
27018
27235
  throw new Error(
27019
27236
  target.name + ": missing or unsupported declared iOS deployment target " + JSON.stringify(version2)
27020
27237
  );
27021
- const sdkIntake = objcSdkIntakeFlags(headers, toolchainBin, minimum);
27238
+ const sdkIntake = objcSdkIntakeFlags(
27239
+ headers,
27240
+ toolchainBin,
27241
+ minimum,
27242
+ sdkOverlayDirectory
27243
+ );
27022
27244
  const sdkOverlay = sdkIntake.indexOf("-ivfsoverlay");
27023
27245
  if (sdkOverlay >= 0) generatedOverlays.add(sdkIntake[sdkOverlay + 1]);
27024
27246
  const intake = [
@@ -27240,7 +27462,7 @@ ${entry}`);
27240
27462
  distribution: distribution ?? void 0,
27241
27463
  moduleExcludes,
27242
27464
  deferDarwinOverlay: native.size > 0 && toolsetOrdersLibcxxBeforeDarwinOverlay(
27243
- swiftSdkPaths(moduleRoot, nativeToolchain()).cFlags
27465
+ resolvedSdkPaths(nativeToolchain()).cFlags
27244
27466
  ),
27245
27467
  ...reachesFrameworks ? {
27246
27468
  distributionLink: {
@@ -27283,7 +27505,7 @@ ${entry}`);
27283
27505
  ...headerAliasFlags,
27284
27506
  ...native.size > 0 ? [
27285
27507
  "-fmodule-map-file=" + import_node_path49.default.join(
27286
- swiftSdkPaths(moduleRoot, nativeToolchain()).sysroot,
27508
+ resolvedSdkPaths(nativeToolchain()).sysroot,
27287
27509
  "darwin/wasm/include/module.modulemap"
27288
27510
  )
27289
27511
  ] : []
@@ -27293,7 +27515,7 @@ ${entry}`);
27293
27515
  const prebuiltCompiler = distribution && objcPrebuiltStage !== false ? swiftObjCPrebuiltCompiler(
27294
27516
  clang,
27295
27517
  layout2.root,
27296
- swiftSdkPaths(moduleRoot, nativeToolchain()).sysroot,
27518
+ resolvedSdkPaths(nativeToolchain()).sysroot,
27297
27519
  distribution.id,
27298
27520
  [...native.keys()],
27299
27521
  objcPrebuiltStage
@@ -27551,12 +27773,55 @@ package.targets += [.target(name: ${JSON.stringify(name3)}, dependencies: ${JSON
27551
27773
  `;
27552
27774
  return name3;
27553
27775
  };
27554
- const headerBuilds = headerCompiler ? [
27555
- {
27556
- target: buildProduct(SWIFT_HEADER_PRODUCTS_TARGET, orderedProducers),
27557
- producers: orderedProducers
27776
+ const producerUnitCount = /* @__PURE__ */ new Map();
27777
+ for (const target of targets) {
27778
+ if (!producerSet.has(target.name)) continue;
27779
+ producerUnitCount.set(
27780
+ target.name,
27781
+ Math.max(
27782
+ 1,
27783
+ targetEntries(target).filter(([file]) => file.endsWith(".swift")).length
27784
+ )
27785
+ );
27786
+ }
27787
+ const MAX_HEADER_STAGE_TARGETS = 100;
27788
+ const MAX_HEADER_STAGE_UNITS = 400;
27789
+ const chunkHeaderProducers = (producers2) => {
27790
+ const levelOrdered = [...producers2].sort(
27791
+ (left, right) => depths.get(left) - depths.get(right)
27792
+ );
27793
+ const totalUnits = levelOrdered.reduce(
27794
+ (sum, name3) => sum + (producerUnitCount.get(name3) ?? 1),
27795
+ 0
27796
+ );
27797
+ if (levelOrdered.length <= 1 || levelOrdered.length <= MAX_HEADER_STAGE_TARGETS && totalUnits <= MAX_HEADER_STAGE_UNITS) {
27798
+ return [
27799
+ {
27800
+ target: buildProduct(SWIFT_HEADER_PRODUCTS_TARGET, levelOrdered),
27801
+ producers: levelOrdered
27802
+ }
27803
+ ];
27804
+ }
27805
+ const chunks = [];
27806
+ let current = [];
27807
+ let units = 0;
27808
+ for (const name3 of levelOrdered) {
27809
+ const size = producerUnitCount.get(name3) ?? 1;
27810
+ if (current.length > 0 && (current.length >= MAX_HEADER_STAGE_TARGETS || units + size > MAX_HEADER_STAGE_UNITS)) {
27811
+ chunks.push(current);
27812
+ current = [];
27813
+ units = 0;
27814
+ }
27815
+ current.push(name3);
27816
+ units += size;
27558
27817
  }
27559
- ] : [...stages].sort(([left], [right]) => left - right).map(([level, producers2]) => ({
27818
+ if (current.length > 0) chunks.push(current);
27819
+ return chunks.map((members, index) => ({
27820
+ target: buildProduct(`${SWIFT_HEADER_PRODUCTS_TARGET}${index + 1}`, members),
27821
+ producers: members
27822
+ }));
27823
+ };
27824
+ const headerBuilds = headerCompiler ? chunkHeaderProducers(orderedProducers) : [...stages].sort(([left], [right]) => left - right).map(([level, producers2]) => ({
27560
27825
  target: buildProduct(`${SWIFT_HEADER_PRODUCTS_TARGET}${level}`, producers2),
27561
27826
  producers: producers2
27562
27827
  }));
@@ -29083,8 +29348,15 @@ ${compatShape}` : "";
29083
29348
  frameworkLease
29084
29349
  );
29085
29350
  const compileFrameworkRoot2 = distribution ? swiftDistributionCompileView(frameworkRoot2, distribution) : frameworkRoot2;
29086
- const sdk2 = swiftModuleSdk(frameworkRoot2).wasmSdkId;
29087
- const icu2 = options.linkOnly ? null : swiftIcuAsset(options.toolchainBin, sdk2);
29351
+ const sdk = swiftModuleSdk(frameworkRoot2).wasmSdkId;
29352
+ const compileSdk2 = mirrorDistribution ? syncSwiftSdkMirror(root2, frameworkRoot2, options.toolchainBin, sdk) : {
29353
+ id: sdk,
29354
+ options: swiftCompileSdkOptions(frameworkRoot2, options.toolchainBin),
29355
+ toolsetChanged: false
29356
+ };
29357
+ if (mirrorDistribution && compileSdk2.toolsetChanged)
29358
+ clearSwiftSdkPathsCache(import_node_path49.default.join(root2, SWIFT_SDK_MIRROR));
29359
+ const icu2 = options.linkOnly ? null : swiftIcuAsset(options.toolchainBin, sdk);
29088
29360
  let prebuilt2;
29089
29361
  if (!distribution) {
29090
29362
  if (allowWrite) stage("compiling framework products");
@@ -29095,7 +29367,7 @@ ${compatShape}` : "";
29095
29367
  frameworkKey,
29096
29368
  input,
29097
29369
  swift,
29098
- sdk: sdk2,
29370
+ sdk,
29099
29371
  toolchainBin: options.toolchainBin,
29100
29372
  plugins: macroPlugins2,
29101
29373
  buildOptions: {
@@ -29120,7 +29392,8 @@ ${compatShape}` : "";
29120
29392
  frameworkRoot: frameworkRoot2,
29121
29393
  compileFrameworkRoot: compileFrameworkRoot2,
29122
29394
  macroPlugins: macroPlugins2,
29123
- sdk: sdk2,
29395
+ sdk,
29396
+ compileSdk: compileSdk2,
29124
29397
  icu: icu2,
29125
29398
  prebuilt: prebuilt2,
29126
29399
  readHold: readHold2
@@ -29141,7 +29414,7 @@ ${compatShape}` : "";
29141
29414
  frameworkRoot,
29142
29415
  compileFrameworkRoot,
29143
29416
  macroPlugins,
29144
- sdk,
29417
+ compileSdk,
29145
29418
  icu,
29146
29419
  prebuilt
29147
29420
  } = frameworks;
@@ -29159,13 +29432,13 @@ ${compatShape}` : "";
29159
29432
  if (retireStaleSwiftLink(
29160
29433
  root2,
29161
29434
  swiftLinkStamp({
29162
- frameworkKey: `${options.release}\0${Boolean(distribution)}\0${swiftModuleSdk(frameworkRoot).wasmSdkId}`,
29435
+ frameworkKey: mirrorDistribution ? `${options.release}\0mirror` : `${options.release}\0${Boolean(distribution)}\0${swiftModuleSdk(frameworkRoot).wasmSdkId}`,
29163
29436
  packageHostMacros
29164
29437
  }),
29165
29438
  swiftLinkStamp({
29166
- // a distribution's objects reach only the deferred link, and
29167
- // the root's mirror keeps its compile inputs at fixed paths
29168
- frameworkKey: distribution ? `${options.release}\0${distribution.wasmSdkChecksum}` : frameworkKey,
29439
+ // mirrored distributions and their WASI SDK mirror invalidate
29440
+ // dependents per changed file instead of wiping every Clang object.
29441
+ frameworkKey: mirrorDistribution ? `${options.release}\0mirror` : distribution ? `${options.release}\0${distribution.wasmSdkChecksum}` : frameworkKey,
29169
29442
  prebuilt,
29170
29443
  packageHostMacros
29171
29444
  }),
@@ -29179,7 +29452,8 @@ ${compatShape}` : "";
29179
29452
  frameworkRoot,
29180
29453
  prebuilt,
29181
29454
  !options.project,
29182
- options.project ? false : options.objcPrebuiltStage ?? (options.intermediates ? false : void 0)
29455
+ options.project ? false : options.objcPrebuiltStage ?? (options.intermediates ? false : void 0),
29456
+ compileSdk
29183
29457
  );
29184
29458
  const productFile = import_node_path49.default.join(frameworkRoot, SWIFT_FRAMEWORK_PRODUCT_FILE);
29185
29459
  writeSwiftAutolinkLinker(
@@ -29255,6 +29529,7 @@ ${compatShape}` : "";
29255
29529
  const jobs = swiftCompilerJobs();
29256
29530
  const incrementalPreview = sdkImage !== void 0 && !guestGraph && !options.project && !input.optimize && !input.unoptimized;
29257
29531
  const perFile = input.unoptimized || incrementalPreview;
29532
+ const reproducibleFrameworkRoot = mirrorDistribution ? frameworkRoot : compileFrameworkRoot;
29258
29533
  const buildArgs = [
29259
29534
  "build",
29260
29535
  ...projectProcess?.cacheOptions ?? swiftPackageCacheOptions(),
@@ -29264,10 +29539,10 @@ ${compatShape}` : "";
29264
29539
  String(jobs),
29265
29540
  "--package-path",
29266
29541
  root2,
29267
- ...swiftCompileSdkOptions(frameworkRoot, options.toolchainBin),
29542
+ ...compileSdk.options,
29268
29543
  ...swiftObjCSelectorOptions(frameworkRoot),
29269
29544
  "--swift-sdk",
29270
- sdk,
29545
+ compileSdk.id,
29271
29546
  ...preparation.targetToolset ? ["--toolset", import_node_path49.default.join(root2, ".peach-target-toolset.json")] : [],
29272
29547
  "-c",
29273
29548
  "release",
@@ -29302,7 +29577,7 @@ ${compatShape}` : "";
29302
29577
  ],
29303
29578
  ...swiftReproducibleBuildFlags([
29304
29579
  [import_node_path49.default.dirname(options.toolchainBin), "toolchain"],
29305
- [compileFrameworkRoot, "framework"],
29580
+ [reproducibleFrameworkRoot, "framework"],
29306
29581
  [root2, "build"],
29307
29582
  ...forwarders
29308
29583
  ]).flatMap((flag, index, flags) => {
@@ -29312,8 +29587,8 @@ ${compatShape}` : "";
29312
29587
  let mapped = flag;
29313
29588
  for (const [dir, target] of [
29314
29589
  [root2, "/peach/build"],
29315
- [compileFrameworkRoot, "/peach/framework"],
29316
- [(0, import_node_fs47.realpathSync)(compileFrameworkRoot), "/peach/framework"],
29590
+ [reproducibleFrameworkRoot, "/peach/framework"],
29591
+ [(0, import_node_fs47.realpathSync)(reproducibleFrameworkRoot), "/peach/framework"],
29317
29592
  [toolchainDir, "/peach/toolchain"],
29318
29593
  [(0, import_node_fs47.realpathSync)(toolchainDir), "/peach/toolchain"]
29319
29594
  ]) {
@@ -29342,8 +29617,14 @@ ${compatShape}` : "";
29342
29617
  (0, import_node_fs47.rmSync)(linked, { force: true });
29343
29618
  stage("compiling and linking Swift modules");
29344
29619
  const frameworkInterfaces = /* @__PURE__ */ new Map();
29620
+ const compileSdkPaths = swiftSdkPaths(
29621
+ frameworkRoot,
29622
+ options.toolchainBin,
29623
+ compileSdk.options,
29624
+ compileSdk.id
29625
+ );
29345
29626
  const sdkFrameworks = import_node_path49.default.join(
29346
- swiftSdkPaths(frameworkRoot, options.toolchainBin).darwin,
29627
+ compileSdkPaths.darwin,
29347
29628
  "System/Library/Frameworks"
29348
29629
  );
29349
29630
  const generatedInterface = (source) => withoutImportedSdkEnumForwards(
@@ -29547,7 +29828,7 @@ ${compatShape}` : "";
29547
29828
  options.toolchainBin,
29548
29829
  recipe,
29549
29830
  new Map(
29550
- preparation.headerBuilds[0].producers.map((producer) => {
29831
+ preparation.headerBuilds.flatMap((stage2) => stage2.producers).map((producer) => {
29551
29832
  const paths = headerPaths(producer);
29552
29833
  return [
29553
29834
  swiftTargetModuleName(producer),
@@ -29641,7 +29922,7 @@ ${compatShape}` : "";
29641
29922
  moduleRoot: frameworkRoot,
29642
29923
  toolchainBin: options.toolchainBin,
29643
29924
  swiftCompiler: preparation.headerCompiler ? import_node_path49.default.join(root2, SWIFT_HEADER_COMPILER_WRAPPER) : compiler.SWIFT_EXEC ?? import_node_path49.default.join(options.toolchainBin, "swiftc"),
29644
- sysroot: swiftSdkPaths(frameworkRoot, options.toolchainBin).sysroot,
29925
+ sysroot: compileSdkPaths.sysroot,
29645
29926
  sdk: swiftModuleSdk(frameworkRoot),
29646
29927
  sdkImage,
29647
29928
  compilerDigest: compilerSourceDigest,
@@ -29671,9 +29952,7 @@ ${compatShape}` : "";
29671
29952
  project: options.project && {
29672
29953
  ...options.project,
29673
29954
  env: { ...options.project.env, ...projectProcess?.env },
29674
- sdkRoot: import_node_path49.default.dirname(
29675
- swiftSdkPaths(frameworkRoot, options.toolchainBin).sysroot
29676
- ),
29955
+ sdkRoot: import_node_path49.default.dirname(compileSdkPaths.sysroot),
29677
29956
  linked: output
29678
29957
  }
29679
29958
  });
@@ -29933,7 +30212,7 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
29933
30212
  REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
29934
30213
  MULTI_MANIFEST_VERSION = 76;
29935
30214
  SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
29936
- compilerSourceDigest = true ? "e28f3765de44ea471f6097cb0ae6ead762595ae2bb24b4e38d4210f32b9434c1" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
30215
+ compilerSourceDigest = true ? "a0b547d433e1045fc952acc099a7aa9b05cde3376f8d2dd002afbf6d4593e5ba" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
29937
30216
  nativeCxxCompilerFlags = ["-fno-cxx-modules"];
29938
30217
  MODULE_MAP_RESPONSE_FILE_RUN = 16;
29939
30218
  cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));