1 | import { SimpleDocument, SimpleElement, SimpleNode } from '@simple-dom/interface';
|
2 | interface GenericElementTags {
|
3 | HTML: HTMLElement;
|
4 | SVG: SVGElement;
|
5 | ELEMENT: HTMLElement | SVGElement;
|
6 | }
|
7 | interface GenericNodeTags {
|
8 | NODE: Node;
|
9 | }
|
10 | declare type GenericNodeTag = keyof GenericNodeTags;
|
11 | interface BrowserElementTags extends HTMLElementTagNameMap, GenericElementTags {
|
12 | }
|
13 | declare type BrowserElementTag = keyof BrowserElementTags;
|
14 | interface BrowserTags extends BrowserElementTags, GenericNodeTags {
|
15 | }
|
16 | declare type BrowserTag = keyof BrowserTags;
|
17 | declare type NodeCheck<N extends Node> = (node: Node) => node is N;
|
18 | declare type SugaryNodeCheck<K extends BrowserTag = BrowserTag> = NodeCheck<BrowserTags[K]> | K | K[];
|
19 | declare type NodeForSugaryCheck<S extends SugaryNodeCheck<BrowserTag>> = S extends NodeCheck<infer N> ? N : S extends keyof BrowserTags ? BrowserTags[S] : S extends (keyof BrowserTags)[] ? BrowserTags[S[number]] : never;
|
20 | declare type BrowserNode = Element | Document | DocumentFragment | Text | Comment | Node;
|
21 | export declare function castToSimple(doc: Document | SimpleDocument): SimpleDocument;
|
22 | export declare function castToSimple(elem: Element | SimpleElement): SimpleElement;
|
23 | export declare function castToSimple(node: Node | SimpleNode): SimpleNode;
|
24 | export declare function castToBrowser(doc: Document | SimpleDocument): Document;
|
25 | export declare function castToBrowser<S extends SugaryNodeCheck<BrowserElementTag>>(node: BrowserNode | SimpleNode, check: S): NodeForSugaryCheck<S>;
|
26 | export declare function castToBrowser<S extends SugaryNodeCheck<GenericNodeTag>>(element: BrowserNode | SimpleNode, check: S): NodeForSugaryCheck<S>;
|
27 | export declare function castToBrowser<K extends keyof HTMLElementTagNameMap>(element: SimpleElement | Element, check: K): HTMLElementTagNameMap[K];
|
28 | export declare function checkNode<S extends SugaryNodeCheck>(node: Node | null, check: S): NodeForSugaryCheck<S>;
|
29 | export {};
|
30 |
|
\ | No newline at end of file |