Skip to content

Commit ee766b7

Browse files
committed
Move sqlite-wasm-rs to the root
1 parent f68191b commit ee766b7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+201
-214
lines changed

.cargo/config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[target.'cfg(target_arch = "wasm32")']
2+
runner = 'wasm-bindgen-test-runner'

.github/workflows/test.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ jobs:
2020
uses: ./.github/actions/setup-emscripten
2121
- name: Test bundled
2222
run: |
23-
cd sqlite-wasm-rs
2423
wasm-pack test --chrome --headless --features relaxed-idb
2524
- name: Test custom-libc
2625
if: matrix.os != 'windows-latest'
@@ -41,7 +40,6 @@ jobs:
4140
uses: ./.github/actions/setup-emscripten
4241
- name: Test bundled sqlite3mc
4342
run: |
44-
cd sqlite-wasm-rs
4543
wasm-pack test --chrome --headless --features relaxed-idb,sqlite3mc
4644
4745
test_diesel:
@@ -57,7 +55,7 @@ jobs:
5755
rustup target add wasm32-unknown-unknown
5856
cargo install wasm-bindgen-cli
5957
printf "[patch.crates-io]\n" >> Cargo.toml
60-
printf "sqlite-wasm-rs = { path = \"../sqlite-wasm-rs\" }\n" >> Cargo.toml
58+
printf "sqlite-wasm-rs = { path = \"..\" }\n" >> Cargo.toml
6159
WASM_BINDGEN_TEST_TIMEOUT=120 cargo xtask run-tests --wasm sqlite
6260
6361
test_rusqlite:
@@ -73,7 +71,7 @@ jobs:
7371
git clone https://github.com/Spxg/rusqlite.git
7472
cd rusqlite
7573
printf "[patch.crates-io]\n" >> Cargo.toml
76-
printf "sqlite-wasm-rs = { path = \"../sqlite-wasm-rs\" }\n" >> Cargo.toml
74+
printf "sqlite-wasm-rs = { path = \"..\" }\n" >> Cargo.toml
7775
WASM_BINDGEN_TEST_TIMEOUT=60 wasm-pack test --chrome --headless --features modern-base
7876
7977
test_clippy:
@@ -82,7 +80,6 @@ jobs:
8280
- uses: actions/checkout@v4
8381
- name: Check clippy
8482
run: |
85-
cd sqlite-wasm-rs
8683
cargo clippy --no-default-features --features precompiled,relaxed-idb -- -D warnings
8784
8885
test_implement_a_vfs:
@@ -116,7 +113,6 @@ jobs:
116113
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
117114
- name: Test
118115
run: |
119-
cd sqlite-wasm-rs
120116
wasm-pack test --chrome --headless --no-default-features --features precompiled,relaxed-idb
121117
122118
test_atomics:
@@ -132,7 +128,6 @@ jobs:
132128
uses: ./.github/actions/setup-emscripten
133129
- name: Test
134130
run: |
135-
cd sqlite-wasm-rs
136131
rustup toolchain install nightly
137132
rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu
138133
RUSTFLAGS='-C target-feature=+atomics,+bulk-memory' rustup run nightly wasm-pack test --chrome --headless --features relaxed-idb -Z build-std=panic_abort,std
@@ -152,7 +147,6 @@ jobs:
152147
version: '3.1.52'
153148
- name: Test MSRV
154149
run: |
155-
cd sqlite-wasm-rs
156150
rustup toolchain install 1.78.0
157151
rustup default 1.78.0
158152
wasm-pack test --chrome --headless --features relaxed-idb

