/** * The style scope identifier * * It is actually a non-negative integer. * * Specifically, `0` represents *global* scope, which means it is a global style in stylesheets. * However, in elements, `0` means it does not match any stylesheets other than the global styles. */ type StyleScopeId = number; /** * Style scope manager */ declare class StyleScopeManager { static globalScope(): StyleScopeId; register(name: string): StyleScopeId; queryName(id: StyleScopeId): string | undefined; } /** * Class manager for non-virtual `Element` */ declare class ClassList { constructor(element: Element$4, externalNames: string[] | undefined, owner: ClassList | null, styleScope: number, extraStyleScope: number | undefined, styleScopeManager: StyleScopeManager | undefined); toggle(name: string, force?: boolean, segmentIndex?: StyleSegmentIndex): boolean; contains(name: string, segmentIndex?: StyleSegmentIndex): boolean; /** * Set class string * * Returns `false` if the not success. * Although this method accepts `string[]`, it contains a deprecated behavior (use `setClassNameList` in this case). * */ setClassNames(names: string, segmentIndex?: StyleSegmentIndex): boolean; /** @deprecated */ setClassNames(names: string[], segmentIndex?: StyleSegmentIndex): boolean; /** Set class list */ setClassNameList(names: string[], segmentIndex?: StyleSegmentIndex): boolean; /** Returns space separated class string */ getClassNames(segmentIndex?: StyleSegmentIndex): string; } type DataPath = Array; type MultiPaths = DataPath[]; declare const parseSinglePath: (str: string) => DataPath; declare const parseMultiPaths: (str: string | readonly string[]) => MultiPaths; type data_path_DataPath = DataPath; type data_path_MultiPaths = MultiPaths; declare const data_path_parseMultiPaths: typeof parseMultiPaths; declare const data_path_parseSinglePath: typeof parseSinglePath; declare namespace data_path { export { type data_path_DataPath as DataPath, type data_path_MultiPaths as MultiPaths, data_path_parseMultiPaths as parseMultiPaths, data_path_parseSinglePath as parseSinglePath }; } /** * Interface that can be implement dynamically * * A `TraitBehavior` is like a TypeScript interface, but can be implemented dynamically. * It requires the implementors to implement `TIn` . * Also, it can provide do a transform from `TIn` to `TOut` as common logic of the trait. */ declare class TraitBehavior { ownerSpace: ComponentSpace; } declare class TextNode implements NodeCast { ownerShadowRoot: ShadowRoot; parentNode: Element$4 | null; parentIndex: number; containingSlot: Element$4 | null | undefined; slotNodes: Node[] | undefined; slotIndex: number | undefined; static isTextNode: (e: any) => e is TextNode; asTextNode(): TextNode; asElement(): null; asNativeNode(): null; asVirtualNode(): null; asShadowRoot(): null; asGeneralComponent(): null; asInstanceOf(): null; /** Destroy the backend element */ destroyBackendElement(): void; /** * Destroy the backend element when removed from any parent element */ destroyBackendElementOnRemoval(): void; /** * Cancel the destroy scheduling of the backend element */ cancelDestroyBackendElementOnRemoval(): void; /** * Destroy the backend element when removed from any parent element * * @deprecated Use `destroyBackendElementOnRemoval` instead. */ destroyBackendElementOnDetach(): void; /** * Cancel the destroy scheduling of the backend element * * @deprecated Use `cancelDestroyBackendElementOnRemoval` instead. */ cancelDestroyBackendElementOnDetach(): void; /** Get the backend element */ getBackendElement(): GeneralBackendElement | null; /** Get the backend context */ getBackendContext(): GeneralBackendContext | null; /** Get composed parent (including virtual nodes) */ getComposedParent(): Element$4 | null; get $$(): GeneralBackendElement | null; get textContent(): string; set textContent(text: string); } declare class VirtualNode extends Element$4 { [VIRTUAL_NODE_SYMBOL]: true; static isVirtualNode: (e: any) => e is VirtualNode; } type Node$1 = TextNode | Element$4; interface NodeCast { /** * Cast a node to a text node * * Returns `null` if the element is not a text node. */ asTextNode(): TextNode | null; /** * Cast a node to an element (native node, virtual node, or component node) * * Returns `null` if the element is not a text node. */ asElement(): Element$4 | null; /** * Cast an element to a native node * * Returns `null` if the element is not a native node. */ asNativeNode(): NativeNode | null; /** * Cast an element to a virtual node * * Returns `null` if the element is not a virtual node. */ asVirtualNode(): VirtualNode | null; /** * Cast an element to a shadow root * * Returns `null` if the element is not a shadow root. */ asShadowRoot(): ShadowRoot | null; /** * Cast an element to a general component * * Returns `null` if the element is not a component */ asGeneralComponent(): GeneralComponent | null; /** * Cast an element to the instance of the specified component * * Returns `null` if the element is not the instance of the specified component. */ asInstanceOf(componentDefinition: ComponentDefinition): ComponentInstance | null; } declare const dumpSingleElementToString: (elem: any) => string; declare const dumpElementToString: (elem: any, composed: boolean, tabDepth?: number) => string; declare const dumpElement: (elem: any, composed: boolean) => void; declare const enum SlotMode { Single = 1, Multiple = 2, Dynamic = 3 } declare class ShadowRoot extends VirtualNode { constructor(); static isShadowRoot: (e: any) => e is ShadowRoot; static createShadowRoot(host: GeneralComponent): ShadowRoot; getHostNode(): GeneralComponent; createTextNode(text?: string): TextNode; createNativeNode(tagName: string): NativeNode; createVirtualNode(virtualName?: string): VirtualNode; createNativeNodeWithInit(tagName: string, stylingName: string, placeholderHandlerRemover: (() => void) | undefined, initPropValues?: (comp: NativeNode) => void): NativeNode; resolveComponent(tagName: string, usingKey?: string): { using: GeneralComponentDefinition | string; waiting?: ComponentWaitingList; }; /** * Create a component if possible * * Placeholding status should be checked with `checkComponentPlaceholder` . * This function may create a native node if the using target is native node. */ createComponent(tagName: string, usingKey?: string, genericTargets?: { [key: string]: string; }, placeholderCallback?: ((c: GeneralComponentDefinition) => void) | undefined, initPropValues?: (comp: GeneralComponent | NativeNode) => void): GeneralComponent | NativeNode; createComponentByDef(tagName: string, componentDef: GeneralComponentDefinition, genericTargets?: { [key: string]: string; }, placeholderHandlerRemover?: (() => void) | undefined, initPropValues?: (comp: GeneralComponent | NativeNode) => void): GeneralComponent; createComponentByDef(tagName: string, componentDef: string, genericTargets?: { [key: string]: string; }, placeholderHandlerRemover?: (() => void) | undefined, initPropValues?: (comp: GeneralComponent | NativeNode) => void): NativeNode; createComponentByDef(tagName: string, componentDef: GeneralComponentDefinition | string, genericTargets?: { [key: string]: string; }, placeholderHandlerRemover?: (() => void) | undefined, initPropValues?: (comp: GeneralComponent | NativeNode) => void): GeneralComponent | NativeNode; /** * Find whether this component is placeholding or not * * This method will only find in the component `using` list and `generics` list. * If not found, returns `undefined` . * If the placeholder will be used, returns `true` ; `false` otherwise. */ checkComponentPlaceholder(usingKey: string): boolean | undefined; getElementById(id: string): Element$4 | undefined; /** Get the slot element with the specified name */ getSlotElementFromName(name: string): Element$4 | Element$4[] | null; /** * Get the slot element for the slot content * * The provided node must be a valid child node of the host of this shadow root. * Otherwise the behavior is undefined. */ getContainingSlot(elem: Node$1 | null): Element$4 | null; /** * Get the elements that should be composed in specified slot * * This method always returns a new array (or null if the specified slot is invalid). * It is convenient but less performant. * For better performance, consider using `forEachNodeInSpecifiedSlot` . */ getSlotContentArray(slot: Element$4): Node$1[] | null; /** * Iterate slots */ forEachSlot(f: (slot: Element$4) => boolean | void): void; /** * Iterate through elements ahd their corresponding slots (including slots-inherited nodes) * @param f A function to execute for each element. Return false to break the iteration. * @returns A boolean indicating whether the iteration is complete. */ forEachNodeInSlot(f: (node: Node$1, slot: Element$4 | null | undefined) => boolean | void): boolean; /** * Iterate through elements of a specified slot (including slots-inherited nodes) * @param f A function to execute for each element. Return false to break the iteration. * @returns A boolean indicating whether the iteration is complete. */ forEachNodeInSpecifiedSlot(slot: Element$4 | null, f: (node: Node$1) => boolean | void): boolean; /** * Iterate through elements ahd their corresponding slots (NOT including slots-inherited nodes) * @param f A function to execute for each element. Return false to break the iteration. * @returns A boolean indicating whether the iteration is complete. */ forEachSlotContentInSlot(f: (node: Node$1, slot: Element$4 | null | undefined) => boolean | void): boolean; /** * Iterate through elements of a specified slot (NOT including slots-inherited nodes) * @param f A function to execute for each element. Return false to break the iteration. * @returns A boolean indicating whether the iteration is complete. */ forEachSlotContentInSpecifiedSlot(slot: Element$4 | null, f: (node: Node$1) => boolean | void): boolean; /** * Check whether a node is connected to this shadow root */ isConnected(node: Node$1): boolean; /** * Set the dynamic slot handlers * * If the handlers have not been set yet, * the `insertSlotHandler` will be called for each slot that has been added to the shadow tree, * otherwise call `updateSlotHandler` for each slots. */ setDynamicSlotHandler(insertSlotHandler: (slots: { slot: Element$4; name: string; slotValues: { [name: string]: unknown; }; }[]) => void, removeSlotHandler: (slots: Element$4[]) => void, updateSlotHandler: (slot: Element$4, slotValues: { [name: string]: unknown; }) => void, updateSlotValueHandler: (slot: Element$4, name: string) => void): void; /** * Use the same dynamic slot handlers with the `source` */ useDynamicSlotHandlerFrom(source: ShadowRoot): void; /** * Update a slot value * * The updated value should be applied with `applySlotValueUpdates` call. */ replaceSlotValue(slot: Element$4, name: string, value: unknown): void; /** * Apply slot value updates */ applySlotValueUpdates(slot: Element$4): void; applySlotUpdates(): void; /** * Get slot mode */ getSlotMode(): SlotMode; } declare const ELEMENT_SYMBOL: unique symbol; declare const NATIVE_NODE_SYMBOL: unique symbol; declare const VIRTUAL_NODE_SYMBOL: unique symbol; declare const COMPONENT_SYMBOL: unique symbol; declare class NativeNode extends Element$4 { [NATIVE_NODE_SYMBOL]: true; stylingName: string; static isNativeNode: (e: any) => e is NativeNode; setModelBindingListener(propName: string, listener: ModelBindingListener): void; getModelBindingListeners(): { [name: string]: ModelBindingListener; }; } type MiddlewareHook = (this: ShadowRoot, next: (...metadata: T) => R, ...metadata: T) => R; type ComponentSpaceHooks = { createTextNode: MiddlewareHook; createNativeNode: MiddlewareHook; createComponent: MiddlewareHook; }; declare class ComponentWaitingList { constructor(ownerSpace: ComponentSpace, isPub: boolean, alias: string); add(callback: (c: GeneralComponentDefinition) => void): void; hintUsed(owner: GeneralComponent): void; remove(callback: (c: GeneralComponentDefinition) => void): void; call(c: GeneralComponentDefinition): void; } /** A group of components for cross-component using */ declare class ComponentSpace { /** * The corresponding `styleScopeManager`. * * A `styleScopeManager` can be shared by multiple component spaces. */ readonly styleScopeManager: StyleScopeManager; /** The hooks used to alter some workflow within this component space. */ readonly hooks: ComponentSpaceHooks; /** * Create a new component space * * The `defaultComponent` is the default component path. * It should be defined soon after creation. * A `baseSpace` can be provided as a "base" component space - * every component alias (and behavior alias) in the space will be imported when creation. * However, if any new component is added to the base space after the creation, * it will not be added to the created space. */ constructor(defaultComponent?: string, baseSpace?: ComponentSpace, styleScopeManager?: StyleScopeManager, allowUnusedNativeNode?: boolean); /** * Update the default component options for this space * * The new options will be merged with existing options. */ updateComponentOptions(componentOptions: ComponentOptions): void; getComponentOptions(): NormalizedComponentOptions; /** * Mark a style scope as shared * * This style scope will not be written to backend as a dedicated style scope for a component. */ setSharedStyleScope(styleScopeId: StyleScopeId): void; /** * Set (or update) a global using component item * * This will allow all the components in this component space using this component automatically, * without declaring it with `using` or `usingComponents` again. * The target can also be a tag name of a native node. */ setGlobalUsingComponent(key: string, target: GeneralComponentDefinition | string): void; /** * Import another component space * * The components in the imported space can be used by components in this space. * The `protoDomain` should be URL-like, i.e. `space://another-space` . * When using, the components in the imported space should be specified with `protoDomain` . * For example, if `protoDomain` is `space://another-space` and one imported component has alias `my-comp` , * then it should be specified with `space://another-space/my-comp` . * If `privateUse` set to false, only component alias in the imported space can be used; * the original name of components is imported otherwise. */ importSpace(protoDomain: string, space: ComponentSpace, privateUse: boolean): void; /** * Get a component by the `path` * * The component `is` is actually treated as the "path" of the component. * In other words, the component `is` field can be a string like `path/to/the/component` . * Other components can be used by the component with "relative path" specified. * In this method, if the `path` is given as a relative path (not started with `/` ), * it will be converted according to the `basePath` . * If the `path` is given as a URL-like format, * the component will be searched in imported component spaces ( `importSpace()` for details). */ getComponentByUrl(path: string, basePath: string): GeneralComponentDefinition; /** * Get a component by the `path` * * Similar to `getComponentByUrl()` , * but returns `null` instead of the default component if no component was found. */ getComponentByUrlWithoutDefault(path: string, relPath: string): GeneralComponentDefinition | null; private getComponent; getDefaultComponent(): GeneralComponentDefinition | null; isDefaultComponent(def: GeneralComponentDefinition): boolean; getGlobalUsingComponent(key: string): GeneralComponentDefinition | NativeNodeDefinition | null; /** * Get a behavior by the `path` * * Similar to `getComponentByUrlWithoutDefault()` but for behaviors. */ getBehaviorByUrl(path: string, relPath: string): GeneralBehavior | null; /** Register a component in this space */ defineComponent(def: ComponentParams & ThisType>): ComponentDefinition; /** Register a behavior in this space */ defineBehavior(def: ComponentParams & ThisType>): Behavior; /** Register a component or a behavior with chaining API */ define(is?: string): BehaviorBuilder; /** * Register a component or a behavior with chaining API (with method caller type specified) * * This API is generally designed for adapters which require special method callers. */ defineWithMethodCaller(is?: string): BehaviorBuilder; /** Register a component in this space using an existing definition */ registerComponent(is: string, comp: GeneralComponentDefinition): void; /** * Start a series of components and behaviors registration * * In most cases, `groupRegister` is prefered. */ startGroupRegister(): void; /** * End a series of components and behaviors registration * * In most cases, `groupRegister` is prefered. */ endGroupRegister(): void; /** * Group a series of components and behaviors registration * * If any placeholder should be replaced, * the replacement will happen after the whole series of registration. */ groupRegister(cb: () => R): R | undefined; /** * Assign a public alias to a component * * The alias can be used in other component spaces which imported this component space. * One component may have multiple aliases. */ exportComponent(alias: string, is: string): void; /** Get a component by its exported alias */ getExportedComponent(alias: string): GeneralComponentDefinition | undefined; /** Get a behavior by its exported alias */ getExportedBehavior(alias: string): GeneralBehavior | undefined; /** * Assign a public alias to a behavior * * The alias can be used in other component spaces which imported this component space. * One behavior may have multiple aliases. */ exportBehavior(alias: string, is: string): void; /** * Set a listener which will be called when a placeholded component is used. * * This can be used as a hint for a component that should be registered later. * If `isPub` is false, the `alias` is the path of the component, a.k.a. `is` . * Otherwise, it is the exported `alias` instead. */ setComponentWaitingListener(listener: ((isPub: boolean, alias: string, owner: GeneralComponent) => void) | null): void; /** * Create a component by URL * * This `url` can contain params (started with "?" character). * The params will try to be set to component properties (if matches the property name). */ createComponentByUrl(tagName: string, url: string, genericTargets: { [name: string]: string; } | null, backendContext: GeneralBackendContext | null): GeneralComponent; /** * Define a trait behavior * * A trait behavior * Optionally, the trait behavior can add a conversion function. * This function can convert the implementation to another interface. */ defineTraitBehavior(): TraitBehavior; defineTraitBehavior(trans: (impl: TIn) => TOut): TraitBehavior; } declare const getDefaultComponentSpace: () => ComponentSpace; type GeneralFuncType = (this: any, ...args: any[]) => any; declare class FuncArr { empty: boolean; constructor(type: string); add(func: F): void; remove(func: F): F | null; call(caller: ThisParameterType, args: Parameters, relatedComponent?: AnyComponent | string): boolean; } declare function safeCallback(this: void, type: string, method: F, caller: ThisParameterType, args: Parameters, relatedComponent?: AnyComponent | string): ReturnType | undefined; /** * Options for an event */ type EventOptions = { originalEvent?: unknown; bubbles?: boolean; composed?: boolean; capturePhase?: boolean; extraFields?: { [key: string]: unknown; }; handleListenerReturn?: (ret: unknown) => boolean | void; }; /** * Options for an event listener */ type EventListenerOptions = { /** Always stop bubbling after this listener */ final?: boolean; /** Mark mutated after this listener (ignored if `final` is true) */ mutated?: boolean; /** Listen in the capture phase */ capture?: boolean; /** The same as `capture` for compatibility */ useCapture?: boolean; }; /** * Event bubbling control */ declare const enum EventBubbleStatus { Normal = 0, NoDefault = 1 } type EventListener = (ev: ShadowedEvent) => boolean | void; declare const enum MutLevel { None = 0, Mut = 1, Final = 2 } declare const enum EventPhase { None = 0, CapturingPhase = 1, AtTarget = 2, BubblingPhase = 3 } type ShadowedEvent = Required> & { target: Element$4; mark: { [name: string]: unknown; } | null; currentTarget: Element$4; }; declare class Event { type: string; timeStamp: number; detail: TDetail; bubbles: boolean; composed: boolean; extraFields: Record | undefined; eventPhase: EventPhase; constructor(name: string, detail: TDetail, options?: EventOptions); getEventBubbleStatus(): EventBubbleStatus; wrapShadowedEvent(targetCaller: Element$4, mark: { [name: string]: unknown; } | null, currentTargetCaller: Element$4): ShadowedEvent; getEventName(): string; getOriginalEvent(): unknown; preventDefault(): void; defaultPrevented(): boolean; stopPropagation(): void; propagationStopped(): boolean; hasListener(): boolean; markMutated(): void; mutatedMarked(): boolean; listenerReturnHandler(): ((ret: unknown) => boolean | void) | undefined; isCapturePhase(): boolean; callListener(currentTarget: Element$4, mark: Record | null, target: Element$4, isCapture: boolean): void; dispatch(target: Element$4, externalTarget?: GeneralBackendElement): EventBubbleStatus; static dispatchEvent(target: Element$4, event: Event): EventBubbleStatus; static dispatchExternalEvent(element: Element$4, externalTarget: GeneralBackendElement, event: Event): EventBubbleStatus; static triggerEvent(this: void, target: Element$4, name: string, detail: TDetail, options?: EventOptions): EventBubbleStatus; static triggerExternalEvent(this: void, element: Element$4, target: GeneralBackendElement, name: string, detail: TDetail, options?: EventOptions): EventBubbleStatus; static triggerBackendEvent(this: void, element: Element$4, name: string, detail: TDetail, options: EventOptions, target?: GeneralBackendElement): EventBubbleStatus; } /** * An external shadow root * * It can be used to build an external component. * External component is a customizable subtree that can be composed with normal components. * It allows third-party frameworks to render a subtree and then compose it together. * However, the subtree must be created in the same backend context. */ interface ExternalShadowRoot { root: GeneralBackendElement | null; slot: GeneralBackendElement | null; getIdMap(): { [id: string]: GeneralBackendElement; }; handleEvent(target: GeneralBackendElement, event: Event): void; setListener(elem: GeneralBackendElement, ev: string, listener: (event: ShadowedEvent) => unknown): void; } /** * A template engine that handles the template part of a component */ interface TemplateEngine { /** * Preprocess a behavior and generate a preprocessed template * * This function is called during component prepare. * The `_$template` field of the behavior is designed to be handled by the template engine, * and should be preprocessed in this function. */ create(behavior: GeneralBehavior, componentOptions: NormalizedComponentOptions): Template; } /** * A preprocessed template */ interface Template { /** * Create a template instance for a component instance */ createInstance(elem: GeneralComponent, createShadowRoot: (component: GeneralComponent) => ShadowRoot): TemplateInstance; /** * Update the content of the template (optional) * * Implement this function if template update is needed (usually used during development). * The behavior is always the object which used when creation. */ updateTemplate?(behavior: GeneralBehavior): void; } /** * A template instance that works with a component instance */ interface TemplateInstance { /** * The shadow root of the component * * This field should not be changed. */ shadowRoot: ShadowRoot | ExternalShadowRoot; /** * Apply the updated template content (optional) * * Implement this function if template update is needed (usually used during development). * The template is always the object which used when creation. */ updateTemplate?(template: Template, data: DataValue): void; initValues(data: DataValue): void; updateValues(data: DataValue, changes: DataChange[]): void; } type template_engine_Template = Template; type template_engine_TemplateEngine = TemplateEngine; type template_engine_TemplateInstance = TemplateInstance; declare namespace template_engine { export type { template_engine_Template as Template, template_engine_TemplateEngine as TemplateEngine, template_engine_TemplateInstance as TemplateInstance }; } declare const DEFAULT_PROC_GEN_GROUP: (name: string) => ProcGen; type ProcGenGroup = (name: string) => ProcGen; type ProcGenGroupList = { [path: string]: ProcGenGroup; }; type ComponentTemplate = { groupList?: ProcGenGroupList; content: (name: string) => ProcGen; updateMode?: string; fallbackListenerOnNativeNode?: boolean; procGenWrapperType?: typeof ProcGenWrapper; }; declare const enum BindingMapUpdateEnabled { Disabled = 0, Enabled = 1, Forced = 2 } declare class GlassEaselTemplateEngine implements TemplateEngine { create(behavior: GeneralBehavior, componentOptions: NormalizedComponentOptions): Template; } declare class GlassEaselTemplate implements Template { genObjectGroupEnv: ProcGenEnv; updateMode: string; fallbackListenerOnNativeNode: boolean; constructor(behavior: GeneralBehavior); /** * Update the underlying template content * * This method does not affect created instances. */ updateTemplate(behavior: GeneralBehavior): void; createInstance(comp: GeneralComponent, createShadowRoot: (component: GeneralComponent) => ShadowRoot): TemplateInstance; } declare class GlassEaselTemplateInstance implements TemplateInstance { comp: GeneralComponent; shadowRoot: ShadowRoot; procGenWrapper: ProcGenWrapper; forceBindingMapUpdate: BindingMapUpdateEnabled; bindingMapGen: { [field: string]: BindingMapGen[]; } | undefined; constructor(template: GlassEaselTemplate, comp: GeneralComponent, shadowRoot: ShadowRoot); updateTemplate(template: GlassEaselTemplate, data: DataValue): void; private _$applyTemplate; initValues(data: DataValue): ShadowRoot | ExternalShadowRoot; updateValues(data: DataValue, changes: DataChange[]): void; tryBindingMapUpdate(data: DataValue, change?: DataChange): boolean; } declare const getDefaultTemplateEngine: () => TemplateEngine; type index_ChangePropFilter = ChangePropFilter; type index_ChangePropListener = ChangePropListener; type index_ComponentTemplate = ComponentTemplate; declare const index_DEFAULT_PROC_GEN_GROUP: typeof DEFAULT_PROC_GEN_GROUP; type index_EventListenerWrapper = EventListenerWrapper; type index_GeneralLvaluePathPrefix = GeneralLvaluePathPrefix; declare const index_GeneralLvaluePathPrefix: typeof GeneralLvaluePathPrefix; type index_GlassEaselTemplateEngine = GlassEaselTemplateEngine; declare const index_GlassEaselTemplateEngine: typeof GlassEaselTemplateEngine; type index_GlassEaselTemplateInstance = GlassEaselTemplateInstance; declare const index_GlassEaselTemplateInstance: typeof GlassEaselTemplateInstance; type index_ProcGenGroup = ProcGenGroup; type index_ProcGenGroupList = ProcGenGroupList; type index_TmplDevArgs = TmplDevArgs; declare const index_getDefaultTemplateEngine: typeof getDefaultTemplateEngine; declare namespace index { export { type index_ChangePropFilter as ChangePropFilter, type index_ChangePropListener as ChangePropListener, type index_ComponentTemplate as ComponentTemplate, index_DEFAULT_PROC_GEN_GROUP as DEFAULT_PROC_GEN_GROUP, type index_EventListenerWrapper as EventListenerWrapper, index_GeneralLvaluePathPrefix as GeneralLvaluePathPrefix, index_GlassEaselTemplateEngine as GlassEaselTemplateEngine, index_GlassEaselTemplateInstance as GlassEaselTemplateInstance, type index_ProcGenGroup as ProcGenGroup, type index_ProcGenGroupList as ProcGenGroupList, type index_TmplDevArgs as TmplDevArgs, index_getDefaultTemplateEngine as getDefaultTemplateEngine }; } type UpdatePathTreeNode = true | { [key: string]: UpdatePathTreeNode; } | UpdatePathTreeNode[]; type UpdatePathTreeRoot = UpdatePathTreeNode | undefined; type ChangePropListener = (this: null, newValue: T, oldValue: T, host: GeneralComponent, elem: Element$4) => void; type ChangePropFilter = (listener: ChangePropListener, generalLvaluePath: DataPath | null | undefined, elem: Element$4, propName: string) => ChangePropListener; interface EventListenerWrapper { (elem: Element$4, evName: string, listener: EventListener, final: boolean, mutated: boolean, capture: boolean, generalLvaluePath?: DataPath | null): EventListener | null; isEventListenerWrapper?: true; } type TmplDevArgs = { A?: string[]; }; interface ProcGen { (wrapper: ProcGenWrapper, isCreation: true, data: DataValue): { C: DefineChildren; B?: { [field: string]: BindingMapGen[]; }; }; (wrapper: ProcGenWrapper, isCreation: false, data: DataValue, dataUpdatePathTree: UpdatePathTreeNode, bindingMapGenList: { [field: string]: BindingMapGen[]; } | undefined): { C: DefineChildren; B?: { [field: string]: BindingMapGen[]; }; }; } type ProcGenEnv = { group: (name: string) => ProcGen; list: ProcGenGroupList; }; type BindingMapGen = (data: DataValue, elementUpdated: (elem: Element$4) => void, updateText: (node: TextNode, content: string) => void) => void; type DefineChildren = (isCreation: boolean, defineTextNode: DefineTextNode, defineElement: DefineElement, defineIfGroup: DefineIfGroup, defineForLoop: DefineForLoop, defineSlot: DefineSlot, definePureVirtualNode: DefinePureVirtualNode, dynamicSlotValues: { [name: string]: unknown; } | undefined, slotValueUpdatePathTrees: UpdatePathTreeNode | undefined) => void; type DefineTextNode = (text: string | undefined, textInit?: (elem: TextNode) => boolean) => void; type DefineElement = (tag: string, genericImpls: { [key: string]: string; }, propertyInit: (elem: Element$4, isCreation: boolean) => void, children: DefineChildren, slot?: string, dynamicSlotValueNames?: string[]) => void; type DefineIfGroup = (branchKey: number | string, branchFunc: DefineChildren) => void; type DefineForLoop = (list: DataValue[], key: string | null, oriListUpdatePathTree: UpdatePathTreeRoot, lvaluePath: DataPath | null, itemCallback: (isCreation: boolean, item: DataValue, index: number | string, itemUpdatePathTree: UpdatePathTreeRoot, indexUpdatePathTree: UpdatePathTreeRoot, itemLvaluePath: DataPath | null, defineTextNode: DefineTextNode, defineElement: DefineElement, defineIfGroup: DefineIfGroup, defineForLoop: DefineForLoop, defineSlot: DefineSlot, definePureVirtualNode: DefinePureVirtualNode) => void) => void; type DefineSlot = (name: string | undefined, slotValueInit?: (elem: Element$4) => void, slot?: string) => void; type DefinePureVirtualNode = (children: DefineChildren, slot: string | undefined) => void; declare class ProcGenWrapper { shadowRoot: ShadowRoot; procGen: ProcGen; fallbackListenerOnNativeNode: boolean; bindingMapDisabled: boolean; changePropFilter: ChangePropFilter; eventListenerWrapper: EventListenerWrapper; constructor(shadowRoot: ShadowRoot, procGen: ProcGen, fallbackListenerOnNativeNode: boolean); create(data: DataValue): { [field: string]: BindingMapGen[]; } | undefined; update(data: DataValue, dataUpdatePathTree: UpdatePathTreeNode, bindingMapGen: { [field: string]: BindingMapGen[]; } | undefined): { [field: string]: BindingMapGen[]; } | undefined; private endBindingMapUpdateForElement; bindingMapUpdate(field: string, data: DataValue, bindingMapGenList: { [field: string]: BindingMapGen[]; }): boolean; handleChildrenCreation(children: DefineChildren, slotElement: Element$4 | undefined, dynamicSlotName: string | undefined): Node$1[]; private handleChildrenCreationAndInsert; handleChildrenUpdate(children: DefineChildren, parentNode: Element$4, slotElement: Element$4 | undefined, dynamicSlotName: string | undefined): void; private dynamicSlotUpdate; private createDynamicPlaceholder; private checkFallbackEventListener; private getInitPropValuesCallback; private createCommonElement; private tryCallPropertyChangeListener; s: (elem: Element$4, v: string) => void; l: (elem: Element$4, name: string, value: unknown, generalLvaluePath?: DataPath | null) => void; i: (elem: Element$4, v: string) => void; c: (elem: Element$4, v: string | string[]) => void; e: (elem: Element$4, classNames: (string | null)[]) => void; ei: (elem: Element$4, index: number, className: string) => void; private applyClassListUpdates; y: (elem: Element$4, v: string) => void; w: (elem: Element$4, styles: (string | null)[]) => void; wi: (elem: Element$4, valueIndex: number, newValue: string) => void; private applyStyleListUpdates; d: (elem: Element$4, name: string, v: unknown, fallbackDataHyphen: boolean) => void; m: (elem: Element$4, name: string, v: unknown) => void; v: (elem: Element$4, evName: string, v: unknown, final: boolean, mutated: boolean, capture: boolean, isDynamic: boolean, generalLvaluePath?: DataPath | null) => void; r: (elem: Element$4, name: string, v: unknown, modelLvaluePath?: DataPath | null, generalLvaluePath?: DataPath | null) => void; a: (elem: Element$4, name: string, v: unknown) => void; wl: (elem: Element$4, name: string, value: unknown) => void; p: (elem: Element$4, name: string, v: ChangePropListener, generalLvaluePath?: DataPath | null) => void; setFnFilter(changePropFilter: ChangePropFilter): void; setEventListenerWrapper(eventListenerWrapper?: EventListenerWrapper): void; devArgs(elem: Element$4): TmplDevArgs; } declare const enum GeneralLvaluePathPrefix { Data = 0, Script = 1, InlineScript = 2 } interface DevTools { inspector?: InspectorDevTools; performance?: PerformanceDevTools; } interface MountPointEnv { } interface InspectorDevTools { addMountPoint(root: Element$4, env: MountPointEnv): void; removeMountPoint(root: Element$4): void; } interface PerformanceDevTools { now: () => number; addTimelineEvent: (time: number, type: string, data?: Record) => void; addTimelineComponentEvent: (time: number, type: string, component: GeneralComponent, data?: Record) => void; addTimelinePerformanceMeasureStart: (time: number, type: string, component: GeneralComponent | string | null, data?: Record) => void; addTimelinePerformanceMeasureEnd: (time: number) => void; addTimelineBackendWaterfall: (type: string, times: [ number, number, number ], data?: Record) => void; } /** * The deep copy strategy * * Higher level indicates more accuracy but probably less performance. */ declare enum DeepCopyKind { /** * Avoid deep copy * * This avoids any copy, and recursive objects can be handled without any failing. * However, changing non-copied data will sometimes break the logic. */ None = "none", /** * Do a simple deep copy * * This simply clones each enumerable fields in an object to a new object. * It causes stack overflow in recursive objects. * Everything in prototypes is ignored. */ Simple = "simple", /** * Do a deep copy with recursion detection * * This clones each enumerable fields in an object to a new object. * It can handle recursive objects by recursive detection. * Everything in prototypes is ignored. */ SimpleWithRecursion = "simple-recursion" } /** * Options for a component */ type ComponentOptions = { /** Is external component or not */ externalComponent?: boolean; /** * The logical tag name of the host node * * For a domlike backend (which does not support logical/styling tag names), * this can be set to `wx-*` (or similar), * means that using `wx-${tagName}` as the tag name of the host node. */ hostNodeTagName?: string; /** The template engine */ templateEngine?: TemplateEngine; /** The style scope */ styleScope?: StyleScopeId; /** An extra style scope assigned to the component */ extraStyleScope?: StyleScopeId | null; /** Inherit style scope from parent component or not */ inheritStyleScope?: boolean; /** Enable multiple slots or not */ multipleSlots?: boolean; /** Enable dynamic slots or not */ dynamicSlots?: boolean; /** Write property values of components to backend with `setAttribute` */ reflectToAttributes?: boolean; /** Allow properties and methods to be able to visit directly in component instance */ writeFieldsToNode?: boolean; /** Write node ID to backend node */ writeIdToDOM?: boolean; /** Use the methods in method caller as the event handlers or not */ useMethodCallerListeners?: boolean; /** Generate a prefix for ID written to backend node */ idPrefixGenerator?: ((this: GeneralComponent) => string) | null; /** Filter some fields out when applying to templates */ pureDataPattern?: RegExp | null; /** Decide how to deep copy component data when updates */ dataDeepCopy?: DeepCopyKind; /** Decide how to deep copy when a property changes */ propertyPassingDeepCopy?: DeepCopyKind; /** Enable listener change events or not */ listenerChangeLifetimes?: boolean; /** Component host node is virtual or not */ virtualHost?: boolean; /** Init component with property values or not */ propertyEarlyInit?: boolean; /** Property comparer function, return false if properties are equal */ propertyComparer?: ((a: any, b: any) => boolean) | null; /** Handle unknown properties or not */ unknownPropertyHandler?: ((this: GeneralComponent, name: string, value: any) => boolean | void) | null; }; type NormalizedComponentOptions = { externalComponent: boolean; hostNodeTagName: string; templateEngine: TemplateEngine | null; styleScope: StyleScopeId | null; extraStyleScope: StyleScopeId | null; inheritStyleScope: boolean; multipleSlots: boolean; dynamicSlots: boolean; reflectToAttributes: boolean; writeFieldsToNode: boolean; writeIdToDOM: boolean; useMethodCallerListeners: boolean; idPrefixGenerator: ((this: GeneralComponent) => string) | null; pureDataPattern: RegExp | null; dataDeepCopy: DeepCopyKind; propertyPassingDeepCopy: DeepCopyKind; listenerChangeLifetimes: boolean; virtualHost: boolean; propertyEarlyInit: boolean; propertyComparer: ((a: any, b: any) => boolean) | null; unknownPropertyHandler: ((this: GeneralComponent, name: string, value: any) => boolean | void) | null; }; /** * Options for global environment */ type EnvironmentOptions = { /** The default component space */ defaultComponentSpace: ComponentSpace | null; /** Throw errors when errors caught in event callbacks (useful in testing scripts) */ throwGlobalError: boolean; /** Write some extra attributes to DOM backend (for testing) */ writeExtraInfoToAttr: boolean; /** The default backend context */ backendContext: GeneralBackendContext | null; /** The devtool interface */ devTools: DevTools | null; }; /** * The default options */ declare const globalOptions: NormalizedComponentOptions & EnvironmentOptions; declare const enum NormalizedPropertyType { Invalid = "invalid", Any = "any", String = "string", Number = "number", Boolean = "boolean", Object = "object", Array = "array", Function = "function" } type PropertyDefinition = { type: NormalizedPropertyType; optionalTypes: NormalizedPropertyType[] | null; defaultFn: () => unknown; observer: ((newValue: unknown, oldValue: unknown) => void) | null; comparer: ((newValue: unknown, oldValue: unknown) => boolean) | null; reflectIdPrefix: boolean; }; declare const enum DeepCopyStrategy { None = 0, Simple = 1, SimpleWithRecursion = 2 } type DataValue = unknown; type DataObserver = (...values: unknown[]) => void; type DataChange = DataReplace | DataSplice; type DataReplace = [DataPath, DataValue, undefined, undefined]; type DataSplice = [DataPath, DataValue[], number, number]; type PropertyChange = { propName: string; prop: PropertyDefinition; oldValue: unknown; newValue: unknown; skipModelListener: boolean; }; type DataUpdateCallback = (data: { [name: string]: DataValue; }, combinedChanges: DataChange[]) => void; type ModelBindingListener = (value: DataValue) => void; type ObserverNode = { listener?: number[]; wildcard?: number[]; sub: { [name: string]: ObserverNode; }; }; declare class DataGroupObserverTree { propFields: { [name: string]: PropertyDefinition; }; observerRoot: ObserverNode; observers: DataObserverWithPath[]; constructor(propFields: { [name: string]: PropertyDefinition; }); cloneSub(): DataGroupObserverTree; addObserver(func: DataObserver, dataPath: MultiPaths): void; } type DataObserverWithPath = { path: MultiPaths; f: DataObserver; }; /** A data wrapper for data operations such as `setData` */ declare class DataGroup { data: DataWithPropertyValues; innerData: { [key: string]: DataValue; } | null; updateListener?: DataUpdateCallback; constructor(associatedComponent: ComponentInstance | null, data: DataWithPropertyValues, pureDataPattern: RegExp | null, dataDeepCopy: DeepCopyStrategy, propertyPassingDeepCopy: DeepCopyStrategy, reflectToAttributes: boolean, observerTree: DataGroupObserverTree, propertyComparer: ((a: DataValue, b: DataValue) => boolean) | null, unknownPropertyHandler: ((this: GeneralComponent, name: string, value: DataValue) => boolean | void) | null); /** Create a simple data group */ static create(data: { [key: string]: DataValue; }): DataGroup; /** Replace the underlying data */ replaceWholeData(data: DataWithPropertyValues): void; /** Add a new common data change to queue */ replaceDataOnPath(path: DataPath, newData: DataValue): void; /** Add a new array splice operation to queue */ spliceArrayDataOnPath(path: DataPath, index: number | undefined, del: number | undefined, inserts: DataValue[]): void; /** * Add a new property change to queue * * (Generally designed for template engines.) * If the `propName` is a property, * the `newData` will be deep-copied according to the `propertyPassingDeepCopy` configuration. * Otherwise, it returns false. */ replaceProperty(propName: string, newData: DataValue): boolean; /** Discard changes in queue and generate a new queue with specified changes */ setChanges(changes: DataChange[]): void; /** Get the data change queue */ getChanges(): DataChange[]; /** * Set a callback when a specified property changes * * (Generally designed for template engines.) */ setModelBindingListener(propName: string, listener: ModelBindingListener): void; /** Apply all changes in queue */ applyDataUpdates(skipModelListener?: boolean): void; } type GeneralDataGroup = DataGroup; type Empty = Record; type IsEmpty = Equal; type NewField = Extract extends never ? TValueType : never; type NewFieldList = Extract extends never ? TNewObject : never; type Equal = (() => T extends X ? 1 : 2) extends () => T extends Y ? 1 : 2 ? true : false; /** * UnionToIntersection<'foo' | 42 | true> = 'foo' & 42 & true * UnionToIntersection<(() => 'foo') | ((i: 42) => true)> = (() => 'foo') & ((i: 42) => true) */ type UnionToIntersection = (T extends unknown ? (arg: T) => void : never) extends (args: infer Arg) => void ? Arg : never; /** * Merge<{ foo: string }, { bar: number }> = { foo: string, bar: number } */ type Merge = U extends infer T ? { [K in keyof T]: T[K]; } : never; /** * IsAny = true * IsAny<{}> = false */ type IsAny = ((S: S) => S extends T ? 1 : 2) extends (R: R) => R extends any ? 1 : 2 ? true : false; /** * IsNever = true * IsNever = false * IsNever = false */ type IsNever = [T] extends [never] ? true : false; type SetDataStringPath = [Prefix] extends [never] ? `${K}` : K extends number ? `${Prefix}[${K}]` : `${Prefix}.${K}`; type Tuple = 0 extends 1 ? never : Res['length'] extends T ? Res : Tuple; type Subtract = Tuple extends [...Tuple, ...infer Rest] ? Rest['length'] : never; /** * SetDataSetter<{ name: string; foo: { bar: number } }> = { * name: string, * foo: { bar: number }, * 'foo.bar': number, * } * setDataSetter<{ list: number[], foo: { bar: number }[]}> = { * list: number[], * `list[${number}]`: number, * foo: { bar: number }[], * `foo[${number}]`: { bar: number }[], * `foo[${number}].bar`: number, * } */ type SetDataSetter = Count extends 0 ? Record, T> : IsAny extends true ? Record, T> : UnionToIntersection, Subtract> & Record, T[P]>; }[keyof T & number] : T extends Record ? { [P in keyof T & (string | number)]: SetDataSetter, Subtract> & Record, T[P]>; }[keyof T & (string | number)] : never>; /** * DeepReadonly<{ foo: { bar: number } }> = { * readonly foo: { * readonly bar: number * } * } */ type DeepReadonly = Count extends 0 ? T : T extends Record ? T extends (...args: any[]) => any ? T : { readonly [P in keyof T]: DeepReadonly>; } : T; type PublicFields = { [K in keyof T as K extends `_$${any}` ? never : K]: T[K]; }; /** * ObjectDataPathStrings<{ name: string; age: number }> = 'name' | 'age' * ObjectDataPathStrings<{ * refCount: number; * person: { name: string; age: number }; * }> = 'refCount' | 'person' | 'person.name' | 'person.age' * ObjectDataPathStrings<{ books: [{ name: string; price: number }] }> = * 'books' | `books[${number}]` | `books[${number}].name` | `books[${number}].price` */ type ObjectDataPathStrings = Count extends 0 ? SetDataStringPath : IsAny extends true ? SetDataStringPath : T extends any[] ? { [P in keyof T & number]: SetDataStringPath | ObjectDataPathStrings, Subtract>; }[keyof T & number] : T extends Record ? { [P in keyof T & (string | number)]: SetDataStringPath | ObjectDataPathStrings, Subtract>; }[keyof T & (string | number)] : Prefix; type ObserverDataPathStrings> = '**' | S | `${S}.**`; /** * GetFromDataPathString<{ name: string; age: number }, 'name'> = string * GetFromDataPathString<{ person: { name: string; age: number } }, 'person.name'> = string * GetFromDataPathString<{ books: [{ name: string; price: number }] }, 'books[0].name'> = string */ type GetFromDataPathString = P extends keyof T ? T[P] : P extends '' ? T : P extends `[${infer K extends keyof T & number}].${infer R}` ? GetFromDataPathString : P extends `[${infer K extends keyof T & number}]${infer R}` ? GetFromDataPathString : P extends `${infer K extends keyof T & string}[${infer R}` ? GetFromDataPathString : P extends `${infer K extends keyof T & string}.${infer R}` ? GetFromDataPathString : never; type GetFromObserverPathString = P extends '**' ? GetFromDataPathString : P extends `${infer K}.**` ? GetFromDataPathString : GetFromDataPathString; /** * GetFromDataPath<{ foo: { bar: number } }, ['foo', 'bar']> = number * GetFromDataPath<{ list: { bar: number }[] }, ['list', 0, 'bar']> = number * GetFromDataPath<{ list: number }, ['nonExists']> = never */ type GetFromDataPath = K extends [ infer F, ...infer R extends (string | number)[] ] ? F extends keyof T ? GetFromDataPath : never : T; declare const TaggedSymbol: unique symbol; type Tagged = typeof TaggedSymbol; type IfNeverOrAny = [T] extends [never] ? Replacement : 1 extends T & 0 ? Replacement : T; type GetTags = B extends { readonly [Tag in Tagged]: infer Tags extends symbol[]; } ? Tags : []; type GetTagsWithout> = Tags extends [infer F, ...infer R] ? Equal extends true ? GetTagsWithout : [F, ...GetTagsWithout] : []; type UnTagAll = Tagged extends keyof IfNeverOrAny ? B extends infer Origin & { readonly [Tag in Tagged]: GetTags; } ? Origin : B : B; type Tag = [IfNeverOrAny] extends [null | undefined] ? B : UnTagAll & { readonly [Tag in Tagged]: [...GetTags, T]; }; type UnTag> = Tagged extends keyof IfNeverOrAny ? Tags extends [] ? UnTagAll : UnTagAll & { readonly [Tag in Tagged]: Tags; } : B; type HasTag = T extends GetTags[number] ? true : false; type DataList = Record; type PropertyList = Record>; type PropertyType = null | StringConstructor | NumberConstructor | BooleanConstructor | ArrayConstructor | ObjectConstructor | FunctionConstructor | NormalizedPropertyType; /** * PropertyTypeToValueType = any * PropertyTypeToValueType = string * PropertyTypeToValueType = number */ type PropertyTypeToValueType = T extends null | NormalizedPropertyType.Any ? any : T extends StringConstructor | NormalizedPropertyType.String ? string : T extends NumberConstructor | NormalizedPropertyType.Number ? number : T extends BooleanConstructor | NormalizedPropertyType.Boolean ? boolean : T extends ArrayConstructor | NormalizedPropertyType.Array ? any[] : T extends ObjectConstructor | NormalizedPropertyType.Object ? Record | null : T extends FunctionConstructor | NormalizedPropertyType.Function ? (...args: any[]) => any : never; type Satisfy = V extends T ? V : T; /** * PropertyTypeToSimpleValueType = 'foo' * PropertyTypeToSimpleValueType = string */ type PropertyTypeToSimpleValueType = T extends null | NormalizedPropertyType.Any ? V : T extends StringConstructor | NormalizedPropertyType.String ? Satisfy : T extends NumberConstructor | NormalizedPropertyType.Number ? Satisfy : T extends BooleanConstructor | NormalizedPropertyType.Boolean ? Satisfy : T extends ArrayConstructor | NormalizedPropertyType.Array ? Satisfy : T extends ObjectConstructor | NormalizedPropertyType.Object ? Satisfy | null, V> : T extends FunctionConstructor | NormalizedPropertyType.Function ? Satisfy<(...args: any[]) => any, V> : never; /** * PropertyValueType = any * PropertyValueType = string * PropertyValueType = string | number * PropertyValueType<{ type: typeof String }> = string * PropertyValueType<{ type: typeof String, optionalTypes: [typeof Number] }> = string | number * PropertyValueType<{ type: typeof String, value: 'foo' }> = 'foo' * PropertyValueType<{ type: typeof String, value: 123 }> = never * PropertyValueType<{ type: typeof String, optionalTypes: [typeof Number], value: 123 }> = * string | 123 */ type PropertyValueType

