peachsim 0.1.1744 → 0.1.1801

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 (690) hide show
  1. package/README.md +28 -28
  2. package/cli/account-gate.ts +97 -0
  3. package/cli/app-catalog.ts +24 -0
  4. package/cli/app-stubs.ts +7 -0
  5. package/cli/auth.ts +48 -18
  6. package/cli/bin.ts +35 -2
  7. package/cli/bridge-flow-runner.ts +174 -6
  8. package/cli/cloud-dispatch.ts +0 -3
  9. package/cli/command-registry.ts +2 -6
  10. package/cli/commands/auth.ts +68 -3
  11. package/cli/commands/compat.ts +1116 -0
  12. package/cli/commands/control.ts +90 -13
  13. package/cli/commands/coverage.ts +85 -116
  14. package/cli/commands/detox.ts +20 -20
  15. package/cli/commands/device.ts +31 -27
  16. package/cli/commands/doctor.ts +76 -1032
  17. package/cli/commands/flow.ts +80 -41
  18. package/cli/commands/guest-host.ts +2 -2
  19. package/cli/commands/inspect/core.ts +8 -7
  20. package/cli/commands/inspect/settling.ts +60 -25
  21. package/cli/commands/inspect/wait-ready.ts +6 -4
  22. package/cli/commands/inspect/wait-selector.ts +32 -18
  23. package/cli/commands/inspect.ts +8 -6
  24. package/cli/commands/kotlin.ts +15 -6
  25. package/cli/commands/logout.ts +4 -2
  26. package/cli/commands/maestro-compare.ts +19 -37
  27. package/cli/commands/maestro-generate.ts +4 -4
  28. package/cli/commands/maestro.ts +56 -37
  29. package/cli/commands/package.ts +136 -57
  30. package/cli/commands/preview.ts +10 -1
  31. package/cli/commands/{film.ts → record-three.ts} +33 -28
  32. package/cli/commands/record.ts +41 -39
  33. package/cli/commands/screenshots.ts +4 -0
  34. package/cli/commands/setup.ts +38 -1
  35. package/cli/commands/shell-url.ts +49 -24
  36. package/cli/commands/swift.ts +29 -11
  37. package/cli/commands/test.ts +43 -13
  38. package/cli/commands/upload.ts +12 -9
  39. package/cli/drivers/playwright-core-pin.ts +2 -2
  40. package/cli/flow-export.ts +1 -1
  41. package/cli/flow-file.ts +1 -1
  42. package/cli/internal-child.ts +3 -8
  43. package/cli/maestro-compare.ts +73 -7
  44. package/cli/maestro-js.ts +1 -1
  45. package/cli/maestro-report.ts +1 -1
  46. package/cli/maestro-workspace.ts +66 -4
  47. package/cli/main.ts +22 -55
  48. package/cli/native-input.ts +13 -20
  49. package/cli/outbound-endpoints.ts +40 -7
  50. package/cli/output-redaction.ts +8 -3
  51. package/cli/packaged-app-launcher.ts +40 -28
  52. package/cli/prompt.ts +20 -0
  53. package/cli/recording-access.ts +7 -7
  54. package/cli/run-registry.ts +1 -1
  55. package/cli/scene-video.ts +0 -4
  56. package/cli/ws-bridge.ts +7 -4
  57. package/detox/index.ts +293 -50
  58. package/detox/jest-preset.cjs +6 -0
  59. package/detox/launch-permissions.ts +1 -21
  60. package/dist-lib/agent-daemon-client.cjs +1 -1
  61. package/dist-lib/agent-events.cjs +1 -1
  62. package/dist-lib/attached-projects.cjs +1 -1
  63. package/dist-lib/auth/shared-session.cjs +1 -1
  64. package/dist-lib/backend-origin.cjs +1 -1
  65. package/dist-lib/beta.cjs +1 -1
  66. package/dist-lib/beta.mjs +1 -1
  67. package/dist-lib/bridge-constants.cjs +1 -1
  68. package/dist-lib/bridge-contract-input.cjs +1 -1
  69. package/dist-lib/bridge-contract-input.mjs +1 -1
  70. package/dist-lib/bridge-contract.cjs +2 -8
  71. package/dist-lib/bridge-contract.mjs +2 -7
  72. package/dist-lib/bundle-channel.cjs +45273 -38265
  73. package/dist-lib/capture-contract.cjs +37 -14
  74. package/dist-lib/capture-contract.mjs +36 -13
  75. package/dist-lib/cloud-contract.cjs +1 -1
  76. package/dist-lib/cloud-contract.mjs +1 -1
  77. package/dist-lib/cloud-test-args.cjs +1 -1
  78. package/dist-lib/cloud-test-args.mjs +1 -1
  79. package/dist-lib/cloud.cjs +2 -2
  80. package/dist-lib/cloud.mjs +2 -2
  81. package/dist-lib/config.cjs +1 -1
  82. package/dist-lib/config.mjs +1 -1
  83. package/dist-lib/detox/index.cjs +562 -126
  84. package/dist-lib/detox/jest-preset.cjs +6 -0
  85. package/dist-lib/dev-bundle-resolution.cjs +18 -13
  86. package/dist-lib/expo-swift-bundle.cjs +28566 -23874
  87. package/dist-lib/expo-swift-metadata.cjs +104 -2
  88. package/dist-lib/expo-swift-metadata.mjs +104 -2
  89. package/dist-lib/home-paths.cjs +8 -5
  90. package/dist-lib/host/bridge-host.cjs +36618 -29846
  91. package/dist-lib/host/fetch-proxy-handler.cjs +23 -20
  92. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  93. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  94. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  95. package/dist-lib/host/websocket-proxy.cjs +5 -2
  96. package/dist-lib/index.cjs +1921 -1549
  97. package/dist-lib/jump-to-source-babel.cjs +1 -1
  98. package/dist-lib/jump-to-source-native.cjs +1 -1
  99. package/dist-lib/kotlin-host.cjs +1 -1
  100. package/dist-lib/menu.cjs +21 -7
  101. package/dist-lib/menu.mjs +21 -7
  102. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  103. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  104. package/dist-lib/metro-production-bundle.cjs +1 -1
  105. package/dist-lib/metro-production-bundle.mjs +1 -1
  106. package/dist-lib/metro.cjs +1877 -1584
  107. package/dist-lib/native-app-identity-project.cjs +1274 -951
  108. package/dist-lib/native-app-identity-project.mjs +1414 -963
  109. package/dist-lib/native-app-identity.cjs +64 -58
  110. package/dist-lib/native-app-identity.mjs +64 -58
  111. package/dist-lib/native-firebase-metadata.cjs +1 -1
  112. package/dist-lib/native-firebase-metadata.mjs +1 -1
  113. package/dist-lib/plist.cjs +1 -1
  114. package/dist-lib/plist.mjs +1 -1
  115. package/dist-lib/profiles.cjs +1 -1
  116. package/dist-lib/public-brand.cjs +1 -1
  117. package/dist-lib/public-origins-lib-esm.json +79 -33
  118. package/dist-lib/public-origins-lib-static.json +1 -1
  119. package/dist-lib/public-origins-lib.json +484 -280
  120. package/dist-lib/react-native-host-modules.cjs +3 -1
  121. package/dist-lib/react-native-host-modules.mjs +3 -1
  122. package/dist-lib/reap-browser.cjs +23 -26
  123. package/dist-lib/scripts/dev-server-scanner.cjs +13 -10
  124. package/dist-lib/sdk.cjs +69 -36
  125. package/dist-lib/sdk.mjs +69 -36
  126. package/dist-lib/skills.cjs +33781 -27141
  127. package/dist-lib/swift-compile.cjs +3759 -2520
  128. package/dist-lib/swift-compile.mjs +3680 -2441
  129. package/dist-lib/swift-package.cjs +33 -1
  130. package/dist-lib/swift-package.mjs +31 -1
  131. package/dist-lib/swift-submit.cjs +1 -1
  132. package/dist-lib/swift-submit.mjs +1 -1
  133. package/dist-lib/swift-toolchain.cjs +102 -5
  134. package/dist-lib/swift.cjs +1 -1
  135. package/dist-lib/vite-swift.cjs +16480 -14579
  136. package/dist-lib/vite.cjs +269 -295
  137. package/dist-lib/worklet-executable.cjs +1 -1
  138. package/dist-lib/worklet-executable.mjs +1 -1
  139. package/dist-types/packages/peach-compat/src/secure-item-store.d.ts +38 -0
  140. package/dist-types/packages/peach-compat/src/stubs/ring-mode-state.d.ts +4 -0
  141. package/dist-types/packages/peach-compat/src/stubs/screen-transition-math.d.ts +21 -12
  142. package/dist-types/packages/peach-engine/src/billing/plans.d.ts +1 -2
  143. package/dist-types/packages/peach-engine/src/capture/browser-composite-provider.d.ts +2 -0
  144. package/dist-types/packages/peach-engine/src/capture/browser-composite.d.ts +1 -1
  145. package/dist-types/packages/peach-engine/src/engine/animated-driven-style.d.ts +10 -10
  146. package/dist-types/packages/peach-engine/src/engine/animated.d.ts +1 -0
  147. package/dist-types/packages/peach-engine/src/engine/animation-graph.d.ts +6 -2
  148. package/dist-types/packages/peach-engine/src/engine/canvaskit-api.d.ts +1 -0
  149. package/dist-types/packages/peach-engine/src/engine/canvaskit-renderer.d.ts +3 -2
  150. package/dist-types/packages/peach-engine/src/engine/fiber-debug-metadata.d.ts +5 -0
  151. package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +3 -0
  152. package/dist-types/packages/peach-engine/src/engine/liquid-glass.d.ts +1 -0
  153. package/dist-types/packages/peach-engine/src/engine/lottie-runtime.d.ts +3 -0
  154. package/dist-types/packages/peach-engine/src/engine/native-animation-driver.d.ts +18 -1
  155. package/dist-types/packages/peach-engine/src/engine/native-layout.d.ts +1 -0
  156. package/dist-types/packages/peach-engine/src/engine/nativeReplayContract.d.ts +71 -0
  157. package/dist-types/packages/peach-engine/src/engine/node.d.ts +31 -3
  158. package/dist-types/packages/peach-engine/src/engine/paint-boundary-types.d.ts +0 -1
  159. package/dist-types/packages/peach-engine/src/engine/paint-boundary.d.ts +7 -2
  160. package/dist-types/packages/peach-engine/src/engine/portals.d.ts +2 -4
  161. package/dist-types/packages/peach-engine/src/engine/render-damage.d.ts +5 -0
  162. package/dist-types/packages/peach-engine/src/engine/scene-table.d.ts +7 -1
  163. package/dist-types/packages/peach-engine/src/engine/scroll-momentum-math.d.ts +3 -3
  164. package/dist-types/packages/peach-engine/src/engine/scroll-velocity.d.ts +1 -0
  165. package/dist-types/packages/peach-engine/src/engine/scroll.d.ts +10 -0
  166. package/dist-types/packages/peach-engine/src/engine/secureItemHostContract.d.ts +30 -0
  167. package/dist-types/packages/peach-engine/src/engine/shell-owned-values.d.ts +55 -0
  168. package/dist-types/packages/peach-engine/src/engine/text-first-baseline.d.ts +2 -1
  169. package/dist-types/packages/peach-engine/src/engine/types.d.ts +85 -26
  170. package/dist-types/packages/peach-engine/src/graphite-stats-fields.d.ts +28 -0
  171. package/dist-types/packages/peach-engine/src/ios/apps/canvas-map-data.d.ts +1 -0
  172. package/dist-types/packages/peach-engine/src/ios/aux-home-scene.d.ts +3 -4
  173. package/dist-types/packages/peach-engine/src/ios/aux-shell-animated-sources.d.ts +1 -1
  174. package/dist-types/packages/peach-engine/src/ios/home-app-catalog.d.ts +2 -0
  175. package/dist-types/packages/peach-engine/src/ios/photo-store.d.ts +2 -0
  176. package/dist-types/packages/peach-engine/src/ios/photoLibraryContract.d.ts +15 -0
  177. package/dist-types/packages/peach-engine/src/ios/shell-controller-types.d.ts +1 -0
  178. package/dist-types/packages/peach-engine/src/metro-asset-path.d.ts +2 -0
  179. package/dist-types/packages/peach-engine/src/react-native/platform-colors.d.ts +1 -0
  180. package/dist-types/packages/peach-engine/src/remote-stream/cloud-display.d.ts +2 -2
  181. package/dist-types/packages/peach-engine/src/render-worker/canvaskit-webgpu.d.ts +2 -0
  182. package/dist-types/packages/peach-engine/src/render-worker/canvaskit-worker-init.d.ts +1 -1
  183. package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +31 -12
  184. package/dist-types/packages/peach-engine/src/render-worker/compositor-runtime/scroll-drag-presentation.d.ts +23 -0
  185. package/dist-types/packages/peach-engine/src/render-worker/expo-widgetContract.d.ts +6 -0
  186. package/dist-types/packages/peach-engine/src/render-worker/expo-widgets-activityContract.d.ts +15 -0
  187. package/dist-types/packages/peach-engine/src/render-worker/graph-linked-value.d.ts +3 -1
  188. package/dist-types/packages/peach-engine/src/render-worker/host-service-protocol.d.ts +12 -2
  189. package/dist-types/packages/peach-engine/src/render-worker/image-pixel-contract.d.ts +12 -0
  190. package/dist-types/packages/peach-engine/src/render-worker/native-ui-protocol.d.ts +30 -0
  191. package/dist-types/packages/peach-engine/src/render-worker/native-widgetContract.d.ts +4 -1
  192. package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +15 -9
  193. package/dist-types/packages/peach-engine/src/render-worker/scroll-mirror-tenant.d.ts +3 -1
  194. package/dist-types/packages/peach-engine/src/render-worker/scroll-mirror.d.ts +24 -0
  195. package/dist-types/packages/peach-engine/src/render-worker/shell-protocol.d.ts +8 -4
  196. package/dist-types/packages/peach-engine/src/render-worker/shell-scene-schema.d.ts +4 -0
  197. package/dist-types/packages/peach-engine/src/render-worker/shell-tree-wire.d.ts +3 -2
  198. package/dist-types/packages/peach-engine/src/render-worker/text-inputContract.d.ts +1 -0
  199. package/dist-types/packages/peach-engine/src/render-worker/tree-sync-port.d.ts +1 -1
  200. package/dist-types/packages/peach-engine/src/render-worker/worker-input-runtime.d.ts +2 -0
  201. package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +10 -1
  202. package/dist-types/packages/peach-engine/src/render-worker/worklet-sab.d.ts +5 -0
  203. package/dist-types/packages/peach-engine/src/rolldown-production-module.d.ts +2 -1
  204. package/dist-types/packages/peach-engine/src/settings/devices.d.ts +4 -0
  205. package/dist-types/packages/peach-globals/src/eventBridgeContract.d.ts +1 -1
  206. package/dist-types/packages/peach-globals/src/lockstepCaptureBridgeContract.d.ts +7 -0
  207. package/dist-types/packages/peach-globals/src/nodeContract.d.ts +3 -1
  208. package/dist-types/packages/peach-globals/src/recordingBridgeContract.d.ts +5 -1
  209. package/dist-types/packages/peach-globals/src/shellBridgeContract.d.ts +2 -0
  210. package/dist-types/packages/peach-globals/src/testBridgeContract.d.ts +3 -1
  211. package/dist-types/packages/peach-kit/src/capabilities.d.ts +23 -1
  212. package/dist-types/packages/peach-kit/src/internal.d.ts +2 -1
  213. package/dist-types/packages/peach-kit/src/ui/hosting-safe-area.d.ts +2 -0
  214. package/dist-types/packages/peach-kit/src/ui/keyboard-toolbar.d.ts +5 -0
  215. package/install.sh +20 -1
  216. package/package.json +6 -5
  217. package/runtime-companion.json +1 -1
  218. package/sdk/ios/System/Library/Frameworks/AVFAudio.framework/Headers/AVAudioSession.h +629 -0
  219. package/sdk/ios/System/Library/Frameworks/AVFAudio.framework/Headers/AVAudioSessionDeprecated.h +90 -0
  220. package/sdk/ios/System/Library/Frameworks/AVFAudio.framework/Headers/AVAudioSessionRoute.h +256 -0
  221. package/sdk/ios/System/Library/Frameworks/AVFAudio.framework/Headers/AVAudioSessionTypes.h +1006 -0
  222. package/sdk/ios/System/Library/Frameworks/AVFAudio.framework/Headers/AVFAudio.apinotes +246 -0
  223. package/sdk/ios/System/Library/Frameworks/AVFAudio.framework/Headers/AVFAudio.h +5 -0
  224. package/sdk/ios/System/Library/Frameworks/AVFAudio.framework/Modules/module.modulemap +5 -0
  225. package/sdk/ios/System/Library/Frameworks/AVFoundation.framework/Headers/AVAnimation.h +52 -0
  226. package/sdk/ios/System/Library/Frameworks/AVFoundation.framework/Headers/AVAudioSession.h +11 -0
  227. package/sdk/ios/System/Library/Frameworks/AVFoundation.framework/Headers/AVBase.h +264 -0
  228. package/sdk/ios/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureDevice.h +88 -0
  229. package/sdk/ios/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureSession.h +1360 -0
  230. package/sdk/ios/System/Library/Frameworks/AVFoundation.framework/Headers/AVCaptureSessionPreset.h +167 -0
  231. package/sdk/ios/System/Library/Frameworks/AVFoundation.framework/Headers/AVFoundation.h +13 -0
  232. package/sdk/ios/System/Library/Frameworks/AVFoundation.framework/Headers/AVMediaFormat.h +508 -0
  233. package/sdk/ios/System/Library/Frameworks/AVFoundation.framework/Headers/AVMetadataItem.h +1 -1
  234. package/sdk/ios/System/Library/Frameworks/AVFoundation.framework/Headers/AVPlayerItem.h +31 -0
  235. package/sdk/ios/System/Library/Frameworks/AVFoundation.framework/Headers/AVSampleBufferDisplayLayer.h +18 -0
  236. package/sdk/ios/System/Library/Frameworks/AVKit.framework/Headers/AVCaptureDeviceDirectionCoordinator.h +113 -0
  237. package/sdk/ios/System/Library/Frameworks/AVKit.framework/Headers/AVCaptureEvent.h +82 -0
  238. package/sdk/ios/System/Library/Frameworks/AVKit.framework/Headers/AVCaptureEventInteraction.h +114 -0
  239. package/sdk/ios/System/Library/Frameworks/AVKit.framework/Headers/AVCaptureEventSound.h +50 -0
  240. package/sdk/ios/System/Library/Frameworks/AVKit.framework/Headers/AVError.h +51 -0
  241. package/sdk/ios/System/Library/Frameworks/AVKit.framework/Headers/AVInputPickerInteraction.h +93 -0
  242. package/sdk/ios/System/Library/Frameworks/AVKit.framework/Headers/AVInterstitialTimeRange.h +39 -0
  243. package/sdk/ios/System/Library/Frameworks/AVKit.framework/Headers/AVKit.apinotes +112 -0
  244. package/sdk/ios/System/Library/Frameworks/AVKit.framework/Headers/AVKit.h +110 -0
  245. package/sdk/ios/System/Library/Frameworks/AVKit.framework/Headers/AVKitDefines.h +79 -0
  246. package/sdk/ios/System/Library/Frameworks/AVKit.framework/Headers/AVKitTypes.h +54 -0
  247. package/sdk/ios/System/Library/Frameworks/AVKit.framework/Headers/AVLegibleMediaOptionsMenuController.h +193 -0
  248. package/sdk/ios/System/Library/Frameworks/AVKit.framework/Headers/AVPictureInPictureController.h +271 -0
  249. package/sdk/ios/System/Library/Frameworks/AVKit.framework/Headers/AVPictureInPictureController_AVSampleBufferDisplayLayerSupport.h +135 -0
  250. package/sdk/ios/System/Library/Frameworks/AVKit.framework/Headers/AVPictureInPictureController_VideoCallSupport.h +66 -0
  251. package/sdk/ios/System/Library/Frameworks/AVKit.framework/Headers/AVPlaybackRouteSelecting.h +46 -0
  252. package/sdk/ios/System/Library/Frameworks/AVKit.framework/Headers/AVPlaybackSpeed.h +71 -0
  253. package/sdk/ios/System/Library/Frameworks/AVKit.framework/Headers/AVPlaybackUserInterfaceControllable.h +551 -0
  254. package/sdk/ios/System/Library/Frameworks/AVKit.framework/Headers/AVPlayerItem+AVKitAdditions.h +42 -0
  255. package/sdk/ios/System/Library/Frameworks/AVKit.framework/Headers/AVPlayerViewController.h +704 -0
  256. package/sdk/ios/System/Library/Frameworks/AVKit.framework/Headers/AVRoutePickerView.h +186 -0
  257. package/sdk/ios/System/Library/Frameworks/AVKit.framework/Modules/module.modulemap +5 -0
  258. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccount.h +1 -1
  259. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountCredential.h +1 -1
  260. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountStore.h +1 -1
  261. package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountType.h +1 -1
  262. package/sdk/ios/System/Library/Frameworks/CoreAudioTypes.framework/Headers/AudioSessionTypes.h +104 -0
  263. package/sdk/ios/System/Library/Frameworks/CoreAudioTypes.framework/Headers/CoreAudioBaseTypes.h +1621 -0
  264. package/sdk/ios/System/Library/Frameworks/CoreAudioTypes.framework/Headers/CoreAudioTypes.apinotes +42 -0
  265. package/sdk/ios/System/Library/Frameworks/CoreAudioTypes.framework/Headers/CoreAudioTypes.h +9 -0
  266. package/sdk/ios/System/Library/Frameworks/CoreAudioTypes.framework/Modules/module.modulemap +6 -0
  267. package/sdk/ios/System/Library/Frameworks/CoreBluetooth.framework/Headers/CBAttribute.h +1 -1
  268. package/sdk/ios/System/Library/Frameworks/CoreBluetooth.framework/Headers/CBCentralManager.h +1 -1
  269. package/sdk/ios/System/Library/Frameworks/CoreBluetooth.framework/Headers/CBCharacteristic.h +1 -1
  270. package/sdk/ios/System/Library/Frameworks/CoreBluetooth.framework/Headers/CBDescriptor.h +1 -1
  271. package/sdk/ios/System/Library/Frameworks/CoreBluetooth.framework/Headers/CBManager.h +1 -1
  272. package/sdk/ios/System/Library/Frameworks/CoreBluetooth.framework/Headers/CBPeer.h +1 -1
  273. package/sdk/ios/System/Library/Frameworks/CoreBluetooth.framework/Headers/CBPeripheral.h +1 -1
  274. package/sdk/ios/System/Library/Frameworks/CoreBluetooth.framework/Headers/CBService.h +1 -1
  275. package/sdk/ios/System/Library/Frameworks/CoreBluetooth.framework/Headers/CBUUID.h +1 -1
  276. package/sdk/ios/System/Library/Frameworks/CoreData.framework/Headers/NSFetchRequest.h +1 -1
  277. package/sdk/ios/System/Library/Frameworks/CoreData.framework/Headers/NSManagedObjectID.h +1 -1
  278. package/sdk/ios/System/Library/Frameworks/CoreData.framework/Headers/NSManagedObjectModel.h +1 -1
  279. package/sdk/ios/System/Library/Frameworks/CoreData.framework/Headers/NSPersistentStoreCoordinator.h +1 -1
  280. package/sdk/ios/System/Library/Frameworks/CoreData.framework/Headers/NSPersistentStoreRequest.h +1 -1
  281. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFRunLoop.h +195 -0
  282. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFSocket.h +220 -0
  283. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFStream.h +501 -0
  284. package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h +3 -18
  285. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLBeaconIdentityConstraint.h +1 -1
  286. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLBeaconRegion.h +2 -2
  287. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLCircularRegion.h +1 -1
  288. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLGeocoder.h +2 -2
  289. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLHeading.h +1 -1
  290. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocationManager+CLVisitExtensions.h +1 -1
  291. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocationManager.h +1 -1
  292. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLPlacemark.h +2 -2
  293. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLRegion.h +1 -1
  294. package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLVisit.h +1 -1
  295. package/sdk/ios/System/Library/Frameworks/CoreMedia.framework/Headers/CMBase.h +443 -0
  296. package/sdk/ios/System/Library/Frameworks/CoreMedia.framework/Headers/CMFormatDescription.h +8 -0
  297. package/sdk/ios/System/Library/Frameworks/CoreMedia.framework/Headers/CMSync.h +996 -0
  298. package/sdk/ios/System/Library/Frameworks/CoreMedia.framework/Headers/CMTime.h +9 -0
  299. package/sdk/ios/System/Library/Frameworks/CoreMedia.framework/Headers/CoreMedia.h +3 -0
  300. package/sdk/ios/System/Library/Frameworks/CoreNFC.framework/Headers/NFCNDEFMessage.h +1 -1
  301. package/sdk/ios/System/Library/Frameworks/CoreNFC.framework/Headers/NFCNDEFPayload.h +2 -2
  302. package/sdk/ios/System/Library/Frameworks/CoreNFC.framework/Headers/NFCNDEFReaderSession.h +1 -1
  303. package/sdk/ios/System/Library/Frameworks/CoreNFC.framework/Headers/NFCReaderSession.h +1 -1
  304. package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTCellularData.h +1 -1
  305. package/sdk/ios/System/Library/Frameworks/CoreTelephony.framework/Headers/CTTelephonyNetworkInfo.h +1 -1
  306. package/sdk/ios/System/Library/Frameworks/CoreText.framework/Headers/CTFont.h +1811 -0
  307. package/sdk/ios/System/Library/Frameworks/CoreText.framework/Headers/CTFontCollection.h +360 -0
  308. package/sdk/ios/System/Library/Frameworks/CoreText.framework/Headers/CTFontManager.h +574 -17
  309. package/sdk/ios/System/Library/Frameworks/CoreText.framework/Headers/CTFontManagerErrors.h +109 -0
  310. package/sdk/ios/System/Library/Frameworks/CoreText.framework/Headers/CTFrame.h +336 -0
  311. package/sdk/ios/System/Library/Frameworks/CoreText.framework/Headers/CTFramesetter.h +203 -0
  312. package/sdk/ios/System/Library/Frameworks/CoreText.framework/Headers/CTGlyphInfo.h +264 -0
  313. package/sdk/ios/System/Library/Frameworks/CoreText.framework/Headers/CTLine.h +531 -0
  314. package/sdk/ios/System/Library/Frameworks/CoreText.framework/Headers/CTParagraphStyle.h +496 -0
  315. package/sdk/ios/System/Library/Frameworks/CoreText.framework/Headers/CTRubyAnnotation.h +326 -0
  316. package/sdk/ios/System/Library/Frameworks/CoreText.framework/Headers/CTRun.h +547 -0
  317. package/sdk/ios/System/Library/Frameworks/CoreText.framework/Headers/CTRunDelegate.h +213 -0
  318. package/sdk/ios/System/Library/Frameworks/CoreText.framework/Headers/CTStringAttributes.h +496 -0
  319. package/sdk/ios/System/Library/Frameworks/CoreText.framework/Headers/CTTextTab.h +158 -0
  320. package/sdk/ios/System/Library/Frameworks/CoreText.framework/Headers/CTTypesetter.h +286 -0
  321. package/sdk/ios/System/Library/Frameworks/CoreText.framework/Headers/CoreText.h +80 -1
  322. package/sdk/ios/System/Library/Frameworks/CoreText.framework/Headers/SFNTLayoutTypes.h +1833 -0
  323. package/sdk/ios/System/Library/Frameworks/CoreText.framework/Headers/SFNTTypes.h +482 -0
  324. package/sdk/ios/System/Library/Frameworks/DeviceDiscoveryUI.framework/Headers/DDDevicePickerViewController.h +41 -0
  325. package/sdk/ios/System/Library/Frameworks/DeviceDiscoveryUI.framework/Headers/DeviceDiscoveryUI.h +9 -0
  326. package/sdk/ios/System/Library/Frameworks/DeviceDiscoveryUI.framework/Headers/DeviceDiscoveryUIDefines.h +14 -0
  327. package/sdk/ios/System/Library/Frameworks/DeviceDiscoveryUI.framework/Modules/DeviceDiscoveryUI.swiftcrossimport/SwiftUI.swiftoverlay +4 -0
  328. package/sdk/ios/System/Library/Frameworks/DeviceDiscoveryUI.framework/Modules/module.modulemap +9 -0
  329. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes +1 -1
  330. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h +49 -1
  331. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h +2 -0
  332. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSRegularExpression.h +15 -0
  333. package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/NSUbiquitousKeyValueStore.h +30 -0
  334. package/sdk/ios/System/Library/Frameworks/GameKit.framework/Headers/GKAchievement.h +3 -3
  335. package/sdk/ios/System/Library/Frameworks/GameKit.framework/Headers/GKBasePlayer.h +1 -1
  336. package/sdk/ios/System/Library/Frameworks/GameKit.framework/Headers/GKChallenge.h +6 -6
  337. package/sdk/ios/System/Library/Frameworks/GameKit.framework/Headers/GKGameCenterViewController.h +4 -4
  338. package/sdk/ios/System/Library/Frameworks/GameKit.framework/Headers/GKLocalPlayer.h +6 -6
  339. package/sdk/ios/System/Library/Frameworks/GameKit.framework/Headers/GKMatchmaker.h +2 -2
  340. package/sdk/ios/System/Library/Frameworks/GameKit.framework/Headers/GKNotificationBanner.h +1 -1
  341. package/sdk/ios/System/Library/Frameworks/GameKit.framework/Headers/GKPlayer.h +3 -3
  342. package/sdk/ios/System/Library/Frameworks/GameKit.framework/Headers/GKSavedGame.h +2 -2
  343. package/sdk/ios/System/Library/Frameworks/GameKit.framework/Headers/GKTurnBasedMatch.h +4 -4
  344. package/sdk/ios/System/Library/Frameworks/GameKit.framework/Headers/GKTurnBasedMatchmakerViewController.h +3 -3
  345. package/sdk/ios/System/Library/Frameworks/HealthKit.framework/Headers/HKActivitySummary.h +1 -1
  346. package/sdk/ios/System/Library/Frameworks/HealthKit.framework/Headers/HKActivitySummaryQuery.h +1 -1
  347. package/sdk/ios/System/Library/Frameworks/HealthKit.framework/Headers/HKCategorySample.h +1 -1
  348. package/sdk/ios/System/Library/Frameworks/HealthKit.framework/Headers/HKClinicalType.h +1 -1
  349. package/sdk/ios/System/Library/Frameworks/HealthKit.framework/Headers/HKHealthStore.h +6 -6
  350. package/sdk/ios/System/Library/Frameworks/HealthKit.framework/Headers/HKObject.h +1 -1
  351. package/sdk/ios/System/Library/Frameworks/HealthKit.framework/Headers/HKObjectType.h +5 -5
  352. package/sdk/ios/System/Library/Frameworks/HealthKit.framework/Headers/HKObserverQuery.h +1 -1
  353. package/sdk/ios/System/Library/Frameworks/HealthKit.framework/Headers/HKQuantity.h +1 -1
  354. package/sdk/ios/System/Library/Frameworks/HealthKit.framework/Headers/HKQuantitySample.h +1 -1
  355. package/sdk/ios/System/Library/Frameworks/HealthKit.framework/Headers/HKQuery.h +14 -14
  356. package/sdk/ios/System/Library/Frameworks/HealthKit.framework/Headers/HKSample.h +1 -1
  357. package/sdk/ios/System/Library/Frameworks/HealthKit.framework/Headers/HKSampleQuery.h +1 -1
  358. package/sdk/ios/System/Library/Frameworks/HealthKit.framework/Headers/HKStatistics.h +1 -1
  359. package/sdk/ios/System/Library/Frameworks/HealthKit.framework/Headers/HKStatisticsQuery.h +1 -1
  360. package/sdk/ios/System/Library/Frameworks/HealthKit.framework/Headers/HKUnit.h +20 -20
  361. package/sdk/ios/System/Library/Frameworks/IOSurface.framework/Headers/IOSurfaceObjC.h +1 -1
  362. package/sdk/ios/System/Library/Frameworks/ImageIO.framework/Headers/CGImageAnimation.h +2 -0
  363. package/sdk/ios/System/Library/Frameworks/ImageIO.framework/Headers/CGImageDestination.h +2 -0
  364. package/sdk/ios/System/Library/Frameworks/ImageIO.framework/Headers/CGImageMetadata.h +2 -0
  365. package/sdk/ios/System/Library/Frameworks/ImageIO.framework/Headers/CGImageProperties.h +2 -0
  366. package/sdk/ios/System/Library/Frameworks/ImageIO.framework/Headers/CGImageSource.h +2 -0
  367. package/sdk/ios/System/Library/Frameworks/ImageIO.framework/Headers/ImageIOBase.h +6 -0
  368. package/sdk/ios/System/Library/Frameworks/JavaScriptCore.framework/Headers/JSBase.h +195 -0
  369. package/sdk/ios/System/Library/Frameworks/JavaScriptCore.framework/Headers/JSContext.h +245 -0
  370. package/sdk/ios/System/Library/Frameworks/JavaScriptCore.framework/Headers/JSContextRef.h +178 -0
  371. package/sdk/ios/System/Library/Frameworks/JavaScriptCore.framework/Headers/JSExport.h +151 -0
  372. package/sdk/ios/System/Library/Frameworks/JavaScriptCore.framework/Headers/JSManagedValue.h +81 -0
  373. package/sdk/ios/System/Library/Frameworks/JavaScriptCore.framework/Headers/JSObjectRef.h +755 -0
  374. package/sdk/ios/System/Library/Frameworks/JavaScriptCore.framework/Headers/JSStringRef.h +148 -0
  375. package/sdk/ios/System/Library/Frameworks/JavaScriptCore.framework/Headers/JSStringRefCF.h +60 -0
  376. package/sdk/ios/System/Library/Frameworks/JavaScriptCore.framework/Headers/JSTypedArray.h +180 -0
  377. package/sdk/ios/System/Library/Frameworks/JavaScriptCore.framework/Headers/JSValue.h +824 -0
  378. package/sdk/ios/System/Library/Frameworks/JavaScriptCore.framework/Headers/JSValueRef.h +555 -0
  379. package/sdk/ios/System/Library/Frameworks/JavaScriptCore.framework/Headers/JSVirtualMachine.h +92 -0
  380. package/sdk/ios/System/Library/Frameworks/JavaScriptCore.framework/Headers/JavaScript.h +37 -0
  381. package/sdk/ios/System/Library/Frameworks/JavaScriptCore.framework/Headers/JavaScriptCore.h +38 -0
  382. package/sdk/ios/System/Library/Frameworks/JavaScriptCore.framework/Headers/WebKitAvailability.h +36 -0
  383. package/sdk/ios/System/Library/Frameworks/JavaScriptCore.framework/Modules/module.modulemap +8 -0
  384. package/sdk/ios/System/Library/Frameworks/MobileCoreServices.framework/Headers/UTType.h +19 -0
  385. package/sdk/ios/System/Library/Frameworks/MultipeerConnectivity.framework/Headers/MCAdvertiserAssistant.h +76 -0
  386. package/sdk/ios/System/Library/Frameworks/MultipeerConnectivity.framework/Headers/MCBrowserViewController.h +88 -0
  387. package/sdk/ios/System/Library/Frameworks/MultipeerConnectivity.framework/Headers/MCError.h +34 -0
  388. package/sdk/ios/System/Library/Frameworks/MultipeerConnectivity.framework/Headers/MCNearbyServiceAdvertiser.h +84 -0
  389. package/sdk/ios/System/Library/Frameworks/MultipeerConnectivity.framework/Headers/MCNearbyServiceBrowser.h +94 -0
  390. package/sdk/ios/System/Library/Frameworks/MultipeerConnectivity.framework/Headers/MCPeerID.h +37 -0
  391. package/sdk/ios/System/Library/Frameworks/MultipeerConnectivity.framework/Headers/MCSession.h +215 -0
  392. package/sdk/ios/System/Library/Frameworks/MultipeerConnectivity.framework/Headers/MultipeerConnectivity.apinotes +5 -0
  393. package/sdk/ios/System/Library/Frameworks/MultipeerConnectivity.framework/Headers/MultipeerConnectivity.h +15 -0
  394. package/sdk/ios/System/Library/Frameworks/MultipeerConnectivity.framework/Modules/module.modulemap +7 -0
  395. package/sdk/ios/System/Library/Frameworks/NetworkExtension.framework/Headers/NEHotspotHelper.h +1 -1
  396. package/sdk/ios/System/Library/Frameworks/NetworkExtension.framework/Headers/NEHotspotNetwork.h +1 -1
  397. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAEmitterCell.h +1 -1
  398. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAEmitterLayer.h +1 -1
  399. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAGradientLayer.h +1 -1
  400. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAReplicatorLayer.h +1 -1
  401. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAScrollLayer.h +1 -1
  402. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAShapeLayer.h +1 -1
  403. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CATextLayer.h +1 -1
  404. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CATiledLayer.h +1 -1
  405. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CATransformLayer.h +1 -1
  406. package/sdk/ios/System/Library/Frameworks/QuartzCore.framework/Headers/CAValueFunction.h +1 -1
  407. package/sdk/ios/System/Library/Frameworks/SafariServices.framework/Headers/SFSafariViewController.h +1 -1
  408. package/sdk/ios/System/Library/Frameworks/SceneKit.framework/Headers/ModelIO.h +6 -6
  409. package/sdk/ios/System/Library/Frameworks/SceneKit.framework/Headers/SCNAction.h +1 -1
  410. package/sdk/ios/System/Library/Frameworks/SceneKit.framework/Headers/SCNAudioSource.h +1 -1
  411. package/sdk/ios/System/Library/Frameworks/SceneKit.framework/Headers/SCNCamera.h +1 -1
  412. package/sdk/ios/System/Library/Frameworks/SceneKit.framework/Headers/SCNConstraint.h +2 -2
  413. package/sdk/ios/System/Library/Frameworks/SceneKit.framework/Headers/SCNGeometry.h +1 -1
  414. package/sdk/ios/System/Library/Frameworks/SceneKit.framework/Headers/SCNHitTest.h +2 -2
  415. package/sdk/ios/System/Library/Frameworks/SceneKit.framework/Headers/SCNLight.h +1 -1
  416. package/sdk/ios/System/Library/Frameworks/SceneKit.framework/Headers/SCNMaterial.h +1 -1
  417. package/sdk/ios/System/Library/Frameworks/SceneKit.framework/Headers/SCNMaterialProperty.h +1 -1
  418. package/sdk/ios/System/Library/Frameworks/SceneKit.framework/Headers/SCNNode.h +4 -4
  419. package/sdk/ios/System/Library/Frameworks/SceneKit.framework/Headers/SCNParametricGeometry.h +1 -1
  420. package/sdk/ios/System/Library/Frameworks/SceneKit.framework/Headers/SCNParticleSystem.h +2 -2
  421. package/sdk/ios/System/Library/Frameworks/SceneKit.framework/Headers/SCNScene.h +1 -1
  422. package/sdk/ios/System/Library/Frameworks/SceneKit.framework/Headers/SCNTransaction.h +1 -1
  423. package/sdk/ios/System/Library/Frameworks/SceneKit.framework/Headers/SCNView.h +1 -1
  424. package/sdk/ios/System/Library/Frameworks/SceneKit.framework/Headers/SceneKitDeprecated.h +3 -3
  425. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/NSLayoutManager.h +14 -0
  426. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/NSParagraphStyle.h +172 -27
  427. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/NSText.h +59 -0
  428. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/NSTextContainer.h +13 -0
  429. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/NSTextList.h +63 -0
  430. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/NSTextStorage.h +10 -0
  431. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/NSToolbar+UIKitAdditions.h +142 -0
  432. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIAccessibilityConstants.h +20 -20
  433. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIAction.h +103 -0
  434. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h +6 -0
  435. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UICommand.h +131 -0
  436. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIEvent.h +8 -3
  437. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIFont.h +80 -0
  438. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIFontDescriptor.h +191 -0
  439. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIGeometry.h +259 -0
  440. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIGestureRecognizer.h +9 -3
  441. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIGestureRecognizerSubclass.h +5 -3
  442. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIHoverGestureRecognizer.h +6 -3
  443. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIInteraction.h +37 -0
  444. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIKit.apinotes +4248 -0
  445. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h +66 -102
  446. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIKitDefines.h +55 -0
  447. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UILayoutGuide.h +62 -0
  448. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIMenu.h +283 -0
  449. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIMenuDisplayPreferences.h +27 -0
  450. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIMenuElement.h +86 -0
  451. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIMenuLeaf.h +68 -0
  452. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UITouch.h +1 -0
  453. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UITraitCollection.h +2 -2
  454. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIView.h +3 -0
  455. package/sdk/ios/System/Library/Frameworks/UIKit.framework/Modules/module.modulemap +2 -0
  456. package/sdk/ios/System/Library/Frameworks/UIKitText.framework/Headers/UIKitText.apinotes +135 -0
  457. package/sdk/ios/System/Library/Frameworks/UIKitText.framework/Modules/module.modulemap +8 -0
  458. package/sdk/ios/System/Library/Frameworks/UniformTypeIdentifiers.framework/Headers/UTAdditions.h +167 -0
  459. package/sdk/ios/System/Library/Frameworks/UniformTypeIdentifiers.framework/Headers/UTCoreTypes.h +1332 -0
  460. package/sdk/ios/System/Library/Frameworks/UniformTypeIdentifiers.framework/Headers/UniformTypeIdentifiers.apinotes +53 -0
  461. package/sdk/ios/System/Library/Frameworks/UniformTypeIdentifiers.framework/Headers/UniformTypeIdentifiers.h +18 -0
  462. package/sdk/ios/System/Library/Frameworks/UniformTypeIdentifiers.framework/Modules/module.modulemap +6 -0
  463. package/sdk/ios/System/Library/Frameworks/UserNotifications.framework/Headers/NSString+UserNotifications.h +19 -0
  464. package/sdk/ios/System/Library/Frameworks/UserNotifications.framework/Headers/UNError.h +29 -0
  465. package/sdk/ios/System/Library/Frameworks/UserNotifications.framework/Headers/UNNotification.h +27 -0
  466. package/sdk/ios/System/Library/Frameworks/UserNotifications.framework/Headers/UNNotificationAction.h +69 -0
  467. package/sdk/ios/System/Library/Frameworks/UserNotifications.framework/Headers/UNNotificationActionIcon.h +23 -0
  468. package/sdk/ios/System/Library/Frameworks/UserNotifications.framework/Headers/UNNotificationAttachment.h +44 -0
  469. package/sdk/ios/System/Library/Frameworks/UserNotifications.framework/Headers/UNNotificationAttributedMessageContext.h +24 -0
  470. package/sdk/ios/System/Library/Frameworks/UserNotifications.framework/Headers/UNNotificationCategory.h +82 -0
  471. package/sdk/ios/System/Library/Frameworks/UserNotifications.framework/Headers/UNNotificationContent.h +152 -0
  472. package/sdk/ios/System/Library/Frameworks/UserNotifications.framework/Headers/UNNotificationRequest.h +34 -0
  473. package/sdk/ios/System/Library/Frameworks/UserNotifications.framework/Headers/UNNotificationResponse.h +41 -0
  474. package/sdk/ios/System/Library/Frameworks/UserNotifications.framework/Headers/UNNotificationServiceExtension.h +27 -0
  475. package/sdk/ios/System/Library/Frameworks/UserNotifications.framework/Headers/UNNotificationSettings.h +90 -0
  476. package/sdk/ios/System/Library/Frameworks/UserNotifications.framework/Headers/UNNotificationSound.h +45 -0
  477. package/sdk/ios/System/Library/Frameworks/UserNotifications.framework/Headers/UNNotificationTrigger.h +64 -0
  478. package/sdk/ios/System/Library/Frameworks/UserNotifications.framework/Headers/UNUserNotificationCenter.h +107 -0
  479. package/sdk/ios/System/Library/Frameworks/UserNotifications.framework/Headers/UserNotifications.apinotes +17 -0
  480. package/sdk/ios/System/Library/Frameworks/UserNotifications.framework/Headers/UserNotifications.h +23 -0
  481. package/sdk/ios/System/Library/Frameworks/UserNotifications.framework/Modules/module.modulemap +6 -0
  482. package/sdk/ios/System/Library/Frameworks/WatchConnectivity.framework/Headers/WCDefines.h +14 -0
  483. package/sdk/ios/System/Library/Frameworks/WatchConnectivity.framework/Headers/WCError.h +38 -0
  484. package/sdk/ios/System/Library/Frameworks/WatchConnectivity.framework/Headers/WCSession.h +200 -0
  485. package/sdk/ios/System/Library/Frameworks/WatchConnectivity.framework/Headers/WCSessionFile.h +30 -0
  486. package/sdk/ios/System/Library/Frameworks/WatchConnectivity.framework/Headers/WCSessionUserInfoTransfer.h +22 -0
  487. package/sdk/ios/System/Library/Frameworks/WatchConnectivity.framework/Headers/WatchConnectivity.apinotes +19 -0
  488. package/sdk/ios/System/Library/Frameworks/WatchConnectivity.framework/Headers/WatchConnectivity.h +15 -0
  489. package/sdk/ios/System/Library/Frameworks/WatchConnectivity.framework/Modules/module.modulemap +5 -0
  490. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/NSAttributedString.h +120 -0
  491. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKBackForwardList.h +77 -0
  492. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKBackForwardListItem.h +54 -0
  493. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKContentRuleList.h +37 -0
  494. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKContentRuleListStore.h +47 -0
  495. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKContentWorld.h +87 -0
  496. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKContentWorldConfiguration.h +71 -0
  497. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKContextMenuElementInfo.h +47 -0
  498. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKDOMNodeSnapshot.h +57 -0
  499. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKDataDetectorTypes.h +60 -0
  500. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKDownload.h +67 -0
  501. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKDownloadDelegate.h +146 -0
  502. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKError.h +71 -0
  503. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKFindConfiguration.h +52 -0
  504. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKFindResult.h +41 -0
  505. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKFormInfo.h +63 -0
  506. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKFoundation.h +72 -0
  507. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKFrameInfo.h +62 -0
  508. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKHTTPCookieStore.h +108 -0
  509. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKImmersiveEnvironment.h +50 -0
  510. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKImmersiveEnvironmentDelegate.h +69 -0
  511. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKJSHandle.h +80 -0
  512. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKNavigation.h +45 -0
  513. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKNavigationAction.h +118 -0
  514. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKNavigationDelegate.h +219 -0
  515. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKNavigationResponse.h +60 -0
  516. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKOpenPanelParameters.h +47 -0
  517. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKPDFConfiguration.h +49 -0
  518. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKPreferences.h +117 -0
  519. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKPreviewActionItem.h +39 -0
  520. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKPreviewActionItemIdentifiers.h +38 -0
  521. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKPreviewElementInfo.h +43 -0
  522. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKProcessPool.h +39 -0
  523. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKScriptMessage.h +64 -0
  524. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKScriptMessageHandler.h +52 -0
  525. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKScriptMessageHandlerWithReply.h +95 -0
  526. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKSecurityOrigin.h +57 -0
  527. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKSnapshotConfiguration.h +59 -0
  528. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKUIDelegate.h +316 -0
  529. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKURLSchemeHandler.h +61 -0
  530. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKURLSchemeTask.h +75 -0
  531. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKUserContentController.h +162 -0
  532. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKUserScript.h +76 -0
  533. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKWebExtension.h +237 -0
  534. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKWebExtensionAction.h +164 -0
  535. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKWebExtensionCommand.h +106 -0
  536. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKWebExtensionContext.h +790 -0
  537. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKWebExtensionController.h +255 -0
  538. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKWebExtensionControllerConfiguration.h +89 -0
  539. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKWebExtensionControllerDelegate.h +207 -0
  540. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKWebExtensionDataRecord.h +90 -0
  541. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKWebExtensionDataType.h +43 -0
  542. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKWebExtensionMatchPattern.h +175 -0
  543. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKWebExtensionMessagePort.h +99 -0
  544. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKWebExtensionPermission.h +95 -0
  545. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKWebExtensionTab.h +396 -0
  546. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKWebExtensionTabConfiguration.h +94 -0
  547. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKWebExtensionWindow.h +170 -0
  548. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKWebExtensionWindowConfiguration.h +87 -0
  549. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKWebView.h +800 -0
  550. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKWebViewConfiguration.h +275 -0
  551. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKWebpagePreferences.h +150 -0
  552. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKWebsiteDataRecord.h +90 -0
  553. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKWebsiteDataStore.h +137 -0
  554. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WKWindowFeatures.h +72 -0
  555. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WebKit.apinotes +204 -0
  556. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WebKit.h +93 -0
  557. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Headers/WebKitLegacy.h +3 -0
  558. package/sdk/ios/System/Library/Frameworks/WebKit.framework/Modules/module.modulemap +5 -0
  559. package/sdk/ios/System/Library/Frameworks/WiFiAware.framework/Modules/WiFiAware.swiftmodule/arm64-apple-ios-simulator.swiftinterface +605 -0
  560. package/sdk/ios/System/Library/Frameworks/_DeviceDiscoveryUI_SwiftUI.framework/Modules/_DeviceDiscoveryUI_SwiftUI.swiftmodule/arm64-apple-ios-simulator.swiftinterface +79 -0
  561. package/sdk/ios/usr/include/MacTypes.h +8 -0
  562. package/sdk/ios/usr/include/objc/NSObjCRuntime.h +5 -0
  563. package/sdk/ios/wasm/include/fcntl.h +1 -0
  564. package/sdk/ios/wasm/include/pthread.h +2 -0
  565. package/sdk/ios/wasm/include/stdlib.h +1 -0
  566. package/sdk/native-hashes.json +11 -1
  567. package/skills/contrast/SKILL.md +4 -9
  568. package/skills/peach-perf/SKILL.md +3 -1
  569. package/skills/peach-perf/references/profiling.md +1 -1
  570. package/skills/peach-test/SKILL.md +20 -17
  571. package/skills/peach-test/references/detox.md +7 -7
  572. package/skills/peach-test/references/maestro.md +20 -18
  573. package/src/admitted-mac-build.ts +7 -0
  574. package/src/android-autolinking.ts +2 -2
  575. package/src/android-drawables.ts +5 -5
  576. package/src/android-string-value.ts +1 -1
  577. package/src/android-strings.ts +1 -1
  578. package/src/android-theme.ts +2 -2
  579. package/src/appPackageContract.ts +1 -1
  580. package/src/bridge-contract.ts +12 -16
  581. package/src/build-cache.ts +65 -0
  582. package/src/bundle-channel.mjs +69 -9
  583. package/src/capture-contract.ts +55 -17
  584. package/src/chromium-admission.ts +24 -21
  585. package/src/conformance-comparison-contract.ts +105 -40
  586. package/src/dev-bundle-resolution.ts +23 -10
  587. package/src/device-catalog.ts +35 -2
  588. package/src/disk-cleanup.ts +18 -8
  589. package/src/expo-autolinking.ts +24 -0
  590. package/src/expo-discovery-cache.ts +168 -23
  591. package/src/expo-native-workspace.ts +551 -191
  592. package/src/expo-swift-host.ts +711 -314
  593. package/src/expo-swift-ready.ts +39 -5
  594. package/src/expo-widget-assets.ts +2 -2
  595. package/src/expo-widgets-bundle.ts +56 -0
  596. package/src/expo-workspace-exclusion.ts +62 -0
  597. package/src/expoSwiftContract.ts +27 -4
  598. package/src/forked-script-contract.ts +3 -0
  599. package/src/home-paths.ts +10 -6
  600. package/src/host/bridge-host.ts +27 -0
  601. package/src/host/network-policy.ts +1 -1
  602. package/src/kotlin-app.ts +9 -11
  603. package/src/kotlin-host.ts +2 -2
  604. package/src/launchMetadataContract.ts +5 -0
  605. package/src/menu.ts +19 -5
  606. package/src/native-app-identity-project.ts +35 -49
  607. package/src/native-app-identity.ts +5 -6
  608. package/src/native-firebase-config.ts +10 -48
  609. package/src/native-prebuilt.ts +3 -2
  610. package/src/native-slices.ts +39 -0
  611. package/src/native-static-libraries.ts +73 -0
  612. package/src/nitro-adapter.lock.json +249 -249
  613. package/src/nitro-adapter.ts +16 -5
  614. package/src/nitro-bundle.ts +35 -16
  615. package/src/nitro-compile.ts +254 -16
  616. package/src/nitro-compiler-digest.ts +39 -0
  617. package/src/nitro-dependencies.ts +368 -28
  618. package/src/nitro-source.ts +432 -77
  619. package/src/nitro-superset.lock.json +27 -36
  620. package/src/nitro-superset.ts +6 -0
  621. package/src/nitroAdapterContract.ts +52 -0
  622. package/src/nitroContract.ts +40 -4
  623. package/src/numbered-lock.ts +2 -2
  624. package/src/one-native-app-accent.ts +32 -0
  625. package/src/one-widget-discovery.ts +6 -1
  626. package/src/one-widget-metadata.ts +2 -2
  627. package/src/portable-expo-contract.ts +103 -0
  628. package/src/portable-expo-workspace.ts +94 -0
  629. package/src/prepared-native-inventory.ts +93 -0
  630. package/src/prepared-xcode-phases.ts +194 -0
  631. package/src/process-group.ts +8 -15
  632. package/src/process-table.ts +117 -0
  633. package/src/react-native-bridge-modules.ts +240 -14
  634. package/src/react-native-coverage/native-typescript-parser.ts +11 -2
  635. package/src/react-native-coverage/verified-reach.ts +12 -6
  636. package/src/react-native-host-modules.ts +2 -0
  637. package/src/reap-browser.ts +13 -9
  638. package/src/retired-cache-directory.ts +34 -0
  639. package/src/runtime-assets.ts +1 -0
  640. package/src/screenshots/orchestrate.ts +4 -0
  641. package/src/screenshots/schema.ts +2 -2
  642. package/src/storageSnapshotContract.ts +9 -2
  643. package/src/stub-pattern-matcher.ts +53 -19
  644. package/src/swift-compile.ts +1011 -327
  645. package/src/swift-compiler-digest.ts +3 -0
  646. package/src/swift-coverage/indexing.ts +1 -1
  647. package/src/swift-coverage/xcode-asset-symbols.ts +72 -39
  648. package/src/swift-coverage/xcode-assets.ts +2 -1
  649. package/src/swift-cxx-declarations.ts +114 -130
  650. package/src/swift-cxx-standin.ts +3 -3
  651. package/src/swift-darwin-records.ts +88 -0
  652. package/src/swift-distribution.lock.json +15 -12
  653. package/src/swift-distribution.ts +25 -9
  654. package/src/swift-host.ts +443 -142
  655. package/src/swift-icu.ts +72 -4
  656. package/src/swift-link-roots.ts +2 -0
  657. package/src/swift-objc-compile.ts +312 -65
  658. package/src/swift-objc-import.ts +8 -1
  659. package/src/swift-objc-standin.ts +20 -2
  660. package/src/swift-package-manifest.ts +189 -57
  661. package/src/swift-package.ts +51 -0
  662. package/src/swift-packages.ts +117 -45
  663. package/src/swift-pdf-raster.ts +7 -4
  664. package/src/swift-project-user.ts +183 -0
  665. package/src/swift-reproducible.ts +26 -0
  666. package/src/swift-root-lock.ts +34 -62
  667. package/src/swift-shared-sdk.ts +232 -21
  668. package/src/swift-source-pods.ts +9 -2
  669. package/src/swift-standin-emit.ts +248 -7
  670. package/src/swift-standins.ts +130 -108
  671. package/src/swift-submit.ts +3 -0
  672. package/src/swift-toolchain.ts +109 -8
  673. package/src/swift-wasm-prune.ts +210 -55
  674. package/src/swiftContract.ts +14 -0
  675. package/src/swiftGuestImageContract.ts +113 -0
  676. package/src/turbo-bundle.ts +5 -8
  677. package/src/turbo-codegen-intake.ts +134 -0
  678. package/src/turbo-compile.ts +198 -21
  679. package/src/turbo-native-libraries.ts +98 -0
  680. package/src/turbo-runtime.lock.json +25 -18
  681. package/src/turbo-source.ts +1519 -147
  682. package/src/vite-plugin-one.ts +25 -3
  683. package/src/vite-plugin-swift.ts +5 -1
  684. package/src/vite-plugin.ts +40 -18
  685. package/src/worker-system-chunks.ts +103 -15
  686. package/src/worklets-babel.ts +50 -29
  687. package/src/xcode-header-search.ts +15 -5
  688. package/src/xcode-project.ts +444 -88
  689. package/src/xcode-target-members.ts +72 -63
  690. package/dist-types/packages/peach-engine/src/render-worker/compositor-runtime/scroll-drag-resample.d.ts +0 -44
