html-minifier-next 5.1.0 → 5.1.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.
package/dist/htmlminifier.cjs
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var entities = require('entities');
|
|
6
|
-
|
|
7
5
|
/*
|
|
8
6
|
* HTML Parser By John Resig (ejohn.org)
|
|
9
7
|
* Modified by Juriy “kangax” Zaytsev
|
|
@@ -2052,6 +2050,16 @@ const processOptions = (inputOptions, { getLightningCSS, getTerser, getSwc, getS
|
|
|
2052
2050
|
// Imports
|
|
2053
2051
|
|
|
2054
2052
|
|
|
2053
|
+
// Lazy-load entities only when `decodeEntities` is enabled
|
|
2054
|
+
|
|
2055
|
+
let decodeHTMLStrictPromise;
|
|
2056
|
+
async function getDecodeHTMLStrict() {
|
|
2057
|
+
if (!decodeHTMLStrictPromise) {
|
|
2058
|
+
decodeHTMLStrictPromise = import('entities').then(m => m.decodeHTMLStrict);
|
|
2059
|
+
}
|
|
2060
|
+
return decodeHTMLStrictPromise;
|
|
2061
|
+
}
|
|
2062
|
+
|
|
2055
2063
|
// Validators
|
|
2056
2064
|
|
|
2057
2065
|
function isConditionalComment(text) {
|
|
@@ -2467,7 +2475,7 @@ async function normalizeAttr(attr, attrs, tag, options, minifyHTML) {
|
|
|
2467
2475
|
if (options.decodeEntities && attrValue) {
|
|
2468
2476
|
// Fast path: Only decode when entities are present
|
|
2469
2477
|
if (attrValue.indexOf('&') !== -1) {
|
|
2470
|
-
attrValue =
|
|
2478
|
+
attrValue = (await getDecodeHTMLStrict())(attrValue);
|
|
2471
2479
|
}
|
|
2472
2480
|
}
|
|
2473
2481
|
|
|
@@ -2891,6 +2899,14 @@ async function getSvgo() {
|
|
|
2891
2899
|
return svgoPromise;
|
|
2892
2900
|
}
|
|
2893
2901
|
|
|
2902
|
+
let decodeHTMLPromise;
|
|
2903
|
+
async function getDecodeHTML() {
|
|
2904
|
+
if (!decodeHTMLPromise) {
|
|
2905
|
+
decodeHTMLPromise = import('entities').then(m => m.decodeHTML);
|
|
2906
|
+
}
|
|
2907
|
+
return decodeHTMLPromise;
|
|
2908
|
+
}
|
|
2909
|
+
|
|
2894
2910
|
// Minification caches (initialized on first use with configurable sizes)
|
|
2895
2911
|
let cssMinifyCache = null;
|
|
2896
2912
|
let jsMinifyCache = null;
|
|
@@ -4091,7 +4107,7 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
4091
4107
|
nextAttrs = nextAttrs || [];
|
|
4092
4108
|
if (options.decodeEntities && text && !specialContentElements.has(currentTag)) {
|
|
4093
4109
|
if (text.indexOf('&') !== -1) {
|
|
4094
|
-
text =
|
|
4110
|
+
text = (await getDecodeHTML())(text);
|
|
4095
4111
|
}
|
|
4096
4112
|
}
|
|
4097
4113
|
// Trim outermost newline-based whitespace inside `pre`/`textarea` elements
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"htmlminifier.d.ts","sourceRoot":"","sources":["../../src/htmlminifier.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"htmlminifier.d.ts","sourceRoot":"","sources":["../../src/htmlminifier.js"],"names":[],"mappings":"AAyoDO,8BAJI,MAAM,YACN,eAAe,GACb,OAAO,CAAC,MAAM,CAAC,CAwB3B;;;;;;;;;;;;UA56CS,MAAM;YACN,MAAM;YACN,MAAM;mBACN,MAAM;iBACN,MAAM;kBACN,MAAM;;;;;;;;;;;;;4BAQN,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,EAAE,qBAAqB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,KAAK,OAAO;;;;;;;wBAMjG,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,SAAS,EAAE,iBAAiB,EAAE,CAAC,GAAG,EAAE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AAG;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAC,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;;;;;;;;;gBASjF,OAAO,MAAS;;;;;;;;WAQhB,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM;;;;;;;+BAOxB,OAAO;;;;;;;;;;oBAMP,OAAO;;;;;;;;yBASP,OAAO;;;;;;;gCAOP,OAAO;;;;;;;;iCAMP,OAAO;;;;;;;;;;qBAOP,MAAM,EAAE;;;;;;;qBASR,IAAI,GAAG,GAAG;;;;;;;4BAMV,OAAO;;;;;;;;qBAMP,OAAO;;;;;;;;;4BAOP,OAAO,GAAG,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;;;;;;;;0BAQtD,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;gCAOP,MAAM,EAAE;;;;;;;;yBAyBR,OAAO;;;;;;;;gCAOP,OAAO;;;;;;;iCAOP,OAAO;;;;;;;oCAMP,OAAO;;;;;;;;;;0BAMP,OAAO;;;;;;;;;qBASP,OAAO,GAAG,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,IAAI,CAAC;;;;;;;;;qBAQzD,OAAO,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;;;;;;;;0BAQrC,OAAO;;;;;;;sBAOP,OAAO;;wBAzoBkC,cAAc;0BAAd,cAAc;+BAAd,cAAc"}
|
|
@@ -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":"AAmCA,yDAEC;AAED,mEAOC;AAED,uEAWC;AAED,8DAGC;AAED,4EAOC;AAgCD,mGAuCC;AAED,mEAGC;AAED,qEAGC;AAED,kEAWC;AAED,sEAGC;AAED,8DAWC;AAED,2EAIC;AAED,qEAaC;AAED,wEAUC;AAED,sEAUC;AAED,2EAEC;AAED,2DAEC;AAED,8DAUC;AAED,uEAUC;AAED,oGASC;AAED,4DAOC;AAID,0IAqIC;AAsBD;;;;GAsCC;AAED,6GAuHC;AA7gBD;;;;;;;GAOG;AACH,mEAHW,OAAO,SAuBjB"}
|
package/package.json
CHANGED
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
"description": "Super-configurable and well-tested web page minifier (enhanced successor of HTML Minifier)",
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@commitlint/cli": "^20.3.1",
|
|
17
|
-
"@eslint/js": "^
|
|
17
|
+
"@eslint/js": "^10.0.1",
|
|
18
18
|
"@rollup/plugin-commonjs": "^29.0.0",
|
|
19
19
|
"@rollup/plugin-json": "^6.1.0",
|
|
20
20
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
21
21
|
"@swc/core": "^1.15.11",
|
|
22
|
-
"eslint": "^
|
|
22
|
+
"eslint": "^10.0.0",
|
|
23
23
|
"rollup": "^4.57.1",
|
|
24
24
|
"rollup-plugin-polyfill-node": "^0.13.0",
|
|
25
25
|
"typescript": "^5.9.3",
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
"import": "./src/htmlminifier.js",
|
|
32
32
|
"require": "./dist/htmlminifier.cjs"
|
|
33
33
|
},
|
|
34
|
-
"./dist/*": "./dist/*.js",
|
|
35
34
|
"./package.json": "./package.json"
|
|
36
35
|
},
|
|
37
36
|
"files": [
|
|
38
37
|
"cli.js",
|
|
39
|
-
"dist/",
|
|
38
|
+
"dist/htmlminifier.cjs",
|
|
39
|
+
"dist/types/",
|
|
40
40
|
"src/"
|
|
41
41
|
],
|
|
42
42
|
"funding": "https://github.com/j9t/html-minifier-next?sponsor=1",
|
|
@@ -95,5 +95,5 @@
|
|
|
95
95
|
},
|
|
96
96
|
"type": "module",
|
|
97
97
|
"types": "./dist/types/htmlminifier.d.ts",
|
|
98
|
-
"version": "5.1.
|
|
98
|
+
"version": "5.1.1"
|
|
99
99
|
}
|
package/src/htmlminifier.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// Imports
|
|
2
2
|
|
|
3
|
-
import { decodeHTML } from 'entities';
|
|
4
3
|
import { HTMLParser, endTag } from './htmlparser.js';
|
|
5
4
|
import TokenChain from './tokenchain.js';
|
|
6
5
|
import { presets, getPreset, getPresetNames } from './presets.js';
|
|
@@ -100,6 +99,14 @@ async function getSvgo() {
|
|
|
100
99
|
return svgoPromise;
|
|
101
100
|
}
|
|
102
101
|
|
|
102
|
+
let decodeHTMLPromise;
|
|
103
|
+
async function getDecodeHTML() {
|
|
104
|
+
if (!decodeHTMLPromise) {
|
|
105
|
+
decodeHTMLPromise = import('entities').then(m => m.decodeHTML);
|
|
106
|
+
}
|
|
107
|
+
return decodeHTMLPromise;
|
|
108
|
+
}
|
|
109
|
+
|
|
103
110
|
// Minification caches (initialized on first use with configurable sizes)
|
|
104
111
|
let cssMinifyCache = null;
|
|
105
112
|
let jsMinifyCache = null;
|
|
@@ -1304,7 +1311,7 @@ async function minifyHTML(value, options, partialMarkup) {
|
|
|
1304
1311
|
nextAttrs = nextAttrs || [];
|
|
1305
1312
|
if (options.decodeEntities && text && !specialContentElements.has(currentTag)) {
|
|
1306
1313
|
if (text.indexOf('&') !== -1) {
|
|
1307
|
-
text =
|
|
1314
|
+
text = (await getDecodeHTML())(text);
|
|
1308
1315
|
}
|
|
1309
1316
|
}
|
|
1310
1317
|
// Trim outermost newline-based whitespace inside `pre`/`textarea` elements
|
package/src/lib/attributes.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// Imports
|
|
2
2
|
|
|
3
|
-
import { decodeHTMLStrict } from 'entities';
|
|
4
3
|
import {
|
|
5
4
|
RE_CONDITIONAL_COMMENT,
|
|
6
5
|
RE_EVENT_ATTR_DEFAULT,
|
|
@@ -22,6 +21,16 @@ import {
|
|
|
22
21
|
import { trimWhitespace, collapseWhitespaceAll } from './whitespace.js';
|
|
23
22
|
import { shouldMinifyInnerHTML } from './options.js';
|
|
24
23
|
|
|
24
|
+
// Lazy-load entities only when `decodeEntities` is enabled
|
|
25
|
+
|
|
26
|
+
let decodeHTMLStrictPromise;
|
|
27
|
+
async function getDecodeHTMLStrict() {
|
|
28
|
+
if (!decodeHTMLStrictPromise) {
|
|
29
|
+
decodeHTMLStrictPromise = import('entities').then(m => m.decodeHTMLStrict);
|
|
30
|
+
}
|
|
31
|
+
return decodeHTMLStrictPromise;
|
|
32
|
+
}
|
|
33
|
+
|
|
25
34
|
// Validators
|
|
26
35
|
|
|
27
36
|
function isConditionalComment(text) {
|
|
@@ -437,7 +446,7 @@ async function normalizeAttr(attr, attrs, tag, options, minifyHTML) {
|
|
|
437
446
|
if (options.decodeEntities && attrValue) {
|
|
438
447
|
// Fast path: Only decode when entities are present
|
|
439
448
|
if (attrValue.indexOf('&') !== -1) {
|
|
440
|
-
attrValue =
|
|
449
|
+
attrValue = (await getDecodeHTMLStrict())(attrValue);
|
|
441
450
|
}
|
|
442
451
|
}
|
|
443
452
|
|