> = P extends PropertyListItem ? unknown extends V ? PropertyTypeToValueType : ((a: T) => void) extends (a: PropertyType) => void ? V : V extends PropertyTypeToValueType ? PropertyTypeToSimpleValueType : never : never; type PropertyOption = { type?: T; optionalTypes?: T[]; value?: V; default?: () => V; observer?: ((newValue: V, oldValue: V) => void) | string; comparer?: (newValue: V, oldValue: V) => boolean; reflectIdPrefix?: boolean; }; type PropertyListItem = T | PropertyOption; type PropertyValues

= { [key in keyof P]: PropertyValueType; }; type DataWithPropertyValues = TData & PropertyValues; type ComponentMethod = (...args: any[]) => any; type MethodList = Record; declare const METHOD_TAG: unique symbol; type TaggedMethod = Tag; type UnTaggedMethod> = UnTag; type RelationParams = { target?: string | ComponentDefinition | GeneralBehavior | TraitBehavior; type: 'ancestor' | 'descendant' | 'parent' | 'child' | 'parent-common-node' | 'child-common-node'; linked?: (target: GeneralComponent) => void; linkChanged?: (target: GeneralComponent) => void; unlinked?: (target: GeneralComponent) => void; linkFailed?: (target: GeneralComponent) => void; }; type RelationParamsWithKey = { [name: string]: RelationParams; }; type TraitRelationParams = { target: TraitBehavior; type: 'ancestor' | 'descendant' | 'parent' | 'child' | 'parent-common-node' | 'child-common-node'; linked?: (target: GeneralComponent) => void; linkChanged?: (target: GeneralComponent) => void; unlinked?: (target: GeneralComponent) => void; linkFailed?: (target: GeneralComponent) => void; }; type ChainingFilterFunc = (chain: GeneralBehaviorBuilder) => Omit & TAddedFields; type ChainingFilterType = { add: { [key: string]: any; }; remove: string; }; type ComponentInstance = Component & { data: Merge>; properties: Merge>; } & TMethod & TExtraThisFields; type ComponentParams = { is?: string; behaviors?: (string | GeneralBehavior)[]; using?: { [name: string]: string | ComponentDefinition; }; generics?: { [name: string]: { default: string | ComponentDefinition; } | true; }; placeholders?: { [name: string]: string; }; template?: { [key: string]: any; } | null; externalClasses?: string[]; data?: TData | (() => TData); properties?: TProperty; methods?: TMethod; listeners?: { [name: string]: ComponentMethod | string; }; relations?: RelationParamsWithKey; lifetimes?: { [name: string]: ComponentMethod; }; created?: () => any; attached?: ComponentMethod; moved?: ComponentMethod; detached?: ComponentMethod; ready?: ComponentMethod; pageLifetimes?: { [name: string]: ComponentMethod; }; observers?: { fields?: string; observer: ComponentMethod | string; }[] | { [fields: string]: ComponentMethod | string; }; options?: ComponentOptions; }; type component_params_ChainingFilterFunc = ChainingFilterFunc; type component_params_ChainingFilterType = ChainingFilterType; type component_params_ComponentInstance = ComponentInstance; type component_params_ComponentMethod = ComponentMethod; type component_params_ComponentParams = ComponentParams; type component_params_DataList = DataList; type component_params_DataWithPropertyValues = DataWithPropertyValues; type component_params_DeepReadonly = DeepReadonly; type component_params_Empty = Empty; type component_params_Equal = Equal; type component_params_GetFromDataPath = GetFromDataPath; type component_params_GetFromDataPathString = GetFromDataPathString; type component_params_GetFromObserverPathString = GetFromObserverPathString; type component_params_HasTag = HasTag; type component_params_IsAny = IsAny; type component_params_IsEmpty = IsEmpty; type component_params_IsNever = IsNever; declare const component_params_METHOD_TAG: typeof METHOD_TAG; type component_params_Merge = Merge; type component_params_MethodList = MethodList; type component_params_NewField = NewField; type component_params_NewFieldList = NewFieldList; type component_params_ObjectDataPathStrings = ObjectDataPathStrings; type component_params_ObserverDataPathStrings> = ObserverDataPathStrings; type component_params_PropertyList = PropertyList; type component_params_PropertyListItem = PropertyListItem; type component_params_PropertyOption = PropertyOption; type component_params_PropertyType = PropertyType; type component_params_PropertyTypeToValueType = PropertyTypeToValueType; type component_params_PropertyValues

