@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,81 @@
1
+ // The app's windows as NSWindows, one surface each (the core's WindowBackend), and the app
2
+ // delegate's part in closing and quitting, which the core decides (app-windows.h).
3
+ #pragma once
4
+
5
+ #include <set>
6
+
7
+ #import <AppKit/AppKit.h>
8
+
9
+ #include "ngn/app-windows.h"
10
+
11
+ #include <functional>
12
+ #include <memory>
13
+
14
+ @class NGNSurfaceView;
15
+
16
+ namespace ngn::appkit {
17
+
18
+ class AppKitWindows final : public WindowBackend {
19
+ public:
20
+ // What a window needs from the rest of the host. Main thread.
21
+ struct Hooks {
22
+ // A surface view for the window's content, registered with the mounting backend.
23
+ std::function<NGNSurfaceView *(SurfaceId, NSRect)> makeSurface;
24
+ // Start, size and stop the surface on the runtime, at the window's size.
25
+ std::function<void(SurfaceId, NSWindow *)> startSurface;
26
+ std::function<void(SurfaceId, NSWindow *)> resizeSurface;
27
+ std::function<void(SurfaceId)> stopSurface;
28
+ // The key window changed, or its size did.
29
+ std::function<void(NSWindow *)> keyWindowChanged;
30
+ // Runs a first show now, or once the splash screen lets the windows go, on the main thread.
31
+ std::function<void(std::function<void()>)> whenShown;
32
+ // A window is on screen for the first time.
33
+ std::function<void(NSWindow *)> shown;
34
+ };
35
+
36
+ explicit AppKitWindows(Hooks hooks);
37
+
38
+ // Set once, before the app runs.
39
+ void setHost(std::shared_ptr<WindowHost> host);
40
+ WindowHost *host() const {
41
+ return host_.get();
42
+ }
43
+
44
+ // A surface mounted: its window shows on the first. Main thread.
45
+ void didMount(SurfaceId surface);
46
+ NSWindow *window(SurfaceId surface) const;
47
+ // The surface whose window this is, or 0.
48
+ SurfaceId surfaceOf(NSWindow *window) const;
49
+
50
+ void openWindow(
51
+ SurfaceId surface,
52
+ const WindowRequest &request,
53
+ const WindowPlacement &placement,
54
+ std::function<void()> opened) override;
55
+ void closeWindow(SurfaceId surface) override;
56
+ void focusWindow(SurfaceId surface) override;
57
+ void setWindowTitle(SurfaceId surface, const std::string &title) override;
58
+ void beginQuit() override;
59
+ void replyToQuit(bool proceed) override;
60
+ void after(double seconds, std::function<void()> task) override;
61
+
62
+ // The window delegate's calls. Main thread.
63
+ bool shouldClose(SurfaceId surface);
64
+ void willClose(SurfaceId surface);
65
+ void frameChanged(SurfaceId surface, bool resized);
66
+ void keyChanged(SurfaceId surface, bool key);
67
+
68
+ private:
69
+ // Shows a mounted window that has not shown yet. Main thread.
70
+ void show(SurfaceId surface);
71
+ Hooks hooks_;
72
+ // Mounted, and waiting for the splash screen to show them.
73
+ std::set<SurfaceId> held_;
74
+ std::shared_ptr<WindowHost> host_;
75
+ NSMutableDictionary<NSNumber *, NSWindow *> *windows_;
76
+ NSMutableDictionary<NSNumber *, id> *delegates_;
77
+ // Windows waiting for their first frame, and whether each opens in full screen.
78
+ NSMutableDictionary<NSNumber *, NSNumber *> *unshown_;
79
+ };
80
+
81
+ } // namespace ngn::appkit
@@ -0,0 +1,318 @@
1
+ #import "app-windows.h"
2
+ #import "test-launch.h"
3
+ #import "undo.h"
4
+ #import "screen-capture.h"
5
+
6
+ #import "surface-view.h"
7
+
8
+ using ngn::appkit::AppKitWindows;
9
+
10
+ @interface NGNWindowDelegate : NSObject <NSWindowDelegate>
11
+ - (instancetype)initWithSurface:(facebook::react::SurfaceId)surface windows:(AppKitWindows *)windows;
12
+ @end
13
+
14
+ @implementation NGNWindowDelegate {
15
+ facebook::react::SurfaceId _surface;
16
+ AppKitWindows *_windows;
17
+ }
18
+
19
+ - (NSUndoManager *)windowWillReturnUndoManager:(NSWindow *)window {
20
+ return ngn::appkit::undoManagerFor(window);
21
+ }
22
+
23
+ - (instancetype)initWithSurface:(facebook::react::SurfaceId)surface windows:(AppKitWindows *)windows {
24
+ if ((self = [super init])) {
25
+ _surface = surface;
26
+ _windows = windows;
27
+ }
28
+ return self;
29
+ }
30
+
31
+ - (BOOL)windowShouldClose:(NSWindow *)sender {
32
+ return _windows->shouldClose(_surface);
33
+ }
34
+
35
+ - (void)windowWillClose:(NSNotification *)note {
36
+ _windows->willClose(_surface);
37
+ }
38
+
39
+ - (void)windowDidResize:(NSNotification *)note {
40
+ _windows->frameChanged(_surface, true);
41
+ }
42
+
43
+ - (void)windowDidChangeBackingProperties:(NSNotification *)note {
44
+ _windows->frameChanged(_surface, true);
45
+ }
46
+
47
+ - (void)windowDidMove:(NSNotification *)note {
48
+ _windows->frameChanged(_surface, false);
49
+ }
50
+
51
+ - (void)windowDidBecomeKey:(NSNotification *)note {
52
+ _windows->keyChanged(_surface, true);
53
+ }
54
+
55
+ - (void)windowDidResignKey:(NSNotification *)note {
56
+ _windows->keyChanged(_surface, false);
57
+ }
58
+
59
+ @end
60
+
61
+ namespace ngn::appkit {
62
+
63
+ namespace {
64
+
65
+ void onMain(std::function<void()> task) {
66
+ if (NSThread.isMainThread) {
67
+ task();
68
+ return;
69
+ }
70
+ auto shared = std::make_shared<std::function<void()>>(std::move(task));
71
+ dispatch_async(dispatch_get_main_queue(), ^{
72
+ (*shared)();
73
+ });
74
+ }
75
+
76
+ NSString *string(const std::string &s) {
77
+ NSString *out = [NSString stringWithUTF8String:s.c_str()];
78
+ return out != nil ? out : @"";
79
+ }
80
+
81
+ WindowFrame frameOf(NSWindow *window) {
82
+ NSRect content = [window contentRectForFrameRect:window.frame];
83
+ return {.x = NSMinX(content), .y = NSMinY(content), .width = NSWidth(content), .height = NSHeight(content)};
84
+ }
85
+
86
+ // Whether enough of `rect` is on a screen to grab its title bar: a display that has gone away
87
+ // leaves a saved frame nowhere.
88
+ bool onScreen(NSRect rect) {
89
+ for (NSScreen *screen in NSScreen.screens) {
90
+ NSRect visible = NSIntersectionRect(screen.visibleFrame, rect);
91
+ if (NSWidth(visible) >= 40 && NSHeight(visible) >= 20) {
92
+ return true;
93
+ }
94
+ }
95
+ return false;
96
+ }
97
+
98
+ } // namespace
99
+
100
+ AppKitWindows::AppKitWindows(Hooks hooks)
101
+ : hooks_(std::move(hooks)),
102
+ windows_([NSMutableDictionary dictionary]),
103
+ delegates_([NSMutableDictionary dictionary]),
104
+ unshown_([NSMutableDictionary dictionary]) {}
105
+
106
+ void AppKitWindows::setHost(std::shared_ptr<WindowHost> host) {
107
+ host_ = std::move(host);
108
+ }
109
+
110
+ NSWindow *AppKitWindows::window(SurfaceId surface) const {
111
+ return windows_[@(surface)];
112
+ }
113
+
114
+ SurfaceId AppKitWindows::surfaceOf(NSWindow *window) const {
115
+ for (NSNumber *key in windows_) {
116
+ if (windows_[key] == window) {
117
+ return key.intValue;
118
+ }
119
+ }
120
+ return 0;
121
+ }
122
+
123
+ void AppKitWindows::openWindow(
124
+ SurfaceId surface,
125
+ const WindowRequest &request,
126
+ const WindowPlacement &placement,
127
+ std::function<void()> opened) {
128
+ onMain([this, surface, request, placement, opened] {
129
+ NSWindowStyleMask style = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable |
130
+ NSWindowStyleMaskFullSizeContentView;
131
+ if (request.resizable) {
132
+ style |= NSWindowStyleMaskResizable;
133
+ }
134
+ NSRect content = NSMakeRect(placement.frame.x, placement.frame.y, placement.frame.width, placement.frame.height);
135
+ NSWindow *window = [[NSWindow alloc] initWithContentRect:content
136
+ styleMask:style
137
+ backing:NSBackingStoreBuffered
138
+ defer:NO];
139
+ window.releasedWhenClosed = NO;
140
+ shieldNewWindow(window);
141
+ window.title = string(request.title);
142
+ window.tabbingMode = NSWindowTabbingModeDisallowed;
143
+ if (request.titleBar != TitleBar::Default) {
144
+ window.titlebarAppearsTransparent = YES;
145
+ }
146
+ if (request.titleBar == TitleBar::Hidden) {
147
+ window.titleVisibility = NSWindowTitleHidden;
148
+ }
149
+ if (request.minWidth || request.minHeight) {
150
+ window.contentMinSize = NSMakeSize(request.minWidth.value_or(0), request.minHeight.value_or(0));
151
+ }
152
+ if (request.maxWidth || request.maxHeight) {
153
+ window.contentMaxSize = NSMakeSize(request.maxWidth.value_or(CGFLOAT_MAX), request.maxHeight.value_or(CGFLOAT_MAX));
154
+ }
155
+ if (!placement.restored || !onScreen(window.frame)) {
156
+ // Down and to the right of the window in front, or near the top left of the screen.
157
+ NSWindow *front = NSApp.keyWindow != nil ? NSApp.keyWindow : NSApp.orderedWindows.firstObject;
158
+ NSPoint at;
159
+ if (front != nil && front.visible) {
160
+ at = NSMakePoint(NSMinX(front.frame) + 28, NSMaxY(front.frame) - 28);
161
+ } else {
162
+ NSRect visible = NSScreen.mainScreen.visibleFrame;
163
+ at = NSMakePoint(NSMinX(visible) + 40, NSMaxY(visible) - 40);
164
+ }
165
+ // Past any window already there, so a second note never hides the first.
166
+ for (bool taken = true; taken;) {
167
+ taken = false;
168
+ for (NSWindow *other in NSApp.windows) {
169
+ if (other.visible && fabs(NSMinX(other.frame) - at.x) < 2 && fabs(NSMaxY(other.frame) - at.y) < 2) {
170
+ at = NSMakePoint(at.x + 28, at.y - 28);
171
+ taken = true;
172
+ }
173
+ }
174
+ }
175
+ [window setFrameTopLeftPoint:at];
176
+ }
177
+ NGNWindowDelegate *delegate = [[NGNWindowDelegate alloc] initWithSurface:surface windows:this];
178
+ delegates_[@(surface)] = delegate;
179
+ window.delegate = delegate;
180
+ NSRect bounds = NSMakeRect(0, 0, NSWidth(content), NSHeight(content));
181
+ // A split view controller a reloaded app's window had gives way to the new surface.
182
+ window.contentViewController = nil;
183
+ window.contentView = hooks_.makeSurface(surface, bounds);
184
+ windows_[@(surface)] = window;
185
+ unshown_[@(surface)] = @(request.fullScreen);
186
+ hooks_.startSurface(surface, window);
187
+ opened();
188
+ });
189
+ }
190
+
191
+ void AppKitWindows::didMount(SurfaceId surface) {
192
+ if (unshown_[@(surface)] == nil || windows_[@(surface)] == nil || held_.count(surface) > 0) {
193
+ return;
194
+ }
195
+ if (!hooks_.whenShown) {
196
+ show(surface);
197
+ return;
198
+ }
199
+ held_.insert(surface);
200
+ hooks_.whenShown([this, surface] {
201
+ held_.erase(surface);
202
+ show(surface);
203
+ });
204
+ }
205
+
206
+ void AppKitWindows::show(SurfaceId surface) {
207
+ NSNumber *fullScreen = unshown_[@(surface)];
208
+ NSWindow *window = windows_[@(surface)];
209
+ // A window closed while the splash held it is not shown.
210
+ if (fullScreen == nil || window == nil) {
211
+ return;
212
+ }
213
+ [unshown_ removeObjectForKey:@(surface)];
214
+ showWindow(window);
215
+ // The app learns the size the window opened at, which a restored frame decides.
216
+ if (host_) {
217
+ host_->resized(surface, frameOf(window), window.backingScaleFactor);
218
+ }
219
+ if (fullScreen.boolValue) {
220
+ [window toggleFullScreen:nil];
221
+ }
222
+ if (hooks_.shown) {
223
+ hooks_.shown(window);
224
+ }
225
+ }
226
+
227
+ void AppKitWindows::closeWindow(SurfaceId surface) {
228
+ onMain([this, surface] {
229
+ // close does not ask windowShouldClose: the app already decided.
230
+ [windows_[@(surface)] close];
231
+ });
232
+ }
233
+
234
+ void AppKitWindows::focusWindow(SurfaceId surface) {
235
+ onMain([this, surface] {
236
+ NSWindow *window = windows_[@(surface)];
237
+ if (window != nil && unshown_[@(surface)] == nil) {
238
+ if (window.miniaturized) {
239
+ [window deminiaturize:nil];
240
+ }
241
+ activateWith(window);
242
+ }
243
+ });
244
+ }
245
+
246
+ void AppKitWindows::setWindowTitle(SurfaceId surface, const std::string &title) {
247
+ onMain([this, surface, title] { windows_[@(surface)].title = string(title); });
248
+ }
249
+
250
+ void AppKitWindows::beginQuit() {
251
+ onMain([] { [NSApp terminate:nil]; });
252
+ }
253
+
254
+ void AppKitWindows::replyToQuit(bool proceed) {
255
+ onMain([proceed] { [NSApp replyToApplicationShouldTerminate:proceed]; });
256
+ }
257
+
258
+ void AppKitWindows::after(double seconds, std::function<void()> task) {
259
+ auto shared = std::make_shared<std::function<void()>>(std::move(task));
260
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, static_cast<int64_t>(seconds * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
261
+ (*shared)();
262
+ });
263
+ }
264
+
265
+ bool AppKitWindows::shouldClose(SurfaceId surface) {
266
+ return host_ == nullptr || host_->closeRequested(surface);
267
+ }
268
+
269
+ void AppKitWindows::willClose(SurfaceId surface) {
270
+ NSWindow *window = windows_[@(surface)];
271
+ window.delegate = nil;
272
+ [windows_ removeObjectForKey:@(surface)];
273
+ [delegates_ removeObjectForKey:@(surface)];
274
+ [unshown_ removeObjectForKey:@(surface)];
275
+ hooks_.stopSurface(surface);
276
+ if (host_) {
277
+ if (host_->focusedSurface() == surface) {
278
+ host_->focused(std::nullopt);
279
+ }
280
+ }
281
+ }
282
+
283
+ void AppKitWindows::frameChanged(SurfaceId surface, bool resized) {
284
+ NSWindow *window = windows_[@(surface)];
285
+ if (window == nil) {
286
+ return;
287
+ }
288
+ if (resized) {
289
+ hooks_.resizeSurface(surface, window);
290
+ if (window.isKeyWindow && hooks_.keyWindowChanged) {
291
+ hooks_.keyWindowChanged(window);
292
+ }
293
+ }
294
+ // A window still waiting for its first frame has not been placed by the user.
295
+ if (host_ && unshown_[@(surface)] == nil) {
296
+ if (resized) {
297
+ host_->resized(surface, frameOf(window), window.backingScaleFactor);
298
+ } else {
299
+ host_->moved(surface, frameOf(window));
300
+ }
301
+ }
302
+ }
303
+
304
+ void AppKitWindows::keyChanged(SurfaceId surface, bool key) {
305
+ if (!host_) {
306
+ return;
307
+ }
308
+ if (key) {
309
+ host_->focused(surface);
310
+ if (hooks_.keyWindowChanged) {
311
+ hooks_.keyWindowChanged(windows_[@(surface)]);
312
+ }
313
+ } else if (host_->focusedSurface() == surface) {
314
+ host_->focused(std::nullopt);
315
+ }
316
+ }
317
+
318
+ } // namespace ngn::appkit
@@ -0,0 +1,73 @@
1
+ // The AppKit backend: the core's mounting and desktop props interfaces over NSViews, on the main
2
+ // thread.
3
+ #pragma once
4
+
5
+ #import <AppKit/AppKit.h>
6
+
7
+ #include "ngn/app-menus.h"
8
+ #include "ngn/desktop-view-props.h"
9
+ #include "ngn/mounting-backend.h"
10
+
11
+ @class NGNHeaderToolbar;
12
+ @class NGNSourceLists;
13
+ @class NGNSurfaceView;
14
+ @class NGNView;
15
+
16
+ namespace ngn::appkit {
17
+
18
+ class AppKitBackend final : public MountingBackend, public DesktopPropsSink {
19
+ public:
20
+ AppKitBackend();
21
+
22
+ // The view a surface's root mounts into. Main thread.
23
+ void addSurface(NGNSurfaceView *surfaceView);
24
+ void removeSurface(SurfaceId surfaceId);
25
+ NGNSurfaceView *surface(SurfaceId surfaceId) const;
26
+ // The view mounted for `tag`, or nil. Main thread.
27
+ NGNView *view(Tag tag) const;
28
+ // The history the app reports for the window of `surfaceId`, for its toolbar's chevrons. Main
29
+ // thread.
30
+ void setHistory(SurfaceId surfaceId, const std::optional<WindowHistory> &history);
31
+ // The history a window's toolbar starts with, when it is made after the app reported it.
32
+ std::function<std::optional<WindowHistory>(SurfaceId)> historyOf;
33
+ // Called on the main thread after each mounted transaction.
34
+ std::function<void(SurfaceId)> onMount;
35
+
36
+ void runOnUiThread(std::function<void()> task) override;
37
+ bool onUiThread() const override;
38
+ void serviceUiThread() override;
39
+ void createView(const ShadowView &view) override;
40
+ void deleteView(SurfaceId surfaceId, Tag tag) override;
41
+ void insertChild(SurfaceId surfaceId, Tag parent, Tag child, int index) override;
42
+ void removeChild(SurfaceId surfaceId, Tag parent, Tag child, int index) override;
43
+ void updateProps(const ShadowView &view) override;
44
+ void updateState(const ShadowView &view) override;
45
+ void updateLayout(const ShadowView &view) override;
46
+ void updateEventEmitter(const ShadowView &view) override;
47
+ void dispatchCommand(Tag tag, const std::string &name, const folly::dynamic &args) override;
48
+ void setCovered(SurfaceId surfaceId, Tag tag, bool covered) override;
49
+ void setFrontHeader(SurfaceId surfaceId, const std::optional<ScreenStacks::FrontHeader> &header) override;
50
+ void setPresented(SurfaceId surfaceId, Tag screen, bool presented) override;
51
+ void setSplitView(SurfaceId surfaceId, Tag split, bool window) override;
52
+ void setSourceLists(SurfaceId surfaceId, Tag parent, const std::vector<SourceList> &lists) override;
53
+ void setSvgDrawing(SurfaceId surfaceId, Tag svg, std::shared_ptr<const SvgDocument> document) override;
54
+ void setExpoUITree(SurfaceId surfaceId, Tag host, std::shared_ptr<const ExpoUINode> root) override;
55
+ void announce(SurfaceId surfaceId, const Announcement &announcement) override;
56
+ void didMount(SurfaceId surfaceId) override;
57
+ void updateDesktopProps(SurfaceId surfaceId, Tag tag, const DesktopProps &props) override;
58
+ std::vector<facebook::react::ComponentDescriptorProvider> componentProviders() const override;
59
+
60
+ private:
61
+ NSMutableDictionary<NSNumber *, NGNView *> *views_;
62
+ NGNHeaderToolbar *toolbarFor(SurfaceId surfaceId);
63
+ // A view whose change may change the header in front, rebuilt once the transaction is in.
64
+ void touched(NSView *view);
65
+
66
+ NSMutableDictionary<NSNumber *, NGNSurfaceView *> *surfaces_;
67
+ NSMutableDictionary<NSNumber *, NGNHeaderToolbar *> *toolbars_;
68
+ NSMutableSet<NSView *> *touched_;
69
+ // The source lists of each parent that has some, by the parent's tag.
70
+ NSMutableDictionary<NSNumber *, NGNSourceLists *> *sourceLists_;
71
+ };
72
+
73
+ } // namespace ngn::appkit