@ng-native/desktop 0.0.0-stage → 0.23.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 (393) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +51 -2
  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 +276 -0
  14. package/native/appkit/CMakeLists.txt +109 -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-view.h +15 -0
  41. package/native/appkit/camera-view.mm +130 -0
  42. package/native/appkit/camera.h +39 -0
  43. package/native/appkit/camera.mm +362 -0
  44. package/native/appkit/cg-canvas.h +17 -0
  45. package/native/appkit/cg-canvas.mm +518 -0
  46. package/native/appkit/component-view.h +17 -0
  47. package/native/appkit/crypto.h +19 -0
  48. package/native/appkit/crypto.mm +78 -0
  49. package/native/appkit/desktop-expo.h +29 -0
  50. package/native/appkit/desktop-expo.mm +385 -0
  51. package/native/appkit/expo-image-drawing.h +46 -0
  52. package/native/appkit/expo-image-drawing.mm +131 -0
  53. package/native/appkit/expo-image-view.h +15 -0
  54. package/native/appkit/expo-image-view.mm +182 -0
  55. package/native/appkit/expo-ui-renderer.h +68 -0
  56. package/native/appkit/expo-ui-renderer.mm +101 -0
  57. package/native/appkit/expo-ui-view.h +26 -0
  58. package/native/appkit/expo-ui-view.mm +134 -0
  59. package/native/appkit/expo-ui.swift +1284 -0
  60. package/native/appkit/file-system.h +16 -0
  61. package/native/appkit/file-system.mm +140 -0
  62. package/native/appkit/fonts.h +12 -0
  63. package/native/appkit/fonts.mm +48 -0
  64. package/native/appkit/geocoder.h +19 -0
  65. package/native/appkit/geocoder.mm +101 -0
  66. package/native/appkit/glass-effect.h +22 -0
  67. package/native/appkit/glass-effect.mm +63 -0
  68. package/native/appkit/glass-view.h +8 -0
  69. package/native/appkit/glass-view.mm +65 -0
  70. package/native/appkit/header-toolbar.h +60 -0
  71. package/native/appkit/header-toolbar.mm +629 -0
  72. package/native/appkit/host-view.h +54 -0
  73. package/native/appkit/host-view.mm +1200 -0
  74. package/native/appkit/image-manipulator.h +14 -0
  75. package/native/appkit/image-manipulator.mm +191 -0
  76. package/native/appkit/image-request.h +22 -0
  77. package/native/appkit/image-request.mm +62 -0
  78. package/native/appkit/image-view.h +8 -0
  79. package/native/appkit/image-view.mm +142 -0
  80. package/native/appkit/input-replay.h +25 -0
  81. package/native/appkit/input-replay.mm +418 -0
  82. package/native/appkit/language-model.h +14 -0
  83. package/native/appkit/language-model.mm +99 -0
  84. package/native/appkit/language-model.swift +472 -0
  85. package/native/appkit/local-authentication.h +15 -0
  86. package/native/appkit/local-authentication.mm +133 -0
  87. package/native/appkit/location.h +16 -0
  88. package/native/appkit/location.mm +214 -0
  89. package/native/appkit/main.mm +1515 -0
  90. package/native/appkit/map-view.h +15 -0
  91. package/native/appkit/map-view.mm +109 -0
  92. package/native/appkit/maps.h +35 -0
  93. package/native/appkit/maps.mm +343 -0
  94. package/native/appkit/menu-bar.h +22 -0
  95. package/native/appkit/menu-bar.mm +208 -0
  96. package/native/appkit/modal-focus.h +16 -0
  97. package/native/appkit/modal-focus.mm +26 -0
  98. package/native/appkit/modal-host-view.h +79 -0
  99. package/native/appkit/modal-host-view.mm +442 -0
  100. package/native/appkit/native-controls.h +22 -0
  101. package/native/appkit/native-controls.mm +431 -0
  102. package/native/appkit/network-state.h +12 -0
  103. package/native/appkit/network-state.mm +64 -0
  104. package/native/appkit/network.h +14 -0
  105. package/native/appkit/network.mm +396 -0
  106. package/native/appkit/notifications.h +19 -0
  107. package/native/appkit/notifications.mm +309 -0
  108. package/native/appkit/photo-library.h +33 -0
  109. package/native/appkit/photo-library.mm +548 -0
  110. package/native/appkit/pointer-buttons.h +32 -0
  111. package/native/appkit/presentation-label.h +15 -0
  112. package/native/appkit/presentation-label.mm +12 -0
  113. package/native/appkit/presented-screen.h +19 -0
  114. package/native/appkit/presented-screen.mm +181 -0
  115. package/native/appkit/printing.h +42 -0
  116. package/native/appkit/printing.mm +393 -0
  117. package/native/appkit/push.h +19 -0
  118. package/native/appkit/push.mm +81 -0
  119. package/native/appkit/red-box.h +26 -0
  120. package/native/appkit/red-box.mm +387 -0
  121. package/native/appkit/screen-capture.h +21 -0
  122. package/native/appkit/screen-capture.mm +92 -0
  123. package/native/appkit/scroll-view.h +13 -0
  124. package/native/appkit/scroll-view.mm +251 -0
  125. package/native/appkit/scrollers.h +25 -0
  126. package/native/appkit/scrollers.mm +43 -0
  127. package/native/appkit/search-field.h +34 -0
  128. package/native/appkit/search-field.mm +291 -0
  129. package/native/appkit/search-toolbar-item.h +19 -0
  130. package/native/appkit/search-toolbar-item.mm +269 -0
  131. package/native/appkit/share-picker.h +34 -0
  132. package/native/appkit/share-picker.mm +121 -0
  133. package/native/appkit/split-view.h +77 -0
  134. package/native/appkit/split-view.mm +1206 -0
  135. package/native/appkit/store-review.h +13 -0
  136. package/native/appkit/store-review.mm +28 -0
  137. package/native/appkit/surface-view.h +45 -0
  138. package/native/appkit/surface-view.mm +558 -0
  139. package/native/appkit/svg-view.h +17 -0
  140. package/native/appkit/svg-view.mm +57 -0
  141. package/native/appkit/symbol-drawing.h +24 -0
  142. package/native/appkit/symbol-drawing.mm +117 -0
  143. package/native/appkit/symbol-view.h +8 -0
  144. package/native/appkit/symbol-view.mm +33 -0
  145. package/native/appkit/system-access.h +34 -0
  146. package/native/appkit/system-access.mm +210 -0
  147. package/native/appkit/system.h +24 -0
  148. package/native/appkit/system.mm +403 -0
  149. package/native/appkit/test-launch.h +36 -0
  150. package/native/appkit/test-launch.mm +115 -0
  151. package/native/appkit/text-input-field.h +76 -0
  152. package/native/appkit/text-input-field.mm +444 -0
  153. package/native/appkit/text-layout.h +58 -0
  154. package/native/appkit/text-layout.mm +477 -0
  155. package/native/appkit/text-recognition.h +13 -0
  156. package/native/appkit/text-recognition.mm +102 -0
  157. package/native/appkit/tracking.h +13 -0
  158. package/native/appkit/tracking.mm +51 -0
  159. package/native/appkit/tray-and-dock.h +45 -0
  160. package/native/appkit/tray-and-dock.mm +130 -0
  161. package/native/appkit/undo.h +23 -0
  162. package/native/appkit/undo.mm +125 -0
  163. package/native/appkit/updates.h +17 -0
  164. package/native/appkit/updates.mm +71 -0
  165. package/native/appkit/video-view.h +10 -0
  166. package/native/appkit/video-view.mm +42 -0
  167. package/native/appkit/video.h +38 -0
  168. package/native/appkit/video.mm +404 -0
  169. package/native/appkit/web-browser.h +12 -0
  170. package/native/appkit/web-browser.mm +97 -0
  171. package/native/appkit/web-view-component.h +9 -0
  172. package/native/appkit/web-view-component.mm +56 -0
  173. package/native/appkit/web-view.h +31 -0
  174. package/native/appkit/web-view.mm +394 -0
  175. package/native/cmake/libraries/react-native-reanimated.cmake +45 -0
  176. package/native/cmake/libraries/react-native-worklets.cmake +46 -0
  177. package/native/cmake/libraries.cmake +109 -0
  178. package/native/cmake/linked-modules.cmake +112 -0
  179. package/native/cmake/react-native.cmake +175 -0
  180. package/native/cmake/runtime-dependencies.cmake +34 -0
  181. package/native/cmake/swift.cmake +43 -0
  182. package/native/cmake/third-party.cmake +74 -0
  183. package/native/core/include/ngn/absent-views.h +27 -0
  184. package/native/core/include/ngn/accessibility.h +140 -0
  185. package/native/core/include/ngn/address-search.h +69 -0
  186. package/native/core/include/ngn/animation-frames.h +39 -0
  187. package/native/core/include/ngn/app-info.h +52 -0
  188. package/native/core/include/ngn/app-menus.h +146 -0
  189. package/native/core/include/ngn/app-windows.h +181 -0
  190. package/native/core/include/ngn/apple-authentication.h +116 -0
  191. package/native/core/include/ngn/asset.h +28 -0
  192. package/native/core/include/ngn/audio.h +125 -0
  193. package/native/core/include/ngn/back-swipe.h +112 -0
  194. package/native/core/include/ngn/battery.h +48 -0
  195. package/native/core/include/ngn/bytes.h +59 -0
  196. package/native/core/include/ngn/calendar.h +180 -0
  197. package/native/core/include/ngn/camera.h +128 -0
  198. package/native/core/include/ngn/control-sizes.h +111 -0
  199. package/native/core/include/ngn/core-modules.h +105 -0
  200. package/native/core/include/ngn/crypto.h +38 -0
  201. package/native/core/include/ngn/default-menu.h +91 -0
  202. package/native/core/include/ngn/desktop-expo.h +193 -0
  203. package/native/core/include/ngn/desktop-modal.h +109 -0
  204. package/native/core/include/ngn/desktop-props.h +75 -0
  205. package/native/core/include/ngn/desktop-view-props.h +110 -0
  206. package/native/core/include/ngn/dev-server.h +33 -0
  207. package/native/core/include/ngn/download.h +24 -0
  208. package/native/core/include/ngn/expo-image.h +192 -0
  209. package/native/core/include/ngn/expo-ui.h +133 -0
  210. package/native/core/include/ngn/file-system.h +274 -0
  211. package/native/core/include/ngn/focus-order.h +63 -0
  212. package/native/core/include/ngn/fonts.h +64 -0
  213. package/native/core/include/ngn/gestures.h +305 -0
  214. package/native/core/include/ngn/glass.h +67 -0
  215. package/native/core/include/ngn/header-bar.h +112 -0
  216. package/native/core/include/ngn/host-state.h +243 -0
  217. package/native/core/include/ngn/image-manipulator.h +70 -0
  218. package/native/core/include/ngn/input-dispatcher.h +211 -0
  219. package/native/core/include/ngn/input-script.h +56 -0
  220. package/native/core/include/ngn/input.h +112 -0
  221. package/native/core/include/ngn/key-value-store.h +41 -0
  222. package/native/core/include/ngn/language-model.h +69 -0
  223. package/native/core/include/ngn/launch-frame.h +47 -0
  224. package/native/core/include/ngn/launch-settings.h +98 -0
  225. package/native/core/include/ngn/layout-animations.h +24 -0
  226. package/native/core/include/ngn/library-components.h +13 -0
  227. package/native/core/include/ngn/library-glue.h +53 -0
  228. package/native/core/include/ngn/live-regions.h +54 -0
  229. package/native/core/include/ngn/local-authentication.h +74 -0
  230. package/native/core/include/ngn/location.h +89 -0
  231. package/native/core/include/ngn/maps.h +226 -0
  232. package/native/core/include/ngn/module-registry.h +51 -0
  233. package/native/core/include/ngn/mounting-backend.h +96 -0
  234. package/native/core/include/ngn/mounting-manager.h +155 -0
  235. package/native/core/include/ngn/native-controls.h +161 -0
  236. package/native/core/include/ngn/native-module.h +109 -0
  237. package/native/core/include/ngn/network-state.h +44 -0
  238. package/native/core/include/ngn/network.h +100 -0
  239. package/native/core/include/ngn/notifications.h +185 -0
  240. package/native/core/include/ngn/photo-library.h +130 -0
  241. package/native/core/include/ngn/printing.h +69 -0
  242. package/native/core/include/ngn/processes.h +114 -0
  243. package/native/core/include/ngn/red-box.h +119 -0
  244. package/native/core/include/ngn/reload-thread.h +258 -0
  245. package/native/core/include/ngn/runtime.h +161 -0
  246. package/native/core/include/ngn/safe-areas.h +77 -0
  247. package/native/core/include/ngn/screen-capture.h +35 -0
  248. package/native/core/include/ngn/screen-presentation.h +85 -0
  249. package/native/core/include/ngn/screen-stacks.h +80 -0
  250. package/native/core/include/ngn/scrollers.h +106 -0
  251. package/native/core/include/ngn/sharing.h +39 -0
  252. package/native/core/include/ngn/spawn-rules.h +78 -0
  253. package/native/core/include/ngn/splash-screen.h +41 -0
  254. package/native/core/include/ngn/split-view.h +270 -0
  255. package/native/core/include/ngn/sqlite.h +38 -0
  256. package/native/core/include/ngn/store-review.h +26 -0
  257. package/native/core/include/ngn/surface-book.h +101 -0
  258. package/native/core/include/ngn/svg.h +393 -0
  259. package/native/core/include/ngn/symbol.h +90 -0
  260. package/native/core/include/ngn/system.h +102 -0
  261. package/native/core/include/ngn/tabs-host.h +171 -0
  262. package/native/core/include/ngn/text-input.h +125 -0
  263. package/native/core/include/ngn/text-measurer.h +38 -0
  264. package/native/core/include/ngn/text-recognition.h +55 -0
  265. package/native/core/include/ngn/tracking.h +34 -0
  266. package/native/core/include/ngn/tray-and-dock.h +107 -0
  267. package/native/core/include/ngn/undo.h +37 -0
  268. package/native/core/include/ngn/updates.h +253 -0
  269. package/native/core/include/ngn/video.h +126 -0
  270. package/native/core/include/ngn/view-box.h +126 -0
  271. package/native/core/include/ngn/view-transform.h +26 -0
  272. package/native/core/include/ngn/view-tree.h +85 -0
  273. package/native/core/include/ngn/web-browser.h +45 -0
  274. package/native/core/include/ngn/web-view.h +133 -0
  275. package/native/core/include/ngn/worklet-host.h +98 -0
  276. package/native/core/src/absent-views.cpp +41 -0
  277. package/native/core/src/accessibility.cpp +374 -0
  278. package/native/core/src/animation-frames.cpp +49 -0
  279. package/native/core/src/app-menus.cpp +352 -0
  280. package/native/core/src/app-windows.cpp +444 -0
  281. package/native/core/src/back-swipe.cpp +91 -0
  282. package/native/core/src/bytes.cpp +158 -0
  283. package/native/core/src/control-sizes.cpp +232 -0
  284. package/native/core/src/default-menu.cpp +96 -0
  285. package/native/core/src/desktop-modal.cpp +162 -0
  286. package/native/core/src/desktop-view-props.cpp +80 -0
  287. package/native/core/src/dev-server-helper.cpp +152 -0
  288. package/native/core/src/dev-server.cpp +103 -0
  289. package/native/core/src/download.cpp +53 -0
  290. package/native/core/src/expo-image.cpp +548 -0
  291. package/native/core/src/expo-ui.cpp +203 -0
  292. package/native/core/src/focus-order.cpp +441 -0
  293. package/native/core/src/gestures.cpp +1806 -0
  294. package/native/core/src/glass.cpp +49 -0
  295. package/native/core/src/header-bar.cpp +104 -0
  296. package/native/core/src/host-services.cpp +50 -0
  297. package/native/core/src/host-state.cpp +61 -0
  298. package/native/core/src/input-dispatcher.cpp +727 -0
  299. package/native/core/src/input-script.cpp +123 -0
  300. package/native/core/src/key-value-store.cpp +169 -0
  301. package/native/core/src/launch-settings.cpp +148 -0
  302. package/native/core/src/layout-animations.cpp +62 -0
  303. package/native/core/src/libraries/RNCWebViewSpec.cpp +80 -0
  304. package/native/core/src/libraries/react-native-reanimated.cpp +216 -0
  305. package/native/core/src/libraries/react-native-worklets.cpp +192 -0
  306. package/native/core/src/libraries/rnscreens.cpp +125 -0
  307. package/native/core/src/libraries/rnsvg.cpp +345 -0
  308. package/native/core/src/libraries/safeareacontext.cpp +70 -0
  309. package/native/core/src/libraries/worklets-idle-frames.js +70 -0
  310. package/native/core/src/library-glue.cpp +35 -0
  311. package/native/core/src/live-regions.cpp +122 -0
  312. package/native/core/src/module-registry.cpp +50 -0
  313. package/native/core/src/modules/accessibility-manager.cpp +98 -0
  314. package/native/core/src/modules/address-search.cpp +219 -0
  315. package/native/core/src/modules/alert-manager.cpp +140 -0
  316. package/native/core/src/modules/app-info.cpp +74 -0
  317. package/native/core/src/modules/app-modules.cpp +405 -0
  318. package/native/core/src/modules/apple-authentication.cpp +188 -0
  319. package/native/core/src/modules/asset.cpp +111 -0
  320. package/native/core/src/modules/async-storage.cpp +192 -0
  321. package/native/core/src/modules/audio.cpp +541 -0
  322. package/native/core/src/modules/battery.cpp +88 -0
  323. package/native/core/src/modules/calendar.cpp +457 -0
  324. package/native/core/src/modules/camera.cpp +221 -0
  325. package/native/core/src/modules/core-modules.cpp +62 -0
  326. package/native/core/src/modules/crypto.cpp +117 -0
  327. package/native/core/src/modules/desktop-expo.cpp +527 -0
  328. package/native/core/src/modules/file-system.cpp +941 -0
  329. package/native/core/src/modules/fonts.cpp +163 -0
  330. package/native/core/src/modules/image-loader.cpp +105 -0
  331. package/native/core/src/modules/image-manipulator.cpp +305 -0
  332. package/native/core/src/modules/language-model.cpp +195 -0
  333. package/native/core/src/modules/local-authentication.cpp +140 -0
  334. package/native/core/src/modules/location.cpp +186 -0
  335. package/native/core/src/modules/maps.cpp +500 -0
  336. package/native/core/src/modules/network-state.cpp +72 -0
  337. package/native/core/src/modules/networking.cpp +387 -0
  338. package/native/core/src/modules/notifications.cpp +549 -0
  339. package/native/core/src/modules/photo-library.cpp +371 -0
  340. package/native/core/src/modules/printing.cpp +201 -0
  341. package/native/core/src/modules/screen-capture.cpp +71 -0
  342. package/native/core/src/modules/sharing.cpp +59 -0
  343. package/native/core/src/modules/splash-screen.cpp +70 -0
  344. package/native/core/src/modules/sqlite.cpp +421 -0
  345. package/native/core/src/modules/store-review.cpp +23 -0
  346. package/native/core/src/modules/text-recognition.cpp +107 -0
  347. package/native/core/src/modules/tracking.cpp +46 -0
  348. package/native/core/src/modules/undo.cpp +59 -0
  349. package/native/core/src/modules/video.cpp +366 -0
  350. package/native/core/src/modules/web-browser.cpp +100 -0
  351. package/native/core/src/modules/web-socket.cpp +266 -0
  352. package/native/core/src/mounting-manager.cpp +380 -0
  353. package/native/core/src/native-controls.cpp +129 -0
  354. package/native/core/src/native-module.cpp +250 -0
  355. package/native/core/src/network.cpp +219 -0
  356. package/native/core/src/posix-launcher.cpp +366 -0
  357. package/native/core/src/processes.cpp +324 -0
  358. package/native/core/src/red-box-errors.js +83 -0
  359. package/native/core/src/red-box.cpp +306 -0
  360. package/native/core/src/runtime.cpp +422 -0
  361. package/native/core/src/safe-areas.cpp +130 -0
  362. package/native/core/src/screen-presentation.cpp +61 -0
  363. package/native/core/src/screen-stacks.cpp +254 -0
  364. package/native/core/src/scrollers.cpp +181 -0
  365. package/native/core/src/spawn-rules.cpp +292 -0
  366. package/native/core/src/split-view.cpp +343 -0
  367. package/native/core/src/svg.cpp +1883 -0
  368. package/native/core/src/symbol.cpp +94 -0
  369. package/native/core/src/tabs-host.cpp +234 -0
  370. package/native/core/src/text-input.cpp +126 -0
  371. package/native/core/src/text-layout-manager.cpp +63 -0
  372. package/native/core/src/tray-and-dock.cpp +154 -0
  373. package/native/core/src/updates.cpp +965 -0
  374. package/native/core/src/view-box.cpp +788 -0
  375. package/native/core/src/view-transform.cpp +45 -0
  376. package/native/core/src/view-tree.cpp +234 -0
  377. package/native/core/src/web-view.cpp +143 -0
  378. package/native/core/src/worklet-host.cpp +10 -0
  379. package/native/scripts/build-hermes.sh +44 -0
  380. package/native/scripts/build.sh +171 -0
  381. package/native/scripts/cache-dir.sh +18 -0
  382. package/native/scripts/codegen-library.sh +193 -0
  383. package/native/scripts/compiler-launcher.sh +17 -0
  384. package/native/scripts/fetch.sh +174 -0
  385. package/native/scripts/hermes-built.sh +10 -0
  386. package/native/scripts/host-dir.sh +16 -0
  387. package/native/scripts/macos-target.sh +8 -0
  388. package/native/scripts/make-prebuilt.mjs +360 -0
  389. package/native/scripts/prebuilt-host-cache.mjs +158 -0
  390. package/native/shim/openssl/sha.h +22 -0
  391. package/native/shim/view-platform/react/renderer/components/view/HostPlatformViewTraitsInitializer.h +37 -0
  392. package/package.json +70 -3
  393. package/prebuilt.json +33 -0
