html-minifier-next 7.5.3 → 8.0.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.
- package/README.md +60 -24
- package/cli.js +178 -55
- package/dist/types/htmlminifier.d.ts +24 -4
- package/dist/types/htmlminifier.d.ts.map +1 -1
- package/dist/types/lib/attributes.d.ts +2 -2
- package/dist/types/lib/attributes.d.ts.map +1 -1
- package/dist/types/lib/constants.d.ts +3 -2
- package/dist/types/lib/constants.d.ts.map +1 -1
- package/dist/types/lib/elements.d.ts +1 -1
- package/dist/types/lib/fragments.d.ts +46 -0
- package/dist/types/lib/fragments.d.ts.map +1 -0
- package/dist/types/lib/option-definitions.d.ts +21 -194
- package/dist/types/lib/option-definitions.d.ts.map +1 -1
- package/dist/types/lib/options.d.ts +33 -5
- package/dist/types/lib/options.d.ts.map +1 -1
- package/dist/types/lib/unused-css.d.ts +43 -0
- package/dist/types/lib/unused-css.d.ts.map +1 -0
- package/dist/types/lib/utils.d.ts +26 -1
- package/dist/types/lib/utils.d.ts.map +1 -1
- package/dist/types/tokenchain.d.ts +2 -2
- package/dist/types/tokenchain.d.ts.map +1 -1
- package/html-minifier-next.schema.json +11 -8
- package/package.json +2 -2
- package/src/htmlminifier.js +86 -88
- package/src/htmlparser.js +4 -4
- package/src/lib/attributes.js +65 -8
- package/src/lib/constants.js +8 -8
- package/src/lib/elements.js +3 -3
- package/src/lib/fragments.js +274 -0
- package/src/lib/option-definitions.js +19 -7
- package/src/lib/options.js +151 -28
- package/src/lib/unused-css.js +377 -0
- package/src/lib/utils.js +330 -2
- package/src/tokenchain.js +37 -30
|
@@ -119,7 +119,7 @@ declare function hasAttrName(name: string, attrs: HTMLAttribute[]): boolean;
|
|
|
119
119
|
* @param {HTMLAttribute[]} attrs
|
|
120
120
|
* @param {Function} minifyHTMLSelf
|
|
121
121
|
*/
|
|
122
|
-
declare function cleanAttributeValue(tag: string, attrName: string, attrValue: string, options: ProcessedOptions, attrs: HTMLAttribute[], minifyHTMLSelf: Function):
|
|
122
|
+
declare function cleanAttributeValue(tag: string, attrName: string, attrValue: string, options: ProcessedOptions, attrs: HTMLAttribute[], minifyHTMLSelf: Function): string | Promise<string>;
|
|
123
123
|
/**
|
|
124
124
|
* @param {HTMLAttribute} attr
|
|
125
125
|
* @param {HTMLAttribute[]} attrs
|
|
@@ -127,7 +127,7 @@ declare function cleanAttributeValue(tag: string, attrName: string, attrValue: s
|
|
|
127
127
|
* @param {ProcessedOptions} options
|
|
128
128
|
* @param {Function} minifyHTML
|
|
129
129
|
*/
|
|
130
|
-
declare function normalizeAttr(attr: HTMLAttribute, attrs: HTMLAttribute[], tag: string, options: ProcessedOptions, minifyHTML: Function):
|
|
130
|
+
declare function normalizeAttr(attr: HTMLAttribute, attrs: HTMLAttribute[], tag: string, options: ProcessedOptions, minifyHTML: Function): Promise<{
|
|
131
131
|
attr: HTMLAttribute;
|
|
132
132
|
name: string;
|
|
133
133
|
value: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../../src/lib/attributes.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../../src/lib/attributes.js"],"names":[],"mappings":"AAuBI,OAAQ,KAAA,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAKjD,YAA0I,aAAa,GAA7I;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAE1I;AAyBD;;;GAGG;AACH,iBAAS,gBAAgB,CAAC,IAAI,EAHnB,MAGmB,EAAE,OAAO,EAF5B,gBAE4B,WAOtC;AAED;;;GAGG;AACH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B;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,IAAI,EAAE,aAAa,CAAA;CAM3C,EAAE,aAAa,EALjC,MAAM,GAAG,OAAO,GAAG,SAKc,EAAE,OAAO,EAJ1C,gBAI0C,EAAE,MAAM,EAHlD,OAGkD,EAAE,OAAO,EAF3D,MAAM,GAAG,SAEkD,UAwHrE;AAID,OAAO,EAEL,gBAAgB,EAChB,gBAAgB,EAChB,wBAAwB,EACxB,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EAClB,wBAAwB,EACxB,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,uBAAuB,EACvB,uBAAuB,EACvB,WAAW,EAGX,mBAAmB,EACnB,aAAa,EACb,SAAS,EACT,qBAAqB,EACtB,CAAC"}
|
|
@@ -14,6 +14,8 @@ declare const RE_ESCAPE_LT: RegExp;
|
|
|
14
14
|
declare const RE_ATTR_WS_CHECK: RegExp;
|
|
15
15
|
declare const RE_ATTR_WS_COLLAPSE: RegExp;
|
|
16
16
|
declare const RE_ATTR_WS_TRIM: RegExp;
|
|
17
|
+
declare const RE_STYLE_ELEMENT: RegExp;
|
|
18
|
+
declare const RE_EMPTY_ATTRIBUTE: RegExp;
|
|
17
19
|
declare const inlineElementsToKeepWhitespaceAround: Set<string>;
|
|
18
20
|
declare const inlineElementsToKeepWhitespaceWithin: Set<string>;
|
|
19
21
|
declare const inlineElementsToKeepWhitespace: Set<string>;
|
|
@@ -92,7 +94,6 @@ declare const compactElements: Set<string>;
|
|
|
92
94
|
declare const looseElements: Set<string>;
|
|
93
95
|
declare const trailingElements: Set<string>;
|
|
94
96
|
declare const htmlElements: Set<string>;
|
|
95
|
-
declare const reEmptyAttribute: RegExp;
|
|
96
97
|
declare const specialContentElements: Set<string>;
|
|
97
|
-
export { RE_WS_START, RE_WS_END, RE_ALL_WS_NBSP, RE_NBSP_LEADING_GROUP, RE_NBSP_LEAD_GROUP, RE_NBSP_TRAILING_GROUP, RE_NBSP_TRAILING_STRIP, RE_EVENT_ATTR_DEFAULT, RE_CAN_REMOVE_ATTR_QUOTES, RE_TRAILING_SEMICOLON, RE_AMP_ENTITY, RE_LEGACY_ENTITIES, RE_ESCAPE_LT, RE_ATTR_WS_CHECK, RE_ATTR_WS_COLLAPSE, RE_ATTR_WS_TRIM, inlineElementsToKeepWhitespaceAround, inlineElementsToKeepWhitespaceWithin, inlineElementsToKeepWhitespace, formControlElements, generalDefaults, tagDefaults, executableScriptsMimetypes, keepScriptsMimetypes, jsonScriptTypes, isSimpleBoolean, isBooleanValue, collapsibleValues, srcsetElements, optionalStartTags, optionalEndTags, headerElements, descriptionElements, pBlockElements, pInlineElements, rubyEndTagOmission, rubyRtcEndTagOmission, optionElements, tableContentElements, tableSectionElements, cellElements, topLevelElements, compactElements, looseElements, trailingElements, htmlElements,
|
|
98
|
+
export { RE_WS_START, RE_WS_END, RE_ALL_WS_NBSP, RE_NBSP_LEADING_GROUP, RE_NBSP_LEAD_GROUP, RE_NBSP_TRAILING_GROUP, RE_NBSP_TRAILING_STRIP, RE_EVENT_ATTR_DEFAULT, RE_CAN_REMOVE_ATTR_QUOTES, RE_TRAILING_SEMICOLON, RE_AMP_ENTITY, RE_LEGACY_ENTITIES, RE_ESCAPE_LT, RE_ATTR_WS_CHECK, RE_ATTR_WS_COLLAPSE, RE_ATTR_WS_TRIM, RE_STYLE_ELEMENT, RE_EMPTY_ATTRIBUTE, inlineElementsToKeepWhitespaceAround, inlineElementsToKeepWhitespaceWithin, inlineElementsToKeepWhitespace, formControlElements, generalDefaults, tagDefaults, executableScriptsMimetypes, keepScriptsMimetypes, jsonScriptTypes, isSimpleBoolean, isBooleanValue, collapsibleValues, srcsetElements, optionalStartTags, optionalEndTags, headerElements, descriptionElements, pBlockElements, pInlineElements, rubyEndTagOmission, rubyRtcEndTagOmission, optionElements, tableContentElements, tableSectionElements, cellElements, topLevelElements, compactElements, looseElements, trailingElements, htmlElements, specialContentElements };
|
|
98
99
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/lib/constants.js"],"names":[],"mappings":"AAEA,QAAA,MAAM,WAAW,QAAkB,CAAC;AACpC,QAAA,MAAM,SAAS,QAAkB,CAAC;AAClC,QAAA,MAAM,cAAc,QAAsB,CAAC;AAC3C,QAAA,MAAM,qBAAqB,QAAuB,CAAC;AACnD,QAAA,MAAM,kBAAkB,QAAqB,CAAC;AAC9C,QAAA,MAAM,sBAAsB,QAAqB,CAAC;AAClD,QAAA,MAAM,sBAAsB,QAAc,CAAC;AAC3C,QAAA,MAAM,qBAAqB,QAAkB,CAAC;AAC9C,QAAA,MAAM,yBAAyB,QAA0B,CAAC;AAC1D,QAAA,MAAM,qBAAqB,QAAO,CAAC;AACnC,QAAA,MAAM,aAAa,QAAwB,CAAC;AAC5C,QAAA,MAAM,kBAAkB,QAA+oB,CAAC;AACxqB,QAAA,MAAM,YAAY,QAAO,CAAC;AAC1B,QAAA,MAAM,gBAAgB,QAAgB,CAAC;AACvC,QAAA,MAAM,mBAAmB,QAAkB,CAAC;AAC5C,QAAA,MAAM,eAAe,QAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/lib/constants.js"],"names":[],"mappings":"AAEA,QAAA,MAAM,WAAW,QAAkB,CAAC;AACpC,QAAA,MAAM,SAAS,QAAkB,CAAC;AAClC,QAAA,MAAM,cAAc,QAAsB,CAAC;AAC3C,QAAA,MAAM,qBAAqB,QAAuB,CAAC;AACnD,QAAA,MAAM,kBAAkB,QAAqB,CAAC;AAC9C,QAAA,MAAM,sBAAsB,QAAqB,CAAC;AAClD,QAAA,MAAM,sBAAsB,QAAc,CAAC;AAC3C,QAAA,MAAM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,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,YAAY,EAGZ,sBAAsB,EACvB,CAAC"}
|
|
@@ -23,7 +23,7 @@ declare function canRemovePrecedingTag(optionalEndTag: string, tag: string): boo
|
|
|
23
23
|
*/
|
|
24
24
|
declare function canRemoveElement(tag: string, attrs: HTMLAttribute[]): boolean;
|
|
25
25
|
/**
|
|
26
|
-
* @param {string} str - Tag name or HTML-like element spec (e.g.,
|
|
26
|
+
* @param {string} str - Tag name or HTML-like element spec (e.g., `td` or `<span aria-hidden='true'>`)
|
|
27
27
|
* @param {ProcessedOptions} options - Options object for name normalization
|
|
28
28
|
* @returns {{tag: string, attrs: Object.<string, string|undefined>|null}|null} Parsed spec or null if invalid
|
|
29
29
|
*/
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom fragment matching
|
|
3
|
+
*
|
|
4
|
+
* `ignoreCustomFragments` patterns nearly always describe the same shape: a literal
|
|
5
|
+
* opening delimiter, an any-character or negated-class body, and a literal closing
|
|
6
|
+
* delimiter, as in `<%[\s\S]*?%>` or `\{\{[^}]*?\}\}`. Such a fragment can be found
|
|
7
|
+
* with `indexOf` in linear time, where running the pattern as a regex costs O(n²)
|
|
8
|
+
* on input that opens fragments it never closes—and can cost far more than that when
|
|
9
|
+
* the pattern itself backtracks. Patterns of other shapes keep running as regexes,
|
|
10
|
+
* one per pattern, so each keeps its own flags.
|
|
11
|
+
*/
|
|
12
|
+
export type DelimitedFragment = {
|
|
13
|
+
open: string;
|
|
14
|
+
close: string;
|
|
15
|
+
min: number;
|
|
16
|
+
max: number;
|
|
17
|
+
excluded: RegExp | null;
|
|
18
|
+
};
|
|
19
|
+
export type PatternFragment = {
|
|
20
|
+
search: RegExp;
|
|
21
|
+
anchored: RegExp;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Describe a fragment pattern as literal delimiters around an any-character body
|
|
25
|
+
* @param {RegExp} pattern
|
|
26
|
+
* @returns {DelimitedFragment | null} Null when the pattern has another shape, which
|
|
27
|
+
* the caller answers by running it as a regex
|
|
28
|
+
*/
|
|
29
|
+
declare function toDelimitedFragment(pattern: RegExp): DelimitedFragment | null;
|
|
30
|
+
/**
|
|
31
|
+
* Prepare a fragment pattern for matching, by scanning where the shape allows it
|
|
32
|
+
* @param {RegExp} pattern
|
|
33
|
+
* @returns {DelimitedFragment | PatternFragment}
|
|
34
|
+
*/
|
|
35
|
+
declare function toFragment(pattern: RegExp): DelimitedFragment | PatternFragment;
|
|
36
|
+
/**
|
|
37
|
+
* Replace runs of custom fragments, and the whitespace padding them
|
|
38
|
+
* @param {string} value - Document to scan
|
|
39
|
+
* @param {(DelimitedFragment | PatternFragment)[]} fragments - In the order the patterns
|
|
40
|
+
* were given, since the earliest match wins and ties go to the pattern listed first
|
|
41
|
+
* @param {(match: string) => string} replacer - Called with each match, as `replace` would
|
|
42
|
+
* @returns {string}
|
|
43
|
+
*/
|
|
44
|
+
declare function replaceCustomFragments(value: string, fragments: (DelimitedFragment | PatternFragment)[], replacer: (match: string) => string): string;
|
|
45
|
+
export { toDelimitedFragment, toFragment, replaceCustomFragments };
|
|
46
|
+
//# sourceMappingURL=fragments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fragments.d.ts","sourceRoot":"","sources":["../../../src/lib/fragments.js"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAaA,YAA4F,iBAAiB,GAAnG;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;CAAC,CAI1F;AAAA,YAA8C,eAAe,GAAnD;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,CAE9C;AAmCD;;;;;GAKG;AACH,iBAAS,mBAAmB,CAAC,OAAO,EAJzB,MAIyB,GAHvB,iBAAiB,GAAG,IAAI,CAwBpC;AAED;;;;GAIG;AACH,iBAAS,UAAU,CAAC,OAAO,EAHhB,MAGgB,GAFd,iBAAiB,GAAG,eAAe,CAS/C;AAED;;;;;;;GAOG;AACH,iBAAS,sBAAsB,CAAC,KAAK,EAN1B,MAM0B,EAAE,SAAS,EALrC,CAAC,iBAAiB,GAAG,eAAe,CAAC,EAKA,EAAE,QAAQ,EAH/C,CAAC,KAAK,EAAE,MAAM,KAAK,MAG4B,GAF7C,MAAM,CAwJlB;AAID,OAAO,EACL,mBAAmB,EACnB,UAAU,EACV,sBAAsB,EACvB,CAAC"}
|
|
@@ -1,198 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
caseSensitive: {
|
|
15
|
-
description: string;
|
|
16
|
-
type: string;
|
|
17
|
-
};
|
|
18
|
-
collapseAttributeWhitespace: {
|
|
19
|
-
description: string;
|
|
20
|
-
type: string;
|
|
21
|
-
};
|
|
22
|
-
collapseBooleanAttributes: {
|
|
23
|
-
description: string;
|
|
24
|
-
type: string;
|
|
25
|
-
};
|
|
26
|
-
collapseInlineTagWhitespace: {
|
|
27
|
-
description: string;
|
|
28
|
-
type: string;
|
|
29
|
-
};
|
|
30
|
-
collapseWhitespace: {
|
|
31
|
-
description: string;
|
|
32
|
-
type: string;
|
|
33
|
-
};
|
|
34
|
-
conservativeCollapse: {
|
|
35
|
-
description: string;
|
|
36
|
-
type: string;
|
|
37
|
-
};
|
|
38
|
-
continueOnMinifyError: {
|
|
39
|
-
description: string;
|
|
40
|
-
descriptionAffirmative: string;
|
|
41
|
-
type: string;
|
|
42
|
-
};
|
|
43
|
-
continueOnParseError: {
|
|
44
|
-
description: string;
|
|
45
|
-
type: string;
|
|
46
|
-
};
|
|
47
|
-
customAttrAssign: {
|
|
48
|
-
description: string;
|
|
49
|
-
type: string;
|
|
50
|
-
};
|
|
51
|
-
customAttrCollapse: {
|
|
52
|
-
description: string;
|
|
53
|
-
type: string;
|
|
54
|
-
};
|
|
55
|
-
customAttrSurround: {
|
|
56
|
-
description: string;
|
|
57
|
-
type: string;
|
|
58
|
-
};
|
|
59
|
-
customEventAttributes: {
|
|
60
|
-
description: string;
|
|
61
|
-
type: string;
|
|
62
|
-
};
|
|
63
|
-
customFragmentQuantifierLimit: {
|
|
64
|
-
description: string;
|
|
65
|
-
type: string;
|
|
66
|
-
};
|
|
67
|
-
decodeEntities: {
|
|
68
|
-
description: string;
|
|
69
|
-
type: string;
|
|
70
|
-
};
|
|
71
|
-
ignoreCustomComments: {
|
|
72
|
-
description: string;
|
|
73
|
-
type: string;
|
|
74
|
-
};
|
|
75
|
-
ignoreCustomFragments: {
|
|
76
|
-
description: string;
|
|
77
|
-
type: string;
|
|
78
|
-
};
|
|
79
|
-
includeAutoGeneratedTags: {
|
|
80
|
-
description: string;
|
|
81
|
-
type: string;
|
|
82
|
-
};
|
|
83
|
-
inlineCustomElements: {
|
|
84
|
-
description: string;
|
|
85
|
-
type: string;
|
|
86
|
-
};
|
|
87
|
-
keepClosingSlash: {
|
|
88
|
-
description: string;
|
|
89
|
-
type: string;
|
|
90
|
-
};
|
|
91
|
-
maxInputLength: {
|
|
92
|
-
description: string;
|
|
93
|
-
type: string;
|
|
94
|
-
};
|
|
95
|
-
maxLineLength: {
|
|
96
|
-
description: string;
|
|
97
|
-
type: string;
|
|
98
|
-
};
|
|
99
|
-
mergeScripts: {
|
|
100
|
-
description: string;
|
|
101
|
-
type: string;
|
|
102
|
-
};
|
|
103
|
-
minifyCSS: {
|
|
104
|
-
description: string;
|
|
105
|
-
type: string;
|
|
106
|
-
};
|
|
107
|
-
minifyJS: {
|
|
108
|
-
description: string;
|
|
109
|
-
type: string;
|
|
110
|
-
};
|
|
111
|
-
minifySVG: {
|
|
112
|
-
description: string;
|
|
113
|
-
type: string;
|
|
114
|
-
};
|
|
115
|
-
minifyURLs: {
|
|
116
|
-
description: string;
|
|
117
|
-
type: string;
|
|
118
|
-
};
|
|
119
|
-
noNewlinesBeforeTagClose: {
|
|
120
|
-
description: string;
|
|
121
|
-
type: string;
|
|
122
|
-
};
|
|
123
|
-
partialMarkup: {
|
|
124
|
-
description: string;
|
|
125
|
-
type: string;
|
|
126
|
-
};
|
|
127
|
-
preserveLineBreaks: {
|
|
128
|
-
description: string;
|
|
129
|
-
type: string;
|
|
130
|
-
};
|
|
131
|
-
preventAttributesEscaping: {
|
|
132
|
-
description: string;
|
|
133
|
-
type: string;
|
|
134
|
-
};
|
|
135
|
-
processScripts: {
|
|
136
|
-
description: string;
|
|
137
|
-
type: string;
|
|
138
|
-
};
|
|
139
|
-
quoteCharacter: {
|
|
140
|
-
description: string;
|
|
141
|
-
type: string;
|
|
142
|
-
};
|
|
143
|
-
removeAttributeQuotes: {
|
|
144
|
-
description: string;
|
|
145
|
-
type: string;
|
|
146
|
-
};
|
|
147
|
-
removeComments: {
|
|
148
|
-
description: string;
|
|
149
|
-
type: string;
|
|
150
|
-
};
|
|
151
|
-
removeDefaultTypeAttributes: {
|
|
152
|
-
description: string;
|
|
153
|
-
type: string;
|
|
154
|
-
};
|
|
155
|
-
removeEmptyAttributes: {
|
|
156
|
-
description: string;
|
|
157
|
-
type: string;
|
|
158
|
-
};
|
|
159
|
-
removeEmptyElements: {
|
|
160
|
-
description: string;
|
|
161
|
-
type: string;
|
|
162
|
-
};
|
|
163
|
-
removeEmptyElementsExcept: {
|
|
164
|
-
description: string;
|
|
165
|
-
type: string;
|
|
166
|
-
};
|
|
167
|
-
removeOptionalTags: {
|
|
168
|
-
description: string;
|
|
169
|
-
type: string;
|
|
170
|
-
};
|
|
171
|
-
removeRedundantAttributes: {
|
|
172
|
-
description: string;
|
|
173
|
-
type: string;
|
|
174
|
-
};
|
|
175
|
-
removeTagWhitespace: {
|
|
176
|
-
description: string;
|
|
177
|
-
type: string;
|
|
178
|
-
};
|
|
179
|
-
sortAttributes: {
|
|
180
|
-
description: string;
|
|
181
|
-
type: string;
|
|
182
|
-
};
|
|
183
|
-
sortClassNames: {
|
|
184
|
-
description: string;
|
|
185
|
-
type: string;
|
|
186
|
-
};
|
|
187
|
-
trimCustomFragments: {
|
|
188
|
-
description: string;
|
|
189
|
-
type: string;
|
|
190
|
-
};
|
|
191
|
-
useShortDoctype: {
|
|
192
|
-
description: string;
|
|
193
|
-
type: string;
|
|
194
|
-
};
|
|
1
|
+
export type OptionDefinition = {
|
|
2
|
+
/**
|
|
3
|
+
* Help text, phrased for the option’s primary CLI form
|
|
4
|
+
*/
|
|
5
|
+
description: string;
|
|
6
|
+
/**
|
|
7
|
+
* Help text for what enabling the option does, where `description` describes the negated form
|
|
8
|
+
*/
|
|
9
|
+
descriptionAffirmative?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Key into the parser and JSON Schema type maps in cli.js and scripts/build-schema.js
|
|
12
|
+
*/
|
|
13
|
+
type: string;
|
|
195
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {object} OptionDefinition
|
|
17
|
+
* @property {string} description Help text, phrased for the option’s primary CLI form
|
|
18
|
+
* @property {string} [descriptionAffirmative] Help text for what enabling the option does, where `description` describes the negated form
|
|
19
|
+
* @property {string} type Key into the parser and JSON Schema type maps in cli.js and scripts/build-schema.js
|
|
20
|
+
*/
|
|
21
|
+
/** @type {Record<string, OptionDefinition>} */
|
|
22
|
+
declare const optionDefinitions: Record<string, OptionDefinition>;
|
|
196
23
|
declare const optionDefaults: {
|
|
197
24
|
continueOnMinifyError: boolean;
|
|
198
25
|
ignoreCustomComments: RegExp[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"option-definitions.d.ts","sourceRoot":"","sources":["../../../src/lib/option-definitions.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"option-definitions.d.ts","sourceRoot":"","sources":["../../../src/lib/option-definitions.js"],"names":[],"mappings":"AAGG,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,CAuMzC,CAAC;AAEF,QAAA,MAAM,cAAc;IAClB,qBAAqB;IACrB,oBAAoB;IAIpB,qBAAqB;IAIrB,wBAAwB;CACzB,CAAC;AAIF,OAAO,EACL,iBAAiB,EACjB,cAAc,EACf,CAAC"}
|
|
@@ -1,38 +1,66 @@
|
|
|
1
1
|
import { LRU } from './utils.js';
|
|
2
2
|
import type { MinifierOptions, HTMLAttribute } from '../htmlminifier.js';
|
|
3
|
-
export type
|
|
3
|
+
export type CSSContext = {
|
|
4
|
+
usedSymbols?: Set<string>;
|
|
5
|
+
warned: Set<string>;
|
|
6
|
+
};
|
|
7
|
+
export type CSSResult = {
|
|
8
|
+
css: string;
|
|
9
|
+
warnings: string[];
|
|
10
|
+
};
|
|
11
|
+
export type ProcessedOptions = Omit<MinifierOptions, 'preset' | 'canCollapseWhitespace' | 'canTrimWhitespace' | 'ignoreCustomComments' | 'log' | 'minifyCSS' | 'minifyJS' | 'minifyURLs' | 'minifySVG' | 'removeUnusedCSS'> & {
|
|
4
12
|
name: (name: string) => string;
|
|
5
13
|
log: (message: any) => unknown;
|
|
6
14
|
ignoreCustomComments: RegExp[];
|
|
7
15
|
canCollapseWhitespace: (tag: string, attrs: HTMLAttribute[], defaultFn: (tag: string) => boolean) => boolean;
|
|
8
16
|
canTrimWhitespace: (tag: string, attrs: HTMLAttribute[], defaultFn: (tag: string) => boolean) => boolean;
|
|
9
|
-
minifyCSS: (text: string, type?: string) => string | Promise<string>;
|
|
17
|
+
minifyCSS: (text: string, type?: string, context?: CSSContext) => string | Promise<string>;
|
|
10
18
|
minifyJS: (text: string, inline?: boolean, isModule?: boolean) => string | Promise<string>;
|
|
11
19
|
minifyURLs: (text: string) => string | Promise<string>;
|
|
12
20
|
minifySVG: ((svgContent: string) => string | Promise<string>) | null;
|
|
21
|
+
removeUnusedCSS: {
|
|
22
|
+
safelist: Array<string | RegExp>;
|
|
23
|
+
scripts: boolean;
|
|
24
|
+
} | null;
|
|
25
|
+
cssContext?: CSSContext;
|
|
13
26
|
nameParent?: (name: string) => string;
|
|
14
27
|
nameHTML?: (name: string) => string;
|
|
15
28
|
insideSVG?: boolean;
|
|
16
29
|
insideForeignContent?: boolean;
|
|
17
30
|
};
|
|
18
31
|
/** @import { MinifierOptions, HTMLAttribute } from '../htmlminifier.js' */
|
|
32
|
+
/**
|
|
33
|
+
* Per-document state handed to `minifyCSS`. Its closure hangs off the memoized
|
|
34
|
+
* options object that every `minify()` call with those options shares, so state
|
|
35
|
+
* belonging to one document has to be passed in rather than captured.
|
|
36
|
+
*
|
|
37
|
+
* @typedef {{usedSymbols?: Set<string>, warned: Set<string>}} CSSContext
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* Minified style sheet plus the warnings its transform produced, cached together
|
|
41
|
+
* so that a cache hit can report what the transform reported
|
|
42
|
+
*
|
|
43
|
+
* @typedef {{css: string, warnings: string[]}} CSSResult
|
|
44
|
+
*/
|
|
19
45
|
/**
|
|
20
46
|
* Options object produced by `processOptions` and consumed by `minifyHTML` and
|
|
21
|
-
* the
|
|
47
|
+
* the lib/ helpers; normalization guarantees that the function-valued options
|
|
22
48
|
* below are always present (defaulting to identity/built-in functions), and
|
|
23
49
|
* minification adds writable internal state on top of the public options
|
|
24
50
|
* (set on prototype-chain forks during SVG/MathML namespace transitions)
|
|
25
51
|
*
|
|
26
|
-
* @typedef {Omit<MinifierOptions, 'preset' | 'canCollapseWhitespace' | 'canTrimWhitespace' | 'ignoreCustomComments' | 'log' | 'minifyCSS' | 'minifyJS' | 'minifyURLs' | 'minifySVG'> & {
|
|
52
|
+
* @typedef {Omit<MinifierOptions, 'preset' | 'canCollapseWhitespace' | 'canTrimWhitespace' | 'ignoreCustomComments' | 'log' | 'minifyCSS' | 'minifyJS' | 'minifyURLs' | 'minifySVG' | 'removeUnusedCSS'> & {
|
|
27
53
|
* name: (name: string) => string,
|
|
28
54
|
* log: (message: any) => unknown,
|
|
29
55
|
* ignoreCustomComments: RegExp[],
|
|
30
56
|
* canCollapseWhitespace: (tag: string, attrs: HTMLAttribute[], defaultFn: (tag: string) => boolean) => boolean,
|
|
31
57
|
* canTrimWhitespace: (tag: string, attrs: HTMLAttribute[], defaultFn: (tag: string) => boolean) => boolean,
|
|
32
|
-
* minifyCSS: (text: string, type?: string) => string | Promise<string>,
|
|
58
|
+
* minifyCSS: (text: string, type?: string, context?: CSSContext) => string | Promise<string>,
|
|
33
59
|
* minifyJS: (text: string, inline?: boolean, isModule?: boolean) => string | Promise<string>,
|
|
34
60
|
* minifyURLs: (text: string) => string | Promise<string>,
|
|
35
61
|
* minifySVG: ((svgContent: string) => string | Promise<string>) | null,
|
|
62
|
+
* removeUnusedCSS: {safelist: Array<string | RegExp>, scripts: boolean} | null,
|
|
63
|
+
* cssContext?: CSSContext,
|
|
36
64
|
* nameParent?: (name: string) => string,
|
|
37
65
|
* nameHTML?: (name: string) => string,
|
|
38
66
|
* insideSVG?: boolean,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/lib/options.js"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/lib/options.js"],"names":[],"mappings":"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AC5O,gBAmhBZ,CAAC;AAIF,OAAO,EACL,qBAAqB,EACrB,cAAc,EACf,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collect the class names and IDs a document references.
|
|
3
|
+
*
|
|
4
|
+
* Style sheet contents are excluded, so that a style sheet never counts as
|
|
5
|
+
* evidence for its own selectors. An `iframe srcdoc` value is not scanned
|
|
6
|
+
* either: It holds a document of its own, minified against its own symbol set.
|
|
7
|
+
* Over-collecting is safe here (a symbol wrongly considered used is merely
|
|
8
|
+
* kept), under-collecting is not.
|
|
9
|
+
*
|
|
10
|
+
* @param {string} html - Raw document markup
|
|
11
|
+
* @param {boolean} includeScripts - Also treat identifiers inside inline `script` elements as used
|
|
12
|
+
* @param {((text: string) => string)} [decode] - Resolves character references in attribute values
|
|
13
|
+
* @returns {Set<string>} Symbols to keep
|
|
14
|
+
*/
|
|
15
|
+
declare function collectUsedSymbols(html: string, includeScripts: boolean, decode?: ((text: string) => string)): Set<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Determine which class/ID symbols a style sheet defines but the document never references.
|
|
18
|
+
* @param {string} css - Style sheet contents
|
|
19
|
+
* @param {Set<string>} used - Symbols the document references
|
|
20
|
+
* @param {Array<string | RegExp>} safelist - Symbols to keep regardless
|
|
21
|
+
* @returns {string[]} Symbols safe to remove
|
|
22
|
+
*/
|
|
23
|
+
declare function findUnusedSymbols(css: string, used: Set<string>, safelist: Array<string | RegExp>): string[];
|
|
24
|
+
/**
|
|
25
|
+
* Normalize the `removeUnusedCSS` option into a settled configuration.
|
|
26
|
+
*
|
|
27
|
+
* A misspelled key or a safelist that is not an array would otherwise protect
|
|
28
|
+
* nothing, and that only surfaces as a missing rule much later—so every value
|
|
29
|
+
* that gets dropped is reported.
|
|
30
|
+
*
|
|
31
|
+
* @param {boolean | {safelist?: Array<string | RegExp>, scripts?: boolean} | undefined} option
|
|
32
|
+
* @param {(message: string) => unknown} [warn] - Receives one message per ignored value
|
|
33
|
+
* @returns {{safelist: Array<string | RegExp>, scripts: boolean} | null} Null when disabled
|
|
34
|
+
*/
|
|
35
|
+
declare function normalizeUnusedCSSOptions(option: boolean | {
|
|
36
|
+
safelist?: Array<string | RegExp>;
|
|
37
|
+
scripts?: boolean;
|
|
38
|
+
} | undefined, warn?: (message: string) => unknown): {
|
|
39
|
+
safelist: Array<string | RegExp>;
|
|
40
|
+
scripts: boolean;
|
|
41
|
+
} | null;
|
|
42
|
+
export { collectUsedSymbols, findUnusedSymbols, normalizeUnusedCSSOptions };
|
|
43
|
+
//# 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":"AAwKA;;;;;;;;;;;;;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"}
|
|
@@ -51,5 +51,30 @@ declare function lowercase(value: string): string;
|
|
|
51
51
|
declare function replaceAsync(str: string, regex: RegExp, asyncFn: Function): Promise<string>;
|
|
52
52
|
/** @param {string | RegExp} value */
|
|
53
53
|
declare function parseRegExp(value: string | RegExp): RegExp | undefined;
|
|
54
|
-
|
|
54
|
+
/**
|
|
55
|
+
* A pattern’s source, rewritten to match the way its own flags make it match, for
|
|
56
|
+
* embedding in a larger regex that cannot carry them. `i` and `s` fit into a
|
|
57
|
+
* source; `m`, `u`, and `v` do not, and are left to the pattern it joins. Where
|
|
58
|
+
* `i` cannot be written in—a backreference, a range outside ASCII, a range that
|
|
59
|
+
* spans letters without being one—the source stands as it is, matching less than
|
|
60
|
+
* the pattern would rather than more.
|
|
61
|
+
* @param {RegExp} pattern
|
|
62
|
+
* @returns {string}
|
|
63
|
+
*/
|
|
64
|
+
declare function embedSource(pattern: RegExp): string;
|
|
65
|
+
/**
|
|
66
|
+
* @param {string} source - Regex source to judge
|
|
67
|
+
* @returns {string | null} What makes the pattern a backtracking risk, phrased
|
|
68
|
+
* to follow the pattern itself, or `null` where it is none
|
|
69
|
+
*/
|
|
70
|
+
declare function describeQuantifierRisk(source: string): string | null;
|
|
71
|
+
/**
|
|
72
|
+
* Find the index of the `>` that closes an opening tag, correctly skipping
|
|
73
|
+
* over quoted attribute values (which may contain `>`).
|
|
74
|
+
* @param {string} html
|
|
75
|
+
* @param {number} pos - Start position (just after the tag name)
|
|
76
|
+
* @returns {number} Index of the closing `>`, or -1 if not found
|
|
77
|
+
*/
|
|
78
|
+
declare function findTagEnd(html: string, pos: number): number;
|
|
79
|
+
export { stableStringify, findTagEnd, LRU, MAX_CACHE_ENTRY_SIZE, hashContent, uniqueId, identity, isThenable, lowercase, replaceAsync, parseRegExp, embedSource, describeQuantifierRisk };
|
|
55
80
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils.js"],"names":[],"mappings":"AAEA;;;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;AAID;;;;;;GAMG;AACH,iBAAe,YAAY,CAAC,GAAG,EALpB,MAKoB,EAAE,KAAK,EAJ3B,MAI2B,EA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OAAO,CAAC,MAAM,CAAC,CAe3B;AAID,qCAAqC;AACrC,iBAAS,WAAW,CAAC,KAAK,EADd,MAAM,GAAG,MACK,sBAUzB;AAqLD;;;;;;;;;GASG;AACH,iBAAS,WAAW,CAAC,OAAO,EAHjB,MAGiB,GAFf,MAAM,CAOlB;AAyFD;;;;GAIG;AACH,iBAAS,sBAAsB,CAAC,MAAM,EAJ3B,MAI2B,GAHzB,MAAM,GAAG,IAAI,CAezB;AAED;;;;;;GAMG;AACH,iBAAS,UAAU,CAAC,IAAI,EAJb,MAIa,EAAE,GAAG,EAHlB,MAGkB,GAFhB,MAAM,CAelB;AAID,OAAO,EACL,eAAe,EACf,UAAU,EACV,GAAG,EACH,oBAAoB,EACpB,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,SAAS,EACT,YAAY,EACZ,WAAW,EACX,WAAW,EACX,sBAAsB,EACvB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokenchain.d.ts","sourceRoot":"","sources":["../../src/tokenchain.js"],"names":[],"mappings":"AAAA,cAAM,MAAM;
|
|
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"}
|
|
@@ -117,11 +117,6 @@
|
|
|
117
117
|
"type": "string"
|
|
118
118
|
}
|
|
119
119
|
},
|
|
120
|
-
"customFragmentQuantifierLimit": {
|
|
121
|
-
"description": "Set maximum quantifier limit for custom fragments to prevent ReDoS attacks (default: 200)",
|
|
122
|
-
"type": "integer",
|
|
123
|
-
"minimum": 0
|
|
124
|
-
},
|
|
125
120
|
"decodeEntities": {
|
|
126
121
|
"description": "Use direct Unicode characters whenever possible",
|
|
127
122
|
"type": "boolean"
|
|
@@ -182,7 +177,6 @@
|
|
|
182
177
|
"description": "Minify CSS in `style` elements and attributes (uses Lightning CSS)",
|
|
183
178
|
"type": [
|
|
184
179
|
"boolean",
|
|
185
|
-
"string",
|
|
186
180
|
"object"
|
|
187
181
|
]
|
|
188
182
|
},
|
|
@@ -190,7 +184,6 @@
|
|
|
190
184
|
"description": "Minify JavaScript in `script` elements and event attributes (uses Terser or SWC; pass `{\"engine\": \"swc\"}` for SWC)",
|
|
191
185
|
"type": [
|
|
192
186
|
"boolean",
|
|
193
|
-
"string",
|
|
194
187
|
"object"
|
|
195
188
|
]
|
|
196
189
|
},
|
|
@@ -198,7 +191,6 @@
|
|
|
198
191
|
"description": "Minify SVG elements (uses SVGO)",
|
|
199
192
|
"type": [
|
|
200
193
|
"boolean",
|
|
201
|
-
"string",
|
|
202
194
|
"object"
|
|
203
195
|
]
|
|
204
196
|
},
|
|
@@ -282,6 +274,13 @@
|
|
|
282
274
|
"description": "Remove space between attributes whenever possible; note that this will result in invalid HTML",
|
|
283
275
|
"type": "boolean"
|
|
284
276
|
},
|
|
277
|
+
"removeUnusedCSS": {
|
|
278
|
+
"description": "Remove rules from `style` elements whose class or ID selectors the document never references (requires `--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
|
+
},
|
|
285
284
|
"sortAttributes": {
|
|
286
285
|
"description": "Sort attributes by frequency",
|
|
287
286
|
"type": "boolean"
|
|
@@ -294,6 +293,10 @@
|
|
|
294
293
|
"description": "Trim whitespace around custom fragments (`--ignore-custom-fragments`)",
|
|
295
294
|
"type": "boolean"
|
|
296
295
|
},
|
|
296
|
+
"strictCustomFragments": {
|
|
297
|
+
"description": "Reject `ignoreCustomFragments` patterns that risk catastrophic backtracking (rather than warning about them)",
|
|
298
|
+
"type": "boolean"
|
|
299
|
+
},
|
|
297
300
|
"useShortDoctype": {
|
|
298
301
|
"description": "Replaces the doctype with the short HTML doctype",
|
|
299
302
|
"type": "boolean"
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@commitlint/cli": "^21.2.2",
|
|
18
18
|
"@eslint/js": "^10.0.1",
|
|
19
|
-
"@swc/core": "^1.
|
|
19
|
+
"@swc/core": "^1.16.0",
|
|
20
20
|
"@types/node": "^26.2.0",
|
|
21
21
|
"eslint": "^10.8.1",
|
|
22
22
|
"globals": "^17.11.0",
|
|
@@ -95,5 +95,5 @@
|
|
|
95
95
|
},
|
|
96
96
|
"type": "module",
|
|
97
97
|
"types": "dist/types/htmlminifier.d.ts",
|
|
98
|
-
"version": "
|
|
98
|
+
"version": "8.0.0"
|
|
99
99
|
}
|