refactor: extract framework-agnostic core into @a2ui/core package#532
refactor: extract framework-agnostic core into @a2ui/core package#532abalmush wants to merge 2 commits intogoogle:mainfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This is a great refactoring that extracts the framework-agnostic logic into a new @a2ui/core package. This will significantly improve reusability for other frameworks. The new package is well-structured and comes with a comprehensive test suite.
My review focuses on the new core logic and I've identified a few areas for improvement:
- A potential bug in a regex used for path resolution.
- An inconsistency between a type definition and its corresponding type guard.
- Opportunities to refactor repetitive code and clarify the public API of the new package.
Overall, this is a solid piece of work. Addressing these points will improve the robustness and maintainability of the new core package.
Extract the data processing, type definitions, guards, and message handling logic from @a2ui/lit into a new @a2ui/core package. This enables React, Vue, and other framework developers to integrate A2UI without reimplementing core functionality. The new @a2ui/core package includes: - A2uiMessageProcessor for processing server-to-client messages - Type definitions for all A2UI components and primitives - Type guards for runtime type checking - Event type definitions The @a2ui/lit and @a2ui/angular packages now depend on @a2ui/core and re-export its types for backwards compatibility.
- Fix regex path stripping: escape dot and simplify replacement chain - Refactor buildNodeRecursive: replace switch with type guard map - Fix ResolvedCard: use union type for mutually exclusive properties - Consolidate exports: remove duplicate top-level exports, keep namespaces
6dfefc7 to
5169383
Compare
Summary
#195
@a2ui/litinto a new@a2ui/corepackage@a2ui/litand@a2ui/angularProblem
External developers who want to integrate A2UI with their existing component libraries (React, Vue, or custom design systems) currently have to rebuild core functionality from scratch. The data processing, path resolution, and message handling logic lives inside
@a2ui/lit, which means:A2uiMessageProcessorand all the JSON Pointer utilitiesSolution
Create a new
@a2ui/corepackage containing:A2uiMessageProcessorTypesPrimitivesGuardsEventsChanges
New package:
renderers/core/src/processor/model-processor.ts- Message processor implementationsrc/types/- All type definitionssrc/guards/- Type guard functionssrc/events/- Event definitionsModified:
renderers/lit/@a2ui/coreModified:
renderers/angular/@a2ui/core@a2ui/coretoallowedNonPeerDependencies