peachsim 0.1.1716 → 0.1.1738

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 (282) 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 +83 -822
  8. package/cli/commands/coverage-swift.ts +112 -4
  9. package/cli/commands/daemon.ts +8 -0
  10. package/cli/commands/detox.ts +3 -0
  11. package/cli/commands/doctor.ts +19 -2
  12. package/cli/commands/inspect/actions.ts +74 -14
  13. package/cli/commands/inspect/core.ts +5 -1
  14. package/cli/commands/inspect/settling.ts +5 -2
  15. package/cli/commands/inspect/wait-ready.ts +6 -0
  16. package/cli/commands/inspect.ts +48 -45
  17. package/cli/commands/kotlin.ts +12 -2
  18. package/cli/commands/package.ts +760 -0
  19. package/cli/commands/serve.ts +6 -0
  20. package/cli/commands/shell-url.ts +838 -0
  21. package/cli/commands/swift.ts +42 -102
  22. package/cli/commands/test.ts +20 -0
  23. package/cli/commands/upload.ts +1 -1
  24. package/cli/device-option.ts +1 -1
  25. package/cli/main.ts +13 -1
  26. package/cli/native-input.ts +199 -0
  27. package/cli/outbound-endpoints.ts +26 -1
  28. package/cli/packaged-app-launcher.ts +95 -0
  29. package/cli/scene-video.ts +36 -12
  30. package/detox/index.ts +196 -24
  31. package/dist-lib/agent-daemon-client.cjs +1 -1
  32. package/dist-lib/agent-events.cjs +1 -1
  33. package/dist-lib/attached-projects.cjs +5 -2
  34. package/dist-lib/auth/shared-session.cjs +5 -2
  35. package/dist-lib/backend-origin.cjs +1 -1
  36. package/dist-lib/beta.cjs +1 -1
  37. package/dist-lib/beta.mjs +1 -1
  38. package/dist-lib/bridge-constants.cjs +1 -1
  39. package/dist-lib/bridge-contract-input.cjs +1 -1
  40. package/dist-lib/bridge-contract-input.mjs +1 -1
  41. package/dist-lib/bridge-contract.cjs +1 -1
  42. package/dist-lib/bridge-contract.mjs +1 -1
  43. package/dist-lib/bundle-channel.cjs +39889 -31873
  44. package/dist-lib/capture-contract.cjs +1 -1
  45. package/dist-lib/capture-contract.mjs +1 -1
  46. package/dist-lib/cloud-contract.cjs +1 -1
  47. package/dist-lib/cloud-contract.mjs +1 -1
  48. package/dist-lib/cloud-test-args.cjs +1 -1
  49. package/dist-lib/cloud-test-args.mjs +1 -1
  50. package/dist-lib/cloud.cjs +1 -1
  51. package/dist-lib/cloud.mjs +1 -1
  52. package/dist-lib/config.cjs +1 -1
  53. package/dist-lib/config.mjs +1 -1
  54. package/dist-lib/detox/index.cjs +195 -63
  55. package/dist-lib/dev-bundle-resolution.cjs +14 -13
  56. package/dist-lib/expo-swift-bundle.cjs +18507 -11835
  57. package/dist-lib/expo-swift-metadata.cjs +4 -1
  58. package/dist-lib/expo-swift-metadata.mjs +3 -1
  59. package/dist-lib/home-paths.cjs +27 -3
  60. package/dist-lib/host/bridge-host.cjs +28373 -24090
  61. package/dist-lib/host/fetch-proxy-handler.cjs +235 -225
  62. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  63. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  64. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  65. package/dist-lib/host/websocket-proxy.cjs +1 -1
  66. package/dist-lib/index.cjs +915 -399
  67. package/dist-lib/jump-to-source-babel.cjs +1 -1
  68. package/dist-lib/jump-to-source-native.cjs +1 -1
  69. package/dist-lib/kotlin-host.cjs +335 -47
  70. package/dist-lib/menu.cjs +13 -1
  71. package/dist-lib/menu.mjs +13 -1
  72. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  73. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  74. package/dist-lib/metro-production-bundle.cjs +1 -1
  75. package/dist-lib/metro-production-bundle.mjs +1 -1
  76. package/dist-lib/metro.cjs +918 -411
  77. package/dist-lib/native-app-identity-project.cjs +703 -283
  78. package/dist-lib/native-app-identity-project.mjs +500 -87
  79. package/dist-lib/native-app-identity.cjs +13 -2
  80. package/dist-lib/native-app-identity.mjs +13 -2
  81. package/dist-lib/native-firebase-metadata.cjs +1 -1
  82. package/dist-lib/native-firebase-metadata.mjs +1 -1
  83. package/dist-lib/plist.cjs +1 -1
  84. package/dist-lib/plist.mjs +1 -1
  85. package/dist-lib/profiles.cjs +5 -2
  86. package/dist-lib/public-brand.cjs +1 -1
  87. package/dist-lib/public-origins-lib-esm.json +28 -23
  88. package/dist-lib/public-origins-lib.json +418 -224
  89. package/dist-lib/react-native-host-modules.cjs +35 -2
  90. package/dist-lib/react-native-host-modules.mjs +35 -2
  91. package/dist-lib/reap-browser.cjs +12 -4
  92. package/dist-lib/scripts/dev-server-scanner.cjs +15 -8
  93. package/dist-lib/sdk.cjs +17 -7
  94. package/dist-lib/sdk.mjs +16 -7
  95. package/dist-lib/skills.cjs +44825 -29141
  96. package/dist-lib/swift-compile.cjs +616 -400
  97. package/dist-lib/swift-compile.mjs +528 -315
  98. package/dist-lib/swift-package.cjs +1 -1
  99. package/dist-lib/swift-package.mjs +1 -1
  100. package/dist-lib/swift-submit.cjs +2 -2
  101. package/dist-lib/swift-submit.mjs +2 -2
  102. package/dist-lib/swift-toolchain.cjs +105 -17
  103. package/dist-lib/swift.cjs +1 -1
  104. package/dist-lib/vite-swift.cjs +4660 -2252
  105. package/dist-lib/vite.cjs +248 -234
  106. package/dist-lib/worklet-executable.cjs +1 -1
  107. package/dist-lib/worklet-executable.mjs +1 -1
  108. package/dist-types/packages/peach-compat/src/stubs/native-seams/react-native-cookies.d.ts +17 -8
  109. package/dist-types/packages/peach-engine/src/engine/canvaskit-renderer.d.ts +1 -0
  110. package/dist-types/packages/peach-engine/src/engine/font-config.d.ts +7 -4
  111. package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +9 -6
  112. package/dist-types/packages/peach-engine/src/engine/liquid-glass.d.ts +0 -5
  113. package/dist-types/packages/peach-engine/src/engine/memory-counts.d.ts +11 -1
  114. package/dist-types/packages/peach-engine/src/engine/node.d.ts +5 -12
  115. package/dist-types/packages/peach-engine/src/engine/render-damage.d.ts +2 -2
  116. package/dist-types/packages/peach-engine/src/engine/text-first-baseline.d.ts +5 -0
  117. package/dist-types/packages/peach-engine/src/engine/text-paragraph.d.ts +1 -0
  118. package/dist-types/packages/peach-engine/src/engine/types.d.ts +3 -0
  119. package/dist-types/packages/peach-engine/src/native-preview-bundle.d.ts +2 -0
  120. package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +9 -0
  121. package/dist-types/packages/peach-engine/src/render-worker/host-service-protocol.d.ts +3 -0
  122. package/dist-types/packages/peach-engine/src/render-worker/native-ui-commandContract.d.ts +1 -1
  123. package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +7 -2
  124. package/dist-types/packages/peach-engine/src/render-worker/shell-protocol.d.ts +5 -0
  125. package/dist-types/packages/peach-engine/src/render-worker/tree-sync-port.d.ts +1 -1
  126. package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +36 -2
  127. package/dist-types/packages/peach-engine/src/shell-events.d.ts +1 -0
  128. package/dist-types/packages/peach-globals/src/audioBridgeContract.d.ts +5 -0
  129. package/dist-types/packages/peach-globals/src/index.d.ts +1 -1
  130. package/dist-types/packages/peach-globals/src/keyboardBridgeContract.d.ts +11 -0
  131. package/dist-types/packages/peach-globals/src/shellBridgeContract.d.ts +1 -0
  132. package/dist-types/packages/peach-globals/src/testBridgeContract.d.ts +9 -2
  133. package/dist-types/packages/peach-kit/src/capabilities.d.ts +1 -0
  134. package/kotlin/README.md +3 -0
  135. package/kotlin/sdk.tar.gz +0 -0
  136. package/package.json +1 -1
  137. package/runtime-companion.json +1 -1
  138. package/scripts/dev-server-scanner.ts +12 -25
  139. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccount.h +55 -0
  140. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountCredential.h +35 -0
  141. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountStore.h +94 -0
  142. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountType.h +53 -0
  143. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACError.h +37 -0
  144. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/Accounts.h +13 -0
  145. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/AccountsDefines.h +13 -0
  146. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Modules/module.modulemap +5 -0
  147. package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/ASFoundation.h +52 -0
  148. package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/ASWebAuthenticationSession.h +128 -0
  149. package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/ASWebAuthenticationSessionCallback.h +35 -0
  150. package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/AuthenticationServices.h +3 -0
  151. package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Modules/module.modulemap +5 -0
  152. package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFHTTPMessage.h +724 -0
  153. package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetwork.h +4 -0
  154. package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetworkDefs.h +27 -0
  155. package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Modules/module.modulemap +5 -0
  156. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFURL.h +1301 -0
  157. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.h +3 -1
  158. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocationManager.h +21 -50
  159. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLRegion.h +6 -6
  160. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes +58 -3
  161. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h +711 -46
  162. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h +12 -0
  163. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIInterface.h +23 -0
  164. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h +7 -9
  165. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIOrientation.h +14 -0
  166. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIStringDrawing.h +12 -0
  167. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIView.h +14 -0
  168. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIViewAnimating.h +12 -0
  169. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIViewController.h +16 -0
  170. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIWindow.h +2 -0
  171. package/sdk/ios/usr/include/ConditionalMacros.h +619 -0
  172. package/sdk/ios/usr/include/module.modulemap +1 -0
  173. package/sdk/ios/usr/include/objc/objc-sync.h +59 -0
  174. package/sdk/ios/usr/include/os/signpost.h +414 -0
  175. package/sdk/ios/usr/include/os.modulemap +10 -0
  176. package/sdk/ios/usr/include/sys/cdefs.h +5 -0
  177. package/sdk/ios/usr/include/sys/ioccom.h +99 -0
  178. package/sdk/ios/usr/include/sys/syslog.h +236 -0
  179. package/sdk/ios/usr/include/syslog.h +24 -0
  180. package/sdk/ios/wasm/include/errno.h +4 -20
  181. package/sdk/ios/wasm/include/fcntl.h +4 -2
  182. package/sdk/ios/wasm/include/pthread.h +3 -0
  183. package/sdk/ios/wasm/include/setjmp.h +57 -0
  184. package/sdk/ios/wasm/include/stdio.h +24 -0
  185. package/sdk/ios/wasm/include/stdlib.h +32 -7
  186. package/sdk/ios/wasm/include/sys/file.h +7 -0
  187. package/sdk/ios/wasm/include/sys/ioctl.h +6 -0
  188. package/sdk/ios/wasm/include/sys/resource.h +2 -2
  189. package/sdk/ios/wasm/include/sys/syscall.h +9 -0
  190. package/sdk/ios/wasm/include/sys/time.h +10 -0
  191. package/sdk/ios/wasm/include/unistd.h +12 -3
  192. package/sdk/native-hashes.json +4 -3
  193. package/skills/contrast/SKILL.md +2 -1
  194. package/skills/peach-debug/SKILL.md +0 -1
  195. package/skills/peach-perf/SKILL.md +0 -1
  196. package/skills/peach-setup/SKILL.md +0 -1
  197. package/skills/peach-test/SKILL.md +7 -4
  198. package/skills/peach-visual/SKILL.md +0 -1
  199. package/src/admitted-mac-build.ts +3 -0
  200. package/src/android-app-identity.ts +18 -0
  201. package/src/android-autolinking.ts +1 -0
  202. package/src/android-bridge-packages.ts +279 -0
  203. package/src/android-root-module.ts +9 -9
  204. package/src/appPackageContract.ts +83 -0
  205. package/src/bridge-contract.ts +50 -0
  206. package/src/bundle-channel.mjs +41 -6
  207. package/src/cli-runtime.ts +9 -5
  208. package/src/dev-bundle-resolution.ts +7 -27
  209. package/src/dom-source-reference.ts +15 -0
  210. package/src/expo-discovery-cache.ts +134 -26
  211. package/src/expo-kotlin-host.ts +97 -26
  212. package/src/expo-manifest-body.ts +33 -0
  213. package/src/expo-native-workspace.ts +158 -38
  214. package/src/expo-swift-host.ts +350 -75
  215. package/src/expo-swift-ready.ts +5 -1
  216. package/src/expoKotlinContract.ts +12 -2
  217. package/src/expoSwiftContract.ts +10 -0
  218. package/src/generated/swift-c-predefines.json +1 -1
  219. package/src/home-paths.ts +41 -2
  220. package/src/host/app-package-handler.ts +47 -0
  221. package/src/host/bridge-host.ts +8 -0
  222. package/src/host/fetch-proxy-handler.ts +10 -0
  223. package/src/host/staged-host-files.ts +18 -0
  224. package/src/index.ts +3 -0
  225. package/src/kotlin-host.ts +225 -48
  226. package/src/kotlin-instance-source.ts +126 -0
  227. package/src/kotlinSdkContract.ts +2 -1
  228. package/src/menu.ts +14 -0
  229. package/src/native-app-identity-project.ts +7 -2
  230. package/src/native-app-identity.ts +11 -0
  231. package/src/native-firebase-config.ts +24 -1
  232. package/src/native-prebuilt.ts +154 -0
  233. package/src/nitro-adapter.lock.json +270 -270
  234. package/src/nitro-adapter.ts +56 -50
  235. package/src/nitro-bundle.ts +92 -74
  236. package/src/nitro-compile.ts +45 -14
  237. package/src/nitro-dependencies.ts +63 -46
  238. package/src/nitro-source.ts +64 -26
  239. package/src/nitroAdapterContract.ts +146 -98
  240. package/src/nitroContract.ts +71 -21
  241. package/src/react-native-bridge-modules.ts +70 -42
  242. package/src/react-native-host-modules.ts +34 -1
  243. package/src/reactNativeConfigurationContract.ts +14 -0
  244. package/src/reap-browser.ts +15 -3
  245. package/src/sdk.ts +5 -0
  246. package/src/settingsContract.ts +38 -1
  247. package/src/sim-client.ts +4 -1
  248. package/src/storageSnapshotContract.ts +32 -81
  249. package/src/swift-compile.ts +268 -89
  250. package/src/swift-coverage/indexdump.ts +22 -6
  251. package/src/swift-coverage/indexing.ts +4 -4
  252. package/src/swift-coverage/provenance.ts +1 -0
  253. package/src/swift-coverage/sdk.ts +104 -20
  254. package/src/swift-coverage/types.ts +34 -0
  255. package/src/swift-coverage/xcode-asset-symbols.ts +922 -0
  256. package/src/swift-coverage/xcode-assets.ts +89 -131
  257. package/src/swift-coverage/xcode.ts +10 -2
  258. package/src/swift-cxx-reachable.ts +2 -1
  259. package/src/swift-distribution.lock.json +20 -16
  260. package/src/swift-host.ts +98 -22
  261. package/src/swift-icu.ts +1 -1
  262. package/src/swift-link-roots.ts +118 -0
  263. package/src/swift-objc-compile.ts +144 -22
  264. package/src/swift-objc-import.ts +6 -0
  265. package/src/swift-objc-standin.ts +2 -14
  266. package/src/swift-package-manifest.ts +14 -6
  267. package/src/swift-packages.ts +75 -11
  268. package/src/swift-pdf-raster.ts +1 -0
  269. package/src/swift-root-lock.ts +17 -1
  270. package/src/swift-source-pods.ts +2 -10
  271. package/src/swift-standin-emit.ts +597 -57
  272. package/src/swift-standins.ts +599 -56
  273. package/src/swift-submit.ts +7 -1
  274. package/src/swift-toolchain.ts +140 -17
  275. package/src/turbo-bundle.ts +81 -0
  276. package/src/turbo-codegen-intake.ts +91 -0
  277. package/src/turbo-compile.ts +120 -0
  278. package/src/turbo-runtime.lock.json +69 -0
  279. package/src/turbo-source.ts +754 -0
  280. package/src/vite-plugin-one.ts +17 -12
  281. package/src/vite-plugin.ts +28 -15
  282. package/src/xcode-project.ts +223 -22
