@ohos-ports/html-minifier-next 8.4.2-beta.0 → 8.10.8-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 (46) hide show
  1. package/README.md +147 -33
  2. package/cli.js +70 -54
  3. package/dist/types/htmlminifier.d.ts +87 -33
  4. package/dist/types/htmlminifier.d.ts.map +1 -1
  5. package/dist/types/htmlparser.d.ts +4 -1
  6. package/dist/types/htmlparser.d.ts.map +1 -1
  7. package/dist/types/lib/attributes.d.ts +12 -10
  8. package/dist/types/lib/attributes.d.ts.map +1 -1
  9. package/dist/types/lib/constants.d.ts +38 -3
  10. package/dist/types/lib/constants.d.ts.map +1 -1
  11. package/dist/types/lib/content.d.ts.map +1 -1
  12. package/dist/types/lib/elements.d.ts.map +1 -1
  13. package/dist/types/lib/fragments.d.ts +1 -0
  14. package/dist/types/lib/fragments.d.ts.map +1 -1
  15. package/dist/types/lib/option-definitions.d.ts.map +1 -1
  16. package/dist/types/lib/options.d.ts +14 -46
  17. package/dist/types/lib/options.d.ts.map +1 -1
  18. package/dist/types/lib/unused-css.d.ts +34 -4
  19. package/dist/types/lib/unused-css.d.ts.map +1 -1
  20. package/dist/types/lib/urls.d.ts.map +1 -1
  21. package/dist/types/lib/utils.d.ts +31 -1
  22. package/dist/types/lib/utils.d.ts.map +1 -1
  23. package/dist/types/lib/whitespace.d.ts +57 -5
  24. package/dist/types/lib/whitespace.d.ts.map +1 -1
  25. package/dist/types/presets.d.ts +1 -2
  26. package/dist/types/presets.d.ts.map +1 -1
  27. package/dist/types/tokenchain.d.ts.map +1 -1
  28. package/html-minifier-next.schema.json +15 -7
  29. package/package.json +17 -18
  30. package/src/htmlminifier.js +1103 -392
  31. package/src/htmlparser.js +452 -200
  32. package/src/lib/attributes.js +201 -112
  33. package/src/lib/constants.js +130 -19
  34. package/src/lib/content.js +1 -6
  35. package/src/lib/elements.js +17 -12
  36. package/src/lib/file-pool.js +18 -2
  37. package/src/lib/file-write.js +87 -0
  38. package/src/lib/fragments.js +74 -8
  39. package/src/lib/option-definitions.js +17 -10
  40. package/src/lib/options.js +151 -71
  41. package/src/lib/unused-css.js +145 -27
  42. package/src/lib/urls.js +0 -9
  43. package/src/lib/utils.js +210 -45
  44. package/src/lib/whitespace.js +173 -63
  45. package/src/presets.js +1 -2
  46. package/src/tokenchain.js +1 -4
@@ -19,6 +19,7 @@ export declare const presets: {
19
19
  comprehensive: {
20
20
  collapseAttributeWhitespace: boolean;
21
21
  collapseBooleanAttributes: boolean;
22
+ collapseEmptyAttributes: boolean;
22
23
  collapseWhitespace: boolean;
23
24
  decodeEntities: boolean;
24
25
  mergeScripts: boolean;
@@ -36,13 +37,11 @@ export declare const presets: {
36
37
  };
37
38
  };
38
39
  /**
39
- * Get preset configuration by name.
40
40
  * @param {string} name - Preset name (“conservative” or “comprehensive”)
41
41
  * @returns {object|null} Preset options object or null if not found
42
42
  */
43
43
  export declare function getPreset(name: string): object | null;
44
44
  /**
45
- * Get list of available preset names
46
45
  * @returns {string[]} Array of preset names
47
46
  */
48
47
  export declare function getPresetNames(): string[];
@@ -1 +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"}
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,SAAS;QACT,UAAU;QACV,qBAAqB;QACrB,cAAc;QACd,2BAA2B;QAC3B,qBAAqB;QACrB,kBAAkB;QAClB,yBAAyB;QACzB,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"}
@@ -1 +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"}
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,WA4CX;CACF;eAEc,UAAU"}
@@ -52,7 +52,7 @@
52
52
  "minimum": 0
53
53
  },
