@magnusbag/livets-rust-core
Version:
High-performance Rust core for LiveTS framework - real-time server-rendered web applications
38 lines (35 loc) • 1.78 kB
TypeScript
/* tslint:disable */
/* eslint-disable */
/* auto-generated by NAPI-RS */
export type LiveTSEngine = LiveTsEngine
/** The main LiveTS engine that coordinates all core functionality */
export declare class LiveTsEngine {
/** Creates a new LiveTS engine instance */
constructor()
/** Renders a component and returns the diff patches */
renderComponent(componentId: string, oldHtml: string, newHtml: string): string
/** Renders a component and returns compact string patches for ultra-efficient WebSocket transmission */
renderComponentCompact(componentId: string, oldHtml: string, newHtml: string): string
/**
* Renders a component and returns complete ultra-compact WebSocket message
* This eliminates ALL JSON operations in TypeScript layer
*/
renderComponentMessage(componentId: string, oldHtml: string, newHtml: string): string
}
export type LiveTSWebSocketBroker = LiveTsWebSocketBroker
/** Tokio-based WebSocket broker running inside the Rust core */
export declare class LiveTsWebSocketBroker {
constructor()
/** Register a JS callback that receives broker events as JSON strings */
setEventHandler(callback: (...args: any[]) => any): NapiResult
/** Start listening on a TCP port for WebSocket upgrades (ws://host:port/livets-ws) */
listen(host: string, port: number): void
/** Stop the listener and close all connections */
stop(): void
/** Send a JSON-stringified message to a specific connection */
sendToConnection(connectionId: string, message: string): void
/** Register a component to a connection (for targeted broadcasts) */
registerComponent(componentId: string, connectionId: string): void
/** Unregister a component from a connection */
unregisterComponent(componentId: string, connectionId: string): void
}