UNPKG

@worker-tools/html

Version:

HTML templating and streaming response library for Worker Runtimes such as Cloudflare Workers.

33 lines (32 loc) 1.91 kB
declare type Primitive = undefined | boolean | number | string | bigint | symbol; declare type Callable<T> = T | (() => T); export 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>>>>; export declare type Renderable = null | Exclude<Primitive, symbol> | HTML | UnsafeHTML | Fallback; export declare type HTMLContentStatic = Unpackable<Renderable>; export declare type HTMLContent = Callable<HTMLContentStatic>; export declare abstract class AbstractHTML { abstract [Symbol.asyncIterator](): AsyncIterableIterator<string>; } export declare class HTML extends AbstractHTML { #private; constructor(strings: TemplateStringsArray, args: HTMLContent[]); [Symbol.asyncIterator](): AsyncIterableIterator<string>; } export declare class UnsafeHTML extends AbstractHTML { #private; constructor(value: string); [Symbol.asyncIterator](): AsyncGenerator<string, void, unknown>; toString(): string; toJSON(): string; } export declare class Fallback extends AbstractHTML { #private; constructor(content: HTMLContent, fallback: HTML | ((e: any) => HTML)); [Symbol.asyncIterator](): AsyncGenerator<string, void, undefined>; } export declare function html(strings: TemplateStringsArray, ...args: HTMLContent[]): HTML; export declare function html(strings: TemplateStringsArray, ...args: any[]): HTML; export { html as css, html as js }; export declare function fallback(content: HTMLContent, fallback: HTML | ((e: any) => HTML)): Fallback; export declare function fallback(content: any, fallback: HTML | ((e: any) => HTML)): Fallback; export declare function unsafeHTML(content: string): UnsafeHTML;