ordojs
Version:
A revolutionary web framework with compile-time optimizations and unified client-server development
147 lines • 3.45 kB
TypeScript
/**
* @fileoverview OrdoJS CLI - Hot Module Replacement System
*
* Manages hot updates with WebSocket communication and state preservation.
*/
import { EventEmitter } from 'events';
import { WebSocket } from 'ws';
import type { FileChangeEvent } from './file-watcher.js';
/**
* HMR update types
*/
export declare enum HMRUpdateType {
COMPONENT_UPDATE = "component-update",
STYLE_UPDATE = "style-update",
ASSET_UPDATE = "asset-update",
FULL_RELOAD = "full-reload",
ERROR = "error"
}
/**
* HMR update message
*/
export interface HMRUpdate {
type: HMRUpdateType;
timestamp: number;
file: string;
componentName?: string;
code?: string;
css?: string;
error?: string;
affectedComponents?: string[];
preserveState?: boolean;
}
/**
* Component state snapshot for preservation
*/
export interface ComponentStateSnapshot {
componentId: string;
componentName: string;
state: Record<string, any>;
props: Record<string, any>;
timestamp: number;
}
/**
* HMR client connection
*/
export interface HMRClient {
id: string;
socket: WebSocket;
connectedAt: number;
lastPing: number;
userAgent?: string;
}
/**
* HMR configuration options
*/
export interface HMROptions {
/** Port for WebSocket server */
port: number;
/** Enable state preservation during updates */
preserveState: boolean;
/** Debounce delay for updates in milliseconds */
debounceMs: number;
/** Maximum number of connected clients */
maxClients: number;
/** Enable verbose logging */
verbose: boolean;
}
/**
* OrdoJSHMR class for managing hot module replacement
*/
export declare class OrdoJSHMR extends EventEmitter {
private options;
private wsServer;
private clients;
private compiler;
private updateQueue;
private debounceTimers;
private componentStates;
private isRunning;
/**
* Create a new OrdoJSHMR instance
*/
constructor(options?: Partial<HMROptions>);
/**
* Start the HMR system
*/
start(): Promise<void>;
/**
* Stop the HMR system
*/
stop(): Promise<void>;
/**
* Handle file change events from file watcher
*/
handleFileChange(event: FileChangeEvent): Promise<void>;
/**
* Get the number of connected clients
*/
getClientCount(): number;
/**
* Get HMR statistics
*/
getStats(): {
isRunning: boolean;
clientCount: number;
port: number;
updatesSent: number;
componentsTracked: number;
};
/**
* Process file update and generate HMR patch
*/
private processFileUpdate;
/**
* Generate HMR update patch for a file
*/
private generateUpdatePatch;
/**
* Generate component update patch
*/
private generateComponentUpdate;
/**
* Generate style update patch
*/
private generateStyleUpdate;
/**
* Broadcast update to all connected clients
*/
private broadcastUpdate;
/**
* Set up WebSocket server event handlers
*/
private setupWebSocketHandlers;
/**
* Handle messages from HMR clients
*/
private handleClientMessage;
/**
* Store component state snapshot for preservation
*/
private storeComponentState;
/**
* Generate unique client ID
*/
private generateClientId;
}
//# sourceMappingURL=hmr.d.ts.map