@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
|
@@ -216,7 +216,7 @@ folly::dynamic toJson(const std::optional<LaunchState::Update> &update) {
|
|
|
216
216
|
return nullptr;
|
|
217
217
|
}
|
|
218
218
|
return folly::dynamic::object("id", update->id)("createdAt", update->createdAt)("runtimeVersion", update->runtimeVersion)(
|
|
219
|
-
"file", update->file);
|
|
219
|
+
"file", update->file)("embedded", update->embedded);
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
std::optional<LaunchState::Update> updateFrom(const folly::dynamic &json) {
|
|
@@ -228,7 +228,37 @@ std::optional<LaunchState::Update> updateFrom(const folly::dynamic &json) {
|
|
|
228
228
|
return value != nullptr && value->isString() ? value->asString() : std::string();
|
|
229
229
|
};
|
|
230
230
|
return LaunchState::Update{
|
|
231
|
-
.id = text("id"),
|
|
231
|
+
.id = text("id"),
|
|
232
|
+
.createdAt = text("createdAt"),
|
|
233
|
+
.runtimeVersion = text("runtimeVersion"),
|
|
234
|
+
.file = text("file"),
|
|
235
|
+
.embedded = text("embedded")};
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// The bytes' digest as the manifest writes it, or nothing when the system's crypto cannot hash: a
|
|
239
|
+
// download then fails with an error, as a hash that does not match does, instead of throwing from
|
|
240
|
+
// the network's callback.
|
|
241
|
+
std::optional<std::string> hashOrNothing(UpdateCrypto &crypto, const std::string &bytes) {
|
|
242
|
+
try {
|
|
243
|
+
return base64Url(crypto.sha256(bytes));
|
|
244
|
+
} catch (const std::exception &) {
|
|
245
|
+
return std::nullopt;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// The embedded bundle as it is on disk now, by its content: a package or app update that replaces
|
|
250
|
+
// it changes the digest, even to a file of the same size and modification time (a build that
|
|
251
|
+
// normalises timestamps). Empty for a bundle that is not a readable file.
|
|
252
|
+
std::string fingerprintOf(const std::string &bundle, UpdateCrypto &crypto) {
|
|
253
|
+
std::error_code error;
|
|
254
|
+
if (!fs::is_regular_file(bundle, error)) {
|
|
255
|
+
return "";
|
|
256
|
+
}
|
|
257
|
+
try {
|
|
258
|
+
return base64Url(crypto.sha256(readFile(bundle)));
|
|
259
|
+
} catch (const std::exception &) {
|
|
260
|
+
return "";
|
|
261
|
+
}
|
|
232
262
|
}
|
|
233
263
|
|
|
234
264
|
// The response body and status of one request, gathered from its callbacks.
|
|
@@ -435,9 +465,25 @@ std::optional<std::string> UpdatesClient::signatureProblem(
|
|
|
435
465
|
return std::nullopt;
|
|
436
466
|
}
|
|
437
467
|
|
|
468
|
+
bool UpdatesClient::stale(const LaunchState::Update &update) const {
|
|
469
|
+
return update.runtimeVersion != config_.runtimeVersion || update.embedded != fingerprintOf(config_.embeddedBundle, *crypto_);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
void UpdatesClient::prune(const LaunchState &state) const {
|
|
473
|
+
std::error_code error;
|
|
474
|
+
for (const auto &entry : fs::directory_iterator(config_.directory, error)) {
|
|
475
|
+
auto name = entry.path().filename().string();
|
|
476
|
+
bool keep = !entry.is_directory() || (state.current && name == state.current->id) ||
|
|
477
|
+
(state.previous && name == state.previous->id) || (running_ && name == running_->id);
|
|
478
|
+
if (!keep) {
|
|
479
|
+
fs::remove_all(entry.path(), error);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
438
484
|
bool UpdatesClient::usable(const LaunchState::Update &update, const LaunchState &state) const {
|
|
439
485
|
// Only `<uuid>/launch-asset`, whatever the state file says.
|
|
440
|
-
if (!isUuid(update.id) || update.file != update.id + "/launch-asset" || update
|
|
486
|
+
if (!isUuid(update.id) || update.file != update.id + "/launch-asset" || stale(update) ||
|
|
441
487
|
std::find(state.failed.begin(), state.failed.end(), update.id) != state.failed.end() || !fs::exists(pathOf(update))) {
|
|
442
488
|
return false;
|
|
443
489
|
}
|
|
@@ -484,6 +530,11 @@ std::string UpdatesClient::launch() {
|
|
|
484
530
|
}
|
|
485
531
|
state.launching.clear();
|
|
486
532
|
}
|
|
533
|
+
// An update for another runtime version, or fetched over the embedded bundle a package update
|
|
534
|
+
// has since replaced, is dropped with its files.
|
|
535
|
+
if (state.previous && stale(*state.previous)) {
|
|
536
|
+
state.previous.reset();
|
|
537
|
+
}
|
|
487
538
|
if (state.current && !usable(*state.current, state)) {
|
|
488
539
|
state.current.reset();
|
|
489
540
|
}
|
|
@@ -493,6 +544,7 @@ std::string UpdatesClient::launch() {
|
|
|
493
544
|
}
|
|
494
545
|
try {
|
|
495
546
|
save(state);
|
|
547
|
+
prune(state);
|
|
496
548
|
} catch (const std::exception &) {
|
|
497
549
|
// Without its launch mark a crash in the update would never roll it back: the embedded
|
|
498
550
|
// bundle runs instead.
|
|
@@ -585,9 +637,13 @@ std::string UpdatesClient::beginReload() {
|
|
|
585
637
|
return running_ ? pathOf(*running_) : config_.embeddedBundle;
|
|
586
638
|
}
|
|
587
639
|
|
|
640
|
+
std::string UpdatesClient::offReason() const {
|
|
641
|
+
return enabled() ? "" : "Updates are off: the app has no updates URL (updates.url in app.json).";
|
|
642
|
+
}
|
|
643
|
+
|
|
588
644
|
void UpdatesClient::check(std::function<void(CheckResult)> done) {
|
|
589
645
|
if (!enabled()) {
|
|
590
|
-
done({.error =
|
|
646
|
+
done({.error = offReason()});
|
|
591
647
|
return;
|
|
592
648
|
}
|
|
593
649
|
HttpRequest request{.url = config_.url, .withCredentials = false};
|
|
@@ -754,6 +810,7 @@ void UpdatesClient::fetch(std::function<void(FetchResult)> done) {
|
|
|
754
810
|
.createdAt = found.createdAt,
|
|
755
811
|
.runtimeVersion = found.runtimeVersion,
|
|
756
812
|
.file = found.id + "/launch-asset",
|
|
813
|
+
.embedded = fingerprintOf(config_.embeddedBundle, *crypto_),
|
|
757
814
|
};
|
|
758
815
|
for (const auto &[file, bytes] : fetching.files) {
|
|
759
816
|
writeFile(config_.directory / update.id / file, bytes);
|
|
@@ -773,14 +830,7 @@ void UpdatesClient::fetch(std::function<void(FetchResult)> done) {
|
|
|
773
830
|
state.current = update;
|
|
774
831
|
save(state);
|
|
775
832
|
// Only the updates the state names, and the one running, are kept.
|
|
776
|
-
|
|
777
|
-
auto name = entry.path().filename().string();
|
|
778
|
-
bool keep = !entry.is_directory() || name == update.id || (state.previous && name == state.previous->id) ||
|
|
779
|
-
(running_ && name == running_->id);
|
|
780
|
-
if (!keep) {
|
|
781
|
-
fs::remove_all(entry.path());
|
|
782
|
-
}
|
|
783
|
-
}
|
|
833
|
+
prune(state);
|
|
784
834
|
found_.reset();
|
|
785
835
|
result.isNew = true;
|
|
786
836
|
result.manifest = found.raw;
|
|
@@ -821,7 +871,12 @@ void UpdatesClient::fetch(std::function<void(FetchResult)> done) {
|
|
|
821
871
|
}
|
|
822
872
|
}
|
|
823
873
|
download(asset.url, "the asset " + asset.key, [this, fetching, asset, path, done](std::string bytes) {
|
|
824
|
-
|
|
874
|
+
auto hash = hashOrNothing(*crypto_, bytes);
|
|
875
|
+
if (!hash) {
|
|
876
|
+
done({.error = "the asset " + asset.key + " could not be hashed: the update was not kept"});
|
|
877
|
+
return;
|
|
878
|
+
}
|
|
879
|
+
if (*hash != asset.hash) {
|
|
825
880
|
done({.error = "the asset " + asset.key + "'s hash is not the manifest's: the update was not kept"});
|
|
826
881
|
return;
|
|
827
882
|
}
|
|
@@ -831,7 +886,12 @@ void UpdatesClient::fetch(std::function<void(FetchResult)> done) {
|
|
|
831
886
|
};
|
|
832
887
|
|
|
833
888
|
download(found->launchUrl, "the launch asset", [this, fetching, done](std::string bytes) {
|
|
834
|
-
|
|
889
|
+
auto hash = hashOrNothing(*crypto_, bytes);
|
|
890
|
+
if (!hash) {
|
|
891
|
+
done({.error = "the launch asset could not be hashed: it was not kept"});
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
894
|
+
if (*hash != fetching->manifest.launchHash) {
|
|
835
895
|
done({.error = "the launch asset's hash is not the manifest's: it was not kept"});
|
|
836
896
|
return;
|
|
837
897
|
}
|
|
@@ -906,12 +966,11 @@ std::shared_ptr<NativeModule> makeUpdatesModule(
|
|
|
906
966
|
}
|
|
907
967
|
return assets;
|
|
908
968
|
});
|
|
909
|
-
auto refuse = [on, development](JsPromise &p) {
|
|
969
|
+
auto refuse = [on, development, client](JsPromise &p) {
|
|
910
970
|
if (on) {
|
|
911
971
|
return false;
|
|
912
972
|
}
|
|
913
|
-
p.reject(development ? "Updates are off in development, where the bundle comes from the dev server."
|
|
914
|
-
: "Updates are off: the app has no updates URL (updates.url in app.json).");
|
|
973
|
+
p.reject(development ? "Updates are off in development, where the bundle comes from the dev server." : client->offReason());
|
|
915
974
|
return true;
|
|
916
975
|
};
|
|
917
976
|
promise("checkForUpdateAsync", [client, refuse](const folly::dynamic &, JsPromise p) {
|
|
@@ -150,10 +150,9 @@ void drawSides(const SvgRect &box, const EdgeWidths &w, const CornerRadii &radii
|
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
std::optional<uint32_t> colors[4] = {argbOf(c.top), argbOf(c.right), argbOf(c.bottom), argbOf(c.left)};
|
|
153
|
+
// The border of `box`, its sides' colours from the top clockwise, in `style`.
|
|
154
|
+
void drawBorderOf(
|
|
155
|
+
const SvgRect &box, const EdgeWidths &w, const std::optional<uint32_t> colors[4], const CornerRadii &radii, BorderStyle style, SvgCanvas &canvas) {
|
|
157
156
|
double widths[4] = {w.top, w.right, w.bottom, w.left};
|
|
158
157
|
std::optional<uint32_t> only;
|
|
159
158
|
bool oneColor = true, any = false, hidden = false;
|
|
@@ -175,7 +174,6 @@ void drawBorder(const SvgRect &box, const BorderMetrics &metrics, const CornerRa
|
|
|
175
174
|
return;
|
|
176
175
|
}
|
|
177
176
|
|
|
178
|
-
auto style = metrics.borderStyles.left;
|
|
179
177
|
if (style == BorderStyle::Dashed || style == BorderStyle::Dotted) {
|
|
180
178
|
// One colour, stroked along the middle of the widest side, as React Native iOS draws it.
|
|
181
179
|
if (!oneColor) {
|
|
@@ -183,7 +181,7 @@ void drawBorder(const SvgRect &box, const BorderMetrics &metrics, const CornerRa
|
|
|
183
181
|
}
|
|
184
182
|
double line = *std::max_element(std::begin(widths), std::end(widths));
|
|
185
183
|
SvgRect middle{box.x + line / 2, box.y + line / 2, box.width - line, box.height - line};
|
|
186
|
-
bool uniform =
|
|
184
|
+
bool uniform = w.top == w.right && w.top == w.bottom && w.top == w.left;
|
|
187
185
|
if (!uniform) {
|
|
188
186
|
canvas.save();
|
|
189
187
|
auto ring = rectPath(box);
|
|
@@ -669,9 +667,60 @@ std::vector<SvgRect> backgroundTiles(
|
|
|
669
667
|
return tiles;
|
|
670
668
|
}
|
|
671
669
|
|
|
670
|
+
namespace {
|
|
671
|
+
|
|
672
|
+
// background-origin: padding-box; background-clip: border-box. The first image is on top, so it
|
|
673
|
+
// comes last.
|
|
674
|
+
std::vector<BackgroundLayer> backgroundLayers(const ViewProps &props, const SvgRect &bounds, const EdgeWidths &widths) {
|
|
675
|
+
std::vector<BackgroundLayer> layers;
|
|
676
|
+
auto area = inset(bounds, widths);
|
|
677
|
+
for (size_t i = props.backgroundImage.size(); i-- > 0;) {
|
|
678
|
+
auto pick = [i](const auto &list, auto fallback) { return list.empty() ? fallback : list[i % list.size()]; };
|
|
679
|
+
auto tiles = backgroundTiles(
|
|
680
|
+
area,
|
|
681
|
+
bounds,
|
|
682
|
+
pick(props.backgroundSize, BackgroundSize{BackgroundSizeLengthPercentage{}}),
|
|
683
|
+
pick(props.backgroundPosition, BackgroundPosition{}),
|
|
684
|
+
pick(props.backgroundRepeat, BackgroundRepeat{}));
|
|
685
|
+
if (tiles.empty()) {
|
|
686
|
+
continue;
|
|
687
|
+
}
|
|
688
|
+
const auto &image = props.backgroundImage[i];
|
|
689
|
+
double w = tiles[0].width, h = tiles[0].height;
|
|
690
|
+
std::optional<SvgGradient> gradient = std::holds_alternative<LinearGradient>(image)
|
|
691
|
+
? std::optional{linearGradient(std::get<LinearGradient>(image), w, h)}
|
|
692
|
+
: radialGradient(std::get<RadialGradient>(image), w, h);
|
|
693
|
+
if (!gradient || gradient->stops.empty()) {
|
|
694
|
+
continue;
|
|
695
|
+
}
|
|
696
|
+
layers.push_back({.gradient = std::move(*gradient), .tiles = std::move(tiles)});
|
|
697
|
+
}
|
|
698
|
+
return layers;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
} // namespace
|
|
702
|
+
|
|
703
|
+
BoxDescription describeBox(const ViewProps &props, const LayoutMetrics &layout) {
|
|
704
|
+
auto metrics = props.resolveBorderMetrics(layout);
|
|
705
|
+
const auto &colors = metrics.borderColors;
|
|
706
|
+
SvgRect bounds{0, 0, layout.frame.size.width, layout.frame.size.height};
|
|
707
|
+
return {
|
|
708
|
+
.bounds = bounds,
|
|
709
|
+
.background = argbOf(props.backgroundColor),
|
|
710
|
+
.backgroundImages = backgroundLayers(props, bounds, widthsOf(metrics.borderWidths)),
|
|
711
|
+
.radii = cornerRadiiOf(metrics.borderRadii),
|
|
712
|
+
.borderWidths = widthsOf(metrics.borderWidths),
|
|
713
|
+
.borderColors = {.top = argbOf(colors.top), .right = argbOf(colors.right), .bottom = argbOf(colors.bottom), .left = argbOf(colors.left)},
|
|
714
|
+
.borderStyle = metrics.borderStyles.isUniform() ? metrics.borderStyles.left : BorderStyle::Solid,
|
|
715
|
+
.clips = props.yogaStyle.overflow() != facebook::yoga::Overflow::Visible,
|
|
716
|
+
.shadows = props.boxShadow,
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
|
|
672
720
|
ViewBox viewBox(const ViewProps &props, const LayoutMetrics &layout) {
|
|
673
721
|
ViewBox box;
|
|
674
722
|
auto metrics = props.resolveBorderMetrics(layout);
|
|
723
|
+
// Not describeBox: its background layers build every tile, which drawViewBox builds once for itself.
|
|
675
724
|
auto radii = cornerRadiiOf(metrics.borderRadii);
|
|
676
725
|
auto widths = widthsOf(metrics.borderWidths);
|
|
677
726
|
bool clips = props.yogaStyle.overflow() != facebook::yoga::Overflow::Visible;
|
|
@@ -728,52 +777,34 @@ ViewBox viewBox(const ViewProps &props, const LayoutMetrics &layout) {
|
|
|
728
777
|
return box;
|
|
729
778
|
}
|
|
730
779
|
|
|
780
|
+
void drawBorder(const BoxDescription &box, SvgCanvas &canvas) {
|
|
781
|
+
const auto &c = box.borderColors;
|
|
782
|
+
std::optional<uint32_t> colors[4] = {c.top, c.right, c.bottom, c.left};
|
|
783
|
+
drawBorderOf(box.bounds, box.borderWidths, colors, box.radii, box.borderStyle, canvas);
|
|
784
|
+
}
|
|
785
|
+
|
|
731
786
|
void drawViewBox(const ViewProps &props, const LayoutMetrics &layout, SvgCanvas &canvas) {
|
|
732
787
|
auto box = viewBox(props, layout);
|
|
733
788
|
if (!box.drawn) {
|
|
734
789
|
return;
|
|
735
790
|
}
|
|
736
|
-
auto
|
|
737
|
-
auto
|
|
738
|
-
auto widths = widthsOf(metrics.borderWidths);
|
|
739
|
-
SvgRect bounds{0, 0, layout.frame.size.width, layout.frame.size.height};
|
|
740
|
-
auto outer = roundedRect(bounds, radii);
|
|
791
|
+
auto described = describeBox(props, layout);
|
|
792
|
+
auto outer = roundedRect(described.bounds, described.radii);
|
|
741
793
|
|
|
742
794
|
if (!box.layerDrawn) {
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
canvas.fill(outer, false, SvgPaint{.argb = *background});
|
|
795
|
+
if (visible(described.background)) {
|
|
796
|
+
canvas.fill(outer, false, SvgPaint{.argb = *described.background});
|
|
746
797
|
}
|
|
747
798
|
}
|
|
748
799
|
|
|
749
|
-
if (!
|
|
750
|
-
// background-origin: padding-box; background-clip: border-box. The first image is on top.
|
|
751
|
-
auto area = inset(bounds, widths);
|
|
800
|
+
if (!described.backgroundImages.empty()) {
|
|
752
801
|
canvas.save();
|
|
753
802
|
canvas.clip(outer, false);
|
|
754
|
-
for (
|
|
755
|
-
|
|
756
|
-
auto tiles = backgroundTiles(
|
|
757
|
-
area,
|
|
758
|
-
bounds,
|
|
759
|
-
pick(props.backgroundSize, BackgroundSize{BackgroundSizeLengthPercentage{}}),
|
|
760
|
-
pick(props.backgroundPosition, BackgroundPosition{}),
|
|
761
|
-
pick(props.backgroundRepeat, BackgroundRepeat{}));
|
|
762
|
-
if (tiles.empty()) {
|
|
763
|
-
continue;
|
|
764
|
-
}
|
|
765
|
-
const auto &image = props.backgroundImage[i];
|
|
766
|
-
double w = tiles[0].width, h = tiles[0].height;
|
|
767
|
-
std::optional<SvgGradient> gradient = std::holds_alternative<LinearGradient>(image)
|
|
768
|
-
? std::optional{linearGradient(std::get<LinearGradient>(image), w, h)}
|
|
769
|
-
: radialGradient(std::get<RadialGradient>(image), w, h);
|
|
770
|
-
if (!gradient || gradient->stops.empty()) {
|
|
771
|
-
continue;
|
|
772
|
-
}
|
|
773
|
-
for (const auto &tile : tiles) {
|
|
803
|
+
for (const auto &layer : described.backgroundImages) {
|
|
804
|
+
for (const auto &tile : layer.tiles) {
|
|
774
805
|
SvgPaint paint;
|
|
775
|
-
paint.gradient =
|
|
776
|
-
paint.gradient->transform = SvgMatrix::translate(tile.x, tile.y) * gradient
|
|
806
|
+
paint.gradient = layer.gradient;
|
|
807
|
+
paint.gradient->transform = SvgMatrix::translate(tile.x, tile.y) * layer.gradient.transform;
|
|
777
808
|
canvas.fill(rectPath(tile), false, paint);
|
|
778
809
|
}
|
|
779
810
|
}
|
|
@@ -781,7 +812,11 @@ void drawViewBox(const ViewProps &props, const LayoutMetrics &layout, SvgCanvas
|
|
|
781
812
|
}
|
|
782
813
|
|
|
783
814
|
if (!box.layerDrawn) {
|
|
784
|
-
|
|
815
|
+
// React Native iOS draws every side in the left side's style.
|
|
816
|
+
auto style = props.resolveBorderMetrics(layout).borderStyles.left;
|
|
817
|
+
const auto &c = described.borderColors;
|
|
818
|
+
std::optional<uint32_t> colors[4] = {c.top, c.right, c.bottom, c.left};
|
|
819
|
+
drawBorderOf(described.bounds, described.borderWidths, colors, described.radii, style, canvas);
|
|
785
820
|
}
|
|
786
821
|
}
|
|
787
822
|
|
|
@@ -42,4 +42,32 @@ std::optional<Point> layerPointAt(const Transform &transform, Point point) {
|
|
|
42
42
|
return Point{static_cast<Float>(ix / iw), static_cast<Float>(iy / iw)};
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
std::optional<PlaneSteps> planeSteps(const Transform &transform) {
|
|
46
|
+
const auto &m = transform.matrix;
|
|
47
|
+
constexpr double kNone = 1e-9;
|
|
48
|
+
if (std::abs(m[3]) > kNone || std::abs(m[7]) > kNone || std::abs(m[15]) < kNone) {
|
|
49
|
+
return std::nullopt;
|
|
50
|
+
}
|
|
51
|
+
// x' = a x + c y + tx, y' = b x + d y + ty, as layerPointAt reads the matrix.
|
|
52
|
+
double a = m[0] / m[15], b = m[1] / m[15], c = m[4] / m[15], d = m[5] / m[15];
|
|
53
|
+
// [a c; b d] = rotate(angle) * [1 shear; 0 1] * scale(sx, sy).
|
|
54
|
+
double sx = std::hypot(a, b);
|
|
55
|
+
double det = a * d - b * c;
|
|
56
|
+
if (sx < kNone || std::abs(det) < kNone) {
|
|
57
|
+
return std::nullopt;
|
|
58
|
+
}
|
|
59
|
+
double cosine = a / sx, sine = b / sx;
|
|
60
|
+
double sy = det / sx;
|
|
61
|
+
double shear = (cosine * c + sine * d) / sy;
|
|
62
|
+
constexpr double kDegrees = 180.0 / 3.14159265358979323846;
|
|
63
|
+
return PlaneSteps{
|
|
64
|
+
.scaleX = static_cast<Float>(sx),
|
|
65
|
+
.scaleY = static_cast<Float>(sy),
|
|
66
|
+
.skewX = static_cast<Float>(std::atan(shear) * kDegrees),
|
|
67
|
+
.rotate = static_cast<Float>(std::atan2(sine, cosine) * kDegrees),
|
|
68
|
+
.translateX = static_cast<Float>(m[12] / m[15]),
|
|
69
|
+
.translateY = static_cast<Float>(m[13] / m[15]),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
45
73
|
} // namespace ngn
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# The Linux build image for the desktop host: AlmaLinux 9, so whatever it builds needs glibc 2.34 at
|
|
2
|
+
# most, with clang and lld from llvm-toolset. CI's host-linux job builds it on each run, and a Mac
|
|
3
|
+
# builds the same image with Docker (arm64, natively), from the repository's root:
|
|
4
|
+
#
|
|
5
|
+
# docker build -t ngn-el9 packages/desktop/native/docker
|
|
6
|
+
# docker run --rm --user "$(id -u):$(id -g)" -e HOME=/tmp -e NGN_DESKTOP_CACHE=/tmp/cache \
|
|
7
|
+
# -v "$PWD:$PWD" -w "$PWD/packages/desktop" ngn-el9 \
|
|
8
|
+
# native/scripts/build.sh --backend none --runtime --test
|
|
9
|
+
#
|
|
10
|
+
# Run it as a user other than root: root reads a file whatever its mode, so the core tests that make
|
|
11
|
+
# one unreadable fail.
|
|
12
|
+
FROM almalinux:9
|
|
13
|
+
|
|
14
|
+
# CRB has ninja, the GTK and libadwaita headers and nghttp2's; EPEL has ccache and Weston. python3
|
|
15
|
+
# builds ICU's filtered data and serves the libcurl client's tests. OpenSSL, nghttp2 and zlib are
|
|
16
|
+
# what the static libcurl links dynamically (cmake/curl.cmake). Xvfb, Weston, Mesa's software
|
|
17
|
+
# drivers, D-Bus and the fonts are for launching the GTK host headless, under X11 and Wayland, and
|
|
18
|
+
# pyatspi reads its accessibility tree over AT-SPI as a screen reader would (atspi-check.py).
|
|
19
|
+
# libsecret is SecureStore's. GStreamer's headers and its base, good and bad-free plugins are the
|
|
20
|
+
# audio and video players' and recorders' (gst-playback.h), and their tests' encoders. The English
|
|
21
|
+
# locales are for the GTK tests of a 12-hour clock (en_US) beside a 24-hour one, and the German for
|
|
22
|
+
# a locale that writes neither AM nor PM (de_DE); both are for the Localization tests too.
|
|
23
|
+
RUN dnf -y install dnf-plugins-core epel-release \
|
|
24
|
+
&& dnf config-manager --set-enabled crb \
|
|
25
|
+
&& dnf -y module enable nodejs:24 \
|
|
26
|
+
&& dnf -y install \
|
|
27
|
+
llvm-toolset clang lld cmake ninja-build ccache \
|
|
28
|
+
git python3 perl perl-Digest-SHA nodejs \
|
|
29
|
+
binutils diffutils file findutils procps-ng which \
|
|
30
|
+
bzip2 tar unzip xz \
|
|
31
|
+
libatomic sqlite-devel openssl-devel libnghttp2-devel zlib-devel \
|
|
32
|
+
gtk4-devel libadwaita-devel pango-devel cairo-devel libsecret-devel \
|
|
33
|
+
gstreamer1-devel gstreamer1-plugins-base-devel gstreamer1-plugins-good gstreamer1-plugins-bad-free \
|
|
34
|
+
xorg-x11-server-Xvfb weston mesa-dri-drivers dbus-daemon dbus-tools at-spi2-core python3-pyatspi \
|
|
35
|
+
dejavu-sans-fonts google-noto-sans-fonts glibc-langpack-en glibc-langpack-de \
|
|
36
|
+
&& dnf clean all
|
|
37
|
+
|
|
38
|
+
ENV CC=clang CXX=clang++
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# The same build and test image on Fedora, for the newer GTK, libadwaita, Mesa and compositors the
|
|
2
|
+
# Linux host also runs on, beside the AlmaLinux 9 one in Dockerfile, which stays the image whose
|
|
3
|
+
# output ships (it keeps the glibc floor, and the GTK 4.12 and libadwaita 1.4 the host builds
|
|
4
|
+
# against). Where el9 runs the fallbacks libadwaita 1.4 needs, this runs the code a newer libadwaita
|
|
5
|
+
# takes instead. The nightly workflow builds the host and runs the core and GTK tests in it, and a
|
|
6
|
+
# Mac builds it the same way, from the repository's root:
|
|
7
|
+
#
|
|
8
|
+
# docker build -f packages/desktop/native/docker/Dockerfile.fedora -t ngn-fedora packages/desktop/native/docker
|
|
9
|
+
# docker run --rm --user "$(id -u):$(id -g)" -e HOME=/tmp -e NGN_DESKTOP_CACHE=/tmp/cache \
|
|
10
|
+
# -v "$PWD:$PWD" -w "$PWD/packages/desktop" ngn-fedora \
|
|
11
|
+
# native/scripts/build.sh --backend gtk --test
|
|
12
|
+
#
|
|
13
|
+
# The tools that start a container take its name from NGN_LINUX_IMAGE, so `NGN_LINUX_IMAGE=ngn-fedora
|
|
14
|
+
# pnpm bench:linux` and a `linuxLauncher()` run in this image instead of `ngn-el9`. Run it as a user
|
|
15
|
+
# other than root, as the el9 image: root reads a file whatever its mode, so the core tests that
|
|
16
|
+
# make one unreadable fail.
|
|
17
|
+
ARG FEDORA=44
|
|
18
|
+
FROM fedora:${FEDORA}
|
|
19
|
+
|
|
20
|
+
# What Dockerfile installs, under Fedora's names: its llvm packages, GTK, libadwaita, libsecret and
|
|
21
|
+
# GStreamer headers with GStreamer's base, good and bad-free plugins, the libraries the static
|
|
22
|
+
# libcurl links dynamically, Xvfb, Weston, Mesa's software drivers, D-Bus, the fonts, the English
|
|
23
|
+
# and German locales the GTK tests set, and pyatspi for the AT-SPI check. Fedora's repositories carry ninja, ccache and Weston, so it needs no CRB and no EPEL.
|
|
24
|
+
RUN dnf -y install \
|
|
25
|
+
clang lld llvm cmake ninja-build ccache \
|
|
26
|
+
git python3 perl perl-Digest-SHA nodejs \
|
|
27
|
+
binutils diffutils file findutils procps-ng which \
|
|
28
|
+
bzip2 tar unzip xz \
|
|
29
|
+
libatomic sqlite-devel openssl-devel libnghttp2-devel zlib-devel \
|
|
30
|
+
gtk4-devel libadwaita-devel pango-devel cairo-devel libsecret-devel \
|
|
31
|
+
gstreamer1-devel gstreamer1-plugins-base-devel gstreamer1-plugins-good gstreamer1-plugins-bad-free \
|
|
32
|
+
xorg-x11-server-Xvfb weston mesa-dri-drivers dbus-daemon dbus-tools at-spi2-core python3-pyatspi \
|
|
33
|
+
dejavu-sans-fonts google-noto-sans-fonts glibc-langpack-en glibc-langpack-de \
|
|
34
|
+
&& dnf clean all
|
|
35
|
+
|
|
36
|
+
ENV CC=clang CXX=clang++
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Fails unless every binary named needs glibc <floor> at most: the highest GLIBC_ symbol version
|
|
3
|
+
# each one imports, read with objdump. A binary that imports none, or that objdump cannot read,
|
|
4
|
+
# fails too.
|
|
5
|
+
#
|
|
6
|
+
# A binary that imports OpenSSL (the host, through libcurl) must also need OpenSSL 3.0.0 at most,
|
|
7
|
+
# the oldest libssl.so.3 a tier 1 distribution ships (Ubuntu 24.04's 3.0.13): el9's headers are
|
|
8
|
+
# 3.5's, and a call newer than 3.0 there would stop the host loading on Ubuntu.
|
|
9
|
+
#
|
|
10
|
+
# glibc-floor.sh <floor, e.g. 2.34> <binary>...
|
|
11
|
+
set -euo pipefail
|
|
12
|
+
floor="${1:?usage: glibc-floor.sh <floor> <binary>...}"
|
|
13
|
+
shift
|
|
14
|
+
[ $# -gt 0 ] || { echo "glibc-floor.sh: no binaries named" >&2; exit 2; }
|
|
15
|
+
openssl_floor=3.0.0
|
|
16
|
+
status=0
|
|
17
|
+
|
|
18
|
+
# The highest of a library's symbol versions a binary imports, by their prefix (GLIBC_, OPENSSL_).
|
|
19
|
+
highest() {
|
|
20
|
+
objdump -T "$2" | { grep -o "$1[0-9][0-9.]*" || true; } | sed "s/^$1//" | sort -uV | tail -n 1
|
|
21
|
+
}
|
|
22
|
+
above() {
|
|
23
|
+
[ "$(printf '%s\n%s\n' "$1" "$2" | sort -V | tail -n 1)" != "$2" ]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
for binary in "$@"; do
|
|
27
|
+
glibc="$(highest GLIBC_ "$binary")"
|
|
28
|
+
if [ -z "$glibc" ]; then
|
|
29
|
+
echo "glibc-floor.sh: $binary imports no GLIBC_ symbol version" >&2
|
|
30
|
+
status=1
|
|
31
|
+
elif above "$glibc" "$floor"; then
|
|
32
|
+
echo "glibc-floor.sh: $binary needs glibc $glibc, above $floor:" >&2
|
|
33
|
+
objdump -T "$binary" | grep -F "GLIBC_$glibc" >&2
|
|
34
|
+
status=1
|
|
35
|
+
else
|
|
36
|
+
echo "$binary: glibc $glibc at most"
|
|
37
|
+
fi
|
|
38
|
+
openssl="$(highest OPENSSL_ "$binary")"
|
|
39
|
+
if [ -n "$openssl" ]; then
|
|
40
|
+
if above "$openssl" "$openssl_floor"; then
|
|
41
|
+
echo "glibc-floor.sh: $binary needs OpenSSL $openssl, above $openssl_floor:" >&2
|
|
42
|
+
objdump -T "$binary" | grep -F "OPENSSL_$openssl" >&2
|
|
43
|
+
status=1
|
|
44
|
+
else
|
|
45
|
+
echo "$binary: OpenSSL $openssl at most"
|
|
46
|
+
fi
|
|
47
|
+
fi
|
|
48
|
+
done
|
|
49
|
+
exit "$status"
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# The GTK 4 backend and the ngn-linux binary. GTK 4.10 is the floor (el9 ships 4.12) and newer API
|
|
2
|
+
# is refused at compile time; libadwaita is linked for its style manager and the header bar, and
|
|
3
|
+
# newer libadwaita (AdwDialog) is found at run time.
|
|
4
|
+
# Both come from pkg-config: the distribution's on Linux, Homebrew's on a Mac, where the backend
|
|
5
|
+
# builds as a dev loop.
|
|
6
|
+
#
|
|
7
|
+
# Every source but main.cpp, compiled once into objects the binary and the GTK view tests both link.
|
|
8
|
+
find_package(PkgConfig REQUIRED)
|
|
9
|
+
pkg_check_modules(NGN_GTK REQUIRED IMPORTED_TARGET gtk4>=4.10 libadwaita-1>=1.4 pangocairo gio-unix-2.0)
|
|
10
|
+
# Xlib, for an input script's steps posted to the X server (input-replay.h); a Mac's GTK has no X11.
|
|
11
|
+
if(NOT APPLE)
|
|
12
|
+
pkg_check_modules(NGN_X11 REQUIRED IMPORTED_TARGET x11)
|
|
13
|
+
endif()
|
|
14
|
+
# libsecret, SecureStore's (0.20 keeps secrets through the Secret portal inside a Flatpak). Homebrew
|
|
15
|
+
# has none, so on a Mac the dev loop goes without it and SecureStore is absent.
|
|
16
|
+
if(APPLE)
|
|
17
|
+
pkg_check_modules(NGN_SECRET IMPORTED_TARGET libsecret-1>=0.20)
|
|
18
|
+
else()
|
|
19
|
+
pkg_check_modules(NGN_SECRET REQUIRED IMPORTED_TARGET libsecret-1>=0.20)
|
|
20
|
+
endif()
|
|
21
|
+
# fontconfig, which Fonts adds an app's font files to, and Pango's fontconfig font map, told to
|
|
22
|
+
# look again (fonts.h).
|
|
23
|
+
pkg_check_modules(NGN_FONTCONFIG REQUIRED IMPORTED_TARGET fontconfig pangoft2)
|
|
24
|
+
# GStreamer 1.22, which plays and records audio and video (gst-playback.h, audio.h): el9 ships
|
|
25
|
+
# 1.22. Homebrew's GStreamer is not looked for, so on a Mac the dev loop goes without it and the
|
|
26
|
+
# media modules are absent.
|
|
27
|
+
if(APPLE)
|
|
28
|
+
set(NGN_GSTREAMER_FOUND FALSE)
|
|
29
|
+
else()
|
|
30
|
+
pkg_check_modules(NGN_GSTREAMER REQUIRED IMPORTED_TARGET gstreamer-1.0>=1.22 gstreamer-app-1.0>=1.22 gstreamer-video-1.0>=1.22 gstreamer-pbutils-1.0>=1.22)
|
|
31
|
+
endif()
|
|
32
|
+
# GTK's own print dialog, which prints a PDF where no Print portal answers (printing.h); part of
|
|
33
|
+
# GTK on Linux and in Homebrew's.
|
|
34
|
+
pkg_check_modules(NGN_UNIX_PRINT IMPORTED_TARGET gtk4-unix-print)
|
|
35
|
+
|
|
36
|
+
add_library(ngn_gtk OBJECT
|
|
37
|
+
accent-colour.cpp
|
|
38
|
+
accessibility-settings.cpp
|
|
39
|
+
accessible.cpp
|
|
40
|
+
app-info.cpp
|
|
41
|
+
accessible-text.cpp
|
|
42
|
+
alerts.cpp
|
|
43
|
+
animation-frames.cpp
|
|
44
|
+
app-windows.cpp
|
|
45
|
+
auth-session.cpp
|
|
46
|
+
battery.cpp
|
|
47
|
+
box-paint.cpp
|
|
48
|
+
cairo-canvas.cpp
|
|
49
|
+
focus.cpp
|
|
50
|
+
capture.cpp
|
|
51
|
+
clock-format.cpp
|
|
52
|
+
crypto.cpp
|
|
53
|
+
dbus-properties.cpp
|
|
54
|
+
drag-and-drop.cpp
|
|
55
|
+
file-dialogs.cpp
|
|
56
|
+
file-system.cpp
|
|
57
|
+
fonts.cpp
|
|
58
|
+
gtk-backend.cpp
|
|
59
|
+
host-sources.cpp
|
|
60
|
+
image-manipulator.cpp
|
|
61
|
+
image-view.cpp
|
|
62
|
+
input-replay.cpp
|
|
63
|
+
locales.cpp
|
|
64
|
+
location.cpp
|
|
65
|
+
launcher-badge.cpp
|
|
66
|
+
menus.cpp
|
|
67
|
+
native-controls.cpp
|
|
68
|
+
network-state.cpp
|
|
69
|
+
notifications.cpp
|
|
70
|
+
pango-text.cpp
|
|
71
|
+
portal.cpp
|
|
72
|
+
printing.cpp
|
|
73
|
+
proxy-resolver.cpp
|
|
74
|
+
screens.cpp
|
|
75
|
+
secret-store.cpp
|
|
76
|
+
scroll-view.cpp
|
|
77
|
+
settings-portal.cpp
|
|
78
|
+
split-view.cpp
|
|
79
|
+
status-notifier.cpp
|
|
80
|
+
surface-input.cpp
|
|
81
|
+
system-access.cpp
|
|
82
|
+
text-field.cpp
|
|
83
|
+
view-widget.cpp
|
|
84
|
+
window-scale.cpp)
|
|
85
|
+
target_link_libraries(ngn_gtk PUBLIC ngn_core_runtime ngn_curl ngn_openssl ngn_libraries PkgConfig::NGN_GTK PkgConfig::NGN_FONTCONFIG)
|
|
86
|
+
if(NOT APPLE)
|
|
87
|
+
target_link_libraries(ngn_gtk PUBLIC PkgConfig::NGN_X11)
|
|
88
|
+
endif()
|
|
89
|
+
if(NGN_SECRET_FOUND)
|
|
90
|
+
target_link_libraries(ngn_gtk PUBLIC PkgConfig::NGN_SECRET)
|
|
91
|
+
target_compile_definitions(ngn_gtk PUBLIC NGN_LIBSECRET=1)
|
|
92
|
+
endif()
|
|
93
|
+
if(NGN_GSTREAMER_FOUND)
|
|
94
|
+
target_sources(ngn_gtk PRIVATE audio.cpp camera.cpp gst-frames.cpp gst-playback.cpp video.cpp)
|
|
95
|
+
target_link_libraries(ngn_gtk PUBLIC PkgConfig::NGN_GSTREAMER)
|
|
96
|
+
target_compile_definitions(ngn_gtk PUBLIC NGN_GSTREAMER=1)
|
|
97
|
+
endif()
|
|
98
|
+
if(NGN_UNIX_PRINT_FOUND)
|
|
99
|
+
target_link_libraries(ngn_gtk PUBLIC PkgConfig::NGN_UNIX_PRINT)
|
|
100
|
+
target_compile_definitions(ngn_gtk PUBLIC NGN_UNIX_PRINT=1)
|
|
101
|
+
endif()
|
|
102
|
+
target_compile_options(ngn_gtk PUBLIC -Wall -Werror -Wno-unused-parameter -Wno-missing-field-initializers)
|
|
103
|
+
target_compile_definitions(ngn_gtk PUBLIC
|
|
104
|
+
GDK_VERSION_MIN_REQUIRED=GDK_VERSION_4_10 GDK_VERSION_MAX_ALLOWED=GDK_VERSION_4_10
|
|
105
|
+
ADW_VERSION_MIN_REQUIRED=ADW_VERSION_1_4 ADW_VERSION_MAX_ALLOWED=ADW_VERSION_1_4)
|
|
106
|
+
|
|
107
|
+
add_executable(ngn-linux main.cpp)
|
|
108
|
+
# The autolinked code (cmake/linked-modules.cmake), which only a target linking it directly takes whole.
|
|
109
|
+
target_link_libraries(ngn-linux PRIVATE ngn_gtk ${NGN_LINKED})
|
|
110
|
+
# The React Native the host is built from, which PlatformConstants reports.
|
|
111
|
+
file(READ ${RN_DIR}/package.json _rn_package)
|
|
112
|
+
string(JSON _rn_version GET "${_rn_package}" version)
|
|
113
|
+
target_compile_definitions(ngn-linux PRIVATE NGN_REACT_NATIVE_VERSION="${_rn_version}")
|
|
114
|
+
# The hermesc built with the Hermes the binary links, beside it, as ngn-macos has it.
|
|
115
|
+
add_custom_command(TARGET ngn-linux POST_BUILD
|
|
116
|
+
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${NGN_HERMESC} $<TARGET_FILE_DIR:ngn-linux>/hermesc
|
|
117
|
+
VERBATIM)
|
|
118
|
+
|
|
119
|
+
# The GTK view tests: views mounted from Fabric mutations into a window GTK draws, through the
|
|
120
|
+
# backend the binary uses. Built with the core tests, and run beside them.
|
|
121
|
+
if(NGN_TESTS)
|
|
122
|
+
set(ngn_gtk_test_SRC ../core/tests/main.cpp tests/accent-colour.test.cpp tests/accessibility-settings.test.cpp tests/accessible.test.cpp tests/alerts.test.cpp tests/animation-frames.test.cpp tests/app-windows.test.cpp tests/audio.test.cpp tests/camera.test.cpp tests/chrome.test.cpp tests/clock-format.test.cpp tests/controls.test.cpp tests/drag-and-drop.test.cpp tests/focus.test.cpp tests/fonts.test.cpp tests/image-manipulator.test.cpp tests/image-view.test.cpp tests/input-replay.test.cpp tests/input.test.cpp tests/linking.test.cpp tests/locales.test.cpp tests/machine.test.cpp tests/menus.test.cpp tests/notifications.test.cpp tests/paint.test.cpp tests/proxy-resolver.test.cpp
|
|
123
|
+
tests/screens.test.cpp tests/scroll-view.test.cpp tests/secret-store.test.cpp tests/split-view.test.cpp tests/status-notifier.test.cpp tests/svg.test.cpp tests/system-access.test.cpp tests/system-modules.test.cpp tests/system-services.test.cpp tests/text.test.cpp tests/video.test.cpp tests/views.test.cpp)
|
|
124
|
+
add_executable(ngn_gtk_tests ${ngn_gtk_test_SRC} ../core/testing/fake-network.cpp ../core/testing/fake-system.cpp)
|
|
125
|
+
target_include_directories(ngn_gtk_tests PRIVATE ../core/tests ../core/testing)
|
|
126
|
+
target_link_libraries(ngn_gtk_tests PRIVATE ngn_gtk doctest)
|
|
127
|
+
if(NGN_DOCTEST_SOURCE_OPTIONS)
|
|
128
|
+
set_source_files_properties(${ngn_gtk_test_SRC}
|
|
129
|
+
PROPERTIES COMPILE_OPTIONS "${NGN_DOCTEST_SOURCE_OPTIONS}")
|
|
130
|
+
endif()
|
|
131
|
+
if(NOT APPLE)
|
|
132
|
+
target_compile_options(ngn_gtk_tests PRIVATE
|
|
133
|
+
$<$<CXX_COMPILER_ID:Clang>:-Wno-error=\#warnings>
|
|
134
|
+
$<$<CXX_COMPILER_ID:GNU>:-Wno-error=cpp>)
|
|
135
|
+
endif()
|
|
136
|
+
add_test(NAME gtk COMMAND ngn_gtk_tests)
|
|
137
|
+
endif()
|