UNPKG

inline-source

Version:

Inline all flagged js, css, image source files

71 lines (66 loc) 1.58 kB
export type Handler = ( source: Source, context: Context ) => Promise<void> | void; export interface Context { attribute: string | boolean; compress: boolean; fs: typeof import('node:fs'); html: string; htmlpath: string; ignore: Array<string>; pretty: boolean; rootpath: string; re: RegExp; saveRemote: boolean; sources: Array<Source>; stack: Array<Handler>; swallowErrors: boolean; svgAsImage: boolean; } export interface Source { attributes: Record<string, string | boolean>; compress: boolean; content: null | string; errored: boolean; extension: string; fileContent: string; filepath: string; filepathAnchor: string; format: string; isRemote: boolean; match: string; padding: string; parentContext: Context; props: Record<string, string | boolean>; replace: string; sourcepath: string | boolean; stack: Array<Handler>; svgAsImage: boolean; tag: string; type: string; } export interface Options { attribute?: string | boolean; compress?: boolean; fs?: typeof import('node:fs'); preHandlers?: Array<Handler>; handlers?: Array<Handler>; ignore?: Array<string> | Record<string, string>; pretty?: boolean; rootpath?: string; saveRemote?: boolean; svgAsImage?: boolean; swallowErrors?: boolean; } /** * Parse `htmlpath` content for tags containing an `inline` attribute, * and replace with (optionally compressed) file contents. */ export function inlineSource( /** * Path to html file or raw string of html */ htmlpath: string, options?: Options ): Promise<string>;