54
54
  "caseSensitive": {
55
- "description": "Treat attributes in case-sensitive manner (useful for custom HTML elements)",
55
+ "description": "Keep element and attribute names as written (e.g., for framework components like `<MyButton>`)",
56
56
  "type": "boolean"
57
57
  },
58
58
  "collapseAttributeWhitespace": {
@@ -63,10 +63,18 @@
63
63
  "description": "Omit attribute values from boolean attributes",
64
64
  "type": "boolean"
65
65
  },
66
+ "collapseEmptyAttributes": {
67
+ "description": "Omit empty attribute values (e.g., `alt=\"\"` → `alt`)",
68
+ "type": "boolean"
69
+ },
66
70
  "collapseInlineTagWhitespace": {
67
71
  "description": "Collapse whitespace more aggressively between inline elements—use with `--collapse-whitespace`",
68
72
  "type": "boolean"
69
73
  },
74
+ "collapseNoBreakSpaces": {
75
+ "description": "Remove whitespace next to no-break spaces, narrow no-break spaces, and figure spaces in text (e.g., `a &nbsp; b` → `a&nbsp;b`), keeping runs of them—use with `--collapse-whitespace`",
76
+ "type": "boolean"
77
+ },
70
78
  "collapseWhitespace": {
71
79
  "description": "Collapse whitespace that contributes to text nodes in a document tree",
72
80
  "type": "boolean"
@@ -132,7 +140,7 @@
132
140
  }
133
141
  },
134
142
  "ignoreCustomFragments": {
135
- "description": "Array of regexes that allow to ignore certain fragments, when matched (e.g., `<?php … ?>`, `{{ … }}`)",
143
+ "description": "Array of regexes that allow to ignore certain fragments, when matched (e.g., `<?php … ?>`, `{{ … }}`, etc.)",
136
144
  "type": [
137
145
  "string",
138
146
  "array"
@@ -165,7 +173,7 @@
165
173
  "minimum": 0
166
174
  },
167
175
  "maxLineLength": {
168
- "description": "Specify a maximum line length; compressed output will be split by newlines at valid HTML split-points",
176
+ "description": "Specify a maximum line length; output will be split by newlines in tags only (between attributes or before a tag’s `>`), where they can’t change the page, so lines may run longer",
169
177
  "type": "integer",
170
178
  "minimum": 0
171
179
  },
@@ -203,7 +211,7 @@
203
211
  ]
204
212
  },
205
213
  "noNewlinesBeforeTagClose": {
206
- "description": "Never add a newline before a tag that closes an element—use with `--max-line-length`",
214
+ "description": "Never split a line in a tag that closes an element—use with `--max-line-length`",
207
215
  "type": "boolean"
208
216
  },
209
217
  "partialMarkup": {
@@ -253,7 +261,7 @@
253
261
  "type": "boolean"
254
262
  },
