import * as _angular_core from '@angular/core'; import { Type, ApplicationRef, ComponentRef, Signal, ApplicationConfig, ComponentMirror, InputSignal, WritableSignal, PlatformRef, StaticProvider } from '@angular/core'; /** * Creates and destroys a component ref using a component factory and handles change detection * in response to input changes. */ declare class NgElementumStrategy { private component; private appRef; /** Reference to the component that was created on connect. */ private componentRef; /** Callback function that when called will cancel a scheduled destruction on the component. */ private scheduledDestroy; /** Initial input values that were set before the component was created. */ private readonly initialInputValues; /** * Angular's change detection scheduler, which works independently of zone.js. */ private cdScheduler; private readonly inputMap; private readonly componentMirror; constructor(component: Type, appRef: ApplicationRef); /** * Initializes a new component if one has not yet been created and cancels any scheduled * destruction. */ connect(element: HTMLElement): void; /** * Schedules the component to be destroyed after some small delay in case the element is just * being moved across the DOM. */ disconnect(): void; /** * Returns the component property value. If the component has not yet been created, the value is * retrieved from the cached initialization values. */ getValue(property: string): any; /** * Sets the input value for the property. If the component has not yet been created, the value is * cached and set when the component is created. */ setValue(property: string, value: any): void; applyMethod(methodName: keyof any, args: any[]): any; /** * Creates a new component through the component factory with the provided element host and * sets up its initial inputs, listens for outputs changes, and runs an initial change detection. */ protected initializeComponent(element: HTMLElement): void; /** Sets up listeners for the component's outputs so that the events stream emits the events. */ protected initializeOutputs(element: HTMLElement, componentRef: ComponentRef): void; } /** * Prototype for a class constructor based on an Angular component * that can be used for custom element registration. Implemented and returned * by the {@link createCustomElement createCustomElement() function}. * * @see [Angular Elements Overview](guide/elements "Turning Angular components into custom elements") * * @publicApi */ interface NgElementumConstructor { /** * Initializes a constructor instance. */ new (): NgElementum & ExposeInputs & ExposeSignals & ExposeMethods; } /** * Implements the functionality needed for a custom element. * * @publicApi */ declare abstract class NgElementum extends HTMLElement { #private; constructor(componentType: ComponentMirror, config: NgElementumConfig); /** * Prototype for a handler that responds to a change in an observed attribute. * @param attrName The name of the attribute that has changed. * @param oldValue The old value of the attribute. * @param newValue The new value of the attribute. * @returns Nothing. */ attributeChangedCallback(attrName: string, oldValue: string, newValue: string): void; /** * Prototype for a handler that responds to the insertion of the custom element in the DOM. * @returns Nothing. */ connectedCallback(): void; /** * Prototype for a handler that responds to the deletion of the custom element from the DOM. * @returns Nothing. */ disconnectedCallback(): void; protected ngElementumGetValue(propName: string): any; protected ngElementumSetValue(propName: string, newValue: string): void; setSignalValue(propName: string, newValue: string): void; remove(): void; attachShadow(init: ShadowRootInit): ShadowRoot; protected get ngElementumCachedStrategy(): NgElementumStrategy | undefined; } type ExtractMethods = { [K in keyof T]: K extends string ? T[K] extends (...args: any[]) => any ? T[K] extends Signal ? never : K : never : never; }[keyof T]; type ExtractSignals = { [K in keyof T]: K extends string ? T[K] extends Signal ? K : never : never; }[keyof T]; type UnwrapSignal = T extends Signal ? V | null : never; type ExposeInputs = { -readonly [K in keyof T as T[K] extends InputSignal ? K : never]: UnwrapSignal; }; type ExposeMethods = { [K in keyof T as M extends K ? K : never]: T[K] extends (...args: infer A) => infer R ? (...args: A) => R extends Promise ? R : Promise : never; }; type ExposeSignals = { readonly [K in keyof T as S extends K ? T[K] extends Signal ? T[K] extends WritableSignal ? never : K : never : never]: UnwrapSignal; } & { -readonly [K in keyof T as S extends K ? T[K] extends WritableSignal ? K : never : never]: UnwrapSignal; }; /** * A configuration that initializes an NgElementConstructor with the * dependencies and strategy it needs to transform a component into * a custom element class. * * @publicApi */ type NgElementumConfig = { /** * An optional list of methods to expose on the custom element. */ exposedMethods?: M[]; /** * An optional list of signals to expose on the custom element. */ exposedSignals?: S[]; /** * The config for application. * * If function passed, it will be called within the platform injection context. */ applicationConfig: ApplicationConfig | (() => ApplicationConfig); }; /** * @description Creates a custom element class based on an Angular component. * * Builds a class that encapsulates the functionality of the provided component and * uses the configuration information to provide more context to the class. * Takes the component factory's inputs and outputs to convert them to the proper * custom element API and add hooks to input changes. * * The configuration's injector is the initial injector set on the class, * and used by default for each created instance.This behavior can be overridden with the * static property to affect all newly created instances, or as a constructor argument for * one-off creations. * * @see [Angular Elements Overview](guide/elements "Turning Angular components into custom elements") * * @param component The component to transform. * @param config A configuration that provides initialization information to the created class. * @returns The custom-element construction class, which can be registered with * a browser's `CustomElementRegistry`. * * @publicApi */ declare function createCustomElement, const S extends ExtractSignals>(component: Type, config: NgElementumConfig): NgElementumConstructor; declare const platformElementum: (extraProviders?: _angular_core.StaticProvider[]) => PlatformRef; declare function createApplicationSync(applicationConfig: ApplicationConfig): ApplicationRef; declare function providePlatformEffectInterop(): StaticProvider[]; declare function providePlatformResourceInterop(): StaticProvider[]; export { NgElementum, createCustomElement, platformElementum, createApplicationSync as ɵcreateApplicationSync, providePlatformEffectInterop as ɵprovidePlatformEffectInterop, providePlatformResourceInterop as ɵprovidePlatformResourceInterop }; export type { NgElementumConfig, NgElementumConstructor };