@ng-native/desktop 0.0.0 → 0.24.0

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 (401) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +52 -0
  3. package/app.plugin.cjs +17 -0
  4. package/bin/app-config.mjs +168 -0
  5. package/bin/autolink.mjs +224 -0
  6. package/bin/cli.mjs +158 -0
  7. package/bin/host.mjs +427 -0
  8. package/bin/ng-native-desktop.mjs +4 -0
  9. package/bin/package.mjs +971 -0
  10. package/bin/plist.mjs +68 -0
  11. package/bin/prebuilt.mjs +328 -0
  12. package/bin/toolchain.mjs +192 -0
  13. package/native/CMakeLists.txt +277 -0
  14. package/native/appkit/CMakeLists.txt +130 -0
  15. package/native/appkit/address-search.h +26 -0
  16. package/native/appkit/address-search.mm +277 -0
  17. package/native/appkit/animation-frames.h +14 -0
  18. package/native/appkit/animation-frames.mm +106 -0
  19. package/native/appkit/app-info.h +12 -0
  20. package/native/appkit/app-info.mm +98 -0
  21. package/native/appkit/app-updater.mm +128 -0
  22. package/native/appkit/app-windows.h +81 -0
  23. package/native/appkit/app-windows.mm +318 -0
  24. package/native/appkit/appkit-backend.h +73 -0
  25. package/native/appkit/appkit-backend.mm +276 -0
  26. package/native/appkit/apple-authentication.h +19 -0
  27. package/native/appkit/apple-authentication.mm +248 -0
  28. package/native/appkit/apple-button-view.h +10 -0
  29. package/native/appkit/apple-button-view.mm +37 -0
  30. package/native/appkit/apple-id-button.h +16 -0
  31. package/native/appkit/apple-id-button.mm +50 -0
  32. package/native/appkit/audio.h +16 -0
  33. package/native/appkit/audio.mm +275 -0
  34. package/native/appkit/battery.h +13 -0
  35. package/native/appkit/battery.mm +92 -0
  36. package/native/appkit/bookmarks.h +17 -0
  37. package/native/appkit/bookmarks.mm +145 -0
  38. package/native/appkit/calendar.h +25 -0
  39. package/native/appkit/calendar.mm +660 -0
  40. package/native/appkit/camera-sheet.h +59 -0
  41. package/native/appkit/camera-sheet.mm +344 -0
  42. package/native/appkit/camera-view.h +15 -0
  43. package/native/appkit/camera-view.mm +134 -0
  44. package/native/appkit/camera.h +61 -0
  45. package/native/appkit/camera.mm +496 -0
  46. package/native/appkit/cg-canvas.h +24 -0
  47. package/native/appkit/cg-canvas.mm +663 -0
  48. package/native/appkit/component-view.h +17 -0
  49. package/native/appkit/crypto.h +19 -0
  50. package/native/appkit/crypto.mm +78 -0
  51. package/native/appkit/desktop-expo.h +29 -0
  52. package/native/appkit/desktop-expo.mm +385 -0
  53. package/native/appkit/expo-image-drawing.h +46 -0
  54. package/native/appkit/expo-image-drawing.mm +131 -0
  55. package/native/appkit/expo-image-view.h +15 -0
  56. package/native/appkit/expo-image-view.mm +182 -0
  57. package/native/appkit/expo-ui-renderer.h +68 -0
  58. package/native/appkit/expo-ui-renderer.mm +101 -0
  59. package/native/appkit/expo-ui-view.h +26 -0
  60. package/native/appkit/expo-ui-view.mm +134 -0
  61. package/native/appkit/expo-ui.swift +1284 -0
  62. package/native/appkit/file-system.h +16 -0
  63. package/native/appkit/file-system.mm +140 -0
  64. package/native/appkit/fonts.h +12 -0
  65. package/native/appkit/fonts.mm +48 -0
  66. package/native/appkit/geocoder.h +19 -0
  67. package/native/appkit/geocoder.mm +101 -0
  68. package/native/appkit/glass-effect.h +22 -0
  69. package/native/appkit/glass-effect.mm +63 -0
  70. package/native/appkit/glass-view.h +8 -0
  71. package/native/appkit/glass-view.mm +65 -0
  72. package/native/appkit/header-toolbar.h +60 -0
  73. package/native/appkit/header-toolbar.mm +632 -0
  74. package/native/appkit/host-view.h +54 -0
  75. package/native/appkit/host-view.mm +1228 -0
  76. package/native/appkit/image-manipulator.h +14 -0
  77. package/native/appkit/image-manipulator.mm +191 -0
  78. package/native/appkit/image-request.h +22 -0
  79. package/native/appkit/image-request.mm +62 -0
  80. package/native/appkit/image-view.h +8 -0
  81. package/native/appkit/image-view.mm +142 -0
  82. package/native/appkit/input-replay.h +25 -0
  83. package/native/appkit/input-replay.mm +418 -0
  84. package/native/appkit/language-model.h +14 -0
  85. package/native/appkit/language-model.mm +99 -0
  86. package/native/appkit/language-model.swift +472 -0
  87. package/native/appkit/local-authentication.h +15 -0
  88. package/native/appkit/local-authentication.mm +133 -0
  89. package/native/appkit/location.h +16 -0
  90. package/native/appkit/location.mm +214 -0
  91. package/native/appkit/main.mm +1475 -0
  92. package/native/appkit/map-view.h +15 -0
  93. package/native/appkit/map-view.mm +109 -0
  94. package/native/appkit/maps.h +35 -0
  95. package/native/appkit/maps.mm +343 -0
  96. package/native/appkit/menu-bar.h +22 -0
  97. package/native/appkit/menu-bar.mm +208 -0
  98. package/native/appkit/modal-focus.h +16 -0
  99. package/native/appkit/modal-focus.mm +26 -0
  100. package/native/appkit/modal-host-view.h +79 -0
  101. package/native/appkit/modal-host-view.mm +442 -0
  102. package/native/appkit/native-controls.h +22 -0
  103. package/native/appkit/native-controls.mm +431 -0
  104. package/native/appkit/network-state.h +12 -0
  105. package/native/appkit/network-state.mm +64 -0
  106. package/native/appkit/network.h +14 -0
  107. package/native/appkit/network.mm +396 -0
  108. package/native/appkit/notifications.h +19 -0
  109. package/native/appkit/notifications.mm +309 -0
  110. package/native/appkit/photo-library.h +33 -0
  111. package/native/appkit/photo-library.mm +548 -0
  112. package/native/appkit/pointer-buttons.h +32 -0
  113. package/native/appkit/presentation-label.h +15 -0
  114. package/native/appkit/presentation-label.mm +12 -0
  115. package/native/appkit/presented-screen.h +19 -0
  116. package/native/appkit/presented-screen.mm +181 -0
  117. package/native/appkit/printing.h +42 -0
  118. package/native/appkit/printing.mm +393 -0
  119. package/native/appkit/push.h +19 -0
  120. package/native/appkit/push.mm +81 -0
  121. package/native/appkit/red-box.h +26 -0
  122. package/native/appkit/red-box.mm +387 -0
  123. package/native/appkit/screen-capture.h +21 -0
  124. package/native/appkit/screen-capture.mm +92 -0
  125. package/native/appkit/scroll-view.h +13 -0
  126. package/native/appkit/scroll-view.mm +251 -0
  127. package/native/appkit/scrollers.h +25 -0
  128. package/native/appkit/scrollers.mm +43 -0
  129. package/native/appkit/search-field.h +34 -0
  130. package/native/appkit/search-field.mm +291 -0
  131. package/native/appkit/search-toolbar-item.h +19 -0
  132. package/native/appkit/search-toolbar-item.mm +269 -0
  133. package/native/appkit/share-picker.h +34 -0
  134. package/native/appkit/share-picker.mm +121 -0
  135. package/native/appkit/split-view.h +77 -0
  136. package/native/appkit/split-view.mm +1206 -0
  137. package/native/appkit/store-review.h +13 -0
  138. package/native/appkit/store-review.mm +28 -0
  139. package/native/appkit/surface-view.h +45 -0
  140. package/native/appkit/surface-view.mm +562 -0
  141. package/native/appkit/svg-view.h +18 -0
  142. package/native/appkit/svg-view.mm +103 -0
  143. package/native/appkit/symbol-drawing.h +24 -0
  144. package/native/appkit/symbol-drawing.mm +117 -0
  145. package/native/appkit/symbol-view.h +8 -0
  146. package/native/appkit/symbol-view.mm +33 -0
  147. package/native/appkit/system-access.h +34 -0
  148. package/native/appkit/system-access.mm +210 -0
  149. package/native/appkit/system.h +24 -0
  150. package/native/appkit/system.mm +403 -0
  151. package/native/appkit/tab-walk.h +31 -0
  152. package/native/appkit/tab-walk.mm +64 -0
  153. package/native/appkit/test-launch.h +36 -0
  154. package/native/appkit/test-launch.mm +115 -0
  155. package/native/appkit/text-input-field.h +81 -0
  156. package/native/appkit/text-input-field.mm +525 -0
  157. package/native/appkit/text-layout.h +58 -0
  158. package/native/appkit/text-layout.mm +485 -0
  159. package/native/appkit/text-recognition.h +13 -0
  160. package/native/appkit/text-recognition.mm +102 -0
  161. package/native/appkit/tracking.h +13 -0
  162. package/native/appkit/tracking.mm +51 -0
  163. package/native/appkit/tray-and-dock.h +45 -0
  164. package/native/appkit/tray-and-dock.mm +130 -0
  165. package/native/appkit/undo.h +23 -0
  166. package/native/appkit/undo.mm +125 -0
  167. package/native/appkit/updates.h +17 -0
  168. package/native/appkit/updates.mm +71 -0
  169. package/native/appkit/video-view.h +10 -0
  170. package/native/appkit/video-view.mm +42 -0
  171. package/native/appkit/video.h +38 -0
  172. package/native/appkit/video.mm +404 -0
  173. package/native/appkit/web-browser.h +12 -0
  174. package/native/appkit/web-browser.mm +97 -0
  175. package/native/appkit/web-view-component.h +10 -0
  176. package/native/appkit/web-view-component.mm +62 -0
  177. package/native/appkit/web-view.h +31 -0
  178. package/native/appkit/web-view.mm +401 -0
  179. package/native/cmake/libraries/react-native-reanimated.cmake +45 -0
  180. package/native/cmake/libraries/react-native-worklets.cmake +46 -0
  181. package/native/cmake/libraries.cmake +109 -0
  182. package/native/cmake/linked-modules.cmake +112 -0
  183. package/native/cmake/react-native.cmake +175 -0
  184. package/native/cmake/runtime-dependencies.cmake +34 -0
  185. package/native/cmake/swift.cmake +43 -0
  186. package/native/cmake/third-party.cmake +74 -0
  187. package/native/core/include/ngn/absent-views.h +27 -0
  188. package/native/core/include/ngn/accessibility.h +140 -0
  189. package/native/core/include/ngn/address-search.h +69 -0
  190. package/native/core/include/ngn/animation-frames.h +39 -0
  191. package/native/core/include/ngn/app-info.h +52 -0
  192. package/native/core/include/ngn/app-menus.h +151 -0
  193. package/native/core/include/ngn/app-windows.h +181 -0
  194. package/native/core/include/ngn/apple-authentication.h +116 -0
  195. package/native/core/include/ngn/asset.h +28 -0
  196. package/native/core/include/ngn/audio.h +125 -0
  197. package/native/core/include/ngn/back-swipe.h +121 -0
  198. package/native/core/include/ngn/battery.h +48 -0
  199. package/native/core/include/ngn/bytes.h +59 -0
  200. package/native/core/include/ngn/calendar.h +180 -0
  201. package/native/core/include/ngn/camera.h +222 -0
  202. package/native/core/include/ngn/control-sizes.h +111 -0
  203. package/native/core/include/ngn/core-modules.h +108 -0
  204. package/native/core/include/ngn/crypto.h +38 -0
  205. package/native/core/include/ngn/default-menu.h +91 -0
  206. package/native/core/include/ngn/desktop-expo.h +193 -0
  207. package/native/core/include/ngn/desktop-modal.h +109 -0
  208. package/native/core/include/ngn/desktop-props.h +75 -0
  209. package/native/core/include/ngn/desktop-view-props.h +110 -0
  210. package/native/core/include/ngn/dev-server.h +33 -0
  211. package/native/core/include/ngn/dom-web-view.h +53 -0
  212. package/native/core/include/ngn/download.h +24 -0
  213. package/native/core/include/ngn/expo-image.h +192 -0
  214. package/native/core/include/ngn/expo-ui.h +133 -0
  215. package/native/core/include/ngn/file-system.h +274 -0
  216. package/native/core/include/ngn/focus-order.h +63 -0
  217. package/native/core/include/ngn/fonts.h +64 -0
  218. package/native/core/include/ngn/gestures.h +305 -0
  219. package/native/core/include/ngn/glass.h +67 -0
  220. package/native/core/include/ngn/header-bar.h +112 -0
  221. package/native/core/include/ngn/host-state.h +243 -0
  222. package/native/core/include/ngn/image-manipulator.h +70 -0
  223. package/native/core/include/ngn/input-dispatcher.h +211 -0
  224. package/native/core/include/ngn/input-script.h +56 -0
  225. package/native/core/include/ngn/input.h +112 -0
  226. package/native/core/include/ngn/key-value-store.h +41 -0
  227. package/native/core/include/ngn/language-model.h +69 -0
  228. package/native/core/include/ngn/launch-frame.h +47 -0
  229. package/native/core/include/ngn/launch-settings.h +98 -0
  230. package/native/core/include/ngn/layout-animations.h +24 -0
  231. package/native/core/include/ngn/library-components.h +13 -0
  232. package/native/core/include/ngn/library-glue.h +53 -0
  233. package/native/core/include/ngn/live-regions.h +54 -0
  234. package/native/core/include/ngn/local-authentication.h +74 -0
  235. package/native/core/include/ngn/location.h +89 -0
  236. package/native/core/include/ngn/maps.h +226 -0
  237. package/native/core/include/ngn/module-registry.h +51 -0
  238. package/native/core/include/ngn/mounting-backend.h +96 -0
  239. package/native/core/include/ngn/mounting-manager.h +155 -0
  240. package/native/core/include/ngn/native-controls.h +161 -0
  241. package/native/core/include/ngn/native-module.h +109 -0
  242. package/native/core/include/ngn/network-state.h +44 -0
  243. package/native/core/include/ngn/network.h +100 -0
  244. package/native/core/include/ngn/notifications.h +185 -0
  245. package/native/core/include/ngn/photo-library.h +134 -0
  246. package/native/core/include/ngn/printing.h +69 -0
  247. package/native/core/include/ngn/processes.h +114 -0
  248. package/native/core/include/ngn/red-box.h +119 -0
  249. package/native/core/include/ngn/reload-thread.h +258 -0
  250. package/native/core/include/ngn/runtime.h +163 -0
  251. package/native/core/include/ngn/safe-areas.h +82 -0
  252. package/native/core/include/ngn/screen-capture.h +35 -0
  253. package/native/core/include/ngn/screen-presentation.h +85 -0
  254. package/native/core/include/ngn/screen-stacks.h +80 -0
  255. package/native/core/include/ngn/scrollers.h +106 -0
  256. package/native/core/include/ngn/sharing.h +39 -0
  257. package/native/core/include/ngn/spawn-rules.h +78 -0
  258. package/native/core/include/ngn/splash-screen.h +41 -0
  259. package/native/core/include/ngn/split-view.h +270 -0
  260. package/native/core/include/ngn/sqlite.h +38 -0
  261. package/native/core/include/ngn/store-review.h +26 -0
  262. package/native/core/include/ngn/surface-book.h +101 -0
  263. package/native/core/include/ngn/surface-metrics.h +51 -0
  264. package/native/core/include/ngn/svg.h +434 -0
  265. package/native/core/include/ngn/symbol.h +90 -0
  266. package/native/core/include/ngn/system.h +102 -0
  267. package/native/core/include/ngn/tabs-host.h +171 -0
  268. package/native/core/include/ngn/text-input.h +134 -0
  269. package/native/core/include/ngn/text-measurer.h +38 -0
  270. package/native/core/include/ngn/text-recognition.h +55 -0
  271. package/native/core/include/ngn/tracking.h +34 -0
  272. package/native/core/include/ngn/tray-and-dock.h +107 -0
  273. package/native/core/include/ngn/undo.h +37 -0
  274. package/native/core/include/ngn/updates.h +253 -0
  275. package/native/core/include/ngn/video.h +126 -0
  276. package/native/core/include/ngn/view-box.h +126 -0
  277. package/native/core/include/ngn/view-transform.h +26 -0
  278. package/native/core/include/ngn/view-tree.h +85 -0
  279. package/native/core/include/ngn/web-browser.h +45 -0
  280. package/native/core/include/ngn/web-view.h +137 -0
  281. package/native/core/include/ngn/worklet-host.h +98 -0
  282. package/native/core/src/absent-views.cpp +41 -0
  283. package/native/core/src/accessibility.cpp +374 -0
  284. package/native/core/src/animation-frames.cpp +49 -0
  285. package/native/core/src/app-menus.cpp +359 -0
  286. package/native/core/src/app-windows.cpp +444 -0
  287. package/native/core/src/back-swipe.cpp +98 -0
  288. package/native/core/src/bytes.cpp +158 -0
  289. package/native/core/src/control-sizes.cpp +232 -0
  290. package/native/core/src/default-menu.cpp +96 -0
  291. package/native/core/src/desktop-modal.cpp +162 -0
  292. package/native/core/src/desktop-view-props.cpp +80 -0
  293. package/native/core/src/dev-server-helper.cpp +152 -0
  294. package/native/core/src/dev-server.cpp +103 -0
  295. package/native/core/src/dom-web-view.cpp +45 -0
  296. package/native/core/src/download.cpp +53 -0
  297. package/native/core/src/expo-image.cpp +548 -0
  298. package/native/core/src/expo-ui.cpp +203 -0
  299. package/native/core/src/focus-order.cpp +441 -0
  300. package/native/core/src/gestures.cpp +1806 -0
  301. package/native/core/src/glass.cpp +49 -0
  302. package/native/core/src/header-bar.cpp +104 -0
  303. package/native/core/src/host-services.cpp +50 -0
  304. package/native/core/src/host-state.cpp +61 -0
  305. package/native/core/src/input-dispatcher.cpp +727 -0
  306. package/native/core/src/input-script.cpp +123 -0
  307. package/native/core/src/key-value-store.cpp +169 -0
  308. package/native/core/src/launch-settings.cpp +148 -0
  309. package/native/core/src/layout-animations.cpp +62 -0
  310. package/native/core/src/libraries/RNCWebViewSpec.cpp +80 -0
  311. package/native/core/src/libraries/react-native-reanimated.cpp +216 -0
  312. package/native/core/src/libraries/react-native-worklets.cpp +192 -0
  313. package/native/core/src/libraries/rnscreens.cpp +125 -0
  314. package/native/core/src/libraries/rnsvg.cpp +358 -0
  315. package/native/core/src/libraries/safeareacontext.cpp +70 -0
  316. package/native/core/src/libraries/worklets-idle-frames.js +70 -0
  317. package/native/core/src/library-glue.cpp +35 -0
  318. package/native/core/src/live-regions.cpp +122 -0
  319. package/native/core/src/module-registry.cpp +50 -0
  320. package/native/core/src/modules/accessibility-manager.cpp +98 -0
  321. package/native/core/src/modules/address-search.cpp +219 -0
  322. package/native/core/src/modules/alert-manager.cpp +140 -0
  323. package/native/core/src/modules/app-info.cpp +74 -0
  324. package/native/core/src/modules/app-modules.cpp +412 -0
  325. package/native/core/src/modules/apple-authentication.cpp +188 -0
  326. package/native/core/src/modules/asset.cpp +111 -0
  327. package/native/core/src/modules/async-storage.cpp +192 -0
  328. package/native/core/src/modules/audio.cpp +541 -0
  329. package/native/core/src/modules/battery.cpp +88 -0
  330. package/native/core/src/modules/calendar.cpp +457 -0
  331. package/native/core/src/modules/camera.cpp +401 -0
  332. package/native/core/src/modules/core-modules.cpp +62 -0
  333. package/native/core/src/modules/crypto.cpp +117 -0
  334. package/native/core/src/modules/desktop-expo.cpp +527 -0
  335. package/native/core/src/modules/file-system.cpp +941 -0
  336. package/native/core/src/modules/fonts.cpp +163 -0
  337. package/native/core/src/modules/image-loader.cpp +105 -0
  338. package/native/core/src/modules/image-manipulator.cpp +305 -0
  339. package/native/core/src/modules/language-model.cpp +195 -0
  340. package/native/core/src/modules/local-authentication.cpp +140 -0
  341. package/native/core/src/modules/location.cpp +186 -0
  342. package/native/core/src/modules/maps.cpp +500 -0
  343. package/native/core/src/modules/network-state.cpp +72 -0
  344. package/native/core/src/modules/networking.cpp +387 -0
  345. package/native/core/src/modules/notifications.cpp +549 -0
  346. package/native/core/src/modules/photo-library.cpp +385 -0
  347. package/native/core/src/modules/printing.cpp +201 -0
  348. package/native/core/src/modules/screen-capture.cpp +71 -0
  349. package/native/core/src/modules/sharing.cpp +59 -0
  350. package/native/core/src/modules/splash-screen.cpp +70 -0
  351. package/native/core/src/modules/sqlite.cpp +421 -0
  352. package/native/core/src/modules/store-review.cpp +23 -0
  353. package/native/core/src/modules/text-recognition.cpp +107 -0
  354. package/native/core/src/modules/tracking.cpp +46 -0
  355. package/native/core/src/modules/undo.cpp +59 -0
  356. package/native/core/src/modules/video.cpp +366 -0
  357. package/native/core/src/modules/web-browser.cpp +100 -0
  358. package/native/core/src/modules/web-socket.cpp +266 -0
  359. package/native/core/src/mounting-manager.cpp +384 -0
  360. package/native/core/src/native-controls.cpp +129 -0
  361. package/native/core/src/native-module.cpp +250 -0
  362. package/native/core/src/network.cpp +219 -0
  363. package/native/core/src/posix-launcher.cpp +366 -0
  364. package/native/core/src/processes.cpp +324 -0
  365. package/native/core/src/red-box-errors.js +83 -0
  366. package/native/core/src/red-box.cpp +306 -0
  367. package/native/core/src/runtime.cpp +420 -0
  368. package/native/core/src/safe-areas.cpp +137 -0
  369. package/native/core/src/screen-presentation.cpp +61 -0
  370. package/native/core/src/screen-stacks.cpp +254 -0
  371. package/native/core/src/scrollers.cpp +181 -0
  372. package/native/core/src/spawn-rules.cpp +292 -0
  373. package/native/core/src/split-view.cpp +343 -0
  374. package/native/core/src/svg.cpp +2190 -0
  375. package/native/core/src/symbol.cpp +94 -0
  376. package/native/core/src/tabs-host.cpp +234 -0
  377. package/native/core/src/text-input.cpp +139 -0
  378. package/native/core/src/text-layout-manager.cpp +63 -0
  379. package/native/core/src/tray-and-dock.cpp +154 -0
  380. package/native/core/src/updates.cpp +965 -0
  381. package/native/core/src/view-box.cpp +788 -0
  382. package/native/core/src/view-transform.cpp +45 -0
  383. package/native/core/src/view-tree.cpp +234 -0
  384. package/native/core/src/web-view.cpp +143 -0
  385. package/native/core/src/worklet-host.cpp +10 -0
  386. package/native/scripts/build-hermes.sh +44 -0
  387. package/native/scripts/build.sh +175 -0
  388. package/native/scripts/cache-dir.sh +18 -0
  389. package/native/scripts/codegen-library.sh +193 -0
  390. package/native/scripts/compiler-launcher.sh +17 -0
  391. package/native/scripts/fetch.sh +174 -0
  392. package/native/scripts/hermes-built.sh +10 -0
  393. package/native/scripts/host-dir.sh +16 -0
  394. package/native/scripts/launch-probe.sh +60 -0
  395. package/native/scripts/macos-target.sh +8 -0
  396. package/native/scripts/make-prebuilt.mjs +360 -0
  397. package/native/scripts/prebuilt-host-cache.mjs +158 -0
  398. package/native/shim/openssl/sha.h +22 -0
  399. package/native/shim/view-platform/react/renderer/components/view/HostPlatformViewTraitsInitializer.h +37 -0
  400. package/package.json +73 -1
  401. package/prebuilt.json +33 -0
