refactor: as patch

This commit is contained in:
Kainoa Kanter 2026-02-21 14:54:20 -07:00
parent ce7d9d8dfd
commit b75eba06f5
No known key found for this signature in database
GPG key ID: 8703CACD01000000
3 changed files with 156 additions and 54 deletions

View file

@ -1,7 +1,7 @@
pkgbase = surrealist-cef
pkgdesc = Surrealist is the ultimate way to visually manage your SurrealDB database (Experimental CEF runtime)
pkgver = 3.7.2
pkgrel = 1
pkgrel = 2
url = https://github.com/surrealdb/surrealist
arch = x86_64
arch = aarch64
@ -34,13 +34,16 @@ pkgbase = surrealist-cef
depends = openssl
depends = pango
depends = wayland
optdepends = surrealdb: non-sandboxed SurrealDB instance
provides = surrealist
conflicts = surrealist
conflicts = surrealist-bin
source = https://github.com/surrealdb/surrealist/archive/refs/tags/surrealist-v3.7.2.tar.gz
source = cef-runtime.patch
source = surrealist
source = Surrealist.desktop
sha256sums = 51d6ae88a746a4a5cbce6b19aaf6778acffd990f7b26e5e9ca8e20348c88f729
sha256sums = 1790c8fdaec8750844c69d6d1798b41236504461313764c6f740dad0a56376a7
sha256sums = 9f2c7374511c39bb98cb8a41f85908b76f90052904edb88b17a1523e40942fb1
sha256sums = 94f0619847e1136a07c7386c9bf20fec15ff29c69c4dede523958beeaed28427

View file

