Context
Currently in genui.dart:L16-17, we have to hide two classes in our exports due to name clashes:
export 'src/engine.dart' hide SurfaceAdded, SurfaceRemoved;
The classes are defined in two places:
- SurfaceUpdate events (Public UI-level updates for facades/consumers):
- Location: ui_models.dart:L402-438
- Classes:
SurfaceAdded, ComponentsUpdated, and SurfaceRemoved (subclasses of SurfaceUpdate).
- RegistryEvent events (Internal engine-level registry updates):
Proposed Solution
To make the API clean, robust, and unambiguous without needing hide clauses, we should prefix the event classes in surface_registry.dart to associate them explicitly with the registry.
1. Rename classes
In surface_registry.dart:
-
RegistryEvent $\rightarrow$ SurfaceRegistryEvent
-
SurfaceAdded $\rightarrow$ SurfaceRegistryAdded
-
SurfaceRemoved $\rightarrow$ SurfaceRegistryRemoved
-
SurfaceUpdated $\rightarrow$ SurfaceRegistryUpdated
2. Update surface controller
In surface_controller.dart
Update the mapping logic in surfaceUpdates (around L57-67) to match the new class names:
@override
Stream<SurfaceUpdate> get surfaceUpdates => _registry.events.map(
(e) => switch (e) {
surface_reg.SurfaceRegistryAdded(:final surfaceId, :final definition) =>
SurfaceAdded(surfaceId, definition),
surface_reg.SurfaceRegistryUpdated(:final surfaceId, :final definition) =>
ComponentsUpdated(surfaceId, definition),
surface_reg.SurfaceRegistryRemoved(:final surfaceId) =>
SurfaceRemoved(surfaceId),
},
);
Benefits
- Cleaner Exports: No need to hide classes in the main package entrypoint.
- Unambiguous Code: Developers importing internal libraries or both files directly won't run into naming collisions.
- Stronger Semantics: Clearly distinguishes between engine-internal registry state events (
SurfaceRegistryAdded) and public UI-level state events (SurfaceAdded).
Context
Currently in genui.dart:L16-17, we have to hide two classes in our exports due to name clashes:
The classes are defined in two places:
SurfaceAdded,ComponentsUpdated, andSurfaceRemoved(subclasses ofSurfaceUpdate).SurfaceAdded,SurfaceRemoved, andSurfaceUpdated(subclasses ofRegistryEvent).Proposed Solution
To make the API clean, robust, and unambiguous without needing
hideclauses, we should prefix the event classes in surface_registry.dart to associate them explicitly with the registry.1. Rename classes
In surface_registry.dart:
RegistryEventSurfaceRegistryEventSurfaceAddedSurfaceRegistryAddedSurfaceRemovedSurfaceRegistryRemovedSurfaceUpdatedSurfaceRegistryUpdated2. Update surface controller
In surface_controller.dart
Update the mapping logic in
surfaceUpdates(around L57-67) to match the new class names:Benefits
SurfaceRegistryAdded) and public UI-level state events (SurfaceAdded).