Browse Source

refactor: generate dart pb files with feature flag: dart

appflowy 3 years ago
parent
commit
d0b02cb4fd
42 changed files with 172 additions and 573 deletions
  1. 0 1
      frontend/app_flowy/packages/flowy_sdk/lib/dispatch/dispatch.dart
  2. 0 1
      frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-document/protobuf.dart
  3. 0 1
      frontend/app_flowy/packages/flowy_sdk/lib/protobuf/lib-infra/protobuf.dart
  4. 0 310
      frontend/app_flowy/packages/flowy_sdk/lib/protobuf/lib-ot/model.pb.dart
  5. 0 41
      frontend/app_flowy/packages/flowy_sdk/lib/protobuf/lib-ot/model.pbenum.dart
  6. 0 80
      frontend/app_flowy/packages/flowy_sdk/lib/protobuf/lib-ot/model.pbjson.dart
  7. 0 9
      frontend/app_flowy/packages/flowy_sdk/lib/protobuf/lib-ot/model.pbserver.dart
  8. 0 2
      frontend/app_flowy/packages/flowy_sdk/lib/protobuf/lib-ot/protobuf.dart
  9. 0 21
      frontend/rust-lib/Cargo.lock
  10. 2 2
      frontend/rust-lib/dart-ffi/Cargo.toml
  11. 2 2
      frontend/rust-lib/dart-ffi/build.rs
  12. 2 2
      frontend/rust-lib/dart-notify/Cargo.toml
  13. 2 2
      frontend/rust-lib/dart-notify/build.rs
  14. 1 2
      frontend/rust-lib/flowy-document/Cargo.toml
  15. 3 2
      frontend/rust-lib/flowy-error/Cargo.toml
  16. 2 2
      frontend/rust-lib/flowy-error/build.rs
  17. 2 1
      frontend/rust-lib/flowy-folder/Cargo.toml
  18. 2 2
      frontend/rust-lib/flowy-folder/build.rs
  19. 10 2
      frontend/rust-lib/flowy-net/Cargo.toml
  20. 2 2
      frontend/rust-lib/flowy-net/build.rs
  21. 2 1
      frontend/rust-lib/flowy-sdk/Cargo.toml
  22. 4 1
      frontend/rust-lib/flowy-test/Cargo.toml
  23. 2 1
      frontend/rust-lib/flowy-user/Cargo.toml
  24. 2 2
      frontend/rust-lib/flowy-user/build.rs
  25. 11 8
      frontend/scripts/flowy-tool/src/proto/proto_gen.rs
  26. 3 0
      frontend/scripts/flowy-tool/src/proto/proto_info.rs
  27. 5 0
      frontend/scripts/flowy-tool/src/proto/template/derive_meta/derive_meta.rs
  28. 0 12
      shared-lib/Cargo.lock
  29. 4 1
      shared-lib/error-code/Cargo.toml
  30. 2 2
      shared-lib/error-code/build.rs
  31. 4 1
      shared-lib/flowy-collaboration/Cargo.toml
  32. 2 2
      shared-lib/flowy-collaboration/build.rs
  33. 4 3
      shared-lib/flowy-folder-data-model/Cargo.toml
  34. 2 2
      shared-lib/flowy-folder-data-model/build.rs
  35. 5 2
      shared-lib/flowy-user-data-model/Cargo.toml
  36. 2 2
      shared-lib/flowy-user-data-model/build.rs
  37. 2 2
      shared-lib/lib-infra/Cargo.toml
  38. 2 2
      shared-lib/lib-infra/src/lib.rs
  39. 0 38
      shared-lib/lib-infra/src/pb.rs
  40. 77 0
      shared-lib/lib-infra/src/pb_gen.rs
  41. 5 2
      shared-lib/lib-ws/Cargo.toml
  42. 2 2
      shared-lib/lib-ws/build.rs

+ 0 - 1
frontend/app_flowy/packages/flowy_sdk/lib/dispatch/dispatch.dart

@@ -23,7 +23,6 @@ import 'package:flowy_sdk/protobuf/flowy-folder-data-model/protobuf.dart';
 import 'package:flowy_sdk/protobuf/flowy-collaboration/protobuf.dart';
 
 // ignore: unused_import
-import 'package:flowy_sdk/protobuf/lib-infra/protobuf.dart';
 import 'package:protobuf/protobuf.dart';
 import 'dart:convert' show utf8;
 import 'error.dart';

+ 0 - 1
frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-document/protobuf.dart

@@ -1 +0,0 @@
-// Auto-generated, do not edit 

+ 0 - 1
frontend/app_flowy/packages/flowy_sdk/lib/protobuf/lib-infra/protobuf.dart

@@ -1 +0,0 @@
-// Auto-generated, do not edit 

+ 0 - 310
frontend/app_flowy/packages/flowy_sdk/lib/protobuf/lib-ot/model.pb.dart

