@ohos-ports/html-minifier-next 8.4.2-beta.0

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 (51) hide show
  1. package/LICENSE.txt +23 -0
  2. package/README.md +776 -0
  3. package/cli.js +1209 -0
  4. package/dist/types/htmlminifier.d.ts +556 -0
  5. package/dist/types/htmlminifier.d.ts.map +1 -0
  6. package/dist/types/htmlparser.d.ts +25 -0
  7. package/dist/types/htmlparser.d.ts.map +1 -0
  8. package/dist/types/lib/attributes.d.ts +155 -0
  9. package/dist/types/lib/attributes.d.ts.map +1 -0
  10. package/dist/types/lib/constants.d.ts +110 -0
  11. package/dist/types/lib/constants.d.ts.map +1 -0
  12. package/dist/types/lib/content.d.ts +51 -0
  13. package/dist/types/lib/content.d.ts.map +1 -0
  14. package/dist/types/lib/elements.d.ts +57 -0
  15. package/dist/types/lib/elements.d.ts.map +1 -0
  16. package/dist/types/lib/fragments.d.ts +46 -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 +120 -0
  21. package/dist/types/lib/options.d.ts.map +1 -0
  22. package/dist/types/lib/unused-css.d.ts +46 -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 +102 -0
  27. package/dist/types/lib/utils.d.ts.map +1 -0
  28. package/dist/types/lib/whitespace.d.ts +45 -0
  29. package/dist/types/lib/whitespace.d.ts.map +1 -0
  30. package/dist/types/presets.d.ts +49 -0
  31. package/dist/types/presets.d.ts.map +1 -0
  32. package/dist/types/tokenchain.d.ts +26 -0
  33. package/dist/types/tokenchain.d.ts.map +1 -0
  34. package/html-minifier-next.schema.json +306 -0
  35. package/package.json +100 -0
  36. package/src/htmlminifier.js +2294 -0
  37. package/src/htmlparser.js +1069 -0
  38. package/src/lib/attributes.js +928 -0
  39. package/src/lib/constants.js +285 -0
  40. package/src/lib/content.js +190 -0
  41. package/src/lib/elements.js +274 -0
  42. package/src/lib/file-pool.js +177 -0
  43. package/src/lib/fragments.js +274 -0
  44. package/src/lib/option-definitions.js +231 -0
  45. package/src/lib/options.js +730 -0
  46. package/src/lib/unused-css.js +379 -0
  47. package/src/lib/urls.js +155 -0
  48. package/src/lib/utils.js +861 -0
  49. package/src/lib/whitespace.js +321 -0
  50. package/src/presets.js +57 -0
  51. package/src/tokenchain.js +123 -0
