peachsim 0.1.1716 → 0.1.1728

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 (234) hide show
  1. package/README.md +21 -3
  2. package/cli/app-bundle-resources.ts +2 -1
  3. package/cli/app-fonts.ts +4 -4
  4. package/cli/app-splash.ts +4 -4
  5. package/cli/app-stubs.ts +17 -0
  6. package/cli/command-registry.ts +1 -0
  7. package/cli/commands/control.ts +82 -822
  8. package/cli/commands/daemon.ts +8 -0
  9. package/cli/commands/detox.ts +3 -0
  10. package/cli/commands/doctor.ts +19 -2
  11. package/cli/commands/inspect/actions.ts +74 -14
  12. package/cli/commands/inspect/core.ts +5 -1
  13. package/cli/commands/inspect/settling.ts +5 -2
  14. package/cli/commands/inspect/wait-ready.ts +6 -0
  15. package/cli/commands/inspect.ts +48 -45
  16. package/cli/commands/kotlin.ts +12 -2
  17. package/cli/commands/package.ts +750 -0
  18. package/cli/commands/serve.ts +6 -0
  19. package/cli/commands/shell-url.ts +834 -0
  20. package/cli/commands/swift.ts +42 -102
  21. package/cli/commands/test.ts +20 -0
  22. package/cli/commands/upload.ts +1 -1
  23. package/cli/device-option.ts +1 -1
  24. package/cli/main.ts +13 -1
  25. package/cli/native-input.ts +199 -0
  26. package/cli/outbound-endpoints.ts +26 -1
  27. package/cli/packaged-app-launcher.ts +95 -0
  28. package/cli/scene-video.ts +13 -6
  29. package/detox/index.ts +187 -23
  30. package/dist-lib/agent-daemon-client.cjs +1 -1
  31. package/dist-lib/agent-events.cjs +1 -1
  32. package/dist-lib/attached-projects.cjs +1 -1
  33. package/dist-lib/auth/shared-session.cjs +1 -1
  34. package/dist-lib/backend-origin.cjs +1 -1
  35. package/dist-lib/beta.cjs +1 -1
  36. package/dist-lib/beta.mjs +1 -1
  37. package/dist-lib/bridge-constants.cjs +1 -1
  38. package/dist-lib/bridge-contract-input.cjs +1 -1
  39. package/dist-lib/bridge-contract-input.mjs +1 -1
  40. package/dist-lib/bridge-contract.cjs +1 -1
  41. package/dist-lib/bridge-contract.mjs +1 -1
  42. package/dist-lib/bundle-channel.cjs +38000 -31658
  43. package/dist-lib/capture-contract.cjs +1 -1
  44. package/dist-lib/capture-contract.mjs +1 -1
  45. package/dist-lib/cloud-contract.cjs +1 -1
  46. package/dist-lib/cloud-contract.mjs +1 -1
  47. package/dist-lib/cloud-test-args.cjs +1 -1
  48. package/dist-lib/cloud-test-args.mjs +1 -1
  49. package/dist-lib/cloud.cjs +1 -1
  50. package/dist-lib/cloud.mjs +1 -1
  51. package/dist-lib/config.cjs +1 -1
  52. package/dist-lib/config.mjs +1 -1
  53. package/dist-lib/detox/index.cjs +184 -60
  54. package/dist-lib/dev-bundle-resolution.cjs +14 -13
  55. package/dist-lib/expo-swift-bundle.cjs +18199 -11834
  56. package/dist-lib/expo-swift-metadata.cjs +4 -1
  57. package/dist-lib/expo-swift-metadata.mjs +3 -1
  58. package/dist-lib/home-paths.cjs +21 -2
  59. package/dist-lib/host/bridge-host.cjs +26509 -23850
  60. package/dist-lib/host/fetch-proxy-handler.cjs +221 -222
  61. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  62. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  63. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  64. package/dist-lib/host/websocket-proxy.cjs +1 -1
  65. package/dist-lib/index.cjs +876 -389
  66. package/dist-lib/jump-to-source-babel.cjs +1 -1
  67. package/dist-lib/jump-to-source-native.cjs +1 -1
  68. package/dist-lib/kotlin-host.cjs +127 -16
  69. package/dist-lib/menu.cjs +7 -1
  70. package/dist-lib/menu.mjs +7 -1
  71. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  72. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  73. package/dist-lib/metro-production-bundle.cjs +1 -1
  74. package/dist-lib/metro-production-bundle.mjs +1 -1
  75. package/dist-lib/metro.cjs +883 -404
  76. package/dist-lib/native-app-identity-project.cjs +694 -280
  77. package/dist-lib/native-app-identity-project.mjs +490 -83
  78. package/dist-lib/native-app-identity.cjs +13 -2
  79. package/dist-lib/native-app-identity.mjs +13 -2
  80. package/dist-lib/native-firebase-metadata.cjs +1 -1
  81. package/dist-lib/native-firebase-metadata.mjs +1 -1
  82. package/dist-lib/plist.cjs +1 -1
  83. package/dist-lib/plist.mjs +1 -1
  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 +28 -23
  87. package/dist-lib/public-origins-lib.json +392 -224
  88. package/dist-lib/react-native-host-modules.cjs +32 -2
  89. package/dist-lib/react-native-host-modules.mjs +32 -2
  90. package/dist-lib/reap-browser.cjs +12 -4
  91. package/dist-lib/scripts/dev-server-scanner.cjs +15 -8
  92. package/dist-lib/sdk.cjs +17 -7
  93. package/dist-lib/sdk.mjs +16 -7
  94. package/dist-lib/skills.cjs +61838 -47851
  95. package/dist-lib/swift-compile.cjs +583 -360
  96. package/dist-lib/swift-compile.mjs +496 -275
  97. package/dist-lib/swift-package.cjs +1 -1
  98. package/dist-lib/swift-package.mjs +1 -1
  99. package/dist-lib/swift-submit.cjs +2 -2
  100. package/dist-lib/swift-submit.mjs +2 -2
  101. package/dist-lib/swift-toolchain.cjs +105 -17
  102. package/dist-lib/swift.cjs +1 -1
  103. package/dist-lib/vite-swift.cjs +4453 -2231
  104. package/dist-lib/vite.cjs +230 -228
  105. package/dist-lib/worklet-executable.cjs +1 -1
  106. package/dist-lib/worklet-executable.mjs +1 -1
  107. package/dist-types/packages/peach-compat/src/stubs/native-seams/react-native-cookies.d.ts +17 -8
  108. package/dist-types/packages/peach-engine/src/engine/canvaskit-renderer.d.ts +1 -0
  109. package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +7 -5
  110. package/dist-types/packages/peach-engine/src/engine/memory-counts.d.ts +3 -1
  111. package/dist-types/packages/peach-engine/src/engine/node.d.ts +1 -11
  112. package/dist-types/packages/peach-engine/src/engine/types.d.ts +3 -0
  113. package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +9 -0
  114. package/dist-types/packages/peach-engine/src/render-worker/host-service-protocol.d.ts +3 -0
  115. package/dist-types/packages/peach-engine/src/render-worker/native-ui-commandContract.d.ts +1 -1
  116. package/dist-types/packages/peach-engine/src/render-worker/shell-protocol.d.ts +4 -0
  117. package/dist-types/packages/peach-engine/src/render-worker/tree-sync-port.d.ts +1 -1
  118. package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +23 -1
  119. package/dist-types/packages/peach-engine/src/shell-events.d.ts +1 -0
  120. package/dist-types/packages/peach-globals/src/audioBridgeContract.d.ts +5 -0
  121. package/dist-types/packages/peach-globals/src/index.d.ts +1 -1
  122. package/dist-types/packages/peach-globals/src/keyboardBridgeContract.d.ts +11 -0
  123. package/dist-types/packages/peach-globals/src/shellBridgeContract.d.ts +1 -0
  124. package/dist-types/packages/peach-globals/src/testBridgeContract.d.ts +9 -2
  125. package/package.json +1 -1
  126. package/runtime-companion.json +1 -1
  127. package/scripts/dev-server-scanner.ts +12 -25
  128. package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/ASFoundation.h +52 -0
  129. package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/ASWebAuthenticationSession.h +128 -0
  130. package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/ASWebAuthenticationSessionCallback.h +35 -0
  131. package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/AuthenticationServices.h +3 -0
  132. package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Modules/module.modulemap +5 -0
  133. package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFHTTPMessage.h +724 -0
  134. package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetwork.h +4 -0
  135. package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetworkDefs.h +27 -0
  136. package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Modules/module.modulemap +5 -0
  137. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFURL.h +1301 -0
  138. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.h +2 -0
  139. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocationManager.h +21 -50
  140. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLRegion.h +6 -6
  141. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h +75 -9
  142. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h +12 -0
  143. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIInterface.h +23 -0
  144. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h +7 -9
  145. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIOrientation.h +14 -0
  146. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIStringDrawing.h +12 -0
  147. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIView.h +14 -0
  148. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIViewAnimating.h +12 -0
  149. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIViewController.h +16 -0
  150. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIWindow.h +2 -0
  151. package/sdk/ios/usr/include/ConditionalMacros.h +619 -0
  152. package/sdk/ios/usr/include/module.modulemap +1 -0
  153. package/sdk/ios/usr/include/objc/objc-sync.h +59 -0
  154. package/sdk/ios/usr/include/os.modulemap +5 -0
  155. package/sdk/ios/usr/include/sys/cdefs.h +5 -0
  156. package/sdk/ios/usr/include/sys/ioccom.h +99 -0
  157. package/sdk/ios/usr/include/sys/syslog.h +236 -0
  158. package/sdk/ios/usr/include/syslog.h +24 -0
  159. package/sdk/ios/wasm/include/fcntl.h +4 -2
  160. package/sdk/ios/wasm/include/stdio.h +24 -0
  161. package/sdk/ios/wasm/include/stdlib.h +32 -7
  162. package/sdk/ios/wasm/include/sys/file.h +7 -0
  163. package/sdk/ios/wasm/include/sys/ioctl.h +6 -0
  164. package/sdk/ios/wasm/include/sys/syscall.h +9 -0
  165. package/sdk/ios/wasm/include/sys/time.h +10 -0
  166. package/sdk/ios/wasm/include/unistd.h +12 -3
  167. package/sdk/native-hashes.json +1 -0
  168. package/skills/contrast/SKILL.md +2 -1
  169. package/skills/peach-test/SKILL.md +7 -3
  170. package/src/admitted-mac-build.ts +3 -0
  171. package/src/android-app-identity.ts +18 -0
  172. package/src/android-root-module.ts +9 -9
  173. package/src/appPackageContract.ts +81 -0
  174. package/src/bridge-contract.ts +50 -0
  175. package/src/bundle-channel.mjs +21 -4
  176. package/src/dev-bundle-resolution.ts +7 -27
  177. package/src/dom-source-reference.ts +15 -0
  178. package/src/expo-discovery-cache.ts +127 -23
  179. package/src/expo-manifest-body.ts +33 -0
  180. package/src/expo-native-workspace.ts +38 -13
  181. package/src/expo-swift-host.ts +264 -62
  182. package/src/expoSwiftContract.ts +3 -0
  183. package/src/generated/swift-c-predefines.json +1 -1
  184. package/src/home-paths.ts +35 -1
  185. package/src/host/app-package-handler.ts +47 -0
  186. package/src/host/bridge-host.ts +3 -0
  187. package/src/host/staged-host-files.ts +18 -0
  188. package/src/index.ts +3 -0
  189. package/src/kotlin-host.ts +21 -18
  190. package/src/kotlin-instance-source.ts +126 -0
  191. package/src/menu.ts +7 -0
  192. package/src/native-app-identity-project.ts +7 -2
  193. package/src/native-app-identity.ts +11 -0
  194. package/src/native-firebase-config.ts +24 -1
  195. package/src/nitro-adapter.lock.json +268 -268
  196. package/src/nitro-bundle.ts +8 -0
  197. package/src/nitro-compile.ts +35 -9
  198. package/src/nitro-dependencies.ts +21 -19
  199. package/src/nitro-source.ts +4 -0
  200. package/src/nitroContract.ts +7 -0
  201. package/src/react-native-bridge-modules.ts +68 -42
  202. package/src/react-native-host-modules.ts +31 -1
  203. package/src/reactNativeConfigurationContract.ts +14 -0
  204. package/src/reap-browser.ts +15 -3
  205. package/src/sdk.ts +5 -0
  206. package/src/settingsContract.ts +27 -1
  207. package/src/sim-client.ts +4 -1
  208. package/src/storageSnapshotContract.ts +3 -0
  209. package/src/swift-compile.ts +221 -41
  210. package/src/swift-coverage/provenance.ts +1 -0
  211. package/src/swift-coverage/xcode-asset-symbols.ts +922 -0
  212. package/src/swift-coverage/xcode-assets.ts +89 -131
  213. package/src/swift-coverage/xcode.ts +1 -1
  214. package/src/swift-cxx-reachable.ts +2 -1
  215. package/src/swift-distribution.lock.json +14 -13
  216. package/src/swift-host.ts +95 -22
  217. package/src/swift-icu.ts +1 -1
  218. package/src/swift-link-roots.ts +118 -0
  219. package/src/swift-objc-compile.ts +144 -22
  220. package/src/swift-objc-import.ts +6 -0
  221. package/src/swift-objc-standin.ts +2 -14
  222. package/src/swift-package-manifest.ts +14 -6
  223. package/src/swift-packages.ts +75 -11
  224. package/src/swift-pdf-raster.ts +1 -0
  225. package/src/swift-root-lock.ts +17 -1
  226. package/src/swift-source-pods.ts +2 -10
  227. package/src/swift-standin-emit.ts +592 -57
  228. package/src/swift-standins.ts +430 -49
  229. package/src/swift-submit.ts +3 -1
  230. package/src/swift-toolchain.ts +140 -17
  231. package/src/turbo-codegen-intake.ts +91 -0
  232. package/src/vite-plugin-one.ts +13 -9
  233. package/src/vite-plugin.ts +28 -15
  234. package/src/xcode-project.ts +223 -22
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.1716 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1728 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
 
3
3
  // src/swift-compile.ts
4
4
  import {
@@ -17,11 +17,12 @@ import {
17
17
  renameSync,
18
18
  rmSync as rmSync3,
19
19
  statSync,
20
+ symlinkSync,
20
21
  utimesSync,
21
22
  writeFileSync as writeFileSync3
22
23
  } from "node:fs";
23
24
  import os2 from "node:os";
24
- import path12 from "node:path";
25
+ import path13 from "node:path";
25
26
 
26
27
  // src/admitted-mac-build.ts
27
28
  import { spawnSync } from "node:child_process";
@@ -30,6 +31,8 @@ function windowAdmission() {
30
31
  encoding: "utf8",
31
32
  stdio: ["ignore", "pipe", "inherit"]
32
33
  });
34
+ if (result.error && "code" in result.error && result.error.code === "ENOENT")
35
+ return null;
33
36
  if (result.error) throw result.error;
34
37
  if (result.status === 1) return null;
35
38
  if (result.status !== 0) throw new Error(`tm window ancestor exited ${result.status}`);
