@ng-native/desktop 0.0.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +276 -0
- package/native/appkit/CMakeLists.txt +109 -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-view.h +15 -0
- package/native/appkit/camera-view.mm +130 -0
- package/native/appkit/camera.h +39 -0
- package/native/appkit/camera.mm +362 -0
- package/native/appkit/cg-canvas.h +17 -0
- package/native/appkit/cg-canvas.mm +518 -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 +629 -0
- package/native/appkit/host-view.h +54 -0
- package/native/appkit/host-view.mm +1200 -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 +1515 -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 +558 -0
- package/native/appkit/svg-view.h +17 -0
- package/native/appkit/svg-view.mm +57 -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/test-launch.h +36 -0
- package/native/appkit/test-launch.mm +115 -0
- package/native/appkit/text-input-field.h +76 -0
- package/native/appkit/text-input-field.mm +444 -0
- package/native/appkit/text-layout.h +58 -0
- package/native/appkit/text-layout.mm +477 -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 +9 -0
- package/native/appkit/web-view-component.mm +56 -0
- package/native/appkit/web-view.h +31 -0
- package/native/appkit/web-view.mm +394 -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 +146 -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 +112 -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 +128 -0
- package/native/core/include/ngn/control-sizes.h +111 -0
- package/native/core/include/ngn/core-modules.h +105 -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/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 +130 -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 +161 -0
- package/native/core/include/ngn/safe-areas.h +77 -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/svg.h +393 -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 +125 -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 +133 -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 +352 -0
- package/native/core/src/app-windows.cpp +444 -0
- package/native/core/src/back-swipe.cpp +91 -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/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 +345 -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 +405 -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 +221 -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 +371 -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 +380 -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 +422 -0
- package/native/core/src/safe-areas.cpp +130 -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 +1883 -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 +126 -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 +171 -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/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,171 @@
|
|
|
1
|
+
// react-native-screens' tabs (RNSTabsHostIOS and its RNSTabsScreenIOS children) as a desktop draws
|
|
2
|
+
// them: the window's sidebar lists the tabs and the content pane shows the selected one. The tabs
|
|
3
|
+
// outlet commits the same props as on iOS, so the selection handshake is iOS's:
|
|
4
|
+
//
|
|
5
|
+
// - The host holds the navigation state, a selected screen key and a provenance that counts each
|
|
6
|
+
// change. The app asks for a tab with `navStateRequest` {selectedScreenKey, baseProvenance}; a
|
|
7
|
+
// request is rejected as stale (with `rejectStaleNavStateUpdates`) when it is older than the last
|
|
8
|
+
// change the user made, and as repeated when it names the tab already selected.
|
|
9
|
+
// - Every change is reported with `tabSelected` {selectedScreenKey, provenance, isRepeated,
|
|
10
|
+
// hasTriggeredSpecialEffect, actionOrigin}: `user` for a click, `programmatic-js` for a request.
|
|
11
|
+
// A click on a tab with `preventNativeSelection` selects nothing and sends
|
|
12
|
+
// `tabSelectionPrevented` instead.
|
|
13
|
+
// - Before the app asks for one, the first tab shows, as UIKit's tab bar controller does.
|
|
14
|
+
// - When the selected tab is taken away, the first tab left shows and becomes the selection,
|
|
15
|
+
// reported with `actionOrigin` `implicit`, as react-native-screens reconciles it on iOS.
|
|
16
|
+
//
|
|
17
|
+
// The screens not selected are covered (screen-stacks.h): mounted, but neither drawn nor hit. The
|
|
18
|
+
// selected one hears willAppear and didAppear, the one it replaces willDisappear and didDisappear.
|
|
19
|
+
#pragma once
|
|
20
|
+
|
|
21
|
+
#include "ngn/split-view.h"
|
|
22
|
+
#include "ngn/view-tree.h"
|
|
23
|
+
|
|
24
|
+
#include <react/renderer/core/Props.h>
|
|
25
|
+
|
|
26
|
+
#include <folly/dynamic.h>
|
|
27
|
+
#include <optional>
|
|
28
|
+
#include <string>
|
|
29
|
+
#include <unordered_map>
|
|
30
|
+
#include <unordered_set>
|
|
31
|
+
#include <variant>
|
|
32
|
+
#include <vector>
|
|
33
|
+
|
|
34
|
+
namespace ngn {
|
|
35
|
+
|
|
36
|
+
// The navigation state machine of one tabs host, as RNSTabBarController keeps it.
|
|
37
|
+
class TabsNavigation {
|
|
38
|
+
public:
|
|
39
|
+
struct Selected {
|
|
40
|
+
std::string screenKey;
|
|
41
|
+
int provenance{0};
|
|
42
|
+
bool isRepeated{false};
|
|
43
|
+
std::string actionOrigin;
|
|
44
|
+
bool operator==(const Selected &) const = default;
|
|
45
|
+
};
|
|
46
|
+
struct Rejected {
|
|
47
|
+
std::string selectedScreenKey;
|
|
48
|
+
int provenance{0};
|
|
49
|
+
std::string rejectedScreenKey;
|
|
50
|
+
int rejectedBaseProvenance{0};
|
|
51
|
+
std::string reason;
|
|
52
|
+
bool operator==(const Rejected &) const = default;
|
|
53
|
+
};
|
|
54
|
+
struct Prevented {
|
|
55
|
+
std::string selectedScreenKey;
|
|
56
|
+
int provenance{0};
|
|
57
|
+
std::string preventedScreenKey;
|
|
58
|
+
bool operator==(const Prevented &) const = default;
|
|
59
|
+
};
|
|
60
|
+
using Outcome = std::variant<std::monostate, Selected, Rejected, Prevented>;
|
|
61
|
+
|
|
62
|
+
// The app's request. `known` says whether a screen with the key is mounted: one that is not is
|
|
63
|
+
// left for when it is.
|
|
64
|
+
Outcome request(const std::string &screenKey, int baseProvenance, bool rejectStale);
|
|
65
|
+
// A click on a tab.
|
|
66
|
+
Outcome userSelect(const std::string &screenKey, bool preventNativeSelection);
|
|
67
|
+
// The tab the host shows before any request or click names one: where the count starts, so the
|
|
68
|
+
// first click is a change the user made.
|
|
69
|
+
void show(const std::string &screenKey);
|
|
70
|
+
// The tab the host shows in place of the selected one, once that one is taken away: a change
|
|
71
|
+
// neither the app nor the user asked for, which iOS reports as `implicit`.
|
|
72
|
+
Outcome reconcile(const std::string &screenKey);
|
|
73
|
+
|
|
74
|
+
// The selected key, or empty before the first change.
|
|
75
|
+
const std::string &selected() const {
|
|
76
|
+
return selected_;
|
|
77
|
+
}
|
|
78
|
+
bool started() const {
|
|
79
|
+
return started_;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// The event an outcome sends from the host, and its payload: nothing for monostate.
|
|
83
|
+
static std::optional<std::pair<std::string, folly::dynamic>> event(const Outcome &outcome);
|
|
84
|
+
|
|
85
|
+
private:
|
|
86
|
+
void progress(const std::string &screenKey, bool fromJs);
|
|
87
|
+
|
|
88
|
+
bool started_{false};
|
|
89
|
+
std::string selected_;
|
|
90
|
+
int provenance_{0};
|
|
91
|
+
// The provenance of the last change that was not the app's own request.
|
|
92
|
+
std::optional<int> lastUi_;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// A tab as the host reads it from its RNSTabsScreenIOS props (library-glue.h).
|
|
96
|
+
struct TabScreen {
|
|
97
|
+
std::string screenKey;
|
|
98
|
+
std::string title;
|
|
99
|
+
std::string badge;
|
|
100
|
+
// The SF Symbol, when the tab's icon is one.
|
|
101
|
+
std::string sfSymbol;
|
|
102
|
+
bool preventNativeSelection{false};
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// The request a RNSTabsHostIOS's props carry.
|
|
106
|
+
struct TabsRequest {
|
|
107
|
+
std::string screenKey;
|
|
108
|
+
int baseProvenance{0};
|
|
109
|
+
bool rejectStale{false};
|
|
110
|
+
bool operator==(const TabsRequest &) const = default;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// What the tabs' props say, through the library's glue: nothing for other props or a host built
|
|
114
|
+
// without react-native-screens.
|
|
115
|
+
std::optional<TabScreen> tabScreen(const facebook::react::Props &props);
|
|
116
|
+
std::optional<TabsRequest> tabsRequest(const facebook::react::Props &props);
|
|
117
|
+
|
|
118
|
+
// Every tabs host of the surfaces, kept by the mounting manager as ScreenStacks is.
|
|
119
|
+
class TabsHosts {
|
|
120
|
+
public:
|
|
121
|
+
virtual ~TabsHosts() = default;
|
|
122
|
+
|
|
123
|
+
void childrenChanged(const ViewTree &tree, Tag parent);
|
|
124
|
+
void propsChanged(const ViewTree &tree, Tag tag);
|
|
125
|
+
void deleted(Tag tag);
|
|
126
|
+
|
|
127
|
+
// A click on the tab `screen` of `host`.
|
|
128
|
+
void userSelect(const ViewTree &tree, Tag host, Tag screen);
|
|
129
|
+
|
|
130
|
+
struct Change {
|
|
131
|
+
Tag host{-1};
|
|
132
|
+
// The tabs, as one untitled source list, with the selected one marked.
|
|
133
|
+
SourceList list;
|
|
134
|
+
bool operator==(const Change &) const = default;
|
|
135
|
+
};
|
|
136
|
+
struct Covered {
|
|
137
|
+
Tag tag;
|
|
138
|
+
bool covered;
|
|
139
|
+
};
|
|
140
|
+
struct Changes {
|
|
141
|
+
std::vector<Change> hosts;
|
|
142
|
+
std::vector<Covered> covered;
|
|
143
|
+
};
|
|
144
|
+
// Applies the requests and clicks since the last call: sends the events, covers the screens not
|
|
145
|
+
// selected in `tree`, and answers what the toolkit must redraw.
|
|
146
|
+
Changes settle(ViewTree &tree);
|
|
147
|
+
|
|
148
|
+
// Whether `tag` is a tabs host.
|
|
149
|
+
static bool isHost(const ViewTree::Node *node);
|
|
150
|
+
|
|
151
|
+
protected:
|
|
152
|
+
// Where events leave the core: through the view's event emitter by default, recorded in tests.
|
|
153
|
+
virtual void emit(const ViewTree::Node &node, const std::string &event, folly::dynamic payload);
|
|
154
|
+
|
|
155
|
+
private:
|
|
156
|
+
struct Host {
|
|
157
|
+
TabsNavigation navigation;
|
|
158
|
+
TabsRequest request;
|
|
159
|
+
// The last request applied: a request is applied once, when its props change.
|
|
160
|
+
std::optional<TabsRequest> applied;
|
|
161
|
+
// The screen shown, which hears appear and disappear.
|
|
162
|
+
Tag shown{-1};
|
|
163
|
+
std::optional<SourceList> drawn;
|
|
164
|
+
};
|
|
165
|
+
void send(const ViewTree &tree, Tag host, const TabsNavigation::Outcome &outcome);
|
|
166
|
+
|
|
167
|
+
std::unordered_map<Tag, Host> hosts_;
|
|
168
|
+
std::unordered_set<Tag> dirty_;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
} // namespace ngn
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// `<text-input>` on the desktop: React Native's iOS TextInput props with `smartQuotes` beside them,
|
|
2
|
+
// and the options a toolkit's field applies, resolved from them.
|
|
3
|
+
//
|
|
4
|
+
// React Native's TextInputProps is final, so DesktopTextInputProps repeats its few own members
|
|
5
|
+
// (traits and selection) over the shared BaseTextInputProps, and the TextInput component is
|
|
6
|
+
// React Native's BaseTextInputShadowNode over it: it measures and lays out as on iOS.
|
|
7
|
+
#pragma once
|
|
8
|
+
|
|
9
|
+
#include <react/renderer/components/iostextinput/primitives.h>
|
|
10
|
+
#include <react/renderer/components/textinput/BaseTextInputProps.h>
|
|
11
|
+
#include <react/renderer/components/textinput/BaseTextInputShadowNode.h>
|
|
12
|
+
#include <react/renderer/components/textinput/TextInputEventEmitter.h>
|
|
13
|
+
#include <react/renderer/components/textinput/TextInputState.h>
|
|
14
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
15
|
+
#include <react/renderer/textlayoutmanager/TextLayoutManager.h>
|
|
16
|
+
|
|
17
|
+
#include <cstddef>
|
|
18
|
+
#include <optional>
|
|
19
|
+
|
|
20
|
+
namespace ngn {
|
|
21
|
+
|
|
22
|
+
class DesktopTextInputProps final : public facebook::react::BaseTextInputProps {
|
|
23
|
+
public:
|
|
24
|
+
DesktopTextInputProps() = default;
|
|
25
|
+
DesktopTextInputProps(
|
|
26
|
+
const facebook::react::PropsParserContext &context,
|
|
27
|
+
const DesktopTextInputProps &sourceProps,
|
|
28
|
+
const facebook::react::RawProps &rawProps);
|
|
29
|
+
|
|
30
|
+
facebook::react::TextInputTraits traits{};
|
|
31
|
+
std::optional<facebook::react::Selection> selection{};
|
|
32
|
+
// Curly quotes and em dashes as the user types. Unset follows `autoCorrect`.
|
|
33
|
+
std::optional<bool> smartQuotes{};
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
extern const char DesktopTextInputComponentName[];
|
|
37
|
+
|
|
38
|
+
class DesktopTextInputShadowNode final : public facebook::react::BaseTextInputShadowNode<
|
|
39
|
+
DesktopTextInputComponentName,
|
|
40
|
+
DesktopTextInputProps,
|
|
41
|
+
facebook::react::TextInputEventEmitter,
|
|
42
|
+
facebook::react::TextInputState> {
|
|
43
|
+
public:
|
|
44
|
+
using BaseTextInputShadowNode::BaseTextInputShadowNode;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
class DesktopTextInputComponentDescriptor final
|
|
48
|
+
: public facebook::react::ConcreteComponentDescriptor<DesktopTextInputShadowNode> {
|
|
49
|
+
public:
|
|
50
|
+
explicit DesktopTextInputComponentDescriptor(const facebook::react::ComponentDescriptorParameters ¶meters)
|
|
51
|
+
: ConcreteComponentDescriptor(parameters),
|
|
52
|
+
textLayoutManager_(std::make_shared<facebook::react::TextLayoutManager>(contextContainer_)) {}
|
|
53
|
+
|
|
54
|
+
protected:
|
|
55
|
+
void adopt(facebook::react::ShadowNode &shadowNode) const override {
|
|
56
|
+
ConcreteComponentDescriptor::adopt(shadowNode);
|
|
57
|
+
static_cast<DesktopTextInputShadowNode &>(shadowNode).setTextLayoutManager(textLayoutManager_);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
private:
|
|
61
|
+
const std::shared_ptr<facebook::react::TextLayoutManager> textLayoutManager_;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// `autoCapitalize`.
|
|
65
|
+
enum class Capitalize { None, Sentences, Words, Characters };
|
|
66
|
+
|
|
67
|
+
// What a field applies. An unset switch leaves the user's system setting in charge.
|
|
68
|
+
struct TextInputOptions {
|
|
69
|
+
std::optional<bool> autoCorrect;
|
|
70
|
+
std::optional<bool> spellCheck;
|
|
71
|
+
std::optional<bool> smartQuotes;
|
|
72
|
+
std::optional<bool> smartInsertDelete;
|
|
73
|
+
Capitalize capitalize{Capitalize::Sentences};
|
|
74
|
+
bool secure{false};
|
|
75
|
+
// In UTF-16 code units, as React Native counts. Unset is unlimited.
|
|
76
|
+
std::optional<std::size_t> maxLength;
|
|
77
|
+
|
|
78
|
+
bool operator==(const TextInputOptions &) const = default;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// React Native iOS's rules: `spellCheck` and `smartQuotes` follow `autoCorrect` when unset, and
|
|
82
|
+
// secure entry turns every substitution and check off and never capitalizes.
|
|
83
|
+
TextInputOptions textInputOptions(const DesktopTextInputProps &props);
|
|
84
|
+
|
|
85
|
+
// How much of an insertion of `inserted` units, replacing `replaced` of the field's `current`, fits
|
|
86
|
+
// in `maxLength`: all of it, a leading part, or none.
|
|
87
|
+
std::size_t insertionThatFits(
|
|
88
|
+
std::size_t current,
|
|
89
|
+
std::size_t replaced,
|
|
90
|
+
std::size_t inserted,
|
|
91
|
+
std::optional<std::size_t> maxLength);
|
|
92
|
+
|
|
93
|
+
// What a backend's text system knows that the core does not, over UTF-16 as the toolkits keep text:
|
|
94
|
+
// capitals in the user's locale, and where a character (a composed character sequence: a surrogate
|
|
95
|
+
// pair, a letter with its combining marks) starts.
|
|
96
|
+
class TextCharacters {
|
|
97
|
+
public:
|
|
98
|
+
virtual ~TextCharacters() = default;
|
|
99
|
+
virtual std::u16string uppercase(const std::u16string &text) const = 0;
|
|
100
|
+
// Where the character holding the unit at `index` starts, and how many units it has.
|
|
101
|
+
virtual std::pair<std::size_t, std::size_t> characterAt(const std::u16string &text, std::size_t index) const = 0;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// Whether a UTF-16 unit is white space or a line break: what ends a word for `words`.
|
|
105
|
+
bool isTextSpace(char16_t unit);
|
|
106
|
+
|
|
107
|
+
// The text an edit puts in a field: `replacement`, replacing `length` units of `current` at
|
|
108
|
+
// `location`, capitalized as `autoCapitalize` asks (`characters`, all of it; `words`, each word's
|
|
109
|
+
// first character, a word starting at the start or after white space, pasted text too), then cut to
|
|
110
|
+
// what fits in `maxLength`, never inside a character.
|
|
111
|
+
std::u16string fitReplacement(
|
|
112
|
+
const std::u16string ¤t,
|
|
113
|
+
std::size_t location,
|
|
114
|
+
std::size_t length,
|
|
115
|
+
const std::u16string &replacement,
|
|
116
|
+
const TextInputOptions &options,
|
|
117
|
+
const TextCharacters &characters);
|
|
118
|
+
|
|
119
|
+
// React Native's controlled-text rule (iOS's mostRecentEventCount): the text JavaScript sends a
|
|
120
|
+
// field replaces what it shows only when it answers the field's latest change
|
|
121
|
+
// (`mostRecentEventCount` at least the field's own count), and never while an input method is
|
|
122
|
+
// composing.
|
|
123
|
+
bool controlledTextIsCurrent(int mostRecentEventCount, int fieldEventCount, bool composing);
|
|
124
|
+
|
|
125
|
+
} // namespace ngn
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// The text measurement interface: how big a toolkit lays a paragraph out.
|
|
2
|
+
//
|
|
3
|
+
// React Native's TextLayoutManager (the cxx header) is implemented in the core, which keeps the
|
|
4
|
+
// measure cache, attachments, constraint clamping and rounding to the device pixel for every
|
|
5
|
+
// backend, and asks the TextMeasurer found in the ContextContainer only for the raw size.
|
|
6
|
+
#pragma once
|
|
7
|
+
|
|
8
|
+
#include <react/renderer/attributedstring/AttributedString.h>
|
|
9
|
+
#include <react/renderer/attributedstring/ParagraphAttributes.h>
|
|
10
|
+
#include <react/renderer/graphics/Size.h>
|
|
11
|
+
#include <react/utils/ContextContainer.h>
|
|
12
|
+
|
|
13
|
+
#include <memory>
|
|
14
|
+
|
|
15
|
+
namespace ngn {
|
|
16
|
+
|
|
17
|
+
class TextMeasurer {
|
|
18
|
+
public:
|
|
19
|
+
virtual ~TextMeasurer() = default;
|
|
20
|
+
|
|
21
|
+
// The unrounded size of the laid-out text, at most `maxWidth` wide (which may be infinite).
|
|
22
|
+
// Called on the JS thread, concurrently with drawing on the UI thread.
|
|
23
|
+
virtual facebook::react::Size measure(
|
|
24
|
+
const facebook::react::AttributedString &text,
|
|
25
|
+
const facebook::react::ParagraphAttributes ¶graph,
|
|
26
|
+
facebook::react::Float maxWidth) const = 0;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// The ContextContainer key the core's TextLayoutManager reads the measurer from.
|
|
30
|
+
inline constexpr const char *kTextMeasurerKey = "ngn.TextMeasurer";
|
|
31
|
+
|
|
32
|
+
inline void installTextMeasurer(
|
|
33
|
+
facebook::react::ContextContainer &context,
|
|
34
|
+
std::shared_ptr<const TextMeasurer> measurer) {
|
|
35
|
+
context.insert(kTextMeasurerKey, std::move(measurer));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
} // namespace ngn
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// NgNativeTextRecognition: @ng-native/expo's TextRecognition, the same module the iOS app has, over
|
|
2
|
+
// a TextReader, which the AppKit backend implements with Vision's VNRecognizeTextRequest.
|
|
3
|
+
//
|
|
4
|
+
// - recognize(uri, {languages, level}): {text, lines: [{text, confidence, box}], width, height}.
|
|
5
|
+
// A box is in the image's pixels from its top left corner, the right way up. `uri` is a `file:`
|
|
6
|
+
// uri or an absolute path. A language Vision does not list is matched by its primary language
|
|
7
|
+
// (`en-GB` reads as `en-US`), and one with no match refuses the call, naming those it can read.
|
|
8
|
+
// Without languages, Vision detects the language.
|
|
9
|
+
#pragma once
|
|
10
|
+
|
|
11
|
+
#include "ngn/file-system.h"
|
|
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 TextReader {
|
|
24
|
+
public:
|
|
25
|
+
struct Line {
|
|
26
|
+
std::string text;
|
|
27
|
+
double confidence{0};
|
|
28
|
+
// A fraction of the image from its bottom left corner, as Vision gives it.
|
|
29
|
+
double x{0}, y{0}, width{0}, height{0};
|
|
30
|
+
};
|
|
31
|
+
struct Reading {
|
|
32
|
+
std::vector<Line> lines;
|
|
33
|
+
// The upright image's size in pixels.
|
|
34
|
+
double width{0};
|
|
35
|
+
double height{0};
|
|
36
|
+
};
|
|
37
|
+
virtual ~TextReader() = default;
|
|
38
|
+
// The languages Vision reads at this level.
|
|
39
|
+
virtual std::vector<std::string> languages(bool fast) = 0;
|
|
40
|
+
// Reads the image at `path`, off the calling thread. Answers once, on any thread: the reading,
|
|
41
|
+
// or why there is none.
|
|
42
|
+
virtual void read(
|
|
43
|
+
const std::string &path,
|
|
44
|
+
const std::vector<std::string> &languages,
|
|
45
|
+
bool fast,
|
|
46
|
+
std::function<void(std::optional<Reading>, std::string error)> done) = 0;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// The code Vision lists for `code`: itself, or the first with its primary language.
|
|
50
|
+
std::optional<std::string> visionLanguage(const std::string &code, const std::vector<std::string> &supported);
|
|
51
|
+
|
|
52
|
+
// The image is read only where `files` lets it (FileAccess::readFor).
|
|
53
|
+
std::shared_ptr<NativeModule> makeTextRecognitionModule(std::shared_ptr<TextReader> reader, std::shared_ptr<FileAccess> files);
|
|
54
|
+
|
|
55
|
+
} // namespace ngn
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// NgNativeTrackingTransparency: what @ng-native/expo's Tracking calls on
|
|
2
|
+
// expo-tracking-transparency, over a TrackingAuthority, which the AppKit backend implements with
|
|
3
|
+
// App Tracking Transparency and AdSupport.
|
|
4
|
+
//
|
|
5
|
+
// - isAvailable(): true; macOS has the permission.
|
|
6
|
+
// - getTrackingPermissionsAsync(), requestTrackingPermissionsAsync(): expo's permission shape.
|
|
7
|
+
// Only what is undetermined is asked, never with `noPrompts` (NGN_NO_PROMPTS=1), and the
|
|
8
|
+
// authority asks only when the app's Info.plist has NSUserTrackingUsageDescription.
|
|
9
|
+
// - getAdvertisingId(): the advertising identifier once tracking is allowed, else null, as is an
|
|
10
|
+
// identifier of zeros, which macOS answers where it has none.
|
|
11
|
+
#pragma once
|
|
12
|
+
|
|
13
|
+
#include "ngn/native-module.h"
|
|
14
|
+
|
|
15
|
+
#include <functional>
|
|
16
|
+
#include <memory>
|
|
17
|
+
#include <string>
|
|
18
|
+
|
|
19
|
+
namespace ngn {
|
|
20
|
+
|
|
21
|
+
class TrackingAuthority {
|
|
22
|
+
public:
|
|
23
|
+
enum class Access { NotDetermined, Denied, Restricted, Granted };
|
|
24
|
+
virtual ~TrackingAuthority() = default;
|
|
25
|
+
virtual Access access() = 0;
|
|
26
|
+
// Shows the OS's prompt and answers once the user decides; answers the access as it is, with no
|
|
27
|
+
// prompt, when the app's Info.plist gives no reason to ask. Any thread.
|
|
28
|
+
virtual void requestAccess(std::function<void(Access)> done) = 0;
|
|
29
|
+
virtual std::string advertisingId() = 0;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
std::shared_ptr<NativeModule> makeTrackingModule(std::shared_ptr<TrackingAuthority> authority, bool noPrompts);
|
|
33
|
+
|
|
34
|
+
} // namespace ngn
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// The app's icons in the menu bar's status area (`NgNativeTray`) and its Dock icon's menu and
|
|
2
|
+
// bounce (`NgNativeDock`). Menus come in the form the menu bar's take (app-menus.h).
|
|
3
|
+
//
|
|
4
|
+
// A reloaded app starts with no tray icons and no Dock menu: what the old one set goes as the new
|
|
5
|
+
// one's module starts, and the new app sets its own.
|
|
6
|
+
#pragma once
|
|
7
|
+
|
|
8
|
+
#include "ngn/app-menus.h"
|
|
9
|
+
#include "ngn/host-state.h"
|
|
10
|
+
#include "ngn/native-module.h"
|
|
11
|
+
|
|
12
|
+
#include <map>
|
|
13
|
+
#include <memory>
|
|
14
|
+
#include <mutex>
|
|
15
|
+
#include <optional>
|
|
16
|
+
#include <set>
|
|
17
|
+
#include <string>
|
|
18
|
+
#include <vector>
|
|
19
|
+
|
|
20
|
+
namespace ngn {
|
|
21
|
+
|
|
22
|
+
struct TrayIcon {
|
|
23
|
+
std::string id;
|
|
24
|
+
std::string title;
|
|
25
|
+
std::string sfSymbol;
|
|
26
|
+
// An image asset of the app's own, by name.
|
|
27
|
+
std::string image;
|
|
28
|
+
std::string tooltip;
|
|
29
|
+
// The menu a click opens; with none, a click is a press.
|
|
30
|
+
std::optional<std::vector<MenuItem>> menu;
|
|
31
|
+
bool operator==(const TrayIcon &) const = default;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
std::vector<TrayIcon> parseTrayIcons(const folly::dynamic &icons);
|
|
35
|
+
|
|
36
|
+
class TrayBackend {
|
|
37
|
+
public:
|
|
38
|
+
virtual ~TrayBackend() = default;
|
|
39
|
+
// Every icon, in place of those before: an icon whose id was there before keeps its place.
|
|
40
|
+
virtual void setIcons(std::vector<TrayIcon> icons) = 0;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// Listeners for the events a module sends, and whether a runtime's module came before.
|
|
44
|
+
class EventSource {
|
|
45
|
+
public:
|
|
46
|
+
using Listener = std::function<void(const folly::dynamic &event)>;
|
|
47
|
+
// True from the second listener on: the app reloaded.
|
|
48
|
+
std::shared_ptr<void> listen(Listener listener, bool &reloaded);
|
|
49
|
+
void send(const folly::dynamic &event);
|
|
50
|
+
|
|
51
|
+
private:
|
|
52
|
+
std::mutex mutex_;
|
|
53
|
+
bool listened_{false};
|
|
54
|
+
// A dropped handle waits for its listener's call in progress, so a module going with a reload
|
|
55
|
+
// is never called after.
|
|
56
|
+
Listeners<folly::dynamic> listeners_;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
class TrayHost {
|
|
60
|
+
public:
|
|
61
|
+
explicit TrayHost(std::shared_ptr<TrayBackend> backend);
|
|
62
|
+
|
|
63
|
+
void setIcons(const folly::dynamic &icons);
|
|
64
|
+
// A click on an icon with no menu, or the choice of an item in an icon's menu.
|
|
65
|
+
void press(const std::string &icon);
|
|
66
|
+
void menuSelect(const std::string &icon, const std::string &id);
|
|
67
|
+
|
|
68
|
+
std::shared_ptr<void> attach(EventSource::Listener listener);
|
|
69
|
+
|
|
70
|
+
private:
|
|
71
|
+
std::shared_ptr<TrayBackend> backend_;
|
|
72
|
+
EventSource events_;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
class DockBackend {
|
|
76
|
+
public:
|
|
77
|
+
virtual ~DockBackend() = default;
|
|
78
|
+
// The app's items above the Dock menu's own, or none.
|
|
79
|
+
virtual void setMenu(std::optional<std::vector<MenuItem>> menu) = 0;
|
|
80
|
+
// Ask for attention (`critical` bounces until the app is active) under the core's `id`.
|
|
81
|
+
virtual void bounce(int id, bool critical) = 0;
|
|
82
|
+
virtual void cancelBounce(int id) = 0;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
class DockHost {
|
|
86
|
+
public:
|
|
87
|
+
explicit DockHost(std::shared_ptr<DockBackend> backend);
|
|
88
|
+
|
|
89
|
+
void setMenu(const folly::dynamic &entries);
|
|
90
|
+
int bounce(bool critical);
|
|
91
|
+
void cancelBounce(int id);
|
|
92
|
+
void menuSelect(const std::string &id);
|
|
93
|
+
|
|
94
|
+
std::shared_ptr<void> attach(EventSource::Listener listener);
|
|
95
|
+
|
|
96
|
+
private:
|
|
97
|
+
std::shared_ptr<DockBackend> backend_;
|
|
98
|
+
EventSource events_;
|
|
99
|
+
std::mutex mutex_;
|
|
100
|
+
int nextBounce_{1};
|
|
101
|
+
std::set<int> bounces_;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
std::shared_ptr<NativeModule> makeTrayModule(std::shared_ptr<TrayHost> host);
|
|
105
|
+
std::shared_ptr<NativeModule> makeDockModule(std::shared_ptr<DockHost> host);
|
|
106
|
+
|
|
107
|
+
} // namespace ngn
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// The app's undo stack on the desktop: `NgNativeUndo` for `UndoStack` in @ng-native/device
|
|
2
|
+
// (packages/integration-tests/undo-stack.test.ts).
|
|
3
|
+
//
|
|
4
|
+
// - `register(id, label)` registers an action with the toolkit's undo manager (NSUndoManager),
|
|
5
|
+
// named `label`, so Edit > Undo reads "Undo <label>". One manager serves every window; a focused
|
|
6
|
+
// text input keeps its own history (the backend gives it another manager).
|
|
7
|
+
// - Undoing it sends `{ type: 'undo', id }` on `ngNativeUndo` and registers its redo under the same
|
|
8
|
+
// id; redoing sends `{ type: 'redo', id }` and registers the undo again.
|
|
9
|
+
// - `undo()`, `redo()` and `clear()` do what Edit > Undo, Edit > Redo and clearing do.
|
|
10
|
+
// - A reload clears the history: the reloaded app knows none of the old ids.
|
|
11
|
+
#pragma once
|
|
12
|
+
|
|
13
|
+
#include "ngn/native-module.h"
|
|
14
|
+
|
|
15
|
+
#include <functional>
|
|
16
|
+
#include <memory>
|
|
17
|
+
#include <string>
|
|
18
|
+
|
|
19
|
+
namespace ngn {
|
|
20
|
+
|
|
21
|
+
// The toolkit's undo manager, with NSUndoManager's rules: an action registered while undoing goes
|
|
22
|
+
// on the redo stack, one registered while redoing on the undo stack, and one registered otherwise
|
|
23
|
+
// clears the redo stack.
|
|
24
|
+
class UndoManager {
|
|
25
|
+
public:
|
|
26
|
+
virtual ~UndoManager() = default;
|
|
27
|
+
virtual void registerAction(const std::string &label, std::function<void()> action) = 0;
|
|
28
|
+
// Whether the manager is undoing now, as an action it runs asks.
|
|
29
|
+
virtual bool undoing() const = 0;
|
|
30
|
+
virtual void undo() = 0;
|
|
31
|
+
virtual void redo() = 0;
|
|
32
|
+
virtual void clear() = 0;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
std::shared_ptr<NativeModule> makeUndoModule(std::shared_ptr<UndoManager> manager);
|
|
36
|
+
|
|
37
|
+
} // namespace ngn
|