import { Component } from './component'; import { elementExtrasName } from './share'; export interface Distinct { __distinct: Name; } export type NameSpace = string & Distinct<'NameSpace'>; export type TagName = string & Distinct<'TagName'>; export type Primitive = string | number | bigint | boolean | symbol | null | undefined | void; export type StaticProp = Primitive | readonly any[] | { apply?: never; readonly [k: string]: any; } | { call?: never; readonly [k: string]: any; }; export type SingleStaticChild = Primitive | Node; export type StaticChild = SingleStaticChild | readonly SingleStaticChild[]; export interface StaticProps { /** Custom element name. */ is?: string; readonly [key: string]: StaticProp; } export type StaticArg = StaticProps | StaticChild; /** @deprecated use any */ export type Prop = StaticProp | ((...a: unknown[]) => unknown); export type SingleChild = SingleStaticChild | (() => Child) | Fusion; /** @deprecated use any */ export type Child = SingleChild | readonly SingleChild[]; declare global { namespace Fusor { type ParameterSeparator = '_'; } } type ___ = Fusor.ParameterSeparator; /** Element parameters: arguments, properties, event handlers */ export interface Params { is?: string; mount?: Mount; readonly [key: `${string}${___}e`]: EL; readonly [key: `${string}${___}e${___}${string}`]: EL; readonly [key: string]: unknown; } export type Arg = Params | Child; /** Event listener function (resembles: EventListener) */ export type ELFunction = (event: EV & { target: EL; }, self: Fusion) => void; /** Event listener object (resembles: EventListenerObject) */ export type ELObject = { handleEvent: ELFunction; }; /** Event listener function or object (resembles: EventListenerOrEventListenerObject) */ export type ELFunctionOrObject = ELObject> = ELFunction | O; /** Event listener options (resembles: AddEventListenerOptions) */ export type ELOptions = ELObject> = AddEventListenerOptions & { update?: boolean; handle: ELFunctionOrObject; }; /** Event Listener */ export type EL = ELObject> = ELFunctionOrObject | ELOptions; /** DOM Element connect callback. Return disconnect function if needed. */ export type Mount = (self: Fusion) => Unmount | void; /** DOM Element disconnect callback. */ export type Unmount = () => void; /** @internal */ export interface ElementExtras { mount?: Mount; unmount?: ReturnType; component?: Component; } /** @internal */ export interface ElementWithExtras extends Element { [elementExtrasName]?: ElementExtras; } /** Some unknown structure * @internal do not rely on its internal structure * Use public API method to work with it: update, isUpdatable, getElement */ export type Fusion = E | Component; export interface XMLInitter { (namespace: NameSpace | undefined, tag: TagName, args: readonly unknown[]): Fusion; } export interface HyperNotation { (tag: Tag, ...args: readonly Arg[]): Fusion; } export interface FunctionalNotation { (...args: readonly Arg[]): Fusion; } export interface JsxFactory { (tagName: TagName | Function, props?: Params, ...children: readonly Child[]): Fusion; } export interface JsxImportSource { (tagName: TagName | Function, props?: Params, key?: any): Fusion; } export interface UpdatableProp { readonly update: () => Prop; value: Prop; isAttr: boolean; namespace?: null | string; } export interface DynamicProps { [key: string]: UpdatableProp; } export interface ChildCache { value: string | Node | Component; node: Node; } export interface UpdatableChild { readonly update: () => Child; cache: ChildCache; terminator: Text | null; arrayRef: null; } export type UpdatableChildren = { readonly update: () => Child; cache: ChildCache[]; /** Empty node after the last array node (used for insertion before it if array is empty) */ terminator: Text; arrayRef: Child[]; }; export type DynamicChild = UpdatableChild | UpdatableChildren | Component; export type AllHTMLElementTagNameMap = HTMLElementTagNameMap & HTMLElementDeprecatedTagNameMap; export {};