Bump sqlite-wasm-rs version to 0.4.0

This commit is contained in:
Spxg
2025-07-03 00:00:14 +08:00
parent d820d135d4
commit fc846a81c2
3 changed files with 47 additions and 184 deletions

203
Cargo.lock generated
View File

@@ -2,18 +2,6 @@
# It is not intended for manual editing.
version = 4
[[package]]
name = "accessory"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28e416a3ab45838bac2ab2d81b1088d738d7b2d2c5272a54d39366565a29bd80"
dependencies = [
"macroific",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "aceditor"
version = "0.1.0"
@@ -172,9 +160,9 @@ checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3"
[[package]]
name = "cc"
version = "1.2.24"
version = "1.2.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16595d3be041c03b09d08d0858631facccee9221e579704070e6e9e4915d3bc7"
checksum = "d487aa071b5f64da6f19a3e848e3578944b726ee5a4854b82172f02aa876bfdc"
dependencies = [
"shlex",
]
@@ -335,20 +323,6 @@ dependencies = [
"parking_lot_core",
]
[[package]]
name = "delegate-display"
version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9926686c832494164c33a36bf65118f4bd6e704000b58c94681bf62e9ad67a74"
dependencies = [
"impartial-ord",
"itoa",
"macroific",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "derive-where"
version = "1.4.0"
@@ -360,27 +334,6 @@ dependencies = [
"syn",
]
[[package]]
name = "derive_more"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "093242cf7570c207c83073cf82f79706fe7b8317e98620a47d5be7c3d8497678"
dependencies = [
"derive_more-impl",
]
[[package]]
name = "derive_more-impl"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3"
dependencies = [
"proc-macro2",
"quote",
"syn",
"unicode-xid",
]
[[package]]
name = "dirs-next"
version = "2.0.0"
@@ -474,18 +427,6 @@ dependencies = [
"pin-project-lite",
]
[[package]]
name = "fancy_constructor"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28a27643a5d05f3a22f5afd6e0d0e6e354f92d37907006f97b84b9cb79082198"
dependencies = [
"macroific",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "floating-ui"
version = "0.1.0"
@@ -850,51 +791,6 @@ dependencies = [
"icu_properties",
]
[[package]]
name = "impartial-ord"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ab604ee7085efba6efc65e4ebca0e9533e3aff6cb501d7d77b211e3a781c6d5"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "indexed_db_futures"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69ff41758cbd104e91033bb53bc449bec7eea65652960c81eddf3fc146ecea19"
dependencies = [
"accessory",
"cfg-if",
"delegate-display",
"derive_more",
"fancy_constructor",
"indexed_db_futures_macros_internal",
"js-sys",
"sealed",
"smallvec",
"thiserror 2.0.12",
"tokio",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
]
[[package]]
name = "indexed_db_futures_macros_internal"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "caeba94923b68f254abef921cea7e7698bf4675fdd89d7c58bf1ed885b49a27d"
dependencies = [
"macroific",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "indexmap"
version = "2.9.0"
@@ -911,6 +807,17 @@ version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71dd52191aae121e8611f1e8dc3e324dd0dd1dee1e6dd91d10ee07a3cfb4d9d8"
[[package]]
name = "io-uring"
version = "0.7.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b86e202f00093dcba4275d4636b93ef9dd75d025ae560d2521b45ea28ab49013"
dependencies = [
"bitflags",
"cfg-if",
"libc",
]
[[package]]
name = "is-terminal"
version = "0.4.16"
@@ -1133,54 +1040,6 @@ version = "0.4.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
[[package]]
name = "macroific"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89f276537b4b8f981bf1c13d79470980f71134b7bdcc5e6e911e910e556b0285"
dependencies = [
"macroific_attr_parse",
"macroific_core",
"macroific_macro",
]
[[package]]
name = "macroific_attr_parse"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad4023761b45fcd36abed8fb7ae6a80456b0a38102d55e89a57d9a594a236be9"
dependencies = [
"proc-macro2",
"quote",
"sealed",
"syn",
]
[[package]]
name = "macroific_core"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0a7594d3c14916fa55bef7e9d18c5daa9ed410dd37504251e4b75bbdeec33e3"
dependencies = [
"proc-macro2",
"quote",
"sealed",
"syn",
]
[[package]]
name = "macroific_macro"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4da6f2ed796261b0a74e2b52b42c693bb6dee1effba3a482c49592659f824b3b"
dependencies = [
"macroific_attr_parse",
"macroific_core",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "manyhow"
version = "0.11.4"
@@ -1219,6 +1078,17 @@ dependencies = [
"adler2",
]
[[package]]
name = "mio"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c"
dependencies = [
"libc",
"wasi 0.11.0+wasi-snapshot-preview1",
"windows-sys",
]
[[package]]
name = "next_tuple"
version = "0.1.0"
@@ -1634,17 +1504,6 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "sealed"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22f968c5ea23d555e670b449c1c5e7b2fc399fdaec1d304a17cd48e288abc107"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "semver"
version = "1.0.26"
@@ -1858,6 +1717,7 @@ dependencies = [
"sqlite-wasm-rs",
"thiserror 2.0.12",
"tokio",
"wasm-array-cp",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
@@ -1865,13 +1725,12 @@ dependencies = [
[[package]]
name = "sqlite-wasm-rs"
version = "0.3.8"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3154cbfc5c60b307a5ce91ee19314571b22f4549628f3c1d731c24696dfa3af"
checksum = "de7f07bae637a5bd84def164aa94e4078daeec91346781fa3b07699061b0aeea"
dependencies = [
"cc",
"fragile",
"indexed_db_futures",
"js-sys",
"once_cell",
"parking_lot",
@@ -2030,12 +1889,16 @@ dependencies = [
[[package]]
name = "tokio"
version = "1.45.0"
version = "1.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2513ca694ef9ede0fb23fe71a4ee4107cb102b9dc1930f6d0fd77aae068ae165"
checksum = "1140bb80481756a8cbe10541f37433b459c5aa1e727b4c020fbfebdc25bf3ec4"
dependencies = [
"backtrace",
"io-uring",
"libc",
"mio",
"pin-project-lite",
"slab",
]
[[package]]

View File

@@ -18,7 +18,7 @@ aceditor = { path = "crates/aceditor" }
split-grid = { path = "crates/split-grid" }
floating-ui = { path = "crates/floating-ui" }
sqlite-wasm-rs = { version = "0.3.7", default-features = false, optional = true }
sqlite-wasm-rs = { version = "0.4.0", default-features = false, optional = true }
console_error_panic_hook = "0.1.7"
leptos = { version = "0.8.2", features = ["csr"] }
reactive_stores = "0.2.2"
@@ -39,6 +39,7 @@ fragile = "2.0.1"
hex = "0.4.3"
prettytable-rs = "0.10.0"
sqlformat = "0.3.5"
wasm-array-cp = "0.1.1"
[features]
default = ["sqlite3"]

View File

@@ -6,15 +6,15 @@ use crate::{
};
use once_cell::sync::Lazy;
use sqlite_wasm_rs::{
export::{OpfsSAHPoolCfgBuilder, OpfsSAHPoolUtil},
mem_vfs::MemVfsUtil,
utils::{copy_to_uint8_array, copy_to_vec},
sahpool_vfs::{OpfsSAHPoolCfgBuilder, OpfsSAHPoolUtil},
};
use sqlitend::SQLiteDb;
use std::sync::Arc;
use tokio::sync::Mutex;
use tokio::sync::OnceCell;
use tokio::sync::mpsc::UnboundedReceiver;
use wasm_array_cp::ArrayBufferCopy;
use wasm_bindgen::{JsCast, JsValue, prelude::Closure};
use wasm_bindgen_futures::spawn_local;
use web_sys::{DedicatedWorkerGlobalScope, MessageEvent};
@@ -78,12 +78,10 @@ async fn init_opfs_util() -> Result<&'static OpfsSAHPoolUtil> {
.opfs
.get_or_try_init(|| async {
sqlite_wasm_rs::sahpool_vfs::install(
Some(
&OpfsSAHPoolCfgBuilder::new()
.directory(OPFS_VFS_DIR)
.vfs_name("opfs")
.build(),
),
&OpfsSAHPoolCfgBuilder::new()
.directory(OPFS_VFS_DIR)
.vfs_name("opfs")
.build(),
false,
)
.await
@@ -101,7 +99,7 @@ async fn download_db() -> Result<DownloadDbResponse> {
let filename = &worker.open_options.filename;
let db = if worker.open_options.persist {
get_opfs_util()?
.export_file(filename)
.export_db(filename)
.map_err(|err| WorkerError::DownloadDb(format!("{err}")))?
} else {
let mem_vfs = &FS_UTIL.mem;
@@ -111,14 +109,14 @@ async fn download_db() -> Result<DownloadDbResponse> {
};
Ok(DownloadDbResponse {
filename: worker.open_options.filename.clone(),
data: copy_to_uint8_array(&db),
data: ArrayBufferCopy::from_slice(&db),
})
})
.await
}
async fn load_db(options: LoadDbOptions) -> Result<()> {
let db = copy_to_vec(&options.data);
let db = ArrayBufferCopy::to_vec(&options.data);
#[cfg(feature = "sqlite3")]
let page_size = sqlite_wasm_rs::utils::check_import_db(&db)
@@ -133,7 +131,8 @@ async fn load_db(options: LoadDbOptions) -> Result<()> {
let filename = &worker.open_options.filename;
if worker.open_options.persist {
let opfs = get_opfs_util()?;
opfs.unlink(filename).map_err(|_| WorkerError::Unexpected)?;
opfs.delete_db(filename)
.map_err(|_| WorkerError::Unexpected)?;
if let Err(err) = opfs.import_db_unchecked(filename, &db) {
return Err(WorkerError::LoadDb(format!("{err}")));
@@ -180,7 +179,7 @@ async fn run(options: RunOptions) -> Result<SQLiteRunResult> {
let filename = &worker.open_options.filename;
if worker.open_options.persist {
get_opfs_util()?
.unlink(filename)
.delete_db(filename)
.map_err(|_| WorkerError::Unexpected)?;
} else {
let mem_vfs = &FS_UTIL.mem;