peachsim 0.1.1644 → 0.1.1654

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 (618) hide show
  1. package/README.md +12 -0
  2. package/cli/app-catalog.ts +1 -1
  3. package/cli/app-fonts.ts +11 -80
  4. package/cli/app-splash.ts +18 -12
  5. package/cli/app-stubs.ts +97 -14
  6. package/cli/bridge-diagnostics.ts +10 -7
  7. package/cli/bridge-flow-runner.ts +11 -7
  8. package/cli/cloud-client.ts +21 -15
  9. package/cli/command-registry.ts +13 -4
  10. package/cli/commands/box.ts +4 -4
  11. package/cli/commands/control.ts +93 -53
  12. package/cli/commands/coverage-parser.ts +67 -0
  13. package/cli/commands/coverage.ts +550 -0
  14. package/cli/commands/debug.ts +9 -18
  15. package/cli/commands/desktop.ts +19 -7
  16. package/cli/commands/device.ts +14 -9
  17. package/cli/commands/doctor.ts +20 -10
  18. package/cli/commands/guest-host.ts +6 -10
  19. package/cli/commands/inspect/core.ts +83 -18
  20. package/cli/commands/inspect/shared.ts +2 -0
  21. package/cli/commands/inspect.ts +24 -10
  22. package/cli/commands/kotlin.ts +2 -2
  23. package/cli/commands/maestro-compare.ts +1 -1
  24. package/cli/commands/platform.ts +20 -11
  25. package/cli/commands/preview.ts +16 -18
  26. package/cli/commands/runtime.ts +3 -2
  27. package/cli/commands/screenshot-layers.ts +1 -1
  28. package/cli/commands/screenshot.ts +1 -1
  29. package/cli/commands/serve.ts +5 -1
  30. package/cli/commands/support.ts +4 -4
  31. package/cli/commands/three-mode.ts +22 -15
  32. package/cli/commands/upload.ts +44 -45
  33. package/cli/current-sim.ts +38 -0
  34. package/cli/desktop-companion.ts +36 -8
  35. package/cli/device-option.ts +1 -1
  36. package/cli/drivers/playwright.ts +1 -0
  37. package/cli/drivers/types.ts +4 -0
  38. package/cli/help-core.ts +1 -1
  39. package/cli/internal-child.ts +2 -1
  40. package/cli/main.ts +9 -3
  41. package/cli/outbound-endpoints.ts +11 -3
  42. package/cli/output-redaction.ts +59 -18
  43. package/cli/pause-aware-timeout.ts +24 -10
  44. package/cli/remote-simulators.ts +4 -1
  45. package/cli/scene-video.ts +5 -2
  46. package/cli/send-to-box.ts +7 -10
  47. package/cli/telemetry.ts +1 -1
  48. package/cli/ws-bridge.ts +25 -2
  49. package/detox/attempt-events.cjs +3 -1
  50. package/detox/attempt-events.d.cts +1 -1
  51. package/detox/expectations.ts +108 -99
  52. package/detox/frame-offset.d.mts +6 -0
  53. package/detox/frame-offset.mjs +35 -0
  54. package/detox/gestures.ts +6 -18
  55. package/detox/index.ts +169 -101
  56. package/detox/jest-preset.cjs +1 -3
  57. package/detox/jest-transform.cjs +4 -0
  58. package/detox/matchers.ts +3 -0
  59. package/detox/motion-change.cjs +46 -114
  60. package/detox/motion-change.d.cts +5 -27
  61. package/dist-lib/agent-daemon-client.cjs +1 -1
  62. package/dist-lib/agent-events.cjs +1 -1
  63. package/dist-lib/attached-projects.cjs +1 -1
  64. package/dist-lib/auth/shared-session.cjs +1 -1
  65. package/dist-lib/backend-origin.cjs +1 -1
  66. package/dist-lib/beta.cjs +1 -1
  67. package/dist-lib/beta.mjs +1 -1
  68. package/dist-lib/bridge-constants.cjs +1 -1
  69. package/dist-lib/bridge-contract-input.cjs +65 -1
  70. package/dist-lib/bridge-contract-input.mjs +63 -1
  71. package/dist-lib/bridge-contract.cjs +19 -1
  72. package/dist-lib/bridge-contract.mjs +17 -1
  73. package/dist-lib/bundle-channel.cjs +38081 -14844
  74. package/dist-lib/capture-contract.cjs +1 -1
  75. package/dist-lib/capture-contract.mjs +1 -1
  76. package/dist-lib/cloud-contract.cjs +1 -1
  77. package/dist-lib/cloud-contract.mjs +1 -1
  78. package/dist-lib/cloud-test-args.cjs +1 -1
  79. package/dist-lib/cloud-test-args.mjs +1 -1
  80. package/dist-lib/cloud.cjs +1 -1
  81. package/dist-lib/cloud.mjs +1 -1
  82. package/dist-lib/config.cjs +1 -1
  83. package/dist-lib/config.mjs +5 -3
  84. package/dist-lib/detox/index.cjs +1277 -4507
  85. package/dist-lib/detox/jest-preset.cjs +1 -3
  86. package/dist-lib/detox/jest-transform.cjs +4 -0
  87. package/dist-lib/dev-bundle-resolution.cjs +28 -24
  88. package/dist-lib/expo-swift-bundle.cjs +35039 -13123
  89. package/dist-lib/expo-swift-metadata.cjs +1 -1
  90. package/dist-lib/expo-swift-metadata.mjs +1 -1
  91. package/dist-lib/home-paths.cjs +1 -1
  92. package/dist-lib/host/bridge-host.cjs +45136 -63149
  93. package/dist-lib/host/fetch-proxy-handler.cjs +3689 -11
  94. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  95. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  96. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  97. package/dist-lib/host/websocket-proxy.cjs +1 -1
  98. package/dist-lib/index.cjs +7740 -7600
  99. package/dist-lib/jump-to-source-babel.cjs +1 -1
  100. package/dist-lib/jump-to-source-native.cjs +1 -1
  101. package/dist-lib/kotlin-host.cjs +2 -2
  102. package/dist-lib/menu.cjs +1 -1
  103. package/dist-lib/menu.mjs +1 -1
  104. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  105. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  106. package/dist-lib/metro-production-bundle.cjs +1 -1
  107. package/dist-lib/metro-production-bundle.mjs +1 -1
  108. package/dist-lib/metro.cjs +441 -535
  109. package/dist-lib/native-app-identity-project.cjs +39 -252
  110. package/dist-lib/native-app-identity-project.mjs +1174 -11
  111. package/dist-lib/native-app-identity.cjs +8 -3
  112. package/dist-lib/native-app-identity.mjs +8 -3
  113. package/dist-lib/native-firebase-metadata.cjs +1 -1
  114. package/dist-lib/native-firebase-metadata.mjs +1 -1
  115. package/dist-lib/plist.cjs +2 -244
  116. package/dist-lib/plist.mjs +1 -1
  117. package/dist-lib/profiles.cjs +1 -1
  118. package/dist-lib/public-brand.cjs +1 -1
  119. package/dist-lib/public-origins-lib-esm.json +290 -0
  120. package/dist-lib/public-origins-lib-static.json +1 -0
  121. package/dist-lib/public-origins-lib.json +1860 -0
  122. package/dist-lib/react-native-host-modules.cjs +1 -1
  123. package/dist-lib/react-native-host-modules.mjs +1 -1
  124. package/dist-lib/scripts/dev-server-scanner.cjs +14 -253
  125. package/dist-lib/sdk.cjs +84 -17
  126. package/dist-lib/sdk.mjs +82 -16
  127. package/dist-lib/skills.cjs +50663 -75116
  128. package/dist-lib/swift-compile.cjs +25912 -1065
  129. package/dist-lib/swift-compile.mjs +25901 -1049
  130. package/dist-lib/swift-package.cjs +79 -1
  131. package/dist-lib/swift-package.mjs +75 -1
  132. package/dist-lib/swift-submit.cjs +1 -1
  133. package/dist-lib/swift-submit.mjs +1 -1
  134. package/dist-lib/swift-toolchain.cjs +1 -1
  135. package/dist-lib/swift.cjs +1 -1
  136. package/dist-lib/vite-swift.cjs +34294 -12378
  137. package/dist-lib/vite.cjs +687 -427
  138. package/dist-lib/worklet-executable.cjs +1 -1
  139. package/dist-lib/worklet-executable.mjs +1 -1
  140. package/dist-types/packages/peach-compat/src/engine-config.d.ts +2 -0
  141. package/dist-types/packages/peach-compat/src/stubs/form-sheet-spring.d.ts +9 -0
  142. package/dist-types/packages/peach-compat/src/stubs/native-evaluation-lease.d.ts +47 -0
  143. package/dist-types/packages/peach-compat/src/stubs/native-seams/react-native-cookies.d.ts +113 -0
  144. package/dist-types/packages/peach-compat/src/stubs/native-seams/react-native-gesture-handler.d.ts +155 -0
  145. package/dist-types/packages/peach-compat/src/stubs/screen-transition-math.d.ts +759 -0
  146. package/dist-types/packages/peach-compat/src/stubs/transition-scalar.d.ts +25 -0
  147. package/dist-types/packages/peach-engine/src/billing/plans.d.ts +64 -0
  148. package/dist-types/packages/peach-engine/src/browser-page-target.d.ts +2 -0
  149. package/dist-types/packages/peach-engine/src/bundle-platform-url.d.ts +3 -0
  150. package/dist-types/packages/peach-engine/src/capture/browser-accessibility-host.d.ts +3 -0
  151. package/dist-types/packages/peach-engine/src/capture/browser-composite.d.ts +65 -0
  152. package/dist-types/packages/peach-engine/src/capture/browserAccessibilityContract.d.ts +27 -0
  153. package/dist-types/packages/peach-engine/src/capture/nativeScreenCaptureContract.d.ts +22 -0
  154. package/dist-types/packages/peach-engine/src/cli-companion.d.ts +37 -0
  155. package/dist-types/packages/peach-engine/src/components/native-ui/webview-frame-bridge.d.ts +34 -0
  156. package/dist-types/packages/peach-engine/src/config.d.ts +5 -0
  157. package/dist-types/packages/peach-engine/src/engine/android-stretch-effect.d.ts +57 -0
  158. package/dist-types/packages/peach-engine/src/engine/animated-driven-style.d.ts +47 -0
  159. package/dist-types/packages/peach-engine/src/engine/animated-value.d.ts +5 -0
  160. package/dist-types/packages/peach-engine/src/engine/animated.d.ts +195 -0
  161. package/dist-types/packages/peach-engine/src/engine/animation-clockContract.d.ts +15 -0
  162. package/dist-types/packages/peach-engine/src/engine/animation-graph.d.ts +148 -0
  163. package/dist-types/packages/peach-engine/src/engine/app-catalog-wire.d.ts +10 -0
  164. package/dist-types/packages/peach-engine/src/engine/app-font-registry.d.ts +87 -0
  165. package/dist-types/packages/peach-engine/src/engine/attributed-paragraph-paint.d.ts +7 -0
  166. package/dist-types/packages/peach-engine/src/engine/attributed-paragraph.d.ts +123 -0
  167. package/dist-types/packages/peach-engine/src/engine/audioContract.d.ts +16 -0
  168. package/dist-types/packages/peach-engine/src/engine/canvaskit-api.d.ts +93 -0
  169. package/dist-types/packages/peach-engine/src/engine/canvaskit-renderer.d.ts +216 -0
  170. package/dist-types/packages/peach-engine/src/engine/config-plugin-fonts.d.ts +40 -0
  171. package/dist-types/packages/peach-engine/src/engine/config-plugin-splash.d.ts +25 -0
  172. package/dist-types/packages/peach-engine/src/engine/cull-visibility.d.ts +44 -0
  173. package/dist-types/packages/peach-engine/src/engine/damage-rect.d.ts +19 -0
  174. package/dist-types/packages/peach-engine/src/engine/engine-resource.d.ts +6 -0
  175. package/dist-types/packages/peach-engine/src/engine/expo-manifest.d.ts +5 -0
  176. package/dist-types/packages/peach-engine/src/engine/fiber-debug-metadata.d.ts +30 -0
  177. package/dist-types/packages/peach-engine/src/engine/font-config.d.ts +139 -0
  178. package/dist-types/packages/peach-engine/src/engine/generated/sf-pro-font.d.ts +1 -0
  179. package/dist-types/packages/peach-engine/src/engine/glass-material.d.ts +31 -0
  180. package/dist-types/packages/peach-engine/src/engine/host-composite.d.ts +100 -0
  181. package/dist-types/packages/peach-engine/src/engine/hosted-semantics.d.ts +49 -0
  182. package/dist-types/packages/peach-engine/src/engine/image-audit.d.ts +70 -0
  183. package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +350 -0
  184. package/dist-types/packages/peach-engine/src/engine/inspect-info.d.ts +27 -0
  185. package/dist-types/packages/peach-engine/src/engine/inspect-outline.d.ts +14 -0
  186. package/dist-types/packages/peach-engine/src/engine/inspect-visibility.d.ts +33 -0
  187. package/dist-types/packages/peach-engine/src/engine/ios-fast-scroll.d.ts +16 -0
  188. package/dist-types/packages/peach-engine/src/engine/layout-sab.d.ts +43 -0
  189. package/dist-types/packages/peach-engine/src/engine/liquid-glass-rect.d.ts +23 -0
  190. package/dist-types/packages/peach-engine/src/engine/liquid-glass-shaders.d.ts +9 -0
  191. package/dist-types/packages/peach-engine/src/engine/liquid-glass.d.ts +283 -0
  192. package/dist-types/packages/peach-engine/src/engine/live-object-counts.d.ts +6 -0
  193. package/dist-types/packages/peach-engine/src/engine/lottie-runtime.d.ts +32 -0
  194. package/dist-types/packages/peach-engine/src/engine/lottie-types.d.ts +138 -0
  195. package/dist-types/packages/peach-engine/src/engine/memory-counts.d.ts +27 -0
  196. package/dist-types/packages/peach-engine/src/engine/metalDirectContract.d.ts +108 -0
  197. package/dist-types/packages/peach-engine/src/engine/metalShaderContract.d.ts +217 -0
  198. package/dist-types/packages/peach-engine/src/engine/native-animation-driver.d.ts +112 -0
  199. package/dist-types/packages/peach-engine/src/engine/native-animation-graph.d.ts +62 -0
  200. package/dist-types/packages/peach-engine/src/engine/native-layout.d.ts +133 -0
  201. package/dist-types/packages/peach-engine/src/engine/native-resources.d.ts +26 -0
  202. package/dist-types/packages/peach-engine/src/engine/nativeReanimatedContract.d.ts +25 -0
  203. package/dist-types/packages/peach-engine/src/engine/nativeReplayContract.d.ts +64 -0
  204. package/dist-types/packages/peach-engine/src/engine/node.d.ts +591 -0
  205. package/dist-types/packages/peach-engine/src/engine/paint-boundary-types.d.ts +112 -0
  206. package/dist-types/packages/peach-engine/src/engine/paint-boundary.d.ts +57 -0
  207. package/dist-types/packages/peach-engine/src/engine/portalContract.d.ts +21 -0
  208. package/dist-types/packages/peach-engine/src/engine/portals.d.ts +20 -0
  209. package/dist-types/packages/peach-engine/src/engine/render-damage.d.ts +107 -0
  210. package/dist-types/packages/peach-engine/src/engine/riveContract.d.ts +420 -0
  211. package/dist-types/packages/peach-engine/src/engine/rn-spring.d.ts +51 -0
  212. package/dist-types/packages/peach-engine/src/engine/scene-table.d.ts +379 -0
  213. package/dist-types/packages/peach-engine/src/engine/scroll-momentum-math.d.ts +152 -0
  214. package/dist-types/packages/peach-engine/src/engine/scroll-pan-contacts.d.ts +10 -0
  215. package/dist-types/packages/peach-engine/src/engine/scroll-platform.d.ts +75 -0
  216. package/dist-types/packages/peach-engine/src/engine/scroll-range.d.ts +14 -0
  217. package/dist-types/packages/peach-engine/src/engine/scroll-velocity.d.ts +14 -0
  218. package/dist-types/packages/peach-engine/src/engine/scroll.d.ts +320 -0
  219. package/dist-types/packages/peach-engine/src/engine/signal.d.ts +7 -0
  220. package/dist-types/packages/peach-engine/src/engine/snapshot-cache-policy.d.ts +6 -0
  221. package/dist-types/packages/peach-engine/src/engine/svg-geometry.d.ts +41 -0
  222. package/dist-types/packages/peach-engine/src/engine/text-attachment-paragraphs.d.ts +10 -0
  223. package/dist-types/packages/peach-engine/src/engine/text-decoration.d.ts +11 -0
  224. package/dist-types/packages/peach-engine/src/engine/text-first-baseline.d.ts +23 -0
  225. package/dist-types/packages/peach-engine/src/engine/text-line-break.d.ts +22 -0
  226. package/dist-types/packages/peach-engine/src/engine/text-paint-receipt.d.ts +98 -0
  227. package/dist-types/packages/peach-engine/src/engine/text-paragraph.d.ts +11 -0
  228. package/dist-types/packages/peach-engine/src/engine/text-paragraphContract.d.ts +34 -0
  229. package/dist-types/packages/peach-engine/src/engine/text-transform.d.ts +1 -0
  230. package/dist-types/packages/peach-engine/src/engine/types.d.ts +657 -0
  231. package/dist-types/packages/peach-engine/src/engine/visible-frame.d.ts +55 -0
  232. package/dist-types/packages/peach-engine/src/engine/webrtcContract.d.ts +74 -0
  233. package/dist-types/packages/peach-engine/src/graphite-stats-fields.d.ts +184 -0
  234. package/dist-types/packages/peach-engine/src/guest-import-meta.d.ts +12 -0
  235. package/dist-types/packages/peach-engine/src/guest-module-overrides.d.ts +7 -0
  236. package/dist-types/packages/peach-engine/src/ios/app-card-types.d.ts +7 -0
  237. package/dist-types/packages/peach-engine/src/ios/apps/canvas-map-data.d.ts +177 -0
  238. package/dist-types/packages/peach-engine/src/ios/aux-home-scene.d.ts +54 -0
  239. package/dist-types/packages/peach-engine/src/ios/chrome-metrics.d.ts +47 -0
  240. package/dist-types/packages/peach-engine/src/ios/constants.d.ts +21 -0
  241. package/dist-types/packages/peach-engine/src/ios/duo-housing.d.ts +37 -0
  242. package/dist-types/packages/peach-engine/src/ios/home/types.d.ts +29 -0
  243. package/dist-types/packages/peach-engine/src/ios/home-app-catalog.d.ts +43 -0
  244. package/dist-types/packages/peach-engine/src/ios/photo-store.d.ts +73 -0
  245. package/dist-types/packages/peach-engine/src/ios/photoLibraryContract.d.ts +166 -0
  246. package/dist-types/packages/peach-engine/src/ios/shell-controller-types.d.ts +21 -0
  247. package/dist-types/packages/peach-engine/src/ios/shell-transition-debug.d.ts +18 -0
  248. package/dist-types/packages/peach-engine/src/metro-asset-path.d.ts +21 -0
  249. package/dist-types/packages/peach-engine/src/metro-fingerprint-registry-client.d.ts +11 -0
  250. package/dist-types/packages/peach-engine/src/metro-fingerprint.d.ts +38 -0
  251. package/dist-types/packages/peach-engine/src/native-preview-bundle.d.ts +44 -0
  252. package/dist-types/packages/peach-engine/src/observability/types.d.ts +75 -0
  253. package/dist-types/packages/peach-engine/src/peach-warm-manifest.d.ts +32 -0
  254. package/dist-types/packages/peach-engine/src/permissions/app-settings-client.d.ts +25 -0
  255. package/dist-types/packages/peach-engine/src/permissions/system-permission-types.d.ts +20 -0
  256. package/dist-types/packages/peach-engine/src/platform/android-back-panel.d.ts +131 -0
  257. package/dist-types/packages/peach-engine/src/platform/android-gesture-exclusion.d.ts +28 -0
  258. package/dist-types/packages/peach-engine/src/platform/android-predictive-back.d.ts +33 -0
  259. package/dist-types/packages/peach-engine/src/platform/system-bars-state.d.ts +14 -0
  260. package/dist-types/packages/peach-engine/src/playwright-sim-host.d.ts +1 -0
  261. package/dist-types/packages/peach-engine/src/preview/bundle-layout.d.ts +8 -0
  262. package/dist-types/packages/peach-engine/src/preview/bundle-variantContract.d.ts +24 -0
  263. package/dist-types/packages/peach-engine/src/preview/capture-bundle.d.ts +26 -0
  264. package/dist-types/packages/peach-engine/src/preview/compress-node.d.ts +2 -0
  265. package/dist-types/packages/peach-engine/src/preview/compress.d.ts +2 -0
  266. package/dist-types/packages/peach-engine/src/preview/presigned-upload.d.ts +60 -0
  267. package/dist-types/packages/peach-engine/src/preview/trace.d.ts +144 -0
  268. package/dist-types/packages/peach-engine/src/preview/upload-protocol.d.ts +152 -0
  269. package/dist-types/packages/peach-engine/src/profiler/animation-recording-loader.d.ts +1 -0
  270. package/dist-types/packages/peach-engine/src/profiler/profile-trace.d.ts +4 -0
  271. package/dist-types/packages/peach-engine/src/react-bridge.d.ts +3 -0
  272. package/dist-types/packages/peach-engine/src/react-native/AppState.d.ts +45 -0
  273. package/dist-types/packages/peach-engine/src/react-native/Appearance.d.ts +34 -0
  274. package/dist-types/packages/peach-engine/src/react-native/framework-colors-data.d.ts +2 -0
  275. package/dist-types/packages/peach-engine/src/react-native/host-services.d.ts +42 -0
  276. package/dist-types/packages/peach-engine/src/react-native/layout-animation.d.ts +22 -0
  277. package/dist-types/packages/peach-engine/src/react-native/platform-colors.d.ts +17 -0
  278. package/dist-types/packages/peach-engine/src/remote-stream/client-config.d.ts +10 -0
  279. package/dist-types/packages/peach-engine/src/remote-stream/cloud-display.d.ts +58 -0
  280. package/dist-types/packages/peach-engine/src/remote-stream/scene-recording.d.ts +45 -0
  281. package/dist-types/packages/peach-engine/src/render-worker/animated-drive-output.d.ts +35 -0
  282. package/dist-types/packages/peach-engine/src/render-worker/app-load.d.ts +16 -0
  283. package/dist-types/packages/peach-engine/src/render-worker/aux-surface-types.d.ts +2 -0
  284. package/dist-types/packages/peach-engine/src/render-worker/canvaskit-shared.d.ts +42 -0
  285. package/dist-types/packages/peach-engine/src/render-worker/canvaskit-webgpu.d.ts +434 -0
  286. package/dist-types/packages/peach-engine/src/render-worker/canvaskit-worker-init.d.ts +12 -0
  287. package/dist-types/packages/peach-engine/src/render-worker/compositor-backend.d.ts +31 -0
  288. package/dist-types/packages/peach-engine/src/render-worker/compositor-gpu.d.ts +202 -0
  289. package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +1983 -0
  290. package/dist-types/packages/peach-engine/src/render-worker/compositor-runtime/scroll-drag-resample.d.ts +44 -0
  291. package/dist-types/packages/peach-engine/src/render-worker/css-keyframes-drive.d.ts +36 -0
  292. package/dist-types/packages/peach-engine/src/render-worker/edit-menu-geometry.d.ts +8 -0
  293. package/dist-types/packages/peach-engine/src/render-worker/engine-resource-relay.d.ts +21 -0
  294. package/dist-types/packages/peach-engine/src/render-worker/expo-widgetContract.d.ts +16 -0
  295. package/dist-types/packages/peach-engine/src/render-worker/gesture-seam-protocol.d.ts +152 -0
  296. package/dist-types/packages/peach-engine/src/render-worker/graph-linked-value.d.ts +29 -0
  297. package/dist-types/packages/peach-engine/src/render-worker/graphite-pipeline-compiler-contract.d.ts +49 -0
  298. package/dist-types/packages/peach-engine/src/render-worker/graphite-pipeline-compiler.d.ts +12 -0
  299. package/dist-types/packages/peach-engine/src/render-worker/host-service-protocol.d.ts +756 -0
  300. package/dist-types/packages/peach-engine/src/render-worker/image-lifecycle-event.d.ts +22 -0
  301. package/dist-types/packages/peach-engine/src/render-worker/image-pixel-contract.d.ts +48 -0
  302. package/dist-types/packages/peach-engine/src/render-worker/live-frame-mirror.d.ts +34 -0
  303. package/dist-types/packages/peach-engine/src/render-worker/map-command-channel.d.ts +189 -0
  304. package/dist-types/packages/peach-engine/src/render-worker/mapNativeContract.d.ts +101 -0
  305. package/dist-types/packages/peach-engine/src/render-worker/native-dynamic-synchronizable.d.ts +22 -0
  306. package/dist-types/packages/peach-engine/src/render-worker/native-menu-gesture.d.ts +9 -0
  307. package/dist-types/packages/peach-engine/src/render-worker/native-ui-commandContract.d.ts +23 -0
  308. package/dist-types/packages/peach-engine/src/render-worker/native-ui-protocol.d.ts +1087 -0
  309. package/dist-types/packages/peach-engine/src/render-worker/native-widgetContract.d.ts +100 -0
  310. package/dist-types/packages/peach-engine/src/render-worker/nativeAnimMirrorContract.d.ts +174 -0
  311. package/dist-types/packages/peach-engine/src/render-worker/nativeSyncReplyContract.d.ts +11 -0
  312. package/dist-types/packages/peach-engine/src/render-worker/one-native-contentContract.d.ts +54 -0
  313. package/dist-types/packages/peach-engine/src/render-worker/pointerSampleContract.d.ts +14 -0
  314. package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +880 -0
  315. package/dist-types/packages/peach-engine/src/render-worker/reanimated-css-contract.d.ts +63 -0
  316. package/dist-types/packages/peach-engine/src/render-worker/reanimated-readiness.d.ts +29 -0
  317. package/dist-types/packages/peach-engine/src/render-worker/resilient-frame-clock.d.ts +22 -0
  318. package/dist-types/packages/peach-engine/src/render-worker/retained-app-load.d.ts +20 -0
  319. package/dist-types/packages/peach-engine/src/render-worker/screen-edge-swipe-commit-protocol.d.ts +1 -0
  320. package/dist-types/packages/peach-engine/src/render-worker/screen-form-sheet-commit-protocol.d.ts +26 -0
  321. package/dist-types/packages/peach-engine/src/render-worker/scroll-mirror-tenant.d.ts +37 -0
  322. package/dist-types/packages/peach-engine/src/render-worker/scroll-mirror.d.ts +164 -0
  323. package/dist-types/packages/peach-engine/src/render-worker/shell-event-registry.d.ts +119 -0
  324. package/dist-types/packages/peach-engine/src/render-worker/shell-gesture-regions.d.ts +41 -0
  325. package/dist-types/packages/peach-engine/src/render-worker/shell-protocol.d.ts +603 -0
  326. package/dist-types/packages/peach-engine/src/render-worker/shell-scene-schema.d.ts +101 -0
  327. package/dist-types/packages/peach-engine/src/render-worker/shell-tree-inline-sources.d.ts +13 -0
  328. package/dist-types/packages/peach-engine/src/render-worker/shell-tree-wire.d.ts +87 -0
  329. package/dist-types/packages/peach-engine/src/render-worker/test-bridge-protocol.d.ts +47 -0
  330. package/dist-types/packages/peach-engine/src/render-worker/text-inputContract.d.ts +93 -0
  331. package/dist-types/packages/peach-engine/src/render-worker/tree-sync-port.d.ts +102 -0
  332. package/dist-types/packages/peach-engine/src/render-worker/webgpu-frame-transaction.d.ts +292 -0
  333. package/dist-types/packages/peach-engine/src/render-worker/webgpu-readback-scheduler.d.ts +107 -0
  334. package/dist-types/packages/peach-engine/src/render-worker/webview-capture-protocol.d.ts +16 -0
  335. package/dist-types/packages/peach-engine/src/render-worker/worker-input-runtime.d.ts +211 -0
  336. package/dist-types/packages/peach-engine/src/render-worker/worker-storage.d.ts +33 -0
  337. package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +987 -0
  338. package/dist-types/packages/peach-engine/src/render-worker/worklet-sab.d.ts +24 -0
  339. package/dist-types/packages/peach-engine/src/rolldown-bundle-inventory.d.ts +89 -0
  340. package/dist-types/packages/peach-engine/src/rolldown-production-fingerprint.d.ts +31 -0
  341. package/dist-types/packages/peach-engine/src/screenshots/timeline-assets.d.ts +10 -0
  342. package/dist-types/packages/peach-engine/src/screenshots/tokens.d.ts +9 -0
  343. package/dist-types/packages/peach-engine/src/settings/devices.d.ts +70 -0
  344. package/dist-types/packages/peach-engine/src/settings/duo-fold-bus.d.ts +87 -0
  345. package/dist-types/packages/peach-engine/src/settings/interface-rotation.d.ts +30 -0
  346. package/dist-types/packages/peach-engine/src/settings/react-native-configuration.d.ts +12 -0
  347. package/dist-types/packages/peach-engine/src/settings/scene-geometryContract.d.ts +40 -0
  348. package/dist-types/packages/peach-engine/src/settings/store.d.ts +37 -0
  349. package/dist-types/packages/peach-engine/src/shell-events.d.ts +203 -0
  350. package/dist-types/packages/peach-engine/src/shell-intent.d.ts +68 -0
  351. package/dist-types/packages/peach-engine/src/sootsim-event.d.ts +35 -0
  352. package/dist-types/packages/peach-engine/src/top-overlay-state.d.ts +5 -0
  353. package/dist-types/packages/peach-engine/src/web-authentication-automation-host.d.ts +2 -0
  354. package/dist-types/packages/peach-engine/src/webAuthenticationContract.d.ts +34 -0
  355. package/dist-types/packages/peach-engine/src/webview-automation-host.d.ts +180 -0
  356. package/dist-types/packages/peach-engine/src/wireframe-mode.d.ts +16 -0
  357. package/dist-types/packages/peach-globals/src/frameBreakdownContract.d.ts +16 -0
  358. package/dist-types/packages/peach-globals/src/index.d.ts +3311 -0
  359. package/dist-types/packages/peach-globals/src/nativeSurfaceContract.d.ts +76 -0
  360. package/dist-types/packages/peach-globals/src/pointerSourceEventContract.d.ts +8 -0
  361. package/dist-types/packages/peach-globals/src/profileTrace.d.ts +11 -0
  362. package/dist-types/packages/peach-globals/src/profilerContract.d.ts +223 -0
  363. package/dist-types/packages/peach-kit/src/capabilities.d.ts +721 -0
  364. package/dist-types/packages/peach-kit/src/internal.d.ts +4 -0
  365. package/dist-types/packages/peach-kit/src/materials/types.d.ts +27 -0
  366. package/dist-types/packages/peach-kit/src/materials/uikit-blur-material.d.ts +14 -0
  367. package/dist-types/packages/peach-kit/src/navigation-types.d.ts +11 -0
  368. package/dist-types/packages/peach-kit/src/react-bridge.d.ts +53 -0
  369. package/dist-types/packages/peach-kit/src/runtime.d.ts +26 -0
  370. package/dist-types/packages/peach-kit/src/ui/hosting-safe-area.d.ts +24 -0
  371. package/dist-types/packages/peach-kit/src/ui/popover-placement.d.ts +53 -0
  372. package/dist-types/packages/peach-kit/src/ui/presentationContract.d.ts +17 -0
  373. package/kotlin/ComposeSources/PeachComposeHost.kt +1 -1
  374. package/kotlin/JniSources/com/facebook/jni/HybridData.kt +0 -2
  375. package/kotlin/JniSources/dev/peach/jni/NativeBindings.kt +0 -2
  376. package/kotlin/JniTransportSources/dev/peach/jni/integration/JniTransport.kt +0 -2
  377. package/kotlin/README.md +6 -0
  378. package/package.json +26 -2
  379. package/runtime-companion.json +1 -0
  380. package/skills/contrast/SKILL.md +1 -0
  381. package/src/assetCatalogContract.ts +21 -0
  382. package/src/bridge-contract-input.ts +84 -0
  383. package/src/bridge-contract.ts +37 -3
  384. package/src/browser-launch-policy.ts +1 -0
  385. package/src/bundle-channel.mjs +4 -2
  386. package/src/bundleGlobalFooter.ts +9 -0
  387. package/src/cli-runtime.ts +55 -0
  388. package/src/crash-fingerprint.ts +26 -0
  389. package/src/dev-bundle-resolution.ts +50 -23
  390. package/src/device-catalog.ts +1159 -0
  391. package/src/host/bridge-host.ts +3 -26
  392. package/src/host/browser-pointer.ts +71 -0
  393. package/src/host/dev-server-package-versions.ts +23 -0
  394. package/src/host/fetch-proxy-handler.ts +54 -4
  395. package/src/installed-package-versions.ts +142 -38
  396. package/src/kotlin-host.ts +1 -1
  397. package/src/metro-plugin.ts +4 -4
  398. package/src/metro-project-root.ts +68 -0
  399. package/src/nitro-adapter.lock.json +26 -0
  400. package/src/nitro-adapter.ts +103 -0
  401. package/src/nitro-bundle.ts +24 -10
  402. package/src/nitro-compile.ts +33 -51
  403. package/src/nitro-source.ts +177 -96
  404. package/src/nitroAdapterContract.ts +217 -0
  405. package/src/nitroContract.ts +24 -11
  406. package/src/process-group.ts +41 -34
  407. package/src/react-bridge-importers.ts +28 -0
  408. package/src/reactNativeConfigurationContract.ts +36 -0
  409. package/src/runtime-assets.ts +7 -2
  410. package/src/runtime-delivery.ts +2 -0
  411. package/src/runtimePlatformContract.ts +70 -0
  412. package/src/screenshots/frame-compose.ts +42 -43
  413. package/src/screenshots/org-deck.ts +9 -4
  414. package/src/screenshots/preset-names.ts +29 -0
  415. package/src/screenshots/registry.ts +5 -5
  416. package/src/screenshots/schema.ts +1 -1
  417. package/src/screenshots/screenshotContract.ts +971 -0
  418. package/src/settings-flags.ts +107 -0
  419. package/src/settingsContract.ts +609 -0
  420. package/src/sfSymbolMetricsContract.ts +268 -0
  421. package/src/storageSnapshotContract.ts +344 -0
  422. package/src/stub-pattern-matcher.ts +550 -0
  423. package/src/swift-compile.ts +924 -41
  424. package/src/swift-compiler-digest.ts +13 -1
  425. package/src/swift-distribution.lock.json +12 -11
  426. package/src/swift-host.ts +167 -52
  427. package/src/swift-objc-compile.ts +54 -24
  428. package/src/swift-objc-export.ts +532 -0
  429. package/src/swift-objc-import.ts +769 -0
  430. package/src/swift-objc-metadata.ts +305 -16
  431. package/src/swift-objc-sdk.ts +13983 -158
  432. package/src/swift-objc-standin.ts +137 -1
  433. package/src/swift-package.ts +94 -0
  434. package/src/swift-packages.ts +5 -5
  435. package/src/swift-submit.ts +6 -0
  436. package/src/swiftContract.ts +99 -0
  437. package/src/target-matcher.ts +6 -1
  438. package/src/vite-plugin-one.ts +161 -16
  439. package/src/vite-plugin.ts +14 -40
  440. package/src/worker-system-chunks.ts +1 -1
  441. package/src/workerChunkContract.ts +5 -0
  442. package/src/worklets-babel.ts +24 -5
  443. package/src/xcode-project.ts +36 -7
  444. package/src/xcode-target-members.ts +10 -3
  445. package/cli/drivers/playwright-sim-host.ts +0 -825
  446. package/kotlin/fixtures/counter/Counter.d.kt.ts +0 -17
  447. package/kotlin/fixtures/counter/Counter.kt +0 -51
  448. package/kotlin/fixtures/counter/CounterApp.native.tsx +0 -61
  449. package/kotlin/fixtures/counter/CounterApp.tsx +0 -3
  450. package/kotlin/fixtures/counter/CounterScreen.d.kt.ts +0 -8
  451. package/kotlin/fixtures/counter/CounterScreen.kt +0 -56
  452. package/kotlin/fixtures/counter/app/_layout.tsx +0 -4
  453. package/kotlin/fixtures/counter/app/index+spa.tsx +0 -1
  454. package/kotlin/fixtures/counter/app/routes.d.ts +0 -18
  455. package/kotlin/fixtures/counter/package.json +0 -20
  456. package/kotlin/fixtures/counter/tsconfig.json +0 -19
  457. package/kotlin/fixtures/counter/vite.config.ts +0 -20
  458. package/kotlin/fixtures/headless-counter/Headless.kt +0 -234
  459. package/kotlin/fixtures/import-animation/Animation.d.kt.ts +0 -7
  460. package/kotlin/fixtures/import-animation/Animation.kt +0 -80
  461. package/kotlin/fixtures/import-animation/ImportAnimation.native.tsx +0 -13
  462. package/kotlin/fixtures/import-animation/README.md +0 -24
  463. package/kotlin/fixtures/import-animation/app/_layout.tsx +0 -4
  464. package/kotlin/fixtures/import-animation/app/index+spa.tsx +0 -1
  465. package/kotlin/fixtures/import-animation/app/routes.d.ts +0 -18
  466. package/kotlin/fixtures/import-animation/package.json +0 -23
  467. package/kotlin/fixtures/import-animation/tsconfig.json +0 -20
  468. package/kotlin/fixtures/import-animation/vite.config.ts +0 -20
  469. package/kotlin/fixtures/import-drawing/Drawing.d.kt.ts +0 -7
  470. package/kotlin/fixtures/import-drawing/Drawing.kt +0 -101
  471. package/kotlin/fixtures/import-drawing/ImportDrawing.native.tsx +0 -18
  472. package/kotlin/fixtures/import-drawing/README.md +0 -34
  473. package/kotlin/fixtures/import-drawing/app/_layout.tsx +0 -4
  474. package/kotlin/fixtures/import-drawing/app/index+spa.tsx +0 -1
  475. package/kotlin/fixtures/import-drawing/package.json +0 -23
  476. package/kotlin/fixtures/import-drawing/tsconfig.json +0 -20
  477. package/kotlin/fixtures/import-drawing/vite.config.ts +0 -20
  478. package/kotlin/fixtures/import-editor/Editor.d.kt.ts +0 -7
  479. package/kotlin/fixtures/import-editor/Editor.kt +0 -59
  480. package/kotlin/fixtures/import-editor/ImportEditor.native.tsx +0 -23
  481. package/kotlin/fixtures/import-editor/README.md +0 -27
  482. package/kotlin/fixtures/import-editor/app/_layout.tsx +0 -4
  483. package/kotlin/fixtures/import-editor/app/index+spa.tsx +0 -1
  484. package/kotlin/fixtures/import-editor/package.json +0 -23
  485. package/kotlin/fixtures/import-editor/tsconfig.json +0 -20
  486. package/kotlin/fixtures/import-editor/vite.config.ts +0 -20
  487. package/kotlin/fixtures/import-effects/Effects.d.kt.ts +0 -7
  488. package/kotlin/fixtures/import-effects/Effects.kt +0 -87
  489. package/kotlin/fixtures/import-effects/ImportEffects.native.tsx +0 -13
  490. package/kotlin/fixtures/import-effects/README.md +0 -19
  491. package/kotlin/fixtures/import-effects/app/_layout.tsx +0 -4
  492. package/kotlin/fixtures/import-effects/app/index+spa.tsx +0 -1
  493. package/kotlin/fixtures/import-effects/package.json +0 -23
  494. package/kotlin/fixtures/import-effects/tsconfig.json +0 -20
  495. package/kotlin/fixtures/import-effects/vite.config.ts +0 -20
  496. package/kotlin/fixtures/import-layout/ImportLayout.native.tsx +0 -13
  497. package/kotlin/fixtures/import-layout/Layout.d.kt.ts +0 -7
  498. package/kotlin/fixtures/import-layout/Layout.kt +0 -72
  499. package/kotlin/fixtures/import-layout/README.md +0 -24
  500. package/kotlin/fixtures/import-layout/app/_layout.tsx +0 -4
  501. package/kotlin/fixtures/import-layout/app/index+spa.tsx +0 -1
  502. package/kotlin/fixtures/import-layout/package.json +0 -23
  503. package/kotlin/fixtures/import-layout/tsconfig.json +0 -20
  504. package/kotlin/fixtures/import-layout/vite.config.ts +0 -20
  505. package/kotlin/fixtures/import-navigation/ImportNavigation.native.tsx +0 -18
  506. package/kotlin/fixtures/import-navigation/Navigation.d.kt.ts +0 -7
  507. package/kotlin/fixtures/import-navigation/Navigation.kt +0 -104
  508. package/kotlin/fixtures/import-navigation/README.md +0 -31
  509. package/kotlin/fixtures/import-navigation/app/_layout.tsx +0 -4
  510. package/kotlin/fixtures/import-navigation/app/index+spa.tsx +0 -1
  511. package/kotlin/fixtures/import-navigation/package.json +0 -23
  512. package/kotlin/fixtures/import-navigation/tsconfig.json +0 -20
  513. package/kotlin/fixtures/import-navigation/vite.config.ts +0 -20
  514. package/kotlin/fixtures/import-overlays/ImportOverlays.native.tsx +0 -29
  515. package/kotlin/fixtures/import-overlays/Overlays.d.kt.ts +0 -7
  516. package/kotlin/fixtures/import-overlays/Overlays.kt +0 -93
  517. package/kotlin/fixtures/import-overlays/README.md +0 -34
  518. package/kotlin/fixtures/import-overlays/app/_layout.tsx +0 -4
  519. package/kotlin/fixtures/import-overlays/app/index+spa.tsx +0 -1
  520. package/kotlin/fixtures/import-overlays/package.json +0 -23
  521. package/kotlin/fixtures/import-overlays/tsconfig.json +0 -20
  522. package/kotlin/fixtures/import-overlays/vite.config.ts +0 -20
  523. package/kotlin/fixtures/import-resources/ImportResources.native.tsx +0 -18
  524. package/kotlin/fixtures/import-resources/README.md +0 -26
  525. package/kotlin/fixtures/import-resources/Resources.d.kt.ts +0 -6
  526. package/kotlin/fixtures/import-resources/Resources.kt +0 -72
  527. package/kotlin/fixtures/import-resources/app/_layout.tsx +0 -4
  528. package/kotlin/fixtures/import-resources/app/index+spa.tsx +0 -1
  529. package/kotlin/fixtures/import-resources/package.json +0 -23
  530. package/kotlin/fixtures/import-resources/tsconfig.json +0 -20
  531. package/kotlin/fixtures/import-resources/vite.config.ts +0 -20
  532. package/kotlin/fixtures/import-scroll/ImportNested.native.tsx +0 -10
  533. package/kotlin/fixtures/import-scroll/ImportScroll.native.tsx +0 -13
  534. package/kotlin/fixtures/import-scroll/Nested.d.kt.ts +0 -4
  535. package/kotlin/fixtures/import-scroll/Nested.kt +0 -64
  536. package/kotlin/fixtures/import-scroll/README.md +0 -38
  537. package/kotlin/fixtures/import-scroll/Scroll.d.kt.ts +0 -7
  538. package/kotlin/fixtures/import-scroll/Scroll.kt +0 -91
  539. package/kotlin/fixtures/import-scroll/app/_layout.tsx +0 -4
  540. package/kotlin/fixtures/import-scroll/app/index+spa.tsx +0 -1
  541. package/kotlin/fixtures/import-scroll/app/nested+spa.tsx +0 -1
  542. package/kotlin/fixtures/import-scroll/package.json +0 -23
  543. package/kotlin/fixtures/import-scroll/tsconfig.json +0 -20
  544. package/kotlin/fixtures/import-scroll/vite.config.ts +0 -20
  545. package/kotlin/fixtures/import-selection/ImportSelection.native.tsx +0 -44
  546. package/kotlin/fixtures/import-selection/README.md +0 -32
  547. package/kotlin/fixtures/import-selection/Selection.d.kt.ts +0 -8
  548. package/kotlin/fixtures/import-selection/Selection.kt +0 -78
  549. package/kotlin/fixtures/import-selection/app/_layout.tsx +0 -4
  550. package/kotlin/fixtures/import-selection/app/index+spa.tsx +0 -1
  551. package/kotlin/fixtures/import-selection/package.json +0 -23
  552. package/kotlin/fixtures/import-selection/tsconfig.json +0 -20
  553. package/kotlin/fixtures/import-selection/vite.config.ts +0 -20
  554. package/kotlin/fixtures/import-surfaces/ImportSurfaces.native.tsx +0 -13
  555. package/kotlin/fixtures/import-surfaces/README.md +0 -22
  556. package/kotlin/fixtures/import-surfaces/Surfaces.d.kt.ts +0 -7
  557. package/kotlin/fixtures/import-surfaces/Surfaces.kt +0 -64
  558. package/kotlin/fixtures/import-surfaces/app/_layout.tsx +0 -4
  559. package/kotlin/fixtures/import-surfaces/app/index+spa.tsx +0 -1
  560. package/kotlin/fixtures/import-surfaces/package.json +0 -23
  561. package/kotlin/fixtures/import-surfaces/tsconfig.json +0 -20
  562. package/kotlin/fixtures/import-surfaces/vite.config.ts +0 -20
  563. package/kotlin/fixtures/import-values/ImportValues.native.tsx +0 -61
  564. package/kotlin/fixtures/import-values/README.md +0 -28
  565. package/kotlin/fixtures/import-values/Values.d.kt.ts +0 -15
  566. package/kotlin/fixtures/import-values/Values.kt +0 -84
  567. package/kotlin/fixtures/import-values/app/_layout.tsx +0 -4
  568. package/kotlin/fixtures/import-values/app/index+spa.tsx +0 -1
  569. package/kotlin/fixtures/import-values/package.json +0 -23
  570. package/kotlin/fixtures/import-values/tsconfig.json +0 -20
  571. package/kotlin/fixtures/import-values/vite.config.ts +0 -20
  572. package/kotlin/fixtures/kotlin-app/app/build.gradle.kts +0 -30
  573. package/kotlin/fixtures/kotlin-app/app/src/main/AndroidManifest.xml +0 -13
  574. package/kotlin/fixtures/kotlin-app/app/src/main/java/dev/contrast/kotlinapp/MainActivity.kt +0 -60
  575. package/kotlin/fixtures/kotlin-app/app/src/main/java/dev/contrast/kotlinapp/ProbeApplication.kt +0 -18
  576. package/kotlin/fixtures/kotlin-app/build.gradle.kts +0 -5
  577. package/kotlin/fixtures/kotlin-app/gradle.properties +0 -4
  578. package/kotlin/fixtures/kotlin-app/settings.gradle.kts +0 -4
  579. package/kotlin/fixtures/kotlin-app-variants/Anim.kt +0 -62
  580. package/kotlin/fixtures/kotlin-app-variants/BarBehavior.kt +0 -38
  581. package/kotlin/fixtures/kotlin-app-variants/BarVisibility.kt +0 -36
  582. package/kotlin/fixtures/kotlin-app-variants/Bitmaps.kt +0 -50
  583. package/kotlin/fixtures/kotlin-app-variants/Browse.kt +0 -73
  584. package/kotlin/fixtures/kotlin-app-variants/Colors.kt +0 -41
  585. package/kotlin/fixtures/kotlin-app-variants/Controls.kt +0 -62
  586. package/kotlin/fixtures/kotlin-app-variants/Drag.kt +0 -56
  587. package/kotlin/fixtures/kotlin-app-variants/Draw.kt +0 -74
  588. package/kotlin/fixtures/kotlin-app-variants/Drawables.kt +0 -53
  589. package/kotlin/fixtures/kotlin-app-variants/Focus.kt +0 -62
  590. package/kotlin/fixtures/kotlin-app-variants/Form.kt +0 -47
  591. package/kotlin/fixtures/kotlin-app-variants/Icons.kt +0 -59
  592. package/kotlin/fixtures/kotlin-app-variants/Ime.kt +0 -53
  593. package/kotlin/fixtures/kotlin-app-variants/Lists.kt +0 -57
  594. package/kotlin/fixtures/kotlin-app-variants/Nav.kt +0 -47
  595. package/kotlin/fixtures/kotlin-app-variants/Note.kt +0 -40
  596. package/kotlin/fixtures/kotlin-app-variants/Overlays.kt +0 -56
  597. package/kotlin/fixtures/kotlin-app-variants/Pan.kt +0 -38
  598. package/kotlin/fixtures/kotlin-app-variants/Pickers.kt +0 -44
  599. package/kotlin/fixtures/kotlin-app-variants/Press.kt +0 -43
  600. package/kotlin/fixtures/kotlin-app-variants/Scroll.kt +0 -63
  601. package/kotlin/fixtures/kotlin-app-variants/Sheet.kt +0 -43
  602. package/kotlin/fixtures/kotlin-app-variants/Strings.kt +0 -49
  603. package/kotlin/fixtures/kotlin-app-variants/Tabs.kt +0 -47
  604. package/kotlin/fixtures/kotlin-app-variants/TextWidth.kt +0 -45
  605. package/kotlin/fixtures/kotlin-app-variants/TransientInsets.kt +0 -50
  606. package/kotlin/fixtures/kotlin-app-variants/Transition.kt +0 -69
  607. package/kotlin/fixtures/kotlin-app-variants/ViewConfig.kt +0 -22
  608. package/kotlin/fixtures/kotlin-app-variants/Widgets.kt +0 -67
  609. package/kotlin/fixtures/runtime-state/RuntimeState.kt +0 -200
  610. package/kotlin/fork/README.md +0 -97
  611. package/kotlin/fork/build.sh +0 -176
  612. package/kotlin/fork/compose-worker-globals.patch +0 -1247
  613. package/kotlin/fork/fork.json +0 -46
  614. package/kotlin/fork/publish.ts +0 -99
  615. package/kotlin/fork/skia-android-shaping.patch +0 -189
  616. package/kotlin/fork/skiko-local.init.gradle +0 -10
  617. package/kotlin/fork/skiko-worker-clock.patch +0 -122
  618. package/src/host/lease-owner.test.ts +0 -49
