import { type TemplateData, ChildOpCode, PropOpCode, StateOpCode } from "./template.js"; export declare const EMPTY_ARRAY: any[]; declare global { interface Element { moveBefore(node: T, child: Node | null): void; } } /** * Render Context. */ export interface RenderContext { /** Parent DOM Element */ p: Element; /** Next DOM Node. */ n: Node | null; /** Template state index. */ si: number; /** DOM Side Effects */ e: Array<() => void>; } /** * Global Render Context. */ export declare const RENDER_CONTEXT: RenderContext; /** * Flags. */ export declare const enum Flags { Template = 1, Component = 2, List = 4, Array = 8, Text = 16, Root = 32, Context = 64, TypeMask = 127, Dirty = 128, DirtySubtree = 256, ForceUpdate = 512, DisplaceNode = 1024 } /** * Stateful Node. */ export type SAny = null | SRoot | SText | STemplate | SList | SComponent | SContext; /** * Stateful Node. */ export type SNode = SNode1 | SNode2; /** * Stateful Node with 1 state slot. * * @typeparam S1 State slot #1. */ export interface SNode1 { /** Stateless Node. */ v: V; /** See {@link Flags} for details. */ f: Flags; /** Children Stateful Nodes. */ c: SNode | (SNode | null)[] | null; /** Parent Stateful Node. */ p: SNode | null; /** State slot #1. */ s1: S1; } /** * Stateful Node with 2 state slots. * * @typeparam S1 State slot #1. * @typeparam S2 State slot #2. */ export interface SNode2 extends SNode1 { /** State slot #2. */ s2: S2; } /** Stateful Root Node. */ export type SRoot = SNode1; /** Stateful Root Node. */ export type Root = SRoot; /** Stateful Text Node. */ export type SText = SNode1; /** Stateful Template Node. */ export type STemplate = SNode1; /** Stateful List Node. */ export type SList = SNode1; /** Stateful Component Node. */ export type SComponent

= SNode2, /** Unmount hooks. */ null | (() => void) | (() => void)[]>; /** Stateful Component Node. */ export type Component

= SComponent

; export type ComponentRenderFn

= (props: P) => VAny; export type SContext = SNode1; /** * Creates a Stateful Node instance. * * @param v VNode. * @returns {@link SNode} instance. */ export declare const createSNode: (f: Flags, v: V, c: SNode | Array | null, p: SNode | null, s1: S) => SNode1; /** * Stateless Tree Node. */ export type VAny = null | undefined | false | string | number | VRoot | VTemplate | VComponent | VContext | VList | VAny[]; /** * Stateless Node Descriptor. */ export interface VDescriptor { /** See {@link Flags} for details. */ readonly f: Flags; /** First property. */ readonly p1: P1; /** Second property. */ readonly p2: P2; } /** Root Invalidate Hook. */ export type OnRootInvalidated = (root: SRoot, state: S) => void; /** Root Descriptor. */ export type RootDescriptor = VDescriptor, null>; /** Template Descriptor */ export type TemplateDescriptor = VDescriptor Element>; /** Component Descriptor */ export type ComponentDescriptor

= VDescriptor, undefined | ((prev: P, next: P) => boolean)>; export type ComponentFactoryFn

= (component: Component) => (props: P) => VAny; /** Context Descriptor */ export type ContextDescriptor = VDescriptor; /** List Descriptor */ export type ListDescriptor = VDescriptor; /** * Stateless Node. * * @typeparam D Descriptor. * @typeparam P Property. */ export interface VNode = VDescriptor, P = any> { /** Descriptor. */ readonly d: D; /** Property. */ readonly p: P; } /** Stateless Root Node. */ export type VRoot = VNode; /** Stateless Template Node. */ export type VTemplate

= VNode; /** Stateless Component Node. */ export type VComponent

= VNode; /** Stateless Context Node. */ export type VContext = VNode>; /** Stateless List Node. */ export type VList = VNode>; /** * Stateless Root Node Props. * * Contains a DOM position where root children should mounted. */ export interface RootProps { /** Parent Element */ p: Element; /** Next Node */ n: Node | null; } /** * Stateless Context Node Props. */ export interface ContextProps { /** Context Value. */ v: T; /** Stateless Child Node. */ c: VAny; } /** * Stateless List Node Props. * * Contains unique keys for stateless nodes and stateless nodes. */ export interface ListProps { /** Unique Keys. */ k: K[]; /** Stateless Nodes. */ v: VAny[]; } /** * Element Directive. */ export type ElementDirective = (element: E) => void; export declare const _flushDOMEffects: () => void; /** * Creates a HTML Template cloning factory. * * @__NO_SIDE_EFFECTS__ */ export declare const _hN: (t: string | Node) => () => Element; /** * Creates a HTML Element factory. * * @__NO_SIDE_EFFECTS__ */ export declare const _hE: (t: string) => () => Element; /** * Creates a SVG Template cloning factory. */ export declare const _sN: (t: string | Node) => () => Element; /** * Creates a SVG Element factory. * * @__NO_SIDE_EFFECTS__ */ export declare const _sE: (t: string) => () => Element; /** * Creates a template descriptor with globally shared data. * * @__NO_SIDE_EFFECTS__ */ export declare const _T: (p2: () => Element, f: number, p: PropOpCode[], c: ChildOpCode[], s: StateOpCode[], d?: string[]) => TemplateDescriptor; /** * @__NO_SIDE_EFFECTS__ */ export declare const _t: (d: TemplateDescriptor, p: any[]) => VTemplate; export type ComponentFactory = { (factory: (c: Component) => () => VAny, areEqual?: (a?: any, b?: any) => boolean): () => VComponent;

(factory: (c: Component

) => (props: P) => VAny, areEqual?: (prev: P, next: P) => boolean): (props: P) => VComponent

; }; /** * Creates a factory that produces component nodes. * * @typeparam P Property type. * @param factory Function that produces stateful render functions. * @param areEqyal Function that checks `props` for equality. * @returns Factory that produces component nodes. * @__NO_SIDE_EFFECTS__ */ export declare const component: ComponentFactory; /** * Gets current component props. * * @typeparam P Property type. * @param component Component node. * @returns Current component props. */ export declare const getProps:

