@ng-native/desktop 0.0.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +52 -0
- package/app.plugin.cjs +17 -0
- package/bin/app-config.mjs +168 -0
- package/bin/autolink.mjs +224 -0
- package/bin/cli.mjs +158 -0
- package/bin/host.mjs +427 -0
- package/bin/ng-native-desktop.mjs +4 -0
- package/bin/package.mjs +971 -0
- package/bin/plist.mjs +68 -0
- package/bin/prebuilt.mjs +328 -0
- package/bin/toolchain.mjs +192 -0
- package/native/CMakeLists.txt +277 -0
- package/native/appkit/CMakeLists.txt +130 -0
- package/native/appkit/address-search.h +26 -0
- package/native/appkit/address-search.mm +277 -0
- package/native/appkit/animation-frames.h +14 -0
- package/native/appkit/animation-frames.mm +106 -0
- package/native/appkit/app-info.h +12 -0
- package/native/appkit/app-info.mm +98 -0
- package/native/appkit/app-updater.mm +128 -0
- package/native/appkit/app-windows.h +81 -0
- package/native/appkit/app-windows.mm +318 -0
- package/native/appkit/appkit-backend.h +73 -0
- package/native/appkit/appkit-backend.mm +276 -0
- package/native/appkit/apple-authentication.h +19 -0
- package/native/appkit/apple-authentication.mm +248 -0
- package/native/appkit/apple-button-view.h +10 -0
- package/native/appkit/apple-button-view.mm +37 -0
- package/native/appkit/apple-id-button.h +16 -0
- package/native/appkit/apple-id-button.mm +50 -0
- package/native/appkit/audio.h +16 -0
- package/native/appkit/audio.mm +275 -0
- package/native/appkit/battery.h +13 -0
- package/native/appkit/battery.mm +92 -0
- package/native/appkit/bookmarks.h +17 -0
- package/native/appkit/bookmarks.mm +145 -0
- package/native/appkit/calendar.h +25 -0
- package/native/appkit/calendar.mm +660 -0
- package/native/appkit/camera-sheet.h +59 -0
- package/native/appkit/camera-sheet.mm +344 -0
- package/native/appkit/camera-view.h +15 -0
- package/native/appkit/camera-view.mm +134 -0
- package/native/appkit/camera.h +61 -0
- package/native/appkit/camera.mm +496 -0
- package/native/appkit/cg-canvas.h +24 -0
- package/native/appkit/cg-canvas.mm +663 -0
- package/native/appkit/component-view.h +17 -0
- package/native/appkit/crypto.h +19 -0
- package/native/appkit/crypto.mm +78 -0
- package/native/appkit/desktop-expo.h +29 -0
- package/native/appkit/desktop-expo.mm +385 -0
- package/native/appkit/expo-image-drawing.h +46 -0
- package/native/appkit/expo-image-drawing.mm +131 -0
- package/native/appkit/expo-image-view.h +15 -0
- package/native/appkit/expo-image-view.mm +182 -0
- package/native/appkit/expo-ui-renderer.h +68 -0
- package/native/appkit/expo-ui-renderer.mm +101 -0
- package/native/appkit/expo-ui-view.h +26 -0
- package/native/appkit/expo-ui-view.mm +134 -0
- package/native/appkit/expo-ui.swift +1284 -0
- package/native/appkit/file-system.h +16 -0
- package/native/appkit/file-system.mm +140 -0
- package/native/appkit/fonts.h +12 -0
- package/native/appkit/fonts.mm +48 -0
- package/native/appkit/geocoder.h +19 -0
- package/native/appkit/geocoder.mm +101 -0
- package/native/appkit/glass-effect.h +22 -0
- package/native/appkit/glass-effect.mm +63 -0
- package/native/appkit/glass-view.h +8 -0
- package/native/appkit/glass-view.mm +65 -0
- package/native/appkit/header-toolbar.h +60 -0
- package/native/appkit/header-toolbar.mm +632 -0
- package/native/appkit/host-view.h +54 -0
- package/native/appkit/host-view.mm +1228 -0
- package/native/appkit/image-manipulator.h +14 -0
- package/native/appkit/image-manipulator.mm +191 -0
- package/native/appkit/image-request.h +22 -0
- package/native/appkit/image-request.mm +62 -0
- package/native/appkit/image-view.h +8 -0
- package/native/appkit/image-view.mm +142 -0
- package/native/appkit/input-replay.h +25 -0
- package/native/appkit/input-replay.mm +418 -0
- package/native/appkit/language-model.h +14 -0
- package/native/appkit/language-model.mm +99 -0
- package/native/appkit/language-model.swift +472 -0
- package/native/appkit/local-authentication.h +15 -0
- package/native/appkit/local-authentication.mm +133 -0
- package/native/appkit/location.h +16 -0
- package/native/appkit/location.mm +214 -0
- package/native/appkit/main.mm +1475 -0
- package/native/appkit/map-view.h +15 -0
- package/native/appkit/map-view.mm +109 -0
- package/native/appkit/maps.h +35 -0
- package/native/appkit/maps.mm +343 -0
- package/native/appkit/menu-bar.h +22 -0
- package/native/appkit/menu-bar.mm +208 -0
- package/native/appkit/modal-focus.h +16 -0
- package/native/appkit/modal-focus.mm +26 -0
- package/native/appkit/modal-host-view.h +79 -0
- package/native/appkit/modal-host-view.mm +442 -0
- package/native/appkit/native-controls.h +22 -0
- package/native/appkit/native-controls.mm +431 -0
- package/native/appkit/network-state.h +12 -0
- package/native/appkit/network-state.mm +64 -0
- package/native/appkit/network.h +14 -0
- package/native/appkit/network.mm +396 -0
- package/native/appkit/notifications.h +19 -0
- package/native/appkit/notifications.mm +309 -0
- package/native/appkit/photo-library.h +33 -0
- package/native/appkit/photo-library.mm +548 -0
- package/native/appkit/pointer-buttons.h +32 -0
- package/native/appkit/presentation-label.h +15 -0
- package/native/appkit/presentation-label.mm +12 -0
- package/native/appkit/presented-screen.h +19 -0
- package/native/appkit/presented-screen.mm +181 -0
- package/native/appkit/printing.h +42 -0
- package/native/appkit/printing.mm +393 -0
- package/native/appkit/push.h +19 -0
- package/native/appkit/push.mm +81 -0
- package/native/appkit/red-box.h +26 -0
- package/native/appkit/red-box.mm +387 -0
- package/native/appkit/screen-capture.h +21 -0
- package/native/appkit/screen-capture.mm +92 -0
- package/native/appkit/scroll-view.h +13 -0
- package/native/appkit/scroll-view.mm +251 -0
- package/native/appkit/scrollers.h +25 -0
- package/native/appkit/scrollers.mm +43 -0
- package/native/appkit/search-field.h +34 -0
- package/native/appkit/search-field.mm +291 -0
- package/native/appkit/search-toolbar-item.h +19 -0
- package/native/appkit/search-toolbar-item.mm +269 -0
- package/native/appkit/share-picker.h +34 -0
- package/native/appkit/share-picker.mm +121 -0
- package/native/appkit/split-view.h +77 -0
- package/native/appkit/split-view.mm +1206 -0
- package/native/appkit/store-review.h +13 -0
- package/native/appkit/store-review.mm +28 -0
- package/native/appkit/surface-view.h +45 -0
- package/native/appkit/surface-view.mm +562 -0
- package/native/appkit/svg-view.h +18 -0
- package/native/appkit/svg-view.mm +103 -0
- package/native/appkit/symbol-drawing.h +24 -0
- package/native/appkit/symbol-drawing.mm +117 -0
- package/native/appkit/symbol-view.h +8 -0
- package/native/appkit/symbol-view.mm +33 -0
- package/native/appkit/system-access.h +34 -0
- package/native/appkit/system-access.mm +210 -0
- package/native/appkit/system.h +24 -0
- package/native/appkit/system.mm +403 -0
- package/native/appkit/tab-walk.h +31 -0
- package/native/appkit/tab-walk.mm +64 -0
- package/native/appkit/test-launch.h +36 -0
- package/native/appkit/test-launch.mm +115 -0
- package/native/appkit/text-input-field.h +81 -0
- package/native/appkit/text-input-field.mm +525 -0
- package/native/appkit/text-layout.h +58 -0
- package/native/appkit/text-layout.mm +485 -0
- package/native/appkit/text-recognition.h +13 -0
- package/native/appkit/text-recognition.mm +102 -0
- package/native/appkit/tracking.h +13 -0
- package/native/appkit/tracking.mm +51 -0
- package/native/appkit/tray-and-dock.h +45 -0
- package/native/appkit/tray-and-dock.mm +130 -0
- package/native/appkit/undo.h +23 -0
- package/native/appkit/undo.mm +125 -0
- package/native/appkit/updates.h +17 -0
- package/native/appkit/updates.mm +71 -0
- package/native/appkit/video-view.h +10 -0
- package/native/appkit/video-view.mm +42 -0
- package/native/appkit/video.h +38 -0
- package/native/appkit/video.mm +404 -0
- package/native/appkit/web-browser.h +12 -0
- package/native/appkit/web-browser.mm +97 -0
- package/native/appkit/web-view-component.h +10 -0
- package/native/appkit/web-view-component.mm +62 -0
- package/native/appkit/web-view.h +31 -0
- package/native/appkit/web-view.mm +401 -0
- package/native/cmake/libraries/react-native-reanimated.cmake +45 -0
- package/native/cmake/libraries/react-native-worklets.cmake +46 -0
- package/native/cmake/libraries.cmake +109 -0
- package/native/cmake/linked-modules.cmake +112 -0
- package/native/cmake/react-native.cmake +175 -0
- package/native/cmake/runtime-dependencies.cmake +34 -0
- package/native/cmake/swift.cmake +43 -0
- package/native/cmake/third-party.cmake +74 -0
- package/native/core/include/ngn/absent-views.h +27 -0
- package/native/core/include/ngn/accessibility.h +140 -0
- package/native/core/include/ngn/address-search.h +69 -0
- package/native/core/include/ngn/animation-frames.h +39 -0
- package/native/core/include/ngn/app-info.h +52 -0
- package/native/core/include/ngn/app-menus.h +151 -0
- package/native/core/include/ngn/app-windows.h +181 -0
- package/native/core/include/ngn/apple-authentication.h +116 -0
- package/native/core/include/ngn/asset.h +28 -0
- package/native/core/include/ngn/audio.h +125 -0
- package/native/core/include/ngn/back-swipe.h +121 -0
- package/native/core/include/ngn/battery.h +48 -0
- package/native/core/include/ngn/bytes.h +59 -0
- package/native/core/include/ngn/calendar.h +180 -0
- package/native/core/include/ngn/camera.h +222 -0
- package/native/core/include/ngn/control-sizes.h +111 -0
- package/native/core/include/ngn/core-modules.h +108 -0
- package/native/core/include/ngn/crypto.h +38 -0
- package/native/core/include/ngn/default-menu.h +91 -0
- package/native/core/include/ngn/desktop-expo.h +193 -0
- package/native/core/include/ngn/desktop-modal.h +109 -0
- package/native/core/include/ngn/desktop-props.h +75 -0
- package/native/core/include/ngn/desktop-view-props.h +110 -0
- package/native/core/include/ngn/dev-server.h +33 -0
- package/native/core/include/ngn/dom-web-view.h +53 -0
- package/native/core/include/ngn/download.h +24 -0
- package/native/core/include/ngn/expo-image.h +192 -0
- package/native/core/include/ngn/expo-ui.h +133 -0
- package/native/core/include/ngn/file-system.h +274 -0
- package/native/core/include/ngn/focus-order.h +63 -0
- package/native/core/include/ngn/fonts.h +64 -0
- package/native/core/include/ngn/gestures.h +305 -0
- package/native/core/include/ngn/glass.h +67 -0
- package/native/core/include/ngn/header-bar.h +112 -0
- package/native/core/include/ngn/host-state.h +243 -0
- package/native/core/include/ngn/image-manipulator.h +70 -0
- package/native/core/include/ngn/input-dispatcher.h +211 -0
- package/native/core/include/ngn/input-script.h +56 -0
- package/native/core/include/ngn/input.h +112 -0
- package/native/core/include/ngn/key-value-store.h +41 -0
- package/native/core/include/ngn/language-model.h +69 -0
- package/native/core/include/ngn/launch-frame.h +47 -0
- package/native/core/include/ngn/launch-settings.h +98 -0
- package/native/core/include/ngn/layout-animations.h +24 -0
- package/native/core/include/ngn/library-components.h +13 -0
- package/native/core/include/ngn/library-glue.h +53 -0
- package/native/core/include/ngn/live-regions.h +54 -0
- package/native/core/include/ngn/local-authentication.h +74 -0
- package/native/core/include/ngn/location.h +89 -0
- package/native/core/include/ngn/maps.h +226 -0
- package/native/core/include/ngn/module-registry.h +51 -0
- package/native/core/include/ngn/mounting-backend.h +96 -0
- package/native/core/include/ngn/mounting-manager.h +155 -0
- package/native/core/include/ngn/native-controls.h +161 -0
- package/native/core/include/ngn/native-module.h +109 -0
- package/native/core/include/ngn/network-state.h +44 -0
- package/native/core/include/ngn/network.h +100 -0
- package/native/core/include/ngn/notifications.h +185 -0
- package/native/core/include/ngn/photo-library.h +134 -0
- package/native/core/include/ngn/printing.h +69 -0
- package/native/core/include/ngn/processes.h +114 -0
- package/native/core/include/ngn/red-box.h +119 -0
- package/native/core/include/ngn/reload-thread.h +258 -0
- package/native/core/include/ngn/runtime.h +163 -0
- package/native/core/include/ngn/safe-areas.h +82 -0
- package/native/core/include/ngn/screen-capture.h +35 -0
- package/native/core/include/ngn/screen-presentation.h +85 -0
- package/native/core/include/ngn/screen-stacks.h +80 -0
- package/native/core/include/ngn/scrollers.h +106 -0
- package/native/core/include/ngn/sharing.h +39 -0
- package/native/core/include/ngn/spawn-rules.h +78 -0
- package/native/core/include/ngn/splash-screen.h +41 -0
- package/native/core/include/ngn/split-view.h +270 -0
- package/native/core/include/ngn/sqlite.h +38 -0
- package/native/core/include/ngn/store-review.h +26 -0
- package/native/core/include/ngn/surface-book.h +101 -0
- package/native/core/include/ngn/surface-metrics.h +51 -0
- package/native/core/include/ngn/svg.h +434 -0
- package/native/core/include/ngn/symbol.h +90 -0
- package/native/core/include/ngn/system.h +102 -0
- package/native/core/include/ngn/tabs-host.h +171 -0
- package/native/core/include/ngn/text-input.h +134 -0
- package/native/core/include/ngn/text-measurer.h +38 -0
- package/native/core/include/ngn/text-recognition.h +55 -0
- package/native/core/include/ngn/tracking.h +34 -0
- package/native/core/include/ngn/tray-and-dock.h +107 -0
- package/native/core/include/ngn/undo.h +37 -0
- package/native/core/include/ngn/updates.h +253 -0
- package/native/core/include/ngn/video.h +126 -0
- package/native/core/include/ngn/view-box.h +126 -0
- package/native/core/include/ngn/view-transform.h +26 -0
- package/native/core/include/ngn/view-tree.h +85 -0
- package/native/core/include/ngn/web-browser.h +45 -0
- package/native/core/include/ngn/web-view.h +137 -0
- package/native/core/include/ngn/worklet-host.h +98 -0
- package/native/core/src/absent-views.cpp +41 -0
- package/native/core/src/accessibility.cpp +374 -0
- package/native/core/src/animation-frames.cpp +49 -0
- package/native/core/src/app-menus.cpp +359 -0
- package/native/core/src/app-windows.cpp +444 -0
- package/native/core/src/back-swipe.cpp +98 -0
- package/native/core/src/bytes.cpp +158 -0
- package/native/core/src/control-sizes.cpp +232 -0
- package/native/core/src/default-menu.cpp +96 -0
- package/native/core/src/desktop-modal.cpp +162 -0
- package/native/core/src/desktop-view-props.cpp +80 -0
- package/native/core/src/dev-server-helper.cpp +152 -0
- package/native/core/src/dev-server.cpp +103 -0
- package/native/core/src/dom-web-view.cpp +45 -0
- package/native/core/src/download.cpp +53 -0
- package/native/core/src/expo-image.cpp +548 -0
- package/native/core/src/expo-ui.cpp +203 -0
- package/native/core/src/focus-order.cpp +441 -0
- package/native/core/src/gestures.cpp +1806 -0
- package/native/core/src/glass.cpp +49 -0
- package/native/core/src/header-bar.cpp +104 -0
- package/native/core/src/host-services.cpp +50 -0
- package/native/core/src/host-state.cpp +61 -0
- package/native/core/src/input-dispatcher.cpp +727 -0
- package/native/core/src/input-script.cpp +123 -0
- package/native/core/src/key-value-store.cpp +169 -0
- package/native/core/src/launch-settings.cpp +148 -0
- package/native/core/src/layout-animations.cpp +62 -0
- package/native/core/src/libraries/RNCWebViewSpec.cpp +80 -0
- package/native/core/src/libraries/react-native-reanimated.cpp +216 -0
- package/native/core/src/libraries/react-native-worklets.cpp +192 -0
- package/native/core/src/libraries/rnscreens.cpp +125 -0
- package/native/core/src/libraries/rnsvg.cpp +358 -0
- package/native/core/src/libraries/safeareacontext.cpp +70 -0
- package/native/core/src/libraries/worklets-idle-frames.js +70 -0
- package/native/core/src/library-glue.cpp +35 -0
- package/native/core/src/live-regions.cpp +122 -0
- package/native/core/src/module-registry.cpp +50 -0
- package/native/core/src/modules/accessibility-manager.cpp +98 -0
- package/native/core/src/modules/address-search.cpp +219 -0
- package/native/core/src/modules/alert-manager.cpp +140 -0
- package/native/core/src/modules/app-info.cpp +74 -0
- package/native/core/src/modules/app-modules.cpp +412 -0
- package/native/core/src/modules/apple-authentication.cpp +188 -0
- package/native/core/src/modules/asset.cpp +111 -0
- package/native/core/src/modules/async-storage.cpp +192 -0
- package/native/core/src/modules/audio.cpp +541 -0
- package/native/core/src/modules/battery.cpp +88 -0
- package/native/core/src/modules/calendar.cpp +457 -0
- package/native/core/src/modules/camera.cpp +401 -0
- package/native/core/src/modules/core-modules.cpp +62 -0
- package/native/core/src/modules/crypto.cpp +117 -0
- package/native/core/src/modules/desktop-expo.cpp +527 -0
- package/native/core/src/modules/file-system.cpp +941 -0
- package/native/core/src/modules/fonts.cpp +163 -0
- package/native/core/src/modules/image-loader.cpp +105 -0
- package/native/core/src/modules/image-manipulator.cpp +305 -0
- package/native/core/src/modules/language-model.cpp +195 -0
- package/native/core/src/modules/local-authentication.cpp +140 -0
- package/native/core/src/modules/location.cpp +186 -0
- package/native/core/src/modules/maps.cpp +500 -0
- package/native/core/src/modules/network-state.cpp +72 -0
- package/native/core/src/modules/networking.cpp +387 -0
- package/native/core/src/modules/notifications.cpp +549 -0
- package/native/core/src/modules/photo-library.cpp +385 -0
- package/native/core/src/modules/printing.cpp +201 -0
- package/native/core/src/modules/screen-capture.cpp +71 -0
- package/native/core/src/modules/sharing.cpp +59 -0
- package/native/core/src/modules/splash-screen.cpp +70 -0
- package/native/core/src/modules/sqlite.cpp +421 -0
- package/native/core/src/modules/store-review.cpp +23 -0
- package/native/core/src/modules/text-recognition.cpp +107 -0
- package/native/core/src/modules/tracking.cpp +46 -0
- package/native/core/src/modules/undo.cpp +59 -0
- package/native/core/src/modules/video.cpp +366 -0
- package/native/core/src/modules/web-browser.cpp +100 -0
- package/native/core/src/modules/web-socket.cpp +266 -0
- package/native/core/src/mounting-manager.cpp +384 -0
- package/native/core/src/native-controls.cpp +129 -0
- package/native/core/src/native-module.cpp +250 -0
- package/native/core/src/network.cpp +219 -0
- package/native/core/src/posix-launcher.cpp +366 -0
- package/native/core/src/processes.cpp +324 -0
- package/native/core/src/red-box-errors.js +83 -0
- package/native/core/src/red-box.cpp +306 -0
- package/native/core/src/runtime.cpp +420 -0
- package/native/core/src/safe-areas.cpp +137 -0
- package/native/core/src/screen-presentation.cpp +61 -0
- package/native/core/src/screen-stacks.cpp +254 -0
- package/native/core/src/scrollers.cpp +181 -0
- package/native/core/src/spawn-rules.cpp +292 -0
- package/native/core/src/split-view.cpp +343 -0
- package/native/core/src/svg.cpp +2190 -0
- package/native/core/src/symbol.cpp +94 -0
- package/native/core/src/tabs-host.cpp +234 -0
- package/native/core/src/text-input.cpp +139 -0
- package/native/core/src/text-layout-manager.cpp +63 -0
- package/native/core/src/tray-and-dock.cpp +154 -0
- package/native/core/src/updates.cpp +965 -0
- package/native/core/src/view-box.cpp +788 -0
- package/native/core/src/view-transform.cpp +45 -0
- package/native/core/src/view-tree.cpp +234 -0
- package/native/core/src/web-view.cpp +143 -0
- package/native/core/src/worklet-host.cpp +10 -0
- package/native/scripts/build-hermes.sh +44 -0
- package/native/scripts/build.sh +175 -0
- package/native/scripts/cache-dir.sh +18 -0
- package/native/scripts/codegen-library.sh +193 -0
- package/native/scripts/compiler-launcher.sh +17 -0
- package/native/scripts/fetch.sh +174 -0
- package/native/scripts/hermes-built.sh +10 -0
- package/native/scripts/host-dir.sh +16 -0
- package/native/scripts/launch-probe.sh +60 -0
- package/native/scripts/macos-target.sh +8 -0
- package/native/scripts/make-prebuilt.mjs +360 -0
- package/native/scripts/prebuilt-host-cache.mjs +158 -0
- package/native/shim/openssl/sha.h +22 -0
- package/native/shim/view-platform/react/renderer/components/view/HostPlatformViewTraitsInitializer.h +37 -0
- package/package.json +73 -1
- package/prebuilt.json +33 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// The OS half of NgNativeFileSystem (the core's file-system.h): FSEvents and the Mac's folders.
|
|
2
|
+
#pragma once
|
|
3
|
+
|
|
4
|
+
#include "ngn/file-system.h"
|
|
5
|
+
|
|
6
|
+
#include <memory>
|
|
7
|
+
#include <string>
|
|
8
|
+
|
|
9
|
+
namespace ngn::appkit {
|
|
10
|
+
|
|
11
|
+
std::shared_ptr<FileWatcher> makeFileWatcher();
|
|
12
|
+
// The app's folders and the user's: `appData` and `cache` as the host already makes them, the
|
|
13
|
+
// documents in appData's Documents, and the system's temporary folder.
|
|
14
|
+
FileAccess::Folders fileFolders(const std::string &appData, const std::string &cache);
|
|
15
|
+
|
|
16
|
+
} // namespace ngn::appkit
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// The OS half of NgNativeFileSystem: FSEvents streams with file-level events, one per watch, each
|
|
2
|
+
// on its own serial queue, and the folders NSFileManager names.
|
|
3
|
+
#import "file-system.h"
|
|
4
|
+
#import "test-launch.h"
|
|
5
|
+
|
|
6
|
+
#import <CoreServices/CoreServices.h>
|
|
7
|
+
#import <Foundation/Foundation.h>
|
|
8
|
+
|
|
9
|
+
#include <climits>
|
|
10
|
+
#include <cstdlib>
|
|
11
|
+
#include <map>
|
|
12
|
+
#include <mutex>
|
|
13
|
+
|
|
14
|
+
namespace ngn::appkit {
|
|
15
|
+
|
|
16
|
+
namespace {
|
|
17
|
+
|
|
18
|
+
std::string str(NSString *s) {
|
|
19
|
+
return s != nil ? std::string(s.UTF8String) : std::string{};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// The path with every link followed (/var is /private/var), as FSEvents reports paths, and with
|
|
23
|
+
// no trailing slash. Foundation's own resolving strips /private, so this is realpath's.
|
|
24
|
+
std::string plain(NSString *path) {
|
|
25
|
+
char resolved[PATH_MAX];
|
|
26
|
+
if (realpath(path.fileSystemRepresentation, resolved) != nullptr) {
|
|
27
|
+
return resolved;
|
|
28
|
+
}
|
|
29
|
+
return str([path hasSuffix:@"/"] && path.length > 1 ? [path substringToIndex:path.length - 1] : path);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
struct Stream {
|
|
33
|
+
FSEventStreamRef stream{nullptr};
|
|
34
|
+
dispatch_queue_t queue{nil};
|
|
35
|
+
std::function<void(std::vector<FileWatcher::Event>)> events;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
void callback(ConstFSEventStreamRef, void *info, size_t count, void *paths, const FSEventStreamEventFlags flags[],
|
|
39
|
+
const FSEventStreamEventId[]) {
|
|
40
|
+
auto *stream = static_cast<Stream *>(info);
|
|
41
|
+
auto **names = static_cast<char **>(paths);
|
|
42
|
+
std::vector<FileWatcher::Event> batch;
|
|
43
|
+
for (size_t i = 0; i < count; i++) {
|
|
44
|
+
batch.push_back({
|
|
45
|
+
.path = names[i],
|
|
46
|
+
.created = (flags[i] & kFSEventStreamEventFlagItemCreated) != 0,
|
|
47
|
+
.removed = (flags[i] & kFSEventStreamEventFlagItemRemoved) != 0,
|
|
48
|
+
.renamed = (flags[i] & kFSEventStreamEventFlagItemRenamed) != 0,
|
|
49
|
+
.modified = (flags[i] & (kFSEventStreamEventFlagItemModified | kFSEventStreamEventFlagItemInodeMetaMod)) != 0,
|
|
50
|
+
// Set too when FSEvents or the kernel dropped events.
|
|
51
|
+
.rescan = (flags[i] & kFSEventStreamEventFlagMustScanSubDirs) != 0,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
stream->events(std::move(batch));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
class FSEventsWatcher final : public FileWatcher {
|
|
58
|
+
public:
|
|
59
|
+
int start(const std::string &path, std::function<void(std::vector<Event>)> events) override {
|
|
60
|
+
// A file is watched through its folder; the core keeps only the file's own events.
|
|
61
|
+
BOOL folder = NO;
|
|
62
|
+
NSString *at = [NSString stringWithUTF8String:path.c_str()];
|
|
63
|
+
[NSFileManager.defaultManager fileExistsAtPath:at isDirectory:&folder];
|
|
64
|
+
NSString *watched = folder ? at : at.stringByDeletingLastPathComponent;
|
|
65
|
+
|
|
66
|
+
auto stream = std::make_unique<Stream>();
|
|
67
|
+
stream->events = std::move(events);
|
|
68
|
+
stream->queue = dispatch_queue_create("ngn.file-watch", DISPATCH_QUEUE_SERIAL);
|
|
69
|
+
FSEventStreamContext context{.version = 0, .info = stream.get()};
|
|
70
|
+
CFArrayRef paths = (__bridge CFArrayRef) @[ watched ];
|
|
71
|
+
stream->stream = FSEventStreamCreate(
|
|
72
|
+
nullptr, callback, &context, paths, kFSEventStreamEventIdSinceNow, 0.1,
|
|
73
|
+
kFSEventStreamCreateFlagFileEvents | kFSEventStreamCreateFlagNoDefer | kFSEventStreamCreateFlagWatchRoot);
|
|
74
|
+
if (stream->stream == nullptr) {
|
|
75
|
+
return 0;
|
|
76
|
+
}
|
|
77
|
+
FSEventStreamSetDispatchQueue(stream->stream, stream->queue);
|
|
78
|
+
if (!FSEventStreamStart(stream->stream)) {
|
|
79
|
+
FSEventStreamInvalidate(stream->stream);
|
|
80
|
+
FSEventStreamRelease(stream->stream);
|
|
81
|
+
return 0;
|
|
82
|
+
}
|
|
83
|
+
std::lock_guard lock(mutex_);
|
|
84
|
+
int handle = ++next_;
|
|
85
|
+
streams_[handle] = std::move(stream);
|
|
86
|
+
return handle;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
void stop(int handle) override {
|
|
90
|
+
std::unique_ptr<Stream> stream;
|
|
91
|
+
{
|
|
92
|
+
std::lock_guard lock(mutex_);
|
|
93
|
+
auto it = streams_.find(handle);
|
|
94
|
+
if (it == streams_.end()) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
stream = std::move(it->second);
|
|
98
|
+
streams_.erase(it);
|
|
99
|
+
}
|
|
100
|
+
// On its own queue, so no callback is running or follows once this returns.
|
|
101
|
+
FSEventStreamRef ref = stream->stream;
|
|
102
|
+
dispatch_sync(stream->queue, ^{
|
|
103
|
+
FSEventStreamStop(ref);
|
|
104
|
+
FSEventStreamInvalidate(ref);
|
|
105
|
+
FSEventStreamRelease(ref);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
private:
|
|
110
|
+
std::mutex mutex_;
|
|
111
|
+
std::map<int, std::unique_ptr<Stream>> streams_;
|
|
112
|
+
int next_{0};
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
} // namespace
|
|
116
|
+
|
|
117
|
+
std::shared_ptr<FileWatcher> makeFileWatcher() {
|
|
118
|
+
return std::make_shared<FSEventsWatcher>();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
FileAccess::Folders fileFolders(const std::string &appData, const std::string &cache) {
|
|
122
|
+
NSFileManager *files = NSFileManager.defaultManager;
|
|
123
|
+
auto user = [files](NSSearchPathDirectory directory) {
|
|
124
|
+
NSURL *url = [files URLsForDirectory:directory inDomains:NSUserDomainMask].firstObject;
|
|
125
|
+
return url != nil ? plain(url.path) : std::string{};
|
|
126
|
+
};
|
|
127
|
+
NSString *documents = [[NSString stringWithUTF8String:appData.c_str()] stringByAppendingPathComponent:@"Documents"];
|
|
128
|
+
[files createDirectoryAtPath:documents withIntermediateDirectories:YES attributes:nil error:nil];
|
|
129
|
+
return {
|
|
130
|
+
.cache = plain([NSString stringWithUTF8String:cache.c_str()]),
|
|
131
|
+
.document = plain(documents),
|
|
132
|
+
.appData = plain([NSString stringWithUTF8String:appData.c_str()]),
|
|
133
|
+
.temp = testLaunch() ? plain([NSString stringWithUTF8String:testLaunch()->temp().c_str()]) : plain(NSTemporaryDirectory()),
|
|
134
|
+
.home = plain(NSHomeDirectory()),
|
|
135
|
+
.desktop = user(NSDesktopDirectory),
|
|
136
|
+
.downloads = user(NSDownloadsDirectory),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
} // namespace ngn::appkit
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// The OS half of NgNativeFont (the core's fonts.h): CTFontManager, registering for this process.
|
|
2
|
+
#pragma once
|
|
3
|
+
|
|
4
|
+
#include "ngn/fonts.h"
|
|
5
|
+
|
|
6
|
+
#include <memory>
|
|
7
|
+
|
|
8
|
+
namespace ngn::appkit {
|
|
9
|
+
|
|
10
|
+
std::shared_ptr<FontRegistrar> makeFontRegistrar();
|
|
11
|
+
|
|
12
|
+
} // namespace ngn::appkit
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#include "fonts.h"
|
|
2
|
+
|
|
3
|
+
#import <CoreText/CoreText.h>
|
|
4
|
+
#import <Foundation/Foundation.h>
|
|
5
|
+
|
|
6
|
+
#include <stdexcept>
|
|
7
|
+
|
|
8
|
+
namespace ngn::appkit {
|
|
9
|
+
|
|
10
|
+
namespace {
|
|
11
|
+
|
|
12
|
+
std::string stringOf(CFStringRef value) {
|
|
13
|
+
return value != nullptr ? std::string([(__bridge NSString *)value UTF8String]) : "";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
class CoreTextRegistrar final : public FontRegistrar {
|
|
17
|
+
public:
|
|
18
|
+
RegisteredFont registerFile(const std::string &path) override {
|
|
19
|
+
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithUTF8String:path.c_str()]];
|
|
20
|
+
NSArray *descriptors = CFBridgingRelease(CTFontManagerCreateFontDescriptorsFromURL((__bridge CFURLRef)url));
|
|
21
|
+
if (descriptors.count == 0) {
|
|
22
|
+
throw std::runtime_error([NSFileManager.defaultManager fileExistsAtPath:url.path] ? "the file is not a font CoreText reads"
|
|
23
|
+
: "there is no such file");
|
|
24
|
+
}
|
|
25
|
+
auto descriptor = (__bridge CTFontDescriptorRef)descriptors.firstObject;
|
|
26
|
+
RegisteredFont font{
|
|
27
|
+
.family = stringOf((__bridge CFStringRef)CFBridgingRelease(CTFontDescriptorCopyAttribute(descriptor, kCTFontFamilyNameAttribute))),
|
|
28
|
+
.postScriptName = stringOf((__bridge CFStringRef)CFBridgingRelease(CTFontDescriptorCopyAttribute(descriptor, kCTFontNameAttribute))),
|
|
29
|
+
};
|
|
30
|
+
CFErrorRef error = nullptr;
|
|
31
|
+
if (!CTFontManagerRegisterFontsForURL((__bridge CFURLRef)url, kCTFontManagerScopeProcess, &error)) {
|
|
32
|
+
NSError *failure = CFBridgingRelease(error);
|
|
33
|
+
// Registered before, by this process or the system: it is there to use either way.
|
|
34
|
+
if (failure.code != kCTFontManagerErrorAlreadyRegistered && failure.code != kCTFontManagerErrorDuplicatedName) {
|
|
35
|
+
throw std::runtime_error(failure.localizedDescription.UTF8String);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return font;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
} // namespace
|
|
43
|
+
|
|
44
|
+
std::shared_ptr<FontRegistrar> makeFontRegistrar() {
|
|
45
|
+
return std::make_shared<CoreTextRegistrar>();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
} // namespace ngn::appkit
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// The geocoding half of NgNativeLocation (the core's location.h Geocoder): CLGeocoder, which needs
|
|
2
|
+
// no location permission. It answers on the main thread.
|
|
3
|
+
#pragma once
|
|
4
|
+
|
|
5
|
+
#include "ngn/location.h"
|
|
6
|
+
|
|
7
|
+
#import <CoreLocation/CoreLocation.h>
|
|
8
|
+
|
|
9
|
+
#include <memory>
|
|
10
|
+
|
|
11
|
+
namespace ngn::appkit {
|
|
12
|
+
|
|
13
|
+
std::shared_ptr<Geocoder> makeGeocoder();
|
|
14
|
+
|
|
15
|
+
// What CLGeocoder's completion gives, as the core's answer: no result and a partial result as no
|
|
16
|
+
// places, kCLErrorNetwork (offline or rate limited) as Network, any other error as Failed.
|
|
17
|
+
Geocoder::Answer geocoderAnswer(NSArray<CLPlacemark *> *placemarks, NSError *error);
|
|
18
|
+
|
|
19
|
+
} // namespace ngn::appkit
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#include "geocoder.h"
|
|
2
|
+
|
|
3
|
+
#import <CoreLocation/CoreLocation.h>
|
|
4
|
+
#import <Foundation/Foundation.h>
|
|
5
|
+
|
|
6
|
+
namespace ngn::appkit {
|
|
7
|
+
|
|
8
|
+
namespace {
|
|
9
|
+
|
|
10
|
+
using Answer = Geocoder::Answer;
|
|
11
|
+
|
|
12
|
+
void put(std::map<std::string, std::string> &address, const char *field, NSString *value) {
|
|
13
|
+
if (value.length > 0) {
|
|
14
|
+
address[field] = value.UTF8String;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
Geocoder::Place placeOf(CLPlacemark *placemark) {
|
|
19
|
+
Geocoder::Place place;
|
|
20
|
+
if (CLLocation *location = placemark.location) {
|
|
21
|
+
place.latitude = location.coordinate.latitude;
|
|
22
|
+
place.longitude = location.coordinate.longitude;
|
|
23
|
+
// Core Location's altitude is 0 when its vertical accuracy is 0 or less: not known.
|
|
24
|
+
if (location.verticalAccuracy > 0) {
|
|
25
|
+
place.altitude = location.ellipsoidalAltitude;
|
|
26
|
+
}
|
|
27
|
+
if (location.horizontalAccuracy >= 0) {
|
|
28
|
+
place.accuracy = location.horizontalAccuracy;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
// expo-location's iOS names for CLPlacemark's fields.
|
|
32
|
+
put(place.address, "city", placemark.locality);
|
|
33
|
+
put(place.address, "district", placemark.subLocality);
|
|
34
|
+
put(place.address, "streetNumber", placemark.subThoroughfare);
|
|
35
|
+
put(place.address, "street", placemark.thoroughfare);
|
|
36
|
+
put(place.address, "region", placemark.administrativeArea);
|
|
37
|
+
put(place.address, "subregion", placemark.subAdministrativeArea);
|
|
38
|
+
put(place.address, "country", placemark.country);
|
|
39
|
+
put(place.address, "postalCode", placemark.postalCode);
|
|
40
|
+
put(place.address, "name", placemark.name);
|
|
41
|
+
put(place.address, "isoCountryCode", placemark.ISOcountryCode);
|
|
42
|
+
put(place.address, "timezone", placemark.timeZone.name);
|
|
43
|
+
return place;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
CLGeocodeCompletionHandler answering(std::function<void(Answer)> done) {
|
|
47
|
+
auto answer = std::make_shared<std::function<void(Answer)>>(std::move(done));
|
|
48
|
+
return ^(NSArray<CLPlacemark *> *placemarks, NSError *error) {
|
|
49
|
+
(*answer)(geocoderAnswer(placemarks, error));
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
class CoreLocationGeocoder final : public Geocoder {
|
|
54
|
+
public:
|
|
55
|
+
// A geocoder per request, as expo-location's: one CLGeocoder runs one request at a time.
|
|
56
|
+
void geocode(const std::string &address, std::function<void(Answer)> done) override {
|
|
57
|
+
CLGeocoder *geocoder = [CLGeocoder new];
|
|
58
|
+
auto handler = answering(std::move(done));
|
|
59
|
+
NSString *text = [NSString stringWithUTF8String:address.c_str()];
|
|
60
|
+
[geocoder geocodeAddressString:text != nil ? text : @""
|
|
61
|
+
completionHandler:^(NSArray<CLPlacemark *> *placemarks, NSError *error) {
|
|
62
|
+
(void)geocoder;
|
|
63
|
+
handler(placemarks, error);
|
|
64
|
+
}];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
void reverseGeocode(double latitude, double longitude, std::function<void(Answer)> done) override {
|
|
68
|
+
CLGeocoder *geocoder = [CLGeocoder new];
|
|
69
|
+
auto handler = answering(std::move(done));
|
|
70
|
+
CLLocation *location = [[CLLocation alloc] initWithLatitude:latitude longitude:longitude];
|
|
71
|
+
[geocoder reverseGeocodeLocation:location
|
|
72
|
+
completionHandler:^(NSArray<CLPlacemark *> *placemarks, NSError *error) {
|
|
73
|
+
(void)geocoder;
|
|
74
|
+
handler(placemarks, error);
|
|
75
|
+
}];
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
} // namespace
|
|
80
|
+
|
|
81
|
+
Geocoder::Answer geocoderAnswer(NSArray<CLPlacemark *> *placemarks, NSError *error) {
|
|
82
|
+
Answer result;
|
|
83
|
+
if (error) {
|
|
84
|
+
bool none = [error.domain isEqualToString:kCLErrorDomain] &&
|
|
85
|
+
(error.code == kCLErrorGeocodeFoundNoResult || error.code == kCLErrorGeocodeFoundPartialResult);
|
|
86
|
+
bool network = [error.domain isEqualToString:kCLErrorDomain] && error.code == kCLErrorNetwork;
|
|
87
|
+
result.failure = none ? Geocoder::Failure::NoResult : network ? Geocoder::Failure::Network : Geocoder::Failure::Failed;
|
|
88
|
+
result.reason = error.localizedDescription.length > 0 ? error.localizedDescription.UTF8String : "";
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
for (CLPlacemark *placemark in placemarks) {
|
|
92
|
+
result.places.push_back(placeOf(placemark));
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
std::shared_ptr<Geocoder> makeGeocoder() {
|
|
98
|
+
return std::make_shared<CoreLocationGeocoder>();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
} // namespace ngn::appkit
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// The material an `<expo-glass>` draws behind its children (the core's glass.h): Liquid Glass,
|
|
2
|
+
// NSGlassEffectView, from macOS 26, and an NSVisualEffectView before it. Found by name, so a host
|
|
3
|
+
// built with an older SDK still draws Liquid Glass on macOS 26.
|
|
4
|
+
#pragma once
|
|
5
|
+
|
|
6
|
+
#include "ngn/glass.h"
|
|
7
|
+
|
|
8
|
+
#import <AppKit/AppKit.h>
|
|
9
|
+
|
|
10
|
+
namespace ngn::appkit {
|
|
11
|
+
|
|
12
|
+
// Whether this Mac has NSGlassEffectView.
|
|
13
|
+
bool liquidGlassAvailable();
|
|
14
|
+
|
|
15
|
+
// A new view of the material for `glass`: NSGlassEffectView where `liquid` and the Mac has it,
|
|
16
|
+
// else an NSVisualEffectView.
|
|
17
|
+
NSView *makeGlassEffect(const Glass &glass, bool liquid);
|
|
18
|
+
|
|
19
|
+
// Sets `effect`'s style, tint, appearance and corners to `glass` and `radius`.
|
|
20
|
+
void updateGlassEffect(NSView *effect, const Glass &glass, CGFloat radius);
|
|
21
|
+
|
|
22
|
+
} // namespace ngn::appkit
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#import "glass-effect.h"
|
|
2
|
+
|
|
3
|
+
#include <react/renderer/graphics/Color.h>
|
|
4
|
+
|
|
5
|
+
namespace ngn::appkit {
|
|
6
|
+
|
|
7
|
+
namespace {
|
|
8
|
+
|
|
9
|
+
NSColor *colorOf(const facebook::react::SharedColor &color) {
|
|
10
|
+
if (!color) {
|
|
11
|
+
return nil;
|
|
12
|
+
}
|
|
13
|
+
auto rgba = facebook::react::colorComponentsFromColor(color);
|
|
14
|
+
return [NSColor colorWithSRGBRed:rgba.red green:rgba.green blue:rgba.blue alpha:rgba.alpha];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// NSGlassEffectViewStyleRegular and NSGlassEffectViewStyleClear.
|
|
18
|
+
constexpr NSInteger kGlassRegular = 0;
|
|
19
|
+
constexpr NSInteger kGlassClear = 1;
|
|
20
|
+
|
|
21
|
+
} // namespace
|
|
22
|
+
|
|
23
|
+
bool liquidGlassAvailable() {
|
|
24
|
+
return NSClassFromString(@"NSGlassEffectView") != nil;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
NSView *makeGlassEffect(const Glass &glass, bool liquid) {
|
|
28
|
+
NSView *effect = nil;
|
|
29
|
+
if (Class glassClass = liquid ? NSClassFromString(@"NSGlassEffectView") : nil) {
|
|
30
|
+
effect = [[glassClass alloc] initWithFrame:NSZeroRect];
|
|
31
|
+
} else {
|
|
32
|
+
NSVisualEffectView *visual = [[NSVisualEffectView alloc] initWithFrame:NSZeroRect];
|
|
33
|
+
visual.blendingMode = NSVisualEffectBlendingModeWithinWindow;
|
|
34
|
+
visual.state = NSVisualEffectStateActive;
|
|
35
|
+
effect = visual;
|
|
36
|
+
}
|
|
37
|
+
effect.wantsLayer = YES;
|
|
38
|
+
effect.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
|
|
39
|
+
updateGlassEffect(effect, glass, 0);
|
|
40
|
+
return effect;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
void updateGlassEffect(NSView *effect, const Glass &glass, CGFloat radius) {
|
|
44
|
+
if (glass.dark) {
|
|
45
|
+
effect.appearance = [NSAppearance appearanceNamed:*glass.dark ? NSAppearanceNameDarkAqua : NSAppearanceNameAqua];
|
|
46
|
+
} else {
|
|
47
|
+
effect.appearance = nil;
|
|
48
|
+
}
|
|
49
|
+
if ([effect isKindOfClass:NSVisualEffectView.class]) {
|
|
50
|
+
auto *visual = (NSVisualEffectView *)effect;
|
|
51
|
+
// Regular glass is frosted like a popover; clear lets more through.
|
|
52
|
+
visual.material = glass.style == Glass::Style::Clear ? NSVisualEffectMaterialFullScreenUI : NSVisualEffectMaterialPopover;
|
|
53
|
+
visual.layer.cornerRadius = radius;
|
|
54
|
+
visual.layer.masksToBounds = radius > 0;
|
|
55
|
+
visual.layer.backgroundColor = colorOf(glass.tint).CGColor;
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
[effect setValue:@(glass.style == Glass::Style::Clear ? kGlassClear : kGlassRegular) forKey:@"style"];
|
|
59
|
+
[effect setValue:@(radius) forKey:@"cornerRadius"];
|
|
60
|
+
[effect setValue:colorOf(glass.tint) forKey:@"tintColor"];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
} // namespace ngn::appkit
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// `<expo-glass>`'s view on macOS (the core's glass.h): an NGNView with the glass material
|
|
2
|
+
// (glass-effect.h) behind a container its children mount into, in the view's own corners.
|
|
3
|
+
#pragma once
|
|
4
|
+
|
|
5
|
+
#import "host-view.h"
|
|
6
|
+
|
|
7
|
+
@interface NGNGlassView : NGNView
|
|
8
|
+
@end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#import "glass-view.h"
|
|
2
|
+
|
|
3
|
+
#import "glass-effect.h"
|
|
4
|
+
|
|
5
|
+
using namespace facebook::react;
|
|
6
|
+
|
|
7
|
+
// The children's container: y-down, as every view the host mounts into.
|
|
8
|
+
@interface NGNGlassContent : NSView
|
|
9
|
+
@end
|
|
10
|
+
|
|
11
|
+
@implementation NGNGlassContent
|
|
12
|
+
- (BOOL)isFlipped {
|
|
13
|
+
return YES;
|
|
14
|
+
}
|
|
15
|
+
@end
|
|
16
|
+
|
|
17
|
+
@implementation NGNGlassView {
|
|
18
|
+
NSView *_effect;
|
|
19
|
+
NGNGlassContent *_content;
|
|
20
|
+
std::optional<ngn::Glass> _glass;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
- (instancetype)initWithShadowView:(const ShadowView &)view {
|
|
24
|
+
if ((self = [super initWithShadowView:view])) {
|
|
25
|
+
_content = [[NGNGlassContent alloc] initWithFrame:self.bounds];
|
|
26
|
+
_content.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
|
|
27
|
+
[self addSubview:_content];
|
|
28
|
+
}
|
|
29
|
+
return self;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
- (NSView *)contentContainer {
|
|
33
|
+
return _content;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
- (void)updateProps:(const Props::Shared &)props {
|
|
37
|
+
[super updateProps:props];
|
|
38
|
+
auto glass = std::dynamic_pointer_cast<const ngn::GlassProps>(props);
|
|
39
|
+
_glass = glass ? ngn::glassOf(*glass) : std::nullopt;
|
|
40
|
+
[self updateGlass];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
- (void)updateLayout:(const LayoutMetrics &)metrics {
|
|
44
|
+
[super updateLayout:metrics];
|
|
45
|
+
[self updateGlass];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// The material for the props now, in the view's top-left corner radius, or none.
|
|
49
|
+
- (void)updateGlass {
|
|
50
|
+
if (!_glass) {
|
|
51
|
+
[_effect removeFromSuperview];
|
|
52
|
+
_effect = nil;
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
auto viewProps = std::dynamic_pointer_cast<const ViewProps>(self.props);
|
|
56
|
+
CGFloat radius = viewProps ? viewProps->resolveBorderMetrics(self.layoutMetrics).borderRadii.topLeft.horizontal : 0;
|
|
57
|
+
if (_effect == nil) {
|
|
58
|
+
_effect = ngn::appkit::makeGlassEffect(*_glass, ngn::appkit::liquidGlassAvailable());
|
|
59
|
+
_effect.frame = self.bounds;
|
|
60
|
+
[self addSubview:_effect positioned:NSWindowBelow relativeTo:_content];
|
|
61
|
+
}
|
|
62
|
+
ngn::appkit::updateGlassEffect(_effect, *_glass, radius);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// A native stack's header as the window's NSToolbar: the screen in front's
|
|
2
|
+
// RNSScreenStackHeaderConfig fills it. Its title is the window title; the back and forward chevrons
|
|
3
|
+
// lead when the window has history (or back alone when the app reports none and the screen has
|
|
4
|
+
// one below it), each listing its way's entries on a long press or a secondary click; left bar
|
|
5
|
+
// buttons and left header items follow it, and right ones trail, then the search bar of a
|
|
6
|
+
// searchBar header item as an NSSearchToolbarItem. A header item's Angular content (an
|
|
7
|
+
// RNSScreenStackHeaderSubview) moves into its toolbar item as a container of its own, hit-tested
|
|
8
|
+
// from the item's root.
|
|
9
|
+
//
|
|
10
|
+
// The config view itself stays in the screen, hidden: on macOS the header is the window's.
|
|
11
|
+
#pragma once
|
|
12
|
+
|
|
13
|
+
#import "host-view.h"
|
|
14
|
+
|
|
15
|
+
#include "ngn/app-menus.h"
|
|
16
|
+
#include "ngn/input.h"
|
|
17
|
+
|
|
18
|
+
#include <functional>
|
|
19
|
+
|
|
20
|
+
// RNSScreenStackHeaderConfig: never drawn in content.
|
|
21
|
+
@interface NGNHeaderConfigView : NGNView
|
|
22
|
+
@end
|
|
23
|
+
|
|
24
|
+
// RNSScreenStackHeaderSubview: placed by its toolbar item rather than by Yoga's origin.
|
|
25
|
+
@interface NGNHeaderSubviewView : NGNView
|
|
26
|
+
@end
|
|
27
|
+
|
|
28
|
+
@class NGNSearchToolbarItem;
|
|
29
|
+
|
|
30
|
+
// RNSSearchBar, in a header item of type searchBar: never drawn in content. Its field is the
|
|
31
|
+
// toolbar's NGNSearchToolbarItem (search-toolbar-item.h), which this view owns, so commands reach it
|
|
32
|
+
// whether or not the header is in front.
|
|
33
|
+
@interface NGNSearchBarView : NGNView
|
|
34
|
+
@property (nonatomic, readonly) NGNSearchToolbarItem *item;
|
|
35
|
+
@end
|
|
36
|
+
|
|
37
|
+
@interface NGNHeaderToolbar : NSObject <NSToolbarDelegate>
|
|
38
|
+
// Set once by the host: where toolbar items' containers report input, and where the core learns
|
|
39
|
+
// which views root a container of their own.
|
|
40
|
+
@property (class, nonatomic) ngn::InputSink *input;
|
|
41
|
+
@property (class, nonatomic) std::function<void(NSInteger tag, BOOL isRoot)> containerRootChanged;
|
|
42
|
+
// Set once by the host: where a chevron's click, or a pick from its menu, goes when the window
|
|
43
|
+
// reports its history.
|
|
44
|
+
@property (class, nonatomic)
|
|
45
|
+
std::function<void(NSWindow *window, ngn::NavigationDirection direction, int steps)> navigate;
|
|
46
|
+
|
|
47
|
+
- (instancetype)initWithWindow:(NSWindow *)window;
|
|
48
|
+
// The window's content is a split view controller: the sidebar button and the tracking separator
|
|
49
|
+
// lead, and the toolbar shows even when no header does.
|
|
50
|
+
@property (nonatomic) BOOL sidebar;
|
|
51
|
+
// The header in front, or nil for none. `screen` hears the back button.
|
|
52
|
+
- (void)showConfig:(NGNHeaderConfigView *)config screen:(NGNView *)screen canGoBack:(BOOL)canGoBack;
|
|
53
|
+
// A secondary click on a chevron shows its way's entries, in place of the toolbar's own menu that
|
|
54
|
+
// the toolbar would show. True when it did.
|
|
55
|
+
+ (BOOL)showHistoryMenuForEvent:(NSEvent *)event;
|
|
56
|
+
// The window's history as the app reports it, or nothing for an app that reports none.
|
|
57
|
+
- (void)showHistory:(const std::optional<ngn::WindowHistory> &)history;
|
|
58
|
+
// Rebuilds the bar when the config in front (or a view under it) changed.
|
|
59
|
+
- (void)refreshIfShowing:(NGNView *)view;
|
|
60
|
+
@end
|