peachsim 0.1.1738 → 0.1.1744

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 (327) hide show
  1. package/README.md +4 -0
  2. package/cli/app-catalog.ts +47 -23
  3. package/cli/app-fonts.ts +19 -1
  4. package/cli/command-registry.ts +3 -0
  5. package/cli/commands/control.ts +67 -16
  6. package/cli/commands/device.ts +3 -1
  7. package/cli/commands/doctor.ts +1 -4
  8. package/cli/commands/inspect/settling.ts +6 -1
  9. package/cli/commands/inspect/wait-ready.ts +22 -2
  10. package/cli/commands/package.ts +22 -20
  11. package/cli/commands/push.ts +56 -0
  12. package/cli/commands/serve.ts +9 -0
  13. package/cli/commands/shell-url.ts +37 -9
  14. package/cli/commands/swift.ts +1 -1
  15. package/cli/current-sim.ts +27 -0
  16. package/cli/drivers/linux-browser-libs.lock.json +323 -1
  17. package/cli/drivers/linux-browser-libs.ts +8 -6
  18. package/cli/drivers/playwright.ts +5 -1
  19. package/cli/internal-child.ts +11 -1
  20. package/cli/main.ts +6 -0
  21. package/cli/native-input.ts +1 -7
  22. package/cli/outbound-endpoints.ts +9 -1
  23. package/cli/packaged-app-launcher.ts +3 -1
  24. package/cli/scene-video.ts +4 -0
  25. package/cli/ws-bridge.ts +3 -1
  26. package/detox/index.ts +9 -4
  27. package/dist-lib/agent-daemon-client.cjs +1 -1
  28. package/dist-lib/agent-events.cjs +1 -1
  29. package/dist-lib/attached-projects.cjs +1 -1
  30. package/dist-lib/auth/shared-session.cjs +1 -1
  31. package/dist-lib/backend-origin.cjs +1 -1
  32. package/dist-lib/beta.cjs +1 -1
  33. package/dist-lib/beta.mjs +1 -1
  34. package/dist-lib/bridge-constants.cjs +1 -1
  35. package/dist-lib/bridge-contract-input.cjs +1 -1
  36. package/dist-lib/bridge-contract-input.mjs +1 -1
  37. package/dist-lib/bridge-contract.cjs +1 -1
  38. package/dist-lib/bridge-contract.mjs +1 -1
  39. package/dist-lib/bundle-channel.cjs +7372 -3675
  40. package/dist-lib/capture-contract.cjs +1 -1
  41. package/dist-lib/capture-contract.mjs +1 -1
  42. package/dist-lib/cloud-contract.cjs +1 -1
  43. package/dist-lib/cloud-contract.mjs +1 -1
  44. package/dist-lib/cloud-test-args.cjs +1 -1
  45. package/dist-lib/cloud-test-args.mjs +1 -1
  46. package/dist-lib/cloud.cjs +1 -1
  47. package/dist-lib/cloud.mjs +1 -1
  48. package/dist-lib/config.cjs +1 -1
  49. package/dist-lib/config.mjs +1 -1
  50. package/dist-lib/detox/index.cjs +22 -8
  51. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  52. package/dist-lib/expo-swift-bundle.cjs +6340 -3064
  53. package/dist-lib/expo-swift-metadata.cjs +14 -2
  54. package/dist-lib/expo-swift-metadata.mjs +14 -2
  55. package/dist-lib/home-paths.cjs +1 -1
  56. package/dist-lib/host/bridge-host.cjs +6524 -2720
  57. package/dist-lib/host/fetch-proxy-handler.cjs +8 -7
  58. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  59. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  60. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  61. package/dist-lib/host/websocket-proxy.cjs +6 -3
  62. package/dist-lib/index.cjs +97 -31
  63. package/dist-lib/jump-to-source-babel.cjs +1 -1
  64. package/dist-lib/jump-to-source-native.cjs +1 -1
  65. package/dist-lib/kotlin-host.cjs +1 -1
  66. package/dist-lib/menu.cjs +1 -1
  67. package/dist-lib/menu.mjs +1 -1
  68. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  69. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  70. package/dist-lib/metro-production-bundle.cjs +1 -1
  71. package/dist-lib/metro-production-bundle.mjs +1 -1
  72. package/dist-lib/metro.cjs +71 -29
  73. package/dist-lib/native-app-identity-project.cjs +53 -22
  74. package/dist-lib/native-app-identity-project.mjs +53 -22
  75. package/dist-lib/native-app-identity.cjs +10 -3
  76. package/dist-lib/native-app-identity.mjs +10 -3
  77. package/dist-lib/native-firebase-metadata.cjs +1 -1
  78. package/dist-lib/native-firebase-metadata.mjs +1 -1
  79. package/dist-lib/plist.cjs +1 -1
  80. package/dist-lib/plist.mjs +1 -1
  81. package/dist-lib/profiles.cjs +1 -1
  82. package/dist-lib/public-brand.cjs +1 -1
  83. package/dist-lib/public-origins-lib-esm.json +25 -23
  84. package/dist-lib/public-origins-lib.json +111 -79
  85. package/dist-lib/react-native-host-modules.cjs +1 -1
  86. package/dist-lib/react-native-host-modules.mjs +1 -1
  87. package/dist-lib/reap-browser.cjs +1 -1
  88. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  89. package/dist-lib/sdk.cjs +4 -1
  90. package/dist-lib/sdk.mjs +4 -1
  91. package/dist-lib/skills.cjs +40549 -37613
  92. package/dist-lib/swift-compile.cjs +2054 -388
  93. package/dist-lib/swift-compile.mjs +1976 -312
  94. package/dist-lib/swift-package.cjs +1 -1
  95. package/dist-lib/swift-package.mjs +1 -1
  96. package/dist-lib/swift-submit.cjs +2 -2
  97. package/dist-lib/swift-submit.mjs +2 -2
  98. package/dist-lib/swift-toolchain.cjs +68 -8
  99. package/dist-lib/swift.cjs +1 -1
  100. package/dist-lib/vite-swift.cjs +5867 -2646
  101. package/dist-lib/vite.cjs +18 -8
  102. package/dist-lib/worklet-executable.cjs +1 -1
  103. package/dist-lib/worklet-executable.mjs +1 -1
  104. package/dist-types/packages/peach-compat/src/stubs/screen-transition-math.d.ts +1 -0
  105. package/dist-types/packages/peach-engine/src/cli-companion.d.ts +1 -0
  106. package/dist-types/packages/peach-engine/src/engine/canvaskit-renderer.d.ts +2 -0
  107. package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +0 -3
  108. package/dist-types/packages/peach-engine/src/engine/node.d.ts +6 -0
  109. package/dist-types/packages/peach-engine/src/engine/paint-boundary.d.ts +1 -0
  110. package/dist-types/packages/peach-engine/src/engine/scene-table.d.ts +25 -3
  111. package/dist-types/packages/peach-engine/src/engine/scroll-platform.d.ts +1 -15
  112. package/dist-types/packages/peach-engine/src/engine/scroll.d.ts +1 -3
  113. package/dist-types/packages/peach-engine/src/engine/text-first-baseline.d.ts +1 -0
  114. package/dist-types/packages/peach-engine/src/engine/types.d.ts +23 -0
  115. package/dist-types/packages/peach-engine/src/ios/chrome-metrics.d.ts +6 -0
  116. package/dist-types/packages/peach-engine/src/metro-identity-contract.d.ts +33 -0
  117. package/dist-types/packages/peach-engine/src/preview/bundle-layout.d.ts +1 -1
  118. package/dist-types/packages/peach-engine/src/remote-stream/scene-recording.d.ts +2 -0
  119. package/dist-types/packages/peach-engine/src/render-worker/compositor-gpu.d.ts +1 -1
  120. package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +2 -0
  121. package/dist-types/packages/peach-engine/src/render-worker/metro-bundle-metadata.d.ts +28 -0
  122. package/dist-types/packages/peach-engine/src/render-worker/native-ui-protocol.d.ts +21 -1
  123. package/dist-types/packages/peach-engine/src/render-worker/prepared-boot-bundle.d.ts +7 -0
  124. package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +8 -0
  125. package/dist-types/packages/peach-engine/src/render-worker/scroll-mirror.d.ts +1 -0
  126. package/dist-types/packages/peach-engine/src/render-worker/shell-protocol.d.ts +5 -0
  127. package/dist-types/packages/peach-engine/src/render-worker/test-bridge-protocol.d.ts +3 -3
  128. package/dist-types/packages/peach-engine/src/render-worker/webgpu-frame-transaction.d.ts +1 -0
  129. package/dist-types/packages/peach-engine/src/render-worker/webgpu-readback-scheduler.d.ts +1 -1
  130. package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +1 -0
  131. package/dist-types/packages/peach-engine/src/rolldown-bundle-inventory.d.ts +8 -1
  132. package/dist-types/packages/peach-engine/src/rolldown-production-fingerprint.d.ts +1 -4
  133. package/dist-types/packages/peach-engine/src/rolldown-production-module.d.ts +12 -0
  134. package/dist-types/packages/peach-engine/src/rolldown-production-roles.d.ts +6 -0
  135. package/dist-types/packages/peach-engine/src/settings/devices.d.ts +6 -1
  136. package/dist-types/packages/peach-engine/src/settings/duo-fold-bus.d.ts +1 -0
  137. package/dist-types/packages/peach-engine/src/shell-events.d.ts +4 -0
  138. package/dist-types/packages/peach-kit/src/capabilities.d.ts +7 -0
  139. package/package.json +2 -1
  140. package/runtime-companion.json +1 -1
  141. package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetwork.h +1 -0
  142. package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetworkErrors.h +257 -0
  143. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFByteOrder.h +305 -0
  144. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h +2 -0
  145. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGAffineTransform.h +204 -0
  146. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGBitmapContext.h +260 -0
  147. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGColor.h +164 -0
  148. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGColorConversionInfo.h +101 -0
  149. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGColorSpace.h +510 -0
  150. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGContext.h +1132 -0
  151. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGConvertColorDataWithFormat.h +34 -0
  152. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGDataConsumer.h +83 -0
  153. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGDataProvider.h +197 -0
  154. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGEXRToneMappingGamma.h +36 -0
  155. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGError.h +38 -0
  156. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGFont.h +312 -0
  157. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGFunction.h +106 -0
  158. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGGradient.h +123 -0
  159. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGITUToneMapping.h +31 -0
  160. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGImage.h +409 -0
  161. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGLayer.h +78 -0
  162. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFArray.h +120 -0
  163. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFContentStream.h +55 -0
  164. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFContext.h +535 -0
  165. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFDictionary.h +133 -0
  166. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFDocument.h +252 -0
  167. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFMarkedContentItem.h +37 -0
  168. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFObject.h +67 -0
  169. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFOperatorTable.h +51 -0
  170. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFPage.h +101 -0
  171. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFScanner.h +123 -0
  172. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFStream.h +44 -0
  173. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFString.h +52 -0
  174. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFStructureElement.h +87 -0
  175. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPath.h +441 -0
  176. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPattern.h +89 -0
  177. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGRenderingBufferProvider.h +49 -0
  178. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGShading.h +124 -0
  179. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGToneMapping.h +85 -0
  180. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.h +44 -252
  181. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Modules/module.modulemap +1 -0
  182. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/CFNetworkErrors.h +257 -0
  183. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes +0 -6
  184. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h +356 -61
  185. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/NSURLSession+Network.h +32 -0
  186. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/Network.h +51 -0
  187. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/advertise_descriptor.h +193 -0
  188. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/browse_descriptor.h +163 -0
  189. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/browse_result.h +207 -0
  190. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/browser.h +285 -0
  191. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/connection.h +714 -0
  192. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/connection_group.h +629 -0
  193. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/connection_report.h +932 -0
  194. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/content_context.h +229 -0
  195. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/endpoint.h +390 -0
  196. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/error.h +135 -0
  197. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/ethernet_channel.h +349 -0
  198. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/framer_options.h +1187 -0
  199. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/group_descriptor.h +184 -0
  200. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/interface.h +150 -0
  201. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/ip_options.h +351 -0
  202. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/listener.h +438 -0
  203. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/nw_object.h +200 -0
  204. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/parameters.h +1205 -0
  205. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/path.h +392 -0
  206. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/path_monitor.h +216 -0
  207. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/privacy_context.h +188 -0
  208. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/protocol_options.h +126 -0
  209. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/proxy_config.h +357 -0
  210. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/quic_options.h +889 -0
  211. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/resolver_config.h +94 -0
  212. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/tcp_options.h +459 -0
  213. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/tls_options.h +115 -0
  214. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/txt_record.h +432 -0
  215. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/udp_options.h +112 -0
  216. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/ws_options.h +743 -0
  217. package/sdk/ios/System/Library/Frameworks/Network.framework/Modules/module.modulemap +9 -0
  218. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAAnimation.h +395 -0
  219. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CABase.h +132 -0
  220. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CADisplayLink.h +107 -0
  221. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAEmitterCell.h +153 -0
  222. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAEmitterLayer.h +151 -0
  223. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAFrameRateRange.h +40 -0
  224. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAGradientLayer.h +78 -0
  225. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CALayer.h +1078 -0
  226. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAMediaTiming.h +97 -0
  227. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAMediaTimingFunction.h +67 -0
  228. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAReplicatorLayer.h +65 -0
  229. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAScrollLayer.h +64 -0
  230. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAShapeLayer.h +135 -0
  231. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CATextLayer.h +99 -0
  232. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CATiledLayer.h +67 -0
  233. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CATransaction.h +124 -0
  234. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CATransform3D.h +138 -0
  235. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CATransformLayer.h +40 -0
  236. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAValueFunction.h +78 -0
  237. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.h +19 -38
  238. package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/SecureTransport.h +1757 -0
  239. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/NSAttributedString.h +19 -0
  240. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/NSParagraphStyle.h +28 -0
  241. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIAccessibilityConstants.h +114 -0
  242. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h +16 -0
  243. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIBarAppearance.h +47 -0
  244. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIDataDetectors.h +20 -0
  245. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIDatePicker.h +13 -0
  246. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIDevice.h +16 -0
  247. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIEvent.h +84 -0
  248. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIGestureRecognizer.h +119 -0
  249. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIGestureRecognizerSubclass.h +66 -0
  250. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIHoverGestureRecognizer.h +45 -0
  251. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h +161 -37
  252. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIPickerView.h +76 -0
  253. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UITabBar.h +8 -0
  254. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UITabBarAppearance.h +78 -0
  255. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UITextInputTraits.h +29 -0
  256. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UITouch.h +104 -0
  257. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UITraitCollection.h +19 -0
  258. package/sdk/ios/usr/include/dns_sd.h +3616 -0
  259. package/sdk/ios/usr/include/dnssd.modulemap +4 -0
  260. package/sdk/ios/usr/include/module.modulemap +1 -0
  261. package/sdk/ios/usr/include/sys/socketvar.h +191 -0
  262. package/sdk/ios/usr/include/sys/vsock.h +84 -0
  263. package/sdk/native-hashes.json +1 -1
  264. package/skills/contrast/SKILL.md +6 -5
  265. package/skills/peach-debug/SKILL.md +68 -264
  266. package/skills/peach-debug/references/accessibility.md +37 -73
  267. package/skills/peach-debug/references/commands.md +2 -2
  268. package/skills/peach-debug/references/events.md +74 -0
  269. package/skills/peach-perf/SKILL.md +64 -401
  270. package/skills/peach-perf/references/presentation.md +46 -0
  271. package/skills/peach-perf/references/profiling.md +93 -0
  272. package/skills/peach-perf/references/render-counters.md +57 -0
  273. package/skills/peach-setup/SKILL.md +66 -216
  274. package/skills/peach-setup/references/native-config.md +35 -0
  275. package/skills/peach-setup/references/reporting.md +28 -0
  276. package/skills/peach-test/SKILL.md +68 -284
  277. package/skills/peach-test/references/detox.md +69 -0
  278. package/skills/peach-test/references/maestro.md +95 -0
  279. package/skills/peach-visual/SKILL.md +53 -105
  280. package/src/appPackageContract.ts +12 -1
  281. package/src/assetCatalogContract.ts +8 -1
  282. package/src/bridge-contract.ts +6 -0
  283. package/src/bundle-channel.mjs +133 -59
  284. package/src/cli-runtime.ts +8 -9
  285. package/src/configured-bundle-producer.ts +10 -0
  286. package/src/device-catalog.ts +68 -4
  287. package/src/expo-discovery-cache.ts +3 -0
  288. package/src/expo-native-workspace.ts +81 -17
  289. package/src/expo-swift-host.ts +57 -104
  290. package/src/expo-widget-assets.ts +76 -0
  291. package/src/expoSwiftContract.ts +13 -1
  292. package/src/host/websocket-proxy.ts +7 -2
  293. package/src/native-prebuilt.ts +3 -3
  294. package/src/nitro-adapter.lock.json +263 -263
  295. package/src/nitro-adapter.ts +69 -7
  296. package/src/nitro-bundle.ts +52 -24
  297. package/src/nitro-compile.ts +6 -1
  298. package/src/nitro-source.ts +82 -4
  299. package/src/nitro-superset.lock.json +103 -0
  300. package/src/nitro-superset.ts +137 -0
  301. package/src/nitroContract.ts +5 -1
  302. package/src/react-bridge-importers.ts +1 -0
  303. package/src/settingsContract.ts +26 -1
  304. package/src/swift-compile.ts +267 -68
  305. package/src/swift-compiler-digest.ts +2 -0
  306. package/src/swift-coverage/xcode-packages.ts +61 -1
  307. package/src/swift-coverage/xcode.ts +10 -12
  308. package/src/swift-cxx-reachable.ts +1 -1
  309. package/src/swift-distribution.lock.json +15 -13
  310. package/src/swift-distribution.ts +57 -26
  311. package/src/swift-host.ts +48 -35
  312. package/src/swift-link-roots.ts +45 -18
  313. package/src/swift-objc-compile.ts +78 -2
  314. package/src/swift-objc-standin.ts +3 -0
  315. package/src/swift-shared-sdk.ts +85 -1
  316. package/src/swift-standins.ts +233 -11
  317. package/src/swift-submit.ts +13 -1
  318. package/src/swift-toolchain.ts +82 -7
  319. package/src/swift-wasm-prune.ts +1629 -0
  320. package/src/turbo-bundle.ts +11 -10
  321. package/src/turbo-runtime.lock.json +16 -16
  322. package/src/vite-plugin-one.ts +12 -1
  323. package/src/vite-plugin.ts +82 -23
  324. package/src/wasm-optimize.ts +34 -0
  325. package/src/worker-system-chunks.ts +3 -3
  326. package/src/xcode-project.ts +52 -0
  327. package/src/xcode-target-members.ts +12 -1
