diff --git a/examples/function_router/Cargo.toml b/examples/function_router/Cargo.toml index 40b64b3b1..d2b7cf4dd 100644 --- a/examples/function_router/Cargo.toml +++ b/examples/function_router/Cargo.toml @@ -11,10 +11,10 @@ rand = { version = "0.8", features = ["small_rng"] } yew = { path = "../../packages/yew" } yew-router = { path = "../../packages/yew-router" } serde = { version = "1.0", features = ["derive"] } -lazy_static = "1.4.0" gloo-timers = "0.2" wasm-logger = "0.2" instant = { version = "0.1", features = ["wasm-bindgen"] } +once_cell = "1" [target.'cfg(target_arch = "wasm32")'.dependencies] getrandom = { version = "0.2", features = ["js"] } diff --git a/examples/function_router/src/generator.rs b/examples/function_router/src/generator.rs index 0ae69df07..15df04eb2 100644 --- a/examples/function_router/src/generator.rs +++ b/examples/function_router/src/generator.rs @@ -1,5 +1,5 @@ -use lazy_static::lazy_static; use lipsum::MarkovChain; +use once_cell::sync::Lazy; use rand::distributions::Bernoulli; use rand::rngs::StdRng; use rand::seq::IteratorRandom; @@ -9,13 +9,11 @@ const KEYWORDS: &str = include_str!("../data/keywords.txt"); const SYLLABLES: &str = include_str!("../data/syllables.txt"); const YEW_CONTENT: &str = include_str!("../data/yew.txt"); -lazy_static! { - static ref YEW_CHAIN: MarkovChain<'static> = { - let mut chain = MarkovChain::new(); - chain.learn(YEW_CONTENT); - chain - }; -} +static YEW_CHAIN: Lazy> = Lazy::new(|| { + let mut chain = MarkovChain::new(); + chain.learn(YEW_CONTENT); + chain +}); pub struct Generator { pub seed: u32, diff --git a/examples/router/Cargo.toml b/examples/router/Cargo.toml index c9fe6c4a6..54bba23c2 100644 --- a/examples/router/Cargo.toml +++ b/examples/router/Cargo.toml @@ -14,5 +14,5 @@ wasm-logger = "0.2" yew = { path = "../../packages/yew", features = ["csr"] } yew-router = { path = "../../packages/yew-router" } serde = { version = "1.0", features = ["derive"] } -lazy_static = "1.4.0" +once_cell = "1" gloo-timers = "0.2" diff --git a/examples/router/src/generator.rs b/examples/router/src/generator.rs index d71f51eab..d87061b35 100644 --- a/examples/router/src/generator.rs +++ b/examples/router/src/generator.rs @@ -1,5 +1,5 @@ -use lazy_static::lazy_static; use lipsum::MarkovChain; +use once_cell::sync::Lazy; use rand::distributions::Bernoulli; use rand::rngs::SmallRng; use rand::seq::IteratorRandom; @@ -9,13 +9,11 @@ const KEYWORDS: &str = include_str!("../data/keywords.txt"); const SYLLABLES: &str = include_str!("../data/syllables.txt"); const YEW_CONTENT: &str = include_str!("../data/yew.txt"); -lazy_static! { - static ref YEW_CHAIN: MarkovChain<'static> = { - let mut chain = MarkovChain::new(); - chain.learn(YEW_CONTENT); - chain - }; -} +static YEW_CHAIN: Lazy> = Lazy::new(|| { + let mut chain = MarkovChain::new(); + chain.learn(YEW_CONTENT); + chain +}); pub struct Generator { pub seed: u64, diff --git a/packages/yew-macro/Cargo.toml b/packages/yew-macro/Cargo.toml index 5cd5679ad..837db1210 100644 --- a/packages/yew-macro/Cargo.toml +++ b/packages/yew-macro/Cargo.toml @@ -17,7 +17,6 @@ proc-macro = true [dependencies] boolinator = "2" -lazy_static = "1" proc-macro-error = "1" proc-macro2 = "1" quote = "1" diff --git a/packages/yew-macro/src/props/element.rs b/packages/yew-macro/src/props/element.rs index 37e71c237..f80af1c2a 100644 --- a/packages/yew-macro/src/props/element.rs +++ b/packages/yew-macro/src/props/element.rs @@ -1,6 +1,6 @@ use std::collections::HashSet; -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use syn::parse::{Parse, ParseStream}; use syn::{Expr, ExprTuple}; @@ -64,154 +64,146 @@ impl Parse for ElementProps { } } -lazy_static! { - static ref BOOLEAN_SET: HashSet<&'static str> = { - vec![ - // Living Standard - // From: https://html.spec.whatwg.org/#attributes-3 - // where `Value` = Boolean attribute - // Note: `checked` is uniquely handled in the html! macro. - "allowfullscreen", - "async", - "autofocus", - "autoplay", - "controls", - "default", - "defer", - "disabled", - "formnovalidate", - "hidden", - "ismap", - "itemscope", - "loop", - "multiple", - "muted", - "nomodule", - "novalidate", - "open", - "playsinline", - "readonly", - "required", - "reversed", - "selected", - "truespeed", - ] - .into_iter() - .collect() - }; -} +static BOOLEAN_SET: Lazy> = Lazy::new(|| { + [ + // Living Standard + // From: https://html.spec.whatwg.org/#attributes-3 + // where `Value` = Boolean attribute + // Note: `checked` is uniquely handled in the html! macro. + "allowfullscreen", + "async", + "autofocus", + "autoplay", + "controls", + "default", + "defer", + "disabled", + "formnovalidate", + "hidden", + "ismap", + "itemscope", + "loop", + "multiple", + "muted", + "nomodule", + "novalidate", + "open", + "playsinline", + "readonly", + "required", + "reversed", + "selected", + "truespeed", + ] + .into() +}); -lazy_static! { - static ref LISTENER_SET: HashSet<&'static str> = { - vec![ - // Living Standard - // From: https://html.spec.whatwg.org/multipage/webappapis.html#globaleventhandlers - "onabort", - "onauxclick", - "onblur", - "oncancel", - "oncanplay", - "oncanplaythrough", - "onchange", - "onclick", - "onclose", - "oncontextmenu", - "oncuechange", - "ondblclick", - "ondrag", - "ondragend", - "ondragenter", - "ondragexit", - "ondragleave", - "ondragover", - "ondragstart", - "ondrop", - "ondurationchange", - "onemptied", - "onended", - "onerror", - "onfocus", - // onfocusin + onfocusout not in standard but added due to browser support - // see issue 1896: https://github.com/yewstack/yew/issues/1896 - "onfocusin", - "onfocusout", - "onformdata", - "oninput", - "oninvalid", - "onkeydown", - "onkeypress", - "onkeyup", - "onload", - "onloadeddata", - "onloadedmetadata", - "onloadstart", - "onmousedown", - "onmouseenter", - "onmouseleave", - "onmousemove", - "onmouseout", - "onmouseover", - "onmouseup", - "onpause", - "onplay", - "onplaying", - "onprogress", - "onratechange", - "onreset", - "onresize", - "onscroll", - "onsecuritypolicyviolation", - "onseeked", - "onseeking", - "onselect", - "onslotchange", - "onstalled", - "onsubmit", - "onsuspend", - "ontimeupdate", - "ontoggle", - "onvolumechange", - "onwaiting", - "onwheel", - - // Standard HTML Document and Element - // From: https://html.spec.whatwg.org/multipage/webappapis.html#documentandelementeventhandlers - "oncopy", - "oncut", - "onpaste", - - // Others - // From: https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers - "onanimationcancel", - "onanimationend", - "onanimationiteration", - "onanimationstart", - "ongotpointercapture", - "onloadend", - "onlostpointercapture", - "onpointercancel", - "onpointerdown", - "onpointerenter", - "onpointerleave", - "onpointerlockchange", - "onpointerlockerror", - "onpointermove", - "onpointerout", - "onpointerover", - "onpointerup", - "onselectionchange", - "onselectstart", - "onshow", - "ontouchcancel", - "ontouchend", - "ontouchmove", - "ontouchstart", - "ontransitioncancel", - "ontransitionend", - "ontransitionrun", - "ontransitionstart", - ] - .into_iter() - .collect() - }; -} +static LISTENER_SET: Lazy> = Lazy::new(|| { + [ + // Living Standard + // From: https://html.spec.whatwg.org/multipage/webappapis.html#globaleventhandlers + "onabort", + "onauxclick", + "onblur", + "oncancel", + "oncanplay", + "oncanplaythrough", + "onchange", + "onclick", + "onclose", + "oncontextmenu", + "oncuechange", + "ondblclick", + "ondrag", + "ondragend", + "ondragenter", + "ondragexit", + "ondragleave", + "ondragover", + "ondragstart", + "ondrop", + "ondurationchange", + "onemptied", + "onended", + "onerror", + "onfocus", + // onfocusin + onfocusout not in standard but added due to browser support + // see issue 1896: https://github.com/yewstack/yew/issues/1896 + "onfocusin", + "onfocusout", + "onformdata", + "oninput", + "oninvalid", + "onkeydown", + "onkeypress", + "onkeyup", + "onload", + "onloadeddata", + "onloadedmetadata", + "onloadstart", + "onmousedown", + "onmouseenter", + "onmouseleave", + "onmousemove", + "onmouseout", + "onmouseover", + "onmouseup", + "onpause", + "onplay", + "onplaying", + "onprogress", + "onratechange", + "onreset", + "onresize", + "onscroll", + "onsecuritypolicyviolation", + "onseeked", + "onseeking", + "onselect", + "onslotchange", + "onstalled", + "onsubmit", + "onsuspend", + "ontimeupdate", + "ontoggle", + "onvolumechange", + "onwaiting", + "onwheel", + // Standard HTML Document and Element + // From: https://html.spec.whatwg.org/multipage/webappapis.html#documentandelementeventhandlers + "oncopy", + "oncut", + "onpaste", + // Others + // From: https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers + "onanimationcancel", + "onanimationend", + "onanimationiteration", + "onanimationstart", + "ongotpointercapture", + "onloadend", + "onlostpointercapture", + "onpointercancel", + "onpointerdown", + "onpointerenter", + "onpointerleave", + "onpointerlockchange", + "onpointerlockerror", + "onpointermove", + "onpointerout", + "onpointerover", + "onpointerup", + "onselectionchange", + "onselectstart", + "onshow", + "ontouchcancel", + "ontouchend", + "ontouchmove", + "ontouchstart", + "ontransitioncancel", + "ontransitionend", + "ontransitionrun", + "ontransitionstart", + ] + .into() +}); diff --git a/tools/changelog/Cargo.toml b/tools/changelog/Cargo.toml index e114ad5fe..56a6ae172 100644 --- a/tools/changelog/Cargo.toml +++ b/tools/changelog/Cargo.toml @@ -13,7 +13,7 @@ git2 = "=0.14.2" # see https://github.com/rust-lang/git2-rs/issues/838 fixed wit regex = "1" reqwest = { version = "0.11", features = ["blocking", "json"] } serde = { version = "1", features = ["derive"] } -structopt = "0.3" strum = { version = "0.24", features = ["derive"] } -lazy_static = "1.4.0" +clap = { version = "3", features = ["derive"] } semver = "1.0" +once_cell = "1" diff --git a/tools/changelog/src/cli.rs b/tools/changelog/src/cli.rs index 6e0de33fe..5eaf66c14 100644 --- a/tools/changelog/src/cli.rs +++ b/tools/changelog/src/cli.rs @@ -1,6 +1,6 @@ use anyhow::{bail, Result}; +use clap::Parser; use semver::Version; -use structopt::StructOpt; use crate::create_log_lines::create_log_lines; use crate::get_latest_version::get_latest_version; @@ -11,7 +11,7 @@ use crate::write_log_lines::write_log_lines; use crate::write_version_changelog::write_changelog_file; use crate::yew_package::YewPackage; -#[derive(StructOpt)] +#[derive(Parser)] pub struct Cli { /// package to generate changelog for pub package: YewPackage, @@ -23,23 +23,23 @@ pub struct Cli { pub from: Option, /// To commit. (ex. commit hash or for tags "refs/tags/yew-v0.19.3") - #[structopt(short = "r", long, default_value = "HEAD")] + #[clap(short = 'r', long, default_value = "HEAD")] pub to: String, /// Path to changelog file - #[structopt(short = "f", long, default_value = "CHANGELOG.md")] + #[clap(short = 'f', long, default_value = "CHANGELOG.md")] pub changelog_path: String, /// Skip writing changelog file - #[structopt(short, long)] + #[clap(short, long)] pub skip_file_write: bool, /// Skip getting the next version - #[structopt(short = "b", long)] + #[clap(short = 'b', long)] pub skip_get_bump_version: bool, /// Github token - #[structopt(short = "t", long)] + #[clap(short = 't', long)] pub token: Option, } diff --git a/tools/changelog/src/create_log_line.rs b/tools/changelog/src/create_log_line.rs index 93c53a724..28a06bf11 100644 --- a/tools/changelog/src/create_log_line.rs +++ b/tools/changelog/src/create_log_line.rs @@ -2,19 +2,18 @@ use std::sync::Mutex; use anyhow::{anyhow, Context, Result}; use git2::{Error, Oid, Repository}; -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use regex::Regex; use crate::github_issue_labels_fetcher::GitHubIssueLabelsFetcher; use crate::github_user_fetcher::GitHubUsersFetcher; use crate::log_line::LogLine; -lazy_static! { - static ref REGEX_FOR_ISSUE_ID_CAPTURE: Regex = Regex::new(r"\s*\(#(\d+)\)").unwrap(); - static ref GITHUB_USERS_FETCHER: Mutex = Default::default(); - static ref GITHUB_ISSUE_LABELS_FETCHER: Mutex = Default::default(); - static ref PACKAGE_LABELS: Vec = vec![]; -} +static REGEX_FOR_ISSUE_ID_CAPTURE: Lazy = + Lazy::new(|| Regex::new(r"\s*\(#(\d+)\)").unwrap()); +static GITHUB_USERS_FETCHER: Lazy> = Lazy::new(Default::default); +static GITHUB_ISSUE_LABELS_FETCHER: Lazy> = + Lazy::new(Default::default); pub fn create_log_line( repo: &Repository, diff --git a/tools/changelog/src/main.rs b/tools/changelog/src/main.rs index 377d95f3c..5d50d7180 100644 --- a/tools/changelog/src/main.rs +++ b/tools/changelog/src/main.rs @@ -1,7 +1,7 @@ use anyhow::Result; use changelog::Cli; -use structopt::StructOpt; +use clap::Parser; fn main() -> Result<()> { - Cli::from_args().run() + Cli::parse().run() }