peachsim 0.1.2767 → 0.1.2769

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 +351 -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-RDD3HI5C.mjs → acorn-GNB3RJH7.mjs} +3 -3
  27. package/dist-lib/esm-chunks/{chunk-BY3E6CUM.mjs → chunk-3WG4L5YK.mjs} +372 -106
  28. package/dist-lib/esm-chunks/{chunk-YX56RZ26.mjs → chunk-3ZKE33FC.mjs} +1 -1
  29. package/dist-lib/esm-chunks/{chunk-555YCJDH.mjs → chunk-4GHACZYW.mjs} +5 -5
  30. package/dist-lib/esm-chunks/{chunk-CBAMX2H3.mjs → chunk-4IJOKKT2.mjs} +1 -1
  31. package/dist-lib/esm-chunks/{chunk-GKHSLOW6.mjs → chunk-53WFZATQ.mjs} +1 -1
  32. package/dist-lib/esm-chunks/{chunk-H4KLP3QO.mjs → chunk-57JPQBQL.mjs} +1 -1
  33. package/dist-lib/esm-chunks/{chunk-PDMYH4NT.mjs → chunk-ALLMPTWQ.mjs} +2 -2
  34. package/dist-lib/esm-chunks/{chunk-UGTY5DQQ.mjs → chunk-BFLH7V77.mjs} +6 -6
  35. package/dist-lib/esm-chunks/{chunk-LO5KFOI3.mjs → chunk-BP7TLKZD.mjs} +1 -1
  36. package/dist-lib/esm-chunks/{chunk-WJKKLL2J.mjs → chunk-ETXC2XBY.mjs} +1 -1
  37. package/dist-lib/esm-chunks/{chunk-C6YNOAXM.mjs → chunk-GHJPVQ3A.mjs} +1 -1
  38. package/dist-lib/esm-chunks/{chunk-D6JZSVL7.mjs → chunk-L2U2IEHU.mjs} +1 -1
  39. package/dist-lib/esm-chunks/{chunk-7G6WGJWR.mjs → chunk-MBLYJ74N.mjs} +1 -1
  40. package/dist-lib/esm-chunks/{chunk-P2KN5U5O.mjs → chunk-MGIODRG3.mjs} +1 -1
  41. package/dist-lib/esm-chunks/{chunk-XPSICY6F.mjs → chunk-OG5C2CN2.mjs} +3 -3
  42. package/dist-lib/esm-chunks/{chunk-4W67A7NE.mjs → chunk-OPIPPBGX.mjs} +1 -1
  43. package/dist-lib/esm-chunks/{chunk-DFK4ZVNM.mjs → chunk-TI42U3CD.mjs} +1 -1
  44. package/dist-lib/esm-chunks/{chunk-H5C5TZNB.mjs → chunk-TJNFADI5.mjs} +1 -1
  45. package/dist-lib/esm-chunks/{chunk-OYMWLKPN.mjs → chunk-TTVQWJGW.mjs} +4 -4
  46. package/dist-lib/esm-chunks/{chunk-7VSU2AV7.mjs → chunk-VF3CWZTM.mjs} +1 -1
  47. package/dist-lib/esm-chunks/{chunk-AC2RBU5N.mjs → chunk-WWANYYJG.mjs} +1 -1
  48. package/dist-lib/esm-chunks/{chunk-EJWUFWN3.mjs → chunk-XX7VUACB.mjs} +26 -13
  49. package/dist-lib/esm-chunks/{chunk-BSN5R62H.mjs → chunk-ZGNNVEWM.mjs} +1 -1
  50. package/dist-lib/esm-chunks/{chunk-3WJRW63F.mjs → chunk-ZLYAJ4CU.mjs} +1 -1
  51. package/dist-lib/esm-chunks/{metro-layout-parser-7POGDD5P.mjs → metro-layout-parser-LT2DPN6F.mjs} +3 -3
  52. package/dist-lib/esm-chunks/{swift-package-prebuilt-ULD72CI5.mjs → swift-package-prebuilt-ZFFWBI33.mjs} +12 -12
  53. package/dist-lib/esm-chunks/{swift-sdk-app-module-VXSTLD57.mjs → swift-sdk-app-module-UZ6BZSES.mjs} +22 -17
  54. package/dist-lib/esm-chunks/{swift-sdk-image-KDJATRA6.mjs → swift-sdk-image-J2DE3SBW.mjs} +16 -16
  55. package/dist-lib/esm-chunks/{swift-sdk-image-producer-KNBUALWN.mjs → swift-sdk-image-producer-C4U4EQRW.mjs} +5 -5
  56. package/dist-lib/expo-swift-bundle.cjs +351 -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 +351 -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 +351 -77
  95. package/dist-lib/swift-compile.cjs +331 -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 +273 -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.2767 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2769 | (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,175 @@ 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 options = ["--swift-sdks-path", mirror];
5591
+ const previous = readSdkRecord(recordFile);
5592
+ 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"))) {
5593
+ return { id: SWIFT_SDK_MIRROR_ID, options, toolsetChanged: false };
5594
+ }
5595
+ const sourceTriple = resolveSdkViewTripleDir(sourceView, sourceSdkId);
5596
+ if (!previous) {
5597
+ (0, import_node_fs13.rmSync)(mirror, { recursive: true, force: true });
5598
+ (0, import_node_fs13.rmSync)(import_node_path13.default.join(root, ".build"), { recursive: true, force: true });
5599
+ }
5600
+ const changed = [];
5601
+ const removed = [];
5602
+ const distributionPrefix = `${frameworkRoot}${import_node_path13.default.sep}`;
5603
+ syncSdkTree(sourceTriple, destTriple, "", distributionPrefix, changed, removed);
5604
+ const infoText = JSON.stringify(
5605
+ {
5606
+ artifacts: {
5607
+ [SWIFT_SDK_MIRROR_ID]: {
5608
+ type: "swiftSDK",
5609
+ variants: [{ path: `sdk/${SWIFT_WASM_TRIPLE}/swift-sdk.json` }],
5610
+ version: "0.0.1"
5611
+ }
5612
+ },
5613
+ schemaVersion: "1.0"
5614
+ },
5615
+ null,
5616
+ 2
5617
+ ) + "\n";
5618
+ if (!(0, import_node_fs13.existsSync)(bundleInfo) || (0, import_node_fs13.readFileSync)(bundleInfo, "utf8") !== infoText) {
5619
+ (0, import_node_fs13.mkdirSync)(bundle, { recursive: true });
5620
+ const partial = `${bundleInfo}.${(0, import_node_crypto7.randomUUID)()}`;
5621
+ (0, import_node_fs13.writeFileSync)(partial, infoText);
5622
+ (0, import_node_fs13.renameSync)(partial, bundleInfo);
5623
+ }
5624
+ const touched = [...changed, ...removed];
5625
+ const toolsetChanged = !previous || touched.some(
5626
+ (file) => file === "toolset.json" || file === "swift-sdk.json" || file.startsWith("swift.xctoolchain/usr/bin/")
5627
+ );
5628
+ if (previous) {
5629
+ if (toolsetChanged) {
5630
+ (0, import_node_fs13.rmSync)(import_node_path13.default.join(root, ".build"), { recursive: true, force: true });
5631
+ } else {
5632
+ const compileTouched = touched.filter(
5633
+ (file) => !file.endsWith(".a") && !file.endsWith(".o") && !file.startsWith("rust/") && file !== "runtime-products.json"
5634
+ );
5635
+ const headersChanged = compileTouched.some(
5636
+ (file) => !file.endsWith(".swiftmodule") && !file.endsWith(".swiftdoc") && !file.endsWith(".swiftsourceinfo") && !file.endsWith(".abi.json")
5637
+ );
5638
+ if (compileTouched.length > 0) {
5639
+ invalidateBuildDependents(
5640
+ root,
5641
+ [[Buffer.from(`${escapeDepPath(destTriple)}/`), ""]],
5642
+ new Set(compileTouched),
5643
+ headersChanged
5644
+ );
5645
+ }
5646
+ if (headersChanged) clearCaseInsensitiveHeaderOverlayCache(mirror);
5647
+ }
5648
+ } else {
5649
+ clearCaseInsensitiveHeaderOverlayCache(mirror);
5650
+ }
5651
+ (0, import_node_fs13.mkdirSync)(mirror, { recursive: true });
5652
+ const partialRecord = `${recordFile}.${(0, import_node_crypto7.randomUUID)()}`;
5653
+ (0, import_node_fs13.writeFileSync)(partialRecord, JSON.stringify({ version: 1, sourceView, sourceSdkId }));
5654
+ (0, import_node_fs13.renameSync)(partialRecord, recordFile);
5655
+ return { id: SWIFT_SDK_MIRROR_ID, options, toolsetChanged };
5656
+ }
5657
+ function readSdkRecord(file) {
5658
+ if (!(0, import_node_fs13.existsSync)(file)) return null;
5659
+ const value = JSON.parse((0, import_node_fs13.readFileSync)(file, "utf8"));
5660
+ if (!isRecord(value) || value.version !== 1 || typeof value.sourceView !== "string" || typeof value.sourceSdkId !== "string")
5661
+ return null;
5662
+ return {
5663
+ version: value.version,
5664
+ sourceView: value.sourceView,
5665
+ sourceSdkId: value.sourceSdkId
5666
+ };
5667
+ }
5668
+ function resolveSdkViewTripleDir(sourceView, sourceSdkId) {
5669
+ for (const entry of (0, import_node_fs13.readdirSync)(sourceView, { withFileTypes: true })) {
5670
+ if (!entry.name.endsWith(".artifactbundle")) continue;
5671
+ const bundleDir = import_node_path13.default.join(sourceView, entry.name);
5672
+ const infoPath = import_node_path13.default.join(bundleDir, "info.json");
5673
+ if (!(0, import_node_fs13.existsSync)(infoPath)) continue;
5674
+ const info = JSON.parse((0, import_node_fs13.readFileSync)(infoPath, "utf8"));
5675
+ if (!isRecord(info) || !isRecord(info.artifacts)) continue;
5676
+ const artifact = info.artifacts[sourceSdkId];
5677
+ if (!isRecord(artifact) || !Array.isArray(artifact.variants)) continue;
5678
+ const first = artifact.variants[0];
5679
+ if (!isRecord(first) || typeof first.path !== "string") continue;
5680
+ return import_node_path13.default.dirname(import_node_path13.default.join(bundleDir, first.path));
5681
+ }
5682
+ throw new Error(`Swift SDK ${sourceSdkId} not found in view ${sourceView}`);
5683
+ }
5684
+ function collectRemovedFiles(dir, prefix, out) {
5685
+ for (const entry of (0, import_node_fs13.readdirSync)(dir, { withFileTypes: true })) {
5686
+ const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
5687
+ const full = import_node_path13.default.join(dir, entry.name);
5688
+ if (entry.isDirectory()) collectRemovedFiles(full, rel, out);
5689
+ else out.push(rel);
5690
+ }
5691
+ }
5692
+ function syncSdkTree(sourceDir, destDir, prefix, distributionPrefix, changed, removed) {
5693
+ (0, import_node_fs13.mkdirSync)(destDir, { recursive: true });
5694
+ const wanted = /* @__PURE__ */ new Set();
5695
+ for (const entry of (0, import_node_fs13.readdirSync)(sourceDir, { withFileTypes: true })) {
5696
+ wanted.add(entry.name);
5697
+ const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
5698
+ const src = import_node_path13.default.join(sourceDir, entry.name);
5699
+ const dest = import_node_path13.default.join(destDir, entry.name);
5700
+ const destLstat = (0, import_node_fs13.lstatSync)(dest, { throwIfNoEntry: false });
5701
+ if (entry.isSymbolicLink()) {
5702
+ const target = (0, import_node_fs13.readlinkSync)(src);
5703
+ if (target.startsWith(distributionPrefix)) {
5704
+ if (destLstat?.isSymbolicLink() && (0, import_node_fs13.readlinkSync)(dest) === target) continue;
5705
+ if (destLstat) (0, import_node_fs13.rmSync)(dest, { recursive: true, force: true });
5706
+ (0, import_node_fs13.symlinkSync)(target, dest);
5707
+ changed.push(rel);
5708
+ continue;
5709
+ }
5710
+ }
5711
+ const srcStat = (0, import_node_fs13.statSync)(src, { throwIfNoEntry: false });
5712
+ if (!srcStat) continue;
5713
+ if (srcStat.isDirectory()) {
5714
+ if (destLstat && (!destLstat.isDirectory() || destLstat.isSymbolicLink()))
5715
+ (0, import_node_fs13.rmSync)(dest, { recursive: true, force: true });
5716
+ syncSdkTree(src, dest, rel, distributionPrefix, changed, removed);
5717
+ continue;
5718
+ }
5719
+ if (destLstat?.isFile() && !destLstat.isSymbolicLink() && destLstat.size === srcStat.size && (0, import_node_fs13.readFileSync)(src).equals((0, import_node_fs13.readFileSync)(dest)))
5720
+ continue;
5721
+ if (destLstat?.isDirectory()) (0, import_node_fs13.rmSync)(dest, { recursive: true, force: true });
5722
+ place(src, dest, (srcStat.mode & 73) !== 0 ? srcStat.mode & 511 : void 0);
5723
+ changed.push(rel);
5724
+ }
5725
+ for (const entry of (0, import_node_fs13.readdirSync)(destDir, { withFileTypes: true })) {
5726
+ if (wanted.has(entry.name)) continue;
5727
+ const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
5728
+ const dest = import_node_path13.default.join(destDir, entry.name);
5729
+ if (entry.isDirectory()) collectRemovedFiles(dest, rel, removed);
5730
+ else removed.push(rel);
5731
+ (0, import_node_fs13.rmSync)(dest, { recursive: true, force: true });
5732
+ }
5733
+ }
5560
5734
  function readRecord(file) {
5561
5735
  if (!(0, import_node_fs13.existsSync)(file)) return null;
5562
5736
  const value = JSON.parse((0, import_node_fs13.readFileSync)(file, "utf8"));
@@ -5568,24 +5742,33 @@ function readRecord(file) {
5568
5742
  }
5569
5743
  return files;
5570
5744
  }