Cargo.toml

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,68 @@
1+
[package]
2+
name = "sqlite-wasm-rs"
3+
version = "0.4.4"
4+
edition = "2021"
5+
authors = ["Spxg <[email protected]>"]
6+
readme = "README.md"
7+
license = "MIT"
8+
repository = "https://github.com/Spxg/sqlite-wasm-rs"
9+
description = "Provide sqlite solution for wasm32-unknown-unknown target."
10+
categories = ["development-tools::ffi", "wasm", "database"]
11+
keywords = ["sqlite", "sqlite-wasm", "wasm", "webassembly", "javascript"]
12+
rust-version = "1.78.0"
13+
14+
[dependencies]
15+
once_cell = "1.21.3"
16+
tokio = { version = "1.45.1", features = ["sync"] }
17+
thiserror = "2.0.12"
18+
19+
wasm-bindgen = "0.2.104"
20+
wasm-bindgen-futures = "0.4.54"
21+
js-sys = "0.3.81"
22+
web-sys = { version = "0.3.81", features = [
23+
"StorageManager",
24+
"FileSystemSyncAccessHandle",
25+
"FileSystemDirectoryHandle",
26+
"FileSystemGetDirectoryOptions",
27+
"FileSystemReadWriteOptions",
28+
"WorkerGlobalScope",
29+
"WorkerNavigator",
30+
"FileSystemGetFileOptions",
31+
"FileSystemFileHandle",
32+
]}
33+
34+
indexed_db_futures = { version = "0.6.4", optional = true }
35+
sqlite-wasm-libc = { path = "crates/sqlite-wasm-libc", version = "0.1.0", optional = true }
36+
37+
[features]
38+
default = ["bundled"]
39+
bundled = ["cc"]
40+
precompiled = []
41+
buildtime-bindgen = ["bindgen"]
42+
custom-libc = ["bundled", "sqlite-wasm-libc"]
43+
# SQLite3MultipleCiphers
44+
# <https://github.com/utelle/SQLite3MultipleCiphers>
45+
# <https://utelle.github.io/SQLite3MultipleCiphers>
46+
sqlite3mc = ["bundled"]
47+
relaxed-idb = ["indexed_db_futures"]
48+
49+
[dev-dependencies]
50+
wasm-bindgen-test = "0.3.54"
51+
web-time = "1.1.0"
52+
53+
[build-dependencies]
54+
bindgen = { version = "0.72", optional = true }
55+
cc = { version = "1.2.27", optional = true }
56+
57+
[package.metadata.docs.rs]
58+
no-default-features = true
59+
features = ["precompiled"]
60+
targets = ["wasm32-unknown-unknown"]
61+
162
[workspace]
263
resolver = "2"
364
members = [
4-
"sqlite-wasm-rs",
5-
"sqlite-wasm-libc",
6-
65+
"crates/sqlite-wasm-libc",
766
"examples/custom-libc",
867
"examples/implement-a-vfs",
968
"examples/nodejs"

README.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,27 @@ async fn open_db() {
6868

6969
The following vfs have been implemented:
7070

71-
* [`memory`](https://github.com/Spxg/sqlite-wasm-rs/tree/master/sqlite-wasm-rs/src/vfs/memory.rs): as the default vfs, no additional conditions are required, store the database in memory.
72-
* [`sahpool`](https://github.com/Spxg/sqlite-wasm-rs/tree/master/sqlite-wasm-rs/src/vfs/sahpool.rs): ported from sqlite-wasm, store the database in opfs.
73-
* [`relaxed-idb`](https://github.com/Spxg/sqlite-wasm-rs/tree/master/sqlite-wasm-rs/src/vfs/relaxed_idb.rs): store the database in blocks in indexed db.
71+
* [`memory`](https://github.com/Spxg/sqlite-wasm-rs/tree/master/src/vfs/memory.rs): as the default vfs, no additional conditions are required, store the database in memory.
72+
* [`sahpool`](https://github.com/Spxg/sqlite-wasm-rs/tree/master/src/vfs/sahpool.rs): ported from sqlite-wasm, store the database in opfs.
73+
* [`relaxed-idb`](https://github.com/Spxg/sqlite-wasm-rs/tree/master/src/vfs/relaxed_idb.rs): store the database in blocks in indexed db.
7474

75-
Go to [`here`](https://github.com/Spxg/sqlite-wasm-rs/tree/master/sqlite-wasm-rs/src/vfs/README.md) to check it out.
75+
Go to [`here`](https://github.com/Spxg/sqlite-wasm-rs/tree/master/src/vfs/README.md) to check it out.
76+
77+
### VFS Comparison
78+
79+
||MemoryVFS|SyncAccessHandlePoolVFS|RelaxedIdbVFS|
80+
|-|-|-|-|
81+
|Storage|RAM|OPFS|IndexedDB|
82+
|Contexts|All|Dedicated Worker|All|
83+
|Multiple connections|:x:|:x:|:x:|
84+
|Full durability|||:x:|
85+
|Relaxed durability|:x:|:x:||
86+
|Multi-database transactions||||
87+
|No COOP/COEP requirements||||
88+
89+
### How to implement a VFS
90+
91+
Here is an example showing how to use `sqlite-wasm-rs` to implement a simple in-memory VFS, see [`implement-a-vfs`](https://github.com/Spxg/sqlite-wasm-rs/tree/master/examples/implement-a-vfs) example.
7692

7793
## About multithreading
7894

@@ -96,7 +112,7 @@ About security:
96112

97113
We provide the ability to customize "libc", cargo provides a [`links`](https://doc.rust-lang.org/cargo/reference/manifest.html#the-links-field) field that can be used to specify which library to link to.
98114

99-
We created a new [`sqlite-wasm-libc`](https://github.com/Spxg/sqlite-wasm-rs/tree/master/sqlite-wasm-libc) library with no implementation and only a `links = "libc"` configuration, and then with the help of [overriding build scripts](https://doc.rust-lang.org/cargo/reference/build-scripts.html#overriding-build-scripts), you can overriding its configuration in your crate and link sqlite to your custom libc.
115+
We created a new [`sqlite-wasm-libc`](https://github.com/Spxg/sqlite-wasm-rs/tree/master/crates/sqlite-wasm-libc) library with no implementation and only a `links = "libc"` configuration, and then with the help of [overriding build scripts](https://doc.rust-lang.org/cargo/reference/build-scripts.html#overriding-build-scripts), you can overriding its configuration in your crate and link sqlite to your custom libc.
100116

101117
More see [`custom-libc`](https://github.com/Spxg/sqlite-wasm-rs/tree/master/examples/custom-libc) example.
102118

File renamed without changes.
File renamed without changes.

crates/sqlite-wasm-libc/LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../LICENSE
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)