UNPKG

@magnusbag/livets-core

Version:

TypeScript API layer for LiveTS framework

72 lines 1.82 kB
/** * Type definitions for the LiveTS framework */ import type { Hono } from 'hono'; export interface LiveViewState { [key: string]: any; } export interface EventPayload { [key: string]: any; } export interface ComponentProps { [key: string]: any; } export type ComponentId = string; export type ConnectionId = string; export type EventName = string; export interface ClientEvent { eventType: string; eventName: string; componentId: string; payload: EventPayload; target?: EventTarget; } export interface EventTarget { tagName: string; attributes: Record<string, string>; value?: string; } export interface LiveViewOptions { id?: string; props?: ComponentProps; } export interface ServerOptions { port?: number; host?: string; app: Hono; } export interface RenderOptions { layout?: string; title?: string; meta?: Record<string, string>; scripts?: string[]; styles?: string[]; } export interface ComponentRouteConfig<T = any> { ComponentClass: new (props?: ComponentProps) => T; renderOptions?: RenderOptions; } export interface PubSubMessage { channel: string; data: any; timestamp: number; } export interface DomPatch { type: 'ReplaceText' | 'UpdateText' | 'SetAttribute' | 'RemoveAttribute' | 'ReplaceInnerHtml' | 'ReplaceElement'; selector: string; content?: string; text?: string; attr?: string; value?: string; html?: string; element?: string; } export type EventHandler = (event: string, payload: EventPayload) => void | Promise<void>; export type PubSubHandler = (data: any) => void | Promise<void>; export interface LiveViewMetadata { componentId: string; connectionId?: string; mounted: boolean; subscriptions: Set<string>; } //# sourceMappingURL=types.d.ts.map