html-minifier 4.0.0 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/LICENSE.txt +23 -0
  2. package/README.md +851 -110
  3. package/cli.js +991 -207
  4. package/dist/types/htmlminifier.d.ts +629 -0
  5. package/dist/types/htmlminifier.d.ts.map +1 -0
  6. package/dist/types/htmlparser.d.ts +28 -0
  7. package/dist/types/htmlparser.d.ts.map +1 -0
  8. package/dist/types/lib/attributes.d.ts +87 -0
  9. package/dist/types/lib/attributes.d.ts.map +1 -0
  10. package/dist/types/lib/constants.d.ts +421 -0
  11. package/dist/types/lib/constants.d.ts.map +1 -0
  12. package/dist/types/lib/content.d.ts +44 -0
  13. package/dist/types/lib/content.d.ts.map +1 -0
  14. package/dist/types/lib/elements.d.ts +48 -0
  15. package/dist/types/lib/elements.d.ts.map +1 -0
  16. package/dist/types/lib/fragments.d.ts +47 -0
  17. package/dist/types/lib/fragments.d.ts.map +1 -0
  18. package/dist/types/lib/option-definitions.d.ts +33 -0
  19. package/dist/types/lib/option-definitions.d.ts.map +1 -0
  20. package/dist/types/lib/options.d.ts +93 -0
  21. package/dist/types/lib/options.d.ts.map +1 -0
  22. package/dist/types/lib/unused-css.d.ts +76 -0
  23. package/dist/types/lib/unused-css.d.ts.map +1 -0
  24. package/dist/types/lib/urls.d.ts +15 -0
  25. package/dist/types/lib/urls.d.ts.map +1 -0
  26. package/dist/types/lib/utils.d.ts +132 -0
  27. package/dist/types/lib/utils.d.ts.map +1 -0
  28. package/dist/types/lib/whitespace.d.ts +97 -0
  29. package/dist/types/lib/whitespace.d.ts.map +1 -0
  30. package/dist/types/presets.d.ts +50 -0
  31. package/dist/types/presets.d.ts.map +1 -0
  32. package/dist/types/tokenchain.d.ts +36 -0
  33. package/dist/types/tokenchain.d.ts.map +1 -0
  34. package/html-minifier.schema.json +322 -0
  35. package/package.json +71 -60
  36. package/src/htmlminifier.js +2862 -1106
  37. package/src/htmlparser.js +1163 -452
  38. package/src/lib/attributes.js +1196 -0
  39. package/src/lib/constants.js +521 -0
  40. package/src/lib/content.js +237 -0
  41. package/src/lib/elements.js +268 -0
  42. package/src/lib/file-pool.js +193 -0
  43. package/src/lib/file-write.js +87 -0
  44. package/src/lib/fragments.js +340 -0
  45. package/src/lib/option-definitions.js +246 -0
  46. package/src/lib/options.js +841 -0
  47. package/src/lib/unused-css.js +499 -0
  48. package/src/lib/urls.js +146 -0
  49. package/src/lib/utils.js +1026 -0
  50. package/src/lib/whitespace.js +431 -0
  51. package/src/presets.js +58 -0
  52. package/src/tokenchain.js +142 -56
  53. package/LICENSE +0 -22
  54. package/sample-cli-config-file.conf +0 -40
  55. package/src/utils.js +0 -18
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Single source of truth for minifier option names, descriptions, types, and shared defaults
3
+ */
4
+ export type OptionDefinition = {
5
+ /**
6
+ * Help text, phrased for the option’s primary CLI form
7
+ */
8
+ description: string;
9
+ /**
10
+ * Help text for what enabling the option does, where `description` describes the negated form
11
+ */
12
+ descriptionAffirmative?: string;
13
+ /**
14
+ * Key into the parser and JSON Schema type maps in cli.js and scripts/build-schema.js
15
+ */
16
+ type: string;
17
+ };
18
+ /**
19
+ * @typedef {object} OptionDefinition
20
+ * @property {string} description Help text, phrased for the option’s primary CLI form
21
+ * @property {string} [descriptionAffirmative] Help text for what enabling the option does, where `description` describes the negated form
22
+ * @property {string} type Key into the parser and JSON Schema type maps in cli.js and scripts/build-schema.js
23
+ */
24
+ /** @type {Record<string, OptionDefinition>} */
25
+ declare const optionDefinitions: Record<string, OptionDefinition>;
26
+ declare const optionDefaults: {
27
+ continueOnMinifyError: boolean;
28
+ ignoreCustomComments: RegExp[];
29
+ ignoreCustomFragments: RegExp[];
30
+ includeAutoGeneratedTags: boolean;
31
+ };
32
+ export { optionDefinitions, optionDefaults };
33
+ //# sourceMappingURL=option-definitions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"option-definitions.d.ts","sourceRoot":"","sources":["../../../src/lib/option-definitions.js"],"names":[],"mappings":"AAAA;;GAEG;AAGA,YAAkB,gBAAgB,GAClC;;;;IAAmB,WAAW,EAAnB,MAAM,CACjB;;;;IAAoB,sBAAsB,AAA1C,CACA,EADW,MAAM,CACjB;;;;IAAmB,IAAI,EAAZ,MAAM,CACnB;CAAA,CAAA;AALD;;;;;GAKG;AAEH,+CAA+C;AAC/C,QAAA,MAAM,iBAAiB,EADZ,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAuNzC,CAAC;AAEF,QAAA,MAAM,cAAc;IAClB,qBAAqB;IACrB,oBAAoB;IAIpB,qBAAqB;IAKrB,wBAAwB;CACzB,CAAC;AAEF,OAAO,EACL,iBAAiB,EACjB,cAAc,EACf,CAAC"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Options processing and per-document minification state
3
+ */
4
+ import { LRU } from './utils.js';
5
+ import type { MinifierOptions, HTMLAttribute } from '../htmlminifier.js';
6
+ export type CSSContext = {
7
+ usedSymbols?: Set<string>;
8
+ usedElements?: Set<string>;
9
+ usedElementsKey?: string;
10
+ warned: Set<string>;
11
+ };
12
+ export type CSSResult = {
13
+ css: string;
14
+ warnings: string[];
15
+ };
16
+ export type ProcessedOptions = Omit<MinifierOptions, 'preset' | 'canCollapseWhitespace' | 'canTrimWhitespace' | 'ignoreCustomComments' | 'log' | 'minifyCSS' | 'minifyJS' | 'minifyURLs' | 'minifySVG' | 'removeUnusedCSS'> & {
17
+ name: (name: string) => string;
18
+ log: (message: any) => unknown;
19
+ ignoreCustomComments: RegExp[];
20
+ canCollapseWhitespace: (tag: string, attrs: HTMLAttribute[], defaultFn: (tag: string) => boolean) => boolean;
21
+ canTrimWhitespace: (tag: string, attrs: HTMLAttribute[], defaultFn: (tag: string) => boolean) => boolean;
22
+ minifyCSS: (text: string, type?: string, context?: CSSContext) => string | Promise<string>;
23
+ minifyJS: (text: string, inline?: boolean, isModule?: boolean) => string | Promise<string>;
24
+ minifyURLs: (text: string) => string | Promise<string>;
25
+ minifySVG: ((svgContent: string) => string | Promise<string>) | null;
26
+ canMinifyCSS: ((text: string, type?: 'inline' | 'media') => boolean) | null;
27
+ canMinifyJS: ((text: string, inline?: boolean) => boolean) | null;
28
+ canMinifySVG: ((text: string) => boolean) | null;
29
+ removeUnusedCSS: {
30
+ safelist: Array<string | RegExp>;
31
+ scripts: boolean;
32
+ } | null;
33
+ cssContext?: CSSContext;
34
+ documentState?: {
35
+ hasMathML: boolean;
36
+ };
37
+ baseState?: {
38
+ hasBase: boolean | undefined;
39
+ source: string;
40
+ };
41
+ parallelJS?: boolean;
42
+ nameParent?: (name: string) => string;
43
+ namesAsWritten?: boolean;
44
+ keepClosingSlashHTML?: boolean;
45
+ insideSVG?: boolean;
46
+ insideForeignContent?: boolean;
47
+ namespaceForeign?: 'svg' | 'math';
48
+ };
49
+ /** @param {ProcessedOptions} options */
50
+ declare function shouldMinifyInnerHTML(options: ProcessedOptions): boolean;
51
+ declare const optionKeysExtra: Set<string>;
52
+ export type OptionDependency = OptionDependency[];
53
+ /**
54
+ * Options that do nothing on their own, and the option each one needs to take effect
55
+ *
56
+ * Cache sizes are deliberately absent: They never change output, so they are
57
+ * configuration for a subsystem rather than a transform that silently fails.
58
+ *
59
+ * @typedef {object} OptionDependency
60
+ * @property {string} option
61
+ * @property {string} requires
62
+ * @property {(input: Record<string, any>) => string | false} [unusable] Clause saying why the prerequisite does not count even though it is set
63
+ * @property {boolean} [clear] Whether to null the option out, where leaving it set would cost work downstream
64
+ *
65
+ * @type {OptionDependency[]}
66
+ */
67
+ declare const optionDependencies: ({
68
+ option: string;
69
+ requires: string;
70
+ unusable: (input: Record<string, any>) => "which a function of your own replaces" | false;
71
+ clear: boolean;
72
+ } | {
73
+ unusable?: never;
74
+ clear?: never;
75
+ option: string;
76
+ requires: string;
77
+ })[];
78
+ /**
79
+ * @param {MinifierOptions} inputOptions - User-provided options
80
+ * @param {{getLightningCSS: Function, getTerser: Function, getSwc: Function, getSvgo: Function, cssMinifyCache: LRU, jsMinifyCache: LRU, svgMinifyCache: LRU}} deps - Dependencies from htmlminifier.js
81
+ * @returns {ProcessedOptions} Normalized options with defaults applied
82
+ */
83
+ declare const processOptions: (inputOptions: MinifierOptions, { getLightningCSS, getTerser, getSwc, getSvgo, cssMinifyCache, jsMinifyCache, svgMinifyCache }: {
84
+ getLightningCSS: Function;
85
+ getTerser: Function;
86
+ getSwc: Function;
87
+ getSvgo: Function;
88
+ cssMinifyCache: LRU;
89
+ jsMinifyCache: LRU;
90
+ svgMinifyCache: LRU;
91
+ }) => ProcessedOptions;
92
+ export { optionDependencies, optionKeysExtra, shouldMinifyInnerHTML, processOptions };
93
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/lib/options.js"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,GAAG,EAA2K,MAAM,YAAY,CAAC;AAQtM,OAAQ,KAAA,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAOrE,YAAkH,UAAU,GAAlH;IAAC,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAAC,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAAC,CAAY;AAO5H,YAA6C,SAAS,GAA5C;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAC,CAAW;AAUtD,YAwBG,gBAAgB,GAxBT,IAAI,CAAC,eAAe,EAAE,QAAQ,GAAG,uBAAuB,GAAG,mBAAmB,GAAG,sBAAsB,GAAG,KAAK,GAAG,WAAW,GAAG,UAAU,GAAG,YAAY,GAAG,WAAW,GAAG,iBAAiB,CAAC,GAAG;IACvM,IAAI,EAA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BAkiBZ,CAAC;AAEF,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,cAAc,EACf,CAAC"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Unused-CSS removal
3
+ */
4
+ /**
5
+ * Collect the class names and IDs a document references.
6
+ *
7
+ * Style sheet contents are excluded, so that a style sheet never counts as
8
+ * evidence for its own selectors. An `iframe srcdoc` value is not scanned,
9
+ * either: It holds a document of its own, minified against its own symbol set.
10
+ * Over-collecting is safe here (a symbol wrongly considered used is merely
11
+ * kept), under-collecting is not.
12
+ *
13
+ * @param {string} html - Raw document markup
14
+ * @param {boolean} includeScripts - Also treat identifiers inside inline `script` elements as used
15
+ * @param {((text: string) => string)} [decode] - Resolves character references in attribute values and foreign script contents
16
+ * @param {Set<string>} [elements] - Receives the element names the markup uses, lowercased, and the identifiers found in scripts, as possible element names
17
+ * @returns {Set<string>} Symbols to keep
18
+ */
19
+ declare function collectUsedSymbols(html: string, includeScripts: boolean, decode?: ((text: string) => string), elements?: Set<string>): Set<string>;
20
+ /**
21
+ * Determine which class/ID symbols a style sheet defines but the document doesn’t reference.
22
+ * @param {string} css - Style sheet contents
23
+ * @param {Set<string>} used - Symbols the document references
24
+ * @param {Array<string | RegExp>} safelist - Symbols to keep regardless
25
+ * @returns {string[]} Symbols safe to remove
26
+ */
27
+ declare function findUnusedSymbols(css: string, used: Set<string>, safelist: Array<string | RegExp>): string[];
28
+ /**
29
+ * Build the unused-CSS context for a document.
30
+ * @param {string} html - Raw document markup
31
+ * @param {boolean} includeScripts - Also treat identifiers inside inline `script` elements as used
32
+ * @param {((text: string) => string)} [decode] - Resolves character references in attribute values and foreign script contents
33
+ * @returns {{usedSymbols: Set<string>, usedElements: Set<string>, usedElementsKey: string}}
34
+ */
35
+ declare function collectUsage(html: string, includeScripts: boolean, decode?: ((text: string) => string)): {
36
+ usedSymbols: Set<string>;
37
+ usedElements: Set<string>;
38
+ usedElementsKey: string;
39
+ };
40
+ /**
41
+ * Create a Lightning CSS `Selector` visitor that drops selectors naming an unused
42
+ * class, ID, or element from their list, so the rule stays for the selectors that
43
+ * remain (`unusedSymbols` alone only removes rules whose selectors are all unused).
44
+ *
45
+ * Only a selector’s own compounds are judged: Names inside pseudo-class and
46
+ * pseudo-element arguments (`:not(.x)`, `:host(.x)`) are left alone.
47
+ *
48
+ * @param {string[]} unusedSymbols - Class/ID symbols safe to remove, from `findUnusedSymbols`
49
+ * @param {Set<string>} usedElements - Lowercase element names the document contains or its scripts name
50
+ * @param {Array<string | RegExp>} safelist - Symbols to keep regardless
51
+ * @returns {(selector: Array<{type: string, name?: string}>) => [] | undefined}
52
+ */
53
+ declare function createSelectorPruner(unusedSymbols: string[], usedElements: Set<string>, safelist: Array<string | RegExp>): (selector: Array<{
54
+ type: string;
55
+ name?: string;
56
+ }>) => [] | undefined;
57
+ /**
58
+ * Normalize the `removeUnusedCSS` option into a settled configuration.
59
+ *
60
+ * A misspelled key or a safelist that is not an array would otherwise protect
61
+ * nothing, and that only surfaces as a missing rule much later—so every value
62
+ * that gets dropped is reported.
63
+ *
64
+ * @param {boolean | {safelist?: Array<string | RegExp>, scripts?: boolean} | undefined} option
65
+ * @param {(message: string) => unknown} [warn] - Receives one message per ignored value
66
+ * @returns {{safelist: Array<string | RegExp>, scripts: boolean} | null} Null when disabled
67
+ */
68
+ declare function normalizeUnusedCSSOptions(option: boolean | {
69
+ safelist?: Array<string | RegExp>;
70
+ scripts?: boolean;
71
+ } | undefined, warn?: (message: string) => unknown): {
72
+ safelist: Array<string | RegExp>;
73
+ scripts: boolean;
74
+ } | null;
75
+ export { collectUsage, collectUsedSymbols, createSelectorPruner, findUnusedSymbols, normalizeUnusedCSSOptions };
76
+ //# sourceMappingURL=unused-css.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unused-css.d.ts","sourceRoot":"","sources":["../../../src/lib/unused-css.js"],"names":[],"mappings":"AAAA;;GAEG;AA4KH;;;;;;;;;;;;;;GAcG;AACH,iBAA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AE,OAAO,CAAA;CAAC,GAAG,SAIrC,EAAE,IAAI,AAH5C,CACA,EADQ,CAAC,OAAO,EAAE,MAAM,KAAK,OAGe,GAFlC;IAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAC,GAAG,IAAI,CAyCvE;AAED,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,yBAAyB,EAC1B,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * URL minification using Node’s WHATWG URL API
3
+ *
4
+ * Produces the shortest equivalent URL representation:
5
+ * - Same origin: shortest of root-relative or path-relative
6
+ * - Cross-origin, same scheme: scheme-relative (`//host/path`)
7
+ * - Otherwise: normalized absolute URL
8
+ */
9
+ /**
10
+ * Create a URL minifier function for the given site context.
11
+ * @param {string} site - The site base URL (used to compute relative URLs)
12
+ * @returns {(url: string) => string} Minifier function that returns the shortest URL
13
+ */
14
+ export declare function createUrlMinifier(site: string): (url: string) => string;
15
+ //# sourceMappingURL=urls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"urls.d.ts","sourceRoot":"","sources":["../../../src/lib/urls.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAqEH;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAH3B,MAG2B,GAFzB,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAkEnC"}
@@ -0,0 +1,132 @@
1
+ /**
2
+ * General utility functions
3
+ */
4
+ /**
5
+ * Stringify with sorted keys, for cache keys—values that can behave differently must not
6
+ * stringify alike, so unquoted markers stand in for what JSON cannot express
7
+ * @param {unknown} obj
8
+ * @returns {string}
9
+ */
10
+ declare function stableStringify(obj: unknown): string;
11
+ declare class LRU {
12
+ limit: number;
13
+ gets: number;
14
+ hits: number;
15
+ /** @type {Map<string, unknown>} */
16
+ map: Map<string, unknown>;
17
+ constructor(limit?: number);
18
+ /** @param {string} key */
19
+ get(key: string): unknown;
20
+ /**
21
+ * @param {string} key
22
+ * @param {unknown} value
23
+ */
24
+ set(key: string, value: unknown): void;
25
+ /** @param {string} key */
26
+ delete(key: string): void;
27
+ /** @returns {{ gets: number, hits: number, size: number, limit: number }} */
28
+ stats(): {
29
+ gets: number;
30
+ hits: number;
31
+ size: number;
32
+ limit: number;
33
+ };
34
+ }
35
+ declare const MAX_CACHE_ENTRY_SIZE: number;
36
+ /** @param {string} str */
37
+ declare function hashContent(str: string): string;
38
+ /** @param {string} value */
39
+ declare function uniqueId(value: string): string;
40
+ /**
41
+ * Write decoded text or an attribute value for an XML parser to read it the same
42
+ * @param {string} value - Text or attribute value, decoded
43
+ * @param {boolean} [attribute] - Whether the value is an attribute value
44
+ * @returns {string}
45
+ */
46
+ declare function escapeXML(value: string, attribute?: boolean): string;
47
+ /**
48
+ * Read text in foreign content as HTML does: CDATA sections hold text as written,
49
+ * while what surrounds them reads character references
50
+ * @param {string} text
51
+ * @param {(text: string) => string} decode - `decodeHTML`
52
+ * @returns {string}
53
+ */
54
+ declare function decodeForeignText(text: string, decode: (text: string) => string): string;
55
+ /** @param {string} value */
56
+ declare function identity(value: string): string;
57
+ /**
58
+ * @param {unknown} value
59
+ * @returns {value is PromiseLike<any>}
60
+ */
61
+ declare function isThenable(value: unknown): value is PromiseLike<any>;
62
+ /** @param {string} value */
63
+ declare function lowercase(value: string): string;
64
+ /** @param {string} value */
65
+ declare function paramCase(value: string): string;
66
+ /**
67
+ * Asynchronously replace matches in a string.
68
+ * @param {string} str - Input string
69
+ * @param {RegExp} regex - Regular expression with global flag
70
+ * @param {Function} asyncFn - Async function to process each match
71
+ * @returns {Promise<string>} Processed string
72
+ */
73
+ declare function replaceAsync(str: string, regex: RegExp, asyncFn: Function): Promise<string>;
74
+ /** @param {string | RegExp} value */
75
+ declare function parseRegExp(value: string | RegExp): RegExp | undefined;
76
+ /**
77
+ * Which flag changes what a source matches, so that embedding the source where the
78
+ * flag cannot follow would silently match something else. `u` and `v` only narrow
79
+ * what syntax is legal, so a source valid under either stays valid without it—the
80
+ * difference never surfaces as a syntax error, and this stands in for the one that
81
+ * would otherwise be raised.
82
+ * @param {RegExp} pattern
83
+ * @returns {'u' | 'v' | 'm' | null} The flag the source depends on, or `null` where
84
+ * every flag it carries would leave the source matching the same
85
+ */
86
+ declare function lostFlag(pattern: RegExp): 'u' | 'v' | 'm' | null;
87
+ /**
88
+ * A pattern’s source, rewritten to match the way its own flags make it match, for
89
+ * embedding in a larger regex that cannot carry them. `i` and `s` fit into a
90
+ * source; `m`, `u`, and `v` do not, and are left to the pattern it joins. Where
91
+ * `i` cannot be written in—a backreference, a range outside ASCII, a range that
92
+ * spans letters without being one—the source stands as it is, matching less than
93
+ * the pattern would rather than more.
94
+ * @param {RegExp} pattern
95
+ * @returns {string}
96
+ */
97
+ declare function embedSource(pattern: RegExp): string;
98
+ export type Repeat = {
99
+ text: string;
100
+ ranges: [number, number][] | null;
101
+ };
102
+ /**
103
+ * @param {RegExp | string} pattern - Pattern to judge, or a bare source to read
104
+ * as it stands
105
+ * @returns {string | null} What makes the pattern a backtracking risk, phrased
106
+ * to follow the pattern itself, or `null` where it is none
107
+ */
108
+ declare function describeQuantifierRisk(pattern: RegExp | string): string | null;
109
+ /**
110
+ * Find the index of the `>` that closes an opening tag, correctly skipping
111
+ * over quoted attribute values (which may contain `>`).
112
+ * @param {string} html
113
+ * @param {number} pos - Start position (just after the tag name)
114
+ * @param {number} [limit] - Position to stop the search at (exclusive)
115
+ * @returns {number} Index of the closing `>`, or -1 if not found
116
+ */
117
+ declare function findTagEnd(html: string, pos: number, limit?: number): number;
118
+ /**
119
+ * A package that resolves but fails to load—e.g., a native binding built for
120
+ * another platform—is not one another `npm install` fixes, so name what happened
121
+ * rather than the install command
122
+ *
123
+ * @param {string} label - Minifier name as it should read in the message
124
+ * @param {string} specifier - Package that failed to load
125
+ * @param {unknown} cause - Error the import rejected with
126
+ * @returns {string} Message describing the failure
127
+ */
128
+ declare function describeDependencyFailure(label: string, specifier: string, cause: unknown): string;
129
+ /** @param {string} doctype */
130
+ declare function isQuirksDoctype(doctype: string): boolean;
131
+ export { stableStringify, findTagEnd, LRU, MAX_CACHE_ENTRY_SIZE, hashContent, uniqueId, escapeXML, decodeForeignText, identity, isQuirksDoctype, isThenable, lowercase, paramCase, replaceAsync, parseRegExp, embedSource, lostFlag, describeQuantifierRisk, describeDependencyFailure };
132
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils.js"],"names":[],"mappings":"AAAA;;GAEG;AAoBH;;;;;GAKG;AACH,iBAAS,eAAe,CAAC,GAAG,EAHjB,OAGiB,GAFf,MAAM,CAgBlB;AAID,cAAM,GAAG;IAEA,KAAK;IACL,IAAI;IACJ,IAAI;IACT,mCAAmC;IAC9B,GAAG,EADG,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAJjC,YAAY,KAAK,SAAM,EAMtB;IACD,0BAA0B;IAC1B,GAAG,CAAC,GAAG,EADK,MACL,WAUN;IACD;;;OAGG;IACH,GAAG,CAAC,GAAG,EAHI,MAGJ,EAAE,KAAK,EAFH,OAEG,QAOb;IACD,0BAA0B;IAC1B,MAAM,CAAC,GAAG,EADE,MACF,QAA2B;IACrC,6EAA6E;IAC7E,KAAK,IADS;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAGxE;CACF;AAKD,QAAA,MAAM,oBAAoB,QAAc,CAAC;AAKzC,0BAA0B;AAC1B,iBAAS,WAAW,CAAC,GAAG,EADZ,MACY,UAWvB;AAED,4BAA4B;AAC5B,iBAAS,QAAQ,CAAC,KAAK,EADX,MACW,UAMtB;AAUD;;;;;GAKG;AACH,iBAAS,SAAS,CAAC,KAAK,EAJb,MAIa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a,EAAE,GAAG,EAJlB,MAIkB,EAAE,KAAK,AAHjC,CACA,EADQ,MAGuC,GAFrC,MAAM,CAelB;AAED;;;;;;;;;GASG;AACH,iBAAS,yBAAyB,CAAC,KAAK,EAL7B,MAK6B,EAAE,SAAS,EAJxC,MAIwC,EAAE,KAAK,EAH/C,OAG+C,GAF7C,MAAM,CAYlB;AAKD,8BAA8B;AAC9B,iBAAS,eAAe,CAAC,OAAO,EADpB,MACoB,WAc/B;AAED,OAAO,EACL,eAAe,EACf,UAAU,EACV,GAAG,EACH,oBAAoB,EACpB,WAAW,EACX,QAAQ,EACR,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,eAAe,EACf,UAAU,EACV,SAAS,EACT,SAAS,EACT,YAAY,EACZ,WAAW,EACX,WAAW,EACX,QAAQ,EACR,sBAAsB,EACtB,yBAAyB,EAC1B,CAAC"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Whitespace trimming and collapsing
3
+ */
4
+ /** @param {string} str */
5
+ declare const trimWhitespace: (str: string) => string;
6
+ /** @param {string} str */
7
+ declare function isAllWhitespace(str: string): boolean;
8
+ /** @param {string} str */
9
+ declare function endsWithWhitespace(str: string): boolean;
10
+ /** @param {string} str */
11
+ declare function collapseWhitespaceAll(str: string): string;
12
+ /**
13
+ * @param {string} str
14
+ * @param {{decodeEntities?: boolean | undefined, preserveLineBreaks?: boolean | undefined}} options
15
+ */
16
+ declare function collapseNoBreakSpaces(str: string, options: {
17
+ decodeEntities?: boolean | undefined;
18
+ preserveLineBreaks?: boolean | undefined;
19
+ }): string;
20
+ /**
21
+ * @param {string} str
22
+ * @param {{preserveLineBreaks?: boolean | undefined, conservativeCollapse?: boolean | undefined}} options
23
+ * @param {boolean} trimLeft
24
+ * @param {boolean} trimRight
25
+ * @param {boolean} [collapseAll]
26
+ * @param {boolean} [keepUntrimmed] - Whether a side not trimmed keeps its line breaks as written
27
+ */
28
+ declare function collapseWhitespace(str: string, options: {
29
+ preserveLineBreaks?: boolean | undefined;
30
+ conservativeCollapse?: boolean | undefined;
31
+ }, trimLeft: boolean, trimRight: boolean, collapseAll?: boolean, keepUntrimmed?: boolean): string;
32
+ export type InlineSets = {
33
+ /**
34
+ * - Elements whose surrounding whitespace is kept
35
+ */
36
+ around: Set<string>;
37
+ /**
38
+ * - The same, spelled as end tags
39
+ */
40
+ aroundEnd: Set<string>;
41
+ /**
42
+ * - Elements whose inner whitespace is kept
43
+ */
44
+ within: Set<string>;
45
+ /**
46
+ * - The same, spelled as end tags
47
+ */
48
+ withinEnd: Set<string>;
49
+ /**
50
+ * - `within` under both spellings
51
+ */
52
+ withinEither: Set<string>;
53
+ };
54
+ /**
55
+ * @typedef {object} InlineSets
56
+ * @prop {Set<string>} around - Elements whose surrounding whitespace is kept
57
+ * @prop {Set<string>} aroundEnd - The same, spelled as end tags
58
+ * @prop {Set<string>} within - Elements whose inner whitespace is kept
59
+ * @prop {Set<string>} withinEnd - The same, spelled as end tags
60
+ * @prop {Set<string>} withinEither - `within` under both spellings
61
+ */
62
+ /**
63
+ * Inline-element membership for the whitespace pass, each set paired with its end-tag
64
+ * spelling so a lookup takes the tag as it comes rather than slicing off the slash
65
+ * @param {Set<string>} around
66
+ * @param {Set<string>} within
67
+ * @returns {InlineSets}
68
+ */
69
+ declare function buildInlineSets(around: Set<string>, within: Set<string>): InlineSets;
70
+ declare const defaultInlineSets: InlineSets;
71
+ /**
72
+ * @param {string} str
73
+ * @param {string} prevTag
74
+ * @param {string} nextTag
75
+ * @param {Array<{name: string, value?: string}>} prevAttrs
76
+ * @param {Array<{name: string, value?: string}>} nextAttrs
77
+ * @param {{preserveLineBreaks?: boolean, conservativeCollapse?: boolean, collapseInlineTagWhitespace?: boolean}} options
78
+ * @param {InlineSets} inlineSets
79
+ * @param {boolean} [collapseInside] - False where `canCollapseWhitespace` keeps runs inside the text as they are
80
+ */
81
+ declare function collapseWhitespaceSmart(str: string, prevTag: string, nextTag: string, prevAttrs: Array<{
82
+ name: string;
83
+ value?: string;
84
+ }>, nextAttrs: Array<{
85
+ name: string;
86
+ value?: string;
87
+ }>, options: {
88
+ preserveLineBreaks?: boolean;
89
+ conservativeCollapse?: boolean;
90
+ collapseInlineTagWhitespace?: boolean;
91
+ }, inlineSets: InlineSets, collapseInside?: boolean): string;
92
+ /** @param {string} tag */
93
+ declare function canCollapseWhitespace(tag: string): boolean;
94
+ /** @param {string} tag */
95
+ declare function canTrimWhitespace(tag: string): boolean;
96
+ export { buildInlineSets, defaultInlineSets, endsWithWhitespace, trimWhitespace, collapseWhitespaceAll, collapseNoBreakSpaces, collapseWhitespace, collapseWhitespaceSmart, canCollapseWhitespace, canTrimWhitespace, isAllWhitespace };
97
+ //# sourceMappingURL=whitespace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"whitespace.d.ts","sourceRoot":"","sources":["../../../src/lib/whitespace.js"],"names":[],"mappings":"AAAA;;GAEG;AA4BH,0BAA0B;AAC1B,QAAA,MAAM,cAAc,QADR,MAAM,WAQjB,CAAC;AAcF,0BAA0B;AAC1B,iBAAS,eAAe,CAAC,GAAG,EADhB,MACgB,WAU3B;AAGD,0BAA0B;AAC1B,iBAAS,kBAAkB,CAAC,GAAG,EADnB,MACmB,WAE9B;AAUD,0BAA0B;AAC1B,iBAAS,qBAAqB,CAAC,GAAG,EADtB,MACsB,UAOjC;AAwCD;;;GAGG;AACH,iBAAS,qBAAqB,CAAC,GAAG,EAHvB,MAGuB,EAAE,OAAO,EAFhC;IAAC,cAAc,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAAC,kBAAkB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAE/C,UAW1C;AAID;;;;;;;GAOG;AACH,iBAAS,kBAAkB,CAAC,GAAG,EAPpB,MAOoB,EAAE,OAAO,EAN7B;IAAC,kBAAkB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAAC,oBAAoB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAMxD,EAAE,QAAQ,EAL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EADtB,MACsB,WAEjC;AAED,0BAA0B;AAC1B,iBAAS,iBAAiB,CAAC,GAAG,EADlB,MACkB,WAE7B;AAED,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,uBAAuB,EACvB,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EAChB,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Preset configurations
3
+ *
4
+ * Presets provide curated option sets for common use cases:
5
+ * - `conservative`: Safe minification suitable for most projects
6
+ * - `comprehensive`: Aggressive minification for maximum file size reduction
7
+ */
8
+ export declare const presets: {
9
+ conservative: {
10
+ caseSensitive: boolean;
11
+ collapseBooleanAttributes: boolean;
12
+ collapseWhitespace: boolean;
13
+ conservativeCollapse: boolean;
14
+ preserveLineBreaks: boolean;
15
+ removeComments: boolean;
16
+ removeDefaultTypeAttributes: boolean;
17
+ useShortDoctype: boolean;
18
+ };
19
+ comprehensive: {
20
+ collapseAttributeWhitespace: boolean;
21
+ collapseBooleanAttributes: boolean;
22
+ collapseEmptyAttributes: boolean;
23
+ collapseWhitespace: boolean;
24
+ decodeEntities: boolean;
25
+ mergeScripts: boolean;
26
+ minifyCSS: boolean;
27
+ minifyJS: boolean;
28
+ minifyJSON: boolean;
29
+ minifySVG: boolean;
30
+ minifyURLs: boolean;
31
+ removeAttributeQuotes: boolean;
32
+ removeComments: boolean;
33
+ removeDefaultTypeAttributes: boolean;
34
+ removeEmptyAttributes: boolean;
35
+ removeOptionalTags: boolean;
36
+ removeRedundantAttributes: boolean;
37
+ selfCloseForeignElements: boolean;
38
+ useShortDoctype: boolean;
39
+ };
40
+ };
41
+ /**
42
+ * @param {string} name - Preset name (“conservative” or “comprehensive”)
43
+ * @returns {object|null} Preset options object or null if not found
44
+ */
45
+ export declare function getPreset(name: string): object | null;
46
+ /**
47
+ * @returns {string[]} Array of preset names
48
+ */
49
+ export declare function getPresetNames(): string[];
50
+ //# sourceMappingURL=presets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presets.d.ts","sourceRoot":"","sources":["../../src/presets.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,OAAO;IAClB,YAAY;QACV,aAAa;QACb,yBAAyB;QACzB,kBAAkB;QAClB,oBAAoB;QACpB,kBAAkB;QAClB,cAAc;QACd,2BAA2B;QAC3B,eAAe;;IAEjB,aAAa;QACX,2BAA2B;QAC3B,yBAAyB;QACzB,uBAAuB;QACvB,kBAAkB;QAClB,cAAc;QACd,YAAY;QACZ,SAAS;QACT,QAAQ;QACR,UAAU;QACV,SAAS;QACT,UAAU;QACV,qBAAqB;QACrB,cAAc;QACd,2BAA2B;QAC3B,qBAAqB;QACrB,kBAAkB;QAClB,yBAAyB;QACzB,wBAAwB;QACxB,eAAe;;CAElB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAHnB,MAGmB,GAFjB,MAAM,GAAC,IAAI,CAMvB;AAED;;GAEG;AACH,wBAAgB,cAAc,IAFjB,MAAM,EAAE,CAIpB"}
@@ -0,0 +1,36 @@
1
+ declare class Sorter {
2
+ /** @type {Map<string, number>} */
3
+ rank: Map<string, number>;
4
+ /** @type {Map<string, Sorter | (() => Sorter)>} */
5
+ sorterMap: Map<string, Sorter | (() => Sorter)>;
6
+ constructor();
7
+ /** @param {string} token */
8
+ child(token: string): Sorter | undefined;
9
+ /**
10
+ * @param {string[]} tokens
11
+ * @param {number} fromIndex
12
+ * @returns {string[]}
13
+ */
14
+ sort(tokens: string[], fromIndex?: number): string[];
15
+ }
16
+ declare class TokenChain {
17
+ /** @type {Map<string, {lists: Map<string, {tokens: string[], weight: number}>, count: number, processed: number}>} */
18
+ map: Map<string, {
19
+ lists: Map<string, {
20
+ tokens: string[];
21
+ weight: number;
22
+ }>;
23
+ count: number;
24
+ processed: number;
25
+ }>;
26
+ constructor();
27
+ /**
28
+ * @param {string[]} tokens
29
+ * @param {number} [weight]
30
+ */
31
+ add(tokens: string[], weight?: number): void;
32
+ /** @param {Map<string, number>} [localeRanks] */
33
+ createSorter(localeRanks?: Map<string, number>): Sorter;
34
+ }
35
+ export default TokenChain;
36
+ //# sourceMappingURL=tokenchain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenchain.d.ts","sourceRoot":"","sources":["../../src/tokenchain.js"],"names":[],"mappings":"AAAA,cAAM,MAAM;IAIR,kCAAkC;IAC7B,IAAI,EADE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IAE9B,mDAAmD;IAC9C,SAAS,EADH,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;IALjD,cAOC;IAED,4BAA4B;IAC5B,KAAK,CAAC,KAAK,EADC,MACD,sBAQV;IAED;;;;OAIG;IACH,IAAI,CAAC,MAAM,EAJA,MAAM,EAIN,EAAE,SAAS,GAHX,MAGe,GAFb,MAAM,EAAE,CAsCpB;CACF;AAID,cAAM,UAAU;IAGZ,sHAAsH;IACjH,GAAG,EADG,GAAG,CAAC,MAAM,EAAE;QAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE;YAAC,MAAM,EAAE,MAAM,EAAE,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAC,CAAC,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAC,CAAC;IAFpH,cAIC;IAED;;;OAGG;IACH,GAAG,CAAC,MAAM,EAHC,MAAM,EAGP,EAAE,MAAM,AAFf,CAAwB,EAAhB,MAEW,QAiBrB;IAED,iDAAiD;IACjD,YAAY,CAAC,WAAW,AADpB,CAA0C,EAAlC,GAAG,CAAC,MAAM,EAAE,MAAM,CACN,UAuDvB;CACF;eAEc,UAAU"}