@altano/html-cdnify
Version:
Transform the relative URLs in your HTML markup (e.g. scripts, stylesheets, images) to use your CDN URL.
36 lines (35 loc) • 1.49 kB
TypeScript
import HtmlTransformer from "./HtmlTransformer.js";
//#region src/HtmlAttributeStreamTransformer.d.ts
interface HtmlAttributeStreamTransformerOptions {
transformDefinitions: TransformDefinition[];
transformFunction: TransformFunction;
attributeToMarkElementToBeIgnored?: string;
}
interface TransformDefinition {
selector: string;
attribute: string;
attributeParser?: undefined | ((oldAttribute: string, transformFunction: TransformFunction) => string);
}
type TransformFunction = (oldAttribute: string) => string;
interface AttributeParser {
(oldAttribute: string, transformFunction: TransformFunction): string;
}
interface AttributeParsers {
[index: string]: AttributeParser;
}
/**
* Wraps a node-trumpet Transform stream, w/ HTML as input and
* HTML as output. The output will have all non-absolute-URL
* attributes that identify CDN-able resources converted to
* use the given CDN URL.
*/
declare class HtmlAttributeStreamTransformer extends HtmlTransformer {
options: HtmlAttributeStreamTransformerOptions;
condensedTransformOptions: TransformDefinition[];
constructor(options: HtmlAttributeStreamTransformerOptions);
static attributeParsers: AttributeParsers;
protected applyTransforms(): void;
private processTransforms;
} //#endregion
export { AttributeParser, AttributeParsers, HtmlAttributeStreamTransformer, HtmlAttributeStreamTransformerOptions, TransformDefinition, TransformFunction };
//# sourceMappingURL=HtmlAttributeStreamTransformer.d.ts.map