export type State = {
val: T
onnew(l: (val: T, oldVal: T) => void): void
}
// Defining readonly view of State for covariance.
// Basically we want State implements StateView
export interface StateView {
readonly val: T
}
export type Primitive = string | number | boolean | bigint
export type PropValue = Primitive | Function | null
export interface DerivedProp {
readonly deps: readonly StateView[]
readonly f: (...args: readonly any[]) => PropValue
}
export interface Props {
readonly [key: string]: PropValue | StateView | DerivedProp
}
export type ChildDom = Primitive | Node | StateView | readonly ChildDom[]
export type TagFunc = (first?: Props | ChildDom, ...rest: readonly ChildDom[]) => Result
type Tags = {
readonly [key: string]: TagFunc
// Register known element types
// Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element
// Main root
readonly html: TagFunc
// Document metadata
readonly base: TagFunc
readonly head: TagFunc
readonly link: TagFunc
readonly meta: TagFunc
readonly style: TagFunc
readonly title: TagFunc
// Sectioning root
readonly body: TagFunc
// Content sectioning
readonly h1: TagFunc
readonly h2: TagFunc
readonly h3: TagFunc
readonly h4: TagFunc
readonly h5: TagFunc
readonly h6: TagFunc
// Text content
readonly blockquote: TagFunc
readonly div: TagFunc
readonly dl: TagFunc
readonly hr: TagFunc
readonly li: TagFunc
readonly menu: TagFunc
readonly ol: TagFunc
readonly p: TagFunc
readonly pre: TagFunc
readonly ul: TagFunc
// Inline text semantics
readonly a: TagFunc
readonly br: TagFunc
readonly data: TagFunc
readonly q: TagFunc
readonly span: TagFunc
readonly time: TagFunc
// Image and multimedia
readonly area: TagFunc
readonly audio: TagFunc
readonly img: TagFunc
readonly map: TagFunc
readonly track: TagFunc
readonly video: TagFunc
// Embedded content
readonly embed: TagFunc
readonly iframe: TagFunc
readonly object: TagFunc
readonly picture: TagFunc
readonly source: TagFunc
// Scripting
readonly canvas: TagFunc
readonly script: TagFunc
// Demarcating edits
readonly del: TagFunc
readonly ins: TagFunc
// Table content
readonly caption: TagFunc
readonly col: TagFunc
readonly colgroup: TagFunc
readonly table: TagFunc
readonly tbody: TagFunc
readonly td: TagFunc
readonly tfoot: TagFunc
readonly th: TagFunc
readonly thead: TagFunc
readonly tr: TagFunc
// Forms
readonly button: TagFunc
readonly datalist: TagFunc
readonly fieldset: TagFunc
readonly form: TagFunc
readonly input: TagFunc
readonly label: TagFunc
readonly legend: TagFunc
readonly meter: TagFunc
readonly optgroup: TagFunc
readonly option: TagFunc
readonly output: TagFunc
readonly progress: TagFunc
readonly select: TagFunc
readonly textarea: TagFunc
// Interactive elements
readonly details: TagFunc
readonly dialog: TagFunc
// Web Components
readonly slot: TagFunc
readonly template: TagFunc
}
declare function bind(d1: StateView, f: (v1: T1, dom: Element, oldV1: T1) => Primitive | Node | null | undefined): Node | []
declare function bind(d1: StateView, d2: StateView, f: (v1: T1, v2: T2, dom: Element, oldV1: T1, oldV2: T2) => Primitive | Node | null | undefined): Node | []
declare function bind(d1: StateView, d2: StateView, d3: StateView, f: (v1: T1, v2: T2, v3: T3, dom: Element, oldV1: T1, oldV2: T2, oldV3: T3) => Primitive | Node | null | undefined): Node | []
declare function bind(d1: StateView, d2: StateView, d3: StateView, d4: StateView, f: (v1: T1, v2: T2, v3: T3, v4: T4, dom: Element, oldV1: T1, oldV2: T2, oldV3: T3, oldV4: T4) => Primitive | Node | null | undefined): Node | []
declare function bind(d1: StateView, d2: StateView, d3: StateView, d4: StateView, d5: StateView, f: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, dom: Element, oldV1: T1, oldV2: T2, oldV3: T3, oldV4: T4, oldV5: T5) => Primitive | Node | null | undefined): Node | []
declare function bind(d1: StateView, d2: StateView, d3: StateView, d4: StateView, d5: StateView, d6: StateView, f: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, dom: Element, oldV1: T1, oldV2: T2, oldV3: T3, oldV4: T4, oldV5: T5, oldV6: T6) => Primitive | Node | null | undefined): Node | []
declare function bind(d1: StateView, d2: StateView, d3: StateView, d4: StateView, d5: StateView, d6: StateView, d7: StateView, f: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, dom: Element, oldV1: T1, oldV2: T2, oldV3: T3, oldV4: T4, oldV5: T5, oldV6: T6, oldV7: T7) => Primitive | Node | null | undefined): Node | []
declare function bind(d1: StateView, d2: StateView, d3: StateView, d4: StateView, d5: StateView, d6: StateView, d7: StateView, d8: StateView, f: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8, dom: Element, oldV1: T1, oldV2: T2, oldV3: T3, oldV4: T4, oldV5: T5, oldV6: T6, oldV7: T7, oldV8: T8) => Primitive | Node | null | undefined): Node | []
declare function bind(d1: StateView, d2: StateView, d3: StateView, d4: StateView, d5: StateView, d6: StateView, d7: StateView, d8: StateView, d9: StateView, f: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8, v9: T9, dom: Element, oldV1: T1, oldV2: T2, oldV3: T3, oldV4: T4, oldV5: T5, oldV6: T6, oldV7: T7, oldV8: T8, oldV9: T9) => Primitive | Node | null | undefined): Node | []
declare function bind(d1: StateView, d2: StateView, d3: StateView, d4: StateView, d5: StateView, d6: StateView, d7: StateView, d8: StateView, d9: StateView, d10: StateView, f: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8, v9: T9, v10: T10, dom: Element, oldV1: T1, oldV2: T2, oldV3: T3, oldV4: T4, oldV5: T5, oldV6: T6, oldV7: T7, oldV8: T8, oldV9: T9, oldV10: T10) => Primitive | Node | null | undefined): Node | []
export type Van = {
readonly state: (initVal: T) => State
readonly add: (dom: Element, ...children: readonly ChildDom[]) => Element
readonly tags: Tags
readonly bind: typeof bind
}
declare const van: Van
export default van