diff --git a/.github/workflows/latest.yml b/.github/workflows/latest.yml index 047f0b8..2849812 100644 --- a/.github/workflows/latest.yml +++ b/.github/workflows/latest.yml @@ -16,7 +16,10 @@ jobs: with: toolchain: stable # targets: x86_64-unknown-linux-musl + - run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh - run: cargo test --verbose -- --nocapture + - run: wasm-pack test --headless --firefox ./adana-script-wasm + - run: wasm-pack test --headless --chrome ./adana-script-wasm docker: needs: test runs-on: ubuntu-latest diff --git a/.github/workflows/release-wasm.yml b/.github/workflows/release-wasm.yml index eba86e0..e168752 100644 --- a/.github/workflows/release-wasm.yml +++ b/.github/workflows/release-wasm.yml @@ -1,9 +1,15 @@ name: Release WASM +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write on: push: tags: - "**[0-9]+.[0-9]+.[0-9]+*" + workflow_dispatch: env: CARGO_TERM_COLOR: always @@ -23,11 +29,24 @@ jobs: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh wasm-pack build --target web --release --scope nbittich ./adana-script-wasm wasm-pack pack ./adana-script-wasm/pkg + mkdir ghPages + cp -r ./adana-script-wasm/pkg ghPages + cp ./adana-playground/app.js ghPages + cp ./adana-playground/style.css ghPages + cp ./adana-playground/favicon.ico ghPages + cp ./adana-playground/examples.js ghPages + cp ./adana-playground/index.html ghPages + - name: Upload pkg uses: actions/upload-artifact@v4 with: name: pkg path: adana-script-wasm/pkg + - name: Upload ghPages + uses: actions/upload-artifact@v4 + with: + name: ghPages + path: ghPages publish: needs: build runs-on: ubuntu-latest @@ -49,3 +68,19 @@ jobs: cd pkg npm install npm publish --access public + gh-pages: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + needs: build + runs-on: ubuntu-latest + steps: + - name: Download ghPages + uses: actions/download-artifact@v4 + with: + name: ghPages + path: "_site/" + - name: Upload pages + uses: actions/upload-pages-artifact@v3 + - name: Deploy pages + uses: actions/deploy-pages@v4 diff --git a/.gitignore b/.gitignore index f00b4de..3a6cac8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /target .idea -.history \ No newline at end of file +.history +Cargo.lock diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index 8b6af5d..0000000 --- a/Cargo.lock +++ /dev/null @@ -1,1474 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "adana" -version = "0.17.2" -dependencies = [ - "adana-cache-command", - "adana-db", - "adana-script", - "adana-script-core", - "anyhow", - "ctrlc", - "dirs", - "env_logger", - "log", - "nu-ansi-term", - "rustyline", - "rustyline-derive", -] - -[[package]] -name = "adana-cache-command" -version = "0.17.2" -dependencies = [ - "adana-db", - "adana-script", - "adana-script-core", - "anyhow", - "arboard", - "bincode", - "dirs", - "log", - "nom", - "nu-ansi-term", - "regex", - "serde", - "serde_json", - "strum", -] - -[[package]] -name = "adana-db" -version = "0.17.2" -dependencies = [ - "anyhow", - "bincode", - "dirs", - "log", - "serde", -] - -[[package]] -name = "adana-script" -version = "0.17.2" -dependencies = [ - "adana-script-core", - "anyhow", - "nom", - "serial_test", - "slab_tree", -] - -[[package]] -name = "adana-script-core" -version = "0.17.2" -dependencies = [ - "anyhow", - "libloading", - "serde", - "strum", -] - -[[package]] -name = "adana-script-wasm" -version = "0.17.2" -dependencies = [ - "adana-script", - "adana-script-core", - "bincode", - "console_error_panic_hook", - "serde", - "serde-wasm-bindgen", - "wasm-bindgen", - "wasm-bindgen-test", - "wee_alloc", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "aho-corasick" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" -dependencies = [ - "memchr", -] - -[[package]] -name = "anyhow" -version = "1.0.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" - -[[package]] -name = "arboard" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aafb29b107435aa276664c1db8954ac27a6e105cdad3c88287a199eb0e313c08" -dependencies = [ - "clipboard-win 4.5.0", - "core-graphics", - "image", - "log", - "objc", - "objc-foundation", - "objc_id", - "parking_lot", - "thiserror", - "winapi", - "x11rb", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "bincode" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" -dependencies = [ - "serde", -] - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitflags" -version = "2.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" - -[[package]] -name = "block" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" - -[[package]] -name = "bumpalo" -version = "3.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" - -[[package]] -name = "bytemuck" -version = "1.14.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed2490600f404f2b94c167e31d3ed1d5f3c225a0f3b80230053b3e0b7b962bd9" - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "clipboard-win" -version = "4.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7191c27c2357d9b7ef96baac1773290d4ca63b24205b82a3fd8a0637afcf0362" -dependencies = [ - "error-code 2.3.1", - "str-buf", - "winapi", -] - -[[package]] -name = "clipboard-win" -version = "5.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c57002a5d9be777c1ef967e33674dac9ebd310d8893e4e3437b14d5f0f6372cc" -dependencies = [ - "error-code 3.0.0", -] - -[[package]] -name = "color_quant" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" - -[[package]] -name = "console_error_panic_hook" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" -dependencies = [ - "cfg-if 1.0.0", - "wasm-bindgen", -] - -[[package]] -name = "core-foundation" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" - -[[package]] -name = "core-graphics" -version = "0.22.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "core-graphics-types", - "foreign-types", - "libc", -] - -[[package]] -name = "core-graphics-types" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "libc", -] - -[[package]] -name = "crc32fast" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" -dependencies = [ - "cfg-if 1.0.0", -] - -[[package]] -name = "ctrlc" -version = "3.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b467862cc8610ca6fc9a1532d7777cee0804e678ab45410897b9396495994a0b" -dependencies = [ - "nix 0.27.1", - "windows-sys 0.52.0", -] - -[[package]] -name = "dashmap" -version = "5.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" -dependencies = [ - "cfg-if 1.0.0", - "hashbrown", - "lock_api", - "once_cell", - "parking_lot_core", -] - -[[package]] -name = "dirs" -version = "5.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" -dependencies = [ - "dirs-sys", -] - -[[package]] -name = "dirs-sys" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" -dependencies = [ - "libc", - "option-ext", - "redox_users", - "windows-sys 0.48.0", -] - -[[package]] -name = "endian-type" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" - -[[package]] -name = "env_filter" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" -dependencies = [ - "log", -] - -[[package]] -name = "env_logger" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05e7cf40684ae96ade6232ed84582f40ce0a66efcd43a5117aef610534f8e0b8" -dependencies = [ - "env_filter", - "log", -] - -[[package]] -name = "errno" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" -dependencies = [ - "libc", - "windows-sys 0.52.0", -] - -[[package]] -name = "error-code" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64f18991e7bf11e7ffee451b5318b5c1a73c52d0d0ada6e5a3017c8c1ced6a21" -dependencies = [ - "libc", - "str-buf", -] - -[[package]] -name = "error-code" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "281e452d3bad4005426416cdba5ccfd4f5c1280e10099e21db27f7c1c28347fc" - -[[package]] -name = "fd-lock" -version = "4.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e5768da2206272c81ef0b5e951a41862938a6070da63bcea197899942d3b947" -dependencies = [ - "cfg-if 1.0.0", - "rustix", - "windows-sys 0.52.0", -] - -[[package]] -name = "fdeflate" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f9bfee30e4dedf0ab8b422f03af778d9612b63f502710fc500a334ebe2de645" -dependencies = [ - "simd-adler32", -] - -[[package]] -name = "flate2" -version = "1.0.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" -dependencies = [ - "crc32fast", - "miniz_oxide", -] - -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - -[[package]] -name = "futures" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-core" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" - -[[package]] -name = "futures-executor" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-io" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" - -[[package]] -name = "futures-sink" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" - -[[package]] -name = "futures-task" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" - -[[package]] -name = "futures-util" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" -dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-sink", - "futures-task", - "memchr", - "pin-project-lite", - "pin-utils", - "slab", -] - -[[package]] -name = "gethostname" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb65d4ba3173c56a500b555b532f72c42e8d1fe64962b518897f8959fae2c177" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "getrandom" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "wasi", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - -[[package]] -name = "home" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" -dependencies = [ - "windows-sys 0.52.0", -] - -[[package]] -name = "image" -version = "0.24.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "034bbe799d1909622a74d1193aa50147769440040ff36cb2baa947609b0a4e23" -dependencies = [ - "bytemuck", - "byteorder", - "color_quant", - "num-traits", - "png", - "tiff", -] - -[[package]] -name = "itoa" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" - -[[package]] -name = "jpeg-decoder" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0" - -[[package]] -name = "js-sys" -version = "0.3.68" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "libc" -version = "0.2.153" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" - -[[package]] -name = "libloading" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c571b676ddfc9a8c12f1f3d3085a7b163966a8fd8098a90640953ce5f6170161" -dependencies = [ - "cfg-if 1.0.0", - "windows-sys 0.48.0", -] - -[[package]] -name = "libredox" -version = "0.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" -dependencies = [ - "bitflags 2.4.2", - "libc", - "redox_syscall", -] - -[[package]] -name = "linux-raw-sys" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" - -[[package]] -name = "lock_api" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "log" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" - -[[package]] -name = "malloc_buf" -version = "0.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" -dependencies = [ - "libc", -] - -[[package]] -name = "memchr" -version = "2.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" - -[[package]] -name = "memoffset" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" -dependencies = [ - "autocfg", -] - -[[package]] -name = "memory_units" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" - -[[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" - -[[package]] -name = "miniz_oxide" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" -dependencies = [ - "adler", - "simd-adler32", -] - -[[package]] -name = "nibble_vec" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a5d83df9f36fe23f0c3648c6bbb8b0298bb5f1939c8f2704431371f4b84d43" -dependencies = [ - "smallvec", -] - -[[package]] -name = "nix" -version = "0.26.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" -dependencies = [ - "bitflags 1.3.2", - "cfg-if 1.0.0", - "libc", - "memoffset", -] - -[[package]] -name = "nix" -version = "0.27.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" -dependencies = [ - "bitflags 2.4.2", - "cfg-if 1.0.0", - "libc", -] - -[[package]] -name = "nom" -version = "7.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" -dependencies = [ - "memchr", - "minimal-lexical", -] - -[[package]] -name = "nu-ansi-term" -version = "0.50.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd2800e1520bdc966782168a627aa5d1ad92e33b984bf7c7615d31280c83ff14" -dependencies = [ - "windows-sys 0.48.0", -] - -[[package]] -name = "num-traits" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" -dependencies = [ - "autocfg", -] - -[[package]] -name = "objc" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" -dependencies = [ - "malloc_buf", -] - -[[package]] -name = "objc-foundation" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9" -dependencies = [ - "block", - "objc", - "objc_id", -] - -[[package]] -name = "objc_id" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b" -dependencies = [ - "objc", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "option-ext" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" - -[[package]] -name = "parking_lot" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "redox_syscall", - "smallvec", - "windows-targets 0.48.5", -] - -[[package]] -name = "pin-project-lite" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "png" -version = "0.17.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f6c3c3e617595665b8ea2ff95a86066be38fb121ff920a9c0eb282abcd1da5a" -dependencies = [ - "bitflags 1.3.2", - "crc32fast", - "fdeflate", - "flate2", - "miniz_oxide", -] - -[[package]] -name = "proc-macro2" -version = "1.0.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "radix_trie" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c069c179fcdc6a2fe24d8d18305cf085fdbd4f922c041943e203685d6a1c58fd" -dependencies = [ - "endian-type", - "nibble_vec", -] - -[[package]] -name = "redox_syscall" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "redox_users" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" -dependencies = [ - "getrandom", - "libredox", - "thiserror", -] - -[[package]] -name = "regex" -version = "1.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" - -[[package]] -name = "rustix" -version = "0.38.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" -dependencies = [ - "bitflags 2.4.2", - "errno", - "libc", - "linux-raw-sys", - "windows-sys 0.52.0", -] - -[[package]] -name = "rustversion" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" - -[[package]] -name = "rustyline" -version = "13.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02a2d683a4ac90aeef5b1013933f6d977bd37d51ff3f4dad829d4931a7e6be86" -dependencies = [ - "bitflags 2.4.2", - "cfg-if 1.0.0", - "clipboard-win 5.0.0", - "fd-lock", - "home", - "libc", - "log", - "memchr", - "nix 0.27.1", - "radix_trie", - "unicode-segmentation", - "unicode-width", - "utf8parse", - "winapi", -] - -[[package]] -name = "rustyline-derive" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5af959c8bf6af1aff6d2b463a57f71aae53d1332da58419e30ad8dc7011d951" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "ryu" -version = "1.0.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" - -[[package]] -name = "scoped-tls" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "serde" -version = "1.0.196" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde-wasm-bindgen" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9b713f70513ae1f8d92665bbbbda5c295c2cf1da5542881ae5eefe20c9af132" -dependencies = [ - "js-sys", - "serde", - "wasm-bindgen", -] - -[[package]] -name = "serde_derive" -version = "1.0.196" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.113" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "serial_test" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953ad9342b3aaca7cb43c45c097dd008d4907070394bd0751a0aa8817e5a018d" -dependencies = [ - "dashmap", - "futures", - "lazy_static", - "log", - "parking_lot", - "serial_test_derive", -] - -[[package]] -name = "serial_test_derive" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b93fb4adc70021ac1b47f7d45e8cc4169baaa7ea58483bc5b721d19a26202212" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "simd-adler32" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" - -[[package]] -name = "slab" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" -dependencies = [ - "autocfg", -] - -[[package]] -name = "slab_tree" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9e8b45abe77b7cab703054a11973cffe164c82c5ff5e211ae5a73af5e42e39f" -dependencies = [ - "snowflake", -] - -[[package]] -name = "smallvec" -version = "1.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" - -[[package]] -name = "snowflake" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27207bb65232eda1f588cf46db2fee75c0808d557f6b3cf19a75f5d6d7c94df1" - -[[package]] -name = "str-buf" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e08d8363704e6c71fc928674353e6b7c23dcea9d82d7012c8faf2a3a025f8d0" - -[[package]] -name = "strum" -version = "0.26.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "723b93e8addf9aa965ebe2d11da6d7540fa2283fcea14b3371ff055f7ba13f5f" -dependencies = [ - "strum_macros", -] - -[[package]] -name = "strum_macros" -version = "0.26.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a3417fc93d76740d974a01654a09777cb500428cc874ca9f45edfe0c4d4cd18" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "rustversion", - "syn", -] - -[[package]] -name = "syn" -version = "2.0.48" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "thiserror" -version = "1.0.56" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.56" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tiff" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba1310fcea54c6a9a4fd1aad794ecc02c31682f6bfbecdf460bf19533eed1e3e" -dependencies = [ - "flate2", - "jpeg-decoder", - "weezl", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "unicode-segmentation" -version = "1.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" - -[[package]] -name = "unicode-width" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" - -[[package]] -name = "utf8parse" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "wasm-bindgen" -version = "0.2.91" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" -dependencies = [ - "cfg-if 1.0.0", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.91" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.41" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877b9c3f61ceea0e56331985743b13f3d25c406a7098d45180fb5f09bc19ed97" -dependencies = [ - "cfg-if 1.0.0", - "js-sys", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.91" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.91" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.91" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" - -[[package]] -name = "wasm-bindgen-test" -version = "0.3.41" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143ddeb4f833e2ed0d252e618986e18bfc7b0e52f2d28d77d05b2f045dd8eb61" -dependencies = [ - "console_error_panic_hook", - "js-sys", - "scoped-tls", - "wasm-bindgen", - "wasm-bindgen-futures", - "wasm-bindgen-test-macro", -] - -[[package]] -name = "wasm-bindgen-test-macro" -version = "0.3.41" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5211b7550606857312bba1d978a8ec75692eae187becc5e680444fffc5e6f89" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "web-sys" -version = "0.3.68" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96565907687f7aceb35bc5fc03770a8a0471d82e479f25832f54a0e3f4b28446" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "wee_alloc" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e" -dependencies = [ - "cfg-if 0.1.10", - "libc", - "memory_units", - "winapi", -] - -[[package]] -name = "weezl" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082" - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-wsapoll" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c17110f57155602a80dca10be03852116403c9ff3cd25b079d666f2aa3df6e" -dependencies = [ - "winapi", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", -] - -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets 0.52.0", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", -] - -[[package]] -name = "windows-targets" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" -dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" - -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" - -[[package]] -name = "x11rb" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1641b26d4dec61337c35a1b1aaf9e3cba8f46f0b43636c609ab0291a648040a" -dependencies = [ - "gethostname", - "nix 0.26.4", - "winapi", - "winapi-wsapoll", - "x11rb-protocol", -] - -[[package]] -name = "x11rb-protocol" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82d6c3f9a0fb6701fab8f6cea9b0c0bd5d6876f1f89f7fada07e558077c344bc" -dependencies = [ - "nix 0.26.4", -] diff --git a/Cargo.toml b/Cargo.toml index 2cb51db..648b138 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ description = "namespaces aliases for command lines & basic scripting language" homepage = "https://github.com/nbittich/adana" repository = "https://github.com/nbittich/adana" readme = "README.md" -rust-version = "1.75" +rust-version = "1.76" edition = "2021" license = "MIT" exclude = ["vscode/", "dist/", ".vscode", ".history", ".git", ".github"] @@ -48,6 +48,8 @@ console_error_panic_hook = { version = "0.1.7" } serde-wasm-bindgen = "0.6.3" wee_alloc = "0.4.5" wasm-bindgen-test = "0.3.41" +web-sys = "0.3.68" + # workspace specific libs adana-script-core = { version = "0.17.2", path = "./adana-script-core" } adana-script = { version = "0.17.2", path = "./adana-script" } diff --git a/Dockerfile b/Dockerfile index ea7f23a..fe6eae1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM rust:1.75-bookworm as builder +FROM rust:1.76-bookworm as builder WORKDIR /app @@ -10,7 +10,7 @@ COPY . . RUN cargo build --release -FROM rust:1.75-slim-bookworm +FROM rust:1.76-slim-bookworm ENV RUST_LOG=info diff --git a/README.md b/README.md index 1826341..b35053e 100644 --- a/README.md +++ b/README.md @@ -530,6 +530,7 @@ Below, is a list of types and how you declare them. You can also define your str | array | `[1,2,"3", true]` | | function | `() => {"hello"}`
`(name) => {"hello" + name}`
`(n) => {`
  `"hello"`
` }` | | struct | `struct {x: 8, y: ()=> {println("hello!")}}` | +| error | `make_err("could not process...")` |
@@ -744,29 +745,39 @@ You already have seen `length` to find the length of an array or string, `includ Here is a list of built-in functions available: -| name | description | example | -| --------- | ---------------------------- | ---------------------------------- | -| sqrt | square root | `sqrt(2)` | -| abs | absolute value | `abs(-2)` | -| log | logarithm | `log(2)` | -| ln | natural logarithm | `ln(2)` | -| length | length of an array or string | `length("azert")` | -| sin | sine of a number | `sin(2)` | -| cos | cosine of a number | `cos(2)` | -| tan | tangent of a number | `tan(2.2)` | -| print | print without a newline | `print("hello")` | -| println | print with a newline | `println("hello")` | -| include | include a script | `include("scripts/test_fn.adana")` | -| require | load a shared object | `require("my_lib.so")` | -| to_int | cast to int | `to_int("2")`
`to_int(2.2)` | -| to_hex | format num to hex | `to_hex(2)`
`to_hex(2.2)` | -| to_binary | format num to binary | `to_binary(2)` | -| to_double | cast to double | `to_double("2.2")` | -| to_bool | cast to bool | `to_bool("true")` | -| to_string | cast to string | `to_string(true)` | -| drop | drop a variable from context | `drop("myvar")`
`drop(arr[0])` | -| eval | Evaluate a string as code | `eval("sqrt(9)")` | -| type_of | Type of variable | `type_of(true)` | +| name | description | example | +| ----------- | ---------------------------- | ---------------------------------- | +| sqrt | square root | `sqrt(2)` | +| abs | absolute value | `abs(-2)` | +| log | logarithm | `log(2)` | +| ln | natural logarithm | `ln(2)` | +| length | length of an array or string | `length("azert")` | +| sin | sine of a number | `sin(2)` | +| cos | cosine of a number | `cos(2)` | +| tan | tangent of a number | `tan(2.2)` | +| print | print without a newline | `print("hello")` | +| println | print with a newline | `println("hello")` | +| include | include a script | `include("scripts/test_fn.adana")` | +| require | load a shared object | `require("my_lib.so")` | +| to_int | cast to int | `to_int("2")`
`to_int(2.2)` | +| to_hex | format num to hex | `to_hex(2)`
`to_hex(2.2)` | +| to_binary | format num to binary | `to_binary(2)` | +| to_double | cast to double | `to_double("2.2")` | +| to_bool | cast to bool | `to_bool("true")` | +| to_string | cast to string | `to_string(true)` | +| drop | drop a variable from context | `drop("myvar")`
`drop(arr[0])` | +| eval | Evaluate a string as code | `eval("sqrt(9)")` | +| type_of | Type of variable | `type_of(true)` | +| is_u8 | Check if u8 | `is_u8(0x1)` | +| is_i8 | Check if i8 | `is_i8(-1)` | +| is_int | Check if int | `is_int(512)` | +| is_double | Check if double | `is_double(1.2)` | +| is_function | Check if function | `is_function(()=> {1})` | +| is_struct | Check if struct | `is_struct(struct {})` | +| is_bool | Check if bool | `is_bool(false)` | +| is_array | Check if array | `is_bool([1,2])` | +| is_error | Check if error | `is_error(err)` | +| make_err | Create an error | `make_err("oops")` |
diff --git a/adana-playground/.gitignore b/adana-playground/.gitignore new file mode 100644 index 0000000..5fff1d9 --- /dev/null +++ b/adana-playground/.gitignore @@ -0,0 +1 @@ +pkg diff --git a/adana-playground/README.md b/adana-playground/README.md new file mode 100644 index 0000000..30382fd --- /dev/null +++ b/adana-playground/README.md @@ -0,0 +1,7 @@ +# adana-playground + +## WIP + +### todo + +- clear the heap diff --git a/adana-playground/app.js b/adana-playground/app.js new file mode 100644 index 0000000..0a20071 --- /dev/null +++ b/adana-playground/app.js @@ -0,0 +1,112 @@ +import { EXAMPLES } from "./examples.js"; + +async function loadWasmContext() { + const module = await import("./pkg/adana_script_wasm.js"); + await module.default(); + return module.compute_as_string; +} + +function toggleForm(form, toggle) { + const elements = form.elements; + for (let i = 0, len = elements.length; i < len; ++i) { + elements[i].readOnly = toggle; + } + const submitButton = form.querySelector('button[type="submit"]'); + submitButton.disabled = toggle; +} +async function run() { + const form = document.querySelector("form"); + form.classList.add("d-none"); + + let compute = await loadWasmContext(); + + const memory = new WebAssembly.Memory({ + initial: 32, // 2mb + maximum: 512, // 32mb + shared: true, + }); + + const ctx = new Uint8Array(memory.buffer); + + form.classList.remove("d-none"); + + const text_area = document.querySelector("#code"); + text_area.value = ""; + text_area.focus(); + + const out = document.querySelector("#out"); + out.value = ""; + + let logs = []; + + console.log = function () { + for (const a of arguments) { + logs.push(a); + } + }; + + const select = document.querySelector("#examples"); + for (const example of EXAMPLES) { + const option = document.createElement("option"); + option.innerText = example.label; + option.value = example.key; + select.appendChild(option); + } + + select.addEventListener("change", function (e) { + const key = e.target.value; + const example = EXAMPLES.find((e) => e.key === key); + if (example) { + text_area.value = example.script; + } + }); + + form.addEventListener("submit", async (e) => { + e.preventDefault(); + toggleForm(form, true); + logs = []; + out.classList.remove("text-danger"); + + const data = new FormData(e.target); + for (let i = 0; i < ctx.length; i++) { + ctx[i] = undefined; + } + try { + let res = compute(data.get("code") || "", ctx); + // console.log(res); + out.value = logs.join(""); + toggleForm(form, false); + } catch (e) { + out.classList.add("text-danger"); + out.value = e.toString(); + compute = await loadWasmContext(); + toggleForm(form, false); + } + }); + const issueLink = document.querySelector("#issueLink"); + issueLink.onclick = (e) => { + e.preventDefault(); + const a = document.createElement("a"); + let params = new URLSearchParams(); + const data = new FormData(form); + params.append("title", "Adana playground bug"); + + a.href = `https://github.com/nbittich/adana/issues/new?${params.toString()}`; + a.target = "_blank"; + a.click(); + }; + + const copyToClipboardBtn = document.querySelector("#copyToClipboard"); + copyToClipboardBtn.onclick = function (e) { + e.preventDefault(); + if (out.value) { + navigator.clipboard.writeText(out.value); + + alert("Copied to clipboard"); + } else { + alert("Nothing to copy"); + } + }; +} + +run(); diff --git a/adana-playground/examples.js b/adana-playground/examples.js new file mode 100644 index 0000000..6081dd2 --- /dev/null +++ b/adana-playground/examples.js @@ -0,0 +1,235 @@ +export const EXAMPLES = [ + { + key: "fizz_buzz", + label: "Fizz Buzz", + script: `num = 100 +count = 0 +text = "" + while count == 0 || count <= num { + if count % 3 == 0 && count % 5 == 0 { + # Fizz Buzz + text = count + " = FizzBuzz" + println(text) + + } else if count % 5 == 0 { + # buzz + text = count + " = Buzz" # oops + println(text) + } else if count % 3 == 0 { + #fizz + text = count + " = Fizz" + println(text) + + } else { + println(count + " neither fizz nor buzz") + } + count += 1 +} +`, + }, + { + key: "fib", + label: "Fibonnacci", + script: `fib = (n) => { + a = 0 + b = 1 + c = n + x = null + while n > 1 { + n -= 1 + c = a + b + a = b + b = c + } + c +} + +for i in 0..10 { + println("""fib(\${i}): \${fib(i)}""") +} +`, + }, + { + key: "fact", + label: "Factorial", + script: `fact = (n) => { + if n>=1 { + n * fact(n-1) + } else { + 1 + } +} + +for i in 0..10 { + println("""fact(\${i}): \${fact(i)}""") +}`, + }, + { + key: "strings", + label: "Strings", + script: `v = "eodrnin" +count = 0 +# we can iterate over a string +while count < length(v) { + println(v[count]) + count = count + 1 +} + +copy = v + +v[0] = copy[6] +v[2] = copy[3] +v[3] = copy[2] +v[4] = copy[5] +v[5] = copy[6] +v[6] = copy[0] + +i = 0 + +s = "" + +while i < length("kekeke") { + s += "kekeke"[i] + i += 1 +} + +println(v) +`, + }, + { + key: "sort", + label: "Sort array of structs", + script: `# sort array of students +student_1 = struct { + first_name: "John", + last_name: "Doe", + note: 18 +} +student_2 = struct { + first_name: "Jane", + last_name: "Dow", + note: 9 +} + +student_3 = struct { + first_name: "Bryan", + last_name: "Bower", + note: -10 +} + +students = [student_1, student_2, student_3] + +sort = (students) => { + sorted = false + while !sorted { + sorted = true + len = length(students)-1 + for i in 0..len { + left = students[i] + right = students[i+1] + if left.note > right.note { + sorted = false + students[i] = right + students[i+1] = left + } + } + } + students +} + +println(sort(students)) +`, + }, + { + key: "arrays", + label: "Arrays", + script: `# initial array +arr = ["a", true, "bababa", ("ze" * 4 ), 1, 2.1, 3.] + +arr += [69, 420] # append to array + +arr *= 2 # duplicate values in the array + +arrlen = length(arr) # length of the array should be 18 + +copy = [] + +count = 0 + +# copy the array one by one +while count < arrlen { + copy = copy + [arr[count]] + count = count + 1 +} + +println(length(copy) == length(arr)) +println("""Are same: \${copy == arr}""") + +# mutate array +arr[9] = "Yolo" +println(arr) + +# fancy list +i = 9 +list = [] + +while i !=0 { + list = [i, list] + i = i -1 +} + +# should print [1, [2, [3, [4, [5, [6, [7, [8, [9, []]]]]]]]]] +println(list) + +# should print 2 +println(length(list)) +`, + }, + { + key: "maps", + label: "Key-Value Map", + script: `map = () => { + [] +} + +push_v = (key, value, m) => { + idx = index_of_v(key, m) + if(idx != null) { + m[idx] = [key, value] + } else { + m = [[key, value]] + m + } + m + +} + +get_v = (key, m) => { + res = null + idx = index_of_v(key,m) + if(idx != null) { + k = m[idx] + res = k[1] + } + res +} + +index_of_v = (key, m) => { + count = 0 + res = null + while(count < length(m)) { + k = m[count] + if(k[0] == key) { + res = count + break + } else { + count += 1 + } + } + res +} + +m = map() +m = push_v("nordine", 34, m) +println(get_v("nordine", m))`, + }, +]; diff --git a/adana-playground/favicon.ico b/adana-playground/favicon.ico new file mode 100644 index 0000000..ba94e48 Binary files /dev/null and b/adana-playground/favicon.ico differ diff --git a/adana-playground/index.html b/adana-playground/index.html new file mode 100644 index 0000000..f94f537 --- /dev/null +++ b/adana-playground/index.html @@ -0,0 +1,69 @@ + + + + + + + Adana Playground + + + + + + + + +
+

