Skip to content

Commit

Permalink
chore: client api wasm (#262)
Browse files Browse the repository at this point in the history
* feat: client_api wasm

* ci: client_api wasm ci

* ci: client_api wasm ci
  • Loading branch information
appflowy authored Jan 16, 2024
1 parent cbb52e1 commit 480b737
Show file tree
Hide file tree
Showing 34 changed files with 374 additions and 240 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/client_api_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,17 @@ jobs:
- name: Install cargo-tree
run: cargo install cargo-tree

- name: Install wasm-pack
run: cargo install wasm-pack

- name: Build ClientAPI
working-directory: ./libs/client-api
run: cargo build

- name: Build ClientAPI WASM
working-directory: ./libs/client-api
run: wasm-pack build --features="wasm_build"

- name: Check ClientAPI Dependencies
run: bash ./build/client_api_deps_check.sh

5 changes: 4 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions libs/app_error/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
thiserror = "1.0.56"
Expand All @@ -18,7 +20,7 @@ url = { version = "2.5.0"}
actix-web = { version = "4.4.1", optional = true }
reqwest = { version = "0.11" }
serde_json.workspace = true
tokio = { workspace = true, optional = true }
tokio = { workspace = true, optional = true, default-features = false }
bincode = { version = "1.3.3", optional = true }

[features]
Expand All @@ -29,4 +31,7 @@ s3_error = ["rust-s3"]
actix_web_error = ["actix-web"]
tokio_error = ["tokio"]
gotrue_error= []
bincode_error = ["bincode"]
bincode_error = ["bincode"]

[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.2", features = ["js"]}
1 change: 1 addition & 0 deletions libs/app_error/src/gotrue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ impl GoTrueError {

impl From<reqwest::Error> for GoTrueError {
fn from(value: reqwest::Error) -> Self {
#[cfg(not(target_arch = "wasm32"))]
if value.is_connect() {
return GoTrueError::Connect(value.to_string());
}
Expand Down
1 change: 1 addition & 0 deletions libs/app_error/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ impl AppError {

impl From<reqwest::Error> for AppError {
fn from(error: reqwest::Error) -> Self {
#[cfg(not(target_arch = "wasm32"))]
if error.is_connect() {
return AppError::Connect(error.to_string());
}
Expand Down
61 changes: 37 additions & 24 deletions libs/client-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,64 @@ version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
reqwest = { version = "0.11.23", default-features = false, features = ["stream","json","multipart"] }
reqwest = { version = "0.11.23", default-features = false, features = ["stream","json"] }
anyhow = "1.0.79"
serde_json.workspace = true
serde_repr = "0.1.18"
gotrue = { path = "../gotrue" }
gotrue-entity = { path = "../gotrue-entity" }
shared_entity = { path = "../shared-entity" }
database-entity.workspace = true
url = "2.5.0"
tokio-stream = { version = "0.1.14" }
parking_lot = "0.12.1"
mime = "0.3.17"
app-error = { workspace = true, features = ["tokio_error", "bincode_error"] }
brotli = "3.4.0"

# ws
tracing = { version = "0.1" }
thiserror = "1.0.56"
serde.workspace = true
tokio-tungstenite = { version = "0.20.1", features = ["native-tls"] }
tokio = { version = "1.35", features = ["full"] }
bytes = "1.5"
uuid = "1.6.1"
futures-util = "0.3.30"
futures-core = "0.3.30"
tokio-retry = "0.3"
bytes = "1.5"
uuid = "1.6.1"
scraper = { version = "0.17.1", optional = true }
parking_lot = "0.12.1"
brotli = "3.4.0"
mime_guess = "2.0.4"
async-trait = { version = "0.1.77" }
prost = "0.12.3"
bincode = "1.3.3"
url = "2.5.0"
mime = "0.3.17"
tokio-stream = { version = "0.1.14" }
realtime-entity = { workspace = true }

# collab sync
collab = { version = "0.1.0", optional = true }
collab-entity = { version = "0.1.0" }
yrs = { workspace = true, optional = true }
realtime-entity = { workspace = true, features = ["tungstenite"] }
realtime-protocol = { workspace = true }
workspace-template = { workspace = true, optional = true }
mime_guess = "2.0.4"
async-trait = { version = "0.1.77" }
prost = "0.12.3"
bincode = "1.3.3"
serde_json.workspace = true
serde.workspace = true
database-entity.workspace = true
app-error = { workspace = true, features = ["tokio_error", "bincode_error"] }
scraper = { version = "0.17.1", optional = true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.2", features = ["js"]}
tokio = { workspace = true, features = ["sync"]}


[target.'cfg(not(target_arch = "wasm32"))'.dependencies.tokio]
workspace = true
features = ["sync", "net"]

[target.'cfg(not(target_arch = "wasm32"))'.dependencies.realtime-entity]
workspace = true
features = ["tungstenite"]

[target.'cfg(not(target_arch = "wasm32"))'.dependencies.tokio-tungstenite]
version = "0.20.1"
features = ["native-tls"]

[features]
collab-sync = ["collab", "yrs"]
test_util = ["scraper"]
template = ["workspace-template"]

wasm_build = []
2 changes: 1 addition & 1 deletion libs/client-api/src/collab_sync/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use realtime_protocol::{Message, SyncMessage};
use tokio_stream::StreamExt;

use crate::collab_sync::{SinkConfig, SyncQueue};
use crate::ws::{ConnectState, WSConnectStateReceiver};
use tokio_stream::wrappers::WatchStream;
use tracing::trace;

use crate::{ConnectState, WSConnectStateReceiver};
use yrs::updates::encoder::Encode;

pub struct SyncPlugin<Sink, Stream, C> {
Expand Down
Loading

0 comments on commit 480b737

Please sign in to comment.