@@ -1,3 +1,4 @@
1
+ import { execFile } from 'node:child_process'
1
2
  // the original native source of an app's C++ TurboModules, collected as
2
3
  // CocoaPods builds it for iOS: every autolinked pod whose sources register a
3
4
  // module into React Native's global C++ module map
@@ -10,12 +11,28 @@
10
11
  import { createHash } from 'node:crypto'
11
12
  import fs from 'node:fs'
12
13
  import path from 'node:path'
13
- import { nitroDependencyReader, prepareNitroDependencies } from './nitro-dependencies'
14
- import { iosAutolinkedDependencies } from './nitro-source'
14
+ import { promisify } from 'node:util'
15
+ import { PEACH_ANSWERED_NATIVE_PACKAGE_NAMES } from '../../peach-compat/src/generated/supported-native-packages'
16
+ import { rnxHomeDir } from './home-paths'
17
+
18
+ const execFileAsync = promisify(execFile)
19
+ import {
20
+ glogSources,
21
+ nitroDependencyIncludes,
22
+ nitroDependencyReader,
23
+ nitroDependencySources,
24
+ prepareNitroDependencies,
25
+ } from './nitro-dependencies'
26
+ import { iosAutolinkedDependencies, nitroRegisteredNames } from './nitro-source'
15
27
  import { TURBO_RUNTIME_HEADER } from './nitroAdapterContract'
