peachsim 0.1.1728 → 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 (374) 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 +68 -16
  6. package/cli/commands/coverage-swift.ts +112 -4
  7. package/cli/commands/device.ts +3 -1
  8. package/cli/commands/doctor.ts +1 -4
  9. package/cli/commands/inspect/settling.ts +6 -1
  10. package/cli/commands/inspect/wait-ready.ts +22 -2
  11. package/cli/commands/package.ts +33 -21
  12. package/cli/commands/push.ts +56 -0
  13. package/cli/commands/serve.ts +9 -0
  14. package/cli/commands/shell-url.ts +41 -9
  15. package/cli/commands/swift.ts +1 -1
  16. package/cli/current-sim.ts +27 -0
  17. package/cli/drivers/linux-browser-libs.lock.json +323 -1
  18. package/cli/drivers/linux-browser-libs.ts +8 -6
  19. package/cli/drivers/playwright.ts +5 -1
  20. package/cli/internal-child.ts +11 -1
  21. package/cli/main.ts +6 -0
  22. package/cli/native-input.ts +1 -7
  23. package/cli/outbound-endpoints.ts +9 -1
  24. package/cli/packaged-app-launcher.ts +3 -1
  25. package/cli/scene-video.ts +28 -7
  26. package/cli/ws-bridge.ts +3 -1
  27. package/detox/index.ts +18 -5
  28. package/dist-lib/agent-daemon-client.cjs +1 -1
  29. package/dist-lib/agent-events.cjs +1 -1
  30. package/dist-lib/attached-projects.cjs +5 -2
  31. package/dist-lib/auth/shared-session.cjs +5 -2
  32. package/dist-lib/backend-origin.cjs +1 -1
  33. package/dist-lib/beta.cjs +1 -1
  34. package/dist-lib/beta.mjs +1 -1
  35. package/dist-lib/bridge-constants.cjs +1 -1
  36. package/dist-lib/bridge-contract-input.cjs +1 -1
  37. package/dist-lib/bridge-contract-input.mjs +1 -1
  38. package/dist-lib/bridge-contract.cjs +1 -1
  39. package/dist-lib/bridge-contract.mjs +1 -1
  40. package/dist-lib/bundle-channel.cjs +9932 -4561
  41. package/dist-lib/capture-contract.cjs +1 -1
  42. package/dist-lib/capture-contract.mjs +1 -1
  43. package/dist-lib/cloud-contract.cjs +1 -1
  44. package/dist-lib/cloud-contract.mjs +1 -1
  45. package/dist-lib/cloud-test-args.cjs +1 -1
  46. package/dist-lib/cloud-test-args.mjs +1 -1
  47. package/dist-lib/cloud.cjs +1 -1
  48. package/dist-lib/cloud.mjs +1 -1
  49. package/dist-lib/config.cjs +1 -1
  50. package/dist-lib/config.mjs +1 -1
  51. package/dist-lib/detox/index.cjs +30 -8
  52. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  53. package/dist-lib/expo-swift-bundle.cjs +6886 -3303
  54. package/dist-lib/expo-swift-metadata.cjs +14 -2
  55. package/dist-lib/expo-swift-metadata.mjs +14 -2
  56. package/dist-lib/home-paths.cjs +7 -2
  57. package/dist-lib/host/bridge-host.cjs +8513 -3085
  58. package/dist-lib/host/fetch-proxy-handler.cjs +19 -7
  59. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  60. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  61. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  62. package/dist-lib/host/websocket-proxy.cjs +6 -3
  63. package/dist-lib/index.cjs +175 -80
  64. package/dist-lib/jump-to-source-babel.cjs +1 -1
  65. package/dist-lib/jump-to-source-native.cjs +1 -1
  66. package/dist-lib/kotlin-host.cjs +209 -32
  67. package/dist-lib/menu.cjs +7 -1
  68. package/dist-lib/menu.mjs +7 -1
  69. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  70. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  71. package/dist-lib/metro-production-bundle.cjs +1 -1
  72. package/dist-lib/metro-production-bundle.mjs +1 -1
  73. package/dist-lib/metro.cjs +146 -76
  74. package/dist-lib/native-app-identity-project.cjs +76 -39
  75. package/dist-lib/native-app-identity-project.mjs +76 -39
  76. package/dist-lib/native-app-identity.cjs +10 -3
  77. package/dist-lib/native-app-identity.mjs +10 -3
  78. package/dist-lib/native-firebase-metadata.cjs +1 -1
  79. package/dist-lib/native-firebase-metadata.mjs +1 -1
  80. package/dist-lib/plist.cjs +1 -1
  81. package/dist-lib/plist.mjs +1 -1
  82. package/dist-lib/profiles.cjs +5 -2
  83. package/dist-lib/public-brand.cjs +1 -1
  84. package/dist-lib/public-origins-lib-esm.json +25 -23
  85. package/dist-lib/public-origins-lib.json +138 -80
  86. package/dist-lib/react-native-host-modules.cjs +5 -2
  87. package/dist-lib/react-native-host-modules.mjs +5 -2
  88. package/dist-lib/reap-browser.cjs +1 -1
  89. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  90. package/dist-lib/sdk.cjs +4 -1
  91. package/dist-lib/sdk.mjs +4 -1
  92. package/dist-lib/skills.cjs +41126 -36493
  93. package/dist-lib/swift-compile.cjs +2103 -444
  94. package/dist-lib/swift-compile.mjs +2025 -369
  95. package/dist-lib/swift-package.cjs +1 -1
  96. package/dist-lib/swift-package.mjs +1 -1
  97. package/dist-lib/swift-submit.cjs +2 -2
  98. package/dist-lib/swift-submit.mjs +2 -2
  99. package/dist-lib/swift-toolchain.cjs +84 -24
  100. package/dist-lib/swift.cjs +1 -1
  101. package/dist-lib/vite-swift.cjs +6094 -2687
  102. package/dist-lib/vite.cjs +32 -10
  103. package/dist-lib/worklet-executable.cjs +1 -1
  104. package/dist-lib/worklet-executable.mjs +1 -1
  105. package/dist-types/packages/peach-compat/src/stubs/screen-transition-math.d.ts +1 -0
  106. package/dist-types/packages/peach-engine/src/cli-companion.d.ts +1 -0
  107. package/dist-types/packages/peach-engine/src/engine/canvaskit-renderer.d.ts +2 -0
  108. package/dist-types/packages/peach-engine/src/engine/font-config.d.ts +7 -4
  109. package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +1 -3
  110. package/dist-types/packages/peach-engine/src/engine/liquid-glass.d.ts +0 -5
  111. package/dist-types/packages/peach-engine/src/engine/memory-counts.d.ts +8 -0
  112. package/dist-types/packages/peach-engine/src/engine/node.d.ts +10 -1
  113. package/dist-types/packages/peach-engine/src/engine/paint-boundary.d.ts +1 -0
  114. package/dist-types/packages/peach-engine/src/engine/render-damage.d.ts +2 -2
  115. package/dist-types/packages/peach-engine/src/engine/scene-table.d.ts +25 -3
  116. package/dist-types/packages/peach-engine/src/engine/scroll-platform.d.ts +1 -15
  117. package/dist-types/packages/peach-engine/src/engine/scroll.d.ts +1 -3
  118. package/dist-types/packages/peach-engine/src/engine/text-first-baseline.d.ts +6 -0
  119. package/dist-types/packages/peach-engine/src/engine/text-paragraph.d.ts +1 -0
  120. package/dist-types/packages/peach-engine/src/engine/types.d.ts +23 -0
  121. package/dist-types/packages/peach-engine/src/ios/chrome-metrics.d.ts +6 -0
  122. package/dist-types/packages/peach-engine/src/metro-identity-contract.d.ts +33 -0
  123. package/dist-types/packages/peach-engine/src/native-preview-bundle.d.ts +2 -0
  124. package/dist-types/packages/peach-engine/src/preview/bundle-layout.d.ts +1 -1
  125. package/dist-types/packages/peach-engine/src/remote-stream/scene-recording.d.ts +2 -0
  126. package/dist-types/packages/peach-engine/src/render-worker/compositor-gpu.d.ts +1 -1
  127. package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +2 -0
  128. package/dist-types/packages/peach-engine/src/render-worker/metro-bundle-metadata.d.ts +28 -0
  129. package/dist-types/packages/peach-engine/src/render-worker/native-ui-protocol.d.ts +21 -1
  130. package/dist-types/packages/peach-engine/src/render-worker/prepared-boot-bundle.d.ts +7 -0
  131. package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +15 -2
  132. package/dist-types/packages/peach-engine/src/render-worker/scroll-mirror.d.ts +1 -0
  133. package/dist-types/packages/peach-engine/src/render-worker/shell-protocol.d.ts +6 -0
  134. package/dist-types/packages/peach-engine/src/render-worker/test-bridge-protocol.d.ts +3 -3
  135. package/dist-types/packages/peach-engine/src/render-worker/webgpu-frame-transaction.d.ts +1 -0
  136. package/dist-types/packages/peach-engine/src/render-worker/webgpu-readback-scheduler.d.ts +1 -1
  137. package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +14 -1
  138. package/dist-types/packages/peach-engine/src/rolldown-bundle-inventory.d.ts +8 -1
  139. package/dist-types/packages/peach-engine/src/rolldown-production-fingerprint.d.ts +1 -4
  140. package/dist-types/packages/peach-engine/src/rolldown-production-module.d.ts +12 -0
  141. package/dist-types/packages/peach-engine/src/rolldown-production-roles.d.ts +6 -0
  142. package/dist-types/packages/peach-engine/src/settings/devices.d.ts +6 -1
  143. package/dist-types/packages/peach-engine/src/settings/duo-fold-bus.d.ts +1 -0
  144. package/dist-types/packages/peach-engine/src/shell-events.d.ts +4 -0
  145. package/dist-types/packages/peach-kit/src/capabilities.d.ts +8 -0
  146. package/kotlin/README.md +3 -0
  147. package/kotlin/sdk.tar.gz +0 -0
  148. package/package.json +2 -1
  149. package/runtime-companion.json +1 -1
  150. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccount.h +55 -0
  151. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountCredential.h +35 -0
  152. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountStore.h +94 -0
  153. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountType.h +53 -0
  154. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACError.h +37 -0
  155. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/Accounts.h +13 -0
  156. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/AccountsDefines.h +13 -0
  157. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Modules/module.modulemap +5 -0
  158. package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetwork.h +1 -0
  159. package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetworkErrors.h +257 -0
  160. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFByteOrder.h +305 -0
  161. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h +2 -0
  162. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGAffineTransform.h +204 -0
  163. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGBitmapContext.h +260 -0
  164. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGColor.h +164 -0
  165. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGColorConversionInfo.h +101 -0
  166. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGColorSpace.h +510 -0
  167. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGContext.h +1132 -0
  168. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGConvertColorDataWithFormat.h +34 -0
  169. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGDataConsumer.h +83 -0
  170. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGDataProvider.h +197 -0
  171. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGEXRToneMappingGamma.h +36 -0
  172. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGError.h +38 -0
  173. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGFont.h +312 -0
  174. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGFunction.h +106 -0
  175. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGGradient.h +123 -0
  176. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGITUToneMapping.h +31 -0
  177. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGImage.h +409 -0
  178. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGLayer.h +78 -0
  179. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFArray.h +120 -0
  180. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFContentStream.h +55 -0
  181. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFContext.h +535 -0
  182. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFDictionary.h +133 -0
  183. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFDocument.h +252 -0
  184. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFMarkedContentItem.h +37 -0
  185. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFObject.h +67 -0
  186. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFOperatorTable.h +51 -0
  187. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFPage.h +101 -0
  188. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFScanner.h +123 -0
  189. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFStream.h +44 -0
  190. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFString.h +52 -0
  191. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPDFStructureElement.h +87 -0
  192. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPath.h +441 -0
  193. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGPattern.h +89 -0
  194. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGRenderingBufferProvider.h +49 -0
  195. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGShading.h +124 -0
  196. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CGToneMapping.h +85 -0
  197. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.h +44 -252
  198. package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Modules/module.modulemap +1 -0
  199. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/CFNetworkErrors.h +257 -0
  200. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes +58 -9
  201. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h +992 -98
  202. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/NSURLSession+Network.h +32 -0
  203. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/Network.h +51 -0
  204. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/advertise_descriptor.h +193 -0
  205. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/browse_descriptor.h +163 -0
  206. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/browse_result.h +207 -0
  207. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/browser.h +285 -0
  208. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/connection.h +714 -0
  209. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/connection_group.h +629 -0
  210. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/connection_report.h +932 -0
  211. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/content_context.h +229 -0
  212. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/endpoint.h +390 -0
  213. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/error.h +135 -0
  214. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/ethernet_channel.h +349 -0
  215. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/framer_options.h +1187 -0
  216. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/group_descriptor.h +184 -0
  217. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/interface.h +150 -0
  218. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/ip_options.h +351 -0
  219. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/listener.h +438 -0
  220. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/nw_object.h +200 -0
  221. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/parameters.h +1205 -0
  222. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/path.h +392 -0
  223. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/path_monitor.h +216 -0
  224. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/privacy_context.h +188 -0
  225. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/protocol_options.h +126 -0
  226. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/proxy_config.h +357 -0
  227. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/quic_options.h +889 -0
  228. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/resolver_config.h +94 -0
  229. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/tcp_options.h +459 -0
  230. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/tls_options.h +115 -0
  231. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/txt_record.h +432 -0
  232. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/udp_options.h +112 -0
  233. package/sdk/ios/System/Library/Frameworks/Network.framework/Headers/ws_options.h +743 -0
  234. package/sdk/ios/System/Library/Frameworks/Network.framework/Modules/module.modulemap +9 -0
  235. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAAnimation.h +395 -0
  236. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CABase.h +132 -0
  237. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CADisplayLink.h +107 -0
  238. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAEmitterCell.h +153 -0
  239. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAEmitterLayer.h +151 -0
  240. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAFrameRateRange.h +40 -0
  241. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAGradientLayer.h +78 -0
  242. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CALayer.h +1078 -0
  243. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAMediaTiming.h +97 -0
  244. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAMediaTimingFunction.h +67 -0
  245. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAReplicatorLayer.h +65 -0
  246. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAScrollLayer.h +64 -0
  247. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAShapeLayer.h +135 -0
  248. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CATextLayer.h +99 -0
  249. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CATiledLayer.h +67 -0
  250. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CATransaction.h +124 -0
  251. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CATransform3D.h +138 -0
  252. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CATransformLayer.h +40 -0
  253. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAValueFunction.h +78 -0
  254. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/QuartzCore.h +19 -38
  255. package/sdk/ios/System/Library/Frameworks/Security.framework/Headers/SecureTransport.h +1757 -0
  256. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/NSAttributedString.h +19 -0
  257. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/NSParagraphStyle.h +28 -0
  258. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIAccessibilityConstants.h +114 -0
  259. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h +16 -0
  260. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIBarAppearance.h +47 -0
  261. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIDataDetectors.h +20 -0
  262. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIDatePicker.h +13 -0
  263. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIDevice.h +16 -0
  264. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIEvent.h +84 -0
  265. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIGestureRecognizer.h +119 -0
  266. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIGestureRecognizerSubclass.h +66 -0
  267. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIHoverGestureRecognizer.h +45 -0
  268. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h +161 -37
  269. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIPickerView.h +76 -0
  270. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UITabBar.h +8 -0
  271. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UITabBarAppearance.h +78 -0
  272. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UITextInputTraits.h +29 -0
  273. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UITouch.h +104 -0
  274. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UITraitCollection.h +19 -0
  275. package/sdk/ios/usr/include/dns_sd.h +3616 -0
  276. package/sdk/ios/usr/include/dnssd.modulemap +4 -0
  277. package/sdk/ios/usr/include/module.modulemap +1 -0
  278. package/sdk/ios/usr/include/os/signpost.h +414 -0
  279. package/sdk/ios/usr/include/os.modulemap +5 -0
  280. package/sdk/ios/usr/include/sys/socketvar.h +191 -0
  281. package/sdk/ios/usr/include/sys/vsock.h +84 -0
  282. package/sdk/ios/wasm/include/errno.h +4 -20
  283. package/sdk/ios/wasm/include/pthread.h +3 -0
  284. package/sdk/ios/wasm/include/setjmp.h +57 -0
  285. package/sdk/ios/wasm/include/sys/resource.h +2 -2
  286. package/sdk/native-hashes.json +3 -3
  287. package/skills/contrast/SKILL.md +6 -5
  288. package/skills/peach-debug/SKILL.md +68 -265
  289. package/skills/peach-debug/references/accessibility.md +37 -73
  290. package/skills/peach-debug/references/commands.md +2 -2
  291. package/skills/peach-debug/references/events.md +74 -0
  292. package/skills/peach-perf/SKILL.md +64 -402
  293. package/skills/peach-perf/references/presentation.md +46 -0
  294. package/skills/peach-perf/references/profiling.md +93 -0
  295. package/skills/peach-perf/references/render-counters.md +57 -0
  296. package/skills/peach-setup/SKILL.md +66 -217
  297. package/skills/peach-setup/references/native-config.md +35 -0
  298. package/skills/peach-setup/references/reporting.md +28 -0
  299. package/skills/peach-test/SKILL.md +68 -285
  300. package/skills/peach-test/references/detox.md +69 -0
  301. package/skills/peach-test/references/maestro.md +95 -0
  302. package/skills/peach-visual/SKILL.md +53 -106
  303. package/src/android-autolinking.ts +1 -0
  304. package/src/android-bridge-packages.ts +279 -0
  305. package/src/appPackageContract.ts +14 -1
  306. package/src/assetCatalogContract.ts +8 -1
  307. package/src/bridge-contract.ts +6 -0
  308. package/src/bundle-channel.mjs +152 -60
  309. package/src/cli-runtime.ts +3 -0
  310. package/src/configured-bundle-producer.ts +10 -0
  311. package/src/device-catalog.ts +68 -4
  312. package/src/expo-discovery-cache.ts +10 -3
  313. package/src/expo-kotlin-host.ts +97 -26
  314. package/src/expo-native-workspace.ts +211 -52
  315. package/src/expo-swift-host.ts +149 -123
  316. package/src/expo-swift-ready.ts +5 -1
  317. package/src/expo-widget-assets.ts +76 -0
  318. package/src/expoKotlinContract.ts +12 -2
  319. package/src/expoSwiftContract.ts +21 -2
  320. package/src/generated/swift-c-predefines.json +1 -1
  321. package/src/home-paths.ts +6 -1
  322. package/src/host/bridge-host.ts +5 -0
  323. package/src/host/fetch-proxy-handler.ts +10 -0
  324. package/src/host/websocket-proxy.ts +7 -2
  325. package/src/kotlin-host.ts +204 -30
  326. package/src/kotlinSdkContract.ts +2 -1
  327. package/src/menu.ts +7 -0
  328. package/src/native-prebuilt.ts +154 -0
  329. package/src/nitro-adapter.lock.json +261 -261
  330. package/src/nitro-adapter.ts +118 -50
  331. package/src/nitro-bundle.ts +134 -96
  332. package/src/nitro-compile.ts +16 -6
  333. package/src/nitro-dependencies.ts +43 -28
  334. package/src/nitro-source.ts +142 -30
  335. package/src/nitro-superset.lock.json +103 -0
  336. package/src/nitro-superset.ts +137 -0
  337. package/src/nitroAdapterContract.ts +146 -98
  338. package/src/nitroContract.ts +68 -21
  339. package/src/react-bridge-importers.ts +1 -0
  340. package/src/react-native-bridge-modules.ts +2 -0
  341. package/src/react-native-host-modules.ts +4 -1
  342. package/src/settingsContract.ts +37 -1
  343. package/src/storageSnapshotContract.ts +29 -81
  344. package/src/swift-compile.ts +315 -117
  345. package/src/swift-compiler-digest.ts +2 -0
  346. package/src/swift-coverage/indexdump.ts +22 -6
  347. package/src/swift-coverage/indexing.ts +4 -4
  348. package/src/swift-coverage/sdk.ts +104 -20
  349. package/src/swift-coverage/types.ts +34 -0
  350. package/src/swift-coverage/xcode-packages.ts +61 -1
  351. package/src/swift-coverage/xcode.ts +19 -13
  352. package/src/swift-cxx-reachable.ts +1 -1
  353. package/src/swift-distribution.lock.json +18 -13
  354. package/src/swift-distribution.ts +57 -26
  355. package/src/swift-host.ts +51 -35
  356. package/src/swift-link-roots.ts +45 -18
  357. package/src/swift-objc-compile.ts +78 -2
  358. package/src/swift-objc-standin.ts +3 -0
  359. package/src/swift-shared-sdk.ts +85 -1
  360. package/src/swift-standin-emit.ts +6 -1
  361. package/src/swift-standins.ts +403 -19
  362. package/src/swift-submit.ts +17 -1
  363. package/src/swift-toolchain.ts +98 -23
  364. package/src/swift-wasm-prune.ts +1629 -0
  365. package/src/turbo-bundle.ts +82 -0
  366. package/src/turbo-compile.ts +120 -0
  367. package/src/turbo-runtime.lock.json +69 -0
  368. package/src/turbo-source.ts +754 -0
  369. package/src/vite-plugin-one.ts +15 -3
  370. package/src/vite-plugin.ts +82 -23
  371. package/src/wasm-optimize.ts +34 -0
  372. package/src/worker-system-chunks.ts +3 -3
  373. package/src/xcode-project.ts +52 -0
  374. package/src/xcode-target-members.ts +12 -1
@@ -1,13 +1,15 @@
1
1
  // the SwiftUI module app Swift compiles against on this machine, and the
2
2
  // swift.org toolchain that compiles it. a source checkout links
3
3
  // packages/sootsim-swift; an installed peach downloads the prebuilt
4
- // distribution from PEACH_SWIFT_ENDPOINT, verifies it against the lock this
5
- // build carries, and unpacks it under the peach home
4
+ // distribution from PEACH_SWIFT_ENDPOINT, or the public default when it is
5
+ // unset, verifies it against the lock this build carries, and unpacks it under
6
+ // the peach home
6
7
  // (docs/swift-distribution.md). no path here asks Contrast to compile.
7
8
  import fs from 'node:fs'
8
9
  import os from 'node:os'
9
10
  import path from 'node:path'
10
11
  import { installVerifiedTarball } from '@contrast/runtime-delivery'
12
+ import { ensureLinuxBrowserLibraries } from '../cli/drivers/linux-browser-libs'
11
13
  import { rnxHomeDir } from './home-paths'
12
14
  import { swiftDistributionAt, swiftModuleSdk } from './swift-compile'
13
15
  import {
@@ -19,10 +21,14 @@ import {
19
21
  import lockJson from './swift-distribution.lock.json' with { type: 'json' }
20
22
  import {
21
23
  confineSwiftScratch,
24
+ ensureSwiftLinuxRuntime,
22
25
  installSwiftWasmSdk,
26
+ privateSwiftDistributionRoot,
27
+ SWIFT_PRIVATE_DISTRIBUTION_ENV,
23
28
  swiftCompiler,
24
29
  swiftCompilerInstallSteps,
25
30
  sourceSwiftCheckout,
31
+ setSwiftLinuxLibraryPath,
26
32
  swiftHostCompilerArchive,
27
33
  swiftToolchain,
28
34
  swiftToolchainBin,
@@ -32,6 +38,17 @@ import {
32
38
 
33
39
  export const SWIFT_ENDPOINT_ENV = 'PEACH_SWIFT_ENDPOINT'
34
40
 
41
+ /** where an installed peach downloads distribution archives when
42
+ * PEACH_SWIFT_ENDPOINT is unset: compiled objects only, content addressed and
43
+ * checked against the locks this build carries. */
44
+ export const DEFAULT_SWIFT_ENDPOINT = 'https://r2.sootsim.com/swift-distribution'
45
+
46
+ export function swiftEndpoint(): string {
47
+ return (
48
+ process.env[SWIFT_ENDPOINT_ENV]?.trim().replace(/\/+$/, '') || DEFAULT_SWIFT_ENDPOINT
49
+ )
50
+ }
51
+
35
52
  export interface SwiftModule {
36
53
  /** the module root compileSwiftProjectUnit links: a checkout or a distribution. */
37
54
  root: string
@@ -48,21 +65,29 @@ const installs = new Map<
48
65
  }
49
66
  >()
50
67
 
51
- /** the installed distribution's root, downloading it on first use, or null
52
- * when PEACH_SWIFT_ENDPOINT is unset. */
53
- export async function swiftDistributionRoot(
54
- signal?: AbortSignal,
55
- ): Promise<string | null> {
68
+ /** the installed distribution's root, downloading it on first use. */
69
+ export async function swiftDistributionRoot(signal?: AbortSignal): Promise<string> {
56
70
  signal?.throwIfAborted()
57
- const endpoint = process.env[SWIFT_ENDPOINT_ENV]?.trim().replace(/\/+$/, '')
58
- if (!endpoint) return null
59
- const lock = parseSwiftDistributionLock(lockJson)
60
71
  const host = swiftDistributionHost(process.platform, process.arch)
61
72
  if (!host) {
62
73
  throw new Error(
63
74
  `peach has no Swift distribution for ${process.platform}-${process.arch}; it ships for macOS arm64 and Linux x64 and arm64`,
64
75
  )
65
76
  }
77
+ // a developer's unpublished distribution: its own manifest is the identity,
78
+ // so no lock, endpoint or download applies. its builder installs the compiler
79
+ // and SDK; swiftModuleToolchain verifies them against the manifest.
80
+ const privateRoot = privateSwiftDistributionRoot()
81
+ if (privateRoot) {
82
+ const manifest = swiftDistributionAt(privateRoot)
83
+ if (manifest?.host !== host)
84
+ throw new Error(
85
+ `${privateRoot} holds no Swift distribution for ${host} (${SWIFT_PRIVATE_DISTRIBUTION_ENV})`,
86
+ )
87
+ return privateRoot
88
+ }
89
+ const endpoint = swiftEndpoint()
90
+ const lock = parseSwiftDistributionLock(lockJson)
66
91
  // the archive is useless without its compiler, so the toolchain installs
67
92
  // or fails before the download
68
93
  await installSwiftToolchain(lock.release, lock, signal)
@@ -151,7 +176,6 @@ async function installSwiftToolchain(
151
176
  signal?: AbortSignal,
152
177
  ): Promise<void> {
153
178
  process.env.PEACH_SWIFT_SDKS_PATH ??= path.join(rnxHomeDir(), 'swift', 'sdks')
154
- if (swiftToolchainReady(release, sdk)) return
155
179
  const root = path.resolve(swiftToolchainBin(release), '../..')
156
180
  // macOS installs where the locator looks first, the user's Toolchains
157
181
  // directory, and only into a directory without a compiler; linux installs
@@ -181,6 +205,15 @@ async function installSwiftToolchain(
181
205
  verify: (dir) => verifySwiftHostCompiler(release, dir),
182
206
  })
183
207
  }
208
+ ensureSwiftLinuxRuntime(release)
209
+ for (const executable of ['swift', 'swift-package', 'swift-frontend', 'wasm-ld']) {
210
+ const libraries = await ensureLinuxBrowserLibraries(
211
+ path.join(root, 'usr/bin', executable),
212
+ 'Swift',
213
+ )
214
+ if (!libraries.ok) throw new Error(libraries.message)
215
+ if (libraries.libraryPath) setSwiftLinuxLibraryPath(libraries.libraryPath)
216
+ }
184
217
  try {
185
218
  swiftCompiler(release)
186
219
  } catch (error) {
@@ -225,28 +258,26 @@ function swiftToolchainReady(release: string, sdk: SwiftWasmSdk): boolean {
225
258
  }
226
259
  }
227
260
 
228
- /** the module this process compiles app Swift against: the checkout beside a
229
- * source peach, else the distribution, else null. `required` callers compile
230
- * nothing without it, so a checkout's toolchain error surfaces to them. */
261
+ /** the module this process compiles app Swift against, installing its pinned
262
+ * compiler and SDK before returning either a checkout or a distribution. */
231
263
  export async function resolveSwiftModule({
232
- required = false,
233
264
  signal,
234
- }: { required?: boolean; signal?: AbortSignal } = {}): Promise<SwiftModule | null> {
265
+ }: { signal?: AbortSignal } = {}): Promise<SwiftModule> {
235
266
  signal?.throwIfAborted()
236
267
  confineSwiftScratch(path.join(rnxHomeDir(), 'cache', 'swift-tmp'))
237
268
  const checkout = sourceSwiftCheckout()
238
- if (fs.existsSync(path.join(checkout, 'toolchain.json'))) {
239
- // a checkout is implicit: without its toolchain, apps run without their
240
- // Swift. a distribution is asked for, so its toolchain errors surface.
241
- try {
242
- return { root: checkout, ...swiftModuleToolchain(checkout) }
243
- } catch (error) {
244
- if (required) throw error
245
- return null
246
- }
269
+ if (
270
+ !privateSwiftDistributionRoot() &&
271
+ fs.existsSync(path.join(checkout, 'toolchain.json'))
272
+ ) {
273
+ const pin: { release: string } = JSON.parse(
274
+ fs.readFileSync(path.join(checkout, 'toolchain.json'), 'utf8'),
275
+ )
276
+ await installSwiftToolchain(pin.release, swiftModuleSdk(checkout), signal)
277
+ return { root: checkout, ...swiftModuleToolchain(checkout) }
247
278
  }
248
279
  const root = await swiftDistributionRoot(signal)
249
- return root ? { root, ...swiftModuleToolchain(root) } : null
280
+ return { root, ...swiftModuleToolchain(root) }
250
281
  }
251
282
 
252
283
  /** the release a module root was built for and its installed toolchain. */
package/src/swift-host.ts CHANGED
@@ -11,8 +11,6 @@ import {
11
11
  resolveSwiftImageResourceUrls,
12
12
  } from '../../sootsim-swift/src/bundleAssets'
13
13
  import { compileStringCatalog } from '../../sootsim-swift/src/stringCatalog'
14
- import { authHeaderValue, resolveCliAuth } from '../cli/auth'
15
- import { resolveContrastBackendOrigin } from './backend-origin'
16
14
  import { swiftCacheDir } from './home-paths'
17
15
  import iosSdk from './ios-sdk-frameworks.json' with { type: 'json' }
18
16
  import { type NativeAppIdentity } from './native-app-identity'
@@ -296,6 +294,8 @@ interface XcodeProjectEntry {
296
294
  provided: ReadonlySet<string> | null
297
295
  /** the module root a local compile links, which builds binary stand-ins. */
298
296
  moduleRoot: string | null
297
+ /** the distribution whose generated interface headers an installed pod's declarations come from. */
298
+ interfaceRoot: string | null
299
299
  behavior?: SwiftStandinBehaviors
300
300
  packages?: {
301
301
  key: string
@@ -371,6 +371,7 @@ export function openXcodeProject(
371
371
  target: string | undefined,
372
372
  moduleRoot: string | undefined,
373
373
  configuration?: string,
374
+ interfaceRoot?: string,
374
375
  ): string {
375
376
  const app = readXcodeAppTargetPrepared(xcodeproj, target, configuration, {
376
377
  prepareGeneratedSources: true,
@@ -383,6 +384,7 @@ export function openXcodeProject(
383
384
  configuration: app.configuration,
384
385
  provided: moduleRoot ? new Set(swiftPeachModules(moduleRoot)) : null,
385
386
  moduleRoot: moduleRoot ?? null,
387
+ interfaceRoot: interfaceRoot ?? null,
386
388
  })
387
389
  return root
388
390
  }
@@ -656,6 +658,9 @@ function buildXcodeLayout(root: string): XcodeLayout | null {
656
658
  }
657
659
  targetAssetSymbols(app, XCODE_APP_DIR)
658
660
  for (const framework of app.frameworks) {
661
+ // a framework target that only links products compiles nothing, so it has
662
+ // no module, directory or bundle contents for swiftpm to take as a target
663
+ if (framework.allSources.length === 0 && framework.resources.length === 0) continue
659
664
  const dir = path.posix.join(XCODE_FRAMEWORKS_DIR, framework.moduleName)
660
665
  resourceBundles.push({
661
666
  target: framework.moduleName,
@@ -900,7 +905,11 @@ function buildXcodeLayout(root: string): XcodeLayout | null {
900
905
  file,
901
906
  path.relative(app.rootDir, file).split(path.sep).join('/') || '.',
902
907
  )
903
- const nativeInputs = xcodeObjCInputs(app, binaries)
908
+ const nativeInputs = xcodeObjCInputs(
909
+ app,
910
+ binaries,
911
+ registered.moduleRoot ?? registered.interfaceRoot,
912
+ )
904
913
  const nativeFiles = nativeInputs.sources
905
914
  for (const file of nativeFiles.keys()) files.add(file)
906
915
  const nativeHeaders = [...nativeFiles.keys()].filter((file) =>
@@ -1012,6 +1021,9 @@ function buildXcodeLayout(root: string): XcodeLayout | null {
1012
1021
  if (!settings.publicHeaders) continue
1013
1022
  const target = packages.targets.find((value) => value.name === settings.name)
1014
1023
  if (!target) continue
1024
+ const prefixHeader = path.posix.join(target.path, 'PeachPodPrefix.pch')
1025
+ generatedSources[prefixHeader] =
1026
+ '#ifdef __OBJC__\n#import <UIKit/UIKit.h>\n#import <Foundation/Foundation.h>\n#endif\n'
1015
1027
  nativeTargets.push({
1016
1028
  name: target.name,
1017
1029
  deploymentTarget: settings.deploymentTarget,
@@ -1025,7 +1037,7 @@ function buildXcodeLayout(root: string): XcodeLayout | null {
1025
1037
  .map(relative),
1026
1038
  flattensPublicHeaders: false,
1027
1039
  bridgingHeader: null,
1028
- prefixHeader: null,
1040
+ prefixHeader,
1029
1041
  headerSearchPaths: settings.includes.map(relative),
1030
1042
  moduleMaps: settings.moduleMaps.map((map) => ({
1031
1043
  module: map.module,
@@ -1363,6 +1375,7 @@ const RESOURCE_CONTENT_TYPES: Record<string, string> = {
1363
1375
  '.jpeg': 'image/jpeg',
1364
1376
  '.jpg': 'image/jpeg',
1365
1377
  '.png': 'image/png',
1378
+ '.svg': 'image/svg+xml',
1366
1379
  '.webp': 'image/webp',
1367
1380
  }
1368
1381
 
@@ -1477,7 +1490,7 @@ export function buildSwiftResourceTable(
1477
1490
  registered.set(`${sha256}.metal`, { bytes, contentType: 'text/plain; charset=utf-8' })
1478
1491
  }
1479
1492
  let imageBytes = 0
1480
- for (const { name, file, scale, bundlePath } of found) {
1493
+ for (const { name, file, scale, bundlePath, renderingMode } of found) {
1481
1494
  const disk = byRelative.get(file)
1482
1495
  if (!disk) continue
1483
1496
  if (Object.keys(images).length >= limits.images) {
@@ -1513,7 +1526,11 @@ export function buildSwiftResourceTable(
1513
1526
  const hash = createHash('sha256').update(bytes).digest('hex').slice(0, 16)
1514
1527
  const bundle = table[bundlePath] ?? Object.create(null)
1515
1528
  const variants = (bundle[name] ??= [])
1516
- variants.push({ uri: `${baseUrl}${RESOURCE_PATH}${hash}${ext}`, scale })
1529
+ variants.push({
1530
+ uri: `${baseUrl}${RESOURCE_PATH}${hash}${ext}`,
1531
+ scale,
1532
+ ...(renderingMode ? { renderingMode } : {}),
1533
+ })
1517
1534
  table[bundlePath] = bundle
1518
1535
  const key = layout ? xcodeInputKey(layout, disk, file) : file
1519
1536
  images[key] = {
@@ -2059,6 +2076,21 @@ export function compileInput(packagePath: string, entry: string): SwiftCompileIn
2059
2076
  )
2060
2077
  }
2061
2078
 
2079
+ // the compile input of an installed workspace with the binary frameworks its
2080
+ // pods and project vendor, read from one layout.
2081
+ export function installedWorkspaceInput(
2082
+ packagePath: string,
2083
+ entry: string,
2084
+ ): { input: SwiftCompileInput; binaryFrameworks: string[] } {
2085
+ return withXcodeLayout(() => {
2086
+ const input = snapshotCompileInput(packageSnapshot(projectFor(packagePath), entry))
2087
+ const binaryFrameworks = (
2088
+ xcodeLayout(fs.realpathSync(packagePath))?.app.binaryFrameworks ?? []
2089
+ ).flatMap(({ path: dir }) => (dir ? [dir] : []))
2090
+ return { input, binaryFrameworks }
2091
+ })
2092
+ }
2093
+
2062
2094
  async function compile(
2063
2095
  packagePath: string,
2064
2096
  stamp: string,
@@ -2085,20 +2117,13 @@ async function compile(
2085
2117
  stamp,
2086
2118
  package: content,
2087
2119
  }
2088
- // a linked checkout, else the installed distribution; with neither, the
2089
- // package compiles on Contrast as before
2120
+ // a linked checkout, else the installed distribution
2090
2121
  const moduleRoot =
2091
2122
  moduleRootOverride ??
2092
2123
  linkedModuleRoots(packagePath).find((root) =>
2093
2124
  fs.existsSync(path.join(root, 'toolchain.json')),
2094
2125
  ) ??
2095
2126
  (await swiftDistributionRoot(signal))
2096
- if (!moduleRoot)
2097
- return {
2098
- ...(await compileRemote(packagePath, snapshot, undefined, signal)),
2099
- stamp,
2100
- package: content,
2101
- }
2102
2127
  const toolchain = swiftModuleToolchain(moduleRoot)
2103
2128
  const input = snapshotCompileInput(snapshot)
2104
2129
  const compiled = {
@@ -2144,16 +2169,14 @@ async function compile(
2144
2169
  if (process.env.CONTRAST_SWIFT_BUILD_ROOT)
2145
2170
  return process.env.CONTRAST_SWIFT_BUILD_ROOT
2146
2171
  const resolvedPath = path.resolve(packagePath)
2147
- // units of one app share a root so the module cache stays warm.
2148
- // peach-expo-swift/<app>/<scope>/<package> shares <app>/<scope>, and
2149
- // the older <app>/<package> layout shares <app>. the scope is this
2150
- // process, so two servers do not compile into one tree.
2172
+ // units of one app share a root so the module cache stays warm across
2173
+ // server restarts: peach-expo-swift/<app>/<scope>/<package> shares
2174
+ // <app>. servers on one app queue on the root lock.
2151
2175
  const parts = resolvedPath.split(path.sep)
2152
2176
  const expoAt = parts.lastIndexOf('peach-expo-swift')
2153
- const scoped = expoAt >= 0 && parts.length >= expoAt + 4
2154
2177
  const buildKeyPath =
2155
2178
  expoAt >= 0 && parts.length >= expoAt + 3
2156
- ? parts.slice(0, scoped ? expoAt + 3 : expoAt + 2).join(path.sep)
2179
+ ? parts.slice(0, expoAt + 2).join(path.sep)
2157
2180
  : (sourceEntries.get(resolvedPath) ?? resolvedPath)
2158
2181
  return path.join(
2159
2182
  swiftCacheDir(),
@@ -2334,9 +2357,9 @@ async function missingModulesMessage(
2334
2357
  ].join('\n')
2335
2358
  }
2336
2359
 
2337
- // a peachsim with neither a module checkout nor a distribution compiles the
2338
- // package where a Contrast project's compiles: Contrast's compile
2339
- // route, authorized by `peach login` or PEACH_API_KEY. the service renders the
2360
+ // a hosted compile (`peach swift --upload-source`) compiles the package where
2361
+ // a Contrast project's compiles: Contrast's compile route, authorized by
2362
+ // `peach login` or PEACH_API_KEY. the service renders the
2340
2363
  // native dispatch glue itself under the package's id and answers the wasm at a
2341
2364
  // public content address, which is fetched once and served from this dev
2342
2365
  // server like a local build. resource bytes share the compile snapshot and
@@ -2344,20 +2367,10 @@ async function missingModulesMessage(
2344
2367
  async function compileRemote(
2345
2368
  packagePath: string,
2346
2369
  snapshot: SwiftPackageSnapshot,
2347
- hosted?: SwiftHostedCompileOptions,
2370
+ hosted: SwiftHostedCompileOptions,
2348
2371
  ownerSignal?: AbortSignal,
2349
2372
  ): Promise<Omit<SwiftArtifact, 'stamp' | 'package'>> {
2350
- const auth = hosted ? null : resolveCliAuth()
2351
- if (!hosted && (!auth || auth.kind === 'github')) {
2352
- throw new Error(
2353
- `compiling ${path.basename(packagePath)} for Peach needs \`peach login\` or PEACH_API_KEY: this peachsim has no local SwiftUI module, so Contrast compiles it`,
2354
- )
2355
- }
2356
- const origin =
2357
- hosted?.origin ??
2358
- resolveContrastBackendOrigin(auth?.kind === 'session' ? auth.origin : null)
2359
- const authorization =
2360
- hosted?.authorization ?? (auth ? authHeaderValue(auth) : undefined)
2373
+ const { origin, authorization } = hosted
2361
2374
  const signal = AbortSignal.any([
2362
2375
  ...(ownerSignal ? [ownerSignal] : []),
2363
2376
  AbortSignal.timeout(DEFAULT_SWIFT_COMPILE_BUILD_MS + 60_000),
@@ -2391,6 +2404,9 @@ async function compileRemote(
2391
2404
  }
2392
2405
  : {}),
2393
2406
  ...(snapshot.nativeTargets ? { nativeTargets: snapshot.nativeTargets } : {}),
2407
+ ...(snapshot.defaultLocalization
2408
+ ? { defaultLocalization: snapshot.defaultLocalization }
2409
+ : {}),
2394
2410
  metalSources: snapshot.resources.metalUploads,
2395
2411
  resourcePaths: snapshot.resourcePaths,
2396
2412
  resourceBundles: snapshot.bundleFiles.bundles,
@@ -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'),