diff --git a/frontend/app_flowy/packages/flowy_sdk/lib/dispatch/dispatch.dart b/frontend/app_flowy/packages/flowy_sdk/lib/dispatch/dispatch.dart index 62908d3ac5..e78641d0fb 100644 --- a/frontend/app_flowy/packages/flowy_sdk/lib/dispatch/dispatch.dart +++ b/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'; diff --git a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-document/protobuf.dart b/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-document/protobuf.dart deleted file mode 100644 index 58506e3e5f..0000000000 --- a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-document/protobuf.dart +++ /dev/null @@ -1 +0,0 @@ -// Auto-generated, do not edit diff --git a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/lib-infra/protobuf.dart b/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/lib-infra/protobuf.dart deleted file mode 100644 index 58506e3e5f..0000000000 --- a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/lib-infra/protobuf.dart +++ /dev/null @@ -1 +0,0 @@ -// Auto-generated, do not edit diff --git a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/lib-ot/model.pb.dart b/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/lib-ot/model.pb.dart deleted file mode 100644 index 7ade684beb..0000000000 --- a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/lib-ot/model.pb.dart +++ /dev/null @@ -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(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 createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static Revision getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(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(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'items', $pb.PbFieldType.PM, subBuilder: Revision.create) - ..hasRequiredFields = false - ; - - RepeatedRevision._() : super(); - factory RepeatedRevision({ - $core.Iterable? 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 createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static RepeatedRevision getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static RepeatedRevision? _defaultInstance; - - @$pb.TagNumber(1) - $core.List 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 createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static RevId getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(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 createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static RevisionRange getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(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); -} - diff --git a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/lib-ot/model.pbenum.dart b/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/lib-ot/model.pbenum.dart deleted file mode 100644 index dea5bb4a27..0000000000 --- a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/lib-ot/model.pbenum.dart +++ /dev/null @@ -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 values = [ - 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 values = [ - 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); -} - diff --git a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/lib-ot/model.pbjson.dart b/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/lib-ot/model.pbjson.dart deleted file mode 100644 index aeeff92034..0000000000 --- a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/lib-ot/model.pbjson.dart +++ /dev/null @@ -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'); diff --git a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/lib-ot/model.pbserver.dart b/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/lib-ot/model.pbserver.dart deleted file mode 100644 index 0a058aba64..0000000000 --- a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/lib-ot/model.pbserver.dart +++ /dev/null @@ -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'; - diff --git a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/lib-ot/protobuf.dart b/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/lib-ot/protobuf.dart deleted file mode 100644 index f524faf0c8..0000000000 --- a/frontend/app_flowy/packages/flowy_sdk/lib/protobuf/lib-ot/protobuf.dart +++ /dev/null @@ -1,2 +0,0 @@ -// Auto-generated, do not edit -export './model.pb.dart'; diff --git a/frontend/rust-lib/Cargo.lock b/frontend/rust-lib/Cargo.lock index 90bbc15fc5..13675046cc 100755 --- a/frontend/rust-lib/Cargo.lock +++ b/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" diff --git a/frontend/rust-lib/dart-ffi/Cargo.toml b/frontend/rust-lib/dart-ffi/Cargo.toml index 74fa95726f..9d733b13e5 100644 --- a/frontend/rust-lib/dart-ffi/Cargo.toml +++ b/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"] } \ No newline at end of file +lib-infra = { path = "../../../shared-lib/lib-infra", features = ["pb_gen", "dart"] } \ No newline at end of file diff --git a/frontend/rust-lib/dart-ffi/build.rs b/frontend/rust-lib/dart-ffi/build.rs index 8708af08ad..3fe5e908d3 100644 --- a/frontend/rust-lib/dart-ffi/build.rs +++ b/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"); } diff --git a/frontend/rust-lib/dart-notify/Cargo.toml b/frontend/rust-lib/dart-notify/Cargo.toml index 3210c3d5a0..0d0cddf676 100644 --- a/frontend/rust-lib/dart-notify/Cargo.toml +++ b/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"] } \ No newline at end of file +lib-infra = { path = "../../../shared-lib/lib-infra", features = ["pb_gen"] } \ No newline at end of file diff --git a/frontend/rust-lib/dart-notify/build.rs b/frontend/rust-lib/dart-notify/build.rs index 76c2697b8b..83043c402f 100644 --- a/frontend/rust-lib/dart-notify/build.rs +++ b/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"); } diff --git a/frontend/rust-lib/flowy-document/Cargo.toml b/frontend/rust-lib/flowy-document/Cargo.toml index 0dbecccd3b..7ad988cbaa 100644 --- a/frontend/rust-lib/flowy-document/Cargo.toml +++ b/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"] \ No newline at end of file diff --git a/frontend/rust-lib/flowy-error/Cargo.toml b/frontend/rust-lib/flowy-error/Cargo.toml index fa25d1d094..a93776894b 100644 --- a/frontend/rust-lib/flowy-error/Cargo.toml +++ b/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"] } \ No newline at end of file +lib-infra = { path = "../../../shared-lib/lib-infra", features = ["pb_gen"] } \ No newline at end of file diff --git a/frontend/rust-lib/flowy-error/build.rs b/frontend/rust-lib/flowy-error/build.rs index d5f17bf093..2e2596840b 100644 --- a/frontend/rust-lib/flowy-error/build.rs +++ b/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"); } diff --git a/frontend/rust-lib/flowy-folder/Cargo.toml b/frontend/rust-lib/flowy-folder/Cargo.toml index e93f3eae89..43d259dd4b 100644 --- a/frontend/rust-lib/flowy-folder/Cargo.toml +++ b/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"] } \ No newline at end of file +lib-infra = { path = "../../../shared-lib/lib-infra", features = ["pb_gen"] } \ No newline at end of file diff --git a/frontend/rust-lib/flowy-folder/build.rs b/frontend/rust-lib/flowy-folder/build.rs index 223a7a8b8d..75e6a617c3 100644 --- a/frontend/rust-lib/flowy-folder/build.rs +++ b/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"); } diff --git a/frontend/rust-lib/flowy-net/Cargo.toml b/frontend/rust-lib/flowy-net/Cargo.toml index 24b09946e6..46537f8f4b 100644 --- a/frontend/rust-lib/flowy-net/Cargo.toml +++ b/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"] } \ No newline at end of file +lib-infra = { path = "../../../shared-lib/lib-infra", features = ["pb_gen"] } \ No newline at end of file diff --git a/frontend/rust-lib/flowy-net/build.rs b/frontend/rust-lib/flowy-net/build.rs index 75083105f3..27cb230e29 100644 --- a/frontend/rust-lib/flowy-net/build.rs +++ b/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"); } diff --git a/frontend/rust-lib/flowy-sdk/Cargo.toml b/frontend/rust-lib/flowy-sdk/Cargo.toml index 0afae1e70e..be4aaabeaa 100644 --- a/frontend/rust-lib/flowy-sdk/Cargo.toml +++ b/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"] \ No newline at end of file +use_bunyan = ["lib-log/use_bunyan"] +dart = ["flowy-user/dart", "flowy-net/dart", "flowy-folder/dart", "flowy-collaboration/dart"] \ No newline at end of file diff --git a/frontend/rust-lib/flowy-test/Cargo.toml b/frontend/rust-lib/flowy-test/Cargo.toml index faf85b7c32..1440506586 100644 --- a/frontend/rust-lib/flowy-test/Cargo.toml +++ b/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" \ No newline at end of file +serial_test = "0.5.1" + +[features] +dart = ["flowy-sdk/dart"] \ No newline at end of file diff --git a/frontend/rust-lib/flowy-user/Cargo.toml b/frontend/rust-lib/flowy-user/Cargo.toml index 7f7d04f964..f37c35c4be 100644 --- a/frontend/rust-lib/flowy-user/Cargo.toml +++ b/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"] } \ No newline at end of file +lib-infra = { path = "../../../shared-lib/lib-infra", features = ["pb_gen"] } \ No newline at end of file diff --git a/frontend/rust-lib/flowy-user/build.rs b/frontend/rust-lib/flowy-user/build.rs index bcc5f28171..19d5124f70 100644 --- a/frontend/rust-lib/flowy-user/build.rs +++ b/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"); } diff --git a/frontend/scripts/flowy-tool/src/proto/proto_gen.rs b/frontend/scripts/flowy-tool/src/proto/proto_gen.rs index 8077f49f6f..cd9af16d59 100644 --- a/frontend/scripts/flowy-tool/src/proto/proto_gen.rs +++ b/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); } } diff --git a/frontend/scripts/flowy-tool/src/proto/proto_info.rs b/frontend/scripts/flowy-tool/src/proto/proto_info.rs index 921bce5c1d..570631d7a7 100644 --- a/frontend/scripts/flowy-tool/src/proto/proto_info.rs +++ b/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; diff --git a/frontend/scripts/flowy-tool/src/proto/template/derive_meta/derive_meta.rs b/frontend/scripts/flowy-tool/src/proto/template/derive_meta/derive_meta.rs index fc816fee26..ec46810499 100644 --- a/frontend/scripts/flowy-tool/src/proto/template/derive_meta/derive_meta.rs +++ b/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; diff --git a/shared-lib/Cargo.lock b/shared-lib/Cargo.lock index 82716e07ad..eadc7bc748 100644 --- a/shared-lib/Cargo.lock +++ b/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", diff --git a/shared-lib/error-code/Cargo.toml b/shared-lib/error-code/Cargo.toml index bedb25a63a..404da61a41 100644 --- a/shared-lib/error-code/Cargo.toml +++ b/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"] } \ No newline at end of file +lib-infra = { path = "../lib-infra", features = ["pb_gen"] } + +[features] +dart = ["lib-infra/dart"] \ No newline at end of file diff --git a/shared-lib/error-code/build.rs b/shared-lib/error-code/build.rs index afa413f054..f611fe8523 100644 --- a/shared-lib/error-code/build.rs +++ b/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"); } diff --git a/shared-lib/flowy-collaboration/Cargo.toml b/shared-lib/flowy-collaboration/Cargo.toml index 6d70ef5b5f..c758d9d855 100644 --- a/shared-lib/flowy-collaboration/Cargo.toml +++ b/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"] } \ No newline at end of file +lib-infra = { path = "../lib-infra", features = ["pb_gen"] } + +[features] +dart = ["lib-infra/dart"] \ No newline at end of file diff --git a/shared-lib/flowy-collaboration/build.rs b/shared-lib/flowy-collaboration/build.rs index 413973cb05..90b829eeb8 100644 --- a/shared-lib/flowy-collaboration/build.rs +++ b/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"); } diff --git a/shared-lib/flowy-folder-data-model/Cargo.toml b/shared-lib/flowy-folder-data-model/Cargo.toml index bf56e55147..23695e9947 100644 --- a/shared-lib/flowy-folder-data-model/Cargo.toml +++ b/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 = [] \ No newline at end of file +frontend = [] +dart = ["lib-infra/dart", "error-code/dart"] \ No newline at end of file diff --git a/shared-lib/flowy-folder-data-model/build.rs b/shared-lib/flowy-folder-data-model/build.rs index 4a73077b68..876f89a90f 100644 --- a/shared-lib/flowy-folder-data-model/build.rs +++ b/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"); } diff --git a/shared-lib/flowy-user-data-model/Cargo.toml b/shared-lib/flowy-user-data-model/Cargo.toml index fe15afdf2c..b8bdc9760d 100644 --- a/shared-lib/flowy-user-data-model/Cargo.toml +++ b/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" \ No newline at end of file +serial_test = "0.5.1" + +[features] +dart = ["lib-infra/dart", "error-code/dart"] diff --git a/shared-lib/flowy-user-data-model/build.rs b/shared-lib/flowy-user-data-model/build.rs index 3b049683be..f9897cc349 100644 --- a/shared-lib/flowy-user-data-model/build.rs +++ b/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"); } diff --git a/shared-lib/lib-infra/Cargo.toml b/shared-lib/lib-infra/Cargo.toml index cf4a4115ef..07fd103cb1 100644 --- a/shared-lib/lib-infra/Cargo.toml +++ b/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"] \ No newline at end of file +pb_gen = ["cmd_lib", "protoc-rust", "walkdir"] +dart = [] \ No newline at end of file diff --git a/shared-lib/lib-infra/src/lib.rs b/shared-lib/lib-infra/src/lib.rs index f8dc092f7e..dabb895f51 100644 --- a/shared-lib/lib-infra/src/lib.rs +++ b/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 { diff --git a/shared-lib/lib-infra/src/pb.rs b/shared-lib/lib-infra/src/pb.rs deleted file mode 100644 index 3d30167bbc..0000000000 --- a/shared-lib/lib-infra/src/pb.rs +++ /dev/null @@ -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."); -} diff --git a/shared-lib/lib-infra/src/pb_gen.rs b/shared-lib/lib-infra/src/pb_gen.rs new file mode 100644 index 0000000000..5296a39f31 --- /dev/null +++ b/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, file_names: &Vec) { + 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); + } + } +} diff --git a/shared-lib/lib-ws/Cargo.toml b/shared-lib/lib-ws/Cargo.toml index 5d3972f4db..76668c297d 100644 --- a/shared-lib/lib-ws/Cargo.toml +++ b/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" \ No newline at end of file +env_logger = "0.8.2" + +[features] +dart = ["lib-infra/dart"] \ No newline at end of file diff --git a/shared-lib/lib-ws/build.rs b/shared-lib/lib-ws/build.rs index e527a83276..aebe8041a2 100644 --- a/shared-lib/lib-ws/build.rs +++ b/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"); }