@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
@@ -0,0 +1,193 @@
1
+ // The desktop host's Expo modules (@ng-native/expo's DESKTOP_MODULES): each is `NgNative` and the
2
+ // package's name after `expo-`, answering the methods @ng-native/expo calls on the Expo package,
3
+ // so a service works unchanged. The OS is reached through narrow interfaces, which the AppKit
4
+ // backend implements (the Keychain, the pasteboard, IOKit's power assertions, the trackpad).
5
+ //
6
+ // - NgNativeSecureStore: getItemAsync, setItemAsync, deleteItemAsync, getItem, setItem and
7
+ // canUseBiometricAuthentication, over a SecretStore. Keys follow expo-secure-store's rule
8
+ // (letters, digits, `.`, `-` and `_`), and the `keychainService` option picks the service.
9
+ // - NgNativeClipboard: getStringAsync, setStringAsync and hasStringAsync, over System's pasteboard,
10
+ // and `ngNativeClipboard` on DeviceEventEmitter each time HostState's clipboard change count moves.
11
+ // - NgNativeKeepAwake: activateKeepAwakeAsync and deactivateKeepAwake by tag; the display stays
12
+ // awake while any tag holds it.
13
+ // - NgNativeHaptics: impactAsync, notificationAsync and selectionAsync, as the trackpad's feedback.
14
+ // - NgNativeDocumentPicker: getDocumentAsync in expo-document-picker's shape (copied into the
15
+ // cache unless copyToCacheDirectory is false), saveDocumentAsync (text, or bytes as {base64},
16
+ // written where the save panel says; null when dismissed) and pickDirectoryAsync ({uri} or null),
17
+ // over FileDialogs, with uris percent-encoded.
18
+ // - NgNativeLocalization: getLocales and getCalendars, in expo-localization's shapes, over a
19
+ // LocaleSource (the user's preferred languages and the region's formats).
20
+ #pragma once
21
+
22
+ #include "ngn/file-system.h"
23
+ #include "ngn/host-state.h"
24
+ #include "ngn/native-module.h"
25
+ #include "ngn/system.h"
26
+
27
+ #include <functional>
28
+ #include <memory>
29
+ #include <mutex>
30
+ #include <optional>
31
+ #include <set>
32
+ #include <string>
33
+ #include <vector>
34
+
35
+ namespace ngn {
36
+
37
+ class SecretStore {
38
+ public:
39
+ virtual ~SecretStore() = default;
40
+ // Nothing when there is no such item. Throws std::runtime_error when the store fails.
41
+ virtual std::optional<std::string> get(const std::string &service, const std::string &key) = 0;
42
+ virtual void set(const std::string &service, const std::string &key, const std::string &value) = 0;
43
+ virtual void remove(const std::string &service, const std::string &key) = 0;
44
+ };
45
+
46
+ // Items in `now`, with what `old` still has moved over as it is read: the Data Protection keychain
47
+ // over the file keychain an app used before it was signed with a Team ID. A write or a removal
48
+ // takes the old copy away too, so it never comes back; a removal that cannot tell the old store
49
+ // has none fails.
50
+ class MovingSecretStore final : public SecretStore {
51
+ public:
52
+ MovingSecretStore(std::shared_ptr<SecretStore> now, std::shared_ptr<SecretStore> old)
53
+ : now_(std::move(now)), old_(std::move(old)) {}
54
+ std::optional<std::string> get(const std::string &service, const std::string &key) override;
55
+ void set(const std::string &service, const std::string &key, const std::string &value) override;
56
+ void remove(const std::string &service, const std::string &key) override;
57
+
58
+ private:
59
+ void removeOld(const std::string &service, const std::string &key);
60
+ std::shared_ptr<SecretStore> now_;
61
+ std::shared_ptr<SecretStore> old_;
62
+ };
63
+
64
+ // A test launch's store: each service is `prefix` and the service asked for, so a run's items
65
+ // never meet the app's own or another run's. `clear()` removes every item this store wrote.
66
+ class PrefixedSecretStore final : public SecretStore {
67
+ public:
68
+ PrefixedSecretStore(std::shared_ptr<SecretStore> inner, std::string prefix) : inner_(std::move(inner)), prefix_(std::move(prefix)) {}
69
+ std::optional<std::string> get(const std::string &service, const std::string &key) override;
70
+ void set(const std::string &service, const std::string &key, const std::string &value) override;
71
+ void remove(const std::string &service, const std::string &key) override;
72
+ void clear();
73
+
74
+ private:
75
+ std::shared_ptr<SecretStore> inner_;
76
+ std::string prefix_;
77
+ std::mutex mutex_;
78
+ std::set<std::pair<std::string, std::string>> written_;
79
+ };
80
+
81
+ // Whether the app can use the Data Protection keychain: its signature has a Team ID, and an
82
+ // entitlement that gives it a keychain access group (an application identifier, as a Mac App Store
83
+ // build has, or keychain-access-groups). Without one the keychain refuses it (errSecMissingEntitlement).
84
+ bool usesDataProtectionKeychain(const std::string &teamId, const std::set<std::string> &entitlements);
85
+
86
+ // The service items go under when the call names none: the app's own.
87
+ std::shared_ptr<NativeModule> makeSecureStoreModule(std::shared_ptr<SecretStore> store, std::string defaultService);
88
+ bool secureStoreKeyValid(const std::string &key);
89
+
90
+ std::shared_ptr<NativeModule> makeDesktopClipboardModule(std::shared_ptr<System> system, std::shared_ptr<HostState> state);
91
+
92
+ class SleepPreventer {
93
+ public:
94
+ virtual ~SleepPreventer() = default;
95
+ // Keep the display awake, or let it sleep again.
96
+ virtual void hold(bool awake) = 0;
97
+ };
98
+
99
+ // The tags holding the display awake: it is held while there is any.
100
+ class KeepAwakeTags {
101
+ public:
102
+ explicit KeepAwakeTags(std::shared_ptr<SleepPreventer> preventer) : preventer_(std::move(preventer)) {}
103
+ void activate(const std::string &tag);
104
+ void deactivate(const std::string &tag);
105
+
106
+ private:
107
+ std::shared_ptr<SleepPreventer> preventer_;
108
+ std::set<std::string> tags_;
109
+ };
110
+
111
+ std::shared_ptr<NativeModule> makeKeepAwakeModule(std::shared_ptr<KeepAwakeTags> tags);
112
+
113
+ class HapticPlayer {
114
+ public:
115
+ enum class Pattern { Generic, Alignment, LevelChange };
116
+ virtual ~HapticPlayer() = default;
117
+ virtual void play(Pattern pattern) = 0;
118
+ };
119
+
120
+ // The pattern each of expo-haptics' calls plays: an impact is generic, a selection an alignment,
121
+ // a notification a level change.
122
+ std::optional<HapticPlayer::Pattern> hapticPattern(const std::string &method);
123
+
124
+ std::shared_ptr<NativeModule> makeHapticsModule(std::shared_ptr<HapticPlayer> player);
125
+
126
+ // The OS's open and save panels. Each answers on any thread, with nothing when dismissed.
127
+ class FileDialogs {
128
+ public:
129
+ struct OpenRequest {
130
+ // MIME types ("text/plain", "image/*"); empty for any file.
131
+ std::vector<std::string> types;
132
+ bool multiple{false};
133
+ };
134
+ struct SaveRequest {
135
+ std::string suggestedName;
136
+ // MIME types the file may be saved as, the first the default.
137
+ std::vector<std::string> types;
138
+ };
139
+ virtual ~FileDialogs() = default;
140
+ virtual void openFiles(const OpenRequest &request, std::function<void(std::optional<std::vector<std::string>>)> done) = 0;
141
+ virtual void saveFile(const SaveRequest &request, std::function<void(std::optional<std::string>)> done) = 0;
142
+ virtual void chooseFolder(std::function<void(std::optional<std::string>)> done) = 0;
143
+ };
144
+
145
+ // Panels that answer as dismissed at once, never shown: a test launch's fake system UI.
146
+ std::shared_ptr<FileDialogs> makeDismissedFileDialogs();
147
+
148
+ // The MIME type of a file name's extension, or application/octet-stream.
149
+ std::string mimeTypeOf(const std::string &name);
150
+
151
+ // `cacheDirectory` is where picked files are copied. What the user picks or saves becomes
152
+ // reachable through `access`, NgNativeFileSystem's, when there is one.
153
+ std::shared_ptr<NativeModule> makeDocumentPickerModule(
154
+ std::shared_ptr<FileDialogs> dialogs,
155
+ std::string cacheDirectory,
156
+ std::shared_ptr<FileAccess> access = nullptr);
157
+
158
+ // One of the user's preferred languages, with the formats of the region the system is set to.
159
+ struct LocaleFacts {
160
+ // BCP 47: "en-GB", "zh-Hant-TW", "ar".
161
+ std::string languageTag;
162
+ bool rightToLeft{false};
163
+ std::string decimalSeparator;
164
+ std::string groupingSeparator;
165
+ // As NSLocale says it: "Metric", "U.S." or "U.K.".
166
+ std::string measurementSystem;
167
+ std::string currencyCode;
168
+ std::string currencySymbol;
169
+ // "celsius" or "fahrenheit".
170
+ std::string temperatureUnit;
171
+ };
172
+
173
+ struct CalendarFacts {
174
+ // expo-localization's names: "gregorian", "buddhist", "japanese" and the rest.
175
+ std::string calendar;
176
+ std::string timeZone;
177
+ bool uses24hourClock{false};
178
+ // 1 is Sunday.
179
+ int firstWeekday{1};
180
+ };
181
+
182
+ class LocaleSource {
183
+ public:
184
+ virtual ~LocaleSource() = default;
185
+ // Most preferred first.
186
+ virtual std::vector<LocaleFacts> locales() = 0;
187
+ virtual CalendarFacts calendars() = 0;
188
+ };
189
+
190
+ // `regionCode` is the system's region ("GB"), which a language tag with no region of its own takes.
191
+ std::shared_ptr<NativeModule> makeLocalizationModule(std::shared_ptr<LocaleSource> source, std::string regionCode);
192
+
193
+ } // namespace ngn
@@ -0,0 +1,109 @@
1
+ // ModalHostView with the props the desktop reads: `presentationStyle` and `transparent`, which
2
+ // choose a sheet or an in-window cover, and the one prop the desktop adds, `anchor`, the tag of the
3
+ // view a modal is anchored to, which presents it as a popover at that view (an NSPopover on macOS).
4
+ // React Native's own ModalHostViewProps are final and drop any key they do not declare, so the core
5
+ // registers ModalHostView with props of its own; the shadow node, its state (the size the host
6
+ // sets) and its event emitter are React Native's.
7
+ //
8
+ // `pageSheet`, `formSheet` or no style is a sheet on the window; `fullScreen`, `overFullScreen` or
9
+ // `transparent` is a cover in the window, below its title bar. The presentation and the anchor
10
+ // reach the backend through DesktopPropsSink, with focusable and tabIndex.
11
+ //
12
+ // A sheet takes the size of its content's root: the root's definite CSS width and height where it
13
+ // has them, and otherwise a default width and the height its content lays out to, which takes a
14
+ // second commit. Either way it stays between 320x200 and the window.
15
+ #pragma once
16
+
17
+ #include "ngn/desktop-view-props.h"
18
+
19
+ #include <react/renderer/components/FBReactNativeSpec/EventEmitters.h>
20
+ #include <react/renderer/components/modal/ModalHostViewState.h>
21
+ #include <react/renderer/components/view/ConcreteViewShadowNode.h>
22
+
23
+ #include <string>
24
+ #include <string_view>
25
+
26
+ namespace facebook::react {
27
+ extern const char ModalHostViewComponentName[];
28
+ } // namespace facebook::react
29
+
30
+ namespace ngn {
31
+
32
+ class DesktopModalProps final : public facebook::react::ViewProps {
33
+ public:
34
+ DesktopModalProps() = default;
35
+ DesktopModalProps(
36
+ const facebook::react::PropsParserContext &context,
37
+ const DesktopModalProps &sourceProps,
38
+ const facebook::react::RawProps &rawProps);
39
+
40
+ // 0 for none.
41
+ int anchor{0};
42
+ std::string presentationStyle;
43
+ bool transparent{false};
44
+ };
45
+
46
+ ModalPresentation modalPresentation(const DesktopModalProps &props);
47
+
48
+ // The name a sheet, cover or popover is announced by: the presented view's own accessibility
49
+ // label, or without one its title (a presented screen's header title; a <modal> has none). Empty
50
+ // for no name. The host names the presentation's container with it, and again whenever either
51
+ // changes.
52
+ std::string presentationLabel(std::string_view label, std::string_view title);
53
+
54
+ constexpr facebook::react::Size kMinimumSheetSize{320, 200};
55
+ // A sheet's width when its root has no definite one.
56
+ constexpr facebook::react::Float kDefaultSheetWidth = 480;
57
+
58
+ // A view of a sheet's content as Yoga laid it out, read from the shadow tree rather than the
59
+ // mounted views, which Fabric flattens: a layout-only root with a CSS size is not mounted at all.
60
+ struct SheetNode {
61
+ facebook::react::Rect frame;
62
+ // The definite CSS width and height, in points, where the view has them.
63
+ std::optional<facebook::react::Float> width;
64
+ std::optional<facebook::react::Float> height;
65
+ // Its padding and border, which its content's extent leaves out.
66
+ facebook::react::EdgeInsets insets;
67
+ std::vector<SheetNode> children;
68
+ };
69
+
70
+ // Whether a child takes room in its sheet's content: not a modal inside, presented on its own, nor
71
+ // a presented screen's header config, which the sheet draws around its content.
72
+ bool takesRoomInSheet(std::string_view componentName);
73
+
74
+ // A laid out shadow node and those under it, leaving out what takes no room in it.
75
+ SheetNode sheetNode(const facebook::react::ShadowNode &node);
76
+
77
+ // The size a sheet takes for `modal`, laid out at the size it has now, on a window whose content
78
+ // is `window`.
79
+ facebook::react::Size sheetSize(const SheetNode &modal, facebook::react::Size window);
80
+
81
+ // The most a popover measures its content against, before it fits.
82
+ constexpr facebook::react::Float kPopoverMax = 640;
83
+
84
+ // The size a popover takes for `presented` (a <modal> or a presented screen), laid out at the size
85
+ // it has now: its root's definite CSS size where it has one, or what its content laid out to, no
86
+ // larger than the window or kPopoverMax. Zero before the content lays out.
87
+ facebook::react::Size popoverSize(const SheetNode &presented, facebook::react::Size window);
88
+
89
+ class DesktopModalShadowNode final : public facebook::react::ConcreteViewShadowNode<
90
+ facebook::react::ModalHostViewComponentName,
91
+ DesktopModalProps,
92
+ facebook::react::ModalHostViewEventEmitter,
93
+ facebook::react::ModalHostViewState> {
94
+ public:
95
+ using ConcreteViewShadowNode::ConcreteViewShadowNode;
96
+ // React Native's ModalHostViewShadowNode's: a root of its own, and never culled.
97
+ static facebook::react::ShadowNodeTraits BaseTraits();
98
+ };
99
+
100
+ // React Native's ModalHostViewComponentDescriptor's adoption: the modal takes the size its state
101
+ // says, positioned absolutely.
102
+ class DesktopModalComponentDescriptor final
103
+ : public facebook::react::ConcreteComponentDescriptor<DesktopModalShadowNode> {
104
+ public:
105
+ using ConcreteComponentDescriptor::ConcreteComponentDescriptor;
106
+ void adopt(facebook::react::ShadowNode &shadowNode) const override;
107
+ };
108
+
109
+ } // namespace ngn
@@ -0,0 +1,75 @@
1
+ // The desktop props as plain values (desktop-view-props.h parses them), in a header of their own
2
+ // because React Native's view traits read them too: the shim's HostPlatformViewTraitsInitializer.h
3
+ // keeps a view that has any of them from being flattened away, as React Native does for a view
4
+ // with an event listener or a cursor.
5
+ #pragma once
6
+
7
+ #include <folly/dynamic.h>
8
+ #include <react/renderer/components/view/primitives.h>
9
+ #include <react/renderer/core/ReactPrimitives.h>
10
+
11
+ #include <optional>
12
+ #include <string>
13
+
14
+ namespace ngn {
15
+
16
+ using facebook::react::SurfaceId;
17
+ using facebook::react::Tag;
18
+
19
+ // CSS's `scrollbar-width` and `scrollbar-gutter`.
20
+ enum class ScrollbarWidth { Auto, Thin, None };
21
+ enum class ScrollbarGutter { Auto, Stable };
22
+
23
+ // How a ModalHostView shows (desktop-modal.h): a sheet on its window, a cover in the window, or a
24
+ // popover at its anchor.
25
+ enum class ModalPresentation { Sheet, Cover, Popover };
26
+
27
+ struct DesktopProps {
28
+ // Unset means the toolkit's default for the component.
29
+ std::optional<bool> focusable;
30
+ // Unset means no explicit place in Tab order. Negative leaves the view out of it.
31
+ std::optional<int> tabIndex;
32
+ // ModalHostView only: the view it is anchored to, as a popover (desktop-modal.h).
33
+ std::optional<Tag> anchor;
34
+ // The CSS cursor as written, when React Native's `cursor` cannot say it. Unset defers to
35
+ // `cursor`, then to the nearest ancestor's (input-dispatcher.h).
36
+ std::optional<facebook::react::Cursor> cursor;
37
+ // ScrollView only.
38
+ ScrollbarWidth scrollbarWidth{ScrollbarWidth::Auto};
39
+ ScrollbarGutter scrollbarGutter{ScrollbarGutter::Auto};
40
+ // Whether a binding listens for the element event, which is then sent to the view.
41
+ bool onDoubleClick{false};
42
+ bool onContextMenu{false};
43
+ bool onWheel{false};
44
+ // Whether the view takes files, text and urls dragged onto it (input-dispatcher.h).
45
+ bool fileDrop{false};
46
+ // The `dragItem` prop: `{ files, text, url }` the view offers when dragged out, or null for none.
47
+ folly::dynamic dragItem{nullptr};
48
+ // The `contextMenu` prop: the entries of the menu a secondary click shows, as the app sends them
49
+ // (app-menus.h), or null for none.
50
+ folly::dynamic contextMenu{nullptr};
51
+ // `role` as written. React Native's Role has no `listbox`, `gridcell`, `menuitemcheckbox` or
52
+ // `menuitemradio` and drops them; the core reads them from here (accessibility.h roleName).
53
+ std::string role;
54
+ // `accessibilityLevel` (`aria-level`): a heading's level, from 1.
55
+ std::optional<int> accessibilityLevel;
56
+ // ModalHostView only.
57
+ ModalPresentation presentation{ModalPresentation::Sheet};
58
+
59
+ bool operator==(const DesktopProps &other) const = default;
60
+ };
61
+
62
+ // What a props class with desktop props carries beside its React Native base.
63
+ struct HasDesktopProps {
64
+ DesktopProps desktop;
65
+ };
66
+
67
+ // Whether a view with these props must be a view of its own, with its children under it: the
68
+ // hit test, the cursor and Tab order all read it, and a flattened view is not mounted.
69
+ inline bool formsStackingContext(const DesktopProps &props) {
70
+ return props.focusable.value_or(false) || props.tabIndex.has_value() || props.cursor.has_value() ||
71
+ !props.role.empty() || props.onDoubleClick || props.onContextMenu || props.onWheel || props.fileDrop || !props.dragItem.isNull() ||
72
+ !props.contextMenu.isNull();
73
+ }
74
+
75
+ } // namespace ngn
@@ -0,0 +1,110 @@
1
+ // The desktop view props interface: the View props React Native's cross-platform ViewProps drop
2
+ // and the desktop needs. `focusable` and `tabIndex`, which Tab order reads; `desktopCursor`, the
3
+ // CSS cursors React Native's `cursor` (auto and pointer) lacks; `scrollbarWidth` and
4
+ // `scrollbarGutter` on a scroll view; and the opt-ins for the desktop's element events,
5
+ // `onDoubleClick`, `onContextMenu` and `onWheel` (input-dispatcher.h).
6
+ //
7
+ // The core registers View and ScrollView with descriptors whose props carry them, and reports them
8
+ // to the backend as plain values through DesktopPropsSink when a view is created and whenever they
9
+ // change.
10
+ #pragma once
11
+
12
+ #include "ngn/desktop-props.h"
13
+ #include "ngn/scrollers.h"
14
+
15
+ #include <react/renderer/components/scrollview/ScrollViewProps.h>
16
+ #include <react/renderer/components/scrollview/ScrollViewShadowNode.h>
17
+ #include <react/renderer/components/view/ViewProps.h>
18
+ #include <react/renderer/components/view/ViewShadowNode.h>
19
+ #include <react/renderer/core/ConcreteComponentDescriptor.h>
20
+
21
+ #include <optional>
22
+
23
+ namespace ngn {
24
+
25
+ // The desktop props an update sets, on top of `source`'s.
26
+ DesktopProps parseDesktopProps(
27
+ const facebook::react::PropsParserContext &context,
28
+ const DesktopProps &source,
29
+ const facebook::react::RawProps &rawProps);
30
+
31
+ class DesktopViewProps final : public facebook::react::ViewProps, public HasDesktopProps {
32
+ public:
33
+ DesktopViewProps() = default;
34
+ DesktopViewProps(
35
+ const facebook::react::PropsParserContext &context,
36
+ const DesktopViewProps &sourceProps,
37
+ const facebook::react::RawProps &rawProps);
38
+ // A View's props with the desktop props unset.
39
+ explicit DesktopViewProps(const facebook::react::ViewProps &viewProps) : facebook::react::ViewProps(viewProps) {}
40
+ };
41
+
42
+ class DesktopScrollViewProps final : public facebook::react::ScrollViewProps, public HasDesktopProps {
43
+ public:
44
+ DesktopScrollViewProps() = default;
45
+ DesktopScrollViewProps(
46
+ const facebook::react::PropsParserContext &context,
47
+ const DesktopScrollViewProps &sourceProps,
48
+ const facebook::react::RawProps &rawProps);
49
+ explicit DesktopScrollViewProps(const facebook::react::ScrollViewProps &props)
50
+ : facebook::react::ScrollViewProps(props) {}
51
+ };
52
+
53
+ // The desktop props of any props object: a View's own, or the defaults for anything else.
54
+ DesktopProps desktopProps(const facebook::react::Props &props);
55
+
56
+ // React Native's component with `DesktopPropsT`, which derives from the props its shadow node
57
+ // reads. Everything else (traits, flattening, state, measuring) is the shadow node's own.
58
+ template <class ShadowNodeT, class DesktopPropsT>
59
+ class DesktopPropsComponentDescriptor final : public facebook::react::ConcreteComponentDescriptor<ShadowNodeT> {
60
+ using Base = facebook::react::ConcreteComponentDescriptor<ShadowNodeT>;
61
+ using BaseProps = typename ShadowNodeT::ConcreteProps;
62
+
63
+ public:
64
+ explicit DesktopPropsComponentDescriptor(const facebook::react::ComponentDescriptorParameters &parameters)
65
+ : Base(parameters, preparedParser()) {}
66
+
67
+ // ConcreteComponentDescriptor::cloneProps's classic path, constructing DesktopPropsT.
68
+ facebook::react::Props::Shared cloneProps(
69
+ const facebook::react::PropsParserContext &context,
70
+ const facebook::react::Props::Shared &props,
71
+ facebook::react::RawProps rawProps) const override {
72
+ if (!props && rawProps.isEmpty()) {
73
+ return ShadowNodeT::defaultSharedProps();
74
+ }
75
+ rawProps.parse(this->rawPropsParser_);
76
+ static const DesktopPropsT defaults;
77
+ const auto *source = props ? dynamic_cast<const DesktopPropsT *>(props.get()) : &defaults;
78
+ if (source == nullptr) {
79
+ // Props made before this descriptor (Fabric's shared defaults): start from them.
80
+ DesktopPropsT upgraded{static_cast<const BaseProps &>(*props)};
81
+ return std::make_shared<const DesktopPropsT>(context, upgraded, rawProps);
82
+ }
83
+ return std::make_shared<const DesktopPropsT>(context, *source, rawProps);
84
+ }
85
+
86
+ private:
87
+ // The parser records the keys a props class reads the first time it is prepared, so it has to
88
+ // be prepared for DesktopPropsT before ConcreteComponentDescriptor prepares it for the base
89
+ // props, whose keys are a subset and add nothing once the parser is ready.
90
+ static facebook::react::RawPropsParser preparedParser() {
91
+ facebook::react::RawPropsParser parser;
92
+ parser.template prepare<DesktopPropsT>();
93
+ return parser;
94
+ }
95
+ };
96
+
97
+ using DesktopViewComponentDescriptor =
98
+ DesktopPropsComponentDescriptor<facebook::react::ViewShadowNode, DesktopViewProps>;
99
+ // The scroll view pads its content by its scrollers' gutter (scrollers.h).
100
+ using DesktopScrollViewComponentDescriptor =
101
+ DesktopPropsComponentDescriptor<DesktopScrollViewShadowNode, DesktopScrollViewProps>;
102
+
103
+ // Implemented by a backend that maps desktop props onto its toolkit (key-view loop, Tab order).
104
+ class DesktopPropsSink {
105
+ public:
106
+ virtual ~DesktopPropsSink() = default;
107
+ virtual void updateDesktopProps(SurfaceId surfaceId, Tag tag, const DesktopProps &props) = 0;
108
+ };
109
+
110
+ } // namespace ngn
@@ -0,0 +1,33 @@
1
+ // The Metro dev server a bundle URL points at. The desktop host loads the bundle URL directly
2
+ // (never the Expo manifest, which the Expo dev server refuses for macos), then keeps a connection
3
+ // to the same server for reload (/message) and Fast Refresh (the HMR client, over /hot).
4
+ #pragma once
5
+
6
+ #include <folly/dynamic.h>
7
+
8
+ #include <cstdint>
9
+ #include <optional>
10
+ #include <string>
11
+
12
+ namespace ngn {
13
+
14
+ struct DevServer {
15
+ // `url` when it is an http or https URL with a host, otherwise nothing (a bundle on disk).
16
+ static std::optional<DevServer> fromBundleUrl(const std::string &url);
17
+
18
+ std::string bundleUrl;
19
+ std::string scheme;
20
+ std::string host;
21
+ uint32_t port{0};
22
+ // The bundle's path without its leading slash and `.bundle`, as HMRClient.setup takes it.
23
+ std::string entry;
24
+ // The `platform` query parameter; `macos` when the URL has none.
25
+ std::string platform;
26
+
27
+ // Where Metro sends reload and dev menu messages.
28
+ std::string packagerConnectionUrl() const;
29
+ // HMRClient.setup(platform, bundleEntry, host, port, isEnabled, scheme).
30
+ folly::dynamic hmrSetupArgs() const;
31
+ };
32
+
33
+ } // namespace ngn
@@ -0,0 +1,53 @@
1
+ // `<dom-component>` on a desktop host: @expo/dom-webview's view (ViewManagerAdapter_ExpoDomWebViewModule,
2
+ // the component @ng-native/expo's `<dom-component>` commits) as a Fabric component of the desktop's
3
+ // own, drawn by the same web view as react-native-webview's RNCWebView (web-view.h).
4
+ //
5
+ // The core reads Expo's props into a WebViewConfig (domWebViewConfig): `source` ({uri}),
6
+ // `injectedJavaScript`, `injectedJavaScriptBeforeContentLoaded`, `injectedJavaScriptObject` and
7
+ // `webviewDebuggingEnabled`. As in Expo's iOS view, the page always has
8
+ // window.ReactNativeWebView.postMessage, each message is the `message` event ({url, title, data}),
9
+ // the injected scripts run in every frame, and a navigation goes ahead without asking the app.
10
+ // `injectJavaScript` is the view's command, where Expo's is a function on its view.
11
+ #pragma once
12
+
13
+ #include "ngn/desktop-props.h"
14
+ #include "ngn/web-view.h"
15
+
16
+ #include <react/renderer/components/view/ConcreteViewShadowNode.h>
17
+ #include <react/renderer/components/view/ViewEventEmitter.h>
18
+ #include <react/renderer/components/view/ViewProps.h>
19
+ #include <react/renderer/core/ConcreteComponentDescriptor.h>
20
+
21
+ #include <folly/dynamic.h>
22
+
23
+ #include <optional>
24
+ #include <string>
25
+
26
+ namespace ngn {
27
+
28
+ extern const char DomWebViewComponentName[];
29
+
30
+ class DomWebViewProps final : public facebook::react::ViewProps, public HasDesktopProps {
31
+ public:
32
+ DomWebViewProps() = default;
33
+ DomWebViewProps(
34
+ const facebook::react::PropsParserContext &context,
35
+ const DomWebViewProps &sourceProps,
36
+ const facebook::react::RawProps &rawProps);
37
+
38
+ // {uri}, as Expo's DomWebViewSource.
39
+ folly::dynamic source;
40
+ std::string injectedJavaScript;
41
+ std::string injectedJavaScriptBeforeContentLoaded;
42
+ std::string injectedJavaScriptObject;
43
+ bool webviewDebuggingEnabled{false};
44
+ };
45
+
46
+ // The web view's config for Expo's DOM web view's props; nothing for another component's.
47
+ std::optional<WebViewConfig> domWebViewConfig(const facebook::react::Props &props);
48
+
49
+ using DomWebViewShadowNode =
50
+ facebook::react::ConcreteViewShadowNode<DomWebViewComponentName, DomWebViewProps, facebook::react::ViewEventEmitter>;
51
+ using DomWebViewComponentDescriptor = facebook::react::ConcreteComponentDescriptor<DomWebViewShadowNode>;
52
+
53
+ } // namespace ngn
@@ -0,0 +1,24 @@
1
+ // A file fetched over the backend's HTTP client: an asset or a font the dev server serves, saved
2
+ // before the OS opens it.
3
+ #pragma once
4
+
5
+ #include "ngn/network.h"
6
+
7
+ #include <functional>
8
+ #include <memory>
9
+ #include <string>
10
+
11
+ namespace ngn {
12
+
13
+ // Reads the whole body of `url` (a `file:`, `data:` or `http(s):` url). Answers once, on any thread:
14
+ // the body and an empty error, or no body and why: "HTTP <status>" or the client's error.
15
+ void fetchBytes(const std::shared_ptr<Http> &http, const std::string &url, std::function<void(std::string body, const std::string &error)> done);
16
+ // The same for a request of its own, with its method and headers.
17
+ void fetchBytes(const std::shared_ptr<Http> &http, HttpRequest request, std::function<void(std::string body, const std::string &error)> done);
18
+
19
+ // Downloads `url` into the file `target`, making its folder first. Answers once, on any thread:
20
+ // an empty error once the file is written, else why not: "HTTP <status>", the client's error, or
21
+ // "could not be saved to <target>".
22
+ void downloadFile(const std::shared_ptr<Http> &http, const std::string &url, const std::string &target, std::function<void(const std::string &error)> done);
23
+
24
+ } // namespace ngn