@werker/html
Version:
HTML templating and streaming response library for worker environments such as Cloudflare Workers
34 lines • 1.59 kB
TypeScript
declare type Repeatable<T> = T | T[];
declare type Awaitable<T> = T | Promise<T>;
declare type Callable<T> = T | (() => T);
declare type Primitive = undefined | boolean | number | string | BigInt | Symbol;
declare type Renderable = null | Primitive | HTML | UnsafeHTML | Fallback;
declare type HTMLContentStatic = Repeatable<Awaitable<Repeatable<Renderable>>>;
export declare type HTMLContent = Callable<HTMLContentStatic>;
declare abstract class Unpackable {
abstract [Symbol.asyncIterator](): AsyncIterableIterator<string>;
}
export declare class HTML extends Unpackable {
strings: TemplateStringsArray;
args: HTMLContent[];
constructor(strings: TemplateStringsArray, args: HTMLContent[]);
[Symbol.asyncIterator](): AsyncIterableIterator<string>;
}
export declare class UnsafeHTML extends Unpackable {
value: string;
constructor(value: string);
[Symbol.asyncIterator](): AsyncGenerator<string, void, unknown>;
toString(): string;
toJSON(): string;
}
export declare class Fallback extends Unpackable {
content: HTMLContent;
fallback: HTML | ((e: any) => HTML);
constructor(content: HTMLContent, fallback: HTML | ((e: any) => HTML));
[Symbol.asyncIterator](): AsyncGenerator<string, void, undefined>;
}
export declare function html(strings: TemplateStringsArray, ...args: HTMLContent[]): HTML;
export { html as css, html as js };
export declare function fallback(content: HTMLContent, fallback: HTML | ((e: any) => HTML)): Fallback;
export declare function unsafeHTML(content: string): UnsafeHTML;
//# sourceMappingURL=html.d.ts.map