peachsim 0.1.2935 → 0.1.2937

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 (345) hide show
  1. package/LICENSE +6 -8
  2. package/cli/account-gate.ts +20 -3
  3. package/cli/app-bundle-resources.ts +66 -19
  4. package/cli/catalog/meta.ts +2 -106
  5. package/cli/command-agent.ts +7 -0
  6. package/cli/command-registry.ts +0 -1
  7. package/cli/commands/control.ts +13 -5
  8. package/cli/commands/daemon.ts +4 -2
  9. package/cli/commands/device.ts +78 -8
  10. package/cli/commands/do-chain.ts +11 -8
  11. package/cli/commands/inspect/core.ts +4 -9
  12. package/cli/commands/inspect/settling.ts +1 -0
  13. package/cli/commands/logout.ts +6 -1
  14. package/cli/commands/map.ts +2 -6
  15. package/cli/commands/package.ts +112 -57
  16. package/cli/commands/shell-url.ts +0 -1
  17. package/cli/download-auth.ts +2 -0
  18. package/cli/drivers/playwright-provisioning.ts +10 -38
  19. package/cli/github-workflow-identity.ts +8 -0
  20. package/cli/internal-child-contract.ts +1 -0
  21. package/cli/internal-child.ts +5 -0
  22. package/cli/main.ts +2 -10
  23. package/cli/outbound-endpoints.ts +26 -0
  24. package/detox/index.ts +227 -131
  25. package/dist-lib/agent-daemon-client.cjs +1 -1
  26. package/dist-lib/agent-events.cjs +1 -1
  27. package/dist-lib/attached-projects.cjs +1 -1
  28. package/dist-lib/auth/shared-session.cjs +1 -1
  29. package/dist-lib/backend-origin.cjs +1 -1
  30. package/dist-lib/beta.cjs +1 -1
  31. package/dist-lib/beta.mjs +2 -2
  32. package/dist-lib/bridge-constants.cjs +1 -1
  33. package/dist-lib/bridge-contract-input.cjs +47 -3
  34. package/dist-lib/bridge-contract-input.mjs +6 -6
  35. package/dist-lib/bridge-contract.cjs +10 -1
  36. package/dist-lib/bridge-contract.mjs +3 -3
  37. package/dist-lib/bundle-channel.cjs +12779 -9515
  38. package/dist-lib/capture-contract.cjs +39 -17
  39. package/dist-lib/capture-contract.mjs +3 -3
  40. package/dist-lib/cloud-contract.cjs +1 -1
  41. package/dist-lib/cloud-contract.mjs +3 -3
  42. package/dist-lib/cloud-test-args.cjs +1 -1
  43. package/dist-lib/cloud-test-args.mjs +2 -2
  44. package/dist-lib/cloud.cjs +1 -1
  45. package/dist-lib/cloud.mjs +8 -8
  46. package/dist-lib/config.cjs +1 -1
  47. package/dist-lib/config.mjs +6 -6
  48. package/dist-lib/detox/index.cjs +200 -132
  49. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  50. package/dist-lib/esm-chunks/{acorn-Q5TRRYSO.mjs → acorn-IIBLEO25.mjs} +3 -3
  51. package/dist-lib/esm-chunks/{chunk-UDWBTBVG.mjs → chunk-4FTPQKPT.mjs} +10 -1
  52. package/dist-lib/esm-chunks/chunk-4WIDTRBB.mjs +10232 -0
  53. package/dist-lib/esm-chunks/{chunk-LCMFYMT7.mjs → chunk-5QZOQ3NZ.mjs} +1 -1
  54. package/dist-lib/esm-chunks/{chunk-BJ2OGUX7.mjs → chunk-CIY67HNL.mjs} +39 -17
  55. package/dist-lib/esm-chunks/{chunk-SKQTNQYE.mjs → chunk-CQFEMJ64.mjs} +1 -1
  56. package/dist-lib/esm-chunks/{chunk-AXWVXRHX.mjs → chunk-CWVMCW23.mjs} +1 -1
  57. package/dist-lib/esm-chunks/{chunk-MTALOHQR.mjs → chunk-F6DZ4DS2.mjs} +1 -1
  58. package/dist-lib/esm-chunks/{chunk-I4R7IZRD.mjs → chunk-HJMF6O7L.mjs} +74 -46
  59. package/dist-lib/esm-chunks/chunk-I6T4PXJF.mjs +154 -0
  60. package/dist-lib/esm-chunks/{chunk-XWAUZKIA.mjs → chunk-IJU3JMWM.mjs} +1 -1
  61. package/dist-lib/esm-chunks/{chunk-CXWUIOCH.mjs → chunk-KODEPXQC.mjs} +4 -4
  62. package/dist-lib/esm-chunks/{chunk-WJE5QHSD.mjs → chunk-LD4K2VBL.mjs} +155 -36
  63. package/dist-lib/esm-chunks/{chunk-2TSM64HI.mjs → chunk-LTE7YMEG.mjs} +1 -1
  64. package/dist-lib/esm-chunks/{chunk-3GGOXUJA.mjs → chunk-M3CSKAJE.mjs} +1 -1
  65. package/dist-lib/esm-chunks/{chunk-7G5UETIG.mjs → chunk-NA6DJPB6.mjs} +43 -1
  66. package/dist-lib/esm-chunks/{chunk-MSUHMNAI.mjs → chunk-NNAX24FS.mjs} +1 -1
  67. package/dist-lib/esm-chunks/{chunk-VDJA4LP4.mjs → chunk-PZPJJBAS.mjs} +1 -1
  68. package/dist-lib/esm-chunks/{chunk-UEEEJVQA.mjs → chunk-QXSTHMWN.mjs} +1 -1
  69. package/dist-lib/esm-chunks/{chunk-S2RJB5I7.mjs → chunk-RBPVK5YI.mjs} +1 -1
  70. package/dist-lib/esm-chunks/{chunk-VRAXNGYT.mjs → chunk-SCT5OFDV.mjs} +1 -1
  71. package/dist-lib/esm-chunks/{chunk-T3M73LGP.mjs → chunk-U3CJGYSP.mjs} +50 -6
  72. package/dist-lib/esm-chunks/{chunk-SLUGTGQQ.mjs → chunk-VXTOQ522.mjs} +12 -6
  73. package/dist-lib/esm-chunks/{chunk-EL44SZMV.mjs → chunk-WMSVGYTH.mjs} +1 -1
  74. package/dist-lib/esm-chunks/{chunk-FEDEPSEV.mjs → chunk-WRWINRWK.mjs} +1 -1
  75. package/dist-lib/esm-chunks/{chunk-BNO52N2S.mjs → chunk-YZF2USRD.mjs} +1905 -8760
  76. package/dist-lib/esm-chunks/{chunk-TQLKYMVP.mjs → chunk-ZNHR6C3L.mjs} +1 -1
  77. package/dist-lib/esm-chunks/{download-auth-registry-G75MIT55.mjs → download-auth-registry-AHS5MSIB.mjs} +4 -4
  78. package/dist-lib/esm-chunks/{metro-layout-parser-FXLUDTYT.mjs → metro-layout-parser-24ZYK5UP.mjs} +3 -3
  79. package/dist-lib/esm-chunks/{swift-package-prebuilt-524D4MA2.mjs → swift-package-prebuilt-L4YNXQRD.mjs} +15 -15
  80. package/dist-lib/esm-chunks/{swift-sdk-app-module-EX544YJY.mjs → swift-sdk-app-module-RM652JSW.mjs} +87 -71
  81. package/dist-lib/esm-chunks/{swift-sdk-image-LOTMWVM7.mjs → swift-sdk-image-5PQ44UJT.mjs} +15 -15
  82. package/dist-lib/esm-chunks/{swift-sdk-image-producer-UO6B3M4U.mjs → swift-sdk-image-producer-GD3SM6YI.mjs} +5 -5
  83. package/dist-lib/esm-chunks/swift-sdk-later-data-62QYJ2KH.mjs +590 -0
  84. package/dist-lib/expo-swift-bundle.cjs +21037 -17896
  85. package/dist-lib/expo-swift-metadata.cjs +8 -2
  86. package/dist-lib/expo-swift-metadata.mjs +9 -8
  87. package/dist-lib/home-paths.cjs +1 -1
  88. package/dist-lib/host/bridge-host.cjs +22481 -18741
  89. package/dist-lib/host/fetch-proxy-handler.cjs +21079 -17980
  90. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  91. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
  92. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  93. package/dist-lib/host/websocket-proxy.cjs +1 -1
  94. package/dist-lib/index.cjs +68 -38
  95. package/dist-lib/kotlin-host.cjs +97 -21
  96. package/dist-lib/menu.cjs +1 -1
  97. package/dist-lib/menu.mjs +3 -3
  98. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  99. package/dist-lib/metro-fingerprint-registry.mjs +3 -3
  100. package/dist-lib/metro-production-bundle.cjs +23 -1
  101. package/dist-lib/metro-production-bundle.mjs +24 -4
  102. package/dist-lib/native-app-identity-project.cjs +3582 -571
  103. package/dist-lib/native-app-identity-project.mjs +1024 -398
  104. package/dist-lib/native-app-identity.cjs +1 -1
  105. package/dist-lib/native-app-identity.mjs +6 -6
  106. package/dist-lib/native-firebase-metadata.cjs +1 -1
  107. package/dist-lib/native-firebase-metadata.mjs +3 -3
  108. package/dist-lib/pdfium-raster.cjs +1 -1
  109. package/dist-lib/pdfium-raster.mjs +2 -2
  110. package/dist-lib/plist.cjs +1 -1
  111. package/dist-lib/plist.mjs +3 -3
  112. package/dist-lib/profiles.cjs +1 -1
  113. package/dist-lib/public-brand.cjs +1 -1
  114. package/dist-lib/public-origins-lib-esm.json +132 -116
  115. package/dist-lib/public-origins-lib.json +215 -173
  116. package/dist-lib/react-native-host-modules.cjs +1 -1
  117. package/dist-lib/react-native-host-modules.mjs +2 -2
  118. package/dist-lib/reap-browser.cjs +17 -1
  119. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  120. package/dist-lib/sdk.cjs +6 -7
  121. package/dist-lib/sdk.mjs +13 -14
  122. package/dist-lib/skills.cjs +23216 -19650
  123. package/dist-lib/swift-compile.cjs +4337 -2905
  124. package/dist-lib/swift-compile.mjs +15 -13
  125. package/dist-lib/swift-package.cjs +1 -1
  126. package/dist-lib/swift-package.mjs +3 -3
  127. package/dist-lib/swift-submit.cjs +1 -1
  128. package/dist-lib/swift-submit.mjs +6 -6
  129. package/dist-lib/swift-svg-raster.cjs +1 -1
  130. package/dist-lib/swift-svg-raster.mjs +2 -2
  131. package/dist-lib/swift-toolchain.cjs +19 -1
  132. package/dist-lib/swift.cjs +1 -1
  133. package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
  134. package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
  135. package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
  136. package/dist-lib/vendor/acorn.cjs +1 -1
  137. package/dist-lib/vendor/stream-json.cjs +1 -1
  138. package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
  139. package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
  140. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
  141. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
  142. package/dist-lib/vendor/sucrase.cjs +1 -1
  143. package/dist-lib/vendor/terser.cjs +1 -1
  144. package/dist-lib/vendor/valibot.cjs +1 -1
  145. package/dist-lib/vendor/ws.cjs +94 -32
  146. package/dist-lib/vendor/zod.cjs +1 -1
  147. package/dist-lib/worklet-executable.cjs +8 -5
  148. package/dist-lib/worklet-executable.mjs +9 -6
  149. package/dist-types/packages/peach-engine/src/canvaskit-artifact-urls.d.ts +2 -1
  150. package/dist-types/packages/peach-engine/src/capture/compositor-presentation-recording.d.ts +1 -0
  151. package/dist-types/packages/peach-engine/src/engine/generated/canvaskit-artifact-hashes.d.ts +26 -0
  152. package/dist-types/packages/peach-engine/src/engine/guest-scene-inspect.d.ts +1 -1
  153. package/dist-types/packages/peach-engine/src/engine/inspect-info.d.ts +1 -0
  154. package/dist-types/packages/peach-engine/src/engine/metalTypes.d.ts +32 -2
  155. package/dist-types/packages/peach-engine/src/engine/portalContract.d.ts +24 -0
  156. package/dist-types/packages/peach-engine/src/engine/remote-display-protocol.d.ts +12 -2
  157. package/dist-types/packages/peach-engine/src/guest/http-cookie-storage.d.ts +73 -0
  158. package/dist-types/packages/peach-engine/src/guest/native-evaluation-lease.d.ts +5 -0
  159. package/dist-types/packages/peach-engine/src/guest/nitro-jsi-host.d.ts +3 -1
  160. package/dist-types/packages/peach-engine/src/ios/apps/canvas-map-data.d.ts +225 -9
  161. package/dist-types/packages/peach-engine/src/ios/chrome-metrics.d.ts +4 -1
  162. package/dist-types/packages/peach-engine/src/ios/duo-vertical-bar-geometry.d.ts +0 -1
  163. package/dist-types/packages/peach-engine/src/native-preview-bundle.d.ts +1 -0
  164. package/dist-types/packages/peach-engine/src/remote-stream/canvas-display-compositor.d.ts +1 -0
  165. package/dist-types/packages/peach-engine/src/remote-stream/canvas-display-contract.d.ts +44 -10
  166. package/dist-types/packages/peach-engine/src/remote-stream/cloud-display.d.ts +4 -3
  167. package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +2 -4
  168. package/dist-types/packages/peach-engine/src/render-worker/metro-bundle-metadata.d.ts +2 -0
  169. package/dist-types/packages/peach-engine/src/render-worker/native-widgetContract.d.ts +1 -1
  170. package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +15 -27
  171. package/dist-types/packages/peach-engine/src/render-worker/reanimated-readiness.d.ts +2 -6
  172. package/dist-types/packages/peach-engine/src/render-worker/shell-protocol.d.ts +11 -3
  173. package/dist-types/packages/peach-engine/src/settings/devices.d.ts +3 -1
  174. package/dist-types/packages/peach-engine/src/settings/duo-fold.d.ts +1 -1
  175. package/dist-types/packages/peach-engine/src/webview-automation-host.d.ts +1 -1
  176. package/dist-types/packages/peach-globals/src/app-bundle-resources.d.ts +10 -0
  177. package/dist-types/packages/peach-globals/src/compositorBridgeContract.d.ts +1 -1
  178. package/dist-types/packages/peach-globals/src/hostStorageBridgeContract.d.ts +1 -0
  179. package/dist-types/packages/peach-globals/src/index.d.ts +2 -2
  180. package/dist-types/packages/peach-globals/src/lockstepCaptureBridgeContract.d.ts +9 -6
  181. package/dist-types/packages/peach-globals/src/nodeContract.d.ts +11 -0
  182. package/dist-types/packages/peach-globals/src/oneWidgetContract.d.ts +28 -0
  183. package/package.json +2 -2
  184. package/runtime-companion.json +1 -1
  185. package/sdk/ios/System/Library/Frameworks/CoreHaptics.framework/Headers/CoreHaptics.h +251 -0
  186. package/sdk/ios/System/Library/Frameworks/Intents.framework/Headers/INImage.h +14 -0
  187. package/sdk/ios/System/Library/Frameworks/Intents.framework/Headers/INIntent.h +18 -0
  188. package/sdk/ios/System/Library/Frameworks/Intents.framework/Headers/INIntentIdentifiers.h +30 -0
  189. package/sdk/ios/System/Library/Frameworks/Intents.framework/Headers/INIntentResponse.h +12 -0
  190. package/sdk/ios/System/Library/Frameworks/Intents.framework/Headers/INInteraction.h +35 -0
  191. package/sdk/ios/System/Library/Frameworks/Intents.framework/Headers/INObjectCollection.h +0 -7
  192. package/sdk/ios/System/Library/Frameworks/Intents.framework/Headers/INObjectSection.h +0 -7
  193. package/sdk/ios/System/Library/Frameworks/Intents.framework/Headers/INOutgoingMessageType.h +7 -0
  194. package/sdk/ios/System/Library/Frameworks/Intents.framework/Headers/INPerson.h +36 -0
  195. package/sdk/ios/System/Library/Frameworks/Intents.framework/Headers/INPersonHandle.h +22 -0
  196. package/sdk/ios/System/Library/Frameworks/Intents.framework/Headers/INSendMessageIntent+UserNotifications.h +6 -0
  197. package/sdk/ios/System/Library/Frameworks/Intents.framework/Headers/INSendMessageIntent.h +33 -0
  198. package/sdk/ios/System/Library/Frameworks/Intents.framework/Headers/INSpeakableString.h +24 -0
  199. package/sdk/ios/System/Library/Frameworks/Intents.framework/Headers/Intents.h +11 -7
  200. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMailComposeViewController.h +1 -1
  201. package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMessageComposeViewController.h +1 -1
  202. package/sdk/ios/System/Library/Frameworks/Metal.framework/Headers/MTLRenderCommandEncoder.h +0 -8
  203. package/sdk/ios/System/Library/Frameworks/MetalTypes.framework/Headers/MetalTypes.h +8 -0
  204. package/sdk/ios/System/Library/Frameworks/Social.framework/Headers/SLServiceTypes.h +9 -0
  205. package/sdk/ios/System/Library/Frameworks/Social.framework/Headers/Social.h +1 -0
  206. package/sdk/ios/System/Library/Frameworks/UserNotifications.framework/Headers/UNNotification.h +1 -1
  207. package/sdk/ios/System/Library/Frameworks/UserNotifications.framework/Headers/UNNotificationAction.h +2 -2
  208. package/sdk/ios/System/Library/Frameworks/UserNotifications.framework/Headers/UNNotificationAttachment.h +1 -1
  209. package/sdk/ios/System/Library/Frameworks/UserNotifications.framework/Headers/UNNotificationCategory.h +1 -1
  210. package/sdk/ios/System/Library/Frameworks/UserNotifications.framework/Headers/UNNotificationContent.h +2 -2
  211. package/sdk/ios/System/Library/Frameworks/UserNotifications.framework/Headers/UNNotificationRequest.h +1 -1
  212. package/sdk/ios/System/Library/Frameworks/UserNotifications.framework/Headers/UNNotificationResponse.h +2 -2
  213. package/sdk/ios/System/Library/Frameworks/UserNotifications.framework/Headers/UNNotificationSound.h +1 -1
  214. package/sdk/ios/System/Library/Frameworks/UserNotifications.framework/Headers/UNNotificationTrigger.h +5 -5
  215. package/sdk/ios/usr/lib/swift/UIKit.swiftmodule/arm64-apple-ios-simulator.swiftinterface +4 -0
  216. package/sdk/ios/wasm/include/unistd.h +1 -0
  217. package/src/acorn-program.ts +3 -0
  218. package/src/audio-codec-archives.ts +141 -0
  219. package/src/bridge-contract-input.ts +61 -1
  220. package/src/bridge-contract.ts +45 -4
  221. package/src/bundle-channel.mjs +44 -30
  222. package/src/capture-contract.ts +57 -39
  223. package/src/conformance-comparison-contract.ts +2 -0
  224. package/src/expo-discovery-cache.ts +0 -2
  225. package/src/expo-macro-host.ts +8 -3
  226. package/src/expo-native-compiler-digest.ts +0 -1
  227. package/src/expo-native-prebuilt.ts +1 -1
  228. package/src/expo-native-workspace.ts +83 -45
  229. package/src/expo-pod-prebuilt.ts +1 -0
  230. package/src/expo-swift-host.ts +158 -77
  231. package/src/expo-swift-legacy-runtime-source.ts +12 -1
  232. package/src/expo-swift-view-source.ts +51 -20
  233. package/src/expo-workspace-exclusion.ts +7 -1
  234. package/src/expoSwiftContract.ts +10 -1
  235. package/src/ffmpeg-source-build.ts +123 -59
  236. package/src/genrule-archives.ts +7 -2
  237. package/src/genrule-library-builds.ts +101 -18
  238. package/src/host/bridge-host.ts +10 -1
  239. package/src/installed-native-libraries.ts +147 -23
  240. package/src/installed-package-versions.ts +30 -0
  241. package/src/ios-rn-bundle-request.ts +3 -1
  242. package/src/ios-rn-bundle.ts +38 -27
  243. package/src/ios-rn-compile.ts +23 -6
  244. package/src/ios-rn-startup.ts +2 -1
  245. package/src/java-module-abi.ts +4 -3
  246. package/src/kotlin-host.ts +4 -4
  247. package/src/kotlin-library-sources.ts +8 -5
  248. package/src/metro-production-bundle.ts +24 -0
  249. package/src/native-firebase-config.ts +2 -0
  250. package/src/native-framework-compiler.ts +5 -0
  251. package/src/native-package-slice-build.ts +3 -0
  252. package/src/native-package-slice.ts +15 -10
  253. package/src/native-preparation.ts +4 -1
  254. package/src/native-static-libraries.ts +107 -33
  255. package/src/nativeRuntimePackageIndex.ts +1 -4
  256. package/src/nitro-adapter.lock.json +286 -286
  257. package/src/nitro-app-providers.ts +20 -8
  258. package/src/nitro-compile.ts +131 -37
  259. package/src/nitro-dependencies.ts +42 -8
  260. package/src/nitro-source.ts +40 -36
  261. package/src/nitro-superset.lock.json +4 -4
  262. package/src/nitroAdapterContract.ts +32 -7
  263. package/src/nitroContract.ts +21 -37
  264. package/src/one-direct-host-source.ts +247 -140
  265. package/src/one-fabric.ts +129 -0
  266. package/src/one-native-controls-package.ts +95 -21
  267. package/src/one-native-controls-release.ts +147 -14
  268. package/src/one-native-source.ts +4 -1
  269. package/src/one-nitro-inputs.ts +1 -1
  270. package/src/one-nitro-source.ts +45 -1
  271. package/src/one-sdk/source.ts +10 -41
  272. package/src/one-widget-metadata.ts +2 -2
  273. package/src/one-widget-package.ts +1 -1
  274. package/src/oneSdkContract.ts +3 -0
  275. package/src/playwright-browser-paths.ts +30 -0
  276. package/src/pods-install.ts +6 -2
  277. package/src/pods-post-install.ts +2 -2
  278. package/src/pods-project.ts +10 -0
  279. package/src/podspec-ruby-stdlib.ts +73 -0
  280. package/src/podspec-ruby.ts +1 -1
  281. package/src/podspec-sources.ts +31 -13
  282. package/src/process-group.ts +135 -5
  283. package/src/published-swift-sdk.ts +25 -1
  284. package/src/react-native-bridge-modules.ts +35 -3
  285. package/src/react-native-core-build.ts +14 -2
  286. package/src/react-native-core.ts +12 -2
  287. package/src/rive-runtime-dependencies.ts +178 -40
  288. package/src/serverDiscoveryContract.ts +1 -1
  289. package/src/storageSnapshotContract.ts +1 -1
  290. package/src/swift-app-data-store.ts +35 -0
  291. package/src/swift-compile.ts +403 -121
  292. package/src/swift-compiler-digest.ts +4 -0
  293. package/src/swift-darwin-records.ts +6 -0
  294. package/src/swift-distribution-mirror.ts +10 -1
  295. package/src/swift-distribution.lock.json +19 -18
  296. package/src/swift-distribution.ts +17 -1
  297. package/src/swift-entry-module.ts +1 -0
  298. package/src/swift-guest-compile.ts +8 -1
  299. package/src/swift-host.ts +79 -23
  300. package/src/swift-installed-targets.ts +51 -20
  301. package/src/swift-objc-standin.ts +60 -8
  302. package/src/swift-packages.ts +104 -24
  303. package/src/swift-project-user.ts +2 -1
  304. package/src/swift-reproducible.ts +99 -1
  305. package/src/swift-root-lock.ts +52 -46
  306. package/src/swift-sdk-app-module.ts +65 -13
  307. package/src/swift-sdk-image-producer.ts +2 -1
  308. package/src/swift-sdk-image.ts +23 -8
  309. package/src/swift-sdk-later-data.ts +294 -44
  310. package/src/swift-sdk-surface.ts +233 -55
  311. package/src/swift-shared-sdk.ts +7 -0
  312. package/src/swift-standin-builtin-behavior.ts +18 -0
  313. package/src/swift-standin-emit.ts +242 -54
  314. package/src/swift-standins.ts +184 -38
  315. package/src/swift-startup-split.ts +19 -9
  316. package/src/swift-toolchain.ts +18 -0
  317. package/src/swift-wasm-prune.ts +179 -9
  318. package/src/swift-xcframework.ts +16 -0
  319. package/src/swiftContract.ts +4 -1
  320. package/src/swiftSdkLinkContract.ts +2 -0
  321. package/src/swiftTargetContract.ts +1 -0
  322. package/src/turbo-bundle.ts +6 -3
  323. package/src/turbo-codegen-intake.ts +106 -16
  324. package/src/turbo-compile.ts +89 -68
  325. package/src/turbo-fabric-app.ts +287 -23
  326. package/src/turbo-provider-host.ts +122 -31
  327. package/src/turbo-runtime.lock.json +26 -26
  328. package/src/turbo-source.ts +374 -157
  329. package/src/vite-plugin.ts +48 -112
  330. package/src/wasm-binary-sections.ts +40 -0
  331. package/src/wasm-code-immediates.ts +35 -5
  332. package/src/widget-extension-bundle.ts +15 -1
  333. package/src/worklet-executable.ts +2 -1
  334. package/src/worklet-kernel.ts +5 -3
  335. package/src/worklets-babel.ts +2 -1
  336. package/src/xcode-project.ts +151 -53
  337. package/src/xcode-scheme-actions.ts +104 -0
  338. package/cli/commands/canvas.ts +0 -1204
  339. package/dist-lib/esm-chunks/chunk-B5QD2KEV.mjs +0 -2787
  340. package/dist-lib/vendor/magic-string.cjs +0 -1693
  341. package/dist-types/packages/peach-compat/src/stubs/native-seams/react-native-cookies.d.ts +0 -127
  342. package/src/appBundleResourcesContract.ts +0 -51
  343. package/src/canvas-groups.ts +0 -28
  344. package/src/canvas-map-layout.ts +0 -161
  345. package/src/oneWidgetContract.ts +0 -134