@@ -1,18 +1,13 @@
1
- // which distribution objects a link must keep whole when the rest of the
1
+ // which distribution objects a link must keep as roots when the rest of the
2
2
  // distribution links as an archive. the gnustep ObjC runtime registers an
3
- // object's classes, protocols and categories from its own initializer, and
4
- // nothing references that object by symbol, so an archive pass would never
5
- // load it. every other object is pulled by the symbols the program uses, as
6
- // SwiftPM links a static Swift library.
3
+ // object's categories and class aliases from its own initializer, and the host
4
+ // runtime calls wasm-exported entrypoints by export name, so an archive pass
5
+ // would never load them. classes and Swift metadata are pulled by type and
6
+ // symbol reachability (swift-wasm-prune.ts).
7
7
  import fs from 'node:fs'
8
8
  import path from 'node:path'
9
9
 
10
- const OBJC_SEGMENTS = [
11
- '__objc_classes',
12
- '__objc_protocols',
13
- '__objc_cats',
14
- '__objc_class_aliases',
15
- ]
10
+ const OBJC_SEGMENTS = ['__objc_cats', '__objc_class_aliases']
16
11
 
17
12
  const leb = (bytes: Uint8Array, at: { offset: number }): number => {
18
13
  let value = 0
@@ -25,12 +20,14 @@ const leb = (bytes: Uint8Array, at: { offset: number }): number => {
25
20
  }
26
21
  }
