html-minifier-next 7.1.0 → 7.3.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 (35) hide show
  1. package/README.md +59 -22
  2. package/cli.js +29 -4
  3. package/dist/types/htmlminifier.d.ts +77 -20
  4. package/dist/types/htmlminifier.d.ts.map +1 -1
  5. package/dist/types/htmlparser.d.ts +11 -11
  6. package/dist/types/htmlparser.d.ts.map +1 -1
  7. package/dist/types/lib/attributes.d.ts +36 -38
  8. package/dist/types/lib/attributes.d.ts.map +1 -1
  9. package/dist/types/lib/constants.d.ts +97 -100
  10. package/dist/types/lib/constants.d.ts.map +1 -1
  11. package/dist/types/lib/content.d.ts +7 -6
  12. package/dist/types/lib/content.d.ts.map +1 -1
  13. package/dist/types/lib/elements.d.ts +13 -18
  14. package/dist/types/lib/elements.d.ts.map +1 -1
  15. package/dist/types/lib/option-definitions.d.ts +202 -281
  16. package/dist/types/lib/option-definitions.d.ts.map +1 -1
  17. package/dist/types/lib/options.d.ts +7 -14
  18. package/dist/types/lib/options.d.ts.map +1 -1
  19. package/dist/types/lib/urls.d.ts +10 -2
  20. package/dist/types/lib/urls.d.ts.map +1 -1
  21. package/dist/types/lib/utils.d.ts +30 -10
  22. package/dist/types/lib/utils.d.ts.map +1 -1
  23. package/dist/types/lib/whitespace.d.ts +7 -6
  24. package/dist/types/lib/whitespace.d.ts.map +1 -1
  25. package/dist/types/presets.d.ts +39 -37
  26. package/dist/types/presets.d.ts.map +1 -1
  27. package/dist/types/tokenchain.d.ts +13 -11
  28. package/dist/types/tokenchain.d.ts.map +1 -1
  29. package/html-minifier-next.schema.json +303 -0
  30. package/package.json +8 -6
  31. package/src/htmlminifier.js +34 -1
  32. package/src/lib/option-definitions.js +12 -0
  33. package/src/lib/options.js +44 -32
  34. package/src/lib/urls.js +1 -1
  35. package/src/lib/utils.js +14 -0
package/README.md CHANGED
@@ -40,7 +40,7 @@ Use `npx html-minifier-next --help` to check all available options:
40
40
  | `--output <file>`, `-o <file>` | Specify output file (reads from `--input` file argument or STDIN; outputs to STDOUT if not specified) | File to file: `npx html-minifier-next input.html -o output.html`<br>File to file (explicit): `npx html-minifier-next -i input.html -o output.html`<br>Pipe to file: `cat input.html \| npx html-minifier-next -o output.html`<br>File to STDOUT: `npx html-minifier-next input.html` |
41
41
  | `--file-ext <extensions>`, `-f <extensions>` | Specify file extension(s) to process (comma-separated, overrides config file setting); defaults to `html,htm,shtml,shtm`; use `*` for all files | `--file-ext=html,php`, `--file-ext='*'` |
42
42
  | `--preset <name>`, `-p <name>` | Use a preset configuration (conservative or comprehensive) | `--preset=conservative` |
43
- | `--config-file <file>`, `-c <file>` | Use a configuration file | `--config-file=html-minifier.json` |
43
+ | `--config-file <file>`, `-c <file>` | Use a configuration file | `--config-file=html-minifier-next.json` |
44
44
  | `--verbose`, `-v` | Show detailed processing information (active options, file statistics) | `npx html-minifier-next --input-dir=src --output-dir=dist --verbose --collapse-whitespace` |
45
45
  | `--dry`, `-d` | Dry run: Process and report statistics without writing output | `npx html-minifier-next input.html --dry --collapse-whitespace` |
46
46
 
@@ -59,9 +59,21 @@ You can use a configuration file to specify options. The file can be either in J
59
59
  }