= PropertyValues

; type component_params_PublicFields = PublicFields; type component_params_RelationParams = RelationParams; type component_params_RelationParamsWithKey = RelationParamsWithKey; type component_params_SetDataSetter = SetDataSetter; type component_params_Tag = Tag; type component_params_TaggedMethod = TaggedMethod; type component_params_TraitRelationParams = TraitRelationParams; type component_params_UnTag> = UnTag; type component_params_UnTaggedMethod> = UnTaggedMethod; type component_params_UnionToIntersection = UnionToIntersection; declare namespace component_params { export { type component_params_ChainingFilterFunc as ChainingFilterFunc, type component_params_ChainingFilterType as ChainingFilterType, type component_params_ComponentInstance as ComponentInstance, type component_params_ComponentMethod as ComponentMethod, type component_params_ComponentParams as ComponentParams, type component_params_DataList as DataList, type component_params_DataWithPropertyValues as DataWithPropertyValues, type component_params_DeepReadonly as DeepReadonly, type component_params_Empty as Empty, type component_params_Equal as Equal, type component_params_GetFromDataPath as GetFromDataPath, type component_params_GetFromDataPathString as GetFromDataPathString, type component_params_GetFromObserverPathString as GetFromObserverPathString, type component_params_HasTag as HasTag, type component_params_IsAny as IsAny, type component_params_IsEmpty as IsEmpty, type component_params_IsNever as IsNever, component_params_METHOD_TAG as METHOD_TAG, type component_params_Merge as Merge, type component_params_MethodList as MethodList, type component_params_NewField as NewField, type component_params_NewFieldList as NewFieldList, type component_params_ObjectDataPathStrings as ObjectDataPathStrings, type component_params_ObserverDataPathStrings as ObserverDataPathStrings, type component_params_PropertyList as PropertyList, type component_params_PropertyListItem as PropertyListItem, type component_params_PropertyOption as PropertyOption, type component_params_PropertyType as PropertyType, type component_params_PropertyTypeToValueType as PropertyTypeToValueType, type component_params_PropertyValues as PropertyValues, type component_params_PublicFields as PublicFields, type component_params_RelationParams as RelationParams, type component_params_RelationParamsWithKey as RelationParamsWithKey, type component_params_SetDataSetter as SetDataSetter, type component_params_Tag as Tag, type component_params_TaggedMethod as TaggedMethod, type component_params_TraitRelationParams as TraitRelationParams, type component_params_UnTag as UnTag, type component_params_UnTaggedMethod as UnTaggedMethod, type component_params_UnionToIntersection as UnionToIntersection }; } declare const enum RelationType { Ancestor = 0, Descendant = 1, ParentNonVirtualNode = 2, ChildNonVirtualNode = 3, ParentComponent = 4, ChildComponent = 5 } interface RelationHandler { list(): TTarget[]; listAsTrait: TOut extends never ? undefined : () => TOut[]; } type RelationListener = (target: unknown) => void; type RelationFailedListener = () => void; type ComponentDefinitionWithPlaceholder = { final: GeneralComponentDefinition | null; source: GeneralBehavior; placeholder: string | null; waiting: ComponentWaitingList | null; } | NativeNodeDefinition; type NativeNodeDefinition = string; type ResolveBehaviorBuilder = IsNever extends false ? TChainingFilter extends ChainingFilterType ? Omit & TChainingFilter['add'] : B : B; interface BuilderContext extends ThisType { self: TMethodCaller; data: Merge>; setData: (this: void, newData: Partial>) => void; implement: (this: void, traitBehavior: TraitBehavior, impl: TIn) => void; relation(this: void, def: TraitRelationParams): RelationHandler; relation(this: void, def: RelationParams): RelationHandler; observer

>, V = Merge, P>>>(this: void, paths: P, func: (newValue: V) => void): void; observer

>[], V = { [K in keyof P]: Merge, P[K]>>; }>(this: void, paths: readonly [...P], func: (...newValues: V extends any[] ? V : never) => void): void; lifetime: (this: void, name: L, func: Lifetimes[L]) => void; pageLifetime: (this: void, name: string, func: (...args: any[]) => void) => void; method: (this: void, func: Fn) => TaggedMethod; listener: (this: void, func: EventListener) => TaggedMethod>; } type GeneralBehaviorBuilder = BehaviorBuilder, Record, Record, Record, never, never, Record>; declare class BehaviorBuilder { is: string | undefined; /** * Set a front-most init function * * It should return the method caller (the `this` value for various callbacks) * that will be used in future. */ methodCallerInit(func: (this: ComponentInstance) => any): ResolveBehaviorBuilder; /** * Add a behavior * * If the behavior contains a chaining filter, the chaining filter is called. */ behavior(behavior: Behavior): ResolveBehaviorBuilder, UChainingFilter>; /** * Set the chaining filter * * The chaining filter is the definition filter for chaining API. * It SHOULD return another chainable object for further chaining. */ chainingFilter(func: ChainingFilterFunc): ResolveBehaviorBuilder, TChainingFilter>; /** * Set component options * * The options will be merged with previous settings. */ options(options: ComponentOptions): ResolveBehaviorBuilder; /** * Implement a trait behavior */ implement(traitBehavior: TraitBehavior, impl: TIn): ResolveBehaviorBuilder; /** * Set the compiled template object */ template(template: { [key: string]: unknown; }): ResolveBehaviorBuilder; /** * Add other components to the component using list */ usingComponents>>(list: T): ResolveBehaviorBuilder; /** * Add some placeholders * * The alias SHOULD be in the using list, otherwise it will be ignored. */ placeholders(list: Record): ResolveBehaviorBuilder; /** * Add other generics * * The alias SHOULD NOT be in the using list, otherwise it will be ignored. */ generics(list: Record): ResolveBehaviorBuilder; /** * Add external classes */ externalClasses(list: string[]): ResolveBehaviorBuilder; /** * Add some template data fields * * It does not support raw data, but a `gen` function which returns the new data fields. * The `gen` function executes once during component creation. */ data(gen: () => NewFieldList, T>): ResolveBehaviorBuilder, TChainingFilter>; /** * Set the static template data fields * * The data will be cloned once during component creation. * If called multiple times, the static data will be overwritten but not merged! * Usually, the `data()` method is preferred. */ staticData(data: NewFieldList, T>): ResolveBehaviorBuilder, TChainingFilter>; /** * Add a single property * * The property name should be different from other properties. */ property>(name: N, def: N extends keyof (TData & TProperty) ? never : PropertyListItem): ResolveBehaviorBuilder>, TMethod, TChainingFilter, TPendingChainingFilter, TExtraThisFields>, TChainingFilter>; /** * Add a single public method * * The public method can be used as an event handler, and can be visited in component instance. */ methods(funcs: T & ThisType>): ResolveBehaviorBuilder, TChainingFilter>; /** * Add a data observer */ observer

>, V = Merge, P>>>(paths: P, func: (this: ComponentInstance, newValue: V) => void, once?: boolean): ResolveBehaviorBuilder; observer

>[], V = { [K in keyof P]: Merge, P[K]>>; }>(paths: readonly [...P], func: (this: ComponentInstance, ...newValues: V extends any[] ? V : never) => void, once?: boolean): ResolveBehaviorBuilder; /** * Add a lifetime callback */ lifetime(name: L, func: (this: ComponentInstance, ...args: Parameters) => ReturnType, once?: boolean): ResolveBehaviorBuilder; /** * Add a page-lifetime callback */ pageLifetime(name: string, func: (this: ComponentInstance, ...args: any[]) => any, once?: boolean): ResolveBehaviorBuilder; /** * Add a relation */ relation(name: string, rel: RelationParams & ThisType>): ResolveBehaviorBuilder; /** * Execute a function while component instance creation * * A `BuilderContext` is provided to tweak the component creation progress. * The return value is used as the "export" value of the behavior. */ init any>> | void>(func: (this: ComponentInstance, builderContext: BuilderContext>) => TExport, once?: boolean): ResolveBehaviorBuilder; }), TChainingFilter, TPendingChainingFilter, TExtraThisFields>, TChainingFilter>; /** * Apply a classic-style definition */ definition(def: ComponentParams & ThisType>): ResolveBehaviorBuilder, TChainingFilter>; /** * Finish build, generate a behavior, and register it in the component space */ registerBehavior(): Behavior; extraThisFieldsType(): ResolveBehaviorBuilder, TChainingFilter>; /** * Finish build, generate a component definition, and register it in the component space */ registerComponent(): ComponentDefinition; } /** * Common mixin-like behavior * * Each component definition contains a single *root* behavior. * A behavior can mixin other behaviors. */ declare class Behavior { is: string; ownerSpace: ComponentSpace; /** * Create a behavior with classic-style definition */ static create(def: ComponentParams & ThisType>, ownerSpace?: ComponentSpace): Behavior; general(): GeneralBehavior; /** * List all component dependencies (recursively) * * This method will prepare the underlying behavior. */ getComponentDependencies(genericTargets?: { [name: string]: GeneralComponentDefinition | NativeNodeDefinition; }): Set; /** Same as `prepare` method in the prototype (for backward compatibility) */ static prepare(behavior: Behavior): void; /** * Execute the prepare phase (an optimization phase) of this behavior * * Every behavior needs this phase for better future performance. * However, this phase requires a little time for execution, * and requires its all dependent behaviors created. * If a dependent behavior is not prepared, then its prepare phase is also executed. */ prepare(): void; /** * Get the template content * * This method is usually used by the template engine. */ getTemplate(): { [key: string]: unknown; } | undefined; _$updateTemplate(template: { [key: string]: unknown; }): void; /** Check whether the `other` behavior is a dependent behavior of this behavior */ hasBehavior(other: string | GeneralBehavior): boolean; /** * List the properties * * Only valid after `prepare` . */ listProperties(): string[]; /** * Get the type of the specified property * * Only valid after `prepare` . * Return `undefined` if the name is not a property. */ getPropertyType(name: string): NormalizedPropertyType | undefined; /** * Get the type of the specified property * * Only valid after `prepare` . * Return `undefined` if the name is not a property. */ getPropertyOptionalType(name: string): NormalizedPropertyType[] | null | undefined; /** * Get the methods * * Only valid after `prepare` . */ getMethods(): TMethod; } type GeneralBehavior = Behavior, Record, Record, any, any>; type Lifetimes = { created: () => void; attached: () => void; moved: () => void; detached: () => void; ready: () => void; error: (err: unknown) => void; listenerChange: (isAdd: boolean, name: string, func: EventListener, options: EventListenerOptions | undefined) => void; workletChange: (name: string, value: unknown) => void; }; declare class ComponentDefinition { is: string; behavior: Behavior; general(): GeneralComponentDefinition; /** Get the normalized component options */ getComponentOptions(): NormalizedComponentOptions; /** * List all component dependencies (recursively) * * This method will prepare the underlying behavior. * The caller component is not included in the result. */ getComponentDependencies(): Set; /** * Update the template field * * This method throws error if the template engine does not support template update. */ updateTemplate(template: { [key: string]: unknown; }): void; isPrepared(): boolean; prepare(): void; } /** * A node that has a shadow tree attached to it */ declare class Component extends Element$4 { [COMPONENT_SYMBOL]: true; shadowRoot: ShadowRoot | ExternalShadowRoot; templateInstance: TemplateInstance | undefined; tagName: string; constructor(); general(): GeneralComponent; static isComponent: (e: any) => e is GeneralComponent; /** * Cast a general component node to the instance of the specified component * * Returns `null` if the component node is not the instance of the specified component. */ asInstanceOf(componentDefinition: ComponentDefinition): ComponentInstance | null; static register(def: ComponentParams & ThisType>, space?: ComponentSpace): ComponentDefinition; static isTaggedMethod(func: unknown): func is TaggedMethod; static _$advancedCreate(tagName: string, def: ComponentDefinition, owner: ShadowRoot | null, backendContext: GeneralBackendContext | null, genericImpls: { [name: string]: ComponentDefinitionWithPlaceholder; } | null, placeholderHandlerRemover: (() => void) | undefined, initPropValues?: (comp: ComponentInstance) => void): ComponentInstance; static createWithGenericsAndContext(tagName: string | ComponentDefinition, componentDefinition: ComponentDefinition | null, genericTargets: { [name: string]: GeneralComponentDefinition; } | null, backendContext: GeneralBackendContext | null, initPropValues?: (comp: ComponentInstance) => void): ComponentInstance; static createWithGenerics(tagName: string | ComponentDefinition, componentDefinition: ComponentDefinition | null, genericImpls: { [name: string]: GeneralComponentDefinition; } | null, initPropValues?: (comp: ComponentInstance) => void): ComponentInstance; static createWithContext(tagName: string | ComponentDefinition, componentDefinition: ComponentDefinition | null, backendContext: GeneralBackendContext | null, initPropValues?: (comp: ComponentInstance) => void): ComponentInstance; static create(tagName: string | ComponentDefinition, componentDefinition: ComponentDefinition | null, initPropValues?: (comp: ComponentInstance) => void): ComponentInstance; get properties(): Merge>; get data(): Merge>; set data(newData: Partial>); get $(): { [id: string]: Element$4; } | { [id: string]: GeneralBackendElement; }; /** * Returns the shadow root element * * Returns `null` for external components. */ getShadowRoot(): ShadowRoot | null; /** * Apply the template updates to this component instance * * This method throws error if the template engine does not support template update. */ applyTemplateUpdates(): void; /** * Returns the owner component space of this component */ getOwnerSpace(): ComponentSpace; /** Get whether the component is external or not */ isExternal(): boolean; static listProperties(comp: ComponentInstance): string[]; static hasProperty(comp: Component, propName: string): boolean; /** * Check whether a property has been explicitly set since the component was created. * * A property is considered "dirty" once it receives a value through an update * (e.g. `setData`, or parent component passing a prop). * A property that still holds its initial default value is not dirty. */ static isDirtyProperty(comp: Component, propName: string): boolean; /** List methods by the component definition (backward compatibility) */ static getMethodsFromDef(compDef: ComponentDefinition): { [name: string]: GeneralFuncType; }; /** * Get a method * * If `useMethodCallerListeners` option is set for this component, * this method will use the corresponding fields in the `methodCaller` . */ static getMethod(comp: Component, methodName: string): GeneralFuncType | undefined; /** * Call a method * * If `useMethodCallerListeners` option is set for this component, * this method will use the corresponding fields in the `methodCaller` . * Returns `undefined` if there is no such method. */ callMethod(methodName: T, ...args: Parameters): ReturnType; /** * Get the corresponding component definition */ getComponentDefinition(): ComponentDefinition; /** * Get the options of the component */ getComponentOptions(): NormalizedComponentOptions; /** * Get the style scopes of the component */ getStyleScopes(): [number | null, number | null, StyleScopeManager]; /** * Check whether the `other` behavior is a dependent behavior or a implemented trait behavior */ hasBehavior(other: string | GeneralBehavior | TraitBehavior): boolean; /** Get the root behavior of the component */ getRootBehavior(): Behavior; /** * Get the trait behavior implementation of the component * * Returns `undefined` if the specified trait behavior is not implemented. */ traitBehavior(traitBehavior: TraitBehavior): TOut | undefined; /** * Set the caller (a.k.a. `this` ) of event callbacks and life-time callbacks * * By default, the caller is the component instance itself. * Use this method to override this behavior. */ setMethodCaller(caller: ComponentInstance): void; /** * Get the current caller set by `setMethodCaller` */ getMethodCaller(): ComponentInstance; /** * Add a lifetime event listener on the component */ addLifetimeListener(name: N, func: Lifetimes[N]): void; /** * remove a lifetime event listener on the component */ removeLifetimeListener(name: N, func: Lifetimes[N]): void; /** * Triggers a life-time callback on an element * * Normally external life-times should only be triggered by template engine. * Most cases should take a common method instead. */ triggerLifetime(name: string, args: Parameters): void; /** * Add a page lifetime event listener on the component */ addPageLifetimeListener(name: string, func: (...args: unknown[]) => void): void; /** * remove a page lifetime event listener on the component */ removePageLifetimeListener(name: string, func: (...args: unknown[]) => void): void; /** * Triggers a page-life-time callback on an element */ triggerPageLifetime(name: string, args: Parameters): void; /** * Add an observer on the runtime * @note This method is for debug or inspect use only, do not use it in production. */ dynamicAddObserver(func: DataObserver, dataPaths: string | readonly string[]): void; /** * Get the target elements of a relation */ getRelationNodes(relationKey: string): GeneralComponent[]; /** Check the existence of an external class */ hasExternalClass(name: string): boolean; /** Update an external class value */ setExternalClass(name: string, target: string | string[]): void; /** Get all external classes */ getExternalClasses(): { [name: string]: string[] | undefined; }; /** Schedule an update for an external class value */ scheduleExternalClassChange(name: string, target: string | string[]): void; /** Update multiple external class values */ applyExternalClassChanges(): void; /** Triggers a worklet change lifetime */ triggerWorkletChangeLifetime(name: string, value: unknown): void; /** Check a field is excluded by pureDataPattern or not */ isInnerDataExcluded(fieldName: string): boolean; static getInnerData(comp: Component): { [key: string]: DataValue; } | null; static getDataProxy(comp: Component): DataGroup; static replaceWholeData(comp: Component, newData: DataWithPropertyValues): void; /** * Schedule a data update on a single specified path * * The data update will not be applied until next `setData` or `applyDataUpdates` call. * All data observers will not be triggered immediately before applied. * Reads of the data will get the unchanged value before applied. */ replaceDataOnPath(path: readonly [...T], data: GetFromDataPath, T>): void; /** * Schedule an array update * * The behavior is like `Array.prototype.slice` . * Break the array before the `index`-th item, delete `del` items, and insert some items here. * If `index` is undefined, negative, or larger than the length of the array, * no items will be deleted and new items will be appended to the end of the array. * The data update will not be applied until next `setData` or `applyDataUpdates` call. * All data observers will not be triggered immediately before applied. * Reads of the data will get the unchanged value before applied. */ spliceArrayDataOnPath(path: readonly [...T], index: GetFromDataPath, T> extends any[] ? number | undefined : never, del: GetFromDataPath, T> extends any[] ? number | undefined : never, inserts: GetFromDataPath, T> extends (infer I)[] ? I[] : never): void; /** * Check whether there are pending changes or not */ hasPendingChanges(): boolean; /** * Apply all scheduled updates immediately * * Inside observers, it is generally not . */ applyDataUpdates(): void; /** * Pending all data updates in the callback, and apply updates after callback returns * * This function helps grouping several `replaceDataOnPath` or `spliceArrayDataOnPath` calls, * and then apply them at the end of the callback. * `setData` and `applyDataUpdates` calls inside the callback still apply updates immediately. */ groupUpdates(callback: () => T): T; /** * Schedule a classic data updates * * The data update will not be applied until next `setData` or `applyDataUpdates` call. * When called inside observers, the data update will be applied when observer ends. * All data observers will not be triggered immediately before applied. * Reads of the data will get the unchanged value before applied. */ updateData(newData?: Partial>>): void; /** * Do a classic data updates * * This method apply updates immediately, so there is no async callback. * When called inside observers, the data update will not be applied to templates. * Inside observers, it is recommended to use `updateData` instead. */ setData(newData?: Partial>>): void; } type GeneralComponentDefinition = ComponentDefinition, Record, Record>; type GeneralComponent = Component, Record, Record>; type AnyComponent = Component; declare const enum SegmentRelation { Child = 0, Descendant = 1, CrossShadowDescendant = 2 } type Segment = { id: string; classes: string[]; relation: SegmentRelation; }; type Union = Segment[]; /** A parsed selector that can be used in selector queries */ declare class ParsedSelector { unions: Union[]; private static _$parseSegment; constructor(str: string); /** Whether the selector is empty */ isEmpty(): boolean; private static _$testSelectorSegment; /** * Test whether the specified node matches the selector * * If `root` is specified, than the selector is match inside this subtree; * otherwise it match in the whole tree. */ testSelector(root: Element$4 | null, node: Element$4): boolean; /** Queries an element or elements that matches this selector */ query(root: Element$4, findOne: boolean): Element$4[] | Element$4 | null; } /** * The "style" attribute and class list segments * * This allows different modules set the "style" attribute or the class list of an element * without overriding each other. * The final value is the concat of all segments. * When calling `setNodeStyle` or `setNodeClass` on an element, * a segment can be specified. */ declare const enum StyleSegmentIndex { /** The main style segment, generally managed by the template engine (or manually set) */ MAIN = 0, /** The template style segment, preserved for template engine */ TEMPLATE_EXTRA = 1, /** The animation style segment, preserved for temporary transition */ ANIMATION_EXTRA = 2, /** The temporary style segment, preserved for high priority styles */ TEMP_EXTRA = 3 } /** * A general element * * An element can be a `NativeNode` , a `Component` , or a `VirtualNode` . */ declare class Element$4 implements NodeCast { [ELEMENT_SYMBOL]: true; is: string; dataset: { [name: string]: unknown; }; /** The `ClassList` of the element (will never change and must not be modified!) */ classList: ClassList | null; /** The parent element (must not be modified directly!) */ parentNode: Element$4 | null; /** The child nodes (must not be modified directly!) */ childNodes: Node$1[]; /** The index in parentNode.childNodes (-1 if no parentNode) (must not be modified directly!) */ parentIndex: number; /** The parent slot element in composed tree (must not be modified directly!) */ containingSlot: Element$4 | null | undefined; /** The slot content nodes composed tree (must not be modified directly!) */ slotNodes: Node$1[] | undefined; /** The index in containingSlot.slotNodes (must not be modified directly!) */ slotIndex: number | undefined; /** The shadow-root which owns the element (will never change and must not be modified!) */ ownerShadowRoot: ShadowRoot | null; constructor(); get $$(): GeneralBackendElement | null; get id(): string; set id(x: unknown); get slot(): string; set slot(x: string); get attributes(): { name: string; value: unknown; }[]; get class(): string; set class(classNames: string); get style(): string; set style(styleText: string); asTextNode(): null; asElement(): Element$4; asNativeNode(): NativeNode | null; asVirtualNode(): VirtualNode | null; asShadowRoot(): ShadowRoot | null; asGeneralComponent(): GeneralComponent | null; static isElement: (e: any) => e is Element$4; asInstanceOf(componentDefinition: ComponentDefinition): ComponentInstance | null; /** Get the backend context */ getBackendContext(): GeneralBackendContext | null; /** Get the backend mode */ getBackendMode(): BackendMode; /** Get the backend element */ getBackendElement(): GeneralBackendElement | null; /** * Destroy the backend element * * It only destroy the backend element of the element itself. */ destroyBackendElement(): void; /** * Destroy backend element for the whole subtree. * * It will destroy backend elements for the whole subtree (shadow tree) recursively. * If a backend element for a component is destroyed, * any backend element in the shadow tree of the component will also be destroyed. */ destroyBackendElementOnSubtree(): void; /** * Destroy the backend element when removed from any parent element */ destroyBackendElementOnRemoval(): void; /** * Cancel the destroy scheduling of the backend element */ cancelDestroyBackendElementOnRemoval(): void; /** * Destroy the backend element when removed from any parent element * * @deprecated Use `destroyBackendElementOnRemoval` instead. */ destroyBackendElementOnDetach(): void; /** * Cancel the destroy scheduling of the backend element * * @deprecated Use `cancelDestroyBackendElementOnRemoval` instead. */ cancelDestroyBackendElementOnDetach(): void; /** Get whether the node is virtual or not */ isVirtual(): boolean; /** Set the node class * * Although this method accepts `string[]`, it contains a deprecated behavior (see `setNodeClassList`). */ setNodeClass(classNames: string, index?: StyleSegmentIndex): void; /** @deprecated */ setNodeClass(classNames: string[], index?: StyleSegmentIndex): void; /** Toggle the node class */ setNodeClassList(classNames: string[], index?: StyleSegmentIndex): void; /** Toggle the node class */ toggleNodeClass(classNames: string, force?: boolean, index?: StyleSegmentIndex): void; /** Set the node style */ setNodeStyle(styleSegment: string, index?: StyleSegmentIndex): void; getNodeStyleSegments(): string[]; private static checkAndCallAttached; private static checkAndCallDetached; private static checkAndCallMoved; private static checkChildObservers; /** * Get whether a node has any subtree `MutationObserver` attached to it * * If there is, then tree update may have more performance impact. */ static hasSubtreeMutationObservers(node: Element$4): boolean; static insertChildReassign(shadowParent: Element$4, child: Node$1, oldSlot: Element$4 | null, newSlot: Element$4 | null, ideaPosIndex: number): void; private static findNearestNonVirtual; private static countNonVirtual; /** * Iterate elements with their slots (slots-inherited nodes included) */ static forEachNodeInSlot(node: Node$1, f: (node: Node$1, slot: Element$4 | null | undefined) => boolean | void): boolean; /** * Iterate elements in specified slot (slots-inherited nodes included) */ static forEachNodeInSpecificSlot(node: Node$1, slot: Element$4 | undefined | null, f: (node: Node$1) => boolean | void): boolean; /** * Iterate elements with their slots (slots-inherited nodes NOT included) */ static forEachSlotContentInSlot(node: Node$1, f: (node: Node$1, slot: Element$4 | null | undefined) => boolean | void): boolean; /** * Iterate elements in specified slot (slots-inherited nodes NOT included) */ static forEachSlotContentInSpecificSlot(node: Node$1, slot: Element$4 | undefined | null, f: (node: Node$1) => boolean | void): boolean; private static insertChildComposed; private static insertChildSingleOperation; private static insertChildBatchRemoval; private static insertChildBatchInsertion; private static insertChildPlaceholderReplace; appendChild(child: Node$1): void; insertChildAt(child: Node$1, index: number): void; insertBefore(child: Node$1, before?: Node$1): void; removeChildAt(index: number): void; removeChild(child: Node$1): void; replaceChildAt(child: Node$1, index: number): void; replaceChild(child: Node$1, relChild: Node$1): void; insertChildren(children: Node$1[], index: number): void; removeChildren(index: number, count: number): void; selfReplaceWith(replaceWith: Element$4): void; /** Trigger an event on the element */ triggerEvent(name: string, detail?: unknown, options?: EventOptions): void; /** Trigger an event with specified event object on the element */ dispatchEvent(ev: Event): void; /** Add an event listener on the element */ addListener(name: string, func: EventListener, options?: EventListenerOptions): void; /** Remove an event listener on the element */ removeListener(name: string, func: EventListener, options?: EventListenerOptions): void; getListeners(): Record & { listener: EventListener; })[]>; /** Get an attribute value ( `null` if not set or removed) */ getAttribute(name: string): unknown; /** Update an attribute value */ updateAttribute(name: string, value: unknown): void; /** Set an attribute value */ setAttribute(name: string, value: unknown): void; /** Remove an attribute */ removeAttribute(name: string): void; /** Set a dataset on the element */ setDataset(name: string, value: unknown): void; /** Set a mark on the element */ setMark(name: string, value: unknown): void; /** * Collect the marks on the element * * The marks includes the marks on ancestors (in shadow tree) of the element. * If multiple marks on different elements shares the same name, * the mark value on the child-most element is accepted. */ collectMarks(): { [name: string]: unknown; }; /** * Attach the element into the backend, swapping out a placeholder element in the backend. * * The `element` must not be a child node of another element, * must not be attached before, * and must not have a `ownerShadowRoot` . * The `element` `targetParent` and `targetNode` must be in the same backend context. * The `element` replaces the `targetNode` in the `targetParent` . */ static replaceDocumentElement(element: Element$4, targetParent: GeneralBackendElement, targetNode: GeneralBackendElement): void; /** * Make the element looks like attached. * * If the element will never be attached to backend or it has no backend element at all, * this can be used to trigger `attached` life-time. */ static pretendAttached(element: Element$4): void; /** * Make the element looks like detached. * * This can be used to trigger `detached` life-time without remove the element in the backend. */ static pretendDetached(element: Element$4): void; /** Check the element is attached or not */ static isAttached(element: Element$4): boolean; /** * Set the slot name of the element * * Once this method is called for an `element` , * it will be treated as a slot which can contain child nodes in composed tree. * This method should not be used in components, * otherwise the slot content will always be dangled. */ static setSlotName(element: Element$4, name?: string): void; /** * Get the slot name of the element */ static getSlotName(element: Element$4): string | undefined; /** * Set the virtual node to slot-inherit mode * * In slot-inherit mode of an element, * the child nodes of the element will be treated as siblings and can have different target slot. */ static setInheritSlots(element: Element$4): void; /** Get whether the slot-inherit mode is set or not */ static getInheritSlots(element: Element$4): boolean; /** Get whether the slot-inherit mode is set or not */ isInheritSlots(): boolean; /** * Set the binding slot of specific node * * Necessary if node belongs to a dynamic slot, which cannot be identified by slot name. */ static setSlotElement(node: Node$1, slot: Element$4 | null): void; /** * Get the binding slot of specific node */ static getSlotElement(node: Node$1): Element$4 | null; static _$updateContainingSlot(node: Node$1, containingSlot: Element$4 | null | undefined): void; static _$spliceSlotNodes(slot: Element$4, before: number, deleteCount: number, insertion: Node$1[] | undefined): void; /** Get composed parent (including virtual nodes) */ getComposedParent(): Element$4 | null; /** * Get the composed children * * This method always returns a new array. * It is convenient but less performant. * For better performance, consider using `forEachComposedChild` . */ getComposedChildren(): Node$1[]; /** * Iterate composed child nodes (including virtual nodes) * * if `f` returns `false` then the iteration is interrupted. * Returns `true` if that happens. */ forEachComposedChild(f: (node: Node$1) => boolean | void): boolean; /** * Iterate composed child nodes (including virtual nodes) * * if `f` returns `false` then the iteration is interrupted. * Returns `true` if that happens. */ iterateComposedChild(): Generator; /** * Iterate non-virtual composed child nodes * * if `f` returns `false` then the iteration is interrupted. * Returns `true` if that happens. */ forEachNonVirtualComposedChild(f: (node: Node$1) => boolean | void): boolean; /** Parse a selector string so that it can be used multiple queries */ static parseSelector(str: string): ParsedSelector; /** Select the first descendant which matches the selector */ querySelector(selectorStr: string | ParsedSelector): Element$4 | null; /** Select all descendants which matches the selector */ querySelectorAll(selectorStr: string | ParsedSelector): Element$4[]; /** Test whether the target matches the selector */ static matchSelector(selectorStr: string | ParsedSelector, target: Element$4): boolean; /** Test whether the target in this subtree matches the selector */ matchSelector(selectorStr: string | ParsedSelector, target: Element$4): boolean; /** * Get the bounding client rect * * Return zero values when the backend element is invalid or it does not have layout information. */ getBoundingClientRect(cb: (res: BoundingClientRect) => void): void; /** * Get the bounding client rect * * Return zero values when the backend element is invalid or it does not have layout information. */ getScrollOffset(cb: (res: ScrollOffset) => void): void; /** * Create an intersection observer * * The `relativeElement` is the element to calculate intersection with ( `null` for the viewport). * The `relativeElementMargin` is the margins of the `relativeElement` . * The `thresholds` is a list of intersection ratios to trigger the `listener` . * The listener always triggers once immediately after this call. */ createIntersectionObserver(relativeElement: Element$4 | null, relativeElementMargin: string, thresholds: number[], listener: ((res: IntersectionStatus) => void) | null): Observer | null; /** * Create a resize observer * * It is possible to choose to observe either the content box or the border box. */ createResizeObserver(mode: ResizeObserverMode, listener: ((res: ResizeStatus) => void) | null): Observer | null; /** * Get an interactive context */ getContext(cb: (res: unknown) => void): void; } declare const BM: { DYNAMIC: boolean; SHADOW: boolean; COMPOSED: boolean; DOMLIKE: boolean; }; declare const enum BackendMode { Shadow = 1, Composed = 2, Domlike = 3 } type BoundingClientRect = { left: number; top: number; width: number; height: number; }; type ScrollOffset = { scrollLeft: number; scrollTop: number; scrollWidth: number; scrollHeight: number; }; type CSSProperty = { name: string; value: string; disabled?: boolean; invalid?: boolean; important?: boolean; }; type CSSRule = { sheetIndex: number; ruleIndex: number; inlineText: string; mediaQueries: string[]; selector: string; selectors: { text: string; matches: boolean; }[]; properties: CSSProperty[]; filename?: string; startLine?: number; startColumn?: number; propertyText?: string; weightHighBits?: number; weightLowBits?: number; inactive?: boolean; styleScope?: string | number; }; type GetMatchedRulesResponses = { inline: CSSProperty[]; inlineText?: string; rules: CSSRule[]; }; type GetInheritedRulesResponses = { rules: CSSRule[][]; }; type GetAllComputedStylesResponses = { properties: { name: string; value: string; }[]; }; interface Observer { disconnect(): void; } type IntersectionStatus = { intersectionRatio: number; boundingClientRect: BoundingClientRect; intersectionRect: BoundingClientRect; rootBounds: BoundingClientRect | null; time: number; isIntersecting: boolean; }; declare const enum ResizeObserverMode { ContentBox = 1, BorderBox = 2 } type ResizeStatus = { boundingContentBoxWidth: number; boundingContentBoxHeight: number; boundingBorderBoxWidth: number; boundingBorderBoxHeight: number; }; type MediaQueryStatus = { minWidth?: number; maxWidth?: number; width?: number; minHeight?: number; maxHeight?: number; height?: number; orientation?: string; }; interface GetWrapper { get(): T; } type Element$3 = { getAllComputedStyles(cb: (res: GetAllComputedStylesResponses) => void): void; getPseudoComputedStyles(pseudoType: string, cb: (res: GetAllComputedStylesResponses) => void): void; getBoundingClientRect(cb: (res: BoundingClientRect) => void): void; getBoxModel(cb: (res: { margin: BoundingClientRect; border: BoundingClientRect; padding: BoundingClientRect; content: BoundingClientRect; } | null) => void): void; createIntersectionObserver(relativeElement: E | null, relativeElementMargin: string, thresholds: number[], listener: (res: IntersectionStatus) => void): Observer; createResizeObserver(mode: ResizeObserverMode, listener: (res: ResizeStatus) => void): Observer; getMatchedRules(cb: (res: GetMatchedRulesResponses) => void): void; getPseudoMatchedRules(pseudoType: string, cb: (res: GetMatchedRulesResponses) => void): void; getInheritedRules(cb: (res: GetInheritedRulesResponses) => void): void; getScrollOffset(cb: (res: ScrollOffset) => void): void; setScrollPosition(scrollLeft: number, scrollTop: number, duration: number): void; getContext(cb: (res: unknown) => void): void; getPseudoTypes(cb: (res: string[]) => void): void; triggerNativeEvent(type: string, detail: unknown): void; manipulateNativeNode(action: string, args: unknown, cb: (res: unknown) => void): void; }; type ElementForDomLike = { getBoundingClientRect(): BoundingClientRect; readonly scrollLeft: number; readonly scrollTop: number; readonly scrollWidth: number; readonly scrollHeight: number; }; interface Context$3 { dropBackendAfterRelease?: boolean; createContext(options: unknown, cb: (ContextWrapper: GetWrapper & Ctx>>) => void): void; addPriorEventListener(listener: (target: Element$4, type: string, detail: unknown, options: EventOptions) => EventBubbleStatus | void): void; removePriorEventListener(listener: (target: Element$4, type: string, detail: unknown, options: EventOptions) => EventBubbleStatus | void): void; setFocusedNode(target: Elem): void; getFocusedNode(cb: (node: Node$1 | null) => void): void; onWindowResize(cb: (res: { width: number; height: number; devicePixelRatio: number; }) => void): void; onThemeChange(cb: (res: { theme: string; }) => void): void; elementFromPoint(left: number, top: number, cb: (node: Element$4 | null) => void): void; createMediaQueryObserver(status: MediaQueryStatus, listener: (res: { matches: boolean; }) => void): Observer; addStyleSheetRule(mediaQueryStr: string, selector: string, callback: (ruleIndex: number | null) => void): void; getStyleSheetIndexForNewRules(callback: (sheetIndex: number) => void): void; resetStyleSheetRule(sheetIndex: number, ruleIndex: number, callback: (ruleIndex: number | null) => void): void; modifyStyleSheetRuleSelector(sheetIndex: number, ruleIndex: number, selector: string, callback: (ruleIndex: number | null) => void): void; addStyleSheetProperty(sheetIndex: number, ruleIndex: number, inlineStyle: string, callback: (propertyIndex: number | null) => void): void; replaceStyleSheetAllProperties(sheetIndex: number, ruleIndex: number, inlineStyle: string, callback: (propertyIndex: number | null) => void): void; setStyleSheetPropertyDisabled(sheetIndex: number, ruleIndex: number, propertyIndex: number, disabled: boolean, callback: (propertyIndex: number | null) => void): void; removeStyleSheetProperty(sheetIndex: number, ruleIndex: number, propertyIndex: number, callback: (propertyIndex: number | null) => void): void; replaceStyleSheetProperty(sheetIndex: number, ruleIndex: number, propertyIndex: number, inlineStyle: string, callback: (propertyIndex: number | null) => void): void; performanceTraceStart(): number; performanceTraceEnd(id: number, cb: (stats: { startTimestamp: number; endTimestamp: number; }) => void): void; startOverlayInspect(cb: (event: string, node: Element$4 | null) => void): void; stopOverlayInspect(): void; getActiveElement(cb: (node: Element$4 | null) => void): void; } type UnshiftTarget = Fn extends (...args: infer Args) => infer Ret ? (target: T, ...args: Args) => Ret : never; type UnshiftTargets = { [K in keyof T]: UnshiftTarget; }; type ContextForDomLike = Context$3 & UnshiftTargets, 'getBoundingClientRect' | 'getScrollOffset'>, Elem>; /** * Shadow Mode Backend Protocol * * glass-easel supports custom backends. A backend must provide the interfaces defined here * so that glass-easel can correctly output the required information to the backend. * * ## Backend Protocol Modes * * The backend protocol has two modes: * - **Shadow Mode**: glass-easel works only on the shadow tree; the backend handles * shadow-to-composed tree composition. * - **Composed Mode**: glass-easel works on both the shadow tree and the composed tree. * * Each mode requires a different set of interfaces. Interfaces only needed in one mode * are noted accordingly. * * ## Node Types * * Nodes are divided into the following types: * - Normal node * - Text node (carries text only, no children) * - Fragment node (used to temporarily hold a node tree fragment) * - Component node (Shadow Mode only; has its own shadow tree, can be virtual or non-virtual) * - Component root node (Shadow Mode only; the shadowRoot node of a component) * - Virtual node (Shadow Mode only) * * ## Interface Conventions * * Interfaces marked as `async` use a callback pattern: `async method(...): T` is actually * `method(..., (T) => void)`. * * glass-easel guarantees that a node's ancestor list never contains itself (no cycles). */ /** * A backend-provided object. Each Context instance can display a node tree on the screen. * * In Shadow Mode, `Context` provides the core rendering context for glass-easel. */ interface Context$2 extends Partial> { /** Protocol mode. Always `BackendMode.Shadow` in this protocol. */ mode: BackendMode.Shadow; /** * Destroy this Context instance. * glass-easel does not call this directly; other modules should call it. */ destroy(): void; /** Get the display area width of this Context. */ getWindowWidth(): number; /** Get the display area height of this Context. */ getWindowHeight(): number; /** Get the device pixel ratio of this Context. */ getDevicePixelRatio(): number; /** Get the current theme of this Context, typically `"light"` or `"dark"`. */ getTheme(): string; /** * Register a style sheet. * `path` is the style sheet path, `content` is the corresponding CSS style sheet * in a format the backend can interpret. * If the CSS contains `@import` or similar references, the referenced content * may also be registered via another `registerStyleSheetContent` call, * either before or after this one. */ registerStyleSheetContent(path: string, content: unknown): void; /** * Insert a style sheet item whose content comes from the specified path. * `styleScope` is an optional scope identifier. Returns the new style sheet index. * If styleScope is not a positive integer, it is treated as empty (globally effective). */ appendStyleSheetPath(path: string, styleScope?: number): number; /** Disable an inserted style sheet. */ disableStyleSheet(index: number): void; /** * Wait for the next render to complete (align with the backend vsync). * The backend must ensure the callback is asynchronous. * Setting new properties inside the callback should trigger CSS transitions. */ render(cb: (err: Error | null) => void): void; /** * Get the root node. * In Shadow Mode, the root node must be a component root node. */ getRootNode(): ShadowRootContext; /** Create a fragment node. Used to represent a node array for batch insertion and removal. */ createFragment(): Element$2; /** * Set the global event callback. This callback is the only one. * Shadow Mode only; for Composed Mode see the other `onEvent` signature. * * @param createEvent - Creates an event object from the given type, detail, and options. * @param listener - Called when an event occurs. */ onEvent(createEvent: (type: string, detail: unknown, options: EventOptions) => Event, listener: (event: Event, currentTarget: Element$4, mark: Record | null, target: Element$4, isCapture: boolean) => EventBubbleStatus | void): void; } /** * Element interface for Shadow Mode. * Represents a node in the backend node tree. */ interface Element$2 extends Partial> { /** Internal reference to the glass-easel element. */ __wxElement?: Element$4; /** Release this node. */ release(): void; /** * Notify that node-related information has been created and set an associated value. * Called exactly once on each created node (except text nodes, which are not called). */ associateValue(v: Element$4): void; /** * For a component node, return its ShadowRootContext; otherwise return undefined. * Shadow Mode only. */ getShadowRoot(): ShadowRootContext | undefined; /** * Append a child node. * The inserted child is guaranteed to have no parent. */ appendChild(child: Element$2): void; /** * Remove a child node. The removed child may be reused later. * If `index` is provided, it must equal the child's position in the child list. * If `index` is not a non-negative integer, it is treated as undefined. */ removeChild(child: Element$2, index?: number): void; /** * Insert a child node. Behavior varies by parameters: * - Without `before` and `index`: equivalent to append. * - With `before` or `index`: insert before that position. * - With both `before` and `index`: `index` must equal `before`'s position in the child list. * If `index` is not a non-negative integer, it is treated as undefined. * The inserted child is guaranteed to have no parent. */ insertBefore(child: Element$2, before: Element$2, index?: number): void; /** * Replace a child node. Behavior varies by parameters: * - Without `oldChild` and `index`: equivalent to append. * - With `oldChild` or `index`: replace that child. * - With both `oldChild` and `index`: `index` must equal `oldChild`'s position in the child list. * If `index` is not a non-negative integer, it is treated as undefined. * The inserted child is guaranteed to have no parent. */ replaceChild(child: Element$2, oldChild: Element$2, index?: number): void; /** * Remove `deleteCount` nodes starting from `before`, then insert all nodes from `list` at that position. * `list` must be a fragment node; it should be cleared but may be reused. * All inserted nodes are guaranteed to have no parent. */ spliceBefore(before: Element$2, deleteCount: number, list: Element$2): void; /** * Append all nodes contained in `list`. * `list` must be a fragment node; it should be cleared but may be reused. * All inserted nodes are guaranteed to have no parent. */ spliceAppend(list: Element$2): void; /** Remove `deleteCount` nodes starting from `before`. */ spliceRemove(before: Element$2, deleteCount: number): void; /** Set the node ID. */ setId(id: string): void; /** * Set the target slot name of this node. * Shadow Mode only. */ setSlot(name: string): void; /** * Mark this node as a slot node and set its slot name. * Shadow Mode only. */ setSlotName(slot: string): void; /** * Set the target slot of this node. * `undefined` means the node has no target slot; * `null` means the node's target slot is empty (composedParent is empty). * Shadow Mode only. */ setSlotElement(slot: Element$2 | null): void; /** * Mark this node as slot-inherit. * For slot-inherit nodes, their children are not considered children in the composed tree, * but rather siblings after the node. This allows these children to have different target slots. * A node is only set as slot-inherit during initialization, before it has any children. * Shadow Mode only. */ setInheritSlots(): void; /** * Set the style of this node. * Not called on text nodes. */ setStyle(styleText: string, styleSegmentIndex: number): void; /** * Add a class to this node. * Not called on text nodes. * In Shadow Mode, styleScope is not passed. */ addClass(className: string): void; /** * Remove the specified class (if both name and styleScope match). * Not called on text nodes. * In Shadow Mode, styleScope is not passed. */ removeClass(className: string): void; /** * Update a class alias of this node. * Not called on text nodes. * Shadow Mode only. */ setClassAlias(className: string, targets: string[]): void; /** Set an attribute on this node. `value` can be any type. Not called on text nodes. */ setAttribute(name: string, value: unknown): void; /** Remove an attribute from this node. Not called on text nodes. */ removeAttribute(name: string): void; /** * Set a dataset attribute on this node. `value` can be any type. * Not called on text nodes. * Shadow Mode only. */ setDataset(name: string, value: unknown): void; /** Set the text content. Only called on text nodes. */ setText(content: string): void; /** * Sync data binding settings on this node. * `attributeName` is the field name; `listener` is the data binding update callback. * Only called on normal nodes. */ setModelBindingStat(attributeName: string, listener: ((newValue: unknown) => void) | null): void; /** * Sync event listener settings on this node. * `type` is the event name; `capture` indicates whether this is a capture listener; * `mutLevel` indicates the event response type: * - `MutLevel.None`: normal response. * - `MutLevel.Mut`: mutual-exclusive response; only the first mutual-exclusive listener * is executed in a single event bubble round. * - `MutLevel.Final`: final response; stops event bubbling and prevents default behavior. * Not called on text nodes. */ setListenerStats(type: string, capture: boolean, mutLevel: MutLevel): void; } /** * Represents a shadow tree environment. * Shadow Mode only. */ interface ShadowRootContext extends Element$2 { /** * Create a normal node. * `logicalName` is the node's own defined name. * `stylingName` is the alias set when used. * Shadow Mode only. */ createElement(logicalName: string, stylingName: string): Element$2; /** * Create a text node. * Shadow Mode only. */ createTextNode(content: string): Element$2; /** * Create a component node. * `tagName` is the component name (corresponding to stylingName). * `external` indicates whether this is an external component node * (a pre-built backend node tree joined directly with the rest). * `virtualHost` indicates whether this is a virtual component * (a component whose outermost node is a virtual node). * `styleScope` is the component's scope identifier. * `extraStyleScope` is the component's extra scope identifier. * `externalClasses` is the list of external classes. * Shadow Mode only. */ createComponent(tagName: string, external: boolean, virtualHost: boolean, styleScope: number, extraStyleScope: number | null, externalClasses: string[] | undefined, slotMode: SlotMode | null, writeIdToDOM: boolean): Element$2; /** * Create a virtual node. * Shadow Mode only. */ createVirtualNode(virtualName: string): Element$2; } declare const backend_BM: typeof BM; type backend_BackendMode = BackendMode; declare const backend_BackendMode: typeof BackendMode; type backend_BoundingClientRect = BoundingClientRect; type backend_CSSProperty = CSSProperty; type backend_CSSRule = CSSRule; type backend_GetAllComputedStylesResponses = GetAllComputedStylesResponses; type backend_GetInheritedRulesResponses = GetInheritedRulesResponses; type backend_GetMatchedRulesResponses = GetMatchedRulesResponses; type backend_IntersectionStatus = IntersectionStatus; type backend_MediaQueryStatus = MediaQueryStatus; type backend_Observer = Observer; type backend_ResizeObserverMode = ResizeObserverMode; declare const backend_ResizeObserverMode: typeof ResizeObserverMode; type backend_ResizeStatus = ResizeStatus; type backend_ScrollOffset = ScrollOffset; type backend_ShadowRootContext = ShadowRootContext; declare namespace backend { export { backend_BM as BM, backend_BackendMode as BackendMode, type backend_BoundingClientRect as BoundingClientRect, type backend_CSSProperty as CSSProperty, type backend_CSSRule as CSSRule, type Context$2 as Context, type Element$2 as Element, type backend_GetAllComputedStylesResponses as GetAllComputedStylesResponses, type backend_GetInheritedRulesResponses as GetInheritedRulesResponses, type backend_GetMatchedRulesResponses as GetMatchedRulesResponses, type backend_IntersectionStatus as IntersectionStatus, type backend_MediaQueryStatus as MediaQueryStatus, type backend_Observer as Observer, backend_ResizeObserverMode as ResizeObserverMode, type backend_ResizeStatus as ResizeStatus, type backend_ScrollOffset as ScrollOffset, type backend_ShadowRootContext as ShadowRootContext }; } /** * Composed Mode Backend Protocol * * glass-easel supports custom backends. A backend must provide the interfaces defined here * so that glass-easel can correctly output the required information to the backend. * * In Composed Mode, glass-easel works on both the shadow tree and the composed tree. * This is the preferred protocol as it is relatively simpler to implement. * * ## Node Types * * Nodes are divided into the following types: * - Normal node * - Text node (carries text only, no children) * - Fragment node (used to temporarily hold a node tree fragment) * * ## Interface Conventions * * Interfaces marked as `async` use a callback pattern: `async method(...): T` is actually * `method(..., (T) => void)`. * * glass-easel guarantees that a node's ancestor list never contains itself (no cycles). */ /** * A backend-provided object. Each Context instance can display a node tree on the screen. * * In Composed Mode, `Context` provides the core rendering context for glass-easel. */ interface Context$1 extends Partial> { /** Protocol mode. Always `BackendMode.Composed` in this protocol. */ mode: BackendMode.Composed; /** * Destroy this Context instance. * glass-easel does not call this directly; other modules should call it. */ destroy(): void; /** Get the display area width of this Context. */ getWindowWidth(): number; /** Get the display area height of this Context. */ getWindowHeight(): number; /** Get the device pixel ratio of this Context. */ getDevicePixelRatio(): number; /** Get the current theme of this Context, typically `"light"` or `"dark"`. */ getTheme(): string; /** * Register a style sheet. * `path` is the style sheet path, `content` is the corresponding CSS style sheet * in a format the backend can interpret. * If the CSS contains `@import` or similar references, the referenced content * may also be registered via another `registerStyleSheetContent` call, * either before or after this one. */ registerStyleSheetContent(path: string, content: unknown): void; /** * Insert a style sheet item whose content comes from the specified path. * `styleScope` is an optional scope identifier. Returns the new style sheet index. * If styleScope is not a positive integer, it is treated as empty (globally effective). */ appendStyleSheetPath(path: string, styleScope?: number): number; /** Disable an inserted style sheet. */ disableStyleSheet(index: number): void; /** * Wait for the next render to complete (align with the backend vsync). * The backend must ensure the callback is asynchronous. * Setting new properties inside the callback should trigger CSS transitions. */ render(cb: (err: Error | null) => void): void; /** * Get the root node. * In Composed Mode, the root node must be a normal node. */ getRootNode(): Element$1; /** * Create a normal node. * Composed Mode only. * * @param logicalName - The node's own defined name. * @param stylingName - The alias set when used. */ createElement(logicalName: string, stylingName: string): Element$1; /** * Create a text node. * Composed Mode only. */ createTextNode(content: string): Element$1; /** Create a fragment node. Used to represent a node array for batch insertion and removal. */ createFragment(): Element$1; /** * Set the global event callback. This callback is the only one. * Composed Mode only; for Shadow Mode see the other `onEvent` signature. * * @param listener - Called when an event occurs. */ onEvent(listener: (element: Element$4, type: string, detail: unknown, options: EventOptions, target?: Element$1) => EventBubbleStatus | void): void; } /** * Element interface for Composed Mode. * Represents a node in the backend node tree. */ interface Element$1 extends Partial> { /** Internal reference to the glass-easel element. */ __wxElement?: Element$4; /** Release this node. */ release(): void; /** * Notify that node-related information has been created and set an associated value. * Called exactly once on each created node (except text nodes, which are not called). */ associateValue(v: Element$4): void; /** * Append a child node. * The inserted child is guaranteed to have no parent. */ appendChild(child: Element$1): void; /** * Remove a child node. The removed child may be reused later. * If `index` is provided, it must equal the child's position in the child list. * If `index` is not a non-negative integer, it is treated as undefined. */ removeChild(child: Element$1, index?: number): void; /** * Insert a child node. Behavior varies by parameters: * - Without `before` and `index`: equivalent to append. * - With `before` or `index`: insert before that position. * - With both `before` and `index`: `index` must equal `before`'s position in the child list. * If `index` is not a non-negative integer, it is treated as undefined. * The inserted child is guaranteed to have no parent. */ insertBefore(child: Element$1, before: Element$1, index?: number): void; /** * Replace a child node. Behavior varies by parameters: * - Without `oldChild` and `index`: equivalent to append. * - With `oldChild` or `index`: replace that child. * - With both `oldChild` and `index`: `index` must equal `oldChild`'s position in the child list. * If `index` is not a non-negative integer, it is treated as undefined. * The inserted child is guaranteed to have no parent. */ replaceChild(child: Element$1, oldChild: Element$1, index?: number): void; /** * Remove `deleteCount` nodes starting from `before`, then insert all nodes from `list` at that position. * `list` must be a fragment node; it should be cleared but may be reused. * All inserted nodes are guaranteed to have no parent. */ spliceBefore(before: Element$1, deleteCount: number, list: Element$1): void; /** * Append all nodes contained in `list`. * `list` must be a fragment node; it should be cleared but may be reused. * All inserted nodes are guaranteed to have no parent. */ spliceAppend(list: Element$1): void; /** Remove `deleteCount` nodes starting from `before`. */ spliceRemove(before: Element$1, deleteCount: number): void; /** Set the node ID. */ setId(id: string): void; /** * Set the scope identifiers of this node. Set at most once per node. * If styleScope is not a positive integer, it is treated as empty. * When matching style rules using selectors other than class (e.g. tag name or ID selectors), * the style sheet's scope identifier must be empty or equal to this node's scope identifier. * Composed Mode only. */ setStyleScope(styleScope: number, extraStyleScope?: number, hostStyleScope?: number): void; /** Set the style of this node. Not called on text nodes. */ setStyle(styleText: string): void; /** * Add a class to this node. * If styleScope is not a non-negative integer, it is treated as empty. * When matching style rules using this class, the style sheet's scope identifier * must be empty or equal to this `styleScope`. * Not called on text nodes. */ addClass(elementClass: string, styleScope?: number): void; /** * Remove the specified class (if both name and styleScope match). * If styleScope is not a non-negative integer, it is treated as empty. * Not called on text nodes. */ removeClass(elementClass: string, styleScope?: number): void; /** Set an attribute on this node. `value` can be any type. Not called on text nodes. */ setAttribute(name: string, value: unknown): void; /** Remove an attribute from this node. Not called on text nodes. */ removeAttribute(name: string): void; /** Set the text content. Only called on text nodes. */ setText(content: string): void; /** * Sync data binding settings on this node. * `attributeName` is the field name; `listener` is the data binding update callback. * Only called on normal nodes. */ setModelBindingStat(attributeName: string, listener: ((newValue: unknown) => void) | null): void; /** * Sync event listener settings on this node. * `type` is the event name; `capture` indicates whether this is a capture listener; * `mutLevel` indicates the event response type: * - `MutLevel.None`: normal response. * - `MutLevel.Mut`: mutual-exclusive response; only the first mutual-exclusive listener * is executed in a single event bubble round. * - `MutLevel.Final`: final response; stops event bubbling and prevents default behavior. * Not called on text nodes. */ setListenerStats(type: string, capture: boolean, mutLevel: MutLevel): void; } declare namespace composedBackend { export type { Context$1 as Context, Element$1 as Element }; } /** * DOM-like Mode Backend Protocol * * glass-easel supports custom backends. A backend must provide the interfaces defined here * so that glass-easel can correctly output the required information to the backend. * * The DOM-like Mode protocol is designed for adapting to DOM interfaces. * It should typically only be used when interfacing with the DOM. * * Unlike Shadow Mode and Composed Mode, the DOM-like Mode follows the standard DOM API * conventions. Node operations (appendChild, removeChild, etc.) and properties (tagName, id, * classList, etc.) mirror the DOM Element interface. Some glass-easel-specific operations * are provided as methods on the Context rather than on individual nodes. * * ## Node Types * * Nodes follow DOM conventions: * - Element nodes (with tagName) * - Text nodes * - Document fragment nodes * * ## Interface Conventions * * Interfaces marked as `async` use a callback pattern: `async method(...): T` is actually * `method(..., (T) => void)`. * * glass-easel guarantees that a node's ancestor list never contains itself (no cycles). */ /** * A backend-provided object. Each Context instance can display a node tree on the screen. * * In DOM-like Mode, `Context` provides the core rendering context for glass-easel, * using DOM-compatible interfaces. Some glass-easel-specific operations (such as * setListenerStats, setModelBindingStat) are provided on the Context rather than on nodes. */ interface Context extends Partial> { /** Protocol mode. Always `BackendMode.Domlike` in this protocol. */ mode: BackendMode.Domlike; /** * Destroy this Context instance. * glass-easel does not call this directly; other modules should call it. */ destroy(): void; /** Get the display area width of this Context. */ getWindowWidth(): number; /** Get the display area height of this Context. */ getWindowHeight(): number; /** Get the device pixel ratio of this Context. */ getDevicePixelRatio(): number; /** Get the current theme of this Context, typically `"light"` or `"dark"`. */ getTheme(): string; /** * Register a style sheet. * `path` is the style sheet path, `content` is the corresponding CSS style sheet * in a format the backend can interpret. * If the CSS contains `@import` or similar references, the referenced content * may also be registered via another `registerStyleSheetContent` call, * either before or after this one. */ registerStyleSheetContent(path: string, content: unknown): void; /** * Insert a style sheet item whose content comes from the specified path. * `styleScope` is an optional scope identifier. Returns the new style sheet index. * If styleScope is not a positive integer, it is treated as empty (globally effective). */ appendStyleSheetPath(path: string, styleScope?: number): number; /** Disable an inserted style sheet. */ disableStyleSheet(index: number): void; /** * Wait for the next render to complete (align with the backend vsync). * The backend must ensure the callback is asynchronous. * Setting new properties inside the callback should trigger CSS transitions. */ render(cb: (err: Error | null) => void): void; /** * Get the root node. * In DOM-like Mode, the root node is a normal node. */ getRootNode(): Element; /** The document object providing DOM-compatible node creation methods. */ document: { /** Create a normal element node with the given tag name. */ createElement(tagName: string): Element; /** Create a text node with the given content. */ createTextNode(content: string): Element; /** Create a document fragment node. */ createDocumentFragment(): Element; }; /** * Notify that node-related information has been created and set an associated value. * Called exactly once on each created node (except text nodes, which are not called). * In DOM-like Mode, this is a Context-level method instead of an Element method. */ associateValue(element: Element, value: Element$4): void; /** * Set the global event callback. This callback is the only one. * Composed/DOM-like Mode signature. * * @param listener - Called when an event occurs. */ onEvent(listener: (element: Element$4, type: string, detail: unknown, options: EventOptions, target?: Element) => EventBubbleStatus | void): void; /** * Sync event listener settings on the given element. * In DOM-like Mode, this is a Context-level method instead of an Element method. * * `type` is the event name; `capture` indicates whether this is a capture listener; * `mutLevel` indicates the event response type: * - `MutLevel.None`: normal response. * - `MutLevel.Mut`: mutual-exclusive response; only the first mutual-exclusive listener * is executed in a single event bubble round. * - `MutLevel.Final`: final response; stops event bubbling and prevents default behavior. * Not called on text nodes. */ setListenerStats(element: Element, type: string, capture: boolean, mutLevel: MutLevel): void; /** * Sync data binding settings on the given element. * In DOM-like Mode, this is a Context-level method instead of an Element method. * * `attributeName` is the field name; `listener` is the data binding update callback. * Only called on normal nodes. */ setModelBindingStat(element: Element, attributeName: string, listener: ((newValue: unknown) => void) | null): void; } /** * Element interface for DOM-like Mode. * Follows the standard DOM Element interface conventions. */ interface Element extends Partial { /** Internal storage for model listeners. */ _$wxArgs?: { modelListeners: { [name: string]: ((newValue: unknown) => void) | null; }; }; /** Internal reference to the glass-easel element. */ __wxElement?: Element$4; /** * Append a child node. * The inserted child is guaranteed to have no parent. */ appendChild(child: Element): void; /** * Remove a child node. The removed child may be reused later. * If `index` is provided, it must equal the child's position in the child list. * If `index` is not a non-negative integer, it is treated as undefined. */ removeChild(child: Element, index?: number): void; /** * Insert a child node. Behavior varies by parameters: * - Without `before` and `index`: equivalent to append. * - With `before` or `index`: insert before that position. * - With both `before` and `index`: `index` must equal `before`'s position in the child list. * If `index` is not a non-negative integer, it is treated as undefined. * The inserted child is guaranteed to have no parent. */ insertBefore(child: Element, before?: Element, index?: number): void; /** * Replace a child node. Behavior varies by parameters: * - Without `oldChild` and `index`: equivalent to append. * - With `oldChild` or `index`: replace that child. * - With both `oldChild` and `index`: `index` must equal `oldChild`'s position in the child list. * If `index` is not a non-negative integer, it is treated as undefined. * The inserted child is guaranteed to have no parent. */ replaceChild(child: Element, oldChild?: Element, index?: number): void; /** The tag name of this element. */ tagName: string; /** The ID of this element. */ id: string; /** The class list of this element, providing `add` and `remove` methods. */ classList: { /** Add a class to this element. */ add(elementClass: string): void; /** Remove a class from this element. */ remove(elementClass: string): void; }; /** Set an attribute on this element. `value` can be any type. Not called on text nodes. */ setAttribute(name: string, value: unknown): void; /** Remove an attribute from this element. Not called on text nodes. */ removeAttribute(name: string): void; /** The text content of this node. Only meaningful for text nodes. */ textContent: string; /** The next sibling node, or undefined if none. */ nextSibling: Element | undefined; /** The child nodes of this element. */ childNodes: Element[]; /** The parent node, or null if none. */ parentNode: Element | null; /** Add an event listener (DOM-compatible overload for known HTMLElement event map). */ addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void; /** Add an event listener (generic overload). */ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; } type domlikeBackend_Context = Context; type domlikeBackend_Element = Element; declare namespace domlikeBackend { export type { domlikeBackend_Context as Context, domlikeBackend_Element as Element }; } type GeneralBackendContext = Context$2 | Context$1 | Context; type GeneralBackendElement = Element$2 | Element$1 | Element; declare class CurrentWindowBackendContext implements Context { mode: BackendMode.Domlike; document: { createElement(tagName: string): Element; createTextNode(content: string): Element; createDocumentFragment(): Element; }; destroy(): void; getWindowWidth(): number; getWindowHeight(): number; getDevicePixelRatio(): number; getTheme(): string; registerStyleSheetContent(path: string, content: unknown): void; appendStyleSheetPath(path: string, styleScope?: number): number; disableStyleSheet(index: number): void; render(cb: (err: Error | null) => void): void; getRootNode(): Element; associateValue(element: Element, value: Element$4): void; onEvent(listener: (element: Element$4, type: string, detail: any, options: EventOptions, target: Element) => EventBubbleStatus | void): void; protected _$initEvent(): void; setListenerStats(element: Element, type: string, capture: boolean, mutLevel: MutLevel): void; setModelBindingStat(element: Element, attributeName: string, listener: ((newValue: unknown) => void) | null): void; createIntersectionObserver(targetElement: Element, relativeElement: Element | null, relativeElementMargin: string, thresholds: number[], listener: (res: IntersectionStatus) => void): Observer; createResizeObserver(targetElement: Element, mode: ResizeObserverMode, listener: (res: ResizeStatus) => void): Observer; createMediaQueryObserver(status: MediaQueryStatus, listener: (res: { matches: boolean; }) => void): Observer; getContext(element: Element, cb: (res: unknown) => void): void; setFocusedNode(target: Element): void; getFocusedNode(cb: (node: Node$1 | null) => void): void; onWindowResize(cb: (res: { width: number; height: number; devicePixelRatio: number; }) => void): void; onThemeChange(cb: (res: { theme: string; }) => void): void; elementFromPoint(left: number, top: number, cb: (node: Element$4 | null) => void): void; getAllComputedStyles(target: Element, cb: (computedStyle: { properties: { name: string; value: string; }[]; }) => void): void; getPseudoComputedStyles(target: Element, pseudoType: string, cb: (res: GetAllComputedStylesResponses) => void): void; getBoxModel(target: Element, cb: (res: { margin: BoundingClientRect; border: BoundingClientRect; padding: BoundingClientRect; content: BoundingClientRect; }) => void): void; getPseudoTypes(target: Element, cb: (res: string[]) => void): void; setScrollPosition(target: Element, scrollLeft: number, scrollTop: number, duration: number): void; private queryMatchedRules; getMatchedRules(target: Element, cb: (res: GetMatchedRulesResponses) => void): void; getPseudoMatchedRules(target: Element, pseudoType: string, cb: (res: GetMatchedRulesResponses) => void): void; private iframe; private getIframe; private getDefaultComputedStyles; private getModifiedComputedStyles; getInheritedRules(target: Element, cb: (res: GetInheritedRulesResponses) => void): void; private findStyleRule; replaceStyleSheetAllProperties(sheetIndex: number, ruleIndex: number, inlineStyle: string, cb: (propertyIndex: number | null) => void): void; private _stopOverlayInspectHandler; startOverlayInspect(cb: (event: string, node: Element$4 | null) => void): void; stopOverlayInspect(): void; getActiveElement(cb: (node: Element$4 | null) => void): void; } declare const enum EmptyBackendElementType { Fragment = 0, Element = 1, TextNode = 2, Component = 3, VirtualNode = 4 } /** An empty backend implementation */ declare class EmptyBackendContext implements Context$2 { mode: BackendMode.Shadow; destroy(): void; getWindowWidth(): number; getWindowHeight(): number; getDevicePixelRatio(): number; getTheme(): string; registerStyleSheetContent(_path: string, _content: unknown): void; appendStyleSheetPath(_path: string, _styleScope?: number): number; disableStyleSheet(_index: number): void; render(cb: (err: Error | null) => void): void; getRootNode(): EmptyBackendShadowRootContext; createFragment(): EmptyBackendElement; onEvent(_createEvent: (type: string, detail: unknown, options: EventOptions) => Event, _listener: (event: Event, currentTarget: Element$4, mark: Record | null, target: Element$4, isCapture: boolean) => EventBubbleStatus): void; } /** An element for empty backend implementation */ declare class EmptyBackendElement implements Element$2 { private _$shadowRoot; constructor(type: EmptyBackendElementType); release(): void; associateValue(_v: Element$4): void; getShadowRoot(): EmptyBackendShadowRootContext | undefined; appendChild(_child: EmptyBackendElement): void; removeChild(_child: EmptyBackendElement, _index: number): void; insertBefore(_child: EmptyBackendElement, _before: EmptyBackendElement, _index: number): void; replaceChild(_child: EmptyBackendElement, _oldChild: EmptyBackendElement, _index?: number): void; spliceBefore(_before: EmptyBackendElement, _deleteCount: number, _list: EmptyBackendElement): void; spliceAppend(_list: EmptyBackendElement): void; spliceRemove(_before: EmptyBackendElement, _deleteCount: number): void; setId(_id: string): void; setSlot(_name: string): void; setSlotName(_name: string): void; setSlotElement(_slot: EmptyBackendElement | null): void; setInheritSlots(): void; setStyle(_styleText: string, _styleSegmentIndex: number): void; addClass(_className: string): void; removeClass(_className: string): void; setClassAlias(_className: string, _target: string[]): void; setAttribute(_name: string, _value: unknown): void; removeAttribute(_name: string): void; setDataset(_name: string, _value: unknown): void; setText(_content: string): void; setListenerStats(_type: string, _capture: boolean, _mutLevel: MutLevel): void; setModelBindingStat(_attributeName: string, _listener: ((newValue: unknown) => void) | null): void; } /** A shadow root for empty backend implementation */ declare class EmptyBackendShadowRootContext extends EmptyBackendElement implements ShadowRootContext { constructor(); createElement(_tagName: string, _stylingName: string): EmptyBackendElement; createTextNode(_content: string): EmptyBackendElement; createComponent(_tagName: string, _external: boolean, _virtualHost: boolean, _styleScope: number, _extraStyleScope: number | null, _externalClasses: string[] | undefined, _slotMode: SlotMode | null, _writeIdToDOM: boolean): EmptyBackendElement; createVirtualNode(_virtualName: string): EmptyBackendElement; } /** An empty backend implementation */ declare class EmptyComposedBackendContext implements Context$1 { mode: BackendMode.Composed; private _$styleSheetIdInc; private _$renderCallbacks; private _$rootNode; destroy(): void; getWindowWidth(): number; getWindowHeight(): number; getDevicePixelRatio(): number; getTheme(): string; registerStyleSheetContent(_path: string, _content: unknown): void; appendStyleSheetPath(_path: string, _styleScope?: number): number; disableStyleSheet(_index: number): void; render(cb: (err: Error | null) => void): void; getRootNode(): EmptyComposedBackendElement; createElement(_tagName: string, _stylingName: string): EmptyComposedBackendElement; createTextNode(_tagName: string): EmptyComposedBackendElement; createFragment(): EmptyComposedBackendElement; onEvent(_listener: (element: Element$4, type: string, detail: unknown, options: EventOptions, target: EmptyComposedBackendElement) => EventBubbleStatus): void; createMediaQueryObserver(_status: MediaQueryStatus, _listener: (res: { matches: boolean; }) => void): Observer; } /** An element for empty backend implementation */ declare class EmptyComposedBackendElement implements Element$1 { release(): void; associateValue(_v: unknown): void; appendChild(_child: EmptyComposedBackendElement): void; removeChild(_child: EmptyComposedBackendElement, _index?: number): void; insertBefore(_child: EmptyComposedBackendElement, _before: EmptyComposedBackendElement, _index?: number): void; replaceChild(_child: EmptyComposedBackendElement, _oldChild: EmptyComposedBackendElement, _index?: number): void; spliceBefore(_before: EmptyComposedBackendElement, _deleteCount: number, _list: EmptyComposedBackendElement): void; spliceAppend(_list: EmptyComposedBackendElement): void; spliceRemove(_before: EmptyComposedBackendElement, _deleteCount: number): void; setId(_id: string): void; setStyleScope(_styleScope: number, _extraStyleScope?: number, _hostStyleScope?: number): void; setStyle(_styleText: string): void; addClass(_elementClass: string, _styleScope?: number): void; removeClass(_elementClass: string, _styleScope?: number): void; setAttribute(_name: string, _value: unknown): void; removeAttribute(_name: string): void; setText(_content: string): void; getBoundingClientRect(cb: (res: BoundingClientRect) => void): void; getScrollOffset(cb: (res: ScrollOffset) => void): void; setListenerStats(_type: string, _capture: boolean, _mutLevel: MutLevel): void; setModelBindingStat(_attributeName: string, _listener: ((newValue: unknown) => void) | null): void; createIntersectionObserver(_relativeElement: EmptyComposedBackendElement | null, _relativeElementMargin: string, _thresholds: number[], _listener: (res: IntersectionStatus) => void): Observer; getContext(cb: (res: unknown) => void): void; } declare const simpleDeepCopy: (src: T) => T; declare const deepCopy: (src: T, withRecursion: boolean) => T; declare const enum AutoDestroyState { Disabled = 0, Enabled = 1, Destroyed = 2 } type data_utils_AutoDestroyState = AutoDestroyState; declare const data_utils_AutoDestroyState: typeof AutoDestroyState; declare const data_utils_deepCopy: typeof deepCopy; declare const data_utils_simpleDeepCopy: typeof simpleDeepCopy; declare namespace data_utils { export { data_utils_AutoDestroyState as AutoDestroyState, data_utils_deepCopy as deepCopy, data_utils_simpleDeepCopy as simpleDeepCopy }; } /** The iterator direction and order */ declare const enum ElementIteratorType { /** Iterate all ancestors in shadow tree */ ShadowAncestors = "shadow-ancestors", /** Iterate all ancestors in composed tree */ ComposedAncestors = "composed-ancestors", /** Iterate all descendants in shadow tree, returning parents before their children */ ShadowDescendantsRootFirst = "shadow-descendants-root-first", /** Iterate all descendants in shadow tree, returning parents after their children */ ShadowDescendantsRootLast = "shadow-descendants-root-last", /** Iterate all descendants in composed tree, returning parents before their children */ ComposedDescendantsRootFirst = "composed-descendants-root-first", /** Iterate all descendants in composed tree, returning parents after their children */ ComposedDescendantsRootLast = "composed-descendants-root-last" } /** * An iterator for node tree traversal * * This iterator is convenient but seems a little slower. */ declare class ElementIterator { /** * Create an iterator with type specified * * The `nodeTypeLimit` is used to limit which kind of nodes will be returned. * It limits the returned result by an `instanceof` call. * The default value is `Element` , * which means only elements will be returned (text nodes will not). * Consider specifying `Object` if text nodes need to be returned as well as elements. * Specify `Component` will only return components. */ constructor(node: Node$1, type: ElementIteratorType, nodeTypeLimit?: unknown); /** Same as constructor (for backward compatibility) */ static create(node: Node$1, type: ElementIteratorType, nodeTypeLimit: typeof Component): ElementIterator; static create(node: Node$1, type: ElementIteratorType, nodeTypeLimit: typeof NativeNode): ElementIterator; static create(node: Node$1, type: ElementIteratorType, nodeTypeLimit: typeof ShadowRoot): ElementIterator; static create(node: Node$1, type: ElementIteratorType, nodeTypeLimit: typeof VirtualNode): ElementIterator; static create(node: Node$1, type: ElementIteratorType, nodeTypeLimit?: typeof Element$4): ElementIterator; static create(node: Node$1, type: ElementIteratorType, nodeTypeLimit: typeof TextNode): ElementIterator; static create(node: Node$1, type: ElementIteratorType, nodeTypeLimit: typeof Object): ElementIterator; [Symbol.iterator](): Generator; private _$getIterator; forEach(f: (node: T) => boolean | void): void; } /** * What the observer will listen */ type MutationObserverOptions = { /** * Changes of element parameters * * If set to `true` , the non-data changes will be returned, * including attributes, component properties, external classes, id, class, style, slot, and slot names. * If set to `all` , all changes will be returned. */ properties: boolean | 'all'; /** Child nodes changes */ childList: boolean; /** Text content changes */ characterData: boolean; /** Enable property, childList, and characterData changes in subtree */ subtree: boolean; /** Attached status changes (does not support subtree listening) */ attachStatus: boolean; }; /** * The event for element parameter changes * * This includes most changes to an element except for its children changes. * If the change is a property change for an element or slot value change for a slot node, * the `propertyName` field is provided as the normalized property name; * otherwise the `attributeName` is provided. * For dataset and mark changes, the `data:` and `mark:` are preserved in `attributeName` . * Note that attribute, dataset, mark, and external class events are dispatched whenever they are set (may not changed). */ type MutationObserverAttrEvent = { type: 'properties'; target: Element$4; nameType: 'basic' | 'attribute' | 'component-property' | 'slot-value' | 'dataset' | 'mark' | 'external-class'; propertyName?: string; attributeName?: string; }; /** * The event for the text content changes of a text node */ type MutationObserverTextEvent = { type: 'characterData'; target: TextNode; }; /** * The event for some child nodes added or removed */ type MutationObserverChildEvent = { type: 'childList'; target: Element$4; addedNodes?: Node$1[]; removedNodes?: Node$1[]; }; /** * The event for the element attaches or detaches */ type MutationObserverAttachEvent = { type: 'attachStatus'; target: Element$4; status: 'attached' | 'detached'; }; type MutationObserverEvent = MutationObserverAttrEvent | MutationObserverTextEvent | MutationObserverChildEvent | MutationObserverAttachEvent; type MutationObserverListener = (this: Node$1, ev: T) => void; declare class MutationObserverTarget { attrObservers: FuncArr> | null; allAttrObservers: FuncArr> | null; textObservers: FuncArr> | null; childObservers: FuncArr> | null; attachObservers: FuncArr> | null; constructor(bound: Node$1); attachChild(child: Node$1): void; detachChild(child: Node$1): void; updateSubtreeCount(diff: number): void; hasSubtreeListeners(): boolean; static callAttrObservers(node: Element$4, eventObj: MutationObserverAttrEvent): void; static callTextObservers(textNode: TextNode, eventObj: MutationObserverTextEvent): void; static callChildObservers(node: Element$4, eventObj: MutationObserverChildEvent): void; static callAttachObservers(node: Element$4, eventObj: MutationObserverAttachEvent): void; } /** * An observer that can observe shadow tree changes * * Like DOM MutationObserver, * this observer can observe attributes, text content, and child nodes changes. * It can optionally observe changes in a subtree. * Further more, it can listen attached/detached events on an element. */ declare class MutationObserver { constructor(listener: (ev: MutationObserverEvent) => void); static create(listener: (ev: MutationObserverEvent) => void): MutationObserver; /** Start observation */ observe(targetNode: Node$1, options?: Partial): void; /** End observation */ disconnect(): void; } type mutation_observer_MutationObserver = MutationObserver; declare const mutation_observer_MutationObserver: typeof MutationObserver; type mutation_observer_MutationObserverAttachEvent = MutationObserverAttachEvent; type mutation_observer_MutationObserverAttrEvent = MutationObserverAttrEvent; type mutation_observer_MutationObserverChildEvent = MutationObserverChildEvent; type mutation_observer_MutationObserverEvent = MutationObserverEvent; type mutation_observer_MutationObserverListener = MutationObserverListener; type mutation_observer_MutationObserverOptions = MutationObserverOptions; type mutation_observer_MutationObserverTarget = MutationObserverTarget; declare const mutation_observer_MutationObserverTarget: typeof MutationObserverTarget; type mutation_observer_MutationObserverTextEvent = MutationObserverTextEvent; declare namespace mutation_observer { export { mutation_observer_MutationObserver as MutationObserver, type mutation_observer_MutationObserverAttachEvent as MutationObserverAttachEvent, type mutation_observer_MutationObserverAttrEvent as MutationObserverAttrEvent, type mutation_observer_MutationObserverChildEvent as MutationObserverChildEvent, type mutation_observer_MutationObserverEvent as MutationObserverEvent, type mutation_observer_MutationObserverListener as MutationObserverListener, type mutation_observer_MutationObserverOptions as MutationObserverOptions, mutation_observer_MutationObserverTarget as MutationObserverTarget, type mutation_observer_MutationObserverTextEvent as MutationObserverTextEvent }; } declare const triggerRender: (element: Element$4, callback?: ((err: Error | null) => void) | undefined) => void; type ErrorListener = (error: unknown, method?: string, relatedComponent?: GeneralComponent | string, element?: Node$1) => boolean | void; type WarningListener = (message: string, relatedComponent: GeneralComponent | string, element?: Node$1) => boolean | void; declare function dispatchError(err: unknown, method?: string, relatedComponent?: AnyComponent | string, element?: Node$1): void; declare function triggerWarning(msg: string, relatedComponent?: AnyComponent | string, element?: Node$1): void; declare function addGlobalErrorListener(func: ErrorListener): void; declare function removeGlobalErrorListener(func: ErrorListener): void; declare function addGlobalWarningListener(func: WarningListener): void; declare function removeGlobalWarningListener(func: WarningListener): void; declare const registerBehavior: (def: ComponentParams & ThisType>) => Behavior; declare const registerElement: (def: ComponentParams & ThisType>) => ComponentDefinition; declare function createElement(tagName: string, compDef?: GeneralComponentDefinition): GeneralComponent; declare function createElement(tagName: string, compDef: ComponentDefinition): ComponentInstance; declare const triggerEvent: typeof Event.triggerEvent; declare const triggerExternalEvent: typeof Event.triggerExternalEvent; export { BackendMode, Behavior, BehaviorBuilder, type BoundingClientRect, type BuilderContext, type CSSProperty, type CSSRule, ClassList, Component, ComponentDefinition, type ComponentOptions, ComponentSpace, CurrentWindowBackendContext, type DataChange, DataGroup, type DataObserver, type DataUpdateCallback, type DataValue, DeepCopyKind, type DevTools, Element$4 as Element, ElementIterator, ElementIteratorType, EmptyBackendContext, EmptyComposedBackendContext, type EnvironmentOptions, Event, EventBubbleStatus, type EventListener, type EventListenerOptions, MutLevel as EventMutLevel, type EventOptions, EventPhase, type ExternalShadowRoot, FuncArr, type GeneralBackendContext, type GeneralBackendElement, type GeneralBehavior, type GeneralBehaviorBuilder, type GeneralComponent, type GeneralComponentDefinition, type GeneralDataGroup, type GeneralFuncType, type InspectorDevTools, type MiddlewareHook, type MountPointEnv, MutationObserver, NativeNode, type Node$1 as Node, type NodeCast, type NormalizedComponentOptions, NormalizedPropertyType, MutationObserver as Observer, ParsedSelector, type PerformanceDevTools, type PropertyChange, type RelationFailedListener, type RelationListener, RelationType, type ScrollOffset, ShadowRoot, type ShadowedEvent, SlotMode, type StyleScopeId, StyleScopeManager, StyleSegmentIndex, TextNode, TraitBehavior, VirtualNode, addGlobalErrorListener, addGlobalWarningListener, backend, composedBackend, createElement, data_path as dataPath, data_utils as dataUtils, dispatchError, domlikeBackend, dumpElement, dumpElementToString, dumpSingleElementToString, getDefaultComponentSpace, globalOptions, mutation_observer as mutationObserver, registerBehavior, registerElement, removeGlobalErrorListener, removeGlobalWarningListener, safeCallback, index as template, template_engine as templateEngine, triggerEvent, triggerExternalEvent, triggerRender, triggerWarning, component_params as typeUtils };