UNPKG

minify-xml

Version:

Fast XML minifier / compressor / uglifier with a command-line

136 lines 6.74 kB
/** * Minify an XML document. * * @param {string} xml The XML document to minify * @param {MinifyOptions} [options=defaultOptions] The options to minify the XML document * @returns {string} The minified XML document */ export function minify(xml: string, options?: MinifyOptions): string; /** * Minify an XML document stream. * * @param {MinifyStreamOptions} [options=defaultStreamOptions] The options to minify the XML document stream * @returns {import('node:stream').Duplex} A duplex stream that minifies an XML document */ export function minifyStream(options?: MinifyStreamOptions): import("node:stream").Duplex; /** * Debug minifying an XML document. * * @ignore * @param {string} xml The XML document to debug minifying * @param {MinifyOptions} [options=defaultOptions] The options to minify the XML document */ export function debug(xml: string, options?: MinifyOptions): void; /** * Options to minify an XML document. * * @typedef {object} MinifyOptions * @property {boolean} removeComments Remove XML comments <!-- ... --> * @property {boolean|string} removeWhitespaceBetweenTags Remove whitespace only between tags <anyTag/> <anyOtherTag/> (true / false or 'strict', strict will not consider prolog / doctype, as tags) * @property {boolean} considerPreserveWhitespace Remove / trim whitespace in texts like <anyTag> foo </anyTag> * @property {boolean} collapseWhitespaceInTags Remove / collapse whitespace in tags <anyTag attributeA = "..." attributeB = "..."> ... </anyTag > * @property {boolean} collapseEmptyElements Collapse elements with start / end tags and no content to empty element tags <anyTag anyAttribute = "..." ></anyTag > * @property {boolean|string} trimWhitespaceFromTexts Remove / trim whitespace in texts like <anyTag> foo </anyTag> (true / false or 'strict', strict will not consider prolog / doctype, as tags) * @property {boolean|string} collapseWhitespaceInTexts Collapse whitespace in texts like <anyTag>foo bar baz</anyTag> (true / false or 'strict', strict will not consider prolog / doctype, as tags) * @property {boolean} collapseWhitespaceInProlog Remove / collapse whitespace in the xml prolog <?xml version = "1.0" ?> * @property {boolean} collapseWhitespaceInDocType Remove / collapse whitespace in the xml document type declaration <!DOCTYPE DocType > * @property {boolean} removeSchemaLocationAttributes Remove any xsi:schemaLocation / xsi:noNamespaceSchemaLocation attributes <anyTag xsi:schemaLocation="/schema/" /> * @property {boolean} removeUnnecessaryStandaloneDeclaration Remove unnecessary standalone declaration in prolog <?xml standalone = "yes" ?> * @property {boolean} removeUnusedNamespaces Remove unused namespaces and shorten the remaining ones to a minimum length * @property {boolean} removeUnusedDefaultNamespace Remove unused default namespace declaration if no tags with no namespace declaration are present * @property {boolean} shortenNamespaces Shorten existing (non already one character namespaces) to a shorter equivalent * @property {boolean} ignoreCData Ignore CDATA sections <![CDATA[ ... ]]> */ /** * The default options applied when minifying an XML document. * * @type {MinifyOptions} */ export const defaultOptions: MinifyOptions; export default minify; /** * The default options applied when minifying an XML document stream. * * @type {MinifyStreamOptions} */ export const defaultStreamOptions: MinifyStreamOptions; export function minifyPipeline(source: import("node:stream").PipelineSource<string>, destination: import("node:stream").PipelineDestination<import("node:stream").PipelineTransformSource<string>, string>, options?: MinifyStreamOptions): import("node:stream").PipelinePromise<import("node:stream").PipelineDestination<any, string>>; /** * Options to minify an XML document. */ export type MinifyOptions = { /** * Remove XML comments <!-- ... --> */ removeComments: boolean; /** * Remove whitespace only between tags <anyTag/> <anyOtherTag/> (true / false or 'strict', strict will not consider prolog / doctype, as tags) */ removeWhitespaceBetweenTags: boolean | string; /** * Remove / trim whitespace in texts like <anyTag> foo </anyTag> */ considerPreserveWhitespace: boolean; /** * Remove / collapse whitespace in tags <anyTag attributeA = "..." attributeB = "..."> ... </anyTag > */ collapseWhitespaceInTags: boolean; /** * Collapse elements with start / end tags and no content to empty element tags <anyTag anyAttribute = "..." ></anyTag > */ collapseEmptyElements: boolean; /** * Remove / trim whitespace in texts like <anyTag> foo </anyTag> (true / false or 'strict', strict will not consider prolog / doctype, as tags) */ trimWhitespaceFromTexts: boolean | string; /** * Collapse whitespace in texts like <anyTag>foo bar baz</anyTag> (true / false or 'strict', strict will not consider prolog / doctype, as tags) */ collapseWhitespaceInTexts: boolean | string; /** * Remove / collapse whitespace in the xml prolog <?xml version = "1.0" ?> */ collapseWhitespaceInProlog: boolean; /** * Remove / collapse whitespace in the xml document type declaration <!DOCTYPE DocType > */ collapseWhitespaceInDocType: boolean; /** * Remove any xsi:schemaLocation / xsi:noNamespaceSchemaLocation attributes <anyTag xsi:schemaLocation="/schema/" /> */ removeSchemaLocationAttributes: boolean; /** * Remove unnecessary standalone declaration in prolog <?xml standalone = "yes" ?> */ removeUnnecessaryStandaloneDeclaration: boolean; /** * Remove unused namespaces and shorten the remaining ones to a minimum length */ removeUnusedNamespaces: boolean; /** * Remove unused default namespace declaration if no tags with no namespace declaration are present */ removeUnusedDefaultNamespace: boolean; /** * Shorten existing (non already one character namespaces) to a shorter equivalent */ shortenNamespaces: boolean; /** * Ignore CDATA sections <![CDATA[ ... ]]> */ ignoreCData: boolean; }; /** * Options to minify an XML document stream. */ export type MinifyStreamSpecificOptions = { /** * The maximum size of matches between chunks */ streamMaxMatchLength: number; }; /** * Options to minify an XML document stream. */ export type MinifyStreamOptions = Omit<MinifyOptions, "removeUnnecessaryStandaloneDeclaration" | "removeUnusedNamespaces" | "removeUnusedDefaultNamespace" | "shortenNamespaces" | "ignoreCData"> & MinifyStreamSpecificOptions; //# sourceMappingURL=index.d.ts.map