60
60
  ```
61
61
 
62
+ For editor support (validation, autocomplete, and inline documentation) in JSON configuration files, reference the [JSON Schema](https://raw.githubusercontent.com/j9t/html-minifier-next/main/html-minifier-next.schema.json) that ships with the package:
63
+
64
+ ```json
65
+ {
66
+ "$schema": "https://raw.githubusercontent.com/j9t/html-minifier-next/main/html-minifier-next.schema.json",
67
+ "collapseWhitespace": true,
68
+ "removeComments": true
69
+ }
70
+ ```
71
+
72
+ (If HMN is installed locally, you can also use the path `./node_modules/html-minifier-next/html-minifier-next.schema.json` instead of the URL.)
73
+
62
74
  **JavaScript module configuration example** (requires `"type": "module"` in the project’s package.json, or use a .mjs extension):
63
75
 
64
- ```javascript
76
+ ```js
65
77
  export default {
66
78
  collapseWhitespace: true,
67
79
  removeComments: true,
@@ -72,7 +84,7 @@ export default {
72
84
 
73
85
  ### Node.js
74
86
 
75
- ```javascript
87
+ ```js
76
88
  import { minify } from 'html-minifier-next';
77
89
 
78
90
  const result = await minify('<p title="example" id="moo">foo</p>', {
@@ -100,8 +112,8 @@ To review the specific options set, [presets.js](https://github.com/j9t/html-min
100
112
  npx html-minifier-next --preset conservative input.html
101
113
 
102
114
  # Via config file
103
- npx html-minifier-next --config-file=html-minifier.json input.html
104
- # where html-minifier.json contains: { "preset": "conservative" }
115
+ npx html-minifier-next --config-file=html-minifier-next.json input.html
116
+ # where html-minifier-next.json contains: { "preset": "conservative" }
105
117
 
106
118
  # Override preset options
107
119
  npx html-minifier-next --preset conservative --remove-empty-attributes input.html
@@ -186,7 +198,7 @@ When `minifyCSS` is set to `true`, HTML Minifier Next uses [Lightning CSS](https
186
198
 
187
199
  You can pass Lightning CSS configuration options by providing an object:
188
200
 
189
- ```javascript
201
+ ```js
190
202
  const result = await minify(html, {
191
203
  minifyCSS: {
192
204
  targets: {
@@ -209,7 +221,7 @@ Available Lightning CSS options when passed as an object:
209
221
 
210
222
  For advanced usage, you can also pass a function:
211
223
 
212
- ```javascript
224
+ ```js
213
225
  const result = await minify(html, {
214
226
  minifyCSS: function(text, type) {
215
227
  // `text`: CSS string to minify
@@ -225,7 +237,7 @@ When `minifyJS` is set to `true`, HTML Minifier Next uses [Terser](https://terse
225
237
 
226
238
  You can choose between different JS minifiers using the `engine` field:
227
239
 
228
- ```javascript
240
+ ```js
229
241
  const result = await minify(html, {
230
242
  minifyJS: {
231
243
  engine: 'swc', // Use SWC for faster minification
@@ -249,7 +261,7 @@ npm i -D @swc/core
249
261
 
250
262
  You can pass engine-specific configuration options:
251
263
 
252
- ```javascript
264
+ ```js
253
265
  // Using Terser with custom options
254
266
  const result = await minify(html, {
255
267
  minifyJS: {
@@ -269,7 +281,7 @@ const result = await minify(html, {
269
281
 
270
282
  For advanced usage, you can also pass a function:
271
283
 
272
- ```javascript
284
+ ```js
273
285
  const result = await minify(html, {
274
286
  minifyJS: function(text, inline) {
275
287
  // `text`: JavaScript string to minify
@@ -283,7 +295,7 @@ const result = await minify(html, {
283
295
 
284
296
  When `minifySVG` is set to `true`, HTML Minifier Next uses [SVGO](https://svgo.dev/) to optimize inline SVG elements. Complete `<svg>` subtrees are extracted and processed as a block, enabling deep structural optimization:
285
297
 
286
- ```javascript
298
+ ```js
287
299
  const result = await minify(html, {
288
300
  minifySVG: true // Enable with SVGO defaults
289
301
  });
@@ -291,7 +303,7 @@ const result = await minify(html, {
291
303
 
292
304
  You can pass custom SVGO options:
293
305
 
294
- ```javascript
306
+ ```js
295
307
  const result = await minify(html, {
296
308
  minifySVG: {
297
309
  plugins: [{
@@ -316,7 +328,7 @@ const result = await minify(html, {
316
328
 
317
329
  HTML Minifier Next uses in-memory caches to improve performance when processing multiple files or repeated content. The cache sizes can be configured for optimal performance based on your use case:
318
330
 
319
- ```javascript
331
+ ```js
320
332
  const result = await minify(html, {
321
333
  minifyCSS: true,
322
334
  minifyJS: true,
@@ -360,16 +372,41 @@ npx html-minifier-next --minify-css --minify-js --minify-svg input.html
360
372
 
361
373
  * Single file processing: Default `500` is sufficient
362
374
  * Batch processing: Increase to `1000` or higher for better cache hit rates
363
- * Memory-constrained environments: Reduce to `200`–`300` to save memory
375
+ * Memory-constrained environments: Cache sizes can be lowered, though the savings are usually negligible—entries are typically kilobyte-scale, so even full caches only hold a few megabytes
364
376
  * Hundreds/thousands of files: Increase to `1000`–`2000` for optimal performance
365
377
 
366
378
  **Important:**
367
379
 
368
380
  * Cache locking: Caches are created on the first `minify()` call and persist for the process lifetime. Cache sizes are locked after first initialization—subsequent calls reuse the same caches even if different `cacheCSS`, `cacheJS`, or `cacheSVG` options are provided. The first call’s options determine the cache sizes.
369
- * Zero values: Explicit `0` values are coerced to `1` (minimum functional cache size) to avoid immediate eviction. If you want to minimize memory usage, use a small number like `10` or `50` instead of `0`.
381
+ * Zero values: Explicit `0` values are coerced to `1` (minimum functional cache size) to avoid immediate eviction. To keep the cache footprint as small as possible, use a small number like `10` or `50` instead of `0`.
382
+ * Entry size cap: Individual CSS, JavaScript, or SVG blocks larger than 1 MB are minified normally but not stored in the cache—this bounds worst-case cache memory without affecting realistically sized inline content. (This cutoff is fixed and not configurable.)
370
383
 
371
384
  The caches persist across multiple `minify()` calls, making them particularly effective when processing many files in a batch operation.
372
385
 
386
+ **Inspecting cache effectiveness:**
387
+
388
+ Use `getCacheStats()` to see hit/miss counts and current occupancy for each cache:
389
+
390
+ ```js
391
+ import { minify, getCacheStats } from 'html-minifier-next';
392
+
393
+ // After minifying pages that share templated CSS/JS…
394
+ for (const html of pages) {
395
+ await minify(html, { minifyCSS: true, minifyJS: true });
396
+ }
397
+
398
+ console.log(getCacheStats());
399
+ // {
400
+ // css: { gets: 392, hits: 298, size: 94, limit: 500 },
401
+ // js: { gets: 1196, hits: 1192, size: 4, limit: 500 },
402
+ // svg: { gets: 0, hits: 0, size: 0, limit: 500 }
403
+ // }
404
+ ```
405
+
406
+ A cache that was never exercised (e.g., `minifySVG` disabled, or `minify()` not yet called) reports all-zero stats.
407
+
408
+ The CLI’s `--verbose` and `--dry` modes print the same information to STDERR at the end of a run, omitting caches that were never touched.
409
+
373
410
  ## Minification comparison
374
411
 
375
412
  Please see [**the Minifier Benchmarks project**](https://github.com/j9t/minifier-benchmarks) for details on how HTML Minifier Next compares to other minifiers.
@@ -396,7 +433,7 @@ npx html-minifier-next --collapse-whitespace --input-dir=src --output-dir=dist
396
433
  npx html-minifier-next --collapse-whitespace --input-dir=src --output-dir=dist --file-ext=html,php
397
434
 
398
435
  # Using configuration file that sets `fileExt` (e.g., `"fileExt": "html,php"`)
399
- npx html-minifier-next --config-file=html-minifier.json --input-dir=src --output-dir=dist
436
+ npx html-minifier-next --config-file=html-minifier-next.json --input-dir=src --output-dir=dist
400
437
 
401
438
  # Process all files (explicit wildcard)
402
439
  npx html-minifier-next --collapse-whitespace --input-dir=src --output-dir=dist --file-ext='*'
@@ -489,7 +526,7 @@ This minifier includes protection against regular expression denial of service (
489
526
 
490
527
  **Safe patterns** (recommended):
491
528
 
492
- ```javascript
529
+ ```js
493
530
  ignoreCustomFragments: [
494
531
  /<%[\s\S]{0,1000}?%>/, // JSP/ASP with explicit bounds
495
532
  /<\?php[\s\S]{0,5000}?\?>/, // PHP with bounds
@@ -499,7 +536,7 @@ ignoreCustomFragments: [
499
536
 
500
537
  **Potentially unsafe patterns** (will trigger warnings):
501
538
 
502
- ```javascript
539
+ ```js
503
540
  ignoreCustomFragments: [
504
541
  /<%[\s\S]*?%>/, // Unlimited quantifiers
505
542
  /<!--[\s\S]*?-->/, // Could cause issues with very long comments
@@ -510,7 +547,7 @@ ignoreCustomFragments: [
510
547
 
511
548
  **Template engine configurations:**
512
549
 
513
- ```javascript
550
+ ```js
514
551
  // Handlebars/Mustache
515
552
  ignoreCustomFragments: [/\{\{[\s\S]{0,1000}?\}\}/]
516
553
 
@@ -540,7 +577,7 @@ The escaping requirements for `ignoreCustomFragments` patterns differ depending
540
577
 
541
578
  **Programmatic (JavaScript/Node.js):**
542
579
 
543
- ```javascript
580
+ ```js
544
581
  ignoreCustomFragments: [/\{%[\s\S]{0,1000}?%\}/, /\{\{[\s\S]{0,500}?\}\}/]
545
582
  ```
