@tbela99/css-parser 1.8.2 → 2.0.1

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 (105) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/README.md +129 -31
  3. package/dist/index-umd-web.js +27383 -24083
  4. package/dist/index.d.ts +2737 -2200
  5. package/dist/package.json.js +2 -2
  6. package/dist/src/data/properties.json.js +1 -1
  7. package/dist/src/data/validation.json.js +1 -1
  8. package/dist/src/lib/ast/arena-node.js +548 -0
  9. package/dist/src/lib/ast/arena.js +3198 -0
  10. package/dist/src/lib/ast/cache.js +333 -0
  11. package/dist/src/lib/ast/features/calc.js +85 -76
  12. package/dist/src/lib/ast/features/if.js +155 -115
  13. package/dist/src/lib/ast/features/index.js +1 -1
  14. package/dist/src/lib/ast/features/inlinecssvariables.js +77 -84
  15. package/dist/src/lib/ast/features/prefix.js +184 -183
  16. package/dist/src/lib/ast/features/shorthand.js +40 -46
  17. package/dist/src/lib/ast/features/transform.js +24 -24
  18. package/dist/src/lib/ast/features/type.js +1 -1
  19. package/dist/src/lib/ast/math/expression.js +458 -543
  20. package/dist/src/lib/ast/math/math.js +19 -41
  21. package/dist/src/lib/ast/minify.js +590 -647
  22. package/dist/src/lib/ast/transform/compute.js +82 -85
  23. package/dist/src/lib/ast/transform/matrix.js +21 -38
  24. package/dist/src/lib/ast/transform/minify.js +82 -193
  25. package/dist/src/lib/ast/transform/perspective.js +2 -3
  26. package/dist/src/lib/ast/transform/rotate.js +1 -1
  27. package/dist/src/lib/ast/transform/scale.js +1 -1
  28. package/dist/src/lib/ast/transform/skew.js +1 -1
  29. package/dist/src/lib/ast/transform/translate.js +1 -1
  30. package/dist/src/lib/ast/transform/utils.js +2 -2
  31. package/dist/src/lib/ast/types.js +263 -258
  32. package/dist/src/lib/ast/walk.js +246 -610
  33. package/dist/src/lib/fs/resolve.js +1 -1
  34. package/dist/src/lib/parser/declaration/list.js +223 -139
  35. package/dist/src/lib/parser/declaration/map.js +251 -238
  36. package/dist/src/lib/parser/declaration/set.js +74 -66
  37. package/dist/src/lib/parser/linesmap.js +1 -1
  38. package/dist/src/lib/parser/parse.js +1379 -1658
  39. package/dist/src/lib/parser/source.js +7 -4
  40. package/dist/src/lib/parser/tokenize.js +406 -199
  41. package/dist/src/lib/parser/utils/angle.js +11 -13
  42. package/dist/src/lib/parser/utils/at-rule-container.js +183 -168
  43. package/dist/src/lib/parser/utils/at-rule-font-feature-values.js +5 -5
  44. package/dist/src/lib/parser/utils/at-rule-generic.js +31 -24
  45. package/dist/src/lib/parser/utils/at-rule-import.js +44 -44
  46. package/dist/src/lib/parser/utils/at-rule-media.js +216 -205
  47. package/dist/src/lib/parser/utils/at-rule-support.js +83 -88
  48. package/dist/src/lib/parser/utils/at-rule-when-else.js +47 -47
  49. package/dist/src/lib/parser/utils/at-rule.js +5 -5
  50. package/dist/src/lib/parser/utils/base64.js +2 -2
  51. package/dist/src/lib/parser/utils/cache.js +1 -1
  52. package/dist/src/lib/parser/utils/config.js +1 -1
  53. package/dist/src/lib/parser/utils/declaration.js +233 -234
  54. package/dist/src/lib/parser/utils/eq.js +50 -3
  55. package/dist/src/lib/parser/utils/hash.js +2 -35
  56. package/dist/src/lib/parser/utils/selector.js +309 -387
  57. package/dist/src/lib/parser/utils/text.js +18 -4
  58. package/dist/src/lib/parser/utils/token.js +16 -69
  59. package/dist/src/lib/parser/utils/type.js +37 -24
  60. package/dist/src/lib/printer/render.js +965 -511
  61. package/dist/src/lib/printer/sourcemap/lib/codec.js +1 -1
  62. package/dist/src/lib/printer/sourcemap/sourcemap.js +1 -1
  63. package/dist/src/lib/syntax/color/a98rgb.js +1 -1
  64. package/dist/src/lib/syntax/color/alpha.js +36 -37
  65. package/dist/src/lib/syntax/color/cmyk.js +35 -52
  66. package/dist/src/lib/syntax/color/color-mix.js +96 -132
  67. package/dist/src/lib/syntax/color/color.js +222 -231
  68. package/dist/src/lib/syntax/color/hex.js +45 -55
  69. package/dist/src/lib/syntax/color/hsl.js +54 -62
  70. package/dist/src/lib/syntax/color/hwb.js +60 -68
  71. package/dist/src/lib/syntax/color/lab.js +59 -67
  72. package/dist/src/lib/syntax/color/lch.js +59 -67
  73. package/dist/src/lib/syntax/color/oklab.js +60 -68
  74. package/dist/src/lib/syntax/color/oklch.js +60 -67
  75. package/dist/src/lib/syntax/color/p3.js +1 -1
  76. package/dist/src/lib/syntax/color/prophotorgb.js +1 -1
  77. package/dist/src/lib/syntax/color/rec2020.js +1 -1
  78. package/dist/src/lib/syntax/color/relative-color.js +94 -144
  79. package/dist/src/lib/syntax/color/rgb.js +54 -57
  80. package/dist/src/lib/syntax/color/srgb.js +55 -53
  81. package/dist/src/lib/syntax/color/utils/color-type.js +13 -10
  82. package/dist/src/lib/syntax/color/utils/colorspace.js +11 -11
  83. package/dist/src/lib/syntax/color/utils/components.js +19 -20
  84. package/dist/src/lib/syntax/color/utils/distance.js +15 -13
  85. package/dist/src/lib/syntax/color/utils/make-color.js +15 -19
  86. package/dist/src/lib/syntax/color/utils/matrix.js +2 -2
  87. package/dist/src/lib/syntax/color/xyz.js +1 -1
  88. package/dist/src/lib/syntax/color/xyzd50.js +1 -1
  89. package/dist/src/lib/syntax/constants.js +2 -16
  90. package/dist/src/lib/syntax/syntax.js +301 -407
  91. package/dist/src/lib/validation/config.js +1 -1
  92. package/dist/src/lib/validation/match.js +959 -723
  93. package/dist/src/lib/validation/parser/parse.js +230 -112
  94. package/dist/src/lib/validation/parser/typedef.js +1 -1
  95. package/dist/src/lib/validation/utils/list.js +27 -12
  96. package/dist/src/node.js +12 -72
  97. package/dist/src/types.js +1 -1
  98. package/dist/src/utils/sync.js +9 -6
  99. package/dist/src/web.js +11 -73
  100. package/package.json +9 -10
  101. package/dist/index.cjs +0 -35870
  102. package/dist/src/lib/ast/clone.js +0 -51
  103. package/dist/src/lib/ast/expand.js +0 -311
  104. package/dist/src/lib/ast/find.js +0 -192
  105. package/dist/src/lib/ast/node.js +0 -59
