@tbela99/css-parser 1.4.6 → 1.4.8

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 (55) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +1 -0
  3. package/dist/index-umd-web.js +6578 -6969
  4. package/dist/index.cjs +7808 -8197
  5. package/dist/index.d.ts +923 -51
  6. package/dist/lib/ast/clone.js +16 -23
  7. package/dist/lib/ast/expand.js +2 -2
  8. package/dist/lib/ast/features/if.js +88 -87
  9. package/dist/lib/ast/features/inlinecssvariables.js +2 -2
  10. package/dist/lib/ast/features/prefix.js +26 -22
  11. package/dist/lib/ast/features/transform.js +3 -3
  12. package/dist/lib/ast/find.js +17 -14
  13. package/dist/lib/ast/minify.js +97 -94
  14. package/dist/lib/ast/types.js +10 -2
  15. package/dist/lib/ast/walk.js +1 -1
  16. package/dist/lib/fs/resolve.js +47 -45
  17. package/dist/lib/parser/arena.js +206 -0
  18. package/dist/lib/parser/declaration/list.js +9 -10
  19. package/dist/lib/parser/declaration/map.js +13 -18
  20. package/dist/lib/parser/linemap.js +62 -0
  21. package/dist/lib/parser/parse.js +331 -504
  22. package/dist/lib/parser/source.js +72 -0
  23. package/dist/lib/parser/tokenize.js +39 -33
  24. package/dist/lib/parser/utils/at-rule-container.js +244 -247
  25. package/dist/lib/parser/utils/at-rule-generic.js +25 -25
  26. package/dist/lib/parser/utils/at-rule-import.js +194 -234
  27. package/dist/lib/parser/utils/at-rule-media.js +284 -283
  28. package/dist/lib/parser/utils/at-rule-support.js +279 -251
  29. package/dist/lib/parser/utils/at-rule-when-else.js +256 -259
  30. package/dist/lib/parser/utils/at-rule.js +19 -16
  31. package/dist/lib/parser/utils/cache.js +33 -5
  32. package/dist/lib/parser/utils/declaration.js +260 -298
  33. package/dist/lib/parser/utils/hash.js +15 -15
  34. package/dist/lib/parser/utils/selector.js +182 -222
  35. package/dist/lib/parser/utils/token.js +4 -7
  36. package/dist/lib/renderer/render.js +152 -121
  37. package/dist/lib/syntax/color/alpha.js +1 -4
  38. package/dist/lib/syntax/color/color-mix.js +8 -1
  39. package/dist/lib/syntax/color/color.js +17 -9
  40. package/dist/lib/syntax/color/hex.js +1 -1
  41. package/dist/lib/syntax/color/p3.js +9 -1
  42. package/dist/lib/syntax/color/utils/colorspace.js +3 -3
  43. package/dist/lib/syntax/color/utils/components.js +21 -22
  44. package/dist/lib/syntax/color/utils/distance.js +6 -1
  45. package/dist/lib/syntax/color/utils/matrix.js +12 -11
  46. package/dist/lib/syntax/constants.js +25 -3
  47. package/dist/lib/syntax/syntax.js +240 -311
  48. package/dist/lib/validation/config.js +16 -17
  49. package/dist/lib/validation/match.js +1118 -1131
  50. package/dist/lib/validation/parser/parse.js +130 -286
  51. package/dist/node.js +18 -14
  52. package/dist/web.js +12 -10
  53. package/package.json +4 -4
  54. package/dist/lib/validation/utils/whitespace.js +0 -17
  55. /package/dist/lib/syntax/color/{relativecolor.js → relative-color.js} +0 -0
@@ -1,17 +1,9 @@
1
1
  import { EnumToken } from '../../ast/types.js';
2
- import { renderValue } from '../../renderer/render.js';
3
2
  import { trimArray } from '../../validation/match.js';