@@ -1,310 +0,0 @@
-///
-//  Generated code. Do not modify.
-//  source: model.proto
-//
-// @dart = 2.12
-// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
-
-import 'dart:core' as $core;
-
-import 'package:fixnum/fixnum.dart' as $fixnum;
-import 'package:protobuf/protobuf.dart' as $pb;
-
-import 'model.pbenum.dart';
-
-export 'model.pbenum.dart';
-
-class Revision extends $pb.GeneratedMessage {
-  static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'Revision', createEmptyInstance: create)
-    ..aInt64(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'baseRevId')
-    ..aInt64(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'revId')
-    ..a<$core.List<$core.int>>(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'deltaData', $pb.PbFieldType.OY)
-    ..aOS(4, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'md5')
-    ..aOS(5, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'docId')
-    ..e<RevType>(6, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'ty', $pb.PbFieldType.OE, defaultOrMaker: RevType.Local, valueOf: RevType.valueOf, enumValues: RevType.values)
-    ..aOS(7, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'userId')
-    ..hasRequiredFields = false
-  ;
-
-  Revision._() : super();
-  factory Revision({
-    $fixnum.Int64? baseRevId,
-    $fixnum.Int64? revId,
-    $core.List<$core.int>? deltaData,
-    $core.String? md5,
-    $core.String? docId,
-    RevType? ty,
-    $core.String? userId,
-  }) {
-    final _result = create();
-    if (baseRevId != null) {
-      _result.baseRevId = baseRevId;
-    }
-    if (revId != null) {
-      _result.revId = revId;
-    }
-    if (deltaData != null) {
-      _result.deltaData = deltaData;
-    }
-    if (md5 != null) {
-      _result.md5 = md5;
-    }
-    if (docId != null) {
-      _result.docId = docId;
-    }
-    if (ty != null) {
-      _result.ty = ty;
-    }
-    if (userId != null) {
-      _result.userId = userId;
-    }
-    return _result;
-  }
-  factory Revision.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
-  factory Revision.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
-  @$core.Deprecated(
-  'Using this can add significant overhead to your binary. '
-  'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
-  'Will be removed in next major version')
-  Revision clone() => Revision()..mergeFromMessage(this);
-  @$core.Deprecated(
-  'Using this can add significant overhead to your binary. '
-  'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
-  'Will be removed in next major version')
-  Revision copyWith(void Function(Revision) updates) => super.copyWith((message) => updates(message as Revision)) as Revision; // ignore: deprecated_member_use
-  $pb.BuilderInfo get info_ => _i;
-  @$core.pragma('dart2js:noInline')
-  static Revision create() => Revision._();
-  Revision createEmptyInstance() => create();
-  static $pb.PbList<Revision> createRepeated() => $pb.PbList<Revision>();
-  @$core.pragma('dart2js:noInline')
-  static Revision getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<Revision>(create);
-  static Revision? _defaultInstance;
-
-  @$pb.TagNumber(1)
-  $fixnum.Int64 get baseRevId => $_getI64(0);
-  @$pb.TagNumber(1)
-  set baseRevId($fixnum.Int64 v) { $_setInt64(0, v); }
-  @$pb.TagNumber(1)
-  $core.bool hasBaseRevId() => $_has(0);
-  @$pb.TagNumber(1)
-  void clearBaseRevId() => clearField(1);
-
-  @$pb.TagNumber(2)
-  $fixnum.Int64 get revId => $_getI64(1);
-  @$pb.TagNumber(2)
-  set revId($fixnum.Int64 v) { $_setInt64(1, v); }
-  @$pb.TagNumber(2)
-  $core.bool hasRevId() => $_has(1);
-  @$pb.TagNumber(2)
-  void clearRevId() => clearField(2);
-
-  @$pb.TagNumber(3)
-  $core.List<$core.int> get deltaData => $_getN(2);
-  @$pb.TagNumber(3)
-  set deltaData($core.List<$core.int> v) { $_setBytes(2, v); }
-  @$pb.TagNumber(3)
-  $core.bool hasDeltaData() => $_has(2);
-  @$pb.TagNumber(3)
-  void clearDeltaData() => clearField(3);
-
-  @$pb.TagNumber(4)
-  $core.String get md5 => $_getSZ(3);
-  @$pb.TagNumber(4)
-  set md5($core.String v) { $_setString(3, v); }
-  @$pb.TagNumber(4)
-  $core.bool hasMd5() => $_has(3);
-  @$pb.TagNumber(4)
-  void clearMd5() => clearField(4);
-
-  @$pb.TagNumber(5)
-  $core.String get docId => $_getSZ(4);
-  @$pb.TagNumber(5)
-  set docId($core.String v) { $_setString(4, v); }
-  @$pb.TagNumber(5)
-  $core.bool hasDocId() => $_has(4);
-  @$pb.TagNumber(5)
-  void clearDocId() => clearField(5);
-
-  @$pb.TagNumber(6)
-  RevType get ty => $_getN(5);
-  @$pb.TagNumber(6)
-  set ty(RevType v) { setField(6, v); }
-  @$pb.TagNumber(6)
-  $core.bool hasTy() => $_has(5);
-  @$pb.TagNumber(6)
-  void clearTy() => clearField(6);
-
-  @$pb.TagNumber(7)
-  $core.String get userId => $_getSZ(6);
-  @$pb.TagNumber(7)
-  set userId($core.String v) { $_setString(6, v); }
-  @$pb.TagNumber(7)
-  $core.bool hasUserId() => $_has(6);
-  @$pb.TagNumber(7)
-  void clearUserId() => clearField(7);
-}
-
-class RepeatedRevision extends $pb.GeneratedMessage {
-  static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'RepeatedRevision', createEmptyInstance: create)
-    ..pc<Revision>(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'items', $pb.PbFieldType.PM, subBuilder: Revision.create)
-    ..hasRequiredFields = false
-  ;
-
-  RepeatedRevision._() : super();
-  factory RepeatedRevision({
-    $core.Iterable<Revision>? items,
-  }) {
-    final _result = create();
-    if (items != null) {
-      _result.items.addAll(items);
-    }
-    return _result;
-  }
-  factory RepeatedRevision.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
-  factory RepeatedRevision.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
-  @$core.Deprecated(
-  'Using this can add significant overhead to your binary. '
-  'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
-  'Will be removed in next major version')
-  RepeatedRevision clone() => RepeatedRevision()..mergeFromMessage(this);
-  @$core.Deprecated(
-  'Using this can add significant overhead to your binary. '
-  'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
-  'Will be removed in next major version')
-  RepeatedRevision copyWith(void Function(RepeatedRevision) updates) => super.copyWith((message) => updates(message as RepeatedRevision)) as RepeatedRevision; // ignore: deprecated_member_use
-  $pb.BuilderInfo get info_ => _i;
-  @$core.pragma('dart2js:noInline')
-  static RepeatedRevision create() => RepeatedRevision._();
-  RepeatedRevision createEmptyInstance() => create();
-  static $pb.PbList<RepeatedRevision> createRepeated() => $pb.PbList<RepeatedRevision>();
-  @$core.pragma('dart2js:noInline')
-  static RepeatedRevision getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<RepeatedRevision>(create);
-  static RepeatedRevision? _defaultInstance;
-
-  @$pb.TagNumber(1)
-  $core.List<Revision> get items => $_getList(0);
-}
-
-class RevId extends $pb.GeneratedMessage {
-  static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'RevId', createEmptyInstance: create)
-    ..aInt64(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'value')
-    ..hasRequiredFields = false
-  ;
-
-  RevId._() : super();
-  factory RevId({
-    $fixnum.Int64? value,
-  }) {
-    final _result = create();
-    if (value != null) {
-      _result.value = value;
-    }
-    return _result;
-  }
-  factory RevId.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
-  factory RevId.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
-  @$core.Deprecated(
-  'Using this can add significant overhead to your binary. '
-  'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
-  'Will be removed in next major version')
-  RevId clone() => RevId()..mergeFromMessage(this);
-  @$core.Deprecated(
-  'Using this can add significant overhead to your binary. '
-  'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
-  'Will be removed in next major version')
-  RevId copyWith(void Function(RevId) updates) => super.copyWith((message) => updates(message as RevId)) as RevId; // ignore: deprecated_member_use
-  $pb.BuilderInfo get info_ => _i;
-  @$core.pragma('dart2js:noInline')
-  static RevId create() => RevId._();
-  RevId createEmptyInstance() => create();
-  static $pb.PbList<RevId> createRepeated() => $pb.PbList<RevId>();
-  @$core.pragma('dart2js:noInline')
-  static RevId getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<RevId>(create);
-  static RevId? _defaultInstance;
-
-  @$pb.TagNumber(1)
-  $fixnum.Int64 get value => $_getI64(0);
-  @$pb.TagNumber(1)
-  set value($fixnum.Int64 v) { $_setInt64(0, v); }
-  @$pb.TagNumber(1)
-  $core.bool hasValue() => $_has(0);
-  @$pb.TagNumber(1)
-  void clearValue() => clearField(1);
-}
-
-class RevisionRange extends $pb.GeneratedMessage {
-  static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'RevisionRange', createEmptyInstance: create)
-    ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'docId')
-    ..aInt64(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'start')
-    ..aInt64(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'end')
-    ..hasRequiredFields = false
-  ;
-
-  RevisionRange._() : super();
-  factory RevisionRange({
-    $core.String? docId,
-    $fixnum.Int64? start,
-    $fixnum.Int64? end,
-  }) {
-    final _result = create();
-    if (docId != null) {
-      _result.docId = docId;
-    }
-    if (start != null) {
-      _result.start = start;
-    }
-    if (end != null) {
-      _result.end = end;
-    }
-    return _result;
-  }
-  factory RevisionRange.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
-  factory RevisionRange.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
-  @$core.Deprecated(
-  'Using this can add significant overhead to your binary. '
-  'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
-  'Will be removed in next major version')
-  RevisionRange clone() => RevisionRange()..mergeFromMessage(this);
-  @$core.Deprecated(
-  'Using this can add significant overhead to your binary. '
-  'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
-  'Will be removed in next major version')
-  RevisionRange copyWith(void Function(RevisionRange) updates) => super.copyWith((message) => updates(message as RevisionRange)) as RevisionRange; // ignore: deprecated_member_use
-  $pb.BuilderInfo get info_ => _i;
-  @$core.pragma('dart2js:noInline')
-  static RevisionRange create() => RevisionRange._();
-  RevisionRange createEmptyInstance() => create();
-  static $pb.PbList<RevisionRange> createRepeated() => $pb.PbList<RevisionRange>();
-  @$core.pragma('dart2js:noInline')
-  static RevisionRange getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<RevisionRange>(create);
-  static RevisionRange? _defaultInstance;
-
-  @$pb.TagNumber(1)
-  $core.String get docId => $_getSZ(0);
-  @$pb.TagNumber(1)
-  set docId($core.String v) { $_setString(0, v); }
-  @$pb.TagNumber(1)
-  $core.bool hasDocId() => $_has(0);
-  @$pb.TagNumber(1)
-  void clearDocId() => clearField(1);
-
-  @$pb.TagNumber(2)
-  $fixnum.Int64 get start => $_getI64(1);
-  @$pb.TagNumber(2)
-  set start($fixnum.Int64 v) { $_setInt64(1, v); }
-  @$pb.TagNumber(2)
-  $core.bool hasStart() => $_has(1);
-  @$pb.TagNumber(2)
-  void clearStart() => clearField(2);
-
-  @$pb.TagNumber(3)
-  $fixnum.Int64 get end => $_getI64(2);
-  @$pb.TagNumber(3)
-  set end($fixnum.Int64 v) { $_setInt64(2, v); }
-  @$pb.TagNumber(3)
-  $core.bool hasEnd() => $_has(2);
-  @$pb.TagNumber(3)
-  void clearEnd() => clearField(3);
-}
-