@@ -20,8 +20,10 @@ import {
20
20
  } from 'node:fs'
21
21
  import os from 'node:os'
22
22
  import path from 'node:path'
23
+ import yaml from 'yaml'
23
24
  import { admittedMacBuilderSlot } from './admitted-mac-build'
24
25
  import { rnxHomeDir, swiftPackageCacheOptions } from './home-paths'
26
+ import { isRecord } from './is-record'
25
27
  import { terminateProcessGroup } from './process-group'
26
28
  import { swiftCompilerSourceDigest } from './swift-compiler-digest'
27
29
  import { designTimeDiagnostic, designTimeSource } from './swift-design-time'
@@ -31,16 +33,38 @@ import {
31
33
  type SwiftDistributionManifest,
32
34
  } from './swift-distribution-contract'
33
35
  import { swiftIcuAsset, type SwiftIcuAsset } from './swift-icu'
36
+ import { swiftObjCExports } from './swift-objc-export'
37
+ import { swiftObjCImports, swiftObjCPrivateImports } from './swift-objc-import'
38
+ import { validateObjcPeerStartupLibraries } from './swift-objc-metadata'
39
+ import { materializeObjcSdk, objcView } from './swift-objc-standin'
34
40
  import {
41
+ OBJC_RESOURCE_ACCESSOR_BODY,
42
+ OBJC_RESOURCE_ACCESSOR_HEADER,
35
43
  swiftManifestCxxLanguageStandard,
36
44
  swiftManifestTargets,
45
+ swiftObjCResourceAccessor,
46
+ swiftObjCResourceBundleName,
37
47
  swiftPackagePartition,
38
48
  swiftTargetModuleName,
39
49
  type SwiftPackageTarget,
40
50
  } from './swift-package'