@@ -2,7 +2,7 @@
2
2
  CSS parser, minifier and validator for node and the browser
3
3
 
4
4
  Author(s): Thierry Bela
5
- Version: 1.8.2
5
+ Version: 2.0.1
6
6
  License: MIT
7
7
  */
8
8
  import { memoize } from '../parser/utils/cache.js';
@@ -2,7 +2,7 @@
2
2
  CSS parser, minifier and validator for node and the browser
3
3
 
4
4
  Author(s): Thierry Bela
5
- Version: 1.8.2
5
+ Version: 2.0.1
6
6
  License: MIT
7
7
  */
8
8
  import { PropertySet } from './set.js';
@@ -11,12 +11,69 @@ import { PropertyMap } from './map.js';
11
11
  import { EnumAstNodeStatus, EnumToken } from '../../ast/types.js';
12
12
  import { getParsedSyntax } from '../../validation/config.js';
13
13
  import { ValidationSyntaxGroupEnum } from '../../validation/parser/typedef.js';
14
- import { matchAllSyntaxes, createValidationContext } from '../../validation/match.js';
15
- import { STATE } from '../../syntax/constants.js';
16
- import { objectHash } from '../utils/hash.js';
17
- import { equalsIgnoreCase } from '../utils/text.js';
14
+ import { isValidDeclarationValue } from '../../validation/match.js';
15
+ import { equalsIgnoreCase, lowercase } from '../utils/text.js';
16
+ import { StructuralMemo } from '../../ast/cache.js';
17
+ import { parseString } from '../parse.js';
18
18
 