+ 0 - 41
frontend/app_flowy/packages/flowy_sdk/lib/protobuf/lib-ot/model.pbenum.dart

@@ -1,41 +0,0 @@
-///
-//  Generated code. Do not modify.
-//  source: model.proto
-//
-// @dart = 2.12
-// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields
-
-// ignore_for_file: UNDEFINED_SHOWN_NAME
-import 'dart:core' as $core;
-import 'package:protobuf/protobuf.dart' as $pb;
-
-class RevType extends $pb.ProtobufEnum {
-  static const RevType Local = RevType._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'Local');
-  static const RevType Remote = RevType._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'Remote');
-
-  static const $core.List<RevType> values = <RevType> [
-    Local,
-    Remote,
-  ];
-
-  static final $core.Map<$core.int, RevType> _byValue = $pb.ProtobufEnum.initByValue(values);
-  static RevType? valueOf($core.int value) => _byValue[value];
-
-  const RevType._($core.int v, $core.String n) : super(v, n);
-}
-
-class RevState extends $pb.ProtobufEnum {
-  static const RevState StateLocal = RevState._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'StateLocal');
-  static const RevState Ack = RevState._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'Ack');
-
-  static const $core.List<RevState> values = <RevState> [
-    StateLocal,
-    Ack,
-  ];
-
-  static final $core.Map<$core.int, RevState> _byValue = $pb.ProtobufEnum.initByValue(values);
-  static RevState? valueOf($core.int value) => _byValue[value];
-
-  const RevState._($core.int v, $core.String n) : super(v, n);
-}
-