546
583
 
@@ -608,7 +645,7 @@ Parameters:
608
645
  * `--save`: Saves the run as the baseline (e.g., on `main` before switching to a branch)
609
646
  * `--core`: Disables the external minifiers (CSS, JS, SVG, URLs) to isolate HMN’s own processing time
610
647
  * `--iterations=N`: Sets the number of timed iterations (default 5; the median is reported)
611
- * `--config=PATH`: Uses an alternative options file (default `html-minifier.json`)
648
+ * `--config=PATH`: Uses an alternative options file (default `html-minifier-next.json`)
612
649
 
613
650
  To compare branches (A/B run), execute `npm run benchmark -- --save` on `main`, then `npm run benchmark` on the branch to see the deltas. Add `--core` on both ends when measuring changes to HMN’s own code rather than the bundled minifiers.
614
651
 
@@ -630,6 +667,6 @@ With many thanks to the previous authors of and contributors to HTML Minifier, e
630
667
 
631
668
  You might like some of my other work:
632
669
 
633
- * Optimization tools: [hihtml](https://github.com/j9t/hihtml) · HTML Minifier Next · [ObsoHTML](https://github.com/j9t/obsohtml) · [Image Guard](https://github.com/j9t/image-guard) · [Compressor.js Next](https://github.com/j9t/compressorjs-next) · [.htaccess Punk](https://github.com/j9t/htaccess-punk)
670
+ * Optimization tools: [hihtml](https://github.com/j9t/hihtml) · HTML Minifier Next · [ObsoHTML](https://github.com/j9t/obsohtml) · [CSS Dedup](https://github.com/j9t/css-dedup) · [Image Guard](https://github.com/j9t/image-guard) · [Compressor.js Next](https://github.com/j9t/compressorjs-next) · [.htaccess Punk](https://github.com/j9t/htaccess-punk)
634
671
  * Defense tools: [IA Defensa](https://iadefensa.com/solutions/)
635
672
  * Resources for quality web development: [Articles](https://meiert.com/topics/development/) · [Books](https://meiert.com/topics/books/) (including [_On Web Development_](https://meiert.com/blog/on-web-development-2/)) · [News](https://frontenddogma.com/) · [Terminology](https://webglossary.info/)
package/cli.js CHANGED
@@ -227,7 +227,7 @@ async function loadConfigFromPath(configPath) {
227
227
  }
228
228
 
229
229
  // Config keys the CLI handles itself, beyond the options in `optionDefinitions`
230
- const CONFIG_KEYS_EXTRA = new Set(['preset', 'fileExt', 'ignoreDir']);
230
+ const CONFIG_KEYS_EXTRA = new Set(['$schema', 'preset', 'fileExt', 'ignoreDir']);
231
231
 
232
232
  /**
233
233
  * Normalize and validate config object by applying parsers and transforming values.
@@ -283,9 +283,6 @@ program.option('-O --output-dir <dir>', 'Specify an output directory');
283
283
  program.option('-f --file-ext <extensions>', 'Specify file extension(s) to process (comma-separated); defaults to “html,htm,shtml,shtm”; use “*” for all files');
284
284
  program.option('-p --preset <name>', `Use a preset configuration (${getPresetNames().join(', ')})`);
285
285
  program.option('-c --config-file <file>', 'Use config file');
286
- program.option('--cache-css <size>', 'Set CSS minification cache size (number of entries, default: 500)', parseValidInt('cacheCSS'));
287
- program.option('--cache-js <size>', 'Set JavaScript minification cache size (number of entries, default: 500)', parseValidInt('cacheJS'));
288
- program.option('--cache-svg <size>', 'Set SVG minification cache size (number of entries, default: 500)', parseValidInt('cacheSVG'));
289
286
  program.version(pkg.version, '-V, --version', 'Output the version number');
290
287
  program.helpOption('-h, --help', 'Display help for command');
291
288
 
@@ -455,6 +452,26 @@ program.helpOption('-h, --help', 'Display help for command');
455
452
  return { originalSize, minifiedSize, saved, sign, percentage };
456
453
  }
457
454
 
455
+ // Print a one-line-per-cache hits/misses/size summary to STDERR, skipping caches
456
+ // that were never touched (e.g., their minifier is disabled)
457
+ async function printCacheStats() {
458
+ const { getCacheStats } = await import('./src/htmlminifier.js');
459
+ const cacheStats = getCacheStats();
460
+ const labels = { css: 'CSS', js: 'JS', svg: 'SVG' };
461
+
462
+ const lines = Object.keys(labels).reduce((acc, key) => {
463
+ const { gets, hits, size, limit } = cacheStats[key];
464
+ if (gets === 0) return acc;
465
+ const misses = gets - hits;
466
+ acc.push(` ${labels[key]} cache: ${hits.toLocaleString()} hit${hits === 1 ? '' : 's'}, ${misses.toLocaleString()} miss${misses === 1 ? '' : 'es'}, ${size.toLocaleString()}/${limit.toLocaleString()} entries`);
467
+ return acc;
468
+ }, []);
469
+
470
+ if (lines.length === 0) return;
471
+ console.error('Cache stats:');
472
+ lines.forEach(line => console.error(line));
473
+ }
474
+
458
475
  async function processFile(inputFile, outputFile, isDryRun = false, isVerbose = false) {
459
476
  const data = await fs.promises.readFile(inputFile, { encoding: 'utf8' }).catch(err => {
460
477
  fatal('Cannot read ' + inputFile + '\n' + err.message);
@@ -701,6 +718,7 @@ program.helpOption('-h, --help', 'Display help for command');
701
718
  console.error(` Original: ${stats.originalSize.toLocaleString()} bytes`);
702
719
  console.error(` Minified: ${stats.minifiedSize.toLocaleString()} bytes`);
703
720
  console.error(` Saved: ${stats.sign}${Math.abs(stats.saved).toLocaleString()} bytes (${stats.percentage}%)`);
721
+ await printCacheStats();
704
722
  return;
705
723
  }
706
724
 
@@ -708,6 +726,7 @@ program.helpOption('-h, --help', 'Display help for command');
708
726
  if (programOptions.verbose) {
709
727
  const inputSource = program.args.length > 0 ? program.args.join(', ') : 'STDIN';
710
728
  console.error(` ${MARK_SUCCESS}✓${MARK_RESET} ${inputSource}: ${stats.originalSize.toLocaleString()} → ${stats.minifiedSize.toLocaleString()} bytes (${stats.sign}${Math.abs(stats.saved).toLocaleString()}, ${stats.percentage}%)`);
729
+ await printCacheStats();
711
730
  }
712
731
 
713
732
  if (programOptions.output) {
@@ -836,6 +855,10 @@ program.helpOption('-h, --help', 'Display help for command');
836
855
  console.error('---');
837
856
  console.error(`Total: ${totalOriginal.toLocaleString()} → ${totalMinified.toLocaleString()} bytes (${sign}${Math.abs(totalSaved).toLocaleString()}, ${totalPercentage}%)`);
838
857
  }
858
+
859
+ if (isVerbose) {
860
+ await printCacheStats();
861
+ }
839
862
  })();
840
863
  } else if (filesProvided) { // Minifying one or more files specified on the CMD line
841
864
  // Process each file independently, then concatenate outputs
@@ -884,12 +907,14 @@ program.helpOption('-h, --help', 'Display help for command');
884
907
  console.error(` Original: ${stats.originalSize.toLocaleString()} bytes`);
885
908
  console.error(` Minified: ${stats.minifiedSize.toLocaleString()} bytes`);
886
909
  console.error(` Saved: ${stats.sign}${Math.abs(stats.saved).toLocaleString()} bytes (${stats.percentage}%)`);
910
+ await printCacheStats();
887
911
  process.exit(0);
888
912
  }
889
913
 
890
914
  if (programOptions.verbose) {
891
915
  const inputSource = capturedFiles.join(', ');
892
916
  console.error(` ${MARK_SUCCESS}✓${MARK_RESET} ${inputSource}: ${stats.originalSize.toLocaleString()} → ${stats.minifiedSize.toLocaleString()} bytes (${stats.sign}${Math.abs(stats.saved).toLocaleString()}, ${stats.percentage}%)`);
917
+ await printCacheStats();
893
918
  }
894
919
 
895
920
  if (programOptions.output) {
@@ -1,15 +1,4 @@
1
- export function minify(value: string, options?: MinifierOptions): Promise<string>;
2
- declare namespace _default {
3
- export { minify };
4
- export { presets };
5
- export { getPreset };
6
- export { getPresetNames };
7
- }
8
- export default _default;
9
- /**
10
- * Representation of an attribute from the HTML parser.
11
- * Internal counterpart: `HTMLAttribute` in `lib/attributes.js`—keep in sync.
12
- */
1
+ import { presets, getPreset, getPresetNames } from './presets.js';
13
2
  export type HTMLAttribute = {
14
3
  name: string;
15
4
  value?: string;
@@ -18,10 +7,6 @@ export type HTMLAttribute = {
18
7
  customOpen?: string;
19
8
  customClose?: string;
20
9
  };
21
- /**
22
- * Options that control how HTML is minified. All of these are optional
23
- * and usually default to a disabled/safe value unless noted.
24
- */
25
10
  export type MinifierOptions = {
26
11
  /**
27
12
  * Predicate that determines whether whitespace inside a given element
@@ -264,7 +249,7 @@ export type MinifierOptions = {
264
249
  * Default: `false`
265
250
  */
266
251
  minifyJS?: boolean | import("terser").MinifyOptions | {
267
- engine?: "terser" | "swc";
252
+ engine?: 'terser' | 'swc';
268
253
  [key: string]: any;
269
254
  } | ((text: string, inline?: boolean) => Promise<string> | string);
270
255
  /**
@@ -470,8 +455,80 @@ export type MinifierOptions = {
470
455
  */
471
456
  useShortDoctype?: boolean;
472
457
  };
473
- import { presets } from './presets.js';
474
- import { getPreset } from './presets.js';
475
- import { getPresetNames } from './presets.js';
458
+ export type CacheStats = {
459
+ /**
460
+ * Number of lookups attempted against the cache.
461
+ */
462
+ gets: number;
463
+ /**
464
+ * Number of lookups that found a cached entry.
465
+ */
466
+ hits: number;
467
+ /**
468
+ * Number of entries currently held in the cache.
469
+ */
470
+ size: number;
471
+ /**
472
+ * Maximum number of entries the cache can hold.
473
+ */
474
+ limit: number;
475
+ };
476
+ /**
477
+ * Get hit/miss statistics for the CSS, JavaScript, and SVG minification caches.
478
+ *
479
+ * Each cache is created lazily on the first `minify()` call (see `initCaches`); before
480
+ * that first call, or for a cache never exercised (e.g., `minifyCSS` disabled), its
481
+ * entry reports all-zero stats.
482
+ *
483
+ * @returns {{ css: CacheStats, js: CacheStats, svg: CacheStats }}
484
+ */
485
+ export declare function getCacheStats(): {
486
+ css: CacheStats;
487
+ js: CacheStats;
488
+ svg: CacheStats;
489
+ };
490
+ /**
491
+ * @param {string} value
492
+ * @param {MinifierOptions} [options]
493
+ * @returns {Promise<string>}
494
+ */
495
+ export declare const minify: (value: string, options?: MinifierOptions) => Promise<string>;
476
496
  export { presets, getPreset, getPresetNames };
497
+ declare const _default: {
498
+ minify: typeof minify;
499
+ presets: {
500
+ conservative: {
501
+ caseSensitive: boolean;
502
+ collapseBooleanAttributes: boolean;
503
+ collapseWhitespace: boolean;
504
+ conservativeCollapse: boolean;
505
+ preserveLineBreaks: boolean;
506
+ removeComments: boolean;
507
+ removeDefaultTypeAttributes: boolean;
508
+ useShortDoctype: boolean;
509
+ };
510
+ comprehensive: {
511
+ collapseAttributeWhitespace: boolean;
512
+ collapseBooleanAttributes: boolean;
513
+ collapseWhitespace: boolean;
514
+ decodeEntities: boolean;
515
+ mergeScripts: boolean;
516
+ minifyCSS: boolean;
517
+ minifyJS: boolean;
518
+ minifySVG: boolean;
519
+ minifyURLs: boolean;
520
+ removeAttributeQuotes: boolean;
521
+ removeComments: boolean;
522
+ removeDefaultTypeAttributes: boolean;
523
+ removeEmptyAttributes: boolean;
524
+ removeOptionalTags: boolean;
525
+ removeRedundantAttributes: boolean;
526
+ useShortDoctype: boolean;
527
+ };
528
+ };
529
+ getPreset: typeof getPreset;
530
+ getPresetNames: typeof getPresetNames;
531
+ getCacheStats: typeof getCacheStats;
532
+ };
533
+ export default _default;
477
534
  //# sourceMappingURL=htmlminifier.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"htmlminifier.d.ts","sourceRoot":"","sources":["../../src/htmlminifier.js"],"names":[],"mappings":"AA42DO,8BAJI,MAAM,YACN,eAAe,GACb,OAAO,CAAC,MAAM,CAAC,CA0B3B;;;;;;;;;;;;;UAn0DS,MAAM;YACN,MAAM;YACN,MAAM;mBACN,MAAM;iBACN,MAAM;kBACN,MAAM;;;;;;;;;;;;;4BAQN,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,E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@param {string} html
5
- * @param {HTMLParserHandler} handler
6
- */
7
- constructor(html: string, handler: HTMLParserHandler);
8
- html: string;
9
- handler: HTMLParserHandler;
10
- parse(): Promise<void>;
11
- }
12
1
  export type HTMLParserHandler = {
13
2
  start?: Function;
14
3
  end?: Function;
@@ -21,4 +10,15 @@ export type HTMLParserHandler = {
21
10
  customAttrSurround?: RegExp[][] | undefined;
22
11
  customAttrAssign?: RegExp[] | undefined;
23
12
  };
13
+ export declare const endTag: RegExp;
14
+ export declare class HTMLParser {
15
+ html: string;
16
+ handler: HTMLParserHandler;
17
+ /**
18
+ * @param {string} html
19
+ * @param {HTMLParserHandler} handler
20
+ */
21
+ constructor(html: string, handler: HTMLParserHandler);
22
+ parse(): Promise<void>;
23
+ }
24
24
  //# sourceMappingURL=htmlparser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"htmlparser.d.ts","sourceRoot":"","sources":["../../src/htmlparser.js"],"names":[],"mappings":"AAyEA,4BAAkE;AA2HlE;IACE;;;OAGG;IACH,kBAHW,MAAM,WACN,iBAAiB,EAK3B;IAFC,aAAgB;IAChB,2BAAsB;IAGxB,uBA4nBC;CACF;gCA7zBY;IACR,KAAK,CAAC,WAAW;IACjB,GAAG,CAAC,WAAW;IACf,KAAK,CAAC,WAAW;IACjB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,WAAW;IACnB,oBAAoB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC3C,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACpC,YAAY,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACnC,kBAAkB,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,SAAS,CAAC;IAC5C,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAA;CACxC"}
1
+ {"version":3,"file":"htmlparser.d.ts","sourceRoot":"","sources":["../../src/htmlparser.js"],"names":[],"mappings":"AAcG,YAWG,iBAAiB,GAXV;IACR,KAAK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