@ng-native/desktop 0.26.1 → 0.27.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/README.md +6 -3
- package/bin/app-config.mjs +1 -0
- package/bin/archive.mjs +166 -0
- package/bin/autolink.mjs +61 -30
- package/bin/cli.mjs +127 -27
- package/bin/host.mjs +255 -58
- package/bin/package-linux.mjs +1394 -0
- package/bin/package.mjs +171 -35
- package/bin/plist.mjs +6 -2
- package/bin/png-icon.mjs +315 -0
- package/bin/prebuilt.mjs +147 -26
- package/bin/toolchain.mjs +258 -19
- package/native/CMakeLists.txt +64 -6
- package/native/appkit/CMakeLists.txt +2 -1
- package/native/appkit/appkit-backend.h +1 -0
- package/native/appkit/appkit-backend.mm +13 -0
- package/native/appkit/header-toolbar.mm +28 -25
- package/native/appkit/host-view.h +10 -0
- package/native/appkit/host-view.mm +146 -40
- package/native/appkit/input-replay.h +6 -0
- package/native/appkit/input-replay.mm +21 -12
- package/native/appkit/main.mm +11 -7
- package/native/appkit/native-controls.mm +13 -1
- package/native/appkit/split-view.mm +7 -13
- package/native/appkit/text-input-field.h +4 -0
- package/native/appkit/text-input-field.mm +20 -1
- package/native/cmake/curl.cmake +79 -0
- package/native/cmake/libraries/react-native-reanimated.cmake +5 -0
- package/native/cmake/libraries/react-native-worklets.cmake +5 -0
- package/native/cmake/linked-modules.cmake +20 -4
- package/native/cmake/react-native.cmake +18 -1
- package/native/core/include/ngn/accent-colors.h +38 -0
- package/native/core/include/ngn/accessibility-relations.h +65 -0
- package/native/core/include/ngn/accessibility.h +26 -0
- package/native/core/include/ngn/animated-frame-loop.h +56 -0
- package/native/core/include/ngn/app-info.h +24 -8
- package/native/core/include/ngn/app-menus.h +14 -1
- package/native/core/include/ngn/app-windows.h +15 -2
- package/native/core/include/ngn/aria-role.h +96 -0
- package/native/core/include/ngn/audio.h +2 -0
- package/native/core/include/ngn/camera.h +9 -0
- package/native/core/include/ngn/control-sizes.h +7 -2
- package/native/core/include/ngn/crash-report.h +31 -0
- package/native/core/include/ngn/curl-network.h +93 -0
- package/native/core/include/ngn/dbus-menu.h +39 -0
- package/native/core/include/ngn/default-menu.h +36 -0
- package/native/core/include/ngn/desktop-expo.h +7 -1
- package/native/core/include/ngn/desktop-modules.h +22 -0
- package/native/core/include/ngn/desktop-props.h +21 -1
- package/native/core/include/ngn/desktop-view-props.h +6 -0
- package/native/core/include/ngn/focus-order.h +10 -0
- package/native/core/include/ngn/header-bar.h +22 -0
- package/native/core/include/ngn/host-os.h +6 -0
- package/native/core/include/ngn/host-reload.h +21 -0
- package/native/core/include/ngn/host-state.h +23 -0
- package/native/core/include/ngn/image-source.h +26 -1
- package/native/core/include/ngn/input-script.h +3 -3
- package/native/core/include/ngn/input.h +4 -1
- package/native/core/include/ngn/launch-frame.h +21 -0
- package/native/core/include/ngn/launch-settings.h +23 -5
- package/native/core/include/ngn/mounting-backend.h +5 -0
- package/native/core/include/ngn/mounting-manager.h +1 -0
- package/native/core/include/ngn/native-controls.h +26 -5
- package/native/core/include/ngn/notification-schedule.h +74 -0
- package/native/core/include/ngn/notifications.h +2 -1
- package/native/core/include/ngn/openssl-update-crypto.h +15 -0
- package/native/core/include/ngn/photo-library.h +60 -20
- package/native/core/include/ngn/posix-locale.h +43 -0
- package/native/core/include/ngn/runtime.h +5 -0
- package/native/core/include/ngn/safe-areas.h +14 -2
- package/native/core/include/ngn/split-view.h +78 -0
- package/native/core/include/ngn/surface-metrics.h +7 -0
- package/native/core/include/ngn/system.h +14 -0
- package/native/core/include/ngn/text-input.h +13 -0
- package/native/core/include/ngn/text-units.h +38 -0
- package/native/core/include/ngn/updates.h +14 -2
- package/native/core/include/ngn/view-box.h +40 -0
- package/native/core/include/ngn/view-transform.h +15 -0
- package/native/core/include/ngn/web-browser.h +46 -0
- package/native/core/src/accent-colors.cpp +88 -0
- package/native/core/src/accessibility-relations.cpp +138 -0
- package/native/core/src/accessibility.cpp +50 -0
- package/native/core/src/animated-frame-loop.cpp +166 -0
- package/native/core/src/app-menus.cpp +26 -9
- package/native/core/src/app-windows.cpp +27 -6
- package/native/core/src/aria-role.cpp +127 -0
- package/native/core/src/control-sizes.cpp +9 -5
- package/native/core/src/crash-report.cpp +196 -0
- package/native/core/src/curl-network.cpp +1562 -0
- package/native/core/src/dbus-menu.cpp +71 -0
- package/native/core/src/default-menu.cpp +134 -0
- package/native/core/src/desktop-view-props.cpp +14 -0
- package/native/core/src/focus-order.cpp +19 -0
- package/native/core/src/header-bar.cpp +20 -0
- package/native/core/src/host-os.cpp +19 -0
- package/native/core/src/host-reload.cpp +45 -0
- package/native/core/src/host-state.cpp +8 -0
- package/native/core/src/image-source.cpp +90 -0
- package/native/core/src/input-dispatcher.cpp +27 -5
- package/native/core/src/input-script.cpp +3 -2
- package/native/core/src/launch-settings.cpp +76 -0
- package/native/core/src/libraries/react-native-reanimated.cpp +6 -1
- package/native/core/src/modules/app-info.cpp +55 -6
- package/native/core/src/modules/app-modules.cpp +1 -1
- package/native/core/src/modules/audio.cpp +4 -2
- package/native/core/src/modules/camera.cpp +8 -11
- package/native/core/src/modules/desktop-expo.cpp +10 -5
- package/native/core/src/modules/desktop-modules.cpp +106 -41
- package/native/core/src/modules/file-photo-picker.cpp +408 -0
- package/native/core/src/modules/notifications.cpp +13 -17
- package/native/core/src/modules/photo-library.cpp +42 -13
- package/native/core/src/modules/web-browser.cpp +89 -0
- package/native/core/src/mounting-manager.cpp +12 -0
- package/native/core/src/native-controls.cpp +42 -1
- package/native/core/src/notification-schedule.cpp +429 -0
- package/native/core/src/openssl-update-crypto.cpp +83 -0
- package/native/core/src/posix-locale.cpp +192 -0
- package/native/core/src/runtime.cpp +30 -1
- package/native/core/src/safe-areas.cpp +19 -4
- package/native/core/src/spawn-rules.cpp +4 -1
- package/native/core/src/split-view.cpp +93 -0
- package/native/core/src/system.cpp +19 -0
- package/native/core/src/text-input.cpp +18 -1
- package/native/core/src/text-units.cpp +99 -0
- package/native/core/src/updates.cpp +76 -17
- package/native/core/src/view-box.cpp +75 -40
- package/native/core/src/view-transform.cpp +28 -0
- package/native/docker/Dockerfile +38 -0
- package/native/docker/Dockerfile.fedora +36 -0
- package/native/docker/glibc-floor.sh +49 -0
- package/native/gtk/CMakeLists.txt +137 -0
- package/native/gtk/accent-colour.cpp +57 -0
- package/native/gtk/accent-colour.h +41 -0
- package/native/gtk/accessibility-settings.cpp +159 -0
- package/native/gtk/accessibility-settings.h +62 -0
- package/native/gtk/accessible-text.cpp +151 -0
- package/native/gtk/accessible-text.h +49 -0
- package/native/gtk/accessible.cpp +306 -0
- package/native/gtk/accessible.h +75 -0
- package/native/gtk/alerts.cpp +267 -0
- package/native/gtk/alerts.h +30 -0
- package/native/gtk/animation-frames.cpp +159 -0
- package/native/gtk/animation-frames.h +20 -0
- package/native/gtk/app-info.cpp +91 -0
- package/native/gtk/app-info.h +25 -0
- package/native/gtk/app-windows.cpp +439 -0
- package/native/gtk/app-windows.h +150 -0
- package/native/gtk/audio.cpp +370 -0
- package/native/gtk/audio.h +54 -0
- package/native/gtk/auth-session.cpp +73 -0
- package/native/gtk/auth-session.h +16 -0
- package/native/gtk/battery.cpp +110 -0
- package/native/gtk/battery.h +19 -0
- package/native/gtk/box-paint.cpp +262 -0
- package/native/gtk/box-paint.h +32 -0
- package/native/gtk/cairo-canvas.cpp +755 -0
- package/native/gtk/cairo-canvas.h +49 -0
- package/native/gtk/camera.cpp +909 -0
- package/native/gtk/camera.h +69 -0
- package/native/gtk/capture.cpp +46 -0
- package/native/gtk/capture.h +19 -0
- package/native/gtk/clock-format.cpp +151 -0
- package/native/gtk/clock-format.h +36 -0
- package/native/gtk/crypto.cpp +75 -0
- package/native/gtk/crypto.h +14 -0
- package/native/gtk/dbus-properties.cpp +131 -0
- package/native/gtk/dbus-properties.h +61 -0
- package/native/gtk/drag-and-drop.cpp +339 -0
- package/native/gtk/drag-and-drop.h +30 -0
- package/native/gtk/file-dialogs.cpp +239 -0
- package/native/gtk/file-dialogs.h +21 -0
- package/native/gtk/file-system.cpp +212 -0
- package/native/gtk/file-system.h +25 -0
- package/native/gtk/focus.cpp +282 -0
- package/native/gtk/focus.h +37 -0
- package/native/gtk/fonts.cpp +89 -0
- package/native/gtk/fonts.h +22 -0
- package/native/gtk/gst-frames.cpp +150 -0
- package/native/gtk/gst-frames.h +47 -0
- package/native/gtk/gst-playback.cpp +496 -0
- package/native/gtk/gst-playback.h +81 -0
- package/native/gtk/gtk-backend.cpp +690 -0
- package/native/gtk/gtk-backend.h +134 -0
- package/native/gtk/host-sources.cpp +354 -0
- package/native/gtk/host-sources.h +46 -0
- package/native/gtk/image-manipulator.cpp +254 -0
- package/native/gtk/image-manipulator.h +30 -0
- package/native/gtk/image-view.cpp +256 -0
- package/native/gtk/image-view.h +54 -0
- package/native/gtk/input-replay.cpp +299 -0
- package/native/gtk/input-replay.h +36 -0
- package/native/gtk/launcher-badge.cpp +29 -0
- package/native/gtk/launcher-badge.h +21 -0
- package/native/gtk/locales.cpp +131 -0
- package/native/gtk/locales.h +23 -0
- package/native/gtk/location.cpp +274 -0
- package/native/gtk/location.h +19 -0
- package/native/gtk/main.cpp +1092 -0
- package/native/gtk/menus.cpp +447 -0
- package/native/gtk/menus.h +100 -0
- package/native/gtk/native-controls.cpp +831 -0
- package/native/gtk/native-controls.h +58 -0
- package/native/gtk/network-state.cpp +72 -0
- package/native/gtk/network-state.h +24 -0
- package/native/gtk/notifications.cpp +235 -0
- package/native/gtk/notifications.h +30 -0
- package/native/gtk/pango-text.cpp +274 -0
- package/native/gtk/pango-text.h +73 -0
- package/native/gtk/portal.cpp +451 -0
- package/native/gtk/portal.h +71 -0
- package/native/gtk/printing.cpp +338 -0
- package/native/gtk/printing.h +34 -0
- package/native/gtk/proxy-resolver.cpp +74 -0
- package/native/gtk/proxy-resolver.h +20 -0
- package/native/gtk/screens.cpp +1461 -0
- package/native/gtk/screens.h +274 -0
- package/native/gtk/scroll-view.cpp +414 -0
- package/native/gtk/scroll-view.h +82 -0
- package/native/gtk/secret-store.cpp +120 -0
- package/native/gtk/secret-store.h +27 -0
- package/native/gtk/settings-portal.cpp +129 -0
- package/native/gtk/settings-portal.h +47 -0
- package/native/gtk/split-view.cpp +1105 -0
- package/native/gtk/split-view.h +195 -0
- package/native/gtk/status-notifier.cpp +487 -0
- package/native/gtk/status-notifier.h +43 -0
- package/native/gtk/surface-input.cpp +251 -0
- package/native/gtk/surface-input.h +57 -0
- package/native/gtk/system-access.cpp +295 -0
- package/native/gtk/system-access.h +37 -0
- package/native/gtk/text-field.cpp +827 -0
- package/native/gtk/text-field.h +78 -0
- package/native/gtk/video.cpp +527 -0
- package/native/gtk/video.h +47 -0
- package/native/gtk/view-widget.cpp +431 -0
- package/native/gtk/view-widget.h +105 -0
- package/native/gtk/window-scale.cpp +95 -0
- package/native/gtk/window-scale.h +35 -0
- package/native/scripts/atspi-check.py +310 -0
- package/native/scripts/atspi-check.test.py +48 -0
- package/native/scripts/build.sh +20 -3
- package/native/scripts/compilers.sh +17 -0
- package/native/scripts/deb-depends-check.sh +22 -0
- package/native/scripts/fetch.sh +23 -2
- package/native/scripts/launch-cell.sh +157 -0
- package/native/scripts/launch-probe.sh +14 -3
- package/native/scripts/make-prebuilt.mjs +133 -44
- package/native/scripts/prebuilt-host-cache.mjs +71 -40
- package/native/scripts/reset-for-compilers.sh +44 -0
- package/native/scripts/start-xvfb.sh +35 -0
- package/native/shim/paragraph-platform/react/renderer/components/text/HostPlatformParagraphProps.h +35 -0
- package/native/shim/view-platform/react/renderer/components/view/HostPlatformViewTraitsInitializer.h +5 -2
- package/native/shim/worklets/linux-reanimated-props.h +14 -0
- package/native/shim/worklets/linux-worklets.h +23 -0
- package/package.json +6 -3
- package/prebuilt.json +70 -6
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
// items (compositeMove). A text input inside one keeps a Tab stop of its own.
|
|
15
15
|
#pragma once
|
|
16
16
|
|
|
17
|
+
#include "ngn/desktop-props.h"
|
|
17
18
|
#include "ngn/view-tree.h"
|
|
18
19
|
|
|
19
20
|
#include <optional>
|
|
@@ -25,6 +26,15 @@ namespace ngn {
|
|
|
25
26
|
// only text inputs (the Mac's default, where Option-Tab reaches everything).
|
|
26
27
|
enum class TabReach { TextInputs, All };
|
|
27
28
|
|
|
29
|
+
// Whether a plain view takes the focus a click, Tab or an assistive technology moves to it: when
|
|
30
|
+
// `focusable` says so, or with any `tabIndex`. A text input and a native control take it in a
|
|
31
|
+
// widget of their own.
|
|
32
|
+
bool viewTakesFocus(const DesktopProps &props);
|
|
33
|
+
|
|
34
|
+
// The container whose Tab order a Tab from `tag` walks: the nearest container root at or above it
|
|
35
|
+
// (a sheet, a popover, a sidebar pane), else the root of its tree.
|
|
36
|
+
Tag focusContainer(const ViewTree &tree, Tag tag);
|
|
37
|
+
|
|
28
38
|
// The views Tab visits in the container `root`, in order. `focused` is the view with the focus,
|
|
29
39
|
// which is a composite widget's stop.
|
|
30
40
|
std::vector<Tag> tabOrder(const ViewTree &tree, Tag root, TabReach reach, std::optional<Tag> focused = std::nullopt);
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
#pragma once
|
|
4
4
|
|
|
5
5
|
#include <react/renderer/core/Props.h>
|
|
6
|
+
#include <react/renderer/core/ReactPrimitives.h>
|
|
6
7
|
#include <react/renderer/graphics/Color.h>
|
|
7
8
|
|
|
8
9
|
#include <folly/dynamic.h>
|
|
@@ -105,6 +106,27 @@ std::optional<HeaderBar> headerBar(const facebook::react::Props &props);
|
|
|
105
106
|
// Nothing for other props, or without react-native-screens.
|
|
106
107
|
std::optional<std::string> headerItemType(const facebook::react::Props &props);
|
|
107
108
|
|
|
109
|
+
// A RNSScreenStackHeaderSubview of a header: its tag and where it sits (headerItemType).
|
|
110
|
+
struct HeaderSubview {
|
|
111
|
+
facebook::react::Tag tag;
|
|
112
|
+
std::string type;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// Where a front header's pieces go in a window's bar, for AppKit's toolbar and GTK's header bar
|
|
116
|
+
// alike: the back button first, then the left subviews and the left bar buttons; the title or the
|
|
117
|
+
// center subviews; then the right bar buttons, the right subviews and the search fields. Subviews
|
|
118
|
+
// of a side keep the order they were made in (their tags). A left subview or bar button replaces
|
|
119
|
+
// the back button, as on iOS.
|
|
120
|
+
struct HeaderLayout {
|
|
121
|
+
bool back{false};
|
|
122
|
+
std::vector<facebook::react::Tag> left;
|
|
123
|
+
std::vector<facebook::react::Tag> center;
|
|
124
|
+
std::vector<facebook::react::Tag> right;
|
|
125
|
+
std::vector<facebook::react::Tag> searchBars;
|
|
126
|
+
bool operator==(const HeaderLayout &) const = default;
|
|
127
|
+
};
|
|
128
|
+
HeaderLayout headerLayout(const HeaderBar &bar, std::vector<HeaderSubview> subviews, bool canGoBack);
|
|
129
|
+
|
|
108
130
|
// The search field a RNSSearchBar's props describe, or nothing for other props or without
|
|
109
131
|
// react-native-screens.
|
|
110
132
|
std::optional<SearchBarConfig> searchBarConfig(const facebook::react::Props &props);
|
|
@@ -25,6 +25,9 @@ struct HostOs {
|
|
|
25
25
|
std::string id;
|
|
26
26
|
// What Device's `osName` reports ("macOS").
|
|
27
27
|
std::string name;
|
|
28
|
+
// Device's brand and manufacturer where the OS's maker makes the machines it runs on ("Apple");
|
|
29
|
+
// empty where the machine's own maker is (MachineFacts::manufacturer).
|
|
30
|
+
std::string deviceMaker;
|
|
28
31
|
// The host binary's name, for its usage line.
|
|
29
32
|
std::string program;
|
|
30
33
|
// The modifier an app's shortcuts and the OS's own commands use (MenuModifier): the one a
|
|
@@ -41,5 +44,8 @@ struct HostOs {
|
|
|
41
44
|
};
|
|
42
45
|
|
|
43
46
|
HostOs macOS();
|
|
47
|
+
// Linux, under GTK. Not `linux()`: GNU C++ predefines `linux` as a macro on Linux. In a
|
|
48
|
+
// right-to-left locale back and forward swap arrows, as GTK's own apps mirror them.
|
|
49
|
+
HostOs linuxOs(bool rightToLeft = false);
|
|
44
50
|
|
|
45
51
|
} // namespace ngn
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Where React Native's own reloads go. ReactHost::reloadReactInstance, which DevSettings.reload(),
|
|
2
|
+
// the dev server's reload command and the debugger's call, tears its instance down and makes the
|
|
3
|
+
// next on a thread of its own, with nothing holding off the UI thread: a window sized meanwhile
|
|
4
|
+
// (one the splash screen lets go as the reload ends its module, say) reads a SurfaceManager already
|
|
5
|
+
// freed. The host builds a copy of ReactHost.cpp (cmake/react-native.cmake) that asks here first,
|
|
6
|
+
// and the core's Runtime routes its host's reloads to Runtime::reload, which keeps the surfaces in
|
|
7
|
+
// step with the UI thread as it runs.
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <functional>
|
|
11
|
+
|
|
12
|
+
namespace ngn {
|
|
13
|
+
|
|
14
|
+
// Sends `host`'s reloads to `reload` from now on; a null `reload` lets them go to React Native's
|
|
15
|
+
// own again. Any thread.
|
|
16
|
+
void routeHostReload(const void *host, std::function<void()> reload);
|
|
17
|
+
|
|
18
|
+
// Runs the reload routed for `host`, outside any lock, and answers true; false where none is.
|
|
19
|
+
bool reloadThroughRoute(const void *host);
|
|
20
|
+
|
|
21
|
+
} // namespace ngn
|
|
@@ -202,6 +202,29 @@ struct AccessibilitySettings {
|
|
|
202
202
|
bool operator==(const AccessibilitySettings &) const = default;
|
|
203
203
|
};
|
|
204
204
|
|
|
205
|
+
// What a Linux desktop says about those settings, each from wherever it is said: the settings
|
|
206
|
+
// portal, GTK's own settings, and AT-SPI's status (the GTK host's accessibility-settings.h).
|
|
207
|
+
struct LinuxAccessibilitySources {
|
|
208
|
+
// The portal's org.freedesktop.appearance reduced-motion, set to reduce.
|
|
209
|
+
bool portalReducedMotion{false};
|
|
210
|
+
// The portal's org.freedesktop.appearance contrast, set to higher.
|
|
211
|
+
bool portalContrast{false};
|
|
212
|
+
// GTK 4.22's gtk-interface-reduced-motion, set to reduce.
|
|
213
|
+
bool gtkReducedMotion{false};
|
|
214
|
+
// gtk-enable-animations, which GNOME's Animations switch turns off.
|
|
215
|
+
bool animations{true};
|
|
216
|
+
// High contrast as GTK has it: libadwaita's high-contrast, or GTK 4.20's gtk-interface-contrast
|
|
217
|
+
// set to more.
|
|
218
|
+
bool highContrast{false};
|
|
219
|
+
// org.a11y.Status ScreenReaderEnabled.
|
|
220
|
+
bool screenReader{false};
|
|
221
|
+
bool operator==(const LinuxAccessibilitySources &) const = default;
|
|
222
|
+
};
|
|
223
|
+
// Reduce motion when any source asks for it, increase contrast when any does, a screen reader as
|
|
224
|
+
// AT-SPI says; Linux has no reduce-transparency, invert-colours, bold-text or grayscale setting an
|
|
225
|
+
// app can read, so those stay off.
|
|
226
|
+
AccessibilitySettings linuxAccessibility(const LinuxAccessibilitySources &sources);
|
|
227
|
+
|
|
205
228
|
struct WindowMetrics {
|
|
206
229
|
Dimensions window;
|
|
207
230
|
Dimensions screen;
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
// Which of an Image's sources it loads, and whether a new one is a new load: the same on every
|
|
2
|
-
// toolkit, which then makes the request (appkit/image-request.h on macOS
|
|
2
|
+
// toolkit, which then makes the request (appkit/image-request.h on macOS, loadImageSource below
|
|
3
|
+
// on the others).
|
|
3
4
|
#pragma once
|
|
4
5
|
|
|
6
|
+
#include "ngn/expo-image.h"
|
|
7
|
+
#include "ngn/file-system.h"
|
|
8
|
+
#include "ngn/network.h"
|
|
9
|
+
|
|
5
10
|
#include <react/renderer/imagemanager/primitives.h>
|
|
6
11
|
|
|
12
|
+
#include <functional>
|
|
13
|
+
#include <memory>
|
|
7
14
|
#include <optional>
|
|
15
|
+
#include <string>
|
|
8
16
|
#include <vector>
|
|
9
17
|
|
|
10
18
|
namespace ngn {
|
|
@@ -15,4 +23,21 @@ std::optional<facebook::react::ImageSource> pickImageSource(
|
|
|
15
23
|
// Whether two sources load the same thing: ImageSource's own == compares only the uri.
|
|
16
24
|
bool sameImageRequest(const facebook::react::ImageSource &a, const facebook::react::ImageSource &b);
|
|
17
25
|
|
|
26
|
+
// An Image's resizeMode as a CSS object-fit for placeImage (expo-image.h), as the macOS host's layer
|
|
27
|
+
// gravity draws it: `center` centres the image at its own size, and `repeat` stretches it.
|
|
28
|
+
const char *imageContentFit(facebook::react::ImageResizeMode mode);
|
|
29
|
+
|
|
30
|
+
// Reads an Image source's bytes with its method, headers and body, as the macOS host's request
|
|
31
|
+
// does. Its `cache` is read as React Native iOS maps it to a cache policy, over `cache` (kept in
|
|
32
|
+
// memory) in place of the system's URL cache: `default` and `force-cache` answer from it when it
|
|
33
|
+
// holds the source, `reload` fetches again, and `only-if-cached` fails when it does not. Only a GET
|
|
34
|
+
// over http(s) with no body is cached, by its uri and headers. `file:` and `data:` sources are read, a file only inside the
|
|
35
|
+
// boundary `files` draws (readableSource). Answers once, on any thread: the bytes, or an error.
|
|
36
|
+
void loadImageSource(
|
|
37
|
+
const std::shared_ptr<Http> &http,
|
|
38
|
+
const std::shared_ptr<ImageCache> &cache,
|
|
39
|
+
const FileAccess *files,
|
|
40
|
+
const facebook::react::ImageSource &source,
|
|
41
|
+
std::function<void(std::string bytes, const std::string &error)> done);
|
|
42
|
+
|
|
18
43
|
} // namespace ngn
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
// magnify <x> <y> <amount> began|changed|ended
|
|
13
13
|
// rotate <x> <y> <degrees> began|changed|ended anticlockwise
|
|
14
14
|
// key <key> [cmd] [shift] [option] [ctrl] to the key window, whichever it is (the
|
|
15
|
-
// script's own when none is): a character, escape, return, space, tab
|
|
16
|
-
// delete; a character (or a space) with
|
|
17
|
-
// typed into a focused field
|
|
15
|
+
// script's own when none is): a character, escape, return, space, tab,
|
|
16
|
+
// delete, or an arrow (left, right, up, down); a character (or a space) with
|
|
17
|
+
// no command or control modifier is typed into a focused field
|
|
18
18
|
// type <text> the rest of the line, inner spaces and all, typed a character at a time
|
|
19
19
|
// into the focused field, as the keyboard would (no `#`, which starts a
|
|
20
20
|
// comment)
|
|
@@ -68,10 +68,13 @@ struct DragItems {
|
|
|
68
68
|
std::vector<DroppedFile> files;
|
|
69
69
|
std::optional<std::string> text;
|
|
70
70
|
std::vector<std::string> urls;
|
|
71
|
+
// The toolkit has not read the drag's data yet (GTK's preload): the drag is hit tested but its
|
|
72
|
+
// enter is held back until the data comes, so the event carries what is dragged.
|
|
73
|
+
bool pending{false};
|
|
71
74
|
};
|
|
72
75
|
|
|
73
76
|
// The items of a drag's urls (`file://` ones are files, named by their last part decoded) and
|
|
74
|
-
// its plain text, which is left out when it only repeats
|
|
77
|
+
// its plain text, which is left out when it only repeats the urls or the files' paths, one a line.
|
|
75
78
|
DragItems dragItems(const std::vector<std::string> &urls, std::optional<std::string> text);
|
|
76
79
|
|
|
77
80
|
class InputSink {
|
|
@@ -7,11 +7,16 @@
|
|
|
7
7
|
// Toolkit-free.
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
|
+
#include <atomic>
|
|
10
11
|
#include <cstdint>
|
|
11
12
|
#include <optional>
|
|
12
13
|
|
|
13
14
|
namespace ngn {
|
|
14
15
|
|
|
16
|
+
// How long a launch's first frame stays on screen before the launch counts as a success: an update
|
|
17
|
+
// that crashes before then is rolled back at the next launch.
|
|
18
|
+
constexpr double kLaunchSuccessSeconds = 10;
|
|
19
|
+
|
|
15
20
|
class LaunchFrame {
|
|
16
21
|
public:
|
|
17
22
|
// The launch `generation` (UpdatesClient::launchGeneration) loaded its bundle into the mounting
|
|
@@ -25,6 +30,21 @@ class LaunchFrame {
|
|
|
25
30
|
owed_.reset();
|
|
26
31
|
}
|
|
27
32
|
|
|
33
|
+
// A reload's bundle is loading, and then whether it loaded. Any thread, unlike the rest. A clean
|
|
34
|
+
// quit marks the launch a success only while its bundle is loaded: a reload still under way, or
|
|
35
|
+
// one whose bundle did not load, leaves the launch mark for the next launch to roll back.
|
|
36
|
+
void bundleLoading() {
|
|
37
|
+
bundleLoaded_ = false;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
void bundleLoadEnded(bool loaded) {
|
|
41
|
+
bundleLoaded_ = loaded;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
bool bundleLoaded() const {
|
|
45
|
+
return bundleLoaded_;
|
|
46
|
+
}
|
|
47
|
+
|
|
28
48
|
// A window shows content the instance `instance` mounted while `current` is the launch running:
|
|
29
49
|
// the launch whose success timer starts now, once.
|
|
30
50
|
std::optional<uint64_t> shown(uint64_t instance, uint64_t current) {
|
|
@@ -42,6 +62,7 @@ class LaunchFrame {
|
|
|
42
62
|
uint64_t instance;
|
|
43
63
|
};
|
|
44
64
|
std::optional<Owed> owed_;
|
|
65
|
+
std::atomic<bool> bundleLoaded_{true};
|
|
45
66
|
};
|
|
46
67
|
|
|
47
68
|
} // namespace ngn
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// bundle, module, title, app id and capabilities from argv, and settings such as the updates URL
|
|
3
3
|
// from the environment. A packaged app (its Info.plist names NGNBundleFile) takes all of them from
|
|
4
4
|
// its Info.plist only: argv and the environment are ignored, so nothing launching the app can make
|
|
5
|
-
// it run another bundle, as another app, or take updates from another server.
|
|
5
|
+
// it run another bundle, as another app, or take updates from another server. A Linux package has
|
|
6
|
+
// no Info.plist: the same keys are in the metadata.json beside its host (packagedMetadata).
|
|
6
7
|
#pragma once
|
|
7
8
|
|
|
8
9
|
#include "ngn/host-os.h"
|
|
@@ -16,18 +17,28 @@
|
|
|
16
17
|
|
|
17
18
|
namespace ngn {
|
|
18
19
|
|
|
20
|
+
// The switch the session bus starts a D-Bus activatable app with (GApplication's own).
|
|
21
|
+
inline constexpr const char *kDBusServiceArg = "--gapplication-service";
|
|
22
|
+
|
|
19
23
|
struct LaunchSources {
|
|
20
24
|
// argv without the program's own name.
|
|
21
25
|
std::vector<std::string> args;
|
|
22
26
|
using Lookup = std::function<std::optional<std::string>(const std::string &)>;
|
|
23
27
|
// An environment variable.
|
|
24
28
|
Lookup env;
|
|
25
|
-
// A string in the app's Info.plist.
|
|
29
|
+
// A string in the app's Info.plist, or its Linux package's metadata.json.
|
|
26
30
|
Lookup plist;
|
|
27
|
-
// The app bundle's Resources folder, where NGNBundleFile is
|
|
31
|
+
// The app bundle's Resources folder, where NGNBundleFile is: on Linux, the folder holding the
|
|
32
|
+
// host, the bundle and metadata.json.
|
|
28
33
|
std::string resourcePath;
|
|
29
34
|
};
|
|
30
35
|
|
|
36
|
+
// The metadata.json in `folder`, the folder of a Linux package's host (bin/package-linux.mjs), as a
|
|
37
|
+
// lookup for LaunchSources::plist: a string value as it is, any other (NGNCapabilities' object) as
|
|
38
|
+
// its JSON. An empty lookup when there is no such file, as in a dev run; why, when the file is there
|
|
39
|
+
// but is not a JSON object, so a broken package says so rather than running as a dev build.
|
|
40
|
+
std::variant<LaunchSources::Lookup, std::string> packagedMetadata(const std::string &folder);
|
|
41
|
+
|
|
31
42
|
// A test launch: `vitest --project macos` through @ng-native/testing starts a dev run with
|
|
32
43
|
// NGN_TESTS=1, NGN_STATE_DIR (a new empty directory), NGN_RUN_ID (unique to the launch) and
|
|
33
44
|
// NGN_TESTS_FAKE_SYSTEM_UI=1. The host keeps every piece of state under the state directory or
|
|
@@ -58,12 +69,19 @@ struct LaunchSettings {
|
|
|
58
69
|
std::string module{"main"};
|
|
59
70
|
std::string title{"ng-native"};
|
|
60
71
|
std::string appId;
|
|
61
|
-
// A dev run's --capabilities (or NGN_DESKTOP_CAPABILITIES) JSON
|
|
62
|
-
//
|
|
72
|
+
// A dev run's --capabilities (or NGN_DESKTOP_CAPABILITIES) JSON. A packaged app's are its
|
|
73
|
+
// NGNCapabilities: here when its lookup gives them as JSON (metadata.json); a macOS app reads its
|
|
74
|
+
// Info.plist's dictionary itself.
|
|
63
75
|
std::string capabilitiesJson;
|
|
64
76
|
// A dev run's --url: the link the app opens as it launches (Linking's initial URL), as a click on
|
|
65
77
|
// a link to the app's scheme would. Empty when none; a packaged app is opened on a link by the OS.
|
|
66
78
|
std::string initialUrl;
|
|
79
|
+
// What a packaged Linux app was opened on: the links and files its desktop entry's `%U` passes,
|
|
80
|
+
// as given (a URL, or a file's path).
|
|
81
|
+
std::vector<std::string> openArgs;
|
|
82
|
+
// `--gapplication-service`: started by the session bus as the app's D-Bus service, which a
|
|
83
|
+
// desktop entry with DBusActivatable=true asks for.
|
|
84
|
+
bool dbusService{false};
|
|
67
85
|
// Set for a test launch.
|
|
68
86
|
std::optional<TestLaunch> test;
|
|
69
87
|
// No system prompt is ever shown (NGN_NO_PROMPTS=1, or a test launch's fake system UI): a
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// other; the backend attaches it to the surface's main container.
|
|
6
6
|
#pragma once
|
|
7
7
|
|
|
8
|
+
#include "ngn/accessibility-relations.h"
|
|
8
9
|
#include "ngn/expo-ui.h"
|
|
9
10
|
#include "ngn/screen-stacks.h"
|
|
10
11
|
#include "ngn/split-view.h"
|
|
@@ -82,6 +83,10 @@ class MountingBackend {
|
|
|
82
83
|
// A live region on the surface changed its text (live-regions.h): the screen reader says it.
|
|
83
84
|
virtual void announce(SurfaceId /*surfaceId*/, const Announcement & /*announcement*/) {}
|
|
84
85
|
|
|
86
|
+
// The views `tag` is labelled and described by changed (accessibility-relations.h): empty when it
|
|
87
|
+
// has none now. Sent after the transaction's mutations, so every view named is mounted.
|
|
88
|
+
virtual void setAccessibilityRelations(SurfaceId /*surfaceId*/, Tag /*tag*/, const AxRelations & /*relations*/) {}
|
|
89
|
+
|
|
85
90
|
// Called once a transaction's mutations have all been applied.
|
|
86
91
|
virtual void didMount(SurfaceId /*surfaceId*/) {}
|
|
87
92
|
|
|
@@ -141,6 +141,7 @@ class MountingManager final : public facebook::react::IMountingManager,
|
|
|
141
141
|
std::unordered_map<SurfaceId, uint64_t> mountedBy_;
|
|
142
142
|
ViewTree tree_;
|
|
143
143
|
LiveRegions liveRegions_;
|
|
144
|
+
AccessibilityRelations relations_;
|
|
144
145
|
std::unique_ptr<ScreenStacks> screens_;
|
|
145
146
|
std::unique_ptr<SafeAreas> safeAreas_;
|
|
146
147
|
bool safeAreasSettled_{false};
|
|
@@ -16,10 +16,12 @@
|
|
|
16
16
|
#include <react/renderer/components/view/ViewProps.h>
|
|
17
17
|
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
18
18
|
#include <react/renderer/core/LayoutConstraints.h>
|
|
19
|
+
#include <react/renderer/core/LayoutContext.h>
|
|
19
20
|
#include <react/renderer/graphics/Color.h>
|
|
20
21
|
#include <react/utils/ContextContainer.h>
|
|
21
22
|
|
|
22
23
|
#include <optional>
|
|
24
|
+
#include <string_view>
|
|
23
25
|
#include <string>
|
|
24
26
|
#include <vector>
|
|
25
27
|
|
|
@@ -44,8 +46,8 @@ class NativeControlProps final : public facebook::react::ViewProps, public HasDe
|
|
|
44
46
|
|
|
45
47
|
// Button.
|
|
46
48
|
std::string title;
|
|
47
|
-
// `default`, `cancel`, `destructive` or `plain
|
|
48
|
-
std::string kind
|
|
49
|
+
// `default`, `cancel`, `destructive` or `plain`, or empty when the element sets none.
|
|
50
|
+
std::string kind;
|
|
49
51
|
std::string sfSymbol;
|
|
50
52
|
|
|
51
53
|
// Switch.
|
|
@@ -69,6 +71,8 @@ class NativeControlProps final : public facebook::react::ViewProps, public HasDe
|
|
|
69
71
|
std::optional<double> maximumDate;
|
|
70
72
|
// `date`, `time`, `datetime` or `countdown`.
|
|
71
73
|
std::string mode{"date"};
|
|
74
|
+
// The minutes a time is picked in steps of (iOS's minuteInterval): 1 to 30, dividing 60.
|
|
75
|
+
int minuteInterval{1};
|
|
72
76
|
// `default`, `spinner`, `compact` or `inline`.
|
|
73
77
|
std::string display{"default"};
|
|
74
78
|
|
|
@@ -100,11 +104,13 @@ struct NativeControlState {
|
|
|
100
104
|
int measured{0};
|
|
101
105
|
};
|
|
102
106
|
|
|
103
|
-
// The size layout gives a control: the one ControlSizes holds for its inputs (control-sizes.cpp)
|
|
107
|
+
// The size layout gives a control: the one ControlSizes holds for its inputs (control-sizes.cpp),
|
|
108
|
+
// at the text size multiplier the layout runs with.
|
|
104
109
|
facebook::react::Size measureControl(
|
|
105
110
|
const facebook::react::ShadowNode &node,
|
|
106
111
|
ControlKind kind,
|
|
107
|
-
const facebook::react::ContextContainer *context
|
|
112
|
+
const facebook::react::ContextContainer *context,
|
|
113
|
+
float fontScale);
|
|
108
114
|
|
|
109
115
|
// The control a Fabric component name is, if it is one.
|
|
110
116
|
std::optional<ControlKind> controlKind(std::string_view componentName);
|
|
@@ -139,7 +145,7 @@ class NativeControlShadowNode final : public facebook::react::ConcreteViewShadow
|
|
|
139
145
|
const facebook::react::LayoutContext &layoutContext,
|
|
140
146
|
const facebook::react::LayoutConstraints &layoutConstraints) const override {
|
|
141
147
|
const auto &context = this->getContextContainer();
|
|
142
|
-
return layoutConstraints.clamp(measureControl(*this, Kind, context.get()));
|
|
148
|
+
return layoutConstraints.clamp(measureControl(*this, Kind, context.get(), layoutContext.fontSizeMultiplier));
|
|
143
149
|
}
|
|
144
150
|
};
|
|
145
151
|
|
|
@@ -147,6 +153,21 @@ template <const char *Name, ControlKind Kind>
|
|
|
147
153
|
using NativeControlComponentDescriptor =
|
|
148
154
|
facebook::react::ConcreteComponentDescriptor<NativeControlShadowNode<Name, Kind>>;
|
|
149
155
|
|
|
156
|
+
// Whether a strftime time format, as the C library's locale gives it (nl_langinfo(T_FMT)), writes a
|
|
157
|
+
// 12-hour clock: it has %I, %l, %r, %p or %P. A date picker's time follows it on Linux.
|
|
158
|
+
bool twelveHourClock(std::string_view timeFormat);
|
|
159
|
+
// The hour of the day, 0 to 23, for an hour on a 12-hour clock (1 to 12) in the morning or after
|
|
160
|
+
// noon; and the 12-hour clock's hour for an hour of the day.
|
|
161
|
+
int dayHour(int clockHour, bool afterNoon);
|
|
162
|
+
int clockHour(int dayHour);
|
|
163
|
+
// GNOME's clock-format (org.gnome.desktop.interface, through the settings portal): true for
|
|
164
|
+
// `12h`, false for `24h`, nothing for anything else, where the locale's format decides.
|
|
165
|
+
std::optional<bool> clockFormatTwelveHour(std::string_view clockFormat);
|
|
166
|
+
// A minuteInterval as UIDatePicker takes it: one that does not divide 60 evenly, or is outside 1
|
|
167
|
+
// to 30, is 1. And a minute rounded down to it, as the picker shows a time between two steps.
|
|
168
|
+
int pickerMinuteInterval(int minuteInterval);
|
|
169
|
+
int minuteOnInterval(int minute, int minuteInterval);
|
|
170
|
+
|
|
150
171
|
using NativeButtonComponentDescriptor = NativeControlComponentDescriptor<NativeButtonComponentName, ControlKind::Button>;
|
|
151
172
|
using SwitchControlComponentDescriptor =
|
|
152
173
|
NativeControlComponentDescriptor<SwitchControlComponentName, ControlKind::Switch>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Scheduled local notifications for an OS with no scheduler of its own (Linux): the requests kept
|
|
2
|
+
// in a JSON file in the app's data folder, each with the time it next fires, and fired from a timer
|
|
3
|
+
// in the app's process. So a trigger fires only while the app runs; one that came due while it did
|
|
4
|
+
// not is delivered once as the schedule starts, and a repeating one then waits for its next time.
|
|
5
|
+
// The delivered ones are kept too, as the OS keeps no list an app can read.
|
|
6
|
+
//
|
|
7
|
+
// Times are ms since the epoch, and calendar components match in the local time zone (TZ). Any
|
|
8
|
+
// thread: `deliver` is called on the timer's.
|
|
9
|
+
#pragma once
|
|
10
|
+
|
|
11
|
+
#include "ngn/notifications.h"
|
|
12
|
+
|
|
13
|
+
#include <functional>
|
|
14
|
+
#include <map>
|
|
15
|
+
#include <memory>
|
|
16
|
+
#include <optional>
|
|
17
|
+
#include <string>
|
|
18
|
+
#include <utility>
|
|
19
|
+
#include <vector>
|
|
20
|
+
|
|
21
|
+
namespace ngn {
|
|
22
|
+
|
|
23
|
+
// The first time after `after` that `components` match (notifications.h's names: year, month 1 to
|
|
24
|
+
// 12, day, weekday 1 (Sunday) to 7, hour, minute and second), as NSCalendar matches them: a unit
|
|
25
|
+
// smaller than every one named is at its start (`{ hour: 8 }` is 08:00:00), and a larger one is
|
|
26
|
+
// any. Nothing when no time will match, as for a year gone by or the 30th of February.
|
|
27
|
+
std::optional<double> nextCalendarMatch(const std::map<std::string, int> &components, double after);
|
|
28
|
+
|
|
29
|
+
// When `trigger` fires first if it is scheduled at `now`; nothing for a date gone by.
|
|
30
|
+
std::optional<double> firstFireDate(const NotificationTrigger &trigger, double now);
|
|
31
|
+
|
|
32
|
+
class NotificationSchedule {
|
|
33
|
+
public:
|
|
34
|
+
struct Clock {
|
|
35
|
+
std::function<double()> now;
|
|
36
|
+
// Calls `fn` once after `ms`, later and never from inside the call, on the backend's main
|
|
37
|
+
// thread; the answer cancels it.
|
|
38
|
+
std::function<std::function<void()>(double ms, std::function<void()> fn)> after;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// `path` is the file it keeps its requests in, read now. `deliver` presents one as it fires.
|
|
42
|
+
NotificationSchedule(std::string path, Clock clock, std::function<void(const NotificationRequest &)> deliver);
|
|
43
|
+
~NotificationSchedule();
|
|
44
|
+
NotificationSchedule(const NotificationSchedule &) = delete;
|
|
45
|
+
NotificationSchedule &operator=(const NotificationSchedule &) = delete;
|
|
46
|
+
|
|
47
|
+
// Delivers what came due while the app was not running, and waits for the next.
|
|
48
|
+
void start();
|
|
49
|
+
// Schedules `request`, replacing one with its identifier; a trigger of now delivers it at once.
|
|
50
|
+
// False when the schedule could not be written: nothing changed, and the file is as it was.
|
|
51
|
+
bool add(const NotificationRequest &request);
|
|
52
|
+
std::vector<NotificationRequest> pending() const;
|
|
53
|
+
void removePending(const std::vector<std::string> &identifiers);
|
|
54
|
+
void removeAllPending();
|
|
55
|
+
|
|
56
|
+
// What was delivered (and not dismissed) with when, oldest first, at most kKeptDelivered.
|
|
57
|
+
std::vector<std::pair<double, NotificationRequest>> delivered() const;
|
|
58
|
+
// The delivered one with `identifier`, as a click on it names it.
|
|
59
|
+
std::optional<std::pair<double, NotificationRequest>> deliveredOne(const std::string &identifier) const;
|
|
60
|
+
// Forgets delivered ones; the answer is the identifiers it had, for the backend to withdraw.
|
|
61
|
+
std::vector<std::string> removeDelivered(const std::vector<std::string> &identifiers);
|
|
62
|
+
std::vector<std::string> removeAllDelivered();
|
|
63
|
+
|
|
64
|
+
static constexpr size_t kKeptDelivered = 64;
|
|
65
|
+
// The longest the timer waits before it reads the clock again: a wait measured on a monotonic
|
|
66
|
+
// clock stops while the computer sleeps, which the wall clock does not.
|
|
67
|
+
static constexpr double kLongestWait = 60'000;
|
|
68
|
+
|
|
69
|
+
private:
|
|
70
|
+
struct State;
|
|
71
|
+
std::shared_ptr<State> state_;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
} // namespace ngn
|
|
@@ -182,7 +182,8 @@ class NotificationEvents {
|
|
|
182
182
|
Listeners<folly::dynamic> listeners_;
|
|
183
183
|
};
|
|
184
184
|
|
|
185
|
-
// `push` absent (a host
|
|
185
|
+
// `push` absent (a host with no push service, such as Linux's) leaves out getDevicePushTokenAsync
|
|
186
|
+
// and unregisterForNotificationsAsync, which JavaScript then reads as absent.
|
|
186
187
|
std::shared_ptr<NativeModule> makeNotificationsModule(
|
|
187
188
|
std::shared_ptr<NotificationCenter> center,
|
|
188
189
|
std::shared_ptr<NotificationEvents> events,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// The Expo Updates client's hash and signature check (updates.h) over OpenSSL 3, for a host whose
|
|
2
|
+
// OS has no crypto library of its own to use: the GTK host links the system's libcrypto.so.3, which
|
|
3
|
+
// its libcurl links already. Only OpenSSL 3.0 calls, so the host runs on any 3.x
|
|
4
|
+
// (native/docker/glibc-floor.sh checks). Toolkit-free.
|
|
5
|
+
#pragma once
|
|
6
|
+
|
|
7
|
+
#include "ngn/updates.h"
|
|
8
|
+
|
|
9
|
+
#include <memory>
|
|
10
|
+
|
|
11
|
+
namespace ngn {
|
|
12
|
+
|
|
13
|
+
std::shared_ptr<UpdateCrypto> makeOpenSslUpdateCrypto();
|
|
14
|
+
|
|
15
|
+
} // namespace ngn
|
|
@@ -23,9 +23,14 @@
|
|
|
23
23
|
// get/requestMediaLibraryPermissionsAsync() as above. Its camera half is the host's own camera
|
|
24
24
|
// sheet (camera.h's launchPickerCamera), since macOS has no system camera screen to open:
|
|
25
25
|
// launchCameraAsync(options) and get/requestCameraPermissionsAsync(), the camera's permission.
|
|
26
|
+
// A picked image comes with `base64` and `exif` when the options ask for them, as a camera shot
|
|
27
|
+
// does: the EXIF the host read, else a JPEG's own. A host with a picker and no photo library (GTK's
|
|
28
|
+
// FileChooser over the user's files, makeFilePhotoPicker) answers the library permissions granted,
|
|
29
|
+
// since an open panel needs none.
|
|
26
30
|
#pragma once
|
|
27
31
|
|
|
28
32
|
#include "ngn/camera.h"
|
|
33
|
+
#include "ngn/desktop-expo.h"
|
|
29
34
|
#include "ngn/file-system.h"
|
|
30
35
|
|
|
31
36
|
#include "ngn/native-module.h"
|
|
@@ -34,11 +39,37 @@
|
|
|
34
39
|
#include <memory>
|
|
35
40
|
#include <optional>
|
|
36
41
|
#include <string>
|
|
42
|
+
#include <utility>
|
|
37
43
|
#include <vector>
|
|
38
44
|
|
|
39
45
|
namespace ngn {
|
|
40
46
|
|
|
41
|
-
|
|
47
|
+
// The system's photo picker.
|
|
48
|
+
class PhotoPicker {
|
|
49
|
+
public:
|
|
50
|
+
struct Picked {
|
|
51
|
+
// A file url in the app's caches.
|
|
52
|
+
std::string uri;
|
|
53
|
+
std::string fileName;
|
|
54
|
+
std::string mimeType;
|
|
55
|
+
std::string type;
|
|
56
|
+
double width{0};
|
|
57
|
+
double height{0};
|
|
58
|
+
std::optional<double> duration;
|
|
59
|
+
double fileSize{0};
|
|
60
|
+
std::optional<std::string> assetId;
|
|
61
|
+
// The image's EXIF as expo names its tags, when the host read it; null for the core to read a
|
|
62
|
+
// JPEG's own.
|
|
63
|
+
folly::dynamic exif{nullptr};
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
virtual ~PhotoPicker() = default;
|
|
67
|
+
// Nothing when the user cancels or there is no window to show it on. `options` are
|
|
68
|
+
// launchImageLibraryAsync's. Any thread.
|
|
69
|
+
virtual void pick(const folly::dynamic &options, std::function<void(std::optional<std::vector<Picked>>)> done) = 0;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
class PhotoLibrary : public PhotoPicker {
|
|
42
73
|
public:
|
|
43
74
|
enum class Access { NotDetermined, Denied, Restricted, Granted, Limited };
|
|
44
75
|
|
|
@@ -79,19 +110,6 @@ class PhotoLibrary {
|
|
|
79
110
|
// album or smartAlbum.
|
|
80
111
|
std::string type{"album"};
|
|
81
112
|
};
|
|
82
|
-
struct Picked {
|
|
83
|
-
// A file url in the app's caches.
|
|
84
|
-
std::string uri;
|
|
85
|
-
std::string fileName;
|
|
86
|
-
std::string mimeType;
|
|
87
|
-
std::string type;
|
|
88
|
-
double width{0};
|
|
89
|
-
double height{0};
|
|
90
|
-
std::optional<double> duration;
|
|
91
|
-
double fileSize{0};
|
|
92
|
-
std::optional<std::string> assetId;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
113
|
virtual ~PhotoLibrary() = default;
|
|
96
114
|
virtual Access access(bool writeOnly) = 0;
|
|
97
115
|
// Shows the OS's prompt and answers once the user decides; answers the access as it is, with no
|
|
@@ -118,17 +136,39 @@ class PhotoLibrary {
|
|
|
118
136
|
std::function<void(std::optional<Album>, const std::string &error)> done) = 0;
|
|
119
137
|
virtual void deleteAlbums(const std::vector<std::string> &ids, bool deleteAssets, Done done) = 0;
|
|
120
138
|
virtual void changeAlbum(const std::string &album, const std::vector<std::string> &ids, bool add, Done done) = 0;
|
|
121
|
-
|
|
122
|
-
// The system's photo picker; null when the user cancels or there is no window to show it on.
|
|
123
|
-
virtual void pick(const folly::dynamic &options, std::function<void(std::optional<std::vector<Picked>>)> done) = 0;
|
|
124
139
|
};
|
|
125
140
|
|
|
126
141
|
// The query a JS Query describes; throws for a field or operator the library has none of.
|
|
127
142
|
PhotoLibrary::Query photoQueryOf(const folly::dynamic &query);
|
|
128
143
|
|
|
129
144
|
std::shared_ptr<NativeModule> makeMediaLibraryModule(std::shared_ptr<PhotoLibrary> library, bool noPrompts, std::shared_ptr<FileAccess> files);
|
|
130
|
-
// `
|
|
131
|
-
//
|
|
132
|
-
|
|
145
|
+
// `library`, whose permissions the picker answers with, is null for a picker with no library behind
|
|
146
|
+
// it. `camera`: the host's own camera for launchCameraAsync; without it the camera permissions
|
|
147
|
+
// answer denied and launchCameraAsync canceled.
|
|
148
|
+
std::shared_ptr<NativeModule> makeImagePickerModule(std::shared_ptr<PhotoPicker> picker, std::shared_ptr<PhotoLibrary> library, bool noPrompts,
|
|
149
|
+
std::optional<PickerCamera> camera = std::nullopt);
|
|
150
|
+
|
|
151
|
+
// A picker over the OS's open panel, for a host with no photo library: `mediaTypes` choose the
|
|
152
|
+
// filter (images, videos or both), `allowsMultipleSelection` and `selectionLimit` how many. On a
|
|
153
|
+
// thread of its own, off the one the panel answers on, each file chosen is copied into a folder of
|
|
154
|
+
// its own in `folder` and described there: its MIME type from its name, an image's size from
|
|
155
|
+
// `imageSize` (nothing when it cannot be read; called on that thread), and an MP4 or QuickTime
|
|
156
|
+
// video's size and duration from its own boxes (0 and no duration in another container).
|
|
157
|
+
std::shared_ptr<PhotoPicker> makeFilePhotoPicker(std::shared_ptr<FileDialogs> dialogs, std::string folder,
|
|
158
|
+
std::function<std::optional<std::pair<double, double>>(const std::string &path)> imageSize);
|
|
159
|
+
|
|
160
|
+
// An MP4 or QuickTime file's first video track: its size in pixels and its duration in
|
|
161
|
+
// milliseconds, from its moov box; nothing for another file.
|
|
162
|
+
struct VideoFacts {
|
|
163
|
+
double width{0};
|
|
164
|
+
double height{0};
|
|
165
|
+
double duration{0};
|
|
166
|
+
};
|
|
167
|
+
std::optional<VideoFacts> isoVideoFacts(const std::string &path);
|
|
168
|
+
|
|
169
|
+
// A JPEG's EXIF (its APP1 segment's first IFD, Exif IFD and GPS IFD), keyed by expo's tag names
|
|
170
|
+
// (Orientation, DateTimeOriginal, ExposureTime, GPSLatitude...): numbers, strings, or arrays of
|
|
171
|
+
// them. Null for bytes with no EXIF. Tags it has no name for are left out.
|
|
172
|
+
folly::dynamic jpegExif(const std::string &bytes);
|
|
133
173
|
|
|
134
174
|
} // namespace ngn
|