255
263
  "removeEmptyElementsExcept": {
256
- "description": "Array of elements to preserve (e.g., `td`, `<span aria-hidden=\"true\">`)—use with `--remove-empty-elements`",
264
+ "description": "Array of elements to preserve (e.g., `td`, `<i class=\"test\">`, etc.)—use with `--remove-empty-elements`",
257
265
  "type": [
258
266
  "string",
259
267
  "array"
@@ -275,7 +283,7 @@
275
283
  "type": "boolean"
276
284
  },
277
285
  "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",
286
+ "description": "Remove CSS from `style` elements that name an element, class, or ID the document doesn’t reference—use with `--minify-css`, and `{\"safelist\": […]}` for names only external scripts use",
279
287
  "type": [
280
288
  "boolean",
281
289
  "object"
@@ -290,7 +298,7 @@
290
298
  "type": "boolean"
291
299
  },
292
300
  "trimCustomFragments": {
293
- "description": "Trim whitespace around custom fragments (`--ignore-custom-fragments`)—use with `--collapse-whitespace`",
301
+ "description": "Trim whitespace around custom fragments (`--ignore-custom-fragments`) where it does not affect the output—use with `--collapse-whitespace`",
294
302
  "type": "boolean"
295
303
  },
296
304
  "strictCustomFragments": {
package/package.json CHANGED
@@ -4,26 +4,23 @@
4
4
  "html-minifier-next": "./cli.js",
5
5
  "hmn": "./cli.js"
6
6
  },
7
- "bugs": {
8
- "url": "https://github.com/ohos-ports/ohos-ports/issues"
9
- },
7
+ "bugs": "https://github.com/ohos-ports/ohos-ports/issues",
10
8
  "dependencies": {
11
9
  "commander": "^15.0.0",
12
10
  "entities": "^8.1.0",
11
+ "@ohos-ports/lightningcss": "^1.33.0",
13
12
  "svgo": "^4.1.0",
14
- "terser": "^5.51.2",
15
- "@ohos-ports/lightningcss": "^1.33.0-1"
13
+ "terser": "^5.51.2"
16
14
  },
17
15
  "description": "Highly effective, super-configurable, well-tested web page minifier (enhanced successor to HTML Minifier)",
18
16
  "devDependencies": {
19
- "@commitlint/cli": "^21.2.2",
20
17
  "@eslint/js": "^10.0.1",
21
- "@types/node": "^26.5.0",
22
- "eslint": "^10.10.0",
23
- "globals": "^17.12.0",
18
+ "@swc/core": "^1.16.18",
19
+ "@types/node": "^26.6.5",
20
+ "eslint": "^10.12.0",
21
+ "globals": "^17.13.0",
24
22
  "typescript": "^7.0.2",
25
- "vite": "^8.2.2",
26
- "@ohos-ports/swc-core": "^1.16.2"
23
+ "vite": "^8.3.4"
27
24
  },
28
25
  "engines": {
29
26
  "node": ">=22.13"
@@ -70,17 +67,17 @@
70
67
  "license": "MIT",
71
68
  "name": "@ohos-ports/html-minifier-next",
72
69
  "peerDependencies": {
73
- "@ohos-ports/swc-core": "^1.15.43-beta.1"
70
+ "@swc/core": "^1.15.7"
74
71
  },
75
72
  "peerDependenciesMeta": {
76
- "@ohos-ports/swc-core": {
73
+ "@swc/core": {
77
74
  "optional": true
78
75
  }
79
76
  },
80
77
  "repository": {
81
78
  "type": "git",
82
- "url": "https://github.com/ohos-ports/ohos-ports.git",
83
- "directory": "ports/html-minifier-next/8.4.2"
79
+ "url": "git+https://github.com/ohos-ports/ohos-ports.git",
80
+ "directory": "ports/html-minifier-next/8.10.8"
84
81
  },
85
82
  "scripts": {
86
83
  "build": "tsc && npm run build:schema",
@@ -89,12 +86,14 @@
89
86
  "deploy": "npm run build && npm run build:docs",
90
87
  "lint": "eslint .",
91
88
  "prebuild": "node --input-type=module --eval \"import {rmSync} from 'fs';rmSync('dist',{recursive:true,force:true})\"",
89
+ "prepack": "npm run build",
90
+ "prepare": "git config core.hooksPath .githooks || true",
92
91
  "serve": "vite",
93
- "test": "npm run test:types && node --test \"test/**/*.test.js\"",
92
+ "test": "npm run test:types && node --test \"test/**/*.test.js\" \"backtest/*.test.js\"",
94
93
  "test:types": "tsc --noEmit && tsc --project tsconfig.test.json",
95
- "test:watch": "node --test --watch \"test/**/*.test.js\""
94
+ "test:watch": "node --test --watch \"test/**/*.test.js\" \"backtest/*.test.js\""
96
95
  },
97
96
  "type": "module",
98
97
  "types": "dist/types/htmlminifier.d.ts",
99
- "version": "8.4.2-beta.0"
98
+ "version": "8.10.8-beta.0"
100
99
  }