From a57f68abe8696e74aa0f0943f5830c6dc6027bd0 Mon Sep 17 00:00:00 2001 From: Kilu Date: Fri, 29 Mar 2024 16:39:20 +0800 Subject: [PATCH] fix: readme --- libs/client-api-for-wasm/Cargo.toml | 1 + libs/client-api-for-wasm/README.md | 76 ++++++++------------------ libs/client-api-for-wasm/src/logger.rs | 5 -- 3 files changed, 25 insertions(+), 57 deletions(-) diff --git a/libs/client-api-for-wasm/Cargo.toml b/libs/client-api-for-wasm/Cargo.toml index 1a57bb6c4..ec4dc982f 100644 --- a/libs/client-api-for-wasm/Cargo.toml +++ b/libs/client-api-for-wasm/Cargo.toml @@ -11,6 +11,7 @@ crate-type = ["cdylib", "rlib"] [features] default = [] + [dependencies] wasm-bindgen = "0.2.84" diff --git a/libs/client-api-for-wasm/README.md b/libs/client-api-for-wasm/README.md index 6b6840850..863ac2bf2 100644 --- a/libs/client-api-for-wasm/README.md +++ b/libs/client-api-for-wasm/README.md @@ -1,44 +1,24 @@
-

wasm-pack-template

+

Client API WASM

- A template for kick starting a Rust and WebAssembly project using wasm-pack. + Client-API to WebAssembly Compiler -

- Build Status -

- -

- Tutorial - | - Chat -

- - Built with 🦀🕸 by The Rust and WebAssembly Working Group
-## About - -[**📚 Read this template tutorial! 📚**][template-docs] - -This template is designed for compiling Rust libraries into WebAssembly and -publishing the resulting package to NPM. - -Be sure to check out [other `wasm-pack` tutorials online][tutorials] for other -templates and usages of `wasm-pack`. - -[tutorials]: https://rustwasm.github.io/docs/wasm-pack/tutorials/index.html -[template-docs]: https://rustwasm.github.io/docs/wasm-pack/tutorials/npm-browser-packages/index.html - ## 🚴 Usage -### 🐑 Use `cargo generate` to Clone this Template +### 🐑 Prepare -[Learn more about `cargo generate` here.](https://github.com/ashleygwilliams/cargo-generate) +```bash +# Clone the repository (if you haven't already) +git clone https://github.com/AppFlowy-IO/AppFlowy-Cloud.git -``` -cargo generate --git https://github.com/rustwasm/wasm-pack-template.git --name my-project -cd my-project +# Navigate to the client-api-for-wasm directory +cd libs/client-api-for-wasm + +# Install the dependencies (if you haven't already) +cargo install wasm-pack ``` ### 🛠️ Build with `wasm-pack build` @@ -51,34 +31,26 @@ wasm-pack build ``` wasm-pack test --headless --firefox -``` -### 🎁 Publish to NPM with `wasm-pack publish` +or -``` -wasm-pack publish +wasm-pack test --headless --chrome ``` -## 🔋 Batteries Included +### 🎁 Publish to NPM with ~~`wasm-pack publish`~~ -* [`wasm-bindgen`](https://github.com/rustwasm/wasm-bindgen) for communicating - between WebAssembly and JavaScript. -* [`console_error_panic_hook`](https://github.com/rustwasm/console_error_panic_hook) - for logging panic messages to the developer console. -* `LICENSE-APACHE` and `LICENSE-MIT`: most Rust projects are licensed this way, so these are included for you +##### Don't publish in local development, only publish in github actions -## License - -Licensed under either of +``` +wasm-pack publish +``` -* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) -* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) +### 📦 Use your package as a dependency -at your option. +``` +npm install --save @appflowy/client-api-for-wasm +``` -### Contribution +### 📝 How to use the package in development? -Unless you explicitly state otherwise, any contribution intentionally -submitted for inclusion in the work by you, as defined in the Apache-2.0 -license, shall be dual licensed as above, without any additional terms or -conditions. +See the [README.md](https://github.com/AppFlowy-IO/AppFlowy/tree/main/frontend/appflowy_web_app/README.md) in the AppFlowy Repository. diff --git a/libs/client-api-for-wasm/src/logger.rs b/libs/client-api-for-wasm/src/logger.rs index 486594294..b926e6d6c 100644 --- a/libs/client-api-for-wasm/src/logger.rs +++ b/libs/client-api-for-wasm/src/logger.rs @@ -1,9 +1,5 @@ use crate::wasm_trace; -pub fn set_panic_hook() { - #[cfg(debug_assertions)] - console_error_panic_hook::set_once(); -} pub struct WASMLogger; @@ -31,7 +27,6 @@ impl Default for WASMLogger { static WASM_LOGGER: WASMLogger = WASMLogger; pub fn init_logger() { - set_panic_hook(); log::set_logger(&WASM_LOGGER).unwrap(); log::set_max_level(log::LevelFilter::Debug); }