Migrate tauri to new config

This commit is contained in:
Vladimir Stoilov 2024-04-24 15:30:46 +03:00
parent 7ee1faa68c
commit f15958b091
No known key found for this signature in database
GPG key ID: 2F190B67A43A81AF
15 changed files with 193 additions and 82 deletions

View file

@ -290,31 +290,29 @@ rust-base:
# Install library dependencies for all supported architectures
# required for succesfully linking.
FOR arch IN amd64 arm64 armhf
RUN apt-get install --no-install-recommends -qq \
libsoup-3.0-0:${arch} \
libwebkit2gtk-4.1-0:${arch} \
libssl3:${arch} \
libayatana-appindicator3-1:${arch} \
librsvg2-bin:${arch} \
libgtk-3-0:${arch} \
libjavascriptcoregtk-4.1-0:${arch} \
libssl-dev:${arch} \
libayatana-appindicator3-dev:${arch} \
librsvg2-dev:${arch} \
libgtk-3-dev:${arch} \
libjavascriptcoregtk-4.1-dev:${arch}
END
RUN apt-get install --no-install-recommends -y \
libsoup-3.0-0 \
libwebkit2gtk-4.1-0 \
libssl3 \
libayatana-appindicator3-1 \
librsvg2-bin \
libgtk-3-0 \
libjavascriptcoregtk-4.1-0 \
libssl-dev \
libayatana-appindicator3-dev \
librsvg2-dev \
libgtk-3-dev \
libjavascriptcoregtk-4.1-dev
# Note(ppacher): I've no idea why we need to explicitly create those symlinks:
# Some how all the other libs work but libsoup and libwebkit2gtk do not create the link file
RUN cd /usr/lib/aarch64-linux-gnu && \
ln -s libwebkit2gtk-4.1.so.0 libwebkit2gtk-4.1.so && \
ln -s libsoup-3.0.so.0 libsoup-3.0.so
# RUN cd /usr/lib/aarch64-linux-gnu && \
# ln -s libwebkit2gtk-4.1.so.0 libwebkit2gtk-4.1.so && \
# ln -s libsoup-3.0.so.0 libsoup-3.0.so
RUN cd /usr/lib/arm-linux-gnueabihf && \
ln -s libwebkit2gtk-4.1.so.0 libwebkit2gtk-4.1.so && \
ln -s libsoup-3.0.so.0 libsoup-3.0.so
# RUN cd /usr/lib/arm-linux-gnueabihf && \
# ln -s libwebkit2gtk-4.1.so.0 libwebkit2gtk-4.1.so && \
# ln -s libsoup-3.0.so.0 libsoup-3.0.so
# For what ever reason trying to install the gcc compilers together with the above
# command makes apt fail due to conflicts with gcc-multilib. Installing in a separate
@ -341,8 +339,8 @@ rust-base:
DO rust+INIT --keep_fingerprints=true
# For now we need tauri-cli 1.5 for bulding
DO rust+CARGO --args="install tauri-cli --version ^1.5.11"
# For now we need tauri-cli 2.0.0 for bulding
DO rust+CARGO --args="install tauri-cli --version ^2.0.0-beta"
# Required for cross compilation to work.
ENV PKG_CONFIG_ALLOW_CROSS=1
@ -371,7 +369,7 @@ tauri-build:
FROM +tauri-src
ARG --required target
ARG output=".*/release/(([^\./]+|([^\./]+\.(dll|exe)))|bundle/.*\.(deb|msi|AppImage))"
ARG output=".*/release/(([^\./]+|([^\./]+\.(dll|exe)))|bundle/.*\.(deb|rpm|msi|AppImage))"
ARG bundle="none"
@ -413,7 +411,7 @@ tauri-build:
# For, now, we just directly mount the rust target cache and call cargo ourself.
DO rust+SET_CACHE_MOUNTS_ENV
RUN --mount=$EARTHLY_RUST_TARGET_CACHE cargo tauri build --bundles "${bundle}" --ci --target="${target}"
RUN --mount=$EARTHLY_RUST_TARGET_CACHE cargo tauri build --ci --target="${target}"
DO rust+COPY_OUTPUT --output="${output}"
# BUG(cross-compilation):

View file

@ -29,7 +29,7 @@
"@tauri-apps/plugin-dialog": ">=2.0.0-beta.0",
"@tauri-apps/plugin-notification": ">=2.0.0-beta.0",
"@tauri-apps/plugin-os": ">=2.0.0-beta.0",
"@tauri-apps/plugin-shell": ">=2.0.0-beta.0",
"@tauri-apps/plugin-shell": "^2.0.0-beta",
"autoprefixer": "^10.4.14",
"d3": "^7.8.4",
"data-urls": "^5.0.0",

View file

