@ng-native/desktop 0.0.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +52 -0
- package/app.plugin.cjs +17 -0
- package/bin/app-config.mjs +168 -0
- package/bin/autolink.mjs +224 -0
- package/bin/cli.mjs +158 -0
- package/bin/host.mjs +427 -0
- package/bin/ng-native-desktop.mjs +4 -0
- package/bin/package.mjs +971 -0
- package/bin/plist.mjs +68 -0
- package/bin/prebuilt.mjs +328 -0
- package/bin/toolchain.mjs +192 -0
- package/native/CMakeLists.txt +276 -0
- package/native/appkit/CMakeLists.txt +109 -0
- package/native/appkit/address-search.h +26 -0
- package/native/appkit/address-search.mm +277 -0
- package/native/appkit/animation-frames.h +14 -0
- package/native/appkit/animation-frames.mm +106 -0
- package/native/appkit/app-info.h +12 -0
- package/native/appkit/app-info.mm +98 -0
- package/native/appkit/app-updater.mm +128 -0
- package/native/appkit/app-windows.h +81 -0
- package/native/appkit/app-windows.mm +318 -0
- package/native/appkit/appkit-backend.h +73 -0
- package/native/appkit/appkit-backend.mm +276 -0
- package/native/appkit/apple-authentication.h +19 -0
- package/native/appkit/apple-authentication.mm +248 -0
- package/native/appkit/apple-button-view.h +10 -0
- package/native/appkit/apple-button-view.mm +37 -0
- package/native/appkit/apple-id-button.h +16 -0
- package/native/appkit/apple-id-button.mm +50 -0
- package/native/appkit/audio.h +16 -0
- package/native/appkit/audio.mm +275 -0
- package/native/appkit/battery.h +13 -0
- package/native/appkit/battery.mm +92 -0
- package/native/appkit/bookmarks.h +17 -0
- package/native/appkit/bookmarks.mm +145 -0
- package/native/appkit/calendar.h +25 -0
- package/native/appkit/calendar.mm +660 -0
- package/native/appkit/camera-view.h +15 -0
- package/native/appkit/camera-view.mm +130 -0
- package/native/appkit/camera.h +39 -0
- package/native/appkit/camera.mm +362 -0
- package/native/appkit/cg-canvas.h +17 -0
- package/native/appkit/cg-canvas.mm +518 -0
- package/native/appkit/component-view.h +17 -0
- package/native/appkit/crypto.h +19 -0
- package/native/appkit/crypto.mm +78 -0
- package/native/appkit/desktop-expo.h +29 -0
- package/native/appkit/desktop-expo.mm +385 -0
- package/native/appkit/expo-image-drawing.h +46 -0
- package/native/appkit/expo-image-drawing.mm +131 -0
- package/native/appkit/expo-image-view.h +15 -0
- package/native/appkit/expo-image-view.mm +182 -0
- package/native/appkit/expo-ui-renderer.h +68 -0
- package/native/appkit/expo-ui-renderer.mm +101 -0
- package/native/appkit/expo-ui-view.h +26 -0
- package/native/appkit/expo-ui-view.mm +134 -0
- package/native/appkit/expo-ui.swift +1284 -0
- package/native/appkit/file-system.h +16 -0
- package/native/appkit/file-system.mm +140 -0
- package/native/appkit/fonts.h +12 -0
- package/native/appkit/fonts.mm +48 -0
- package/native/appkit/geocoder.h +19 -0
- package/native/appkit/geocoder.mm +101 -0
- package/native/appkit/glass-effect.h +22 -0
- package/native/appkit/glass-effect.mm +63 -0
- package/native/appkit/glass-view.h +8 -0
- package/native/appkit/glass-view.mm +65 -0
- package/native/appkit/header-toolbar.h +60 -0
- package/native/appkit/header-toolbar.mm +629 -0
- package/native/appkit/host-view.h +54 -0
- package/native/appkit/host-view.mm +1200 -0
- package/native/appkit/image-manipulator.h +14 -0
- package/native/appkit/image-manipulator.mm +191 -0
- package/native/appkit/image-request.h +22 -0
- package/native/appkit/image-request.mm +62 -0
- package/native/appkit/image-view.h +8 -0
- package/native/appkit/image-view.mm +142 -0
- package/native/appkit/input-replay.h +25 -0
- package/native/appkit/input-replay.mm +418 -0
- package/native/appkit/language-model.h +14 -0
- package/native/appkit/language-model.mm +99 -0
- package/native/appkit/language-model.swift +472 -0
- package/native/appkit/local-authentication.h +15 -0
- package/native/appkit/local-authentication.mm +133 -0
- package/native/appkit/location.h +16 -0
- package/native/appkit/location.mm +214 -0
- package/native/appkit/main.mm +1515 -0
- package/native/appkit/map-view.h +15 -0
- package/native/appkit/map-view.mm +109 -0
- package/native/appkit/maps.h +35 -0
- package/native/appkit/maps.mm +343 -0
- package/native/appkit/menu-bar.h +22 -0
- package/native/appkit/menu-bar.mm +208 -0
- package/native/appkit/modal-focus.h +16 -0
- package/native/appkit/modal-focus.mm +26 -0
- package/native/appkit/modal-host-view.h +79 -0
- package/native/appkit/modal-host-view.mm +442 -0
- package/native/appkit/native-controls.h +22 -0
- package/native/appkit/native-controls.mm +431 -0
- package/native/appkit/network-state.h +12 -0
- package/native/appkit/network-state.mm +64 -0
- package/native/appkit/network.h +14 -0
- package/native/appkit/network.mm +396 -0
- package/native/appkit/notifications.h +19 -0
- package/native/appkit/notifications.mm +309 -0
- package/native/appkit/photo-library.h +33 -0
- package/native/appkit/photo-library.mm +548 -0
- package/native/appkit/pointer-buttons.h +32 -0
- package/native/appkit/presentation-label.h +15 -0
- package/native/appkit/presentation-label.mm +12 -0
- package/native/appkit/presented-screen.h +19 -0
- package/native/appkit/presented-screen.mm +181 -0
- package/native/appkit/printing.h +42 -0
- package/native/appkit/printing.mm +393 -0
- package/native/appkit/push.h +19 -0
- package/native/appkit/push.mm +81 -0
- package/native/appkit/red-box.h +26 -0
- package/native/appkit/red-box.mm +387 -0
- package/native/appkit/screen-capture.h +21 -0
- package/native/appkit/screen-capture.mm +92 -0
- package/native/appkit/scroll-view.h +13 -0
- package/native/appkit/scroll-view.mm +251 -0
- package/native/appkit/scrollers.h +25 -0
- package/native/appkit/scrollers.mm +43 -0
- package/native/appkit/search-field.h +34 -0
- package/native/appkit/search-field.mm +291 -0
- package/native/appkit/search-toolbar-item.h +19 -0
- package/native/appkit/search-toolbar-item.mm +269 -0
- package/native/appkit/share-picker.h +34 -0
- package/native/appkit/share-picker.mm +121 -0
- package/native/appkit/split-view.h +77 -0
- package/native/appkit/split-view.mm +1206 -0
- package/native/appkit/store-review.h +13 -0
- package/native/appkit/store-review.mm +28 -0
- package/native/appkit/surface-view.h +45 -0
- package/native/appkit/surface-view.mm +558 -0
- package/native/appkit/svg-view.h +17 -0
- package/native/appkit/svg-view.mm +57 -0
- package/native/appkit/symbol-drawing.h +24 -0
- package/native/appkit/symbol-drawing.mm +117 -0
- package/native/appkit/symbol-view.h +8 -0
- package/native/appkit/symbol-view.mm +33 -0
- package/native/appkit/system-access.h +34 -0
- package/native/appkit/system-access.mm +210 -0
- package/native/appkit/system.h +24 -0
- package/native/appkit/system.mm +403 -0
- package/native/appkit/test-launch.h +36 -0
- package/native/appkit/test-launch.mm +115 -0
- package/native/appkit/text-input-field.h +76 -0
- package/native/appkit/text-input-field.mm +444 -0
- package/native/appkit/text-layout.h +58 -0
- package/native/appkit/text-layout.mm +477 -0
- package/native/appkit/text-recognition.h +13 -0
- package/native/appkit/text-recognition.mm +102 -0
- package/native/appkit/tracking.h +13 -0
- package/native/appkit/tracking.mm +51 -0
- package/native/appkit/tray-and-dock.h +45 -0
- package/native/appkit/tray-and-dock.mm +130 -0
- package/native/appkit/undo.h +23 -0
- package/native/appkit/undo.mm +125 -0
- package/native/appkit/updates.h +17 -0
- package/native/appkit/updates.mm +71 -0
- package/native/appkit/video-view.h +10 -0
- package/native/appkit/video-view.mm +42 -0
- package/native/appkit/video.h +38 -0
- package/native/appkit/video.mm +404 -0
- package/native/appkit/web-browser.h +12 -0
- package/native/appkit/web-browser.mm +97 -0
- package/native/appkit/web-view-component.h +9 -0
- package/native/appkit/web-view-component.mm +56 -0
- package/native/appkit/web-view.h +31 -0
- package/native/appkit/web-view.mm +394 -0
- package/native/cmake/libraries/react-native-reanimated.cmake +45 -0
- package/native/cmake/libraries/react-native-worklets.cmake +46 -0
- package/native/cmake/libraries.cmake +109 -0
- package/native/cmake/linked-modules.cmake +112 -0
- package/native/cmake/react-native.cmake +175 -0
- package/native/cmake/runtime-dependencies.cmake +34 -0
- package/native/cmake/swift.cmake +43 -0
- package/native/cmake/third-party.cmake +74 -0
- package/native/core/include/ngn/absent-views.h +27 -0
- package/native/core/include/ngn/accessibility.h +140 -0
- package/native/core/include/ngn/address-search.h +69 -0
- package/native/core/include/ngn/animation-frames.h +39 -0
- package/native/core/include/ngn/app-info.h +52 -0
- package/native/core/include/ngn/app-menus.h +146 -0
- package/native/core/include/ngn/app-windows.h +181 -0
- package/native/core/include/ngn/apple-authentication.h +116 -0
- package/native/core/include/ngn/asset.h +28 -0
- package/native/core/include/ngn/audio.h +125 -0
- package/native/core/include/ngn/back-swipe.h +112 -0
- package/native/core/include/ngn/battery.h +48 -0
- package/native/core/include/ngn/bytes.h +59 -0
- package/native/core/include/ngn/calendar.h +180 -0
- package/native/core/include/ngn/camera.h +128 -0
- package/native/core/include/ngn/control-sizes.h +111 -0
- package/native/core/include/ngn/core-modules.h +105 -0
- package/native/core/include/ngn/crypto.h +38 -0
- package/native/core/include/ngn/default-menu.h +91 -0
- package/native/core/include/ngn/desktop-expo.h +193 -0
- package/native/core/include/ngn/desktop-modal.h +109 -0
- package/native/core/include/ngn/desktop-props.h +75 -0
- package/native/core/include/ngn/desktop-view-props.h +110 -0
- package/native/core/include/ngn/dev-server.h +33 -0
- package/native/core/include/ngn/download.h +24 -0
- package/native/core/include/ngn/expo-image.h +192 -0
- package/native/core/include/ngn/expo-ui.h +133 -0
- package/native/core/include/ngn/file-system.h +274 -0
- package/native/core/include/ngn/focus-order.h +63 -0
- package/native/core/include/ngn/fonts.h +64 -0
- package/native/core/include/ngn/gestures.h +305 -0
- package/native/core/include/ngn/glass.h +67 -0
- package/native/core/include/ngn/header-bar.h +112 -0
- package/native/core/include/ngn/host-state.h +243 -0
- package/native/core/include/ngn/image-manipulator.h +70 -0
- package/native/core/include/ngn/input-dispatcher.h +211 -0
- package/native/core/include/ngn/input-script.h +56 -0
- package/native/core/include/ngn/input.h +112 -0
- package/native/core/include/ngn/key-value-store.h +41 -0
- package/native/core/include/ngn/language-model.h +69 -0
- package/native/core/include/ngn/launch-frame.h +47 -0
- package/native/core/include/ngn/launch-settings.h +98 -0
- package/native/core/include/ngn/layout-animations.h +24 -0
- package/native/core/include/ngn/library-components.h +13 -0
- package/native/core/include/ngn/library-glue.h +53 -0
- package/native/core/include/ngn/live-regions.h +54 -0
- package/native/core/include/ngn/local-authentication.h +74 -0
- package/native/core/include/ngn/location.h +89 -0
- package/native/core/include/ngn/maps.h +226 -0
- package/native/core/include/ngn/module-registry.h +51 -0
- package/native/core/include/ngn/mounting-backend.h +96 -0
- package/native/core/include/ngn/mounting-manager.h +155 -0
- package/native/core/include/ngn/native-controls.h +161 -0
- package/native/core/include/ngn/native-module.h +109 -0
- package/native/core/include/ngn/network-state.h +44 -0
- package/native/core/include/ngn/network.h +100 -0
- package/native/core/include/ngn/notifications.h +185 -0
- package/native/core/include/ngn/photo-library.h +130 -0
- package/native/core/include/ngn/printing.h +69 -0
- package/native/core/include/ngn/processes.h +114 -0
- package/native/core/include/ngn/red-box.h +119 -0
- package/native/core/include/ngn/reload-thread.h +258 -0
- package/native/core/include/ngn/runtime.h +161 -0
- package/native/core/include/ngn/safe-areas.h +77 -0
- package/native/core/include/ngn/screen-capture.h +35 -0
- package/native/core/include/ngn/screen-presentation.h +85 -0
- package/native/core/include/ngn/screen-stacks.h +80 -0
- package/native/core/include/ngn/scrollers.h +106 -0
- package/native/core/include/ngn/sharing.h +39 -0
- package/native/core/include/ngn/spawn-rules.h +78 -0
- package/native/core/include/ngn/splash-screen.h +41 -0
- package/native/core/include/ngn/split-view.h +270 -0
- package/native/core/include/ngn/sqlite.h +38 -0
- package/native/core/include/ngn/store-review.h +26 -0
- package/native/core/include/ngn/surface-book.h +101 -0
- package/native/core/include/ngn/svg.h +393 -0
- package/native/core/include/ngn/symbol.h +90 -0
- package/native/core/include/ngn/system.h +102 -0
- package/native/core/include/ngn/tabs-host.h +171 -0
- package/native/core/include/ngn/text-input.h +125 -0
- package/native/core/include/ngn/text-measurer.h +38 -0
- package/native/core/include/ngn/text-recognition.h +55 -0
- package/native/core/include/ngn/tracking.h +34 -0
- package/native/core/include/ngn/tray-and-dock.h +107 -0
- package/native/core/include/ngn/undo.h +37 -0
- package/native/core/include/ngn/updates.h +253 -0
- package/native/core/include/ngn/video.h +126 -0
- package/native/core/include/ngn/view-box.h +126 -0
- package/native/core/include/ngn/view-transform.h +26 -0
- package/native/core/include/ngn/view-tree.h +85 -0
- package/native/core/include/ngn/web-browser.h +45 -0
- package/native/core/include/ngn/web-view.h +133 -0
- package/native/core/include/ngn/worklet-host.h +98 -0
- package/native/core/src/absent-views.cpp +41 -0
- package/native/core/src/accessibility.cpp +374 -0
- package/native/core/src/animation-frames.cpp +49 -0
- package/native/core/src/app-menus.cpp +352 -0
- package/native/core/src/app-windows.cpp +444 -0
- package/native/core/src/back-swipe.cpp +91 -0
- package/native/core/src/bytes.cpp +158 -0
- package/native/core/src/control-sizes.cpp +232 -0
- package/native/core/src/default-menu.cpp +96 -0
- package/native/core/src/desktop-modal.cpp +162 -0
- package/native/core/src/desktop-view-props.cpp +80 -0
- package/native/core/src/dev-server-helper.cpp +152 -0
- package/native/core/src/dev-server.cpp +103 -0
- package/native/core/src/download.cpp +53 -0
- package/native/core/src/expo-image.cpp +548 -0
- package/native/core/src/expo-ui.cpp +203 -0
- package/native/core/src/focus-order.cpp +441 -0
- package/native/core/src/gestures.cpp +1806 -0
- package/native/core/src/glass.cpp +49 -0
- package/native/core/src/header-bar.cpp +104 -0
- package/native/core/src/host-services.cpp +50 -0
- package/native/core/src/host-state.cpp +61 -0
- package/native/core/src/input-dispatcher.cpp +727 -0
- package/native/core/src/input-script.cpp +123 -0
- package/native/core/src/key-value-store.cpp +169 -0
- package/native/core/src/launch-settings.cpp +148 -0
- package/native/core/src/layout-animations.cpp +62 -0
- package/native/core/src/libraries/RNCWebViewSpec.cpp +80 -0
- package/native/core/src/libraries/react-native-reanimated.cpp +216 -0
- package/native/core/src/libraries/react-native-worklets.cpp +192 -0
- package/native/core/src/libraries/rnscreens.cpp +125 -0
- package/native/core/src/libraries/rnsvg.cpp +345 -0
- package/native/core/src/libraries/safeareacontext.cpp +70 -0
- package/native/core/src/libraries/worklets-idle-frames.js +70 -0
- package/native/core/src/library-glue.cpp +35 -0
- package/native/core/src/live-regions.cpp +122 -0
- package/native/core/src/module-registry.cpp +50 -0
- package/native/core/src/modules/accessibility-manager.cpp +98 -0
- package/native/core/src/modules/address-search.cpp +219 -0
- package/native/core/src/modules/alert-manager.cpp +140 -0
- package/native/core/src/modules/app-info.cpp +74 -0
- package/native/core/src/modules/app-modules.cpp +405 -0
- package/native/core/src/modules/apple-authentication.cpp +188 -0
- package/native/core/src/modules/asset.cpp +111 -0
- package/native/core/src/modules/async-storage.cpp +192 -0
- package/native/core/src/modules/audio.cpp +541 -0
- package/native/core/src/modules/battery.cpp +88 -0
- package/native/core/src/modules/calendar.cpp +457 -0
- package/native/core/src/modules/camera.cpp +221 -0
- package/native/core/src/modules/core-modules.cpp +62 -0
- package/native/core/src/modules/crypto.cpp +117 -0
- package/native/core/src/modules/desktop-expo.cpp +527 -0
- package/native/core/src/modules/file-system.cpp +941 -0
- package/native/core/src/modules/fonts.cpp +163 -0
- package/native/core/src/modules/image-loader.cpp +105 -0
- package/native/core/src/modules/image-manipulator.cpp +305 -0
- package/native/core/src/modules/language-model.cpp +195 -0
- package/native/core/src/modules/local-authentication.cpp +140 -0
- package/native/core/src/modules/location.cpp +186 -0
- package/native/core/src/modules/maps.cpp +500 -0
- package/native/core/src/modules/network-state.cpp +72 -0
- package/native/core/src/modules/networking.cpp +387 -0
- package/native/core/src/modules/notifications.cpp +549 -0
- package/native/core/src/modules/photo-library.cpp +371 -0
- package/native/core/src/modules/printing.cpp +201 -0
- package/native/core/src/modules/screen-capture.cpp +71 -0
- package/native/core/src/modules/sharing.cpp +59 -0
- package/native/core/src/modules/splash-screen.cpp +70 -0
- package/native/core/src/modules/sqlite.cpp +421 -0
- package/native/core/src/modules/store-review.cpp +23 -0
- package/native/core/src/modules/text-recognition.cpp +107 -0
- package/native/core/src/modules/tracking.cpp +46 -0
- package/native/core/src/modules/undo.cpp +59 -0
- package/native/core/src/modules/video.cpp +366 -0
- package/native/core/src/modules/web-browser.cpp +100 -0
- package/native/core/src/modules/web-socket.cpp +266 -0
- package/native/core/src/mounting-manager.cpp +380 -0
- package/native/core/src/native-controls.cpp +129 -0
- package/native/core/src/native-module.cpp +250 -0
- package/native/core/src/network.cpp +219 -0
- package/native/core/src/posix-launcher.cpp +366 -0
- package/native/core/src/processes.cpp +324 -0
- package/native/core/src/red-box-errors.js +83 -0
- package/native/core/src/red-box.cpp +306 -0
- package/native/core/src/runtime.cpp +422 -0
- package/native/core/src/safe-areas.cpp +130 -0
- package/native/core/src/screen-presentation.cpp +61 -0
- package/native/core/src/screen-stacks.cpp +254 -0
- package/native/core/src/scrollers.cpp +181 -0
- package/native/core/src/spawn-rules.cpp +292 -0
- package/native/core/src/split-view.cpp +343 -0
- package/native/core/src/svg.cpp +1883 -0
- package/native/core/src/symbol.cpp +94 -0
- package/native/core/src/tabs-host.cpp +234 -0
- package/native/core/src/text-input.cpp +126 -0
- package/native/core/src/text-layout-manager.cpp +63 -0
- package/native/core/src/tray-and-dock.cpp +154 -0
- package/native/core/src/updates.cpp +965 -0
- package/native/core/src/view-box.cpp +788 -0
- package/native/core/src/view-transform.cpp +45 -0
- package/native/core/src/view-tree.cpp +234 -0
- package/native/core/src/web-view.cpp +143 -0
- package/native/core/src/worklet-host.cpp +10 -0
- package/native/scripts/build-hermes.sh +44 -0
- package/native/scripts/build.sh +171 -0
- package/native/scripts/cache-dir.sh +18 -0
- package/native/scripts/codegen-library.sh +193 -0
- package/native/scripts/compiler-launcher.sh +17 -0
- package/native/scripts/fetch.sh +174 -0
- package/native/scripts/hermes-built.sh +10 -0
- package/native/scripts/host-dir.sh +16 -0
- package/native/scripts/macos-target.sh +8 -0
- package/native/scripts/make-prebuilt.mjs +360 -0
- package/native/scripts/prebuilt-host-cache.mjs +158 -0
- package/native/shim/openssl/sha.h +22 -0
- package/native/shim/view-platform/react/renderer/components/view/HostPlatformViewTraitsInitializer.h +37 -0
- package/package.json +73 -1
- package/prebuilt.json +33 -0
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
// The Expo Updates protocol client (protocol version 1), for updates from a
|
|
2
|
+
// self-hosted server: EAS Update refuses `macos`, and the iOS client is Swift over RCT and
|
|
3
|
+
// ExpoModulesCore, neither of which the desktop host has. Toolkit-free: requests go through the
|
|
4
|
+
// Http interface (network.h), the hash and the signature through UpdateCrypto, which a backend
|
|
5
|
+
// implements over the OS's own (CommonCrypto and Security on macOS), and files through
|
|
6
|
+
// std::filesystem under the app's data directory.
|
|
7
|
+
//
|
|
8
|
+
// - check: GET the server's URL with the protocol's headers (platform, runtime version, the
|
|
9
|
+
// running update's id, and the signature expected when code signing is on). The answer is a
|
|
10
|
+
// manifest, or a directive (`noUpdateAvailable`, `rollBackToEmbedded`), as JSON or as
|
|
11
|
+
// multipart/mixed. A manifest is an update only when its runtime version is this build's, it is
|
|
12
|
+
// not the running update nor one that failed to launch, and, with code signing on, its
|
|
13
|
+
// `expo-signature` verifies against the certificate (RSASSA-PKCS1-v1_5 over SHA-256).
|
|
14
|
+
// - fetch: downloads the checked update's launch asset and its other assets, one after another,
|
|
15
|
+
// and keeps the update only when each one's SHA-256 is the manifest's `hash` (base64url). An
|
|
16
|
+
// asset a kept update already has with the same hash is taken from disk. Each asset goes where
|
|
17
|
+
// React Native's resolver looks for it beside the bundle (SourceCode's scriptURL), found from the
|
|
18
|
+
// bundle's own registration of it (assetPathsInBundle); `assets.json` in the update's folder
|
|
19
|
+
// records where. A bundle whose registrations cannot be read (Hermes bytecode) gets each by its
|
|
20
|
+
// key, and NgNativeUpdates' `localAssets` answers where each is by that key, which a macOS
|
|
21
|
+
// bundle's asset resolver asks first. The update becomes the one the next launch runs.
|
|
22
|
+
// - launch: what the host loads at startup, the newest kept update or the embedded bundle. A launch
|
|
23
|
+
// of a downloaded update is marked before it starts and cleared once it has run for a while
|
|
24
|
+
// (markLaunchSucceeded); a marker still set at the next startup means that launch crashed, so the
|
|
25
|
+
// update is marked failed and the one before it, or the embedded bundle, runs instead. Expo's own
|
|
26
|
+
// recovery covers JavaScript errors only; a native crash needs this marker.
|
|
27
|
+
//
|
|
28
|
+
// `assetRequestHeaders` from a multipart response's extensions are not sent with the asset requests.
|
|
29
|
+
#pragma once
|
|
30
|
+
|
|
31
|
+
#include "ngn/network.h"
|
|
32
|
+
|
|
33
|
+
#include <folly/dynamic.h>
|
|
34
|
+
|
|
35
|
+
#include <filesystem>
|
|
36
|
+
#include <functional>
|
|
37
|
+
#include <map>
|
|
38
|
+
#include <memory>
|
|
39
|
+
#include <mutex>
|
|
40
|
+
#include <optional>
|
|
41
|
+
#include <string>
|
|
42
|
+
#include <vector>
|
|
43
|
+
|
|
44
|
+
namespace ngn {
|
|
45
|
+
|
|
46
|
+
class UpdateCrypto {
|
|
47
|
+
public:
|
|
48
|
+
virtual ~UpdateCrypto() = default;
|
|
49
|
+
// The SHA-256 digest of `bytes`, as 32 raw bytes.
|
|
50
|
+
virtual std::string sha256(const std::string &bytes) = 0;
|
|
51
|
+
// Whether `signature` (raw bytes) is an RSASSA-PKCS1-v1_5 SHA-256 signature of `data` by the key
|
|
52
|
+
// of the PEM certificate `certificatePem`. False for a certificate that does not parse.
|
|
53
|
+
virtual bool verifyRsaSha256(const std::string &certificatePem, const std::string &data, const std::string &signature) = 0;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
struct UpdatesConfig {
|
|
57
|
+
// The server's manifest URL (Expo's `updates.url`). Empty turns updates off.
|
|
58
|
+
std::string url;
|
|
59
|
+
std::string runtimeVersion;
|
|
60
|
+
// The `expo-platform` header. EAS Update refuses `macos`; a self-hosted server serves it.
|
|
61
|
+
std::string platform{"macos"};
|
|
62
|
+
// The certificate a manifest must be signed by, as PEM, with its `keyid` and `alg`
|
|
63
|
+
// (Expo's `updates.codeSigningCertificate` and `codeSigningMetadata`). Empty: no code signing.
|
|
64
|
+
std::string certificatePem;
|
|
65
|
+
std::string keyId{"main"};
|
|
66
|
+
std::string algorithm{"rsa-v1_5-sha256"};
|
|
67
|
+
// Where downloaded updates and the launch state are kept.
|
|
68
|
+
std::filesystem::path directory;
|
|
69
|
+
// The bundle packaged with the app, which runs when no update does.
|
|
70
|
+
std::string embeddedBundle;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// base64url without padding, as the protocol writes a hash.
|
|
74
|
+
std::string base64Url(const std::string &bytes);
|
|
75
|
+
|
|
76
|
+
// A Structured Field Values dictionary of strings, as `expo-signature` is: `sig="...", keyid="main"`.
|
|
77
|
+
// Nothing when it does not parse.
|
|
78
|
+
std::optional<std::map<std::string, std::string>> parseSignatureHeader(const std::string &header);
|
|
79
|
+
|
|
80
|
+
// One of a manifest's `assets`: its `key`, the file hash the bundle registers it by, and where it
|
|
81
|
+
// comes from.
|
|
82
|
+
struct UpdateAsset {
|
|
83
|
+
std::string key;
|
|
84
|
+
std::string hash;
|
|
85
|
+
std::string url;
|
|
86
|
+
// With its dot, as `.png`, or empty.
|
|
87
|
+
std::string fileExtension;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
// Where a bundle's assets go beside it, by file hash, read from Metro's `registerAsset` calls in
|
|
91
|
+
// it: `<httpServerLocation>/<name>[@<scale>x].<type>`, as React Native's resolver asks for them
|
|
92
|
+
// next to a bundle on disk, with `../` as `_`. A path that would lead out of the folder, or onto a
|
|
93
|
+
// file the client keeps there, is left out. Plain JavaScript only: Hermes bytecode gives nothing,
|
|
94
|
+
// so its assets are kept by key and found through NgNativeUpdates' `localAssets`.
|
|
95
|
+
std::map<std::string, std::string> assetPathsInBundle(const std::string &bundle);
|
|
96
|
+
|
|
97
|
+
struct UpdateManifest {
|
|
98
|
+
std::string id;
|
|
99
|
+
std::string createdAt;
|
|
100
|
+
std::string runtimeVersion;
|
|
101
|
+
std::string launchUrl;
|
|
102
|
+
std::string launchHash;
|
|
103
|
+
std::vector<UpdateAsset> assets;
|
|
104
|
+
// The manifest as the server sent it, which JavaScript gets.
|
|
105
|
+
folly::dynamic raw;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// What a server answers a check with.
|
|
109
|
+
struct UpdateResponse {
|
|
110
|
+
std::optional<UpdateManifest> manifest;
|
|
111
|
+
// The manifest's bytes as sent, which its signature covers.
|
|
112
|
+
std::string manifestBody;
|
|
113
|
+
// Its `expo-signature` header, empty when it has none.
|
|
114
|
+
std::string signature;
|
|
115
|
+
// `noUpdateAvailable` or `rollBackToEmbedded`, or empty.
|
|
116
|
+
std::string directive;
|
|
117
|
+
// The directive's bytes as sent, and its part's `expo-signature`, which covers them.
|
|
118
|
+
std::string directiveBody;
|
|
119
|
+
std::string directiveSignature;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// Reads a response body as the protocol allows it: a manifest as JSON (`application/json` or
|
|
123
|
+
// `application/expo+json`), or `multipart/mixed` with `manifest`, `directive` and `extensions`
|
|
124
|
+
// parts. Throws std::runtime_error naming what is wrong.
|
|
125
|
+
UpdateResponse parseUpdateResponse(const Headers &headers, const std::string &body);
|
|
126
|
+
|
|
127
|
+
// What the client keeps between launches, in `state.json` in its directory.
|
|
128
|
+
struct LaunchState {
|
|
129
|
+
struct Update {
|
|
130
|
+
std::string id;
|
|
131
|
+
std::string createdAt;
|
|
132
|
+
std::string runtimeVersion;
|
|
133
|
+
// The launch asset, relative to the directory.
|
|
134
|
+
std::string file;
|
|
135
|
+
bool operator==(const Update &) const = default;
|
|
136
|
+
};
|
|
137
|
+
std::optional<Update> current;
|
|
138
|
+
std::optional<Update> previous;
|
|
139
|
+
// Updates that crashed on launch, never run or offered again.
|
|
140
|
+
std::vector<std::string> failed;
|
|
141
|
+
// The update whose launch has not yet been marked a success.
|
|
142
|
+
std::string launching;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
class UpdatesClient {
|
|
146
|
+
public:
|
|
147
|
+
UpdatesClient(UpdatesConfig config, std::shared_ptr<Http> http, std::shared_ptr<UpdateCrypto> crypto);
|
|
148
|
+
|
|
149
|
+
bool enabled() const {
|
|
150
|
+
return !config_.url.empty();
|
|
151
|
+
}
|
|
152
|
+
const UpdatesConfig &config() const {
|
|
153
|
+
return config_;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// The bundle to load at startup, recovering from a launch that crashed (see above), and marking
|
|
157
|
+
// this launch. Call once, before the runtime starts.
|
|
158
|
+
std::string launch();
|
|
159
|
+
// This launch ran long enough to count, or the app quit cleanly: an update that crashes after it
|
|
160
|
+
// is not rolled back.
|
|
161
|
+
void markLaunchSucceeded();
|
|
162
|
+
// The same, only when `generation` is still the current launch's: a timer armed for a launch a
|
|
163
|
+
// reload has since replaced marks nothing.
|
|
164
|
+
void markLaunchSucceeded(uint64_t generation);
|
|
165
|
+
// Which launch is current; launch() and beginReload() each begin a new one.
|
|
166
|
+
uint64_t launchGeneration() const;
|
|
167
|
+
// The update this launch runs, or nothing for the embedded bundle.
|
|
168
|
+
std::optional<LaunchState::Update> running() const;
|
|
169
|
+
// That update's assets on disk, absolute paths by the manifest's key (the file hash a bundle
|
|
170
|
+
// registers each with). Empty for the embedded bundle.
|
|
171
|
+
std::map<std::string, std::string> localAssets() const;
|
|
172
|
+
|
|
173
|
+
struct CheckResult {
|
|
174
|
+
bool isAvailable{false};
|
|
175
|
+
bool isRollBackToEmbedded{false};
|
|
176
|
+
folly::dynamic manifest{nullptr};
|
|
177
|
+
// Why the check failed; empty when it did not.
|
|
178
|
+
std::string error;
|
|
179
|
+
};
|
|
180
|
+
// Asks the server. `done` may run on any thread.
|
|
181
|
+
void check(std::function<void(CheckResult)> done);
|
|
182
|
+
|
|
183
|
+
struct FetchResult {
|
|
184
|
+
bool isNew{false};
|
|
185
|
+
bool isRollBackToEmbedded{false};
|
|
186
|
+
folly::dynamic manifest{nullptr};
|
|
187
|
+
std::string error;
|
|
188
|
+
};
|
|
189
|
+
// Downloads what the last check found, which the next launch (or reload) runs.
|
|
190
|
+
void fetch(std::function<void(FetchResult)> done);
|
|
191
|
+
|
|
192
|
+
// The bundle a reload now runs: the fetched update, or the embedded bundle after a rollback.
|
|
193
|
+
std::string bundleToRun() const;
|
|
194
|
+
// Marks that bundle's launch, as launch() does, and answers it, for a reload into it.
|
|
195
|
+
std::string beginReload();
|
|
196
|
+
|
|
197
|
+
LaunchState state() const;
|
|
198
|
+
|
|
199
|
+
private:
|
|
200
|
+
LaunchState load() const;
|
|
201
|
+
void save(const LaunchState &state) const;
|
|
202
|
+
std::string pathOf(const LaunchState::Update &update) const;
|
|
203
|
+
bool usable(const LaunchState::Update &update, const LaunchState &state) const;
|
|
204
|
+
void markLocked();
|
|
205
|
+
// Why a manifest's (or the `what` named) signature header does not verify its bytes, when the
|
|
206
|
+
// app requires signing.
|
|
207
|
+
std::optional<std::string> signatureProblem(
|
|
208
|
+
const std::string &body, const std::string &header, const std::string &what = "manifest") const;
|
|
209
|
+
|
|
210
|
+
UpdatesConfig config_;
|
|
211
|
+
std::shared_ptr<Http> http_;
|
|
212
|
+
std::shared_ptr<UpdateCrypto> crypto_;
|
|
213
|
+
mutable std::mutex mutex_;
|
|
214
|
+
std::optional<LaunchState::Update> running_;
|
|
215
|
+
// What the last check found.
|
|
216
|
+
std::optional<UpdateManifest> found_;
|
|
217
|
+
std::string foundBody_;
|
|
218
|
+
uint64_t generation_{0};
|
|
219
|
+
std::string foundSignature_;
|
|
220
|
+
bool foundRollBack_{false};
|
|
221
|
+
std::shared_ptr<HttpTask> task_;
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
// The whole-app updater: Sparkle, in a `dmg` build only (the Mac App Store updates a `mas` build,
|
|
225
|
+
// and an `app` build has none).
|
|
226
|
+
class AppUpdater {
|
|
227
|
+
public:
|
|
228
|
+
virtual ~AppUpdater() = default;
|
|
229
|
+
// Checks now, with the updater's own window.
|
|
230
|
+
virtual void check() = 0;
|
|
231
|
+
// Whether a background check found an update.
|
|
232
|
+
virtual bool updateAvailable() = 0;
|
|
233
|
+
// Told when a check finds an update, or finds none. One listener: a later one replaces it.
|
|
234
|
+
virtual void onUpdateAvailable(std::function<void(bool available)> listener) = 0;
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
class NativeModule;
|
|
238
|
+
// NgNativeUpdates: what @ng-native/expo's Updates calls on expo-updates. `isEnabled`, `updateId`,
|
|
239
|
+
// `runtimeVersion` and `isEmbeddedLaunch` as properties; checkForUpdateAsync, fetchUpdateAsync and
|
|
240
|
+
// reloadAsync, which resolves and then restarts the runtime on the fetched bundle through `reload`
|
|
241
|
+
// (the promise's runtime does not outlive the reload). Disabled (every
|
|
242
|
+
// call refused) in development, where the bundle comes from Metro.
|
|
243
|
+
//
|
|
244
|
+
// The whole-app half, over `appUpdater`: the `isAppUpdaterAvailable` property, isAppUpdateAvailable,
|
|
245
|
+
// checkForAppUpdateAsync (true once the updater's window is up) and the `appUpdateAvailable` event
|
|
246
|
+
// ({available}). Without an updater it is absent: the property is false and the calls answer false.
|
|
247
|
+
std::shared_ptr<NativeModule> makeUpdatesModule(
|
|
248
|
+
std::shared_ptr<UpdatesClient> client,
|
|
249
|
+
bool development,
|
|
250
|
+
std::function<void(const std::string &bundle, std::function<void(bool)> done)> reload,
|
|
251
|
+
std::shared_ptr<AppUpdater> appUpdater = nullptr);
|
|
252
|
+
|
|
253
|
+
} // namespace ngn
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// NgNativeVideo: what @ng-native/expo's videoPlayer calls on expo-video, over a VideoOutput the
|
|
2
|
+
// AppKit backend implements with AVPlayer, and expo-video's view (ViewManagerAdapter_ExpoVideo_VideoView)
|
|
3
|
+
// as a Fabric component of the desktop's own. A TurboModule cannot hand back expo-video's shared
|
|
4
|
+
// objects, so players are numbers, and the JS adapter (desktop-video.ts) wraps each in expo-video's
|
|
5
|
+
// VideoPlayer, whose shared-object id is that number: `<expo-video [player]>` commits it, and the
|
|
6
|
+
// view finds the player's AVPlayer by it.
|
|
7
|
+
//
|
|
8
|
+
// - createPlayer(uri | null) -> id, replace(id, uri | null), release(id).
|
|
9
|
+
// - play(id), pause(id), replay(id) (from the start), seekBy(id, seconds), setCurrentTime(id, seconds).
|
|
10
|
+
// - setPlaybackRate(id, rate), setVolume(id, volume) (0 to 1), setMuted(id, muted), setLoop(id, loop),
|
|
11
|
+
// setPreservesPitch(id, preserves), setTimeUpdateEventInterval(id, seconds) (0 stops them).
|
|
12
|
+
// - state(id) -> {status, playing, currentTime, duration, bufferedPosition, playbackRate, volume,
|
|
13
|
+
// muted, loop, preservesPitch, timeUpdateEventInterval}, what the player's getters read.
|
|
14
|
+
//
|
|
15
|
+
// Events are `ngNativeVideo` {type, id, payload}, with expo-video's iOS names and payloads:
|
|
16
|
+
// statusChange ({status, oldStatus, error?: {message}}), playingChange, playbackRateChange,
|
|
17
|
+
// volumeChange, mutedChange (each with its old value), sourceChange ({source, oldSource}),
|
|
18
|
+
// sourceLoad (once a source is ready: {videoSource, duration, and empty track lists}), timeUpdate
|
|
19
|
+
// ({currentTime, currentLiveTimestamp: null, currentOffsetFromLive: null, bufferedPosition}) every
|
|
20
|
+
// interval while the position moves, and playToEnd. A looping player starts over at its end, and
|
|
21
|
+
// one that is not stays there, as AVPlayer does, until replay() or a seek.
|
|
22
|
+
#pragma once
|
|
23
|
+
|
|
24
|
+
#include "ngn/desktop-props.h"
|
|
25
|
+
#include "ngn/file-system.h"
|
|
26
|
+
#include "ngn/native-module.h"
|
|
27
|
+
|
|
28
|
+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
29
|
+
#include <react/renderer/components/view/ViewEventEmitter.h>
|
|
30
|
+
#include <react/renderer/components/view/ViewProps.h>
|
|
31
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
32
|
+
|
|
33
|
+
#include <functional>
|
|
34
|
+
#include <memory>
|
|
35
|
+
#include <optional>
|
|
36
|
+
#include <string>
|
|
37
|
+
|
|
38
|
+
namespace ngn {
|
|
39
|
+
|
|
40
|
+
struct VideoState {
|
|
41
|
+
enum class Load { Loading, Ready, Failed };
|
|
42
|
+
Load load{Load::Loading};
|
|
43
|
+
std::string error;
|
|
44
|
+
bool playing{false};
|
|
45
|
+
// Waiting for data at a rate above zero.
|
|
46
|
+
bool buffering{false};
|
|
47
|
+
// Seconds; a duration not known yet is 0.
|
|
48
|
+
double currentTime{0};
|
|
49
|
+
double duration{0};
|
|
50
|
+
double bufferedPosition{0};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// One player and the source it holds, if any. Destroying it stops it and starts no call after;
|
|
54
|
+
// a call already running on another thread may still finish, so `changed` guards what it reaches
|
|
55
|
+
// (the core's does, by a weak pointer and the source's generation). The backend never waits for
|
|
56
|
+
// such a call, since the core destroys and reconfigures players under the lock `changed` takes.
|
|
57
|
+
class VideoPlayback {
|
|
58
|
+
public:
|
|
59
|
+
enum class Change { State, Time, Ended };
|
|
60
|
+
virtual ~VideoPlayback() = default;
|
|
61
|
+
// Replaces the source; null leaves the player empty. `changed` on any thread for this source
|
|
62
|
+
// only: State as it loads, fails, starts, stalls or stops, Time every update interval while the
|
|
63
|
+
// position moves, Ended as it reaches the end.
|
|
64
|
+
virtual void load(const std::optional<std::string> &uri, std::function<void(Change)> changed) = 0;
|
|
65
|
+
// The current source's state; meaningless with none.
|
|
66
|
+
virtual VideoState state() = 0;
|
|
67
|
+
virtual void play(double rate) = 0;
|
|
68
|
+
virtual void pause() = 0;
|
|
69
|
+
// `done` once the position is there, on any thread.
|
|
70
|
+
virtual void seek(double seconds, std::function<void()> done) = 0;
|
|
71
|
+
virtual void setRate(double rate) = 0;
|
|
72
|
+
virtual void setVolume(double volume) = 0;
|
|
73
|
+
virtual void setMuted(bool muted) = 0;
|
|
74
|
+
virtual void setPreservesPitch(bool preserves) = 0;
|
|
75
|
+
// Seconds between Time changes; 0 sends none.
|
|
76
|
+
virtual void setTimeUpdates(double interval) = 0;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
class VideoOutput {
|
|
80
|
+
public:
|
|
81
|
+
virtual ~VideoOutput() = default;
|
|
82
|
+
// A player with no source, that the view finds by `id` while it lives.
|
|
83
|
+
virtual std::unique_ptr<VideoPlayback> make(int id) = 0;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// A file source plays only inside the file boundary `files` draws (readableSource); one outside is
|
|
87
|
+
// a source whose status is error, with the refusal as its message, and is never opened.
|
|
88
|
+
std::shared_ptr<NativeModule> makeVideoModule(std::shared_ptr<VideoOutput> output, std::shared_ptr<FileAccess> files);
|
|
89
|
+
|
|
90
|
+
// --- the view ------------------------------------------------------------------------------------
|
|
91
|
+
|
|
92
|
+
extern const char VideoViewComponentName[];
|
|
93
|
+
|
|
94
|
+
class VideoViewProps final : public facebook::react::ViewProps, public HasDesktopProps {
|
|
95
|
+
public:
|
|
96
|
+
VideoViewProps() = default;
|
|
97
|
+
VideoViewProps(
|
|
98
|
+
const facebook::react::PropsParserContext &context,
|
|
99
|
+
const VideoViewProps &sourceProps,
|
|
100
|
+
const facebook::react::RawProps &rawProps);
|
|
101
|
+
// Every prop as committed, the last value of each: a `null` removes one.
|
|
102
|
+
folly::dynamic values = folly::dynamic::object();
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
using VideoViewShadowNode =
|
|
106
|
+
facebook::react::ConcreteViewShadowNode<VideoViewComponentName, VideoViewProps, facebook::react::ViewEventEmitter>;
|
|
107
|
+
using VideoViewComponentDescriptor = facebook::react::ConcreteComponentDescriptor<VideoViewShadowNode>;
|
|
108
|
+
|
|
109
|
+
// What the view shows, from expo-video's iOS props.
|
|
110
|
+
struct VideoViewModel {
|
|
111
|
+
enum class Fit { Contain, Cover, Fill };
|
|
112
|
+
// The player's id, as `player` commits it; none draws nothing.
|
|
113
|
+
std::optional<int> player;
|
|
114
|
+
bool nativeControls{true};
|
|
115
|
+
Fit contentFit{Fit::Contain};
|
|
116
|
+
// `fullscreenOptions.enable`, the full screen button.
|
|
117
|
+
bool fullscreen{true};
|
|
118
|
+
bool pictureInPicture{false};
|
|
119
|
+
bool timecodes{true};
|
|
120
|
+
bool frameAnalysis{true};
|
|
121
|
+
bool operator==(const VideoViewModel &) const = default;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
VideoViewModel videoViewModel(const folly::dynamic &values);
|
|
125
|
+
|
|
126
|
+
} // namespace ngn
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// A view's box as React Native iOS paints it (RCTViewComponentView, RCTBorderDrawing,
|
|
2
|
+
// RCTBoxShadow, RCTLinearGradient, RCTRadialGradient and RCTBackgroundImageUtils), with CSS's
|
|
3
|
+
// meaning where it reads a value: its background colour and images, its borders, its corner radii
|
|
4
|
+
// and its box shadows.
|
|
5
|
+
//
|
|
6
|
+
// Core Animation draws a box whose corners share one radius and whose border is one solid width
|
|
7
|
+
// and colour, on the view's own layer, as React Native iOS does; it draws the border over the
|
|
8
|
+
// view's children, so only where that cannot show (no border, a clear one, or a view that clips).
|
|
9
|
+
// Every other box is drawn by drawViewBox on an SvgCanvas over the view's own contents, under its
|
|
10
|
+
// children: the background in the border box's shape, the background images, then each side of the
|
|
11
|
+
// border in its own width and colour. A box shadow is a layer of its own (BoxShadowLayer), as
|
|
12
|
+
// Core Animation blurs it.
|
|
13
|
+
#pragma once
|
|
14
|
+
|
|
15
|
+
#include "ngn/svg.h"
|
|
16
|
+
|
|
17
|
+
#include <react/renderer/components/view/ViewProps.h>
|
|
18
|
+
#include <react/renderer/core/LayoutMetrics.h>
|
|
19
|
+
#include <react/renderer/graphics/BoxShadow.h>
|
|
20
|
+
#include <react/renderer/graphics/LinearGradient.h>
|
|
21
|
+
#include <react/renderer/graphics/RadialGradient.h>
|
|
22
|
+
|
|
23
|
+
#include <cstdint>
|
|
24
|
+
#include <optional>
|
|
25
|
+
#include <vector>
|
|
26
|
+
|
|
27
|
+
namespace ngn {
|
|
28
|
+
|
|
29
|
+
// Each corner's radius across (x) and down (y).
|
|
30
|
+
struct CornerRadii {
|
|
31
|
+
struct Corner {
|
|
32
|
+
double x{0}, y{0};
|
|
33
|
+
bool operator==(const Corner &) const = default;
|
|
34
|
+
};
|
|
35
|
+
Corner topLeft, topRight, bottomRight, bottomLeft;
|
|
36
|
+
|
|
37
|
+
// One radius, the same across and down at every corner: what a layer's cornerRadius draws.
|
|
38
|
+
bool circular() const;
|
|
39
|
+
bool operator==(const CornerRadii &) const = default;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
struct EdgeWidths {
|
|
43
|
+
double top{0}, right{0}, bottom{0}, left{0};
|
|
44
|
+
bool operator==(const EdgeWidths &) const = default;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// The radii of the box inside a border: each less the width of the side it meets, never below 0.
|
|
48
|
+
CornerRadii innerRadii(const CornerRadii &radii, const EdgeWidths &widths);
|
|
49
|
+
|
|
50
|
+
// The radii of a shadow's shape, spread by `spread` (CSS's rule, which grows a small radius less).
|
|
51
|
+
CornerRadii spreadRadii(const CornerRadii &radii, double spread);
|
|
52
|
+
|
|
53
|
+
// The rect with its corners rounded, clockwise from the top left, each radius kept within what the
|
|
54
|
+
// opposite corner on its side leaves. `reversed` runs it anticlockwise, so that it cuts a hole in
|
|
55
|
+
// a path filled by the nonzero rule.
|
|
56
|
+
SvgPath roundedRect(const SvgRect &rect, const CornerRadii &radii, bool reversed = false);
|
|
57
|
+
|
|
58
|
+
// A gradient's stops, from 0 at its start to 1 at its end, as CSS places them: a missing first or
|
|
59
|
+
// last position at the end, the missing ones between spread evenly, none before the one before,
|
|
60
|
+
// a length taken along `lineLength`, and a colour hint as the curve of stops it stands for.
|
|
61
|
+
std::vector<std::pair<double, uint32_t>> gradientStops(
|
|
62
|
+
const std::vector<facebook::react::ColorStop> &stops,
|
|
63
|
+
double lineLength);
|
|
64
|
+
|
|
65
|
+
// A gradient filling a tile of `size` whose top left is at (0, 0), ready for SvgCanvas. Stops
|
|
66
|
+
// before the start or past the end move its ends out, so that none is cut off.
|
|
67
|
+
SvgGradient linearGradient(const facebook::react::LinearGradient &gradient, double width, double height);
|
|
68
|
+
// nullopt when the gradient has no area (a radius of 0).
|
|
69
|
+
std::optional<SvgGradient> radialGradient(const facebook::react::RadialGradient &gradient, double width, double height);
|
|
70
|
+
|
|
71
|
+
// Where one background image's tiles go, in the view's coordinates: the size background-size
|
|
72
|
+
// gives it in the positioning area (the padding box), placed by background-position and repeated
|
|
73
|
+
// by background-repeat over the painting area (the border box, from (0, 0)). A gradient has no
|
|
74
|
+
// size of its own, so `auto`, `cover` and `contain` are the positioning area's.
|
|
75
|
+
std::vector<SvgRect> backgroundTiles(
|
|
76
|
+
const SvgRect &positioningArea,
|
|
77
|
+
const SvgRect &paintingArea,
|
|
78
|
+
const facebook::react::BackgroundSize &size,
|
|
79
|
+
const facebook::react::BackgroundPosition &position,
|
|
80
|
+
const facebook::react::BackgroundRepeat &repeat);
|
|
81
|
+
|
|
82
|
+
// A box shadow as a layer the size of the view, which Core Animation blurs.
|
|
83
|
+
struct BoxShadowLayer {
|
|
84
|
+
bool inset{false};
|
|
85
|
+
uint32_t argb{0xff000000};
|
|
86
|
+
// The layer's shadowRadius: half the CSS blur, React Native iOS's match for the web's.
|
|
87
|
+
double radius{0};
|
|
88
|
+
// The shape that casts the shadow, filled by the nonzero rule.
|
|
89
|
+
SvgPath shadowPath;
|
|
90
|
+
// Where the layer shows: outside the view's box for an outer shadow (by the even-odd rule), and
|
|
91
|
+
// inside its padding box for an inset one.
|
|
92
|
+
SvgPath mask;
|
|
93
|
+
bool maskEvenOdd{false};
|
|
94
|
+
bool operator==(const BoxShadowLayer &) const = default;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// What the backend sets on a view's own layer and adds to it.
|
|
98
|
+
struct ViewBox {
|
|
99
|
+
// Core Animation draws the background and border: the layer's backgroundColor, cornerRadius,
|
|
100
|
+
// borderWidth and borderColor are these. Otherwise the layer has no background or border, and
|
|
101
|
+
// drawViewBox draws them.
|
|
102
|
+
bool layerDrawn{true};
|
|
103
|
+
std::optional<uint32_t> background;
|
|
104
|
+
double borderWidth{0};
|
|
105
|
+
std::optional<uint32_t> borderColor;
|
|
106
|
+
// The layer's cornerRadius, which also clips a view that clips its overflow, when every corner
|
|
107
|
+
// has the same radius; 0 when they differ.
|
|
108
|
+
double cornerRadius{0};
|
|
109
|
+
// Whether drawViewBox draws anything: the background and border when the layer does not, and
|
|
110
|
+
// background images.
|
|
111
|
+
bool drawn{false};
|
|
112
|
+
// For a view that clips its overflow when its corners differ: the border box's shape, the
|
|
113
|
+
// layer's mask.
|
|
114
|
+
std::optional<SvgPath> clip;
|
|
115
|
+
// Bottom first: the last shadow CSS lists is under the others.
|
|
116
|
+
std::vector<BoxShadowLayer> shadows;
|
|
117
|
+
bool operator==(const ViewBox &) const = default;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
ViewBox viewBox(const facebook::react::ViewProps &props, const facebook::react::LayoutMetrics &layout);
|
|
121
|
+
|
|
122
|
+
// Draws what the layer does not: the background colour in the border box's shape, the background
|
|
123
|
+
// images, and the border side by side. Draws nothing for a box viewBox says is not `drawn`.
|
|
124
|
+
void drawViewBox(const facebook::react::ViewProps &props, const facebook::react::LayoutMetrics &layout, SvgCanvas &canvas);
|
|
125
|
+
|
|
126
|
+
} // namespace ngn
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// A view's `transform` as a layer whose anchor is its top-left corner takes it. React Native iOS
|
|
2
|
+
// sets `props.resolveTransform(layoutMetrics)` on a UIView's layer, whose anchor is its centre;
|
|
3
|
+
// an AppKit view's layer is anchored at its origin, so the same matrix is moved there.
|
|
4
|
+
#pragma once
|
|
5
|
+
|
|
6
|
+
#include <react/renderer/components/view/ViewProps.h>
|
|
7
|
+
#include <react/renderer/core/LayoutMetrics.h>
|
|
8
|
+
#include <react/renderer/graphics/Transform.h>
|
|
9
|
+
|
|
10
|
+
#include <optional>
|
|
11
|
+
|
|
12
|
+
namespace ngn {
|
|
13
|
+
|
|
14
|
+
// Nothing for no transform: the layer keeps the identity.
|
|
15
|
+
std::optional<facebook::react::Transform> layerTransform(
|
|
16
|
+
const facebook::react::ViewProps &props,
|
|
17
|
+
const facebook::react::LayoutMetrics &layout);
|
|
18
|
+
|
|
19
|
+
// The point of the layer's own plane (z = 0) that `transform` draws at `point`, both from the
|
|
20
|
+
// layer's corner: the inverse of the homography of the matrix's x, y and w rows and columns.
|
|
21
|
+
// Nothing when the transform flattens the plane to a line or a point.
|
|
22
|
+
std::optional<facebook::react::Point> layerPointAt(
|
|
23
|
+
const facebook::react::Transform &transform,
|
|
24
|
+
facebook::react::Point point);
|
|
25
|
+
|
|
26
|
+
} // namespace ngn
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// The core's copy of the mounted view tree: which view is where, for every surface.
|
|
2
|
+
//
|
|
3
|
+
// The mounting manager keeps it in step with what it asks the backend to mount, on the UI thread,
|
|
4
|
+
// so hit testing (and later the Tab-order walk) runs in the core, the same on every toolkit.
|
|
5
|
+
#pragma once
|
|
6
|
+
|
|
7
|
+
#include <react/renderer/core/LayoutMetrics.h>
|
|
8
|
+
#include <react/renderer/mounting/ShadowView.h>
|
|
9
|
+
|
|
10
|
+
#include <optional>
|
|
11
|
+
#include <unordered_map>
|
|
12
|
+
#include <unordered_set>
|
|
13
|
+
#include <vector>
|
|
14
|
+
|
|
15
|
+
namespace ngn {
|
|
16
|
+
|
|
17
|
+
using facebook::react::Point;
|
|
18
|
+
using facebook::react::ShadowView;
|
|
19
|
+
using facebook::react::SurfaceId;
|
|
20
|
+
using facebook::react::Tag;
|
|
21
|
+
|
|
22
|
+
class ViewTree {
|
|
23
|
+
public:
|
|
24
|
+
struct Node {
|
|
25
|
+
ShadowView view;
|
|
26
|
+
Tag parent{-1};
|
|
27
|
+
std::vector<Tag> children;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
void create(const ShadowView &view);
|
|
31
|
+
void destroy(Tag tag);
|
|
32
|
+
void insert(Tag parent, Tag child, int index);
|
|
33
|
+
void remove(Tag parent, Tag child);
|
|
34
|
+
void update(const ShadowView &view);
|
|
35
|
+
|
|
36
|
+
const Node *find(Tag tag) const;
|
|
37
|
+
bool contains(Tag tag) const;
|
|
38
|
+
|
|
39
|
+
// Marks `root` as the root of a container of its own (a sheet, a popover, a sidebar pane).
|
|
40
|
+
// A hit test that starts anywhere else skips that subtree, so a click in the window never
|
|
41
|
+
// lands on a popover's nodes.
|
|
42
|
+
void addContainerRoot(Tag root);
|
|
43
|
+
void removeContainerRoot(Tag root);
|
|
44
|
+
bool isContainerRoot(Tag tag) const;
|
|
45
|
+
|
|
46
|
+
// The views under `point` (in `root`'s coordinates), from `root` down to the deepest, as React
|
|
47
|
+
// Native iOS's hitTest:withEvent: finds them: later siblings are on top, `pointerEvents` is
|
|
48
|
+
// honoured, hidden views are skipped, and a view clips the hit test to its bounds when it
|
|
49
|
+
// clips its content or nothing of it overflows. A view with a `transform` is hit where its
|
|
50
|
+
// layer draws it, moved, scaled or rotated. Empty when nothing is hit.
|
|
51
|
+
std::vector<Tag> hitTest(Tag root, Point point) const;
|
|
52
|
+
|
|
53
|
+
// A screen below the top of its stack: kept mounted, but neither drawn nor hit.
|
|
54
|
+
void setCovered(Tag tag, bool covered);
|
|
55
|
+
bool covered(Tag tag) const;
|
|
56
|
+
|
|
57
|
+
// How far a scrolling view has scrolled its content: the content's origin is drawn at minus
|
|
58
|
+
// this. The backend reports it as the user scrolls; the view's state lags behind.
|
|
59
|
+
void setScrollOffset(Tag tag, Point offset);
|
|
60
|
+
|
|
61
|
+
// The views from `root` down to `tag`, or nothing when `tag` is not under `root`.
|
|
62
|
+
std::vector<Tag> chain(Tag tag, Tag root) const;
|
|
63
|
+
|
|
64
|
+
// Where `tag`'s origin is in `root`'s coordinates, or nothing when `tag` is not under `root`.
|
|
65
|
+
// Transforms are not applied: this is the layout's origin.
|
|
66
|
+
std::optional<Point> originIn(Tag tag, Tag root) const;
|
|
67
|
+
|
|
68
|
+
// `point`, in `root`'s coordinates, in `tag`'s own, through every transform between them, as
|
|
69
|
+
// UIKit's convertPoint:fromView: does. Nothing when `tag` is not under `root` or a transform
|
|
70
|
+
// flattens it to a line.
|
|
71
|
+
std::optional<Point> pointIn(Tag tag, Tag root, Point point) const;
|
|
72
|
+
|
|
73
|
+
private:
|
|
74
|
+
bool hitTest(Tag tag, Tag root, Point point, std::vector<Tag> &chain) const;
|
|
75
|
+
// `point` in the parent's coordinates (its scroll already taken off) in `child`'s own.
|
|
76
|
+
static std::optional<Point> toChild(const Node &child, Point point);
|
|
77
|
+
Point scrollOffset(Tag tag) const;
|
|
78
|
+
|
|
79
|
+
std::unordered_map<Tag, Node> nodes_;
|
|
80
|
+
std::unordered_set<Tag> containerRoots_;
|
|
81
|
+
std::unordered_set<Tag> covered_;
|
|
82
|
+
std::unordered_map<Tag, Point> scrollOffsets_;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
} // namespace ngn
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// NgNativeWebBrowser: what @ng-native/expo's Browser calls on expo-web-browser. A Mac has no
|
|
2
|
+
// in-app browser sheet, so a page opens in the user's default browser, and a sign-in runs in an
|
|
3
|
+
// AuthSession, which the AppKit backend implements with ASWebAuthenticationSession.
|
|
4
|
+
//
|
|
5
|
+
// - openBrowserAsync(url): opens an http or https url, by the one url policy Linking and Shell
|
|
6
|
+
// use (externalUrlAllowed), and answers {type: 'opened'}. Anything else is refused.
|
|
7
|
+
// - dismissBrowser(): {type: 'dismiss'}; there is nothing of the host's to close.
|
|
8
|
+
// - openAuthSessionAsync(url, redirectUrl, {preferEphemeralSession}): {type: 'success', url} with
|
|
9
|
+
// the url the session was redirected to, or {type: 'cancel'}. One at a time, as on iOS. The
|
|
10
|
+
// session's callback scheme is redirectUrl's. With `noPrompts` (NGN_NO_PROMPTS=1) no session
|
|
11
|
+
// starts, since the OS asks the user first, and the answer is {type: 'cancel'}.
|
|
12
|
+
// - dismissAuthSession(): ends the session in progress, which answers {type: 'cancel'}.
|
|
13
|
+
#pragma once
|
|
14
|
+
|
|
15
|
+
#include "ngn/native-module.h"
|
|
16
|
+
#include "ngn/system.h"
|
|
17
|
+
|
|
18
|
+
#include <functional>
|
|
19
|
+
#include <memory>
|
|
20
|
+
#include <optional>
|
|
21
|
+
#include <string>
|
|
22
|
+
|
|
23
|
+
namespace ngn {
|
|
24
|
+
|
|
25
|
+
class AuthSession {
|
|
26
|
+
public:
|
|
27
|
+
struct Request {
|
|
28
|
+
std::string url;
|
|
29
|
+
// The scheme the session ends on ("myapp"), or empty for none.
|
|
30
|
+
std::string callbackScheme;
|
|
31
|
+
bool ephemeral{false};
|
|
32
|
+
};
|
|
33
|
+
virtual ~AuthSession() = default;
|
|
34
|
+
// Answers once, on any thread: the url the session ended on, or nothing when it was cancelled
|
|
35
|
+
// (by the user, or by cancel()). `error` says why it could not start.
|
|
36
|
+
virtual void start(const Request &request, std::function<void(std::optional<std::string> url, std::string error)> done) = 0;
|
|
37
|
+
virtual void cancel() = 0;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// Whether `url` is http or https: what expo-web-browser opens.
|
|
41
|
+
bool webUrl(const std::string &url);
|
|
42
|
+
|
|
43
|
+
std::shared_ptr<NativeModule> makeWebBrowserModule(std::shared_ptr<System> system, std::shared_ptr<AuthSession> sessions, bool noPrompts);
|
|
44
|
+
|
|
45
|
+
} // namespace ngn
|