UNPKG

1.91 kBTypeScriptView Raw
1declare type Primitive = undefined | boolean | number | string | bigint | symbol;
2declare type Callable<T> = T | (() => T);
3export declare type Unpackable<T> = T | Iterable<T> | Iterable<Promise<T>> | Promise<T> | Promise<Iterable<T>> | Promise<Iterable<Promise<T>>> | AsyncIterable<T> | AsyncIterable<Iterable<T>> | AsyncIterable<Iterable<Promise<T>>> | Promise<AsyncIterable<T>> | Promise<AsyncIterable<Iterable<T>>> | Promise<AsyncIterable<Iterable<Promise<T>>>>;
4export declare type Renderable = null | Exclude<Primitive, symbol> | HTML | UnsafeHTML | Fallback;
5export declare type HTMLContentStatic = Unpackable<Renderable>;
6export declare type HTMLContent = Callable<HTMLContentStatic>;
7export declare abstract class AbstractHTML {
8 abstract [Symbol.asyncIterator](): AsyncIterableIterator<string>;
9}
10export declare class HTML extends AbstractHTML {
11 #private;
12 constructor(strings: TemplateStringsArray, args: HTMLContent[]);
13 [Symbol.asyncIterator](): AsyncIterableIterator<string>;
14}
15export declare class UnsafeHTML extends AbstractHTML {
16 #private;
17 constructor(value: string);
18 [Symbol.asyncIterator](): AsyncGenerator<string, void, unknown>;
19 toString(): string;
20 toJSON(): string;
21}
22export declare class Fallback extends AbstractHTML {
23 #private;
24 constructor(content: HTMLContent, fallback: HTML | ((e: any) => HTML));
25 [Symbol.asyncIterator](): AsyncGenerator<string, void, undefined>;
26}
27export declare function html(strings: TemplateStringsArray, ...args: HTMLContent[]): HTML;
28export declare function html(strings: TemplateStringsArray, ...args: any[]): HTML;
29export { html as css, html as js };
30export declare function fallback(content: HTMLContent, fallback: HTML | ((e: any) => HTML)): Fallback;
31export declare function fallback(content: any, fallback: HTML | ((e: any) => HTML)): Fallback;
32export declare function unsafeHTML(content: string): UnsafeHTML;
33
\No newline at end of file