@@ -0,0 +1,1200 @@
1
+ #import "host-view.h"
2
+
3
+ #include "ngn/view-transform.h"
4
+
5
+ #import <QuartzCore/QuartzCore.h>
6
+
7
+ #import "cg-canvas.h"
8
+ #import "header-toolbar.h"
9
+ #import "image-view.h"
10
+ #import "modal-host-view.h"
11
+ #import "native-controls.h"
12
+ #import "presented-screen.h"
13
+ #import "scroll-view.h"
14
+ #import "split-view.h"
15
+ #import "svg-view.h"
16
+ #import "symbol-view.h"
17
+ #import "glass-view.h"
18
+
19
+ #include "ngn/glass.h"
20
+ #import "web-view-component.h"
21
+ #import "expo-image-view.h"
22
+ #import "expo-ui-view.h"
23
+ #import "camera-view.h"
24
+ #import "video-view.h"
25
+ #import "apple-button-view.h"
26
+ #import "map-view.h"
27
+ #import "text-input-field.h"
28
+
29
+ #include "text-layout.h"
30
+
31
+ #include "ngn/accessibility.h"
32
+ #include "ngn/symbol.h"
33
+ #include "ngn/view-box.h"
34
+
35
+ #include "ngn/text-input.h"
36
+ #include <react/renderer/components/text/ParagraphState.h>
37
+ #include <react/renderer/components/textinput/TextInputEventEmitter.h>
38
+ #include <react/renderer/components/view/ViewEventEmitter.h>
39
+ #include <react/renderer/components/view/ViewProps.h>
40
+ #include <react/renderer/core/ConcreteState.h>
41
+
42
+ using namespace facebook::react;
43
+
44
+ namespace {
45
+
46
+ NSColor *nsColor(const SharedColor &color) {
47
+ if (!color) {
48
+ return nil;
49
+ }
50
+ auto c = colorComponentsFromColor(color);
51
+ return [NSColor colorWithSRGBRed:c.red green:c.green blue:c.blue alpha:c.alpha];
52
+ }
53
+
54
+ CGColorRef cgColor(uint32_t argb) {
55
+ return [NSColor colorWithSRGBRed:((argb >> 16) & 0xff) / 255.0
56
+ green:((argb >> 8) & 0xff) / 255.0
57
+ blue:(argb & 0xff) / 255.0
58
+ alpha:(argb >> 24) / 255.0]
59
+ .CGColor;
60
+ }
61
+
62
+ // A mask layer over `bounds` showing `path`.
63
+ CAShapeLayer *shapeLayer(const ngn::SvgPath &path, BOOL evenOdd, NSRect bounds) {
64
+ CAShapeLayer *mask = [CAShapeLayer layer];
65
+ mask.frame = bounds;
66
+ CGPathRef p = NGNCreatePath(path);
67
+ mask.path = p;
68
+ CGPathRelease(p);
69
+ mask.fillRule = evenOdd ? kCAFillRuleEvenOdd : kCAFillRuleNonZero;
70
+ return mask;
71
+ }
72
+
73
+ NSString *nsString(const std::string &s) {
74
+ NSString *result = [NSString stringWithUTF8String:s.c_str()];
75
+ return result != nil ? result : @"";
76
+ }
77
+
78
+ NSAccessibilityRole nsRole(ngn::AxRole role) {
79
+ switch (role) {
80
+ case ngn::AxRole::Group:
81
+ return NSAccessibilityGroupRole;
82
+ case ngn::AxRole::Button:
83
+ return NSAccessibilityButtonRole;
84
+ case ngn::AxRole::Link:
85
+ return NSAccessibilityLinkRole;
86
+ case ngn::AxRole::Image:
87
+ return NSAccessibilityImageRole;
88
+ case ngn::AxRole::StaticText:
89
+ return NSAccessibilityStaticTextRole;
90
+ case ngn::AxRole::CheckBox:
91
+ return NSAccessibilityCheckBoxRole;
92
+ case ngn::AxRole::RadioButton:
93
+ return NSAccessibilityRadioButtonRole;
94
+ case ngn::AxRole::RadioGroup:
95
+ return NSAccessibilityRadioGroupRole;
96
+ case ngn::AxRole::Slider:
97
+ return NSAccessibilitySliderRole;
98
+ case ngn::AxRole::TextField:
99
+ return NSAccessibilityTextFieldRole;
100
+ case ngn::AxRole::List:
101
+ return NSAccessibilityListRole;
102
+ case ngn::AxRole::Menu:
103
+ return NSAccessibilityMenuRole;
104
+ case ngn::AxRole::MenuItem:
105
+ return NSAccessibilityMenuItemRole;
106
+ case ngn::AxRole::MenuBar:
107
+ return NSAccessibilityMenuBarRole;
108
+ case ngn::AxRole::ProgressIndicator:
109
+ return NSAccessibilityProgressIndicatorRole;
110
+ case ngn::AxRole::ComboBox:
111
+ return NSAccessibilityComboBoxRole;
112
+ case ngn::AxRole::TabGroup:
113
+ return NSAccessibilityTabGroupRole;
114
+ case ngn::AxRole::Toolbar:
115
+ return NSAccessibilityToolbarRole;
116
+ case ngn::AxRole::ScrollBar:
117
+ return NSAccessibilityScrollBarRole;
118
+ case ngn::AxRole::Table:
119
+ return NSAccessibilityTableRole;
120
+ case ngn::AxRole::Row:
121
+ return NSAccessibilityRowRole;
122
+ case ngn::AxRole::Cell:
123
+ return NSAccessibilityCellRole;
124
+ case ngn::AxRole::Incrementor:
125
+ return NSAccessibilityIncrementorRole;
126
+ case ngn::AxRole::Heading:
127
+ if (@available(macOS 26, *)) {
128
+ return NSAccessibilityHeadingRole;
129
+ }
130
+ return NSAccessibilityGroupRole;
131
+ case ngn::AxRole::LevelIndicator:
132
+ return NSAccessibilityLevelIndicatorRole;
133
+ case ngn::AxRole::Outline:
134
+ return NSAccessibilityOutlineRole;
135
+ case ngn::AxRole::ScrollArea:
136
+ return NSAccessibilityScrollAreaRole;
137
+ }
138
+ return NSAccessibilityGroupRole;
139
+ }
140
+
141
+ // Whether AppKit has a role of its own for this one, so its own name for it is spoken.
142
+ bool nativeRole(ngn::AxRole role) {
143
+ if (role == ngn::AxRole::Heading) {
144
+ if (@available(macOS 26, *)) {
145
+ return true;
146
+ }
147
+ return false;
148
+ }
149
+ return true;
150
+ }
151
+
152
+ NSAccessibilitySubrole nsSubrole(ngn::AxSubrole subrole) {
153
+ switch (subrole) {
154
+ case ngn::AxSubrole::Switch:
155
+ return NSAccessibilitySwitchSubrole;
156
+ case ngn::AxSubrole::Toggle:
157
+ return NSAccessibilityToggleSubrole;
158
+ case ngn::AxSubrole::Tab:
159
+ return NSAccessibilityTabButtonSubrole;
160
+ case ngn::AxSubrole::SearchField:
161
+ return NSAccessibilitySearchFieldSubrole;
162
+ case ngn::AxSubrole::OutlineRow:
163
+ return NSAccessibilityOutlineRowSubrole;
164
+ case ngn::AxSubrole::None:
165
+ return nil;
166
+ }
167
+ return nil;
168
+ }
169
+
170
+ } // namespace
171
+
172
+ #pragma mark - NGNView
173
+
174
+ static ngn::InputDispatcher *gViewInput;
175
+
176
+ // A view's backing layer, holding the transform from its props. AppKit puts a layer-backed view's
177
+ // own geometry back on its layer as it lays out and displays the window, which sets the transform
178
+ // back to the identity (the view has no rotation of its own); this layer keeps the view's.
179
+ @interface NGNViewLayer : CALayer
180
+ @property (nonatomic) CATransform3D viewTransform;
181
+ @end
182
+
183
+ @implementation NGNViewLayer
184
+
185
+ - (instancetype)init {
186
+ if ((self = [super init])) {
187
+ _viewTransform = CATransform3DIdentity;
188
+ }
189
+ return self;
190
+ }
191
+
192
+ - (void)setTransform:(CATransform3D)transform {
193
+ [super setTransform:_viewTransform];
194
+ }
195
+
196
+ - (void)setViewTransform:(CATransform3D)transform {
197
+ _viewTransform = transform;
198
+ [super setTransform:transform];
199
+ }
200
+
201
+ @end
202
+
203
+ @implementation NGNView {
204
+ Props::Shared _props;
205
+ LayoutMetrics _layout;
206
+ State::Shared _state;
207
+ EventEmitter::Shared _emitter;
208
+ ngn::DesktopProps _desktop;
209
+ BOOL _focusVisible;
210
+ // drawRect draws the box (ngn/view-box.h), which the layer does not.
211
+ BOOL _boxDrawn;
212
+ NSMutableArray<CALayer *> *_shadowLayers;
213
+ // The transform from the props, as NGNViewLayer holds it.
214
+ CATransform3D _transform;
215
+ }
216
+
217
+ - (instancetype)initWithShadowView:(const ShadowView &)view {
218
+ if ((self = [super initWithFrame:NSZeroRect])) {
219
+ _transform = CATransform3DIdentity;
220
+ _swipeOpacity = 1;
221
+ _reactTag = view.tag;
222
+ _surfaceId = view.surfaceId;
223
+ _componentName = [NSString stringWithUTF8String:view.componentName];
224
+ self.wantsLayer = YES;
225
+ self.layerContentsRedrawPolicy = NSViewLayerContentsRedrawOnSetNeedsDisplay;
226
+ }
227
+ return self;
228
+ }
229
+
230
+ + (ngn::InputDispatcher *)activator {
231
+ return gViewInput;
232
+ }
233
+ + (void)setActivator:(ngn::InputDispatcher *)input {
234
+ gViewInput = input;
235
+ }
236
+
237
+ - (BOOL)isFlipped {
238
+ return YES;
239
+ }
240
+
241
+ - (CALayer *)makeBackingLayer {
242
+ NGNViewLayer *layer = [NGNViewLayer layer];
243
+ layer.contentsScale = self.window ? self.window.backingScaleFactor : NSScreen.mainScreen.backingScaleFactor;
244
+ return layer;
245
+ }
246
+
247
+ // A layer of the view's own making draws its contents at the scale it is given, not the screen's.
248
+ - (void)viewDidChangeBackingProperties {
249
+ [super viewDidChangeBackingProperties];
250
+ if (self.window) {
251
+ self.layer.contentsScale = self.window.backingScaleFactor;
252
+ }
253
+ }
254
+
255
+ // AppKit's hit test goes by the frame and ignores the layer's transform. A transformed view is
256
+ // hit where its layer draws it, as the core's hit test finds it (ViewTree::pointIn): `point` (in
257
+ // the superview's coordinates) goes back through the transform, about the frame's corner, before
258
+ // AppKit tests the frame and the subviews.
259
+ - (NSView *)hitTest:(NSPoint)point {
260
+ CATransform3D t = _transform;
261
+ if (CATransform3DIsIdentity(t)) {
262
+ return [super hitTest:point];
263
+ }
264
+ const CGFloat columns[16] = {
265
+ t.m11, t.m12, t.m13, t.m14, t.m21, t.m22, t.m23, t.m24, t.m31, t.m32, t.m33, t.m34, t.m41, t.m42, t.m43, t.m44};
266
+ Transform matrix;
267
+ for (size_t i = 0; i < 16; ++i) {
268
+ matrix.matrix[i] = static_cast<Float>(columns[i]);
269
+ }
270
+ NSPoint origin = self.frame.origin;
271
+ auto local = ngn::layerPointAt(matrix, {static_cast<Float>(point.x - origin.x), static_cast<Float>(point.y - origin.y)});
272
+ if (!local) {
273
+ return nil;
274
+ }
275
+ return [super hitTest:NSMakePoint(origin.x + local->x, origin.y + local->y)];
276
+ }
277
+
278
+ // Any tabIndex takes the focus, -1 too, as on the web: out of Tab order, but where a click or the
279
+ // arrow keys in a composite widget move it (focus-order.h).
280
+ - (BOOL)acceptsFirstResponder {
281
+ return _desktop.focusable.value_or(false) || _desktop.tabIndex.has_value();
282
+ }
283
+
284
+
285
+ // Whether the event AppKit is handling is a key's: a focus a key moved draws a ring and matches
286
+ // `:focus-visible`, which the engine learns from `focusVisible` on the focus event.
287
+ static BOOL focusFromKeyboard() {
288
+ NSEventType type = NSApp.currentEvent.type;
289
+ return type == NSEventTypeKeyDown || type == NSEventTypeKeyUp;
290
+ }
291
+
292
+ - (BOOL)becomeFirstResponder {
293
+ if (![super becomeFirstResponder]) {
294
+ return NO;
295
+ }
296
+ _focusVisible = focusFromKeyboard();
297
+ self.focusRingType = _focusVisible ? NSFocusRingTypeDefault : NSFocusRingTypeNone;
298
+ [self noteFocusRingMaskChanged];
299
+ if (_emitter) {
300
+ _emitter->dispatchEvent("focus", folly::dynamic::object("target", (int)_reactTag)("focusVisible", (bool)_focusVisible));
301
+ }
302
+ return YES;
303
+ }
304
+
305
+ - (BOOL)resignFirstResponder {
306
+ if (![super resignFirstResponder]) {
307
+ return NO;
308
+ }
309
+ _focusVisible = NO;
310
+ [self noteFocusRingMaskChanged];
311
+ if (_emitter) {
312
+ _emitter->dispatchEvent("blur", folly::dynamic::object("target", (int)_reactTag));
313
+ }
314
+ return YES;
315
+ }
316
+
317
+ // AppKit's focus ring, in the view's shape, while the focus came from the keyboard. An app that
318
+ // styles `outline` draws its own.
319
+ - (void)drawFocusRingMask {
320
+ auto viewProps = std::dynamic_pointer_cast<const ViewProps>(_props);
321
+ CGFloat radius = viewProps ? viewProps->resolveBorderMetrics(_layout).borderRadii.topLeft.horizontal : 0;
322
+ [[NSBezierPath bezierPathWithRoundedRect:self.bounds xRadius:radius yRadius:radius] fill];
323
+ }
324
+
325
+ - (NSRect)focusRingMaskBounds {
326
+ auto viewProps = std::dynamic_pointer_cast<const ViewProps>(_props);
327
+ BOOL ownOutline = viewProps && (viewProps->outlineWidth > 0 || viewProps->outlineColor);
328
+ return _focusVisible && !ownOutline ? self.bounds : NSZeroRect;
329
+ }
330
+
331
+ - (EventEmitter::Shared)eventEmitter {
332
+ return _emitter;
333
+ }
334
+
335
+ - (Props::Shared)props {
336
+ return _props;
337
+ }
338
+
339
+ - (State::Shared)state {
340
+ return _state;
341
+ }
342
+
343
+ - (const LayoutMetrics &)layoutMetrics {
344
+ return _layout;
345
+ }
346
+
347
+ - (const ngn::DesktopProps &)desktopProps {
348
+ return _desktop;
349
+ }
350
+
351
+ - (NSView *)contentContainer {
352
+ return self;
353
+ }
354
+
355
+ - (NSResponder *)keyboardResponder {
356
+ return self;
357
+ }
358
+
359
+ #pragma mark Accessibility
360
+
361
+ // React Native's accessibility props, mapped in the core (accessibility.h).
362
+ - (ngn::AxInfo)axInfo {
363
+ auto viewProps = std::dynamic_pointer_cast<const ViewProps>(_props);
364
+ if (!viewProps) {
365
+ return ngn::AxInfo{};
366
+ }
367
+ if ([_componentName isEqualToString:@"Paragraph"]) {
368
+ return ngn::paragraphAccessibilityInfo(*viewProps, ngn::paragraphText(_state));
369
+ }
370
+ return ngn::accessibilityInfo(*viewProps);
371
+ }
372
+
373
+ - (BOOL)isAccessibilityElement {
374
+ return [self axInfo].element;
375
+ }
376
+
377
+ - (NSAccessibilityRole)accessibilityRole {
378
+ return nsRole([self axInfo].role);
379
+ }
380
+
381
+ - (NSAccessibilitySubrole)accessibilitySubrole {
382
+ return nsSubrole([self axInfo].subrole);
383
+ }
384
+
385
+ - (NSString *)accessibilityRoleDescription {
386
+ auto info = [self axInfo];
387
+ // A role AppKit has (a heading from macOS 26) is spoken by AppKit's own name for it.
388
+ if (!info.roleDescription.empty() && !(info.role == ngn::AxRole::Heading && nativeRole(info.role))) {
389
+ return nsString(info.roleDescription);
390
+ }
391
+ return NSAccessibilityRoleDescription(nsRole(info.role), nsSubrole(info.subrole));
392
+ }
393
+
394
+ - (NSString *)accessibilityLabel {
395
+ auto info = [self axInfo];
396
+ if (info.label.empty() && info.hidesChildren && ![_componentName isEqualToString:@"Paragraph"]) {
397
+ // Read as one element with no label of its own: named by the text inside it, as iOS does.
398
+ NSMutableArray<NSString *> *texts = [NSMutableArray array];
399
+ [self collectTextInto:texts];
400
+ return texts.count > 0 ? [texts componentsJoinedByString:@" "] : nil;
401
+ }
402
+ return info.label.empty() ? nil : nsString(info.label);
403
+ }
404
+
405
+ - (void)collectTextInto:(NSMutableArray<NSString *> *)texts {
406
+ for (NSView *child in [self contentContainer].subviews) {
407
+ if (![child isKindOfClass:NGNView.class] || child.hidden) {
408
+ continue;
409
+ }
410
+ NGNView *view = (NGNView *)child;
411
+ auto info = [view axInfo];
412
+ if (!info.label.empty()) {
413
+ [texts addObject:nsString(info.label)];
414
+ } else if ([view.componentName isEqualToString:@"Paragraph"]) {
415
+ auto text = ngn::paragraphText(view.state);
416
+ if (!text.empty()) {
417
+ [texts addObject:nsString(text)];
418
+ }
419
+ } else {
420
+ [view collectTextInto:texts];
421
+ }
422
+ }
423
+ }
424
+
425
+ // An element read as one has no elements inside it.
426
+ - (NSArray *)accessibilityChildren {
427
+ if ([self axInfo].hidesChildren) {
428
+ return @[];
429
+ }
430
+ return [super accessibilityChildren];
431
+ }
432
+
433
+ - (NSString *)accessibilityHelp {
434
+ auto info = [self axInfo];
435
+ return info.hint.empty() ? nil : nsString(info.hint);
436
+ }
437
+
438
+ - (id)accessibilityValue {
439
+ auto info = [self axInfo];
440
+ if (info.checked) {
441
+ return @(*info.checked);
442
+ }
443
+ return info.value.empty() ? nil : nsString(info.value);
444
+ }
445
+
446
+ // The heading level, which AppKit names from macOS 26 and has no property for.
447
+ #pragma clang diagnostic push
448
+ #pragma clang diagnostic ignored "-Wdeprecated-declarations"
449
+ - (NSArray<NSAccessibilityAttributeName> *)accessibilityAttributeNames {
450
+ NSArray *names = [super accessibilityAttributeNames];
451
+ auto info = [self axInfo];
452
+ if (info.level && nativeRole(info.role) && info.role == ngn::AxRole::Heading) {
453
+ return [names arrayByAddingObject:@"AXHeadingLevel"];
454
+ }
455
+ return names;
456
+ }
457
+
458
+ - (id)accessibilityAttributeValue:(NSAccessibilityAttributeName)attribute {
459
+ if ([attribute isEqualToString:@"AXHeadingLevel"]) {
460
+ auto level = [self axInfo].level;
461
+ return level ? @(*level) : nil;
462
+ }
463
+ return [super accessibilityAttributeValue:attribute];
464
+ }
465
+ #pragma clang diagnostic pop
466
+
467
+ - (BOOL)isAccessibilityEnabled {
468
+ return ![self axInfo].disabled;
469
+ }
470
+
471
+ - (BOOL)isAccessibilitySelected {
472
+ return [self axInfo].selected;
473
+ }
474
+
475
+ - (BOOL)isAccessibilityExpanded {
476
+ return [self axInfo].expanded.value_or(false);
477
+ }
478
+
479
+ - (NSArray<NSAccessibilityCustomAction *> *)accessibilityCustomActions {
480
+ auto info = [self axInfo];
481
+ if (info.customActions.empty()) {
482
+ return nil;
483
+ }
484
+ NSMutableArray<NSAccessibilityCustomAction *> *actions = [NSMutableArray array];
485
+ __weak NGNView *weakSelf = self;
486
+ for (const auto &action : info.customActions) {
487
+ std::string name = action.name;
488
+ [actions addObject:[[NSAccessibilityCustomAction alloc] initWithName:nsString(action.label)
489
+ handler:^BOOL {
490
+ return [weakSelf sendAccessibilityAction:name];
491
+ }]];
492
+ }
493
+ return actions;
494
+ }
495
+
496
+ // Sends a declared action, as iOS does only to a view that listens for them.
497
+ - (BOOL)sendAccessibilityAction:(const std::string &)name {
498
+ auto viewProps = std::dynamic_pointer_cast<const ViewProps>(_props);
499
+ auto emitter = std::dynamic_pointer_cast<const ViewEventEmitter>(_emitter);
500
+ if (!viewProps || !viewProps->onAccessibilityAction || !emitter) {
501
+ return NO;
502
+ }
503
+ emitter->onAccessibilityAction(name);
504
+ return YES;
505
+ }
506
+
507
+ // One of AppKit's standard actions, as the core decides it reaches the app (accessibility.h).
508
+ - (BOOL)performAxVerb:(ngn::AxVerb)verb {
509
+ auto viewProps = std::dynamic_pointer_cast<const ViewProps>(_props);
510
+ auto emitter = std::dynamic_pointer_cast<const ViewEventEmitter>(_emitter);
511
+ if (!viewProps || !emitter) {
512
+ return NO;
513
+ }
514
+ auto dispatch = ngn::axDispatch(*viewProps, verb);
515
+ switch (dispatch.kind) {
516
+ case ngn::AxDispatch::Kind::None:
517
+ return NO;
518
+ case ngn::AxDispatch::Kind::Tap:
519
+ emitter->onAccessibilityTap();
520
+ return YES;
521
+ case ngn::AxDispatch::Kind::Escape:
522
+ emitter->onAccessibilityEscape();
523
+ return YES;
524
+ case ngn::AxDispatch::Kind::Action:
525
+ emitter->onAccessibilityAction(dispatch.action);
526
+ return YES;
527
+ case ngn::AxDispatch::Kind::Click:
528
+ return gViewInput != nullptr && gViewInput->activate(static_cast<SurfaceId>(_surfaceId), static_cast<Tag>(_reactTag));
529
+ }
530
+ return NO;
531
+ }
532
+
533
+ - (BOOL)accessibilityPerformPress {
534
+ return [self performAxVerb:ngn::AxVerb::Press];
535
+ }
536
+
537
+ - (BOOL)accessibilityPerformIncrement {
538
+ return [self performAxVerb:ngn::AxVerb::Increment];
539
+ }
540
+
541
+ - (BOOL)accessibilityPerformDecrement {
542
+ return [self performAxVerb:ngn::AxVerb::Decrement];
543
+ }
544
+
545
+ - (BOOL)accessibilityPerformCancel {
546
+ return [self performAxVerb:ngn::AxVerb::Cancel];
547
+ }
548
+
549
+ // AppKit lists an action for every one of these the class implements; a view offers only those
550
+ // that mean something for it. A focusable view is pressed as a control is.
551
+ - (BOOL)isAccessibilitySelectorAllowed:(SEL)selector {
552
+ if (selector == @selector(accessibilityPerformPress)) {
553
+ return [self axInfo].offersPress || [self acceptsFirstResponder];
554
+ }
555
+ if (selector == @selector(accessibilityPerformIncrement) || selector == @selector(accessibilityPerformDecrement)) {
556
+ return [self axInfo].offersIncrement;
557
+ }
558
+ if (selector == @selector(accessibilityPerformCancel)) {
559
+ return [self axInfo].offersCancel;
560
+ }
561
+ // Only a view that expands says whether it is expanded.
562
+ if (selector == @selector(isAccessibilityExpanded)) {
563
+ return [self axInfo].expanded.has_value();
564
+ }
565
+ return [super isAccessibilitySelectorAllowed:selector];
566
+ }
567
+
568
+ // Space and Return press a focused view, as they press a focused AppKit control. A default button
569
+ // takes Return first, as AppKit's own key equivalents do.
570
+ - (void)keyDown:(NSEvent *)event {
571
+ NSEventModifierFlags modifiers = event.modifierFlags & (NSEventModifierFlagCommand | NSEventModifierFlagControl |
572
+ NSEventModifierFlagOption);
573
+ NSString *key = event.charactersIgnoringModifiers;
574
+ BOOL activates = [key isEqualToString:@" "] || [key isEqualToString:@"\r"];
575
+ if (modifiers == 0 && activates && !event.isARepeat && self.window.firstResponder == self &&
576
+ [self performAxVerb:ngn::AxVerb::Press]) {
577
+ return;
578
+ }
579
+ [super keyDown:event];
580
+ }
581
+
582
+ - (void)updateProps:(const Props::Shared &)props {
583
+ _props = props;
584
+ [self applyVisuals];
585
+ if ([_componentName isEqualToString:@"Paragraph"]) {
586
+ [self setNeedsDisplay:YES];
587
+ }
588
+ }
589
+
590
+ - (void)updateLayout:(const LayoutMetrics &)metrics {
591
+ _layout = metrics;
592
+ const auto &f = metrics.frame;
593
+ self.frame = NSMakeRect(f.origin.x + _swipeOffset, f.origin.y, f.size.width, f.size.height);
594
+ [self updateHidden];
595
+ [self applyVisuals];
596
+ [self setNeedsDisplay:YES];
597
+ }
598
+
599
+ - (void)updateHidden {
600
+ self.hidden = _layout.displayType == DisplayType::None || (_covered && !_swipeShown);
601
+ }
602
+
603
+ - (void)setCovered:(BOOL)covered {
604
+ _covered = covered;
605
+ [self updateHidden];
606
+ }
607
+
608
+ - (void)setSwipeShown:(BOOL)swipeShown {
609
+ _swipeShown = swipeShown;
610
+ [self updateHidden];
611
+ }
612
+
613
+ - (void)setSwipeOffset:(CGFloat)swipeOffset {
614
+ _swipeOffset = swipeOffset;
615
+ [self setFrameOrigin:NSMakePoint(_layout.frame.origin.x + swipeOffset, _layout.frame.origin.y)];
616
+ }
617
+
618
+ - (void)setSwipeOpacity:(CGFloat)swipeOpacity {
619
+ _swipeOpacity = swipeOpacity;
620
+ [self applyVisuals];
621
+ }
622
+
623
+ - (void)updateState:(const State::Shared &)state {
624
+ _state = state;
625
+ [self setNeedsDisplay:YES];
626
+ }
627
+
628
+ - (void)updateEventEmitter:(const EventEmitter::Shared &)emitter {
629
+ _emitter = emitter;
630
+ }
631
+
632
+ - (void)updateDesktopProps:(const ngn::DesktopProps &)props {
633
+ // Kept for the Tab-order walk; focusable already decides acceptsFirstResponder.
634
+ _desktop = props;
635
+ }
636
+
637
+ - (void)handleCommand:(const std::string &)name args:(const folly::dynamic &)args {
638
+ }
639
+
640
+ - (void)applyVisuals {
641
+ auto viewProps = std::dynamic_pointer_cast<const ViewProps>(_props);
642
+ if (!viewProps) {
643
+ return;
644
+ }
645
+ CALayer *layer = self.layer;
646
+ self.alphaValue = viewProps->opacity * _swipeOpacity;
647
+ auto box = ngn::viewBox(*viewProps, _layout);
648
+ layer.backgroundColor = box.background ? cgColor(*box.background) : nil;
649
+ layer.cornerRadius = box.cornerRadius;
650
+ layer.borderWidth = box.borderWidth;
651
+ layer.borderColor = box.borderColor ? cgColor(*box.borderColor) : nil;
652
+ layer.masksToBounds = viewProps->yogaStyle.overflow() != facebook::yoga::Overflow::Visible;
653
+ layer.mask = box.clip ? shapeLayer(*box.clip, NO, self.bounds) : nil;
654
+ [self applyShadows:box.shadows];
655
+ // Its transform, about its centre on a layer anchored at its corner (view-transform.h).
656
+ CATransform3D transform = CATransform3DIdentity;
657
+ if (auto matrix = ngn::layerTransform(*viewProps, _layout)) {
658
+ const auto &m = matrix->matrix;
659
+ transform = CATransform3D{m[0], m[1], m[2], m[3], m[4], m[5], m[6], m[7], m[8], m[9], m[10], m[11], m[12], m[13], m[14], m[15]};
660
+ }
661
+ if (!CATransform3DEqualToTransform(_transform, transform)) {
662
+ _transform = transform;
663
+ if ([layer isKindOfClass:NGNViewLayer.class]) {
664
+ ((NGNViewLayer *)layer).viewTransform = transform;
665
+ } else {
666
+ layer.transform = transform;
667
+ }
668
+ }
669
+ if (box.drawn || _boxDrawn) {
670
+ [self setNeedsDisplay:YES];
671
+ }
672
+ _boxDrawn = box.drawn;
673
+ }
674
+
675
+ // Each box shadow as a layer under the children, as RCTViewComponentView adds them.
676
+ - (void)applyShadows:(const std::vector<ngn::BoxShadowLayer> &)shadows {
677
+ for (CALayer *old in _shadowLayers) {
678
+ [old removeFromSuperlayer];
679
+ }
680
+ [_shadowLayers removeAllObjects];
681
+ if (shadows.empty()) {
682
+ return;
683
+ }
684
+ if (_shadowLayers == nil) {
685
+ _shadowLayers = [NSMutableArray array];
686
+ }
687
+ for (const auto &shadow : shadows) {
688
+ CALayer *layer = [CALayer layer];
689
+ layer.frame = self.bounds;
690
+ layer.zPosition = -1000;
691
+ layer.shadowColor = cgColor(shadow.argb);
692
+ layer.shadowOpacity = 1;
693
+ layer.shadowOffset = CGSizeZero;
694
+ layer.shadowRadius = shadow.radius;
695
+ CGPathRef path = NGNCreatePath(shadow.shadowPath);
696
+ layer.shadowPath = path;
697
+ CGPathRelease(path);
698
+ layer.mask = shapeLayer(shadow.mask, shadow.maskEvenOdd, self.bounds);
699
+ [self.layer addSublayer:layer];
700
+ [_shadowLayers addObject:layer];
701
+ }
702
+ }
703
+
704
+ - (void)drawRect:(NSRect)dirtyRect {
705
+ auto viewProps = std::dynamic_pointer_cast<const ViewProps>(_props);
706
+ if (_boxDrawn && viewProps) {
707
+ CGContextRef context = NSGraphicsContext.currentContext.CGContext;
708
+ CGFloat scale = self.window ? self.window.backingScaleFactor : NSScreen.mainScreen.backingScaleFactor;
709
+ auto canvas = NGNMakeCGCanvas(context, self.bounds.size, scale, nil);
710
+ CGContextSaveGState(context);
711
+ ngn::drawViewBox(*viewProps, _layout, *canvas);
712
+ CGContextRestoreGState(context);
713
+ }
714
+ if (![_componentName isEqualToString:@"Paragraph"] || !_state) {
715
+ return;
716
+ }
717
+ auto state = std::static_pointer_cast<const ConcreteState<ParagraphState>>(_state);
718
+ const auto &data = state->getData();
719
+ const auto &insets = _layout.contentInsets;
720
+ CGFloat width = _layout.frame.size.width - insets.left - insets.right;
721
+ // A hair of slack, so the width Yoga rounded to the pixel lays out the same lines as measure.
722
+ auto layout = ngn::layoutText(data.attributedString, data.paragraphAttributes, width + 0.5);
723
+ ngn::drawText(layout, NSGraphicsContext.currentContext.CGContext, CGPointMake(insets.left, insets.top), width);
724
+ }
725
+
726
+ @end
727
+
728
+ #pragma mark - NGNTextInputView
729
+
730
+ using ngn::DesktopTextInputProps;
731
+
732
+ namespace {
733
+
734
+ // The font a TextInput's text attributes resolve to, as its Paragraph would draw them.
735
+ NSFont *inputFont(const DesktopTextInputProps &p) {
736
+ auto attrs = p.getEffectiveTextAttributes(1);
737
+ AttributedString probe;
738
+ probe.appendFragment(AttributedString::Fragment{.string = "x", .textAttributes = attrs, .parentShadowView = {}});
739
+ CFAttributedStringRef s = ngn::makeAttributedString(probe);
740
+ NSFont *font = (__bridge NSFont *)CFAttributedStringGetAttribute(s, 0, kCTFontAttributeName, nullptr);
741
+ CFRelease(s);
742
+ return font;
743
+ }
744
+
745
+ // The `selection` prop, when it is new in this update: React Native iOS applies it only then.
746
+ std::optional<NSRange> newSelection(const Props::Shared &old, const DesktopTextInputProps &p) {
747
+ if (!p.selection) {
748
+ return std::nullopt;
749
+ }
750
+ auto before = std::dynamic_pointer_cast<const DesktopTextInputProps>(old);
751
+ if (before && before->selection && before->selection->start == p.selection->start &&
752
+ before->selection->end == p.selection->end) {
753
+ return std::nullopt;
754
+ }
755
+ int start = std::max(0, std::min(p.selection->start, p.selection->end));
756
+ int end = std::max(p.selection->start, p.selection->end);
757
+ return NSMakeRange(start, end - start);
758
+ }
759
+
760
+ } // namespace
761
+
762
+ @implementation NGNTextInputView {
763
+ NGNTextField *_box;
764
+ int _eventCount;
765
+ BOOL _settingText;
766
+ }
767
+
768
+ - (instancetype)initWithShadowView:(const ShadowView &)view {
769
+ if ((self = [super initWithShadowView:view])) {
770
+ _box = [[NGNTextField alloc] initWithFrame:NSZeroRect];
771
+ NSTextField *field = _box.control;
772
+ field.bezeled = NO;
773
+ field.bordered = NO;
774
+ field.drawsBackground = NO;
775
+ field.focusRingType = NSFocusRingTypeNone;
776
+ field.usesSingleLineMode = YES;
777
+ field.cell.scrollable = YES;
778
+ field.cell.wraps = NO;
779
+ field.delegate = self;
780
+ __weak NGNTextInputView *weakSelf = self;
781
+ _box.focused = ^{
782
+ NGNTextInputView *strong = weakSelf;
783
+ if (auto e = [strong inputEmitter]) {
784
+ e->onFocus([strong metrics]);
785
+ }
786
+ };
787
+ // Secure entry is a field of its own class in AppKit; the box swaps it as the prop changes.
788
+ auto first = std::dynamic_pointer_cast<const DesktopTextInputProps>(view.props);
789
+ _box.secure = first && first->traits.secureTextEntry;
790
+ _box.autoFocus = first && first->autoFocus;
791
+ [self addSubview:_box];
792
+ }
793
+ return self;
794
+ }
795
+
796
+ - (void)dealloc {
797
+ [NSNotificationCenter.defaultCenter removeObserver:self];
798
+ }
799
+
800
+ - (void)updateProps:(const Props::Shared &)props {
801
+ Props::Shared old = self.props;
802
+ [super updateProps:props];
803
+ auto p = std::dynamic_pointer_cast<const DesktopTextInputProps>(props);
804
+ if (!p) {
805
+ return;
806
+ }
807
+ _box.secure = p->traits.secureTextEntry;
808
+ NSTextField *field = _box.control;
809
+ auto attrs = p->getEffectiveTextAttributes(1);
810
+ field.font = inputFont(*p);
811
+ field.textColor = attrs.foregroundColor ? nsColor(attrs.foregroundColor) : NSColor.textColor;
812
+ [_box setPlaceholder:nsString(p->placeholder) color:p->placeholderTextColor ? nsColor(p->placeholderTextColor) : nil];
813
+ field.editable = p->editable && !p->readOnly;
814
+ [_box applyOptions:ngn::textInputOptions(*p)];
815
+ // The text prop wins only when it is not older than what the field has sent (React Native iOS's
816
+ // rule), and never while an input method is composing.
817
+ if (ngn::controlledTextIsCurrent(p->mostRecentEventCount, _eventCount, [self composing]) && !p->text.empty()) {
818
+ NSString *text = nsString(p->text);
819
+ if (![field.stringValue isEqualToString:text]) {
820
+ field.stringValue = text;
821
+ }
822
+ }
823
+ if (auto range = newSelection(old, *p)) {
824
+ [_box selectRange:*range];
825
+ }
826
+ }
827
+
828
+ - (void)updateLayout:(const LayoutMetrics &)metrics {
829
+ [super updateLayout:metrics];
830
+ const auto &i = metrics.contentInsets;
831
+ NSRect content = NSMakeRect(
832
+ i.left, i.top, metrics.frame.size.width - i.left - i.right, metrics.frame.size.height - i.top - i.bottom);
833
+ // The single line, centred vertically in the content box.
834
+ CGFloat h = std::min<CGFloat>(content.size.height, _box.control.intrinsicContentSize.height);
835
+ _box.frame = NSMakeRect(content.origin.x, content.origin.y + (content.size.height - h) / 2, content.size.width, h);
836
+ }
837
+
838
+ - (NSResponder *)keyboardResponder {
839
+ return _box.control;
840
+ }
841
+
842
+ - (BOOL)composing {
843
+ NSText *editor = _box.currentEditor;
844
+ return [editor isKindOfClass:NSTextView.class] && [(NSTextView *)editor hasMarkedText];
845
+ }
846
+
847
+ - (TextInputEventEmitter::Metrics)metrics {
848
+ NSString *value = _box.stringValue;
849
+ NSRange sel = _box.currentEditor ? _box.currentEditor.selectedRange : NSMakeRange(value.length, 0);
850
+ return TextInputEventEmitter::Metrics{
851
+ .text = std::string(value.UTF8String),
852
+ .selectionRange = {.location = (int)sel.location, .length = (int)sel.length},
853
+ .eventCount = _eventCount,
854
+ .target = (Tag)self.reactTag,
855
+ };
856
+ }
857
+
858
+ - (std::shared_ptr<const TextInputEventEmitter>)inputEmitter {
859
+ return std::static_pointer_cast<const TextInputEventEmitter>(self.eventEmitter);
860
+ }
861
+
862
+ - (void)controlTextDidChange:(NSNotification *)note {
863
+ if (_settingText) {
864
+ return;
865
+ }
866
+ _eventCount++;
867
+ if (auto e = [self inputEmitter]) {
868
+ e->onChange([self metrics]);
869
+ }
870
+ }
871
+
872
+ - (void)controlTextDidBeginEditing:(NSNotification *)note {
873
+ NSTextView *editor = note.userInfo[@"NSFieldEditor"];
874
+ if (editor != nil) {
875
+ [NSNotificationCenter.defaultCenter addObserver:self
876
+ selector:@selector(selectionDidChange:)
877
+ name:NSTextViewDidChangeSelectionNotification
878
+ object:editor];
879
+ }
880
+ }
881
+
882
+ - (void)controlTextDidEndEditing:(NSNotification *)note {
883
+ [NSNotificationCenter.defaultCenter removeObserver:self name:NSTextViewDidChangeSelectionNotification object:nil];
884
+ if (_box.swapping) {
885
+ return; // secure entry changing hands the keyboard from one control to the other
886
+ }
887
+ if (auto e = [self inputEmitter]) {
888
+ e->onEndEditing([self metrics]);
889
+ e->onBlur([self metrics]);
890
+ }
891
+ }
892
+
893
+ - (void)selectionDidChange:(NSNotification *)note {
894
+ if (auto e = [self inputEmitter]) {
895
+ e->onSelectionChange([self metrics]);
896
+ }
897
+ }
898
+
899
+ - (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)selector {
900
+ if (selector == @selector(insertNewline:)) {
901
+ if (auto e = [self inputEmitter]) {
902
+ e->onSubmitEditing([self metrics]);
903
+ }
904
+ return YES;
905
+ }
906
+ return NO;
907
+ }
908
+
909
+ - (void)handleCommand:(const std::string &)name args:(const folly::dynamic &)args {
910
+ if (name == "focus") {
911
+ // The box reports the focus as the field takes the keyboard.
912
+ [self.window makeFirstResponder:_box.control];
913
+ } else if (name == "blur") {
914
+ [self.window makeFirstResponder:nil];
915
+ } else if (name == "setTextAndSelection" && args.isArray() && args.size() >= 4) {
916
+ int count = (int)args[0].asInt();
917
+ if (count < _eventCount) {
918
+ return; // stale: the field has moved on since JavaScript sent this
919
+ }
920
+ NSTextField *field = _box.control;
921
+ if (args[1].isString() && ![self composing]) {
922
+ NSString *text = nsString(args[1].asString());
923
+ if (![field.stringValue isEqualToString:text]) {
924
+ _settingText = YES;
925
+ field.stringValue = text;
926
+ _settingText = NO;
927
+ }
928
+ }
929
+ if (args[2].isNumber() && args[3].isNumber() && field.currentEditor) {
930
+ NSInteger start = args[2].asInt(), end = args[3].asInt();
931
+ if (start >= 0 && end >= start && (NSUInteger)end <= field.stringValue.length) {
932
+ field.currentEditor.selectedRange = NSMakeRange(start, end - start);
933
+ }
934
+ }
935
+ }
936
+ }
937
+
938
+ @end
939
+
940
+ #pragma mark - NGNMultilineTextInputView
941
+
942
+ // A multiline TextInput: an NSTextView, which wraps, scrolls and takes Return as a new line.
943
+ @interface NGNMultilineTextInputView : NGNView <NSTextViewDelegate>
944
+ @end
945
+
946
+ @implementation NGNMultilineTextInputView {
947
+ NSScrollView *_scroll;
948
+ NGNTextView *_text;
949
+ int _eventCount;
950
+ BOOL _settingText;
951
+ }
952
+
953
+ - (instancetype)initWithShadowView:(const ShadowView &)view {
954
+ if ((self = [super initWithShadowView:view])) {
955
+ _scroll = [[NSScrollView alloc] initWithFrame:NSZeroRect];
956
+ _scroll.drawsBackground = NO;
957
+ _scroll.hasVerticalScroller = YES;
958
+ _scroll.autohidesScrollers = YES;
959
+ _text = [[NGNTextView alloc] initWithFrame:NSZeroRect];
960
+ _text.drawsBackground = NO;
961
+ _text.richText = NO;
962
+ _text.allowsUndo = YES;
963
+ _text.verticallyResizable = YES;
964
+ _text.horizontallyResizable = NO;
965
+ _text.autoresizingMask = NSViewWidthSizable;
966
+ _text.textContainer.widthTracksTextView = YES;
967
+ _text.textContainerInset = NSZeroSize;
968
+ _text.textContainer.lineFragmentPadding = 0;
969
+ _text.delegate = self;
970
+ __weak NGNMultilineTextInputView *weakSelf = self;
971
+ _text.focused = ^{
972
+ NGNMultilineTextInputView *strong = weakSelf;
973
+ if (auto e = [strong inputEmitter]) {
974
+ e->onFocus([strong metrics]);
975
+ }
976
+ };
977
+ auto first = std::dynamic_pointer_cast<const DesktopTextInputProps>(view.props);
978
+ _text.autoFocus = first && first->autoFocus;
979
+ _scroll.documentView = _text;
980
+ [self addSubview:_scroll];
981
+ }
982
+ return self;
983
+ }
984
+
985
+ - (void)updateProps:(const Props::Shared &)props {
986
+ Props::Shared old = self.props;
987
+ [super updateProps:props];
988
+ auto p = std::dynamic_pointer_cast<const DesktopTextInputProps>(props);
989
+ if (!p) {
990
+ return;
991
+ }
992
+ auto attrs = p->getEffectiveTextAttributes(1);
993
+ _text.font = inputFont(*p);
994
+ _text.textColor = attrs.foregroundColor ? nsColor(attrs.foregroundColor) : NSColor.textColor;
995
+ [_text setPlaceholder:nsString(p->placeholder) color:p->placeholderTextColor ? nsColor(p->placeholderTextColor) : nil];
996
+ _text.editable = p->editable && !p->readOnly;
997
+ [_text applyOptions:ngn::textInputOptions(*p)];
998
+ if (ngn::controlledTextIsCurrent(p->mostRecentEventCount, _eventCount, _text.hasMarkedText) && !p->text.empty()) {
999
+ NSString *text = nsString(p->text);
1000
+ if (![_text.string isEqualToString:text]) {
1001
+ _settingText = YES;
1002
+ _text.string = text;
1003
+ _settingText = NO;
1004
+ }
1005
+ }
1006
+ if (auto range = newSelection(old, *p)) {
1007
+ [_text selectRange:*range];
1008
+ }
1009
+ }
1010
+
1011
+ - (void)updateLayout:(const LayoutMetrics &)metrics {
1012
+ [super updateLayout:metrics];
1013
+ const auto &i = metrics.contentInsets;
1014
+ _scroll.frame = NSMakeRect(
1015
+ i.left, i.top, metrics.frame.size.width - i.left - i.right, metrics.frame.size.height - i.top - i.bottom);
1016
+ _text.frame = NSMakeRect(0, 0, _scroll.contentSize.width, std::max(_text.frame.size.height, _scroll.contentSize.height));
1017
+ }
1018
+
1019
+ - (NSResponder *)keyboardResponder {
1020
+ return _text;
1021
+ }
1022
+
1023
+ - (TextInputEventEmitter::Metrics)metrics {
1024
+ NSRange sel = _text.selectedRange;
1025
+ return TextInputEventEmitter::Metrics{
1026
+ .text = std::string(_text.string.UTF8String),
1027
+ .selectionRange = {.location = (int)sel.location, .length = (int)sel.length},
1028
+ .eventCount = _eventCount,
1029
+ .target = (Tag)self.reactTag,
1030
+ };
1031
+ }
1032
+
1033
+ - (std::shared_ptr<const TextInputEventEmitter>)inputEmitter {
1034
+ return std::static_pointer_cast<const TextInputEventEmitter>(self.eventEmitter);
1035
+ }
1036
+
1037
+ - (void)textDidChange:(NSNotification *)note {
1038
+ if (_settingText) {
1039
+ return;
1040
+ }
1041
+ _eventCount++;
1042
+ if (auto e = [self inputEmitter]) {
1043
+ e->onChange([self metrics]);
1044
+ }
1045
+ }
1046
+
1047
+ - (void)textDidEndEditing:(NSNotification *)note {
1048
+ if (auto e = [self inputEmitter]) {
1049
+ e->onEndEditing([self metrics]);
1050
+ e->onBlur([self metrics]);
1051
+ }
1052
+ }
1053
+
1054
+ - (void)textViewDidChangeSelection:(NSNotification *)note {
1055
+ if (auto e = [self inputEmitter]) {
1056
+ e->onSelectionChange([self metrics]);
1057
+ }
1058
+ }
1059
+
1060
+ - (NSDictionary<NSTextCheckingOptionKey, id> *)textView:(NSTextView *)view
1061
+ willCheckTextInRange:(NSRange)range
1062
+ options:(NSDictionary<NSTextCheckingOptionKey, id> *)options
1063
+ types:(NSTextCheckingTypes *)checkingTypes {
1064
+ auto p = std::dynamic_pointer_cast<const DesktopTextInputProps>(self.props);
1065
+ return p ? NGNTextCheckingOptions(options, ngn::textInputOptions(*p)) : options;
1066
+ }
1067
+
1068
+ - (void)handleCommand:(const std::string &)name args:(const folly::dynamic &)args {
1069
+ if (name == "focus") {
1070
+ [self.window makeFirstResponder:_text];
1071
+ } else if (name == "blur") {
1072
+ [self.window makeFirstResponder:nil];
1073
+ } else if (name == "setTextAndSelection" && args.isArray() && args.size() >= 4) {
1074
+ if ((int)args[0].asInt() < _eventCount) {
1075
+ return;
1076
+ }
1077
+ if (args[1].isString() && !_text.hasMarkedText) {
1078
+ NSString *text = nsString(args[1].asString());
1079
+ if (![_text.string isEqualToString:text]) {
1080
+ _settingText = YES;
1081
+ _text.string = text;
1082
+ _settingText = NO;
1083
+ }
1084
+ }
1085
+ if (args[2].isNumber() && args[3].isNumber()) {
1086
+ NSInteger start = args[2].asInt(), end = args[3].asInt();
1087
+ if (start >= 0 && end >= start && (NSUInteger)end <= _text.string.length) {
1088
+ _text.selectedRange = NSMakeRange(start, end - start);
1089
+ }
1090
+ }
1091
+ }
1092
+ }
1093
+
1094
+ @end
1095
+
1096
+ // The libraries' views (component-view.h), by component name. Filled as the binary loads, before
1097
+ // anything mounts, and read on the UI thread after.
1098
+ static NSMutableDictionary<NSString *, Class> *libraryViews() {
1099
+ static NSMutableDictionary<NSString *, Class> *views = [NSMutableDictionary dictionary];
1100
+ return views;
1101
+ }
1102
+
1103
+ void NGNRegisterComponentView(NSString *componentName, Class viewClass) {
1104
+ if (![viewClass isSubclassOfClass:NGNView.class]) {
1105
+ NSLog(@"[ngn] %@ is not an NGNView, so %@ mounts as a plain view", viewClass, componentName);
1106
+ return;
1107
+ }
1108
+ libraryViews()[componentName] = viewClass;
1109
+ }
1110
+
1111
+ NGNView *NGNMakeView(const ShadowView &view) {
1112
+ if (NGNView *control = NGNMakeControlView(view)) {
1113
+ return control;
1114
+ }
1115
+ std::string_view name = view.componentName;
1116
+ if (name == "TextInput") {
1117
+ auto props = std::dynamic_pointer_cast<const DesktopTextInputProps>(view.props);
1118
+ if (props && props->multiline) {
1119
+ return [[NGNMultilineTextInputView alloc] initWithShadowView:view];
1120
+ }
1121
+ return [[NGNTextInputView alloc] initWithShadowView:view];
1122
+ }
1123
+ if (name == "Image") {
1124
+ return [[NGNImageView alloc] initWithShadowView:view];
1125
+ }
1126
+ if (name == "ModalHostView") {
1127
+ return [[NGNModalHostView alloc] initWithShadowView:view];
1128
+ }
1129
+ if (name == "RNSScreen") {
1130
+ return [[NGNPresentedScreenView alloc] initWithShadowView:view];
1131
+ }
1132
+ if (name == "RNSScreenStackHeaderConfig") {
1133
+ return [[NGNHeaderConfigView alloc] initWithShadowView:view];
1134
+ }
1135
+ if (name == "RNSScreenStackHeaderSubview") {
1136
+ return [[NGNHeaderSubviewView alloc] initWithShadowView:view];
1137
+ }
1138
+ if (name == "RNSSearchBar") {
1139
+ return [[NGNSearchBarView alloc] initWithShadowView:view];
1140
+ }
1141
+ if (name == "ScrollView") {
1142
+ return [[NGNScrollView alloc] initWithShadowView:view];
1143
+ }
1144
+ if (name == ngn::SplitViewComponentName) {
1145
+ return [[NGNSplitView alloc] initWithShadowView:view];
1146
+ }
1147
+ if (name == ngn::SidebarComponentName || name == ngn::SplitContentComponentName) {
1148
+ return [[NGNSplitPaneView alloc] initWithShadowView:view];
1149
+ }
1150
+ if (name == "RNSTabsHostIOS") {
1151
+ return [[NGNTabsHostView alloc] initWithShadowView:view];
1152
+ }
1153
+ if (name == "RNSTabsScreenIOS") {
1154
+ return [[NGNTabScreenView alloc] initWithShadowView:view];
1155
+ }
1156
+ if (name == ngn::SidebarSectionComponentName) {
1157
+ return [[NGNSidebarSectionView alloc] initWithShadowView:view];
1158
+ }
1159
+ if (name == ngn::SidebarItemComponentName) {
1160
+ return [[NGNSidebarItemView alloc] initWithShadowView:view];
1161
+ }
1162
+ if (name == ngn::SymbolComponentName) {
1163
+ return [[NGNSymbolView alloc] initWithShadowView:view];
1164
+ }
1165
+ if (name == ngn::GlassViewComponentName) {
1166
+ return [[NGNGlassView alloc] initWithShadowView:view];
1167
+ }
1168
+ // react-native-svg's: the svg draws its elements, whose own views are hidden.
1169
+ if (name == "RNSVGSvgView") {
1170
+ return [[NGNSvgView alloc] initWithShadowView:view];
1171
+ }
1172
+ if (name.starts_with("RNSVG")) {
1173
+ return [[NGNSvgElementView alloc] initWithShadowView:view];
1174
+ }
1175
+ if (name == ngn::MapComponentName) {
1176
+ return [[NGNMapView alloc] initWithShadowView:view];
1177
+ }
1178
+ if (name == ngn::CameraComponentName) {
1179
+ return [[NGNCameraView alloc] initWithShadowView:view];
1180
+ }
1181
+ if (name == ngn::VideoViewComponentName) {
1182
+ return [[NGNVideoView alloc] initWithShadowView:view];
1183
+ }
1184
+ if (name == ngn::AppleButtonComponentName) {
1185
+ return [[NGNAppleButtonView alloc] initWithShadowView:view];
1186
+ }
1187
+ if (NGNView *expoUI = NGNMakeExpoUIView(view)) {
1188
+ return expoUI;
1189
+ }
1190
+ if (name == ngn::ExpoImageComponentName) {
1191
+ return [[NGNExpoImageView alloc] initWithShadowView:view];
1192
+ }
1193
+ if (name == "RNCWebView") {
1194
+ return [[NGNWebView alloc] initWithShadowView:view];
1195
+ }
1196
+ if (Class library = libraryViews()[@(view.componentName)]) {
1197
+ return [[library alloc] initWithShadowView:view];
1198
+ }
1199
+ return [[NGNView alloc] initWithShadowView:view];
1200
+ }