5571
- function place(from, to) {
5745
+ function place(from, to, mode) {
5572
5746
  (0, import_node_fs13.mkdirSync)(import_node_path13.default.dirname(to), { recursive: true });
5573
5747
  const partial = `${to}.${(0, import_node_crypto7.randomUUID)()}`;
5574
5748
  (0, import_node_fs13.copyFileSync)(from, partial, import_node_fs13.constants.COPYFILE_FICLONE);
5749
+ if (mode !== void 0) (0, import_node_fs13.chmodSync)(partial, mode);
5575
5750
  (0, import_node_fs13.renameSync)(partial, to);
5576
5751
  }
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(
5752
+ function escapeDepPath(directory) {
5753
+ return directory.replace(
5581
5754
  /[\\ #$]/g,
5582
5755
  (character) => character === "$" ? "$$" : `\\${character}`
5583
5756
  );
5757
+ }
5758
+ function invalidateDependents(root, mirror, files) {
5759
+ const read = new Set(files.filter((file) => !file.startsWith("lib/")));
5760
+ if (read.size === 0) return;
5584
5761
  const spellings = [
5585
- [Buffer.from(`${escapedMirror}/`), ""]
5762
+ [Buffer.from(`${escapeDepPath(mirror)}/`), ""]
5586
5763
  ];
5587
5764
  if (files.some((file) => file.startsWith("sdk/ios/")))
5588
5765
  spellings.push([Buffer.from("/darwin/"), "sdk/ios/"]);
5766
+ const headersChanged = files.some(
5767
+ (file) => !file.startsWith("lib/") && !file.startsWith("modules/")
5768
+ );
5769
+ invalidateBuildDependents(root, spellings, read, headersChanged);
5770
+ }
5771
+ function invalidateBuildDependents(root, spellings, read, headersChanged) {
5589
5772
  const names = (text2) => spellings.some(([prefix, base]) => {
5590
5773
  let end = 0;
5591
5774
  for (let at = text2.indexOf(prefix); at !== -1; at = text2.indexOf(prefix, end)) {
@@ -5600,9 +5783,6 @@ function invalidateDependents(root, mirror, files) {
5600
5783
  });
5601
5784
  const scratch2 = import_node_path13.default.join(root, ".build");
5602
5785
  if (!(0, import_node_fs13.existsSync)(scratch2)) return;
5603
- const headersChanged = files.some(
5604
- (file) => !file.startsWith("lib/") && !file.startsWith("modules/")
5605
- );
5606
5786
  for (const triple of (0, import_node_fs13.readdirSync)(scratch2, { withFileTypes: true })) {
5607
5787
  const products = import_node_path13.default.join(scratch2, triple.name, "release");
5608
5788
  if (!triple.isDirectory() || !(0, import_node_fs13.existsSync)(products)) continue;
@@ -5642,18 +5822,24 @@ function invalidateDependents(root, mirror, files) {
5642
5822
  if (headersChanged)
5643
5823
  (0, import_node_fs13.rmSync)(import_node_path13.default.join(scratch2, "ModuleCache"), { recursive: true, force: true });
5644
5824
  }
5645
- var import_node_crypto7, import_node_fs13, import_node_path13, SWIFT_DISTRIBUTION_MIRROR;
5825
+ 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_BUNDLE;
5646
5826
  var init_swift_distribution_mirror = __esm({
5647
5827
  "src/swift-distribution-mirror.ts"() {
5648
5828
  "use strict";
5649
5829
  import_node_crypto7 = require("node:crypto");
5650
5830
  import_node_fs13 = require("node:fs");
5651
5831
  import_node_path13 = __toESM(require("node:path"), 1);
5832
+ init_case_insensitive_header_overlay();
5652
5833
  init_is_record();
5653
5834
  init_swift_distribution_contract();
5654
5835
  init_swift_shared_sdk();
5655
5836
  init_swiftContract();
5837
+ init_swiftTargetContract();
5656
5838
  SWIFT_DISTRIBUTION_MIRROR = ".peach-distribution";
5839
+ SWIFT_SDK_MIRROR = ".peach-sdk";
5840
+ SWIFT_SDK_MIRROR_ID = "peach-wasm-sdk";
5841
+ SWIFT_SDK_MIRROR_RECORD = ".peach-sdk-mirror.json";
5842
+ SWIFT_SDK_MIRROR_BUNDLE = "peach-wasm.artifactbundle";
5657
5843
  }
5658
5844
  });
5659
5845
 
@@ -18102,8 +18288,10 @@ function swiftPeachModules(moduleRoot) {
18102
18288
  (0, import_node_fs32.readFileSync)(import_node_path32.default.join(moduleRoot, "Package.swift"), "utf8")
18103
18289
  ).filter((target) => !target.executable && !target.path.startsWith("fixtures/")).map((target) => target.name);
18104
18290
  }
18105
- function swiftSdkPaths(moduleRoot, toolchainBin, options = swiftCompileSdkOptions(moduleRoot, toolchainBin)) {
18106
- const sdk = swiftModuleSdk(moduleRoot).wasmSdkId;
18291
+ function clearSwiftSdkPathsCache(sdkDir) {
18292
+ for (const key of sdkPaths.keys()) if (key.includes(sdkDir)) sdkPaths.delete(key);
18293
+ }
18294
+ function swiftSdkPaths(moduleRoot, toolchainBin, options = swiftCompileSdkOptions(moduleRoot, toolchainBin), sdk = swiftModuleSdk(moduleRoot).wasmSdkId) {
18107
18295
  const key = JSON.stringify([toolchainBin, sdk, options]);
18108
18296
  const cached2 = sdkPaths.get(key);
18109
18297
  if (cached2) return cached2;
@@ -20470,7 +20658,10 @@ function finishSwiftAppModuleFile(file) {
20470
20658
  (0, import_node_fs38.appendFileSync)(file, Buffer.concat([header, nameBytes, thunks]));
20471
20659
  }
20472
20660
  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"));
20661
+ const owned = (token) => {
20662
+ const resolved = import_node_path38.default.resolve(token);
20663
+ 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"));
20664
+ };
20474
20665
  const inputs = [];
20475
20666
  for (const [index, token] of tokens.entries()) {
20476
20667
  if (token === "--start-lib") inputs.push(token);
@@ -21925,6 +22116,7 @@ var init_swift_sdk_app_module = __esm({
21925
22116
  import_node_zlib4 = require("node:zlib");
21926
22117
  init_nativeSdkBindingContract();
21927
22118
  init_nativeWasmContract();
22119
+ init_swift_distribution_mirror();
21928
22120
  init_swift_guest_dyld_functions();
21929
22121
  init_swift_guest_linked_spans();
21930
22122
  init_swift_project_user();
@@ -23456,7 +23648,9 @@ var init_swift_objc_prebuilt = __esm({
23456
23648
  init_internal_child_contract();
23457
23649
  init_self_invocation();
23458
23650
  init_native_prebuilt();
23651
+ init_swift_distribution_mirror();
23459
23652
  init_swift_objc_prebuilt_catalog();
23653
+ init_swift_objc_standin();
23460
23654
  init_swift_toolchain();
23461
23655
  quote = (value) => "'" + value.replaceAll("'", "'\\''") + "'";
23462
23656
  }
@@ -25108,7 +25302,7 @@ function syncSwiftTree(base, files, alreadySynced) {
25108
25302
  const full = import_node_path49.default.join(dir, entry.name);
25109
25303
  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
25304
  // 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))
25305
+ 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
25306
  continue;
25113
25307
  if (entry.isDirectory()) walk(full);
25114
25308
  else if (!files.has(full) && (!kept || !kept.has((0, import_node_fs47.lstatSync)(full).ino)))
@@ -25801,7 +25995,7 @@ function needsNativeToolset(input, prebuilt) {
25801
25995
  input.packageFiles || prebuilt || Object.keys(input.files).some(isSwiftNativeTranslationUnit)
25802
25996
  );
25803
25997
  }
25804
- function writeSwiftProject(layout2, input, moduleRoot, prebuilt, allowHeaderCompiler = false, objcPrebuiltStage) {
25998
+ function writeSwiftProject(layout2, input, moduleRoot, prebuilt, allowHeaderCompiler = false, objcPrebuiltStage, compileSdk) {
25805
25999
  const nativeToolset = needsNativeToolset(input, prebuilt);
25806
26000
  if (input.headerAliases !== void 0 && !isSwiftHeaderAliases(input.headerAliases))
25807
26001
  throw new Error("swift compile input has invalid original header aliases");
@@ -25930,6 +26124,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
25930
26124
  checkedToolchain = swiftToolchain(pin.release, swiftModuleSdk(moduleRoot));
25931
26125
  return checkedToolchain;
25932
26126
  };
26127
+ const resolvedSdkPaths = (toolchainBin) => swiftSdkPaths(moduleRoot, toolchainBin, compileSdk?.options, compileSdk?.id);
25933
26128
  const targetStagedFiles = /* @__PURE__ */ new Map();
25934
26129
  const stageTargetFile = (target, file, contents2, options) => {
25935
26130
  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 +26251,25 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
26056
26251
  files.set(destination, contents2);
26057
26252
  }
26058
26253
  }
26254
+ const binaryTreePrefix = `${SWIFT_BINARY_TREES_DIR}/`;
26255
+ const binaryTreeSegment = `/${SWIFT_BINARY_TREES_DIR}/`;
26256
+ const isBinaryTreeFile = (file) => file.startsWith(binaryTreePrefix) || file.includes(binaryTreeSegment);
26257
+ const stageBinaryTreeFile = (file, contents2) => {
26258
+ const destination = import_node_path49.default.join(layout2.root, file);
26259
+ if (files.has(destination)) return;
26260
+ writeBuildFile(destination, contents2);
26261
+ alreadySynced.set(destination, contents2);
26262
+ files.set(destination, contents2);
26263
+ };
26264
+ for (const [file, contents2] of Object.entries(input.files))
26265
+ if (isBinaryTreeFile(file)) stageBinaryTreeFile(file, contents2);
26266
+ for (const [file, bytes] of Object.entries(input.packageFiles ?? {}))
26267
+ if (isBinaryTreeFile(file) && !file.endsWith(".swift"))
26268
+ stageBinaryTreeFile(file, Buffer.from(bytes, "base64"));
26269
+ for (const [file, bytes] of Object.entries(input.projectFiles ?? {}))
26270
+ if (isBinaryTreeFile(file)) stageBinaryTreeFile(file, Buffer.from(bytes, "base64"));
26059
26271
  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
26272
  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
26273
  const headerSearch = writeXcodeHeaderSearch(
26063
26274
  import_node_path49.default.join(layout2.root, ".build", "peach-xcode-headers"),
26064
26275
  nativeTargets.map((settings) => {
@@ -26110,7 +26321,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
26110
26321
  import_node_path49.default.join(layout2.root, file)
26111
26322
  ])
26112
26323
  ),
26113
- (file) => !file.startsWith(inRoot) || files.has(file) || file.includes(binaryTree)
26324
+ (file) => !file.startsWith(inRoot) || files.has(file)
26114
26325
  );
26115
26326
  const importModuleMaps = /* @__PURE__ */ new Map();
26116
26327
  const sourceModuleMaps = /* @__PURE__ */ new Map();
@@ -26253,7 +26464,7 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
26253
26464
  ];
26254
26465
  })();
26255
26466
  const sdkInclude = import_node_path49.default.join(
26256
- swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
26467
+ resolvedSdkPaths(toolchainBin).sysroot,
26257
26468
  "darwin/usr/include"
26258
26469
  );
26259
26470
  const dependencyModuleMaps = clangImportModuleMapFlags(
@@ -27000,7 +27211,8 @@ ${entry}`);
27000
27211
  );
27001
27212
  if (nativeFlags) {
27002
27213
  const toolchainBin = nativeToolchain();
27003
- const headers = import_node_path49.default.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, "darwin");
27214
+ const headers = import_node_path49.default.join(resolvedSdkPaths(toolchainBin).sysroot, "darwin");
27215
+ const sdkOverlayDirectory = compileSdk?.id === SWIFT_SDK_MIRROR_ID ? import_node_path49.default.join(layout2.root, SWIFT_SDK_MIRROR) : void 0;
27004
27216
  const dependencies2 = swiftTargetDependencies(input.files, targets);
27005
27217
  const reachesNative = (name3, seen = /* @__PURE__ */ new Set()) => {
27006
27218
  if (native.has(name3)) return true;
@@ -27018,7 +27230,12 @@ ${entry}`);
27018
27230
  throw new Error(
27019
27231
  target.name + ": missing or unsupported declared iOS deployment target " + JSON.stringify(version2)
27020
27232
  );
27021
- const sdkIntake = objcSdkIntakeFlags(headers, toolchainBin, minimum);
27233
+ const sdkIntake = objcSdkIntakeFlags(
27234
+ headers,
27235
+ toolchainBin,
27236
+ minimum,
27237
+ sdkOverlayDirectory
27238
+ );
27022
27239
  const sdkOverlay = sdkIntake.indexOf("-ivfsoverlay");
27023
27240
  if (sdkOverlay >= 0) generatedOverlays.add(sdkIntake[sdkOverlay + 1]);
27024
27241
  const intake = [
@@ -27240,7 +27457,7 @@ ${entry}`);
27240
27457
  distribution: distribution ?? void 0,
27241
27458
  moduleExcludes,
27242
27459
  deferDarwinOverlay: native.size > 0 && toolsetOrdersLibcxxBeforeDarwinOverlay(
27243
- swiftSdkPaths(moduleRoot, nativeToolchain()).cFlags
27460
+ resolvedSdkPaths(nativeToolchain()).cFlags
27244
27461
  ),
27245
27462
  ...reachesFrameworks ? {
27246
27463
  distributionLink: {
@@ -27283,7 +27500,7 @@ ${entry}`);
27283
27500
  ...headerAliasFlags,
27284
27501
  ...native.size > 0 ? [
27285
27502
  "-fmodule-map-file=" + import_node_path49.default.join(
27286
- swiftSdkPaths(moduleRoot, nativeToolchain()).sysroot,
27503
+ resolvedSdkPaths(nativeToolchain()).sysroot,
27287
27504
  "darwin/wasm/include/module.modulemap"
27288
27505
  )
27289
27506
  ] : []
@@ -27293,7 +27510,7 @@ ${entry}`);
27293
27510
  const prebuiltCompiler = distribution && objcPrebuiltStage !== false ? swiftObjCPrebuiltCompiler(
27294
27511
  clang,
27295
27512
  layout2.root,
27296
- swiftSdkPaths(moduleRoot, nativeToolchain()).sysroot,
27513
+ resolvedSdkPaths(nativeToolchain()).sysroot,
27297
27514
  distribution.id,
27298
27515
  [...native.keys()],
27299
27516
  objcPrebuiltStage
@@ -27551,12 +27768,55 @@ package.targets += [.target(name: ${JSON.stringify(name3)}, dependencies: ${JSON
27551
27768
  `;
27552
27769
  return name3;
27553
27770
  };
27554
- const headerBuilds = headerCompiler ? [
27555
- {
27556
- target: buildProduct(SWIFT_HEADER_PRODUCTS_TARGET, orderedProducers),
27557
- producers: orderedProducers
27771
+ const producerUnitCount = /* @__PURE__ */ new Map();
27772
+ for (const target of targets) {
27773
+ if (!producerSet.has(target.name)) continue;
27774
+ producerUnitCount.set(
27775
+ target.name,
27776
+ Math.max(
27777
+ 1,
27778
+ targetEntries(target).filter(([file]) => file.endsWith(".swift")).length
27779
+ )
27780
+ );
27781
+ }
27782
+ const MAX_HEADER_STAGE_TARGETS = 100;
27783
+ const MAX_HEADER_STAGE_UNITS = 400;
27784
+ const chunkHeaderProducers = (producers2) => {
27785
+ const levelOrdered = [...producers2].sort(
27786
+ (left, right) => depths.get(left) - depths.get(right)
27787
+ );
27788
+ const totalUnits = levelOrdered.reduce(
27789
+ (sum, name3) => sum + (producerUnitCount.get(name3) ?? 1),
27790
+ 0
27791
+ );
27792
+ if (levelOrdered.length <= 1 || levelOrdered.length <= MAX_HEADER_STAGE_TARGETS && totalUnits <= MAX_HEADER_STAGE_UNITS) {
27793
+ return [
27794
+ {
27795
+ target: buildProduct(SWIFT_HEADER_PRODUCTS_TARGET, levelOrdered),
27796
+ producers: levelOrdered
27797
+ }
27798
+ ];
27799
+ }
27800
+ const chunks = [];
27801
+ let current = [];
27802
+ let units = 0;
27803
+ for (const name3 of levelOrdered) {
27804
+ const size = producerUnitCount.get(name3) ?? 1;
27805
+ if (current.length > 0 && (current.length >= MAX_HEADER_STAGE_TARGETS || units + size > MAX_HEADER_STAGE_UNITS)) {
27806
+ chunks.push(current);
27807
+ current = [];
27808
+ units = 0;
27809
+ }
27810
+ current.push(name3);
27811
+ units += size;
27558
27812
  }
27559
- ] : [...stages].sort(([left], [right]) => left - right).map(([level, producers2]) => ({
27813
+ if (current.length > 0) chunks.push(current);
27814
+ return chunks.map((members, index) => ({
27815
+ target: buildProduct(`${SWIFT_HEADER_PRODUCTS_TARGET}${index + 1}`, members),
27816
+ producers: members
27817
+ }));
27818
+ };
27819
+ const headerBuilds = headerCompiler ? chunkHeaderProducers(orderedProducers) : [...stages].sort(([left], [right]) => left - right).map(([level, producers2]) => ({
27560
27820
  target: buildProduct(`${SWIFT_HEADER_PRODUCTS_TARGET}${level}`, producers2),
27561
27821
  producers: producers2
27562
27822
  }));
@@ -29083,8 +29343,15 @@ ${compatShape}` : "";
29083
29343
  frameworkLease
29084
29344
  );
29085
29345
  const compileFrameworkRoot2 = distribution ? swiftDistributionCompileView(frameworkRoot2, distribution) : frameworkRoot2;
29086
- const sdk2 = swiftModuleSdk(frameworkRoot2).wasmSdkId;
29087
- const icu2 = options.linkOnly ? null : swiftIcuAsset(options.toolchainBin, sdk2);
29346
+ const sdk = swiftModuleSdk(frameworkRoot2).wasmSdkId;
29347
+ const compileSdk2 = mirrorDistribution ? syncSwiftSdkMirror(root2, frameworkRoot2, options.toolchainBin, sdk) : {
29348
+ id: sdk,
29349
+ options: swiftCompileSdkOptions(frameworkRoot2, options.toolchainBin),
29350
+ toolsetChanged: false
29351
+ };
29352
+ if (mirrorDistribution && compileSdk2.toolsetChanged)
29353
+ clearSwiftSdkPathsCache(import_node_path49.default.join(root2, SWIFT_SDK_MIRROR));
29354
+ const icu2 = options.linkOnly ? null : swiftIcuAsset(options.toolchainBin, sdk);
29088
29355
  let prebuilt2;
29089
29356
  if (!distribution) {
29090
29357
  if (allowWrite) stage("compiling framework products");
@@ -29095,7 +29362,7 @@ ${compatShape}` : "";
29095
29362
  frameworkKey,
29096
29363
  input,
29097
29364
  swift,
29098
- sdk: sdk2,
29365
+ sdk,
29099
29366
  toolchainBin: options.toolchainBin,
29100
29367
  plugins: macroPlugins2,
29101
29368
  buildOptions: {
@@ -29120,7 +29387,8 @@ ${compatShape}` : "";
29120
29387
  frameworkRoot: frameworkRoot2,
29121
29388
  compileFrameworkRoot: compileFrameworkRoot2,
29122
29389
  macroPlugins: macroPlugins2,
29123
- sdk: sdk2,
29390
+ sdk,
29391
+ compileSdk: compileSdk2,
29124
29392
  icu: icu2,
29125
29393
  prebuilt: prebuilt2,
29126
29394
  readHold: readHold2
@@ -29141,7 +29409,7 @@ ${compatShape}` : "";
29141
29409
  frameworkRoot,
29142
29410
  compileFrameworkRoot,
29143
29411
  macroPlugins,
29144
- sdk,
29412
+ compileSdk,
29145
29413
  icu,
29146
29414
  prebuilt
29147
29415
  } = frameworks;
@@ -29159,13 +29427,13 @@ ${compatShape}` : "";
29159
29427
  if (retireStaleSwiftLink(
29160
29428
  root2,
29161
29429
  swiftLinkStamp({
29162
- frameworkKey: `${options.release}\0${Boolean(distribution)}\0${swiftModuleSdk(frameworkRoot).wasmSdkId}`,
29430
+ frameworkKey: mirrorDistribution ? `${options.release}\0mirror` : `${options.release}\0${Boolean(distribution)}\0${swiftModuleSdk(frameworkRoot).wasmSdkId}`,
29163
29431
  packageHostMacros
29164
29432
  }),
29165
29433
  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,
29434
+ // mirrored distributions and their WASI SDK mirror invalidate
29435
+ // dependents per changed file instead of wiping every Clang object.
29436
+ frameworkKey: mirrorDistribution ? `${options.release}\0mirror` : distribution ? `${options.release}\0${distribution.wasmSdkChecksum}` : frameworkKey,
29169
29437
  prebuilt,
29170
29438
  packageHostMacros
29171
29439
  }),
@@ -29179,7 +29447,8 @@ ${compatShape}` : "";
29179
29447
  frameworkRoot,
29180
29448
  prebuilt,
29181
29449
  !options.project,
29182
- options.project ? false : options.objcPrebuiltStage ?? (options.intermediates ? false : void 0)
29450
+ options.project ? false : options.objcPrebuiltStage ?? (options.intermediates ? false : void 0),
29451
+ compileSdk
29183
29452
  );
29184
29453
  const productFile = import_node_path49.default.join(frameworkRoot, SWIFT_FRAMEWORK_PRODUCT_FILE);
29185
29454
  writeSwiftAutolinkLinker(
@@ -29255,6 +29524,7 @@ ${compatShape}` : "";
29255
29524
  const jobs = swiftCompilerJobs();
29256
29525
  const incrementalPreview = sdkImage !== void 0 && !guestGraph && !options.project && !input.optimize && !input.unoptimized;
29257
29526
  const perFile = input.unoptimized || incrementalPreview;
29527
+ const reproducibleFrameworkRoot = mirrorDistribution ? frameworkRoot : compileFrameworkRoot;
29258
29528
  const buildArgs = [
29259
29529
  "build",
29260
29530
  ...projectProcess?.cacheOptions ?? swiftPackageCacheOptions(),
@@ -29264,10 +29534,10 @@ ${compatShape}` : "";
29264
29534
  String(jobs),
29265
29535
  "--package-path",
29266
29536
  root2,
29267
- ...swiftCompileSdkOptions(frameworkRoot, options.toolchainBin),
29537
+ ...compileSdk.options,
29268
29538
  ...swiftObjCSelectorOptions(frameworkRoot),
29269
29539
  "--swift-sdk",
29270
- sdk,
29540
+ compileSdk.id,
29271
29541
  ...preparation.targetToolset ? ["--toolset", import_node_path49.default.join(root2, ".peach-target-toolset.json")] : [],
29272
29542
  "-c",
29273
29543
  "release",
@@ -29302,7 +29572,7 @@ ${compatShape}` : "";
29302
29572
  ],
29303
29573
  ...swiftReproducibleBuildFlags([
29304
29574
  [import_node_path49.default.dirname(options.toolchainBin), "toolchain"],
29305
- [compileFrameworkRoot, "framework"],
29575
+ [reproducibleFrameworkRoot, "framework"],
29306
29576
  [root2, "build"],
29307
29577
  ...forwarders
29308
29578
  ]).flatMap((flag, index, flags) => {
@@ -29312,8 +29582,8 @@ ${compatShape}` : "";
29312
29582
  let mapped = flag;
29313
29583
  for (const [dir, target] of [
29314
29584
  [root2, "/peach/build"],
29315
- [compileFrameworkRoot, "/peach/framework"],
29316
- [(0, import_node_fs47.realpathSync)(compileFrameworkRoot), "/peach/framework"],
29585
+ [reproducibleFrameworkRoot, "/peach/framework"],
29586
+ [(0, import_node_fs47.realpathSync)(reproducibleFrameworkRoot), "/peach/framework"],
29317
29587
  [toolchainDir, "/peach/toolchain"],
29318
29588
  [(0, import_node_fs47.realpathSync)(toolchainDir), "/peach/toolchain"]
29319
29589
  ]) {
@@ -29342,8 +29612,14 @@ ${compatShape}` : "";
29342
29612
  (0, import_node_fs47.rmSync)(linked, { force: true });
29343
29613
  stage("compiling and linking Swift modules");
29344
29614
  const frameworkInterfaces = /* @__PURE__ */ new Map();
29615
+ const compileSdkPaths = swiftSdkPaths(
29616
+ frameworkRoot,
29617
+ options.toolchainBin,
29618
+ compileSdk.options,
29619
+ compileSdk.id
29620
+ );
29345
29621
  const sdkFrameworks = import_node_path49.default.join(
29346
- swiftSdkPaths(frameworkRoot, options.toolchainBin).darwin,
29622
+ compileSdkPaths.darwin,
29347
29623
  "System/Library/Frameworks"
29348
29624
  );
29349
29625
  const generatedInterface = (source) => withoutImportedSdkEnumForwards(
@@ -29547,7 +29823,7 @@ ${compatShape}` : "";
29547
29823
  options.toolchainBin,
29548
29824
  recipe,
29549
29825
  new Map(
29550
- preparation.headerBuilds[0].producers.map((producer) => {
29826
+ preparation.headerBuilds.flatMap((stage2) => stage2.producers).map((producer) => {
29551
29827
  const paths = headerPaths(producer);
29552
29828
  return [
29553
29829
  swiftTargetModuleName(producer),
@@ -29641,7 +29917,7 @@ ${compatShape}` : "";
29641
29917
  moduleRoot: frameworkRoot,
29642
29918
  toolchainBin: options.toolchainBin,
29643
29919
  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,
29920
+ sysroot: compileSdkPaths.sysroot,
29645
29921
  sdk: swiftModuleSdk(frameworkRoot),
29646
29922
  sdkImage,
29647
29923
  compilerDigest: compilerSourceDigest,
@@ -29671,9 +29947,7 @@ ${compatShape}` : "";
29671
29947
  project: options.project && {
29672
29948
  ...options.project,
29673
29949
  env: { ...options.project.env, ...projectProcess?.env },
29674
- sdkRoot: import_node_path49.default.dirname(
29675
- swiftSdkPaths(frameworkRoot, options.toolchainBin).sysroot
29676
- ),
29950
+ sdkRoot: import_node_path49.default.dirname(compileSdkPaths.sysroot),
29677
29951
  linked: output
29678
29952
  }
29679
29953
  });
@@ -29933,7 +30207,7 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
29933
30207
  REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
29934
30208
  MULTI_MANIFEST_VERSION = 76;
29935
30209
  SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
29936
- compilerSourceDigest = true ? "e28f3765de44ea471f6097cb0ae6ead762595ae2bb24b4e38d4210f32b9434c1" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
30210
+ compilerSourceDigest = true ? "404914a824c2f550a36612007732c8afa8459125cb02e28f12c34e2e6d8878d3" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
29937
30211
  nativeCxxCompilerFlags = ["-fno-cxx-modules"];
29938
30212
  MODULE_MAP_RESPONSE_FILE_RUN = 16;
29939
30213
  cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));