27
22
 
28
- // data segment name to its summed size in one wasm object. the linking
29
- // section names each segment and the data section sizes them in the same order.
23
+ // data segment name to its summed size in one wasm object, plus a sentinel when
24
+ // the object defines a wasm-exported symbol. the linking section names each
25
+ // segment and the data section sizes them in the same order.
30
26
  function objcSegmentSizes(bytes: Uint8Array): Map<string, number> {
31
27
  const at = { offset: 8 }
32
28
  const names: string[] = []
33
29
  const sizes: number[] = []
30
+ let hasExportedSymbol = false
34
31
  while (at.offset < bytes.length) {
35
32
  const id = bytes[at.offset++]!
36
33
  const size = leb(bytes, at)
@@ -55,6 +52,31 @@ function objcSegmentSizes(bytes: Uint8Array): Map<string, number> {
55
52
  leb(bytes, at)
56
53
  leb(bytes, at)
57
54
  }
55
+ } else if (kind === 8) {
56
+ for (let count = leb(bytes, at); count > 0; count--) {
57
+ const symKind = bytes[at.offset++]!
58
+ const flags = leb(bytes, at)
59
+ const isUndef = (flags & 0x10) !== 0
60
+ const isExplicitName = (flags & 0x40) !== 0
61
+ if (!isUndef && (flags & 0x20) !== 0) hasExportedSymbol = true
62
+ if (symKind === 0 || symKind === 2 || symKind === 4 || symKind === 5) {
63
+ leb(bytes, at)
64
+ if (!isUndef || isExplicitName) {
65
+ const sLen = leb(bytes, at)
66
+ at.offset += sLen
67
+ }
68
+ } else if (symKind === 1) {
69
+ const sLen = leb(bytes, at)
70
+ at.offset += sLen
71
+ if (!isUndef) {
72
+ leb(bytes, at)
73
+ leb(bytes, at)
74
+ leb(bytes, at)
75
+ }
76
+ } else if (symKind === 3) {
77
+ leb(bytes, at)
78
+ }
79
+ }
58
80
  }
59
81
  at.offset = next
60
82
  }
