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:
Nathan.fooo
2024-01-30 05:36:27 +08:00
committed by GitHub
parent 86a0569d84
commit 55c97b56a3
164 changed files with 9334 additions and 2885 deletions

View File

@ -22,4 +22,4 @@ lib-infra = { workspace = true }
[features]
default = []
wasm_build = ["collab-plugins/wasm_build"]
enable_wasm = ["collab-plugins/wasm_build"]

View File

@ -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>>,

View File

@ -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};

View File

@ -0,0 +1 @@
pub mod plugin_provider;

View File

@ -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()
}
}

View File

@ -0,0 +1 @@
pub mod plugin_provider;

View File

@ -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()
}
}