UNPKG

jokkerr

Version:

Node package and CLI tool for saving web page as single HTML file

88 lines (87 loc) 2.95 kB
import { Options, Webpage } from './types'; /** * @see https://html.spec.whatwg.org/multipage/semantics.html */ export declare class HTML { opt: Options; private rx; constructor(opt?: Options); /** * Process assets within webpage * * @param {Webpage} [Webpage] if error will be thrown * @return {this} [Cairn] `this` command for chaning * @api public */ process(page: Webpage): Promise<string>; /** * setContentSecurityPolicy prevent browsers from requesting any remote * resources by setting Content-Security-Policy to only allow from * inline element and data URL. * * @param {Document} doc JSDOM.window.document * @api private */ setContentSecurityPolicy(doc: Document): void; /** * Removes or replace elements following the configuration. * * @param {Document} doc JSDOM.window.document * @api private */ applyConfiguration(doc: Document): void; /** * Convert all noscript to div element. * * @param {Document} doc JSDOM.window.document * @param {boolean} [markNewDiv] mark to noscript * @api private */ convertNoScriptToDiv(doc: Document, markNewDiv?: boolean): void; /** * Find all comments in document then remove it. * * @param {Document} doc JSDOM.window.document * @api private */ removeComments(doc: Document): void; /** * Convert attributes data-src and data-srcset which often found * in lazy-loaded images and pictures, into basic attribute * src and srcset, so images that can be loaded without JS. * * @param {Document} doc JSDOM.window.document * @api private */ convertLazyImageAttrs(doc: Document): void; /** * Converts all relative URL in document into absolute URL. * We do this for a, img, picture, figure, video, audio, source, link, * embed, iframe and object. * * @param {Document} doc JSDOM.window.document * @param {string} [url] original request url * @api private */ convertRelativeURLs(doc: Document, url: string): void; /** * Removes integrity attributes from link tags. * * @param {Document} doc JSDOM.window.document * @api private */ removeLinkIntegrityAttr(doc: Document): void; /** * Set og:title to title when it empty. * * @param {Document} doc JSDOM.window.document * @api private */ convertOpenGraph(doc: Document): void; processLinkNode(doc: HTMLElement, baseURL?: string): Promise<void>; processURLNode(node: HTMLElement, attrName: string, baseURL: string): Promise<void>; processScriptNode(node: HTMLElement, baseURL: string): Promise<void>; processEmbedNode(node: HTMLElement, baseURL: string): Promise<void>; processMediaNode(node: HTMLElement, baseURL: string): Promise<void>; revertConvertedNoScript(doc: Document): void; }