UNPKG

@ordojs/core

Version:

Core compiler and runtime for OrdoJS framework

156 lines 3.71 kB
/** * @fileoverview OrdoJS DOM Optimizer - Generates efficient DOM update code */ import { type ComponentAST } from '../types/index.js'; import { type DependencyGraph } from './dependency-analyzer.js'; /** * DOM update operation */ export interface DOMUpdateOperation { id: string; type: DOMUpdateType; selector: string; property: string; expression: string; dependencies: string[]; batchGroup?: string; } /** * Types of DOM update operations */ export declare enum DOMUpdateType { TEXT_CONTENT = "TEXT_CONTENT", ATTRIBUTE = "ATTRIBUTE", PROPERTY = "PROPERTY", CLASS_TOGGLE = "CLASS_TOGGLE", STYLE = "STYLE", VISIBILITY = "VISIBILITY", LIST_UPDATE = "LIST_UPDATE", CONDITIONAL_RENDER = "CONDITIONAL_RENDER" } /** * Batched update group */ export interface UpdateBatch { id: string; operations: DOMUpdateOperation[]; dependencies: string[]; priority: number; } /** * Two-way binding configuration */ export interface TwoWayBinding { elementSelector: string; variableName: string; eventType: string; propertyName: string; transformFunction?: string; } /** * DOM optimizer for efficient DOM manipulation code generation */ export declare class DOMOptimizer { private componentId; private updateOperations; private updateBatches; private twoWayBindings; private elementCounter; /** * Optimize DOM updates for a component */ optimize(ast: ComponentAST, dependencyGraph: DependencyGraph): { updateCode: string; setupCode: string; cleanupCode: string; }; /** * Generate selective DOM updates (only changed elements) */ generateSelectiveUpdates(ast: ComponentAST, dependencyGraph: DependencyGraph, changedVariables: string[]): string; /** * Reset optimizer state */ private reset; /** * Analyze component for DOM update opportunities */ private analyzeComponent; /** * Analyze markup block for DOM updates */ private analyzeMarkupBlock; /** * Analyze HTML element for DOM updates */ private analyzeHTMLElement; /** * Analyze attribute for reactive updates */ private analyzeAttribute; /** * Analyze interpolation for reactive updates */ private analyzeInterpolation; /** * Create two-way binding */ private createTwoWayBinding; /** * Create class update operation */ private createClassUpdate; /** * Create style update operation */ private createStyleUpdate; /** * Create attribute update operation */ private createAttributeUpdate; /** * Analyze two-way bindings */ private analyzeTwoWayBindings; /** * Extract dependencies from expression */ private extractDependencies; /** * Generate expression code */ private generateExpressionCode; /** * Add update operation to the appropriate group */ private addUpdateOperation; /** * Generate batched update operations */ private generateUpdateBatches; /** * Get update priority for operation type */ private getUpdatePriority; /** * Generate optimized update code */ private generateUpdateCode; /** * Generate setup code for two-way bindings */ private generateSetupCode; /** * Generate cleanup code */ private generateCleanupCode; /** * Generate unique element ID */ private generateElementId; /** * Generate unique operation ID */ private generateOperationId; } //# sourceMappingURL=dom-optimizer.d.ts.map