import type { RenderResult } from "@knyt/weaver"; import { __isKnytElementComposed, __knytElementComposedRenderer, type __knytElementComposedHotUpdate, type __knytElementComposedLifecycle } from "./constants.ts"; import type { KnytElement } from "./KnytElement.ts"; import type { HTMLElementConstructor, PropertiesDefinition } from "./types.ts"; /** * @internal scope: package */ export type RendererFn> = ( /** * @deprecated The host should be retrieved from the lifecycle function. * * ### As this API was only available in an alpha version, this WILL be removed without a major release. */ this: KnytElement.FromPropertiesDefinition, /** * @deprecated The host should be retrieved from the lifecycle function. * * ### As this API was only available in an alpha version, this WILL be removed without a major release. */ host: KnytElement.FromPropertiesDefinition) => RenderResult; /** * @internal scope: package */ export type LifecycleFn> = (this: KnytElement.FromPropertiesDefinition, host: KnytElement.FromPropertiesDefinition) => RendererFn | void; /** * An HMR hook that is called whenever the constructor is updated. * * @remarks * * The function shouldn't return a promise, because we don't want to * encourage any wait logic. The HMR process should simply be fire-and-forget. * Generally speaking, the update should occur within a few microtasks, * and not await any element operations. * * @internal scope: package */ export type HotUpdateFn = (params: HotUpdateFn.Params) => void; export declare namespace HotUpdateFn { type Params = { tagName: string; nextConstructor: KnytElementComposed.Constructor; instances: HTMLElement[]; }; } /** * A type representing a `KnytElement` composed by `defineKnytElement`. * * @internal scope: workspace */ export type KnytElementComposed = KnytElement & { [__knytElementComposedRenderer]: RendererFn; }; export declare namespace KnytElementComposed { /** * Static members added to a `KnytElementComposed` constructor. * * @internal scope: workspace */ type ConstructorStaticMembers = { /** * A marker to identify a `KnytElementComposed` constructor. * * @internal scope: workspace */ readonly [__isKnytElementComposed]: true; /** * The lifecycle function used to create the renderer. * * @internal scope: workspace */ [__knytElementComposedLifecycle]: LifecycleFn; /** * An HMR hook that is called whenever the constructor is updated. * * @internal scope: workspace * * @remarks * * Despite being optional, this method is NOT detachable from the constructor. * It must be called with the constructor as `this` context. */ [__knytElementComposedHotUpdate]?: HotUpdateFn; }; /** * A type representing a `KnytElement` constructor composed by `defineKnytElement`. * * @internal scope: workspace */ type Constructor = KnytElement.Constructor & ConstructorStaticMembers; } /** * A type guard to check if an element is a `KnytElementComposed`. * * @internal scope: workspace */ export declare function isKnytElementComposed(element: HTMLElement | undefined): element is KnytElementComposed; /** * A type guard to check if a constructor is a `KnytElementComposed.Constructor`. * * @internal scope: workspace */ export declare function isKnytElementComposedConstructor(constructor: HTMLElementConstructor | undefined): constructor is KnytElementComposed.Constructor; //# sourceMappingURL=KnytElementComposed.d.ts.map