export {} declare global { namespace Van { interface State { val: T readonly oldVal: T readonly rawVal: T } // Defining readonly view of State for covariance. // Basically we want StateView to implement StateView type StateView = Readonly> type Val = State | T type Primitive = string | number | boolean | bigint // deno-lint-ignore no-explicit-any type PropValue = Primitive | ((e: any) => void) | null type PropValueOrDerived = PropValue | StateView | (() => PropValue) type Props = Record & { class?: PropValueOrDerived; is?: string } type PropsWithKnownKeys = Partial<{[K in keyof ElementType]: PropValueOrDerived}> type ValidChildDomValue = Primitive | Node | null | undefined type BindingFunc = ((dom?: Node) => ValidChildDomValue) | ((dom?: Element) => Element) type ChildDom = ValidChildDomValue | StateView | BindingFunc | readonly ChildDom[] type TagFunc = (first?: Props & PropsWithKnownKeys | ChildDom, ...rest: readonly ChildDom[]) => Result type Tags = Readonly>> & { [K in keyof HTMLElementTagNameMap]: TagFunc } } const Van:{ readonly state: (initVal: T)=> Van.State readonly derive: (f: () => T) => Van.State readonly add: (dom: Element, ...children: readonly Van.ChildDom[]) => Element readonly tags: Van.Tags & ((namespaceURI: string) => Readonly>>) readonly hydrate: (dom: T, f: (dom: T) => T | null | undefined) => T }; namespace VanX { type StateOf = { readonly [K in keyof T]: Van.State } type ValueType = T extends (infer V)[] ? V : T[keyof T] type KeyType = T extends unknown[] ? number : string type ReplacementFunc = T extends (infer V)[] ? (items: V[]) => readonly V[] : (items: [string, T[keyof T]][]) => readonly [string, T[keyof T]][] } const VanX:{ readonly calc: (f: () => R) => R readonly reactive: (obj: T) => T readonly noreactive: (obj: T) => T readonly stateFields: (obj: T) => VanX.StateOf readonly raw: (obj: T) => T readonly list: (container: (() => ElementType) | ElementType, items: T,itemFunc: (v: Van.State>, deleter: () => void, k: VanX.KeyType) => Node) => ElementType readonly replace: (obj: T, replacement: VanX.ReplacementFunc | T) => T readonly compact: (obj: T) => T }; namespace Gale { type KeyQuery = "@"; type KeyPseudo = ":"; type KeyChild = "."; type KeyGroup = "^"; type UserStyles = Partial & {[key: `${KeyQuery|KeyPseudo|KeyChild|KeyGroup}${string}`]: UserStyles } type UserSheet = Record type CollectKeys = {[Key in keyof Obj]: Obj[Key] extends object ? Key | CollectKeys : Key }[keyof Obj] type FilterKeys = Keys extends `${KeyChild|KeyGroup}${infer Rest}` ? Keys : never type CrossMultiply = A extends string ? B extends string ? `${A}${B}` : never : never type CrossMultiplyRecord = keyof Rec | { [K in keyof Rec]: K extends string ? CrossMultiply>> : never }[keyof Rec] type Tier = (selector:string, obj:UserStyles)=>string; type CreateSheet = (sheet:UserSheet&T)=> ((...args:CrossMultiplyRecord[])=>string)&{css:string} } const Gale:Gale.CreateSheet }