-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
179 additions
and
72 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,26 @@ | ||
[package] | ||
name = "diesel-wasm-sqlite" | ||
version = "0.1.0" | ||
version = "0.1.1" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
diesel = { git = "https://github.com/xmtp/diesel", branch = "insipx/wasm-backend", features = ["r2d2", "i-implement-a-third-party-backend-and-opt-into-breaking-changes"] } | ||
wasm-bindgen = "0.2" | ||
log = "0.4" | ||
rand = "0.8" | ||
getrandom = { version = "0.2", features = ["js"] } | ||
wee_alloc = { version = "0.4.2", optional = true } | ||
console_error_panic_hook = { version = "0.1", optional = true } | ||
|
||
[dev-dependencies] | ||
rand = "0.8" | ||
getrandom = { version = "0.2", features = ["js"] } | ||
wasm-bindgen-test = "0.3" | ||
web-sys = { version = "0.3", features = ["console"] } | ||
|
||
|
||
[lib] | ||
crate-type = ["cdylib", "rlib"] | ||
|
||
[features] | ||
default = ["console_error_panic_hook"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,13 @@ | ||
# Custom Diesel Backend for Wasm wa-sqlite | ||
|
||
#### Bundle the javascript in `package.js` to rust | ||
|
||
`npm run esbuild` | ||
|
||
#### Build the JS WASM interface | ||
|
||
`wasm-pack build` | ||
|
||
#### Run the Wasm Tests | ||
|
||
wasm-pack test --safari --headless |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
const esbuild = require("esbuild"); | ||
const { wasmLoader } = require("esbuild-plugin-wasm"); | ||
|
||
esbuild.build({ | ||
entryPoints: ["package.js"], | ||
bundle: true, | ||
outfile: "src/package.js", | ||
plugins: [ | ||
wasmLoader(), | ||
], | ||
format: "esm", | ||
minify: true, | ||
}).catch(() => process.exit(1)); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
pub fn set_panic_hook() { | ||
// When the `console_error_panic_hook` feature is enabled, we can call the | ||
// `set_panic_hook` function at least once during initialization, and then | ||
// we will get better error messages if our code ever panics. | ||
// | ||
// For more details see | ||
// https://github.com/rustwasm/console_error_panic_hook#readme | ||
#[cfg(feature = "console_error_panic_hook")] | ||
console_error_panic_hook::set_once(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#![cfg(target_arch = "wasm32")] | ||
|
||
use wasm_bindgen_test::*; | ||
use web_sys::console; | ||
use diesel_wasm_sqlite::WasmSqliteConnection; | ||
wasm_bindgen_test_configure!(run_in_browser); | ||
|
||
#[wasm_bindgen_test] | ||
fn test_console_log() { | ||
diesel_wasm_sqlite::utils::set_panic_hook(); | ||
console::log_1(&"TEST THIS WORKS????".into()); | ||
assert_eq!(1, 2); | ||
} | ||
|
||
/* | ||
#[wasm_bindgen_test] | ||
fn test_establish() { | ||
let rng: u16 = rand::random(); | ||
let url = format!( | ||
"{}/wasmtest-{}.db3", | ||
std::env::temp_dir().to_str().unwrap(), | ||
rng | ||
); | ||
let mut conn = WasmSqliteConnection::establish(&url).unwrap(); | ||
println!("{:?}", conn); | ||
} | ||
*/ |