diff --git a/Cargo.lock b/Cargo.lock index bf50719..a5eb0bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -172,6 +172,15 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" +[[package]] +name = "cc" +version = "1.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c3d1b2e905a3a7b00a6141adb0e4c0bb941d11caf55349d863942a1cc44e3c9" +dependencies = [ + "shlex", +] + [[package]] name = "cfg-if" version = "1.0.0" @@ -287,6 +296,7 @@ dependencies = [ "cql2", "getrandom", "wasm-bindgen", + "wasm-bindgen-test", "web-sys", ] @@ -960,6 +970,16 @@ dependencies = [ "autocfg", ] +[[package]] +name = "minicov" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27fe9f1cc3c22e1687f9446c2083c4c5fc7f0bcf1c7a86bdbded14985895b4b" +dependencies = [ + "cc", + "walkdir", +] + [[package]] name = "num" version = "0.4.3" @@ -1485,6 +1505,15 @@ version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -1541,6 +1570,12 @@ dependencies = [ "digest", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "siphasher" version = "1.0.1" @@ -1785,6 +1820,16 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c3082ca00d5a5ef149bb8b555a72ae84c9c59f7250f013ac822ac2e49b19c64" +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -1817,6 +1862,19 @@ dependencies = [ "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" +dependencies = [ + "cfg-if", + "js-sys", + "once_cell", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "wasm-bindgen-macro" version = "0.2.100" @@ -1849,6 +1907,30 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "wasm-bindgen-test" +version = "0.3.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66c8d5e33ca3b6d9fa3b4676d774c5778031d27a578c2b007f905acf816152c3" +dependencies = [ + "js-sys", + "minicov", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-bindgen-test-macro", +] + +[[package]] +name = "wasm-bindgen-test-macro" +version = "0.3.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17d5042cc5fa009658f9a7333ef24291b1291a25b6382dd68862a7f3b969f69b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "web-sys" version = "0.3.77" @@ -1859,6 +1941,15 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "winapi-util" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +dependencies = [ + "windows-sys", +] + [[package]] name = "windows-sys" version = "0.59.0" diff --git a/Cargo.toml b/Cargo.toml index 2998f17..1621842 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,3 +53,6 @@ members = ["cli", "python", "wasm"] [workspace.dependencies] clap = "4.5.28" + +[profile.release] +opt-level = "s" diff --git a/wasm/Cargo.toml b/wasm/Cargo.toml index aa96721..e072a8e 100644 --- a/wasm/Cargo.toml +++ b/wasm/Cargo.toml @@ -12,7 +12,7 @@ keywords = ["cql2"] publish = false [lib] -crate-type = ["cdylib"] +crate-type = ["cdylib", "rlib"] [dependencies] cql2 = { path = ".." } @@ -22,3 +22,6 @@ getrandom = { version = "0.2.15", features = ["js"] } [dependencies.web-sys] version = "0.3.4" features = ['Document', 'Element', 'HtmlElement', 'Node', 'Window'] + +[dev-dependencies] +wasm-bindgen-test = "0.3.34" diff --git a/wasm/LICENSE b/wasm/LICENSE new file mode 120000 index 0000000..ea5b606 --- /dev/null +++ b/wasm/LICENSE @@ -0,0 +1 @@ +../LICENSE \ No newline at end of file diff --git a/wasm/README.md b/wasm/README.md index 98cc0ce..d8041a3 100644 --- a/wasm/README.md +++ b/wasm/README.md @@ -21,3 +21,18 @@ uv run mkdocs serve The playground will be available at . There is a live version available at . + +## Testing + +```shell +wasm-pack test --firefox wasm +``` + +Then, open to see the test(s) run. + +## Releasing to NPM + +```shell +wasm-pack build wasm +# TODO actually release +``` diff --git a/wasm/tests/web.rs b/wasm/tests/web.rs new file mode 100644 index 0000000..588094c --- /dev/null +++ b/wasm/tests/web.rs @@ -0,0 +1,16 @@ +//! Test suite for the Web and headless browsers. + +#![cfg(target_arch = "wasm32")] + +extern crate wasm_bindgen_test; +use cql2_wasm::CQL2Expression; +use wasm_bindgen_test::*; + +wasm_bindgen_test_configure!(run_in_browser); + +#[wasm_bindgen_test] +fn is_valid() { + let expr = + CQL2Expression::new("landsat:scene_id = 'LC82030282019133LGN00'".to_string()).unwrap(); + assert!(expr.is_valid()); +}