+ 0 - 80
frontend/app_flowy/packages/flowy_sdk/lib/protobuf/lib-ot/model.pbjson.dart

@@ -1,80 +0,0 @@
-///
-//  Generated code. Do not modify.
-//  source: model.proto
-//
-// @dart = 2.12
-// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package
-
-import 'dart:core' as $core;
-import 'dart:convert' as $convert;
-import 'dart:typed_data' as $typed_data;
-@$core.Deprecated('Use revTypeDescriptor instead')
-const RevType$json = const {
-  '1': 'RevType',
-  '2': const [
-    const {'1': 'Local', '2': 0},
-    const {'1': 'Remote', '2': 1},
-  ],
-};
-
-/// Descriptor for `RevType`. Decode as a `google.protobuf.EnumDescriptorProto`.
-final $typed_data.Uint8List revTypeDescriptor = $convert.base64Decode('CgdSZXZUeXBlEgkKBUxvY2FsEAASCgoGUmVtb3RlEAE=');
-@$core.Deprecated('Use revStateDescriptor instead')
-const RevState$json = const {
-  '1': 'RevState',
-  '2': const [
-    const {'1': 'StateLocal', '2': 0},
-    const {'1': 'Ack', '2': 1},
-  ],
-};
-
-/// Descriptor for `RevState`. Decode as a `google.protobuf.EnumDescriptorProto`.
-final $typed_data.Uint8List revStateDescriptor = $convert.base64Decode('CghSZXZTdGF0ZRIOCgpTdGF0ZUxvY2FsEAASBwoDQWNrEAE=');
-@$core.Deprecated('Use revisionDescriptor instead')
-const Revision$json = const {
-  '1': 'Revision',
-  '2': const [
-    const {'1': 'base_rev_id', '3': 1, '4': 1, '5': 3, '10': 'baseRevId'},
-    const {'1': 'rev_id', '3': 2, '4': 1, '5': 3, '10': 'revId'},
-    const {'1': 'delta_data', '3': 3, '4': 1, '5': 12, '10': 'deltaData'},
-    const {'1': 'md5', '3': 4, '4': 1, '5': 9, '10': 'md5'},
-    const {'1': 'doc_id', '3': 5, '4': 1, '5': 9, '10': 'docId'},
-    const {'1': 'ty', '3': 6, '4': 1, '5': 14, '6': '.RevType', '10': 'ty'},
-    const {'1': 'user_id', '3': 7, '4': 1, '5': 9, '10': 'userId'},
-  ],
-};
-
-/// Descriptor for `Revision`. Decode as a `google.protobuf.DescriptorProto`.
-final $typed_data.Uint8List revisionDescriptor = $convert.base64Decode('CghSZXZpc2lvbhIeCgtiYXNlX3Jldl9pZBgBIAEoA1IJYmFzZVJldklkEhUKBnJldl9pZBgCIAEoA1IFcmV2SWQSHQoKZGVsdGFfZGF0YRgDIAEoDFIJZGVsdGFEYXRhEhAKA21kNRgEIAEoCVIDbWQ1EhUKBmRvY19pZBgFIAEoCVIFZG9jSWQSGAoCdHkYBiABKA4yCC5SZXZUeXBlUgJ0eRIXCgd1c2VyX2lkGAcgASgJUgZ1c2VySWQ=');
-@$core.Deprecated('Use repeatedRevisionDescriptor instead')
-const RepeatedRevision$json = const {
-  '1': 'RepeatedRevision',
-  '2': const [
-    const {'1': 'items', '3': 1, '4': 3, '5': 11, '6': '.Revision', '10': 'items'},
-  ],
-};
-
-/// Descriptor for `RepeatedRevision`. Decode as a `google.protobuf.DescriptorProto`.
-final $typed_data.Uint8List repeatedRevisionDescriptor = $convert.base64Decode('ChBSZXBlYXRlZFJldmlzaW9uEh8KBWl0ZW1zGAEgAygLMgkuUmV2aXNpb25SBWl0ZW1z');
-@$core.Deprecated('Use revIdDescriptor instead')
-const RevId$json = const {
-  '1': 'RevId',
-  '2': const [
-    const {'1': 'value', '3': 1, '4': 1, '5': 3, '10': 'value'},
-  ],
-};
-
-/// Descriptor for `RevId`. Decode as a `google.protobuf.DescriptorProto`.
-final $typed_data.Uint8List revIdDescriptor = $convert.base64Decode('CgVSZXZJZBIUCgV2YWx1ZRgBIAEoA1IFdmFsdWU=');
-@$core.Deprecated('Use revisionRangeDescriptor instead')
-const RevisionRange$json = const {
-  '1': 'RevisionRange',
-  '2': const [
-    const {'1': 'doc_id', '3': 1, '4': 1, '5': 9, '10': 'docId'},
-    const {'1': 'start', '3': 2, '4': 1, '5': 3, '10': 'start'},
-    const {'1': 'end', '3': 3, '4': 1, '5': 3, '10': 'end'},
-  ],
-};
-
-/// Descriptor for `RevisionRange`. Decode as a `google.protobuf.DescriptorProto`.
-final $typed_data.Uint8List revisionRangeDescriptor = $convert.base64Decode('Cg1SZXZpc2lvblJhbmdlEhUKBmRvY19pZBgBIAEoCVIFZG9jSWQSFAoFc3RhcnQYAiABKANSBXN0YXJ0EhAKA2VuZBgDIAEoA1IDZW5k');

