mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
Merge branch 'AppFlowy-IO:main' into main
This commit is contained in:
commit
eda5d9f4f9
@ -1,6 +1,6 @@
|
||||
|
||||
/// Auto generate. Do not edit
|
||||
part of 'dispatch.dart';
|
||||
part of '../../dispatch.dart';
|
||||
class FolderEventCreateWorkspace {
|
||||
CreateWorkspaceRequest request;
|
||||
FolderEventCreateWorkspace(this.request);
|
||||
@ -411,158 +411,3 @@ class FolderEventExportDocument {
|
||||
}
|
||||
}
|
||||
|
||||
class NetworkEventUpdateNetworkType {
|
||||
NetworkState request;
|
||||
NetworkEventUpdateNetworkType(this.request);
|
||||
|
||||
Future<Either<Unit, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = NetworkEvent.UpdateNetworkType.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(bytes) => left(unit),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class UserEventInitUser {
|
||||
UserEventInitUser();
|
||||
|
||||
Future<Either<Unit, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = UserEvent.InitUser.toString();
|
||||
|
||||
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
|
||||
(bytes) => left(unit),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class UserEventSignIn {
|
||||
SignInRequest request;
|
||||
UserEventSignIn(this.request);
|
||||
|
||||
Future<Either<UserProfile, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = UserEvent.SignIn.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(okBytes) => left(UserProfile.fromBuffer(okBytes)),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class UserEventSignUp {
|
||||
SignUpRequest request;
|
||||
UserEventSignUp(this.request);
|
||||
|
||||
Future<Either<UserProfile, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = UserEvent.SignUp.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(okBytes) => left(UserProfile.fromBuffer(okBytes)),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class UserEventSignOut {
|
||||
UserEventSignOut();
|
||||
|
||||
Future<Either<Unit, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = UserEvent.SignOut.toString();
|
||||
|
||||
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
|
||||
(bytes) => left(unit),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class UserEventUpdateUser {
|
||||
UpdateUserRequest request;
|
||||
UserEventUpdateUser(this.request);
|
||||
|
||||
Future<Either<Unit, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = UserEvent.UpdateUser.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(bytes) => left(unit),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class UserEventGetUserProfile {
|
||||
UserEventGetUserProfile();
|
||||
|
||||
Future<Either<UserProfile, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = UserEvent.GetUserProfile.toString();
|
||||
|
||||
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
|
||||
(okBytes) => left(UserProfile.fromBuffer(okBytes)),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class UserEventCheckUser {
|
||||
UserEventCheckUser();
|
||||
|
||||
Future<Either<UserProfile, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = UserEvent.CheckUser.toString();
|
||||
|
||||
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
|
||||
(okBytes) => left(UserProfile.fromBuffer(okBytes)),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class UserEventSetAppearanceSetting {
|
||||
AppearanceSettings request;
|
||||
UserEventSetAppearanceSetting(this.request);
|
||||
|
||||
Future<Either<Unit, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = UserEvent.SetAppearanceSetting.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(bytes) => left(unit),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class UserEventGetAppearanceSetting {
|
||||
UserEventGetAppearanceSetting();
|
||||
|
||||
Future<Either<AppearanceSettings, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = UserEvent.GetAppearanceSetting.toString();
|
||||
|
||||
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
|
||||
(okBytes) => left(AppearanceSettings.fromBuffer(okBytes)),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,20 @@
|
||||
|
||||
/// Auto generate. Do not edit
|
||||
part of '../../dispatch.dart';
|
||||
class NetworkEventUpdateNetworkType {
|
||||
NetworkState request;
|
||||
NetworkEventUpdateNetworkType(this.request);
|
||||
|
||||
Future<Either<Unit, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = NetworkEvent.UpdateNetworkType.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(bytes) => left(unit),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,141 @@
|
||||
|
||||
/// Auto generate. Do not edit
|
||||
part of '../../dispatch.dart';
|
||||
class UserEventInitUser {
|
||||
UserEventInitUser();
|
||||
|
||||
Future<Either<Unit, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = UserEvent.InitUser.toString();
|
||||
|
||||
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
|
||||
(bytes) => left(unit),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class UserEventSignIn {
|
||||
SignInRequest request;
|
||||
UserEventSignIn(this.request);
|
||||
|
||||
Future<Either<UserProfile, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = UserEvent.SignIn.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(okBytes) => left(UserProfile.fromBuffer(okBytes)),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class UserEventSignUp {
|
||||
SignUpRequest request;
|
||||
UserEventSignUp(this.request);
|
||||
|
||||
Future<Either<UserProfile, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = UserEvent.SignUp.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(okBytes) => left(UserProfile.fromBuffer(okBytes)),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class UserEventSignOut {
|
||||
UserEventSignOut();
|
||||
|
||||
Future<Either<Unit, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = UserEvent.SignOut.toString();
|
||||
|
||||
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
|
||||
(bytes) => left(unit),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class UserEventUpdateUser {
|
||||
UpdateUserRequest request;
|
||||
UserEventUpdateUser(this.request);
|
||||
|
||||
Future<Either<Unit, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = UserEvent.UpdateUser.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(bytes) => left(unit),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class UserEventGetUserProfile {
|
||||
UserEventGetUserProfile();
|
||||
|
||||
Future<Either<UserProfile, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = UserEvent.GetUserProfile.toString();
|
||||
|
||||
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
|
||||
(okBytes) => left(UserProfile.fromBuffer(okBytes)),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class UserEventCheckUser {
|
||||
UserEventCheckUser();
|
||||
|
||||
Future<Either<UserProfile, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = UserEvent.CheckUser.toString();
|
||||
|
||||
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
|
||||
(okBytes) => left(UserProfile.fromBuffer(okBytes)),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class UserEventSetAppearanceSetting {
|
||||
AppearanceSettings request;
|
||||
UserEventSetAppearanceSetting(this.request);
|
||||
|
||||
Future<Either<Unit, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = UserEvent.SetAppearanceSetting.toString()
|
||||
..payload = requestToBytes(this.request);
|
||||
|
||||
return Dispatch.asyncRequest(request)
|
||||
.then((bytesResult) => bytesResult.fold(
|
||||
(bytes) => left(unit),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
class UserEventGetAppearanceSetting {
|
||||
UserEventGetAppearanceSetting();
|
||||
|
||||
Future<Either<AppearanceSettings, FlowyError>> send() {
|
||||
final request = FFIRequest.create()
|
||||
..event = UserEvent.GetAppearanceSetting.toString();
|
||||
|
||||
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
|
||||
(okBytes) => left(AppearanceSettings.fromBuffer(okBytes)),
|
||||
(errBytes) => right(FlowyError.fromBuffer(errBytes)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,9 @@ import 'package:protobuf/protobuf.dart';
|
||||
import 'dart:convert' show utf8;
|
||||
import 'error.dart';
|
||||
|
||||
part 'dart_event.dart';
|
||||
part 'dart_event/flowy-folder/dart_event.dart';
|
||||
part 'dart_event/flowy-net/dart_event.dart';
|
||||
part 'dart_event/flowy-user/dart_event.dart';
|
||||
|
||||
enum FFIException {
|
||||
RequestIsEmpty,
|
||||
|
@ -1,17 +1,5 @@
|
||||
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/dart_event.dart", workspace_dir, flutter_sdk_path);
|
||||
println!("cargo:rerun-if-changed={}", output_file);
|
||||
dart_event::write_dart_event_file(&output_file);
|
||||
}
|
||||
|
@ -4,16 +4,27 @@ use crate::code_gen::util::{cache_dir, is_crate_dir, is_hidden, read_file};
|
||||
use flowy_ast::{event_ast::*, *};
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
use syn::Item;
|
||||
use walkdir::WalkDir;
|
||||
|
||||
pub fn gen(crate_name: &str) {
|
||||
if std::env::var("CARGO_MAKE_WORKING_DIRECTORY").is_err() {
|
||||
log::warn!("CARGO_MAKE_WORKING_DIRECTORY was not set, skip generate dart pb");
|
||||
return;
|
||||
}
|
||||
|
||||
if std::env::var("FLUTTER_FLOWY_SDK_PATH").is_err() {
|
||||
log::warn!("FLUTTER_FLOWY_SDK_PATH was not set, skip generate dart pb");
|
||||
return;
|
||||
}
|
||||
|
||||
let crate_path = std::fs::canonicalize(".").unwrap().as_path().display().to_string();
|
||||
let event_crates = parse_dart_event_files(vec![crate_path]);
|
||||
let event_ast = event_crates.iter().map(parse_event_crate).flatten().collect::<Vec<_>>();
|
||||
|
||||
let event_render_ctx = ast_to_event_render_ctx(event_ast.as_ref());
|
||||
let mut render_result = String::new();
|
||||
let mut render_result = DART_IMPORTED.to_owned();
|
||||
for (index, render_ctx) in event_render_ctx.into_iter().enumerate() {
|
||||
let mut event_template = EventTemplate::new();
|
||||
|
||||
@ -22,8 +33,19 @@ pub fn gen(crate_name: &str) {
|
||||
}
|
||||
}
|
||||
|
||||
let cache_dir = format!("{}/{}", cache_dir(), crate_name);
|
||||
let dart_event_file_path = format!("{}/dart_event.dart", cache_dir);
|
||||
let dart_event_folder = format!(
|
||||
"{}/{}/lib/dispatch/dart_event/{}",
|
||||
std::env::var("CARGO_MAKE_WORKING_DIRECTORY").unwrap(),
|
||||
std::env::var("FLUTTER_FLOWY_SDK_PATH").unwrap(),
|
||||
crate_name
|
||||
);
|
||||
|
||||
if !Path::new(&dart_event_folder).exists() {
|
||||
std::fs::create_dir_all(&dart_event_folder).unwrap();
|
||||
}
|
||||
|
||||
let dart_event_file_path = format!("{}/dart_event.dart", dart_event_folder);
|
||||
println!("cargo:rerun-if-changed={}", dart_event_file_path);
|
||||
|
||||
match std::fs::OpenOptions::new()
|
||||
.create(true)
|
||||
@ -44,7 +66,7 @@ pub fn gen(crate_name: &str) {
|
||||
|
||||
const DART_IMPORTED: &str = r#"
|
||||
/// Auto generate. Do not edit
|
||||
part of 'dispatch.dart';
|
||||
part of '../../dispatch.dart';
|
||||
"#;
|
||||
|
||||
pub fn write_dart_event_file(file_path: &str) {
|
||||
|
Loading…
Reference in New Issue
Block a user