@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,269 @@
1
+ #import "search-toolbar-item.h"
2
+
3
+ #import "text-input-field.h"
4
+
5
+ #include <react/renderer/graphics/Color.h>
6
+
7
+ namespace {
8
+
9
+ NSString *string(const std::string &s) {
10
+ NSString *out = [NSString stringWithUTF8String:s.c_str()];
11
+ return out != nil ? out : @"";
12
+ }
13
+
14
+ NSColor *color(const facebook::react::SharedColor &value) {
15
+ if (!value) {
16
+ return nil;
17
+ }
18
+ auto c = facebook::react::colorComponentsFromColor(value);
19
+ return [NSColor colorWithSRGBRed:c.red green:c.green blue:c.blue alpha:c.alpha];
20
+ }
21
+
22
+ // systemDefault is none, as UIKit's default for a search bar is.
23
+ ngn::TextInputOptions inputOptions(const std::string &autoCapitalize) {
24
+ ngn::TextInputOptions options{.capitalize = ngn::Capitalize::None};
25
+ if (autoCapitalize == "words") {
26
+ options.capitalize = ngn::Capitalize::Words;
27
+ } else if (autoCapitalize == "sentences") {
28
+ options.capitalize = ngn::Capitalize::Sentences;
29
+ } else if (autoCapitalize == "characters") {
30
+ options.capitalize = ngn::Capitalize::Characters;
31
+ }
32
+ return options;
33
+ }
34
+
35
+ } // namespace
36
+
37
+ @interface NGNSearchToolbarItem () <NSSearchFieldDelegate>
38
+ - (const ngn::TextInputOptions &)options;
39
+ - (void)fieldDidBecomeFirstResponder;
40
+ @end
41
+
42
+ // The item's field: it tells the item when it takes the keyboard, and keeps the shared field editor
43
+ // to the item's capitalization.
44
+ @interface NGNSearchBarField : NSSearchField
45
+ @property (nonatomic, weak) NGNSearchToolbarItem *item;
46
+ @end
47
+
48
+ @implementation NGNSearchBarField {
49
+ BOOL _inserting;
50
+ }
51
+
52
+ - (BOOL)becomeFirstResponder {
53
+ if (![super becomeFirstResponder]) {
54
+ return NO;
55
+ }
56
+ [self.item fieldDidBecomeFirstResponder];
57
+ return YES;
58
+ }
59
+
60
+ - (BOOL)textView:(NSTextView *)textView shouldChangeTextInRange:(NSRange)range replacementString:(NSString *)string {
61
+ static const ngn::TextInputOptions none{};
62
+ return NGNControlShouldChangeText(
63
+ self, NSSearchField.class, textView, range, string, self.item ? self.item.options : none, &_inserting);
64
+ }
65
+
66
+ - (NSDictionary<NSTextCheckingOptionKey, id> *)textView:(NSTextView *)view
67
+ willCheckTextInRange:(NSRange)range
68
+ options:(NSDictionary<NSTextCheckingOptionKey, id> *)options
69
+ types:(NSTextCheckingTypes *)checkingTypes {
70
+ return self.item ? NGNTextCheckingOptions(options, self.item.options) : options;
71
+ }
72
+
73
+ @end
74
+
75
+ @implementation NGNSearchToolbarItem {
76
+ ngn::TextInputOptions _options;
77
+ NSColor *_tint;
78
+ BOOL _quiet;
79
+ // Whether the field's taking the keyboard has been reported, and not its leaving.
80
+ BOOL _editing;
81
+ // The text last reported or set from JavaScript: a change is reported once, from whichever of the
82
+ // field's action and its text-change notification comes first.
83
+ NSString *_text;
84
+ }
85
+
86
+ - (instancetype)initWithItemIdentifier:(NSToolbarItemIdentifier)identifier {
87
+ if ((self = [super initWithItemIdentifier:identifier])) {
88
+ NGNSearchBarField *field = [[NGNSearchBarField alloc] initWithFrame:NSZeroRect];
89
+ field.item = self;
90
+ field.delegate = self;
91
+ field.sendsWholeSearchString = NO;
92
+ self.searchField = field;
93
+ field.target = self;
94
+ field.action = @selector(fieldAction:);
95
+ self.label = @"Search";
96
+ _text = @"";
97
+ [self takeClearButton];
98
+ }
99
+ return self;
100
+ }
101
+
102
+ - (const ngn::TextInputOptions &)options {
103
+ return _options;
104
+ }
105
+
106
+ - (void)report:(ngn::SearchBarInput)input {
107
+ if (_quiet && (input == ngn::SearchBarInput::Began || input == ngn::SearchBarInput::Ended)) {
108
+ return;
109
+ }
110
+ if (self.input) {
111
+ self.input(input, self.searchField.stringValue);
112
+ }
113
+ }
114
+
115
+ - (void)apply:(const ngn::SearchBarConfig &)config {
116
+ NSString *placeholder = string(config.placeholder);
117
+ if (![self.searchField.placeholderString isEqualToString:placeholder]) {
118
+ self.searchField.placeholderString = placeholder;
119
+ }
120
+ self.label = placeholder.length > 0 ? placeholder : @"Search";
121
+ _options = inputOptions(config.autoCapitalize);
122
+ NSColor *text = color(config.textColor);
123
+ self.searchField.textColor = text != nil ? text : NSColor.controlTextColor;
124
+ _tint = color(config.tintColor);
125
+ [self applyTint];
126
+ [self takeClearButton];
127
+ }
128
+
129
+ - (void)applyTint {
130
+ if ([self.searchField.currentEditor isKindOfClass:NSTextView.class]) {
131
+ ((NSTextView *)self.searchField.currentEditor).insertionPointColor = _tint ? _tint : NSColor.textColor;
132
+ }
133
+ }
134
+
135
+ - (void)keepFocusAcross:(void (^)(void))change {
136
+ NSText *editor = self.searchField.currentEditor;
137
+ if (editor == nil) {
138
+ change();
139
+ return;
140
+ }
141
+ NSRange selection = editor.selectedRange;
142
+ NSWindow *window = self.searchField.window;
143
+ _quiet = YES;
144
+ change();
145
+ // The toolbar places an item put back on its next layout: the field needs its window now.
146
+ [window layoutIfNeeded];
147
+ [self focus];
148
+ NSText *again = self.searchField.currentEditor;
149
+ if (again != nil && NSMaxRange(selection) <= again.string.length) {
150
+ again.selectedRange = selection;
151
+ }
152
+ _quiet = NO;
153
+ }
154
+
155
+ - (void)run:(const ngn::SearchBarCommand &)command {
156
+ switch (command.kind) {
157
+ case ngn::SearchBarCommand::Focus:
158
+ [self focus];
159
+ break;
160
+ case ngn::SearchBarCommand::Blur:
161
+ [self blur];
162
+ break;
163
+ case ngn::SearchBarCommand::ClearText:
164
+ [self setText:@""];
165
+ break;
166
+ case ngn::SearchBarCommand::SetText:
167
+ [self setText:string(command.text)];
168
+ break;
169
+ case ngn::SearchBarCommand::Cancel:
170
+ [self cancel];
171
+ break;
172
+ }
173
+ }
174
+
175
+ - (void)focus {
176
+ // In a narrow window the item is a button until a search begins; beginning one expands it and
177
+ // gives the field the keyboard.
178
+ [self beginSearchInteraction];
179
+ if (self.searchField.currentEditor == nil) {
180
+ [self.searchField.window makeFirstResponder:self.searchField];
181
+ }
182
+ [self fieldDidBecomeFirstResponder];
183
+ }
184
+
185
+ - (void)blur {
186
+ if (self.searchField.currentEditor != nil) {
187
+ [self.searchField.window makeFirstResponder:nil];
188
+ }
189
+ }
190
+
191
+ // iOS's Cancel button: the text goes, the search ends.
192
+ - (void)cancel {
193
+ [self setText:@""];
194
+ if (self.input) {
195
+ self.input(ngn::SearchBarInput::Cancelled, @"");
196
+ }
197
+ [self blur];
198
+ [self endSearchInteraction];
199
+ }
200
+
201
+ - (void)textMayHaveChanged {
202
+ NSString *text = self.searchField.stringValue;
203
+ if (![text isEqualToString:_text]) {
204
+ _text = [text copy];
205
+ [self report:ngn::SearchBarInput::Typed];
206
+ }
207
+ }
208
+
209
+ // The clear button empties the field and reports the empty text, as iOS's clear button does; the
210
+ // cell's own only sends the field's action while it edits.
211
+ - (void)takeClearButton {
212
+ NSButtonCell *clear = ((NSSearchFieldCell *)self.searchField.cell).cancelButtonCell;
213
+ clear.target = self;
214
+ clear.action = @selector(clearField:);
215
+ }
216
+
217
+ - (void)clearField:(id)sender {
218
+ self.searchField.stringValue = @"";
219
+ [self textMayHaveChanged];
220
+ }
221
+
222
+ - (void)fieldAction:(id)sender {
223
+ [self textMayHaveChanged];
224
+ }
225
+
226
+ - (void)setText:(NSString *)text {
227
+ _text = [text copy];
228
+ self.searchField.stringValue = text;
229
+ }
230
+
231
+ // The field took the keyboard: through a click (becomeFirstResponder), or through the item's own
232
+ // search interaction, which gives it a field editor without going through becomeFirstResponder.
233
+ - (void)fieldDidBecomeFirstResponder {
234
+ [self applyTint];
235
+ if (!_editing && self.searchField.currentEditor != nil) {
236
+ _editing = YES;
237
+ [self report:ngn::SearchBarInput::Began];
238
+ }
239
+ }
240
+
241
+ - (void)beginSearchInteraction {
242
+ [super beginSearchInteraction];
243
+ [self fieldDidBecomeFirstResponder];
244
+ }
245
+
246
+ - (void)controlTextDidChange:(NSNotification *)note {
247
+ [self textMayHaveChanged];
248
+ }
249
+
250
+ - (void)controlTextDidEndEditing:(NSNotification *)note {
251
+ if (_editing) {
252
+ _editing = NO;
253
+ [self report:ngn::SearchBarInput::Ended];
254
+ }
255
+ }
256
+
257
+ - (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)selector {
258
+ if (selector == @selector(insertNewline:)) {
259
+ [self report:ngn::SearchBarInput::Submitted];
260
+ return YES;
261
+ }
262
+ if (selector == @selector(cancelOperation:)) {
263
+ [self cancel];
264
+ return YES;
265
+ }
266
+ return NO;
267
+ }
268
+
269
+ @end
@@ -0,0 +1,34 @@
1
+ // The OS half of NgNativeSharing (the core's sharing.h): AppKit's NSSharingServicePicker, shown
2
+ // below the top of the key window's content. The items it shares and how it answers are built
3
+ // apart from the picker, so they run without a window.
4
+ #pragma once
5
+
6
+ #include "ngn/sharing.h"
7
+
8
+ #import <AppKit/AppKit.h>
9
+
10
+ #include <functional>
11
+ #include <memory>
12
+ #include <optional>
13
+ #include <string>
14
+
15
+ namespace ngn::appkit {
16
+
17
+ // What a share request hands NSSharingServicePicker, in React Native iOS's order: the message as
18
+ // text, then the url as an NSURL (a `file:` uri or an absolute path as a file url, so the file
19
+ // itself is shared). A url NSURL cannot read is shared as text.
20
+ NSArray *shareItems(const SharePicker::Request &request);
21
+
22
+ std::shared_ptr<SharePicker> makeSharePicker();
23
+
24
+ } // namespace ngn::appkit
25
+
26
+ // Follows one share through the picker and the service picked, and answers once: the service's
27
+ // title once it has shared, or nothing when the picker is dismissed or the service fails. It gives
28
+ // the service the request's title as its subject (a mail's).
29
+ @interface NGNSharePickerDelegate : NSObject <NSSharingServicePickerDelegate, NSSharingServiceDelegate>
30
+ - (instancetype)initWithTitle:(std::optional<std::string>)title
31
+ done:(std::function<void(std::optional<std::string>)>)done;
32
+ // Keeps `object` (the picker) alive until the share has answered.
33
+ - (void)holdUntilAnswered:(id)object;
34
+ @end
@@ -0,0 +1,121 @@
1
+ #include "share-picker.h"
2
+
3
+ #include "ngn/file-system.h"
4
+
5
+ @implementation NGNSharePickerDelegate {
6
+ std::optional<std::string> _title;
7
+ std::function<void(std::optional<std::string>)> _done;
8
+ // Keeps itself alive until it has answered: the picker and the service hold their delegates weakly.
9
+ NGNSharePickerDelegate *_self;
10
+ id _held;
11
+ }
12
+
13
+ - (void)holdUntilAnswered:(id)object {
14
+ _held = object;
15
+ }
16
+
17
+ - (instancetype)initWithTitle:(std::optional<std::string>)title done:(std::function<void(std::optional<std::string>)>)done {
18
+ if ((self = [super init])) {
19
+ _title = std::move(title);
20
+ _done = std::move(done);
21
+ _self = self;
22
+ }
23
+ return self;
24
+ }
25
+
26
+ - (void)answer:(std::optional<std::string>)service {
27
+ if (auto done = std::exchange(_done, nullptr)) {
28
+ done(std::move(service));
29
+ }
30
+ _held = nil;
31
+ _self = nil;
32
+ }
33
+
34
+ - (id<NSSharingServiceDelegate>)sharingServicePicker:(NSSharingServicePicker *)picker
35
+ delegateForSharingService:(NSSharingService *)sharingService {
36
+ return self;
37
+ }
38
+
39
+ - (void)sharingServicePicker:(NSSharingServicePicker *)picker didChooseSharingService:(NSSharingService *)service {
40
+ if (service == nil) {
41
+ [self answer:std::nullopt];
42
+ return;
43
+ }
44
+ if (_title) {
45
+ service.subject = [NSString stringWithUTF8String:_title->c_str()];
46
+ }
47
+ }
48
+
49
+ - (void)sharingService:(NSSharingService *)sharingService didShareItems:(NSArray *)items {
50
+ NSString *title = sharingService.title;
51
+ [self answer:std::string(title.length > 0 ? title.UTF8String : "")];
52
+ }
53
+
54
+ - (void)sharingService:(NSSharingService *)sharingService didFailToShareItems:(NSArray *)items error:(NSError *)error {
55
+ [self answer:std::nullopt];
56
+ }
57
+
58
+ @end
59
+
60
+ namespace ngn::appkit {
61
+
62
+ NSArray *shareItems(const SharePicker::Request &request) {
63
+ NSMutableArray *items = [NSMutableArray array];
64
+ if (request.message) {
65
+ NSString *message = [NSString stringWithUTF8String:request.message->c_str()];
66
+ [items addObject:message != nil ? message : @""];
67
+ }
68
+ if (request.url) {
69
+ NSURL *url = nil;
70
+ if (auto path = pathOfUri(*request.url)) {
71
+ url = [NSURL fileURLWithPath:[NSString stringWithUTF8String:path->c_str()]];
72
+ } else if (NSString *text = [NSString stringWithUTF8String:request.url->c_str()]) {
73
+ url = [NSURL URLWithString:text];
74
+ if (url.scheme.length == 0) {
75
+ url = nil;
76
+ }
77
+ }
78
+ if (url != nil) {
79
+ [items addObject:url];
80
+ } else {
81
+ NSString *text = [NSString stringWithUTF8String:request.url->c_str()];
82
+ [items addObject:text != nil ? text : @""];
83
+ }
84
+ }
85
+ return items;
86
+ }
87
+
88
+ namespace {
89
+
90
+ class AppKitSharePicker final : public SharePicker {
91
+ public:
92
+ void show(const Request &request, std::function<void(std::optional<std::string>)> done) override {
93
+ auto answer = std::make_shared<std::function<void(std::optional<std::string>)>>(std::move(done));
94
+ Request copy = request;
95
+ dispatch_async(dispatch_get_main_queue(), ^{
96
+ NSWindow *window = NSApp.keyWindow != nil ? NSApp.keyWindow : NSApp.mainWindow;
97
+ NSView *anchor = window.isVisible ? window.contentView : nil;
98
+ if (anchor == nil) {
99
+ // No window to show it on: nothing was shared.
100
+ (*answer)(std::nullopt);
101
+ return;
102
+ }
103
+ NGNSharePickerDelegate *delegate = [[NGNSharePickerDelegate alloc] initWithTitle:copy.title done:*answer];
104
+ NSSharingServicePicker *picker = [[NSSharingServicePicker alloc] initWithItems:shareItems(copy)];
105
+ picker.delegate = delegate;
106
+ [delegate holdUntilAnswered:picker];
107
+ NSRect bounds = anchor.bounds;
108
+ // A point at the top centre of the content, as a sheet comes from.
109
+ NSRect at = NSMakeRect(NSMidX(bounds) - 1, anchor.isFlipped ? NSMinY(bounds) : NSMaxY(bounds) - 2, 2, 2);
110
+ [picker showRelativeToRect:at ofView:anchor preferredEdge:NSRectEdgeMinY];
111
+ });
112
+ }
113
+ };
114
+
115
+ } // namespace
116
+
117
+ std::shared_ptr<SharePicker> makeSharePicker() {
118
+ return std::make_shared<AppKitSharePicker>();
119
+ }
120
+
121
+ } // namespace ngn::appkit
@@ -0,0 +1,77 @@
1
+ // `<split-view>` and its sidebar on AppKit (the core's split-view.h decides what is what):
2
+ //
3
+ // - The window's split view is an NSSplitViewController as the window's content view controller,
4
+ // with the full-height sidebar, the toolbar's sidebar button and tracking separator, View > Show
5
+ // Sidebar and autosave. A plain one is an NSSplitView in the content, at its Yoga frame.
6
+ // - Each pane is a container of its own (NGNSurfaceView) in its split item, and the size it is given
7
+ // goes back to layout as the pane's state, at most once per display frame. The sidebar pane sits
8
+ // below the title bar; the content pane runs under the toolbar, as a window's content does.
9
+ // - Each run of neighbouring sections is a source-list NSOutlineView in the sections' place. A
10
+ // native row is drawn from the item's props; a custom row's views move into a container of their
11
+ // own as the row's cell, which takes a click on something that takes it (rowContentTakesClick)
12
+ // and otherwise lets the row select.
13
+ #pragma once
14
+
15
+ #import "host-view.h"
16
+
17
+ #include "ngn/input.h"
18
+ #include "ngn/split-view.h"
19
+
20
+ #include <functional>
21
+
22
+ // Views whose Fabric children the toolkit places itself, rather than as subviews.
23
+ @protocol NGNMountsChildren
24
+ - (void)mountChild:(NGNView *)child index:(NSInteger)index;
25
+ - (void)unmountChild:(NGNView *)child;
26
+ @end
27
+
28
+ // NgNativeSplitView, and the split view a tabs host draws as.
29
+ @interface NGNSplitView : NGNView <NGNMountsChildren>
30
+ // Set once by the host: where the panes' and rows' containers report input, which views root a
31
+ // container of their own, and whether a click in a custom row is the content's.
32
+ @property (class, nonatomic) ngn::InputSink *input;
33
+ @property (class, nonatomic) std::function<void(NSInteger tag, BOOL isRoot)> containerRootChanged;
34
+ @property (class, nonatomic) std::function<bool(NSInteger rowTag, NSPoint point)> rowContentTakesClick;
35
+ // The window this split view is the content of, once it is the window's.
36
+ @property (nonatomic, readonly, weak) NSWindow *ownWindow;
37
+ // The core's decision (Sidebars::settle): the window's, or plain in the content.
38
+ - (void)placeAsWindows:(BOOL)window;
39
+ // The split view is leaving: the window gets its surface back.
40
+ - (void)uninstall;
41
+ @end
42
+
43
+ // NgNativeSidebar and NgNativeSplitContent: filled by their container, not placed by Yoga.
44
+ @interface NGNSplitPaneView : NGNView
45
+ @end
46
+
47
+ // NgNativeSidebarSection: a model object, never drawn.
48
+ @interface NGNSidebarSectionView : NGNView
49
+ @end
50
+
51
+ // NgNativeSidebarItem: a model object, or a custom row's views.
52
+ @interface NGNSidebarItemView : NGNView
53
+ @end
54
+
55
+ // RNSTabsHostIOS (the core's tabs-host.h): a split view whose sidebar lists the tabs and whose
56
+ // content pane shows the selected one's screen.
57
+ @interface NGNTabsHostView : NGNSplitView
58
+ // Set once by the host: the user chose a tab (surface, host, screen).
59
+ @property (class, nonatomic) std::function<void(NSInteger, NSInteger, NSInteger)> tabChosen;
60
+ - (void)setTabs:(const ngn::SourceList &)tabs;
61
+ @end
62
+
63
+ // RNSTabsScreenIOS: as big as its tabs host's content pane.
64
+ @interface NGNTabScreenView : NGNView
65
+ @end
66
+
67
+ // The source lists among one parent's children.
68
+ @interface NGNSourceLists : NSObject
69
+ - (instancetype)initWithParent:(NGNView *)parent;
70
+ - (void)setLists:(const std::vector<ngn::SourceList> &)lists views:(NGNView * (^)(NSInteger tag))views;
71
+ // Lays each list out over its sections' frames, which Yoga may have moved.
72
+ - (void)layOut;
73
+ - (void)remove;
74
+ @end
75
+
76
+ // The window a surface shows in, even once a split view controller took its content: nil when none.
77
+ NSWindow *NGNWindowOfSplit(NSView *surfaceView);