@@ -119,7 +119,13 @@ export const MAX_SWIFT_COMPILE_IMAGE_TOTAL_BYTES = 16 * 1024 * 1024
119
119
  // 49: synchronous PDFKit document inspection uses the shared PDF parser host.
120
120
  // 50: the PDFKit inspection reply carries each page rotation and crop box.
121
121
  // 51: PDFKit asks the PDF host for one page's glyph spans on demand.
122
- export const SWIFT_HOST_ABI = 51
122
+ // 52: the PDFKit inspection reply reports a password-locked document as
123
+ // `{ok: true, locked: true}`, distinct from bytes the parser rejects.
124
+ // 53: block-backed IMP signature keys can carry compiler-emitted invoke roles.
125
+ // 54: `rnx.draw_text` lays attributed runs out and answers premultiplied rgba.
126
+ // 55: NSInvocation calls IMPs of any encoding through host-minted callers
127
+ // (`peach.imp_caller_mint`).
128
+ export const SWIFT_HOST_ABI = 55
123
129
 
124
130
  export interface SwiftImageUpload {
125
131
  /** the raster file picked for the asset (has the extension). */
@@ -49,35 +49,157 @@ export function swiftSdkOptions(): string[] {
49
49
  }
50
50
 
51
51
  // host archives include the official driver/runtime and the qualified patched frontend.
52
- export const SWIFT_HOST_COMPILER_RELEASE = 'swift-6.4.0-RELEASE-custom-ecd2ad9d3fe59329'
53
- export const SWIFT_HOST_COMPILER_ID = 'ecd2ad9d3fe59329'
54
- const compilerArchives: Record<string, { checksum: string; manifest: string }> = {
55
- 'darwin-arm64': {
56
- checksum: 'ab42a13b34e410ca09737420d1ee1d6af417eec039ab44f9a60502bdb5c76506',
57
- manifest: '8a93b6b1e6ff577f6dacd81a511d415ca3b396698f9b0c4abc35a4ca807e9d1a',
52
+ export const SWIFT_HOST_COMPILER_RELEASE = 'swift-6.4.0-RELEASE-custom-81b2c791c27276bf'
53
+ export const SWIFT_HOST_COMPILER_ID = '81b2c791c27276bf'
54
+ // retain qualification for the published distribution while source builds advance.
55
+ const compilerArchives: Record<
56
+ string,
57
+ { identity: string; hosts: Record<string, { checksum: string; manifest: string }> }
58
+ > = {
59
+ 'swift-6.4.0-RELEASE-custom-0b2d0a9011c88e66': {
60
+ identity: '0b2d0a9011c88e66',
61
+ hosts: {
62
+ 'darwin-arm64': {
63
+ checksum: 'dc6a494227297ea657e8e5f7c5b4a861cb5e142bdbcfcb028ace2aeb19db90cc',
64
+ manifest: 'd8e9eee0fb9b847f1e9350525d6c68606df46101745f553332309ed026b3c26a',
65
+ },
66
+ 'linux-x64': {
67
+ checksum: '85c04b4496aea1657c21a47f448e01d6ccc1c7920d130a566db37fb8350a7be2',
68
+ manifest: '8451659e74235ad53b700c1afbe293512197900eb98cb1f79e36df2f5c85d511',
69
+ },
70
+ 'linux-arm64': {
71
+ checksum: '196606ed62c5c926d18e6ef0769cb1ab21c9943f9084070ddf14a7bc696768b8',
72
+ manifest: '85fb8d5b6527bd75003a6dbd25b68b22540665cf9df9b13f41f82e5d8acdbf1d',
73
+ },
74
+ },
58
75
  },
59
- 'linux-x64': {
60
- checksum: 'b174baa2c578fb32f09c79590d65d03951b04cdec52101b23a46c0b274249fc3',
61
- manifest: '330e6cbae5890111c22a58e645049a971eff30334c3f240c650fcfedfeab4ef6',
76
+ [SWIFT_HOST_COMPILER_RELEASE]: {
77
+ identity: SWIFT_HOST_COMPILER_ID,
78
+ hosts: {
79
+ 'darwin-arm64': {
80
+ checksum: 'bc51b83d9e2e01c9873875326544734486d3ff3a868d650379c304045e8838d3',
81
+ manifest: 'a26eb9cb4fbd1dbd7faac20cced1ec5e67745bd358aa1180cc4abc1a0d21d6e6',
82
+ },
83
+ 'linux-x64': {
84
+ checksum: 'ea63bbdecae14ff8e9e3f535b521fedc65d51b31521c5d10cc332cb91882d058',
85
+ manifest: 'b22b321ce3eb3fe044fa2122484a15c061f262c45d88a05b3fbace0a5bf038b6',
86
+ },
87
+ 'linux-arm64': {
88
+ checksum: '3eef4ed57830908515d8def2882e312f7cabeea57ccda5b2a7585401ef98cc48',
89
+ manifest: 'cfab342b8090fa83a697a391a7563cba14b771c24f07e1f8e19977f913ac88be',
90
+ },
91
+ },
92
+ },
93
+ }
94
+
95
+ // ICU-free libxml2.so.2 the CLI installs into its own toolchain when the host
96
+ // libxml2 moved past the .so.2 soname (Ubuntu 25.04+). built from pinned
97
+ // libxml2-2.9.14 without icu, python or lzma; a rebuild ships under a new
98
+ // versioned prefix, never by replacing these immutable bytes.
99
+ const linuxRuntimeLibs: Record<string, { url: string; checksum: string }> = {
100
+ x64: {
101
+ url: 'https://r2.sootsim.com/swift-linux-runtime/libxml2-2.9.14/x64/libxml2.so.2',
102
+ checksum: 'ae1982f7614096bdbd42301e7acc5f74be2aca295eb603cc81ad55d00ddde763',
62
103
  },
63
- 'linux-arm64': {
64
- checksum: '25f722334dd9d79391cb2e47301165e9ef98dd9a8036927652f3c5db3c56b2ae',
65
- manifest: '94e5667febf26f8a4ee8c5456f83f62d17453e503d261a4c46d2b80f872470ab',
104
+ arm64: {
105
+ url: 'https://r2.sootsim.com/swift-linux-runtime/libxml2-2.9.14/arm64/libxml2.so.2',
106
+ checksum: '70acdc2a54328159fdff4ec39f5e75bda7b8301af60698b88d8fa99766252b4b',
66
107
  },
67
108
  }
68
109
 
110
+ /** the pinned runtime library blob for a Linux architecture. */
111
+ export function swiftLinuxRuntimeLib(arch: string = process.arch): {
112
+ url: string
113
+ checksum: string
114
+ } {
115
+ const lib = linuxRuntimeLibs[arch]
116
+ if (!lib) throw new Error(`unsupported Swift Linux runtime host ${arch}`)
117
+ return { ...lib }
118
+ }
119
+
120
+ export interface SwiftLinuxRuntimePlan {
121
+ url: string
122
+ checksum: string
123
+ /** <root>/usr/lib/libxml2.so.2, reached from both toolchain RUNPATH legs. */
124
+ dest: string
125
+ /** <root>/usr/lib/swift/linux/libxml2.so.2 symlink to dest. */
126
+ link: string
127
+ }
128
+
129
+ /**
130
+ * pure decision: the runtime library install plan, or null when the
131
+ * toolchain is out of scope. the install is unconditional on supported
132
+ * Linux hosts: no distro probe, one bundled path. callers pass observed
133
+ * values so the policy stays testable without a Linux host or network.
134
+ */
135
+ export function swiftLinuxRuntimePlan(options: {
136
+ platform: NodeJS.Platform
137
+ arch: string
138
+ release: string
139
+ root: string
140
+ ownedRoot: string
141
+ }): SwiftLinuxRuntimePlan | null {
142
+ if (options.platform !== 'linux') return null
143
+ if (!options.release.includes('-custom-')) return null
144
+ if (path.resolve(options.root) !== path.resolve(options.ownedRoot)) return null
145
+ const { url, checksum } = swiftLinuxRuntimeLib(options.arch)
146
+ return {
147
+ url,
148
+ checksum,
149
+ dest: path.join(options.root, 'usr/lib/libxml2.so.2'),
150
+ link: path.join(options.root, 'usr/lib/swift/linux/libxml2.so.2'),
151
+ }
152
+ }
153
+
154
+ /**
155
+ * install the pinned libxml2.so.2 into a Peach-owned Linux toolchain.
156
+ * no-op on other platforms, upstream toolchains, elsewhere-owned trees
157
+ * and missing roots; an existing matching library is kept and relinked.
158
+ */
159
+ export function ensureSwiftLinuxRuntime(release: string): void {
160
+ if (process.platform !== 'linux' || !release.includes('-custom-')) return
161
+ const root = path.resolve(swiftToolchainBin(release), '../..')
162
+ if (!fs.existsSync(root)) return
163
+ const plan = swiftLinuxRuntimePlan({
164
+ platform: process.platform,
165
+ arch: process.arch,
166
+ release,
167
+ root,
168
+ ownedRoot: path.join(peachHome(), 'swift', 'toolchains', release),
169
+ })
170
+ if (!plan) return
171
+ fs.mkdirSync(path.dirname(plan.dest), { recursive: true })
172
+ fs.mkdirSync(path.dirname(plan.link), { recursive: true })
173
+ if (!fs.existsSync(plan.dest) || swiftFileChecksum(plan.dest) !== plan.checksum) {
174
+ process.stderr.write(`peach: installing Linux runtime libxml2.so.2 into ${root}…\n`)
175
+ const download = `${plan.dest}.${process.pid}.tmp`
176
+ try {
177
+ execFileSync('curl', ['-fsSL', '--show-error', plan.url, '-o', download], {
178
+ stdio: 'inherit',
179
+ })
180
+ if (swiftFileChecksum(download) !== plan.checksum)
181
+ throw new Error('declared Linux runtime checksum mismatch')
182
+ fs.renameSync(download, plan.dest)
183
+ } finally {
184
+ fs.rmSync(download, { force: true })
185
+ }
186
+ }
187
+ fs.rmSync(plan.link, { force: true })
188
+ fs.symlinkSync('../../libxml2.so.2', plan.link)
189
+ }
190
+
69
191
  export function swiftHostCompilerArchive(
70
192
  release: string,
71
193
  host = `${process.platform}-${process.arch}`,
72
194
  ) {
73
- if (release !== SWIFT_HOST_COMPILER_RELEASE)
74
- throw new Error(`unqualified host compiler ${release}`)
75
- const archive = compilerArchives[host]
195
+ const compiler = compilerArchives[release]
196
+ if (!compiler) throw new Error(`unqualified host compiler ${release}`)
197
+ const archive = compiler.hosts[host]
76
198
  if (!archive) throw new Error(`unsupported Swift compiler host ${host}`)
77
199
  return {
78
200
  ...archive,
79
- identity: SWIFT_HOST_COMPILER_ID,
80
- url: `https://r2.sootsim.com/swift-host-compiler/${SWIFT_HOST_COMPILER_ID}/${release}-${host}.tar.gz`,
201
+ identity: compiler.identity,
202
+ url: `https://r2.sootsim.com/swift-host-compiler/${compiler.identity}/${release}-${host}.tar.gz`,
81
203
  }
82
204
  }
83
205
 
@@ -463,6 +585,7 @@ function installSwiftSdkArchive(swift: string, sdk: SwiftWasmSdk, archive: strin
463
585
  /** verify the compiler and install a declared SDK under the shared store lock. */
464
586
  export function installSwiftWasmSdk(release: string, sdk: SwiftWasmSdk): void {
465
587
  validateSwiftSdkIdentity(sdk)
588
+ ensureSwiftLinuxRuntime(release)
466
589
  try {
467
590
  swiftToolchain(release, sdk)
468
591
  return
@@ -0,0 +1,81 @@
1
+ import { createRequire } from 'node:module'
2
+ import path from 'node:path'
3
+ import { PEACH_ANSWERED_NATIVE_PACKAGE_NAMES } from '../../peach-compat/src/generated/supported-native-packages'
4
+ import { prepareExpoNativeWorkspace } from './expo-native-workspace'
5
+ import { readIosAppTarget } from './native-app-identity-project'
6
+ import {
7
+ compiledModuleAssets,
8
+ compiledModuleRequestHandler,
9
+ type CompiledModuleAsset,
10
+ } from './nitro-bundle'
11
+ import { SWIFT_ENDPOINT_ENV, swiftDistributionRoot } from './swift-distribution'
12
+ import { icuUrl, type SwiftArtifact } from './swift-host'
13
+ import { compileTurboModule } from './turbo-compile'
14
+ import { discoverTurboProviders } from './turbo-source'
15
+ import type { TurboCompiledModule } from './nitroContract'
16
+
17
+ export const TURBO_ROUTE = '/__peach/turbo'
18
+
19
+ const answeredPackages: ReadonlySet<string> = new Set(PEACH_ANSWERED_NATIVE_PACKAGE_NAMES)
20
+
21
+ // every installed iOS pod that registers a C++ TurboModule compiles from its
22
+ // original source into one executable, with the same compiler and asset
23
+ // addresses as local native loads. package javascript is carried verbatim by
24
+ // its bundler. a package Peach answers itself (a seam resolves before the
25
+ // original module) is not compiled. asset urls are relative to `origin`.
26
+ export async function compileTurboApp(
27
+ appRoot: string,
28
+ origin: string,
29
+ moduleRoot?: string,
30
+ ): Promise<{ metadata: TurboCompiledModule; artifact: SwiftArtifact } | null> {
31
+ const providers = (await discoverTurboProviders(appRoot)).filter(
32
+ ({ name }) => !answeredPackages.has(name),
33
+ )
34
+ if (providers.length === 0) return null
35
+ // the runtime archive is built against the published distribution, as the
36
+ // Nitro adapter is
37
+ const module = moduleRoot ?? (await swiftDistributionRoot())
38
+ if (!module)
39
+ throw new Error(
40
+ `TurboModule compilation needs ${SWIFT_ENDPOINT_ENV} for the Swift distribution`,
41
+ )
42
+ const projectRoot = readIosAppTarget(appRoot)
43
+ ? appRoot
44
+ : (await prepareExpoNativeWorkspace(appRoot)).app
45
+ const { artifact, collection } = await compileTurboModule({
46
+ appRoot,
47
+ reactNativeRoot: path.dirname(
48
+ createRequire(path.join(appRoot, 'package.json')).resolve(
49
+ 'react-native/package.json',
50
+ ),
51
+ ),
52
+ providers,
53
+ moduleRoot: module,
54
+ projectRoot,
55
+ })
56
+ return {
57
+ artifact,
58
+ metadata: {
59
+ platform: 'ios',
60
+ packages: collection.providers.map(({ name, version }) => ({ name, version })),
61
+ url: `${origin}/__peach/swift/${artifact.hash}.wasm`,
62
+ hash: artifact.hash,
63
+ icuUrl: icuUrl(origin, artifact),
64
+ bundleFiles: artifact.package.bundleFiles.files,
65
+ },
66
+ }
67
+ }
68
+
69
+ export async function buildTurboBundle(
70
+ appRoot: string,
71
+ moduleRoot?: string,
72
+ ): Promise<{ metadata: TurboCompiledModule; assets: CompiledModuleAsset[] } | null> {
73
+ const compiled = await compileTurboApp(appRoot, '', moduleRoot)
74
+ if (!compiled) return null
75
+ return { metadata: compiled.metadata, assets: compiledModuleAssets(compiled.artifact) }
76
+ }
77
+
78
+ export const handleTurboRequest = compiledModuleRequestHandler(
79
+ 'TurboModule',
80
+ compileTurboApp,
81
+ )
@@ -0,0 +1,91 @@
1
+ // the native source an installed app's React Native codegen produces, from the
2
+ // app's own installed react-native. `pod install` runs exactly this script
3
+ // (react_native_pods.rb, codegen_utils.rb), so its output is the real
4
+ // ReactCodegen pod: each library's Spec headers and bindings, the module
5
+ // provider table naming every codegen TurboModule's class, and the podspecs.
6
+ // nothing here reimplements codegen, and nothing under the app is written.
7
+ import { execFile } from 'node:child_process'
8
+ import { createHash } from 'node:crypto'
9
+ import fs from 'node:fs'
10
+ import { createRequire } from 'node:module'
11
+ import path from 'node:path'
12
+ import { promisify } from 'node:util'
13
+ import { isRecord } from './is-record'
14
+
15
+ const run = promisify(execFile)
16
+
17
+ export interface TurboCodegenIntake {
18
+ reactNativeVersion: string
19
+ // <outDir>/build/generated/ios, where CocoaPods finds the generated pods
20
+ generatedRoot: string
21
+ // sha256 of each generated file, keyed by posix path under generatedRoot
22
+ files: Record<string, string>
23
+ }
24
+
25
+ // sha256 of every file under a directory, keyed by posix relative path
26
+ export function hashTree(root: string): Record<string, string> {
27
+ const hashes: Record<string, string> = {}
28
+ for (const entry of fs.readdirSync(root, { recursive: true, withFileTypes: true })) {
29
+ if (!entry.isFile()) continue
30
+ const file = path.join(entry.parentPath, entry.name)
31
+ hashes[path.relative(root, file).split(path.sep).join('/')] = createHash('sha256')
32
+ .update(fs.readFileSync(file))
33
+ .digest('hex')
34
+ }
35
+ return Object.fromEntries(Object.entries(hashes).sort(([a], [b]) => (a < b ? -1 : 1)))
36
+ }
37
+
38
+ // the real path of a target that may not exist yet: its nearest existing
39
+ // ancestor resolved, then the missing tail
40
+ function realTarget(target: string): string {
41
+ const resolved = path.resolve(target)
42
+ if (fs.existsSync(resolved)) return fs.realpathSync(resolved)
43
+ return path.join(realTarget(path.dirname(resolved)), path.basename(resolved))
44
+ }
45
+
46
+ /**
47
+ * runs the app's installed react-native codegen for iOS into outDir, which the
48
+ * caller owns as scratch: it must be new or empty and outside the app, and
49
+ * nothing is ever deleted. it throws with the script's own output when the app
50
+ * has no react-native or the script fails.
51
+ */
52
+ export async function runInstalledTurboCodegen(
53
+ appRoot: string,
54
+ outDir: string,
55
+ signal?: AbortSignal,
56
+ ): Promise<TurboCodegenIntake> {
57
+ const manifestPath = createRequire(path.join(appRoot, 'package.json')).resolve(
58
+ 'react-native/package.json',
59
+ )
60
+ const manifest: unknown = JSON.parse(fs.readFileSync(manifestPath, 'utf8'))
61
+ if (!isRecord(manifest) || typeof manifest.version !== 'string')
62
+ throw new Error(`${manifestPath}: no version`)
63
+ // RCT_SCRIPT_OUTPUT_DIR would move the output out from under outDir
64
+ const env = { ...process.env }
65
+ delete env.RCT_SCRIPT_OUTPUT_DIR
66
+ const app = fs.realpathSync(appRoot)
67
+ const out = realTarget(outDir)
68
+ if (out === app || out.startsWith(app + path.sep))
69
+ throw new Error(`${outDir}: codegen output must be outside the app ${appRoot}`)
70
+ if (fs.existsSync(out) && fs.readdirSync(out).length > 0)
71
+ throw new Error(`${outDir}: codegen output directory must be new or empty`)
72
+ await run(
73
+ 'node',
74
+ [
75
+ path.join(path.dirname(manifestPath), 'scripts/generate-codegen-artifacts.js'),
76
+ '-p',
77
+ appRoot,
78
+ '-o',
79
+ outDir,
80
+ '-t',
81
+ 'ios',
82
+ ],
83
+ { env, signal },
84
+ )
85
+ const generatedRoot = path.join(outDir, 'build/generated/ios')
86
+ return {
87
+ reactNativeVersion: manifest.version,
88
+ generatedRoot,
89
+ files: hashTree(generatedRoot),
90
+ }
91
+ }
@@ -0,0 +1,120 @@
1
+ import { createHash } from 'node:crypto'
2
+ import fs from 'node:fs'
3
+ import os from 'node:os'
4
+ import path from 'node:path'
5
+ import { readIosAppTarget } from './native-app-identity-project'
6
+ import {
7
+ committedAdapterLocks,
8
+ resolveAdapterArchive,
9
+ type AdapterArchive,
10
+ } from './nitro-adapter'
11
+ import { syncSwiftTree, type SwiftCompileInput } from './swift-compile'
12
+ import { artifactFor, projectFor, type SwiftArtifact } from './swift-host'
13
+ import {
14
+ collectTurboSources,
15
+ prepareTurboSourceDependencies,
16
+ TURBO_CORE_TARGET,
17
+ type TurboProvider,
18
+ type TurboSourceCollection,
19
+ } from './turbo-source'
20
+
21
+ // every provider's original sources, React Native's TurboModule core and the
22
+ // verified runtime archive form one executable. the entry runs each provider's
23
+ // transcribed +load, as the app's image loads them before React Native starts,
24
+ // then installs the binding on the archive's runtime.
25
+ export function collectTurboCompileInput(
26
+ collection: TurboSourceCollection,
27
+ runtime: AdapterArchive,
28
+ iosDeploymentTarget: string,
29
+ ): SwiftCompileInput {
30
+ const files = { ...collection.files }
31
+ const entry = 'Sources/PeachTurboApp/main.swift'
32
+ const loaders = [...new Set(collection.loads.map(({ target }) => target))]
33
+ files[entry] =
34
+ `import ${TURBO_CORE_TARGET}\n${loaders.map((target) => `import ${target}\n`).join('')}` +
35
+ `${collection.loads.map(({ symbol }) => `${symbol}()\n`).join('')}peachTurboInitialize()\n`
36
+ files['Package.swift'] = [
37
+ '// swift-tools-version: 6.2',
38
+ 'import PackageDescription',
39
+ `let package = Package(name: "PeachNativeModule", platforms: [.iOS(${JSON.stringify(iosDeploymentTarget)})], targets: [`,
40
+ ...collection.targets.map(
41
+ (target) =>
42
+ `.target(name: ${JSON.stringify(target.name)}, dependencies: ${JSON.stringify(target.dependencies?.map((dependency) => dependency.name) ?? [])}, path: ${JSON.stringify(target.path)}, cxxSettings: [${(
43
+ target.cxxDefines ?? []
44
+ )
45
+ .map((define) => {
46
+ const [name, ...value] = define.split('=')
47
+ return value.length
48
+ ? `.define(${JSON.stringify(name)}, to: ${JSON.stringify(value.join('='))})`
49
+ : `.define(${JSON.stringify(name)})`
50
+ })
51
+ .join(', ')}]),`,
52
+ ),
53
+ `.executableTarget(name: "PeachTurboApp", dependencies: ${JSON.stringify([TURBO_CORE_TARGET, ...loaders])}, swiftSettings: [.interoperabilityMode(.Cxx)]),`,
54
+ '], cxxLanguageStandard: .cxx20)',
55
+ '',
56
+ ].join('\n')
57
+ return {
58
+ files,
59
+ entry,
60
+ libraries: { [TURBO_CORE_TARGET]: runtime.base64 },
61
+ lazyDistribution: true,
62
+ }
63
+ }
64
+
65
+ export async function compileTurboModule(options: {
66
+ appRoot: string
67
+ reactNativeRoot: string
68
+ providers: TurboProvider[]
69
+ moduleRoot: string
70
+ projectRoot: string
71
+ }): Promise<{ artifact: SwiftArtifact; collection: TurboSourceCollection }> {
72
+ await prepareTurboSourceDependencies(options.reactNativeRoot)
73
+ const key = createHash('sha256')
74
+ .update(options.providers.map(({ root }) => fs.realpathSync(root)).join('\0'))
75
+ .update('\0')
76
+ .update(fs.realpathSync(options.moduleRoot))
77
+ .digest('hex')
78
+ const scratch = path.join(os.tmpdir(), 'peach-turbo-swift', key)
79
+ // the codegen intake writes only into a new or empty directory
80
+ fs.rmSync(path.join(scratch, 'codegen'), { recursive: true, force: true })
81
+ const collection = await collectTurboSources({
82
+ appRoot: options.appRoot,
83
+ reactNativeRoot: options.reactNativeRoot,
84
+ providers: options.providers,
85
+ codegenDir: path.join(scratch, 'codegen'),
86
+ })
87
+ // the compiled sources target the app's own declared iOS minimum
88
+ const iosDeploymentTarget = readIosAppTarget(options.projectRoot)?.iosDeploymentTarget
89
+ if (!iosDeploymentTarget)
90
+ throw new Error(
91
+ `TurboModule compilation needs the app's Xcode project to declare an iOS deployment target: ${options.projectRoot}`,
92
+ )
93
+ const input = collectTurboCompileInput(
94
+ collection,
95
+ await resolveAdapterArchive(
96
+ 'turbo',
97
+ { reactNative: collection.reactNative.root },
98
+ options.moduleRoot,
99
+ committedAdapterLocks.turbo,
100
+ ),
101
+ iosDeploymentTarget,
102
+ )
103
+ const packagePath = path.join(scratch, 'package')
104
+ syncSwiftTree(
105
+ packagePath,
106
+ new Map(
107
+ Object.entries(input.files).map(([file, source]) => [
108
+ path.join(packagePath, file),
109
+ source,
110
+ ]),
111
+ ),
112
+ )
113
+ const project = projectFor(packagePath)
114
+ project.libraries = input.libraries
115
+ project.lazyDistribution = input.lazyDistribution
116
+ return {
117
+ artifact: await artifactFor(project, input.entry, options.moduleRoot),
118
+ collection,
119
+ }
120
+ }
@@ -0,0 +1,69 @@
1
+ {
2
+ "schema": 2,
3
+ "platform": "ios",
4
+ "target": "wasm32-unknown-wasip1",
5
+ "recipe": "704fe0a2e79278bce00a7af1b1dc1846943873c3f54942a174833a515d222b79",
6
+ "adapter": {
7
+ "sha256": "0d31912293226deb3354b3b32f2944e9c61c68590e3020d8b5af0c12a6677893"
8
+ },
9
+ "compiler": "swift-6.4.0-RELEASE-custom-81b2c791c27276bf",
10
+ "sdk": {
11
+ "id": "swift-6.4.0-RELEASE_wasm-peach-b26c1c1d",
12
+ "checksum": "d3bec118d62c1015e0a2b30e0f09b8fab25613d0ac98e0dee31e68c5521bc747"
13
+ },
14
+ "framework": {
15
+ "distribution": "c1636d7b2e11fc76",
16
+ "wireAbi": "246b8412514b644113e6a26252c8ebd6de49ab4156ac5f5c98bb9e4c2ff2568b"
17
+ },
18
+ "archives": [
19
+ {
20
+ "headers": {
21
+ "reactNativeJsi": "0f8c2defbca69a27a848a81ae72363073bf9602fd316e57a75811be1a0528358"
22
+ },
23
+ "sha256": "f1652a56346d7042f118c2694b13f870af04a6fadb4131f9a0ed356f6c569f55",
24
+ "size": 25399
25
+ },
26
+ {
27
+ "headers": {
28
+ "reactNativeJsi": "324aefd8591d9ce688bce7589c4c2b516cd33ecb95d35c47239a87a8fcf6a8da"
29
+ },
30
+ "sha256": "70ce25d883d54c1a285eb5be7b6f9f579b96e17004bd290e45f554166610eb43",
31
+ "size": 25398
32
+ },
33
+ {
34
+ "headers": {
35
+ "reactNativeJsi": "66b2cd5a38511195207f6c8a76aba735f9b9cc66a52a0d00780ffe5d331623f7"
36
+ },
37
+ "sha256": "c983243dce2d889c0aaea3aaa9d34d1af7050b2f26866e465a1473dc066fa6dd",
38
+ "size": 25396
39
+ },
40
+ {
41
+ "headers": {
42
+ "reactNativeJsi": "96db4e758dd53e9320cef7cad485e00aa06e7a982cefd920f17007de8a5bd9f9"
43
+ },
44
+ "sha256": "d651a6f69f016264a9a72ff0fd9303c6fb8b9ed30db545ce462ceadd1d9e2c1b",
45
+ "size": 26143
46
+ },
47
+ {
48
+ "headers": {
49
+ "reactNativeJsi": "aeab590ddd1218df963462242d3954ce467b0fa88f70e91429e4ffc74d230893"
50
+ },
51
+ "sha256": "293fb5ae79d60939eeb341cda359faf1d9868dd8e4ff0db3c3f3eee8285d5504",
52
+ "size": 26138
53
+ },
54
+ {
55
+ "headers": {
56
+ "reactNativeJsi": "b5fb260522384dd7ab07d740cdc534b529922446fcec798341c7817d9eaa49f4"
57
+ },
58
+ "sha256": "ecec13cfa871c6732c394a7eb620ec764227aecf237bf605534ac9b2e75dc460",
59
+ "size": 25265
60
+ },
61
+ {
62
+ "headers": {
63
+ "reactNativeJsi": "c6b391a1e870ccf7cdd534be63582862840f8245b99ebd253317deece1e6ffd5"
64
+ },
65
+ "sha256": "7da7688735e62030faeff9722ce932e0c0262762981df2988bcb5bb5fff3d3e4",
66
+ "size": 26144
67
+ }
68
+ ]
69
+ }