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:
@ -31,5 +31,4 @@ zip = { version = "0.6.6", features = ["deflate"] }
|
||||
brotli = { version = "3.4.0", optional = true }
|
||||
|
||||
[features]
|
||||
compression = ["brotli"]
|
||||
wasm_build = []
|
||||
compression = ["brotli"]
|
@ -1,15 +1,25 @@
|
||||
pub use async_trait;
|
||||
pub mod box_any;
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub mod file_util;
|
||||
|
||||
#[cfg(feature = "compression")]
|
||||
pub mod compression;
|
||||
|
||||
pub mod future;
|
||||
if_native! {
|
||||
mod native;
|
||||
pub mod file_util;
|
||||
pub mod future {
|
||||
pub use crate::native::future::*;
|
||||
}
|
||||
}
|
||||
|
||||
if_wasm! {
|
||||
mod wasm;
|
||||
pub mod future {
|
||||
pub use crate::wasm::future::*;
|
||||
}
|
||||
}
|
||||
|
||||
pub mod priority_task;
|
||||
pub mod ref_map;
|
||||
pub mod util;
|
||||
pub mod validator_fn;
|
||||
|
||||
pub mod priority_task;
|
||||
|
1
frontend/rust-lib/lib-infra/src/native/mod.rs
Normal file
1
frontend/rust-lib/lib-infra/src/native/mod.rs
Normal file
@ -0,0 +1 @@
|
||||
pub(crate) mod future;
|
65
frontend/rust-lib/lib-infra/src/wasm/future.rs
Normal file
65
frontend/rust-lib/lib-infra/src/wasm/future.rs
Normal file
@ -0,0 +1,65 @@
|
||||
use futures_core::future::LocalBoxFuture;
|
||||
use futures_core::ready;
|
||||
use pin_project::pin_project;
|
||||
use std::{
|
||||
fmt::Debug,
|
||||
future::Future,
|
||||
pin::Pin,
|
||||
task::{Context, Poll},
|
||||
};
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn to_fut<T, O>(f: T) -> Fut<O>
|
||||
where
|
||||
T: Future<Output = O> + 'static,
|
||||
{
|
||||
Fut { fut: Box::pin(f) }
|
||||
}
|
||||
|
||||
#[pin_project]
|
||||
pub struct Fut<T> {
|
||||
#[pin]
|
||||
pub fut: Pin<Box<dyn Future<Output = T>>>,
|
||||
}
|
||||
|
||||
impl<T> Future for Fut<T> {
|
||||
type Output = T;
|
||||
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
let this = self.as_mut().project();
|
||||
Poll::Ready(ready!(this.fut.poll(cx)))
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[pin_project]
|
||||
pub struct FutureResult<T, E> {
|
||||
#[pin]
|
||||
pub fut: Pin<Box<dyn Future<Output = Result<T, E>>>>,
|
||||
}
|
||||
|
||||
impl<T, E> FutureResult<T, E> {
|
||||
#[allow(dead_code)]
|
||||
pub fn new<F>(f: F) -> Self
|
||||
where
|
||||
F: Future<Output = Result<T, E>> + 'static,
|
||||
{
|
||||
Self { fut: Box::pin(f) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, E> Future for FutureResult<T, E>
|
||||
where
|
||||
E: Debug,
|
||||
{
|
||||
type Output = Result<T, E>;
|
||||
|
||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
let this = self.as_mut().project();
|
||||
let result = ready!(this.fut.poll(cx));
|
||||
Poll::Ready(result)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub type BoxResultFuture<'a, T, E> = LocalBoxFuture<'a, Result<T, E>>;
|
1
frontend/rust-lib/lib-infra/src/wasm/mod.rs
Normal file
1
frontend/rust-lib/lib-infra/src/wasm/mod.rs
Normal file
@ -0,0 +1 @@
|
||||
pub mod future;
|
Reference in New Issue
Block a user