@tbela99/rust-css-parser-wasm 0.0.0-stage → 2.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.
- package/LICENSE.md +21 -0
- package/README.md +27 -2
- package/dist/api.js +142 -0
- package/dist/ast/arena-node.js +96 -0
- package/dist/ast/arena.js +742 -0
- package/dist/ast/features/type.js +9 -0
- package/dist/ast/minify.js +6 -0
- package/dist/ast/strings.js +27 -0
- package/dist/ast/transform/utils.js +5 -0
- package/dist/ast/types.js +460 -0
- package/dist/backend.js +82 -0
- package/dist/columns.js +20 -0
- package/dist/core.js +50 -0
- package/dist/css_parser.wasm +0 -0
- package/dist/enums-extra.js +31 -0
- package/dist/exports.js +16 -0
- package/dist/fs/resolve.js +11 -0
- package/dist/node.js +60 -0
- package/dist/parser/declaration/list.js +25 -0
- package/dist/parser/parse.js +10 -0
- package/dist/printer/render.js +34 -0
- package/dist/printer/result.js +67 -0
- package/dist/printer/sourcemap.js +30 -0
- package/dist/runtime.js +505 -0
- package/dist/syntax/color/color.js +6 -0
- package/dist/syntax/color/utils/distance.js +10 -0
- package/dist/types.js +1 -0
- package/dist/validation/config.js +58 -0
- package/dist/validation/first.js +21 -0
- package/dist/validation/parser/parse.js +5 -0
- package/dist/validation/parser/typedef.js +124 -0
- package/dist/version.js +4 -0
- package/dist/web.js +59 -0
- package/package.json +63 -4
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// StringBuilder of src/ast/strings.ts: a string built from code units and interned strings
|
|
2
|
+
// (see AstArena.appendString() / AstArena.internBuilder()).
|
|
3
|
+
|
|
4
|
+
export { StringFlag, StringSource } from "../enums-extra.js";
|
|
5
|
+
|
|
6
|
+
export class StringBuilder {
|
|
7
|
+
#parts = [];
|
|
8
|
+
|
|
9
|
+
reset() {
|
|
10
|
+
this.#parts.length = 0;
|
|
11
|
+
return this;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
appendString(str) {
|
|
15
|
+
this.#parts.push(str);
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
appendCode(code) {
|
|
20
|
+
this.#parts.push(String.fromCharCode(code));
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
toString() {
|
|
25
|
+
return this.#parts.join("");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,460 @@
|
|
|
1
|
+
// Enums of the typescript API (data only). Generated by scripts/gen-enums.mjs.
|
|
2
|
+
|
|
3
|
+
export const ColorType = Object.freeze({
|
|
4
|
+
"NONE": 0,
|
|
5
|
+
"SYS": 1,
|
|
6
|
+
"DPSYS": 2,
|
|
7
|
+
"LIT": 3,
|
|
8
|
+
"HEX": 4,
|
|
9
|
+
"RGBA": 5,
|
|
10
|
+
"HSLA": 6,
|
|
11
|
+
"HWB": 7,
|
|
12
|
+
"CMYK": 8,
|
|
13
|
+
"OKLAB": 9,
|
|
14
|
+
"OKLCH": 10,
|
|
15
|
+
"LAB": 11,
|
|
16
|
+
"LCH": 12,
|
|
17
|
+
"COLOR": 13,
|
|
18
|
+
"SRGB": 14,
|
|
19
|
+
"PROPHOTO_RGB": 15,
|
|
20
|
+
"A98_RGB": 16,
|
|
21
|
+
"REC2020": 17,
|
|
22
|
+
"DISPLAY_P3": 18,
|
|
23
|
+
"SRGB_LINEAR": 19,
|
|
24
|
+
"XYZ_D50": 20,
|
|
25
|
+
"XYZ_D65": 21,
|
|
26
|
+
"LIGHT_DARK": 22,
|
|
27
|
+
"COLOR_MIX": 23,
|
|
28
|
+
"NON_STD": 24,
|
|
29
|
+
"CUSTOM_COLOR": 25,
|
|
30
|
+
"ALPHA": 26,
|
|
31
|
+
"DISPLAY_P3_LINEAR": 27,
|
|
32
|
+
"CONTRAST_COLOR": 28,
|
|
33
|
+
"COLOR_LAYERS": 29,
|
|
34
|
+
"RGB": 5,
|
|
35
|
+
"HSL": 6,
|
|
36
|
+
"XYZ": 21,
|
|
37
|
+
"DEVICE_CMYK": 8,
|
|
38
|
+
"0": "NONE",
|
|
39
|
+
"1": "SYS",
|
|
40
|
+
"2": "DPSYS",
|
|
41
|
+
"3": "LIT",
|
|
42
|
+
"4": "HEX",
|
|
43
|
+
"7": "HWB",
|
|
44
|
+
"9": "OKLAB",
|
|
45
|
+
"10": "OKLCH",
|
|
46
|
+
"11": "LAB",
|
|
47
|
+
"12": "LCH",
|
|
48
|
+
"13": "COLOR",
|
|
49
|
+
"14": "SRGB",
|
|
50
|
+
"15": "PROPHOTO_RGB",
|
|
51
|
+
"16": "A98_RGB",
|
|
52
|
+
"17": "REC2020",
|
|
53
|
+
"18": "DISPLAY_P3",
|
|
54
|
+
"19": "SRGB_LINEAR",
|
|
55
|
+
"20": "XYZ_D50",
|
|
56
|
+
"22": "LIGHT_DARK",
|
|
57
|
+
"23": "COLOR_MIX",
|
|
58
|
+
"24": "NON_STD",
|
|
59
|
+
"25": "CUSTOM_COLOR",
|
|
60
|
+
"26": "ALPHA",
|
|
61
|
+
"27": "DISPLAY_P3_LINEAR",
|
|
62
|
+
"28": "CONTRAST_COLOR",
|
|
63
|
+
"29": "COLOR_LAYERS",
|
|
64
|
+
"5": "RGB",
|
|
65
|
+
"6": "HSL",
|
|
66
|
+
"21": "XYZ",
|
|
67
|
+
"8": "DEVICE_CMYK",
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
export const EnumAstNodeStatus = Object.freeze({
|
|
71
|
+
"Validated": 1,
|
|
72
|
+
"Invalid": 2,
|
|
73
|
+
"Unvalidated": 4,
|
|
74
|
+
"ValidationFailed": 8,
|
|
75
|
+
"Unknown": 16,
|
|
76
|
+
"Unparsed": 32,
|
|
77
|
+
"Disallowed": 64,
|
|
78
|
+
"Malformed": 128,
|
|
79
|
+
"ImportantDeclaration": 256,
|
|
80
|
+
"PowerlessColorComponent": 512,
|
|
81
|
+
"StateMask": 65535,
|
|
82
|
+
"HasChildren": 65536,
|
|
83
|
+
"HasValues": 131072,
|
|
84
|
+
"HasLocation": 262144,
|
|
85
|
+
"Marked": 524288,
|
|
86
|
+
"Matched": 1048576,
|
|
87
|
+
"1": "Validated",
|
|
88
|
+
"2": "Invalid",
|
|
89
|
+
"4": "Unvalidated",
|
|
90
|
+
"8": "ValidationFailed",
|
|
91
|
+
"16": "Unknown",
|
|
92
|
+
"32": "Unparsed",
|
|
93
|
+
"64": "Disallowed",
|
|
94
|
+
"128": "Malformed",
|
|
95
|
+
"256": "ImportantDeclaration",
|
|
96
|
+
"512": "PowerlessColorComponent",
|
|
97
|
+
"65535": "StateMask",
|
|
98
|
+
"65536": "HasChildren",
|
|
99
|
+
"131072": "HasValues",
|
|
100
|
+
"262144": "HasLocation",
|
|
101
|
+
"524288": "Marked",
|
|
102
|
+
"1048576": "Matched",
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
export const EnumToken = Object.freeze({
|
|
106
|
+
"CommentTokenType": 1,
|
|
107
|
+
"CDOCOMMTokenType": 2,
|
|
108
|
+
"StyleSheetNodeType": 3,
|
|
109
|
+
"AtRuleNodeType": 4,
|
|
110
|
+
"RuleNodeType": 5,
|
|
111
|
+
"DeclarationNodeType": 6,
|
|
112
|
+
"LiteralTokenType": 7,
|
|
113
|
+
"IdenTokenType": 8,
|
|
114
|
+
"DashedIdenTokenType": 9,
|
|
115
|
+
"CommaTokenType": 10,
|
|
116
|
+
"ColonTokenType": 11,
|
|
117
|
+
"SemiColonTokenType": 12,
|
|
118
|
+
"NumberTokenType": 13,
|
|
119
|
+
"AtRuleTokenType": 14,
|
|
120
|
+
"PercentageTokenType": 15,
|
|
121
|
+
"FunctionTokenType": 16,
|
|
122
|
+
"TimelineFunctionTokenType": 17,
|
|
123
|
+
"TimingFunctionTokenType": 18,
|
|
124
|
+
"UrlFunctionTokenType": 19,
|
|
125
|
+
"ImageFunctionTokenType": 20,
|
|
126
|
+
"StringTokenType": 21,
|
|
127
|
+
"UnclosedStringTokenType": 22,
|
|
128
|
+
"DimensionTokenType": 23,
|
|
129
|
+
"LengthTokenType": 24,
|
|
130
|
+
"AngleTokenType": 25,
|
|
131
|
+
"TimeTokenType": 26,
|
|
132
|
+
"FrequencyTokenType": 27,
|
|
133
|
+
"ResolutionTokenType": 28,
|
|
134
|
+
"HashTokenType": 29,
|
|
135
|
+
"BlockStartTokenType": 30,
|
|
136
|
+
"BlockEndTokenType": 31,
|
|
137
|
+
"AttrStartTokenType": 32,
|
|
138
|
+
"AttrEndTokenType": 33,
|
|
139
|
+
"StartParensTokenType": 34,
|
|
140
|
+
"EndParensTokenType": 35,
|
|
141
|
+
"ParensTokenType": 36,
|
|
142
|
+
"WhitespaceTokenType": 37,
|
|
143
|
+
"IncludeMatchTokenType": 38,
|
|
144
|
+
"DashMatchTokenType": 39,
|
|
145
|
+
"EqualMatchTokenType": 40,
|
|
146
|
+
"LtTokenType": 41,
|
|
147
|
+
"LteTokenType": 42,
|
|
148
|
+
"GtTokenType": 43,
|
|
149
|
+
"GteTokenType": 44,
|
|
150
|
+
"PseudoClassTokenType": 45,
|
|
151
|
+
"PseudoClassFuncTokenType": 46,
|
|
152
|
+
"DelimTokenType": 47,
|
|
153
|
+
"UrlTokenTokenType": 48,
|
|
154
|
+
"EOFTokenType": 49,
|
|
155
|
+
"ImportantTokenType": 50,
|
|
156
|
+
"ColorTokenType": 51,
|
|
157
|
+
"AttrTokenType": 52,
|
|
158
|
+
"BadCommentTokenType": 53,
|
|
159
|
+
"BadCdoTokenType": 54,
|
|
160
|
+
"BadUrlTokenType": 55,
|
|
161
|
+
"BadStringTokenType": 56,
|
|
162
|
+
"BinaryExpressionTokenType": 57,
|
|
163
|
+
"UnaryExpressionTokenType": 58,
|
|
164
|
+
"FlexTokenType": 59,
|
|
165
|
+
"ListToken": 60,
|
|
166
|
+
"Add": 61,
|
|
167
|
+
"Mul": 62,
|
|
168
|
+
"Div": 63,
|
|
169
|
+
"Sub": 64,
|
|
170
|
+
"ColumnCombinatorTokenType": 65,
|
|
171
|
+
"ContainMatchTokenType": 66,
|
|
172
|
+
"StartMatchTokenType": 67,
|
|
173
|
+
"EndMatchTokenType": 68,
|
|
174
|
+
"MatchExpressionTokenType": 69,
|
|
175
|
+
"NameSpaceAttributeTokenType": 70,
|
|
176
|
+
"FractionTokenType": 71,
|
|
177
|
+
"IdenListTokenType": 72,
|
|
178
|
+
"GridTemplateFuncTokenType": 73,
|
|
179
|
+
"KeyframesRuleNodeType": 74,
|
|
180
|
+
"ClassSelectorTokenType": 75,
|
|
181
|
+
"UniversalSelectorTokenType": 76,
|
|
182
|
+
"ChildCombinatorTokenType": 77,
|
|
183
|
+
"DescendantCombinatorTokenType": 78,
|
|
184
|
+
"NextSiblingCombinatorTokenType": 79,
|
|
185
|
+
"SubsequentSiblingCombinatorTokenType": 80,
|
|
186
|
+
"NestingSelectorTokenType": 81,
|
|
187
|
+
"MediaQueryConditionTokenType": 82,
|
|
188
|
+
"MediaFeatureTokenType": 83,
|
|
189
|
+
"OnlyTokenType": 84,
|
|
190
|
+
"NotTokenType": 85,
|
|
191
|
+
"AndTokenType": 86,
|
|
192
|
+
"OrTokenType": 87,
|
|
193
|
+
"PseudoPageTokenType": 88,
|
|
194
|
+
"PseudoElementTokenType": 89,
|
|
195
|
+
"KeyframesAtRuleNodeType": 90,
|
|
196
|
+
"ComposesSelectorNodeType": 91,
|
|
197
|
+
"CssVariableTokenType": 92,
|
|
198
|
+
"CssVariableImportTokenType": 93,
|
|
199
|
+
"CssVariableDeclarationMapTokenType": 94,
|
|
200
|
+
"MediaRangeQueryTokenType": 95,
|
|
201
|
+
"SupportsQueryConditionTokenType": 96,
|
|
202
|
+
"SupportsQueryUnaryConditionTokenType": 97,
|
|
203
|
+
"WhenElseQueryConditionTokenType": 98,
|
|
204
|
+
"WhenElseUnaryConditionTokenType": 99,
|
|
205
|
+
"ContainerStyleRangeTokenType": 100,
|
|
206
|
+
"Star": 101,
|
|
207
|
+
"Plus": 102,
|
|
208
|
+
"Tilda": 103,
|
|
209
|
+
"PipeTokenType": 104,
|
|
210
|
+
"DoubleColonTokenType": 105,
|
|
211
|
+
"MathFunctionTokenType": 106,
|
|
212
|
+
"TransformFunctionTokenType": 107,
|
|
213
|
+
"WhenElseFunctionTokenType": 108,
|
|
214
|
+
"GeneralEnclosedFunctionTokenType": 109,
|
|
215
|
+
"SupportsFunctionTokenType": 110,
|
|
216
|
+
"ContainerFunctionTokenType": 111,
|
|
217
|
+
"RawNodeTokenType": 112,
|
|
218
|
+
"MediaQueryUnaryFeatureTokenType": 113,
|
|
219
|
+
"GridTemplateFuncTokenDefType": 114,
|
|
220
|
+
"ImageFunctionTokenDefType": 115,
|
|
221
|
+
"TimelineFunctionTokenDefType": 116,
|
|
222
|
+
"FunctionTokenDefType": 117,
|
|
223
|
+
"TimingFunctionTokenDefType": 118,
|
|
224
|
+
"ColorFunctionTokenDefType": 119,
|
|
225
|
+
"MathFunctionTokenDefType": 120,
|
|
226
|
+
"ContainerFunctionTokenDefType": 121,
|
|
227
|
+
"UrlFunctionTokenDefType": 122,
|
|
228
|
+
"PseudoClassFunctionTokenDefType": 123,
|
|
229
|
+
"TransformFunctionTokenDefType": 124,
|
|
230
|
+
"WhenElseFunctionTokenDefType": 125,
|
|
231
|
+
"GeneralEnclosedFunctionTokenDefType": 126,
|
|
232
|
+
"SupportsFunctionTokenDefType": 127,
|
|
233
|
+
"CustomFunctionTokenDefType": 128,
|
|
234
|
+
"CustomFunctionTokenType": 129,
|
|
235
|
+
"WildCardFunctionTokenDefType": 130,
|
|
236
|
+
"WildCardFunctionTokenType": 131,
|
|
237
|
+
"IfConditionTokenType": 132,
|
|
238
|
+
"IfElseConditionTokenType": 133,
|
|
239
|
+
"WrappedValuesTokenType": 134,
|
|
240
|
+
"ListTokenType": 135,
|
|
241
|
+
"NaNTokenType": 136,
|
|
242
|
+
"InfinityTokenType": 137,
|
|
243
|
+
"NegativeInfinityTokenType": 138,
|
|
244
|
+
"CssTypeTokenType": 139,
|
|
245
|
+
"UserDefinedDimensionTokenType": 140,
|
|
246
|
+
"UniCodeRange": 141,
|
|
247
|
+
"Time": 26,
|
|
248
|
+
"Iden": 8,
|
|
249
|
+
"EOF": 49,
|
|
250
|
+
"Hash": 29,
|
|
251
|
+
"Flex": 59,
|
|
252
|
+
"Angle": 25,
|
|
253
|
+
"Color": 51,
|
|
254
|
+
"Comma": 10,
|
|
255
|
+
"String": 21,
|
|
256
|
+
"Length": 24,
|
|
257
|
+
"Number": 13,
|
|
258
|
+
"Perc": 15,
|
|
259
|
+
"Literal": 7,
|
|
260
|
+
"Comment": 1,
|
|
261
|
+
"UrlFunc": 19,
|
|
262
|
+
"Dimension": 23,
|
|
263
|
+
"Frequency": 27,
|
|
264
|
+
"Resolution": 28,
|
|
265
|
+
"Whitespace": 37,
|
|
266
|
+
"IdenList": 72,
|
|
267
|
+
"DashedIden": 9,
|
|
268
|
+
"GridTemplateFunc": 73,
|
|
269
|
+
"ImageFunc": 20,
|
|
270
|
+
"CommentNodeType": 1,
|
|
271
|
+
"CDOCOMMNodeType": 2,
|
|
272
|
+
"TimingFunction": 18,
|
|
273
|
+
"TimelineFunction": 17,
|
|
274
|
+
"3": "StyleSheetNodeType",
|
|
275
|
+
"4": "AtRuleNodeType",
|
|
276
|
+
"5": "RuleNodeType",
|
|
277
|
+
"6": "DeclarationNodeType",
|
|
278
|
+
"11": "ColonTokenType",
|
|
279
|
+
"12": "SemiColonTokenType",
|
|
280
|
+
"14": "AtRuleTokenType",
|
|
281
|
+
"16": "FunctionTokenType",
|
|
282
|
+
"22": "UnclosedStringTokenType",
|
|
283
|
+
"30": "BlockStartTokenType",
|
|
284
|
+
"31": "BlockEndTokenType",
|
|
285
|
+
"32": "AttrStartTokenType",
|
|
286
|
+
"33": "AttrEndTokenType",
|
|
287
|
+
"34": "StartParensTokenType",
|
|
288
|
+
"35": "EndParensTokenType",
|
|
289
|
+
"36": "ParensTokenType",
|
|
290
|
+
"38": "IncludeMatchTokenType",
|
|
291
|
+
"39": "DashMatchTokenType",
|
|
292
|
+
"40": "EqualMatchTokenType",
|
|
293
|
+
"41": "LtTokenType",
|
|
294
|
+
"42": "LteTokenType",
|
|
295
|
+
"43": "GtTokenType",
|
|
296
|
+
"44": "GteTokenType",
|
|
297
|
+
"45": "PseudoClassTokenType",
|
|
298
|
+
"46": "PseudoClassFuncTokenType",
|
|
299
|
+
"47": "DelimTokenType",
|
|
300
|
+
"48": "UrlTokenTokenType",
|
|
301
|
+
"50": "ImportantTokenType",
|
|
302
|
+
"52": "AttrTokenType",
|
|
303
|
+
"53": "BadCommentTokenType",
|
|
304
|
+
"54": "BadCdoTokenType",
|
|
305
|
+
"55": "BadUrlTokenType",
|
|
306
|
+
"56": "BadStringTokenType",
|
|
307
|
+
"57": "BinaryExpressionTokenType",
|
|
308
|
+
"58": "UnaryExpressionTokenType",
|
|
309
|
+
"60": "ListToken",
|
|
310
|
+
"61": "Add",
|
|
311
|
+
"62": "Mul",
|
|
312
|
+
"63": "Div",
|
|
313
|
+
"64": "Sub",
|
|
314
|
+
"65": "ColumnCombinatorTokenType",
|
|
315
|
+
"66": "ContainMatchTokenType",
|
|
316
|
+
"67": "StartMatchTokenType",
|
|
317
|
+
"68": "EndMatchTokenType",
|
|
318
|
+
"69": "MatchExpressionTokenType",
|
|
319
|
+
"70": "NameSpaceAttributeTokenType",
|
|
320
|
+
"71": "FractionTokenType",
|
|
321
|
+
"74": "KeyframesRuleNodeType",
|
|
322
|
+
"75": "ClassSelectorTokenType",
|
|
323
|
+
"76": "UniversalSelectorTokenType",
|
|
324
|
+
"77": "ChildCombinatorTokenType",
|
|
325
|
+
"78": "DescendantCombinatorTokenType",
|
|
326
|
+
"79": "NextSiblingCombinatorTokenType",
|
|
327
|
+
"80": "SubsequentSiblingCombinatorTokenType",
|
|
328
|
+
"81": "NestingSelectorTokenType",
|
|
329
|
+
"82": "MediaQueryConditionTokenType",
|
|
330
|
+
"83": "MediaFeatureTokenType",
|
|
331
|
+
"84": "OnlyTokenType",
|
|
332
|
+
"85": "NotTokenType",
|
|
333
|
+
"86": "AndTokenType",
|
|
334
|
+
"87": "OrTokenType",
|
|
335
|
+
"88": "PseudoPageTokenType",
|
|
336
|
+
"89": "PseudoElementTokenType",
|
|
337
|
+
"90": "KeyframesAtRuleNodeType",
|
|
338
|
+
"91": "ComposesSelectorNodeType",
|
|
339
|
+
"92": "CssVariableTokenType",
|
|
340
|
+
"93": "CssVariableImportTokenType",
|
|
341
|
+
"94": "CssVariableDeclarationMapTokenType",
|
|
342
|
+
"95": "MediaRangeQueryTokenType",
|
|
343
|
+
"96": "SupportsQueryConditionTokenType",
|
|
344
|
+
"97": "SupportsQueryUnaryConditionTokenType",
|
|
345
|
+
"98": "WhenElseQueryConditionTokenType",
|
|
346
|
+
"99": "WhenElseUnaryConditionTokenType",
|
|
347
|
+
"100": "ContainerStyleRangeTokenType",
|
|
348
|
+
"101": "Star",
|
|
349
|
+
"102": "Plus",
|
|
350
|
+
"103": "Tilda",
|
|
351
|
+
"104": "PipeTokenType",
|
|
352
|
+
"105": "DoubleColonTokenType",
|
|
353
|
+
"106": "MathFunctionTokenType",
|
|
354
|
+
"107": "TransformFunctionTokenType",
|
|
355
|
+
"108": "WhenElseFunctionTokenType",
|
|
356
|
+
"109": "GeneralEnclosedFunctionTokenType",
|
|
357
|
+
"110": "SupportsFunctionTokenType",
|
|
358
|
+
"111": "ContainerFunctionTokenType",
|
|
359
|
+
"112": "RawNodeTokenType",
|
|
360
|
+
"113": "MediaQueryUnaryFeatureTokenType",
|
|
361
|
+
"114": "GridTemplateFuncTokenDefType",
|
|
362
|
+
"115": "ImageFunctionTokenDefType",
|
|
363
|
+
"116": "TimelineFunctionTokenDefType",
|
|
364
|
+
"117": "FunctionTokenDefType",
|
|
365
|
+
"118": "TimingFunctionTokenDefType",
|
|
366
|
+
"119": "ColorFunctionTokenDefType",
|
|
367
|
+
"120": "MathFunctionTokenDefType",
|
|
368
|
+
"121": "ContainerFunctionTokenDefType",
|
|
369
|
+
"122": "UrlFunctionTokenDefType",
|
|
370
|
+
"123": "PseudoClassFunctionTokenDefType",
|
|
371
|
+
"124": "TransformFunctionTokenDefType",
|
|
372
|
+
"125": "WhenElseFunctionTokenDefType",
|
|
373
|
+
"126": "GeneralEnclosedFunctionTokenDefType",
|
|
374
|
+
"127": "SupportsFunctionTokenDefType",
|
|
375
|
+
"128": "CustomFunctionTokenDefType",
|
|
376
|
+
"129": "CustomFunctionTokenType",
|
|
377
|
+
"130": "WildCardFunctionTokenDefType",
|
|
378
|
+
"131": "WildCardFunctionTokenType",
|
|
379
|
+
"132": "IfConditionTokenType",
|
|
380
|
+
"133": "IfElseConditionTokenType",
|
|
381
|
+
"134": "WrappedValuesTokenType",
|
|
382
|
+
"135": "ListTokenType",
|
|
383
|
+
"136": "NaNTokenType",
|
|
384
|
+
"137": "InfinityTokenType",
|
|
385
|
+
"138": "NegativeInfinityTokenType",
|
|
386
|
+
"139": "CssTypeTokenType",
|
|
387
|
+
"140": "UserDefinedDimensionTokenType",
|
|
388
|
+
"141": "UniCodeRange",
|
|
389
|
+
"26": "Time",
|
|
390
|
+
"8": "Iden",
|
|
391
|
+
"49": "EOF",
|
|
392
|
+
"29": "Hash",
|
|
393
|
+
"59": "Flex",
|
|
394
|
+
"25": "Angle",
|
|
395
|
+
"51": "Color",
|
|
396
|
+
"10": "Comma",
|
|
397
|
+
"21": "String",
|
|
398
|
+
"24": "Length",
|
|
399
|
+
"13": "Number",
|
|
400
|
+
"15": "Perc",
|
|
401
|
+
"7": "Literal",
|
|
402
|
+
"19": "UrlFunc",
|
|
403
|
+
"23": "Dimension",
|
|
404
|
+
"27": "Frequency",
|
|
405
|
+
"28": "Resolution",
|
|
406
|
+
"37": "Whitespace",
|
|
407
|
+
"72": "IdenList",
|
|
408
|
+
"9": "DashedIden",
|
|
409
|
+
"73": "GridTemplateFunc",
|
|
410
|
+
"20": "ImageFunc",
|
|
411
|
+
"1": "CommentNodeType",
|
|
412
|
+
"2": "CDOCOMMNodeType",
|
|
413
|
+
"18": "TimingFunction",
|
|
414
|
+
"17": "TimelineFunction",
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
export const ModuleCaseTransformEnum = Object.freeze({
|
|
418
|
+
"IgnoreCase": 1,
|
|
419
|
+
"CamelCase": 2,
|
|
420
|
+
"CamelCaseOnly": 4,
|
|
421
|
+
"DashCase": 8,
|
|
422
|
+
"DashCaseOnly": 16,
|
|
423
|
+
"1": "IgnoreCase",
|
|
424
|
+
"2": "CamelCase",
|
|
425
|
+
"4": "CamelCaseOnly",
|
|
426
|
+
"8": "DashCase",
|
|
427
|
+
"16": "DashCaseOnly",
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
export const ModuleScopeEnumOptions = Object.freeze({
|
|
431
|
+
"Global": 32,
|
|
432
|
+
"Local": 64,
|
|
433
|
+
"Pure": 128,
|
|
434
|
+
"ICSS": 256,
|
|
435
|
+
"Shortest": 512,
|
|
436
|
+
"32": "Global",
|
|
437
|
+
"64": "Local",
|
|
438
|
+
"128": "Pure",
|
|
439
|
+
"256": "ICSS",
|
|
440
|
+
"512": "Shortest",
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
export const WalkerEvent = Object.freeze({
|
|
444
|
+
"Enter": 1,
|
|
445
|
+
"Leave": 2,
|
|
446
|
+
"1": "Enter",
|
|
447
|
+
"2": "Leave",
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
export const WalkerOptionEnum = Object.freeze({
|
|
451
|
+
"Ignore": 1,
|
|
452
|
+
"Stop": 2,
|
|
453
|
+
"Children": 4,
|
|
454
|
+
"IgnoreChildren": 8,
|
|
455
|
+
"1": "Ignore",
|
|
456
|
+
"2": "Stop",
|
|
457
|
+
"4": "Children",
|
|
458
|
+
"8": "IgnoreChildren",
|
|
459
|
+
});
|
|
460
|
+
|
package/dist/backend.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// WASM backend of the runtime (see runtime.js): the WebAssembly module css_parser.wasm, in node and in the browsers
|
|
2
|
+
|
|
3
|
+
import { columnTypes } from "./columns.js";
|
|
4
|
+
|
|
5
|
+
const isNode = typeof process !== "undefined" && process.versions?.node != null && typeof window === "undefined";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* the backend of this package
|
|
9
|
+
*/
|
|
10
|
+
export const backendName = "wasm";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* the WASM backend: the exchange buffer and the columns are views of the linear memory
|
|
14
|
+
*/
|
|
15
|
+
export async function createBackend() {
|
|
16
|
+
const url = new URL("./css_parser.wasm", import.meta.url);
|
|
17
|
+
let bytes;
|
|
18
|
+
|
|
19
|
+
if (isNode) {
|
|
20
|
+
const { readFile } = await import("node:fs/promises");
|
|
21
|
+
bytes = await readFile(url);
|
|
22
|
+
} else {
|
|
23
|
+
bytes = await fetch(url).then((response) => {
|
|
24
|
+
if (!response.ok) {
|
|
25
|
+
throw new Error(`could not load ${url}: ${response.status}`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return response.arrayBuffer();
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let host = null;
|
|
33
|
+
const { instance } = await WebAssembly.instantiate(bytes, {
|
|
34
|
+
env: {
|
|
35
|
+
css_now: () => performance.now(),
|
|
36
|
+
css_host: (length) => host(length),
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
const exports = instance.exports;
|
|
40
|
+
const memory = exports.memory;
|
|
41
|
+
// the pointers and the lengths are i32 values: the addresses above 2 GB of the linear memory (up to 4 GB) are
|
|
42
|
+
// negative numbers, they are read as unsigned
|
|
43
|
+
const u32 = (value) => value >>> 0;
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
exchange(capacity) {
|
|
47
|
+
const ptr = u32(exports.css_buffer(capacity));
|
|
48
|
+
return new Uint8Array(memory.buffer, ptr, capacity);
|
|
49
|
+
},
|
|
50
|
+
invoke(length) {
|
|
51
|
+
return exports.css_call(length);
|
|
52
|
+
},
|
|
53
|
+
setHost(fn) {
|
|
54
|
+
host = fn;
|
|
55
|
+
},
|
|
56
|
+
column(handle, index) {
|
|
57
|
+
const Type = columnTypes[index];
|
|
58
|
+
const length = u32(exports.css_column_len(handle, index));
|
|
59
|
+
|
|
60
|
+
if (length === 0) {
|
|
61
|
+
return new Type(0);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return new Type(memory.buffer, u32(exports.css_column_ptr(handle, index)), length);
|
|
65
|
+
},
|
|
66
|
+
generation(handle) {
|
|
67
|
+
return new Uint32Array(memory.buffer, u32(exports.css_generation_ptr(handle)), 1);
|
|
68
|
+
},
|
|
69
|
+
output(id) {
|
|
70
|
+
// the linear memory cannot be given away: one copy
|
|
71
|
+
const length = u32(exports.css_output_take(id));
|
|
72
|
+
const buffer = new ArrayBuffer(length);
|
|
73
|
+
|
|
74
|
+
new Uint8Array(buffer).set(new Uint8Array(memory.buffer, u32(exports.css_output_ptr()), length));
|
|
75
|
+
exports.css_output_free();
|
|
76
|
+
return buffer;
|
|
77
|
+
},
|
|
78
|
+
stale(view) {
|
|
79
|
+
return view.buffer !== memory.buffer;
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
package/dist/columns.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// the typed array types of the arena columns, by column index (see AstArena::column_raw in rust)
|
|
2
|
+
|
|
3
|
+
export const columnTypes = [
|
|
4
|
+
Uint8Array,
|
|
5
|
+
Uint32Array,
|
|
6
|
+
Uint32Array,
|
|
7
|
+
Uint32Array,
|
|
8
|
+
Uint32Array,
|
|
9
|
+
Uint32Array,
|
|
10
|
+
Uint32Array,
|
|
11
|
+
Uint32Array,
|
|
12
|
+
Uint32Array,
|
|
13
|
+
Uint32Array,
|
|
14
|
+
Float64Array,
|
|
15
|
+
Uint32Array,
|
|
16
|
+
Uint32Array,
|
|
17
|
+
Uint8Array,
|
|
18
|
+
BigUint64Array,
|
|
19
|
+
];
|
|
20
|
+
|
package/dist/core.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Loads the native code of the extension: the N-API addon (package css-parser-napi) or the WASM module (package
|
|
2
|
+
// css-parser-wasm). Each package provides its own `backend.js` next to this file.
|
|
3
|
+
|
|
4
|
+
import { Runtime, readAll } from "./runtime.js";
|
|
5
|
+
import { backendName, createBackend } from "./backend.js";
|
|
6
|
+
import { columnTypes } from "./columns.js";
|
|
7
|
+
|
|
8
|
+
export { readAll, backendName, columnTypes };
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* the classes created from the values (set by ast/arena.js), shared by the runtimes
|
|
12
|
+
*/
|
|
13
|
+
export const classes = {};
|
|
14
|
+
|
|
15
|
+
const runtimes = new Map();
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* the runtime of the backend of the package ("napi" or "wasm"), created once
|
|
19
|
+
*/
|
|
20
|
+
export function getRuntime(name = backendName) {
|
|
21
|
+
if (name !== backendName) {
|
|
22
|
+
throw new Error(`the ${name} backend is not available: this package provides the ${backendName} backend`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let runtime = runtimes.get(name);
|
|
26
|
+
|
|
27
|
+
if (runtime === undefined) {
|
|
28
|
+
runtime = createBackend().then((backend) => {
|
|
29
|
+
const result = new Runtime(backend, classes);
|
|
30
|
+
|
|
31
|
+
result.name = name;
|
|
32
|
+
return result;
|
|
33
|
+
});
|
|
34
|
+
runtimes.set(name, runtime);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return runtime;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* the runtime of the package backend
|
|
42
|
+
*/
|
|
43
|
+
export const rt = await getRuntime(backendName);
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* the runtime of an arena, or of an arena node: the default runtime otherwise
|
|
47
|
+
*/
|
|
48
|
+
export function runtimeOf(value) {
|
|
49
|
+
return (value != null && classes.runtimeOf?.(value)) || rt;
|
|
50
|
+
}
|
|
Binary file
|