mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
chore: write dart_event file
This commit is contained in:
@ -29,8 +29,8 @@ dart-notify = {path = "../dart-notify" }
|
||||
flowy-derive = {path = "../../../shared-lib/flowy-derive" }
|
||||
|
||||
[features]
|
||||
default = ["flowy-sdk/dart"]
|
||||
flutter = ["dart-notify/dart"]
|
||||
default = ["flowy-sdk/dart", "dart-notify/dart", "flutter"]
|
||||
flutter = []
|
||||
http_server = ["flowy-sdk/http_server", "flowy-sdk/use_bunyan"]
|
||||
#use_serde = ["bincode"]
|
||||
#use_protobuf= ["protobuf"]
|
||||
|
@ -1,5 +1,16 @@
|
||||
use lib_infra::code_gen;
|
||||
use lib_infra::code_gen::dart_event;
|
||||
|
||||
fn main() {
|
||||
code_gen::protobuf_file::gen(env!("CARGO_PKG_NAME"), "./src/protobuf/proto");
|
||||
#[cfg(feature = "flutter")]
|
||||
copy_dart_event_files();
|
||||
}
|
||||
|
||||
#[cfg(feature = "flutter")]
|
||||
fn copy_dart_event_files() {
|
||||
let workspace_dir = std::env::var("CARGO_MAKE_WORKING_DIRECTORY").unwrap();
|
||||
let flutter_sdk_path = std::env::var("FLUTTER_FLOWY_SDK_PATH").unwrap();
|
||||
let output_file = format!("{}/{}/lib/dispatch/code_gen.dart", workspace_dir, flutter_sdk_path);
|
||||
dart_event::write_dart_event_file(&output_file);
|
||||
}
|
||||
|
@ -3,5 +3,5 @@ use lib_infra::code_gen;
|
||||
fn main() {
|
||||
let crate_name = env!("CARGO_PKG_NAME");
|
||||
code_gen::protobuf_file::gen(crate_name, "./src/protobuf/proto");
|
||||
// dart_event::gen(crate_name);
|
||||
code_gen::dart_event::gen(crate_name);
|
||||
}
|
||||
|
@ -1,2 +1,2 @@
|
||||
proto_crates = ["src/event.rs", "src/entities"]
|
||||
event_files = ["src/event.rs"]
|
||||
proto_crates = ["src/event_map.rs", "src/entities"]
|
||||
event_files = ["src/event_map.rs"]
|
@ -1,5 +1,7 @@
|
||||
use lib_infra::code_gen;
|
||||
|
||||
fn main() {
|
||||
code_gen::protobuf_file::gen(env!("CARGO_PKG_NAME"), "./src/protobuf/proto");
|
||||
let crate_name = env!("CARGO_PKG_NAME");
|
||||
code_gen::protobuf_file::gen(crate_name, "./src/protobuf/proto");
|
||||
code_gen::dart_event::gen(crate_name);
|
||||
}
|
||||
|
@ -1,9 +0,0 @@
|
||||
use flowy_derive::{Flowy_Event, ProtoBuf_Enum};
|
||||
use strum_macros::Display;
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, Display, Hash, ProtoBuf_Enum, Flowy_Event)]
|
||||
#[event_err = "FlowyError"]
|
||||
pub enum NetworkEvent {
|
||||
#[event(input = "NetworkState")]
|
||||
UpdateNetworkType = 0,
|
||||
}
|
19
frontend/rust-lib/flowy-net/src/event_map.rs
Normal file
19
frontend/rust-lib/flowy-net/src/event_map.rs
Normal file
@ -0,0 +1,19 @@
|
||||
use crate::{handlers::*, ws::connection::FlowyWebSocketConnect};
|
||||
use flowy_derive::{Flowy_Event, ProtoBuf_Enum};
|
||||
use lib_dispatch::prelude::*;
|
||||
use std::sync::Arc;
|
||||
use strum_macros::Display;
|
||||
|
||||
pub fn create(ws_conn: Arc<FlowyWebSocketConnect>) -> Module {
|
||||
Module::new()
|
||||
.name("Flowy-Network")
|
||||
.data(ws_conn)
|
||||
.event(NetworkEvent::UpdateNetworkType, update_network_ty)
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, Display, Hash, ProtoBuf_Enum, Flowy_Event)]
|
||||
#[event_err = "FlowyError"]
|
||||
pub enum NetworkEvent {
|
||||
#[event(input = "NetworkState")]
|
||||
UpdateNetworkType = 0,
|
||||
}
|
@ -1,10 +1,9 @@
|
||||
mod configuration;
|
||||
pub mod entities;
|
||||
mod event;
|
||||
pub mod event_map;
|
||||
mod handlers;
|
||||
pub mod http_server;
|
||||
pub mod local_server;
|
||||
pub mod module;
|
||||
pub mod protobuf;
|
||||
mod request;
|
||||
pub mod ws;
|
||||
|
@ -1,10 +0,0 @@
|
||||
use crate::{event::NetworkEvent, handlers::*, ws::connection::FlowyWebSocketConnect};
|
||||
use lib_dispatch::prelude::*;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub fn create(ws_conn: Arc<FlowyWebSocketConnect>) -> Module {
|
||||
Module::new()
|
||||
.name("Flowy-Network")
|
||||
.data(ws_conn)
|
||||
.event(NetworkEvent::UpdateNetworkType, update_network_ty)
|
||||
}
|
@ -17,7 +17,7 @@
|
||||
#![allow(trivial_casts)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(unused_results)]
|
||||
//! Generated file from `event.proto`
|
||||
//! Generated file from `event_map.proto`
|
||||
|
||||
/// Generated files are compatible only with the same version
|
||||
/// of protobuf runtime.
|
||||
@ -71,8 +71,8 @@ impl ::protobuf::reflect::ProtobufValue for NetworkEvent {
|
||||
}
|
||||
|
||||
static file_descriptor_proto_data: &'static [u8] = b"\
|
||||
\n\x0bevent.proto*%\n\x0cNetworkEvent\x12\x15\n\x11UpdateNetworkType\x10\
|
||||
\0b\x06proto3\
|
||||
\n\x0fevent_map.proto*%\n\x0cNetworkEvent\x12\x15\n\x11UpdateNetworkType\
|
||||
\x10\0b\x06proto3\
|
||||
";
|
||||
|
||||
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;
|
@ -4,5 +4,5 @@
|
||||
mod network_state;
|
||||
pub use network_state::*;
|
||||
|
||||
mod event;
|
||||
pub use event::*;
|
||||
mod event_map;
|
||||
pub use event_map::*;
|
||||
|
@ -24,5 +24,5 @@ fn mk_folder_module(core: Arc<FolderManager>) -> Module {
|
||||
}
|
||||
|
||||
fn mk_network_module(ws_conn: Arc<FlowyWebSocketConnect>) -> Module {
|
||||
flowy_net::module::create(ws_conn)
|
||||
flowy_net::event_map::create(ws_conn)
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
use lib_infra::code_gen;
|
||||
|
||||
fn main() {
|
||||
code_gen::protobuf_file::gen(env!("CARGO_PKG_NAME"), "./src/protobuf/proto");
|
||||
let crate_name = env!("CARGO_PKG_NAME");
|
||||
code_gen::protobuf_file::gen(crate_name, "./src/protobuf/proto");
|
||||
code_gen::dart_event::gen(crate_name);
|
||||
}
|
||||
|
@ -1,27 +0,0 @@
|
||||
use flowy_derive::{Flowy_Event, ProtoBuf_Enum};
|
||||
use strum_macros::Display;
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, Display, Hash, ProtoBuf_Enum, Flowy_Event)]
|
||||
#[event_err = "FlowyError"]
|
||||
pub enum UserEvent {
|
||||
#[event()]
|
||||
InitUser = 0,
|
||||
|
||||
#[event(input = "SignInRequest", output = "UserProfile")]
|
||||
SignIn = 1,
|
||||
|
||||
#[event(input = "SignUpRequest", output = "UserProfile")]
|
||||
SignUp = 2,
|
||||
|
||||
#[event(passthrough)]
|
||||
SignOut = 3,
|
||||
|
||||
#[event(input = "UpdateUserRequest")]
|
||||
UpdateUser = 4,
|
||||
|
||||
#[event(output = "UserProfile")]
|
||||
GetUserProfile = 5,
|
||||
|
||||
#[event(output = "UserProfile")]
|
||||
CheckUser = 6,
|
||||
}
|
Reference in New Issue
Block a user