@ng-native/desktop 0.0.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +52 -0
- package/app.plugin.cjs +17 -0
- package/bin/app-config.mjs +168 -0
- package/bin/autolink.mjs +224 -0
- package/bin/cli.mjs +158 -0
- package/bin/host.mjs +427 -0
- package/bin/ng-native-desktop.mjs +4 -0
- package/bin/package.mjs +971 -0
- package/bin/plist.mjs +68 -0
- package/bin/prebuilt.mjs +328 -0
- package/bin/toolchain.mjs +192 -0
- package/native/CMakeLists.txt +277 -0
- package/native/appkit/CMakeLists.txt +130 -0
- package/native/appkit/address-search.h +26 -0
- package/native/appkit/address-search.mm +277 -0
- package/native/appkit/animation-frames.h +14 -0
- package/native/appkit/animation-frames.mm +106 -0
- package/native/appkit/app-info.h +12 -0
- package/native/appkit/app-info.mm +98 -0
- package/native/appkit/app-updater.mm +128 -0
- package/native/appkit/app-windows.h +81 -0
- package/native/appkit/app-windows.mm +318 -0
- package/native/appkit/appkit-backend.h +73 -0
- package/native/appkit/appkit-backend.mm +276 -0
- package/native/appkit/apple-authentication.h +19 -0
- package/native/appkit/apple-authentication.mm +248 -0
- package/native/appkit/apple-button-view.h +10 -0
- package/native/appkit/apple-button-view.mm +37 -0
- package/native/appkit/apple-id-button.h +16 -0
- package/native/appkit/apple-id-button.mm +50 -0
- package/native/appkit/audio.h +16 -0
- package/native/appkit/audio.mm +275 -0
- package/native/appkit/battery.h +13 -0
- package/native/appkit/battery.mm +92 -0
- package/native/appkit/bookmarks.h +17 -0
- package/native/appkit/bookmarks.mm +145 -0
- package/native/appkit/calendar.h +25 -0
- package/native/appkit/calendar.mm +660 -0
- package/native/appkit/camera-sheet.h +59 -0
- package/native/appkit/camera-sheet.mm +344 -0
- package/native/appkit/camera-view.h +15 -0
- package/native/appkit/camera-view.mm +134 -0
- package/native/appkit/camera.h +61 -0
- package/native/appkit/camera.mm +496 -0
- package/native/appkit/cg-canvas.h +24 -0
- package/native/appkit/cg-canvas.mm +663 -0
- package/native/appkit/component-view.h +17 -0
- package/native/appkit/crypto.h +19 -0
- package/native/appkit/crypto.mm +78 -0
- package/native/appkit/desktop-expo.h +29 -0
- package/native/appkit/desktop-expo.mm +385 -0
- package/native/appkit/expo-image-drawing.h +46 -0
- package/native/appkit/expo-image-drawing.mm +131 -0
- package/native/appkit/expo-image-view.h +15 -0
- package/native/appkit/expo-image-view.mm +182 -0
- package/native/appkit/expo-ui-renderer.h +68 -0
- package/native/appkit/expo-ui-renderer.mm +101 -0
- package/native/appkit/expo-ui-view.h +26 -0
- package/native/appkit/expo-ui-view.mm +134 -0
- package/native/appkit/expo-ui.swift +1284 -0
- package/native/appkit/file-system.h +16 -0
- package/native/appkit/file-system.mm +140 -0
- package/native/appkit/fonts.h +12 -0
- package/native/appkit/fonts.mm +48 -0
- package/native/appkit/geocoder.h +19 -0
- package/native/appkit/geocoder.mm +101 -0
- package/native/appkit/glass-effect.h +22 -0
- package/native/appkit/glass-effect.mm +63 -0
- package/native/appkit/glass-view.h +8 -0
- package/native/appkit/glass-view.mm +65 -0
- package/native/appkit/header-toolbar.h +60 -0
- package/native/appkit/header-toolbar.mm +632 -0
- package/native/appkit/host-view.h +54 -0
- package/native/appkit/host-view.mm +1228 -0
- package/native/appkit/image-manipulator.h +14 -0
- package/native/appkit/image-manipulator.mm +191 -0
- package/native/appkit/image-request.h +22 -0
- package/native/appkit/image-request.mm +62 -0
- package/native/appkit/image-view.h +8 -0
- package/native/appkit/image-view.mm +142 -0
- package/native/appkit/input-replay.h +25 -0
- package/native/appkit/input-replay.mm +418 -0
- package/native/appkit/language-model.h +14 -0
- package/native/appkit/language-model.mm +99 -0
- package/native/appkit/language-model.swift +472 -0
- package/native/appkit/local-authentication.h +15 -0
- package/native/appkit/local-authentication.mm +133 -0
- package/native/appkit/location.h +16 -0
- package/native/appkit/location.mm +214 -0
- package/native/appkit/main.mm +1475 -0
- package/native/appkit/map-view.h +15 -0
- package/native/appkit/map-view.mm +109 -0
- package/native/appkit/maps.h +35 -0
- package/native/appkit/maps.mm +343 -0
- package/native/appkit/menu-bar.h +22 -0
- package/native/appkit/menu-bar.mm +208 -0
- package/native/appkit/modal-focus.h +16 -0
- package/native/appkit/modal-focus.mm +26 -0
- package/native/appkit/modal-host-view.h +79 -0
- package/native/appkit/modal-host-view.mm +442 -0
- package/native/appkit/native-controls.h +22 -0
- package/native/appkit/native-controls.mm +431 -0
- package/native/appkit/network-state.h +12 -0
- package/native/appkit/network-state.mm +64 -0
- package/native/appkit/network.h +14 -0
- package/native/appkit/network.mm +396 -0
- package/native/appkit/notifications.h +19 -0
- package/native/appkit/notifications.mm +309 -0
- package/native/appkit/photo-library.h +33 -0
- package/native/appkit/photo-library.mm +548 -0
- package/native/appkit/pointer-buttons.h +32 -0
- package/native/appkit/presentation-label.h +15 -0
- package/native/appkit/presentation-label.mm +12 -0
- package/native/appkit/presented-screen.h +19 -0
- package/native/appkit/presented-screen.mm +181 -0
- package/native/appkit/printing.h +42 -0
- package/native/appkit/printing.mm +393 -0
- package/native/appkit/push.h +19 -0
- package/native/appkit/push.mm +81 -0
- package/native/appkit/red-box.h +26 -0
- package/native/appkit/red-box.mm +387 -0
- package/native/appkit/screen-capture.h +21 -0
- package/native/appkit/screen-capture.mm +92 -0
- package/native/appkit/scroll-view.h +13 -0
- package/native/appkit/scroll-view.mm +251 -0
- package/native/appkit/scrollers.h +25 -0
- package/native/appkit/scrollers.mm +43 -0
- package/native/appkit/search-field.h +34 -0
- package/native/appkit/search-field.mm +291 -0
- package/native/appkit/search-toolbar-item.h +19 -0
- package/native/appkit/search-toolbar-item.mm +269 -0
- package/native/appkit/share-picker.h +34 -0
- package/native/appkit/share-picker.mm +121 -0
- package/native/appkit/split-view.h +77 -0
- package/native/appkit/split-view.mm +1206 -0
- package/native/appkit/store-review.h +13 -0
- package/native/appkit/store-review.mm +28 -0
- package/native/appkit/surface-view.h +45 -0
- package/native/appkit/surface-view.mm +562 -0
- package/native/appkit/svg-view.h +18 -0
- package/native/appkit/svg-view.mm +103 -0
- package/native/appkit/symbol-drawing.h +24 -0
- package/native/appkit/symbol-drawing.mm +117 -0
- package/native/appkit/symbol-view.h +8 -0
- package/native/appkit/symbol-view.mm +33 -0
- package/native/appkit/system-access.h +34 -0
- package/native/appkit/system-access.mm +210 -0
- package/native/appkit/system.h +24 -0
- package/native/appkit/system.mm +403 -0
- package/native/appkit/tab-walk.h +31 -0
- package/native/appkit/tab-walk.mm +64 -0
- package/native/appkit/test-launch.h +36 -0
- package/native/appkit/test-launch.mm +115 -0
- package/native/appkit/text-input-field.h +81 -0
- package/native/appkit/text-input-field.mm +525 -0
- package/native/appkit/text-layout.h +58 -0
- package/native/appkit/text-layout.mm +485 -0
- package/native/appkit/text-recognition.h +13 -0
- package/native/appkit/text-recognition.mm +102 -0
- package/native/appkit/tracking.h +13 -0
- package/native/appkit/tracking.mm +51 -0
- package/native/appkit/tray-and-dock.h +45 -0
- package/native/appkit/tray-and-dock.mm +130 -0
- package/native/appkit/undo.h +23 -0
- package/native/appkit/undo.mm +125 -0
- package/native/appkit/updates.h +17 -0
- package/native/appkit/updates.mm +71 -0
- package/native/appkit/video-view.h +10 -0
- package/native/appkit/video-view.mm +42 -0
- package/native/appkit/video.h +38 -0
- package/native/appkit/video.mm +404 -0
- package/native/appkit/web-browser.h +12 -0
- package/native/appkit/web-browser.mm +97 -0
- package/native/appkit/web-view-component.h +10 -0
- package/native/appkit/web-view-component.mm +62 -0
- package/native/appkit/web-view.h +31 -0
- package/native/appkit/web-view.mm +401 -0
- package/native/cmake/libraries/react-native-reanimated.cmake +45 -0
- package/native/cmake/libraries/react-native-worklets.cmake +46 -0
- package/native/cmake/libraries.cmake +109 -0
- package/native/cmake/linked-modules.cmake +112 -0
- package/native/cmake/react-native.cmake +175 -0
- package/native/cmake/runtime-dependencies.cmake +34 -0
- package/native/cmake/swift.cmake +43 -0
- package/native/cmake/third-party.cmake +74 -0
- package/native/core/include/ngn/absent-views.h +27 -0
- package/native/core/include/ngn/accessibility.h +140 -0
- package/native/core/include/ngn/address-search.h +69 -0
- package/native/core/include/ngn/animation-frames.h +39 -0
- package/native/core/include/ngn/app-info.h +52 -0
- package/native/core/include/ngn/app-menus.h +151 -0
- package/native/core/include/ngn/app-windows.h +181 -0
- package/native/core/include/ngn/apple-authentication.h +116 -0
- package/native/core/include/ngn/asset.h +28 -0
- package/native/core/include/ngn/audio.h +125 -0
- package/native/core/include/ngn/back-swipe.h +121 -0
- package/native/core/include/ngn/battery.h +48 -0
- package/native/core/include/ngn/bytes.h +59 -0
- package/native/core/include/ngn/calendar.h +180 -0
- package/native/core/include/ngn/camera.h +222 -0
- package/native/core/include/ngn/control-sizes.h +111 -0
- package/native/core/include/ngn/core-modules.h +108 -0
- package/native/core/include/ngn/crypto.h +38 -0
- package/native/core/include/ngn/default-menu.h +91 -0
- package/native/core/include/ngn/desktop-expo.h +193 -0
- package/native/core/include/ngn/desktop-modal.h +109 -0
- package/native/core/include/ngn/desktop-props.h +75 -0
- package/native/core/include/ngn/desktop-view-props.h +110 -0
- package/native/core/include/ngn/dev-server.h +33 -0
- package/native/core/include/ngn/dom-web-view.h +53 -0
- package/native/core/include/ngn/download.h +24 -0
- package/native/core/include/ngn/expo-image.h +192 -0
- package/native/core/include/ngn/expo-ui.h +133 -0
- package/native/core/include/ngn/file-system.h +274 -0
- package/native/core/include/ngn/focus-order.h +63 -0
- package/native/core/include/ngn/fonts.h +64 -0
- package/native/core/include/ngn/gestures.h +305 -0
- package/native/core/include/ngn/glass.h +67 -0
- package/native/core/include/ngn/header-bar.h +112 -0
- package/native/core/include/ngn/host-state.h +243 -0
- package/native/core/include/ngn/image-manipulator.h +70 -0
- package/native/core/include/ngn/input-dispatcher.h +211 -0
- package/native/core/include/ngn/input-script.h +56 -0
- package/native/core/include/ngn/input.h +112 -0
- package/native/core/include/ngn/key-value-store.h +41 -0
- package/native/core/include/ngn/language-model.h +69 -0
- package/native/core/include/ngn/launch-frame.h +47 -0
- package/native/core/include/ngn/launch-settings.h +98 -0
- package/native/core/include/ngn/layout-animations.h +24 -0
- package/native/core/include/ngn/library-components.h +13 -0
- package/native/core/include/ngn/library-glue.h +53 -0
- package/native/core/include/ngn/live-regions.h +54 -0
- package/native/core/include/ngn/local-authentication.h +74 -0
- package/native/core/include/ngn/location.h +89 -0
- package/native/core/include/ngn/maps.h +226 -0
- package/native/core/include/ngn/module-registry.h +51 -0
- package/native/core/include/ngn/mounting-backend.h +96 -0
- package/native/core/include/ngn/mounting-manager.h +155 -0
- package/native/core/include/ngn/native-controls.h +161 -0
- package/native/core/include/ngn/native-module.h +109 -0
- package/native/core/include/ngn/network-state.h +44 -0
- package/native/core/include/ngn/network.h +100 -0
- package/native/core/include/ngn/notifications.h +185 -0
- package/native/core/include/ngn/photo-library.h +134 -0
- package/native/core/include/ngn/printing.h +69 -0
- package/native/core/include/ngn/processes.h +114 -0
- package/native/core/include/ngn/red-box.h +119 -0
- package/native/core/include/ngn/reload-thread.h +258 -0
- package/native/core/include/ngn/runtime.h +163 -0
- package/native/core/include/ngn/safe-areas.h +82 -0
- package/native/core/include/ngn/screen-capture.h +35 -0
- package/native/core/include/ngn/screen-presentation.h +85 -0
- package/native/core/include/ngn/screen-stacks.h +80 -0
- package/native/core/include/ngn/scrollers.h +106 -0
- package/native/core/include/ngn/sharing.h +39 -0
- package/native/core/include/ngn/spawn-rules.h +78 -0
- package/native/core/include/ngn/splash-screen.h +41 -0
- package/native/core/include/ngn/split-view.h +270 -0
- package/native/core/include/ngn/sqlite.h +38 -0
- package/native/core/include/ngn/store-review.h +26 -0
- package/native/core/include/ngn/surface-book.h +101 -0
- package/native/core/include/ngn/surface-metrics.h +51 -0
- package/native/core/include/ngn/svg.h +434 -0
- package/native/core/include/ngn/symbol.h +90 -0
- package/native/core/include/ngn/system.h +102 -0
- package/native/core/include/ngn/tabs-host.h +171 -0
- package/native/core/include/ngn/text-input.h +134 -0
- package/native/core/include/ngn/text-measurer.h +38 -0
- package/native/core/include/ngn/text-recognition.h +55 -0
- package/native/core/include/ngn/tracking.h +34 -0
- package/native/core/include/ngn/tray-and-dock.h +107 -0
- package/native/core/include/ngn/undo.h +37 -0
- package/native/core/include/ngn/updates.h +253 -0
- package/native/core/include/ngn/video.h +126 -0
- package/native/core/include/ngn/view-box.h +126 -0
- package/native/core/include/ngn/view-transform.h +26 -0
- package/native/core/include/ngn/view-tree.h +85 -0
- package/native/core/include/ngn/web-browser.h +45 -0
- package/native/core/include/ngn/web-view.h +137 -0
- package/native/core/include/ngn/worklet-host.h +98 -0
- package/native/core/src/absent-views.cpp +41 -0
- package/native/core/src/accessibility.cpp +374 -0
- package/native/core/src/animation-frames.cpp +49 -0
- package/native/core/src/app-menus.cpp +359 -0
- package/native/core/src/app-windows.cpp +444 -0
- package/native/core/src/back-swipe.cpp +98 -0
- package/native/core/src/bytes.cpp +158 -0
- package/native/core/src/control-sizes.cpp +232 -0
- package/native/core/src/default-menu.cpp +96 -0
- package/native/core/src/desktop-modal.cpp +162 -0
- package/native/core/src/desktop-view-props.cpp +80 -0
- package/native/core/src/dev-server-helper.cpp +152 -0
- package/native/core/src/dev-server.cpp +103 -0
- package/native/core/src/dom-web-view.cpp +45 -0
- package/native/core/src/download.cpp +53 -0
- package/native/core/src/expo-image.cpp +548 -0
- package/native/core/src/expo-ui.cpp +203 -0
- package/native/core/src/focus-order.cpp +441 -0
- package/native/core/src/gestures.cpp +1806 -0
- package/native/core/src/glass.cpp +49 -0
- package/native/core/src/header-bar.cpp +104 -0
- package/native/core/src/host-services.cpp +50 -0
- package/native/core/src/host-state.cpp +61 -0
- package/native/core/src/input-dispatcher.cpp +727 -0
- package/native/core/src/input-script.cpp +123 -0
- package/native/core/src/key-value-store.cpp +169 -0
- package/native/core/src/launch-settings.cpp +148 -0
- package/native/core/src/layout-animations.cpp +62 -0
- package/native/core/src/libraries/RNCWebViewSpec.cpp +80 -0
- package/native/core/src/libraries/react-native-reanimated.cpp +216 -0
- package/native/core/src/libraries/react-native-worklets.cpp +192 -0
- package/native/core/src/libraries/rnscreens.cpp +125 -0
- package/native/core/src/libraries/rnsvg.cpp +358 -0
- package/native/core/src/libraries/safeareacontext.cpp +70 -0
- package/native/core/src/libraries/worklets-idle-frames.js +70 -0
- package/native/core/src/library-glue.cpp +35 -0
- package/native/core/src/live-regions.cpp +122 -0
- package/native/core/src/module-registry.cpp +50 -0
- package/native/core/src/modules/accessibility-manager.cpp +98 -0
- package/native/core/src/modules/address-search.cpp +219 -0
- package/native/core/src/modules/alert-manager.cpp +140 -0
- package/native/core/src/modules/app-info.cpp +74 -0
- package/native/core/src/modules/app-modules.cpp +412 -0
- package/native/core/src/modules/apple-authentication.cpp +188 -0
- package/native/core/src/modules/asset.cpp +111 -0
- package/native/core/src/modules/async-storage.cpp +192 -0
- package/native/core/src/modules/audio.cpp +541 -0
- package/native/core/src/modules/battery.cpp +88 -0
- package/native/core/src/modules/calendar.cpp +457 -0
- package/native/core/src/modules/camera.cpp +401 -0
- package/native/core/src/modules/core-modules.cpp +62 -0
- package/native/core/src/modules/crypto.cpp +117 -0
- package/native/core/src/modules/desktop-expo.cpp +527 -0
- package/native/core/src/modules/file-system.cpp +941 -0
- package/native/core/src/modules/fonts.cpp +163 -0
- package/native/core/src/modules/image-loader.cpp +105 -0
- package/native/core/src/modules/image-manipulator.cpp +305 -0
- package/native/core/src/modules/language-model.cpp +195 -0
- package/native/core/src/modules/local-authentication.cpp +140 -0
- package/native/core/src/modules/location.cpp +186 -0
- package/native/core/src/modules/maps.cpp +500 -0
- package/native/core/src/modules/network-state.cpp +72 -0
- package/native/core/src/modules/networking.cpp +387 -0
- package/native/core/src/modules/notifications.cpp +549 -0
- package/native/core/src/modules/photo-library.cpp +385 -0
- package/native/core/src/modules/printing.cpp +201 -0
- package/native/core/src/modules/screen-capture.cpp +71 -0
- package/native/core/src/modules/sharing.cpp +59 -0
- package/native/core/src/modules/splash-screen.cpp +70 -0
- package/native/core/src/modules/sqlite.cpp +421 -0
- package/native/core/src/modules/store-review.cpp +23 -0
- package/native/core/src/modules/text-recognition.cpp +107 -0
- package/native/core/src/modules/tracking.cpp +46 -0
- package/native/core/src/modules/undo.cpp +59 -0
- package/native/core/src/modules/video.cpp +366 -0
- package/native/core/src/modules/web-browser.cpp +100 -0
- package/native/core/src/modules/web-socket.cpp +266 -0
- package/native/core/src/mounting-manager.cpp +384 -0
- package/native/core/src/native-controls.cpp +129 -0
- package/native/core/src/native-module.cpp +250 -0
- package/native/core/src/network.cpp +219 -0
- package/native/core/src/posix-launcher.cpp +366 -0
- package/native/core/src/processes.cpp +324 -0
- package/native/core/src/red-box-errors.js +83 -0
- package/native/core/src/red-box.cpp +306 -0
- package/native/core/src/runtime.cpp +420 -0
- package/native/core/src/safe-areas.cpp +137 -0
- package/native/core/src/screen-presentation.cpp +61 -0
- package/native/core/src/screen-stacks.cpp +254 -0
- package/native/core/src/scrollers.cpp +181 -0
- package/native/core/src/spawn-rules.cpp +292 -0
- package/native/core/src/split-view.cpp +343 -0
- package/native/core/src/svg.cpp +2190 -0
- package/native/core/src/symbol.cpp +94 -0
- package/native/core/src/tabs-host.cpp +234 -0
- package/native/core/src/text-input.cpp +139 -0
- package/native/core/src/text-layout-manager.cpp +63 -0
- package/native/core/src/tray-and-dock.cpp +154 -0
- package/native/core/src/updates.cpp +965 -0
- package/native/core/src/view-box.cpp +788 -0
- package/native/core/src/view-transform.cpp +45 -0
- package/native/core/src/view-tree.cpp +234 -0
- package/native/core/src/web-view.cpp +143 -0
- package/native/core/src/worklet-host.cpp +10 -0
- package/native/scripts/build-hermes.sh +44 -0
- package/native/scripts/build.sh +175 -0
- package/native/scripts/cache-dir.sh +18 -0
- package/native/scripts/codegen-library.sh +193 -0
- package/native/scripts/compiler-launcher.sh +17 -0
- package/native/scripts/fetch.sh +174 -0
- package/native/scripts/hermes-built.sh +10 -0
- package/native/scripts/host-dir.sh +16 -0
- package/native/scripts/launch-probe.sh +60 -0
- package/native/scripts/macos-target.sh +8 -0
- package/native/scripts/make-prebuilt.mjs +360 -0
- package/native/scripts/prebuilt-host-cache.mjs +158 -0
- package/native/shim/openssl/sha.h +22 -0
- package/native/shim/view-platform/react/renderer/components/view/HostPlatformViewTraitsInitializer.h +37 -0
- package/package.json +73 -1
- package/prebuilt.json +33 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
// `<expo-camera>` on a desktop host: expo-camera's view (ViewManagerAdapter_ExpoCamera) as a
|
|
2
|
+
// Fabric component of the desktop's own, and NgNativeCamera, the module @ng-native/expo's Camera
|
|
3
|
+
// calls the view's functions through, by the view's tag, over a CameraHardware the AppKit backend
|
|
4
|
+
// implements with AVFoundation.
|
|
5
|
+
//
|
|
6
|
+
// - getCameraPermissionsAsync(), requestCameraPermissionsAsync(): expo's permission response. Only
|
|
7
|
+
// an undetermined permission is asked, and only when the app's Info.plist explains why; with
|
|
8
|
+
// `noPrompts` (NGN_NO_PROMPTS=1) nothing is.
|
|
9
|
+
// - isAvailableAsync(): whether the Mac has a camera.
|
|
10
|
+
// - takePicture(tag, options): expo's picture, {uri, width, height, format, base64?}, in
|
|
11
|
+
// `<caches>/Camera`, from the view `tag` once its camera runs: a JPEG at `quality`, or with
|
|
12
|
+
// `imageType: 'png'` a PNG (lossless, so `quality` does nothing), as on iOS. Another imageType
|
|
13
|
+
// is refused.
|
|
14
|
+
// - record(tag, options): expo's recording, {uri}, a QuickTime movie in `<caches>/Camera` from the
|
|
15
|
+
// view `tag`, once it stops: stopRecording(tag), `maxDuration` seconds or `maxFileSize` bytes
|
|
16
|
+
// reached, or the view going. It has sound unless the view has `mute`, and only with the
|
|
17
|
+
// microphone allowed (as on iOS, a recording without the microphone permission has none; nothing
|
|
18
|
+
// is asked). The view's `mute` as the recording starts holds until it stops; like iOS, record()
|
|
19
|
+
// takes no `mute` of its own. One recording a view at a time.
|
|
20
|
+
//
|
|
21
|
+
// A view starts its camera when it mounts with the camera allowed and present: it sends
|
|
22
|
+
// `cameraReady`, and `mountError` ({message}, expo-camera's words) when the permission is not
|
|
23
|
+
// granted or the Mac has no camera. It asks for the permission first when it can.
|
|
24
|
+
#pragma once
|
|
25
|
+
|
|
26
|
+
#include "ngn/audio.h"
|
|
27
|
+
#include "ngn/desktop-props.h"
|
|
28
|
+
#include "ngn/native-module.h"
|
|
29
|
+
|
|
30
|
+
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
|
|
31
|
+
#include <react/renderer/components/view/ViewEventEmitter.h>
|
|
32
|
+
#include <react/renderer/components/view/ViewProps.h>
|
|
33
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
34
|
+
|
|
35
|
+
#include <functional>
|
|
36
|
+
#include <map>
|
|
37
|
+
#include <memory>
|
|
38
|
+
#include <mutex>
|
|
39
|
+
#include <optional>
|
|
40
|
+
#include <set>
|
|
41
|
+
#include <string>
|
|
42
|
+
#include <vector>
|
|
43
|
+
|
|
44
|
+
namespace ngn {
|
|
45
|
+
|
|
46
|
+
extern const char CameraComponentName[];
|
|
47
|
+
|
|
48
|
+
class CameraProps final : public facebook::react::ViewProps, public HasDesktopProps {
|
|
49
|
+
public:
|
|
50
|
+
CameraProps() = default;
|
|
51
|
+
CameraProps(
|
|
52
|
+
const facebook::react::PropsParserContext &context,
|
|
53
|
+
const CameraProps &sourceProps,
|
|
54
|
+
const facebook::react::RawProps &rawProps);
|
|
55
|
+
// back or front: on a Mac, the built-in camera either way, or the first one there is.
|
|
56
|
+
std::string facing{"back"};
|
|
57
|
+
bool active{true};
|
|
58
|
+
bool mirror{false};
|
|
59
|
+
// expo-camera's `mute`: the view records without sound.
|
|
60
|
+
bool mute{false};
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
using CameraShadowNode = facebook::react::ConcreteViewShadowNode<CameraComponentName, CameraProps, facebook::react::ViewEventEmitter>;
|
|
64
|
+
using CameraComponentDescriptor = facebook::react::ConcreteComponentDescriptor<CameraShadowNode>;
|
|
65
|
+
|
|
66
|
+
class CameraHardware {
|
|
67
|
+
public:
|
|
68
|
+
enum class Access { NotDetermined, Denied, Restricted, Granted };
|
|
69
|
+
virtual ~CameraHardware() = default;
|
|
70
|
+
virtual Access access() = 0;
|
|
71
|
+
// Shows the OS's prompt and answers once the user decides; answers the access as it is, with no
|
|
72
|
+
// prompt, when the app's Info.plist gives no reason to ask. Any thread.
|
|
73
|
+
virtual void requestAccess(std::function<void(Access)> done) = 0;
|
|
74
|
+
virtual bool hasCamera() = 0;
|
|
75
|
+
// Whether a recording can have sound: the microphone allowed, and one there. Never asks.
|
|
76
|
+
virtual bool microphoneAllowed() = 0;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// What a picture is asked for.
|
|
80
|
+
struct CameraPictureRequest {
|
|
81
|
+
std::string path;
|
|
82
|
+
// 0 to 1, for a JPEG.
|
|
83
|
+
double quality{1};
|
|
84
|
+
// expo-camera's PictureFormat: "jpg" or "png".
|
|
85
|
+
std::string format{"jpg"};
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// What a recording is asked for.
|
|
89
|
+
struct CameraRecordingRequest {
|
|
90
|
+
std::string path;
|
|
91
|
+
// Seconds and bytes; 0 for no limit.
|
|
92
|
+
double maxDuration{0};
|
|
93
|
+
double maxFileSize{0};
|
|
94
|
+
bool sound{true};
|
|
95
|
+
// expo-camera's VideoCodec ("avc1", "hvc1", "jpeg", "apcn", "ap4h"), or empty for the default.
|
|
96
|
+
std::string codec;
|
|
97
|
+
// The session preset the movie is recorded at, AVFoundation's name for it without its prefix
|
|
98
|
+
// (High, Medium, Low, 640x480, iFrame1280x720, iFrame960x540); empty for High.
|
|
99
|
+
std::string preset;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// A view's running camera.
|
|
103
|
+
class CameraCapture {
|
|
104
|
+
public:
|
|
105
|
+
virtual ~CameraCapture() = default;
|
|
106
|
+
// Writes the picture `request` asks for; answers its size, or why not. Any thread.
|
|
107
|
+
virtual void takePicture(const CameraPictureRequest &request, std::function<void(int width, int height, const std::string &error)> done) = 0;
|
|
108
|
+
// Records a movie until stopRecording or a limit; `done` gets why not, or empty once the file
|
|
109
|
+
// is finished. Any thread.
|
|
110
|
+
virtual void startRecording(const CameraRecordingRequest &request, std::function<void(const std::string &error)> done) = 0;
|
|
111
|
+
virtual void stopRecording() = 0;
|
|
112
|
+
virtual bool recording() const = 0;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// The running cameras by view tag, and the views with `mute`, shared by the views and
|
|
116
|
+
// NgNativeCamera. A view sets its `mute` as its props change; detaching forgets both. Any thread.
|
|
117
|
+
class CameraViews {
|
|
118
|
+
public:
|
|
119
|
+
void attach(int tag, std::shared_ptr<CameraCapture> capture);
|
|
120
|
+
void detach(int tag);
|
|
121
|
+
// With `muted`, also whether the view has `mute`, read under the same lock, so a view that
|
|
122
|
+
// detaches meanwhile cannot leave its camera without its mute.
|
|
123
|
+
std::shared_ptr<CameraCapture> find(int tag, bool *muted = nullptr) const;
|
|
124
|
+
void mute(int tag, bool muted);
|
|
125
|
+
bool muted(int tag) const;
|
|
126
|
+
|
|
127
|
+
private:
|
|
128
|
+
mutable std::mutex mutex_;
|
|
129
|
+
std::map<int, std::shared_ptr<CameraCapture>> captures_;
|
|
130
|
+
std::set<int> muted_;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
// A camera the host could start: the Mac's own, and whether it is suspended (a MacBook's with the
|
|
134
|
+
// lid closed, which is listed but gives no frames).
|
|
135
|
+
struct CameraCandidate {
|
|
136
|
+
bool builtIn{false};
|
|
137
|
+
bool suspended{false};
|
|
138
|
+
};
|
|
139
|
+
// The one to start, by index: the built-in camera, else the first other, never a suspended one;
|
|
140
|
+
// -1 when none gives frames.
|
|
141
|
+
int chooseCamera(const std::vector<CameraCandidate> &cameras);
|
|
142
|
+
|
|
143
|
+
// What a view does as it mounts: ask for the permission, start the camera, or report why not.
|
|
144
|
+
// `asked` is a view that has asked once already: a request that left the permission undetermined
|
|
145
|
+
// (an app with no camera usage string, which the OS never prompts for) is not asked again.
|
|
146
|
+
enum class CameraMount { Ask, Start, NotPermitted, NoCamera };
|
|
147
|
+
CameraMount cameraMount(CameraHardware::Access access, bool hasCamera, bool noPrompts, bool asked = false);
|
|
148
|
+
// expo-camera's mountError message for a mount that cannot start, or empty.
|
|
149
|
+
std::string cameraMountError(CameraMount mount);
|
|
150
|
+
|
|
151
|
+
// A picture the host's camera sheet took: its size, and the camera's EXIF (an object, or null).
|
|
152
|
+
struct CameraShot {
|
|
153
|
+
int width{0};
|
|
154
|
+
int height{0};
|
|
155
|
+
folly::dynamic exif{nullptr};
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// A movie the host's camera sheet recorded: its size as it plays, and its length in milliseconds.
|
|
159
|
+
struct CameraClip {
|
|
160
|
+
int width{0};
|
|
161
|
+
int height{0};
|
|
162
|
+
double duration{0};
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// What the sheet is asked for: a photo, a video, or either, with a switch between them.
|
|
166
|
+
struct CameraSheetRequest {
|
|
167
|
+
bool photos{true};
|
|
168
|
+
bool videos{false};
|
|
169
|
+
CameraPictureRequest photo;
|
|
170
|
+
CameraRecordingRequest video;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
// What the sheet took: a photo or a video, or neither when the user cancelled.
|
|
174
|
+
struct CameraTake {
|
|
175
|
+
std::optional<CameraShot> photo;
|
|
176
|
+
std::optional<CameraClip> video;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
// The host's own camera for expo-image-picker's launchCameraAsync: macOS has no system camera
|
|
180
|
+
// screen like iOS's UIImagePickerController, so the host shows the camera's preview and a shutter
|
|
181
|
+
// itself.
|
|
182
|
+
class CameraSheet {
|
|
183
|
+
public:
|
|
184
|
+
virtual ~CameraSheet() = default;
|
|
185
|
+
// Shows the camera; once the user takes a photo or records a video, writes it as `request` asks
|
|
186
|
+
// and answers it. Answers neither and no error when they cancel or there is no window to show it
|
|
187
|
+
// on, and an error when the camera fails. Only with the camera allowed and present. Any thread.
|
|
188
|
+
virtual void shoot(const CameraSheetRequest &request, std::function<void(CameraTake, const std::string &error)> done) = 0;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
// What NgNativeImagePicker's camera half needs: the permission and the device, the microphone a
|
|
192
|
+
// video's sound comes from, the sheet, and the folder its photos and videos go in
|
|
193
|
+
// (`<caches>/ImagePicker`, as on iOS).
|
|
194
|
+
struct PickerCamera {
|
|
195
|
+
std::shared_ptr<CameraHardware> hardware;
|
|
196
|
+
std::shared_ptr<AudioInput> microphone;
|
|
197
|
+
std::shared_ptr<CameraSheet> sheet;
|
|
198
|
+
std::string folder;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
// expo's camera permission response, asked as NgNativeCamera asks it: only when undetermined, and
|
|
202
|
+
// never with `noPrompts`.
|
|
203
|
+
folly::dynamic cameraPermissionOf(CameraHardware::Access access);
|
|
204
|
+
void requestCameraPermission(CameraHardware &hardware, bool noPrompts, JsPromise promise);
|
|
205
|
+
|
|
206
|
+
// expo-image-picker's launchCameraAsync(options) over `camera`, shaped as iOS shapes a camera
|
|
207
|
+
// shot (no assetId and no fileName):
|
|
208
|
+
// - a photo, a JPEG at `quality` (1 by default), with base64 and exif only when asked;
|
|
209
|
+
// - with `mediaTypes` asking for videos, a QuickTime movie (`video/quicktime`) recorded at
|
|
210
|
+
// `videoQuality` (UIImagePickerControllerQualityType, High by default) for at most
|
|
211
|
+
// `videoMaxDuration` seconds (0, the default, for no limit), with its duration in milliseconds.
|
|
212
|
+
// Videos alone show a record button; videos and photos, a switch between the two.
|
|
213
|
+
// Rejected without the camera permission, as iOS does, or on a Mac with no camera. A request for
|
|
214
|
+
// videos asks for the microphone when it is undetermined; refused, the video has no sound, as iOS's
|
|
215
|
+
// camera records it. Only an app that cannot ask (no NSMicrophoneUsageDescription) is rejected,
|
|
216
|
+
// with iOS's message. Canceled with `noPrompts`, which shows no sheet.
|
|
217
|
+
void launchPickerCamera(const PickerCamera &camera, bool noPrompts, const folly::dynamic &options, JsPromise promise);
|
|
218
|
+
|
|
219
|
+
std::shared_ptr<NativeModule> makeCameraModule(
|
|
220
|
+
std::shared_ptr<CameraHardware> hardware, std::shared_ptr<CameraViews> views, std::string pictures, bool noPrompts);
|
|
221
|
+
|
|
222
|
+
} // namespace ngn
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// The native controls' intrinsic sizes, measured on the UI thread and read by layout.
|
|
2
|
+
//
|
|
3
|
+
// A toolkit's controls (AppKit's cells) are UI-thread only, and layout runs on the JS thread, which
|
|
4
|
+
// never waits on the UI thread. So layout reads a cache, keyed by the inputs a control's size
|
|
5
|
+
// depends on (controlSizeKey), and never measures off the UI thread:
|
|
6
|
+
//
|
|
7
|
+
// - A hit is the size.
|
|
8
|
+
// - A miss on the UI thread is measured there at once.
|
|
9
|
+
// - A miss anywhere else lays the control out at the size it last had (nothing, for a new one),
|
|
10
|
+
// queues it and posts a settle to the UI thread. The settle measures what is queued, fills the
|
|
11
|
+
// cache and asks each queued control for a layout again with a state update, which lays it out
|
|
12
|
+
// with the size. Until the mount that carries that state, the controls are not settled, and the
|
|
13
|
+
// app window is held as it is for its safe areas: its first frame draws the controls at their
|
|
14
|
+
// size. A control added to a window already on screen draws at its last size, or not at all,
|
|
15
|
+
// for one frame.
|
|
16
|
+
//
|
|
17
|
+
// Every size belongs to the controls laid out with its inputs: one whose inputs change lets go of
|
|
18
|
+
// the old size, a deleted one lets go of its own, and a size no control holds is dropped.
|
|
19
|
+
#pragma once
|
|
20
|
+
|
|
21
|
+
#include "ngn/native-controls.h"
|
|
22
|
+
|
|
23
|
+
#include <react/renderer/core/State.h>
|
|
24
|
+
|
|
25
|
+
#include <functional>
|
|
26
|
+
#include <map>
|
|
27
|
+
#include <memory>
|
|
28
|
+
#include <mutex>
|
|
29
|
+
#include <set>
|
|
30
|
+
#include <string>
|
|
31
|
+
#include <unordered_map>
|
|
32
|
+
|
|
33
|
+
namespace ngn {
|
|
34
|
+
|
|
35
|
+
using facebook::react::Tag;
|
|
36
|
+
|
|
37
|
+
// The inputs a control's size depends on, as one string: its kind and what it draws (title,
|
|
38
|
+
// symbol, segments, date, font and so on). Props that do not change its size (enabled, value,
|
|
39
|
+
// colours) are not in it.
|
|
40
|
+
std::string controlSizeKey(ControlKind kind, const NativeControlProps &props);
|
|
41
|
+
|
|
42
|
+
// Made with std::make_shared: a posted settle holds it weakly.
|
|
43
|
+
class ControlSizes : public std::enable_shared_from_this<ControlSizes> {
|
|
44
|
+
public:
|
|
45
|
+
// Asks the control `tag`, whose state is `state`, for a layout again. The default updates its
|
|
46
|
+
// state.
|
|
47
|
+
using Relayout = std::function<void(Tag tag, const facebook::react::State &state)>;
|
|
48
|
+
|
|
49
|
+
// `runOnUiThread` runs a task on the UI thread later, and `onUiThread` says whether the caller is
|
|
50
|
+
// on it.
|
|
51
|
+
ControlSizes(
|
|
52
|
+
std::shared_ptr<const ControlMeasurer> measurer,
|
|
53
|
+
std::function<void(std::function<void()>)> runOnUiThread,
|
|
54
|
+
std::function<bool()> onUiThread,
|
|
55
|
+
Relayout relayout = nullptr);
|
|
56
|
+
|
|
57
|
+
// Layout, any thread: the size of the control `tag` with `props`. `state` is the node's.
|
|
58
|
+
facebook::react::Size layoutSize(
|
|
59
|
+
Tag tag,
|
|
60
|
+
ControlKind kind,
|
|
61
|
+
std::shared_ptr<const NativeControlProps> props,
|
|
62
|
+
const facebook::react::State::Shared &state);
|
|
63
|
+
|
|
64
|
+
// UI thread: measures every control layout queued, and asks each for a layout again.
|
|
65
|
+
void settle();
|
|
66
|
+
// UI thread: a mount gave `tag` a new state, the one a settle asked for or a later one.
|
|
67
|
+
void relaidOut(Tag tag);
|
|
68
|
+
// UI thread: the control `tag` was deleted.
|
|
69
|
+
void forget(Tag tag);
|
|
70
|
+
|
|
71
|
+
// Whether no control waits for a measurement or for the layout after one.
|
|
72
|
+
bool settled() const;
|
|
73
|
+
// How many sizes are held, for the tests.
|
|
74
|
+
size_t held() const;
|
|
75
|
+
|
|
76
|
+
private:
|
|
77
|
+
struct Control {
|
|
78
|
+
std::string key;
|
|
79
|
+
facebook::react::Size size{};
|
|
80
|
+
};
|
|
81
|
+
struct Queued {
|
|
82
|
+
ControlKind kind;
|
|
83
|
+
std::shared_ptr<const NativeControlProps> props;
|
|
84
|
+
facebook::react::State::Shared state;
|
|
85
|
+
};
|
|
86
|
+
// With mutex_ held.
|
|
87
|
+
void hold(Tag tag, const std::string &key);
|
|
88
|
+
void release(const std::string &key);
|
|
89
|
+
|
|
90
|
+
std::shared_ptr<const ControlMeasurer> measurer_;
|
|
91
|
+
std::function<void(std::function<void()>)> runOnUiThread_;
|
|
92
|
+
std::function<bool()> onUiThread_;
|
|
93
|
+
Relayout relayout_;
|
|
94
|
+
|
|
95
|
+
mutable std::mutex mutex_;
|
|
96
|
+
std::unordered_map<std::string, facebook::react::Size> sizes_;
|
|
97
|
+
// How many controls hold each key.
|
|
98
|
+
std::unordered_map<std::string, int> holders_;
|
|
99
|
+
std::unordered_map<Tag, Control> controls_;
|
|
100
|
+
std::map<Tag, Queued> queued_;
|
|
101
|
+
std::set<Tag> awaiting_;
|
|
102
|
+
bool posted_{false};
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
inline constexpr const char *kControlSizesKey = "ngn.ControlSizes";
|
|
106
|
+
|
|
107
|
+
inline void installControlSizes(facebook::react::ContextContainer &context, std::shared_ptr<ControlSizes> sizes) {
|
|
108
|
+
context.insert(kControlSizesKey, std::move(sizes));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
} // namespace ngn
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// React Native's iOS-shaped modules, implemented once in the core for every desktop backend.
|
|
2
|
+
// macOS runs React Native's iOS JavaScript, so each module answers under its iOS name with the
|
|
3
|
+
// iOS shapes. Each is a NativeModule: plain C++ over the System and HostState interfaces.
|
|
4
|
+
#pragma once
|
|
5
|
+
|
|
6
|
+
#include "ngn/bytes.h"
|
|
7
|
+
#include "ngn/file-system.h"
|
|
8
|
+
#include "ngn/host-state.h"
|
|
9
|
+
#include "ngn/key-value-store.h"
|
|
10
|
+
#include "ngn/module-registry.h"
|
|
11
|
+
#include "ngn/native-module.h"
|
|
12
|
+
#include "ngn/network.h"
|
|
13
|
+
#include "ngn/system.h"
|
|
14
|
+
|
|
15
|
+
#include <functional>
|
|
16
|
+
#include <memory>
|
|
17
|
+
#include <string>
|
|
18
|
+
|
|
19
|
+
namespace ngn {
|
|
20
|
+
|
|
21
|
+
class Gestures;
|
|
22
|
+
|
|
23
|
+
struct CoreModuleServices {
|
|
24
|
+
std::shared_ptr<System> system;
|
|
25
|
+
std::shared_ptr<HostState> state;
|
|
26
|
+
std::shared_ptr<Http> http;
|
|
27
|
+
std::shared_ptr<WebSockets> webSockets;
|
|
28
|
+
// Made by addCoreModules when not given: one for every runtime, shared by its modules.
|
|
29
|
+
std::shared_ptr<BlobStore> blobs;
|
|
30
|
+
// What a request's file url, a body's `{uri}` and Image.getSize's file source may read
|
|
31
|
+
// (FileAccess::readFor); without it, no file is read.
|
|
32
|
+
std::shared_ptr<FileAccess> files;
|
|
33
|
+
// AsyncStorage's files. Made by addCoreModules when not given, in the app's data directory.
|
|
34
|
+
std::shared_ptr<KeyValueStore> storage;
|
|
35
|
+
// "0.88.0", the React Native the host was built from, which its JavaScript checks.
|
|
36
|
+
std::string reactNativeVersion;
|
|
37
|
+
// The bundle the runtime runs now: a path, or a dev server's URL. SourceCode is registered only
|
|
38
|
+
// with it.
|
|
39
|
+
std::function<std::string()> bundle;
|
|
40
|
+
// Moves the screen reader to the view with this tag (AccessibilityInfo.setAccessibilityFocus).
|
|
41
|
+
// Any thread; nothing when absent.
|
|
42
|
+
std::function<void(int tag)> focusAccessibility;
|
|
43
|
+
// A test launch's fake system UI: an alert is never shown and answers at once with its cancel
|
|
44
|
+
// button, or not at all when it has none, as a person must pick one of its buttons.
|
|
45
|
+
bool fakeSystemUI{false};
|
|
46
|
+
// The gesture handler's recognisers (gestures.h), which RNGestureHandlerModule drives, and the
|
|
47
|
+
// UI thread they live on. Without them the module recognises nothing.
|
|
48
|
+
std::shared_ptr<Gestures> gestures;
|
|
49
|
+
std::function<void(std::function<void()>)> runOnUiThread;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// Registers every core module.
|
|
53
|
+
void addCoreModules(ModuleRegistry ®istry, const CoreModuleServices &services);
|
|
54
|
+
|
|
55
|
+
// The modules one at a time, for tests.
|
|
56
|
+
std::shared_ptr<NativeModule> makePlatformConstants(const CoreModuleServices &services);
|
|
57
|
+
std::shared_ptr<NativeModule> makeDeviceInfo(const CoreModuleServices &services);
|
|
58
|
+
std::shared_ptr<NativeModule> makeAppState(const CoreModuleServices &services);
|
|
59
|
+
std::shared_ptr<NativeModule> makeAppearance(const CoreModuleServices &services);
|
|
60
|
+
// AccessibilityInfo's iOS module: the settings in the host state and their change events.
|
|
61
|
+
std::shared_ptr<NativeModule> makeAccessibilityManager(const CoreModuleServices &services);
|
|
62
|
+
std::shared_ptr<NativeModule> makeLinking(const CoreModuleServices &services);
|
|
63
|
+
std::shared_ptr<NativeModule> makeI18n(const CoreModuleServices &services);
|
|
64
|
+
// What I18nManager's isRTL answers, and the direction each surface lays out from: the system's,
|
|
65
|
+
// unless the app turned right to left off (allowRTL) or forced it on (forceRTL).
|
|
66
|
+
bool appRightToLeft(System &system);
|
|
67
|
+
std::shared_ptr<NativeModule> makeAlertManager(const CoreModuleServices &services);
|
|
68
|
+
std::shared_ptr<NativeModule> makeClipboard(const CoreModuleServices &services);
|
|
69
|
+
std::shared_ptr<NativeModule> makeSettingsManager(const CoreModuleServices &services);
|
|
70
|
+
std::shared_ptr<NativeModule> makeStatusBarManager(const CoreModuleServices &services);
|
|
71
|
+
std::shared_ptr<NativeModule> makeVibration(const CoreModuleServices &services);
|
|
72
|
+
std::shared_ptr<NativeModule> makeKeyboardObserver(const CoreModuleServices &services);
|
|
73
|
+
std::shared_ptr<NativeModule> makeScreensModule(const CoreModuleServices &services);
|
|
74
|
+
// react-native-gesture-handler's module, which its JavaScript requires as it loads. The host has
|
|
75
|
+
// no recognisers: every method is there and does nothing, so a gesture attached to a view never
|
|
76
|
+
// fires and the app draws as it does without one.
|
|
77
|
+
std::shared_ptr<NativeModule> makeGestureHandlerModule(const CoreModuleServices &services);
|
|
78
|
+
std::shared_ptr<NativeModule> makeNetworking(const CoreModuleServices &services);
|
|
79
|
+
std::shared_ptr<NativeModule> makeImageLoader(const CoreModuleServices &services);
|
|
80
|
+
std::shared_ptr<NativeModule> makeWebSocket(const CoreModuleServices &services);
|
|
81
|
+
std::shared_ptr<NativeModule> makeBlobModule(const CoreModuleServices &services);
|
|
82
|
+
std::shared_ptr<NativeModule> makeFileReader(const CoreModuleServices &services);
|
|
83
|
+
// @react-native-async-storage: RNCAsyncStorage for 2.x, RNAsyncStorage for 3.x, over one store.
|
|
84
|
+
std::shared_ptr<NativeModule> makeLegacyAsyncStorage(const CoreModuleServices &services);
|
|
85
|
+
std::shared_ptr<NativeModule> makeAsyncStorage(const CoreModuleServices &services);
|
|
86
|
+
// SourceCode's scriptURL, which React Native's asset resolver finds a bundle's assets beside, as
|
|
87
|
+
// iOS's RCTSourceCode gives it. React Native's own answers nothing for a bundle on disk.
|
|
88
|
+
std::shared_ptr<NativeModule> makeSourceCode(const CoreModuleServices &services);
|
|
89
|
+
|
|
90
|
+
// The body of a request JavaScript sent (Networking.sendRequest's `data`), and the content type
|
|
91
|
+
// it implies when the request has none. A file (`{uri}`, or a form part's) is read only where
|
|
92
|
+
// `files` lets it, and the request fails otherwise.
|
|
93
|
+
struct RequestBody {
|
|
94
|
+
std::string bytes;
|
|
95
|
+
std::string contentType;
|
|
96
|
+
std::string error;
|
|
97
|
+
};
|
|
98
|
+
RequestBody requestBody(const folly::dynamic &data, const BlobStore &blobs, const std::string &boundary, const FileAccess *files);
|
|
99
|
+
|
|
100
|
+
// The alert JavaScript asked for (AlertManager.alertWithArgs) as the backend shows it, and the
|
|
101
|
+
// button keys in the request's order, so a pressed index maps back to the key JavaScript gave.
|
|
102
|
+
struct PreparedAlert {
|
|
103
|
+
AlertRequest request;
|
|
104
|
+
std::vector<std::string> keys;
|
|
105
|
+
};
|
|
106
|
+
PreparedAlert prepareAlert(const folly::dynamic &args);
|
|
107
|
+
|
|
108
|
+
} // namespace ngn
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// NgNativeCrypto: what @ng-native/expo's Crypto calls on expo-crypto, over a CryptoSource, which the
|
|
2
|
+
// AppKit backend implements with CommonCrypto and the system's secure random source.
|
|
3
|
+
//
|
|
4
|
+
// - randomUUID(): a version 4 UUID, lowercase, as expo-crypto's.
|
|
5
|
+
// - getRandomBytes(count): {base64} of `count` secure random bytes, 0 to 1024 of them.
|
|
6
|
+
// - digestStringAsync(algorithm, text, {encoding}): the hash of the text's UTF-8, as hex
|
|
7
|
+
// (the default) or base64.
|
|
8
|
+
// - digestAsync(algorithm, {base64}): the hash of the bytes, as {base64}.
|
|
9
|
+
// The algorithms are expo-crypto's names: SHA-1, SHA-256, SHA-384, SHA-512, MD2, MD4 and MD5. A
|
|
10
|
+
// sync call that cannot answer throws; an async one rejects. Bytes cross as {base64}; the JS
|
|
11
|
+
// adapter (desktop-crypto.ts) turns them into the Uint8Array and ArrayBuffer expo-crypto answers.
|
|
12
|
+
#pragma once
|
|
13
|
+
|
|
14
|
+
#include "ngn/native-module.h"
|
|
15
|
+
|
|
16
|
+
#include <memory>
|
|
17
|
+
#include <optional>
|
|
18
|
+
#include <string>
|
|
19
|
+
|
|
20
|
+
namespace ngn {
|
|
21
|
+
|
|
22
|
+
class CryptoSource {
|
|
23
|
+
public:
|
|
24
|
+
virtual ~CryptoSource() = default;
|
|
25
|
+
// The raw digest of `bytes` by `algorithm` (expo-crypto's name), or nothing for a name it does
|
|
26
|
+
// not know.
|
|
27
|
+
virtual std::optional<std::string> digest(const std::string &algorithm, const std::string &bytes) = 0;
|
|
28
|
+
// `count` bytes from the OS's secure random source. Throws std::runtime_error when it fails.
|
|
29
|
+
virtual std::string randomBytes(size_t count) = 0;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// Sixteen random bytes as a version 4 UUID: the version and variant bits set, lowercase hex.
|
|
33
|
+
std::string uuidV4(std::string bytes);
|
|
34
|
+
std::string hexOf(const std::string &bytes);
|
|
35
|
+
|
|
36
|
+
std::shared_ptr<NativeModule> makeCryptoModule(std::shared_ptr<CryptoSource> source);
|
|
37
|
+
|
|
38
|
+
} // namespace ngn
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// The menu bar every desktop app gets at launch, before any JavaScript runs: the app menu with
|
|
2
|
+
// Quit, File's Close Window and Print... (which prints the key window), the standard text editing commands, View's Back, Forward and Show Sidebar, the window commands and, for
|
|
3
|
+
// a bundle from a dev server, the developer commands. A backend draws it and maps each command to
|
|
4
|
+
// the toolkit's own. The app's own bar replaces it once the app sets one (app-menus.h).
|
|
5
|
+
#pragma once
|
|
6
|
+
|
|
7
|
+
#include <string>
|
|
8
|
+
#include <vector>
|
|
9
|
+
|
|
10
|
+
namespace ngn {
|
|
11
|
+
|
|
12
|
+
enum class MenuCommand {
|
|
13
|
+
None,
|
|
14
|
+
About,
|
|
15
|
+
Hide,
|
|
16
|
+
HideOthers,
|
|
17
|
+
ShowAll,
|
|
18
|
+
Quit,
|
|
19
|
+
CloseWindow,
|
|
20
|
+
Undo,
|
|
21
|
+
Redo,
|
|
22
|
+
Cut,
|
|
23
|
+
Copy,
|
|
24
|
+
Paste,
|
|
25
|
+
PasteAndMatchStyle,
|
|
26
|
+
Delete,
|
|
27
|
+
SelectAll,
|
|
28
|
+
ToggleFullScreen,
|
|
29
|
+
Minimize,
|
|
30
|
+
Zoom,
|
|
31
|
+
BringAllToFront,
|
|
32
|
+
Reload,
|
|
33
|
+
// React Native DevTools, through the dev server's inspector proxy (Developer menu).
|
|
34
|
+
OpenDevTools,
|
|
35
|
+
Find,
|
|
36
|
+
ToggleSidebar,
|
|
37
|
+
Print,
|
|
38
|
+
// Back and forward through the window's history: the app hears them as `navigate`.
|
|
39
|
+
Back,
|
|
40
|
+
Forward,
|
|
41
|
+
// An app's own item: the app hears it as `menuSelect` with the item's id.
|
|
42
|
+
AppItem,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// The key equivalent's modifiers, as a bitmask. Command is the platform's primary modifier
|
|
46
|
+
// (Control off macOS).
|
|
47
|
+
enum MenuModifier : unsigned {
|
|
48
|
+
Command = 1 << 0,
|
|
49
|
+
Shift = 1 << 1,
|
|
50
|
+
Option = 1 << 2,
|
|
51
|
+
Control = 1 << 3,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// What the toolkit's own menus add to a menu: AppKit fills the Services and Window menus.
|
|
55
|
+
enum class MenuRole { None, App, Services, Window, Help };
|
|
56
|
+
|
|
57
|
+
struct MenuItem {
|
|
58
|
+
std::string title;
|
|
59
|
+
MenuCommand command{MenuCommand::None};
|
|
60
|
+
// A key equivalent: a character such as "q", a key named as the web names it ("ArrowLeft",
|
|
61
|
+
// "Enter", "F5"), or empty for none.
|
|
62
|
+
std::string key;
|
|
63
|
+
unsigned modifiers{0};
|
|
64
|
+
bool separator{false};
|
|
65
|
+
MenuRole role{MenuRole::None};
|
|
66
|
+
std::vector<MenuItem> items;
|
|
67
|
+
// An app's item: the id the app knows it by, and how it is drawn.
|
|
68
|
+
std::string id;
|
|
69
|
+
bool disabled{false};
|
|
70
|
+
bool checked{false};
|
|
71
|
+
bool destructive{false};
|
|
72
|
+
std::string subtitle;
|
|
73
|
+
std::string sfSymbol;
|
|
74
|
+
// Its items are drawn in place, between separators, rather than as a submenu.
|
|
75
|
+
bool inlineItems{false};
|
|
76
|
+
|
|
77
|
+
bool operator==(const MenuItem &) const = default;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
struct DefaultMenuOptions {
|
|
81
|
+
std::string appName;
|
|
82
|
+
// Adds the Developer menu (Reload) for a bundle from a dev server.
|
|
83
|
+
bool developer{false};
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
std::vector<MenuItem> defaultMenuBar(const DefaultMenuOptions &options);
|
|
87
|
+
|
|
88
|
+
// The item with this command anywhere in `menus`, or null.
|
|
89
|
+
const MenuItem *findMenuItem(const std::vector<MenuItem> &menus, MenuCommand command);
|
|
90
|
+
|
|
91
|
+
} // namespace ngn
|