html-minifier-next 6.2.10 → 7.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.
@@ -202,78 +202,72 @@ export namespace optionDefinitions {
202
202
  let type_33: string;
203
203
  export { type_33 as type };
204
204
  }
205
- namespace removeEmptyAttributes {
205
+ namespace removeDefaultTypeAttributes {
206
206
  let description_34: string;
207
207
  export { description_34 as description };
208
208
  let type_34: string;
209
209
  export { type_34 as type };
210
210
  }
211
- namespace removeEmptyElements {
211
+ namespace removeEmptyAttributes {
212
212
  let description_35: string;
213
213
  export { description_35 as description };
214
214
  let type_35: string;
215
215
  export { type_35 as type };
216
216
  }
217
- namespace removeEmptyElementsExcept {
217
+ namespace removeEmptyElements {
218
218
  let description_36: string;
219
219
  export { description_36 as description };
220
220
  let type_36: string;
221
221
  export { type_36 as type };
222
222
  }
223
- namespace removeOptionalTags {
223
+ namespace removeEmptyElementsExcept {
224
224
  let description_37: string;
225
225
  export { description_37 as description };
226
226
  let type_37: string;
227
227
  export { type_37 as type };
228
228
  }
229
- namespace removeRedundantAttributes {
229
+ namespace removeOptionalTags {
230
230
  let description_38: string;
231
231
  export { description_38 as description };
232
232
  let type_38: string;
233
233
  export { type_38 as type };
234
234
  }
235
- namespace removeScriptTypeAttributes {
235
+ namespace removeRedundantAttributes {
236
236
  let description_39: string;
237
237
  export { description_39 as description };
238
238
  let type_39: string;
239
239
  export { type_39 as type };
240
240
  }
241
- namespace removeStyleLinkTypeAttributes {
241
+ namespace removeTagWhitespace {
242
242
  let description_40: string;
243
243
  export { description_40 as description };
244
244
  let type_40: string;
245
245
  export { type_40 as type };
246
246
  }
247
- namespace removeTagWhitespace {
247
+ namespace sortAttributes {
248
248
  let description_41: string;
249
249
  export { description_41 as description };
250
250
  let type_41: string;
251
251
  export { type_41 as type };
252
252
  }
253
- namespace sortAttributes {
253
+ namespace sortClassNames {
254
254
  let description_42: string;
255
255
  export { description_42 as description };
256
256
  let type_42: string;
257
257
  export { type_42 as type };
258
258
  }
259
- namespace sortClassNames {
259
+ namespace trimCustomFragments {
260
260
  let description_43: string;
261
261
  export { description_43 as description };
262
262
  let type_43: string;
263
263
  export { type_43 as type };
264
264
  }
265
- namespace trimCustomFragments {
265
+ namespace useShortDoctype {
266
266
  let description_44: string;
267
267
  export { description_44 as description };
268
268
  let type_44: string;
269
269
  export { type_44 as type };
270
270
  }
271
- namespace useShortDoctype {
272
- let description_45: string;
273
- export { description_45 as description };
274
- let type_45: string;
275
- export { type_45 as type };
276
- }
277
271
  }
278
272
  export namespace optionDefaults {
279
273
  let continueOnMinifyError_1: boolean;
@@ -1,13 +1,55 @@
1
- export type MinifierOptions = Record<string, any>;
2
1
  /**
3
- * @typedef {Record<string, any>} MinifierOptions
2
+ * Options object produced by `processOptions` and consumed by `minifyHTML` and
3
+ * the `lib/` helpers; normalization guarantees that the function-valued options
4
+ * below are always present (defaulting to identity/built-in functions), and
5
+ * minification adds writable internal state on top of the public options
6
+ * (set on prototype-chain forks during SVG/MathML namespace transitions)
4
7
  */
5
- /** @param {MinifierOptions} options */
6
- export function shouldMinifyInnerHTML(options: MinifierOptions): boolean;
8
+ export type ProcessedOptions = Omit<MinifierOptions, "preset" | "canCollapseWhitespace" | "canTrimWhitespace" | "ignoreCustomComments" | "log" | "minifyCSS" | "minifyJS" | "minifyURLs" | "minifySVG"> & {
9
+ name: (name: string) => string;
10
+ log: (message: any) => unknown;
11
+ ignoreCustomComments: RegExp[];
12
+ canCollapseWhitespace: (tag: string, attrs: HTMLAttribute[], defaultFn: (tag: string) => boolean) => boolean;
13
+ canTrimWhitespace: (tag: string, attrs: HTMLAttribute[], defaultFn: (tag: string) => boolean) => boolean;
14
+ minifyCSS: (text: string, type?: string) => string | Promise<string>;
15
+ minifyJS: (text: string, inline?: boolean, isModule?: boolean) => string | Promise<string>;
16
+ minifyURLs: (text: string) => string | Promise<string>;
17
+ minifySVG: ((svgContent: string) => string | Promise<string>) | null;
18
+ nameParent?: (name: string) => string;
19
+ nameHTML?: (name: string) => string;
20
+ insideSVG?: boolean;
21
+ insideForeignContent?: boolean;
22
+ };
23
+ /** @import { MinifierOptions, HTMLAttribute } from '../htmlminifier.js' */
24
+ /**
25
+ * Options object produced by `processOptions` and consumed by `minifyHTML` and
26
+ * the `lib/` helpers; normalization guarantees that the function-valued options
27
+ * below are always present (defaulting to identity/built-in functions), and
28
+ * minification adds writable internal state on top of the public options
29
+ * (set on prototype-chain forks during SVG/MathML namespace transitions)
30
+ *
31
+ * @typedef {Omit<MinifierOptions, 'preset' | 'canCollapseWhitespace' | 'canTrimWhitespace' | 'ignoreCustomComments' | 'log' | 'minifyCSS' | 'minifyJS' | 'minifyURLs' | 'minifySVG'> & {
32
+ * name: (name: string) => string,
33
+ * log: (message: any) => unknown,
34
+ * ignoreCustomComments: RegExp[],
35
+ * canCollapseWhitespace: (tag: string, attrs: HTMLAttribute[], defaultFn: (tag: string) => boolean) => boolean,
36
+ * canTrimWhitespace: (tag: string, attrs: HTMLAttribute[], defaultFn: (tag: string) => boolean) => boolean,
37
+ * minifyCSS: (text: string, type?: string) => string | Promise<string>,
38
+ * minifyJS: (text: string, inline?: boolean, isModule?: boolean) => string | Promise<string>,
39
+ * minifyURLs: (text: string) => string | Promise<string>,
40
+ * minifySVG: ((svgContent: string) => string | Promise<string>) | null,
41
+ * nameParent?: (name: string) => string,
42
+ * nameHTML?: (name: string) => string,
43
+ * insideSVG?: boolean,
44
+ * insideForeignContent?: boolean
45
+ * }} ProcessedOptions
46
+ */
47
+ /** @param {ProcessedOptions} options */
48
+ export function shouldMinifyInnerHTML(options: ProcessedOptions): boolean;
7
49
  /**
8
50
  * @param {MinifierOptions} inputOptions - User-provided options
9
51
  * @param {{getLightningCSS?: Function | undefined, getTerser?: Function | undefined, getSwc?: Function | undefined, getSvgo?: Function | undefined, cssMinifyCache?: LRU | undefined, jsMinifyCache?: LRU | undefined, svgMinifyCache?: LRU | undefined}} [deps] - Dependencies from htmlminifier.js
10
- * @returns {MinifierOptions} Normalized options with defaults applied
52
+ * @returns {ProcessedOptions} Normalized options with defaults applied
11
53
  */
12
54
  export function processOptions(inputOptions: MinifierOptions, { getLightningCSS, getTerser, getSwc, getSvgo, cssMinifyCache, jsMinifyCache, svgMinifyCache }?: {
13
55
  getLightningCSS?: Function | undefined;
@@ -17,6 +59,8 @@ export function processOptions(inputOptions: MinifierOptions, { getLightningCSS,
17
59
  cssMinifyCache?: LRU | undefined;
18
60
  jsMinifyCache?: LRU | undefined;
19
61
  svgMinifyCache?: LRU | undefined;
20
- }): MinifierOptions;
62
+ }): ProcessedOptions;
63
+ import type { MinifierOptions } from '../htmlminifier.js';
64
+ import type { HTMLAttribute } from '../htmlminifier.js';
21
65
  import { LRU } from './utils.js';
22
66
  //# sourceMappingURL=options.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/lib/options.js"],"names":[],"mappings":"8BAWa,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;AADhC;;GAEG;AAMH,uCAAuC;AACvC,+CADY,eAAe,WAW1B;AAID;;;;GAIG;AACH,6CAJW,eAAe,mGACf;IAAC,eAAe,CAAC,EAAE,WAAW,SAAS,CAAC;IAAC,SAAS,CAAC,EAAE,WAAW,SAAS,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,SAAS,CAAC;IAAC,OAAO,CAAC,EAAE,WAAW,SAAS,CAAC;IAAC,cAAc,CAAC,EAAE,GAAG,GAAG,SAAS,CAAC;IAAC,aAAa,CAAC,EAAE,GAAG,GAAG,SAAS,CAAC;IAAC,cAAc,CAAC,EAAE,GAAG,GAAG,SAAS,CAAA;CAAC,GAC5O,eAAe,CA6X3B;oBAhaiG,YAAY"}
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/lib/options.js"],"names":[],"mappings":";;;;;;;+BAmBa,IAAI,CAAC,eAAe,EAAE,QAAQ,GAAG,uBAAuB,GAAG,mBAAmB,GAAG,sBAA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J,2EAA2E;AAI3E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,wCAAwC;AACxC,+CADY,gBAAgB,WAW3B;AAYD;;;;GAIG;AACH,6CAJW,eAAe,mGACf;IAAC,eAAe,CAAC,EAAE,WAAW,SAAS,CAAC;IAAC,SAAS,CAAC,EAAE,WAAW,SAAS,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,SAAS,CAAC;IAAC,OAAO,CAAC,EAAE,WAAW,SAAS,CAAC;IAAC,cAAc,CAAC,EAAE,GAAG,GAAG,SAAS,CAAC;IAAC,aAAa,CAAC,EAAE,GAAG,GAAG,SAAS,CAAC;IAAC,cAAc,CAAC,EAAE,GAAG,GAAG,SAAS,CAAA;CAAC,GAC5O,gBAAgB,CA8Y5B;qCAtcmD,oBAAoB;mCAApB,oBAAoB;oBAP0B,YAAY"}
@@ -24,8 +24,11 @@ export function hashContent(str: string): string;
24
24
  export function uniqueId(value: string): string;
25
25
  /** @param {string} value */
26
26
  export function identity(value: string): string;
27
- /** @param {unknown} value */
28
- export function isThenable(value: unknown): boolean;
27
+ /**
28
+ * @param {unknown} value
29
+ * @returns {value is PromiseLike<any>}
30
+ */
31
+ export function isThenable(value: unknown): value is PromiseLike<any>;
29
32
  /** @param {string} value */
30
33
  export function lowercase(value: string): string;
31
34
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils.js"],"names":[],"mappings":"AAEA;;;GAGG;AACH,qCAHW,OAAO,GACL,MAAM,CAYlB;AAID;IACE,4BAIC;IAHC,cAAkB;IAClB,mCAAmC;IACnC,KADW,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CACX;IAEtB,0BAA0B;IAC1B,SADY,MAAM,WASjB;IACD;;;OAGG;IACH,SAHW,MAAM,SACN,OAAO,QASjB;IACD,0BAA0B;IAC1B,YADY,MAAM,QACmB;CACtC;AAID,0BAA0B;AAC1B,iCADY,MAAM,UAQjB;AAID,4BAA4B;AAC5B,gCADY,MAAM,UAOjB;AAID,4BAA4B;AAC5B,gCADY,MAAM,UAGjB;AAED,6BAA6B;AAC7B,kCADY,OAAO,WAGlB;AAED,4BAA4B;AAC5B,iCADY,MAAM,UAGjB;AAID;;;;;;GAMG;AACH,kCALW,MAAM,SACN,MAAM,sBAEJ,OAAO,CAAC,MAAM,CAAC,CAc3B;AAID,qCAAqC;AACrC,mCADY,MAAM,GAAG,MAAM,sBAW1B"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils.js"],"names":[],"mappings":"AAEA;;;GAGG;AACH,qCAHW,OAAO,GACL,MAAM,CAYlB;AAID;IACE,4BAIC;IAHC,cAAkB;IAClB,mCAAmC;IACnC,KADW,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CACX;IAEtB,0BAA0B;IAC1B,SADY,MAAM,WASjB;IACD;;;OAGG;IACH,SAHW,MAAM,SACN,OAAO,QASjB;IACD,0BAA0B;IAC1B,YADY,MAAM,QACmB;CACtC;AAID,0BAA0B;AAC1B,iCADY,MAAM,UAQjB;AAID,4BAA4B;AAC5B,gCADY,MAAM,UAOjB;AAID,4BAA4B;AAC5B,gCADY,MAAM,UAGjB;AAED;;;GAGG;AACH,kCAHW,OAAO,GACL,KAAK,IAAI,WAAW,CAAC,GAAG,CAAC,CAIrC;AAED,4BAA4B;AAC5B,iCADY,MAAM,UAGjB;AAID;;;;;;GAMG;AACH,kCALW,MAAM,SACN,MAAM,sBAEJ,OAAO,CAAC,MAAM,CAAC,CAc3B;AAID,qCAAqC;AACrC,mCADY,MAAM,GAAG,MAAM,sBAW1B"}
@@ -17,8 +17,7 @@ export namespace presets {
17
17
  let conservativeCollapse: boolean;
18
18
  let preserveLineBreaks: boolean;
19
19
  let removeComments: boolean;
20
- let removeScriptTypeAttributes: boolean;
21
- let removeStyleLinkTypeAttributes: boolean;
20
+ let removeDefaultTypeAttributes: boolean;
22
21
  let useShortDoctype: boolean;
23
22
  }
24
23
  namespace comprehensive {
@@ -36,13 +35,11 @@ export namespace presets {
36
35
  export let removeAttributeQuotes: boolean;
37
36
  let removeComments_1: boolean;
38
37
  export { removeComments_1 as removeComments };
38
+ let removeDefaultTypeAttributes_1: boolean;
39
+ export { removeDefaultTypeAttributes_1 as removeDefaultTypeAttributes };
39
40
  export let removeEmptyAttributes: boolean;
40
41
  export let removeOptionalTags: boolean;
41
42
  export let removeRedundantAttributes: boolean;
42
- let removeScriptTypeAttributes_1: boolean;
43
- export { removeScriptTypeAttributes_1 as removeScriptTypeAttributes };
44
- let removeStyleLinkTypeAttributes_1: boolean;
45
- export { removeStyleLinkTypeAttributes_1 as removeStyleLinkTypeAttributes };
46
43
  let useShortDoctype_1: boolean;
47
44
  export { useShortDoctype_1 as useShortDoctype };
48
45
  }
@@ -1 +1 @@
1
- {"version":3,"file":"presets.d.ts","sourceRoot":"","sources":["../../src/presets.js"],"names":[],"mappings":"AAyCA;;;;GAIG;AACH,gCAHW,MAAM,GACJ,MAAM,GAAC,IAAI,CAMvB;AAED;;;GAGG;AACH,kCAFa,MAAM,EAAE,CAIpB"}
1
+ {"version":3,"file":"presets.d.ts","sourceRoot":"","sources":["../../src/presets.js"],"names":[],"mappings":"AAuCA;;;;GAIG;AACH,gCAHW,MAAM,GACJ,MAAM,GAAC,IAAI,CAMvB;AAED;;;GAGG;AACH,kCAFa,MAAM,EAAE,CAIpB"}
package/package.json CHANGED
@@ -12,32 +12,28 @@
12
12
  "svgo": "^4.0.1",
13
13
  "terser": "^5.47.1"
14
14
  },
15
- "description": "Super-configurable and well-tested web page minifier (enhanced successor of HTML Minifier)",
15
+ "description": "Super-configurable and well-tested web page minifier (enhanced successor to HTML Minifier)",
16
16
  "devDependencies": {
17
17
  "@commitlint/cli": "^21.0.1",
18
18
  "@eslint/js": "^10.0.1",
19
- "@rollup/plugin-commonjs": "^29.0.2",
20
- "@rollup/plugin-json": "^6.1.0",
21
- "@rollup/plugin-node-resolve": "^16.0.3",
22
19
  "@swc/core": "^1.15.40",
23
20
  "@types/node": "^25.9.1",
24
21
  "eslint": "^10.4.0",
25
- "rollup": "^4.60.4",
26
- "rollup-plugin-polyfill-node": "^0.13.0",
27
22
  "typescript": "^6.0.3",
28
23
  "vite": "^8.0.14"
29
24
  },
25
+ "engines": {
26
+ "node": ">=22"
27
+ },
30
28
  "exports": {
31
29
  ".": {
32
30
  "types": "./dist/types/htmlminifier.d.ts",
33
- "import": "./src/htmlminifier.js",
34
- "require": "./dist/htmlminifier.cjs"
31
+ "import": "./src/htmlminifier.js"
35
32
  },
36
33
  "./package.json": "./package.json"
37
34
  },
38
35
  "files": [
39
36
  "cli.js",
40
- "dist/htmlminifier.cjs",
41
37
  "dist/types/",
42
38
  "src/"
43
39
  ],
@@ -68,8 +64,6 @@
68
64
  "uglify"
69
65
  ],
70
66
  "license": "MIT",
71
- "main": "./dist/htmlminifier.cjs",
72
- "module": "./src/htmlminifier.js",
73
67
  "name": "html-minifier-next",
74
68
  "peerDependencies": {
75
69
  "@swc/core": "^1.15.7"
@@ -84,19 +78,18 @@
84
78
  "url": "git+https://github.com/j9t/html-minifier-next.git"
85
79
  },
86
80
  "scripts": {
87
- "build": "tsc && rollup -c",
88
- "build:docs": "vite build --base /html-minifier-next/ --outDir build",
81
+ "build": "tsc",
82
+ "build:docs": "vite build --base /html-minifier-next/",
89
83
  "deploy": "npm run build && npm run build:docs",
90
84
  "lint": "eslint .",
91
- "prebuild": "node --eval='require(`fs`).rmSync(`dist`,{recursive:true,force:true})'",
85
+ "prebuild": "node --input-type=module --eval \"import {rmSync} from 'fs';rmSync('dist',{recursive:true,force:true})\"",
92
86
  "prepack": "npm run build",
93
87
  "prepare": "git config core.hooksPath .githooks || true",
94
- "serve": "npm run build && vite",
88
+ "serve": "vite",
95
89
  "test": "npm run test:types && node --test tests/*.spec.js",
96
- "test:types": "tsc --project tsconfig.test.json",
90
+ "test:types": "tsc --noEmit && tsc --project tsconfig.test.json",
97
91
  "test:watch": "node --test --watch tests/*.spec.js"
98
92
  },
99
93
  "type": "module",
100
- "types": "./dist/types/htmlminifier.d.ts",
101
- "version": "6.2.10"
94
+ "version": "7.0.0"
102
95
  }