28
+ import { COMPILED_TURBO_NATIVE_PACKAGES } from './nitroContract'
16
29
  import { readPackageFile } from './swift-source-file'
17
30
  import { MAX_SWIFT_COMPILE_SOURCE_BYTES } from './swift-submit'
18
- import { runInstalledTurboCodegen } from './turbo-codegen-intake'
31
+ import {
32
+ installedFabricSources,
33
+ installedRendererDependencyGlobs,
34
+ runInstalledTurboCodegen,
35
+ } from './turbo-codegen-intake'
19
36
  import type { SwiftCompileInput } from './swift-compile'
20
37
  import type { SwiftPackageTarget } from './swift-package'
21
38
 
@@ -28,10 +45,17 @@ export interface TurboProvider {
28
45
  podspecPath: string
29
46
  }
30
47
 
48
+ export interface TurboInstalledPod {
49
+ root: string
50
+ files: string[]
51
+ library: string
52
+ }
53
+
31
54
  /** source fragments for the common Swift host. the caller owns the executable,
32
55
  * which runs every `loads` symbol and then `peachTurboInitialize`. */
33
56
  export interface TurboSourceCollection {
34
57
  files: SwiftCompileInput['files']
58
+ libraries?: SwiftCompileInput['libraries']
35
59
  targets: SwiftPackageTarget[]
36
60
  /** each transcribed +load, sorted by package; `target` declares it. */
37
61
  loads: { symbol: string; target: string }[]
@@ -42,7 +66,9 @@ export interface TurboSourceCollection {
42
66
  source: string
43
67
  sha256: string
44
68
  derivation?: { upstreamCommit: string; originalSha256: string }
69
+ configured?: { template: string; originalSha256: string }
45
70
  }[]
71
+ externalPodSources: { moduleName: string; file: string }[]
46
72
  }
