peachsim 0.1.1817 → 0.1.1821

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 (144) hide show
  1. package/cli/commands/agent-indicator-mode.ts +2 -1
  2. package/cli/commands/coverage-swift.ts +4 -3
  3. package/cli/commands/flow.ts +7 -0
  4. package/cli/commands/inspect/core.ts +14 -4
  5. package/cli/commands/inspect/wait-selector.ts +9 -1
  6. package/cli/commands/maestro-compare.ts +7 -0
  7. package/cli/commands/package.ts +5 -0
  8. package/cli/commands/screenshot-mode.ts +2 -1
  9. package/cli/commands/shell-boolean-mode.ts +7 -3
  10. package/cli/commands/shell-url.ts +4 -0
  11. package/cli/commands/show-touches-mode.ts +2 -1
  12. package/cli/commands/test.ts +3 -2
  13. package/cli/commands/three-mode.ts +2 -1
  14. package/cli/outbound-endpoints.ts +5 -0
  15. package/dist-lib/agent-daemon-client.cjs +1 -1
  16. package/dist-lib/agent-events.cjs +1 -1
  17. package/dist-lib/attached-projects.cjs +1 -1
  18. package/dist-lib/auth/shared-session.cjs +1 -1
  19. package/dist-lib/backend-origin.cjs +1 -1
  20. package/dist-lib/beta.cjs +1 -1
  21. package/dist-lib/beta.mjs +1 -1
  22. package/dist-lib/bridge-constants.cjs +1 -1
  23. package/dist-lib/bridge-contract-input.cjs +1 -1
  24. package/dist-lib/bridge-contract-input.mjs +1 -1
  25. package/dist-lib/bridge-contract.cjs +1 -1
  26. package/dist-lib/bridge-contract.mjs +1 -1
  27. package/dist-lib/bundle-channel.cjs +2842 -3830
  28. package/dist-lib/capture-contract.cjs +1 -1
  29. package/dist-lib/capture-contract.mjs +1 -1
  30. package/dist-lib/cloud-contract.cjs +1 -1
  31. package/dist-lib/cloud-contract.mjs +1 -1
  32. package/dist-lib/cloud-test-args.cjs +1 -1
  33. package/dist-lib/cloud-test-args.mjs +1 -1
  34. package/dist-lib/cloud.cjs +1 -1
  35. package/dist-lib/cloud.mjs +1 -1
  36. package/dist-lib/config.cjs +1 -1
  37. package/dist-lib/config.mjs +1 -1
  38. package/dist-lib/detox/index.cjs +2 -2
  39. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  40. package/dist-lib/expo-swift-bundle.cjs +1722 -1580
  41. package/dist-lib/expo-swift-metadata.cjs +1 -1
  42. package/dist-lib/expo-swift-metadata.mjs +1 -1
  43. package/dist-lib/home-paths.cjs +1 -1
  44. package/dist-lib/host/bridge-host.cjs +2800 -3794
  45. package/dist-lib/host/fetch-proxy-handler.cjs +2 -2
  46. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  47. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  48. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  49. package/dist-lib/host/websocket-proxy.cjs +1 -1
  50. package/dist-lib/index.cjs +32 -11
  51. package/dist-lib/jump-to-source-babel.cjs +1 -1
  52. package/dist-lib/jump-to-source-native.cjs +1 -1
  53. package/dist-lib/kotlin-host.cjs +1 -1
  54. package/dist-lib/menu.cjs +1 -1
  55. package/dist-lib/menu.mjs +1 -1
  56. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  57. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  58. package/dist-lib/metro-production-bundle.cjs +1 -1
  59. package/dist-lib/metro-production-bundle.mjs +1 -1
  60. package/dist-lib/metro.cjs +28 -7
  61. package/dist-lib/native-app-identity-project.cjs +31 -6
  62. package/dist-lib/native-app-identity-project.mjs +295 -259
  63. package/dist-lib/native-app-identity.cjs +1 -1
  64. package/dist-lib/native-app-identity.mjs +1 -1
  65. package/dist-lib/native-firebase-metadata.cjs +1 -1
  66. package/dist-lib/native-firebase-metadata.mjs +1 -1
  67. package/dist-lib/pdfium-raster.cjs +1 -1
  68. package/dist-lib/pdfium-raster.mjs +1 -1
  69. package/dist-lib/plist.cjs +1 -1
  70. package/dist-lib/plist.mjs +1 -1
  71. package/dist-lib/profiles.cjs +1 -1
  72. package/dist-lib/public-brand.cjs +1 -1
  73. package/dist-lib/public-origins-lib-esm.json +29 -24
  74. package/dist-lib/public-origins-lib.json +100 -80
  75. package/dist-lib/react-native-host-modules.cjs +1 -1
  76. package/dist-lib/react-native-host-modules.mjs +1 -1
  77. package/dist-lib/reap-browser.cjs +1 -1
  78. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  79. package/dist-lib/sdk.cjs +8 -6
  80. package/dist-lib/sdk.mjs +8 -6
  81. package/dist-lib/skills.cjs +3192 -4150
  82. package/dist-lib/swift-compile.cjs +136 -29
  83. package/dist-lib/swift-compile.mjs +143 -34
  84. package/dist-lib/swift-package.cjs +1 -1
  85. package/dist-lib/swift-package.mjs +1 -1
  86. package/dist-lib/swift-submit.cjs +1 -1
  87. package/dist-lib/swift-submit.mjs +1 -1
  88. package/dist-lib/swift-toolchain.cjs +52 -6
  89. package/dist-lib/swift.cjs +1 -1
  90. package/dist-lib/vite-swift.cjs +2206 -2060
  91. package/dist-lib/vite.cjs +2 -2
  92. package/dist-lib/worklet-executable.cjs +1 -1
  93. package/dist-lib/worklet-executable.mjs +1 -1
  94. package/dist-types/packages/peach-engine/src/ios/photoLibraryContract.d.ts +1 -1
  95. package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +5 -0
  96. package/dist-types/packages/peach-engine/src/render-worker/map-command-channel.d.ts +41 -0
  97. package/dist-types/packages/peach-engine/src/render-worker/mapServicesContract.d.ts +45 -0
  98. package/package.json +2 -1
  99. package/runtime-companion.json +1 -1
  100. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes +1 -1
  101. package/sdk/ios/usr/include/module.modulemap +3 -0
  102. package/sdk/ios/usr/include/notify.modulemap +9 -0
  103. package/sdk/ios/usr/lib/swift/Darwin.swiftmodule/arm64-apple-ios-simulator.swiftinterface +4 -0
  104. package/sdk/ios/usr/lib/swift/Dispatch.swiftmodule/arm64-apple-ios-simulator.swiftinterface +1 -1
  105. package/sdk/ios/usr/lib/swift/Foundation.swiftmodule/arm64-apple-ios-simulator.swiftinterface +7 -1
  106. package/sdk/ios/usr/lib/swift/ObjectiveC.swiftmodule/arm64-apple-ios-simulator.swiftinterface +1 -0
  107. package/sdk/ios/usr/lib/swift/SwiftUI.swiftmodule/arm64-apple-ios-simulator.swiftinterface +21 -0
  108. package/sdk/ios/usr/lib/swift/SwiftUICore.swiftmodule/arm64-apple-ios-simulator.swiftinterface +6 -1
  109. package/sdk/ios/wasm/include/__header_time.h +4 -0
  110. package/sdk/ios/wasm/include/pthread.h +2 -0
  111. package/sdk/ios/wasm/include/sys/mman.h +1 -1
  112. package/sdk/ios/wasm/include/sys/resource.h +31 -0
  113. package/sdk/ios/wasm/include/unistd.h +4 -0
  114. package/src/answeredNativePackages.ts +11 -9
  115. package/src/expo-discovery-cache.ts +69 -52
  116. package/src/expo-native-workspace.ts +3 -1
  117. package/src/expo-swift-host.ts +45 -7
  118. package/src/installed-native-libraries.ts +103 -20
  119. package/src/native-static-libraries.ts +69 -33
  120. package/src/nitro-adapter.ts +0 -9
  121. package/src/nitro-compile.ts +45 -16
  122. package/src/nitro-superset.ts +4 -5
  123. package/src/plist-bytes.ts +9 -0
  124. package/src/portable-expo-workspace.ts +4 -3
  125. package/src/react-native-bridge-modules.ts +11 -15
  126. package/src/swift-compile.ts +146 -18
  127. package/src/swift-cxx-reachable.ts +13 -0
  128. package/src/swift-distribution.ts +3 -4
  129. package/src/swift-host.ts +5 -3
  130. package/src/swift-installed-targets.ts +32 -14
  131. package/src/swift-native-pin.ts +45 -0
  132. package/src/swift-objc-compile.ts +23 -1
  133. package/src/swift-objc-standin.ts +4 -1
  134. package/src/swift-package-manifest.ts +2 -2
  135. package/src/swift-root-lock.ts +4 -3
  136. package/src/swift-standins.ts +5 -26
  137. package/src/swift-toolchain.ts +69 -12
  138. package/src/swift-wasm-prune.ts +1 -0
  139. package/src/swift-xcframework.ts +23 -12
  140. package/src/swiftContract.ts +2 -0
  141. package/src/swiftNativePinContract.ts +68 -0
  142. package/src/turbo-bundle.ts +14 -6
  143. package/src/turbo-compile.ts +76 -11
  144. package/src/turbo-source.ts +91 -15
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1817 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1821 | (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;
@@ -2674,6 +2674,7 @@ var SWIFT_HOST_COMPILER_ID = "81b2c791c27276bf";
2674
2674
  var compilerArchives = {
2675
2675
  "swift-6.4.0-RELEASE-custom-0b2d0a9011c88e66": {
2676
2676
  identity: "0b2d0a9011c88e66",
2677
+ archive: "tar.gz",
2677
2678
  hosts: {
2678
2679
  "darwin-arm64": {
2679
2680
  checksum: "dc6a494227297ea657e8e5f7c5b4a861cb5e142bdbcfcb028ace2aeb19db90cc",
@@ -2691,6 +2692,7 @@ var compilerArchives = {
2691
2692
  },
2692
2693
  "swift-6.4.0-RELEASE-custom-f7c03c3f59ec5d83": {
2693
2694
  identity: "f7c03c3f59ec5d83",
2695
+ archive: "tar.gz",
2694
2696
  hosts: {
2695
2697
  "darwin-arm64": {
2696
2698
  checksum: "8946a2d4716d3b0784cef7a85a35f66537bd319c4c5a48c63457d607260df5c5",
@@ -2708,6 +2710,7 @@ var compilerArchives = {
2708
2710
  },
2709
2711
  "swift-6.4.0-RELEASE-custom-3e3dca8fd1d82975": {
2710
2712
  identity: "3e3dca8fd1d82975",
2713
+ archive: "tar.gz",
2711
2714
  hosts: {
2712
2715
  "darwin-arm64": {
2713
2716
  checksum: "dfad56454f5e1e465071ff708bf485be65b438cf55d02b04d26d17d26df9f54a",
@@ -2725,6 +2728,7 @@ var compilerArchives = {
2725
2728
  },
2726
2729
  "swift-6.4.0-RELEASE-custom-b082ac5437336790": {
2727
2730
  identity: "b082ac5437336790",
2731
+ archive: "tar.gz",
2728
2732
  hosts: {
2729
2733
  "darwin-arm64": {
2730
2734
  checksum: "85e601982321d3a6f81f05928bc9bbe7a61bc75b27ce24508e79f6b5b537254d",
@@ -2742,6 +2746,7 @@ var compilerArchives = {
2742
2746
  },
2743
2747
  "swift-6.4.0-RELEASE-custom-9cdaffdb6b37fb47": {
2744
2748
  identity: "9cdaffdb6b37fb47",
2749
+ archive: "tar.gz",
2745
2750
  hosts: {
2746
2751
  "darwin-arm64": {
2747
2752
  checksum: "fdd3f88cf76a8dc2083275d4253255030068a25b5ba68acbf59e0407c45677dd",
@@ -2759,6 +2764,7 @@ var compilerArchives = {
2759
2764
  },
2760
2765
  "swift-6.4.0-RELEASE-custom-bd49e2f77434e7b1": {
2761
2766
  identity: "bd49e2f77434e7b1",
2767
+ archive: "tar.gz",
2762
2768
  hosts: {
2763
2769
  "darwin-arm64": {
2764
2770
  checksum: "e815b06394566e8125475afc8f1807f7f465318c845549c5831043cdc28eca64",
@@ -2776,6 +2782,7 @@ var compilerArchives = {
2776
2782
  },
2777
2783
  "swift-6.4.0-RELEASE-custom-13450179a7e01c81": {
2778
2784
  identity: "13450179a7e01c81",
2785
+ archive: "tar.gz",
2779
2786
  hosts: {
2780
2787
  "darwin-arm64": {
2781
2788
  checksum: "a29be6b722f15c7aafac26ba5703a7392f49ce7ea5e1c56548846b7e458290f7",
@@ -2793,6 +2800,7 @@ var compilerArchives = {
2793
2800
  },
2794
2801
  "swift-6.4.0-RELEASE-custom-f6868fa6054e83d6": {
2795
2802
  identity: "f6868fa6054e83d6",
2803
+ archive: "tar.gz",
2796
2804
  hosts: {
2797
2805
  "darwin-arm64": {
2798
2806
  checksum: "bd80c2f35864ec29883dd22001d0165821e80d78002fc12f92406c3c708694a4",
@@ -2810,23 +2818,25 @@ var compilerArchives = {
2810
2818
  },
2811
2819
  "swift-6.4.0-RELEASE-custom-a560ff35bf882b5c": {
2812
2820
  identity: "a560ff35bf882b5c",
2821
+ archive: "tar.zst",
2813
2822
  hosts: {
2814
2823
  "darwin-arm64": {
2815
- checksum: "ec20a41851ac558fe663d78def6b93d0d47c5a0cb69688ee270fd85de637a522",
2824
+ checksum: "36c50bcdfba88a4c0989af0bd60371497eb4403aa7b80644b479fa509a2187a9",
2816
2825
  manifest: "253e891527d2213f54eace768b902de89de5e9495a3c5f4018de1985516bd553"
2817
2826
  },
2818
2827
  "linux-x64": {
2819
- checksum: "f0126a2e63d275895036d02d75a901070da0343dbf03bf17342e10cb6f893dee",
2828
+ checksum: "ba25da9182314fc7b7dd2fc041280e1c7b409f80a1fbccdfa5c342669d164c8e",
2820
2829
  manifest: "6f951cc4071dd0d6054d85711a7c5fe272273658847831b477a8b24be7254ca0"
2821
2830
  },
2822
2831
  "linux-arm64": {
2823
- checksum: "315fa766559a6e69bfd10dcddf40e04c91155f0db3047d210d74ac87652fb7e6",
2832
+ checksum: "5f0f4456e9fe22b5486025db9f679c865841660797d71761245291c2c6811c20",
2824
2833
  manifest: "b6f62fca2ec37593e274ee5bac474f21ffc5db14cd82f492ccbc774f8e9b75d8"
2825
2834
  }
2826
2835
  }
2827
2836
  },
2828
2837
  [SWIFT_HOST_COMPILER_RELEASE]: {
2829
2838
  identity: SWIFT_HOST_COMPILER_ID,
2839
+ archive: "tar.gz",
2830
2840
  hosts: {
2831
2841
  "darwin-arm64": {
2832
2842
  checksum: "bc51b83d9e2e01c9873875326544734486d3ff3a868d650379c304045e8838d3",
@@ -2859,15 +2869,20 @@ function privateSwiftRelease() {
2859
2869
  throw new Error(`${root} holds no Swift distribution release`);
2860
2870
  return release;
2861
2871
  }
2862
- function swiftHostCompilerArchive(release, host2 = `${process.platform}-${process.arch}`) {
2872
+ function swiftHostCompilerPin(release) {
2863
2873
  const compiler = compilerArchives[release];
2864
2874
  if (!compiler) throw new Error(`unqualified host compiler ${release}`);
2875
+ return compiler;
2876
+ }
2877
+ function swiftHostCompilerArchive(release, host2 = `${process.platform}-${process.arch}`) {
2878
+ const compiler = swiftHostCompilerPin(release);
2865
2879
  const archive = compiler.hosts[host2];
2866
2880
  if (!archive) throw new Error(`unsupported Swift compiler host ${host2}`);
2867
2881
  return {
2868
2882
  ...archive,
2869
2883
  identity: compiler.identity,
2870
- url: `https://r2.sootsim.com/swift-host-compiler/${compiler.identity}/${release}-${host2}.tar.gz`
2884
+ archive: compiler.archive,
2885
+ url: `https://r2.sootsim.com/swift-host-compiler/${compiler.identity}/${archive.checksum}.${compiler.archive}`
2871
2886
  };
2872
2887
  }
2873
2888
  function swiftUpstreamRelease(release) {
@@ -3823,6 +3838,9 @@ function objcSdkIntakeFlags(headers, toolchainBin, minimum) {
3823
3838
  import_node_path7.default.join(headers, "System/Library/Frameworks"),
3824
3839
  "-isystem",
3825
3840
  import_node_path7.default.join(headers, "wasm/include"),
3841
+ // compiler intrinsics an arm64 unit includes, ahead of clang's arm-only ones.
3842
+ "-isystem",
3843
+ import_node_path7.default.join(headers, "wasm/intrinsics"),
3826
3844
  // libxml2 headers sit one level deeper, as in the iOS sdk: a unit
3827
3845
  // includes <libxml/parser.h> through usr/include/libxml2, never the parent.
3828
3846
  "-I",
@@ -5187,12 +5205,12 @@ async function withSwiftRootLock(root, work, signal, wait = true) {
5187
5205
  const children = [];
5188
5206
  const lease = {
5189
5207
  register(child) {
5190
- children.push(child);
5208
+ const index = children.push(child);
5191
5209
  if (child.pid === void 0) throw new Error("could not register compiler process");
5192
- const childPending = `${pending}.child.${child.pid}`;
5210
+ const childPending = `${pending}.child.${index}`;
5193
5211
  try {
5194
5212
  (0, import_node_fs13.writeFileSync)(childPending, JSON.stringify(ownIdentity(child.pid)));
5195
- (0, import_node_fs13.linkSync)(childPending, import_node_path14.default.join(directory, name(held, `child.${child.pid}`)));
5213
+ (0, import_node_fs13.linkSync)(childPending, import_node_path14.default.join(directory, name(held, `child.${index}`)));
5196
5214
  } finally {
5197
5215
  (0, import_node_fs13.rmSync)(childPending, { force: true });
5198
5216
  }
@@ -6768,7 +6786,8 @@ function pruneSwiftWasmLink(directory, toolchainBin, moduleRoot, staticClangTarg
6768
6786
  const prunedRspPath = import_node_path16.default.join(directory, ".peach-link.pruned.rsp");
6769
6787
  import_node_fs14.default.writeFileSync(prunedRspPath, outTokens.map((t) => JSON.stringify(t)).join(" "));
6770
6788
  (0, import_node_child_process12.execFileSync)(import_node_path16.default.join(toolchainBin, "wasm-ld"), [`@${prunedRspPath}`], {
6771
- stdio: "pipe"
6789
+ stdio: "pipe",
6790
+ maxBuffer: Infinity
6772
6791
  });
6773
6792
  import_node_fs14.default.rmSync(rspPath, { force: true });
6774
6793
  }
@@ -7292,7 +7311,7 @@ function swiftModuleInputFiles(root) {
7292
7311
  walk("ios-simulator-stdlib");
7293
7312
  return files.sort();
7294
7313
  }
7295
- function swiftMacroPlugins(moduleRoot) {
7314
+ function swiftMacroPlugins(moduleRoot, dir = import_node_path19.default.join(moduleRoot, ".build/host/RnxPreviewMacros")) {
7296
7315
  const distribution = swiftDistributionAt(moduleRoot);
7297
7316
  if (distribution)
7298
7317
  return {
@@ -7300,7 +7319,6 @@ function swiftMacroPlugins(moduleRoot) {
7300
7319
  executables: distribution.plugins.filter((plugin) => import_node_path19.default.basename(plugin) === "ExpoModulesMacros").map((plugin) => import_node_path19.default.join(moduleRoot, plugin)),
7301
7320
  stale: false
7302
7321
  };
7303
- const dir = import_node_path19.default.join(moduleRoot, ".build/host/RnxPreviewMacros");
7304
7322
  const release = JSON.parse(
7305
7323
  (0, import_node_fs17.readFileSync)(import_node_path19.default.join(moduleRoot, "toolchain.json"), "utf8")
7306
7324
  ).release;
@@ -7694,14 +7712,20 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
7694
7712
  for (const match of (0, import_node_fs17.readFileSync)(map, "utf8").matchAll(/^module\s+([A-Za-z_]\w*)/gm))
7695
7713
  modules.add(match[1]);
7696
7714
  }
7697
- const libc = import_node_path19.default.join(darwin, "usr/include");
7698
- for (const entry of (0, import_node_fs17.readdirSync)(libc)) {
7699
- if (!entry.endsWith(".modulemap")) continue;
7700
- for (const match of (0, import_node_fs17.readFileSync)(import_node_path19.default.join(libc, entry), "utf8").matchAll(
7701
- /^module\s+([A-Za-z_]\w*)/gm
7702
- ))
7703
- modules.add(match[1]);
7704
- }
7715
+ for (const libc of [
7716
+ import_node_path19.default.join(darwin, "usr/include"),
7717
+ import_node_path19.default.join(
7718
+ swiftSharedSdkRoot(moduleRoot, swiftDistributionAt(moduleRoot) !== null),
7719
+ "usr/include"
7720
+ )
7721
+ ])
7722
+ for (const entry of (0, import_node_fs17.readdirSync)(libc)) {
7723
+ if (!entry.endsWith(".modulemap")) continue;
7724
+ for (const match of (0, import_node_fs17.readFileSync)(import_node_path19.default.join(libc, entry), "utf8").matchAll(
7725
+ /^module\s+([A-Za-z_]\w*)/gm
7726
+ ))
7727
+ modules.add(match[1]);
7728
+ }
7705
7729
  for (const directory of frameworks) {
7706
7730
  for (const entry of (0, import_node_fs17.readdirSync)(directory)) {
7707
7731
  const map = import_node_path19.default.join(directory, entry, "Modules/module.modulemap");
@@ -7833,7 +7857,7 @@ var darwinRecordsRegion = (quoted) => quoted.length ? ["-Wl,--start-lib", ...quo
7833
7857
  var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
7834
7858
  var MULTI_MANIFEST_VERSION = 65;
7835
7859
  var SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
7836
- var compilerSourceDigest = true ? "1519f1f37c446535792f7bb0c9ba9c5e59b0b0f87d7b5c849346abe684325aa7" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
7860
+ var compilerSourceDigest = true ? "3d055fb169dadbe3931422242039d4edc7f595c6301256776bac390c04b04fff" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
7837
7861
  function swiftArtifactHash(input, release, moduleRoot) {
7838
7862
  const hash = (0, import_node_crypto8.createHash)("sha256");
7839
7863
  hash.update(`swift-compile
@@ -8030,6 +8054,14 @@ function emitSwiftPackageManifest(args) {
8030
8054
  );
8031
8055
  const macroSettings = (values) => (values ?? []).map((value) => ` ${clangMacroSetting(value)},`).join("");
8032
8056
  const flagArray = (literal) => `peachCompilerArguments(${JSON.stringify(literal.replace(/,\s*]$/, "]"))})`;
8057
+ const swiftFlagArray = (literal) => {
8058
+ const flags = JSON.parse(literal.replace(/,\s*]$/, "]"));
8059
+ const content = flags.map((flag) => JSON.stringify(flag)).join("\n") + "\n";
8060
+ const digest = (0, import_node_crypto8.createHash)("sha256").update(content).digest("hex");
8061
+ const file = import_node_path19.default.join(args.root, ".peach-swift-arguments", `${digest}.rsp`);
8062
+ args.files.set(file, content);
8063
+ return JSON.stringify([`@${file}`]);
8064
+ };
8033
8065
  const declaredClangSettings = (target, tool) => clangSettingEntries(
8034
8066
  target?.clangSettings?.map(
8035
8067
  (setting) => "flags" in setting ? {
@@ -8092,7 +8124,7 @@ function emitSwiftPackageManifest(args) {
8092
8124
  (value) => value.late?.producers.includes(target.name)
8093
8125
  )) ? `, "-emit-objc-header-path", ${JSON.stringify(import_node_path19.default.join(args.headerDirectory, `${target.name}-Swift${args.nativeHeaderDeclarations?.[target.name] ? ".original" : ""}.h`))}` : "";
8094
8126
  const clangMode = target.cxxInterop ? "" : ', "-Xcc", "-fno-cxx-modules"';
8095
- const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation}${interoperability}${defines}${features}${upcoming} .unsafeFlags(${flagArray(`["-Osize", "-Xfrontend", "-enable-cross-import-overlays"${overlayFlags}${FOUNDATION_IMPLICIT_FLAGS}${oneModule ? ONE_IMPLICIT_FLAGS : ""}${imports}${nativeImportFlags}${objcFlags}${header}${clangMode}${upstream}]`)})]`;
8127
+ const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation}${interoperability}${defines}${features}${upcoming} .unsafeFlags(${swiftFlagArray(`["-Osize", "-Xfrontend", "-enable-cross-import-overlays"${overlayFlags}${FOUNDATION_IMPLICIT_FLAGS}${oneModule ? ONE_IMPLICIT_FLAGS : ""}${imports}${nativeImportFlags}${objcFlags}${header}${clangMode}${upstream}]`)})]`;
8096
8128
  const deps = [
8097
8129
  .../* @__PURE__ */ new Set([
8098
8130
  ...(target.dependencies ?? []).flatMap(
@@ -9794,7 +9826,13 @@ function namesLibxml2(input) {
9794
9826
  }
9795
9827
  return false;
9796
9828
  }
9829
+ function needsNativeToolset(input, prebuilt) {
9830
+ return Boolean(
9831
+ input.packageFiles || prebuilt || Object.keys(input.files).some(isSwiftNativeTranslationUnit)
9832
+ );
9833
+ }
9797
9834
  function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
9835
+ const nativeToolset = needsNativeToolset(input, prebuilt);
9798
9836
  if (input.headerAliases !== void 0 && !isSwiftHeaderAliases(input.headerAliases))
9799
9837
  throw new Error("swift compile input has invalid original header aliases");
9800
9838
  if (input.nativeTargets !== void 0 && !isSwiftNativeTargets(input.nativeTargets))
@@ -10140,7 +10178,11 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
10140
10178
  importModuleMaps,
10141
10179
  generatedModuleMaps
10142
10180
  );
10143
- const flags = [...stageFlags(originalFlags, sdkInclude), ...dependencyModuleMaps];
10181
+ const flags = [
10182
+ ...stageFlags(originalFlags, sdkInclude),
10183
+ ...dependencyModuleMaps,
10184
+ ...target.defines?.includes(SWIFT_XCODE_BUILD_CONDITION) && !target.defines.includes("SWIFT_PACKAGE") ? ["-USWIFT_PACKAGE"] : []
10185
+ ];
10144
10186
  const prefixHeader = settings?.prefixHeader ? ["-include", import_node_path19.default.join(layout.root, settings.prefixHeader)] : [];
10145
10187
  const bundleName = entries.some(([file]) => file.endsWith(".swift")) ? void 0 : swiftObjCResourceBundleName({
10146
10188
  target: target.name,
@@ -10242,6 +10284,24 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
10242
10284
  stageTargetFile(target.name, import_node_path19.default.join(layout.root, modulemap), moduleContents, {
10243
10285
  allowExisting: true
10244
10286
  });
10287
+ if (modulemap.endsWith("/Modules/module.modulemap")) {
10288
+ const headers = import_node_path19.default.posix.join(
10289
+ import_node_path19.default.posix.dirname(import_node_path19.default.posix.dirname(modulemap)),
10290
+ "Headers"
10291
+ );
10292
+ const mirrored = import_node_path19.default.posix.join(import_node_path19.default.posix.dirname(modulemap), "Headers");
10293
+ for (const [, umbrella] of moduleContents.toString().matchAll(/\bumbrella\s+header\s+"([^"]+)"/g)) {
10294
+ const source = settings.productHeaders[import_node_path19.default.posix.join(headers, umbrella)];
10295
+ const contents = source === void 0 ? void 0 : input.files[source];
10296
+ if (contents !== void 0)
10297
+ stageTargetFile(
10298
+ target.name,
10299
+ import_node_path19.default.join(layout.root, mirrored, umbrella),
10300
+ contents,
10301
+ { allowExisting: true }
10302
+ );
10303
+ }
10304
+ }
10245
10305
  if (nativeC && import_node_path19.default.posix.basename(modulemap) !== "module.modulemap") {
10246
10306
  stageTargetFile(
10247
10307
  target.name,
@@ -10296,7 +10356,8 @@ ${swiftProjectFilesProblems(input.projectFiles).join("\n")}`
10296
10356
  ).digest("hex").slice(0, 12);
10297
10357
  const name2 = `${target.name}${nativeC ? "Native" : "Swift"}Implementation_${identity}`;
10298
10358
  const groupPath = import_node_path19.default.posix.join("PeachNativeSources", name2);
10299
- const sourceIdentity = `-ffile-prefix-map=${import_node_path19.default.join(layout.root, groupPath)}=${import_node_path19.default.join(layout.root, target.path)}`;
10359
+ const identityRoot = nativeToolset ? "/peach/build" : layout.root;
10360
+ const sourceIdentity = `-ffile-prefix-map=${import_node_path19.default.join(identityRoot, groupPath)}=${import_node_path19.default.join(identityRoot, target.path)}`;
10300
10361
  const group = groups.get(identity) ?? {
10301
10362
  name: name2,
10302
10363
  path: groupPath,
@@ -10821,6 +10882,7 @@ module ${moduleName}.Swift {
10821
10882
  import_node_path19.default.join(layout.root, "Package.swift"),
10822
10883
  emitSwiftPackageManifest({
10823
10884
  root: layout.root,
10885
+ files,
10824
10886
  targets: manifestTargets,
10825
10887
  packages,
10826
10888
  native,
@@ -10875,7 +10937,7 @@ module ${moduleName}.Swift {
10875
10937
  if (files.has(destination)) continue;
10876
10938
  files.set(destination, Buffer.from(bytes, "base64"));
10877
10939
  }
10878
- if (input.packageFiles || prebuilt) {
10940
+ if (nativeToolset) {
10879
10941
  files.set(
10880
10942
  import_node_path19.default.join(layout.root, ".peach-target-toolset.json"),
10881
10943
  JSON.stringify({
@@ -10966,6 +11028,10 @@ module ${moduleName}.Swift {
10966
11028
  for (const producer of producers)
10967
11029
  for (const dependency of dependencies.get(producer) ?? []) include(dependency);
10968
11030
  return {
11031
+ nativeBuildTargets: [...native].flatMap(([name2, plan]) => [
11032
+ ...!plan.mixed && plan.sources.length > 0 ? [name2] : [],
11033
+ ...plan.groups?.map((group) => group.name) ?? (plan.late ? [plan.late.name] : [])
11034
+ ]),
10969
11035
  headerProducers: [
10970
11036
  .../* @__PURE__ */ new Set([
10971
11037
  ...Object.keys(nativeHeaderDeclarations),
@@ -10988,7 +11054,7 @@ function outputOf(error) {
10988
11054
  streamText(Reflect.get(error, "stdout")),
10989
11055
  streamText(Reflect.get(error, "stderr"))
10990
11056
  ].filter(Boolean);
10991
- if (error instanceof Error) streams.push(error.message);
11057
+ if (error instanceof Error) streams.unshift(error.message);
10992
11058
  if (streams.length > 0) return streams.join("\n");
10993
11059
  }
10994
11060
  return error instanceof Error ? error.message : String(error);
@@ -11537,7 +11603,17 @@ function retireStaleSwiftLink(root, stamp) {
11537
11603
  (0, import_node_fs17.rmSync)(retired, { recursive: true, force: true });
11538
11604
  return true;
11539
11605
  }
11540
- function compileSwiftProjectUnit(input, options) {
11606
+ async function compileSwiftProjectUnit(input, options) {
11607
+ for (let attempt = 1; ; attempt++) {
11608
+ try {
11609
+ return await compileSwiftProjectOnce(input, options);
11610
+ } catch (error) {
11611
+ if (attempt >= 3 || !outputOf(error).includes("differs from the caller"))
11612
+ throw error;
11613
+ }
11614
+ }
11615
+ }
11616
+ function compileSwiftProjectOnce(input, options) {
11541
11617
  options.signal?.throwIfAborted();
11542
11618
  (0, import_node_fs17.mkdirSync)(options.buildRoot, { recursive: true });
11543
11619
  const root = (0, import_node_fs17.realpathSync)(options.buildRoot);
@@ -11706,6 +11782,7 @@ function compileSwiftProjectUnit(input, options) {
11706
11782
  })
11707
11783
  ))
11708
11784
  report("framework revision changed; rebuilding the app link");
11785
+ const nativeToolset = needsNativeToolset(input, prebuilt);
11709
11786
  const preparation = writeSwiftProject(layout, input, frameworkRoot, prebuilt);
11710
11787
  writeSwiftAutolinkLinker(root, options.toolchainBin);
11711
11788
  const projectProcess = options.project ? prepareSwiftProjectProcess(root, options.project) : void 0;
@@ -11740,7 +11817,7 @@ function compileSwiftProjectUnit(input, options) {
11740
11817
  ...swiftCompileSdkOptions(frameworkRoot, options.toolchainBin),
11741
11818
  "--swift-sdk",
11742
11819
  sdk,
11743
- ...input.packageFiles || prebuilt ? ["--toolset", import_node_path19.default.join(root, ".peach-target-toolset.json")] : [],
11820
+ ...nativeToolset ? ["--toolset", import_node_path19.default.join(root, ".peach-target-toolset.json")] : [],
11744
11821
  "-c",
11745
11822
  "release",
11746
11823
  "-Xswiftc",
@@ -11752,7 +11829,12 @@ function compileSwiftProjectUnit(input, options) {
11752
11829
  [frameworkRoot, "framework"],
11753
11830
  [root, "build"],
11754
11831
  ...forwarders
11755
- ]),
11832
+ ]).flatMap((flag, index, flags) => {
11833
+ if (!nativeToolset || !flag.startsWith("-ffile-prefix-map="))
11834
+ return [flag];
11835
+ const mapped = flag.replaceAll(root, "/peach/build").replaceAll(frameworkRoot, "/peach/framework").replaceAll(import_node_path19.default.dirname(options.toolchainBin), "/peach/toolchain");
11836
+ return flags[index - 1] === "-Xcc" ? [mapped, "-Xswiftc", "-Xcc", "-Xswiftc", flag] : [mapped];
11837
+ }),
11756
11838
  ...macroPlugins.libraries.flatMap((plugin) => [
11757
11839
  "-Xswiftc",
11758
11840
  "-load-plugin-library",
@@ -11805,6 +11887,31 @@ function compileSwiftProjectUnit(input, options) {
11805
11887
  );
11806
11888
  }
11807
11889
  }
11890
+ const checkpoints = import_node_path19.default.join(
11891
+ root,
11892
+ ".build",
11893
+ "peach-native-targets",
11894
+ (0, import_node_crypto8.createHash)("sha256").update((0, import_node_fs17.readFileSync)(import_node_path19.default.join(root, "Package.swift"))).digest("hex")
11895
+ );
11896
+ (0, import_node_fs17.mkdirSync)(checkpoints, { recursive: true });
11897
+ for (const target of /* @__PURE__ */ new Set([
11898
+ ...input.staticClangTargets ?? [],
11899
+ ...preparation.nativeBuildTargets
11900
+ ])) {
11901
+ const checkpoint = import_node_path19.default.join(
11902
+ checkpoints,
11903
+ (0, import_node_crypto8.createHash)("sha256").update(target).digest("hex")
11904
+ );
11905
+ if ((0, import_node_fs17.existsSync)(checkpoint)) continue;
11906
+ await runCompiler(
11907
+ swift,
11908
+ [...buildArgs, "--target", target],
11909
+ appOptions,
11910
+ SWIFTPM_PROGRESS,
11911
+ SWIFTPM_NOISE
11912
+ );
11913
+ (0, import_node_fs17.writeFileSync)(checkpoint, "");
11914
+ }
11808
11915
  await runCompiler(
11809
11916
  swift,
11810
11917
  buildArgs,