Minor tweaks

This commit is contained in:
Pauan 2019-06-15 11:23:38 +02:00
parent 8e276c3572
commit a7904e27c8
12 changed files with 45 additions and 19 deletions

View File

@ -21,7 +21,7 @@ futures-signals = "0.3.5"
wasm-bindgen = "0.2.45" wasm-bindgen = "0.2.45"
js-sys = "0.3.22" js-sys = "0.3.22"
# TODO fix this before release # TODO fix this before release
gloo = { git = "https://github.com/rustwasm/gloo" } gloo = { git = "https://github.com/rustwasm/gloo", commit = "e8e505fbdbe96164381bd6fe7ef350438d54a84f" }
[dependencies.wasm-bindgen-futures] [dependencies.wasm-bindgen-futures]
version = "0.3.22" version = "0.3.22"

View File

@ -4,7 +4,7 @@
"version": "0.1.0", "version": "0.1.0",
"scripts": { "scripts": {
"build": "rimraf dist pkg && webpack", "build": "rimraf dist pkg && webpack",
"start": "rimraf dist pkg && webpack-dev-server --open -d" "start": "rimraf dist pkg && webpack-dev-server -d"
}, },
"devDependencies": { "devDependencies": {
"@wasm-tool/wasm-pack-plugin": "^0.4.2", "@wasm-tool/wasm-pack-plugin": "^0.4.2",

View File

@ -6,6 +6,7 @@ const dist = path.resolve(__dirname, "dist");
module.exports = { module.exports = {
mode: "production", mode: "production",
stats: "errors-warnings",
entry: { entry: {
index: "./js/index.js" index: "./js/index.js"
}, },
@ -14,7 +15,13 @@ module.exports = {
filename: "[name].js" filename: "[name].js"
}, },
devServer: { devServer: {
contentBase: dist, liveReload: true,
open: true,
noInfo: true,
overlay: {
warnings: true,
errors: true
}
}, },
plugins: [ plugins: [
new CopyPlugin([ new CopyPlugin([
@ -22,8 +29,7 @@ module.exports = {
]), ]),
new WasmPackPlugin({ new WasmPackPlugin({
crateDirectory: __dirname, crateDirectory: __dirname
extraArgs: "--out-name index" })
}),
] ]
}; };

View File

@ -4,7 +4,7 @@
"version": "0.1.0", "version": "0.1.0",
"scripts": { "scripts": {
"build": "rimraf dist pkg && webpack", "build": "rimraf dist pkg && webpack",
"start": "rimraf dist pkg && webpack-dev-server --open -d" "start": "rimraf dist pkg && webpack-dev-server -d"
}, },
"devDependencies": { "devDependencies": {
"@wasm-tool/wasm-pack-plugin": "^0.4.2", "@wasm-tool/wasm-pack-plugin": "^0.4.2",

View File

@ -6,6 +6,7 @@ const dist = path.resolve(__dirname, "dist");
module.exports = { module.exports = {
mode: "production", mode: "production",
stats: "errors-warnings",
entry: { entry: {
index: "./js/index.js" index: "./js/index.js"
}, },
@ -14,7 +15,13 @@ module.exports = {
filename: "[name].js" filename: "[name].js"
}, },
devServer: { devServer: {
contentBase: dist, liveReload: true,
open: true,
noInfo: true,
overlay: {
warnings: true,
errors: true
}
}, },
plugins: [ plugins: [
new CopyPlugin([ new CopyPlugin([
@ -22,8 +29,7 @@ module.exports = {
]), ]),
new WasmPackPlugin({ new WasmPackPlugin({
crateDirectory: __dirname, crateDirectory: __dirname
extraArgs: "--out-name index" })
}),
] ]
}; };

View File

@ -4,7 +4,7 @@
"version": "0.1.0", "version": "0.1.0",
"scripts": { "scripts": {
"build": "rimraf dist pkg && webpack", "build": "rimraf dist pkg && webpack",
"start": "rimraf dist pkg && webpack-dev-server --open -d" "start": "rimraf dist pkg && webpack-dev-server -d"
}, },
"devDependencies": { "devDependencies": {
"@wasm-tool/wasm-pack-plugin": "^0.4.2", "@wasm-tool/wasm-pack-plugin": "^0.4.2",

View File

@ -292,7 +292,10 @@ pub fn main_js() -> Result<(), JsValue> {
.event(clone!(todo => move |event: events::KeyDown| { .event(clone!(todo => move |event: events::KeyDown| {
match event.key().as_str() { match event.key().as_str() {
"Enter" => { "Enter" => {
event.dyn_target::<HtmlElement>().unwrap_throw().blur(); event.dyn_target::<HtmlElement>()
.unwrap_throw()
.blur()
.unwrap_throw();
}, },
"Escape" => { "Escape" => {
todo.editing.set_neq(None); todo.editing.set_neq(None);

View File

@ -6,6 +6,7 @@ const dist = path.resolve(__dirname, "dist");
module.exports = { module.exports = {
mode: "production", mode: "production",
stats: "errors-warnings",
entry: { entry: {
index: "./js/index.js" index: "./js/index.js"
}, },
@ -14,7 +15,13 @@ module.exports = {
filename: "[name].js" filename: "[name].js"
}, },
devServer: { devServer: {
contentBase: dist, liveReload: true,
open: true,
noInfo: true,
overlay: {
warnings: true,
errors: true
}
}, },
plugins: [ plugins: [
new CopyPlugin([ new CopyPlugin([
@ -22,8 +29,7 @@ module.exports = {
]), ]),
new WasmPackPlugin({ new WasmPackPlugin({
crateDirectory: __dirname, crateDirectory: __dirname
extraArgs: "--out-name index" })
}),
] ]
}; };

View File

@ -100,6 +100,7 @@ struct TimestampsState {
waker: Option<Waker>, waker: Option<Waker>,
} }
// TODO must_use ?
#[derive(Debug)] #[derive(Debug)]
pub struct Timestamps { pub struct Timestamps {
state: Arc<Mutex<TimestampsState>>, state: Arc<Mutex<TimestampsState>>,

View File

@ -124,6 +124,7 @@ pub fn append_dom(parent: &Node, mut dom: Dom) -> DomHandle {
} }
// TODO use must_use ?
enum IsWindowLoaded { enum IsWindowLoaded {
Initial {}, Initial {},
Pending { Pending {
@ -214,6 +215,8 @@ pub fn text_signal<A, B>(value: B) -> Dom
} }
// TODO better warning message for must_use
#[must_use]
#[derive(Debug)] #[derive(Debug)]
pub struct Dom { pub struct Dom {
pub(crate) element: Node, pub(crate) element: Node,
@ -232,7 +235,6 @@ impl Dom {
#[inline] #[inline]
pub fn empty() -> Self { pub fn empty() -> Self {
// TODO is there a better way of doing this ? // TODO is there a better way of doing this ?
// TODO is it legal to append children to a comment node ?
Self::new(document().create_comment("").into()) Self::new(document().create_comment("").into())
} }
@ -351,6 +353,8 @@ fn set_property<A, B, C>(element: &A, name: &B, value: C) where A: AsRef<JsValue
} }
// TODO better warning message for must_use
#[must_use]
pub struct DomBuilder<A> { pub struct DomBuilder<A> {
element: A, element: A,
callbacks: Callbacks, callbacks: Callbacks,

View File

@ -16,7 +16,6 @@ use crate::dom::Dom;
use crate::callbacks::Callbacks; use crate::callbacks::Callbacks;
// TODO this should probably be in stdweb
#[inline] #[inline]
pub(crate) fn spawn_future<F>(future: F) -> DiscardOnDrop<CancelableFutureHandle> pub(crate) fn spawn_future<F>(future: F) -> DiscardOnDrop<CancelableFutureHandle>
where F: Future<Output = ()> + 'static { where F: Future<Output = ()> + 'static {

View File

@ -67,6 +67,7 @@ impl<A> Discard for FnDiscard<A> where A: FnOnce() {
} }
// TODO verify that this doesn't leak events / memory
// TODO is this worth using ? // TODO is this worth using ?
pub(crate) struct EventDiscard(Option<EventListener>); pub(crate) struct EventDiscard(Option<EventListener>);