From 7c3c717f77d943e44a336b42be3a22fb8c88f959 Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Tue, 28 Dec 2021 17:08:10 -0700 Subject: [PATCH 01/23] Instance generator puts overrides where need it --- .../symbols/pb_instancesym_gen.dart | 52 ++++++++++++------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/lib/generation/generators/symbols/pb_instancesym_gen.dart b/lib/generation/generators/symbols/pb_instancesym_gen.dart index 87cef644..b693fe75 100644 --- a/lib/generation/generators/symbols/pb_instancesym_gen.dart +++ b/lib/generation/generators/symbols/pb_instancesym_gen.dart @@ -7,6 +7,7 @@ import 'package:parabeac_core/interpret_and_optimize/entities/subclasses/pb_inte import 'package:parabeac_core/interpret_and_optimize/helpers/override_helper.dart'; import 'package:parabeac_core/interpret_and_optimize/helpers/pb_context.dart'; import 'package:parabeac_core/interpret_and_optimize/helpers/pb_symbol_storage.dart'; +import 'package:parabeac_core/tags/custom_tag/custom_tag.dart'; import 'package:quick_log/quick_log.dart'; import 'package:recase/recase.dart'; @@ -40,6 +41,14 @@ class PBSymbolInstanceGenerator extends PBGenerator { buffer.write('}\n'); // end of LayoutBuilder() buffer.write(')'); + // To write the override properties for the class + if (source.parent is CustomTag) { + buffer.write(',' + + overridesToString( + source.sharedParamValues, + generatorContext, + )); + } return buffer.toString(); } return ''; @@ -102,22 +111,8 @@ class PBSymbolInstanceGenerator extends PBGenerator { return override == null || override.value == null; }); - _formatNameAndValues(overrideValues, context); - for (var element in overrideValues) { - if (element.overrideName != null && element.initialValue != null) { - // If the type is image, we should print the whole widget - // so the end user can place whatever kind of widget - // TODO: Refactor so it place the image from the instance not from component - if (element.type == 'image') { - var elementCode = - element.value.generator.generate(element.value, context); - - buffer.write('${element.overrideName}: $elementCode,'); - } else { - buffer.write('${element.overrideName}: ${element.valueName},'); - } - } - } + formatNameAndValues(overrideValues, context); + buffer.write(overridesToString(overrideValues, context)); } buffer.write(')\n'); @@ -125,9 +120,30 @@ class PBSymbolInstanceGenerator extends PBGenerator { return buffer.toString(); } + // Traverse all overridable properties to write them for class use + String overridesToString( + List overrideValues, PBContext context) { + var buffer = StringBuffer(); + for (var element in overrideValues) { + if (element.overrideName != null && element.initialValue != null) { + // If the type is image, we should print the whole widget + // so the end user can place whatever kind of widget + // TODO: Refactor so it place the image from the instance not from component + if (element.type == 'image') { + var elementCode = + element.value.generator.generate(element.value, context); + + buffer.write('${element.overrideName}: $elementCode,'); + } else { + buffer.write('${element.overrideName}: ${element.valueName},'); + } + } + } + return buffer.toString(); + } + /// Traverses `params` and attempts to find the override `name` and `value` for each parameter. - void _formatNameAndValues( - List params, PBContext context) { + void formatNameAndValues(List params, PBContext context) { params.forEach((param) { var overrideProp = OverrideHelper.getProperty(param.UUID, param.type); From f0ea7766a8993a25081c3de7a7794f572838abc1 Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Tue, 28 Dec 2021 17:08:25 -0700 Subject: [PATCH 02/23] Added overridable properties to custom pages --- lib/tags/custom_tag/custom_tag.dart | 54 +++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/lib/tags/custom_tag/custom_tag.dart b/lib/tags/custom_tag/custom_tag.dart index e0b03fa6..77c24d0c 100644 --- a/lib/tags/custom_tag/custom_tag.dart +++ b/lib/tags/custom_tag/custom_tag.dart @@ -3,6 +3,7 @@ import 'package:parabeac_core/controllers/main_info.dart'; import 'package:parabeac_core/generation/generators/import_generator.dart'; import 'package:parabeac_core/generation/generators/pb_generator.dart'; import 'package:parabeac_core/generation/generators/plugins/pb_plugin_node.dart'; +import 'package:parabeac_core/generation/generators/symbols/pb_instancesym_gen.dart'; import 'package:parabeac_core/generation/generators/util/pb_input_formatter.dart'; import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/commands/write_symbol_command.dart'; import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/file_ownership_policy.dart'; @@ -12,6 +13,7 @@ import 'package:parabeac_core/interpret_and_optimize/entities/pb_shared_instance import 'package:parabeac_core/interpret_and_optimize/entities/pb_shared_master_node.dart'; import 'package:parabeac_core/interpret_and_optimize/entities/subclasses/pb_layout_intermediate_node.dart'; import 'package:parabeac_core/interpret_and_optimize/helpers/child_strategy.dart'; +import 'package:parabeac_core/interpret_and_optimize/helpers/override_helper.dart'; import 'package:parabeac_core/interpret_and_optimize/helpers/pb_context.dart'; import 'package:parabeac_core/interpret_and_optimize/entities/subclasses/pb_intermediate_node.dart'; import 'package:parabeac_core/interpret_and_optimize/helpers/pb_intermediate_node_tree.dart'; @@ -129,10 +131,14 @@ class CustomTagGenerator extends PBGenerator { )); context.configuration.generationConfiguration.fileStructureStrategy .commandCreated(WriteSymbolCommand( - Uuid().v4(), cleanName, customBoilerPlate(titleName), - relativePath: '$DIRECTORY_GEN', - symbolPath: 'lib', - ownership: FileOwnership.DEV)); + Uuid().v4(), + cleanName, + customBoilerPlate( + titleName, context.tree.childrenOf(source).first, context), + relativePath: '$DIRECTORY_GEN', + symbolPath: 'lib', + ownership: FileOwnership.DEV, + )); if (source is CustomTag) { return ''' @@ -144,13 +150,35 @@ class CustomTagGenerator extends PBGenerator { return ''; } - String customBoilerPlate(String className) { + String customBoilerPlate( + String className, PBIntermediateNode child, PBContext context) { + var variableList = []; + if (child is PBSharedInstanceIntermediateNode) { + if (child.sharedParamValues != null) { + child.sharedParamValues.removeWhere((value) { + var override = OverrideHelper.getProperty(value.UUID, value.type); + return override == null || override.value == null; + }); + + PBSymbolInstanceGenerator() + .formatNameAndValues(child.sharedParamValues, context); + for (var element in child.sharedParamValues) { + if (element.overrideName != null && element.initialValue != null) { + // print(element.overrideName); + // print(element.initialValue); + + variableList.add(element.overrideName); + } + } + } + } return ''' import 'package:flutter/material.dart'; class $className extends StatefulWidget{ final Widget? child; - $className({Key? key, this.child}) : super (key: key); + ${_printVariables(variableList)} + $className({Key? key, this.child, ${_printVariables(variableList, true)}}) : super (key: key); @override _${className}State createState() => _${className}State(); @@ -164,4 +192,18 @@ class CustomTagGenerator extends PBGenerator { } '''; } + + String _printVariables(List variables, + [bool forConstructor = false]) { + var buffer = StringBuffer(); + for (var variable in variables) { + var preVariable = forConstructor ? 'this.' : 'final '; + + var postVariable = forConstructor ? ', ' : ';'; + + buffer.write(preVariable + variable + postVariable); + } + + return buffer.toString(); + } } From b9b05475c288488b1a6977f91f23b45b2cd093bb Mon Sep 17 00:00:00 2001 From: Ivan <42812006+ivan-015@users.noreply.github.com> Date: Wed, 29 Dec 2021 17:49:57 -0700 Subject: [PATCH 03/23] Update PBDL --- pbdl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pbdl b/pbdl index 1eb6a163..c72b301e 160000 --- a/pbdl +++ b/pbdl @@ -1 +1 @@ -Subproject commit 1eb6a16374162cb26f6f6603a4dc107a92ce3ead +Subproject commit c72b301e0ee64aca60dc314fa55cea9b8aa07d4d From 8d7bf01cc12ebb1866cefe04dc5519b6763dcb93 Mon Sep 17 00:00:00 2001 From: Ivan <42812006+ivan-015@users.noreply.github.com> Date: Wed, 29 Dec 2021 18:55:57 -0700 Subject: [PATCH 04/23] Update PBDL --- pbdl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pbdl b/pbdl index c72b301e..28340820 160000 --- a/pbdl +++ b/pbdl @@ -1 +1 @@ -Subproject commit c72b301e0ee64aca60dc314fa55cea9b8aa07d4d +Subproject commit 28340820460510e3c1b03b3b7e5687d6005071ed From f5f7125247766f693e72425699e3c13d99c8f768 Mon Sep 17 00:00:00 2001 From: Ivan <42812006+ivan-015@users.noreply.github.com> Date: Wed, 29 Dec 2021 20:42:27 -0700 Subject: [PATCH 05/23] Fix relative sizing for components --- lib/generation/generators/attribute-helper/pb_size_helper.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/generation/generators/attribute-helper/pb_size_helper.dart b/lib/generation/generators/attribute-helper/pb_size_helper.dart index 98e5d33a..932ee7d6 100644 --- a/lib/generation/generators/attribute-helper/pb_size_helper.dart +++ b/lib/generation/generators/attribute-helper/pb_size_helper.dart @@ -51,6 +51,9 @@ class PBSizeHelper extends PBAttributesHelper { widthString = 'width: $width,'; } else if (context.sizingContext == SizingValueContext.LayoutBuilderValue) { + relativeWidth = relativeWidth / screenWidth; + relativeHeight = relativeHeight / screenHeight; + // Size for LayoutBuilder widthString = 'width: constraints.maxWidth * ${relativeWidth.toStringAsFixed(3)},'; From cd2d83debbee58160e67dacb6c4d10f18ea4fc8c Mon Sep 17 00:00:00 2001 From: Ivan <42812006+ivan-015@users.noreply.github.com> Date: Thu, 30 Dec 2021 19:29:18 -0700 Subject: [PATCH 06/23] Update PBDL --- pbdl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pbdl b/pbdl index 28340820..923fa036 160000 --- a/pbdl +++ b/pbdl @@ -1 +1 @@ -Subproject commit 28340820460510e3c1b03b3b7e5687d6005071ed +Subproject commit 923fa0363f6b76c8bc7cf58b4ae3f2e5f757144e From 1321b6ab210d997f3ed35d393a62ca7e6edfd450 Mon Sep 17 00:00:00 2001 From: Ivan <42812006+ivan-015@users.noreply.github.com> Date: Wed, 5 Jan 2022 17:52:34 -0700 Subject: [PATCH 07/23] Update PBDL --- pbdl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pbdl b/pbdl index 28340820..250addf9 160000 --- a/pbdl +++ b/pbdl @@ -1 +1 @@ -Subproject commit 28340820460510e3c1b03b3b7e5687d6005071ed +Subproject commit 250addf9195f378176c5e653a7bd1572385163bb From 7c5fa21b3a2fbae1172c90fb2f4714cd87c319e2 Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Wed, 5 Jan 2022 18:47:24 -0700 Subject: [PATCH 08/23] Copy constraints when injecting a container --- .../entities/layouts/group/frame_group.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/interpret_and_optimize/entities/layouts/group/frame_group.dart b/lib/interpret_and_optimize/entities/layouts/group/frame_group.dart index 0d0a0dbf..83ac0bc0 100644 --- a/lib/interpret_and_optimize/entities/layouts/group/frame_group.dart +++ b/lib/interpret_and_optimize/entities/layouts/group/frame_group.dart @@ -39,7 +39,8 @@ class FrameGroup extends Group PBIntermediateNode parent, PBIntermediateTree tree) { var tempFrame = _$FrameGroupFromJson(json); - var tempChild = injectAContainer(json, tempFrame.frame); + var tempChild = injectAContainer(json, tempFrame.frame) + ..constraints = tempFrame.constraints.copyWith(); if (tempChild != null) { tree.addEdges(tempFrame, [tempChild]); From 19d5b818a80f565228d48680668901576c1449ae Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Wed, 5 Jan 2022 18:47:36 -0700 Subject: [PATCH 09/23] Use layout temp --- .../services/pb_layout_generation_service.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/interpret_and_optimize/services/pb_layout_generation_service.dart b/lib/interpret_and_optimize/services/pb_layout_generation_service.dart index 14999da7..62da18a2 100644 --- a/lib/interpret_and_optimize/services/pb_layout_generation_service.dart +++ b/lib/interpret_and_optimize/services/pb_layout_generation_service.dart @@ -110,7 +110,7 @@ class PBLayoutGenerationService extends AITHandler { top: tempLayout.layoutProperties.topPadding, bottom: tempLayout.layoutProperties.bottomPadding, ), - constraints: tempGroup.constraints.copyWith(), + constraints: tempLayout.constraints.copyWith(), // Let the Container know if it is going to show // the width or height on the generation process showHeight: tempLayout.layoutProperties.primaryAxisAlignment == @@ -118,12 +118,12 @@ class PBLayoutGenerationService extends AITHandler { showWidth: tempLayout.layoutProperties.crossAxisSizing == IntermediateAxisMode.FIXED, ) - ..layoutCrossAxisSizing = tempGroup.layoutCrossAxisSizing - ..layoutMainAxisSizing = tempGroup.layoutMainAxisSizing; + ..layoutCrossAxisSizing = tempLayout.layoutCrossAxisSizing + ..layoutMainAxisSizing = tempLayout.layoutMainAxisSizing; // Let the tree know that the layout will be // wrapped by the Container - tree.wrapNode(wrapper, tempGroup); + tree.wrapNode(wrapper, tempLayout); } } }); From c4865f23b5fd787d1d22c6be43c95e8d8e73304d Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Fri, 7 Jan 2022 13:01:21 -0700 Subject: [PATCH 10/23] Copy constraints correctly --- .../layouts/auto_layout_align_strategy.dart | 1 + .../rules/container_constraint_rule.dart | 19 +++++++++++-------- .../helpers/align_strategy.dart | 8 ++++++-- lib/tags/injected_tab_bar.dart | 1 + 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/lib/interpret_and_optimize/entities/layouts/auto_layout_align_strategy.dart b/lib/interpret_and_optimize/entities/layouts/auto_layout_align_strategy.dart index 45e915b8..6328e903 100644 --- a/lib/interpret_and_optimize/entities/layouts/auto_layout_align_strategy.dart +++ b/lib/interpret_and_optimize/entities/layouts/auto_layout_align_strategy.dart @@ -92,6 +92,7 @@ class AutoLayoutAlignStrategy extends AlignStrategy { pointValueWidth: isVertical ? child.layoutCrossAxisSizing == ParentLayoutSizing.INHERIT : child.layoutMainAxisSizing == ParentLayoutSizing.INHERIT, + constraints: child.constraints.copyWith(), ) ..layoutCrossAxisSizing = child.layoutCrossAxisSizing ..layoutMainAxisSizing = child.layoutMainAxisSizing; diff --git a/lib/interpret_and_optimize/entities/layouts/rules/container_constraint_rule.dart b/lib/interpret_and_optimize/entities/layouts/rules/container_constraint_rule.dart index 7e9d3407..ad15e06f 100644 --- a/lib/interpret_and_optimize/entities/layouts/rules/container_constraint_rule.dart +++ b/lib/interpret_and_optimize/entities/layouts/rules/container_constraint_rule.dart @@ -7,20 +7,23 @@ import 'package:uuid/uuid.dart'; class ContainerConstraintRule extends PostConditionRule { @override - dynamic executeAction(PBContext context, - PBIntermediateNode currentNode, PBIntermediateNode nextNode) { + dynamic executeAction(PBContext context, PBIntermediateNode currentNode, + PBIntermediateNode nextNode) { if (testRule(context, currentNode, nextNode)) { - var container = InjectedContainer(null, currentNode.frame, - name: currentNode.name, - // constraints: currentNode.constraints - ); - //FIXME container.addChild(currentNode); + var container = InjectedContainer( + null, + currentNode.frame, + name: currentNode.name, + constraints: currentNode.constraints.copyWith(), + ); + //FIXME container.addChild(currentNode); return container; } return currentNode; } @override - bool testRule(PBContext context, PBIntermediateNode currentNode, PBIntermediateNode nextNode) => + bool testRule(PBContext context, PBIntermediateNode currentNode, + PBIntermediateNode nextNode) => (currentNode != null && currentNode is PBLayoutIntermediateNode); } diff --git a/lib/interpret_and_optimize/helpers/align_strategy.dart b/lib/interpret_and_optimize/helpers/align_strategy.dart index 891d3dea..bf255c61 100644 --- a/lib/interpret_and_optimize/helpers/align_strategy.dart +++ b/lib/interpret_and_optimize/helpers/align_strategy.dart @@ -119,8 +119,12 @@ class PositionedAlignment extends AlignStrategy { if (child is! PBContainer) { /// The container is going to be used to control the point value height/width var container = InjectedContainer( - null, child.frame.boundingBox(child.frame), - pointValueHeight: centerY, pointValueWidth: centerX); + null, + child.frame.boundingBox(child.frame), + pointValueHeight: centerY, + pointValueWidth: centerX, + constraints: child.constraints.copyWith(), + ); tree.addEdges(container, [child]); tree.addEdges(center, [container]); tree.addEdges(injectedPositioned, [center]); diff --git a/lib/tags/injected_tab_bar.dart b/lib/tags/injected_tab_bar.dart index f5889177..7acf9ae2 100644 --- a/lib/tags/injected_tab_bar.dart +++ b/lib/tags/injected_tab_bar.dart @@ -95,6 +95,7 @@ class InjectedTabBar extends PBTag implements PBInjectedIntermediate { null, child.frame, name: child.name, + constraints: child.constraints.copyWith(), )..attributeName = child.attributeName; context.tree.removeEdges(child.parent, [child]); context.tree.addEdges(container, [child]); From 8aaaf073e4a2a89a86fb325416ac7b47e130afe9 Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Fri, 7 Jan 2022 13:01:32 -0700 Subject: [PATCH 11/23] Pass axissizing to custom tag --- lib/tags/custom_tag/custom_tag.dart | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/tags/custom_tag/custom_tag.dart b/lib/tags/custom_tag/custom_tag.dart index e0b03fa6..cc832702 100644 --- a/lib/tags/custom_tag/custom_tag.dart +++ b/lib/tags/custom_tag/custom_tag.dart @@ -23,11 +23,17 @@ class CustomTag extends PBTag implements PBInjectedIntermediate { @override String semanticName = ''; + @override + ParentLayoutSizing layoutCrossAxisSizing; + @override + ParentLayoutSizing layoutMainAxisSizing; CustomTag( String UUID, Rectangle3D frame, String name, { PBIntermediateConstraints constraints, + this.layoutCrossAxisSizing, + this.layoutMainAxisSizing, }) : super( UUID, frame, @@ -58,6 +64,8 @@ class CustomTag extends PBTag implements PBInjectedIntermediate { frame, originalRef.name.replaceAll('', '').pascalCase + 'Custom', constraints: originalRef.constraints.copyWith(), + layoutCrossAxisSizing: originalRef.layoutCrossAxisSizing, + layoutMainAxisSizing: originalRef.layoutMainAxisSizing, ); } From 91cf641fdc3b32e1c2d02859e48d21a2e7958e5c Mon Sep 17 00:00:00 2001 From: Ivan <42812006+ivan-015@users.noreply.github.com> Date: Tue, 11 Jan 2022 14:13:39 -0700 Subject: [PATCH 12/23] Add new calls to Sentry --- lib/controllers/interpret.dart | 5 +++-- lib/controllers/main_info.dart | 18 ------------------ .../flutter_project_builder.dart | 11 +++++------ .../pb_generation_configuration.dart | 10 +++++----- .../visual-widgets/pb_align_gen.dart | 7 ++----- .../visual-widgets/pb_positioned_gen.dart | 9 +++------ .../services/pb_layout_generation_service.dart | 11 ++++------- lib/main.dart | 18 +++++++++--------- lib/tags/injected_tab_bar.dart | 6 ++---- pubspec.yaml | 2 +- 10 files changed, 34 insertions(+), 63 deletions(-) diff --git a/lib/controllers/interpret.dart b/lib/controllers/interpret.dart index 5f3796ec..41574627 100644 --- a/lib/controllers/interpret.dart +++ b/lib/controllers/interpret.dart @@ -12,6 +12,7 @@ import 'package:parabeac_core/interpret_and_optimize/services/pb_platform_orient import 'package:parabeac_core/interpret_and_optimize/services/pb_symbol_linker_service.dart'; import 'package:parabeac_core/interpret_and_optimize/services/state_management_node_interpreter.dart'; import 'package:quick_log/quick_log.dart'; +import 'package:sentry/sentry.dart'; import 'package:tuple/tuple.dart'; class Interpret { @@ -160,8 +161,8 @@ class AITServiceBuilder { 'The $name returned a null \"$treeName\" $PBIntermediateTree (or its rootnode is null)\n after its transformation, this will remove the tree from the process!'); // throw NullThrownError(); } - } catch (e) { - MainInfo().captureException(e); + } catch (e, stackTrace) { + await Sentry.captureException(e, stackTrace: stackTrace); log.error('${e.toString()} at $name'); } finally { _stopwatch.stop(); diff --git a/lib/controllers/main_info.dart b/lib/controllers/main_info.dart index 41fc824e..8178bcad 100644 --- a/lib/controllers/main_info.dart +++ b/lib/controllers/main_info.dart @@ -6,12 +6,6 @@ import 'package:path/path.dart' as p; class MainInfo { static final MainInfo _singleton = MainInfo._internal(); - final _sentry = DummySentry(); - - @Deprecated( - 'Use the function handle error for logging and capturing the error') - get sentry => _sentry; - /// Path representing where the output of parabeac-core will be produced to. /// /// First, we are going to check the if any path was passed as a flag to [outputPath], @@ -99,11 +93,6 @@ class MainInfo { return p.normalize(p.absolute(path)); } - /// Decoupling the exception capture client from the services that report the [exception] - void captureException(exception) { - // _sentry.captureException(exception: exception); - } - factory MainInfo() { return _singleton; } @@ -113,10 +102,3 @@ class MainInfo { /// The type of design that is being processed by Parabeac Core. enum DesignType { SKETCH, FIGMA, PBDL, UNKNOWN } - -class DummySentry { - /// Decoupling the exception capture client from the services that report the [exception] - void captureException({exception, stackTrace}) { - return; - } -} diff --git a/lib/generation/flutter_project_builder/flutter_project_builder.dart b/lib/generation/flutter_project_builder/flutter_project_builder.dart index c42a37e8..e09b66d2 100644 --- a/lib/generation/flutter_project_builder/flutter_project_builder.dart +++ b/lib/generation/flutter_project_builder/flutter_project_builder.dart @@ -6,13 +6,12 @@ import 'package:parabeac_core/interpret_and_optimize/helpers/pb_context.dart'; import 'package:parabeac_core/interpret_and_optimize/helpers/pb_intermediate_node_tree.dart'; import 'package:path/path.dart' as p; -import 'package:archive/archive.dart'; import 'package:parabeac_core/controllers/main_info.dart'; import 'package:parabeac_core/generation/generators/value_objects/generation_configuration/pb_generation_configuration.dart'; -import 'package:parabeac_core/generation/generators/writers/pb_page_writer.dart'; import 'package:parabeac_core/interpret_and_optimize/helpers/pb_project.dart'; import 'package:parabeac_core/interpret_and_optimize/helpers/pb_state_management_linker.dart'; import 'package:quick_log/quick_log.dart'; +import 'package:sentry/sentry.dart'; import 'package:tuple/tuple.dart'; /// The [FlutterProjectBuilder] generates the actual flutter project, @@ -80,8 +79,8 @@ class FlutterProjectBuilder { }); } return tuple; - } catch (e) { - MainInfo().captureException(e); + } catch (e, stackStrace) { + await Sentry.captureException(e, stackTrace: stackStrace); log.error(e.toString()); } } @@ -104,8 +103,8 @@ class FlutterProjectBuilder { workingDirectory: projectDir, runInShell: true) .then((result) => result.exitCode == 2 ? result.stderr : result.stdout) - .catchError((error) { - MainInfo().captureException(error); + .catchError((error, stackTrace) async { + await Sentry.captureException(error, stackTrace: stackTrace); log.error(error.toString()); }); } diff --git a/lib/generation/generators/value_objects/generation_configuration/pb_generation_configuration.dart b/lib/generation/generators/value_objects/generation_configuration/pb_generation_configuration.dart index d0d506ab..938c9a41 100644 --- a/lib/generation/generators/value_objects/generation_configuration/pb_generation_configuration.dart +++ b/lib/generation/generators/value_objects/generation_configuration/pb_generation_configuration.dart @@ -28,6 +28,7 @@ import 'package:parabeac_core/interpret_and_optimize/services/pb_platform_orient import 'package:quick_log/quick_log.dart'; import 'package:recase/recase.dart'; import 'package:path/path.dart' as p; +import 'package:sentry/sentry.dart'; abstract class GenerationConfiguration with PBPlatformOrientationGeneration { FileStructureStrategy fileStructureStrategy; @@ -124,7 +125,7 @@ abstract class GenerationConfiguration with PBPlatformOrientationGeneration { ///First we are going to perform a dry run in the generation to ///gather all the necessary information await setUpConfiguration(pb_project); - + fileStructureStrategy.addFileObserver(_importProcessor); // pb_project.fileStructureStrategy = fileStructureStrategy; @@ -234,12 +235,11 @@ abstract class GenerationConfiguration with PBPlatformOrientationGeneration { poLinker.getPlatformOrientationData(screenName); var imports = {}; platformOrientationMap.forEach((key, map) { - map.forEach((key, tree) { + map.forEach((key, tree) async { var uuidImport = _importProcessor.getImport(tree.UUID); if (uuidImport == null) { - MainInfo().sentry.captureException( - exception: Exception( - 'Import for tree with UUID ${tree.UUID} was null when getting imports from processor.')); + await Sentry.captureException(Exception( + 'Import for tree with UUID ${tree.UUID} was null when getting imports from processor.')); } else { imports.addAll(_importProcessor.getImport(tree.UUID)); } diff --git a/lib/generation/generators/visual-widgets/pb_align_gen.dart b/lib/generation/generators/visual-widgets/pb_align_gen.dart index 66d32f93..02154bdf 100644 --- a/lib/generation/generators/visual-widgets/pb_align_gen.dart +++ b/lib/generation/generators/visual-widgets/pb_align_gen.dart @@ -1,9 +1,9 @@ -import 'package:parabeac_core/controllers/main_info.dart'; import 'package:parabeac_core/generation/generators/pb_generator.dart'; import 'package:parabeac_core/interpret_and_optimize/entities/alignments/injected_align.dart'; import 'package:parabeac_core/interpret_and_optimize/entities/subclasses/pb_intermediate_node.dart'; import 'package:parabeac_core/interpret_and_optimize/helpers/pb_context.dart'; import 'package:quick_log/quick_log.dart'; +import 'package:sentry/sentry.dart'; class PBAlignGenerator extends PBGenerator { var log = Logger('Align Generator'); @@ -24,10 +24,7 @@ class PBAlignGenerator extends PBGenerator { buffer.write( 'child: ${sourceChild.generator.generate(sourceChild, context)},'); } catch (e, stackTrace) { - MainInfo().sentry.captureException( - exception: e, - stackTrace: stackTrace, - ); + Sentry.captureException(e, stackTrace: stackTrace); log.error(e.toString()); } diff --git a/lib/generation/generators/visual-widgets/pb_positioned_gen.dart b/lib/generation/generators/visual-widgets/pb_positioned_gen.dart index 4deb11a6..1f9700a4 100644 --- a/lib/generation/generators/visual-widgets/pb_positioned_gen.dart +++ b/lib/generation/generators/visual-widgets/pb_positioned_gen.dart @@ -1,10 +1,9 @@ -import 'package:parabeac_core/controllers/main_info.dart'; import 'package:parabeac_core/generation/generators/pb_generator.dart'; import 'package:parabeac_core/interpret_and_optimize/entities/alignments/injected_positioned.dart'; import 'package:parabeac_core/interpret_and_optimize/entities/subclasses/pb_intermediate_constraints.dart'; import 'package:parabeac_core/interpret_and_optimize/entities/subclasses/pb_intermediate_node.dart'; import 'package:parabeac_core/interpret_and_optimize/helpers/pb_context.dart'; -import 'package:tuple/tuple.dart'; +import 'package:sentry/sentry.dart'; class PBPositionedGenerator extends PBGenerator { /// The Flutter Position class allows it to override the `height` and the @@ -61,11 +60,9 @@ class PBPositionedGenerator extends PBGenerator { // source.child.currentContext = source.currentContext; buffer.write( 'child: ${sourceChildren.first.generator.generate(sourceChildren.first, context)},'); - } catch (e) { + } catch (e, stackTrace) { logger.error(e.toString()); - MainInfo().captureException( - e, - ); + Sentry.captureException(e, stackTrace: stackTrace); } buffer.write(')'); diff --git a/lib/interpret_and_optimize/services/pb_layout_generation_service.dart b/lib/interpret_and_optimize/services/pb_layout_generation_service.dart index 62da18a2..087abf77 100644 --- a/lib/interpret_and_optimize/services/pb_layout_generation_service.dart +++ b/lib/interpret_and_optimize/services/pb_layout_generation_service.dart @@ -1,7 +1,5 @@ -import 'package:directed_graph/directed_graph.dart'; import 'package:parabeac_core/controllers/interpret.dart'; import 'package:parabeac_core/controllers/main_info.dart'; -import 'package:parabeac_core/interpret_and_optimize/entities/inherited_container.dart'; import 'package:parabeac_core/interpret_and_optimize/entities/injected_container.dart'; import 'package:parabeac_core/interpret_and_optimize/entities/layouts/column.dart'; import 'package:parabeac_core/interpret_and_optimize/entities/layouts/layout_properties.dart'; @@ -17,6 +15,7 @@ import 'package:parabeac_core/interpret_and_optimize/entities/subclasses/pb_layo import 'package:parabeac_core/interpret_and_optimize/entities/subclasses/pb_visual_intermediate_node.dart'; import 'package:parabeac_core/interpret_and_optimize/helpers/pb_context.dart'; import 'package:parabeac_core/interpret_and_optimize/helpers/pb_intermediate_node_tree.dart'; +import 'package:sentry/sentry.dart'; /// PBLayoutGenerationService: /// Inject PBLayoutIntermediateNode to a PBIntermediateNode Tree that signifies the grouping of PBItermediateNodes in a given direction. There should not be any PBAlignmentIntermediateNode in the input tree. @@ -61,7 +60,7 @@ class PBLayoutGenerationService extends AITHandler { } Future extractLayouts( - PBIntermediateTree tree, PBContext context) { + PBIntermediateTree tree, PBContext context) async { if (tree.rootNode == null) { return Future.value(tree); } @@ -75,10 +74,8 @@ class PBLayoutGenerationService extends AITHandler { _wrapLayout(tree, context); return Future.value(tree); - } catch (e) { - MainInfo().captureException( - e, - ); + } catch (e, stackTrace) { + await Sentry.captureException(e, stackTrace: stackTrace); logger.error(e.toString()); } finally { return Future.value(tree); diff --git a/lib/main.dart b/lib/main.dart index b05c7699..08006d9a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,14 +1,10 @@ import 'dart:convert'; import 'dart:io'; -import 'dart:math'; -import 'package:directed_graph/directed_graph.dart'; import 'package:parabeac_core/generation/generators/util/pb_generation_view_data.dart'; import 'package:parabeac_core/interpret_and_optimize/entities/pb_shared_master_node.dart'; -import 'package:parabeac_core/interpret_and_optimize/helpers/element_storage.dart'; import 'package:parabeac_core/controllers/main_info.dart'; import 'package:parabeac_core/generation/flutter_project_builder/file_system_analyzer.dart'; import 'package:parabeac_core/generation/flutter_project_builder/flutter_project_builder.dart'; -import 'package:parabeac_core/generation/generators/writers/pb_flutter_writer.dart'; import 'package:parabeac_core/interpret_and_optimize/helpers/pb_configuration.dart'; import 'package:parabeac_core/interpret_and_optimize/helpers/pb_context.dart'; import 'package:parabeac_core/interpret_and_optimize/helpers/pb_intermediate_node_tree.dart'; @@ -19,6 +15,7 @@ import 'package:parabeac_core/interpret_and_optimize/services/design_to_pbdl/fig import 'package:parabeac_core/interpret_and_optimize/services/design_to_pbdl/json_to_pbdl_service.dart'; import 'package:parabeac_core/interpret_and_optimize/services/design_to_pbdl/sketch_to_pbdl_service.dart'; import 'package:quick_log/quick_log.dart'; +import 'package:sentry/sentry.dart'; import 'package:uuid/uuid.dart'; import 'package:http/http.dart' as http; import 'package:args/args.dart'; @@ -64,6 +61,9 @@ final parser = ArgParser() ..addFlag('exclude-styles', help: 'If this flag is set, it will exclude output styles document'); void main(List args) async { + await Sentry.init((p0) => p0.dsn = + 'https://6e011ce0d8cd4b7fb0ff284a23c5cb37@o433482.ingest.sentry.io/5388747'); + await checkConfigFile(); var log = Logger('Main'); var pubspec = File('pubspec.yaml'); @@ -75,7 +75,7 @@ void main(List args) async { MainInfo().cwd = Directory.current; -//error handler using logger package + //error handler using logger package void handleError(String msg) { log.error(msg); exitCode = 2; @@ -325,10 +325,10 @@ PBConfiguration generateConfiguration(String path) { configuration = PBConfiguration.fromJson(json.decode(File(path).readAsStringSync())); } catch (e, stackTrace) { - MainInfo().sentry.captureException( - exception: e, - stackTrace: stackTrace, - ); + Sentry.captureException( + e, + stackTrace: stackTrace, + ); } configuration ??= PBConfiguration.genericConfiguration(); return configuration; diff --git a/lib/tags/injected_tab_bar.dart b/lib/tags/injected_tab_bar.dart index 7acf9ae2..b7f8a5a3 100644 --- a/lib/tags/injected_tab_bar.dart +++ b/lib/tags/injected_tab_bar.dart @@ -13,6 +13,7 @@ import 'package:parabeac_core/interpret_and_optimize/helpers/child_strategy.dart import 'package:parabeac_core/interpret_and_optimize/helpers/pb_context.dart'; import 'package:parabeac_core/interpret_and_optimize/helpers/pb_intermediate_node_tree.dart'; import 'package:recase/recase.dart'; +import 'package:sentry/sentry.dart'; import 'package:uuid/uuid.dart'; @@ -148,10 +149,7 @@ class PBTabBarGenerator extends PBGenerator { buffer.write('),'); } } catch (e, stackTrace) { - MainInfo().sentry.captureException( - exception: e, - stackTrace: stackTrace, - ); + Sentry.captureException(e, stackTrace: stackTrace); buffer.write('),'); } buffer.write('],'); diff --git a/pubspec.yaml b/pubspec.yaml index 8c185131..f27a88f4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,6 @@ dependencies: logger: ^0.8.3 uuid: ^3.0.0 quick_log: ^1.1.3 - sentry: ^3.0.0 http2: ^1.0.1 recase: "^3.0.0" tuple: ^1.0.3 @@ -26,6 +25,7 @@ dependencies: pbdl: path: ./pbdl directed_graph: ^0.2.3 + sentry: ^6.2.2 dev_dependencies: pedantic: ^1.8.0 From 402dc020d823ab15ac001c122d4719ad869cec80 Mon Sep 17 00:00:00 2001 From: Ivan <42812006+ivan-015@users.noreply.github.com> Date: Tue, 11 Jan 2022 16:05:22 -0700 Subject: [PATCH 13/23] Add closing Sentry --- lib/main.dart | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 08006d9a..6fdcb419 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -60,10 +60,17 @@ final parser = ArgParser() help: 'This flag outputs Parabeac Design Logic (PBDL) in JSON format.') ..addFlag('exclude-styles', help: 'If this flag is set, it will exclude output styles document'); -void main(List args) async { - await Sentry.init((p0) => p0.dsn = - 'https://6e011ce0d8cd4b7fb0ff284a23c5cb37@o433482.ingest.sentry.io/5388747'); +Future main(List args) async { + await Sentry.init( + (p0) => p0.dsn = + 'https://6e011ce0d8cd4b7fb0ff284a23c5cb37@o433482.ingest.sentry.io/5388747', + appRunner: () async => runParabeac(args), + ); + await Sentry.close(); +} + +Future runParabeac(List args) async { await checkConfigFile(); var log = Logger('Main'); var pubspec = File('pubspec.yaml'); @@ -325,10 +332,11 @@ PBConfiguration generateConfiguration(String path) { configuration = PBConfiguration.fromJson(json.decode(File(path).readAsStringSync())); } catch (e, stackTrace) { - Sentry.captureException( - e, - stackTrace: stackTrace, - ); + print(e); + // Sentry.captureException( + // e, + // stackTrace: stackTrace, + // ); } configuration ??= PBConfiguration.genericConfiguration(); return configuration; From de53707e26ab7156b676442e6669c8ca8329a9d5 Mon Sep 17 00:00:00 2001 From: Ivan <42812006+ivan-015@users.noreply.github.com> Date: Tue, 11 Jan 2022 17:27:10 -0700 Subject: [PATCH 14/23] Add runZonedGuarded() to sentry calls --- lib/main.dart | 16 +++++++++++----- pbdl | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 6fdcb419..cd20b714 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,3 +1,4 @@ +import 'dart:async'; import 'dart:convert'; import 'dart:io'; import 'package:parabeac_core/generation/generators/util/pb_generation_view_data.dart'; @@ -62,11 +63,16 @@ final parser = ArgParser() help: 'If this flag is set, it will exclude output styles document'); Future main(List args) async { - await Sentry.init( - (p0) => p0.dsn = - 'https://6e011ce0d8cd4b7fb0ff284a23c5cb37@o433482.ingest.sentry.io/5388747', - appRunner: () async => runParabeac(args), - ); + await runZonedGuarded(() async { + await Sentry.init( + (p0) => p0.dsn = + 'https://6e011ce0d8cd4b7fb0ff284a23c5cb37@o433482.ingest.sentry.io/5388747', + ); + await runParabeac(args); + }, (error, stackTrace) async { + await Sentry.captureException(error); + await Sentry.close(); + }); await Sentry.close(); } diff --git a/pbdl b/pbdl index 250addf9..8c18158f 160000 --- a/pbdl +++ b/pbdl @@ -1 +1 @@ -Subproject commit 250addf9195f378176c5e653a7bd1572385163bb +Subproject commit 8c18158f5ef2d59cd0537ac4f5ca138f61142cfd From a44f0caea411e33399bb4cc59005a33b573a4ab2 Mon Sep 17 00:00:00 2001 From: Ivan <42812006+ivan-015@users.noreply.github.com> Date: Wed, 12 Jan 2022 11:04:21 -0700 Subject: [PATCH 15/23] Adjust Sentry calling Specifically, removed async from one of the `forEach` and added captureException in main.dart --- .../pb_generation_configuration.dart | 4 ++-- lib/main.dart | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/generation/generators/value_objects/generation_configuration/pb_generation_configuration.dart b/lib/generation/generators/value_objects/generation_configuration/pb_generation_configuration.dart index 938c9a41..c370d21a 100644 --- a/lib/generation/generators/value_objects/generation_configuration/pb_generation_configuration.dart +++ b/lib/generation/generators/value_objects/generation_configuration/pb_generation_configuration.dart @@ -235,10 +235,10 @@ abstract class GenerationConfiguration with PBPlatformOrientationGeneration { poLinker.getPlatformOrientationData(screenName); var imports = {}; platformOrientationMap.forEach((key, map) { - map.forEach((key, tree) async { + map.forEach((key, tree) { var uuidImport = _importProcessor.getImport(tree.UUID); if (uuidImport == null) { - await Sentry.captureException(Exception( + Sentry.captureException(Exception( 'Import for tree with UUID ${tree.UUID} was null when getting imports from processor.')); } else { imports.addAll(_importProcessor.getImport(tree.UUID)); diff --git a/lib/main.dart b/lib/main.dart index cd20b714..c244f0f5 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -338,11 +338,7 @@ PBConfiguration generateConfiguration(String path) { configuration = PBConfiguration.fromJson(json.decode(File(path).readAsStringSync())); } catch (e, stackTrace) { - print(e); - // Sentry.captureException( - // e, - // stackTrace: stackTrace, - // ); + Sentry.captureException(e, stackTrace: stackTrace); } configuration ??= PBConfiguration.genericConfiguration(); return configuration; From 1566eaec288586a55e1e1600e2a678fdf081b1b8 Mon Sep 17 00:00:00 2001 From: Ivan <42812006+ivan-015@users.noreply.github.com> Date: Thu, 13 Jan 2022 02:03:10 -0700 Subject: [PATCH 16/23] Update PBDL ref --- pbdl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pbdl b/pbdl index 8c18158f..24906ff8 160000 --- a/pbdl +++ b/pbdl @@ -1 +1 @@ -Subproject commit 8c18158f5ef2d59cd0537ac4f5ca138f61142cfd +Subproject commit 24906ff8389e7a23ef55cc1aa835f664b66953dd From 9680fcb85d8ef7a2ab5f02e862e773b421b49d6b Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Thu, 13 Jan 2022 13:23:03 -0700 Subject: [PATCH 17/23] Added component set properties to master --- .../entities/pb_shared_master_node.dart | 8 ++++++++ .../entities/pb_shared_master_node.g.dart | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/lib/interpret_and_optimize/entities/pb_shared_master_node.dart b/lib/interpret_and_optimize/entities/pb_shared_master_node.dart index ae56936e..52dc82b0 100644 --- a/lib/interpret_and_optimize/entities/pb_shared_master_node.dart +++ b/lib/interpret_and_optimize/entities/pb_shared_master_node.dart @@ -51,6 +51,12 @@ class PBSharedMasterNode extends PBVisualIntermediateNode @JsonKey(ignore: true) Map originalRef; + @JsonKey(ignore: false) + String componentSetName; + + @JsonKey(ignore: false) + String sharedNodeSetID; + PBSharedMasterNode( String UUID, Rectangle3D frame, { @@ -60,6 +66,8 @@ class PBSharedMasterNode extends PBVisualIntermediateNode this.overridableProperties, this.prototypeNode, PBIntermediateConstraints constraints, + this.componentSetName, + this.sharedNodeSetID, }) : super(UUID, frame, name, constraints: constraints) { overridableProperties ??= []; diff --git a/lib/interpret_and_optimize/entities/pb_shared_master_node.g.dart b/lib/interpret_and_optimize/entities/pb_shared_master_node.g.dart index cc8b3f42..41d48be8 100644 --- a/lib/interpret_and_optimize/entities/pb_shared_master_node.g.dart +++ b/lib/interpret_and_optimize/entities/pb_shared_master_node.g.dart @@ -18,7 +18,10 @@ PBSharedMasterNode _$PBSharedMasterNodeFromJson(Map json) { ? null : PBIntermediateConstraints.fromJson( json['constraints'] as Map), + componentSetName: json['componentSetName'] as String, + sharedNodeSetID: json['sharedNodeSetID'] as String, ) + ..subsemantic = json['subsemantic'] as String ..layoutMainAxisSizing = _$enumDecodeNullable( _$ParentLayoutSizingEnumMap, json['layoutMainAxisSizing']) ..layoutCrossAxisSizing = _$enumDecodeNullable( @@ -32,6 +35,7 @@ PBSharedMasterNode _$PBSharedMasterNodeFromJson(Map json) { Map _$PBSharedMasterNodeToJson(PBSharedMasterNode instance) => { + 'subsemantic': instance.subsemantic, 'UUID': instance.UUID, 'constraints': instance.constraints?.toJson(), 'layoutMainAxisSizing': @@ -44,6 +48,8 @@ Map _$PBSharedMasterNodeToJson(PBSharedMasterNode instance) => 'prototypeNodeUUID': instance.prototypeNode?.toJson(), 'symbolID': instance.SYMBOL_ID, 'type': instance.type, + 'componentSetName': instance.componentSetName, + 'sharedNodeSetID': instance.sharedNodeSetID, }; T _$enumDecode( From 3342ac1c19d34700347269c33aea03850b228dc0 Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Thu, 13 Jan 2022 13:23:17 -0700 Subject: [PATCH 18/23] Generate sub directory for variant components --- .../generators/middleware/command_gen_middleware.dart | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/generation/generators/middleware/command_gen_middleware.dart b/lib/generation/generators/middleware/command_gen_middleware.dart index 98a47b3d..827593af 100644 --- a/lib/generation/generators/middleware/command_gen_middleware.dart +++ b/lib/generation/generators/middleware/command_gen_middleware.dart @@ -7,6 +7,7 @@ import 'package:parabeac_core/generation/generators/value_objects/file_structure import 'package:parabeac_core/generation/generators/value_objects/file_structure_strategy/commands/write_symbol_command.dart'; import 'package:parabeac_core/generation/generators/value_objects/generation_configuration/pb_generation_configuration.dart'; import 'package:parabeac_core/generation/generators/value_objects/generation_configuration/pb_platform_orientation_generation_mixin.dart'; +import 'package:parabeac_core/interpret_and_optimize/entities/pb_shared_master_node.dart'; import 'package:parabeac_core/interpret_and_optimize/helpers/element_storage.dart'; import 'package:parabeac_core/interpret_and_optimize/helpers/pb_context.dart'; import 'package:parabeac_core/interpret_and_optimize/helpers/pb_intermediate_node_tree.dart'; @@ -62,11 +63,19 @@ class CommandGenMiddleware extends Middleware ?.isEmpty ?? true) { // TODO: Find a more optimal way to exclude state management nodes + var relativePath = tree.name; + if (tree.rootNode is PBSharedMasterNode) { + var componentSetName = + (tree.rootNode as PBSharedMasterNode).componentSetName; + relativePath = componentSetName != null + ? relativePath + '/' + componentSetName.snakeCase + : relativePath; + } command = WriteSymbolCommand( tree.UUID, tree.identifier, generationManager.generate(tree.rootNode, context), - relativePath: tree.name, + relativePath: relativePath, ); } if (command != null) { From d910022391e915f6ed02fc7ec947ef767bf9bb6c Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Mon, 17 Jan 2022 12:46:08 -0700 Subject: [PATCH 19/23] Re geenerate .g files --- .../entities/inherited_container.g.dart | 4 ++++ lib/interpret_and_optimize/entities/injected_container.g.dart | 4 ++++ .../entities/layouts/group/base_group.g.dart | 4 ++++ .../entities/layouts/group/frame_group.g.dart | 4 ++++ lib/interpret_and_optimize/entities/layouts/row.g.dart | 4 ++++ lib/interpret_and_optimize/entities/pb_shared_instance.dart | 4 ++++ lib/interpret_and_optimize/entities/pb_shared_instance.g.dart | 4 ++++ .../entities/subclasses/pb_intermediate_node.g.dart | 3 +++ 8 files changed, 31 insertions(+) diff --git a/lib/interpret_and_optimize/entities/inherited_container.g.dart b/lib/interpret_and_optimize/entities/inherited_container.g.dart index 8b56989a..1d49c99d 100644 --- a/lib/interpret_and_optimize/entities/inherited_container.g.dart +++ b/lib/interpret_and_optimize/entities/inherited_container.g.dart @@ -14,6 +14,8 @@ InheritedContainer _$InheritedContainerFromJson(Map json) { isBackgroundVisible: json['isBackgroundVisible'] as bool ?? true, prototypeNode: PrototypeNode.prototypeNodeFromJson( json['prototypeNodeUUID'] as String), + showWidth: json['showWidth'] as bool, + showHeight: json['showHeight'] as bool, constraints: json['constraints'] == null ? null : PBIntermediateConstraints.fromJson( @@ -46,6 +48,8 @@ Map _$InheritedContainerToJson(InheritedContainer instance) => 'prototypeNodeUUID': instance.prototypeNode, 'isBackgroundVisible': instance.isBackgroundVisible, 'type': instance.type, + 'showWidth': instance.showWidth, + 'showHeight': instance.showHeight, }; T _$enumDecode( diff --git a/lib/interpret_and_optimize/entities/injected_container.g.dart b/lib/interpret_and_optimize/entities/injected_container.g.dart index 3e7f8152..35e8ad6b 100644 --- a/lib/interpret_and_optimize/entities/injected_container.g.dart +++ b/lib/interpret_and_optimize/entities/injected_container.g.dart @@ -20,6 +20,8 @@ InjectedContainer _$InjectedContainerFromJson(Map json) { ? null : PBIntermediateConstraints.fromJson( json['constraints'] as Map), + showWidth: json['showWidth'] as bool, + showHeight: json['showHeight'] as bool, ) ..subsemantic = json['subsemantic'] as String ..layoutMainAxisSizing = _$enumDecodeNullable( @@ -48,6 +50,8 @@ Map _$InjectedContainerToJson(InjectedContainer instance) => 'type': instance.type, 'pointValueWidth': instance.pointValueWidth, 'pointValueHeight': instance.pointValueHeight, + 'showWidth': instance.showWidth, + 'showHeight': instance.showHeight, }; T _$enumDecode( diff --git a/lib/interpret_and_optimize/entities/layouts/group/base_group.g.dart b/lib/interpret_and_optimize/entities/layouts/group/base_group.g.dart index 2588e70e..23fc0dec 100644 --- a/lib/interpret_and_optimize/entities/layouts/group/base_group.g.dart +++ b/lib/interpret_and_optimize/entities/layouts/group/base_group.g.dart @@ -18,6 +18,7 @@ BaseGroup _$BaseGroupFromJson(Map json) { : PBIntermediateConstraints.fromJson( json['constraints'] as Map), ) + ..subsemantic = json['subsemantic'] as String ..layoutMainAxisSizing = _$enumDecodeNullable( _$ParentLayoutSizingEnumMap, json['layoutMainAxisSizing']) ..layoutCrossAxisSizing = _$enumDecodeNullable( @@ -26,10 +27,12 @@ BaseGroup _$BaseGroupFromJson(Map json) { ? null : IntermediateAuxiliaryData.fromJson( json['style'] as Map) + ..alignment = json['alignment'] as Map ..type = json['type'] as String; } Map _$BaseGroupToJson(BaseGroup instance) => { + 'subsemantic': instance.subsemantic, 'UUID': instance.UUID, 'constraints': instance.constraints, 'layoutMainAxisSizing': @@ -39,6 +42,7 @@ Map _$BaseGroupToJson(BaseGroup instance) => { 'boundaryRectangle': Rectangle3D.toJson(instance.frame), 'style': instance.auxiliaryData, 'name': instance.name, + 'alignment': instance.alignment, 'prototypeNodeUUID': instance.prototypeNode, 'type': instance.type, }; diff --git a/lib/interpret_and_optimize/entities/layouts/group/frame_group.g.dart b/lib/interpret_and_optimize/entities/layouts/group/frame_group.g.dart index f9c363e8..b35c73cf 100644 --- a/lib/interpret_and_optimize/entities/layouts/group/frame_group.g.dart +++ b/lib/interpret_and_optimize/entities/layouts/group/frame_group.g.dart @@ -18,6 +18,7 @@ FrameGroup _$FrameGroupFromJson(Map json) { : PBIntermediateConstraints.fromJson( json['constraints'] as Map), ) + ..subsemantic = json['subsemantic'] as String ..layoutMainAxisSizing = _$enumDecodeNullable( _$ParentLayoutSizingEnumMap, json['layoutMainAxisSizing']) ..layoutCrossAxisSizing = _$enumDecodeNullable( @@ -26,11 +27,13 @@ FrameGroup _$FrameGroupFromJson(Map json) { ? null : IntermediateAuxiliaryData.fromJson( json['style'] as Map) + ..alignment = json['alignment'] as Map ..type = json['type'] as String; } Map _$FrameGroupToJson(FrameGroup instance) => { + 'subsemantic': instance.subsemantic, 'UUID': instance.UUID, 'constraints': instance.constraints, 'layoutMainAxisSizing': @@ -40,6 +43,7 @@ Map _$FrameGroupToJson(FrameGroup instance) => 'boundaryRectangle': Rectangle3D.toJson(instance.frame), 'style': instance.auxiliaryData, 'name': instance.name, + 'alignment': instance.alignment, 'prototypeNodeUUID': instance.prototypeNode, 'type': instance.type, }; diff --git a/lib/interpret_and_optimize/entities/layouts/row.g.dart b/lib/interpret_and_optimize/entities/layouts/row.g.dart index ec5de067..54b904ab 100644 --- a/lib/interpret_and_optimize/entities/layouts/row.g.dart +++ b/lib/interpret_and_optimize/entities/layouts/row.g.dart @@ -11,6 +11,7 @@ PBIntermediateRowLayout _$PBIntermediateRowLayoutFromJson( return PBIntermediateRowLayout( name: json['name'] as String, ) + ..subsemantic = json['subsemantic'] as String ..constraints = json['constraints'] == null ? null : PBIntermediateConstraints.fromJson( @@ -25,6 +26,7 @@ PBIntermediateRowLayout _$PBIntermediateRowLayoutFromJson( ? null : IntermediateAuxiliaryData.fromJson( json['style'] as Map) + ..alignment = json['alignment'] as Map ..prototypeNode = json['prototypeNode'] == null ? null : PrototypeNode.fromJson(json['prototypeNode'] as Map) @@ -38,6 +40,7 @@ PBIntermediateRowLayout _$PBIntermediateRowLayoutFromJson( Map _$PBIntermediateRowLayoutToJson( PBIntermediateRowLayout instance) => { + 'subsemantic': instance.subsemantic, 'constraints': instance.constraints, 'layoutMainAxisSizing': _$ParentLayoutSizingEnumMap[instance.layoutMainAxisSizing], @@ -46,6 +49,7 @@ Map _$PBIntermediateRowLayoutToJson( 'boundaryRectangle': Rectangle3D.toJson(instance.frame), 'style': instance.auxiliaryData, 'name': instance.name, + 'alignment': instance.alignment, 'prototypeNode': instance.prototypeNode, 'autoLayoutOptions': instance.layoutProperties, 'type': instance.type, diff --git a/lib/interpret_and_optimize/entities/pb_shared_instance.dart b/lib/interpret_and_optimize/entities/pb_shared_instance.dart index c013ef92..9e913343 100644 --- a/lib/interpret_and_optimize/entities/pb_shared_instance.dart +++ b/lib/interpret_and_optimize/entities/pb_shared_instance.dart @@ -53,6 +53,9 @@ class PBSharedInstanceIntermediateNode extends PBVisualIntermediateNode @JsonKey(ignore: true) Map originalRef; + @JsonKey(ignore: false) + String sharedNodeSetID; + PBSharedInstanceIntermediateNode( String UUID, Rectangle3D frame, { @@ -62,6 +65,7 @@ class PBSharedInstanceIntermediateNode extends PBVisualIntermediateNode this.prototypeNode, this.overrideValues, String name, + this.sharedNodeSetID, }) : super( UUID, frame, diff --git a/lib/interpret_and_optimize/entities/pb_shared_instance.g.dart b/lib/interpret_and_optimize/entities/pb_shared_instance.g.dart index e4d2fa99..c712029a 100644 --- a/lib/interpret_and_optimize/entities/pb_shared_instance.g.dart +++ b/lib/interpret_and_optimize/entities/pb_shared_instance.g.dart @@ -20,7 +20,9 @@ PBSharedInstanceIntermediateNode _$PBSharedInstanceIntermediateNodeFromJson( prototypeNode: PrototypeNode.prototypeNodeFromJson( json['prototypeNodeUUID'] as String), name: json['name'] as String, + sharedNodeSetID: json['sharedNodeSetID'] as String, ) + ..subsemantic = json['subsemantic'] as String ..constraints = json['constraints'] == null ? null : PBIntermediateConstraints.fromJson( @@ -39,6 +41,7 @@ PBSharedInstanceIntermediateNode _$PBSharedInstanceIntermediateNodeFromJson( Map _$PBSharedInstanceIntermediateNodeToJson( PBSharedInstanceIntermediateNode instance) => { + 'subsemantic': instance.subsemantic, 'UUID': instance.UUID, 'constraints': instance.constraints?.toJson(), 'layoutMainAxisSizing': @@ -53,6 +56,7 @@ Map _$PBSharedInstanceIntermediateNodeToJson( instance.sharedParamValues?.map((e) => e?.toJson())?.toList(), 'prototypeNodeUUID': instance.prototypeNode?.toJson(), 'type': instance.type, + 'sharedNodeSetID': instance.sharedNodeSetID, }; T _$enumDecode( diff --git a/lib/interpret_and_optimize/entities/subclasses/pb_intermediate_node.g.dart b/lib/interpret_and_optimize/entities/subclasses/pb_intermediate_node.g.dart index 671d8efd..2d452eca 100644 --- a/lib/interpret_and_optimize/entities/subclasses/pb_intermediate_node.g.dart +++ b/lib/interpret_and_optimize/entities/subclasses/pb_intermediate_node.g.dart @@ -8,6 +8,7 @@ part of 'pb_intermediate_node.dart'; Map _$PBIntermediateNodeToJson(PBIntermediateNode instance) => { + 'subsemantic': instance.subsemantic, 'UUID': instance.UUID, 'constraints': instance.constraints?.toJson(), 'layoutMainAxisSizing': @@ -17,6 +18,8 @@ Map _$PBIntermediateNodeToJson(PBIntermediateNode instance) => 'boundaryRectangle': Rectangle3D.toJson(instance.frame), 'style': instance.auxiliaryData?.toJson(), 'name': instance.name, + 'hashCode': instance.hashCode, + 'id': instance.id, }; const _$ParentLayoutSizingEnumMap = { From 54101915c6b2cc1b90961a407cc68246e5ca5e9e Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Mon, 17 Jan 2022 12:46:27 -0700 Subject: [PATCH 20/23] Re structured state management --- .../helpers/pb_state_management_helper.dart | 41 +++++++++++-------- .../helpers/pb_state_management_linker.dart | 15 +++---- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/lib/interpret_and_optimize/helpers/pb_state_management_helper.dart b/lib/interpret_and_optimize/helpers/pb_state_management_helper.dart index b2409324..35478f3b 100644 --- a/lib/interpret_and_optimize/helpers/pb_state_management_helper.dart +++ b/lib/interpret_and_optimize/helpers/pb_state_management_helper.dart @@ -3,6 +3,7 @@ import 'package:parabeac_core/interpret_and_optimize/entities/pb_shared_master_n import 'package:parabeac_core/interpret_and_optimize/entities/subclasses/pb_intermediate_node.dart'; import 'package:parabeac_core/interpret_and_optimize/helpers/pb_intermediate_node_tree.dart'; import 'package:parabeac_core/interpret_and_optimize/helpers/pb_state_management_linker.dart'; +import 'package:parabeac_core/interpret_and_optimize/helpers/pb_symbol_storage.dart'; import 'package:parabeac_core/interpret_and_optimize/state_management/directed_state_graph.dart'; /// Class that interprets state management nodes @@ -20,11 +21,12 @@ class PBStateManagementHelper { void interpretStateManagementNode( PBIntermediateNode node, PBIntermediateTree tree) { - if (isValidStateNode(node.name)) { - var nodeName = _getNodeName(node.name); + if (isValidStateNode(node)) { // TODO: these states will be used for phase 2 of state management - var states = _getStates(node.name); - linker.processVariation(node, nodeName, tree); + // var nodeName = _getNodeName(node.name); + // var states = _getStates(node.name); + linker.processVariation( + node, (node as PBSharedMasterNode).sharedNodeSetID, tree); } } @@ -32,31 +34,34 @@ class PBStateManagementHelper { /// `false` otherwise bool isDefaultNode(PBIntermediateNode node) => node is PBSharedMasterNode && - (linker.isSymbolInstance(_getNodeName(node.name)) || - !linker.containsElement(_getNodeName(node.name))); + !linker.containsElement(node.sharedNodeSetID); - String _getNodeName(String fullName) => - isValidStateNode(fullName) ? fullName.split('/')[0] : ''; + // String _getNodeName(String fullName) => + // isValidStateNode(fullName) ? fullName.split('/')[0] : ''; - List _getStates(String fullName) => - isValidStateNode(fullName) ? fullName.split('/')[1].split(',') : []; + // List _getStates(String fullName) => + // isValidStateNode(fullName) ? fullName.split('/')[1].split(',') : []; /// Returns true if `name` is a valid state management name - bool isValidStateNode(String name) => - RegExp(r'^\w*\/(\w*,?\s?)*[\w]$').hasMatch(name ?? ''); + bool isValidStateNode(PBIntermediateNode node) { + if (node is PBSharedMasterNode) { + return node.sharedNodeSetID != null; + } else if (node is PBSharedInstanceIntermediateNode) { + return node.sharedNodeSetID != null; + } else { + return false; + } + } /// Returns the [DirectedStateGraph] of `node`. /// /// Returns `null` if `node` has no `DirectedStateGraph` DirectedStateGraph getStateGraphOfNode(PBIntermediateNode node) { - var identifier = node is PBSharedInstanceIntermediateNode - ? node.functionCallName - : node.name; - if (isValidStateNode(identifier) && + if (isValidStateNode(node) && (node is PBSharedMasterNode || node is PBSharedInstanceIntermediateNode)) { - var rootNodeName = _getNodeName(identifier); - return linker.getDirectedStateGraphOfName(rootNodeName); + return linker + .getDirectedStateGraphOfName((node as dynamic).sharedNodeSetID); } return null; } diff --git a/lib/interpret_and_optimize/helpers/pb_state_management_linker.dart b/lib/interpret_and_optimize/helpers/pb_state_management_linker.dart index f63b51d3..9206f1a0 100644 --- a/lib/interpret_and_optimize/helpers/pb_state_management_linker.dart +++ b/lib/interpret_and_optimize/helpers/pb_state_management_linker.dart @@ -32,7 +32,8 @@ class PBStateManagementLinker { List stateQueue; - bool containsElement(String name) => _rootNameToGraph.containsKey(name); + bool containsElement(String sharedNodeSetID) => + _rootNameToGraph.containsKey(sharedNodeSetID); /// Returns true if `name` exists in the statemap and it is /// a symbol instance. @@ -40,11 +41,11 @@ class PBStateManagementLinker { _rootNameToGraph.containsKey(name) && _rootNameToGraph[name] is PBSharedInstanceIntermediateNode; - void processVariation(PBIntermediateNode node, String rootNodeName, + void processVariation(PBIntermediateNode node, String sharedNodeSetID, PBIntermediateTree tree) async { // if `node` is default, create a new graph - if (!containsElement(rootNodeName)) { - _rootNameToGraph[rootNodeName] = DirectedStateGraph(node); + if (!containsElement(sharedNodeSetID)) { + _rootNameToGraph[sharedNodeSetID] = DirectedStateGraph(node); } // Add variation to default state node @@ -55,13 +56,13 @@ class PBStateManagementLinker { tempSym?.forEach((element) => element.isMasterState = true); } stateQueue.add(_interpretVariationNode(node, tree).then((processedNode) => - _rootNameToGraph[rootNodeName].addVariation(processedNode))); + _rootNameToGraph[sharedNodeSetID].addVariation(processedNode))); } } /// Gets the [DirectedStateGraph] of `rootNodeName` or `null` if it does not exist. - DirectedStateGraph getDirectedStateGraphOfName(String rootNodeName) => - _rootNameToGraph[rootNodeName]; + DirectedStateGraph getDirectedStateGraphOfName(String sharedNodeSetID) => + _rootNameToGraph[sharedNodeSetID]; /// Runs the state management [PBIntermediateNode] through /// the necessary interpretation services. From 0c87b61aec666d9fd9394059e39fc00ec4042aa5 Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Mon, 17 Jan 2022 12:46:40 -0700 Subject: [PATCH 21/23] Commented out statemanagement --- .../state_management_node_interpreter.dart | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/interpret_and_optimize/services/state_management_node_interpreter.dart b/lib/interpret_and_optimize/services/state_management_node_interpreter.dart index 491a15ca..f2bc5d19 100644 --- a/lib/interpret_and_optimize/services/state_management_node_interpreter.dart +++ b/lib/interpret_and_optimize/services/state_management_node_interpreter.dart @@ -17,16 +17,16 @@ class StateManagementNodeInterpreter extends AITHandler { } var node = tree.rootNode; var smHelper = PBStateManagementHelper(); - if (smHelper.isValidStateNode(node.name)) { - if (smHelper.isDefaultNode(node)) { - smHelper.interpretStateManagementNode(node, tree); - return Future.value(tree); - } else { - /// Remove tree entirely - smHelper.interpretStateManagementNode(node, tree); - return Future.value(null); - } - } + // if (smHelper.isValidStateNode(node)) { + // if (smHelper.isDefaultNode(node)) { + // smHelper.interpretStateManagementNode(node, tree); + // return Future.value(tree); + // } else { + // /// Remove tree entirely + // smHelper.interpretStateManagementNode(node, tree); + // return Future.value(null); + // } + // } return Future.value(tree); } } From 4f237b8d9d981e2d27e26c7d44af8e6c3f33ba56 Mon Sep 17 00:00:00 2001 From: Ivan <42812006+ivan-015@users.noreply.github.com> Date: Mon, 17 Jan 2022 17:18:35 -0700 Subject: [PATCH 22/23] Update PBDL Ref --- pbdl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pbdl b/pbdl index 250addf9..4d360857 160000 --- a/pbdl +++ b/pbdl @@ -1 +1 @@ -Subproject commit 250addf9195f378176c5e653a7bd1572385163bb +Subproject commit 4d360857d1052c5ca87f1d033e55242e947aa6f1 From 6170d012c1859415fa9129899536ec00039a337c Mon Sep 17 00:00:00 2001 From: Bryan Figueroa Date: Mon, 17 Jan 2022 17:34:22 -0700 Subject: [PATCH 23/23] Updated version --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index f27a88f4..42b0be5f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: parabeac_core description: A starting point for Dart libraries or applications. -version: 2.2.0 +version: 2.3.0 # homepage: https://www.example.com environment: