UNPKG

@wabarc/cairn

Version:

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

109 lines (108 loc) 3.51 kB
/// <reference types="cheerio" /> import { Options } 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 {Object} page if error will be thrown * @return {cheerio.Cheerio} [cheerio.Cheerio] call .html() parse as html string * @api public */ process(page: { uri: string; html: string; }): Promise<cheerio.Root | null>; /** * setContentSecurityPolicy prevent browsers from requesting any remote * resources by setting Content-Security-Policy to only allow from * inline element and data URL. * * @param {Document} $ cheerio.Root * @api private */ setContentSecurityPolicy($: cheerio.Root): void; /** * Removes or replace elements following the configuration. * * @param {Document} $ cheerio.Root * @api private */ applyConfiguration($: cheerio.Root): void; /** * Convert all noscript to div element. * * @param {Document} $ cheerio.Root * @param {boolean} [markNewDiv] mark to noscript * @api private */ convertNoScriptToDiv($: cheerio.Root, markNewDiv?: boolean): void; /** * Find all comments in document then remove it. * * @param {Document} $ cheerio.Root * @api private */ removeComments($: cheerio.Root): 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} $ cheerio.Root * @api private */ convertLazyImageAttrs($: cheerio.Root): 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} $ cheerio.Root * @param {string} [url] original request url * @api private */ convertRelativeURLs($: cheerio.Root, url: string): void; /** * Removes integrity attributes from link tags. * * @param {Document} $ cheerio.Root * @api private */ removeLinkIntegrityAttr($: cheerio.Root): void; /** * Set og:title to title when it empty. * * @param {Document} $ cheerio.Root * @api private */ convertOpenGraph($: cheerio.Root): void; /** * Set webpage charset as UTF-8 * * @param {Document} $ cheerio.Root * @api private */ setCharset($: cheerio.Root): void; /** * Set source webpage url * * @param {Document} $ cheerio.Root * @param {string} url * @api private */ setSource($: cheerio.Root, url: string): void; processStyleAttr(node: cheerio.Cheerio, baseURL?: string): Promise<void>; processStyleNode(node: cheerio.Cheerio, baseURL?: string): Promise<void>; processLinkNode(node: cheerio.Cheerio, baseURL?: string): Promise<void>; processURLNode(node: cheerio.Cheerio, attrName: string, baseURL: string): Promise<void>; processScriptNode(node: cheerio.Cheerio, baseURL: string): Promise<void>; processEmbedNode(node: cheerio.Cheerio, baseURL: string): Promise<void>; processMediaNode(node: cheerio.Cheerio, baseURL: string): Promise<void>; revertConvertedNoScript($: cheerio.Root): void; }