+ 0 - 9
frontend/app_flowy/packages/flowy_sdk/lib/protobuf/lib-ot/model.pbserver.dart

@@ -1,9 +0,0 @@
-///
-//  Generated code. Do not modify.
-//  source: model.proto
-//
-// @dart = 2.12
-// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package
-
-export 'model.pb.dart';
-

+ 0 - 2
frontend/app_flowy/packages/flowy_sdk/lib/protobuf/lib-ot/protobuf.dart

@@ -1,2 +0,0 @@
-// Auto-generated, do not edit 
-export './model.pb.dart';

+ 0 - 21
frontend/rust-lib/Cargo.lock

@@ -214,17 +214,6 @@ dependencies = [
  "serde",
 ]
 
-[[package]]
-name = "cargo_toml"
-version = "0.11.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4e270ef0cd868745878982f7ce470aa898d0d4bb248af67f0cf66f54617913ef"
-dependencies = [
- "serde",
- "serde_derive",
- "toml",
-]
-
 [[package]]
 name = "cast"
 version = "0.2.7"
@@ -1572,7 +1561,6 @@ name = "lib-infra"
 version = "0.1.0"
 dependencies = [
  "bytes",
- "cargo_toml",
  "chrono",
  "cmd_lib",
  "futures-core",
@@ -2836,15 +2824,6 @@ dependencies = [
  "tokio",
 ]
 
-[[package]]
-name = "toml"
-version = "0.5.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa"
-dependencies = [
- "serde",
-]
-
 [[package]]
 name = "tower-service"
 version = "0.3.1"

+ 2 - 2
frontend/rust-lib/dart-ffi/Cargo.toml

@@ -24,7 +24,7 @@ bytes = { version = "1.0" }
 once_cell = "1"
 
 lib-dispatch = {path = "../lib-dispatch" }
-flowy-sdk = {path = "../flowy-sdk"}
+flowy-sdk = {path = "../flowy-sdk", features = ["dart"]}
 dart-notify = {path = "../dart-notify" }
 flowy-derive = {path = "../../../shared-lib/flowy-derive" }
 
@@ -35,4 +35,4 @@ http_server = ["flowy-sdk/http_server", "flowy-sdk/use_bunyan"]
 #use_protobuf= ["protobuf"]
 
 [build-dependencies]
-lib-infra = { path = "../../../shared-lib/lib-infra", features = ["gen_pb"] }
+lib-infra = { path = "../../../shared-lib/lib-infra", features = ["pb_gen", "dart"] }

+ 2 - 2
frontend/rust-lib/dart-ffi/build.rs

@@ -1,5 +1,5 @@
-use lib_infra::pb;
+use lib_infra::pb_gen;
 
 fn main() {
-    pb::gen("dart-ffi", "./src/protobuf/proto");
+    pb_gen::gen("dart-ffi", "./src/protobuf/proto");
 }

+ 2 - 2
frontend/rust-lib/dart-notify/Cargo.toml

@@ -16,7 +16,7 @@ flowy-derive = {path = "../../../shared-lib/flowy-derive" }
 lib-dispatch = {path = "../lib-dispatch" }
 
 [features]
-dart = []
+dart = ["lib-infra/dart"]
 
 [build-dependencies]
-lib-infra = { path = "../../../shared-lib/lib-infra", features = ["gen_pb"] }
+lib-infra = { path = "../../../shared-lib/lib-infra", features = ["pb_gen"] }

+ 2 - 2
frontend/rust-lib/dart-notify/build.rs

@@ -1,5 +1,5 @@
-use lib_infra::pb;
+use lib_infra::pb_gen;
 
 fn main() {
-    pb::gen("dart-notify", "./src/protobuf/proto");
+    pb_gen::gen("dart-notify", "./src/protobuf/proto");
 }

+ 1 - 2
frontend/rust-lib/flowy-document/Cargo.toml

@@ -7,7 +7,7 @@ edition = "2018"
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 [dependencies]
-flowy-collaboration = { path = "../../../shared-lib/flowy-collaboration" }
+flowy-collaboration = { path = "../../../shared-lib/flowy-collaboration"}
 flowy-derive = { path = "../../../shared-lib/flowy-derive" }
 lib-ot = { path = "../../../shared-lib/lib-ot" }
 lib-ws = { path = "../../../shared-lib/lib-ws" }
@@ -52,7 +52,6 @@ color-eyre = { version = "0.5", default-features = false }
 criterion = "0.3"
 rand = "0.7.3"
 
-
 [features]
 http_server = []
 flowy_unit_test = ["lib-ot/flowy_unit_test", "flowy-sync/flowy_unit_test"]

+ 3 - 2
frontend/rust-lib/flowy-error/Cargo.toml

@@ -7,7 +7,7 @@ edition = "2018"
 
 [dependencies]
 flowy-derive = { path = "../../../shared-lib/flowy-derive" }
-error-code = { path = "../../../shared-lib/error-code" }
+error-code = { path = "../../../shared-lib/error-code"}
 lib-dispatch = { path = "../lib-dispatch" }
 protobuf = {version = "2.20.0"}
 bytes = "1.0"
@@ -27,6 +27,7 @@ ot = ["lib-ot"]
 serde = ["serde_json"]
 http_server = ["http-flowy"]
 db = ["flowy-database", "lib-sqlite", "r2d2"]
+dart = ["error-code/dart", "lib-infra/dart"]
 
 [build-dependencies]
-lib-infra = { path = "../../../shared-lib/lib-infra", features = ["gen_pb"] }
+lib-infra = { path = "../../../shared-lib/lib-infra", features = ["pb_gen"] }

+ 2 - 2
frontend/rust-lib/flowy-error/build.rs

@@ -1,5 +1,5 @@
-use lib_infra::pb;
+use lib_infra::pb_gen;
 
 fn main() {
-    pb::gen("flowy-error", "./src/protobuf/proto");
+    pb_gen::gen("flowy-error", "./src/protobuf/proto");
 }

+ 2 - 1
frontend/rust-lib/flowy-folder/Cargo.toml

@@ -53,6 +53,7 @@ flowy-test = { path = "../flowy-test" }
 default = []
 http_server = []
 flowy_unit_test = ["lib-ot/flowy_unit_test", "flowy-sync/flowy_unit_test"]
+dart = ["lib-infra/dart", "flowy-folder/dart", "flowy-folder/dart",]
 
 [build-dependencies]
-lib-infra = { path = "../../../shared-lib/lib-infra", features = ["gen_pb"] }
+lib-infra = { path = "../../../shared-lib/lib-infra", features = ["pb_gen"] }

+ 2 - 2
frontend/rust-lib/flowy-folder/build.rs

@@ -1,5 +1,5 @@
-use lib_infra::pb;
+use lib_infra::pb_gen;
 
 fn main() {
-    pb::gen("flowy-folder", "./src/protobuf/proto");
+    pb_gen::gen("flowy-folder", "./src/protobuf/proto");
 }

+ 10 - 2
frontend/rust-lib/flowy-net/Cargo.toml

@@ -10,7 +10,7 @@ lib-dispatch = { path = "../lib-dispatch" }
 flowy-error = { path = "../flowy-error", features = ["collaboration", "http_server"] }
 flowy-derive = { path = "../../../shared-lib/flowy-derive" }
 flowy-collaboration = { path = "../../../shared-lib/flowy-collaboration"}
-flowy-folder-data-model = { path = "../../../shared-lib/flowy-folder-data-model" }
+flowy-folder-data-model = { path = "../../../shared-lib/flowy-folder-data-model"}
 flowy-user-data-model = { path = "../../../shared-lib/flowy-user-data-model"}
 flowy-folder = { path = "../flowy-folder" }
 flowy-user = { path = "../flowy-user" }
@@ -40,6 +40,14 @@ serde_json = "1.0"
 
 [features]
 http_server = []
+dart = [
+    "lib-infra/dart",
+    "flowy-user/dart",
+    "flowy-collaboration/dart",
+    "flowy-error/dart",
+    "flowy-user-data-model/dart",
+    "flowy-folder-data-model/dart"
+]
 
 [build-dependencies]
-lib-infra = { path = "../../../shared-lib/lib-infra", features = ["gen_pb"] }
+lib-infra = { path = "../../../shared-lib/lib-infra", features = ["pb_gen"] }

+ 2 - 2
frontend/rust-lib/flowy-net/build.rs

@@ -1,5 +1,5 @@
-use lib_infra::pb;
+use lib_infra::pb_gen;
 
 fn main() {
-    pb::gen("flowy-net", "./src/protobuf/proto");
+    pb_gen::gen("flowy-net", "./src/protobuf/proto");
 }

+ 2 - 1
frontend/rust-lib/flowy-sdk/Cargo.toml

@@ -38,4 +38,5 @@ futures-util = "0.3.15"
 
 [features]
 http_server = ["flowy-user/http_server", "flowy-folder/http_server", "flowy-document/http_server"]
-use_bunyan = ["lib-log/use_bunyan"]
+use_bunyan = ["lib-log/use_bunyan"]
+dart = ["flowy-user/dart", "flowy-net/dart", "flowy-folder/dart", "flowy-collaboration/dart"]

+ 4 - 1
frontend/rust-lib/flowy-test/Cargo.toml

@@ -33,4 +33,7 @@ quickcheck_macros = "0.9.1"
 fake = "~2.3.0"
 claim = "0.4.0"
 futures = "0.3.15"
-serial_test = "0.5.1"
+serial_test = "0.5.1"
+
+[features]
+dart = ["flowy-sdk/dart"]

+ 2 - 1
frontend/rust-lib/flowy-user/Cargo.toml

@@ -45,6 +45,7 @@ serial_test = "0.5.1"
 
 [features]
 http_server = []
+dart = ["lib-infra/dart"]
 
 [build-dependencies]
-lib-infra = { path = "../../../shared-lib/lib-infra", features = ["gen_pb"] }
+lib-infra = { path = "../../../shared-lib/lib-infra", features = ["pb_gen"] }

+ 2 - 2
frontend/rust-lib/flowy-user/build.rs

@@ -1,5 +1,5 @@
-use lib_infra::pb;
+use lib_infra::pb_gen;
 
 fn main() {
-    pb::gen("flowy-user", "./src/protobuf/proto");
+    pb_gen::gen("flowy-user", "./src/protobuf/proto");
 }

+ 11 - 8
frontend/scripts/flowy-tool/src/proto/proto_gen.rs

@@ -1,3 +1,8 @@
+#![allow(clippy::all)]
+#![allow(unused_attributes)]
+#![allow(dead_code)]
+#![allow(unused_imports)]
+#![allow(unused_results)]
 use crate::proto::ast::*;
 use crate::proto::proto_info::*;
 use crate::{proto::template::*, util::*};
@@ -15,15 +20,13 @@ impl ProtoGen {
         let crate_proto_infos = parse_crate_protobuf(self.rust_source_dirs.clone());
         write_proto_files(&crate_proto_infos);
 
-        // TODO: ignore unchanged file to reduce time cost
-        run_rust_protoc(&crate_proto_infos);
-        write_rust_crate_mod_file(&crate_proto_infos);
-        write_derive_meta(&crate_proto_infos, self.derive_meta_dir.as_ref());
+        // run_rust_protoc(&crate_proto_infos);
+        // write_rust_crate_mod_file(&crate_proto_infos);
+        // write_derive_meta(&crate_proto_infos, self.derive_meta_dir.as_ref());
 
-        // TODO: ignore unchanged file to reduce time cost
-        let flutter_package = FlutterProtobufInfo::new(self.flutter_package_lib.as_ref());
-        run_flutter_protoc(&crate_proto_infos, &flutter_package);
-        write_flutter_protobuf_package_mod_file(&crate_proto_infos, &flutter_package);
+        // let flutter_package = FlutterProtobufInfo::new(self.flutter_package_lib.as_ref());
+        // run_flutter_protoc(&crate_proto_infos, &flutter_package);
+        // write_flutter_protobuf_package_mod_file(&crate_proto_infos, &flutter_package);
     }
 }
 

