2021-07-17 10:26:05 +08:00
|
|
|
use crate::flowy_server::{ArcFlowyServer, FlowyServerMocker};
|
2021-07-19 21:05:49 +08:00
|
|
|
use flowy_dispatch::prelude::Module;
|
2021-07-22 22:26:38 +08:00
|
|
|
use flowy_editor::prelude::*;
|
2021-07-19 11:32:33 +08:00
|
|
|
use flowy_user::prelude::*;
|
|
|
|
|
2021-07-20 14:03:21 +08:00
|
|
|
use crate::deps_resolve::{WorkspaceDatabaseImpl, WorkspaceUserImpl};
|
2021-07-19 11:32:33 +08:00
|
|
|
use std::sync::Arc;
|
2021-06-30 23:11:27 +08:00
|
|
|
|
2021-07-09 23:31:44 +08:00
|
|
|
pub struct ModuleConfig {
|
|
|
|
pub root: String,
|
|
|
|
}
|
|
|
|
|
2021-07-16 23:18:12 +08:00
|
|
|
pub fn build_modules(config: ModuleConfig, _server: ArcFlowyServer) -> Vec<Module> {
|
2021-07-14 21:12:52 +08:00
|
|
|
let user_session = Arc::new(
|
|
|
|
UserSessionBuilder::new()
|
|
|
|
.root_dir(&config.root)
|
2021-07-17 10:26:05 +08:00
|
|
|
.build(Arc::new(FlowyServerMocker {})),
|
2021-07-14 21:12:52 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
let workspace_user_impl = Arc::new(WorkspaceUserImpl {
|
|
|
|
user_session: user_session.clone(),
|
|
|
|
});
|
2021-07-13 23:08:20 +08:00
|
|
|
|
2021-07-20 14:03:21 +08:00
|
|
|
let workspace_data_impl = Arc::new(WorkspaceDatabaseImpl {
|
|
|
|
user_session: user_session.clone(),
|
|
|
|
});
|
|
|
|
|
2021-07-14 08:07:25 +08:00
|
|
|
vec![
|
|
|
|
flowy_user::module::create(user_session),
|
2021-07-20 14:03:21 +08:00
|
|
|
flowy_workspace::module::create(workspace_user_impl, workspace_data_impl),
|
2021-07-22 22:26:38 +08:00
|
|
|
flowy_editor::module::create(),
|
2021-07-14 08:07:25 +08:00
|
|
|
]
|
2021-07-09 23:31:44 +08:00
|
|
|
}
|