@@ -0,0 +1,46 @@
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
16
+ * @returns {Set<string>} Symbols to keep
17
+ */
18
+ declare function collectUsedSymbols(html: string, includeScripts: boolean, decode?: ((text: string) => string)): Set<string>;
19
+ /**
20
+ * Determine which class/ID symbols a style sheet defines but the document never references.
21
+ * @param {string} css - Style sheet contents
22
+ * @param {Set<string>} used - Symbols the document references
23
+ * @param {Array<string | RegExp>} safelist - Symbols to keep regardless
24
+ * @returns {string[]} Symbols safe to remove
25
+ */
26
+ declare function findUnusedSymbols(css: string, used: Set<string>, safelist: Array<string | RegExp>): string[];
27
+ /**
28
+ * Normalize the `removeUnusedCSS` option into a settled configuration.
29
+ *
30
+ * A misspelled key or a safelist that is not an array would otherwise protect
31
+ * nothing, and that only surfaces as a missing rule much later—so every value
32
+ * that gets dropped is reported.
33
+ *
34
+ * @param {boolean | {safelist?: Array<string | RegExp>, scripts?: boolean} | undefined} option
35
+ * @param {(message: string) => unknown} [warn] - Receives one message per ignored value
36
+ * @returns {{safelist: Array<string | RegExp>, scripts: boolean} | null} Null when disabled
37
+ */
38
+ declare function normalizeUnusedCSSOptions(option: boolean | {
39
+ safelist?: Array<string | RegExp>;
40
+ scripts?: boolean;
41
+ } | undefined, warn?: (message: string) => unknown): {
42
+ safelist: Array<string | RegExp>;
43
+ scripts: boolean;
44
+ } | null;
45
+ export { collectUsedSymbols, findUnusedSymbols, normalizeUnusedCSSOptions };
46
+ //# 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;AAwKH;;;;;;;;;;;;;GAaG;AACH,iBAAS,kBAAkB,CAAC,IAAI,EALrB,MAKqB,EAAE,cAAc,EAJrC,OAIqC,EAAE,MAAM,AAHrD,CACA,EADQ,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAGoB,GAF3C,GAAG,CAAC,MAAM,CAAC,CA0FvB;AAED;;;;;;GAMG;AACH,iBAAS,iBAAiB,CAAC,GAAG,EALnB,MAKmB,EAAE,IAAI,EAJzB,GAAG,CAAC,MAAM,CAIe,EAAE,QAAQ,EAHnC,KAAK,CAAC,MAAM,GAAG,MAAM,CAGc,GAFjC,MAAM,EAAE,CAuCpB;AAID;;;;;;;;;;GAUG;AACH,iBAAS,yBAAyB,CAAC,MAAM,EAJ9B,OAAO,GAAG;IAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IAAC,OAAO,CAAC,EAAE,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,kBAAkB,EAClB,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;AAuEH;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAH3B,MAG2B,GAFzB,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAyEnC"}
@@ -0,0 +1,102 @@
1
+ /**
2
+ * General utility functions
3
+ */
4
+ /**
5
+ * @param {unknown} obj
6
+ * @returns {string}
7
+ */
8
+ declare function stableStringify(obj: unknown): string;
9
+ declare class LRU {
10
+ limit: number;
11
+ gets: number;
12
+ hits: number;
13
+ /** @type {Map<string, unknown>} */
14
+ map: Map<string, unknown>;
15
+ constructor(limit?: number);
16
+ /** @param {string} key */
17
+ get(key: string): unknown;
18
+ /**
19
+ * @param {string} key
20
+ * @param {unknown} value
21
+ */
22
+ set(key: string, value: unknown): void;
23
+ /** @param {string} key */
24
+ delete(key: string): void;
25
+ /** @returns {{ gets: number, hits: number, size: number, limit: number }} */
26
+ stats(): {
27
+ gets: number;
28
+ hits: number;
29
+ size: number;
30
+ limit: number;
31
+ };
32
+ }
33
+ declare const MAX_CACHE_ENTRY_SIZE: number;
34
+ /** @param {string} str */
35
+ declare function hashContent(str: string): string;
36
+ /** @param {string} value */
37
+ declare function uniqueId(value: string): string;
38
+ /** @param {string} value */
39
+ declare function identity(value: string): string;
40
+ /**
41
+ * @param {unknown} value
42
+ * @returns {value is PromiseLike<any>}
43
+ */
44
+ declare function isThenable(value: unknown): value is PromiseLike<any>;
45
+ /** @param {string} value */
46
+ declare function lowercase(value: string): string;
47
+ /** @param {string} value */
48
+ declare function paramCase(value: string): string;
49
+ /**
50
+ * Asynchronously replace matches in a string.
51
+ * @param {string} str - Input string
52
+ * @param {RegExp} regex - Regular expression with global flag
53
+ * @param {Function} asyncFn - Async function to process each match
54
+ * @returns {Promise<string>} Processed string
55
+ */
56
+ declare function replaceAsync(str: string, regex: RegExp, asyncFn: Function): Promise<string>;
57
+ /** @param {string | RegExp} value */
58
+ declare function parseRegExp(value: string | RegExp): RegExp | undefined;
59
+ /**
60
+ * Which flag changes what a source matches, so that embedding the source where the
61
+ * flag cannot follow would silently match something else. `u` and `v` only narrow
62
+ * what syntax is legal, so a source valid under either stays valid without it—the
63
+ * difference never surfaces as a syntax error, and this stands in for the one that
64
+ * would otherwise be raised.
65
+ * @param {RegExp} pattern
66
+ * @returns {'u' | 'v' | 'm' | null} The flag the source depends on, or `null` where
67
+ * every flag it carries would leave the source matching the same
68
+ */
69
+ declare function lostFlag(pattern: RegExp): 'u' | 'v' | 'm' | null;
70
+ /**
71
+ * A pattern’s source, rewritten to match the way its own flags make it match, for
72
+ * embedding in a larger regex that cannot carry them. `i` and `s` fit into a
73
+ * source; `m`, `u`, and `v` do not, and are left to the pattern it joins. Where
74
+ * `i` cannot be written in—a backreference, a range outside ASCII, a range that
75
+ * spans letters without being one—the source stands as it is, matching less than
76
+ * the pattern would rather than more.
77
+ * @param {RegExp} pattern
78
+ * @returns {string}
79
+ */
80
+ declare function embedSource(pattern: RegExp): string;
81
+ export type Repeat = {
82
+ text: string;
83
+ ranges: [number, number][] | null;
84
+ };
85
+ /**
86
+ * @param {RegExp | string} pattern - Pattern to judge, or a bare source to read
87
+ * as it stands
88
+ * @returns {string | null} What makes the pattern a backtracking risk, phrased
89
+ * to follow the pattern itself, or `null` where it is none
90
+ */
91
+ declare function describeQuantifierRisk(pattern: RegExp | string): string | null;
92
+ /**
93
+ * Find the index of the `>` that closes an opening tag, correctly skipping
94
+ * over quoted attribute values (which may contain `>`).
95
+ * @param {string} html
96
+ * @param {number} pos - Start position (just after the tag name)
97
+ * @param {number} [limit] - Position to stop the search at (exclusive)
98
+ * @returns {number} Index of the closing `>`, or -1 if not found
99
+ */
100
+ declare function findTagEnd(html: string, pos: number, limit?: number): number;
101
+ export { stableStringify, findTagEnd, LRU, MAX_CACHE_ENTRY_SIZE, hashContent, uniqueId, identity, isThenable, lowercase, paramCase, replaceAsync, parseRegExp, embedSource, lostFlag, describeQuantifierRisk };
102
+ //# 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;AAEH;;;GAGG;AACH,iBAAS,eAAe,CAAC,GAAG,EAHjB,OAGiB,GAFf,MAAM,CAYlB;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;AAIzC,0BAA0B;AAC1B,iBAAS,WAAW,CAAC,GAAG,EADZ,MACY,UAOvB;AAID,4BAA4B;AAC5B,iBAAS,QAAQ,CAAC,KAAK,EADX,MACW,UAMtB;AAID,4BAA4B;AAC5B,iBAAS,QAAQ,CAAC,KAAK,EADX,MACW,UAEtB;AAED;;;GAGG;AACH,iBAAS,UAAU,CAAC,KAAK,EAHd,OAGc,GAFZ,KAAK,IAAI,WAAW,CAAC,GAAG,CAAC,CAIrC;AAED,4BAA4B;AAC5B,iBAAS,SAAS,CAAC,KAAK,EADZ,MACY,UAEvB;AAGD,4BAA4B;AAC5B,iBAAS,SAAS,CAAC,KAAK,EADZ,MACY,UAEvB;AAID;;;;;;GAMG;AACH,iBAAe,YAAY,CAAC,GAAG,EALpB,MAKoB,EAAE,KAAK,EAJ3B,MAI2B,EAAE,OAAO,UAAA,GAFlC,OAAO,CAAC,MAAM,CAAC,CAe3B;AAID,qCAAqC;AACrC,iBAAS,WAAW,CAAC,KAAK,EADd,MAAM,GAAG,MACK,sBAUzB;AAyYD;;;;;;;;;GASG;AACH,iBAAS,QAAQ,CAAC,OAAO,EAJd,MAIc,GAHZ,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,CAqDlC;AAED;;;;;;;;;GASG;AACH,iBAAS,WAAW,CAAC,OAAO,EAHjB,MAGiB,GAFf,MAAM,CAOlB;AAGE,YAA6D,MAAM,GAAzD;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,IAAI,CAAA;CAAC,CAE7D;AAqKD;;;;;GAKG;AACH,iBAAS,sBAAsB,CAAC,OAAO,EAL5B,MAAM,GAAG,MAKmB,GAH1B,MAAM,GAAG,IAAI,CAqBzB;AAED;;;;;;;GAOG;AACH,iBAAS,UAAU,CAAC,IAAI,EALb,MAKa,EAAE,GAAG,EAJlB,MAIkB,EAAE,KAAK,AAHjC,CACA,EADQ,MAGuC,GAFrC,MAAM,CAelB;AAID,OAAO,EACL,eAAe,EACf,UAAU,EACV,GAAG,EACH,oBAAoB,EACpB,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,SAAS,EACT,SAAS,EACT,YAAY,EACZ,WAAW,EACX,WAAW,EACX,QAAQ,EACR,sBAAsB,EACvB,CAAC"}
@@ -0,0 +1,45 @@
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 collapseWhitespaceAll(str: string): string;
8
+ /**
9
+ * @param {string} str
10
+ * @param {{preserveLineBreaks?: boolean | undefined, conservativeCollapse?: boolean | undefined}} options
11
+ * @param {boolean} trimLeft
12
+ * @param {boolean} trimRight
13
+ * @param {boolean} [collapseAll]
14
+ */
15
+ declare function collapseWhitespace(str: string, options: {
16
+ preserveLineBreaks?: boolean | undefined;
17
+ conservativeCollapse?: boolean | undefined;
18
+ }, trimLeft: boolean, trimRight: boolean, collapseAll?: boolean): string;
19
+ /**
20
+ * @param {string} str
21
+ * @param {string} prevTag
22
+ * @param {string} nextTag
23
+ * @param {Array<{name: string, value?: string}>} prevAttrs
24
+ * @param {Array<{name: string, value?: string}>} nextAttrs
25
+ * @param {{preserveLineBreaks?: boolean, conservativeCollapse?: boolean, collapseInlineTagWhitespace?: boolean}} options
26
+ * @param {Set<string>} inlineElements
27
+ * @param {Set<string>} inlineTextSet
28
+ */
29
+ declare function collapseWhitespaceSmart(str: string, prevTag: string, nextTag: string, prevAttrs: Array<{
30
+ name: string;
31
+ value?: string;
32
+ }>, nextAttrs: Array<{
33
+ name: string;
34
+ value?: string;
35
+ }>, options: {
36
+ preserveLineBreaks?: boolean;
37
+ conservativeCollapse?: boolean;
38
+ collapseInlineTagWhitespace?: boolean;
39
+ }, inlineElements: Set<string>, inlineTextSet: Set<string>): string;
40
+ /** @param {string} tag */
41
+ declare function canCollapseWhitespace(tag: string): boolean;
42
+ /** @param {string} tag */
43
+ declare function canTrimWhitespace(tag: string): boolean;
44
+ export { trimWhitespace, collapseWhitespaceAll, collapseWhitespace, collapseWhitespaceSmart, canCollapseWhitespace, canTrimWhitespace };
45
+ //# 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;AAqBH,0BAA0B;AAC1B,QAAA,MAAM,cAAc,QADR,MAAM,WAQjB,CAAC;AAuBF,0BAA0B;AAC1B,iBAAS,qBAAqB,CAAC,GAAG,EADtB,MACsB,UAOjC;AAeD;;;;;;GAMG;AACH,iBAAS,kBAAkB,CAAC,GAAG,EANpB,MAMoB,EAAE,OAAO,EAL7B;IAAC,kBAAkB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAAC,oBAAoB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAKxD,EAAE,QAAQ,EAJvC,OAIuC,EAAE,SAAS,EAHlD,OAGkD,EAAE,WAAW,AAFvE,CAA8B,EAAtB,OAEuE,UAcjF;AAsHD;;;;;;;;;GASG;AACH,iBAAS,uBAAuB,CAAC,GAAG,EATzB,MASyB,EAAE,OAAO,EARlC,MAQkC,EAAE,OAAO,EAP3C,MAO2C,EAAE,SAAS,EANtD,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAC,CAMkB,EAAE,SAAS,EALjE,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAC,CAK6B,EAAE,OAAO,EAJ1E;IAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAAC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAAC,2BAA2B,CAAC,EAAE,OAAO,CAAA;CAI1B,EAAE,cAAc,EAH1F,GAAG,CAAC,MAAM,CAGgF,EAAE,aAAa,EAFzG,GAAG,CAAC,MAAM,CAE+F,UA6DnH;AAcD,0BAA0B;AAC1B,iBAAS,qBAAqB,CAAC,GAAG,EADtB,MACsB,WAEjC;AAED,0BAA0B;AAC1B,iBAAS,iBAAiB,CAAC,GAAG,EADlB,MACkB,WAE7B;AAID,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EAClB,uBAAuB,EACvB,qBAAqB,EACrB,iBAAiB,EAClB,CAAC"}
@@ -0,0 +1,49 @@
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
+ collapseWhitespace: boolean;
23
+ decodeEntities: boolean;
24
+ mergeScripts: boolean;
25
+ minifyCSS: boolean;
26
+ minifyJS: boolean;
27
+ minifySVG: boolean;
28
+ minifyURLs: boolean;
29
+ removeAttributeQuotes: boolean;
30
+ removeComments: boolean;
31
+ removeDefaultTypeAttributes: boolean;
32
+ removeEmptyAttributes: boolean;
33
+ removeOptionalTags: boolean;
34
+ removeRedundantAttributes: boolean;
35
+ useShortDoctype: boolean;
36
+ };
37
+ };
38
+ /**
39
+ * Get preset configuration by name.
40
+ * @param {string} name - Preset name (“conservative” or “comprehensive”)
41
+ * @returns {object|null} Preset options object or null if not found
42
+ */
43
+ export declare function getPreset(name: string): object | null;
44
+ /**
45
+ * Get list of available preset names
46
+ * @returns {string[]} Array of preset names
47
+ */
48
+ export declare function getPresetNames(): string[];
49
+ //# 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,kBAAkB;QAClB,cAAc;QACd,YAAY;QACZ,SAAS;QACT,QAAQ;QACR,SAAS;QACT,UAAU;QACV,qBAAqB;QACrB,cAAc;QACd,2BAA2B;QAC3B,qBAAqB;QACrB,kBAAkB;QAClB,yBAAyB;QACzB,eAAe;;CAElB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAHnB,MAGmB,GAFjB,MAAM,GAAC,IAAI,CAMvB;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAFjB,MAAM,EAAE,CAIpB"}
@@ -0,0 +1,26 @@
1
+ declare class Sorter {
2
+ /** @type {Map<string, number>} */
3
+ rank: Map<string, number>;
4
+ /** @type {Map<string, Sorter>} */
5
+ sorterMap: Map<string, Sorter>;
6
+ constructor();
7
+ /**
8
+ * @param {string[]} tokens
9
+ * @param {number} fromIndex
10
+ * @returns {string[]}
11
+ */
12
+ sort(tokens: string[], fromIndex?: number): string[];
13
+ }
14
+ declare class TokenChain {
15
+ /** @type {Map<string, {arrays: string[][], processed: number}>} */
16
+ map: Map<string, {
17
+ arrays: string[][];
18
+ processed: number;
19
+ }>;
20
+ constructor();
21
+ /** @param {string[]} tokens */
22
+ add(tokens: string[]): void;
23
+ createSorter(): Sorter;
24
+ }
25
+ export default TokenChain;
26
+ //# 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,kCAAkC;IAC7B,SAAS,EADH,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;IALhC,cAOC;IAED;;;;OAIG;IACH,IAAI,CAAC,MAAM,EAJA,MAAM,EAIN,EAAE,SAAS,GAHX,MAGe,GAFb,MAAM,EAAE,CAsCpB;CACF;AAED,cAAM,UAAU;IAEZ,mEAAmE;IAC9D,GAAG,EADG,GAAG,CAAC,MAAM,EAAE;QAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAC,CAAC;IADjE,cAGC;IAED,+BAA+B;IAC/B,GAAG,CAAC,MAAM,EADE,MAAM,EACR,QAST;IAED,YAAY,WA+CX;CACF;eAEc,UAAU"}
@@ -0,0 +1,306 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://raw.githubusercontent.com/j9t/html-minifier-next/main/html-minifier-next.schema.json",
4
+ "title": "HTML Minifier Next configuration",
5
+ "description": "Configuration file for HTML Minifier Next (HMN), used via `--config-file`",
6
+ "type": "object",
7
+ "properties": {
8
+ "$schema": {
9
+ "description": "JSON Schema reference for this configuration file (enables editor validation and autocomplete)",
10
+ "type": "string"
11
+ },
12
+ "preset": {
13
+ "description": "Preset configuration to start from—config file options override preset options",
14
+ "enum": [
15
+ "conservative",
16
+ "comprehensive"
17
+ ]
18
+ },
19
+ "fileExt": {
20
+ "description": "File extension(s) to process, as comma-separated string or array (default: `html,htm,shtml,shtm`; use `*` for all files)",
21
+ "type": [
22
+ "string",
23
+ "array"
24
+ ],
25
+ "items": {
26
+ "type": "string"
27
+ }
28
+ },
29
+ "ignoreDir": {
30
+ "description": "Directories—relative to the input directory—to exclude from processing, as comma-separated string or array",
31
+ "type": [
32
+ "string",
33
+ "array"
34
+ ],
35
+ "items": {
36
+ "type": "string"
37
+ }
38
+ },
39
+ "cacheCSS": {
40
+ "description": "Set CSS minification cache size (number of entries, default: 500)",
41
+ "type": "integer",
42
+ "minimum": 0
43
+ },
44
+ "cacheJS": {
45
+ "description": "Set JavaScript minification cache size (number of entries, default: 500)",
46
+ "type": "integer",
47
+ "minimum": 0
48
+ },
49
+ "cacheSVG": {
50
+ "description": "Set SVG minification cache size (number of entries, default: 500)",
51
+ "type": "integer",
52
+ "minimum": 0
53
+ },
54
+ "caseSensitive": {
55
+ "description": "Treat attributes in case-sensitive manner (useful for custom HTML elements)",
56
+ "type": "boolean"
57
+ },
58
+ "collapseAttributeWhitespace": {
59
+ "description": "Trim and collapse whitespace characters within attribute values",
60
+ "type": "boolean"
61
+ },
62
+ "collapseBooleanAttributes": {
63
+ "description": "Omit attribute values from boolean attributes",
64
+ "type": "boolean"
65
+ },
66
+ "collapseInlineTagWhitespace": {
67
+ "description": "Collapse whitespace more aggressively between inline elements—use with `--collapse-whitespace`",
68
+ "type": "boolean"
69
+ },
70
+ "collapseWhitespace": {
71
+ "description": "Collapse whitespace that contributes to text nodes in a document tree",
72
+ "type": "boolean"
73
+ },
74
+ "conservativeCollapse": {
75
+ "description": "Always collapse to one space (never remove it entirely)—use with `--collapse-whitespace`",
76
+ "type": "boolean"
77
+ },
78
+ "continueOnMinifyError": {
79
+ "description": "Continue on minification errors",
80
+ "type": "boolean"
81
+ },
82
+ "continueOnParseError": {
83
+ "description": "Handle parse errors instead of aborting",
84
+ "type": "boolean"
85
+ },
86
+ "customAttrAssign": {
87
+ "description": "Array of regexes that allow to support custom attribute assign expressions (e.g., `<div flex?=\"{{mode != cover}}\"></div>`)",
88
+ "type": [
89
+ "string",
90
+ "array"
91
+ ],
92
+ "items": {
93
+ "type": "string"
94
+ }
95
+ },
96
+ "customAttrCollapse": {
97
+ "description": "Regex that specifies custom attribute to strip newlines from (e.g., `/ng-class/`)",
98
+ "type": "string"
99
+ },
100
+ "customAttrSurround": {
101
+ "description": "Array of regexes that allow to support custom attribute surround expressions (e.g., `<input {{#if value}}checked=\"checked\"{{/if}}>`)",
102
+ "type": [
103
+ "string",
104
+ "array"
105
+ ],
106
+ "items": {
107
+ "type": "string"
108
+ }
109
+ },
110
+ "customEventAttributes": {
111
+ "description": "Array of regexes that allow to support custom event attributes (e.g., `ng-click`)—use with `--minify-js`",
112
+ "type": [
113
+ "string",
114
+ "array"
115
+ ],
116
+ "items": {
117
+ "type": "string"
118
+ }
119
+ },
120
+ "decodeEntities": {
121
+ "description": "Use direct Unicode characters whenever possible",
122
+ "type": "boolean"
123
+ },
124
+ "ignoreCustomComments": {
125
+ "description": "Array of regexes that allow to ignore matching comments",
126
+ "type": [
127
+ "string",
128
+ "array"
129
+ ],
130
+ "items": {
131
+ "type": "string"
132
+ }
133
+ },
134
+ "ignoreCustomFragments": {
135
+ "description": "Array of regexes that allow to ignore certain fragments, when matched (e.g., `<?php … ?>`, `{{ … }}`)",
136
+ "type": [
137
+ "string",
138
+ "array"
139
+ ],
140
+ "items": {
141
+ "type": "string"
142
+ }
143
+ },
144
+ "includeAutoGeneratedTags": {
145
+ "description": "Insert elements generated by HTML parser",
146
+ "type": "boolean"
147
+ },
148
+ "inlineCustomElements": {
149
+ "description": "Array of names of custom elements which are inline, for whitespace handling—use with `--collapse-whitespace`",
150
+ "type": [
151
+ "string",
152
+ "array"
153
+ ],
154
+ "items": {
155
+ "type": "string"
156
+ }
157
+ },
158
+ "keepClosingSlash": {
159
+ "description": "Keep the trailing slash on void elements and other start tags that carry one, and read it as closing the element",
160
+ "type": "boolean"
161
+ },
162
+ "maxInputLength": {
163
+ "description": "Maximum input length to prevent ReDoS attacks",
164
+ "type": "integer",
165
+ "minimum": 0
166
+ },
167
+ "maxLineLength": {
168
+ "description": "Specify a maximum line length; compressed output will be split by newlines at valid HTML split-points",
169
+ "type": "integer",
170
+ "minimum": 0
171
+ },
172
+ "mergeScripts": {
173
+ "description": "Merge consecutive inline `script` elements into one",
174
+ "type": "boolean"
175
+ },
176
+ "minifyCSS": {
177
+ "description": "Minify CSS in `style` elements and attributes (uses Lightning CSS)",
178
+ "type": [
179
+ "boolean",
180
+ "object"
181
+ ]
182
+ },
183
+ "minifyJS": {
184
+ "description": "Minify JavaScript in `script` elements and event attributes (uses Terser or SWC; pass `{\"engine\": \"swc\"}` for SWC)",
185
+ "type": [
186
+ "boolean",
187
+ "object"
188
+ ]
189
+ },
190
+ "minifySVG": {
191
+ "description": "Minify SVG elements (uses SVGO)",
192
+ "type": [
193
+ "boolean",
194
+ "object"
195
+ ]
196
+ },
197
+ "minifyURLs": {
198
+ "description": "Minify URLs in various attributes",
199
+ "type": [
200
+ "boolean",
201
+ "string",
202
+ "object"
203
+ ]
204
+ },
205
+ "noNewlinesBeforeTagClose": {
206
+ "description": "Never add a newline before a tag that closes an element—use with `--max-line-length`",
207
+ "type": "boolean"
208
+ },
209
+ "partialMarkup": {
210
+ "description": "Treat input as a partial HTML fragment, preserving stray end tags and unclosed tags",
211
+ "type": "boolean"
212
+ },
213
+ "preserveLineBreaks": {
214
+ "description": "Always collapse to one line break (never remove it entirely) when whitespace between tags includes a line break—use with `--collapse-whitespace`",
215
+ "type": "boolean"
216
+ },
217
+ "preventAttributesEscaping": {
218
+ "description": "Prevents the escaping of the values of attributes",
219
+ "type": "boolean"
220
+ },
221
+ "processScripts": {
222
+ "description": "Array of strings corresponding to types of `script` elements to process through minifier (e.g., `text/ng-template`, `text/x-handlebars-template`, etc.)",
223
+ "type": [
224
+ "string",
225
+ "array"
226
+ ],
227
+ "items": {
228
+ "type": "string"
229
+ }
230
+ },
231
+ "quoteCharacter": {
232
+ "description": "Type of quote to use for attribute values (`'` or `\"`)",
233
+ "type": "string"
234
+ },
235
+ "removeAttributeQuotes": {
236
+ "description": "Remove quotes around attributes when possible",
237
+ "type": "boolean"
238
+ },
239
+ "removeComments": {
240
+ "description": "Strip HTML comments",
241
+ "type": "boolean"
242
+ },
243
+ "removeDefaultTypeAttributes": {
244
+ "description": "Remove default `type` attributes from `style`/`link` (e.g., `type=\"text/css\"`) and `script` (e.g., `type=\"text/javascript\"`) elements; other `type` attribute values are left intact",
245
+ "type": "boolean"
246
+ },
247
+ "removeEmptyAttributes": {
248
+ "description": "Remove all attributes with whitespace-only values",
249
+ "type": "boolean"
250
+ },
251
+ "removeEmptyElements": {
252
+ "description": "Remove all elements with empty contents",
253
+ "type": "boolean"
254
+ },
255
+ "removeEmptyElementsExcept": {
256
+ "description": "Array of elements to preserve (e.g., `td`, `<span aria-hidden=\"true\">`)—use with `--remove-empty-elements`",
257
+ "type": [
258
+ "string",
259
+ "array"
260
+ ],
261
+ "items": {
262
+ "type": "string"
263
+ }
264
+ },
265
+ "removeOptionalTags": {
266
+ "description": "Remove optional tags",
267
+ "type": "boolean"
268
+ },
269
+ "removeRedundantAttributes": {
270
+ "description": "Remove attributes when value matches default",
271
+ "type": "boolean"
272
+ },
273
+ "removeTagWhitespace": {
274
+ "description": "Remove space between attributes whenever possible; note that this will result in invalid HTML",
275
+ "type": "boolean"
276
+ },
277
+ "removeUnusedCSS": {
278
+ "description": "Remove rules from `style` elements whose class or ID selectors the document never references—use with `--minify-css`; note that class names only applied by external scripts cannot be detected—use `{\"safelist\": […]}` for those",
279
+ "type": [
280
+ "boolean",
281
+ "object"
282
+ ]
283
+ },
284
+ "sortAttributes": {
285
+ "description": "Sort attributes by frequency",
286
+ "type": "boolean"
287
+ },
288
+ "sortClassNames": {
289
+ "description": "Sort style classes by frequency",
290
+ "type": "boolean"
291
+ },
292
+ "trimCustomFragments": {
293
+ "description": "Trim whitespace around custom fragments (`--ignore-custom-fragments`)—use with `--collapse-whitespace`",
294
+ "type": "boolean"
295
+ },
296
+ "strictCustomFragments": {
297
+ "description": "Reject `ignoreCustomFragments` patterns that risk catastrophic backtracking (rather than warning about them)",
298
+ "type": "boolean"
299
+ },
300
+ "useShortDoctype": {
301
+ "description": "Replaces the doctype with the short HTML doctype",
302
+ "type": "boolean"
303
+ }
304
+ },
305
+ "additionalProperties": false
306
+ }