UNPKG

resig.js

Version:

Universal reactive signal library with complete platform features: signals, animations, CRDTs, scheduling, DOM integration. Works identically across React, SolidJS, Svelte, Vue, and Qwik.

38 lines (37 loc) 1.92 kB
/** * Block System - Operadic composition for UI components * Following category-theoretic operads for structured composition */ import { Signal } from '../core/signal'; export interface Block { readonly id: string; readonly arity: number; readonly render: (parent: HTMLElement) => HTMLElement; readonly plug: (children: Block[]) => Block; readonly destroy: () => void; } export interface BlockMetadata { readonly type: string; readonly props: Record<string, any>; readonly children: Block[]; } export type BlockFactory<T = any> = (props: T) => Block; export declare const registerBlock: <T = any>(type: string, factory: BlockFactory<T>) => void; export declare const createBlock: <T = any>(type: string, props: T) => Block; export declare const block: (type: string, arity: number, renderFn: (parent: HTMLElement, props: any, children: Block[]) => HTMLElement, props?: any) => Block; export interface ReactiveBlock extends Block { readonly signal: Signal<any>; readonly update: (newProps: any) => void; } export declare const reactiveBlock: <T = any>(type: string, arity: number, renderFn: (parent: HTMLElement, props: T, children: Block[], signal: Signal<T> & { _set: (value: T) => void; }) => HTMLElement, initialProps: T) => ReactiveBlock; export declare const textBlock: (text: string) => Block; export declare const headingBlock: (level: 1 | 2 | 3 | 4 | 5 | 6, text: string) => Block; export declare const paragraphBlock: (text: string) => Block; export declare const containerBlock: (className?: string) => Block; export declare const listBlock: (ordered?: boolean) => Block; export declare const editableTextBlock: (initialText: string) => ReactiveBlock; export declare const compose: (...blocks: Block[]) => Block; export declare const sequence: (blocks: Block[]) => Block; export declare const walkBlocks: (block: Block, visitor: (block: Block) => void) => void;