@tbela99/css-parser 1.6.4 → 1.6.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -5217,6 +5217,12 @@ interface MinifyOptions {
5217
5217
  * Enable minification
5218
5218
  */
5219
5219
  minify?: boolean;
5220
+
5221
+ /**
5222
+ * enable ast minification
5223
+ */
5224
+ minifyAST?: boolean;
5225
+
5220
5226
  /**
5221
5227
  * Parse color tokens
5222
5228
  */
@@ -5294,7 +5300,8 @@ export declare type LoadResult =
5294
5300
  | Promise<ReadableStream<Uint8Array>>
5295
5301
  | ReadableStream<Uint8Array>
5296
5302
  | string
5297
- | Promise<string> | object;
5303
+ | Promise<string>
5304
+ | object;
5298
5305
 
5299
5306
  /**
5300
5307
  * CSS module parser options
@@ -5792,9 +5799,15 @@ export declare interface RenderOptions {
5792
5799
  src?: string;
5793
5800
 
5794
5801
  /**
5795
- * Minify css values.
5802
+ * strip comments and whitespace.
5796
5803
  */
5797
5804
  minify?: boolean;
5805
+
5806
+ /**
5807
+ * Minify values
5808
+ */
5809
+ minifyValues?: boolean;
5810
+
5798
5811
  /**
5799
5812
  * Pretty print css
5800
5813
  *
@@ -8,7 +8,7 @@ import { replaceNodeOrValue } from '../../parser/utils/token.js';
8
8
  class ComputeCalcExpressionFeature {
9
9
  accept = new Set([EnumToken.RuleNodeType, EnumToken.AtRuleNodeType]);
10
10
  get ordering() {
11
- return 1;
11
+ return 3;
12
12
  }
13
13
  get processMode() {
14
14
  return FeatureWalkMode.Post;
@@ -20,7 +20,8 @@ class ComputeCalcExpressionFeature {
20
20
  }
21
21
  }
22
22
  run(ast) {
23
- if (!("chi" in ast)) {
23
+ // @ts-ignore
24
+ if (ast.chi == null) {
24
25
  return null;
25
26
  }
26
27
  for (const node of ast.chi) {
@@ -33,8 +34,12 @@ class ComputeCalcExpressionFeature {
33
34
  continue;
34
35
  }
35
36
  if (value.typ == EnumToken.BinaryExpressionTokenType) {
36
- // @ts-ignore
37
- replaceNodeOrValue(parent, value, evaluate([value]));
37
+ const result = evaluate([value]);
38
+ try {
39
+ // @ts-ignore
40
+ replaceNodeOrValue(parent, value, result);
41
+ }
42
+ catch (e) { }
38
43
  continue;
39
44
  }
40
45
  if (value != null && tokensfuncSet.has(value.typ)) {
@@ -52,7 +57,7 @@ class ComputeCalcExpressionFeature {
52
57
  ? value.val
53
58
  : value.chi;
54
59
  const values = evaluate(cp);
55
- // fix a + -b to a - b
60
+ // fix a + -b into a - b
56
61
  for (const { value, parent: p } of walkValues(values)) {
57
62
  if (value.typ === EnumToken.BinaryExpressionTokenType) {
58
63
  if (value.op === EnumToken.Add &&
@@ -174,7 +174,7 @@ function processNode(declarationNode, cache) {
174
174
  class ExpandIfFeature {
175
175
  accept = new Set([EnumToken.DeclarationNodeType]);
176
176
  get ordering() {
177
- return 4;
177
+ return 1;
178
178
  }
179
179
  get processMode() {
180
180
  return FeatureWalkMode.Pre;
@@ -57,10 +57,10 @@ function replace(node, variableScope) {
57
57
  class InlineCssVariablesFeature {
58
58
  accept = new Set([EnumToken.RuleNodeType, EnumToken.AtRuleNodeType]);
59
59
  get ordering() {
60
- return 0;
60
+ return 2;
61
61
  }
62
62
  get processMode() {
63
- return FeatureWalkMode.Pre;
63
+ return FeatureWalkMode.Post;
64
64
  }
65
65
  static register(options) {
66
66
  if (options.inlineCssVariables) {
@@ -109,7 +109,7 @@ function replaceAstNodes(tokens, root) {
109
109
  }
110
110
  class ComputePrefixFeature {
111
111
  get ordering() {
112
- return 2;
112
+ return 0;
113
113
  }
114
114
  get processMode() {
115
115
  return FeatureWalkMode.Pre;
@@ -9,7 +9,7 @@ class ComputeShorthandFeature {
9
9
  EnumToken.KeyframesRuleNodeType,
10
10
  ]);
11
11
  get ordering() {
12
- return 10;
12
+ return 5;
13
13
  }
14
14
  get processMode() {
15
15
  return FeatureWalkMode.Post;
@@ -28,7 +28,6 @@ class ComputeShorthandFeature {
28
28
  const j = ast.chi.length;
29
29
  let k = 0;
30
30
  let l;
31
- // let properties: PropertyList = new PropertyList(options);
32
31
  const rules = [];
33
32
  const declarations = [];
34
33
  // @ts-ignore
@@ -49,7 +48,6 @@ class ComputeShorthandFeature {
49
48
  if (node.typ == EnumToken.DeclarationNodeType) {
50
49
  for (let m = k; m <= l; m++) {
51
50
  declarations.push(ast.chi[m]);
52
- // properties.add(ast.chi![m]);
53
51
  }
54
52
  }
55
53
  else {
@@ -59,7 +57,6 @@ class ComputeShorthandFeature {
59
57
  }
60
58
  k = l;
61
59
  }
62
- // console.error([...new PropertyList(options).add(declarations)]);
63
60
  if (declarations.length > 0) {
64
61
  ast.chi.length = 0;
65
62
  // @ts-expect-error
@@ -12,7 +12,7 @@ class TransformCssFeature {
12
12
  EnumToken.KeyframesRuleNodeType,
13
13
  ]);
14
14
  get ordering() {
15
- return 3;
15
+ return 4;
16
16
  }
17
17
  get processMode() {
18
18
  return FeatureWalkMode.Post;
@@ -1,8 +1,9 @@
1
1
  import { equalsIgnoreCase } from '../../parser/utils/text.js';
2
- import { mathFuncs, LOCEND, LOCSTA, LOCSRCID } from '../../syntax/constants.js';
2
+ import { mathFuncs, PARENT, LOCEND, LOCSTA, LOCSRCID } from '../../syntax/constants.js';
3
3
  import { EnumToken } from '../types.js';
4
4
  import { rem, compute } from './math.js';
5
5
 
6
+ const numbers = new Set(["sin", "cos", "asin", "acos", "sign", "tan"]);
6
7
  /**
7
8
  * evaluate an array of tokens
8
9
  * @param tokens
@@ -64,6 +65,7 @@ function evaluate(tokens) {
64
65
  [LOCSRCID]: nodes[0][LOCSRCID],
65
66
  [LOCSTA]: nodes[0][LOCSTA],
66
67
  [LOCEND]: nodes[0][LOCEND],
68
+ [PARENT]: nodes[0][PARENT],
67
69
  },
68
70
  ];
69
71
  }
@@ -86,6 +88,7 @@ function evaluate(tokens) {
86
88
  [LOCSRCID]: nodes[i][LOCSRCID],
87
89
  [LOCSTA]: nodes[i][LOCSTA],
88
90
  [LOCEND]: nodes[i + 1][LOCEND],
91
+ [PARENT]: nodes[i + 1][PARENT],
89
92
  };
90
93
  }
91
94
  else {
@@ -95,6 +98,7 @@ function evaluate(tokens) {
95
98
  [LOCSRCID]: nodes[i + 1][LOCSRCID],
96
99
  [LOCSTA]: nodes[i + 1][LOCSTA],
97
100
  [LOCEND]: nodes[i + 1][LOCEND],
101
+ [PARENT]: nodes[i + 1][PARENT],
98
102
  }, EnumToken.Mul);
99
103
  }
100
104
  i++;
@@ -115,12 +119,14 @@ function evaluate(tokens) {
115
119
  [LOCSRCID]: token[LOCSRCID],
116
120
  [LOCSTA]: token[LOCSTA],
117
121
  [LOCEND]: token[LOCEND],
122
+ [PARENT]: token[PARENT],
118
123
  }, {
119
124
  ...token,
120
125
  val: -token.val,
121
126
  [LOCSRCID]: token[LOCSRCID],
122
127
  [LOCSTA]: token[LOCSTA],
123
128
  [LOCEND]: token[LOCEND],
129
+ [PARENT]: token[PARENT],
124
130
  });
125
131
  return acc;
126
132
  }
@@ -131,6 +137,7 @@ function evaluate(tokens) {
131
137
  [LOCSRCID]: token[LOCSRCID],
132
138
  [LOCSTA]: token[LOCSTA],
133
139
  [LOCEND]: token[LOCEND],
140
+ [PARENT]: token[PARENT],
134
141
  });
135
142
  }
136
143
  acc.push(token);
@@ -152,6 +159,7 @@ function doEvaluate(l, r, op) {
152
159
  [LOCSRCID]: l[LOCSRCID],
153
160
  [LOCSTA]: l[LOCSTA],
154
161
  [LOCEND]: r?.[LOCEND] ?? l[LOCEND],
162
+ [PARENT]: l[PARENT],
155
163
  };
156
164
  if (!isScalarToken(l) || !isScalarToken(r) || (l.typ == r.typ && "unit" in l && "unit" in r && l.unit != r.unit)) {
157
165
  return defaultReturn;
@@ -185,9 +193,22 @@ function doEvaluate(l, r, op) {
185
193
  r.typ == EnumToken.NegativeInfinityTokenType) {
186
194
  return computeInfinity(l, r, op, defaultReturn);
187
195
  }
196
+ if (l.typ == EnumToken.FunctionTokenType || l.typ == EnumToken.MathFunctionTokenType) {
197
+ const val = evaluateFunc(l);
198
+ if (val == null ||
199
+ (val.length == 1 &&
200
+ (val[0].typ == EnumToken.MathFunctionTokenType || val[0].typ == EnumToken.FunctionTokenType))) {
201
+ return defaultReturn;
202
+ }
203
+ if (val.length == 1) {
204
+ l = val[0];
205
+ }
206
+ }
188
207
  if (r.typ == EnumToken.FunctionTokenType || r.typ == EnumToken.MathFunctionTokenType) {
189
208
  const val = evaluateFunc(r);
190
- if (val == null) {
209
+ if (val == null ||
210
+ (val.length == 1 &&
211
+ (val[0].typ == EnumToken.MathFunctionTokenType || val[0].typ == EnumToken.FunctionTokenType))) {
191
212
  return defaultReturn;
192
213
  }
193
214
  if (val.length == 1) {
@@ -224,6 +245,7 @@ function doEvaluate(l, r, op) {
224
245
  [LOCSRCID]: l[LOCSRCID],
225
246
  [LOCSTA]: l[LOCSTA],
226
247
  [LOCEND]: l[LOCEND],
248
+ [PARENT]: l[PARENT],
227
249
  },
228
250
  r: {
229
251
  typ: EnumToken.NumberTokenType,
@@ -231,6 +253,7 @@ function doEvaluate(l, r, op) {
231
253
  [LOCSRCID]: r[LOCSRCID],
232
254
  [LOCSTA]: r[LOCSTA],
233
255
  [LOCEND]: r[LOCEND],
256
+ [PARENT]: r[PARENT],
234
257
  },
235
258
  };
236
259
  }
@@ -243,6 +266,7 @@ function doEvaluate(l, r, op) {
243
266
  [LOCSRCID]: l[LOCSRCID],
244
267
  [LOCSTA]: l[LOCSTA],
245
268
  [LOCEND]: l[LOCEND],
269
+ [PARENT]: l[PARENT],
246
270
  },
247
271
  r: {
248
272
  typ: EnumToken.NumberTokenType,
@@ -250,6 +274,7 @@ function doEvaluate(l, r, op) {
250
274
  [LOCSRCID]: r[LOCSRCID],
251
275
  [LOCSTA]: r[LOCSTA],
252
276
  [LOCEND]: r[LOCEND],
277
+ [PARENT]: r[PARENT],
253
278
  },
254
279
  };
255
280
  }
@@ -276,6 +301,7 @@ function doEvaluate(l, r, op) {
276
301
  [LOCSRCID]: l[LOCSRCID],
277
302
  [LOCSTA]: l[LOCSTA],
278
303
  [LOCEND]: r?.[LOCEND] ?? l[LOCEND],
304
+ [PARENT]: l[PARENT],
279
305
  };
280
306
  if (token.typ == EnumToken.IdenTokenType) {
281
307
  // @ts-ignore
@@ -400,45 +426,43 @@ function getValue(t) {
400
426
  function evaluateFunc(token) {
401
427
  const values = token.chi.slice();
402
428
  switch (token.val) {
403
- case "abs":
404
429
  case "sin":
405
430
  case "cos":
406
431
  case "tan":
432
+ for (let i = 0; i < values.length; i++) {
433
+ if (values[i].typ == EnumToken.NumberTokenType) {
434
+ values[i] = Object.assign(values[i], { typ: EnumToken.AngleTokenType, unit: "rad" });
435
+ }
436
+ else if (values[i].typ == EnumToken.AngleTokenType && values[i].unit != "rad") {
437
+ switch (values[i].unit) {
438
+ case "deg":
439
+ Object.assign(values[i], {
440
+ unit: "rad",
441
+ val: values[i].val * (Math.PI / 180),
442
+ });
443
+ break;
444
+ case "grad":
445
+ Object.assign(values[i], {
446
+ unit: "rad",
447
+ val: values[i].val * (Math.PI / 200),
448
+ });
449
+ break;
450
+ case "turn":
451
+ Object.assign(values[i], {
452
+ unit: "rad",
453
+ val: values[i].val * (2 * Math.PI),
454
+ });
455
+ break;
456
+ }
457
+ }
458
+ }
407
459
  case "asin":
408
460
  case "acos":
409
461
  case "atan":
462
+ case "abs":
410
463
  case "sign":
411
464
  case "sqrt":
412
- case "exp": {
413
- if (token.val == "tan" || token.val == "atan") {
414
- for (let i = 0; i < values.length; i++) {
415
- if (values[i].typ == EnumToken.NumberTokenType) {
416
- values[i] = Object.assign(values[i], { typ: EnumToken.AngleTokenType, unit: "rad" });
417
- }
418
- else if (values[i].typ == EnumToken.AngleTokenType && values[i].unit != "rad") {
419
- switch (values[i].unit) {
420
- case "deg":
421
- Object.assign(values[i], {
422
- unit: "rad",
423
- val: values[i].val * (Math.PI / 180),
424
- });
425
- break;
426
- case "grad":
427
- Object.assign(values[i], {
428
- unit: "rad",
429
- val: values[i].val * (Math.PI / 200),
430
- });
431
- break;
432
- case "turn":
433
- Object.assign(values[i], {
434
- unit: "rad",
435
- val: values[i].val * (2 * Math.PI),
436
- });
437
- break;
438
- }
439
- }
440
- }
441
- }
465
+ case "exp":
442
466
  const value = evaluate(values);
443
467
  // @ts-ignore
444
468
  let val = value[0].typ == EnumToken.NumberTokenType ||
@@ -448,7 +472,7 @@ function evaluateFunc(token) {
448
472
  : // @ts-expect-error
449
473
  value[0].l.val / value[0].r.val;
450
474
  return [
451
- token.val == "tan" || token.val == "atan"
475
+ token.val == "asin" || token.val == "acos" || token.val == "atan"
452
476
  ? {
453
477
  typ: EnumToken.AngleTokenType,
454
478
  val: Math[token.val](val),
@@ -456,16 +480,17 @@ function evaluateFunc(token) {
456
480
  [LOCSRCID]: value[0][LOCSRCID],
457
481
  [LOCSTA]: value[0][LOCSTA],
458
482
  [LOCEND]: value[0][LOCEND],
483
+ [PARENT]: value[0][PARENT],
459
484
  }
460
485
  : {
461
- typ: token.val == "sign" ? EnumToken.NumberTokenType : value[0].typ,
486
+ typ: numbers.has(token.val) ? EnumToken.NumberTokenType : value[0].typ,
462
487
  val: Math[token.val](val),
463
488
  [LOCSRCID]: value[0][LOCSRCID],
464
489
  [LOCSTA]: value[0][LOCSTA],
465
490
  [LOCEND]: value[0][LOCEND],
491
+ [PARENT]: value[0][PARENT],
466
492
  },
467
493
  ];
468
- }
469
494
  case "hypot": {
470
495
  const chi = values.filter((t) => ![EnumToken.WhitespaceTokenType, EnumToken.CommentTokenType, EnumToken.CommaTokenType].includes(t.typ));
471
496
  let all = [];
@@ -485,6 +510,7 @@ function evaluateFunc(token) {
485
510
  [LOCSRCID]: token[LOCSRCID],
486
511
  [LOCSTA]: token[LOCSTA],
487
512
  [LOCEND]: token[LOCEND],
513
+ [PARENT]: token[PARENT],
488
514
  },
489
515
  ];
490
516
  }
@@ -558,6 +584,7 @@ function evaluateFunc(token) {
558
584
  [LOCSRCID]: token[LOCSRCID],
559
585
  [LOCSTA]: token[LOCSTA],
560
586
  [LOCEND]: token[LOCEND],
587
+ [PARENT]: token[PARENT],
561
588
  },
562
589
  ];
563
590
  }
@@ -572,6 +599,7 @@ function evaluateFunc(token) {
572
599
  [LOCSRCID]: token[LOCSRCID],
573
600
  [LOCSTA]: token[LOCSTA],
574
601
  [LOCEND]: token[LOCEND],
602
+ [PARENT]: token[PARENT],
575
603
  },
576
604
  ];
577
605
  }
@@ -582,6 +610,7 @@ function evaluateFunc(token) {
582
610
  [LOCSRCID]: token[LOCSRCID],
583
611
  [LOCSTA]: token[LOCSTA],
584
612
  [LOCEND]: token[LOCEND],
613
+ [PARENT]: token[PARENT],
585
614
  },
586
615
  ];
587
616
  }
@@ -621,6 +650,7 @@ function evaluateFunc(token) {
621
650
  [LOCSRCID]: token[LOCSRCID],
622
651
  [LOCSTA]: token[LOCSTA],
623
652
  [LOCEND]: token[LOCEND],
653
+ [PARENT]: token[PARENT],
624
654
  },
625
655
  ];
626
656
  }
@@ -663,6 +693,7 @@ function evaluateFunc(token) {
663
693
  [LOCSRCID]: token[LOCSRCID],
664
694
  [LOCSTA]: token[LOCSTA],
665
695
  [LOCEND]: token[LOCEND],
696
+ [PARENT]: token[PARENT],
666
697
  },
667
698
  ];
668
699
  }
@@ -690,6 +721,7 @@ function inlineExpression(token) {
690
721
  [LOCSRCID]: token[LOCSRCID],
691
722
  [LOCSTA]: token[LOCSTA],
692
723
  [LOCEND]: token[LOCEND],
724
+ [PARENT]: token[PARENT],
693
725
  });
694
726
  for (const child of inlineExpression(token.r)) {
695
727
  result.push(child);
@@ -769,6 +801,7 @@ function factorToken(token) {
769
801
  [LOCSRCID]: token[LOCSRCID],
770
802
  [LOCSTA]: token[LOCSTA],
771
803
  [LOCEND]: token[LOCEND],
804
+ [PARENT]: token[PARENT],
772
805
  };
773
806
  // @ts-ignore
774
807
  delete token.val;
@@ -810,6 +843,7 @@ function factor(tokens, ops) {
810
843
  [LOCSRCID]: tokens[i - 1][LOCSRCID],
811
844
  [LOCSTA]: tokens[i - 1][LOCSTA],
812
845
  [LOCEND]: tokens[i + 1][LOCEND],
846
+ [PARENT]: tokens[i + 1][PARENT],
813
847
  });
814
848
  i--;
815
849
  }
@@ -787,7 +787,8 @@ function doMinify(ast, options = {}, recursive = false, errors, nestingContent,
787
787
  previous = node;
788
788
  nodeIndex = i;
789
789
  }
790
- if (recursive && node != null && "chi" in node) {
790
+ // @ts-ignore
791
+ if (recursive && node != null && node.chi != null) {
791
792
  if (node.typ == EnumToken.KeyframesAtRuleNodeType ||
792
793
  !node.chi.some((n) => n.typ == EnumToken.DeclarationNodeType)) {
793
794
  if (!(node.typ == EnumToken.AtRuleNodeType && node.nam != "font-face")) {
@@ -10,6 +10,9 @@ import { objectHash } from '../utils/hash.js';
10
10
  import { equalsIgnoreCase } from '../utils/text.js';
11
11
 
12
12
  const config = getConfig();
13
+ /**
14
+ * Represents a list of property declarations, compute shorthand and remove duplicate declarations.
15
+ */
13
16
  class PropertyList {
14
17
  options = { removeDuplicateDeclarations: true, computeShorthand: true };
15
18
  declarations;
@@ -84,28 +87,35 @@ class PropertyList {
84
87
  // @ts-ignore
85
88
  shorthand = config.property[propertyName];
86
89
  }
87
- // console.error({shortHandType, propertyName, config: config.map[propertyName], map: config.map[shorthand].properties[propertyName]});
88
90
  // @ts-ignore
89
91
  if (shortHandType == "map") {
90
92
  let owner = this;
93
+ const mapName =
91
94
  // @ts-ignore
92
- const mapName = config.map[propertyName]?.map ?? config.map[shorthand]?.properties?.[propertyName]?.map;
95
+ config.map[propertyName]?.map ?? config.map[shorthand]?.properties?.[propertyName]?.map;
93
96
  if (typeof mapName === "string") {
94
97
  if (!this.declarations.has(mapName)) {
95
98
  // @ts-ignore
96
99
  this.declarations.set(mapName, new PropertyMap(config.map[mapName]));
97
100
  }
98
101
  owner = this.declarations.get(mapName);
99
- // console.error({mapName});
100
102
  }
101
- // @ts-ignore
102
- if (!owner.declarations.has(shorthand)) {
103
+ else if (!this.declarations.has(shorthand)) {
103
104
  // @ts-ignore
104
- owner.declarations.set(shorthand, new PropertyMap(config.map[shorthand]));
105
+ this.declarations.set(shorthand, new PropertyMap(config.map[shorthand]));
106
+ }
107
+ if (owner == this) {
108
+ // @ts-ignore
109
+ owner.declarations.get(shorthand).add(declaration);
110
+ }
111
+ else {
112
+ if (!owner.declarations.has(shorthand)) {
113
+ // @ts-ignore
114
+ owner.declarations.set(shorthand, new PropertyMap(config.map[shorthand]));
115
+ }
116
+ // @ts-ignore
117
+ owner.declarations.get(shorthand).add(declaration);
105
118
  }
106
- // console.error({propertyName,mapName, owned: owner == this});
107
- // @ts-ignore
108
- owner.declarations.get(shorthand).add(declaration);
109
119
  }
110
120
  // @ts-ignore
111
121
  else if (shortHandType == "set") {
@@ -192,7 +202,7 @@ class PropertyList {
192
202
  [Symbol.iterator]() {
193
203
  let iterator = this.declarations.values();
194
204
  const iterators = [];
195
- // console.error(this);
205
+ // @ts-ignore
196
206
  return {
197
207
  next() {
198
208
  let value = iterator.next();
@@ -10,8 +10,8 @@ import { cloneNode } from '../../ast/clone.js';
10
10
 
11
11
  const propertiesConfig = getConfig();
12
12
  class PropertyMap {
13
- config;
14
13
  declarations;
14
+ config;
15
15
  requiredCount;
16
16
  pattern;
17
17
  constructor(config) {
@@ -25,7 +25,7 @@ class PropertyMap {
25
25
  }
26
26
  add(declaration) {
27
27
  if (declaration.nam == this.config.shorthand) {
28
- this.declarations = new Map();
28
+ this.declarations.clear();
29
29
  this.declarations.set(declaration.nam, declaration);
30
30
  this.matchTypes(declaration);
31
31
  }
@@ -41,23 +41,17 @@ class PropertyMap {
41
41
  if (this.declarations.has(this.config.shorthand)) {
42
42
  const tokens = {};
43
43
  const values = [];
44
- // @ts-ignore
45
- this.declarations
46
- .get(this.config.shorthand)
47
- // @ts-ignore
48
- .val.slice()
49
- .reduce((acc, curr) => {
44
+ const val = [[]];
45
+ for (const curr of this.declarations.get(this.config.shorthand).val) { // @ts-ignore
50
46
  // @ts-ignore
51
47
  if (separator != null && separator.typ == curr.typ && separator.val == curr.val) {
52
- acc.push([]);
53
- return acc;
48
+ val.push([]);
49
+ continue;
54
50
  }
55
51
  // @ts-ignore
56
- acc.at(-1).push(curr);
57
- return acc;
58
- }, [[]])
59
- // @ts-ignore
60
- .reduce((acc, list, current) => {
52
+ val.at(-1).push(curr);
53
+ }
54
+ for (let current = 0; current < val.length; current++) {
61
55
  values.push(...this.pattern.reduce((acc, property) => {
62
56
  // let current: number = 0;
63
57
  const props = this.config.properties[property];
@@ -72,9 +66,7 @@ class PropertyMap {
72
66
  // @ts-ignore
73
67
  acc[i][PROPERTYNAME] == property ||
74
68
  matchType(acc[i], props)) {
75
- if ("prefix" in props &&
76
- props.previous != null &&
77
- !(props.previous in tokens)) {
69
+ if ("prefix" in props && props.previous != null && !(props.previous in tokens)) {
78
70
  return acc;
79
71
  }
80
72
  if (!(property in tokens)) {
@@ -139,9 +131,8 @@ class PropertyMap {
139
131
  }
140
132
  }
141
133
  return acc;
142
- }, list));
143
- return values;
144
- }, []);
134
+ }, val[current]));
135
+ }
145
136
  if (values.length == 0) {
146
137
  this.declarations = Object.entries(tokens).reduce((acc, curr) => {
147
138
  acc.set(curr[0], {
@@ -201,17 +192,40 @@ class PropertyMap {
201
192
  }
202
193
  if (hasMapping) {
203
194
  const mapped = {};
204
- for (const key of declarations.keys()) {
205
- const value = declarations.get(key);
195
+ let key;
196
+ for (const value of declarations.values()) {
197
+ key = value.nam;
206
198
  if (value instanceof PropertyMap) {
207
199
  for (const [k, v] of value.declarations) {
208
- mapped[k] = v;
200
+ if (k == value.config.shorthand) {
201
+ for (const [key, val] of Object.entries(value.config.properties)) {
202
+ mapped[key] = cloneNode(v);
203
+ for (let i = 0; i < v.val.length; i++) {
204
+ // @ts-ignore
205
+ if (key == v.val[i][PROPERTYNAME]) {
206
+ if (mapped[key].val.length > 0) {
207
+ mapped[key].val.push({
208
+ typ: EnumToken.WhitespaceTokenType,
209
+ });
210
+ }
211
+ mapped[key].val.push(v.val[i]);
212
+ }
213
+ }
214
+ if (mapped[key].val.length == 0) {
215
+ mapped[key].val.push(...parseString(value.config.properties[key].default[0]));
216
+ }
217
+ }
218
+ }
219
+ else {
220
+ mapped[k] = v;
221
+ }
209
222
  }
210
223
  }
211
224
  else {
212
225
  mapped[key] = value;
213
226
  }
214
227
  }
228
+ // console.error(mapped);
215
229
  if (patterns.length === Object.keys(mapped).length) {
216
230
  declarations = new Map();
217
231
  for (const key of patterns) {
@@ -667,8 +681,6 @@ class PropertyMap {
667
681
  }
668
682
  return acc;
669
683
  }, []);
670
- // console.error({hasMapping, shorthand: this.config.shorthand, requiredCount, isShorthand,
671
- // declarations: declarations.values(), values});
672
684
  if (this.config.mapping != null) {
673
685
  const val = values.reduce((acc, curr) => acc +
674
686
  renderValue(curr, {
@@ -705,6 +717,7 @@ class PropertyMap {
705
717
  }
706
718
  }
707
719
  const iterators = [];
720
+ // @ts-ignore
708
721
  return {
709
722
  // @ts-ignore
710
723
  next() {