@ng-native/desktop 0.0.0-stage → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +51 -2
- 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 +70 -3
- package/prebuilt.json +33 -0
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
#import "app-windows.h"
|
|
2
|
+
#import "test-launch.h"
|
|
3
|
+
#import "undo.h"
|
|
4
|
+
#import "screen-capture.h"
|
|
5
|
+
|
|
6
|
+
#import "surface-view.h"
|
|
7
|
+
|
|
8
|
+
using ngn::appkit::AppKitWindows;
|
|
9
|
+
|
|
10
|
+
@interface NGNWindowDelegate : NSObject <NSWindowDelegate>
|
|
11
|
+
- (instancetype)initWithSurface:(facebook::react::SurfaceId)surface windows:(AppKitWindows *)windows;
|
|
12
|
+
@end
|
|
13
|
+
|
|
14
|
+
@implementation NGNWindowDelegate {
|
|
15
|
+
facebook::react::SurfaceId _surface;
|
|
16
|
+
AppKitWindows *_windows;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
- (NSUndoManager *)windowWillReturnUndoManager:(NSWindow *)window {
|
|
20
|
+
return ngn::appkit::undoManagerFor(window);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
- (instancetype)initWithSurface:(facebook::react::SurfaceId)surface windows:(AppKitWindows *)windows {
|
|
24
|
+
if ((self = [super init])) {
|
|
25
|
+
_surface = surface;
|
|
26
|
+
_windows = windows;
|
|
27
|
+
}
|
|
28
|
+
return self;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
- (BOOL)windowShouldClose:(NSWindow *)sender {
|
|
32
|
+
return _windows->shouldClose(_surface);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
- (void)windowWillClose:(NSNotification *)note {
|
|
36
|
+
_windows->willClose(_surface);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
- (void)windowDidResize:(NSNotification *)note {
|
|
40
|
+
_windows->frameChanged(_surface, true);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
- (void)windowDidChangeBackingProperties:(NSNotification *)note {
|
|
44
|
+
_windows->frameChanged(_surface, true);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
- (void)windowDidMove:(NSNotification *)note {
|
|
48
|
+
_windows->frameChanged(_surface, false);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
- (void)windowDidBecomeKey:(NSNotification *)note {
|
|
52
|
+
_windows->keyChanged(_surface, true);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
- (void)windowDidResignKey:(NSNotification *)note {
|
|
56
|
+
_windows->keyChanged(_surface, false);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@end
|
|
60
|
+
|
|
61
|
+
namespace ngn::appkit {
|
|
62
|
+
|
|
63
|
+
namespace {
|
|
64
|
+
|
|
65
|
+
void onMain(std::function<void()> task) {
|
|
66
|
+
if (NSThread.isMainThread) {
|
|
67
|
+
task();
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
auto shared = std::make_shared<std::function<void()>>(std::move(task));
|
|
71
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
72
|
+
(*shared)();
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
NSString *string(const std::string &s) {
|
|
77
|
+
NSString *out = [NSString stringWithUTF8String:s.c_str()];
|
|
78
|
+
return out != nil ? out : @"";
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
WindowFrame frameOf(NSWindow *window) {
|
|
82
|
+
NSRect content = [window contentRectForFrameRect:window.frame];
|
|
83
|
+
return {.x = NSMinX(content), .y = NSMinY(content), .width = NSWidth(content), .height = NSHeight(content)};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Whether enough of `rect` is on a screen to grab its title bar: a display that has gone away
|
|
87
|
+
// leaves a saved frame nowhere.
|
|
88
|
+
bool onScreen(NSRect rect) {
|
|
89
|
+
for (NSScreen *screen in NSScreen.screens) {
|
|
90
|
+
NSRect visible = NSIntersectionRect(screen.visibleFrame, rect);
|
|
91
|
+
if (NSWidth(visible) >= 40 && NSHeight(visible) >= 20) {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
} // namespace
|
|
99
|
+
|
|
100
|
+
AppKitWindows::AppKitWindows(Hooks hooks)
|
|
101
|
+
: hooks_(std::move(hooks)),
|
|
102
|
+
windows_([NSMutableDictionary dictionary]),
|
|
103
|
+
delegates_([NSMutableDictionary dictionary]),
|
|
104
|
+
unshown_([NSMutableDictionary dictionary]) {}
|
|
105
|
+
|
|
106
|
+
void AppKitWindows::setHost(std::shared_ptr<WindowHost> host) {
|
|
107
|
+
host_ = std::move(host);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
NSWindow *AppKitWindows::window(SurfaceId surface) const {
|
|
111
|
+
return windows_[@(surface)];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
SurfaceId AppKitWindows::surfaceOf(NSWindow *window) const {
|
|
115
|
+
for (NSNumber *key in windows_) {
|
|
116
|
+
if (windows_[key] == window) {
|
|
117
|
+
return key.intValue;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return 0;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
void AppKitWindows::openWindow(
|
|
124
|
+
SurfaceId surface,
|
|
125
|
+
const WindowRequest &request,
|
|
126
|
+
const WindowPlacement &placement,
|
|
127
|
+
std::function<void()> opened) {
|
|
128
|
+
onMain([this, surface, request, placement, opened] {
|
|
129
|
+
NSWindowStyleMask style = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable |
|
|
130
|
+
NSWindowStyleMaskFullSizeContentView;
|
|
131
|
+
if (request.resizable) {
|
|
132
|
+
style |= NSWindowStyleMaskResizable;
|
|
133
|
+
}
|
|
134
|
+
NSRect content = NSMakeRect(placement.frame.x, placement.frame.y, placement.frame.width, placement.frame.height);
|
|
135
|
+
NSWindow *window = [[NSWindow alloc] initWithContentRect:content
|
|
136
|
+
styleMask:style
|
|
137
|
+
backing:NSBackingStoreBuffered
|
|
138
|
+
defer:NO];
|
|
139
|
+
window.releasedWhenClosed = NO;
|
|
140
|
+
shieldNewWindow(window);
|
|
141
|
+
window.title = string(request.title);
|
|
142
|
+
window.tabbingMode = NSWindowTabbingModeDisallowed;
|
|
143
|
+
if (request.titleBar != TitleBar::Default) {
|
|
144
|
+
window.titlebarAppearsTransparent = YES;
|
|
145
|
+
}
|
|
146
|
+
if (request.titleBar == TitleBar::Hidden) {
|
|
147
|
+
window.titleVisibility = NSWindowTitleHidden;
|
|
148
|
+
}
|
|
149
|
+
if (request.minWidth || request.minHeight) {
|
|
150
|
+
window.contentMinSize = NSMakeSize(request.minWidth.value_or(0), request.minHeight.value_or(0));
|
|
151
|
+
}
|
|
152
|
+
if (request.maxWidth || request.maxHeight) {
|
|
153
|
+
window.contentMaxSize = NSMakeSize(request.maxWidth.value_or(CGFLOAT_MAX), request.maxHeight.value_or(CGFLOAT_MAX));
|
|
154
|
+
}
|
|
155
|
+
if (!placement.restored || !onScreen(window.frame)) {
|
|
156
|
+
// Down and to the right of the window in front, or near the top left of the screen.
|
|
157
|
+
NSWindow *front = NSApp.keyWindow != nil ? NSApp.keyWindow : NSApp.orderedWindows.firstObject;
|
|
158
|
+
NSPoint at;
|
|
159
|
+
if (front != nil && front.visible) {
|
|
160
|
+
at = NSMakePoint(NSMinX(front.frame) + 28, NSMaxY(front.frame) - 28);
|
|
161
|
+
} else {
|
|
162
|
+
NSRect visible = NSScreen.mainScreen.visibleFrame;
|
|
163
|
+
at = NSMakePoint(NSMinX(visible) + 40, NSMaxY(visible) - 40);
|
|
164
|
+
}
|
|
165
|
+
// Past any window already there, so a second note never hides the first.
|
|
166
|
+
for (bool taken = true; taken;) {
|
|
167
|
+
taken = false;
|
|
168
|
+
for (NSWindow *other in NSApp.windows) {
|
|
169
|
+
if (other.visible && fabs(NSMinX(other.frame) - at.x) < 2 && fabs(NSMaxY(other.frame) - at.y) < 2) {
|
|
170
|
+
at = NSMakePoint(at.x + 28, at.y - 28);
|
|
171
|
+
taken = true;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
[window setFrameTopLeftPoint:at];
|
|
176
|
+
}
|
|
177
|
+
NGNWindowDelegate *delegate = [[NGNWindowDelegate alloc] initWithSurface:surface windows:this];
|
|
178
|
+
delegates_[@(surface)] = delegate;
|
|
179
|
+
window.delegate = delegate;
|
|
180
|
+
NSRect bounds = NSMakeRect(0, 0, NSWidth(content), NSHeight(content));
|
|
181
|
+
// A split view controller a reloaded app's window had gives way to the new surface.
|
|
182
|
+
window.contentViewController = nil;
|
|
183
|
+
window.contentView = hooks_.makeSurface(surface, bounds);
|
|
184
|
+
windows_[@(surface)] = window;
|
|
185
|
+
unshown_[@(surface)] = @(request.fullScreen);
|
|
186
|
+
hooks_.startSurface(surface, window);
|
|
187
|
+
opened();
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
void AppKitWindows::didMount(SurfaceId surface) {
|
|
192
|
+
if (unshown_[@(surface)] == nil || windows_[@(surface)] == nil || held_.count(surface) > 0) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (!hooks_.whenShown) {
|
|
196
|
+
show(surface);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
held_.insert(surface);
|
|
200
|
+
hooks_.whenShown([this, surface] {
|
|
201
|
+
held_.erase(surface);
|
|
202
|
+
show(surface);
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
void AppKitWindows::show(SurfaceId surface) {
|
|
207
|
+
NSNumber *fullScreen = unshown_[@(surface)];
|
|
208
|
+
NSWindow *window = windows_[@(surface)];
|
|
209
|
+
// A window closed while the splash held it is not shown.
|
|
210
|
+
if (fullScreen == nil || window == nil) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
[unshown_ removeObjectForKey:@(surface)];
|
|
214
|
+
showWindow(window);
|
|
215
|
+
// The app learns the size the window opened at, which a restored frame decides.
|
|
216
|
+
if (host_) {
|
|
217
|
+
host_->resized(surface, frameOf(window), window.backingScaleFactor);
|
|
218
|
+
}
|
|
219
|
+
if (fullScreen.boolValue) {
|
|
220
|
+
[window toggleFullScreen:nil];
|
|
221
|
+
}
|
|
222
|
+
if (hooks_.shown) {
|
|
223
|
+
hooks_.shown(window);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
void AppKitWindows::closeWindow(SurfaceId surface) {
|
|
228
|
+
onMain([this, surface] {
|
|
229
|
+
// close does not ask windowShouldClose: the app already decided.
|
|
230
|
+
[windows_[@(surface)] close];
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
void AppKitWindows::focusWindow(SurfaceId surface) {
|
|
235
|
+
onMain([this, surface] {
|
|
236
|
+
NSWindow *window = windows_[@(surface)];
|
|
237
|
+
if (window != nil && unshown_[@(surface)] == nil) {
|
|
238
|
+
if (window.miniaturized) {
|
|
239
|
+
[window deminiaturize:nil];
|
|
240
|
+
}
|
|
241
|
+
activateWith(window);
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
void AppKitWindows::setWindowTitle(SurfaceId surface, const std::string &title) {
|
|
247
|
+
onMain([this, surface, title] { windows_[@(surface)].title = string(title); });
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
void AppKitWindows::beginQuit() {
|
|
251
|
+
onMain([] { [NSApp terminate:nil]; });
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
void AppKitWindows::replyToQuit(bool proceed) {
|
|
255
|
+
onMain([proceed] { [NSApp replyToApplicationShouldTerminate:proceed]; });
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
void AppKitWindows::after(double seconds, std::function<void()> task) {
|
|
259
|
+
auto shared = std::make_shared<std::function<void()>>(std::move(task));
|
|
260
|
+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, static_cast<int64_t>(seconds * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
261
|
+
(*shared)();
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
bool AppKitWindows::shouldClose(SurfaceId surface) {
|
|
266
|
+
return host_ == nullptr || host_->closeRequested(surface);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
void AppKitWindows::willClose(SurfaceId surface) {
|
|
270
|
+
NSWindow *window = windows_[@(surface)];
|
|
271
|
+
window.delegate = nil;
|
|
272
|
+
[windows_ removeObjectForKey:@(surface)];
|
|
273
|
+
[delegates_ removeObjectForKey:@(surface)];
|
|
274
|
+
[unshown_ removeObjectForKey:@(surface)];
|
|
275
|
+
hooks_.stopSurface(surface);
|
|
276
|
+
if (host_) {
|
|
277
|
+
if (host_->focusedSurface() == surface) {
|
|
278
|
+
host_->focused(std::nullopt);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
void AppKitWindows::frameChanged(SurfaceId surface, bool resized) {
|
|
284
|
+
NSWindow *window = windows_[@(surface)];
|
|
285
|
+
if (window == nil) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
if (resized) {
|
|
289
|
+
hooks_.resizeSurface(surface, window);
|
|
290
|
+
if (window.isKeyWindow && hooks_.keyWindowChanged) {
|
|
291
|
+
hooks_.keyWindowChanged(window);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
// A window still waiting for its first frame has not been placed by the user.
|
|
295
|
+
if (host_ && unshown_[@(surface)] == nil) {
|
|
296
|
+
if (resized) {
|
|
297
|
+
host_->resized(surface, frameOf(window), window.backingScaleFactor);
|
|
298
|
+
} else {
|
|
299
|
+
host_->moved(surface, frameOf(window));
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
void AppKitWindows::keyChanged(SurfaceId surface, bool key) {
|
|
305
|
+
if (!host_) {
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
if (key) {
|
|
309
|
+
host_->focused(surface);
|
|
310
|
+
if (hooks_.keyWindowChanged) {
|
|
311
|
+
hooks_.keyWindowChanged(windows_[@(surface)]);
|
|
312
|
+
}
|
|
313
|
+
} else if (host_->focusedSurface() == surface) {
|
|
314
|
+
host_->focused(std::nullopt);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
} // namespace ngn::appkit
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// The AppKit backend: the core's mounting and desktop props interfaces over NSViews, on the main
|
|
2
|
+
// thread.
|
|
3
|
+
#pragma once
|
|
4
|
+
|
|
5
|
+
#import <AppKit/AppKit.h>
|
|
6
|
+
|
|
7
|
+
#include "ngn/app-menus.h"
|
|
8
|
+
#include "ngn/desktop-view-props.h"
|
|
9
|
+
#include "ngn/mounting-backend.h"
|
|
10
|
+
|
|
11
|
+
@class NGNHeaderToolbar;
|
|
12
|
+
@class NGNSourceLists;
|
|
13
|
+
@class NGNSurfaceView;
|
|
14
|
+
@class NGNView;
|
|
15
|
+
|
|
16
|
+
namespace ngn::appkit {
|
|
17
|
+
|
|
18
|
+
class AppKitBackend final : public MountingBackend, public DesktopPropsSink {
|
|
19
|
+
public:
|
|
20
|
+
AppKitBackend();
|
|
21
|
+
|
|
22
|
+
// The view a surface's root mounts into. Main thread.
|
|
23
|
+
void addSurface(NGNSurfaceView *surfaceView);
|
|
24
|
+
void removeSurface(SurfaceId surfaceId);
|
|
25
|
+
NGNSurfaceView *surface(SurfaceId surfaceId) const;
|
|
26
|
+
// The view mounted for `tag`, or nil. Main thread.
|
|
27
|
+
NGNView *view(Tag tag) const;
|
|
28
|
+
// The history the app reports for the window of `surfaceId`, for its toolbar's chevrons. Main
|
|
29
|
+
// thread.
|
|
30
|
+
void setHistory(SurfaceId surfaceId, const std::optional<WindowHistory> &history);
|
|
31
|
+
// The history a window's toolbar starts with, when it is made after the app reported it.
|
|
32
|
+
std::function<std::optional<WindowHistory>(SurfaceId)> historyOf;
|
|
33
|
+
// Called on the main thread after each mounted transaction.
|
|
34
|
+
std::function<void(SurfaceId)> onMount;
|
|
35
|
+
|
|
36
|
+
void runOnUiThread(std::function<void()> task) override;
|
|
37
|
+
bool onUiThread() const override;
|
|
38
|
+
void serviceUiThread() override;
|
|
39
|
+
void createView(const ShadowView &view) override;
|
|
40
|
+
void deleteView(SurfaceId surfaceId, Tag tag) override;
|
|
41
|
+
void insertChild(SurfaceId surfaceId, Tag parent, Tag child, int index) override;
|
|
42
|
+
void removeChild(SurfaceId surfaceId, Tag parent, Tag child, int index) override;
|
|
43
|
+
void updateProps(const ShadowView &view) override;
|
|
44
|
+
void updateState(const ShadowView &view) override;
|
|
45
|
+
void updateLayout(const ShadowView &view) override;
|
|
46
|
+
void updateEventEmitter(const ShadowView &view) override;
|
|
47
|
+
void dispatchCommand(Tag tag, const std::string &name, const folly::dynamic &args) override;
|
|
48
|
+
void setCovered(SurfaceId surfaceId, Tag tag, bool covered) override;
|
|
49
|
+
void setFrontHeader(SurfaceId surfaceId, const std::optional<ScreenStacks::FrontHeader> &header) override;
|
|
50
|
+
void setPresented(SurfaceId surfaceId, Tag screen, bool presented) override;
|
|
51
|
+
void setSplitView(SurfaceId surfaceId, Tag split, bool window) override;
|
|
52
|
+
void setSourceLists(SurfaceId surfaceId, Tag parent, const std::vector<SourceList> &lists) override;
|
|
53
|
+
void setSvgDrawing(SurfaceId surfaceId, Tag svg, std::shared_ptr<const SvgDocument> document) override;
|
|
54
|
+
void setExpoUITree(SurfaceId surfaceId, Tag host, std::shared_ptr<const ExpoUINode> root) override;
|
|
55
|
+
void announce(SurfaceId surfaceId, const Announcement &announcement) override;
|
|
56
|
+
void didMount(SurfaceId surfaceId) override;
|
|
57
|
+
void updateDesktopProps(SurfaceId surfaceId, Tag tag, const DesktopProps &props) override;
|
|
58
|
+
std::vector<facebook::react::ComponentDescriptorProvider> componentProviders() const override;
|
|
59
|
+
|
|
60
|
+
private:
|
|
61
|
+
NSMutableDictionary<NSNumber *, NGNView *> *views_;
|
|
62
|
+
NGNHeaderToolbar *toolbarFor(SurfaceId surfaceId);
|
|
63
|
+
// A view whose change may change the header in front, rebuilt once the transaction is in.
|
|
64
|
+
void touched(NSView *view);
|
|
65
|
+
|
|
66
|
+
NSMutableDictionary<NSNumber *, NGNSurfaceView *> *surfaces_;
|
|
67
|
+
NSMutableDictionary<NSNumber *, NGNHeaderToolbar *> *toolbars_;
|
|
68
|
+
NSMutableSet<NSView *> *touched_;
|
|
69
|
+
// The source lists of each parent that has some, by the parent's tag.
|
|
70
|
+
NSMutableDictionary<NSNumber *, NGNSourceLists *> *sourceLists_;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
} // namespace ngn::appkit
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
#import "appkit-backend.h"
|
|
2
|
+
#import "system.h"
|
|
3
|
+
|
|
4
|
+
#import "expo-ui-view.h"
|
|
5
|
+
#import "header-toolbar.h"
|
|
6
|
+
#import "host-view.h"
|
|
7
|
+
#import "modal-host-view.h"
|
|
8
|
+
#import "presented-screen.h"
|
|
9
|
+
#import "split-view.h"
|
|
10
|
+
#import "surface-view.h"
|
|
11
|
+
#import "svg-view.h"
|
|
12
|
+
|
|
13
|
+
#include "ngn/library-components.h"
|
|
14
|
+
|
|
15
|
+
namespace ngn::appkit {
|
|
16
|
+
|
|
17
|
+
AppKitBackend::AppKitBackend()
|
|
18
|
+
: views_([NSMutableDictionary dictionary]),
|
|
19
|
+
surfaces_([NSMutableDictionary dictionary]),
|
|
20
|
+
toolbars_([NSMutableDictionary dictionary]),
|
|
21
|
+
touched_([NSMutableSet set]),
|
|
22
|
+
sourceLists_([NSMutableDictionary dictionary]) {}
|
|
23
|
+
|
|
24
|
+
void AppKitBackend::addSurface(NGNSurfaceView *surfaceView) {
|
|
25
|
+
surfaces_[@(surfaceView.surfaceId)] = surfaceView;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
void AppKitBackend::removeSurface(SurfaceId surfaceId) {
|
|
29
|
+
[surfaces_ removeObjectForKey:@(surfaceId)];
|
|
30
|
+
[toolbars_ removeObjectForKey:@(surfaceId)];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
NGNSurfaceView *AppKitBackend::surface(SurfaceId surfaceId) const {
|
|
34
|
+
return surfaces_[@(surfaceId)];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
NGNView *AppKitBackend::view(Tag tag) const {
|
|
38
|
+
return views_[@(tag)];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
void AppKitBackend::runOnUiThread(std::function<void()> task) {
|
|
42
|
+
// The main queue is FIFO, which keeps transactions in commit order.
|
|
43
|
+
auto shared = std::make_shared<std::function<void()>>(std::move(task));
|
|
44
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
45
|
+
(*shared)();
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
bool AppKitBackend::onUiThread() const {
|
|
50
|
+
return NSThread.isMainThread;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
void AppKitBackend::serviceUiThread() {
|
|
54
|
+
// The main run loop serves the main queue.
|
|
55
|
+
[NSRunLoop.mainRunLoop runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.005]];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
void AppKitBackend::createView(const ShadowView &view) {
|
|
59
|
+
NGNView *created = NGNMakeView(view);
|
|
60
|
+
views_[@(view.tag)] = created;
|
|
61
|
+
[created updateEventEmitter:view.eventEmitter];
|
|
62
|
+
[created updateProps:view.props];
|
|
63
|
+
[created updateState:view.state];
|
|
64
|
+
if (view.tag == view.surfaceId) {
|
|
65
|
+
// A surface's root fills its container: Fabric gives it no frame of its own.
|
|
66
|
+
NGNSurfaceView *surface = surfaces_[@(view.surfaceId)];
|
|
67
|
+
created.frame = surface.bounds;
|
|
68
|
+
created.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
|
|
69
|
+
[surface addSubview:created];
|
|
70
|
+
} else {
|
|
71
|
+
[created updateLayout:view.layoutMetrics];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
void AppKitBackend::deleteView(SurfaceId, Tag tag) {
|
|
76
|
+
[views_ removeObjectForKey:@(tag)];
|
|
77
|
+
[sourceLists_[@(tag)] remove];
|
|
78
|
+
[sourceLists_ removeObjectForKey:@(tag)];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
void AppKitBackend::insertChild(SurfaceId, Tag parent, Tag child, int index) {
|
|
82
|
+
NGNView *parentView = views_[@(parent)];
|
|
83
|
+
NGNView *childView = views_[@(child)];
|
|
84
|
+
if (parentView == nil || childView == nil) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
// The index counts Fabric children only: a TextInput holds an NSTextField of its own.
|
|
88
|
+
if ([childView isKindOfClass:NGNModalHostView.class] && ![childView isKindOfClass:NGNPresentedScreenView.class]) {
|
|
89
|
+
[(NGNModalHostView *)childView presentOver:parentView];
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if ([parentView conformsToProtocol:@protocol(NGNMountsChildren)]) {
|
|
93
|
+
[(id<NGNMountsChildren>)parentView mountChild:childView index:index];
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
NSView *container = parentView.contentContainer;
|
|
97
|
+
NSMutableArray<NSView *> *siblings = [NSMutableArray array];
|
|
98
|
+
for (NSView *v in container.subviews) {
|
|
99
|
+
if ([v isKindOfClass:NGNView.class]) {
|
|
100
|
+
[siblings addObject:v];
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
touched(parentView);
|
|
104
|
+
if (index >= (int)siblings.count) {
|
|
105
|
+
[container addSubview:childView];
|
|
106
|
+
} else {
|
|
107
|
+
[container addSubview:childView positioned:NSWindowBelow relativeTo:siblings[index]];
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
void AppKitBackend::removeChild(SurfaceId, Tag parent, Tag child, int) {
|
|
112
|
+
NGNView *view = views_[@(child)];
|
|
113
|
+
if ([view isKindOfClass:NGNPresentedScreenView.class]) {
|
|
114
|
+
[(NGNPresentedScreenView *)view dismiss];
|
|
115
|
+
[view removeFromSuperview];
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if ([view isKindOfClass:NGNModalHostView.class]) {
|
|
119
|
+
[(NGNModalHostView *)view dismiss];
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if ([view isKindOfClass:NGNSplitView.class]) {
|
|
123
|
+
[(NGNSplitView *)view uninstall];
|
|
124
|
+
}
|
|
125
|
+
NGNView *parentView = views_[@(parent)];
|
|
126
|
+
if ([parentView conformsToProtocol:@protocol(NGNMountsChildren)]) {
|
|
127
|
+
[(id<NGNMountsChildren>)parentView unmountChild:view];
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
touched(view.superview);
|
|
131
|
+
[view removeFromSuperview];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
void AppKitBackend::updateProps(const ShadowView &view) {
|
|
135
|
+
[views_[@(view.tag)] updateProps:view.props];
|
|
136
|
+
touched(views_[@(view.tag)]);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
void AppKitBackend::updateState(const ShadowView &view) {
|
|
140
|
+
[views_[@(view.tag)] updateState:view.state];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
void AppKitBackend::updateLayout(const ShadowView &view) {
|
|
144
|
+
if (view.tag != view.surfaceId) {
|
|
145
|
+
[views_[@(view.tag)] updateLayout:view.layoutMetrics];
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
void AppKitBackend::updateEventEmitter(const ShadowView &view) {
|
|
150
|
+
[views_[@(view.tag)] updateEventEmitter:view.eventEmitter];
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
void AppKitBackend::dispatchCommand(Tag tag, const std::string &name, const folly::dynamic &args) {
|
|
154
|
+
[views_[@(tag)] handleCommand:name args:args];
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
void AppKitBackend::setCovered(SurfaceId, Tag tag, bool covered) {
|
|
158
|
+
views_[@(tag)].covered = covered;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
NGNHeaderToolbar *AppKitBackend::toolbarFor(SurfaceId surfaceId) {
|
|
162
|
+
NGNHeaderToolbar *toolbar = toolbars_[@(surfaceId)];
|
|
163
|
+
NSWindow *window = NGNWindowOfSplit(surfaces_[@(surfaceId)]);
|
|
164
|
+
if (toolbar == nil && window != nil) {
|
|
165
|
+
toolbar = [[NGNHeaderToolbar alloc] initWithWindow:window];
|
|
166
|
+
toolbars_[@(surfaceId)] = toolbar;
|
|
167
|
+
if (historyOf) {
|
|
168
|
+
[toolbar showHistory:historyOf(surfaceId)];
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return toolbar;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
void AppKitBackend::setHistory(SurfaceId surfaceId, const std::optional<WindowHistory> &history) {
|
|
175
|
+
[toolbarFor(surfaceId) showHistory:history];
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
void AppKitBackend::setFrontHeader(SurfaceId surfaceId, const std::optional<ScreenStacks::FrontHeader> &header) {
|
|
179
|
+
NGNView *config = header ? views_[@(header->config)] : nil;
|
|
180
|
+
[toolbarFor(surfaceId) showConfig:[config isKindOfClass:NGNHeaderConfigView.class] ? (NGNHeaderConfigView *)config : nil
|
|
181
|
+
screen:header ? views_[@(header->screen)] : nil
|
|
182
|
+
canGoBack:header && header->canGoBack];
|
|
183
|
+
[touched_ removeAllObjects];
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
void AppKitBackend::touched(NSView *view) {
|
|
187
|
+
if (view != nil && toolbars_.count > 0) {
|
|
188
|
+
[touched_ addObject:view];
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
void AppKitBackend::setPresented(SurfaceId, Tag screen, bool presented) {
|
|
193
|
+
if (auto *view = (NGNPresentedScreenView *)views_[@(screen)]; [view isKindOfClass:NGNPresentedScreenView.class]) {
|
|
194
|
+
[view setPresented:presented];
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
void AppKitBackend::setSplitView(SurfaceId surfaceId, Tag split, bool window) {
|
|
199
|
+
NGNSplitView *view = (NGNSplitView *)views_[@(split)];
|
|
200
|
+
if (![view isKindOfClass:NGNSplitView.class]) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
[view placeAsWindows:window];
|
|
204
|
+
if (window) {
|
|
205
|
+
toolbarFor(surfaceId).sidebar = view.ownWindow != nil;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
void AppKitBackend::setSvgDrawing(SurfaceId, Tag svg, std::shared_ptr<const SvgDocument> document) {
|
|
210
|
+
if (auto *view = (NGNSvgView *)views_[@(svg)]; [view isKindOfClass:NGNSvgView.class]) {
|
|
211
|
+
[view setDocument:std::move(document)];
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
void AppKitBackend::setExpoUITree(SurfaceId, Tag host, std::shared_ptr<const ExpoUINode> root) {
|
|
216
|
+
if (auto *view = (NGNExpoUIHostView *)views_[@(host)]; [view isKindOfClass:NGNExpoUIHostView.class]) {
|
|
217
|
+
[view setTree:std::move(root)];
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
void AppKitBackend::setSourceLists(SurfaceId, Tag parent, const std::vector<SourceList> &lists) {
|
|
222
|
+
if (auto *tabs = (NGNTabsHostView *)views_[@(parent)]; [tabs isKindOfClass:NGNTabsHostView.class]) {
|
|
223
|
+
[tabs setTabs:lists.empty() ? SourceList{} : lists[0]];
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
NGNSourceLists *known = sourceLists_[@(parent)];
|
|
227
|
+
if (lists.empty()) {
|
|
228
|
+
[known remove];
|
|
229
|
+
[sourceLists_ removeObjectForKey:@(parent)];
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
NGNView *parentView = views_[@(parent)];
|
|
233
|
+
if (parentView == nil) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
if (known == nil) {
|
|
237
|
+
known = [[NGNSourceLists alloc] initWithParent:parentView];
|
|
238
|
+
sourceLists_[@(parent)] = known;
|
|
239
|
+
}
|
|
240
|
+
NSMutableDictionary<NSNumber *, NGNView *> *views = views_;
|
|
241
|
+
[known setLists:lists
|
|
242
|
+
views:^NGNView *(NSInteger tag) {
|
|
243
|
+
return views[@(tag)];
|
|
244
|
+
}];
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
void AppKitBackend::announce(SurfaceId, const Announcement &announcement) {
|
|
248
|
+
postAnnouncement(announcement);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
void AppKitBackend::didMount(SurfaceId surfaceId) {
|
|
252
|
+
[NGNPresentedScreenView refreshChrome];
|
|
253
|
+
[NGNModalHostView fitPopovers];
|
|
254
|
+
for (NGNSourceLists *lists in sourceLists_.allValues) {
|
|
255
|
+
[lists layOut];
|
|
256
|
+
}
|
|
257
|
+
for (NSView *view in touched_) {
|
|
258
|
+
for (NGNHeaderToolbar *toolbar in toolbars_.allValues) {
|
|
259
|
+
[toolbar refreshIfShowing:(NGNView *)view];
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
[touched_ removeAllObjects];
|
|
263
|
+
if (onMount) {
|
|
264
|
+
onMount(surfaceId);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
void AppKitBackend::updateDesktopProps(SurfaceId, Tag tag, const DesktopProps &props) {
|
|
269
|
+
[views_[@(tag)] updateDesktopProps:props];
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
std::vector<facebook::react::ComponentDescriptorProvider> AppKitBackend::componentProviders() const {
|
|
273
|
+
return libraryComponents();
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
} // namespace ngn::appkit
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// The OS half of NgNativeAppleAuthentication (the core's apple-authentication.h): AuthenticationServices'
|
|
2
|
+
// Apple ID provider and authorization controller.
|
|
3
|
+
#pragma once
|
|
4
|
+
|
|
5
|
+
#import <Foundation/Foundation.h>
|
|
6
|
+
|
|
7
|
+
#include "ngn/apple-authentication.h"
|
|
8
|
+
|
|
9
|
+
#include <memory>
|
|
10
|
+
|
|
11
|
+
namespace ngn::appkit {
|
|
12
|
+
|
|
13
|
+
std::shared_ptr<AppleIdProvider> makeAppleIdProvider();
|
|
14
|
+
|
|
15
|
+
// Whether a value of the `com.apple.developer.applesignin` entitlement allows Sign in with Apple:
|
|
16
|
+
// an array naming `Default`.
|
|
17
|
+
bool allowsAppleSignIn(id entitlement);
|
|
18
|
+
|
|
19
|
+
} // namespace ngn::appkit
|