// Generated by dts-bundle-generator v9.5.1 export type Vode = FullVode | JustTagVode | NoPropsVode; export type FullVode = [ tag: Tag, props: Props, ...children: ChildVode[] ]; export type NoPropsVode = [ tag: Tag, ...children: ChildVode[] ] | (TextVode[]); export type JustTagVode = [ tag: Tag ]; export type ChildVode = Vode | TextVode | NoVode | Component; export type TextVode = string & {}; export type NoVode = undefined | null | number | boolean | bigint | void; export type AttachedVode = Vode & { node: ChildNode; } | Text & { node?: never; }; export type Tag = keyof (HTMLElementTagNameMap & SVGElementTagNameMap & MathMLElementTagNameMap) | (string & {}); export type Component = (s: S) => ChildVode; export type Patch = IgnoredPatch | RenderPatch | Promise> | Effect; export type IgnoredPatch = undefined | null | number | boolean | bigint | string | symbol | void; export type RenderPatch = {} | DeepPartial; export type AnimatedPatch = Array>; export type DeepPartial = { [P in keyof S]?: S[P] extends Array ? Array> : DeepPartial; }; export type Effect = (() => Patch) | EventFunction | Generator> | AsyncGenerator>; export type EventFunction = (state: S, evt: Event) => Patch; export interface Props extends Partial & { [K in keyof EventsMap]: EventFunction | Patch; }> { [_: string]: unknown; xmlns?: string | null; class?: ClassProp; style?: StyleProp; /** called after the element was attached */ onMount?: MountFunction; /** called before the element is detached */ onUnmount?: MountFunction; /** used instead of original vode when an error occurs during rendering */ catch?: ((s: S, error: any) => ChildVode) | ChildVode; } export type MountFunction = ((s: S, node: HTMLElement) => Patch) | ((s: S, node: SVGSVGElement) => Patch) | ((s: S, node: MathMLElement) => Patch); export type ClassProp = "" | false | null | undefined | string | string[] | Record; export type StyleProp = (Record & { [K in keyof CSSStyleDeclaration]?: CSSStyleDeclaration[K] | null; }) | string | "" | null | undefined; export type EventsMapBase = { [K in keyof HTMLElementEventMap as `on${K}`]: HTMLElementEventMap[K]; } & { [K in keyof WindowEventMap as `on${K}`]: WindowEventMap[K]; } & { [K in keyof SVGElementEventMap as `on${K}`]: SVGElementEventMap[K]; }; export interface EventsMap extends EventsMapBase { } export type PropertyValue = string | boolean | null | undefined | void | StyleProp | ClassProp | Patch; export type Dispatch = (action: Patch) => void; export interface Patchable { patch: Dispatch; } export type PatchableState = S & Patchable; export declare const globals: { currentViewTransition: ViewTransition | null | undefined; requestAnimationFrame: (cb: () => void) => void; startViewTransition: ((callbackOptions?: ViewTransitionUpdateCallback | StartViewTransitionOptions) => ViewTransition) | null; }; export interface ContainerNode extends HTMLElement { /** the `_vode` property is added to the container in `app()`. * it contains all necessary stuff for the vode app to function. * remove the container node to clear vodes resources */ _vode: { state: PatchableState; vode: AttachedVode; renderSync: () => void; renderAsync: () => Promise; syncRenderer: (cb: () => void) => void; asyncRenderer: ((cb: () => void) => ViewTransition) | null | undefined; qSync: {} | undefined | null; qAsync: {} | undefined | null; isRendering: boolean; isAnimating: boolean; /** stats about the overall patches & last render time */ stats: { patchCount: number; liveEffectCount: number; syncRenderPatchCount: number; asyncRenderPatchCount: number; syncRenderCount: number; asyncRenderCount: number; lastSyncRenderTime: number; lastAsyncRenderTime: number; }; }; } /** type-safe way to create a vode. useful for type inference and autocompletion. * * - just a tag: `vode("div")` => `["div"]` --*rendered*-> `
` * - tag and props: `vode("div", { class: "foo" })` => `["div", { class: "foo" }]` --*rendered*-> `
` * - tag, props and children: `vode("div", { class: "foo" }, ["span", "bar"])` => `["div", { class: "foo" }, ["span", "bar"]]` --*rendered*-> `
bar
` * - identity: `vode(["div", ["span", "bar"]])` => `["div", ["span", "bar"]]` --*rendered*-> `
bar
` */ export declare function vode(tag: Tag | Vode, props?: Props | ChildVode, ...children: ChildVode[]): Vode; /** create a vode app inside a container element * @param container will use this container as root and places the result of the dom function and further renderings in it * @param state the state object that is used as singleton state bound to the vode app and is updated with `patch()` * @param dom function is alled every render and returnes the vode-dom that is updated incrementally to the DOM based on the state. * @param initialPatches variadic list of patches that are applied after the first render * @returns a patch function that can be used to update the state */ export declare function app(container: Element, state: Omit, dom: (s: S) => Vode, ...initialPatches: Patch[]): Dispatch; /** unregister vode app from container and free resources * of all vodes inside the container. * removes all event listeners registered by vode * removes patch function from state object * leaves the DOM as is */ export declare function defuse(container: ContainerNode): void; /** return vode representation of given DOM node */ export declare function hydrate(element: Element | Text, prepareForRender?: boolean): Vode | string | AttachedVode | undefined; /** memoizes the resulting component or props by comparing element by element (===) with the * `compare` of the previous render. otherwise skips the render step (not calling `componentOrProps`)*/ export declare function memo(compare: any[], componentOrProps: Component | ((s: S) => Props)): typeof componentOrProps extends ((s: S) => Props) ? ((s: S) => Props) : Component; /** * create a patchable state object for a vode-app. * calls to `patch()` prior to `app()` initialization will queue the patches and apply them before the initial patches. * calls to `patch()` after `app()` initialization will apply the patch immediately and trigger a render as usual. */ export declare function createState(state: S): PatchableState; /** type safe way to create a patch. useful for type inference and autocompletion. */ export declare function createPatch(p: DeepPartial | Effect | IgnoredPatch): typeof p; /** html tag of the vode or `#text` if it is a text node */ export declare function tag(v: Vode | TextVode | NoVode | AttachedVode): Tag | "#text" | undefined; /** get properties object of a vode, if there is any */ export declare function props(vode: ChildVode | AttachedVode): Props | undefined; /** get a slice of all children of a vode, if there are any */ export declare function children(vode: ChildVode | AttachedVode): ChildVode[] | null; export declare function childCount(vode: Vode): number; export declare function child(vode: Vode, index: number): ChildVode | undefined; /** index in vode at which child-vodes start */ export declare function childrenStart(vode: ChildVode | AttachedVode): 1 | 2 | -1; export declare const A: Tag; export declare const ABBR: Tag; export declare const ADDRESS: Tag; export declare const AREA: Tag; export declare const ARTICLE: Tag; export declare const ASIDE: Tag; export declare const AUDIO: Tag; export declare const B: Tag; export declare const BASE: Tag; export declare const BDI: Tag; export declare const BDO: Tag; export declare const BLOCKQUOTE: Tag; export declare const BODY: Tag; export declare const BR: Tag; export declare const BUTTON: Tag; export declare const CANVAS: Tag; export declare const CAPTION: Tag; export declare const CITE: Tag; export declare const CODE: Tag; export declare const COL: Tag; export declare const COLGROUP: Tag; export declare const DATA: Tag; export declare const DATALIST: Tag; export declare const DD: Tag; export declare const DEL: Tag; export declare const DETAILS: Tag; export declare const DFN: Tag; export declare const DIALOG: Tag; export declare const DIV: Tag; export declare const DL: Tag; export declare const DT: Tag; export declare const EM: Tag; export declare const EMBED: Tag; export declare const FIELDSET: Tag; export declare const FIGCAPTION: Tag; export declare const FIGURE: Tag; export declare const FOOTER: Tag; export declare const FORM: Tag; export declare const H1: Tag; export declare const H2: Tag; export declare const H3: Tag; export declare const H4: Tag; export declare const H5: Tag; export declare const H6: Tag; export declare const HEAD: Tag; export declare const HEADER: Tag; export declare const HGROUP: Tag; export declare const HR: Tag; export declare const HTML: Tag; export declare const I: Tag; export declare const IFRAME: Tag; export declare const IMG: Tag; export declare const INPUT: Tag; export declare const INS: Tag; export declare const KBD: Tag; export declare const LABEL: Tag; export declare const LEGEND: Tag; export declare const LI: Tag; export declare const LINK: Tag; export declare const MAIN: Tag; export declare const MAP: Tag; export declare const MARK: Tag; export declare const MENU: Tag; export declare const META: Tag; export declare const METER: Tag; export declare const NAV: Tag; export declare const NOSCRIPT: Tag; export declare const OBJECT: Tag; export declare const OL: Tag; export declare const OPTGROUP: Tag; export declare const OPTION: Tag; export declare const OUTPUT: Tag; export declare const P: Tag; export declare const PICTURE: Tag; export declare const PRE: Tag; export declare const PROGRESS: Tag; export declare const Q: Tag; export declare const RP: Tag; export declare const RT: Tag; export declare const RUBY: Tag; export declare const S: Tag; export declare const SAMP: Tag; export declare const SCRIPT: Tag; export declare const SEARCH: Tag; export declare const SECTION: Tag; export declare const SELECT: Tag; export declare const SLOT: Tag; export declare const SMALL: Tag; export declare const SOURCE: Tag; export declare const SPAN: Tag; export declare const STRONG: Tag; export declare const STYLE: Tag; export declare const SUB: Tag; export declare const SUMMARY: Tag; export declare const SUP: Tag; export declare const TABLE: Tag; export declare const TBODY: Tag; export declare const TD: Tag; export declare const TEMPLATE: Tag; export declare const TEXTAREA: Tag; export declare const TFOOT: Tag; export declare const TH: Tag; export declare const THEAD: Tag; export declare const TIME: Tag; export declare const TITLE: Tag; export declare const TR: Tag; export declare const TRACK: Tag; export declare const U: Tag; export declare const UL: Tag; export declare const VAR: Tag; export declare const VIDEO: Tag; export declare const WBR: Tag; export declare const ANIMATE: Tag; export declare const ANIMATEMOTION: Tag; export declare const ANIMATETRANSFORM: Tag; export declare const CIRCLE: Tag; export declare const CLIPPATH: Tag; export declare const DEFS: Tag; export declare const DESC: Tag; export declare const ELLIPSE: Tag; export declare const FEBLEND: Tag; export declare const FECOLORMATRIX: Tag; export declare const FECOMPONENTTRANSFER: Tag; export declare const FECOMPOSITE: Tag; export declare const FECONVOLVEMATRIX: Tag; export declare const FEDIFFUSELIGHTING: Tag; export declare const FEDISPLACEMENTMAP: Tag; export declare const FEDISTANTLIGHT: Tag; export declare const FEDROPSHADOW: Tag; export declare const FEFLOOD: Tag; export declare const FEFUNCA: Tag; export declare const FEFUNCB: Tag; export declare const FEFUNCG: Tag; export declare const FEFUNCR: Tag; export declare const FEGAUSSIANBLUR: Tag; export declare const FEIMAGE: Tag; export declare const FEMERGE: Tag; export declare const FEMERGENODE: Tag; export declare const FEMORPHOLOGY: Tag; export declare const FEOFFSET: Tag; export declare const FEPOINTLIGHT: Tag; export declare const FESPECULARLIGHTING: Tag; export declare const FESPOTLIGHT: Tag; export declare const FETILE: Tag; export declare const FETURBULENCE: Tag; export declare const FILTER: Tag; export declare const FOREIGNOBJECT: Tag; export declare const G: Tag; export declare const IMAGE: Tag; export declare const LINE: Tag; export declare const LINEARGRADIENT: Tag; export declare const MARKER: Tag; export declare const MASK: Tag; export declare const METADATA: Tag; export declare const MPATH: Tag; export declare const PATH: Tag; export declare const PATTERN: Tag; export declare const POLYGON: Tag; export declare const POLYLINE: Tag; export declare const RADIALGRADIENT: Tag; export declare const RECT: Tag; export declare const SET: Tag; export declare const STOP: Tag; export declare const SVG: Tag; export declare const SWITCH: Tag; export declare const SYMBOL: Tag; export declare const TEXT: Tag; export declare const TEXTPATH: Tag; export declare const TSPAN: Tag; export declare const USE: Tag; export declare const VIEW: Tag; export declare const ANNOTATION: Tag; export declare const ANNOTATION_XML: Tag; export declare const MACTION: Tag; export declare const MATH: Tag; export declare const MERROR: Tag; export declare const MFRAC: Tag; export declare const MI: Tag; export declare const MMULTISCRIPTS: Tag; export declare const MN: Tag; export declare const MO: Tag; export declare const MOVER: Tag; export declare const MPADDED: Tag; export declare const MPHANTOM: Tag; export declare const MPRESCRIPTS: Tag; export declare const MROOT: Tag; export declare const MROW: Tag; export declare const MS: Tag; export declare const MSPACE: Tag; export declare const MSQRT: Tag; export declare const MSTYLE: Tag; export declare const MSUB: Tag; export declare const MSUBSUP: Tag; export declare const MSUP: Tag; export declare const MTABLE: Tag; export declare const MTD: Tag; export declare const MTEXT: Tag; export declare const MTR: Tag; export declare const MUNDER: Tag; export declare const MUNDEROVER: Tag; export declare const SEMANTICS: Tag; /** merge `ClassProp`s regardless of structure */ export declare function mergeClass(...classes: ClassProp[]): ClassProp; /** merge `StyleProps`s regardless of type * @returns {string} merged StyleProp */ export declare function mergeStyle(...props: StyleProp[]): StyleProp; /** merge `Props` from left to right * utilizing `mergeStyle` for style properties and `mergeClass` for class properties. * @returns {Props} merged Prop object or undefined if no props were provided */ export declare function mergeProps(...props: (Props | undefined | null)[]): Props | undefined; /** * State context for type-safe access and manipulation of nested state paths * while still be able to access the parent state. */ export interface StateContext extends SubContext { /** * parent state * @see PatchableState */ get state(): S; } /** * State context for type-safe access and manipulation of nested sub-state values without knowledge of the parent state. */ export interface SubContext { /** * Reads the current value of the substate if it exists. * * @returns The current value, or undefined if the path doesn't exist */ get(): SubState | undefined; /** * Updates the nested sub-state value WITHOUT triggering a render. * This performs a silent mutation of the parent state object. * * @param {DeepPartial} value - The new value or partial update to apply */ put(value: SubState | Partial | DeepPartial | undefined | null): void; /** * Updates the nested sub-state value AND triggers a render. * This is the recommended way to update nested state in most cases. * * @param value - The new value or partial update to apply */ patch(value: SubState | Partial | DeepPartial | Array> | undefined | null): void; } export type ProxyStateContext = StateContext & { [K in keyof SubState]-?: SubState[K] extends object ? ProxyStateContext : StateContext; }; export type ProxySubContext = SubContext & { [K in keyof SubState]-?: SubState[K] extends object ? ProxySubContext : SubContext; }; /** * create a ProxyStateContext for type-safe dynamic access to nested state * * @example * ```typescript * const state = createState({ * user: { * profile: { * settings: { theme: 'dark', lang: 'en' } * } * }); * app(element, state, (s) => [DIV]); * * // Create a proxy context for the state * const ctx = context(state).user.profile.settings; * * // Access nested state dynamically * const settings = ctx.get(); // { theme: 'dark', lang: 'en' } * * // Update and trigger render * ctx.patch({ theme: 'light' }); * * // Update without render (silent mutation) * ctx.put({ lang: 'de' }); * state.patch({}); // trigger render manually later * ``` * * @param state * @returns */ export declare function context(state: S): ProxyStateContext; export {};