You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 7be54df
Browse filesBrowse the repository at this point in the historyBrowse files
fix(angular): resolve universal element injectors per renderer (#4129)
### Summary
With `useUniversalComponents`, every catalog entry renders as a custom element that looks up the Angular `Injector` it needs when it connects. This PR fixes that lookup for pages with more than one renderer, and lets plain `{...api, component}` entries render inside universal containers.
An `AngularWcHost` now takes its own `injector` first. Then it tries the nearest `ComponentHostComponent` above it in the DOM, then the `A2uiRendererService` that owns its surface, and finally a stack of fallback injectors. Destroying one renderer no longer clears the fallback of another.
**Breaking:** with `useUniversalComponents: true`, plain `{...api, component}` entries now mount inside an `<a2ui-ng-<name>>` host element.
### Changes
- `AngularCatalog` adds `tagName` and `element` to plain `{...api, component}` entries, so universal containers can render them. Extensible entries are updated in place to keep their identity.
- `AngularWcHost` resolves its injector from the DOM host, then the surface group, then the fallback stack. `ComponentHostComponent` and `A2uiRendererService` register their injectors for this lookup.
- `A2uiLitElement.adoptLightDomStyles` caches scoped styles per element class instead of in inherited static fields, so a subclass registered under another tag gets its own sheet.
### Verification
- `yarn --cwd typescript/core/web_core test` and the Angular karma suite (`ng test lib`), with the new specs confirmed in the karma output.
- `yarn lint` in both packages, the web_core and Angular builds, and `./scripts/fix_format.sh --check`.
Part of #4148.
Copy file name to clipboardExpand all lines: typescript/core/web_core/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,6 +40,7 @@
40
40
- (v1_0) Function calls inside `${...}` template expressions of `formatString` now inherit the `catalogId` that the enclosing `formatString` call resolved to (preserving reserved `@`-prefixed system calls such as `${@index()}` as catalogless), so nested template calls resolve against `formatString`'s catalog on defaultless surfaces and when the surface defines a different default `catalogId` ([#3727](https://github.com/a2ui-project/a2ui/issues/3727), [#4028](https://github.com/a2ui-project/a2ui/pull/4028)).
41
41
-`extractRefFields`, `NodeResolver`, `GenericBinder`, `scrapeSchemaBehavior`, `scrapeComponentBehavior` (newly exported), and `Catalog.componentRefMap` now resolve child references and dynamic bindings across wrapped (`ZodCatch`, `ZodPipeline`), composite (`ZodIntersection`, `ZodUnion`, `ZodDiscriminatedUnion`), empty-shape (`z.object({})`), open (`.passthrough()`, `.catchall()`, `z.record()`, `z.any()`, `z.unknown()`), and unannotated `child` / `children` component schemas ([#3783](https://github.com/a2ui-project/a2ui/issues/3783), [#3938](https://github.com/a2ui-project/a2ui/pull/3938)).
42
42
- Export `getMarkdownRenderer`, `markdown`, and `setMarkdownRenderer` from `@a2ui/web_core/universal`, make `Catalog<T, F>` covariant in `T` and `F`, and infer `T` from the `catalogs` argument of `new MessageProcessor(catalogs)` so `SurfaceModel` instances carry the component implementation type of their registered catalogs ([#3423](https://github.com/a2ui-project/a2ui/issues/3423), [#4181](https://github.com/a2ui-project/a2ui/pull/4181)).
43
+
-`A2uiLitElement.adoptLightDomStyles` scopes styles per element class, so a subclass registered under another tag gets its own stylesheet instead of reusing its parent's. [#4129](https://github.com/a2ui-project/a2ui/pull/4129)
Copy file name to clipboardExpand all lines: typescript/renderers/angular/CHANGELOG.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,8 +2,10 @@
2
2
3
3
-**BREAKING CHANGE**: `ComponentHostComponent` no longer assigns `element.context` when mounting universal Web Components, and `ComponentBinder.bind(context)` and `AngularWcHost.context` are deprecated in favor of `ComponentBinder.bindNode(node)` and `AngularWcHost.node`. Recommended migration: implement `node` on custom `A2uiWebComponentElement` classes instead of `context`. [#3841](https://github.com/a2ui-project/a2ui/pull/3841)
4
4
- **BREAKING CHANGE**: The host element of an Angular catalog component (`<a2ui-v09-component-host>`, or `<a2ui-ng-<name>>` from `toWebComponent`) applies the component's `accessibility` attributes: `aria-live`, `aria-hidden`, and `inert` on the host, and `aria-label` and `aria-description` on the host with `role="group"` (unless the host already has a `role`). Add `AccessibilityTargetDirective` (`a2uiAccessibilityTarget`), which moves `aria-label` and `aria-description` to the element it marks and adds `aria-invalid="true"` there while a check fails, and `ValidationErrorsDirective` (`a2uiValidationErrors`), which marks the element showing the validation errors so the target gets `aria-describedby` pointing at it. The v0.9 native basic catalog marks the control of `Button`, `CheckBox`, `Slider`, `TextField`, `Image`, `AudioPlayer`, and `Video`, and wraps the error messages of `Slider` and `TextField` in `<div class="a2ui-validation-errors">`. Recommended migration: a component that already sets `aria-label` from `props().accessibility` on an inner element should mark that element with `a2uiAccessibilityTarget`, or the label is announced twice. [#3499](https://github.com/a2ui-project/a2ui/issues/3499), [#3869](https://github.com/a2ui-project/a2ui/pull/3869)
5
+
-**BREAKING CHANGE**: With `useUniversalComponents: true`, plain `{...api, component}` catalog entries now mount inside an `<a2ui-ng-<name>>` host element, as `createComponentImplementation` entries already do. Recommended migration: update styles and selectors that expect the component as a direct child of `<a2ui-v09-component-host>`. [#4129](https://github.com/a2ui-project/a2ui/pull/4129)
5
6
-`ListComponent` hides the item of a child that renders nothing, so it leaves no empty marker or gap. `<a2ui-v09-component-host>` carries `data-a2ui-empty` while it renders nothing. [#2013](https://github.com/a2ui-project/a2ui/issues/2013)
6
7
- Import core and universal symbols from `@a2ui/web_core` and `@a2ui/web_core/universal` instead of `@a2ui/web_core/v0_9/*` across `@a2ui/angular`'s version-agnostic `core/` and `catalog/` runtime, and strip both v0.9 (`{path}`, `{call}`) and v1.0 (`{'@path'}`, `{'@call'}`) dynamic AST branches in `ComponentApiToProps`. [#4182](https://github.com/a2ui-project/a2ui/pull/4182)
8
+
-`AngularCatalog` adds `tagName` and `element` to plain `{...api, component}` entries in place, keeping entry identity. Universal elements now resolve their Angular `Injector` from the nearest `ComponentHostComponent`, then from the `A2uiRendererService` owning their surface, so several renderers can share a page. [#4129](https://github.com/a2ui-project/a2ui/pull/4129)
0 commit comments