diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml index b53e55dd..1ecd780c 100644 --- a/.github/workflows/integration_test.yml +++ b/.github/workflows/integration_test.yml @@ -113,17 +113,6 @@ jobs: echo "Running tests for ${{ matrix.test_service }} with flags: ${{ matrix.test_cmd }}" RUST_LOG="info" DISABLE_CI_TEST_LOG="true" cargo test ${{ matrix.test_cmd }} - - name: Install Node.js - uses: actions/setup-node@v2 - with: - node-version: '14' - - - name: Run WASM tests - working-directory: ./libs/wasm-test - run: | - cargo install wasm-pack - wasm-pack test --headless --firefox - cleanup: name: Cleanup Docker Images if: always() diff --git a/.github/workflows/wasm_ci.yml b/.github/workflows/wasm_ci.yml deleted file mode 100644 index 75cbfc2b..00000000 --- a/.github/workflows/wasm_ci.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: WASM CI - -on: - push: - branches: [ main ] - pull_request: - types: [ opened, synchronize, reopened ] - branches: [ main ] - -env: - NODE_VERSION: '20.12.0' - RUST_TOOLCHAIN: "1.77" - -jobs: - build: - name: Build - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ env.RUST_TOOLCHAIN }} - - - name: Setup Node.js - uses: actions/setup-node@v1 - with: - node-version: ${{ env.NODE_VERSION }} - - - uses: Swatinem/rust-cache@v2 - with: - workspaces: | - AppFlowy-Cloud - - - name: Install wasm-pack - run: npm install -g wasm-pack - - - name: Build with wasm-pack - run: wasm-pack build - working-directory: ./libs/client-api-wasm \ No newline at end of file diff --git a/.github/workflows/wasm_publish.yml b/.github/workflows/wasm_publish.yml deleted file mode 100644 index 3a12decd..00000000 --- a/.github/workflows/wasm_publish.yml +++ /dev/null @@ -1,82 +0,0 @@ -name: Manual NPM Package Publish - -on: - workflow_dispatch: - inputs: - working_directory: - description: 'Working directory (e.g., libs/client-api-wasm)' - required: true - default: 'libs/client-api-wasm' - package_name: - description: 'Which package to publish' - required: true - default: '@appflowyinc/client-api-wasm' - type: choice - options: - - '@appflowyinc/client-api-wasm' - package_version: - description: 'Package version' - required: true - prerelease_preid: - description: 'Preid for prerelease version (e.g., alpha, beta, rc)' - required: false - type: choice - default: '' - options: - - '' - - 'alpha' - - 'beta' - - 'rc' - -env: - NODE_VERSION: '20.12.0' - RUST_TOOLCHAIN: "1.77" -jobs: - publish: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ env.RUST_TOOLCHAIN }} - - - name: Setup Node.js - uses: actions/setup-node@v1 - with: - node-version: ${{ env.NODE_VERSION }} - - - uses: Swatinem/rust-cache@v2 - with: - workspaces: | - AppFlowy-Cloud - - - name: Install wasm-pack - run: npm install -g wasm-pack - - - name: Build with wasm-pack - run: wasm-pack build - working-directory: ${{ github.event.inputs.working_directory }} - - - name: Update name - working-directory: ${{ github.event.inputs.working_directory }}/pkg - run: | - jq '.name = "${{ github.event.inputs.package_name }}"' package.json > package.json.tmp - mv package.json.tmp package.json - - name: Update version - working-directory: ${{ github.event.inputs.working_directory }}/pkg - run: | - npm version ${{ github.event.inputs.package_version }} - if [ "${{ github.event.inputs.prerelease_preid }}" != "" ]; then - npm version prerelease --preid ${{ github.event.inputs.prerelease_preid }} - fi - - - name: Configure npm for wasm-pack - run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ${{ github.event.inputs.working_directory }}/pkg/.npmrc - - - name: Publish package - run: | - npm config set access public - wasm-pack publish - working-directory: ${{ github.event.inputs.working_directory }}/pkg - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/Cargo.lock b/Cargo.lock index 5efc9a3e..2dfd9157 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2006,7 +2006,7 @@ dependencies = [ [[package]] name = "collab" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=870cd70#870cd70e31fa30bc6f94595ca040a91c685dfb4e" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=20f7814#20f7814beb265ea76e85ea7a9d392b9fe18a2a63" dependencies = [ "anyhow", "async-trait", @@ -2030,7 +2030,7 @@ dependencies = [ [[package]] name = "collab-document" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=870cd70#870cd70e31fa30bc6f94595ca040a91c685dfb4e" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=20f7814#20f7814beb265ea76e85ea7a9d392b9fe18a2a63" dependencies = [ "anyhow", "collab", @@ -2044,12 +2044,13 @@ dependencies = [ "tokio", "tokio-stream", "tracing", + "uuid", ] [[package]] name = "collab-entity" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=870cd70#870cd70e31fa30bc6f94595ca040a91c685dfb4e" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=20f7814#20f7814beb265ea76e85ea7a9d392b9fe18a2a63" dependencies = [ "anyhow", "bytes", @@ -2064,7 +2065,7 @@ dependencies = [ [[package]] name = "collab-folder" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=870cd70#870cd70e31fa30bc6f94595ca040a91c685dfb4e" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=20f7814#20f7814beb265ea76e85ea7a9d392b9fe18a2a63" dependencies = [ "anyhow", "chrono", @@ -7189,6 +7190,7 @@ checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" dependencies = [ "getrandom 0.2.12", "serde", + "sha1_smol", ] [[package]] @@ -7799,9 +7801,9 @@ dependencies = [ [[package]] name = "yrs" -version = "0.18.7" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d58fbc807677598fedfab76f99f6e1aa5c644411255002b5438ea0ab14672398" +checksum = "71df0198938b69f1eec0d5f19f591c6e4f2f770b0bf16f858428f6d91b8bb280" dependencies = [ "arc-swap", "atomic_refcell", diff --git a/Cargo.toml b/Cargo.toml index d5fb2447..bd8cbe67 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -215,7 +215,7 @@ pgvector = { version = "0.3", features = ["sqlx"] } client-api-entity = { path = "libs/client-api-entity" } # collaboration -yrs = "0.18.7" +yrs = "0.19.1" collab = { version = "0.2.0" } collab-entity = { version = "0.2.0" } collab-folder = { version = "0.2.0" } @@ -233,10 +233,10 @@ debug = true [patch.crates-io] # It's diffcult to resovle different version with the same crate used in AppFlowy Frontend and the Client-API crate. # So using patch to workaround this issue. -collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "870cd70" } -collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "870cd70" } -collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "870cd70" } -collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "870cd70" } +collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "20f7814" } +collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "20f7814" } +collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "20f7814" } +collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "20f7814" } [features] history = [] diff --git a/libs/collab-rt-entity/src/client_message.rs b/libs/collab-rt-entity/src/client_message.rs index 6dd61e22..3766c2bb 100644 --- a/libs/collab-rt-entity/src/client_message.rs +++ b/libs/collab-rt-entity/src/client_message.rs @@ -328,7 +328,7 @@ impl UpdateSync { Some(Message::Sync(SyncMessage::Update(right))), ) = (self.as_update(), other.as_update()) { - let update = merge_updates_v1(&[&left, &right])?; + let update = merge_updates_v1([left, right])?; let msg = Message::Sync(SyncMessage::Update(update)); let mut encoder = EncoderV1::new(); msg.encode(&mut encoder); diff --git a/services/appflowy-collaborate/src/group/broadcast.rs b/services/appflowy-collaborate/src/group/broadcast.rs index 1e1534bd..ede8c999 100644 --- a/services/appflowy-collaborate/src/group/broadcast.rs +++ b/services/appflowy-collaborate/src/group/broadcast.rs @@ -131,15 +131,17 @@ impl CollabBroadcast { let cloned_oid = self.object_id.clone(); // Observer the awareness's update and broadcast it to all subscribers. - let awareness_sub = collab.lock().observe_awareness(move |event| { - if let Some(awareness_update) = event.awareness_update() { - let payload = Message::Awareness(awareness_update.clone()).encode_v1(); - let msg = AwarenessSync::new(cloned_oid.clone(), payload, CollabOrigin::Empty); - if let Err(err) = broadcast_sink.send(msg.into()) { - trace!("fail to broadcast awareness:{}", err); + let awareness_sub = collab + .lock() + .observe_awareness(move |awareness, event, _origin| { + if let Ok(awareness_update) = awareness.update_with_clients(event.all_changes()) { + let payload = Message::Awareness(awareness_update).encode_v1(); + let msg = AwarenessSync::new(cloned_oid.clone(), payload, CollabOrigin::Empty); + if let Err(err) = broadcast_sink.send(msg.into()) { + trace!("fail to broadcast awareness:{}", err); + } } - } - }); + }); (doc_sub, awareness_sub) }; diff --git a/src/biz/user/user_init.rs b/src/biz/user/user_init.rs index e7c11bfc..dd4b6da0 100644 --- a/src/biz/user/user_init.rs +++ b/src/biz/user/user_init.rs @@ -2,7 +2,7 @@ use app_error::AppError; use appflowy_collaborate::collab::storage::CollabAccessControlStorage; use collab::core::origin::CollabOrigin; -use collab::preclude::{Any, Collab, MapPrelim}; +use collab::preclude::{Any, Collab}; use collab_entity::define::WORKSPACE_DATABASES; use collab_entity::CollabType; use database::collab::CollabStorage; @@ -85,7 +85,7 @@ async fn create_workspace_database_collab( let collab_type = CollabType::WorkspaceDatabase; let collab = Collab::new_with_origin(CollabOrigin::Empty, object_id, vec![], false); let _ = collab.with_origin_transact_mut(|txn| { - collab.create_array_with_txn::>(txn, WORKSPACE_DATABASES, vec![]); + collab.create_array_with_txn::(txn, WORKSPACE_DATABASES, vec![]); Ok::<(), AppError>(()) }); diff --git a/tests/collab/single_device_edit.rs b/tests/collab/single_device_edit.rs index a40f5890..e4354d23 100644 --- a/tests/collab/single_device_edit.rs +++ b/tests/collab/single_device_edit.rs @@ -339,7 +339,7 @@ async fn same_device_multiple_connect_in_order_test() { &object_id, &collab_type, 10, - json!({"0":0.0,"1":1.0,"2":2.0}), + json!({"0":0,"1":1,"2":2}), ) .await .unwrap();