47
73
 
48
74
  export const TURBO_CORE_TARGET = 'TurboCore'
@@ -53,6 +79,26 @@ const CODEGEN_OBJC = /@generated by codegen project: GenerateModuleObjCpp\b/
53
79
  const UNIT = /\.(?:c|cc|cpp|cxx)$/
54
80
  const HEADER = /\.(?:h|hh|hpp|hxx|inl|ipp)$/
55
81
  const OBJC = /\.(?:m|mm)$/
82
+ const answeredPackages: ReadonlySet<string> = new Set(PEACH_ANSWERED_NATIVE_PACKAGE_NAMES)
83
+ // an Objective-C TurboModule: a class whose getTurboModule: returns the C++
84
+ // object React Native's TurboModule manager installs
85
+ const OBJC_TURBO =
86
+ /-\s*\(\s*std::shared_ptr<\s*(?:facebook::react::)?TurboModule\s*>\s*\)\s*getTurboModule\s*:/
87
+ // RCT_EXTERN_MODULE pods are Swift bridge modules owned by collectInstalledSwiftBridgeUnits
88
+ const OBJC_BRIDGE = /\b(?:RCT_EXPORT_MODULE|RCT_EXPORT_MODULE_NO_LOAD)\s*\(/
89
+
90
+ function fabricComponents(root: string): boolean {
91
+ const manifest: unknown = JSON.parse(
92
+ fs.readFileSync(path.join(root, 'package.json'), 'utf8'),
93
+ )
94
+ if (!object(manifest) || !object(manifest.codegenConfig)) return false
95
+ const ios = manifest.codegenConfig.ios
96
+ return (
97
+ object(ios) &&
98
+ object(ios.componentProvider) &&
99
+ Object.keys(ios.componentProvider).length > 0
100
+ )
101
+ }
56
102
 
57
103
  // the TurboModule core every module pod links (ReactCommon/turbomodule/core
58
104
  // and the pods it depends on), and the header search roots CocoaPods exposes
@@ -65,11 +111,88 @@ const REACT_NATIVE_UNITS = [
65
111
  'ReactCommon/react/utils/jsi-utils.cpp',
66
112
  ]
67
113
  const REACT_NATIVE_INCLUDE_ROOTS = [
114
+ 'React/FBReactNativeSpec',
68
115
  'ReactCommon/jsi',
69
116
  'ReactCommon',
70
117
  'ReactCommon/callinvoker',
118
+ 'ReactCommon/jsiexecutor',
71
119
  'ReactCommon/react/nativemodule/core',
120
+ 'ReactCommon/react/nativemodule/core/platform/ios',
121
+ 'ReactCommon/runtimeexecutor',
122
+ 'ReactCommon/runtimeexecutor/platform/ios',
123
+ 'ReactCommon/yoga',
72
124
  'ReactCommon/reactperflogger',
125
+ // the platform directories the React-Fabric, React-graphics and React-utils podspecs give their header search paths
126
+ 'ReactCommon/react/renderer/components/view/platform/cxx',
127
+ 'ReactCommon/react/renderer/components/scrollview/platform/cxx',
128
+ 'ReactCommon/react/renderer/components/scrollview/platform/ios',
129
+ 'ReactCommon/react/renderer/components/legacyviewmanagerinterop/platform/ios',
130
+ 'ReactCommon/react/renderer/components/text/platform/cxx',
131
+ 'ReactCommon/react/renderer/components/textinput/platform/ios',
132
+ 'ReactCommon/react/renderer/components/switch/iosswitch',
133
+ 'ReactCommon/react/renderer/textlayoutmanager/platform/ios',
134
+ 'ReactCommon/react/renderer/graphics/platform/ios',
135
+ 'ReactCommon/react/renderer/imagemanager/platform/ios',
136
+ 'ReactCommon/react/utils/platform/ios',
137
+ ]
138
+ // what an Objective-C TurboModule adds: React Native's Objective-C module
139
+ // manager and the React-Core, RCTTypeSafety, Yoga and feature flag units it reaches
140
+ const REACT_NATIVE_OBJC_UNITS = [
141
+ 'ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/*.mm',
142
+ 'ReactCommon/react/featureflags/*.cpp',
143
+ 'ReactCommon/yoga/yoga/YGValue.cpp',
144
+ 'Libraries/TypeSafety/*.mm',
145
+ 'React/Base/RCTAssert.m',
146
+ 'React/Base/RCTBridge.mm',
147
+ 'React/Base/RCTBridgeConstants.m',
148
+ 'React/Base/RCTBridgeModuleDecorator.m',
149
+ 'React/Base/RCTCallableJSModules.m',
150
+ 'React/Base/RCTCallInvoker.mm',
151
+ 'React/Base/RCTConstants.m',
152
+ 'React/Base/RCTConvert.mm',
153
+ 'React/Base/RCTCxxConvert.m',
154
+ 'React/Base/RCTJSThread.m',
155
+ 'React/Base/RCTLog.mm',
156
+ 'React/Base/RCTManagedPointer.mm',
157
+ 'React/Base/RCTModuleMethod.mm',
158
+ 'React/Base/RCTModuleRegistry.m',
159
+ 'React/Base/RCTParserUtils.m',
160
+ 'React/Base/RCTRedBoxSetEnabled.m',
161
+ 'React/Base/RCTUtils.mm',
162
+ 'React/Base/RCTViewRegistry.m',
163
+ 'React/Modules/RCTEventEmitter.m',
164
+ ]
165
+ // units added or removed between react native releases; compile those installed
166
+ const REACT_NATIVE_OBJC_VERSIONED_UNITS = [
167
+ // removed in react-native 0.79; nothing references it there
168
+ 'ReactCommon/runtimeexecutor/platform/ios/ReactCommon/RuntimeExecutorSyncUIThreadUtils.mm',
169
+ 'React/Base/RCTArrayBuffer.mm',
170
+ 'React/Base/RCTModuleData.mm',
171
+ 'React/CoreModules/RCTDevMenuConfigurationDecorator.mm',
172
+ ]
173
+ // the header_dir each React pod gives its headers: React-Core flattens every
174
+ // header under React/, RCTRequired and RCTTypeSafety keep their own
175
+ const REACT_NATIVE_HEADER_DIRS = [
176
+ { from: 'React', to: 'React' },
177
+ { from: 'Libraries/ActionSheetIOS', to: 'React' },
178
+ { from: 'Libraries/Blob', to: 'React' },
179
+ { from: 'Libraries/Image', to: 'React' },
180
+ { from: 'Libraries/LinkingIOS', to: 'React' },
181
+ { from: 'Libraries/Network', to: 'React' },
182
+ { from: 'Libraries/NativeAnimation', to: 'React' },
183
+ { from: 'Libraries/PushNotificationIOS', to: 'React' },
184
+ { from: 'Libraries/Settings', to: 'React' },
185
+ { from: 'Libraries/Text', to: 'React' },
186
+ { from: 'Libraries/Vibration', to: 'React' },
187
+ { from: 'Libraries/Network', to: 'RCTNetwork' },
188
+ { from: 'Libraries/Required', to: 'RCTRequired' },
189
+ { from: 'Libraries/TypeSafety', to: 'RCTTypeSafety' },
190
+ { from: 'Libraries/FBLazyVector/FBLazyVector', to: 'FBLazyVector' },
191
+ { from: 'ReactApple/RCTSwiftUIWrapper', to: 'RCTSwiftUIWrapper' },
192
+ {
193
+ from: 'ReactApple/Libraries/RCTFoundation/RCTDeprecation/Exported',
194
+ to: 'RCTDeprecation',
195
+ },
73
196
  ]
74
197
 
75
198
  function object(value: unknown): value is Record<string, unknown> {
@@ -145,42 +268,248 @@ function podspecList(text: string, attribute: string): string[] | 'computed' | n
145
268
  if (assignments.length === 0) return null
146
269
  if (assignments.length > 1) return 'computed'
147
270
  const rest = text.slice(assignments[0]!.index + assignments[0]![0].length)
148
- const value = (
149
- rest.startsWith('[') ? rest.slice(1, rest.indexOf(']')) : (rest.split('\n')[0] ?? '')
150
- ).trim()
271
+ const bracketed = rest.startsWith('[')
272
+ // a bracketed list runs to its closing bracket, a bare one to its line
273
+ const end = bracketed ? rest.indexOf(']') : rest.indexOf('\n')
274
+ if (bracketed && end === -1) return 'computed'
275
+ const value = rest.slice(bracketed ? 1 : 0, end === -1 ? undefined : end)
151
276
  const items: string[] = []
152
- const pattern = /("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')\s*(?:,\s*|$)/y
153
- for (let at = 0; at < value.length; at = pattern.lastIndex) {
154
- pattern.lastIndex = at
155
- const match = pattern.exec(value)
277
+ // string literals, separating commas and whitespace; ruby comments (# to
278
+ // end of line) between elements are skipped
279
+ const token = /\s+|,|#[^\n]*|("(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')/y
280
+ for (let at = 0; at < value.length; at = token.lastIndex) {
281
+ token.lastIndex = at
282
+ const match = token.exec(value)
156
283
  if (!match) return 'computed'
157
- const literal = match[1]!
284
+ const literal = match[1]
285
+ if (!literal) continue
158
286
  if (literal.startsWith('"') && literal.includes('#{')) return 'computed'
159
287
  items.push(literal.slice(1, -1))
160
288
  }
161
289
  return items
162
290
  }
163
291
 
164
- type Pod = { root: string; directory: string; text: string; name: string }
292
+ function podspecDependencies(text: string): { name: string; version?: string }[] {
293
+ const deps: { name: string; version?: string }[] = []
294
+ const seen = new Set<string>()
295
+ for (const match of text.matchAll(
296
+ /^\s*\w+\.dependency\s+['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?/gm,
297
+ )) {
298
+ const root = match[1]!.split('/')[0]!
299
+ if (
300
+ seen.has(root) ||
301
+ root === 'React' ||
302
+ root === 'React-Core' ||
303
+ root === 'ReactCommon' ||
304
+ root.startsWith('React-') ||
305
+ root.startsWith('RCT') ||
306
+ root === 'FBLazyVector' ||
307
+ root === 'DoubleConversion' ||
308
+ root === 'glog' ||
309
+ root === 'boost' ||
310
+ root === 'fmt' ||
311
+ root === 'fast_float' ||
312
+ root === 'Yoga'
313
+ )
314
+ continue
315
+ seen.add(root)
316
+ deps.push({ name: root, ...(match[2] ? { version: match[2] } : {}) })
317
+ }
318
+ return deps
319
+ }
320
+
321
+ function stringList(value: unknown): string[] {
322
+ if (typeof value === 'string') return [value]
323
+ if (Array.isArray(value))
324
+ return value.filter((item): item is string => typeof item === 'string')
325
+ return []
326
+ }
327
+
328
+ async function resolveExternalTurboPod(
329
+ name: string,
330
+ versionHint: string | undefined,
331
+ ): Promise<{
332
+ name: string
333
+ moduleName: string
334
+ root: string
335
+ files: string[]
336
+ } | null> {
337
+ const shard = createHash('md5').update(name).digest('hex').slice(0, 3).split('')
338
+ const baseDir = path.join(rnxHomeDir(), 'turbo-pods')
339
+ let version =
340
+ versionHint && /^\d+\.\d+(?:\.\d+)*(?:-[0-9A-Za-z.-]+)?$/.test(versionHint.trim())
341
+ ? versionHint.trim()
342
+ : undefined
343
+ if (!version) {
344
+ const versionsFile = path.join(baseDir, 'versions', `${shard.join('_')}.txt`)
345
+ let versionsText: string
346
+ if (fs.existsSync(versionsFile)) {
347
+ versionsText = fs.readFileSync(versionsFile, 'utf8')
348
+ } else {
349
+ const res = await fetch(
350
+ `https://cdn.cocoapods.org/all_pods_versions_${shard.join('_')}.txt`,
351
+ )
352
+ if (!res.ok) return null
353
+ versionsText = await res.text()
354
+ fs.mkdirSync(path.dirname(versionsFile), { recursive: true })
355
+ fs.writeFileSync(versionsFile, versionsText)
356
+ }
357
+ const line = versionsText.split('\n').find((entry) => entry.startsWith(`${name}/`))
358
+ if (!line) return null
359
+ const allVersions = line
360
+ .slice(name.length + 1)
361
+ .split('/')
362
+ .filter(Boolean)
363
+ const stable = allVersions.filter((v) => !v.includes('-'))
364
+ version = (stable.length > 0 ? stable : allVersions).at(-1)
365
+ if (!version) return null
366
+ }
367
+ const specFile = path.join(baseDir, 'specs', `${name}-${version}.podspec.json`)
368
+ let specText: string
369
+ if (fs.existsSync(specFile)) {
370
+ specText = fs.readFileSync(specFile, 'utf8')
371
+ } else {
372
+ const res = await fetch(
373
+ `https://cdn.cocoapods.org/Specs/${shard.join('/')}/${name}/${version}/${name}.podspec.json`,
374
+ )
375
+ if (!res.ok) return null
376
+ specText = await res.text()
377
+ fs.mkdirSync(path.dirname(specFile), { recursive: true })
378
+ fs.writeFileSync(specFile, specText)
379
+ }
380
+ const spec: unknown = JSON.parse(specText)
381
+ if (!object(spec)) return null
382
+ const source = object(spec.source) ? spec.source : null
383
+ const gitUrl = typeof source?.git === 'string' ? source.git : null
384
+ const tag = typeof source?.tag === 'string' ? source.tag : version
385
+ if (!gitUrl || !gitUrl.startsWith('https://github.com/')) return null
386
+ const treeDir = path.join(baseDir, 'trees', `${name}-${version}`)
387
+ const marker = path.join(treeDir, '.extracted')
388
+ if (!fs.existsSync(marker)) {
389
+ const archiveUrl = `${gitUrl.replace(/\.git$/, '')}/archive/refs/tags/${tag}.tar.gz`
390
+ const res = await fetch(archiveUrl)
391
+ if (!res.ok) return null
392
+ const bytes = new Uint8Array(await res.arrayBuffer())
393
+ const archiveFile = path.join(baseDir, 'archives', `${name}-${version}.tar.gz`)
394
+ fs.mkdirSync(path.dirname(archiveFile), { recursive: true })
395
+ fs.writeFileSync(archiveFile, bytes)
396
+ const staging = path.join(baseDir, 'staging', `${name}-${version}-${process.pid}`)
397
+ fs.rmSync(staging, { recursive: true, force: true })
398
+ fs.mkdirSync(staging, { recursive: true })
399
+ await execFileAsync('tar', ['-xzf', archiveFile, '-C', staging])
400
+ const entries = fs.readdirSync(staging)
401
+ const extractedRoot =
402
+ entries.length === 1 && fs.statSync(path.join(staging, entries[0]!)).isDirectory()
403
+ ? path.join(staging, entries[0]!)
404
+ : staging
405
+ fs.rmSync(treeDir, { recursive: true, force: true })
406
+ fs.mkdirSync(path.dirname(treeDir), { recursive: true })
407
+ fs.renameSync(extractedRoot, treeDir)
408
+ fs.rmSync(staging, { recursive: true, force: true })
409
+ fs.writeFileSync(marker, version)
410
+ }
411
+ const iosSpec = object(spec.ios) ? spec.ios : null
412
+ const sourceGlobs = [
413
+ ...stringList(spec.source_files),
414
+ ...stringList(iosSpec?.source_files),
415
+ ]
416
+ const excludeGlobs = [
417
+ ...stringList(spec.exclude_files),
418
+ ...stringList(iosSpec?.exclude_files),
419
+ ]
420
+ if (sourceGlobs.length === 0) return null
421
+ const candidates = new Set<string>()
422
+ for (const glob of sourceGlobs) walkFiles(treeDir, globBase(glob), candidates)
423
+ const included = sourceGlobs.map((glob) => globRegex(glob))
424
+ const excluded = excludeGlobs.map((glob) => globRegex(glob))
425
+ const files = [...candidates]
426
+ .filter(
427
+ (file) =>
428
+ included.some((glob) => glob.test(file)) &&
429
+ !excluded.some((glob) => glob.test(file)),
430
+ )
431
+ .sort()
432
+ const moduleName =
433
+ typeof spec.module_name === 'string'
434
+ ? spec.module_name
435
+ : typeof iosSpec?.module_name === 'string'
436
+ ? iosSpec.module_name
437
+ : name
438
+ return { name, moduleName, root: treeDir, files }
439
+ }
440
+
441
+ type Pod = {
442
+ root: string
443
+ directory: string
444
+ text: string
445
+ name: string
446
+ installed?: TurboInstalledPod
447
+ }
165
448
 
166
- function readPod(provider: TurboProvider): Pod {
167
- const root = fs.realpathSync(provider.root)
168
- const podspec = fs.realpathSync(provider.podspecPath)
449
+ function readPod(provider: TurboProvider, installed?: TurboInstalledPod): Pod {
450
+ const originalRoot = fs.realpathSync(provider.root)
451
+ const relative = path.relative(originalRoot, fs.realpathSync(provider.podspecPath))
452
+ const root = installed?.root ?? originalRoot
453
+ const podspec = path.join(root, relative)
169
454
  return {
170
455
  root,
171
456
  // CocoaPods resolves every glob against the podspec's own directory
172
457
  directory: path.relative(root, path.dirname(podspec)).split(path.sep).join('/'),
173
458
  text: readPackageFile(root, podspec, MAX_SWIFT_COMPILE_SOURCE_BYTES).toString('utf8'),
174
459
  name: path.basename(podspec, '.podspec'),
460
+ ...(installed ? { installed } : {}),
175
461
  }
176
462
  }
177
463
 
464
+ // the text CocoaPods installs by default: the pod's own attributes plus the
465
+ // subspecs it names in default_subspecs, or every subspec when it names none
466
+ function podSegments(pod: Pod): string[] {
467
+ const walk = (lines: string[]): string[] => {
468
+ const blocks = new Map<string, string[]>()
469
+ const own: string[] = []
470
+ for (let at = 0; at < lines.length; at++) {
471
+ const open = /^(\s*)\w+\.subspec\s+['"]([^'"]+)['"]\s+do\b/.exec(lines[at]!)
472
+ if (!open) {
473
+ own.push(lines[at]!)
474
+ continue
475
+ }
476
+ const body: string[] = []
477
+ const close = new RegExp(`^${open[1]}end\\b`)
478
+ for (at++; at < lines.length && !close.test(lines[at]!); at++) body.push(lines[at]!)
479
+ blocks.set(open[2]!, body)
480
+ }
481
+ const ownText = own.join('\n')
482
+ if (blocks.size === 0) return [ownText]
483
+ const named =
484
+ podspecList(ownText, 'default_subspecs') ?? podspecList(ownText, 'default_subspec')
485
+ if (named === 'computed')
486
+ throw new Error(`${pod.name}.podspec: default_subspecs is computed by Ruby`)
487
+ return [
488
+ ownText,
489
+ ...(named ?? [...blocks.keys()]).flatMap((name) => {
490
+ const block = blocks.get(name)
491
+ if (!block)
492
+ throw new Error(`${pod.name}.podspec: default subspec ${name} is not defined`)
493
+ return walk(block)
494
+ }),
495
+ ]
496
+ }
497
+ return walk(pod.text.split('\n'))
498
+ }
499
+
178
500
  // the package-relative files a podspec's literal globs select
179
501
  function podGlobFiles(pod: Pod): string[] | 'computed' | null {
180
- const sources = podspecList(pod.text, 'source_files')
181
- const excludes = podspecList(pod.text, 'exclude_files') ?? []
182
- if (sources === 'computed' || excludes === 'computed') return 'computed'
183
- if (!sources) return null
502
+ const segments = podSegments(pod)
503
+ const lists = (attribute: string) =>
504
+ segments.map((text) => podspecList(text, attribute))
505
+ const allSources = lists('source_files')
506
+ const allExcludes = lists('exclude_files')
507
+ if ([...allSources, ...allExcludes].includes('computed')) return 'computed'
508
+ const flat = (all: (string[] | 'computed' | null)[]) =>
509
+ all.flatMap((list) => (Array.isArray(list) ? list : []))
510
+ const sources = flat(allSources)
511
+ const excludes = flat(allExcludes)
512
+ if (allSources.every((list) => list === null)) return null
184
513
  const prefix = pod.directory ? `${pod.directory}/` : ''
185
514
  const candidates = new Set<string>()
186
515
  for (const glob of sources) walkFiles(pod.root, prefix + globBase(glob), candidates)
@@ -197,12 +526,36 @@ function podGlobFiles(pod: Pod): string[] | 'computed' | null {
197
526
  .sort()
198
527
  }
199
528
 
529
+ // where CocoaPods places the headers of a podspec segment that sets
530
+ // header_mappings_dir: under header_dir at the path below that directory, not
531
+ // flattened into the pod's header directory
532
+ function podHeaderMappings(pod: Pod): { dir: string; headerDir: string }[] {
533
+ const segments = podSegments(pod)
534
+ const prefix = pod.directory ? `${pod.directory}/` : ''
535
+ const single = (text: string, attribute: string) => {
536
+ const value = podspecList(text, attribute)
537
+ if (value === 'computed' || (value && value.length !== 1))
538
+ throw new Error(`${pod.name}.podspec: ${attribute} is computed by Ruby`)
539
+ return value?.[0]
540
+ }
541
+ const ownHeaderDir = single(segments[0]!, 'header_dir')
542
+ return segments.flatMap((text) => {
543
+ const dir = single(text, 'header_mappings_dir')
544
+ if (dir === undefined) return []
545
+ return [
546
+ {
547
+ dir: path.posix.normalize(prefix + dir),
548
+ headerDir: single(text, 'header_dir') ?? ownHeaderDir ?? '',
549
+ },
550
+ ]
551
+ })
552
+ }
553
+
200
554
  // the files a provider's podspec compiles, refused when the pod ships binaries
201
- // or subspecs this reading cannot follow
555
+ // this reading cannot follow
202
556
  function podFiles(pod: Pod): string[] {
557
+ if (pod.installed) return pod.installed.files
203
558
  const file = `${pod.name}.podspec`
204
- if (/^\s*\w+\.subspec\b/m.test(pod.text))
205
- throw new Error(`${file}: TurboModule pods with subspecs are not supported yet`)
206
559
  for (const binary of ['vendored_frameworks', 'vendored_libraries'])
207
560
  if (new RegExp(`\\.${binary}\\s*=`).test(pod.text))
208
561
  throw new Error(
@@ -271,13 +624,52 @@ function transcribeLoad(text: string, file: string) {
271
624
  return { includes, usings, body }
272
625
  }
273
626
 
274
- function registers(root: string, files: Iterable<string>): boolean {
275
- for (const file of files)
627
+ function viewManagers(root: string, files: Iterable<string>): Set<string> {
628
+ const classes = new Map<string, string>()
629
+ for (const file of files) {
630
+ if (!HEADER.test(file) && !OBJC.test(file)) continue
631
+ const text = stripComments(fs.readFileSync(path.join(root, file), 'utf8'))
632
+ for (const [, name, parent] of text.matchAll(/@interface\s+(\w+)\s*:\s*(\w+)/g))
633
+ classes.set(name!, parent!)
634
+ for (const [, name, parent] of text.matchAll(
635
+ /\bRCT_EXTERN_(?:REMAP_MODULE\s*\(\s*\w*\s*,\s*|MODULE\s*\(\s*)(\w+)\s*,\s*(\w+)/g,
636
+ ))
637
+ classes.set(name!, parent!)
638
+ }
639
+ const managers = new Set(['RCTViewManager'])
640
+ for (let remaining = classes.size; remaining > 0; remaining--) {
641
+ let changed = false
642
+ for (const [name, parent] of classes) {
643
+ if (!managers.has(name) && managers.has(parent)) {
644
+ managers.add(name)
645
+ changed = true
646
+ }
647
+ }
648
+ if (!changed) break
649
+ }
650
+ return managers
651
+ }
652
+
653
+ function registers(root: string, files: Iterable<string>, objc = true): boolean {
654
+ const sources = [...files]
655
+ const managers = objc ? viewManagers(root, sources) : new Set<string>()
656
+ for (const file of sources) {
657
+ if (!UNIT.test(file) && !OBJC.test(file)) continue
658
+ const text = fs.readFileSync(path.join(root, file), 'utf8')
659
+ if (text.includes(REGISTRATION)) return true
660
+ const stripped = stripComments(text)
276
661
  if (
277
- (UNIT.test(file) || OBJC.test(file)) &&
278
- fs.readFileSync(path.join(root, file), 'utf8').includes(REGISTRATION)
662
+ objc &&
663
+ OBJC.test(file) &&
664
+ !CODEGEN_OBJC.test(text) &&
665
+ (OBJC_TURBO.test(stripped) ||
666
+ (OBJC_BRIDGE.test(stripped) &&
667
+ ![...stripped.matchAll(/@implementation\s+(\w+)/g)].some(([, name]) =>
668
+ managers.has(name!),
669
+ )))
279
670
  )
280
671
  return true
672
+ }
281
673
  return false
282
674
  }
283
675
 
@@ -287,22 +679,47 @@ function registers(root: string, files: Iterable<string>): boolean {
287
679
  export async function discoverTurboProviders(appRoot: string): Promise<TurboProvider[]> {
288
680
  const providers: TurboProvider[] = []
289
681
  for (const { name, root, podspecPath } of await iosAutolinkedDependencies(appRoot)) {
682
+ if (answeredPackages.has(name) && !COMPILED_TURBO_NATIVE_PACKAGES.includes(name))
683
+ continue
290
684
  if (!podspecPath) continue
291
685
  const provider = { name, root, podspecPath }
292
686
  const pod = readPod(provider)
293
687
  const files = podGlobFiles(pod)
294
688
  if (files === null) continue
295
689
  if (files !== 'computed') {
296
- if (registers(pod.root, files)) providers.push(provider)
690
+ if (registers(pod.root, files) || fabricComponents(root)) {
691
+ const dependencies = await Promise.all(
692
+ podspecDependencies(pod.text).map((dep) =>
693
+ resolveExternalTurboPod(dep.name, dep.version),
694
+ ),
695
+ )
696
+ if (
697
+ !dependencies.some((dep) => dep?.files.some((file) => file.endsWith('.swift')))
698
+ )
699
+ providers.push(provider)
700
+ }
297
701
  continue
298
702
  }
299
703
  const tree = new Set<string>()
300
704
  walkFiles(pod.root, pod.directory, tree)
301
- if (registers(pod.root, tree)) podFiles(pod)
705
+ // computed globs cannot identify which objective-c sources belong to the pod.
706
+ if (registers(pod.root, tree, false)) podFiles(pod)
302
707
  }
303
708
  return providers
304
709
  }
305
710
 
711
+ /** autolinked pods whose public headers CocoaPods exposes to other pods. */
712
+ export async function installedTurboHeaderPods(
713
+ appRoot: string,
714
+ ): Promise<TurboProvider[]> {
715
+ const pods: TurboProvider[] = []
716
+ for (const { name, root, podspecPath } of await iosAutolinkedDependencies(appRoot)) {
717
+ if (!podspecPath) continue
718
+ pods.push({ name, root, podspecPath })
719
+ }
720
+ return pods
721
+ }
722
+
306
723
  function readFollyConfig(reactNativeRoot: string) {
307
724
  const helpers = fs.readFileSync(
308
725
  path.join(reactNativeRoot, 'scripts/cocoapods/helpers.rb'),
@@ -311,18 +728,24 @@ function readFollyConfig(reactNativeRoot: string) {
311
728
  const config = /@@folly_config\s*=\s*\{([\s\S]*?)\n\s*\}/.exec(helpers)?.[1]
312
729
  const flags = config && /:compiler_flags\s*=>\s*'([^']*)'/.exec(config)?.[1]
313
730
  const lines = config && /:config_file\s*=>\s*\[([\s\S]*?)\]/.exec(config)?.[1]
314
- if (!flags || !lines)
315
- throw new Error(`${reactNativeRoot}: helpers.rb has no folly config`)
316
- const header = [...lines.matchAll(/"((?:[^"\\]|\\.)*)"|'([^']*)'/g)]
317
- .map((match) => match[1] ?? match[2] ?? '')
318
- .join('\n')
731
+ if (!flags) throw new Error(`${reactNativeRoot}: helpers.rb has no folly config`)
732
+ // react-native 0.79 dropped :config_file; -DFOLLY_NO_CONFIG means folly
733
+ // builds with no generated header, exactly as xcode builds it.
734
+ const noConfigHeader = /(?:^|\s)-DFOLLY_NO_CONFIG(?:\s|$)/.test(flags)
735
+ if (!lines && !noConfigHeader)
736
+ throw new Error(`${reactNativeRoot}: helpers.rb folly config has no :config_file`)
737
+ const header = lines
738
+ ? [...lines.matchAll(/"((?:[^"\\]|\\.)*)"|'([^']*)'/g)]
739
+ .map((match) => match[1] ?? match[2] ?? '')
740
+ .join('\n')
741
+ : ''
319
742
  const defines = [...flags.matchAll(/-D(\w+(?:=\S+)?)/g)].map((match) => match[1]!)
320
743
  return { header: `${header}\n`, defines }
321
744
  }
322
745
 
323
746
  /** fetch the installed RN release's pinned C++ dependencies before collection. */
324
747
  export function prepareTurboSourceDependencies(reactNativeRoot: string): Promise<void> {
325
- return prepareNitroDependencies(packageInfo(reactNativeRoot).version)
748
+ return prepareNitroDependencies(packageInfo(reactNativeRoot).version, reactNativeRoot)
326
749
  }
327
750
 
328
751
  /** collect each provider's podspec sources, its codegen output and React
@@ -334,6 +757,7 @@ export async function collectTurboSources(options: {
334
757
  reactNativeRoot: string
335
758
  providers: TurboProvider[]
336
759
  codegenDir: string
760
+ installedPods?: ReadonlyMap<string, TurboInstalledPod>
337
761
  }): Promise<TurboSourceCollection> {
338
762
  if (options.providers.length === 0)
339
763
  throw new Error('TurboModule compilation needs at least one provider')
@@ -343,13 +767,38 @@ export async function collectTurboSources(options: {
343
767
  const providers = options.providers
344
768
  .map((provider) => ({ ...provider, info: packageInfo(provider.root) }))
345
769
  .sort((a, b) => a.info.name.localeCompare(b.info.name))
770
+ const installedHeaderPods = (await installedTurboHeaderPods(options.appRoot)).map(
771
+ (provider) => readPod(provider, options.installedPods?.get(provider.name)),
772
+ )
773
+ let codegen: string | null = null
774
+ const installedCodegenNames = new Set(
775
+ installedHeaderPods.flatMap((pod) => {
776
+ const manifest: unknown = JSON.parse(
777
+ fs.readFileSync(path.join(pod.root, 'package.json'), 'utf8'),
778
+ )
779
+ if (!object(manifest) || !object(manifest.codegenConfig)) return []
780
+ const config = manifest.codegenConfig
781
+ return typeof config.name === 'string' && config.includesGeneratedCode !== true
782
+ ? [config.name]
783
+ : []
784
+ }),
785
+ )
786
+ const installedHeaders = new Map<
787
+ string,
788
+ Map<string, { label: string; root: string; relative: string }>
789
+ >()
346
790
  const targetPath = (name: string) => `Sources/${name}`
347
791
  const providerTarget = (name: string) => `TurboPackage_${sha256(name).slice(0, 16)}`
348
792
  const folly = readFollyConfig(reactNative.root)
349
793
  // the compile builds for production, as an app's Release configuration does.
350
794
  // Debug also compiles React Native's asserts, which need the glog headers
351
795
  // its pod generates at install.
352
- const defines = ['NDEBUG', 'RCT_NEW_ARCH_ENABLED=1', ...folly.defines]
796
+ const defines = [
797
+ 'NDEBUG',
798
+ 'RCT_NEW_ARCH_ENABLED=1',
799
+ 'RCT_REMOVE_LEGACY_ARCH=1',
800
+ ...folly.defines,
801
+ ]
353
802
  const target = (name: string, dependencies: string[]) => ({
354
803
  name,
355
804
  path: targetPath(name),
@@ -370,6 +819,7 @@ export async function collectTurboSources(options: {
370
819
  providers: providers.map(({ info }) => info),
371
820
  reactNative,
372
821
  sources: [],
822
+ externalPodSources: [],
373
823
  }
374
824
  const add = (file: string, text: string) => {
375
825
  if (Object.hasOwn(result.files, file)) {
@@ -381,11 +831,13 @@ export async function collectTurboSources(options: {
381
831
  return true
382
832
  }
383
833
  const alias = (file: string, original: string) => {
384
- if (file !== original)
834
+ if (file !== original) {
835
+ const rel = JSON.stringify(path.posix.relative(path.posix.dirname(file), original))
385
836
  add(
386
837
  file,
387
- `#include ${JSON.stringify(path.posix.relative(path.posix.dirname(file), original))}\n`,
838
+ `#pragma once\n#ifdef __OBJC__\n#import ${rel}\n#else\n#include ${rel}\n#endif\n`,
388
839
  )
840
+ }
389
841
  }
390
842
  // an original file under a target, by its root-relative path. returns the
391
843
  // compile key; reading it again is free.
@@ -415,8 +867,92 @@ export async function collectTurboSources(options: {
415
867
  relative: string
416
868
  }
417
869
  const pending: Scan[] = []
418
- const dependencyHeader = nitroDependencyReader(reactNative.version)
870
+ const pendingCodegen: { from: Scan; include: string; quoted: boolean }[] = []
871
+ const dependencyHeader = nitroDependencyReader(reactNative.version, reactNative.root)
872
+ const dependencyTrees = new Set<string>()
419
873
  const core = targetPath(TURBO_CORE_TARGET)
874
+ let reactHeaderMap: Map<string, string> | undefined
875
+ const reactHeaders = () => {
876
+ if (reactHeaderMap) return reactHeaderMap
877
+ reactHeaderMap = new Map()
878
+ for (const { from, to } of REACT_NATIVE_HEADER_DIRS) {
879
+ const found = new Set<string>()
880
+ walkFiles(reactNative.root, from, found)
881
+ for (const file of [...found].sort()) {
882
+ if (!HEADER.test(file)) continue
883
+ const name = `${to}/${path.posix.basename(file)}`
884
+ if (reactHeaderMap.has(name))
885
+ throw new Error(
886
+ `react-native ${reactNative.version}: two headers are named ${name}`,
887
+ )
888
+ reactHeaderMap.set(name, file)
889
+ }
890
+ }
891
+ // react native pods expose their umbrella headers through subspecs with
892
+ // an empty header_dir and a mapping rooted at the podspec directory.
893
+ const podspecs = new Set<string>()
894
+ walkFiles(reactNative.root, 'ReactCommon', podspecs)
895
+ for (const file of [...podspecs].filter((name) => name.endsWith('.podspec')).sort()) {
896
+ const pod = readPod({
897
+ root: reactNative.root,
898
+ podspecPath: path.join(reactNative.root, file),
899
+ name: path.posix.basename(file, '.podspec'),
900
+ })
901
+ if (!/\.header_dir\s*=\s*['"]['"]/.test(pod.text)) continue
902
+ for (const segment of podSegments(pod)) {
903
+ const mapping = podspecList(segment, 'header_mappings_dir')
904
+ const headerDir = podspecList(segment, 'header_dir')
905
+ if (
906
+ !Array.isArray(mapping) ||
907
+ mapping.length !== 1 ||
908
+ !Array.isArray(headerDir) ||
909
+ headerDir.length !== 1 ||
910
+ headerDir[0] !== ''
911
+ )
912
+ continue
913
+ const sources = podspecList(segment, 'source_files')
914
+ const excluded = podspecList(segment, 'exclude_files')
915
+ const publicFiles = podspecList(segment, 'public_header_files')
916
+ const privateFiles = podspecList(segment, 'private_header_files')
917
+ if (
918
+ !Array.isArray(sources) ||
919
+ excluded === 'computed' ||
920
+ publicFiles === 'computed' ||
921
+ privateFiles === 'computed'
922
+ )
923
+ continue
924
+ const base = path.posix.normalize(path.posix.join(pod.directory, mapping[0]!))
925
+ const candidates = new Set<string>()
926
+ for (const glob of sources)
927
+ walkFiles(
928
+ reactNative.root,
929
+ path.posix.join(pod.directory, globBase(glob)),
930
+ candidates,
931
+ )
932
+ const matches = (patterns: string[] | null, relative: string) =>
933
+ patterns?.some((glob) => globRegex(glob).test(relative)) ?? false
934
+ for (const candidate of [...candidates].sort()) {
935
+ if (!HEADER.test(candidate) || !candidate.startsWith(`${base}/`)) continue
936
+ const relative = path.posix.relative(pod.directory, candidate)
937
+ if (
938
+ !matches(sources, relative) ||
939
+ matches(excluded, relative) ||
940
+ matches(privateFiles, relative) ||
941
+ (publicFiles !== null && !matches(publicFiles, relative))
942
+ )
943
+ continue
944
+ const name = candidate.slice(base.length + 1)
945
+ const prior = reactHeaderMap.get(name)
946
+ if (prior && prior !== candidate)
947
+ throw new Error(
948
+ `react-native ${reactNative.version}: two headers are named ${name}`,
949
+ )
950
+ reactHeaderMap.set(name, candidate)
951
+ }
952
+ }
953
+ }
954
+ return reactHeaderMap
955
+ }
420
956
  // each provider's headers by the names its search paths give them, collected
421
957
  // only once a compiled file includes one
422
958
  const podHeaders = new Map<
@@ -446,6 +982,98 @@ export async function collectTurboSources(options: {
446
982
  )
447
983
  return
448
984
  }
985
+ const namespace = include.split('/')[0]!
986
+ let publicHeaders = installedHeaders.get(namespace)
987
+ if (!publicHeaders) {
988
+ publicHeaders = new Map()
989
+ for (const pod of installedHeaderPods) {
990
+ // only read pods which can expose this namespace. other podspecs may
991
+ // use Ruby-computed attributes unrelated to this include.
992
+ if (
993
+ pod.name !== namespace &&
994
+ ![...pod.text.matchAll(/\.header_dir\s*=\s*['"]([^'"]+)['"]/g)].some(
995
+ (match) => match[1] === namespace,
996
+ )
997
+ )
998
+ continue
999
+ const segments = podSegments(pod)
1000
+ const publicGlobs = segments
1001
+ .flatMap((segment) => {
1002
+ const value = podspecList(segment, 'public_header_files')
1003
+ if (value === 'computed')
1004
+ throw new Error(
1005
+ `${pod.name}.podspec: public_header_files is computed by Ruby`,
1006
+ )
1007
+ return value ?? []
1008
+ })
1009
+ .map(globRegex)
1010
+ const privateGlobs = segments
1011
+ .flatMap((segment) => {
1012
+ const value = podspecList(segment, 'private_header_files')
1013
+ if (value === 'computed')
1014
+ throw new Error(
1015
+ `${pod.name}.podspec: private_header_files is computed by Ruby`,
1016
+ )
1017
+ return value ?? []
1018
+ })
1019
+ .map(globRegex)
1020
+ const prefix = pod.directory ? `${pod.directory}/` : ''
1021
+ const mappings = podHeaderMappings(pod)
1022
+ const headerDir = podspecList(segments[0]!, 'header_dir')
1023
+ if (headerDir === 'computed' || (headerDir && headerDir.length !== 1))
1024
+ throw new Error(`${pod.name}.podspec: header_dir is computed by Ruby`)
1025
+ for (const file of podFiles(pod)) {
1026
+ if (!HEADER.test(file)) continue
1027
+ const relative = file.slice(prefix.length)
1028
+ if (publicGlobs.length && !publicGlobs.some((glob) => glob.test(relative)))
1029
+ continue
1030
+ if (privateGlobs.some((glob) => glob.test(relative))) continue
1031
+ const mapping = mappings.find(({ dir }) => file.startsWith(`${dir}/`))
1032
+ const name = mapping
1033
+ ? path.posix.join(mapping.headerDir, file.slice(mapping.dir.length + 1))
1034
+ : path.posix.join(headerDir?.[0] ?? pod.name, path.posix.basename(file))
1035
+ const names = mapping ? [name, path.posix.join(pod.name, name)] : [name]
1036
+ for (const key of names) {
1037
+ const previous = publicHeaders.get(key)
1038
+ if (previous && (previous.root !== pod.root || previous.relative !== file))
1039
+ throw new Error(`two installed pod headers are named ${key}`)
1040
+ publicHeaders.set(key, { label: pod.name, root: pod.root, relative: file })
1041
+ }
1042
+ }
1043
+ }
1044
+ installedHeaders.set(namespace, publicHeaders)
1045
+ }
1046
+ const installed = publicHeaders.get(include)
1047
+ if (installed) {
1048
+ alias(
1049
+ own,
1050
+ original(from.targetName, installed.label, installed.root, installed.relative),
1051
+ )
1052
+ return
1053
+ }
1054
+ if (codegen && HEADER.test(include)) {
1055
+ const generated = path.join(codegen, 'ReactCodegen')
1056
+ const relative = path.posix.normalize(include.replace(/^ReactCodegen\//, ''))
1057
+ if (
1058
+ !relative.startsWith('../') &&
1059
+ !path.posix.isAbsolute(relative) &&
1060
+ fs.existsSync(path.join(generated, relative))
1061
+ ) {
1062
+ alias(own, original(from.targetName, 'ReactCodegen', generated, relative))
1063
+ return
1064
+ }
1065
+ }
1066
+ if (!codegen && HEADER.test(include)) {
1067
+ const name = include.replace(/^ReactCodegen\//, '')
1068
+ if (
1069
+ [...installedCodegenNames].some(
1070
+ (spec) => name.startsWith(`${spec}/`) || name === `${spec}JSI.h`,
1071
+ )
1072
+ ) {
1073
+ pendingCodegen.push({ from, include, quoted })
1074
+ return
1075
+ }
1076
+ }
449
1077
  if (Object.hasOwn(result.files, `${core}/include/${include}`)) return
450
1078
  if (include === 'folly/folly-config.h') {
451
1079
  add(`${core}/include/${include}`, folly.header)
@@ -460,37 +1088,45 @@ export async function collectTurboSources(options: {
460
1088
  )
461
1089
  return
462
1090
  }
463
- const header = dependencyHeader(include)
464
- if (!header) return
465
- const key = `${core}/dependencies/${header.name}/${header.relative}`
466
- if (add(key, header.text)) {
467
- result.sources.push({
468
- file: key,
469
- source: header.source,
470
- sha256: header.sha256,
471
- ...(header.derivation && { derivation: header.derivation }),
472
- })
473
- scanText(
474
- { key, targetName: TURBO_CORE_TARGET, label: '', root: '', relative: include },
475
- header.text,
476
- true,
1091
+ // a React pod header by its header_dir name; a quoted bare name reaches
1092
+ // React-Core's through the header map CocoaPods gives its own sources
1093
+ const react = reactHeaders().get(
1094
+ quoted && !include.includes('/') ? `React/${include}` : include,
1095
+ )
1096
+ if (react) {
1097
+ alias(
1098
+ `${core}/include/${include}`,
1099
+ original(TURBO_CORE_TARGET, 'react-native', reactNative.root, react),
477
1100
  )
1101
+ return
478
1102
  }
479
- alias(`${core}/include/${include}`, key)
1103
+ resolveDependency(include)
480
1104
  }
481
1105
  const scanText = (from: Scan, text: string, dependency = false) => {
482
1106
  for (const [, quote, name] of stripComments(text).matchAll(
483
1107
  /^\s*#\s*(?:include|import)\s*([<"])([^>"\n]+)[>"]/gm,
484
- ))
1108
+ )) {
485
1109
  if (!dependency) resolve(from, name!, quote === '"')
486
1110
  // a quoted include names its own header's directory first
487
- else if (
488
- quote !== '"' ||
489
- !resolveDependency(
490
- path.posix.normalize(path.posix.join(path.posix.dirname(from.relative), name!)),
1111
+ else {
1112
+ const relative = path.posix.normalize(
1113
+ path.posix.join(path.posix.dirname(from.relative), name!),
491
1114
  )
492
- )
493
- resolveDependency(name!)
1115
+ if (quote === '"' && resolveDependency(relative)) {
1116
+ // implementation units live outside SwiftPM's public header directory.
1117
+ // preserve their adjacent quoted includes without adding include guards.
1118
+ const adjacent = path.posix.normalize(
1119
+ path.posix.join(path.posix.dirname(from.key), name!),
1120
+ )
1121
+ const header = `${core}/include/${relative}`
1122
+ if (adjacent !== header)
1123
+ add(
1124
+ adjacent,
1125
+ `#include ${JSON.stringify(path.posix.relative(path.posix.dirname(adjacent), header))}\n`,
1126
+ )
1127
+ } else resolveDependency(name!)
1128
+ }
1129
+ }
494
1130
  }
495
1131
  // a third-party header's includes stay inside the third-party archives
496
1132
  const resolveDependency = (include: string): boolean => {
@@ -501,8 +1137,9 @@ export async function collectTurboSources(options: {
501
1137
  }
502
1138
  const header = dependencyHeader(include)
503
1139
  if (!header) return false
504
- const key = `${core}/dependencies/${header.name}/${header.relative}`
505
- alias(`${core}/include/${include}`, key)
1140
+ // use the original header at its native include path: forwarding headers
1141
+ // with pragma once would change boost's deliberately repeated includes.
1142
+ const key = `${core}/include/${include}`
506
1143
  if (add(key, header.text)) {
507
1144
  result.sources.push({
508
1145
  file: key,
@@ -516,67 +1153,69 @@ export async function collectTurboSources(options: {
516
1153
  true,
517
1154
  )
518
1155
  }
1156
+ if (!dependencyTrees.has(header.name)) {
1157
+ dependencyTrees.add(header.name)
1158
+ for (const name of nitroDependencyIncludes(
1159
+ reactNative.version,
1160
+ reactNative.root,
1161
+ header.name,
1162
+ ))
1163
+ resolveDependency(name)
1164
+ }
519
1165
  return true
520
1166
  }
521
1167
 
522
1168
  // react native's core units
523
- const units = new Set<string>()
524
- for (const glob of REACT_NATIVE_UNITS) {
525
- const candidates = new Set<string>()
526
- walkFiles(reactNative.root, globBase(glob), candidates)
527
- const matched = [...candidates].filter((file) => globRegex(glob).test(file)).sort()
528
- if (matched.length === 0)
529
- throw new Error(`react-native ${reactNative.version} has no ${glob}`)
530
- for (const file of matched) units.add(file)
531
- }
532
- for (const unit of units)
533
- original(TURBO_CORE_TARGET, 'react-native', reactNative.root, unit)
534
-
535
- // the host: the binding installed on the process's JSI runtime, answered
536
- // from the global C++ module map as RCTTurboModuleManager answers a C++
537
- // module. React Native 0.84 passes the runtime to the provider.
538
- const binding = fs.readFileSync(
539
- path.join(
540
- reactNative.root,
541
- 'ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.h',
542
- ),
543
- 'utf8',
544
- )
545
- const withRuntime = binding.includes('TurboModuleProviderFunctionTypeWithRuntime')
546
- add(`${core}/include/PeachJsiRuntime.hpp`, TURBO_RUNTIME_HEADER)
547
- add(
548
- `${core}/include/${TURBO_ENTRY_HEADER}`,
549
- '#pragma once\nextern "C" void peachTurboInitialize();\n',
550
- )
551
- add(
552
- `${core}/include/module.modulemap`,
553
- `module ${TURBO_CORE_TARGET} { header "${TURBO_ENTRY_HEADER}" export * }\n`,
554
- )
555
- const host = `${core}/PeachTurboHost.cpp`
556
- add(host, turboHostSource(withRuntime))
557
- scanText(
558
- {
559
- key: host,
560
- targetName: TURBO_CORE_TARGET,
561
- label: '',
562
- root: core,
563
- relative: 'PeachTurboHost.cpp',
564
- },
565
- result.files[host]!,
566
- )
1169
+ const addUnits = (globs: string[], optional = false) => {
1170
+ const units = new Set<string>()
1171
+ for (const glob of globs) {
1172
+ const candidates = new Set<string>()
1173
+ walkFiles(reactNative.root, globBase(glob), candidates)
1174
+ const matched = [...candidates].filter((file) => globRegex(glob).test(file)).sort()
1175
+ if (matched.length === 0) {
1176
+ if (optional) continue
1177
+ throw new Error(`react-native ${reactNative.version} has no ${glob}`)
1178
+ }
1179
+ for (const file of matched) units.add(file)
1180
+ }
1181
+ for (const unit of units)
1182
+ original(TURBO_CORE_TARGET, 'react-native', reactNative.root, unit)
1183
+ }
1184
+ addUnits(REACT_NATIVE_UNITS)
1185
+
1186
+ let objc = false
1187
+ let fabric = false
1188
+ const objcClasses = new Set<string>()
1189
+ const deferredDepUnits: {
1190
+ targetName: string
1191
+ label: string
1192
+ moduleName: string
1193
+ root: string
1194
+ relative: string
1195
+ companionHeader?: string
1196
+ }[] = []
567
1197
 
568
1198
  // generated code a provider does not ship comes from the app's own codegen,
569
1199
  // the ReactCodegen pod pod install builds
570
- let codegen: string | null = null
571
1200
  for (const provider of providers) {
572
1201
  const targetName = providerTarget(provider.info.name)
573
1202
  const label = provider.info.name
574
- const root = provider.info.root
575
1203
  result.targets.push(target(targetName, [TURBO_CORE_TARGET]))
576
- const pod = readPod(provider)
1204
+ const pod = readPod(provider, options.installedPods?.get(provider.name))
1205
+ const root = pod.root
1206
+ const nitro = nitroRegisteredNames(root)
1207
+ fabric ||= fabricComponents(root)
1208
+ if (pod.installed) {
1209
+ result.libraries ??= {}
1210
+ result.libraries[targetName] = fs
1211
+ .readFileSync(pod.installed.library)
1212
+ .toString('base64')
1213
+ }
577
1214
  const files = podFiles(pod)
1215
+ const managers = viewManagers(root, files)
578
1216
  const headers = new Map<string, { label: string; root: string; relative: string }>()
579
1217
  podHeaders.set(targetName, headers)
1218
+ const mappings = podHeaderMappings(pod)
580
1219
  // CocoaPods flattens a pod's headers: `Name.h` and `<pod>/Name.h`
581
1220
  const header = (
582
1221
  names: string[],
@@ -589,29 +1228,194 @@ export async function collectTurboSources(options: {
589
1228
  headers.set(name, entry)
590
1229
  }
591
1230
  }
1231
+ const manifest: unknown = JSON.parse(
1232
+ fs.readFileSync(path.join(root, 'package.json'), 'utf8'),
1233
+ )
1234
+ const codegenConfig =
1235
+ object(manifest) && object(manifest.codegenConfig) ? manifest.codegenConfig : null
592
1236
  const sources: string[] = []
1237
+ const codegenObjCSources: string[] = []
1238
+ const swiftSources: string[] = []
593
1239
  const loads: { file: string; load: ReturnType<typeof transcribeLoad> }[] = []
1240
+ let providerObjC = false
594
1241
  for (const file of files) {
595
1242
  if (HEADER.test(file)) {
1243
+ const mapping = mappings.find(({ dir }) => file.startsWith(`${dir}/`))
596
1244
  const base = path.posix.basename(file)
597
- header([base, `${pod.name}/${base}`], { label, root, relative: file })
1245
+ const dir = path.posix.basename(path.posix.dirname(file))
1246
+ header(
1247
+ mapping
1248
+ ? [
1249
+ path.posix.join(mapping.headerDir, file.slice(mapping.dir.length + 1)),
1250
+ path.posix.join(
1251
+ pod.name,
1252
+ mapping.headerDir,
1253
+ file.slice(mapping.dir.length + 1),
1254
+ ),
1255
+ ]
1256
+ : [
1257
+ base,
1258
+ `${pod.name}/${base}`,
1259
+ ...(dir && dir !== '.' && dir !== pod.name ? [`${dir}/${base}`] : []),
1260
+ ],
1261
+ { label, root, relative: file },
1262
+ )
598
1263
  } else if (UNIT.test(file)) sources.push(file)
599
1264
  else if (OBJC.test(file)) {
600
1265
  const text = fs.readFileSync(path.join(root, file), 'utf8')
601
- if (CODEGEN_OBJC.test(text)) continue
602
- loads.push({ file, load: transcribeLoad(text, `${label}/${file}`) })
603
- } else if (file.endsWith('.swift'))
604
- throw new Error(
605
- `${label}/${file}: Swift TurboModule sources are not supported yet`,
1266
+ if (CODEGEN_OBJC.test(text)) codegenObjCSources.push(file)
1267
+ else if (text.includes(REGISTRATION))
1268
+ loads.push({ file, load: transcribeLoad(text, `${label}/${file}`) })
1269
+ else {
1270
+ sources.push(file)
1271
+ providerObjC = true
1272
+ const stripped = stripComments(text)
1273
+ if (OBJC_TURBO.test(stripped) || OBJC_BRIDGE.test(stripped)) {
1274
+ for (const [, className] of stripped.matchAll(/@implementation\s+(\w+)/g))
1275
+ if (!managers.has(className!)) objcClasses.add(className!)
1276
+ for (const [, className] of stripped.matchAll(
1277
+ /\bRCT_EXTERN_MODULE\s*\(\s*(\w+)/g,
1278
+ ))
1279
+ if (!managers.has(className!)) objcClasses.add(className!)
1280
+ for (const [, className] of stripped.matchAll(
1281
+ /\bRCT_EXTERN_REMAP_MODULE\s*\(\s*\w*\s*,\s*(\w+)/g,
1282
+ ))
1283
+ if (!managers.has(className!)) objcClasses.add(className!)
1284
+ }
1285
+ }
1286
+ } else if (file.endsWith('.swift') && !nitro) swiftSources.push(file)
1287
+ }
1288
+ if (providerObjC) sources.push(...codegenObjCSources)
1289
+ const depUnits: {
1290
+ label: string
1291
+ moduleName: string
1292
+ root: string
1293
+ relative: string
1294
+ companionHeader?: string
1295
+ }[] = []
1296
+ const depSwiftPods: {
1297
+ moduleName: string
1298
+ label: string
1299
+ root: string
1300
+ files: string[]
1301
+ }[] = []
1302
+ for (const dep of podspecDependencies(pod.text)) {
1303
+ const resolved = await resolveExternalTurboPod(dep.name, dep.version)
1304
+ if (!resolved) continue
1305
+ const swiftFilesForDep: string[] = []
1306
+ for (const file of resolved.files) {
1307
+ if (HEADER.test(file)) {
1308
+ const base = path.posix.basename(file)
1309
+ const dir = path.posix.basename(path.posix.dirname(file))
1310
+ const slash = file.indexOf('/')
1311
+ const subRelative = slash !== -1 ? file.slice(slash + 1) : file
1312
+ header(
1313
+ [
1314
+ ...new Set([
1315
+ base,
1316
+ `${resolved.name}/${base}`,
1317
+ `${resolved.moduleName}/${base}`,
1318
+ file,
1319
+ subRelative,
1320
+ ...(dir && dir !== '.' ? [`${dir}/${base}`] : []),
1321
+ ]),
1322
+ ],
1323
+ { label: resolved.name, root: resolved.root, relative: file },
1324
+ )
1325
+ } else if (UNIT.test(file) || OBJC.test(file)) {
1326
+ const stem = file.replace(/\.[^.]+$/, '')
1327
+ const hasCompanionHeader = resolved.files.some(
1328
+ (f) => HEADER.test(f) && f.replace(/\.[^.]+$/, '') === stem,
1329
+ )
1330
+ depUnits.push({
1331
+ label: resolved.name,
1332
+ moduleName: resolved.moduleName,
1333
+ root: resolved.root,
1334
+ relative: file,
1335
+ companionHeader: hasCompanionHeader ? `${stem}.h` : undefined,
1336
+ })
1337
+ } else if (file.endsWith('.swift')) {
1338
+ swiftFilesForDep.push(file)
1339
+ }
1340
+ }
1341
+ if (swiftFilesForDep.length > 0) {
1342
+ depSwiftPods.push({
1343
+ moduleName: resolved.moduleName,
1344
+ label: resolved.name,
1345
+ root: resolved.root,
1346
+ files: swiftFilesForDep,
1347
+ })
1348
+ }
1349
+ }
1350
+ for (const depPod of depSwiftPods) {
1351
+ if (!result.targets.some((t) => t.name === depPod.moduleName)) {
1352
+ result.targets.push(target(depPod.moduleName, []))
1353
+ for (const file of depPod.files)
1354
+ result.externalPodSources.push({
1355
+ moduleName: depPod.moduleName,
1356
+ file: original(depPod.moduleName, depPod.label, depPod.root, file),
1357
+ })
1358
+ add(
1359
+ `${targetPath(depPod.moduleName)}/_PeachTurboSwiftSupport.swift`,
1360
+ ['@_exported import Foundation', '@_exported import UIKit', ''].join('\n'),
606
1361
  )
1362
+ }
607
1363
  }
608
- if (loads.length === 0 && !registers(root, files))
609
- throw new Error(`${label}: its pod sources register no C++ TurboModule`)
610
- const manifest: unknown = JSON.parse(
611
- fs.readFileSync(path.join(root, 'package.json'), 'utf8'),
612
- )
613
- const codegenConfig =
614
- object(manifest) && object(manifest.codegenConfig) ? manifest.codegenConfig : null
1364
+ if (swiftSources.length > 0 || depSwiftPods.length > 0) {
1365
+ const moduleName = podspecList(pod.text, 'module_name')
1366
+ const swiftModule =
1367
+ (Array.isArray(moduleName) ? moduleName[0] : undefined) ??
1368
+ pod.name.replace(/[^A-Za-z0-9_]/g, '_').replace(/^[0-9]/, '_')
1369
+ result.targets.push(
1370
+ target(
1371
+ swiftModule,
1372
+ depSwiftPods.map((dep) => dep.moduleName),
1373
+ ),
1374
+ )
1375
+ for (const file of swiftSources) original(swiftModule, label, root, file)
1376
+ const usesPassKit = swiftSources.some((file) =>
1377
+ /\bimport\s+PassKit\b/.test(fs.readFileSync(path.join(root, file), 'utf8')),
1378
+ )
1379
+ add(
1380
+ `${targetPath(swiftModule)}/_PeachTurboSwiftSupport.swift`,
1381
+ [
1382
+ '@_exported import Foundation',
1383
+ '@_exported import UIKit',
1384
+ 'import PeachFoundation',
1385
+ ...(usesPassKit ? ['import PassKit'] : []),
1386
+ '',
1387
+
1388
+ 'open class RCTViewManager: NSObject {',
1389
+ ' public override init() { super.init() }',
1390
+ ' open func view() -> UIView! { nil }',
1391
+ ' open class func requiresMainQueueSetup() -> Bool { false }',
1392
+ '}',
1393
+ '',
1394
+ 'public func RCTPresentedViewController() -> UIViewController? {',
1395
+ ' UIApplication.shared.keyWindow?.rootViewController',
1396
+ '}',
1397
+ ...(usesPassKit
1398
+ ? [
1399
+ '',
1400
+ 'extension PKAddPaymentPassViewControllerDelegate {',
1401
+ ' public func addPaymentPassViewController(',
1402
+ ' _ controller: PKAddPaymentPassViewController,',
1403
+ ' generateRequestWithCertificateChain certificates: [Data],',
1404
+ ' nonce: Data,',
1405
+ ' nonceSignature: Data',
1406
+ ' ) async -> PKAddPaymentPassRequest {',
1407
+ ' PKAddPaymentPassRequest()',
1408
+ ' }',
1409
+ '}',
1410
+ ]
1411
+ : []),
1412
+ '',
1413
+ ].join('\n'),
1414
+ )
1415
+ }
1416
+ if (loads.length === 0 && !registers(root, files) && !fabricComponents(root))
1417
+ throw new Error(`${label}: its pod sources register no TurboModule`)
1418
+ objc ||= providerObjC
615
1419
  if (codegenConfig && codegenConfig.includesGeneratedCode !== true) {
616
1420
  if (typeof codegenConfig.name !== 'string')
617
1421
  throw new Error(`${label}: codegenConfig has no name`)
@@ -623,17 +1427,42 @@ export async function collectTurboSources(options: {
623
1427
  const spec = codegenConfig.name
624
1428
  for (const file of [...owned].sort()) {
625
1429
  const base = path.posix.basename(file)
626
- if (!base.startsWith(`${spec}JSI`)) continue
1430
+ // the Objective-C spec classes only an Objective-C module reaches
1431
+ const objcSpec = providerObjC && file.startsWith(`${spec}/`)
1432
+ // the Fabric component sources, named by the path codegen gives them
1433
+ const component = file.startsWith(`react/renderer/components/${spec}/`)
1434
+ if (!base.startsWith(`${spec}JSI`) && !objcSpec && !component) continue
627
1435
  if (HEADER.test(base))
628
- header([base, `${pod.name}/${base}`, `ReactCodegen/${base}`], {
629
- label: 'ReactCodegen',
630
- root: generated,
631
- relative: file,
632
- })
1436
+ header(
1437
+ component
1438
+ ? [file]
1439
+ : [
1440
+ base,
1441
+ `${pod.name}/${base}`,
1442
+ `ReactCodegen/${base}`,
1443
+ `ReactCodegen/${file}`,
1444
+ `${spec}/${base}`,
1445
+ ],
1446
+ {
1447
+ label: 'ReactCodegen',
1448
+ root: generated,
1449
+ relative: file,
1450
+ },
1451
+ )
633
1452
  else original(targetName, 'ReactCodegen', generated, file)
634
1453
  }
635
1454
  }
636
1455
  for (const file of sources) original(targetName, label, root, file)
1456
+ for (const unit of depUnits) {
1457
+ if (!unit.companionHeader) {
1458
+ result.externalPodSources.push({
1459
+ moduleName: unit.moduleName,
1460
+ file: original(targetName, unit.label, unit.root, unit.relative),
1461
+ })
1462
+ } else {
1463
+ deferredDepUnits.push({ targetName, ...unit })
1464
+ }
1465
+ }
637
1466
  const declared: string[] = []
638
1467
  for (const [count, { file, load }] of loads.entries()) {
639
1468
  const symbol = `peach_turbo_load_${targetName}_${count}`
@@ -665,29 +1494,255 @@ export async function collectTurboSources(options: {
665
1494
  )
666
1495
  }
667
1496
 
1497
+ // the host: the binding installed on the process's JSI runtime. C++ modules
1498
+ // alone are answered from the global C++ module map as RCTTurboModuleManager
1499
+ // answers a C++ module; an Objective-C module brings React Native's own
1500
+ // RCTTurboModuleManager, with the app's codegen module providers. React
1501
+ // Native 0.84 passes the runtime to the provider.
1502
+ const binding = fs.readFileSync(
1503
+ path.join(
1504
+ reactNative.root,
1505
+ 'ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.h',
1506
+ ),
1507
+ 'utf8',
1508
+ )
1509
+ const withRuntime = binding.includes('TurboModuleProviderFunctionTypeWithRuntime')
1510
+ add(`${core}/include/PeachJsiRuntime.hpp`, TURBO_RUNTIME_HEADER)
1511
+ add(
1512
+ `${core}/include/${TURBO_ENTRY_HEADER}`,
1513
+ '#pragma once\nextern "C" void peachTurboInitialize();\n',
1514
+ )
1515
+ add(
1516
+ `${core}/include/module.modulemap`,
1517
+ `module ${TURBO_CORE_TARGET} { header "${TURBO_ENTRY_HEADER}" export * }\n`,
1518
+ )
1519
+ let decoratorHasPerformanceLogger = false
1520
+ if (objc) {
1521
+ // the installed react native declaration owns this ABI, including for
1522
+ // unpublished workspace versions whose package version is 1000.0.0.
1523
+ const decoratorHeader = fs.readFileSync(
1524
+ path.join(reactNative.root, 'React/Base/RCTBridgeModuleDecorator.h'),
1525
+ 'utf8',
1526
+ )
1527
+ const initializer = /-\s*\(instancetype\)\s*initWithViewRegistry\s*:[^;]+;/.exec(
1528
+ decoratorHeader,
1529
+ )?.[0]
1530
+ const selector = initializer
1531
+ ? [...initializer.matchAll(/(\w+)\s*:\s*\([^)]+\)/g)]
1532
+ .map((match) => match[1])
1533
+ .join(':')
1534
+ : undefined
1535
+ if (
1536
+ selector ===
1537
+ 'initWithViewRegistry:moduleRegistry:bundleManager:callableJSModules:launchOptions:performanceLogger'
1538
+ )
1539
+ decoratorHasPerformanceLogger = true
1540
+ else if (
1541
+ selector !== 'initWithViewRegistry:moduleRegistry:bundleManager:callableJSModules'
1542
+ )
1543
+ throw new Error(
1544
+ `react-native ${reactNative.version}: unsupported RCTBridgeModuleDecorator initializer`,
1545
+ )
1546
+ // Apple's Foundation.h transitively includes <ctype.h>, and CF_OPTIONS
1547
+ // typedefs NSUInteger under __cplusplus so RCTParserUtils.m and
1548
+ // RCTConvert.mm compile unchanged against the published distribution.
1549
+ add(
1550
+ `${core}/include/PeachTurboPrefix.pch`,
1551
+ [
1552
+ '#pragma once',
1553
+ '#include <ctype.h>',
1554
+ '#define DISABLE_INIT_WITH_INFO_PLIST 1',
1555
+ '#ifdef __OBJC__',
1556
+ '#import <UIKit/UIKit.h>',
1557
+ '#endif',
1558
+ '#if defined(__OBJC__) && !defined(__swift__)',
1559
+ '@class NSURLConnection;',
1560
+ '@class NSURLAuthenticationChallenge;',
1561
+ '@class NSURLProtectionSpace;',
1562
+ '@protocol NSURLConnectionDelegate <NSObject>',
1563
+ '@optional',
1564
+ '- (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge;',
1565
+ '- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace;',
1566
+ '- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge;',
1567
+ '@end',
1568
+ '@interface UIScreen (PeachTurboRuntime)',
1569
+ '@property(nonatomic) CGFloat brightness;',
1570
+ '@end',
1571
+ '@interface UIApplication (PeachTurboRuntime)',
1572
+ '@property(nonatomic, getter=isIdleTimerDisabled) BOOL idleTimerDisabled;',
1573
+ '@end',
1574
+ '@interface NSUserDefaults (PeachTurboRuntime)',
1575
+ '- (NSString *)stringForKey:(NSString *)defaultName;',
1576
+ '- (void)setObject:(id)value forKey:(NSString *)defaultName;',
1577
+ '- (BOOL)synchronize;',
1578
+ '@end',
1579
+ '@interface NSKeyedUnarchiver (PeachTurboRuntime)',
1580
+ '+ (id)unarchivedObjectOfClasses:(NSSet<Class> *)classes fromData:(NSData *)data error:(NSError **)error;',
1581
+ '@end',
1582
+ '@interface NSNotification (PeachTurboRuntime)',
1583
+ '@property (nullable, readonly, copy) NSDictionary *userInfo;',
1584
+ '@end',
1585
+ '#endif',
1586
+ 'typedef struct __CFBundle *CFBundleRef;',
1587
+ '#ifndef NSLocalizedStringWithDefaultValue',
1588
+ '#define NSLocalizedStringWithDefaultValue(key, tbl, bundle, val, comment) ((void)(tbl), (void)(bundle), (void)(comment), (val) ?: (key))',
1589
+ '#endif',
1590
+ '@interface NSObject (PeachTurboThreadPerform)',
1591
+ '- (void)performSelector:(SEL _Nonnull)aSelector onThread:(NSThread * _Nullable)thr withObject:(id _Nullable)arg waitUntilDone:(BOOL)wait;',
1592
+ '+ (void)performSelector:(SEL _Nonnull)aSelector onThread:(NSThread * _Nullable)thr withObject:(id _Nullable)arg waitUntilDone:(BOOL)wait;',
1593
+ '@end',
1594
+ '#ifdef __cplusplus',
1595
+ 'extern "C" {',
1596
+ '#endif',
1597
+ 'void peachTurboDispatchAsync(dispatch_block_t block);',
1598
+ 'CFBundleRef CFBundleGetMainBundle(void);',
1599
+ 'CFStringRef CFBundleGetIdentifier(CFBundleRef bundle);',
1600
+ 'CFTypeRef CFBundleGetValueForInfoDictionaryKey(CFBundleRef bundle, CFStringRef key);',
1601
+ '#ifdef __cplusplus',
1602
+ '}',
1603
+ '#endif',
1604
+ 'static inline void _peach_dispatch_async(dispatch_queue_t _Nullable q, dispatch_block_t _Nonnull b) { (void)q; peachTurboDispatchAsync(b); }',
1605
+ 'static inline void _peach_dispatch_after(dispatch_time_t w, dispatch_queue_t _Nullable q, dispatch_block_t _Nonnull b) { (void)q; dispatch_block_t copied = [b copy]; dispatch_after(w, dispatch_get_global_queue(QOS_CLASS_DEFAULT, 0), ^{ peachTurboDispatchAsync(copied); }); }',
1606
+ '#define dispatch_async _peach_dispatch_async',
1607
+ '#define dispatch_after _peach_dispatch_after',
1608
+ '#endif',
1609
+ '',
1610
+ ].join('\n'),
1611
+ )
1612
+ add(
1613
+ `${core}/include/PassKit/PassKit.h`,
1614
+ '#pragma once\n#import <Foundation/Foundation.h>\n',
1615
+ )
1616
+ addUnits(REACT_NATIVE_OBJC_UNITS)
1617
+ addUnits(REACT_NATIVE_OBJC_VERSIONED_UNITS, true)
1618
+ if (decoratorHasPerformanceLogger)
1619
+ addUnits([
1620
+ 'React/Base/RCTPerformanceLogger.mm',
1621
+ 'ReactCommon/cxxreact/ReactMarker.cpp',
1622
+ ])
1623
+ // glog, which RCTTurboModule logs a fatal error through, as its configured
1624
+ // pod builds it
1625
+ for (const { relative, source, text, sha256, configured } of glogSources()) {
1626
+ const key = `${core}/dependencies/glog/${relative}`
1627
+ add(key, text)
1628
+ result.sources.push({
1629
+ file: key,
1630
+ source,
1631
+ sha256,
1632
+ ...(configured && { configured }),
1633
+ })
1634
+ if (relative.startsWith('src/glog/'))
1635
+ alias(`${core}/include/${relative.slice('src/'.length)}`, key)
1636
+ }
1637
+ // the pod's header search path is src/, which base/mutex.h's "config.h"
1638
+ // reaches
1639
+ alias(
1640
+ `${core}/dependencies/glog/src/base/config.h`,
1641
+ `${core}/dependencies/glog/src/config.h`,
1642
+ )
1643
+ codegen ??= (await runInstalledTurboCodegen(options.appRoot, options.codegenDir))
1644
+ .generatedRoot
1645
+ const generated = path.join(codegen, 'ReactCodegen')
1646
+ original(TURBO_CORE_TARGET, 'ReactCodegen', generated, 'RCTModuleProviders.mm')
1647
+ alias(
1648
+ `${core}/include/ReactCodegen/RCTModuleProviders.h`,
1649
+ original(TURBO_CORE_TARGET, 'ReactCodegen', generated, 'RCTModuleProviders.h'),
1650
+ )
1651
+ }
1652
+ if (fabric) {
1653
+ for (const pod of await installedFabricSources(reactNative.root)) {
1654
+ const swift = pod.files.some((file) => file.endsWith('.swift'))
1655
+ const name = swift ? pod.module : TURBO_CORE_TARGET
1656
+ if (swift) {
1657
+ if (!pod.swiftVersion || !/^[56](?:\.0)?$/.test(pod.swiftVersion))
1658
+ throw new Error(
1659
+ pod.module + ': renderer pod must declare its Swift language version',
1660
+ )
1661
+ result.targets.push({
1662
+ ...target(name, []),
1663
+ languageMode: Number(pod.swiftVersion),
1664
+ cxxInterop: false,
1665
+ })
1666
+ }
1667
+ for (const file of pod.files) original(name, 'react-native', reactNative.root, file)
1668
+ }
1669
+ const patterns = await installedRendererDependencyGlobs(reactNative.root)
1670
+ const matchers = new Map(
1671
+ Object.entries(patterns).map(([name, globs]) => [name, globs.map(globRegex)]),
1672
+ )
1673
+ for (const unit of nitroDependencySources(
1674
+ reactNative.version,
1675
+ reactNative.root,
1676
+ (name, relative) =>
1677
+ matchers.get(name)?.some((pattern) => pattern.test(relative)) ?? false,
1678
+ )) {
1679
+ const key = `${core}/dependencies/${unit.name}/${unit.relative}`
1680
+ if (add(key, unit.text)) {
1681
+ result.sources.push({ file: key, source: unit.source, sha256: unit.sha256 })
1682
+ scanText(
1683
+ {
1684
+ key,
1685
+ targetName: TURBO_CORE_TARGET,
1686
+ label: '',
1687
+ root: '',
1688
+ relative: unit.includePath,
1689
+ },
1690
+ unit.text,
1691
+ true,
1692
+ )
1693
+ }
1694
+ }
1695
+ }
1696
+ const hostName = objc ? 'PeachTurboHost.mm' : 'PeachTurboHost.cpp'
1697
+ const host = `${core}/${hostName}`
1698
+ add(
1699
+ host,
1700
+ objc
1701
+ ? turboObjCHostSource([...objcClasses].sort(), decoratorHasPerformanceLogger)
1702
+ : turboHostSource(withRuntime),
1703
+ )
1704
+ scanText(
1705
+ {
1706
+ key: host,
1707
+ targetName: TURBO_CORE_TARGET,
1708
+ label: '',
1709
+ root: core,
1710
+ relative: hostName,
1711
+ },
1712
+ result.files[host]!,
1713
+ )
1714
+
668
1715
  // every collected file's includes, transitively
669
- for (let next = pending.shift(); next; next = pending.shift())
670
- scanText(next, result.files[next.key]!)
1716
+ for (;;) {
1717
+ for (let next = pending.shift(); next; next = pending.shift())
1718
+ scanText(next, result.files[next.key]!)
1719
+ let addedDep = false
1720
+ for (let i = deferredDepUnits.length - 1; i >= 0; i--) {
1721
+ const unit = deferredDepUnits[i]!
1722
+ const hdrKey = `${targetPath(unit.targetName)}/upstream/${unit.label}/${unit.companionHeader!}`
1723
+ if (Object.hasOwn(result.files, hdrKey)) {
1724
+ deferredDepUnits.splice(i, 1)
1725
+ result.externalPodSources.push({
1726
+ moduleName: unit.moduleName,
1727
+ file: original(unit.targetName, unit.label, unit.root, unit.relative),
1728
+ })
1729
+ addedDep = true
1730
+ }
1731
+ }
1732
+ if (!addedDep) break
1733
+ }
1734
+ // mapped public pod headers can themselves import their generated specs.
1735
+ if (pendingCodegen.length) {
1736
+ codegen ??= (await runInstalledTurboCodegen(options.appRoot, options.codegenDir))
1737
+ .generatedRoot
1738
+ for (const { from, include, quoted } of pendingCodegen) resolve(from, include, quoted)
1739
+ for (let next = pending.shift(); next; next = pending.shift())
1740
+ scanText(next, result.files[next.key]!)
1741
+ }
671
1742
  return result
672
1743
  }
673
1744
 
674
- function turboHostSource(withRuntime: boolean): string {
675
- return `// React Native's TurboModuleBinding on the process's JSI runtime, answered
676
- // from the global C++ module map as RCTTurboModuleManager answers a C++ module:
677
- // each module is created once, with the JS thread's call invoker.
678
- #include "${TURBO_ENTRY_HEADER}"
679
- #include "PeachJsiRuntime.hpp"
680
- #include <ReactCommon/CallInvoker.h>
681
- #include <ReactCommon/CxxTurboModuleUtils.h>
682
- #include <ReactCommon/TurboModuleBinding.h>
683
- #include <deque>
684
- #include <memory>
685
- #include <string>
686
- #include <unordered_map>
687
-
688
- using namespace facebook;
689
-
690
- namespace {
1745
+ const JS_CALL_INVOKER = `namespace {
691
1746
  // async work runs once the host's current call returns; sync work runs
692
1747
  // inline, both on the one JS thread.
693
1748
  class JsCallInvoker final : public react::CallInvoker {
@@ -713,6 +1768,25 @@ class JsCallInvoker final : public react::CallInvoker {
713
1768
  std::deque<react::CallFunc> pending;
714
1769
  };
715
1770
 
1771
+ `
1772
+
1773
+ function turboHostSource(withRuntime: boolean): string {
1774
+ return `// React Native's TurboModuleBinding on the process's JSI runtime, answered
1775
+ // from the global C++ module map as RCTTurboModuleManager answers a C++ module:
1776
+ // each module is created once, with the JS thread's call invoker.
1777
+ #include "${TURBO_ENTRY_HEADER}"
1778
+ #include "PeachJsiRuntime.hpp"
1779
+ #include <ReactCommon/CallInvoker.h>
1780
+ #include <ReactCommon/CxxTurboModuleUtils.h>
1781
+ #include <ReactCommon/TurboModuleBinding.h>
1782
+ #include <deque>
1783
+ #include <memory>
1784
+ #include <string>
1785
+ #include <unordered_map>
1786
+
1787
+ using namespace facebook;
1788
+
1789
+ ${JS_CALL_INVOKER}
716
1790
  std::shared_ptr<JsCallInvoker> invoker;
717
1791
  std::unordered_map<std::string, std::shared_ptr<react::TurboModule>> modules;
718
1792
  std::string names;
@@ -752,3 +1826,301 @@ extern "C" __attribute__((export_name("peach_turbo_module_names"))) const char*
752
1826
  }
753
1827
  `
754
1828
  }
1829
+
1830
+ function turboObjCHostSource(
1831
+ objcClasses: readonly string[],
1832
+ decoratorHasPerformanceLogger: boolean,
1833
+ ): string {
1834
+ const classNamesList = objcClasses.map((name) => `@${JSON.stringify(name)}`).join(', ')
1835
+ return `// React Native's RCTTurboModuleManager on the process's JSI runtime, set up
1836
+ // as a bridgeless RCTInstance sets it up, with the delegate an app gets from
1837
+ // RCTDefaultReactNativeFactoryDelegate: module providers from the app's codegen
1838
+ // (RCTModuleProviders), module classes from their RCT_EXPORT_MODULE
1839
+ // registration. React Native's core modules are the engine's own, so the
1840
+ // RCTCoreModulesClassProvider and DefaultTurboModules fallbacks are not linked.
1841
+ #include "${TURBO_ENTRY_HEADER}"
1842
+ #include "PeachJsiRuntime.hpp"
1843
+ #import <CoreGraphics/CoreGraphics.h>
1844
+ #import <Security/Security.h>
1845
+ #import <Block.h>
1846
+ #import <objc/runtime.h>
1847
+ #import <React/RCTBridge+Private.h>
1848
+ #import <React/RCTBridge.h>
1849
+ #import <React/RCTBridgeModuleDecorator.h>
1850
+ ${decoratorHasPerformanceLogger ? '#import <React/RCTPerformanceLogger.h>' : ''}
1851
+ #import <React/RCTBridgeModule.h>
1852
+ #import <React/RCTEventDispatcherProtocol.h>
1853
+ #import <ReactCodegen/RCTModuleProviders.h>
1854
+ #import <ReactCommon/CxxTurboModuleUtils.h>
1855
+ #import <ReactCommon/RCTTurboModuleManager.h>
1856
+ #include <os/log.h>
1857
+ #include <deque>
1858
+ #include <limits>
1859
+ #include <memory>
1860
+ #include <string>
1861
+
1862
+ extern "C" {
1863
+ BOOL objc_create_block_classes_as_subclasses_of(Class super);
1864
+ #undef dispatch_async
1865
+ static void *peachBlockCopy(const void *self, SEL) {
1866
+ return _Block_copy(self);
1867
+ }
1868
+ static void *peachBlockCopyWithZone(const void *self, SEL, void *) {
1869
+ return _Block_copy(self);
1870
+ }
1871
+ __attribute__((weak)) const CGPoint CGPointZero = {0, 0};
1872
+ __attribute__((weak)) const CGSize CGSizeZero = {0, 0};
1873
+ __attribute__((weak)) const CGRect CGRectZero = {{0, 0}, {0, 0}};
1874
+ __attribute__((weak)) const CGRect CGRectNull = {
1875
+ {std::numeric_limits<CGFloat>::infinity(), std::numeric_limits<CGFloat>::infinity()},
1876
+ {0, 0}};
1877
+ __attribute__((weak)) const CGRect CGRectInfinite = {
1878
+ {-std::numeric_limits<CGFloat>::max() / 2, -std::numeric_limits<CGFloat>::max() / 2},
1879
+ {std::numeric_limits<CGFloat>::max(), std::numeric_limits<CGFloat>::max()}};
1880
+ __attribute__((weak)) const CGAffineTransform CGAffineTransformIdentity = {1, 0, 0, 1, 0, 0};
1881
+ __attribute__((weak)) bool os_log_type_enabled(os_log_t, os_log_type_t) {
1882
+ return false;
1883
+ }
1884
+ __attribute__((weak)) void _os_log_impl(
1885
+ void *,
1886
+ os_log_t,
1887
+ os_log_type_t,
1888
+ const char *,
1889
+ uint8_t *,
1890
+ uint32_t) {}
1891
+ __attribute__((weak)) void dispatch_barrier_async(
1892
+ dispatch_queue_t queue,
1893
+ dispatch_block_t block) {
1894
+ dispatch_async(queue, block);
1895
+ }
1896
+ __attribute__((weak)) extern const SecKeyAlgorithm kSecKeyAlgorithmRSAEncryptionPKCS1 = (__bridge SecKeyAlgorithm)@"algid:encrypt:RSA:PKCS1";
1897
+ __attribute__((weak)) extern const SecKeyAlgorithm kSecKeyAlgorithmRSASignatureMessagePKCS1v15SHA256 = (__bridge SecKeyAlgorithm)@"algid:sign:RSA:message-PKCS1v15:SHA256";
1898
+ __attribute__((weak)) extern const SecKeyAlgorithm kSecKeyAlgorithmRSAEncryptionOAEPSHA256 = (__bridge SecKeyAlgorithm)@"algid:encrypt:RSA:OAEP-SHA256";
1899
+ __attribute__((weak)) CFDataRef SecKeyCreateEncryptedData(SecKeyRef, SecKeyAlgorithm, CFDataRef, CFErrorRef *) {
1900
+ return nullptr;
1901
+ }
1902
+ __attribute__((weak)) CFDataRef SecKeyCreateDecryptedData(SecKeyRef, SecKeyAlgorithm, CFDataRef, CFErrorRef *) {
1903
+ return nullptr;
1904
+ }
1905
+ __attribute__((weak)) CFDataRef SecCertificateCopyData(SecCertificateRef) {
1906
+ return nullptr;
1907
+ }
1908
+ __attribute__((weak)) CFStringRef SecCertificateCopySubjectSummary(SecCertificateRef) {
1909
+ return nullptr;
1910
+ }
1911
+ __attribute__((weak)) SecPolicyRef SecPolicyCreateBasicX509(void) {
1912
+ return nullptr;
1913
+ }
1914
+ __attribute__((weak)) SecPolicyRef SecPolicyCreateSSL(Boolean, CFStringRef) {
1915
+ return nullptr;
1916
+ }
1917
+ __attribute__((weak)) OSStatus SecTrustCreateWithCertificates(CFTypeRef, CFTypeRef, SecTrustRef *trust) {
1918
+ if (trust) *trust = nullptr;
1919
+ return -50;
1920
+ }
1921
+ __attribute__((weak)) OSStatus SecTrustSetPolicies(SecTrustRef, CFTypeRef) {
1922
+ return -50;
1923
+ }
1924
+ __attribute__((weak)) bool SecTrustEvaluateWithError(SecTrustRef, CFErrorRef *error) {
1925
+ if (error) *error = nullptr;
1926
+ return false;
1927
+ }
1928
+ __attribute__((weak)) OSStatus SecTrustGetTrustResult(SecTrustRef, SecTrustResultType *result) {
1929
+ if (result) *result = kSecTrustResultInvalid;
1930
+ return -50;
1931
+ }
1932
+ __attribute__((weak)) SecKeyRef SecTrustCopyKey(SecTrustRef) {
1933
+ return nullptr;
1934
+ }
1935
+ __attribute__((weak)) CFIndex SecTrustGetCertificateCount(SecTrustRef) {
1936
+ return 0;
1937
+ }
1938
+ __attribute__((weak)) CFDictionaryRef SecTrustCopyResult(SecTrustRef) {
1939
+ return nullptr;
1940
+ }
1941
+ extern void* _TtC15PeachFoundation7NSProxy __asm__("._OBJC_CLASS__TtC15PeachFoundation7NSProxy");
1942
+ __attribute__((weak)) void* peach_objc_ref_NSProxy __asm__("._OBJC_REF_CLASS_NSProxy") =
1943
+ &_TtC15PeachFoundation7NSProxy;
1944
+ extern void* _TtC10Foundation12UserDefaults __asm__("._OBJC_CLASS__TtC10Foundation12UserDefaults");
1945
+ __attribute__((weak)) void* peach_objc_ref_NSUserDefaults __asm__("._OBJC_REF_CLASS_NSUserDefaults") =
1946
+ &_TtC10Foundation12UserDefaults;
1947
+ extern void* _TtC15PeachFoundation18NSAssertionHandler __asm__("._OBJC_CLASS__TtC15PeachFoundation18NSAssertionHandler");
1948
+ __attribute__((weak)) void* peach_objc_ref_NSAssertionHandler __asm__("._OBJC_REF_CLASS_NSAssertionHandler") =
1949
+ &_TtC15PeachFoundation18NSAssertionHandler;
1950
+ extern void* _TtC9UIKitCore8UISwitch __asm__("._OBJC_CLASS__TtC9UIKitCore8UISwitch");
1951
+ __attribute__((weak)) void* peach_objc_ref_UISwitch __asm__("._OBJC_REF_CLASS_UISwitch") =
1952
+ &_TtC9UIKitCore8UISwitch;
1953
+ }
1954
+
1955
+ using namespace facebook;
1956
+
1957
+ ${JS_CALL_INVOKER}
1958
+ std::shared_ptr<JsCallInvoker> invoker;
1959
+ std::string names;
1960
+
1961
+ extern "C" void peachTurboDispatchAsync(dispatch_block_t block) {
1962
+ if (!block || !invoker) return;
1963
+ dispatch_block_t copied = [block copy];
1964
+ invoker->invokeAsync([copied](jsi::Runtime&) { copied(); });
1965
+ }
1966
+
1967
+ void dispatchToJSThread(dispatch_block_t block) {
1968
+ invoker->invokeAsync([block](jsi::Runtime&) { block(); });
1969
+ }
1970
+ } // namespace
1971
+
1972
+ static CGFloat peachScreenBrightness = 0.5;
1973
+
1974
+ @implementation UIScreen (PeachTurboRuntime)
1975
+ + (UIScreen *)mainScreen {
1976
+ static UIScreen *screen = nil;
1977
+ if (!screen) screen = [[UIScreen alloc] init];
1978
+ return screen;
1979
+ }
1980
+ - (CGFloat)brightness {
1981
+ return peachScreenBrightness;
1982
+ }
1983
+ - (void)setBrightness:(CGFloat)value {
1984
+ peachScreenBrightness = value;
1985
+ }
1986
+ @end
1987
+
1988
+ static BOOL peachIdleTimerDisabled = NO;
1989
+
1990
+ @implementation UIApplication (PeachTurboRuntime)
1991
+ + (UIApplication *)sharedApplication {
1992
+ static UIApplication *app = nil;
1993
+ if (!app) app = [[UIApplication alloc] init];
1994
+ return app;
1995
+ }
1996
+ - (BOOL)isIdleTimerDisabled {
1997
+ return peachIdleTimerDisabled;
1998
+ }
1999
+ - (void)setIdleTimerDisabled:(BOOL)disabled {
2000
+ peachIdleTimerDisabled = disabled;
2001
+ }
2002
+ @end
2003
+
2004
+ @interface RCTTurboModuleManager (PeachTurboLegacy)
2005
+ - (std::shared_ptr<facebook::react::TurboModule>)provideLegacyModule:(const char *)moduleName;
2006
+ @end
2007
+
2008
+ @interface PeachTurboModuleDelegate : NSObject <RCTTurboModuleManagerDelegate>
2009
+ @end
2010
+
2011
+ static PeachTurboModuleDelegate *delegate;
2012
+ static RCTTurboModuleManager *manager;
2013
+
2014
+ @implementation PeachTurboModuleDelegate
2015
+
2016
+ - (Class)getModuleClassFromName:(const char *)name
2017
+ {
2018
+ NSString *target = @(name);
2019
+ for (NSString *className in @[${classNamesList}]) {
2020
+ Class moduleClass = NSClassFromString(className);
2021
+ if (moduleClass &&
2022
+ ([moduleClass conformsToProtocol:@protocol(RCTTurboModule)] ||
2023
+ [moduleClass conformsToProtocol:@protocol(RCTBridgeModule)]) &&
2024
+ [RCTBridgeModuleNameForClass(moduleClass) isEqualToString:target])
2025
+ return moduleClass;
2026
+ }
2027
+ for (Class moduleClass in RCTGetModuleClasses()) {
2028
+ if ([RCTBridgeModuleNameForClass(moduleClass) isEqualToString:target])
2029
+ return moduleClass;
2030
+ }
2031
+ return nil;
2032
+ }
2033
+
2034
+ - (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass
2035
+ {
2036
+ id<RCTTurboModule> module = [moduleClass new];
2037
+ if ([module respondsToSelector:@selector(setDispatchToJSThread:)])
2038
+ ((id<RCTJSDispatcherModule>)module).dispatchToJSThread = ^(dispatch_block_t block) {
2039
+ dispatchToJSThread(block);
2040
+ };
2041
+ return module;
2042
+ }
2043
+
2044
+ - (id<RCTModuleProvider>)getModuleProvider:(const char *)name
2045
+ {
2046
+ return RCTModuleProviders.moduleProviders[@(name)];
2047
+ }
2048
+
2049
+ - (std::shared_ptr<react::TurboModule>)getTurboModule:(const std::string &)name
2050
+ jsInvoker:(std::shared_ptr<react::CallInvoker>)jsInvoker
2051
+ {
2052
+ Class cls = [self getModuleClassFromName:name.c_str()];
2053
+ if (cls && ![cls instancesRespondToSelector:@selector(getTurboModule:)]) {
2054
+ return [manager provideLegacyModule:name.c_str()];
2055
+ }
2056
+ return nullptr;
2057
+ }
2058
+
2059
+ @end
2060
+
2061
+ extern "C" void peachTurboInitialize() {
2062
+ objc_create_block_classes_as_subclasses_of([NSObject class]);
2063
+ if (Class blockClass = NSClassFromString(@"_NSBlock")) {
2064
+ class_addMethod(blockClass, @selector(copy), (IMP)peachBlockCopy, "@@:");
2065
+ class_addMethod(blockClass, @selector(copyWithZone:), (IMP)peachBlockCopyWithZone, "@@:^v");
2066
+ }
2067
+ if (Class mainQueueClass = NSClassFromString(@"OS_dispatch_queue_main")) {
2068
+ class_replaceMethod(mainQueueClass, sel_registerName("retain"), (IMP)+[](const void *self, SEL) -> const void * { return self; }, "@@:");
2069
+ class_replaceMethod(mainQueueClass, sel_registerName("release"), (IMP)+[](const void *, SEL) -> void {}, "v@:");
2070
+ class_replaceMethod(mainQueueClass, sel_registerName("autorelease"), (IMP)+[](const void *self, SEL) -> const void * { return self; }, "@@:");
2071
+ static_cast<uint32_t *>((__bridge void *)mainQueueClass)[4] &= ~2048u;
2072
+ *reinterpret_cast<void **>(&_dispatch_main_q) = (__bridge void *)mainQueueClass;
2073
+ }
2074
+ auto& runtime = peach::jsi_runtime::create(
2075
+ [] { invoker->drain(); },
2076
+ [] {
2077
+ [manager invalidate];
2078
+ manager = nil;
2079
+ delegate = nil;
2080
+ invoker.reset();
2081
+ });
2082
+ invoker = std::make_shared<JsCallInvoker>(runtime);
2083
+ RCTBridgeModuleDecorator *decorator =
2084
+ [[RCTBridgeModuleDecorator alloc] initWithViewRegistry:[RCTViewRegistry new]
2085
+ moduleRegistry:[RCTModuleRegistry new]
2086
+ bundleManager:nil
2087
+ callableJSModules:[RCTCallableJSModules new]${decoratorHasPerformanceLogger ? '\n launchOptions:nil\n performanceLogger:[RCTPerformanceLogger new]' : ''}];
2088
+ RCTEnableTurboModuleInterop(YES);
2089
+ delegate = [PeachTurboModuleDelegate new];
2090
+ manager = [[RCTTurboModuleManager alloc] initWithBridgeProxy:nil
2091
+ bridgeModuleDecorator:decorator
2092
+ delegate:delegate
2093
+ jsInvoker:invoker
2094
+ devMenuConfigurationDecorator:nil];
2095
+ [decorator.moduleRegistry setTurboModuleRegistry:manager];
2096
+ [manager installJSBindings:runtime];
2097
+ }
2098
+
2099
+ // the names the process answers, newline separated, for the host to claim:
2100
+ // the global C++ map, the codegen module providers and each registered
2101
+ // Objective-C TurboModule class
2102
+ extern "C" __attribute__((export_name("peach_turbo_module_names"))) const char* peachTurboModuleNames() {
2103
+ NSMutableOrderedSet<NSString *> *found = [NSMutableOrderedSet new];
2104
+ for (const auto& [name, provider] : react::globalExportedCxxTurboModuleMap())
2105
+ [found addObject:@(name.c_str())];
2106
+ [found addObjectsFromArray:RCTModuleProviders.moduleProviders.allKeys];
2107
+ for (Class moduleClass in RCTGetModuleClasses())
2108
+ if ([moduleClass conformsToProtocol:@protocol(RCTTurboModule)] ||
2109
+ [moduleClass conformsToProtocol:@protocol(RCTBridgeModule)])
2110
+ [found addObject:RCTBridgeModuleNameForClass(moduleClass)];
2111
+ for (NSString *className in @[${classNamesList}]) {
2112
+ Class moduleClass = NSClassFromString(className);
2113
+ if (moduleClass &&
2114
+ ([moduleClass conformsToProtocol:@protocol(RCTTurboModule)] ||
2115
+ [moduleClass conformsToProtocol:@protocol(RCTBridgeModule)]))
2116
+ [found addObject:RCTBridgeModuleNameForClass(moduleClass)];
2117
+ }
2118
+ names.clear();
2119
+ for (NSString *name in found) {
2120
+ if (!names.empty()) names += '\\n';
2121
+ names += name.UTF8String;
2122
+ }
2123
+ return names.c_str();
2124
+ }
2125
+ `
2126
+ }