(component: Component

) => P; /** * Adds an unmount hook. * * @example * * const Example = component((c) => { * useUnmount(c, () => { console.log("unmounted"); }); * * return () => null; * }); * * @param component Component instance. * @param hook Unmount hook. */ export declare const useUnmount: (component: Component, hook: () => void) => void; export type Effect = { (component: Component, effect: () => (() => void) | void, areEqual?: (prev?: any, next?: any) => boolean): () => void;

(component: Component, effect: (props: P) => (() => void) | void, areEqual?: (prev: P, next: P) => boolean): (props: P) => void; }; /** * Creates a side effect hook. * * @example * * const Example = component((c) => { * const [count, setCount] = useState(c, 0); * const timer = useEffect(c, ({ interval }) => { * const tid = setInterval(() => { setCount(count() + 1); }, interval); * return () => { clearInterval(tid); }; * }, shallowEq); * * return (interval) => ( * timer({ interval }), * * html`${count()}` * ); * }); * * @typeparam T Hook props type. * @param component Component instance. * @param hook Side effect function. * @param areEqual Function that checks if input value hasn't changed. * @returns Side effect hook. */ export declare const useEffect: Effect; export declare const createEffectHandler: (scheduleFlushTask: () => Array<() => void>) =>

(component: Component, hook: (props?: P) => (() => void) | void, areEqual?: (prev: P, next: P) => boolean) => (props?: P) => void; export declare const useAnimationFrameEffect:

(component: Component, hook: (props?: P) => (() => void) | void, areEqual?: (prev: P, next: P) => boolean) => (props?: P) => void; export declare const useIdleEffect:

(component: Component, hook: (props?: P) => (() => void) | void, areEqual?: (prev: P, next: P) => boolean) => (props?: P) => void; /** * Invalidates a component. * * @param c Component instance. */ export declare const invalidate: (c: Component) => void; /** * VDescriptor for List nodes. */ export declare const LIST_DESCRIPTOR: ListDescriptor; /** * Creates a dynamic list. * * @typeparam E Entry type. * @typeparam K Key type. * @param entries Entries. * @param getKey Get key from entry function. * @param render Render entry function. * @returns Dynamic list. * @__NO_SIDE_EFFECTS__ */ export declare const List: (entries: E[], getKey: (entry: E, index: number) => K, render: (entry: E, index: number) => VAny) => VList; /** * Performs dirty checking in a root subtree. * * When `forceUpdate` option is enabled, all components in a root subtree will * be updated. * * @param root Root Node. * @param forceUpdate Force update components. */ export declare const dirtyCheck: (root: Root, forceUpdate?: boolean) => void; /** * Unmounts a root subtree. * * When `detach` option is enabled, root DOM nodes will be detached from the * DOM. * * @param root Root Node. * @param detach Detach root DOM nodes from the DOM. */ export declare const unmount: (root: Root, detach: boolean) => void; export type RootFactory = { (onInvalidate: (root: Root) => void): (parentElement: Element, nextNode?: Node | null) => Root; (onInvalidate: (root: Root, state: S) => void): (parentElement: Element, nextNode: Node | null, state: S) => Root; }; /** * Defines a root node with a custom invalidation hook. * * @param onInvalidate Invalidated Hook. * @returns Root Node factory. * @__NO_SIDE_EFFECTS__ */ export declare const defineRoot: RootFactory; /** * Creates a root node that uses microtask queue for scheduling updates. * * @param parentElement Parent DOM Element. * @param nextNode Next DOM Node. * @returns Root Node. */ export declare const createRoot: (parentElement: Element, nextNode?: Node | null) => Root; /** * Updates a root subtree. * * When `forceUpdate` option is enabled, all components in a root subtree will * be updated. * * @param root Root Node. * @param v Stateless View Node. * @param forceUpdate Force update components. */ export declare const update: (root: Root, v: VAny, forceUpdate?: boolean) => void; /** * Context. * * @returns Context getter and context provider. * @__NO_SIDE_EFFECTS__ */ export declare const context: () => [get: (component: Component) => T | undefined, provider: (value: T, child: VAny) => VContext]; //# sourceMappingURL=core.d.ts.map