@ordojs/core
Version:
Core compiler and runtime for OrdoJS framework
99 lines • 2.67 kB
TypeScript
/**
* @fileoverview OrdoJS Runtime - Minimal runtime components
*/
import type { ComponentData, HydrationData, Props } from '../types/index.js';
/**
* Component instance for hydrated components
*/
interface ComponentInstance {
id: string;
name: string;
element: Element;
props: Props;
state: Record<string, any>;
eventListeners: Map<string, EventListener>;
update: () => void;
unmount: () => void;
}
/**
* Minimal runtime for hydration and reactivity
*/
export declare class OrdoJSRuntime {
private static instance;
private hydratedComponents;
private componentConstructors;
static getInstance(): OrdoJSRuntime;
/**
* Initialize the runtime
*/
init(): void;
/**
* Register a component constructor for hydration
*/
registerComponent(name: string, constructor: Function): void;
/**
* Auto-hydrate all components found in the DOM
*/
autoHydrate(): void;
/**
* Hydrate a component from hydration data
*/
hydrateFromData(hydrationData: HydrationData): void;
/**
* Hydrate a specific component
*/
hydrateComponent(element: Element, componentName: string, componentId: string, hydrationData?: HydrationData): ComponentInstance | null;
/**
* Extract props from element attributes or hydration data
*/
private extractProps;
/**
* Initialize reactive state from server data
*/
private initializeReactiveState;
/**
* Attach event listeners to hydrated components
*/
private attachEventListeners;
/**
* Set up updates for interpolated content
*/
private setupInterpolationUpdates;
/**
* Get a hydrated component by ID
*/
getComponent(componentId: string): ComponentInstance | undefined;
/**
* Get all hydrated components
*/
getAllComponents(): ComponentInstance[];
/**
* Unmount a component
*/
unmountComponent(componentId: string): void;
/**
* Unmount all components
*/
unmountAll(): void;
}
/**
* Hydrator class for mounting to pre-rendered HTML
*/
export declare class OrdoJSHydrator {
private runtime;
constructor();
/**
* Hydrate a specific component
*/
hydrateComponent(element: Element, componentData: ComponentData): ComponentInstance | null;
/**
* Attach event listeners to hydrated components
*/
attachEventListeners(element: Element, handlers: Record<string, Function>): void;
/**
* Initialize reactive state
*/
initializeReactiveState(component: ComponentInstance): void;
}
export {};
//# sourceMappingURL=index.d.ts.map