mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: calling user event from web (#4535)
* refactor: user manager * refactor: user manager * refactor: session location * refactor: user manager * chore: gen ts files * feat: implement indexeddb persistence * chore: integrate user manager * chore: update * chore: run on web thread * chore: run on web thread * chore: fix test * chore: add test * chore: add test * chore: add user & sign in with password * chore: fix test * chore: update docs * chore: fix warnings * chore: gen files * chore: add user * chore: add files * chore: update config * chore: update scirpt * chore: update scirpt * fix: build * chore: update command * fix: ci * ci: fix * fix: compile * fix: compile * fix: ci * fix: compile * fix: tauri build * chore: fix test * chore: fix test
This commit is contained in:
@ -22,4 +22,4 @@ lib-infra = { workspace = true }
|
||||
|
||||
[features]
|
||||
default = []
|
||||
wasm_build = ["collab-plugins/wasm_build"]
|
||||
enable_wasm = ["collab-plugins/wasm_build"]
|
@ -4,7 +4,7 @@ use std::sync::{Arc, Weak};
|
||||
use crate::CollabKVDB;
|
||||
use anyhow::Error;
|
||||
use collab::core::collab::{CollabDocState, MutexCollab};
|
||||
use collab::preclude::{CollabBuilder, CollabPlugin};
|
||||
use collab::preclude::CollabBuilder;
|
||||
use collab_entity::{CollabObject, CollabType};
|
||||
use collab_plugins::connect_state::{CollabConnectReachability, CollabConnectState};
|
||||
use collab_plugins::local_storage::kv::snapshot::SnapshotPersistence;
|
||||
@ -16,8 +16,9 @@ if_wasm! {
|
||||
use collab_plugins::local_storage::indexeddb::IndexeddbDiskPlugin;
|
||||
}
|
||||
|
||||
pub use crate::plugin_provider::CollabCloudPluginProvider;
|
||||
use collab_plugins::local_storage::CollabPersistenceConfig;
|
||||
use lib_infra::future::Fut;
|
||||
|
||||
use lib_infra::{if_native, if_wasm};
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
use tracing::trace;
|
||||
@ -64,31 +65,6 @@ impl Display for CollabPluginProviderContext {
|
||||
}
|
||||
}
|
||||
|
||||
pub trait CollabCloudPluginProvider: Send + Sync + 'static {
|
||||
fn provider_type(&self) -> CollabPluginProviderType;
|
||||
|
||||
fn get_plugins(&self, context: CollabPluginProviderContext) -> Fut<Vec<Arc<dyn CollabPlugin>>>;
|
||||
|
||||
fn is_sync_enabled(&self) -> bool;
|
||||
}
|
||||
|
||||
impl<T> CollabCloudPluginProvider for Arc<T>
|
||||
where
|
||||
T: CollabCloudPluginProvider,
|
||||
{
|
||||
fn provider_type(&self) -> CollabPluginProviderType {
|
||||
(**self).provider_type()
|
||||
}
|
||||
|
||||
fn get_plugins(&self, context: CollabPluginProviderContext) -> Fut<Vec<Arc<dyn CollabPlugin>>> {
|
||||
(**self).get_plugins(context)
|
||||
}
|
||||
|
||||
fn is_sync_enabled(&self) -> bool {
|
||||
(**self).is_sync_enabled()
|
||||
}
|
||||
}
|
||||
|
||||
pub struct AppFlowyCollabBuilder {
|
||||
network_reachability: CollabConnectReachability,
|
||||
workspace_id: RwLock<Option<String>>,
|
||||
|
@ -2,8 +2,25 @@ pub use collab::core::collab::MutexCollab;
|
||||
pub use collab::preclude::Snapshot;
|
||||
pub use collab_plugins::local_storage::CollabPersistenceConfig;
|
||||
pub use collab_plugins::CollabKVDB;
|
||||
use collab_plugins::{if_native, if_wasm};
|
||||
|
||||
pub mod collab_builder;
|
||||
pub mod config;
|
||||
|
||||
if_native! {
|
||||
mod native;
|
||||
mod plugin_provider {
|
||||
pub use crate::native::plugin_provider::*;
|
||||
}
|
||||
}
|
||||
|
||||
if_wasm! {
|
||||
mod wasm;
|
||||
mod plugin_provider {
|
||||
pub use crate::wasm::plugin_provider::*;
|
||||
}
|
||||
}
|
||||
|
||||
pub use collab_plugins::local_storage::kv::doc::CollabKVAction;
|
||||
pub use collab_plugins::local_storage::kv::error::PersistenceError;
|
||||
pub use collab_plugins::local_storage::kv::snapshot::{CollabSnapshot, SnapshotPersistence};
|
||||
|
1
frontend/rust-lib/collab-integrate/src/native/mod.rs
Normal file
1
frontend/rust-lib/collab-integrate/src/native/mod.rs
Normal file
@ -0,0 +1 @@
|
||||
pub mod plugin_provider;
|
@ -0,0 +1,29 @@
|
||||
use crate::collab_builder::{CollabPluginProviderContext, CollabPluginProviderType};
|
||||
use collab::preclude::CollabPlugin;
|
||||
use lib_infra::future::Fut;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub trait CollabCloudPluginProvider: Send + Sync + 'static {
|
||||
fn provider_type(&self) -> CollabPluginProviderType;
|
||||
|
||||
fn get_plugins(&self, context: CollabPluginProviderContext) -> Fut<Vec<Arc<dyn CollabPlugin>>>;
|
||||
|
||||
fn is_sync_enabled(&self) -> bool;
|
||||
}
|
||||
|
||||
impl<T> CollabCloudPluginProvider for Arc<T>
|
||||
where
|
||||
T: CollabCloudPluginProvider,
|
||||
{
|
||||
fn provider_type(&self) -> CollabPluginProviderType {
|
||||
(**self).provider_type()
|
||||
}
|
||||
|
||||
fn get_plugins(&self, context: CollabPluginProviderContext) -> Fut<Vec<Arc<dyn CollabPlugin>>> {
|
||||
(**self).get_plugins(context)
|
||||
}
|
||||
|
||||
fn is_sync_enabled(&self) -> bool {
|
||||
(**self).is_sync_enabled()
|
||||
}
|
||||
}
|
1
frontend/rust-lib/collab-integrate/src/wasm/mod.rs
Normal file
1
frontend/rust-lib/collab-integrate/src/wasm/mod.rs
Normal file
@ -0,0 +1 @@
|
||||
pub mod plugin_provider;
|
@ -0,0 +1,30 @@
|
||||
use crate::collab_builder::{CollabPluginProviderContext, CollabPluginProviderType};
|
||||
use collab::preclude::CollabPlugin;
|
||||
use lib_infra::future::Fut;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub trait CollabCloudPluginProvider: 'static {
|
||||
fn provider_type(&self) -> CollabPluginProviderType;
|
||||
|
||||
fn get_plugins(&self, context: CollabPluginProviderContext) -> Fut<Vec<Arc<dyn CollabPlugin>>>;
|
||||
|
||||
fn is_sync_enabled(&self) -> bool;
|
||||
}
|
||||
|
||||
impl<T> CollabCloudPluginProvider for Rc<T>
|
||||
where
|
||||
T: CollabCloudPluginProvider,
|
||||
{
|
||||
fn provider_type(&self) -> CollabPluginProviderType {
|
||||
(**self).provider_type()
|
||||
}
|
||||
|
||||
fn get_plugins(&self, context: CollabPluginProviderContext) -> Fut<Vec<Arc<dyn CollabPlugin>>> {
|
||||
(**self).get_plugins(context)
|
||||
}
|
||||
|
||||
fn is_sync_enabled(&self) -> bool {
|
||||
(**self).is_sync_enabled()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user