-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathindex.d.ts
60 lines (55 loc) · 1.71 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
export type TemplateFunction<T> = (
template: TemplateStringsArray,
...values: any[]
) => T;
export interface Tag<T> extends TemplateFunction<Hole> {
for(object: object, id?: string): TemplateFunction<T>;
node: TemplateFunction<T>;
}
export declare const html: Tag<HTMLElement>;
export declare const svg: Tag<SVGElement>;
export type Renderable = Hole | HTMLElement | SVGElement;
export declare function render<T extends Node>(
node: T,
renderer: (() => Renderable) | Renderable,
): T;
export declare function custom(
// TODO: This should be defined in `domtagger`
overrides: {
/**
* Used to provide a custom algorithm for converting a lighterhtml template
* to a valid HTML text.
*
* @param stringify The default HTML template tag to valid HTML text conversion implementation.
*/
convert?(
stringify: (template: TemplateStringsArray) => string,
): (template: TemplateStringsArray) => string;
/**
* Used to postprocess the result of `convert`.
*
* @param transform The default transformation.
*/
transform?(
transform: (markup: string) => string,
): (markup: string) => string;
} & {
[override: string]: (
defaultConversion: (...args: any) => (value: any) => void,
) => (...args: any) => (value: any) => void;
},
): {
html: Tag<HTMLElement>;
svg: Tag<SVGElement>;
render<T extends Node>(node: T, renderer: (() => Hole) | Hole): T;
};
/**
* Used for internal purposes, should be created using
* the `html` or `svg` template tags.
*/
export class Hole {
constructor(type: string, args: readonly [TemplateStringsArray, ...any[]]);
readonly type: string;
readonly template: TemplateStringsArray;
readonly values: any[];
}