flexium
Version:
A lightweight, signals-based UI framework with cross-platform renderers
114 lines (107 loc) • 3.78 kB
TypeScript
import { R as Renderer, E as EventHandler, V as VNode } from './renderer-CWYPPHmO.js';
/**
* DOM Renderer implementation
*/
declare class DOMRenderer implements Renderer {
createNode(type: string, props: Record<string, any>): HTMLElement;
updateNode(node: HTMLElement, oldProps: Record<string, any>, newProps: Record<string, any>): void;
appendChild(parent: Node, child: Node): void;
insertBefore(parent: Node, child: Node, beforeChild: Node | null): void;
nextSibling(node: Node): Node | null;
removeChild(parent: Node, child: Node): void;
createTextNode(text: string): Text;
updateTextNode(node: Text, text: string): void;
addEventListener(node: Node, event: string, handler: EventHandler): void;
removeEventListener(node: Node, event: string, _handler: EventHandler): void;
}
/**
* Default DOM renderer instance
*/
declare const domRenderer: DOMRenderer;
/**
* JSX Factory Function (h)
*
* This module provides the JSX factory function for creating virtual nodes.
* It's used by the JSX transpiler to convert JSX syntax into function calls.
*
* Usage in tsconfig.json:
* {
* "compilerOptions": {
* "jsx": "react",
* "jsxFactory": "h",
* "jsxFragmentFactory": "Fragment"
* }
* }
*/
/**
* JSX factory function
* Creates a virtual node from JSX syntax
*
* @param type - Element type (string for built-in, function for components)
* @param props - Element properties
* @param children - Child elements
* @returns Virtual node
*/
declare function h(type: string | Function, props: Record<string, any> | null, ...children: any[]): VNode;
/**
* Fragment component
* Renders children without a wrapper element
*/
declare function Fragment(props: {
children?: any[];
}): VNode;
/**
* Check if a value is a VNode
*/
declare function isVNode(value: any): value is VNode;
/**
* Create a text node
*/
declare function createTextVNode(text: string | number): string;
/**
* DOM Render Function
*
* This module provides the main render function for mounting components to the DOM.
* It includes simple reconciliation logic for mounting and unmounting components.
*
* Note: For reactive rendering with automatic signal tracking, use renderReactive
* or createReactiveRoot from './reactive'.
*/
/**
* Render a component to a DOM container with automatic reactivity
*
* This function uses reactive rendering by default, which means:
* - Signals passed as children automatically update the DOM
* - Signals in props automatically update element properties
* - Component functions automatically re-render when signals change
*
* @param vnode - Virtual node to render
* @param container - DOM element to render into
* @returns The rendered DOM node
*
* @example
* const count = signal(0);
* render(h('div', {}, [count]), document.body);
* // The div will automatically update when count changes
*/
declare function render(vnode: VNode | string | number | null | undefined | Function, container: HTMLElement): Node | null;
/**
* Create a root for rendering with automatic reactivity
*
* This creates a root that supports fine-grained reactive updates.
* Signals are automatically tracked and only the affected DOM nodes are updated.
*
* @param container - DOM element to render into
* @returns Root object with render and unmount methods
*
* @example
* const root = createRoot(document.body);
* const count = signal(0);
* root.render(h('div', {}, [count]));
* // Later: count.value++ will automatically update the DOM
*/
declare function createRoot(container: HTMLElement): {
render(vnode: VNode): void;
unmount(): void;
};
export { DOMRenderer as D, Fragment as F, createRoot as a, createTextVNode as c, domRenderer as d, h, isVNode as i, render as r };