html-minifier-next 7.5.2 → 7.6.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 +47 -8
- package/cli.js +31 -11
- package/dist/types/htmlminifier.d.ts +18 -0
- package/dist/types/htmlminifier.d.ts.map +1 -1
- package/dist/types/lib/constants.d.ts +2 -1
- package/dist/types/lib/constants.d.ts.map +1 -1
- package/dist/types/lib/elements.d.ts +1 -1
- package/dist/types/lib/option-definitions.d.ts +4 -0
- package/dist/types/lib/option-definitions.d.ts.map +1 -1
- package/dist/types/lib/options.d.ts +32 -4
- package/dist/types/lib/options.d.ts.map +1 -1
- package/dist/types/lib/unused-css.d.ts +42 -0
- package/dist/types/lib/unused-css.d.ts.map +1 -0
- package/dist/types/lib/urls.d.ts +1 -1
- package/dist/types/lib/utils.d.ts +10 -2
- package/dist/types/lib/utils.d.ts.map +1 -1
- package/dist/types/presets.d.ts +1 -1
- package/html-minifier-next.schema.json +7 -3
- package/package.json +10 -9
- package/src/htmlminifier.js +52 -39
- package/src/htmlparser.js +28 -28
- package/src/lib/attributes.js +5 -5
- package/src/lib/constants.js +2 -0
- package/src/lib/elements.js +3 -3
- package/src/lib/option-definitions.js +7 -3
- package/src/lib/options.js +127 -12
- package/src/lib/unused-css.js +394 -0
- package/src/lib/urls.js +4 -4
- package/src/lib/utils.js +24 -1
- package/src/presets.js +1 -1
package/src/lib/utils.js
CHANGED
|
@@ -109,7 +109,7 @@ function lowercase(value) {
|
|
|
109
109
|
// Replace async helper
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
|
-
* Asynchronously replace matches in a string
|
|
112
|
+
* Asynchronously replace matches in a string.
|
|
113
113
|
* @param {string} str - Input string
|
|
114
114
|
* @param {RegExp} regex - Regular expression with global flag
|
|
115
115
|
* @param {Function} asyncFn - Async function to process each match
|
|
@@ -146,8 +146,31 @@ function parseRegExp(value) {
|
|
|
146
146
|
|
|
147
147
|
// Exports
|
|
148
148
|
|
|
149
|
+
/**
|
|
150
|
+
* Find the index of the `>` that closes an opening tag, correctly skipping
|
|
151
|
+
* over quoted attribute values (which may contain `>`).
|
|
152
|
+
* @param {string} html
|
|
153
|
+
* @param {number} pos - Start position (just after the tag name)
|
|
154
|
+
* @returns {number} Index of the closing `>`, or -1 if not found
|
|
155
|
+
*/
|
|
156
|
+
function findTagEnd(html, pos) {
|
|
157
|
+
let i = pos;
|
|
158
|
+
while (i < html.length) {
|
|
159
|
+
const ch = html[i];
|
|
160
|
+
if (ch === '>') return i;
|
|
161
|
+
if (ch === '"' || ch === "'") {
|
|
162
|
+
const q = ch;
|
|
163
|
+
i++;
|
|
164
|
+
while (i < html.length && html[i] !== q) i++;
|
|
165
|
+
}
|
|
166
|
+
i++;
|
|
167
|
+
}
|
|
168
|
+
return -1;
|
|
169
|
+
}
|
|
170
|
+
|
|
149
171
|
export {
|
|
150
172
|
stableStringify,
|
|
173
|
+
findTagEnd,
|
|
151
174
|
LRU,
|
|
152
175
|
MAX_CACHE_ENTRY_SIZE,
|
|
153
176
|
hashContent,
|
package/src/presets.js
CHANGED
|
@@ -38,7 +38,7 @@ export const presets = {
|
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
|
-
* Get preset configuration by name
|
|
41
|
+
* Get preset configuration by name.
|
|
42
42
|
* @param {string} name - Preset name (“conservative” or “comprehensive”)
|
|
43
43
|
* @returns {object|null} Preset options object or null if not found
|
|
44
44
|
*/
|