+ 3 - 0
frontend/scripts/flowy-tool/src/proto/proto_info.rs

@@ -1,3 +1,6 @@
+#![allow(clippy::all)]
+#![allow(dead_code)]
+#![allow(unused_imports)]
 use crate::util::*;
 use std::fs::OpenOptions;
 use std::io::Write;

+ 5 - 0
frontend/scripts/flowy-tool/src/proto/template/derive_meta/derive_meta.rs

@@ -1,3 +1,8 @@
+#![allow(clippy::all)]
+#![allow(unused_attributes)]
+#![allow(dead_code)]
+#![allow(unused_imports)]
+#![allow(unused_results)]
 use crate::proto::proto_info::{CrateProtoInfo, ProtoFile};
 use crate::util::{get_tera, read_file};
 use itertools::Itertools;

+ 0 - 12
shared-lib/Cargo.lock

@@ -109,17 +109,6 @@ version = "1.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8"
 
-[[package]]
-name = "cargo_toml"
-version = "0.11.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4e270ef0cd868745878982f7ce470aa898d0d4bb248af67f0cf66f54617913ef"
-dependencies = [
- "serde",
- "serde_derive",
- "toml",
-]
-
 [[package]]
 name = "cfg-if"
 version = "1.0.0"
@@ -623,7 +612,6 @@ name = "lib-infra"
 version = "0.1.0"
 dependencies = [
  "bytes",
- "cargo_toml",
  "chrono",
  "cmd_lib",
  "futures-core",

+ 4 - 1
shared-lib/error-code/Cargo.toml

@@ -11,4 +11,7 @@ protobuf = {version = "2.18.0"}
 derive_more = {version = "0.99", features = ["display"]}
 
 [build-dependencies]
-lib-infra = { path = "../lib-infra", features = ["gen_pb"] }
+lib-infra = { path = "../lib-infra", features = ["pb_gen"] }
+
+[features]
+dart = ["lib-infra/dart"]

+ 2 - 2
shared-lib/error-code/build.rs

@@ -1,5 +1,5 @@
-use lib_infra::pb;
+use lib_infra::pb_gen;
 
 fn main() {
-    pb::gen("error-code", "./src/protobuf/proto");
+    pb_gen::gen("error-code", "./src/protobuf/proto");
 }

+ 4 - 1
shared-lib/flowy-collaboration/Cargo.toml

@@ -29,4 +29,7 @@ futures = "0.3.15"
 async-stream = "0.3.2"
 
 [build-dependencies]
-lib-infra = { path = "../lib-infra", features = ["gen_pb"] }
+lib-infra = { path = "../lib-infra", features = ["pb_gen"] }
+
+[features]
+dart = ["lib-infra/dart"]

+ 2 - 2
shared-lib/flowy-collaboration/build.rs

@@ -1,5 +1,5 @@
-use lib_infra::pb;
+use lib_infra::pb_gen;
 
 fn main() {
-    pb::gen("flowy-collaboration", "./src/protobuf/proto");
+    pb_gen::gen("flowy-collaboration", "./src/protobuf/proto");
 }

+ 4 - 3
shared-lib/flowy-folder-data-model/Cargo.toml

@@ -16,14 +16,15 @@ derive_more = {version = "0.99", features = ["display"]}
 log = "0.4.14"
 uuid = { version = "0.8", features = ["serde", "v4"] }
 chrono = { version = "0.4" }
-error-code = { path = "../error-code" }
+error-code = { path = "../error-code"}
 serde = { version = "1.0", features = ["derive"] }
 serde_json = "1.0"
 
 [build-dependencies]
-lib-infra = { path = "../lib-infra", features = ["gen_pb"] }
+lib-infra = { path = "../lib-infra", features = ["pb_gen"] }
 
 [features]
 default = []
 backend = []
-frontend = []
+frontend = []
+dart = ["lib-infra/dart", "error-code/dart"]

+ 2 - 2
shared-lib/flowy-folder-data-model/build.rs

@@ -1,5 +1,5 @@
-use lib_infra::pb;
+use lib_infra::pb_gen;
 
 fn main() {
-    pb::gen("flowy-folder-data-model", "./src/protobuf/proto");
+    pb_gen::gen("flowy-folder-data-model", "./src/protobuf/proto");
 }

+ 5 - 2
shared-lib/flowy-user-data-model/Cargo.toml

@@ -19,7 +19,7 @@ fancy-regex = "0.5.0"
 lazy_static = "1.4"
 
 [build-dependencies]
-lib-infra = { path = "../lib-infra", features = ["gen_pb"] }
+lib-infra = { path = "../lib-infra", features = ["pb_gen"] }
 
 [dev-dependencies]
 quickcheck = "0.9.2"
@@ -27,4 +27,7 @@ quickcheck_macros = "0.9.1"
 fake = "~2.3.0"
 claim = "0.4.0"
 futures = "0.3.15"
-serial_test = "0.5.1"
+serial_test = "0.5.1"
+
+[features]
+dart = ["lib-infra/dart", "error-code/dart"]

+ 2 - 2
shared-lib/flowy-user-data-model/build.rs

@@ -1,5 +1,5 @@
-use lib_infra::pb;
+use lib_infra::pb_gen;
 
 fn main() {
-    pb::gen("flowy-user-data-model", "./src/protobuf/proto");
+    pb_gen::gen("flowy-user-data-model", "./src/protobuf/proto");
 }

+ 2 - 2
shared-lib/lib-infra/Cargo.toml

@@ -16,9 +16,9 @@ tokio = { version = "1.0", features = ["time", "rt"] }
 rand = "0.8.3"
 
 cmd_lib = { version = "1", optional = true }
-cargo_toml = { version = "0.11", optional = true }
 protoc-rust = { version = "2", optional = true }
 walkdir = { version = "2", optional = true }
 
 [features]
-gen_pb = ["cmd_lib","cargo_toml", "protoc-rust", "walkdir"]
+pb_gen = ["cmd_lib", "protoc-rust", "walkdir"]
+dart = []

+ 2 - 2
shared-lib/lib-infra/src/lib.rs

@@ -1,8 +1,8 @@
 pub mod future;
 pub mod retry;
 
-#[cfg(feature = "gen_pb")]
-pub mod pb;
+#[cfg(feature = "pb_gen")]
+pub mod pb_gen;
 
 #[allow(dead_code)]
 pub fn uuid_string() -> String {

+ 0 - 38
shared-lib/lib-infra/src/pb.rs

@@ -1,38 +0,0 @@
-use walkdir::WalkDir;
-
-pub fn gen(name: &str, root: &str) {
-    let mut paths = vec![];
-    for path in WalkDir::new(root)
-        .into_iter()
-        .filter_map(|e| e.ok())
-        .map(|e| e.path().to_str().unwrap().to_string())
-    {
-        if path.ends_with(".proto") {
-            // https://stackoverflow.com/questions/49077147/how-can-i-force-build-rs-to-run-again-without-cleaning-my-whole-project
-            println!("cargo:rerun-if-changed={}", path);
-            paths.push(path);
-        }
-    }
-    let flutter_pb_path = format!(
-        "{}/{}/{}",
-        env!("CARGO_MAKE_WORKING_DIRECTORY"),
-        env!("FLUTTER_FLOWY_SDK_PATH"),
-        name
-    );
-    paths.iter().for_each(|path| {
-        if cmd_lib::run_cmd! {
-            protoc --dart_out=${flutter_pb_path} --proto_path=${root} ${path}
-        }
-        .is_err()
-        {
-            panic!("Run flutter protoc fail")
-        };
-    });
-
-    protoc_rust::Codegen::new()
-        .out_dir("./src/protobuf/model")
-        .inputs(&paths)
-        .include(root)
-        .run()
-        .expect("Running protoc failed.");
-}

+ 77 - 0
shared-lib/lib-infra/src/pb_gen.rs

@@ -0,0 +1,77 @@
+#![allow(unused_imports)]
+use std::fs::File;
+use std::io::Write;
+use walkdir::WalkDir;
+
+pub fn gen(name: &str, root: &str) {
+    let mut paths = vec![];
+    let mut file_names = vec![];
+    for (path, file_name) in WalkDir::new(root).into_iter().filter_map(|e| e.ok()).map(|e| {
+        let path = e.path().to_str().unwrap().to_string();
+        let file_name = e.path().file_stem().unwrap().to_str().unwrap().to_string();
+        (path, file_name)
+    }) {
+        if path.ends_with(".proto") {
+            // https://stackoverflow.com/questions/49077147/how-can-i-force-build-rs-to-run-again-without-cleaning-my-whole-project
+            println!("cargo:rerun-if-changed={}", path);
+            paths.push(path);
+            file_names.push(file_name);
+        }
+    }
+
+    #[cfg(feature = "dart")]
+    gen_pb_for_dart(name, root, &paths, &file_names);
+
+    protoc_rust::Codegen::new()
+        .out_dir("./src/protobuf/model")
+        .inputs(&paths)
+        .include(root)
+        .run()
+        .expect("Running protoc failed.");
+}
+
+#[cfg(feature = "dart")]
+fn gen_pb_for_dart(name: &str, root: &str, paths: &Vec<String>, file_names: &Vec<String>) {
+    let output = format!(
+        "{}/{}/{}",
+        env!("CARGO_MAKE_WORKING_DIRECTORY"),
+        env!("FLUTTER_FLOWY_SDK_PATH"),
+        name
+    );
+    if !std::path::Path::new(&output).exists() {
+        std::fs::create_dir_all(&output).unwrap();
+    }
+    paths.iter().for_each(|path| {
+        if cmd_lib::run_cmd! {
+            protoc --dart_out=${output} --proto_path=${root} ${path}
+        }
+        .is_err()
+        {
+            panic!("Run flutter protoc fail")
+        };
+    });
+
+    let protobuf_dart = format!("{}/protobuf.dart", output);
+    match std::fs::OpenOptions::new()
+        .create(true)
+        .write(true)
+        .append(false)
+        .truncate(true)
+        .open(&protobuf_dart)
+    {
+        Ok(ref mut file) => {
+            let mut export = String::new();
+            export.push_str("// Auto-generated, do not edit \n");
+            for file_name in file_names {
+                let c = format!("export './{}.pb.dart';\n", file_name);
+                export.push_str(c.as_ref());
+            }
+
+            file.write_all(export.as_bytes()).unwrap();
+            File::flush(file).unwrap();
+        }
+        Err(err) => {
+            panic!("Failed to open file: {}", err);
+        }
+    }
+}

+ 5 - 2
shared-lib/lib-ws/Cargo.toml

@@ -28,8 +28,11 @@ parking_lot = "0.11"
 dashmap = "4.0"
 
 [build-dependencies]
-lib-infra = { path = "../lib-infra", features = ["gen_pb"] }
+lib-infra = { path = "../lib-infra", features = ["pb_gen"] }
 
 [dev-dependencies]
 tokio = {version = "1", features = ["full"]}
-env_logger = "0.8.2"
+env_logger = "0.8.2"
+
+[features]
+dart = ["lib-infra/dart"]

+ 2 - 2
shared-lib/lib-ws/build.rs

@@ -1,5 +1,5 @@
-use lib_infra::pb;
+use lib_infra::pb_gen;
 
 fn main() {
-    pb::gen("lib-ws", "./src/protobuf/proto");
+    pb_gen::gen("lib-ws", "./src/protobuf/proto");
 }