diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4d3fe53b..b522c6d9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,10 +7,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Install Protoc - uses: arduino/setup-protoc@v2 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - uses: subosito/flutter-action@v2.10.0 with: flutter-version: "3.10.5" diff --git a/generate_protos.sh b/generate_protos.sh deleted file mode 100755 index bcdcea6a..00000000 --- a/generate_protos.sh +++ /dev/null @@ -1,3 +0,0 @@ -cd packages/io_library/lib/src/serialization/proto || exit -mkdir -p output -protoc --dart_out=output --proto_path=schema $(find schema -iname "*.proto") google/protobuf/any.proto diff --git a/packages/command/lib/command.dart b/packages/command/lib/command.dart index e6dc05e4..ef1579a7 100644 --- a/packages/command/lib/command.dart +++ b/packages/command/lib/command.dart @@ -1,9 +1,8 @@ library command; -export 'src/graphic/draw_path_command.dart'; -export 'src/manager/sync_command_manager.dart'; - -export 'src/command_factory.dart'; -export 'src/command_manager.dart'; -export 'src/command.dart'; -export 'src/graphic_command.dart'; +export 'src/command_factory/command_factory.dart'; +export 'src/command_implementation/command.dart'; +export 'src/command_implementation/graphic/draw_path_command.dart'; +export 'src/command_implementation/graphic/graphic_command.dart'; +export 'src/command_manager/command_manager.dart'; +export 'src/command_manager/sync_command_manager.dart'; diff --git a/packages/command/lib/command_providers.dart b/packages/command/lib/command_providers.dart index f94e8ec9..4980378e 100644 --- a/packages/command/lib/command_providers.dart +++ b/packages/command/lib/command_providers.dart @@ -1,4 +1,4 @@ library command; -export 'src/command_factory_provider.dart'; -export 'src/command_manager_provider.dart'; +export 'src/command_factory/command_factory_provider.dart'; +export 'src/command_manager/command_manager_provider.dart'; diff --git a/packages/command/lib/src/command.dart b/packages/command/lib/src/command.dart deleted file mode 100644 index 555fd20a..00000000 --- a/packages/command/lib/src/command.dart +++ /dev/null @@ -1,5 +0,0 @@ -import 'package:equatable/equatable.dart'; - -abstract class Command with EquatableMixin { - const Command(); -} diff --git a/packages/command/lib/src/command_factory.dart b/packages/command/lib/src/command_factory/command_factory.dart similarity index 100% rename from packages/command/lib/src/command_factory.dart rename to packages/command/lib/src/command_factory/command_factory.dart diff --git a/packages/command/lib/src/command_factory_provider.dart b/packages/command/lib/src/command_factory/command_factory_provider.dart similarity index 100% rename from packages/command/lib/src/command_factory_provider.dart rename to packages/command/lib/src/command_factory/command_factory_provider.dart diff --git a/packages/command/lib/src/command_factory_provider.g.dart b/packages/command/lib/src/command_factory/command_factory_provider.g.dart similarity index 100% rename from packages/command/lib/src/command_factory_provider.g.dart rename to packages/command/lib/src/command_factory/command_factory_provider.g.dart diff --git a/packages/command/lib/src/command_implementation/command.dart b/packages/command/lib/src/command_implementation/command.dart new file mode 100644 index 00000000..e5377362 --- /dev/null +++ b/packages/command/lib/src/command_implementation/command.dart @@ -0,0 +1,19 @@ +import 'package:command/command.dart'; +import 'package:equatable/equatable.dart'; +import 'package:io_library/io_library.dart'; + +abstract class Command with EquatableMixin { + const Command(); + + Map toJson(); + + factory Command.fromJson(Map json) { + String type = json['type'] as String; + switch (type) { + case SerializerType.DRAW_PATH_COMMAND: + return DrawPathCommand.fromJson(json); + default: + return DrawPathCommand.fromJson(json); + } + } +} diff --git a/packages/command/lib/src/command_implementation/graphic/draw_path_command.dart b/packages/command/lib/src/command_implementation/graphic/draw_path_command.dart new file mode 100644 index 00000000..096dbcea --- /dev/null +++ b/packages/command/lib/src/command_implementation/graphic/draw_path_command.dart @@ -0,0 +1,52 @@ +import 'dart:ui'; + +import 'package:command/command.dart'; +import 'package:component_library/component_library.dart'; +import 'package:flutter/widgets.dart'; +import 'package:io_library/io_library.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'draw_path_command.g.dart'; + +@JsonSerializable() +class DrawPathCommand extends GraphicCommand { + final String type; + final int version; + + DrawPathCommand( + this.path, + super.paint, { + this.type = SerializerType.DRAW_PATH_COMMAND, + int? version, + }) : version = version ?? + VersionStrategyManager.strategy.getDrawPathCommandVersion(); + + @PathWithActionHistoryConverter() + final PathWithActionHistory path; + + @override + void call(Canvas canvas) { + canvas.drawPath(path, paint); + } + + @override + List get props => [paint, path, type]; + + @override + Map toJson() => _$DrawPathCommandToJson(this); + + factory DrawPathCommand.fromJson(Map json) { + int version = json['version'] as int; + + switch (version) { + case Version.v1: + return _$DrawPathCommandFromJson(json); + case Version.v2: + // For different versions of DrawPathCommand the deserialization + // has to be implemented manually. + // Autogenerated code can only be used for one version + default: + return _$DrawPathCommandFromJson(json); + } + } +} diff --git a/packages/command/lib/src/command_implementation/graphic/draw_path_command.g.dart b/packages/command/lib/src/command_implementation/graphic/draw_path_command.g.dart new file mode 100644 index 00000000..5d76772c --- /dev/null +++ b/packages/command/lib/src/command_implementation/graphic/draw_path_command.g.dart @@ -0,0 +1,24 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'draw_path_command.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +DrawPathCommand _$DrawPathCommandFromJson(Map json) => + DrawPathCommand( + const PathWithActionHistoryConverter() + .fromJson(json['path'] as Map), + const PaintConverter().fromJson(json['paint'] as Map), + type: json['type'] as String? ?? SerializerType.DRAW_PATH_COMMAND, + version: json['version'] as int?, + ); + +Map _$DrawPathCommandToJson(DrawPathCommand instance) => + { + 'paint': const PaintConverter().toJson(instance.paint), + 'type': instance.type, + 'version': instance.version, + 'path': const PathWithActionHistoryConverter().toJson(instance.path), + }; diff --git a/packages/command/lib/src/graphic_command.dart b/packages/command/lib/src/command_implementation/graphic/graphic_command.dart similarity index 75% rename from packages/command/lib/src/graphic_command.dart rename to packages/command/lib/src/command_implementation/graphic/graphic_command.dart index 7f251477..20108abc 100644 --- a/packages/command/lib/src/graphic_command.dart +++ b/packages/command/lib/src/command_implementation/graphic/graphic_command.dart @@ -1,10 +1,12 @@ import 'dart:ui'; import 'package:command/command.dart'; +import 'package:io_library/io_library.dart'; abstract class GraphicCommand extends Command { const GraphicCommand(this.paint); + @PaintConverter() final Paint paint; void call(Canvas canvas); diff --git a/packages/command/lib/src/command_manager.dart b/packages/command/lib/src/command_manager/command_manager.dart similarity index 100% rename from packages/command/lib/src/command_manager.dart rename to packages/command/lib/src/command_manager/command_manager.dart diff --git a/packages/command/lib/src/command_manager_provider.dart b/packages/command/lib/src/command_manager/command_manager_provider.dart similarity index 100% rename from packages/command/lib/src/command_manager_provider.dart rename to packages/command/lib/src/command_manager/command_manager_provider.dart diff --git a/packages/command/lib/src/command_manager_provider.g.dart b/packages/command/lib/src/command_manager/command_manager_provider.g.dart similarity index 100% rename from packages/command/lib/src/command_manager_provider.g.dart rename to packages/command/lib/src/command_manager/command_manager_provider.g.dart diff --git a/packages/command/lib/src/manager/sync_command_manager.dart b/packages/command/lib/src/command_manager/sync_command_manager.dart similarity index 100% rename from packages/command/lib/src/manager/sync_command_manager.dart rename to packages/command/lib/src/command_manager/sync_command_manager.dart diff --git a/packages/command/lib/src/graphic/draw_path_command.dart b/packages/command/lib/src/graphic/draw_path_command.dart deleted file mode 100644 index 45cfd96b..00000000 --- a/packages/command/lib/src/graphic/draw_path_command.dart +++ /dev/null @@ -1,18 +0,0 @@ -import 'dart:ui'; -import 'package:command/command.dart'; -import 'package:component_library/component_library.dart'; -import 'package:flutter/widgets.dart'; - -class DrawPathCommand extends GraphicCommand { - const DrawPathCommand(this.path, super.paint); - - final PathWithActionHistory path; - - @override - void call(Canvas canvas) { - canvas.drawPath(path, paint); - } - - @override - List get props => [paint, path]; -} diff --git a/packages/command/pubspec.yaml b/packages/command/pubspec.yaml index bc3e81f7..01cef047 100644 --- a/packages/command/pubspec.yaml +++ b/packages/command/pubspec.yaml @@ -14,10 +14,14 @@ dependencies: flutter_riverpod: ^2.3.6 riverpod_annotation: ^2.1.1 equatable: ^2.0.3 + json_annotation: ^4.8.1 + # Internal packages component_library: path: ../component_library + io_library: + path: ../io_library dev_dependencies: flutter_test: @@ -31,6 +35,7 @@ dev_dependencies: riverpod_lint: ^1.3.2 build_runner: ^2.2.0 freezed: ^2.4.1 + json_serializable: ^6.7.1 flutter: uses-material-design: true diff --git a/packages/component_library/lib/src/models/path_with_action_history.dart b/packages/component_library/lib/src/models/path_with_action_history.dart index 75bffb9b..e5657dde 100644 --- a/packages/component_library/lib/src/models/path_with_action_history.dart +++ b/packages/component_library/lib/src/models/path_with_action_history.dart @@ -1,6 +1,12 @@ import 'dart:ui'; +import 'package:collection/collection.dart'; +import 'package:io_library/io_library.dart'; + class PathWithActionHistory extends Path { + PathWithActionHistory(); + + @PathActionConverter() final actions = []; @override @@ -20,6 +26,25 @@ class PathWithActionHistory extends Path { actions.add(const CloseAction()); super.close(); } + + Map toJson() { + return const PathWithActionHistoryConverter().toJson(this); + } + + factory PathWithActionHistory.fromJson(Map json) { + return const PathWithActionHistoryConverter().fromJson(json); + } + + @override + bool operator ==(Object other) { + if (other is PathWithActionHistory) { + return const ListEquality().equals(actions, other.actions); + } + return false; + } + + @override + int get hashCode => const ListEquality().hash(actions); } abstract class PathAction { @@ -31,6 +56,17 @@ class MoveToAction extends PathAction { final double y; const MoveToAction(this.x, this.y); + + @override + bool operator ==(Object other) { + if (other is MoveToAction) { + return x == other.x && y == other.y; + } + return false; + } + + @override + int get hashCode => Object.hash(x, y); } class LineToAction extends PathAction { @@ -38,6 +74,17 @@ class LineToAction extends PathAction { final double y; const LineToAction(this.x, this.y); + + @override + bool operator ==(Object other) { + if (other is LineToAction) { + return x == other.x && y == other.y; + } + return false; + } + + @override + int get hashCode => Object.hash(x, y); } class CloseAction extends PathAction { diff --git a/packages/component_library/pubspec.yaml b/packages/component_library/pubspec.yaml index 6889f556..e73271f4 100644 --- a/packages/component_library/pubspec.yaml +++ b/packages/component_library/pubspec.yaml @@ -20,6 +20,12 @@ dependencies: toast: ^0.3.0 logging: ^1.0.2 + collection: ^1.17.1 + + # Internal packages: + io_library: + path: ../io_library + dev_dependencies: flutter_test: sdk: flutter diff --git a/packages/io_library/lib/io_library.dart b/packages/io_library/lib/io_library.dart index acd0a174..beda5731 100644 --- a/packages/io_library/lib/io_library.dart +++ b/packages/io_library/lib/io_library.dart @@ -2,29 +2,23 @@ library io_library; export 'src/enums/image_format.dart'; export 'src/enums/image_location.dart'; - export 'src/failure/load_image_failure.dart'; export 'src/failure/save_image_failure.dart'; - +export 'src/io_handler.dart'; +export 'src/json_serialization/converter/paint_converter.dart'; +export 'src/json_serialization/converter/path_action_converter.dart'; +export 'src/json_serialization/converter/path_with_action_history_converter.dart'; +export 'src/json_serialization/versioning/serializer_version.dart'; +export 'src/json_serialization/versioning/version_strategy.dart'; export 'src/models/catrobat_image.dart'; export 'src/models/failure.dart'; export 'src/models/image_from_file.dart'; export 'src/models/image_meta_data.dart'; export 'src/models/loggable_mixin.dart'; - -export 'src/serialization/proto/protos.dart'; -export 'src/serialization/serializer/command/graphic/draw_path_command_serializer.dart'; -export 'src/serialization/serializer/graphic/paint_serializer.dart'; -export 'src/serialization/serializer/graphic/path_serializer.dart'; -export 'src/serialization/serializer/catrobat_image_serializer.dart'; -export 'src/serialization/proto_serializer_with_versioning.dart'; -export 'src/serialization/version_serializer.dart'; - export 'src/service/file_service.dart'; export 'src/service/image_service.dart'; export 'src/service/permission_service.dart'; export 'src/service/photo_library_service.dart'; - export 'src/ui/about_dialog.dart'; export 'src/ui/delete_project_dialog.dart'; export 'src/ui/discard_changes_dialog.dart'; @@ -34,10 +28,7 @@ export 'src/ui/load_image_dialog.dart'; export 'src/ui/overwrite_dialog.dart'; export 'src/ui/project_details_dialog.dart'; export 'src/ui/save_image_dialog.dart'; - export 'src/usecase/load_image_from_file_manager.dart'; export 'src/usecase/load_image_from_photo_library.dart'; export 'src/usecase/save_as_catrobat_image.dart'; export 'src/usecase/save_as_raster_image.dart'; - -export 'src/io_handler.dart'; diff --git a/packages/io_library/lib/serialization.dart b/packages/io_library/lib/serialization.dart deleted file mode 100644 index 7009b8be..00000000 --- a/packages/io_library/lib/serialization.dart +++ /dev/null @@ -1,10 +0,0 @@ -export 'src/serialization/proto/output/catrobat_image.pb.dart'; -export 'src/serialization/proto/output/command/graphic/draw_path_command.pb.dart'; -export 'src/serialization/proto/output/google/protobuf/any.pb.dart'; -export 'src/serialization/proto/output/graphic/paint.pb.dart'; -export 'src/serialization/proto/output/graphic/path.pb.dart'; -export 'src/serialization/proto_serializer_with_versioning.dart'; -export 'src/serialization/serializer/command/graphic/draw_path_command_serializer.dart'; -export 'src/serialization/serializer/graphic/paint_serializer.dart'; -export 'src/serialization/serializer/graphic/path_serializer.dart'; -export 'src/serialization/version_serializer.dart'; diff --git a/packages/io_library/lib/src/io_handler.dart b/packages/io_library/lib/src/io_handler.dart index 0713e174..59d354cc 100644 --- a/packages/io_library/lib/src/io_handler.dart +++ b/packages/io_library/lib/src/io_handler.dart @@ -1,4 +1,6 @@ +import 'dart:convert'; import 'dart:io'; +import 'dart:typed_data'; import 'package:command/command_providers.dart'; import 'package:component_library/component_library.dart'; @@ -201,8 +203,19 @@ class IOHandler { final canvasState = ref.read(canvasStateProvider); final imgWidth = canvasState.size.width.toInt(); final imgHeight = canvasState.size.height.toInt(); - final catrobatImage = CatrobatImage( - commands, imgWidth, imgHeight, canvasState.backgroundImage); + Uint8List? backgroundImageData; + if (canvasState.backgroundImage != null) { + final result = await ref + .read(IImageService.provider) + .exportAsPng(canvasState.backgroundImage!); + backgroundImageData = + result.unwrapOrElse((failure) => throw failure.message); + } + + final String backgroundImageAsString = + backgroundImageData != null ? base64Encode(backgroundImageData) : ''; + final catrobatImage = + CatrobatImage(commands, imgWidth, imgHeight, backgroundImageAsString); final saveAsCatrobatImage = ref.read(SaveAsCatrobatImage.provider); final result = await saveAsCatrobatImage(imageData, catrobatImage, isAProject); diff --git a/packages/io_library/lib/src/json_serialization/converter/paint_converter.dart b/packages/io_library/lib/src/json_serialization/converter/paint_converter.dart new file mode 100644 index 00000000..902a4c0c --- /dev/null +++ b/packages/io_library/lib/src/json_serialization/converter/paint_converter.dart @@ -0,0 +1,50 @@ +import 'dart:ui'; + +import 'package:io_library/io_library.dart'; +import 'package:json_annotation/json_annotation.dart'; + +class PaintConverter implements JsonConverter> { + const PaintConverter(); + + @override + Paint fromJson(Map json) { + Paint paint = Paint(); + + int version = json['version'] as int; + if (version >= Version.v1) { + paint.color = Color(json['color']); + paint.strokeWidth = json['strokeWidth']; + paint.strokeCap = StrokeCap.values[json['strokeCap']]; + paint.isAntiAlias = json['isAntiAlias']; + paint.style = PaintingStyle.values[json['style']]; + paint.strokeJoin = StrokeJoin.values[json['strokeJoin']]; + paint.blendMode = BlendMode.values[json['blendMode']]; + } + if (version >= Version.v2) { + // paint.newAttribute = json['newAttribute']; + } + return paint; + } + + // Never remove attributes, it will cause errors in older versions!! + // Only add new attributes at the end of the map and increase the version number. + @override + Map toJson(Paint paint) { + Map json = {}; + if (SerializerVersion.PAINT_VERSION >= Version.v1) { + json['version'] = SerializerVersion.PAINT_VERSION; + json['color'] = paint.color.value; + json['strokeWidth'] = paint.strokeWidth; + json['strokeCap'] = paint.strokeCap.index; + json['isAntiAlias'] = paint.isAntiAlias; + json['style'] = paint.style.index; + json['strokeJoin'] = paint.strokeJoin.index; + json['blendMode'] = paint.blendMode.index; + } + if (SerializerVersion.PAINT_VERSION >= Version.v2) { + // json['newAttribute'] = paint.newAttribute; + } + + return json; + } +} diff --git a/packages/io_library/lib/src/json_serialization/converter/path_action_converter.dart b/packages/io_library/lib/src/json_serialization/converter/path_action_converter.dart new file mode 100644 index 00000000..9c2de9aa --- /dev/null +++ b/packages/io_library/lib/src/json_serialization/converter/path_action_converter.dart @@ -0,0 +1,41 @@ +import 'package:component_library/component_library.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:io_library/io_library.dart'; + +class PathActionConverter + implements JsonConverter> { + const PathActionConverter(); + + @override + PathAction fromJson(Map json) { + switch (json['type'] as String) { + case SerializerType.MOVE_TO_ACTION: + return MoveToAction(json['x'] as double, json['y'] as double); + case SerializerType.LINE_TO_ACTION: + return LineToAction(json['x'] as double, json['y'] as double); + case SerializerType.CLOSE_ACTION: + return const CloseAction(); + default: + return const CloseAction(); + } + } + + @override + Map toJson(PathAction action) { + if (action is MoveToAction) { + return { + 'type': SerializerType.MOVE_TO_ACTION, + 'x': action.x, + 'y': action.y + }; + } else if (action is LineToAction) { + return { + 'type': SerializerType.LINE_TO_ACTION, + 'x': action.x, + 'y': action.y + }; + } else { + return {'type': SerializerType.CLOSE_ACTION}; + } + } +} diff --git a/packages/io_library/lib/src/json_serialization/converter/path_with_action_history_converter.dart b/packages/io_library/lib/src/json_serialization/converter/path_with_action_history_converter.dart new file mode 100644 index 00000000..03438c0d --- /dev/null +++ b/packages/io_library/lib/src/json_serialization/converter/path_with_action_history_converter.dart @@ -0,0 +1,34 @@ +import 'package:component_library/component_library.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:io_library/io_library.dart'; + +class PathWithActionHistoryConverter + implements JsonConverter> { + const PathWithActionHistoryConverter(); + + @override + PathWithActionHistory fromJson(Map json) { + var pathWithActionHistory = PathWithActionHistory(); + var actionsJson = json['actions'] as List; + for (var actionJson in actionsJson) { + var action = const PathActionConverter() + .fromJson(actionJson as Map); + + if (action is MoveToAction) { + pathWithActionHistory.moveTo(action.x, action.y); + } else if (action is LineToAction) { + pathWithActionHistory.lineTo(action.x, action.y); + } else if (action is CloseAction) { + pathWithActionHistory.close(); + } + } + return pathWithActionHistory; + } + + @override + Map toJson(PathWithActionHistory pathWithActionHistory) => { + 'actions': pathWithActionHistory.actions + .map((action) => const PathActionConverter().toJson(action)) + .toList(), + }; +} diff --git a/packages/io_library/lib/src/json_serialization/versioning/serializer_version.dart b/packages/io_library/lib/src/json_serialization/versioning/serializer_version.dart new file mode 100644 index 00000000..bb592105 --- /dev/null +++ b/packages/io_library/lib/src/json_serialization/versioning/serializer_version.dart @@ -0,0 +1,19 @@ +class SerializerVersion { + static const int PAINT_VERSION = Version.v1; + static const int CATROBAT_IMAGE_VERSION = Version.v1; + static const int DRAW_PATH_COMMAND_VERSION = Version.v1; +} + +class Version { + static const int v1 = 1; + static const int v2 = 2; + static const int v3 = 3; +// ... +} + +class SerializerType { + static const String DRAW_PATH_COMMAND = 'DrawPathCommand'; + static const String MOVE_TO_ACTION = 'MoveToAction'; + static const String LINE_TO_ACTION = 'LineToAction'; + static const String CLOSE_ACTION = 'CloseAction'; +} diff --git a/packages/io_library/lib/src/json_serialization/versioning/version_strategy.dart b/packages/io_library/lib/src/json_serialization/versioning/version_strategy.dart new file mode 100644 index 00000000..0f4ca73f --- /dev/null +++ b/packages/io_library/lib/src/json_serialization/versioning/version_strategy.dart @@ -0,0 +1,25 @@ +import 'package:io_library/io_library.dart'; + +abstract class IVersionStrategy { + int getCatrobatImageVersion(); + int getDrawPathCommandVersion(); +} + +class ProductionVersionStrategy implements IVersionStrategy { + @override + int getCatrobatImageVersion() => SerializerVersion.CATROBAT_IMAGE_VERSION; + + @override + int getDrawPathCommandVersion() => + SerializerVersion.DRAW_PATH_COMMAND_VERSION; +} + +class VersionStrategyManager { + static IVersionStrategy _strategy = ProductionVersionStrategy(); + + static void setStrategy(IVersionStrategy strategy) { + _strategy = strategy; + } + + static IVersionStrategy get strategy => _strategy; +} diff --git a/packages/io_library/lib/src/models/catrobat_image.dart b/packages/io_library/lib/src/models/catrobat_image.dart index 99b28a3a..af77bb99 100644 --- a/packages/io_library/lib/src/models/catrobat_image.dart +++ b/packages/io_library/lib/src/models/catrobat_image.dart @@ -1,22 +1,52 @@ -import 'dart:ui'; +import 'dart:convert'; +import 'dart:typed_data'; import 'package:command/command.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:io_library/io_library.dart'; -class CatrobatImage { - static const magicValue = 'CATROBAT'; - static const latestVersion = 1; +part 'catrobat_image.g.dart'; +@JsonSerializable() +class CatrobatImage { + final String magicValue; final int version; final int width; final int height; final Iterable commands; - final Image? backgroundImage; - - const CatrobatImage( - this.commands, - this.width, - this.height, - this.backgroundImage, { - this.version = latestVersion, - }); + final String backgroundImage; + + CatrobatImage(this.commands, this.width, this.height, this.backgroundImage, + {int? version, this.magicValue = 'CATROBAT'}) + : version = version ?? + VersionStrategyManager.strategy.getCatrobatImageVersion(); + + Uint8List toBytes() { + Map jsonMap = toJson(); + String jsonString = json.encode(jsonMap); + return utf8.encode(jsonString) as Uint8List; + } + + static CatrobatImage fromBytes(Uint8List bytes) { + String jsonString = utf8.decode(bytes); + Map jsonMap = json.decode(jsonString); + return CatrobatImage.fromJson(jsonMap); + } + + Map toJson() => _$CatrobatImageToJson(this); + + factory CatrobatImage.fromJson(Map json) { + int version = json['version'] as int; + + switch (version) { + case Version.v1: + return _$CatrobatImageFromJson(json); + case Version.v2: + // For different versions of CatrobatImage the deserialization + // has to be implemented manually. + // Autogenerated code can only be used for one version + default: + return _$CatrobatImageFromJson(json); + } + } } diff --git a/packages/io_library/lib/src/models/catrobat_image.g.dart b/packages/io_library/lib/src/models/catrobat_image.g.dart new file mode 100644 index 00000000..9d900f86 --- /dev/null +++ b/packages/io_library/lib/src/models/catrobat_image.g.dart @@ -0,0 +1,28 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'catrobat_image.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +CatrobatImage _$CatrobatImageFromJson(Map json) => + CatrobatImage( + (json['commands'] as List) + .map((e) => Command.fromJson(e as Map)), + json['width'] as int, + json['height'] as int, + json['backgroundImage'] as String, + version: json['version'] as int?, + magicValue: json['magicValue'] as String? ?? 'CATROBAT', + ); + +Map _$CatrobatImageToJson(CatrobatImage instance) => + { + 'magicValue': instance.magicValue, + 'version': instance.version, + 'width': instance.width, + 'height': instance.height, + 'commands': instance.commands.toList(), + 'backgroundImage': instance.backgroundImage, + }; diff --git a/packages/io_library/lib/src/serialization/proto/output/catrobat_image.pb.dart b/packages/io_library/lib/src/serialization/proto/output/catrobat_image.pb.dart deleted file mode 100644 index d6f0e1d3..00000000 --- a/packages/io_library/lib/src/serialization/proto/output/catrobat_image.pb.dart +++ /dev/null @@ -1,161 +0,0 @@ -// -// Generated code. Do not modify. -// source: catrobat_image.proto -// -// @dart = 2.12 - -// ignore_for_file: annotate_overrides, camel_case_types, comment_references -// ignore_for_file: constant_identifier_names, library_prefixes -// ignore_for_file: non_constant_identifier_names, prefer_final_fields -// ignore_for_file: unnecessary_import, unnecessary_this, unused_import - -import 'dart:core' as $core; - -import 'package:protobuf/protobuf.dart' as $pb; - -import 'google/protobuf/any.pb.dart' as $2; - -class SerializableCatrobatImage extends $pb.GeneratedMessage { - factory SerializableCatrobatImage({ - $core.String? magicValue, - $core.int? version, - $core.int? width, - $core.int? height, - $core.Iterable<$2.Any>? commands, - $core.List<$core.int>? backgroundImage, - }) { - final $result = create(); - if (magicValue != null) { - $result.magicValue = magicValue; - } - if (version != null) { - $result.version = version; - } - if (width != null) { - $result.width = width; - } - if (height != null) { - $result.height = height; - } - if (commands != null) { - $result.commands.addAll(commands); - } - if (backgroundImage != null) { - $result.backgroundImage = backgroundImage; - } - return $result; - } - SerializableCatrobatImage._() : super(); - factory SerializableCatrobatImage.fromBuffer($core.List<$core.int> i, - [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromBuffer(i, r); - factory SerializableCatrobatImage.fromJson($core.String i, - [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromJson(i, r); - - static final $pb.BuilderInfo _i = $pb.BuilderInfo( - _omitMessageNames ? '' : 'SerializableCatrobatImage', - createEmptyInstance: create) - ..aOS(1, _omitFieldNames ? '' : 'magicValue', protoName: 'magicValue') - ..a<$core.int>(2, _omitFieldNames ? '' : 'version', $pb.PbFieldType.O3) - ..a<$core.int>(3, _omitFieldNames ? '' : 'width', $pb.PbFieldType.OU3) - ..a<$core.int>(4, _omitFieldNames ? '' : 'height', $pb.PbFieldType.OU3) - ..pc<$2.Any>(5, _omitFieldNames ? '' : 'commands', $pb.PbFieldType.PM, - subBuilder: $2.Any.create) - ..a<$core.List<$core.int>>( - 6, _omitFieldNames ? '' : 'backgroundImage', $pb.PbFieldType.OY, - protoName: 'backgroundImage') - ..hasRequiredFields = false; - - @$core.Deprecated('Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - SerializableCatrobatImage clone() => - SerializableCatrobatImage()..mergeFromMessage(this); - @$core.Deprecated('Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - SerializableCatrobatImage copyWith( - void Function(SerializableCatrobatImage) updates) => - super.copyWith((message) => updates(message as SerializableCatrobatImage)) - as SerializableCatrobatImage; - - $pb.BuilderInfo get info_ => _i; - - @$core.pragma('dart2js:noInline') - static SerializableCatrobatImage create() => SerializableCatrobatImage._(); - SerializableCatrobatImage createEmptyInstance() => create(); - static $pb.PbList createRepeated() => - $pb.PbList(); - @$core.pragma('dart2js:noInline') - static SerializableCatrobatImage getDefault() => _defaultInstance ??= - $pb.GeneratedMessage.$_defaultFor(create); - static SerializableCatrobatImage? _defaultInstance; - - @$pb.TagNumber(1) - $core.String get magicValue => $_getSZ(0); - @$pb.TagNumber(1) - set magicValue($core.String v) { - $_setString(0, v); - } - - @$pb.TagNumber(1) - $core.bool hasMagicValue() => $_has(0); - @$pb.TagNumber(1) - void clearMagicValue() => clearField(1); - - @$pb.TagNumber(2) - $core.int get version => $_getIZ(1); - @$pb.TagNumber(2) - set version($core.int v) { - $_setSignedInt32(1, v); - } - - @$pb.TagNumber(2) - $core.bool hasVersion() => $_has(1); - @$pb.TagNumber(2) - void clearVersion() => clearField(2); - - @$pb.TagNumber(3) - $core.int get width => $_getIZ(2); - @$pb.TagNumber(3) - set width($core.int v) { - $_setUnsignedInt32(2, v); - } - - @$pb.TagNumber(3) - $core.bool hasWidth() => $_has(2); - @$pb.TagNumber(3) - void clearWidth() => clearField(3); - - @$pb.TagNumber(4) - $core.int get height => $_getIZ(3); - @$pb.TagNumber(4) - set height($core.int v) { - $_setUnsignedInt32(3, v); - } - - @$pb.TagNumber(4) - $core.bool hasHeight() => $_has(3); - @$pb.TagNumber(4) - void clearHeight() => clearField(4); - - @$pb.TagNumber(5) - $core.List<$2.Any> get commands => $_getList(4); - - @$pb.TagNumber(6) - $core.List<$core.int> get backgroundImage => $_getN(5); - @$pb.TagNumber(6) - set backgroundImage($core.List<$core.int> v) { - $_setBytes(5, v); - } - - @$pb.TagNumber(6) - $core.bool hasBackgroundImage() => $_has(5); - @$pb.TagNumber(6) - void clearBackgroundImage() => clearField(6); -} - -const _omitFieldNames = $core.bool.fromEnvironment('protobuf.omit_field_names'); -const _omitMessageNames = - $core.bool.fromEnvironment('protobuf.omit_message_names'); diff --git a/packages/io_library/lib/src/serialization/proto/output/catrobat_image.pbenum.dart b/packages/io_library/lib/src/serialization/proto/output/catrobat_image.pbenum.dart deleted file mode 100644 index 9cf6956b..00000000 --- a/packages/io_library/lib/src/serialization/proto/output/catrobat_image.pbenum.dart +++ /dev/null @@ -1,10 +0,0 @@ -// -// Generated code. Do not modify. -// source: catrobat_image.proto -// -// @dart = 2.12 - -// ignore_for_file: annotate_overrides, camel_case_types, comment_references -// ignore_for_file: constant_identifier_names, library_prefixes -// ignore_for_file: non_constant_identifier_names, prefer_final_fields -// ignore_for_file: unnecessary_import, unnecessary_this, unused_import diff --git a/packages/io_library/lib/src/serialization/proto/output/catrobat_image.pbjson.dart b/packages/io_library/lib/src/serialization/proto/output/catrobat_image.pbjson.dart deleted file mode 100644 index 13afd26d..00000000 --- a/packages/io_library/lib/src/serialization/proto/output/catrobat_image.pbjson.dart +++ /dev/null @@ -1,42 +0,0 @@ -// -// Generated code. Do not modify. -// source: catrobat_image.proto -// -// @dart = 2.12 - -// ignore_for_file: annotate_overrides, camel_case_types, comment_references -// ignore_for_file: constant_identifier_names, library_prefixes -// ignore_for_file: non_constant_identifier_names, prefer_final_fields -// ignore_for_file: unnecessary_import, unnecessary_this, unused_import - -import 'dart:convert' as $convert; -import 'dart:core' as $core; -import 'dart:typed_data' as $typed_data; - -@$core.Deprecated('Use serializableCatrobatImageDescriptor instead') -const SerializableCatrobatImage$json = { - '1': 'SerializableCatrobatImage', - '2': [ - {'1': 'magicValue', '3': 1, '4': 1, '5': 9, '10': 'magicValue'}, - {'1': 'version', '3': 2, '4': 1, '5': 5, '10': 'version'}, - {'1': 'width', '3': 3, '4': 1, '5': 13, '10': 'width'}, - {'1': 'height', '3': 4, '4': 1, '5': 13, '10': 'height'}, - { - '1': 'commands', - '3': 5, - '4': 3, - '5': 11, - '6': '.google.protobuf.Any', - '10': 'commands' - }, - {'1': 'backgroundImage', '3': 6, '4': 1, '5': 12, '10': 'backgroundImage'}, - ], -}; - -/// Descriptor for `SerializableCatrobatImage`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List serializableCatrobatImageDescriptor = $convert.base64Decode( - 'ChlTZXJpYWxpemFibGVDYXRyb2JhdEltYWdlEh4KCm1hZ2ljVmFsdWUYASABKAlSCm1hZ2ljVm' - 'FsdWUSGAoHdmVyc2lvbhgCIAEoBVIHdmVyc2lvbhIUCgV3aWR0aBgDIAEoDVIFd2lkdGgSFgoG' - 'aGVpZ2h0GAQgASgNUgZoZWlnaHQSMAoIY29tbWFuZHMYBSADKAsyFC5nb29nbGUucHJvdG9idW' - 'YuQW55Ughjb21tYW5kcxIoCg9iYWNrZ3JvdW5kSW1hZ2UYBiABKAxSD2JhY2tncm91bmRJbWFn' - 'ZQ=='); diff --git a/packages/io_library/lib/src/serialization/proto/output/catrobat_image.pbserver.dart b/packages/io_library/lib/src/serialization/proto/output/catrobat_image.pbserver.dart deleted file mode 100644 index 3971a739..00000000 --- a/packages/io_library/lib/src/serialization/proto/output/catrobat_image.pbserver.dart +++ /dev/null @@ -1,13 +0,0 @@ -// -// Generated code. Do not modify. -// source: catrobat_image.proto -// -// @dart = 2.12 - -// ignore_for_file: annotate_overrides, camel_case_types, comment_references -// ignore_for_file: constant_identifier_names -// ignore_for_file: deprecated_member_use_from_same_package, library_prefixes -// ignore_for_file: non_constant_identifier_names, prefer_final_fields -// ignore_for_file: unnecessary_import, unnecessary_this, unused_import - -export 'catrobat_image.pb.dart'; diff --git a/packages/io_library/lib/src/serialization/proto/output/command/graphic/draw_path_command.pb.dart b/packages/io_library/lib/src/serialization/proto/output/command/graphic/draw_path_command.pb.dart deleted file mode 100644 index 6311b5fc..00000000 --- a/packages/io_library/lib/src/serialization/proto/output/command/graphic/draw_path_command.pb.dart +++ /dev/null @@ -1,108 +0,0 @@ -// -// Generated code. Do not modify. -// source: command/graphic/draw_path_command.proto -// -// @dart = 2.12 - -// ignore_for_file: annotate_overrides, camel_case_types, comment_references -// ignore_for_file: constant_identifier_names, library_prefixes -// ignore_for_file: non_constant_identifier_names, prefer_final_fields -// ignore_for_file: unnecessary_import, unnecessary_this, unused_import - -import 'dart:core' as $core; - -import 'package:protobuf/protobuf.dart' as $pb; - -import '../../graphic/paint.pb.dart' as $0; -import '../../graphic/path.pb.dart' as $1; - -class SerializableDrawPathCommand extends $pb.GeneratedMessage { - factory SerializableDrawPathCommand({ - $0.SerializablePaint? paint, - $1.SerializablePath? path, - }) { - final $result = create(); - if (paint != null) { - $result.paint = paint; - } - if (path != null) { - $result.path = path; - } - return $result; - } - SerializableDrawPathCommand._() : super(); - factory SerializableDrawPathCommand.fromBuffer($core.List<$core.int> i, - [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromBuffer(i, r); - factory SerializableDrawPathCommand.fromJson($core.String i, - [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromJson(i, r); - - static final $pb.BuilderInfo _i = $pb.BuilderInfo( - _omitMessageNames ? '' : 'SerializableDrawPathCommand', - createEmptyInstance: create) - ..aOM<$0.SerializablePaint>(1, _omitFieldNames ? '' : 'paint', - subBuilder: $0.SerializablePaint.create) - ..aOM<$1.SerializablePath>(2, _omitFieldNames ? '' : 'path', - subBuilder: $1.SerializablePath.create) - ..hasRequiredFields = false; - - @$core.Deprecated('Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - SerializableDrawPathCommand clone() => - SerializableDrawPathCommand()..mergeFromMessage(this); - @$core.Deprecated('Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - SerializableDrawPathCommand copyWith( - void Function(SerializableDrawPathCommand) updates) => - super.copyWith( - (message) => updates(message as SerializableDrawPathCommand)) - as SerializableDrawPathCommand; - - $pb.BuilderInfo get info_ => _i; - - @$core.pragma('dart2js:noInline') - static SerializableDrawPathCommand create() => - SerializableDrawPathCommand._(); - SerializableDrawPathCommand createEmptyInstance() => create(); - static $pb.PbList createRepeated() => - $pb.PbList(); - @$core.pragma('dart2js:noInline') - static SerializableDrawPathCommand getDefault() => _defaultInstance ??= - $pb.GeneratedMessage.$_defaultFor(create); - static SerializableDrawPathCommand? _defaultInstance; - - @$pb.TagNumber(1) - $0.SerializablePaint get paint => $_getN(0); - @$pb.TagNumber(1) - set paint($0.SerializablePaint v) { - setField(1, v); - } - - @$pb.TagNumber(1) - $core.bool hasPaint() => $_has(0); - @$pb.TagNumber(1) - void clearPaint() => clearField(1); - @$pb.TagNumber(1) - $0.SerializablePaint ensurePaint() => $_ensure(0); - - @$pb.TagNumber(2) - $1.SerializablePath get path => $_getN(1); - @$pb.TagNumber(2) - set path($1.SerializablePath v) { - setField(2, v); - } - - @$pb.TagNumber(2) - $core.bool hasPath() => $_has(1); - @$pb.TagNumber(2) - void clearPath() => clearField(2); - @$pb.TagNumber(2) - $1.SerializablePath ensurePath() => $_ensure(1); -} - -const _omitFieldNames = $core.bool.fromEnvironment('protobuf.omit_field_names'); -const _omitMessageNames = - $core.bool.fromEnvironment('protobuf.omit_message_names'); diff --git a/packages/io_library/lib/src/serialization/proto/output/command/graphic/draw_path_command.pbenum.dart b/packages/io_library/lib/src/serialization/proto/output/command/graphic/draw_path_command.pbenum.dart deleted file mode 100644 index dbe32309..00000000 --- a/packages/io_library/lib/src/serialization/proto/output/command/graphic/draw_path_command.pbenum.dart +++ /dev/null @@ -1,10 +0,0 @@ -// -// Generated code. Do not modify. -// source: command/graphic/draw_path_command.proto -// -// @dart = 2.12 - -// ignore_for_file: annotate_overrides, camel_case_types, comment_references -// ignore_for_file: constant_identifier_names, library_prefixes -// ignore_for_file: non_constant_identifier_names, prefer_final_fields -// ignore_for_file: unnecessary_import, unnecessary_this, unused_import diff --git a/packages/io_library/lib/src/serialization/proto/output/command/graphic/draw_path_command.pbjson.dart b/packages/io_library/lib/src/serialization/proto/output/command/graphic/draw_path_command.pbjson.dart deleted file mode 100644 index 3ff6d2c5..00000000 --- a/packages/io_library/lib/src/serialization/proto/output/command/graphic/draw_path_command.pbjson.dart +++ /dev/null @@ -1,43 +0,0 @@ -// -// Generated code. Do not modify. -// source: command/graphic/draw_path_command.proto -// -// @dart = 2.12 - -// ignore_for_file: annotate_overrides, camel_case_types, comment_references -// ignore_for_file: constant_identifier_names, library_prefixes -// ignore_for_file: non_constant_identifier_names, prefer_final_fields -// ignore_for_file: unnecessary_import, unnecessary_this, unused_import - -import 'dart:convert' as $convert; -import 'dart:core' as $core; -import 'dart:typed_data' as $typed_data; - -@$core.Deprecated('Use serializableDrawPathCommandDescriptor instead') -const SerializableDrawPathCommand$json = { - '1': 'SerializableDrawPathCommand', - '2': [ - { - '1': 'paint', - '3': 1, - '4': 1, - '5': 11, - '6': '.SerializablePaint', - '10': 'paint' - }, - { - '1': 'path', - '3': 2, - '4': 1, - '5': 11, - '6': '.SerializablePath', - '10': 'path' - }, - ], -}; - -/// Descriptor for `SerializableDrawPathCommand`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List serializableDrawPathCommandDescriptor = - $convert.base64Decode( - 'ChtTZXJpYWxpemFibGVEcmF3UGF0aENvbW1hbmQSKAoFcGFpbnQYASABKAsyEi5TZXJpYWxpem' - 'FibGVQYWludFIFcGFpbnQSJQoEcGF0aBgCIAEoCzIRLlNlcmlhbGl6YWJsZVBhdGhSBHBhdGg='); diff --git a/packages/io_library/lib/src/serialization/proto/output/command/graphic/draw_path_command.pbserver.dart b/packages/io_library/lib/src/serialization/proto/output/command/graphic/draw_path_command.pbserver.dart deleted file mode 100644 index 5dc7a54f..00000000 --- a/packages/io_library/lib/src/serialization/proto/output/command/graphic/draw_path_command.pbserver.dart +++ /dev/null @@ -1,13 +0,0 @@ -// -// Generated code. Do not modify. -// source: command/graphic/draw_path_command.proto -// -// @dart = 2.12 - -// ignore_for_file: annotate_overrides, camel_case_types, comment_references -// ignore_for_file: constant_identifier_names -// ignore_for_file: deprecated_member_use_from_same_package, library_prefixes -// ignore_for_file: non_constant_identifier_names, prefer_final_fields -// ignore_for_file: unnecessary_import, unnecessary_this, unused_import - -export 'draw_path_command.pb.dart'; diff --git a/packages/io_library/lib/src/serialization/proto/output/google/protobuf/any.pb.dart b/packages/io_library/lib/src/serialization/proto/output/google/protobuf/any.pb.dart deleted file mode 100644 index 9f9d4c72..00000000 --- a/packages/io_library/lib/src/serialization/proto/output/google/protobuf/any.pb.dart +++ /dev/null @@ -1,224 +0,0 @@ -// -// Generated code. Do not modify. -// source: google/protobuf/any.proto -// -// @dart = 2.12 - -// ignore_for_file: annotate_overrides, camel_case_types, comment_references -// ignore_for_file: constant_identifier_names, library_prefixes -// ignore_for_file: non_constant_identifier_names, prefer_final_fields -// ignore_for_file: unnecessary_import, unnecessary_this, unused_import - -import 'dart:core' as $core; - -import 'package:protobuf/protobuf.dart' as $pb; -import 'package:protobuf/src/protobuf/mixins/well_known.dart' as $mixin; - -/// `Any` contains an arbitrary serialized protocol buffer message along with a -/// URL that describes the type of the serialized message. -/// -/// Protobuf library provides support to pack/unpack Any values in the form -/// of utility functions or additional generated methods of the Any type. -/// -/// Example 1: Pack and unpack a message in C++. -/// -/// Foo foo = ...; -/// Any any; -/// any.PackFrom(foo); -/// ... -/// if (any.UnpackTo(&foo)) { -/// ... -/// } -/// -/// Example 2: Pack and unpack a message in Java. -/// -/// Foo foo = ...; -/// Any any = Any.pack(foo); -/// ... -/// if (any.is(Foo.class)) { -/// foo = any.unpack(Foo.class); -/// } -/// // or ... -/// if (any.isSameTypeAs(Foo.getDefaultInstance())) { -/// foo = any.unpack(Foo.getDefaultInstance()); -/// } -/// -/// Example 3: Pack and unpack a message in Python. -/// -/// foo = Foo(...) -/// any = Any() -/// any.Pack(foo) -/// ... -/// if any.Is(Foo.DESCRIPTOR): -/// any.Unpack(foo) -/// ... -/// -/// Example 4: Pack and unpack a message in Go -/// -/// foo := &pb.Foo{...} -/// any, err := anypb.New(foo) -/// if err != nil { -/// ... -/// } -/// ... -/// foo := &pb.Foo{} -/// if err := any.UnmarshalTo(foo); err != nil { -/// ... -/// } -/// -/// The pack methods provided by protobuf library will by default use -/// 'type.googleapis.com/full.type.name' as the type URL and the unpack -/// methods only use the fully qualified type name after the last '/' -/// in the type URL, for example "foo.bar.com/x/y.z" will yield type -/// name "y.z". -/// -/// JSON -/// ==== -/// The JSON representation of an `Any` value uses the regular -/// representation of the deserialized, embedded message, with an -/// additional field `@type` which contains the type URL. Example: -/// -/// package google.profile; -/// message Person { -/// string first_name = 1; -/// string last_name = 2; -/// } -/// -/// { -/// "@type": "type.googleapis.com/google.profile.Person", -/// "firstName": , -/// "lastName": -/// } -/// -/// If the embedded message type is well-known and has a custom JSON -/// representation, that representation will be embedded adding a field -/// `value` which holds the custom JSON in addition to the `@type` -/// field. Example (for message [google.protobuf.Duration][]): -/// -/// { -/// "@type": "type.googleapis.com/google.protobuf.Duration", -/// "value": "1.212s" -/// } -class Any extends $pb.GeneratedMessage with $mixin.AnyMixin { - factory Any({ - $core.String? typeUrl, - $core.List<$core.int>? value, - }) { - final $result = create(); - if (typeUrl != null) { - $result.typeUrl = typeUrl; - } - if (value != null) { - $result.value = value; - } - return $result; - } - Any._() : super(); - factory Any.fromBuffer($core.List<$core.int> i, - [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromBuffer(i, r); - factory Any.fromJson($core.String i, - [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromJson(i, r); - - static final $pb.BuilderInfo _i = $pb.BuilderInfo( - _omitMessageNames ? '' : 'Any', - package: - const $pb.PackageName(_omitMessageNames ? '' : 'google.protobuf'), - createEmptyInstance: create, - toProto3Json: $mixin.AnyMixin.toProto3JsonHelper, - fromProto3Json: $mixin.AnyMixin.fromProto3JsonHelper) - ..aOS(1, _omitFieldNames ? '' : 'typeUrl') - ..a<$core.List<$core.int>>( - 2, _omitFieldNames ? '' : 'value', $pb.PbFieldType.OY) - ..hasRequiredFields = false; - - @$core.Deprecated('Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - Any clone() => Any()..mergeFromMessage(this); - @$core.Deprecated('Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - Any copyWith(void Function(Any) updates) => - super.copyWith((message) => updates(message as Any)) as Any; - - $pb.BuilderInfo get info_ => _i; - - @$core.pragma('dart2js:noInline') - static Any create() => Any._(); - Any createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - @$core.pragma('dart2js:noInline') - static Any getDefault() => - _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); - static Any? _defaultInstance; - - /// A URL/resource name that uniquely identifies the type of the serialized - /// protocol buffer message. This string must contain at least - /// one "/" character. The last segment of the URL's path must represent - /// the fully qualified name of the type (as in - /// `path/google.protobuf.Duration`). The name should be in a canonical form - /// (e.g., leading "." is not accepted). - /// - /// In practice, teams usually precompile into the binary all types that they - /// expect it to use in the context of Any. However, for URLs which use the - /// scheme `http`, `https`, or no scheme, one can optionally set up a type - /// server that maps type URLs to message definitions as follows: - /// - /// * If no scheme is provided, `https` is assumed. - /// * An HTTP GET on the URL must yield a [google.protobuf.Type][] - /// value in binary format, or produce an error. - /// * Applications are allowed to cache lookup results based on the - /// URL, or have them precompiled into a binary to avoid any - /// lookup. Therefore, binary compatibility needs to be preserved - /// on changes to types. (Use versioned type names to manage - /// breaking changes.) - /// - /// Note: this functionality is not currently available in the official - /// protobuf release, and it is not used for type URLs beginning with - /// type.googleapis.com. As of May 2023, there are no widely used type server - /// implementations and no plans to implement one. - /// - /// Schemes other than `http`, `https` (or the empty scheme) might be - /// used with implementation specific semantics. - @$pb.TagNumber(1) - $core.String get typeUrl => $_getSZ(0); - @$pb.TagNumber(1) - set typeUrl($core.String v) { - $_setString(0, v); - } - - @$pb.TagNumber(1) - $core.bool hasTypeUrl() => $_has(0); - @$pb.TagNumber(1) - void clearTypeUrl() => clearField(1); - - /// Must be a valid serialized protocol buffer of the above specified type. - @$pb.TagNumber(2) - $core.List<$core.int> get value => $_getN(1); - @$pb.TagNumber(2) - set value($core.List<$core.int> v) { - $_setBytes(1, v); - } - - @$pb.TagNumber(2) - $core.bool hasValue() => $_has(1); - @$pb.TagNumber(2) - void clearValue() => clearField(2); - - /// Creates a new [Any] encoding [message]. - /// - /// The [typeUrl] will be [typeUrlPrefix]/`fullName` where `fullName` is - /// the fully qualified name of the type of [message]. - static Any pack($pb.GeneratedMessage message, - {$core.String typeUrlPrefix = 'type.googleapis.com'}) { - final result = create(); - $mixin.AnyMixin.packIntoAny(result, message, typeUrlPrefix: typeUrlPrefix); - return result; - } -} - -const _omitFieldNames = $core.bool.fromEnvironment('protobuf.omit_field_names'); -const _omitMessageNames = - $core.bool.fromEnvironment('protobuf.omit_message_names'); diff --git a/packages/io_library/lib/src/serialization/proto/output/google/protobuf/any.pbenum.dart b/packages/io_library/lib/src/serialization/proto/output/google/protobuf/any.pbenum.dart deleted file mode 100644 index 3744f124..00000000 --- a/packages/io_library/lib/src/serialization/proto/output/google/protobuf/any.pbenum.dart +++ /dev/null @@ -1,10 +0,0 @@ -// -// Generated code. Do not modify. -// source: google/protobuf/any.proto -// -// @dart = 2.12 - -// ignore_for_file: annotate_overrides, camel_case_types, comment_references -// ignore_for_file: constant_identifier_names, library_prefixes -// ignore_for_file: non_constant_identifier_names, prefer_final_fields -// ignore_for_file: unnecessary_import, unnecessary_this, unused_import diff --git a/packages/io_library/lib/src/serialization/proto/output/google/protobuf/any.pbjson.dart b/packages/io_library/lib/src/serialization/proto/output/google/protobuf/any.pbjson.dart deleted file mode 100644 index eafbc6bd..00000000 --- a/packages/io_library/lib/src/serialization/proto/output/google/protobuf/any.pbjson.dart +++ /dev/null @@ -1,27 +0,0 @@ -// -// Generated code. Do not modify. -// source: google/protobuf/any.proto -// -// @dart = 2.12 - -// ignore_for_file: annotate_overrides, camel_case_types, comment_references -// ignore_for_file: constant_identifier_names, library_prefixes -// ignore_for_file: non_constant_identifier_names, prefer_final_fields -// ignore_for_file: unnecessary_import, unnecessary_this, unused_import - -import 'dart:convert' as $convert; -import 'dart:core' as $core; -import 'dart:typed_data' as $typed_data; - -@$core.Deprecated('Use anyDescriptor instead') -const Any$json = { - '1': 'Any', - '2': [ - {'1': 'type_url', '3': 1, '4': 1, '5': 9, '10': 'typeUrl'}, - {'1': 'value', '3': 2, '4': 1, '5': 12, '10': 'value'}, - ], -}; - -/// Descriptor for `Any`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List anyDescriptor = $convert.base64Decode( - 'CgNBbnkSGQoIdHlwZV91cmwYASABKAlSB3R5cGVVcmwSFAoFdmFsdWUYAiABKAxSBXZhbHVl'); diff --git a/packages/io_library/lib/src/serialization/proto/output/google/protobuf/any.pbserver.dart b/packages/io_library/lib/src/serialization/proto/output/google/protobuf/any.pbserver.dart deleted file mode 100644 index 227b7b2c..00000000 --- a/packages/io_library/lib/src/serialization/proto/output/google/protobuf/any.pbserver.dart +++ /dev/null @@ -1,13 +0,0 @@ -// -// Generated code. Do not modify. -// source: google/protobuf/any.proto -// -// @dart = 2.12 - -// ignore_for_file: annotate_overrides, camel_case_types, comment_references -// ignore_for_file: constant_identifier_names -// ignore_for_file: deprecated_member_use_from_same_package, library_prefixes -// ignore_for_file: non_constant_identifier_names, prefer_final_fields -// ignore_for_file: unnecessary_import, unnecessary_this, unused_import - -export 'any.pb.dart'; diff --git a/packages/io_library/lib/src/serialization/proto/output/graphic/paint.pb.dart b/packages/io_library/lib/src/serialization/proto/output/graphic/paint.pb.dart deleted file mode 100644 index 7598857a..00000000 --- a/packages/io_library/lib/src/serialization/proto/output/graphic/paint.pb.dart +++ /dev/null @@ -1,187 +0,0 @@ -// -// Generated code. Do not modify. -// source: graphic/paint.proto -// -// @dart = 2.12 - -// ignore_for_file: annotate_overrides, camel_case_types, comment_references -// ignore_for_file: constant_identifier_names, library_prefixes -// ignore_for_file: non_constant_identifier_names, prefer_final_fields -// ignore_for_file: unnecessary_import, unnecessary_this, unused_import - -import 'dart:core' as $core; - -import 'package:protobuf/protobuf.dart' as $pb; - -import 'paint.pbenum.dart'; - -export 'paint.pbenum.dart'; - -class SerializablePaint extends $pb.GeneratedMessage { - factory SerializablePaint({ - $core.int? color, - $core.double? strokeWidth, - SerializablePaint_StrokeCap? cap, - SerializablePaint_PaintingStyle? style, - SerializablePaint_BlendMode? blendMode, - SerializablePaint_StrokeJoin? strokeJoin, - }) { - final $result = create(); - if (color != null) { - $result.color = color; - } - if (strokeWidth != null) { - $result.strokeWidth = strokeWidth; - } - if (cap != null) { - $result.cap = cap; - } - if (style != null) { - $result.style = style; - } - if (blendMode != null) { - $result.blendMode = blendMode; - } - if (strokeJoin != null) { - $result.strokeJoin = strokeJoin; - } - return $result; - } - SerializablePaint._() : super(); - factory SerializablePaint.fromBuffer($core.List<$core.int> i, - [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromBuffer(i, r); - factory SerializablePaint.fromJson($core.String i, - [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromJson(i, r); - - static final $pb.BuilderInfo _i = $pb.BuilderInfo( - _omitMessageNames ? '' : 'SerializablePaint', - createEmptyInstance: create) - ..a<$core.int>(1, _omitFieldNames ? '' : 'color', $pb.PbFieldType.OU3) - ..a<$core.double>( - 2, _omitFieldNames ? '' : 'strokeWidth', $pb.PbFieldType.OF, - protoName: 'strokeWidth') - ..e( - 3, _omitFieldNames ? '' : 'cap', $pb.PbFieldType.OE, - defaultOrMaker: SerializablePaint_StrokeCap.STROKE_CAP_ROUND, - valueOf: SerializablePaint_StrokeCap.valueOf, - enumValues: SerializablePaint_StrokeCap.values) - ..e( - 4, _omitFieldNames ? '' : 'style', $pb.PbFieldType.OE, - defaultOrMaker: SerializablePaint_PaintingStyle.PAINTING_STYLE_FILL, - valueOf: SerializablePaint_PaintingStyle.valueOf, - enumValues: SerializablePaint_PaintingStyle.values) - ..e( - 5, _omitFieldNames ? '' : 'blendMode', $pb.PbFieldType.OE, - protoName: 'blendMode', - defaultOrMaker: SerializablePaint_BlendMode.BLEND_MODE_SCR_OVER, - valueOf: SerializablePaint_BlendMode.valueOf, - enumValues: SerializablePaint_BlendMode.values) - ..e( - 6, _omitFieldNames ? '' : 'strokeJoin', $pb.PbFieldType.OE, - protoName: 'strokeJoin', - defaultOrMaker: SerializablePaint_StrokeJoin.STROKE_JOIN_MITER, - valueOf: SerializablePaint_StrokeJoin.valueOf, - enumValues: SerializablePaint_StrokeJoin.values) - ..hasRequiredFields = false; - - @$core.Deprecated('Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - SerializablePaint clone() => SerializablePaint()..mergeFromMessage(this); - @$core.Deprecated('Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - SerializablePaint copyWith(void Function(SerializablePaint) updates) => - super.copyWith((message) => updates(message as SerializablePaint)) - as SerializablePaint; - - $pb.BuilderInfo get info_ => _i; - - @$core.pragma('dart2js:noInline') - static SerializablePaint create() => SerializablePaint._(); - SerializablePaint createEmptyInstance() => create(); - static $pb.PbList createRepeated() => - $pb.PbList(); - @$core.pragma('dart2js:noInline') - static SerializablePaint getDefault() => _defaultInstance ??= - $pb.GeneratedMessage.$_defaultFor(create); - static SerializablePaint? _defaultInstance; - - @$pb.TagNumber(1) - $core.int get color => $_getIZ(0); - @$pb.TagNumber(1) - set color($core.int v) { - $_setUnsignedInt32(0, v); - } - - @$pb.TagNumber(1) - $core.bool hasColor() => $_has(0); - @$pb.TagNumber(1) - void clearColor() => clearField(1); - - @$pb.TagNumber(2) - $core.double get strokeWidth => $_getN(1); - @$pb.TagNumber(2) - set strokeWidth($core.double v) { - $_setFloat(1, v); - } - - @$pb.TagNumber(2) - $core.bool hasStrokeWidth() => $_has(1); - @$pb.TagNumber(2) - void clearStrokeWidth() => clearField(2); - - @$pb.TagNumber(3) - SerializablePaint_StrokeCap get cap => $_getN(2); - @$pb.TagNumber(3) - set cap(SerializablePaint_StrokeCap v) { - setField(3, v); - } - - @$pb.TagNumber(3) - $core.bool hasCap() => $_has(2); - @$pb.TagNumber(3) - void clearCap() => clearField(3); - - @$pb.TagNumber(4) - SerializablePaint_PaintingStyle get style => $_getN(3); - @$pb.TagNumber(4) - set style(SerializablePaint_PaintingStyle v) { - setField(4, v); - } - - @$pb.TagNumber(4) - $core.bool hasStyle() => $_has(3); - @$pb.TagNumber(4) - void clearStyle() => clearField(4); - - @$pb.TagNumber(5) - SerializablePaint_BlendMode get blendMode => $_getN(4); - @$pb.TagNumber(5) - set blendMode(SerializablePaint_BlendMode v) { - setField(5, v); - } - - @$pb.TagNumber(5) - $core.bool hasBlendMode() => $_has(4); - @$pb.TagNumber(5) - void clearBlendMode() => clearField(5); - - @$pb.TagNumber(6) - SerializablePaint_StrokeJoin get strokeJoin => $_getN(5); - @$pb.TagNumber(6) - set strokeJoin(SerializablePaint_StrokeJoin v) { - setField(6, v); - } - - @$pb.TagNumber(6) - $core.bool hasStrokeJoin() => $_has(5); - @$pb.TagNumber(6) - void clearStrokeJoin() => clearField(6); -} - -const _omitFieldNames = $core.bool.fromEnvironment('protobuf.omit_field_names'); -const _omitMessageNames = - $core.bool.fromEnvironment('protobuf.omit_message_names'); diff --git a/packages/io_library/lib/src/serialization/proto/output/graphic/paint.pbenum.dart b/packages/io_library/lib/src/serialization/proto/output/graphic/paint.pbenum.dart deleted file mode 100644 index fd71611c..00000000 --- a/packages/io_library/lib/src/serialization/proto/output/graphic/paint.pbenum.dart +++ /dev/null @@ -1,115 +0,0 @@ -// -// Generated code. Do not modify. -// source: graphic/paint.proto -// -// @dart = 2.12 - -// ignore_for_file: annotate_overrides, camel_case_types, comment_references -// ignore_for_file: constant_identifier_names, library_prefixes -// ignore_for_file: non_constant_identifier_names, prefer_final_fields -// ignore_for_file: unnecessary_import, unnecessary_this, unused_import - -import 'dart:core' as $core; - -import 'package:protobuf/protobuf.dart' as $pb; - -class SerializablePaint_StrokeCap extends $pb.ProtobufEnum { - static const SerializablePaint_StrokeCap STROKE_CAP_ROUND = - SerializablePaint_StrokeCap._( - 0, _omitEnumNames ? '' : 'STROKE_CAP_ROUND'); - static const SerializablePaint_StrokeCap STROKE_CAP_BUTT = - SerializablePaint_StrokeCap._(1, _omitEnumNames ? '' : 'STROKE_CAP_BUTT'); - static const SerializablePaint_StrokeCap STROKE_CAP_SQUARE = - SerializablePaint_StrokeCap._( - 2, _omitEnumNames ? '' : 'STROKE_CAP_SQUARE'); - - static const $core.List values = - [ - STROKE_CAP_ROUND, - STROKE_CAP_BUTT, - STROKE_CAP_SQUARE, - ]; - - static final $core.Map<$core.int, SerializablePaint_StrokeCap> _byValue = - $pb.ProtobufEnum.initByValue(values); - static SerializablePaint_StrokeCap? valueOf($core.int value) => - _byValue[value]; - - const SerializablePaint_StrokeCap._($core.int v, $core.String n) - : super(v, n); -} - -class SerializablePaint_PaintingStyle extends $pb.ProtobufEnum { - static const SerializablePaint_PaintingStyle PAINTING_STYLE_FILL = - SerializablePaint_PaintingStyle._( - 0, _omitEnumNames ? '' : 'PAINTING_STYLE_FILL'); - static const SerializablePaint_PaintingStyle PAINTING_STYLE_STROKE = - SerializablePaint_PaintingStyle._( - 1, _omitEnumNames ? '' : 'PAINTING_STYLE_STROKE'); - - static const $core.List values = - [ - PAINTING_STYLE_FILL, - PAINTING_STYLE_STROKE, - ]; - - static final $core.Map<$core.int, SerializablePaint_PaintingStyle> _byValue = - $pb.ProtobufEnum.initByValue(values); - static SerializablePaint_PaintingStyle? valueOf($core.int value) => - _byValue[value]; - - const SerializablePaint_PaintingStyle._($core.int v, $core.String n) - : super(v, n); -} - -class SerializablePaint_BlendMode extends $pb.ProtobufEnum { - static const SerializablePaint_BlendMode BLEND_MODE_SCR_OVER = - SerializablePaint_BlendMode._( - 0, _omitEnumNames ? '' : 'BLEND_MODE_SCR_OVER'); - static const SerializablePaint_BlendMode BLEND_MODE_CLEAR = - SerializablePaint_BlendMode._( - 1, _omitEnumNames ? '' : 'BLEND_MODE_CLEAR'); - - static const $core.List values = - [ - BLEND_MODE_SCR_OVER, - BLEND_MODE_CLEAR, - ]; - - static final $core.Map<$core.int, SerializablePaint_BlendMode> _byValue = - $pb.ProtobufEnum.initByValue(values); - static SerializablePaint_BlendMode? valueOf($core.int value) => - _byValue[value]; - - const SerializablePaint_BlendMode._($core.int v, $core.String n) - : super(v, n); -} - -class SerializablePaint_StrokeJoin extends $pb.ProtobufEnum { - static const SerializablePaint_StrokeJoin STROKE_JOIN_MITER = - SerializablePaint_StrokeJoin._( - 0, _omitEnumNames ? '' : 'STROKE_JOIN_MITER'); - static const SerializablePaint_StrokeJoin STROKE_JOIN_ROUND = - SerializablePaint_StrokeJoin._( - 1, _omitEnumNames ? '' : 'STROKE_JOIN_ROUND'); - static const SerializablePaint_StrokeJoin STROKE_JOIN_BEVEL = - SerializablePaint_StrokeJoin._( - 2, _omitEnumNames ? '' : 'STROKE_JOIN_BEVEL'); - - static const $core.List values = - [ - STROKE_JOIN_MITER, - STROKE_JOIN_ROUND, - STROKE_JOIN_BEVEL, - ]; - - static final $core.Map<$core.int, SerializablePaint_StrokeJoin> _byValue = - $pb.ProtobufEnum.initByValue(values); - static SerializablePaint_StrokeJoin? valueOf($core.int value) => - _byValue[value]; - - const SerializablePaint_StrokeJoin._($core.int v, $core.String n) - : super(v, n); -} - -const _omitEnumNames = $core.bool.fromEnvironment('protobuf.omit_enum_names'); diff --git a/packages/io_library/lib/src/serialization/proto/output/graphic/paint.pbjson.dart b/packages/io_library/lib/src/serialization/proto/output/graphic/paint.pbjson.dart deleted file mode 100644 index 98ae48cc..00000000 --- a/packages/io_library/lib/src/serialization/proto/output/graphic/paint.pbjson.dart +++ /dev/null @@ -1,113 +0,0 @@ -// -// Generated code. Do not modify. -// source: graphic/paint.proto -// -// @dart = 2.12 - -// ignore_for_file: annotate_overrides, camel_case_types, comment_references -// ignore_for_file: constant_identifier_names, library_prefixes -// ignore_for_file: non_constant_identifier_names, prefer_final_fields -// ignore_for_file: unnecessary_import, unnecessary_this, unused_import - -import 'dart:convert' as $convert; -import 'dart:core' as $core; -import 'dart:typed_data' as $typed_data; - -@$core.Deprecated('Use serializablePaintDescriptor instead') -const SerializablePaint$json = { - '1': 'SerializablePaint', - '2': [ - {'1': 'color', '3': 1, '4': 1, '5': 13, '10': 'color'}, - {'1': 'strokeWidth', '3': 2, '4': 1, '5': 2, '10': 'strokeWidth'}, - { - '1': 'cap', - '3': 3, - '4': 1, - '5': 14, - '6': '.SerializablePaint.StrokeCap', - '10': 'cap' - }, - { - '1': 'style', - '3': 4, - '4': 1, - '5': 14, - '6': '.SerializablePaint.PaintingStyle', - '10': 'style' - }, - { - '1': 'blendMode', - '3': 5, - '4': 1, - '5': 14, - '6': '.SerializablePaint.BlendMode', - '10': 'blendMode' - }, - { - '1': 'strokeJoin', - '3': 6, - '4': 1, - '5': 14, - '6': '.SerializablePaint.StrokeJoin', - '10': 'strokeJoin' - }, - ], - '4': [ - SerializablePaint_StrokeCap$json, - SerializablePaint_PaintingStyle$json, - SerializablePaint_BlendMode$json, - SerializablePaint_StrokeJoin$json - ], -}; - -@$core.Deprecated('Use serializablePaintDescriptor instead') -const SerializablePaint_StrokeCap$json = { - '1': 'StrokeCap', - '2': [ - {'1': 'STROKE_CAP_ROUND', '2': 0}, - {'1': 'STROKE_CAP_BUTT', '2': 1}, - {'1': 'STROKE_CAP_SQUARE', '2': 2}, - ], -}; - -@$core.Deprecated('Use serializablePaintDescriptor instead') -const SerializablePaint_PaintingStyle$json = { - '1': 'PaintingStyle', - '2': [ - {'1': 'PAINTING_STYLE_FILL', '2': 0}, - {'1': 'PAINTING_STYLE_STROKE', '2': 1}, - ], -}; - -@$core.Deprecated('Use serializablePaintDescriptor instead') -const SerializablePaint_BlendMode$json = { - '1': 'BlendMode', - '2': [ - {'1': 'BLEND_MODE_SCR_OVER', '2': 0}, - {'1': 'BLEND_MODE_CLEAR', '2': 1}, - ], -}; - -@$core.Deprecated('Use serializablePaintDescriptor instead') -const SerializablePaint_StrokeJoin$json = { - '1': 'StrokeJoin', - '2': [ - {'1': 'STROKE_JOIN_MITER', '2': 0}, - {'1': 'STROKE_JOIN_ROUND', '2': 1}, - {'1': 'STROKE_JOIN_BEVEL', '2': 2}, - ], -}; - -/// Descriptor for `SerializablePaint`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List serializablePaintDescriptor = $convert.base64Decode( - 'ChFTZXJpYWxpemFibGVQYWludBIUCgVjb2xvchgBIAEoDVIFY29sb3ISIAoLc3Ryb2tlV2lkdG' - 'gYAiABKAJSC3N0cm9rZVdpZHRoEi4KA2NhcBgDIAEoDjIcLlNlcmlhbGl6YWJsZVBhaW50LlN0' - 'cm9rZUNhcFIDY2FwEjYKBXN0eWxlGAQgASgOMiAuU2VyaWFsaXphYmxlUGFpbnQuUGFpbnRpbm' - 'dTdHlsZVIFc3R5bGUSOgoJYmxlbmRNb2RlGAUgASgOMhwuU2VyaWFsaXphYmxlUGFpbnQuQmxl' - 'bmRNb2RlUglibGVuZE1vZGUSPQoKc3Ryb2tlSm9pbhgGIAEoDjIdLlNlcmlhbGl6YWJsZVBhaW' - '50LlN0cm9rZUpvaW5SCnN0cm9rZUpvaW4iTQoJU3Ryb2tlQ2FwEhQKEFNUUk9LRV9DQVBfUk9V' - 'TkQQABITCg9TVFJPS0VfQ0FQX0JVVFQQARIVChFTVFJPS0VfQ0FQX1NRVUFSRRACIkMKDVBhaW' - '50aW5nU3R5bGUSFwoTUEFJTlRJTkdfU1RZTEVfRklMTBAAEhkKFVBBSU5USU5HX1NUWUxFX1NU' - 'Uk9LRRABIjoKCUJsZW5kTW9kZRIXChNCTEVORF9NT0RFX1NDUl9PVkVSEAASFAoQQkxFTkRfTU' - '9ERV9DTEVBUhABIlEKClN0cm9rZUpvaW4SFQoRU1RST0tFX0pPSU5fTUlURVIQABIVChFTVFJP' - 'S0VfSk9JTl9ST1VORBABEhUKEVNUUk9LRV9KT0lOX0JFVkVMEAI='); diff --git a/packages/io_library/lib/src/serialization/proto/output/graphic/paint.pbserver.dart b/packages/io_library/lib/src/serialization/proto/output/graphic/paint.pbserver.dart deleted file mode 100644 index 4b9c3196..00000000 --- a/packages/io_library/lib/src/serialization/proto/output/graphic/paint.pbserver.dart +++ /dev/null @@ -1,13 +0,0 @@ -// -// Generated code. Do not modify. -// source: graphic/paint.proto -// -// @dart = 2.12 - -// ignore_for_file: annotate_overrides, camel_case_types, comment_references -// ignore_for_file: constant_identifier_names -// ignore_for_file: deprecated_member_use_from_same_package, library_prefixes -// ignore_for_file: non_constant_identifier_names, prefer_final_fields -// ignore_for_file: unnecessary_import, unnecessary_this, unused_import - -export 'paint.pb.dart'; diff --git a/packages/io_library/lib/src/serialization/proto/output/graphic/path.pb.dart b/packages/io_library/lib/src/serialization/proto/output/graphic/path.pb.dart deleted file mode 100644 index 1e21d472..00000000 --- a/packages/io_library/lib/src/serialization/proto/output/graphic/path.pb.dart +++ /dev/null @@ -1,420 +0,0 @@ -// -// Generated code. Do not modify. -// source: graphic/path.proto -// -// @dart = 2.12 - -// ignore_for_file: annotate_overrides, camel_case_types, comment_references -// ignore_for_file: constant_identifier_names, library_prefixes -// ignore_for_file: non_constant_identifier_names, prefer_final_fields -// ignore_for_file: unnecessary_import, unnecessary_this, unused_import - -import 'dart:core' as $core; - -import 'package:protobuf/protobuf.dart' as $pb; - -import 'path.pbenum.dart'; - -export 'path.pbenum.dart'; - -class SerializablePath_Action_MoveTo extends $pb.GeneratedMessage { - factory SerializablePath_Action_MoveTo({ - $core.double? x, - $core.double? y, - }) { - final $result = create(); - if (x != null) { - $result.x = x; - } - if (y != null) { - $result.y = y; - } - return $result; - } - SerializablePath_Action_MoveTo._() : super(); - factory SerializablePath_Action_MoveTo.fromBuffer($core.List<$core.int> i, - [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromBuffer(i, r); - factory SerializablePath_Action_MoveTo.fromJson($core.String i, - [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromJson(i, r); - - static final $pb.BuilderInfo _i = $pb.BuilderInfo( - _omitMessageNames ? '' : 'SerializablePath.Action.MoveTo', - createEmptyInstance: create) - ..a<$core.double>(1, _omitFieldNames ? '' : 'x', $pb.PbFieldType.OD) - ..a<$core.double>(2, _omitFieldNames ? '' : 'y', $pb.PbFieldType.OD) - ..hasRequiredFields = false; - - @$core.Deprecated('Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - SerializablePath_Action_MoveTo clone() => - SerializablePath_Action_MoveTo()..mergeFromMessage(this); - @$core.Deprecated('Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - SerializablePath_Action_MoveTo copyWith( - void Function(SerializablePath_Action_MoveTo) updates) => - super.copyWith( - (message) => updates(message as SerializablePath_Action_MoveTo)) - as SerializablePath_Action_MoveTo; - - $pb.BuilderInfo get info_ => _i; - - @$core.pragma('dart2js:noInline') - static SerializablePath_Action_MoveTo create() => - SerializablePath_Action_MoveTo._(); - SerializablePath_Action_MoveTo createEmptyInstance() => create(); - static $pb.PbList createRepeated() => - $pb.PbList(); - @$core.pragma('dart2js:noInline') - static SerializablePath_Action_MoveTo getDefault() => _defaultInstance ??= - $pb.GeneratedMessage.$_defaultFor(create); - static SerializablePath_Action_MoveTo? _defaultInstance; - - @$pb.TagNumber(1) - $core.double get x => $_getN(0); - @$pb.TagNumber(1) - set x($core.double v) { - $_setDouble(0, v); - } - - @$pb.TagNumber(1) - $core.bool hasX() => $_has(0); - @$pb.TagNumber(1) - void clearX() => clearField(1); - - @$pb.TagNumber(2) - $core.double get y => $_getN(1); - @$pb.TagNumber(2) - set y($core.double v) { - $_setDouble(1, v); - } - - @$pb.TagNumber(2) - $core.bool hasY() => $_has(1); - @$pb.TagNumber(2) - void clearY() => clearField(2); -} - -class SerializablePath_Action_LineTo extends $pb.GeneratedMessage { - factory SerializablePath_Action_LineTo({ - $core.double? x, - $core.double? y, - }) { - final $result = create(); - if (x != null) { - $result.x = x; - } - if (y != null) { - $result.y = y; - } - return $result; - } - SerializablePath_Action_LineTo._() : super(); - factory SerializablePath_Action_LineTo.fromBuffer($core.List<$core.int> i, - [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromBuffer(i, r); - factory SerializablePath_Action_LineTo.fromJson($core.String i, - [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromJson(i, r); - - static final $pb.BuilderInfo _i = $pb.BuilderInfo( - _omitMessageNames ? '' : 'SerializablePath.Action.LineTo', - createEmptyInstance: create) - ..a<$core.double>(1, _omitFieldNames ? '' : 'x', $pb.PbFieldType.OD) - ..a<$core.double>(2, _omitFieldNames ? '' : 'y', $pb.PbFieldType.OD) - ..hasRequiredFields = false; - - @$core.Deprecated('Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - SerializablePath_Action_LineTo clone() => - SerializablePath_Action_LineTo()..mergeFromMessage(this); - @$core.Deprecated('Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - SerializablePath_Action_LineTo copyWith( - void Function(SerializablePath_Action_LineTo) updates) => - super.copyWith( - (message) => updates(message as SerializablePath_Action_LineTo)) - as SerializablePath_Action_LineTo; - - $pb.BuilderInfo get info_ => _i; - - @$core.pragma('dart2js:noInline') - static SerializablePath_Action_LineTo create() => - SerializablePath_Action_LineTo._(); - SerializablePath_Action_LineTo createEmptyInstance() => create(); - static $pb.PbList createRepeated() => - $pb.PbList(); - @$core.pragma('dart2js:noInline') - static SerializablePath_Action_LineTo getDefault() => _defaultInstance ??= - $pb.GeneratedMessage.$_defaultFor(create); - static SerializablePath_Action_LineTo? _defaultInstance; - - @$pb.TagNumber(1) - $core.double get x => $_getN(0); - @$pb.TagNumber(1) - set x($core.double v) { - $_setDouble(0, v); - } - - @$pb.TagNumber(1) - $core.bool hasX() => $_has(0); - @$pb.TagNumber(1) - void clearX() => clearField(1); - - @$pb.TagNumber(2) - $core.double get y => $_getN(1); - @$pb.TagNumber(2) - set y($core.double v) { - $_setDouble(1, v); - } - - @$pb.TagNumber(2) - $core.bool hasY() => $_has(1); - @$pb.TagNumber(2) - void clearY() => clearField(2); -} - -class SerializablePath_Action_Close extends $pb.GeneratedMessage { - factory SerializablePath_Action_Close() => create(); - SerializablePath_Action_Close._() : super(); - factory SerializablePath_Action_Close.fromBuffer($core.List<$core.int> i, - [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromBuffer(i, r); - factory SerializablePath_Action_Close.fromJson($core.String i, - [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromJson(i, r); - - static final $pb.BuilderInfo _i = $pb.BuilderInfo( - _omitMessageNames ? '' : 'SerializablePath.Action.Close', - createEmptyInstance: create) - ..hasRequiredFields = false; - - @$core.Deprecated('Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - SerializablePath_Action_Close clone() => - SerializablePath_Action_Close()..mergeFromMessage(this); - @$core.Deprecated('Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - SerializablePath_Action_Close copyWith( - void Function(SerializablePath_Action_Close) updates) => - super.copyWith( - (message) => updates(message as SerializablePath_Action_Close)) - as SerializablePath_Action_Close; - - $pb.BuilderInfo get info_ => _i; - - @$core.pragma('dart2js:noInline') - static SerializablePath_Action_Close create() => - SerializablePath_Action_Close._(); - SerializablePath_Action_Close createEmptyInstance() => create(); - static $pb.PbList createRepeated() => - $pb.PbList(); - @$core.pragma('dart2js:noInline') - static SerializablePath_Action_Close getDefault() => _defaultInstance ??= - $pb.GeneratedMessage.$_defaultFor(create); - static SerializablePath_Action_Close? _defaultInstance; -} - -enum SerializablePath_Action_Action { moveTo, lineTo, close, notSet } - -class SerializablePath_Action extends $pb.GeneratedMessage { - factory SerializablePath_Action({ - SerializablePath_Action_MoveTo? moveTo, - SerializablePath_Action_LineTo? lineTo, - SerializablePath_Action_Close? close, - }) { - final $result = create(); - if (moveTo != null) { - $result.moveTo = moveTo; - } - if (lineTo != null) { - $result.lineTo = lineTo; - } - if (close != null) { - $result.close = close; - } - return $result; - } - SerializablePath_Action._() : super(); - factory SerializablePath_Action.fromBuffer($core.List<$core.int> i, - [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromBuffer(i, r); - factory SerializablePath_Action.fromJson($core.String i, - [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromJson(i, r); - - static const $core.Map<$core.int, SerializablePath_Action_Action> - _SerializablePath_Action_ActionByTag = { - 1: SerializablePath_Action_Action.moveTo, - 2: SerializablePath_Action_Action.lineTo, - 3: SerializablePath_Action_Action.close, - 0: SerializablePath_Action_Action.notSet - }; - static final $pb.BuilderInfo _i = $pb.BuilderInfo( - _omitMessageNames ? '' : 'SerializablePath.Action', - createEmptyInstance: create) - ..oo(0, [1, 2, 3]) - ..aOM(1, _omitFieldNames ? '' : 'moveTo', - subBuilder: SerializablePath_Action_MoveTo.create) - ..aOM(2, _omitFieldNames ? '' : 'lineTo', - subBuilder: SerializablePath_Action_LineTo.create) - ..aOM(3, _omitFieldNames ? '' : 'close', - subBuilder: SerializablePath_Action_Close.create) - ..hasRequiredFields = false; - - @$core.Deprecated('Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - SerializablePath_Action clone() => - SerializablePath_Action()..mergeFromMessage(this); - @$core.Deprecated('Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - SerializablePath_Action copyWith( - void Function(SerializablePath_Action) updates) => - super.copyWith((message) => updates(message as SerializablePath_Action)) - as SerializablePath_Action; - - $pb.BuilderInfo get info_ => _i; - - @$core.pragma('dart2js:noInline') - static SerializablePath_Action create() => SerializablePath_Action._(); - SerializablePath_Action createEmptyInstance() => create(); - static $pb.PbList createRepeated() => - $pb.PbList(); - @$core.pragma('dart2js:noInline') - static SerializablePath_Action getDefault() => _defaultInstance ??= - $pb.GeneratedMessage.$_defaultFor(create); - static SerializablePath_Action? _defaultInstance; - - SerializablePath_Action_Action whichAction() => - _SerializablePath_Action_ActionByTag[$_whichOneof(0)]!; - void clearAction() => clearField($_whichOneof(0)); - - @$pb.TagNumber(1) - SerializablePath_Action_MoveTo get moveTo => $_getN(0); - @$pb.TagNumber(1) - set moveTo(SerializablePath_Action_MoveTo v) { - setField(1, v); - } - - @$pb.TagNumber(1) - $core.bool hasMoveTo() => $_has(0); - @$pb.TagNumber(1) - void clearMoveTo() => clearField(1); - @$pb.TagNumber(1) - SerializablePath_Action_MoveTo ensureMoveTo() => $_ensure(0); - - @$pb.TagNumber(2) - SerializablePath_Action_LineTo get lineTo => $_getN(1); - @$pb.TagNumber(2) - set lineTo(SerializablePath_Action_LineTo v) { - setField(2, v); - } - - @$pb.TagNumber(2) - $core.bool hasLineTo() => $_has(1); - @$pb.TagNumber(2) - void clearLineTo() => clearField(2); - @$pb.TagNumber(2) - SerializablePath_Action_LineTo ensureLineTo() => $_ensure(1); - - @$pb.TagNumber(3) - SerializablePath_Action_Close get close => $_getN(2); - @$pb.TagNumber(3) - set close(SerializablePath_Action_Close v) { - setField(3, v); - } - - @$pb.TagNumber(3) - $core.bool hasClose() => $_has(2); - @$pb.TagNumber(3) - void clearClose() => clearField(3); - @$pb.TagNumber(3) - SerializablePath_Action_Close ensureClose() => $_ensure(2); -} - -class SerializablePath extends $pb.GeneratedMessage { - factory SerializablePath({ - $core.Iterable? actions, - SerializablePath_FillType? fillType, - }) { - final $result = create(); - if (actions != null) { - $result.actions.addAll(actions); - } - if (fillType != null) { - $result.fillType = fillType; - } - return $result; - } - SerializablePath._() : super(); - factory SerializablePath.fromBuffer($core.List<$core.int> i, - [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromBuffer(i, r); - factory SerializablePath.fromJson($core.String i, - [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => - create()..mergeFromJson(i, r); - - static final $pb.BuilderInfo _i = $pb.BuilderInfo( - _omitMessageNames ? '' : 'SerializablePath', - createEmptyInstance: create) - ..pc( - 1, _omitFieldNames ? '' : 'actions', $pb.PbFieldType.PM, - subBuilder: SerializablePath_Action.create) - ..e( - 2, _omitFieldNames ? '' : 'fillType', $pb.PbFieldType.OE, - defaultOrMaker: SerializablePath_FillType.NON_ZERO, - valueOf: SerializablePath_FillType.valueOf, - enumValues: SerializablePath_FillType.values) - ..hasRequiredFields = false; - - @$core.Deprecated('Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' - 'Will be removed in next major version') - SerializablePath clone() => SerializablePath()..mergeFromMessage(this); - @$core.Deprecated('Using this can add significant overhead to your binary. ' - 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' - 'Will be removed in next major version') - SerializablePath copyWith(void Function(SerializablePath) updates) => - super.copyWith((message) => updates(message as SerializablePath)) - as SerializablePath; - - $pb.BuilderInfo get info_ => _i; - - @$core.pragma('dart2js:noInline') - static SerializablePath create() => SerializablePath._(); - SerializablePath createEmptyInstance() => create(); - static $pb.PbList createRepeated() => - $pb.PbList(); - @$core.pragma('dart2js:noInline') - static SerializablePath getDefault() => _defaultInstance ??= - $pb.GeneratedMessage.$_defaultFor(create); - static SerializablePath? _defaultInstance; - - @$pb.TagNumber(1) - $core.List get actions => $_getList(0); - - @$pb.TagNumber(2) - SerializablePath_FillType get fillType => $_getN(1); - @$pb.TagNumber(2) - set fillType(SerializablePath_FillType v) { - setField(2, v); - } - - @$pb.TagNumber(2) - $core.bool hasFillType() => $_has(1); - @$pb.TagNumber(2) - void clearFillType() => clearField(2); -} - -const _omitFieldNames = $core.bool.fromEnvironment('protobuf.omit_field_names'); -const _omitMessageNames = - $core.bool.fromEnvironment('protobuf.omit_message_names'); diff --git a/packages/io_library/lib/src/serialization/proto/output/graphic/path.pbenum.dart b/packages/io_library/lib/src/serialization/proto/output/graphic/path.pbenum.dart deleted file mode 100644 index a942740d..00000000 --- a/packages/io_library/lib/src/serialization/proto/output/graphic/path.pbenum.dart +++ /dev/null @@ -1,35 +0,0 @@ -// -// Generated code. Do not modify. -// source: graphic/path.proto -// -// @dart = 2.12 - -// ignore_for_file: annotate_overrides, camel_case_types, comment_references -// ignore_for_file: constant_identifier_names, library_prefixes -// ignore_for_file: non_constant_identifier_names, prefer_final_fields -// ignore_for_file: unnecessary_import, unnecessary_this, unused_import - -import 'dart:core' as $core; - -import 'package:protobuf/protobuf.dart' as $pb; - -class SerializablePath_FillType extends $pb.ProtobufEnum { - static const SerializablePath_FillType NON_ZERO = - SerializablePath_FillType._(0, _omitEnumNames ? '' : 'NON_ZERO'); - static const SerializablePath_FillType EVEN_ODD = - SerializablePath_FillType._(1, _omitEnumNames ? '' : 'EVEN_ODD'); - - static const $core.List values = - [ - NON_ZERO, - EVEN_ODD, - ]; - - static final $core.Map<$core.int, SerializablePath_FillType> _byValue = - $pb.ProtobufEnum.initByValue(values); - static SerializablePath_FillType? valueOf($core.int value) => _byValue[value]; - - const SerializablePath_FillType._($core.int v, $core.String n) : super(v, n); -} - -const _omitEnumNames = $core.bool.fromEnvironment('protobuf.omit_enum_names'); diff --git a/packages/io_library/lib/src/serialization/proto/output/graphic/path.pbjson.dart b/packages/io_library/lib/src/serialization/proto/output/graphic/path.pbjson.dart deleted file mode 100644 index f209b2c4..00000000 --- a/packages/io_library/lib/src/serialization/proto/output/graphic/path.pbjson.dart +++ /dev/null @@ -1,125 +0,0 @@ -// -// Generated code. Do not modify. -// source: graphic/path.proto -// -// @dart = 2.12 - -// ignore_for_file: annotate_overrides, camel_case_types, comment_references -// ignore_for_file: constant_identifier_names, library_prefixes -// ignore_for_file: non_constant_identifier_names, prefer_final_fields -// ignore_for_file: unnecessary_import, unnecessary_this, unused_import - -import 'dart:convert' as $convert; -import 'dart:core' as $core; -import 'dart:typed_data' as $typed_data; - -@$core.Deprecated('Use serializablePathDescriptor instead') -const SerializablePath$json = { - '1': 'SerializablePath', - '2': [ - { - '1': 'actions', - '3': 1, - '4': 3, - '5': 11, - '6': '.SerializablePath.Action', - '10': 'actions' - }, - { - '1': 'fill_type', - '3': 2, - '4': 1, - '5': 14, - '6': '.SerializablePath.FillType', - '10': 'fillType' - }, - ], - '3': [SerializablePath_Action$json], - '4': [SerializablePath_FillType$json], -}; - -@$core.Deprecated('Use serializablePathDescriptor instead') -const SerializablePath_Action$json = { - '1': 'Action', - '2': [ - { - '1': 'move_to', - '3': 1, - '4': 1, - '5': 11, - '6': '.SerializablePath.Action.MoveTo', - '9': 0, - '10': 'moveTo' - }, - { - '1': 'line_to', - '3': 2, - '4': 1, - '5': 11, - '6': '.SerializablePath.Action.LineTo', - '9': 0, - '10': 'lineTo' - }, - { - '1': 'close', - '3': 3, - '4': 1, - '5': 11, - '6': '.SerializablePath.Action.Close', - '9': 0, - '10': 'close' - }, - ], - '3': [ - SerializablePath_Action_MoveTo$json, - SerializablePath_Action_LineTo$json, - SerializablePath_Action_Close$json - ], - '8': [ - {'1': 'action'}, - ], -}; - -@$core.Deprecated('Use serializablePathDescriptor instead') -const SerializablePath_Action_MoveTo$json = { - '1': 'MoveTo', - '2': [ - {'1': 'x', '3': 1, '4': 1, '5': 1, '10': 'x'}, - {'1': 'y', '3': 2, '4': 1, '5': 1, '10': 'y'}, - ], -}; - -@$core.Deprecated('Use serializablePathDescriptor instead') -const SerializablePath_Action_LineTo$json = { - '1': 'LineTo', - '2': [ - {'1': 'x', '3': 1, '4': 1, '5': 1, '10': 'x'}, - {'1': 'y', '3': 2, '4': 1, '5': 1, '10': 'y'}, - ], -}; - -@$core.Deprecated('Use serializablePathDescriptor instead') -const SerializablePath_Action_Close$json = { - '1': 'Close', -}; - -@$core.Deprecated('Use serializablePathDescriptor instead') -const SerializablePath_FillType$json = { - '1': 'FillType', - '2': [ - {'1': 'NON_ZERO', '2': 0}, - {'1': 'EVEN_ODD', '2': 1}, - ], -}; - -/// Descriptor for `SerializablePath`. Decode as a `google.protobuf.DescriptorProto`. -final $typed_data.Uint8List serializablePathDescriptor = $convert.base64Decode( - 'ChBTZXJpYWxpemFibGVQYXRoEjIKB2FjdGlvbnMYASADKAsyGC5TZXJpYWxpemFibGVQYXRoLk' - 'FjdGlvblIHYWN0aW9ucxI3CglmaWxsX3R5cGUYAiABKA4yGi5TZXJpYWxpemFibGVQYXRoLkZp' - 'bGxUeXBlUghmaWxsVHlwZRqXAgoGQWN0aW9uEjoKB21vdmVfdG8YASABKAsyHy5TZXJpYWxpem' - 'FibGVQYXRoLkFjdGlvbi5Nb3ZlVG9IAFIGbW92ZVRvEjoKB2xpbmVfdG8YAiABKAsyHy5TZXJp' - 'YWxpemFibGVQYXRoLkFjdGlvbi5MaW5lVG9IAFIGbGluZVRvEjYKBWNsb3NlGAMgASgLMh4uU2' - 'VyaWFsaXphYmxlUGF0aC5BY3Rpb24uQ2xvc2VIAFIFY2xvc2UaJAoGTW92ZVRvEgwKAXgYASAB' - 'KAFSAXgSDAoBeRgCIAEoAVIBeRokCgZMaW5lVG8SDAoBeBgBIAEoAVIBeBIMCgF5GAIgASgBUg' - 'F5GgcKBUNsb3NlQggKBmFjdGlvbiImCghGaWxsVHlwZRIMCghOT05fWkVSTxAAEgwKCEVWRU5f' - 'T0REEAE='); diff --git a/packages/io_library/lib/src/serialization/proto/output/graphic/path.pbserver.dart b/packages/io_library/lib/src/serialization/proto/output/graphic/path.pbserver.dart deleted file mode 100644 index a406ef5d..00000000 --- a/packages/io_library/lib/src/serialization/proto/output/graphic/path.pbserver.dart +++ /dev/null @@ -1,13 +0,0 @@ -// -// Generated code. Do not modify. -// source: graphic/path.proto -// -// @dart = 2.12 - -// ignore_for_file: annotate_overrides, camel_case_types, comment_references -// ignore_for_file: constant_identifier_names -// ignore_for_file: deprecated_member_use_from_same_package, library_prefixes -// ignore_for_file: non_constant_identifier_names, prefer_final_fields -// ignore_for_file: unnecessary_import, unnecessary_this, unused_import - -export 'path.pb.dart'; diff --git a/packages/io_library/lib/src/serialization/proto/protos.dart b/packages/io_library/lib/src/serialization/proto/protos.dart deleted file mode 100644 index a180b981..00000000 --- a/packages/io_library/lib/src/serialization/proto/protos.dart +++ /dev/null @@ -1,4 +0,0 @@ -export 'output/command/graphic/draw_path_command.pb.dart'; -export 'output/google/protobuf/any.pb.dart'; -export 'output/graphic/paint.pb.dart'; -export 'output/graphic/path.pb.dart'; diff --git a/packages/io_library/lib/src/serialization/proto/schema/catrobat_image.proto b/packages/io_library/lib/src/serialization/proto/schema/catrobat_image.proto deleted file mode 100644 index 5ac819af..00000000 --- a/packages/io_library/lib/src/serialization/proto/schema/catrobat_image.proto +++ /dev/null @@ -1,12 +0,0 @@ -syntax = "proto3"; - -import "google/protobuf/any.proto"; - -message SerializableCatrobatImage { - string magicValue = 1; - int32 version = 2; - uint32 width = 3; - uint32 height = 4; - repeated google.protobuf.Any commands = 5; - bytes backgroundImage = 6; -} \ No newline at end of file diff --git a/packages/io_library/lib/src/serialization/proto/schema/command/graphic/draw_path_command.proto b/packages/io_library/lib/src/serialization/proto/schema/command/graphic/draw_path_command.proto deleted file mode 100644 index 84b8781b..00000000 --- a/packages/io_library/lib/src/serialization/proto/schema/command/graphic/draw_path_command.proto +++ /dev/null @@ -1,9 +0,0 @@ -syntax = 'proto3'; - -import 'graphic/paint.proto'; -import 'graphic/path.proto'; - -message SerializableDrawPathCommand { - SerializablePaint paint = 1; - SerializablePath path = 2; -} \ No newline at end of file diff --git a/packages/io_library/lib/src/serialization/proto/schema/graphic/paint.proto b/packages/io_library/lib/src/serialization/proto/schema/graphic/paint.proto deleted file mode 100644 index d9a40ceb..00000000 --- a/packages/io_library/lib/src/serialization/proto/schema/graphic/paint.proto +++ /dev/null @@ -1,34 +0,0 @@ -syntax = 'proto3'; - -message SerializablePaint { - uint32 color = 1; - - float strokeWidth = 2; - - enum StrokeCap { - STROKE_CAP_ROUND = 0; - STROKE_CAP_BUTT = 1; - STROKE_CAP_SQUARE = 2; - } - StrokeCap cap = 3; - - enum PaintingStyle { - PAINTING_STYLE_FILL = 0; - PAINTING_STYLE_STROKE = 1; - } - PaintingStyle style = 4; - - enum BlendMode { - BLEND_MODE_SCR_OVER = 0; - BLEND_MODE_CLEAR = 1; - } - BlendMode blendMode = 5; - - enum StrokeJoin { - STROKE_JOIN_MITER = 0; - STROKE_JOIN_ROUND = 1; - STROKE_JOIN_BEVEL = 2; - } - StrokeJoin strokeJoin = 6; - -} \ No newline at end of file diff --git a/packages/io_library/lib/src/serialization/proto/schema/graphic/path.proto b/packages/io_library/lib/src/serialization/proto/schema/graphic/path.proto deleted file mode 100644 index 8fa45480..00000000 --- a/packages/io_library/lib/src/serialization/proto/schema/graphic/path.proto +++ /dev/null @@ -1,27 +0,0 @@ -syntax = "proto3"; - -message SerializablePath { - message Action { - message MoveTo { - double x = 1; - double y = 2; - } - message LineTo { - double x = 1; - double y = 2; - } - message Close {} - - oneof action { - MoveTo move_to = 1; - LineTo line_to = 2; - Close close = 3; - } - } - repeated Action actions = 1; - enum FillType { - NON_ZERO = 0; - EVEN_ODD = 1; - } - FillType fill_type = 2; -} \ No newline at end of file diff --git a/packages/io_library/lib/src/serialization/proto_serializer_with_versioning.dart b/packages/io_library/lib/src/serialization/proto_serializer_with_versioning.dart deleted file mode 100644 index 808b1026..00000000 --- a/packages/io_library/lib/src/serialization/proto_serializer_with_versioning.dart +++ /dev/null @@ -1,22 +0,0 @@ -import 'package:flutter/foundation.dart'; -import 'package:io_library/io_library.dart'; -import 'package:protobuf/protobuf.dart' show GeneratedMessage; - -abstract class ProtoSerializerWithVersioning - extends VersionSerializer { - const ProtoSerializerWithVersioning(super.version); - - static const urlPrefix = 'org.catrobat.paintroid'; - - @protected - SERIALIZABLE Function(Uint8List binary) get fromBytesToSerializable; - - @nonVirtual - Future fromBytes(Uint8List binary) => - deserialize(fromBytesToSerializable(binary)); - - @nonVirtual - Future toBytes(T object) async => - (await serializeWithLatestVersion(object)).writeToBuffer(); -} diff --git a/packages/io_library/lib/src/serialization/serializer/catrobat_image_serializer.dart b/packages/io_library/lib/src/serialization/serializer/catrobat_image_serializer.dart deleted file mode 100644 index a2aa999f..00000000 --- a/packages/io_library/lib/src/serialization/serializer/catrobat_image_serializer.dart +++ /dev/null @@ -1,78 +0,0 @@ -import 'dart:typed_data'; -import 'dart:ui'; - -import 'package:command/command.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart' show Provider; -import 'package:io_library/io_library.dart'; -import 'package:io_library/serialization.dart'; - -class CatrobatImageSerializer extends ProtoSerializerWithVersioning< - CatrobatImage, SerializableCatrobatImage> { - final DrawPathCommandSerializer _drawPathCommandSerializer; - final IImageService _imageService; - - const CatrobatImageSerializer( - super.version, this._imageService, this._drawPathCommandSerializer); - - static final provider = Provider.family( - (ref, int ver) => CatrobatImageSerializer( - ver, - ref.watch(IImageService.provider), - ref.watch(DrawPathCommandSerializer.provider(ver)), - ), - ); - - @override - Future serializeWithLatestVersion( - CatrobatImage object) async { - Uint8List? backgroundImageData; - if (object.backgroundImage != null) { - final result = await _imageService.exportAsPng(object.backgroundImage!); - backgroundImageData = - result.unwrapOrElse((failure) => throw failure.message); - } - return SerializableCatrobatImage() - ..magicValue = CatrobatImage.magicValue - ..version = CatrobatImage.latestVersion - ..width = object.width - ..height = object.height - ..backgroundImage = - (backgroundImageData != null) ? backgroundImageData : Uint8List(0) - ..commands.addAll(await Future.wait(object.commands.map((command) async { - if (command is DrawPathCommand) { - return Any.pack( - await _drawPathCommandSerializer - .serializeWithLatestVersion(command), - typeUrlPrefix: ProtoSerializerWithVersioning.urlPrefix, - ); - } else { - throw 'Invalid command type'; - } - }))); - } - - @override - Future deserializeWithLatestVersion( - SerializableCatrobatImage data) async { - final commands = []; - for (final cmd in data.commands) { - if (cmd.canUnpackInto(SerializableDrawPathCommand.getDefault())) { - final unpacked = cmd.unpackInto(SerializableDrawPathCommand()); - commands.add(await _drawPathCommandSerializer.deserialize(unpacked)); - } else { - throw 'Invalid command type'; - } - } - Image? image; - if (data.hasBackgroundImage()) { - final result = - await _imageService.import(Uint8List.fromList(data.backgroundImage)); - image = result.unwrapOrElse((failure) => throw failure.message); - } - return CatrobatImage(commands, data.width, data.height, image, - version: data.version); - } - - @override - final fromBytesToSerializable = SerializableCatrobatImage.fromBuffer; -} diff --git a/packages/io_library/lib/src/serialization/serializer/command/graphic/draw_path_command_serializer.dart b/packages/io_library/lib/src/serialization/serializer/command/graphic/draw_path_command_serializer.dart deleted file mode 100644 index 41f05511..00000000 --- a/packages/io_library/lib/src/serialization/serializer/command/graphic/draw_path_command_serializer.dart +++ /dev/null @@ -1,48 +0,0 @@ -import 'package:command/command.dart'; -import 'package:command/command_providers.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:io_library/io_library.dart'; - -class DrawPathCommandSerializer extends ProtoSerializerWithVersioning< - DrawPathCommand, SerializableDrawPathCommand> { - final PathSerializer _pathSerializer; - final PaintSerializer _paintSerializer; - final CommandFactory _commandFactory; - - const DrawPathCommandSerializer( - super.version, - this._pathSerializer, - this._paintSerializer, - this._commandFactory, - ); - - static final provider = Provider.family( - (ref, int ver) => DrawPathCommandSerializer( - ver, - ref.watch(PathSerializer.provider(ver)), - ref.watch(PaintSerializer.provider(ver)), - ref.watch(commandFactoryProvider)), - ); - - @override - final fromBytesToSerializable = SerializableDrawPathCommand.fromBuffer; - - @override - Future deserializeWithLatestVersion( - SerializableDrawPathCommand data) async { - final path = await _pathSerializer.deserialize(data.path); - final paint = await _paintSerializer.deserialize(data.paint); - return _commandFactory.createDrawPathCommand(path, paint); - } - - @override - Future serializeWithLatestVersion( - DrawPathCommand object) async { - final sPaint = - await _paintSerializer.serializeWithLatestVersion(object.paint); - final sPath = await _pathSerializer.serializeWithLatestVersion(object.path); - return SerializableDrawPathCommand() - ..paint = sPaint - ..path = sPath; - } -} diff --git a/packages/io_library/lib/src/serialization/serializer/graphic/paint_serializer.dart b/packages/io_library/lib/src/serialization/serializer/graphic/paint_serializer.dart deleted file mode 100644 index 96124bf9..00000000 --- a/packages/io_library/lib/src/serialization/serializer/graphic/paint_serializer.dart +++ /dev/null @@ -1,68 +0,0 @@ -import 'dart:ui'; - -import 'package:component_library/component_library.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:io_library/io_library.dart'; - -class PaintSerializer - extends ProtoSerializerWithVersioning { - final GraphicFactory _graphicFactory; - - static final _capMap = { - SerializablePaint_StrokeCap.STROKE_CAP_BUTT: StrokeCap.butt, - SerializablePaint_StrokeCap.STROKE_CAP_ROUND: StrokeCap.round, - SerializablePaint_StrokeCap.STROKE_CAP_SQUARE: StrokeCap.square, - }; - - static final _styleMap = { - SerializablePaint_PaintingStyle.PAINTING_STYLE_FILL: PaintingStyle.fill, - SerializablePaint_PaintingStyle.PAINTING_STYLE_STROKE: PaintingStyle.stroke, - }; - - static final _blendModeMap = { - SerializablePaint_BlendMode.BLEND_MODE_SCR_OVER: BlendMode.srcOver, - SerializablePaint_BlendMode.BLEND_MODE_CLEAR: BlendMode.clear, - }; - - static final _strokeJoinMap = { - SerializablePaint_StrokeJoin.STROKE_JOIN_MITER: StrokeJoin.miter, - SerializablePaint_StrokeJoin.STROKE_JOIN_ROUND: StrokeJoin.round, - SerializablePaint_StrokeJoin.STROKE_JOIN_BEVEL: StrokeJoin.bevel, - }; - - const PaintSerializer(super.version, this._graphicFactory); - - static final provider = Provider.family( - (ref, int ver) => PaintSerializer(ver, ref.watch(graphicFactoryProvider)), - ); - - @override - final fromBytesToSerializable = SerializablePaint.fromBuffer; - - @override - Future deserializeWithLatestVersion(SerializablePaint data) async { - return _graphicFactory.createPaint() - ..color = Color(data.color) - ..strokeWidth = data.strokeWidth - ..strokeCap = _capMap[data.cap] ?? StrokeCap.butt - ..style = _styleMap[data.style] ?? PaintingStyle.fill - ..blendMode = _blendModeMap[data.blendMode] ?? BlendMode.srcOver - ..strokeJoin = _strokeJoinMap[data.strokeJoin] ?? StrokeJoin.miter; - } - - @override - Future serializeWithLatestVersion(Paint object) async { - final serializable = SerializablePaint() - ..color = object.color.value - ..strokeWidth = object.strokeWidth - ..cap = _capMap.entries.firstWhere((e) => e.value == object.strokeCap).key - ..style = _styleMap.entries.firstWhere((e) => e.value == object.style).key - ..blendMode = _blendModeMap.entries - .firstWhere((e) => e.value == object.blendMode) - .key - ..strokeJoin = _strokeJoinMap.entries - .firstWhere((e) => e.value == object.strokeJoin) - .key; - return serializable; - } -} diff --git a/packages/io_library/lib/src/serialization/serializer/graphic/path_serializer.dart b/packages/io_library/lib/src/serialization/serializer/graphic/path_serializer.dart deleted file mode 100644 index 9c45db4a..00000000 --- a/packages/io_library/lib/src/serialization/serializer/graphic/path_serializer.dart +++ /dev/null @@ -1,81 +0,0 @@ -import 'dart:ui'; - -import 'package:component_library/component_library.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:io_library/io_library.dart'; - -class PathSerializer extends ProtoSerializerWithVersioning< - PathWithActionHistory, SerializablePath> with LoggableMixin { - final GraphicFactory _graphicFactory; - - PathSerializer(super.version, this._graphicFactory); - - static final provider = Provider.family( - (ref, int ver) => PathSerializer(ver, ref.watch(graphicFactoryProvider)), - ); - - @override - Future deserializeWithLatestVersion( - SerializablePath data) async { - final path = _graphicFactory.createPathWithActionHistory(); - switch (data.fillType) { - case SerializablePath_FillType.EVEN_ODD: - path.fillType = PathFillType.evenOdd; - break; - case SerializablePath_FillType.NON_ZERO: - path.fillType = PathFillType.nonZero; - break; - } - for (var i = 0; i < data.actions.length; i++) { - final action = data.actions[i]; - if (action.hasMoveTo()) { - path.moveTo(action.moveTo.x, action.moveTo.y); - } else if (action.hasLineTo()) { - path.lineTo(action.lineTo.x, action.lineTo.y); - } else if (action.hasClose()) { - path.close(); - } else { - logger.severe('No Path Action was set at index $i.'); - } - } - return path; - } - - @override - final fromBytesToSerializable = SerializablePath.fromBuffer; - - @override - Future serializeWithLatestVersion( - PathWithActionHistory object) async { - final serializablePath = SerializablePath(); - switch (object.fillType) { - case PathFillType.nonZero: - serializablePath.fillType = SerializablePath_FillType.NON_ZERO; - break; - case PathFillType.evenOdd: - serializablePath.fillType = SerializablePath_FillType.EVEN_ODD; - break; - } - for (final action in object.actions) { - late final SerializablePath_Action serializableAction; - if (action is MoveToAction) { - final moveTo = SerializablePath_Action_MoveTo() - ..x = action.x - ..y = action.y; - serializableAction = SerializablePath_Action()..moveTo = moveTo; - } else if (action is LineToAction) { - final lineTo = SerializablePath_Action_LineTo() - ..x = action.x - ..y = action.y; - serializableAction = SerializablePath_Action()..lineTo = lineTo; - } else if (action is CloseAction) { - final close = SerializablePath_Action_Close(); - serializableAction = SerializablePath_Action()..close = close; - } else { - logger.severe('Path Action serialization was not handled for $action'); - } - serializablePath.actions.add(serializableAction); - } - return serializablePath; - } -} diff --git a/packages/io_library/lib/src/serialization/version_serializer.dart b/packages/io_library/lib/src/serialization/version_serializer.dart deleted file mode 100644 index 5fd5b1f5..00000000 --- a/packages/io_library/lib/src/serialization/version_serializer.dart +++ /dev/null @@ -1,27 +0,0 @@ -import 'package:flutter/foundation.dart'; - -abstract class VersionSerializer { - final int version; - - static const v1 = 1; - - const VersionSerializer(this.version); - - Future serializeWithLatestVersion(FROM object); - - @nonVirtual - Future deserialize(TO data) { - switch (version) { - case v1: - return deserializeV1(data); - default: - throw 'Invalid version'; - } - } - - @protected - Future deserializeV1(TO data) => deserializeWithLatestVersion(data); - - @protected - Future deserializeWithLatestVersion(TO data); -} diff --git a/packages/io_library/lib/src/usecase/load_image_from_file_manager.dart b/packages/io_library/lib/src/usecase/load_image_from_file_manager.dart index 53a96d9f..e4dfd642 100644 --- a/packages/io_library/lib/src/usecase/load_image_from_file_manager.dart +++ b/packages/io_library/lib/src/usecase/load_image_from_file_manager.dart @@ -1,4 +1,7 @@ +import 'dart:convert'; import 'dart:io'; +import 'dart:typed_data'; +import 'dart:ui'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:io_library/io_library.dart'; @@ -16,19 +19,16 @@ class LoadImageFromFileManager with LoggableMixin { final IFileService fileService; final IImageService imageService; final IPermissionService permissionService; - final CatrobatImageSerializer catrobatImageSerializer; - LoadImageFromFileManager(this.fileService, this.imageService, - this.permissionService, this.catrobatImageSerializer); + LoadImageFromFileManager( + this.fileService, this.imageService, this.permissionService); static final provider = Provider((ref) { final imageService = ref.watch(IImageService.provider); final fileService = ref.watch(IFileService.provider); final permissionService = ref.watch(IPermissionService.provider); - const ver = CatrobatImage.latestVersion; - final serializer = ref.watch(CatrobatImageSerializer.provider(ver)); return LoadImageFromFileManager( - fileService, imageService, permissionService, serializer); + fileService, imageService, permissionService); }); Future> call( @@ -50,11 +50,13 @@ class LoadImageFromFileManager with LoggableMixin { .import(await file.readAsBytes()) .map((img) => ImageFromFile.rasterImage(img)); case 'catrobat-image': - final image = await catrobatImageSerializer - .fromBytes(await file.readAsBytes()); + Uint8List bytes = await file.readAsBytes(); + CatrobatImage catrobatImage = CatrobatImage.fromBytes(bytes); + Image? backgroundImage = + await rebuildBackgroundImage(catrobatImage); return Result.ok(ImageFromFile.catrobatImage( - image, - backgroundImage: image.backgroundImage, + catrobatImage, + backgroundImage: backgroundImage, )); default: return const Result.err(LoadImageFailure.invalidImage); @@ -68,4 +70,16 @@ class LoadImageFromFileManager with LoggableMixin { } }); } + + Future rebuildBackgroundImage(CatrobatImage catrobatImage) async { + Image? backgroundImage; + if (catrobatImage.backgroundImage.isNotEmpty) { + Uint8List? backgroundImageData = + base64Decode(catrobatImage.backgroundImage); + final result = + await imageService.import(Uint8List.fromList(backgroundImageData)); + backgroundImage = result.unwrapOrElse((failure) => throw failure.message); + } + return backgroundImage; + } } diff --git a/packages/io_library/lib/src/usecase/save_as_catrobat_image.dart b/packages/io_library/lib/src/usecase/save_as_catrobat_image.dart index ba7b9cc4..3eea44f8 100644 --- a/packages/io_library/lib/src/usecase/save_as_catrobat_image.dart +++ b/packages/io_library/lib/src/usecase/save_as_catrobat_image.dart @@ -1,4 +1,5 @@ import 'dart:io'; +import 'dart:typed_data'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:io_library/io_library.dart'; @@ -7,17 +8,13 @@ import 'package:oxidized/oxidized.dart'; class SaveAsCatrobatImage with LoggableMixin { final IFileService _fileService; final IPermissionService permissionService; - final CatrobatImageSerializer _catrobatImageSerializer; - SaveAsCatrobatImage( - this._fileService, this.permissionService, this._catrobatImageSerializer); + SaveAsCatrobatImage(this._fileService, this.permissionService); static final provider = Provider((ref) { final fileService = ref.watch(IFileService.provider); final permissionService = ref.watch(IPermissionService.provider); - const ver = CatrobatImage.latestVersion; - final serializer = ref.watch(CatrobatImageSerializer.provider(ver)); - return SaveAsCatrobatImage(fileService, permissionService, serializer); + return SaveAsCatrobatImage(fileService, permissionService); }); Future> call( @@ -27,7 +24,7 @@ class SaveAsCatrobatImage with LoggableMixin { } final nameWithExt = '${data.name}.${data.format.extension}'; try { - final bytes = await _catrobatImageSerializer.toBytes(image); + Uint8List bytes = image.toBytes(); if (isAProject) { return _fileService.saveToApplicationDirectory(nameWithExt, bytes); } diff --git a/packages/io_library/pubspec.yaml b/packages/io_library/pubspec.yaml index cda4d8dd..33e1fe2b 100644 --- a/packages/io_library/pubspec.yaml +++ b/packages/io_library/pubspec.yaml @@ -26,6 +26,7 @@ dependencies: filesize: ^2.0.1 oxidized: ^5.2.0 intl: ^0.18.0 + json_annotation: ^4.8.1 # Internal packages: component_library: @@ -37,6 +38,7 @@ dependencies: workspace_screen: path: ../features/workspace_screen + dev_dependencies: flutter_test: sdk: flutter @@ -49,6 +51,7 @@ dev_dependencies: riverpod_lint: ^1.3.2 build_runner: ^2.2.0 freezed: ^2.4.1 + json_serializable: ^6.7.1 flutter: uses-material-design: true diff --git a/packages/io_library/test/unit/serialization/command/draw_path_command_serializer_test.dart b/packages/io_library/test/unit/serialization/command/draw_path_command_serializer_test.dart new file mode 100644 index 00000000..5b1d63bc --- /dev/null +++ b/packages/io_library/test/unit/serialization/command/draw_path_command_serializer_test.dart @@ -0,0 +1,53 @@ +import 'package:command/command.dart'; +import 'package:component_library/component_library.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:io_library/io_library.dart'; + +import '../utils/test_command_factory.dart'; +import '../utils/test_paint_factory.dart'; +import '../utils/test_path_factory.dart'; + +void main() { + group('Version 1', () { + test('Test DrawPathCommand serialization with one path', () { + PathWithActionHistory originalPath = + TestPathFactory.createPathWithActionHistory(1); + Paint originalPaint = TestPaintFactory.createPaint(version: Version.v1); + DrawPathCommand command = TestCommandFactory.createDrawPathCommand( + originalPath, originalPaint, + version: Version.v1); + + var json = command.toJson(); + DrawPathCommand deserializedCommand = DrawPathCommand.fromJson(json); + + expect(command.version, equals(deserializedCommand.version)); + expect( + TestPaintFactory.comparePaint( + originalPaint, deserializedCommand.paint, + version: Version.v1), + isTrue); + expect(originalPath, equals(deserializedCommand.path)); + }); + + test('Test DrawPathCommand serialization with multiple paths', () { + PathWithActionHistory originalPath = + TestPathFactory.createPathWithActionHistory(5); + Paint originalPaint = TestPaintFactory.createPaint(version: Version.v1); + DrawPathCommand command = TestCommandFactory.createDrawPathCommand( + originalPath, originalPaint, + version: Version.v1); + + var json = command.toJson(); + DrawPathCommand deserializedCommand = DrawPathCommand.fromJson(json); + + expect(command.version, equals(deserializedCommand.version)); + expect( + TestPaintFactory.comparePaint( + originalPaint, deserializedCommand.paint, + version: Version.v1), + isTrue); + expect(originalPath, equals(deserializedCommand.path)); + }); + }); +} diff --git a/packages/io_library/test/unit/serialization/converter/paint_converter_test.dart b/packages/io_library/test/unit/serialization/converter/paint_converter_test.dart new file mode 100644 index 00000000..a4083376 --- /dev/null +++ b/packages/io_library/test/unit/serialization/converter/paint_converter_test.dart @@ -0,0 +1,81 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:io_library/io_library.dart'; + +import '../utils/test_paint_factory.dart'; + +void main() { + PaintConverter converter = const PaintConverter(); + + group('Version 1', () { + test('Basic Paint', () { + Paint originalPaint = Paint() + ..color = Colors.blue + ..strokeWidth = 5.0 + ..strokeCap = StrokeCap.round + ..isAntiAlias = true + ..style = PaintingStyle.fill + ..strokeJoin = StrokeJoin.bevel + ..blendMode = BlendMode.clear; + + var json = converter.toJson(originalPaint); + + Paint deserializedPaint = converter.fromJson(json); + + expect( + TestPaintFactory.comparePaint(deserializedPaint, originalPaint, + version: Version.v1), + isTrue); + }); + + test('Basic Paint', () { + Paint originalPaint = Paint() + ..color = Colors.yellow + ..strokeWidth = 2.5 + ..strokeCap = StrokeCap.butt + ..isAntiAlias = true + ..style = PaintingStyle.stroke + ..strokeJoin = StrokeJoin.miter + ..blendMode = BlendMode.srcOver; + + var json = converter.toJson(originalPaint); + + Paint deserializedPaint = converter.fromJson(json); + + expect( + TestPaintFactory.comparePaint(deserializedPaint, originalPaint, + version: Version.v1), + isTrue); + }); + + test('Basic Paint', () { + Paint originalPaint = Paint() + ..color = Colors.green + ..strokeWidth = 3.0 + ..strokeCap = StrokeCap.square + ..isAntiAlias = false + ..style = PaintingStyle.stroke + ..strokeJoin = StrokeJoin.round + ..blendMode = BlendMode.srcIn; + + var json = converter.toJson(originalPaint); + + Paint deserializedPaint = converter.fromJson(json); + + expect( + TestPaintFactory.comparePaint(deserializedPaint, originalPaint, + version: Version.v1), + isTrue); + }); + + test('Custom Color', () { + Paint originalPaint = Paint()..color = Colors.red; + + var json = converter.toJson(originalPaint); + + Paint deserializedPaint = converter.fromJson(json); + + expect(deserializedPaint.color, equals(originalPaint.color)); + }); + }); +} diff --git a/packages/io_library/test/unit/serialization/converter/path_action_converter_test.dart b/packages/io_library/test/unit/serialization/converter/path_action_converter_test.dart new file mode 100644 index 00000000..c3cfa314 --- /dev/null +++ b/packages/io_library/test/unit/serialization/converter/path_action_converter_test.dart @@ -0,0 +1,47 @@ +import 'package:component_library/component_library.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:io_library/io_library.dart'; + +void main() { + const PathActionConverter converter = PathActionConverter(); + + test('Test converter for MoveToAction', () { + double xExpected = 1.0; + double yExpected = 2.0; + + MoveToAction moveToAction = MoveToAction(xExpected, yExpected); + + var json = converter.toJson(moveToAction); + + PathAction deserializedMoveToAction = converter.fromJson(json); + + expect(deserializedMoveToAction, isA()); + deserializedMoveToAction as MoveToAction; + expect(moveToAction, equals(deserializedMoveToAction)); + }); + + test('Test converter for LineToAction', () { + double xExpected = 1.0; + double yExpected = 2.0; + + LineToAction lineToAction = LineToAction(xExpected, yExpected); + + var json = converter.toJson(lineToAction); + + PathAction deserializedLineToAction = converter.fromJson(json); + + expect(deserializedLineToAction, isA()); + deserializedLineToAction as LineToAction; + expect(lineToAction, equals(deserializedLineToAction)); + }); + + test('Test converter for CloseAction', () { + CloseAction closeAction = const CloseAction(); + + var json = converter.toJson(closeAction); + + PathAction deserializedCloseAction = converter.fromJson(json); + + expect(deserializedCloseAction, isA()); + }); +} diff --git a/packages/io_library/test/unit/serialization/converter/path_with_action_history_converter_test.dart b/packages/io_library/test/unit/serialization/converter/path_with_action_history_converter_test.dart new file mode 100644 index 00000000..36193552 --- /dev/null +++ b/packages/io_library/test/unit/serialization/converter/path_with_action_history_converter_test.dart @@ -0,0 +1,41 @@ +import 'package:component_library/component_library.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:io_library/io_library.dart'; + +import '../utils/test_path_factory.dart'; + +void main() { + const PathWithActionHistoryConverter converter = + PathWithActionHistoryConverter(); + + test('Test converter for PathWithActionHistory with one path', () { + PathWithActionHistory path = TestPathFactory.createPathWithActionHistory(1); + + var json = converter.toJson(path); + + PathWithActionHistory deserializedPath = converter.fromJson(json); + + expect(path, equals(deserializedPath)); + }); + + test('Test converter for PathWithActionHistory with two paths', () { + PathWithActionHistory path = TestPathFactory.createPathWithActionHistory(2); + + var json = converter.toJson(path); + + PathWithActionHistory deserializedPath = converter.fromJson(json); + + expect(path, equals(deserializedPath)); + }); + + test('Test converter for PathWithActionHistory with multiple paths', () { + PathWithActionHistory path = + TestPathFactory.createPathWithActionHistory(10); + + var json = converter.toJson(path); + + PathWithActionHistory deserializedPath = converter.fromJson(json); + + expect(path, equals(deserializedPath)); + }); +} diff --git a/packages/io_library/test/unit/serialization/image/catrobat_image_serializer_test.dart b/packages/io_library/test/unit/serialization/image/catrobat_image_serializer_test.dart new file mode 100644 index 00000000..0b3dd113 --- /dev/null +++ b/packages/io_library/test/unit/serialization/image/catrobat_image_serializer_test.dart @@ -0,0 +1,55 @@ +import 'dart:typed_data'; + +import 'package:command/command.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:io_library/io_library.dart'; + +import '../utils/test_command_factory.dart'; +import '../utils/test_version_strategy.dart'; + +void main() { + group('Version 1', () { + test('Test CatrobatImage serialization with 1 path', () { + Iterable commands = + TestCommandFactory.createCommandList(1, version: Version.v1); + VersionStrategyManager.setStrategy( + TestVersionStrategy(catrobatImageVersion: Version.v1)); + CatrobatImage originalImage = CatrobatImage(commands, 100, 200, ''); + + Uint8List bytes = originalImage.toBytes(); + CatrobatImage deserializedImage = CatrobatImage.fromBytes(bytes); + + expect( + TestCommandFactory.compareCommandLists( + commands, deserializedImage.commands), + isTrue); + expect(originalImage.width, equals(deserializedImage.width)); + expect(originalImage.height, equals(deserializedImage.height)); + expect(originalImage.backgroundImage, + equals(deserializedImage.backgroundImage)); + expect(Version.v1, equals(deserializedImage.version)); + expect(originalImage.magicValue, equals(deserializedImage.magicValue)); + }); + + test('Test CatrobatImage serialization with multiple paths', () { + Iterable commands = TestCommandFactory.createCommandList(5); + VersionStrategyManager.setStrategy( + TestVersionStrategy(catrobatImageVersion: Version.v1)); + CatrobatImage originalImage = CatrobatImage(commands, 100, 200, ''); + + Uint8List bytes = originalImage.toBytes(); + CatrobatImage deserializedImage = CatrobatImage.fromBytes(bytes); + + expect( + TestCommandFactory.compareCommandLists( + commands, deserializedImage.commands), + isTrue); + expect(originalImage.width, equals(deserializedImage.width)); + expect(originalImage.height, equals(deserializedImage.height)); + expect(originalImage.backgroundImage, + equals(deserializedImage.backgroundImage)); + expect(Version.v1, equals(deserializedImage.version)); + expect(originalImage.magicValue, equals(deserializedImage.magicValue)); + }); + }); +} diff --git a/packages/io_library/test/unit/serialization/paint_serializer_test.dart b/packages/io_library/test/unit/serialization/paint_serializer_test.dart deleted file mode 100644 index 40015ca9..00000000 --- a/packages/io_library/test/unit/serialization/paint_serializer_test.dart +++ /dev/null @@ -1,53 +0,0 @@ -import 'package:component_library/component_library.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:io_library/io_library.dart'; - -void main() { - final mockGraphicFactory = MockGraphicFactory(); - final paintSerializer = PaintSerializer(1, mockGraphicFactory); - - group('PaintSerializer', () { - test( - 'serialize and deserialize with a Paint object having all default values', - () async { - final paint = Paint(); - - final serialized = - await paintSerializer.serializeWithLatestVersion(paint); - final deserialized = - await paintSerializer.deserializeWithLatestVersion(serialized); - - expect(deserialized.color, Colors.black); - expect(deserialized.strokeWidth, 0.0); - expect(deserialized.blendMode, BlendMode.srcOver); - expect(deserialized.strokeCap, StrokeCap.butt); - expect(deserialized.strokeJoin, StrokeJoin.miter); - expect(deserialized.style, PaintingStyle.fill); - }); - - test('serialize and deserialize with different values', () async { - final paint = Paint() - ..blendMode = BlendMode.srcOver - ..color = Colors.red - ..strokeCap = StrokeCap.round - ..strokeJoin = StrokeJoin.round - ..strokeWidth = 25.0 - ..style = PaintingStyle.stroke; - - final serialized = - await paintSerializer.serializeWithLatestVersion(paint); - final deserialized = - await paintSerializer.deserializeWithLatestVersion(serialized); - - expect(deserialized.blendMode, paint.blendMode); - expect(deserialized.color, paint.color); - expect(deserialized.strokeCap, paint.strokeCap); - expect(deserialized.strokeJoin, paint.strokeJoin); - expect(deserialized.strokeWidth, paint.strokeWidth); - expect(deserialized.style, paint.style); - }); - }); -} - -class MockGraphicFactory extends GraphicFactory {} diff --git a/packages/io_library/test/unit/serialization/utils/test_command_factory.dart b/packages/io_library/test/unit/serialization/utils/test_command_factory.dart new file mode 100644 index 00000000..353785a1 --- /dev/null +++ b/packages/io_library/test/unit/serialization/utils/test_command_factory.dart @@ -0,0 +1,61 @@ +import 'dart:ui'; + +import 'package:command/command.dart'; +import 'package:component_library/component_library.dart'; +import 'package:io_library/io_library.dart'; + +import 'test_paint_factory.dart'; +import 'test_path_factory.dart'; +import 'test_version_strategy.dart'; + +class TestCommandFactory { + static Iterable createCommandList(int numberOfCommands, + {int version = Version.v1}) { + CommandFactory commandFactory = const CommandFactory(); + VersionStrategyManager.setStrategy( + TestVersionStrategy(drawPathCommandVersion: version)); + List commands = []; + for (int i = 0; i < numberOfCommands; i++) { + PathWithActionHistory originalPath = + TestPathFactory.createPathWithActionHistory(i * numberOfCommands); + Paint originalPaint = TestPaintFactory.createPaint(); + DrawPathCommand command = + commandFactory.createDrawPathCommand(originalPath, originalPaint); + commands.add(command); + } + return commands; + } + + static DrawPathCommand createDrawPathCommand( + PathWithActionHistory path, Paint paint, + {int version = Version.v1}) { + CommandFactory commandFactory = const CommandFactory(); + VersionStrategyManager.setStrategy( + TestVersionStrategy(drawPathCommandVersion: version)); + return commandFactory.createDrawPathCommand(path, paint); + } + + static bool compareCommandLists( + Iterable commands1, Iterable commands2) { + if (commands1.length != commands2.length) { + return false; + } + var iterator1 = commands1.iterator; + var iterator2 = commands2.iterator; + + while (iterator1.moveNext() && iterator2.moveNext()) { + if (!areCommandsEqual(iterator1.current, iterator2.current)) { + return false; + } + } + return true; + } + + static bool areCommandsEqual(Command command1, Command command2) { + if (command1 is DrawPathCommand && command2 is DrawPathCommand) { + return command1.path == command2.path && + TestPaintFactory.comparePaint(command1.paint, command2.paint); + } + return false; + } +} diff --git a/packages/io_library/test/unit/serialization/utils/test_paint_factory.dart b/packages/io_library/test/unit/serialization/utils/test_paint_factory.dart new file mode 100644 index 00000000..59c5fbe5 --- /dev/null +++ b/packages/io_library/test/unit/serialization/utils/test_paint_factory.dart @@ -0,0 +1,39 @@ +import 'package:flutter/material.dart'; +import 'package:io_library/io_library.dart'; + +class TestPaintFactory { + static Paint createPaint({int version = Version.v1}) { + Paint paint = Paint(); + if (version >= Version.v1) { + paint.color = Colors.blue; + paint.strokeWidth = 5.0; + paint.strokeCap = StrokeCap.round; + paint.isAntiAlias = true; + paint.style = PaintingStyle.fill; + paint.strokeJoin = StrokeJoin.bevel; + paint.blendMode = BlendMode.clear; + } + if (version >= Version.v2) { + // paint.newAttribute = newAttribute; + } + return paint; + } + + static bool comparePaint(Paint paint1, Paint paint2, + {int version = Version.v1}) { + bool result = true; + if (version >= Version.v1) { + result = paint1.color == paint2.color && + paint1.strokeWidth == paint2.strokeWidth && + paint1.strokeCap == paint2.strokeCap && + paint1.isAntiAlias == paint2.isAntiAlias && + paint1.style == paint2.style && + paint1.strokeJoin == paint2.strokeJoin && + paint1.blendMode == paint2.blendMode; + } + if (version >= Version.v2) { + // result = result && paint1.newAttribute == paint2.newAttribute; + } + return result; + } +} diff --git a/packages/io_library/test/unit/serialization/utils/test_path_factory.dart b/packages/io_library/test/unit/serialization/utils/test_path_factory.dart new file mode 100644 index 00000000..b2d67e60 --- /dev/null +++ b/packages/io_library/test/unit/serialization/utils/test_path_factory.dart @@ -0,0 +1,14 @@ +import 'package:component_library/component_library.dart'; + +class TestPathFactory { + static PathWithActionHistory createPathWithActionHistory( + int numberOfActions) { + PathWithActionHistory pathWithActionHistory = PathWithActionHistory(); + for (int i = 0; i < numberOfActions; i++) { + pathWithActionHistory.moveTo(i.toDouble(), i.toDouble() + 1); + pathWithActionHistory.lineTo(i.toDouble() + 2, i.toDouble() + 3); + } + pathWithActionHistory.close(); + return pathWithActionHistory; + } +} diff --git a/packages/io_library/test/unit/serialization/utils/test_version_strategy.dart b/packages/io_library/test/unit/serialization/utils/test_version_strategy.dart new file mode 100644 index 00000000..9c593332 --- /dev/null +++ b/packages/io_library/test/unit/serialization/utils/test_version_strategy.dart @@ -0,0 +1,17 @@ +import 'package:io_library/io_library.dart'; + +class TestVersionStrategy implements IVersionStrategy { + final int drawPathCommandVersion; + final int catrobatImageVersion; + + TestVersionStrategy( + {this.drawPathCommandVersion = + SerializerVersion.DRAW_PATH_COMMAND_VERSION, + this.catrobatImageVersion = SerializerVersion.CATROBAT_IMAGE_VERSION}); + + @override + int getCatrobatImageVersion() => catrobatImageVersion; + + @override + int getDrawPathCommandVersion() => drawPathCommandVersion; +} diff --git a/packages/tools/test/unit/brush_tool_test.mocks.dart b/packages/tools/test/unit/brush_tool_test.mocks.dart index 25e8e73a..55f6caab 100644 --- a/packages/tools/test/unit/brush_tool_test.mocks.dart +++ b/packages/tools/test/unit/brush_tool_test.mocks.dart @@ -185,6 +185,15 @@ class MockPathWithActionHistory extends _i1.Mock returnValueForMissingStub: null, ); + @override + Map toJson() => (super.noSuchMethod( + Invocation.method( + #toJson, + [], + ), + returnValue: {}, + ) as Map); + @override void relativeMoveTo( double? dx, @@ -857,6 +866,18 @@ class MockDrawPathCommand extends _i1.Mock implements _i4.DrawPathCommand { _i1.throwOnMissingStub(this); } + @override + String get type => (super.noSuchMethod( + Invocation.getter(#type), + returnValue: '', + ) as String); + + @override + int get version => (super.noSuchMethod( + Invocation.getter(#version), + returnValue: 0, + ) as int); + @override _i3.PathWithActionHistory get path => (super.noSuchMethod( Invocation.getter(#path), @@ -889,6 +910,15 @@ class MockDrawPathCommand extends _i1.Mock implements _i4.DrawPathCommand { ), returnValueForMissingStub: null, ); + + @override + Map toJson() => (super.noSuchMethod( + Invocation.method( + #toJson, + [], + ), + returnValue: {}, + ) as Map); } /// A class which mocks [CommandManager].