19
19
  const config = getConfig();
20
+ /**
21
+ * Results shared by the property lists of a minification, valid for the arena they were computed for:
22
+ * - the keys of the declarations that are not merged by name (invalid declarations, custom properties, comments, ...):
23
+ * identical declarations have the same key
24
+ * - the tokens of the default values of the shorthand properties: each value is parsed once, the tokens are cloned
25
+ *
26
+ * @internal
27
+ */
28
+ class DeclarationMemo {
29
+ /**
30
+ * An instance is kept alive: the hidden class of the instances would otherwise be collected by a full garbage
31
+ * collection when no instance is alive, and the optimized code that depends on it discarded (deoptimized)
32
+ */
33
+ static shape = new DeclarationMemo();
34
+ /**
35
+ * key by structure. same equality as the structural signature: 0 and -0 are equal
36
+ */
37
+ keys = new StructuralMemo(true);
38
+ /**
39
+ * parsed values: detached tokens that are cloned, never attached to the tree
40
+ */
41
+ parsed = new Map();
42
+ /**
43
+ * tokens of a value, see {@link parseString}. the value is parsed once, the tokens are cloned
44
+ * @param arena
45
+ * @param value
46
+ */
47
+ parse(arena, value) {
48
+ let template = this.parsed.get(value);
49
+ if (template === undefined) {
50
+ template = parseString(arena, value);
51
+ this.parsed.set(value, template);
52
+ }
53
+ const tokens = new Array(template.length);
54
+ for (let i = 0; i < template.length; i++) {
55
+ tokens[i] = arena.clone(template[i], true);
56
+ }
57
+ return tokens;
58
+ }
59
+ /**
60
+ * unique key of the structure of a node (type, name, values, tokens and children). identical nodes have the same key
61
+ * @param arena
62
+ * @param node
63
+ */
64
+ key(arena, node) {
65
+ const slot = this.keys.token(arena, node);
66
+ // inlined: this.keys.get(slot)
67
+ let key = this.keys.values[slot];
68
+ if (key === undefined) {
69
+ // not a property name
70
+ key = "\0" + slot;
71
+ // inlined: this.keys.set(slot, key)
72
+ this.keys.values[slot] = key;
73
+ }
74
+ return key;
75
+ }
76
+ }
20
77
  /**
21
78
  * Represents a list of property declarations, compute shorthand and remove duplicate declarations.
22
79
  */
