@tbela99/css-parser 1.6.2 → 1.6.4
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/CHANGELOG.md +40 -0
- package/README.md +8 -8
- package/dist/{lib/data → data}/properties.json.js +296 -29
- package/dist/{lib/data → data}/validation.json.js +6 -0
- package/dist/index-umd-web.js +678 -461
- package/dist/index.cjs +678 -461
- package/dist/index.d.ts +9 -4
- package/dist/lib/ast/expand.js +1 -1
- package/dist/lib/ast/features/if.js +1 -1
- package/dist/lib/ast/features/inlinecssvariables.js +1 -1
- package/dist/lib/ast/features/prefix.js +1 -1
- package/dist/lib/ast/features/shorthand.js +10 -5
- package/dist/lib/ast/features/transform.js +1 -1
- package/dist/lib/ast/minify.js +1 -1
- package/dist/lib/ast/transform/utils.js +2 -2
- package/dist/lib/ast/walk.js +108 -90
- package/dist/lib/parser/declaration/list.js +19 -26
- package/dist/lib/parser/declaration/map.js +152 -33
- package/dist/lib/parser/parse.js +7 -7
- package/dist/lib/parser/source.js +2 -2
- package/dist/lib/parser/utils/config.js +1 -1
- package/dist/lib/parser/utils/declaration.js +0 -18
- package/dist/lib/parser/utils/hash.js +10 -5
- package/dist/lib/parser/utils/selector.js +1 -1
- package/dist/lib/{renderer → printer}/render.js +17 -17
- package/dist/lib/syntax/color/lch.js +0 -1
- package/dist/lib/syntax/color/oklch.js +0 -1
- package/dist/lib/syntax/color/xyzd50.js +0 -17
- package/dist/lib/syntax/constants.js +1 -1
- package/dist/lib/validation/config.js +5 -33
- package/dist/lib/validation/match.js +50 -180
- package/dist/node.js +3 -3
- package/dist/web.js +3 -3
- package/package.json +2 -2
- /package/dist/lib/{renderer → printer}/sourcemap/lib/codec.js +0 -0
- /package/dist/lib/{renderer → printer}/sourcemap/sourcemap.js +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -4132,7 +4132,6 @@ declare class LineMap {
|
|
|
4132
4132
|
* Source file helper class
|
|
4133
4133
|
*/
|
|
4134
4134
|
declare class SourceFile {
|
|
4135
|
-
private inputSourceMap;
|
|
4136
4135
|
/**
|
|
4137
4136
|
* Source file ID
|
|
4138
4137
|
*/
|
|
@@ -4149,6 +4148,7 @@ declare class SourceFile {
|
|
|
4149
4148
|
* Source file content
|
|
4150
4149
|
*/
|
|
4151
4150
|
content: string;
|
|
4151
|
+
private inputSourceMap;
|
|
4152
4152
|
/**
|
|
4153
4153
|
* Constructor
|
|
4154
4154
|
* @param content
|
|
@@ -4495,8 +4495,8 @@ interface PropertyType {
|
|
|
4495
4495
|
}
|
|
4496
4496
|
|
|
4497
4497
|
interface SinglePropertyType {
|
|
4498
|
-
|
|
4499
|
-
|
|
4498
|
+
typ: keyof EnumToken;
|
|
4499
|
+
val: string | number;
|
|
4500
4500
|
}
|
|
4501
4501
|
|
|
4502
4502
|
interface SinglePropertyTypeMapping {
|
|
@@ -5011,10 +5011,15 @@ export declare interface WalkerOptions {
|
|
|
5011
5011
|
*/
|
|
5012
5012
|
reverse?: boolean;
|
|
5013
5013
|
|
|
5014
|
+
/**
|
|
5015
|
+
* traverse node children
|
|
5016
|
+
*/
|
|
5017
|
+
children?: boolean;
|
|
5018
|
+
|
|
5014
5019
|
/**
|
|
5015
5020
|
* Traverse node value tokens. If false, only traverse node children
|
|
5016
5021
|
*/
|
|
5017
|
-
|
|
5022
|
+
attributes?: boolean;
|
|
5018
5023
|
/**
|
|
5019
5024
|
* filter function to control the walk
|
|
5020
5025
|
*/
|
package/dist/lib/ast/expand.js
CHANGED
|
@@ -2,7 +2,7 @@ import { splitRule } from './minify.js';
|
|
|
2
2
|
import { STATE, PARENT, combinators, RAW } from '../syntax/constants.js';
|
|
3
3
|
import { parseString } from '../parser/parse.js';
|
|
4
4
|
import { walkValues } from './walk.js';
|
|
5
|
-
import { renderValue } from '../
|
|
5
|
+
import { renderValue } from '../printer/render.js';
|
|
6
6
|
import { EnumAstNodeStatus, EnumToken } from './types.js';
|
|
7
7
|
import { cloneNode } from './clone.js';
|
|
8
8
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EnumToken } from '../types.js';
|
|
2
|
-
import { renderValue } from '../../
|
|
2
|
+
import { renderValue } from '../../printer/render.js';
|
|
3
3
|
import { FeatureWalkMode } from './type.js';
|
|
4
4
|
import { PARENT, LOCSRCID, LOCSTA, LOCEND, TOKENS } from '../../syntax/constants.js';
|
|
5
5
|
import { equalsIgnoreCase } from '../../parser/utils/text.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EnumToken } from '../types.js';
|
|
2
2
|
import { walkValues } from '../walk.js';
|
|
3
|
-
import { renderValue } from '../../
|
|
3
|
+
import { renderValue } from '../../printer/render.js';
|
|
4
4
|
import { splitRule } from '../minify.js';
|
|
5
5
|
import { FeatureWalkMode } from './type.js';
|
|
6
6
|
import { RAW, mathFuncs } from '../../syntax/constants.js';
|
|
@@ -2,7 +2,7 @@ import { EnumAstNodeStatus, EnumToken } from '../types.js';
|
|
|
2
2
|
import { walkValues } from '../walk.js';
|
|
3
3
|
import { pseudoAliasMap } from '../../syntax/syntax.js';
|
|
4
4
|
import { splitRule } from '../minify.js';
|
|
5
|
-
import { renderValue } from '../../
|
|
5
|
+
import { renderValue } from '../../printer/render.js';
|
|
6
6
|
import { STATE, TOKENS, funcLike, regMatchLinearGradient, regMatchRadialGradient } from '../../syntax/constants.js';
|
|
7
7
|
import { FeatureWalkMode } from './type.js';
|
|
8
8
|
import { ValidationSyntaxGroupEnum } from '../../validation/parser/typedef.js';
|
|
@@ -28,8 +28,9 @@ class ComputeShorthandFeature {
|
|
|
28
28
|
const j = ast.chi.length;
|
|
29
29
|
let k = 0;
|
|
30
30
|
let l;
|
|
31
|
-
let properties = new PropertyList(options);
|
|
31
|
+
// let properties: PropertyList = new PropertyList(options);
|
|
32
32
|
const rules = [];
|
|
33
|
+
const declarations = [];
|
|
33
34
|
// @ts-ignore
|
|
34
35
|
for (; k < j; k++) {
|
|
35
36
|
l = k;
|
|
@@ -47,7 +48,8 @@ class ComputeShorthandFeature {
|
|
|
47
48
|
const node = ast.chi[l];
|
|
48
49
|
if (node.typ == EnumToken.DeclarationNodeType) {
|
|
49
50
|
for (let m = k; m <= l; m++) {
|
|
50
|
-
|
|
51
|
+
declarations.push(ast.chi[m]);
|
|
52
|
+
// properties.add(ast.chi![m]);
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
else {
|
|
@@ -57,9 +59,12 @@ class ComputeShorthandFeature {
|
|
|
57
59
|
}
|
|
58
60
|
k = l;
|
|
59
61
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
// console.error([...new PropertyList(options).add(declarations)]);
|
|
63
|
+
if (declarations.length > 0) {
|
|
64
|
+
ast.chi.length = 0;
|
|
65
|
+
// @ts-expect-error
|
|
66
|
+
ast.chi.push(...new PropertyList(options).add(declarations), ...rules);
|
|
67
|
+
}
|
|
63
68
|
return ast;
|
|
64
69
|
}
|
|
65
70
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EnumToken, EnumAstNodeStatus } from '../types.js';
|
|
2
2
|
import { compute } from '../transform/compute.js';
|
|
3
|
-
import { filterValues, renderValue } from '../../
|
|
3
|
+
import { filterValues, renderValue } from '../../printer/render.js';
|
|
4
4
|
import { minifyTransformFunctions, eqMatrix } from '../transform/minify.js';
|
|
5
5
|
import { FeatureWalkMode } from './type.js';
|
|
6
6
|
import { STATE } from '../../syntax/constants.js';
|
package/dist/lib/ast/minify.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { eq } from '../parser/utils/eq.js';
|
|
2
|
-
import { renderValue, doRender } from '../
|
|
2
|
+
import { renderValue, doRender } from '../printer/render.js';
|
|
3
3
|
import * as index from './features/index.js';
|
|
4
4
|
import { walkValues } from './walk.js';
|
|
5
5
|
import { EnumToken } from './types.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { epsilon } from '../../syntax/constants.js';
|
|
2
2
|
|
|
3
|
-
const identityMatrix = new
|
|
3
|
+
const identityMatrix = new Float64Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
|
|
4
4
|
function identity() {
|
|
5
5
|
return identityMatrix.slice();
|
|
6
6
|
}
|
|
@@ -16,7 +16,7 @@ function dot(point1, point2) {
|
|
|
16
16
|
return point1[0] * point2[0] + point1[1] * point2[1] + point1[2] * point2[2];
|
|
17
17
|
}
|
|
18
18
|
function multiply(matrixA, matrixB) {
|
|
19
|
-
const result = new
|
|
19
|
+
const result = new Float64Array(16);
|
|
20
20
|
result[0] = matrixA[0] * matrixB[0] + matrixA[4] * matrixB[1] + matrixA[8] * matrixB[2] + matrixA[12] * matrixB[3];
|
|
21
21
|
result[1] = matrixA[1] * matrixB[0] + matrixA[5] * matrixB[1] + matrixA[9] * matrixB[2] + matrixA[13] * matrixB[3];
|
|
22
22
|
result[2] = matrixA[2] * matrixB[0] + matrixA[6] * matrixB[1] + matrixA[10] * matrixB[2] + matrixA[14] * matrixB[3];
|
package/dist/lib/ast/walk.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TOKENS } from '../syntax/constants.js';
|
|
1
|
+
import { PARENT, TOKENS } from '../syntax/constants.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Options for the walk function
|
|
@@ -114,20 +114,34 @@ var WalkerEvent;
|
|
|
114
114
|
function* walk(node, filter, reverse) {
|
|
115
115
|
const parents = [node];
|
|
116
116
|
const root = node;
|
|
117
|
-
const map = new Map();
|
|
118
117
|
let options = filter;
|
|
119
118
|
let isNumeric = false;
|
|
120
|
-
let
|
|
119
|
+
let children = true;
|
|
120
|
+
let attributes = false;
|
|
121
121
|
let i = 0;
|
|
122
122
|
if (options != null && typeof options == "object") {
|
|
123
123
|
filter = options.filter;
|
|
124
124
|
reverse = options.reverse;
|
|
125
|
-
|
|
125
|
+
attributes = options.attributes;
|
|
126
|
+
children = options.children ?? true;
|
|
126
127
|
}
|
|
128
|
+
// @ts-expect-error
|
|
129
|
+
const result = {
|
|
130
|
+
node: null,
|
|
131
|
+
parent: null,
|
|
132
|
+
root,
|
|
133
|
+
parents: function* () {
|
|
134
|
+
let parent = node[PARENT];
|
|
135
|
+
while (parent != null) {
|
|
136
|
+
yield parent;
|
|
137
|
+
parent = parent[PARENT];
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
};
|
|
127
141
|
while ((node = parents[i++])) {
|
|
128
142
|
let option = null;
|
|
129
143
|
if (filter != null) {
|
|
130
|
-
// @ts-
|
|
144
|
+
// @ts-expect-error
|
|
131
145
|
option = filter(node);
|
|
132
146
|
isNumeric = typeof option == "number";
|
|
133
147
|
if (isNumeric) {
|
|
@@ -140,38 +154,43 @@ function* walk(node, filter, reverse) {
|
|
|
140
154
|
}
|
|
141
155
|
}
|
|
142
156
|
if (!isNumeric || (option & WalkerOptionEnum.Children) === 0) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
root,
|
|
148
|
-
// @ts-expect-error
|
|
149
|
-
parents: function* () {
|
|
150
|
-
let parent = map.get(node);
|
|
151
|
-
while (parent != null) {
|
|
152
|
-
yield parent;
|
|
153
|
-
parent = map.get(parent);
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
|
-
};
|
|
157
|
+
result.node = node;
|
|
158
|
+
// @ts-expect-error
|
|
159
|
+
result.parent = node[PARENT];
|
|
160
|
+
yield result;
|
|
157
161
|
}
|
|
158
|
-
if (
|
|
162
|
+
if (attributes) {
|
|
159
163
|
if (node[TOKENS] != null) {
|
|
160
|
-
// @ts-
|
|
164
|
+
// @ts-expect-error
|
|
161
165
|
parents.splice(i, 0, ...(reverse ? node[TOKENS].toReversed() : node[TOKENS]));
|
|
162
|
-
|
|
166
|
+
for (const child of node[TOKENS]) {
|
|
167
|
+
if (child[PARENT] != node) {
|
|
168
|
+
child[PARENT] = node;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
// @ts-expect-error
|
|
163
172
|
}
|
|
164
173
|
else if (Array.isArray(node.val)) {
|
|
165
|
-
// @ts-
|
|
174
|
+
// @ts-expect-error
|
|
175
|
+
for (const val of node.val) {
|
|
176
|
+
if (val[PARENT] != node) {
|
|
177
|
+
val[PARENT] = node;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
// @ts-expect-error
|
|
166
181
|
parents.splice(i, 0, ...(reverse ? node.val.toReversed() : node.val));
|
|
167
182
|
}
|
|
168
183
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
184
|
+
if (children &&
|
|
185
|
+
// @ts-expect-error
|
|
186
|
+
node["chi"] != null &&
|
|
187
|
+
(!isNumeric || (option & WalkerOptionEnum.IgnoreChildren) === 0)) {
|
|
188
|
+
// @ts-expect-error
|
|
172
189
|
parents.splice(i, 0, ...(reverse ? node.chi.toReversed() : node.chi));
|
|
173
190
|
for (const child of node.chi) {
|
|
174
|
-
|
|
191
|
+
if (child[PARENT] != node) {
|
|
192
|
+
child[PARENT] = node;
|
|
193
|
+
}
|
|
175
194
|
}
|
|
176
195
|
}
|
|
177
196
|
}
|
|
@@ -225,8 +244,6 @@ function* walk(node, filter, reverse) {
|
|
|
225
244
|
*/
|
|
226
245
|
function* walkValues(values, root = null, filter, reverse) {
|
|
227
246
|
const stack = values.slice();
|
|
228
|
-
const map = new Map();
|
|
229
|
-
const used = new Set();
|
|
230
247
|
let previous = null;
|
|
231
248
|
if (filter != null && typeof filter == "function") {
|
|
232
249
|
filter = {
|
|
@@ -243,31 +260,43 @@ function* walkValues(values, root = null, filter, reverse) {
|
|
|
243
260
|
let value;
|
|
244
261
|
let option;
|
|
245
262
|
let node;
|
|
246
|
-
|
|
263
|
+
let i = -1;
|
|
247
264
|
const eventType = filter.event ?? WalkerEvent.Enter;
|
|
248
|
-
|
|
249
|
-
|
|
265
|
+
// @ts-ignore
|
|
266
|
+
const result = {
|
|
267
|
+
value: null,
|
|
268
|
+
parent: null,
|
|
269
|
+
previousValue: null,
|
|
270
|
+
nextValue: null,
|
|
271
|
+
//
|
|
272
|
+
root: root ?? null,
|
|
273
|
+
parents: function* () {
|
|
274
|
+
// @ts-ignore
|
|
275
|
+
let result = root;
|
|
276
|
+
while (result != null) {
|
|
277
|
+
yield result;
|
|
278
|
+
result = result[PARENT] ?? null;
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
};
|
|
282
|
+
while (++i < stack.length) {
|
|
283
|
+
value = stack[i];
|
|
250
284
|
option = null;
|
|
251
|
-
node = map.get(value) ?? null;
|
|
252
|
-
if (used.has(value)) {
|
|
253
|
-
continue;
|
|
254
|
-
}
|
|
255
|
-
used.add(value);
|
|
256
285
|
if (filter.fn != null && eventType & WalkerEvent.Enter) {
|
|
257
286
|
const isValid = filter.type == null ||
|
|
258
287
|
value.typ == filter.type ||
|
|
259
288
|
(Array.isArray(filter.type) && filter.type.includes(value.typ)) ||
|
|
260
289
|
(typeof filter.type == "function" && filter.type(value));
|
|
261
290
|
if (isValid) {
|
|
262
|
-
// @ts-
|
|
263
|
-
option = filter.fn(value,
|
|
291
|
+
// @ts-expect-error
|
|
292
|
+
option = filter.fn(value, value[PARENT] ?? root, WalkerEvent.Enter,
|
|
264
293
|
// @ts-expect-error
|
|
265
294
|
function* () {
|
|
266
295
|
// @ts-expect-error
|
|
267
|
-
let parent =
|
|
296
|
+
let parent = node[PARENT];
|
|
268
297
|
while (parent != null) {
|
|
269
298
|
yield parent;
|
|
270
|
-
parent =
|
|
299
|
+
parent = parent[PARENT] ?? null;
|
|
271
300
|
}
|
|
272
301
|
});
|
|
273
302
|
isNumeric = typeof option == "number";
|
|
@@ -277,48 +306,30 @@ function* walkValues(values, root = null, filter, reverse) {
|
|
|
277
306
|
if (isNumeric && option & WalkerOptionEnum.Ignore) {
|
|
278
307
|
continue;
|
|
279
308
|
}
|
|
280
|
-
//
|
|
309
|
+
//
|
|
281
310
|
if (option != null && typeof option == "object" && ("typ" in option || Array.isArray(option))) {
|
|
282
311
|
const op = Array.isArray(option) ? option : [option];
|
|
312
|
+
stack.splice(i, 0, ...(reverse ? op.toReversed() : op));
|
|
283
313
|
for (const o of op) {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
stack.unshift(o);
|
|
287
|
-
}
|
|
288
|
-
else {
|
|
289
|
-
stack.push(o);
|
|
314
|
+
if (o[PARENT] != value) {
|
|
315
|
+
o[PARENT] = value;
|
|
290
316
|
}
|
|
291
317
|
}
|
|
292
318
|
}
|
|
293
319
|
}
|
|
294
320
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
// @ts-ignore
|
|
301
|
-
root: root ?? null,
|
|
302
|
-
// @ts-expect-error
|
|
303
|
-
parents: function* () {
|
|
304
|
-
// @ts-expect-error
|
|
305
|
-
let result = map.get(node) ?? root;
|
|
306
|
-
let next;
|
|
307
|
-
do {
|
|
308
|
-
yield result;
|
|
309
|
-
next = map.get(result) ?? root;
|
|
310
|
-
if (next == result) {
|
|
311
|
-
break;
|
|
312
|
-
}
|
|
313
|
-
result = next;
|
|
314
|
-
} while (result != null);
|
|
315
|
-
},
|
|
316
|
-
};
|
|
321
|
+
result.value = value;
|
|
322
|
+
result.parent = value[PARENT] ?? root;
|
|
323
|
+
result.previousValue = previous;
|
|
324
|
+
result.nextValue = stack[0] ?? null;
|
|
325
|
+
yield result;
|
|
317
326
|
if (!isNumeric || (option & WalkerOptionEnum.IgnoreChildren) === 0) {
|
|
318
327
|
if ("chi" in value) {
|
|
319
328
|
const sliced = value.chi.slice();
|
|
320
329
|
for (const child of sliced) {
|
|
321
|
-
|
|
330
|
+
if (child[PARENT] != value) {
|
|
331
|
+
child[PARENT] = value;
|
|
332
|
+
}
|
|
322
333
|
if (reverse) {
|
|
323
334
|
stack.unshift(child);
|
|
324
335
|
}
|
|
@@ -330,31 +341,41 @@ function* walkValues(values, root = null, filter, reverse) {
|
|
|
330
341
|
else {
|
|
331
342
|
const values = [];
|
|
332
343
|
if ("l" in value && value.l != null) {
|
|
333
|
-
// @ts-
|
|
344
|
+
// @ts-expect-error
|
|
334
345
|
values.push(value.l);
|
|
335
|
-
// @ts-
|
|
336
|
-
|
|
346
|
+
// @ts-expect-error
|
|
347
|
+
if (value.l[PARENT] != value) {
|
|
348
|
+
// @ts-expect-error
|
|
349
|
+
value.l[PARENT] = value;
|
|
350
|
+
}
|
|
337
351
|
}
|
|
338
352
|
if ("op" in value && typeof value.op == "object") {
|
|
339
|
-
// @ts-
|
|
353
|
+
// @ts-expect-error
|
|
340
354
|
values.push(value.op);
|
|
341
|
-
// @ts-
|
|
342
|
-
|
|
355
|
+
// @ts-expect-error
|
|
356
|
+
if (value.op[PARENT] != value) {
|
|
357
|
+
// @ts-expect-error
|
|
358
|
+
value.op[PARENT] = value;
|
|
359
|
+
}
|
|
343
360
|
}
|
|
344
361
|
if ("r" in value && value.r != null) {
|
|
345
362
|
if (Array.isArray(value.r)) {
|
|
346
363
|
for (const r of value.r) {
|
|
347
|
-
//
|
|
364
|
+
//
|
|
348
365
|
values.push(r);
|
|
349
|
-
|
|
350
|
-
|
|
366
|
+
if (r[PARENT] != value) {
|
|
367
|
+
//
|
|
368
|
+
r[PARENT] = value;
|
|
369
|
+
}
|
|
351
370
|
}
|
|
352
371
|
}
|
|
353
372
|
else {
|
|
354
|
-
//
|
|
373
|
+
//
|
|
355
374
|
values.push(value.r);
|
|
356
|
-
|
|
357
|
-
|
|
375
|
+
if (value.r[PARENT] != value) {
|
|
376
|
+
//
|
|
377
|
+
value.r[PARENT] = value;
|
|
378
|
+
}
|
|
358
379
|
}
|
|
359
380
|
}
|
|
360
381
|
if (values.length > 0) {
|
|
@@ -376,17 +397,14 @@ function* walkValues(values, root = null, filter, reverse) {
|
|
|
376
397
|
(typeof filter.type == "function" && filter.type(value));
|
|
377
398
|
if (isValid) {
|
|
378
399
|
// @ts-ignore
|
|
379
|
-
option = filter.fn(value,
|
|
400
|
+
option = filter.fn(value, value[PARENT], WalkerEvent.Leave);
|
|
380
401
|
// @ts-ignore
|
|
381
402
|
if (option != null && ("typ" in option || Array.isArray(option))) {
|
|
382
403
|
const op = Array.isArray(option) ? option : [option];
|
|
404
|
+
stack.splice(i, 0, ...(reverse ? op.toReversed() : op));
|
|
383
405
|
for (const o of op) {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
stack.unshift(o);
|
|
387
|
-
}
|
|
388
|
-
else {
|
|
389
|
-
stack.push(o);
|
|
406
|
+
if (o[PARENT] != value) {
|
|
407
|
+
o[PARENT] = value;
|
|
390
408
|
}
|
|
391
409
|
}
|
|
392
410
|
}
|
|
@@ -17,14 +17,7 @@ class PropertyList {
|
|
|
17
17
|
this.options = options;
|
|
18
18
|
this.declarations = new Map();
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
// return this.add({
|
|
22
|
-
// typ: EnumToken.DeclarationNodeType,
|
|
23
|
-
// nam,
|
|
24
|
-
// val: Array.isArray(value) ? value : parseString(String(value)),
|
|
25
|
-
// });
|
|
26
|
-
// }
|
|
27
|
-
add(...declarations) {
|
|
20
|
+
add(declarations) {
|
|
28
21
|
let name;
|
|
29
22
|
let syntaxRules = null;
|
|
30
23
|
let result;
|
|
@@ -62,22 +55,8 @@ class PropertyList {
|
|
|
62
55
|
}
|
|
63
56
|
// do not compute shorthand for invalid declarations
|
|
64
57
|
if (declaration[STATE] !== EnumAstNodeStatus.Validated) {
|
|
65
|
-
// const key = objectHash(declaration);
|
|
66
|
-
// if (!this.ketsey.has(key)) {
|
|
67
|
-
// this.ketsey.set(key, [declaration.nam]);
|
|
68
|
-
// console.error(
|
|
69
|
-
// `Adding declaration : ${(<AstDeclaration>declaration).nam} with key : ${key}`
|
|
70
|
-
// )
|
|
71
|
-
// }
|
|
72
|
-
// else {
|
|
73
|
-
// console.error(
|
|
74
|
-
// `Duplicate declaration found: ${(<AstDeclaration>declaration).nam} with key : [ ${key} => ${this.ketsey.get(key)} ]`
|
|
75
|
-
// )
|
|
76
|
-
// console.error(JSON.stringify(toSortedString(declaration)))
|
|
77
|
-
// this.ketsey.get(key).push(declaration.nam);
|
|
78
|
-
// }
|
|
79
58
|
this.declarations.set(objectHash(declaration), declaration);
|
|
80
|
-
|
|
59
|
+
continue;
|
|
81
60
|
}
|
|
82
61
|
let propertyName = declaration.nam;
|
|
83
62
|
let shortHandType;
|
|
@@ -105,15 +84,28 @@ class PropertyList {
|
|
|
105
84
|
// @ts-ignore
|
|
106
85
|
shorthand = config.property[propertyName];
|
|
107
86
|
}
|
|
87
|
+
// console.error({shortHandType, propertyName, config: config.map[propertyName], map: config.map[shorthand].properties[propertyName]});
|
|
108
88
|
// @ts-ignore
|
|
109
89
|
if (shortHandType == "map") {
|
|
90
|
+
let owner = this;
|
|
110
91
|
// @ts-ignore
|
|
111
|
-
|
|
92
|
+
const mapName = config.map[propertyName]?.map ?? config.map[shorthand]?.properties?.[propertyName]?.map;
|
|
93
|
+
if (typeof mapName === "string") {
|
|
94
|
+
if (!this.declarations.has(mapName)) {
|
|
95
|
+
// @ts-ignore
|
|
96
|
+
this.declarations.set(mapName, new PropertyMap(config.map[mapName]));
|
|
97
|
+
}
|
|
98
|
+
owner = this.declarations.get(mapName);
|
|
99
|
+
// console.error({mapName});
|
|
100
|
+
}
|
|
101
|
+
// @ts-ignore
|
|
102
|
+
if (!owner.declarations.has(shorthand)) {
|
|
112
103
|
// @ts-ignore
|
|
113
|
-
|
|
104
|
+
owner.declarations.set(shorthand, new PropertyMap(config.map[shorthand]));
|
|
114
105
|
}
|
|
106
|
+
// console.error({propertyName,mapName, owned: owner == this});
|
|
115
107
|
// @ts-ignore
|
|
116
|
-
|
|
108
|
+
owner.declarations.get(shorthand).add(declaration);
|
|
117
109
|
}
|
|
118
110
|
// @ts-ignore
|
|
119
111
|
else if (shortHandType == "set") {
|
|
@@ -200,6 +192,7 @@ class PropertyList {
|
|
|
200
192
|
[Symbol.iterator]() {
|
|
201
193
|
let iterator = this.declarations.values();
|
|
202
194
|
const iterators = [];
|
|
195
|
+
// console.error(this);
|
|
203
196
|
return {
|
|
204
197
|
next() {
|
|
205
198
|
let value = iterator.next();
|