@@ -51,7 +54,7 @@ function admittedMacBuilderSlot(env = process.env) {
51
54
 
52
55
  // src/generated/swift-c-predefines.json
53
56
  var swift_c_predefines_default = {
54
- release: "swift-6.4.0-RELEASE-custom-ecd2ad9d3fe59329",
57
+ release: "swift-6.4.0-RELEASE-custom-0b2d0a9011c88e66",
55
58
  languages: {
56
59
  c: {
57
60
  TARGET_IPHONE_SIMULATOR: "1",
@@ -2109,8 +2112,17 @@ function rnxHomeDir() {
2109
2112
  function cacheDir() {
2110
2113
  return path.join(rnxHomeDir(), "cache");
2111
2114
  }
2115
+ var BUILDERS_ROOT_ENV = "CONTRAST_BUILDERS_ROOT";
2116
+ function buildersRootEnv() {
2117
+ const root = process.env[BUILDERS_ROOT_ENV]?.trim();
2118
+ return root ? root : null;
2119
+ }
2120
+ function swiftCacheDir() {
2121
+ const root = buildersRootEnv();
2122
+ return root ? path.join(root, "peach-cache") : cacheDir();
2123
+ }
2112
2124
  function swiftPackageCacheOptions() {
2113
- const root = path.join(cacheDir(), "swiftpm");
2125
+ const root = path.join(swiftCacheDir(), "swiftpm");
2114
2126
  return ["cache", "config", "security"].flatMap((name2) => [
2115
2127
  `--${name2}-path`,
2116
2128
  path.join(root, name2)
@@ -2810,9 +2822,9 @@ var EXCERPT = /^(\s*)(\d+)( \| )(.*)$/;
2810
2822
  var MARKER = /^(\s*)( \| )(.*)$/;
2811
2823
  function designTimeDiagnostic(output, files) {
2812
2824
  const rewritten = /* @__PURE__ */ new Map();
2813
- const linesOf = (path13) => {
2825
+ const linesOf = (path14) => {
2814
2826
  const file = Object.keys(files).find(
2815
- (name2) => name2.endsWith(".swift") && (path13 === name2 || path13.endsWith(`/${name2}`))
2827
+ (name2) => name2.endsWith(".swift") && (path14 === name2 || path14.endsWith(`/${name2}`))
2816
2828
  );
2817
2829
  if (file === void 0) return null;
2818
2830
  let lines = rewritten.get(file);
@@ -2929,31 +2941,53 @@ function swiftSdkOptions() {
2929
2941
  }
2930
2942
  return [];
2931
2943
  }
2932
- var SWIFT_HOST_COMPILER_RELEASE = "swift-6.4.0-RELEASE-custom-ecd2ad9d3fe59329";
2933
- var SWIFT_HOST_COMPILER_ID = "ecd2ad9d3fe59329";
2944
+ var SWIFT_HOST_COMPILER_RELEASE = "swift-6.4.0-RELEASE-custom-0b2d0a9011c88e66";
2945
+ var SWIFT_HOST_COMPILER_ID = "0b2d0a9011c88e66";
2934
2946
  var compilerArchives = {
2935
- "darwin-arm64": {
2936
- checksum: "ab42a13b34e410ca09737420d1ee1d6af417eec039ab44f9a60502bdb5c76506",
2937
- manifest: "8a93b6b1e6ff577f6dacd81a511d415ca3b396698f9b0c4abc35a4ca807e9d1a"
2938
- },
2939
- "linux-x64": {
2940
- checksum: "b174baa2c578fb32f09c79590d65d03951b04cdec52101b23a46c0b274249fc3",
2941
- manifest: "330e6cbae5890111c22a58e645049a971eff30334c3f240c650fcfedfeab4ef6"
2947
+ "swift-6.4.0-RELEASE-custom-ecd2ad9d3fe59329": {
2948
+ identity: "ecd2ad9d3fe59329",
2949
+ hosts: {
2950
+ "darwin-arm64": {
2951
+ checksum: "ab42a13b34e410ca09737420d1ee1d6af417eec039ab44f9a60502bdb5c76506",
2952
+ manifest: "8a93b6b1e6ff577f6dacd81a511d415ca3b396698f9b0c4abc35a4ca807e9d1a"
2953
+ },
2954
+ "linux-x64": {
2955
+ checksum: "b174baa2c578fb32f09c79590d65d03951b04cdec52101b23a46c0b274249fc3",
2956
+ manifest: "330e6cbae5890111c22a58e645049a971eff30334c3f240c650fcfedfeab4ef6"
2957
+ },
2958
+ "linux-arm64": {
2959
+ checksum: "25f722334dd9d79391cb2e47301165e9ef98dd9a8036927652f3c5db3c56b2ae",
2960
+ manifest: "94e5667febf26f8a4ee8c5456f83f62d17453e503d261a4c46d2b80f872470ab"
2961
+ }
2962
+ }
2942
2963
  },
2943
- "linux-arm64": {
2944
- checksum: "25f722334dd9d79391cb2e47301165e9ef98dd9a8036927652f3c5db3c56b2ae",
2945
- manifest: "94e5667febf26f8a4ee8c5456f83f62d17453e503d261a4c46d2b80f872470ab"
2964
+ [SWIFT_HOST_COMPILER_RELEASE]: {
2965
+ identity: SWIFT_HOST_COMPILER_ID,
2966
+ hosts: {
2967
+ "darwin-arm64": {
2968
+ checksum: "dc6a494227297ea657e8e5f7c5b4a861cb5e142bdbcfcb028ace2aeb19db90cc",
2969
+ manifest: "d8e9eee0fb9b847f1e9350525d6c68606df46101745f553332309ed026b3c26a"
2970
+ },
2971
+ "linux-x64": {
2972
+ checksum: "85c04b4496aea1657c21a47f448e01d6ccc1c7920d130a566db37fb8350a7be2",
2973
+ manifest: "8451659e74235ad53b700c1afbe293512197900eb98cb1f79e36df2f5c85d511"
2974
+ },
2975
+ "linux-arm64": {
2976
+ checksum: "196606ed62c5c926d18e6ef0769cb1ab21c9943f9084070ddf14a7bc696768b8",
2977
+ manifest: "85fb8d5b6527bd75003a6dbd25b68b22540665cf9df9b13f41f82e5d8acdbf1d"
2978
+ }
2979
+ }
2946
2980
  }
2947
2981
  };
2948
2982
  function swiftHostCompilerArchive(release, host2 = `${process.platform}-${process.arch}`) {
2949
- if (release !== SWIFT_HOST_COMPILER_RELEASE)
2950
- throw new Error(`unqualified host compiler ${release}`);
2951
- const archive = compilerArchives[host2];
2983
+ const compiler = compilerArchives[release];
2984
+ if (!compiler) throw new Error(`unqualified host compiler ${release}`);
2985
+ const archive = compiler.hosts[host2];
2952
2986
  if (!archive) throw new Error(`unsupported Swift compiler host ${host2}`);
2953
2987
  return {
2954
2988
  ...archive,
2955
- identity: SWIFT_HOST_COMPILER_ID,
2956
- url: `https://r2.sootsim.com/swift-host-compiler/${SWIFT_HOST_COMPILER_ID}/${release}-${host2}.tar.gz`
2989
+ identity: compiler.identity,
2990
+ url: `https://r2.sootsim.com/swift-host-compiler/${compiler.identity}/${release}-${host2}.tar.gz`
2957
2991
  };
2958
2992
  }
2959
2993
  function swiftUpstreamRelease(release) {
@@ -3316,7 +3350,7 @@ function archiveMember(archive, name2) {
3316
3350
  }
3317
3351
  function icuSegment(object) {
3318
3352
  let at = 8;
3319
- const leb = () => {
3353
+ const leb2 = () => {
3320
3354
  let result = 0;
3321
3355
  let shift = 0;
3322
3356
  let byte;
@@ -3330,15 +3364,15 @@ function icuSegment(object) {
3330
3364
  const found = [];
3331
3365
  while (at < object.length) {
3332
3366
  const id = object[at++];
3333
- const size = leb();
3367
+ const size = leb2();
3334
3368
  const end = at + size;
3335
3369
  if (id === 11) {
3336
- for (let count = leb(); count > 0; count--) {
3337
- if (leb() !== 0) throw new Error("swift-icu: unexpected data segment kind");
3370
+ for (let count = leb2(); count > 0; count--) {
3371
+ if (leb2() !== 0) throw new Error("swift-icu: unexpected data segment kind");
3338
3372
  at++;
3339
- leb();
3373
+ leb2();
3340
3374
  at++;
3341
- const length = leb();
3375
+ const length = leb2();
3342
3376
  const bytes = object.subarray(at, at + length);
3343
3377
  if (bytes[2] === 218 && bytes[3] === 39) found.push(bytes);
3344
3378
  at += length;
@@ -3351,6 +3385,100 @@ function icuSegment(object) {
3351
3385
  return found[0];
3352
3386
  }
3353
3387
 
3388
+ // src/swift-link-roots.ts
3389
+ import fs3 from "node:fs";
3390
+ import path6 from "node:path";
3391
+ var OBJC_SEGMENTS = [
3392
+ "__objc_classes",
3393
+ "__objc_protocols",
3394
+ "__objc_cats",
3395
+ "__objc_class_aliases"
3396
+ ];
3397
+ var leb = (bytes, at) => {
3398
+ let value = 0;
3399
+ let scale = 1;
3400
+ for (; ; ) {
3401
+ const byte = bytes[at.offset++];
3402
+ value += (byte & 127) * scale;
3403
+ if (!(byte & 128)) return value;
3404
+ scale *= 128;
3405
+ }
3406
+ };
3407
+ function objcSegmentSizes(bytes) {
3408
+ const at = { offset: 8 };
3409
+ const names = [];
3410
+ const sizes = [];
3411
+ while (at.offset < bytes.length) {
3412
+ const id = bytes[at.offset++];
3413
+ const size = leb(bytes, at);
3414
+ const end = at.offset + size;
3415
+ if (id === 0) {
3416
+ const length = leb(bytes, at);
3417
+ const name2 = Buffer.from(bytes.subarray(at.offset, at.offset + length)).toString();
3418
+ at.offset += length;
3419
+ if (name2 === "linking") {
3420
+ leb(bytes, at);
3421
+ while (at.offset < end) {
3422
+ const kind = bytes[at.offset++];
3423
+ const length2 = leb(bytes, at);
3424
+ const next = at.offset + length2;
3425
+ if (kind === 5) {
3426
+ for (let count = leb(bytes, at); count > 0; count--) {
3427
+ const nameLength = leb(bytes, at);
3428
+ names.push(
3429
+ Buffer.from(bytes.subarray(at.offset, at.offset + nameLength)).toString()
3430
+ );
3431
+ at.offset += nameLength;
3432
+ leb(bytes, at);
3433
+ leb(bytes, at);
3434
+ }
3435
+ }
3436
+ at.offset = next;
3437
+ }
3438
+ }
3439
+ } else if (id === 11) {
3440
+ for (let count = leb(bytes, at); count > 0; count--) {
3441
+ const flags = leb(bytes, at);
3442
+ if (flags === 2) leb(bytes, at);
3443
+ if (flags !== 1) {
3444
+ at.offset++;
3445
+ leb(bytes, at);
3446
+ at.offset++;
3447
+ }
3448
+ const length = leb(bytes, at);
3449
+ sizes.push(length);
3450
+ at.offset += length;
3451
+ }
3452
+ }
3453
+ at.offset = end;
3454
+ }
3455
+ const result = /* @__PURE__ */ new Map();
3456
+ names.forEach((name2, index) => {
3457
+ if (OBJC_SEGMENTS.includes(name2))
3458
+ result.set(name2, (result.get(name2) ?? 0) + (sizes[index] ?? 0));
3459
+ });
3460
+ return result;
3461
+ }
3462
+ var rootsByDistribution = /* @__PURE__ */ new Map();
3463
+ function swiftObjcRootObjects(id, root, objects) {
3464
+ const cached = rootsByDistribution.get(id);
3465
+ if (cached) return cached;
3466
+ const measured = objects.map(
3467
+ (object) => [object, objcSegmentSizes(fs3.readFileSync(path6.join(root, object)))]
3468
+ );
3469
+ const empty = /* @__PURE__ */ new Map();
3470
+ for (const [, sizes] of measured)
3471
+ for (const [name2, size] of sizes)
3472
+ empty.set(name2, Math.min(empty.get(name2) ?? size, size));
3473
+ const roots = new Set(
3474
+ measured.filter(
3475
+ ([, sizes]) => [...sizes].some(([name2, size]) => size > (empty.get(name2) ?? 0))
3476
+ ).map(([object]) => object)
3477
+ );
3478
+ rootsByDistribution.set(id, roots);
3479
+ return roots;
3480
+ }
3481
+
3354
3482
  // src/swift-objc-import.ts
3355
3483
  var SWIFT_OBJC_INTEROP_FLAGS = [
3356
3484
  "-Xfrontend",
@@ -3362,6 +3490,9 @@ var SWIFT_OBJC_INTEROP_FLAGS = [
3362
3490
  "-Xcc",
3363
3491
  "-fblocks"
3364
3492
  ];
3493
+ function swiftClangImporterFlags(flags) {
3494
+ return flags.filter((flag) => flag !== "-fobjc-arc" && flag !== "-fno-objc-arc");
3495
+ }
3365
3496
  function swiftObjCModuleMap(module, headers) {
3366
3497
  return [
3367
3498
  `module ${module} {`,
@@ -3383,12 +3514,12 @@ var swiftObjCRuntimeFlags = [
3383
3514
  // src/swift-objc-standin.ts
3384
3515
  import { execFileSync as execFileSync2, spawnSync as spawnSync4 } from "node:child_process";
3385
3516
  import { createHash as createHash4 } from "node:crypto";
3386
- import fs3 from "node:fs";
3387
- import path8 from "node:path";
3517
+ import fs4 from "node:fs";
3518
+ import path9 from "node:path";
3388
3519
 
3389
3520
  // src/swift-objc-platform.ts
3390
3521
  import { spawnSync as spawnSync3 } from "node:child_process";
3391
- import path6 from "node:path";
3522
+ import path7 from "node:path";
3392
3523
  var platforms = /* @__PURE__ */ new Map();
3393
3524
  function swiftObjCPlatformFlags(toolchainBin, minimum) {
3394
3525
  const key = `${toolchainBin}:${minimum}`;
@@ -3400,7 +3531,7 @@ function swiftObjCPlatformFlags(toolchainBin, minimum) {
3400
3531
  minimum % 100
3401
3532
  ].join(".");
3402
3533
  const result = spawnSync3(
3403
- path6.join(toolchainBin, "clang"),
3534
+ path7.join(toolchainBin, "clang"),
3404
3535
  [
3405
3536
  "-target",
3406
3537
  `arm64-apple-ios${version}-simulator`,
@@ -3434,10 +3565,10 @@ function swiftObjCPlatformFlags(toolchainBin, minimum) {
3434
3565
  }
3435
3566
 
3436
3567
  // src/swift-objc-sdk.ts
3437
- import path7 from "node:path";
3568
+ import path8 from "node:path";
3438
3569
  var IOS_SDK_TARGET = "arm64-apple-ios16.0-simulator";
3439
3570
  var OVERLAY_PATH = /^usr\/lib\/swift\/([^/]+)\.swiftmodule\/arm64-apple-ios-simulator\.swiftinterface$/;
3440
- var tree = typeof __PEACH_BUNDLED_IOS_SDK__ === "undefined" ? readIosSdkTree(path7.join(peachsimPackageRoot(), "sdk", "ios")) : Object.entries(__PEACH_BUNDLED_IOS_SDK__).sort(([a], [b]) => a < b ? -1 : 1);
3571
+ var tree = typeof __PEACH_BUNDLED_IOS_SDK__ === "undefined" ? readIosSdkTree(path8.join(peachsimPackageRoot(), "sdk", "ios")) : Object.entries(__PEACH_BUNDLED_IOS_SDK__).sort(([a], [b]) => a < b ? -1 : 1);
3441
3572
  var IOS_SDK_HEADERS = {};
3442
3573
  var IOS_SDK_OVERLAYS = {};
3443
3574
  for (const [file, text2] of tree) {
@@ -3941,13 +4072,7 @@ function iosSdkEntries() {
3941
4072
  ${text2}`
3942
4073
  ]
3943
4074
  );
3944
- const osMap = IOS_SDK_HEADERS["usr/include/os.modulemap"];
3945
- if (osMap === void 0)
3946
- throw new Error("sdk intake has no usr/include/os.modulemap for clang-import");
3947
- const clangImport = [
3948
- ["clang-import/module.modulemap", osMap]
3949
- ];
3950
- return [...Object.entries(IOS_SDK_HEADERS), ...overlays, ...clangImport].sort(
4075
+ return [...Object.entries(IOS_SDK_HEADERS), ...overlays].sort(
3951
4076
  ([a], [b]) => a < b ? -1 : 1
3952
4077
  );
3953
4078
  }
@@ -3970,11 +4095,11 @@ function objcSdkIntakeFlags(headers, toolchainBin, minimum) {
3970
4095
  "-DU_DISABLE_RENAMING=0",
3971
4096
  ...WASI_EMULATION_FLAGS,
3972
4097
  "-iframework",
3973
- path8.join(headers, "System/Library/Frameworks"),
4098
+ path9.join(headers, "System/Library/Frameworks"),
3974
4099
  "-isystem",
3975
- path8.join(headers, "wasm/include"),
4100
+ path9.join(headers, "wasm/include"),
3976
4101
  "-idirafter",
3977
- path8.join(headers, "usr/include")
4102
+ path9.join(headers, "usr/include")
3978
4103
  ];
3979
4104
  }
3980
4105
  function iosDeploymentMinimum(version) {
@@ -3997,7 +4122,7 @@ import {
3997
4122
  rmSync as rmSync2,
3998
4123
  writeFileSync as writeFileSync2
3999
4124
  } from "node:fs";
4000
- import path9 from "node:path";
4125
+ import path10 from "node:path";
4001
4126
  var POLL_MS = 250;
4002
4127
  var START_TOLERANCE_MS = 2e3;
4003
4128
  function errorCode(error) {
@@ -4072,7 +4197,7 @@ function generationNumbers(directory) {
4072
4197
  function readGeneration(directory, number) {
4073
4198
  let owner;
4074
4199
  try {
4075
- owner = readFileSync5(path9.join(directory, name(number, "owner")), "utf8");
4200
+ owner = readFileSync5(path10.join(directory, name(number, "owner")), "utf8");
4076
4201
  } catch (error) {
4077
4202
  if (errorCode(error) === "ENOENT") return null;
4078
4203
  throw error;
@@ -4085,15 +4210,15 @@ function readGeneration(directory, number) {
4085
4210
  }
4086
4211
  function readChildren(directory, number) {
4087
4212
  const prefix = name(number, "child.");
4088
- return readdirSync3(directory).filter((entry) => entry.startsWith(prefix)).map((entry) => parseIdentity(readFileSync5(path9.join(directory, entry), "utf8")));
4213
+ return readdirSync3(directory).filter((entry) => entry.startsWith(prefix)).map((entry) => parseIdentity(readFileSync5(path10.join(directory, entry), "utf8")));
4089
4214
  }
4090
4215
  function groupAlive(table, leader) {
4091
4216
  const row = table.find((candidate) => candidate.pid === leader.pid);
4092
4217
  if (row && !sameProcess(row, leader)) return false;
4093
4218
  return table.some((candidate) => candidate.pgid === leader.pid && !candidate.zombie);
4094
4219
  }
4095
- async function withSwiftRootLock(root, work, signal) {
4096
- const directory = path9.join(
4220
+ async function withSwiftRootLock(root, work, signal, wait = true) {
4221
+ const directory = path10.join(
4097
4222
  rnxHomeDir(),
4098
4223
  "cache",
4099
4224
  "swift-root-locks",
@@ -4102,7 +4227,7 @@ async function withSwiftRootLock(root, work, signal) {
4102
4227
  mkdirSync(directory, { recursive: true });
4103
4228
  const token = randomUUID2();
4104
4229
  const owner = JSON.stringify(ownIdentity(process.pid));
4105
- const pending = path9.join(directory, `pending.${token}`);
4230
+ const pending = path10.join(directory, `pending.${token}`);
4106
4231
  let held = 0;
4107
4232
  for (; ; ) {
4108
4233
  signal?.throwIfAborted();
@@ -4112,18 +4237,20 @@ async function withSwiftRootLock(root, work, signal) {
4112
4237
  if (current && !current.released) {
4113
4238
  const table = processTable();
4114
4239
  if (table.some((row) => !row.zombie && sameProcess(row, current.holder))) {
4240
+ if (!wait) return void 0;
4115
4241
  await pause(POLL_MS, signal);
4116
4242
  continue;
4117
4243
  }
4118
4244
  const children2 = readChildren(directory, newest);
4119
4245
  if (children2.some((child) => groupAlive(table, child))) {
4246
+ if (!wait) return void 0;
4120
4247
  await pause(POLL_MS, signal);
4121
4248
  continue;
4122
4249
  }
4123
4250
  }
4124
4251
  writeFileSync2(pending, owner);
4125
4252
  try {
4126
- linkSync(pending, path9.join(directory, name(newest + 1, "owner")));
4253
+ linkSync(pending, path10.join(directory, name(newest + 1, "owner")));
4127
4254
  } catch (error) {
4128
4255
  if (errorCode(error) === "EEXIST") continue;
4129
4256
  throw error;
@@ -4132,7 +4259,7 @@ async function withSwiftRootLock(root, work, signal) {
4132
4259
  }
4133
4260
  const numbers = generationNumbers(directory);
4134
4261
  if (numbers.at(-1) !== newest + 1) {
4135
- rmSync2(path9.join(directory, name(newest + 1, "owner")), { force: true });
4262
+ rmSync2(path10.join(directory, name(newest + 1, "owner")), { force: true });
4136
4263
  continue;
4137
4264
  }
4138
4265
  held = newest + 1;
@@ -4140,7 +4267,7 @@ async function withSwiftRootLock(root, work, signal) {
4140
4267
  if (number < held) {
4141
4268
  for (const entry of readdirSync3(directory))
4142
4269
  if (entry.startsWith(name(number, "")))
4143
- rmSync2(path9.join(directory, entry), { force: true });
4270
+ rmSync2(path10.join(directory, entry), { force: true });
4144
4271
  }
4145
4272
  break;
4146
4273
  }
@@ -4164,7 +4291,7 @@ async function withSwiftRootLock(root, work, signal) {
4164
4291
  const childPending = `${pending}.child.${child.pid}`;
4165
4292
  try {
4166
4293
  writeFileSync2(childPending, JSON.stringify(ownIdentity(child.pid)));
4167
- linkSync(childPending, path9.join(directory, name(held, `child.${child.pid}`)));
4294
+ linkSync(childPending, path10.join(directory, name(held, `child.${child.pid}`)));
4168
4295
  } finally {
4169
4296
  rmSync2(childPending, { force: true });
4170
4297
  }
@@ -4180,19 +4307,19 @@ async function withSwiftRootLock(root, work, signal) {
4180
4307
  return await work(lease);
4181
4308
  } finally {
4182
4309
  await Promise.all(children.map((child) => terminateProcessGroup(child, "SIGKILL", 0)));
4183
- writeFileSync2(path9.join(directory, name(held, "released")), "");
4310
+ writeFileSync2(path10.join(directory, name(held, "released")), "");
4184
4311
  }
4185
4312
  }
4186
4313
 
4187
4314
  // src/swift-shared-sdk.ts
4188
4315
  import { readdirSync as readdirSync4, readFileSync as readFileSync6 } from "node:fs";
4189
- import path10 from "node:path";
4316
+ import path11 from "node:path";
4190
4317
  function swiftSharedSdkRoot(moduleRoot, distribution) {
4191
- return path10.resolve(moduleRoot, distribution ? "sdk/ios" : "../peachsim/sdk/ios");
4318
+ return path11.resolve(moduleRoot, distribution ? "sdk/ios" : "../peachsim/sdk/ios");
4192
4319
  }
4193
4320
  function swiftSharedSdkInputFiles(moduleRoot) {
4194
4321
  const root = swiftSharedSdkRoot(moduleRoot, false);
4195
- return readdirSync4(root, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) => path10.relative(moduleRoot, path10.join(entry.parentPath, entry.name))).sort();
4322
+ return readdirSync4(root, { recursive: true, withFileTypes: true }).filter((entry) => entry.isFile()).map((entry) => path11.relative(moduleRoot, path11.join(entry.parentPath, entry.name))).sort();
4196
4323
  }
4197
4324
 
4198
4325
  // src/swiftContract.ts
@@ -4298,8 +4425,8 @@ function isSwiftResourceBundles(value) {
4298
4425
  }
4299
4426
 
4300
4427
  // src/xcode-header-search.ts
4301
- import fs4 from "node:fs";
4302
- import path11 from "node:path";
4428
+ import fs5 from "node:fs";
4429
+ import path12 from "node:path";
4303
4430
  function headerMap(entries) {
4304
4431
  const unique = /* @__PURE__ */ new Map();
4305
4432
  for (const entry of entries)
@@ -4342,16 +4469,16 @@ function headerMap(entries) {
4342
4469
  return Buffer.concat([table, ...strings]);
4343
4470
  }
4344
4471
  function writeXcodeHeaderSearch(directory, targets) {
4345
- fs4.mkdirSync(directory, { recursive: true });
4472
+ fs5.mkdirSync(directory, { recursive: true });
4346
4473
  const productDirectories = /* @__PURE__ */ new Map();
4347
4474
  for (const target of targets)
4348
4475
  for (const [product, file] of Object.entries(target.productHeaders)) {
4349
- const listed = productDirectories.get(path11.dirname(product)) ?? [];
4350
- productDirectories.set(path11.dirname(product), listed);
4351
- listed.push({ name: path11.basename(product), file });
4476
+ const listed = productDirectories.get(path12.dirname(product)) ?? [];
4477
+ productDirectories.set(path12.dirname(product), listed);
4478
+ listed.push({ name: path12.basename(product), file });
4352
4479
  }
4353
- const overlay = path11.join(directory, "all-product-headers.yaml");
4354
- fs4.writeFileSync(
4480
+ const overlay = path12.join(directory, "all-product-headers.yaml");
4481
+ fs5.writeFileSync(
4355
4482
  overlay,
4356
4483
  JSON.stringify({
4357
4484
  "case-sensitive": "false",
@@ -4370,8 +4497,8 @@ function writeXcodeHeaderSearch(directory, targets) {
4370
4497
  const files = [overlay];
4371
4498
  const flags = targets.map((target, index) => {
4372
4499
  const maps = target.headerMaps.map((map, order) => {
4373
- const file = path11.join(directory, `${index}-${order}.hmap`);
4374
- fs4.writeFileSync(file, headerMap(map.entries));
4500
+ const file = path12.join(directory, `${index}-${order}.hmap`);
4501
+ fs5.writeFileSync(file, headerMap(map.entries));
4375
4502
  files.push(file);
4376
4503
  return { flag: map.flag, file };
4377
4504
  });
@@ -4487,7 +4614,7 @@ function swiftBuilderHopTimeoutMs(compileTimeoutMs) {
4487
4614
  return (compileTimeoutMs ?? SWIFT_BUILDER_DEFAULT_COMPILE_MS) + SWIFT_BUILDER_TRANSPORT_MARGIN_MS;
4488
4615
  }
4489
4616
  function swiftDistributionAt(root) {
4490
- const file = path12.join(root, SWIFT_DISTRIBUTION_MANIFEST);
4617
+ const file = path13.join(root, SWIFT_DISTRIBUTION_MANIFEST);
4491
4618
  if (!existsSync2(file)) return null;
4492
4619
  return parseSwiftDistributionManifest(JSON.parse(readFileSync7(file, "utf8")));
4493
4620
  }
@@ -4505,6 +4632,7 @@ function swiftModuleInputFiles(root) {
4505
4632
  ...swiftSharedSdkInputFiles(root),
4506
4633
  "../peachsim/src/swift-shared-sdk.ts",
4507
4634
  "../../scripts/generate/swift-sdk-module/darwin-mach.json",
4635
+ "../../scripts/ops/swift-distribution-publish.ts",
4508
4636
  "Package.swift",
4509
4637
  "scripts/contrast-app-Package.swift",
4510
4638
  "scripts/build-distribution.ts",
@@ -4519,7 +4647,7 @@ function swiftModuleInputFiles(root) {
4519
4647
  "toolchain.json"
4520
4648
  ];
4521
4649
  const walk = (dir) => {
4522
- for (const entry of readdirSync5(path12.join(root, dir), {
4650
+ for (const entry of readdirSync5(path13.join(root, dir), {
4523
4651
  withFileTypes: true
4524
4652
  })) {
4525
4653
  const relative = `${dir}/${entry.name}`;
@@ -4537,35 +4665,35 @@ function swiftMacroPlugins(moduleRoot) {
4537
4665
  const distribution = swiftDistributionAt(moduleRoot);
4538
4666
  if (distribution)
4539
4667
  return {
4540
- libraries: distribution.plugins.filter((plugin) => path12.basename(plugin) !== "ExpoModulesMacros").map((plugin) => path12.join(moduleRoot, plugin)),
4541
- executables: distribution.plugins.filter((plugin) => path12.basename(plugin) === "ExpoModulesMacros").map((plugin) => path12.join(moduleRoot, plugin)),
4668
+ libraries: distribution.plugins.filter((plugin) => path13.basename(plugin) !== "ExpoModulesMacros").map((plugin) => path13.join(moduleRoot, plugin)),
4669
+ executables: distribution.plugins.filter((plugin) => path13.basename(plugin) === "ExpoModulesMacros").map((plugin) => path13.join(moduleRoot, plugin)),
4542
4670
  stale: false
4543
4671
  };
4544
- const dir = path12.join(moduleRoot, ".build/host/RnxPreviewMacros");
4672
+ const dir = path13.join(moduleRoot, ".build/host/RnxPreviewMacros");
4545
4673
  const release = JSON.parse(
4546
- readFileSync7(path12.join(moduleRoot, "toolchain.json"), "utf8")
4674
+ readFileSync7(path13.join(moduleRoot, "toolchain.json"), "utf8")
4547
4675
  ).release;
4548
- const compilerStamp = path12.join(dir, "compiler-release");
4549
- const pluginScript = path12.join(moduleRoot, "scripts/build-preview-plugin.sh");
4550
- const expoPlugin = path12.join(dir, "ExpoModulesMacros");
4676
+ const compilerStamp = path13.join(dir, "compiler-release");
4677
+ const pluginScript = path13.join(moduleRoot, "scripts/build-preview-plugin.sh");
4678
+ const expoPlugin = path13.join(dir, "ExpoModulesMacros");
4551
4679
  const ext = process.platform === "darwin" ? "dylib" : "so";
4552
4680
  const plugins = [
4553
4681
  {
4554
- library: path12.join(dir, `libRnxPreviewMacros.${ext}`),
4555
- sources: [path12.join(moduleRoot, "Sources/RnxPreviewMacros/PreviewMacro.swift")]
4682
+ library: path13.join(dir, `libRnxPreviewMacros.${ext}`),
4683
+ sources: [path13.join(moduleRoot, "Sources/RnxPreviewMacros/PreviewMacro.swift")]
4556
4684
  },
4557
4685
  {
4558
- library: path12.join(dir, `libFoundationMacros.${ext}`),
4686
+ library: path13.join(dir, `libFoundationMacros.${ext}`),
4559
4687
  sources: [
4560
- path12.join(moduleRoot, "Sources/FoundationMacros/PredicateMacro.swift"),
4561
- path12.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
4688
+ path13.join(moduleRoot, "Sources/FoundationMacros/PredicateMacro.swift"),
4689
+ path13.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
4562
4690
  ]
4563
4691
  },
4564
4692
  {
4565
- library: path12.join(dir, `libTipKitMacros.${ext}`),
4693
+ library: path13.join(dir, `libTipKitMacros.${ext}`),
4566
4694
  sources: [
4567
- path12.join(moduleRoot, "Sources/TipKitMacros/TipKitMacros.swift"),
4568
- path12.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
4695
+ path13.join(moduleRoot, "Sources/TipKitMacros/TipKitMacros.swift"),
4696
+ path13.join(moduleRoot, "Sources/SwiftMacroSupport/PredicateExpression.swift")
4569
4697
  ]
4570
4698
  }
4571
4699
  ];
@@ -4583,14 +4711,14 @@ async function ensureMacroPlugins(moduleRoot, toolchainBin, release, signal) {
4583
4711
  await runCompiler(
4584
4712
  "sh",
4585
4713
  [
4586
- path12.join(moduleRoot, "scripts/build-preview-plugin.sh"),
4714
+ path13.join(moduleRoot, "scripts/build-preview-plugin.sh"),
4587
4715
  toolchainBin,
4588
4716
  libraries[0]
4589
4717
  ],
4590
4718
  { signal }
4591
4719
  );
4592
4720
  writeFileSync3(
4593
- path12.join(path12.dirname(libraries[0]), "compiler-release"),
4721
+ path13.join(path13.dirname(libraries[0]), "compiler-release"),
4594
4722
  `${release}
4595
4723
  `
4596
4724
  );
@@ -4606,7 +4734,7 @@ function swiftModuleDigest(root) {
4606
4734
  const files = swiftModuleInputFiles(root);
4607
4735
  const stampHash = createHash6("sha256");
4608
4736
  for (const file of files) {
4609
- const stat = statSync(path12.join(root, file), { bigint: true });
4737
+ const stat = statSync(path13.join(root, file), { bigint: true });
4610
4738
  stampHash.update(file);
4611
4739
  stampHash.update(
4612
4740
  `${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}
@@ -4620,7 +4748,7 @@ function swiftModuleDigest(root) {
4620
4748
  for (const file of files) {
4621
4749
  hash.update(createHash6("sha256").update(file).digest());
4622
4750
  hash.update(
4623
- createHash6("sha256").update(readFileSync7(path12.join(root, file))).digest()
4751
+ createHash6("sha256").update(readFileSync7(path13.join(root, file))).digest()
4624
4752
  );
4625
4753
  }
4626
4754
  const digest = hash.digest();
@@ -4644,7 +4772,7 @@ function withNativeSourceGlue(input, glue) {
4644
4772
  ...input,
4645
4773
  files: {
4646
4774
  ...input.files,
4647
- [path12.posix.join(targetPath, "OneNativeSource.generated.swift")]: glue
4775
+ [path13.posix.join(targetPath, "OneNativeSource.generated.swift")]: glue
4648
4776
  },
4649
4777
  oneModule: true
4650
4778
  };
@@ -4785,7 +4913,7 @@ function swiftImportNames(contents, available) {
4785
4913
  function swiftPeachModules(moduleRoot) {
4786
4914
  const distribution = swiftDistributionAt(moduleRoot);
4787
4915
  return distribution ? distribution.modules : swiftManifestDeclarations(
4788
- readFileSync7(path12.join(moduleRoot, "Package.swift"), "utf8")
4916
+ readFileSync7(path13.join(moduleRoot, "Package.swift"), "utf8")
4789
4917
  ).filter((target) => !target.executable && !target.path.startsWith("fixtures/")).map((target) => target.name);
4790
4918
  }
4791
4919
  var sdkPaths = /* @__PURE__ */ new Map();
@@ -4795,7 +4923,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
4795
4923
  const cached = sdkPaths.get(key);
4796
4924
  if (cached) return cached;
4797
4925
  const configuration = execFileSync3(
4798
- path12.join(toolchainBin, "swift"),
4926
+ path13.join(toolchainBin, "swift"),
4799
4927
  [
4800
4928
  "sdk",
4801
4929
  "configure",
@@ -4836,7 +4964,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
4836
4964
  if (flag !== "-fwasm-exceptions") cFlags.push(flag);
4837
4965
  if (flag === "-iframeworkwithsysroot" && options[index + 2] === "-Xcc" && typeof options[index + 3] === "string") {
4838
4966
  cFlags.push(options[index + 3]);
4839
- frameworks.push(path12.join(sysroot, options[index + 3]));
4967
+ frameworks.push(path13.join(sysroot, options[index + 3]));
4840
4968
  index += 3;
4841
4969
  continue;
4842
4970
  }
@@ -4853,7 +4981,7 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
4853
4981
  }
4854
4982
  const paths = {
4855
4983
  sysroot,
4856
- darwin: path12.join(sysroot, "darwin"),
4984
+ darwin: path13.join(sysroot, "darwin"),
4857
4985
  resources: field("swiftResourcesPath"),
4858
4986
  frameworks,
4859
4987
  cFlags
@@ -4869,19 +4997,19 @@ function swiftAvailableModules(moduleRoot, toolchainBin) {
4869
4997
  if (cached) return cached;
4870
4998
  const modules = new Set(swiftPeachModules(moduleRoot));
4871
4999
  const { resources, frameworks } = swiftSdkPaths(moduleRoot, toolchainBin);
4872
- for (const entry of readdirSync5(path12.join(resources, "wasi"))) {
5000
+ for (const entry of readdirSync5(path13.join(resources, "wasi"))) {
4873
5001
  if (entry.endsWith(".swiftmodule"))
4874
5002
  modules.add(entry.slice(0, -".swiftmodule".length));
4875
5003
  }
4876
5004
  for (const entry of readdirSync5(resources)) {
4877
- const map = path12.join(resources, entry, "module.modulemap");
5005
+ const map = path13.join(resources, entry, "module.modulemap");
4878
5006
  if (!existsSync2(map)) continue;
4879
5007
  for (const match of readFileSync7(map, "utf8").matchAll(/^module\s+([A-Za-z_]\w*)/gm))
4880
5008
  modules.add(match[1]);
4881
5009
  }
4882
5010
  for (const directory of frameworks) {
4883
5011
  for (const entry of readdirSync5(directory)) {
4884
- const map = path12.join(directory, entry, "Modules/module.modulemap");
5012
+ const map = path13.join(directory, entry, "Modules/module.modulemap");
4885
5013
  if (!existsSync2(map)) continue;
4886
5014
  for (const match of readFileSync7(map, "utf8").matchAll(
4887
5015
  /^framework\s+module\s+([A-Za-z_]\w*)/gm
@@ -4905,6 +5033,52 @@ function missingSwiftModules(files, available, providedByFile = () => []) {
4905
5033
  }
4906
5034
  return new Map([...missing].sort(([left], [right]) => left.localeCompare(right)));
4907
5035
  }
5036
+ function swiftSystemLibrarySurface(files, targets) {
5037
+ const modules = /* @__PURE__ */ new Set();
5038
+ const headers = /* @__PURE__ */ new Set();
5039
+ for (const target of targets) {
5040
+ if (!target.systemLibrary) continue;
5041
+ const prefix = target.path === "." ? "" : `${target.path.replace(/\/+$/, "")}/`;
5042
+ for (const [file, contents] of Object.entries(files)) {
5043
+ if (!file.startsWith(prefix) || !file.endsWith(".modulemap")) continue;
5044
+ for (const match of contents.matchAll(/^\s*module\s+([A-Za-z_]\w*)/gm))
5045
+ modules.add(match[1]);
5046
+ for (const match of contents.matchAll(/^\s*(?:umbrella\s+)?header\s+"([^"]+)"/gm)) {
5047
+ const header = files[`${prefix}${match[1]}`];
5048
+ if (header === void 0) continue;
5049
+ for (const include of header.matchAll(/#\s*(?:include|import)\s*<([^>/]+)>/g))
5050
+ headers.add(include[1].replace(/\.h$/, ""));
5051
+ }
5052
+ }
5053
+ }
5054
+ return { modules, headers };
5055
+ }
5056
+ function swiftSystemLibraryExclusions(files, targets, distributionModules) {
5057
+ const surface = swiftSystemLibrarySurface(files, targets);
5058
+ return new Set(
5059
+ distributionModules.filter(
5060
+ (name2) => surface.modules.has(name2) || surface.headers.has(name2)
5061
+ )
5062
+ );
5063
+ }
5064
+ function distributionModulesPath(root, moduleRoot, excluded) {
5065
+ const modules = path13.join(moduleRoot, "modules");
5066
+ if (!excluded || excluded.size === 0) return modules;
5067
+ const key = createHash6("sha256").update([...excluded].sort().join("\0")).digest("hex").slice(0, 16);
5068
+ const directory = path13.join(root, `.peach-modules-${key}`);
5069
+ const complete = path13.join(directory, ".complete");
5070
+ if (!existsSync2(complete)) {
5071
+ mkdirSync2(directory, { recursive: true });
5072
+ for (const entry of readdirSync5(directory))
5073
+ rmSync3(path13.join(directory, entry), { recursive: true, force: true });
5074
+ for (const entry of readdirSync5(modules)) {
5075
+ if (excluded.has(entry.replace(/\.swiftmodule$/, ""))) continue;
5076
+ symlinkSync(path13.join(modules, entry), path13.join(directory, entry));
5077
+ }
5078
+ writeFileSync3(complete, "");
5079
+ }
5080
+ return directory;
5081
+ }
4908
5082
  function swiftTargetDependencies(files, targets) {
4909
5083
  const names = /* @__PURE__ */ new Set([...OPTIONAL_FRAMEWORKS, ...targets.map((target) => target.name)]);
4910
5084
  const siblings = /* @__PURE__ */ new Map();
@@ -4946,15 +5120,17 @@ var FOUNDATION_IMPLICIT_FLAGS = FOUNDATION_IMPLICIT_MODULES.map(
4946
5120
  ).join("");
4947
5121
  var ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One"';
4948
5122
  var executableLinkFlags = (root) => ` "-Xclang-linker", "-O0",
4949
- "-Xclang-linker", ${JSON.stringify(`-fuse-ld=${path12.join(root, SWIFT_AUTOLINK_LINKER)}`)},
5123
+ "-Xclang-linker", ${JSON.stringify(`-fuse-ld=${path13.join(root, SWIFT_AUTOLINK_LINKER)}`)},
4950
5124
  "-Xlinker", "-z", "-Xlinker", "stack-size=8372224",
4951
5125
  "-Xlinker", "--stack-first",
4952
5126
  "-Xlinker", "--global-base=8372224",
4953
5127
  "-Xlinker", "-lsetjmp",
5128
+ "-Xlinker", "--export-table",
5129
+ "-Xlinker", "--growable-table",
4954
5130
  `;
4955
5131
  var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
4956
- var MULTI_MANIFEST_VERSION = 46;
4957
- var compilerSourceDigest = true ? "5df98b2ce6152133e55499b786f6b6a1f9f86b4f6b50270401b30b9c782091e3" : swiftCompilerSourceDigest(import.meta.dirname);
5132
+ var MULTI_MANIFEST_VERSION = 50;
5133
+ var compilerSourceDigest = true ? "16646f92cd4ac005481518b6bb1ecd5c0e3ba5c275a17123aae4ec7e63b74548" : swiftCompilerSourceDigest(import.meta.dirname);
4958
5134
  function swiftArtifactHash(input, release, moduleRoot) {
4959
5135
  const hash = createHash6("sha256");
4960
5136
  hash.update(`swift-compile
@@ -4963,6 +5139,7 @@ ${release}
4963
5139
  hash.update(compilerSourceDigest);
4964
5140
  if (input.oneModule) hash.update("one-module\n");
4965
5141
  hash.update(swiftModuleDigest(moduleRoot));
5142
+ if (input.lazyDistribution) hash.update("lazy-distribution\n");
4966
5143
  for (const file of Object.keys(input.files).sort()) {
4967
5144
  hash.update(createHash6("sha256").update(file).digest());
4968
5145
  hash.update(createHash6("sha256").update(input.files[file]).digest());
@@ -4998,6 +5175,10 @@ ${release}
4998
5175
  );
4999
5176
  hash.update(JSON.stringify(input.nativeTargets ?? []));
5000
5177
  hash.update(JSON.stringify(input.packageGuestImports ?? []));
5178
+ if (input.defaultLocalization)
5179
+ hash.update(`default-localization
5180
+ ${input.defaultLocalization}
5181
+ `);
5001
5182
  for (const file of Object.keys(input.packageFiles ?? {}).sort()) {
5002
5183
  hash.update(`package-file\0${file}\0`);
5003
5184
  hash.update(createHash6("sha256").update(input.packageFiles[file]).digest());
@@ -5030,7 +5211,7 @@ ${target}
5030
5211
  return hash.digest("hex");
5031
5212
  }
5032
5213
  function swiftCrossImportFlags(moduleRoot, distribution) {
5033
- const overlayRoot = path12.join(
5214
+ const overlayRoot = path13.join(
5034
5215
  moduleRoot,
5035
5216
  distribution ? "modules" : "cross-import-overlays"
5036
5217
  );
@@ -5038,9 +5219,9 @@ function swiftCrossImportFlags(moduleRoot, distribution) {
5038
5219
  "-Xfrontend",
5039
5220
  "-swift-module-cross-import",
5040
5221
  "-Xfrontend",
5041
- path12.basename(path12.dirname(file), ".swiftcrossimport"),
5222
+ path13.basename(path13.dirname(file), ".swiftcrossimport"),
5042
5223
  "-Xfrontend",
5043
- path12.join(overlayRoot, file)
5224
+ path13.join(overlayRoot, file)
5044
5225
  ]);
5045
5226
  }
5046
5227
  function withoutWasmOverlayIsystem(flags) {
@@ -5078,23 +5259,27 @@ function emitSwiftPackageManifest(args) {
5078
5259
  if (spriteKit) {
5079
5260
  for (const name2 of ["SpriteKit", "PeachBox2D", "simd", "GLKit"]) reach(name2);
5080
5261
  }
5262
+ let distributionLinkPath;
5081
5263
  const distributionLink = args.distributionLink;
5082
- if (distribution && !distributionLink)
5083
- throw new Error(
5084
- "swift-compile: distribution linking requires its object response file"
5085
- );
5086
5264
  if (distribution && distributionLink) {
5087
5265
  const objects = distribution.objects.filter(
5088
5266
  (object) => [...OPTIONAL_FRAMEWORKS, "SpriteKit", "PeachBox2D"].every(
5089
5267
  (name2) => !object.startsWith(`lib/${name2}-`) || reachedFrameworks.has(name2)
5090
5268
  )
5091
5269
  );
5092
- distributionLink.files.set(
5093
- distributionLink.path,
5094
- objects.map(
5095
- (object) => `"${path12.join(moduleRoot, object).replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`
5096
- ).join("\n") + "\n"
5270
+ const quoted = (object) => `"${path13.join(moduleRoot, object).replaceAll("\\", "\\\\").replaceAll('"', '\\"')}"`;
5271
+ const roots = args.lazyDistribution ? swiftObjcRootObjects(distribution.id, moduleRoot, distribution.objects) : null;
5272
+ const list = (roots ? [
5273
+ ...objects.filter((object) => roots.has(object)).map(quoted),
5274
+ "-Wl,--start-lib",
5275
+ ...objects.filter((object) => !roots.has(object)).map(quoted),
5276
+ "-Wl,--end-lib"
5277
+ ] : objects.map(quoted)).join("\n") + "\n";
5278
+ distributionLinkPath = distributionLink.path.replace(
5279
+ /\.rsp$/,
5280
+ `-${createHash6("sha256").update(list).digest("hex").slice(0, 12)}.rsp`
5097
5281
  );
5282
+ distributionLink.files.set(distributionLinkPath, list);
5098
5283
  }
5099
5284
  const overlayFlags = swiftCrossImportFlags(moduleRoot, Boolean(distribution)).map((flag) => `, ${JSON.stringify(flag)}`).join("");
5100
5285
  const executable = targets.find((target) => target.executable);
@@ -5106,14 +5291,16 @@ function emitSwiftPackageManifest(args) {
5106
5291
  const stanza = (target) => {
5107
5292
  const native = args.native?.get(target.name);
5108
5293
  if (target.systemLibrary || native?.clang?.sources.length === 0)
5109
- return ` .systemLibrary(name: ${JSON.stringify(target.name)}, path: ${JSON.stringify(native?.clang ? path12.posix.dirname(native.clang.modulemap) : target.path)}),`;
5294
+ return ` .systemLibrary(name: ${JSON.stringify(target.name)}, path: ${JSON.stringify(native?.clang ? path13.posix.dirname(native.clang.modulemap) : target.path)}),`;
5110
5295
  const isolation = target.mainActorIsolation ? " .defaultIsolation(MainActor.self)," : "";
5111
5296
  const interoperability = target.cxxInterop ? " .interoperabilityMode(.Cxx)," : "";
5112
5297
  const defines = (target.defines ?? []).map((name2) => ` .define(${JSON.stringify(name2)}),`).join("");
5113
5298
  const features = (target.experimentalFeatures ?? []).map((name2) => ` .enableExperimentalFeature(${JSON.stringify(name2)}),`).join("");
5114
5299
  const upcoming = (target.upcomingFeatures ?? []).map((name2) => ` .enableUpcomingFeature(${JSON.stringify(name2)}),`).join("");
5115
5300
  const upstream = (target.swiftFlags ?? []).map((flag) => `, ${JSON.stringify(flag)}`).join("");
5116
- const imports = distribution ? `, "-I", ${JSON.stringify(path12.join(moduleRoot, "modules"))}` : prebuilt ? `, "-I", ${JSON.stringify(prebuilt.modules)}${prebuilt.moduleMaps.map((map) => `, "-Xcc", ${JSON.stringify(`-fmodule-map-file=${map}`)}`).join("")}` : "";
5301
+ const imports = distribution ? `, "-I", ${JSON.stringify(
5302
+ distributionModulesPath(args.root, moduleRoot, args.distributionExcludes)
5303
+ )}` : prebuilt ? `, "-I", ${JSON.stringify(prebuilt.modules)}${prebuilt.moduleMaps.map((map) => `, "-Xcc", ${JSON.stringify(`-fmodule-map-file=${map}`)}`).join("")}` : "";
5117
5304
  const nativeFlags = [
5118
5305
  ...args.nativeFlags?.get(target.name) ?? [],
5119
5306
  ...args.nativeHeaderFlags ?? []
@@ -5145,12 +5332,12 @@ function emitSwiftPackageManifest(args) {
5145
5332
  ].map((flag) => `, ${JSON.stringify(flag)}`).join("");
5146
5333
  const header = args.headerDirectory && [...args.native?.values() ?? []].some(
5147
5334
  (value) => value.late?.producers.includes(target.name)
5148
- ) ? `, "-emit-objc-header-path", ${JSON.stringify(path12.join(args.headerDirectory, `${target.name}-Swift.h`))}` : "";
5335
+ ) ? `, "-emit-objc-header-path", ${JSON.stringify(path13.join(args.headerDirectory, `${target.name}-Swift.h`))}` : "";
5149
5336
  const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation}${interoperability}${defines}${features}${upcoming} .unsafeFlags(["-Osize", "-Xfrontend", "-enable-cross-import-overlays"${overlayFlags}${FOUNDATION_IMPLICIT_FLAGS}${oneModule ? ONE_IMPLICIT_FLAGS : ""}${imports}${nativeImports}${nativeImportFlags}${objcFlags}${header}${upstream}])]`;
5150
5337
  const deps = [
5151
5338
  .../* @__PURE__ */ new Set([
5152
5339
  ...(target.dependencies ?? []).flatMap(
5153
- (dependency) => dependency.kind === "product" && !(linkedObjects && dependency.package === path12.basename(moduleRoot).toLowerCase()) ? [
5340
+ (dependency) => dependency.kind === "product" && !(linkedObjects && dependency.package === path13.basename(moduleRoot).toLowerCase()) ? [
5154
5341
  `.product(name: ${JSON.stringify(dependency.name)}, package: ${JSON.stringify(dependency.package)})`
5155
5342
  ] : []
5156
5343
  ),
@@ -5179,7 +5366,10 @@ function emitSwiftPackageManifest(args) {
5179
5366
  )
5180
5367
  ])
5181
5368
  ].join(", ");
5182
- const library = distribution && distributionLink ? ["-Xclang-linker", `--config=${distributionLink.path}`, ...distribution.link].map((flag) => `, ${JSON.stringify(flag)}`).join("") : prebuilt ? ["-Xclang-linker", `--config=${prebuilt.linkFile}`, ...prebuilt.link].map((flag) => `, ${JSON.stringify(flag)}`).join("") : "";
5369
+ const library = distribution ? [
5370
+ ...distributionLinkPath ? ["-Xclang-linker", `--config=${distributionLinkPath}`] : [],
5371
+ ...distribution.link
5372
+ ].map((flag) => `, ${JSON.stringify(flag)}`).join("") : prebuilt ? ["-Xclang-linker", `--config=${prebuilt.linkFile}`, ...prebuilt.link].map((flag) => `, ${JSON.stringify(flag)}`).join("") : "";
5183
5373
  const kind = target.executable ? ".executableTarget" : ".target";
5184
5374
  const linkedLibraries = (target.linkedLibraries ?? []).map(
5185
5375
  (name2) => `.linkedLibrary(${JSON.stringify(name2)})`
@@ -5218,8 +5408,8 @@ function emitSwiftPackageManifest(args) {
5218
5408
  ` path: ${JSON.stringify(native?.clang ? "." : target.path)},`,
5219
5409
  ...exclusions.length ? [` exclude: ${JSON.stringify(exclusions)},`] : [],
5220
5410
  ...native?.clang ? [
5221
- ` sources: ${JSON.stringify(native.clang.sources.map((source) => path12.posix.join(native.path, source)))},`,
5222
- ` publicHeadersPath: ${JSON.stringify(path12.posix.dirname(native.clang.modulemap))},`
5411
+ ` sources: ${JSON.stringify(native.clang.sources.map((source) => path13.posix.join(native.path, source)))},`,
5412
+ ` publicHeadersPath: ${JSON.stringify(path13.posix.dirname(native.clang.modulemap))},`
5223
5413
  ] : native?.flags ? [` sources: ${JSON.stringify(native.sources)},`] : [],
5224
5414
  ...!native?.clang && target.publicHeadersPath !== void 0 ? [` publicHeadersPath: ${JSON.stringify(target.publicHeadersPath)},`] : [],
5225
5415
  // the native backend supplies dependency module maps without their
@@ -5235,6 +5425,7 @@ function emitSwiftPackageManifest(args) {
5235
5425
  "// generated by swift-compile from the project package partition.",
5236
5426
  "let package = Package(",
5237
5427
  ' name: "app",',
5428
+ ...args.defaultLocalization ? [` defaultLocalization: ${JSON.stringify(args.defaultLocalization)},`] : [],
5238
5429
  ` products: [.executable(name: "${executable.name}", targets: ["${executable.name}"])],`,
5239
5430
  ` dependencies: [${[
5240
5431
  ...linkedObjects ? [] : [`.package(path: ${JSON.stringify(moduleRoot)})`],
@@ -5262,8 +5453,8 @@ function emitSwiftPackageManifest(args) {
5262
5453
  ` .target(name: ${JSON.stringify(group.name)},`,
5263
5454
  ` dependencies: ${JSON.stringify(native.mixed ? [] : [name2])},`,
5264
5455
  ` path: ${JSON.stringify(native.clang || native.mixed ? "." : native.path)},`,
5265
- ` sources: ${JSON.stringify(native.clang || native.mixed ? group.sources.map((source) => path12.posix.join(native.path, source)) : group.sources)},`,
5266
- ` publicHeadersPath: ${JSON.stringify(native.clang ? path12.posix.dirname(native.clang.modulemap) : native.implementationHeaders ?? "include")},`,
5456
+ ` sources: ${JSON.stringify(native.clang || native.mixed ? group.sources.map((source) => path13.posix.join(native.path, source)) : group.sources)},`,
5457
+ ` publicHeadersPath: ${JSON.stringify(native.clang ? path13.posix.dirname(native.clang.modulemap) : native.implementationHeaders ?? "include")},`,
5267
5458
  ` cSettings: [${macroSettings(owner?.cDefines)} .unsafeFlags(${JSON.stringify([...nativeFlags, ...group.flags])})],`,
5268
5459
  ` cxxSettings: [${macroSettings(owner?.cxxDefines)} .unsafeFlags(${JSON.stringify(["-fno-cxx-modules", ...cxxFlagsFor(nativeFlags), "-I", native.includeDirectory, "-I", args.headerDirectory, ...group.cxxFlags])})]),`
5269
5460
  ]) : [];
@@ -5278,8 +5469,8 @@ function syncSwiftTree(base, files) {
5278
5469
  mkdirSync2(base, { recursive: true });
5279
5470
  const walk = (dir) => {
5280
5471
  for (const entry of readdirSync5(dir, { withFileTypes: true })) {
5281
- const full = path12.join(dir, entry.name);
5282
- if (dir === base && (entry.name === ".build" || entry.name === SWIFT_LINK_STAMP || entry.name === SWIFT_FRAMEWORK_KEY))
5472
+ const full = path13.join(dir, entry.name);
5473
+ if (dir === base && (entry.name === ".build" || entry.name.startsWith(".peach-modules-") || entry.name === SWIFT_LINK_STAMP || entry.name === SWIFT_FRAMEWORK_KEY))
5283
5474
  continue;
5284
5475
  if (entry.isDirectory()) walk(full);
5285
5476
  else if (!files.has(full)) rmSync3(full, { force: true });
@@ -5289,7 +5480,7 @@ function syncSwiftTree(base, files) {
5289
5480
  for (const [full, contents] of files) {
5290
5481
  if (existsSync2(full) && (typeof contents === "string" ? readFileSync7(full, "utf8") === contents : readFileSync7(full).equals(contents)))
5291
5482
  continue;
5292
- mkdirSync2(path12.dirname(full), { recursive: true });
5483
+ mkdirSync2(path13.dirname(full), { recursive: true });
5293
5484
  writeFileSync3(full, contents);
5294
5485
  }
5295
5486
  }
@@ -6309,11 +6500,16 @@ function swiftApplicationEntry(file, source) {
6309
6500
  else if (source[at] === "}") depth--;
6310
6501
  else if (depth === 0 && /^@(?:main|UIApplicationMain)\b/.test(source.slice(at)))
6311
6502
  return true;
6312
- else if (depth === 0 && path12.basename(file) === "main.swift" && /^UIApplicationMain\s*\(/.test(source.slice(at)))
6503
+ else if (depth === 0 && path13.basename(file) === "main.swift" && /^UIApplicationMain\s*\(/.test(source.slice(at)))
6313
6504
  return true;
6314
6505
  }
6315
6506
  return false;
6316
6507
  }
6508
+ function swiftTypedApplicationEntry(source) {
6509
+ const code = [...swiftConditionalLines(swiftCodeMask(source))].map(({ line, active }) => active === false ? " ".repeat(line.length) : line).join("\n");
6510
+ const match = /@main\b[\s\S]*?\b(?:struct|class|enum)\s+([A-Za-z_]\w*)/.exec(code);
6511
+ return match ? { index: match.index, name: match[1] } : null;
6512
+ }
6317
6513
  function wrapUIApplicationMainEntry(source) {
6318
6514
  const code = [...swiftConditionalLines(swiftCodeMask(source))].map(({ line, active }) => active === false ? " ".repeat(line.length) : line).join("\n");
6319
6515
  const { tokens } = swiftCodeScan(code);
@@ -6665,14 +6861,14 @@ function prepareSwiftDependency(source, destination) {
6665
6861
  for (const entry of readdirSync5(from, { withFileTypes: true })) {
6666
6862
  if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
6667
6863
  continue;
6668
- const file = path12.join(from, entry.name);
6864
+ const file = path13.join(from, entry.name);
6669
6865
  if (entry.isDirectory()) gather(file);
6670
6866
  else if (entry.isFile() && entry.name.endsWith(".swift"))
6671
- origins[path12.relative(source, file)] = readFileSync7(file, "utf8");
6867
+ origins[path13.relative(source, file)] = readFileSync7(file, "utf8");
6672
6868
  }
6673
6869
  };
6674
6870
  gather(source);
6675
- const manifest = path12.join(source, "Package.swift");
6871
+ const manifest = path13.join(source, "Package.swift");
6676
6872
  const targets = existsSync2(manifest) ? swiftManifestTargets(readFileSync7(manifest, "utf8")) : [];
6677
6873
  const compiled = compiledSwiftSources(origins, targets);
6678
6874
  const copy = (from, to) => {
@@ -6680,11 +6876,11 @@ function prepareSwiftDependency(source, destination) {
6680
6876
  for (const entry of readdirSync5(from, { withFileTypes: true })) {
6681
6877
  if (entry.name === ".git" || entry.name === ".build" || entry.name === ".swiftpm")
6682
6878
  continue;
6683
- const file = path12.join(from, entry.name);
6684
- const target = path12.join(to, entry.name);
6879
+ const file = path13.join(from, entry.name);
6880
+ const target = path13.join(to, entry.name);
6685
6881
  if (entry.isDirectory()) copy(file, target);
6686
6882
  else if (entry.isFile() && entry.name.endsWith(".swift"))
6687
- writeFileSync3(target, compiled.get(path12.relative(source, file)));
6883
+ writeFileSync3(target, compiled.get(path13.relative(source, file)));
6688
6884
  else cpSync(file, target, { verbatimSymlinks: true });
6689
6885
  }
6690
6886
  };
@@ -6693,18 +6889,18 @@ function prepareSwiftDependency(source, destination) {
6693
6889
  var HIDDEN_UNITS = "PeachHiddenUnits";
6694
6890
  function clangImportModuleMapFlags(settings, layoutRoot, written) {
6695
6891
  const searched = new Set(settings.headerSearchPaths);
6696
- const directory = path12.join(layoutRoot, ".build", "peach-clang-modulemaps");
6892
+ const directory = path13.join(layoutRoot, ".build", "peach-clang-modulemaps");
6697
6893
  return (settings.moduleMaps ?? []).flatMap((map) => {
6698
- const headers = path12.join(layoutRoot, map.headers);
6894
+ const headers = path13.join(layoutRoot, map.headers);
6699
6895
  if (!existsSync2(headers)) return [];
6700
- const published = path12.join(headers, "module.modulemap");
6896
+ const published = path13.join(headers, "module.modulemap");
6701
6897
  if (searched.has(map.headers) && existsSync2(published)) return [];
6702
6898
  if (!searched.has(map.headers) && existsSync2(published))
6703
6899
  return [`-fmodule-map-file=${published}`];
6704
6900
  const cached = written.get(headers);
6705
6901
  if (cached) return [cached];
6706
6902
  mkdirSync2(directory, { recursive: true });
6707
- const output = path12.join(directory, `module-${written.size}.modulemap`);
6903
+ const output = path13.join(directory, `module-${written.size}.modulemap`);
6708
6904
  writeFileSync3(
6709
6905
  output,
6710
6906
  swiftPackageClangModuleMap(swiftTargetModuleName(map.module), {
@@ -6740,13 +6936,14 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
6740
6936
  const targets = distribution && compileTargets(input).length === 0 ? [
6741
6937
  {
6742
6938
  name: "App",
6743
- path: path12.relative(layout.root, layout.sources),
6939
+ path: path13.relative(layout.root, layout.sources),
6744
6940
  executable: true,
6745
6941
  languageMode: 5,
6746
6942
  mainActorIsolation: false,
6747
6943
  resources: false
6748
6944
  }
6749
6945
  ] : compileTargets(input);
6946
+ const distributionExcludes = distribution ? swiftSystemLibraryExclusions(input.files, targets, distribution.modules) : void 0;
6750
6947
  const files = /* @__PURE__ */ new Map();
6751
6948
  const native = /* @__PURE__ */ new Map();
6752
6949
  const targetFailures = [];
@@ -6770,18 +6967,18 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
6770
6967
  ))
6771
6968
  for (const name2 of clangImportNames(contents)) importedModules.add(name2);
6772
6969
  }
6773
- const headerDirectory = path12.join(layout.root, ".build", "peach-cxx-headers");
6970
+ const headerDirectory = path13.join(layout.root, ".build", "peach-cxx-headers");
6774
6971
  let checkedToolchain;
6775
6972
  const nativeToolchain = () => {
6776
6973
  if (checkedToolchain) return checkedToolchain;
6777
- const pin = distribution ?? JSON.parse(readFileSync7(path12.join(moduleRoot, "toolchain.json"), "utf8"));
6974
+ const pin = distribution ?? JSON.parse(readFileSync7(path13.join(moduleRoot, "toolchain.json"), "utf8"));
6778
6975
  checkedToolchain = swiftToolchain(pin.release, swiftModuleSdk(moduleRoot));
6779
6976
  return checkedToolchain;
6780
6977
  };
6781
6978
  const deploymentTarget = (name2) => input.nativeTargets?.find((value) => value.name === name2)?.deploymentTarget ?? targets.find((value) => value.name === name2)?.iosDeploymentTarget ?? null;
6782
6979
  const targetStagedFiles = /* @__PURE__ */ new Map();
6783
6980
  const stageTargetFile = (target, file, contents, options) => {
6784
- const relative = path12.relative(layout.root, file).split(path12.sep).join(path12.posix.sep);
6981
+ const relative = path13.relative(layout.root, file).split(path13.sep).join(path13.posix.sep);
6785
6982
  const prior = files.has(file) ? files.get(file) : Object.hasOwn(input.files, relative) ? input.files[relative] : void 0;
6786
6983
  if (!options?.allowExisting && prior !== void 0)
6787
6984
  throw new Error(`target ${target} already contains generated output ${relative}`);
@@ -6810,7 +7007,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
6810
7007
  targetStagedFiles.delete(target.name);
6811
7008
  if (entries.some(([file]) => isSwiftNativeTranslationUnit(file)) && (swift || input.nativeTargets?.some((value) => value.name === target.name))) {
6812
7009
  if (!swift) {
6813
- const unprepared = path12.join(
7010
+ const unprepared = path13.join(
6814
7011
  layout.root,
6815
7012
  target.path,
6816
7013
  "PeachUnprepared.generated.swift"
@@ -6825,7 +7022,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
6825
7022
  native.set(target.name, {
6826
7023
  mixed: true,
6827
7024
  path: target.path,
6828
- includeDirectory: path12.join(layout.root, target.path, "include"),
7025
+ includeDirectory: path13.join(layout.root, target.path, "include"),
6829
7026
  sources: [],
6830
7027
  lateSources: [],
6831
7028
  exclude: entries.filter(([file]) => !file.endsWith(".swift") && !file.endsWith(".metal")).map(([file]) => file.slice(prefix.length))
@@ -6837,27 +7034,27 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
6837
7034
  const contents = input.files[file];
6838
7035
  if (contents === void 0)
6839
7036
  throw new Error(`missing original Objective-C header ${file}`);
6840
- const destination = path12.join(layout.root, file);
6841
- mkdirSync2(path12.dirname(destination), { recursive: true });
7037
+ const destination = path13.join(layout.root, file);
7038
+ mkdirSync2(path13.dirname(destination), { recursive: true });
6842
7039
  writeFileSync3(destination, contents);
6843
7040
  files.set(destination, contents);
6844
7041
  }
6845
7042
  if (!settings.flattensPublicHeaders) continue;
6846
7043
  for (const header of settings.publicHeaders) {
6847
- const destination = path12.join(headerDirectory, settings.name, path12.basename(header));
7044
+ const destination = path13.join(headerDirectory, settings.name, path13.basename(header));
6848
7045
  if (files.has(destination))
6849
7046
  throw new Error(`duplicate product header ${destination}`);
6850
- const contents = `#import ${JSON.stringify(path12.join(layout.root, header))}
7047
+ const contents = `#import ${JSON.stringify(path13.join(layout.root, header))}
6851
7048
  `;
6852
7049
  files.set(destination, contents);
6853
- mkdirSync2(path12.dirname(destination), { recursive: true });
7050
+ mkdirSync2(path13.dirname(destination), { recursive: true });
6854
7051
  writeFileSync3(destination, contents);
6855
7052
  }
6856
7053
  }
6857
7054
  const nativeTargets = input.nativeTargets ?? [];
6858
- const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ? path12.join(layout.root, file.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1)) : file;
7055
+ const fromInputRoot = (file) => file.startsWith(`${SWIFT_NATIVE_INPUT_ROOT}/`) ? path13.join(layout.root, file.slice(SWIFT_NATIVE_INPUT_ROOT.length + 1)) : file;
6859
7056
  const headerSearch = writeXcodeHeaderSearch(
6860
- path12.join(layout.root, ".build", "peach-xcode-headers"),
7057
+ path13.join(layout.root, ".build", "peach-xcode-headers"),
6861
7058
  nativeTargets.map((settings) => ({
6862
7059
  headerMaps: settings.headerMaps.map((map) => ({
6863
7060
  flag: map.flag,
@@ -6868,12 +7065,12 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
6868
7065
  })),
6869
7066
  productHeaders: Object.fromEntries(
6870
7067
  Object.entries(settings.productHeaders).map(([product, file]) => [
6871
- path12.join(layout.root, product),
6872
- path12.join(layout.root, file)
7068
+ path13.join(layout.root, product),
7069
+ path13.join(layout.root, file)
6873
7070
  ])
6874
7071
  ),
6875
7072
  userHeaderSearchPaths: settings.userHeaderSearchPaths.map(
6876
- (directory) => path12.join(layout.root, directory)
7073
+ (directory) => path13.join(layout.root, directory)
6877
7074
  )
6878
7075
  }))
6879
7076
  );
@@ -6897,7 +7094,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
6897
7094
  if (producer && targets.some((value) => value.name === producer))
6898
7095
  producers2.add(producer);
6899
7096
  const local = [
6900
- path12.posix.join(path12.posix.dirname(file), include2),
7097
+ path13.posix.join(path13.posix.dirname(file), include2),
6901
7098
  `${includes}${include2}`
6902
7099
  ].find((candidate) => input.files[candidate] !== void 0);
6903
7100
  if (local) {
@@ -6931,12 +7128,12 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
6931
7128
  const headers = settings.headers;
6932
7129
  const roots2 = settings.bridgingHeader ? [settings.bridgingHeader] : entries.some(([file]) => file.endsWith(".swift")) || importedModules.has(swiftTargetModuleName(target.name)) ? settings.publicHeaders : [];
6933
7130
  for (const file of headers) {
6934
- const destination = path12.join(layout.root, file);
6935
- mkdirSync2(path12.dirname(destination), { recursive: true });
7131
+ const destination = path13.join(layout.root, file);
7132
+ mkdirSync2(path13.dirname(destination), { recursive: true });
6936
7133
  writeFileSync3(destination, input.files[file]);
6937
7134
  }
6938
7135
  const search = [.../* @__PURE__ */ new Set([...settings?.headerSearchPaths ?? []])].flatMap(
6939
- (dir) => ["-I", path12.join(layout.root, dir)]
7136
+ (dir) => ["-I", path13.join(layout.root, dir)]
6940
7137
  );
6941
7138
  const toolchainBin = nativeToolchain();
6942
7139
  const stageFlags = (flags2, sdkInclude2) => flags2.map(
@@ -6948,7 +7145,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
6948
7145
  ...search,
6949
7146
  ...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
6950
7147
  "-F",
6951
- path12.join(layout.root, dir)
7148
+ path13.join(layout.root, dir)
6952
7149
  ]),
6953
7150
  "-I",
6954
7151
  headerDirectory
@@ -6959,13 +7156,13 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
6959
7156
  const flag = settings.flags[index];
6960
7157
  if (flag === "-I" || flag === "-iquote") {
6961
7158
  const directory = settings.flags[index + 1];
6962
- if (directory === void 0 || !path12.isAbsolute(directory)) {
7159
+ if (directory === void 0 || !path13.isAbsolute(directory)) {
6963
7160
  index++;
6964
7161
  continue;
6965
7162
  }
6966
7163
  }
6967
7164
  const joined = /^-(?:I|iquote)(.+)$/.exec(flag);
6968
- if (joined && !path12.isAbsolute(joined[1])) continue;
7165
+ if (joined && !path13.isAbsolute(joined[1])) continue;
6969
7166
  kept.push(flag);
6970
7167
  }
6971
7168
  return [
@@ -6974,18 +7171,18 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
6974
7171
  ...search,
6975
7172
  ...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
6976
7173
  "-F",
6977
- path12.join(layout.root, dir)
7174
+ path13.join(layout.root, dir)
6978
7175
  ]),
6979
7176
  "-I",
6980
7177
  headerDirectory
6981
7178
  ];
6982
7179
  })();
6983
- const sdkInclude = path12.join(
7180
+ const sdkInclude = path13.join(
6984
7181
  swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
6985
7182
  "darwin/usr/include"
6986
7183
  );
6987
7184
  const flags = stageFlags(originalFlags, sdkInclude);
6988
- const prefixHeader = settings?.prefixHeader ? ["-include", path12.join(layout.root, settings.prefixHeader)] : [];
7185
+ const prefixHeader = settings?.prefixHeader ? ["-include", path13.join(layout.root, settings.prefixHeader)] : [];
6989
7186
  const bundleName = entries.some(([file]) => file.endsWith(".swift")) ? void 0 : swiftObjCResourceBundleName({
6990
7187
  target: target.name,
6991
7188
  path: target.path,
@@ -6996,7 +7193,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
6996
7193
  bundles: input.resourceBundles
6997
7194
  });
6998
7195
  const accessor = bundleName === void 0 ? void 0 : swiftObjCResourceAccessor(bundleName);
6999
- const accessorHeader = path12.join(
7196
+ const accessorHeader = path13.join(
7000
7197
  layout.root,
7001
7198
  target.path,
7002
7199
  OBJC_RESOURCE_ACCESSOR_HEADER
@@ -7007,7 +7204,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7007
7204
  const nativeUnits = accessor ? [...units, [accessorUnit, accessor.body]] : units;
7008
7205
  const unitSource = (file) => {
7009
7206
  const relative = file.slice(prefix.length);
7010
- return relative.split("/").some((part) => part.startsWith(".")) ? path12.posix.join(HIDDEN_UNITS, relative.replaceAll(/(^|\/)\./g, "$1%2E")) : relative;
7207
+ return relative.split("/").some((part) => part.startsWith(".")) ? path13.posix.join(HIDDEN_UNITS, relative.replaceAll(/(^|\/)\./g, "$1%2E")) : relative;
7011
7208
  };
7012
7209
  const accessorFlags = accessor ? ["-include", accessorHeader] : [];
7013
7210
  const nativeC = !entries.some(([file]) => file.endsWith(".swift"));
@@ -7037,20 +7234,20 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7037
7234
  )
7038
7235
  ].sort();
7039
7236
  const topHeaders = settings.publicHeaders.filter(
7040
- (file) => path12.posix.dirname(file) === headerDir
7237
+ (file) => path13.posix.dirname(file) === headerDir
7041
7238
  );
7042
7239
  if (input.files[custom] !== void 0) {
7043
7240
  swiftpmModuleMap = { path: custom, contents: input.files[custom] };
7044
7241
  } else if (input.files[umbrella] !== void 0) {
7045
7242
  if (siblingDirs.length > 0)
7046
7243
  throw new Error(
7047
- `target ${target.name} has invalid header layout: umbrella header found at '${path12.join(layout.root, umbrella)}', but directories exist next to it: ${siblingDirs.map((name2) => path12.join(layout.root, headerDir, name2)).join(", ")}; consider removing them`
7244
+ `target ${target.name} has invalid header layout: umbrella header found at '${path13.join(layout.root, umbrella)}', but directories exist next to it: ${siblingDirs.map((name2) => path13.join(layout.root, headerDir, name2)).join(", ")}; consider removing them`
7048
7245
  );
7049
7246
  swiftpmModuleMap = {
7050
7247
  path: custom,
7051
7248
  contents: swiftPackageClangModuleMap(moduleName, {
7052
7249
  kind: "header",
7053
- path: path12.join(layout.root, umbrella)
7250
+ path: path13.join(layout.root, umbrella)
7054
7251
  })
7055
7252
  };
7056
7253
  } else if (input.files[nestedUmbrella] !== void 0 && siblingDirs.length === 1 && siblingDirs[0] === moduleName && topHeaders.length === 0) {
@@ -7058,7 +7255,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7058
7255
  path: custom,
7059
7256
  contents: swiftPackageClangModuleMap(moduleName, {
7060
7257
  kind: "header",
7061
- path: path12.join(layout.root, nestedUmbrella)
7258
+ path: path13.join(layout.root, nestedUmbrella)
7062
7259
  })
7063
7260
  };
7064
7261
  } else {
@@ -7066,12 +7263,12 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7066
7263
  path: custom,
7067
7264
  contents: swiftPackageClangModuleMap(moduleName, {
7068
7265
  kind: "directory",
7069
- path: path12.join(layout.root, headerDir)
7266
+ path: path13.join(layout.root, headerDir)
7070
7267
  })
7071
7268
  };
7072
7269
  }
7073
7270
  }
7074
- const modulemap = originalModuleMap?.[0] ?? swiftpmModuleMap?.path ?? packageModuleMap?.[0] ?? path12.posix.join(
7271
+ const modulemap = originalModuleMap?.[0] ?? swiftpmModuleMap?.path ?? packageModuleMap?.[0] ?? path13.posix.join(
7075
7272
  ".build",
7076
7273
  "peach-objc-originals",
7077
7274
  target.name,
@@ -7079,41 +7276,41 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7079
7276
  );
7080
7277
  const moduleContents = originalModuleMap ? input.files[originalModuleMap[1]] : swiftpmModuleMap?.contents ?? packageModuleMap?.[1] ?? swiftObjCModuleMap(
7081
7278
  swiftTargetModuleName(target.name),
7082
- roots2.map((file) => path12.join(layout.root, file))
7279
+ roots2.map((file) => path13.join(layout.root, file))
7083
7280
  );
7084
7281
  if (moduleContents === void 0)
7085
7282
  throw new Error("missing original module map " + modulemap);
7086
- stageTargetFile(target.name, path12.join(layout.root, modulemap), moduleContents, {
7283
+ stageTargetFile(target.name, path13.join(layout.root, modulemap), moduleContents, {
7087
7284
  allowExisting: true
7088
7285
  });
7089
7286
  const importFlags = [
7090
- ...stageFlags(importOriginalFlags, sdkInclude),
7091
- "-fmodule-map-file=" + path12.join(layout.root, modulemap),
7287
+ ...swiftClangImporterFlags(stageFlags(importOriginalFlags, sdkInclude)),
7288
+ "-fmodule-map-file=" + path13.join(layout.root, modulemap),
7092
7289
  ...clangImportModuleMapFlags(settings, layout.root, importModuleMaps)
7093
7290
  ];
7094
7291
  const groups = /* @__PURE__ */ new Map();
7095
7292
  for (const [file, contents] of nativeUnits) {
7096
7293
  const origin = settings?.sourceDirectories[file];
7097
7294
  if (origin) {
7098
- const original = path12.join(layout.root, origin, path12.posix.basename(file));
7099
- mkdirSync2(path12.dirname(original), { recursive: true });
7295
+ const original = path13.join(layout.root, origin, path13.posix.basename(file));
7296
+ mkdirSync2(path13.dirname(original), { recursive: true });
7100
7297
  stageTargetFile(target.name, original, contents, { allowExisting: true });
7101
7298
  }
7102
7299
  const source = unitSource(file);
7103
7300
  if (source !== file.slice(prefix.length))
7104
7301
  stageTargetFile(
7105
7302
  target.name,
7106
- path12.join(layout.root, target.path, source),
7303
+ path13.join(layout.root, target.path, source),
7107
7304
  contents,
7108
7305
  {
7109
7306
  allowExisting: true
7110
7307
  }
7111
7308
  );
7112
7309
  const perFile = [
7113
- ...origin ? ["-iquote", path12.join(layout.root, origin)] : [],
7310
+ ...origin ? ["-iquote", path13.join(layout.root, origin)] : [],
7114
7311
  ...stageFlags(
7115
7312
  settings?.fileFlags[file] ?? [],
7116
- path12.join(
7313
+ path13.join(
7117
7314
  swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
7118
7315
  "darwin/usr/include"
7119
7316
  )
@@ -7131,7 +7328,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7131
7328
  ...accessorFlags,
7132
7329
  ...stageFlags(
7133
7330
  cxx ? settings.cxxFlags : [],
7134
- path12.join(
7331
+ path13.join(
7135
7332
  swiftSdkPaths(moduleRoot, toolchainBin).sysroot,
7136
7333
  "darwin/usr/include"
7137
7334
  )
@@ -7146,7 +7343,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7146
7343
  stageTargetFile(target.name, accessorHeader, accessor.header);
7147
7344
  stageTargetFile(
7148
7345
  target.name,
7149
- path12.join(layout.root, accessorUnit),
7346
+ path13.join(layout.root, accessorUnit),
7150
7347
  accessor.body
7151
7348
  );
7152
7349
  }
@@ -7161,7 +7358,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7161
7358
  ].sort();
7162
7359
  native.set(target.name, {
7163
7360
  path: target.path,
7164
- includeDirectory: path12.dirname(path12.join(layout.root, modulemap)),
7361
+ includeDirectory: path13.dirname(path13.join(layout.root, modulemap)),
7165
7362
  importFlags,
7166
7363
  sources: nativeUnits.map(([file]) => unitSource(file)),
7167
7364
  lateSources: implementations.flatMap((group) => group.sources),
@@ -7179,15 +7376,15 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7179
7376
  });
7180
7377
  continue;
7181
7378
  }
7182
- const implementationHeaders = path12.posix.join(
7379
+ const implementationHeaders = path13.posix.join(
7183
7380
  ".build",
7184
7381
  "peach-objc-implementations",
7185
7382
  target.name
7186
7383
  );
7187
- const include2 = path12.join(layout.root, implementationHeaders);
7384
+ const include2 = path13.join(layout.root, implementationHeaders);
7188
7385
  stageTargetFile(
7189
7386
  target.name,
7190
- path12.join(include2, "module.modulemap"),
7387
+ path13.join(include2, "module.modulemap"),
7191
7388
  `module ${target.name}ImplementationDeclarations { export * }
7192
7389
  `
7193
7390
  );
@@ -7198,7 +7395,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7198
7395
  implementationHeaders,
7199
7396
  importFlags,
7200
7397
  swiftFlags: [
7201
- ...settings.bridgingHeader ? ["-import-objc-header", path12.join(layout.root, settings.bridgingHeader)] : roots2.length ? ["-import-underlying-module"] : [],
7398
+ ...settings.bridgingHeader ? ["-import-objc-header", path13.join(layout.root, settings.bridgingHeader)] : roots2.length ? ["-import-underlying-module"] : [],
7202
7399
  ...importFlags.flatMap((flag) => ["-Xcc", flag])
7203
7400
  ],
7204
7401
  sources: nativeUnits.map(([file]) => unitSource(file)),
@@ -7228,7 +7425,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7228
7425
  }
7229
7426
  native.set(target.name, {
7230
7427
  path: target.path,
7231
- includeDirectory: path12.join(layout.root, includes),
7428
+ includeDirectory: path13.join(layout.root, includes),
7232
7429
  sources: units.map(([file]) => file.slice(prefix.length)),
7233
7430
  lateSources: late.map(([file]) => file.slice(prefix.length)),
7234
7431
  ...late.length > 0 ? {
@@ -7246,7 +7443,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7246
7443
  ([file]) => file.startsWith(includes) && /\.(?:h|hpp|hh|hxx)$/.test(file) && consumers.get(file).size === 0
7247
7444
  );
7248
7445
  files.set(
7249
- path12.join(layout.root, includes, "module.modulemap"),
7446
+ path13.join(layout.root, includes, "module.modulemap"),
7250
7447
  [
7251
7448
  `module ${target.name} {`,
7252
7449
  ...roots.map(
@@ -7264,10 +7461,10 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7264
7461
  [...native.values()].flatMap((value) => value.late?.producers ?? [])
7265
7462
  )) {
7266
7463
  files.set(
7267
- path12.join(headerDirectory, name2, name2 + "-Swift.h"),
7464
+ path13.join(headerDirectory, name2, name2 + "-Swift.h"),
7268
7465
  '#include "../' + name2 + '-Swift.h"\n'
7269
7466
  );
7270
- const modulemap = path12.join(
7467
+ const modulemap = path13.join(
7271
7468
  layout.root,
7272
7469
  ".build",
7273
7470
  "peach-objc-swift-headers",
@@ -7277,8 +7474,8 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7277
7474
  files.set(
7278
7475
  modulemap,
7279
7476
  swiftObjCModuleMap(swiftTargetModuleName(name2), [
7280
- ...(input.nativeTargets?.find((target) => target.name === name2)?.publicHeaders ?? []).map((header) => path12.join(layout.root, header)),
7281
- path12.join(headerDirectory, name2 + "-Swift.h")
7477
+ ...(input.nativeTargets?.find((target) => target.name === name2)?.publicHeaders ?? []).map((header) => path13.join(layout.root, header)),
7478
+ path13.join(headerDirectory, name2 + "-Swift.h")
7282
7479
  ])
7283
7480
  );
7284
7481
  nativeHeaderFlags.push("-fmodule-map-file=" + modulemap);
@@ -7287,7 +7484,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7287
7484
  swiftModuleInputFiles(moduleRoot).join("\n")
7288
7485
  );
7289
7486
  if (!distribution) {
7290
- modulePlan.update(readFileSync7(path12.join(moduleRoot, "Package.swift")));
7487
+ modulePlan.update(readFileSync7(path13.join(moduleRoot, "Package.swift")));
7291
7488
  }
7292
7489
  const resourcePlan = createHash6("sha256").update(
7293
7490
  JSON.stringify(
@@ -7321,22 +7518,20 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7321
7518
  )
7322
7519
  );
7323
7520
  const mains = entries.flatMap(([file, source]) => {
7324
- const match = /@main\b[\s\S]*?\b(?:struct|class|enum)\s+([A-Za-z_]\w*)/.exec(
7325
- swiftCodeMask(source)
7326
- );
7327
- return match ? [{ file, source, match }] : [];
7521
+ const entry = swiftTypedApplicationEntry(source);
7522
+ return entry ? [{ file, source, ...entry }] : [];
7328
7523
  });
7329
7524
  let entryFile;
7330
7525
  let entrySource;
7331
7526
  if (mains.length === 1) {
7332
7527
  const main = mains[0];
7333
7528
  entryFile = main.file;
7334
- entrySource = main.source.slice(0, main.match.index) + " " + main.source.slice(main.match.index + 5) + `
7335
- @MainActor public func __peachRunApplication() { ${main.match[1]}.main() }
7529
+ entrySource = main.source.slice(0, main.index) + " " + main.source.slice(main.index + 5) + `
7530
+ @MainActor public func __peachRunApplication() { ${main.name}.main() }
7336
7531
  `;
7337
7532
  } else if (mains.length === 0) {
7338
7533
  const procedural = entries.filter(
7339
- ([file, source]) => path12.basename(file) === "main.swift" && swiftApplicationEntry(file, source)
7534
+ ([file, source]) => path13.basename(file) === "main.swift" && swiftApplicationEntry(file, source)
7340
7535
  );
7341
7536
  const wrapped = procedural.length === 1 ? wrapUIApplicationMainEntry(procedural[0][1]) : null;
7342
7537
  if (!wrapped)
@@ -7365,7 +7560,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7365
7560
  exclude: []
7366
7561
  });
7367
7562
  files.set(
7368
- path12.join(layout.root, `PeachApplication/${name2}/Entry.swift`),
7563
+ path13.join(layout.root, `PeachApplication/${name2}/Entry.swift`),
7369
7564
  `import ${swiftTargetModuleName(target.name)}
7370
7565
  @main struct __PeachApplicationEntry { @MainActor static func main() { __peachRunApplication() } }
7371
7566
  `
@@ -7375,7 +7570,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7375
7570
  const nativeFlags = native.size > 0 ? /* @__PURE__ */ new Map() : void 0;
7376
7571
  if (nativeFlags) {
7377
7572
  const toolchainBin = nativeToolchain();
7378
- const headers = path12.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, "darwin");
7573
+ const headers = path13.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, "darwin");
7379
7574
  for (const target of targets) {
7380
7575
  const version = deploymentTarget(target.name);
7381
7576
  const minimum = iosDeploymentMinimum(version);
@@ -7394,6 +7589,10 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7394
7589
  "-fobjc-exceptions",
7395
7590
  "-fexceptions",
7396
7591
  "-fwasm-exceptions",
7592
+ // the backend lowers direct setjmp-family calls; -lsetjmp is already
7593
+ // linked. no-op for units without setjmp calls (byte-identical).
7594
+ "-mllvm",
7595
+ "-wasm-enable-sjlj",
7397
7596
  "-fobjc-arc",
7398
7597
  ...intake
7399
7598
  ]);
@@ -7402,10 +7601,10 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7402
7601
  if (targets.length === 0 && !prebuilt) {
7403
7602
  for (const [file, contents] of Object.entries(input.files)) {
7404
7603
  if (file === "Package.swift") continue;
7405
- files.set(path12.join(layout.sources, file), compiled.get(file) ?? contents);
7604
+ files.set(path13.join(layout.sources, file), compiled.get(file) ?? contents);
7406
7605
  }
7407
7606
  let manifest = readFileSync7(
7408
- path12.join(moduleRoot, "scripts/contrast-app-Package.swift"),
7607
+ path13.join(moduleRoot, "scripts/contrast-app-Package.swift"),
7409
7608
  "utf8"
7410
7609
  ).replaceAll("__SOOTSIM_SWIFT_PACKAGE__", moduleRoot);
7411
7610
  const reactor = ` ${REACTOR_FLAG}`;
@@ -7449,30 +7648,37 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7449
7648
  manifest = manifest.replace(anchor, `${anchor}
7450
7649
  ${SPRITEKIT_PRODUCT},`);
7451
7650
  }
7452
- files.set(path12.join(layout.root, "Package.swift"), manifest + moduleFiles);
7651
+ files.set(path13.join(layout.root, "Package.swift"), manifest + moduleFiles);
7453
7652
  } else {
7454
7653
  const base = layout.multi ? layout.root : layout.sources;
7455
7654
  const libraries = /* @__PURE__ */ new Map();
7456
7655
  for (const [target, data] of Object.entries(input.libraries ?? {})) {
7457
- const file = path12.join(layout.root, ".peach-libraries", `lib${target}.a`);
7458
- files.set(file, Buffer.from(data, "base64"));
7656
+ const bytes = Buffer.from(data, "base64");
7657
+ const digest = createHash6("sha256").update(bytes).digest("hex");
7658
+ const file = path13.join(layout.root, ".peach-libraries", `lib${target}-${digest}.a`);
7659
+ files.set(file, bytes);
7459
7660
  libraries.set(target, file);
7460
7661
  }
7461
7662
  for (const [file, contents] of Object.entries(input.files)) {
7462
7663
  if (file === "Package.swift") continue;
7463
- files.set(path12.join(base, file), compiled.get(file) ?? contents);
7664
+ files.set(path13.join(base, file), compiled.get(file) ?? contents);
7464
7665
  }
7465
7666
  const manifestTargets = targets.length > 0 ? targets : [
7466
7667
  {
7467
7668
  name: "App",
7468
- path: path12.relative(layout.root, layout.sources).split(path12.sep).join("/"),
7669
+ path: path13.relative(layout.root, layout.sources).split(path13.sep).join("/"),
7469
7670
  executable: true,
7470
7671
  languageMode: 5,
7471
7672
  mainActorIsolation: false,
7472
7673
  resources: false
7473
7674
  }
7474
7675
  ];
7475
- const frameworkLink = prebuilt ? path12.join(layout.root, ".peach-framework-objects.rsp") : void 0;
7676
+ const reachesFrameworks = !distribution || Object.entries(input.files).some(
7677
+ ([file, source]) => file.endsWith(".swift") && file !== input.entry && file !== "Package.swift" || /\.mm?$/.test(file) || source.includes("dispatch_")
7678
+ ) || [...importedModules].some(
7679
+ (name2) => distribution.modules.includes(name2) && !targets.some((target) => target.name === name2)
7680
+ );
7681
+ const frameworkLink = prebuilt ? path13.join(layout.root, ".peach-framework-objects.rsp") : void 0;
7476
7682
  if (prebuilt && frameworkLink) {
7477
7683
  files.set(
7478
7684
  frameworkLink,
@@ -7480,7 +7686,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7480
7686
  );
7481
7687
  }
7482
7688
  files.set(
7483
- path12.join(layout.root, "Package.swift"),
7689
+ path13.join(layout.root, "Package.swift"),
7484
7690
  emitSwiftPackageManifest({
7485
7691
  root: layout.root,
7486
7692
  targets: manifestTargets,
@@ -7508,13 +7714,17 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7508
7714
  oneModule: input.oneModule,
7509
7715
  spriteKit: importsSpriteKit(input.files),
7510
7716
  distribution: distribution ?? void 0,
7717
+ distributionExcludes,
7511
7718
  deferDarwinOverlay: native.size > 0 && toolsetOrdersLibcxxBeforeDarwinOverlay(
7512
7719
  swiftSdkPaths(moduleRoot, nativeToolchain()).cFlags
7513
7720
  ),
7514
- distributionLink: {
7515
- path: path12.join(layout.root, ".peach-distribution-objects.rsp"),
7516
- files
7517
- },
7721
+ ...reachesFrameworks ? {
7722
+ distributionLink: {
7723
+ path: path13.join(layout.root, ".peach-distribution-objects.rsp"),
7724
+ files
7725
+ },
7726
+ lazyDistribution: input.lazyDistribution
7727
+ } : {},
7518
7728
  ...prebuilt && frameworkLink ? {
7519
7729
  prebuilt: {
7520
7730
  modules: prebuilt.modules,
@@ -7523,26 +7733,27 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7523
7733
  moduleMaps: prebuilt.moduleMaps
7524
7734
  }
7525
7735
  } : {},
7526
- libraries
7736
+ libraries,
7737
+ ...input.defaultLocalization ? { defaultLocalization: input.defaultLocalization } : {}
7527
7738
  }) + moduleFiles
7528
7739
  );
7529
7740
  }
7530
7741
  for (const [file, bytes] of Object.entries(input.packageFiles ?? {}))
7531
- files.set(path12.join(layout.root, file), Buffer.from(bytes, "base64"));
7742
+ files.set(path13.join(layout.root, file), Buffer.from(bytes, "base64"));
7532
7743
  for (const [file, bytes] of Object.entries(input.projectFiles ?? {})) {
7533
- const destination = path12.join(layout.root, file);
7744
+ const destination = path13.join(layout.root, file);
7534
7745
  if (files.has(destination)) continue;
7535
7746
  files.set(destination, Buffer.from(bytes, "base64"));
7536
7747
  }
7537
7748
  if (input.packageFiles || prebuilt) {
7538
7749
  files.set(
7539
- path12.join(layout.root, ".peach-target-toolset.json"),
7750
+ path13.join(layout.root, ".peach-target-toolset.json"),
7540
7751
  JSON.stringify({
7541
7752
  schemaVersion: "1.0",
7542
7753
  swiftCompiler: {
7543
7754
  extraCLIOptions: [
7544
7755
  "-I",
7545
- distribution ? path12.join(moduleRoot, "modules") : prebuilt ? prebuilt.modules : path12.join(layout.root, ".build", WASM_TRIPLE, "release", "Modules"),
7756
+ distribution ? distributionModulesPath(layout.root, moduleRoot, distributionExcludes) : prebuilt ? prebuilt.modules : path13.join(layout.root, ".build", WASM_TRIPLE, "release", "Modules"),
7546
7757
  ...prebuilt?.moduleMaps.flatMap((map) => [
7547
7758
  "-Xcc",
7548
7759
  `-fmodule-map-file=${map}`
@@ -7571,9 +7782,9 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7571
7782
  throw new Error(
7572
7783
  `swift resource target ${target.name} has no matching bundle assignment`
7573
7784
  );
7574
- const directory = layout.multi ? path12.join(layout.root, target.path) : layout.sources;
7785
+ const directory = layout.multi ? path13.join(layout.root, target.path) : layout.sources;
7575
7786
  files.set(
7576
- path12.join(directory, "ResourceBundleAccessor.generated.swift"),
7787
+ path13.join(directory, "ResourceBundleAccessor.generated.swift"),
7577
7788
  [
7578
7789
  "import Foundation",
7579
7790
  "",
@@ -7590,7 +7801,7 @@ function writeSwiftProject(layout, input, moduleRoot, prebuilt) {
7590
7801
  }
7591
7802
  for (const [file, source] of compiled)
7592
7803
  if (!Object.hasOwn(input.files, file))
7593
- files.set(path12.join(layout.multi ? layout.root : layout.sources, file), source);
7804
+ files.set(path13.join(layout.multi ? layout.root : layout.sources, file), source);
7594
7805
  syncSwiftTree(layout.root, files);
7595
7806
  const producers = [
7596
7807
  .../* @__PURE__ */ new Set([...[...native.values()].flatMap((value) => value.late?.producers ?? [])])
@@ -7625,13 +7836,13 @@ function outputOf(error) {
7625
7836
  return error instanceof Error ? error.message : String(error);
7626
7837
  }
7627
7838
  function builtArtifact(layout) {
7628
- const binDir = path12.join(layout.root, ".build", WASM_TRIPLE, "release");
7629
- const manifest = readFileSync7(path12.join(layout.root, "Package.swift"), "utf8");
7839
+ const binDir = path13.join(layout.root, ".build", WASM_TRIPLE, "release");
7840
+ const manifest = readFileSync7(path13.join(layout.root, "Package.swift"), "utf8");
7630
7841
  const executable = swiftManifestTargets(manifest).find((target) => target.executable);
7631
7842
  if (executable === void 0) {
7632
7843
  throw new Error("swift-compile: the written manifest names no executable target");
7633
7844
  }
7634
- const file = path12.join(binDir, `${executable.name}.wasm`);
7845
+ const file = path13.join(binDir, `${executable.name}.wasm`);
7635
7846
  if (!existsSync2(file)) {
7636
7847
  const found = existsSync2(binDir) ? readdirSync5(binDir).filter((name2) => name2.endsWith(".wasm")).sort() : [];
7637
7848
  throw new Error(
@@ -7642,7 +7853,7 @@ function builtArtifact(layout) {
7642
7853
  }
7643
7854
  function projectDiagnostic(output, layout, files) {
7644
7855
  const base = layout.multi ? layout.root : layout.sources;
7645
- const prefix = `${base}${path12.sep}`;
7856
+ const prefix = `${base}${path13.sep}`;
7646
7857
  return designTimeDiagnostic(output, files).split("\n").filter((line) => !SWIFTPM_NOISE.test(line)).map((line) => line.startsWith(prefix) ? line.slice(prefix.length) : line).join("\n").trim();
7647
7858
  }
7648
7859
  var ROOT_LOCKS = Symbol.for("peachsim.swiftCompile.rootLocks");
@@ -7678,12 +7889,12 @@ function serialize(root, work, signal) {
7678
7889
  function readCompiledArtifact(directory, hash) {
7679
7890
  try {
7680
7891
  const receipt = JSON.parse(
7681
- readFileSync7(path12.join(directory, "artifact.json"), "utf8")
7892
+ readFileSync7(path13.join(directory, "artifact.json"), "utf8")
7682
7893
  );
7683
7894
  if (!receipt || typeof receipt !== "object" || !("hash" in receipt) || receipt.hash !== hash || !("icu" in receipt) || typeof receipt.icu !== "string" || !("wasm" in receipt) || typeof receipt.wasm !== "string")
7684
7895
  return null;
7685
- const bytes = readFileSync7(path12.join(directory, "app.wasm"));
7686
- const gzip2 = readFileSync7(path12.join(directory, "icu.gz"));
7896
+ const bytes = readFileSync7(path13.join(directory, "app.wasm"));
7897
+ const gzip2 = readFileSync7(path13.join(directory, "icu.gz"));
7687
7898
  if (createHash6("sha256").update(bytes).digest("hex") !== receipt.wasm || createHash6("sha256").update(gzip2).digest("hex") !== receipt.icu || bytes.length < 8 || bytes.readUInt32LE(0) !== 1836278016 || bytes.readUInt32LE(4) !== 1)
7688
7899
  return null;
7689
7900
  return { hash, bytes, icu: { sha256: receipt.icu, gzip: gzip2 } };
@@ -7694,14 +7905,14 @@ function readCompiledArtifact(directory, hash) {
7694
7905
  }
7695
7906
  }
7696
7907
  function saveCompiledArtifact(root, artifact) {
7697
- const directory = path12.join(root, "artifact");
7908
+ const directory = path13.join(root, "artifact");
7698
7909
  mkdirSync2(directory, { recursive: true });
7699
- const pending = mkdtempSync2(path12.join(root, ".artifact-"));
7910
+ const pending = mkdtempSync2(path13.join(root, ".artifact-"));
7700
7911
  try {
7701
- writeFileSync3(path12.join(pending, "app.wasm"), artifact.bytes);
7702
- writeFileSync3(path12.join(pending, "icu.gz"), artifact.icu.gzip);
7912
+ writeFileSync3(path13.join(pending, "app.wasm"), artifact.bytes);
7913
+ writeFileSync3(path13.join(pending, "icu.gz"), artifact.icu.gzip);
7703
7914
  writeFileSync3(
7704
- path12.join(pending, "artifact.json"),
7915
+ path13.join(pending, "artifact.json"),
7705
7916
  JSON.stringify({
7706
7917
  hash: artifact.hash,
7707
7918
  wasm: createHash6("sha256").update(artifact.bytes).digest("hex"),
@@ -7709,7 +7920,7 @@ function saveCompiledArtifact(root, artifact) {
7709
7920
  })
7710
7921
  );
7711
7922
  for (const file of ["app.wasm", "icu.gz", "artifact.json"]) {
7712
- renameSync(path12.join(pending, file), path12.join(directory, file));
7923
+ renameSync(path13.join(pending, file), path13.join(directory, file));
7713
7924
  }
7714
7925
  } finally {
7715
7926
  rmSync3(pending, { recursive: true, force: true });
@@ -7731,16 +7942,16 @@ function renewSharedArtifact(sharedRoot) {
7731
7942
  function pruneSharedArtifacts(parent, keep) {
7732
7943
  const entries = [];
7733
7944
  for (const name2 of readdirSync5(parent)) {
7734
- const directory = path12.join(parent, name2);
7945
+ const directory = path13.join(parent, name2);
7735
7946
  if (name2.startsWith(RETIRED_PREFIX)) {
7736
7947
  rmSync3(directory, { recursive: true, force: true });
7737
7948
  continue;
7738
7949
  }
7739
7950
  try {
7740
7951
  let bytes = 0;
7741
- for (const file of readdirSync5(path12.join(directory, "artifact"))) {
7952
+ for (const file of readdirSync5(path13.join(directory, "artifact"))) {
7742
7953
  try {
7743
- bytes += statSync(path12.join(directory, "artifact", file)).size;
7954
+ bytes += statSync(path13.join(directory, "artifact", file)).size;
7744
7955
  } catch (error) {
7745
7956
  if (!vanished(error)) throw error;
7746
7957
  }
@@ -7755,9 +7966,9 @@ function pruneSharedArtifacts(parent, keep) {
7755
7966
  if (total <= SHARED_ARTIFACT_BUDGET_BYTES) break;
7756
7967
  if (entry.directory === keep || Date.now() - entry.used < SHARED_ARTIFACT_GRACE_MS)
7757
7968
  continue;
7758
- const retired = path12.join(
7969
+ const retired = path13.join(
7759
7970
  parent,
7760
- `${RETIRED_PREFIX}${process.pid}-${path12.basename(entry.directory)}`
7971
+ `${RETIRED_PREFIX}${process.pid}-${path13.basename(entry.directory)}`
7761
7972
  );
7762
7973
  try {
7763
7974
  if (statSync(entry.directory).mtimeMs !== entry.used) continue;
@@ -7773,7 +7984,7 @@ function pruneSharedArtifacts(parent, keep) {
7773
7984
  function saveSharedArtifact(sharedRoot, artifact) {
7774
7985
  saveCompiledArtifact(sharedRoot, artifact);
7775
7986
  renewSharedArtifact(sharedRoot);
7776
- pruneSharedArtifacts(path12.dirname(sharedRoot), sharedRoot);
7987
+ pruneSharedArtifacts(path13.dirname(sharedRoot), sharedRoot);
7777
7988
  }
7778
7989
  var retainedArtifacts = /* @__PURE__ */ new Map();
7779
7990
  function retain(root, artifact) {
@@ -7801,7 +8012,7 @@ function frameworkLibraryTargets(manifest) {
7801
8012
  }
7802
8013
  function linkedFrameworkTargets(moduleRoot, input) {
7803
8014
  const libraries = frameworkLibraryTargets(
7804
- readFileSync7(path12.join(moduleRoot, "Package.swift"), "utf8")
8015
+ readFileSync7(path13.join(moduleRoot, "Package.swift"), "utf8")
7805
8016
  );
7806
8017
  const targets = compileTargets(input);
7807
8018
  const planning = targets.length > 0 ? targets : [{ name: "App", path: "." }];
@@ -7842,7 +8053,7 @@ function linkedFrameworkTargets(moduleRoot, input) {
7842
8053
  return { products: linked, targets: linkedMembers };
7843
8054
  }
7844
8055
  function writeFrameworkLinkPackage(linkRoot, moduleRoot, products) {
7845
- const identity = path12.basename(moduleRoot).toLowerCase();
8056
+ const identity = path13.basename(moduleRoot).toLowerCase();
7846
8057
  const swiftString = (value) => `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
7847
8058
  const dependencies = products.map(
7848
8059
  (name2) => ` .product(name: ${swiftString(name2)}, package: ${swiftString(identity)}),`
@@ -7864,12 +8075,12 @@ ${dependencies}
7864
8075
  ]
7865
8076
  )
7866
8077
  `;
7867
- const sourceDir = path12.join(linkRoot, "Sources", FRAMEWORK_LINK_TARGET);
8078
+ const sourceDir = path13.join(linkRoot, "Sources", FRAMEWORK_LINK_TARGET);
7868
8079
  mkdirSync2(sourceDir, { recursive: true });
7869
- const manifestPath = path12.join(linkRoot, "Package.swift");
8080
+ const manifestPath = path13.join(linkRoot, "Package.swift");
7870
8081
  if (!existsSync2(manifestPath) || readFileSync7(manifestPath, "utf8") !== manifest)
7871
8082
  writeFileSync3(manifestPath, manifest);
7872
- const source = path12.join(sourceDir, "Link.swift");
8083
+ const source = path13.join(sourceDir, "Link.swift");
7873
8084
  if (!existsSync2(source)) writeFileSync3(source, "");
7874
8085
  }
7875
8086
  function frameworkLinkClosure(scratch2, roots) {
@@ -7881,7 +8092,7 @@ function frameworkLinkClosure(scratch2, roots) {
7881
8092
  const moduleMaps = /* @__PURE__ */ new Map();
7882
8093
  let pending = null;
7883
8094
  let compiling = null;
7884
- for (const line of readFileSync7(path12.join(scratch2, "release.yaml"), "utf8").split(
8095
+ for (const line of readFileSync7(path13.join(scratch2, "release.yaml"), "utf8").split(
7885
8096
  "\n"
7886
8097
  )) {
7887
8098
  const phony = phonyHeader.exec(line);
@@ -7955,14 +8166,14 @@ function removeUnbuiltModuleArtifacts(modulesDir, keep) {
7955
8166
  const dot = name2.indexOf(".");
7956
8167
  if (dot <= 0) continue;
7957
8168
  if (keep.has(name2.slice(0, dot))) continue;
7958
- rmSync3(path12.join(modulesDir, name2), { recursive: true, force: true });
8169
+ rmSync3(path13.join(modulesDir, name2), { recursive: true, force: true });
7959
8170
  }
7960
8171
  }
7961
8172
  async function compileFrameworkProducts(args) {
7962
8173
  const scratch2 = swiftFrameworkScratch(args.appRoot);
7963
8174
  mkdirSync2(scratch2, { recursive: true });
7964
8175
  const linkedTargets = linkedFrameworkTargets(args.moduleRoot, args.input);
7965
- const linkRoot = path12.join(scratch2, "link");
8176
+ const linkRoot = path13.join(scratch2, "link");
7966
8177
  writeFrameworkLinkPackage(linkRoot, args.moduleRoot, linkedTargets.products);
7967
8178
  await runCompiler(
7968
8179
  args.swift,
@@ -8007,21 +8218,28 @@ async function compileFrameworkProducts(args) {
8007
8218
  SWIFTPM_PROGRESS,
8008
8219
  SWIFTPM_NOISE
8009
8220
  );
8010
- const release = path12.join(scratch2, WASM_TRIPLE, "release");
8221
+ const release = path13.join(scratch2, WASM_TRIPLE, "release");
8011
8222
  const linked = frameworkLinkClosure(scratch2, linkedTargets.targets);
8012
8223
  const objects = linked.objects;
8013
- removeUnbuiltModuleArtifacts(path12.join(release, "Modules"), linked.modules);
8014
- const response = path12.join(scratch2, "autolink-objects.rsp");
8224
+ removeUnbuiltModuleArtifacts(path13.join(release, "Modules"), linked.modules);
8225
+ const response = path13.join(scratch2, "autolink-objects.rsp");
8015
8226
  writeFileSync3(response, objects.map((file) => JSON.stringify(file)).join("\n") + "\n");
8016
8227
  const extracted = await runCompiler(
8017
- path12.join(args.toolchainBin, "swift-autolink-extract"),
8228
+ path13.join(args.toolchainBin, "swift-autolink-extract"),
8018
8229
  [`@${response}`, "-o", "-"],
8019
8230
  args.buildOptions
8020
8231
  );
8021
8232
  rmSync3(response, { force: true });
8022
8233
  const link = extracted.split("\n").map((line) => line.trim()).filter((flag, index, all) => flag.length > 0 && all.indexOf(flag) === index);
8234
+ if (link.includes("-lFoundation"))
8235
+ objects.push(
8236
+ path13.join(
8237
+ swiftSdkPaths(args.moduleRoot, args.toolchainBin).resources,
8238
+ "wasi/NSStringFormatting.objc.o"
8239
+ )
8240
+ );
8023
8241
  return {
8024
- modules: path12.join(release, "Modules"),
8242
+ modules: path13.join(release, "Modules"),
8025
8243
  objects,
8026
8244
  link,
8027
8245
  moduleMaps: linked.moduleMaps
@@ -8030,7 +8248,7 @@ async function compileFrameworkProducts(args) {
8030
8248
  var SWIFT_LINK_STAMP = ".peach-link-stamp";
8031
8249
  var SWIFT_FRAMEWORK_KEY = ".peach-framework-key";
8032
8250
  function swiftFrameworkScratch(appRoot) {
8033
- return path12.join(path12.dirname(appRoot), `${path12.basename(appRoot)}.packages`);
8251
+ return path13.join(path13.dirname(appRoot), `${path13.basename(appRoot)}.packages`);
8034
8252
  }
8035
8253
  function swiftLinkStamp(args) {
8036
8254
  const hash = createHash6("sha256");
@@ -8058,11 +8276,11 @@ ${args.prebuilt.modules}
8058
8276
  `);
8059
8277
  for (const entry of readdirSync5(args.prebuilt.modules).sort())
8060
8278
  hash.update(`${entry}
8061
- ${statOf(path12.join(args.prebuilt.modules, entry))}`);
8279
+ ${statOf(path13.join(args.prebuilt.modules, entry))}`);
8062
8280
  return hash.digest("hex");
8063
8281
  }
8064
8282
  function retireStaleSwiftFrameworks(root, key) {
8065
- const receipt = path12.join(root, SWIFT_FRAMEWORK_KEY);
8283
+ const receipt = path13.join(root, SWIFT_FRAMEWORK_KEY);
8066
8284
  let previous = null;
8067
8285
  try {
8068
8286
  previous = readFileSync7(receipt, "utf8").trim();
@@ -8077,7 +8295,7 @@ function retireStaleSwiftFrameworks(root, key) {
8077
8295
  return true;
8078
8296
  }
8079
8297
  function retireStaleSwiftLink(root, stamp) {
8080
- const receipt = path12.join(root, SWIFT_LINK_STAMP);
8298
+ const receipt = path13.join(root, SWIFT_LINK_STAMP);
8081
8299
  let previous = null;
8082
8300
  try {
8083
8301
  previous = readFileSync7(receipt, "utf8").trim();
@@ -8086,7 +8304,7 @@ function retireStaleSwiftLink(root, stamp) {
8086
8304
  }
8087
8305
  writeFileSync3(receipt, `${stamp}
8088
8306
  `);
8089
- const retired = path12.join(root, ".build");
8307
+ const retired = path13.join(root, ".build");
8090
8308
  if (previous === stamp || !existsSync2(retired)) return false;
8091
8309
  rmSync3(retired, { recursive: true, force: true });
8092
8310
  return true;
@@ -8095,15 +8313,15 @@ function compileSwiftProjectUnit(input, options) {
8095
8313
  options.signal?.throwIfAborted();
8096
8314
  mkdirSync2(options.buildRoot, { recursive: true });
8097
8315
  const root = realpathSync(options.buildRoot);
8098
- const moduleRoot = path12.resolve(options.moduleRoot);
8316
+ const moduleRoot = path13.resolve(options.moduleRoot);
8099
8317
  const layout = {
8100
8318
  root,
8101
- sources: path12.join(root, "Sources", "App"),
8319
+ sources: path13.join(root, "Sources", "App"),
8102
8320
  multi: compileTargets(input).length > 0
8103
8321
  };
8104
8322
  const hash = swiftArtifactHash(input, options.release, moduleRoot);
8105
8323
  const frameworkKey = swiftProjectBuildKey(moduleRoot, options.release);
8106
- const sharedRoot = path12.join(rnxHomeDir(), "cache", "swift-projects", hash);
8324
+ const sharedRoot = path13.join(swiftCacheDir(), "swift-projects", hash);
8107
8325
  const report = (message) => {
8108
8326
  console.error(`[swift-project ${hash.slice(0, 16)}] ${message}`);
8109
8327
  options.onStage?.(message);
@@ -8117,8 +8335,8 @@ function compileSwiftProjectUnit(input, options) {
8117
8335
  report("reusing memory artifact");
8118
8336
  return retain(root, retained);
8119
8337
  }
8120
- const cached = readCompiledArtifact(path12.join(sharedRoot, "artifact"), hash);
8121
- const previous = cached ?? readCompiledArtifact(path12.join(root, "artifact"), hash);
8338
+ const cached = readCompiledArtifact(path13.join(sharedRoot, "artifact"), hash);
8339
+ const previous = cached ?? readCompiledArtifact(path13.join(root, "artifact"), hash);
8122
8340
  if (previous) {
8123
8341
  if (cached) renewSharedArtifact(sharedRoot);
8124
8342
  else saveSharedArtifact(sharedRoot, previous);
@@ -8127,8 +8345,8 @@ function compileSwiftProjectUnit(input, options) {
8127
8345
  }
8128
8346
  if (process.platform === "darwin" && process.env.TM_SESSION && !admittedMacBuilderSlot() && process.env.CI !== "true" && moduleRoot === sourceSwiftCheckout() && !swiftDistributionAt(moduleRoot)) {
8129
8347
  const requestRoot = mkdtempSync2(`${root}.builder-request-`);
8130
- const output = path12.join(requestRoot, "output");
8131
- const request = path12.join(requestRoot, "request.json");
8348
+ const output = path13.join(requestRoot, "output");
8349
+ const request = path13.join(requestRoot, "request.json");
8132
8350
  writeFileSync3(
8133
8351
  request,
8134
8352
  JSON.stringify({
@@ -8142,12 +8360,12 @@ function compileSwiftProjectUnit(input, options) {
8142
8360
  })
8143
8361
  );
8144
8362
  try {
8145
- const repo = path12.resolve(moduleRoot, "../..");
8363
+ const repo = path13.resolve(moduleRoot, "../..");
8146
8364
  report("requesting builder admission or cached result");
8147
8365
  await runCompiler(
8148
8366
  "bun",
8149
8367
  [
8150
- path12.join(repo, "scripts/build/swift-project.ts"),
8368
+ path13.join(repo, "scripts/build/swift-project.ts"),
8151
8369
  "--request",
8152
8370
  request,
8153
8371
  "--output",
@@ -8181,12 +8399,12 @@ function compileSwiftProjectUnit(input, options) {
8181
8399
  return withSwiftRootLock(
8182
8400
  root,
8183
8401
  async (lease) => {
8184
- const built = readCompiledArtifact(path12.join(sharedRoot, "artifact"), hash);
8402
+ const built = readCompiledArtifact(path13.join(sharedRoot, "artifact"), hash);
8185
8403
  if (built) {
8186
8404
  report("reusing verified disk artifact");
8187
8405
  return retain(root, built);
8188
8406
  }
8189
- const swift = path12.join(options.toolchainBin, "swift");
8407
+ const swift = path13.join(options.toolchainBin, "swift");
8190
8408
  if (!existsSync2(swift)) {
8191
8409
  throw new Error(
8192
8410
  `swift-compile: no swift.org toolchain at ${options.toolchainBin}; install ${options.release} and its matching wasm sdk`
@@ -8209,8 +8427,8 @@ function compileSwiftProjectUnit(input, options) {
8209
8427
  // shipped host plugins resolve against the selected compiler's runtime.
8210
8428
  ...process.platform === "linux" ? {
8211
8429
  LD_LIBRARY_PATH: [
8212
- path12.resolve(options.toolchainBin, "../lib/swift/linux"),
8213
- path12.resolve(options.toolchainBin, "../lib/swift/host"),
8430
+ path13.resolve(options.toolchainBin, "../lib/swift/linux"),
8431
+ path13.resolve(options.toolchainBin, "../lib/swift/host"),
8214
8432
  process.env.LD_LIBRARY_PATH
8215
8433
  ].filter(Boolean).join(":")
8216
8434
  } : {}
@@ -8259,7 +8477,7 @@ function compileSwiftProjectUnit(input, options) {
8259
8477
  ...swiftSdkOptions(),
8260
8478
  "--swift-sdk",
8261
8479
  sdk,
8262
- ...input.packageFiles || prebuilt ? ["--toolset", path12.join(root, ".peach-target-toolset.json")] : [],
8480
+ ...input.packageFiles || prebuilt ? ["--toolset", path13.join(root, ".peach-target-toolset.json")] : [],
8263
8481
  "-c",
8264
8482
  "release",
8265
8483
  "-Xswiftc",
@@ -8301,7 +8519,7 @@ function compileSwiftProjectUnit(input, options) {
8301
8519
  );
8302
8520
  } catch (error) {
8303
8521
  const output = outputOf(error);
8304
- const moduleCache = path12.join(
8522
+ const moduleCache = path13.join(
8305
8523
  root,
8306
8524
  ".build",
8307
8525
  WASM_TRIPLE,
@@ -8386,7 +8604,10 @@ export {
8386
8604
  swiftSdkPaths,
8387
8605
  swiftSourceAsIOS,
8388
8606
  swiftSourceClosure,
8607
+ swiftSystemLibraryExclusions,
8608
+ swiftSystemLibrarySurface,
8389
8609
  swiftTargetDependencies,
8610
+ swiftTypedApplicationEntry,
8390
8611
  syncSwiftTree,
8391
8612
  withNativeSourceGlue,
8392
8613
  wrapUIApplicationMainEntry,