@@ -29,155 +86,181 @@ class PropertyList {
29
86
  * declarations
30
87
  */
31
88
  declarations;
89
+ /**
90
+ * arena the declarations are stored in
91
+ */
92
+ arena;
93
+ /**
94
+ * keys shared by the lists that use the same arena
95
+ */
96
+ memo;
32
97
  /**
33
98
  *
99
+ * @param arena
34
100
  * @param options
101
+ * @param memo keys shared by the lists that use the same arena
35
102
  */
36
- constructor(options = {}) {
103
+ constructor(arena, options = {}, memo = null) {
104
+ this.arena = arena;
37
105
  this.options = options;
38
106
  this.declarations = new Map();
107
+ this.memo = memo ?? new DeclarationMemo();
39
108
  }
40
109
  /**
41
110
  * add declarations
42
- * @param declarations
111
+ * @param declarations node ids
43
112
  * @returns
44
113
  */
45
114
  add(declarations) {
115
+ for (const declaration of declarations) {
116
+ this.addDeclaration(declaration);
117
+ }
118
+ return this;
119
+ }
120
+ /**
121
+ * add a declaration
122
+ * @param declaration node id
123
+ */
124
+ addDeclaration(declaration) {
46
125
  let name;
47
126
  let syntaxRules = null;
48
- let result;
49
- for (const declaration of declarations) {
50
- name = declaration.typ != EnumToken.DeclarationNodeType ? null : declaration.nam;
51
- // do not compute shorthand for invalid declarations
52
- if (name == null) {
53
- this.declarations.set(objectHash(declaration), declaration);
54
- continue;
127
+ const arena = this.arena;
128
+ name =
129
+ arena.dataTypes[declaration] != EnumToken.DeclarationNodeType
130
+ ? null
131
+ : arena.strings[arena.name[declaration]];
132
+ // do not compute shorthand for invalid declarations
133
+ if (name == null) {
134
+ this.declarations.set(this.memo.key(arena, declaration), declaration);
135
+ return this;
136
+ }
137
+ // @functiom / result
138
+ if (arena.flags[declaration] & EnumAstNodeStatus.Unknown && equalsIgnoreCase("result", name)) {
139
+ this.declarations.set(name, declaration);
140
+ return this;
141
+ }
142
+ if (arena.flags[declaration] &
143
+ (EnumAstNodeStatus.Invalid | EnumAstNodeStatus.Unknown | EnumAstNodeStatus.ValidationFailed) ||
144
+ equalsIgnoreCase("composes", name) ||
145
+ (typeof this.options.removeDuplicateDeclarations === "string" &&
146
+ this.options.removeDuplicateDeclarations === name) ||
147
+ (Array.isArray(this.options.removeDuplicateDeclarations)
148
+ ? this.options.removeDuplicateDeclarations.includes(name)
149
+ : !this.options.removeDuplicateDeclarations)) {
150
+ const key = this.memo.key(arena, declaration);
151
+ if (this.declarations.has(key)) {
152
+ this.declarations.delete(key);
55
153
  }
56
- // @functiom / result
57
- if (declaration[STATE] & EnumAstNodeStatus.Unknown && equalsIgnoreCase("result", name)) {
58
- this.declarations.set(declaration.nam, declaration);
59
- continue;
154
+ this.declarations.set(key, declaration);
155
+ return this;
156
+ }
157
+ if (!this.options.computeShorthand) {
158
+ this.declarations.set(name, declaration);
159
+ return this;
160
+ }
161
+ if (arena.flags[declaration] & EnumAstNodeStatus.Unvalidated) {
162
+ syntaxRules = getParsedSyntax(ValidationSyntaxGroupEnum.Declarations, lowercase(name));
163
+ if (syntaxRules != null) {
164
+ arena.flags[declaration] |=
165
+ (isValidDeclarationValue(arena, syntaxRules, declaration, this.options)
166
+ ? EnumAstNodeStatus.Validated
167
+ : EnumAstNodeStatus.ValidationFailed) & ~EnumAstNodeStatus.Unvalidated;
60
168
  }
61
- if (declaration[STATE] &
62
- (EnumAstNodeStatus.Invalid | EnumAstNodeStatus.Unknown | EnumAstNodeStatus.ValidationFailed) ||
63
- declaration.typ != EnumToken.DeclarationNodeType ||
64
- equalsIgnoreCase("composes", name) ||
65
- (typeof this.options.removeDuplicateDeclarations === "string" &&
66
- this.options.removeDuplicateDeclarations === name) ||
67
- (Array.isArray(this.options.removeDuplicateDeclarations)
68
- ? this.options.removeDuplicateDeclarations.includes(declaration.nam)
69
- : !this.options.removeDuplicateDeclarations)) {
70
- const key = objectHash(declaration);
71
- if (this.declarations.has(key)) {
72
- this.declarations.delete(key);
73
- }
74
- this.declarations.set(key, declaration);
75
- continue;
169
+ }
170
+ // do not compute shorthand for invalid declarations
171
+ if (!(arena.flags[declaration] & EnumAstNodeStatus.Validated)) {
172
+ this.declarations.set(this.memo.key(arena, declaration), declaration);
173
+ return this;
174
+ }
175
+ let propertyName = name;
176
+ let shortHandType;
177
+ let shorthand = null;
178
+ if (propertyName in config.properties) {
179
+ // @ts-ignore
180
+ if ("map" in config.properties[propertyName]) {
181
+ shortHandType = "map";
182
+ // @ts-ignore
183
+ shorthand = config.properties[propertyName].map;
76
184
  }
77
- if (!this.options.computeShorthand) {
78
- this.declarations.set(declaration.nam, declaration);
79
- continue;
185
+ else {
186
+ shortHandType = "set";
187
+ // @ts-ignore
188
+ shorthand = config.properties[propertyName].shorthand;
80
189
  }
81
- if (declaration[STATE] & EnumAstNodeStatus.Unvalidated) {
82
- syntaxRules = getParsedSyntax(ValidationSyntaxGroupEnum.Declarations, declaration.nam.toLowerCase());
83
- if (syntaxRules != null) {
84
- result = matchAllSyntaxes(syntaxRules, createValidationContext(declaration.val), this.options);
85
- declaration[STATE] |=
86
- (result.success ? EnumAstNodeStatus.Validated : EnumAstNodeStatus.ValidationFailed) &
87
- ~EnumAstNodeStatus.Unvalidated;
88
- }
190
+ }
191
+ else if (propertyName in config.map) {
192
+ shortHandType = "map";
193
+ // @ts-ignore
194
+ shorthand = config.map[propertyName].shorthand;
195
+ }
196
+ else if (propertyName in config.property) {
197
+ shortHandType = "single";
198
+ // @ts-ignore
199
+ shorthand = config.property[propertyName];
200
+ }
201
+ if (this.declarations.has(shorthand)) {
202
+ let existing = this.declarations.get(shorthand);
203
+ if (existing instanceof PropertySet || existing instanceof PropertyMap) {
204
+ existing = existing.declarations.get(name);
89
205
  }
90
- // do not compute shorthand for invalid declarations
91
- if (!(declaration[STATE] & EnumAstNodeStatus.Validated)) {
92
- this.declarations.set(objectHash(declaration), declaration);
93
- continue;
206
+ if (existing != null &&
207
+ typeof existing == "number" &&
208
+ arena.flags[existing] & EnumAstNodeStatus.ImportantDeclaration &&
209
+ arena.flags[declaration] & ~EnumAstNodeStatus.ImportantDeclaration) {
210
+ return this;
94
211
  }
95
- let propertyName = declaration.nam;
96
- let shortHandType;
97
- let shorthand = null;
98
- if (propertyName in config.properties) {
99
- // @ts-ignore
100
- if ("map" in config.properties[propertyName]) {
101
- shortHandType = "map";
102
- // @ts-ignore
103
- shorthand = config.properties[propertyName].map;
104
- }
105
- else {
106
- shortHandType = "set";
212
+ }
213
+ // @ts-ignore
214
+ if (shortHandType == "map") {
215
+ let owner = this;
216
+ const mapName =
217
+ // @ts-ignore
218
+ config.map[propertyName]?.map ?? config.map[shorthand]?.properties?.[propertyName]?.map;
219
+ if (typeof mapName === "string") {
220
+ if (!this.declarations.has(mapName)) {
221
+ this.declarations.set(mapName,
107
222
  // @ts-ignore
108
- shorthand = config.properties[propertyName].shorthand;
223
+ new PropertyMap(arena, config.map[mapName], this.memo));
109
224
  }
225
+ owner = this.declarations.get(mapName);
110
226
  }
111
- else if (propertyName in config.map) {
112
- shortHandType = "map";
227
+ else if (!this.declarations.has(shorthand)) {
113
228
  // @ts-ignore
114
- shorthand = config.map[propertyName].shorthand;
229
+ this.declarations.set(shorthand, new PropertyMap(arena, config.map[shorthand], this.memo));
115
230
  }
116
- else if (propertyName in config.property) {
117
- shortHandType = "single";
231
+ if (owner == this) {
118
232
  // @ts-ignore
119
- shorthand = config.property[propertyName];
120
- }
121
- if (this.declarations.has(shorthand)) {
122
- let existing = this.declarations.get(shorthand);
123
- if (existing instanceof PropertySet || existing instanceof PropertyMap) {
124
- existing = existing.declarations.get(declaration.nam);
125
- }
126
- if (existing?.[STATE] & EnumAstNodeStatus.ImportantDeclaration &&
127
- declaration[STATE] & ~EnumAstNodeStatus.ImportantDeclaration) {
128
- continue;
129
- }
233
+ owner.declarations.get(shorthand).add(declaration);
130
234
  }
131
- // @ts-ignore
132
- if (shortHandType == "map") {
133
- let owner = this;
134
- const mapName =
135
- // @ts-ignore
136
- config.map[propertyName]?.map ?? config.map[shorthand]?.properties?.[propertyName]?.map;
137
- if (typeof mapName === "string") {
138
- if (!this.declarations.has(mapName)) {
139
- // @ts-ignore
140
- this.declarations.set(mapName, new PropertyMap(config.map[mapName]));
141
- }
142
- owner = this.declarations.get(mapName);
143
- }
144
- else if (!this.declarations.has(shorthand)) {
145
- // @ts-ignore
146
- this.declarations.set(shorthand, new PropertyMap(config.map[shorthand]));
147
- }
148
- if (owner == this) {
149
- // @ts-ignore
150
- owner.declarations.get(shorthand).add(declaration);
151
- }
152
- else {
153
- if (!owner.declarations.has(shorthand)) {
154
- // @ts-ignore
155
- owner.declarations.set(shorthand, new PropertyMap(config.map[shorthand]));
156
- }
235
+ else {
236
+ if (!owner.declarations.has(shorthand)) {
237
+ owner.declarations.set(shorthand,
157
238
  // @ts-ignore
158
- owner.declarations.get(shorthand).add(declaration);
239
+ new PropertyMap(arena, config.map[shorthand], this.memo));
159
240
  }
241
+ // @ts-ignore
242
+ owner.declarations.get(shorthand).add(declaration);
160
243
  }
244
+ }
245
+ // @ts-ignore
246
+ else if (shortHandType == "set") {
161
247
  // @ts-ignore
162
- else if (shortHandType == "set") {
248
+ if (!this.declarations.has(shorthand)) {
163
249
  // @ts-ignore
164
- if (!this.declarations.has(shorthand)) {
165
- // @ts-ignore
166
- this.declarations.set(
167
- // @ts-ignore
168
- shorthand,
169
- // @ts-ignore
170
- new PropertySet(config.properties[shorthand]));
171
- }
250
+ this.declarations.set(
251
+ // @ts-ignore
252
+ shorthand,
172
253
  // @ts-ignore
173
- this.declarations.get(shorthand).add(declaration);
254
+ new PropertySet(arena, config.properties[shorthand]));
174
255
  }
175
- else {
176
- if (shorthand != null) {
177
- this.mapValues(declaration, shorthand);
178
- }
179
- this.declarations.set(propertyName, declaration);
256
+ // @ts-ignore
257
+ this.declarations.get(shorthand).add(declaration);
258
+ }
259
+ else {
260
+ if (shorthand != null) {
261
+ this.mapValues(declaration, shorthand);
180
262
  }
263
+ this.declarations.set(propertyName, declaration);
181
264
  }
182
265
  return this;
183
266
  }
@@ -188,26 +271,29 @@ class PropertyList {
188
271
  */
189
272
  mapValues(declaration, mapping) {
190
273
  let name;
191
- let values = declaration.val;
274
+ const arena = this.arena;
275
+ const declarationValues = arena.tokens(declaration);
276
+ let values = declarationValues;
192
277
  if (mapping.pattern != null) {
193
278
  // match pattern
194
279
  for (const patterns of mapping.pattern) {
195
- const set = new Set(values.filter((v) => v.typ !== EnumToken.CommentTokenType && v.typ !== EnumToken.WhitespaceTokenType));
280
+ const set = new Set(values.filter((v) => arena.dataTypes[v] !== EnumToken.CommentTokenType &&
281
+ arena.dataTypes[v] !== EnumToken.WhitespaceTokenType));
196
282
  const val = [];
197
283
  for (const pattern of patterns) {
198
284
  switch (pattern) {
199
285
  case "<length>":
200
286
  for (const v of set) {
201
- if (v.typ === EnumToken.LengthTokenType ||
202
- (v.typ === EnumToken.NumberTokenType && v.val === 0)) {
287
+ if (arena.dataTypes[v] === EnumToken.LengthTokenType ||
288
+ (arena.dataTypes[v] === EnumToken.NumberTokenType && arena.numericValue[v] === 0)) {
203
289
  val.push(v);
204
290
  set.delete(v);
205
291
  }
206
292
  }
207
293
  default: {
208
294
  for (const v of set) {
209
- if (v.typ === EnumToken.IdenTokenType) {
210
- const value = v.val.toLowerCase();
295
+ if (arena.dataTypes[v] === EnumToken.IdenTokenType) {
296
+ const value = arena.strings[arena.stringValue[v]].toLowerCase();
211
297
  if (value === pattern || new RegExp(`(^|\|)${pattern}(\||$)`).test(value)) {
212
298
  val.push(v);
213
299
  set.delete(v);
@@ -220,7 +306,7 @@ class PropertyList {
220
306
  if (set.size === 0) {
221
307
  values = val.reduce((acc, curr) => {
222
308
  if (acc.length > 0) {
223
- acc.push({ typ: EnumToken.WhitespaceTokenType });
309
+ acc.push(arena.createToken(EnumToken.WhitespaceTokenType));
224
310
  }
225
311
  acc.push(curr);
226
312
  return acc;
@@ -229,20 +315,17 @@ class PropertyList {
229
315
  }
230
316
  }
231
317
  }
232
- for (const val of declaration.val) {
233
- if (val.typ === EnumToken.IdenTokenType) {
234
- name = val.val.toLowerCase();
318
+ for (const val of declarationValues) {
319
+ if (arena.dataTypes[val] === EnumToken.IdenTokenType) {
320
+ name = arena.strings[arena.stringValue[val]].toLowerCase();
235
321
  if (mapping.mapping[name] != null) {
236
- // @ts-expect-error
237
- Object.assign(val, mapping.mapping[name], { typ: EnumToken[mapping.mapping[name].typ] });
322
+ const typ = EnumToken[mapping.mapping[name].typ];
323
+ arena.resetToken(val, typ, mapping.mapping[name].val);
238
324
  }
239
325
  }
240
326
  }
241
- if (values != declaration.val) {
242
- declaration.val.length = 0;
243
- for (const v of values) {
244
- declaration.val.push(v);
245
- }
327
+ if (values != declarationValues) {
328
+ arena.setTokenList(declaration, values);
246
329
  }
247
330
  }
248
331
  /**
@@ -260,13 +343,14 @@ class PropertyList {
260
343
  value.value instanceof PropertySet ||
261
344
  value.value instanceof PropertyMap) {
262
345
  if (value.value instanceof PropertySet || value.value instanceof PropertyMap) {
263
- iterators.unshift(iterator);
346
+ // stack of the parent iterators
347
+ iterators.push(iterator);
264
348
  // @ts-ignore
265
349
  iterator = value.value[Symbol.iterator]();
266
350
  value = iterator.next();
267
351
  }
268
352
  if (value.done && iterators.length > 0) {
269
- iterator = iterators.shift();
353
+ iterator = iterators.pop();
270
354
  value = iterator.next();
271
355
  }
272
356
  }
@@ -276,4 +360,4 @@ class PropertyList {
276
360
  }
277
361
  }
278
362
 
279
- export { PropertyList };
363
+ export { DeclarationMemo, PropertyList };