From f676b566020254aac4bb6f3c3c58ed8d2c3ff990 Mon Sep 17 00:00:00 2001 From: Sydney Jodon Date: Wed, 9 Dec 2020 09:34:35 -0700 Subject: [PATCH 01/54] Change generated factory configs to be private --- lib/src/builder/codegen/names.dart | 9 +++++++-- lib/src/builder/codegen/typed_map_impl_generator.dart | 7 +++++-- lib/src/builder/parsing/ast_util.dart | 6 ++++-- lib/src/builder/parsing/members/factory.dart | 2 +- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/src/builder/codegen/names.dart b/lib/src/builder/codegen/names.dart index 57b8ff95f..ab3ff70df 100644 --- a/lib/src/builder/codegen/names.dart +++ b/lib/src/builder/codegen/names.dart @@ -45,10 +45,15 @@ class FactoryNames { /// - Output: `_$Foo` String get implName => '$_prefix$privateSourcePrefix$unprefixedConsumerName'; - /// The name of the generated function component props config for the factory. + /// The name of the private generated function component props config for the factory. /// /// Example: `$FooConfig - String get configName => '\$${consumerName}Config'; + String get privateConfigName => '_$publicConfigName'; + + /// The name of the public generated function component props config for the factory. + /// + /// Example: `$FooConfig + String get publicConfigName => '\$${consumerName}Config'; } /// A set of names of the different generated members for a given component class. diff --git a/lib/src/builder/codegen/typed_map_impl_generator.dart b/lib/src/builder/codegen/typed_map_impl_generator.dart index e173aa5c4..742ee9dd3 100644 --- a/lib/src/builder/codegen/typed_map_impl_generator.dart +++ b/lib/src/builder/codegen/typed_map_impl_generator.dart @@ -390,11 +390,14 @@ class _TypedMapImplGenerator extends TypedMapImplGenerator { String _generateUiFactoryConfig(FactoryNames factoryName) { return 'final UiFactoryConfig<${names.implName}> ' - '${factoryName.configName} = UiFactoryConfig(\n' + '${factoryName.privateConfigName} = UiFactoryConfig(\n' 'propsFactory: PropsFactory(\n' 'map: (map) => ${names.implName}(map),\n' 'jsMap: (map) => ${names.jsMapImplName}(map),),\n' - 'displayName: \'${factoryName.consumerName}\');\n\n'; + 'displayName: \'${factoryName.consumerName}\');\n\n' + '@Deprecated(\'Use `_\\${factoryName.publicConfigName}` instead.\')\n' + 'final UiFactoryConfig<${names.implName}> ' + '${factoryName.publicConfigName} = ${factoryName.privateConfigName};\n\n'; } @override diff --git a/lib/src/builder/parsing/ast_util.dart b/lib/src/builder/parsing/ast_util.dart index 97faf70ad..39484db11 100644 --- a/lib/src/builder/parsing/ast_util.dart +++ b/lib/src/builder/parsing/ast_util.dart @@ -45,10 +45,12 @@ extension InitializerHelperTopLevel on TopLevelVariableDeclaration { /// Returns whether or not there is a generated config being used. bool get usesAGeneratedConfig { - final generatedConfigName = FactoryNames(firstVariable.name.name).configName; + final generatedPrivateConfigName = FactoryNames(firstVariable.name.name).privateConfigName; + final generatedPublicConfigName = FactoryNames(firstVariable.name.name).publicConfigName; return firstInitializer != null && anyDescendantIdentifiers(firstInitializer, (identifier) { - return identifier.nameWithoutPrefix == generatedConfigName; + return identifier.nameWithoutPrefix == generatedPrivateConfigName || + identifier.nameWithoutPrefix == generatedPublicConfigName; }); } } diff --git a/lib/src/builder/parsing/members/factory.dart b/lib/src/builder/parsing/members/factory.dart index 94f3e69a2..d7053f3b7 100644 --- a/lib/src/builder/parsing/members/factory.dart +++ b/lib/src/builder/parsing/members/factory.dart @@ -87,7 +87,7 @@ class BoilerplateFactory extends BoilerplateMember { final names = FactoryNames(factoryName); final generatedFactoryName = names.implName; - final generatedConfigName = names.configName; + final generatedConfigName = names.privateConfigName; final initializer = variable.initializer; final referencesGeneratedFactory = initializer != null && From 1024112b649e0849a0eeadeeb39e469d0c685a83 Mon Sep 17 00:00:00 2001 From: Sydney Jodon Date: Wed, 9 Dec 2020 09:54:50 -0700 Subject: [PATCH 02/54] Run build and update config usages --- README.md | 2 +- doc/new_boilerplate_migration.md | 12 ++--- doc/props_mixin_component_composition.md | 2 +- example/builder/src/function_component.dart | 6 +-- .../src/function_component.over_react.g.dart | 15 +++++-- .../src/functional_consumed_props.dart | 6 +-- ...unctional_consumed_props.over_react.g.dart | 11 ++++- example/hooks/use_callback_example.dart | 2 +- .../use_callback_example.over_react.g.dart | 6 ++- example/hooks/use_context_example.dart | 4 +- .../use_context_example.over_react.g.dart | 12 ++++- example/hooks/use_debug_value_example.dart | 4 +- .../use_debug_value_example.over_react.g.dart | 12 ++++- .../hooks/use_imperative_handle_example.dart | 4 +- ...mperative_handle_example.over_react.g.dart | 12 ++++- example/hooks/use_layout_effect_example.dart | 2 +- ...se_layout_effect_example.over_react.g.dart | 6 ++- example/hooks/use_memo_example.dart | 2 +- .../hooks/use_memo_example.over_react.g.dart | 6 ++- example/hooks/use_reducer_example.dart | 2 +- .../use_reducer_example.over_react.g.dart | 6 ++- example/hooks/use_ref_example.dart | 2 +- .../hooks/use_ref_example.over_react.g.dart | 6 ++- example/hooks/use_state_example.dart | 2 +- .../hooks/use_state_example.over_react.g.dart | 6 ++- lib/src/component/hooks.dart | 28 ++++++------ lib/src/component/ref_util.dart | 4 +- lib/src/component/with_transition.dart | 6 +-- .../function_component.dart | 4 +- lib/src/util/memo.dart | 4 +- test/over_react/component/memo_test.dart | 2 +- .../component/memo_test.over_react.g.dart | 6 ++- test/over_react/component/ref_util_test.dart | 4 +- .../component/ref_util_test.over_react.g.dart | 12 ++++- .../function_component_test.over_react.g.dart | 15 +++++-- web/component2/src/demos/ref.dart | 10 ++--- .../src/demos/ref.over_react.g.dart | 45 ++++++++++++++----- 37 files changed, 199 insertions(+), 91 deletions(-) diff --git a/README.md b/README.md index beb5832c2..1eadfad1a 100644 --- a/README.md +++ b/README.md @@ -827,7 +827,7 @@ that you get for free from OverReact, you're ready to start building your own cu ); }, // The generated props config will match the factory name. - $FooConfig, // ignore: undefined_identifier + _$FooConfig, // ignore: undefined_identifier ); mixin FooProps on UiProps { diff --git a/doc/new_boilerplate_migration.md b/doc/new_boilerplate_migration.md index c1c389458..b414130ae 100644 --- a/doc/new_boilerplate_migration.md +++ b/doc/new_boilerplate_migration.md @@ -731,7 +731,7 @@ UiFactory Foo = uiFunction( (props) { return 'foo: ${props.foo}'; }, - $FooConfig, // ignore: undefined_identifier + _$FooConfig, // ignore: undefined_identifier ); mixin FooProps on UiProps { @@ -761,7 +761,7 @@ UiFactory Foo = uiFunction( return 'foo: $foo'; }, - $FooConfig, // ignore: undefined_identifier + _$FooConfig, // ignore: undefined_identifier ); ``` @@ -792,14 +792,14 @@ UiFactory FooBar = uiFunction( return (Foo()..addUnconsumedProps(props, consumedProps))(); }, - $FooBarConfig, // ignore: undefined_identifier + _$FooBarConfig, // ignore: undefined_identifier ); UiFactory Foo = uiFunction( (props) { return 'foo: ${props.passedProp}'; }, - $FooConfig, // ignore: undefined_identifier + _$FooConfig, // ignore: undefined_identifier ); ``` @@ -823,7 +823,7 @@ UiFactory Foo = uiFunction( (props) { return 'foo: ${props.foo}'; }, - $FooConfig, // ignore: undefined_identifier + _$FooConfig, // ignore: undefined_identifier getPropTypes: (keyFor) => { keyFor((p) => p.foo): (props, info) { if (props.foo == 'bar') { @@ -889,7 +889,7 @@ UiFactory Foo = uiForwardRef( )('Click me!'), ); }, - $FooConfig, // ignore: undefined_identifier + _$FooConfig, // ignore: undefined_identifier ); ``` diff --git a/doc/props_mixin_component_composition.md b/doc/props_mixin_component_composition.md index a9117be74..a55c87ac6 100644 --- a/doc/props_mixin_component_composition.md +++ b/doc/props_mixin_component_composition.md @@ -168,7 +168,7 @@ UiFactory FooBaz = uiFunction( return (Dom.li()..key = bizzle)(bizzle); } }, - $FooBazConfig, // ignore: undefined_identifier + _$FooBazConfig, // ignore: undefined_identifier ); ``` diff --git a/example/builder/src/function_component.dart b/example/builder/src/function_component.dart index ba9affadb..a9d241e53 100644 --- a/example/builder/src/function_component.dart +++ b/example/builder/src/function_component.dart @@ -36,7 +36,7 @@ UiFactory Basic = uiForwardRef( props.basic3, 'children: ${props.children}'), ); }, - $BasicConfig, // ignore: undefined_identifier + _$BasicConfig, // ignore: undefined_identifier ); UiFactory Simple = uiFunction( @@ -52,7 +52,7 @@ UiFactory Simple = uiFunction( (Foo()..content = props.basic2)(), ); }, - $SimpleConfig, // ignore: undefined_identifier + _$SimpleConfig, // ignore: undefined_identifier ); mixin FooProps on UiProps { @@ -61,7 +61,7 @@ mixin FooProps on UiProps { UiFactory Foo = uiFunction( (props) => Dom.div()('forwarded prop: ${props.content}'), - $FooConfig, // ignore: undefined_identifier + _$FooConfig, // ignore: undefined_identifier ); ReactElement functionComponentContent() { diff --git a/example/builder/src/function_component.over_react.g.dart b/example/builder/src/function_component.over_react.g.dart index eaca6bd81..0722e4625 100644 --- a/example/builder/src/function_component.over_react.g.dart +++ b/example/builder/src/function_component.over_react.g.dart @@ -123,20 +123,26 @@ const PropsMeta _$metaForFooProps = PropsMeta( keys: $FooProps.$propKeys, ); -final UiFactoryConfig<_$$BasicProps> $BasicConfig = UiFactoryConfig( +final UiFactoryConfig<_$$BasicProps> _$BasicConfig = UiFactoryConfig( propsFactory: PropsFactory( map: (map) => _$$BasicProps(map), jsMap: (map) => _$$BasicProps$JsMap(map), ), displayName: 'Basic'); -final UiFactoryConfig<_$$BasicProps> $SimpleConfig = UiFactoryConfig( +@Deprecated('Use `_\$BasicConfig` instead.') +final UiFactoryConfig<_$$BasicProps> $BasicConfig = _$BasicConfig; + +final UiFactoryConfig<_$$BasicProps> _$SimpleConfig = UiFactoryConfig( propsFactory: PropsFactory( map: (map) => _$$BasicProps(map), jsMap: (map) => _$$BasicProps$JsMap(map), ), displayName: 'Simple'); +@Deprecated('Use `_\$SimpleConfig` instead.') +final UiFactoryConfig<_$$BasicProps> $SimpleConfig = _$SimpleConfig; + // Concrete props implementation. // // Implements constructor and backing map, and links up to generated component factory. @@ -209,13 +215,16 @@ class _$$BasicProps$JsMap extends _$$BasicProps { JsBackedMap _props; } -final UiFactoryConfig<_$$FooProps> $FooConfig = UiFactoryConfig( +final UiFactoryConfig<_$$FooProps> _$FooConfig = UiFactoryConfig( propsFactory: PropsFactory( map: (map) => _$$FooProps(map), jsMap: (map) => _$$FooProps$JsMap(map), ), displayName: 'Foo'); +@Deprecated('Use `_\$FooConfig` instead.') +final UiFactoryConfig<_$$FooProps> $FooConfig = _$FooConfig; + // Concrete props implementation. // // Implements constructor and backing map, and links up to generated component factory. diff --git a/example/builder/src/functional_consumed_props.dart b/example/builder/src/functional_consumed_props.dart index 5fa937599..fcb2ac455 100644 --- a/example/builder/src/functional_consumed_props.dart +++ b/example/builder/src/functional_consumed_props.dart @@ -39,7 +39,7 @@ UiFactory SomeParent = uiFunction((props) { ) ); }, - $SomeParentConfig, // ignore: undefined_identifier + _$SomeParentConfig, // ignore: undefined_identifier ); class SomeChildProps = UiProps with SharedPropsMixin; @@ -51,5 +51,5 @@ UiFactory SomeChild = uiFunction((props) { ) ); }, - $SomeChildConfig, // ignore: undefined_identifier -); \ No newline at end of file + _$SomeChildConfig, // ignore: undefined_identifier +); diff --git a/example/builder/src/functional_consumed_props.over_react.g.dart b/example/builder/src/functional_consumed_props.over_react.g.dart index 0c83bdeb2..4acc1fd3b 100644 --- a/example/builder/src/functional_consumed_props.over_react.g.dart +++ b/example/builder/src/functional_consumed_props.over_react.g.dart @@ -75,13 +75,17 @@ const PropsMeta _$metaForSharedPropsMixin = PropsMeta( keys: $SharedPropsMixin.$propKeys, ); -final UiFactoryConfig<_$$SomeParentProps> $SomeParentConfig = UiFactoryConfig( +final UiFactoryConfig<_$$SomeParentProps> _$SomeParentConfig = UiFactoryConfig( propsFactory: PropsFactory( map: (map) => _$$SomeParentProps(map), jsMap: (map) => _$$SomeParentProps$JsMap(map), ), displayName: 'SomeParent'); +@Deprecated('Use `_\$SomeParentConfig` instead.') +final UiFactoryConfig<_$$SomeParentProps> $SomeParentConfig = + _$SomeParentConfig; + // Concrete props implementation. // // Implements constructor and backing map, and links up to generated component factory. @@ -159,13 +163,16 @@ class _$$SomeParentProps$JsMap extends _$$SomeParentProps { JsBackedMap _props; } -final UiFactoryConfig<_$$SomeChildProps> $SomeChildConfig = UiFactoryConfig( +final UiFactoryConfig<_$$SomeChildProps> _$SomeChildConfig = UiFactoryConfig( propsFactory: PropsFactory( map: (map) => _$$SomeChildProps(map), jsMap: (map) => _$$SomeChildProps$JsMap(map), ), displayName: 'SomeChild'); +@Deprecated('Use `_\$SomeChildConfig` instead.') +final UiFactoryConfig<_$$SomeChildProps> $SomeChildConfig = _$SomeChildConfig; + // Concrete props implementation. // // Implements constructor and backing map, and links up to generated component factory. diff --git a/example/hooks/use_callback_example.dart b/example/hooks/use_callback_example.dart index 4cbbc2a22..09525eda5 100644 --- a/example/hooks/use_callback_example.dart +++ b/example/hooks/use_callback_example.dart @@ -39,5 +39,5 @@ UiFactory UseCallbackExample = uiFunction( (Dom.button()..onClick = incrementDelta)('Increment delta'), ); }, - $UseCallbackExampleConfig, // ignore: undefined_identifier + _$UseCallbackExampleConfig, // ignore: undefined_identifier ); diff --git a/example/hooks/use_callback_example.over_react.g.dart b/example/hooks/use_callback_example.over_react.g.dart index df21c672a..1f94aa477 100644 --- a/example/hooks/use_callback_example.over_react.g.dart +++ b/example/hooks/use_callback_example.over_react.g.dart @@ -26,7 +26,7 @@ const PropsMeta _$metaForUseCallbackExampleProps = PropsMeta( keys: $UseCallbackExampleProps.$propKeys, ); -final UiFactoryConfig<_$$UseCallbackExampleProps> $UseCallbackExampleConfig = +final UiFactoryConfig<_$$UseCallbackExampleProps> _$UseCallbackExampleConfig = UiFactoryConfig( propsFactory: PropsFactory( map: (map) => _$$UseCallbackExampleProps(map), @@ -34,6 +34,10 @@ final UiFactoryConfig<_$$UseCallbackExampleProps> $UseCallbackExampleConfig = ), displayName: 'UseCallbackExample'); +@Deprecated('Use `_\$UseCallbackExampleConfig` instead.') +final UiFactoryConfig<_$$UseCallbackExampleProps> $UseCallbackExampleConfig = + _$UseCallbackExampleConfig; + // Concrete props implementation. // // Implements constructor and backing map, and links up to generated component factory. diff --git a/example/hooks/use_context_example.dart b/example/hooks/use_context_example.dart index 795d3873c..c03de5765 100644 --- a/example/hooks/use_context_example.dart +++ b/example/hooks/use_context_example.dart @@ -28,7 +28,7 @@ UiFactory UseContextExample = uiFunction( Dom.div()('useContext counter value is ${context['renderCount']}'), ); }, - $UseContextExampleConfig, // ignore: undefined_identifier + _$UseContextExampleConfig, // ignore: undefined_identifier ); mixin NewContextProviderProps on UiProps {} @@ -55,5 +55,5 @@ UiFactory NewContextProvider = uiFunction( (TestNewContext.Provider()..value = provideMap)(props.children), ); }, - $NewContextProviderConfig, // ignore: undefined_identifier + _$NewContextProviderConfig, // ignore: undefined_identifier ); diff --git a/example/hooks/use_context_example.over_react.g.dart b/example/hooks/use_context_example.over_react.g.dart index 0ebb0b1c9..9fd2c2683 100644 --- a/example/hooks/use_context_example.over_react.g.dart +++ b/example/hooks/use_context_example.over_react.g.dart @@ -45,7 +45,7 @@ const PropsMeta _$metaForNewContextProviderProps = PropsMeta( keys: $NewContextProviderProps.$propKeys, ); -final UiFactoryConfig<_$$UseContextExampleProps> $UseContextExampleConfig = +final UiFactoryConfig<_$$UseContextExampleProps> _$UseContextExampleConfig = UiFactoryConfig( propsFactory: PropsFactory( map: (map) => _$$UseContextExampleProps(map), @@ -53,6 +53,10 @@ final UiFactoryConfig<_$$UseContextExampleProps> $UseContextExampleConfig = ), displayName: 'UseContextExample'); +@Deprecated('Use `_\$UseContextExampleConfig` instead.') +final UiFactoryConfig<_$$UseContextExampleProps> $UseContextExampleConfig = + _$UseContextExampleConfig; + // Concrete props implementation. // // Implements constructor and backing map, and links up to generated component factory. @@ -125,7 +129,7 @@ class _$$UseContextExampleProps$JsMap extends _$$UseContextExampleProps { JsBackedMap _props; } -final UiFactoryConfig<_$$NewContextProviderProps> $NewContextProviderConfig = +final UiFactoryConfig<_$$NewContextProviderProps> _$NewContextProviderConfig = UiFactoryConfig( propsFactory: PropsFactory( map: (map) => _$$NewContextProviderProps(map), @@ -133,6 +137,10 @@ final UiFactoryConfig<_$$NewContextProviderProps> $NewContextProviderConfig = ), displayName: 'NewContextProvider'); +@Deprecated('Use `_\$NewContextProviderConfig` instead.') +final UiFactoryConfig<_$$NewContextProviderProps> $NewContextProviderConfig = + _$NewContextProviderConfig; + // Concrete props implementation. // // Implements constructor and backing map, and links up to generated component factory. diff --git a/example/hooks/use_debug_value_example.dart b/example/hooks/use_debug_value_example.dart index fad5949c4..56b0ce7db 100644 --- a/example/hooks/use_debug_value_example.dart +++ b/example/hooks/use_debug_value_example.dart @@ -60,7 +60,7 @@ UiFactory FriendListItem = uiFunction( props.friend['name'], ); }, - $FriendListItemConfig, // ignore: undefined_identifier + _$FriendListItemConfig, // ignore: undefined_identifier ); mixin UseDebugValueExampleProps on UiProps {} @@ -72,5 +72,5 @@ UiFactory UseDebugValueExample = uiFunction( (FriendListItem()..friend = {'id': 3, 'name': 'user 3'})(), (FriendListItem()..friend = {'id': 4, 'name': 'user 4'})(), ), - $UseDebugValueExampleConfig, // ignore: undefined_identifier + _$UseDebugValueExampleConfig, // ignore: undefined_identifier ); diff --git a/example/hooks/use_debug_value_example.over_react.g.dart b/example/hooks/use_debug_value_example.over_react.g.dart index 20ef32e01..914f40c1a 100644 --- a/example/hooks/use_debug_value_example.over_react.g.dart +++ b/example/hooks/use_debug_value_example.over_react.g.dart @@ -58,7 +58,7 @@ const PropsMeta _$metaForUseDebugValueExampleProps = PropsMeta( keys: $UseDebugValueExampleProps.$propKeys, ); -final UiFactoryConfig<_$$FriendListItemProps> $FriendListItemConfig = +final UiFactoryConfig<_$$FriendListItemProps> _$FriendListItemConfig = UiFactoryConfig( propsFactory: PropsFactory( map: (map) => _$$FriendListItemProps(map), @@ -66,6 +66,10 @@ final UiFactoryConfig<_$$FriendListItemProps> $FriendListItemConfig = ), displayName: 'FriendListItem'); +@Deprecated('Use `_\$FriendListItemConfig` instead.') +final UiFactoryConfig<_$$FriendListItemProps> $FriendListItemConfig = + _$FriendListItemConfig; + // Concrete props implementation. // // Implements constructor and backing map, and links up to generated component factory. @@ -139,13 +143,17 @@ class _$$FriendListItemProps$JsMap extends _$$FriendListItemProps { } final UiFactoryConfig<_$$UseDebugValueExampleProps> - $UseDebugValueExampleConfig = UiFactoryConfig( + _$UseDebugValueExampleConfig = UiFactoryConfig( propsFactory: PropsFactory( map: (map) => _$$UseDebugValueExampleProps(map), jsMap: (map) => _$$UseDebugValueExampleProps$JsMap(map), ), displayName: 'UseDebugValueExample'); +@Deprecated('Use `_\$UseDebugValueExampleConfig` instead.') +final UiFactoryConfig<_$$UseDebugValueExampleProps> + $UseDebugValueExampleConfig = _$UseDebugValueExampleConfig; + // Concrete props implementation. // // Implements constructor and backing map, and links up to generated component factory. diff --git a/example/hooks/use_imperative_handle_example.dart b/example/hooks/use_imperative_handle_example.dart index ac2f770e2..23fa8ec6f 100644 --- a/example/hooks/use_imperative_handle_example.dart +++ b/example/hooks/use_imperative_handle_example.dart @@ -49,7 +49,7 @@ UiFactory FancyInput = uiForwardRef( ..onChange = (e) => props.updater(e.target.value) )(); }, - $FancyInputConfig, // ignore: undefined_identifier + _$FancyInputConfig, // ignore: undefined_identifier ); mixin UseImperativeHandleExampleProps on UiProps {} @@ -71,5 +71,5 @@ UiFactory UseImperativeHandleExample = )('Focus Input'), ); }, - $UseImperativeHandleExampleConfig, // ignore: undefined_identifier + _$UseImperativeHandleExampleConfig, // ignore: undefined_identifier ); diff --git a/example/hooks/use_imperative_handle_example.over_react.g.dart b/example/hooks/use_imperative_handle_example.over_react.g.dart index 704ded8e0..9358f8c88 100644 --- a/example/hooks/use_imperative_handle_example.over_react.g.dart +++ b/example/hooks/use_imperative_handle_example.over_react.g.dart @@ -70,13 +70,17 @@ const PropsMeta _$metaForUseImperativeHandleExampleProps = PropsMeta( keys: $UseImperativeHandleExampleProps.$propKeys, ); -final UiFactoryConfig<_$$FancyInputProps> $FancyInputConfig = UiFactoryConfig( +final UiFactoryConfig<_$$FancyInputProps> _$FancyInputConfig = UiFactoryConfig( propsFactory: PropsFactory( map: (map) => _$$FancyInputProps(map), jsMap: (map) => _$$FancyInputProps$JsMap(map), ), displayName: 'FancyInput'); +@Deprecated('Use `_\$FancyInputConfig` instead.') +final UiFactoryConfig<_$$FancyInputProps> $FancyInputConfig = + _$FancyInputConfig; + // Concrete props implementation. // // Implements constructor and backing map, and links up to generated component factory. @@ -150,13 +154,17 @@ class _$$FancyInputProps$JsMap extends _$$FancyInputProps { } final UiFactoryConfig<_$$UseImperativeHandleExampleProps> - $UseImperativeHandleExampleConfig = UiFactoryConfig( + _$UseImperativeHandleExampleConfig = UiFactoryConfig( propsFactory: PropsFactory( map: (map) => _$$UseImperativeHandleExampleProps(map), jsMap: (map) => _$$UseImperativeHandleExampleProps$JsMap(map), ), displayName: 'UseImperativeHandleExample'); +@Deprecated('Use `_\$UseImperativeHandleExampleConfig` instead.') +final UiFactoryConfig<_$$UseImperativeHandleExampleProps> + $UseImperativeHandleExampleConfig = _$UseImperativeHandleExampleConfig; + // Concrete props implementation. // // Implements constructor and backing map, and links up to generated component factory. diff --git a/example/hooks/use_layout_effect_example.dart b/example/hooks/use_layout_effect_example.dart index a61b01961..31f94d0fa 100644 --- a/example/hooks/use_layout_effect_example.dart +++ b/example/hooks/use_layout_effect_example.dart @@ -42,5 +42,5 @@ UiFactory UseLayoutEffectExample = uiFunction( )(), ); }, - $UseLayoutEffectExampleConfig, // ignore: undefined_identifier + _$UseLayoutEffectExampleConfig, // ignore: undefined_identifier ); diff --git a/example/hooks/use_layout_effect_example.over_react.g.dart b/example/hooks/use_layout_effect_example.over_react.g.dart index 571894224..6033a1130 100644 --- a/example/hooks/use_layout_effect_example.over_react.g.dart +++ b/example/hooks/use_layout_effect_example.over_react.g.dart @@ -26,7 +26,7 @@ const PropsMeta _$metaForUseLayoutEffectProps = PropsMeta( keys: $UseLayoutEffectProps.$propKeys, ); -final UiFactoryConfig<_$$UseLayoutEffectProps> $UseLayoutEffectExampleConfig = +final UiFactoryConfig<_$$UseLayoutEffectProps> _$UseLayoutEffectExampleConfig = UiFactoryConfig( propsFactory: PropsFactory( map: (map) => _$$UseLayoutEffectProps(map), @@ -34,6 +34,10 @@ final UiFactoryConfig<_$$UseLayoutEffectProps> $UseLayoutEffectExampleConfig = ), displayName: 'UseLayoutEffectExample'); +@Deprecated('Use `_\$UseLayoutEffectExampleConfig` instead.') +final UiFactoryConfig<_$$UseLayoutEffectProps> $UseLayoutEffectExampleConfig = + _$UseLayoutEffectExampleConfig; + // Concrete props implementation. // // Implements constructor and backing map, and links up to generated component factory. diff --git a/example/hooks/use_memo_example.dart b/example/hooks/use_memo_example.dart index 8f7bd417e..14c502e40 100644 --- a/example/hooks/use_memo_example.dart +++ b/example/hooks/use_memo_example.dart @@ -44,5 +44,5 @@ UiFactory UseMemoExample = uiFunction( )('+'), ); }, - $UseMemoExampleConfig, // ignore: undefined_identifier + _$UseMemoExampleConfig, // ignore: undefined_identifier ); diff --git a/example/hooks/use_memo_example.over_react.g.dart b/example/hooks/use_memo_example.over_react.g.dart index 0db6196b7..605a3b881 100644 --- a/example/hooks/use_memo_example.over_react.g.dart +++ b/example/hooks/use_memo_example.over_react.g.dart @@ -26,7 +26,7 @@ const PropsMeta _$metaForUseMemoExampleProps = PropsMeta( keys: $UseMemoExampleProps.$propKeys, ); -final UiFactoryConfig<_$$UseMemoExampleProps> $UseMemoExampleConfig = +final UiFactoryConfig<_$$UseMemoExampleProps> _$UseMemoExampleConfig = UiFactoryConfig( propsFactory: PropsFactory( map: (map) => _$$UseMemoExampleProps(map), @@ -34,6 +34,10 @@ final UiFactoryConfig<_$$UseMemoExampleProps> $UseMemoExampleConfig = ), displayName: 'UseMemoExample'); +@Deprecated('Use `_\$UseMemoExampleConfig` instead.') +final UiFactoryConfig<_$$UseMemoExampleProps> $UseMemoExampleConfig = + _$UseMemoExampleConfig; + // Concrete props implementation. // // Implements constructor and backing map, and links up to generated component factory. diff --git a/example/hooks/use_reducer_example.dart b/example/hooks/use_reducer_example.dart index 06dd5e275..0c71e2454 100644 --- a/example/hooks/use_reducer_example.dart +++ b/example/hooks/use_reducer_example.dart @@ -59,5 +59,5 @@ UiFactory UseReducerExample = uiFunction( )('reset'), ); }, - $UseReducerExampleConfig, // ignore: undefined_identifier + _$UseReducerExampleConfig, // ignore: undefined_identifier ); diff --git a/example/hooks/use_reducer_example.over_react.g.dart b/example/hooks/use_reducer_example.over_react.g.dart index 19e8098f9..9ce831785 100644 --- a/example/hooks/use_reducer_example.over_react.g.dart +++ b/example/hooks/use_reducer_example.over_react.g.dart @@ -41,7 +41,7 @@ const PropsMeta _$metaForUseReducerExampleProps = PropsMeta( keys: $UseReducerExampleProps.$propKeys, ); -final UiFactoryConfig<_$$UseReducerExampleProps> $UseReducerExampleConfig = +final UiFactoryConfig<_$$UseReducerExampleProps> _$UseReducerExampleConfig = UiFactoryConfig( propsFactory: PropsFactory( map: (map) => _$$UseReducerExampleProps(map), @@ -49,6 +49,10 @@ final UiFactoryConfig<_$$UseReducerExampleProps> $UseReducerExampleConfig = ), displayName: 'UseReducerExample'); +@Deprecated('Use `_\$UseReducerExampleConfig` instead.') +final UiFactoryConfig<_$$UseReducerExampleProps> $UseReducerExampleConfig = + _$UseReducerExampleConfig; + // Concrete props implementation. // // Implements constructor and backing map, and links up to generated component factory. diff --git a/example/hooks/use_ref_example.dart b/example/hooks/use_ref_example.dart index b4ddd3f39..7ae8a9108 100644 --- a/example/hooks/use_ref_example.dart +++ b/example/hooks/use_ref_example.dart @@ -43,5 +43,5 @@ UiFactory UseRefExample = uiFunction( )('Update'), ); }, - $UseRefExampleConfig, // ignore: undefined_identifier + _$UseRefExampleConfig, // ignore: undefined_identifier ); diff --git a/example/hooks/use_ref_example.over_react.g.dart b/example/hooks/use_ref_example.over_react.g.dart index d9617f7d6..4c1884de4 100644 --- a/example/hooks/use_ref_example.over_react.g.dart +++ b/example/hooks/use_ref_example.over_react.g.dart @@ -26,7 +26,7 @@ const PropsMeta _$metaForUseRefExampleProps = PropsMeta( keys: $UseRefExampleProps.$propKeys, ); -final UiFactoryConfig<_$$UseRefExampleProps> $UseRefExampleConfig = +final UiFactoryConfig<_$$UseRefExampleProps> _$UseRefExampleConfig = UiFactoryConfig( propsFactory: PropsFactory( map: (map) => _$$UseRefExampleProps(map), @@ -34,6 +34,10 @@ final UiFactoryConfig<_$$UseRefExampleProps> $UseRefExampleConfig = ), displayName: 'UseRefExample'); +@Deprecated('Use `_\$UseRefExampleConfig` instead.') +final UiFactoryConfig<_$$UseRefExampleProps> $UseRefExampleConfig = + _$UseRefExampleConfig; + // Concrete props implementation. // // Implements constructor and backing map, and links up to generated component factory. diff --git a/example/hooks/use_state_example.dart b/example/hooks/use_state_example.dart index 025627516..8a3e934cf 100644 --- a/example/hooks/use_state_example.dart +++ b/example/hooks/use_state_example.dart @@ -48,5 +48,5 @@ UiFactory UseStateExample = uiFunction( Dom.p()('${count.value} is ${evenOdd.value}'), ); }, - $UseStateExampleConfig, // ignore: undefined_identifier + _$UseStateExampleConfig, // ignore: undefined_identifier ); diff --git a/example/hooks/use_state_example.over_react.g.dart b/example/hooks/use_state_example.over_react.g.dart index 75bfd4008..cfdc350cd 100644 --- a/example/hooks/use_state_example.over_react.g.dart +++ b/example/hooks/use_state_example.over_react.g.dart @@ -26,7 +26,7 @@ const PropsMeta _$metaForUseStateExampleProps = PropsMeta( keys: $UseStateExampleProps.$propKeys, ); -final UiFactoryConfig<_$$UseStateExampleProps> $UseStateExampleConfig = +final UiFactoryConfig<_$$UseStateExampleProps> _$UseStateExampleConfig = UiFactoryConfig( propsFactory: PropsFactory( map: (map) => _$$UseStateExampleProps(map), @@ -34,6 +34,10 @@ final UiFactoryConfig<_$$UseStateExampleProps> $UseStateExampleConfig = ), displayName: 'UseStateExample'); +@Deprecated('Use `_\$UseStateExampleConfig` instead.') +final UiFactoryConfig<_$$UseStateExampleProps> $UseStateExampleConfig = + _$UseStateExampleConfig; + // Concrete props implementation. // // Implements constructor and backing map, and links up to generated component factory. diff --git a/lib/src/component/hooks.dart b/lib/src/component/hooks.dart index 68c20f7c2..e54caa073 100644 --- a/lib/src/component/hooks.dart +++ b/lib/src/component/hooks.dart @@ -34,7 +34,7 @@ import 'package:react/hooks.dart' as react_hooks; /// )('+'), /// ); /// }, -/// $UseStateExampleConfig, // ignore: undefined_identifier +/// _$UseStateExampleConfig, // ignore: undefined_identifier /// ); /// ``` /// @@ -62,7 +62,7 @@ StateHook useState(T initialValue) => react_hooks.useState(initialValue /// )('+'), /// ); /// }, -/// $UseStateExampleConfig, // ignore: undefined_identifier +/// _$UseStateExampleConfig, // ignore: undefined_identifier /// ); /// ``` /// @@ -107,7 +107,7 @@ StateHook useStateLazy(T Function() init) => react_hooks.useStateLazy(i /// )('+'), /// ); /// }, -/// $UseEffectExampleConfig, // ignore: undefined_identifier +/// _$UseEffectExampleConfig, // ignore: undefined_identifier /// ); /// ``` /// @@ -144,7 +144,7 @@ void useEffect(dynamic Function() sideEffect, [List dependencies]) => re /// )('-'), /// ); /// }, -/// $UseReducerExampleConfig, // ignore: undefined_identifier +/// _$UseReducerExampleConfig, // ignore: undefined_identifier /// ); /// ``` /// @@ -200,7 +200,7 @@ ReducerHook useReducer( /// )('reset'), /// ); /// }, -/// $UseReducerExampleConfig, // ignore: undefined_identifier +/// _$UseReducerExampleConfig, // ignore: undefined_identifier /// ); /// ``` /// @@ -239,7 +239,7 @@ ReducerHook useReducerLazy( /// (Dom.button()..onClick = incrementDelta)('Increment delta'), /// ); /// }, -/// $UseCallbackExampleConfig, // ignore: undefined_identifier +/// _$UseCallbackExampleConfig, // ignore: undefined_identifier /// ); /// ``` /// @@ -272,7 +272,7 @@ T useCallback(T callback, List dependencies) => react_hooks. /// ), // initially renders: 'The count from context is 0' /// ); /// }, -/// $UseContextExampleConfig, // ignore: undefined_identifier +/// _$UseContextExampleConfig, // ignore: undefined_identifier /// ); /// ``` /// @@ -316,7 +316,7 @@ T useContext(Context context) => react_hooks.useContext(context.reactDartC /// )('Update'), /// ); /// }, -/// $UseRefExampleConfig, // ignore: undefined_identifier +/// _$UseRefExampleConfig, // ignore: undefined_identifier /// ); /// ``` /// @@ -354,7 +354,7 @@ Ref useRef([T initialValue]) => react_hooks.useRef(initialValue); /// )('+'), /// ); /// }, -/// $UseMemoExampleConfig, // ignore: undefined_identifier +/// _$UseMemoExampleConfig, // ignore: undefined_identifier /// ); /// ``` /// @@ -396,7 +396,7 @@ T useMemo(T Function() createFunction, [List dependencies]) => /// )(), /// ); /// }, -/// $UseLayoutEffectExampleConfig, // ignore: undefined_identifier +/// _$UseLayoutEffectExampleConfig, // ignore: undefined_identifier /// ); /// ``` /// @@ -446,7 +446,7 @@ void useLayoutEffect(dynamic Function() sideEffect, [List dependencies]) /// ..onChange = (e) => props.updater(e.target.value) /// )(); /// }, -/// $FancyInputConfig, // ignore: undefined_identifier +/// _$FancyInputConfig, // ignore: undefined_identifier /// ); /// /// UiFactory UseImperativeHandleExample = uiFunction( @@ -465,7 +465,7 @@ void useLayoutEffect(dynamic Function() sideEffect, [List dependencies]) /// )('Focus Input'), /// ); /// }, -/// $UseImperativeHandleExampleConfig, // ignore: undefined_identifier +/// _$UseImperativeHandleExampleConfig, // ignore: undefined_identifier /// ); /// ``` /// @@ -529,7 +529,7 @@ void useImperativeHandle(dynamic ref, dynamic Function() createHandle, [List UseDebugValueExample = uiFunction( @@ -539,7 +539,7 @@ void useImperativeHandle(dynamic ref, dynamic Function() createHandle, [List Function(UiFactory) forwardRef /// ..className = 'FancyButton' /// )(props.children); /// }, -/// $FancyButtonConfig, // ignore: undefined_identifier +/// _$FancyButtonConfig, // ignore: undefined_identifier /// ); /// ``` /// @@ -275,7 +275,7 @@ UiFactory Function(UiFactory) forwardRef /// ..className = 'FancyButton' /// )(props.children); /// }, -/// $FancyButtonConfig, // ignore: undefined_identifier +/// _$FancyButtonConfig, // ignore: undefined_identifier /// ); /// /// usageExample() { diff --git a/lib/src/component/with_transition.dart b/lib/src/component/with_transition.dart index 9b60d0bf1..3607f2b29 100644 --- a/lib/src/component/with_transition.dart +++ b/lib/src/component/with_transition.dart @@ -82,7 +82,7 @@ part 'with_transition.over_react.g.dart'; /// ) /// ); /// }, -/// $WithTransitionExampleConfig, // ignore: undefined_identifier +/// _$WithTransitionExampleConfig, // ignore: undefined_identifier /// ); /// ``` /// @@ -103,7 +103,7 @@ part 'with_transition.over_react.g.dart'; /// props.children, /// ), /// }, -/// $CustomChildConfig, // ignore: undefined_identifier +/// _$CustomChildConfig, // ignore: undefined_identifier /// ); /// ``` UiFactory WithTransition = _$WithTransition; @@ -148,7 +148,7 @@ mixin WithTransitionPropsMixin on UiProps { /// // The child that has CSS transitions /// ); /// }, - /// $WithTransitionExampleConfig, // ignore: undefined_identifier + /// _$WithTransitionExampleConfig, // ignore: undefined_identifier /// ); /// ``` Map childPropsByPhase; diff --git a/lib/src/component_declaration/function_component.dart b/lib/src/component_declaration/function_component.dart index 621cdc51a..f8a3f9765 100644 --- a/lib/src/component_declaration/function_component.dart +++ b/lib/src/component_declaration/function_component.dart @@ -42,7 +42,7 @@ export 'component_type_checking.dart' /// ); /// }, /// // The generated props config will match the factory name. -/// $FooConfig, // ignore: undefined_identifier +/// _$FooConfig, // ignore: undefined_identifier /// ); /// /// // Multiple function components can be declared with the same props. @@ -53,7 +53,7 @@ export 'component_type_checking.dart' /// ..isDisabled = true /// )(); /// }, -/// $AnotherFooConfig, // ignore: undefined_identifier +/// _$AnotherFooConfig, // ignore: undefined_identifier /// ); /// /// mixin FooProps on UiProps { diff --git a/lib/src/util/memo.dart b/lib/src/util/memo.dart index c0051a2a5..3f866287b 100644 --- a/lib/src/util/memo.dart +++ b/lib/src/util/memo.dart @@ -37,7 +37,7 @@ import 'package:over_react/component_base.dart'; /// (props) { /// // render using props /// }, -/// $MemoExampleConfig, // ignore: undefined_identifier +/// _$MemoExampleConfig, // ignore: undefined_identifier /// )); /// ``` /// @@ -55,7 +55,7 @@ import 'package:over_react/component_base.dart'; /// (props) { /// // render using props /// }, -/// $MemoWithComparisonConfig, // ignore: undefined_identifier +/// _$MemoWithComparisonConfig, // ignore: undefined_identifier /// ), areEqual: (prevProps, nextProps) { /// // Do some custom comparison logic to return a bool based on prevProps / nextProps /// }); diff --git a/test/over_react/component/memo_test.dart b/test/over_react/component/memo_test.dart index 4d9fbc2e7..a787965ae 100644 --- a/test/over_react/component/memo_test.dart +++ b/test/over_react/component/memo_test.dart @@ -34,7 +34,7 @@ UiFactory FunctionCustomProps = uiFunction( return Dom.div()(Dom.div()('prop id: ${props.id}'), Dom.div()('test Prop: ${props.testProp}')); }, - $FunctionCustomPropsConfig, // ignore: undefined_identifier + _$FunctionCustomPropsConfig, // ignore: undefined_identifier ); main() { diff --git a/test/over_react/component/memo_test.over_react.g.dart b/test/over_react/component/memo_test.over_react.g.dart index 69b317a94..7129a53b0 100644 --- a/test/over_react/component/memo_test.over_react.g.dart +++ b/test/over_react/component/memo_test.over_react.g.dart @@ -215,7 +215,7 @@ const PropsMeta _$metaForFunctionCustomPropsProps = PropsMeta( keys: $FunctionCustomPropsProps.$propKeys, ); -final UiFactoryConfig<_$$FunctionCustomPropsProps> $FunctionCustomPropsConfig = +final UiFactoryConfig<_$$FunctionCustomPropsProps> _$FunctionCustomPropsConfig = UiFactoryConfig( propsFactory: PropsFactory( map: (map) => _$$FunctionCustomPropsProps(map), @@ -223,6 +223,10 @@ final UiFactoryConfig<_$$FunctionCustomPropsProps> $FunctionCustomPropsConfig = ), displayName: 'FunctionCustomProps'); +@Deprecated('Use `_\$FunctionCustomPropsConfig` instead.') +final UiFactoryConfig<_$$FunctionCustomPropsProps> $FunctionCustomPropsConfig = + _$FunctionCustomPropsConfig; + // Concrete props implementation. // // Implements constructor and backing map, and links up to generated component factory. diff --git a/test/over_react/component/ref_util_test.dart b/test/over_react/component/ref_util_test.dart index 40349a3ab..5780ba573 100644 --- a/test/over_react/component/ref_util_test.dart +++ b/test/over_react/component/ref_util_test.dart @@ -336,12 +336,12 @@ final BasicUiFunction = uiFunction( (props) { return props.children.isEmpty ? 'basic component' : props.children; }, - $BasicUiFunctionConfig, // ignore: undefined_identifier + _$BasicUiFunctionConfig, // ignore: undefined_identifier ); final TopLevelForwardUiRefFunction = uiForwardRef( (props, ref) { return (BasicUiFunction()..ref = ref)(props.children); }, - $TopLevelForwardUiRefFunctionConfig, // ignore: undefined_identifier + _$TopLevelForwardUiRefFunctionConfig, // ignore: undefined_identifier ); diff --git a/test/over_react/component/ref_util_test.over_react.g.dart b/test/over_react/component/ref_util_test.over_react.g.dart index 0d80f2d2e..085137fba 100644 --- a/test/over_react/component/ref_util_test.over_react.g.dart +++ b/test/over_react/component/ref_util_test.over_react.g.dart @@ -197,7 +197,7 @@ const PropsMeta _$metaForBasicUiFunctionProps = PropsMeta( keys: $BasicUiFunctionProps.$propKeys, ); -final UiFactoryConfig<_$$BasicUiFunctionProps> $BasicUiFunctionConfig = +final UiFactoryConfig<_$$BasicUiFunctionProps> _$BasicUiFunctionConfig = UiFactoryConfig( propsFactory: PropsFactory( map: (map) => _$$BasicUiFunctionProps(map), @@ -205,6 +205,10 @@ final UiFactoryConfig<_$$BasicUiFunctionProps> $BasicUiFunctionConfig = ), displayName: 'BasicUiFunction'); +@Deprecated('Use `_\$BasicUiFunctionConfig` instead.') +final UiFactoryConfig<_$$BasicUiFunctionProps> $BasicUiFunctionConfig = + _$BasicUiFunctionConfig; + // Concrete props implementation. // // Implements constructor and backing map, and links up to generated component factory. @@ -278,13 +282,17 @@ class _$$BasicUiFunctionProps$JsMap extends _$$BasicUiFunctionProps { } final UiFactoryConfig<_$$SecondaryBasicUiFunctionProps> - $TopLevelForwardUiRefFunctionConfig = UiFactoryConfig( + _$TopLevelForwardUiRefFunctionConfig = UiFactoryConfig( propsFactory: PropsFactory( map: (map) => _$$SecondaryBasicUiFunctionProps(map), jsMap: (map) => _$$SecondaryBasicUiFunctionProps$JsMap(map), ), displayName: 'TopLevelForwardUiRefFunction'); +@Deprecated('Use `_\$TopLevelForwardUiRefFunctionConfig` instead.') +final UiFactoryConfig<_$$SecondaryBasicUiFunctionProps> + $TopLevelForwardUiRefFunctionConfig = _$TopLevelForwardUiRefFunctionConfig; + // Concrete props implementation. // // Implements constructor and backing map, and links up to generated component factory. diff --git a/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/function_component_test.over_react.g.dart b/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/function_component_test.over_react.g.dart index d8cd878c8..6e23a1f0c 100644 --- a/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/function_component_test.over_react.g.dart +++ b/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/function_component_test.over_react.g.dart @@ -178,27 +178,36 @@ const PropsMeta _$metaForAThirdPropsMixin = PropsMeta( keys: $AThirdPropsMixin.$propKeys, ); -final UiFactoryConfig<_$$TestProps> $TestConfig = UiFactoryConfig( +final UiFactoryConfig<_$$TestProps> _$TestConfig = UiFactoryConfig( propsFactory: PropsFactory( map: (map) => _$$TestProps(map), jsMap: (map) => _$$TestProps$JsMap(map), ), displayName: 'Test'); -final UiFactoryConfig<_$$TestProps> $NoLHSTestConfig = UiFactoryConfig( +@Deprecated('Use `_\$TestConfig` instead.') +final UiFactoryConfig<_$$TestProps> $TestConfig = _$TestConfig; + +final UiFactoryConfig<_$$TestProps> _$NoLHSTestConfig = UiFactoryConfig( propsFactory: PropsFactory( map: (map) => _$$TestProps(map), jsMap: (map) => _$$TestProps$JsMap(map), ), displayName: 'NoLHSTest'); -final UiFactoryConfig<_$$TestProps> $_TestConfig = UiFactoryConfig( +@Deprecated('Use `_\$NoLHSTestConfig` instead.') +final UiFactoryConfig<_$$TestProps> $NoLHSTestConfig = _$NoLHSTestConfig; + +final UiFactoryConfig<_$$TestProps> _$_TestConfig = UiFactoryConfig( propsFactory: PropsFactory( map: (map) => _$$TestProps(map), jsMap: (map) => _$$TestProps$JsMap(map), ), displayName: '_Test'); +@Deprecated('Use `_\$_TestConfig` instead.') +final UiFactoryConfig<_$$TestProps> $_TestConfig = _$_TestConfig; + // Concrete props implementation. // // Implements constructor and backing map, and links up to generated component factory. diff --git a/web/component2/src/demos/ref.dart b/web/component2/src/demos/ref.dart index 877b54d9e..e0e856a0c 100644 --- a/web/component2/src/demos/ref.dart +++ b/web/component2/src/demos/ref.dart @@ -26,7 +26,7 @@ UiFactory FancyButton = uiForwardRef( ..className = classes.toClassName() )('Click me!'); }, - $FancyButtonConfig, // ignore: undefined_identifier + _$FancyButtonConfig, // ignore: undefined_identifier ); //----------------------------------------------------------------------------// @@ -190,7 +190,7 @@ final Baz = uiFunction( ..ref = props._forwardedRef )(props.children)); }, - $BazConfig, // ignore: undefined_identifier + _$BazConfig, // ignore: undefined_identifier ); // -------------------------------- Demo Display Logic -------------------------------- @@ -261,7 +261,7 @@ UiFactory RefDemoContainer = uiFunction( ), )); }, - $RefDemoContainerConfig, // ignore: undefined_identifier + _$RefDemoContainerConfig, // ignore: undefined_identifier ); void printButtonOuterHtml(Ref buttonRef) { @@ -288,7 +288,7 @@ UiFactory RefDemoSection = uiFunction( ), )); }, - $RefDemoSectionConfig, // ignore: undefined_identifier + _$RefDemoSectionConfig, // ignore: undefined_identifier ); mixin RefDemoHocProps on UiProps { @@ -302,5 +302,5 @@ UiFactory RefDemoHoc = uiFunction( props.children, )); }, - $RefDemoHocConfig, // ignore: undefined_identifier + _$RefDemoHocConfig, // ignore: undefined_identifier ); diff --git a/web/component2/src/demos/ref.over_react.g.dart b/web/component2/src/demos/ref.over_react.g.dart index 86cfaf0d4..2c5b4c644 100644 --- a/web/component2/src/demos/ref.over_react.g.dart +++ b/web/component2/src/demos/ref.over_react.g.dart @@ -550,12 +550,17 @@ const PropsMeta _$metaForRefDemoHocProps = PropsMeta( keys: $RefDemoHocProps.$propKeys, ); -final UiFactoryConfig<_$$FancyButtonProps> $FancyButtonConfig = UiFactoryConfig( - propsFactory: PropsFactory( - map: (map) => _$$FancyButtonProps(map), - jsMap: (map) => _$$FancyButtonProps$JsMap(map), - ), - displayName: 'FancyButton'); +final UiFactoryConfig<_$$FancyButtonProps> _$FancyButtonConfig = + UiFactoryConfig( + propsFactory: PropsFactory( + map: (map) => _$$FancyButtonProps(map), + jsMap: (map) => _$$FancyButtonProps$JsMap(map), + ), + displayName: 'FancyButton'); + +@Deprecated('Use `_\$FancyButtonConfig` instead.') +final UiFactoryConfig<_$$FancyButtonProps> $FancyButtonConfig = + _$FancyButtonConfig; // Concrete props implementation. // @@ -629,13 +634,16 @@ class _$$FancyButtonProps$JsMap extends _$$FancyButtonProps { JsBackedMap _props; } -final UiFactoryConfig<_$$Foo2Props> $Foo2Config = UiFactoryConfig( +final UiFactoryConfig<_$$Foo2Props> _$Foo2Config = UiFactoryConfig( propsFactory: PropsFactory( map: (map) => _$$Foo2Props(map), jsMap: (map) => _$$Foo2Props$JsMap(map), ), displayName: 'Foo2'); +@Deprecated('Use `_\$Foo2Config` instead.') +final UiFactoryConfig<_$$Foo2Props> $Foo2Config = _$Foo2Config; + // Concrete props implementation. // // Implements constructor and backing map, and links up to generated component factory. @@ -713,13 +721,16 @@ class _$$Foo2Props$JsMap extends _$$Foo2Props { JsBackedMap _props; } -final UiFactoryConfig<_$$BazProps> $BazConfig = UiFactoryConfig( +final UiFactoryConfig<_$$BazProps> _$BazConfig = UiFactoryConfig( propsFactory: PropsFactory( map: (map) => _$$BazProps(map), jsMap: (map) => _$$BazProps$JsMap(map), ), displayName: 'Baz'); +@Deprecated('Use `_\$BazConfig` instead.') +final UiFactoryConfig<_$$BazProps> $BazConfig = _$BazConfig; + // Concrete props implementation. // // Implements constructor and backing map, and links up to generated component factory. @@ -792,7 +803,7 @@ class _$$BazProps$JsMap extends _$$BazProps { JsBackedMap _props; } -final UiFactoryConfig<_$$RefDemoProps> $RefDemoContainerConfig = +final UiFactoryConfig<_$$RefDemoProps> _$RefDemoContainerConfig = UiFactoryConfig( propsFactory: PropsFactory( map: (map) => _$$RefDemoProps(map), @@ -800,6 +811,10 @@ final UiFactoryConfig<_$$RefDemoProps> $RefDemoContainerConfig = ), displayName: 'RefDemoContainer'); +@Deprecated('Use `_\$RefDemoContainerConfig` instead.') +final UiFactoryConfig<_$$RefDemoProps> $RefDemoContainerConfig = + _$RefDemoContainerConfig; + // Concrete props implementation. // // Implements constructor and backing map, and links up to generated component factory. @@ -872,7 +887,7 @@ class _$$RefDemoProps$JsMap extends _$$RefDemoProps { JsBackedMap _props; } -final UiFactoryConfig<_$$RefDemoSectionProps> $RefDemoSectionConfig = +final UiFactoryConfig<_$$RefDemoSectionProps> _$RefDemoSectionConfig = UiFactoryConfig( propsFactory: PropsFactory( map: (map) => _$$RefDemoSectionProps(map), @@ -880,6 +895,10 @@ final UiFactoryConfig<_$$RefDemoSectionProps> $RefDemoSectionConfig = ), displayName: 'RefDemoSection'); +@Deprecated('Use `_\$RefDemoSectionConfig` instead.') +final UiFactoryConfig<_$$RefDemoSectionProps> $RefDemoSectionConfig = + _$RefDemoSectionConfig; + // Concrete props implementation. // // Implements constructor and backing map, and links up to generated component factory. @@ -952,13 +971,17 @@ class _$$RefDemoSectionProps$JsMap extends _$$RefDemoSectionProps { JsBackedMap _props; } -final UiFactoryConfig<_$$RefDemoHocProps> $RefDemoHocConfig = UiFactoryConfig( +final UiFactoryConfig<_$$RefDemoHocProps> _$RefDemoHocConfig = UiFactoryConfig( propsFactory: PropsFactory( map: (map) => _$$RefDemoHocProps(map), jsMap: (map) => _$$RefDemoHocProps$JsMap(map), ), displayName: 'RefDemoHoc'); +@Deprecated('Use `_\$RefDemoHocConfig` instead.') +final UiFactoryConfig<_$$RefDemoHocProps> $RefDemoHocConfig = + _$RefDemoHocConfig; + // Concrete props implementation. // // Implements constructor and backing map, and links up to generated component factory. From b49e726f8a37eb228845b61e619475eee0f763a6 Mon Sep 17 00:00:00 2001 From: Sydney Jodon Date: Wed, 9 Dec 2020 15:15:39 -0700 Subject: [PATCH 03/54] Update tests --- .../function_component_test.dart | 31 ++++++++--- test/vm_tests/builder/codegen/names_test.dart | 4 ++ test/vm_tests/builder/codegen_test.dart | 36 ++++++++++--- .../builder/declaration_parsing_test.dart | 54 +++++++++++++------ .../builder/parsing/ast_util_test.dart | 14 +++++ .../builder/parsing/members_test.dart | 20 +++++-- .../builder/parsing/parsing_helpers.dart | 4 +- 7 files changed, 128 insertions(+), 35 deletions(-) diff --git a/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/function_component_test.dart b/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/function_component_test.dart index 95c1c37ce..fafb314be 100644 --- a/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/function_component_test.dart +++ b/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/function_component_test.dart @@ -29,6 +29,10 @@ main() { functionComponentTestHelper(Test); }); + group('with public generated props config (deprecated)', () { + functionComponentTestHelper(TestPublicConfig); + }); + group('with custom PropsFactory', () { functionComponentTestHelper(TestCustom, testId: 'testIdCustom'); }); @@ -316,7 +320,7 @@ UiFactory BasicUiForwardRef = uiForwardRef( ..addProp('data-prop-custom-key-and-namespace-prop', props.customKeyAndNamespaceProp))('rendered content'); }, - $TestConfig, // ignore: undefined_identifier + _$TestConfig, // ignore: undefined_identifier ); UiFactory CustomUiForwardRef = uiForwardRef( @@ -350,7 +354,7 @@ final NoLHSUiForwardRefTest = uiForwardRef( ..addProp('data-prop-custom-key-and-namespace-prop', props.customKeyAndNamespaceProp))('rendered content'); }, - $NoLHSTestConfig, // ignore: undefined_identifier + _$NoLHSTestConfig, // ignore: undefined_identifier ); UiFactory _UiForwardRef = uiForwardRef( @@ -366,7 +370,7 @@ UiFactory _UiForwardRef = uiForwardRef( ..addProp('data-prop-custom-key-and-namespace-prop', props.customKeyAndNamespaceProp))('rendered content'); }, - $_TestConfig, // ignore: undefined_identifier + _$_TestConfig, // ignore: undefined_identifier ); UiFactory Test = uiFunction( @@ -381,7 +385,22 @@ UiFactory Test = uiFunction( ..addProp('data-prop-custom-key-and-namespace-prop', props.customKeyAndNamespaceProp))('rendered content'); }, - $TestConfig, // ignore: undefined_identifier + _$TestConfig, // ignore: undefined_identifier +); + +UiFactory TestPublicConfig = uiFunction( + (props) { + return (Dom.div() + ..addTestId('testId') + ..addProp('data-prop-string-prop', props.stringProp) + ..addProp('data-prop-dynamic-prop', props.dynamicProp) + ..addProp('data-prop-untyped-prop', props.untypedProp) + ..addProp('data-prop-custom-key-prop', props.customKeyProp) + ..addProp('data-prop-custom-namespace-prop', props.customNamespaceProp) + ..addProp('data-prop-custom-key-and-namespace-prop', + props.customKeyAndNamespaceProp))('rendered content'); + }, + $TestConfig, // ignore: undefined_identifier, deprecated_member_use_from_same_package ); UiFactory TestCustom = uiFunction( @@ -413,7 +432,7 @@ final NoLHSTest = uiFunction( ..addProp('data-prop-custom-key-and-namespace-prop', props.customKeyAndNamespaceProp))('rendered content'); }, - $NoLHSTestConfig, // ignore: undefined_identifier + _$NoLHSTestConfig, // ignore: undefined_identifier ); final _Test = uiFunction( @@ -428,7 +447,7 @@ final _Test = uiFunction( ..addProp('data-prop-custom-key-and-namespace-prop', props.customKeyAndNamespaceProp))('rendered content'); }, - $_TestConfig, // ignore: undefined_identifier + _$_TestConfig, // ignore: undefined_identifier ); mixin TestPropsMixin on UiProps { diff --git a/test/vm_tests/builder/codegen/names_test.dart b/test/vm_tests/builder/codegen/names_test.dart index e2a3a83c4..e64bd368a 100644 --- a/test/vm_tests/builder/codegen/names_test.dart +++ b/test/vm_tests/builder/codegen/names_test.dart @@ -28,6 +28,8 @@ main() { test('consumerName', () => expect(names.consumerName, r'Foo')); test('implName', () => expect(names.implName, r'_$Foo')); + test('privateConfigName', () => expect(names.privateConfigName, r'_$FooConfig')); + test('publicConfigName', () => expect(names.publicConfigName, r'$FooConfig')); }); group('prefixed -', () { @@ -37,6 +39,8 @@ main() { test('consumerName', () => expect(names.consumerName, r'foo.Foo')); test('implName', () => expect(names.implName, r'foo._$Foo')); + test('privateConfigName', () => expect(names.privateConfigName, r'_$foo.FooConfig')); + test('publicConfigName', () => expect(names.publicConfigName, r'$foo.FooConfig')); }); }); diff --git a/test/vm_tests/builder/codegen_test.dart b/test/vm_tests/builder/codegen_test.dart index 8609937a8..de50838be 100644 --- a/test/vm_tests/builder/codegen_test.dart +++ b/test/vm_tests/builder/codegen_test.dart @@ -659,11 +659,14 @@ main() { group('and generates props config for function components constructed with', () { String generatedConfig(String propsName, String factoryName) { return 'final UiFactoryConfig<_\$\$$propsName> ' - '\$${factoryName}Config = UiFactoryConfig(\n' + '_\$${factoryName}Config = UiFactoryConfig(\n' 'propsFactory: PropsFactory(\n' 'map: (map) => _\$\$$propsName(map),\n' 'jsMap: (map) => _\$\$$propsName\$JsMap(map),),\n' - 'displayName: \'$factoryName\');\n'; + 'displayName: \'${factoryName}\');\n\n' + '@Deprecated(\'Use `_\\\$${factoryName}Config` instead.\')\n' + 'final UiFactoryConfig<_\$\$$propsName> ' + '\$${factoryName}Config = _\$${factoryName}Config;\n\n'; } String generatedPropsMapsForConfig(String propsName) { @@ -708,21 +711,21 @@ main() { (props) { return Dom.div()(); }, - \$BarConfig, // ignore: undefined_identifier + _\$BarConfig, // ignore: undefined_identifier ); UiFactory Foo = $wrapperFunction( (props) { return Dom.div()(); }, - \$FooConfig, // ignore: undefined_identifier + _\$FooConfig, // ignore: undefined_identifier ); UiFactory Baz = $wrapperFunction( (props) { return Dom.div()(); }, - \$BazConfig, // ignore: undefined_identifier + _\$BazConfig, // ignore: undefined_identifier ); mixin UnusedPropsMixin on UiProps {} @@ -743,7 +746,7 @@ main() { (props) { return Dom.div()(); }, - \$FooConfig, // ignore: undefined_identifier + _\$FooConfig, // ignore: undefined_identifier )); mixin FooPropsMixin on UiProps {} @@ -753,6 +756,23 @@ main() { expect(implGenerator.outputContentsBuffer.toString(), contains(generatedConfig('FooPropsMixin', 'Foo'))); }); + + test('with public generated config', () { + setUpAndGenerate(''' + UiFactory Foo = $wrapperFunction( + (props) { + return Dom.div()(); + }, + \$FooConfig, // ignore: undefined_identifier + ); + + mixin FooProps on UiProps {} + '''); + + expect(implGenerator.outputContentsBuffer.toString(), contains(generatedPropsMapsForConfig('FooProps'))); + + expect(implGenerator.outputContentsBuffer.toString(), contains(generatedConfig('FooProps', 'Foo'))); + }); } group('uiFunction', () { @@ -796,7 +816,7 @@ main() { ..ref = ref )(); }, - $UiForwardRefFooConfig, + _$UiForwardRefFooConfig, ); '''); @@ -843,7 +863,7 @@ main() { (props) { return Dom.div()(); }, - $FooConfig, // ignore: undefined_identifier + _$FooConfig, // ignore: undefined_identifier ); final Baz = uiFunction( diff --git a/test/vm_tests/builder/declaration_parsing_test.dart b/test/vm_tests/builder/declaration_parsing_test.dart index b637c5e2d..112ea01a4 100644 --- a/test/vm_tests/builder/declaration_parsing_test.dart +++ b/test/vm_tests/builder/declaration_parsing_test.dart @@ -1572,14 +1572,14 @@ main() { (props) { return Dom.div()(); }, - \$FooConfig, // ignore: undefined_identifier + _\$FooConfig, // ignore: undefined_identifier ); final Bar = uiFunction( (props) { return Dom.div()(); }, - \$BarConfig, // ignore: undefined_identifier + _\$BarConfig, // ignore: undefined_identifier ); UiFactory Baz = uiFunction( @@ -1621,7 +1621,7 @@ main() { (props) { return Dom.div()(); }, - \$FooConfig, // ignore: undefined_identifier + _\$FooConfig, // ignore: undefined_identifier ); mixin FooPropsMixin on UiProps {} class FooProps = UiProps with FooPropsMixin; @@ -1652,20 +1652,44 @@ main() { expect(declarations, isEmpty); }); + test('with public generated config', () { + setUpAndParse(''' + UiFactory Foo = uiFunction( + (props) { + return Dom.div()(); + }, + \$FooConfig, // ignore: undefined_identifier + ); + + mixin FooPropsMixin on UiProps {} + '''); + + expect(declarations, unorderedEquals([ + isA(), + isA(), + ])); + final decl = declarations.firstWhereType(); + + expect(decl.factories, hasLength(1)); + expect(decl.factories.first.name.name, equals('Foo')); + expect(decl.props.b?.name?.name, 'FooPropsMixin'); + expect(decl.version, Version.v4_mixinBased); + }); + test('wrapped in an hoc', () { setUpAndParse(''' UiFactory Foo = someHOC(uiFunction( (props) { return Dom.div()(); }, - \$FooConfig, // ignore: undefined_identifier + _\$FooConfig, // ignore: undefined_identifier )); final Bar = someHOC(uiFunction( (props) { return Dom.div()(); }, - \$BarConfig, // ignore: undefined_identifier + _\$BarConfig, // ignore: undefined_identifier )); final Foo2 = someHOC(uiFunction( @@ -1708,21 +1732,21 @@ main() { (props) { return Dom.div()(); }, - \$FooConfig, // ignore: undefined_identifier + _\$FooConfig, // ignore: undefined_identifier ); final Bar = uiFunction( (props) { return Dom.div()(); }, - \$BarConfig, // ignore: undefined_identifier + _\$BarConfig, // ignore: undefined_identifier ); UiFactory Baz = uiFunction( (props) { return Dom.div()(); }, - \$BazConfig, // ignore: undefined_identifier + _\$BazConfig, // ignore: undefined_identifier ); mixin FooPropsMixin on UiProps {} @@ -1911,7 +1935,7 @@ main() { (props) { return Dom.div()(); }, - $FooConfig, // ignore: undefined_identifier + _$FooConfig, // ignore: undefined_identifier ); '''); verify(logger.severe(contains(errorFactoryOnly))); @@ -1924,7 +1948,7 @@ main() { (props) { return Dom.div()(); }, - $FooConfig, // ignore: undefined_identifier + _$FooConfig, // ignore: undefined_identifier ); '''); verify(logger.severe(contains(errorFactoryOnly))); @@ -1937,7 +1961,7 @@ main() { (props) { return Dom.div()(); }, - $FooConfig, // ignore: undefined_identifier + _$FooConfig, // ignore: undefined_identifier ); '''); verify(logger.severe(contains(errorFactoryOnly))); @@ -1953,7 +1977,7 @@ main() { (props) { return Dom.div()(); }, - $FooConfig, // ignore: undefined_identifier + _$FooConfig, // ignore: undefined_identifier ); '''); verify(logger.severe(contains(errorFactoryOnly))); @@ -1999,7 +2023,7 @@ main() { verify(logger.severe(contains('Factory variables are stubs for generated code, and must' ' be initialized with an expression containing either' ' the generated factory (_\$Foo) or' - ' the generated factory config (\$FooConfig).'))); + ' the generated factory config (_\$FooConfig).'))); }); test('declared using multiple variables', () { @@ -2024,7 +2048,7 @@ main() { verify(logger.severe(contains('Factory variables are stubs for generated code, and must' ' be initialized with an expression containing either' ' the generated factory (_\$Foo) or' - ' the generated factory config (\$FooConfig).'))); + ' the generated factory config (_\$FooConfig).'))); }); test('private and declared with an invalid initializer', () { @@ -2038,7 +2062,7 @@ main() { verify(logger.severe(contains('Factory variables are stubs for generated code, and must' ' be initialized with an expression containing either' ' the generated factory (_\$_Foo) or' - ' the generated factory config (\$_FooConfig).'))); + ' the generated factory config (_\$_FooConfig).'))); }); }); diff --git a/test/vm_tests/builder/parsing/ast_util_test.dart b/test/vm_tests/builder/parsing/ast_util_test.dart index e41de8440..b5b2d7358 100644 --- a/test/vm_tests/builder/parsing/ast_util_test.dart +++ b/test/vm_tests/builder/parsing/ast_util_test.dart @@ -72,6 +72,13 @@ main() { }); test('hasConfig', () { + expect(InitializerHelperTopLevel(parseAndGetSingleWithType(''' + final Foo = uiFunction( + (props) => Dom.div()(), + _\$FooConfig, // ignore: undefined_identifier + ); + ''')).usesAGeneratedConfig, true); + expect(InitializerHelperTopLevel(parseAndGetSingleWithType(''' final Foo = uiFunction( (props) => Dom.div()(), @@ -86,6 +93,13 @@ main() { ); ''')).usesAGeneratedConfig, false); + expect(InitializerHelperTopLevel(parseAndGetSingleWithType(''' + final Foo = someHOC(uiFunction( + (props) => Dom.div()(), + _\$FooConfig, // ignore: undefined_identifier + )); + ''')).usesAGeneratedConfig, true); + expect(InitializerHelperTopLevel(parseAndGetSingleWithType(''' final Foo = someHOC(uiFunction( (props) => Dom.div()(), diff --git a/test/vm_tests/builder/parsing/members_test.dart b/test/vm_tests/builder/parsing/members_test.dart index a1bcab8c6..68021fe3c 100644 --- a/test/vm_tests/builder/parsing/members_test.dart +++ b/test/vm_tests/builder/parsing/members_test.dart @@ -266,7 +266,7 @@ main() { (props) { return Dom.div()(); }, - $FooConfig, // ignore: undefined_identifier + _$FooConfig, // ignore: undefined_identifier ); '''), VersionConfidences.none()); expect(factory.propsGenericArg?.typeNameWithoutPrefix, 'FooProps'); @@ -278,7 +278,7 @@ main() { (props) { return Dom.div()(); }, - $FooConfig, // ignore: undefined_identifier + _$FooConfig, // ignore: undefined_identifier ); '''), VersionConfidences.none()); expect(factory.propsGenericArg?.typeNameWithoutPrefix, 'FooProps'); @@ -290,7 +290,7 @@ main() { (props) { return Dom.div()(); }, - $FooConfig, // ignore: undefined_identifier + _$FooConfig, // ignore: undefined_identifier ); '''), VersionConfidences.none()); expect(factory.propsGenericArg, isNull); @@ -307,6 +307,18 @@ main() { }); test('returns true for function component factories', () { + final factory = BoilerplateFactory(parseAndGetSingleWithType(r''' + UiFactory Foo = uiFunction( + (props) { + return Dom.div()(); + }, + _$FooConfig, // ignore: undefined_identifier + ); + '''), VersionConfidences.none()); + expect(factory.shouldGenerateConfig, isTrue); + }); + + test('returns true for function component factories with public config', () { final factory = BoilerplateFactory(parseAndGetSingleWithType(r''' UiFactory Foo = uiFunction( (props) { @@ -427,7 +439,7 @@ main() { contains('Factory variables are stubs for generated code, and must' ' be initialized with an expression containing either' ' the generated factory (_\$Foo) or' - ' the generated factory config (\$FooConfig).'), + ' the generated factory config (_\$FooConfig).'), ]); }); }); diff --git a/test/vm_tests/builder/parsing/parsing_helpers.dart b/test/vm_tests/builder/parsing/parsing_helpers.dart index 03be58420..10a378c99 100644 --- a/test/vm_tests/builder/parsing/parsing_helpers.dart +++ b/test/vm_tests/builder/parsing/parsing_helpers.dart @@ -226,12 +226,12 @@ const mockComponentDeclarations = r''' // Function components UiFactory FunctionFoo = uiFunction( (props) => Dom.div()(), - $FunctionFooConfig, // ignore: undefined_identifier + _$FunctionFooConfig, // ignore: undefined_identifier ); final FunctionFoo1 = uiFunction( (props) => Dom.div()(), - $FunctionFoo1Config, // ignore: undefined_identifier + _$FunctionFoo1Config, // ignore: undefined_identifier ); UiFactory<_$FunctionFooProps> FunctionFoo2 = uiFunction( From 8ce88addddd95308d85403900d3dae3e8e4cb8e2 Mon Sep 17 00:00:00 2001 From: Sydney Jodon Date: Thu, 10 Dec 2020 09:26:34 -0700 Subject: [PATCH 04/54] Update deprecation messages --- .../src/function_component.over_react.g.dart | 9 ++++++--- ...functional_consumed_props.over_react.g.dart | 6 ++++-- .../use_callback_example.over_react.g.dart | 3 ++- .../use_context_example.over_react.g.dart | 6 ++++-- .../use_debug_value_example.over_react.g.dart | 6 ++++-- ...imperative_handle_example.over_react.g.dart | 6 ++++-- ...use_layout_effect_example.over_react.g.dart | 3 ++- .../hooks/use_memo_example.over_react.g.dart | 3 ++- .../use_reducer_example.over_react.g.dart | 3 ++- .../hooks/use_ref_example.over_react.g.dart | 3 ++- .../hooks/use_state_example.over_react.g.dart | 3 ++- lib/src/builder/codegen/names.dart | 6 ++++-- .../codegen/typed_map_impl_generator.dart | 3 ++- lib/src/builder/parsing/ast_util.dart | 1 + .../component/memo_test.over_react.g.dart | 3 ++- .../component/ref_util_test.over_react.g.dart | 6 ++++-- .../function_component_test.over_react.g.dart | 9 ++++++--- test/vm_tests/builder/codegen/names_test.dart | 2 ++ test/vm_tests/builder/codegen_test.dart | 2 +- web/component2/src/demos/ref.over_react.g.dart | 18 ++++++++++++------ 20 files changed, 68 insertions(+), 33 deletions(-) diff --git a/example/builder/src/function_component.over_react.g.dart b/example/builder/src/function_component.over_react.g.dart index 0722e4625..276725b11 100644 --- a/example/builder/src/function_component.over_react.g.dart +++ b/example/builder/src/function_component.over_react.g.dart @@ -130,7 +130,8 @@ final UiFactoryConfig<_$$BasicProps> _$BasicConfig = UiFactoryConfig( ), displayName: 'Basic'); -@Deprecated('Use `_\$BasicConfig` instead.') +@Deprecated( + r'This member is incompatible with Dart >2.9.0. Use `_$BasicConfig` instead.') final UiFactoryConfig<_$$BasicProps> $BasicConfig = _$BasicConfig; final UiFactoryConfig<_$$BasicProps> _$SimpleConfig = UiFactoryConfig( @@ -140,7 +141,8 @@ final UiFactoryConfig<_$$BasicProps> _$SimpleConfig = UiFactoryConfig( ), displayName: 'Simple'); -@Deprecated('Use `_\$SimpleConfig` instead.') +@Deprecated( + r'This member is incompatible with Dart >2.9.0. Use `_$SimpleConfig` instead.') final UiFactoryConfig<_$$BasicProps> $SimpleConfig = _$SimpleConfig; // Concrete props implementation. @@ -222,7 +224,8 @@ final UiFactoryConfig<_$$FooProps> _$FooConfig = UiFactoryConfig( ), displayName: 'Foo'); -@Deprecated('Use `_\$FooConfig` instead.') +@Deprecated( + r'This member is incompatible with Dart >2.9.0. Use `_$FooConfig` instead.') final UiFactoryConfig<_$$FooProps> $FooConfig = _$FooConfig; // Concrete props implementation. diff --git a/example/builder/src/functional_consumed_props.over_react.g.dart b/example/builder/src/functional_consumed_props.over_react.g.dart index 4acc1fd3b..55b807d09 100644 --- a/example/builder/src/functional_consumed_props.over_react.g.dart +++ b/example/builder/src/functional_consumed_props.over_react.g.dart @@ -82,7 +82,8 @@ final UiFactoryConfig<_$$SomeParentProps> _$SomeParentConfig = UiFactoryConfig( ), displayName: 'SomeParent'); -@Deprecated('Use `_\$SomeParentConfig` instead.') +@Deprecated( + r'This member is incompatible with Dart >2.9.0. Use `_$SomeParentConfig` instead.') final UiFactoryConfig<_$$SomeParentProps> $SomeParentConfig = _$SomeParentConfig; @@ -170,7 +171,8 @@ final UiFactoryConfig<_$$SomeChildProps> _$SomeChildConfig = UiFactoryConfig( ), displayName: 'SomeChild'); -@Deprecated('Use `_\$SomeChildConfig` instead.') +@Deprecated( + r'This member is incompatible with Dart >2.9.0. Use `_$SomeChildConfig` instead.') final UiFactoryConfig<_$$SomeChildProps> $SomeChildConfig = _$SomeChildConfig; // Concrete props implementation. diff --git a/example/hooks/use_callback_example.over_react.g.dart b/example/hooks/use_callback_example.over_react.g.dart index 1f94aa477..0bac91845 100644 --- a/example/hooks/use_callback_example.over_react.g.dart +++ b/example/hooks/use_callback_example.over_react.g.dart @@ -34,7 +34,8 @@ final UiFactoryConfig<_$$UseCallbackExampleProps> _$UseCallbackExampleConfig = ), displayName: 'UseCallbackExample'); -@Deprecated('Use `_\$UseCallbackExampleConfig` instead.') +@Deprecated( + r'This member is incompatible with Dart >2.9.0. Use `_$UseCallbackExampleConfig` instead.') final UiFactoryConfig<_$$UseCallbackExampleProps> $UseCallbackExampleConfig = _$UseCallbackExampleConfig; diff --git a/example/hooks/use_context_example.over_react.g.dart b/example/hooks/use_context_example.over_react.g.dart index 9fd2c2683..0a1cbf4d2 100644 --- a/example/hooks/use_context_example.over_react.g.dart +++ b/example/hooks/use_context_example.over_react.g.dart @@ -53,7 +53,8 @@ final UiFactoryConfig<_$$UseContextExampleProps> _$UseContextExampleConfig = ), displayName: 'UseContextExample'); -@Deprecated('Use `_\$UseContextExampleConfig` instead.') +@Deprecated( + r'This member is incompatible with Dart >2.9.0. Use `_$UseContextExampleConfig` instead.') final UiFactoryConfig<_$$UseContextExampleProps> $UseContextExampleConfig = _$UseContextExampleConfig; @@ -137,7 +138,8 @@ final UiFactoryConfig<_$$NewContextProviderProps> _$NewContextProviderConfig = ), displayName: 'NewContextProvider'); -@Deprecated('Use `_\$NewContextProviderConfig` instead.') +@Deprecated( + r'This member is incompatible with Dart >2.9.0. Use `_$NewContextProviderConfig` instead.') final UiFactoryConfig<_$$NewContextProviderProps> $NewContextProviderConfig = _$NewContextProviderConfig; diff --git a/example/hooks/use_debug_value_example.over_react.g.dart b/example/hooks/use_debug_value_example.over_react.g.dart index 914f40c1a..fbf7ab0f9 100644 --- a/example/hooks/use_debug_value_example.over_react.g.dart +++ b/example/hooks/use_debug_value_example.over_react.g.dart @@ -66,7 +66,8 @@ final UiFactoryConfig<_$$FriendListItemProps> _$FriendListItemConfig = ), displayName: 'FriendListItem'); -@Deprecated('Use `_\$FriendListItemConfig` instead.') +@Deprecated( + r'This member is incompatible with Dart >2.9.0. Use `_$FriendListItemConfig` instead.') final UiFactoryConfig<_$$FriendListItemProps> $FriendListItemConfig = _$FriendListItemConfig; @@ -150,7 +151,8 @@ final UiFactoryConfig<_$$UseDebugValueExampleProps> ), displayName: 'UseDebugValueExample'); -@Deprecated('Use `_\$UseDebugValueExampleConfig` instead.') +@Deprecated( + r'This member is incompatible with Dart >2.9.0. Use `_$UseDebugValueExampleConfig` instead.') final UiFactoryConfig<_$$UseDebugValueExampleProps> $UseDebugValueExampleConfig = _$UseDebugValueExampleConfig; diff --git a/example/hooks/use_imperative_handle_example.over_react.g.dart b/example/hooks/use_imperative_handle_example.over_react.g.dart index 9358f8c88..0fceca9e9 100644 --- a/example/hooks/use_imperative_handle_example.over_react.g.dart +++ b/example/hooks/use_imperative_handle_example.over_react.g.dart @@ -77,7 +77,8 @@ final UiFactoryConfig<_$$FancyInputProps> _$FancyInputConfig = UiFactoryConfig( ), displayName: 'FancyInput'); -@Deprecated('Use `_\$FancyInputConfig` instead.') +@Deprecated( + r'This member is incompatible with Dart >2.9.0. Use `_$FancyInputConfig` instead.') final UiFactoryConfig<_$$FancyInputProps> $FancyInputConfig = _$FancyInputConfig; @@ -161,7 +162,8 @@ final UiFactoryConfig<_$$UseImperativeHandleExampleProps> ), displayName: 'UseImperativeHandleExample'); -@Deprecated('Use `_\$UseImperativeHandleExampleConfig` instead.') +@Deprecated( + r'This member is incompatible with Dart >2.9.0. Use `_$UseImperativeHandleExampleConfig` instead.') final UiFactoryConfig<_$$UseImperativeHandleExampleProps> $UseImperativeHandleExampleConfig = _$UseImperativeHandleExampleConfig; diff --git a/example/hooks/use_layout_effect_example.over_react.g.dart b/example/hooks/use_layout_effect_example.over_react.g.dart index 6033a1130..e1e2fc81b 100644 --- a/example/hooks/use_layout_effect_example.over_react.g.dart +++ b/example/hooks/use_layout_effect_example.over_react.g.dart @@ -34,7 +34,8 @@ final UiFactoryConfig<_$$UseLayoutEffectProps> _$UseLayoutEffectExampleConfig = ), displayName: 'UseLayoutEffectExample'); -@Deprecated('Use `_\$UseLayoutEffectExampleConfig` instead.') +@Deprecated( + r'This member is incompatible with Dart >2.9.0. Use `_$UseLayoutEffectExampleConfig` instead.') final UiFactoryConfig<_$$UseLayoutEffectProps> $UseLayoutEffectExampleConfig = _$UseLayoutEffectExampleConfig; diff --git a/example/hooks/use_memo_example.over_react.g.dart b/example/hooks/use_memo_example.over_react.g.dart index 605a3b881..22acce4fa 100644 --- a/example/hooks/use_memo_example.over_react.g.dart +++ b/example/hooks/use_memo_example.over_react.g.dart @@ -34,7 +34,8 @@ final UiFactoryConfig<_$$UseMemoExampleProps> _$UseMemoExampleConfig = ), displayName: 'UseMemoExample'); -@Deprecated('Use `_\$UseMemoExampleConfig` instead.') +@Deprecated( + r'This member is incompatible with Dart >2.9.0. Use `_$UseMemoExampleConfig` instead.') final UiFactoryConfig<_$$UseMemoExampleProps> $UseMemoExampleConfig = _$UseMemoExampleConfig; diff --git a/example/hooks/use_reducer_example.over_react.g.dart b/example/hooks/use_reducer_example.over_react.g.dart index 9ce831785..d218457c4 100644 --- a/example/hooks/use_reducer_example.over_react.g.dart +++ b/example/hooks/use_reducer_example.over_react.g.dart @@ -49,7 +49,8 @@ final UiFactoryConfig<_$$UseReducerExampleProps> _$UseReducerExampleConfig = ), displayName: 'UseReducerExample'); -@Deprecated('Use `_\$UseReducerExampleConfig` instead.') +@Deprecated( + r'This member is incompatible with Dart >2.9.0. Use `_$UseReducerExampleConfig` instead.') final UiFactoryConfig<_$$UseReducerExampleProps> $UseReducerExampleConfig = _$UseReducerExampleConfig; diff --git a/example/hooks/use_ref_example.over_react.g.dart b/example/hooks/use_ref_example.over_react.g.dart index 4c1884de4..42daf15ab 100644 --- a/example/hooks/use_ref_example.over_react.g.dart +++ b/example/hooks/use_ref_example.over_react.g.dart @@ -34,7 +34,8 @@ final UiFactoryConfig<_$$UseRefExampleProps> _$UseRefExampleConfig = ), displayName: 'UseRefExample'); -@Deprecated('Use `_\$UseRefExampleConfig` instead.') +@Deprecated( + r'This member is incompatible with Dart >2.9.0. Use `_$UseRefExampleConfig` instead.') final UiFactoryConfig<_$$UseRefExampleProps> $UseRefExampleConfig = _$UseRefExampleConfig; diff --git a/example/hooks/use_state_example.over_react.g.dart b/example/hooks/use_state_example.over_react.g.dart index cfdc350cd..25466010c 100644 --- a/example/hooks/use_state_example.over_react.g.dart +++ b/example/hooks/use_state_example.over_react.g.dart @@ -34,7 +34,8 @@ final UiFactoryConfig<_$$UseStateExampleProps> _$UseStateExampleConfig = ), displayName: 'UseStateExample'); -@Deprecated('Use `_\$UseStateExampleConfig` instead.') +@Deprecated( + r'This member is incompatible with Dart >2.9.0. Use `_$UseStateExampleConfig` instead.') final UiFactoryConfig<_$$UseStateExampleProps> $UseStateExampleConfig = _$UseStateExampleConfig; diff --git a/lib/src/builder/codegen/names.dart b/lib/src/builder/codegen/names.dart index ab3ff70df..eea7eba74 100644 --- a/lib/src/builder/codegen/names.dart +++ b/lib/src/builder/codegen/names.dart @@ -47,12 +47,14 @@ class FactoryNames { /// The name of the private generated function component props config for the factory. /// - /// Example: `$FooConfig - String get privateConfigName => '_$publicConfigName'; + /// Example: `_$FooConfig + String get privateConfigName => '_\$${consumerName}Config'; /// The name of the public generated function component props config for the factory. /// /// Example: `$FooConfig + @Deprecated('The public config is incompatible with Dart >2.9.0 and will be ' + 'removed. Use `privateConfigName` instead.') String get publicConfigName => '\$${consumerName}Config'; } diff --git a/lib/src/builder/codegen/typed_map_impl_generator.dart b/lib/src/builder/codegen/typed_map_impl_generator.dart index 742ee9dd3..bf124c233 100644 --- a/lib/src/builder/codegen/typed_map_impl_generator.dart +++ b/lib/src/builder/codegen/typed_map_impl_generator.dart @@ -395,8 +395,9 @@ class _TypedMapImplGenerator extends TypedMapImplGenerator { 'map: (map) => ${names.implName}(map),\n' 'jsMap: (map) => ${names.jsMapImplName}(map),),\n' 'displayName: \'${factoryName.consumerName}\');\n\n' - '@Deprecated(\'Use `_\\${factoryName.publicConfigName}` instead.\')\n' + '@Deprecated(r\'This member is incompatible with Dart >2.9.0. Use `${factoryName.privateConfigName}` instead.\')\n' 'final UiFactoryConfig<${names.implName}> ' + // ignore: deprecated_member_use_from_same_package '${factoryName.publicConfigName} = ${factoryName.privateConfigName};\n\n'; } diff --git a/lib/src/builder/parsing/ast_util.dart b/lib/src/builder/parsing/ast_util.dart index 39484db11..4331369a0 100644 --- a/lib/src/builder/parsing/ast_util.dart +++ b/lib/src/builder/parsing/ast_util.dart @@ -46,6 +46,7 @@ extension InitializerHelperTopLevel on TopLevelVariableDeclaration { /// Returns whether or not there is a generated config being used. bool get usesAGeneratedConfig { final generatedPrivateConfigName = FactoryNames(firstVariable.name.name).privateConfigName; + // ignore: deprecated_member_use_from_same_package final generatedPublicConfigName = FactoryNames(firstVariable.name.name).publicConfigName; return firstInitializer != null && anyDescendantIdentifiers(firstInitializer, (identifier) { diff --git a/test/over_react/component/memo_test.over_react.g.dart b/test/over_react/component/memo_test.over_react.g.dart index 7129a53b0..6978edb04 100644 --- a/test/over_react/component/memo_test.over_react.g.dart +++ b/test/over_react/component/memo_test.over_react.g.dart @@ -223,7 +223,8 @@ final UiFactoryConfig<_$$FunctionCustomPropsProps> _$FunctionCustomPropsConfig = ), displayName: 'FunctionCustomProps'); -@Deprecated('Use `_\$FunctionCustomPropsConfig` instead.') +@Deprecated( + r'This member is incompatible with Dart >2.9.0. Use `_$FunctionCustomPropsConfig` instead.') final UiFactoryConfig<_$$FunctionCustomPropsProps> $FunctionCustomPropsConfig = _$FunctionCustomPropsConfig; diff --git a/test/over_react/component/ref_util_test.over_react.g.dart b/test/over_react/component/ref_util_test.over_react.g.dart index 085137fba..213b1217b 100644 --- a/test/over_react/component/ref_util_test.over_react.g.dart +++ b/test/over_react/component/ref_util_test.over_react.g.dart @@ -205,7 +205,8 @@ final UiFactoryConfig<_$$BasicUiFunctionProps> _$BasicUiFunctionConfig = ), displayName: 'BasicUiFunction'); -@Deprecated('Use `_\$BasicUiFunctionConfig` instead.') +@Deprecated( + r'This member is incompatible with Dart >2.9.0. Use `_$BasicUiFunctionConfig` instead.') final UiFactoryConfig<_$$BasicUiFunctionProps> $BasicUiFunctionConfig = _$BasicUiFunctionConfig; @@ -289,7 +290,8 @@ final UiFactoryConfig<_$$SecondaryBasicUiFunctionProps> ), displayName: 'TopLevelForwardUiRefFunction'); -@Deprecated('Use `_\$TopLevelForwardUiRefFunctionConfig` instead.') +@Deprecated( + r'This member is incompatible with Dart >2.9.0. Use `_$TopLevelForwardUiRefFunctionConfig` instead.') final UiFactoryConfig<_$$SecondaryBasicUiFunctionProps> $TopLevelForwardUiRefFunctionConfig = _$TopLevelForwardUiRefFunctionConfig; diff --git a/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/function_component_test.over_react.g.dart b/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/function_component_test.over_react.g.dart index 6e23a1f0c..d7c9d16b7 100644 --- a/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/function_component_test.over_react.g.dart +++ b/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/function_component_test.over_react.g.dart @@ -185,7 +185,8 @@ final UiFactoryConfig<_$$TestProps> _$TestConfig = UiFactoryConfig( ), displayName: 'Test'); -@Deprecated('Use `_\$TestConfig` instead.') +@Deprecated( + r'This member is incompatible with Dart >2.9.0. Use `_$TestConfig` instead.') final UiFactoryConfig<_$$TestProps> $TestConfig = _$TestConfig; final UiFactoryConfig<_$$TestProps> _$NoLHSTestConfig = UiFactoryConfig( @@ -195,7 +196,8 @@ final UiFactoryConfig<_$$TestProps> _$NoLHSTestConfig = UiFactoryConfig( ), displayName: 'NoLHSTest'); -@Deprecated('Use `_\$NoLHSTestConfig` instead.') +@Deprecated( + r'This member is incompatible with Dart >2.9.0. Use `_$NoLHSTestConfig` instead.') final UiFactoryConfig<_$$TestProps> $NoLHSTestConfig = _$NoLHSTestConfig; final UiFactoryConfig<_$$TestProps> _$_TestConfig = UiFactoryConfig( @@ -205,7 +207,8 @@ final UiFactoryConfig<_$$TestProps> _$_TestConfig = UiFactoryConfig( ), displayName: '_Test'); -@Deprecated('Use `_\$_TestConfig` instead.') +@Deprecated( + r'This member is incompatible with Dart >2.9.0. Use `_$_TestConfig` instead.') final UiFactoryConfig<_$$TestProps> $_TestConfig = _$_TestConfig; // Concrete props implementation. diff --git a/test/vm_tests/builder/codegen/names_test.dart b/test/vm_tests/builder/codegen/names_test.dart index e64bd368a..fa2813a92 100644 --- a/test/vm_tests/builder/codegen/names_test.dart +++ b/test/vm_tests/builder/codegen/names_test.dart @@ -29,6 +29,7 @@ main() { test('consumerName', () => expect(names.consumerName, r'Foo')); test('implName', () => expect(names.implName, r'_$Foo')); test('privateConfigName', () => expect(names.privateConfigName, r'_$FooConfig')); + // ignore: deprecated_member_use_from_same_package test('publicConfigName', () => expect(names.publicConfigName, r'$FooConfig')); }); @@ -40,6 +41,7 @@ main() { test('consumerName', () => expect(names.consumerName, r'foo.Foo')); test('implName', () => expect(names.implName, r'foo._$Foo')); test('privateConfigName', () => expect(names.privateConfigName, r'_$foo.FooConfig')); + // ignore: deprecated_member_use_from_same_package test('publicConfigName', () => expect(names.publicConfigName, r'$foo.FooConfig')); }); }); diff --git a/test/vm_tests/builder/codegen_test.dart b/test/vm_tests/builder/codegen_test.dart index de50838be..315624ac0 100644 --- a/test/vm_tests/builder/codegen_test.dart +++ b/test/vm_tests/builder/codegen_test.dart @@ -664,7 +664,7 @@ main() { 'map: (map) => _\$\$$propsName(map),\n' 'jsMap: (map) => _\$\$$propsName\$JsMap(map),),\n' 'displayName: \'${factoryName}\');\n\n' - '@Deprecated(\'Use `_\\\$${factoryName}Config` instead.\')\n' + '@Deprecated(r\'This member is incompatible with Dart >2.9.0. Use `_\$${factoryName}Config` instead.\')\n' 'final UiFactoryConfig<_\$\$$propsName> ' '\$${factoryName}Config = _\$${factoryName}Config;\n\n'; } diff --git a/web/component2/src/demos/ref.over_react.g.dart b/web/component2/src/demos/ref.over_react.g.dart index 2c5b4c644..48fe61e09 100644 --- a/web/component2/src/demos/ref.over_react.g.dart +++ b/web/component2/src/demos/ref.over_react.g.dart @@ -558,7 +558,8 @@ final UiFactoryConfig<_$$FancyButtonProps> _$FancyButtonConfig = ), displayName: 'FancyButton'); -@Deprecated('Use `_\$FancyButtonConfig` instead.') +@Deprecated( + r'This member is incompatible with Dart >2.9.0. Use `_$FancyButtonConfig` instead.') final UiFactoryConfig<_$$FancyButtonProps> $FancyButtonConfig = _$FancyButtonConfig; @@ -641,7 +642,8 @@ final UiFactoryConfig<_$$Foo2Props> _$Foo2Config = UiFactoryConfig( ), displayName: 'Foo2'); -@Deprecated('Use `_\$Foo2Config` instead.') +@Deprecated( + r'This member is incompatible with Dart >2.9.0. Use `_$Foo2Config` instead.') final UiFactoryConfig<_$$Foo2Props> $Foo2Config = _$Foo2Config; // Concrete props implementation. @@ -728,7 +730,8 @@ final UiFactoryConfig<_$$BazProps> _$BazConfig = UiFactoryConfig( ), displayName: 'Baz'); -@Deprecated('Use `_\$BazConfig` instead.') +@Deprecated( + r'This member is incompatible with Dart >2.9.0. Use `_$BazConfig` instead.') final UiFactoryConfig<_$$BazProps> $BazConfig = _$BazConfig; // Concrete props implementation. @@ -811,7 +814,8 @@ final UiFactoryConfig<_$$RefDemoProps> _$RefDemoContainerConfig = ), displayName: 'RefDemoContainer'); -@Deprecated('Use `_\$RefDemoContainerConfig` instead.') +@Deprecated( + r'This member is incompatible with Dart >2.9.0. Use `_$RefDemoContainerConfig` instead.') final UiFactoryConfig<_$$RefDemoProps> $RefDemoContainerConfig = _$RefDemoContainerConfig; @@ -895,7 +899,8 @@ final UiFactoryConfig<_$$RefDemoSectionProps> _$RefDemoSectionConfig = ), displayName: 'RefDemoSection'); -@Deprecated('Use `_\$RefDemoSectionConfig` instead.') +@Deprecated( + r'This member is incompatible with Dart >2.9.0. Use `_$RefDemoSectionConfig` instead.') final UiFactoryConfig<_$$RefDemoSectionProps> $RefDemoSectionConfig = _$RefDemoSectionConfig; @@ -978,7 +983,8 @@ final UiFactoryConfig<_$$RefDemoHocProps> _$RefDemoHocConfig = UiFactoryConfig( ), displayName: 'RefDemoHoc'); -@Deprecated('Use `_\$RefDemoHocConfig` instead.') +@Deprecated( + r'This member is incompatible with Dart >2.9.0. Use `_$RefDemoHocConfig` instead.') final UiFactoryConfig<_$$RefDemoHocProps> $RefDemoHocConfig = _$RefDemoHocConfig; From 9107ae8b2c4b1e23fce2826f44f9b8dd96a37778 Mon Sep 17 00:00:00 2001 From: Sydney Jodon Date: Mon, 14 Dec 2020 16:32:06 -0700 Subject: [PATCH 05/54] Update based on feedback --- .../src/function_component.over_react.g.dart | 15 ++++++---- ...unctional_consumed_props.over_react.g.dart | 10 ++++--- .../use_callback_example.over_react.g.dart | 5 ++-- .../use_context_example.over_react.g.dart | 10 ++++--- .../use_debug_value_example.over_react.g.dart | 10 ++++--- ...mperative_handle_example.over_react.g.dart | 9 ++++-- ...se_layout_effect_example.over_react.g.dart | 4 ++- .../hooks/use_memo_example.over_react.g.dart | 5 ++-- .../use_reducer_example.over_react.g.dart | 5 ++-- .../hooks/use_ref_example.over_react.g.dart | 5 ++-- .../hooks/use_state_example.over_react.g.dart | 5 ++-- lib/src/builder/codegen/names.dart | 4 +-- .../codegen/typed_map_impl_generator.dart | 4 ++- .../component/memo_test.over_react.g.dart | 5 ++-- .../component/ref_util_test.over_react.g.dart | 9 ++++-- .../function_component_test.dart | 6 ++-- .../function_component_test.over_react.g.dart | 27 +++++++++++++---- test/vm_tests/builder/codegen/names_test.dart | 4 +-- .../src/demos/ref.over_react.g.dart | 30 +++++++++++-------- 19 files changed, 109 insertions(+), 63 deletions(-) diff --git a/example/builder/src/function_component.over_react.g.dart b/example/builder/src/function_component.over_react.g.dart index 276725b11..d0ca43a25 100644 --- a/example/builder/src/function_component.over_react.g.dart +++ b/example/builder/src/function_component.over_react.g.dart @@ -130,8 +130,9 @@ final UiFactoryConfig<_$$BasicProps> _$BasicConfig = UiFactoryConfig( ), displayName: 'Basic'); -@Deprecated( - r'This member is incompatible with Dart >2.9.0. Use `_$BasicConfig` instead.') +@Deprecated(r'Use the private variable, _$BasicConfig, instead ' + 'and update the `over_react` lower bound to version 4.1.0. ' + 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') final UiFactoryConfig<_$$BasicProps> $BasicConfig = _$BasicConfig; final UiFactoryConfig<_$$BasicProps> _$SimpleConfig = UiFactoryConfig( @@ -141,8 +142,9 @@ final UiFactoryConfig<_$$BasicProps> _$SimpleConfig = UiFactoryConfig( ), displayName: 'Simple'); -@Deprecated( - r'This member is incompatible with Dart >2.9.0. Use `_$SimpleConfig` instead.') +@Deprecated(r'Use the private variable, _$SimpleConfig, instead ' + 'and update the `over_react` lower bound to version 4.1.0. ' + 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') final UiFactoryConfig<_$$BasicProps> $SimpleConfig = _$SimpleConfig; // Concrete props implementation. @@ -224,8 +226,9 @@ final UiFactoryConfig<_$$FooProps> _$FooConfig = UiFactoryConfig( ), displayName: 'Foo'); -@Deprecated( - r'This member is incompatible with Dart >2.9.0. Use `_$FooConfig` instead.') +@Deprecated(r'Use the private variable, _$FooConfig, instead ' + 'and update the `over_react` lower bound to version 4.1.0. ' + 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') final UiFactoryConfig<_$$FooProps> $FooConfig = _$FooConfig; // Concrete props implementation. diff --git a/example/builder/src/functional_consumed_props.over_react.g.dart b/example/builder/src/functional_consumed_props.over_react.g.dart index 55b807d09..20229d2d0 100644 --- a/example/builder/src/functional_consumed_props.over_react.g.dart +++ b/example/builder/src/functional_consumed_props.over_react.g.dart @@ -82,8 +82,9 @@ final UiFactoryConfig<_$$SomeParentProps> _$SomeParentConfig = UiFactoryConfig( ), displayName: 'SomeParent'); -@Deprecated( - r'This member is incompatible with Dart >2.9.0. Use `_$SomeParentConfig` instead.') +@Deprecated(r'Use the private variable, _$SomeParentConfig, instead ' + 'and update the `over_react` lower bound to version 4.1.0. ' + 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') final UiFactoryConfig<_$$SomeParentProps> $SomeParentConfig = _$SomeParentConfig; @@ -171,8 +172,9 @@ final UiFactoryConfig<_$$SomeChildProps> _$SomeChildConfig = UiFactoryConfig( ), displayName: 'SomeChild'); -@Deprecated( - r'This member is incompatible with Dart >2.9.0. Use `_$SomeChildConfig` instead.') +@Deprecated(r'Use the private variable, _$SomeChildConfig, instead ' + 'and update the `over_react` lower bound to version 4.1.0. ' + 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') final UiFactoryConfig<_$$SomeChildProps> $SomeChildConfig = _$SomeChildConfig; // Concrete props implementation. diff --git a/example/hooks/use_callback_example.over_react.g.dart b/example/hooks/use_callback_example.over_react.g.dart index 0bac91845..659814427 100644 --- a/example/hooks/use_callback_example.over_react.g.dart +++ b/example/hooks/use_callback_example.over_react.g.dart @@ -34,8 +34,9 @@ final UiFactoryConfig<_$$UseCallbackExampleProps> _$UseCallbackExampleConfig = ), displayName: 'UseCallbackExample'); -@Deprecated( - r'This member is incompatible with Dart >2.9.0. Use `_$UseCallbackExampleConfig` instead.') +@Deprecated(r'Use the private variable, _$UseCallbackExampleConfig, instead ' + 'and update the `over_react` lower bound to version 4.1.0. ' + 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') final UiFactoryConfig<_$$UseCallbackExampleProps> $UseCallbackExampleConfig = _$UseCallbackExampleConfig; diff --git a/example/hooks/use_context_example.over_react.g.dart b/example/hooks/use_context_example.over_react.g.dart index 0a1cbf4d2..55c567d3c 100644 --- a/example/hooks/use_context_example.over_react.g.dart +++ b/example/hooks/use_context_example.over_react.g.dart @@ -53,8 +53,9 @@ final UiFactoryConfig<_$$UseContextExampleProps> _$UseContextExampleConfig = ), displayName: 'UseContextExample'); -@Deprecated( - r'This member is incompatible with Dart >2.9.0. Use `_$UseContextExampleConfig` instead.') +@Deprecated(r'Use the private variable, _$UseContextExampleConfig, instead ' + 'and update the `over_react` lower bound to version 4.1.0. ' + 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') final UiFactoryConfig<_$$UseContextExampleProps> $UseContextExampleConfig = _$UseContextExampleConfig; @@ -138,8 +139,9 @@ final UiFactoryConfig<_$$NewContextProviderProps> _$NewContextProviderConfig = ), displayName: 'NewContextProvider'); -@Deprecated( - r'This member is incompatible with Dart >2.9.0. Use `_$NewContextProviderConfig` instead.') +@Deprecated(r'Use the private variable, _$NewContextProviderConfig, instead ' + 'and update the `over_react` lower bound to version 4.1.0. ' + 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') final UiFactoryConfig<_$$NewContextProviderProps> $NewContextProviderConfig = _$NewContextProviderConfig; diff --git a/example/hooks/use_debug_value_example.over_react.g.dart b/example/hooks/use_debug_value_example.over_react.g.dart index fbf7ab0f9..2c9d16db5 100644 --- a/example/hooks/use_debug_value_example.over_react.g.dart +++ b/example/hooks/use_debug_value_example.over_react.g.dart @@ -66,8 +66,9 @@ final UiFactoryConfig<_$$FriendListItemProps> _$FriendListItemConfig = ), displayName: 'FriendListItem'); -@Deprecated( - r'This member is incompatible with Dart >2.9.0. Use `_$FriendListItemConfig` instead.') +@Deprecated(r'Use the private variable, _$FriendListItemConfig, instead ' + 'and update the `over_react` lower bound to version 4.1.0. ' + 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') final UiFactoryConfig<_$$FriendListItemProps> $FriendListItemConfig = _$FriendListItemConfig; @@ -151,8 +152,9 @@ final UiFactoryConfig<_$$UseDebugValueExampleProps> ), displayName: 'UseDebugValueExample'); -@Deprecated( - r'This member is incompatible with Dart >2.9.0. Use `_$UseDebugValueExampleConfig` instead.') +@Deprecated(r'Use the private variable, _$UseDebugValueExampleConfig, instead ' + 'and update the `over_react` lower bound to version 4.1.0. ' + 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') final UiFactoryConfig<_$$UseDebugValueExampleProps> $UseDebugValueExampleConfig = _$UseDebugValueExampleConfig; diff --git a/example/hooks/use_imperative_handle_example.over_react.g.dart b/example/hooks/use_imperative_handle_example.over_react.g.dart index 0fceca9e9..a895ad06a 100644 --- a/example/hooks/use_imperative_handle_example.over_react.g.dart +++ b/example/hooks/use_imperative_handle_example.over_react.g.dart @@ -77,8 +77,9 @@ final UiFactoryConfig<_$$FancyInputProps> _$FancyInputConfig = UiFactoryConfig( ), displayName: 'FancyInput'); -@Deprecated( - r'This member is incompatible with Dart >2.9.0. Use `_$FancyInputConfig` instead.') +@Deprecated(r'Use the private variable, _$FancyInputConfig, instead ' + 'and update the `over_react` lower bound to version 4.1.0. ' + 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') final UiFactoryConfig<_$$FancyInputProps> $FancyInputConfig = _$FancyInputConfig; @@ -163,7 +164,9 @@ final UiFactoryConfig<_$$UseImperativeHandleExampleProps> displayName: 'UseImperativeHandleExample'); @Deprecated( - r'This member is incompatible with Dart >2.9.0. Use `_$UseImperativeHandleExampleConfig` instead.') + r'Use the private variable, _$UseImperativeHandleExampleConfig, instead ' + 'and update the `over_react` lower bound to version 4.1.0. ' + 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') final UiFactoryConfig<_$$UseImperativeHandleExampleProps> $UseImperativeHandleExampleConfig = _$UseImperativeHandleExampleConfig; diff --git a/example/hooks/use_layout_effect_example.over_react.g.dart b/example/hooks/use_layout_effect_example.over_react.g.dart index e1e2fc81b..6fdae10a2 100644 --- a/example/hooks/use_layout_effect_example.over_react.g.dart +++ b/example/hooks/use_layout_effect_example.over_react.g.dart @@ -35,7 +35,9 @@ final UiFactoryConfig<_$$UseLayoutEffectProps> _$UseLayoutEffectExampleConfig = displayName: 'UseLayoutEffectExample'); @Deprecated( - r'This member is incompatible with Dart >2.9.0. Use `_$UseLayoutEffectExampleConfig` instead.') + r'Use the private variable, _$UseLayoutEffectExampleConfig, instead ' + 'and update the `over_react` lower bound to version 4.1.0. ' + 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') final UiFactoryConfig<_$$UseLayoutEffectProps> $UseLayoutEffectExampleConfig = _$UseLayoutEffectExampleConfig; diff --git a/example/hooks/use_memo_example.over_react.g.dart b/example/hooks/use_memo_example.over_react.g.dart index 22acce4fa..4d788124f 100644 --- a/example/hooks/use_memo_example.over_react.g.dart +++ b/example/hooks/use_memo_example.over_react.g.dart @@ -34,8 +34,9 @@ final UiFactoryConfig<_$$UseMemoExampleProps> _$UseMemoExampleConfig = ), displayName: 'UseMemoExample'); -@Deprecated( - r'This member is incompatible with Dart >2.9.0. Use `_$UseMemoExampleConfig` instead.') +@Deprecated(r'Use the private variable, _$UseMemoExampleConfig, instead ' + 'and update the `over_react` lower bound to version 4.1.0. ' + 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') final UiFactoryConfig<_$$UseMemoExampleProps> $UseMemoExampleConfig = _$UseMemoExampleConfig; diff --git a/example/hooks/use_reducer_example.over_react.g.dart b/example/hooks/use_reducer_example.over_react.g.dart index d218457c4..2e3c0c66d 100644 --- a/example/hooks/use_reducer_example.over_react.g.dart +++ b/example/hooks/use_reducer_example.over_react.g.dart @@ -49,8 +49,9 @@ final UiFactoryConfig<_$$UseReducerExampleProps> _$UseReducerExampleConfig = ), displayName: 'UseReducerExample'); -@Deprecated( - r'This member is incompatible with Dart >2.9.0. Use `_$UseReducerExampleConfig` instead.') +@Deprecated(r'Use the private variable, _$UseReducerExampleConfig, instead ' + 'and update the `over_react` lower bound to version 4.1.0. ' + 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') final UiFactoryConfig<_$$UseReducerExampleProps> $UseReducerExampleConfig = _$UseReducerExampleConfig; diff --git a/example/hooks/use_ref_example.over_react.g.dart b/example/hooks/use_ref_example.over_react.g.dart index 42daf15ab..a28db4854 100644 --- a/example/hooks/use_ref_example.over_react.g.dart +++ b/example/hooks/use_ref_example.over_react.g.dart @@ -34,8 +34,9 @@ final UiFactoryConfig<_$$UseRefExampleProps> _$UseRefExampleConfig = ), displayName: 'UseRefExample'); -@Deprecated( - r'This member is incompatible with Dart >2.9.0. Use `_$UseRefExampleConfig` instead.') +@Deprecated(r'Use the private variable, _$UseRefExampleConfig, instead ' + 'and update the `over_react` lower bound to version 4.1.0. ' + 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') final UiFactoryConfig<_$$UseRefExampleProps> $UseRefExampleConfig = _$UseRefExampleConfig; diff --git a/example/hooks/use_state_example.over_react.g.dart b/example/hooks/use_state_example.over_react.g.dart index 25466010c..58d173b67 100644 --- a/example/hooks/use_state_example.over_react.g.dart +++ b/example/hooks/use_state_example.over_react.g.dart @@ -34,8 +34,9 @@ final UiFactoryConfig<_$$UseStateExampleProps> _$UseStateExampleConfig = ), displayName: 'UseStateExample'); -@Deprecated( - r'This member is incompatible with Dart >2.9.0. Use `_$UseStateExampleConfig` instead.') +@Deprecated(r'Use the private variable, _$UseStateExampleConfig, instead ' + 'and update the `over_react` lower bound to version 4.1.0. ' + 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') final UiFactoryConfig<_$$UseStateExampleProps> $UseStateExampleConfig = _$UseStateExampleConfig; diff --git a/lib/src/builder/codegen/names.dart b/lib/src/builder/codegen/names.dart index eea7eba74..9323ac72c 100644 --- a/lib/src/builder/codegen/names.dart +++ b/lib/src/builder/codegen/names.dart @@ -48,14 +48,14 @@ class FactoryNames { /// The name of the private generated function component props config for the factory. /// /// Example: `_$FooConfig - String get privateConfigName => '_\$${consumerName}Config'; + String get privateConfigName => '$_prefix$privateSourcePrefix${unprefixedConsumerName}Config'; /// The name of the public generated function component props config for the factory. /// /// Example: `$FooConfig @Deprecated('The public config is incompatible with Dart >2.9.0 and will be ' 'removed. Use `privateConfigName` instead.') - String get publicConfigName => '\$${consumerName}Config'; + String get publicConfigName => '$_prefix$publicGeneratedPrefix${unprefixedConsumerName}Config'; } /// A set of names of the different generated members for a given component class. diff --git a/lib/src/builder/codegen/typed_map_impl_generator.dart b/lib/src/builder/codegen/typed_map_impl_generator.dart index bf124c233..54c00138f 100644 --- a/lib/src/builder/codegen/typed_map_impl_generator.dart +++ b/lib/src/builder/codegen/typed_map_impl_generator.dart @@ -395,7 +395,9 @@ class _TypedMapImplGenerator extends TypedMapImplGenerator { 'map: (map) => ${names.implName}(map),\n' 'jsMap: (map) => ${names.jsMapImplName}(map),),\n' 'displayName: \'${factoryName.consumerName}\');\n\n' - '@Deprecated(r\'This member is incompatible with Dart >2.9.0. Use `${factoryName.privateConfigName}` instead.\')\n' + '@Deprecated(r\'Use the private variable, ${factoryName.privateConfigName}, instead \'\n' + '\'and update the `over_react` lower bound to version 4.1.0. \'\n' + '\'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650\')\n' 'final UiFactoryConfig<${names.implName}> ' // ignore: deprecated_member_use_from_same_package '${factoryName.publicConfigName} = ${factoryName.privateConfigName};\n\n'; diff --git a/test/over_react/component/memo_test.over_react.g.dart b/test/over_react/component/memo_test.over_react.g.dart index 6978edb04..25ba3d1da 100644 --- a/test/over_react/component/memo_test.over_react.g.dart +++ b/test/over_react/component/memo_test.over_react.g.dart @@ -223,8 +223,9 @@ final UiFactoryConfig<_$$FunctionCustomPropsProps> _$FunctionCustomPropsConfig = ), displayName: 'FunctionCustomProps'); -@Deprecated( - r'This member is incompatible with Dart >2.9.0. Use `_$FunctionCustomPropsConfig` instead.') +@Deprecated(r'Use the private variable, _$FunctionCustomPropsConfig, instead ' + 'and update the `over_react` lower bound to version 4.1.0. ' + 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') final UiFactoryConfig<_$$FunctionCustomPropsProps> $FunctionCustomPropsConfig = _$FunctionCustomPropsConfig; diff --git a/test/over_react/component/ref_util_test.over_react.g.dart b/test/over_react/component/ref_util_test.over_react.g.dart index 213b1217b..52dba2c53 100644 --- a/test/over_react/component/ref_util_test.over_react.g.dart +++ b/test/over_react/component/ref_util_test.over_react.g.dart @@ -205,8 +205,9 @@ final UiFactoryConfig<_$$BasicUiFunctionProps> _$BasicUiFunctionConfig = ), displayName: 'BasicUiFunction'); -@Deprecated( - r'This member is incompatible with Dart >2.9.0. Use `_$BasicUiFunctionConfig` instead.') +@Deprecated(r'Use the private variable, _$BasicUiFunctionConfig, instead ' + 'and update the `over_react` lower bound to version 4.1.0. ' + 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') final UiFactoryConfig<_$$BasicUiFunctionProps> $BasicUiFunctionConfig = _$BasicUiFunctionConfig; @@ -291,7 +292,9 @@ final UiFactoryConfig<_$$SecondaryBasicUiFunctionProps> displayName: 'TopLevelForwardUiRefFunction'); @Deprecated( - r'This member is incompatible with Dart >2.9.0. Use `_$TopLevelForwardUiRefFunctionConfig` instead.') + r'Use the private variable, _$TopLevelForwardUiRefFunctionConfig, instead ' + 'and update the `over_react` lower bound to version 4.1.0. ' + 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') final UiFactoryConfig<_$$SecondaryBasicUiFunctionProps> $TopLevelForwardUiRefFunctionConfig = _$TopLevelForwardUiRefFunctionConfig; diff --git a/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/function_component_test.dart b/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/function_component_test.dart index fafb314be..3817895fd 100644 --- a/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/function_component_test.dart +++ b/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/function_component_test.dart @@ -30,7 +30,7 @@ main() { }); group('with public generated props config (deprecated)', () { - functionComponentTestHelper(TestPublicConfig); + functionComponentTestHelper(TestPublic); }); group('with custom PropsFactory', () { @@ -388,7 +388,7 @@ UiFactory Test = uiFunction( _$TestConfig, // ignore: undefined_identifier ); -UiFactory TestPublicConfig = uiFunction( +UiFactory TestPublic = uiFunction( (props) { return (Dom.div() ..addTestId('testId') @@ -400,7 +400,7 @@ UiFactory TestPublicConfig = uiFunction( ..addProp('data-prop-custom-key-and-namespace-prop', props.customKeyAndNamespaceProp))('rendered content'); }, - $TestConfig, // ignore: undefined_identifier, deprecated_member_use_from_same_package + $TestPublicConfig, // ignore: undefined_identifier, deprecated_member_use_from_same_package ); UiFactory TestCustom = uiFunction( diff --git a/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/function_component_test.over_react.g.dart b/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/function_component_test.over_react.g.dart index d7c9d16b7..597ee8447 100644 --- a/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/function_component_test.over_react.g.dart +++ b/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/function_component_test.over_react.g.dart @@ -185,10 +185,23 @@ final UiFactoryConfig<_$$TestProps> _$TestConfig = UiFactoryConfig( ), displayName: 'Test'); -@Deprecated( - r'This member is incompatible with Dart >2.9.0. Use `_$TestConfig` instead.') +@Deprecated(r'Use the private variable, _$TestConfig, instead ' + 'and update the `over_react` lower bound to version 4.1.0. ' + 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') final UiFactoryConfig<_$$TestProps> $TestConfig = _$TestConfig; +final UiFactoryConfig<_$$TestProps> _$TestPublicConfig = UiFactoryConfig( + propsFactory: PropsFactory( + map: (map) => _$$TestProps(map), + jsMap: (map) => _$$TestProps$JsMap(map), + ), + displayName: 'TestPublic'); + +@Deprecated(r'Use the private variable, _$TestPublicConfig, instead ' + 'and update the `over_react` lower bound to version 4.1.0. ' + 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') +final UiFactoryConfig<_$$TestProps> $TestPublicConfig = _$TestPublicConfig; + final UiFactoryConfig<_$$TestProps> _$NoLHSTestConfig = UiFactoryConfig( propsFactory: PropsFactory( map: (map) => _$$TestProps(map), @@ -196,8 +209,9 @@ final UiFactoryConfig<_$$TestProps> _$NoLHSTestConfig = UiFactoryConfig( ), displayName: 'NoLHSTest'); -@Deprecated( - r'This member is incompatible with Dart >2.9.0. Use `_$NoLHSTestConfig` instead.') +@Deprecated(r'Use the private variable, _$NoLHSTestConfig, instead ' + 'and update the `over_react` lower bound to version 4.1.0. ' + 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') final UiFactoryConfig<_$$TestProps> $NoLHSTestConfig = _$NoLHSTestConfig; final UiFactoryConfig<_$$TestProps> _$_TestConfig = UiFactoryConfig( @@ -207,8 +221,9 @@ final UiFactoryConfig<_$$TestProps> _$_TestConfig = UiFactoryConfig( ), displayName: '_Test'); -@Deprecated( - r'This member is incompatible with Dart >2.9.0. Use `_$_TestConfig` instead.') +@Deprecated(r'Use the private variable, _$_TestConfig, instead ' + 'and update the `over_react` lower bound to version 4.1.0. ' + 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') final UiFactoryConfig<_$$TestProps> $_TestConfig = _$_TestConfig; // Concrete props implementation. diff --git a/test/vm_tests/builder/codegen/names_test.dart b/test/vm_tests/builder/codegen/names_test.dart index fa2813a92..8f9272ed2 100644 --- a/test/vm_tests/builder/codegen/names_test.dart +++ b/test/vm_tests/builder/codegen/names_test.dart @@ -40,9 +40,9 @@ main() { test('consumerName', () => expect(names.consumerName, r'foo.Foo')); test('implName', () => expect(names.implName, r'foo._$Foo')); - test('privateConfigName', () => expect(names.privateConfigName, r'_$foo.FooConfig')); + test('privateConfigName', () => expect(names.privateConfigName, r'foo._$FooConfig')); // ignore: deprecated_member_use_from_same_package - test('publicConfigName', () => expect(names.publicConfigName, r'$foo.FooConfig')); + test('publicConfigName', () => expect(names.publicConfigName, r'foo.$FooConfig')); }); }); diff --git a/web/component2/src/demos/ref.over_react.g.dart b/web/component2/src/demos/ref.over_react.g.dart index 48fe61e09..29553684b 100644 --- a/web/component2/src/demos/ref.over_react.g.dart +++ b/web/component2/src/demos/ref.over_react.g.dart @@ -558,8 +558,9 @@ final UiFactoryConfig<_$$FancyButtonProps> _$FancyButtonConfig = ), displayName: 'FancyButton'); -@Deprecated( - r'This member is incompatible with Dart >2.9.0. Use `_$FancyButtonConfig` instead.') +@Deprecated(r'Use the private variable, _$FancyButtonConfig, instead ' + 'and update the `over_react` lower bound to version 4.1.0. ' + 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') final UiFactoryConfig<_$$FancyButtonProps> $FancyButtonConfig = _$FancyButtonConfig; @@ -642,8 +643,9 @@ final UiFactoryConfig<_$$Foo2Props> _$Foo2Config = UiFactoryConfig( ), displayName: 'Foo2'); -@Deprecated( - r'This member is incompatible with Dart >2.9.0. Use `_$Foo2Config` instead.') +@Deprecated(r'Use the private variable, _$Foo2Config, instead ' + 'and update the `over_react` lower bound to version 4.1.0. ' + 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') final UiFactoryConfig<_$$Foo2Props> $Foo2Config = _$Foo2Config; // Concrete props implementation. @@ -730,8 +732,9 @@ final UiFactoryConfig<_$$BazProps> _$BazConfig = UiFactoryConfig( ), displayName: 'Baz'); -@Deprecated( - r'This member is incompatible with Dart >2.9.0. Use `_$BazConfig` instead.') +@Deprecated(r'Use the private variable, _$BazConfig, instead ' + 'and update the `over_react` lower bound to version 4.1.0. ' + 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') final UiFactoryConfig<_$$BazProps> $BazConfig = _$BazConfig; // Concrete props implementation. @@ -814,8 +817,9 @@ final UiFactoryConfig<_$$RefDemoProps> _$RefDemoContainerConfig = ), displayName: 'RefDemoContainer'); -@Deprecated( - r'This member is incompatible with Dart >2.9.0. Use `_$RefDemoContainerConfig` instead.') +@Deprecated(r'Use the private variable, _$RefDemoContainerConfig, instead ' + 'and update the `over_react` lower bound to version 4.1.0. ' + 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') final UiFactoryConfig<_$$RefDemoProps> $RefDemoContainerConfig = _$RefDemoContainerConfig; @@ -899,8 +903,9 @@ final UiFactoryConfig<_$$RefDemoSectionProps> _$RefDemoSectionConfig = ), displayName: 'RefDemoSection'); -@Deprecated( - r'This member is incompatible with Dart >2.9.0. Use `_$RefDemoSectionConfig` instead.') +@Deprecated(r'Use the private variable, _$RefDemoSectionConfig, instead ' + 'and update the `over_react` lower bound to version 4.1.0. ' + 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') final UiFactoryConfig<_$$RefDemoSectionProps> $RefDemoSectionConfig = _$RefDemoSectionConfig; @@ -983,8 +988,9 @@ final UiFactoryConfig<_$$RefDemoHocProps> _$RefDemoHocConfig = UiFactoryConfig( ), displayName: 'RefDemoHoc'); -@Deprecated( - r'This member is incompatible with Dart >2.9.0. Use `_$RefDemoHocConfig` instead.') +@Deprecated(r'Use the private variable, _$RefDemoHocConfig, instead ' + 'and update the `over_react` lower bound to version 4.1.0. ' + 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') final UiFactoryConfig<_$$RefDemoHocProps> $RefDemoHocConfig = _$RefDemoHocConfig; From 62fef7f676033f48d60ed3632d9fcf06c4121bae Mon Sep 17 00:00:00 2001 From: Sydney Jodon Date: Wed, 6 Jan 2021 13:44:39 -0700 Subject: [PATCH 06/54] Fix failing tests --- lib/src/builder/codegen/names.dart | 3 +-- test/vm_tests/builder/codegen_test.dart | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/src/builder/codegen/names.dart b/lib/src/builder/codegen/names.dart index 9323ac72c..cda549a0b 100644 --- a/lib/src/builder/codegen/names.dart +++ b/lib/src/builder/codegen/names.dart @@ -53,8 +53,7 @@ class FactoryNames { /// The name of the public generated function component props config for the factory. /// /// Example: `$FooConfig - @Deprecated('The public config is incompatible with Dart >2.9.0 and will be ' - 'removed. Use `privateConfigName` instead.') + @Deprecated('The public config is deprecated and will be removed. Use `privateConfigName` instead.') String get publicConfigName => '$_prefix$publicGeneratedPrefix${unprefixedConsumerName}Config'; } diff --git a/test/vm_tests/builder/codegen_test.dart b/test/vm_tests/builder/codegen_test.dart index 315624ac0..b1c3a4449 100644 --- a/test/vm_tests/builder/codegen_test.dart +++ b/test/vm_tests/builder/codegen_test.dart @@ -663,8 +663,10 @@ main() { 'propsFactory: PropsFactory(\n' 'map: (map) => _\$\$$propsName(map),\n' 'jsMap: (map) => _\$\$$propsName\$JsMap(map),),\n' - 'displayName: \'${factoryName}\');\n\n' - '@Deprecated(r\'This member is incompatible with Dart >2.9.0. Use `_\$${factoryName}Config` instead.\')\n' + 'displayName: \'$factoryName\');\n\n' + '@Deprecated(r\'Use the private variable, _\$${factoryName}Config, instead \'\n' + '\'and update the `over_react` lower bound to version 4.1.0. \'\n' + '\'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650\')\n' 'final UiFactoryConfig<_\$\$$propsName> ' '\$${factoryName}Config = _\$${factoryName}Config;\n\n'; } From 325c55cc6af97deb459577542d97e82bbe11a574 Mon Sep 17 00:00:00 2001 From: Sydney Jodon Date: Wed, 6 Jan 2021 15:08:13 -0700 Subject: [PATCH 07/54] Format --- lib/src/builder/codegen/names.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/src/builder/codegen/names.dart b/lib/src/builder/codegen/names.dart index cda549a0b..419b3fb94 100644 --- a/lib/src/builder/codegen/names.dart +++ b/lib/src/builder/codegen/names.dart @@ -53,7 +53,8 @@ class FactoryNames { /// The name of the public generated function component props config for the factory. /// /// Example: `$FooConfig - @Deprecated('The public config is deprecated and will be removed. Use `privateConfigName` instead.') + @Deprecated( + 'The public config is deprecated and will be removed. Use `privateConfigName` instead.') String get publicConfigName => '$_prefix$publicGeneratedPrefix${unprefixedConsumerName}Config'; } From ca02e12424e111fe26036a6384f8e93b98e8f86f Mon Sep 17 00:00:00 2001 From: Joe Bingham Date: Wed, 13 Jan 2021 14:50:28 -0700 Subject: [PATCH 08/54] Add castUiFactory utility --- lib/over_react.dart | 1 + lib/src/util/cast_ui_factory.dart | 20 +++ .../over_react/util/cast_ui_factory_test.dart | 52 ++++++ .../cast_ui_factory_test.over_react.g.dart | 170 ++++++++++++++++++ 4 files changed, 243 insertions(+) create mode 100644 lib/src/util/cast_ui_factory.dart create mode 100644 test/over_react/util/cast_ui_factory_test.dart create mode 100644 test/over_react/util/cast_ui_factory_test.over_react.g.dart diff --git a/lib/over_react.dart b/lib/over_react.dart index 364dcd5b1..712d1bd36 100644 --- a/lib/over_react.dart +++ b/lib/over_react.dart @@ -114,3 +114,4 @@ export 'src/util/test_mode.dart'; export 'src/util/typed_default_props_for.dart'; export 'src/util/validation_util.dart'; export 'src/util/context.dart'; +export 'src/util/cast_ui_factory.dart'; diff --git a/lib/src/util/cast_ui_factory.dart b/lib/src/util/cast_ui_factory.dart new file mode 100644 index 000000000..1824168d6 --- /dev/null +++ b/lib/src/util/cast_ui_factory.dart @@ -0,0 +1,20 @@ +import 'package:over_react/component_base.dart'; + +/// Casts [value] to `UiFactory`, which can be inferred from the surrounding context, +/// allowing you to perform casts of dynamic values without having to repeat the type. +/// +/// Example: +/// +/// ```dart +/// UiFactory Foo = castUiFactory(_$Foo); +/// ``` +/// +/// This is necessary because ungenerated members (identifiable by the `_$` prefix) +/// are considered dynamic. This requires a cast on the right hand side. However, +/// due to complications around formatting and "ignore" comments, in order to prevent +/// false positive lints or errors, there are limitations around using an explicit +/// cast (i.e. `_$Foo as UiFactory`). +/// +/// This works around those limitations by reducing the amount of code necessary +/// to cast the generated factory. +T castUiFactory(dynamic value) => value as T; diff --git a/test/over_react/util/cast_ui_factory_test.dart b/test/over_react/util/cast_ui_factory_test.dart new file mode 100644 index 000000000..502224f0b --- /dev/null +++ b/test/over_react/util/cast_ui_factory_test.dart @@ -0,0 +1,52 @@ +// Copyright 2020 Workiva Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +@TestOn('browser') +library cast_ui_factory_test; + +import 'package:over_react/over_react.dart'; +import 'package:test/test.dart'; + +part 'cast_ui_factory_test.over_react.g.dart'; + +main() { + group('castUiFactory', () { + test('infers the typing of a factory', () { + UiFactory testFactory = castUiFactory(_$Basic); + + expect(testFactory, isA>()); + }); + + test('can use generics to set the type', () { + final testFactory = castUiFactory>(_$Basic); + + expect(testFactory, isA>()); + }); + + test('will leave the type a `UiFactory>()); + }); + }); +} + +UiFactory Basic = castUiFactory(_$Basic); // ignore: undefined_identifier + +mixin BasicProps on UiProps {} + +class BasicComponent extends UiComponent2 { + @override + render() => 'test'; +} diff --git a/test/over_react/util/cast_ui_factory_test.over_react.g.dart b/test/over_react/util/cast_ui_factory_test.over_react.g.dart new file mode 100644 index 000000000..4db7ae839 --- /dev/null +++ b/test/over_react/util/cast_ui_factory_test.over_react.g.dart @@ -0,0 +1,170 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +// ignore_for_file: deprecated_member_use_from_same_package, unnecessary_null_in_if_null_operators, prefer_null_aware_operators +part of 'cast_ui_factory_test.dart'; + +// ************************************************************************** +// OverReactBuilder (package:over_react/src/builder.dart) +// ************************************************************************** + +// React component factory implementation. +// +// Registers component implementation and links type meta to builder factory. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +final $BasicComponentFactory = registerComponent2( + () => _$BasicComponent(), + builderFactory: _$Basic, + componentClass: BasicComponent, + isWrapper: false, + parentType: null, + displayName: 'Basic', +); + +_$$BasicProps _$Basic([Map backingProps]) => backingProps == null + ? _$$BasicProps$JsMap(JsBackedMap()) + : _$$BasicProps(backingProps); + +// Concrete props implementation. +// +// Implements constructor and backing map, and links up to generated component factory. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +abstract class _$$BasicProps extends UiProps + with + BasicProps, + $BasicProps // If this generated mixin is undefined, it's likely because BasicProps is not a valid `mixin`-based props mixin, or because it is but the generated mixin was not imported. Check the declaration of BasicProps, and check that $BasicProps is exported/imported properly. +{ + _$$BasicProps._(); + + factory _$$BasicProps(Map backingMap) { + if (backingMap == null || backingMap is JsBackedMap) { + return _$$BasicProps$JsMap(backingMap); + } else { + return _$$BasicProps$PlainMap(backingMap); + } + } + + /// Let `UiProps` internals know that this class has been generated. + @override + bool get $isClassGenerated => true; + + /// The `ReactComponentFactory` associated with the component built by this class. + @override + ReactComponentFactoryProxy get componentFactory => + super.componentFactory ?? $BasicComponentFactory; + + /// The default namespace for the prop getters/setters generated for this class. + @override + String get propKeyNamespace => ''; + + @override + PropsMetaCollection get staticMeta => const PropsMetaCollection({ + // If this generated mixin is undefined, it's likely because BasicProps is not a valid `mixin`-based props mixin, or because it is but the generated mixin was not imported. Check the declaration of BasicProps, and check that $BasicProps is exported/imported properly. + BasicProps: $BasicProps.meta, + }); +} + +// Concrete props implementation that can be backed by any [Map]. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +class _$$BasicProps$PlainMap extends _$$BasicProps { + // This initializer of `_props` to an empty map, as well as the reassignment + // of `_props` in the constructor body is necessary to work around a DDC bug: https://github.com/dart-lang/sdk/issues/36217 + _$$BasicProps$PlainMap(Map backingMap) + : this._props = {}, + super._() { + this._props = backingMap ?? {}; + } + + /// The backing props map proxied by this class. + @override + Map get props => _props; + Map _props; +} + +// Concrete props implementation that can only be backed by [JsMap], +// allowing dart2js to compile more optimal code for key-value pair reads/writes. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +class _$$BasicProps$JsMap extends _$$BasicProps { + // This initializer of `_props` to an empty map, as well as the reassignment + // of `_props` in the constructor body is necessary to work around a DDC bug: https://github.com/dart-lang/sdk/issues/36217 + _$$BasicProps$JsMap(JsBackedMap backingMap) + : this._props = JsBackedMap(), + super._() { + this._props = backingMap ?? JsBackedMap(); + } + + /// The backing props map proxied by this class. + @override + JsBackedMap get props => _props; + JsBackedMap _props; +} + +// Concrete component implementation mixin. +// +// Implements typed props/state factories, defaults `consumedPropKeys` to the keys +// generated for the associated props class. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +class _$BasicComponent extends BasicComponent { + _$$BasicProps$JsMap _cachedTypedProps; + + @override + _$$BasicProps$JsMap get props => _cachedTypedProps; + + @override + set props(Map value) { + assert( + getBackingMap(value) is JsBackedMap, + 'Component2.props should never be set directly in ' + 'production. If this is required for testing, the ' + 'component should be rendered within the test. If ' + 'that does not have the necessary result, the last ' + 'resort is to use typedPropsFactoryJs.'); + super.props = value; + _cachedTypedProps = typedPropsFactoryJs(getBackingMap(value)); + } + + @override + _$$BasicProps$JsMap typedPropsFactoryJs(JsBackedMap backingMap) => + _$$BasicProps$JsMap(backingMap); + + @override + _$$BasicProps typedPropsFactory(Map backingMap) => _$$BasicProps(backingMap); + + /// Let `UiComponent` internals know that this class has been generated. + @override + bool get $isClassGenerated => true; + + /// The default consumed props, comprising all props mixins used by BasicProps. + /// Used in `*ConsumedProps` methods if [consumedProps] is not overridden. + @override + get $defaultConsumedProps => propsMeta.all; + + @override + PropsMetaCollection get propsMeta => const PropsMetaCollection({ + // If this generated mixin is undefined, it's likely because BasicProps is not a valid `mixin`-based props mixin, or because it is but the generated mixin was not imported. Check the declaration of BasicProps, and check that $BasicProps is exported/imported properly. + BasicProps: $BasicProps.meta, + }); +} + +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.' + ' EXCEPTION: this may be used in legacy boilerplate until' + ' it is transitioned to the new mixin-based boilerplate.') +mixin $BasicProps on BasicProps { + static const PropsMeta meta = _$metaForBasicProps; + /* GENERATED CONSTANTS */ + + static const List $props = []; + static const List $propKeys = []; +} + +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +const PropsMeta _$metaForBasicProps = PropsMeta( + fields: $BasicProps.$props, + keys: $BasicProps.$propKeys, +); From 3f61e9e26457c234cb10ea58c4fd46550d761f29 Mon Sep 17 00:00:00 2001 From: Joe Bingham Date: Wed, 13 Jan 2021 15:02:04 -0700 Subject: [PATCH 09/54] Add 2.9.0 syntax examples --- example/builder/main.dart | 33 +- .../src/dart_two_nine_syntax/basic.dart | 49 +++ .../basic.over_react.g.dart | 242 ++++++++++++ .../builder/src/dart_two_nine_syntax/hoc.dart | 36 ++ .../hoc.over_react.g.dart | 356 ++++++++++++++++++ 5 files changed, 712 insertions(+), 4 deletions(-) create mode 100644 example/builder/src/dart_two_nine_syntax/basic.dart create mode 100644 example/builder/src/dart_two_nine_syntax/basic.over_react.g.dart create mode 100644 example/builder/src/dart_two_nine_syntax/hoc.dart create mode 100644 example/builder/src/dart_two_nine_syntax/hoc.over_react.g.dart diff --git a/example/builder/main.dart b/example/builder/main.dart index 654e98e2c..1b84215c9 100644 --- a/example/builder/main.dart +++ b/example/builder/main.dart @@ -15,10 +15,14 @@ import 'dart:html'; import 'package:over_react/over_react.dart'; +import 'package:over_react/over_react_flux.dart'; import 'package:react/react_dom.dart' as react_dom; +import 'package:redux/redux.dart'; import './src/abstract_inheritance.dart'; import './src/basic.dart'; +import './src/dart_two_nine_syntax/basic.dart' as dart_two_nine_basic; +import './src/dart_two_nine_syntax/hoc.dart'; import './src/basic_library.dart'; import './src/generic_inheritance_sub.dart'; import './src/generic_inheritance_super.dart'; @@ -26,8 +30,17 @@ import './src/function_component.dart' as function; import 'src/functional_consumed_props.dart'; import 'src/new_class_consumed_props.dart'; +class ExampleState { + final String testValue; + + ExampleState(this.testValue); +} + +Store store = Store((_, __) => ExampleState('foo'), initialState: ExampleState('foo')); + main() { react_dom.render( + (ReduxProvider()..store = store)( Dom.div()( Dom.h3()('Components'), (Basic() @@ -65,10 +78,22 @@ main() { ..aParentProp = 'parent' ..aPropToBePassed = 'passed' )(), - (SomeClassParent() - ..aParentProp = 'classParent' - ..aPropToBePassed = 'passed' - )() + (SomeClassParent() + ..aParentProp = 'classParent' + ..aPropToBePassed = 'passed' + )(), + Dom.h3()('Components (Dart >=2.9.0 syntax)'), + (dart_two_nine_basic.Basic() + ..basic1 = '' + ..id = 'the id of this component' + )(null, null, ['this is another child']), + (Hoc() + ..foo = 'HOC test' + )(), + (ConnectedHocWithTwoFactories() + ..foo = 'HOC test' + )(), + ) ), querySelector('#content') ); } diff --git a/example/builder/src/dart_two_nine_syntax/basic.dart b/example/builder/src/dart_two_nine_syntax/basic.dart new file mode 100644 index 000000000..feff5a8ad --- /dev/null +++ b/example/builder/src/dart_two_nine_syntax/basic.dart @@ -0,0 +1,49 @@ +// Copyright 2020 Workiva Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import 'package:over_react/over_react.dart'; + +part 'basic.over_react.g.dart'; + +UiFactory Basic = castUiFactory(_$Basic); // ignore: undefined_identifier + +mixin BasicProps on UiProps { + @Deprecated('This is deprecated') + @requiredProp + String basicProp; + + String basic1; + String basic2; + String basic3; + String basic4; + String basic5; +} + +class BasicComponent extends UiComponent2 { + @override + get defaultProps => newProps()..id = 'basic component' + ..basicProp = 'defaultBasicProps'; // ignore: deprecated_member_use_from_same_package + + @override + render() { + return Dom.div()( + Dom.div()('prop id: ${props.id}'), + Dom.div()('default prop testing: ${props.basicProp}'), // ignore: deprecated_member_use_from_same_package + Dom.div()('default prop testing: ${props.basic1}'), + Dom.div()(null, props.basic4, 'children: ${props.children}' ), + ); + } +} + + diff --git a/example/builder/src/dart_two_nine_syntax/basic.over_react.g.dart b/example/builder/src/dart_two_nine_syntax/basic.over_react.g.dart new file mode 100644 index 000000000..a1825de85 --- /dev/null +++ b/example/builder/src/dart_two_nine_syntax/basic.over_react.g.dart @@ -0,0 +1,242 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +// ignore_for_file: deprecated_member_use_from_same_package, unnecessary_null_in_if_null_operators, prefer_null_aware_operators +part of 'basic.dart'; + +// ************************************************************************** +// OverReactBuilder (package:over_react/src/builder.dart) +// ************************************************************************** + +// React component factory implementation. +// +// Registers component implementation and links type meta to builder factory. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +final $BasicComponentFactory = registerComponent2( + () => _$BasicComponent(), + builderFactory: _$Basic, + componentClass: BasicComponent, + isWrapper: false, + parentType: null, + displayName: 'Basic', +); + +_$$BasicProps _$Basic([Map backingProps]) => backingProps == null + ? _$$BasicProps$JsMap(JsBackedMap()) + : _$$BasicProps(backingProps); + +// Concrete props implementation. +// +// Implements constructor and backing map, and links up to generated component factory. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +abstract class _$$BasicProps extends UiProps + with + BasicProps, + $BasicProps // If this generated mixin is undefined, it's likely because BasicProps is not a valid `mixin`-based props mixin, or because it is but the generated mixin was not imported. Check the declaration of BasicProps, and check that $BasicProps is exported/imported properly. +{ + _$$BasicProps._(); + + factory _$$BasicProps(Map backingMap) { + if (backingMap == null || backingMap is JsBackedMap) { + return _$$BasicProps$JsMap(backingMap); + } else { + return _$$BasicProps$PlainMap(backingMap); + } + } + + /// Let `UiProps` internals know that this class has been generated. + @override + bool get $isClassGenerated => true; + + /// The `ReactComponentFactory` associated with the component built by this class. + @override + ReactComponentFactoryProxy get componentFactory => + super.componentFactory ?? $BasicComponentFactory; + + /// The default namespace for the prop getters/setters generated for this class. + @override + String get propKeyNamespace => ''; + + @override + PropsMetaCollection get staticMeta => const PropsMetaCollection({ + // If this generated mixin is undefined, it's likely because BasicProps is not a valid `mixin`-based props mixin, or because it is but the generated mixin was not imported. Check the declaration of BasicProps, and check that $BasicProps is exported/imported properly. + BasicProps: $BasicProps.meta, + }); +} + +// Concrete props implementation that can be backed by any [Map]. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +class _$$BasicProps$PlainMap extends _$$BasicProps { + // This initializer of `_props` to an empty map, as well as the reassignment + // of `_props` in the constructor body is necessary to work around a DDC bug: https://github.com/dart-lang/sdk/issues/36217 + _$$BasicProps$PlainMap(Map backingMap) + : this._props = {}, + super._() { + this._props = backingMap ?? {}; + } + + /// The backing props map proxied by this class. + @override + Map get props => _props; + Map _props; +} + +// Concrete props implementation that can only be backed by [JsMap], +// allowing dart2js to compile more optimal code for key-value pair reads/writes. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +class _$$BasicProps$JsMap extends _$$BasicProps { + // This initializer of `_props` to an empty map, as well as the reassignment + // of `_props` in the constructor body is necessary to work around a DDC bug: https://github.com/dart-lang/sdk/issues/36217 + _$$BasicProps$JsMap(JsBackedMap backingMap) + : this._props = JsBackedMap(), + super._() { + this._props = backingMap ?? JsBackedMap(); + } + + /// The backing props map proxied by this class. + @override + JsBackedMap get props => _props; + JsBackedMap _props; +} + +// Concrete component implementation mixin. +// +// Implements typed props/state factories, defaults `consumedPropKeys` to the keys +// generated for the associated props class. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +class _$BasicComponent extends BasicComponent { + _$$BasicProps$JsMap _cachedTypedProps; + + @override + _$$BasicProps$JsMap get props => _cachedTypedProps; + + @override + set props(Map value) { + assert( + getBackingMap(value) is JsBackedMap, + 'Component2.props should never be set directly in ' + 'production. If this is required for testing, the ' + 'component should be rendered within the test. If ' + 'that does not have the necessary result, the last ' + 'resort is to use typedPropsFactoryJs.'); + super.props = value; + _cachedTypedProps = typedPropsFactoryJs(getBackingMap(value)); + } + + @override + _$$BasicProps$JsMap typedPropsFactoryJs(JsBackedMap backingMap) => + _$$BasicProps$JsMap(backingMap); + + @override + _$$BasicProps typedPropsFactory(Map backingMap) => _$$BasicProps(backingMap); + + /// Let `UiComponent` internals know that this class has been generated. + @override + bool get $isClassGenerated => true; + + /// The default consumed props, comprising all props mixins used by BasicProps. + /// Used in `*ConsumedProps` methods if [consumedProps] is not overridden. + @override + get $defaultConsumedProps => propsMeta.all; + + @override + PropsMetaCollection get propsMeta => const PropsMetaCollection({ + // If this generated mixin is undefined, it's likely because BasicProps is not a valid `mixin`-based props mixin, or because it is but the generated mixin was not imported. Check the declaration of BasicProps, and check that $BasicProps is exported/imported properly. + BasicProps: $BasicProps.meta, + }); +} + +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.' + ' EXCEPTION: this may be used in legacy boilerplate until' + ' it is transitioned to the new mixin-based boilerplate.') +mixin $BasicProps on BasicProps { + static const PropsMeta meta = _$metaForBasicProps; + @override + @Deprecated('This is deprecated') + @requiredProp + String get basicProp => + props[_$key__basicProp__BasicProps] ?? + null; // Add ` ?? null` to workaround DDC bug: ; + @override + @Deprecated('This is deprecated') + @requiredProp + set basicProp(String value) => props[_$key__basicProp__BasicProps] = value; + @override + String get basic1 => + props[_$key__basic1__BasicProps] ?? + null; // Add ` ?? null` to workaround DDC bug: ; + @override + set basic1(String value) => props[_$key__basic1__BasicProps] = value; + @override + String get basic2 => + props[_$key__basic2__BasicProps] ?? + null; // Add ` ?? null` to workaround DDC bug: ; + @override + set basic2(String value) => props[_$key__basic2__BasicProps] = value; + @override + String get basic3 => + props[_$key__basic3__BasicProps] ?? + null; // Add ` ?? null` to workaround DDC bug: ; + @override + set basic3(String value) => props[_$key__basic3__BasicProps] = value; + @override + String get basic4 => + props[_$key__basic4__BasicProps] ?? + null; // Add ` ?? null` to workaround DDC bug: ; + @override + set basic4(String value) => props[_$key__basic4__BasicProps] = value; + @override + String get basic5 => + props[_$key__basic5__BasicProps] ?? + null; // Add ` ?? null` to workaround DDC bug: ; + @override + set basic5(String value) => props[_$key__basic5__BasicProps] = value; + /* GENERATED CONSTANTS */ + static const PropDescriptor _$prop__basicProp__BasicProps = + PropDescriptor(_$key__basicProp__BasicProps, isRequired: true); + static const PropDescriptor _$prop__basic1__BasicProps = + PropDescriptor(_$key__basic1__BasicProps); + static const PropDescriptor _$prop__basic2__BasicProps = + PropDescriptor(_$key__basic2__BasicProps); + static const PropDescriptor _$prop__basic3__BasicProps = + PropDescriptor(_$key__basic3__BasicProps); + static const PropDescriptor _$prop__basic4__BasicProps = + PropDescriptor(_$key__basic4__BasicProps); + static const PropDescriptor _$prop__basic5__BasicProps = + PropDescriptor(_$key__basic5__BasicProps); + static const String _$key__basicProp__BasicProps = 'BasicProps.basicProp'; + static const String _$key__basic1__BasicProps = 'BasicProps.basic1'; + static const String _$key__basic2__BasicProps = 'BasicProps.basic2'; + static const String _$key__basic3__BasicProps = 'BasicProps.basic3'; + static const String _$key__basic4__BasicProps = 'BasicProps.basic4'; + static const String _$key__basic5__BasicProps = 'BasicProps.basic5'; + + static const List $props = [ + _$prop__basicProp__BasicProps, + _$prop__basic1__BasicProps, + _$prop__basic2__BasicProps, + _$prop__basic3__BasicProps, + _$prop__basic4__BasicProps, + _$prop__basic5__BasicProps + ]; + static const List $propKeys = [ + _$key__basicProp__BasicProps, + _$key__basic1__BasicProps, + _$key__basic2__BasicProps, + _$key__basic3__BasicProps, + _$key__basic4__BasicProps, + _$key__basic5__BasicProps + ]; +} + +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +const PropsMeta _$metaForBasicProps = PropsMeta( + fields: $BasicProps.$props, + keys: $BasicProps.$propKeys, +); diff --git a/example/builder/src/dart_two_nine_syntax/hoc.dart b/example/builder/src/dart_two_nine_syntax/hoc.dart new file mode 100644 index 000000000..fb336e550 --- /dev/null +++ b/example/builder/src/dart_two_nine_syntax/hoc.dart @@ -0,0 +1,36 @@ +import 'package:over_react/over_react.dart'; +import 'package:over_react/over_react_redux.dart'; + +import '../../main.dart'; + +part 'hoc.over_react.g.dart'; + +UiFactory Hoc = connect( + mapStateToPropsWithOwnProps: (state, props) => Hoc(), + mapDispatchToPropsWithOwnProps: (state, props) => Hoc(), +)(castUiFactory(_$Hoc)); // ignore: undefined_identifier + +mixin HocProps on UiProps { + String foo; +} + +class HocComponent extends UiComponent2 { + @override + render() => Dom.div()(props.foo); +} + +UiFactory HocWithTwoFactories = castUiFactory(_$HocWithTwoFactories); // ignore: undefined_identifier + +UiFactory ConnectedHocWithTwoFactories = connect( + mapStateToPropsWithOwnProps: (state, props) => HocWithTwoFactories(), + mapDispatchToPropsWithOwnProps: (state, props) => HocWithTwoFactories(), +)(HocWithTwoFactories); + +mixin HocWithTwoFactoriesProps on UiProps { + String foo; +} + +class HocWithTwoFactoriesComponent extends UiComponent2 { + @override + render() => Dom.div()(props.foo); +} diff --git a/example/builder/src/dart_two_nine_syntax/hoc.over_react.g.dart b/example/builder/src/dart_two_nine_syntax/hoc.over_react.g.dart new file mode 100644 index 000000000..2a79596a0 --- /dev/null +++ b/example/builder/src/dart_two_nine_syntax/hoc.over_react.g.dart @@ -0,0 +1,356 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +// ignore_for_file: deprecated_member_use_from_same_package, unnecessary_null_in_if_null_operators, prefer_null_aware_operators +part of 'hoc.dart'; + +// ************************************************************************** +// OverReactBuilder (package:over_react/src/builder.dart) +// ************************************************************************** + +// React component factory implementation. +// +// Registers component implementation and links type meta to builder factory. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +final $HocComponentFactory = registerComponent2( + () => _$HocComponent(), + builderFactory: _$Hoc, + componentClass: HocComponent, + isWrapper: false, + parentType: null, + displayName: 'Hoc', +); + +_$$HocProps _$Hoc([Map backingProps]) => backingProps == null + ? _$$HocProps$JsMap(JsBackedMap()) + : _$$HocProps(backingProps); + +// Concrete props implementation. +// +// Implements constructor and backing map, and links up to generated component factory. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +abstract class _$$HocProps extends UiProps + with + HocProps, + $HocProps // If this generated mixin is undefined, it's likely because HocProps is not a valid `mixin`-based props mixin, or because it is but the generated mixin was not imported. Check the declaration of HocProps, and check that $HocProps is exported/imported properly. +{ + _$$HocProps._(); + + factory _$$HocProps(Map backingMap) { + if (backingMap == null || backingMap is JsBackedMap) { + return _$$HocProps$JsMap(backingMap); + } else { + return _$$HocProps$PlainMap(backingMap); + } + } + + /// Let `UiProps` internals know that this class has been generated. + @override + bool get $isClassGenerated => true; + + /// The `ReactComponentFactory` associated with the component built by this class. + @override + ReactComponentFactoryProxy get componentFactory => + super.componentFactory ?? $HocComponentFactory; + + /// The default namespace for the prop getters/setters generated for this class. + @override + String get propKeyNamespace => ''; + + @override + PropsMetaCollection get staticMeta => const PropsMetaCollection({ + // If this generated mixin is undefined, it's likely because HocProps is not a valid `mixin`-based props mixin, or because it is but the generated mixin was not imported. Check the declaration of HocProps, and check that $HocProps is exported/imported properly. + HocProps: $HocProps.meta, + }); +} + +// Concrete props implementation that can be backed by any [Map]. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +class _$$HocProps$PlainMap extends _$$HocProps { + // This initializer of `_props` to an empty map, as well as the reassignment + // of `_props` in the constructor body is necessary to work around a DDC bug: https://github.com/dart-lang/sdk/issues/36217 + _$$HocProps$PlainMap(Map backingMap) + : this._props = {}, + super._() { + this._props = backingMap ?? {}; + } + + /// The backing props map proxied by this class. + @override + Map get props => _props; + Map _props; +} + +// Concrete props implementation that can only be backed by [JsMap], +// allowing dart2js to compile more optimal code for key-value pair reads/writes. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +class _$$HocProps$JsMap extends _$$HocProps { + // This initializer of `_props` to an empty map, as well as the reassignment + // of `_props` in the constructor body is necessary to work around a DDC bug: https://github.com/dart-lang/sdk/issues/36217 + _$$HocProps$JsMap(JsBackedMap backingMap) + : this._props = JsBackedMap(), + super._() { + this._props = backingMap ?? JsBackedMap(); + } + + /// The backing props map proxied by this class. + @override + JsBackedMap get props => _props; + JsBackedMap _props; +} + +// Concrete component implementation mixin. +// +// Implements typed props/state factories, defaults `consumedPropKeys` to the keys +// generated for the associated props class. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +class _$HocComponent extends HocComponent { + _$$HocProps$JsMap _cachedTypedProps; + + @override + _$$HocProps$JsMap get props => _cachedTypedProps; + + @override + set props(Map value) { + assert( + getBackingMap(value) is JsBackedMap, + 'Component2.props should never be set directly in ' + 'production. If this is required for testing, the ' + 'component should be rendered within the test. If ' + 'that does not have the necessary result, the last ' + 'resort is to use typedPropsFactoryJs.'); + super.props = value; + _cachedTypedProps = typedPropsFactoryJs(getBackingMap(value)); + } + + @override + _$$HocProps$JsMap typedPropsFactoryJs(JsBackedMap backingMap) => + _$$HocProps$JsMap(backingMap); + + @override + _$$HocProps typedPropsFactory(Map backingMap) => _$$HocProps(backingMap); + + /// Let `UiComponent` internals know that this class has been generated. + @override + bool get $isClassGenerated => true; + + /// The default consumed props, comprising all props mixins used by HocProps. + /// Used in `*ConsumedProps` methods if [consumedProps] is not overridden. + @override + get $defaultConsumedProps => propsMeta.all; + + @override + PropsMetaCollection get propsMeta => const PropsMetaCollection({ + // If this generated mixin is undefined, it's likely because HocProps is not a valid `mixin`-based props mixin, or because it is but the generated mixin was not imported. Check the declaration of HocProps, and check that $HocProps is exported/imported properly. + HocProps: $HocProps.meta, + }); +} + +// React component factory implementation. +// +// Registers component implementation and links type meta to builder factory. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +final $HocWithTwoFactoriesComponentFactory = registerComponent2( + () => _$HocWithTwoFactoriesComponent(), + builderFactory: _$HocWithTwoFactories, + componentClass: HocWithTwoFactoriesComponent, + isWrapper: false, + parentType: null, + displayName: 'HocWithTwoFactories', +); + +_$$HocWithTwoFactoriesProps _$HocWithTwoFactories([Map backingProps]) => + backingProps == null + ? _$$HocWithTwoFactoriesProps$JsMap(JsBackedMap()) + : _$$HocWithTwoFactoriesProps(backingProps); + +// Concrete props implementation. +// +// Implements constructor and backing map, and links up to generated component factory. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +abstract class _$$HocWithTwoFactoriesProps extends UiProps + with + HocWithTwoFactoriesProps, + $HocWithTwoFactoriesProps // If this generated mixin is undefined, it's likely because HocWithTwoFactoriesProps is not a valid `mixin`-based props mixin, or because it is but the generated mixin was not imported. Check the declaration of HocWithTwoFactoriesProps, and check that $HocWithTwoFactoriesProps is exported/imported properly. +{ + _$$HocWithTwoFactoriesProps._(); + + factory _$$HocWithTwoFactoriesProps(Map backingMap) { + if (backingMap == null || backingMap is JsBackedMap) { + return _$$HocWithTwoFactoriesProps$JsMap(backingMap); + } else { + return _$$HocWithTwoFactoriesProps$PlainMap(backingMap); + } + } + + /// Let `UiProps` internals know that this class has been generated. + @override + bool get $isClassGenerated => true; + + /// The `ReactComponentFactory` associated with the component built by this class. + @override + ReactComponentFactoryProxy get componentFactory => + super.componentFactory ?? $HocWithTwoFactoriesComponentFactory; + + /// The default namespace for the prop getters/setters generated for this class. + @override + String get propKeyNamespace => ''; + + @override + PropsMetaCollection get staticMeta => const PropsMetaCollection({ + // If this generated mixin is undefined, it's likely because HocWithTwoFactoriesProps is not a valid `mixin`-based props mixin, or because it is but the generated mixin was not imported. Check the declaration of HocWithTwoFactoriesProps, and check that $HocWithTwoFactoriesProps is exported/imported properly. + HocWithTwoFactoriesProps: $HocWithTwoFactoriesProps.meta, + }); +} + +// Concrete props implementation that can be backed by any [Map]. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +class _$$HocWithTwoFactoriesProps$PlainMap extends _$$HocWithTwoFactoriesProps { + // This initializer of `_props` to an empty map, as well as the reassignment + // of `_props` in the constructor body is necessary to work around a DDC bug: https://github.com/dart-lang/sdk/issues/36217 + _$$HocWithTwoFactoriesProps$PlainMap(Map backingMap) + : this._props = {}, + super._() { + this._props = backingMap ?? {}; + } + + /// The backing props map proxied by this class. + @override + Map get props => _props; + Map _props; +} + +// Concrete props implementation that can only be backed by [JsMap], +// allowing dart2js to compile more optimal code for key-value pair reads/writes. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +class _$$HocWithTwoFactoriesProps$JsMap extends _$$HocWithTwoFactoriesProps { + // This initializer of `_props` to an empty map, as well as the reassignment + // of `_props` in the constructor body is necessary to work around a DDC bug: https://github.com/dart-lang/sdk/issues/36217 + _$$HocWithTwoFactoriesProps$JsMap(JsBackedMap backingMap) + : this._props = JsBackedMap(), + super._() { + this._props = backingMap ?? JsBackedMap(); + } + + /// The backing props map proxied by this class. + @override + JsBackedMap get props => _props; + JsBackedMap _props; +} + +// Concrete component implementation mixin. +// +// Implements typed props/state factories, defaults `consumedPropKeys` to the keys +// generated for the associated props class. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +class _$HocWithTwoFactoriesComponent extends HocWithTwoFactoriesComponent { + _$$HocWithTwoFactoriesProps$JsMap _cachedTypedProps; + + @override + _$$HocWithTwoFactoriesProps$JsMap get props => _cachedTypedProps; + + @override + set props(Map value) { + assert( + getBackingMap(value) is JsBackedMap, + 'Component2.props should never be set directly in ' + 'production. If this is required for testing, the ' + 'component should be rendered within the test. If ' + 'that does not have the necessary result, the last ' + 'resort is to use typedPropsFactoryJs.'); + super.props = value; + _cachedTypedProps = typedPropsFactoryJs(getBackingMap(value)); + } + + @override + _$$HocWithTwoFactoriesProps$JsMap typedPropsFactoryJs( + JsBackedMap backingMap) => + _$$HocWithTwoFactoriesProps$JsMap(backingMap); + + @override + _$$HocWithTwoFactoriesProps typedPropsFactory(Map backingMap) => + _$$HocWithTwoFactoriesProps(backingMap); + + /// Let `UiComponent` internals know that this class has been generated. + @override + bool get $isClassGenerated => true; + + /// The default consumed props, comprising all props mixins used by HocWithTwoFactoriesProps. + /// Used in `*ConsumedProps` methods if [consumedProps] is not overridden. + @override + get $defaultConsumedProps => propsMeta.all; + + @override + PropsMetaCollection get propsMeta => const PropsMetaCollection({ + // If this generated mixin is undefined, it's likely because HocWithTwoFactoriesProps is not a valid `mixin`-based props mixin, or because it is but the generated mixin was not imported. Check the declaration of HocWithTwoFactoriesProps, and check that $HocWithTwoFactoriesProps is exported/imported properly. + HocWithTwoFactoriesProps: $HocWithTwoFactoriesProps.meta, + }); +} + +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.' + ' EXCEPTION: this may be used in legacy boilerplate until' + ' it is transitioned to the new mixin-based boilerplate.') +mixin $HocProps on HocProps { + static const PropsMeta meta = _$metaForHocProps; + @override + String get foo => + props[_$key__foo__HocProps] ?? + null; // Add ` ?? null` to workaround DDC bug: ; + @override + set foo(String value) => props[_$key__foo__HocProps] = value; + /* GENERATED CONSTANTS */ + static const PropDescriptor _$prop__foo__HocProps = + PropDescriptor(_$key__foo__HocProps); + static const String _$key__foo__HocProps = 'HocProps.foo'; + + static const List $props = [_$prop__foo__HocProps]; + static const List $propKeys = [_$key__foo__HocProps]; +} + +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +const PropsMeta _$metaForHocProps = PropsMeta( + fields: $HocProps.$props, + keys: $HocProps.$propKeys, +); + +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.' + ' EXCEPTION: this may be used in legacy boilerplate until' + ' it is transitioned to the new mixin-based boilerplate.') +mixin $HocWithTwoFactoriesProps on HocWithTwoFactoriesProps { + static const PropsMeta meta = _$metaForHocWithTwoFactoriesProps; + @override + String get foo => + props[_$key__foo__HocWithTwoFactoriesProps] ?? + null; // Add ` ?? null` to workaround DDC bug: ; + @override + set foo(String value) => props[_$key__foo__HocWithTwoFactoriesProps] = value; + /* GENERATED CONSTANTS */ + static const PropDescriptor _$prop__foo__HocWithTwoFactoriesProps = + PropDescriptor(_$key__foo__HocWithTwoFactoriesProps); + static const String _$key__foo__HocWithTwoFactoriesProps = + 'HocWithTwoFactoriesProps.foo'; + + static const List $props = [ + _$prop__foo__HocWithTwoFactoriesProps + ]; + static const List $propKeys = [_$key__foo__HocWithTwoFactoriesProps]; +} + +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +const PropsMeta _$metaForHocWithTwoFactoriesProps = PropsMeta( + fields: $HocWithTwoFactoriesProps.$props, + keys: $HocWithTwoFactoriesProps.$propKeys, +); From c5970b889de82c2fa423ffa1edaa6e58351b2a7e Mon Sep 17 00:00:00 2001 From: Joe Bingham Date: Wed, 13 Jan 2021 15:27:22 -0700 Subject: [PATCH 10/54] Update tests --- pubspec.yaml | 6 +- .../compact_hoc_syntax_integration_test.dart | 61 +++- ..._syntax_integration_test.over_react.g.dart | 172 +++++++++++ .../component_integration_test.dart | 71 +++++ ...mponent_integration_test.over_react.g.dart | 280 ++++++++++++++++++ ...onent_integration_verbose_syntax_test.dart | 55 ++++ ...tion_verbose_syntax_test.over_react.g.dart | 155 ++++++++++ test/over_react_util_test.dart | 2 + .../builder/declaration_parsing_test.dart | 35 +++ .../builder/over_react_builder_test.dart | 7 + .../builder/parsing/ast_util_test.dart | 6 +- .../builder/parsing/members_test.dart | 193 ++++++++---- .../builder/parsing/parsing_helpers.dart | 19 +- .../builder/parsing/parsing_version_test.dart | 10 +- test/vm_tests/builder/util.dart | 26 +- .../basic_two_nine.over_react.g.dart.goldFile | 242 +++++++++++++++ .../mixin_based/basic_two_nine.dart | 34 +++ 17 files changed, 1295 insertions(+), 79 deletions(-) create mode 100644 test_fixtures/gold_output_files/mixin_based/basic_two_nine.over_react.g.dart.goldFile create mode 100644 test_fixtures/source_files/mixin_based/basic_two_nine.dart diff --git a/pubspec.yaml b/pubspec.yaml index 4dc65d520..c6964f84a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -43,7 +43,7 @@ dev_dependencies: glob: ^1.2.0 io: ^0.3.2+1 mockito: ^4.1.1 - over_react_test: ^2.7.0 + over_react_test: ^2.10.2 pedantic: ^1.8.0 test: ^1.9.1 yaml: ^2.2.1 @@ -53,7 +53,3 @@ dependency_overrides: git: url: https://github.com/cleandart/react-dart.git ref: 6.0.0-wip - over_react_test: - git: - url: https://github.com/Workiva/over_react_test.git - ref: widen-over-react-constraint diff --git a/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/compact_hoc_syntax_integration_test.dart b/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/compact_hoc_syntax_integration_test.dart index c930ab1ff..acf6269b3 100644 --- a/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/compact_hoc_syntax_integration_test.dart +++ b/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/compact_hoc_syntax_integration_test.dart @@ -21,25 +21,60 @@ part 'compact_hoc_syntax_integration_test.over_react.g.dart'; main() { group('Compact HOC syntax, with generated factory used in factory initializer:', () { - test('variable initializes correctly', () { - expect(() => Foo, returnsNormally); - expect(Foo, isNotNull); + group('(using Dart <2.9.0 syntax)', () { + test('variable initializes correctly', () { + expect(() => Foo, returnsNormally); + expect(Foo, isNotNull); + }); + + test('component renders normally, and reading/writing props works', () { + TestJacket jacket; + expect(() { + jacket = mount( + (ReduxProvider()..store = Store((_, __) => null))( + (Foo()..foo = 'bar')(), + ), + ); + }, returnsNormally); + expect(jacket.mountNode.text, contains('bar')); + }); }); - test('component renders normally, and reading/writing props works', () { - TestJacket jacket; - expect(() { - jacket = mount( - (ReduxProvider()..store = Store((_, __) => null))( - (Foo()..foo = 'bar')(), - ), - ); - }, returnsNormally); - expect(jacket.mountNode.text, contains('bar')); + group('(using Dart >=2.9.0 syntax)', () { + test('variable initializes correctly', () { + expect(() => Foo290, returnsNormally); + expect(Foo290, isNotNull); + }); + + test('component renders normally, and reading/writing props works', () { + TestJacket jacket; + expect(() { + jacket = mount( + (ReduxProvider()..store = Store((_, __) => null))( + (Foo290()..foo = 'bar')(), + ), + ); + }, returnsNormally); + expect(jacket.mountNode.text, contains('bar')); + }); }); }); } +UiFactory Foo290 = connect( + mapStateToPropsWithOwnProps: (state, props) => Foo(), + mapDispatchToPropsWithOwnProps: (state, props) => Foo(), +)(castUiFactory(_$Foo290)); // ignore: undefined_identifier + +mixin Foo290Props on UiProps { + String foo; +} + +class FooComponent290 extends UiComponent2 { + @override + render() => props.foo; +} + UiFactory Foo = connect( mapStateToPropsWithOwnProps: (state, props) => Foo(), mapDispatchToPropsWithOwnProps: (state, props) => Foo(), diff --git a/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/compact_hoc_syntax_integration_test.over_react.g.dart b/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/compact_hoc_syntax_integration_test.over_react.g.dart index 18363f535..e48293ed6 100644 --- a/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/compact_hoc_syntax_integration_test.over_react.g.dart +++ b/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/compact_hoc_syntax_integration_test.over_react.g.dart @@ -7,6 +7,150 @@ part of 'compact_hoc_syntax_integration_test.dart'; // OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** +// React component factory implementation. +// +// Registers component implementation and links type meta to builder factory. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +final $FooComponent290Factory = registerComponent2( + () => _$FooComponent290(), + builderFactory: _$Foo290, + componentClass: FooComponent290, + isWrapper: false, + parentType: null, + displayName: 'Foo290', +); + +_$$Foo290Props _$Foo290([Map backingProps]) => backingProps == null + ? _$$Foo290Props$JsMap(JsBackedMap()) + : _$$Foo290Props(backingProps); + +// Concrete props implementation. +// +// Implements constructor and backing map, and links up to generated component factory. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +abstract class _$$Foo290Props extends UiProps + with + Foo290Props, + $Foo290Props // If this generated mixin is undefined, it's likely because Foo290Props is not a valid `mixin`-based props mixin, or because it is but the generated mixin was not imported. Check the declaration of Foo290Props, and check that $Foo290Props is exported/imported properly. +{ + _$$Foo290Props._(); + + factory _$$Foo290Props(Map backingMap) { + if (backingMap == null || backingMap is JsBackedMap) { + return _$$Foo290Props$JsMap(backingMap); + } else { + return _$$Foo290Props$PlainMap(backingMap); + } + } + + /// Let `UiProps` internals know that this class has been generated. + @override + bool get $isClassGenerated => true; + + /// The `ReactComponentFactory` associated with the component built by this class. + @override + ReactComponentFactoryProxy get componentFactory => + super.componentFactory ?? $FooComponent290Factory; + + /// The default namespace for the prop getters/setters generated for this class. + @override + String get propKeyNamespace => ''; + + @override + PropsMetaCollection get staticMeta => const PropsMetaCollection({ + // If this generated mixin is undefined, it's likely because Foo290Props is not a valid `mixin`-based props mixin, or because it is but the generated mixin was not imported. Check the declaration of Foo290Props, and check that $Foo290Props is exported/imported properly. + Foo290Props: $Foo290Props.meta, + }); +} + +// Concrete props implementation that can be backed by any [Map]. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +class _$$Foo290Props$PlainMap extends _$$Foo290Props { + // This initializer of `_props` to an empty map, as well as the reassignment + // of `_props` in the constructor body is necessary to work around a DDC bug: https://github.com/dart-lang/sdk/issues/36217 + _$$Foo290Props$PlainMap(Map backingMap) + : this._props = {}, + super._() { + this._props = backingMap ?? {}; + } + + /// The backing props map proxied by this class. + @override + Map get props => _props; + Map _props; +} + +// Concrete props implementation that can only be backed by [JsMap], +// allowing dart2js to compile more optimal code for key-value pair reads/writes. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +class _$$Foo290Props$JsMap extends _$$Foo290Props { + // This initializer of `_props` to an empty map, as well as the reassignment + // of `_props` in the constructor body is necessary to work around a DDC bug: https://github.com/dart-lang/sdk/issues/36217 + _$$Foo290Props$JsMap(JsBackedMap backingMap) + : this._props = JsBackedMap(), + super._() { + this._props = backingMap ?? JsBackedMap(); + } + + /// The backing props map proxied by this class. + @override + JsBackedMap get props => _props; + JsBackedMap _props; +} + +// Concrete component implementation mixin. +// +// Implements typed props/state factories, defaults `consumedPropKeys` to the keys +// generated for the associated props class. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +class _$FooComponent290 extends FooComponent290 { + _$$Foo290Props$JsMap _cachedTypedProps; + + @override + _$$Foo290Props$JsMap get props => _cachedTypedProps; + + @override + set props(Map value) { + assert( + getBackingMap(value) is JsBackedMap, + 'Component2.props should never be set directly in ' + 'production. If this is required for testing, the ' + 'component should be rendered within the test. If ' + 'that does not have the necessary result, the last ' + 'resort is to use typedPropsFactoryJs.'); + super.props = value; + _cachedTypedProps = typedPropsFactoryJs(getBackingMap(value)); + } + + @override + _$$Foo290Props$JsMap typedPropsFactoryJs(JsBackedMap backingMap) => + _$$Foo290Props$JsMap(backingMap); + + @override + _$$Foo290Props typedPropsFactory(Map backingMap) => + _$$Foo290Props(backingMap); + + /// Let `UiComponent` internals know that this class has been generated. + @override + bool get $isClassGenerated => true; + + /// The default consumed props, comprising all props mixins used by Foo290Props. + /// Used in `*ConsumedProps` methods if [consumedProps] is not overridden. + @override + get $defaultConsumedProps => propsMeta.all; + + @override + PropsMetaCollection get propsMeta => const PropsMetaCollection({ + // If this generated mixin is undefined, it's likely because Foo290Props is not a valid `mixin`-based props mixin, or because it is but the generated mixin was not imported. Check the declaration of Foo290Props, and check that $Foo290Props is exported/imported properly. + Foo290Props: $Foo290Props.meta, + }); +} + // React component factory implementation. // // Registers component implementation and links type meta to builder factory. @@ -150,6 +294,34 @@ class _$FooComponent extends FooComponent { }); } +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.' + ' EXCEPTION: this may be used in legacy boilerplate until' + ' it is transitioned to the new mixin-based boilerplate.') +mixin $Foo290Props on Foo290Props { + static const PropsMeta meta = _$metaForFoo290Props; + @override + String get foo => + props[_$key__foo__Foo290Props] ?? + null; // Add ` ?? null` to workaround DDC bug: ; + @override + set foo(String value) => props[_$key__foo__Foo290Props] = value; + /* GENERATED CONSTANTS */ + static const PropDescriptor _$prop__foo__Foo290Props = + PropDescriptor(_$key__foo__Foo290Props); + static const String _$key__foo__Foo290Props = 'Foo290Props.foo'; + + static const List $props = [_$prop__foo__Foo290Props]; + static const List $propKeys = [_$key__foo__Foo290Props]; +} + +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +const PropsMeta _$metaForFoo290Props = PropsMeta( + fields: $Foo290Props.$props, + keys: $Foo290Props.$propKeys, +); + @Deprecated('This API is for use only within generated code.' ' Do not reference it in your code, as it may change at any time.' ' EXCEPTION: this may be used in legacy boilerplate until' diff --git a/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/component_integration_test.dart b/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/component_integration_test.dart index 251b2c508..13ad7394d 100644 --- a/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/component_integration_test.dart +++ b/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/component_integration_test.dart @@ -45,6 +45,27 @@ main() { expect(node.dataset, containsPair('prop-custom-key-and-namespace-prop', '6')); }); + test('(Dart >= 2.9.0 syntax) renders a component from end to end, successfully reading props via typed getters', () { + var instance = render((ComponentTest290() + ..stringProp = '1' + ..dynamicProp = '2' + ..untypedProp = '3' + ..customKeyProp = '4' + ..customNamespaceProp = '5' + ..customKeyAndNamespaceProp = '6' + )()); + expect(instance, isNotNull); + + var node = findDomNode(instance); + expect(node.text, 'rendered content'); + expect(node.dataset, containsPair('prop-string-prop', '1')); + expect(node.dataset, containsPair('prop-dynamic-prop', '2')); + expect(node.dataset, containsPair('prop-untyped-prop', '3')); + expect(node.dataset, containsPair('prop-custom-key-prop', '4')); + expect(node.dataset, containsPair('prop-custom-namespace-prop', '5')); + expect(node.dataset, containsPair('prop-custom-key-and-namespace-prop', '6')); + }); + group('isErrorBoundary annotation is set to', () { test('true, allowing use of getDerivedStateFromError and componentDidCatch', () { var jacket = mount( @@ -166,6 +187,56 @@ main() { }); } +UiFactory ComponentTest290 = castUiFactory(_$ComponentTest290); // ignore: undefined_identifier + +mixin ComponentTest290Props on UiProps { + String stringProp; + bool shouldSetPropsDirectly; + bool shouldUseJsFactory; + dynamic dynamicProp; + var untypedProp; // ignore: prefer_typing_uninitialized_variables + + @Accessor(key: 'custom key!') + dynamic customKeyProp; + + @Accessor(keyNamespace: 'custom namespace~~') + dynamic customNamespaceProp; + + @Accessor(keyNamespace: 'custom namespace~~', key: 'custom key!') + dynamic customKeyAndNamespaceProp; +} + + +class ComponentTest290Component extends UiComponent2 { + @override + Map get defaultProps => newProps() + ..id = 'testId' + ..shouldSetPropsDirectly = false + ..shouldUseJsFactory = false; + + @override + render() => (Dom.div() + ..modifyProps(addUnconsumedProps) + ..addProp('data-prop-string-prop', props.stringProp) + ..addProp('data-prop-dynamic-prop', props.dynamicProp) + ..addProp('data-prop-untyped-prop', props.untypedProp) + ..addProp('data-prop-custom-key-prop', props.customKeyProp) + ..addProp('data-prop-custom-namespace-prop', props.customNamespaceProp) + ..addProp('data-prop-custom-key-and-namespace-prop', props.customKeyAndNamespaceProp) + )('rendered content'); + + @override + void componentDidMount() { + if (props.shouldSetPropsDirectly) { + if (props.shouldUseJsFactory) { + this.props = typedPropsFactoryJs(JsBackedMap()); + } else { + this.props = {'shouldSetPropsDirectly': false}; + } + } + } +} + UiFactory ComponentTest = _$ComponentTest; mixin ComponentTestProps on UiProps { diff --git a/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/component_integration_test.over_react.g.dart b/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/component_integration_test.over_react.g.dart index 6776264b6..332c2f102 100644 --- a/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/component_integration_test.over_react.g.dart +++ b/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/component_integration_test.over_react.g.dart @@ -7,6 +7,151 @@ part of 'component_integration_test.dart'; // OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** +// React component factory implementation. +// +// Registers component implementation and links type meta to builder factory. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +final $ComponentTest290ComponentFactory = registerComponent2( + () => _$ComponentTest290Component(), + builderFactory: _$ComponentTest290, + componentClass: ComponentTest290Component, + isWrapper: false, + parentType: null, + displayName: 'ComponentTest290', +); + +_$$ComponentTest290Props _$ComponentTest290([Map backingProps]) => + backingProps == null + ? _$$ComponentTest290Props$JsMap(JsBackedMap()) + : _$$ComponentTest290Props(backingProps); + +// Concrete props implementation. +// +// Implements constructor and backing map, and links up to generated component factory. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +abstract class _$$ComponentTest290Props extends UiProps + with + ComponentTest290Props, + $ComponentTest290Props // If this generated mixin is undefined, it's likely because ComponentTest290Props is not a valid `mixin`-based props mixin, or because it is but the generated mixin was not imported. Check the declaration of ComponentTest290Props, and check that $ComponentTest290Props is exported/imported properly. +{ + _$$ComponentTest290Props._(); + + factory _$$ComponentTest290Props(Map backingMap) { + if (backingMap == null || backingMap is JsBackedMap) { + return _$$ComponentTest290Props$JsMap(backingMap); + } else { + return _$$ComponentTest290Props$PlainMap(backingMap); + } + } + + /// Let `UiProps` internals know that this class has been generated. + @override + bool get $isClassGenerated => true; + + /// The `ReactComponentFactory` associated with the component built by this class. + @override + ReactComponentFactoryProxy get componentFactory => + super.componentFactory ?? $ComponentTest290ComponentFactory; + + /// The default namespace for the prop getters/setters generated for this class. + @override + String get propKeyNamespace => ''; + + @override + PropsMetaCollection get staticMeta => const PropsMetaCollection({ + // If this generated mixin is undefined, it's likely because ComponentTest290Props is not a valid `mixin`-based props mixin, or because it is but the generated mixin was not imported. Check the declaration of ComponentTest290Props, and check that $ComponentTest290Props is exported/imported properly. + ComponentTest290Props: $ComponentTest290Props.meta, + }); +} + +// Concrete props implementation that can be backed by any [Map]. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +class _$$ComponentTest290Props$PlainMap extends _$$ComponentTest290Props { + // This initializer of `_props` to an empty map, as well as the reassignment + // of `_props` in the constructor body is necessary to work around a DDC bug: https://github.com/dart-lang/sdk/issues/36217 + _$$ComponentTest290Props$PlainMap(Map backingMap) + : this._props = {}, + super._() { + this._props = backingMap ?? {}; + } + + /// The backing props map proxied by this class. + @override + Map get props => _props; + Map _props; +} + +// Concrete props implementation that can only be backed by [JsMap], +// allowing dart2js to compile more optimal code for key-value pair reads/writes. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +class _$$ComponentTest290Props$JsMap extends _$$ComponentTest290Props { + // This initializer of `_props` to an empty map, as well as the reassignment + // of `_props` in the constructor body is necessary to work around a DDC bug: https://github.com/dart-lang/sdk/issues/36217 + _$$ComponentTest290Props$JsMap(JsBackedMap backingMap) + : this._props = JsBackedMap(), + super._() { + this._props = backingMap ?? JsBackedMap(); + } + + /// The backing props map proxied by this class. + @override + JsBackedMap get props => _props; + JsBackedMap _props; +} + +// Concrete component implementation mixin. +// +// Implements typed props/state factories, defaults `consumedPropKeys` to the keys +// generated for the associated props class. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +class _$ComponentTest290Component extends ComponentTest290Component { + _$$ComponentTest290Props$JsMap _cachedTypedProps; + + @override + _$$ComponentTest290Props$JsMap get props => _cachedTypedProps; + + @override + set props(Map value) { + assert( + getBackingMap(value) is JsBackedMap, + 'Component2.props should never be set directly in ' + 'production. If this is required for testing, the ' + 'component should be rendered within the test. If ' + 'that does not have the necessary result, the last ' + 'resort is to use typedPropsFactoryJs.'); + super.props = value; + _cachedTypedProps = typedPropsFactoryJs(getBackingMap(value)); + } + + @override + _$$ComponentTest290Props$JsMap typedPropsFactoryJs(JsBackedMap backingMap) => + _$$ComponentTest290Props$JsMap(backingMap); + + @override + _$$ComponentTest290Props typedPropsFactory(Map backingMap) => + _$$ComponentTest290Props(backingMap); + + /// Let `UiComponent` internals know that this class has been generated. + @override + bool get $isClassGenerated => true; + + /// The default consumed props, comprising all props mixins used by ComponentTest290Props. + /// Used in `*ConsumedProps` methods if [consumedProps] is not overridden. + @override + get $defaultConsumedProps => propsMeta.all; + + @override + PropsMetaCollection get propsMeta => const PropsMetaCollection({ + // If this generated mixin is undefined, it's likely because ComponentTest290Props is not a valid `mixin`-based props mixin, or because it is but the generated mixin was not imported. Check the declaration of ComponentTest290Props, and check that $ComponentTest290Props is exported/imported properly. + ComponentTest290Props: $ComponentTest290Props.meta, + }); +} + // React component factory implementation. // // Registers component implementation and links type meta to builder factory. @@ -152,6 +297,141 @@ class _$ComponentTestComponent extends ComponentTestComponent { }); } +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.' + ' EXCEPTION: this may be used in legacy boilerplate until' + ' it is transitioned to the new mixin-based boilerplate.') +mixin $ComponentTest290Props on ComponentTest290Props { + static const PropsMeta meta = _$metaForComponentTest290Props; + @override + String get stringProp => + props[_$key__stringProp__ComponentTest290Props] ?? + null; // Add ` ?? null` to workaround DDC bug: ; + @override + set stringProp(String value) => + props[_$key__stringProp__ComponentTest290Props] = value; + @override + bool get shouldSetPropsDirectly => + props[_$key__shouldSetPropsDirectly__ComponentTest290Props] ?? + null; // Add ` ?? null` to workaround DDC bug: ; + @override + set shouldSetPropsDirectly(bool value) => + props[_$key__shouldSetPropsDirectly__ComponentTest290Props] = value; + @override + bool get shouldUseJsFactory => + props[_$key__shouldUseJsFactory__ComponentTest290Props] ?? + null; // Add ` ?? null` to workaround DDC bug: ; + @override + set shouldUseJsFactory(bool value) => + props[_$key__shouldUseJsFactory__ComponentTest290Props] = value; + @override + dynamic get dynamicProp => + props[_$key__dynamicProp__ComponentTest290Props] ?? + null; // Add ` ?? null` to workaround DDC bug: ; + @override + set dynamicProp(dynamic value) => + props[_$key__dynamicProp__ComponentTest290Props] = value; + @override + get untypedProp => + props[_$key__untypedProp__ComponentTest290Props] ?? + null; // Add ` ?? null` to workaround DDC bug: ; + @override + set untypedProp(value) => + props[_$key__untypedProp__ComponentTest290Props] = value; + @override + @Accessor(key: 'custom key!') + dynamic get customKeyProp => + props[_$key__customKeyProp__ComponentTest290Props] ?? + null; // Add ` ?? null` to workaround DDC bug: ; + @override + @Accessor(key: 'custom key!') + set customKeyProp(dynamic value) => + props[_$key__customKeyProp__ComponentTest290Props] = value; + @override + @Accessor(keyNamespace: 'custom namespace~~') + dynamic get customNamespaceProp => + props[_$key__customNamespaceProp__ComponentTest290Props] ?? + null; // Add ` ?? null` to workaround DDC bug: ; + @override + @Accessor(keyNamespace: 'custom namespace~~') + set customNamespaceProp(dynamic value) => + props[_$key__customNamespaceProp__ComponentTest290Props] = value; + @override + @Accessor(keyNamespace: 'custom namespace~~', key: 'custom key!') + dynamic get customKeyAndNamespaceProp => + props[_$key__customKeyAndNamespaceProp__ComponentTest290Props] ?? + null; // Add ` ?? null` to workaround DDC bug: ; + @override + @Accessor(keyNamespace: 'custom namespace~~', key: 'custom key!') + set customKeyAndNamespaceProp(dynamic value) => + props[_$key__customKeyAndNamespaceProp__ComponentTest290Props] = value; + /* GENERATED CONSTANTS */ + static const PropDescriptor _$prop__stringProp__ComponentTest290Props = + PropDescriptor(_$key__stringProp__ComponentTest290Props); + static const PropDescriptor + _$prop__shouldSetPropsDirectly__ComponentTest290Props = + PropDescriptor(_$key__shouldSetPropsDirectly__ComponentTest290Props); + static const PropDescriptor + _$prop__shouldUseJsFactory__ComponentTest290Props = + PropDescriptor(_$key__shouldUseJsFactory__ComponentTest290Props); + static const PropDescriptor _$prop__dynamicProp__ComponentTest290Props = + PropDescriptor(_$key__dynamicProp__ComponentTest290Props); + static const PropDescriptor _$prop__untypedProp__ComponentTest290Props = + PropDescriptor(_$key__untypedProp__ComponentTest290Props); + static const PropDescriptor _$prop__customKeyProp__ComponentTest290Props = + PropDescriptor(_$key__customKeyProp__ComponentTest290Props); + static const PropDescriptor + _$prop__customNamespaceProp__ComponentTest290Props = + PropDescriptor(_$key__customNamespaceProp__ComponentTest290Props); + static const PropDescriptor + _$prop__customKeyAndNamespaceProp__ComponentTest290Props = + PropDescriptor(_$key__customKeyAndNamespaceProp__ComponentTest290Props); + static const String _$key__stringProp__ComponentTest290Props = + 'ComponentTest290Props.stringProp'; + static const String _$key__shouldSetPropsDirectly__ComponentTest290Props = + 'ComponentTest290Props.shouldSetPropsDirectly'; + static const String _$key__shouldUseJsFactory__ComponentTest290Props = + 'ComponentTest290Props.shouldUseJsFactory'; + static const String _$key__dynamicProp__ComponentTest290Props = + 'ComponentTest290Props.dynamicProp'; + static const String _$key__untypedProp__ComponentTest290Props = + 'ComponentTest290Props.untypedProp'; + static const String _$key__customKeyProp__ComponentTest290Props = + 'ComponentTest290Props.custom key!'; + static const String _$key__customNamespaceProp__ComponentTest290Props = + 'custom namespace~~customNamespaceProp'; + static const String _$key__customKeyAndNamespaceProp__ComponentTest290Props = + 'custom namespace~~custom key!'; + + static const List $props = [ + _$prop__stringProp__ComponentTest290Props, + _$prop__shouldSetPropsDirectly__ComponentTest290Props, + _$prop__shouldUseJsFactory__ComponentTest290Props, + _$prop__dynamicProp__ComponentTest290Props, + _$prop__untypedProp__ComponentTest290Props, + _$prop__customKeyProp__ComponentTest290Props, + _$prop__customNamespaceProp__ComponentTest290Props, + _$prop__customKeyAndNamespaceProp__ComponentTest290Props + ]; + static const List $propKeys = [ + _$key__stringProp__ComponentTest290Props, + _$key__shouldSetPropsDirectly__ComponentTest290Props, + _$key__shouldUseJsFactory__ComponentTest290Props, + _$key__dynamicProp__ComponentTest290Props, + _$key__untypedProp__ComponentTest290Props, + _$key__customKeyProp__ComponentTest290Props, + _$key__customNamespaceProp__ComponentTest290Props, + _$key__customKeyAndNamespaceProp__ComponentTest290Props + ]; +} + +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +const PropsMeta _$metaForComponentTest290Props = PropsMeta( + fields: $ComponentTest290Props.$props, + keys: $ComponentTest290Props.$propKeys, +); + @Deprecated('This API is for use only within generated code.' ' Do not reference it in your code, as it may change at any time.' ' EXCEPTION: this may be used in legacy boilerplate until' diff --git a/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/component_integration_verbose_syntax_test.dart b/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/component_integration_verbose_syntax_test.dart index 0e5f94ff6..b3ee10057 100644 --- a/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/component_integration_verbose_syntax_test.dart +++ b/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/component_integration_verbose_syntax_test.dart @@ -41,6 +41,27 @@ main() { expect(node.dataset, containsPair('prop-custom-key-and-namespace-prop', '6')); }); + test('(Dart >= 2.9.0 syntax) renders a component from end to end, successfully reading props via typed getters', () { + var instance = render((ComponentTest290() + ..stringProp = '1' + ..dynamicProp = '2' + ..untypedProp = '3' + ..customKeyProp = '4' + ..customNamespaceProp = '5' + ..customKeyAndNamespaceProp = '6' + )()); + expect(instance, isNotNull); + + var node = findDomNode(instance); + expect(node.text, 'rendered content'); + expect(node.dataset, containsPair('prop-string-prop', '1')); + expect(node.dataset, containsPair('prop-dynamic-prop', '2')); + expect(node.dataset, containsPair('prop-untyped-prop', '3')); + expect(node.dataset, containsPair('prop-custom-key-prop', '4')); + expect(node.dataset, containsPair('prop-custom-namespace-prop', '5')); + expect(node.dataset, containsPair('prop-custom-key-and-namespace-prop', '6')); + }); + group('initializes the factory variable with a function', () { test('that returns a new props class implementation instance', () { var instance = ComponentTest(); @@ -108,6 +129,40 @@ main() { }); } +UiFactory ComponentTest290 = castUiFactory(_$ComponentTest290); // ignore: undefined_identifier + +class ComponentTestProps290Props = UiProps with ComponentTestPropsMixin, TestPropsMixin; + +class ComponentTest290Component extends UiComponent2 { + @override + Map get defaultProps => newProps() + ..id = 'testId' + ..shouldSetPropsDirectly = false + ..shouldUseJsFactory = false; + + @override + render() => (Dom.div() + ..modifyProps(addUnconsumedProps) + ..addProp('data-prop-string-prop', props.stringProp) + ..addProp('data-prop-dynamic-prop', props.dynamicProp) + ..addProp('data-prop-untyped-prop', props.untypedProp) + ..addProp('data-prop-custom-key-prop', props.customKeyProp) + ..addProp('data-prop-custom-namespace-prop', props.customNamespaceProp) + ..addProp('data-prop-custom-key-and-namespace-prop', props.customKeyAndNamespaceProp) + )('rendered content'); + + @override + void componentDidMount() { + if (props.shouldSetPropsDirectly) { + if (props.shouldUseJsFactory) { + this.props = typedPropsFactoryJs(JsBackedMap()); + } else { + this.props = {'shouldSetPropsDirectly': false}; + } + } + } +} + mixin TestPropsMixin on UiProps { dynamic propsMixinProp; } diff --git a/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/component_integration_verbose_syntax_test.over_react.g.dart b/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/component_integration_verbose_syntax_test.over_react.g.dart index 969a7a7ac..35935ae6b 100644 --- a/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/component_integration_verbose_syntax_test.over_react.g.dart +++ b/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/component_integration_verbose_syntax_test.over_react.g.dart @@ -7,6 +7,161 @@ part of 'component_integration_verbose_syntax_test.dart'; // OverReactBuilder (package:over_react/src/builder.dart) // ************************************************************************** +// React component factory implementation. +// +// Registers component implementation and links type meta to builder factory. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +final $ComponentTest290ComponentFactory = registerComponent2( + () => _$ComponentTest290Component(), + builderFactory: _$ComponentTest290, + componentClass: ComponentTest290Component, + isWrapper: false, + parentType: null, + displayName: 'ComponentTest290', +); + +_$$ComponentTestProps290Props _$ComponentTest290([Map backingProps]) => + backingProps == null + ? _$$ComponentTestProps290Props$JsMap(JsBackedMap()) + : _$$ComponentTestProps290Props(backingProps); + +// Concrete props implementation. +// +// Implements constructor and backing map, and links up to generated component factory. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +abstract class _$$ComponentTestProps290Props extends UiProps + with + ComponentTestPropsMixin, + $ComponentTestPropsMixin, // If this generated mixin is undefined, it's likely because ComponentTestPropsMixin is not a valid `mixin`-based props mixin, or because it is but the generated mixin was not imported. Check the declaration of ComponentTestPropsMixin, and check that $ComponentTestPropsMixin is exported/imported properly. + TestPropsMixin, + $TestPropsMixin // If this generated mixin is undefined, it's likely because TestPropsMixin is not a valid `mixin`-based props mixin, or because it is but the generated mixin was not imported. Check the declaration of TestPropsMixin, and check that $TestPropsMixin is exported/imported properly. + implements + ComponentTestProps290Props { + _$$ComponentTestProps290Props._(); + + factory _$$ComponentTestProps290Props(Map backingMap) { + if (backingMap == null || backingMap is JsBackedMap) { + return _$$ComponentTestProps290Props$JsMap(backingMap); + } else { + return _$$ComponentTestProps290Props$PlainMap(backingMap); + } + } + + /// Let `UiProps` internals know that this class has been generated. + @override + bool get $isClassGenerated => true; + + /// The `ReactComponentFactory` associated with the component built by this class. + @override + ReactComponentFactoryProxy get componentFactory => + super.componentFactory ?? $ComponentTest290ComponentFactory; + + /// The default namespace for the prop getters/setters generated for this class. + @override + String get propKeyNamespace => ''; + + @override + PropsMetaCollection get staticMeta => const PropsMetaCollection({ + // If this generated mixin is undefined, it's likely because ComponentTestPropsMixin is not a valid `mixin`-based props mixin, or because it is but the generated mixin was not imported. Check the declaration of ComponentTestPropsMixin, and check that $ComponentTestPropsMixin is exported/imported properly. + ComponentTestPropsMixin: $ComponentTestPropsMixin.meta, + // If this generated mixin is undefined, it's likely because TestPropsMixin is not a valid `mixin`-based props mixin, or because it is but the generated mixin was not imported. Check the declaration of TestPropsMixin, and check that $TestPropsMixin is exported/imported properly. + TestPropsMixin: $TestPropsMixin.meta, + }); +} + +// Concrete props implementation that can be backed by any [Map]. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +class _$$ComponentTestProps290Props$PlainMap + extends _$$ComponentTestProps290Props { + // This initializer of `_props` to an empty map, as well as the reassignment + // of `_props` in the constructor body is necessary to work around a DDC bug: https://github.com/dart-lang/sdk/issues/36217 + _$$ComponentTestProps290Props$PlainMap(Map backingMap) + : this._props = {}, + super._() { + this._props = backingMap ?? {}; + } + + /// The backing props map proxied by this class. + @override + Map get props => _props; + Map _props; +} + +// Concrete props implementation that can only be backed by [JsMap], +// allowing dart2js to compile more optimal code for key-value pair reads/writes. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +class _$$ComponentTestProps290Props$JsMap + extends _$$ComponentTestProps290Props { + // This initializer of `_props` to an empty map, as well as the reassignment + // of `_props` in the constructor body is necessary to work around a DDC bug: https://github.com/dart-lang/sdk/issues/36217 + _$$ComponentTestProps290Props$JsMap(JsBackedMap backingMap) + : this._props = JsBackedMap(), + super._() { + this._props = backingMap ?? JsBackedMap(); + } + + /// The backing props map proxied by this class. + @override + JsBackedMap get props => _props; + JsBackedMap _props; +} + +// Concrete component implementation mixin. +// +// Implements typed props/state factories, defaults `consumedPropKeys` to the keys +// generated for the associated props class. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +class _$ComponentTest290Component extends ComponentTest290Component { + _$$ComponentTestProps290Props$JsMap _cachedTypedProps; + + @override + _$$ComponentTestProps290Props$JsMap get props => _cachedTypedProps; + + @override + set props(Map value) { + assert( + getBackingMap(value) is JsBackedMap, + 'Component2.props should never be set directly in ' + 'production. If this is required for testing, the ' + 'component should be rendered within the test. If ' + 'that does not have the necessary result, the last ' + 'resort is to use typedPropsFactoryJs.'); + super.props = value; + _cachedTypedProps = typedPropsFactoryJs(getBackingMap(value)); + } + + @override + _$$ComponentTestProps290Props$JsMap typedPropsFactoryJs( + JsBackedMap backingMap) => + _$$ComponentTestProps290Props$JsMap(backingMap); + + @override + _$$ComponentTestProps290Props typedPropsFactory(Map backingMap) => + _$$ComponentTestProps290Props(backingMap); + + /// Let `UiComponent` internals know that this class has been generated. + @override + bool get $isClassGenerated => true; + + /// The default consumed props, comprising all props mixins used by ComponentTestProps290Props. + /// Used in `*ConsumedProps` methods if [consumedProps] is not overridden. + @override + get $defaultConsumedProps => propsMeta.all; + + @override + PropsMetaCollection get propsMeta => const PropsMetaCollection({ + // If this generated mixin is undefined, it's likely because ComponentTestPropsMixin is not a valid `mixin`-based props mixin, or because it is but the generated mixin was not imported. Check the declaration of ComponentTestPropsMixin, and check that $ComponentTestPropsMixin is exported/imported properly. + ComponentTestPropsMixin: $ComponentTestPropsMixin.meta, + // If this generated mixin is undefined, it's likely because TestPropsMixin is not a valid `mixin`-based props mixin, or because it is but the generated mixin was not imported. Check the declaration of TestPropsMixin, and check that $TestPropsMixin is exported/imported properly. + TestPropsMixin: $TestPropsMixin.meta, + }); +} + // React component factory implementation. // // Registers component implementation and links type meta to builder factory. diff --git a/test/over_react_util_test.dart b/test/over_react_util_test.dart index 2a8023ec9..2df6b6719 100644 --- a/test/over_react_util_test.dart +++ b/test/over_react_util_test.dart @@ -22,6 +22,7 @@ library util_test; import 'package:over_react/over_react.dart'; import 'package:test/test.dart'; +import 'over_react/util/cast_ui_factory_test.dart' as cast_ui_factory_test; import 'over_react/util/class_names_test.dart' as class_names_test; import 'over_react/util/constants_base_test.dart' as constants_base_test; import 'over_react/util/css_value_util_test.dart' as css_value_util_test; @@ -44,6 +45,7 @@ import 'over_react/util/test_mode_test.dart' as test_mode_test; void main() { enableTestMode(); + cast_ui_factory_test.main(); class_names_test.main(); constants_base_test.main(); css_value_util_test.main(); diff --git a/test/vm_tests/builder/declaration_parsing_test.dart b/test/vm_tests/builder/declaration_parsing_test.dart index 112ea01a4..93f4f1b2d 100644 --- a/test/vm_tests/builder/declaration_parsing_test.dart +++ b/test/vm_tests/builder/declaration_parsing_test.dart @@ -1777,6 +1777,41 @@ main() { }); }); }); + + group('(Dart >=2.9.0 syntax)', () { + test('a component', () { + setUpAndParse(r''' + UiFactory Foo = castUiFactory(_$Foo); + + mixin FooProps on UiProps { + String foo; + } + + class FooComponent extends UiComponent2 { + render() {} + } + '''); + + expect(declarations, unorderedEquals([ + isA(), + isA(), + ])); + + final propsMixinDecl = declarations.firstWhereType(); + expect(propsMixinDecl.mixin?.name?.name, 'FooProps'); + + final decl = declarations.firstWhereType(); + + expect(decl.factory?.name?.name, 'Foo'); + expect(decl.props?.b?.name?.name, 'FooProps'); + expect(decl.component?.name?.name, 'FooComponent'); + expect(decl.state?.either, isNull); + + expect(decl.factory.meta, isA()); + expect(decl.props.b.meta, isA()); + expect(decl.component.meta, isA()); + }); + }); }); const String restOfComponent = ''' diff --git a/test/vm_tests/builder/over_react_builder_test.dart b/test/vm_tests/builder/over_react_builder_test.dart index 8a8e9ed03..534828123 100644 --- a/test/vm_tests/builder/over_react_builder_test.dart +++ b/test/vm_tests/builder/over_react_builder_test.dart @@ -193,6 +193,13 @@ main() { '${p.absolute(p.current)}/test_fixtures/gold_output_files/mixin_based/basic.over_react.g.dart.goldFile'); }); + test('builds from basic component file using Dart >=2.9.0 syntax', () async { + await checkBuildForFile( + 'over_react|test_fixtures/source_files/mixin_based/basic_two_nine.dart', + 'over_react|test_fixtures/source_files/mixin_based/basic_two_nine.over_react.g.dart', + '${p.absolute(p.current)}/test_fixtures/gold_output_files/mixin_based/basic_two_nine.over_react.g.dart.goldFile'); + }); + test('builds from basic multi-part library', () async { await checkBuildForFile( 'over_react|test_fixtures/source_files/mixin_based/basic_library.dart', diff --git a/test/vm_tests/builder/parsing/ast_util_test.dart b/test/vm_tests/builder/parsing/ast_util_test.dart index b5b2d7358..863a09a1b 100644 --- a/test/vm_tests/builder/parsing/ast_util_test.dart +++ b/test/vm_tests/builder/parsing/ast_util_test.dart @@ -71,7 +71,11 @@ main() { ''')).firstVariable.name.name, 'foo'); }); - test('hasConfig', () { + test('usesAGeneratedConfig', () { + expect(InitializerHelperTopLevel(parseAndGetSingleWithType(''' + UiFactory Foo = castUiFactory(_\$FooConfig); // ignore: undefined_identifier + ''')).usesAGeneratedConfig, true); + expect(InitializerHelperTopLevel(parseAndGetSingleWithType(''' final Foo = uiFunction( (props) => Dom.div()(), diff --git a/test/vm_tests/builder/parsing/members_test.dart b/test/vm_tests/builder/parsing/members_test.dart index 68021fe3c..fa30ed0cf 100644 --- a/test/vm_tests/builder/parsing/members_test.dart +++ b/test/vm_tests/builder/parsing/members_test.dart @@ -35,6 +35,7 @@ main() { BoilerplateComponent legacyBackwardCompatComponent; BoilerplateComponent legacyComponent; BoilerplateComponent newBoilerplateComponent; + BoilerplateComponent dart290BoilerplateComponent; setUp(() { legacyBackwardCompatComponent = mockDeclarationHelper.components @@ -43,6 +44,8 @@ main() { .firstWhere((component) => component.name.name == 'SecondFooComponent'); newBoilerplateComponent = mockDeclarationHelper.components .firstWhere((component) => component.name.name == 'ThirdFooComponent'); + dart290BoilerplateComponent = mockDeclarationHelper.components + .firstWhere((component) => component.name.name == 'FourthFooComponent'); }); group('propsGenericArg', () { @@ -51,6 +54,7 @@ main() { legacyBackwardCompatComponent.propsGenericArg.typeNameWithoutPrefix, 'FirstFooProps'); expect(legacyComponent.propsGenericArg.typeNameWithoutPrefix, 'SecondFooProps'); expect(newBoilerplateComponent.propsGenericArg.typeNameWithoutPrefix, 'ThirdFooProps'); + expect(dart290BoilerplateComponent.propsGenericArg.typeNameWithoutPrefix, 'FourthFooProps'); }); test('returns null if there is no type arg', () { @@ -66,18 +70,21 @@ main() { expect(legacyBackwardCompatComponent.hasAnnotation, true); expect(legacyComponent.hasAnnotation, true); expect(newBoilerplateComponent.hasAnnotation, false); + expect(dart290BoilerplateComponent.hasAnnotation, false); }); test('hasComponent1OrAbstractAnnotation', () { expect(legacyBackwardCompatComponent.hasComponent1OrAbstractAnnotation, true); expect(legacyComponent.hasComponent1OrAbstractAnnotation, false); expect(newBoilerplateComponent.hasComponent1OrAbstractAnnotation, false); + expect(dart290BoilerplateComponent.hasComponent1OrAbstractAnnotation, false); }); test('hasComponent2OrAbstractAnnotation', () { expect(legacyBackwardCompatComponent.hasComponent2OrAbstractAnnotation, false); expect(legacyComponent.hasComponent2OrAbstractAnnotation, true); expect(newBoilerplateComponent.hasComponent2OrAbstractAnnotation, false); + expect(dart290BoilerplateComponent.hasComponent2OrAbstractAnnotation, false); }); }); @@ -97,6 +104,11 @@ main() { .firstWhereType() .isComponent2(Version.v4_mixinBased), true); + expect( + BoilerplateMemberHelper.getBoilerplateMembersForVersion(BoilerplateVersions.v10) + .firstWhereType() + .isComponent2(Version.v4_mixinBased), + true); }); group('validate', () { @@ -233,7 +245,7 @@ main() { final members = BoilerplateMemberHelper.parseAndReturnMembers(componentString); final factory = members.whereType().first; - if (![BoilerplateVersions.v4, BoilerplateVersions.v5].contains(version)) { + if (![BoilerplateVersions.v4, BoilerplateVersions.v5, BoilerplateVersions.v10].contains(version)) { expect(factory.hasFactoryAnnotation, isTrue); } else { expect(factory.hasFactoryAnnotation, isFalse); @@ -243,19 +255,37 @@ main() { }); group('propsGenericArg', () { - group('on a component factory', () { - test('returns the correct props class', () { - final factory = BoilerplateFactory(parseAndGetSingleWithType(r''' + group('on a component factory using Dart', () { + group('<2.9.0 syntax', () { + test('returns the correct props class', () { + final factory = BoilerplateFactory(parseAndGetSingleWithType(r''' UiFactory Foo = _$Foo; '''), VersionConfidences.none()); - expect(factory.propsGenericArg?.typeNameWithoutPrefix, 'FooProps'); - }); + expect(factory.propsGenericArg?.typeNameWithoutPrefix, 'FooProps'); + }); - test('returns null if there is no type arg', () { - final factory = BoilerplateFactory(parseAndGetSingleWithType(r''' + test('returns null if there is no type arg', () { + final factory = BoilerplateFactory(parseAndGetSingleWithType(r''' UiFactory Foo = _$Foo; '''), VersionConfidences.none()); - expect(factory.propsGenericArg, isNull); + expect(factory.propsGenericArg, isNull); + }); + }); + + group('>=2.9.0 syntax', () { + test('returns the correct props class', () { + final factory = BoilerplateFactory(parseAndGetSingleWithType(r''' + UiFactory Foo = castUiFactory(_$Foo); + '''), VersionConfidences.none()); + expect(factory.propsGenericArg?.typeNameWithoutPrefix, 'FooProps'); + }); + + test('returns null if there is no type arg', () { + final factory = BoilerplateFactory(parseAndGetSingleWithType(r''' + UiFactory Foo = castUiFactory(_$Foo); + '''), VersionConfidences.none()); + expect(factory.propsGenericArg, isNull); + }); }); }); @@ -362,12 +392,14 @@ main() { } }); - group('throws when', () { - test('a Dart 2 only component does not have an annotation', () { - const boilerplateString = r''' + group('throws when using Dart', () { + group('<2.9.0 syntax', () { + test('a Dart 2 only component does not have an annotation', () { + const boilerplateString = r''' UiFactory Foo = _$Foo; - @Component() class FooComponent {} + @Component() + class FooComponent {} @Props() class _$FooProps {} @@ -376,24 +408,25 @@ main() { class _$FooState {} '''; - file = SourceFile.fromString(boilerplateString); - collector = ErrorCollector.callback(file, onError: validateCallback); + file = SourceFile.fromString(boilerplateString); + collector = ErrorCollector.callback(file, onError: validateCallback); - final members = BoilerplateMemberHelper.parseAndReturnMembers(boilerplateString); - final factory = members.whereType().first; + final members = BoilerplateMemberHelper.parseAndReturnMembers(boilerplateString); + final factory = members.whereType().first; - factory.validate(resolveVersion(members).version, collector); - expect(validateResults, [ - contains('Legacy boilerplate factories must be annotated with `@Factory()`'), - ]); - }); + factory.validate(resolveVersion(members).version, collector); + expect(validateResults, [ + contains('Legacy boilerplate factories must be annotated with `@Factory()`'), + ]); + }); - test('there is more than one variable', () { - const boilerplateString = r''' + test('there is more than one variable', () { + const boilerplateString = r''' @Factory() UiFactory Foo = _$Foo, _$Bar; - @Component() class FooComponent {} + @Component() + class FooComponent {} @Props() class _$FooProps {} @@ -402,24 +435,25 @@ main() { class _$FooState {} '''; - file = SourceFile.fromString(boilerplateString); - collector = ErrorCollector.callback(file, onError: validateCallback); + file = SourceFile.fromString(boilerplateString); + collector = ErrorCollector.callback(file, onError: validateCallback); - final members = BoilerplateMemberHelper.parseAndReturnMembers(boilerplateString); - final factory = members.whereType().first; + final members = BoilerplateMemberHelper.parseAndReturnMembers(boilerplateString); + final factory = members.whereType().first; - factory.validate(resolveVersion(members).version, collector); - expect(validateResults, [ - contains('Factory declarations must be a single variable.'), - ]); - }); + factory.validate(resolveVersion(members).version, collector); + expect(validateResults, [ + contains('Factory declarations must be a single variable.'), + ]); + }); - test('the factory is not set equal to the generated factory', () { - const boilerplateString = r''' + test('the factory is not set equal to the generated factory', () { + const boilerplateString = r''' @Factory() UiFactory Foo = Bar; - @Component() class FooComponent {} + @Component() + class FooComponent {} @Props() class _$FooProps {} @@ -428,19 +462,78 @@ main() { class _$FooState {} '''; - file = SourceFile.fromString(boilerplateString); - collector = ErrorCollector.callback(file, onError: validateCallback); + file = SourceFile.fromString(boilerplateString); + collector = ErrorCollector.callback(file, onError: validateCallback); - final members = BoilerplateMemberHelper.parseAndReturnMembers(boilerplateString); - final factory = members.whereType().first; + final members = BoilerplateMemberHelper.parseAndReturnMembers(boilerplateString); + final factory = members.whereType().first; - factory.validate(resolveVersion(members).version, collector); - expect(validateResults, [ - contains('Factory variables are stubs for generated code, and must' - ' be initialized with an expression containing either' - ' the generated factory (_\$Foo) or' - ' the generated factory config (_\$FooConfig).'), - ]); + factory.validate(resolveVersion(members).version, collector); + expect(validateResults, [ + contains('Factory variables are stubs for generated code, and must' + ' be initialized with an expression containing either' + ' the generated factory (_\$Foo) or' + ' the generated factory config (_\$FooConfig).'), + ]); + }); + }); + + group('>=2.9.0 syntax', () { + test('a Dart 2 only component does not have an annotation', () { + const boilerplateString = r''' + UiFactory Foo = castUiFactory(_$Foo); + + @Component() + class FooComponent {} + + @Props() + class _$FooProps {} + + @State() + class _$FooState {} + '''; + + file = SourceFile.fromString(boilerplateString); + collector = ErrorCollector.callback(file, onError: validateCallback); + + final members = BoilerplateMemberHelper.parseAndReturnMembers(boilerplateString); + final factory = members.whereType().first; + + factory.validate(resolveVersion(members).version, collector); + expect(validateResults, [ + contains('Legacy boilerplate factories must be annotated with `@Factory()`'), + ]); + }); + + test('the factory is not set equal to the generated factory', () { + const boilerplateString = r''' + @Factory() + UiFactory Foo = castUiFactory(Bar); + + @Component() + class FooComponent {} + + @Props() + class _$FooProps {} + + @State() + class _$FooState {} + '''; + + file = SourceFile.fromString(boilerplateString); + collector = ErrorCollector.callback(file, onError: validateCallback); + + final members = BoilerplateMemberHelper.parseAndReturnMembers(boilerplateString); + final factory = members.whereType().first; + + factory.validate(resolveVersion(members).version, collector); + expect(validateResults, [ + contains('Factory variables are stubs for generated code, and must' + ' be initialized with an expression containing either' + ' the generated factory (_\$Foo) or' + ' the generated factory config (_\$FooConfig).'), + ]); + }); }); }); }); @@ -467,7 +560,7 @@ main() { // The number of classes in VersionOptions that would not have BoilerplatePropsOrState // classes. This would be new boilerplate components that do not have have props or state // class aliases. - const numberOfMixinBasedClasses = 2; + const numberOfMixinBasedClasses = 3; for (final version in BoilerplateVersions.values) { test(versionDescriptions[version], () { @@ -752,7 +845,7 @@ main() { var classesDetected = 0; // The number of classes in VersionOptions that are mixin based. This // includes those that have class aliases. - const numberOfMixinBasedClasses = 4; + const numberOfMixinBasedClasses = 5; for (final version in BoilerplateVersions.values) { test(versionDescriptions[version], () { diff --git a/test/vm_tests/builder/parsing/parsing_helpers.dart b/test/vm_tests/builder/parsing/parsing_helpers.dart index 10a378c99..c53ccd69b 100644 --- a/test/vm_tests/builder/parsing/parsing_helpers.dart +++ b/test/vm_tests/builder/parsing/parsing_helpers.dart @@ -33,6 +33,7 @@ enum BoilerplateVersions { v7, v8, v9, + v10, } /// String descriptions of [BoilerplateVersions] versions. @@ -47,6 +48,7 @@ const versionDescriptions = { BoilerplateVersions.v7: 'legacy (Dart2 only - component 2)', BoilerplateVersions.v8: 'mixin based (abbreviated - with annotations)', BoilerplateVersions.v9: 'mixin based (with class alias - with annotations)', + BoilerplateVersions.v10: 'mixin based (with Dart >=2.9.0 factory syntax)', }; /// Generates a string representation of a provided boilerplate version. @@ -136,7 +138,12 @@ String getBoilerplateString({@required BoilerplateVersions version, String depre shouldIncludeAnnotations: true, baseName: componentBaseName, ).source; - break; + case BoilerplateVersions.v10: + return OverReactSrc.mixinBasedBoilerplateState( + componentBody: deprecatedMethod, + useDart290Factory: true, + baseName: componentBaseName, + ).source; default: return ''; } @@ -242,6 +249,16 @@ const mockComponentDeclarations = r''' mixin _$FunctionFooProps on UiProps {} mixin FunctionFoo2Props on UiProps {} + + // -------------------------- Version.v4_mixinBased -------------------------- + // But with Dart 2.9.0 syntax + UiFactory FourthFoo = castUiFactory(_$FourthFoo); + + mixin FourthFooProps on UiProps {} + + mixin FourthFooState on UiState {} + + class FourthFooComponent extends UiStatefulComponent2{} '''; /// Utility class that holds boilerplate members that can be accessed during testing. diff --git a/test/vm_tests/builder/parsing/parsing_version_test.dart b/test/vm_tests/builder/parsing/parsing_version_test.dart index e12e2182c..e083f9969 100644 --- a/test/vm_tests/builder/parsing/parsing_version_test.dart +++ b/test/vm_tests/builder/parsing/parsing_version_test.dart @@ -82,10 +82,15 @@ main() { expect(resolveVersion(members).version, Version.v3_legacyDart2Only); }); - test('v4_mixinBased', () { + test('v4_mixinBased (Dart <2.9.0 syntax)', () { members = BoilerplateMemberHelper.getBoilerplateMembersForVersion(BoilerplateVersions.v4); expect(resolveVersion(members).version, Version.v4_mixinBased); }); + + test('v4_mixinBased', () { + members = BoilerplateMemberHelper.getBoilerplateMembersForVersion(BoilerplateVersions.v10); + expect(resolveVersion(members).version, Version.v4_mixinBased); + }); }); }); @@ -104,7 +109,10 @@ main() { test('detects non-legacy instances correctly', () { final newBoilerplateMembers = BoilerplateMemberHelper.getBoilerplateMembersForVersion(BoilerplateVersions.v4); + final dart290BoilerplateMembers = + BoilerplateMemberHelper.getBoilerplateMembersForVersion(BoilerplateVersions.v10); expect(resolveVersion(newBoilerplateMembers).version.isLegacy, isFalse); + expect(resolveVersion(dart290BoilerplateMembers).version.isLegacy, isFalse); }); }); }); diff --git a/test/vm_tests/builder/util.dart b/test/vm_tests/builder/util.dart index 3c2bb6b4c..a6385592d 100644 --- a/test/vm_tests/builder/util.dart +++ b/test/vm_tests/builder/util.dart @@ -112,7 +112,8 @@ class OverReactSrc { this.numMixins = 0, this.isMixinBasedBoilerplate = false, this.shouldIncludePropsAlias = false, - this.shouldIncludeAnnotations = true; + this.shouldIncludeAnnotations = true, + this.useDart290Factory = false; /// Creates valid over_react [source] with an abstract state class included. /// @@ -153,7 +154,8 @@ class OverReactSrc { this.numMixins = 0, this.isMixinBasedBoilerplate = false, this.shouldIncludePropsAlias = false, - this.shouldIncludeAnnotations = true; + this.shouldIncludeAnnotations = true, + this.useDart290Factory = false; /// Creates valid over_react [source] with a props class included. /// @@ -190,7 +192,8 @@ class OverReactSrc { this.numMixins = 0, this.isMixinBasedBoilerplate = false, this.shouldIncludePropsAlias = false, - this.shouldIncludeAnnotations = true; + this.shouldIncludeAnnotations = true, + this.useDart290Factory = false; /// Creates valid over_react [source] with a props mixin class included. /// @@ -229,7 +232,8 @@ class OverReactSrc { this.needsComponent = false, this.isMixinBasedBoilerplate = false, this.shouldIncludePropsAlias = false, - this.shouldIncludeAnnotations = true; + this.shouldIncludeAnnotations = true, + this.useDart290Factory = false; /// Creates valid over_react [source] with a state class included. /// @@ -267,7 +271,8 @@ class OverReactSrc { this.numMixins = 0, this.isMixinBasedBoilerplate = false, this.shouldIncludePropsAlias = false, - this.shouldIncludeAnnotations = true; + this.shouldIncludeAnnotations = true, + this.useDart290Factory = false; /// Creates valid over_react [source] with a props mixin class included. /// @@ -306,7 +311,8 @@ class OverReactSrc { this.needsComponent = false, this.isMixinBasedBoilerplate = false, this.shouldIncludePropsAlias = false, - this.shouldIncludeAnnotations = true; + this.shouldIncludeAnnotations = true, + this.useDart290Factory = false; /// Creates valid over_react [source] using the mixin based boilerplate for props. /// @@ -338,6 +344,7 @@ class OverReactSrc { this.shouldIncludePropsAlias = false, this.shouldIncludeAnnotations = false, this.baseName = 'Foo', + this.useDart290Factory = false, isPrivate = false}) : this.annotation = AnnotationType.props, @@ -381,6 +388,7 @@ class OverReactSrc { this.shouldIncludePropsAlias = false, this.shouldIncludeAnnotations = false, this.baseName = 'Foo', + this.useDart290Factory = false, isPrivate = false}) : this.annotation = AnnotationType.state, @@ -406,10 +414,12 @@ class OverReactSrc { final bool isMixinBasedBoilerplate; final bool shouldIncludePropsAlias; final bool shouldIncludeAnnotations; + final bool useDart290Factory; String get componentName => '${prefixedBaseName}Component'; String get constantListName => isProps(annotation) ? '\$props' : '\$state'; String get factoryInitializer => '_\$$prefixedBaseName'; + String get factoryInitializerWithPossibleCast => useDart290Factory ? '_\$$prefixedBaseName' : 'castUiFactory(_\$$prefixedBaseName)'; String get keyListName => isProps(annotation) ? '\$propKeys' : '\$stateKeys'; String get propsClassName => '${prefixedBaseName}Props'; String get propsMixinClassName => '${prefixedBaseName}PropsMixin'; @@ -431,9 +441,9 @@ class OverReactSrc { String componentStr = componentVersion == 2 ? 'Component2' : 'Component'; if (!isAbstract(annotation)) { if (shouldIncludeAnnotations) { - buffer.writeln('\n@Factory()\nUiFactory<$propsClassName> $prefixedBaseName = _\$$prefixedBaseName;\n'); + buffer.writeln('\n@Factory()\nUiFactory<$propsClassName> $prefixedBaseName = $factoryInitializerWithPossibleCast;\n'); } else { - buffer.writeln('\nUiFactory<$propsClassName> $prefixedBaseName = _\$$prefixedBaseName;\n'); + buffer.writeln('\nUiFactory<$propsClassName> $prefixedBaseName = $factoryInitializerWithPossibleCast;\n'); } } diff --git a/test_fixtures/gold_output_files/mixin_based/basic_two_nine.over_react.g.dart.goldFile b/test_fixtures/gold_output_files/mixin_based/basic_two_nine.over_react.g.dart.goldFile new file mode 100644 index 000000000..da13fcd32 --- /dev/null +++ b/test_fixtures/gold_output_files/mixin_based/basic_two_nine.over_react.g.dart.goldFile @@ -0,0 +1,242 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +// ignore_for_file: deprecated_member_use_from_same_package, unnecessary_null_in_if_null_operators, prefer_null_aware_operators +part of 'basic_two_nine.dart'; + +// ************************************************************************** +// OverReactBuilder (package:over_react/src/builder.dart) +// ************************************************************************** + +// React component factory implementation. +// +// Registers component implementation and links type meta to builder factory. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +final $BasicComponentFactory = registerComponent2( + () => _$BasicComponent(), + builderFactory: _$Basic, + componentClass: BasicComponent, + isWrapper: false, + parentType: null, + displayName: 'Basic', +); + +_$$BasicProps _$Basic([Map backingProps]) => backingProps == null + ? _$$BasicProps$JsMap(JsBackedMap()) + : _$$BasicProps(backingProps); + +// Concrete props implementation. +// +// Implements constructor and backing map, and links up to generated component factory. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +abstract class _$$BasicProps extends UiProps + with + BasicProps, + $BasicProps // If this generated mixin is undefined, it's likely because BasicProps is not a valid `mixin`-based props mixin, or because it is but the generated mixin was not imported. Check the declaration of BasicProps, and check that $BasicProps is exported/imported properly. +{ + _$$BasicProps._(); + + factory _$$BasicProps(Map backingMap) { + if (backingMap == null || backingMap is JsBackedMap) { + return _$$BasicProps$JsMap(backingMap); + } else { + return _$$BasicProps$PlainMap(backingMap); + } + } + + /// Let `UiProps` internals know that this class has been generated. + @override + bool get $isClassGenerated => true; + + /// The `ReactComponentFactory` associated with the component built by this class. + @override + ReactComponentFactoryProxy get componentFactory => + super.componentFactory ?? $BasicComponentFactory; + + /// The default namespace for the prop getters/setters generated for this class. + @override + String get propKeyNamespace => ''; + + @override + PropsMetaCollection get staticMeta => const PropsMetaCollection({ + // If this generated mixin is undefined, it's likely because BasicProps is not a valid `mixin`-based props mixin, or because it is but the generated mixin was not imported. Check the declaration of BasicProps, and check that $BasicProps is exported/imported properly. + BasicProps: $BasicProps.meta, + }); +} + +// Concrete props implementation that can be backed by any [Map]. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +class _$$BasicProps$PlainMap extends _$$BasicProps { + // This initializer of `_props` to an empty map, as well as the reassignment + // of `_props` in the constructor body is necessary to work around a DDC bug: https://github.com/dart-lang/sdk/issues/36217 + _$$BasicProps$PlainMap(Map backingMap) + : this._props = {}, + super._() { + this._props = backingMap ?? {}; + } + + /// The backing props map proxied by this class. + @override + Map get props => _props; + Map _props; +} + +// Concrete props implementation that can only be backed by [JsMap], +// allowing dart2js to compile more optimal code for key-value pair reads/writes. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +class _$$BasicProps$JsMap extends _$$BasicProps { + // This initializer of `_props` to an empty map, as well as the reassignment + // of `_props` in the constructor body is necessary to work around a DDC bug: https://github.com/dart-lang/sdk/issues/36217 + _$$BasicProps$JsMap(JsBackedMap backingMap) + : this._props = JsBackedMap(), + super._() { + this._props = backingMap ?? JsBackedMap(); + } + + /// The backing props map proxied by this class. + @override + JsBackedMap get props => _props; + JsBackedMap _props; +} + +// Concrete component implementation mixin. +// +// Implements typed props/state factories, defaults `consumedPropKeys` to the keys +// generated for the associated props class. +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +class _$BasicComponent extends BasicComponent { + _$$BasicProps$JsMap _cachedTypedProps; + + @override + _$$BasicProps$JsMap get props => _cachedTypedProps; + + @override + set props(Map value) { + assert( + getBackingMap(value) is JsBackedMap, + 'Component2.props should never be set directly in ' + 'production. If this is required for testing, the ' + 'component should be rendered within the test. If ' + 'that does not have the necessary result, the last ' + 'resort is to use typedPropsFactoryJs.'); + super.props = value; + _cachedTypedProps = typedPropsFactoryJs(getBackingMap(value)); + } + + @override + _$$BasicProps$JsMap typedPropsFactoryJs(JsBackedMap backingMap) => + _$$BasicProps$JsMap(backingMap); + + @override + _$$BasicProps typedPropsFactory(Map backingMap) => _$$BasicProps(backingMap); + + /// Let `UiComponent` internals know that this class has been generated. + @override + bool get $isClassGenerated => true; + + /// The default consumed props, comprising all props mixins used by BasicProps. + /// Used in `*ConsumedProps` methods if [consumedProps] is not overridden. + @override + get $defaultConsumedProps => propsMeta.all; + + @override + PropsMetaCollection get propsMeta => const PropsMetaCollection({ + // If this generated mixin is undefined, it's likely because BasicProps is not a valid `mixin`-based props mixin, or because it is but the generated mixin was not imported. Check the declaration of BasicProps, and check that $BasicProps is exported/imported properly. + BasicProps: $BasicProps.meta, + }); +} + +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.' + ' EXCEPTION: this may be used in legacy boilerplate until' + ' it is transitioned to the new mixin-based boilerplate.') +mixin $BasicProps on BasicProps { + static const PropsMeta meta = _$metaForBasicProps; + @override + @deprecated + @requiredProp + String get basicProp => + props[_$key__basicProp__BasicProps] ?? + null; // Add ` ?? null` to workaround DDC bug: ; + @override + @deprecated + @requiredProp + set basicProp(String value) => props[_$key__basicProp__BasicProps] = value; + @override + String get basic1 => + props[_$key__basic1__BasicProps] ?? + null; // Add ` ?? null` to workaround DDC bug: ; + @override + set basic1(String value) => props[_$key__basic1__BasicProps] = value; + @override + String get basic2 => + props[_$key__basic2__BasicProps] ?? + null; // Add ` ?? null` to workaround DDC bug: ; + @override + set basic2(String value) => props[_$key__basic2__BasicProps] = value; + @override + String get basic3 => + props[_$key__basic3__BasicProps] ?? + null; // Add ` ?? null` to workaround DDC bug: ; + @override + set basic3(String value) => props[_$key__basic3__BasicProps] = value; + @override + String get basic4 => + props[_$key__basic4__BasicProps] ?? + null; // Add ` ?? null` to workaround DDC bug: ; + @override + set basic4(String value) => props[_$key__basic4__BasicProps] = value; + @override + String get basic5 => + props[_$key__basic5__BasicProps] ?? + null; // Add ` ?? null` to workaround DDC bug: ; + @override + set basic5(String value) => props[_$key__basic5__BasicProps] = value; + /* GENERATED CONSTANTS */ + static const PropDescriptor _$prop__basicProp__BasicProps = + PropDescriptor(_$key__basicProp__BasicProps, isRequired: true); + static const PropDescriptor _$prop__basic1__BasicProps = + PropDescriptor(_$key__basic1__BasicProps); + static const PropDescriptor _$prop__basic2__BasicProps = + PropDescriptor(_$key__basic2__BasicProps); + static const PropDescriptor _$prop__basic3__BasicProps = + PropDescriptor(_$key__basic3__BasicProps); + static const PropDescriptor _$prop__basic4__BasicProps = + PropDescriptor(_$key__basic4__BasicProps); + static const PropDescriptor _$prop__basic5__BasicProps = + PropDescriptor(_$key__basic5__BasicProps); + static const String _$key__basicProp__BasicProps = 'BasicProps.basicProp'; + static const String _$key__basic1__BasicProps = 'BasicProps.basic1'; + static const String _$key__basic2__BasicProps = 'BasicProps.basic2'; + static const String _$key__basic3__BasicProps = 'BasicProps.basic3'; + static const String _$key__basic4__BasicProps = 'BasicProps.basic4'; + static const String _$key__basic5__BasicProps = 'BasicProps.basic5'; + + static const List $props = [ + _$prop__basicProp__BasicProps, + _$prop__basic1__BasicProps, + _$prop__basic2__BasicProps, + _$prop__basic3__BasicProps, + _$prop__basic4__BasicProps, + _$prop__basic5__BasicProps + ]; + static const List $propKeys = [ + _$key__basicProp__BasicProps, + _$key__basic1__BasicProps, + _$key__basic2__BasicProps, + _$key__basic3__BasicProps, + _$key__basic4__BasicProps, + _$key__basic5__BasicProps + ]; +} + +@Deprecated('This API is for use only within generated code.' + ' Do not reference it in your code, as it may change at any time.') +const PropsMeta _$metaForBasicProps = PropsMeta( + fields: $BasicProps.$props, + keys: $BasicProps.$propKeys, +); diff --git a/test_fixtures/source_files/mixin_based/basic_two_nine.dart b/test_fixtures/source_files/mixin_based/basic_two_nine.dart new file mode 100644 index 000000000..cd8534bb9 --- /dev/null +++ b/test_fixtures/source_files/mixin_based/basic_two_nine.dart @@ -0,0 +1,34 @@ +import 'package:over_react/over_react.dart'; + +part 'basic_two_nine.over_react.g.dart'; + +UiFactory Basic = _$Basic; // ignore: undefined_identifier + +mixin BasicProps on UiProps { + @deprecated + @requiredProp + String basicProp; + + String basic1; + String basic2; + String basic3; + String basic4; + String basic5; +} + +class BasicComponent extends UiComponent2 { + @override + get defaultProps => newProps()..id = 'basic component' + ..basicProp = 'defaultBasicProps'; // ignore: deprecated_member_use_from_same_package + + @override + render() { + return Dom.div()( + Dom.div()('prop id: ${props.id}'), + Dom.div()('default prop testing: ${props.basicProp}'), // ignore: deprecated_member_use_from_same_package + Dom.div()('default prop testing: ${props.basic1}'), + Dom.div()(null, props.basic4, 'children: ${props.children}' ), + ); + } +} + From 132b8803cbd4bf846eb1d73011342c426882b25a Mon Sep 17 00:00:00 2001 From: Joe Bingham Date: Thu, 14 Jan 2021 08:14:11 -0700 Subject: [PATCH 11/54] Change functional component config type to dynamic --- .../src/function_component.over_react.g.dart | 6 +++--- .../functional_consumed_props.over_react.g.dart | 5 ++--- .../hooks/use_callback_example.over_react.g.dart | 3 +-- .../hooks/use_context_example.over_react.g.dart | 6 ++---- .../use_debug_value_example.over_react.g.dart | 6 ++---- ...e_imperative_handle_example.over_react.g.dart | 7 +++---- .../use_layout_effect_example.over_react.g.dart | 3 +-- example/hooks/use_memo_example.over_react.g.dart | 3 +-- .../hooks/use_reducer_example.over_react.g.dart | 3 +-- example/hooks/use_ref_example.over_react.g.dart | 3 +-- .../hooks/use_state_example.over_react.g.dart | 3 +-- .../codegen/typed_map_impl_generator.dart | 2 +- .../component/memo_test.over_react.g.dart | 3 +-- .../component/ref_util_test.over_react.g.dart | 7 +++---- .../function_component_test.over_react.g.dart | 8 ++++---- test/vm_tests/builder/codegen_test.dart | 2 +- web/component2/src/demos/ref.over_react.g.dart | 16 ++++++---------- 17 files changed, 34 insertions(+), 52 deletions(-) diff --git a/example/builder/src/function_component.over_react.g.dart b/example/builder/src/function_component.over_react.g.dart index d0ca43a25..32a86e4e8 100644 --- a/example/builder/src/function_component.over_react.g.dart +++ b/example/builder/src/function_component.over_react.g.dart @@ -133,7 +133,7 @@ final UiFactoryConfig<_$$BasicProps> _$BasicConfig = UiFactoryConfig( @Deprecated(r'Use the private variable, _$BasicConfig, instead ' 'and update the `over_react` lower bound to version 4.1.0. ' 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') -final UiFactoryConfig<_$$BasicProps> $BasicConfig = _$BasicConfig; +final dynamic $BasicConfig = _$BasicConfig; final UiFactoryConfig<_$$BasicProps> _$SimpleConfig = UiFactoryConfig( propsFactory: PropsFactory( @@ -145,7 +145,7 @@ final UiFactoryConfig<_$$BasicProps> _$SimpleConfig = UiFactoryConfig( @Deprecated(r'Use the private variable, _$SimpleConfig, instead ' 'and update the `over_react` lower bound to version 4.1.0. ' 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') -final UiFactoryConfig<_$$BasicProps> $SimpleConfig = _$SimpleConfig; +final dynamic $SimpleConfig = _$SimpleConfig; // Concrete props implementation. // @@ -229,7 +229,7 @@ final UiFactoryConfig<_$$FooProps> _$FooConfig = UiFactoryConfig( @Deprecated(r'Use the private variable, _$FooConfig, instead ' 'and update the `over_react` lower bound to version 4.1.0. ' 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') -final UiFactoryConfig<_$$FooProps> $FooConfig = _$FooConfig; +final dynamic $FooConfig = _$FooConfig; // Concrete props implementation. // diff --git a/example/builder/src/functional_consumed_props.over_react.g.dart b/example/builder/src/functional_consumed_props.over_react.g.dart index 20229d2d0..5141d43ce 100644 --- a/example/builder/src/functional_consumed_props.over_react.g.dart +++ b/example/builder/src/functional_consumed_props.over_react.g.dart @@ -85,8 +85,7 @@ final UiFactoryConfig<_$$SomeParentProps> _$SomeParentConfig = UiFactoryConfig( @Deprecated(r'Use the private variable, _$SomeParentConfig, instead ' 'and update the `over_react` lower bound to version 4.1.0. ' 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') -final UiFactoryConfig<_$$SomeParentProps> $SomeParentConfig = - _$SomeParentConfig; +final dynamic $SomeParentConfig = _$SomeParentConfig; // Concrete props implementation. // @@ -175,7 +174,7 @@ final UiFactoryConfig<_$$SomeChildProps> _$SomeChildConfig = UiFactoryConfig( @Deprecated(r'Use the private variable, _$SomeChildConfig, instead ' 'and update the `over_react` lower bound to version 4.1.0. ' 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') -final UiFactoryConfig<_$$SomeChildProps> $SomeChildConfig = _$SomeChildConfig; +final dynamic $SomeChildConfig = _$SomeChildConfig; // Concrete props implementation. // diff --git a/example/hooks/use_callback_example.over_react.g.dart b/example/hooks/use_callback_example.over_react.g.dart index 659814427..e8b2a6d8d 100644 --- a/example/hooks/use_callback_example.over_react.g.dart +++ b/example/hooks/use_callback_example.over_react.g.dart @@ -37,8 +37,7 @@ final UiFactoryConfig<_$$UseCallbackExampleProps> _$UseCallbackExampleConfig = @Deprecated(r'Use the private variable, _$UseCallbackExampleConfig, instead ' 'and update the `over_react` lower bound to version 4.1.0. ' 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') -final UiFactoryConfig<_$$UseCallbackExampleProps> $UseCallbackExampleConfig = - _$UseCallbackExampleConfig; +final dynamic $UseCallbackExampleConfig = _$UseCallbackExampleConfig; // Concrete props implementation. // diff --git a/example/hooks/use_context_example.over_react.g.dart b/example/hooks/use_context_example.over_react.g.dart index 55c567d3c..3f104fe6e 100644 --- a/example/hooks/use_context_example.over_react.g.dart +++ b/example/hooks/use_context_example.over_react.g.dart @@ -56,8 +56,7 @@ final UiFactoryConfig<_$$UseContextExampleProps> _$UseContextExampleConfig = @Deprecated(r'Use the private variable, _$UseContextExampleConfig, instead ' 'and update the `over_react` lower bound to version 4.1.0. ' 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') -final UiFactoryConfig<_$$UseContextExampleProps> $UseContextExampleConfig = - _$UseContextExampleConfig; +final dynamic $UseContextExampleConfig = _$UseContextExampleConfig; // Concrete props implementation. // @@ -142,8 +141,7 @@ final UiFactoryConfig<_$$NewContextProviderProps> _$NewContextProviderConfig = @Deprecated(r'Use the private variable, _$NewContextProviderConfig, instead ' 'and update the `over_react` lower bound to version 4.1.0. ' 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') -final UiFactoryConfig<_$$NewContextProviderProps> $NewContextProviderConfig = - _$NewContextProviderConfig; +final dynamic $NewContextProviderConfig = _$NewContextProviderConfig; // Concrete props implementation. // diff --git a/example/hooks/use_debug_value_example.over_react.g.dart b/example/hooks/use_debug_value_example.over_react.g.dart index 2c9d16db5..ea47ed8e0 100644 --- a/example/hooks/use_debug_value_example.over_react.g.dart +++ b/example/hooks/use_debug_value_example.over_react.g.dart @@ -69,8 +69,7 @@ final UiFactoryConfig<_$$FriendListItemProps> _$FriendListItemConfig = @Deprecated(r'Use the private variable, _$FriendListItemConfig, instead ' 'and update the `over_react` lower bound to version 4.1.0. ' 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') -final UiFactoryConfig<_$$FriendListItemProps> $FriendListItemConfig = - _$FriendListItemConfig; +final dynamic $FriendListItemConfig = _$FriendListItemConfig; // Concrete props implementation. // @@ -155,8 +154,7 @@ final UiFactoryConfig<_$$UseDebugValueExampleProps> @Deprecated(r'Use the private variable, _$UseDebugValueExampleConfig, instead ' 'and update the `over_react` lower bound to version 4.1.0. ' 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') -final UiFactoryConfig<_$$UseDebugValueExampleProps> - $UseDebugValueExampleConfig = _$UseDebugValueExampleConfig; +final dynamic $UseDebugValueExampleConfig = _$UseDebugValueExampleConfig; // Concrete props implementation. // diff --git a/example/hooks/use_imperative_handle_example.over_react.g.dart b/example/hooks/use_imperative_handle_example.over_react.g.dart index a895ad06a..bffe63743 100644 --- a/example/hooks/use_imperative_handle_example.over_react.g.dart +++ b/example/hooks/use_imperative_handle_example.over_react.g.dart @@ -80,8 +80,7 @@ final UiFactoryConfig<_$$FancyInputProps> _$FancyInputConfig = UiFactoryConfig( @Deprecated(r'Use the private variable, _$FancyInputConfig, instead ' 'and update the `over_react` lower bound to version 4.1.0. ' 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') -final UiFactoryConfig<_$$FancyInputProps> $FancyInputConfig = - _$FancyInputConfig; +final dynamic $FancyInputConfig = _$FancyInputConfig; // Concrete props implementation. // @@ -167,8 +166,8 @@ final UiFactoryConfig<_$$UseImperativeHandleExampleProps> r'Use the private variable, _$UseImperativeHandleExampleConfig, instead ' 'and update the `over_react` lower bound to version 4.1.0. ' 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') -final UiFactoryConfig<_$$UseImperativeHandleExampleProps> - $UseImperativeHandleExampleConfig = _$UseImperativeHandleExampleConfig; +final dynamic $UseImperativeHandleExampleConfig = + _$UseImperativeHandleExampleConfig; // Concrete props implementation. // diff --git a/example/hooks/use_layout_effect_example.over_react.g.dart b/example/hooks/use_layout_effect_example.over_react.g.dart index 6fdae10a2..daa3bc935 100644 --- a/example/hooks/use_layout_effect_example.over_react.g.dart +++ b/example/hooks/use_layout_effect_example.over_react.g.dart @@ -38,8 +38,7 @@ final UiFactoryConfig<_$$UseLayoutEffectProps> _$UseLayoutEffectExampleConfig = r'Use the private variable, _$UseLayoutEffectExampleConfig, instead ' 'and update the `over_react` lower bound to version 4.1.0. ' 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') -final UiFactoryConfig<_$$UseLayoutEffectProps> $UseLayoutEffectExampleConfig = - _$UseLayoutEffectExampleConfig; +final dynamic $UseLayoutEffectExampleConfig = _$UseLayoutEffectExampleConfig; // Concrete props implementation. // diff --git a/example/hooks/use_memo_example.over_react.g.dart b/example/hooks/use_memo_example.over_react.g.dart index 4d788124f..eb6dc2049 100644 --- a/example/hooks/use_memo_example.over_react.g.dart +++ b/example/hooks/use_memo_example.over_react.g.dart @@ -37,8 +37,7 @@ final UiFactoryConfig<_$$UseMemoExampleProps> _$UseMemoExampleConfig = @Deprecated(r'Use the private variable, _$UseMemoExampleConfig, instead ' 'and update the `over_react` lower bound to version 4.1.0. ' 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') -final UiFactoryConfig<_$$UseMemoExampleProps> $UseMemoExampleConfig = - _$UseMemoExampleConfig; +final dynamic $UseMemoExampleConfig = _$UseMemoExampleConfig; // Concrete props implementation. // diff --git a/example/hooks/use_reducer_example.over_react.g.dart b/example/hooks/use_reducer_example.over_react.g.dart index 2e3c0c66d..dcc86b197 100644 --- a/example/hooks/use_reducer_example.over_react.g.dart +++ b/example/hooks/use_reducer_example.over_react.g.dart @@ -52,8 +52,7 @@ final UiFactoryConfig<_$$UseReducerExampleProps> _$UseReducerExampleConfig = @Deprecated(r'Use the private variable, _$UseReducerExampleConfig, instead ' 'and update the `over_react` lower bound to version 4.1.0. ' 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') -final UiFactoryConfig<_$$UseReducerExampleProps> $UseReducerExampleConfig = - _$UseReducerExampleConfig; +final dynamic $UseReducerExampleConfig = _$UseReducerExampleConfig; // Concrete props implementation. // diff --git a/example/hooks/use_ref_example.over_react.g.dart b/example/hooks/use_ref_example.over_react.g.dart index a28db4854..167e92355 100644 --- a/example/hooks/use_ref_example.over_react.g.dart +++ b/example/hooks/use_ref_example.over_react.g.dart @@ -37,8 +37,7 @@ final UiFactoryConfig<_$$UseRefExampleProps> _$UseRefExampleConfig = @Deprecated(r'Use the private variable, _$UseRefExampleConfig, instead ' 'and update the `over_react` lower bound to version 4.1.0. ' 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') -final UiFactoryConfig<_$$UseRefExampleProps> $UseRefExampleConfig = - _$UseRefExampleConfig; +final dynamic $UseRefExampleConfig = _$UseRefExampleConfig; // Concrete props implementation. // diff --git a/example/hooks/use_state_example.over_react.g.dart b/example/hooks/use_state_example.over_react.g.dart index 58d173b67..0c7dea73f 100644 --- a/example/hooks/use_state_example.over_react.g.dart +++ b/example/hooks/use_state_example.over_react.g.dart @@ -37,8 +37,7 @@ final UiFactoryConfig<_$$UseStateExampleProps> _$UseStateExampleConfig = @Deprecated(r'Use the private variable, _$UseStateExampleConfig, instead ' 'and update the `over_react` lower bound to version 4.1.0. ' 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') -final UiFactoryConfig<_$$UseStateExampleProps> $UseStateExampleConfig = - _$UseStateExampleConfig; +final dynamic $UseStateExampleConfig = _$UseStateExampleConfig; // Concrete props implementation. // diff --git a/lib/src/builder/codegen/typed_map_impl_generator.dart b/lib/src/builder/codegen/typed_map_impl_generator.dart index 54c00138f..acd0e6cf6 100644 --- a/lib/src/builder/codegen/typed_map_impl_generator.dart +++ b/lib/src/builder/codegen/typed_map_impl_generator.dart @@ -398,7 +398,7 @@ class _TypedMapImplGenerator extends TypedMapImplGenerator { '@Deprecated(r\'Use the private variable, ${factoryName.privateConfigName}, instead \'\n' '\'and update the `over_react` lower bound to version 4.1.0. \'\n' '\'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650\')\n' - 'final UiFactoryConfig<${names.implName}> ' + 'final dynamic ' // ignore: deprecated_member_use_from_same_package '${factoryName.publicConfigName} = ${factoryName.privateConfigName};\n\n'; } diff --git a/test/over_react/component/memo_test.over_react.g.dart b/test/over_react/component/memo_test.over_react.g.dart index 25ba3d1da..9ea39f1fb 100644 --- a/test/over_react/component/memo_test.over_react.g.dart +++ b/test/over_react/component/memo_test.over_react.g.dart @@ -226,8 +226,7 @@ final UiFactoryConfig<_$$FunctionCustomPropsProps> _$FunctionCustomPropsConfig = @Deprecated(r'Use the private variable, _$FunctionCustomPropsConfig, instead ' 'and update the `over_react` lower bound to version 4.1.0. ' 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') -final UiFactoryConfig<_$$FunctionCustomPropsProps> $FunctionCustomPropsConfig = - _$FunctionCustomPropsConfig; +final dynamic $FunctionCustomPropsConfig = _$FunctionCustomPropsConfig; // Concrete props implementation. // diff --git a/test/over_react/component/ref_util_test.over_react.g.dart b/test/over_react/component/ref_util_test.over_react.g.dart index 52dba2c53..f7499df1c 100644 --- a/test/over_react/component/ref_util_test.over_react.g.dart +++ b/test/over_react/component/ref_util_test.over_react.g.dart @@ -208,8 +208,7 @@ final UiFactoryConfig<_$$BasicUiFunctionProps> _$BasicUiFunctionConfig = @Deprecated(r'Use the private variable, _$BasicUiFunctionConfig, instead ' 'and update the `over_react` lower bound to version 4.1.0. ' 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') -final UiFactoryConfig<_$$BasicUiFunctionProps> $BasicUiFunctionConfig = - _$BasicUiFunctionConfig; +final dynamic $BasicUiFunctionConfig = _$BasicUiFunctionConfig; // Concrete props implementation. // @@ -295,8 +294,8 @@ final UiFactoryConfig<_$$SecondaryBasicUiFunctionProps> r'Use the private variable, _$TopLevelForwardUiRefFunctionConfig, instead ' 'and update the `over_react` lower bound to version 4.1.0. ' 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') -final UiFactoryConfig<_$$SecondaryBasicUiFunctionProps> - $TopLevelForwardUiRefFunctionConfig = _$TopLevelForwardUiRefFunctionConfig; +final dynamic $TopLevelForwardUiRefFunctionConfig = + _$TopLevelForwardUiRefFunctionConfig; // Concrete props implementation. // diff --git a/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/function_component_test.over_react.g.dart b/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/function_component_test.over_react.g.dart index 597ee8447..c4f639e3e 100644 --- a/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/function_component_test.over_react.g.dart +++ b/test/over_react/component_declaration/builder_integration_tests/new_boilerplate/function_component_test.over_react.g.dart @@ -188,7 +188,7 @@ final UiFactoryConfig<_$$TestProps> _$TestConfig = UiFactoryConfig( @Deprecated(r'Use the private variable, _$TestConfig, instead ' 'and update the `over_react` lower bound to version 4.1.0. ' 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') -final UiFactoryConfig<_$$TestProps> $TestConfig = _$TestConfig; +final dynamic $TestConfig = _$TestConfig; final UiFactoryConfig<_$$TestProps> _$TestPublicConfig = UiFactoryConfig( propsFactory: PropsFactory( @@ -200,7 +200,7 @@ final UiFactoryConfig<_$$TestProps> _$TestPublicConfig = UiFactoryConfig( @Deprecated(r'Use the private variable, _$TestPublicConfig, instead ' 'and update the `over_react` lower bound to version 4.1.0. ' 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') -final UiFactoryConfig<_$$TestProps> $TestPublicConfig = _$TestPublicConfig; +final dynamic $TestPublicConfig = _$TestPublicConfig; final UiFactoryConfig<_$$TestProps> _$NoLHSTestConfig = UiFactoryConfig( propsFactory: PropsFactory( @@ -212,7 +212,7 @@ final UiFactoryConfig<_$$TestProps> _$NoLHSTestConfig = UiFactoryConfig( @Deprecated(r'Use the private variable, _$NoLHSTestConfig, instead ' 'and update the `over_react` lower bound to version 4.1.0. ' 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') -final UiFactoryConfig<_$$TestProps> $NoLHSTestConfig = _$NoLHSTestConfig; +final dynamic $NoLHSTestConfig = _$NoLHSTestConfig; final UiFactoryConfig<_$$TestProps> _$_TestConfig = UiFactoryConfig( propsFactory: PropsFactory( @@ -224,7 +224,7 @@ final UiFactoryConfig<_$$TestProps> _$_TestConfig = UiFactoryConfig( @Deprecated(r'Use the private variable, _$_TestConfig, instead ' 'and update the `over_react` lower bound to version 4.1.0. ' 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') -final UiFactoryConfig<_$$TestProps> $_TestConfig = _$_TestConfig; +final dynamic $_TestConfig = _$_TestConfig; // Concrete props implementation. // diff --git a/test/vm_tests/builder/codegen_test.dart b/test/vm_tests/builder/codegen_test.dart index b1c3a4449..6d7c3ebab 100644 --- a/test/vm_tests/builder/codegen_test.dart +++ b/test/vm_tests/builder/codegen_test.dart @@ -667,7 +667,7 @@ main() { '@Deprecated(r\'Use the private variable, _\$${factoryName}Config, instead \'\n' '\'and update the `over_react` lower bound to version 4.1.0. \'\n' '\'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650\')\n' - 'final UiFactoryConfig<_\$\$$propsName> ' + 'final dynamic ' '\$${factoryName}Config = _\$${factoryName}Config;\n\n'; } diff --git a/web/component2/src/demos/ref.over_react.g.dart b/web/component2/src/demos/ref.over_react.g.dart index 29553684b..bbc914231 100644 --- a/web/component2/src/demos/ref.over_react.g.dart +++ b/web/component2/src/demos/ref.over_react.g.dart @@ -561,8 +561,7 @@ final UiFactoryConfig<_$$FancyButtonProps> _$FancyButtonConfig = @Deprecated(r'Use the private variable, _$FancyButtonConfig, instead ' 'and update the `over_react` lower bound to version 4.1.0. ' 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') -final UiFactoryConfig<_$$FancyButtonProps> $FancyButtonConfig = - _$FancyButtonConfig; +final dynamic $FancyButtonConfig = _$FancyButtonConfig; // Concrete props implementation. // @@ -646,7 +645,7 @@ final UiFactoryConfig<_$$Foo2Props> _$Foo2Config = UiFactoryConfig( @Deprecated(r'Use the private variable, _$Foo2Config, instead ' 'and update the `over_react` lower bound to version 4.1.0. ' 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') -final UiFactoryConfig<_$$Foo2Props> $Foo2Config = _$Foo2Config; +final dynamic $Foo2Config = _$Foo2Config; // Concrete props implementation. // @@ -735,7 +734,7 @@ final UiFactoryConfig<_$$BazProps> _$BazConfig = UiFactoryConfig( @Deprecated(r'Use the private variable, _$BazConfig, instead ' 'and update the `over_react` lower bound to version 4.1.0. ' 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') -final UiFactoryConfig<_$$BazProps> $BazConfig = _$BazConfig; +final dynamic $BazConfig = _$BazConfig; // Concrete props implementation. // @@ -820,8 +819,7 @@ final UiFactoryConfig<_$$RefDemoProps> _$RefDemoContainerConfig = @Deprecated(r'Use the private variable, _$RefDemoContainerConfig, instead ' 'and update the `over_react` lower bound to version 4.1.0. ' 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') -final UiFactoryConfig<_$$RefDemoProps> $RefDemoContainerConfig = - _$RefDemoContainerConfig; +final dynamic $RefDemoContainerConfig = _$RefDemoContainerConfig; // Concrete props implementation. // @@ -906,8 +904,7 @@ final UiFactoryConfig<_$$RefDemoSectionProps> _$RefDemoSectionConfig = @Deprecated(r'Use the private variable, _$RefDemoSectionConfig, instead ' 'and update the `over_react` lower bound to version 4.1.0. ' 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') -final UiFactoryConfig<_$$RefDemoSectionProps> $RefDemoSectionConfig = - _$RefDemoSectionConfig; +final dynamic $RefDemoSectionConfig = _$RefDemoSectionConfig; // Concrete props implementation. // @@ -991,8 +988,7 @@ final UiFactoryConfig<_$$RefDemoHocProps> _$RefDemoHocConfig = UiFactoryConfig( @Deprecated(r'Use the private variable, _$RefDemoHocConfig, instead ' 'and update the `over_react` lower bound to version 4.1.0. ' 'For information on why this is deprecated, see https://github.com/Workiva/over_react/pull/650') -final UiFactoryConfig<_$$RefDemoHocProps> $RefDemoHocConfig = - _$RefDemoHocConfig; +final dynamic $RefDemoHocConfig = _$RefDemoHocConfig; // Concrete props implementation. // From 39707d2f7c6046afe5611af026dd7c49bfd6c1c2 Mon Sep 17 00:00:00 2001 From: Joe Bingham Date: Thu, 14 Jan 2021 12:42:43 -0700 Subject: [PATCH 12/54] Update non-function snippets --- snippets/README.md | 1 + snippets/snippets.json | 14 +++++++++----- snippets/snippets.xml | 28 ++++++---------------------- 3 files changed, 16 insertions(+), 27 deletions(-) diff --git a/snippets/README.md b/snippets/README.md index 8193b9ece..01a83bf5a 100644 --- a/snippets/README.md +++ b/snippets/README.md @@ -6,6 +6,7 @@ Below is a list of all available over_react snippets and their Triggers for Webs | -------: | ------- | | `orStless` | Stateless component skeleton with abbreviated props declaration | | `orStful` | Stateful component skeleton with abbreviated props and state declarations | +| `orStlessConnect` | Stateless component skeleton with the generated factory wrapped in `connect` | | `orFunc` | Function component skeleton with abbreviated props declaration | | `orAdvStless` | Stateless component skeleton with a props class alias| | `orAdvStful` | Stateful component skeleton with props and state class aliases| diff --git a/snippets/snippets.json b/snippets/snippets.json index 34df4f2ee..77a199ec0 100644 --- a/snippets/snippets.json +++ b/snippets/snippets.json @@ -6,7 +6,8 @@ "", "part '${1:FileName}.over_react.g.dart';", "", - "UiFactory<${2:MyComponent}Props> ${2:MyComponent} = _$${2:MyComponent}; // ignore: undefined_identifier", + "UiFactory<${2:MyComponent}Props> ${2:MyComponent} =", + " castUiFactory(_$${2:MyComponent}); // ignore: undefined_identifier", "", "mixin ${2:MyComponent}PropsMixin on UiProps {}", "", @@ -29,7 +30,8 @@ "", "part '${1:FileName}.over_react.g.dart';", "", - "UiFactory<${2:MyComponent}Props> ${2:MyComponent} = _$${2:MyComponent}; // ignore: undefined_identifier", + "UiFactory<${2:MyComponent}Props> ${2:MyComponent} =", + " castUiFactory(_$${2:MyComponent}); // ignore: undefined_identifier", "", "mixin ${2:MyComponent}PropsMixin on UiProps {}", "", @@ -59,7 +61,8 @@ "", "part '${1:FileName}.over_react.g.dart';", "", - "UiFactory<${2:MyComponent}Props> ${2:MyComponent} = _$${2:MyComponent}; // ignore: undefined_identifier", + "UiFactory<${2:MyComponent}Props> ${2:MyComponent} =", + " castUiFactory(_$${2:MyComponent}); // ignore: undefined_identifier", "", "mixin ${2:MyComponent}Props on UiProps {}", "", @@ -80,7 +83,8 @@ "", "part '${1:FileName}.over_react.g.dart';", "", - "UiFactory<${2:MyComponent}Props> ${2:MyComponent} = _$${2:MyComponent}; // ignore: undefined_identifier", + "UiFactory<${2:MyComponent}Props> ${2:MyComponent} =", + " castUiFactory(_$${2:MyComponent}); // ignore: undefined_identifier", "", "mixin ${2:MyComponent}Props on UiProps {}", "", @@ -110,7 +114,7 @@ "UiFactory<${2:MyComponent}Props> ${2:MyComponent} = connect<${3:SomeReduxStoreState}, ${2:MyComponent}Props>(", "\tmapStateToProps: (state) => (${2:MyComponent}()),", "\tmapDispatchToProps: (dispatch) => (${2:MyComponent}()),", - ")(_$${2:MyComponent}); // ignore: undefined_identifier", + ")(castUiFactory(_$${2:MyComponent})); // ignore: undefined_identifier", "", "mixin ${2:MyComponent}Props on UiProps {}", "", diff --git a/snippets/snippets.xml b/snippets/snippets.xml index 7f3eeb8f2..38791b60b 100644 --- a/snippets/snippets.xml +++ b/snippets/snippets.xml @@ -1,51 +1,35 @@ - - -