41
51
  import { withSwiftRootLock, type SwiftRootLease } from './swift-root-lock'
42
- import { swiftEnvironment, swiftSdkOptions, type SwiftWasmSdk } from './swift-toolchain'
43
- import { isSwiftResourceBundles } from './swiftContract'
52
+ import {
53
+ swiftEnvironment,
54
+ swiftSdkOptions,
55
+ swiftToolchain,
56
+ type SwiftWasmSdk,
57
+ } from './swift-toolchain'
58
+ import {
59
+ isSwiftNativeTargets,
60
+ isSwiftObjCPeerStartup,
61
+ isSwiftResourceBundles,
62
+ SWIFT_NATIVE_INPUT_ROOT,
63
+ SWIFT_NATIVE_SDK_INCLUDE,
64
+ type SwiftNativeTarget,
65
+ type SwiftObjCPeerStartup,
66
+ type SwiftProjectPreparation,
67
+ } from './swiftContract'
44
68
  import type { SwiftImageUpload } from './swift-submit'
45
69
  import type { SwiftResourceBundle } from './swiftContract'
46
70
 
@@ -59,7 +83,7 @@ async function runCompiler(
59
83
  options: ExecFileOptions & { signal?: AbortSignal; lease?: SwiftRootLease },
60
84
  stream: boolean | RegExp = false,
61
85
  quiet?: RegExp,
62
- ): Promise<void> {
86
+ ): Promise<string> {
63
87
  const { signal } = options
64
88
  signal?.throwIfAborted()
65
89
  const launch = {
@@ -73,7 +97,7 @@ async function runCompiler(
73
97
  : spawn(command, args, launch)
74
98
  let stopping: Promise<void> | undefined
75
99
  try {
76
- await new Promise<void>((resolve, reject) => {
100
+ return await new Promise<string>((resolve, reject) => {
77
101
  let failure: Error | undefined
78
102
  let timeout: ReturnType<typeof setTimeout> | undefined
79
103
  const chunks: Record<'stdout' | 'stderr', Buffer[]> = { stdout: [], stderr: [] }
@@ -129,7 +153,7 @@ async function runCompiler(
129
153
  for (const name of ['stdout', 'stderr'] as const)
130
154
  for (const line of Buffer.concat(chunks[name]).toString().split('\n'))
131
155
  if (line && !quiet.test(line)) process[name].write(`${line}\n`)
132
- resolve()
156
+ resolve(Buffer.concat(chunks.stdout).toString())
133
157
  }
134
158
  })
135
159
  if (options.timeout)
@@ -144,7 +168,7 @@ async function runCompiler(
144
168
  }
145
169
  }
146
170
 
147
- const WASM_TRIPLE = 'wasm32-unknown-wasip1'
171
+ export const WASM_TRIPLE = 'wasm32-unknown-wasip1'
148
172
 
149
173
  // swiftpm's step counter, echoed while a build runs; its diagnostics print
150
174
  // once, with the failure.
@@ -161,6 +185,8 @@ const BUILD_JOBS = String(
161
185
 
162
186
  export interface SwiftCompileInput {
163
187
  files: Record<string, string>
188
+ objcPeerStartup?: SwiftObjCPeerStartup
189
+ nativeTargets?: SwiftNativeTarget[]
164
190
  metalSources?: Record<string, string>
165
191
  resources?: Record<string, string>
166
192
  /** project-relative resource paths retained before the bundle namespace flattens. */
@@ -182,6 +208,18 @@ export interface SwiftCompileInput {
182
208
  libraries?: Record<string, string>
183
209
  }
184
210
 
211
+ // the builder hop wraps the compiler's own timeout with admission, transfer and
212
+ // artifact return. both dispatch layers take their deadline from here so the
213
+ // client never kills the hop before the compiler has its full timeout.
214
+ const SWIFT_BUILDER_TRANSPORT_MARGIN_MS = 300_000
215
+ const SWIFT_BUILDER_DEFAULT_COMPILE_MS = 1_800_000
216
+ export function swiftBuilderHopTimeoutMs(compileTimeoutMs: number | undefined): number {
217
+ return (
218
+ (compileTimeoutMs ?? SWIFT_BUILDER_DEFAULT_COMPILE_MS) +
219
+ SWIFT_BUILDER_TRANSPORT_MARGIN_MS
220
+ )
221
+ }
222
+
185
223
  export interface SwiftCompileOptions {
186
224
  buildRoot: string
187
225
  moduleRoot: string
@@ -838,6 +876,8 @@ export function swiftArtifactHash(
838
876
  [...(input.resourceBundles ?? [])].sort((a, b) => a.target.localeCompare(b.target)),
839
877
  ),
840
878
  )
879
+ hash.update(JSON.stringify(input.nativeTargets ?? []))
880
+ hash.update(JSON.stringify(input.objcPeerStartup ?? null))
841
881
  for (const target of Object.keys(input.libraries ?? {}).sort()) {
842
882
  hash.update(`library\n${target}\n`)
843
883
  hash.update(
@@ -864,9 +904,13 @@ export function swiftArtifactHash(
864
904
  interface SwiftNativeTargetPlan {
865
905
  path: string
866
906
  includeDirectory: string
907
+ sources: string[]
867
908
  // units that consume a swift-generated header: excluded from the original
868
909
  // target and compiled by the downstream implementation target.
869
910
  lateSources: string[]
911
+ mixed?: boolean
912
+ exclude?: string[]
913
+ groups?: { name: string; sources: string[]; flags: string[]; cxxFlags: string[] }[]
870
914
  late?: { name: string; producers: string[] }
871
915
  }
872
916
 
@@ -875,6 +919,7 @@ export function emitSwiftPackageManifest(args: {
875
919
  cxxLanguageStandard?: string
876
920
  native?: Map<string, SwiftNativeTargetPlan>
877
921
  headerDirectory?: string
922
+ objcExports?: { modules: Set<string>; flags: string[] }
878
923
  siblings: Map<string, string[]>
879
924
  moduleRoot: string
880
925
  oneModule?: boolean
@@ -953,6 +998,9 @@ export function emitSwiftPackageManifest(args: {
953
998
  ? ' .defaultIsolation(MainActor.self),'
954
999
  : ''
955
1000
  const interoperability = target.cxxInterop ? ' .interoperabilityMode(.Cxx),' : ''
1001
+ const exports = args.objcExports?.modules.has(target.name)
1002
+ ? ' .enableExperimentalFeature("Extern"),'
1003
+ : ''
956
1004
  const defines = (target.defines ?? [])
957
1005
  .map((name) => ` .define(${JSON.stringify(name)}),`)
958
1006
  .join('')
@@ -969,8 +1017,9 @@ export function emitSwiftPackageManifest(args: {
969
1017
  ? `, "-I", ${JSON.stringify(path.join(moduleRoot, 'modules'))}`
970
1018
  : ''
971
1019
  const native = args.native?.get(target.name)
1020
+ const clang = native && !native.mixed
972
1021
  const nativeImports = (siblings.get(target.name) ?? [])
973
- .filter((name) => args.native?.has(name))
1022
+ .filter((name) => args.native?.has(name) && !args.native.get(name)?.mixed)
974
1023
  .map(
975
1024
  (name) =>
976
1025
  `, "-Xfrontend", "-import-module", "-Xfrontend", ${JSON.stringify(swiftTargetModuleName(name))}`,
@@ -981,30 +1030,54 @@ export function emitSwiftPackageManifest(args: {
981
1030
  [...(args.native?.values() ?? [])].some((value) =>
982
1031
  value.late?.producers.includes(target.name),
983
1032
  )
984
- ? `, "-emit-objc-header-path", ${JSON.stringify(path.join(args.headerDirectory, `${target.name}-Swift.h`))}`
1033
+ ? `, "-emit-objc-header-path", ${JSON.stringify(path.join(args.headerDirectory, `${target.name}-${args.objcExports?.modules.has(target.name) ? 'Cxx' : 'Swift'}.h`))}`
985
1034
  : ''
986
- const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation}${interoperability}${defines} .unsafeFlags(["-Osize", "-Xfrontend", "-enable-cross-import-overlays"${overlayFlags}${FOUNDATION_IMPLICIT_FLAGS}${oneModule ? ONE_IMPLICIT_FLAGS : ''}${imports}${nativeImports}${header}])]`
1035
+ const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation}${interoperability}${defines}${exports} .unsafeFlags(["-Osize", "-Xfrontend", "-enable-cross-import-overlays"${overlayFlags}${FOUNDATION_IMPLICIT_FLAGS}${oneModule ? ONE_IMPLICIT_FLAGS : ''}${imports}${nativeImports}${header}])]`
987
1036
  const deps = [
988
- ...(target.executable
989
- ? [...(args.native?.values() ?? [])].flatMap((value) =>
990
- value.late ? [JSON.stringify(value.late.name)] : [],
1037
+ ...new Set([
1038
+ ...(target.executable
1039
+ ? [
1040
+ ...new Set([
1041
+ ...(args.objcExports?.modules ?? []),
1042
+ ...[...(args.native?.values() ?? [])].flatMap(
1043
+ (value) => value.late?.producers ?? [],
1044
+ ),
1045
+ ]),
1046
+ ]
1047
+ .filter((name) => name !== target.name)
1048
+ .map((name) => JSON.stringify(name))
1049
+ : []),
1050
+ ...(target.executable && args.objcExports ? ['"PeachSwiftObjCExports"'] : []),
1051
+ ...(target.executable
1052
+ ? [...(args.native?.values() ?? [])].flatMap((value) =>
1053
+ value.late
1054
+ ? (value.groups ?? [{ name: value.late.name }]).map((group) =>
1055
+ JSON.stringify(group.name),
1056
+ )
1057
+ : [],
1058
+ )
1059
+ : []),
1060
+ ...(distribution || (clang && !target.executable)
1061
+ ? []
1062
+ : [
1063
+ '.product(name: "SwiftUI", package: "sootsim-swift")',
1064
+ ...(oneModule ? [ONE_PRODUCT] : []),
1065
+ ...(spriteKit ? [SPRITEKIT_PRODUCT] : []),
1066
+ ]),
1067
+ ...(siblings.get(target.name) ?? []).flatMap((dependency) =>
1068
+ clang &&
1069
+ [...(args.native?.values() ?? [])].some((value) =>
1070
+ value.late?.producers.includes(dependency),
991
1071
  )
992
- : []),
993
- ...(distribution || (native && !target.executable)
994
- ? []
995
- : [
996
- '.product(name: "SwiftUI", package: "sootsim-swift")',
997
- ...(oneModule ? [ONE_PRODUCT] : []),
998
- ...(spriteKit ? [SPRITEKIT_PRODUCT] : []),
999
- ]),
1000
- ...(siblings.get(target.name) ?? []).flatMap((dependency) =>
1001
- OPTIONAL_FRAMEWORKS.has(dependency) &&
1002
- !targets.some((candidate) => candidate.name === dependency)
1003
- ? distribution
1004
1072
  ? []
1005
- : [`.product(name: "${dependency}", package: "sootsim-swift")`]
1006
- : [`"${dependency}"`],
1007
- ),
1073
+ : OPTIONAL_FRAMEWORKS.has(dependency) &&
1074
+ !targets.some((candidate) => candidate.name === dependency)
1075
+ ? distribution
1076
+ ? []
1077
+ : [`.product(name: "${dependency}", package: "sootsim-swift")`]
1078
+ : [`"${dependency}"`],
1079
+ ),
1080
+ ]),
1008
1081
  ].join(', ')
1009
1082
  const library =
1010
1083
  distribution && distributionLink
@@ -1027,7 +1100,7 @@ export function emitSwiftPackageManifest(args: {
1027
1100
  linkerSettings: [
1028
1101
  ${linkedLibraries.map((setting) => `${setting},`).join('\n ')}
1029
1102
  .unsafeFlags([
1030
- ${REACTOR_FLAG}${EXECUTABLE_LINK_FLAGS} "-Xlinker", "--export-if-defined=__main_argc_argv"${library},
1103
+ ${REACTOR_FLAG}${EXECUTABLE_LINK_FLAGS} "-Xlinker", "--export-if-defined=__main_argc_argv"${args.objcExports ? ', "-Xlinker", "--fatal-warnings"' : ''}${library},
1031
1104
  ]),
1032
1105
  .unsafeFlags(["-Xlinker", "--strip-all"], .when(configuration: .release)),
1033
1106
  ]`
@@ -1040,10 +1113,12 @@ export function emitSwiftPackageManifest(args: {
1040
1113
  ` name: "${target.name}",`,
1041
1114
  ` dependencies: [${deps}],`,
1042
1115
  ` path: "${target.path}",`,
1043
- ...(native ? [` exclude: ${JSON.stringify(native.lateSources)},`] : []),
1116
+ ...(native
1117
+ ? [` exclude: ${JSON.stringify(native.exclude ?? native.lateSources)},`]
1118
+ : []),
1044
1119
  // the native backend supplies dependency module maps without their
1045
1120
  // compiled modules. textual c++ includes keep those dependencies usable.
1046
- ` ${native ? `cxxSettings: [${defines} .unsafeFlags(["-fno-cxx-modules"])]` : swiftSettings}${link}`,
1121
+ ` ${clang ? `${args.objcExports ? `cSettings: [.unsafeFlags(${JSON.stringify(args.objcExports.flags)})], ` : ''}cxxSettings: [${defines} .unsafeFlags(["-fno-cxx-modules"])]` : swiftSettings}${link}`,
1047
1122
  ` ),`,
1048
1123
  ].join('\n')
1049
1124
  }
@@ -1060,16 +1135,40 @@ export function emitSwiftPackageManifest(args: {
1060
1135
  ` dependencies: [${distribution ? '' : `.package(path: "${moduleRoot}")`}],`,
1061
1136
  ' targets: [',
1062
1137
  ...targets.map(stanza),
1138
+ ...(args.objcExports
1139
+ ? [
1140
+ ' .target(name: "PeachSwiftObjCExports",',
1141
+ ' dependencies: [],',
1142
+ ' path: "PeachObjCExports",',
1143
+ ` sources: ${JSON.stringify(['root.m', ...[...args.objcExports.modules].map((name) => `${name}.m`)])},`,
1144
+ ' publicHeadersPath: "include",',
1145
+ ` cSettings: [.unsafeFlags(${JSON.stringify([...args.objcExports.flags.filter((flag) => flag !== '-fobjc-arc'), '-fno-objc-arc', '-Xclang', '-disable-objc-default-synthesize-properties'])})]),`,
1146
+ ]
1147
+ : []),
1063
1148
  ...[...(args.native?.entries() ?? [])].flatMap(([name, native]) =>
1064
1149
  native.late
1065
- ? [
1066
- ` .target(name: ${JSON.stringify(native.late.name)},`,
1067
- ` dependencies: ${JSON.stringify([name, ...native.late.producers])},`,
1150
+ ? (
1151
+ native.groups ?? [
1152
+ {
1153
+ name: native.late.name,
1154
+ sources: native.lateSources,
1155
+ flags: [],
1156
+ cxxFlags: [],
1157
+ },
1158
+ ]
1159
+ ).flatMap((group) => [
1160
+ ` .target(name: ${JSON.stringify(group.name)},`,
1161
+ ` dependencies: ${JSON.stringify(args.native?.get(name)?.mixed ? [] : [name])},`,
1068
1162
  ` path: ${JSON.stringify(native.path)},`,
1069
- ` sources: ${JSON.stringify(native.lateSources)},`,
1163
+ ` sources: ${JSON.stringify(group.sources)},`,
1070
1164
  ` publicHeadersPath: "include",`,
1071
- ` cxxSettings: [.unsafeFlags(["-fno-cxx-modules", "-I", ${JSON.stringify(native.includeDirectory)}, "-I", ${JSON.stringify(args.headerDirectory)}])]),`,
1072
- ]
1165
+ ...(args.objcExports
1166
+ ? [
1167
+ ` cSettings: [.unsafeFlags(${JSON.stringify([...args.objcExports.flags, ...group.flags])})],`,
1168
+ ]
1169
+ : []),
1170
+ ` cxxSettings: [.unsafeFlags(${JSON.stringify(['-fno-cxx-modules', '-I', native.includeDirectory, '-I', args.headerDirectory, ...group.cxxFlags])})]),`,
1171
+ ])
1073
1172
  : [],
1074
1173
  ),
1075
1174
  args.cxxLanguageStandard
@@ -2314,6 +2413,68 @@ const SDK_OBJC_OPTIONAL: Record<
2314
2413
  ][]
2315
2414
  }
2316
2415
  > = {
2416
+ UIAdaptivePresentationControllerDelegate: {
2417
+ mainActor: true,
2418
+ parents: [],
2419
+ requirements: [
2420
+ [
2421
+ 'presentationControllerShouldDismiss(_:)',
2422
+ 'presentationControllerShouldDismiss:',
2423
+ 'UIPresentationController->Bool',
2424
+ ],
2425
+ [
2426
+ 'presentationControllerWillDismiss(_:)',
2427
+ 'presentationControllerWillDismiss:',
2428
+ 'UIPresentationController->Void',
2429
+ ],
2430
+ [
2431
+ 'presentationControllerDidDismiss(_:)',
2432
+ 'presentationControllerDidDismiss:',
2433
+ 'UIPresentationController->Void',
2434
+ ],
2435
+ [
2436
+ 'presentationControllerDidAttemptToDismiss(_:)',
2437
+ 'presentationControllerDidAttemptToDismiss:',
2438
+ 'UIPresentationController->Void',
2439
+ ],
2440
+ [
2441
+ 'adaptivePresentationStyle(for:)',
2442
+ 'adaptivePresentationStyleForPresentationController:',
2443
+ 'UIPresentationController->UIModalPresentationStyle',
2444
+ ],
2445
+ [
2446
+ 'adaptivePresentationStyle(for:traitCollection:)',
2447
+ 'adaptivePresentationStyleForPresentationController:traitCollection:',
2448
+ 'UIPresentationController,UITraitCollection->UIModalPresentationStyle',
2449
+ ],
2450
+ [
2451
+ 'presentationController(_:willPresentWithAdaptiveStyle:transitionCoordinator:)',
2452
+ 'presentationController:willPresentWithAdaptiveStyle:transitionCoordinator:',
2453
+ 'UIPresentationController,UIModalPresentationStyle,(UIViewControllerTransitionCoordinator)?->Void',
2454
+ ],
2455
+ ],
2456
+ },
2457
+ UIPopoverPresentationControllerDelegate: {
2458
+ mainActor: true,
2459
+ parents: ['UIAdaptivePresentationControllerDelegate'],
2460
+ requirements: [
2461
+ [
2462
+ 'popoverPresentationControllerShouldDismissPopover(_:)',
2463
+ 'popoverPresentationControllerShouldDismissPopover:',
2464
+ 'UIPopoverPresentationController->Bool',
2465
+ ],
2466
+ [
2467
+ 'popoverPresentationControllerDidDismissPopover(_:)',
2468
+ 'popoverPresentationControllerDidDismissPopover:',
2469
+ 'UIPopoverPresentationController->Void',
2470
+ ],
2471
+ [
2472
+ 'prepareForPopoverPresentation(_:)',
2473
+ 'prepareForPopoverPresentation:',
2474
+ 'UIPopoverPresentationController->Void',
2475
+ ],
2476
+ ],
2477
+ },
2317
2478
  WKWebExtensionWindow: {
2318
2479
  callers: true,
2319
2480
  mainActor: true,
@@ -5521,6 +5682,87 @@ export function swiftApplicationEntry(file: string, source: string): boolean {
5521
5682
  return false
5522
5683
  }
5523
5684
 
5685
+ // swift's executable entry runs after the reactor's _initialize has completed.
5686
+ // global swift values remain lazy; native application initializers need separate
5687
+ // object evidence and are refused here rather than running the registry early.
5688
+ function installObjcPeerStartup(
5689
+ input: SwiftCompileInput,
5690
+ targets: SwiftPackageTarget[],
5691
+ compiled: Map<string, string>,
5692
+ ): void {
5693
+ const startup = input.objcPeerStartup
5694
+ if (!startup) return
5695
+ function fail(detail: string): never {
5696
+ throw new Error(`Objective-C peer startup: ${detail}`)
5697
+ }
5698
+ if (
5699
+ (input.nativeTargets?.length ?? 0) > 0 ||
5700
+ Object.keys(input.files).some((file) => /\.(?:c|cc|cpp|cxx|m|mm)$/.test(file))
5701
+ )
5702
+ fail('original native source targets require constructor provenance before admission')
5703
+ validateObjcPeerStartupLibraries(input.libraries ?? {})
5704
+ const executables = targets.filter((target) => target.executable)
5705
+ if (executables.length !== 1)
5706
+ fail('requires one executable application entry; library startup is unqualified')
5707
+ const target = executables[0]!
5708
+ const prefix = target.path === '.' ? '' : `${target.path}/`
5709
+ const belongs = (file: string): boolean =>
5710
+ file.startsWith(prefix) &&
5711
+ !targets.some(
5712
+ (other) =>
5713
+ other !== target &&
5714
+ other.path !== '.' &&
5715
+ other.path.startsWith(prefix) &&
5716
+ file.startsWith(`${other.path}/`),
5717
+ )
5718
+ if (
5719
+ !belongs(input.entry) ||
5720
+ !belongs(startup.registration) ||
5721
+ !compiled.has(startup.registration) ||
5722
+ startup.registration === input.entry
5723
+ )
5724
+ fail('generated registration and entry must belong to the same executable target')
5725
+ for (const [file, source] of compiled) {
5726
+ if (/@_(?:section|used)\b/.test(swiftCodeMask(source)))
5727
+ fail(`${file} contains unqualified pre-main Swift storage`)
5728
+ }
5729
+ const entries = [...compiled].filter(
5730
+ ([file, source]) => belongs(file) && /@main\b/.test(swiftCodeMask(source)),
5731
+ )
5732
+ if (entries.length === 0) {
5733
+ const source = compiled.get(input.entry)
5734
+ if (path.basename(input.entry) !== 'main.swift' || source === undefined)
5735
+ fail('requires main.swift or a supported @main App/UIApplicationDelegate entry')
5736
+ compiled.set(input.entry, `_peachRegisterObjcPeers()\n${source}`)
5737
+ return
5738
+ }
5739
+ if (entries.length !== 1 || entries[0]![0] !== input.entry)
5740
+ fail('requires the exact single @main application entry')
5741
+ const [file, source] = entries[0]!
5742
+ const code = swiftCodeMask(source)
5743
+ const attribute = /@main\b/.exec(code)!
5744
+ const nominal = /\b(?:struct|class|enum)\s+([A-Za-z_]\w*)[^{}]*\{/.exec(
5745
+ code.slice(attribute.index),
5746
+ )
5747
+ if (
5748
+ !nominal ||
5749
+ /\bstatic\s+func\s+main\s*\([^)]*\)[^{]*\b(?:async|throws|rethrows)\b/.test(code)
5750
+ )
5751
+ fail('generic, async or throwing application entries are unqualified')
5752
+ if (/\b(?:struct|class|enum)\s+\w+\s*</.test(nominal[0]))
5753
+ fail('generic application entries are unqualified')
5754
+ const generated = `${prefix}PeachObjCPeerStartup.generated.swift`
5755
+ if (compiled.has(generated)) fail('generated entry conflicts with application sources')
5756
+ compiled.set(
5757
+ file,
5758
+ source.slice(0, attribute.index) + ' ' + source.slice(attribute.index + 5),
5759
+ )
5760
+ compiled.set(
5761
+ generated,
5762
+ `@main struct __PeachObjCPeerStartupEntry {\n @MainActor static func main() {\n _peachRegisterObjcPeers()\n ${nominal[1]}.main()\n }\n}\n`,
5763
+ )
5764
+ }
5765
+
5524
5766
  // the offsets of the lines that begin in code, and of every `@`, `#`,
5525
5767
  // `class`, `extension` and `override` keyword that stands in code (an interpolation's code included), from a scan of Swift's
5526
5768
  // lexical contexts: nested block comments, line comments, string literals (single and
@@ -5695,7 +5937,14 @@ export function writeSwiftProject(
5695
5937
  layout: SwiftProjectLayout,
5696
5938
  input: SwiftCompileInput,
5697
5939
  moduleRoot: string,
5698
- ): void {
5940
+ ): SwiftProjectPreparation {
5941
+ if (
5942
+ input.objcPeerStartup !== undefined &&
5943
+ !isSwiftObjCPeerStartup(input.objcPeerStartup)
5944
+ )
5945
+ throw new Error('swift compile input has invalid Objective-C peer startup metadata')
5946
+ if (input.nativeTargets !== undefined && !isSwiftNativeTargets(input.nativeTargets))
5947
+ throw new Error('swift compile input has invalid original clang target inputs')
5699
5948
  if (
5700
5949
  input.resourceBundles !== undefined &&
5701
5950
  !isSwiftResourceBundles(input.resourceBundles)
@@ -5723,7 +5972,54 @@ export function writeSwiftProject(
5723
5972
  : compileTargets(input)
5724
5973
  const files = new Map<string, string | Buffer>()
5725
5974
  const native = new Map<string, SwiftNativeTargetPlan>()
5975
+ const bySourcePath = [...targets].sort(
5976
+ (left, right) => right.path.length - left.path.length,
5977
+ )
5978
+ const swiftTargets = new Set<string>()
5979
+ for (const file of Object.keys(input.files)) {
5980
+ if (!file.endsWith('.swift')) continue
5981
+ const target = bySourcePath.find(
5982
+ (candidate) => candidate.path === '.' || file.startsWith(`${candidate.path}/`),
5983
+ )
5984
+ if (target) swiftTargets.add(target.name)
5985
+ }
5726
5986
  const headerDirectory = path.join(layout.root, '.build', 'peach-cxx-headers')
5987
+ const headerModuleDirectory = path.join(
5988
+ layout.root,
5989
+ '.build',
5990
+ 'peach-objc-export-modules',
5991
+ )
5992
+ const imports = new Map<
5993
+ string,
5994
+ {
5995
+ view: ReturnType<typeof objcView>
5996
+ classes: string[]
5997
+ headers: string[]
5998
+ foreignTypes: Map<string, string>
5999
+ }
6000
+ >()
6001
+ // headers keep their original project paths. product headers additionally
6002
+ // occupy the same Module/Header.h namespace that xcode publishes.
6003
+ for (const settings of input.nativeTargets ?? []) {
6004
+ for (const file of settings.headers) {
6005
+ const contents = input.files[file]
6006
+ if (contents === undefined)
6007
+ throw new Error(`missing original Objective-C header ${file}`)
6008
+ const destination = path.join(layout.root, file)
6009
+ mkdirSync(path.dirname(destination), { recursive: true })
6010
+ writeFileSync(destination, contents)
6011
+ files.set(destination, contents)
6012
+ }
6013
+ for (const header of settings.publicHeaders) {
6014
+ const destination = path.join(headerDirectory, settings.name, path.basename(header))
6015
+ if (files.has(destination))
6016
+ throw new Error(`duplicate product header ${destination}`)
6017
+ const contents = `#import ${JSON.stringify(path.join(layout.root, header))}\n`
6018
+ files.set(destination, contents)
6019
+ mkdirSync(path.dirname(destination), { recursive: true })
6020
+ writeFileSync(destination, contents)
6021
+ }
6022
+ }
5727
6023
  // declarations are imported before swift can emit the header that native
5728
6024
  // implementations consume. give those implementations a downstream target.
5729
6025
  for (const target of targets) {
@@ -5739,9 +6035,232 @@ export function writeSwiftProject(
5739
6035
  file.startsWith(`${candidate.path}/`),
5740
6036
  ),
5741
6037
  )
5742
- if (entries.some(([file]) => file.endsWith('.swift'))) continue
5743
6038
  const units = entries.filter(([file]) => /\.(?:c|cc|cpp|cxx|m|mm)$/.test(file))
5744
6039
  if (units.length === 0) continue
6040
+ const settings = input.nativeTargets?.find((value) => value.name === target.name)
6041
+ if (
6042
+ entries.some(([file]) => file.endsWith('.swift')) ||
6043
+ (settings && units.some(([file]) => /\.mm?$/.test(file)))
6044
+ ) {
6045
+ if (!settings)
6046
+ throw new Error(
6047
+ `mixed target ${target.name} requires its original native target settings; SwiftPM does not compile mixed source targets`,
6048
+ )
6049
+ const headers = settings.headers
6050
+ const roots = settings.bridgingHeader
6051
+ ? [settings.bridgingHeader]
6052
+ : settings.publicHeaders
6053
+ if (!roots.length)
6054
+ throw new Error(`mixed target ${target.name} has no original declaration headers`)
6055
+ for (const file of headers) {
6056
+ const destination = path.join(layout.root, file)
6057
+ mkdirSync(path.dirname(destination), { recursive: true })
6058
+ writeFileSync(destination, input.files[file]!)
6059
+ }
6060
+ const search = [
6061
+ ...new Set([
6062
+ ...(settings?.headerSearchPaths ?? []),
6063
+ ...headers.map((file) => path.posix.dirname(file)),
6064
+ ]),
6065
+ ].flatMap((dir) => ['-I', path.join(layout.root, dir)])
6066
+ const pin: { release: string } =
6067
+ distribution ??
6068
+ JSON.parse(readFileSync(path.join(moduleRoot, 'toolchain.json'), 'utf8'))
6069
+ const release = pin.release
6070
+ const toolchainBin = swiftToolchain(release, swiftModuleSdk(moduleRoot))
6071
+ const sdkHeaders = materializeObjcSdk(
6072
+ path.join(layout.root, '.build', 'peach-objc-sdk'),
6073
+ )
6074
+ const stageFlags = (flags: readonly string[], sdkInclude: string) =>
6075
+ flags.map((flag) =>
6076
+ flag
6077
+ .replaceAll(SWIFT_NATIVE_INPUT_ROOT, layout.root)
6078
+ .replaceAll(SWIFT_NATIVE_SDK_INCLUDE, sdkInclude),
6079
+ )
6080
+ const originalFlags = [
6081
+ ...(settings?.flags ?? []),
6082
+ ...search,
6083
+ ...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
6084
+ '-F',
6085
+ path.join(layout.root, dir),
6086
+ ]),
6087
+ '-I',
6088
+ headerDirectory,
6089
+ ]
6090
+ const flags = stageFlags(
6091
+ originalFlags,
6092
+ path.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, 'include'),
6093
+ )
6094
+ const prefixHeader = settings?.prefixHeader
6095
+ ? ['-include', path.join(layout.root, settings.prefixHeader)]
6096
+ : []
6097
+ // swiftpm gives a native resource target's units an accessor header and
6098
+ // one more unit defining it. the swift accessor below stays for swift.
6099
+ const bundleName = entries.some(([file]) => file.endsWith('.swift'))
6100
+ ? undefined
6101
+ : swiftObjCResourceBundleName({
6102
+ target: target.name,
6103
+ path: target.path,
6104
+ resources:
6105
+ resourceTargets.find((candidate) => candidate.name === target.name)
6106
+ ?.resources ?? false,
6107
+ usesBundleMacro: entries.some(
6108
+ ([file, contents]) =>
6109
+ /\.(?:c|cc|cpp|cxx|m|mm|h|hpp|hh|hxx)$/.test(file) &&
6110
+ /\bSWIFTPM_MODULE_BUNDLE\b/.test(contents),
6111
+ ),
6112
+ bundles: input.resourceBundles,
6113
+ })
6114
+ const accessor =
6115
+ bundleName === undefined ? undefined : swiftObjCResourceAccessor(bundleName)
6116
+ const accessorHeader = path.join(
6117
+ layout.root,
6118
+ target.path,
6119
+ OBJC_RESOURCE_ACCESSOR_HEADER,
6120
+ )
6121
+ const accessorUnit = `${prefix}${OBJC_RESOURCE_ACCESSOR_BODY}`
6122
+ if (
6123
+ accessor &&
6124
+ (input.files[accessorUnit] !== undefined ||
6125
+ input.files[`${prefix}${OBJC_RESOURCE_ACCESSOR_HEADER}`] !== undefined)
6126
+ )
6127
+ throw new Error(`target ${target.name} already contains its resource accessor`)
6128
+ const nativeUnits: [string, string][] = accessor
6129
+ ? [...units, [accessorUnit, accessor.body]]
6130
+ : units
6131
+ const accessorFlags = accessor ? ['-include', accessorHeader] : []
6132
+ if (accessor) {
6133
+ files.set(accessorHeader, accessor.header)
6134
+ files.set(path.join(layout.root, accessorUnit), accessor.body)
6135
+ }
6136
+ const sourceHeaders = path.join(
6137
+ layout.root,
6138
+ '.build',
6139
+ 'peach-objc-originals',
6140
+ target.name,
6141
+ )
6142
+ mkdirSync(sourceHeaders, { recursive: true })
6143
+ const modulemap = path.join(sourceHeaders, 'module.modulemap')
6144
+ writeFileSync(
6145
+ modulemap,
6146
+ `module ${swiftTargetModuleName(target.name)} {\n${roots.map((file) => `header ${JSON.stringify(path.join(layout.root, file))}`).join('\n')}\nexport *\n}\n`,
6147
+ )
6148
+ const view = objcView(
6149
+ { module: swiftTargetModuleName(target.name), headers: sourceHeaders, modulemap },
6150
+ toolchainBin,
6151
+ path.join(moduleRoot, 'ios-simulator-stdlib'),
6152
+ path.join(layout.root, '.build', 'peach-objc-sdk'),
6153
+ path.join(layout.root, '.build', 'peach-objc-imports', target.name),
6154
+ {
6155
+ flags: stageFlags(originalFlags, path.join(sdkHeaders, 'usr/include')),
6156
+ target: `arm64-apple-ios${settings?.deploymentTarget ?? '16.0'}-simulator`,
6157
+ },
6158
+ )
6159
+ const defined = new Set<string>()
6160
+ const declarations = (node: unknown): void => {
6161
+ if (!node || typeof node !== 'object') return
6162
+ const name: unknown = Reflect.get(node, 'name')
6163
+ if (
6164
+ Reflect.get(node, 'kind') === 'ObjCInterfaceDecl' &&
6165
+ Reflect.get(node, 'super') &&
6166
+ typeof name === 'string'
6167
+ )
6168
+ defined.add(name)
6169
+ const children: unknown = Reflect.get(node, 'inner')
6170
+ if (Array.isArray(children)) for (const child of children) declarations(child)
6171
+ }
6172
+ declarations(view.clangAST)
6173
+ const foreignTypes = new Map<string, string>()
6174
+ for (const graph of view.graphs)
6175
+ for (const symbol of graph.symbols) {
6176
+ const nativeName = /^c:objc\(cs\)(\w+)$/.exec(symbol.identifier.precise)?.[1]
6177
+ if (nativeName && defined.has(nativeName))
6178
+ foreignTypes.set(symbol.pathComponents[0]!, nativeName)
6179
+ }
6180
+ imports.set(target.name, {
6181
+ view,
6182
+ classes: [...foreignTypes.values()],
6183
+ headers: roots.map((file) => path.join(layout.root, file)),
6184
+ foreignTypes,
6185
+ })
6186
+ const thunk = 'PeachObjCImports.generated.m'
6187
+ const groups = new Map<
6188
+ string,
6189
+ { name: string; sources: string[]; flags: string[]; cxxFlags: string[] }
6190
+ >()
6191
+ for (const [file] of nativeUnits) {
6192
+ const origin = settings?.sourceDirectories[file]
6193
+ if (origin) mkdirSync(path.join(layout.root, origin), { recursive: true })
6194
+ const perFile = [
6195
+ ...(origin ? ['-iquote', path.join(layout.root, origin)] : []),
6196
+ ...stageFlags(
6197
+ settings?.fileFlags[file] ?? [],
6198
+ path.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, 'include'),
6199
+ ),
6200
+ ]
6201
+ const cxx = /\.(?:cc|cpp|cxx|mm)$/.test(file)
6202
+ const identity = createHash('sha256')
6203
+ .update(JSON.stringify([cxx, perFile]))
6204
+ .digest('hex')
6205
+ .slice(0, 12)
6206
+ const group = groups.get(identity) ?? {
6207
+ name: `${target.name}SwiftImplementation_${identity}`,
6208
+ sources: [],
6209
+ flags: [...flags, ...prefixHeader, ...accessorFlags, ...perFile],
6210
+ cxxFlags: [
6211
+ ...flags,
6212
+ ...prefixHeader,
6213
+ ...accessorFlags,
6214
+ ...stageFlags(
6215
+ cxx ? settings.cxxFlags : [],
6216
+ path.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, 'include'),
6217
+ ),
6218
+ ...perFile,
6219
+ ],
6220
+ }
6221
+ group.sources.push(file.slice(prefix.length))
6222
+ groups.set(identity, group)
6223
+ }
6224
+ groups.set('imports', {
6225
+ name: `${target.name}ObjCImports`,
6226
+ sources: [thunk],
6227
+ flags: [...flags, '-fobjc-arc'],
6228
+ cxxFlags: [...flags, '-fobjc-arc'],
6229
+ })
6230
+ const include = path.join(layout.root, target.path, 'include')
6231
+ files.set(
6232
+ path.join(include, 'module.modulemap'),
6233
+ `module ${target.name}ImplementationDeclarations { export * }\n`,
6234
+ )
6235
+ native.set(target.name, {
6236
+ mixed: true,
6237
+ path: target.path,
6238
+ includeDirectory: include,
6239
+ sources: nativeUnits.map(([file]) => file.slice(prefix.length)),
6240
+ lateSources: [...nativeUnits.map(([file]) => file.slice(prefix.length)), thunk],
6241
+ exclude: [
6242
+ ...entries
6243
+ .filter(([file]) => !file.endsWith('.swift') && !file.endsWith('.metal'))
6244
+ .map(([file]) => file.slice(prefix.length)),
6245
+ ...(accessor
6246
+ ? [OBJC_RESOURCE_ACCESSOR_HEADER, OBJC_RESOURCE_ACCESSOR_BODY]
6247
+ : []),
6248
+ thunk,
6249
+ 'include',
6250
+ ],
6251
+ groups: [...groups.values()],
6252
+ late: {
6253
+ name: `${target.name}SwiftImplementation`,
6254
+ producers: [
6255
+ target.name,
6256
+ ...(target.dependencies ?? [])
6257
+ .filter((dependency) => swiftTargets.has(dependency.name))
6258
+ .map((dependency) => dependency.name),
6259
+ ],
6260
+ },
6261
+ })
6262
+ continue
6263
+ }
5745
6264
  const includes = `${prefix}include/`
5746
6265
  const consumers = new Map<string, Set<string>>()
5747
6266
  const reverse = new Map<string, string[]>()
@@ -5749,7 +6268,9 @@ export function writeSwiftProject(
5749
6268
  const producers = new Set<string>()
5750
6269
  // a block-commented include is not an edge.
5751
6270
  const source = contents.replace(/\/\*[\s\S]*?\*\//g, '')
5752
- for (const match of source.matchAll(/^\s*#\s*include\s*[<"]([^>"]+)[>"]/gm)) {
6271
+ for (const match of source.matchAll(
6272
+ /^\s*#\s*(?:include|import)\s*[<"]([^>"]+)[>"]/gm,
6273
+ )) {
5753
6274
  const include = match[1]!
5754
6275
  const producer = /(?:^|\/)([^/]+)-Swift\.h$/.exec(include)?.[1]
5755
6276
  if (producer && targets.some((value) => value.name === producer))
@@ -5778,6 +6299,7 @@ export function writeSwiftProject(
5778
6299
  native.set(target.name, {
5779
6300
  path: target.path,
5780
6301
  includeDirectory: path.join(layout.root, includes),
6302
+ sources: units.map(([file]) => file.slice(prefix.length)),
5781
6303
  lateSources: late.map(([file]) => file.slice(prefix.length)),
5782
6304
  ...(late.length > 0
5783
6305
  ? {
@@ -5851,6 +6373,247 @@ export function writeSwiftProject(
5851
6373
  ),
5852
6374
  targets,
5853
6375
  )
6376
+ installObjcPeerStartup(
6377
+ input,
6378
+ layout.multi ? targets : targets.map((target) => ({ ...target, path: '.' })),
6379
+ compiled,
6380
+ )
6381
+ // an application's swift module must precede its native implementations.
6382
+ // the tiny executable calls the original typed entry after both are linked.
6383
+ for (const target of [...targets]) {
6384
+ if (
6385
+ !target.executable ||
6386
+ ![...native.values()].some((value) => value.late?.producers.includes(target.name))
6387
+ )
6388
+ continue
6389
+ const prefix = target.path === '.' ? '' : `${target.path}/`
6390
+ const entries = [...compiled].filter(
6391
+ ([file]) =>
6392
+ file.startsWith(prefix) &&
6393
+ !targets.some(
6394
+ (candidate) =>
6395
+ candidate.name !== target.name &&
6396
+ candidate.path !== '.' &&
6397
+ candidate.path.startsWith(prefix) &&
6398
+ file.startsWith(`${candidate.path}/`),
6399
+ ),
6400
+ )
6401
+ const mains = entries.flatMap(([file, source]) => {
6402
+ const match = /@main\b[\s\S]*?\b(?:struct|class|enum)\s+([A-Za-z_]\w*)/.exec(
6403
+ swiftCodeMask(source),
6404
+ )
6405
+ return match ? [{ file, source, match }] : []
6406
+ })
6407
+ if (mains.length !== 1)
6408
+ throw new Error(
6409
+ `mixed executable ${target.name} requires one typed Swift application entry`,
6410
+ )
6411
+ const main = mains[0]!
6412
+ compiled.set(
6413
+ main.file,
6414
+ main.source.slice(0, main.match.index) +
6415
+ ' ' +
6416
+ main.source.slice(main.match.index + 5) +
6417
+ `\n@MainActor public func __peachRunApplication() { ${main.match[1]}.main() }\n`,
6418
+ )
6419
+ const name = `${target.name}Executable`
6420
+ if (targets.some((candidate) => candidate.name === name))
6421
+ throw new Error(`mixed application executable target conflicts with ${name}`)
6422
+ target.executable = false
6423
+ targets.push({
6424
+ ...target,
6425
+ name,
6426
+ path: `PeachApplication/${name}`,
6427
+ executable: true,
6428
+ resources: false,
6429
+ dependencies: [{ kind: 'target', name: target.name }],
6430
+ exclude: [],
6431
+ })
6432
+ files.set(
6433
+ path.join(layout.root, `PeachApplication/${name}/Entry.swift`),
6434
+ `import ${swiftTargetModuleName(target.name)}\n@main struct __PeachApplicationEntry { @MainActor static func main() { __peachRunApplication() } }\n`,
6435
+ )
6436
+ }
6437
+ // genuine objective-c consumers receive declarations and implementations from
6438
+ // one typed export plan. the swift compiler emits their C function prototypes.
6439
+ const objcProducers = new Set<string>()
6440
+ for (const name of imports.keys()) objcProducers.add(name)
6441
+ for (const [name, plan] of native) {
6442
+ if (!plan.late) continue
6443
+ if (plan.lateSources.some((file) => /\.mm?$/.test(file)))
6444
+ for (const producer of plan.late.producers) objcProducers.add(producer)
6445
+ }
6446
+ const objcModules = new Set<string>()
6447
+ const registrations: string[] = []
6448
+ const registeredClasses = new Set<string>(['NSObject'])
6449
+ let rootOwner: string | undefined
6450
+ for (const name of objcProducers) {
6451
+ const target = targets.find((value) => value.name === name)!
6452
+ const prefix = target.path === '.' ? '' : `${target.path}/`
6453
+ const exported = swiftObjCExports({
6454
+ module: swiftTargetModuleName(name),
6455
+ sources: Object.entries(input.files).filter(
6456
+ ([file]) =>
6457
+ file.startsWith(prefix) &&
6458
+ file.endsWith('.swift') &&
6459
+ !targets.some(
6460
+ (candidate) =>
6461
+ candidate.name !== name &&
6462
+ candidate.path !== '.' &&
6463
+ candidate.path.startsWith(prefix) &&
6464
+ file.startsWith(`${candidate.path}/`),
6465
+ ) &&
6466
+ !target.exclude?.some(
6467
+ (excluded) =>
6468
+ file.slice(prefix.length) === excluded ||
6469
+ file.slice(prefix.length).startsWith(`${excluded}/`),
6470
+ ),
6471
+ ),
6472
+ mask: swiftCodeMask,
6473
+ declarationStart,
6474
+ selector: objcSelectorName,
6475
+ foreignTypes: imports.get(name)?.foreignTypes,
6476
+ })
6477
+ const original = imports.get(name)
6478
+ if (!exported && !original) continue
6479
+ objcModules.add(name)
6480
+ rootOwner ??= exported
6481
+ ? [...exported.swift.keys()][0]
6482
+ : `${prefix}PeachObjCImports.generated.swift`
6483
+ files.set(
6484
+ path.join(headerDirectory, `${name}-Swift.h`),
6485
+ exported?.header ?? '#pragma once\n',
6486
+ )
6487
+ files.set(
6488
+ path.join(headerDirectory, name, `${name}-Swift.h`),
6489
+ `#include "../${name}-Swift.h"\n`,
6490
+ )
6491
+ files.set(
6492
+ path.join(headerModuleDirectory, name, 'module.modulemap'),
6493
+ `module ${swiftTargetModuleName(name)} {\n${[
6494
+ path.join(headerDirectory, `${name}-Swift.h`),
6495
+ ...(
6496
+ input.nativeTargets?.find((target) => target.name === name)?.publicHeaders ?? []
6497
+ ).map((header) => path.join(layout.root, header)),
6498
+ ]
6499
+ .map((header) => ` header ${JSON.stringify(header)}`)
6500
+ .join('\n')}\n export *\n}\n`,
6501
+ )
6502
+ files.set(
6503
+ path.join(layout.root, 'PeachObjCExports', `${name}.m`),
6504
+ exported?.implementation ?? `#include "${name}-Cxx.h"\n`,
6505
+ )
6506
+ if (exported) registrations.push(exported.registration)
6507
+ for (const type of exported?.types.values() ?? []) registeredClasses.add(type)
6508
+ for (const type of original?.classes ?? []) registeredClasses.add(type)
6509
+ for (const [file, text] of exported?.swift ?? [])
6510
+ compiled.set(file, compiled.get(file)! + text)
6511
+ if (original) {
6512
+ const generated = swiftObjCImports(original.view.graphs, {
6513
+ module: swiftTargetModuleName(name),
6514
+ headers: original.headers,
6515
+ classes: original.classes,
6516
+ clangAST: original.view.clangAST,
6517
+ peerTypes: exported?.types,
6518
+ })
6519
+ const register = `_peach_objc_imports_${swiftTargetModuleName(name)}`
6520
+ files.set(
6521
+ path.join(layout.root, target.path, 'PeachObjCImports.generated.swift'),
6522
+ generated.swift +
6523
+ generated.registration +
6524
+ `\n@_cdecl("${register}") public func __peachRegisterOriginalObjC() { ${generated.registerFunction}() }\n`,
6525
+ )
6526
+ files.set(
6527
+ path.join(layout.root, target.path, 'PeachObjCImports.generated.m'),
6528
+ generated.objc,
6529
+ )
6530
+ registrations.push(`${register}();`)
6531
+ }
6532
+ }
6533
+ let objcExports: { modules: Set<string>; flags: string[] } | undefined
6534
+ if (rootOwner && input.objcPeerStartup)
6535
+ throw new Error(
6536
+ 'Objective-C peer startup: joining framework metadata with source exports requires one qualified root registration',
6537
+ )
6538
+ if (rootOwner) {
6539
+ if (
6540
+ targets.some((target) => target.name === 'PeachSwiftObjCExports') ||
6541
+ Object.keys(input.files).some((file) => file.startsWith('PeachObjCExports/'))
6542
+ )
6543
+ throw new Error(
6544
+ 'Swift Objective-C export target conflicts with application sources',
6545
+ )
6546
+ const ownerFile = path.join(layout.root, rootOwner)
6547
+ const ownerSource = compiled.get(rootOwner) ?? files.get(ownerFile)
6548
+ if (typeof ownerSource !== 'string')
6549
+ throw new Error('Objective-C root registration has no owning Swift source')
6550
+ files.set(
6551
+ ownerFile,
6552
+ ownerSource +
6553
+ `
6554
+ @_extern(c, "_peach_objc_register_all_exports") private func __peachRegisterAllExports()
6555
+ private let __peachExportRegistration: Void = { __peachRegisterAllExports() }()
6556
+ @_cdecl("_peach_objc_ensure_exports")
6557
+ public func __peachEnsureExportRegistration() { _ = __peachExportRegistration }
6558
+ @_cdecl("_peach_objc_export_root")
6559
+ public func __peachObjcExportRoot() { _objcRegisterPeerClass(NSObject.self, nativeName: "NSObject") }
6560
+ `,
6561
+ )
6562
+ if (compiled.has(rootOwner)) compiled.set(rootOwner, files.get(ownerFile)!.toString())
6563
+ files.set(
6564
+ path.join(layout.root, 'PeachObjCExports', 'include', 'module.modulemap'),
6565
+ 'module PeachSwiftObjCExports { export * }\n',
6566
+ )
6567
+ files.set(
6568
+ path.join(layout.root, 'PeachObjCExports', 'root.m'),
6569
+ [
6570
+ '#import <Foundation/Foundation.h>',
6571
+ 'extern void _peach_objc_ensure_exports(void);',
6572
+ 'extern void *_peach_objc_allocate_foreign(void *);',
6573
+ '@implementation NSObject',
6574
+ '+ (void)initialize { _peach_objc_ensure_exports(); }',
6575
+ '+ (instancetype)alloc { return (__bridge id)_peach_objc_allocate_foreign((__bridge void *)self); }',
6576
+ '+ (instancetype)new { return [[self alloc] init]; }',
6577
+ '- (instancetype)init { return self; }',
6578
+ '@end',
6579
+ 'extern void _peach_objc_export_root(void);',
6580
+ ...registrations.flatMap((text) =>
6581
+ [...text.matchAll(/(\w+)\(\);/g)].map(
6582
+ (match) => `extern void ${match[1]}(void);`,
6583
+ ),
6584
+ ),
6585
+ 'extern void _peach_objc_register_private_implementations(void);',
6586
+ 'void _peach_objc_register_all_exports(void) {',
6587
+ '_peach_objc_export_root();',
6588
+ ...registrations,
6589
+ '_peach_objc_register_private_implementations();',
6590
+ '}',
6591
+ '',
6592
+ ].join('\n'),
6593
+ )
6594
+ const headers = materializeObjcSdk(path.join(layout.root, '.build', 'peach-objc-sdk'))
6595
+ objcExports = {
6596
+ modules: objcModules,
6597
+ flags: [
6598
+ '-fobjc-runtime=gnustep-2.2',
6599
+ '-fobjc-exceptions',
6600
+ '-fexceptions',
6601
+ '-fwasm-exceptions',
6602
+ '-fobjc-arc',
6603
+ '-fblocks',
6604
+ '-F',
6605
+ path.join(headers, 'System/Library/Frameworks'),
6606
+ '-idirafter',
6607
+ path.join(headers, 'usr/include'),
6608
+ '-I',
6609
+ headerDirectory,
6610
+ ...[...objcModules].map(
6611
+ (name) =>
6612
+ `-fmodule-map-file=${path.join(headerModuleDirectory, name, 'module.modulemap')}`,
6613
+ ),
6614
+ ],
6615
+ }
6616
+ }
5854
6617
  if (targets.length === 0) {
5855
6618
  for (const [file, contents] of Object.entries(input.files)) {
5856
6619
  if (file === 'Package.swift') continue
@@ -5922,6 +6685,7 @@ export function writeSwiftProject(
5922
6685
  emitSwiftPackageManifest({
5923
6686
  targets,
5924
6687
  native,
6688
+ objcExports,
5925
6689
  headerDirectory: native.size > 0 ? headerDirectory : undefined,
5926
6690
  cxxLanguageStandard: swiftManifestCxxLanguageStandard(
5927
6691
  input.files['Package.swift'] ?? '',
@@ -5967,7 +6731,42 @@ export function writeSwiftProject(
5967
6731
  ].join('\n'),
5968
6732
  )
5969
6733
  }
6734
+ for (const [file, source] of compiled)
6735
+ if (!Object.hasOwn(input.files, file))
6736
+ files.set(path.join(layout.multi ? layout.root : layout.sources, file), source)
5970
6737
  syncSwiftTree(layout.root, files)
6738
+ const producers = [
6739
+ ...new Set([
6740
+ ...objcProducers,
6741
+ ...[...native.values()].flatMap((value) => value.late?.producers ?? []),
6742
+ ]),
6743
+ ]
6744
+ const dependencies = swiftTargetDependencies(input.files, targets)
6745
+ const included = new Set<string>()
6746
+ const include = (name: string): void => {
6747
+ if (included.has(name)) return
6748
+ included.add(name)
6749
+ for (const dependency of dependencies.get(name) ?? []) include(dependency)
6750
+ }
6751
+ for (const producer of producers)
6752
+ for (const dependency of dependencies.get(producer) ?? []) include(dependency)
6753
+ // building a producer also emits its dependency producers' headers.
6754
+ return {
6755
+ headerProducers: producers.filter((name) => !included.has(name)),
6756
+ ...(rootOwner && objcExports
6757
+ ? {
6758
+ objcImplementations: {
6759
+ owner: path.join(layout.root, rootOwner),
6760
+ registeredClasses: [...registeredClasses],
6761
+ units: [...native.values()].flatMap((value) =>
6762
+ value.sources
6763
+ .filter((file) => /\.mm?$/.test(file))
6764
+ .map((file) => path.join(layout.root, value.path, file)),
6765
+ ),
6766
+ },
6767
+ }
6768
+ : {}),
6769
+ }
5971
6770
  }
5972
6771
 
5973
6772
  function streamText(value: unknown): string {
@@ -6224,7 +7023,10 @@ export function compileSwiftProjectUnit(
6224
7023
  ],
6225
7024
  {
6226
7025
  cwd: repo,
6227
- timeout: options.timeoutMs,
7026
+ timeout:
7027
+ options.timeoutMs === undefined
7028
+ ? undefined
7029
+ : swiftBuilderHopTimeoutMs(options.timeoutMs),
6228
7030
  maxBuffer: 64 * 1024 * 1024,
6229
7031
  signal: options.signal,
6230
7032
  },
@@ -6260,7 +7062,7 @@ export function compileSwiftProjectUnit(
6260
7062
  report('reusing verified disk artifact')
6261
7063
  return retain(root, built)
6262
7064
  }
6263
- writeSwiftProject(layout, input, moduleRoot)
7065
+ const preparation = writeSwiftProject(layout, input, moduleRoot)
6264
7066
  const swift = path.join(options.toolchainBin, 'swift')
6265
7067
  if (!existsSync(swift)) {
6266
7068
  throw new Error(
@@ -6328,6 +7130,87 @@ export function compileSwiftProjectUnit(
6328
7130
  }
6329
7131
  report('compiling and linking Swift modules')
6330
7132
  try {
7133
+ // clang consumes the real emitted headers after swift finishes.
7134
+ // swiftpm's transitive swift module maps are not C declarations:
7135
+ // importing them would shadow SDK modules such as ObjectiveC.
7136
+ for (const producer of preparation.headerProducers) {
7137
+ await runCompiler(
7138
+ swift,
7139
+ [...buildArgs, '--target', producer],
7140
+ buildOptions,
7141
+ SWIFTPM_PROGRESS,
7142
+ SWIFTPM_NOISE,
7143
+ )
7144
+ }
7145
+ if (preparation.objcImplementations) {
7146
+ const plan = preparation.objcImplementations
7147
+ // the producer build writes the complete native build graph. use
7148
+ // its exact per-unit clang argv, including swiftpm's settings.
7149
+ const manifest: unknown = yaml.parse(
7150
+ readFileSync(path.join(root, '.build', 'release.yaml'), 'utf8'),
7151
+ )
7152
+ if (!isRecord(manifest) || !isRecord(manifest.commands))
7153
+ throw new Error('missing SwiftPM native compiler commands')
7154
+ const commands = new Map<string, string[]>()
7155
+ const selected = new Set(plan.units)
7156
+ for (const command of Object.values(manifest.commands)) {
7157
+ if (
7158
+ !isRecord(command) ||
7159
+ command.tool !== 'clang' ||
7160
+ !Array.isArray(command.inputs)
7161
+ )
7162
+ continue
7163
+ for (const file of command.inputs) {
7164
+ if (typeof file !== 'string' || !selected.has(file)) continue
7165
+ if (
7166
+ commands.has(file) ||
7167
+ !Array.isArray(command.args) ||
7168
+ !command.args.length ||
7169
+ !command.args.every((arg: unknown) => typeof arg === 'string')
7170
+ )
7171
+ throw new Error(`invalid SwiftPM compiler command for ${file}`)
7172
+ commands.set(file, command.args)
7173
+ }
7174
+ }
7175
+ async function* implementationASTs(): AsyncGenerator<string> {
7176
+ for (const file of plan.units) {
7177
+ const command = commands.get(file)
7178
+ if (!command)
7179
+ throw new Error(`missing SwiftPM compiler command for ${file}`)
7180
+ // change only the action and its output side effects. language,
7181
+ // SDK, defines, includes and original source identity stay exact.
7182
+ const args: string[] = []
7183
+ for (let index = 1; index < command.length; index++) {
7184
+ const arg = command[index]!
7185
+ if (
7186
+ ['-o', '-MF', '-MT', '-MQ', '-serialize-diagnostics'].includes(arg)
7187
+ )
7188
+ index++
7189
+ else if (!['-c', '-MD', '-MMD'].includes(arg)) args.push(arg)
7190
+ }
7191
+ try {
7192
+ yield await runCompiler(
7193
+ command[0]!,
7194
+ [...args, '-fsyntax-only', '-Xclang', '-ast-dump'],
7195
+ { ...buildOptions, cwd: root, maxBuffer: 256 * 1024 * 1024 },
7196
+ )
7197
+ } catch (error) {
7198
+ const diagnostic =
7199
+ error && typeof error === 'object'
7200
+ ? streamText(Reflect.get(error, 'stderr'))
7201
+ : ''
7202
+ throw new Error(
7203
+ `original Objective-C implementation AST failed for ${file}: ${diagnostic || String(error)}`,
7204
+ )
7205
+ }
7206
+ }
7207
+ }
7208
+ const adapter = await swiftObjCPrivateImports(
7209
+ implementationASTs(),
7210
+ plan.registeredClasses,
7211
+ )
7212
+ writeFileSync(plan.owner, readFileSync(plan.owner, 'utf8') + adapter)
7213
+ }
6331
7214
  await runCompiler(
6332
7215
  swift,
6333
7216
  buildArgs,