Skip to content

Commit

Permalink
chore: removing the feature prefix from the feature_extension descriptor
Browse files Browse the repository at this point in the history
  • Loading branch information
pavanpodila committed Mar 22, 2024
1 parent 4e068a0 commit 5d47d32
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
abstract class FeatureExtensionDescriptor {
abstract class ExtensionDescriptor {
final String title;

FeatureExtensionDescriptor({
ExtensionDescriptor({
required this.title,
});
}

abstract class FeatureExtensionBuilder {
abstract class ExtensionBuilder {
final String title;
final Type extensionType;

FeatureExtensionBuilder({
ExtensionBuilder({
required this.extensionType,
required this.title,
});

void build(List<FeatureExtensionDescriptor> extensions) {}
void build(List<ExtensionDescriptor> extensions) {}

void init() {}
void dispose() {}
Expand Down
4 changes: 2 additions & 2 deletions packages/system/vyuh_core/lib/feature_descriptor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ final class FeatureDescriptor {
final IconData? icon;
final FeatureInitFunction? init;

final List<FeatureExtensionDescriptor>? extensions;
final List<FeatureExtensionBuilder>? extensionBuilders;
final List<ExtensionDescriptor>? extensions;
final List<ExtensionBuilder>? extensionBuilders;

final RouteBuilderFunction _routes;
RouteBuilderFunction? get routes => _routes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import 'package:vyuh_core/vyuh_core.dart';

final class DefaultVyuhPlatform extends VyuhPlatform {
final Map<PluginType, Plugin> _pluginMap = {};
final Map<Type, FeatureExtensionBuilder> _featureExtensionBuilderMap = {};
final Map<Type, ExtensionBuilder> _featureExtensionBuilderMap = {};

late RoutingConfigNotifier _routingConfig;

Expand Down Expand Up @@ -184,8 +184,7 @@ final class DefaultVyuhPlatform extends VyuhPlatform {

void _initFeatureExtensions() {
final builders = features
.expand((element) =>
element.extensionBuilders ?? <FeatureExtensionBuilder>[])
.expand((element) => element.extensionBuilders ?? <ExtensionBuilder>[])
.groupListsBy((element) => element.extensionType);

for (final entry in builders.entries) {
Expand All @@ -199,8 +198,7 @@ final class DefaultVyuhPlatform extends VyuhPlatform {
}

final extensions = features
.expand(
(element) => element.extensions ?? <FeatureExtensionDescriptor>[])
.expand((element) => element.extensions ?? <ExtensionDescriptor>[])
.groupListsBy((element) => element.runtimeType);

extensions.forEach((runtimeType, descriptors) {
Expand Down
2 changes: 1 addition & 1 deletion packages/system/vyuh_core/lib/vyuh_core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export 'content/route_base.dart';
export 'content/serialization.dart';
export 'content/type_descriptor.dart';
export 'content/unknown.dart';
export 'extension.dart';
export 'feature_descriptor.dart';
export 'feature_extension.dart';
export 'plugin_types/analytics/analytics_plugin.dart';
export 'plugin_types/analytics/analytics_provider.dart';
export 'plugin_types/analytics/noop_analytics_provider.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:collection/collection.dart';
import 'package:vyuh_core/vyuh_core.dart';
import 'package:vyuh_extension_content/vyuh_extension_content.dart';

final class ContentExtensionBuilder extends FeatureExtensionBuilder {
final class ContentExtensionBuilder extends ExtensionBuilder {
final Map<Type, Map<String, FromJsonConverter>> _typeConverterMap = {};
final Map<String, ContentBuilder> _contentBuilderMap = {};

Expand All @@ -13,7 +13,7 @@ final class ContentExtensionBuilder extends FeatureExtensionBuilder {
);

@override
void build(List<FeatureExtensionDescriptor> extensions) {
void build(List<ExtensionDescriptor> extensions) {
final descriptors = extensions.cast<ContentExtensionDescriptor>();

final contentBuilders = descriptors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:vyuh_core/vyuh_core.dart';
import 'package:vyuh_extension_content/vyuh_extension_content.dart';

class ContentExtensionDescriptor extends FeatureExtensionDescriptor {
class ContentExtensionDescriptor extends ExtensionDescriptor {
ContentExtensionDescriptor({
this.contents,
this.contentBuilders,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:vyuh_core/vyuh_core.dart';
import 'script_runtime.dart' if (dart.library.html) 'web_script_runtime.dart'
as rt;

final class ScriptExtensionDescriptor extends FeatureExtensionDescriptor {
final class ScriptExtensionDescriptor extends ExtensionDescriptor {
final String name;

String get runtime => 'javascript';
Expand All @@ -16,13 +16,13 @@ final class ScriptExtensionDescriptor extends FeatureExtensionDescriptor {
: super(title: 'ScriptExtension: $name');
}

final class ScriptExtensionBuilder extends FeatureExtensionBuilder {
final class ScriptExtensionBuilder extends ExtensionBuilder {
ScriptExtensionBuilder()
: super(
extensionType: ScriptExtensionDescriptor, title: 'ScriptExtension');

@override
void build(List<FeatureExtensionDescriptor> extensions) {
void build(List<ExtensionDescriptor> extensions) {
for (final extension in extensions.cast<ScriptExtensionDescriptor>()) {
rt.ScriptRuntime.registerFunction(extension.name, extension.function);
}
Expand Down

0 comments on commit 5d47d32

Please sign in to comment.