@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,64 @@
|
|
|
1
|
+
// NgNativeFont: what @ng-native/expo's Fonts calls on expo-font, over a FontRegistrar, which the
|
|
2
|
+
// AppKit backend implements with CTFontManager, registering a font for this process only.
|
|
3
|
+
//
|
|
4
|
+
// - loadAsync(name, uri): registers the font file a `file:` uri or an absolute path names, or that
|
|
5
|
+
// an `http(s):` uri serves (an asset from the dev server), downloaded into the cache first, and
|
|
6
|
+
// makes `name` stand for its family. A file registered before is not registered again. A file
|
|
7
|
+
// is read only where `files` lets it (FileAccess::readFor), and refused in the same words
|
|
8
|
+
// whether or not it is there.
|
|
9
|
+
// - isLoaded(name), getLoadedFonts(): the names loaded, in the order they were.
|
|
10
|
+
// Text asks for a font by its name: FontLibrary::familyOf answers the family it stands for, as
|
|
11
|
+
// expo-font's alias does on iOS, so text in that family picks its weight among the faces loaded.
|
|
12
|
+
#pragma once
|
|
13
|
+
|
|
14
|
+
#include "ngn/native-module.h"
|
|
15
|
+
#include "ngn/file-system.h"
|
|
16
|
+
#include "ngn/network.h"
|
|
17
|
+
|
|
18
|
+
#include <map>
|
|
19
|
+
#include <memory>
|
|
20
|
+
#include <mutex>
|
|
21
|
+
#include <optional>
|
|
22
|
+
#include <string>
|
|
23
|
+
#include <vector>
|
|
24
|
+
|
|
25
|
+
namespace ngn {
|
|
26
|
+
|
|
27
|
+
struct RegisteredFont {
|
|
28
|
+
std::string family;
|
|
29
|
+
std::string postScriptName;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
class FontRegistrar {
|
|
33
|
+
public:
|
|
34
|
+
virtual ~FontRegistrar() = default;
|
|
35
|
+
// Registers the first face in the file at `path`, or one already registered, for this process.
|
|
36
|
+
// Throws std::runtime_error with the OS's reason when it cannot.
|
|
37
|
+
virtual RegisteredFont registerFile(const std::string &path) = 0;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// The names fonts are loaded under, for the process: one library both the module and text layout
|
|
41
|
+
// read, kept across reloads, as the registered fonts are. Any thread.
|
|
42
|
+
class FontLibrary {
|
|
43
|
+
public:
|
|
44
|
+
void add(const std::string &name, RegisteredFont font);
|
|
45
|
+
bool has(const std::string &name) const;
|
|
46
|
+
// The family `name` stands for, or nothing for a name no font was loaded under.
|
|
47
|
+
std::optional<RegisteredFont> fontOf(const std::string &name) const;
|
|
48
|
+
std::vector<std::string> names() const;
|
|
49
|
+
|
|
50
|
+
private:
|
|
51
|
+
mutable std::mutex mutex_;
|
|
52
|
+
std::map<std::string, RegisteredFont> fonts_;
|
|
53
|
+
std::vector<std::string> order_;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// `downloads` is where a font served over http(s) is saved before it is registered.
|
|
57
|
+
std::shared_ptr<NativeModule> makeFontModule(
|
|
58
|
+
std::shared_ptr<FontRegistrar> registrar,
|
|
59
|
+
std::shared_ptr<FontLibrary> library,
|
|
60
|
+
std::shared_ptr<Http> http,
|
|
61
|
+
std::string downloads,
|
|
62
|
+
std::shared_ptr<FileAccess> files);
|
|
63
|
+
|
|
64
|
+
} // namespace ngn
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
// react-native-gesture-handler's recognisers on the desktop, toolkit-free: the handlers
|
|
2
|
+
// RNGestureHandlerModule creates (pan, tap, long press, pinch, rotation, hover, native, manual,
|
|
3
|
+
// fling), their state machine, and the orchestrator that settles them against each other through
|
|
4
|
+
// their relations (simultaneous, requireToFail, blocksHandlers). Ported from the library's own
|
|
5
|
+
// shared implementation (src/web/handlers and src/web/tools/GestureHandlerOrchestrator.ts), which
|
|
6
|
+
// is the logic UIKit's recognisers give it on iOS.
|
|
7
|
+
//
|
|
8
|
+
// The backend's input comes in through the core's InputDispatcher, which hit-tests it against the
|
|
9
|
+
// ViewTree and hands it here in page coordinates (the surface's): presses and drags of the mouse,
|
|
10
|
+
// a trackpad's two-finger scroll, magnify and rotate, and hover. Events leave as the library's
|
|
11
|
+
// iOS module sends them: a JavaScript gesture's as RCTDeviceEventEmitter's
|
|
12
|
+
// `onGestureHandlerStateChange`, a worklet gesture's to Reanimated on the UI thread.
|
|
13
|
+
//
|
|
14
|
+
// UI thread only, like the tree it reads.
|
|
15
|
+
#pragma once
|
|
16
|
+
|
|
17
|
+
#include "ngn/input.h"
|
|
18
|
+
#include "ngn/view-tree.h"
|
|
19
|
+
|
|
20
|
+
#include <folly/dynamic.h>
|
|
21
|
+
#include <react/renderer/graphics/Point.h>
|
|
22
|
+
|
|
23
|
+
#include <deque>
|
|
24
|
+
#include <functional>
|
|
25
|
+
#include <map>
|
|
26
|
+
#include <memory>
|
|
27
|
+
#include <optional>
|
|
28
|
+
#include <string>
|
|
29
|
+
#include <vector>
|
|
30
|
+
|
|
31
|
+
namespace ngn {
|
|
32
|
+
|
|
33
|
+
using facebook::react::Point;
|
|
34
|
+
|
|
35
|
+
// `State` in react-native-gesture-handler.
|
|
36
|
+
enum class GestureState : int { Undetermined = 0, Failed = 1, Began = 2, Cancelled = 3, Active = 4, End = 5 };
|
|
37
|
+
|
|
38
|
+
// `ActionType`: how the handler's events reach JavaScript.
|
|
39
|
+
enum class GestureAction : int {
|
|
40
|
+
None = 0,
|
|
41
|
+
ReanimatedWorklet = 1,
|
|
42
|
+
NativeAnimatedEvent = 2,
|
|
43
|
+
JsFunctionOldApi = 3,
|
|
44
|
+
JsFunctionNewApi = 4,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// A pointer as the handlers see it: in the surface's coordinates, the time in milliseconds.
|
|
48
|
+
struct GesturePointer {
|
|
49
|
+
int id{0};
|
|
50
|
+
Point page{};
|
|
51
|
+
double time{0};
|
|
52
|
+
// The DOM's `button`: 0 primary, 1 middle, 2 secondary.
|
|
53
|
+
int button{0};
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class Gestures;
|
|
58
|
+
|
|
59
|
+
class GestureHandler {
|
|
60
|
+
public:
|
|
61
|
+
GestureHandler(Gestures &owner, int tag, std::string name);
|
|
62
|
+
virtual ~GestureHandler() = default;
|
|
63
|
+
|
|
64
|
+
int tag() const {
|
|
65
|
+
return tag_;
|
|
66
|
+
}
|
|
67
|
+
const std::string &name() const {
|
|
68
|
+
return name_;
|
|
69
|
+
}
|
|
70
|
+
GestureState state() const {
|
|
71
|
+
return state_;
|
|
72
|
+
}
|
|
73
|
+
Tag view() const {
|
|
74
|
+
return view_;
|
|
75
|
+
}
|
|
76
|
+
GestureAction action() const {
|
|
77
|
+
return action_;
|
|
78
|
+
}
|
|
79
|
+
bool enabled() const {
|
|
80
|
+
return enabled_;
|
|
81
|
+
}
|
|
82
|
+
size_t trackedPointers() const {
|
|
83
|
+
return pointers_.size();
|
|
84
|
+
}
|
|
85
|
+
bool tracks(int pointerId) const {
|
|
86
|
+
return pointers_.count(pointerId) > 0;
|
|
87
|
+
}
|
|
88
|
+
bool isNative() const {
|
|
89
|
+
return name_ == "NativeViewGestureHandler";
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Config from JavaScript (the library's ALLOWED_PROPS). `reset` starts from the defaults
|
|
93
|
+
// (setGestureHandlerConfig); without it the keys given change what they name.
|
|
94
|
+
void configure(const folly::dynamic &config, bool reset);
|
|
95
|
+
void attach(Tag view, GestureAction action);
|
|
96
|
+
void setRelations(std::vector<int> waitFor, std::vector<int> simultaneous, std::vector<int> blocks);
|
|
97
|
+
|
|
98
|
+
// The input, as the orchestrator routes it.
|
|
99
|
+
virtual void pointerDown(const GesturePointer &pointer);
|
|
100
|
+
virtual void pointerMove(const GesturePointer &pointer, bool inBounds);
|
|
101
|
+
virtual void pointerUp(const GesturePointer &pointer);
|
|
102
|
+
virtual void pointerCancel();
|
|
103
|
+
// The pointer moved over the view, or out of it, with no button down.
|
|
104
|
+
virtual void hover(const GesturePointer &, bool /*inside*/) {}
|
|
105
|
+
// A trackpad's two-finger scroll over the view, `delta` as the fingers moved, in points.
|
|
106
|
+
virtual void scroll(const GesturePointer &, Point /*delta*/, std::optional<GesturePhase> /*phase*/) {}
|
|
107
|
+
virtual void magnify(const GesturePointer &, double /*magnification*/, GesturePhase) {}
|
|
108
|
+
// `degrees` anticlockwise, as AppKit reports a rotation.
|
|
109
|
+
virtual void rotate(const GesturePointer &, double /*degrees*/, GesturePhase) {}
|
|
110
|
+
// Whether the handler wants this kind of input at all, to be routed to it.
|
|
111
|
+
virtual bool wantsHover() const {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
virtual bool wantsScroll() const {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
virtual bool wantsMagnify() const {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
virtual bool wantsRotate() const {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// The pointer is outside the view: a handler that cancels outside it fails, or is cancelled
|
|
125
|
+
// once active, as the library's handlers do. True when it does, and the input stops there.
|
|
126
|
+
bool leaveBounds();
|
|
127
|
+
|
|
128
|
+
void begin();
|
|
129
|
+
void fail();
|
|
130
|
+
void cancel();
|
|
131
|
+
virtual void activate(bool force = false);
|
|
132
|
+
void end();
|
|
133
|
+
void reset();
|
|
134
|
+
|
|
135
|
+
// The orchestrator's bookkeeping.
|
|
136
|
+
bool active{false};
|
|
137
|
+
bool awaiting{false};
|
|
138
|
+
size_t activationIndex{0};
|
|
139
|
+
|
|
140
|
+
bool shouldWaitFor(const GestureHandler &other) const;
|
|
141
|
+
bool requiresToWaitFor(const GestureHandler &other) const;
|
|
142
|
+
bool recognizesSimultaneously(const GestureHandler &other) const;
|
|
143
|
+
bool cancelledBy(const GestureHandler &other) const;
|
|
144
|
+
bool sharesPointers(const GestureHandler &other) const;
|
|
145
|
+
|
|
146
|
+
// The event payload: what this handler adds (translation, scale) to the position and pointers.
|
|
147
|
+
folly::dynamic eventData() const;
|
|
148
|
+
// A touch event (onTouchesDown and the rest) for a handler that needs pointer data.
|
|
149
|
+
void sendTouches(int eventType, const GesturePointer &changed);
|
|
150
|
+
|
|
151
|
+
protected:
|
|
152
|
+
virtual void readConfig(const folly::dynamic &config);
|
|
153
|
+
virtual void resetConfig();
|
|
154
|
+
virtual folly::dynamic extraData() const;
|
|
155
|
+
virtual void onCancel() {}
|
|
156
|
+
virtual void onReset() {}
|
|
157
|
+
virtual void resetProgress() {}
|
|
158
|
+
virtual void onStateChange(GestureState, GestureState) {}
|
|
159
|
+
|
|
160
|
+
void moveToState(GestureState next);
|
|
161
|
+
bool buttonAllowed(int button) const;
|
|
162
|
+
void track(const GesturePointer &pointer);
|
|
163
|
+
void untrack(int pointerId);
|
|
164
|
+
Point average() const;
|
|
165
|
+
Point velocity() const;
|
|
166
|
+
// A point in the surface in the handler's view, through its transforms, as UIKit's locationInView:.
|
|
167
|
+
Point local(Point page) const;
|
|
168
|
+
// Runs `fn` after `ms` unless the handler resets first.
|
|
169
|
+
void after(double ms, std::function<void()> fn);
|
|
170
|
+
void clearTimer();
|
|
171
|
+
|
|
172
|
+
Gestures &owner_;
|
|
173
|
+
struct Track {
|
|
174
|
+
Point page;
|
|
175
|
+
std::deque<std::pair<double, Point>> samples;
|
|
176
|
+
};
|
|
177
|
+
std::map<int, Track> pointers_;
|
|
178
|
+
Point lastAverage_{};
|
|
179
|
+
bool shouldCancelWhenOutside_{false};
|
|
180
|
+
bool needsPointerData_{false};
|
|
181
|
+
bool manualActivation_{false};
|
|
182
|
+
// A bitmask of the library's MouseButton (1 left, 2 right, 4 middle); nothing means left.
|
|
183
|
+
std::optional<int> mouseButton_;
|
|
184
|
+
|
|
185
|
+
private:
|
|
186
|
+
int tag_;
|
|
187
|
+
std::string name_;
|
|
188
|
+
Tag view_{-1};
|
|
189
|
+
GestureAction action_{GestureAction::None};
|
|
190
|
+
GestureState state_{GestureState::Undetermined};
|
|
191
|
+
std::optional<GestureState> lastSent_;
|
|
192
|
+
bool enabled_{true};
|
|
193
|
+
std::vector<int> waitFor_, simultaneous_, blocks_;
|
|
194
|
+
std::function<void()> cancelTimer_;
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
// The registry and the orchestrator.
|
|
198
|
+
class Gestures {
|
|
199
|
+
public:
|
|
200
|
+
using Schedule = std::function<std::function<void()>(double ms, std::function<void()> fn)>;
|
|
201
|
+
|
|
202
|
+
Gestures(const ViewTree &tree, Schedule schedule);
|
|
203
|
+
~Gestures();
|
|
204
|
+
|
|
205
|
+
// RNGestureHandlerModule's methods.
|
|
206
|
+
void create(const std::string &name, int handlerTag, const folly::dynamic &config);
|
|
207
|
+
void attach(int handlerTag, Tag view, GestureAction action);
|
|
208
|
+
void configure(int handlerTag, const folly::dynamic &config, bool reset);
|
|
209
|
+
void relations(int handlerTag, const folly::dynamic &relations);
|
|
210
|
+
void drop(int handlerTag);
|
|
211
|
+
// A worklet's GestureStateManager (manual activation): begin, activate, fail, end or cancel.
|
|
212
|
+
void setState(int handlerTag, int state);
|
|
213
|
+
// Every handler, as a runtime reloads.
|
|
214
|
+
void clear();
|
|
215
|
+
|
|
216
|
+
// The input. `chain` is the hit test under the pointer, from the surface's root to the deepest.
|
|
217
|
+
void pointerDown(SurfaceId surface, const std::vector<Tag> &chain, const GesturePointer &pointer);
|
|
218
|
+
void pointerMove(const GesturePointer &pointer);
|
|
219
|
+
void pointerUp(const GesturePointer &pointer);
|
|
220
|
+
void pointerCancel();
|
|
221
|
+
void hover(SurfaceId surface, const std::vector<Tag> &chain, const GesturePointer &pointer);
|
|
222
|
+
// True when a handler took the scroll, so it should not also scroll the view under it.
|
|
223
|
+
bool scroll(
|
|
224
|
+
SurfaceId surface,
|
|
225
|
+
const std::vector<Tag> &chain,
|
|
226
|
+
const GesturePointer &pointer,
|
|
227
|
+
Point delta,
|
|
228
|
+
std::optional<GesturePhase> phase);
|
|
229
|
+
void magnify(SurfaceId surface, const std::vector<Tag> &chain, const GesturePointer &pointer, double magnification, GesturePhase phase);
|
|
230
|
+
void rotate(SurfaceId surface, const std::vector<Tag> &chain, const GesturePointer &pointer, double degrees, GesturePhase phase);
|
|
231
|
+
|
|
232
|
+
// Whether any handler is attached to a view of `chain`.
|
|
233
|
+
bool handles(const std::vector<Tag> &chain) const;
|
|
234
|
+
|
|
235
|
+
// Where events go. `name` is `onGestureHandlerEvent` or `onGestureHandlerStateChange`.
|
|
236
|
+
// A JavaScript gesture's events: RCTDeviceEventEmitter, under `onGestureHandlerStateChange` for
|
|
237
|
+
// both kinds, as the library's iOS module sends them.
|
|
238
|
+
std::function<void(const folly::dynamic &body)> onDeviceEvent;
|
|
239
|
+
// A worklet gesture's: Reanimated's event handlers registered on the view.
|
|
240
|
+
std::function<void(const std::string &name, Tag view, const folly::dynamic &body)> onWorkletEvent;
|
|
241
|
+
// A handler other than a native one went active: the press JavaScript was told of is cancelled,
|
|
242
|
+
// as the library's root view recogniser cancels React Native's touches on iOS.
|
|
243
|
+
std::function<void()> onClaim;
|
|
244
|
+
|
|
245
|
+
const ViewTree &tree() const {
|
|
246
|
+
return tree_;
|
|
247
|
+
}
|
|
248
|
+
SurfaceId surface() const {
|
|
249
|
+
return surface_;
|
|
250
|
+
}
|
|
251
|
+
double now() const {
|
|
252
|
+
return now_;
|
|
253
|
+
}
|
|
254
|
+
const Schedule &schedule() const {
|
|
255
|
+
return schedule_;
|
|
256
|
+
}
|
|
257
|
+
// Runs a handler's timer `fn`, due at `due` on the pointer's clock: the clock moves on to it
|
|
258
|
+
// first, and the handlers are settled after it, as after any input.
|
|
259
|
+
void runScheduled(double due, const std::function<void()> &fn);
|
|
260
|
+
GestureHandler *find(int handlerTag) const;
|
|
261
|
+
|
|
262
|
+
// From the handlers.
|
|
263
|
+
void stateChanged(GestureHandler &handler, GestureState next, GestureState previous);
|
|
264
|
+
void send(GestureHandler &handler, GestureState next, GestureState previous);
|
|
265
|
+
void sendEvent(GestureHandler &handler, const std::string &name, folly::dynamic body);
|
|
266
|
+
void record(GestureHandler &handler);
|
|
267
|
+
bool recorded(const GestureHandler &handler) const;
|
|
268
|
+
|
|
269
|
+
private:
|
|
270
|
+
std::vector<GestureHandler *> handlersOn(const std::vector<Tag> &chain) const;
|
|
271
|
+
bool inBounds(const GestureHandler &handler, Point page) const;
|
|
272
|
+
void cleanup();
|
|
273
|
+
void tryActivate(GestureHandler &handler);
|
|
274
|
+
bool shouldActivate(GestureHandler &handler) const;
|
|
275
|
+
void makeActive(GestureHandler &handler);
|
|
276
|
+
void addAwaiting(GestureHandler &handler);
|
|
277
|
+
void cleanupAwaiting(GestureHandler &handler);
|
|
278
|
+
bool waitsFor(const GestureHandler &handler, const GestureHandler &other) const;
|
|
279
|
+
bool simultaneous(const GestureHandler &a, const GestureHandler &b) const;
|
|
280
|
+
bool cancelledBy(const GestureHandler &handler, const GestureHandler &other) const;
|
|
281
|
+
bool hasToWait(const GestureHandler &handler) const;
|
|
282
|
+
bool cancelledByFinished(const GestureHandler &handler) const;
|
|
283
|
+
static bool finished(GestureState state);
|
|
284
|
+
void cleanHandler(GestureHandler &handler);
|
|
285
|
+
// Handlers the input is going to, settled after it as the library's microtask does.
|
|
286
|
+
void settle();
|
|
287
|
+
|
|
288
|
+
const ViewTree &tree_;
|
|
289
|
+
Schedule schedule_;
|
|
290
|
+
std::map<int, std::unique_ptr<GestureHandler>> handlers_;
|
|
291
|
+
std::vector<GestureHandler *> recorded_;
|
|
292
|
+
std::vector<GestureHandler *> awaiting_;
|
|
293
|
+
size_t activationIndex_{0};
|
|
294
|
+
int changing_{0};
|
|
295
|
+
SurfaceId surface_{-1};
|
|
296
|
+
double now_{0};
|
|
297
|
+
// The handlers the press went to, which follow it until it is released.
|
|
298
|
+
std::vector<int> pressed_;
|
|
299
|
+
std::vector<int> hovered_;
|
|
300
|
+
std::vector<int> scrolling_;
|
|
301
|
+
std::vector<int> magnifying_;
|
|
302
|
+
std::vector<int> rotating_;
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
} // namespace ngn
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// `<expo-glass>` and `<expo-glass-container>` on a desktop host: expo-glass-effect's views
|
|
2
|
+
// (ViewManagerAdapter_ExpoGlassEffect_GlassView and _GlassContainer, the components
|
|
3
|
+
// `registerExpoViews('expo-glass', 'expo-glass-container')` commits) as Fabric components.
|
|
4
|
+
//
|
|
5
|
+
// The core reads the props into the glass to draw (glassOf); the backend draws it with its
|
|
6
|
+
// toolkit's material behind the view's children, in the view's own corners. On macOS that is
|
|
7
|
+
// NSGlassEffectView from macOS 26 and an NSVisualEffectView before it, as the iOS view is a plain
|
|
8
|
+
// view before iOS 26. A container is a plain view on macOS: its glass views each draw their own.
|
|
9
|
+
#pragma once
|
|
10
|
+
|
|
11
|
+
#include "ngn/desktop-props.h"
|
|
12
|
+
|
|
13
|
+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
14
|
+
#include <react/renderer/components/view/ViewEventEmitter.h>
|
|
15
|
+
#include <react/renderer/components/view/ViewProps.h>
|
|
16
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
17
|
+
#include <react/renderer/graphics/Color.h>
|
|
18
|
+
|
|
19
|
+
#include <folly/dynamic.h>
|
|
20
|
+
|
|
21
|
+
#include <optional>
|
|
22
|
+
#include <string>
|
|
23
|
+
|
|
24
|
+
namespace ngn {
|
|
25
|
+
|
|
26
|
+
extern const char GlassViewComponentName[];
|
|
27
|
+
extern const char GlassContainerComponentName[];
|
|
28
|
+
|
|
29
|
+
class GlassProps final : public facebook::react::ViewProps, public HasDesktopProps {
|
|
30
|
+
public:
|
|
31
|
+
GlassProps() = default;
|
|
32
|
+
GlassProps(
|
|
33
|
+
const facebook::react::PropsParserContext &context,
|
|
34
|
+
const GlassProps &sourceProps,
|
|
35
|
+
const facebook::react::RawProps &rawProps);
|
|
36
|
+
|
|
37
|
+
// `regular`, `clear` or `none`, or `{ style, animate, animationDuration }`, as the app sends it.
|
|
38
|
+
folly::dynamic glassEffectStyle;
|
|
39
|
+
facebook::react::SharedColor tintColor;
|
|
40
|
+
bool isInteractive{false};
|
|
41
|
+
// `auto`, `light` or `dark`.
|
|
42
|
+
std::string colorScheme;
|
|
43
|
+
// The container's.
|
|
44
|
+
double spacing{0};
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// The glass a view draws: nothing for `none`.
|
|
48
|
+
struct Glass {
|
|
49
|
+
enum class Style { Regular, Clear };
|
|
50
|
+
Style style{Style::Regular};
|
|
51
|
+
facebook::react::SharedColor tint;
|
|
52
|
+
bool interactive{false};
|
|
53
|
+
// Unset follows the app's appearance.
|
|
54
|
+
std::optional<bool> dark;
|
|
55
|
+
bool operator==(const Glass &) const = default;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
std::optional<Glass> glassOf(const GlassProps &props);
|
|
59
|
+
|
|
60
|
+
using GlassViewShadowNode =
|
|
61
|
+
facebook::react::ConcreteViewShadowNode<GlassViewComponentName, GlassProps, facebook::react::ViewEventEmitter>;
|
|
62
|
+
using GlassViewComponentDescriptor = facebook::react::ConcreteComponentDescriptor<GlassViewShadowNode>;
|
|
63
|
+
using GlassContainerShadowNode = facebook::react::
|
|
64
|
+
ConcreteViewShadowNode<GlassContainerComponentName, GlassProps, facebook::react::ViewEventEmitter>;
|
|
65
|
+
using GlassContainerComponentDescriptor = facebook::react::ConcreteComponentDescriptor<GlassContainerShadowNode>;
|
|
66
|
+
|
|
67
|
+
} // namespace ngn
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// A native stack's header as a toolkit draws it: react-native-screens' RNSScreenStackHeaderConfig
|
|
2
|
+
// props, read once into plain data, so a backend needs none of the library's headers.
|
|
3
|
+
#pragma once
|
|
4
|
+
|
|
5
|
+
#include <react/renderer/core/Props.h>
|
|
6
|
+
#include <react/renderer/graphics/Color.h>
|
|
7
|
+
|
|
8
|
+
#include <folly/dynamic.h>
|
|
9
|
+
#include <optional>
|
|
10
|
+
#include <string>
|
|
11
|
+
#include <vector>
|
|
12
|
+
|
|
13
|
+
namespace ngn {
|
|
14
|
+
|
|
15
|
+
// One entry of a bar button's menu: an action (with an id) or a submenu (with items).
|
|
16
|
+
struct HeaderMenuItem {
|
|
17
|
+
std::string title;
|
|
18
|
+
std::string menuId;
|
|
19
|
+
std::string symbol;
|
|
20
|
+
bool on{false};
|
|
21
|
+
bool disabled{false};
|
|
22
|
+
bool destructive{false};
|
|
23
|
+
bool inlineSection{false};
|
|
24
|
+
std::vector<HeaderMenuItem> items;
|
|
25
|
+
bool operator==(const HeaderMenuItem &) const = default;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// An entry of headerLeftBarButtonItems or headerRightBarButtonItems, as RNSBarButtonItem.mm reads
|
|
29
|
+
// it. A press sends its id back; one with a menu opens the menu instead.
|
|
30
|
+
struct BarButton {
|
|
31
|
+
std::string id;
|
|
32
|
+
std::string title;
|
|
33
|
+
std::string symbol;
|
|
34
|
+
std::string accessibilityLabel;
|
|
35
|
+
facebook::react::SharedColor tint;
|
|
36
|
+
bool disabled{false};
|
|
37
|
+
// A fixed space of this width, and nothing else.
|
|
38
|
+
std::optional<double> spacing;
|
|
39
|
+
std::optional<HeaderMenuItem> menu;
|
|
40
|
+
bool operator==(const BarButton &) const = default;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
struct HeaderBar {
|
|
44
|
+
bool hidden{false};
|
|
45
|
+
std::string title;
|
|
46
|
+
facebook::react::SharedColor titleColor;
|
|
47
|
+
std::string titleFontFamily;
|
|
48
|
+
int titleFontSize{0};
|
|
49
|
+
std::string titleFontWeight;
|
|
50
|
+
// The tint of the bar's buttons, the back button's included.
|
|
51
|
+
facebook::react::SharedColor color;
|
|
52
|
+
facebook::react::SharedColor backgroundColor;
|
|
53
|
+
bool hideBackButton{false};
|
|
54
|
+
bool hideShadow{false};
|
|
55
|
+
std::vector<BarButton> left;
|
|
56
|
+
std::vector<BarButton> right;
|
|
57
|
+
bool operator==(const HeaderBar &) const = default;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// A header's search field (react-native-screens' RNSSearchBar), drawn as the window's
|
|
61
|
+
// NSSearchToolbarItem. The text is not a prop: JavaScript sets it with the setText command.
|
|
62
|
+
struct SearchBarConfig {
|
|
63
|
+
std::string placeholder;
|
|
64
|
+
// "systemDefault", "none", "words", "sentences" or "characters".
|
|
65
|
+
std::string autoCapitalize;
|
|
66
|
+
// The caret.
|
|
67
|
+
facebook::react::SharedColor tintColor;
|
|
68
|
+
// The typed text.
|
|
69
|
+
facebook::react::SharedColor textColor;
|
|
70
|
+
bool operator==(const SearchBarConfig &) const = default;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// What the user did in a search field.
|
|
74
|
+
enum class SearchBarInput { Typed, Submitted, Cancelled, Began, Ended };
|
|
75
|
+
|
|
76
|
+
struct SearchBarEvent {
|
|
77
|
+
std::string name;
|
|
78
|
+
folly::dynamic payload;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// The events RNSSearchBar sends on iOS for `input`, with the field's text after it: Return is the
|
|
82
|
+
// search button, Escape the Cancel button (which empties the field first). iOS sends no `open` or
|
|
83
|
+
// `close`, so neither does this.
|
|
84
|
+
std::vector<SearchBarEvent> searchBarEvents(SearchBarInput input, const std::string &text);
|
|
85
|
+
|
|
86
|
+
// A command JavaScript sends a search bar (react-native-screens' RNSSearchBar commands).
|
|
87
|
+
struct SearchBarCommand {
|
|
88
|
+
enum Kind { Focus, Blur, ClearText, SetText, Cancel } kind;
|
|
89
|
+
std::string text;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// The command `name` with `args`, or nothing for one the desktop does not act on:
|
|
93
|
+
// toggleCancelButton (a toolbar field has no Cancel button to show) and setText without a string.
|
|
94
|
+
std::optional<SearchBarCommand> searchBarCommand(const std::string &name, const folly::dynamic &args);
|
|
95
|
+
|
|
96
|
+
// The bar buttons in a headerLeftBarButtonItems or headerRightBarButtonItems list. An entry that
|
|
97
|
+
// is not an object is skipped. Colours are processed colour integers.
|
|
98
|
+
std::vector<BarButton> barButtons(const std::vector<folly::dynamic> &items);
|
|
99
|
+
|
|
100
|
+
// The header a RNSScreenStackHeaderConfig's props describe, or nothing for other props or a host
|
|
101
|
+
// built without react-native-screens (library-glue.h).
|
|
102
|
+
std::optional<HeaderBar> headerBar(const facebook::react::Props &props);
|
|
103
|
+
|
|
104
|
+
// Where a RNSScreenStackHeaderSubview sits: "left", "right", "center", "back" or "searchBar".
|
|
105
|
+
// Nothing for other props, or without react-native-screens.
|
|
106
|
+
std::optional<std::string> headerItemType(const facebook::react::Props &props);
|
|
107
|
+
|
|
108
|
+
// The search field a RNSSearchBar's props describe, or nothing for other props or without
|
|
109
|
+
// react-native-screens.
|
|
110
|
+
std::optional<SearchBarConfig> searchBarConfig(const facebook::react::Props &props);
|
|
111
|
+
|
|
112
|
+
} // namespace ngn
|