package/bin/plist.mjs ADDED
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Property lists as XML, the form `Info.plist` and an entitlements file take. Strings, booleans,
3
+ * whole numbers, lists and dictionaries; `undefined` and `null` values are left out.
4
+ */
5
+
6
+ /**
7
+ * @typedef {string | number | boolean | null | undefined | PlistArray | PlistDict} PlistValue
8
+ * @typedef {Array<PlistValue>} PlistArray
9
+ * @typedef {{ [key: string]: PlistValue }} PlistDict
10
+ */
11
+
12
+ /**
13
+ * @param {PlistDict} root
14
+ * @returns {string}
15
+ */
16
+ export function plist(root) {
17
+ return [
18
+ '<?xml version="1.0" encoding="UTF-8"?>',
19
+ '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">',
20
+ '<plist version="1.0">',
21
+ ...value(root, ''),
22
+ '</plist>',
23
+ '',
24
+ ].join('\n');
25
+ }
26
+
27
+ /**
28
+ * @param {PlistValue} item
29
+ * @param {string} indent
30
+ * @returns {string[]}
31
+ */
32
+ function value(item, indent) {
33
+ if (typeof item === 'string') return [`${indent}<string>${escape(item)}</string>`];
34
+ if (typeof item === 'boolean') return [`${indent}<${item}/>`];
35
+ if (typeof item === 'number') {
36
+ if (!Number.isInteger(item)) throw new Error(`plist: ${item} is not a whole number`);
37
+ return [`${indent}<integer>${item}</integer>`];
38
+ }
39
+ if (Array.isArray(item)) {
40
+ const items = item.filter((entry) => entry !== undefined && entry !== null);
41
+ if (items.length === 0) return [`${indent}<array/>`];
42
+ return [
43
+ `${indent}<array>`,
44
+ ...items.flatMap((entry) => value(entry, `${indent}\t`)),
45
+ `${indent}</array>`,
46
+ ];
47
+ }
48
+ if (item && typeof item === 'object') {
49
+ const entries = Object.entries(item).filter(
50
+ ([, entry]) => entry !== undefined && entry !== null,
51
+ );
52
+ if (entries.length === 0) return [`${indent}<dict/>`];
53
+ return [
54
+ `${indent}<dict>`,
55
+ ...entries.flatMap(([key, entry]) => [
56
+ `${indent}\t<key>${escape(key)}</key>`,
57
+ ...value(entry, `${indent}\t`),
58
+ ]),
59
+ `${indent}</dict>`,
60
+ ];
61
+ }
62
+ throw new Error(`plist: cannot write ${String(item)}`);
63
+ }
64
+
65
+ /** @param {string} text */
66
+ function escape(text) {
67
+ return text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
68
+ }
@@ -0,0 +1,328 @@
1
+ /**
2
+ * Prebuilt desktop hosts: the signed, universal hosts each release publishes per React Native
3
+ * version, so an app with no native desktop code of its own compiles nothing. Each version has two
4
+ * flavours: `debug`, the dev build `run` uses, which carries React Native's debugger, and
5
+ * `release`, the Release build `package` ships, which leaves it out.
6
+ *
7
+ * `prebuilt.json` beside this package lists them, one entry per version and flavour; an entry
8
+ * that names no flavour is a release host. The release workflow writes each entry before
9
+ * the package is packed (`docs/desktop-host.md` has the steps), so the SHA-256 of each archive
10
+ * travels inside the npm package, not beside the archive it vouches for. An archive holds `appkit/ngn-macos`, `appkit/hermesc` and
11
+ * `appkit/Sparkle.framework`, the files a host build's `appkit` folder has, and unpacks into the
12
+ * per-user cache under its own hash, so a new archive never reuses an old one's files.
13
+ *
14
+ * `native/scripts/make-prebuilt.mjs` builds and packs one. The host is signed ad hoc unless
15
+ * `NGN_SIGN_IDENTITY` names an identity: an app re-signs it when it packages, and the download is
16
+ * checked by SHA-256, so no Developer ID is needed.
17
+ */
18
+ import { randomBytes } from 'node:crypto';
19
+ import {
20
+ existsSync,
21
+ mkdirSync,
22
+ readFileSync,
23
+ realpathSync,
24
+ renameSync,
25
+ rmSync,
26
+ writeFileSync,
27
+ } from 'node:fs';
28
+ import path from 'node:path';
29
+
30
+ /** The manifest's format, which `prebuilt.json` names. */
31
+ export const MANIFEST_VERSION = 1;
32
+
33
+ /** The flavours a prebuilt host comes in. */
34
+ export const FLAVOURS = /** @type {const} */ (['debug', 'release']);
35
+
36
+ /**
37
+ * @typedef {typeof FLAVOURS[number]} Flavour
38
+ * @typedef {{ reactNative: string, flavour?: Flavour, url: string, sha256: string, libraries: Record<string, string>, inputs?: string }} PrebuiltHost
39
+ * `flavour` is `release` when it is left out, as a manifest from before the debug host has it.
40
+ * `inputs` is the key of what the host was built from (native/scripts/prebuilt-host-cache.mjs),
41
+ * which the next release's make-prebuilt.mjs --reuse compares with its own
42
+ * @typedef {{ version: number, hosts: PrebuiltHost[] }} PrebuiltManifest
43
+ * @typedef {import('./host.mjs').system} System
44
+ */
45
+
46
+ /**
47
+ * The archive's file name for a release of this package, a React Native version and a flavour.
48
+ * The release host's name has no flavour in it.
49
+ *
50
+ * @param {string} desktopVersion
51
+ * @param {string} reactNative
52
+ * @param {Flavour} [flavour]
53
+ */
54
+ export function prebuiltName(desktopVersion, reactNative, flavour = 'release') {
55
+ const suffix = flavour === 'release' ? '' : `-${flavour}`;
56
+ return `ng-native-desktop-host-${desktopVersion}-rn-${reactNative}-macos-universal${suffix}.tar.gz`;
57
+ }
58
+
59
+ /**
60
+ * The file `make-prebuilt.mjs` writes a host's manifest entry to, beside its archive: one per
61
+ * flavour, so both flavours' builds can share a folder.
62
+ *
63
+ * @param {Flavour} flavour
64
+ */
65
+ export function entryName(flavour) {
66
+ return `prebuilt-host-${flavour}.json`;
67
+ }
68
+
69
+ /**
70
+ * A host's flavour: `release` when its entry names none.
71
+ *
72
+ * @param {PrebuiltHost} host
73
+ * @returns {Flavour}
74
+ */
75
+ export function flavourOf(host) {
76
+ return host.flavour ?? 'release';
77
+ }
78
+
79
+ /**
80
+ * The manifest in `text`, or an empty one for text that is not a manifest of this version.
81
+ *
82
+ * @param {string} text
83
+ * @returns {PrebuiltManifest}
84
+ */
85
+ export function readManifest(text) {
86
+ try {
87
+ const manifest = JSON.parse(text);
88
+ if (manifest?.version === MANIFEST_VERSION && Array.isArray(manifest.hosts)) return manifest;
89
+ } catch {
90
+ // Not a manifest: none, below.
91
+ }
92
+ return { version: MANIFEST_VERSION, hosts: [] };
93
+ }
94
+
95
+ /**
96
+ * `manifest` with `host` in it, in place of the one for the same React Native version and flavour.
97
+ *
98
+ * @param {PrebuiltManifest} manifest
99
+ * @param {PrebuiltHost} host
100
+ * @returns {PrebuiltManifest}
101
+ */
102
+ export function withHost(manifest, host) {
103
+ const hosts = manifest.hosts.filter(
104
+ (each) => each.reactNative !== host.reactNative || flavourOf(each) !== flavourOf(host),
105
+ );
106
+ return { version: MANIFEST_VERSION, hosts: [...hosts, host] };
107
+ }
108
+
109
+ /**
110
+ * Puts a packed archive in `out` under its name, with its manifest entry (`entryName`), and writes
111
+ * the entry into `manifest` when one is given. Runs into the same folder take turns, holding
112
+ * `<out>/.make-prebuilt.lock`, and the manifest's folder's lock too when it is elsewhere, so the
113
+ * archive, its entry and the manifest always describe the same build and no run's manifest entry is
114
+ * lost; each file is replaced by a rename, so none is seen half written. An archive already in
115
+ * `out` under `name` is never replaced, since a manifest may name it with its hash.
116
+ *
117
+ * @param {{ out: string, archive: string, name: string, host: PrebuiltHost, manifest?: string }} files
118
+ * `archive` is the packed archive at a temporary name in `out`
119
+ * @param {{ wait?: number }} [options] how long to wait for another run, in milliseconds
120
+ */
121
+ export function publishPrebuilt({ out, archive, name, host, manifest }, { wait = 600_000 } = {}) {
122
+ // The manifest's folder too when it is elsewhere, since another run may be updating it: by real
123
+ // path, so one folder reached two ways is locked once, and in path order, so two runs never each
124
+ // hold the lock the other waits for.
125
+ const folders = [
126
+ ...new Set([out, ...(manifest ? [path.dirname(manifest)] : [])].map((f) => realpathSync(f))),
127
+ ].sort();
128
+ const give = Date.now() + wait;
129
+ /** @type {string[]} */
130
+ const held = [];
131
+ /** @param {string} file @param {string} text */
132
+ const replace = (file, text) => {
133
+ const temp = `${file}.${process.pid}-${randomBytes(4).toString('hex')}`;
134
+ writeFileSync(temp, text);
135
+ renameSync(temp, file);
136
+ };
137
+ try {
138
+ for (const folder of folders) {
139
+ held.push(takeLock(path.join(folder, '.make-prebuilt.lock'), give));
140
+ }
141
+ // A published archive is never replaced: a manifest written by another run may name it with
142
+ // its hash. A rebuild under the same name needs the old archive removed first.
143
+ const target = path.join(out, name);
144
+ if (existsSync(target)) {
145
+ rmSync(archive, { force: true });
146
+ throw new Error(`${target} is already published. Remove it first to publish another build.`);
147
+ }
148
+ renameSync(archive, target);
149
+ replace(path.join(out, entryName(flavourOf(host))), `${JSON.stringify(host, null, 2)}\n`);
150
+ if (manifest) {
151
+ const updated = withHost(readManifest(readFileSync(manifest, 'utf8')), host);
152
+ replace(manifest, `${JSON.stringify(updated, null, 2)}\n`);
153
+ }
154
+ } finally {
155
+ for (const lock of held.reverse()) rmSync(lock, { recursive: true, force: true });
156
+ }
157
+ }
158
+
159
+ /**
160
+ * Makes `lock`, waiting until `give` (a time in milliseconds) while another run holds it.
161
+ *
162
+ * @param {string} lock
163
+ * @param {number} give
164
+ * @returns {string} the lock
165
+ */
166
+ function takeLock(lock, give) {
167
+ for (;;) {
168
+ try {
169
+ mkdirSync(lock);
170
+ return lock;
171
+ } catch (error) {
172
+ if (/** @type {NodeJS.ErrnoException} */ (error).code !== 'EEXIST') throw error;
173
+ if (Date.now() >= give) {
174
+ throw new Error(
175
+ `Another make-prebuilt.mjs run holds ${lock}. Wait for it, or remove the folder if ` +
176
+ 'no run is left.',
177
+ );
178
+ }
179
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 100);
180
+ }
181
+ }
182
+ }
183
+
184
+ /**
185
+ * The prebuilt host an app can run on, or why it builds its own: one is used only for the app's
186
+ * React Native version and the flavour asked for, when the app links no native desktop code, and
187
+ * when each host library it has is the version the host was built with and is not denied.
188
+ *
189
+ * @param {PrebuiltManifest} manifest
190
+ * @param {{ reactNative: string, flavour: Flavour, linked: number, libraries: Record<string, string | null>, deny: readonly string[], env: Record<string, string | undefined> }} app
191
+ * `flavour` is `debug` for a dev run and `release` for a packaged app; `libraries` holds each
192
+ * host library's installed version, or null where the app lacks it
193
+ * @returns {{ host: PrebuiltHost } | { reason: string }}
194
+ */
195
+ export function choosePrebuilt(manifest, { reactNative, flavour, linked, libraries, deny, env }) {
196
+ if (env['NGN_DESKTOP_FROM_SOURCE'] === '1') return { reason: 'NGN_DESKTOP_FROM_SOURCE=1' };
197
+ if (linked > 0) return { reason: 'the app links native desktop code' };
198
+ const host = manifest.hosts.find(
199
+ (each) => each.reactNative === reactNative && flavourOf(each) === flavour,
200
+ );
201
+ if (!host) return { reason: `no prebuilt ${flavour} host for React Native ${reactNative}` };
202
+ for (const name of Object.keys(host.libraries)) {
203
+ if (deny.includes(name)) return { reason: `${name} is denied, and the prebuilt host has it` };
204
+ }
205
+ for (const [name, version] of Object.entries(libraries)) {
206
+ if (version === null) continue;
207
+ if (host.libraries[name] !== version) {
208
+ return {
209
+ reason: `the prebuilt host has ${name} ${host.libraries[name] ?? 'left out'}, the app ${version}`,
210
+ };
211
+ }
212
+ }
213
+ return { host };
214
+ }
215
+
216
+ /**
217
+ * The prebuilt host's build folder in the cache, downloading, checking and unpacking it first when
218
+ * it is not there. Null, with a warning, when it cannot be downloaded, so the host is built from
219
+ * source instead; a download whose SHA-256 is not the manifest's throws, and is deleted. Each run
220
+ * downloads and unpacks into names of its own, so two first runs at once never touch each other's
221
+ * files, and a run that finds the host unpacked by another when it is done uses that one.
222
+ *
223
+ * @param {System} sys
224
+ * @param {PrebuiltHost} host
225
+ * @param {string} cache the React Native version's folder in the per-user cache
226
+ * @returns {string | null}
227
+ */
228
+ export function fetchPrebuilt(sys, host, cache) {
229
+ if (!/^[0-9a-f]{64}$/.test(host.sha256)) {
230
+ throw new Error(
231
+ `prebuilt.json gives the React Native ${host.reactNative} ${flavourOf(host)} host no SHA-256 to check.`,
232
+ );
233
+ }
234
+ const dir = path.join(cache, 'prebuilt', host.sha256.slice(0, 16));
235
+ if (sys.exists(path.join(dir, 'appkit', 'ngn-macos'))) return dir;
236
+ const own = `${dir}.${process.pid}-${randomBytes(4).toString('hex')}`;
237
+ const archive = `${own}.tar.gz`;
238
+ const unpacked = `${own}.partial`;
239
+ const got = sys.run(
240
+ 'curl',
241
+ [
242
+ '--fail',
243
+ '--silent',
244
+ '--show-error',
245
+ '--location',
246
+ '--retry',
247
+ '3',
248
+ '--create-dirs',
249
+ '-o',
250
+ archive,
251
+ host.url,
252
+ ],
253
+ { capture: true },
254
+ );
255
+ if (got.status !== 0) {
256
+ sys.remove(archive);
257
+ sys.warn(
258
+ `Could not download the prebuilt desktop host from ${host.url}, so it is built from source.`,
259
+ );
260
+ return null;
261
+ }
262
+ const sha256 = sys.sha256(archive);
263
+ if (sha256 !== host.sha256) {
264
+ sys.remove(archive);
265
+ throw new Error(
266
+ `The prebuilt desktop host from ${host.url} has SHA-256 ${sha256}, not the ${host.sha256} ` +
267
+ 'this package names, so it was deleted unused. Set NGN_DESKTOP_FROM_SOURCE=1 to build ' +
268
+ 'the host from source.',
269
+ );
270
+ }
271
+ sys.writeFile(path.join(unpacked, '.sha256'), `${sha256}\n`);
272
+ const tar = sys.run('tar', ['-xzf', archive, '-C', unpacked], { capture: true });
273
+ sys.remove(archive);
274
+ if (tar.status !== 0 || !sys.exists(path.join(unpacked, 'appkit', 'ngn-macos'))) {
275
+ sys.remove(unpacked);
276
+ throw new Error(
277
+ `The prebuilt desktop host from ${host.url} did not unpack to appkit/ngn-macos.`,
278
+ );
279
+ }
280
+ // Published by one atomic rename, which fails rather than replace a folder that holds a host,
281
+ // so a host another run has published is never deleted under it.
282
+ const binary = path.join(dir, 'appkit', 'ngn-macos');
283
+ try {
284
+ if (!sys.exists(binary)) sys.rename(unpacked, dir);
285
+ } catch (error) {
286
+ // Another run moved its copy in first.
287
+ if (!sys.exists(binary)) throw error;
288
+ } finally {
289
+ sys.remove(unpacked);
290
+ }
291
+ return dir;
292
+ }
293
+
294
+ /**
295
+ * Strips each file's local symbols, then signs it with the hardened runtime: with
296
+ * `NGN_SIGN_IDENTITY` when that is set and not empty, ad hoc (`--sign -`, no timestamp) otherwise.
297
+ * Throws when a command fails.
298
+ *
299
+ * @param {(command: string, args: string[]) => { status: number | null }} run
300
+ * @param {string[]} files
301
+ * @param {Record<string, string | undefined>} env
302
+ */
303
+ export function signPrebuiltFiles(run, files, env) {
304
+ const identity = env['NGN_SIGN_IDENTITY'] || '-';
305
+ for (const file of files) {
306
+ // Before signing, which stripping would break.
307
+ for (const [command, args] of /** @type {[string, string[]][]} */ ([
308
+ ['strip', ['-x', file]],
309
+ [
310
+ 'codesign',
311
+ [
312
+ '--force',
313
+ '--options',
314
+ 'runtime',
315
+ identity === '-' ? '--timestamp=none' : '--timestamp',
316
+ '--sign',
317
+ identity,
318
+ file,
319
+ ],
320
+ ],
321
+ ])) {
322
+ const result = run(command, args);
323
+ if (result.status !== 0) {
324
+ throw new Error(`${command} ${args.join(' ')} failed (${result.status}).`);
325
+ }
326
+ }
327
+ }
328
+ }
@@ -0,0 +1,192 @@
1
+ /**
2
+ * The tools a from-source build of the desktop host needs, checked before it starts so a missing or
3
+ * old one stops it with the line that fixes it, not a compiler error minutes in.
4
+ */
5
+ import { UsageError } from './host.mjs';
6
+
7
+ /**
8
+ * The oldest version of each tool the host builds with. Swift 6 comes with Xcode 16, the oldest
9
+ * Xcode React Native 0.88 builds with; CMake 3.25 is `native/CMakeLists.txt`'s minimum.
10
+ */
11
+ export const TOOLCHAIN_MINIMUMS = /** @type {const} */ ({
12
+ swift: '6.0',
13
+ cmake: '3.25',
14
+ ninja: '1.10',
15
+ });
16
+
17
+ /**
18
+ * How long the first build of the host for a React Native version takes on an Apple silicon Mac,
19
+ * measured cold: React Native and Hermes compile from source.
20
+ */
21
+ export const FIRST_BUILD_NOTE =
22
+ 'Building the desktop host from source for the first time for this React Native version: React ' +
23
+ 'Native and Hermes compile, which takes about 4 minutes on an Apple silicon Mac (about 6 for a ' +
24
+ 'universal release build). Later runs reuse it.';
25
+
26
+ /**
27
+ * @typedef {{ run(command: string, args: string[], options?: { capture?: boolean }): { status: number, stdout: string } }} ToolRunner
28
+ */
29
+
30
+ /**
31
+ * What running a tool gave: its output; `missing` when it is not on the PATH (spawn's ENOENT); or
32
+ * `failed`, why it is there but did not run (another spawn error, such as EACCES, or a nonzero
33
+ * exit).
34
+ *
35
+ * @param {ToolRunner} sys
36
+ * @param {string} command
37
+ * @param {string[]} args
38
+ * @returns {{ stdout: string } | { missing: true } | { failed: string, exited: boolean, status?: number | null }}
39
+ */
40
+ function probe(sys, command, args) {
41
+ const line = [command, ...args].join(' ');
42
+ try {
43
+ const result = sys.run(command, args, { capture: true });
44
+ if (result.status === 0) return { stdout: result.stdout };
45
+ return {
46
+ failed: `${line} failed (status ${result.status})`,
47
+ exited: true,
48
+ status: result.status,
49
+ };
50
+ } catch (error) {
51
+ const code = /** @type {NodeJS.ErrnoException} */ (error)?.code;
52
+ if (code === 'ENOENT') return { missing: true };
53
+ return { failed: `${line} could not run (${code ?? String(error)})`, exited: false };
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Whether `version` (dotted numbers) is `minimum` or later.
59
+ *
60
+ * @param {string} version
61
+ * @param {string} minimum
62
+ */
63
+ export function atLeast(version, minimum) {
64
+ const have = version.split('.').map(Number);
65
+ const want = minimum.split('.').map(Number);
66
+ for (let i = 0; i < want.length; i++) {
67
+ const a = have[i] ?? 0;
68
+ const b = want[i] ?? 0;
69
+ if (a !== b) return a > b;
70
+ }
71
+ return true;
72
+ }
73
+
74
+ /**
75
+ * What is missing or too old for a from-source build, each with the line that fixes it. Empty when
76
+ * the build can start.
77
+ *
78
+ * @param {ToolRunner} sys
79
+ * @returns {string[]}
80
+ */
81
+ export function toolchainProblems(sys) {
82
+ const developer = developerToolsProblem(sys);
83
+ return [
84
+ ...(developer === null ? [] : [developer]),
85
+ .../** @type {const} */ ([
86
+ ['cmake', 'CMake'],
87
+ ['ninja', 'Ninja'],
88
+ ]).flatMap(([tool, name]) => {
89
+ const problem = buildToolProblem(sys, tool, name);
90
+ return problem === null ? [] : [problem];
91
+ }),
92
+ ];
93
+ }
94
+
95
+ /**
96
+ * What is wrong with Xcode or its Command Line Tools and their swiftc, or null.
97
+ *
98
+ * @param {ToolRunner} sys
99
+ */
100
+ function developerToolsProblem(sys) {
101
+ const developer = probe(sys, 'xcode-select', ['--print-path']);
102
+ if ('failed' in developer && !developer.exited) {
103
+ return `${developer.failed}. Check its permissions, or reinstall: xcode-select --install`;
104
+ }
105
+ // No developer folder selected: xcode-select exits 2. Any other status is a failure to run.
106
+ if ('failed' in developer && developer.status !== 2) {
107
+ return `${developer.failed}. Reinstall the Command Line Tools: xcode-select --install`;
108
+ }
109
+ if (!('stdout' in developer) || developer.stdout.trim() === '') {
110
+ return (
111
+ 'Xcode or its Command Line Tools are not installed. Install the Command Line Tools: ' +
112
+ 'xcode-select --install'
113
+ );
114
+ }
115
+ return swiftProblem(sys);
116
+ }
117
+
118
+ /**
119
+ * What is wrong with the selected developer tools' swiftc, or null.
120
+ *
121
+ * @param {ToolRunner} sys
122
+ */
123
+ function swiftProblem(sys) {
124
+ const swift = probe(sys, 'xcrun', ['swiftc', '--version']);
125
+ if ('failed' in swift && !swift.exited) {
126
+ return `${swift.failed}. Check its permissions, or reinstall: xcode-select --install`;
127
+ }
128
+ // xcrun exits 72 when the selected tools have no swiftc; any other status (69 while Xcode's
129
+ // licence is not accepted) is a failure to run it.
130
+ if ('failed' in swift && swift.status !== 72) {
131
+ return (
132
+ `${swift.failed}. If Xcode's licence is not yet accepted: sudo xcodebuild -license accept; ` +
133
+ 'otherwise reinstall the Command Line Tools: xcode-select --install'
134
+ );
135
+ }
136
+ const version =
137
+ 'stdout' in swift ? swift.stdout.match(/Swift version (\d+(?:\.\d+)*)/)?.[1] : undefined;
138
+ if (!version) {
139
+ return (
140
+ 'swiftc is missing from the selected developer tools. Reinstall the Command Line Tools ' +
141
+ '(xcode-select --install), or select Xcode: sudo xcode-select -s /Applications/Xcode.app'
142
+ );
143
+ }
144
+ if (!atLeast(version, TOOLCHAIN_MINIMUMS.swift)) {
145
+ return (
146
+ `Swift ${version} is older than ${TOOLCHAIN_MINIMUMS.swift} (Xcode 16). Update Xcode or ` +
147
+ 'the Command Line Tools from Software Update, or install them again: xcode-select --install'
148
+ );
149
+ }
150
+ return null;
151
+ }
152
+
153
+ /**
154
+ * What is wrong with CMake or Ninja, or null: "not installed" only when it is not on the PATH.
155
+ *
156
+ * @param {ToolRunner} sys
157
+ * @param {'cmake' | 'ninja'} tool
158
+ * @param {string} name
159
+ */
160
+ function buildToolProblem(sys, tool, name) {
161
+ const text = probe(sys, tool, ['--version']);
162
+ if ('missing' in text) return `${name} is not installed. Install it: brew install ${tool}`;
163
+ if ('failed' in text) {
164
+ return `${name} is installed but ${text.failed}. Check it runs, or reinstall it: brew reinstall ${tool}`;
165
+ }
166
+ const version = text.stdout.match(/(\d+\.\d+(?:\.\d+)?)/)?.[1];
167
+ const minimum = TOOLCHAIN_MINIMUMS[tool];
168
+ if (!version) {
169
+ return `${name} printed no version for ${tool} --version. Reinstall it: brew reinstall ${tool}`;
170
+ }
171
+ if (!atLeast(version, minimum)) {
172
+ return `${name} ${version} is older than ${minimum}. Update it: brew upgrade ${tool}`;
173
+ }
174
+ return null;
175
+ }
176
+
177
+ /**
178
+ * Stops with every problem `toolchainProblems` finds, before anything builds.
179
+ *
180
+ * @param {ToolRunner} sys
181
+ */
182
+ export function checkToolchain(sys) {
183
+ const problems = toolchainProblems(sys);
184
+ if (problems.length > 0) {
185
+ throw new UsageError(
186
+ [
187
+ 'The desktop host cannot be built from source on this Mac:',
188
+ ...problems.map((p) => `- ${p}`),
189
+ ].join('\n'),
190
+ );
191
+ }
192
+ }