@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,274 @@
|
|
|
1
|
+
// NgNativeFileSystem: files for @ng-native/expo's FileSystem on a desktop OS. A TurboModule cannot
|
|
2
|
+
// hand JavaScript expo-file-system's File and Directory classes, so this answers flat calls over
|
|
3
|
+
// uris (expo-file-system/legacy's, and the service's own readdir, stat and watch), and the desktop
|
|
4
|
+
// loader builds the classes over them.
|
|
5
|
+
//
|
|
6
|
+
// - `paths`: {cache, document, appData, temp, home, desktop, downloads}, each a file:// uri ending
|
|
7
|
+
// in `/`, and each left out where the app cannot reach it. `documentDirectory` and
|
|
8
|
+
// `cacheDirectory` are legacy's two.
|
|
9
|
+
// - readdir(uri): [{name, uri, directory}] by name; stat(uri): {uri, directory, size, modified,
|
|
10
|
+
// created} in ms since 1970, or null where nothing is.
|
|
11
|
+
// - watch(uri): a watch id, or null where nothing is; its changes arrive as `ngNativeFileSystem`
|
|
12
|
+
// on DeviceEventEmitter: {watch, type: created | modified | deleted | renamed, uri, newUri?}, for
|
|
13
|
+
// a file, or for a folder and what is directly in it. unwatch(id) stops one.
|
|
14
|
+
// - readAsStringAsync(uri, {encoding: utf8 | base64}), writeAsStringAsync(uri, text, {encoding,
|
|
15
|
+
// append}), deleteAsync(uri, {idempotent}), makeDirectoryAsync(uri, {intermediates}),
|
|
16
|
+
// moveAsync({from, to}), copyAsync({from, to}) and createFile(folderUri, name): {uri}, empty.
|
|
17
|
+
// - Each of those is synchronous too, with `Async` (or nothing) swapped for `Sync`: statSync,
|
|
18
|
+
// readdirSync, readAsStringSync, writeAsStringSync, deleteSync, makeDirectorySync, moveSync,
|
|
19
|
+
// copySync and createFileSync answer the same value, or throw the failure the promise rejects
|
|
20
|
+
// with. The service's files are synchronous through them, as expo-file-system's are.
|
|
21
|
+
//
|
|
22
|
+
// Every call is checked against FileAccess: the app's own folders and what the user picked can be
|
|
23
|
+
// read and written, and anything else only as the plugin options' `capabilities.paths` declare
|
|
24
|
+
// (`read` or `readwrite`). Symbolic links are followed before the check, so one cannot lead out.
|
|
25
|
+
#pragma once
|
|
26
|
+
|
|
27
|
+
#include "ngn/native-module.h"
|
|
28
|
+
|
|
29
|
+
#include <functional>
|
|
30
|
+
#include <memory>
|
|
31
|
+
#include <mutex>
|
|
32
|
+
#include <optional>
|
|
33
|
+
#include <set>
|
|
34
|
+
#include <stdexcept>
|
|
35
|
+
#include <string>
|
|
36
|
+
#include <vector>
|
|
37
|
+
|
|
38
|
+
namespace ngn {
|
|
39
|
+
|
|
40
|
+
// A path as a file:// uri, percent-encoded as expo-file-system writes them.
|
|
41
|
+
std::string fileUri(const std::string &path);
|
|
42
|
+
// The absolute path a file:// uri or a plain absolute path names, percent-decoded. Nothing for
|
|
43
|
+
// another scheme or a relative path.
|
|
44
|
+
std::optional<std::string> pathOfUri(const std::string &uri);
|
|
45
|
+
|
|
46
|
+
// Writes `bytes` to `path` through a temporary file beside it, renamed over `path` only once the
|
|
47
|
+
// whole write and its close succeeded, so a failed write leaves whatever was at `path` as it was.
|
|
48
|
+
// False when the write failed.
|
|
49
|
+
bool replaceFile(const std::string &path, const std::string &bytes);
|
|
50
|
+
|
|
51
|
+
// The toolkit's security-scoped bookmarks (macOS): what finds a file or folder the user picked
|
|
52
|
+
// again in a later launch, wherever it has moved, and reopens the sandbox to it.
|
|
53
|
+
class Bookmarks {
|
|
54
|
+
public:
|
|
55
|
+
struct Resolved {
|
|
56
|
+
std::string path;
|
|
57
|
+
// The bookmark still resolves but should be made again.
|
|
58
|
+
bool stale{false};
|
|
59
|
+
};
|
|
60
|
+
virtual ~Bookmarks() = default;
|
|
61
|
+
// A bookmark for `path`, or nothing where the toolkit cannot make one.
|
|
62
|
+
virtual std::optional<std::string> make(const std::string &path) = 0;
|
|
63
|
+
// A stale `bookmark` made again for `path`, where it points now, granting what it grants: nothing
|
|
64
|
+
// where the toolkit cannot make one that does, so the stale one, which still resolves, is kept.
|
|
65
|
+
virtual std::optional<std::string> renew(const std::string &bookmark, const std::string &path) {
|
|
66
|
+
(void)bookmark;
|
|
67
|
+
return make(path);
|
|
68
|
+
}
|
|
69
|
+
// Where a bookmark points now, or nothing for one that no longer resolves.
|
|
70
|
+
virtual std::optional<Resolved> resolve(const std::string &bookmark) = 0;
|
|
71
|
+
// Starts and stops using what a bookmark points at. Each start the toolkit agreed to (true) is
|
|
72
|
+
// matched by one stop; starts nest.
|
|
73
|
+
virtual bool startAccess(const std::string &bookmark) = 0;
|
|
74
|
+
virtual void stopAccess(const std::string &bookmark) = 0;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// The user's picks, kept across launches: a bookmark for each, stored through `load` and `save`
|
|
78
|
+
// (somewhere JavaScript cannot write, since a bookmark opens the sandbox) as JSON:
|
|
79
|
+
// {"version": 1, "picks": [{"path", "bookmark" (base64)}]}. Any thread.
|
|
80
|
+
class PickStore {
|
|
81
|
+
public:
|
|
82
|
+
struct Persistence {
|
|
83
|
+
std::function<std::optional<std::string>()> load;
|
|
84
|
+
std::function<void(const std::string &)> save;
|
|
85
|
+
};
|
|
86
|
+
PickStore(Persistence persistence, std::shared_ptr<Bookmarks> bookmarks);
|
|
87
|
+
|
|
88
|
+
// The picks of earlier launches that still resolve, each at its path now. A stale bookmark is
|
|
89
|
+
// made again and one that no longer resolves is dropped, and the store is saved when either
|
|
90
|
+
// happens.
|
|
91
|
+
std::vector<std::string> restore();
|
|
92
|
+
// Keeps a pick for later launches; a path kept already gets a new bookmark.
|
|
93
|
+
void remember(const std::string &path);
|
|
94
|
+
// The bookmark of the innermost pick holding `path`.
|
|
95
|
+
std::optional<std::string> bookmarkFor(const std::string &path) const;
|
|
96
|
+
Bookmarks &bookmarks() const {
|
|
97
|
+
return *bookmarks_;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
private:
|
|
101
|
+
struct Pick {
|
|
102
|
+
std::string path;
|
|
103
|
+
std::string bookmark;
|
|
104
|
+
};
|
|
105
|
+
void save();
|
|
106
|
+
|
|
107
|
+
Persistence persistence_;
|
|
108
|
+
std::shared_ptr<Bookmarks> bookmarks_;
|
|
109
|
+
mutable std::mutex mutex_;
|
|
110
|
+
std::vector<Pick> picks_;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// A path JavaScript named that is outside what the app may read (FileAccess::readFor) or write
|
|
114
|
+
// (FileAccess::writeFor).
|
|
115
|
+
class FileRefused : public std::runtime_error {
|
|
116
|
+
public:
|
|
117
|
+
explicit FileRefused(const std::string &path, bool write = false);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
class FileAccess {
|
|
121
|
+
public:
|
|
122
|
+
enum class Access { None, Read, ReadWrite };
|
|
123
|
+
|
|
124
|
+
struct Folders {
|
|
125
|
+
std::string cache;
|
|
126
|
+
std::string document;
|
|
127
|
+
std::string appData;
|
|
128
|
+
std::string temp;
|
|
129
|
+
// The user's: reachable only as `paths` declares them.
|
|
130
|
+
std::string home;
|
|
131
|
+
std::string desktop;
|
|
132
|
+
std::string downloads;
|
|
133
|
+
// The app bundle's Resources, where a packaged app's assets are: read by the modules that
|
|
134
|
+
// load assets (readFor), never reached by FileSystem.
|
|
135
|
+
std::string bundle;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
// `declared` is `capabilities.paths`: [{path, access}], `~/` meaning the home folder.
|
|
139
|
+
FileAccess(Folders folders, const folly::dynamic &declared);
|
|
140
|
+
|
|
141
|
+
const Folders &folders() const {
|
|
142
|
+
return folders_;
|
|
143
|
+
}
|
|
144
|
+
// What the app may do at `path`, an absolute path.
|
|
145
|
+
Access accessTo(const std::string &path) const;
|
|
146
|
+
// A file or folder the user chose in a panel: for the rest of the process, and in later
|
|
147
|
+
// launches once picks are kept.
|
|
148
|
+
void allowPicked(const std::string &path);
|
|
149
|
+
// Keeps the picks in `store` from now on, and allows the ones earlier launches kept.
|
|
150
|
+
void keepPicks(std::shared_ptr<PickStore> store);
|
|
151
|
+
|
|
152
|
+
// The pick holding a path opened for as long as this lives: a picked file or folder of an earlier
|
|
153
|
+
// launch is reachable in the sandbox only while its bookmark's access is started.
|
|
154
|
+
class Use {
|
|
155
|
+
public:
|
|
156
|
+
Use() = default;
|
|
157
|
+
Use(std::shared_ptr<PickStore> store, std::string bookmark);
|
|
158
|
+
Use(Use &&other) noexcept;
|
|
159
|
+
Use &operator=(Use &&other) noexcept;
|
|
160
|
+
Use(const Use &) = delete;
|
|
161
|
+
Use &operator=(const Use &) = delete;
|
|
162
|
+
~Use();
|
|
163
|
+
bool started() const {
|
|
164
|
+
return store_ != nullptr;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
private:
|
|
168
|
+
void release();
|
|
169
|
+
std::shared_ptr<PickStore> store_;
|
|
170
|
+
std::string bookmark_;
|
|
171
|
+
};
|
|
172
|
+
// A Use for `path`; one that starts nothing outside picks.
|
|
173
|
+
Use use(const std::string &path) const;
|
|
174
|
+
// The one check for a module that reads a file JavaScript names (ImageEditor, TextRecognition,
|
|
175
|
+
// Fonts, Printing, MediaLibrary.createAsset, an XMLHttpRequest body): it may read what accessTo
|
|
176
|
+
// lets FileSystem read, and the app bundle's assets. The Use keeps a pick of an earlier launch
|
|
177
|
+
// open; hold it until the read is done. Throws FileRefused for anything else, in the same words
|
|
178
|
+
// whether or not a file is there.
|
|
179
|
+
std::shared_ptr<Use> readFor(const std::string &path) const;
|
|
180
|
+
// The same check for a module that writes or creates a file where JavaScript says (SQLite's
|
|
181
|
+
// databases): what accessTo lets FileSystem write, never the bundle. Throws FileRefused for
|
|
182
|
+
// anything else, in the same words whether or not a file is there.
|
|
183
|
+
std::shared_ptr<Use> writeFor(const std::string &path) const;
|
|
184
|
+
|
|
185
|
+
private:
|
|
186
|
+
struct Root {
|
|
187
|
+
std::string path;
|
|
188
|
+
Access access;
|
|
189
|
+
};
|
|
190
|
+
void add(const std::string &path, Access access);
|
|
191
|
+
|
|
192
|
+
Folders folders_;
|
|
193
|
+
mutable std::mutex mutex_;
|
|
194
|
+
std::vector<Root> roots_;
|
|
195
|
+
std::shared_ptr<PickStore> picks_;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
// FileAccess::readFor through `access`, refusing every path when there is none.
|
|
199
|
+
std::shared_ptr<FileAccess::Use> readableFile(const FileAccess *access, const std::string &path);
|
|
200
|
+
|
|
201
|
+
// A source JavaScript hands to something that reads it through a uri (an image, a player, a
|
|
202
|
+
// request's url, a web view's page): the uri to hand on, and the pick it reads, held open.
|
|
203
|
+
struct ReadableSource {
|
|
204
|
+
std::string uri;
|
|
205
|
+
std::shared_ptr<FileAccess::Use> use;
|
|
206
|
+
};
|
|
207
|
+
// A file source (an absolute path, or a uri in the `file:` scheme however it is spelled) checked
|
|
208
|
+
// with readFor and answered as fileUri of the path checked, without its query or fragment, so the
|
|
209
|
+
// loader reads exactly that file. Any other uri is answered as it is. Throws FileRefused for a file
|
|
210
|
+
// outside the boundary, a `file:` uri naming a host or no absolute path, and with no `access`.
|
|
211
|
+
ReadableSource readableSource(const FileAccess *access, const std::string &uri);
|
|
212
|
+
// Whether a uri is in the `file:` scheme, in any case: what a URL loader reads from disk.
|
|
213
|
+
bool isFileScheme(const std::string &uri);
|
|
214
|
+
|
|
215
|
+
// The FileAccess the host made, for what loads a source JavaScript names outside a module (the
|
|
216
|
+
// views drawing an image or a page, a drag out of the app). Without one, every file is refused.
|
|
217
|
+
void useViewFileAccess(std::shared_ptr<FileAccess> access);
|
|
218
|
+
std::shared_ptr<FileAccess> viewFileAccess();
|
|
219
|
+
|
|
220
|
+
// The OS's file events (FSEvents on macOS), for one path at a time.
|
|
221
|
+
class FileWatcher {
|
|
222
|
+
public:
|
|
223
|
+
// One event as the OS reports it; the flags may be several at once, coalesced.
|
|
224
|
+
struct Event {
|
|
225
|
+
std::string path;
|
|
226
|
+
bool created{false};
|
|
227
|
+
bool removed{false};
|
|
228
|
+
bool renamed{false};
|
|
229
|
+
bool modified{false};
|
|
230
|
+
// The OS lost track of what changed under the path (FSEvents' must-scan-subdirs, after events
|
|
231
|
+
// were dropped): the changes are found by listing it again.
|
|
232
|
+
bool rescan{false};
|
|
233
|
+
};
|
|
234
|
+
virtual ~FileWatcher() = default;
|
|
235
|
+
// Starts reporting batches of events under `path`, on any thread, until stop. A handle, or 0
|
|
236
|
+
// when the OS would not start watching.
|
|
237
|
+
virtual int start(const std::string &path, std::function<void(std::vector<Event>)> events) = 0;
|
|
238
|
+
virtual void stop(int handle) = 0;
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
// The changes batches of events make to `watched` (a file, or a folder and what is directly in
|
|
242
|
+
// it), as `ngNativeFileSystem` reports them without the watch id. It remembers the paths it has
|
|
243
|
+
// seen, from those there when the watch began, since FSEvents keeps a file's created flag on its
|
|
244
|
+
// later events. `exists` says whether a path is there now, what coalesced flags cannot, or nothing
|
|
245
|
+
// when it cannot tell (a folder that cannot be searched): that event is left out and the folder
|
|
246
|
+
// listed again at the next one.
|
|
247
|
+
class FileChanges {
|
|
248
|
+
public:
|
|
249
|
+
using Exists = std::function<std::optional<bool>(const std::string &)>;
|
|
250
|
+
FileChanges(std::string watched, const Exists &exists);
|
|
251
|
+
folly::dynamic changes(const std::vector<FileWatcher::Event> &events, const Exists &exists);
|
|
252
|
+
// Whether what was there when the watch began was listed in full: a folder that could not be
|
|
253
|
+
// listed has nothing to tell an entry already there from a new one.
|
|
254
|
+
bool listed() const {
|
|
255
|
+
return listed_;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
private:
|
|
259
|
+
bool concerns(const std::string &path) const;
|
|
260
|
+
// A rescan's changes: what is there now against what was seen.
|
|
261
|
+
void rescan(folly::dynamic &out, const Exists &exists);
|
|
262
|
+
// Adds the folder's entries to `into`; false when it could not be listed in full.
|
|
263
|
+
bool list(std::set<std::string> &into) const;
|
|
264
|
+
std::string watched_;
|
|
265
|
+
bool folder_{false};
|
|
266
|
+
bool listed_{true};
|
|
267
|
+
// The last listing failed: the next events start with another.
|
|
268
|
+
bool rescanOwed_{false};
|
|
269
|
+
std::set<std::string> seen_;
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
std::shared_ptr<NativeModule> makeFileSystemModule(std::shared_ptr<FileAccess> access, std::shared_ptr<FileWatcher> watcher);
|
|
273
|
+
|
|
274
|
+
} // namespace ngn
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// Tab order, walked in the core over the committed tree, the same on every toolkit: what Tab and
|
|
2
|
+
// Shift-Tab move the focus to. AppKit's key-view loop is not used.
|
|
3
|
+
//
|
|
4
|
+
// A view is in Tab order when its desktop props say it takes focus (`focusable`, or a `tabIndex`
|
|
5
|
+
// of 0 or more), or when it is a text input or a native control (native-controls.h) that a
|
|
6
|
+
// negative `tabIndex` or `focusable: false` does not take out. Positive `tabIndex` values come
|
|
7
|
+
// first, lowest first, then everything else in tree order, as on the web. Covered screens, views
|
|
8
|
+
// with `display: none` and other containers' content (a popover's, a sheet's) are skipped: the walk
|
|
9
|
+
// stays inside the container it starts in, which keeps Tab inside a modal.
|
|
10
|
+
//
|
|
11
|
+
// A composite widget (a view with the `tablist`, `radiogroup`, `menu`, `menubar`, `listbox` or
|
|
12
|
+
// `grid` role) is one Tab stop, as WAI-ARIA has it: the item in it with the focus, else its
|
|
13
|
+
// selected or checked item, else its first. Arrow keys, Home and End move the focus between its
|
|
14
|
+
// items (compositeMove). A text input inside one keeps a Tab stop of its own.
|
|
15
|
+
#pragma once
|
|
16
|
+
|
|
17
|
+
#include "ngn/view-tree.h"
|
|
18
|
+
|
|
19
|
+
#include <optional>
|
|
20
|
+
#include <vector>
|
|
21
|
+
|
|
22
|
+
namespace ngn {
|
|
23
|
+
|
|
24
|
+
// How far Tab reaches, from the system's keyboard navigation setting: every focusable view, or
|
|
25
|
+
// only text inputs (the Mac's default, where Option-Tab reaches everything).
|
|
26
|
+
enum class TabReach { TextInputs, All };
|
|
27
|
+
|
|
28
|
+
// The views Tab visits in the container `root`, in order. `focused` is the view with the focus,
|
|
29
|
+
// which is a composite widget's stop.
|
|
30
|
+
std::vector<Tag> tabOrder(const ViewTree &tree, Tag root, TabReach reach, std::optional<Tag> focused = std::nullopt);
|
|
31
|
+
|
|
32
|
+
// Where Tab (or Shift-Tab, `backwards`) moves the focus from `from`, wrapping round; the first
|
|
33
|
+
// (or last) view when `from` is not in Tab order. Nothing when no view is.
|
|
34
|
+
std::optional<Tag> nextInTabOrder(
|
|
35
|
+
const ViewTree &tree,
|
|
36
|
+
Tag root,
|
|
37
|
+
std::optional<Tag> from,
|
|
38
|
+
bool backwards,
|
|
39
|
+
TabReach reach);
|
|
40
|
+
|
|
41
|
+
// The keys that move the focus inside a composite widget. Left and Right are as pressed: a
|
|
42
|
+
// right-to-left composite swaps them.
|
|
43
|
+
enum class CompositeKey { Left, Right, Up, Down, Home, End };
|
|
44
|
+
|
|
45
|
+
// Where `key` moves the focus from `focused` inside the nearest composite widget around it, under
|
|
46
|
+
// `root`, as WAI-ARIA's practices have it:
|
|
47
|
+
// - `tablist` and `radiogroup`: every arrow, the previous or the next item, wrapping round;
|
|
48
|
+
// - `menu`: Up and Down, wrapping; `menubar`: Left and Right, wrapping;
|
|
49
|
+
// - `listbox`: Up and Down, stopping at either end;
|
|
50
|
+
// - `grid`: the next cell in the row or the column, stopping at the edges, its `row` views being
|
|
51
|
+
// the rows; Home and End go to the row's ends, and with `control` to the grid's first and last.
|
|
52
|
+
// Home and End go to the first and last item elsewhere. The items are the views with the role the
|
|
53
|
+
// composite takes (`tab`; `radio`; `menuitem`, `menuitemcheckbox` and `menuitemradio`; `option`;
|
|
54
|
+
// `gridcell`, `cell`, `columnheader` and `rowheader`), outside any composite nested in it, focused
|
|
55
|
+
// themselves or, when one takes no focus, through the first view inside it that does. A disabled
|
|
56
|
+
// radio is skipped; other disabled items are not, as WAI-ARIA recommends.
|
|
57
|
+
//
|
|
58
|
+
// The focused view itself at an edge that does not wrap: the key is used and nothing moves.
|
|
59
|
+
// Nothing when the focus is in no composite, the key is not one it uses, or the focus is in a text
|
|
60
|
+
// input or a native control that uses the arrows itself.
|
|
61
|
+
std::optional<Tag> compositeMove(const ViewTree &tree, Tag root, Tag focused, CompositeKey key, bool control);
|
|
62
|
+
|
|
63
|
+
} // namespace ngn
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// NgNativeFont: what @ng-native/expo's Fonts calls on expo-font, over a FontRegistrar, which the
|
|
2
|
+
// AppKit backend implements with CTFontManager, registering a font for this process only.
|
|
3
|
+
//
|
|
4
|
+
// - loadAsync(name, uri): registers the font file a `file:` uri or an absolute path names, or that
|
|
5
|
+
// an `http(s):` uri serves (an asset from the dev server), downloaded into the cache first, and
|
|
6
|
+
// makes `name` stand for its family. A file registered before is not registered again. A file
|
|
7
|
+
// is read only where `files` lets it (FileAccess::readFor), and refused in the same words
|
|
8
|
+
// whether or not it is there.
|
|
9
|
+
// - isLoaded(name), getLoadedFonts(): the names loaded, in the order they were.
|
|
10
|
+
// Text asks for a font by its name: FontLibrary::familyOf answers the family it stands for, as
|
|
11
|
+
// expo-font's alias does on iOS, so text in that family picks its weight among the faces loaded.
|
|
12
|
+
#pragma once
|
|
13
|
+
|
|
14
|
+
#include "ngn/native-module.h"
|
|
15
|
+
#include "ngn/file-system.h"
|
|
16
|
+
#include "ngn/network.h"
|
|
17
|
+
|
|
18
|
+
#include <map>
|
|
19
|
+
#include <memory>
|
|
20
|
+
#include <mutex>
|
|
21
|
+
#include <optional>
|
|
22
|
+
#include <string>
|
|
23
|
+
#include <vector>
|
|
24
|
+
|
|
25
|
+
namespace ngn {
|
|
26
|
+
|
|
27
|
+
struct RegisteredFont {
|
|
28
|
+
std::string family;
|
|
29
|
+
std::string postScriptName;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
class FontRegistrar {
|
|
33
|
+
public:
|
|
34
|
+
virtual ~FontRegistrar() = default;
|
|
35
|
+
// Registers the first face in the file at `path`, or one already registered, for this process.
|
|
36
|
+
// Throws std::runtime_error with the OS's reason when it cannot.
|
|
37
|
+
virtual RegisteredFont registerFile(const std::string &path) = 0;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// The names fonts are loaded under, for the process: one library both the module and text layout
|
|
41
|
+
// read, kept across reloads, as the registered fonts are. Any thread.
|
|
42
|
+
class FontLibrary {
|
|
43
|
+
public:
|
|
44
|
+
void add(const std::string &name, RegisteredFont font);
|
|
45
|
+
bool has(const std::string &name) const;
|
|
46
|
+
// The family `name` stands for, or nothing for a name no font was loaded under.
|
|
47
|
+
std::optional<RegisteredFont> fontOf(const std::string &name) const;
|
|
48
|
+
std::vector<std::string> names() const;
|
|
49
|
+
|
|
50
|
+
private:
|
|
51
|
+
mutable std::mutex mutex_;
|
|
52
|
+
std::map<std::string, RegisteredFont> fonts_;
|
|
53
|
+
std::vector<std::string> order_;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// `downloads` is where a font served over http(s) is saved before it is registered.
|
|
57
|
+
std::shared_ptr<NativeModule> makeFontModule(
|
|
58
|
+
std::shared_ptr<FontRegistrar> registrar,
|
|
59
|
+
std::shared_ptr<FontLibrary> library,
|
|
60
|
+
std::shared_ptr<Http> http,
|
|
61
|
+
std::string downloads,
|
|
62
|
+
std::shared_ptr<FileAccess> files);
|
|
63
|
+
|
|
64
|
+
} // namespace ngn
|