Skip to content

Commit

Permalink
fix: readme
Browse files Browse the repository at this point in the history
  • Loading branch information
qinluhe committed Mar 29, 2024
1 parent aa30233 commit a57f68a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 57 deletions.
1 change: 1 addition & 0 deletions libs/client-api-for-wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ crate-type = ["cdylib", "rlib"]
[features]
default = []


[dependencies]
wasm-bindgen = "0.2.84"

Expand Down
76 changes: 24 additions & 52 deletions libs/client-api-for-wasm/README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,24 @@
<div align="center">

<h1><code>wasm-pack-template</code></h1>
<h1><code>Client API WASM</code></h1>

<strong>A template for kick starting a Rust and WebAssembly project using <a href="https://github.com/rustwasm/wasm-pack">wasm-pack</a>.</strong>
<strong>Client-API to WebAssembly Compiler</strong>

<p>
<a href="https://travis-ci.org/rustwasm/wasm-pack-template"><img src="https://img.shields.io/travis/rustwasm/wasm-pack-template.svg?style=flat-square" alt="Build Status" /></a>
</p>

<h3>
<a href="https://rustwasm.github.io/docs/wasm-pack/tutorials/npm-browser-packages/index.html">Tutorial</a>
<span> | </span>
<a href="https://discordapp.com/channels/442252698964721669/443151097398296587">Chat</a>
</h3>

<sub>Built with 🦀🕸 by <a href="https://rustwasm.github.io/">The Rust and WebAssembly Working Group</a></sub>
</div>

## 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`
Expand All @@ -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.
5 changes: 0 additions & 5 deletions libs/client-api-for-wasm/src/logger.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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);
}

0 comments on commit a57f68a

Please sign in to comment.