@ -3,7 +3,7 @@
_pkgname=surrealist
pkgname="$_pkgname-cef"
pkgver=3.7.2
pkgrel=1
pkgrel=2
pkgdesc="Surrealist is the ultimate way to visually manage your SurrealDB database (Experimental CEF runtime)"
arch=("x86_64" "aarch64")
url="https://github.com/surrealdb/surrealist"
@ -41,10 +41,17 @@ makedepends=(
'git'
'jq'
)
optdepends=('surrealdb: non-sandboxed SurrealDB instance')
provides=("$_pkgname")
conflicts=("$_pkgname" "$_pkgname-bin")
source=("$url/archive/refs/tags/surrealist-v$pkgver.tar.gz" "surrealist" "Surrealist.desktop")
source=(
"$url/archive/refs/tags/surrealist-v$pkgver.tar.gz"
'cef-runtime.patch'
'surrealist'
'Surrealist.desktop'
)
sha256sums=('51d6ae88a746a4a5cbce6b19aaf6778acffd990f7b26e5e9ca8e20348c88f729'
'1790c8fdaec8750844c69d6d1798b41236504461313764c6f740dad0a56376a7'
'9f2c7374511c39bb98cb8a41f85908b76f90052904edb88b17a1523e40942fb1'
'94f0619847e1136a07c7386c9bf20fec15ff29c69c4dede523958beeaed28427')
@ -53,6 +60,8 @@ _cef_ver="144.0.7"
prepare() {
cd "./$_srcdir"
patch -Np0 < "$srcdir/cef-runtime.patch" || true
if ! command -v bun &> /dev/null; then
echo "Bun was not found. Please install bun from https://bun.com/, or install the bun AUR package."
@ -65,12 +74,12 @@ prepare() {
fi
export CARGO_HOME="$srcdir/.cargo-tauri-cef"
msg "Installing tauri-cli from CEF branch (this may take a while)..."
cargo install tauri-cli \
--git https://github.com/tauri-apps/tauri \
--branch feat/cef \
--root "$srcdir/.cargo-tauri-cef" \
--locked # --force
msg "Installing JS dependencies"
bun i
bun run license-report
@ -84,59 +93,10 @@ build() {
export CEF_PATH="$srcdir/cef"
mkdir -p "$CEF_PATH"
if ! grep -q '"cef"' src-tauri/Cargo.toml; then
# Swap wry for cef in the tauri dependency
sed -i 's/^tauri = { version = "2\.4\.0", features = \["devtools"\] }/tauri = { version = "2.4.0", default-features = false, features = ["cef", "devtools"] }/' src-tauri/Cargo.toml
cat >> src-tauri/Cargo.toml <<EOF
[patch.crates-io]
tauri = { git = "https://github.com/tauri-apps/tauri", branch = "feat/cef" }
tauri-build = { git = "https://github.com/tauri-apps/tauri", branch = "feat/cef" }
tauri-utils = { git = "https://github.com/tauri-apps/tauri", branch = "feat/cef" }
tauri-runtime = { git = "https://github.com/tauri-apps/tauri", branch = "feat/cef" }
tauri-runtime-wry = { git = "https://github.com/tauri-apps/tauri", branch = "feat/cef" }
tauri-runtime-cef = { git = "https://github.com/tauri-apps/tauri", branch = "feat/cef" }
tauri-macros = { git = "https://github.com/tauri-apps/tauri", branch = "feat/cef" }
tauri-plugin = { git = "https://github.com/tauri-apps/tauri", branch = "feat/cef" }
tauri-codegen = { git = "https://github.com/tauri-apps/tauri", branch = "feat/cef" }
tauri-plugin-fs = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "feat/cef" }
tauri-plugin-os = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "feat/cef" }
tauri-plugin-log = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "feat/cef" }
tauri-plugin-http = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "feat/cef" }
tauri-plugin-shell = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "feat/cef" }
tauri-plugin-dialog = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "feat/cef" }
tauri-plugin-process = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "feat/cef" }
tauri-plugin-updater = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "feat/cef" }
tauri-plugin-deep-link = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "feat/cef" }
tauri-plugin-localhost = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "feat/cef" }
tauri-plugin-single-instance = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "feat/cef" }
EOF
fi
# Remove the lockfile so Cargo re-resolves against the patched git crates
# instead of the locked crates.io versions which don't have the cef feature
rm -f src-tauri/Cargo.lock
# Patch Surrealist source for CEF branch API changes
sed -i \
-e '/^use /!s/tauri::Window\b/tauri::Window<tauri::Cef>/g' \
-e '/^use /!s/tauri::WebviewWindow\b/tauri::WebviewWindow<tauri::Cef>/g' \
src-tauri/src/window.rs \
src-tauri/src/open.rs \
src-tauri/src/database/mod.rs
sed -i \
-e '/^use /!s/\bAppHandle\b/AppHandle<tauri::Cef>/g' \
-e '/^use /!s/\bWindow\b/Window<tauri::Cef>/g' \
src-tauri/src/window.rs \
src-tauri/src/open.rs \
src-tauri/src/main.rs
# Fix Uuid::new_v4: ensure v4 feature is available
grep -q '^uuid' src-tauri/Cargo.toml \
&& sed -i 's/^uuid = .*/uuid = { version = "1", features = ["v4"] }/' src-tauri/Cargo.toml \
|| echo 'uuid = { version = "1", features = ["v4"] }' >> src-tauri/Cargo.toml
cargo tauri build --no-bundle
}
@ -148,7 +108,7 @@ package() {
mkdir -p "$pkgdir/usr/lib/cef-$_pkgname/"
cp -r "$srcdir/cef/$_cef_ver"/* "$pkgdir/usr/lib/cef-$_pkgname/"
install -Dm644 "$srcdir/Surrealist.desktop" "$pkgdir/usr/share/applications/Surrealist.desktop"
install -Dm644 "src-tauri/icons/icon.png" "$pkgdir/usr/share/icons/hicolor/512x512/apps/Surrealist.png"
install -Dm644 "src-tauri/icons/32x32.png" "$pkgdir/usr/share/icons/hicolor/32x32/apps/Surrealist.png"

139
cef-runtime.patch Normal file
View file

@ -0,0 +1,139 @@
--- src-tauri/src/window.rs 2026-02-20 18:44:14.000000000 -0700
+++ src-tauri/src/window.rs 2026-02-21 14:17:51.023565937 -0700
@@ -5,7 +5,7 @@
static LAST_FOCUSED_WINDOW: OnceLock<Mutex<Option<String>>> = OnceLock::new();
#[tauri::command]
-pub fn toggle_devtools(window: tauri::WebviewWindow) {
+pub fn toggle_devtools(window: tauri::WebviewWindow<tauri::Cef>) {
if window.is_devtools_open() {
window.close_devtools();
} else {
@@ -14,11 +14,11 @@
}
#[tauri::command]
-pub async fn new_window(app: AppHandle) {
+pub async fn new_window(app: AppHandle<tauri::Cef>) {
open_new_window(&app).await;
}
-pub async fn open_new_window(app: &AppHandle) {
+pub async fn open_new_window(app: &AppHandle<tauri::Cef>) {
let window_label = format!("surrealist-{}", Uuid::new_v4());
#[allow(unused_mut)]
@@ -57,7 +57,7 @@
*last = Some(label.to_string());
}
-pub fn get_last_focused_window(app: &AppHandle) -> tauri::WebviewWindow {
+pub fn get_last_focused_window(app: &AppHandle<tauri::Cef>) -> tauri::WebviewWindow<tauri::Cef> {
let storage = LAST_FOCUSED_WINDOW.get_or_init(|| Mutex::new(None));
let last = storage.lock().unwrap();
if let Some(label) = last.as_ref() {
@@ -74,7 +74,7 @@
.clone()
}
-pub fn emit_last(app: &AppHandle, event: &str, payload: impl serde::Serialize + Clone) {
+pub fn emit_last(app: &AppHandle<tauri::Cef>, event: &str, payload: impl serde::Serialize + Clone) {
let last_window = get_last_focused_window(app);
app.emit_to(last_window.label(), event, payload)
--- src-tauri/src/open.rs 2026-02-20 18:44:14.000000000 -0700
+++ src-tauri/src/open.rs 2026-02-21 14:17:51.023690749 -0700
@@ -16,7 +16,7 @@
/// The state holding resources requested for opening
pub struct OpenResourceState(pub Mutex<Vec<url::Url>>);
-pub fn store_resources<T: IntoIterator<Item = String>>(app: &AppHandle, args: T) {
+pub fn store_resources<T: IntoIterator<Item = String>>(app: &AppHandle<tauri::Cef>, args: T) {
let mut urls = Vec::new();
for arg in args.into_iter().skip(1) {
@@ -141,7 +141,7 @@
}
#[tauri::command]
-pub async fn open_query_file(app: AppHandle, window: Window) {
+pub async fn open_query_file(app: AppHandle<tauri::Cef>, window: Window<tauri::Cef>) {
let mut dialog = app.dialog().file();
#[cfg(desktop)]
--- src-tauri/src/database/mod.rs 2026-02-20 18:44:14.000000000 -0700
+++ src-tauri/src/database/mod.rs 2026-02-21 14:17:51.022772510 -0700
@@ -15,7 +15,7 @@
#[allow(clippy::too_many_arguments)]
#[tauri::command]
pub fn start_database(
- window: tauri::Window,
+ window: tauri::Window<tauri::Cef>,
state: tauri::State<DatabaseState>,
username: &str,
password: &str,
--- src-tauri/src/main.rs 2026-02-20 18:44:14.000000000 -0700
+++ src-tauri/src/main.rs 2026-02-21 14:17:51.023760980 -0700
@@ -22,13 +22,13 @@
mod whitelist;
pub mod window;
-static APP_HANDLE: OnceLock<AppHandle> = OnceLock::new();
+static APP_HANDLE: OnceLock<AppHandle<tauri::Cef>> = OnceLock::new();
-fn set_app_handle(app: AppHandle) {
+fn set_app_handle(app: AppHandle<tauri::Cef>) {
APP_HANDLE.set(app).expect("App handle already set");
}
-pub fn get_app_handle() -> &'static AppHandle {
+pub fn get_app_handle() -> &'static AppHandle<tauri::Cef> {
APP_HANDLE.get().expect("App handle not set")
}
--- src-tauri/Cargo.toml 2026-02-20 18:44:14.000000000 -0700
+++ src-tauri/Cargo.toml 2026-02-21 14:17:51.025265660 -0700
@@ -9,7 +9,7 @@
publish = false
[dependencies]
-tauri = { version = "2.4.0", features = ["devtools"] }
+tauri = { version = "2.4.0", default-features = false, features = ["cef", "devtools"] }
tauri-plugin-fs = "2.2.0"
tauri-plugin-os = "2.2.1"
tauri-plugin-log = "2.3.1"
@@ -30,7 +30,7 @@
url = "2"
showfile = "0.1.1"
reqwest = "0.12"
-uuid = "1.17.0"
+uuid = { version = "1", features = ["v4"] }
[target.'cfg(target_os = "macos")'.dependencies]
cocoa = "0.26.1"
@@ -41,3 +41,25 @@
[build-dependencies]
tauri-build = { version = "2.1.0" }
+
+[patch.crates-io]
+tauri = { git = "https://github.com/tauri-apps/tauri", branch = "feat/cef" }
+tauri-build = { git = "https://github.com/tauri-apps/tauri", branch = "feat/cef" }
+tauri-utils = { git = "https://github.com/tauri-apps/tauri", branch = "feat/cef" }
+tauri-runtime = { git = "https://github.com/tauri-apps/tauri", branch = "feat/cef" }
+tauri-runtime-wry = { git = "https://github.com/tauri-apps/tauri", branch = "feat/cef" }
+tauri-runtime-cef = { git = "https://github.com/tauri-apps/tauri", branch = "feat/cef" }
+tauri-macros = { git = "https://github.com/tauri-apps/tauri", branch = "feat/cef" }
+tauri-plugin = { git = "https://github.com/tauri-apps/tauri", branch = "feat/cef" }
+tauri-codegen = { git = "https://github.com/tauri-apps/tauri", branch = "feat/cef" }
+tauri-plugin-fs = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "feat/cef" }
+tauri-plugin-os = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "feat/cef" }
+tauri-plugin-log = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "feat/cef" }
+tauri-plugin-http = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "feat/cef" }
+tauri-plugin-shell = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "feat/cef" }
+tauri-plugin-dialog = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "feat/cef" }
+tauri-plugin-process = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "feat/cef" }
+tauri-plugin-updater = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "feat/cef" }
+tauri-plugin-deep-link = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "feat/cef" }
+tauri-plugin-localhost = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "feat/cef" }
+tauri-plugin-single-instance = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "feat/cef" }