UNPKG

@worker-tools/parsed-html-rewriter

Version:

A DOM-based implementation of Cloudflare Worker's HTMLRewriter.

56 lines 2.23 kB
/// <reference types="@cloudflare/workers-types" /> export declare type Awaitable<T> = T | Promise<T>; export declare function append<K, V>(m: Map<K, V[]>, k: K, v: V): Map<K, V[]>; export declare function promiseToAsyncIterable<T>(promise: Promise<T>): AsyncIterableIterator<T>; export declare function treeWalkerToIter(walker: TreeWalker): IterableIterator<Node>; declare type Content = string; export declare class ParsedHTMLRewriterNode { #private; constructor(node: Element | Text | Comment | null, document: Document); get removed(): boolean; before(content: Content, opts?: ContentOptions): this; after(content: Content, opts?: ContentOptions): this; replace(content: Content, opts?: ContentOptions): this; remove(): this; } export declare class ParsedHTMLRewriterElement extends ParsedHTMLRewriterNode { #private; constructor(node: Element, document: Document); get tagName(): string; get attributes(): Iterable<[string, string]>; get namespaceURI(): string | null; getAttribute(name: string): string | null; hasAttribute(name: string): boolean; setAttribute(name: string, value: string): this; removeAttribute(name: string): this; prepend(content: Content, opts?: ContentOptions): this; append(content: Content, opts?: ContentOptions): this; setInnerContent(content: Content, opts?: ContentOptions): this; removeAndKeepContent(): this; } export declare class ParsedHTMLRewriterText extends ParsedHTMLRewriterNode { #private; constructor(text: Text | null, document: Document); get text(): string; get lastInTextNode(): boolean; } export declare class ParsedHTMLRewriterComment extends ParsedHTMLRewriterNode { #private; constructor(comm: Comment, document: Document); get text(): string; set text(value: string); } export declare class ParsedHTMLRewriterDocumentType { #private; constructor(doctype: DocumentType); get name(): string; get publicId(): string; get systemId(): string; } export declare class ParsedHTMLRewriterEnd { #private; constructor(document: Document); append(content: Content, opts?: ContentOptions): this; } export {}; //# sourceMappingURL=support.d.ts.map