4
- import { tokensfuncDefMap, definedPropertySettings, tokensfuncSet } from '../../syntax/constants.js';
3
+ import { tokensfuncDefMap, LOC } from '../../syntax/constants.js';
5
4
  import { parseMediaqueryList } from './at-rule-media.js';
6
5
  import { parseAtRuleSupportSyntax } from './at-rule-support.js';
7
- import { equalsIgnoreCase } from './text.js';
8
6
 
9
- const validChildTypes = new Set([
10
- EnumToken.WhenElseFunctionTokenDefType,
11
- EnumToken.WhenElseFunctionTokenType,
12
- EnumToken.WhenElseQueryConditionTokenType,
13
- EnumToken.WhenElseUnaryConditionTokenType,
14
- ]);
15
7
  function matchAtRuleWhenElseSyntax(stream, context, options = {}) {
16
8
  const tokens = [];
17
9
  const stack = [];
@@ -20,53 +12,59 @@ function matchAtRuleWhenElseSyntax(stream, context, options = {}) {
20
12
  let expectAndOr = false;
21
13
  let scope = new Set();
22
14
  const errors = [];
23
- const scopes = [scope];
24
- while (i < stream.length &&
25
- (stream[i]?.typ === EnumToken.WhitespaceTokenType || stream[i]?.typ === EnumToken.CommentTokenType)) {
26
- tokens.push(stream[i]);
27
- i++;
28
- }
29
- if (i >= stream.length) {
30
- success = "else" === context.nam;
31
- return {
32
- success,
33
- errors: success
34
- ? []
35
- : [
36
- {
37
- action: "drop",
38
- node: stream[i],
39
- location: stream[i]?.loc,
40
- message: `expecting '<boolean-condition>' at ${stream[i]?.loc?.src}:${stream[i]?.loc?.sta.lin}:${stream[i]?.loc?.sta.col}`,
41
- },
42
- ],
43
- };
44
- }
45
- if (stream[i]?.typ !== EnumToken.WhenElseFunctionTokenDefType &&
46
- stream[i]?.typ !== EnumToken.SupportsFunctionTokenDefType &&
47
- stream[i]?.typ !== EnumToken.StartParensTokenType &&
48
- 'val' in stream[i] &&
49
- !(stream[i]?.typ === EnumToken.IdenTokenType &&
50
- (equalsIgnoreCase(stream[i].val, "not") || equalsIgnoreCase(stream[i].val, "only")))) {
51
- return {
52
- success: false,
53
- errors: [
54
- {
55
- action: "drop",
56
- node: stream[i],
57
- location: stream[i]?.loc,
58
- message: `expecting '<boolean-condition>' at ${stream[i]?.loc?.src}:${stream[i]?.loc?.sta.lin}:${stream[i]?.loc?.sta.col}`,
59
- },
60
- ],
61
- };
62
- }
15
+ // while (
16
+ // i < stream.length &&
17
+ // (stream[i]?.typ === EnumToken.WhitespaceTokenType || stream[i]?.typ === EnumToken.CommentTokenType)
18
+ // ) {
19
+ // tokens.push(stream[i]);
20
+ // i++;
21
+ // }
22
+ // if (i >= stream.length) {
23
+ // success = "else" === context.nam;
24
+ // return {
25
+ // success,
26
+ // errors: success
27
+ // ? []
28
+ // : [
29
+ // {
30
+ // action: "drop",
31
+ // node: stream[i],
32
+ // location: stream[i]?.[LOC],
33
+ // message: `expecting '<boolean-condition>' at ${stream[i]?.[LOC]?.src}:${stream[i]?.[LOC]?.sta.lin}:${stream[i]?.[LOC]?.sta.col}`,
34
+ // },
35
+ // ],
36
+ // };
37
+ // }
38
+ // if (
39
+ // stream[i]?.typ !== EnumToken.WhenElseFunctionTokenDefType &&
40
+ // stream[i]?.typ !== EnumToken.SupportsFunctionTokenDefType &&
41
+ // stream[i]?.typ !== EnumToken.StartParensTokenType &&
42
+ // "val" in stream[i] &&
43
+ // !(
44
+ // stream[i]?.typ === EnumToken.IdenTokenType &&
45
+ // (equalsIgnoreCase((stream[i] as IdentToken).val, "not") ||
46
+ // equalsIgnoreCase((stream[i] as IdentToken).val, "only"))
47
+ // )
48
+ // ) {
49
+ // return {
50
+ // success: false,
51
+ // errors: [
52
+ // {
53
+ // action: "drop",
54
+ // node: stream[i],
55
+ // location: stream[i]?.[LOC],
56
+ // message: `expecting '<boolean-condition>' at ${stream[i]?.[LOC]?.src}:${stream[i]?.[LOC]?.sta.lin}:${stream[i]?.[LOC]?.sta.col}`,
57
+ // },
58
+ // ],
59
+ // };
60
+ // }
63
61
  for (; i < stream.length; i++) {
64
62
  tokens.push(stream[i]);
65
- if (stream[i].typ === EnumToken.StartParensTokenType) {
66
- stack.push(stream[i]);
67
- scopes.push((scope = new Set()));
68
- continue;
69
- }
63
+ // if (stream[i].typ === EnumToken.StartParensTokenType) {
64
+ // stack.push(stream[i]);
65
+ // scopes.push((scope = new Set()));
66
+ // continue;
67
+ // }
70
68
  if (expectAndOr) {
71
69
  let k = i;
72
70
  while (k < stream.length &&
@@ -74,171 +72,179 @@ function matchAtRuleWhenElseSyntax(stream, context, options = {}) {
74
72
  tokens.push(stream[k]);
75
73
  k++;
76
74
  }
77
- if (k < stream.length) {
78
- if (stream[k].typ !== EnumToken.EndParensTokenType &&
79
- !(stream[k].typ === EnumToken.IdenTokenType &&
80
- (equalsIgnoreCase(stream[k].val, "and") || equalsIgnoreCase(stream[k].val, "or")))) {
81
- return {
82
- success: false,
83
- errors: [
84
- {
85
- action: "drop",
86
- node: stream[k],
87
- message: `expecting 'and' or 'or' at ${stream[k]?.loc?.src}:${stream[k]?.loc?.sta.lin}:${stream[k]?.loc?.sta.col}`,
88
- location: stream[k].loc,
89
- },
90
- ],
91
- };
92
- }
93
- }
75
+ // if (k < stream.length) {
76
+ // if (
77
+ // stream[k].typ !== EnumToken.EndParensTokenType &&
78
+ // !(
79
+ // stream[k].typ === EnumToken.IdenTokenType &&
80
+ // (equalsIgnoreCase((stream[k] as IdentToken).val, "and") ||
81
+ // equalsIgnoreCase((stream[k] as IdentToken).val, "or"))
82
+ // )
83
+ // ) {
84
+ // return {
85
+ // success: false,
86
+ // errors: [
87
+ // {
88
+ // action: "drop",
89
+ // node: stream[k],
90
+ // message: `expecting 'and' or 'or' at ${stream[k]?.[LOC]?.src}:${stream[k]?.[LOC]?.sta.lin}:${stream[k]?.[LOC]?.sta.col}`,
91
+ // location: stream[k][LOC],
92
+ // },
93
+ // ],
94
+ // };
95
+ // }
96
+ // }
94
97
  expectAndOr = false;
95
98
  }
96
99
  switch (stream[i].typ) {
97
- case EnumToken.EndParensTokenType:
98
- {
99
- if (stack.length === 0) {
100
- return {
101
- success: false,
102
- errors: [
103
- {
104
- action: "drop",
105
- node: stream[i],
106
- message: `unmatched ')' at ${stream[i]?.loc?.src}:${stream[i]?.loc?.sta.lin}:${stream[i]?.loc?.sta.col}`,
107
- },
108
- ],
109
- };
110
- }
111
- if (stack.at(-1)?.typ === EnumToken.StartParensTokenType) {
112
- const index = tokens.indexOf(stack.at(-1));
113
- const slice = trimArray(tokens.splice(index + 1, tokens.length - index - 2));
114
- const filtered = slice.filter((token) => {
115
- return (token.typ !== EnumToken.WhitespaceTokenType && token.typ !== EnumToken.CommentTokenType);
116
- });
117
- if (filtered.length !== 1 ||
118
- !(validChildTypes.has(filtered[0].typ) ||
119
- tokensfuncDefMap.has(filtered[0].typ) ||
120
- tokensfuncSet.has(filtered[0].typ))) {
121
- const token = filtered[0] ?? slice[0] ?? stream[i];
122
- return {
123
- success: false,
124
- errors: [
125
- {
126
- action: "drop",
127
- node: token,
128
- location: token.loc,
129
- message: `expecting '<boolean-condition"}>' at ${token?.loc?.src}:${token?.loc?.sta.lin}:${token?.loc?.sta.col}`,
130
- },
131
- ],
132
- };
133
- }
134
- tokens[index] = Object.defineProperty({
135
- typ: EnumToken.ParensTokenType,
136
- chi: slice,
137
- }, "loc", {
138
- ...definedPropertySettings,
139
- value: { ...stack.at(-1).loc, end: { ...stream[i]?.loc?.end } },
140
- });
141
- stack.pop();
142
- tokens.pop();
143
- scopes.pop();
144
- scope = scopes[scopes.length - 1];
145
- expectAndOr = true;
146
- }
147
- if (stack.at(-1)?.typ === EnumToken.NotTokenType || stack.at(-1)?.typ === EnumToken.OnlyTokenType) {
148
- const index = tokens.indexOf(stack.at(-1));
149
- tokens[index] = Object.defineProperty({
150
- typ: EnumToken.SupportsQueryUnaryConditionTokenType,
151
- l: stack.at(-1),
152
- r: trimArray(tokens.splice(index + 1, i - index - 1)),
153
- }, "loc", {
154
- ...definedPropertySettings,
155
- value: { ...stack.at(-1).loc, end: { ...stream[i]?.loc?.end } },
156
- });
157
- stack.pop();
158
- }
159
- if (stack.at(-1)?.typ === EnumToken.AndTokenType || stack.at(-1)?.typ === EnumToken.OrTokenType) {
160
- if (stack.length > 1 && stack.at(-2)?.typ !== EnumToken.StartParensTokenType) {
161
- return {
162
- success: false,
163
- errors: [
164
- {
165
- action: "drop",
166
- node: stack.at(-2),
167
- message: `expecting '(' at ${stack.at(-2)?.loc?.src}:${stack.at(-2)?.loc?.sta.lin}:${stack.at(-2)?.loc?.sta.col}`,
168
- },
169
- ],
170
- };
171
- }
172
- const index = tokens.indexOf(stack.at(-1));
173
- const index2 = stack.length > 1 ? tokens.indexOf(stack.at(-2)) + 1 : 0;
174
- const left = trimArray(tokens.slice(index2, index));
175
- const notToken = left.find((t) => t.typ === EnumToken.SupportsQueryUnaryConditionTokenType &&
176
- t.l.typ === EnumToken.NotTokenType);
177
- if (notToken != null) {
178
- return {
179
- success: false,
180
- errors: [
181
- {
182
- action: "drop",
183
- node: stack.at(-1),
184
- message: `unexpected token after 'not' expression at ${stack.at(-1)?.loc?.src}:${stack.at(-1)?.loc?.sta.lin}:${stack.at(-1)?.loc?.sta.col}`,
185
- },
186
- ],
187
- };
188
- }
189
- tokens[index2] = Object.defineProperty({
190
- typ: EnumToken.SupportsQueryConditionTokenType,
191
- op: stack.at(-1),
192
- l: left,
193
- r: trimArray(tokens.slice(index + 1)),
194
- }, "loc", {
195
- ...definedPropertySettings,
196
- value: { ...stack.at(-1).loc, end: { ...stream[i]?.loc?.end } },
197
- });
198
- tokens.length = index2 + 1;
199
- stack.pop();
200
- }
201
- }
202
- break;
100
+ // case EnumToken.EndParensTokenType:
101
+ // {
102
+ // if (stack.length === 0) {
103
+ // return {
104
+ // success: false,
105
+ // errors: [
106
+ // {
107
+ // action: "drop",
108
+ // node: stream[i],
109
+ // message: `unmatched ')' at ${stream[i]?.[LOC]?.src}:${stream[i]?.[LOC]?.sta.lin}:${stream[i]?.[LOC]?.sta.col}`,
110
+ // },
111
+ // ],
112
+ // };
113
+ // }
114
+ // if (stack.at(-1)?.typ === EnumToken.StartParensTokenType) {
115
+ // const index: number = tokens.indexOf(stack.at(-1)!);
116
+ // const slice: Token[] = trimArray(tokens.splice(index + 1, tokens.length - index - 2));
117
+ // const filtered: Token[] = slice.filter((token) => {
118
+ // return (
119
+ // token.typ !== EnumToken.WhitespaceTokenType && token.typ !== EnumToken.CommentTokenType
120
+ // );
121
+ // });
122
+ // if (
123
+ // filtered.length !== 1 ||
124
+ // !(
125
+ // validChildTypes.has(filtered[0].typ) ||
126
+ // tokensfuncDefMap.has(filtered[0].typ) ||
127
+ // tokensfuncSet.has(filtered[0].typ)
128
+ // )
129
+ // ) {
130
+ // const token = filtered[0] ?? slice[0] ?? stream[i];
131
+ // return {
132
+ // success: false,
133
+ // errors: [
134
+ // {
135
+ // action: "drop",
136
+ // node: token,
137
+ // location: token[LOC],
138
+ // message: `expecting '<boolean-condition"}>' at ${token?.[LOC]?.src}:${token?.[LOC]?.sta.lin}:${token?.[LOC]?.sta.col}`,
139
+ // },
140
+ // ],
141
+ // };
142
+ // }
143
+ // tokens[index] = {
144
+ // typ: EnumToken.ParensTokenType,
145
+ // chi: slice,
146
+ // [LOC]: { ...stack.at(-1)![LOC], end: { ...stream[i]?.[LOC]?.end } } as Location,
147
+ // };
148
+ // stack.pop();
149
+ // tokens.pop();
150
+ // scopes.pop();
151
+ // scope = scopes[scopes.length - 1];
152
+ // expectAndOr = true;
153
+ // }
154
+ // if (stack.at(-1)?.typ === EnumToken.NotTokenType || stack.at(-1)?.typ === EnumToken.OnlyTokenType) {
155
+ // const index: number = tokens.indexOf(stack.at(-1)!);
156
+ // tokens[index] = {
157
+ // typ: EnumToken.SupportsQueryUnaryConditionTokenType,
158
+ // l: stack.at(-1),
159
+ // r: trimArray(tokens.splice(index + 1, i - index - 1)),
160
+ // [LOC]: { ...stack.at(-1)![LOC], end: { ...stream[i]?.[LOC]?.end } },
161
+ // } as SupportsQueryUnaryConditionToken;
162
+ // stack.pop();
163
+ // }
164
+ // if (stack.at(-1)?.typ === EnumToken.AndTokenType || stack.at(-1)?.typ === EnumToken.OrTokenType) {
165
+ // if (stack.length > 1 && stack.at(-2)?.typ !== EnumToken.StartParensTokenType) {
166
+ // return {
167
+ // success: false,
168
+ // errors: [
169
+ // {
170
+ // action: "drop",
171
+ // node: stack.at(-2),
172
+ // message: `expecting '(' at ${stack.at(-2)?.[LOC]?.src}:${stack.at(-2)?.[LOC]?.sta.lin}:${stack.at(-2)?.[LOC]?.sta.col}`,
173
+ // },
174
+ // ],
175
+ // };
176
+ // }
177
+ // const index: number = tokens.indexOf(stack.at(-1)!);
178
+ // const index2: number = stack.length > 1 ? tokens.indexOf(stack.at(-2)!) + 1 : 0;
179
+ // const left: Token[] = trimArray(tokens.slice(index2, index));
180
+ // const notToken = left.find(
181
+ // (t) =>
182
+ // t.typ === EnumToken.SupportsQueryUnaryConditionTokenType &&
183
+ // (t as SupportsQueryUnaryConditionToken).l.typ === EnumToken.NotTokenType,
184
+ // );
185
+ // if (notToken != null) {
186
+ // return {
187
+ // success: false,
188
+ // errors: [
189
+ // {
190
+ // action: "drop",
191
+ // node: stack.at(-1),
192
+ // message: `unexpected token after 'not' expression at ${stack.at(-1)?.[LOC]?.src}:${stack.at(-1)?.[LOC]?.sta.lin}:${stack.at(-1)?.[LOC]?.sta.col}`,
193
+ // },
194
+ // ],
195
+ // };
196
+ // }
197
+ // tokens[index2] = {
198
+ // typ: EnumToken.SupportsQueryConditionTokenType,
199
+ // op: stack.at(-1)!,
200
+ // l: left,
201
+ // r: trimArray(tokens.slice(index + 1)),
202
+ // [LOC]: { ...stack.at(-1)![LOC], end: { ...stream[i]?.[LOC]?.end } },
203
+ // } as SupportsQueryConditionToken;
204
+ // tokens.length = index2 + 1;
205
+ // stack.pop();
206
+ // }
207
+ // }
208
+ // break;
203
209
  case EnumToken.IdenTokenType:
204
210
  {
205
211
  const val = stream[i].val.toLowerCase();
206
- if ("not" === val || "only" === val) {
207
- stack.push(stream[i]);
208
- Object.assign(stream[i], {
209
- typ: "only" === val ? EnumToken.OnlyTokenType : EnumToken.NotTokenType,
210
- });
211
- break;
212
- }
212
+ // if ("not" === val || "only" === val) {
213
+ // stack.push(stream[i]);
214
+ // Object.assign(stream[i], {
215
+ // typ: "only" === val ? EnumToken.OnlyTokenType : EnumToken.NotTokenType,
216
+ // });
217
+ // break;
218
+ // }
213
219
  if ("and" === val || "or" === val) {
214
- if (scope.has("or" === val ? EnumToken.AndTokenType : EnumToken.OrTokenType)) {
215
- return {
216
- success: false,
217
- errors: [
218
- {
219
- action: "drop",
220
- message: `mixing <and> and <or> at the same level is not allowed at ${stream[i]?.loc?.src}:${stream[i]?.loc?.sta.lin}:${stream[i]?.loc?.sta.col}`,
221
- },
222
- ],
223
- };
224
- }
225
- if ("or" === val && scopes.length === 1) {
226
- return {
227
- success: false,
228
- errors: [
229
- {
230
- action: "drop",
231
- message: `<or> is not allowed outside of a parenthesis at ${stream[i]?.loc?.src}:${stream[i]?.loc?.sta.lin}:${stream[i]?.loc?.sta.col}`,
232
- },
233
- ],
234
- };
235
- }
220
+ // if (scope.has("or" === val ? EnumToken.AndTokenType : EnumToken.OrTokenType)) {
221
+ // return {
222
+ // success: false,
223
+ // errors: [
224
+ // {
225
+ // action: "drop",
226
+ // message: `mixing <and> and <or> at the same level is not allowed at ${stream[i]?.[LOC]?.src}:${stream[i]?.[LOC]?.sta.lin}:${stream[i]?.[LOC]?.sta.col}`,
227
+ // },
228
+ // ],
229
+ // };
230
+ // }
231
+ // if ("or" === val && scopes.length === 1) {
232
+ // return {
233
+ // success: false,
234
+ // errors: [
235
+ // {
236
+ // action: "drop",
237
+ // message: `<or> is not allowed outside of a parenthesis at ${stream[i]?.[LOC]?.src}:${stream[i]?.[LOC]?.sta.lin}:${stream[i]?.[LOC]?.sta.col}`,
238
+ // },
239
+ // ],
240
+ // };
241
+ // }
236
242
  Object.assign(stream[i], {
237
243
  typ: "or" === val ? EnumToken.OrTokenType : EnumToken.AndTokenType,
238
244
  });
239
245
  scope.add(stream[i].typ);
240
246
  stack.push(stream[i]);
241
- break;
247
+ // break;
242
248
  }
243
249
  }
244
250
  break;
@@ -262,10 +268,11 @@ function matchAtRuleWhenElseSyntax(stream, context, options = {}) {
262
268
  const slice = stream.slice(i, j + 1);
263
269
  const funcName = stream[i].val.toLowerCase();
264
270
  const tokenList = [
265
- Object.defineProperty({ typ: EnumToken.StartParensTokenType }, "loc", {
266
- ...definedPropertySettings,
267
- value: { ...stream[i].loc, end: { ...stream[j]?.loc?.end } },
268
- }),
271
+ {
272
+ typ: EnumToken.StartParensTokenType,
273
+ [LOC]: { ...stream[i][LOC], end: { ...stream[j]?.[LOC]?.end } },
274
+ },
275
+ // @ts-expect-error
269
276
  ].concat(slice.slice(1));
270
277
  if ("media" === funcName) {
271
278
  const result = parseMediaqueryList(tokenList, options);
@@ -286,48 +293,42 @@ function matchAtRuleWhenElseSyntax(stream, context, options = {}) {
286
293
  return result;
287
294
  }
288
295
  }
289
- else {
290
- errors.push({
291
- action: "ignore",
292
- message: `unknown <boolean-condition> function '${funcName}' at ${stream[i]?.loc?.src}:${stream[i]?.loc?.sta.lin}:${stream[i]?.loc?.sta.col}`,
293
- node: stream[i],
294
- location: stream[i].loc,
295
- });
296
- }
297
- Object.defineProperty(Object.assign(stream[i], {
296
+ // else {
297
+ // errors.push({
298
+ // action: "ignore",
299
+ // message: `unknown <boolean-condition> function '${funcName}' at ${stream[i]?.[LOC]?.src}:${stream[i]?.[LOC]?.sta.lin}:${stream[i]?.[LOC]?.sta.col}`,
300
+ // node: stream[i],
301
+ // location: stream[i][LOC],
302
+ // });
303
+ // }
304
+ stream[i][LOC] = { ...stream[i][LOC], end: { ...stream[j]?.[LOC]?.end } };
305
+ Object.assign(stream[i], {
298
306
  typ: tokensfuncDefMap.get(stream[i].typ),
299
307
  chi: stream[i].typ === EnumToken.SupportsFunctionTokenDefType
300
308
  ? trimArray(slice.slice(1, -1))
301
309
  : tokenList[0].chi,
302
- }), "loc", {
303
- ...definedPropertySettings,
304
- value: { ...stream[i].loc, end: { ...stream[j]?.loc?.end } },
305
310
  });
306
- if (stack.at(-1)?.typ === EnumToken.NotTokenType || stack.at(-1)?.typ === EnumToken.OnlyTokenType) {
307
- const index = tokens.indexOf(stack.at(-1));
308
- tokens[index] = Object.defineProperty({
309
- typ: EnumToken.WhenElseUnaryConditionTokenType,
310
- l: stack.at(-1),
311
- r: trimArray(tokens.slice(index + 1)),
312
- }, "loc", {
313
- ...definedPropertySettings,
314
- value: { ...stack.at(-1).loc, end: { ...stream[i]?.loc?.end } },
315
- });
316
- tokens.length = index + 1;
317
- stack.pop();
318
- }
311
+ // if (stack.at(-1)?.typ === EnumToken.NotTokenType || stack.at(-1)?.typ === EnumToken.OnlyTokenType) {
312
+ // const index: number = tokens.indexOf(stack.at(-1)!);
313
+ // tokens[index] = {
314
+ // typ: EnumToken.WhenElseUnaryConditionTokenType,
315
+ // l: stack.at(-1)!,
316
+ // r: trimArray(tokens.slice(index + 1)),
317
+ // [LOC]: { ...stack.at(-1)![LOC], end: { ...stream[i]?.[LOC]?.end } },
318
+ // } as WhenElseUnaryConditionToken;
319
+ // tokens.length = index + 1;
320
+ // stack.pop();
321
+ // }
319
322
  if (stack.at(-1)?.typ === EnumToken.AndTokenType || stack.at(-1)?.typ === EnumToken.OrTokenType) {
320
323
  const index = tokens.indexOf(stack.at(-1));
321
324
  const index2 = stack.length > 1 ? tokens.indexOf(stack.at(-2)) + 1 : 0;
322
- tokens[index2] = Object.defineProperty({
325
+ tokens[index2] = {
323
326
  typ: EnumToken.WhenElseQueryConditionTokenType,
324
327
  op: stack.at(-1),
325
328
  l: trimArray(tokens.slice(index2, index)),
326
329
  r: trimArray(tokens.slice(index + 1)),
327
- }, "loc", {
328
- ...definedPropertySettings,
329
- value: { ...stack.at(-1).loc, end: { ...stream[i]?.loc?.end } },
330
- });
330
+ [LOC]: { ...stack.at(-1)[LOC], end: { ...stream[i]?.[LOC]?.end } },
331
+ };
331
332
  tokens.length = index2 + 1;
332
333
  stack.pop();
333
334
  }
@@ -335,26 +336,22 @@ function matchAtRuleWhenElseSyntax(stream, context, options = {}) {
335
336
  expectAndOr = true;
336
337
  }
337
338
  break;
338
- default:
339
- if (tokensfuncDefMap.has(stream[i].typ)) {
340
- stack.push(stream[i]);
341
- expectAndOr = true;
342
- }
343
- break;
344
339
  }
345
340
  }
346
- if (stack.length > 0) {
347
- return {
348
- success: false,
349
- errors: [
350
- {
351
- action: "drop",
352
- node: stack.at(-1),
353
- message: `unmatched token '${renderValue(stack.at(-1))}' at ${stack.at(-1).loc.src}:${stack.at(-1).loc.sta.lin}:${stack.at(-1).loc.sta.col}`,
354
- },
355
- ],
356
- };
357
- }
341
+ // if (stack.length > 0) {
342
+ // return {
343
+ // success: false,
344
+ // errors: [
345
+ // {
346
+ // action: "drop",
347
+ // node: stack.at(-1),
348
+ // message: `unmatched token '${renderValue(stack.at(-1) as Token)}' at ${stack.at(-1)![LOC]!.src}:${
349
+ // stack.at(-1)![LOC]!.sta.lin
350
+ // }:${stack.at(-1)![LOC]!.sta.col}`,
351
+ // },
352
+ // ],
353
+ // };
354
+ // }
358
355
  stream.length = 0;
359
356
  stream.push(...trimArray(tokens));
360
357
  return { success, errors };