Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #578 from Parabeac/release/2.3.0
Browse files Browse the repository at this point in the history
Release/2.3.0
  • Loading branch information
ivan-015 authored Jan 18, 2022
2 parents 15318a4 + 9df4b2c commit dc29df3
Show file tree
Hide file tree
Showing 32 changed files with 260 additions and 140 deletions.
5 changes: 3 additions & 2 deletions lib/controllers/interpret.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
Expand Down
18 changes: 0 additions & 18 deletions lib/controllers/main_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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());
}
}
Expand All @@ -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());
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)},';
Expand Down
11 changes: 10 additions & 1 deletion lib/generation/generators/middleware/command_gen_middleware.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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) {
Expand Down
52 changes: 34 additions & 18 deletions lib/generation/generators/symbols/pb_instancesym_gen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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 '';
Expand Down Expand Up @@ -102,32 +111,39 @@ 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');

return buffer.toString();
}

// Traverse all overridable properties to write them for class use
String overridesToString(
List<PBInstanceOverride> 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<PBInstanceOverride> params, PBContext context) {
void formatNameAndValues(List<PBInstanceOverride> params, PBContext context) {
params.forEach((param) {
var overrideProp = OverrideHelper.getProperty(param.UUID, param.type);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -237,9 +238,8 @@ abstract class GenerationConfiguration with PBPlatformOrientationGeneration {
map.forEach((key, tree) {
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.'));
Sentry.captureException(Exception(
'Import for tree with UUID ${tree.UUID} was null when getting imports from processor.'));
} else {
imports.addAll(_importProcessor.getImport(tree.UUID));
}
Expand Down
7 changes: 2 additions & 5 deletions lib/generation/generators/visual-widgets/pb_align_gen.dart
Original file line number Diff line number Diff line change
@@ -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');
Expand All @@ -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());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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(')');
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions lib/interpret_and_optimize/entities/injected_container.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class AutoLayoutAlignStrategy extends AlignStrategy<PBLayoutIntermediateNode> {
pointValueWidth: isVertical
? child.layoutCrossAxisSizing == ParentLayoutSizing.INHERIT
: child.layoutMainAxisSizing == ParentLayoutSizing.INHERIT,
constraints: child.constraints.copyWith(),
)
..layoutCrossAxisSizing = child.layoutCrossAxisSizing
..layoutMainAxisSizing = child.layoutMainAxisSizing;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
Loading

0 comments on commit dc29df3

Please sign in to comment.