From 4afde439742b79106c4c038600adc17278af5a89 Mon Sep 17 00:00:00 2001 From: Pauan Date: Tue, 11 Jun 2019 15:29:46 +0200 Subject: [PATCH] Breaking change: dominator now uses wasm-bindgen rather than stdweb --- .gitignore | 6 +- Cargo.lock | 407 ------------ Cargo.toml | 59 +- README.md | 2 +- Web.toml | 1 - examples/animation/.gitignore | 6 + examples/animation/Cargo.toml | 28 + examples/animation/README.md | 19 + examples/animation/js/index.js | 1 + examples/animation/package.json | 17 + .../src/main.rs => animation/src/lib.rs} | 61 +- examples/animation/static/index.html | 10 + examples/animation/webpack.config.js | 29 + examples/counter/.gitignore | 6 + examples/counter/Cargo.toml | 24 + examples/counter/README.md | 19 + examples/counter/js/index.js | 1 + examples/counter/package.json | 17 + .../src/main.rs => counter/src/lib.rs} | 27 +- examples/counter/static/index.html | 10 + examples/counter/webpack.config.js | 29 + examples/stdweb/animation/Cargo.lock | 547 ---------------- examples/stdweb/animation/Cargo.toml | 14 - examples/stdweb/animation/Web.toml | 1 - examples/stdweb/counter/Cargo.lock | 533 ---------------- examples/stdweb/counter/Cargo.toml | 14 - examples/stdweb/counter/Web.toml | 1 - examples/stdweb/todomvc/Cargo.lock | 420 ------------- examples/stdweb/todomvc/Cargo.toml | 19 - examples/stdweb/todomvc/Web.toml | 1 - examples/stdweb/todomvc/static/index.html | 14 - examples/todomvc/.gitignore | 6 + examples/todomvc/Cargo.toml | 35 ++ examples/todomvc/README.md | 19 + examples/todomvc/js/index.js | 1 + examples/todomvc/package.json | 17 + .../src/main.rs => todomvc/src/lib.rs} | 130 ++-- examples/todomvc/static/index.html | 14 + .../static/lib/todomvc-app-css/index.css | 0 .../static/lib/todomvc-common/base.css | 0 .../todomvc/static/lib/todomvc-common/base.js | 0 examples/todomvc/webpack.config.js | 29 + src/animation.rs | 174 ++--- src/callbacks.rs | 2 +- src/dom.rs | 594 ++++++------------ src/dom_operations.rs | 158 ++--- src/events.rs | 114 ++++ src/lib.rs | 33 +- src/macros.rs | 18 +- src/operations.rs | 76 +-- src/routing.rs | 86 ++- src/traits.rs | 11 +- src/utils.rs | 95 +++ 53 files changed, 1118 insertions(+), 2837 deletions(-) delete mode 100644 Cargo.lock delete mode 100644 Web.toml create mode 100644 examples/animation/.gitignore create mode 100644 examples/animation/Cargo.toml create mode 100644 examples/animation/README.md create mode 100644 examples/animation/js/index.js create mode 100644 examples/animation/package.json rename examples/{stdweb/animation/src/main.rs => animation/src/lib.rs} (79%) create mode 100644 examples/animation/static/index.html create mode 100644 examples/animation/webpack.config.js create mode 100644 examples/counter/.gitignore create mode 100644 examples/counter/Cargo.toml create mode 100644 examples/counter/README.md create mode 100644 examples/counter/js/index.js create mode 100644 examples/counter/package.json rename examples/{stdweb/counter/src/main.rs => counter/src/lib.rs} (79%) create mode 100644 examples/counter/static/index.html create mode 100644 examples/counter/webpack.config.js delete mode 100644 examples/stdweb/animation/Cargo.lock delete mode 100644 examples/stdweb/animation/Cargo.toml delete mode 100644 examples/stdweb/animation/Web.toml delete mode 100644 examples/stdweb/counter/Cargo.lock delete mode 100644 examples/stdweb/counter/Cargo.toml delete mode 100644 examples/stdweb/counter/Web.toml delete mode 100644 examples/stdweb/todomvc/Cargo.lock delete mode 100644 examples/stdweb/todomvc/Cargo.toml delete mode 100644 examples/stdweb/todomvc/Web.toml delete mode 100644 examples/stdweb/todomvc/static/index.html create mode 100644 examples/todomvc/.gitignore create mode 100644 examples/todomvc/Cargo.toml create mode 100644 examples/todomvc/README.md create mode 100644 examples/todomvc/js/index.js create mode 100644 examples/todomvc/package.json rename examples/{stdweb/todomvc/src/main.rs => todomvc/src/lib.rs} (87%) create mode 100644 examples/todomvc/static/index.html rename examples/{stdweb => }/todomvc/static/lib/todomvc-app-css/index.css (100%) rename examples/{stdweb => }/todomvc/static/lib/todomvc-common/base.css (100%) rename examples/{stdweb => }/todomvc/static/lib/todomvc-common/base.js (100%) create mode 100644 examples/todomvc/webpack.config.js create mode 100644 src/events.rs create mode 100644 src/utils.rs diff --git a/.gitignore b/.gitignore index 65a5a1c..565017d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ - -target/ -**/*.rs.bk +/target +Cargo.lock +yarn.lock diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index 0eedf5f..0000000 --- a/Cargo.lock +++ /dev/null @@ -1,407 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "base-x" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "bumpalo" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "cfg-if" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "discard" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "dominator" -version = "0.4.3" -dependencies = [ - "discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-channel-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-signals 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb 0.4.16 (git+https://github.com/koute/stdweb)", - "stdweb-derive 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-channel-preview" -version = "0.3.0-alpha.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-core-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-core-preview" -version = "0.3.0-alpha.15" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "futures-executor-preview" -version = "0.3.0-alpha.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-channel-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-io-preview" -version = "0.3.0-alpha.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-core-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-signals" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-channel-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-sink-preview" -version = "0.3.0-alpha.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-channel-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-util-preview" -version = "0.3.0-alpha.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-channel-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-io-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "iovec" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "itoa" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "lazy_static" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "libc" -version = "0.2.53" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "log" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "memchr" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "num_cpus" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "pin-utils" -version = "0.1.0-alpha.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "proc-macro2" -version = "0.4.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "quote" -version = "0.6.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "ryu" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "serde" -version = "1.0.90" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "serde_derive" -version = "1.0.90" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serde_json" -version = "1.0.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "sha1" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "slab" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "stdweb" -version = "0.4.16" -source = "git+https://github.com/koute/stdweb#4d337ee9a0a4542ea5803b46b5124d9bc166dcb7" -dependencies = [ - "discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-channel-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-executor-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb-derive 0.5.1 (git+https://github.com/koute/stdweb)", - "stdweb-internal-macros 0.2.7 (git+https://github.com/koute/stdweb)", - "stdweb-internal-runtime 0.1.4 (git+https://github.com/koute/stdweb)", - "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-derive" -version = "0.5.1" -source = "git+https://github.com/koute/stdweb#4d337ee9a0a4542ea5803b46b5124d9bc166dcb7" -dependencies = [ - "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-derive" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-internal-macros" -version = "0.2.7" -source = "git+https://github.com/koute/stdweb#4d337ee9a0a4542ea5803b46b5124d9bc166dcb7" -dependencies = [ - "base-x 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", - "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-internal-runtime" -version = "0.1.4" -source = "git+https://github.com/koute/stdweb#4d337ee9a0a4542ea5803b46b5124d9bc166dcb7" - -[[package]] -name = "syn" -version = "0.15.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "wasm-bindgen" -version = "0.2.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "wasm-bindgen-macro 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bumpalo 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro-support 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.42" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[metadata] -"checksum base-x 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d55aa264e822dbafa12db4d54767aff17c6ba55ea2d8559b3e17392c7d000e5d" -"checksum bumpalo 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4639720be048090544634e0402490838995ccdc9d2fe648f528f30d3c33ae71f" -"checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4" -"checksum discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" -"checksum futures-channel-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)" = "edf150887ba490560f3d732e479a383ca4b8696af98651806d3f4edc1d968585" -"checksum futures-core-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)" = "10a3833d58fd08b3a40203613ed3a93c8bc0bc0181af5dd6422a0e08df1bfa68" -"checksum futures-executor-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)" = "0a75c64f20734619b4668e87f902544ce8c108dfcb6c9b6b2fcefdd1a848c15a" -"checksum futures-io-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)" = "b24891994ce1445f7e0cd494e4f57fd79f5bd9d37e9cc90a31d109e9a06d9073" -"checksum futures-signals 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d252ec61653bc4c26c21ef9e60ebe3137b58548adb35829084f5c15c633f472" -"checksum futures-sink-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)" = "f64fa75a0ce02dee949c8c9447abfc117df214054d6e96755d329c9053baf2fd" -"checksum futures-util-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)" = "ca958da50f4073c475d9f7ec6ce405451e06707bfd69686e83abd76cb4e1e7fb" -"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" -"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" -"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" -"checksum libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)" = "ec350a9417dfd244dc9a6c4a71e13895a4db6b92f0b106f07ebbc3f3bc580cee" -"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" -"checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" -"checksum num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a23f0ed30a54abaa0c7e83b1d2d87ada7c3c23078d1d87815af3e3b6385fbba" -"checksum pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" -"checksum proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)" = "64c827cea7a7ab30ce4593e5e04d7a11617ad6ece2fa230605a78b00ff965316" -"checksum quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "faf4799c5d274f3868a4aae320a0a182cbd2baee377b378f080e16a23e9d80db" -"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" -"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)" = "aa5f7c20820475babd2c077c3ab5f8c77a31c15e16ea38687b4c02d3e48680f4" -"checksum serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)" = "58fc82bec244f168b23d1963b45c8bf5726e9a15a9d146a067f9081aeed2de79" -"checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d" -"checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" -"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" -"checksum stdweb 0.4.16 (git+https://github.com/koute/stdweb)" = "" -"checksum stdweb-derive 0.5.1 (git+https://github.com/koute/stdweb)" = "" -"checksum stdweb-derive 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0e21ebd9179de08f2300a65454268a17ea3de204627458588c84319c4def3930" -"checksum stdweb-internal-macros 0.2.7 (git+https://github.com/koute/stdweb)" = "" -"checksum stdweb-internal-runtime 0.1.4 (git+https://github.com/koute/stdweb)" = "" -"checksum syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)" = "ec52cd796e5f01d0067225a5392e70084acc4c0013fa71d55166d38a8b307836" -"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" -"checksum wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "ffde3534e5fa6fd936e3260cd62cd644b8656320e369388f9303c955895e35d4" -"checksum wasm-bindgen-backend 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "40c0543374a7ae881cdc5d32d19de28d1d1929e92263ffa7e31712cc2d53f9f1" -"checksum wasm-bindgen-macro 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "f914c94c2c5f4c9364510ca2429e59c92157ec89429243bcc245e983db990a71" -"checksum wasm-bindgen-macro-support 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "9168c413491e4233db7b6884f09a43beb00c14d11d947ffd165242daa48a2385" -"checksum wasm-bindgen-shared 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "326c32126e1a157b6ced7400061a84ac5b11182b2cda6edad7314eb3ae9ac9fe" -"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" diff --git a/Cargo.toml b/Cargo.toml index 4b00934..7a1ebf6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dominator" -version = "0.4.4" +version = "0.5.0" authors = ["Pauan "] description = "Zero cost declarative DOM library using FRP signals" repository = "https://github.com/Pauan/rust-dominator" @@ -9,19 +9,58 @@ readme = "README.md" license = "MIT" keywords = ["javascript", "dom", "reactive", "signal", "frp"] categories = ["web-programming", "template-engine", "wasm"] +edition = "2018" [dependencies] -stdweb-derive = "0.5.0" -lazy_static = "1.0.0" +lazy_static = "1.3.0" discard = "1.0.3" -pin-utils = "0.1.0-alpha.3" -futures-channel-preview = "0.3.0-alpha.15" -futures-util-preview = "0.3.0-alpha.15" -futures-signals = "0.3.0" +pin-utils = "0.1.0-alpha.4" +futures-channel-preview = "0.3.0-alpha.16" +futures-util-preview = "0.3.0-alpha.16" +futures-signals = "0.3.5" +wasm-bindgen = "0.2.45" +js-sys = "0.3.22" +# TODO fix this before release +gloo = { git = "https://github.com/rustwasm/gloo" } -[dependencies.stdweb] -version = "0.4.10" -features = ["experimental_features_which_may_break_on_minor_version_bumps"] +[dependencies.wasm-bindgen-futures] +version = "0.3.22" +features = ["futures_0_3"] + +[dependencies.web-sys] +version = "0.3.22" +features = [ + "CharacterData", + "Comment", + "CssRule", + "CssRuleList", + "CssStyleDeclaration", + "CssStyleRule", + "CssStyleSheet", + "Document", + "DomTokenList", + "Element", + "Event", + "EventTarget", + "FocusEvent", + "History", + "InputEvent", + "HtmlElement", + "HtmlHeadElement", + "HtmlInputElement", + "HtmlStyleElement", + "HtmlTextAreaElement", + "KeyboardEvent", + "Location", + "MouseEvent", + "Node", + "NodeList", + "StyleSheet", + "SvgElement", + "Text", + "Url", + "Window", +] [profile.release] debug-assertions = true diff --git a/README.md b/README.md index a0d966e..c84cf0c 100644 --- a/README.md +++ b/README.md @@ -12,4 +12,4 @@ You must use the Nightly Rust compiler (because it is needed for futures 0.3) Running the examples ==================== -Just do `cargo web start --release` and then open `http://[::1]:8000` in a web browser. +Just do `yarn` and then `yarn start` (it will take a while to compile the dependencies, please be patient) diff --git a/Web.toml b/Web.toml deleted file mode 100644 index 813e273..0000000 --- a/Web.toml +++ /dev/null @@ -1 +0,0 @@ -default-target = "wasm32-unknown-unknown" diff --git a/examples/animation/.gitignore b/examples/animation/.gitignore new file mode 100644 index 0000000..36867e8 --- /dev/null +++ b/examples/animation/.gitignore @@ -0,0 +1,6 @@ +node_modules +/dist +/target +/pkg +/wasm-pack.log +/yarn-error.log diff --git a/examples/animation/Cargo.toml b/examples/animation/Cargo.toml new file mode 100644 index 0000000..2842990 --- /dev/null +++ b/examples/animation/Cargo.toml @@ -0,0 +1,28 @@ +[package] +name = "animation" +version = "0.1.0" +description = "Animation demo using dominator" +authors = ["Pauan "] +categories = ["wasm"] +readme = "README.md" +license = "MIT" +edition = "2018" + +[profile.release] +lto = true + +[lib] +crate-type = ["cdylib"] + +[dependencies] +dominator = { path = "../.." } +wasm-bindgen = "0.2.45" +futures-signals = "0.3.0" +futures-preview = "0.3.0-alpha.16" + +[dependencies.web-sys] +version = "0.3.22" +features = [] + +[target."cfg(debug_assertions)".dependencies] +console_error_panic_hook = "0.1.5" diff --git a/examples/animation/README.md b/examples/animation/README.md new file mode 100644 index 0000000..46fe09f --- /dev/null +++ b/examples/animation/README.md @@ -0,0 +1,19 @@ +## How to install + +```sh +yarn install +``` + +## How to run in debug mode + +```sh +# Builds the project and opens it in a new browser tab. Auto-reloads when the project changes. +yarn start +``` + +## How to build in release mode + +```sh +# Builds the project and places it into the `dist` folder. +yarn run build +``` diff --git a/examples/animation/js/index.js b/examples/animation/js/index.js new file mode 100644 index 0000000..9db81ab --- /dev/null +++ b/examples/animation/js/index.js @@ -0,0 +1 @@ +import("../pkg/index.js").catch(console.error); diff --git a/examples/animation/package.json b/examples/animation/package.json new file mode 100644 index 0000000..3c73d0b --- /dev/null +++ b/examples/animation/package.json @@ -0,0 +1,17 @@ +{ + "author": "Pauan ", + "name": "animation", + "version": "0.1.0", + "scripts": { + "build": "rimraf dist pkg && webpack", + "start": "rimraf dist pkg && webpack-dev-server --open -d" + }, + "devDependencies": { + "@wasm-tool/wasm-pack-plugin": "^0.4.2", + "copy-webpack-plugin": "^5.0.3", + "webpack": "^4.33.0", + "webpack-cli": "^3.3.3", + "webpack-dev-server": "^3.7.1", + "rimraf": "^2.6.3" + } +} diff --git a/examples/stdweb/animation/src/main.rs b/examples/animation/src/lib.rs similarity index 79% rename from examples/stdweb/animation/src/main.rs rename to examples/animation/src/lib.rs index 32203e6..668b210 100644 --- a/examples/stdweb/animation/src/main.rs +++ b/examples/animation/src/lib.rs @@ -1,19 +1,12 @@ -#[macro_use] -extern crate stdweb; -#[macro_use] -extern crate dominator; -#[macro_use] -extern crate futures_signals; - +use wasm_bindgen::prelude::*; use std::rc::Rc; use futures::future::ready; +use futures_signals::map_ref; use futures_signals::signal::SignalExt; use futures_signals::signal_vec::MutableVec; use dominator::traits::*; -use dominator::Dom; -use dominator::events::{MouseOverEvent, MouseOutEvent}; -use dominator::animation::{Percentage, easing}; -use dominator::animation::{MutableAnimation, AnimatedMapBroadcaster}; +use dominator::{Dom, html, clone, events}; +use dominator::animation::{easing, Percentage, MutableAnimation, AnimatedMapBroadcaster}; fn make_animated_box(value: u32, broadcaster: AnimatedMapBroadcaster) -> Dom { @@ -38,11 +31,11 @@ fn make_animated_box(value: u32, broadcaster: AnimatedMapBroadcaster) -> Dom { ready(()) }))) - .event(clone!(hover_animation => move |_: MouseOverEvent| { + .event(clone!(hover_animation => move |_: events::MouseEnter| { hover_animation.animate_to(Percentage::new(1.0)); })) - .event(clone!(hover_animation => move |_: MouseOutEvent| { + .event(clone!(hover_animation => move |_: events::MouseLeave| { hover_animation.animate_to(Percentage::new(0.0)); })) @@ -98,20 +91,38 @@ struct State { impl Drop for State { fn drop(&mut self) { - js! { - console.log("Dropping"); - } + web_sys::console::log_1(&JsValue::from("Dropping")); } } -fn main() { + +// TODO move this into gloo +fn set_interval(ms: i32, f: F) where F: FnMut() + 'static { + let f = wasm_bindgen::closure::Closure::wrap(Box::new(f) as Box); + + web_sys::window() + .unwrap_throw() + .set_interval_with_callback_and_timeout_and_arguments_0(wasm_bindgen::JsCast::unchecked_ref(f.as_ref()), ms) + .unwrap_throw(); + + // TODO cleanup + f.forget() +} + + +#[wasm_bindgen(start)] +pub fn main_js() -> Result<(), JsValue> { + #[cfg(debug_assertions)] + console_error_panic_hook::set_once(); + + let state = Rc::new(State { boxes: MutableVec::new_with_values(vec![0]), }); let mut color = 10; - let f = clone!(state => move || { + let _timer_id = set_interval(500, clone!(state => move || { let mut lock = state.boxes.lock_mut(); if lock.len() >= 40 { @@ -120,15 +131,9 @@ fn main() { lock.push(color % 360); color += 10; - }); + })); - let _timer_id = js!( - return setInterval(function () { - @{f}(); - }, 500); - ); - - /*dominator::append_dom(&body, + /*dominator::append_dom(body, html!("button", { .event(clone!(state => move |_: ClickEvent| { js! { @(no_return) @@ -143,7 +148,7 @@ fn main() { );*/ for _ in 0..1 { - dominator::append_dom(&dominator::body(), + dominator::append_dom(dominator::body(), html!("div", { .style("display", "flex") @@ -165,4 +170,6 @@ fn main() { }) ); } + + Ok(()) } diff --git a/examples/animation/static/index.html b/examples/animation/static/index.html new file mode 100644 index 0000000..a84aaf3 --- /dev/null +++ b/examples/animation/static/index.html @@ -0,0 +1,10 @@ + + + + + rust-dominator • Animation + + + + + diff --git a/examples/animation/webpack.config.js b/examples/animation/webpack.config.js new file mode 100644 index 0000000..57f5c32 --- /dev/null +++ b/examples/animation/webpack.config.js @@ -0,0 +1,29 @@ +const path = require("path"); +const CopyPlugin = require("copy-webpack-plugin"); +const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin"); + +const dist = path.resolve(__dirname, "dist"); + +module.exports = { + mode: "production", + entry: { + index: "./js/index.js" + }, + output: { + path: dist, + filename: "[name].js" + }, + devServer: { + contentBase: dist, + }, + plugins: [ + new CopyPlugin([ + path.resolve(__dirname, "static") + ]), + + new WasmPackPlugin({ + crateDirectory: __dirname, + extraArgs: "--out-name index" + }), + ] +}; diff --git a/examples/counter/.gitignore b/examples/counter/.gitignore new file mode 100644 index 0000000..36867e8 --- /dev/null +++ b/examples/counter/.gitignore @@ -0,0 +1,6 @@ +node_modules +/dist +/target +/pkg +/wasm-pack.log +/yarn-error.log diff --git a/examples/counter/Cargo.toml b/examples/counter/Cargo.toml new file mode 100644 index 0000000..43b1aa0 --- /dev/null +++ b/examples/counter/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "counter" +version = "0.1.0" +description = "Counter demo using dominator" +authors = ["Pauan "] +categories = ["wasm"] +readme = "README.md" +license = "MIT" +edition = "2018" + +[profile.release] +lto = true + +[lib] +crate-type = ["cdylib"] + +[dependencies] +dominator = { path = "../.." } +wasm-bindgen = "0.2.45" +futures-signals = "0.3.0" +lazy_static = "1.0.0" + +[target."cfg(debug_assertions)".dependencies] +console_error_panic_hook = "0.1.5" diff --git a/examples/counter/README.md b/examples/counter/README.md new file mode 100644 index 0000000..46fe09f --- /dev/null +++ b/examples/counter/README.md @@ -0,0 +1,19 @@ +## How to install + +```sh +yarn install +``` + +## How to run in debug mode + +```sh +# Builds the project and opens it in a new browser tab. Auto-reloads when the project changes. +yarn start +``` + +## How to build in release mode + +```sh +# Builds the project and places it into the `dist` folder. +yarn run build +``` diff --git a/examples/counter/js/index.js b/examples/counter/js/index.js new file mode 100644 index 0000000..9db81ab --- /dev/null +++ b/examples/counter/js/index.js @@ -0,0 +1 @@ +import("../pkg/index.js").catch(console.error); diff --git a/examples/counter/package.json b/examples/counter/package.json new file mode 100644 index 0000000..fde81d3 --- /dev/null +++ b/examples/counter/package.json @@ -0,0 +1,17 @@ +{ + "author": "Pauan ", + "name": "counter", + "version": "0.1.0", + "scripts": { + "build": "rimraf dist pkg && webpack", + "start": "rimraf dist pkg && webpack-dev-server --open -d" + }, + "devDependencies": { + "@wasm-tool/wasm-pack-plugin": "^0.4.2", + "copy-webpack-plugin": "^5.0.3", + "webpack": "^4.33.0", + "webpack-cli": "^3.3.3", + "webpack-dev-server": "^3.7.1", + "rimraf": "^2.6.3" + } +} diff --git a/examples/stdweb/counter/src/main.rs b/examples/counter/src/lib.rs similarity index 79% rename from examples/stdweb/counter/src/main.rs rename to examples/counter/src/lib.rs index c34fe4f..ea4719b 100644 --- a/examples/stdweb/counter/src/main.rs +++ b/examples/counter/src/lib.rs @@ -1,12 +1,8 @@ -#[macro_use] -extern crate dominator; -#[macro_use] -extern crate lazy_static; - +use wasm_bindgen::prelude::*; use std::sync::Arc; +use lazy_static::lazy_static; use futures_signals::signal::{Mutable, SignalExt}; -use dominator::Dom; -use dominator::events::ClickEvent; +use dominator::{Dom, class, html, clone, events}; struct State { @@ -54,7 +50,7 @@ impl State { html!("button", { .class(&*BUTTON_CLASS) .text("Increase") - .event(clone!(state => move |_: ClickEvent| { + .event(clone!(state => move |_: events::Click| { // Increment the counter state.counter.replace_with(|x| *x + 1); })) @@ -63,7 +59,7 @@ impl State { html!("button", { .class(&*BUTTON_CLASS) .text("Decrease") - .event(clone!(state => move |_: ClickEvent| { + .event(clone!(state => move |_: events::Click| { // Decrement the counter state.counter.replace_with(|x| *x - 1); })) @@ -72,7 +68,7 @@ impl State { html!("button", { .class(&*BUTTON_CLASS) .text("Reset") - .event(clone!(state => move |_: ClickEvent| { + .event(clone!(state => move |_: events::Click| { // Reset the counter to 0 state.counter.set_neq(0); })) @@ -83,8 +79,15 @@ impl State { } -fn main() { +#[wasm_bindgen(start)] +pub fn main_js() -> Result<(), JsValue> { + #[cfg(debug_assertions)] + console_error_panic_hook::set_once(); + + let state = State::new(); - dominator::append_dom(&dominator::body(), State::render(state)); + dominator::append_dom(dominator::body(), State::render(state)); + + Ok(()) } diff --git a/examples/counter/static/index.html b/examples/counter/static/index.html new file mode 100644 index 0000000..b4968da --- /dev/null +++ b/examples/counter/static/index.html @@ -0,0 +1,10 @@ + + + + + rust-dominator • Counter + + + + + diff --git a/examples/counter/webpack.config.js b/examples/counter/webpack.config.js new file mode 100644 index 0000000..57f5c32 --- /dev/null +++ b/examples/counter/webpack.config.js @@ -0,0 +1,29 @@ +const path = require("path"); +const CopyPlugin = require("copy-webpack-plugin"); +const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin"); + +const dist = path.resolve(__dirname, "dist"); + +module.exports = { + mode: "production", + entry: { + index: "./js/index.js" + }, + output: { + path: dist, + filename: "[name].js" + }, + devServer: { + contentBase: dist, + }, + plugins: [ + new CopyPlugin([ + path.resolve(__dirname, "static") + ]), + + new WasmPackPlugin({ + crateDirectory: __dirname, + extraArgs: "--out-name index" + }), + ] +}; diff --git a/examples/stdweb/animation/Cargo.lock b/examples/stdweb/animation/Cargo.lock deleted file mode 100644 index b2da5c8..0000000 --- a/examples/stdweb/animation/Cargo.lock +++ /dev/null @@ -1,547 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "animation" -version = "0.1.0" -dependencies = [ - "dominator 0.4.2", - "futures-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-signals 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "autocfg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "base-x" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "bitflags" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "discard" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "dominator" -version = "0.4.2" -dependencies = [ - "discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-channel-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-signals 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb-derive 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "either" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "futures-channel-preview" -version = "0.3.0-alpha.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-core-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-core-preview" -version = "0.3.0-alpha.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "either 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-executor-preview" -version = "0.3.0-alpha.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-channel-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-io-preview" -version = "0.3.0-alpha.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-core-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-preview" -version = "0.3.0-alpha.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-channel-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-executor-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-io-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-select-macro-preview" -version = "0.3.0-alpha.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro-hack 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-signals" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-channel-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-sink-preview" -version = "0.3.0-alpha.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "either 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-channel-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-util-preview" -version = "0.3.0-alpha.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "either 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-channel-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-io-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-select-macro-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro-hack 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro-nested 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "iovec" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "itoa" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "lazy_static" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "libc" -version = "0.2.50" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "num_cpus" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "pin-utils" -version = "0.1.0-alpha.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "proc-macro-hack" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "proc-macro-nested" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "proc-macro2" -version = "0.4.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "quote" -version = "0.6.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_jitter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_chacha" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_core" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_jitter" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "ryu" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "serde" -version = "1.0.89" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "serde_derive" -version = "1.0.89" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serde_json" -version = "1.0.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "sha1" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "slab" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "stdweb" -version = "0.4.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-channel-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-executor-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb-derive 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb-internal-macros 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb-internal-runtime 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-derive" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-internal-macros" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "base-x 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", - "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-internal-runtime" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "syn" -version = "0.15.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[metadata] -"checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" -"checksum base-x 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d55aa264e822dbafa12db4d54767aff17c6ba55ea2d8559b3e17392c7d000e5d" -"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" -"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -"checksum discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" -"checksum either 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c67353c641dc847124ea1902d69bd753dee9bb3beff9aa3662ecf86c971d1fac" -"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" -"checksum futures-channel-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)" = "d55b12e2746710757f794670bc4e0461097e8873a6d21a48b3f4bf2f5b44053b" -"checksum futures-core-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)" = "0788448b9b2fc2ca1956f735ac7073745486d6729b44dd083e274f710d1268b0" -"checksum futures-executor-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)" = "cc7d1e0b45afb1c29fa15e90f55608387e7a9f3a9fa49de290262a9dc81a0501" -"checksum futures-io-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)" = "4d9afda895bfc92d256fd66d3c438c8e2a46753b8474658d204df3c2434035a6" -"checksum futures-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)" = "7faf4ac82e295643b1562a524004ef41b62e8f2de42d5506f037eaad68abe111" -"checksum futures-select-macro-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)" = "3bd59b75bb2c86cda47c00d71bf520683a6831751648458540db330e25627c91" -"checksum futures-signals 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e171352dac3c0d87683a051007b673246940999c83ca750966fc42524c7f71ec" -"checksum futures-sink-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)" = "8a9be0748d742f1f5f61a9b65e2de0e815de9c05343cea1ceae74062df3f55fe" -"checksum futures-util-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)" = "88b0edcc082d39a3379a96eb670c9b6b28689cd753cc351fb2c0a4739e4a1f97" -"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" -"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" -"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" -"checksum libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "aab692d7759f5cd8c859e169db98ae5b52c924add2af5fbbca11d12fefb567c1" -"checksum num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a23f0ed30a54abaa0c7e83b1d2d87ada7c3c23078d1d87815af3e3b6385fbba" -"checksum pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" -"checksum proc-macro-hack 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3e90aa19cd73dedc2d0e1e8407473f073d735fef0ab521438de6da8ee449ab66" -"checksum proc-macro-nested 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "369a6ed065f249a159e06c45752c780bda2fb53c995718f9e484d08daa9eb42e" -"checksum proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)" = "4d317f9caece796be1980837fd5cb3dfec5613ebdb04ad0956deea83ce168915" -"checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1" -"checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -"checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -"checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" -"checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -"checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -"checksum rand_jitter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b9ea758282efe12823e0d952ddb269d2e1897227e464919a554f2a03ef1b832" -"checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -"checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -"checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" -"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)" = "92514fb95f900c9b5126e32d020f5c6d40564c27a5ea6d1d7d9f157a96623560" -"checksum serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)" = "bb6eabf4b5914e88e24eea240bb7c9f9a2cbc1bbbe8d961d381975ec3c6b806c" -"checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d" -"checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" -"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" -"checksum stdweb 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a3edad410e603184d656e2abded5fd4d3d6e93d5763d21130dbaf99795db74eb" -"checksum stdweb-derive 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0e21ebd9179de08f2300a65454268a17ea3de204627458588c84319c4def3930" -"checksum stdweb-internal-macros 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1635afd059cbfac7d5b1274f0c44cec110c1e013c48e8bbc22e07e52696cf887" -"checksum stdweb-internal-runtime 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a2a2f4a2eb556337b2d1a302630bbddf989ae383c70393e89b48152b9896cbda" -"checksum syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)" = "1825685f977249735d510a242a6727b46efe914bb67e38d30c071b1b72b1d5c2" -"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" -"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" -"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" -"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/examples/stdweb/animation/Cargo.toml b/examples/stdweb/animation/Cargo.toml deleted file mode 100644 index a3f644b..0000000 --- a/examples/stdweb/animation/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "animation" -version = "0.1.0" -authors = ["Pauan "] -edition = "2018" - -[dependencies] -dominator = { path = "../../.." } -futures-signals = "0.3.0" -futures-preview = "0.3.0-alpha.9" - -[dependencies.stdweb] -version = "0.4.10" -features = ["experimental_features_which_may_break_on_minor_version_bumps"] diff --git a/examples/stdweb/animation/Web.toml b/examples/stdweb/animation/Web.toml deleted file mode 100644 index 813e273..0000000 --- a/examples/stdweb/animation/Web.toml +++ /dev/null @@ -1 +0,0 @@ -default-target = "wasm32-unknown-unknown" diff --git a/examples/stdweb/counter/Cargo.lock b/examples/stdweb/counter/Cargo.lock deleted file mode 100644 index 6c9d973..0000000 --- a/examples/stdweb/counter/Cargo.lock +++ /dev/null @@ -1,533 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "autocfg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "base-x" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "bitflags" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "counter" -version = "0.1.0" -dependencies = [ - "dominator 0.4.2", - "futures-signals 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "discard" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "dominator" -version = "0.4.2" -dependencies = [ - "discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-channel-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-signals 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb-derive 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "either" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "futures-channel-preview" -version = "0.3.0-alpha.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-core-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-core-preview" -version = "0.3.0-alpha.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "either 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-executor-preview" -version = "0.3.0-alpha.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-channel-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-io-preview" -version = "0.3.0-alpha.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-core-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-select-macro-preview" -version = "0.3.0-alpha.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro-hack 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-signals" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-channel-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-sink-preview" -version = "0.3.0-alpha.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "either 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-channel-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-util-preview" -version = "0.3.0-alpha.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "either 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-channel-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-io-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-select-macro-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro-hack 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro-nested 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "iovec" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "itoa" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "lazy_static" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "libc" -version = "0.2.50" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "num_cpus" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "pin-utils" -version = "0.1.0-alpha.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "proc-macro-hack" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "proc-macro-nested" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "proc-macro2" -version = "0.4.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "quote" -version = "0.6.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_jitter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_chacha" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_core" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_jitter" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "ryu" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "serde" -version = "1.0.89" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "serde_derive" -version = "1.0.89" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serde_json" -version = "1.0.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "sha1" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "slab" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "stdweb" -version = "0.4.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-channel-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-executor-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb-derive 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb-internal-macros 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb-internal-runtime 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-derive" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-internal-macros" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "base-x 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", - "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-internal-runtime" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "syn" -version = "0.15.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[metadata] -"checksum autocfg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a6d640bee2da49f60a4068a7fae53acde8982514ab7bae8b8cea9e88cbcfd799" -"checksum base-x 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d55aa264e822dbafa12db4d54767aff17c6ba55ea2d8559b3e17392c7d000e5d" -"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" -"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -"checksum discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" -"checksum either 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c67353c641dc847124ea1902d69bd753dee9bb3beff9aa3662ecf86c971d1fac" -"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" -"checksum futures-channel-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)" = "d55b12e2746710757f794670bc4e0461097e8873a6d21a48b3f4bf2f5b44053b" -"checksum futures-core-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)" = "0788448b9b2fc2ca1956f735ac7073745486d6729b44dd083e274f710d1268b0" -"checksum futures-executor-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)" = "cc7d1e0b45afb1c29fa15e90f55608387e7a9f3a9fa49de290262a9dc81a0501" -"checksum futures-io-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)" = "4d9afda895bfc92d256fd66d3c438c8e2a46753b8474658d204df3c2434035a6" -"checksum futures-select-macro-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)" = "3bd59b75bb2c86cda47c00d71bf520683a6831751648458540db330e25627c91" -"checksum futures-signals 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e171352dac3c0d87683a051007b673246940999c83ca750966fc42524c7f71ec" -"checksum futures-sink-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)" = "8a9be0748d742f1f5f61a9b65e2de0e815de9c05343cea1ceae74062df3f55fe" -"checksum futures-util-preview 0.3.0-alpha.13 (registry+https://github.com/rust-lang/crates.io-index)" = "88b0edcc082d39a3379a96eb670c9b6b28689cd753cc351fb2c0a4739e4a1f97" -"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" -"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" -"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" -"checksum libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "aab692d7759f5cd8c859e169db98ae5b52c924add2af5fbbca11d12fefb567c1" -"checksum num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a23f0ed30a54abaa0c7e83b1d2d87ada7c3c23078d1d87815af3e3b6385fbba" -"checksum pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" -"checksum proc-macro-hack 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3e90aa19cd73dedc2d0e1e8407473f073d735fef0ab521438de6da8ee449ab66" -"checksum proc-macro-nested 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "369a6ed065f249a159e06c45752c780bda2fb53c995718f9e484d08daa9eb42e" -"checksum proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)" = "4d317f9caece796be1980837fd5cb3dfec5613ebdb04ad0956deea83ce168915" -"checksum quote 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "cdd8e04bd9c52e0342b406469d494fcb033be4bdbe5c606016defbb1681411e1" -"checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -"checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -"checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" -"checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -"checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -"checksum rand_jitter 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b9ea758282efe12823e0d952ddb269d2e1897227e464919a554f2a03ef1b832" -"checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -"checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -"checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" -"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)" = "92514fb95f900c9b5126e32d020f5c6d40564c27a5ea6d1d7d9f157a96623560" -"checksum serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)" = "bb6eabf4b5914e88e24eea240bb7c9f9a2cbc1bbbe8d961d381975ec3c6b806c" -"checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d" -"checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" -"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" -"checksum stdweb 0.4.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a3edad410e603184d656e2abded5fd4d3d6e93d5763d21130dbaf99795db74eb" -"checksum stdweb-derive 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0e21ebd9179de08f2300a65454268a17ea3de204627458588c84319c4def3930" -"checksum stdweb-internal-macros 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1635afd059cbfac7d5b1274f0c44cec110c1e013c48e8bbc22e07e52696cf887" -"checksum stdweb-internal-runtime 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a2a2f4a2eb556337b2d1a302630bbddf989ae383c70393e89b48152b9896cbda" -"checksum syn 0.15.29 (registry+https://github.com/rust-lang/crates.io-index)" = "1825685f977249735d510a242a6727b46efe914bb67e38d30c071b1b72b1d5c2" -"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" -"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" -"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" -"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/examples/stdweb/counter/Cargo.toml b/examples/stdweb/counter/Cargo.toml deleted file mode 100644 index d81ea61..0000000 --- a/examples/stdweb/counter/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -[package] -name = "counter" -version = "0.1.0" -authors = ["Pauan "] -edition = "2018" - -[dependencies] -dominator = { path = "../../.." } -futures-signals = "0.3.0" -lazy_static = "1.0.0" - -[dependencies.stdweb] -version = "0.4.10" -features = ["experimental_features_which_may_break_on_minor_version_bumps"] diff --git a/examples/stdweb/counter/Web.toml b/examples/stdweb/counter/Web.toml deleted file mode 100644 index 813e273..0000000 --- a/examples/stdweb/counter/Web.toml +++ /dev/null @@ -1 +0,0 @@ -default-target = "wasm32-unknown-unknown" diff --git a/examples/stdweb/todomvc/Cargo.lock b/examples/stdweb/todomvc/Cargo.lock deleted file mode 100644 index 49f3af5..0000000 --- a/examples/stdweb/todomvc/Cargo.lock +++ /dev/null @@ -1,420 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "base-x" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "bumpalo" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "cfg-if" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "discard" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "dominator" -version = "0.4.3" -dependencies = [ - "discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-channel-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-signals 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb 0.4.16 (git+https://github.com/koute/stdweb)", - "stdweb-derive 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-channel-preview" -version = "0.3.0-alpha.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-core-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-core-preview" -version = "0.3.0-alpha.15" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "futures-executor-preview" -version = "0.3.0-alpha.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-channel-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-io-preview" -version = "0.3.0-alpha.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-core-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-signals" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-channel-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-sink-preview" -version = "0.3.0-alpha.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-channel-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "futures-util-preview" -version = "0.3.0-alpha.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "futures-channel-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-io-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-sink-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "iovec" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "itoa" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "lazy_static" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "libc" -version = "0.2.53" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "log" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "memchr" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "num_cpus" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "pin-utils" -version = "0.1.0-alpha.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "proc-macro2" -version = "0.4.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "quote" -version = "0.6.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "ryu" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "serde" -version = "1.0.90" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "serde_derive" -version = "1.0.90" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serde_json" -version = "1.0.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "sha1" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "slab" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "stdweb" -version = "0.4.16" -source = "git+https://github.com/koute/stdweb#4d337ee9a0a4542ea5803b46b5124d9bc166dcb7" -dependencies = [ - "discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-channel-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-core-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-executor-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "futures-util-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb-derive 0.5.1 (git+https://github.com/koute/stdweb)", - "stdweb-internal-macros 0.2.7 (git+https://github.com/koute/stdweb)", - "stdweb-internal-runtime 0.1.4 (git+https://github.com/koute/stdweb)", - "wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-derive" -version = "0.5.1" -source = "git+https://github.com/koute/stdweb#4d337ee9a0a4542ea5803b46b5124d9bc166dcb7" -dependencies = [ - "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-derive" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-internal-macros" -version = "0.2.7" -source = "git+https://github.com/koute/stdweb#4d337ee9a0a4542ea5803b46b5124d9bc166dcb7" -dependencies = [ - "base-x 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", - "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-internal-runtime" -version = "0.1.4" -source = "git+https://github.com/koute/stdweb#4d337ee9a0a4542ea5803b46b5124d9bc166dcb7" - -[[package]] -name = "syn" -version = "0.15.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "todomvc" -version = "0.1.0" -dependencies = [ - "dominator 0.4.3", - "futures-signals 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb 0.4.16 (git+https://github.com/koute/stdweb)", -] - -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "wasm-bindgen" -version = "0.2.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "wasm-bindgen-macro 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bumpalo 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro-support 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.42" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[metadata] -"checksum base-x 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d55aa264e822dbafa12db4d54767aff17c6ba55ea2d8559b3e17392c7d000e5d" -"checksum bumpalo 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4639720be048090544634e0402490838995ccdc9d2fe648f528f30d3c33ae71f" -"checksum cfg-if 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "11d43355396e872eefb45ce6342e4374ed7bc2b3a502d1b28e36d6e23c05d1f4" -"checksum discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" -"checksum futures-channel-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)" = "edf150887ba490560f3d732e479a383ca4b8696af98651806d3f4edc1d968585" -"checksum futures-core-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)" = "10a3833d58fd08b3a40203613ed3a93c8bc0bc0181af5dd6422a0e08df1bfa68" -"checksum futures-executor-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)" = "0a75c64f20734619b4668e87f902544ce8c108dfcb6c9b6b2fcefdd1a848c15a" -"checksum futures-io-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)" = "b24891994ce1445f7e0cd494e4f57fd79f5bd9d37e9cc90a31d109e9a06d9073" -"checksum futures-signals 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d252ec61653bc4c26c21ef9e60ebe3137b58548adb35829084f5c15c633f472" -"checksum futures-sink-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)" = "f64fa75a0ce02dee949c8c9447abfc117df214054d6e96755d329c9053baf2fd" -"checksum futures-util-preview 0.3.0-alpha.15 (registry+https://github.com/rust-lang/crates.io-index)" = "ca958da50f4073c475d9f7ec6ce405451e06707bfd69686e83abd76cb4e1e7fb" -"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" -"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" -"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" -"checksum libc 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)" = "ec350a9417dfd244dc9a6c4a71e13895a4db6b92f0b106f07ebbc3f3bc580cee" -"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" -"checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" -"checksum num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1a23f0ed30a54abaa0c7e83b1d2d87ada7c3c23078d1d87815af3e3b6385fbba" -"checksum pin-utils 0.1.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" -"checksum proc-macro2 0.4.29 (registry+https://github.com/rust-lang/crates.io-index)" = "64c827cea7a7ab30ce4593e5e04d7a11617ad6ece2fa230605a78b00ff965316" -"checksum quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "faf4799c5d274f3868a4aae320a0a182cbd2baee377b378f080e16a23e9d80db" -"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" -"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)" = "aa5f7c20820475babd2c077c3ab5f8c77a31c15e16ea38687b4c02d3e48680f4" -"checksum serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)" = "58fc82bec244f168b23d1963b45c8bf5726e9a15a9d146a067f9081aeed2de79" -"checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d" -"checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" -"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" -"checksum stdweb 0.4.16 (git+https://github.com/koute/stdweb)" = "" -"checksum stdweb-derive 0.5.1 (git+https://github.com/koute/stdweb)" = "" -"checksum stdweb-derive 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0e21ebd9179de08f2300a65454268a17ea3de204627458588c84319c4def3930" -"checksum stdweb-internal-macros 0.2.7 (git+https://github.com/koute/stdweb)" = "" -"checksum stdweb-internal-runtime 0.1.4 (git+https://github.com/koute/stdweb)" = "" -"checksum syn 0.15.33 (registry+https://github.com/rust-lang/crates.io-index)" = "ec52cd796e5f01d0067225a5392e70084acc4c0013fa71d55166d38a8b307836" -"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" -"checksum wasm-bindgen 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "ffde3534e5fa6fd936e3260cd62cd644b8656320e369388f9303c955895e35d4" -"checksum wasm-bindgen-backend 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "40c0543374a7ae881cdc5d32d19de28d1d1929e92263ffa7e31712cc2d53f9f1" -"checksum wasm-bindgen-macro 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "f914c94c2c5f4c9364510ca2429e59c92157ec89429243bcc245e983db990a71" -"checksum wasm-bindgen-macro-support 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "9168c413491e4233db7b6884f09a43beb00c14d11d947ffd165242daa48a2385" -"checksum wasm-bindgen-shared 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "326c32126e1a157b6ced7400061a84ac5b11182b2cda6edad7314eb3ae9ac9fe" -"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" diff --git a/examples/stdweb/todomvc/Cargo.toml b/examples/stdweb/todomvc/Cargo.toml deleted file mode 100644 index 73765ca..0000000 --- a/examples/stdweb/todomvc/Cargo.toml +++ /dev/null @@ -1,19 +0,0 @@ -[package] -name = "todomvc" -version = "0.1.0" -authors = ["Pauan "] -edition = "2018" - -[dependencies] -dominator = { path = "../../.." } -futures-signals = "0.3.0" -serde_json = "1.0.10" -serde_derive = "1.0.27" - -[dependencies.serde] -version = "1.0.27" -features = ["rc"] - -[dependencies.stdweb] -version = "0.4.10" -features = ["experimental_features_which_may_break_on_minor_version_bumps"] diff --git a/examples/stdweb/todomvc/Web.toml b/examples/stdweb/todomvc/Web.toml deleted file mode 100644 index 813e273..0000000 --- a/examples/stdweb/todomvc/Web.toml +++ /dev/null @@ -1 +0,0 @@ -default-target = "wasm32-unknown-unknown" diff --git a/examples/stdweb/todomvc/static/index.html b/examples/stdweb/todomvc/static/index.html deleted file mode 100644 index 70aa0b4..0000000 --- a/examples/stdweb/todomvc/static/index.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - rust-dominator • TodoMVC - - - - - - - - diff --git a/examples/todomvc/.gitignore b/examples/todomvc/.gitignore new file mode 100644 index 0000000..36867e8 --- /dev/null +++ b/examples/todomvc/.gitignore @@ -0,0 +1,6 @@ +node_modules +/dist +/target +/pkg +/wasm-pack.log +/yarn-error.log diff --git a/examples/todomvc/Cargo.toml b/examples/todomvc/Cargo.toml new file mode 100644 index 0000000..927dfbc --- /dev/null +++ b/examples/todomvc/Cargo.toml @@ -0,0 +1,35 @@ +[package] +name = "todomvc" +version = "0.1.0" +description = "TodoMVC using dominator" +authors = ["Pauan "] +categories = ["wasm"] +readme = "README.md" +license = "MIT" +edition = "2018" + +[profile.release] +lto = true + +[lib] +crate-type = ["cdylib"] + +[dependencies] +dominator = { path = "../.." } +futures-signals = "0.3.0" +wasm-bindgen = "0.2.45" +serde_json = "1.0.10" +serde_derive = "1.0.27" + +[dependencies.serde] +version = "1.0.27" +features = ["rc"] + +[dependencies.web-sys] +version = "0.3.22" +features = [ + "Storage", +] + +[target."cfg(debug_assertions)".dependencies] +console_error_panic_hook = "0.1.5" diff --git a/examples/todomvc/README.md b/examples/todomvc/README.md new file mode 100644 index 0000000..46fe09f --- /dev/null +++ b/examples/todomvc/README.md @@ -0,0 +1,19 @@ +## How to install + +```sh +yarn install +``` + +## How to run in debug mode + +```sh +# Builds the project and opens it in a new browser tab. Auto-reloads when the project changes. +yarn start +``` + +## How to build in release mode + +```sh +# Builds the project and places it into the `dist` folder. +yarn run build +``` diff --git a/examples/todomvc/js/index.js b/examples/todomvc/js/index.js new file mode 100644 index 0000000..9db81ab --- /dev/null +++ b/examples/todomvc/js/index.js @@ -0,0 +1 @@ +import("../pkg/index.js").catch(console.error); diff --git a/examples/todomvc/package.json b/examples/todomvc/package.json new file mode 100644 index 0000000..9ce4fa0 --- /dev/null +++ b/examples/todomvc/package.json @@ -0,0 +1,17 @@ +{ + "author": "Pauan ", + "name": "todomvc", + "version": "0.1.0", + "scripts": { + "build": "rimraf dist pkg && webpack", + "start": "rimraf dist pkg && webpack-dev-server --open -d" + }, + "devDependencies": { + "@wasm-tool/wasm-pack-plugin": "^0.4.2", + "copy-webpack-plugin": "^5.0.3", + "webpack": "^4.33.0", + "webpack-cli": "^3.3.3", + "webpack-dev-server": "^3.7.1", + "rimraf": "^2.6.3" + } +} diff --git a/examples/stdweb/todomvc/src/main.rs b/examples/todomvc/src/lib.rs similarity index 87% rename from examples/stdweb/todomvc/src/main.rs rename to examples/todomvc/src/lib.rs index 3919949..a38e9f1 100644 --- a/examples/stdweb/todomvc/src/main.rs +++ b/examples/todomvc/src/lib.rs @@ -1,25 +1,31 @@ -#[macro_use] -extern crate stdweb; -#[macro_use] -extern crate dominator; -#[macro_use] -extern crate futures_signals; -#[macro_use] -extern crate serde_derive; - use std::rc::Rc; use std::cell::Cell; -// TODO replace most of these with dominator -use stdweb::web::window; -use stdweb::web::html_element::InputElement; -use stdweb::unstable::TryInto; -use stdweb::traits::*; - +use wasm_bindgen::prelude::*; +use serde_derive::{Serialize, Deserialize}; +use web_sys::{window, HtmlElement, Storage}; +use futures_signals::map_ref; use futures_signals::signal::{Signal, SignalExt, Mutable}; use futures_signals::signal_vec::{SignalVecExt, MutableVec}; -use dominator::{Dom, text, routing, HtmlElement}; -use dominator::events::{InputEvent, ClickEvent, KeyDownEvent, ChangeEvent, DoubleClickEvent, BlurEvent}; +use dominator::{Dom, text, routing, html, clone, events}; + + +fn local_storage() -> Storage { + window().unwrap_throw().local_storage().unwrap_throw().unwrap_throw() +} + +// TODO make this more efficient +#[inline] +fn trim(input: &str) -> Option { + let trimmed = input.trim(); + + if trimmed.is_empty() { + None + + } else { + Some(trimmed.to_owned()) + } +} #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -99,7 +105,9 @@ impl State { } fn deserialize() -> Self { - window().local_storage().get("todos-rust-dominator") + local_storage() + .get_item("todos-rust-dominator") + .unwrap_throw() .and_then(|state_json| { serde_json::from_str(state_json.as_str()).ok() }) @@ -107,43 +115,22 @@ impl State { } fn serialize(&self) { - let state_json = serde_json::to_string(self).unwrap(); - window().local_storage().insert("todos-rust-dominator", state_json.as_str()).unwrap(); + let state_json = serde_json::to_string(self).unwrap_throw(); + + local_storage().set_item("todos-rust-dominator", state_json.as_str()).unwrap_throw(); } } -// TODO make this more efficient -#[inline] -fn trim(input: &str) -> Option { - let trimmed = input.trim(); - - if trimmed.is_empty() { - None - - } else { - Some(trimmed.to_owned()) - } -} - -#[inline] -fn get_value(event: &InputEvent) -> String { - let target: InputElement = event.target().unwrap().try_into().unwrap(); - target.raw_value() -} - -#[inline] -fn get_checked(event: &ChangeEvent) -> bool { - js!( return @{&event.target()}.checked; ).try_into().unwrap() -} +#[wasm_bindgen(start)] +pub fn main_js() -> Result<(), JsValue> { + #[cfg(debug_assertions)] + console_error_panic_hook::set_once(); -fn main() { let state = Rc::new(State::deserialize()); - let body = dominator::body(); - - dominator::append_dom(&body, + dominator::append_dom(dominator::body(), html!("section", { .class("todoapp") .children(&mut [ @@ -160,11 +147,11 @@ fn main() { .property_signal("value", state.new_todo_title.signal_cloned()) - .event(clone!(state => move |event: InputEvent| { - state.new_todo_title.set_neq(get_value(&event)); + .event(clone!(state => move |event: events::Input| { + state.new_todo_title.set_neq(event.value().unwrap_throw()); })) - .event(clone!(state => move |event: KeyDownEvent| { + .event(clone!(state => move |event: events::KeyDown| { if event.key() == "Enter" { event.prevent_default(); @@ -212,8 +199,9 @@ fn main() { .len() .map(|len| len != 0)) - .event(clone!(state => move |event: ChangeEvent| { - let checked = !get_checked(&event); + .event(clone!(state => move |event: events::Change| { + // Toggles the boolean + let checked = !event.checked().unwrap_throw(); { let todo_list = state.todo_list.lock_ref(); @@ -264,14 +252,14 @@ fn main() { .property_signal("checked", todo.completed.signal()) - .event(clone!(state, todo => move |event: ChangeEvent| { - todo.completed.set_neq(get_checked(&event)); + .event(clone!(state, todo => move |event: events::Change| { + todo.completed.set_neq(event.checked().unwrap_throw()); state.serialize(); })) }), html!("label", { - .event(clone!(todo => move |_: DoubleClickEvent| { + .event(clone!(todo => move |_: events::DoubleClick| { todo.editing.set_neq(Some(todo.title.get_cloned())); })) @@ -280,7 +268,7 @@ fn main() { html!("button", { .class("destroy") - .event(clone!(state, todo => move |_: ClickEvent| { + .event(clone!(state, todo => move |_: events::Click| { state.remove_todo(&todo); state.serialize(); })) @@ -301,24 +289,24 @@ fn main() { .focused_signal(todo.editing.signal_cloned() .map(|x| x.is_some())) - .event(clone!(todo => move |event: KeyDownEvent| { - let key = event.key(); - - if key == "Enter" { - let element: HtmlElement = event.target().unwrap().try_into().unwrap(); - element.blur(); - - } else if key == "Escape" { - todo.editing.set_neq(None); + .event(clone!(todo => move |event: events::KeyDown| { + match event.key().as_str() { + "Enter" => { + event.dyn_target::().unwrap_throw().blur(); + }, + "Escape" => { + todo.editing.set_neq(None); + }, + _ => {} } })) - .event(clone!(todo => move |event: InputEvent| { - todo.editing.set_neq(Some(get_value(&event))); + .event(clone!(todo => move |event: events::Input| { + todo.editing.set_neq(Some(event.value().unwrap_throw())); })) // TODO global_event ? - .event(clone!(state, todo => move |_: BlurEvent| { + .event(clone!(state, todo => move |_: events::Blur| { if let Some(title) = todo.editing.replace(None) { if let Some(title) = trim(&title) { todo.title.set_neq(title); @@ -399,7 +387,7 @@ fn main() { .len() .map(|len| len > 0)) - .event(clone!(state => move |_: ClickEvent| { + .event(clone!(state => move |_: events::Click| { state.todo_list.lock_mut().retain(|todo| todo.completed.get() == false); state.serialize(); })) @@ -412,7 +400,7 @@ fn main() { }), ); - dominator::append_dom(&body, + dominator::append_dom(dominator::body(), html!("footer", { .class("info") .children(&mut [ @@ -440,4 +428,6 @@ fn main() { ]) }), ); + + Ok(()) } diff --git a/examples/todomvc/static/index.html b/examples/todomvc/static/index.html new file mode 100644 index 0000000..660b0c5 --- /dev/null +++ b/examples/todomvc/static/index.html @@ -0,0 +1,14 @@ + + + + + + rust-dominator • TodoMVC + + + + + + + + diff --git a/examples/stdweb/todomvc/static/lib/todomvc-app-css/index.css b/examples/todomvc/static/lib/todomvc-app-css/index.css similarity index 100% rename from examples/stdweb/todomvc/static/lib/todomvc-app-css/index.css rename to examples/todomvc/static/lib/todomvc-app-css/index.css diff --git a/examples/stdweb/todomvc/static/lib/todomvc-common/base.css b/examples/todomvc/static/lib/todomvc-common/base.css similarity index 100% rename from examples/stdweb/todomvc/static/lib/todomvc-common/base.css rename to examples/todomvc/static/lib/todomvc-common/base.css diff --git a/examples/stdweb/todomvc/static/lib/todomvc-common/base.js b/examples/todomvc/static/lib/todomvc-common/base.js similarity index 100% rename from examples/stdweb/todomvc/static/lib/todomvc-common/base.js rename to examples/todomvc/static/lib/todomvc-common/base.js diff --git a/examples/todomvc/webpack.config.js b/examples/todomvc/webpack.config.js new file mode 100644 index 0000000..57f5c32 --- /dev/null +++ b/examples/todomvc/webpack.config.js @@ -0,0 +1,29 @@ +const path = require("path"); +const CopyPlugin = require("copy-webpack-plugin"); +const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin"); + +const dist = path.resolve(__dirname, "dist"); + +module.exports = { + mode: "production", + entry: { + index: "./js/index.js" + }, + output: { + path: dist, + filename: "[name].js" + }, + devServer: { + contentBase: dist, + }, + plugins: [ + new CopyPlugin([ + path.resolve(__dirname, "static") + ]), + + new WasmPackPlugin({ + crateDirectory: __dirname, + extraArgs: "--out-name index" + }), + ] +}; diff --git a/src/animation.rs b/src/animation.rs index 06d0286..cc2afa8 100644 --- a/src/animation.rs +++ b/src/animation.rs @@ -1,50 +1,77 @@ use std::fmt; +use std::rc::Rc; +use std::cell::RefCell; use std::pin::Pin; use std::marker::Unpin; use std::sync::{Arc, Weak, Mutex, RwLock}; use std::task::{Poll, Waker, Context}; + use futures_util::future::{ready, FutureExt}; use futures_signals::CancelableFutureHandle; use futures_signals::signal::{Signal, SignalExt, WaitFor, MutableSignal, Mutable}; use futures_signals::signal_vec::{SignalVec, VecDiff}; -use stdweb::Value; use discard::DiscardOnDrop; -use operations::spawn_future; use pin_utils::{unsafe_pinned, unsafe_unpinned}; +use wasm_bindgen::{JsCast, UnwrapThrowExt}; +use wasm_bindgen::closure::Closure; +use web_sys::window; +use crate::operations::spawn_future; + + +struct RafState { + id: i32, + closure: Closure, +} // TODO generalize this so it works for any target, not just JS -struct Raf(Value); +struct Raf { + state: Rc>>, +} impl Raf { - #[inline] - fn new(callback: F) -> Self where F: FnMut(f64) + 'static { - Raf(js!( - var callback = @{callback}; + fn new(mut callback: F) -> Self where F: FnMut(f64) + 'static { + let state: Rc>> = Rc::new(RefCell::new(None)); + + fn schedule(callback: &Closure) -> i32 { + window() + .unwrap_throw() + .request_animation_frame(callback.as_ref().unchecked_ref()) + .unwrap_throw() + } + + let closure = { + let state = state.clone(); + + Closure::wrap(Box::new(move |time| { + { + let mut state = state.borrow_mut(); + let state = state.as_mut().unwrap_throw(); + state.id = schedule(&state.closure); + } - function loop(time) { - value.id = requestAnimationFrame(loop); callback(time); - } + }) as Box) + }; - var value = { - callback: callback, - id: requestAnimationFrame(loop) - }; + *state.borrow_mut() = Some(RafState { + id: schedule(&closure), + closure + }); - return value; - )) + Self { state } } } impl Drop for Raf { - #[inline] fn drop(&mut self) { - js! { @(no_return) - var self = @{&self.0}; - cancelAnimationFrame(self.id); - self.callback.drop(); - } + // The take is necessary in order to prevent an Rc leak + let state = self.state.borrow_mut().take().unwrap_throw(); + + window() + .unwrap_throw() + .cancel_animation_frame(state.id) + .unwrap_throw(); } } @@ -85,12 +112,12 @@ impl Signal for Timestamps { // TODO implement Poll::Ready(None) fn poll_change(self: Pin<&mut Self>, cx: &mut Context) -> Poll> { - let mut lock = self.state.lock().unwrap(); + let mut lock = self.state.lock().unwrap_throw(); match lock.state { TimestampsEnum::Changed => { lock.state = TimestampsEnum::NotChanged; - Poll::Ready(Some(*self.value.read().unwrap())) + Poll::Ready(Some(*self.value.read().unwrap_throw())) }, TimestampsEnum::First => { lock.state = TimestampsEnum::NotChanged; @@ -104,8 +131,9 @@ impl Signal for Timestamps { } } -lazy_static! { - static ref TIMESTAMPS: Arc = Arc::new(TimestampsGlobal { +// TODO somehow share this safely between threads ? +thread_local! { + static TIMESTAMPS_MANAGER: Arc = Arc::new(TimestampsGlobal { inner: Mutex::new(TimestampsInner { raf: None, states: vec![], @@ -115,56 +143,58 @@ lazy_static! { } pub fn timestamps() -> Timestamps { - let timestamps = Timestamps { - state: Arc::new(Mutex::new(TimestampsState { - state: TimestampsEnum::First, - waker: None, - })), - value: TIMESTAMPS.value.clone(), - }; + TIMESTAMPS_MANAGER.with(|timestamps_manager| { + let timestamps = Timestamps { + state: Arc::new(Mutex::new(TimestampsState { + state: TimestampsEnum::First, + waker: None, + })), + value: timestamps_manager.value.clone(), + }; - { - let mut lock = TIMESTAMPS.inner.lock().unwrap(); + { + let mut lock = timestamps_manager.inner.lock().unwrap_throw(); - lock.states.push(Arc::downgrade(×tamps.state)); + lock.states.push(Arc::downgrade(×tamps.state)); - if let None = lock.raf { - let global = TIMESTAMPS.clone(); + if let None = lock.raf { + let global = timestamps_manager.clone(); - lock.raf = Some(Raf::new(move |time| { - let mut lock = global.inner.lock().unwrap(); - let mut value = global.value.write().unwrap(); + lock.raf = Some(Raf::new(move |time| { + let mut lock = global.inner.lock().unwrap_throw(); + let mut value = global.value.write().unwrap_throw(); - *value = Some(time); + *value = Some(time); - lock.states.retain(|state| { - if let Some(state) = state.upgrade() { - let mut lock = state.lock().unwrap(); + lock.states.retain(|state| { + if let Some(state) = state.upgrade() { + let mut lock = state.lock().unwrap_throw(); - lock.state = TimestampsEnum::Changed; + lock.state = TimestampsEnum::Changed; - if let Some(waker) = lock.waker.take() { - drop(lock); - waker.wake(); + if let Some(waker) = lock.waker.take() { + drop(lock); + waker.wake(); + } + + true + + } else { + false } + }); - true - - } else { - false + if lock.states.len() == 0 { + lock.raf = None; + // TODO is this a good idea ? + lock.states = vec![]; } - }); - - if lock.states.len() == 0 { - lock.raf = None; - // TODO is this a good idea ? - lock.states = vec![]; - } - })); + })); + } } - } - timestamps + timestamps + }) } @@ -505,12 +535,12 @@ impl MutableTimestamps where F: FnMut(f64) { } pub fn stop(&self) { - let mut lock = self.animating.lock().unwrap(); + let mut lock = self.animating.lock().unwrap_throw(); *lock = None; } pub fn start(&self) { - let mut lock = self.animating.lock().unwrap(); + let mut lock = self.animating.lock().unwrap_throw(); if let None = animating { let callback = self.callback.clone(); @@ -608,7 +638,7 @@ pub struct MutableAnimation { impl fmt::Debug for MutableAnimation { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - let state = self.inner.state.lock().unwrap(); + let state = self.inner.state.lock().unwrap_throw(); fmt.debug_struct("MutableAnimation") .field("playing", &state.playing) @@ -672,7 +702,7 @@ impl MutableAnimation { // TODO test the performance of set_neq if diff >= 1.0 { { - let mut lock = state.inner.state.lock().unwrap(); + let mut lock = state.inner.state.lock().unwrap_throw(); Self::stop_animating(&mut lock); } state.inner.value.set_neq(Percentage::new_unchecked(end)); @@ -697,7 +727,7 @@ impl MutableAnimation { pub fn set_duration(&self, duration: f64) { debug_assert!(duration >= 0.0); - let mut lock = self.inner.state.lock().unwrap(); + let mut lock = self.inner.state.lock().unwrap_throw(); if lock.duration != duration { lock.duration = duration; @@ -707,7 +737,7 @@ impl MutableAnimation { #[inline] pub fn pause(&self) { - let mut lock = self.inner.state.lock().unwrap(); + let mut lock = self.inner.state.lock().unwrap_throw(); if lock.playing { lock.playing = false; @@ -717,7 +747,7 @@ impl MutableAnimation { #[inline] pub fn play(&self) { - let mut lock = self.inner.state.lock().unwrap(); + let mut lock = self.inner.state.lock().unwrap_throw(); if !lock.playing { lock.playing = true; @@ -734,13 +764,13 @@ impl MutableAnimation { } pub fn jump_to(&self, end: Percentage) { - let mut lock = self.inner.state.lock().unwrap(); + let mut lock = self.inner.state.lock().unwrap_throw(); Self::_jump_to(&mut lock, &self.inner.value, end); } pub fn animate_to(&self, end: Percentage) { - let mut lock = self.inner.state.lock().unwrap(); + let mut lock = self.inner.state.lock().unwrap_throw(); if lock.end != end { if lock.duration <= 0.0 { diff --git a/src/callbacks.rs b/src/callbacks.rs index 8fd97bf..d97cb53 100644 --- a/src/callbacks.rs +++ b/src/callbacks.rs @@ -4,7 +4,7 @@ use discard::Discard; // TODO replace this with FnOnce later trait IInsertCallback { - fn call(self: Box, &mut Callbacks); + fn call(self: Box, callbacks: &mut Callbacks); } impl IInsertCallback for F { diff --git a/src/dom.rs b/src/dom.rs index 226422a..87949a6 100644 --- a/src/dom.rs +++ b/src/dom.rs @@ -3,21 +3,24 @@ use std::convert::AsRef; use std::marker::PhantomData; use std::future::Future; use std::task::{Context, Poll}; -use stdweb::{Reference, Value, JsSerialize, Once}; -use stdweb::unstable::{TryFrom, TryInto}; -use stdweb::web::{IEventTarget, INode, IElement, IHtmlElement, HtmlElement, Node, window, TextNode, EventTarget, Element}; -use stdweb::web::event::ConcreteEvent; -use callbacks::Callbacks; -use traits::*; -use operations; -use operations::for_each; -use dom_operations; -use operations::{ValueDiscard, FnDiscard, spawn_future}; + +use lazy_static::lazy_static; use futures_signals::signal::{Signal, not}; use futures_signals::signal_vec::SignalVec; use futures_util::FutureExt; use futures_channel::oneshot; use discard::{Discard, DiscardOnDrop}; +use wasm_bindgen::{JsValue, UnwrapThrowExt, JsCast}; +use js_sys::Reflect; +use web_sys::{window, HtmlElement, Node, EventTarget, Element, CssStyleSheet, HtmlStyleElement, CssStyleRule, CssStyleDeclaration}; +use gloo::events::{EventListener, EventListenerOptions}; + +use crate::callbacks::Callbacks; +use crate::traits::*; +use crate::operations; +use crate::operations::{for_each, spawn_future}; +use crate::dom_operations; +use crate::utils::{document, on, on_with_options, ValueDiscard, FnDiscard, EventDiscard}; pub struct RefFn where B: ?Sized { @@ -71,172 +74,6 @@ impl RefFn where B: ?Sized, C: Fn(&A) -> &B { }*/ -// TODO this should be in stdweb -#[derive(Clone, Debug, PartialEq, Eq, ReferenceType)] -#[reference(instance_of = "CSSStyleRule")] -pub struct CssStyleRule(Reference); - - -/// A reference to an SVG Element. -/// -/// [(JavaScript docs)](https://developer.mozilla.org/en-US/docs/Web/API/SVGElement) -// TODO move this into stdweb -#[derive(Clone, Debug, PartialEq, Eq, ReferenceType)] -#[reference(instance_of = "SVGElement")] -#[reference(subclass_of(EventTarget, Node, Element))] -pub struct SvgElement(Reference); - -impl IEventTarget for SvgElement {} -impl INode for SvgElement {} -impl IElement for SvgElement {} - - -// TODO move this into stdweb -#[derive(Clone, Debug, PartialEq, Eq, ReferenceType)] -#[reference(instance_of = "URL")] -pub struct Url( Reference ); - -// TODO create_object_url, revoke_object_url, and search_params -impl Url { - #[inline] - pub fn new( url: &str ) -> Self { - js!( return new URL( @{url} ); ).try_into().unwrap() - } - - #[inline] - pub fn hash( &self ) -> String { - js!( return @{&self.0}.hash; ).try_into().unwrap() - } - - #[inline] - pub fn set_hash( &self, hash: &str ) { - js! { @(no_return) - @{&self.0}.hash = @{hash}; - } - } - - #[inline] - pub fn host( &self ) -> String { - js!( return @{&self.0}.host; ).try_into().unwrap() - } - - #[inline] - pub fn set_host( &self, host: &str ) { - js! { @(no_return) - @{&self.0}.host = @{host}; - } - } - - #[inline] - pub fn hostname( &self ) -> String { - js!( return @{&self.0}.hostname; ).try_into().unwrap() - } - - #[inline] - pub fn set_hostname( &self, hostname: &str ) { - js! { @(no_return) - @{&self.0}.hostname = @{hostname}; - } - } - - #[inline] - pub fn href( &self ) -> String { - js!( return @{&self.0}.href; ).try_into().unwrap() - } - - #[inline] - pub fn set_href( &self, href: &str ) { - js! { @(no_return) - @{&self.0}.href = @{href}; - } - } - - #[inline] - pub fn origin( &self ) -> String { - js!( return @{&self.0}.origin; ).try_into().unwrap() - } - - #[inline] - pub fn password( &self ) -> String { - js!( return @{&self.0}.password; ).try_into().unwrap() - } - - #[inline] - pub fn set_password( &self, password: &str ) { - js! { @(no_return) - @{&self.0}.password = @{password}; - } - } - - #[inline] - pub fn pathname( &self ) -> String { - js!( return @{&self.0}.pathname; ).try_into().unwrap() - } - - #[inline] - pub fn set_pathname( &self, pathname: &str ) { - js! { @(no_return) - @{&self.0}.pathname = @{pathname}; - } - } - - #[inline] - pub fn port( &self ) -> String { - js!( return @{&self.0}.port; ).try_into().unwrap() - } - - #[inline] - pub fn set_port( &self, port: &str ) { - js! { @(no_return) - @{&self.0}.port = @{port}; - } - } - - #[inline] - pub fn protocol( &self ) -> String { - js!( return @{&self.0}.protocol; ).try_into().unwrap() - } - - #[inline] - pub fn set_protocol( &self, protocol: &str ) { - js! { @(no_return) - @{&self.0}.protocol = @{protocol}; - } - } - - #[inline] - pub fn search( &self ) -> String { - js!( return @{&self.0}.search; ).try_into().unwrap() - } - - #[inline] - pub fn set_search( &self, search: &str ) { - js! { @(no_return) - @{&self.0}.search = @{search}; - } - } - - #[inline] - pub fn username( &self ) -> String { - js!( return @{&self.0}.username; ).try_into().unwrap() - } - - #[inline] - pub fn set_username( &self, username: &str ) { - js! { @(no_return) - @{&self.0}.username = @{username}; - } - } -} - -impl ::std::fmt::Display for Url { - #[inline] - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - self.href().fmt(f) - } -} - - // https://developer.mozilla.org/en-US/docs/Web/API/Document/createElementNS#Valid%20Namespace%20URIs pub const HTML_NAMESPACE: &str = "http://www.w3.org/1999/xhtml"; pub const SVG_NAMESPACE: &str = "http://www.w3.org/2000/svg"; @@ -252,10 +89,9 @@ lazy_static! { } -// TODO this should be in stdweb -// TODO this should return HtmlBodyElement +// TODO should return HtmlBodyElement ? pub fn body() -> HtmlElement { - js! ( return document.body; ).try_into().unwrap() + document().body().unwrap_throw() } @@ -267,14 +103,14 @@ pub struct DomHandle { impl Discard for DomHandle { #[inline] fn discard(self) { - self.parent.remove_child(&self.dom.element).unwrap(); + self.parent.remove_child(&self.dom.element).unwrap_throw(); self.dom.callbacks.discard(); } } #[inline] -pub fn append_dom(parent: &A, mut dom: Dom) -> DomHandle { - parent.append_child(&dom.element); +pub fn append_dom(parent: Node, mut dom: Dom) -> DomHandle { + parent.append_child(&dom.element).unwrap_throw(); dom.callbacks.trigger_after_insert(); @@ -282,49 +118,17 @@ pub fn append_dom(parent: &A, mut dom: Dom) -> DomHandle { dom.callbacks.leak(); DomHandle { - parent: parent.as_node().clone(), - dom + parent, + dom, } } -struct IsWindowLoadedEvent { - callback: Value, -} - -impl IsWindowLoadedEvent { - #[inline] - fn new(callback: F) -> Self where F: FnOnce() + 'static { - // TODO use a proper type for the event - let callback = move |_: Value| { - callback(); - }; - - Self { - callback: js!( - var callback = @{Once(callback)}; - addEventListener("load", callback, true); - return callback; - ), - } - } -} - -impl Drop for IsWindowLoadedEvent { - fn drop(&mut self) { - js! { @(no_return) - var callback = @{&self.callback}; - removeEventListener("load", callback, true); - callback.drop(); - } - } -} - enum IsWindowLoaded { Initial {}, Pending { - receiver: oneshot::Receiver<()>, - _event: IsWindowLoadedEvent, + receiver: oneshot::Receiver>, + _event: EventListener, }, Done {}, } @@ -332,14 +136,10 @@ enum IsWindowLoaded { impl Signal for IsWindowLoaded { type Item = bool; - fn poll_change(self: Pin<&mut Self>, cx: &mut Context) -> Poll> { - // Safe to call `get_mut_unchecked` because we won't move the futures. - // TODO verify the safety of this - let this = unsafe { Pin::get_unchecked_mut(self) }; - - let result = match this { + fn poll_change(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll> { + let result = match *self { IsWindowLoaded::Initial {} => { - let is_ready: bool = js!( return document.readyState === "complete"; ).try_into().unwrap(); + let is_ready = document().ready_state() == "complete"; if is_ready { Poll::Ready(Some(true)) @@ -347,19 +147,19 @@ impl Signal for IsWindowLoaded { } else { let (sender, receiver) = oneshot::channel(); - *this = IsWindowLoaded::Pending { + *self = IsWindowLoaded::Pending { receiver, - _event: IsWindowLoadedEvent::new(move || { + _event: EventListener::once(&window().unwrap_throw(), "load", move |_| { // TODO test this - sender.send(()).unwrap(); + sender.send(Some(true)).unwrap_throw(); }), }; Poll::Ready(Some(false)) } }, - IsWindowLoaded::Pending { receiver, .. } => { - receiver.poll_unpin(cx).map(|_| Some(true)) + IsWindowLoaded::Pending { ref mut receiver, .. } => { + receiver.poll_unpin(cx).map(|x| x.unwrap_throw()) }, IsWindowLoaded::Done {} => { Poll::Ready(None) @@ -367,13 +167,14 @@ impl Signal for IsWindowLoaded { }; if let Poll::Ready(Some(true)) = result { - *this = IsWindowLoaded::Done {}; + *self = IsWindowLoaded::Done {}; } result } } +// TODO this should be moved into gloo #[inline] pub fn is_window_loaded() -> impl Signal { IsWindowLoaded::Initial {} @@ -382,7 +183,7 @@ pub fn is_window_loaded() -> impl Signal { #[inline] pub fn text(value: &str) -> Dom { - Dom::new(js!( return document.createTextNode(@{value}); ).try_into().unwrap()) + Dom::new(document().create_text_node(value).into()) } @@ -391,7 +192,7 @@ pub fn text_signal(value: B) -> Dom where A: AsStr, B: Signal + 'static { - let element: TextNode = js!( return document.createTextNode(""); ).try_into().unwrap(); + let element = document().create_text_node(""); let mut callbacks = Callbacks::new(); @@ -400,7 +201,9 @@ pub fn text_signal(value: B) -> Dom callbacks.after_remove(for_each(value, move |value| { let value = value.as_str(); - dom_operations::set_text(&element, value); + + // http://jsperf.com/textnode-performance + element.set_data(value); })); } @@ -429,7 +232,8 @@ impl Dom { #[inline] pub fn empty() -> Self { // TODO is there a better way of doing this ? - Self::new(js!( return document.createComment(""); ).try_into().unwrap()) + // TODO is it legal to append children to a comment node ? + Self::new(document().create_comment("").into()) } #[inline] @@ -446,40 +250,19 @@ impl Dom { } -struct EventListenerHandle where A: AsRef { - event: &'static str, - element: A, - listener: Value, -} - -impl Discard for EventListenerHandle where A: AsRef { - #[inline] - fn discard(self) { - js! { @(no_return) - var listener = @{&self.listener}; - @{self.element.as_ref()}.removeEventListener(@{self.event}, listener); - listener.drop(); - } - } -} - - // TODO create HTML / SVG specific versions of this ? #[inline] -pub fn create_element_ns(name: &str, namespace: &str) -> A - where >::Error: ::std::fmt::Debug { - dom_operations::create_element_ns(name, namespace) +pub fn create_element_ns(name: &str, namespace: &str) -> A where A: JsCast { + document().create_element_ns(Some(namespace), name).unwrap_throw().dyn_into().unwrap_throw() } -fn set_option(element: &A, callbacks: &mut Callbacks, value: D, mut f: F) - where A: Clone + 'static, +fn set_option(element: A, callbacks: &mut Callbacks, value: D, mut f: F) + where A: 'static, C: OptionStr, D: Signal + 'static, F: FnMut(&A, Option) + 'static { - let element = element.clone(); - let mut is_set = false; callbacks.after_remove(for_each(value, move |value| { @@ -499,17 +282,26 @@ fn set_option(element: &A, callbacks: &mut Callbacks, value: D, m })); } -fn set_style(element: &A, name: &B, value: C, important: bool) - where A: AsRef, - B: MultiStr, - C: MultiStr { +fn set_style(style: &CssStyleDeclaration, name: &A, value: B, important: bool) + where A: MultiStr, + B: MultiStr { let mut names = vec![]; let mut values = vec![]; let okay = name.any(|name| { value.any(|value| { - if dom_operations::try_set_style(element, name, value, important) { + assert!(value != ""); + + // TODO handle browser prefixes ? + style.remove_property(name).unwrap_throw(); + + style.set_property_with_priority(name, value, if important { "important" } else { "" }).unwrap_throw(); + + // TODO maybe use cfg(debug_assertions) ? + let is_changed = style.get_property_value(name).unwrap_throw() != ""; + + if is_changed { true } else { @@ -526,27 +318,38 @@ fn set_style(element: &A, name: &B, value: C, important: bool) } } -fn set_style_signal(element: &A, callbacks: &mut Callbacks, name: B, value: E, important: bool) - where A: AsRef + Clone + 'static, - B: MultiStr + 'static, - C: MultiStr, - D: OptionStr, - E: Signal + 'static { +fn set_style_signal(style: CssStyleDeclaration, callbacks: &mut Callbacks, name: A, value: D, important: bool) + where A: MultiStr + 'static, + B: MultiStr, + C: OptionStr, + D: Signal + 'static { - set_option(element, callbacks, value, move |element, value| { + set_option(style, callbacks, value, move |style, value| { match value { Some(value) => { - set_style(element, &name, value, important); + set_style(style, &name, value, important); }, None => { name.each(|name| { - dom_operations::remove_style(element, name); + // TODO handle browser prefixes ? + style.remove_property(name).unwrap_throw(); }); }, } }); } +// TODO check that the property *actually* was changed ? +fn set_property(element: &A, name: &B, value: C) where A: AsRef, B: MultiStr, C: Into { + let element = element.as_ref(); + let value = value.into(); + + name.each(|name| { + // TODO can this be made more efficient ? + assert!(Reflect::set(element, &JsValue::from(name), &value).unwrap_throw()); + }); +} + pub struct DomBuilder { element: A, @@ -565,32 +368,26 @@ impl DomBuilder { } } - // TODO maybe inline this ? - // TODO replace with element.add_event_listener - fn _event(&mut self, element: B, listener: F) - where B: IEventTarget + 'static, - T: ConcreteEvent, + #[inline] + fn _event(&mut self, element: &EventTarget, listener: F) + where T: StaticEvent, F: FnMut(T) + 'static { + self.callbacks.after_remove(EventDiscard::new(on(element, listener))); + } - let listener = js!( - var listener = @{listener}; - @{element.as_ref()}.addEventListener(@{T::EVENT_TYPE}, listener); - return listener; - ); - - self.callbacks.after_remove(EventListenerHandle { - event: T::EVENT_TYPE, - element, - listener, - }); + #[inline] + fn _event_with_options(&mut self, element: &EventTarget, options: EventListenerOptions, listener: F) + where T: StaticEvent, + F: FnMut(T) + 'static { + self.callbacks.after_remove(EventDiscard::new(on_with_options(element, options, listener))); } // TODO add this to the StylesheetBuilder and ClassBuilder too #[inline] pub fn global_event(mut self, listener: F) -> Self - where T: ConcreteEvent, + where T: StaticEvent, F: FnMut(T) + 'static { - self._event(window(), listener); + self._event(&window().unwrap_throw(), listener); self } @@ -615,29 +412,9 @@ impl DomBuilder { self } } - - - #[deprecated(since = "0.3.2", note = "Use apply instead")] - #[allow(deprecated)] - #[inline] - pub fn mixin>(self, mixin: B) -> Self { - self.mixin_if(true, mixin) - } - - #[deprecated(since = "0.3.2", note = "Use apply_if instead")] - #[allow(deprecated)] - #[inline] - pub fn mixin_if>(self, test: bool, mixin: B) -> Self { - if test { - mixin.apply(self) - - } else { - self - } - } } -impl DomBuilder { +impl DomBuilder where A: Clone { #[inline] pub fn with_element(self, f: F) -> B where F: FnOnce(Self, A) -> B { let element = self.element.clone(); @@ -652,7 +429,7 @@ impl DomBuilder { } } -impl DomBuilder { +impl DomBuilder where A: Clone + 'static { #[inline] pub fn after_inserted(mut self, f: F) -> Self where F: FnOnce(A) + 'static { let element = self.element.clone(); @@ -668,7 +445,7 @@ impl DomBuilder { } } -impl> DomBuilder { +impl DomBuilder where A: Into { #[inline] pub fn into_dom(self) -> Dom { Dom { @@ -678,36 +455,31 @@ impl> DomBuilder { } } -// TODO make this JsSerialize rather than AsRef ? -impl> DomBuilder { +impl DomBuilder where A: AsRef { #[inline] - pub fn property(self, name: B, value: C) -> Self where B: MultiStr, C: JsSerialize { - name.each(|name| { - dom_operations::set_property(&self.element, name, &value); - }); + pub fn property(self, name: B, value: C) -> Self where B: MultiStr, C: Into { + set_property(&self.element, &name, value); self } } -impl + Clone + 'static> DomBuilder { +impl DomBuilder where A: AsRef { fn set_property_signal(&mut self, name: B, value: D) where B: MultiStr + 'static, - C: JsSerialize, + C: Into, D: Signal + 'static { - let element = self.element.clone(); + let element = self.element.as_ref().clone(); self.callbacks.after_remove(for_each(value, move |value| { - name.each(|name| { - dom_operations::set_property(&element, name, &value); - }); + set_property(&element, &name, value); })); } #[inline] pub fn property_signal(mut self, name: B, value: D) -> Self where B: MultiStr + 'static, - C: JsSerialize, + C: Into, D: Signal + 'static { self.set_property_signal(name, value); @@ -715,26 +487,34 @@ impl + Clone + 'static> DomBuilder { } } -impl DomBuilder { +impl DomBuilder where A: AsRef { #[inline] pub fn event(mut self, listener: F) -> Self - where T: ConcreteEvent, + where T: StaticEvent, F: FnMut(T) + 'static { - // TODO is this clone correct ? - let element = self.element.clone(); - self._event(element, listener); + // TODO can this clone be avoided ? + self._event(&self.element.as_ref().clone(), listener); + self + } + + #[inline] + pub fn event_preventable(mut self, listener: F) -> Self + where T: StaticEvent, + F: FnMut(T) + 'static { + // TODO can this clone be avoided ? + self._event_with_options(&self.element.as_ref().clone(), EventListenerOptions::enable_prevent_default(), listener); self } } -impl DomBuilder { +impl DomBuilder where A: AsRef { // TODO figure out how to make this owned rather than &mut #[inline] pub fn children<'a, B: IntoIterator>(mut self, children: B) -> Self { assert_eq!(self.has_children, false); self.has_children = true; - operations::insert_children_iter(&self.element, &mut self.callbacks, children); + operations::insert_children_iter(self.element.as_ref(), &mut self.callbacks, children); self } @@ -757,7 +537,7 @@ impl DomBuilder { } } -impl DomBuilder { +impl DomBuilder where A: AsRef { #[inline] pub fn children_signal_vec(mut self, children: B) -> Self where B: SignalVec + 'static { @@ -765,16 +545,16 @@ impl DomBuilder { assert_eq!(self.has_children, false); self.has_children = true; - operations::insert_children_signal_vec(&self.element, &mut self.callbacks, children); + operations::insert_children_signal_vec(self.element.as_ref().clone(), &mut self.callbacks, children); self } } -impl DomBuilder { +impl DomBuilder where A: AsRef { #[inline] pub fn attribute(self, name: B, value: &str) -> Self where B: MultiStr { name.each(|name| { - dom_operations::set_attribute(&self.element, name, value); + dom_operations::set_attribute(self.element.as_ref(), name, value); }); self } @@ -782,7 +562,7 @@ impl DomBuilder { #[inline] pub fn attribute_namespace(self, namespace: &str, name: B, value: &str) -> Self where B: MultiStr { name.each(|name| { - dom_operations::set_attribute_ns(&self.element, namespace, name, value); + dom_operations::set_attribute_ns(self.element.as_ref(), namespace, name, value); }); self } @@ -790,20 +570,32 @@ impl DomBuilder { #[inline] pub fn class(self, name: B) -> Self where B: MultiStr { name.each(|name| { - dom_operations::add_class(&self.element, name); + dom_operations::add_class(self.element.as_ref(), name); }); self } + + // TODO make this more efficient ? + #[inline] + pub fn visible(self, value: bool) -> Self { + if value { + // TODO remove the class somehow ? + self + + } else { + self.class(&*HIDDEN_CLASS) + } + } } -impl DomBuilder { +impl DomBuilder where A: AsRef { fn set_attribute_signal(&mut self, name: B, value: E) where B: MultiStr + 'static, C: AsStr, D: OptionStr, E: Signal + 'static { - set_option(&self.element, &mut self.callbacks, value, move |element, value| { + set_option(self.element.as_ref().clone(), &mut self.callbacks, value, move |element, value| { match value { Some(value) => { let value = value.as_str(); @@ -841,7 +633,7 @@ impl DomBuilder { let namespace = namespace.to_owned(); - set_option(&self.element, &mut self.callbacks, value, move |element, value| { + set_option(self.element.as_ref().clone(), &mut self.callbacks, value, move |element, value| { match value { Some(value) => { let value = value.as_str(); @@ -875,7 +667,7 @@ impl DomBuilder { where B: MultiStr + 'static, C: Signal + 'static { - let element = self.element.clone(); + let element = self.element.as_ref().clone(); let mut is_set = false; @@ -910,13 +702,19 @@ impl DomBuilder { self } + // TODO make this more efficient ? + #[inline] + pub fn visible_signal(self, value: B) -> Self where B: Signal + 'static { + self.class_signal(&*HIDDEN_CLASS, not(value)) + } + // TODO use OptionStr ? fn set_scroll_signal(&mut self, signal: B, mut f: F) - where B: Signal> + 'static, - F: FnMut(&A, f64) + 'static { + where B: Signal> + 'static, + F: FnMut(&Element, i32) + 'static { - let element = self.element.clone(); + let element: Element = self.element.as_ref().clone(); // This needs to use `after_insert` because scrolling an element before it is in the DOM has no effect self.callbacks.after_insert(move |callbacks| { @@ -929,24 +727,24 @@ impl DomBuilder { } #[inline] - pub fn scroll_left_signal(mut self, signal: B) -> Self where B: Signal> + 'static { - self.set_scroll_signal(signal, IElement::set_scroll_left); + pub fn scroll_left_signal(mut self, signal: B) -> Self where B: Signal> + 'static { + self.set_scroll_signal(signal, Element::set_scroll_left); self } #[inline] - pub fn scroll_top_signal(mut self, signal: B) -> Self where B: Signal> + 'static { - self.set_scroll_signal(signal, IElement::set_scroll_top); + pub fn scroll_top_signal(mut self, signal: B) -> Self where B: Signal> + 'static { + self.set_scroll_signal(signal, Element::set_scroll_top); self } } -impl DomBuilder { +impl DomBuilder where A: AsRef { #[inline] pub fn style(self, name: B, value: C) -> Self where B: MultiStr, C: MultiStr { - set_style(&self.element, &name, value, false); + set_style(&self.element.as_ref().style(), &name, value, false); self } @@ -954,24 +752,12 @@ impl DomBuilder { pub fn style_important(self, name: B, value: C) -> Self where B: MultiStr, C: MultiStr { - set_style(&self.element, &name, value, true); + set_style(&self.element.as_ref().style(), &name, value, true); self } - - // TODO make this more efficient ? - #[inline] - pub fn visible(self, value: bool) -> Self { - if value { - // TODO remove the class somehow ? - self - - } else { - self.class(&*HIDDEN_CLASS) - } - } } -impl DomBuilder { +impl DomBuilder where A: AsRef { #[inline] pub fn style_signal(mut self, name: B, value: E) -> Self where B: MultiStr + 'static, @@ -979,7 +765,7 @@ impl DomBuilder { D: OptionStr, E: Signal + 'static { - set_style_signal(&self.element, &mut self.callbacks, name, value, false); + set_style_signal(self.element.as_ref().style(), &mut self.callbacks, name, value, false); self } @@ -990,7 +776,7 @@ impl DomBuilder { D: OptionStr, E: Signal + 'static { - set_style_signal(&self.element, &mut self.callbacks, name, value, true); + set_style_signal(self.element.as_ref().style(), &mut self.callbacks, name, value, true); self } @@ -998,7 +784,7 @@ impl DomBuilder { // TODO remove the `value` argument ? #[inline] pub fn focused(mut self, value: bool) -> Self { - let element = self.element.clone(); + let element = self.element.as_ref().clone(); // This needs to use `after_insert` because calling `.focus()` on an element before it is in the DOM has no effect self.callbacks.after_insert(move |_| { @@ -1013,7 +799,7 @@ impl DomBuilder { fn set_focused_signal(&mut self, value: B) where B: Signal + 'static { - let element = self.element.clone(); + let element = self.element.as_ref().clone(); // This needs to use `after_insert` because calling `.focus()` on an element before it is in the DOM has no effect self.callbacks.after_insert(move |callbacks| { @@ -1032,20 +818,13 @@ impl DomBuilder { self.set_focused_signal(value); self } - - - // TODO make this more efficient ? - #[inline] - pub fn visible_signal(self, value: B) -> Self where B: Signal + 'static { - self.class_signal(&*HIDDEN_CLASS, not(value)) - } } // TODO better warning message for must_use #[must_use] pub struct StylesheetBuilder { - element: CssStyleRule, + element: CssStyleDeclaration, callbacks: Callbacks, } @@ -1053,24 +832,37 @@ pub struct StylesheetBuilder { impl StylesheetBuilder { #[inline] pub fn new(selector: &str) -> Self { - lazy_static! { - // TODO better static type for this - static ref STYLESHEET: Reference = js!( + // TODO can this be made faster ? + // TODO somehow share this safely between threads ? + thread_local! { + static STYLESHEET: CssStyleSheet = { // TODO use createElementNS ? - var e = document.createElement("style"); - e.type = "text/css"; - document.head.appendChild(e); - return e.sheet; - ).try_into().unwrap(); + let e = document().create_element("style").unwrap_throw(); + // TODO maybe don't use unchecked ? + let e: &HtmlStyleElement = e.unchecked_ref(); + + e.set_type("text/css"); + + document().head().unwrap_throw().append_child(e).unwrap_throw(); + + // TODO maybe don't use unchecked ? + e.sheet().unwrap_throw().unchecked_into() + }; } + let element = STYLESHEET.with(|stylesheet| { + let rules = stylesheet.css_rules().unwrap_throw(); + + let length = rules.length(); + + stylesheet.insert_rule_with_index(&format!("{}{{}}", selector), length).unwrap_throw(); + + // TODO maybe don't use unchecked ? + rules.get(length).unwrap_throw().unchecked_ref::().style() + }); + Self { - element: js!( - var stylesheet = @{&*STYLESHEET}; - var length = stylesheet.cssRules.length; - stylesheet.insertRule(@{selector} + "{}", length); - return stylesheet.cssRules[length]; - ).try_into().unwrap(), + element, callbacks: Callbacks::new(), } } @@ -1098,7 +890,7 @@ impl StylesheetBuilder { D: OptionStr, E: Signal + 'static { - set_style_signal(&self.element, &mut self.callbacks, name, value, false); + set_style_signal(self.element.clone(), &mut self.callbacks, name, value, false); self } @@ -1109,7 +901,7 @@ impl StylesheetBuilder { D: OptionStr, E: Signal + 'static { - set_style_signal(&self.element, &mut self.callbacks, name, value, true); + set_style_signal(self.element.clone(), &mut self.callbacks, name, value, true); self } @@ -1135,13 +927,12 @@ impl ClassBuilder { #[inline] pub fn new() -> Self { let class_name = { - use std::sync::atomic::{AtomicUsize, Ordering}; + use std::sync::atomic::{AtomicU32, Ordering}; // TODO replace this with a global counter in JavaScript ? lazy_static! { // TODO can this be made more efficient ? - // TODO use AtomicU32 instead ? - static ref CLASS_ID: AtomicUsize = AtomicUsize::new(0); + static ref CLASS_ID: AtomicU32 = AtomicU32::new(0); } // TODO check for overflow ? @@ -1210,13 +1001,14 @@ impl ClassBuilder { mod tests { use super::{create_element_ns, DomBuilder, HTML_NAMESPACE, text_signal, RefFn}; use futures_signals::signal::{always, SignalExt}; - use stdweb::web::{HtmlElement, IHtmlElement}; + use lazy_static::lazy_static; + use web_sys::HtmlElement; #[test] fn apply() { let a: DomBuilder = DomBuilder::new(create_element_ns("div", HTML_NAMESPACE)); - fn my_mixin(builder: DomBuilder) -> DomBuilder { + fn my_mixin>(builder: DomBuilder) -> DomBuilder { builder.style("foo", "bar") } diff --git a/src/dom_operations.rs b/src/dom_operations.rs index 36ab6e4..b9d4682 100644 --- a/src/dom_operations.rs +++ b/src/dom_operations.rs @@ -1,174 +1,90 @@ -use std; -use stdweb::unstable::{TryFrom, TryInto}; -use stdweb::{Value, Reference, JsSerialize}; -use stdweb::web::{TextNode, INode, IHtmlElement, IElement}; +use wasm_bindgen::UnwrapThrowExt; +use wasm_bindgen::prelude::wasm_bindgen; +use web_sys::{Node, HtmlElement, Element}; #[inline] -pub(crate) fn create_element_ns(name: &str, namespace: &str) -> A - where >::Error: std::fmt::Debug { - js!( return document.createElementNS(@{namespace}, @{name}); ).try_into().unwrap() +pub(crate) fn get_at(parent: &Node, index: u32) -> Node { + parent.child_nodes().get(index).unwrap_throw() } // TODO make this more efficient #[inline] -pub(crate) fn move_from_to(parent: &A, old_index: u32, new_index: u32) { - js! { @(no_return) - var parent = @{parent.as_ref()}; - // TODO verify that it exists ? - var child = parent.childNodes[@{old_index}]; - parent.removeChild(child); - parent.insertBefore(child, parent.childNodes[@{new_index}]); - } +pub(crate) fn move_from_to(parent: &Node, old_index: u32, new_index: u32) { + let child = get_at(parent, old_index); + + parent.remove_child(&child).unwrap_throw(); + + insert_at(parent, new_index, &child); } // TODO make this more efficient #[inline] -pub(crate) fn insert_at(parent: &A, index: u32, child: &B) { - js! { @(no_return) - var parent = @{parent.as_ref()}; - parent.insertBefore(@{child.as_ref()}, parent.childNodes[@{index}]); - } +pub(crate) fn insert_at(parent: &Node, index: u32, child: &Node) { + parent.insert_before(child, Some(&get_at(parent, index))).unwrap_throw(); } // TODO make this more efficient #[inline] -pub(crate) fn update_at(parent: &A, index: u32, child: &B) { - js! { @(no_return) - var parent = @{parent.as_ref()}; - parent.replaceChild(@{child.as_ref()}, parent.childNodes[@{index}]); - } +pub(crate) fn update_at(parent: &Node, index: u32, child: &Node) { + parent.replace_child(child, &get_at(parent, index)).unwrap_throw(); } // TODO make this more efficient #[inline] -pub(crate) fn remove_at(parent: &A, index: u32) { - js! { @(no_return) - var parent = @{parent.as_ref()}; - parent.removeChild(parent.childNodes[@{index}]); - } -} - -// TODO this should be in stdweb -#[inline] -pub(crate) fn set_text(element: &TextNode, value: &str) { - js! { @(no_return) - // http://jsperf.com/textnode-performance - @{element}.data = @{value}; - } +pub(crate) fn remove_at(parent: &Node, index: u32) { + parent.remove_child(&get_at(parent, index)).unwrap_throw(); } #[inline] -fn get_style>(element: &A, name: &str) -> String { - js!( return @{element.as_ref()}.style.getPropertyValue(@{name}); ).try_into().unwrap() -} +pub(crate) fn set_focused(element: &HtmlElement, focused: bool) { + if focused { + element.focus().unwrap_throw(); -#[inline] -fn set_style_raw>(element: &A, name: &str, value: &str, important: bool) { - js! { @(no_return) - @{element.as_ref()}.style.setProperty(@{name}, @{value}, (@{important} ? "important" : "")); - } -} - -// TODO this should be in stdweb -// TODO maybe use cfg(debug_assertions) ? -pub(crate) fn try_set_style>(element: &A, name: &str, value: &str, important: bool) -> bool { - assert!(value != ""); - - remove_style(element, name); - set_style_raw(element, name, value, important); - - get_style(element, name) != "" -} - -// TODO this should be in stdweb -// TODO handle browser prefixes -#[inline] -pub(crate) fn remove_style>(element: &A, name: &str) { - js! { @(no_return) - @{element.as_ref()}.style.removeProperty(@{name}); - } -} - -// TODO replace with element.focus() and element.blur() -// TODO make element.focus() and element.blur() inline -#[inline] -pub(crate) fn set_focused(element: &A, focused: bool) { - js! { @(no_return) - var element = @{element.as_ref()}; - - if (@{focused}) { - element.focus(); - - } else { - element.blur(); - } + } else { + element.blur().unwrap_throw(); } } #[inline] -pub(crate) fn add_class(element: &A, name: &str) { - js! { @(no_return) - @{element.as_ref()}.classList.add(@{name}); - } +pub(crate) fn add_class(element: &Element, name: &str) { + element.class_list().add_1(name).unwrap_throw(); } #[inline] -pub(crate) fn remove_class(element: &A, name: &str) { - js! { @(no_return) - @{element.as_ref()}.classList.remove(@{name}); - } +pub(crate) fn remove_class(element: &Element, name: &str) { + element.class_list().remove_1(name).unwrap_throw(); } // TODO check that the attribute *actually* was changed #[inline] -pub(crate) fn set_attribute(element: &A, name: &str, value: &str) { - js! { @(no_return) - @{element.as_ref()}.setAttribute(@{name}, @{value}); - } +pub(crate) fn set_attribute(element: &Element, name: &str, value: &str) { + element.set_attribute(name, value).unwrap_throw(); } // TODO check that the attribute *actually* was changed #[inline] -pub(crate) fn set_attribute_ns(element: &A, namespace: &str, name: &str, value: &str) { - js! { @(no_return) - @{element.as_ref()}.setAttributeNS(@{namespace}, @{name}, @{value}); - } +pub(crate) fn set_attribute_ns(element: &Element, namespace: &str, name: &str, value: &str) { + element.set_attribute_ns(Some(namespace), name, value).unwrap_throw(); } #[inline] -pub(crate) fn remove_attribute_ns(element: &A, namespace: &str, name: &str) { - js! { @(no_return) - @{element.as_ref()}.removeAttributeNS(@{namespace}, @{name}); - } +pub(crate) fn remove_attribute_ns(element: &Element, namespace: &str, name: &str) { + element.remove_attribute_ns(Some(namespace), name).unwrap_throw(); } #[inline] -pub(crate) fn remove_attribute(element: &A, name: &str) { - js! { @(no_return) - @{element.as_ref()}.removeAttribute(@{name}); - } +pub(crate) fn remove_attribute(element: &Element, name: &str) { + element.remove_attribute(name).unwrap_throw(); } -// TODO check that the property *actually* was changed ? -// TODO better type checks ? -#[inline] -pub(crate) fn set_property, B: JsSerialize>(obj: &A, name: &str, value: B) { - js! { @(no_return) - @{obj.as_ref()}[@{name}] = @{value}; - } -} - -// TODO make this work on Nodes, not just Elements // TODO is this the most efficient way to remove all children ? -#[inline] -pub(crate) fn remove_all_children(element: &A) { - js! { @(no_return) - @{element.as_ref()}.innerHTML = ""; - } +#[wasm_bindgen(inline_js = "export function remove_all_children(node) { while (node.firstChild != null) { node.removeChild(node.firstChild); } }")] +extern "C" { + pub(crate) fn remove_all_children(node: &Node); } diff --git a/src/events.rs b/src/events.rs new file mode 100644 index 0000000..8c1b564 --- /dev/null +++ b/src/events.rs @@ -0,0 +1,114 @@ +use crate::traits::StaticEvent; +use wasm_bindgen::JsCast; +use web_sys::{EventTarget, HtmlInputElement, HtmlTextAreaElement}; + + +macro_rules! make_event { + ($name:ident, $type:literal => $event:path) => { + pub struct $name { + event: $event, + } + + impl StaticEvent for $name { + const EVENT_TYPE: &'static str = $type; + + #[inline] + fn unchecked_from_event(event: web_sys::Event) -> Self { + Self { + event: event.unchecked_into(), + } + } + } + + impl $name { + #[inline] pub fn prevent_default(&self) { self.event.prevent_default(); } + + #[inline] pub fn target(&self) -> Option { self.event.target() } + + #[inline] + pub fn dyn_target(&self) -> Option where A: JsCast { + self.target()?.dyn_into().ok() + } + } + }; +} + +macro_rules! make_mouse_event { + ($name:ident, $type:literal) => { + make_event!($name, $type => web_sys::MouseEvent); + + impl $name { + #[inline] pub fn x(&self) -> i32 { self.event.client_x() } + #[inline] pub fn y(&self) -> i32 { self.event.client_y() } + + #[inline] pub fn screen_x(&self) -> i32 { self.event.screen_x() } + #[inline] pub fn screen_y(&self) -> i32 { self.event.screen_y() } + } + }; +} + +macro_rules! make_keyboard_event { + ($name:ident, $type:literal) => { + make_event!($name, $type => web_sys::KeyboardEvent); + + impl $name { + // TODO return enum or something + #[inline] pub fn key(&self) -> String { self.event.key() } + } + }; +} + +macro_rules! make_focus_event { + ($name:ident, $type:literal) => { + make_event!($name, $type => web_sys::FocusEvent); + }; +} + + +make_mouse_event!(Click, "click"); +make_mouse_event!(MouseEnter, "mouseenter"); +make_mouse_event!(MouseLeave, "mouseleave"); +make_mouse_event!(DoubleClick, "dblclick"); + +make_keyboard_event!(KeyDown, "keydown"); +make_keyboard_event!(KeyUp, "keyup"); + +make_focus_event!(Focus, "focus"); +make_focus_event!(Blur, "blur"); + + +make_event!(Input, "input" => web_sys::InputEvent); + +impl Input { + // TODO should this work on other types as well ? + pub fn value(&self) -> Option { + let target = self.target()?; + + if let Some(target) = target.dyn_ref::() { + // TODO check the element's type ? + Some(target.value()) + + } else if let Some(target) = target.dyn_ref::() { + Some(target.value()) + + } else { + None + } + } +} + + +make_event!(Change, "change" => web_sys::Event); + +// TODO add in a value method as well, the same as Input::value +impl Change { + // https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement + pub fn checked(&self) -> Option { + let target = self.dyn_target::()?; + + match target.type_().as_str() { + "checkbox" | "radio" => Some(target.checked()), + _ => None, + } + } +} diff --git a/src/lib.rs b/src/lib.rs index 65fa0cd..d20e316 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,24 +2,10 @@ #![warn(unreachable_pub)] #![deny(warnings)] -#[macro_use] -extern crate stdweb; - -#[macro_use] -extern crate stdweb_derive; - -#[macro_use] -extern crate lazy_static; - -extern crate discard; -extern crate futures_channel; -extern crate futures_util; -extern crate futures_signals; -extern crate pin_utils; - #[macro_use] mod macros; +mod utils; mod callbacks; mod operations; mod dom_operations; @@ -29,18 +15,7 @@ pub use dom::*; pub mod traits; pub mod animation; pub mod routing; +pub mod events; -pub use stdweb::web::HtmlElement; - -pub mod events { - pub use stdweb::web::event::*; -} - - -#[cfg(test)] -mod tests { - #[test] - fn it_works() { - assert_eq!(2 + 2, 4); - } -} +pub use web_sys::HtmlElement; +pub use web_sys::SvgElement; diff --git a/src/macros.rs b/src/macros.rs index 8943d21..9a57c2c 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -1,7 +1,7 @@ #[macro_export] macro_rules! builder { ($namespace:expr, $default:ty, $kind:expr => $t:ty) => { - builder!($namespace, $default, $kind => $t, {}) + $crate::builder!($namespace, $default, $kind => $t, {}) }; ($namespace:expr, $default:ty, $kind:expr => $t:ty, { $(.$name:ident($($args:expr),*))* }) => {{ let a: $crate::DomBuilder<$t> = $crate::DomBuilder::new($crate::create_element_ns($kind, $namespace)); @@ -11,10 +11,10 @@ macro_rules! builder { }}; ($namespace:expr, $default:ty, $kind:expr) => { - builder!($namespace, $default, $kind => $default) + $crate::builder!($namespace, $default, $kind => $default) }; ($namespace:expr, $default:ty, $kind:expr, { $(.$name:ident($($args:expr),*))* }) => { - builder!($namespace, $default, $kind => $default, { $(.$name($($args),*))* }) + $crate::builder!($namespace, $default, $kind => $default, { $(.$name($($args),*))* }) }; } @@ -22,7 +22,7 @@ macro_rules! builder { #[macro_export] macro_rules! html { ($($args:tt)+) => { - builder!($crate::HTML_NAMESPACE, $crate::HtmlElement, $($args)+) + $crate::builder!($crate::HTML_NAMESPACE, $crate::HtmlElement, $($args)+) }; } @@ -30,7 +30,7 @@ macro_rules! html { #[macro_export] macro_rules! svg { ($($args:tt)+) => { - builder!($crate::SVG_NAMESPACE, $crate::SvgElement, $($args)+) + $crate::builder!($crate::SVG_NAMESPACE, $crate::SvgElement, $($args)+) }; } @@ -38,7 +38,7 @@ macro_rules! svg { #[macro_export] macro_rules! stylesheet { ($rule:expr) => { - stylesheet!($rule, {}) + $crate::stylesheet!($rule, {}) }; ($rule:expr, { $(.$name:ident($($args:expr),*))* }) => { $crate::StylesheetBuilder::new($rule)$(.$name($($args),*))*.done() @@ -64,12 +64,12 @@ macro_rules! __internal_clone_split { $y }}; (($($x:ident)*), $t:ident, $($after:tt)*) => { - __internal_clone_split!(($($x)* $t), $($after)*) + $crate::__internal_clone_split!(($($x)* $t), $($after)*) }; } -// TODO move into stdweb ? +// TODO move into gloo ? #[macro_export] macro_rules! clone { - ($($input:tt)*) => { __internal_clone_split!((), $($input)*) }; + ($($input:tt)*) => { $crate::__internal_clone_split!((), $($input)*) }; } diff --git a/src/operations.rs b/src/operations.rs index b67976e..d1e02a8 100644 --- a/src/operations.rs +++ b/src/operations.rs @@ -1,17 +1,19 @@ use std::sync::{Arc, Mutex}; -use std::mem::ManuallyDrop; use std::future::Future; +use std::iter::IntoIterator; + use discard::{Discard, DiscardOnDrop}; use futures_util::future::ready; use futures_signals::{cancelable_future, CancelableFutureHandle}; use futures_signals::signal::{Signal, SignalExt}; use futures_signals::signal_vec::{VecDiff, SignalVec, SignalVecExt}; -use dom_operations; -use dom::Dom; -use callbacks::Callbacks; -use std::iter::IntoIterator; -use stdweb::spawn_local; -use stdweb::traits::INode; +use web_sys::Node; +use wasm_bindgen::UnwrapThrowExt; +use wasm_bindgen_futures::futures_0_3::spawn_local; + +use crate::dom_operations; +use crate::dom::Dom; +use crate::callbacks::Callbacks; // TODO this should probably be in stdweb @@ -80,60 +82,18 @@ pub fn insert_children_signal(element: &A, callbacks: &mut Callbacks, s }*/ #[inline] -pub(crate) fn insert_children_iter<'a, A: INode, B: IntoIterator>(element: &A, callbacks: &mut Callbacks, value: B) { +pub(crate) fn insert_children_iter<'a, A: IntoIterator>(element: &Node, callbacks: &mut Callbacks, value: A) { for dom in value.into_iter() { callbacks.after_insert.append(&mut dom.callbacks.after_insert); callbacks.after_remove.append(&mut dom.callbacks.after_remove); - element.append_child(&dom.element); + element.append_child(&dom.element).unwrap_throw(); } } -// TODO move this into the discard crate -// TODO verify that this is correct and doesn't leak memory or cause memory safety -pub(crate) struct ValueDiscard(ManuallyDrop); - -impl ValueDiscard { - #[inline] - pub(crate) fn new(value: A) -> Self { - ValueDiscard(ManuallyDrop::new(value)) - } -} - -impl Discard for ValueDiscard { - #[inline] - fn discard(self) { - // TODO verify that this works - ManuallyDrop::into_inner(self.0); - } -} - - -// TODO move this into the discard crate -// TODO replace this with an impl for FnOnce() ? -pub(crate) struct FnDiscard(A); - -impl FnDiscard where A: FnOnce() { - #[inline] - pub(crate) fn new(f: A) -> Self { - FnDiscard(f) - } -} - -impl Discard for FnDiscard where A: FnOnce() { - #[inline] - fn discard(self) { - self.0(); - } -} - - -pub(crate) fn insert_children_signal_vec(element: &A, callbacks: &mut Callbacks, signal: B) - where A: INode + Clone + 'static, - B: SignalVec + 'static { - - let element = element.clone(); +pub(crate) fn insert_children_signal_vec(element: Node, callbacks: &mut Callbacks, signal: A) + where A: SignalVec + 'static { // TODO does this create a new struct type every time ? struct State { @@ -151,7 +111,7 @@ pub(crate) fn insert_children_signal_vec(element: &A, callbacks: &mut Call let state = state.clone(); callbacks.after_insert(move |_| { - let mut state = state.lock().unwrap(); + let mut state = state.lock().unwrap_throw(); if !state.is_inserted { state.is_inserted = true; @@ -165,7 +125,7 @@ pub(crate) fn insert_children_signal_vec(element: &A, callbacks: &mut Call // TODO verify that this will drop `children` callbacks.after_remove(for_each_vec(signal, move |change| { - let mut state = state.lock().unwrap(); + let mut state = state.lock().unwrap_throw(); match change { VecDiff::Replace { values } => { @@ -186,7 +146,7 @@ pub(crate) fn insert_children_signal_vec(element: &A, callbacks: &mut Call for dom in state.children.iter_mut() { dom.callbacks.leak(); - element.append_child(&dom.element); + element.append_child(&dom.element).unwrap_throw(); if is_inserted { dom.callbacks.trigger_after_insert(); @@ -209,7 +169,7 @@ pub(crate) fn insert_children_signal_vec(element: &A, callbacks: &mut Call }, VecDiff::Push { mut value } => { - element.append_child(&value.element); + element.append_child(&value.element).unwrap_throw(); value.callbacks.leak(); @@ -261,7 +221,7 @@ pub(crate) fn insert_children_signal_vec(element: &A, callbacks: &mut Call // TODO better usize -> u32 conversion dom_operations::remove_at(&element, index as u32); - state.children.pop().unwrap().callbacks.discard(); + state.children.pop().unwrap_throw().callbacks.discard(); }, VecDiff::Clear {} => { diff --git a/src/routing.rs b/src/routing.rs index 9d71423..87704a1 100644 --- a/src/routing.rs +++ b/src/routing.rs @@ -1,9 +1,10 @@ -use dom::{Dom, DomBuilder, Url}; +use wasm_bindgen::{JsValue, UnwrapThrowExt}; +use web_sys::{window, Url, EventTarget, HtmlElement}; use futures_signals::signal::{Mutable, Signal}; -use stdweb::web::{window, HtmlElement, IEventTarget}; -use stdweb::web::event::ClickEvent; -use stdweb::traits::IEvent; -use stdweb::Value; +use gloo::events::EventListener; + +use crate::dom::{Dom, DomBuilder}; +use crate::events; /*pub struct State { @@ -14,7 +15,7 @@ use stdweb::Value; impl State { pub fn new() -> Self { // TODO replace with stdweb function - let value = Mutable::new(js!( return history.state; ).try_into().unwrap()); + let value = Mutable::new(js!( return history.state; ).try_into().unwrap_throw()); let callback = |state: Option| { value.set(state); @@ -35,14 +36,14 @@ impl State { } pub fn set(&self, value: A) { - window().history().replace_state(value, "", None).unwrap(); + window().history().replace_state(value, "", None).unwrap_throw(); self.value.set(value); } }*/ fn current_url_string() -> String { - window().location().unwrap().href().unwrap() + window().unwrap_throw().location().href().unwrap_throw() } // TODO inline ? @@ -55,88 +56,74 @@ fn change_url(mutable: &Mutable) { // TODO helper method for this // TODO can this be made more efficient ? if lock.href() != new_url { - *lock = Url::new(&new_url); + *lock = Url::new(&new_url).unwrap_throw(); } } struct CurrentUrl { value: Mutable, - listener: Value, + _listener: EventListener, } impl CurrentUrl { - #[inline] fn new() -> Self { - let value = Mutable::new(Url::new(¤t_url_string())); - - let callback = { - let value = value.clone(); - move || { - change_url(&value); - } - }; + // TODO can this be made more efficient ? + let value = Mutable::new(Url::new(¤t_url_string()).unwrap_throw()); Self { - value, - listener: js!( - function listener(e) { - @{callback}(); + _listener: EventListener::new(&window().unwrap_throw(), "popstate", { + let value = value.clone(); + move |_| { + change_url(&value); } - - addEventListener("popstate", listener, true); - - return listener; - ), + }), + value, } } } -impl Drop for CurrentUrl { - fn drop(&mut self) { - js! { @(no_return) - removeEventListener("popstate", @{&self.listener}, true); - } - } -} - -// TODO use thread_local instead ? -lazy_static! { - static ref URL: CurrentUrl = CurrentUrl::new(); +// TODO somehow share this safely between threads ? +thread_local! { + static URL: CurrentUrl = CurrentUrl::new(); } #[inline] pub fn current_url() -> Url { - URL.value.get_cloned() + URL.with(|url| url.value.get_cloned()) } #[inline] pub fn url() -> impl Signal { - URL.value.signal_cloned() + URL.with(|url| url.value.signal_cloned()) } // TODO if URL hasn't been created yet, don't create it #[inline] pub fn go_to_url(new_url: &str) { - // TODO replace with stdweb function - js! { @(no_return) + window() + .unwrap_throw() + .history() + .unwrap_throw() // TODO is this the best state object to use ? - history.pushState(null, "", @{new_url}); - } + .push_state_with_url(&JsValue::NULL, "", Some(new_url)) + .unwrap_throw(); - change_url(&URL.value); + URL.with(|url| { + change_url(&url.value); + }); } -// TODO somehow use &str rather than String +// TODO somehow use &str rather than String, maybe Cow ? #[inline] -pub fn on_click_go_to_url(new_url: String) -> impl FnOnce(DomBuilder) -> DomBuilder where A: IEventTarget + Clone + 'static { +pub fn on_click_go_to_url(new_url: String) -> impl FnOnce(DomBuilder) -> DomBuilder where A: AsRef { #[inline] move |dom| { - dom.event(move |e: ClickEvent| { + dom.event_preventable(move |e: events::Click| { e.prevent_default(); go_to_url(&new_url); }) @@ -144,6 +131,7 @@ pub fn on_click_go_to_url(new_url: String) -> impl FnOnce(DomBuilder) -> D } +// TODO better type than HtmlElement #[inline] pub fn link(url: &str, f: F) -> Dom where F: FnOnce(DomBuilder) -> DomBuilder { html!("a", { diff --git a/src/traits.rs b/src/traits.rs index 4348bd1..f12cc06 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -1,6 +1,13 @@ -use dom::RefFn; +use crate::dom::RefFn; -pub use animation::AnimatedSignalVec; +pub use crate::animation::AnimatedSignalVec; + + +pub trait StaticEvent { + const EVENT_TYPE: &'static str; + + fn unchecked_from_event(event: web_sys::Event) -> Self; +} #[deprecated(since = "0.3.2", note = "Use the apply or apply_if methods instead")] diff --git a/src/utils.rs b/src/utils.rs new file mode 100644 index 0000000..01ed016 --- /dev/null +++ b/src/utils.rs @@ -0,0 +1,95 @@ +use std::mem::ManuallyDrop; +use discard::Discard; +use wasm_bindgen::UnwrapThrowExt; +use web_sys::{window, Document, EventTarget}; +use gloo::events::{EventListener, EventListenerOptions}; +use crate::traits::StaticEvent; + + +pub(crate) fn on(element: &EventTarget, mut callback: F) -> EventListener + where E: StaticEvent, + F: FnMut(E) + 'static { + EventListener::new(element, E::EVENT_TYPE, move |e| { + callback(E::unchecked_from_event(e.clone())); + }) +} + +pub(crate) fn on_with_options(element: &EventTarget, options: EventListenerOptions, mut callback: F) -> EventListener + where E: StaticEvent, + F: FnMut(E) + 'static { + EventListener::new_with_options(element, E::EVENT_TYPE, options, move |e| { + callback(E::unchecked_from_event(e.clone())); + }) +} + + +pub(crate) fn document() -> Document { + window().unwrap_throw().document().unwrap_throw() +} + + +// TODO move this into the discard crate +// TODO verify that this is correct and doesn't leak memory or cause memory safety +pub(crate) struct ValueDiscard(ManuallyDrop); + +impl ValueDiscard { + #[inline] + pub(crate) fn new(value: A) -> Self { + ValueDiscard(ManuallyDrop::new(value)) + } +} + +impl Discard for ValueDiscard { + #[inline] + fn discard(self) { + // TODO verify that this works + ManuallyDrop::into_inner(self.0); + } +} + + +// TODO move this into the discard crate +// TODO replace this with an impl for FnOnce() ? +pub(crate) struct FnDiscard(A); + +impl FnDiscard where A: FnOnce() { + #[inline] + pub(crate) fn new(f: A) -> Self { + FnDiscard(f) + } +} + +impl Discard for FnDiscard where A: FnOnce() { + #[inline] + fn discard(self) { + self.0(); + } +} + + +// TODO is this worth using ? +pub(crate) struct EventDiscard(Option); + +impl EventDiscard { + #[inline] + pub(crate) fn new(listener: EventListener) -> Self { + EventDiscard(Some(listener)) + } +} + +impl Drop for EventDiscard { + #[inline] + fn drop(&mut self) { + // TODO does this cleanup as much memory as possible ? + if let Some(listener) = self.0.take() { + listener.forget(); + } + } +} + +impl Discard for EventDiscard { + #[inline] + fn discard(mut self) { + self.0.take(); + } +}