// Copyright 2024 The Lynx Authors. All rights reserved. // Licensed under the Apache License Version 2.0 that can be found in the // LICENSE file in the root directory of this source tree. export interface ElementRef extends Record { } export interface ComponentElementRef extends ElementRef { } export interface PageElementRef extends ComponentElementRef { } export interface ListElementRef extends ElementRef { } export interface ViewElementRef extends ElementRef { } export interface TextElementRef extends ElementRef { } export interface RawTextElementRef extends ElementRef { } export interface ImageElementRef extends ElementRef { } export interface ScrollElementRef extends ElementRef { } export interface WrapperElementRef extends ElementRef { } export interface NoneElementRef extends ElementRef { } export interface IfElementRef extends ElementRef { } export interface ForElementRef extends ElementRef { } export interface BlockElementRef extends ElementRef { } export interface StyleObjectRef extends ElementRef { } export type ElementInfo = Record; export interface PipelineOptions { pipelineID: string needTimestamps: boolean } export interface SelectorParams { onlyCurrentComponent?: boolean; } export interface DynamicComponentResult { code: number; data: { evalResult: ( url: string ) => { name: string; }; }; } export type ComponentAtIndexCallback = ( listRef: ElementRef, listElementId: number, cellIndex: number, opId: number, enableReuseNotification?: boolean, enableBatchRender?: boolean, asyncFlush?: boolean, ) => number | undefined | Promise export type ComponentAtIndexesCallback = ( listRef: ElementRef, listElementId: number, cellIndexes: number[], opIds: number[], enableReuseNotification: boolean, asyncFlush: boolean, ) => void export type EnqueueComponentCallback = ( listRef: ElementRef, listId: number, eleId: number, ) => void /** * Animation operation types for ElementAnimate function */ export enum AnimationOperation { START = 0, // Start a new animation PLAY = 1, // Play/resume a paused animation PAUSE = 2, // Pause an existing animation CANCEL = 3, // Cancel an animation } /** * Animation timing options configuration */ export interface AnimationTimingOptions { name?: string; // Animation name (optional, auto-generated if not provided) duration?: number | string; // Animation duration delay?: number | string; // Animation delay iterationCount?: number | string; // Number of iterations (can be 'infinite') fillMode?: string; // Animation fill mode timingFunction?: string; // Animation timing function direction?: string; // Animation direction } /** * Keyframe definition for animation */ export type Keyframe = Record; export interface GestureConfig { callbacks: { name: string; callback: unknown; }[]; config?: Record; } export enum ElementEventClosureType { NONE = 0, JS = 1, CORE = 2, CLIENT = 3, } export enum ElementEventBindType { NONE = 0, BUBBLE = 1, CAPTURE = 2, CAPTURE_CATCH = 3, BUBBLE_CATCH = 4, GLOBAL_BIND = 5, } export enum ElementEventType { NONE = 0, TOUCH = 1, KEYBOARD = 2, WHEEL = 3, POINTER = 4, UI = 5, MOUSE = 6, MESSAGE = 7, CUSTOM = 8, } export interface ElementEventRef extends Record { } export interface ElementEvent extends Record { ref?: ElementEventRef; } export type ElementEventCallback = (event: ElementEvent) => void; export interface ElementEventListenerOptions { capture?: boolean; once?: boolean; passive?: boolean; signal?: boolean; closure_type?: ElementEventClosureType.NONE | ElementEventClosureType.CORE | ElementEventClosureType.CLIENT; bind_type?: ElementEventBindType; } export interface ElementEventOptions { capture?: boolean; bubbles?: boolean; cancelable?: boolean; composed?: boolean; } export type SerializableValue = any; export type SerializedTemplateInstance = | SerializedCompiledTemplateInstance | SerializedTypedTemplateInstance; export interface SerializedCompiledTemplateInstance { templateKey: string; bundleUrl?: string; attributeSlots?: SerializableValue[] | null; elementSlots?: SerializedTemplateInstance[][] | null; options?: Record | null; uid: number | string; } export interface SerializedTypedTemplateInstance { tag: string; attributes?: Record | null; elementSlots?: SerializedTemplateInstance[][] | null; options?: Record | null; uid: number | string; } declare global { function __CreatePage(componentId: string, cssId: number, info?: ElementInfo): PageElementRef; function __CreateComponent( parentComponentUniId: number, componentId: string, cssId: number, entryName: string, name: string, path: string, config?: Record, info?: ElementInfo, ): ComponentElementRef; function __CreateView(parentComponentUniId: number, info?: ElementInfo): ViewElementRef; function __CreateScrollView(parentComponentUniId: number, info?: ElementInfo): ScrollElementRef; function __CreateText(parentComponentUniId: number, info?: ElementInfo): TextElementRef; function __CreateRawText(text: string, info?: ElementInfo): RawTextElementRef; function __CreateImage(parentComponentUniId: number, info?: ElementInfo): ImageElementRef; function __CreateWrapperElement(parentComponentUniId: number): WrapperElementRef; function __CreateNonElement(parentComponentUniId: number): ElementRef; function __CreateIf(parentComponentUniId: number, info?: ElementInfo): IfElementRef; function __CreateFor(parentComponentUniId: number, info?: ElementInfo): ForElementRef; function __CreateBlock(parentComponentUniId: number, info?: ElementInfo): BlockElementRef; function __CreateList( parentComponentUniId: number, componentAtIndex: ComponentAtIndexCallback, enqueueComponent: EnqueueComponentCallback, info?: ElementInfo, componentAtIndexes?: ComponentAtIndexesCallback, ): ListElementRef; function __UpdateListCallbacks( node: ListElementRef, componentAtIndex: ComponentAtIndexCallback, enqueueComponent: EnqueueComponentCallback, componentAtIndexes: ComponentAtIndexesCallback, ): void; function __CreateElement(tag: string, comParentUniID: number, info?: ElementInfo): ElementRef; function __AppendElement(parent: ElementRef, current: ElementRef): ElementRef; function __RemoveElement(parent: ElementRef, current: ElementRef): ElementRef; function __InsertElementBefore(parent: ElementRef, current: ElementRef, marker?: ElementRef): ElementRef; function __SwapElement(left: ElementRef, right: ElementRef): void; function __ReplaceElement(newElement: ElementRef, oldElement: ElementRef): void; function __ReplaceElements(parent: ElementRef, insertedChildren: ElementRef | ElementRef[] | undefined, removedChildren: ElementRef | ElementRef[] | undefined): void; function __GetParent(current: ElementRef): ElementRef; function __GetChildren(current: ElementRef): ElementRef[]; function __FirstElement(current: ElementRef): ElementRef; function __LastElement(current: ElementRef): ElementRef; function __NextElement(node: ElementRef): ElementRef; function __GetTag(node: ElementRef): string; function __SetAttribute(current: ElementRef, attrName: string, value: any): void; function __AddClass(current: ElementRef, className: string): void; function __SetClasses(current: ElementRef, className: string | undefined): void; function __GetClasses(current: ElementRef): string[]; function __SetStaticStyle(node: ElementRef, key: number, value: unknown): void; function __SetInlineStyles(node: ElementRef, value: unknown): void; function __GetInlineStyle(node: ElementRef, propertyId: number): string; function __GetInlineStyles(node: ElementRef): string; function __SetID(node: ElementRef, id: string | null): void; function __GetID(node: ElementRef): string; function __SetCSSId(node: ElementRef | ElementRef[], cssId: number, entryName?: string): void; function __AddEvent(node: ElementRef, type: string, name: string, func: string | Object | undefined): void; function __SetEvents(node: ElementRef, events: Record[] | undefined): void; function __GetEvent(node: ElementRef, name: string, type: string): Record; function __GetEvents(node: ElementRef): Record>; function __AddEventListener( node: ElementRef, name: string, callback: ElementEventCallback | string, options: ElementEventListenerOptions, ): void; function __RemoveEventListener( node: ElementRef, name: string, callback: ElementEventCallback | string, options: ElementEventListenerOptions, ): void; function __RemoveEventListeners(node: ElementRef): void; function __CreateEvent( type: ElementEventType, name: string, options: ElementEventOptions, detail: Record, ): ElementEventRef; function __DispatchEvent(node: ElementRef, event: ElementEventRef): boolean; function __StopPropagation(event: ElementEventRef): void; function __StopImmediatePropagation(event: ElementEventRef): void; function __AddDataset(node: ElementRef, key: string, value: unknown): void; function __SetDataset(node: ElementRef, value: Record | undefined): void; function __GetDataset(node: ElementRef): Record; function __GetDataByKey(node: ElementRef, key: string): any; function __GetElementUniqueID(node: ElementRef): number; function __ElementIsEqual(left: ElementRef, right: ElementRef): boolean; function __UpdateComponentID(node: ElementRef, id: string): void; function __GetComponentID(node: ElementRef): string; function __UpdateComponentInfo( node: ElementRef, params: { componentID?: string; name?: string; path?: string; entry?: string; cssID?: number; config?: Record; } ): void; function __FlushElementTree( element?: ElementRef, options?: { triggerLayout?: boolean; triggerDataUpdated?: boolean; operationID?: number; nativeUpdateDataOrder?: number; __lynx_timing_flag?: string; elementID?: number; reloadTemplate?: boolean; listID?: number; pipelineOptions?: Record; elementIDs?: number[]; operationIDs?: number[]; asyncFlush?: boolean; onLayoutReady?: () => void; emptyPatch?: boolean; } ): void; function __AsyncResolveElement(element: ElementRef): void; function __AsyncResolveSubtree(node: ElementRef): void function __OnLifecycleEvent(args: any[]): void; function _ReportError( err: Error, info: { errorCode: number; } ): void; function __ElementFromBinary(elementTemplateKey: string, parentComponentUniId: number): ElementRef[]; /** * Create a template instance from the complete initial slot state. * `attributeSlots[i]` maps to `attrSlotIndex = i`. * `elementSlots[i]` maps to `elementSlotIndex = i`. */ function __CreateElementTemplate( templateKey: string, bundleUrl: string | null | undefined, attributeSlots: any[] | null | undefined, elementSlots: ElementRef[][] | null | undefined, uid: number | string, options?: Record | null | undefined, ): ElementRef; /** * Create a typed template instance. `elementSlots[0]` is mounted as the root element's children. */ function __CreateTypedElementTemplate( tag: string, attributes: Record | null | undefined, elementSlots: ElementRef[][] | null | undefined, uid: number | string, options?: Record | null | undefined, ): ElementRef; /** * Update one dynamic attribute slot on an existing compiled template instance. * * For typed template instances, `attrSlotIndex === 0` applies `value` as * the root spread attributes. Passing `null` or `undefined` clears the * previously applied root spread attributes. */ function __SetAttributeOfElementTemplate( templateInstance: ElementRef, attrSlotIndex: number, value: any, ): void; /** * Insert or move a child into one element slot. * If `referenceChild` is omitted or `null`, append to the slot tail. */ function __InsertNodeToElementTemplate( templateInstance: ElementRef, elementSlotIndex: number, child: ElementRef, referenceChild?: ElementRef | null, ): void; /** * Remove a child from one element slot. */ function __RemoveNodeFromElementTemplate( templateInstance: ElementRef, elementSlotIndex: number, child: ElementRef, ): void; /** * Serialize a template instance into a machine-consumable structure used by * hydration and cross-thread transfer. */ function __SerializeElementTemplate( templateInstance: ElementRef, ): SerializedTemplateInstance; function __GetTemplateParts(ele: ElementRef): Record; function __CloneElement(ele: ElementRef, options: Record): ElementRef; function __IsTemplateElement(ele: ElementRef): boolean; function __MarkTemplateElement(ele: ElementRef): void; function __MarkPartElement(ele: ElementRef, key: string): void; function __QuerySelector(root: ElementRef, cssSelector: string, params: SelectorParams): ElementRef; function __QuerySelectorAll(root: ElementRef, cssSelector: string, params: SelectorParams): ElementRef[]; function __AddConfig(ele: ElementRef, key: string, value: any): void; function __SetConfig(ele: ElementRef, config: Record): void; function __GetConfig(ele: ElementRef): Record; function __QueryComponent(source: string, callback?: (evalResult: DynamicComponentResult) => void): { evalResult: unknown }; function __AddInlineStyle(e: ElementRef, key: number | string, value: unknown): void; function __GetAttributeByName(e: ElementRef, name: string): any; function __GetAttributeNames(e: ElementRef): string[]; function __GetAttributes(e: ElementRef): Record; function __GetPageElement(): ElementRef; function __InvokeUIMethod(e: ElementRef, method: string, params: Record, callback: (res: { code: number; data: unknown }) => void): ElementRef[]; function __LoadLepusChunk(name: string, cfg: { chunkType: number }): void; function __CreateGestureDetector( node: ElementRef, gestureID: number, gestureType: number, config: GestureConfig, relationMap: Record ): void; function __SetGestureDetector( node: ElementRef, gestureID: number, gestureType: number, config: GestureConfig, relationMap: Record ): void; function __RemoveGestureDetector(node: ElementRef, gestureID: number): void; function __SetGestureState(node: ElementRef, gestureID: number, state: number): void; function __ConsumeGesture(node: ElementRef, gestureID: number, options: Record): void; function __GeneratePipelineOptions(): Record; function __OnPipelineStart(pipeLineId: string, pipeLineOrigin: string): void; function __BindPipelineIDWithTimingFlag(pipeLineId: string, timingFlag: string): void; function __MarkTiming(pipeLineId: string, timingFlag: string): void; function __AddTimingListener(): void; function __SetLepusInitData(initData: Object): void; function __GetElementByUniqueID(elementId: number): ElementRef | undefined; function __UpdateIfNodeIndex(node: IfElementRef, ifIndex: number): void; function __UpdateForChildCount(node: ForElementRef, childCount: number): void; function __CreateStyleObject(styleObject: Object): StyleObjectRef; function __SetStyleObject(elementRef: ElementRef, styleObjects: Array): void; function __UpdateStyleObject(styleObjectRef: StyleObjectRef, styleObject: Object): void; /** * ElementAnimate function - controls animations on DOM elements * @param element - The DOM element to animate (FiberElement reference) * @param args - Animation configuration array * @returns undefined */ function __ElementAnimate( element: ElementRef, args: [ operation: AnimationOperation, // Animation operation type name: string, // Animation name keyframes: Keyframe[], // Array of keyframes options?: AnimationTimingOptions, // Timing and configuration options ] | [ operation: AnimationOperation.PAUSE | AnimationOperation.PLAY | AnimationOperation.CANCEL, name: string, // Animation name to pause/play ], ): void; function __CreateFrame(comParentUniID: number, options?: Record): ElementRef; }