@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.
- package/LICENSE +21 -0
- package/README.md +52 -0
- package/app.plugin.cjs +17 -0
- package/bin/app-config.mjs +168 -0
- package/bin/autolink.mjs +224 -0
- package/bin/cli.mjs +158 -0
- package/bin/host.mjs +427 -0
- package/bin/ng-native-desktop.mjs +4 -0
- package/bin/package.mjs +971 -0
- package/bin/plist.mjs +68 -0
- package/bin/prebuilt.mjs +328 -0
- package/bin/toolchain.mjs +192 -0
- package/native/CMakeLists.txt +277 -0
- package/native/appkit/CMakeLists.txt +130 -0
- package/native/appkit/address-search.h +26 -0
- package/native/appkit/address-search.mm +277 -0
- package/native/appkit/animation-frames.h +14 -0
- package/native/appkit/animation-frames.mm +106 -0
- package/native/appkit/app-info.h +12 -0
- package/native/appkit/app-info.mm +98 -0
- package/native/appkit/app-updater.mm +128 -0
- package/native/appkit/app-windows.h +81 -0
- package/native/appkit/app-windows.mm +318 -0
- package/native/appkit/appkit-backend.h +73 -0
- package/native/appkit/appkit-backend.mm +276 -0
- package/native/appkit/apple-authentication.h +19 -0
- package/native/appkit/apple-authentication.mm +248 -0
- package/native/appkit/apple-button-view.h +10 -0
- package/native/appkit/apple-button-view.mm +37 -0
- package/native/appkit/apple-id-button.h +16 -0
- package/native/appkit/apple-id-button.mm +50 -0
- package/native/appkit/audio.h +16 -0
- package/native/appkit/audio.mm +275 -0
- package/native/appkit/battery.h +13 -0
- package/native/appkit/battery.mm +92 -0
- package/native/appkit/bookmarks.h +17 -0
- package/native/appkit/bookmarks.mm +145 -0
- package/native/appkit/calendar.h +25 -0
- package/native/appkit/calendar.mm +660 -0
- package/native/appkit/camera-sheet.h +59 -0
- package/native/appkit/camera-sheet.mm +344 -0
- package/native/appkit/camera-view.h +15 -0
- package/native/appkit/camera-view.mm +134 -0
- package/native/appkit/camera.h +61 -0
- package/native/appkit/camera.mm +496 -0
- package/native/appkit/cg-canvas.h +24 -0
- package/native/appkit/cg-canvas.mm +663 -0
- package/native/appkit/component-view.h +17 -0
- package/native/appkit/crypto.h +19 -0
- package/native/appkit/crypto.mm +78 -0
- package/native/appkit/desktop-expo.h +29 -0
- package/native/appkit/desktop-expo.mm +385 -0
- package/native/appkit/expo-image-drawing.h +46 -0
- package/native/appkit/expo-image-drawing.mm +131 -0
- package/native/appkit/expo-image-view.h +15 -0
- package/native/appkit/expo-image-view.mm +182 -0
- package/native/appkit/expo-ui-renderer.h +68 -0
- package/native/appkit/expo-ui-renderer.mm +101 -0
- package/native/appkit/expo-ui-view.h +26 -0
- package/native/appkit/expo-ui-view.mm +134 -0
- package/native/appkit/expo-ui.swift +1284 -0
- package/native/appkit/file-system.h +16 -0
- package/native/appkit/file-system.mm +140 -0
- package/native/appkit/fonts.h +12 -0
- package/native/appkit/fonts.mm +48 -0
- package/native/appkit/geocoder.h +19 -0
- package/native/appkit/geocoder.mm +101 -0
- package/native/appkit/glass-effect.h +22 -0
- package/native/appkit/glass-effect.mm +63 -0
- package/native/appkit/glass-view.h +8 -0
- package/native/appkit/glass-view.mm +65 -0
- package/native/appkit/header-toolbar.h +60 -0
- package/native/appkit/header-toolbar.mm +632 -0
- package/native/appkit/host-view.h +54 -0
- package/native/appkit/host-view.mm +1228 -0
- package/native/appkit/image-manipulator.h +14 -0
- package/native/appkit/image-manipulator.mm +191 -0
- package/native/appkit/image-request.h +22 -0
- package/native/appkit/image-request.mm +62 -0
- package/native/appkit/image-view.h +8 -0
- package/native/appkit/image-view.mm +142 -0
- package/native/appkit/input-replay.h +25 -0
- package/native/appkit/input-replay.mm +418 -0
- package/native/appkit/language-model.h +14 -0
- package/native/appkit/language-model.mm +99 -0
- package/native/appkit/language-model.swift +472 -0
- package/native/appkit/local-authentication.h +15 -0
- package/native/appkit/local-authentication.mm +133 -0
- package/native/appkit/location.h +16 -0
- package/native/appkit/location.mm +214 -0
- package/native/appkit/main.mm +1475 -0
- package/native/appkit/map-view.h +15 -0
- package/native/appkit/map-view.mm +109 -0
- package/native/appkit/maps.h +35 -0
- package/native/appkit/maps.mm +343 -0
- package/native/appkit/menu-bar.h +22 -0
- package/native/appkit/menu-bar.mm +208 -0
- package/native/appkit/modal-focus.h +16 -0
- package/native/appkit/modal-focus.mm +26 -0
- package/native/appkit/modal-host-view.h +79 -0
- package/native/appkit/modal-host-view.mm +442 -0
- package/native/appkit/native-controls.h +22 -0
- package/native/appkit/native-controls.mm +431 -0
- package/native/appkit/network-state.h +12 -0
- package/native/appkit/network-state.mm +64 -0
- package/native/appkit/network.h +14 -0
- package/native/appkit/network.mm +396 -0
- package/native/appkit/notifications.h +19 -0
- package/native/appkit/notifications.mm +309 -0
- package/native/appkit/photo-library.h +33 -0
- package/native/appkit/photo-library.mm +548 -0
- package/native/appkit/pointer-buttons.h +32 -0
- package/native/appkit/presentation-label.h +15 -0
- package/native/appkit/presentation-label.mm +12 -0
- package/native/appkit/presented-screen.h +19 -0
- package/native/appkit/presented-screen.mm +181 -0
- package/native/appkit/printing.h +42 -0
- package/native/appkit/printing.mm +393 -0
- package/native/appkit/push.h +19 -0
- package/native/appkit/push.mm +81 -0
- package/native/appkit/red-box.h +26 -0
- package/native/appkit/red-box.mm +387 -0
- package/native/appkit/screen-capture.h +21 -0
- package/native/appkit/screen-capture.mm +92 -0
- package/native/appkit/scroll-view.h +13 -0
- package/native/appkit/scroll-view.mm +251 -0
- package/native/appkit/scrollers.h +25 -0
- package/native/appkit/scrollers.mm +43 -0
- package/native/appkit/search-field.h +34 -0
- package/native/appkit/search-field.mm +291 -0
- package/native/appkit/search-toolbar-item.h +19 -0
- package/native/appkit/search-toolbar-item.mm +269 -0
- package/native/appkit/share-picker.h +34 -0
- package/native/appkit/share-picker.mm +121 -0
- package/native/appkit/split-view.h +77 -0
- package/native/appkit/split-view.mm +1206 -0
- package/native/appkit/store-review.h +13 -0
- package/native/appkit/store-review.mm +28 -0
- package/native/appkit/surface-view.h +45 -0
- package/native/appkit/surface-view.mm +562 -0
- package/native/appkit/svg-view.h +18 -0
- package/native/appkit/svg-view.mm +103 -0
- package/native/appkit/symbol-drawing.h +24 -0
- package/native/appkit/symbol-drawing.mm +117 -0
- package/native/appkit/symbol-view.h +8 -0
- package/native/appkit/symbol-view.mm +33 -0
- package/native/appkit/system-access.h +34 -0
- package/native/appkit/system-access.mm +210 -0
- package/native/appkit/system.h +24 -0
- package/native/appkit/system.mm +403 -0
- package/native/appkit/tab-walk.h +31 -0
- package/native/appkit/tab-walk.mm +64 -0
- package/native/appkit/test-launch.h +36 -0
- package/native/appkit/test-launch.mm +115 -0
- package/native/appkit/text-input-field.h +81 -0
- package/native/appkit/text-input-field.mm +525 -0
- package/native/appkit/text-layout.h +58 -0
- package/native/appkit/text-layout.mm +485 -0
- package/native/appkit/text-recognition.h +13 -0
- package/native/appkit/text-recognition.mm +102 -0
- package/native/appkit/tracking.h +13 -0
- package/native/appkit/tracking.mm +51 -0
- package/native/appkit/tray-and-dock.h +45 -0
- package/native/appkit/tray-and-dock.mm +130 -0
- package/native/appkit/undo.h +23 -0
- package/native/appkit/undo.mm +125 -0
- package/native/appkit/updates.h +17 -0
- package/native/appkit/updates.mm +71 -0
- package/native/appkit/video-view.h +10 -0
- package/native/appkit/video-view.mm +42 -0
- package/native/appkit/video.h +38 -0
- package/native/appkit/video.mm +404 -0
- package/native/appkit/web-browser.h +12 -0
- package/native/appkit/web-browser.mm +97 -0
- package/native/appkit/web-view-component.h +10 -0
- package/native/appkit/web-view-component.mm +62 -0
- package/native/appkit/web-view.h +31 -0
- package/native/appkit/web-view.mm +401 -0
- package/native/cmake/libraries/react-native-reanimated.cmake +45 -0
- package/native/cmake/libraries/react-native-worklets.cmake +46 -0
- package/native/cmake/libraries.cmake +109 -0
- package/native/cmake/linked-modules.cmake +112 -0
- package/native/cmake/react-native.cmake +175 -0
- package/native/cmake/runtime-dependencies.cmake +34 -0
- package/native/cmake/swift.cmake +43 -0
- package/native/cmake/third-party.cmake +74 -0
- package/native/core/include/ngn/absent-views.h +27 -0
- package/native/core/include/ngn/accessibility.h +140 -0
- package/native/core/include/ngn/address-search.h +69 -0
- package/native/core/include/ngn/animation-frames.h +39 -0
- package/native/core/include/ngn/app-info.h +52 -0
- package/native/core/include/ngn/app-menus.h +151 -0
- package/native/core/include/ngn/app-windows.h +181 -0
- package/native/core/include/ngn/apple-authentication.h +116 -0
- package/native/core/include/ngn/asset.h +28 -0
- package/native/core/include/ngn/audio.h +125 -0
- package/native/core/include/ngn/back-swipe.h +121 -0
- package/native/core/include/ngn/battery.h +48 -0
- package/native/core/include/ngn/bytes.h +59 -0
- package/native/core/include/ngn/calendar.h +180 -0
- package/native/core/include/ngn/camera.h +222 -0
- package/native/core/include/ngn/control-sizes.h +111 -0
- package/native/core/include/ngn/core-modules.h +108 -0
- package/native/core/include/ngn/crypto.h +38 -0
- package/native/core/include/ngn/default-menu.h +91 -0
- package/native/core/include/ngn/desktop-expo.h +193 -0
- package/native/core/include/ngn/desktop-modal.h +109 -0
- package/native/core/include/ngn/desktop-props.h +75 -0
- package/native/core/include/ngn/desktop-view-props.h +110 -0
- package/native/core/include/ngn/dev-server.h +33 -0
- package/native/core/include/ngn/dom-web-view.h +53 -0
- package/native/core/include/ngn/download.h +24 -0
- package/native/core/include/ngn/expo-image.h +192 -0
- package/native/core/include/ngn/expo-ui.h +133 -0
- package/native/core/include/ngn/file-system.h +274 -0
- package/native/core/include/ngn/focus-order.h +63 -0
- package/native/core/include/ngn/fonts.h +64 -0
- package/native/core/include/ngn/gestures.h +305 -0
- package/native/core/include/ngn/glass.h +67 -0
- package/native/core/include/ngn/header-bar.h +112 -0
- package/native/core/include/ngn/host-state.h +243 -0
- package/native/core/include/ngn/image-manipulator.h +70 -0
- package/native/core/include/ngn/input-dispatcher.h +211 -0
- package/native/core/include/ngn/input-script.h +56 -0
- package/native/core/include/ngn/input.h +112 -0
- package/native/core/include/ngn/key-value-store.h +41 -0
- package/native/core/include/ngn/language-model.h +69 -0
- package/native/core/include/ngn/launch-frame.h +47 -0
- package/native/core/include/ngn/launch-settings.h +98 -0
- package/native/core/include/ngn/layout-animations.h +24 -0
- package/native/core/include/ngn/library-components.h +13 -0
- package/native/core/include/ngn/library-glue.h +53 -0
- package/native/core/include/ngn/live-regions.h +54 -0
- package/native/core/include/ngn/local-authentication.h +74 -0
- package/native/core/include/ngn/location.h +89 -0
- package/native/core/include/ngn/maps.h +226 -0
- package/native/core/include/ngn/module-registry.h +51 -0
- package/native/core/include/ngn/mounting-backend.h +96 -0
- package/native/core/include/ngn/mounting-manager.h +155 -0
- package/native/core/include/ngn/native-controls.h +161 -0
- package/native/core/include/ngn/native-module.h +109 -0
- package/native/core/include/ngn/network-state.h +44 -0
- package/native/core/include/ngn/network.h +100 -0
- package/native/core/include/ngn/notifications.h +185 -0
- package/native/core/include/ngn/photo-library.h +134 -0
- package/native/core/include/ngn/printing.h +69 -0
- package/native/core/include/ngn/processes.h +114 -0
- package/native/core/include/ngn/red-box.h +119 -0
- package/native/core/include/ngn/reload-thread.h +258 -0
- package/native/core/include/ngn/runtime.h +163 -0
- package/native/core/include/ngn/safe-areas.h +82 -0
- package/native/core/include/ngn/screen-capture.h +35 -0
- package/native/core/include/ngn/screen-presentation.h +85 -0
- package/native/core/include/ngn/screen-stacks.h +80 -0
- package/native/core/include/ngn/scrollers.h +106 -0
- package/native/core/include/ngn/sharing.h +39 -0
- package/native/core/include/ngn/spawn-rules.h +78 -0
- package/native/core/include/ngn/splash-screen.h +41 -0
- package/native/core/include/ngn/split-view.h +270 -0
- package/native/core/include/ngn/sqlite.h +38 -0
- package/native/core/include/ngn/store-review.h +26 -0
- package/native/core/include/ngn/surface-book.h +101 -0
- package/native/core/include/ngn/surface-metrics.h +51 -0
- package/native/core/include/ngn/svg.h +434 -0
- package/native/core/include/ngn/symbol.h +90 -0
- package/native/core/include/ngn/system.h +102 -0
- package/native/core/include/ngn/tabs-host.h +171 -0
- package/native/core/include/ngn/text-input.h +134 -0
- package/native/core/include/ngn/text-measurer.h +38 -0
- package/native/core/include/ngn/text-recognition.h +55 -0
- package/native/core/include/ngn/tracking.h +34 -0
- package/native/core/include/ngn/tray-and-dock.h +107 -0
- package/native/core/include/ngn/undo.h +37 -0
- package/native/core/include/ngn/updates.h +253 -0
- package/native/core/include/ngn/video.h +126 -0
- package/native/core/include/ngn/view-box.h +126 -0
- package/native/core/include/ngn/view-transform.h +26 -0
- package/native/core/include/ngn/view-tree.h +85 -0
- package/native/core/include/ngn/web-browser.h +45 -0
- package/native/core/include/ngn/web-view.h +137 -0
- package/native/core/include/ngn/worklet-host.h +98 -0
- package/native/core/src/absent-views.cpp +41 -0
- package/native/core/src/accessibility.cpp +374 -0
- package/native/core/src/animation-frames.cpp +49 -0
- package/native/core/src/app-menus.cpp +359 -0
- package/native/core/src/app-windows.cpp +444 -0
- package/native/core/src/back-swipe.cpp +98 -0
- package/native/core/src/bytes.cpp +158 -0
- package/native/core/src/control-sizes.cpp +232 -0
- package/native/core/src/default-menu.cpp +96 -0
- package/native/core/src/desktop-modal.cpp +162 -0
- package/native/core/src/desktop-view-props.cpp +80 -0
- package/native/core/src/dev-server-helper.cpp +152 -0
- package/native/core/src/dev-server.cpp +103 -0
- package/native/core/src/dom-web-view.cpp +45 -0
- package/native/core/src/download.cpp +53 -0
- package/native/core/src/expo-image.cpp +548 -0
- package/native/core/src/expo-ui.cpp +203 -0
- package/native/core/src/focus-order.cpp +441 -0
- package/native/core/src/gestures.cpp +1806 -0
- package/native/core/src/glass.cpp +49 -0
- package/native/core/src/header-bar.cpp +104 -0
- package/native/core/src/host-services.cpp +50 -0
- package/native/core/src/host-state.cpp +61 -0
- package/native/core/src/input-dispatcher.cpp +727 -0
- package/native/core/src/input-script.cpp +123 -0
- package/native/core/src/key-value-store.cpp +169 -0
- package/native/core/src/launch-settings.cpp +148 -0
- package/native/core/src/layout-animations.cpp +62 -0
- package/native/core/src/libraries/RNCWebViewSpec.cpp +80 -0
- package/native/core/src/libraries/react-native-reanimated.cpp +216 -0
- package/native/core/src/libraries/react-native-worklets.cpp +192 -0
- package/native/core/src/libraries/rnscreens.cpp +125 -0
- package/native/core/src/libraries/rnsvg.cpp +358 -0
- package/native/core/src/libraries/safeareacontext.cpp +70 -0
- package/native/core/src/libraries/worklets-idle-frames.js +70 -0
- package/native/core/src/library-glue.cpp +35 -0
- package/native/core/src/live-regions.cpp +122 -0
- package/native/core/src/module-registry.cpp +50 -0
- package/native/core/src/modules/accessibility-manager.cpp +98 -0
- package/native/core/src/modules/address-search.cpp +219 -0
- package/native/core/src/modules/alert-manager.cpp +140 -0
- package/native/core/src/modules/app-info.cpp +74 -0
- package/native/core/src/modules/app-modules.cpp +412 -0
- package/native/core/src/modules/apple-authentication.cpp +188 -0
- package/native/core/src/modules/asset.cpp +111 -0
- package/native/core/src/modules/async-storage.cpp +192 -0
- package/native/core/src/modules/audio.cpp +541 -0
- package/native/core/src/modules/battery.cpp +88 -0
- package/native/core/src/modules/calendar.cpp +457 -0
- package/native/core/src/modules/camera.cpp +401 -0
- package/native/core/src/modules/core-modules.cpp +62 -0
- package/native/core/src/modules/crypto.cpp +117 -0
- package/native/core/src/modules/desktop-expo.cpp +527 -0
- package/native/core/src/modules/file-system.cpp +941 -0
- package/native/core/src/modules/fonts.cpp +163 -0
- package/native/core/src/modules/image-loader.cpp +105 -0
- package/native/core/src/modules/image-manipulator.cpp +305 -0
- package/native/core/src/modules/language-model.cpp +195 -0
- package/native/core/src/modules/local-authentication.cpp +140 -0
- package/native/core/src/modules/location.cpp +186 -0
- package/native/core/src/modules/maps.cpp +500 -0
- package/native/core/src/modules/network-state.cpp +72 -0
- package/native/core/src/modules/networking.cpp +387 -0
- package/native/core/src/modules/notifications.cpp +549 -0
- package/native/core/src/modules/photo-library.cpp +385 -0
- package/native/core/src/modules/printing.cpp +201 -0
- package/native/core/src/modules/screen-capture.cpp +71 -0
- package/native/core/src/modules/sharing.cpp +59 -0
- package/native/core/src/modules/splash-screen.cpp +70 -0
- package/native/core/src/modules/sqlite.cpp +421 -0
- package/native/core/src/modules/store-review.cpp +23 -0
- package/native/core/src/modules/text-recognition.cpp +107 -0
- package/native/core/src/modules/tracking.cpp +46 -0
- package/native/core/src/modules/undo.cpp +59 -0
- package/native/core/src/modules/video.cpp +366 -0
- package/native/core/src/modules/web-browser.cpp +100 -0
- package/native/core/src/modules/web-socket.cpp +266 -0
- package/native/core/src/mounting-manager.cpp +384 -0
- package/native/core/src/native-controls.cpp +129 -0
- package/native/core/src/native-module.cpp +250 -0
- package/native/core/src/network.cpp +219 -0
- package/native/core/src/posix-launcher.cpp +366 -0
- package/native/core/src/processes.cpp +324 -0
- package/native/core/src/red-box-errors.js +83 -0
- package/native/core/src/red-box.cpp +306 -0
- package/native/core/src/runtime.cpp +420 -0
- package/native/core/src/safe-areas.cpp +137 -0
- package/native/core/src/screen-presentation.cpp +61 -0
- package/native/core/src/screen-stacks.cpp +254 -0
- package/native/core/src/scrollers.cpp +181 -0
- package/native/core/src/spawn-rules.cpp +292 -0
- package/native/core/src/split-view.cpp +343 -0
- package/native/core/src/svg.cpp +2190 -0
- package/native/core/src/symbol.cpp +94 -0
- package/native/core/src/tabs-host.cpp +234 -0
- package/native/core/src/text-input.cpp +139 -0
- package/native/core/src/text-layout-manager.cpp +63 -0
- package/native/core/src/tray-and-dock.cpp +154 -0
- package/native/core/src/updates.cpp +965 -0
- package/native/core/src/view-box.cpp +788 -0
- package/native/core/src/view-transform.cpp +45 -0
- package/native/core/src/view-tree.cpp +234 -0
- package/native/core/src/web-view.cpp +143 -0
- package/native/core/src/worklet-host.cpp +10 -0
- package/native/scripts/build-hermes.sh +44 -0
- package/native/scripts/build.sh +175 -0
- package/native/scripts/cache-dir.sh +18 -0
- package/native/scripts/codegen-library.sh +193 -0
- package/native/scripts/compiler-launcher.sh +17 -0
- package/native/scripts/fetch.sh +174 -0
- package/native/scripts/hermes-built.sh +10 -0
- package/native/scripts/host-dir.sh +16 -0
- package/native/scripts/launch-probe.sh +60 -0
- package/native/scripts/macos-target.sh +8 -0
- package/native/scripts/make-prebuilt.mjs +360 -0
- package/native/scripts/prebuilt-host-cache.mjs +158 -0
- package/native/shim/openssl/sha.h +22 -0
- package/native/shim/view-platform/react/renderer/components/view/HostPlatformViewTraitsInitializer.h +37 -0
- package/package.json +73 -1
- package/prebuilt.json +33 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// NgNativeLocation: the slice of expo-location that @ng-native/expo's Location calls, over a
|
|
2
|
+
// LocationSource, which the AppKit backend implements with CLLocationManager.
|
|
3
|
+
//
|
|
4
|
+
// - getForegroundPermissionsAsync and requestForegroundPermissionsAsync: {status: granted |
|
|
5
|
+
// denied | undetermined, granted, canAskAgain, expires: 'never'}. Restricted reads as denied.
|
|
6
|
+
// Only an undetermined authorization is asked for; with `noPrompts` (NGN_NO_PROMPTS=1 in the
|
|
7
|
+
// host's environment) nothing is, and the request answers what is decided.
|
|
8
|
+
// - getCurrentPositionAsync({accuracy}): {coords: {latitude, longitude, altitude, accuracy,
|
|
9
|
+
// altitudeAccuracy, heading, speed}, timestamp}, as expo-location's LocationObject.
|
|
10
|
+
// - watchPositionAsync({accuracy, distanceInterval}, callback): a promise of {remove()}, the
|
|
11
|
+
// callback taking each fix.
|
|
12
|
+
// Without the permission both refuse with expo-location's "Not authorized to use location
|
|
13
|
+
// services", and nothing is read.
|
|
14
|
+
// - geocodeAsync(address): [{latitude, longitude, altitude, accuracy}], and
|
|
15
|
+
// reverseGeocodeAsync({latitude, longitude}): [{city, district, streetNumber, street, region,
|
|
16
|
+
// subregion, country, postalCode, name, isoCountryCode, timezone}], over a Geocoder, which needs
|
|
17
|
+
// no permission, as on iOS. No match answers []; a network failure or rate limit and any other
|
|
18
|
+
// failure reject with expo-location's iOS messages. Without a geocoder neither method is there.
|
|
19
|
+
#pragma once
|
|
20
|
+
|
|
21
|
+
#include "ngn/native-module.h"
|
|
22
|
+
|
|
23
|
+
#include <functional>
|
|
24
|
+
#include <map>
|
|
25
|
+
#include <memory>
|
|
26
|
+
#include <optional>
|
|
27
|
+
#include <string>
|
|
28
|
+
#include <vector>
|
|
29
|
+
|
|
30
|
+
namespace ngn {
|
|
31
|
+
|
|
32
|
+
class LocationSource {
|
|
33
|
+
public:
|
|
34
|
+
enum class Authorization { NotDetermined, Denied, Restricted, Granted };
|
|
35
|
+
|
|
36
|
+
struct Fix {
|
|
37
|
+
double latitude{0};
|
|
38
|
+
double longitude{0};
|
|
39
|
+
// Nothing where the Mac does not know.
|
|
40
|
+
std::optional<double> altitude;
|
|
41
|
+
std::optional<double> accuracy;
|
|
42
|
+
std::optional<double> altitudeAccuracy;
|
|
43
|
+
std::optional<double> heading;
|
|
44
|
+
std::optional<double> speed;
|
|
45
|
+
// Milliseconds since 1970.
|
|
46
|
+
double timestamp{0};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
virtual ~LocationSource() = default;
|
|
50
|
+
virtual Authorization authorization() = 0;
|
|
51
|
+
// Shows the OS's prompt, and answers once the user has decided. Any thread.
|
|
52
|
+
virtual void requestAuthorization(std::function<void(Authorization)> done) = 0;
|
|
53
|
+
// One fix at about `accuracy` metres, or why there is none. Any thread.
|
|
54
|
+
virtual void currentFix(double accuracy, std::function<void(std::optional<Fix>, std::string error)> done) = 0;
|
|
55
|
+
// Each fix after moving `distance` metres, until stopWatching. A handle.
|
|
56
|
+
virtual int watch(double accuracy, double distance, std::function<void(const Fix &)> fix) = 0;
|
|
57
|
+
virtual void stopWatching(int handle) = 0;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
class Geocoder {
|
|
61
|
+
public:
|
|
62
|
+
enum class Failure { None, NoResult, Network, Failed };
|
|
63
|
+
struct Place {
|
|
64
|
+
// geocode's: the place's point, and its altitude and accuracy in metres where known.
|
|
65
|
+
std::optional<double> latitude;
|
|
66
|
+
std::optional<double> longitude;
|
|
67
|
+
std::optional<double> altitude;
|
|
68
|
+
std::optional<double> accuracy;
|
|
69
|
+
// reverseGeocode's: expo's address fields the geocoder knows, by expo's names.
|
|
70
|
+
std::map<std::string, std::string> address;
|
|
71
|
+
};
|
|
72
|
+
struct Answer {
|
|
73
|
+
std::vector<Place> places;
|
|
74
|
+
Failure failure{Failure::None};
|
|
75
|
+
// The OS's description of a failure.
|
|
76
|
+
std::string reason;
|
|
77
|
+
};
|
|
78
|
+
virtual ~Geocoder() = default;
|
|
79
|
+
// Each answers once, on any thread.
|
|
80
|
+
virtual void geocode(const std::string &address, std::function<void(Answer)> done) = 0;
|
|
81
|
+
virtual void reverseGeocode(double latitude, double longitude, std::function<void(Answer)> done) = 0;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
std::shared_ptr<NativeModule> makeLocationModule(
|
|
85
|
+
std::shared_ptr<LocationSource> source,
|
|
86
|
+
bool noPrompts,
|
|
87
|
+
std::shared_ptr<Geocoder> geocoder = nullptr);
|
|
88
|
+
|
|
89
|
+
} // namespace ngn
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
// `<expo-map>` on a desktop host: expo-maps' Apple map (ViewManagerAdapter_ExpoAppleMaps, which
|
|
2
|
+
// `registerExpoMap('macos')` commits) as a Fabric component of the desktop's own, drawn by the
|
|
3
|
+
// AppKit backend with MKMapView, and NgNativeMaps, the module @ng-native/expo's MapView calls the
|
|
4
|
+
// view's functions through, by the view's tag.
|
|
5
|
+
//
|
|
6
|
+
// The core holds what does not need MapKit: the props as expo-maps' iOS view reads them (markers,
|
|
7
|
+
// polylines, polygons, circles, the camera, the map's properties, its controls and colour scheme),
|
|
8
|
+
// the camera's zoom as a span and back, which shape a click lands on, and each event's payload in
|
|
9
|
+
// the iOS view's shape:
|
|
10
|
+
//
|
|
11
|
+
// - cameraMove: {coordinates, latitudeDelta, longitudeDelta, zoom, tilt, bearing}, whenever the
|
|
12
|
+
// region changes, and once when the map first appears;
|
|
13
|
+
// - mapClick: {coordinates}, a click on no marker and no shape;
|
|
14
|
+
// - markerClick: the marker's id, title, tintColor, systemImage, monogram and coordinates, when it
|
|
15
|
+
// is selected, by a click or by selectMarker;
|
|
16
|
+
// - polygonClick, circleClick, polylineClick: the shape as committed (colours are the processed
|
|
17
|
+
// values), checked in that order, as on iOS.
|
|
18
|
+
//
|
|
19
|
+
// - setCameraPosition(tag, position): moves the view `tag`'s camera; with no position, to the
|
|
20
|
+
// user's location when the map shows it.
|
|
21
|
+
// - selectMarker(tag, id, {zoom, moveCamera}): selects the marker `id` (none clears the selection)
|
|
22
|
+
// and moves the camera to it unless `moveCamera` is false.
|
|
23
|
+
//
|
|
24
|
+
// The map shows the user's location (`properties.isMyLocationEnabled`) only once location is
|
|
25
|
+
// allowed: the view never asks, as expo-maps' iOS view does not.
|
|
26
|
+
#pragma once
|
|
27
|
+
|
|
28
|
+
#include "ngn/desktop-props.h"
|
|
29
|
+
#include "ngn/location.h"
|
|
30
|
+
#include "ngn/native-module.h"
|
|
31
|
+
|
|
32
|
+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
33
|
+
#include <react/renderer/components/view/ViewEventEmitter.h>
|
|
34
|
+
#include <react/renderer/components/view/ViewProps.h>
|
|
35
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
36
|
+
|
|
37
|
+
#include <folly/dynamic.h>
|
|
38
|
+
|
|
39
|
+
#include <cstdint>
|
|
40
|
+
#include <map>
|
|
41
|
+
#include <memory>
|
|
42
|
+
#include <mutex>
|
|
43
|
+
#include <optional>
|
|
44
|
+
#include <string>
|
|
45
|
+
#include <vector>
|
|
46
|
+
|
|
47
|
+
namespace ngn {
|
|
48
|
+
|
|
49
|
+
extern const char MapComponentName[];
|
|
50
|
+
|
|
51
|
+
class MapProps final : public facebook::react::ViewProps, public HasDesktopProps {
|
|
52
|
+
public:
|
|
53
|
+
MapProps() = default;
|
|
54
|
+
MapProps(
|
|
55
|
+
const facebook::react::PropsParserContext &context,
|
|
56
|
+
const MapProps &sourceProps,
|
|
57
|
+
const facebook::react::RawProps &rawProps);
|
|
58
|
+
// Every prop as committed, the last value of each: a `null` removes one.
|
|
59
|
+
folly::dynamic values = folly::dynamic::object();
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
using MapShadowNode = facebook::react::ConcreteViewShadowNode<MapComponentName, MapProps, facebook::react::ViewEventEmitter>;
|
|
63
|
+
using MapComponentDescriptor = facebook::react::ConcreteComponentDescriptor<MapShadowNode>;
|
|
64
|
+
|
|
65
|
+
struct MapCoordinate {
|
|
66
|
+
double latitude{0};
|
|
67
|
+
double longitude{0};
|
|
68
|
+
bool operator==(const MapCoordinate &) const = default;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
struct MapMarker {
|
|
72
|
+
std::string id;
|
|
73
|
+
MapCoordinate coordinates;
|
|
74
|
+
std::string title;
|
|
75
|
+
// An SF Symbol's name, drawn in the balloon; else the monogram's letters.
|
|
76
|
+
std::string systemImage;
|
|
77
|
+
std::string monogram;
|
|
78
|
+
// ARGB; unset is the system red.
|
|
79
|
+
std::optional<uint32_t> tint;
|
|
80
|
+
// The marker as committed.
|
|
81
|
+
folly::dynamic given;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
struct MapPolyline {
|
|
85
|
+
std::string id;
|
|
86
|
+
std::vector<MapCoordinate> coordinates;
|
|
87
|
+
// Unset is the system blue.
|
|
88
|
+
std::optional<uint32_t> color;
|
|
89
|
+
double width{4};
|
|
90
|
+
// `contourStyle: 'GEODESIC'`: along the Earth's curve.
|
|
91
|
+
bool geodesic{false};
|
|
92
|
+
folly::dynamic given;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
struct MapPolygon {
|
|
96
|
+
std::string id;
|
|
97
|
+
std::vector<MapCoordinate> coordinates;
|
|
98
|
+
// The fill; unset is the system blue. No line colour draws no line.
|
|
99
|
+
std::optional<uint32_t> color;
|
|
100
|
+
std::optional<uint32_t> lineColor;
|
|
101
|
+
double lineWidth{0};
|
|
102
|
+
folly::dynamic given;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
struct MapCircle {
|
|
106
|
+
std::string id;
|
|
107
|
+
MapCoordinate center;
|
|
108
|
+
// Metres.
|
|
109
|
+
double radius{0};
|
|
110
|
+
// The fill; unset is the system green.
|
|
111
|
+
std::optional<uint32_t> color;
|
|
112
|
+
std::optional<uint32_t> lineColor;
|
|
113
|
+
double lineWidth{0};
|
|
114
|
+
folly::dynamic given;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
struct MapCamera {
|
|
118
|
+
MapCoordinate coordinates;
|
|
119
|
+
double zoom{1};
|
|
120
|
+
bool operator==(const MapCamera &) const = default;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
struct MapSpan {
|
|
124
|
+
double latitudeDelta{0};
|
|
125
|
+
double longitudeDelta{0};
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
enum class MapType { Standard, Hybrid, Imagery };
|
|
129
|
+
enum class MapColorScheme { Automatic, Light, Dark };
|
|
130
|
+
|
|
131
|
+
// The map as the props describe it, read as expo-maps' iOS view reads them, with its defaults.
|
|
132
|
+
struct MapModel {
|
|
133
|
+
std::vector<MapMarker> markers;
|
|
134
|
+
std::vector<MapPolyline> polylines;
|
|
135
|
+
std::vector<MapPolygon> polygons;
|
|
136
|
+
std::vector<MapCircle> circles;
|
|
137
|
+
// The lists as committed, to tell whether one changed.
|
|
138
|
+
folly::dynamic givenMarkers;
|
|
139
|
+
folly::dynamic givenShapes;
|
|
140
|
+
std::optional<MapCamera> camera;
|
|
141
|
+
|
|
142
|
+
// properties
|
|
143
|
+
bool myLocation{false};
|
|
144
|
+
MapType type{MapType::Standard};
|
|
145
|
+
bool traffic{false};
|
|
146
|
+
bool selection{true};
|
|
147
|
+
// Metres from a polyline that a click still lands on it.
|
|
148
|
+
double polylineTapThreshold{20};
|
|
149
|
+
bool realisticElevation{false};
|
|
150
|
+
bool mutedEmphasis{false};
|
|
151
|
+
// MapKit's category names (`MKPOICategoryMuseum`): only these, or all but these. Neither shows
|
|
152
|
+
// every category.
|
|
153
|
+
std::optional<std::vector<std::string>> pointsIncluding;
|
|
154
|
+
std::optional<std::vector<std::string>> pointsExcluding;
|
|
155
|
+
|
|
156
|
+
// uiSettings
|
|
157
|
+
bool compass{true};
|
|
158
|
+
bool scaleBar{false};
|
|
159
|
+
bool pitchToggle{true};
|
|
160
|
+
bool userLocationButton{true};
|
|
161
|
+
|
|
162
|
+
MapColorScheme colorScheme{MapColorScheme::Automatic};
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
MapModel mapModel(const folly::dynamic &props);
|
|
166
|
+
|
|
167
|
+
// A colour as expo-maps takes one: a processed ARGB number, `#rgb`, `#rgba`, `#rrggbb`,
|
|
168
|
+
// `#rrggbbaa` or a CSS colour name. Unset for anything else.
|
|
169
|
+
std::optional<uint32_t> mapColor(const folly::dynamic &value);
|
|
170
|
+
|
|
171
|
+
// MapKit's name for expo-maps' point of interest category: `EV_CHARGER` is `MKPOICategoryEVCharger`.
|
|
172
|
+
std::string mapPointOfInterestCategory(const std::string &expoName);
|
|
173
|
+
|
|
174
|
+
// expo-maps' zoom as the span it shows, and the span's zoom: 360 / 2^zoom degrees each way.
|
|
175
|
+
MapSpan mapSpanForZoom(double zoom);
|
|
176
|
+
double mapZoomForSpan(double longitudeDelta);
|
|
177
|
+
|
|
178
|
+
// A position as setCameraPosition and the `cameraPosition` prop take it: unset without coordinates.
|
|
179
|
+
std::optional<MapCamera> mapCameraOf(const folly::dynamic &position);
|
|
180
|
+
|
|
181
|
+
// Metres between two points, along the Earth's surface.
|
|
182
|
+
double mapDistance(MapCoordinate a, MapCoordinate b);
|
|
183
|
+
// The points along the great circle from `a` to `b`, both included, as expo-maps hit-tests a
|
|
184
|
+
// geodesic polyline.
|
|
185
|
+
std::vector<MapCoordinate> mapGreatCircle(MapCoordinate a, MapCoordinate b, int segments = 30);
|
|
186
|
+
|
|
187
|
+
struct MapEvent {
|
|
188
|
+
// As the view sends it, without `on`: `mapClick`.
|
|
189
|
+
std::string name;
|
|
190
|
+
folly::dynamic payload;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
// What a click at `tap` that landed on no marker is: a polygon's, a circle's or a polyline's, in
|
|
194
|
+
// that order, or the map's.
|
|
195
|
+
MapEvent mapClickAt(const MapModel &map, MapCoordinate tap);
|
|
196
|
+
MapEvent mapMarkerClick(const MapMarker &marker);
|
|
197
|
+
MapEvent mapCameraMove(MapCoordinate center, MapSpan span, double pitch, double heading);
|
|
198
|
+
|
|
199
|
+
// Whether the map shows the user's location: asked for, and allowed.
|
|
200
|
+
bool mapShowsUserLocation(const MapModel &map, LocationSource::Authorization authorization);
|
|
201
|
+
|
|
202
|
+
// A view's map, as NgNativeMaps drives it. Any thread.
|
|
203
|
+
class MapController {
|
|
204
|
+
public:
|
|
205
|
+
virtual ~MapController() = default;
|
|
206
|
+
// No camera moves to the user's location, where the map shows it.
|
|
207
|
+
virtual void setCamera(std::optional<MapCamera> camera) = 0;
|
|
208
|
+
// No id clears the selection.
|
|
209
|
+
virtual void selectMarker(std::optional<std::string> id, std::optional<double> zoom, bool moveCamera) = 0;
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
// The mounted maps by view tag, shared by the views and NgNativeMaps. Any thread.
|
|
213
|
+
class MapViews {
|
|
214
|
+
public:
|
|
215
|
+
void attach(int tag, std::shared_ptr<MapController> map);
|
|
216
|
+
void detach(int tag);
|
|
217
|
+
std::shared_ptr<MapController> find(int tag) const;
|
|
218
|
+
|
|
219
|
+
private:
|
|
220
|
+
mutable std::mutex mutex_;
|
|
221
|
+
std::map<int, std::shared_ptr<MapController>> maps_;
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
std::shared_ptr<NativeModule> makeMapsModule(std::shared_ptr<MapViews> views);
|
|
225
|
+
|
|
226
|
+
} // namespace ngn
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// The module registry interface: which TurboModules the runtime gets, by name.
|
|
2
|
+
//
|
|
3
|
+
// The core registers the modules it implements once for every toolkit; a backend registers a
|
|
4
|
+
// ModuleProvider for what only the toolkit can answer. A backend's provider is asked first, so a
|
|
5
|
+
// toolkit can replace a core module, then the core's own, in the order they were added, then the
|
|
6
|
+
// modules autolinked libraries and the app register in React Native's global C++ module map.
|
|
7
|
+
#pragma once
|
|
8
|
+
|
|
9
|
+
#include <ReactCommon/CallInvoker.h>
|
|
10
|
+
#include <ReactCommon/TurboModule.h>
|
|
11
|
+
#include <react/nativemodule/TurboModuleProvider.h>
|
|
12
|
+
|
|
13
|
+
#include <functional>
|
|
14
|
+
#include <map>
|
|
15
|
+
#include <memory>
|
|
16
|
+
#include <string>
|
|
17
|
+
#include <vector>
|
|
18
|
+
|
|
19
|
+
namespace ngn {
|
|
20
|
+
|
|
21
|
+
class ModuleProvider {
|
|
22
|
+
public:
|
|
23
|
+
virtual ~ModuleProvider() = default;
|
|
24
|
+
// The module called `name`, or null when this provider has none.
|
|
25
|
+
virtual std::shared_ptr<facebook::react::TurboModule> module(
|
|
26
|
+
const std::string &name,
|
|
27
|
+
const std::shared_ptr<facebook::react::CallInvoker> &jsInvoker) = 0;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
class ModuleRegistry {
|
|
31
|
+
public:
|
|
32
|
+
using Factory = std::function<std::shared_ptr<facebook::react::TurboModule>(
|
|
33
|
+
const std::shared_ptr<facebook::react::CallInvoker> &jsInvoker)>;
|
|
34
|
+
|
|
35
|
+
// A core module. A second registration under one name replaces the first.
|
|
36
|
+
void add(const std::string &name, Factory factory);
|
|
37
|
+
void addProvider(std::shared_ptr<ModuleProvider> provider);
|
|
38
|
+
|
|
39
|
+
std::shared_ptr<facebook::react::TurboModule> module(
|
|
40
|
+
const std::string &name,
|
|
41
|
+
const std::shared_ptr<facebook::react::CallInvoker> &jsInvoker) const;
|
|
42
|
+
|
|
43
|
+
// The registry as ReactHost takes it.
|
|
44
|
+
facebook::react::TurboModuleProviders providers() const;
|
|
45
|
+
|
|
46
|
+
private:
|
|
47
|
+
std::vector<std::shared_ptr<ModuleProvider>> providers_;
|
|
48
|
+
std::map<std::string, Factory> factories_;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
} // namespace ngn
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// The mounting interface: what the core asks of a toolkit to show a surface's views.
|
|
2
|
+
//
|
|
3
|
+
// The core replays every mounting transaction as these calls, in the transaction's order, on the
|
|
4
|
+
// toolkit's UI thread. The surface's root view (tag == surfaceId) arrives as a createView like any
|
|
5
|
+
// other; the backend attaches it to the surface's main container.
|
|
6
|
+
#pragma once
|
|
7
|
+
|
|
8
|
+
#include "ngn/expo-ui.h"
|
|
9
|
+
#include "ngn/screen-stacks.h"
|
|
10
|
+
#include "ngn/split-view.h"
|
|
11
|
+
#include "ngn/svg.h"
|
|
12
|
+
#include "ngn/system.h"
|
|
13
|
+
|
|
14
|
+
#include <react/renderer/core/ComponentDescriptor.h>
|
|
15
|
+
#include <react/renderer/componentregistry/ComponentDescriptorProvider.h>
|
|
16
|
+
#include <react/renderer/mounting/ShadowView.h>
|
|
17
|
+
|
|
18
|
+
#include <folly/dynamic.h>
|
|
19
|
+
#include <functional>
|
|
20
|
+
#include <string>
|
|
21
|
+
#include <vector>
|
|
22
|
+
|
|
23
|
+
namespace ngn {
|
|
24
|
+
|
|
25
|
+
using facebook::react::ShadowView;
|
|
26
|
+
using facebook::react::SurfaceId;
|
|
27
|
+
using facebook::react::Tag;
|
|
28
|
+
|
|
29
|
+
class MountingBackend {
|
|
30
|
+
public:
|
|
31
|
+
virtual ~MountingBackend() = default;
|
|
32
|
+
|
|
33
|
+
// Runs `task` on the toolkit's UI thread, after every task posted before it.
|
|
34
|
+
virtual void runOnUiThread(std::function<void()> task) = 0;
|
|
35
|
+
// Whether the caller is on the toolkit's UI thread.
|
|
36
|
+
virtual bool onUiThread() const = 0;
|
|
37
|
+
// Runs the UI thread's pending tasks for a moment, from the UI thread, while it waits on work
|
|
38
|
+
// that may need them. Nothing in a backend that cannot.
|
|
39
|
+
virtual void serviceUiThread() {}
|
|
40
|
+
|
|
41
|
+
// A view for `view.tag`, with its first props, state, layout and event emitter already set on
|
|
42
|
+
// `view`. The update calls below then report only what changed.
|
|
43
|
+
virtual void createView(const ShadowView &view) = 0;
|
|
44
|
+
virtual void deleteView(SurfaceId surfaceId, Tag tag) = 0;
|
|
45
|
+
virtual void insertChild(SurfaceId surfaceId, Tag parent, Tag child, int index) = 0;
|
|
46
|
+
virtual void removeChild(SurfaceId surfaceId, Tag parent, Tag child, int index) = 0;
|
|
47
|
+
|
|
48
|
+
virtual void updateProps(const ShadowView &view) = 0;
|
|
49
|
+
virtual void updateState(const ShadowView &view) = 0;
|
|
50
|
+
virtual void updateLayout(const ShadowView &view) = 0;
|
|
51
|
+
virtual void updateEventEmitter(const ShadowView &view) = 0;
|
|
52
|
+
|
|
53
|
+
virtual void dispatchCommand(Tag tag, const std::string &name, const folly::dynamic &args) = 0;
|
|
54
|
+
|
|
55
|
+
// A screen below the top of its stack (screen-stacks.h): hidden without being unmounted, and
|
|
56
|
+
// shown again as it returns to the top.
|
|
57
|
+
virtual void setCovered(SurfaceId /*surfaceId*/, Tag /*tag*/, bool /*covered*/) {}
|
|
58
|
+
|
|
59
|
+
// A screen came to be presented over its stack (screen-presentation.h) or went back to being
|
|
60
|
+
// pushed. It is a sheet, cover or popover as its desktop props say, presented like a modal.
|
|
61
|
+
virtual void setPresented(SurfaceId /*surfaceId*/, Tag /*screen*/, bool /*presented*/) {}
|
|
62
|
+
|
|
63
|
+
// The header the surface's main container shows changed: another screen came to the front, or
|
|
64
|
+
// its stack gained or lost the screen below it. Nothing when no screen in front has a header.
|
|
65
|
+
virtual void setFrontHeader(SurfaceId /*surfaceId*/, const std::optional<ScreenStacks::FrontHeader> & /*header*/) {}
|
|
66
|
+
|
|
67
|
+
// A split view mounted (split-view.h): the window's own, or a plain one in the content. Sent once,
|
|
68
|
+
// after its panes are in it.
|
|
69
|
+
virtual void setSplitView(SurfaceId /*surfaceId*/, Tag /*split*/, bool /*window*/) {}
|
|
70
|
+
|
|
71
|
+
// The source lists among `parent`'s children changed: their sections, rows or rows' props. Empty
|
|
72
|
+
// when the last of them went.
|
|
73
|
+
virtual void setSourceLists(SurfaceId /*surfaceId*/, Tag /*parent*/, const std::vector<SourceList> & /*lists*/) {}
|
|
74
|
+
|
|
75
|
+
// An svg's elements changed (svg.h): its view draws `document` from now on.
|
|
76
|
+
virtual void setSvgDrawing(SurfaceId /*surfaceId*/, Tag /*svg*/, std::shared_ptr<const SvgDocument> /*document*/) {}
|
|
77
|
+
|
|
78
|
+
// The expo/ui views under a HostView changed (expo-ui.h): its view draws `root` in SwiftUI from now
|
|
79
|
+
// on.
|
|
80
|
+
virtual void setExpoUITree(SurfaceId /*surfaceId*/, Tag /*host*/, std::shared_ptr<const ExpoUINode> /*root*/) {}
|
|
81
|
+
|
|
82
|
+
// A live region on the surface changed its text (live-regions.h): the screen reader says it.
|
|
83
|
+
virtual void announce(SurfaceId /*surfaceId*/, const Announcement & /*announcement*/) {}
|
|
84
|
+
|
|
85
|
+
// Called once a transaction's mutations have all been applied.
|
|
86
|
+
virtual void didMount(SurfaceId /*surfaceId*/) {}
|
|
87
|
+
|
|
88
|
+
// Components the toolkit draws beyond the core's own (View, Paragraph, Text, RawText,
|
|
89
|
+
// ScrollView, TextInput, Image, ModalHostView, the native controls of native-controls.h and
|
|
90
|
+
// UnimplementedNativeView).
|
|
91
|
+
virtual std::vector<facebook::react::ComponentDescriptorProvider> componentProviders() const {
|
|
92
|
+
return {};
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
} // namespace ngn
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// React Native's IMountingManager for every toolkit: replays each mounting transaction through a
|
|
2
|
+
// MountingBackend on its UI thread, keeps the core's ViewTree in step, and reports desktop props.
|
|
3
|
+
#pragma once
|
|
4
|
+
|
|
5
|
+
#include "ngn/control-sizes.h"
|
|
6
|
+
#include "ngn/desktop-view-props.h"
|
|
7
|
+
#include "ngn/expo-ui.h"
|
|
8
|
+
#include "ngn/live-regions.h"
|
|
9
|
+
#include "ngn/mounting-backend.h"
|
|
10
|
+
#include "ngn/safe-areas.h"
|
|
11
|
+
#include "ngn/screen-stacks.h"
|
|
12
|
+
#include "ngn/split-view.h"
|
|
13
|
+
#include "ngn/svg.h"
|
|
14
|
+
#include "ngn/tabs-host.h"
|
|
15
|
+
#include "ngn/view-tree.h"
|
|
16
|
+
|
|
17
|
+
#include <react/renderer/uimanager/IMountingManager.h>
|
|
18
|
+
|
|
19
|
+
#include <atomic>
|
|
20
|
+
#include <functional>
|
|
21
|
+
#include <memory>
|
|
22
|
+
#include <mutex>
|
|
23
|
+
#include <unordered_map>
|
|
24
|
+
#include <unordered_set>
|
|
25
|
+
|
|
26
|
+
namespace ngn {
|
|
27
|
+
|
|
28
|
+
class MountingManager final : public facebook::react::IMountingManager,
|
|
29
|
+
public std::enable_shared_from_this<MountingManager> {
|
|
30
|
+
public:
|
|
31
|
+
// `desktopProps` may be null for a backend that has no use for focusable and tabIndex yet.
|
|
32
|
+
// `screens` and `safeAreas` replace the native stack's and the safe area's rules (tests record
|
|
33
|
+
// what they send); null keeps the defaults.
|
|
34
|
+
MountingManager(
|
|
35
|
+
std::shared_ptr<MountingBackend> backend,
|
|
36
|
+
std::shared_ptr<DesktopPropsSink> desktopProps,
|
|
37
|
+
std::unique_ptr<ScreenStacks> screens = nullptr,
|
|
38
|
+
std::unique_ptr<SafeAreas> safeAreas = nullptr,
|
|
39
|
+
std::unique_ptr<TabsHosts> tabs = nullptr);
|
|
40
|
+
|
|
41
|
+
// JS thread: the mutations are applied later, on the backend's UI thread, in order.
|
|
42
|
+
void executeMount(SurfaceId surfaceId, facebook::react::MountingTransaction &&transaction) override;
|
|
43
|
+
void dispatchCommand(const ShadowView &view, const std::string &name, const folly::dynamic &args) override;
|
|
44
|
+
void setAfterMountCallback(std::function<void(SurfaceId)> &&onAfterMount) override;
|
|
45
|
+
// UI thread. The props in `changed` merged into the mounted view's and given to the backend at
|
|
46
|
+
// once, with no commit, as RCTMountingManager does: Animated and Reanimated move views this way.
|
|
47
|
+
void synchronouslyUpdateViewOnUIThread(Tag tag, const folly::dynamic &changed) override;
|
|
48
|
+
|
|
49
|
+
facebook::react::ComponentRegistryFactory getComponentRegistryFactory() override;
|
|
50
|
+
bool hasComponent(const std::string &name) override;
|
|
51
|
+
|
|
52
|
+
// Told on the JS thread of each commit a transaction carries: how long the commit took (layout
|
|
53
|
+
// and diff included), in milliseconds. The host logs it for the performance budget.
|
|
54
|
+
std::function<void(SurfaceId surfaceId, double ms)> onCommit;
|
|
55
|
+
|
|
56
|
+
// UI thread only. A container's size and OS insets (safe-areas.h), which its safe-area views
|
|
57
|
+
// follow at once.
|
|
58
|
+
void setContainerInsets(Tag root, const ContainerInsets &insets);
|
|
59
|
+
// UI thread only. The user chose the tab `screen` of the tabs host `host` (tabs-host.h).
|
|
60
|
+
void chooseTab(SurfaceId surfaceId, Tag host, Tag screen);
|
|
61
|
+
void removeContainerInsets(Tag root);
|
|
62
|
+
// Runs `task` on the backend's UI thread, after what is queued there already. Any thread.
|
|
63
|
+
void runOnUiThread(std::function<void()> task) {
|
|
64
|
+
backend_->runOnUiThread(std::move(task));
|
|
65
|
+
}
|
|
66
|
+
// Runs the backend's pending UI-thread tasks for a moment when called on its UI thread, and does
|
|
67
|
+
// nothing elsewhere: for the UI thread while it waits on another thread's work.
|
|
68
|
+
void serviceUiThread() {
|
|
69
|
+
if (backend_->onUiThread()) {
|
|
70
|
+
backend_->serviceUiThread();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// UI thread only. Whether the last mount told no safe-area view anything new and no container's
|
|
74
|
+
// insets changed since: the views have the insets they will draw with. A window is shown then,
|
|
75
|
+
// so its first frame is not drawn under its toolbar.
|
|
76
|
+
bool safeAreasSettled() const {
|
|
77
|
+
return safeAreasSettled_;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// The native controls' sizes for a runtime's layout (control-sizes.h), measured with `measurer`
|
|
81
|
+
// on the backend's UI thread. A new one for each JavaScript instance, which drops the last's.
|
|
82
|
+
// Any thread. `relayout` replaces the state update that lays a measured control out again.
|
|
83
|
+
std::shared_ptr<ControlSizes> startControlSizes(
|
|
84
|
+
std::shared_ptr<const ControlMeasurer> measurer,
|
|
85
|
+
ControlSizes::Relayout relayout = nullptr);
|
|
86
|
+
// Any thread: a new JavaScript instance (a runtime's first, or a reload's) begins committing.
|
|
87
|
+
// Answers its number, which every mount applied after the last instance's transactions is
|
|
88
|
+
// recorded under (mountedBy): the UI thread's queue keeps the two apart.
|
|
89
|
+
uint64_t beginInstance();
|
|
90
|
+
// Any thread: the instance begun last.
|
|
91
|
+
uint64_t instance() const {
|
|
92
|
+
return instances_;
|
|
93
|
+
}
|
|
94
|
+
// UI thread only. The instance whose transaction last mounted on `surfaceId`, 0 for none.
|
|
95
|
+
uint64_t mountedBy(SurfaceId surfaceId) const {
|
|
96
|
+
auto it = mountedBy_.find(surfaceId);
|
|
97
|
+
return it == mountedBy_.end() ? 0 : it->second;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// UI thread only. Whether every control layout measured has been mounted at its size: a window
|
|
101
|
+
// is shown then, as for its safe areas, so its first frame does not draw them unsized.
|
|
102
|
+
bool controlSizesSettled() const;
|
|
103
|
+
|
|
104
|
+
// UI thread only. What a back swipe in the window of `surfaceId` moves (back-swipe.h), and the top
|
|
105
|
+
// screen of a stack now.
|
|
106
|
+
std::optional<BackSwipeTarget> backSwipeTarget(SurfaceId surfaceId) const {
|
|
107
|
+
return screens_->backSwipeTarget(tree_, surfaceId);
|
|
108
|
+
}
|
|
109
|
+
Tag stackTop(Tag stack) const {
|
|
110
|
+
return screens_->top(stack);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// UI thread only.
|
|
114
|
+
const ViewTree &tree() const {
|
|
115
|
+
return tree_;
|
|
116
|
+
}
|
|
117
|
+
ViewTree &tree() {
|
|
118
|
+
return tree_;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
private:
|
|
122
|
+
void apply(SurfaceId surfaceId, const facebook::react::ShadowViewMutationList &mutations);
|
|
123
|
+
void ensureRoot(SurfaceId surfaceId, Tag tag);
|
|
124
|
+
void reportDesktopProps(const ShadowView &view, const ShadowView *old);
|
|
125
|
+
|
|
126
|
+
std::shared_ptr<ControlSizes> controlSizes() const;
|
|
127
|
+
|
|
128
|
+
std::shared_ptr<MountingBackend> backend_;
|
|
129
|
+
std::shared_ptr<DesktopPropsSink> desktopProps_;
|
|
130
|
+
mutable std::mutex controlSizesMutex_;
|
|
131
|
+
std::shared_ptr<ControlSizes> controlSizes_;
|
|
132
|
+
std::vector<facebook::react::ComponentDescriptorProvider> components_;
|
|
133
|
+
// The descriptors a synchronous update clones props with, made the first time a name needs one.
|
|
134
|
+
std::shared_ptr<const facebook::react::ContextContainer> propsContext_;
|
|
135
|
+
std::unordered_map<std::string, std::shared_ptr<const facebook::react::ComponentDescriptor>> descriptors_;
|
|
136
|
+
std::unordered_set<std::string> componentNames_;
|
|
137
|
+
std::function<void(SurfaceId)> afterMount_;
|
|
138
|
+
std::atomic<uint64_t> instances_{0};
|
|
139
|
+
// UI thread: the instance whose transactions are being applied, and each surface's last.
|
|
140
|
+
uint64_t applying_{0};
|
|
141
|
+
std::unordered_map<SurfaceId, uint64_t> mountedBy_;
|
|
142
|
+
ViewTree tree_;
|
|
143
|
+
LiveRegions liveRegions_;
|
|
144
|
+
std::unique_ptr<ScreenStacks> screens_;
|
|
145
|
+
std::unique_ptr<SafeAreas> safeAreas_;
|
|
146
|
+
bool safeAreasSettled_{false};
|
|
147
|
+
Sidebars sidebars_;
|
|
148
|
+
SvgDrawings svgs_;
|
|
149
|
+
ExpoUITrees expoUI_;
|
|
150
|
+
std::unique_ptr<TabsHosts> tabs_;
|
|
151
|
+
void applyTabs(SurfaceId surfaceId);
|
|
152
|
+
std::unordered_map<SurfaceId, std::optional<ScreenStacks::FrontHeader>> frontHeaders_;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
} // namespace ngn
|