@@ -95,6 +95,8 @@ export async function collectOneNitroSources(
95
95
  ...native.sources,
96
96
  ...native.swiftSources,
97
97
  ])
98
+ const sdkRuntime = path.join(ios, 'SDK/OneSDKRuntime.swift')
99
+ const needsSDKRuntime = sources.delete(sdkRuntime)
98
100
  for (const file of new Set([...sources, ...swift.bridgeHeaders, ...native.headers])) {
99
101
  const relative = relativeInside(apple, file)
100
102
  const shared = relativeInside(cpp, file)
@@ -124,6 +126,36 @@ export async function collectOneNitroSources(
124
126
  keys.add(projectSourceKey([root], path.join(file.parentPath, file.name)))
125
127
  await prepareNitroSourceDependencies(options)
126
128
  const collection = collectNitroSources(options, keys, root, new Map())
129
+ if (needsSDKRuntime) {
130
+ // the generated SDK tables and Nitro receiver must use the same Swift types.
131
+ const sdkTarget = 'OneSDKRuntime'
132
+ const sdkPath = 'Sources/OneSDKRuntime'
133
+ collection.files[`${sdkPath}/OneSDKRuntime.swift`] = fs.readFileSync(
134
+ sdkRuntime,
135
+ 'utf8',
136
+ )
137
+ collection.targets.push({
138
+ name: sdkTarget,
139
+ path: sdkPath,
140
+ executable: false,
141
+ languageMode: 5,
142
+ mainActorIsolation: false,
143
+ resources: false,
144
+ })
145
+ const serviceTarget = collection.targets.find(({ name }) => name === moduleName)
146
+ if (!serviceTarget) throw new Error(`One service target missing: ${moduleName}`)
147
+ serviceTarget.dependencies = [
148
+ ...(serviceTarget.dependencies ?? []),
149
+ { kind: 'target', name: sdkTarget },
150
+ ]
151
+ serviceTarget.swiftFlags = [
152
+ ...(serviceTarget.swiftFlags ?? []),
153
+ '-Xfrontend',
154
+ '-import-module',
155
+ '-Xfrontend',
156
+ sdkTarget,
157
+ ]
158
+ }
127
159
  const target = collection.targets.find(
128
160
  ({ name }) => name === nitroProviderTarget(provider),
129
161
  )!
@@ -137,8 +169,20 @@ export async function collectOneNitroSources(
137
169
  ),
138
170
  )
139
171
  for (const target of collection.targets) {
140
- if (target.name === moduleName)
172
+ if (target.name === moduleName) {
141
173
  target.defines = [...ONE_SDK_DEFINES, ...conditions].sort()
174
+ // the iOS host's headers (core-abi/ios PeachImageEncoding.h) reach every One source.
175
+ target.swiftFlags = [
176
+ ...(target.swiftFlags ?? []),
177
+ ...['-import-module', 'PeachImageEncoding'].flatMap((flag) => [
178
+ '-Xfrontend',
179
+ flag,
180
+ ]),
181
+ ]
182
+ // swiftpm links a product only for a source import; the flag alone left it unbuilt.
183
+ collection.files[target.path + '/PeachHostImports.swift'] =
184
+ 'import PeachImageEncoding\n'
185
+ }
142
186
  }
143
187
  if (swift.sources.length > 0) {
144
188
  const { frameworks } = swiftSdkPaths(moduleRoot, toolchainBin)
@@ -51,11 +51,9 @@ private enum SDKTransport {
51
51
  nonisolated(unsafe) static var handles: [Int: OneSDKHandleBox] = [:]
52
52
  nonisolated(unsafe) static var nextHandle = 0
53
53
  nonisolated(unsafe) static var subscriptions: [Int: () -> Void] = [:]
54
- nonisolated(unsafe) static var contents: [Int: (view: OneNativeContentView, source: Int, item: Int)] = [:]
55
54
  nonisolated(unsafe) static var reply: UnsafeMutableRawPointer?
56
55
 
57
- static func typeName(_ type: Any.Type) -> String {
58
- let name = String(reflecting: type)
56
+ static func normalizeTypeName(_ name: String, _ type: Any.Type? = nil) -> String {
59
57
  let owner = name.split(separator: ".", maxSplits: 1).first.map(String.init) ?? ""
60
58
  if ["UIKitCore", "UIKitText", "UIKitEnums", "Foundation"].contains(owner), let object = type as? AnyClass {
61
59
  let runtimeName = String(cString: class_getName(object))
@@ -70,15 +68,20 @@ private enum SDKTransport {
70
68
  static func metadata(_ box: OneSDKHandleBox) -> [String: Any] {
71
69
  nextHandle += 1
72
70
  handles[nextHandle] = box
73
- var names: [String] = []
74
- if let type = type(of: box.value) as? AnyClass {
71
+ var names = box.superclassNames.map { normalizeTypeName($0) }
72
+ if names.isEmpty, let type = type(of: box.value) as? AnyClass {
75
73
  var at: AnyClass? = class_getSuperclass(type)
76
74
  while let current = at, current != NSObject.self {
77
- names.append(typeName(current))
75
+ names.append(normalizeTypeName(String(reflecting: current), current))
78
76
  at = class_getSuperclass(current)
79
77
  }
80
78
  }
81
- var result: [String: Any] = ["id": nextHandle, "typeName": typeName(type(of: box.value)), "identity": box.identity, "superclasses": names]
79
+ var result: [String: Any] = [
80
+ "id": nextHandle,
81
+ "typeName": normalizeTypeName(box.typeName, type(of: box.value)),
82
+ "identity": box.identity,
83
+ "superclasses": names,
84
+ ]
82
85
  if box.value is OneSDKCallable { result["callable"] = true }
83
86
  return result
84
87
  }
@@ -189,40 +192,6 @@ private enum SDKTransport {
189
192
 
190
193
  @MainActor static func run(_ request: [String: Any]) throws -> [String: Any] {
191
194
  guard let operation = request["operation"] as? String else { throw OneSDKError.unsupported("missing sdk operation") }
192
- if operation == "content" {
193
- guard let id = request["contentId"] as? Int, let source = request["sourceId"] as? Int,
194
- let item = request["item"] as? Int, let height = request["height"] as? Double,
195
- let estimate = request["estimatedHeight"] as? Double, let host = request["host"] as? String else {
196
- throw OneSDKError.unsupported("invalid UIKit content props")
197
- }
198
- let view = OneNativeContentRegistry.view(forId: id)
199
- view._peachReactContentHost = host
200
- view.fixedHeight = height
201
- view.estimatedHeight = estimate
202
- if let previous = contents[id], previous.source != source || previous.item != item {
203
- if previous.source > 0 { OneNativeCellSources.unregister(view, sourceId: previous.source, item: previous.item) }
204
- }
205
- if source > 0 { OneNativeCellSources.register(view, sourceId: source, item: item) }
206
- contents[id] = (view, source, item)
207
- return [:]
208
- }
209
- if operation == "measureContent" {
210
- guard let id = request["contentId"] as? Int, let height = request["height"] as? Double else {
211
- throw OneSDKError.unsupported("invalid UIKit content measurement")
212
- }
213
- contents[id]?.view.setMeasuredHeight(height)
214
- return [:]
215
- }
216
- if operation == "unmountContent" {
217
- guard let id = request["contentId"] as? Int else { throw OneSDKError.unsupported("invalid UIKit content id") }
218
- if let content = contents.removeValue(forKey: id) {
219
- content.view._peachReactContentHost = nil
220
- content.view.retire()
221
- if content.source > 0 { OneNativeCellSources.unregister(content.view, sourceId: content.source, item: content.item) }
222
- }
223
- OneNativeContentRegistry.unmount(id)
224
- return [:]
225
- }
226
195
  if operation == "release" {
227
196
  guard let ids = request["handles"] as? [Int] else { throw OneSDKError.unsupported("invalid sdk release") }
228
197
  for id in ids { handles.removeValue(forKey: id) }
@@ -1,16 +1,16 @@
1
1
  import { createHash } from 'node:crypto'
2
2
  import fs from 'node:fs'
3
3
  import path from 'node:path'
4
+ import { isHomeWidgetFamily } from '@peach/globals/one-widget'
4
5
  import { isRecord } from './is-record'
5
6
  import { oneConfigPath, readOneNativeApp } from './one-native-app-config'
6
- import { isHomeWidgetFamily } from './oneWidgetContract'
7
7
  import { readPackageFile } from './swift-source-file'
8
8
  import { MAX_SWIFT_COMPILE_SOURCE_BYTES } from './swift-submit'
9
9
  import type {
10
10
  ConfiguredOneWidget,
11
11
  HomeWidgetFamily,
12
12
  OneWidgetMetadata,
13
- } from './oneWidgetContract'
13
+ } from '@peach/globals/one-widget'
14
14
 
15
15
  export const ONE_WIDGET_PACKAGE = 'OneWidgets'
16
16
 
@@ -5,7 +5,7 @@ import os from 'node:os'
5
5
  import path from 'node:path'
6
6
  import { readOneWidgetSources, ONE_WIDGET_PACKAGE } from './one-widget-metadata'
7
7
  import { syncSwiftTree } from './swift-compile'
8
- import type { OneWidgetPackage } from './oneWidgetContract'
8
+ import type { OneWidgetPackage } from '@peach/globals/one-widget'
9
9
 
10
10
  export { ONE_WIDGET_PACKAGE } from './one-widget-metadata'
11
11
 
@@ -31,6 +31,7 @@ export function readOneSDKMetadata(value: unknown): OneSDKCompilation | null {
31
31
  sdkUrl,
32
32
  sdkBindingUrl,
33
33
  startupParts,
34
+ interactionParts,
34
35
  modules,
35
36
  bundleFiles,
36
37
  } = value
@@ -44,6 +45,7 @@ export function readOneSDKMetadata(value: unknown): OneSDKCompilation | null {
44
45
  (sdkUrl !== undefined && typeof sdkUrl !== 'string') ||
45
46
  (sdkBindingUrl !== undefined && typeof sdkBindingUrl !== 'string') ||
46
47
  (startupParts !== undefined && !isNativeLazyDigestList(startupParts)) ||
48
+ (interactionParts !== undefined && !isNativeLazyDigestList(interactionParts)) ||
47
49
  !Array.isArray(modules) ||
48
50
  !modules.every((name) => typeof name === 'string') ||
49
51
  !isRecord(bundleFiles)
@@ -69,6 +71,7 @@ export function readOneSDKMetadata(value: unknown): OneSDKCompilation | null {
69
71
  ...(sdkUrl !== undefined ? { sdkUrl } : {}),
70
72
  ...(sdkBindingUrl !== undefined ? { sdkBindingUrl } : {}),
71
73
  ...(startupParts !== undefined ? { startupParts } : {}),
74
+ ...(interactionParts !== undefined ? { interactionParts } : {}),
72
75
  modules,
73
76
  bundleFiles: files,
74
77
  }
@@ -0,0 +1,30 @@
1
+ import { basename, dirname, join, relative } from 'node:path'
2
+
3
+ export function playwrightBrowserPaths(chromiumPath: string, shell: boolean) {
4
+ let chromiumDir = dirname(chromiumPath)
5
+ while (!/^chromium-\d+$/.test(basename(chromiumDir))) {
6
+ const parent = dirname(chromiumDir)
7
+ if (parent === chromiumDir) return
8
+ chromiumDir = parent
9
+ }
10
+ const directory = dirname(chromiumDir)
11
+ const prefix = shell ? 'chromium_headless_shell-' : 'chromium-'
12
+ const paths = shell
13
+ ? process.platform === 'win32'
14
+ ? ['chrome-headless-shell-win64/chrome-headless-shell.exe']
15
+ : [
16
+ process.arch === 'arm64'
17
+ ? 'chrome-headless-shell-linux-arm64/chrome-headless-shell'
18
+ : 'chrome-headless-shell-linux64/chrome-headless-shell',
19
+ 'chrome-linux/headless_shell',
20
+ ]
21
+ : [relative(chromiumDir, chromiumPath)]
22
+ if (!shell && process.platform === 'linux') paths.push('chrome-linux/chrome')
23
+ const revision = basename(chromiumDir).slice('chromium-'.length)
24
+ return {
25
+ directory,
26
+ prefix,
27
+ paths,
28
+ expected: shell ? join(directory, prefix + revision, paths[0]!) : chromiumPath,
29
+ }
30
+ }
@@ -20,7 +20,11 @@ import {
20
20
  runInstallHooks,
21
21
  type ProjectTable,
22
22
  } from './pods-post-install'
23
- import { finalizePodsProject, generatePodsProject } from './pods-project'
23
+ import {
24
+ finalizePodsProject,
25
+ generatePodsProject,
26
+ replaceIntegratedProjectFile,
27
+ } from './pods-project'
24
28
  import { createPodTargets, Sandbox } from './pods-targets'
25
29
  import { reactNativeScripts, rubyFailures } from './podspec-cocoapods'
26
30
  import {
@@ -573,7 +577,7 @@ export async function installPods(
573
577
  serializePbxproj(pods.objects, pods.rootObject, generated.objectVersion),
574
578
  )
575
579
  for (const { table, ruby } of userProjects.values())
576
- fs.writeFileSync(
580
+ replaceIntegratedProjectFile(
577
581
  path.join(table.path, 'project.pbxproj'),
578
582
  serializePbxproj(
579
583
  projectObjects(interp, ruby),
@@ -18,7 +18,7 @@ import {
18
18
  type TargetToIntegrate,
19
19
  UserProject,
20
20
  } from './pods-integration'
21
- import { projectDefaultBuildSettings } from './pods-project'
21
+ import { projectDefaultBuildSettings, replaceIntegratedProjectFile } from './pods-project'
22
22
  import { XcodeConfig } from './pods-xcconfig'
23
23
  import { rubyFailures } from './podspec-cocoapods'
24
24
  import {
@@ -1680,7 +1680,7 @@ function loadFacade(interp: Interpreter) {
1680
1680
  throw new UnsupportedRuby(
1681
1681
  `Xcodeproj::Plist.write_to_path(${target}) without a hash`,
1682
1682
  )
1683
- fs.writeFileSync(target, nanaimoXml(interp, value))
1683
+ replaceIntegratedProjectFile(target, nanaimoXml(interp, value))
1684
1684
  return null
1685
1685
  })
1686
1686
  interp.evalString(XCODEPROJ, 'xcodeproj')
@@ -1409,6 +1409,16 @@ const COMPILABLE_RESOURCES = new Set([
1409
1409
  '.xcmappingmodel',
1410
1410
  ])
1411
1411
 
1412
+ export function replaceIntegratedProjectFile(file: string, contents: string): void {
1413
+ // staged app files can link back to the template in node_modules.
1414
+ using staging = fs.mkdtempDisposableSync(
1415
+ path.join(path.dirname(file), '.peach-project-'),
1416
+ )
1417
+ const output = path.join(staging.path, path.basename(file))
1418
+ fs.writeFileSync(output, contents)
1419
+ fs.renameSync(output, file)
1420
+ }
1421
+
1412
1422
  interface InstallContext {
1413
1423
  project: PodsProject
1414
1424
  settings: PodsBuildSettings
@@ -42,6 +42,42 @@ function text(interp: Interpreter, value: Value | undefined): string {
42
42
  )
43
43
  }
44
44
 
45
+ // dotenv's line grammar: optional `export`, single quotes literal, double quotes
46
+ // unescape \n and expand ${VAR}, unquoted values expand and drop a trailing # comment
47
+ function parseDotenv(
48
+ source: string,
49
+ env: ReadonlyMap<string, string>,
50
+ ): Array<[string, string]> {
51
+ const parsed = new Map<string, string>()
52
+ const expand = (value: string) =>
53
+ value.replace(
54
+ /(\\)?\$(?:\{([A-Za-z_]\w*)\}|([A-Za-z_]\w*))/g,
55
+ (whole, escaped, braced, bare) =>
56
+ escaped
57
+ ? whole.slice(1)
58
+ : (parsed.get(braced ?? bare) ?? env.get(braced ?? bare) ?? ''),
59
+ )
60
+ const line =
61
+ /^\s*(?:export\s+)?([\w.]+)\s*=\s*('(?:\\'|[^'])*'|"(?:\\"|[^"])*"|[^#\n]*)\s*(?:#.*)?$/gm
62
+ for (const [, key, raw] of source.replace(/\r\n?/g, '\n').matchAll(line)) {
63
+ const value = raw!.trim()
64
+ parsed.set(
65
+ key!,
66
+ value.startsWith("'")
67
+ ? value.slice(1, -1)
68
+ : value.startsWith('"')
69
+ ? expand(
70
+ value
71
+ .slice(1, -1)
72
+ .replace(/\\n/g, '\n')
73
+ .replace(/\\(["\\])/g, '$1'),
74
+ )
75
+ : expand(value),
76
+ )
77
+ }
78
+ return [...parsed]
79
+ }
80
+
45
81
  function expandHome(p: string): string {
46
82
  return p === '~' || p.startsWith('~/') ? path.join(os.homedir(), p.slice(1)) : p
47
83
  }
@@ -982,6 +1018,43 @@ export function installStdlib(interp: Interpreter) {
982
1018
  })
983
1019
  interp.defineNative(envClass, 'inspect', () => str('ENV'))
984
1020
 
1021
+ // the dotenv gem, which Podfiles load from their Gemfile to read .env files
1022
+ const dotenv = interp.defineModule('Dotenv', object)
1023
+ const dotenvFiles = (c: Call) =>
1024
+ c.args.length
1025
+ ? c.args.flat().map((name) => resolve(text(interp, name)))
1026
+ : [resolve('.env')]
1027
+ const dotenvApply = (c: Call, override: boolean, required: boolean) => {
1028
+ const loaded: Array<[Value, Value]> = []
1029
+ for (const file of dotenvFiles(c)) {
1030
+ if (!fs.existsSync(file)) {
1031
+ if (required)
1032
+ return interp.raise(
1033
+ 'Errno::ENOENT',
1034
+ `No such file or directory @ rb_sysopen - ${file}`,
1035
+ )
1036
+ continue
1037
+ }
1038
+ for (const [key, value] of parseDotenv(fs.readFileSync(file, 'utf8'), host.env)) {
1039
+ if (override || !host.env.has(key)) host.env.set(key, value)
1040
+ loaded.push([str(key), str(host.env.get(key) ?? value)])
1041
+ }
1042
+ }
1043
+ return RHash.from(loaded)
1044
+ }
1045
+ def(dotenv, 'load', (c) => dotenvApply(c, false, false))
1046
+ def(dotenv, 'load!', (c) => dotenvApply(c, false, true))
1047
+ def(dotenv, 'overload', (c) => dotenvApply(c, true, false))
1048
+ def(dotenv, 'overload!', (c) => dotenvApply(c, true, true))
1049
+ def(dotenv, 'parse', (c) =>
1050
+ RHash.from(
1051
+ dotenvFiles(c)
1052
+ .filter((file) => fs.existsSync(file))
1053
+ .flatMap((file) => parseDotenv(fs.readFileSync(file, 'utf8'), host.env))
1054
+ .map(([key, value]) => [str(key), str(value)]),
1055
+ ),
1056
+ )
1057
+
985
1058
  // Pathname
986
1059
  const pathname = interp.defineModule('Pathname', object, true)
987
1060
  const pathOf = (c: Call) => {
@@ -4207,7 +4207,7 @@ export function requireFile(
4207
4207
  }
4208
4208
 
4209
4209
  const STDLIB = new Set(
4210
- 'json open3 pathname fileutils digest digest/sha1 digest/md5 net/http uri yaml set rexml rexml/document cocoapods cocoapods-core shellwords tmpdir tempfile erb open-uri rubygems xcodeproj English etc time date logger ostruct optparse securerandom base64 zlib socket timeout benchmark pp stringio find forwardable singleton active_support active_support/core_ext colored2 claide molinillo nanaimo fourflusher cfpropertylist'.split(
4210
+ 'dotenv json open3 pathname fileutils digest digest/sha1 digest/md5 net/http uri yaml set rexml rexml/document cocoapods cocoapods-core shellwords tmpdir tempfile erb open-uri rubygems xcodeproj English etc time date logger ostruct optparse securerandom base64 zlib socket timeout benchmark pp stringio find forwardable singleton active_support active_support/core_ext colored2 claide molinillo nanaimo fourflusher cfpropertylist'.split(
4211
4211
  ' ',
4212
4212
  ),
4213
4213
  )
@@ -156,6 +156,7 @@ interface PodspecPlan {
156
156
  app: string
157
157
  key: string
158
158
  environment: string
159
+ env: NodeJS.ProcessEnv
159
160
  installed?: string
160
161
  receipt?: PodspecReceipt
161
162
  }
@@ -164,11 +165,16 @@ function receiptFile(key: string, environment: string) {
164
165
  return path.join(cacheDir(), 'podspecs', 'receipts-v1', key, `${environment}.json`)
165
166
  }
166
167
 
167
- /** the lookup key and evaluation context a receipt for this podspec must carry. */
168
- export function podspecReceiptIdentity(file: string, appRoot: string | null = null) {
168
+ /** the lookup key and evaluation context a receipt for this podspec must carry.
169
+ * `newArchitecture` is the app's own setting; React Native's core always
170
+ * builds for the new architecture. */
171
+ function podspecReceiptIdentity(
172
+ file: string,
173
+ appRoot: string | null,
174
+ newArchitecture: boolean,
175
+ ) {
169
176
  file = fs.realpathSync(file)
170
177
  const app = fs.realpathSync(appRoot ?? packageRoot(file))
171
- const env = podspecEnv()
172
178
  const ios = path.join(app, 'ios')
173
179
  const keys = inputKeys.get(app) ?? new Map<string, string>()
174
180
  inputKeys.set(app, keys)
@@ -178,6 +184,7 @@ export function podspecReceiptIdentity(file: string, appRoot: string | null = nu
178
184
  const reactNative =
179
185
  z.object({ name: z.string().optional() }).parse(JSON.parse(manifest.toString('utf8')))
180
186
  .name === 'react-native'
187
+ const env = podspecEnv(reactNative || newArchitecture)
181
188
  let key = keys.get(file)
182
189
  if (key === undefined) {
183
190
  // manifests above the install root are host layout, so a Mac evaluation
@@ -252,10 +259,15 @@ export function podspecReceiptIdentity(file: string, appRoot: string | null = nu
252
259
  return { file, app, ios, env, installed, key, environment }
253
260
  }
254
261
 
255
- function planPodspec(podspec: string, appRoot: string | null): PodspecPlan {
256
- const { file, app, installed, key, environment } = podspecReceiptIdentity(
262
+ function planPodspec(
263
+ podspec: string,
264
+ appRoot: string | null,
265
+ newArchitecture: boolean,
266
+ ): PodspecPlan {
267
+ const { file, app, env, installed, key, environment } = podspecReceiptIdentity(
257
268
  podspec,
258
269
  appRoot,
270
+ newArchitecture,
259
271
  )
260
272
  let receipt = appReceipts.get(app)?.get(key) ?? receipts.get(key)
261
273
  // a Linux host keeps a Mac evaluation it restored rather than re-checking it
@@ -274,14 +286,15 @@ function planPodspec(podspec: string, appRoot: string | null): PodspecPlan {
274
286
  receipts.set(key, receipt)
275
287
  }
276
288
  }
277
- return { file, app, key, environment, installed, receipt }
289
+ return { file, app, key, environment, env, installed, receipt }
278
290
  }
279
291
 
280
- function podspecEnv(): NodeJS.ProcessEnv {
292
+ function podspecEnv(newArchitecture = true): NodeJS.ProcessEnv {
293
+ const flag = newArchitecture ? '1' : '0'
281
294
  return {
282
295
  ...process.env,
283
- RCT_NEW_ARCH_ENABLED: '1',
284
- RCT_FABRIC_ENABLED: '1',
296
+ RCT_NEW_ARCH_ENABLED: flag,
297
+ RCT_FABRIC_ENABLED: flag,
285
298
  LANG: 'en_US.UTF-8',
286
299
  LC_ALL: 'en_US.UTF-8',
287
300
  }
@@ -293,17 +306,22 @@ function registerReceipt(plan: PodspecPlan, receipt: PodspecReceipt) {
293
306
  appReceipts.set(plan.app, values)
294
307
  }
295
308
 
296
- export function loadPodspec(file: string, appRoot: string | null = null): Spec {
297
- return loadPodspecs([file], appRoot)[0]!
309
+ export function loadPodspec(
310
+ file: string,
311
+ appRoot: string | null = null,
312
+ newArchitecture = true,
313
+ ): Spec {
314
+ return loadPodspecs([file], appRoot, newArchitecture)[0]!
298
315
  }
299
316
 
300
317
  /** the specs for `files` in input order. */
301
318
  export function loadPodspecs(
302
319
  files: readonly string[],
303
320
  appRoot: string | null = null,
321
+ newArchitecture = true,
304
322
  ): Spec[] {
305
323
  return files.map((podspec) => {
306
- const plan = planPodspec(podspec, appRoot)
324
+ const plan = planPodspec(podspec, appRoot, newArchitecture)
307
325
  if (!plan.receipt) {
308
326
  plan.receipt = {
309
327
  key: plan.key,
@@ -314,7 +332,7 @@ export function loadPodspecs(
314
332
  plan.file,
315
333
  plan.app,
316
334
  packageRoot(plan.file),
317
- podspecEnv(),
335
+ plan.env,
318
336
  plan.installed,
319
337
  ),
320
338
  ),
@@ -1,4 +1,10 @@
1
- import { spawn, spawnSync, type ChildProcess } from 'node:child_process'
1
+ import {
2
+ spawn,
3
+ spawnSync,
4
+ type ChildProcess,
5
+ type ChildProcessWithoutNullStreams,
6
+ type SpawnOptions,
7
+ } from 'node:child_process'
2
8
  import {
3
9
  appendFileSync,
4
10
  mkdtempSync,
@@ -23,6 +29,100 @@ const EXIT_SCAN_TIMEOUT_MS = 10_000
23
29
  const INSPECTION_TIMEOUT_MS = 10_000
24
30
  const FREEZE_GUARD_NAME = 'process-freeze-guard'
25
31
 
32
+ type OwnedProcessOptions = Omit<SpawnOptions, 'detached' | 'shell' | 'stdio'>
33
+
34
+ const ownedProcessGroups = new WeakSet<ChildProcess>()
35
+ // swiftc creates separate groups for its frontends. freeze parents before
36
+ // reading their children so they cannot launch or exit during the walk.
37
+ const stopCompilerTree = [
38
+ 'stop_tree() {',
39
+ ' kill -STOP "$1" 2>/dev/null || return',
40
+ process.platform === 'linux'
41
+ ? [
42
+ 'children=',
43
+ 'for file in /proc/"$1"/task/*/children; do',
44
+ ' [ -r "$file" ] || continue',
45
+ ' pids=',
46
+ ' IFS= read -r pids <"$file" || :',
47
+ ' children="$children $pids"',
48
+ 'done',
49
+ ].join('\n')
50
+ : 'children=$(/usr/bin/pgrep -P "$1")',
51
+ ' for child in $children; do stop_tree "$child"; done',
52
+ ' kill -KILL "$1" 2>/dev/null || :',
53
+ '}',
54
+ ].join('\n')
55
+
56
+ export function spawnOwnedProcessGroup(
57
+ command: string,
58
+ args: readonly string[],
59
+ options: OwnedProcessOptions & { output?: undefined },
60
+ register?: (child: ChildProcess) => void,
61
+ ): ChildProcessWithoutNullStreams
62
+ export function spawnOwnedProcessGroup(
63
+ command: string,
64
+ args: readonly string[],
65
+ options: OwnedProcessOptions & { output: [number | 'inherit', 'inherit'] },
66
+ register?: (child: ChildProcess) => void,
67
+ ): ChildProcess
68
+ export function spawnOwnedProcessGroup(
69
+ command: string,
70
+ args: readonly string[],
71
+ options: OwnedProcessOptions & { output?: [number | 'inherit', 'inherit'] },
72
+ register?: (child: ChildProcess) => void,
73
+ ): ChildProcess {
74
+ const { output, ...launch } = options
75
+ // the monitor shares the compiler's uid and group. only the builder owns
76
+ // the writing end, so its death kills the group even after SIGKILL.
77
+ const child = spawn(
78
+ '/bin/sh',
79
+ [
80
+ '-c',
81
+ [
82
+ 'IFS= read -r start || exit 1',
83
+ 'exec 3<&0',
84
+ '"$@" </dev/null 3<&- &',
85
+ 'compiler=$!',
86
+ '(',
87
+ ' trap "" HUP INT TERM',
88
+ ' IFS= read -r _ <&3',
89
+ stopCompilerTree,
90
+ ' stop_tree "$compiler"',
91
+ ' kill -KILL 0',
92
+ ') >/dev/null 2>&1 &',
93
+ 'monitor=$!',
94
+ 'wait "$compiler"',
95
+ 'status=$?',
96
+ 'kill -KILL "$monitor" 2>/dev/null',
97
+ 'wait "$monitor" 2>/dev/null',
98
+ 'exit "$status"',
99
+ ].join('\n'),
100
+ 'process-group',
101
+ command,
102
+ ...args,
103
+ ],
104
+ {
105
+ ...launch,
106
+ detached: true,
107
+ stdio: output ? ['pipe', ...output] : ['pipe', 'pipe', 'pipe'],
108
+ },
109
+ )
110
+ ownedProcessGroups.add(child)
111
+ const control = child.stdin!
112
+ control.on('error', () => {})
113
+ try {
114
+ if (child.pid === undefined) control.destroy()
115
+ else {
116
+ register?.(child)
117
+ control.write('go\n')
118
+ }
119
+ } catch (error) {
120
+ control.destroy()
121
+ throw error
122
+ }
123
+ return child
124
+ }
125
+
26
126
  // keep this self-contained: the detached browser host embeds its source.
27
127
  export function listProcessChildren(parents: number[], timeoutMs = 10_000): number[] {
28
128
  if (parents.some((pid) => !Number.isInteger(pid) || pid <= 1))
@@ -216,17 +316,37 @@ export function groupIsEmpty(pgid: number): boolean {
216
316
  return processesHaveExited([], pgid)
217
317
  }
218
318
 
219
- /** kills a group whose spawner died, so no ChildProcess remains to terminate.
220
- * a group that is gone or refuses the signal is left to the caller's check. */
221
- export function killOrphanedProcessGroup(pgid: number): void {
319
+ // older lock holders could leave groups without a monitor. a confined linux
320
+ // builder may be allowed to switch to the compiler uid but lack CAP_KILL.
321
+ export function killOrphanedProcessGroup(pgid: number, memberPid: number): boolean {
222
322
  if (!Number.isInteger(pgid) || pgid <= 1)
223
323
  throw new Error(`invalid process group ${pgid}`)
224
324
  try {
225
325
  process.kill(-pgid, 'SIGKILL')
326
+ return true
226
327
  } catch (error) {
227
328
  const code = error instanceof Error && 'code' in error ? error.code : undefined
228
- if (code !== 'ESRCH' && code !== 'EPERM') throw error
329
+ if (code === 'ESRCH') return true
330
+ if (code !== 'EPERM') throw error
331
+ }
332
+ if (process.platform !== 'linux' || process.getuid?.() !== 0) return false
333
+ let status: string
334
+ try {
335
+ status = readFileSync(`/proc/${memberPid}/status`, 'utf8')
336
+ } catch (error) {
337
+ if (error instanceof Error && 'code' in error && error.code === 'ENOENT') return true
338
+ throw error
229
339
  }
340
+ const uid = Number(/^Uid:\s+(\d+)/m.exec(status)?.[1])
341
+ if (!Number.isInteger(uid) || uid === 0) return false
342
+ return (
343
+ spawnSync('/bin/kill', ['-KILL', '--', String(-pgid)], {
344
+ uid,
345
+ stdio: 'ignore',
346
+ timeout: FORCED_EXIT_TIMEOUT_MS,
347
+ killSignal: 'SIGKILL',
348
+ }).status === 0
349
+ )
230
350
  }
231
351
 
232
352
  async function waitForExit(
@@ -268,6 +388,16 @@ export async function terminateProcessGroup(
268
388
  if (groupIsEmpty(child.pid)) return
269
389
  }
270
390
 
391
+ if (
392
+ ownedProcessGroups.has(child) &&
393
+ child.exitCode === null &&
394
+ child.signalCode === null
395
+ ) {
396
+ child.stdin!.end()
397
+ if (await waitForExit([], child.pid, EXIT_SCAN_TIMEOUT_MS)) return
398
+ throw new Error(`owned process group ${child.pid} exit could not be confirmed`)
399
+ }
400
+
271
401
  const freeze = await protectProcessFreeze(child.pid)
272
402
  const descendants = new Set<number>()
273
403
  let inspectionError: Error | null = null