html-minifier-next 7.2.0 → 7.4.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.
- package/README.md +49 -24
- package/cli.js +40 -1
- package/dist/types/htmlminifier.d.ts +77 -20
- package/dist/types/htmlminifier.d.ts.map +1 -1
- package/dist/types/htmlparser.d.ts +11 -11
- package/dist/types/htmlparser.d.ts.map +1 -1
- package/dist/types/lib/attributes.d.ts +36 -38
- package/dist/types/lib/attributes.d.ts.map +1 -1
- package/dist/types/lib/constants.d.ts +97 -100
- package/dist/types/lib/constants.d.ts.map +1 -1
- package/dist/types/lib/content.d.ts +7 -6
- package/dist/types/lib/content.d.ts.map +1 -1
- package/dist/types/lib/elements.d.ts +13 -18
- package/dist/types/lib/elements.d.ts.map +1 -1
- package/dist/types/lib/option-definitions.d.ts +202 -299
- package/dist/types/lib/option-definitions.d.ts.map +1 -1
- package/dist/types/lib/options.d.ts +7 -14
- package/dist/types/lib/options.d.ts.map +1 -1
- package/dist/types/lib/urls.d.ts +10 -2
- package/dist/types/lib/urls.d.ts.map +1 -1
- package/dist/types/lib/utils.d.ts +30 -10
- package/dist/types/lib/utils.d.ts.map +1 -1
- package/dist/types/lib/whitespace.d.ts +7 -6
- package/dist/types/lib/whitespace.d.ts.map +1 -1
- package/dist/types/presets.d.ts +39 -37
- package/dist/types/presets.d.ts.map +1 -1
- package/dist/types/tokenchain.d.ts +13 -11
- package/dist/types/tokenchain.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/htmlminifier.js +34 -1
- package/src/lib/options.js +43 -31
- package/src/lib/urls.js +1 -1
- package/src/lib/utils.js +14 -0
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Internal counterpart of the public typedef in `htmlminifier.js`—keep in sync.
|
|
3
|
-
*/
|
|
1
|
+
import type { ProcessedOptions } from './options.js';
|
|
4
2
|
export type HTMLAttribute = {
|
|
5
3
|
name: string;
|
|
6
4
|
value?: string | undefined;
|
|
@@ -13,97 +11,106 @@ export type HTMLAttribute = {
|
|
|
13
11
|
* @param {string} text
|
|
14
12
|
* @param {ProcessedOptions} options
|
|
15
13
|
*/
|
|
16
|
-
|
|
14
|
+
declare function isIgnoredComment(text: string, options: ProcessedOptions): boolean;
|
|
17
15
|
/**
|
|
18
16
|
* @param {string} attrName
|
|
19
17
|
* @param {{customEventAttributes?: RegExp[]}} options
|
|
20
18
|
*/
|
|
21
|
-
|
|
19
|
+
declare function isEventAttribute(attrName: string, options: {
|
|
22
20
|
customEventAttributes?: RegExp[];
|
|
23
21
|
}): boolean;
|
|
24
22
|
/** @param {string} value */
|
|
25
|
-
|
|
23
|
+
declare function canRemoveAttributeQuotes(value: string): boolean;
|
|
26
24
|
/**
|
|
27
25
|
* @param {HTMLAttribute[]} attributes
|
|
28
26
|
* @param {string} attribute
|
|
29
27
|
*/
|
|
30
|
-
|
|
28
|
+
declare function attributesInclude(attributes: HTMLAttribute[], attribute: string): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Remove duplicate attributes from an attribute list.
|
|
31
|
+
* Per HTML spec, when an attribute appears multiple times, the first occurrence wins.
|
|
32
|
+
* Duplicate attributes result in invalid HTML, so only the first is kept.
|
|
33
|
+
* @param {HTMLAttribute[]} attrs - Array of attribute objects with `name` property
|
|
34
|
+
* @param {boolean} caseSensitive - Whether to compare names case-sensitively (for XML/SVG)
|
|
35
|
+
* @returns {HTMLAttribute[]} Deduplicated attribute array (modifies in place and returns)
|
|
36
|
+
*/
|
|
37
|
+
declare function deduplicateAttributes(attrs: HTMLAttribute[], caseSensitive: boolean): HTMLAttribute[];
|
|
31
38
|
/**
|
|
32
39
|
* @param {string} tag
|
|
33
40
|
* @param {string} attrName
|
|
34
41
|
* @param {string} attrValue
|
|
35
42
|
* @param {HTMLAttribute[]} attrs
|
|
36
43
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
declare function isAttributeRedundant(tag: string, attrName: string, attrValue: string, attrs: HTMLAttribute[]): boolean;
|
|
45
|
+
declare function isScriptTypeAttribute(attrValue?: string): boolean;
|
|
46
|
+
declare function keepScriptTypeAttribute(attrValue?: string): boolean;
|
|
40
47
|
/**
|
|
41
48
|
* @param {string} tag
|
|
42
49
|
* @param {HTMLAttribute[]} attrs
|
|
43
50
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
51
|
+
declare function isExecutableScript(tag: string, attrs: HTMLAttribute[]): boolean;
|
|
52
|
+
declare function isStyleLinkTypeAttribute(attrValue?: string): boolean;
|
|
46
53
|
/**
|
|
47
54
|
* @param {string} tag
|
|
48
55
|
* @param {HTMLAttribute[]} attrs
|
|
49
56
|
*/
|
|
50
|
-
|
|
57
|
+
declare function isStyleElement(tag: string, attrs: HTMLAttribute[]): boolean;
|
|
51
58
|
/**
|
|
52
59
|
* @param {string} attrName
|
|
53
60
|
* @param {string} attrValue
|
|
54
61
|
*/
|
|
55
|
-
|
|
62
|
+
declare function isBooleanAttribute(attrName: string, attrValue: string): boolean | undefined;
|
|
56
63
|
/**
|
|
57
64
|
* @param {string} attrName
|
|
58
65
|
* @param {string} tag
|
|
59
66
|
*/
|
|
60
|
-
|
|
67
|
+
declare function isUriTypeAttribute(attrName: string, tag: string): boolean;
|
|
61
68
|
/**
|
|
62
69
|
* @param {string} attrName
|
|
63
70
|
* @param {string} tag
|
|
64
71
|
*/
|
|
65
|
-
|
|
72
|
+
declare function isNumberTypeAttribute(attrName: string, tag: string): boolean;
|
|
66
73
|
/**
|
|
67
74
|
* @param {string} tag
|
|
68
75
|
* @param {HTMLAttribute[]} attrs
|
|
69
76
|
* @param {string} value
|
|
70
77
|
*/
|
|
71
|
-
|
|
78
|
+
declare function isLinkType(tag: string, attrs: HTMLAttribute[], value: string): boolean;
|
|
72
79
|
/**
|
|
73
80
|
* @param {string} tag
|
|
74
81
|
* @param {HTMLAttribute[]} attrs
|
|
75
82
|
* @param {string} attrName
|
|
76
83
|
*/
|
|
77
|
-
|
|
84
|
+
declare function isMediaQuery(tag: string, attrs: HTMLAttribute[], attrName: string): boolean;
|
|
78
85
|
/**
|
|
79
86
|
* @param {string} attrName
|
|
80
87
|
* @param {string} tag
|
|
81
88
|
*/
|
|
82
|
-
|
|
89
|
+
declare function isSrcset(attrName: string, tag: string): boolean;
|
|
83
90
|
/**
|
|
84
91
|
* @param {string} tag
|
|
85
92
|
* @param {HTMLAttribute[]} attrs
|
|
86
93
|
*/
|
|
87
|
-
|
|
94
|
+
declare function isMetaViewport(tag: string, attrs: HTMLAttribute[]): boolean;
|
|
88
95
|
/**
|
|
89
96
|
* @param {string} tag
|
|
90
97
|
* @param {HTMLAttribute[]} attrs
|
|
91
98
|
*/
|
|
92
|
-
|
|
99
|
+
declare function isContentSecurityPolicy(tag: string, attrs: HTMLAttribute[]): boolean;
|
|
93
100
|
/**
|
|
94
101
|
* @param {string} tag
|
|
95
102
|
* @param {string} attrName
|
|
96
103
|
* @param {string | undefined} attrValue
|
|
97
104
|
* @param {{removeEmptyAttributes?: boolean | Function}} options
|
|
98
105
|
*/
|
|
99
|
-
|
|
106
|
+
declare function canDeleteEmptyAttribute(tag: string, attrName: string, attrValue: string | undefined, options: {
|
|
100
107
|
removeEmptyAttributes?: boolean | Function;
|
|
101
108
|
}): any;
|
|
102
109
|
/**
|
|
103
110
|
* @param {string} name
|
|
104
111
|
* @param {HTMLAttribute[]} attrs
|
|
105
112
|
*/
|
|
106
|
-
|
|
113
|
+
declare function hasAttrName(name: string, attrs: HTMLAttribute[]): boolean;
|
|
107
114
|
/**
|
|
108
115
|
* @param {string} tag
|
|
109
116
|
* @param {string} attrName
|
|
@@ -112,7 +119,7 @@ export function hasAttrName(name: string, attrs: HTMLAttribute[]): boolean;
|
|
|
112
119
|
* @param {HTMLAttribute[]} attrs
|
|
113
120
|
* @param {Function} minifyHTMLSelf
|
|
114
121
|
*/
|
|
115
|
-
|
|
122
|
+
declare function cleanAttributeValue(tag: string, attrName: string, attrValue: string, options: ProcessedOptions, attrs: HTMLAttribute[], minifyHTMLSelf: Function): any;
|
|
116
123
|
/**
|
|
117
124
|
* @param {HTMLAttribute} attr
|
|
118
125
|
* @param {HTMLAttribute[]} attrs
|
|
@@ -120,15 +127,15 @@ export function cleanAttributeValue(tag: string, attrName: string, attrValue: st
|
|
|
120
127
|
* @param {ProcessedOptions} options
|
|
121
128
|
* @param {Function} minifyHTML
|
|
122
129
|
*/
|
|
123
|
-
|
|
130
|
+
declare function normalizeAttr(attr: HTMLAttribute, attrs: HTMLAttribute[], tag: string, options: ProcessedOptions, minifyHTML: Function): PromiseLike<{
|
|
124
131
|
attr: HTMLAttribute;
|
|
125
132
|
name: string;
|
|
126
133
|
value: string | undefined;
|
|
127
|
-
} |
|
|
134
|
+
} | undefined> | {
|
|
128
135
|
attr: HTMLAttribute;
|
|
129
136
|
name: string;
|
|
130
137
|
value: string | undefined;
|
|
131
|
-
} | undefined
|
|
138
|
+
} | undefined;
|
|
132
139
|
/**
|
|
133
140
|
* @param {{name: string, value: string | undefined, attr: HTMLAttribute}} normalized
|
|
134
141
|
* @param {string | boolean | undefined} hasUnarySlash
|
|
@@ -136,19 +143,10 @@ export function normalizeAttr(attr: HTMLAttribute, attrs: HTMLAttribute[], tag:
|
|
|
136
143
|
* @param {boolean} isLast
|
|
137
144
|
* @param {string | undefined} uidAttr
|
|
138
145
|
*/
|
|
139
|
-
|
|
146
|
+
declare function buildAttr(normalized: {
|
|
140
147
|
name: string;
|
|
141
148
|
value: string | undefined;
|
|
142
149
|
attr: HTMLAttribute;
|
|
143
150
|
}, hasUnarySlash: string | boolean | undefined, options: ProcessedOptions, isLast: boolean, uidAttr: string | undefined): string;
|
|
144
|
-
|
|
145
|
-
* Remove duplicate attributes from an attribute list.
|
|
146
|
-
* Per HTML spec, when an attribute appears multiple times, the first occurrence wins.
|
|
147
|
-
* Duplicate attributes result in invalid HTML, so only the first is kept.
|
|
148
|
-
* @param {HTMLAttribute[]} attrs - Array of attribute objects with `name` property
|
|
149
|
-
* @param {boolean} caseSensitive - Whether to compare names case-sensitively (for XML/SVG)
|
|
150
|
-
* @returns {HTMLAttribute[]} Deduplicated attribute array (modifies in place and returns)
|
|
151
|
-
*/
|
|
152
|
-
export function deduplicateAttributes(attrs: HTMLAttribute[], caseSensitive: boolean): HTMLAttribute[];
|
|
153
|
-
import type { ProcessedOptions } from './options.js';
|
|
151
|
+
export { isIgnoredComment, isEventAttribute, canRemoveAttributeQuotes, attributesInclude, isAttributeRedundant, isScriptTypeAttribute, keepScriptTypeAttribute, isExecutableScript, isStyleLinkTypeAttribute, isStyleElement, isBooleanAttribute, isUriTypeAttribute, isNumberTypeAttribute, isLinkType, isMediaQuery, isSrcset, isMetaViewport, isContentSecurityPolicy, canDeleteEmptyAttribute, hasAttrName, cleanAttributeValue, normalizeAttr, buildAttr, deduplicateAttributes };
|
|
154
152
|
//# sourceMappingURL=attributes.d.ts.map
|
|
@@ -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":"AAqBI,OAAQ,KAAA,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAKjD,YAA0I,aAAa,GAA7I;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAE1I;AAeD;;;GAGG;AACH,iBAAS,gBAAgB,CAAC,IAAI,EAHnB,MAGmB,EAAE,OAAO,EAF5B,gBAE4B,WAOtC;AAED;;;GAGG;AACH,iBAAS,gBAAgB,CAAC,QAAQ,EAHvB,MAGuB,EAAE,OAAO,EAFhC;IAAC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
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
export
|
|
98
|
-
export const htmlElements: Set<string>;
|
|
99
|
-
export const reEmptyAttribute: RegExp;
|
|
100
|
-
export const specialContentElements: Set<string>;
|
|
1
|
+
declare const RE_WS_START: RegExp;
|
|
2
|
+
declare const RE_WS_END: RegExp;
|
|
3
|
+
declare const RE_ALL_WS_NBSP: RegExp;
|
|
4
|
+
declare const RE_NBSP_LEADING_GROUP: RegExp;
|
|
5
|
+
declare const RE_NBSP_LEAD_GROUP: RegExp;
|
|
6
|
+
declare const RE_NBSP_TRAILING_GROUP: RegExp;
|
|
7
|
+
declare const RE_NBSP_TRAILING_STRIP: RegExp;
|
|
8
|
+
declare const RE_EVENT_ATTR_DEFAULT: RegExp;
|
|
9
|
+
declare const RE_CAN_REMOVE_ATTR_QUOTES: RegExp;
|
|
10
|
+
declare const RE_TRAILING_SEMICOLON: RegExp;
|
|
11
|
+
declare const RE_AMP_ENTITY: RegExp;
|
|
12
|
+
declare const RE_LEGACY_ENTITIES: RegExp;
|
|
13
|
+
declare const RE_ESCAPE_LT: RegExp;
|
|
14
|
+
declare const RE_ATTR_WS_CHECK: RegExp;
|
|
15
|
+
declare const RE_ATTR_WS_COLLAPSE: RegExp;
|
|
16
|
+
declare const RE_ATTR_WS_TRIM: RegExp;
|
|
17
|
+
declare const inlineElementsToKeepWhitespaceAround: Set<string>;
|
|
18
|
+
declare const inlineElementsToKeepWhitespaceWithin: Set<string>;
|
|
19
|
+
declare const inlineElementsToKeepWhitespace: Set<string>;
|
|
20
|
+
declare const formControlElements: Set<string>;
|
|
21
|
+
declare const generalDefaults: {
|
|
22
|
+
autocorrect: string;
|
|
23
|
+
fetchpriority: string;
|
|
24
|
+
loading: string;
|
|
25
|
+
popovertargetaction: string;
|
|
26
|
+
};
|
|
27
|
+
declare const tagDefaults: {
|
|
28
|
+
area: {
|
|
29
|
+
shape: string;
|
|
30
|
+
};
|
|
31
|
+
button: {
|
|
32
|
+
type: string;
|
|
33
|
+
};
|
|
34
|
+
form: {
|
|
35
|
+
enctype: string;
|
|
36
|
+
method: string;
|
|
37
|
+
};
|
|
38
|
+
html: {
|
|
39
|
+
dir: string;
|
|
40
|
+
};
|
|
41
|
+
img: {
|
|
42
|
+
decoding: string;
|
|
43
|
+
};
|
|
44
|
+
input: {
|
|
45
|
+
colorspace: string;
|
|
46
|
+
type: string;
|
|
47
|
+
};
|
|
48
|
+
link: {
|
|
49
|
+
media: string;
|
|
50
|
+
};
|
|
51
|
+
marquee: {
|
|
52
|
+
behavior: string;
|
|
53
|
+
direction: string;
|
|
54
|
+
};
|
|
55
|
+
meta: {
|
|
56
|
+
media: string;
|
|
57
|
+
};
|
|
58
|
+
source: {
|
|
59
|
+
media: string;
|
|
60
|
+
};
|
|
61
|
+
style: {
|
|
62
|
+
media: string;
|
|
63
|
+
};
|
|
64
|
+
textarea: {
|
|
65
|
+
wrap: string;
|
|
66
|
+
};
|
|
67
|
+
track: {
|
|
68
|
+
kind: string;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
declare const executableScriptsMimetypes: Set<string>;
|
|
72
|
+
declare const keepScriptsMimetypes: Set<string>;
|
|
73
|
+
declare const isSimpleBoolean: Set<string>;
|
|
74
|
+
declare const isBooleanValue: Set<string>;
|
|
75
|
+
declare const collapsibleValues: Map<string, Set<string>>;
|
|
76
|
+
declare const srcsetElements: Set<string>;
|
|
77
|
+
declare const jsonScriptTypes: Set<string>;
|
|
78
|
+
declare const optionalStartTags: Set<string>;
|
|
79
|
+
declare const optionalEndTags: Set<string>;
|
|
80
|
+
declare const headerElements: Set<string>;
|
|
81
|
+
declare const descriptionElements: Set<string>;
|
|
82
|
+
declare const pBlockElements: Set<string>;
|
|
83
|
+
declare const pInlineElements: Set<string>;
|
|
84
|
+
declare const rubyEndTagOmission: Set<string>;
|
|
85
|
+
declare const rubyRtcEndTagOmission: Set<string>;
|
|
86
|
+
declare const optionElements: Set<string>;
|
|
87
|
+
declare const tableContentElements: Set<string>;
|
|
88
|
+
declare const tableSectionElements: Set<string>;
|
|
89
|
+
declare const cellElements: Set<string>;
|
|
90
|
+
declare const topLevelElements: Set<string>;
|
|
91
|
+
declare const compactElements: Set<string>;
|
|
92
|
+
declare const looseElements: Set<string>;
|
|
93
|
+
declare const trailingElements: Set<string>;
|
|
94
|
+
declare const htmlElements: Set<string>;
|
|
95
|
+
declare const reEmptyAttribute: RegExp;
|
|
96
|
+
declare const specialContentElements: Set<string>;
|
|
97
|
+
export { RE_WS_START, RE_WS_END, RE_ALL_WS_NBSP, RE_NBSP_LEADING_GROUP, RE_NBSP_LEAD_GROUP, RE_NBSP_TRAILING_GROUP, RE_NBSP_TRAILING_STRIP, RE_EVENT_ATTR_DEFAULT, RE_CAN_REMOVE_ATTR_QUOTES, RE_TRAILING_SEMICOLON, RE_AMP_ENTITY, RE_LEGACY_ENTITIES, RE_ESCAPE_LT, RE_ATTR_WS_CHECK, RE_ATTR_WS_COLLAPSE, RE_ATTR_WS_TRIM, inlineElementsToKeepWhitespaceAround, inlineElementsToKeepWhitespaceWithin, inlineElementsToKeepWhitespace, formControlElements, generalDefaults, tagDefaults, executableScriptsMimetypes, keepScriptsMimetypes, jsonScriptTypes, isSimpleBoolean, isBooleanValue, collapsibleValues, srcsetElements, optionalStartTags, optionalEndTags, headerElements, descriptionElements, pBlockElements, pInlineElements, rubyEndTagOmission, rubyRtcEndTagOmission, optionElements, tableContentElements, tableSectionElements, cellElements, topLevelElements, compactElements, looseElements, trailingElements, htmlElements, reEmptyAttribute, specialContentElements };
|
|
101
98
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/lib/constants.js"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/lib/constants.js"],"names":[],"mappings":"AAEA,QAAA,MAAM,WAAW,QAAkB,CAAC;AACpC,QAAA,MAAM,SAAS,QAAkB,CAAC;AAClC,QAAA,MAAM,cAAc,QAAsB,CAAC;AAC3C,QAAA,MAAM,qBAAqB,QAAuB,CAAC;AACnD,QAAA,MAAM,kBAAkB,QAAqB,CAAC;AAC9C,QAAA,MAAM,sBAAsB,QAAqB,CAAC;AAClD,QAAA,MAAM,sBAAsB,QAAc,CAAC;AAC3C,QAAA,MAAM,qBAAqB,QAAkB,CAAC;AAC9C,QAAA,MAAM,yBAAyB,QAA0B,CAAC;AAC1D,QAAA,MAAM,qBAAqB,QAAO,CAAC;AACnC,QAAA,MAAM,aAAa,QAAwB,CAAC;AAC5C,QAAA,MAAM,kBAAkB,QAA+oB,CAAC;AACxqB,QAAA,MAAM,YAAY,QAAO,CAAC;AAC1B,QAAA,MAAM,gBAAgB,QAAgB,CAAC;AACvC,QAAA,MAAM,mBAAmB,QAAkB,CAAC;AAC5C,QAAA,MAAM,eAAe,QAAiC,CAAC;AAKvD,QAAA,MAAM,oCAAoC,aAAqY,CAAC;AAGhb,QAAA,MAAM,oCAAoC,aAAkM,CAAC;AAG7O,QAAA,MAAM,8BAA8B,aAA8C,CAAC;AAGnF,QAAA,MAAM,mBAAmB,aAAoF,CAAC;AAK9G,QAAA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C,CAAC;AAE3D,QAAA,MAAM,eAAe,aAA4B,CAAC;AAElD,QAAA,MAAM,aAAa,aAA2C,CAAC;AAE/D,QAAA,MAAM,gBAAgB,aAA2B,CAAC;AAElD,QAAA,MAAM,YAAY,aAAgwC,CAAC;AAInxC,QAAA,MAAM,gBAAgB,QAE+B,CAAC;AAItD,QAAA,MAAM,sBAAsB,aAA+B,CAAC;AAI5D,OAAO,EAEL,WAAW,EACX,SAAS,EACT,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,yBAAyB,EACzB,qBAAqB,EACrB,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EAEf,oCAAoC,EACpC,oCAAoC,EACpC,8BAA8B,EAC9B,mBAAmB,EAGnB,eAAe,EACf,WAAW,EAGX,0BAA0B,EAC1B,oBAAoB,EACpB,eAAe,EAGf,eAAe,EACf,cAAc,EACd,iBAAiB,EAGjB,cAAc,EAGd,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,YAAY,EAGZ,gBAAgB,EAChB,sBAAsB,EACvB,CAAC"}
|
|
@@ -1,24 +1,25 @@
|
|
|
1
|
+
import type { ProcessedOptions } from './options.js';
|
|
1
2
|
/** @import { ProcessedOptions } from './options.js' */
|
|
2
3
|
/**
|
|
3
4
|
* @param {string} text
|
|
4
5
|
* @param {string} [type]
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
+
declare function wrapCSS(text: string, type?: string): string;
|
|
7
8
|
/**
|
|
8
9
|
* @param {string} text
|
|
9
10
|
* @param {string} [type]
|
|
10
11
|
*/
|
|
11
|
-
|
|
12
|
+
declare function unwrapCSS(text: string, type?: string): string;
|
|
12
13
|
/**
|
|
13
14
|
* @param {string} text
|
|
14
15
|
* @param {{continueOnMinifyError?: boolean, log?: Function}} options
|
|
15
16
|
*/
|
|
16
|
-
|
|
17
|
+
declare function minifyJson(text: string, options: {
|
|
17
18
|
continueOnMinifyError?: boolean;
|
|
18
19
|
log?: Function;
|
|
19
20
|
}): string;
|
|
20
21
|
/** @param {Array<{name: string, value?: string}>} attrs */
|
|
21
|
-
|
|
22
|
+
declare function hasJsonScriptType(attrs: Array<{
|
|
22
23
|
name: string;
|
|
23
24
|
value?: string;
|
|
24
25
|
}>): boolean;
|
|
@@ -28,9 +29,9 @@ export function hasJsonScriptType(attrs: Array<{
|
|
|
28
29
|
* @param {Array<{name: string, value?: string | undefined}>} currentAttrs
|
|
29
30
|
* @param {Function} minifyHTML
|
|
30
31
|
*/
|
|
31
|
-
|
|
32
|
+
declare function processScript(text: string, options: ProcessedOptions, currentAttrs: Array<{
|
|
32
33
|
name: string;
|
|
33
34
|
value?: string | undefined;
|
|
34
35
|
}>, minifyHTML: Function): Promise<any>;
|
|
35
|
-
|
|
36
|
+
export { wrapCSS, unwrapCSS, minifyJson, hasJsonScriptType, processScript };
|
|
36
37
|
//# sourceMappingURL=content.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../../src/lib/content.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../../src/lib/content.js"],"names":[],"mappings":"AAKI,OAAQ,KAAA,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAApD,uDAAuD;AAMvD;;;GAGG;AACH,iBAAS,OAAO,CAAC,IAAI,EAHV,MAGU,EAAE,IAAI,AAFxB,CAAsB,EAAd,MAEgB,UAS1B;AAED;;;GAGG;AACH,iBAAS,SAAS,CAAC,IAAI,EAHZ,MAGY,EAAE,IAAI,AAF1B,CAAsB,EAAd,MAEkB,UAW5B;AAID;;;GAGG;AACH,iBAAS,UAAU,CAAC,IAAI,EAHb,MAGa,EAAE,OAAO,EAFtB;IAAC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAAC,GAAG,CAAC,WAAU;CAE1B,UAWhC;AAED,2DAA2D;AAC3D,iBAAS,iBAAiB,CAAC,KAAK,EADpB,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAC,CAChB,WAU/B;AAED;;;;;GAKG;AACH,iBAAe,aAAa,CAAC,IAAI,EALtB,MAKsB,EAAE,OAAO,EAJ/B,gBAI+B,EAAE,YAAY,EAH7C,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAC,CAGH,EAAE,UAAU,UAAA,gBAiBnE;AAID,OAAO,EAEL,OAAO,EACP,SAAS,EAGT,UAAU,EACV,iBAAiB,EACjB,aAAa,EACd,CAAC"}
|
|
@@ -1,46 +1,44 @@
|
|
|
1
|
+
import type { HTMLAttribute } from './attributes.js';
|
|
2
|
+
import type { ProcessedOptions } from './options.js';
|
|
1
3
|
/** @import { HTMLAttribute } from './attributes.js' */
|
|
2
4
|
/** @import { ProcessedOptions } from './options.js' */
|
|
3
5
|
/**
|
|
4
6
|
* @param {string} optionalStartTag
|
|
5
7
|
* @param {string} tag
|
|
6
8
|
*/
|
|
7
|
-
|
|
9
|
+
declare function canRemoveParentTag(optionalStartTag: string, tag: string): boolean;
|
|
8
10
|
/**
|
|
9
11
|
* @param {string} optionalEndTag
|
|
10
12
|
* @param {string} tag
|
|
11
13
|
*/
|
|
12
|
-
|
|
14
|
+
declare function isStartTagMandatory(optionalEndTag: string, tag: string): boolean;
|
|
13
15
|
/**
|
|
14
16
|
* @param {string} optionalEndTag
|
|
15
17
|
* @param {string} tag
|
|
16
18
|
*/
|
|
17
|
-
|
|
19
|
+
declare function canRemovePrecedingTag(optionalEndTag: string, tag: string): boolean;
|
|
18
20
|
/**
|
|
19
21
|
* @param {string} tag
|
|
20
22
|
* @param {HTMLAttribute[]} attrs
|
|
21
23
|
*/
|
|
22
|
-
|
|
24
|
+
declare function canRemoveElement(tag: string, attrs: HTMLAttribute[]): boolean;
|
|
23
25
|
/**
|
|
24
26
|
* @param {string} str - Tag name or HTML-like element spec (e.g., “td” or “<span aria-hidden='true'>”)
|
|
25
27
|
* @param {ProcessedOptions} options - Options object for name normalization
|
|
26
28
|
* @returns {{tag: string, attrs: Object.<string, string|undefined>|null}|null} Parsed spec or null if invalid
|
|
27
29
|
*/
|
|
28
|
-
|
|
30
|
+
declare function parseElementSpec(str: string, options: ProcessedOptions): {
|
|
29
31
|
tag: string;
|
|
30
|
-
attrs:
|
|
31
|
-
[x: string]: string | undefined;
|
|
32
|
-
} | null;
|
|
32
|
+
attrs: Record<string, string | undefined> | null;
|
|
33
33
|
} | null;
|
|
34
34
|
/**
|
|
35
35
|
* @param {string[]} input - Array of element specifications from `removeEmptyElementsExcept` option
|
|
36
36
|
* @param {ProcessedOptions} options - Options object for parsing
|
|
37
37
|
* @returns {Array<{tag: string, attrs: Object.<string, string|undefined>|null}>} Array of parsed element specs
|
|
38
38
|
*/
|
|
39
|
-
|
|
39
|
+
declare function parseRemoveEmptyElementsExcept(input: string[], options: ProcessedOptions): Array<{
|
|
40
40
|
tag: string;
|
|
41
|
-
attrs:
|
|
42
|
-
[x: string]: string | undefined;
|
|
43
|
-
} | null;
|
|
41
|
+
attrs: Record<string, string | undefined> | null;
|
|
44
42
|
}>;
|
|
45
43
|
/**
|
|
46
44
|
* @param {string} tag - Element tag name
|
|
@@ -48,12 +46,9 @@ export function parseRemoveEmptyElementsExcept(input: string[], options: Process
|
|
|
48
46
|
* @param {Array<{tag: string, attrs: Object.<string, string|undefined>|null}>} preserveList - Parsed preserve specs
|
|
49
47
|
* @returns {boolean} True if the empty element should be preserved
|
|
50
48
|
*/
|
|
51
|
-
|
|
49
|
+
declare function shouldPreserveEmptyElement(tag: string, attrs: HTMLAttribute[], preserveList: Array<{
|
|
52
50
|
tag: string;
|
|
53
|
-
attrs:
|
|
54
|
-
[x: string]: string | undefined;
|
|
55
|
-
} | null;
|
|
51
|
+
attrs: Record<string, string | undefined> | null;
|
|
56
52
|
}>): boolean;
|
|
57
|
-
|
|
58
|
-
import type { ProcessedOptions } from './options.js';
|
|
53
|
+
export { canRemoveParentTag, isStartTagMandatory, canRemovePrecedingTag, canRemoveElement, parseElementSpec, parseRemoveEmptyElementsExcept, shouldPreserveEmptyElement };
|
|
59
54
|
//# sourceMappingURL=elements.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elements.d.ts","sourceRoot":"","sources":["../../../src/lib/elements.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"elements.d.ts","sourceRoot":"","sources":["../../../src/lib/elements.js"],"names":[],"mappings":"AAaI,OAAQ,KAAA,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAQ,KAAA,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AADpD,uDAAuD;AACvD,uDAAuD;AAIvD;;;GAGG;AACH,iBAAS,kBAAkB,CAAC,gBAAgB,EAHjC,MAGiC,EAAE,GAAG,EAFtC,MAEsC,WAahD;AAED;;;GAGG;AACH,iBAAS,mBAAmB,CAAC,cAAc,EAHhC,MAGgC,EAAE,GAAG,EAFrC,MAEqC,WAQ/C;AAED;;;GAGG;AACH,iBAAS,qBAAqB,CAAC,cAAc,EAHlC,MAGkC,EAAE,GAAG,EAFvC,MAEuC,WAmCjD;AAID;;;GAGG;AACH,iBAAS,gBAAgB,CAAC,GAAG,EAHlB,MAGkB,EAAE,KAAK,EAFzB,aAAa,EAEY,WAsCnC;AAED;;;;GAIG;AACH,iBAAS,gBAAgB,CAAC,GAAG,EAJlB,MAIkB,EAAE,OAAO,EAH3B,gBAG2B,GAFzB;IAAC,GAAG,EAAE,MAAM,CAA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