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
@@ -4,7 +4,7 @@ import {
4
4
  type ExecFileOptions,
5
5
  type SpawnOptions,
6
6
  } from 'node:child_process'
7
- import { createHash } from 'node:crypto'
7
+ import { createHash, randomUUID } from 'node:crypto'
8
8
  import {
9
9
  cpSync,
10
10
  existsSync,
@@ -62,7 +62,11 @@ import {
62
62
  type SwiftPackageTarget,
63
63
  } from './swift-package'
64
64
  import { withSwiftRootLock, type SwiftRootLease } from './swift-root-lock'
65
- import { swiftSharedSdkInputFiles, swiftSharedSdkRoot } from './swift-shared-sdk'
65
+ import {
66
+ swiftSharedSdkInputFiles,
67
+ swiftSharedSdkRoot,
68
+ swiftSharedSdkViewOptions,
69
+ } from './swift-shared-sdk'
66
70
  import {
67
71
  sourceSwiftCheckout,
68
72
  SWIFT_AUTOLINK_LINKER,
@@ -73,6 +77,7 @@ import {
73
77
  writeSwiftAutolinkLinker,
74
78
  type SwiftWasmSdk,
75
79
  } from './swift-toolchain'
80
+ import { pruneSwiftWasmLink } from './swift-wasm-prune'
76
81
  import {
77
82
  isSwiftNativeTargets,
78
83
  isSwiftPackageFiles,
@@ -85,6 +90,7 @@ import {
85
90
  type SwiftNativeTarget,
86
91
  type SwiftProjectPreparation,
87
92
  } from './swiftContract'
93
+ import { optimizeWasm, WASM_OPTIMIZE_IDENTITY } from './wasm-optimize'
88
94
  import { writeXcodeHeaderSearch } from './xcode-header-search'
89
95
  import type { SwiftImageUpload } from './swift-submit'
90
96
  import type { SwiftResourceBundle } from './swiftContract'
@@ -297,6 +303,53 @@ export function swiftDistributionAt(root: string): SwiftDistributionManifest | n
297
303
  return parseSwiftDistributionManifest(JSON.parse(readFileSync(file, 'utf8')))
298
304
  }
299
305
 
306
+ /**
307
+ * the Objective-C interface an SDK module defines: the names Swift owns and
308
+ * its generated header. a distribution ships the header; a source checkout
309
+ * names them by `@objc(Name)` and builds the header with the module
310
+ * (`.build/host`), so it stands as an empty header until that build.
311
+ */
312
+ export function swiftModuleInterface(
313
+ moduleRoot: string,
314
+ name: string,
315
+ ): { declared: ReadonlySet<string>; header: string } | null {
316
+ if (swiftDistributionAt(moduleRoot)) {
317
+ const file = path.join(moduleRoot, 'modules', `${name}-Swift.h`)
318
+ if (!existsSync(file)) return null
319
+ const header = clangInterfaceHeader(readFileSync(file, 'utf8'))
320
+ return { declared: swiftInterfaceDeclarations(header), header }
321
+ }
322
+ const sources = path.join(moduleRoot, 'Sources', name)
323
+ if (!existsSync(sources)) return null
324
+ const declared = new Set<string>()
325
+ for (const file of readdirSync(sources, { recursive: true, encoding: 'utf8' }))
326
+ if (file.endsWith('.swift'))
327
+ for (const [, objc] of readFileSync(path.join(sources, file), 'utf8').matchAll(
328
+ /@objc\((\w+)\)\s+(?:\w+\s+)*?(?:protocol|class)\s/g,
329
+ ))
330
+ declared.add(objc!)
331
+ if (declared.size === 0) return null
332
+ const built = path.join(moduleRoot, '.build/host', `${name}-Swift.h`)
333
+ return {
334
+ declared,
335
+ header: existsSync(built)
336
+ ? clangInterfaceHeader(readFileSync(built, 'utf8'))
337
+ : `// ${name}-Swift.h is generated when ${name} builds\n`,
338
+ }
339
+ }
340
+
341
+ // the compiler imports the module that defines a type, and UIKit's declarations
342
+ // live in UIKitCore, which only the umbrella UIKit module represents to clang.
343
+ const clangInterfaceHeader = (header: string): string =>
344
+ header.replace(/^@import UIKitCore;$/m, '@import UIKit;')
345
+
346
+ /** the Objective-C protocols and classes a generated interface header defines. */
347
+ const swiftInterfaceDeclarations = (header: string): Set<string> =>
348
+ new Set([
349
+ ...[...header.matchAll(/^@protocol\s+(\w+)\b(?![^\n]*;\s*$)/gm)].map((m) => m[1]!),
350
+ ...[...header.matchAll(/^@interface\s+(\w+)\s*(?=[:<{]|$)/gm)].map((m) => m[1]!),
351
+ ])
352
+
300
353
  /** the wasm SDK a module root compiles with: a distribution's manifest names
301
354
  * it, a source checkout's toolchain.json pins it. */
302
355
  export function swiftModuleSdk(root: string): SwiftWasmSdk {
@@ -308,6 +361,20 @@ export function swiftModuleSdk(root: string): SwiftWasmSdk {
308
361
  }
309
362
  }
310
363
 
364
+ /** swiftpm's sdk option for a compile against `moduleRoot`: the installed
365
+ * sdk seen through the module root's shared framework headers. */
366
+ export function swiftCompileSdkOptions(
367
+ moduleRoot: string,
368
+ toolchainBin: string,
369
+ ): string[] {
370
+ return swiftSharedSdkViewOptions(
371
+ moduleRoot,
372
+ swiftDistributionAt(moduleRoot) !== null,
373
+ toolchainBin,
374
+ swiftModuleSdk(moduleRoot).wasmSdkId,
375
+ )
376
+ }
377
+
311
378
  // toolchain.json is an input for its wasm sdk checksum: the sdk's icu blob,
312
379
  // which the host fills into every artifact, is part of what the address names.
313
380
  // distribution producers are inputs so repaired builds get a fresh immutable id.
@@ -318,6 +385,7 @@ export function swiftModuleInputFiles(root: string): string[] {
318
385
  ...swiftSharedSdkInputFiles(root),
319
386
  '../peachsim/src/swift-shared-sdk.ts',
320
387
  '../../scripts/generate/swift-sdk-module/darwin-mach.json',
388
+ '../../scripts/generate/swift-sdk-module/darwin-socketvar.json',
321
389
  '../../scripts/ops/swift-distribution-publish.ts',
322
390
  'Package.swift',
323
391
  'scripts/contrast-app-Package.swift',
@@ -763,7 +831,8 @@ export function swiftSdkPaths(
763
831
  cFlags: string[]
764
832
  } {
765
833
  const sdk = swiftModuleSdk(moduleRoot).wasmSdkId
766
- const key = JSON.stringify([toolchainBin, sdk, swiftSdkOptions()])
834
+ const options = swiftCompileSdkOptions(moduleRoot, toolchainBin)
835
+ const key = JSON.stringify([toolchainBin, sdk, options])
767
836
  const cached = sdkPaths.get(key)
768
837
  if (cached) return cached
769
838
  const configuration = execFileSync(
@@ -771,7 +840,7 @@ export function swiftSdkPaths(
771
840
  [
772
841
  'sdk',
773
842
  'configure',
774
- ...swiftSdkOptions(),
843
+ ...options,
775
844
  '--show-configuration',
776
845
  sdk,
777
846
  'wasm32-unknown-wasip1',
@@ -1073,7 +1142,7 @@ const executableLinkFlags = (root: string) => ` "-Xclang-linker", "-O0"
1073
1142
  const REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n'
1074
1143
 
1075
1144
  /** bump with any change to the emitted multi-target manifest text. */
1076
- export const MULTI_MANIFEST_VERSION = 50
1145
+ export const MULTI_MANIFEST_VERSION = 51
1077
1146
 
1078
1147
  // build-cli replaces this in every bundle; source runs read the files directly.
1079
1148
  declare const __SWIFT_COMPILER_DIGEST__: string | undefined
@@ -1092,7 +1161,8 @@ export function swiftArtifactHash(
1092
1161
  hash.update(compilerSourceDigest)
1093
1162
  if (input.oneModule) hash.update('one-module\n')
1094
1163
  hash.update(swiftModuleDigest(moduleRoot))
1095
- if (input.lazyDistribution) hash.update('lazy-distribution\n')
1164
+ if (input.lazyDistribution)
1165
+ hash.update(`lazy-distribution\n${WASM_OPTIMIZE_IDENTITY}\n`)
1096
1166
  for (const file of Object.keys(input.files).sort()) {
1097
1167
  hash.update(createHash('sha256').update(file).digest())
1098
1168
  hash.update(createHash('sha256').update(input.files[file]).digest())
@@ -1321,7 +1391,12 @@ export function emitSwiftPackageManifest(args: {
1321
1391
  ? [
1322
1392
  ...objects.filter((object) => roots.has(object)).map(quoted),
1323
1393
  '-Wl,--start-lib',
1324
- ...objects.filter((object) => !roots.has(object)).map(quoted),
1394
+ ...objects
1395
+ .filter(
1396
+ (object) =>
1397
+ !roots.has(object) && object !== 'lib/Foundation-NSStringFormatting.o',
1398
+ )
1399
+ .map(quoted),
1325
1400
  '-Wl,--end-lib',
1326
1401
  ]
1327
1402
  : objects.map(quoted)
@@ -1646,8 +1721,7 @@ export function syncSwiftTree(base: string, files: Map<string, string | Buffer>)
1646
1721
  dir === base &&
1647
1722
  (entry.name === '.build' ||
1648
1723
  entry.name.startsWith('.peach-modules-') ||
1649
- entry.name === SWIFT_LINK_STAMP ||
1650
- entry.name === SWIFT_FRAMEWORK_KEY)
1724
+ entry.name === SWIFT_LINK_STAMP)
1651
1725
  )
1652
1726
  continue
1653
1727
  if (entry.isDirectory()) walk(full)
@@ -2021,8 +2095,6 @@ const FOUNDATION_OVERLAY_TYPES = new Set([
2021
2095
  'URLUbiquitousSharedItemRole',
2022
2096
  'UndoManager',
2023
2097
  'ValueTransformer',
2024
- 'XMLParser',
2025
- 'XMLParserDelegate',
2026
2098
  ])
2027
2099
 
2028
2100
  // existing overlay globals retain their declaration and runtime owner.
@@ -2393,7 +2465,6 @@ const FOUNDATION_OVERLAY_GLOBALS = new Set([
2393
2465
  'NSUnicodeStringEncoding',
2394
2466
  'NSUserActivityErrorMaximum',
2395
2467
  'NSUserActivityErrorMinimum',
2396
- 'NSUserActivityTypeBrowsingWeb',
2397
2468
  'NSValidationErrorMaximum',
2398
2469
  'NSValidationErrorMinimum',
2399
2470
  'NSWindows95OperatingSystem',
@@ -3346,11 +3417,14 @@ const HIDDEN_UNITS = 'PeachHiddenUnits'
3346
3417
  // `-I` and no map file, so `@import` fails. the map passed here umbrellas
3347
3418
  // those headers from outside the directory. a second map once
3348
3419
  // `module.modulemap` sits in a searched directory redefines the module
3349
- // (Xcode 27.1 clang).
3420
+ // (Xcode 27.1 clang). a dependency staged after its consumer has no map on
3421
+ // disk yet, so each generated map is recorded and forwards to the published
3422
+ // one once the whole project is staged.
3350
3423
  function clangImportModuleMapFlags(
3351
3424
  settings: SwiftNativeTarget,
3352
3425
  layoutRoot: string,
3353
3426
  written: Map<string, string>,
3427
+ generated: { output: string; module: string; published: string }[],
3354
3428
  ): string[] {
3355
3429
  const searched = new Set(settings.headerSearchPaths)
3356
3430
  const directory = path.join(layoutRoot, '.build', 'peach-clang-modulemaps')
@@ -3372,6 +3446,7 @@ function clangImportModuleMapFlags(
3372
3446
  path: headers,
3373
3447
  }),
3374
3448
  )
3449
+ generated.push({ output, module: swiftTargetModuleName(map.module), published })
3375
3450
  const flag = `-fmodule-map-file=${output}`
3376
3451
  written.set(headers, flag)
3377
3452
  return [flag]
@@ -3426,8 +3501,17 @@ export function writeSwiftProject(
3426
3501
  },
3427
3502
  ]
3428
3503
  : compileTargets(input)
3504
+ // an app target named like an optional sdk family replaces that family, so
3505
+ // the sdk's swift module must not stay on the module search path.
3429
3506
  const distributionExcludes = distribution
3430
- ? swiftSystemLibraryExclusions(input.files, targets, distribution.modules)
3507
+ ? new Set([
3508
+ ...swiftSystemLibraryExclusions(input.files, targets, distribution.modules),
3509
+ ...distribution.modules.filter(
3510
+ (name) =>
3511
+ OPTIONAL_FRAMEWORKS.has(name) &&
3512
+ targets.some((target) => target.name === name),
3513
+ ),
3514
+ ])
3431
3515
  : undefined
3432
3516
  const files = new Map<string, string | Buffer>()
3433
3517
  const native = new Map<string, SwiftNativeTargetPlan>()
@@ -3559,7 +3643,14 @@ export function writeSwiftProject(
3559
3643
  // publishes; a swiftpm target's stay under its public headers directory.
3560
3644
  for (const settings of input.nativeTargets ?? []) {
3561
3645
  for (const file of settings.headers) {
3562
- const contents = input.files[file]
3646
+ // a source checkout's interface header exists once its module built,
3647
+ // after the input was cut; the staged copy stands in until then
3648
+ const interfaceModule = /(?:^|\/)(\w+)\.framework\/Headers\/\1-Swift\.h$/.exec(
3649
+ file,
3650
+ )?.[1]
3651
+ const contents =
3652
+ (interfaceModule && swiftModuleInterface(moduleRoot, interfaceModule)?.header) ||
3653
+ input.files[file]
3563
3654
  if (contents === undefined)
3564
3655
  throw new Error(`missing original Objective-C header ${file}`)
3565
3656
  const destination = path.join(layout.root, file)
@@ -3609,6 +3700,7 @@ export function writeSwiftProject(
3609
3700
  // declarations are imported before swift can emit the header that native
3610
3701
  // implementations consume. give those implementations a downstream target.
3611
3702
  const importModuleMaps = new Map<string, string>()
3703
+ const generatedModuleMaps: { output: string; module: string; published: string }[] = []
3612
3704
  for (const target of targets) {
3613
3705
  const prefix = target.path === '.' ? '' : `${target.path}/`
3614
3706
  const entries = targetEntries(target)
@@ -3890,7 +3982,12 @@ export function writeSwiftProject(
3890
3982
  const importFlags = [
3891
3983
  ...swiftClangImporterFlags(stageFlags(importOriginalFlags, sdkInclude)),
3892
3984
  '-fmodule-map-file=' + path.join(layout.root, modulemap),
3893
- ...clangImportModuleMapFlags(settings, layout.root, importModuleMaps),
3985
+ ...clangImportModuleMapFlags(
3986
+ settings,
3987
+ layout.root,
3988
+ importModuleMaps,
3989
+ generatedModuleMaps,
3990
+ ),
3894
3991
  ]
3895
3992
  const groups = new Map<
3896
3993
  string,
@@ -4093,6 +4190,18 @@ export function writeSwiftProject(
4093
4190
  ].join('\n'),
4094
4191
  )
4095
4192
  }
4193
+ for (const map of generatedModuleMaps)
4194
+ if (
4195
+ files.has(map.published) ||
4196
+ Object.hasOwn(
4197
+ input.files,
4198
+ path.relative(layout.root, map.published).split(path.sep).join(path.posix.sep),
4199
+ )
4200
+ )
4201
+ writeFileSync(
4202
+ map.output,
4203
+ `extern module ${map.module} ${JSON.stringify(map.published)}\n`,
4204
+ )
4096
4205
  if (native.size > 0) mkdirSync(headerDirectory, { recursive: true })
4097
4206
  const nativeHeaderFlags: string[] = []
4098
4207
  for (const name of new Set(
@@ -4570,18 +4679,7 @@ function builtArtifact(layout: SwiftProjectLayout): string {
4570
4679
  if (executable === undefined) {
4571
4680
  throw new Error('swift-compile: the written manifest names no executable target')
4572
4681
  }
4573
- const file = path.join(binDir, `${executable.name}.wasm`)
4574
- if (!existsSync(file)) {
4575
- const found = existsSync(binDir)
4576
- ? readdirSync(binDir)
4577
- .filter((name) => name.endsWith('.wasm'))
4578
- .sort()
4579
- : []
4580
- throw new Error(
4581
- `swift-compile: the build produced no ${executable.name}.wasm (found: ${found.join(', ') || 'none'})`,
4582
- )
4583
- }
4584
- return file
4682
+ return path.join(binDir, `${executable.name}.wasm`)
4585
4683
  }
4586
4684
 
4587
4685
  function projectDiagnostic(
@@ -4992,15 +5090,19 @@ function frameworkLinkClosure(
4992
5090
  return { objects: files, modules, moduleMaps: [...maps].sort() }
4993
5091
  }
4994
5092
 
4995
- function removeUnbuiltModuleArtifacts(
5093
+ // apps with other optional frameworks share this directory, so only an artifact
5094
+ // whose name differs from a kept module by case alone is removed.
5095
+ function removeCaseCollidingModuleArtifacts(
4996
5096
  modulesDir: string,
4997
5097
  keep: ReadonlySet<string>,
4998
5098
  ): void {
4999
5099
  if (!existsSync(modulesDir)) return
5100
+ const folded = new Set([...keep].map((name) => name.toLowerCase()))
5000
5101
  for (const name of readdirSync(modulesDir)) {
5001
5102
  const dot = name.indexOf('.')
5002
5103
  if (dot <= 0) continue
5003
- if (keep.has(name.slice(0, dot))) continue
5104
+ const module = name.slice(0, dot)
5105
+ if (keep.has(module) || !folded.has(module.toLowerCase())) continue
5004
5106
  rmSync(path.join(modulesDir, name), { recursive: true, force: true })
5005
5107
  }
5006
5108
  }
@@ -5013,7 +5115,7 @@ function removeUnbuiltModuleArtifacts(
5013
5115
  // target's objects and modules under its own package, on either volume.
5014
5116
  async function compileFrameworkProducts(args: {
5015
5117
  moduleRoot: string
5016
- appRoot: string
5118
+ frameworkKey: string
5017
5119
  input: SwiftCompileInput
5018
5120
  swift: string
5019
5121
  sdk: string
@@ -5026,8 +5128,33 @@ async function compileFrameworkProducts(args: {
5026
5128
  link: string[]
5027
5129
  moduleMaps: string[]
5028
5130
  }> {
5029
- const scratch = swiftFrameworkScratch(args.appRoot)
5131
+ const scratch = swiftFrameworkScratch(args.frameworkKey)
5030
5132
  mkdirSync(scratch, { recursive: true })
5133
+ // incremental builds leave the directory's own mtime alone, which the prune reads
5134
+ const now = new Date()
5135
+ utimesSync(scratch, now, now)
5136
+ // apps with this framework revision share the scratch, so one build at a time
5137
+ // uses it. a build that finds the products current only plans and returns.
5138
+ return withSwiftRootLock(
5139
+ scratch,
5140
+ (lease) =>
5141
+ buildFrameworkProducts(scratch, {
5142
+ ...args,
5143
+ buildOptions: { ...args.buildOptions, lease },
5144
+ }),
5145
+ args.buildOptions.signal,
5146
+ )
5147
+ }
5148
+
5149
+ async function buildFrameworkProducts(
5150
+ scratch: string,
5151
+ args: Parameters<typeof compileFrameworkProducts>[0],
5152
+ ): Promise<{
5153
+ modules: string
5154
+ objects: string[]
5155
+ link: string[]
5156
+ moduleMaps: string[]
5157
+ }> {
5031
5158
  const linkedTargets = linkedFrameworkTargets(args.moduleRoot, args.input)
5032
5159
  const linkRoot = path.join(scratch, 'link')
5033
5160
  writeFrameworkLinkPackage(linkRoot, args.moduleRoot, linkedTargets.products)
@@ -5046,7 +5173,7 @@ async function compileFrameworkProducts(args: {
5046
5173
  scratch,
5047
5174
  '--target',
5048
5175
  FRAMEWORK_LINK_TARGET,
5049
- ...swiftSdkOptions(),
5176
+ ...swiftCompileSdkOptions(args.moduleRoot, args.toolchainBin),
5050
5177
  '--swift-sdk',
5051
5178
  args.sdk,
5052
5179
  '-c',
@@ -5073,14 +5200,17 @@ async function compileFrameworkProducts(args: {
5073
5200
  args.buildOptions,
5074
5201
  SWIFTPM_PROGRESS,
5075
5202
  SWIFTPM_NOISE,
5076
- )
5203
+ ).catch((error: unknown) => {
5204
+ // the compiler's diagnostics ride on the error's streams, not its message
5205
+ throw new Error(outputOf(error), { cause: error })
5206
+ })
5077
5207
  const release = path.join(scratch, WASM_TRIPLE, 'release')
5078
5208
  const linked = frameworkLinkClosure(scratch, linkedTargets.targets)
5079
5209
  const objects = linked.objects
5080
5210
  // a previous plan of this scratch may have left a fixture module whose name
5081
5211
  // differs only by case. the app searches this directory, so that file would
5082
5212
  // satisfy the import on a case-insensitive volume.
5083
- removeUnbuiltModuleArtifacts(path.join(release, 'Modules'), linked.modules)
5213
+ removeCaseCollidingModuleArtifacts(path.join(release, 'Modules'), linked.modules)
5084
5214
  const response = path.join(scratch, 'autolink-objects.rsp')
5085
5215
  writeFileSync(response, objects.map((file) => JSON.stringify(file)).join('\n') + '\n')
5086
5216
  const extracted = await runCompiler(
@@ -5119,12 +5249,49 @@ async function compileFrameworkProducts(args: {
5119
5249
  // when it moves, so each revision compiles and links against its own objects
5120
5250
  // the way the builder's per-build-key roots do.
5121
5251
  const SWIFT_LINK_STAMP = '.peach-link-stamp'
5122
- const SWIFT_FRAMEWORK_KEY = '.peach-framework-key'
5123
5252
 
5124
- // the framework package builds in a sibling scratch, so its object and module
5125
- // files never share a directory with the app's own.
5126
- function swiftFrameworkScratch(appRoot: string): string {
5127
- return path.join(path.dirname(appRoot), `${path.basename(appRoot)}.packages`)
5253
+ // one scratch per framework revision on the machine: every app built against
5254
+ // that revision reuses its compiled products.
5255
+ const SWIFT_FRAMEWORK_SCRATCHES_KEPT = 3
5256
+
5257
+ function swiftFrameworksDir(): string {
5258
+ return path.join(swiftCacheDir(), 'swift-frameworks')
5259
+ }
5260
+
5261
+ function swiftFrameworkScratch(frameworkKey: string): string {
5262
+ return path.join(swiftFrameworksDir(), frameworkKey)
5263
+ }
5264
+
5265
+ // a builder receives every delivery at a new path, and swiftpm keys its plan and
5266
+ // llbuild its inputs on absolute paths and inodes. one copy of the module and
5267
+ // its shared sdk per framework key, at a fixed path, gives every delivery
5268
+ // identical inputs. a published distribution is already immutable and stays put.
5269
+ function stageFrameworkSource(moduleRoot: string, frameworkKey: string): string {
5270
+ if (swiftDistributionAt(moduleRoot)) return moduleRoot
5271
+ const staged = path.join(swiftFrameworkScratch(frameworkKey), 'source')
5272
+ const stagedModule = path.join(staged, 'packages', path.basename(moduleRoot))
5273
+ if (existsSync(path.join(staged, '.complete'))) return stagedModule
5274
+ const partial = `${staged}.${randomUUID()}`
5275
+ mkdirSync(partial, { recursive: true })
5276
+ cpSync(moduleRoot, path.join(partial, 'packages', path.basename(moduleRoot)), {
5277
+ recursive: true,
5278
+ preserveTimestamps: true,
5279
+ filter: (source) => path.relative(moduleRoot, source) !== '.build',
5280
+ })
5281
+ cpSync(
5282
+ swiftSharedSdkRoot(moduleRoot, false),
5283
+ path.join(partial, 'packages/peachsim/sdk/ios'),
5284
+ { recursive: true, preserveTimestamps: true },
5285
+ )
5286
+ // the plugin build resolves the macro scanner from the module's node_modules
5287
+ symlinkSync(
5288
+ realpathSync(path.join(moduleRoot, '../../node_modules')),
5289
+ path.join(partial, 'node_modules'),
5290
+ )
5291
+ writeFileSync(path.join(partial, '.complete'), '')
5292
+ rmSync(staged, { recursive: true, force: true })
5293
+ renameSync(partial, staged)
5294
+ return stagedModule
5128
5295
  }
5129
5296
 
5130
5297
  function swiftLinkStamp(args: {
@@ -5149,22 +5316,22 @@ function swiftLinkStamp(args: {
5149
5316
  return hash.digest('hex')
5150
5317
  }
5151
5318
 
5152
- // the framework scratch is keyed by the app root, so it would otherwise carry
5153
- // one revision's package plan and module cache into the next.
5154
- function retireStaleSwiftFrameworks(root: string, key: string): boolean {
5155
- const receipt = path.join(root, SWIFT_FRAMEWORK_KEY)
5156
- let previous: string | null = null
5157
- try {
5158
- previous = readFileSync(receipt, 'utf8').trim()
5159
- } catch (error) {
5160
- if (!vanished(error)) throw error
5161
- }
5162
- // a failed build must not wipe again on every retry
5163
- writeFileSync(receipt, `${key}\n`)
5164
- const scratch = swiftFrameworkScratch(root)
5165
- if (previous === key || !existsSync(scratch)) return false
5166
- rmSync(scratch, { recursive: true, force: true })
5167
- return true
5319
+ // each scratch holds over a gibibyte, so the least recently built revisions go.
5320
+ // a scratch another process holds is skipped.
5321
+ async function pruneFrameworkScratches(keep: string): Promise<void> {
5322
+ const dir = swiftFrameworksDir()
5323
+ const idle = readdirSync(dir)
5324
+ .filter((name) => name !== keep)
5325
+ .map((name) => ({ name, modified: statSync(path.join(dir, name)).mtimeMs }))
5326
+ .sort((left, right) => right.modified - left.modified)
5327
+ .slice(SWIFT_FRAMEWORK_SCRATCHES_KEPT - 1)
5328
+ for (const { name } of idle)
5329
+ await withSwiftRootLock(
5330
+ path.join(dir, name),
5331
+ async () => rmSync(path.join(dir, name), { recursive: true, force: true }),
5332
+ undefined,
5333
+ false,
5334
+ )
5168
5335
  }
5169
5336
 
5170
5337
  /** the root keeps one app object tree per linked framework build. */
@@ -5310,18 +5477,26 @@ export function compileSwiftProjectUnit(
5310
5477
  `swift-compile: no swift.org toolchain at ${options.toolchainBin}; install ${options.release} and its matching wasm sdk`,
5311
5478
  )
5312
5479
  }
5313
- if (retireStaleSwiftFrameworks(root, frameworkKey))
5314
- report('framework revision changed; rebuilding framework products')
5480
+ const frameworkRoot = await withSwiftRootLock(
5481
+ swiftFrameworkScratch(frameworkKey),
5482
+ async () => stageFrameworkSource(moduleRoot, frameworkKey),
5483
+ options.signal,
5484
+ )
5315
5485
  report('preparing compiler plugins')
5316
- const macroPlugins = await ensureMacroPlugins(
5317
- moduleRoot,
5318
- options.toolchainBin,
5319
- options.release,
5486
+ const macroPlugins = await withSwiftRootLock(
5487
+ swiftFrameworkScratch(frameworkKey),
5488
+ async () =>
5489
+ ensureMacroPlugins(
5490
+ frameworkRoot,
5491
+ options.toolchainBin,
5492
+ options.release,
5493
+ options.signal,
5494
+ ),
5320
5495
  options.signal,
5321
5496
  )
5322
5497
  // memoized per toolchain, so only a process's first build waits on it,
5323
5498
  // and that one reads and gzips it while swift builds
5324
- const sdk = swiftModuleSdk(moduleRoot).wasmSdkId
5499
+ const sdk = swiftModuleSdk(frameworkRoot).wasmSdkId
5325
5500
  const icu = swiftIcuAsset(options.toolchainBin, sdk)
5326
5501
  const buildOptions = {
5327
5502
  env: {
@@ -5338,6 +5513,7 @@ export function compileSwiftProjectUnit(
5338
5513
  .join(':'),
5339
5514
  }
5340
5515
  : {}),
5516
+ ...(input.lazyDistribution ? { PEACH_DEFER_WASM_LINK: '1' } : {}),
5341
5517
  },
5342
5518
  maxBuffer: 64 * 1024 * 1024,
5343
5519
  timeout: options.timeoutMs,
@@ -5350,8 +5526,8 @@ export function compileSwiftProjectUnit(
5350
5526
  if (!swiftDistributionAt(moduleRoot)) {
5351
5527
  report('compiling framework products')
5352
5528
  prebuilt = await compileFrameworkProducts({
5353
- moduleRoot,
5354
- appRoot: root,
5529
+ moduleRoot: frameworkRoot,
5530
+ frameworkKey,
5355
5531
  input,
5356
5532
  swift,
5357
5533
  sdk,
@@ -5359,6 +5535,7 @@ export function compileSwiftProjectUnit(
5359
5535
  plugins: macroPlugins,
5360
5536
  buildOptions,
5361
5537
  })
5538
+ await pruneFrameworkScratches(frameworkKey)
5362
5539
  }
5363
5540
  if (
5364
5541
  retireStaleSwiftLink(
@@ -5370,7 +5547,7 @@ export function compileSwiftProjectUnit(
5370
5547
  )
5371
5548
  )
5372
5549
  report('framework revision changed; rebuilding the app link')
5373
- const preparation = writeSwiftProject(layout, input, moduleRoot, prebuilt)
5550
+ const preparation = writeSwiftProject(layout, input, frameworkRoot, prebuilt)
5374
5551
  writeSwiftAutolinkLinker(root, options.toolchainBin)
5375
5552
  const unprepared = preparation.targetFailures.map(
5376
5553
  (failure) => `error: target ${failure}`,
@@ -5384,7 +5561,7 @@ export function compileSwiftProjectUnit(
5384
5561
  BUILD_JOBS,
5385
5562
  '--package-path',
5386
5563
  root,
5387
- ...swiftSdkOptions(),
5564
+ ...swiftCompileSdkOptions(frameworkRoot, options.toolchainBin),
5388
5565
  '--swift-sdk',
5389
5566
  sdk,
5390
5567
  ...(input.packageFiles || prebuilt
@@ -5411,6 +5588,12 @@ export function compileSwiftProjectUnit(
5411
5588
  `${plugin}#ExpoModulesMacros`,
5412
5589
  ]),
5413
5590
  ]
5591
+ const linked = builtArtifact(layout)
5592
+ if (input.lazyDistribution) {
5593
+ rmSync(path.join(root, '.peach-link.rsp'), { force: true })
5594
+ if (existsSync(linked) && statSync(linked).size <= 8)
5595
+ rmSync(linked, { force: true })
5596
+ }
5414
5597
  report('compiling and linking Swift modules')
5415
5598
  try {
5416
5599
  // clang consumes the real emitted headers after swift finishes.
@@ -5473,9 +5656,25 @@ export function compileSwiftProjectUnit(
5473
5656
  }
5474
5657
  }
5475
5658
  if (unprepared.length) throw new Error(unprepared.join('\n'))
5659
+ if (!existsSync(linked)) {
5660
+ const binDir = path.dirname(linked)
5661
+ const found = existsSync(binDir)
5662
+ ? readdirSync(binDir)
5663
+ .filter((name) => name.endsWith('.wasm'))
5664
+ .sort()
5665
+ : []
5666
+ throw new Error(
5667
+ `swift-compile: the build produced no ${path.basename(linked)} (found: ${found.join(', ') || 'none'})`,
5668
+ )
5669
+ }
5670
+ const optimized = `${linked}.optimized`
5671
+ if (input.lazyDistribution) {
5672
+ pruneSwiftWasmLink(root, options.toolchainBin, frameworkRoot)
5673
+ await optimizeWasm(linked, optimized)
5674
+ }
5476
5675
  const artifact = {
5477
5676
  hash,
5478
- bytes: readFileSync(builtArtifact(layout)),
5677
+ bytes: readFileSync(input.lazyDistribution ? optimized : linked),
5479
5678
  icu: await icu,
5480
5679
  }
5481
5680
  saveCompiledArtifact(root, artifact)
@@ -14,6 +14,8 @@ export const SWIFT_DIGEST_SOURCES = [
14
14
  'swift-toolchain.ts',
15
15
  'swift-design-time.ts',
16
16
  'swift-root-lock.ts',
17
+ 'swift-link-roots.ts',
18
+ 'swift-wasm-prune.ts',
17
19
  'swift-objc-import.ts',
18
20
  'swiftContract.ts',
19
21
  'swift-objc-platform.ts',