feat(web_core): add WebComponentImplementation helpers and refactor basic catalog - #2596
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the isWebComponentImplementation type guard function to check if a component API or implementation is a WebComponentImplementation, along with corresponding unit tests and a changelog entry. The feedback suggests improving the type guard by also validating the presence and types of name and schema properties, as WebComponentImplementation extends ComponentApi and requires these fields for full type safety.
ecb2dcd to
19abde0
Compare
19abde0 to
32a9afe
Compare
32a9afe to
4e6cdc7
Compare
4e6cdc7 to
d012fd2
Compare
d012fd2 to
bf26acf
Compare
bf26acf to
550966e
Compare
550966e to
8a45eda
Compare
8a45eda to
6c8685c
Compare
6c8685c to
6d0dfb9
Compare
6d0dfb9 to
b8147f2
Compare
b8147f2 to
a09ae2d
Compare
a09ae2d to
5af8c02
Compare
5af8c02 to
07ca19c
Compare
07ca19c to
09dbea1
Compare
09dbea1 to
04cbdd7
Compare
| export const A2uiAudioPlayer = createWebComponentImplementation( | ||
| AudioPlayerApi, | ||
| A2uiAudioPlayerElement, | ||
| ); |
There was a problem hiding this comment.
(Same comment as in the previous entry, maybe it's enough to export createWebComponentImplementation and isWebComponentImplementation to users of web_core (the catalog implementers) and they can create this glue over there?
Or maybe all catalogs are going to use these A2uiAudioPlayer implementation instead of the Element? In that case, do we need to re-export the A2uiAudioPlayerElement custom element implementation?
My hunch is that we don't need to export both the WebComponentImplementation and the BasicCatalogA2uiLitElement classes?
Overview
Implements the
createWebComponentImplementationhelper function andisWebComponentImplementationtype guard in@a2ui/web_core/v0_9, and refactors all basic Lit components inrenderers/web_core/src/v0_9/basic_catalog/components/to export definitions usingcreateWebComponentImplementation.Key Changes
@a2ui/web_core/v0_9:createWebComponentImplementation: Pairs aComponentApidefinition, Custom Element class, and tag name into aWebComponentImplementation, automatically registering the element incustomElementsif not already defined.isWebComponentImplementation: Structural duck-typing check verifying whether a component definition specifies a valid stringtagName.AudioPlayer,Button,Card,CheckBox,ChoicePicker,Column,DateTimeInput,Divider,Icon,Image,List,Modal,Row,Slider,Tabs,Text,TextField,Video) to export universal definitions usingcreateWebComponentImplementation.createWebComponentImplementationandisWebComponentImplementation.Verification
yarn --cwd renderers/web_core test(all 474 unit and conformance tests pass)yarn --cwd renderers/web_core lint(clean, 0 errors)./scripts/fix_format.sh --check(passes)