Adana Playground

+

+ The + adana + programming language playground. If you find any bug, please + open an issue. +

+
+
+
+
+
+
+
+
+
+ + +
+
+
+ +
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+ + + diff --git a/adana-playground/serve.sh b/adana-playground/serve.sh new file mode 100644 index 0000000..69a4f71 --- /dev/null +++ b/adana-playground/serve.sh @@ -0,0 +1 @@ +python -m http.server 8000 diff --git a/adana-playground/style.css b/adana-playground/style.css new file mode 100644 index 0000000..b8f7614 --- /dev/null +++ b/adana-playground/style.css @@ -0,0 +1,36 @@ +* { + --bs-body-bg: black; +} + +.form-select { + --bs-border-radius: 0; +} + +.btn { + --bs-btn-border-radius: 0; +} + +.card { + border-radius: 0 !important; +} + +.terminal { + resize: none; + border-radius: 0; + background-color: var(--bs-body-bg) !important; + outline: none !important; + caret-color: lime; + /* Color of the cursor */ +} + +textarea:focus { + user-select: none !important; + outline: none !important; + box-shadow: none !important; +} + +@media (min-width: 720px) { + .terminal { + height: 82vh !important; + } +} diff --git a/adana-playground/update.sh b/adana-playground/update.sh new file mode 100644 index 0000000..85012b3 --- /dev/null +++ b/adana-playground/update.sh @@ -0,0 +1,3 @@ +rm -rf pkg +npm v @nbittich/adana-script-wasm dist.tarball | xargs curl | tar -xz +mv package pkg diff --git a/adana-script-core/src/lib.rs b/adana-script-core/src/lib.rs index 0a4926e..42ee600 100644 --- a/adana-script-core/src/lib.rs +++ b/adana-script-core/src/lib.rs @@ -2,9 +2,12 @@ pub mod primitive; use std::collections::BTreeMap; use constants::{ - BREAK, DROP, ELSE, EULER_NUMBER, FALSE, FOR, IF, IN, MULTILINE, NULL, PI, - REQUIRE, RETURN, STRUCT, TAU, TO_BINARY, TO_HEX, TRUE, WHILE, + BREAK, DROP, ELSE, EULER_NUMBER, FALSE, FOR, IF, IN, IS_ARRAY, IS_BOOL, + IS_DOUBLE, IS_ERROR, IS_FUNCTION, IS_I8, IS_INT, IS_STRUCT, IS_U8, + MAKE_ERROR, MULTILINE, NULL, PI, REQUIRE, RETURN, STRUCT, TAU, TO_BINARY, + TO_HEX, TRUE, WHILE, }; + use primitive::Primitive; use serde::{Deserialize, Serialize}; use strum::EnumCount; @@ -47,6 +50,16 @@ pub mod constants { pub const TO_BOOL: &str = "to_bool"; pub const TO_DOUBLE: &str = "to_double"; pub const TO_STRING: &str = "to_string"; + pub const IS_ERROR: &str = "is_error"; + pub const IS_U8: &str = "is_u8"; + pub const IS_I8: &str = "is_i8"; + pub const IS_INT: &str = "is_int"; + pub const IS_DOUBLE: &str = "is_double"; + pub const IS_BOOL: &str = "is_bool"; + pub const IS_FUNCTION: &str = "is_function"; + pub const IS_ARRAY: &str = "is_array"; + pub const IS_STRUCT: &str = "is_struct"; + pub const MAKE_ERROR: &str = "make_err"; pub const ABS: &str = "abs"; pub const LENGTH: &str = "length"; pub const LOG: &str = "log"; @@ -188,6 +201,16 @@ pub enum BuiltInFunctionType { Length, Include, Require, + IsError, + IsU8, + IsI8, + IsStruct, + IsBool, + IsInt, + MakeError, + IsDouble, + IsFunction, + IsArray, } #[derive(Debug, Eq, PartialEq, Copy, Clone, Serialize, Deserialize)] @@ -265,6 +288,16 @@ impl BuiltInFunctionType { BuiltInFunctionType::ToDouble => TO_DOUBLE, BuiltInFunctionType::ToBool => TO_BOOL, BuiltInFunctionType::ToString => TO_STRING, + BuiltInFunctionType::IsError => IS_ERROR, + BuiltInFunctionType::IsU8 => IS_U8, + BuiltInFunctionType::IsI8 => IS_I8, + BuiltInFunctionType::IsStruct => IS_STRUCT, + BuiltInFunctionType::IsBool => IS_BOOL, + BuiltInFunctionType::IsInt => IS_INT, + BuiltInFunctionType::IsDouble => IS_DOUBLE, + BuiltInFunctionType::IsFunction => IS_FUNCTION, + BuiltInFunctionType::IsArray => IS_ARRAY, + BuiltInFunctionType::MakeError => MAKE_ERROR, } } } @@ -315,6 +348,16 @@ pub const FORBIDDEN_VARIABLE_NAME: &[&str] = &[ TO_HEX, TO_BINARY, TO_STRING, + IS_FUNCTION, + IS_DOUBLE, + IS_INT, + IS_STRUCT, + IS_U8, + IS_ERROR, + IS_I8, + IS_BOOL, + IS_ARRAY, + MAKE_ERROR, EVAL, TO_BOOL, SQRT, diff --git a/adana-script-core/src/primitive.rs b/adana-script-core/src/primitive.rs index e0d2b3f..d87c9b3 100644 --- a/adana-script-core/src/primitive.rs +++ b/adana-script-core/src/primitive.rs @@ -14,6 +14,21 @@ use super::{constants::NULL, Value}; const MAX_U32_AS_I128: i128 = u32::MAX as i128; +pub const TYPE_U8: &str = "u8"; +pub const TYPE_I8: &str = "i8"; +pub const TYPE_INT: &str = "int"; +pub const TYPE_BOOL: &str = "bool"; +pub const TYPE_NULL: &str = "null"; +pub const TYPE_DOUBLE: &str = "double"; +pub const TYPE_STRING: &str = "string"; +pub const TYPE_ARRAY: &str = "array"; +pub const TYPE_ERROR: &str = "error"; +pub const TYPE_NATIVE_LIB: &str = "nativeLibrary"; +pub const TYPE_FUNCTION: &str = "function"; +pub const TYPE_UNIT: &str = "unit"; +pub const TYPE_STRUCT: &str = "struct"; +pub const TYPE_NO_RETURN: &str = "!"; + #[derive(Debug)] pub struct NativeLibrary { #[cfg(target_arch = "wasm32")] @@ -192,6 +207,7 @@ impl Primitive { pub trait TypeOf { fn type_of(&self) -> Self; + fn type_of_str(&self) -> &'static str; } pub trait BitShift { fn left_shift(&self, n: &Self) -> Self; @@ -1711,34 +1727,36 @@ impl PartialOrd for Primitive { } impl TypeOf for Primitive { - fn type_of(&self) -> Self { + fn type_of_str(&self) -> &'static str { match self { Primitive::Ref(l) => { let l = l.read().expect("TYPE_OF ERROR: could not acquire lock!"); - l.type_of() - } - Primitive::U8(_) => Primitive::String("u8".to_string()), - Primitive::I8(_) => Primitive::String("i8".to_string()), - Primitive::Int(_) => Primitive::String("int".to_string()), - Primitive::Bool(_) => Primitive::String("bool".to_string()), - Primitive::Null => Primitive::String("null".to_string()), - Primitive::Double(_) => Primitive::String("double".to_string()), - Primitive::String(_) => Primitive::String("string".to_string()), - Primitive::Array(_) => Primitive::String("array".to_string()), - Primitive::Error(_) => Primitive::String("error".to_string()), - Primitive::NativeLibrary(_) => { - Primitive::String("nativeLibrary".into()) - } + l.type_of_str() + } + Primitive::U8(_) => TYPE_U8, + Primitive::I8(_) => TYPE_I8, + Primitive::Int(_) => TYPE_INT, + Primitive::Bool(_) => TYPE_BOOL, + Primitive::Null => TYPE_NULL, + Primitive::Double(_) => TYPE_DOUBLE, + Primitive::String(_) => TYPE_STRING, + Primitive::Array(_) => TYPE_ARRAY, + Primitive::Error(_) => TYPE_ERROR, + Primitive::NativeLibrary(_) => TYPE_NATIVE_LIB, Primitive::Function { .. } | Primitive::NativeFunction(_, _) => { - Primitive::String("function".to_string()) + TYPE_FUNCTION } - Primitive::Struct(_) => Primitive::String("struct".to_string()), - Primitive::Unit => Primitive::String("unit".to_string()), - Primitive::NoReturn => Primitive::String("!".to_string()), - Primitive::EarlyReturn(v) => v.type_of(), + Primitive::Struct(_) => TYPE_STRUCT, + Primitive::Unit => TYPE_UNIT, + Primitive::NoReturn => TYPE_NO_RETURN, + Primitive::EarlyReturn(v) => v.type_of_str(), } } + + fn type_of(&self) -> Self { + Primitive::String(self.type_of_str().to_string()) + } } impl Array for Primitive { diff --git a/adana-script-wasm/Cargo.toml b/adana-script-wasm/Cargo.toml index 49b28aa..95b242b 100644 --- a/adana-script-wasm/Cargo.toml +++ b/adana-script-wasm/Cargo.toml @@ -20,6 +20,8 @@ crate-type = ["cdylib", "rlib"] default = ["wee_alloc", "console_error_panic_hook"] [dependencies] + +[target.'cfg(target_arch = "wasm32")'.dependencies] wasm-bindgen = { workspace = true } adana-script.workspace = true adana-script-core.workspace = true diff --git a/adana-script-wasm/src/lib.rs b/adana-script-wasm/src/lib.rs index 166ef48..a864141 100644 --- a/adana-script-wasm/src/lib.rs +++ b/adana-script-wasm/src/lib.rs @@ -1,16 +1,18 @@ +#![cfg(target_arch = "wasm32")] + mod utils; -use adana_script_core::primitive::RefPrimitive; +use adana_script_core::primitive::{Primitive, RefPrimitive}; use std::collections::BTreeMap; use wasm_bindgen::prelude::*; #[global_allocator] static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; -#[wasm_bindgen] -pub fn compute(script: &str, mem: &mut [u8]) -> Result { +fn compute( + script: &str, + mem: &mut [u8], +) -> Result<(BTreeMap, Primitive), JsError> { utils::set_panic_hook(); - // wasm memory: - // https://developer.mozilla.org/fr/docs/WebAssembly/JavaScript_interface/Memory let mut ctx: BTreeMap = if !mem.is_empty() { bincode::deserialize(mem)? } else { @@ -21,6 +23,49 @@ pub fn compute(script: &str, mem: &mut [u8]) -> Result { .map_err(|e| e.to_string()) .map_err(|e| JsError::new(&e))?; + Ok((ctx, result)) +} +#[wasm_bindgen] +pub fn compute_as_js_value( + script: &str, + mem: &mut [u8], +) -> Result { + let (ctx, result) = compute(script, mem)?; bincode::serialize_into(mem, &ctx)?; + Ok(serde_wasm_bindgen::to_value(&result)?) } + +#[wasm_bindgen] +pub fn compute_as_string( + script: &str, + mem: &mut [u8], +) -> Result { + let (ctx, result) = compute(script, mem)?; + + let result = { + if let Some(out) = ctx.get("") { + let mut out_rl = out.write()?; + + match &mut *out_rl { + Primitive::Array(ref mut a) if !a.is_empty() => { + let mut s = String::new(); + for p in a.drain(0..) { + s.push_str(&p.to_string()); + } + if !matches!(result, Primitive::Unit) { + s.push_str(&result.to_string()); + } + + Ok(s) + } + _ => Ok(result.to_string()), + } + } else { + Ok(result.to_string()) + } + }; + bincode::serialize_into(mem, &ctx)?; + + result +} diff --git a/adana-script-wasm/tests/web.rs b/adana-script-wasm/tests/web.rs index 4b95afd..3d71008 100644 --- a/adana-script-wasm/tests/web.rs +++ b/adana-script-wasm/tests/web.rs @@ -5,19 +5,20 @@ extern crate wasm_bindgen_test; use adana_script_core::primitive::{Primitive, RefPrimitive}; -use adana_script_wasm::compute; +use adana_script_wasm::compute_as_js_value; use std::assert_eq; use std::collections::BTreeMap; use wasm_bindgen::JsValue; use wasm_bindgen_test::*; + wasm_bindgen_test_configure!(run_in_browser); #[wasm_bindgen_test] -fn compute_test() { +fn compute_as_js_value_test() { let mut memory = vec![0; 64]; - let res = compute("x = 1+1", &mut memory).map_err(JsValue::from).unwrap(); - - //wasm_bindgen_test::console_log!("{memory:?}"); + let res = compute_as_js_value("x = 1+1", &mut memory) + .map_err(JsValue::from) + .unwrap(); let res: Primitive = serde_wasm_bindgen::from_value(res).unwrap(); assert_eq!(Primitive::Int(2), res); let ctx: BTreeMap = diff --git a/adana-script/Cargo.toml b/adana-script/Cargo.toml index 5fba23e..680c75a 100644 --- a/adana-script/Cargo.toml +++ b/adana-script/Cargo.toml @@ -17,6 +17,11 @@ adana-script-core.workspace = true anyhow.workspace = true slab_tree.workspace = true + +[target.'cfg(target_arch = "wasm32")'.dependencies] +web-sys = { workspace = true, features = ["console"] } +wasm-bindgen.workspace = true + [dev-dependencies] # some test must run sequentially. # if library is broken, alternative is: cargo test -- --test-threads 1 diff --git a/adana-script/dynamic_lib/example_lib_src/Cargo.lock b/adana-script/dynamic_lib/example_lib_src/Cargo.lock index 26ad186..6721b67 100644 --- a/adana-script/dynamic_lib/example_lib_src/Cargo.lock +++ b/adana-script/dynamic_lib/example_lib_src/Cargo.lock @@ -4,14 +4,11 @@ version = 3 [[package]] name = "adana-script-core" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa8a7bb732df5f039dcadd732decc5d1f77c4ab72cc595a1b7d359ea9bfe98ba" +version = "0.17.2" dependencies = [ "anyhow", "libloading", "serde", - "serde_derive", "strum", ] diff --git a/adana-script/dynamic_lib/example_lib_src/Cargo.toml b/adana-script/dynamic_lib/example_lib_src/Cargo.toml index beca582..1949584 100644 --- a/adana-script/dynamic_lib/example_lib_src/Cargo.toml +++ b/adana-script/dynamic_lib/example_lib_src/Cargo.toml @@ -11,7 +11,7 @@ edition = "2021" crate-type = ["dylib"] [dependencies] -adana-script-core = "0.16.1" +adana-script-core = { path = "./../../../adana-script-core" } #adana-script-core = { git = "https://github.com/nbittich/adana-script-core.git", branch = "feature/bitwise-and-new-ints" } anyhow = "1.0.79" diff --git a/adana-script/dynamic_lib/libplugin_example.so b/adana-script/dynamic_lib/libplugin_example.so index deaa7a9..4c3207b 100755 Binary files a/adana-script/dynamic_lib/libplugin_example.so and b/adana-script/dynamic_lib/libplugin_example.so differ diff --git a/adana-script/examples/example1.adana b/adana-script/examples/example1.adana index 56fd9c9..a28dad9 100644 --- a/adana-script/examples/example1.adana +++ b/adana-script/examples/example1.adana @@ -22,13 +22,13 @@ students = [student_1, student_2, student_3] sort = (students) => { sorted = false - while(!sorted) { + while !sorted { sorted = true len = length(students)-1 for i in 0..len { left = students[i] right = students[i+1] - if(left.note > right.note) { + if left.note > right.note { sorted = false students[i] = right students[i+1] = left diff --git a/adana-script/file_tests/string.adana b/adana-script/file_tests/string.adana index b557996..6eeaaa9 100644 --- a/adana-script/file_tests/string.adana +++ b/adana-script/file_tests/string.adana @@ -11,12 +11,12 @@ split = (s, c) => { count = 0 while count < length(s) { curr = s[count] - if(buf == "aka") { + if buf == "aka" { return [buf] } - if(curr != c) { + if curr != c { buf = buf + s[count] - }else{ + } else { res = res + [buf] buf = "" } diff --git a/adana-script/file_tests/test_fizzbuzz_else.adana b/adana-script/file_tests/test_fizzbuzz_else.adana index 446da1b..305e173 100644 --- a/adana-script/file_tests/test_fizzbuzz_else.adana +++ b/adana-script/file_tests/test_fizzbuzz_else.adana @@ -2,7 +2,7 @@ count = -1 text = "" while count <= 100 { - count = count + 1 + count += 1 if count % 3 == 0 && count % 5 == 0 { # Fizz Buzz text = count + " = FizzBuzz" diff --git a/adana-script/src/compute.rs b/adana-script/src/compute.rs index 7aa53a9..08c6009 100644 --- a/adana-script/src/compute.rs +++ b/adana-script/src/compute.rs @@ -10,11 +10,14 @@ use std::{ use crate::{parser::parse_instructions, prelude::BTreeMap}; use super::{ast::to_ast, require_dynamic_lib::require_dynamic_lib}; + use adana_script_core::{ primitive::{ Abs, Add, And, Array, BitShift, Cos, DisplayBinary, DisplayHex, Div, Logarithm, Mul, Neg, Not, Or, Pow, Primitive, RefPrimitive, Rem, Sin, - Sqrt, Sub, Tan, ToBool, ToNumber, TypeOf, + Sqrt, Sub, Tan, ToBool, ToNumber, TypeOf, TYPE_ARRAY, TYPE_BOOL, + TYPE_DOUBLE, TYPE_ERROR, TYPE_FUNCTION, TYPE_I8, TYPE_INT, TYPE_STRUCT, + TYPE_U8, }, BuiltInFunctionType, Operator, TreeNodeValue, Value, }; @@ -349,12 +352,36 @@ fn compute_recur( Ok(v.len()) } adana_script_core::BuiltInFunctionType::Println => { - println!("{v}"); - Ok(Primitive::Unit) + #[cfg(not(target_arch = "wasm32"))] + { + println!("{v}"); + Ok(Primitive::Unit) + } + #[cfg(target_arch = "wasm32")] + { + web_sys::console::log_1( + &wasm_bindgen::JsValue::from_str(&format!( + "{v}\n" + )), + ); + Ok(Primitive::Unit) + } } adana_script_core::BuiltInFunctionType::Print => { - print!("{v}"); - Ok(Primitive::Unit) + #[cfg(not(target_arch = "wasm32"))] + { + print!("{v}"); + Ok(Primitive::Unit) + } + #[cfg(target_arch = "wasm32")] + { + web_sys::console::log_1( + &wasm_bindgen::JsValue::from_str(&format!( + "{v}" + )), + ); + Ok(Primitive::Unit) + } } adana_script_core::BuiltInFunctionType::Require => { match v { @@ -435,6 +462,36 @@ fn compute_recur( adana_script_core::BuiltInFunctionType::TypeOf => { Ok(v.type_of()) } + adana_script_core::BuiltInFunctionType::IsError => { + Ok(Primitive::Bool(v.type_of_str() == TYPE_ERROR)) + } + adana_script_core::BuiltInFunctionType::IsU8 => { + Ok(Primitive::Bool(v.type_of_str() == TYPE_U8)) + } + adana_script_core::BuiltInFunctionType::IsI8 => { + Ok(Primitive::Bool(v.type_of_str() == TYPE_I8)) + } + adana_script_core::BuiltInFunctionType::IsStruct => { + Ok(Primitive::Bool(v.type_of_str() == TYPE_STRUCT)) + } + adana_script_core::BuiltInFunctionType::IsBool => { + Ok(Primitive::Bool(v.type_of_str() == TYPE_BOOL)) + } + adana_script_core::BuiltInFunctionType::IsInt => { + Ok(Primitive::Bool(v.type_of_str() == TYPE_INT)) + } + adana_script_core::BuiltInFunctionType::IsDouble => { + Ok(Primitive::Bool(v.type_of_str() == TYPE_DOUBLE)) + } + adana_script_core::BuiltInFunctionType::IsFunction => { + Ok(Primitive::Bool(v.type_of_str() == TYPE_FUNCTION)) + } + adana_script_core::BuiltInFunctionType::IsArray => { + Ok(Primitive::Bool(v.type_of_str() == TYPE_ARRAY)) + } + adana_script_core::BuiltInFunctionType::MakeError => { + Ok(Primitive::Error(v.to_string())) + } } } TreeNodeValue::IfExpr(v) => { diff --git a/adana-script/src/parser.rs b/adana-script/src/parser.rs index 55cda74..e742aea 100644 --- a/adana-script/src/parser.rs +++ b/adana-script/src/parser.rs @@ -415,26 +415,42 @@ fn parse_builtin_fn(s: &str) -> Res { } } alt(( - parse_builtin(BuiltInFunctionType::Sqrt), - parse_builtin(BuiltInFunctionType::Abs), - parse_builtin(BuiltInFunctionType::Ln), - parse_builtin(BuiltInFunctionType::Log), - parse_builtin(BuiltInFunctionType::Sin), - parse_builtin(BuiltInFunctionType::Cos), - parse_builtin(BuiltInFunctionType::ToInt), - parse_builtin(BuiltInFunctionType::ToDouble), - parse_builtin(BuiltInFunctionType::ToHex), - parse_builtin(BuiltInFunctionType::ToBinary), - parse_builtin(BuiltInFunctionType::TypeOf), - parse_builtin(BuiltInFunctionType::ToBool), - parse_builtin(BuiltInFunctionType::ToString), parse_builtin(BuiltInFunctionType::Eval), - parse_builtin(BuiltInFunctionType::Tan), parse_builtin(BuiltInFunctionType::Println), parse_builtin(BuiltInFunctionType::Print), parse_builtin(BuiltInFunctionType::Length), parse_builtin(BuiltInFunctionType::Include), parse_builtin(BuiltInFunctionType::Require), + parse_builtin(BuiltInFunctionType::MakeError), + alt(( + parse_builtin(BuiltInFunctionType::IsU8), + parse_builtin(BuiltInFunctionType::IsI8), + parse_builtin(BuiltInFunctionType::IsInt), + parse_builtin(BuiltInFunctionType::IsDouble), + parse_builtin(BuiltInFunctionType::IsError), + parse_builtin(BuiltInFunctionType::IsStruct), + parse_builtin(BuiltInFunctionType::IsFunction), + parse_builtin(BuiltInFunctionType::IsBool), + parse_builtin(BuiltInFunctionType::IsArray), + )), + alt(( + parse_builtin(BuiltInFunctionType::ToHex), + parse_builtin(BuiltInFunctionType::ToBinary), + parse_builtin(BuiltInFunctionType::TypeOf), + parse_builtin(BuiltInFunctionType::ToInt), + parse_builtin(BuiltInFunctionType::ToDouble), + parse_builtin(BuiltInFunctionType::ToBool), + parse_builtin(BuiltInFunctionType::ToString), + )), + alt(( + parse_builtin(BuiltInFunctionType::Sqrt), + parse_builtin(BuiltInFunctionType::Abs), + parse_builtin(BuiltInFunctionType::Tan), + parse_builtin(BuiltInFunctionType::Ln), + parse_builtin(BuiltInFunctionType::Log), + parse_builtin(BuiltInFunctionType::Sin), + parse_builtin(BuiltInFunctionType::Cos), + )), // parse_builtin(BuiltInFunctionType::ReadLines), ))(s) } diff --git a/adana-script/src/tests/is_type.rs b/adana-script/src/tests/is_type.rs new file mode 100644 index 0000000..e9a2ea0 --- /dev/null +++ b/adana-script/src/tests/is_type.rs @@ -0,0 +1,78 @@ +use std::collections::BTreeMap; + +use adana_script_core::primitive::Primitive; + +use crate::compute; + +#[test] +fn test_is_u8() { + let mut ctx = BTreeMap::new(); + assert_eq!( + Primitive::Bool(true), + compute("is_u8(0x1)", &mut ctx, "N/A").unwrap() + ); +} +#[test] +fn test_is_i8() { + let mut ctx = BTreeMap::new(); + assert_eq!( + Primitive::Bool(true), + compute("is_i8(-1)", &mut ctx, "N/A").unwrap() + ); +} +#[test] +fn test_is_int() { + let mut ctx = BTreeMap::new(); + assert_eq!( + Primitive::Bool(true), + compute("is_int(512)", &mut ctx, "N/A").unwrap() + ); +} +#[test] +fn test_is_double() { + let mut ctx = BTreeMap::new(); + assert_eq!( + Primitive::Bool(true), + compute("is_double(512.)", &mut ctx, "N/A").unwrap() + ); +} +#[test] +fn test_is_function() { + let mut ctx = BTreeMap::new(); + assert_eq!( + Primitive::Bool(true), + compute("is_function(()=> {1})", &mut ctx, "N/A").unwrap() + ); +} +#[test] +fn test_is_struct() { + let mut ctx = BTreeMap::new(); + assert_eq!( + Primitive::Bool(true), + compute("is_struct(struct {})", &mut ctx, "N/A").unwrap() + ); +} +#[test] +fn test_is_bool() { + let mut ctx = BTreeMap::new(); + assert_eq!( + Primitive::Bool(true), + compute("is_bool(false)", &mut ctx, "N/A").unwrap() + ); +} +#[test] +fn test_is_array() { + let mut ctx = BTreeMap::new(); + assert_eq!( + Primitive::Bool(true), + compute("is_array([1,2,3])", &mut ctx, "N/A").unwrap() + ); +} +#[test] +fn test_is_error() { + let mut ctx = BTreeMap::new(); + assert_eq!( + Primitive::Bool(true), + compute("is_error(make_err(8))", &mut ctx, "N/A").unwrap() + ); +} diff --git a/adana-script/src/tests/mod.rs b/adana-script/src/tests/mod.rs index 096f168..d4e4b58 100644 --- a/adana-script/src/tests/mod.rs +++ b/adana-script/src/tests/mod.rs @@ -4,6 +4,7 @@ mod dynload; mod examples; mod foreach; mod funct; +mod is_type; mod misc; mod opassign; mod range; diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 6d833ff..83a52c3 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.75" +channel = "1.76"