import { Wraplet } from "./types/Wraplet"; import { Constructable } from "../utils/types/Utils"; import { NodeManager } from "./NodeManager"; import { WrapletApi } from "./types/WrapletApi"; import { WrapletApiFactoryBasicCallback } from "./types/WrapletApiFactoryCallbacks"; import { Wiring } from "./composeWrapletApi"; export interface AbstractWrapletWiringArgs { initializeCallback?: () => Promise; destroyCallback?: () => Promise; nodeManager?: (() => NodeManager | undefined) | NodeManager; } export declare abstract class AbstractWraplet implements Wraplet { protected node: N; wraplet: WrapletApi; private _nodeManager; constructor(node: N); /** * Creates the WrapletApi for this wraplet. Subclasses (e.g. AbstractDependentWraplet) * can override this to supply their own lifecycle callbacks without causing a * double-creation of WrapletApi. */ protected createWrapletApi(): WrapletApi; protected defaultWrapletApiWiring(): Wiring; /** * Builds a WrapletApi with the given callbacks and ensures NodeManager cleanup * is always wired into the destroy path. * * @deprecated * The new method of building WrapletApi is through adding wirings in the `wrapletApiWirings` method. * `buildWrapletApi` method will be removed in future versions. */ protected buildWrapletApi(initializeCallback?: WrapletApiFactoryBasicCallback, destroyCallback?: WrapletApiFactoryBasicCallback): WrapletApi; /** * Wires up the WrapletApi with lifecycle callbacks and NodeManager integration. */ protected wrapletApiWirings(): Wiring[]; protected get nodeManager(): NodeManager; /** * Subclasses must return an array of constructors covering all types in union N. * Wrap the result in the `supportedTypeGuard` helper to make sure that the array contains all * and only classes that extend the given type. */ protected supportedNodeTypes(): readonly Constructable[] | null; /** * Helper for subclasses to easily satisfy the exhaustive check. */ protected supportedNodeTypesGuard[]>(types: T & (Exclude> extends never ? T : never)): T; /** * This method gets invoked when the wraplet is initialized. */ protected onInitialize(): Promise; /** * This method gets invoked when the wraplet is destroyed. */ protected onDestroy(): Promise; static wiring(args: AbstractWrapletWiringArgs): Wiring; /** * Instantiates wraplets on a given ParentNode. * * @param node - The ParentNode to instantiate wraplets on. * @param attribute - The attribute to look for or a function to retrieve nodes. * @param additional_args - Additional arguments to pass to the wraplet constructor. * * @returns An array of instantiated wraplets. */ protected static createWraplets AbstractWraplet, PN extends ParentNode>(this: T, node: PN, attribute: string | ((node: PN) => Iterable), additional_args?: unknown[]): InstanceType[]; /** * Instantiates and initializes wraplets on a given ParentNode. * * @param node - The ParentNode to instantiate wraplets on. * @param attribute - The attribute to look for or a function to retrieve nodes. * @param additional_args - Additional arguments to pass to the wraplet constructor. * * @returns An array of instantiated wraplets. */ protected static createAndInitializeWraplets; }, PN extends ParentNode>(this: T, node: PN, attribute: string | ((node: PN) => Iterable), additional_args?: unknown[]): Promise[]>; }