@tbela99/css-parser 2.0.1 → 2.2.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 (128) hide show
  1. package/CHANGELOG.md +86 -1
  2. package/README.md +15 -7
  3. package/architecture.png +0 -0
  4. package/dist/{src/data → data}/properties.json.js +86 -2
  5. package/dist/{src/data → data}/validation.json.js +4848 -3750
  6. package/dist/index-umd-web.js +18234 -9498
  7. package/dist/index.d.ts +1251 -373
  8. package/dist/{src/lib → lib}/ast/arena-node.js +119 -57
  9. package/dist/{src/lib → lib}/ast/arena.js +1034 -655
  10. package/dist/{src/lib → lib}/ast/cache.js +36 -31
  11. package/dist/{src/lib → lib}/ast/features/calc.js +37 -27
  12. package/dist/{src/lib → lib}/ast/features/if.js +24 -19
  13. package/dist/{src/lib → lib}/ast/features/index.js +3 -2
  14. package/dist/{src/lib → lib}/ast/features/inlinecssvariables.js +42 -23
  15. package/dist/lib/ast/features/mixin.js +953 -0
  16. package/dist/{src/lib → lib}/ast/features/prefix.js +82 -69
  17. package/dist/lib/ast/features/shorthand.js +129 -0
  18. package/dist/lib/ast/features/transform.js +188 -0
  19. package/dist/{src/lib → lib}/ast/features/type.js +2 -2
  20. package/dist/{src/lib → lib}/ast/math/expression.js +150 -150
  21. package/dist/{src/lib → lib}/ast/math/math.js +8 -8
  22. package/dist/{src/lib → lib}/ast/minify.js +932 -354
  23. package/dist/lib/ast/mixins/custom-function.js +393 -0
  24. package/dist/lib/ast/mixins/utils.js +53 -0
  25. package/dist/lib/ast/mixins/variables.js +678 -0
  26. package/dist/lib/ast/strings.js +906 -0
  27. package/dist/lib/ast/transform/compute.js +560 -0
  28. package/dist/lib/ast/transform/matrix.js +67 -0
  29. package/dist/lib/ast/transform/minify.js +325 -0
  30. package/dist/lib/ast/transform/perspective.js +24 -0
  31. package/dist/{src/lib → lib}/ast/transform/rotate.js +16 -7
  32. package/dist/lib/ast/transform/scale.js +43 -0
  33. package/dist/lib/ast/transform/skew.js +38 -0
  34. package/dist/lib/ast/transform/translate.js +56 -0
  35. package/dist/lib/ast/transform/utils.js +390 -0
  36. package/dist/{src/lib → lib}/ast/types.js +7 -15
  37. package/dist/{src/lib → lib}/ast/walk.js +19 -19
  38. package/dist/{src/lib → lib}/fs/resolve.js +15 -15
  39. package/dist/{src/lib → lib}/parser/declaration/list.js +55 -26
  40. package/dist/{src/lib → lib}/parser/declaration/map.js +85 -72
  41. package/dist/{src/lib → lib}/parser/declaration/set.js +32 -27
  42. package/dist/lib/parser/input.js +85 -0
  43. package/dist/{src/lib → lib}/parser/linesmap.js +3 -16
  44. package/dist/{src/lib → lib}/parser/parse.js +852 -619
  45. package/dist/lib/parser/source.js +71 -0
  46. package/dist/{src/lib → lib}/parser/tokenize.js +886 -722
  47. package/dist/{src/lib → lib}/parser/utils/angle.js +3 -3
  48. package/dist/{src/lib → lib}/parser/utils/at-rule-container.js +68 -35
  49. package/dist/{src/lib → lib}/parser/utils/at-rule-font-feature-values.js +3 -3
  50. package/dist/{src/lib → lib}/parser/utils/at-rule-generic.js +31 -13
  51. package/dist/{src/lib → lib}/parser/utils/at-rule-import.js +29 -16
  52. package/dist/{src/lib → lib}/parser/utils/at-rule-media.js +77 -58
  53. package/dist/{src/lib → lib}/parser/utils/at-rule-support.js +18 -20
  54. package/dist/{src/lib → lib}/parser/utils/at-rule-when-else.js +9 -8
  55. package/dist/{src/lib → lib}/parser/utils/at-rule.js +3 -3
  56. package/dist/{src/lib → lib}/parser/utils/base64.js +2 -2
  57. package/dist/lib/parser/utils/cache.js +53 -0
  58. package/dist/lib/parser/utils/canonical.js +78 -0
  59. package/dist/lib/parser/utils/codes.js +93 -0
  60. package/dist/{src/lib → lib}/parser/utils/config.js +2 -2
  61. package/dist/{src/lib → lib}/parser/utils/declaration.js +67 -49
  62. package/dist/{src/lib → lib}/parser/utils/eq.js +14 -14
  63. package/dist/{src/lib → lib}/parser/utils/hash.js +4 -4
  64. package/dist/lib/parser/utils/selector.js +720 -0
  65. package/dist/{src/lib → lib}/parser/utils/text.js +2 -2
  66. package/dist/{src/lib → lib}/parser/utils/token.js +2 -2
  67. package/dist/{src/lib → lib}/parser/utils/type.js +11 -9
  68. package/dist/{src/lib → lib}/printer/render.js +536 -243
  69. package/dist/lib/printer/result.js +148 -0
  70. package/dist/{src/lib → lib}/printer/sourcemap/lib/codec.js +5 -8
  71. package/dist/{src/lib → lib}/printer/sourcemap/sourcemap.js +13 -13
  72. package/dist/lib/printer/writer.js +252 -0
  73. package/dist/{src/lib → lib}/syntax/color/a98rgb.js +6 -6
  74. package/dist/{src/lib → lib}/syntax/color/alpha.js +12 -11
  75. package/dist/{src/lib → lib}/syntax/color/cmyk.js +11 -6
  76. package/dist/{src/lib → lib}/syntax/color/color-mix.js +78 -67
  77. package/dist/{src/lib → lib}/syntax/color/color.js +52 -47
  78. package/dist/{src/lib → lib}/syntax/color/hex.js +17 -17
  79. package/dist/{src/lib → lib}/syntax/color/hsl.js +8 -8
  80. package/dist/{src/lib → lib}/syntax/color/hwb.js +6 -7
  81. package/dist/{src/lib → lib}/syntax/color/lab.js +8 -8
  82. package/dist/{src/lib → lib}/syntax/color/lch.js +12 -11
  83. package/dist/{src/lib → lib}/syntax/color/oklab.js +9 -9
  84. package/dist/{src/lib → lib}/syntax/color/oklch.js +5 -5
  85. package/dist/{src/lib → lib}/syntax/color/p3.js +2 -2
  86. package/dist/{src/lib → lib}/syntax/color/prophotorgb.js +4 -4
  87. package/dist/{src/lib → lib}/syntax/color/rec2020.js +3 -3
  88. package/dist/{src/lib → lib}/syntax/color/relative-color.js +41 -34
  89. package/dist/{src/lib → lib}/syntax/color/rgb.js +17 -17
  90. package/dist/{src/lib → lib}/syntax/color/srgb.js +20 -20
  91. package/dist/{src/lib → lib}/syntax/color/utils/color-type.js +6 -4
  92. package/dist/{src/lib → lib}/syntax/color/utils/colorspace.js +12 -14
  93. package/dist/{src/lib → lib}/syntax/color/utils/components.js +13 -13
  94. package/dist/{src/lib → lib}/syntax/color/utils/distance.js +2 -2
  95. package/dist/{src/lib → lib}/syntax/color/utils/make-color.js +6 -4
  96. package/dist/{src/lib → lib}/syntax/color/utils/matrix.js +2 -2
  97. package/dist/{src/lib → lib}/syntax/color/xyz.js +5 -10
  98. package/dist/{src/lib → lib}/syntax/color/xyzd50.js +3 -3
  99. package/dist/{src/lib → lib}/syntax/constants.js +30 -3
  100. package/dist/{src/lib → lib}/syntax/syntax.js +151 -116
  101. package/dist/lib/validation/config.js +173 -0
  102. package/dist/lib/validation/first.js +571 -0
  103. package/dist/{src/lib → lib}/validation/match.js +1256 -579
  104. package/dist/{src/lib → lib}/validation/parser/parse.js +85 -59
  105. package/dist/{src/lib → lib}/validation/parser/typedef.js +6 -2
  106. package/dist/{src/lib → lib}/validation/utils/list.js +3 -19
  107. package/dist/{src/node.js → node.js} +92 -80
  108. package/dist/{src/types.js → types.js} +2 -2
  109. package/dist/{src/utils → utils}/sync.js +13 -8
  110. package/dist/version.d.ts +4 -0
  111. package/dist/version.js +13 -0
  112. package/dist/{src/web.js → web.js} +80 -75
  113. package/package.json +13 -13
  114. package/dist/package.json.js +0 -10
  115. package/dist/src/lib/ast/features/shorthand.js +0 -87
  116. package/dist/src/lib/ast/features/transform.js +0 -85
  117. package/dist/src/lib/ast/transform/compute.js +0 -358
  118. package/dist/src/lib/ast/transform/matrix.js +0 -88
  119. package/dist/src/lib/ast/transform/minify.js +0 -267
  120. package/dist/src/lib/ast/transform/perspective.js +0 -16
  121. package/dist/src/lib/ast/transform/scale.js +0 -39
  122. package/dist/src/lib/ast/transform/skew.js +0 -30
  123. package/dist/src/lib/ast/transform/translate.js +0 -39
  124. package/dist/src/lib/ast/transform/utils.js +0 -287
  125. package/dist/src/lib/parser/source.js +0 -127
  126. package/dist/src/lib/parser/utils/cache.js +0 -54
  127. package/dist/src/lib/parser/utils/selector.js +0 -440
  128. package/dist/src/lib/validation/config.js +0 -120
package/dist/index.d.ts CHANGED
@@ -1,14 +1,3 @@
1
- /**
2
- * Syntax validation enum
3
- */
4
- declare enum SyntaxValidationResult {
5
- /** valid syntax */
6
- Valid = 0,
7
- /** drop invalid syntax */
8
- Drop = 1,
9
- /** preserve unknown at-rules, declarations and pseudo-classes */
10
- Lenient = 2
11
- }
12
1
  /**
13
2
  * Enum of node statuses
14
3
  */
