entities 7.0.0 → 8.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.
- package/dist/decode-codepoint.d.ts +8 -0
- package/dist/decode-codepoint.d.ts.map +1 -0
- package/dist/decode-codepoint.js +46 -0
- package/dist/decode-codepoint.js.map +1 -0
- package/dist/{commonjs/decode.d.ts → decode.d.ts} +11 -20
- package/dist/decode.d.ts.map +1 -0
- package/dist/{esm/decode.js → decode.js} +65 -75
- package/dist/decode.js.map +1 -0
- package/dist/{commonjs/encode.d.ts → encode.d.ts} +2 -0
- package/dist/encode.d.ts.map +1 -0
- package/dist/{esm/encode.js → encode.js} +6 -4
- package/dist/encode.js.map +1 -0
- package/dist/{esm/escape.d.ts → escape.d.ts} +6 -4
- package/dist/escape.d.ts.map +1 -0
- package/dist/{esm/escape.js → escape.js} +15 -17
- package/dist/escape.js.map +1 -0
- package/dist/generated/decode-data-html.d.ts +3 -0
- package/dist/generated/decode-data-html.d.ts.map +1 -0
- package/dist/{esm/generated → generated}/decode-data-html.js +1 -0
- package/dist/generated/decode-data-html.js.map +1 -0
- package/dist/generated/decode-data-xml.d.ts +3 -0
- package/dist/generated/decode-data-xml.d.ts.map +1 -0
- package/dist/{esm/generated → generated}/decode-data-xml.js +1 -0
- package/dist/generated/decode-data-xml.js.map +1 -0
- package/dist/generated/encode-html.d.ts +5 -0
- package/dist/generated/encode-html.d.ts.map +1 -0
- package/dist/{esm/generated → generated}/encode-html.js +2 -1
- package/dist/generated/encode-html.js.map +1 -0
- package/dist/{commonjs/index.d.ts → index.d.ts} +9 -16
- package/dist/index.d.ts.map +1 -0
- package/dist/{esm/index.js → index.js} +7 -23
- package/dist/index.js.map +1 -0
- package/dist/internal/bin-trie-flags.d.ts.map +1 -0
- package/dist/internal/bin-trie-flags.js.map +1 -0
- package/dist/internal/decode-shared.d.ts +7 -0
- package/dist/internal/decode-shared.d.ts.map +1 -0
- package/dist/internal/decode-shared.js +17 -0
- package/dist/internal/decode-shared.js.map +1 -0
- package/dist/{commonjs/internal → internal}/encode-shared.d.ts +1 -0
- package/dist/internal/encode-shared.d.ts.map +1 -0
- package/dist/{esm/internal → internal}/encode-shared.js +4 -2
- package/dist/internal/encode-shared.js.map +1 -0
- package/package.json +33 -63
- package/readme.md +36 -27
- package/src/decode-codepoint.ts +1 -32
- package/src/decode.ts +49 -54
- package/src/encode.ts +2 -0
- package/src/escape.ts +11 -12
- package/src/generated/decode-data-html.ts +1 -0
- package/src/generated/decode-data-xml.ts +1 -0
- package/src/generated/encode-html.ts +2 -1
- package/src/index.ts +8 -33
- package/src/internal/decode-shared.ts +3 -15
- package/src/internal/encode-shared.ts +4 -2
- package/decode.d.ts +0 -3
- package/decode.js +0 -3
- package/dist/commonjs/decode-codepoint.d.ts +0 -19
- package/dist/commonjs/decode-codepoint.d.ts.map +0 -1
- package/dist/commonjs/decode-codepoint.js +0 -77
- package/dist/commonjs/decode-codepoint.js.map +0 -1
- package/dist/commonjs/decode.d.ts.map +0 -1
- package/dist/commonjs/decode.js +0 -568
- package/dist/commonjs/decode.js.map +0 -1
- package/dist/commonjs/encode.d.ts.map +0 -1
- package/dist/commonjs/encode.js +0 -92
- package/dist/commonjs/encode.js.map +0 -1
- package/dist/commonjs/escape.d.ts +0 -46
- package/dist/commonjs/escape.d.ts.map +0 -1
- package/dist/commonjs/escape.js +0 -138
- package/dist/commonjs/escape.js.map +0 -1
- package/dist/commonjs/generated/decode-data-html.d.ts +0 -2
- package/dist/commonjs/generated/decode-data-html.d.ts.map +0 -1
- package/dist/commonjs/generated/decode-data-html.js +0 -7
- package/dist/commonjs/generated/decode-data-html.js.map +0 -1
- package/dist/commonjs/generated/decode-data-xml.d.ts +0 -2
- package/dist/commonjs/generated/decode-data-xml.d.ts.map +0 -1
- package/dist/commonjs/generated/decode-data-xml.js +0 -7
- package/dist/commonjs/generated/decode-data-xml.js.map +0 -1
- package/dist/commonjs/generated/encode-html.d.ts +0 -3
- package/dist/commonjs/generated/encode-html.d.ts.map +0 -1
- package/dist/commonjs/generated/encode-html.js +0 -14
- package/dist/commonjs/generated/encode-html.js.map +0 -1
- package/dist/commonjs/index.d.ts.map +0 -1
- package/dist/commonjs/index.js +0 -131
- package/dist/commonjs/index.js.map +0 -1
- package/dist/commonjs/internal/bin-trie-flags.d.ts.map +0 -1
- package/dist/commonjs/internal/bin-trie-flags.js +0 -21
- package/dist/commonjs/internal/bin-trie-flags.js.map +0 -1
- package/dist/commonjs/internal/decode-shared.d.ts +0 -2
- package/dist/commonjs/internal/decode-shared.d.ts.map +0 -1
- package/dist/commonjs/internal/decode-shared.js +0 -31
- package/dist/commonjs/internal/decode-shared.js.map +0 -1
- package/dist/commonjs/internal/encode-shared.d.ts.map +0 -1
- package/dist/commonjs/internal/encode-shared.js +0 -94
- package/dist/commonjs/internal/encode-shared.js.map +0 -1
- package/dist/commonjs/package.json +0 -3
- package/dist/esm/decode-codepoint.d.ts +0 -19
- package/dist/esm/decode-codepoint.d.ts.map +0 -1
- package/dist/esm/decode-codepoint.js +0 -72
- package/dist/esm/decode-codepoint.js.map +0 -1
- package/dist/esm/decode.d.ts +0 -203
- package/dist/esm/decode.d.ts.map +0 -1
- package/dist/esm/decode.js.map +0 -1
- package/dist/esm/encode.d.ts +0 -22
- package/dist/esm/encode.d.ts.map +0 -1
- package/dist/esm/encode.js.map +0 -1
- package/dist/esm/escape.d.ts.map +0 -1
- package/dist/esm/escape.js.map +0 -1
- package/dist/esm/generated/decode-data-html.d.ts +0 -2
- package/dist/esm/generated/decode-data-html.d.ts.map +0 -1
- package/dist/esm/generated/decode-data-html.js.map +0 -1
- package/dist/esm/generated/decode-data-xml.d.ts +0 -2
- package/dist/esm/generated/decode-data-xml.d.ts.map +0 -1
- package/dist/esm/generated/decode-data-xml.js.map +0 -1
- package/dist/esm/generated/encode-html.d.ts +0 -3
- package/dist/esm/generated/encode-html.d.ts.map +0 -1
- package/dist/esm/generated/encode-html.js.map +0 -1
- package/dist/esm/index.d.ts +0 -96
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/internal/bin-trie-flags.d.ts +0 -17
- package/dist/esm/internal/bin-trie-flags.d.ts.map +0 -1
- package/dist/esm/internal/bin-trie-flags.js.map +0 -1
- package/dist/esm/internal/decode-shared.d.ts +0 -2
- package/dist/esm/internal/decode-shared.d.ts.map +0 -1
- package/dist/esm/internal/decode-shared.js +0 -28
- package/dist/esm/internal/decode-shared.js.map +0 -1
- package/dist/esm/internal/encode-shared.d.ts +0 -32
- package/dist/esm/internal/encode-shared.d.ts.map +0 -1
- package/dist/esm/internal/encode-shared.js.map +0 -1
- package/dist/esm/package.json +0 -3
- package/escape.d.ts +0 -3
- package/escape.js +0 -3
- package/src/decode.spec.ts +0 -363
- package/src/encode.spec.ts +0 -78
- package/src/escape.spec.ts +0 -14
- package/src/generated/.eslintrc.json +0 -10
- package/src/index.spec.ts +0 -125
- /package/dist/{commonjs/internal → internal}/bin-trie-flags.d.ts +0 -0
- /package/dist/{esm/internal → internal}/bin-trie-flags.js +0 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Replace the given code point with a replacement character if it is a
|
|
3
|
+
* surrogate or is outside the valid range. Otherwise return the code
|
|
4
|
+
* point unchanged.
|
|
5
|
+
* @param codePoint Unicode code point to convert.
|
|
6
|
+
*/
|
|
7
|
+
export declare function replaceCodePoint(codePoint: number): number;
|
|
8
|
+
//# sourceMappingURL=decode-codepoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode-codepoint.d.ts","sourceRoot":"","sources":["../src/decode-codepoint.ts"],"names":[],"mappings":"AAkCA;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAS1D"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Adapted from https://github.com/mathiasbynens/he/blob/36afe179392226cf1b6ccdb16ebbb7a5a844d93a/src/he.js#L106-L134
|
|
2
|
+
const decodeMap = new Map([
|
|
3
|
+
[0, 65_533],
|
|
4
|
+
// C1 Unicode control character reference replacements
|
|
5
|
+
[128, 8364],
|
|
6
|
+
[130, 8218],
|
|
7
|
+
[131, 402],
|
|
8
|
+
[132, 8222],
|
|
9
|
+
[133, 8230],
|
|
10
|
+
[134, 8224],
|
|
11
|
+
[135, 8225],
|
|
12
|
+
[136, 710],
|
|
13
|
+
[137, 8240],
|
|
14
|
+
[138, 352],
|
|
15
|
+
[139, 8249],
|
|
16
|
+
[140, 338],
|
|
17
|
+
[142, 381],
|
|
18
|
+
[145, 8216],
|
|
19
|
+
[146, 8217],
|
|
20
|
+
[147, 8220],
|
|
21
|
+
[148, 8221],
|
|
22
|
+
[149, 8226],
|
|
23
|
+
[150, 8211],
|
|
24
|
+
[151, 8212],
|
|
25
|
+
[152, 732],
|
|
26
|
+
[153, 8482],
|
|
27
|
+
[154, 353],
|
|
28
|
+
[155, 8250],
|
|
29
|
+
[156, 339],
|
|
30
|
+
[158, 382],
|
|
31
|
+
[159, 376],
|
|
32
|
+
]);
|
|
33
|
+
/**
|
|
34
|
+
* Replace the given code point with a replacement character if it is a
|
|
35
|
+
* surrogate or is outside the valid range. Otherwise return the code
|
|
36
|
+
* point unchanged.
|
|
37
|
+
* @param codePoint Unicode code point to convert.
|
|
38
|
+
*/
|
|
39
|
+
export function replaceCodePoint(codePoint) {
|
|
40
|
+
if ((codePoint >= 0xd8_00 && codePoint <= 0xdf_ff) ||
|
|
41
|
+
codePoint > 0x10_ff_ff) {
|
|
42
|
+
return 0xff_fd;
|
|
43
|
+
}
|
|
44
|
+
return decodeMap.get(codePoint) ?? codePoint;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=decode-codepoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode-codepoint.js","sourceRoot":"","sources":["../src/decode-codepoint.ts"],"names":[],"mappings":"AAAA,qHAAqH;AA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ACnB,CAAC;IAED,OAAO,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC;AACjD,CAAC"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decoding mode for named entities.
|
|
3
|
+
*/
|
|
1
4
|
export declare enum DecodingMode {
|
|
2
5
|
/** Entities in text nodes that can end with any character. */
|
|
3
6
|
Legacy = 0,
|
|
@@ -25,7 +28,6 @@ export declare class EntityDecoder {
|
|
|
25
28
|
*
|
|
26
29
|
* For multi-byte named entities, this will be called multiple times,
|
|
27
30
|
* with the second codepoint, and the same `consumed` value.
|
|
28
|
-
*
|
|
29
31
|
* @param codepoint The decoded codepoint.
|
|
30
32
|
* @param consumed The number of bytes consumed by the decoder.
|
|
31
33
|
*/
|
|
@@ -40,7 +42,6 @@ export declare class EntityDecoder {
|
|
|
40
42
|
*
|
|
41
43
|
* For multi-byte named entities, this will be called multiple times,
|
|
42
44
|
* with the second codepoint, and the same `consumed` value.
|
|
43
|
-
*
|
|
44
45
|
* @param codepoint The decoded codepoint.
|
|
45
46
|
* @param consumed The number of bytes consumed by the decoder.
|
|
46
47
|
*/
|
|
@@ -64,7 +65,12 @@ export declare class EntityDecoder {
|
|
|
64
65
|
private excess;
|
|
65
66
|
/** The mode in which the decoder is operating. */
|
|
66
67
|
private decodeMode;
|
|
67
|
-
/**
|
|
68
|
+
/** The number of characters that have been consumed in the current run. */
|
|
69
|
+
private runConsumed;
|
|
70
|
+
/**
|
|
71
|
+
* Resets the instance to make it reusable.
|
|
72
|
+
* @param decodeMode Entity decoding mode to use.
|
|
73
|
+
*/
|
|
68
74
|
startEntity(decodeMode: DecodingMode): void;
|
|
69
75
|
/**
|
|
70
76
|
* Write an entity to the decoder. This can be called multiple times with partial entities.
|
|
@@ -72,7 +78,6 @@ export declare class EntityDecoder {
|
|
|
72
78
|
*
|
|
73
79
|
* Mirrors the implementation of `getDecoder`, but with the ability to stop decoding if the
|
|
74
80
|
* entity is incomplete, and resume when the next string is written.
|
|
75
|
-
*
|
|
76
81
|
* @param input The string containing the entity (or a continuation of the entity).
|
|
77
82
|
* @param offset The offset at which the entity begins. Should be 0 if this is not the first call.
|
|
78
83
|
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
@@ -82,7 +87,6 @@ export declare class EntityDecoder {
|
|
|
82
87
|
* Switches between the numeric decimal and hexadecimal states.
|
|
83
88
|
*
|
|
84
89
|
* Equivalent to the `Numeric character reference state` in the HTML spec.
|
|
85
|
-
*
|
|
86
90
|
* @param input The string containing the entity (or a continuation of the entity).
|
|
87
91
|
* @param offset The current offset.
|
|
88
92
|
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
@@ -92,7 +96,6 @@ export declare class EntityDecoder {
|
|
|
92
96
|
* Parses a hexadecimal numeric entity.
|
|
93
97
|
*
|
|
94
98
|
* Equivalent to the `Hexademical character reference state` in the HTML spec.
|
|
95
|
-
*
|
|
96
99
|
* @param input The string containing the entity (or a continuation of the entity).
|
|
97
100
|
* @param offset The current offset.
|
|
98
101
|
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
@@ -102,7 +105,6 @@ export declare class EntityDecoder {
|
|
|
102
105
|
* Parses a decimal numeric entity.
|
|
103
106
|
*
|
|
104
107
|
* Equivalent to the `Decimal character reference state` in the HTML spec.
|
|
105
|
-
*
|
|
106
108
|
* @param input The string containing the entity (or a continuation of the entity).
|
|
107
109
|
* @param offset The current offset.
|
|
108
110
|
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
@@ -113,7 +115,6 @@ export declare class EntityDecoder {
|
|
|
113
115
|
*
|
|
114
116
|
* Implements the logic from the `Hexademical character reference start
|
|
115
117
|
* state` and `Numeric character reference end state` in the HTML spec.
|
|
116
|
-
*
|
|
117
118
|
* @param lastCp The last code point of the entity. Used to see if the
|
|
118
119
|
* entity was terminated with a semicolon.
|
|
119
120
|
* @param expectedLength The minimum number of characters that should be
|
|
@@ -126,7 +127,6 @@ export declare class EntityDecoder {
|
|
|
126
127
|
* Parses a named entity.
|
|
127
128
|
*
|
|
128
129
|
* Equivalent to the `Named character reference state` in the HTML spec.
|
|
129
|
-
*
|
|
130
130
|
* @param input The string containing the entity (or a continuation of the entity).
|
|
131
131
|
* @param offset The current offset.
|
|
132
132
|
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
@@ -134,17 +134,14 @@ export declare class EntityDecoder {
|
|
|
134
134
|
private stateNamedEntity;
|
|
135
135
|
/**
|
|
136
136
|
* Emit a named entity that was not terminated with a semicolon.
|
|
137
|
-
*
|
|
138
137
|
* @returns The number of characters consumed.
|
|
139
138
|
*/
|
|
140
139
|
private emitNotTerminatedNamedEntity;
|
|
141
140
|
/**
|
|
142
141
|
* Emit a named entity.
|
|
143
|
-
*
|
|
144
142
|
* @param result The index of the entity in the decode tree.
|
|
145
143
|
* @param valueLength The number of bytes in the entity.
|
|
146
144
|
* @param consumed The number of characters consumed.
|
|
147
|
-
*
|
|
148
145
|
* @returns The number of characters consumed.
|
|
149
146
|
*/
|
|
150
147
|
private emitNamedEntityData;
|
|
@@ -152,7 +149,6 @@ export declare class EntityDecoder {
|
|
|
152
149
|
* Signal to the parser that the end of the input was reached.
|
|
153
150
|
*
|
|
154
151
|
* Remaining data will be emitted and relevant errors will be produced.
|
|
155
|
-
*
|
|
156
152
|
* @returns The number of characters consumed.
|
|
157
153
|
*/
|
|
158
154
|
end(): number;
|
|
@@ -160,17 +156,15 @@ export declare class EntityDecoder {
|
|
|
160
156
|
/**
|
|
161
157
|
* Determines the branch of the current node that is taken given the current
|
|
162
158
|
* character. This function is used to traverse the trie.
|
|
163
|
-
*
|
|
164
159
|
* @param decodeTree The trie.
|
|
165
160
|
* @param current The current node.
|
|
166
|
-
* @param
|
|
161
|
+
* @param nodeIndex Index immediately after the current node header.
|
|
167
162
|
* @param char The current character.
|
|
168
163
|
* @returns The index of the next node, or -1 if no branch is taken.
|
|
169
164
|
*/
|
|
170
165
|
export declare function determineBranch(decodeTree: Uint16Array, current: number, nodeIndex: number, char: number): number;
|
|
171
166
|
/**
|
|
172
167
|
* Decodes an HTML string.
|
|
173
|
-
*
|
|
174
168
|
* @param htmlString The string to decode.
|
|
175
169
|
* @param mode The decoding mode.
|
|
176
170
|
* @returns The decoded string.
|
|
@@ -178,26 +172,23 @@ export declare function determineBranch(decodeTree: Uint16Array, current: number
|
|
|
178
172
|
export declare function decodeHTML(htmlString: string, mode?: DecodingMode): string;
|
|
179
173
|
/**
|
|
180
174
|
* Decodes an HTML string in an attribute.
|
|
181
|
-
*
|
|
182
175
|
* @param htmlAttribute The string to decode.
|
|
183
176
|
* @returns The decoded string.
|
|
184
177
|
*/
|
|
185
178
|
export declare function decodeHTMLAttribute(htmlAttribute: string): string;
|
|
186
179
|
/**
|
|
187
180
|
* Decodes an HTML string, requiring all entities to be terminated by a semicolon.
|
|
188
|
-
*
|
|
189
181
|
* @param htmlString The string to decode.
|
|
190
182
|
* @returns The decoded string.
|
|
191
183
|
*/
|
|
192
184
|
export declare function decodeHTMLStrict(htmlString: string): string;
|
|
193
185
|
/**
|
|
194
186
|
* Decodes an XML string, requiring all entities to be terminated by a semicolon.
|
|
195
|
-
*
|
|
196
187
|
* @param xmlString The string to decode.
|
|
197
188
|
* @returns The decoded string.
|
|
198
189
|
*/
|
|
199
190
|
export declare function decodeXML(xmlString: string): string;
|
|
200
|
-
export {
|
|
191
|
+
export { replaceCodePoint } from "./decode-codepoint.js";
|
|
201
192
|
export { htmlDecodeTree } from "./generated/decode-data-html.js";
|
|
202
193
|
export { xmlDecodeTree } from "./generated/decode-data-xml.js";
|
|
203
194
|
//# sourceMappingURL=decode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../src/decode.ts"],"names":[],"mappings":"AA6DA;;GAEG;AACH,oBAAY,YAAY;IACpB,8DAA8D;IAC9D,MAAM,IAAI;IACV,uDAAuD;IACvD,MAAM,IA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AC,mBAAmB;IAc3B;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,iBAAiB;IA6BzB;;;;;;;OAOG;IACH,OAAO,CAAC,gBAAgB;IAoIxB;;;OAGG;IACH,OAAO,CAAC,4BAA4B;IAYpC;;;;;;OAMG;IACH,OAAO,CAAC,mBAAmB;IAsB3B;;;;;OAKG;IACH,GAAG,IAAI,MAAM;CA6BhB;AAmDD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC3B,UAAU,EAAE,WAAW,EACvB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,GACb,MAAM,CA4CR;AAKD;;;;;GAKG;AACH,wBAAgB,UAAU,CACtB,UAAU,EAAE,MAAM,EAClB,IAAI,GAAE,YAAkC,GACzC,MAAM,CAER;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAEjE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { replaceCodePoint } from "./decode-codepoint.js";
|
|
2
2
|
import { htmlDecodeTree } from "./generated/decode-data-html.js";
|
|
3
3
|
import { xmlDecodeTree } from "./generated/decode-data-xml.js";
|
|
4
4
|
import { BinTrieFlags } from "./internal/bin-trie-flags.js";
|
|
@@ -18,7 +18,7 @@ var CharCodes;
|
|
|
18
18
|
CharCodes[CharCodes["UPPER_Z"] = 90] = "UPPER_Z";
|
|
19
19
|
})(CharCodes || (CharCodes = {}));
|
|
20
20
|
/** Bit that needs to be set to convert an upper case ASCII character to lower case */
|
|
21
|
-
const TO_LOWER_BIT =
|
|
21
|
+
const TO_LOWER_BIT = 0b10_0000;
|
|
22
22
|
function isNumber(code) {
|
|
23
23
|
return code >= CharCodes.ZERO && code <= CharCodes.NINE;
|
|
24
24
|
}
|
|
@@ -36,6 +36,7 @@ function isAsciiAlphaNumeric(code) {
|
|
|
36
36
|
*
|
|
37
37
|
* Attribute values that aren't terminated properly aren't parsed, and shouldn't lead to a parser error.
|
|
38
38
|
* See the example in https://html.spec.whatwg.org/multipage/parsing.html#named-character-reference-state
|
|
39
|
+
* @param code Code point to decode.
|
|
39
40
|
*/
|
|
40
41
|
function isEntityInAttributeInvalidEnd(code) {
|
|
41
42
|
return code === CharCodes.EQUALS || isAsciiAlphaNumeric(code);
|
|
@@ -48,6 +49,9 @@ var EntityDecoderState;
|
|
|
48
49
|
EntityDecoderState[EntityDecoderState["NumericHex"] = 3] = "NumericHex";
|
|
49
50
|
EntityDecoderState[EntityDecoderState["NamedEntity"] = 4] = "NamedEntity";
|
|
50
51
|
})(EntityDecoderState || (EntityDecoderState = {}));
|
|
52
|
+
/**
|
|
53
|
+
* Decoding mode for named entities.
|
|
54
|
+
*/
|
|
51
55
|
export var DecodingMode;
|
|
52
56
|
(function (DecodingMode) {
|
|
53
57
|
/** Entities in text nodes that can end with any character. */
|
|
@@ -61,6 +65,9 @@ export var DecodingMode;
|
|
|
61
65
|
* Token decoder with support of writing partial entities.
|
|
62
66
|
*/
|
|
63
67
|
export class EntityDecoder {
|
|
68
|
+
decodeTree;
|
|
69
|
+
emitCodePoint;
|
|
70
|
+
errors;
|
|
64
71
|
constructor(
|
|
65
72
|
/** The tree used to decode entities. */
|
|
66
73
|
// biome-ignore lint/correctness/noUnusedPrivateClassMembers: False positive
|
|
@@ -70,7 +77,6 @@ export class EntityDecoder {
|
|
|
70
77
|
*
|
|
71
78
|
* For multi-byte named entities, this will be called multiple times,
|
|
72
79
|
* with the second codepoint, and the same `consumed` value.
|
|
73
|
-
*
|
|
74
80
|
* @param codepoint The decoded codepoint.
|
|
75
81
|
* @param consumed The number of bytes consumed by the decoder.
|
|
76
82
|
*/
|
|
@@ -80,25 +86,30 @@ export class EntityDecoder {
|
|
|
80
86
|
this.decodeTree = decodeTree;
|
|
81
87
|
this.emitCodePoint = emitCodePoint;
|
|
82
88
|
this.errors = errors;
|
|
83
|
-
/** The current state of the decoder. */
|
|
84
|
-
this.state = EntityDecoderState.EntityStart;
|
|
85
|
-
/** Characters that were consumed while parsing an entity. */
|
|
86
|
-
this.consumed = 1;
|
|
87
|
-
/**
|
|
88
|
-
* The result of the entity.
|
|
89
|
-
*
|
|
90
|
-
* Either the result index of a numeric entity, or the codepoint of a
|
|
91
|
-
* numeric entity.
|
|
92
|
-
*/
|
|
93
|
-
this.result = 0;
|
|
94
|
-
/** The current index in the decode tree. */
|
|
95
|
-
this.treeIndex = 0;
|
|
96
|
-
/** The number of characters that were consumed in excess. */
|
|
97
|
-
this.excess = 1;
|
|
98
|
-
/** The mode in which the decoder is operating. */
|
|
99
|
-
this.decodeMode = DecodingMode.Strict;
|
|
100
89
|
}
|
|
101
|
-
/**
|
|
90
|
+
/** The current state of the decoder. */
|
|
91
|
+
state = EntityDecoderState.EntityStart;
|
|
92
|
+
/** Characters that were consumed while parsing an entity. */
|
|
93
|
+
consumed = 1;
|
|
94
|
+
/**
|
|
95
|
+
* The result of the entity.
|
|
96
|
+
*
|
|
97
|
+
* Either the result index of a numeric entity, or the codepoint of a
|
|
98
|
+
* numeric entity.
|
|
99
|
+
*/
|
|
100
|
+
result = 0;
|
|
101
|
+
/** The current index in the decode tree. */
|
|
102
|
+
treeIndex = 0;
|
|
103
|
+
/** The number of characters that were consumed in excess. */
|
|
104
|
+
excess = 1;
|
|
105
|
+
/** The mode in which the decoder is operating. */
|
|
106
|
+
decodeMode = DecodingMode.Strict;
|
|
107
|
+
/** The number of characters that have been consumed in the current run. */
|
|
108
|
+
runConsumed = 0;
|
|
109
|
+
/**
|
|
110
|
+
* Resets the instance to make it reusable.
|
|
111
|
+
* @param decodeMode Entity decoding mode to use.
|
|
112
|
+
*/
|
|
102
113
|
startEntity(decodeMode) {
|
|
103
114
|
this.decodeMode = decodeMode;
|
|
104
115
|
this.state = EntityDecoderState.EntityStart;
|
|
@@ -106,6 +117,7 @@ export class EntityDecoder {
|
|
|
106
117
|
this.treeIndex = 0;
|
|
107
118
|
this.excess = 1;
|
|
108
119
|
this.consumed = 1;
|
|
120
|
+
this.runConsumed = 0;
|
|
109
121
|
}
|
|
110
122
|
/**
|
|
111
123
|
* Write an entity to the decoder. This can be called multiple times with partial entities.
|
|
@@ -113,7 +125,6 @@ export class EntityDecoder {
|
|
|
113
125
|
*
|
|
114
126
|
* Mirrors the implementation of `getDecoder`, but with the ability to stop decoding if the
|
|
115
127
|
* entity is incomplete, and resume when the next string is written.
|
|
116
|
-
*
|
|
117
128
|
* @param input The string containing the entity (or a continuation of the entity).
|
|
118
129
|
* @param offset The offset at which the entity begins. Should be 0 if this is not the first call.
|
|
119
130
|
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
@@ -147,7 +158,6 @@ export class EntityDecoder {
|
|
|
147
158
|
* Switches between the numeric decimal and hexadecimal states.
|
|
148
159
|
*
|
|
149
160
|
* Equivalent to the `Numeric character reference state` in the HTML spec.
|
|
150
|
-
*
|
|
151
161
|
* @param input The string containing the entity (or a continuation of the entity).
|
|
152
162
|
* @param offset The current offset.
|
|
153
163
|
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
@@ -168,7 +178,6 @@ export class EntityDecoder {
|
|
|
168
178
|
* Parses a hexadecimal numeric entity.
|
|
169
179
|
*
|
|
170
180
|
* Equivalent to the `Hexademical character reference state` in the HTML spec.
|
|
171
|
-
*
|
|
172
181
|
* @param input The string containing the entity (or a continuation of the entity).
|
|
173
182
|
* @param offset The current offset.
|
|
174
183
|
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
@@ -195,7 +204,6 @@ export class EntityDecoder {
|
|
|
195
204
|
* Parses a decimal numeric entity.
|
|
196
205
|
*
|
|
197
206
|
* Equivalent to the `Decimal character reference state` in the HTML spec.
|
|
198
|
-
*
|
|
199
207
|
* @param input The string containing the entity (or a continuation of the entity).
|
|
200
208
|
* @param offset The current offset.
|
|
201
209
|
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
@@ -219,7 +227,6 @@ export class EntityDecoder {
|
|
|
219
227
|
*
|
|
220
228
|
* Implements the logic from the `Hexademical character reference start
|
|
221
229
|
* state` and `Numeric character reference end state` in the HTML spec.
|
|
222
|
-
*
|
|
223
230
|
* @param lastCp The last code point of the entity. Used to see if the
|
|
224
231
|
* entity was terminated with a semicolon.
|
|
225
232
|
* @param expectedLength The minimum number of characters that should be
|
|
@@ -228,10 +235,9 @@ export class EntityDecoder {
|
|
|
228
235
|
* @returns The number of characters that were consumed.
|
|
229
236
|
*/
|
|
230
237
|
emitNumericEntity(lastCp, expectedLength) {
|
|
231
|
-
var _a;
|
|
232
238
|
// Ensure we consumed at least one digit.
|
|
233
239
|
if (this.consumed <= expectedLength) {
|
|
234
|
-
|
|
240
|
+
this.errors?.absenceOfDigitsInNumericCharacterReference(this.consumed);
|
|
235
241
|
return 0;
|
|
236
242
|
}
|
|
237
243
|
// Figure out if this is a legit end of the entity
|
|
@@ -254,7 +260,6 @@ export class EntityDecoder {
|
|
|
254
260
|
* Parses a named entity.
|
|
255
261
|
*
|
|
256
262
|
* Equivalent to the `Named character reference state` in the HTML spec.
|
|
257
|
-
*
|
|
258
263
|
* @param input The string containing the entity (or a continuation of the entity).
|
|
259
264
|
* @param offset The current offset.
|
|
260
265
|
* @returns The number of characters that were consumed, or -1 if the entity is incomplete.
|
|
@@ -268,43 +273,40 @@ export class EntityDecoder {
|
|
|
268
273
|
// Handle compact runs (possibly inline): valueLength == 0 and SEMI_REQUIRED bit set.
|
|
269
274
|
if (valueLength === 0 && (current & BinTrieFlags.FLAG13) !== 0) {
|
|
270
275
|
const runLength = (current & BinTrieFlags.BRANCH_LENGTH) >> 7; /* 2..63 */
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
// Verify first char
|
|
276
|
-
if (input.charCodeAt(offset) !== firstChar) {
|
|
277
|
-
return this.result === 0
|
|
278
|
-
? 0
|
|
279
|
-
: this.emitNotTerminatedNamedEntity();
|
|
280
|
-
}
|
|
281
|
-
offset++;
|
|
282
|
-
this.excess++;
|
|
283
|
-
// Remaining characters after the first
|
|
284
|
-
const remaining = runLength - 1;
|
|
285
|
-
// Iterate over packed 2-char words
|
|
286
|
-
for (let runPos = 1; runPos < runLength; runPos += 2) {
|
|
287
|
-
const packedWord = decodeTree[this.treeIndex + 1 + ((runPos - 1) >> 1)];
|
|
288
|
-
const low = packedWord & 0xff;
|
|
289
|
-
if (input.charCodeAt(offset) !== low) {
|
|
276
|
+
// If we are starting a run, check the first char.
|
|
277
|
+
if (this.runConsumed === 0) {
|
|
278
|
+
const firstChar = current & BinTrieFlags.JUMP_TABLE;
|
|
279
|
+
if (input.charCodeAt(offset) !== firstChar) {
|
|
290
280
|
return this.result === 0
|
|
291
281
|
? 0
|
|
292
282
|
: this.emitNotTerminatedNamedEntity();
|
|
293
283
|
}
|
|
294
284
|
offset++;
|
|
295
285
|
this.excess++;
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
286
|
+
this.runConsumed++;
|
|
287
|
+
}
|
|
288
|
+
// Check remaining characters in the run.
|
|
289
|
+
while (this.runConsumed < runLength) {
|
|
290
|
+
if (offset >= input.length) {
|
|
291
|
+
return -1;
|
|
292
|
+
}
|
|
293
|
+
const charIndexInPacked = this.runConsumed - 1;
|
|
294
|
+
const packedWord = decodeTree[this.treeIndex + 1 + (charIndexInPacked >> 1)];
|
|
295
|
+
const expectedChar = charIndexInPacked % 2 === 0
|
|
296
|
+
? packedWord & 0xff
|
|
297
|
+
: (packedWord >> 8) & 0xff;
|
|
298
|
+
if (input.charCodeAt(offset) !== expectedChar) {
|
|
299
|
+
this.runConsumed = 0;
|
|
300
|
+
return this.result === 0
|
|
301
|
+
? 0
|
|
302
|
+
: this.emitNotTerminatedNamedEntity();
|
|
305
303
|
}
|
|
304
|
+
offset++;
|
|
305
|
+
this.excess++;
|
|
306
|
+
this.runConsumed++;
|
|
306
307
|
}
|
|
307
|
-
this.
|
|
308
|
+
this.runConsumed = 0;
|
|
309
|
+
this.treeIndex += 1 + (runLength >> 1);
|
|
308
310
|
current = decodeTree[this.treeIndex];
|
|
309
311
|
valueLength = (current & BinTrieFlags.VALUE_LENGTH) >> 14;
|
|
310
312
|
}
|
|
@@ -359,24 +361,20 @@ export class EntityDecoder {
|
|
|
359
361
|
}
|
|
360
362
|
/**
|
|
361
363
|
* Emit a named entity that was not terminated with a semicolon.
|
|
362
|
-
*
|
|
363
364
|
* @returns The number of characters consumed.
|
|
364
365
|
*/
|
|
365
366
|
emitNotTerminatedNamedEntity() {
|
|
366
|
-
var _a;
|
|
367
367
|
const { result, decodeTree } = this;
|
|
368
368
|
const valueLength = (decodeTree[result] & BinTrieFlags.VALUE_LENGTH) >> 14;
|
|
369
369
|
this.emitNamedEntityData(result, valueLength, this.consumed);
|
|
370
|
-
|
|
370
|
+
this.errors?.missingSemicolonAfterCharacterReference();
|
|
371
371
|
return this.consumed;
|
|
372
372
|
}
|
|
373
373
|
/**
|
|
374
374
|
* Emit a named entity.
|
|
375
|
-
*
|
|
376
375
|
* @param result The index of the entity in the decode tree.
|
|
377
376
|
* @param valueLength The number of bytes in the entity.
|
|
378
377
|
* @param consumed The number of characters consumed.
|
|
379
|
-
*
|
|
380
378
|
* @returns The number of characters consumed.
|
|
381
379
|
*/
|
|
382
380
|
emitNamedEntityData(result, valueLength, consumed) {
|
|
@@ -395,11 +393,9 @@ export class EntityDecoder {
|
|
|
395
393
|
* Signal to the parser that the end of the input was reached.
|
|
396
394
|
*
|
|
397
395
|
* Remaining data will be emitted and relevant errors will be produced.
|
|
398
|
-
*
|
|
399
396
|
* @returns The number of characters consumed.
|
|
400
397
|
*/
|
|
401
398
|
end() {
|
|
402
|
-
var _a;
|
|
403
399
|
switch (this.state) {
|
|
404
400
|
case EntityDecoderState.NamedEntity: {
|
|
405
401
|
// Emit a named entity if we have one.
|
|
@@ -417,7 +413,7 @@ export class EntityDecoder {
|
|
|
417
413
|
return this.emitNumericEntity(0, 3);
|
|
418
414
|
}
|
|
419
415
|
case EntityDecoderState.NumericStart: {
|
|
420
|
-
|
|
416
|
+
this.errors?.absenceOfDigitsInNumericCharacterReference(this.consumed);
|
|
421
417
|
return 0;
|
|
422
418
|
}
|
|
423
419
|
case EntityDecoderState.EntityStart: {
|
|
@@ -429,13 +425,12 @@ export class EntityDecoder {
|
|
|
429
425
|
}
|
|
430
426
|
/**
|
|
431
427
|
* Creates a function that decodes entities in a string.
|
|
432
|
-
*
|
|
433
428
|
* @param decodeTree The decode tree.
|
|
434
429
|
* @returns A function that decodes entities in a string.
|
|
435
430
|
*/
|
|
436
431
|
function getDecoder(decodeTree) {
|
|
437
432
|
let returnValue = "";
|
|
438
|
-
const decoder = new EntityDecoder(decodeTree, (data) => (returnValue += fromCodePoint(data)));
|
|
433
|
+
const decoder = new EntityDecoder(decodeTree, (data) => (returnValue += String.fromCodePoint(data)));
|
|
439
434
|
return function decodeWithTrie(input, decodeMode) {
|
|
440
435
|
let lastIndex = 0;
|
|
441
436
|
let offset = 0;
|
|
@@ -462,10 +457,9 @@ function getDecoder(decodeTree) {
|
|
|
462
457
|
/**
|
|
463
458
|
* Determines the branch of the current node that is taken given the current
|
|
464
459
|
* character. This function is used to traverse the trie.
|
|
465
|
-
*
|
|
466
460
|
* @param decodeTree The trie.
|
|
467
461
|
* @param current The current node.
|
|
468
|
-
* @param
|
|
462
|
+
* @param nodeIndex Index immediately after the current node header.
|
|
469
463
|
* @param char The current character.
|
|
470
464
|
* @returns The index of the next node, or -1 if no branch is taken.
|
|
471
465
|
*/
|
|
@@ -512,7 +506,6 @@ const htmlDecoder = /* #__PURE__ */ getDecoder(htmlDecodeTree);
|
|
|
512
506
|
const xmlDecoder = /* #__PURE__ */ getDecoder(xmlDecodeTree);
|
|
513
507
|
/**
|
|
514
508
|
* Decodes an HTML string.
|
|
515
|
-
*
|
|
516
509
|
* @param htmlString The string to decode.
|
|
517
510
|
* @param mode The decoding mode.
|
|
518
511
|
* @returns The decoded string.
|
|
@@ -522,7 +515,6 @@ export function decodeHTML(htmlString, mode = DecodingMode.Legacy) {
|
|
|
522
515
|
}
|
|
523
516
|
/**
|
|
524
517
|
* Decodes an HTML string in an attribute.
|
|
525
|
-
*
|
|
526
518
|
* @param htmlAttribute The string to decode.
|
|
527
519
|
* @returns The decoded string.
|
|
528
520
|
*/
|
|
@@ -531,7 +523,6 @@ export function decodeHTMLAttribute(htmlAttribute) {
|
|
|
531
523
|
}
|
|
532
524
|
/**
|
|
533
525
|
* Decodes an HTML string, requiring all entities to be terminated by a semicolon.
|
|
534
|
-
*
|
|
535
526
|
* @param htmlString The string to decode.
|
|
536
527
|
* @returns The decoded string.
|
|
537
528
|
*/
|
|
@@ -540,14 +531,13 @@ export function decodeHTMLStrict(htmlString) {
|
|
|
540
531
|
}
|
|
541
532
|
/**
|
|
542
533
|
* Decodes an XML string, requiring all entities to be terminated by a semicolon.
|
|
543
|
-
*
|
|
544
534
|
* @param xmlString The string to decode.
|
|
545
535
|
* @returns The decoded string.
|
|
546
536
|
*/
|
|
547
537
|
export function decodeXML(xmlString) {
|
|
548
538
|
return xmlDecoder(xmlString, DecodingMode.Strict);
|
|
549
539
|
}
|
|
550
|
-
export {
|
|
540
|
+
export { replaceCodePoint } from "./decode-codepoint.js";
|
|
551
541
|
// Re-export for use by eg. htmlparser2
|
|
552
542
|
export { htmlDecodeTree } from "./generated/decode-data-html.js";
|
|
553
543
|
export { xmlDecodeTree } from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C,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* If a character has no equivalent entity, a numeric hexadecimal reference
|
|
10
10
|
* (eg. `ü`) will be used.
|
|
11
|
+
* @param input Input string to encode or decode.
|
|
11
12
|
*/
|
|
12
13
|
export declare function encodeHTML(input: string): string;
|
|
13
14
|
/**
|
|
@@ -17,6 +18,7 @@ export declare function encodeHTML(input: string): string;
|
|
|
17
18
|
*
|
|
18
19
|
* If a character has no equivalent entity, a numeric hexadecimal reference
|
|
19
20
|
* (eg. `ü`) will be used.
|
|
21
|
+
* @param input Input string to encode or decode.
|
|
20
22
|
*/
|
|
21
23
|
export declare function encodeNonAsciiHTML(input: string): string;
|
|
22
24
|
//# sourceMappingURL=encode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../src/encode.ts"],"names":[],"mappings":"AAeA;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AACD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAExD"}
|
|
@@ -4,10 +4,10 @@ import { htmlTrie } from "./generated/encode-html.js";
|
|
|
4
4
|
* We store the characters to consider as a compact bitset for fast lookups.
|
|
5
5
|
*/
|
|
6
6
|
const HTML_BITSET = /* #__PURE__ */ new Uint32Array([
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
0x16_00, // Bits for 09,0A,0C
|
|
8
|
+
0xfc_00_ff_fe, // 32..63 -> 21-2D (minus space), 2E,2F,3A-3F
|
|
9
|
+
0xf8_00_00_01, // 64..95 -> 40, 5B-5F
|
|
10
|
+
0x38_00_00_01, // 96..127-> 60, 7B-7D
|
|
11
11
|
]);
|
|
12
12
|
const XML_BITSET = /* #__PURE__ */ new Uint32Array([0, XML_BITSET_VALUE, 0, 0]);
|
|
13
13
|
/**
|
|
@@ -20,6 +20,7 @@ const XML_BITSET = /* #__PURE__ */ new Uint32Array([0, XML_BITSET_VALUE, 0, 0]);
|
|
|
20
20
|
*
|
|
21
21
|
* If a character has no equivalent entity, a numeric hexadecimal reference
|
|
22
22
|
* (eg. `ü`) will be used.
|
|
23
|
+
* @param input Input string to encode or decode.
|
|
23
24
|
*/
|
|
24
25
|
export function encodeHTML(input) {
|
|
25
26
|
return encodeHTMLTrieRe(HTML_BITSET, input);
|
|
@@ -31,6 +32,7 @@ export function encodeHTML(input) {
|
|
|
31
32
|
*
|
|
32
33
|
* If a character has no equivalent entity, a numeric hexadecimal reference
|
|
33
34
|
* (eg. `ü`) will be used.
|
|
35
|
+
* @param input Input string to encode or decode.
|
|
34
36
|
*/
|
|
35
37
|
export function encodeNonAsciiHTML(input) {
|
|
36
38
|
return encodeHTMLTrieRe(XML_BITSET, input);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encode.js","sourceRoot":"","sources":["../src/encode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,GAAG,eAAe,CAAC,IAAI,WAAW,CAAC;IAChD,OAAO,EAAE,oBAAoB;IAC7B,aAAa,EAAE,6CAA6C;IAC5D,aAAa,EAAE,sBAAsB;IACrC,aAAa,EAAE,sBAAsB;CACxC,CAAC,CAAC;AAEH,MAAM,UAAU,GAAG,eAAe,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAEhF;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,UAAU,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