/** * types/core.d.ts * TypeScript type definitions for EUIXEngineCore. */ export interface EUIXPlugin { name: string; install: (engineClass: typeof EUIXEngineCore) => void; } export interface EUIXStateOptions { silent?: boolean; batch?: boolean; sourceEl?: HTMLElement; context?: Record; } export type EUIXMutationOperation = | 'PUSH' | 'APPEND' | 'POP' | 'SHIFT' | 'UNSHIFT' | 'PREPEND' | 'REMOVE' | 'DELETE' | 'SWAP' | 'UPDATE' | 'SET' | 'INSERT' | 'MOVE_UP' | 'MOVE_DOWN' | 'REVERSE' | 'SORT' | 'INCREMENT' | 'DECREMENT' | 'CLEAR' | 'EMPTY' | 'RESET'; export interface EUIXStructuredErrorOptions { message: string; code?: string; status?: number; originatingAction?: string; component?: string; details?: any; } export class EUIXStructuredError extends Error { code: string; status?: number; originatingAction?: string; component?: string; details?: any; timestamp: number; constructor(options: EUIXStructuredErrorOptions | string); static from(err: any, extra?: Partial): EUIXStructuredError; } export class EUIXXMLParseError extends Error { xmlSnippet?: string; constructor(message: string, xmlSnippet?: string); } export class EUIXExpressionParser { static tokenize(expr: string): Array<{ type: string; value: any }>; static parseToJs(tokens: Array<{ type: string; value: any }>): string; static evaluate(exprString: string, context?: Record): any; static interpolate(templateString: string, context?: Record): string; } export interface BindingModifiers { number?: boolean; trim?: boolean; boolean?: boolean; lazy?: boolean; debounce?: number; } export interface ResolvedBinding { type: 'state' | 'context'; path?: string; scope?: string; prop?: string; modifiers: BindingModifiers; } export interface ErrorBoundaryController { id: string; name: string; hasError: boolean; error: any; el: HTMLElement; catchError(error: Error | any): void; retry(): void; reset(): void; } export class EUIXEngineCore = Record> { container: HTMLElement | null; state: TState; refs: Record; xmlDoc: Document | null; onError: ((err: EUIXStructuredError | Error, context?: string) => void) | null; constructor(containerSelector?: string | HTMLElement); static use(plugin: EUIXPlugin): typeof EUIXEngineCore; static mount = Record>( xmlString: string | HTMLElement, containerSelector?: string | HTMLElement ): EUIXEngineCore; static mountElement = Record>( element: HTMLElement, options?: { props?: Record; state?: Record } ): Promise>; static unmountElement(element: HTMLElement): boolean; static scan(root?: Document | HTMLElement): Promise; static getEngine(elementOrSelector: HTMLElement | string): EUIXEngineCore | undefined; static instances: EUIXEngineCore[]; static elements: WeakMap; static registerAction(actionType: string, handler: (actionNode: Element, context: Record) => any): void; mount = TState>( xmlString: string | HTMLElement, containerSelector?: string | HTMLElement ): EUIXEngineCore; setProps(nextProps: Record): this; unmount(): this; destroy(): void; onUnmount(callback: () => void): this; getState(key: K): TState[K]; getState(): TState; getState(key: string): TVal; setState( key: K, value: TState[K] | ((prev: TState[K]) => TState[K]), options?: EUIXStateOptions ): void; setState(partialState: Partial, options?: EUIXStateOptions): void; setState(key: string, value: TVal, options?: EUIXStateOptions): void; mutateState(path: K | string, operation: EUIXMutationOperation, payload?: any): this; toggleState(key: K | string): boolean; batch(fn: () => void): void; batchUpdates(fn: () => void): void; watch(key: K, callback: (newValue: TState[K], oldValue: TState[K]) => void): () => void; watch(key: string, callback: (newValue: any, oldValue: any) => void): () => void; watchState(key: K, callback: (newValue: TState[K], oldValue: TState[K]) => void): () => void; watchState(key: string, callback: (newValue: any, oldValue: any) => void): () => void; onStateChange(callback: (key: string, newValue: any, oldValue: any) => void): () => void; // Error Boundary controls getErrorBoundary(nameOrId: string): ErrorBoundaryController | undefined; resetErrorBoundary(nameOrId: string): boolean; catchErrorBoundary(nameOrId: string, error: Error | any): boolean; findClosestErrorBoundary(element: HTMLElement): ErrorBoundaryController | null; // Binding modifiers and coercion extractBindModifiers(xmlNode: Element | null): { bindAttr: string | null; modifiers: BindingModifiers }; coerceBindingValue( rawValue: any, binding?: ResolvedBinding | { path?: string; modifiers?: BindingModifiers }, xmlNode?: Element | null ): any; registerAction(name: string, handler: (actionNode: Element, context: Record) => any): this; handleAction(actionNode: Element, context?: Record): any; executeAction(actionName: string, args?: Record): Promise; clearApiCache(tagOrUrl?: string): void; flushOfflineQueue(): Promise; getApiStatus(endpointId: string): { loading: boolean; error: string | null; status: number | null; data: any; timestamp: number | null; stale: boolean; isOffline: boolean; }; interpolate(text: string, context?: Record): string; evalCondition(conditionStr: string, context?: Record): boolean; getPerformanceMetrics(): Record; } export default EUIXEngineCore;