@ -6597,9 +6597,9 @@ checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f"
[[package]]
name = "tauri"
version = "2.0.0-beta.15"
version = "2.0.0-beta.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd0aba659957a3f1f1666acbf17723e8d41dcc177539bf1adbe55305f5d7118a"
checksum = "4d411ebb670bbe5cf948f6c24978632937329748b499de1619ab55ad31512652"
dependencies = [
"anyhow",
"bytes",
@ -6633,35 +6633,35 @@ dependencies = [
"tauri-macros",
"tauri-runtime",
"tauri-runtime-wry",
"tauri-utils 2.0.0-beta.12",
"tauri-utils 2.0.0-beta.13",
"thiserror",
"tokio",
"tray-icon",
"url",
"urlpattern",
"webkit2gtk",
"webview2-com",
"webview2-com 0.30.0",
"window-vibrancy",
"windows 0.54.0",
"windows 0.56.0",
]
[[package]]
name = "tauri-build"
version = "2.0.0-beta.12"
version = "2.0.0-beta.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33de24aabe2b9c340d67005800cb6dd40aac5283126a42896fc8eec0b87cbe45"
checksum = "abcf98a9b4527567c3e5ca9723431d121e001c2145651b3fa044d22b5e025a7e"
dependencies = [
"anyhow",
"cargo_toml",
"dirs-next",
"glob",
"heck 0.4.1",
"heck 0.5.0",
"json-patch",
"schemars",
"semver",
"serde",
"serde_json",
"tauri-utils 2.0.0-beta.12",
"tauri-utils 2.0.0-beta.13",
"tauri-winres",
"toml 0.8.12",
"walkdir",
@ -6698,7 +6698,7 @@ dependencies = [
"strsim 0.11.1",
"tar",
"tauri-icns",
"tauri-utils 2.0.0-beta.12",
"tauri-utils 2.0.0-beta.13",
"tempfile",
"thiserror",
"time",
@ -6766,7 +6766,7 @@ dependencies = [
"tauri-bundler",
"tauri-icns",
"tauri-utils 1.5.3",
"tauri-utils 2.0.0-beta.12",
"tauri-utils 2.0.0-beta.13",
"thiserror",
"tokio",
"toml 0.8.12",
@ -6780,9 +6780,9 @@ dependencies = [
[[package]]
name = "tauri-codegen"
version = "2.0.0-beta.12"
version = "2.0.0-beta.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d1d211268a9590bbf75cc85b47208f59b447626c76396256e12479ac7df6c8b"
checksum = "b383f341efb803852b0235a2f330ca90c4c113f422dd6d646b888685b372cace"
dependencies = [
"base64 0.22.0",
"brotli",
@ -6797,7 +6797,7 @@ dependencies = [
"serde_json",
"sha2",
"syn 2.0.60",
"tauri-utils 2.0.0-beta.12",
"tauri-utils 2.0.0-beta.13",
"thiserror",
"time",
"url",
@ -6817,16 +6817,16 @@ dependencies = [
[[package]]
name = "tauri-macros"
version = "2.0.0-beta.12"
version = "2.0.0-beta.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b096f63f2724a1280ae0f5a34d0731de18ca18305e2ef6e5e9a39bb2710e8a85"
checksum = "71be71718cfe48b149507157bfbad0e2ba0e98ea51658be26c7c677eb188fb0c"
dependencies = [
"heck 0.4.1",
"proc-macro2",
"quote",
"syn 2.0.60",
"tauri-codegen",
"tauri-utils 2.0.0-beta.12",
"tauri-utils 2.0.0-beta.13",
]
[[package]]
@ -6841,7 +6841,7 @@ dependencies = [
"schemars",
"serde",
"serde_json",
"tauri-utils 2.0.0-beta.12",
"tauri-utils 2.0.0-beta.13",
"toml 0.8.12",
"walkdir",
]
@ -6989,9 +6989,9 @@ dependencies = [
[[package]]
name = "tauri-runtime"
version = "2.0.0-beta.12"
version = "2.0.0-beta.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96c957749c40db7999959f379f799db095f2248a80bdbb13d8c078f6c299240e"
checksum = "c7439729d0107c9797764919c39c4a4cc3af64306faaa48271da50d8eb4c0283"
dependencies = [
"dpi",
"gtk",
@ -7000,17 +7000,17 @@ dependencies = [
"raw-window-handle 0.6.0",
"serde",
"serde_json",
"tauri-utils 2.0.0-beta.12",
"tauri-utils 2.0.0-beta.13",
"thiserror",
"url",
"windows 0.54.0",
"windows 0.56.0",
]
[[package]]
name = "tauri-runtime-wry"
version = "2.0.0-beta.12"
version = "2.0.0-beta.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b937adb1cf3fa0457928ace959ca3fc1a85ddd69f56b124682d40f3e5683e60"
checksum = "0c38dcfa7f8c2b2e344c7401972e0ddaaec4fa655666788d94b1852d6c4a7fe8"
dependencies = [
"cocoa",
"gtk",
@ -7022,11 +7022,11 @@ dependencies = [
"softbuffer",
"tao",
"tauri-runtime",
"tauri-utils 2.0.0-beta.12",
"tauri-utils 2.0.0-beta.13",
"url",
"webkit2gtk",
"webview2-com",
"windows 0.54.0",
"webview2-com 0.30.0",
"windows 0.56.0",
"wry",
]
@ -7063,9 +7063,9 @@ dependencies = [
[[package]]
name = "tauri-utils"
version = "2.0.0-beta.12"
version = "2.0.0-beta.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "760ac613d7f0de95067bcbcbcea175fe1df88fc4ab59c7f0b2cc2d01dc16a199"
checksum = "d4709765385f035338ecc330f3fba753b8ee283c659c235da9768949cdb25469"
dependencies = [
"aes-gcm",
"brotli",
@ -7074,7 +7074,7 @@ dependencies = [
"dunce",
"getrandom 0.2.14",
"glob",
"heck 0.4.1",
"heck 0.5.0",
"html5ever",
"infer 0.15.0",
"json-patch",
@ -8184,13 +8184,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38d5949fc3f537e90240c3e4f78dda2fa0431b671d50845a2f582173ef8a1201"
dependencies = [
"webview2-com-macros",
"webview2-com-sys",
"webview2-com-sys 0.29.0",
"windows 0.54.0",
"windows-core 0.54.0",
"windows-implement 0.53.0",
"windows-interface 0.53.0",
]
[[package]]
name = "webview2-com"
version = "0.30.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c914dd492a52f0377bef56fd1b6e74a79090f9ee631d625d5b505a00e4538b6"
dependencies = [
"webview2-com-macros",
"webview2-com-sys 0.30.0",
"windows 0.56.0",
"windows-core 0.56.0",
"windows-implement 0.56.0",
"windows-interface 0.56.0",
]
[[package]]
name = "webview2-com-macros"
version = "0.7.0"
@ -8213,6 +8227,17 @@ dependencies = [
"windows-core 0.54.0",
]
[[package]]
name = "webview2-com-sys"
version = "0.30.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a46bcf03482ec28eeb764ca788f67998cde4213adfbbfa90462622058530f5e"
dependencies = [
"thiserror",
"windows 0.56.0",
"windows-core 0.56.0",
]
[[package]]
name = "weezl"
version = "0.1.8"
@ -8719,7 +8744,7 @@ dependencies = [
"thiserror",
"webkit2gtk",
"webkit2gtk-sys",
"webview2-com",
"webview2-com 0.29.0",
"windows 0.54.0",
"windows-version",
"x11-dl",

View file

@ -12,11 +12,11 @@ rust-version = "1.60"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[build-dependencies]
tauri-build = { version = "2.0.0-beta.12", features = [] }
tauri-build = { version = "2.0.0-beta.13", features = [] }
[dependencies]
# Tauri
tauri = { version = "2.0.0-beta.12", features = ["tray-icon", "image-png"] }
tauri = { version = "2.0.0-beta.16", features = ["tray-icon", "image-png"] }
tauri-plugin-shell = "2.0.0-beta"
tauri-plugin-dialog = "2.0.0-beta"
tauri-plugin-clipboard-manager = "2.0.0-beta"
@ -25,7 +25,7 @@ tauri-plugin-single-instance = "2.0.0-beta"
tauri-plugin-cli = "2.0.0-beta"
tauri-plugin-notification = "2.0.0-beta"
tauri-cli = "2.0.0-beta.12"
tauri-cli = "2.0.0-beta.13"
# General
serde_json = "1.0"

View file

@ -0,0 +1,32 @@
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "Capability for the main window",
"windows": [
"main",
"splash"
],
"remote": {
"urls": [
"http://localhost:817"
]
},
"permissions": [
"path:default",
"event:allow-listen",
"event:allow-unlisten",
"event:allow-emit",
"event:allow-emit-to",
"window:allow-hide",
"window:allow-show",
"window:allow-is-visible",
"window:allow-set-focus",
"app:default",
"image:default",
"resources:default",
"menu:default",
"tray:default",
"shell:allow-open",
"notification:default"
]
}

View file

@ -1,17 +0,0 @@
{
"identifier": "migrated",
"description": "permissions that were migrated from v1",
"local": true,
"windows": [
"main"
],
"permissions": [
"path:default",
"event:default",
"window:default",
"app:default",
"resources:default",
"menu:default",
"tray:default"
]
}

File diff suppressed because one or more lines are too long

View file

@ -1 +1 @@
{"migrated":{"identifier":"migrated","description":"permissions that were migrated from v1","local":true,"windows":["main"],"permissions":["path:default","event:default","window:default","app:default","resources:default","menu:default","tray:default"]}}
{"default":{"identifier":"default","description":"Capability for the main window","remote":{"urls":["http://localhost:817"]},"local":true,"windows":["main","splash"],"permissions":["path:default","event:allow-listen","event:allow-unlisten","event:allow-emit","event:allow-emit-to","window:allow-hide","window:allow-show","window:allow-is-visible","window:allow-set-focus","app:default","image:default","resources:default","menu:default","tray:default","shell:allow-open","notification:default"]}}

View file

@ -2043,6 +2043,13 @@
"window:allow-start-dragging"
]
},
{
"description": "window:allow-start-resize-dragging -> Enables the start_resize_dragging command without any pre-configured scope.",
"type": "string",
"enum": [
"window:allow-start-resize-dragging"
]
},
{
"description": "window:allow-theme -> Enables the theme command without any pre-configured scope.",
"type": "string",
@ -2463,6 +2470,13 @@
"window:deny-start-dragging"
]
},
{
"description": "window:deny-start-resize-dragging -> Denies the start_resize_dragging command without any pre-configured scope.",
"type": "string",
"enum": [
"window:deny-start-resize-dragging"
]
},
{
"description": "window:deny-theme -> Denies the theme command without any pre-configured scope.",
"type": "string",

View file

@ -2043,6 +2043,13 @@
"window:allow-start-dragging"
]
},
{
"description": "window:allow-start-resize-dragging -> Enables the start_resize_dragging command without any pre-configured scope.",
"type": "string",
"enum": [
"window:allow-start-resize-dragging"
]
},
{
"description": "window:allow-theme -> Enables the theme command without any pre-configured scope.",
"type": "string",
@ -2463,6 +2470,13 @@
"window:deny-start-dragging"
]
},
{
"description": "window:deny-start-resize-dragging -> Denies the start_resize_dragging command without any pre-configured scope.",
"type": "string",
"enum": [
"window:deny-start-resize-dragging"
]
},
{
"description": "window:deny-theme -> Denies the theme command without any pre-configured scope.",
"type": "string",

View file

@ -34,7 +34,7 @@ use std::{
use log::{debug, error};
use serde;
use std::sync::Mutex;
use tauri::{AppHandle, EventTarget, Manager, Runtime};
use tauri::{AppHandle, Manager, Runtime};
pub trait Handler {
fn on_connect(&mut self, cli: PortAPI) -> ();

View file

@ -143,6 +143,11 @@ pub fn may_navigate_to_ui(win: &mut WebviewWindow, force: bool) {
#[cfg(debug_assertions)]
{
// Only for dev build
// Allow connection to http://localhost:4200
let capabilities = include_str!("../capabilities/default.json")
.replace("http://localhost:817", "http://localhost:4200");
let _ = win.add_capability(capabilities);
debug!("[tauri] navigating to http://localhost:4200");
win.navigate("http://localhost:4200".parse().unwrap());
}

View file

@ -38,9 +38,49 @@
"identifier": "io.safing.portmaster",
"app": {
"withGlobalTauri": true,
"windows": []
"security": {
"csp": null
}
},
"bundle": {
"active": true,
"category": "Utility",
"copyright": "Safing Limited Inc",
"linux": {
"deb": {
"depends": [
"libayatana-appindicator3"
],
"desktopTemplate": "../../../packaging/linux/portmaster.desktop",
"files": {
"/usr/lib/systemd/system/portmaster.service": "../../../packaging/linux/portmaster.service",
"/etc/xdg/autostart/portmaster.desktop": "../../../packaging/linux/portmaster-autostart.desktop"
},
"postInstallScript": "../../../packaging/linux/postinst",
"postRemoveScript": "../../../packaging/linux/postrm"
},
"rpm": {
"depends": [
"libayatana-appindicator-gtk3"
],
"desktopTemplate": "../../../packaging/linux/portmaster.desktop",
"release": "1",
"files": {
"/usr/lib/systemd/system/portmaster.service": "../../../packaging/linux/portmaster.service",
"/etc/xdg/autostart/portmaster.desktop": "../../../packaging/linux/portmaster-autostart.desktop"
},
"postInstallScript": "../../../packaging/linux/postinst",
"postRemoveScript": "../../../packaging/linux/postrm"
}
},
"externalBin": [
"binaries/portmaster-start",
"binaries/portmaster-core"
],
"targets": [
"deb",
"rpm"
],
"icon": [
"../assets/icons/pm_dark_512.png",
"../assets/icons/pm_dark_512.ico",