@@ -646,6 +635,10 @@ declare enum EnumToken {
646
635
  * user defined dimension token type
647
636
  */
648
637
  UserDefinedDimensionTokenType = 140,
638
+ /**
639
+ * unicode range token type: `U+0025-00FF`, `U+4??`. the token is rendered as it is
640
+ */
641
+ UniCodeRange = 141,
649
642
  /**
650
643
  * alias for time token type
651
644
  */
@@ -1074,11 +1067,19 @@ declare class AstArenaNode {
1074
1067
  * at-rule / declaration name, token name. undefined for the other nodes
1075
1068
  */
1076
1069
  get nam(): string | undefined;
1070
+ /**
1071
+ *
1072
+ * @param nam
1073
+ */
1077
1074
  set nam(nam: string);
1078
1075
  /**
1079
1076
  * rule selector. undefined for the other nodes
1080
1077
  */
1081
1078
  get sel(): string | undefined;
1079
+ /**
1080
+ *
1081
+ * @param sel
1082
+ */
1082
1083
  set sel(sel: string);
1083
1084
  /**
1084
1085
  * value:
@@ -1090,22 +1091,38 @@ declare class AstArenaNode {
1090
1091
  * - structured tokens with a value field: the field tokens
1091
1092
  */
1092
1093
  get val(): string | number | AstArenaNode | readonly AstArenaNode[] | null | undefined;
1094
+ /**
1095
+ *
1096
+ * @param val
1097
+ */
1093
1098
  set val(val: string | number | AstArenaNodeInput | readonly AstArenaNodeInput[] | null | undefined);
1094
1099
  /**
1095
1100
  * children: the child nodes of a stylesheet, a rule or an at-rule with a block, the tokens of a function token
1096
1101
  * (arguments), a parentheses token, ... undefined when the node has no children
1097
1102
  */
1098
1103
  get chi(): readonly AstArenaNode[] | undefined;
1104
+ /**
1105
+ *
1106
+ * @param chi
1107
+ */
1099
1108
  set chi(chi: readonly AstArenaNodeInput[] | null | undefined);
1100
1109
  /**
1101
1110
  * prelude tokens of an at-rule, selector tokens of a rule. null when the node has no prelude tokens
1102
1111
  */
1103
1112
  get tokens(): readonly AstArenaNode[] | null;
1113
+ /**
1114
+ *
1115
+ * @param tokens
1116
+ */
1104
1117
  set tokens(tokens: readonly AstArenaNodeInput[] | null | undefined);
1105
1118
  /**
1106
1119
  * unit of a dimension, calendar (`cal`) of a color, attribute (`attr`) of a match expression
1107
1120
  */
1108
1121
  get unit(): string | undefined;
1122
+ /**
1123
+ *
1124
+ * @param unit
1125
+ */
1109
1126
  set unit(unit: string | null | undefined);
1110
1127
  /**
1111
1128
  * color space of a color
@@ -1126,46 +1143,82 @@ declare class AstArenaNode {
1126
1143
  * sign of a unary expression
1127
1144
  */
1128
1145
  get sign(): EnumToken | undefined;
1146
+ /**
1147
+ *
1148
+ * @param sign
1149
+ */
1129
1150
  set sign(sign: EnumToken);
1130
1151
  /**
1131
1152
  * operator: the operator of a binary expression, the operator tokens of a structured token
1132
1153
  */
1133
1154
  get op(): EnumToken | AstArenaNode | readonly AstArenaNode[] | null | undefined;
1155
+ /**
1156
+ *
1157
+ * @param op
1158
+ */
1134
1159
  set op(op: EnumToken | AstArenaNodeInput | readonly AstArenaNodeInput[] | null);
1135
1160
  /**
1136
1161
  * first operator of a media range query
1137
1162
  */
1138
1163
  get op1(): AstArenaNode | readonly AstArenaNode[] | null | undefined;
1164
+ /**
1165
+ *
1166
+ * @param op
1167
+ */
1139
1168
  set op1(op: AstArenaNodeInput | readonly AstArenaNodeInput[] | null);
1140
1169
  /**
1141
1170
  * second operator of a media range query
1142
1171
  */
1143
1172
  get op2(): AstArenaNode | readonly AstArenaNode[] | null | undefined;
1173
+ /**
1174
+ *
1175
+ * @param op
1176
+ */
1144
1177
  set op2(op: AstArenaNodeInput | readonly AstArenaNodeInput[] | null);
1145
1178
  /**
1146
1179
  * left hand side of a structured token, numerator of a fraction
1147
1180
  */
1148
1181
  get l(): AstArenaNode | readonly AstArenaNode[] | null | undefined;
1182
+ /**
1183
+ *
1184
+ * @param l
1185
+ */
1149
1186
  set l(l: AstArenaNodeInput | readonly AstArenaNodeInput[] | null);
1150
1187
  /**
1151
1188
  * right hand side of a structured token, denominator of a fraction
1152
1189
  */
1153
1190
  get r(): AstArenaNode | readonly AstArenaNode[] | null | undefined;
1191
+ /**
1192
+ *
1193
+ * @param r
1194
+ */
1154
1195
  set r(r: AstArenaNodeInput | readonly AstArenaNodeInput[] | null);
1155
1196
  /**
1156
1197
  * source location. null when the node has no location
1157
1198
  */
1158
1199
  get loc(): Readonly<SourceLocation> | null;
1200
+ /**
1201
+ *
1202
+ * @param loc
1203
+ */
1159
1204
  set loc(loc: SourceLocation | null | undefined);
1160
1205
  /**
1161
1206
  * validation state
1162
1207
  */
1163
1208
  get state(): EnumAstNodeStatus;
1209
+ /**
1210
+ *
1211
+ * @param state
1212
+ */
1164
1213
  set state(state: EnumAstNodeStatus | null | undefined);
1165
1214
  /**
1166
1215
  * validation errors. null when the node has no errors
1167
1216
  */
1168
1217
  get errors(): readonly ErrorDescription[] | null;
1218
+ /**
1219
+ *
1220
+ * @param errors
1221
+ */
1169
1222
  set errors(errors: readonly ErrorDescription[] | null | undefined);
1170
1223
  /**
1171
1224
  * parent node, or the token that owns the token (see {@link AstArena.getValueParent}). null when the node is
@@ -1190,310 +1243,850 @@ declare class AstArenaNode {
1190
1243
  }
1191
1244
 
1192
1245
  /**
1193
- * Arena memory manager: ast nodes and value tokens are integer ids, their data is stored column-wise
1194
- * in typed arrays (structure of arrays), lists are doubly linked lists stored in the `firstChild` /
1195
- * `lastChild` / `firstToken` / `lastToken` / `nextSibling` / `previousSibling` columns and strings are interned.
1246
+ * Hashing and comparison of strings and of ranges of code units, without creating strings.
1196
1247
  *
1197
- * Every node owns two lists that share the sibling columns:
1248
+ * The tokenizer reads the code units of the css source (see `toCodeUnits()`): the values of the tokens are ranges of
1249
+ * the code units. The tables of the tokenizer and the string table of the arena are keyed by the hash of the code units:
1250
+ * a string and a range of code units with the same content have the same hash. When the hashes are equal, the code
1251
+ * units are compared: the hash is 30 bits, different strings may have the same hash.
1198
1252
  *
1199
- * - the children list (`firstChild` / `lastChild`): the child nodes of a stylesheet, a rule or an at-rule, or the
1200
- * structured fields of a token (see {@link TokenField}),
1201
- * - the token list (`firstToken` / `lastToken`): the value tokens of a declaration, the prelude tokens of a rule / at-rule
1202
- * or the arguments of a function token (`chi`).
1253
+ * @module
1254
+ * @internal
1255
+ */
1256
+ /**
1257
+ * code units of the css source: the bytes of an ascii input, the utf-16 code units otherwise
1258
+ */
1259
+ type CodeUnits = Uint8Array | Uint16Array;
1260
+
1261
+ /**
1262
+ * String table of an arena.
1203
1263
  *
1204
- * Token columns:
1264
+ * The strings of the nodes (selectors, names, identifiers, strings, units, ...) are interned: a node stores a string id.
1265
+ * An interned string is not necessarily a string object, it is a range of a text:
1205
1266
  *
1206
- * - `dataTypes`: token type ({@link EnumToken}),
1207
- * - `stringValue`: interned string value (`val`) of identifiers, strings, literals, function names, colors, ...
1208
- * - `numericValue`: numeric value (`val`) of numbers, dimensions and percentages. operator of binary expressions, sign of unary expressions,
1209
- * - `unit`: interned unit of dimensions,
1210
- * - `name`: interned name (`nam`) of at-rule / declaration tokens,
1211
- * - `colorType`: color kind (`kin`) of color tokens,
1212
- * - `spans`: packed source location.
1267
+ * - a range of the content of a source file (`source.content`): the values of the tokens read by the tokenizer. the
1268
+ * table stores the source index and the start and end offsets, no string is created
1269
+ * - a range of the canonical text (see {@link canonicalText}): the spelling of the known units and function names
1270
+ * - a range of the pool: the code units of the strings that are not a range of a source (decoded escape sequences,
1271
+ * the values parsed from a string by `parseString()`) are copied to the pool
1272
+ * - a string: the strings interned by {@link StringTable.intern} (generated by the minifier, the visitors, ...) are
1273
+ * kept as they are
1213
1274
  *
1214
- * Structured tokens (binary expressions, media queries conditions, ...) store their fields (`l`, `r`, `op`, ...) as
1215
- * {@link EnumToken.ListTokenType} children at fixed positions ({@link TokenField}). Fraction tokens store their
1216
- * numerator and denominator as children, numeric tokens with a fraction value store the fraction token as their child.
1275
+ * The table is keyed by the hash of the code units: a string and a range with the same content have the same id.
1276
+ * When the hashes are equal, the code units are compared. The strings are created when they are read
1277
+ * ({@link StringTable.get}), once per id.
1217
1278
  *
1218
1279
  * @module
1280
+ * @internal
1219
1281
  */
1220
1282
 
1221
1283
  /**
1222
- * position of the structured token fields in the children list
1284
+ * boolean properties of the strings computed once per string id, see {@link StringTable.flag}. 4 flags at most
1223
1285
  */
1224
- declare enum TokenField {
1225
- /**
1226
- * left hand side (`l`)
1227
- */
1228
- L = 0,
1229
- /**
1230
- * right hand side (`r`)
1231
- */
1232
- R = 1,
1286
+ declare const enum StringFlag {
1233
1287
  /**
1234
- * operator (`op`, `op1`)
1288
+ * the string is a named color, a system color or `currentcolor` / `transparent`, ignoring the case
1235
1289
  */
1236
- Op = 2,
1290
+ Color = 0,
1237
1291
  /**
1238
- * second operator (`op2`)
1292
+ * a rule selector that is not modified by the minifier (see `isSimpleSelector()`)
1239
1293
  */
1240
- Op2 = 3,
1294
+ SimpleSelector = 1,
1241
1295
  /**
1242
- * value (`val`)
1296
+ * a rule selector that contains a vendor prefixed pseudo class (see `selectorPrefixes()`)
1243
1297
  */
1244
- Val = 4
1298
+ VendorPrefix = 2
1245
1299
  }
1246
1300
  /**
1247
- * Plain (structured-cloneable) properties of an arena. See {@link Arena.toTransferableArenaObject}
1301
+ * values derived from the strings computed once per string id, see {@link StringTable.derived}
1248
1302
  */
1249
- interface ArenaProperties {
1303
+ declare const enum StringDerived {
1250
1304
  /**
1251
- * arena class name: `Arena` or `AstArena`
1305
+ * the validation syntax of a function (`name()`)
1252
1306
  */
1253
- kind: string;
1307
+ FunctionSyntax = 0,
1254
1308
  /**
1255
- * last allocated id
1309
+ * the validation syntax of a selector function (`:name()`)
1256
1310
  */
1257
- current: number;
1311
+ SelectorFunctionSyntax = 1,
1258
1312
  /**
1259
- * interned strings
1313
+ * the kind of a transform function name or of a transform property name (see `transformKind()`)
1260
1314
  */
1261
- strings: string[];
1315
+ TransformKind = 2
1316
+ }
1317
+ /**
1318
+ * structured-cloneable copy of a string table, see {@link StringTable.export}
1319
+ */
1320
+ interface StringTableData {
1262
1321
  /**
1263
- * validation errors by node id
1322
+ * number of strings
1264
1323
  */
1265
- errors: Array<[number, ErrorDescription[]]>;
1324
+ count: number;
1266
1325
  /**
1267
- * source ids ({@link AstArena})
1326
+ * hash, source, start and end of each string
1268
1327
  */
1269
- sources?: number[];
1328
+ hashes: Int32Array;
1329
+ sources: Int32Array;
1330
+ starts: Int32Array;
1331
+ ends: Int32Array;
1270
1332
  /**
1271
- * raw selectors cache ({@link AstArena})
1333
+ * text of each source, by source index
1272
1334
  */
1273
- raw?: Array<RawSelectorTokens | null | undefined>;
1335
+ texts: string[];
1274
1336
  /**
1275
- * optimized selectors cache ({@link AstArena})
1337
+ * code units of the pool
1338
+ */
1339
+ pool: Uint16Array;
1340
+ /**
1341
+ * the strings of the `StringSource.Value` entries, by id
1276
1342
  */
1277
- optimized?: Array<OptimizedSelector | null | undefined>;
1343
+ values: Array<string | undefined>;
1278
1344
  }
1279
1345
  /**
1280
- * Column buffers of an arena, in the order of {@link arenaColumns}. See {@link Arena.toTransferableArenaObject}
1281
- */
1282
- type ArenaTransferables = ArrayBuffer[];
1283
- /**
1284
- * arena columns stored as typed arrays, in the order of the transferable buffers
1285
- */
1286
- declare const arenaColumns: readonly ["dataTypes", "parents", "nextSibling", "previousSibling", "firstToken", "lastToken", "firstChild", "lastChild", "name", "stringValue", "numericValue", "unit", "flags", "colorType", "spans"];
1287
- /**
1288
- * Arena memory manager.
1346
+ * builds a string from code units, strings and interned strings, then interns it: no string is created
1289
1347
  *
1290
- * The node data is stored column-wise in typed arrays allocated for the capacity of the arena ({@link getCapacity},
1291
- * 62 bytes per node). The arena grows by doubling its capacity and never frees memory by itself: detached nodes keep
1292
- * their memory and their ids stay valid. {@link release}, {@link compact}, {@link trim} and {@link compactStrings}
1293
- * reclaim the memory, `compact()` and `trim()` renumber the nodes. See the Arena Memory guide (files/arena.md).
1348
+ * @internal
1294
1349
  */
1295
- declare class Arena {
1296
- #private;
1350
+ declare class StringBuilder {
1297
1351
  /**
1298
- * string interner identifiers
1352
+ * code units
1299
1353
  */
1300
- stringIds: Map<string, number>;
1354
+ codes: Uint16Array;
1301
1355
  /**
1302
- * string interner values
1356
+ * number of code units
1303
1357
  */
1304
- strings: string[];
1358
+ length: number;
1305
1359
  /**
1306
- * root node
1360
+ * drop the code units
1307
1361
  */
1308
- readonly root: number;
1362
+ reset(): this;
1309
1363
  /**
1310
- * last allocated node id. the next node is allocated with the id current + 1 (unless a recycled id is available).
1311
- * 0 is never allocated: it means "no node"
1364
+ * append the code units of an interned string
1365
+ * @param table
1366
+ * @param id
1312
1367
  */
1313
- current: number;
1368
+ appendId(table: StringTable, id: number): this;
1314
1369
  /**
1315
- * head of the list of recycled node ids. the list is linked through the `nextSibling` column, see {@link recycle}
1370
+ * append a string
1371
+ * @param str
1316
1372
  */
1317
- protected freeList: number;
1373
+ appendString(str: string): this;
1318
1374
  /**
1319
- * node EnumToken type array
1375
+ * append a code unit
1376
+ * @param code
1320
1377
  */
1321
- dataTypes: Uint8Array;
1378
+ appendCode(code: number): this;
1322
1379
  /**
1323
- * parent node id array
1380
+ * intern the string
1381
+ * @param table
1324
1382
  */
1325
- parents: Uint32Array;
1383
+ intern(table: StringTable): number;
1326
1384
  /**
1327
- * next sibling node id array
1385
+ * make room for more code units
1386
+ * @param size
1328
1387
  */
1329
- nextSibling: Uint32Array;
1388
+ private reserve;
1389
+ }
1390
+ /**
1391
+ * interned strings of an arena
1392
+ *
1393
+ * @internal
1394
+ */
1395
+ declare class StringTable {
1330
1396
  /**
1331
- * previous sibling node id array
1397
+ * An instance is kept alive: the hidden class of the instances would otherwise be collected by a full garbage
1398
+ * collection when no instance is alive, and the optimized code that depends on it discarded (deoptimized)
1332
1399
  */
1333
- previousSibling: Uint32Array;
1400
+ static readonly shape: StringTable;
1334
1401
  /**
1335
- * first token node id array
1402
+ * number of strings
1336
1403
  */
1337
- firstToken: Uint32Array;
1404
+ count: number;
1338
1405
  /**
1339
- * last token node id array
1406
+ * strings by id: the strings that have been read (see {@link get}) and the `StringSource.Value` strings
1340
1407
  */
1341
- lastToken: Uint32Array;
1408
+ cache: Array<string | undefined>;
1342
1409
  /**
1343
- * first child node id array
1410
+ * identity of the ids: replaced when the ids change (see {@link compact}). the caches keyed by string ids use it
1411
+ * as a key
1344
1412
  */
1345
- firstChild: Uint32Array;
1413
+ epoch: object;
1346
1414
  /**
1347
- * last child node id array
1415
+ * hash of each string
1348
1416
  */
1349
- lastChild: Uint32Array;
1417
+ private hashes;
1350
1418
  /**
1351
- * node name string interner id array. used to store (node as AstRule | AstDeclaration | AstKeyframesAtRule).nam and (node as AstRule | AstKeyframesRule).sel
1419
+ * source of each string, see {@link StringSource}
1352
1420
  */
1353
- name: Uint32Array;
1421
+ private sources;
1354
1422
  /**
1355
- * node string value index array.
1423
+ * start of each string in its source
1356
1424
  */
1357
- stringValue: Uint32Array;
1425
+ private starts;
1358
1426
  /**
1359
- * node numeric value array. previously used as (node as NumberToken | DimensionToken).val
1427
+ * end of each string in its source
1360
1428
  */
1361
- numericValue: Float64Array;
1429
+ private ends;
1362
1430
  /**
1363
- * node unit string interner id array. previously used as (node as DimensionToken).unit
1431
+ * hash table: string id + 1 by slot, 0 when the slot is empty (open addressing, linear probing). the load factor
1432
+ * is at most 0.5
1364
1433
  */
1365
- unit: Uint32Array;
1434
+ private slots;
1366
1435
  /**
1367
- * node flags
1436
+ * text of the sources, by source index
1368
1437
  */
1369
- flags: Uint32Array;
1438
+ private texts;
1370
1439
  /**
1371
- * color type. previously use as (node as ColorToken).kin
1440
+ * code units of the sources being tokenized, by source index
1372
1441
  */
1373
- colorType: Uint8Array;
1442
+ private codes;
1374
1443
  /**
1375
- * token spans. 8 bits for source type. 28 bits for start position, 28 bits for end position. This allows us to store the start and end positions of tokens in a single 64-bit integer, which is more efficient than storing them separately.
1444
+ * values derived from the strings, by slot and by id (see {@link derived})
1376
1445
  */
1377
- spans: BigUint64Array;
1446
+ private derivedValues;
1378
1447
  /**
1379
- * 32 bits view of the spans: the low word holds the end position and the 4 low bits of the start position,
1380
- * the high word holds the 24 high bits of the start position and the source
1448
+ * properties of the strings, by id (see {@link flag})
1381
1449
  */
1382
- protected spans32: Uint32Array;
1450
+ private flags;
1383
1451
  /**
1384
- * error cache
1452
+ * id of the lowercase string + 1, by id. 0 when it is not computed (see {@link lower})
1385
1453
  */
1386
- errors: Map<number, ErrorDescription[]>;
1387
- constructor(size?: number);
1454
+ private lowers;
1388
1455
  /**
1389
- * Export the arena as a structured-cloneable object and the list of its column buffers, to send an arena
1390
- * to a worker (or back to the main thread) without copying the node data.
1391
- *
1392
- * The properties (strings, errors, ...) are cloned by `postMessage()`, the column buffers are moved when they are
1393
- * passed as the transfer list: the source arena must not be used afterwards (its columns are detached).
1394
- * The buffers are copied instead when the transfer list is omitted.
1395
- *
1396
- * ```ts
1397
- * // main thread
1398
- * const [properties, transferables] = AstArena.toTransferableArenaObject(result.arena);
1399
- *
1400
- * worker.postMessage({ ast: result.ast, properties, transferables }, transferables);
1401
- *
1402
- * // worker
1403
- * const { ast, properties, transferables } = event.data;
1404
- * const arena = AstArena.fromTransferableArenaObjects(properties, transferables);
1405
- * ```
1406
- *
1407
- * @param arena
1408
- * @returns the arena properties and the column buffers, see {@link ArenaProperties} and {@link ArenaTransferables}
1456
+ * builder of the lowercase strings
1409
1457
  */
1410
- static toTransferableArenaObject(arena: Arena): [ArenaProperties, ArenaTransferables];
1458
+ private readonly builder;
1411
1459
  /**
1412
- * Create an arena from the objects produced by {@link Arena.toTransferableArenaObject}. The column buffers are
1413
- * used as is (zero copy): the typed arrays are views on the given buffers.
1414
- *
1415
- * @param properties arena properties
1416
- * @param transferables column buffers
1417
- * @returns an `Arena` or an `AstArena` depending on the class the method is called on
1460
+ * code units of the strings that are not a range of a source
1418
1461
  */
1419
- static fromTransferableArenaObjects<T extends Arena>(this: new (size?: number) => T, properties: ArenaProperties, transferables: ArenaTransferables): T;
1462
+ private pool;
1420
1463
  /**
1421
- * true when the column buffers have been transferred to another thread: the arena can no longer be used
1464
+ * used length of the pool
1422
1465
  */
1423
- get transferred(): boolean;
1466
+ private poolLength;
1424
1467
  /**
1425
- * structured-cloneable properties of the arena
1468
+ * set the text of a source: the strings of the source are ranges of the text
1469
+ * @param source source index
1470
+ * @param text content of the source
1471
+ * @param codes code units of the text, while the source is tokenized: the ranges are compared with the code units
1472
+ * (faster than the text). see {@link releaseCodes}
1426
1473
  */
1427
- protected exportProperties(): ArenaProperties;
1474
+ setText(source: number, text: string, codes?: CodeUnits | null): void;
1428
1475
  /**
1429
- * column buffers, in the order of {@link arenaColumns}. the `spans` buffer is shared with the `spans32` view
1476
+ * drop the code units of a source: the source is no longer tokenized, see {@link setText}
1477
+ * @param source
1430
1478
  */
1431
- protected exportTransferables(): ArenaTransferables;
1479
+ releaseCodes(source: number): void;
1432
1480
  /**
1433
- * initialize the arena from exported properties and column buffers
1434
- * @param properties
1435
- * @param transferables
1481
+ * intern a string
1482
+ * @param str
1483
+ * @returns the string id
1436
1484
  */
1437
- protected importProperties(properties: ArenaProperties, transferables: ArenaTransferables): void;
1438
- allocate(): number;
1485
+ intern(str: string): number;
1439
1486
  /**
1440
- * recycle a detached leaf node (no parent, no children, no tokens) that is no longer referenced:
1441
- * its id is reused by the next allocation. the record is zeroed, so a stale reference reads an empty node
1442
- * @param id
1487
+ * intern a range of code units
1488
+ * @param codes code units
1489
+ * @param start
1490
+ * @param end
1491
+ * @param source where the range is stored when it is interned: the index of the source the code units are read
1492
+ * from (the range is kept), `StringSource.Canonical` (the code units are the canonical text) or `StringSource.Pool`
1493
+ * (the code units are copied)
1494
+ * @returns the string id
1443
1495
  */
1444
- recycle(id: number): void;
1496
+ internRange(codes: CodeUnits, start: number, end: number, source: number): number;
1445
1497
  /**
1446
- * Interns a string and returns its unique ID. If the string has already been interned, it returns the existing ID.
1498
+ * id of a string, -1 when the string is not interned
1447
1499
  * @param str
1448
- * @returns
1449
1500
  */
1450
- internString(str: string): number;
1501
+ lookup(str: string): number;
1451
1502
  /**
1452
- * set node data for a given id. The first argument is the id, the second is the type, the third is the string value, the fourth is the numeric value, and the fifth is the unit.
1503
+ * the string of an id. the string is created the first time it is read
1453
1504
  * @param id
1454
- * @param type
1455
- * @param stringValue
1456
1505
  */
1457
- set(id: number, type: EnumToken): void;
1506
+ get(id: number): string;
1458
1507
  /**
1459
- * set node data for a given id. The first argument is the id, the second is the type, the third is the string value, the fourth is the numeric value, and the fifth is the unit.
1508
+ * length of a string
1460
1509
  * @param id
1461
- * @param type
1462
- * @param stringValue
1463
1510
  */
1464
- set(id: number, type: EnumToken, stringValue: number): void;
1511
+ length(id: number): number;
1465
1512
  /**
1466
- * set node data for a given id. The first argument is the id, the second is the type, the third is the string value, and the fourth is the numeric value.
1513
+ * code unit of a string
1467
1514
  * @param id
1468
- * @param type
1469
- * @param stringValue
1470
- * @param numericValue
1515
+ * @param index
1471
1516
  */
1472
- set(id: number, type: EnumToken, stringValue: number, numericValue: number): void;
1517
+ codeAt(id: number, index: number): number;
1473
1518
  /**
1474
- * set node data for a given id. The first argument is the id, the second is the type, the third is the string value, the fourth is the numeric value, and the fifth is the unit.
1519
+ * copy the code units of a string to a buffer. the string is not created
1475
1520
  * @param id
1476
- * @param type
1477
- * @param stringValue
1478
- * @param numericValue
1479
- * @param unit
1521
+ * @param target
1522
+ * @param offset offset in the target
1523
+ * @returns the number of code units
1480
1524
  */
1481
- set(id: number, type: EnumToken, stringValue: number, numericValue: number, unit: number): void;
1482
- getType(id: number): EnumToken;
1525
+ copy(id: number, target: Uint16Array, offset: number): number;
1483
1526
  /**
1484
- * type of a node or a token. null when the id is null
1527
+ * a boolean property of a string, computed once per id: the string is read once (see {@link StringFlag})
1485
1528
  * @param id
1529
+ * @param flag
1530
+ * @param compute computes the property from the string
1531
+ */
1532
+ flag(id: number, flag: StringFlag, compute: (str: string) => boolean): boolean;
1533
+ /**
1534
+ * a boolean property of a string, computed once per id from the string id (the string is not necessarily read),
1535
+ * see {@link flag}
1536
+ * @param id
1537
+ * @param flag
1538
+ * @param compute computes the property from the string id
1539
+ */
1540
+ flagId(id: number, flag: StringFlag, compute: (id: number) => boolean): boolean;
1541
+ /**
1542
+ * a value derived from a string, computed once per id (see {@link StringDerived})
1543
+ * @param id
1544
+ * @param slot
1545
+ * @param compute computes the value from the string id
1546
+ */
1547
+ derived<T>(id: number, slot: StringDerived, compute: (id: number) => T): T;
1548
+ /**
1549
+ * copy the code units of a string to a byte buffer when they are all ascii (UTF-8 encoding). the string is not
1550
+ * created
1551
+ * @param id
1552
+ * @param target
1553
+ * @param offset offset in the target. the target has room for the string
1554
+ * @returns the number of bytes, -1 when the string is not ascii
1555
+ */
1556
+ copyAscii(id: number, target: Uint8Array, offset: number): number;
1557
+ /**
1558
+ * index of the first occurrence of a code unit in a string, -1 when it is not found. the string is not created
1559
+ * @param id
1560
+ * @param code
1561
+ */
1562
+ indexOfCode(id: number, code: number): number;
1563
+ /**
1564
+ * true if the string of an id equals a string. the string is not created
1565
+ * @param id
1566
+ * @param str
1567
+ */
1568
+ equals(id: number, str: string): boolean;
1569
+ /**
1570
+ * id of the lowercase string (like `toLowerCase()`): the id itself when the string has no uppercase letter. the
1571
+ * string is not created when it is ascii
1572
+ * @param id
1573
+ */
1574
+ lower(id: number): number;
1575
+ /**
1576
+ * true if the string of an id starts with a string. the string is not created
1577
+ * @param id
1578
+ * @param str
1579
+ */
1580
+ startsWith(id: number, str: string): boolean;
1581
+ /**
1582
+ * true if the string of an id equals a string, ignoring the case of the ascii letters. the string is not created
1583
+ * @param id
1584
+ * @param str
1585
+ */
1586
+ equalsIgnoreCase(id: number, str: string): boolean;
1587
+ /**
1588
+ * drop the strings that are not used and renumber the others
1589
+ * @param used used strings, by id
1590
+ * @returns the new id of each string
1591
+ */
1592
+ compact(used: Uint8Array): Uint32Array;
1593
+ /**
1594
+ * structured-cloneable copy of the table
1595
+ */
1596
+ export(): StringTableData;
1597
+ /**
1598
+ * initialize the table from an exported copy
1599
+ * @param data
1600
+ */
1601
+ import(data: StringTableData): void;
1602
+ /**
1603
+ * add a string
1604
+ * @param hash
1605
+ * @param slot empty slot of the hash table
1606
+ * @param source
1607
+ * @param start
1608
+ * @param end
1609
+ */
1610
+ private add;
1611
+ /**
1612
+ * true if a string has the code units of a range
1613
+ * @param id
1614
+ * @param codes
1615
+ * @param start
1616
+ * @param end
1617
+ */
1618
+ private equalsRange;
1619
+ /**
1620
+ * true if a string equals a string
1621
+ * @param id
1622
+ * @param str
1623
+ */
1624
+ private equalsString;
1625
+ /**
1626
+ * grow the columns of the strings
1627
+ * @param size
1628
+ */
1629
+ private grow;
1630
+ /**
1631
+ * drop the strings, allocate the columns for `count` strings. the ids change
1632
+ * @param count
1633
+ */
1634
+ private reset;
1635
+ /**
1636
+ * rebuild the hash table
1637
+ */
1638
+ private rehash;
1639
+ /**
1640
+ * shallow copy of the table
1641
+ */
1642
+ private clone;
1643
+ }
1644
+
1645
+ /**
1646
+ * Arena memory manager: ast nodes and value tokens are integer ids, their data is stored column-wise
1647
+ * in typed arrays (structure of arrays), lists are doubly linked lists stored in the `firstChild` /
1648
+ * `lastChild` / `firstToken` / `lastToken` / `nextSibling` / `previousSibling` columns and strings are interned.
1649
+ *
1650
+ * Every node owns two lists that share the sibling columns:
1651
+ *
1652
+ * - the children list (`firstChild` / `lastChild`): the child nodes of a stylesheet, a rule or an at-rule, or the
1653
+ * structured fields of a token (see {@link TokenField}),
1654
+ * - the token list (`firstToken` / `lastToken`): the value tokens of a declaration, the prelude tokens of a rule / at-rule
1655
+ * or the arguments of a function token (`chi`).
1656
+ *
1657
+ * Token columns:
1658
+ *
1659
+ * - `dataTypes`: token type ({@link EnumToken}),
1660
+ * - `stringValue`: interned string value (`val`) of identifiers, strings, literals, function names, colors, ...
1661
+ * - `numericValue`: numeric value (`val`) of numbers, dimensions and percentages. operator of binary expressions, sign of unary expressions,
1662
+ * - `unit`: interned unit of dimensions,
1663
+ * - `name`: interned name (`nam`) of at-rule / declaration tokens,
1664
+ * - `colorType`: color kind (`kin`) of color tokens,
1665
+ * - `spans`: packed source location.
1666
+ *
1667
+ * Structured tokens (binary expressions, media queries conditions, ...) store their fields (`l`, `r`, `op`, ...) as
1668
+ * {@link EnumToken.ListTokenType} children at fixed positions ({@link TokenField}). Fraction tokens store their
1669
+ * numerator and denominator as children, numeric tokens with a fraction value store the fraction token as their child.
1670
+ *
1671
+ * @module
1672
+ */
1673
+
1674
+ /**
1675
+ * position of the structured token fields in the children list
1676
+ */
1677
+ declare enum TokenField {
1678
+ /**
1679
+ * left hand side (`l`)
1680
+ */
1681
+ L = 0,
1682
+ /**
1683
+ * right hand side (`r`)
1684
+ */
1685
+ R = 1,
1686
+ /**
1687
+ * operator (`op`, `op1`)
1688
+ */
1689
+ Op = 2,
1690
+ /**
1691
+ * second operator (`op2`)
1692
+ */
1693
+ Op2 = 3,
1694
+ /**
1695
+ * value (`val`)
1696
+ */
1697
+ Val = 4
1698
+ }
1699
+ /**
1700
+ * Plain (structured-cloneable) properties of an arena. See {@link Arena.toTransferableArenaObject}
1701
+ */
1702
+ interface ArenaProperties {
1703
+ /**
1704
+ * arena class name: `Arena` or `AstArena`
1705
+ */
1706
+ kind: string;
1707
+ /**
1708
+ * last allocated id
1709
+ */
1710
+ current: number;
1711
+ /**
1712
+ * interned strings
1713
+ */
1714
+ strings: StringTableData;
1715
+ /**
1716
+ * validation errors by node id
1717
+ */
1718
+ errors: Array<[number, ErrorDescription[]]>;
1719
+ /**
1720
+ * source ids ({@link AstArena})
1721
+ */
1722
+ sources?: number[];
1723
+ /**
1724
+ * raw selectors cache ({@link AstArena})
1725
+ */
1726
+ raw?: Array<[number, RawSelectorTokens | null | undefined]>;
1727
+ /**
1728
+ * optimized selectors cache ({@link AstArena})
1729
+ */
1730
+ optimized?: Array<[number, OptimizedSelector | null | undefined]>;
1731
+ /**
1732
+ * input length of the parsed stylesheets ({@link AstArena})
1733
+ */
1734
+ inputLengths?: Array<number | undefined>;
1735
+ }
1736
+ /**
1737
+ * Column buffers of an arena, in the order of {@link arenaColumns}. See {@link Arena.toTransferableArenaObject}
1738
+ */
1739
+ type ArenaTransferables = ArrayBuffer[];
1740
+ /**
1741
+ * arena columns stored as typed arrays, in the order of the transferable buffers
1742
+ */
1743
+ declare const arenaColumns: readonly ["dataTypes", "parents", "nextSibling", "previousSibling", "firstToken", "lastToken", "firstChild", "lastChild", "name", "stringValue", "numericValue", "unit", "flags", "colorType", "spans"];
1744
+ /**
1745
+ * Arena memory manager.
1746
+ *
1747
+ * The node data is stored column-wise in typed arrays allocated for the capacity of the arena ({@link getCapacity},
1748
+ * 62 bytes per node). The arena grows by doubling its capacity and never frees memory by itself: detached nodes keep
1749
+ * their memory and their ids stay valid. {@link release}, {@link compact}, {@link trim} and {@link compactStrings}
1750
+ * reclaim the memory, `compact()` and `trim()` renumber the nodes. See the Arena Memory guide (files/arena.md).
1751
+ */
1752
+ declare class Arena {
1753
+ #private;
1754
+ /**
1755
+ * interned strings: ranges of the sources, of the canonical text, of the pool, or strings. see {@link StringTable}
1756
+ */
1757
+ protected stringTable: StringTable;
1758
+ /**
1759
+ * root node
1760
+ */
1761
+ readonly root: number;
1762
+ /**
1763
+ * last allocated node id. the next node is allocated with the id current + 1 (unless a recycled id is available).
1764
+ * 0 is never allocated: it means "no node"
1765
+ */
1766
+ current: number;
1767
+ /**
1768
+ * node EnumToken type array
1769
+ */
1770
+ dataTypes: Uint8Array;
1771
+ /**
1772
+ * parent node id array
1773
+ */
1774
+ parents: Uint32Array;
1775
+ /**
1776
+ * next sibling node id array
1777
+ */
1778
+ nextSibling: Uint32Array;
1779
+ /**
1780
+ * previous sibling node id array
1781
+ */
1782
+ previousSibling: Uint32Array;
1783
+ /**
1784
+ * first token node id array
1785
+ */
1786
+ firstToken: Uint32Array;
1787
+ /**
1788
+ * last token node id array
1789
+ */
1790
+ lastToken: Uint32Array;
1791
+ /**
1792
+ * first child node id array
1793
+ */
1794
+ firstChild: Uint32Array;
1795
+ /**
1796
+ * last child node id array
1797
+ */
1798
+ lastChild: Uint32Array;
1799
+ /**
1800
+ * node name string interner id array. used to store (node as AstRule | AstDeclaration | AstKeyframesAtRule).nam and (node as AstRule | AstKeyframesRule).sel
1801
+ */
1802
+ name: Uint32Array;
1803
+ /**
1804
+ * node string value index array.
1805
+ */
1806
+ stringValue: Uint32Array;
1807
+ /**
1808
+ * node numeric value array. previously used as (node as NumberToken | DimensionToken).val
1809
+ */
1810
+ numericValue: Float64Array;
1811
+ /**
1812
+ * node unit string interner id array. previously used as (node as DimensionToken).unit
1813
+ */
1814
+ unit: Uint32Array;
1815
+ /**
1816
+ * node flags
1817
+ */
1818
+ flags: Uint32Array;
1819
+ /**
1820
+ * color type. previously use as (node as ColorToken).kin
1821
+ */
1822
+ colorType: Uint8Array;
1823
+ /**
1824
+ * token spans. 8 bits for source type. 28 bits for start position, 28 bits for end position. This allows us to store the start and end positions of tokens in a single 64-bit integer, which is more efficient than storing them separately.
1825
+ */
1826
+ spans: BigUint64Array;
1827
+ /**
1828
+ * error cache
1829
+ */
1830
+ errors: Map<number, ErrorDescription[]>;
1831
+ /**
1832
+ * head of the list of recycled node ids. the list is linked through the `nextSibling` column, see {@link recycle}
1833
+ */
1834
+ protected freeList: number;
1835
+ /**
1836
+ * number of nodes the columns can hold: the length of the columns. the length of a typed array is a getter,
1837
+ * allocate() reads the capacity of the arena for each node
1838
+ */
1839
+ protected capacity: number;
1840
+ /**
1841
+ * 32 bits view of the spans: the low word holds the end position and the 4 low bits of the start position,
1842
+ * the high word holds the 24 high bits of the start position and the source
1843
+ */
1844
+ protected spans32: Uint32Array;
1845
+ constructor(size?: number);
1846
+ /**
1847
+ * true when the column buffers have been transferred to another thread: the arena can no longer be used
1848
+ */
1849
+ get transferred(): boolean;
1850
+ /**
1851
+ * Export the arena as a structured-cloneable object and the list of its column buffers, to send an arena
1852
+ * to a worker (or back to the main thread) without copying the node data.
1853
+ *
1854
+ * The properties (strings, errors, ...) are cloned by `postMessage()`, the column buffers are moved when they are
1855
+ * passed as the transfer list: the source arena must not be used afterwards (its columns are detached).
1856
+ * The buffers are copied instead when the transfer list is omitted.
1857
+ *
1858
+ * ```ts
1859
+ * // main thread
1860
+ * const [properties, transferables] = AstArena.toTransferableArenaObject(result.arena);
1861
+ *
1862
+ * worker.postMessage({ ast: result.ast, properties, transferables }, transferables);
1863
+ *
1864
+ * // worker
1865
+ * const { ast, properties, transferables } = event.data;
1866
+ * const arena = AstArena.fromTransferableArenaObjects(properties, transferables);
1867
+ * ```
1868
+ *
1869
+ * @param arena
1870
+ * @returns the arena properties and the column buffers, see {@link ArenaProperties} and {@link ArenaTransferables}
1871
+ */
1872
+ static toTransferableArenaObject(arena: Arena): [ArenaProperties, ArenaTransferables];
1873
+ /**
1874
+ * Create an arena from the objects produced by {@link Arena.toTransferableArenaObject}. The column buffers are
1875
+ * used as is (zero copy): the typed arrays are views on the given buffers.
1876
+ *
1877
+ * @param properties arena properties
1878
+ * @param transferables column buffers
1879
+ * @returns an `Arena` or an `AstArena` depending on the class the method is called on
1880
+ */
1881
+ static fromTransferableArenaObjects<T extends Arena>(this: new (size?: number) => T, properties: ArenaProperties, transferables: ArenaTransferables): T;
1882
+ allocate(): number;
1883
+ /**
1884
+ * recycle a detached leaf node (no parent, no children, no tokens) that is no longer referenced:
1885
+ * its id is reused by the next allocation. the record is zeroed, so a stale reference reads an empty node
1886
+ * @param id
1887
+ */
1888
+ recycle(id: number): void;
1889
+ /**
1890
+ * Interns a string and returns its unique ID. If the string has already been interned, it returns the existing ID.
1891
+ * The strings are looked up by the hash of their code units, see {@link internRange}
1892
+ * @param str
1893
+ * @returns
1894
+ */
1895
+ internString(str: string): number;
1896
+ /**
1897
+ * Interns the string made of a range of code units and returns its unique ID. Same ID as {@link internString} for
1898
+ * the same content. The range is looked up by its hash and compared with the code units of the interned strings:
1899
+ * no string is created.
1900
+ *
1901
+ * - a range of a source (the code units read by the tokenizer): the source index and the offsets are stored, the
1902
+ * text of the source is set with {@link setSourceText}
1903
+ * - `StringSource.Canonical`: a range of the canonical text (the spelling of the known units and function names)
1904
+ * - `StringSource.Pool`: the code units are copied (decoded escape sequences, ...)
1905
+ *
1906
+ * @param codes code units
1907
+ * @param start start offset of the range
1908
+ * @param end end offset of the range
1909
+ * @param source source index, `StringSource.Canonical` or `StringSource.Pool`
1910
+ */
1911
+ internRange(codes: CodeUnits, start: number, end: number, source: number): number;
1912
+ /**
1913
+ * set the text of a source: the strings interned from the source are ranges of the text, see {@link internRange}
1914
+ * @param source source index
1915
+ * @param text content of the source
1916
+ * @param codes code units of the text while the source is tokenized (faster comparisons)
1917
+ */
1918
+ setSourceText(source: number, text: string, codes?: CodeUnits | null): void;
1919
+ /**
1920
+ * drop the code units of a source set by {@link setSourceText}: the source is no longer tokenized
1921
+ * @param source source index
1922
+ */
1923
+ releaseSourceCodes(source: number): void;
1924
+ /**
1925
+ * id of an interned string, -1 when the string is not interned
1926
+ * @param str
1927
+ */
1928
+ stringId(str: string): number;
1929
+ /**
1930
+ * length of an interned string. the string is not created
1931
+ * @param id
1932
+ */
1933
+ stringLength(id: number): number;
1934
+ /**
1935
+ * code unit of an interned string. the string is not created
1936
+ * @param id
1937
+ * @param index
1938
+ */
1939
+ stringCodeAt(id: number, index: number): number;
1940
+ /**
1941
+ * index of the first occurrence of a code unit in an interned string, -1 when it is not found. the string is not
1942
+ * created
1943
+ * @param id
1944
+ * @param code
1945
+ */
1946
+ stringIndexOf(id: number, code: number): number;
1947
+ /**
1948
+ * true if an interned string equals a string. the interned string is not created
1949
+ * @param id
1950
+ * @param str
1951
+ */
1952
+ stringEquals(id: number, str: string): boolean;
1953
+ /**
1954
+ * true if an interned string equals a string, ignoring the case of the ascii letters. the interned string is not
1955
+ * created
1956
+ * @param id
1957
+ * @param str
1958
+ */
1959
+ stringEqualsIgnoreCase(id: number, str: string): boolean;
1960
+ /**
1961
+ * true if an interned string starts with a string. the interned string is not created
1962
+ * @param id
1963
+ * @param str
1964
+ */
1965
+ stringStartsWith(id: number, str: string): boolean;
1966
+ /**
1967
+ * id of the lowercase version of an interned string (like `toLowerCase()`). no string is created when the string
1968
+ * is ascii. the result is cached
1969
+ * @param id
1970
+ */
1971
+ lowerStringId(id: number): number;
1972
+ /**
1973
+ * copy an interned string to a byte buffer when it is ascii (UTF-8 encoding). the string is not created
1974
+ * @param id
1975
+ * @param target
1976
+ * @param offset offset in the target. the target has room for the string ({@link stringLength})
1977
+ * @returns the number of bytes, -1 when the string is not ascii
1978
+ */
1979
+ copyStringAscii(id: number, target: Uint8Array, offset: number): number;
1980
+ /**
1981
+ * a boolean property of an interned string, computed once per string id: the string is read once
1982
+ * @param id
1983
+ * @param flag
1984
+ * @param compute computes the property from the string
1985
+ */
1986
+ stringFlag(id: number, flag: StringFlag, compute: (str: string) => boolean): boolean;
1987
+ /**
1988
+ * a boolean property of an interned string, computed once per string id from the id (see {@link stringCodeAt})
1989
+ * @param id
1990
+ * @param flag
1991
+ * @param compute computes the property from the string id
1992
+ */
1993
+ stringFlagId(id: number, flag: StringFlag, compute: (id: number) => boolean): boolean;
1994
+ /**
1995
+ * a value derived from an interned string, computed once per string id
1996
+ * @param id
1997
+ * @param slot
1998
+ * @param compute computes the value from the string id
1999
+ */
2000
+ stringDerived<T>(id: number, slot: StringDerived, compute: (id: number) => T): T;
2001
+ /**
2002
+ * copy the code units of an interned string to a buffer. the string is not created
2003
+ * @param id
2004
+ * @param target the target has room for the string ({@link stringLength})
2005
+ * @param offset
2006
+ * @returns the number of code units
2007
+ */
2008
+ copyString(id: number, target: Uint16Array, offset: number): number;
2009
+ /**
2010
+ * append an interned string to a builder. the string is not created
2011
+ * @param builder
2012
+ * @param id
2013
+ */
2014
+ appendString(builder: StringBuilder, id: number): StringBuilder;
2015
+ /**
2016
+ * intern the string built by a builder: no string is created
2017
+ * @param builder
2018
+ */
2019
+ internBuilder(builder: StringBuilder): number;
2020
+ /**
2021
+ * identity of the string ids: a new object when the strings are renumbered ({@link compact},
2022
+ * {@link compactStrings}). the caches keyed by string ids use it as a key
2023
+ */
2024
+ get stringEpoch(): object;
2025
+ /**
2026
+ *
2027
+ * @param id
2028
+ */
2029
+ getType(id: number): EnumToken;
2030
+ /**
2031
+ * type of node or a token. null when the id is null
2032
+ * @param id
2033
+ */
2034
+ typeOf(id: number | null | undefined): EnumToken | null;
2035
+ /**
2036
+ *
2037
+ * @param id
2038
+ * @param type
2039
+ */
2040
+ setType(id: number, type: EnumToken): void;
2041
+ /**
2042
+ *
2043
+ * @param id
2044
+ * @param nameId
2045
+ */
2046
+ setName(id: number, nameId: number): void;
2047
+ /**
2048
+ *
2049
+ * @param id
2050
+ */
2051
+ getName(id: number): string;
2052
+ /**
2053
+ *
2054
+ * @param id
2055
+ * @param valueId
2056
+ */
2057
+ setValue(id: number, valueId: number): void;
2058
+ /**
2059
+ *
2060
+ * @param id
2061
+ */
2062
+ getValue(id: number): string;
2063
+ /**
2064
+ *
2065
+ * @param id
2066
+ * @param numericValue
2067
+ */
2068
+ setNumericValue(id: number, numericValue: number): void;
2069
+ /**
2070
+ *
2071
+ * @param id
2072
+ * @param unit
1486
2073
  */
1487
- typeOf(id: number | null | undefined): EnumToken | null;
1488
- setType(id: number, type: EnumToken): void;
1489
- setName(id: number, nameId: number): void;
1490
- getName(id: number): string;
1491
- setValue(id: number, valueId: number): void;
1492
- getValue(id: number): string;
1493
- setNumericValue(id: number, numericValue: number): void;
1494
2074
  setUnit(id: number, unit: number): void;
2075
+ /**
2076
+ *
2077
+ * @param id
2078
+ */
1495
2079
  getUnit(id: number): string;
2080
+ /**
2081
+ *
2082
+ * @param id
2083
+ */
1496
2084
  getNumericValue(id: number): number;
2085
+ /**
2086
+ *
2087
+ * @param id
2088
+ * @param parentId
2089
+ */
1497
2090
  setParent(id: number, parentId: number): void;
1498
2091
  /**
1499
2092
  * first child of a node. 0 when the node has no children
@@ -1539,6 +2132,10 @@ declare class Arena {
1539
2132
  * @param firstChildId
1540
2133
  */
1541
2134
  setFirstChild(id: number, firstChildId: number): void;
2135
+ /**
2136
+ *
2137
+ * @param id
2138
+ */
1542
2139
  getLastChild(id: number): number;
1543
2140
  /**
1544
2141
  * replace the last child
@@ -1564,11 +2161,39 @@ declare class Arena {
1564
2161
  * @param firstTokenId
1565
2162
  */
1566
2163
  setFirstToken(id: number, firstTokenId: number): void;
2164
+ /**
2165
+ *
2166
+ * @param id
2167
+ * @param colorType
2168
+ */
1567
2169
  setColorType(id: number, colorType: number): void;
2170
+ /**
2171
+ *
2172
+ * @param id
2173
+ */
1568
2174
  getColorType(id: number): number;
2175
+ /**
2176
+ *
2177
+ * @param id
2178
+ * @param flags
2179
+ */
1569
2180
  setFlags(id: number, flags: number): void;
2181
+ /**
2182
+ *
2183
+ * @param id
2184
+ */
1570
2185
  getFlags(id: number): number;
2186
+ /**
2187
+ *
2188
+ * @param id
2189
+ * @param flag
2190
+ */
1571
2191
  hasFlags(id: number, flag: number): boolean;
2192
+ /**
2193
+ *
2194
+ * @param id
2195
+ * @param index
2196
+ */
1572
2197
  getChildAt(id: number, index: number): number | null;
1573
2198
  /**
1574
2199
  * token at the given position of the token list
@@ -1621,15 +2246,63 @@ declare class Arena {
1621
2246
  * @param tokens
1622
2247
  */
1623
2248
  appendField(id: number, field: TokenField, ...tokens: number[]): void;
2249
+ /**
2250
+ *
2251
+ * @param id
2252
+ * @param children
2253
+ */
1624
2254
  setLeft(id: number, ...children: number[]): void;
2255
+ /**
2256
+ *
2257
+ * @param id
2258
+ */
1625
2259
  getLeft(id: number): number[] | null;
2260
+ /**
2261
+ *
2262
+ * @param id
2263
+ * @param rightId
2264
+ */
1626
2265
  setRight(id: number, rightId: null): void;
2266
+ /**
2267
+ *
2268
+ * @param id
2269
+ * @param rightId
2270
+ */
1627
2271
  setRight(id: number, ...rightId: number[]): void;
2272
+ /**
2273
+ *
2274
+ * @param id
2275
+ */
1628
2276
  getRight(id: number): number[] | null;
2277
+ /**
2278
+ *
2279
+ * @param id
2280
+ * @param opId
2281
+ */
1629
2282
  setOp(id: number, opId: number): void;
2283
+ /**
2284
+ *
2285
+ * @param id
2286
+ */
1630
2287
  getOp(id: number): number;
2288
+ /**
2289
+ *
2290
+ * @param id
2291
+ * @param op2Id
2292
+ */
1631
2293
  setOp2(id: number, op2Id: number): void;
2294
+ /**
2295
+ *
2296
+ * @param id
2297
+ */
1632
2298
  getOp2(id: number): number;
2299
+ /**
2300
+ *
2301
+ * @param id
2302
+ * @param sourceId
2303
+ * @param start
2304
+ * @param end
2305
+ */
1633
2306
  setSpan(id: number, sourceId: number, start: number, end: number): void;
1634
2307
  /**
1635
2308
  * copy the packed location of a node
@@ -1637,12 +2310,42 @@ declare class Arena {
1637
2310
  * @param source
1638
2311
  */
1639
2312
  copySpan(target: number, source: number): void;
2313
+ /**
2314
+ *
2315
+ * @param id
2316
+ */
1640
2317
  getSourceId(id: number): number;
2318
+ /**
2319
+ *
2320
+ * @param id
2321
+ */
1641
2322
  getSpanStart(id: number): number;
2323
+ /**
2324
+ *
2325
+ * @param id
2326
+ * @param start
2327
+ */
1642
2328
  setSpandStart(id: number, start: number): void;
2329
+ /**
2330
+ *
2331
+ * @param id
2332
+ */
1643
2333
  getSpanEnd(id: number): number;
2334
+ /**
2335
+ *
2336
+ * @param id
2337
+ * @param end
2338
+ */
1644
2339
  setSpanEnd(id: number, end: number): void;
2340
+ /**
2341
+ *
2342
+ * @param id
2343
+ */
1645
2344
  getParent(id: number): number;
2345
+ /**
2346
+ *
2347
+ * @param id
2348
+ */
1646
2349
  resolveString(id: number): string;
1647
2350
  /**
1648
2351
  * detach a node from its parent
@@ -1804,6 +2507,11 @@ declare class Arena {
1804
2507
  * @param id
1805
2508
  */
1806
2509
  subTokens(id: number): number[];
2510
+ /**
2511
+ *
2512
+ * @param id
2513
+ * @param predicate
2514
+ */
1807
2515
  findChild(id: number, predicate: (id: number) => boolean): number | null;
1808
2516
  /**
1809
2517
  * find a token in the token list
@@ -1834,6 +2542,11 @@ declare class Arena {
1834
2542
  * @param id
1835
2543
  */
1836
2544
  tokenCount(id: number): number;
2545
+ /**
2546
+ *
2547
+ * @param id
2548
+ * @param children
2549
+ */
1837
2550
  setChildren(id: number, ...children: number[]): void;
1838
2551
  /**
1839
2552
  * replace the children. same as {@link setChildren} with an array
@@ -1841,6 +2554,11 @@ declare class Arena {
1841
2554
  * @param children
1842
2555
  */
1843
2556
  setChildList(id: number, children: number[]): void;
2557
+ /**
2558
+ *
2559
+ * @param id
2560
+ * @param children
2561
+ */
1844
2562
  setTokens(id: number, ...children: number[]): void;
1845
2563
  /**
1846
2564
  * replace the token list. same as {@link setTokens} with an array
@@ -1855,6 +2573,11 @@ declare class Arena {
1855
2573
  * @param before the children are inserted before this child of `to`. they are appended when 0
1856
2574
  */
1857
2575
  moveChildren(from: number, to: number, before?: number): void;
2576
+ /**
2577
+ *
2578
+ * @param id
2579
+ * @param children
2580
+ */
1858
2581
  appendChildren(id: number, ...children: number[]): void;
1859
2582
  /**
1860
2583
  * append children. same as {@link appendChildren} with an array
@@ -1862,6 +2585,11 @@ declare class Arena {
1862
2585
  * @param children
1863
2586
  */
1864
2587
  appendChildList(id: number, children: number[]): void;
2588
+ /**
2589
+ *
2590
+ * @param id
2591
+ * @param children
2592
+ */
1865
2593
  appendTokens(id: number, ...children: number[]): void;
1866
2594
  /**
1867
2595
  * append tokens. same as {@link appendTokens} with an array
@@ -1887,8 +2615,24 @@ declare class Arena {
1887
2615
  * @param tokens
1888
2616
  */
1889
2617
  prependTokens(id: number, ...tokens: number[]): void;
2618
+ /**
2619
+ *
2620
+ * @param node
2621
+ * @param key
2622
+ * @param string
2623
+ */
1890
2624
  equalsIgnoreCase(node: number, key: "nam" | "val", string: string): boolean;
2625
+ /**
2626
+ *
2627
+ * @param node
2628
+ * @param key
2629
+ * @param string
2630
+ */
1891
2631
  startsWith(node: number, key: "nam" | "val", string: string): boolean;
2632
+ /**
2633
+ *
2634
+ * @param newSize
2635
+ */
1892
2636
  resize(newSize: number): void;
1893
2637
  /**
1894
2638
  * drop the interned strings that are no longer referenced by any node
@@ -1926,14 +2670,37 @@ declare class Arena {
1926
2670
  * @param errors error descriptions whose `node` is remapped
1927
2671
  * @returns mapping of the old ids to the new ids (0 when the node was dropped)
1928
2672
  */
1929
- trim(errors?: ErrorDescription[] | null): Uint32Array;
1930
- setErrors(id: number, errors: ErrorDescription[] | null): void;
1931
- getErrors(id: number): ErrorDescription[] | null;
2673
+ trim(errors?: ErrorDescription[] | null): Uint32Array;
2674
+ /**
2675
+ *
2676
+ * @param id
2677
+ * @param errors
2678
+ */
2679
+ setErrors(id: number, errors: ErrorDescription[] | null): void;
2680
+ /**
2681
+ *
2682
+ * @param id
2683
+ */
2684
+ getErrors(id: number): ErrorDescription[] | null;
2685
+ /**
2686
+ * number of children
2687
+ * @param id
2688
+ */
2689
+ childCount(id: number): number;
2690
+ /**
2691
+ * structured-cloneable properties of the arena
2692
+ */
2693
+ protected exportProperties(): ArenaProperties;
2694
+ /**
2695
+ * column buffers, in the order of {@link arenaColumns}. the `spans` buffer is shared with the `spans32` view
2696
+ */
2697
+ protected exportTransferables(): ArenaTransferables;
1932
2698
  /**
1933
- * number of children
1934
- * @param id
2699
+ * initialize the arena from exported properties and column buffers
2700
+ * @param properties
2701
+ * @param transferables
1935
2702
  */
1936
- childCount(id: number): number;
2703
+ protected importProperties(properties: ArenaProperties, transferables: ArenaTransferables): void;
1937
2704
  }
1938
2705
  /**
1939
2706
  * Css ast arena: ast nodes and value tokens.
@@ -1943,26 +2710,27 @@ declare class Arena {
1943
2710
  */
1944
2711
  declare class AstArena extends Arena {
1945
2712
  /**
1946
- * raw selector (minification cache). sparse: only rules have an entry
2713
+ * raw selector (minification cache), by rule id
1947
2714
  */
1948
- raw: Array<RawSelectorTokens | null | undefined>;
2715
+ raw: Map<number, RawSelectorTokens | null | undefined>;
1949
2716
  /**
1950
- * optimized selector (minification cache). sparse: only rules have an entry
2717
+ * optimized selector (minification cache), by rule id
1951
2718
  */
1952
- optimized: Array<OptimizedSelector | null | undefined>;
2719
+ optimized: Map<number, OptimizedSelector | null | undefined>;
1953
2720
  /**
1954
2721
  * source ids. `spans` store the index in this table (8 bits)
1955
2722
  */
1956
2723
  sources: number[];
1957
- constructor(size?: number);
1958
2724
  /**
1959
- * @inheritDoc
2725
+ * length of the css parsed into a stylesheet, imported files included. sparse: only the stylesheets created by
2726
+ * the parser have an entry. the render buffer is allocated from this length
1960
2727
  */
1961
- protected exportProperties(): ArenaProperties;
2728
+ inputLengths: Array<number | undefined>;
1962
2729
  /**
1963
- * @inheritDoc
2730
+ *
2731
+ * @param size
1964
2732
  */
1965
- protected importProperties(properties: ArenaProperties, transferables: ArenaTransferables): void;
2733
+ constructor(size?: number);
1966
2734
  /**
1967
2735
  * @inheritDoc
1968
2736
  */
@@ -2048,7 +2816,7 @@ declare class AstArena extends Arena {
2048
2816
  * @param state
2049
2817
  * @param errors
2050
2818
  */
2051
- createRule(typ: EnumToken, sel: string, tokens: number[] | null | undefined, state: EnumAstNodeStatus | null | undefined, errors: ErrorDescription[] | null | undefined): number;
2819
+ createRule(typ: EnumToken, sel: string | number, tokens: number[] | null | undefined, state: EnumAstNodeStatus | null | undefined, errors: ErrorDescription[] | null | undefined): number;
2052
2820
  /**
2053
2821
  * allocate an at-rule node
2054
2822
  * @param typ
@@ -2059,7 +2827,7 @@ declare class AstArena extends Arena {
2059
2827
  * @param state
2060
2828
  * @param errors
2061
2829
  */
2062
- createAtRule(typ: EnumToken, nam: string, val: string, block: boolean, tokens: number[] | null | undefined, state: EnumAstNodeStatus | null | undefined, errors: ErrorDescription[] | null | undefined): number;
2830
+ createAtRule(typ: EnumToken, nam: string | number, val: string | number, block: boolean, tokens: number[] | null | undefined, state: EnumAstNodeStatus | null | undefined, errors: ErrorDescription[] | null | undefined): number;
2063
2831
  /**
2064
2832
  * allocate a declaration node
2065
2833
  * @param typ
@@ -2068,13 +2836,13 @@ declare class AstArena extends Arena {
2068
2836
  * @param state
2069
2837
  * @param errors
2070
2838
  */
2071
- createDeclaration(typ: EnumToken, nam: string, val: number[] | null | undefined, state: EnumAstNodeStatus | null | undefined, errors: ErrorDescription[] | null | undefined): number;
2839
+ createDeclaration(typ: EnumToken, nam: string | number, val: number[] | null | undefined, state: EnumAstNodeStatus | null | undefined, errors: ErrorDescription[] | null | undefined): number;
2072
2840
  /**
2073
2841
  * allocate a comment node
2074
2842
  * @param typ
2075
2843
  * @param val
2076
2844
  */
2077
- createComment(typ: EnumToken, val: string): number;
2845
+ createComment(typ: EnumToken, val: string | number): number;
2078
2846
  /**
2079
2847
  * allocate a token. string values are interned, numeric values are stored in the `numericValue` column
2080
2848
  * @param typ
@@ -2201,16 +2969,6 @@ declare class AstArena extends Arena {
2201
2969
  * @returns the node id
2202
2970
  */
2203
2971
  fromObject(node: AstArenaNode | PlainAstNode | PlainToken): number;
2204
- /**
2205
- * create an ast node from a plain object
2206
- * @param node
2207
- */
2208
- protected nodeFromObject(node: PlainAstNode): number;
2209
- /**
2210
- * create a token from a plain object
2211
- * @param token
2212
- */
2213
- protected tokenFromObject(token: PlainToken): number;
2214
2972
  /**
2215
2973
  * Object view of a node or a token: an {@link AstArenaNode}. The view does not copy the node: its properties read
2216
2974
  * and write the arena. Importing the view in this arena ({@link fromObject}, visitor results, setters of the
@@ -2240,10 +2998,17 @@ declare class AstArena extends Arena {
2240
2998
  */
2241
2999
  tokenToObject(id: number): PlainToken;
2242
3000
  /**
2243
- * clone a node or a token. tokens are always cloned deeply
3001
+ * copy the data of a node (type, strings, values, flags, location, errors): its tokens, its children and the
3002
+ * minifier caches (`raw`, `optimized`) are not copied
2244
3003
  * @param id
2245
- * @param deep also clone the children (rules) or the value tokens (declarations)
2246
- * @param cloneMap map of the source ids to their clones
3004
+ */
3005
+ cloneNode(id: number): number;
3006
+ /**
3007
+ * copy a node or a token. the tokens of a node are copied, its children are copied with `deep`. the values of a
3008
+ * declaration are copied with `deep`
3009
+ * @param id
3010
+ * @param deep copy the children and the values of the declarations
3011
+ * @param cloneMap records the copies: id of the copy by original id
2247
3012
  */
2248
3013
  clone(id: number, deep?: boolean, cloneMap?: Map<number, number> | null): number;
2249
3014
  /**
@@ -2325,6 +3090,31 @@ declare class AstArena extends Arena {
2325
3090
  * @returns the node id
2326
3091
  */
2327
3092
  expand(ast: AstStyleSheet | AstAtRule | AstRule): AstNode;
3093
+ /**
3094
+ * replace the nesting selector '&' of a selector
3095
+ * @internal
3096
+ * @param input
3097
+ * @param replace
3098
+ */
3099
+ replaceCompound(input: string, replace: string): string;
3100
+ /**
3101
+ * @inheritDoc
3102
+ */
3103
+ protected exportProperties(): ArenaProperties;
3104
+ /**
3105
+ * @inheritDoc
3106
+ */
3107
+ protected importProperties(properties: ArenaProperties, transferables: ArenaTransferables): void;
3108
+ /**
3109
+ * create an ast node from a plain object
3110
+ * @param node
3111
+ */
3112
+ protected nodeFromObject(node: PlainAstNode): number;
3113
+ /**
3114
+ * create a token from a plain object
3115
+ * @param token
3116
+ */
3117
+ protected tokenFromObject(token: PlainToken): number;
2328
3118
  /**
2329
3119
  * expand a rule: the nested rules and at-rules are moved out of the rule, into `parent` before `before`.
2330
3120
  * the rule is detached when it has no children left
@@ -2334,12 +3124,11 @@ declare class AstArena extends Arena {
2334
3124
  */
2335
3125
  protected expandRule(node: AstRule, parent: AstNode, before: AstNode): void;
2336
3126
  /**
2337
- * replace the nesting selector '&' of a selector
2338
- * @internal
2339
- * @param input
3127
+ *
3128
+ * @param selector
2340
3129
  * @param replace
3130
+ * @protected
2341
3131
  */
2342
- replaceCompound(input: string, replace: string): string;
2343
3132
  protected replaceCompoundLiteral(selector: string, replace: string): string;
2344
3133
  }
2345
3134
 
@@ -2539,6 +3328,14 @@ type AstValueMatcher = (arena: AstArena, token: Token) => boolean;
2539
3328
  */
2540
3329
  type AstNodeMatcher = (arena: AstArena, node: AstNode) => boolean;
2541
3330
 
3331
+ /**
3332
+ * Unicode range token: `U+0025-00FF`, `U+4??`
3333
+ */
3334
+ export declare interface UniCodeRangeToken extends BaseToken {
3335
+ typ: EnumToken.UniCodeRange;
3336
+ val: string;
3337
+ }
3338
+
2542
3339
  /**
2543
3340
  * Literal token
2544
3341
  */
@@ -4128,6 +4925,7 @@ export declare type Token = number;
4128
4925
  */
4129
4926
  export declare type PlainToken =
4130
4927
  | LiteralToken
4928
+ | UniCodeRangeToken
4131
4929
  | IdentToken
4132
4930
  | IdentListToken
4133
4931
  | DashedIdentToken
@@ -5017,15 +5815,6 @@ declare class LineMap {
5017
5815
  * @returns
5018
5816
  */
5019
5817
  search(offset: number): number;
5020
- /**
5021
- * get line starts
5022
- * @returns
5023
- */
5024
- getLineStarts(): number[];
5025
- /**
5026
- * add line start
5027
- */
5028
- addLineStart(lineStart: number): void;
5029
5818
  }
5030
5819
 
5031
5820
  /**
@@ -5061,45 +5850,6 @@ declare class SourceFile {
5061
5850
  * @param content
5062
5851
  */
5063
5852
  append(content: string): void;
5064
- /**
5065
- * get file name
5066
- * @returns
5067
- */
5068
- getFileName(): string | null;
5069
- /**
5070
- * get content
5071
- * @returns
5072
- */
5073
- getContent(): string;
5074
- /**
5075
- * get text
5076
- * @param start
5077
- * @param length
5078
- * @returns
5079
- */
5080
- getText(start: number, length: number): string;
5081
- /**
5082
- * Compute line and column of the offset
5083
- * @param offset
5084
- * @returns
5085
- */
5086
- getOffsets(offset: number): [number, number];
5087
- /**
5088
- * get source location
5089
- * @param offset
5090
- * @returns
5091
- */
5092
- getSourceLocation(offset: number): [string | null, number, number];
5093
- /**
5094
- * get line starts
5095
- * @returns
5096
- */
5097
- getLineStarts(): number[];
5098
- /**
5099
- * add line start
5100
- * @param lineStart
5101
- */
5102
- addLineStart(lineStart: number): void;
5103
5853
  /**
5104
5854
  * set input source map
5105
5855
  * @param inputSourceMap
@@ -5131,9 +5881,14 @@ export declare interface PropertyListOptions {
5131
5881
  */
5132
5882
  export declare interface ParseInfo$1 {
5133
5883
  /**
5134
- * stream
5884
+ * the utf-16 code units of the css, read by the tokenizer. the code units of an ascii ArrayBuffer are its bytes
5135
5885
  */
5136
- stream: string;
5886
+ codes: Uint8Array | Uint16Array;
5887
+
5888
+ /**
5889
+ * the number of code units: the length of a typed array is a getter
5890
+ */
5891
+ length: number;
5137
5892
 
5138
5893
  /**
5139
5894
  * Source file
@@ -5264,6 +6019,10 @@ declare enum ValidationSyntaxGroupEnum {
5264
6019
  Declarations = "declarations",
5265
6020
  Functions = "functions",
5266
6021
  Syntaxes = "syntaxes",
6022
+ /**
6023
+ * value types, keyed by their name without the angle brackets (`color` for `<color>`). referenced as {@link Syntaxes}
6024
+ */
6025
+ Types = "types",
5267
6026
  Selectors = "selectors",
5268
6027
  AtRules = "atRules",
5269
6028
  Units = "units",
@@ -5291,12 +6050,18 @@ interface Position {
5291
6050
  }
5292
6051
 
5293
6052
  interface ValidationValueRangeMatch {
5294
- min: ValidationNumberToken;
6053
+ /**
6054
+ * lower bound. null: -∞
6055
+ */
6056
+ min: ValidationNumberToken | null;
5295
6057
  max: ValidationNumberToken | null;
5296
6058
  }
5297
6059
 
5298
6060
  interface ValidationDimensionRangeMatch {
5299
- min: ValidationDimensionToken;
6061
+ /**
6062
+ * lower bound. null: -∞
6063
+ */
6064
+ min: ValidationDimensionToken | null;
5300
6065
  max: ValidationDimensionToken | null;
5301
6066
  }
5302
6067
 
@@ -5382,6 +6147,12 @@ interface ValidationDimensionToken extends ValidationToken$1 {
5382
6147
  unit: keyof EnumToken;
5383
6148
  }
5384
6149
 
6150
+ /**
6151
+ * css input: the utf-8 encoded css in an ArrayBuffer or in a view of an ArrayBuffer (Uint8Array, Buffer), the preferred
6152
+ * input, or a string
6153
+ */
6154
+ type CssInput = string | ArrayBuffer | ArrayBufferView;
6155
+
5385
6156
  /**
5386
6157
  * response type
5387
6158
  */
@@ -6214,6 +6985,124 @@ export declare interface WalkerValueOptions {
6214
6985
  type?: EnumToken | EnumToken[] | ((arena: AstArena, token: Token) => boolean) | null;
6215
6986
  }
6216
6987
 
6988
+ /**
6989
+ * Render result.
6990
+ *
6991
+ * The generated css is stored as UTF-8 bytes in {@link RenderResult.write}: it can be written to a file or sent over
6992
+ * the network as is. {@link RenderResult.code} decodes the bytes the first time it is read, the string is kept.
6993
+ *
6994
+ * ```ts
6995
+ * import {render} from '@tbela99/css-parser';
6996
+ * import {writeFile} from 'node:fs/promises';
6997
+ *
6998
+ * const result = render(parseResult.arena, parseResult.ast);
6999
+ *
7000
+ * // bytes, no string conversion
7001
+ * await writeFile('out.css', result.write);
7002
+ *
7003
+ * // string, decoded once
7004
+ * console.log(result.code);
7005
+ * ```
7006
+ */
7007
+ declare class RenderResult {
7008
+ #private;
7009
+ /**
7010
+ * An instance is kept alive: the hidden class of the instances would otherwise be collected by a full garbage
7011
+ * collection when no instance is alive, and the optimized code that depends on it discarded (deoptimized)
7012
+ *
7013
+ * @internal
7014
+ */
7015
+ static readonly shape: RenderResult;
7016
+ /**
7017
+ * Rendered CSS, encoded as UTF-8
7018
+ */
7019
+ write: Uint8Array;
7020
+ /**
7021
+ * Render errors
7022
+ */
7023
+ errors: ErrorDescription[];
7024
+ /**
7025
+ * Render stats
7026
+ */
7027
+ stats: RenderResultStats;
7028
+ /**
7029
+ * Source map
7030
+ */
7031
+ map?: SourceMap;
7032
+ /**
7033
+ * @param write rendered css, encoded as UTF-8
7034
+ * @param errors
7035
+ * @param stats
7036
+ * @param map
7037
+ * @param codeLength length of the decoded css (`code.length`), computed when it is not provided
7038
+ */
7039
+ constructor(write: Uint8Array, errors: ErrorDescription[], stats: RenderResultStats, map?: SourceMap, codeLength?: number);
7040
+ /**
7041
+ * length of the rendered css once decoded (`result.code.length`), without decoding it
7042
+ * @param result
7043
+ *
7044
+ * @internal
7045
+ */
7046
+ static codeLength(result: RenderResult): number;
7047
+ /**
7048
+ * Rendered CSS. The bytes of {@link RenderResult.write} are decoded the first time the property is read
7049
+ */
7050
+ get code(): string;
7051
+ /**
7052
+ * JSON representation: the css is serialized as a string, the bytes are not serialized
7053
+ */
7054
+ toJSON(): Record<string, any>;
7055
+ }
7056
+ /**
7057
+ * Transform result: the parse result and the render result
7058
+ */
7059
+ declare class TransformResult extends RenderResult {
7060
+ /**
7061
+ * An instance is kept alive: the hidden class of the instances would otherwise be collected by a full garbage
7062
+ * collection when no instance is alive, and the optimized code that depends on it discarded (deoptimized)
7063
+ *
7064
+ * @internal
7065
+ */
7066
+ static readonly shape: TransformResult;
7067
+ /**
7068
+ * Parsed ast tree: the id of the stylesheet node in {@link TransformResult.arena}
7069
+ */
7070
+ ast: AstStyleSheet;
7071
+ /**
7072
+ * arena the ast nodes are stored in
7073
+ */
7074
+ arena: AstArena;
7075
+ /**
7076
+ * Transform stats
7077
+ */
7078
+ stats: TransformResultStats;
7079
+ /**
7080
+ * CSS module mapping
7081
+ */
7082
+ mapping?: Record<string, string>;
7083
+ /**
7084
+ * CSS module variables
7085
+ * @private
7086
+ */
7087
+ cssModuleVariables?: Record<string, AstArenaNode>;
7088
+ /**
7089
+ * css module import mapping
7090
+ * @private
7091
+ */
7092
+ importMapping?: Record<string, Record<string, string>>;
7093
+ /**
7094
+ * CSS module reverse mapping
7095
+ * @private
7096
+ */
7097
+ revMapping?: Record<string, string>;
7098
+ /**
7099
+ * @param parseResult
7100
+ * @param renderResult
7101
+ * @param stats
7102
+ */
7103
+ constructor(parseResult: ParseResult, renderResult: RenderResult, stats: TransformResultStats);
7104
+ }
7105
+
6217
7106
  /**
6218
7107
  * Error description
6219
7108
  */
@@ -6269,13 +7158,6 @@ interface ValidationOptions {
6269
7158
  */
6270
7159
  lenient?: boolean;
6271
7160
 
6272
- /**
6273
- * Visited tokens
6274
- *
6275
- * @private
6276
- */
6277
- visited?: Map<Token, Set<ValidationToken$1>>;
6278
-
6279
7161
  /**
6280
7162
  * Is optional
6281
7163
  *
@@ -6382,6 +7264,39 @@ interface MinifyOptions {
6382
7264
  * Inline css variables
6383
7265
  */
6384
7266
  inlineCssVariables?: boolean;
7267
+ /**
7268
+ * Evaluate css mixins and custom functions: the `@apply` rules are replaced by the body of the mixin they reference,
7269
+ * the private variables (`@private`, mixin arguments and the custom properties of the rule) are substituted.
7270
+ * the custom function calls (`--fn(1px)`) are replaced by the result of the function.
7271
+ * see https://drafts.csswg.org/css-mixins-1/
7272
+ *
7273
+ * ```ts
7274
+ *
7275
+ * import {transform} from '@tbela99/css-parser';
7276
+ *
7277
+ * const css = `
7278
+ * @mixin --only-descs(--arg) {
7279
+ * color: var(--arg);
7280
+ * & * { color: var(--arg, red); }
7281
+ * }
7282
+ * .foo {
7283
+ * @apply --only-descs(green);
7284
+ * }
7285
+ * `;
7286
+ *
7287
+ * const result = await transform(css, {evaluateMixins: true, expandNestingRules: true});
7288
+ *
7289
+ * console.log(result.code);
7290
+ * // .foo,.foo *{color:green}
7291
+ * ```
7292
+ */
7293
+ evaluateMixins?: boolean;
7294
+ /**
7295
+ * Keep the mixins and the custom functions once they are evaluated, see {@link evaluateMixins}.
7296
+ * By default, the evaluated mixins and custom functions, and the mixins that are not referenced, are dropped and
7297
+ * replaced with a comment
7298
+ */
7299
+ keepMixins?: boolean;
6385
7300
  /**
6386
7301
  * Remove empty ast nodes
6387
7302
  */
@@ -6402,8 +7317,8 @@ interface MinifyOptions {
6402
7317
  export declare type LoadResult =
6403
7318
  | Promise<ReadableStream<Uint8Array>>
6404
7319
  | ReadableStream<Uint8Array>
6405
- | string
6406
- | Promise<string>
7320
+ | CssInput
7321
+ | Promise<CssInput>
6407
7322
  | object;
6408
7323
 
6409
7324
  /**
@@ -6631,18 +7546,18 @@ export declare interface ParseInputFileOptions {
6631
7546
  */
6632
7547
  export declare interface ParseInputOptions {
6633
7548
  /**
6634
- * Input string or stream
7549
+ * Input css: an ArrayBuffer or a view of an ArrayBuffer (utf-8, the preferred input), or a string
6635
7550
  */
6636
- input: string;
7551
+ input: CssInput;
6637
7552
  }
6638
7553
  /**
6639
7554
  * Input options for string or stream
6640
7555
  */
6641
7556
  export declare interface ParseInputStreamOptions {
6642
7557
  /**
6643
- * Input string or stream
7558
+ * Input css: an ArrayBuffer or a view of an ArrayBuffer (utf-8, the preferred input), a string or a stream
6644
7559
  */
6645
- input: string | ReadableStream<Uint8Array>;
7560
+ input: CssInput | ReadableStream<Uint8Array>;
6646
7561
  }
6647
7562
 
6648
7563
  /**
@@ -6774,11 +7689,11 @@ export declare interface ParserSyncOptions
6774
7689
  */
6775
7690
  setParent?: boolean;
6776
7691
  /**
6777
- * Cache
7692
+ * Rendered size of the nodes, in bytes
6778
7693
  *
6779
7694
  * @private
6780
7695
  */
6781
- cache?: Map<AstNode, string>;
7696
+ cache?: Map<AstNode, number>;
6782
7697
 
6783
7698
  /**
6784
7699
  * CSS modules options
@@ -7106,79 +8021,30 @@ export declare interface ParseResult {
7106
8021
  }
7107
8022
 
7108
8023
  /**
7109
- * Render result object
8024
+ * Render stats
7110
8025
  */
7111
- export declare interface RenderResult {
7112
- /**
7113
- * Rendered CSS
7114
- */
7115
- code: string;
7116
- /**
7117
- * Render errors
7118
- */
7119
- errors: ErrorDescription[];
8026
+ export declare interface RenderResultStats {
7120
8027
  /**
7121
- * Render stats
7122
- */
7123
- stats: {
7124
- /**
7125
- * Render time
7126
- */
7127
- total: string;
7128
- };
7129
- /**
7130
- * Source map
8028
+ * Render time
7131
8029
  */
7132
- map?: SourceMap;
8030
+ total: string;
7133
8031
  }
7134
8032
 
7135
8033
  /**
7136
- * Transform result object
8034
+ * Transform stats
7137
8035
  */
7138
- export declare interface TransformResult extends ParseResult, RenderResult {
8036
+ export declare interface TransformResultStats extends ParseResultStats {
7139
8037
  /**
7140
- * Transform stats
8038
+ * Generated CSS size: the length of {@link TransformResult.code}
7141
8039
  */
7142
- stats: {
7143
- /**
7144
- * Source file
7145
- */
7146
- src: string;
7147
- /**
7148
- * Bytes read
7149
- */
7150
- bytesIn: number;
7151
- /**
7152
- * Generated CSS size
7153
- */
7154
- bytesOut: number;
7155
- /**
7156
- * Bytes read from imported files
7157
- */
7158
- importedBytesIn: number;
7159
- /**
7160
- * Parse time
7161
- */
7162
- parse: string;
7163
- /**
7164
- * Minify time
7165
- */
7166
- minify: string;
7167
- /**
7168
- * Render time
7169
- */
7170
- render: string;
7171
- /**
7172
- * Total time
7173
- */
7174
- total: string;
7175
- /**
7176
- * Imported files stats
7177
- */
7178
- imports: ParseResultStats[];
7179
- };
8040
+ bytesOut: number;
8041
+ /**
8042
+ * Render time
8043
+ */
8044
+ render: string;
7180
8045
  }
7181
8046
 
8047
+
7182
8048
  /**
7183
8049
  * Parse token options
7184
8050
  */
@@ -7314,9 +8180,14 @@ declare const resolve: (url: string, currentDirectory?: string, cwd?: string) =>
7314
8180
  */
7315
8181
  export declare interface ValidationSyntaxNode {
7316
8182
  /**
7317
- * mdn data syntax
8183
+ * webref syntax
7318
8184
  */
7319
8185
  syntax: string;
8186
+ /**
8187
+ * name of the standard property whose syntax is used: the vendor prefixed legacy name aliases of webref
8188
+ * (`-webkit-align-content` is an alias of `align-content`). an alias has no other key
8189
+ */
8190
+ alias?: string;
7320
8191
  /**
7321
8192
  * validation tokens
7322
8193
  */
@@ -7378,7 +8249,7 @@ interface ValidationResult {
7378
8249
  /**
7379
8250
  * validation result
7380
8251
  */
7381
- valid: SyntaxValidationResult;
8252
+ valid: boolean;
7382
8253
  /**
7383
8254
  * node
7384
8255
  */
@@ -7444,6 +8315,7 @@ declare function parseDeclarations(declaration: string, arena?: AstArena): {
7444
8315
  };
7445
8316
  /**
7446
8317
  * Parse css string and return an array of tokens
8318
+ * @param arena
7447
8319
  * @param src
7448
8320
  * @param options
7449
8321
  * - parseColor: parse identifiers as colors
@@ -7473,6 +8345,7 @@ declare function parseString(arena: AstArena, src: string, options?: {
7473
8345
  /**
7474
8346
  * render ast token. identical constructs (colors and tokens with sub tokens: functions, parentheses, binary
7475
8347
  * expressions, ...) are rendered once per render, see {@link RenderMemo}
8348
+ * @param arena
7476
8349
  * @param token
7477
8350
  * @param options
7478
8351
  * @param cache
@@ -7486,6 +8359,7 @@ declare function renderValue(arena: AstArena, token: Token, options?: RenderOpti
7486
8359
 
7487
8360
  /**
7488
8361
  * Converts a color to another color space
8362
+ * @param arena
7489
8363
  * @param token
7490
8364
  * @param to
7491
8365
  *
@@ -7520,13 +8394,16 @@ declare function okLabDistance(arena: AstArena, color1: Token, color2: Token): n
7520
8394
  declare function isOkLabClose(arena: AstArena, color1: Token, color2: Token, threshold?: number): boolean;
7521
8395
 
7522
8396
  /**
7523
- * parse mdn data syntax
8397
+ * parse a css value definition syntax (webref)
7524
8398
  * @param syntax
7525
8399
  * @returns
7526
8400
  */
7527
8401
  declare function parseSyntax(syntax: string): ValidationToken$1[];
7528
8402
 
7529
- declare let version: string;
8403
+ /**
8404
+ * Version number
8405
+ */
8406
+ declare const version = "2.2.0";
7530
8407
 
7531
8408
  /**
7532
8409
  * Load file or url
@@ -7546,6 +8423,7 @@ declare function load(url: string | {
7546
8423
  }, currentDirectory?: string, responseType?: boolean | ResponseType): Promise<string | ArrayBuffer | ReadableStream<Uint8Array<ArrayBufferLike>>>;
7547
8424
  /**
7548
8425
  * Render the ast tree
8426
+ * @param arena
7549
8427
  * @param data
7550
8428
  * @param options
7551
8429
  * @param mapping
@@ -7594,7 +8472,7 @@ declare function render(arena: AstArena, data: AstNode, options?: RenderOptions,
7594
8472
  * ```
7595
8473
  *
7596
8474
  */
7597
- declare function parseSync(stream: string, options?: ParserSyncOptions): ParseResult;
8475
+ declare function parseSync(stream: CssInput, options?: ParserSyncOptions): ParseResult;
7598
8476
  /**
7599
8477
  * Parse CSS string
7600
8478
  * @param options
@@ -7628,7 +8506,7 @@ declare function parseSync(options: ParseInputOptions & ParserSyncOptions): Pars
7628
8506
  * ```
7629
8507
  *
7630
8508
  */
7631
- declare function transformSync(css: string, options?: TransformSyncOptions): TransformResult;
8509
+ declare function transformSync(css: CssInput, options?: TransformSyncOptions): TransformResult;
7632
8510
  /**
7633
8511
  * Transform CSS
7634
8512
  * @param options
@@ -7687,7 +8565,7 @@ declare function transformSync(options: ParseInputOptions & TransformSyncOptions
7687
8565
  * console.log(result.ast);
7688
8566
  * ```
7689
8567
  */
7690
- declare function parse(stream: string | ReadableStream<Uint8Array>, options?: ParserOptions): Promise<ParseResult>;
8568
+ declare function parse(stream: CssInput | ReadableStream<Uint8Array>, options?: ParserOptions): Promise<ParseResult>;
7691
8569
  /**
7692
8570
  * Parse CSS
7693
8571
  * @param options
@@ -7804,7 +8682,7 @@ declare function parse(options: ParseInputStreamOptions & ParserOptions): Promis
7804
8682
  * console.log(result.code);
7805
8683
  * ```
7806
8684
  */
7807
- declare function transform(css: string | ReadableStream<Uint8Array>, options?: TransformOptions): Promise<TransformResult>;
8685
+ declare function transform(css: CssInput | ReadableStream<Uint8Array>, options?: TransformOptions): Promise<TransformResult>;
7808
8686
  /**
7809
8687
  * Transform CSS
7810
8688
  * @param options
@@ -7864,5 +8742,5 @@ declare function transform(options: ParseInputStreamOptions & TransformOptions):
7864
8742
  */
7865
8743
  declare function transform(options: ParseInputFileOptions & TransformOptions): Promise<TransformResult>;
7866
8744
 
7867
- export { ARENA, ARENAID, Arena, AstArena, AstArenaNode, ColorType$1 as ColorType, EnumAstNodeStatus, EnumToken, FeatureWalkMode, ModuleCaseTransformEnum, ModuleScopeEnumOptions, ResponseType, SourceMap, TokenField, WalkerEvent, WalkerOptionEnum, arenaColumns, convertColor, dirname, isOkLabClose, load, minify, okLabDistance, parse, parseDeclarations, parseString, parseSync, parseSyntax, render, renderValue as renderToken, resolve, transform, transformSync, version };
7868
- export type { AddToken, AndToken, AngleToken, ArenaProperties, ArenaTransferables, AstArenaNodeInput, AstAtRule, AstComment, AstDeclaration, AstKeyframesAtRule, AstKeyframesRule, AstNode, AstNodeMatcher, AstRule, AstRuleList, AstStyleSheet, AstValueMatcher, AtRuleToken, AtRuleVisitorHandler, AttrEndToken, AttrStartToken, AttrToken, Background, BackgroundAttachmentMapping, BackgroundPosition, BackgroundPositionClass, BackgroundPositionConstraints, BackgroundPositionMapping, BackgroundProperties, BackgroundRepeat, BackgroundRepeatMapping, BackgroundSize, BackgroundSizeMapping, BadCDOCommentToken, BadCommentToken, BadStringToken, BadUrlToken, BaseToken, BinaryExpressionNode, BinaryExpressionToken, BlockEndToken, BlockStartToken, Border, BorderColor, BorderColorClass, BorderProperties, BorderRadius, CDOCommentToken, ChildCombinatorToken, ClassSelectorToken, ColonToken, ColorToken, ColumnCombinatorToken, CommaToken, CommentToken, ComposesSelectorToken, ConstraintsMapping, ContainMatchToken, ContainerStyleRangeToken, CssTypeTokenType, CssVariableImportTokenType, CssVariableMapTokenType, CssVariableToken, DashMatchToken, DashedIdentToken, DeclarationToken, DeclarationVisitorHandler, DelimToken, DescendantCombinatorToken, DimensionToken, DivToken, DoubleColonToken, EOFToken, EndMatchToken, EqualMatchToken, ErrorDescription, FlexToken, Font, FontFamily, FontProperties, FontWeight, FontWeightConstraints, FontWeightMapping, FractionToken, FrequencyToken, FunctionDefToken, FunctionImageToken, FunctionToken, FunctionURLToken, GenericVisitorAstNodeHandlerMap, GenericVisitorAstNodeSyncHandlerMap, GenericVisitorAsyncResult, GenericVisitorHandler, GenericVisitorResult, GenericVisitorSyncHandler, GenericVisitorSyncResult, GreaterThanOrEqualToken, GreaterThanToken, GridTemplateFuncToken, HashToken, IdentListToken, IdentToken, IfConditionToken, IfElseConditionToken, ImportantToken, IncludeMatchToken, InfinityToken, LengthToken, LessThanOrEqualToken, LessThanToken, LineHeight, ListToken, LiteralToken, LoadResult, Map$1 as Map, MatchExpressionToken, MatchedSelector, MediaFeatureOnlyToken, MediaFeatureToken, MediaQueryConditionToken, MediaQueryUnaryFeatureToken, MediaRangeQueryToken, MinifyFeature, MinifyFeatureOptions, MinifyOptions, ModuleAsyncOptions, ModuleSyncOptions, MulToken, NaNToken, NameSpaceAttributeToken, NegativeInfinityToken, NestingSelectorToken, NextSiblingCombinatorToken, NotToken, NumberToken, OptimizedSelector, OptimizedSelectorToken, OrToken, Outline, OutlineProperties, ParensEndToken, ParensStartToken, ParensToken, ParseInfo$1 as ParseInfo, ParseInputFileOptions, ParseInputOptions, ParseInputStreamOptions, ParseResult, ParseResultStats, ParseSourceOptions, ParseTokenOptions, ParsedVisitorHandlers, ParserOptions, ParserSourceMapOptions, ParserSyncOptions, PercentageToken, PlainAstNode, PlainToken, Prefix, PropertiesConfig, PropertiesConfigProperties, PropertyListOptions, PropertyMapType, PropertySetType, PropertyType, PseudoClassFunctionToken, PseudoClassToken, PseudoElementToken, PseudoPageToken, PurpleBackgroundAttachment, RawNodeToken, RawSelectorTokens, RenderOptions, RenderResult, ResolutionToken, ResolvedPath, RuleVisitorHandler, SemiColonToken, Separator, ShorthandDef, ShorthandMapType, ShorthandProperties, ShorthandPropertyType, ShorthandType, SinglePropertyType, SinglePropertyTypeMapping, SourceLocation, SourceMapObject, StartMatchToken, StringToken, SubToken, SubsequentCombinatorToken, SupportsQueryConditionToken, SupportsQueryUnaryConditionToken, TimeToken, TimelineFunctionToken, TimingFunctionToken, Token, TokenizeResult, TransformOptions, TransformResult, TransformSyncOptions, UnaryExpression, UnaryExpressionNode, UnclosedStringToken, UniversalSelectorToken, UrlToken, ValidationConfiguration, ValidationMediaFeature, ValidationOptions, ValidationResult, ValidationSelectorOptions, ValidationSyntaxNode, ValidationSyntaxResult, ValidationToken$1 as ValidationToken, Value, ValueVisitorHandler, ValueVisitorSyncHandler, VariableScopeInfo, VisitorNodeMap, VisitorSyncNodeMap, WalkerFilter, WalkerOption, WalkerOptions, WalkerValueFilter, WalkerValueOptions, WhenElseQueryConditionToken, WhenElseUnaryConditionToken, WhitespaceToken, WrappedValuesToken };
8745
+ export { ARENA, ARENAID, Arena, AstArena, AstArenaNode, ColorType$1 as ColorType, EnumAstNodeStatus, EnumToken, FeatureWalkMode, ModuleCaseTransformEnum, ModuleScopeEnumOptions, RenderResult, ResponseType, SourceMap, TokenField, TransformResult, WalkerEvent, WalkerOptionEnum, arenaColumns, convertColor, dirname, isOkLabClose, load, minify, okLabDistance, parse, parseDeclarations, parseString, parseSync, parseSyntax, render, renderValue, resolve, transform, transformSync, version };
8746
+ export type { AddToken, AndToken, AngleToken, ArenaProperties, ArenaTransferables, AstArenaNodeInput, AstAtRule, AstComment, AstDeclaration, AstKeyframesAtRule, AstKeyframesRule, AstNode, AstNodeMatcher, AstRule, AstRuleList, AstStyleSheet, AstValueMatcher, AtRuleToken, AtRuleVisitorHandler, AttrEndToken, AttrStartToken, AttrToken, Background, BackgroundAttachmentMapping, BackgroundPosition, BackgroundPositionClass, BackgroundPositionConstraints, BackgroundPositionMapping, BackgroundProperties, BackgroundRepeat, BackgroundRepeatMapping, BackgroundSize, BackgroundSizeMapping, BadCDOCommentToken, BadCommentToken, BadStringToken, BadUrlToken, BaseToken, BinaryExpressionNode, BinaryExpressionToken, BlockEndToken, BlockStartToken, Border, BorderColor, BorderColorClass, BorderProperties, BorderRadius, CDOCommentToken, ChildCombinatorToken, ClassSelectorToken, ColonToken, ColorToken, ColumnCombinatorToken, CommaToken, CommentToken, ComposesSelectorToken, ConstraintsMapping, ContainMatchToken, ContainerStyleRangeToken, CssInput, CssTypeTokenType, CssVariableImportTokenType, CssVariableMapTokenType, CssVariableToken, DashMatchToken, DashedIdentToken, DeclarationToken, DeclarationVisitorHandler, DelimToken, DescendantCombinatorToken, DimensionToken, DivToken, DoubleColonToken, EOFToken, EndMatchToken, EqualMatchToken, ErrorDescription, FlexToken, Font, FontFamily, FontProperties, FontWeight, FontWeightConstraints, FontWeightMapping, FractionToken, FrequencyToken, FunctionDefToken, FunctionImageToken, FunctionToken, FunctionURLToken, GenericVisitorAstNodeHandlerMap, GenericVisitorAstNodeSyncHandlerMap, GenericVisitorAsyncResult, GenericVisitorHandler, GenericVisitorResult, GenericVisitorSyncHandler, GenericVisitorSyncResult, GreaterThanOrEqualToken, GreaterThanToken, GridTemplateFuncToken, HashToken, IdentListToken, IdentToken, IfConditionToken, IfElseConditionToken, ImportantToken, IncludeMatchToken, InfinityToken, LengthToken, LessThanOrEqualToken, LessThanToken, LineHeight, ListToken, LiteralToken, LoadResult, Map$1 as Map, MatchExpressionToken, MatchedSelector, MediaFeatureOnlyToken, MediaFeatureToken, MediaQueryConditionToken, MediaQueryUnaryFeatureToken, MediaRangeQueryToken, MinifyFeature, MinifyFeatureOptions, MinifyOptions, ModuleAsyncOptions, ModuleSyncOptions, MulToken, NaNToken, NameSpaceAttributeToken, NegativeInfinityToken, NestingSelectorToken, NextSiblingCombinatorToken, NotToken, NumberToken, OptimizedSelector, OptimizedSelectorToken, OrToken, Outline, OutlineProperties, ParensEndToken, ParensStartToken, ParensToken, ParseInfo$1 as ParseInfo, ParseInputFileOptions, ParseInputOptions, ParseInputStreamOptions, ParseResult, ParseResultStats, ParseSourceOptions, ParseTokenOptions, ParsedVisitorHandlers, ParserOptions, ParserSourceMapOptions, ParserSyncOptions, PercentageToken, PlainAstNode, PlainToken, Prefix, PropertiesConfig, PropertiesConfigProperties, PropertyListOptions, PropertyMapType, PropertySetType, PropertyType, PseudoClassFunctionToken, PseudoClassToken, PseudoElementToken, PseudoPageToken, PurpleBackgroundAttachment, RawNodeToken, RawSelectorTokens, RenderOptions, RenderResultStats, ResolutionToken, ResolvedPath, RuleVisitorHandler, SemiColonToken, Separator, ShorthandDef, ShorthandMapType, ShorthandProperties, ShorthandPropertyType, ShorthandType, SinglePropertyType, SinglePropertyTypeMapping, SourceLocation, SourceMapObject, StartMatchToken, StringToken, SubToken, SubsequentCombinatorToken, SupportsQueryConditionToken, SupportsQueryUnaryConditionToken, TimeToken, TimelineFunctionToken, TimingFunctionToken, Token, TokenizeResult, TransformOptions, TransformResultStats, TransformSyncOptions, UnaryExpression, UnaryExpressionNode, UnclosedStringToken, UniCodeRangeToken, UniversalSelectorToken, UrlToken, ValidationConfiguration, ValidationMediaFeature, ValidationOptions, ValidationResult, ValidationSelectorOptions, ValidationSyntaxNode, ValidationSyntaxResult, ValidationToken$1 as ValidationToken, Value, ValueVisitorHandler, ValueVisitorSyncHandler, VariableScopeInfo, VisitorNodeMap, VisitorSyncNodeMap, WalkerFilter, WalkerOption, WalkerOptions, WalkerValueFilter, WalkerValueOptions, WhenElseQueryConditionToken, WhenElseUnaryConditionToken, WhitespaceToken, WrappedValuesToken };