@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,112 @@
|
|
|
1
|
+
// The input and hover interface: a backend reports the pointer, the core decides what it hit and
|
|
2
|
+
// which events Fabric gets (touches for press, pointer enter and leave for hover).
|
|
3
|
+
//
|
|
4
|
+
// A container is any native view that hosts part of a surface: the window's content, a sheet, a
|
|
5
|
+
// popover, a sidebar pane. Each hit-tests from its own root view in its own coordinates.
|
|
6
|
+
#pragma once
|
|
7
|
+
|
|
8
|
+
#include <react/renderer/graphics/Point.h>
|
|
9
|
+
#include <react/renderer/core/ReactPrimitives.h>
|
|
10
|
+
|
|
11
|
+
#include <optional>
|
|
12
|
+
#include <string>
|
|
13
|
+
#include <vector>
|
|
14
|
+
|
|
15
|
+
namespace ngn {
|
|
16
|
+
|
|
17
|
+
using ContainerId = int;
|
|
18
|
+
|
|
19
|
+
struct PointerInput {
|
|
20
|
+
ContainerId container{0};
|
|
21
|
+
// In the container's coordinates, top-left origin.
|
|
22
|
+
facebook::react::Point point{};
|
|
23
|
+
// In screen coordinates, top-left origin.
|
|
24
|
+
facebook::react::Point screenPoint{};
|
|
25
|
+
// Pressed buttons as a DOM `buttons` bitmask.
|
|
26
|
+
int buttons{0};
|
|
27
|
+
float pressure{0};
|
|
28
|
+
// Seconds, on the clock the toolkit stamps its events with.
|
|
29
|
+
double timestamp{0};
|
|
30
|
+
// Which press of a run of quick ones this is: 2 for a double click. A press only.
|
|
31
|
+
int clickCount{1};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// Where a trackpad gesture or scroll is: it begins, changes and ends, or is cancelled. A wheel's
|
|
35
|
+
// clicks and a scroll's momentum have none.
|
|
36
|
+
enum class GesturePhase { Began, Changed, Ended, Cancelled };
|
|
37
|
+
|
|
38
|
+
// A scroll wheel's or trackpad's movement, as the DOM's WheelEvent has it.
|
|
39
|
+
struct WheelDelta {
|
|
40
|
+
double x{0};
|
|
41
|
+
double y{0};
|
|
42
|
+
double z{0};
|
|
43
|
+
// 0 in pixels (points), 1 in lines, 2 in pages.
|
|
44
|
+
int mode{0};
|
|
45
|
+
// A trackpad's own scroll, by its phase, and whether the content moves with the fingers
|
|
46
|
+
// (natural scrolling): what turns the deltas into the fingers' movement for a gesture.
|
|
47
|
+
std::optional<GesturePhase> phase;
|
|
48
|
+
bool naturalScrolling{true};
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// What became of a wheel turn (InputSink::wheel).
|
|
52
|
+
struct WheelResult {
|
|
53
|
+
// A view listening for it (`onWheel`) heard it.
|
|
54
|
+
bool heard{false};
|
|
55
|
+
// A gesture handler took it, so the toolkit leaves the view under it unscrolled.
|
|
56
|
+
bool taken{false};
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// A file dragged onto a view: its `file://` url and its name.
|
|
60
|
+
struct DroppedFile {
|
|
61
|
+
std::string uri;
|
|
62
|
+
std::string name;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// What a drag from Finder or another app carries, as far as the toolkit shows it: files, plain
|
|
66
|
+
// text, and urls that are not files.
|
|
67
|
+
struct DragItems {
|
|
68
|
+
std::vector<DroppedFile> files;
|
|
69
|
+
std::optional<std::string> text;
|
|
70
|
+
std::vector<std::string> urls;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// The items of a drag's urls (`file://` ones are files, named by their last part decoded) and
|
|
74
|
+
// its plain text, which is left out when it only repeats a url or a file's path.
|
|
75
|
+
DragItems dragItems(const std::vector<std::string> &urls, std::optional<std::string> text);
|
|
76
|
+
|
|
77
|
+
class InputSink {
|
|
78
|
+
public:
|
|
79
|
+
virtual ~InputSink() = default;
|
|
80
|
+
|
|
81
|
+
// `rootTag` is the view the container's hit test starts from. The surface's main container
|
|
82
|
+
// uses the surface's root (tag == surfaceId).
|
|
83
|
+
virtual void addContainer(ContainerId container, facebook::react::SurfaceId surfaceId, facebook::react::Tag rootTag) = 0;
|
|
84
|
+
virtual void removeContainer(ContainerId container) = 0;
|
|
85
|
+
|
|
86
|
+
virtual void pointerDown(const PointerInput &input) = 0;
|
|
87
|
+
// A move with or without a button down. Hover follows the container named here, which is the
|
|
88
|
+
// one under the pointer now, not necessarily the one that saw the last event.
|
|
89
|
+
virtual void pointerMove(const PointerInput &input) = 0;
|
|
90
|
+
virtual void pointerUp(const PointerInput &input) = 0;
|
|
91
|
+
// The pointer left every container of this surface.
|
|
92
|
+
virtual void pointerLeave(facebook::react::SurfaceId surfaceId, const PointerInput &input) = 0;
|
|
93
|
+
// A secondary click (or Control-click). True when a view took it, so the toolkit shows no menu
|
|
94
|
+
// of its own.
|
|
95
|
+
virtual bool contextMenu(const PointerInput &input) = 0;
|
|
96
|
+
// A wheel turn over the container: whether a view heard it, and whether a gesture handler took
|
|
97
|
+
// it. One taken is not the view's to scroll as well; any other still scrolls what it is over.
|
|
98
|
+
virtual WheelResult wheel(const PointerInput &input, const WheelDelta &delta) = 0;
|
|
99
|
+
// A drag over the container, as it enters and each time it moves. True when a view under it
|
|
100
|
+
// takes drops, so the toolkit shows a copy; false and it shows none.
|
|
101
|
+
virtual bool dragOver(const PointerInput &input, const DragItems &items) = 0;
|
|
102
|
+
// The drag left the container without dropping, or was cancelled.
|
|
103
|
+
virtual void dragExit(ContainerId container) = 0;
|
|
104
|
+
// The drag was dropped on the container. True when a view took it.
|
|
105
|
+
virtual bool drop(const PointerInput &input, const DragItems &items) = 0;
|
|
106
|
+
// A trackpad's pinch (`magnification` since the last step, 0.1 for a tenth bigger) and rotation
|
|
107
|
+
// (degrees since the last step, anticlockwise) over the container.
|
|
108
|
+
virtual void magnify(const PointerInput & /*input*/, double /*magnification*/, GesturePhase /*phase*/) {}
|
|
109
|
+
virtual void rotate(const PointerInput & /*input*/, double /*degrees*/, GesturePhase /*phase*/) {}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
} // namespace ngn
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// The file-backed key-value store behind @react-native-async-storage: one JSON file per database
|
|
2
|
+
// in the app's data directory, written whole and atomically after each change. Any thread.
|
|
3
|
+
#pragma once
|
|
4
|
+
|
|
5
|
+
#include <map>
|
|
6
|
+
#include <mutex>
|
|
7
|
+
#include <optional>
|
|
8
|
+
#include <string>
|
|
9
|
+
#include <vector>
|
|
10
|
+
|
|
11
|
+
namespace ngn {
|
|
12
|
+
|
|
13
|
+
class KeyValueStore {
|
|
14
|
+
public:
|
|
15
|
+
explicit KeyValueStore(std::string directory);
|
|
16
|
+
|
|
17
|
+
std::vector<std::optional<std::string>> get(const std::string &db, const std::vector<std::string> &keys);
|
|
18
|
+
// A null value removes its key. False when the file could not be written.
|
|
19
|
+
bool set(const std::string &db, const std::vector<std::pair<std::string, std::optional<std::string>>> &values);
|
|
20
|
+
// Merges each value into the stored one as JSON objects, recursively; a value that is not an
|
|
21
|
+
// object, or a key with nothing stored, is set as it is.
|
|
22
|
+
bool merge(const std::string &db, const std::vector<std::pair<std::string, std::string>> &values);
|
|
23
|
+
bool remove(const std::string &db, const std::vector<std::string> &keys);
|
|
24
|
+
std::vector<std::string> keys(const std::string &db);
|
|
25
|
+
bool clear(const std::string &db);
|
|
26
|
+
|
|
27
|
+
// The database 2.x and 3.x's legacy calls share.
|
|
28
|
+
static constexpr const char *kLegacy = "RCTAsyncLocalStorage";
|
|
29
|
+
|
|
30
|
+
private:
|
|
31
|
+
std::map<std::string, std::string> &load(const std::string &db);
|
|
32
|
+
// Writes `values` as the database, and keeps them once written.
|
|
33
|
+
bool save(const std::string &db, std::map<std::string, std::string> values);
|
|
34
|
+
std::string path(const std::string &db) const;
|
|
35
|
+
|
|
36
|
+
std::string directory_;
|
|
37
|
+
std::mutex mutex_;
|
|
38
|
+
std::map<std::string, std::map<std::string, std::string>> dbs_;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
} // namespace ngn
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// NgNativeLocalLlm: what @ng-native/expo's LanguageModel calls on expo-local-llm, over a
|
|
2
|
+
// LanguageModelEngine, which the AppKit backend implements with Apple's Foundation Models on macOS
|
|
3
|
+
// 26 and later. Sessions are ids; the JS adapter (desktop-local-llm.ts) wraps them in the shape of
|
|
4
|
+
// expo-local-llm's LLMSession.
|
|
5
|
+
//
|
|
6
|
+
// - getAvailability(): expo-local-llm's names: available, notEligible (before macOS 26, or a Mac
|
|
7
|
+
// that cannot run it), notEnabled (Apple Intelligence off), notReady, unknown.
|
|
8
|
+
// - downloadModel(): resolves; macOS manages the model.
|
|
9
|
+
// - createSession(config) -> id: expo-local-llm's SessionConfig (instructions, options, tools,
|
|
10
|
+
// toolTimeout, responseFormat and schema). Throws for a config the model cannot take.
|
|
11
|
+
// - respond(id, prompt, requestId), streamResponse(id, prompt, requestId): the text, or for a
|
|
12
|
+
// json responseFormat the JSON. Rejects "CODE: message" with expo-local-llm's codes:
|
|
13
|
+
// ERR_MODEL_UNAVAILABLE while the model is not available, ERR_SESSION_BUSY while the session's
|
|
14
|
+
// last turn runs, and the model's own (ERR_CONTEXT_WINDOW_EXCEEDED and the rest). A cancelled
|
|
15
|
+
// turn resolves with the text so far.
|
|
16
|
+
// - cancelStream(id), release(id), resolveToolCall(id, callId, output),
|
|
17
|
+
// rejectToolCall(id, callId, error).
|
|
18
|
+
// - `ngNativeLocalLlm` events: {type: 'token', session, requestId, accumulated} as a stream is
|
|
19
|
+
// written, and {type: 'toolCall', session, requestId, callId, toolName, arguments} when the model
|
|
20
|
+
// calls a tool, which resolveToolCall or rejectToolCall answers.
|
|
21
|
+
#pragma once
|
|
22
|
+
|
|
23
|
+
#include "ngn/native-module.h"
|
|
24
|
+
|
|
25
|
+
#include <functional>
|
|
26
|
+
#include <memory>
|
|
27
|
+
#include <optional>
|
|
28
|
+
#include <string>
|
|
29
|
+
|
|
30
|
+
namespace ngn {
|
|
31
|
+
|
|
32
|
+
class LanguageModelEngine {
|
|
33
|
+
public:
|
|
34
|
+
struct Outcome {
|
|
35
|
+
// The text when the turn succeeded.
|
|
36
|
+
std::optional<std::string> text;
|
|
37
|
+
// expo-local-llm's code and the message when it failed; ERR_CANCELLED when it was cancelled.
|
|
38
|
+
std::string code;
|
|
39
|
+
std::string message;
|
|
40
|
+
};
|
|
41
|
+
struct ToolCall {
|
|
42
|
+
std::string id;
|
|
43
|
+
std::string tool;
|
|
44
|
+
// The arguments as JSON.
|
|
45
|
+
std::string arguments;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
class Session {
|
|
49
|
+
public:
|
|
50
|
+
// Ends the session: a running turn is cancelled, and pending tool calls rejected.
|
|
51
|
+
virtual ~Session() = default;
|
|
52
|
+
// One turn. `onText` with the text so far as a stream is written; `done` once, last. Any thread.
|
|
53
|
+
virtual void respond(const std::string &prompt, bool stream, std::function<void(const std::string &)> onText,
|
|
54
|
+
std::function<void(Outcome)> done) = 0;
|
|
55
|
+
virtual void cancel() = 0;
|
|
56
|
+
// Answers a call `onToolCall` made: the output, or the error when there is none.
|
|
57
|
+
virtual void answerTool(const std::string &callId, const std::optional<std::string> &output, const std::string &error) = 0;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
virtual ~LanguageModelEngine() = default;
|
|
61
|
+
virtual std::string availability() = 0;
|
|
62
|
+
// A session for the config as JSON, or null with the reason in `error`. `onToolCall` on any thread.
|
|
63
|
+
virtual std::unique_ptr<Session> session(const std::string &config, std::function<void(ToolCall)> onToolCall,
|
|
64
|
+
std::string &error) = 0;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
std::shared_ptr<NativeModule> makeLocalLlmModule(std::shared_ptr<LanguageModelEngine> engine);
|
|
68
|
+
|
|
69
|
+
} // namespace ngn
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Which launch's first frame starts its success timer (updates.h). A launch, the first or a
|
|
2
|
+
// reload's, owes that frame once its bundle has loaded, and a frame counts for it only when its own
|
|
3
|
+
// JavaScript instance mounted the content (MountingManager::mountedBy) and no reload has begun
|
|
4
|
+
// since. The last launch's content still on screen, or a mount it queued before the reload, never
|
|
5
|
+
// counts for the new one, and a reload whose bundle did not load owes nothing, a reload of the same
|
|
6
|
+
// launch included. Main thread only.
|
|
7
|
+
// Toolkit-free.
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <cstdint>
|
|
11
|
+
#include <optional>
|
|
12
|
+
|
|
13
|
+
namespace ngn {
|
|
14
|
+
|
|
15
|
+
class LaunchFrame {
|
|
16
|
+
public:
|
|
17
|
+
// The launch `generation` (UpdatesClient::launchGeneration) loaded its bundle into the mounting
|
|
18
|
+
// instance `instance` (MountingManager::instance).
|
|
19
|
+
void loaded(uint64_t generation, uint64_t instance) {
|
|
20
|
+
owed_ = Owed{generation, instance};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// A reload began, of this launch or a new one: the instance it replaces owes nothing now.
|
|
24
|
+
void reloadBegan() {
|
|
25
|
+
owed_.reset();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// A window shows content the instance `instance` mounted while `current` is the launch running:
|
|
29
|
+
// the launch whose success timer starts now, once.
|
|
30
|
+
std::optional<uint64_t> shown(uint64_t instance, uint64_t current) {
|
|
31
|
+
if (!owed_ || owed_->generation != current || owed_->instance != instance) {
|
|
32
|
+
return std::nullopt;
|
|
33
|
+
}
|
|
34
|
+
auto generation = owed_->generation;
|
|
35
|
+
owed_.reset();
|
|
36
|
+
return generation;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private:
|
|
40
|
+
struct Owed {
|
|
41
|
+
uint64_t generation;
|
|
42
|
+
uint64_t instance;
|
|
43
|
+
};
|
|
44
|
+
std::optional<Owed> owed_;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
} // namespace ngn
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// What the host runs and how. A dev run (the bare binary `ng-native-desktop run` starts) takes its
|
|
2
|
+
// bundle, module, title, app id and capabilities from argv, and settings such as the updates URL
|
|
3
|
+
// from the environment. A packaged app (its Info.plist names NGNBundleFile) takes all of them from
|
|
4
|
+
// its Info.plist only: argv and the environment are ignored, so nothing launching the app can make
|
|
5
|
+
// it run another bundle, as another app, or take updates from another server.
|
|
6
|
+
#pragma once
|
|
7
|
+
|
|
8
|
+
#include "ngn/updates.h"
|
|
9
|
+
|
|
10
|
+
#include <functional>
|
|
11
|
+
#include <optional>
|
|
12
|
+
#include <string>
|
|
13
|
+
#include <variant>
|
|
14
|
+
#include <vector>
|
|
15
|
+
|
|
16
|
+
namespace ngn {
|
|
17
|
+
|
|
18
|
+
struct LaunchSources {
|
|
19
|
+
// argv without the program's own name.
|
|
20
|
+
std::vector<std::string> args;
|
|
21
|
+
using Lookup = std::function<std::optional<std::string>(const std::string &)>;
|
|
22
|
+
// An environment variable.
|
|
23
|
+
Lookup env;
|
|
24
|
+
// A string in the app's Info.plist.
|
|
25
|
+
Lookup plist;
|
|
26
|
+
// The app bundle's Resources folder, where NGNBundleFile is.
|
|
27
|
+
std::string resourcePath;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// A test launch: `vitest --project macos` through @ng-native/testing starts a dev run with
|
|
31
|
+
// NGN_TESTS=1, NGN_STATE_DIR (a new empty directory), NGN_RUN_ID (unique to the launch) and
|
|
32
|
+
// NGN_TESTS_FAKE_SYSTEM_UI=1. The host keeps every piece of state under the state directory or
|
|
33
|
+
// named by the run id, so a run starts with none of an earlier one and leaves none behind, and
|
|
34
|
+
// opens its windows without taking focus. A packaged app is never a test launch.
|
|
35
|
+
struct TestLaunch {
|
|
36
|
+
std::string stateDir;
|
|
37
|
+
std::string runId;
|
|
38
|
+
// System UI (panels, permission prompts, Touch ID, alerts) answers as a person cancelling would.
|
|
39
|
+
bool fakeSystemUI{false};
|
|
40
|
+
|
|
41
|
+
std::string applicationSupport() const { return stateDir + "/Application Support"; }
|
|
42
|
+
std::string caches() const { return stateDir + "/Caches"; }
|
|
43
|
+
std::string temp() const { return stateDir + "/tmp"; }
|
|
44
|
+
// The UserDefaults suite the app's preferences go in.
|
|
45
|
+
std::string defaultsSuite() const { return keychainPrefix() + "defaults"; }
|
|
46
|
+
// What every Keychain service the app uses is prefixed with.
|
|
47
|
+
std::string keychainPrefix() const { return "ngn-test-" + runId + "."; }
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// Whether a Keychain service belongs to another test launch, one that ended without removing its
|
|
51
|
+
// items (a crash): prefixed `ngn-test-` and not `own`'s.
|
|
52
|
+
bool isStaleTestService(const std::string &service, const TestLaunch &own);
|
|
53
|
+
|
|
54
|
+
struct LaunchSettings {
|
|
55
|
+
bool packaged{false};
|
|
56
|
+
std::string bundle;
|
|
57
|
+
std::string module{"main"};
|
|
58
|
+
std::string title{"ng-native"};
|
|
59
|
+
std::string appId;
|
|
60
|
+
// A dev run's --capabilities (or NGN_DESKTOP_CAPABILITIES) JSON; a packaged app's are in its
|
|
61
|
+
// Info.plist as NGNCapabilities.
|
|
62
|
+
std::string capabilitiesJson;
|
|
63
|
+
// A dev run's --url: the link the app opens as it launches (Linking's initial URL), as a click on
|
|
64
|
+
// a link to the app's scheme would. Empty when none; a packaged app is opened on a link by the OS.
|
|
65
|
+
std::string initialUrl;
|
|
66
|
+
// Set for a test launch.
|
|
67
|
+
std::optional<TestLaunch> test;
|
|
68
|
+
// No system prompt is ever shown (NGN_NO_PROMPTS=1, or a test launch's fake system UI): a
|
|
69
|
+
// permission not decided reads as denied, and a sign-in or Touch ID as cancelled.
|
|
70
|
+
bool noPrompts{false};
|
|
71
|
+
// A dev run's switches, never a packaged app's: NGN_INPUT_SCRIPT, the input script played into
|
|
72
|
+
// the first window (input-script.h); NGN_LOG_ROTORS=1, the window's rotor items logged a second
|
|
73
|
+
// after the first frame; NGN_LOG_COMMITS=1, each commit's time logged.
|
|
74
|
+
std::string inputScript;
|
|
75
|
+
bool logRotors{false};
|
|
76
|
+
bool logCommits{false};
|
|
77
|
+
|
|
78
|
+
// A setting from the Info.plist key, or in a dev run from the environment variable when the
|
|
79
|
+
// Info.plist has none. Empty when neither has it.
|
|
80
|
+
std::string setting(const std::string &plistKey, const std::string &envName) const;
|
|
81
|
+
|
|
82
|
+
LaunchSources::Lookup env;
|
|
83
|
+
LaunchSources::Lookup plist;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// The settings, or the usage line when a dev run's argv names no bundle or is malformed, or why a
|
|
87
|
+
// test launch's environment is unusable (NGN_TESTS=1 without an absolute NGN_STATE_DIR, or with a
|
|
88
|
+
// run id that is not letters, digits and dashes).
|
|
89
|
+
std::variant<LaunchSettings, std::string> launchSettings(LaunchSources sources);
|
|
90
|
+
|
|
91
|
+
// The Expo Updates client's settings: NGNUpdatesURL, NGNRuntimeVersion, NGNUpdatesPlatform,
|
|
92
|
+
// NGNUpdatesCodeSigningCertificate (PEM), NGNUpdatesCodeSigningKeyId and
|
|
93
|
+
// NGNUpdatesCodeSigningAlg, and in a dev run NGN_UPDATES_URL and the rest, as `setting` reads
|
|
94
|
+
// them. Updates are kept in `appData`/updates; `embeddedBundle` runs without one. Off (no url)
|
|
95
|
+
// without a runtime version.
|
|
96
|
+
UpdatesConfig updatesConfigFrom(const LaunchSettings &settings, const std::string &appData, const std::string &embeddedBundle);
|
|
97
|
+
|
|
98
|
+
} // namespace ngn
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// React Native's layout animations on the desktop host: LayoutAnimation, and the engine's CSS
|
|
2
|
+
// transitions of a size or a place, which it commits where they end and asks native to move the
|
|
3
|
+
// view there. ReactCxxPlatform's ReactHost makes its Scheduler with no animation delegate, so
|
|
4
|
+
// configureNextLayoutAnimation did nothing and such a transition jumped to its end. The build
|
|
5
|
+
// patches ReactHost to make its Scheduler here (cmake/react-native.cmake), with React Native's
|
|
6
|
+
// LayoutAnimationDriver, as React Native iOS's RCTScheduler does.
|
|
7
|
+
#pragma once
|
|
8
|
+
|
|
9
|
+
#include <react/renderer/scheduler/Scheduler.h>
|
|
10
|
+
|
|
11
|
+
#include <functional>
|
|
12
|
+
#include <memory>
|
|
13
|
+
|
|
14
|
+
namespace ngn {
|
|
15
|
+
|
|
16
|
+
std::unique_ptr<facebook::react::Scheduler> makeScheduler(
|
|
17
|
+
const facebook::react::SchedulerToolbox &toolbox,
|
|
18
|
+
facebook::react::SchedulerDelegate *delegate);
|
|
19
|
+
|
|
20
|
+
// Called, on any thread, as layout animations start running and once all of them are done. While
|
|
21
|
+
// they run, the host calls Runtime::animationTick each frame.
|
|
22
|
+
void onLayoutAnimationsRunning(std::function<void(bool running)> handler);
|
|
23
|
+
|
|
24
|
+
} // namespace ngn
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// The Fabric components of the libraries compiled into this host (cmake/libraries.cmake generates
|
|
2
|
+
// the definition from the build's NGN_LIBRARIES). Empty when the build names no library.
|
|
3
|
+
#pragma once
|
|
4
|
+
|
|
5
|
+
#include <react/renderer/componentregistry/ComponentDescriptorProvider.h>
|
|
6
|
+
|
|
7
|
+
#include <vector>
|
|
8
|
+
|
|
9
|
+
namespace ngn {
|
|
10
|
+
|
|
11
|
+
std::vector<facebook::react::ComponentDescriptorProvider> libraryComponents();
|
|
12
|
+
|
|
13
|
+
} // namespace ngn
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// What the core reads and writes of the libraries' own component types (their props and state),
|
|
2
|
+
// which only a host built with the library can name. Each library's glue fills this in as the host
|
|
3
|
+
// registers its components (cmake/libraries.cmake); a host built without it leaves it empty.
|
|
4
|
+
#pragma once
|
|
5
|
+
|
|
6
|
+
#include "ngn/header-bar.h"
|
|
7
|
+
#include "ngn/module-registry.h"
|
|
8
|
+
#include "ngn/svg.h"
|
|
9
|
+
#include "ngn/tabs-host.h"
|
|
10
|
+
#include "ngn/web-view.h"
|
|
11
|
+
|
|
12
|
+
#include <react/renderer/componentregistry/ComponentDescriptorProvider.h>
|
|
13
|
+
|
|
14
|
+
#include <react/renderer/core/State.h>
|
|
15
|
+
#include <react/renderer/mounting/ShadowView.h>
|
|
16
|
+
#include <react/renderer/graphics/RectangleEdges.h>
|
|
17
|
+
|
|
18
|
+
#include <functional>
|
|
19
|
+
#include <map>
|
|
20
|
+
#include <optional>
|
|
21
|
+
#include <string>
|
|
22
|
+
#include <vector>
|
|
23
|
+
|
|
24
|
+
namespace ngn {
|
|
25
|
+
|
|
26
|
+
struct LibraryGlue {
|
|
27
|
+
std::function<std::optional<HeaderBar>(const facebook::react::Props &)> headerBar;
|
|
28
|
+
std::function<std::optional<std::string>(const facebook::react::Props &)> headerItemType;
|
|
29
|
+
std::function<std::optional<SearchBarConfig>(const facebook::react::Props &)> searchBarConfig;
|
|
30
|
+
// Each sets a safe-area view's insets through its state, and answers false for another state.
|
|
31
|
+
std::vector<std::function<bool(const facebook::react::State &, facebook::react::EdgeInsets)>> safeAreaStates;
|
|
32
|
+
// Each reads how far a safe-area view's mounted state moves it (the margin its insets add), and
|
|
33
|
+
// answers nothing for a view that pads its content instead, or another library's view.
|
|
34
|
+
std::vector<std::function<std::optional<facebook::react::EdgeInsets>(const facebook::react::ShadowView &)>>
|
|
35
|
+
safeAreaMargins;
|
|
36
|
+
std::function<std::optional<TabScreen>(const facebook::react::Props &)> tabScreen;
|
|
37
|
+
std::function<std::optional<TabsRequest>(const facebook::react::Props &)> tabsRequest;
|
|
38
|
+
// The svg element a view's props are (svg.h), from react-native-svg's props.
|
|
39
|
+
std::function<std::optional<SvgElement>(const facebook::react::Props &)> svgElement;
|
|
40
|
+
// A web view's config (web-view.h), from react-native-webview's props.
|
|
41
|
+
std::function<std::optional<WebViewConfig>(const facebook::react::Props &)> webViewConfig;
|
|
42
|
+
// Components the desktop draws its own way, registered before the library's own and in place of
|
|
43
|
+
// any of theirs with the same name.
|
|
44
|
+
std::vector<facebook::react::ComponentDescriptorProvider> components;
|
|
45
|
+
// TurboModules the library's glue implements in place of its iOS module (react-native-worklets'
|
|
46
|
+
// WorkletsModule, Reanimated's ReanimatedModule), by name. The registry asks these after the
|
|
47
|
+
// core's own modules.
|
|
48
|
+
std::map<std::string, ModuleRegistry::Factory> modules;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
LibraryGlue &libraryGlue();
|
|
52
|
+
|
|
53
|
+
} // namespace ngn
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Live regions (`accessibilityLiveRegion`, `aria-live`): what each one says when its text
|
|
2
|
+
// changes, as Android and the web announce it. AppKit has no live-region property a native view can
|
|
3
|
+
// set, so the host announces the region's new text itself.
|
|
4
|
+
//
|
|
5
|
+
// A region says nothing as it appears, nor when its text empties; after that, each transaction
|
|
6
|
+
// that leaves it with other text than before announces that text, politely for `polite` and
|
|
7
|
+
// interrupting for `assertive`. Its text is its label when it has one, otherwise the text of the
|
|
8
|
+
// views under it in tree order, each one's label or its paragraph's string, leaving out hidden
|
|
9
|
+
// ones.
|
|
10
|
+
#pragma once
|
|
11
|
+
|
|
12
|
+
#include "ngn/system.h"
|
|
13
|
+
#include "ngn/view-tree.h"
|
|
14
|
+
|
|
15
|
+
#include <functional>
|
|
16
|
+
#include <map>
|
|
17
|
+
#include <string>
|
|
18
|
+
#include <vector>
|
|
19
|
+
|
|
20
|
+
namespace ngn {
|
|
21
|
+
|
|
22
|
+
class LiveRegions {
|
|
23
|
+
public:
|
|
24
|
+
// The text a view holds itself: a paragraph's string, empty for anything else.
|
|
25
|
+
using TextOf = std::function<std::string(const ShadowView &)>;
|
|
26
|
+
|
|
27
|
+
explicit LiveRegions(const ViewTree &tree, TextOf textOf);
|
|
28
|
+
|
|
29
|
+
// A view was created or its props changed: it may have become a region or stopped being one.
|
|
30
|
+
void update(const ShadowView &view);
|
|
31
|
+
void remove(Tag tag);
|
|
32
|
+
|
|
33
|
+
// After a transaction on `surfaceId`: what its regions whose text changed say.
|
|
34
|
+
std::vector<Announcement> didMount(SurfaceId surfaceId);
|
|
35
|
+
|
|
36
|
+
private:
|
|
37
|
+
struct Region {
|
|
38
|
+
SurfaceId surfaceId;
|
|
39
|
+
AnnouncementPriority priority;
|
|
40
|
+
std::string text;
|
|
41
|
+
// Not yet read: its first text is what it holds, not news.
|
|
42
|
+
bool fresh{true};
|
|
43
|
+
};
|
|
44
|
+
// The view or one of its ancestors hides itself and what is under it.
|
|
45
|
+
bool hiddenAt(Tag tag) const;
|
|
46
|
+
std::string textOf(Tag tag) const;
|
|
47
|
+
void collect(Tag tag, std::string &out) const;
|
|
48
|
+
|
|
49
|
+
const ViewTree &tree_;
|
|
50
|
+
TextOf textOf_;
|
|
51
|
+
std::map<Tag, Region> regions_;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
} // namespace ngn
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// NgNativeLocalAuthentication: expo-local-authentication's calls over an Authenticator, which the
|
|
2
|
+
// AppKit backend implements with LAContext (Touch ID, the login password, an Apple Watch).
|
|
3
|
+
//
|
|
4
|
+
// - hasHardwareAsync, isEnrolledAsync, supportedAuthenticationTypesAsync (1 fingerprint, 2 face,
|
|
5
|
+
// 3 iris) and getEnrolledLevelAsync (0 none, 1 a password, 3 strong biometrics).
|
|
6
|
+
// - authenticateAsync({promptMessage, cancelLabel, fallbackLabel, disableDeviceFallback}):
|
|
7
|
+
// {success: true}, or {success: false, error} with expo's iOS error names. The password stands
|
|
8
|
+
// in for Touch ID unless disableDeviceFallback is set. With it set, a call Touch ID cannot answer
|
|
9
|
+
// (none, nothing enrolled, locked out, the lid closed) fails at once, with no prompt.
|
|
10
|
+
// - cancelAuthenticate: ends the prompt in progress, which answers `app_cancel`.
|
|
11
|
+
#pragma once
|
|
12
|
+
|
|
13
|
+
#include "ngn/native-module.h"
|
|
14
|
+
|
|
15
|
+
#include <functional>
|
|
16
|
+
#include <memory>
|
|
17
|
+
#include <optional>
|
|
18
|
+
#include <string>
|
|
19
|
+
#include <vector>
|
|
20
|
+
|
|
21
|
+
namespace ngn {
|
|
22
|
+
|
|
23
|
+
class Authenticator {
|
|
24
|
+
public:
|
|
25
|
+
enum class Biometry { None, TouchId, FaceId, OpticId };
|
|
26
|
+
|
|
27
|
+
// Why an evaluation failed, as LAError says it.
|
|
28
|
+
enum class Failure {
|
|
29
|
+
AuthenticationFailed,
|
|
30
|
+
UserCancel,
|
|
31
|
+
UserFallback,
|
|
32
|
+
SystemCancel,
|
|
33
|
+
AppCancel,
|
|
34
|
+
PasscodeNotSet,
|
|
35
|
+
BiometryNotAvailable,
|
|
36
|
+
BiometryNotEnrolled,
|
|
37
|
+
BiometryLockout,
|
|
38
|
+
InvalidContext,
|
|
39
|
+
NotInteractive,
|
|
40
|
+
Other,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
struct Facts {
|
|
44
|
+
// The kind of biometry the Mac has, whether or not it can be used.
|
|
45
|
+
Biometry biometry{Biometry::None};
|
|
46
|
+
// Why it cannot be used now: nothing enrolled, locked out, or the lid closed (SystemCancel).
|
|
47
|
+
// Nothing when it can.
|
|
48
|
+
std::optional<Failure> biometryUnusable;
|
|
49
|
+
bool passwordSet{false};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
struct Request {
|
|
53
|
+
std::string reason;
|
|
54
|
+
// Nothing for the system's own titles; an empty fallback title hides the fallback button.
|
|
55
|
+
std::optional<std::string> cancelTitle;
|
|
56
|
+
std::optional<std::string> fallbackTitle;
|
|
57
|
+
// Touch ID only, without the password as a fallback.
|
|
58
|
+
bool biometricsOnly{false};
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
virtual ~Authenticator() = default;
|
|
62
|
+
virtual Facts facts() = 0;
|
|
63
|
+
// Answers once, on any thread: nothing on success.
|
|
64
|
+
virtual void evaluate(const Request &request, std::function<void(std::optional<Failure>)> done) = 0;
|
|
65
|
+
// Ends the evaluation in progress, if any.
|
|
66
|
+
virtual void cancel() = 0;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// expo-local-authentication's name for a failure: "user_cancel", "lockout" and the rest.
|
|
70
|
+
std::string authenticationError(Authenticator::Failure failure);
|
|
71
|
+
|
|
72
|
+
std::shared_ptr<NativeModule> makeLocalAuthenticationModule(std::shared_ptr<Authenticator> authenticator);
|
|
73
|
+
|
|
74
|
+
} // namespace ngn
|