@@ -81,15 +103,17 @@ function objcSegmentSizes(bytes: Uint8Array): Map<string, number> {
81
103
  if (OBJC_SEGMENTS.includes(name))
82
104
  result.set(name, (result.get(name) ?? 0) + (sizes[index] ?? 0))
83
105
  })
106
+ result.set('__wasm_exported', hasExportedSymbol ? 1 : 0)
84
107
  return result
85
108
  }
86
109
 
87
110
  const rootsByDistribution = new Map<string, ReadonlySet<string>>()
88
111
 
89
112
  /**
90
- * the objects (relative to root) that define an ObjC class, protocol or
91
- * category. every object carries each section's empty terminator, so a segment
92
- * holds a definition when it outgrows the smallest one the distribution has.
113
+ * the objects (relative to root) that define an ObjC category, class alias or
114
+ * wasm-exported entrypoint. every object carries each section's empty
115
+ * terminator, so a segment holds a definition when it outgrows the smallest one
116
+ * the distribution has.
93
117
  */
94
118
  export function swiftObjcRootObjects(
95
119
  id: string,
@@ -108,8 +132,11 @@ export function swiftObjcRootObjects(
108
132
  empty.set(name, Math.min(empty.get(name) ?? size, size))
109
133
  const roots = new Set(
110
134
  measured
111
- .filter(([, sizes]) =>
112
- [...sizes].some(([name, size]) => size > (empty.get(name) ?? 0)),
135
+ .filter(
136
+ ([object, sizes]) =>
137
+ object !== 'lib/Foundation-NSStringFormatting.o' &&
138
+ object !== 'lib/FoundationNetworking-Session.o' &&
139
+ [...sizes].some(([name, size]) => size > (empty.get(name) ?? 0)),
113
140
  )
114
141
  .map(([object]) => object),
115
142
  )
@@ -103,10 +103,73 @@ function writeXcodeSnapshot(
103
103
  }
104
104
  }
105
105
 
106
+ const FRAMEWORK_IMPORT = /#\s*(?:import|include)\s*<([\w+-]+)\/([\w+.-]+\.h)>/g
107
+ const OWN_IMPORT =
108
+ /#\s*(?:import|include)\s*(?:"([\w+.-]+\.h)"|<([\w+-]+)\/([\w+.-]+\.h)>)/g
109
+
110
+ /** the framework headers the project's Objective-C sources and headers import, by framework. */
111
+ function frameworkImports(app: XcodeAppTarget): Map<string, Set<string>> {
112
+ const imports = new Map<string, Set<string>>()
113
+ for (const target of [...app.frameworks, app]) {
114
+ if (!target.objc) continue
115
+ for (const file of [
116
+ ...target.objc.headers,
117
+ ...target.allSources.filter(isSwiftNativeTranslationUnit),
118
+ ]) {
119
+ if (file.endsWith('.swift') || !fs.existsSync(file)) continue
120
+ for (const [, framework, header] of fs
121
+ .readFileSync(file, 'utf8')
122
+ .matchAll(FRAMEWORK_IMPORT)) {
123
+ const headers = imports.get(framework!) ?? new Set<string>()
124
+ headers.add(header!)
125
+ imports.set(framework!, headers)
126
+ }
127
+ }
128
+ }
129
+ return imports
130
+ }
131
+
132
+ /**
133
+ * the framework headers the compiled translation units reach, by framework:
134
+ * their own imports and those of the target's own quoted headers they import
135
+ * in turn. a target a product provides is not compiled, and a public umbrella
136
+ * header imports whole frameworks that no compiled unit needs.
137
+ */
138
+ function compiledFrameworkImports(
139
+ app: XcodeAppTarget,
140
+ products: SwiftXcodeSwiftProducts | undefined,
141
+ ): Map<string, Set<string>> {
142
+ const imports = new Map<string, Set<string>>()
143
+ for (const target of [...app.frameworks, app]) {
144
+ if (!target.objc || products?.provided.includes(target.moduleName)) continue
145
+ const own = new Map(
146
+ target.objc.headers.map((header) => [path.basename(header), header]),
147
+ )
148
+ const seen = new Set<string>()
149
+ const visit = (file: string) => {
150
+ if (seen.has(file) || !fs.existsSync(file)) return
151
+ seen.add(file)
152
+ const source = fs.readFileSync(file, 'utf8')
153
+ for (const [, framework, header] of source.matchAll(FRAMEWORK_IMPORT)) {
154
+ const headers = imports.get(framework!) ?? new Set<string>()
155
+ headers.add(header!)
156
+ imports.set(framework!, headers)
157
+ }
158
+ for (const [, name] of source.matchAll(OWN_IMPORT)) {
159
+ const next = own.get(name!)
160
+ if (next) visit(next)
161
+ }
162
+ }
163
+ for (const file of target.allSources.filter(isSwiftNativeTranslationUnit)) visit(file)
164
+ }
165
+ return imports
166
+ }
167
+
106
168
  /** one original source snapshot serves declaration import and implementation compile. */
107
169
  export function xcodeObjCInputs(
108
170
  app: XcodeAppTarget,
109
171
  binaries: readonly SwiftPackageBinary[],
172
+ moduleRoot: string | null,
110
173
  products?: SwiftXcodeSwiftProducts,
111
174
  ) {
112
175
  const sources = new Map<string, Buffer>()
@@ -298,7 +361,19 @@ export function xcodeObjCInputs(
298
361
  binary.publicHeaders === undefined &&
299
362
  binary.placeholder === undefined,
300
363
  )
301
- .map((binary) => binaryHeaderSearchPaths(binary, checkouts))
364
+ .map((binary) =>
365
+ binaryHeaderSearchPaths(
366
+ binary,
367
+ checkouts,
368
+ moduleRoot
369
+ ? {
370
+ moduleRoot,
371
+ imports: frameworkImports(app),
372
+ compiledImports: compiledFrameworkImports(app, products),
373
+ }
374
+ : undefined,
375
+ ),
376
+ )
302
377
  const binaryFrameworks = binarySearch.flatMap((search) => search.frameworks)
303
378
  const binaryHeaders = binarySearch.flatMap((search) => search.headers)
304
379
  for (const directory of [...binaryHeaders, ...binaryFrameworks])
@@ -464,7 +539,7 @@ export function prepareXcodeSwiftProducts(
464
539
  const frontend = path.join(toolchain.toolchainBin, 'swift-frontend')
465
540
  const supplied = new Set(swiftPeachModules(moduleRoot))
466
541
  const modules = path.join(moduleRoot, 'modules')
467
- const { sources, links, targets: native } = xcodeObjCInputs(app, binaries)
542
+ const { sources, links, targets: native } = xcodeObjCInputs(app, binaries, moduleRoot)
468
543
  for (const file of app.projectFiles) sources.set(file, fs.readFileSync(file))
469
544
  const digest = (bytes: string | Buffer) =>
470
545
  createHash('sha256').update(bytes).digest('hex')
@@ -845,6 +920,7 @@ export function prepareXcodeObjCImplementations(
845
920
  const { sources, links, derivations, targets } = xcodeObjCInputs(
846
921
  app,
847
922
  binaries,
923
+ moduleRoot,
848
924
  products,
849
925
  )
850
926
  const checkouts = remoteSwiftCheckouts(app.rootDir)
@@ -330,6 +330,9 @@ export function objcSdkIntakeFlags(
330
330
  // the installed icu archive exports its swift_-prefixed names, which the
331
331
  // unicode headers rename to only off darwin.
332
332
  '-DU_DISABLE_RENAMING=0',
333
+ // clang enables blocks in every language for darwin targets, and the sdk
334
+ // headers declare block types unguarded.
335
+ '-fblocks',
333
336
  ...WASI_EMULATION_FLAGS,
334
337
  '-iframework',
335
338
  path.join(headers, 'System/Library/Frameworks'),
@@ -1,5 +1,9 @@
1
- import { readdirSync, readFileSync } from 'node:fs'
1
+ import { execFileSync } from 'node:child_process'
2
+ import { createHash } from 'node:crypto'
3
+ import fs, { readdirSync, readFileSync } from 'node:fs'
2
4
  import path from 'node:path'
5
+ import { swiftCacheDir } from './home-paths'
6
+ import { swiftEnvironment, swiftSdkOptions } from './swift-toolchain'
3
7
 
4
8
  // records targets share the same native declarations as original c units.
5
9
  // storage overlays carry wasm scalar identities without changing wasi libc abi.
@@ -17,6 +21,86 @@ export function swiftSharedSdkFlags(moduleRoot: string, distribution: boolean):
17
21
  ]
18
22
  }
19
23
 
24
+ // compiles reach the sdk through a view of the installed bundle whose
25
+ // darwin/System/Library/Frameworks is the shared tree, so a framework header
26
+ // change reaches the toolset's framework path and original units' intake
27
+ // without rebuilding the sdk. every other entry links into the real bundle,
28
+ // which installs and checksums keep reading. a published distribution's tree
29
+ // is the copy its sdk was built with.
30
+ const sdkViews = new Map<string, string[]>()
31
+ export function swiftSharedSdkViewOptions(
32
+ moduleRoot: string,
33
+ distribution: boolean,
34
+ toolchainBin: string,
35
+ sdk: string,
36
+ ): string[] {
37
+ const frameworks = path.join(
38
+ swiftSharedSdkRoot(moduleRoot, distribution),
39
+ 'System/Library/Frameworks',
40
+ )
41
+ const key = JSON.stringify([toolchainBin, sdk, frameworks, swiftSdkOptions()])
42
+ const cached = sdkViews.get(key)
43
+ if (cached) return cached
44
+ const configuration = execFileSync(
45
+ path.join(toolchainBin, 'swift'),
46
+ [
47
+ 'sdk',
48
+ 'configure',
49
+ ...swiftSdkOptions(),
50
+ '--show-configuration',
51
+ sdk,
52
+ 'wasm32-unknown-wasip1',
53
+ ],
54
+ { encoding: 'utf8', env: swiftEnvironment(), stdio: ['ignore', 'pipe', 'pipe'] },
55
+ )
56
+ const sysroot = /^sdkRootPath: (.+)$/m.exec(configuration)?.[1]?.trim()
57
+ if (!sysroot || !path.isAbsolute(sysroot))
58
+ throw new Error(`swift sdk ${sdk} reports no absolute sdkRootPath`)
59
+ let bundle = sysroot
60
+ while (!bundle.endsWith('.artifactbundle')) {
61
+ if (path.dirname(bundle) === bundle)
62
+ throw new Error(`swift sdk ${sdk} is outside an artifact bundle`)
63
+ bundle = path.dirname(bundle)
64
+ }
65
+ const view = path.join(
66
+ swiftCacheDir(),
67
+ 'swift-sdk-views',
68
+ createHash('sha256').update(key).digest('hex').slice(0, 16),
69
+ )
70
+ if (!fs.existsSync(view)) {
71
+ fs.mkdirSync(path.dirname(view), { recursive: true })
72
+ const staging = fs.mkdtempSync(`${view}-`)
73
+ const segments = [
74
+ path.basename(bundle),
75
+ ...path
76
+ .relative(bundle, path.join(sysroot, 'darwin/System/Library'))
77
+ .split(path.sep),
78
+ 'Frameworks',
79
+ ]
80
+ let real = path.dirname(bundle)
81
+ let mirror = staging
82
+ for (const segment of segments) {
83
+ for (const entry of readdirSync(real))
84
+ if (entry !== segment)
85
+ fs.symlinkSync(path.join(real, entry), path.join(mirror, entry))
86
+ real = path.join(real, segment)
87
+ mirror = path.join(mirror, segment)
88
+ if (segment !== 'Frameworks') fs.mkdirSync(mirror)
89
+ }
90
+ fs.symlinkSync(frameworks, mirror)
91
+ try {
92
+ fs.renameSync(staging, view)
93
+ } catch (error) {
94
+ // another process built the same view first
95
+ fs.rmSync(staging, { recursive: true, force: true })
96
+ if (!fs.existsSync(view)) throw error
97
+ }
98
+ }
99
+ const options = ['--swift-sdks-path', view]
100
+ sdkViews.set(key, options)
101
+ return options
102
+ }
103
+
20
104
  export function swiftSharedSdkInputFiles(moduleRoot: string): string[] {
21
105
  const root = swiftSharedSdkRoot(moduleRoot, false)
22
106
  return readdirSync(root, { recursive: true, withFileTypes: true })
@@ -22,10 +22,12 @@ import {
22
22
  FOUNDATION_IMPLICIT_MODULES,
23
23
  foundationOwnerOf,
24
24
  swiftDistributionAt,
25
+ swiftModuleInterface,
25
26
  swiftImportNames,
26
27
  swiftMacroPlugins,
27
28
  swiftModuleDigest,
28
29
  swiftModuleSdk,
30
+ swiftCompileSdkOptions,
29
31
  swiftPeachModules,
30
32
  swiftSdkPaths,
31
33
  } from './swift-compile'
@@ -58,7 +60,7 @@ import {
58
60
  type SwiftStandinBehaviors,
59
61
  type StandinBehavior,
60
62
  } from './swift-standin-emit'
61
- import { sourceSwiftCheckout, swiftEnvironment, swiftSdkOptions } from './swift-toolchain'
63
+ import { sourceSwiftCheckout, swiftEnvironment } from './swift-toolchain'
62
64
  import type { SwiftPackageBinary } from './swift-packages'
63
65
 
64
66
  const TRIPLE = 'wasm32-unknown-wasip1'
@@ -255,10 +257,166 @@ function xcframework(binary: SwiftPackageBinary): {
255
257
  export const isBinaryLibraryFile = (file: string): boolean =>
256
258
  /\.(?:a|dylib|o|tbd)$/i.test(file)
257
259
 
260
+ /**
261
+ * the headers a framework's consumers import and the module root that
262
+ * compiles the framework's Swift. a framework whose module the root provides
263
+ * takes that module's `<Module>-Swift.h` for the declarations Swift owns
264
+ * there, as a mixed framework's own interface header does.
265
+ */
266
+ export interface SwiftDeclaredFrameworks {
267
+ moduleRoot: string
268
+ /** the framework headers its consumers import, by framework name. */
269
+ imports: ReadonlyMap<string, ReadonlySet<string>>
270
+ /** the headers the compiled translation units reach, which stage frameworks without Swift. */
271
+ compiledImports: ReadonlyMap<string, ReadonlySet<string>>
272
+ }
273
+
274
+ /**
275
+ * UIKit declarations the sdk header surface does not carry because the Swift
276
+ * UIKitCore module owns them. a staged header that names one gets a private
277
+ * clang typedef, which Swift does not import under the public name.
278
+ */
279
+ const UIKIT_SWIFT_OWNED_TYPEDEFS: Readonly<Record<string, string>> = {
280
+ UIApplicationLaunchOptionsKey:
281
+ 'typedef NSString *UIApplicationLaunchOptionsKey __attribute__((swift_private));',
282
+ UIBackgroundFetchResult:
283
+ 'typedef NSUInteger UIBackgroundFetchResult __attribute__((swift_private));',
284
+ }
285
+
286
+ /**
287
+ * frameworks without Swift declarations that stage by the headers consumers
288
+ * import: React's umbrella imports UIKit headers (UIKeyCommand, UIFontMetrics,
289
+ * UIAccessibilityElement) the sdk's clang UIKit surface does not carry.
290
+ */
291
+ const REACH_STAGED_FRAMEWORKS: ReadonlySet<string> = new Set(['React'])
292
+
293
+ const OBJC_IMPORT = /#\s*(?:import|include)\s*[<"](?:[\w+-]+\/)?([\w+.-]+\.h)[>"]/g
294
+
295
+ /** a header with the definitions Swift owns replaced by an import of its interface header. */
296
+ function withoutSwiftDeclarations(
297
+ text: string,
298
+ declared: ReadonlySet<string>,
299
+ interfaceImport: string,
300
+ ): string {
301
+ const out: string[] = []
302
+ let skipping = false
303
+ let imported = false
304
+ // clang refuses to enter a header inside an assume_nonnull region, so the
305
+ // import goes above the region's start when the declaration sits inside it.
306
+ let regionStart = -1
307
+ for (const line of text.split('\n')) {
308
+ if (skipping) {
309
+ if (/^@end\b/.test(line)) skipping = false
310
+ continue
311
+ }
312
+ if (regionStart < 0 && /^NS_ASSUME_NONNULL_BEGIN\b/.test(line))
313
+ regionStart = out.length
314
+ const name = /^@(?:protocol|interface)\s+(\w+)\s*(?=[:<{]|$)/.exec(line)?.[1]
315
+ if (name && declared.has(name)) {
316
+ skipping = true
317
+ if (!imported)
318
+ out.splice(regionStart < 0 ? out.length : regionStart, 0, interfaceImport)
319
+ imported = true
320
+ continue
321
+ }
322
+ out.push(line)
323
+ }
324
+ return out.join('\n')
325
+ }
326
+
327
+ /**
328
+ * a framework whose module the distribution provides as Swift is staged as a
329
+ * mixed framework: the upstream headers minus the umbrella, with the
330
+ * definitions Swift owns taken from the distribution's interface header, and
331
+ * a module map that lists the headers consumers import with what they pull in.
332
+ * clang builds one module per framework, so a header no consumer reaches
333
+ * (one that needs a system framework this sysroot lacks) stays out of it. the
334
+ * header named for the framework imports every other header, so it stays out
335
+ * too, and a consumer of it is refused as a missing header.
336
+ */
337
+ function stageDeclaredFramework(
338
+ framework: string,
339
+ declared: ReadonlySet<string> | null,
340
+ imports: ReadonlySet<string>,
341
+ destination: string,
342
+ ): void {
343
+ const name = path.basename(framework, '.framework')
344
+ const own = `${name}-Swift.h`
345
+ const modulemap = fs.readFileSync(
346
+ path.join(framework, 'Modules/module.modulemap'),
347
+ 'utf8',
348
+ )
349
+ const umbrella = /umbrella header "([^"]+)"/.exec(modulemap)?.[1]
350
+ if (!umbrella) throw new Error(`${name} module map names no umbrella header`)
351
+ const headers = new Map(
352
+ fs
353
+ .readdirSync(path.join(framework, 'Headers'))
354
+ .filter(
355
+ (file) =>
356
+ file.endsWith('.h') &&
357
+ file !== umbrella &&
358
+ file !== own &&
359
+ file !== `${name}.h`,
360
+ )
361
+ .map((file) => [
362
+ file,
363
+ fs.readFileSync(path.join(framework, 'Headers', file), 'utf8'),
364
+ ]),
365
+ )
366
+ const reached = new Set<string>()
367
+ const reach = (file: string) => {
368
+ const source = headers.get(file)
369
+ if (source === undefined || reached.has(file)) return
370
+ reached.add(file)
371
+ for (const match of source.matchAll(OBJC_IMPORT)) reach(match[1]!)
372
+ }
373
+ for (const file of imports) reach(file)
374
+ const target = path.join(destination, 'frameworks', path.basename(framework))
375
+ fs.mkdirSync(path.join(target, 'Headers'), { recursive: true })
376
+ fs.mkdirSync(path.join(target, 'Modules'))
377
+ // each header is its own submodule, so it sees only what it imports; the
378
+ // umbrella gave them Foundation and UIKit first, and the platform macros
379
+ // that choose UIKit come from Foundation.
380
+ for (const [file, source] of headers) {
381
+ const body = declared
382
+ ? withoutSwiftDeclarations(source, declared, `#import <${name}/${own}>`)
383
+ : source
384
+ const uikit =
385
+ /\bUI[A-Z]\w+/.test(body) && !body.includes('UIKit/UIKit.h')
386
+ ? '#import <UIKit/UIKit.h>\n'
387
+ : ''
388
+ const owned = Object.entries(UIKIT_SWIFT_OWNED_TYPEDEFS)
389
+ .filter(([type]) => new RegExp(`\\b${type}\\b`).test(body))
390
+ .map(([, typedef]) => `${typedef}\n`)
391
+ .join('')
392
+ fs.writeFileSync(
393
+ path.join(target, 'Headers', file),
394
+ `#import <Foundation/Foundation.h>\n${uikit}${owned}${body}`,
395
+ )
396
+ }
397
+ const submodules = [
398
+ ...(declared ? [` module Swift { header "${own}" export * }`] : []),
399
+ ...[...reached]
400
+ .filter((file) => !modulemap.includes(`textual header "${file}"`))
401
+ .sort()
402
+ .map(
403
+ (file) =>
404
+ ` module ${path.basename(file, '.h').replace(/\W/g, '_')} { header "${file}" export * }`,
405
+ ),
406
+ ]
407
+ fs.writeFileSync(
408
+ path.join(target, 'Modules/module.modulemap'),
409
+ modulemap
410
+ .replace(/^\s*umbrella header "[^"]*"\s*\n/m, '')
411
+ .replace(/^\s*module \*\s*\{[^}]*\}\s*\n/m, `${submodules.join('\n')}\n`),
412
+ )
413
+ }
414
+
258
415
  /** stage simulator framework and library headers for original clang units. */
259
416
  export function binaryHeaderSearchPaths(
260
417
  binary: SwiftPackageBinary,
261
418
  root: string,
419
+ declaredFrameworks?: SwiftDeclaredFrameworks,
262
420
  ): { frameworks: string[]; headers: string[] } {
263
421
  const artifact = xcframework(binary)
264
422
  const slice = simulatorSlice(artifact.dir)
@@ -282,16 +440,51 @@ export function binaryHeaderSearchPaths(
282
440
  const headers = libraryHeaders && fs.existsSync(libraryHeaders) ? [libraryHeaders] : []
283
441
  if (headers.length === 0 && frameworks.length === 0)
284
442
  return { frameworks: [], headers: [] }
443
+ const declared = new Map<
444
+ string,
445
+ {
446
+ declared: ReadonlySet<string> | null
447
+ header: string | null
448
+ imports: ReadonlySet<string>
449
+ }
450
+ >()
451
+ for (const framework of frameworks) {
452
+ const name = path.basename(framework, '.framework')
453
+ if (!declaredFrameworks) continue
454
+ const imports = declaredFrameworks.imports.get(name)
455
+ const swift = imports && swiftModuleInterface(declaredFrameworks.moduleRoot, name)
456
+ const compiled = declaredFrameworks.compiledImports.get(name)
457
+ if (swift) declared.set(framework, { ...swift, imports })
458
+ else if (compiled && REACH_STAGED_FRAMEWORKS.has(name))
459
+ declared.set(framework, { declared: null, header: null, imports: compiled })
460
+ }
461
+ // the interface header's bytes change with the module, so the staged
462
+ // directory names the declarations and imports it was cut by, and the
463
+ // header is written into it on every call
464
+ const declaredDigest = createHash('sha256')
465
+ for (const [framework, { declared: names, imports }] of declared)
466
+ declaredDigest
467
+ .update(framework)
468
+ .update([...(names ?? [])].sort().join('\0'))
469
+ .update('\n')
470
+ .update([...imports].sort().join('\0'))
285
471
  const search = path.join(
286
472
  root,
287
473
  'peach-binary-inputs',
288
474
  STANDIN_SOURCE_DIGEST.slice(0, 32),
289
- artifact.digest.slice(0, 32),
475
+ declared.size
476
+ ? `${artifact.digest.slice(0, 32)}-${declaredDigest.digest('hex').slice(0, 16)}`
477
+ : artifact.digest.slice(0, 32),
290
478
  )
291
479
  if (!fs.existsSync(search)) {
292
480
  const pending = `${search}.${process.pid}.tmp`
293
481
  fs.rmSync(pending, { recursive: true, force: true })
294
- for (const framework of frameworks)
482
+ for (const framework of frameworks) {
483
+ const swift = declared.get(framework)
484
+ if (swift) {
485
+ stageDeclaredFramework(framework, swift.declared, swift.imports, pending)
486
+ continue
487
+ }
295
488
  for (const part of ['Headers', 'Modules'])
296
489
  if (fs.existsSync(path.join(framework, part)))
297
490
  fs.cpSync(
@@ -299,6 +492,7 @@ export function binaryHeaderSearchPaths(
299
492
  path.join(pending, 'frameworks', path.basename(framework), part),
300
493
  { recursive: true, dereference: true },
301
494
  )
495
+ }
302
496
  for (const [index, directory] of headers.entries())
303
497
  fs.cpSync(directory, path.join(pending, 'headers', String(index)), {
304
498
  recursive: true,
@@ -320,6 +514,19 @@ export function binaryHeaderSearchPaths(
320
514
  if (!fs.existsSync(search)) throw error
321
515
  }
322
516
  }
517
+ for (const [framework, { header }] of declared) {
518
+ if (header === null) continue
519
+ const name = path.basename(framework, '.framework')
520
+ const staged = path.join(
521
+ search,
522
+ 'frameworks',
523
+ path.basename(framework),
524
+ 'Headers',
525
+ `${name}-Swift.h`,
526
+ )
527
+ if (!fs.existsSync(staged) || fs.readFileSync(staged, 'utf8') !== header)
528
+ fs.writeFileSync(staged, header)
529
+ }
323
530
  return {
324
531
  frameworks: frameworks.length ? [path.join(search, 'frameworks')] : [],
325
532
  headers: headers.map((_, index) => path.join(search, 'headers', String(index))),
@@ -470,7 +677,7 @@ function peachModuleDirs(toolchain: Toolchain, imports: string[]): string[] {
470
677
  'native',
471
678
  '-j',
472
679
  '4',
473
- ...swiftSdkOptions(),
680
+ ...swiftCompileSdkOptions(moduleRoot, toolchainBin),
474
681
  '--swift-sdk',
475
682
  swiftModuleSdk(moduleRoot).wasmSdkId,
476
683
  '-c',
@@ -1007,6 +1214,12 @@ function objcStandin(
1007
1214
  cacheDir,
1008
1215
  path.join(work, 'objc'),
1009
1216
  )
1217
+ // the modules its headers import carry the types its declarations name; a
1218
+ // module peach does not ship stays unimported and drops what needs it
1219
+ const provided = new Set(swiftPeachModules(toolchain.moduleRoot))
1220
+ const headerModules = view.imports.filter(
1221
+ (name) => !STANDIN_IMPORTS.includes(name) && provided.has(name),
1222
+ )
1010
1223
  return graphStandin(
1011
1224
  surface.module,
1012
1225
  view.graphs,
@@ -1016,9 +1229,14 @@ function objcStandin(
1016
1229
  toolchain,
1017
1230
  work,
1018
1231
  behavior,
1019
- binary.headerDependencies?.map((dependency) =>
1020
- swiftTargetModuleName(dependency.module),
1021
- ),
1232
+ [
1233
+ ...new Set([
1234
+ ...headerModules,
1235
+ ...(binary.headerDependencies?.map((dependency) =>
1236
+ swiftTargetModuleName(dependency.module),
1237
+ ) ?? []),
1238
+ ]),
1239
+ ],
1022
1240
  )
1023
1241
  }
1024
1242
 
@@ -1753,7 +1971,7 @@ export function rustCrateEntry(manifest: string, library: string) {
1753
1971
  * xcframework (`wasm32-wasip1/lib<name>.a`) wins; otherwise the crate under
1754
1972
  * `searchRoot` that builds the slice's library comes from the registry when
1755
1973
  * it holds that crate's source and toolchain, else compiles with the
1756
- * developer's own cargo. peach ships no rust compiler.
1974
+ * developer's cargo with the registry's pinned toolchain. peach ships no rust compiler.
1757
1975
  */
1758
1976
  export function standinLibrary(
1759
1977
  binary: SwiftPackageBinary,
@@ -1782,7 +2000,7 @@ export function standinLibrary(
1782
2000
  return buildRustCrate(manifest, library, searchRoot)
1783
2001
  }
1784
2002
 
1785
- /** compiles a crate for the wasm target with the environment's cargo. */
2003
+ /** compiles a crate with the same rust standard library as registry archives. */
1786
2004
  export function buildRustCrate(
1787
2005
  manifest: string,
1788
2006
  library: string,
@@ -1805,7 +2023,11 @@ export function buildRustCrate(
1805
2023
  ],
1806
2024
  {
1807
2025
  encoding: 'utf8',
1808
- env: { ...process.env, CARGO_HOME: path.join(cacheDir, 'cargo-home') },
2026
+ env: {
2027
+ ...process.env,
2028
+ RUSTUP_TOOLCHAIN: RUST_TOOLCHAIN,
2029
+ CARGO_HOME: path.join(cacheDir, 'cargo-home'),
2030
+ },
1809
2031
  maxBuffer: 256 * 1024 * 1024,
1810
2032
  stdio: ['ignore', 'pipe', 'pipe'],
1811
2033
  },
@@ -1820,7 +2042,7 @@ export function buildRustCrate(
1820
2042
  /target may not be installed|can't find crate for `(core|std)`/.test(result.stderr)
1821
2043
  )
1822
2044
  throw new Error(
1823
- `${crate} builds for ${RUST_TARGET}, which this rust lacks; run \`rustup target add ${RUST_TARGET}\`, then run again`,
2045
+ `${crate} builds for ${RUST_TARGET}, which Rust ${RUST_TOOLCHAIN} lacks; run \`rustup target add --toolchain ${RUST_TOOLCHAIN} ${RUST_TARGET}\`, then run again`,
1824
2046
  )
1825
2047
  throw new Error(
1826
2048
  `cargo could not build ${crate} for ${RUST_TARGET}: ${failure(result)}`,