@ohos-ports/html-minifier-next 8.4.2-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 (51) hide show
  1. package/LICENSE.txt +23 -0
  2. package/README.md +776 -0
  3. package/cli.js +1209 -0
  4. package/dist/types/htmlminifier.d.ts +556 -0
  5. package/dist/types/htmlminifier.d.ts.map +1 -0
  6. package/dist/types/htmlparser.d.ts +25 -0
  7. package/dist/types/htmlparser.d.ts.map +1 -0
  8. package/dist/types/lib/attributes.d.ts +155 -0
  9. package/dist/types/lib/attributes.d.ts.map +1 -0
  10. package/dist/types/lib/constants.d.ts +110 -0
  11. package/dist/types/lib/constants.d.ts.map +1 -0
  12. package/dist/types/lib/content.d.ts +51 -0
  13. package/dist/types/lib/content.d.ts.map +1 -0
  14. package/dist/types/lib/elements.d.ts +57 -0
  15. package/dist/types/lib/elements.d.ts.map +1 -0
  16. package/dist/types/lib/fragments.d.ts +46 -0
  17. package/dist/types/lib/fragments.d.ts.map +1 -0
  18. package/dist/types/lib/option-definitions.d.ts +33 -0
  19. package/dist/types/lib/option-definitions.d.ts.map +1 -0
  20. package/dist/types/lib/options.d.ts +120 -0
  21. package/dist/types/lib/options.d.ts.map +1 -0
  22. package/dist/types/lib/unused-css.d.ts +46 -0
  23. package/dist/types/lib/unused-css.d.ts.map +1 -0
  24. package/dist/types/lib/urls.d.ts +15 -0
  25. package/dist/types/lib/urls.d.ts.map +1 -0
  26. package/dist/types/lib/utils.d.ts +102 -0
  27. package/dist/types/lib/utils.d.ts.map +1 -0
  28. package/dist/types/lib/whitespace.d.ts +45 -0
  29. package/dist/types/lib/whitespace.d.ts.map +1 -0
  30. package/dist/types/presets.d.ts +49 -0
  31. package/dist/types/presets.d.ts.map +1 -0
  32. package/dist/types/tokenchain.d.ts +26 -0
  33. package/dist/types/tokenchain.d.ts.map +1 -0
  34. package/html-minifier-next.schema.json +306 -0
  35. package/package.json +100 -0
  36. package/src/htmlminifier.js +2294 -0
  37. package/src/htmlparser.js +1069 -0
  38. package/src/lib/attributes.js +928 -0
  39. package/src/lib/constants.js +285 -0
  40. package/src/lib/content.js +190 -0
  41. package/src/lib/elements.js +274 -0
  42. package/src/lib/file-pool.js +177 -0
  43. package/src/lib/fragments.js +274 -0
  44. package/src/lib/option-definitions.js +231 -0
  45. package/src/lib/options.js +730 -0
  46. package/src/lib/unused-css.js +379 -0
  47. package/src/lib/urls.js +155 -0
  48. package/src/lib/utils.js +861 -0
  49. package/src/lib/whitespace.js +321 -0
  50. package/src/presets.js +57 -0
  51. package/src/tokenchain.js +123 -0
