@angular/elements 20.0.0-next.0 → 20.0.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/elements.mjs +9 -38
- package/fesm2022/elements.mjs.map +1 -1
- package/index.d.ts +78 -88
- package/package.json +2 -2
package/fesm2022/elements.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v20.0.0-next.
|
|
3
|
-
* (c) 2010-
|
|
2
|
+
* @license Angular v20.0.0-next.2
|
|
3
|
+
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { ComponentFactoryResolver, NgZone, ApplicationRef, ɵChangeDetectionScheduler, Injector, Version } from '@angular/core';
|
|
7
|
+
import { ComponentFactoryResolver, NgZone, ApplicationRef, ɵChangeDetectionScheduler as _ChangeDetectionScheduler, ɵisViewDirty as _isViewDirty, ɵmarkForRefresh as _markForRefresh, Injector, Version } from '@angular/core';
|
|
8
8
|
import { ReplaySubject, merge, Observable } from 'rxjs';
|
|
9
9
|
import { switchMap } from 'rxjs/operators';
|
|
10
10
|
|
|
@@ -34,18 +34,6 @@ function camelToDashCase(input) {
|
|
|
34
34
|
function isElement(node) {
|
|
35
35
|
return !!node && node.nodeType === Node.ELEMENT_NODE;
|
|
36
36
|
}
|
|
37
|
-
/**
|
|
38
|
-
* Check whether the input is a function.
|
|
39
|
-
*/
|
|
40
|
-
function isFunction(value) {
|
|
41
|
-
return typeof value === 'function';
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Convert a kebab-cased string to camelCased.
|
|
45
|
-
*/
|
|
46
|
-
function kebabToCamelCase(input) {
|
|
47
|
-
return input.replace(/-([a-z\d])/g, (_, char) => char.toUpperCase());
|
|
48
|
-
}
|
|
49
37
|
let _matches;
|
|
50
38
|
/**
|
|
51
39
|
* Check whether an `Element` matches a CSS selector.
|
|
@@ -65,12 +53,6 @@ function matchesSelector(el, selector) {
|
|
|
65
53
|
}
|
|
66
54
|
return el.nodeType === Node.ELEMENT_NODE ? _matches.call(el, selector) : false;
|
|
67
55
|
}
|
|
68
|
-
/**
|
|
69
|
-
* Test two values for strict equality, accounting for the fact that `NaN !== NaN`.
|
|
70
|
-
*/
|
|
71
|
-
function strictEquals(value1, value2) {
|
|
72
|
-
return value1 === value2 || (value1 !== value1 && value2 !== value2);
|
|
73
|
-
}
|
|
74
56
|
/** Gets a map of default set of attributes to observe and the properties they affect. */
|
|
75
57
|
function getDefaultAttributeToPropertyInputs(inputs) {
|
|
76
58
|
const attributeToPropertyInputs = {};
|
|
@@ -90,6 +72,8 @@ function getComponentInputs(component, injector) {
|
|
|
90
72
|
}
|
|
91
73
|
|
|
92
74
|
// NOTE: This is a (slightly improved) version of what is used in ngUpgrade's
|
|
75
|
+
// `DowngradeComponentAdapter`.
|
|
76
|
+
// TODO(gkalpak): Investigate if it makes sense to share the code.
|
|
93
77
|
function extractProjectableNodes(host, ngContentSelectors) {
|
|
94
78
|
const nodes = host.childNodes;
|
|
95
79
|
const projectableNodes = ngContentSelectors.map(() => []);
|
|
@@ -181,7 +165,7 @@ class ComponentNgElementStrategy {
|
|
|
181
165
|
this.inputMap = inputMap;
|
|
182
166
|
this.ngZone = this.injector.get(NgZone);
|
|
183
167
|
this.appRef = this.injector.get(ApplicationRef);
|
|
184
|
-
this.cdScheduler = injector.get(
|
|
168
|
+
this.cdScheduler = injector.get(_ChangeDetectionScheduler);
|
|
185
169
|
this.elementZone = typeof Zone === 'undefined' ? null : this.ngZone.run(() => Zone.current);
|
|
186
170
|
}
|
|
187
171
|
/**
|
|
@@ -246,12 +230,12 @@ class ComponentNgElementStrategy {
|
|
|
246
230
|
this.runInZone(() => {
|
|
247
231
|
this.componentRef.setInput(this.inputMap.get(property) ?? property, value);
|
|
248
232
|
// `setInput` won't mark the view dirty if the input didn't change from its previous value.
|
|
249
|
-
if (this.componentRef.hostView
|
|
233
|
+
if (_isViewDirty(this.componentRef.hostView)) {
|
|
250
234
|
// `setInput` will have marked the view dirty already, but also mark it for refresh. This
|
|
251
235
|
// guarantees the view will be checked even if the input is being set from within change
|
|
252
236
|
// detection. This provides backwards compatibility, since we used to unconditionally
|
|
253
237
|
// schedule change detection in addition to the current zone run.
|
|
254
|
-
this.componentRef.changeDetectorRef
|
|
238
|
+
_markForRefresh(this.componentRef.changeDetectorRef);
|
|
255
239
|
// Notifying the scheduler with `NotificationSource.CustomElement` causes a `tick()` to be
|
|
256
240
|
// scheduled unconditionally, even if the scheduler is otherwise disabled.
|
|
257
241
|
this.cdScheduler.notify(6 /* NotificationSource.CustomElement */);
|
|
@@ -426,20 +410,7 @@ function createCustomElement(component, config) {
|
|
|
426
410
|
/**
|
|
427
411
|
* @publicApi
|
|
428
412
|
*/
|
|
429
|
-
const VERSION = new Version('20.0.0-next.
|
|
430
|
-
|
|
431
|
-
/**
|
|
432
|
-
* @module
|
|
433
|
-
* @description
|
|
434
|
-
* Entry point for all public APIs of the `elements` package.
|
|
435
|
-
*/
|
|
436
|
-
// This file only reexports content of the `src` folder. Keep it that way.
|
|
437
|
-
|
|
438
|
-
// This file is not used to build this module. It is only used during editing
|
|
439
|
-
|
|
440
|
-
/**
|
|
441
|
-
* Generated bundle index. Do not edit.
|
|
442
|
-
*/
|
|
413
|
+
const VERSION = new Version('20.0.0-next.2');
|
|
443
414
|
|
|
444
415
|
export { NgElement, VERSION, createCustomElement };
|
|
445
416
|
//# sourceMappingURL=elements.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elements.mjs","sources":["../../../../../../packages/elements/src/utils.ts","../../../../../../packages/elements/src/extract-projectable-nodes.ts","../../../../../../packages/elements/src/component-factory-strategy.ts","../../../../../../packages/elements/src/create-custom-element.ts","../../../../../../packages/elements/src/version.ts","../../../../../../packages/elements/public_api.ts","../../../../../../packages/elements/index.ts","../../../../../../packages/elements/elements.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\nimport {ComponentFactoryResolver, Injector, Type} from '@angular/core';\n\n/**\n * Provide methods for scheduling the execution of a callback.\n */\nexport const scheduler = {\n /**\n * Schedule a callback to be called after some delay.\n *\n * Returns a function that when executed will cancel the scheduled function.\n */\n schedule(taskFn: () => void, delay: number): () => void {\n const id = setTimeout(taskFn, delay);\n return () => clearTimeout(id);\n },\n};\n\n/**\n * Convert a camelCased string to kebab-cased.\n */\nexport function camelToDashCase(input: string): string {\n return input.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);\n}\n\n/**\n * Check whether the input is an `Element`.\n */\nexport function isElement(node: Node | null): node is Element {\n return !!node && node.nodeType === Node.ELEMENT_NODE;\n}\n\n/**\n * Check whether the input is a function.\n */\nexport function isFunction(value: any): value is Function {\n return typeof value === 'function';\n}\n\n/**\n * Convert a kebab-cased string to camelCased.\n */\nexport function kebabToCamelCase(input: string): string {\n return input.replace(/-([a-z\\d])/g, (_, char) => char.toUpperCase());\n}\n\nlet _matches: (this: any, selector: string) => boolean;\n\n/**\n * Check whether an `Element` matches a CSS selector.\n * NOTE: this is duplicated from @angular/upgrade, and can\n * be consolidated in the future\n */\nexport function matchesSelector(el: any, selector: string): boolean {\n if (!_matches) {\n const elProto = <any>Element.prototype;\n _matches =\n elProto.matches ||\n elProto.matchesSelector ||\n elProto.mozMatchesSelector ||\n elProto.msMatchesSelector ||\n elProto.oMatchesSelector ||\n elProto.webkitMatchesSelector;\n }\n return el.nodeType === Node.ELEMENT_NODE ? _matches.call(el, selector) : false;\n}\n\n/**\n * Test two values for strict equality, accounting for the fact that `NaN !== NaN`.\n */\nexport function strictEquals(value1: any, value2: any): boolean {\n return value1 === value2 || (value1 !== value1 && value2 !== value2);\n}\n\n/** Gets a map of default set of attributes to observe and the properties they affect. */\nexport function getDefaultAttributeToPropertyInputs(\n inputs: {propName: string; templateName: string; transform?: (value: any) => any}[],\n) {\n const attributeToPropertyInputs: {\n [key: string]: [propName: string, transform: ((value: any) => any) | undefined];\n } = {};\n inputs.forEach(({propName, templateName, transform}) => {\n attributeToPropertyInputs[camelToDashCase(templateName)] = [propName, transform];\n });\n\n return attributeToPropertyInputs;\n}\n\n/**\n * Gets a component's set of inputs. Uses the injector to get the component factory where the inputs\n * are defined.\n */\nexport function getComponentInputs(\n component: Type<any>,\n injector: Injector,\n): {\n propName: string;\n templateName: string;\n transform?: (value: any) => any;\n isSignal: boolean;\n}[] {\n const componentFactoryResolver = injector.get(ComponentFactoryResolver);\n const componentFactory = componentFactoryResolver.resolveComponentFactory(component);\n return componentFactory.inputs;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\n// NOTE: This is a (slightly improved) version of what is used in ngUpgrade's\n// `DowngradeComponentAdapter`.\n// TODO(gkalpak): Investigate if it makes sense to share the code.\n\nimport {isElement, matchesSelector} from './utils';\n\nexport function extractProjectableNodes(host: HTMLElement, ngContentSelectors: string[]): Node[][] {\n const nodes = host.childNodes;\n const projectableNodes: Node[][] = ngContentSelectors.map(() => []);\n let wildcardIndex = -1;\n\n ngContentSelectors.some((selector, i) => {\n if (selector === '*') {\n wildcardIndex = i;\n return true;\n }\n return false;\n });\n\n for (let i = 0, ii = nodes.length; i < ii; ++i) {\n const node = nodes[i];\n const ngContentIndex = findMatchingIndex(node, ngContentSelectors, wildcardIndex);\n\n if (ngContentIndex !== -1) {\n projectableNodes[ngContentIndex].push(node);\n }\n }\n\n return projectableNodes;\n}\n\nfunction findMatchingIndex(node: Node, selectors: string[], defaultIndex: number): number {\n let matchingIndex = defaultIndex;\n\n if (isElement(node)) {\n selectors.some((selector, i) => {\n if (selector !== '*' && matchesSelector(node, selector)) {\n matchingIndex = i;\n return true;\n }\n return false;\n });\n }\n\n return matchingIndex;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {\n ApplicationRef,\n ComponentFactory,\n ComponentFactoryResolver,\n ComponentRef,\n EventEmitter,\n Injector,\n NgZone,\n Type,\n ɵChangeDetectionScheduler as ChangeDetectionScheduler,\n ɵNotificationSource as NotificationSource,\n ɵViewRef as ViewRef,\n OutputRef,\n} from '@angular/core';\nimport {merge, Observable, ReplaySubject} from 'rxjs';\nimport {switchMap} from 'rxjs/operators';\n\nimport {\n NgElementStrategy,\n NgElementStrategyEvent,\n NgElementStrategyFactory,\n} from './element-strategy';\nimport {extractProjectableNodes} from './extract-projectable-nodes';\nimport {scheduler} from './utils';\n\n/** Time in milliseconds to wait before destroying the component ref when disconnected. */\nconst DESTROY_DELAY = 10;\n\n/**\n * Factory that creates new ComponentNgElementStrategy instance. Gets the component factory with the\n * constructor's injector's factory resolver and passes that factory to each strategy.\n */\nexport class ComponentNgElementStrategyFactory implements NgElementStrategyFactory {\n componentFactory: ComponentFactory<any>;\n\n inputMap = new Map<string, string>();\n\n constructor(component: Type<any>, injector: Injector) {\n this.componentFactory = injector\n .get(ComponentFactoryResolver)\n .resolveComponentFactory(component);\n for (const input of this.componentFactory.inputs) {\n this.inputMap.set(input.propName, input.templateName);\n }\n }\n\n create(injector: Injector) {\n return new ComponentNgElementStrategy(this.componentFactory, injector, this.inputMap);\n }\n}\n\n/**\n * Creates and destroys a component ref using a component factory and handles change detection\n * in response to input changes.\n */\nexport class ComponentNgElementStrategy implements NgElementStrategy {\n // Subject of `NgElementStrategyEvent` observables corresponding to the component's outputs.\n private eventEmitters = new ReplaySubject<Observable<NgElementStrategyEvent>[]>(1);\n\n /** Merged stream of the component's output events. */\n readonly events = this.eventEmitters.pipe(switchMap((emitters) => merge(...emitters)));\n\n /** Reference to the component that was created on connect. */\n private componentRef: ComponentRef<any> | null = null;\n\n /** Callback function that when called will cancel a scheduled destruction on the component. */\n private scheduledDestroyFn: (() => void) | null = null;\n\n /** Initial input values that were set before the component was created. */\n private readonly initialInputValues = new Map<string, any>();\n\n /** Service for setting zone context. */\n private readonly ngZone: NgZone;\n\n /** The zone the element was created in or `null` if Zone.js is not loaded. */\n private readonly elementZone: Zone | null;\n\n /**\n * The `ApplicationRef` shared by all instances of this custom element (and potentially others).\n */\n private readonly appRef: ApplicationRef;\n\n /**\n * Angular's change detection scheduler, which works independently of zone.js.\n */\n private cdScheduler: ChangeDetectionScheduler;\n\n constructor(\n private componentFactory: ComponentFactory<any>,\n private injector: Injector,\n private inputMap: Map<string, string>,\n ) {\n this.ngZone = this.injector.get(NgZone);\n this.appRef = this.injector.get(ApplicationRef);\n this.cdScheduler = injector.get(ChangeDetectionScheduler);\n this.elementZone = typeof Zone === 'undefined' ? null : this.ngZone.run(() => Zone.current);\n }\n\n /**\n * Initializes a new component if one has not yet been created and cancels any scheduled\n * destruction.\n */\n connect(element: HTMLElement) {\n this.runInZone(() => {\n // If the element is marked to be destroyed, cancel the task since the component was\n // reconnected\n if (this.scheduledDestroyFn !== null) {\n this.scheduledDestroyFn();\n this.scheduledDestroyFn = null;\n return;\n }\n\n if (this.componentRef === null) {\n this.initializeComponent(element);\n }\n });\n }\n\n /**\n * Schedules the component to be destroyed after some small delay in case the element is just\n * being moved across the DOM.\n */\n disconnect() {\n this.runInZone(() => {\n // Return if there is no componentRef or the component is already scheduled for destruction\n if (this.componentRef === null || this.scheduledDestroyFn !== null) {\n return;\n }\n\n // Schedule the component to be destroyed after a small timeout in case it is being\n // moved elsewhere in the DOM\n this.scheduledDestroyFn = scheduler.schedule(() => {\n if (this.componentRef !== null) {\n this.componentRef.destroy();\n this.componentRef = null;\n }\n }, DESTROY_DELAY);\n });\n }\n\n /**\n * Returns the component property value. If the component has not yet been created, the value is\n * retrieved from the cached initialization values.\n */\n getInputValue(property: string): any {\n return this.runInZone(() => {\n if (this.componentRef === null) {\n return this.initialInputValues.get(property);\n }\n\n return this.componentRef.instance[property];\n });\n }\n\n /**\n * Sets the input value for the property. If the component has not yet been created, the value is\n * cached and set when the component is created.\n */\n setInputValue(property: string, value: any): void {\n if (this.componentRef === null) {\n this.initialInputValues.set(property, value);\n return;\n }\n\n this.runInZone(() => {\n this.componentRef!.setInput(this.inputMap.get(property) ?? property, value);\n\n // `setInput` won't mark the view dirty if the input didn't change from its previous value.\n if ((this.componentRef!.hostView as ViewRef<unknown>).dirty) {\n // `setInput` will have marked the view dirty already, but also mark it for refresh. This\n // guarantees the view will be checked even if the input is being set from within change\n // detection. This provides backwards compatibility, since we used to unconditionally\n // schedule change detection in addition to the current zone run.\n (this.componentRef!.changeDetectorRef as ViewRef<unknown>).markForRefresh();\n\n // Notifying the scheduler with `NotificationSource.CustomElement` causes a `tick()` to be\n // scheduled unconditionally, even if the scheduler is otherwise disabled.\n this.cdScheduler.notify(NotificationSource.CustomElement);\n }\n });\n }\n\n /**\n * Creates a new component through the component factory with the provided element host and\n * sets up its initial inputs, listens for outputs changes, and runs an initial change detection.\n */\n protected initializeComponent(element: HTMLElement) {\n const childInjector = Injector.create({providers: [], parent: this.injector});\n const projectableNodes = extractProjectableNodes(\n element,\n this.componentFactory.ngContentSelectors,\n );\n this.componentRef = this.componentFactory.create(childInjector, projectableNodes, element);\n\n this.initializeInputs();\n this.initializeOutputs(this.componentRef);\n\n this.appRef.attachView(this.componentRef.hostView);\n this.componentRef.hostView.detectChanges();\n }\n\n /** Set any stored initial inputs on the component's properties. */\n protected initializeInputs(): void {\n for (const [propName, value] of this.initialInputValues) {\n this.setInputValue(propName, value);\n }\n\n this.initialInputValues.clear();\n }\n\n /** Sets up listeners for the component's outputs so that the events stream emits the events. */\n protected initializeOutputs(componentRef: ComponentRef<any>): void {\n const eventEmitters: Observable<NgElementStrategyEvent>[] = this.componentFactory.outputs.map(\n ({propName, templateName}) => {\n const emitter: EventEmitter<any> | OutputRef<any> = componentRef.instance[propName];\n return new Observable((observer) => {\n const sub = emitter.subscribe((value) => observer.next({name: templateName, value}));\n return () => sub.unsubscribe();\n });\n },\n );\n\n this.eventEmitters.next(eventEmitters);\n }\n\n /** Runs in the angular zone, if present. */\n private runInZone(fn: () => unknown) {\n return this.elementZone && Zone.current !== this.elementZone ? this.ngZone.run(fn) : fn();\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {Injector, Type} from '@angular/core';\nimport {Subscription} from 'rxjs';\n\nimport {ComponentNgElementStrategyFactory} from './component-factory-strategy';\nimport {NgElementStrategy, NgElementStrategyFactory} from './element-strategy';\nimport {getComponentInputs, getDefaultAttributeToPropertyInputs} from './utils';\n\n/**\n * Prototype for a class constructor based on an Angular component\n * that can be used for custom element registration. Implemented and returned\n * by the {@link createCustomElement createCustomElement() function}.\n *\n * @see [Angular Elements Overview](guide/elements \"Turning Angular components into custom elements\")\n *\n * @publicApi\n */\nexport interface NgElementConstructor<P> {\n /**\n * An array of observed attribute names for the custom element,\n * derived by transforming input property names from the source component.\n */\n readonly observedAttributes: string[];\n\n /**\n * Initializes a constructor instance.\n * @param injector If provided, overrides the configured injector.\n */\n new (injector?: Injector): NgElement & WithProperties<P>;\n}\n\n/**\n * Implements the functionality needed for a custom element.\n *\n * @publicApi\n */\nexport abstract class NgElement extends HTMLElement {\n /**\n * The strategy that controls how a component is transformed in a custom element.\n */\n protected abstract ngElementStrategy: NgElementStrategy;\n /**\n * A subscription to change, connect, and disconnect events in the custom element.\n */\n protected ngElementEventsSubscription: Subscription | null = null;\n\n /**\n * Prototype for a handler that responds to a change in an observed attribute.\n * @param attrName The name of the attribute that has changed.\n * @param oldValue The previous value of the attribute.\n * @param newValue The new value of the attribute.\n * @param namespace The namespace in which the attribute is defined.\n * @returns Nothing.\n */\n abstract attributeChangedCallback(\n attrName: string,\n oldValue: string | null,\n newValue: string,\n namespace?: string,\n ): void;\n /**\n * Prototype for a handler that responds to the insertion of the custom element in the DOM.\n * @returns Nothing.\n */\n abstract connectedCallback(): void;\n /**\n * Prototype for a handler that responds to the deletion of the custom element from the DOM.\n * @returns Nothing.\n */\n abstract disconnectedCallback(): void;\n}\n\n/**\n * Additional type information that can be added to the NgElement class,\n * for properties that are added based\n * on the inputs and methods of the underlying component.\n *\n * @publicApi\n */\nexport type WithProperties<P> = {\n [property in keyof P]: P[property];\n};\n\n/**\n * A configuration that initializes an NgElementConstructor with the\n * dependencies and strategy it needs to transform a component into\n * a custom element class.\n *\n * @publicApi\n */\nexport interface NgElementConfig {\n /**\n * The injector to use for retrieving the component's factory.\n */\n injector: Injector;\n /**\n * An optional custom strategy factory to use instead of the default.\n * The strategy controls how the transformation is performed.\n */\n strategyFactory?: NgElementStrategyFactory;\n}\n\n/**\n * @description Creates a custom element class based on an Angular component.\n *\n * Builds a class that encapsulates the functionality of the provided component and\n * uses the configuration information to provide more context to the class.\n * Takes the component factory's inputs and outputs to convert them to the proper\n * custom element API and add hooks to input changes.\n *\n * The configuration's injector is the initial injector set on the class,\n * and used by default for each created instance.This behavior can be overridden with the\n * static property to affect all newly created instances, or as a constructor argument for\n * one-off creations.\n *\n * @see [Angular Elements Overview](guide/elements \"Turning Angular components into custom elements\")\n *\n * @param component The component to transform.\n * @param config A configuration that provides initialization information to the created class.\n * @returns The custom-element construction class, which can be registered with\n * a browser's `CustomElementRegistry`.\n *\n * @publicApi\n */\nexport function createCustomElement<P>(\n component: Type<any>,\n config: NgElementConfig,\n): NgElementConstructor<P> {\n const inputs = getComponentInputs(component, config.injector);\n\n const strategyFactory =\n config.strategyFactory || new ComponentNgElementStrategyFactory(component, config.injector);\n\n const attributeToPropertyInputs = getDefaultAttributeToPropertyInputs(inputs);\n\n class NgElementImpl extends NgElement {\n // Work around a bug in closure typed optimizations(b/79557487) where it is not honoring static\n // field externs. So using quoted access to explicitly prevent renaming.\n static readonly ['observedAttributes'] = Object.keys(attributeToPropertyInputs);\n\n protected override get ngElementStrategy(): NgElementStrategy {\n // TODO(andrewseguin): Add e2e tests that cover cases where the constructor isn't called. For\n // now this is tested using a Google internal test suite.\n if (!this._ngElementStrategy) {\n const strategy = (this._ngElementStrategy = strategyFactory.create(\n this.injector || config.injector,\n ));\n\n // Re-apply pre-existing input values (set as properties on the element) through the\n // strategy.\n // TODO(alxhub): why are we doing this? this makes no sense.\n inputs.forEach(({propName, transform}) => {\n if (!this.hasOwnProperty(propName)) {\n // No pre-existing value for `propName`.\n return;\n }\n\n // Delete the property from the DOM node and re-apply it through the strategy.\n const value = (this as any)[propName];\n delete (this as any)[propName];\n strategy.setInputValue(propName, value, transform);\n });\n }\n\n return this._ngElementStrategy!;\n }\n\n private _ngElementStrategy?: NgElementStrategy;\n\n constructor(private readonly injector?: Injector) {\n super();\n }\n\n override attributeChangedCallback(\n attrName: string,\n oldValue: string | null,\n newValue: string,\n namespace?: string,\n ): void {\n const [propName, transform] = attributeToPropertyInputs[attrName]!;\n this.ngElementStrategy.setInputValue(propName, newValue, transform);\n }\n\n override connectedCallback(): void {\n // For historical reasons, some strategies may not have initialized the `events` property\n // until after `connect()` is run. Subscribe to `events` if it is available before running\n // `connect()` (in order to capture events emitted during initialization), otherwise subscribe\n // afterwards.\n //\n // TODO: Consider deprecating/removing the post-connect subscription in a future major version\n // (e.g. v11).\n\n let subscribedToEvents = false;\n\n if (this.ngElementStrategy.events) {\n // `events` are already available: Subscribe to it asap.\n this.subscribeToEvents();\n subscribedToEvents = true;\n }\n\n this.ngElementStrategy.connect(this);\n\n if (!subscribedToEvents) {\n // `events` were not initialized before running `connect()`: Subscribe to them now.\n // The events emitted during the component initialization have been missed, but at least\n // future events will be captured.\n this.subscribeToEvents();\n }\n }\n\n override disconnectedCallback(): void {\n // Not using `this.ngElementStrategy` to avoid unnecessarily creating the `NgElementStrategy`.\n if (this._ngElementStrategy) {\n this._ngElementStrategy.disconnect();\n }\n\n if (this.ngElementEventsSubscription) {\n this.ngElementEventsSubscription.unsubscribe();\n this.ngElementEventsSubscription = null;\n }\n }\n\n private subscribeToEvents(): void {\n // Listen for events from the strategy and dispatch them as custom events.\n this.ngElementEventsSubscription = this.ngElementStrategy.events.subscribe((e) => {\n const customEvent = new CustomEvent(e.name, {detail: e.value});\n this.dispatchEvent(customEvent);\n });\n }\n }\n\n // Add getters and setters to the prototype for each property input.\n inputs.forEach(({propName, transform}) => {\n Object.defineProperty(NgElementImpl.prototype, propName, {\n get(): any {\n return this.ngElementStrategy.getInputValue(propName);\n },\n set(newValue: any): void {\n this.ngElementStrategy.setInputValue(propName, newValue, transform);\n },\n configurable: true,\n enumerable: true,\n });\n });\n\n return NgElementImpl as any as NgElementConstructor<P>;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {Version} from '@angular/core';\n\n/**\n * @publicApi\n */\nexport const VERSION = new Version('20.0.0-next.0');\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\n/**\n * @module\n * @description\n * Entry point for all public APIs of the `elements` package.\n */\nexport {\n createCustomElement,\n NgElement,\n NgElementConfig,\n NgElementConstructor,\n WithProperties,\n} from './src/create-custom-element';\nexport {\n NgElementStrategy,\n NgElementStrategyEvent,\n NgElementStrategyFactory,\n} from './src/element-strategy';\nexport {VERSION} from './src/version';\n\n// This file only reexports content of the `src` folder. Keep it that way.\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\n// This file is not used to build this module. It is only used during editing\n// by the TypeScript language service and during build for verification. `ngc`\n// replaces this file with production index.ts when it rewrites private symbol\n// names.\n\nexport * from './public_api';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["ChangeDetectionScheduler"],"mappings":";;;;;;;;;;AASA;;AAEG;AACI,MAAM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/extract-projectable-nodes.ts","../../../../../../packages/elements/src/component-factory-strategy.ts","../../../../../../packages/elements/src/create-custom-element.ts","../../../../../../packages/elements/src/version.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\nimport {ComponentFactoryResolver, Injector, Type} from '@angular/core';\n\n/**\n * Provide methods for scheduling the execution of a callback.\n */\nexport const scheduler = {\n /**\n * Schedule a callback to be called after some delay.\n *\n * Returns a function that when executed will cancel the scheduled function.\n */\n schedule(taskFn: () => void, delay: number): () => void {\n const id = setTimeout(taskFn, delay);\n return () => clearTimeout(id);\n },\n};\n\n/**\n * Convert a camelCased string to kebab-cased.\n */\nexport function camelToDashCase(input: string): string {\n return input.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);\n}\n\n/**\n * Check whether the input is an `Element`.\n */\nexport function isElement(node: Node | null): node is Element {\n return !!node && node.nodeType === Node.ELEMENT_NODE;\n}\n\n/**\n * Check whether the input is a function.\n */\nexport function isFunction(value: any): value is Function {\n return typeof value === 'function';\n}\n\n/**\n * Convert a kebab-cased string to camelCased.\n */\nexport function kebabToCamelCase(input: string): string {\n return input.replace(/-([a-z\\d])/g, (_, char) => char.toUpperCase());\n}\n\nlet _matches: (this: any, selector: string) => boolean;\n\n/**\n * Check whether an `Element` matches a CSS selector.\n * NOTE: this is duplicated from @angular/upgrade, and can\n * be consolidated in the future\n */\nexport function matchesSelector(el: any, selector: string): boolean {\n if (!_matches) {\n const elProto = <any>Element.prototype;\n _matches =\n elProto.matches ||\n elProto.matchesSelector ||\n elProto.mozMatchesSelector ||\n elProto.msMatchesSelector ||\n elProto.oMatchesSelector ||\n elProto.webkitMatchesSelector;\n }\n return el.nodeType === Node.ELEMENT_NODE ? _matches.call(el, selector) : false;\n}\n\n/**\n * Test two values for strict equality, accounting for the fact that `NaN !== NaN`.\n */\nexport function strictEquals(value1: any, value2: any): boolean {\n return value1 === value2 || (value1 !== value1 && value2 !== value2);\n}\n\n/** Gets a map of default set of attributes to observe and the properties they affect. */\nexport function getDefaultAttributeToPropertyInputs(\n inputs: {propName: string; templateName: string; transform?: (value: any) => any}[],\n) {\n const attributeToPropertyInputs: {\n [key: string]: [propName: string, transform: ((value: any) => any) | undefined];\n } = {};\n inputs.forEach(({propName, templateName, transform}) => {\n attributeToPropertyInputs[camelToDashCase(templateName)] = [propName, transform];\n });\n\n return attributeToPropertyInputs;\n}\n\n/**\n * Gets a component's set of inputs. Uses the injector to get the component factory where the inputs\n * are defined.\n */\nexport function getComponentInputs(\n component: Type<any>,\n injector: Injector,\n): {\n propName: string;\n templateName: string;\n transform?: (value: any) => any;\n isSignal: boolean;\n}[] {\n const componentFactoryResolver = injector.get(ComponentFactoryResolver);\n const componentFactory = componentFactoryResolver.resolveComponentFactory(component);\n return componentFactory.inputs;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\n// NOTE: This is a (slightly improved) version of what is used in ngUpgrade's\n// `DowngradeComponentAdapter`.\n// TODO(gkalpak): Investigate if it makes sense to share the code.\n\nimport {isElement, matchesSelector} from './utils';\n\nexport function extractProjectableNodes(host: HTMLElement, ngContentSelectors: string[]): Node[][] {\n const nodes = host.childNodes;\n const projectableNodes: Node[][] = ngContentSelectors.map(() => []);\n let wildcardIndex = -1;\n\n ngContentSelectors.some((selector, i) => {\n if (selector === '*') {\n wildcardIndex = i;\n return true;\n }\n return false;\n });\n\n for (let i = 0, ii = nodes.length; i < ii; ++i) {\n const node = nodes[i];\n const ngContentIndex = findMatchingIndex(node, ngContentSelectors, wildcardIndex);\n\n if (ngContentIndex !== -1) {\n projectableNodes[ngContentIndex].push(node);\n }\n }\n\n return projectableNodes;\n}\n\nfunction findMatchingIndex(node: Node, selectors: string[], defaultIndex: number): number {\n let matchingIndex = defaultIndex;\n\n if (isElement(node)) {\n selectors.some((selector, i) => {\n if (selector !== '*' && matchesSelector(node, selector)) {\n matchingIndex = i;\n return true;\n }\n return false;\n });\n }\n\n return matchingIndex;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {\n ApplicationRef,\n ComponentFactory,\n ComponentFactoryResolver,\n ComponentRef,\n EventEmitter,\n Injector,\n NgZone,\n Type,\n ɵChangeDetectionScheduler as ChangeDetectionScheduler,\n ɵNotificationSource as NotificationSource,\n ɵViewRef as ViewRef,\n ɵisViewDirty as isViewDirty,\n ɵmarkForRefresh as markForRefresh,\n OutputRef,\n} from '@angular/core';\nimport {merge, Observable, ReplaySubject} from 'rxjs';\nimport {switchMap} from 'rxjs/operators';\n\nimport {\n NgElementStrategy,\n NgElementStrategyEvent,\n NgElementStrategyFactory,\n} from './element-strategy';\nimport {extractProjectableNodes} from './extract-projectable-nodes';\nimport {scheduler} from './utils';\n\n/** Time in milliseconds to wait before destroying the component ref when disconnected. */\nconst DESTROY_DELAY = 10;\n\n/**\n * Factory that creates new ComponentNgElementStrategy instance. Gets the component factory with the\n * constructor's injector's factory resolver and passes that factory to each strategy.\n */\nexport class ComponentNgElementStrategyFactory implements NgElementStrategyFactory {\n componentFactory: ComponentFactory<any>;\n\n inputMap = new Map<string, string>();\n\n constructor(component: Type<any>, injector: Injector) {\n this.componentFactory = injector\n .get(ComponentFactoryResolver)\n .resolveComponentFactory(component);\n for (const input of this.componentFactory.inputs) {\n this.inputMap.set(input.propName, input.templateName);\n }\n }\n\n create(injector: Injector) {\n return new ComponentNgElementStrategy(this.componentFactory, injector, this.inputMap);\n }\n}\n\n/**\n * Creates and destroys a component ref using a component factory and handles change detection\n * in response to input changes.\n */\nexport class ComponentNgElementStrategy implements NgElementStrategy {\n // Subject of `NgElementStrategyEvent` observables corresponding to the component's outputs.\n private eventEmitters = new ReplaySubject<Observable<NgElementStrategyEvent>[]>(1);\n\n /** Merged stream of the component's output events. */\n readonly events = this.eventEmitters.pipe(switchMap((emitters) => merge(...emitters)));\n\n /** Reference to the component that was created on connect. */\n private componentRef: ComponentRef<any> | null = null;\n\n /** Callback function that when called will cancel a scheduled destruction on the component. */\n private scheduledDestroyFn: (() => void) | null = null;\n\n /** Initial input values that were set before the component was created. */\n private readonly initialInputValues = new Map<string, any>();\n\n /** Service for setting zone context. */\n private readonly ngZone: NgZone;\n\n /** The zone the element was created in or `null` if Zone.js is not loaded. */\n private readonly elementZone: Zone | null;\n\n /**\n * The `ApplicationRef` shared by all instances of this custom element (and potentially others).\n */\n private readonly appRef: ApplicationRef;\n\n /**\n * Angular's change detection scheduler, which works independently of zone.js.\n */\n private cdScheduler: ChangeDetectionScheduler;\n\n constructor(\n private componentFactory: ComponentFactory<any>,\n private injector: Injector,\n private inputMap: Map<string, string>,\n ) {\n this.ngZone = this.injector.get(NgZone);\n this.appRef = this.injector.get(ApplicationRef);\n this.cdScheduler = injector.get(ChangeDetectionScheduler);\n this.elementZone = typeof Zone === 'undefined' ? null : this.ngZone.run(() => Zone.current);\n }\n\n /**\n * Initializes a new component if one has not yet been created and cancels any scheduled\n * destruction.\n */\n connect(element: HTMLElement) {\n this.runInZone(() => {\n // If the element is marked to be destroyed, cancel the task since the component was\n // reconnected\n if (this.scheduledDestroyFn !== null) {\n this.scheduledDestroyFn();\n this.scheduledDestroyFn = null;\n return;\n }\n\n if (this.componentRef === null) {\n this.initializeComponent(element);\n }\n });\n }\n\n /**\n * Schedules the component to be destroyed after some small delay in case the element is just\n * being moved across the DOM.\n */\n disconnect() {\n this.runInZone(() => {\n // Return if there is no componentRef or the component is already scheduled for destruction\n if (this.componentRef === null || this.scheduledDestroyFn !== null) {\n return;\n }\n\n // Schedule the component to be destroyed after a small timeout in case it is being\n // moved elsewhere in the DOM\n this.scheduledDestroyFn = scheduler.schedule(() => {\n if (this.componentRef !== null) {\n this.componentRef.destroy();\n this.componentRef = null;\n }\n }, DESTROY_DELAY);\n });\n }\n\n /**\n * Returns the component property value. If the component has not yet been created, the value is\n * retrieved from the cached initialization values.\n */\n getInputValue(property: string): any {\n return this.runInZone(() => {\n if (this.componentRef === null) {\n return this.initialInputValues.get(property);\n }\n\n return this.componentRef.instance[property];\n });\n }\n\n /**\n * Sets the input value for the property. If the component has not yet been created, the value is\n * cached and set when the component is created.\n */\n setInputValue(property: string, value: any): void {\n if (this.componentRef === null) {\n this.initialInputValues.set(property, value);\n return;\n }\n\n this.runInZone(() => {\n this.componentRef!.setInput(this.inputMap.get(property) ?? property, value);\n\n // `setInput` won't mark the view dirty if the input didn't change from its previous value.\n if (isViewDirty(this.componentRef!.hostView as ViewRef<unknown>)) {\n // `setInput` will have marked the view dirty already, but also mark it for refresh. This\n // guarantees the view will be checked even if the input is being set from within change\n // detection. This provides backwards compatibility, since we used to unconditionally\n // schedule change detection in addition to the current zone run.\n markForRefresh(this.componentRef!.changeDetectorRef as ViewRef<unknown>);\n\n // Notifying the scheduler with `NotificationSource.CustomElement` causes a `tick()` to be\n // scheduled unconditionally, even if the scheduler is otherwise disabled.\n this.cdScheduler.notify(NotificationSource.CustomElement);\n }\n });\n }\n\n /**\n * Creates a new component through the component factory with the provided element host and\n * sets up its initial inputs, listens for outputs changes, and runs an initial change detection.\n */\n protected initializeComponent(element: HTMLElement) {\n const childInjector = Injector.create({providers: [], parent: this.injector});\n const projectableNodes = extractProjectableNodes(\n element,\n this.componentFactory.ngContentSelectors,\n );\n this.componentRef = this.componentFactory.create(childInjector, projectableNodes, element);\n\n this.initializeInputs();\n this.initializeOutputs(this.componentRef);\n\n this.appRef.attachView(this.componentRef.hostView);\n this.componentRef.hostView.detectChanges();\n }\n\n /** Set any stored initial inputs on the component's properties. */\n protected initializeInputs(): void {\n for (const [propName, value] of this.initialInputValues) {\n this.setInputValue(propName, value);\n }\n\n this.initialInputValues.clear();\n }\n\n /** Sets up listeners for the component's outputs so that the events stream emits the events. */\n protected initializeOutputs(componentRef: ComponentRef<any>): void {\n const eventEmitters: Observable<NgElementStrategyEvent>[] = this.componentFactory.outputs.map(\n ({propName, templateName}) => {\n const emitter: EventEmitter<any> | OutputRef<any> = componentRef.instance[propName];\n return new Observable((observer) => {\n const sub = emitter.subscribe((value) => observer.next({name: templateName, value}));\n return () => sub.unsubscribe();\n });\n },\n );\n\n this.eventEmitters.next(eventEmitters);\n }\n\n /** Runs in the angular zone, if present. */\n private runInZone(fn: () => unknown) {\n return this.elementZone && Zone.current !== this.elementZone ? this.ngZone.run(fn) : fn();\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {Injector, Type} from '@angular/core';\nimport {Subscription} from 'rxjs';\n\nimport {ComponentNgElementStrategyFactory} from './component-factory-strategy';\nimport {NgElementStrategy, NgElementStrategyFactory} from './element-strategy';\nimport {getComponentInputs, getDefaultAttributeToPropertyInputs} from './utils';\n\n/**\n * Prototype for a class constructor based on an Angular component\n * that can be used for custom element registration. Implemented and returned\n * by the {@link createCustomElement createCustomElement() function}.\n *\n * @see [Angular Elements Overview](guide/elements \"Turning Angular components into custom elements\")\n *\n * @publicApi\n */\nexport interface NgElementConstructor<P> {\n /**\n * An array of observed attribute names for the custom element,\n * derived by transforming input property names from the source component.\n */\n readonly observedAttributes: string[];\n\n /**\n * Initializes a constructor instance.\n * @param injector If provided, overrides the configured injector.\n */\n new (injector?: Injector): NgElement & WithProperties<P>;\n}\n\n/**\n * Implements the functionality needed for a custom element.\n *\n * @publicApi\n */\nexport abstract class NgElement extends HTMLElement {\n /**\n * The strategy that controls how a component is transformed in a custom element.\n */\n protected abstract ngElementStrategy: NgElementStrategy;\n /**\n * A subscription to change, connect, and disconnect events in the custom element.\n */\n protected ngElementEventsSubscription: Subscription | null = null;\n\n /**\n * Prototype for a handler that responds to a change in an observed attribute.\n * @param attrName The name of the attribute that has changed.\n * @param oldValue The previous value of the attribute.\n * @param newValue The new value of the attribute.\n * @param namespace The namespace in which the attribute is defined.\n * @returns Nothing.\n */\n abstract attributeChangedCallback(\n attrName: string,\n oldValue: string | null,\n newValue: string,\n namespace?: string,\n ): void;\n /**\n * Prototype for a handler that responds to the insertion of the custom element in the DOM.\n * @returns Nothing.\n */\n abstract connectedCallback(): void;\n /**\n * Prototype for a handler that responds to the deletion of the custom element from the DOM.\n * @returns Nothing.\n */\n abstract disconnectedCallback(): void;\n}\n\n/**\n * Additional type information that can be added to the NgElement class,\n * for properties that are added based\n * on the inputs and methods of the underlying component.\n *\n * @publicApi\n */\nexport type WithProperties<P> = {\n [property in keyof P]: P[property];\n};\n\n/**\n * A configuration that initializes an NgElementConstructor with the\n * dependencies and strategy it needs to transform a component into\n * a custom element class.\n *\n * @publicApi\n */\nexport interface NgElementConfig {\n /**\n * The injector to use for retrieving the component's factory.\n */\n injector: Injector;\n /**\n * An optional custom strategy factory to use instead of the default.\n * The strategy controls how the transformation is performed.\n */\n strategyFactory?: NgElementStrategyFactory;\n}\n\n/**\n * @description Creates a custom element class based on an Angular component.\n *\n * Builds a class that encapsulates the functionality of the provided component and\n * uses the configuration information to provide more context to the class.\n * Takes the component factory's inputs and outputs to convert them to the proper\n * custom element API and add hooks to input changes.\n *\n * The configuration's injector is the initial injector set on the class,\n * and used by default for each created instance.This behavior can be overridden with the\n * static property to affect all newly created instances, or as a constructor argument for\n * one-off creations.\n *\n * @see [Angular Elements Overview](guide/elements \"Turning Angular components into custom elements\")\n *\n * @param component The component to transform.\n * @param config A configuration that provides initialization information to the created class.\n * @returns The custom-element construction class, which can be registered with\n * a browser's `CustomElementRegistry`.\n *\n * @publicApi\n */\nexport function createCustomElement<P>(\n component: Type<any>,\n config: NgElementConfig,\n): NgElementConstructor<P> {\n const inputs = getComponentInputs(component, config.injector);\n\n const strategyFactory =\n config.strategyFactory || new ComponentNgElementStrategyFactory(component, config.injector);\n\n const attributeToPropertyInputs = getDefaultAttributeToPropertyInputs(inputs);\n\n class NgElementImpl extends NgElement {\n // Work around a bug in closure typed optimizations(b/79557487) where it is not honoring static\n // field externs. So using quoted access to explicitly prevent renaming.\n static readonly ['observedAttributes'] = Object.keys(attributeToPropertyInputs);\n\n protected override get ngElementStrategy(): NgElementStrategy {\n // TODO(andrewseguin): Add e2e tests that cover cases where the constructor isn't called. For\n // now this is tested using a Google internal test suite.\n if (!this._ngElementStrategy) {\n const strategy = (this._ngElementStrategy = strategyFactory.create(\n this.injector || config.injector,\n ));\n\n // Re-apply pre-existing input values (set as properties on the element) through the\n // strategy.\n // TODO(alxhub): why are we doing this? this makes no sense.\n inputs.forEach(({propName, transform}) => {\n if (!this.hasOwnProperty(propName)) {\n // No pre-existing value for `propName`.\n return;\n }\n\n // Delete the property from the DOM node and re-apply it through the strategy.\n const value = (this as any)[propName];\n delete (this as any)[propName];\n strategy.setInputValue(propName, value, transform);\n });\n }\n\n return this._ngElementStrategy!;\n }\n\n private _ngElementStrategy?: NgElementStrategy;\n\n constructor(private readonly injector?: Injector) {\n super();\n }\n\n override attributeChangedCallback(\n attrName: string,\n oldValue: string | null,\n newValue: string,\n namespace?: string,\n ): void {\n const [propName, transform] = attributeToPropertyInputs[attrName]!;\n this.ngElementStrategy.setInputValue(propName, newValue, transform);\n }\n\n override connectedCallback(): void {\n // For historical reasons, some strategies may not have initialized the `events` property\n // until after `connect()` is run. Subscribe to `events` if it is available before running\n // `connect()` (in order to capture events emitted during initialization), otherwise subscribe\n // afterwards.\n //\n // TODO: Consider deprecating/removing the post-connect subscription in a future major version\n // (e.g. v11).\n\n let subscribedToEvents = false;\n\n if (this.ngElementStrategy.events) {\n // `events` are already available: Subscribe to it asap.\n this.subscribeToEvents();\n subscribedToEvents = true;\n }\n\n this.ngElementStrategy.connect(this);\n\n if (!subscribedToEvents) {\n // `events` were not initialized before running `connect()`: Subscribe to them now.\n // The events emitted during the component initialization have been missed, but at least\n // future events will be captured.\n this.subscribeToEvents();\n }\n }\n\n override disconnectedCallback(): void {\n // Not using `this.ngElementStrategy` to avoid unnecessarily creating the `NgElementStrategy`.\n if (this._ngElementStrategy) {\n this._ngElementStrategy.disconnect();\n }\n\n if (this.ngElementEventsSubscription) {\n this.ngElementEventsSubscription.unsubscribe();\n this.ngElementEventsSubscription = null;\n }\n }\n\n private subscribeToEvents(): void {\n // Listen for events from the strategy and dispatch them as custom events.\n this.ngElementEventsSubscription = this.ngElementStrategy.events.subscribe((e) => {\n const customEvent = new CustomEvent(e.name, {detail: e.value});\n this.dispatchEvent(customEvent);\n });\n }\n }\n\n // Add getters and setters to the prototype for each property input.\n inputs.forEach(({propName, transform}) => {\n Object.defineProperty(NgElementImpl.prototype, propName, {\n get(): any {\n return this.ngElementStrategy.getInputValue(propName);\n },\n set(newValue: any): void {\n this.ngElementStrategy.setInputValue(propName, newValue, transform);\n },\n configurable: true,\n enumerable: true,\n });\n });\n\n return NgElementImpl as any as NgElementConstructor<P>;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {Version} from '@angular/core';\n\n/**\n * @publicApi\n */\nexport const VERSION = new Version('20.0.0-next.2');\n"],"names":["ChangeDetectionScheduler","isViewDirty","markForRefresh"],"mappings":";;;;;;;;;;AASA;;AAEG;AACI,MAAM,SAAS,GAAG;AACvB;;;;AAIG;IACH,QAAQ,CAAC,MAAkB,EAAE,KAAa,EAAA;QACxC,MAAM,EAAE,GAAG,UAAU,CAAC,MAAM,EAAE,KAAK,CAAC;AACpC,QAAA,OAAO,MAAM,YAAY,CAAC,EAAE,CAAC;KAC9B;CACF;AAED;;AAEG;AACG,SAAU,eAAe,CAAC,KAAa,EAAA;AAC3C,IAAA,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,WAAW,EAAE,CAAA,CAAE,CAAC;AACpE;AAEA;;AAEG;AACG,SAAU,SAAS,CAAC,IAAiB,EAAA;IACzC,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AE,SAAS,EAAC,KAAI;QACvC,MAAM,CAAC,cAAc,CAAC,aAAa,CAAC,SAAS,EAAE,QAAQ,EAAE;YACvD,GAAG,GAAA;gBACD,OAAO,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,QAAQ,CAAC;aACtD;AACD,YAAA,GAAG,CAAC,QAAa,EAAA;gBACf,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC;aACpE;AACD,YAAA,YAAY,EAAE,IAAI;AAClB,YAAA,UAAU,EAAE,IAAI;AACjB,SAAA,CAAC;AACJ,KAAC,CAAC;AAEF,IAAA,OAAO,aAA+C;AACxD;;ACnPA;;AAEG;MACU,OAAO,GAAG,IAAI,OAAO,CAAC,mBAAmB;;;;"}
|
package/index.d.ts
CHANGED
|
@@ -1,46 +1,71 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v20.0.0-next.
|
|
3
|
-
* (c) 2010-
|
|
2
|
+
* @license Angular v20.0.0-next.2
|
|
3
|
+
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
import { Observable } from 'rxjs';
|
|
10
|
-
import { Subscription } from 'rxjs';
|
|
11
|
-
import { Type } from '@angular/core';
|
|
12
|
-
import { Version } from '@angular/core';
|
|
7
|
+
import { Injector, Type, Version } from '@angular/core';
|
|
8
|
+
import { Observable, Subscription } from 'rxjs';
|
|
13
9
|
|
|
14
10
|
/**
|
|
15
|
-
*
|
|
11
|
+
* Interface for the events emitted through the NgElementStrategy.
|
|
16
12
|
*
|
|
17
|
-
*
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
* @publicApi
|
|
14
|
+
*/
|
|
15
|
+
interface NgElementStrategyEvent {
|
|
16
|
+
name: string;
|
|
17
|
+
value: any;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Underlying strategy used by the NgElement to create/destroy the component and react to input
|
|
21
|
+
* changes.
|
|
21
22
|
*
|
|
22
|
-
*
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
* @publicApi
|
|
24
|
+
*/
|
|
25
|
+
interface NgElementStrategy {
|
|
26
|
+
events: Observable<NgElementStrategyEvent>;
|
|
27
|
+
connect(element: HTMLElement): void;
|
|
28
|
+
disconnect(): void;
|
|
29
|
+
getInputValue(propName: string): any;
|
|
30
|
+
setInputValue(propName: string, value: string, transform?: (value: any) => any): void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Factory used to create new strategies for each NgElement instance.
|
|
26
34
|
*
|
|
27
|
-
* @
|
|
35
|
+
* @publicApi
|
|
36
|
+
*/
|
|
37
|
+
interface NgElementStrategyFactory {
|
|
38
|
+
/** Creates a new instance to be used for an NgElement. */
|
|
39
|
+
create(injector: Injector): NgElementStrategy;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Prototype for a class constructor based on an Angular component
|
|
44
|
+
* that can be used for custom element registration. Implemented and returned
|
|
45
|
+
* by the {@link createCustomElement createCustomElement() function}.
|
|
28
46
|
*
|
|
29
|
-
* @
|
|
30
|
-
* @param config A configuration that provides initialization information to the created class.
|
|
31
|
-
* @returns The custom-element construction class, which can be registered with
|
|
32
|
-
* a browser's `CustomElementRegistry`.
|
|
47
|
+
* @see [Angular Elements Overview](guide/elements "Turning Angular components into custom elements")
|
|
33
48
|
*
|
|
34
49
|
* @publicApi
|
|
35
50
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
51
|
+
interface NgElementConstructor<P> {
|
|
52
|
+
/**
|
|
53
|
+
* An array of observed attribute names for the custom element,
|
|
54
|
+
* derived by transforming input property names from the source component.
|
|
55
|
+
*/
|
|
56
|
+
readonly observedAttributes: string[];
|
|
57
|
+
/**
|
|
58
|
+
* Initializes a constructor instance.
|
|
59
|
+
* @param injector If provided, overrides the configured injector.
|
|
60
|
+
*/
|
|
61
|
+
new (injector?: Injector): NgElement & WithProperties<P>;
|
|
62
|
+
}
|
|
38
63
|
/**
|
|
39
64
|
* Implements the functionality needed for a custom element.
|
|
40
65
|
*
|
|
41
66
|
* @publicApi
|
|
42
67
|
*/
|
|
43
|
-
|
|
68
|
+
declare abstract class NgElement extends HTMLElement {
|
|
44
69
|
/**
|
|
45
70
|
* The strategy that controls how a component is transformed in a custom element.
|
|
46
71
|
*/
|
|
@@ -69,7 +94,16 @@ export declare abstract class NgElement extends HTMLElement {
|
|
|
69
94
|
*/
|
|
70
95
|
abstract disconnectedCallback(): void;
|
|
71
96
|
}
|
|
72
|
-
|
|
97
|
+
/**
|
|
98
|
+
* Additional type information that can be added to the NgElement class,
|
|
99
|
+
* for properties that are added based
|
|
100
|
+
* on the inputs and methods of the underlying component.
|
|
101
|
+
*
|
|
102
|
+
* @publicApi
|
|
103
|
+
*/
|
|
104
|
+
type WithProperties<P> = {
|
|
105
|
+
[property in keyof P]: P[property];
|
|
106
|
+
};
|
|
73
107
|
/**
|
|
74
108
|
* A configuration that initializes an NgElementConstructor with the
|
|
75
109
|
* dependencies and strategy it needs to transform a component into
|
|
@@ -77,7 +111,7 @@ export declare abstract class NgElement extends HTMLElement {
|
|
|
77
111
|
*
|
|
78
112
|
* @publicApi
|
|
79
113
|
*/
|
|
80
|
-
|
|
114
|
+
interface NgElementConfig {
|
|
81
115
|
/**
|
|
82
116
|
* The injector to use for retrieving the component's factory.
|
|
83
117
|
*/
|
|
@@ -88,77 +122,33 @@ export declare interface NgElementConfig {
|
|
|
88
122
|
*/
|
|
89
123
|
strategyFactory?: NgElementStrategyFactory;
|
|
90
124
|
}
|
|
91
|
-
|
|
92
125
|
/**
|
|
93
|
-
*
|
|
94
|
-
* that can be used for custom element registration. Implemented and returned
|
|
95
|
-
* by the {@link createCustomElement createCustomElement() function}.
|
|
126
|
+
* @description Creates a custom element class based on an Angular component.
|
|
96
127
|
*
|
|
97
|
-
*
|
|
128
|
+
* Builds a class that encapsulates the functionality of the provided component and
|
|
129
|
+
* uses the configuration information to provide more context to the class.
|
|
130
|
+
* Takes the component factory's inputs and outputs to convert them to the proper
|
|
131
|
+
* custom element API and add hooks to input changes.
|
|
98
132
|
*
|
|
99
|
-
*
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
* An array of observed attribute names for the custom element,
|
|
104
|
-
* derived by transforming input property names from the source component.
|
|
105
|
-
*/
|
|
106
|
-
readonly observedAttributes: string[];
|
|
107
|
-
/**
|
|
108
|
-
* Initializes a constructor instance.
|
|
109
|
-
* @param injector If provided, overrides the configured injector.
|
|
110
|
-
*/
|
|
111
|
-
new (injector?: Injector): NgElement & WithProperties<P>;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Underlying strategy used by the NgElement to create/destroy the component and react to input
|
|
116
|
-
* changes.
|
|
133
|
+
* The configuration's injector is the initial injector set on the class,
|
|
134
|
+
* and used by default for each created instance.This behavior can be overridden with the
|
|
135
|
+
* static property to affect all newly created instances, or as a constructor argument for
|
|
136
|
+
* one-off creations.
|
|
117
137
|
*
|
|
118
|
-
* @
|
|
119
|
-
*/
|
|
120
|
-
export declare interface NgElementStrategy {
|
|
121
|
-
events: Observable<NgElementStrategyEvent>;
|
|
122
|
-
connect(element: HTMLElement): void;
|
|
123
|
-
disconnect(): void;
|
|
124
|
-
getInputValue(propName: string): any;
|
|
125
|
-
setInputValue(propName: string, value: string, transform?: (value: any) => any): void;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Interface for the events emitted through the NgElementStrategy.
|
|
138
|
+
* @see [Angular Elements Overview](guide/elements "Turning Angular components into custom elements")
|
|
130
139
|
*
|
|
131
|
-
* @
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
value: any;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Factory used to create new strategies for each NgElement instance.
|
|
140
|
+
* @param component The component to transform.
|
|
141
|
+
* @param config A configuration that provides initialization information to the created class.
|
|
142
|
+
* @returns The custom-element construction class, which can be registered with
|
|
143
|
+
* a browser's `CustomElementRegistry`.
|
|
140
144
|
*
|
|
141
145
|
* @publicApi
|
|
142
146
|
*/
|
|
143
|
-
|
|
144
|
-
/** Creates a new instance to be used for an NgElement. */
|
|
145
|
-
create(injector: Injector): NgElementStrategy;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* @publicApi
|
|
150
|
-
*/
|
|
151
|
-
export declare const VERSION: Version;
|
|
147
|
+
declare function createCustomElement<P>(component: Type<any>, config: NgElementConfig): NgElementConstructor<P>;
|
|
152
148
|
|
|
153
149
|
/**
|
|
154
|
-
* Additional type information that can be added to the NgElement class,
|
|
155
|
-
* for properties that are added based
|
|
156
|
-
* on the inputs and methods of the underlying component.
|
|
157
|
-
*
|
|
158
150
|
* @publicApi
|
|
159
151
|
*/
|
|
160
|
-
|
|
161
|
-
[property in keyof P]: P[property];
|
|
162
|
-
};
|
|
152
|
+
declare const VERSION: Version;
|
|
163
153
|
|
|
164
|
-
export { }
|
|
154
|
+
export { NgElement, type NgElementConfig, type NgElementConstructor, type NgElementStrategy, type NgElementStrategyEvent, type NgElementStrategyFactory, VERSION, type WithProperties, createCustomElement };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular/elements",
|
|
3
|
-
"version": "20.0.0-next.
|
|
3
|
+
"version": "20.0.0-next.2",
|
|
4
4
|
"description": "Angular - library for using Angular Components as Custom Elements",
|
|
5
5
|
"author": "angular",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"tslib": "^2.3.0"
|
|
12
12
|
},
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"@angular/core": "20.0.0-next.
|
|
14
|
+
"@angular/core": "20.0.0-next.2",
|
|
15
15
|
"rxjs": "^6.5.3 || ^7.4.0"
|
|
16
16
|
},
|
|
17
17
|
"repository": {
|