@@ -0,0 +1,556 @@
1
+ import { presets, getPreset, getPresetNames } from './presets.js';
2
+ export type HTMLAttribute = {
3
+ name: string;
4
+ value?: string;
5
+ quote?: string;
6
+ customAssign?: string;
7
+ customOpen?: string;
8
+ customClose?: string;
9
+ };
10
+ export type MinifierOptions = {
11
+ /**
12
+ * Predicate that determines whether whitespace inside a given element
13
+ * can be collapsed.
14
+ *
15
+ * Default: Built-in `canCollapseWhitespace` function
16
+ */
17
+ canCollapseWhitespace?: (tag: string, attrs: HTMLAttribute[], canCollapseWhitespace: (tag: string) => boolean) => boolean;
18
+ /**
19
+ * Predicate that determines whether leading/trailing whitespace around
20
+ * the element may be trimmed.
21
+ *
22
+ * Default: Built-in `canTrimWhitespace` function
23
+ */
24
+ canTrimWhitespace?: (tag: string | null, attrs: HTMLAttribute[] | undefined, canTrimWhitespace: (tag: string) => boolean) => boolean;
25
+ /**
26
+ * The maximum number of entries for the CSS minification cache. Higher values
27
+ * improve performance for inputs with repeated CSS (e.g., batch processing).
28
+ * - Cache is created on first `minify()` call and persists for the process lifetime
29
+ * - Cache size is locked after first call—subsequent calls reuse the same cache
30
+ * - `0` switches the cache off; negative and non-finite values fall back to the default size
31
+ *
32
+ * Default: `500`
33
+ */
34
+ cacheCSS?: number;
35
+ /**
36
+ * The maximum number of entries for the JavaScript minification cache. Higher
37
+ * values improve performance for inputs with repeated JavaScript.
38
+ * - Cache is created on first `minify()` call and persists for the process lifetime
39
+ * - Cache size is locked after first call—subsequent calls reuse the same cache
40
+ * - `0` switches the cache off; negative and non-finite values fall back to the default size
41
+ *
42
+ * Default: `500`
43
+ */
44
+ cacheJS?: number;
45
+ /**
46
+ * The maximum number of entries for the SVG minification cache. Higher
47
+ * values improve performance for inputs with repeated SVG content.
48
+ * - Cache is created on first `minify()` call and persists for the process lifetime
49
+ * - Cache size is locked after first call—subsequent calls reuse the same cache
50
+ * - `0` switches the cache off; negative and non-finite values fall back to the default size
51
+ *
52
+ * Default: `500`
53
+ */
54
+ cacheSVG?: number;
55
+ /**
56
+ * When true, tag and attribute names are treated as case-sensitive.
57
+ * Useful for custom HTML tags.
58
+ * If false (default) names are lower-cased via the `name` function.
59
+ *
60
+ * Default: `false`
61
+ */
62
+ caseSensitive?: boolean;
63
+ /**
64
+ * Collapse multiple whitespace characters within attribute values into a
65
+ * single space. Also trims leading and trailing whitespace from attribute
66
+ * values. Applied as an early normalization step before special attribute
67
+ * handlers (CSS minification, class sorting, etc.) run.
68
+ *
69
+ * Default: `false`
70
+ */
71
+ collapseAttributeWhitespace?: boolean;
72
+ /**
73
+ * Collapse boolean attributes to their name only (for example
74
+ * `disabled="disabled"` → `disabled`).
75
+ * See also: https://perfectionkills.com/experimenting-with-html-minifier/#collapse_boolean_attributes
76
+ *
77
+ * Default: `false`
78
+ */
79
+ collapseBooleanAttributes?: boolean;
80
+ /**
81
+ * When false (default) whitespace around `inline` tags is preserved in
82
+ * more cases. When true, whitespace around inline tags may be collapsed.
83
+ * Must also enable `collapseWhitespace` to have effect.
84
+ *
85
+ * Default: `false`
86
+ */
87
+ collapseInlineTagWhitespace?: boolean;
88
+ /**
89
+ * Collapse multiple whitespace characters into one where allowed. Also
90
+ * controls trimming behaviour in several code paths.
91
+ * See also: https://perfectionkills.com/experimenting-with-html-minifier/#collapse_whitespace
92
+ *
93
+ * Default: `false`
94
+ */
95
+ collapseWhitespace?: boolean;
96
+ /**
97
+ * If true, be conservative when collapsing whitespace (preserve more
98
+ * whitespace in edge cases). Affects collapse algorithms.
99
+ * Must also enable `collapseWhitespace` to have effect.
100
+ *
101
+ * Default: `false`
102
+ */
103
+ conservativeCollapse?: boolean;
104
+ /**
105
+ * When set to `false`, minification errors may throw.
106
+ * By default, the minifier will attempt to recover from minification
107
+ * errors, or ignore them and preserve the original content.
108
+ *
109
+ * Default: `true`
110
+ */
111
+ continueOnMinifyError?: boolean;
112
+ /**
113
+ * When true, the parser will attempt to continue on recoverable parse
114
+ * errors. Otherwise, parsing errors may throw.
115
+ *
116
+ * Default: `false`
117
+ */
118
+ continueOnParseError?: boolean;
119
+ /**
120
+ * Array of regexes used to recognise custom attribute assignment
121
+ * operators (e.g., `'<div flex?="{{mode != cover}}"></div>'`).
122
+ * These are concatenated with the built-in assignment patterns.
123
+ *
124
+ * Default: `[]`
125
+ */
126
+ customAttrAssign?: RegExp[];
127
+ /**
128
+ * Regex matching attribute names whose values should be collapsed.
129
+ * Basically used to remove newlines and excess spaces inside attribute values,
130
+ * e.g., `/ng-class/`.
131
+ */
132
+ customAttrCollapse?: RegExp;
133
+ /**
134
+ * Array of `[openRegExp, closeRegExp]` pairs used by the parser to
135
+ * detect custom attribute surround patterns (for non-standard syntaxes,
136
+ * e.g., `<input {{#if value}}checked="checked"{{/if}}>`).
137
+ */
138
+ customAttrSurround?: [RegExp, RegExp][];
139
+ /**
140
+ * Array of regexes used to detect event handler attributes for `minifyJS`
141
+ * (e.g., `ng-click`). The default matches standard `on…` event attributes.
142
+ *
143
+ * Default: `[/^on[a-z]{3,}$/]`
144
+ */
145
+ customEventAttributes?: RegExp[];
146
+ /**
147
+ * Rejects `ignoreCustomFragments` patterns that risk catastrophic backtracking,
148
+ * rather than warning about them: those that compound quantifiers or alternation
149
+ * (`(a+)+`, `(a|b)*`), those that repeat the same unbounded atom twice in a row
150
+ * (`.*.*`), and those too long or too deeply nested to analyze at all.
151
+ *
152
+ * Default: `false`
153
+ */
154
+ strictCustomFragments?: boolean;
155
+ /**
156
+ * When true, decodes HTML entities in text and attributes before
157
+ * processing, and re-encodes ambiguous ampersands when outputting.
158
+ *
159
+ * Default: `false`
160
+ */
161
+ decodeEntities?: boolean;
162
+ /**
163
+ * Comments matching any pattern in this array of regexes will be
164
+ * preserved when `removeComments` is enabled. The default preserves
165
+ * “bang” comments and comments starting with `#`.
166
+ *
167
+ * Default: `[/^!/, /^\s*#/]`
168
+ */
169
+ ignoreCustomComments?: RegExp[];
170
+ /**
171
+ * Array of regexes used to identify fragments that should be
172
+ * preserved (for example server templates). These fragments are temporarily
173
+ * replaced during minification to avoid corrupting template code.
174
+ * The default preserves ASP/PHP-style tags.
175
+ *
176
+ * Default: `[/<%[\s\S]*?%>/, /<\?[\s\S]*?\?>/]`
177
+ */
178
+ ignoreCustomFragments?: RegExp[];
179
+ /**
180
+ * If false, tags marked as auto-generated by the parser will be omitted
181
+ * from output. Useful to skip injected tags.
182
+ *
183
+ * Default: `false`
184
+ */
185
+ includeAutoGeneratedTags?: boolean;
186
+ /**
187
+ * Collection of custom element tag names that should be treated as inline
188
+ * elements for white-space handling, alongside the built-in inline elements.
189
+ *
190
+ * Default: `[]`
191
+ */
192
+ inlineCustomElements?: ArrayLike<string>;
193
+ /**
194
+ * Keep the trailing slash on void elements and other start tags that carry one, and read it
195
+ * as closing the element. The default drops the slash and ignores it, as HTML does; in SVG
196
+ * and MathML a slash closes the element either way.
197
+ *
198
+ * Default: `false`
199
+ */
200
+ keepClosingSlash?: boolean;
201
+ /**
202
+ * Logging function used by the minifier for warnings/errors/info.
203
+ * You can directly provide `console.log`, but `message` may also be an `Error`
204
+ * object or other non-string value.
205
+ *
206
+ * Default: `() => {}` (no-op function)
207
+ */
208
+ log?: (message: unknown) => void;
209
+ /**
210
+ * The maximum allowed input length. Used as a guard against ReDoS via
211
+ * pathological inputs. If the input exceeds this length an error is
212
+ * thrown.
213
+ *
214
+ * Default: No limit
215
+ */
216
+ maxInputLength?: number;
217
+ /**
218
+ * Maximum line length for the output. When set the minifier will wrap
219
+ * output to the given number of characters where possible.
220
+ *
221
+ * Default: No limit
222
+ */
223
+ maxLineLength?: number;
224
+ /**
225
+ * When true, consecutive inline `<script>` elements are merged into one.
226
+ * Only merges compatible scripts (same `type`, matching `async`/`defer`/
227
+ * `nomodule`/`nonce` attributes). Does not merge external scripts (with `src`).
228
+ *
229
+ * Default: `false`
230
+ */
231
+ mergeScripts?: boolean;
232
+ /**
233
+ * When true, enables CSS minification for inline `<style>` tags or
234
+ * `style` attributes. If an object is provided, it is passed to
235
+ * [Lightning CSS](https://www.npmjs.com/package/lightningcss)
236
+ * as transform options. If a function is provided, it will be used to perform
237
+ * custom CSS minification. If disabled, CSS is not minified.
238
+ *
239
+ * Default: `false`
240
+ */
241
+ minifyCSS?: boolean | Partial<import("lightningcss").TransformOptions<import("lightningcss").CustomAtRules>> | ((text: string, type?: string) => Promise<string> | string);
242
+ /**
243
+ * When true, enables JS minification for `<script>` contents and
244
+ * event handler attributes. If an object is provided, it can include:
245
+ * - `engine`: The minifier to use (`terser` or `swc`). Default: `terser`.
246
+ * Note: Inline event handlers (e.g., `onclick="…"`) always use Terser
247
+ * regardless of engine setting, as SWC doesn’t support bare return statements.
248
+ * - Engine-specific options (e.g., Terser options if `engine: 'terser'`,
249
+ * SWC options if `engine: 'swc'`).
250
+ * If a function is provided, it will be used to perform
251
+ * custom JS minification. If disabled, JS is not minified.
252
+ *
253
+ * Default: `false`
254
+ */
255
+ minifyJS?: boolean | import("terser").MinifyOptions | {
256
+ engine?: 'terser' | 'swc';
257
+ [key: string]: any;
258
+ } | ((text: string, inline?: boolean) => Promise<string> | string);
259
+ /**
260
+ * When true, enables URL rewriting/minification. If an object is provided,
261
+ * the `site` property sets the base URL for computing relative paths.
262
+ * If a string is provided, it is treated as an `{ site: string }` options
263
+ * object. If a function is provided, it will be used to perform custom URL
264
+ * minification. If disabled, URLs are not minified.
265
+ *
266
+ * Default: `false`
267
+ */
268
+ minifyURLs?: boolean | string | {
269
+ site?: string;
270
+ } | ((text: string) => Promise<string> | string);
271
+ /**
272
+ * When true, enables SVG minification using [SVGO](https://github.com/svg/svgo).
273
+ * Complete SVG subtrees are extracted and optimized as a block.
274
+ * If an object is provided, it is passed to SVGO as configuration options.
275
+ * If disabled, SVG content is minified using standard HTML rules only.
276
+ *
277
+ * Default: `false`
278
+ */
279
+ minifySVG?: boolean | Object;
280
+ /**
281
+ * When wrapping lines, prevent inserting a newline directly before a
282
+ * closing tag (useful to keep tags like `</a>` on the same line).
283
+ *
284
+ * Default: `false`
285
+ */
286
+ noNewlinesBeforeTagClose?: boolean;
287
+ /**
288
+ * When true, treat input as a partial HTML fragment rather than a complete
289
+ * document. This preserves stray end tags (closing tags without corresponding
290
+ * opening tags) and prevents auto-closing of unclosed tags at the end of input.
291
+ * Useful for minifying template fragments, SSI includes, or other partial HTML
292
+ * that will be combined with other fragments.
293
+ *
294
+ * Default: `false`
295
+ */
296
+ partialMarkup?: boolean;
297
+ /**
298
+ * Preserve a single line break at the start/end of text nodes when
299
+ * collapsing/trimming whitespace.
300
+ * Must also enable `collapseWhitespace` to have effect.
301
+ *
302
+ * Default: `false`
303
+ */
304
+ preserveLineBreaks?: boolean;
305
+ /**
306
+ * Name of a preset configuration to use as a base (`conservative` or
307
+ * `comprehensive`). Explicitly provided options take precedence over
308
+ * preset values. Unknown preset names are ignored (with a warning).
309
+ *
310
+ * Default: No preset
311
+ */
312
+ preset?: string;
313
+ /**
314
+ * When true, attribute values will not be HTML-escaped (dangerous for
315
+ * untrusted input). By default, attributes are escaped.
316
+ *
317
+ * Default: `false`
318
+ */
319
+ preventAttributesEscaping?: boolean;
320
+ /**
321
+ * Array of `type` attribute values for `<script>` elements whose contents
322
+ * should be processed as HTML
323
+ * (e.g., `text/ng-template`, `text/x-handlebars-template`, etc.).
324
+ * When present, the contents of matching script tags are recursively minified,
325
+ * like normal HTML content.
326
+ *
327
+ * Default: `[]`
328
+ */
329
+ processScripts?: string[];
330
+ /**
331
+ * Preferred quote character for attribute values. If unspecified the
332
+ * minifier picks the safest quote based on the attribute value.
333
+ *
334
+ * Default: Auto-detected
335
+ */
336
+ quoteCharacter?: "\"" | "'";
337
+ /**
338
+ * Remove quotes around attribute values where it is safe to do so.
339
+ * See also: https://perfectionkills.com/experimenting-with-html-minifier/#remove_attribute_quotes
340
+ *
341
+ * Default: `false`
342
+ */
343
+ removeAttributeQuotes?: boolean;
344
+ /**
345
+ * Remove HTML comments. Comments that match `ignoreCustomComments` will
346
+ * still be preserved.
347
+ * See also: https://perfectionkills.com/experimenting-with-html-minifier/#remove_comments
348
+ *
349
+ * Default: `false`
350
+ */
351
+ removeComments?: boolean;
352
+ /**
353
+ * Remove default `type` attributes from `<style>`/`<link>` (e.g., `type="text/css"`)
354
+ * and `<script>` (e.g., `type="text/javascript"`) elements.
355
+ *
356
+ * Default: `false`
357
+ */
358
+ removeDefaultTypeAttributes?: boolean;
359
+ /**
360
+ * If true, removes attributes whose values are empty (some attributes
361
+ * are excluded by name). Can also be a function to customise which empty
362
+ * attributes are removed.
363
+ * See also: https://perfectionkills.com/experimenting-with-html-minifier/#remove_empty_or_blank_attributes
364
+ *
365
+ * Default: `false`
366
+ */
367
+ removeEmptyAttributes?: boolean | ((attrName: string, tag: string) => boolean);
368
+ /**
369
+ * Remove elements that are empty and safe to remove (for example
370
+ * `<script />` without `src`).
371
+ * See also: https://perfectionkills.com/experimenting-with-html-minifier/#remove_empty_elements
372
+ *
373
+ * Default: `false`
374
+ */
375
+ removeEmptyElements?: boolean;
376
+ /**
377
+ * Specifies empty elements to preserve when `removeEmptyElements` is enabled.
378
+ * Has no effect unless `removeEmptyElements: true`.
379
+ *
380
+ * Accepts tag names or HTML-like element specifications:
381
+ *
382
+ * * Tag name only: `["td", "span"]`—preserves all empty elements of these types
383
+ * * With valued attributes: `["<span aria-hidden='true'>"]`—preserves only when attribute values match
384
+ * * With boolean attributes: `["<input disabled>"]`—preserves only when boolean attribute is present
385
+ * * Mixed: `["<button type='button' disabled>"]`—all specified attributes must match
386
+ *
387
+ * Attribute matching:
388
+ *
389
+ * * All specified attributes must be present and match (valued attributes must have exact values)
390
+ * * Additional attributes on the element are allowed
391
+ * * Attribute name matching respects the `caseSensitive` option
392
+ * * Supports double quotes, single quotes, and unquoted attribute values in specifications
393
+ *
394
+ * Limitations:
395
+ *
396
+ * * Self-closing syntax (e.g., `["<span/>"]`) is not supported; use `["span"]` instead
397
+ * * Definitions containing `>` within quoted attribute values (e.g., `["<span title='a>b'>"]`) are not supported
398
+ *
399
+ * Default: `[]`
400
+ */
401
+ removeEmptyElementsExcept?: string[];
402
+ /**
403
+ * Drop optional start/end tags where the HTML specification permits it
404
+ * (for example `</li>`, optional `<html>` etc.).
405
+ * See also: https://perfectionkills.com/experimenting-with-html-minifier/#remove_optional_tags
406
+ *
407
+ * Default: `false`
408
+ */
409
+ removeOptionalTags?: boolean;
410
+ /**
411
+ * Remove attributes that are redundant because they match the element’s
412
+ * default values (for example `<button type="submit">`).
413
+ * See also: https://perfectionkills.com/experimenting-with-html-minifier/#remove_redundant_attributes
414
+ *
415
+ * Default: `false`
416
+ */
417
+ removeRedundantAttributes?: boolean;
418
+ /**
419
+ * **Note that this will result in invalid HTML!**
420
+ *
421
+ * When true, extra whitespace between tag name and attributes (or before
422
+ * the closing bracket) will be removed where possible. Affects output spacing
423
+ * such as the space used in the short doctype representation.
424
+ *
425
+ * Default: `false`
426
+ */
427
+ removeTagWhitespace?: boolean;
428
+ /**
429
+ * **Note that this can change how a document renders!**
430
+ *
431
+ * Remove rules from `style` elements whose class or ID selectors the document
432
+ * never references. Requires `minifyCSS` (removal runs through Lightning CSS)
433
+ * and has no effect on `style` or `media` attributes.
434
+ *
435
+ * Class names and IDs are collected from the markup, from `data-*` attributes,
436
+ * and—unless `scripts` is set to `false`—from inline `script` elements. Names
437
+ * that only ever appear in external scripts cannot be detected; list those
438
+ * under `safelist` (strings or regular expressions) to keep them.
439
+ *
440
+ * Default: `false`
441
+ */
442
+ removeUnusedCSS?: boolean | {
443
+ safelist?: Array<string | RegExp>;
444
+ scripts?: boolean;
445
+ };
446
+ /**
447
+ * When true, enables sorting of attributes. If a function is provided it
448
+ * will be used as a custom attribute sorter, which should mutate `attrs`
449
+ * in-place to the desired order. If disabled, the minifier will attempt to
450
+ * preserve the order from the input.
451
+ *
452
+ * Default: `false`
453
+ */
454
+ sortAttributes?: boolean | ((tag: string, attrs: HTMLAttribute[]) => void);
455
+ /**
456
+ * When true, enables sorting of class names inside `class` attributes.
457
+ * If a function is provided, it will be used to transform/sort the class
458
+ * name string. If disabled, the minifier will attempt to preserve the
459
+ * class-name order from the input.
460
+ *
461
+ * Default: `false`
462
+ */
463
+ sortClassNames?: boolean | ((value: string) => string);
464
+ /**
465
+ * When true, whitespace around ignored custom fragments may be trimmed
466
+ * more aggressively. This affects how preserved fragments interact with
467
+ * surrounding whitespace collapse.
468
+ *
469
+ * Default: `false`
470
+ */
471
+ trimCustomFragments?: boolean;
472
+ /**
473
+ * Replace the HTML doctype with the short `<!doctype html>` form.
474
+ * See also: https://perfectionkills.com/experimenting-with-html-minifier/#use_short_doctype
475
+ *
476
+ * Default: `false`
477
+ */
478
+ useShortDoctype?: boolean;
479
+ };
480
+ export type CacheStats = {
481
+ /**
482
+ * Number of lookups attempted against the cache.
483
+ */
484
+ gets: number;
485
+ /**
486
+ * Number of lookups that found a cached entry.
487
+ */
488
+ hits: number;
489
+ /**
490
+ * Number of entries currently held in the cache.
491
+ */
492
+ size: number;
493
+ /**
494
+ * Maximum number of entries the cache can hold.
495
+ */
496
+ limit: number;
497
+ };
498
+ /**
499
+ * Get hit/miss statistics for the CSS, JavaScript, and SVG minification caches.
500
+ *
501
+ * Each cache is created lazily on the first `minify()` call (see `initCaches`); before
502
+ * that first call, or for a cache never exercised (e.g., `minifyCSS` disabled), its
503
+ * entry reports all-zero stats.
504
+ *
505
+ * @returns {{ css: CacheStats, js: CacheStats, svg: CacheStats }}
506
+ */
507
+ export declare function getCacheStats(): {
508
+ css: CacheStats;
509
+ js: CacheStats;
510
+ svg: CacheStats;
511
+ };
512
+ /**
513
+ * @param {string} value
514
+ * @param {MinifierOptions} [options]
515
+ * @returns {Promise<string>}
516
+ */
517
+ export declare const minify: (value: string, options?: MinifierOptions) => Promise<string>;
518
+ export { presets, getPreset, getPresetNames };
519
+ declare const _default: {
520
+ minify: typeof minify;
521
+ presets: {
522
+ conservative: {
523
+ caseSensitive: boolean;
524
+ collapseBooleanAttributes: boolean;
525
+ collapseWhitespace: boolean;
526
+ conservativeCollapse: boolean;
527
+ preserveLineBreaks: boolean;
528
+ removeComments: boolean;
529
+ removeDefaultTypeAttributes: boolean;
530
+ useShortDoctype: boolean;
531
+ };
532
+ comprehensive: {
533
+ collapseAttributeWhitespace: boolean;
534
+ collapseBooleanAttributes: boolean;
535
+ collapseWhitespace: boolean;
536
+ decodeEntities: boolean;
537
+ mergeScripts: boolean;
538
+ minifyCSS: boolean;
539
+ minifyJS: boolean;
540
+ minifySVG: boolean;
541
+ minifyURLs: boolean;
542
+ removeAttributeQuotes: boolean;
543
+ removeComments: boolean;
544
+ removeDefaultTypeAttributes: boolean;
545
+ removeEmptyAttributes: boolean;
546
+ removeOptionalTags: boolean;
547
+ removeRedundantAttributes: boolean;
548
+ useShortDoctype: boolean;
549
+ };
550
+ };
551
+ getPreset: typeof getPreset;
552
+ getPresetNames: typeof getPresetNames;
553
+ getCacheStats: typeof getCacheStats;
554
+ };
555
+ export default _default;
556
+ //# sourceMappingURL=htmlminifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"htmlminifier.d.ts","sourceRoot":"","sources":["../../src/htmlminifier.js"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAsE/D,YAAkB,aAAa,GAI/B;IAAe,IAAI,EAAZ,MAAM,CACb;IAAgB,KAAK,AAArB,CACA,EADO,MAAM,CACb;IAAgB,KAAK,AAArB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type HTMLParserHandler = {
2
+ start?: Function;
3
+ end?: Function;
4
+ chars?: Function;
5
+ comment?: Function;
6
+ doctype?: Function;
7
+ continueOnParseError?: boolean | undefined;
8
+ partialMarkup?: boolean | undefined;
9
+ wantsNextTag?: boolean | undefined;
10
+ selfClosingSlash?: boolean | undefined;
11
+ customAttrSurround?: RegExp[][] | undefined;
12
+ customAttrAssign?: RegExp[] | undefined;
13
+ };
14
+ export declare const endTag: RegExp;
15
+ export declare class HTMLParser {
16
+ html: string;
17
+ handler: HTMLParserHandler;
18
+ /**
19
+ * @param {string} html
20
+ * @param {HTMLParserHandler} handler
21
+ */
22
+ constructor(html: string, handler: HTMLParserHandler);
23
+ parse(): Promise<void>;
24
+ }
25
+ //# sourceMappingURL=htmlparser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"htmlparser.d.ts","sourceRoot":"","sources":["../../src/htmlparser.js"],"names":[],"mappings":"AAeG,YAYG,iBAAiB,GAZV;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,gBAAgB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACvC,kBAAkB,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,SAAS,CAAC;IAC5C,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAA;CACxC,CAAmB;AA0CvB,eAAO,MAAM,MAAM,QAA8C,CAAC;AAoLlE,qBAAa,UAAU;IAMd,IAAI;IACJ,OAAO;IANd;;;OAGG;IACH,YAAY,IAAI,EAHL,MAGK,EAAE,OAAO,EAFd,iBAEc,EAGxB;IAEK,KAAK,kBAwyBV;CACF"}