@tbela99/css-parser 1.6.3 → 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 +13 -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 +676 -459
- package/dist/index.cjs +676 -459
- 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 +15 -15
- 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-umd-web.js
CHANGED
|
@@ -2574,6 +2574,9 @@
|
|
|
2574
2574
|
scale: {
|
|
2575
2575
|
syntax: "none | [ <number> | <percentage> ]{1,3}"
|
|
2576
2576
|
},
|
|
2577
|
+
"scroll-axis-lock": {
|
|
2578
|
+
syntax: "auto | none"
|
|
2579
|
+
},
|
|
2577
2580
|
"scroll-behavior": {
|
|
2578
2581
|
syntax: "auto | smooth"
|
|
2579
2582
|
},
|
|
@@ -2979,6 +2982,9 @@
|
|
|
2979
2982
|
"will-change": {
|
|
2980
2983
|
syntax: "auto | <animateable-feature>#"
|
|
2981
2984
|
},
|
|
2985
|
+
"window-drag": {
|
|
2986
|
+
syntax: "none | move"
|
|
2987
|
+
},
|
|
2982
2988
|
"word-break": {
|
|
2983
2989
|
syntax: "normal | break-all | keep-all | break-word | auto-phrase"
|
|
2984
2990
|
},
|
|
@@ -7050,7 +7056,6 @@
|
|
|
7050
7056
|
return lchToken(values);
|
|
7051
7057
|
}
|
|
7052
7058
|
function lchToken(values) {
|
|
7053
|
-
values[2] = values[2];
|
|
7054
7059
|
const chi = [
|
|
7055
7060
|
{ typ: exports.EnumToken.NumberTokenType, val: values[0] },
|
|
7056
7061
|
{ typ: exports.EnumToken.NumberTokenType, val: values[1] },
|
|
@@ -7174,23 +7179,6 @@
|
|
|
7174
7179
|
return alpha == null ? [l, c, h] : [l, c, h, alpha];
|
|
7175
7180
|
}
|
|
7176
7181
|
|
|
7177
|
-
// export function srgb2xyzd50values(r: number, g: number, b: number, alpha: number | null = null): number[] {
|
|
7178
|
-
// [r, g, b] = srgb2lsrgbvalues(r, g, b);
|
|
7179
|
-
//
|
|
7180
|
-
// const rgb: number[] = [
|
|
7181
|
-
// 0.436065742824811 * r + 0.3851514688337912 * g + 0.14307845442264197 * b,
|
|
7182
|
-
//
|
|
7183
|
-
// 0.22249319175623702 * r + 0.7168870538238823 * g + 0.06061979053616537 * b,
|
|
7184
|
-
//
|
|
7185
|
-
// 0.013923904500943465 * r + 0.09708128566574634 * g + 0.7140993584005155 * b,
|
|
7186
|
-
// ];
|
|
7187
|
-
//
|
|
7188
|
-
// if (alpha != null && alpha != 1) {
|
|
7189
|
-
// rgb.push(alpha);
|
|
7190
|
-
// }
|
|
7191
|
-
//
|
|
7192
|
-
// return rgb;
|
|
7193
|
-
// }
|
|
7194
7182
|
/*
|
|
7195
7183
|
*/
|
|
7196
7184
|
function xyzd502lch(x, y, z, alpha) {
|
|
@@ -7337,7 +7325,6 @@
|
|
|
7337
7325
|
return oklchToken(srgb2oklch(values[0], values[1], values[2], values[3]));
|
|
7338
7326
|
}
|
|
7339
7327
|
function oklchToken(values) {
|
|
7340
|
-
values[2] = values[2];
|
|
7341
7328
|
const chi = [
|
|
7342
7329
|
{ typ: exports.EnumToken.NumberTokenType, val: values[0] },
|
|
7343
7330
|
{ typ: exports.EnumToken.NumberTokenType, val: values[1] },
|
|
@@ -9642,20 +9629,34 @@
|
|
|
9642
9629
|
function* walk(node, filter, reverse) {
|
|
9643
9630
|
const parents = [node];
|
|
9644
9631
|
const root = node;
|
|
9645
|
-
const map = new Map();
|
|
9646
9632
|
let options = filter;
|
|
9647
9633
|
let isNumeric = false;
|
|
9648
|
-
let
|
|
9634
|
+
let children = true;
|
|
9635
|
+
let attributes = false;
|
|
9649
9636
|
let i = 0;
|
|
9650
9637
|
if (options != null && typeof options == "object") {
|
|
9651
9638
|
filter = options.filter;
|
|
9652
9639
|
reverse = options.reverse;
|
|
9653
|
-
|
|
9640
|
+
attributes = options.attributes;
|
|
9641
|
+
children = options.children ?? true;
|
|
9654
9642
|
}
|
|
9643
|
+
// @ts-expect-error
|
|
9644
|
+
const result = {
|
|
9645
|
+
node: null,
|
|
9646
|
+
parent: null,
|
|
9647
|
+
root,
|
|
9648
|
+
parents: function* () {
|
|
9649
|
+
let parent = node[PARENT];
|
|
9650
|
+
while (parent != null) {
|
|
9651
|
+
yield parent;
|
|
9652
|
+
parent = parent[PARENT];
|
|
9653
|
+
}
|
|
9654
|
+
},
|
|
9655
|
+
};
|
|
9655
9656
|
while ((node = parents[i++])) {
|
|
9656
9657
|
let option = null;
|
|
9657
9658
|
if (filter != null) {
|
|
9658
|
-
// @ts-
|
|
9659
|
+
// @ts-expect-error
|
|
9659
9660
|
option = filter(node);
|
|
9660
9661
|
isNumeric = typeof option == "number";
|
|
9661
9662
|
if (isNumeric) {
|
|
@@ -9668,38 +9669,43 @@
|
|
|
9668
9669
|
}
|
|
9669
9670
|
}
|
|
9670
9671
|
if (!isNumeric || (option & exports.WalkerOptionEnum.Children) === 0) {
|
|
9671
|
-
|
|
9672
|
-
|
|
9673
|
-
|
|
9674
|
-
|
|
9675
|
-
root,
|
|
9676
|
-
// @ts-expect-error
|
|
9677
|
-
parents: function* () {
|
|
9678
|
-
let parent = map.get(node);
|
|
9679
|
-
while (parent != null) {
|
|
9680
|
-
yield parent;
|
|
9681
|
-
parent = map.get(parent);
|
|
9682
|
-
}
|
|
9683
|
-
},
|
|
9684
|
-
};
|
|
9672
|
+
result.node = node;
|
|
9673
|
+
// @ts-expect-error
|
|
9674
|
+
result.parent = node[PARENT];
|
|
9675
|
+
yield result;
|
|
9685
9676
|
}
|
|
9686
|
-
if (
|
|
9677
|
+
if (attributes) {
|
|
9687
9678
|
if (node[TOKENS] != null) {
|
|
9688
|
-
// @ts-
|
|
9679
|
+
// @ts-expect-error
|
|
9689
9680
|
parents.splice(i, 0, ...(reverse ? node[TOKENS].toReversed() : node[TOKENS]));
|
|
9690
|
-
|
|
9681
|
+
for (const child of node[TOKENS]) {
|
|
9682
|
+
if (child[PARENT] != node) {
|
|
9683
|
+
child[PARENT] = node;
|
|
9684
|
+
}
|
|
9685
|
+
}
|
|
9686
|
+
// @ts-expect-error
|
|
9691
9687
|
}
|
|
9692
9688
|
else if (Array.isArray(node.val)) {
|
|
9693
|
-
// @ts-
|
|
9689
|
+
// @ts-expect-error
|
|
9690
|
+
for (const val of node.val) {
|
|
9691
|
+
if (val[PARENT] != node) {
|
|
9692
|
+
val[PARENT] = node;
|
|
9693
|
+
}
|
|
9694
|
+
}
|
|
9695
|
+
// @ts-expect-error
|
|
9694
9696
|
parents.splice(i, 0, ...(reverse ? node.val.toReversed() : node.val));
|
|
9695
9697
|
}
|
|
9696
9698
|
}
|
|
9697
|
-
|
|
9698
|
-
|
|
9699
|
-
|
|
9699
|
+
if (children &&
|
|
9700
|
+
// @ts-expect-error
|
|
9701
|
+
node["chi"] != null &&
|
|
9702
|
+
(!isNumeric || (option & exports.WalkerOptionEnum.IgnoreChildren) === 0)) {
|
|
9703
|
+
// @ts-expect-error
|
|
9700
9704
|
parents.splice(i, 0, ...(reverse ? node.chi.toReversed() : node.chi));
|
|
9701
9705
|
for (const child of node.chi) {
|
|
9702
|
-
|
|
9706
|
+
if (child[PARENT] != node) {
|
|
9707
|
+
child[PARENT] = node;
|
|
9708
|
+
}
|
|
9703
9709
|
}
|
|
9704
9710
|
}
|
|
9705
9711
|
}
|
|
@@ -9753,8 +9759,6 @@
|
|
|
9753
9759
|
*/
|
|
9754
9760
|
function* walkValues(values, root = null, filter, reverse) {
|
|
9755
9761
|
const stack = values.slice();
|
|
9756
|
-
const map = new Map();
|
|
9757
|
-
const used = new Set();
|
|
9758
9762
|
let previous = null;
|
|
9759
9763
|
if (filter != null && typeof filter == "function") {
|
|
9760
9764
|
filter = {
|
|
@@ -9771,31 +9775,43 @@
|
|
|
9771
9775
|
let value;
|
|
9772
9776
|
let option;
|
|
9773
9777
|
let node;
|
|
9774
|
-
|
|
9778
|
+
let i = -1;
|
|
9775
9779
|
const eventType = filter.event ?? exports.WalkerEvent.Enter;
|
|
9776
|
-
|
|
9777
|
-
|
|
9780
|
+
// @ts-ignore
|
|
9781
|
+
const result = {
|
|
9782
|
+
value: null,
|
|
9783
|
+
parent: null,
|
|
9784
|
+
previousValue: null,
|
|
9785
|
+
nextValue: null,
|
|
9786
|
+
//
|
|
9787
|
+
root: root ?? null,
|
|
9788
|
+
parents: function* () {
|
|
9789
|
+
// @ts-ignore
|
|
9790
|
+
let result = root;
|
|
9791
|
+
while (result != null) {
|
|
9792
|
+
yield result;
|
|
9793
|
+
result = result[PARENT] ?? null;
|
|
9794
|
+
}
|
|
9795
|
+
},
|
|
9796
|
+
};
|
|
9797
|
+
while (++i < stack.length) {
|
|
9798
|
+
value = stack[i];
|
|
9778
9799
|
option = null;
|
|
9779
|
-
node = map.get(value) ?? null;
|
|
9780
|
-
if (used.has(value)) {
|
|
9781
|
-
continue;
|
|
9782
|
-
}
|
|
9783
|
-
used.add(value);
|
|
9784
9800
|
if (filter.fn != null && eventType & exports.WalkerEvent.Enter) {
|
|
9785
9801
|
const isValid = filter.type == null ||
|
|
9786
9802
|
value.typ == filter.type ||
|
|
9787
9803
|
(Array.isArray(filter.type) && filter.type.includes(value.typ)) ||
|
|
9788
9804
|
(typeof filter.type == "function" && filter.type(value));
|
|
9789
9805
|
if (isValid) {
|
|
9790
|
-
// @ts-
|
|
9791
|
-
option = filter.fn(value,
|
|
9806
|
+
// @ts-expect-error
|
|
9807
|
+
option = filter.fn(value, value[PARENT] ?? root, exports.WalkerEvent.Enter,
|
|
9792
9808
|
// @ts-expect-error
|
|
9793
9809
|
function* () {
|
|
9794
9810
|
// @ts-expect-error
|
|
9795
|
-
let parent =
|
|
9811
|
+
let parent = node[PARENT];
|
|
9796
9812
|
while (parent != null) {
|
|
9797
9813
|
yield parent;
|
|
9798
|
-
parent =
|
|
9814
|
+
parent = parent[PARENT] ?? null;
|
|
9799
9815
|
}
|
|
9800
9816
|
});
|
|
9801
9817
|
isNumeric = typeof option == "number";
|
|
@@ -9805,48 +9821,30 @@
|
|
|
9805
9821
|
if (isNumeric && option & exports.WalkerOptionEnum.Ignore) {
|
|
9806
9822
|
continue;
|
|
9807
9823
|
}
|
|
9808
|
-
//
|
|
9824
|
+
//
|
|
9809
9825
|
if (option != null && typeof option == "object" && ("typ" in option || Array.isArray(option))) {
|
|
9810
9826
|
const op = Array.isArray(option) ? option : [option];
|
|
9827
|
+
stack.splice(i, 0, ...(reverse ? op.toReversed() : op));
|
|
9811
9828
|
for (const o of op) {
|
|
9812
|
-
|
|
9813
|
-
|
|
9814
|
-
stack.unshift(o);
|
|
9815
|
-
}
|
|
9816
|
-
else {
|
|
9817
|
-
stack.push(o);
|
|
9829
|
+
if (o[PARENT] != value) {
|
|
9830
|
+
o[PARENT] = value;
|
|
9818
9831
|
}
|
|
9819
9832
|
}
|
|
9820
9833
|
}
|
|
9821
9834
|
}
|
|
9822
9835
|
}
|
|
9823
|
-
|
|
9824
|
-
|
|
9825
|
-
|
|
9826
|
-
|
|
9827
|
-
|
|
9828
|
-
// @ts-ignore
|
|
9829
|
-
root: root ?? null,
|
|
9830
|
-
// @ts-expect-error
|
|
9831
|
-
parents: function* () {
|
|
9832
|
-
// @ts-expect-error
|
|
9833
|
-
let result = map.get(node) ?? root;
|
|
9834
|
-
let next;
|
|
9835
|
-
do {
|
|
9836
|
-
yield result;
|
|
9837
|
-
next = map.get(result) ?? root;
|
|
9838
|
-
if (next == result) {
|
|
9839
|
-
break;
|
|
9840
|
-
}
|
|
9841
|
-
result = next;
|
|
9842
|
-
} while (result != null);
|
|
9843
|
-
},
|
|
9844
|
-
};
|
|
9836
|
+
result.value = value;
|
|
9837
|
+
result.parent = value[PARENT] ?? root;
|
|
9838
|
+
result.previousValue = previous;
|
|
9839
|
+
result.nextValue = stack[0] ?? null;
|
|
9840
|
+
yield result;
|
|
9845
9841
|
if (!isNumeric || (option & exports.WalkerOptionEnum.IgnoreChildren) === 0) {
|
|
9846
9842
|
if ("chi" in value) {
|
|
9847
9843
|
const sliced = value.chi.slice();
|
|
9848
9844
|
for (const child of sliced) {
|
|
9849
|
-
|
|
9845
|
+
if (child[PARENT] != value) {
|
|
9846
|
+
child[PARENT] = value;
|
|
9847
|
+
}
|
|
9850
9848
|
if (reverse) {
|
|
9851
9849
|
stack.unshift(child);
|
|
9852
9850
|
}
|
|
@@ -9858,31 +9856,41 @@
|
|
|
9858
9856
|
else {
|
|
9859
9857
|
const values = [];
|
|
9860
9858
|
if ("l" in value && value.l != null) {
|
|
9861
|
-
// @ts-
|
|
9859
|
+
// @ts-expect-error
|
|
9862
9860
|
values.push(value.l);
|
|
9863
|
-
// @ts-
|
|
9864
|
-
|
|
9861
|
+
// @ts-expect-error
|
|
9862
|
+
if (value.l[PARENT] != value) {
|
|
9863
|
+
// @ts-expect-error
|
|
9864
|
+
value.l[PARENT] = value;
|
|
9865
|
+
}
|
|
9865
9866
|
}
|
|
9866
9867
|
if ("op" in value && typeof value.op == "object") {
|
|
9867
|
-
// @ts-
|
|
9868
|
+
// @ts-expect-error
|
|
9868
9869
|
values.push(value.op);
|
|
9869
|
-
// @ts-
|
|
9870
|
-
|
|
9870
|
+
// @ts-expect-error
|
|
9871
|
+
if (value.op[PARENT] != value) {
|
|
9872
|
+
// @ts-expect-error
|
|
9873
|
+
value.op[PARENT] = value;
|
|
9874
|
+
}
|
|
9871
9875
|
}
|
|
9872
9876
|
if ("r" in value && value.r != null) {
|
|
9873
9877
|
if (Array.isArray(value.r)) {
|
|
9874
9878
|
for (const r of value.r) {
|
|
9875
|
-
//
|
|
9879
|
+
//
|
|
9876
9880
|
values.push(r);
|
|
9877
|
-
|
|
9878
|
-
|
|
9881
|
+
if (r[PARENT] != value) {
|
|
9882
|
+
//
|
|
9883
|
+
r[PARENT] = value;
|
|
9884
|
+
}
|
|
9879
9885
|
}
|
|
9880
9886
|
}
|
|
9881
9887
|
else {
|
|
9882
|
-
//
|
|
9888
|
+
//
|
|
9883
9889
|
values.push(value.r);
|
|
9884
|
-
|
|
9885
|
-
|
|
9890
|
+
if (value.r[PARENT] != value) {
|
|
9891
|
+
//
|
|
9892
|
+
value.r[PARENT] = value;
|
|
9893
|
+
}
|
|
9886
9894
|
}
|
|
9887
9895
|
}
|
|
9888
9896
|
if (values.length > 0) {
|
|
@@ -9904,17 +9912,14 @@
|
|
|
9904
9912
|
(typeof filter.type == "function" && filter.type(value));
|
|
9905
9913
|
if (isValid) {
|
|
9906
9914
|
// @ts-ignore
|
|
9907
|
-
option = filter.fn(value,
|
|
9915
|
+
option = filter.fn(value, value[PARENT], exports.WalkerEvent.Leave);
|
|
9908
9916
|
// @ts-ignore
|
|
9909
9917
|
if (option != null && ("typ" in option || Array.isArray(option))) {
|
|
9910
9918
|
const op = Array.isArray(option) ? option : [option];
|
|
9919
|
+
stack.splice(i, 0, ...(reverse ? op.toReversed() : op));
|
|
9911
9920
|
for (const o of op) {
|
|
9912
|
-
|
|
9913
|
-
|
|
9914
|
-
stack.unshift(o);
|
|
9915
|
-
}
|
|
9916
|
-
else {
|
|
9917
|
-
stack.push(o);
|
|
9921
|
+
if (o[PARENT] != value) {
|
|
9922
|
+
o[PARENT] = value;
|
|
9918
9923
|
}
|
|
9919
9924
|
}
|
|
9920
9925
|
}
|
|
@@ -12039,52 +12044,24 @@
|
|
|
12039
12044
|
// @ts-expect-error
|
|
12040
12045
|
return config$4;
|
|
12041
12046
|
}
|
|
12042
|
-
// export const getSyntax = memoize((group: ValidationSyntaxGroupEnum, key: string | string[]): null | string => {
|
|
12043
|
-
// // @ts-expect-error
|
|
12044
|
-
// let obj = config[group] as Record<ValidationSyntaxGroupEnum, ValidationSyntaxNode>;
|
|
12045
|
-
//
|
|
12046
|
-
// const keys: string[] = Array.isArray(key) ? key : [key];
|
|
12047
|
-
//
|
|
12048
|
-
// for (let i = 0; i < keys.length; i++) {
|
|
12049
|
-
// key = keys[i];
|
|
12050
|
-
//
|
|
12051
|
-
// if (!(key in obj)) {
|
|
12052
|
-
// if ((i == 0 && key.charAt(0) == "@") || key.charAt(0) == "-") {
|
|
12053
|
-
// const matches: RegExpMatchArray = key.match(/^(@?)(-[a-zA-Z]+)-(.*?)$/) as RegExpMatchArray;
|
|
12054
|
-
//
|
|
12055
|
-
// if (matches != null) {
|
|
12056
|
-
// key = matches[1] + matches[3];
|
|
12057
|
-
// }
|
|
12058
|
-
// }
|
|
12059
|
-
// }
|
|
12060
|
-
//
|
|
12061
|
-
// // @ts-expect-error
|
|
12062
|
-
// obj = obj[key];
|
|
12063
|
-
// }
|
|
12064
|
-
//
|
|
12065
|
-
// // @ts-expect-error
|
|
12066
|
-
// return obj?.syntax ?? null;
|
|
12067
|
-
// }) as (group: ValidationSyntaxGroupEnum, key: string | string[]) => null | string;
|
|
12068
12047
|
function findNode(group, key) {
|
|
12069
12048
|
// @ts-expect-error
|
|
12070
12049
|
let obj = config$4[group];
|
|
12071
|
-
//
|
|
12072
|
-
|
|
12073
|
-
// key = keys[i];
|
|
12074
|
-
if (!(key in obj)) {
|
|
12050
|
+
// @ts-expect-error
|
|
12051
|
+
if (obj[key] == null) {
|
|
12075
12052
|
if (key.charAt(0) == "@" || key.charAt(0) == "-") {
|
|
12076
12053
|
const matches = key.match(/^(@?)(-[a-zA-Z]+)-(.*?)$/);
|
|
12077
12054
|
if (matches != null) {
|
|
12078
12055
|
key = matches[1] + matches[3];
|
|
12079
12056
|
}
|
|
12080
12057
|
}
|
|
12081
|
-
|
|
12058
|
+
// @ts-expect-error
|
|
12059
|
+
if (obj[key] == null) {
|
|
12082
12060
|
return null;
|
|
12083
12061
|
}
|
|
12084
12062
|
}
|
|
12085
12063
|
// @ts-expect-error
|
|
12086
12064
|
obj = obj[key];
|
|
12087
|
-
// }
|
|
12088
12065
|
return obj;
|
|
12089
12066
|
}
|
|
12090
12067
|
const getParsedSyntax = memoize((group, key) => {
|
|
@@ -12195,6 +12172,20 @@
|
|
|
12195
12172
|
const config$3 = getSyntaxConfig();
|
|
12196
12173
|
// @ts-expect-error
|
|
12197
12174
|
const allValues = config$3.declarations.all.syntax.split(/[\s|]+/g);
|
|
12175
|
+
const selectorNodeTypes = [
|
|
12176
|
+
exports.EnumToken.CommaTokenType,
|
|
12177
|
+
exports.EnumToken.ColumnCombinatorTokenType,
|
|
12178
|
+
exports.EnumToken.ChildCombinatorTokenType,
|
|
12179
|
+
exports.EnumToken.NextSiblingCombinatorTokenType,
|
|
12180
|
+
exports.EnumToken.SubsequentSiblingCombinatorTokenType,
|
|
12181
|
+
];
|
|
12182
|
+
const trimWhitespaceBefore = selectorNodeTypes.concat(exports.EnumToken.DelimTokenType, exports.EnumToken.DashMatchTokenType, exports.EnumToken.IncludeMatchTokenType, exports.EnumToken.ContainMatchTokenType, exports.EnumToken.StartMatchTokenType, exports.EnumToken.EndMatchTokenType, exports.EnumToken.AttrEndTokenType);
|
|
12183
|
+
const trimWhitespaceAfter = selectorNodeTypes.concat(exports.EnumToken.DelimTokenType, exports.EnumToken.DashMatchTokenType, exports.EnumToken.IncludeMatchTokenType, exports.EnumToken.ContainMatchTokenType, exports.EnumToken.StartMatchTokenType, exports.EnumToken.EndMatchTokenType, exports.EnumToken.AttrStartTokenType);
|
|
12184
|
+
const selectorEnumMap = new Map([
|
|
12185
|
+
[exports.EnumToken.Tilda, exports.EnumToken.SubsequentSiblingCombinatorTokenType],
|
|
12186
|
+
[exports.EnumToken.GtTokenType, exports.EnumToken.ChildCombinatorTokenType],
|
|
12187
|
+
]);
|
|
12188
|
+
const propertyKeywordValues = new Map();
|
|
12198
12189
|
/**
|
|
12199
12190
|
* @type {Array.<EnumToken>}
|
|
12200
12191
|
*/
|
|
@@ -12418,24 +12409,6 @@
|
|
|
12418
12409
|
getRemainingTokens() {
|
|
12419
12410
|
return this.tokens.slice(this.index + 1);
|
|
12420
12411
|
},
|
|
12421
|
-
// last() {
|
|
12422
|
-
// let index: number = this.tokens.length - 1;
|
|
12423
|
-
// let token: Token = this.tokens[index];
|
|
12424
|
-
// while (
|
|
12425
|
-
// (this.index >= 0 && token?.typ === EnumToken.WhitespaceTokenType) ||
|
|
12426
|
-
// token?.typ === EnumToken.CommentTokenType ||
|
|
12427
|
-
// token?.typ === EnumToken.CDOCOMMTokenType ||
|
|
12428
|
-
// token?.typ === EnumToken.InvalidCommentTokenType ||
|
|
12429
|
-
// token?.typ === EnumToken.BadCommentTokenType ||
|
|
12430
|
-
// token?.typ === EnumToken.BadStringTokenType
|
|
12431
|
-
// ) {
|
|
12432
|
-
// token = this.tokens[--index];
|
|
12433
|
-
// if (token == null) {
|
|
12434
|
-
// break;
|
|
12435
|
-
// }
|
|
12436
|
-
// }
|
|
12437
|
-
// return token;
|
|
12438
|
-
// },
|
|
12439
12412
|
end() {
|
|
12440
12413
|
this.index = this.tokens.length + 1;
|
|
12441
12414
|
return this;
|
|
@@ -12495,19 +12468,6 @@
|
|
|
12495
12468
|
function matchSelectorSyntax(stream, errors, options, nested = true) {
|
|
12496
12469
|
const stack = [];
|
|
12497
12470
|
const tokens = [];
|
|
12498
|
-
const nodes = [
|
|
12499
|
-
exports.EnumToken.CommaTokenType,
|
|
12500
|
-
exports.EnumToken.ColumnCombinatorTokenType,
|
|
12501
|
-
exports.EnumToken.ChildCombinatorTokenType,
|
|
12502
|
-
exports.EnumToken.NextSiblingCombinatorTokenType,
|
|
12503
|
-
exports.EnumToken.SubsequentSiblingCombinatorTokenType,
|
|
12504
|
-
];
|
|
12505
|
-
const trimWhitespaceBefore = nodes.concat(exports.EnumToken.DelimTokenType, exports.EnumToken.DashMatchTokenType, exports.EnumToken.IncludeMatchTokenType, exports.EnumToken.ContainMatchTokenType, exports.EnumToken.StartMatchTokenType, exports.EnumToken.EndMatchTokenType, exports.EnumToken.AttrEndTokenType);
|
|
12506
|
-
const trimWhitespaceAfter = nodes.concat(exports.EnumToken.DelimTokenType, exports.EnumToken.DashMatchTokenType, exports.EnumToken.IncludeMatchTokenType, exports.EnumToken.ContainMatchTokenType, exports.EnumToken.StartMatchTokenType, exports.EnumToken.EndMatchTokenType, exports.EnumToken.AttrStartTokenType);
|
|
12507
|
-
const enumMap = new Map([
|
|
12508
|
-
[exports.EnumToken.Tilda, exports.EnumToken.SubsequentSiblingCombinatorTokenType],
|
|
12509
|
-
[exports.EnumToken.GtTokenType, exports.EnumToken.ChildCombinatorTokenType],
|
|
12510
|
-
]);
|
|
12511
12471
|
let token;
|
|
12512
12472
|
let i = 0;
|
|
12513
12473
|
let success = true;
|
|
@@ -12547,15 +12507,15 @@
|
|
|
12547
12507
|
}
|
|
12548
12508
|
tokens.push(token);
|
|
12549
12509
|
if (tokensfuncDefMap.has(token.typ)) {
|
|
12550
|
-
if (stack.length > 0 &&
|
|
12510
|
+
if (stack.length > 0 && selectorNodeTypes.includes(stack.at(-1).typ)) {
|
|
12551
12511
|
stack.pop();
|
|
12552
12512
|
}
|
|
12553
12513
|
stack.push(token);
|
|
12554
12514
|
continue;
|
|
12555
12515
|
}
|
|
12556
12516
|
if (stack.length > 0 &&
|
|
12557
|
-
|
|
12558
|
-
!
|
|
12517
|
+
selectorNodeTypes.includes(stack.at(-1).typ) &&
|
|
12518
|
+
!selectorNodeTypes.includes(token.typ) &&
|
|
12559
12519
|
token.typ !== exports.EnumToken.WhitespaceTokenType &&
|
|
12560
12520
|
token.typ !== exports.EnumToken.CommentTokenType &&
|
|
12561
12521
|
token.typ !== exports.EnumToken.CDOCOMMTokenType) {
|
|
@@ -12601,7 +12561,7 @@
|
|
|
12601
12561
|
break;
|
|
12602
12562
|
case exports.EnumToken.Tilda:
|
|
12603
12563
|
case exports.EnumToken.GtTokenType:
|
|
12604
|
-
Object.assign(token, { typ:
|
|
12564
|
+
Object.assign(token, { typ: selectorEnumMap.get(token.typ) });
|
|
12605
12565
|
case exports.EnumToken.ColumnCombinatorTokenType:
|
|
12606
12566
|
case exports.EnumToken.ChildCombinatorTokenType:
|
|
12607
12567
|
case exports.EnumToken.UniversalSelectorTokenType:
|
|
@@ -12614,7 +12574,7 @@
|
|
|
12614
12574
|
if (stack.length > 0 && stack.at(-1)?.typ === exports.EnumToken.UniversalSelectorTokenType) {
|
|
12615
12575
|
stack.pop();
|
|
12616
12576
|
}
|
|
12617
|
-
if (stack.length > 0 &&
|
|
12577
|
+
if (stack.length > 0 && selectorNodeTypes.includes(stack.at(-1)?.typ)) {
|
|
12618
12578
|
return {
|
|
12619
12579
|
success: false,
|
|
12620
12580
|
errors: [
|
|
@@ -12724,106 +12684,10 @@
|
|
|
12724
12684
|
};
|
|
12725
12685
|
}
|
|
12726
12686
|
slice.shift();
|
|
12727
|
-
// if (slice.length > 0) {
|
|
12728
|
-
// return {
|
|
12729
|
-
// success: false,
|
|
12730
|
-
// errors: [
|
|
12731
|
-
// {
|
|
12732
|
-
// action: "drop",
|
|
12733
|
-
// message: `Unexpected token ${EnumToken[slice[0].typ]} at ${slice[0][LOC]!.src}:${slice[0][LOCSTA].lin}:${
|
|
12734
|
-
// slice[0][LOCSTA].col
|
|
12735
|
-
// }`,
|
|
12736
|
-
// node: slice[0],
|
|
12737
|
-
// location: slice[0][LOC],
|
|
12738
|
-
// },
|
|
12739
|
-
// ],
|
|
12740
|
-
// };
|
|
12741
|
-
// }
|
|
12742
12687
|
stack.pop();
|
|
12743
12688
|
break;
|
|
12744
12689
|
}
|
|
12745
|
-
// case EnumToken.ColonTokenType:
|
|
12746
|
-
// if (stream[i + 1]?.typ === EnumToken.IdenTokenType) {
|
|
12747
|
-
// Object.assign(token, {
|
|
12748
|
-
// typ:
|
|
12749
|
-
// (stream[i + 1] as IdentToken).val === "page"
|
|
12750
|
-
// ? EnumToken.PseudoPageTokenType
|
|
12751
|
-
// : pseudoElements.includes((token as PseudoElementToken).val)
|
|
12752
|
-
// ? EnumToken.PseudoElementTokenType
|
|
12753
|
-
// : EnumToken.PseudoClassTokenType,
|
|
12754
|
-
// val: ":" + (stream[i + 1] as IdentToken).val,
|
|
12755
|
-
// });
|
|
12756
|
-
// token[LOC]!.end = stream[++i][LOC]!.end;
|
|
12757
|
-
// break;
|
|
12758
|
-
// } else if (stream[i + 1]?.typ === EnumToken.FunctionTokenDefType) {
|
|
12759
|
-
// Object.assign(token, {
|
|
12760
|
-
// typ: EnumToken.PseudoClassFunctionTokenDefType,
|
|
12761
|
-
// val: ":" + (stream[i + 1] as IdentToken).val,
|
|
12762
|
-
// });
|
|
12763
|
-
// token[LOC]!.end = stream[++i][LOC]!.end;
|
|
12764
|
-
// stack.push(token);
|
|
12765
|
-
// break;
|
|
12766
|
-
// }
|
|
12767
|
-
// return {
|
|
12768
|
-
// success: false,
|
|
12769
|
-
// errors: [
|
|
12770
|
-
// {
|
|
12771
|
-
// action: "drop",
|
|
12772
|
-
// message: `Unexpected token ${EnumToken[token.typ]} at ${token[LOC]!.src}:${token[LOCSTA].lin}:${
|
|
12773
|
-
// token[LOCSTA].col
|
|
12774
|
-
// }`,
|
|
12775
|
-
// node: token,
|
|
12776
|
-
// location: token[LOC],
|
|
12777
|
-
// },
|
|
12778
|
-
// ],
|
|
12779
|
-
// };
|
|
12780
|
-
// case EnumToken.DoubleColonTokenType:
|
|
12781
|
-
// if (stream[i + 1]?.typ === EnumToken.IdenTokenType) {
|
|
12782
|
-
// Object.assign(token, {
|
|
12783
|
-
// typ:
|
|
12784
|
-
// (stream[i + 1] as IdentToken).val === "page"
|
|
12785
|
-
// ? EnumToken.PseudoPageTokenType
|
|
12786
|
-
// : EnumToken.PseudoElementTokenType,
|
|
12787
|
-
// val: "::" + (stream[i + 1] as IdentToken).val,
|
|
12788
|
-
// });
|
|
12789
|
-
// token[LOC]!.end = stream[++i][LOC]!.end;
|
|
12790
|
-
// break;
|
|
12791
|
-
// } else if (stream[i + 1]?.typ === EnumToken.FunctionTokenDefType) {
|
|
12792
|
-
// Object.assign(token, {
|
|
12793
|
-
// typ: EnumToken.PseudoClassFunctionTokenDefType,
|
|
12794
|
-
// val: "::" + (stream[i + 1] as IdentToken).val,
|
|
12795
|
-
// });
|
|
12796
|
-
// token[LOC]!.end = stream[++i][LOC]!.end;
|
|
12797
|
-
// stack.push(token);
|
|
12798
|
-
// break;
|
|
12799
|
-
// }
|
|
12800
|
-
// return {
|
|
12801
|
-
// success: false,
|
|
12802
|
-
// errors: [
|
|
12803
|
-
// {
|
|
12804
|
-
// action: "drop",
|
|
12805
|
-
// message: `Unexpected token ${EnumToken[token.typ]} at ${token[LOC]!.src}:${token[LOCSTA].lin}:${
|
|
12806
|
-
// token[LOCSTA].col
|
|
12807
|
-
// }`,
|
|
12808
|
-
// node: token,
|
|
12809
|
-
// location: token[LOC],
|
|
12810
|
-
// },
|
|
12811
|
-
// ],
|
|
12812
|
-
// };
|
|
12813
12690
|
case exports.EnumToken.StartParensTokenType:
|
|
12814
|
-
// if (
|
|
12815
|
-
// tokens.at(-2)?.typ === EnumToken.PseudoClassTokenType ||
|
|
12816
|
-
// tokens.at(-2)?.typ === EnumToken.PseudoElementTokenType
|
|
12817
|
-
// ) {
|
|
12818
|
-
// stack.push(
|
|
12819
|
-
// Object.assign(tokens.at(-2) as Token, {
|
|
12820
|
-
// typ: EnumToken.PseudoClassFunctionTokenDefType,
|
|
12821
|
-
// chi: [],
|
|
12822
|
-
// }),
|
|
12823
|
-
// );
|
|
12824
|
-
// // tokens.pop();
|
|
12825
|
-
// break;
|
|
12826
|
-
// }
|
|
12827
12691
|
return {
|
|
12828
12692
|
success: false,
|
|
12829
12693
|
errors: [
|
|
@@ -12843,19 +12707,6 @@
|
|
|
12843
12707
|
if (stack.at(-1)?.typ === exports.EnumToken.PseudoClassFunctionTokenDefType ||
|
|
12844
12708
|
stack.at(-1)?.typ === exports.EnumToken.PseudoElementTokenType) {
|
|
12845
12709
|
const token = stack.at(-1);
|
|
12846
|
-
// if (!((stack.at(-1) as PseudoClassFunctionToken).val + "()" in config.selectors)) {
|
|
12847
|
-
// return {
|
|
12848
|
-
// errors: [
|
|
12849
|
-
// {
|
|
12850
|
-
// action: "drop",
|
|
12851
|
-
// message: `Unknown class element ${(token as PseudoElementToken).val}`,
|
|
12852
|
-
// node: token,
|
|
12853
|
-
// location: token[LOC]!,
|
|
12854
|
-
// },
|
|
12855
|
-
// ],
|
|
12856
|
-
// success: false,
|
|
12857
|
-
// };
|
|
12858
|
-
// }
|
|
12859
12710
|
const index = tokens.indexOf(token);
|
|
12860
12711
|
const result = matchAllSyntaxes(getParsedSyntax(ValidationSyntaxGroupEnum.Selectors, token.val + "()")?.[0]?.chi ?? [], createValidationContext(tokens.slice(index + 1, tokens.length - 1)), options);
|
|
12861
12712
|
if (!result.success) {
|
|
@@ -12995,6 +12846,7 @@
|
|
|
12995
12846
|
let tmpResult;
|
|
12996
12847
|
let count = 0;
|
|
12997
12848
|
let range;
|
|
12849
|
+
let done = false;
|
|
12998
12850
|
success = false;
|
|
12999
12851
|
do {
|
|
13000
12852
|
range = context.peekRange(exports.EnumToken.CommaTokenType, exports.EnumToken.CommaTokenType, 1);
|
|
@@ -13010,12 +12862,9 @@
|
|
|
13010
12862
|
else {
|
|
13011
12863
|
context.update(range.at(-1));
|
|
13012
12864
|
}
|
|
13013
|
-
|
|
13014
|
-
// context.end();
|
|
13015
|
-
break;
|
|
13016
|
-
}
|
|
12865
|
+
done = context.done();
|
|
13017
12866
|
}
|
|
13018
|
-
} while (tmpResult.success && !
|
|
12867
|
+
} while (tmpResult.success && !done);
|
|
13019
12868
|
return result == null
|
|
13020
12869
|
? {
|
|
13021
12870
|
success: false,
|
|
@@ -13053,6 +12902,9 @@
|
|
|
13053
12902
|
context.end();
|
|
13054
12903
|
break;
|
|
13055
12904
|
}
|
|
12905
|
+
if (tmpResult.context.index === context.index) {
|
|
12906
|
+
break;
|
|
12907
|
+
}
|
|
13056
12908
|
context.update(tmpResult.context.current());
|
|
13057
12909
|
if (match?.max?.val != null && Number.isFinite(match?.max?.val) && count === match.max.val) {
|
|
13058
12910
|
break;
|
|
@@ -13098,7 +12950,6 @@
|
|
|
13098
12950
|
errors: [],
|
|
13099
12951
|
};
|
|
13100
12952
|
}
|
|
13101
|
-
syntaxes = syntaxes.slice();
|
|
13102
12953
|
let i = -1;
|
|
13103
12954
|
let success = false;
|
|
13104
12955
|
let token = null;
|
|
@@ -13430,21 +13281,19 @@
|
|
|
13430
13281
|
case ValidationTokenEnum.PipeToken:
|
|
13431
13282
|
{
|
|
13432
13283
|
result = null;
|
|
13433
|
-
const results = [];
|
|
13434
13284
|
let tmp = null;
|
|
13435
13285
|
for (const syntax of syntaxes[i].chi) {
|
|
13436
13286
|
tmp = matchSyntax(syntax, context.slice(), options);
|
|
13437
13287
|
if (tmp.success) {
|
|
13438
|
-
|
|
13288
|
+
if (result == null || tmp.context.index >= result.context.index) {
|
|
13289
|
+
result = tmp;
|
|
13290
|
+
}
|
|
13439
13291
|
if (tmp.context.done()) {
|
|
13440
13292
|
context.end();
|
|
13441
13293
|
return { ...tmp, context, syntaxToken: syntaxes[i + 1] };
|
|
13442
13294
|
}
|
|
13443
13295
|
}
|
|
13444
13296
|
}
|
|
13445
|
-
if (results.length > 0) {
|
|
13446
|
-
result = results.reduce((a, b) => (a.context.index > b.context.index ? a : b));
|
|
13447
|
-
}
|
|
13448
13297
|
if (result?.success) {
|
|
13449
13298
|
success = true;
|
|
13450
13299
|
options.visited.get(token).delete(syntaxes[i]);
|
|
@@ -13806,7 +13655,8 @@
|
|
|
13806
13655
|
*/
|
|
13807
13656
|
function matchProperty(property, context, options) {
|
|
13808
13657
|
let success = false;
|
|
13809
|
-
|
|
13658
|
+
const token = context.peek();
|
|
13659
|
+
let t = token?.typ;
|
|
13810
13660
|
let checkCalc = (t == exports.EnumToken.MathFunctionTokenDefType || t == exports.EnumToken.MathFunctionTokenType) &&
|
|
13811
13661
|
[
|
|
13812
13662
|
"number",
|
|
@@ -13821,19 +13671,19 @@
|
|
|
13821
13671
|
"calc-product",
|
|
13822
13672
|
].includes(property.val);
|
|
13823
13673
|
if (checkCalc && !["number", "zero", "integer", "percentage", "length-percentage"].includes(property.val)) {
|
|
13824
|
-
checkCalc =
|
|
13674
|
+
checkCalc = token.val === "calc";
|
|
13825
13675
|
}
|
|
13826
13676
|
if (checkCalc) {
|
|
13827
13677
|
let result;
|
|
13828
|
-
const syntax = getParsedSyntax(ValidationSyntaxGroupEnum.Syntaxes,
|
|
13678
|
+
const syntax = getParsedSyntax(ValidationSyntaxGroupEnum.Syntaxes, token.val + "()")?.[0]?.chi;
|
|
13829
13679
|
if (t === exports.EnumToken.MathFunctionTokenType) {
|
|
13830
|
-
result = matchSyntax(syntax, createValidationContext(
|
|
13680
|
+
result = matchSyntax(syntax, createValidationContext(token.chi), options);
|
|
13831
13681
|
if (result.success && result.context.done()) {
|
|
13832
13682
|
context.next();
|
|
13833
13683
|
return {
|
|
13834
13684
|
success: true,
|
|
13835
13685
|
valid: true,
|
|
13836
|
-
token:
|
|
13686
|
+
token: token,
|
|
13837
13687
|
context,
|
|
13838
13688
|
syntaxToken: null,
|
|
13839
13689
|
errors: [],
|
|
@@ -14007,13 +13857,16 @@
|
|
|
14007
13857
|
case "display-outside":
|
|
14008
13858
|
case "display-legacy":
|
|
14009
13859
|
case "content-position":
|
|
14010
|
-
|
|
14011
|
-
|
|
14012
|
-
|
|
14013
|
-
config$3.syntaxes[property.val].syntax
|
|
14014
|
-
|
|
14015
|
-
|
|
14016
|
-
|
|
13860
|
+
{
|
|
13861
|
+
let values = propertyKeywordValues.get(property.val);
|
|
13862
|
+
if (values == null) {
|
|
13863
|
+
values = new Set(config$3.syntaxes[property.val].syntax.split(/[\s|]+/));
|
|
13864
|
+
propertyKeywordValues.set(property.val, values);
|
|
13865
|
+
}
|
|
13866
|
+
success =
|
|
13867
|
+
token?.typ == exports.EnumToken.IdenTokenType && values.has(token.val.toLowerCase());
|
|
13868
|
+
break;
|
|
13869
|
+
}
|
|
14017
13870
|
case "mf-name":
|
|
14018
13871
|
{
|
|
14019
13872
|
const token = context.peek();
|
|
@@ -14034,9 +13887,9 @@
|
|
|
14034
13887
|
case "counter-name":
|
|
14035
13888
|
case "counter-style-name":
|
|
14036
13889
|
success =
|
|
14037
|
-
|
|
14038
|
-
if (success &&
|
|
14039
|
-
const val =
|
|
13890
|
+
token?.typ == exports.EnumToken.IdenTokenType || token?.typ == exports.EnumToken.DashedIdenTokenType;
|
|
13891
|
+
if (success && token?.typ === exports.EnumToken.IdenTokenType) {
|
|
13892
|
+
const val = token.val.toLowerCase();
|
|
14040
13893
|
success = "none" !== val && !allValues.includes(val);
|
|
14041
13894
|
}
|
|
14042
13895
|
break;
|
|
@@ -14550,7 +14403,6 @@
|
|
|
14550
14403
|
let result = null;
|
|
14551
14404
|
let tmpResult;
|
|
14552
14405
|
let success = !!isRepeatable;
|
|
14553
|
-
// let index: number = context.index;
|
|
14554
14406
|
do {
|
|
14555
14407
|
tmpResult = matchSyntax([rest], context.slice(), options);
|
|
14556
14408
|
if (tmpResult.success) {
|
|
@@ -14560,15 +14412,10 @@
|
|
|
14560
14412
|
context.end();
|
|
14561
14413
|
break;
|
|
14562
14414
|
}
|
|
14563
|
-
|
|
14564
|
-
|
|
14565
|
-
|
|
14415
|
+
if (tmpResult.context.index === context.index) {
|
|
14416
|
+
break;
|
|
14417
|
+
}
|
|
14566
14418
|
context.update(result.context.current());
|
|
14567
|
-
// }
|
|
14568
|
-
// if (index === context.index) {
|
|
14569
|
-
// break;
|
|
14570
|
-
// }
|
|
14571
|
-
// index = context.index;
|
|
14572
14419
|
}
|
|
14573
14420
|
} while (tmpResult.success && !context.done());
|
|
14574
14421
|
return {
|
|
@@ -18177,35 +18024,6 @@
|
|
|
18177
18024
|
"border-left-color": {
|
|
18178
18025
|
map: "border",
|
|
18179
18026
|
shorthand: "border-color"
|
|
18180
|
-
},
|
|
18181
|
-
"grid-row": {
|
|
18182
|
-
shorthand: "grid-row",
|
|
18183
|
-
properties: [
|
|
18184
|
-
"grid-row-start",
|
|
18185
|
-
"grid-row-end"
|
|
18186
|
-
],
|
|
18187
|
-
types: [
|
|
18188
|
-
"Iden",
|
|
18189
|
-
"Number"
|
|
18190
|
-
],
|
|
18191
|
-
multiple: true,
|
|
18192
|
-
valueSeparator: {
|
|
18193
|
-
typ: "Literal",
|
|
18194
|
-
val: "/"
|
|
18195
|
-
},
|
|
18196
|
-
"default": [
|
|
18197
|
-
"auto"
|
|
18198
|
-
],
|
|
18199
|
-
keywords: [
|
|
18200
|
-
"auto",
|
|
18201
|
-
"span"
|
|
18202
|
-
]
|
|
18203
|
-
},
|
|
18204
|
-
"grid-row-start": {
|
|
18205
|
-
shorthand: "grid-row"
|
|
18206
|
-
},
|
|
18207
|
-
"grid-row-end": {
|
|
18208
|
-
shorthand: "grid-row"
|
|
18209
18027
|
}
|
|
18210
18028
|
};
|
|
18211
18029
|
var map = {
|
|
@@ -19471,6 +19289,302 @@
|
|
|
19471
19289
|
},
|
|
19472
19290
|
"background-size": {
|
|
19473
19291
|
shorthand: "background"
|
|
19292
|
+
},
|
|
19293
|
+
"grid-area": {
|
|
19294
|
+
shorthand: "grid-area",
|
|
19295
|
+
pattern: "grid-row-start grid-column-start grid-row-end grid-column-end",
|
|
19296
|
+
keywords: [
|
|
19297
|
+
"auto"
|
|
19298
|
+
],
|
|
19299
|
+
"default": [
|
|
19300
|
+
"auto"
|
|
19301
|
+
],
|
|
19302
|
+
multiple: false,
|
|
19303
|
+
expandShorthands: true,
|
|
19304
|
+
separator: {
|
|
19305
|
+
typ: "Literal",
|
|
19306
|
+
val: "/"
|
|
19307
|
+
},
|
|
19308
|
+
mapping: {
|
|
19309
|
+
"auto/auto": "auto",
|
|
19310
|
+
"auto/auto/auto": "auto",
|
|
19311
|
+
"auto/auto/auto/auto": "auto"
|
|
19312
|
+
},
|
|
19313
|
+
expandedProperties: {
|
|
19314
|
+
"grid-row": [
|
|
19315
|
+
"grid-row-start",
|
|
19316
|
+
"grid-row-end"
|
|
19317
|
+
],
|
|
19318
|
+
"grid-column": [
|
|
19319
|
+
"grid-column-start",
|
|
19320
|
+
"grid-column-end"
|
|
19321
|
+
]
|
|
19322
|
+
},
|
|
19323
|
+
properties: {
|
|
19324
|
+
"grid-row-start": {
|
|
19325
|
+
map: "grid-area",
|
|
19326
|
+
shorthand: "grid-row",
|
|
19327
|
+
types: [
|
|
19328
|
+
"Iden",
|
|
19329
|
+
"Number"
|
|
19330
|
+
],
|
|
19331
|
+
"default": [
|
|
19332
|
+
"auto"
|
|
19333
|
+
],
|
|
19334
|
+
keywords: [
|
|
19335
|
+
"auto"
|
|
19336
|
+
]
|
|
19337
|
+
},
|
|
19338
|
+
"grid-column-start": {
|
|
19339
|
+
map: "grid-area",
|
|
19340
|
+
shorthand: "grid-column",
|
|
19341
|
+
types: [
|
|
19342
|
+
"Iden",
|
|
19343
|
+
"Number"
|
|
19344
|
+
],
|
|
19345
|
+
prefix: {
|
|
19346
|
+
typ: "Literal",
|
|
19347
|
+
val: "/"
|
|
19348
|
+
},
|
|
19349
|
+
"default": [
|
|
19350
|
+
"auto"
|
|
19351
|
+
],
|
|
19352
|
+
keywords: [
|
|
19353
|
+
"auto"
|
|
19354
|
+
]
|
|
19355
|
+
},
|
|
19356
|
+
"grid-row-end": {
|
|
19357
|
+
map: "grid-area",
|
|
19358
|
+
shorthand: "grid-row",
|
|
19359
|
+
types: [
|
|
19360
|
+
"Iden",
|
|
19361
|
+
"Number"
|
|
19362
|
+
],
|
|
19363
|
+
prefix: {
|
|
19364
|
+
typ: "Literal",
|
|
19365
|
+
val: "/"
|
|
19366
|
+
},
|
|
19367
|
+
"default": [
|
|
19368
|
+
"auto"
|
|
19369
|
+
],
|
|
19370
|
+
keywords: [
|
|
19371
|
+
"auto"
|
|
19372
|
+
]
|
|
19373
|
+
},
|
|
19374
|
+
"grid-column-end": {
|
|
19375
|
+
map: "grid-area",
|
|
19376
|
+
shorthand: "grid-column",
|
|
19377
|
+
types: [
|
|
19378
|
+
"Iden",
|
|
19379
|
+
"Number"
|
|
19380
|
+
],
|
|
19381
|
+
prefix: {
|
|
19382
|
+
typ: "Literal",
|
|
19383
|
+
val: "/"
|
|
19384
|
+
},
|
|
19385
|
+
"default": [
|
|
19386
|
+
"auto"
|
|
19387
|
+
],
|
|
19388
|
+
keywords: [
|
|
19389
|
+
"auto"
|
|
19390
|
+
]
|
|
19391
|
+
}
|
|
19392
|
+
}
|
|
19393
|
+
},
|
|
19394
|
+
"grid-row-start": {
|
|
19395
|
+
shorthand: "grid-row"
|
|
19396
|
+
},
|
|
19397
|
+
"grid-column-start": {
|
|
19398
|
+
shorthand: "grid-column"
|
|
19399
|
+
},
|
|
19400
|
+
"grid-row-end": {
|
|
19401
|
+
shorthand: "grid-row"
|
|
19402
|
+
},
|
|
19403
|
+
"grid-column-end": {
|
|
19404
|
+
shorthand: "grid-column"
|
|
19405
|
+
},
|
|
19406
|
+
"grid-row": {
|
|
19407
|
+
shorthand: "grid-row",
|
|
19408
|
+
map: "grid-area",
|
|
19409
|
+
pattern: "grid-row-start grid-row-end",
|
|
19410
|
+
types: [
|
|
19411
|
+
"Iden",
|
|
19412
|
+
"Number"
|
|
19413
|
+
],
|
|
19414
|
+
keywords: [
|
|
19415
|
+
"auto"
|
|
19416
|
+
],
|
|
19417
|
+
"default": [
|
|
19418
|
+
"auto"
|
|
19419
|
+
],
|
|
19420
|
+
multiple: false,
|
|
19421
|
+
mapping: {
|
|
19422
|
+
"auto auto": "auto",
|
|
19423
|
+
"auto/auto": "auto"
|
|
19424
|
+
},
|
|
19425
|
+
properties: {
|
|
19426
|
+
"grid-row-start": {
|
|
19427
|
+
map: "grid-area",
|
|
19428
|
+
types: [
|
|
19429
|
+
"Iden",
|
|
19430
|
+
"Number"
|
|
19431
|
+
],
|
|
19432
|
+
"default": [
|
|
19433
|
+
"auto"
|
|
19434
|
+
],
|
|
19435
|
+
multiple: true,
|
|
19436
|
+
keywords: [
|
|
19437
|
+
"auto"
|
|
19438
|
+
]
|
|
19439
|
+
},
|
|
19440
|
+
"grid-row-end": {
|
|
19441
|
+
map: "grid-area",
|
|
19442
|
+
types: [
|
|
19443
|
+
"Iden",
|
|
19444
|
+
"Number"
|
|
19445
|
+
],
|
|
19446
|
+
"default": [
|
|
19447
|
+
"auto"
|
|
19448
|
+
],
|
|
19449
|
+
prefix: {
|
|
19450
|
+
typ: "Literal",
|
|
19451
|
+
val: "/"
|
|
19452
|
+
},
|
|
19453
|
+
multiple: true,
|
|
19454
|
+
keywords: [
|
|
19455
|
+
"auto"
|
|
19456
|
+
]
|
|
19457
|
+
}
|
|
19458
|
+
}
|
|
19459
|
+
},
|
|
19460
|
+
"grid-column": {
|
|
19461
|
+
shorthand: "grid-column",
|
|
19462
|
+
map: "grid-area",
|
|
19463
|
+
pattern: "grid-column-start grid-column-end",
|
|
19464
|
+
types: [
|
|
19465
|
+
"Iden",
|
|
19466
|
+
"Number"
|
|
19467
|
+
],
|
|
19468
|
+
keywords: [
|
|
19469
|
+
"auto"
|
|
19470
|
+
],
|
|
19471
|
+
"default": [
|
|
19472
|
+
"auto"
|
|
19473
|
+
],
|
|
19474
|
+
multiple: false,
|
|
19475
|
+
mapping: {
|
|
19476
|
+
"auto/auto": "auto"
|
|
19477
|
+
},
|
|
19478
|
+
properties: {
|
|
19479
|
+
"grid-column-start": {
|
|
19480
|
+
map: "grid-area",
|
|
19481
|
+
types: [
|
|
19482
|
+
"Iden",
|
|
19483
|
+
"Number"
|
|
19484
|
+
],
|
|
19485
|
+
"default": [
|
|
19486
|
+
"auto"
|
|
19487
|
+
],
|
|
19488
|
+
multiple: true,
|
|
19489
|
+
keywords: [
|
|
19490
|
+
"auto"
|
|
19491
|
+
]
|
|
19492
|
+
},
|
|
19493
|
+
"grid-column-end": {
|
|
19494
|
+
map: "grid-area",
|
|
19495
|
+
types: [
|
|
19496
|
+
"Iden",
|
|
19497
|
+
"Number"
|
|
19498
|
+
],
|
|
19499
|
+
"default": [
|
|
19500
|
+
"auto"
|
|
19501
|
+
],
|
|
19502
|
+
multiple: true,
|
|
19503
|
+
prefix: {
|
|
19504
|
+
typ: "Literal",
|
|
19505
|
+
val: "/"
|
|
19506
|
+
},
|
|
19507
|
+
keywords: [
|
|
19508
|
+
"auto"
|
|
19509
|
+
]
|
|
19510
|
+
}
|
|
19511
|
+
}
|
|
19512
|
+
},
|
|
19513
|
+
"grid-template": {
|
|
19514
|
+
shorthand: "grid-template",
|
|
19515
|
+
pattern: "grid-template-areas grid-template-rows grid-template-columns",
|
|
19516
|
+
keywords: [
|
|
19517
|
+
"none"
|
|
19518
|
+
],
|
|
19519
|
+
"default": [
|
|
19520
|
+
"none"
|
|
19521
|
+
],
|
|
19522
|
+
multiple: false,
|
|
19523
|
+
mapping: {
|
|
19524
|
+
"none none": "none",
|
|
19525
|
+
"none/none": "none",
|
|
19526
|
+
"none none/none": "none"
|
|
19527
|
+
},
|
|
19528
|
+
properties: {
|
|
19529
|
+
"grid-template-areas": {
|
|
19530
|
+
types: [
|
|
19531
|
+
"String"
|
|
19532
|
+
],
|
|
19533
|
+
"default": [
|
|
19534
|
+
"none"
|
|
19535
|
+
],
|
|
19536
|
+
multiple: true,
|
|
19537
|
+
keywords: [
|
|
19538
|
+
"none",
|
|
19539
|
+
"auto"
|
|
19540
|
+
],
|
|
19541
|
+
mapping: {
|
|
19542
|
+
}
|
|
19543
|
+
},
|
|
19544
|
+
"grid-template-rows": {
|
|
19545
|
+
types: [
|
|
19546
|
+
"Perc",
|
|
19547
|
+
"Iden",
|
|
19548
|
+
"Length",
|
|
19549
|
+
"Flex"
|
|
19550
|
+
],
|
|
19551
|
+
"default": [
|
|
19552
|
+
"none"
|
|
19553
|
+
],
|
|
19554
|
+
multiple: true,
|
|
19555
|
+
keywords: [
|
|
19556
|
+
"none"
|
|
19557
|
+
]
|
|
19558
|
+
},
|
|
19559
|
+
"grid-template-columns": {
|
|
19560
|
+
types: [
|
|
19561
|
+
"Perc",
|
|
19562
|
+
"Iden",
|
|
19563
|
+
"Length",
|
|
19564
|
+
"Flex"
|
|
19565
|
+
],
|
|
19566
|
+
"default": [
|
|
19567
|
+
"none"
|
|
19568
|
+
],
|
|
19569
|
+
prefix: {
|
|
19570
|
+
typ: "Literal",
|
|
19571
|
+
val: "/"
|
|
19572
|
+
},
|
|
19573
|
+
multiple: true,
|
|
19574
|
+
keywords: [
|
|
19575
|
+
"none"
|
|
19576
|
+
]
|
|
19577
|
+
}
|
|
19578
|
+
}
|
|
19579
|
+
},
|
|
19580
|
+
"grid-template-areas": {
|
|
19581
|
+
shorthand: "grid-template"
|
|
19582
|
+
},
|
|
19583
|
+
"grid-template-rows": {
|
|
19584
|
+
shorthand: "grid-template"
|
|
19585
|
+
},
|
|
19586
|
+
"grid-template-columns": {
|
|
19587
|
+
shorthand: "grid-template"
|
|
19474
19588
|
}
|
|
19475
19589
|
};
|
|
19476
19590
|
var property = {
|
|
@@ -19741,18 +19855,50 @@
|
|
|
19741
19855
|
return this;
|
|
19742
19856
|
}
|
|
19743
19857
|
[Symbol.iterator]() {
|
|
19858
|
+
const propertiesMapping = { ...this.config.properties };
|
|
19859
|
+
const patterns = this.config.pattern.split(" ");
|
|
19860
|
+
let hasMapping = false;
|
|
19744
19861
|
let iterable;
|
|
19745
19862
|
let requiredCount = 0;
|
|
19746
19863
|
let property;
|
|
19747
19864
|
let isShorthand = true;
|
|
19748
|
-
|
|
19749
|
-
|
|
19750
|
-
|
|
19865
|
+
let declarations = this.declarations;
|
|
19866
|
+
for (const key of declarations.keys()) {
|
|
19867
|
+
if (declarations.has(key) && declarations.get(key) instanceof PropertyMap) {
|
|
19868
|
+
hasMapping = true;
|
|
19869
|
+
break;
|
|
19870
|
+
}
|
|
19871
|
+
}
|
|
19872
|
+
if (hasMapping) {
|
|
19873
|
+
const mapped = {};
|
|
19874
|
+
for (const key of declarations.keys()) {
|
|
19875
|
+
const value = declarations.get(key);
|
|
19876
|
+
if (value instanceof PropertyMap) {
|
|
19877
|
+
for (const [k, v] of value.declarations) {
|
|
19878
|
+
mapped[k] = v;
|
|
19879
|
+
}
|
|
19880
|
+
}
|
|
19881
|
+
else {
|
|
19882
|
+
mapped[key] = value;
|
|
19883
|
+
}
|
|
19884
|
+
}
|
|
19885
|
+
if (patterns.length === Object.keys(mapped).length) {
|
|
19886
|
+
declarations = new Map();
|
|
19887
|
+
for (const key of patterns) {
|
|
19888
|
+
if (mapped[key] != null) {
|
|
19889
|
+
declarations.set(key, mapped[key]);
|
|
19890
|
+
}
|
|
19891
|
+
}
|
|
19892
|
+
}
|
|
19893
|
+
}
|
|
19894
|
+
for (property of Object.keys(propertiesMapping)) {
|
|
19895
|
+
if (propertiesMapping[property].required) {
|
|
19896
|
+
if (!declarations.has(property)) {
|
|
19751
19897
|
isShorthand = false;
|
|
19752
19898
|
break;
|
|
19753
19899
|
}
|
|
19754
19900
|
else {
|
|
19755
|
-
const val =
|
|
19901
|
+
const val = declarations.get(property);
|
|
19756
19902
|
if (val instanceof PropertySet && !val.isShortHand()) {
|
|
19757
19903
|
isShorthand = false;
|
|
19758
19904
|
break;
|
|
@@ -19764,10 +19910,10 @@
|
|
|
19764
19910
|
}
|
|
19765
19911
|
}
|
|
19766
19912
|
if (requiredCount === 0) {
|
|
19767
|
-
requiredCount =
|
|
19913
|
+
requiredCount = declarations.size;
|
|
19768
19914
|
}
|
|
19769
19915
|
if (!isShorthand || requiredCount < this.requiredCount) {
|
|
19770
|
-
if (isShorthand &&
|
|
19916
|
+
if (isShorthand && declarations.has(this.config.shorthand)) {
|
|
19771
19917
|
const cache = new Map();
|
|
19772
19918
|
const removeDefaults = (declaration) => {
|
|
19773
19919
|
let i;
|
|
@@ -19842,8 +19988,8 @@
|
|
|
19842
19988
|
}
|
|
19843
19989
|
return declaration;
|
|
19844
19990
|
};
|
|
19845
|
-
const values = [...
|
|
19846
|
-
if (curr instanceof PropertySet) {
|
|
19991
|
+
const values = [...declarations.values()].reduce((acc, curr) => {
|
|
19992
|
+
if (curr instanceof PropertySet || curr instanceof PropertyMap) {
|
|
19847
19993
|
for (const declaration of curr) {
|
|
19848
19994
|
acc.push(declaration);
|
|
19849
19995
|
}
|
|
@@ -19883,13 +20029,13 @@
|
|
|
19883
20029
|
}
|
|
19884
20030
|
return (filtered.length > 0 ? filtered : values)[Symbol.iterator]();
|
|
19885
20031
|
}
|
|
19886
|
-
for (const declaration of
|
|
19887
|
-
if (declaration instanceof PropertySet) {
|
|
20032
|
+
for (const declaration of declarations.values()) {
|
|
20033
|
+
if (declaration instanceof PropertySet || declaration instanceof PropertyMap) {
|
|
19888
20034
|
continue;
|
|
19889
20035
|
}
|
|
19890
20036
|
const config = declaration.nam == this.config.shorthand
|
|
19891
20037
|
? this.config
|
|
19892
|
-
: (
|
|
20038
|
+
: (propertiesMapping[declaration.nam] ?? this.config);
|
|
19893
20039
|
if (!("mapping" in config)) {
|
|
19894
20040
|
continue;
|
|
19895
20041
|
}
|
|
@@ -19906,7 +20052,7 @@
|
|
|
19906
20052
|
}
|
|
19907
20053
|
}
|
|
19908
20054
|
// @ts-ignore
|
|
19909
|
-
iterable =
|
|
20055
|
+
iterable = declarations.values();
|
|
19910
20056
|
}
|
|
19911
20057
|
else {
|
|
19912
20058
|
let count = 0;
|
|
@@ -19920,19 +20066,19 @@
|
|
|
19920
20066
|
: null;
|
|
19921
20067
|
const tokens = {};
|
|
19922
20068
|
// @ts-ignore
|
|
19923
|
-
Object.entries(
|
|
19924
|
-
if (!
|
|
20069
|
+
Object.entries(propertiesMapping).reduce((acc, curr) => {
|
|
20070
|
+
if (!declarations.has(curr[0])) {
|
|
19925
20071
|
if (curr[1].required) {
|
|
19926
20072
|
acc.push(curr[0]);
|
|
19927
20073
|
}
|
|
19928
20074
|
return acc;
|
|
19929
20075
|
}
|
|
19930
20076
|
let current = 0;
|
|
19931
|
-
const props =
|
|
19932
|
-
const properties = (
|
|
19933
|
-
for (const declaration of
|
|
19934
|
-
|
|
19935
|
-
|
|
20077
|
+
const props = propertiesMapping[curr[0]];
|
|
20078
|
+
const properties = (declarations.get(curr[0]));
|
|
20079
|
+
for (const declaration of properties instanceof PropertySet || properties instanceof PropertyMap
|
|
20080
|
+
? [...properties].flat()
|
|
20081
|
+
: [properties]) {
|
|
19936
20082
|
// @ts-ignore
|
|
19937
20083
|
for (const val of declaration.val) {
|
|
19938
20084
|
// @ts-ignore
|
|
@@ -19979,9 +20125,45 @@
|
|
|
19979
20125
|
}
|
|
19980
20126
|
return acc;
|
|
19981
20127
|
}, []);
|
|
20128
|
+
// grid-template
|
|
20129
|
+
if (this.config.shorthand == "grid-template" && patterns.length == Object.keys(tokens).length) {
|
|
20130
|
+
const k = tokens[patterns[0]][0].length;
|
|
20131
|
+
const l = tokens[patterns[1]][0].length;
|
|
20132
|
+
const j = k < l ? k : l;
|
|
20133
|
+
const result = [];
|
|
20134
|
+
let i;
|
|
20135
|
+
for (i = 0; i < j; i++) {
|
|
20136
|
+
if (i < k) {
|
|
20137
|
+
result.push(tokens[patterns[0]][0][i]);
|
|
20138
|
+
}
|
|
20139
|
+
if (i < l) {
|
|
20140
|
+
result.push(tokens[patterns[1]][0][i]);
|
|
20141
|
+
}
|
|
20142
|
+
}
|
|
20143
|
+
if (j < k) {
|
|
20144
|
+
result.push(...tokens[patterns[0]][0].slice(j));
|
|
20145
|
+
}
|
|
20146
|
+
if (j < l) {
|
|
20147
|
+
result.push(...tokens[patterns[1]][0].slice(j));
|
|
20148
|
+
}
|
|
20149
|
+
const separator = this.config.properties[patterns[2]]?.prefix;
|
|
20150
|
+
result.push(
|
|
20151
|
+
// @ts-ignore
|
|
20152
|
+
{ ...separator, typ: exports.EnumToken[separator.typ] }, ...tokens[patterns[2]][0].reduce((acc, curr) => {
|
|
20153
|
+
if (acc.length > 0) {
|
|
20154
|
+
acc.push({ typ: exports.EnumToken.WhitespaceTokenType });
|
|
20155
|
+
}
|
|
20156
|
+
acc.push(curr);
|
|
20157
|
+
return acc;
|
|
20158
|
+
}, []));
|
|
20159
|
+
const declaration = cloneNode(declarations.get(patterns[0]));
|
|
20160
|
+
declaration.nam = this.config.shorthand;
|
|
20161
|
+
declaration.val = result;
|
|
20162
|
+
return [declaration][Symbol.iterator]();
|
|
20163
|
+
}
|
|
19982
20164
|
count++;
|
|
19983
20165
|
if (!isShorthand ||
|
|
19984
|
-
Object.entries(
|
|
20166
|
+
Object.entries(propertiesMapping).some((entry) => {
|
|
19985
20167
|
// missing required property
|
|
19986
20168
|
return entry[1].required && !(entry[0] in tokens);
|
|
19987
20169
|
}) ||
|
|
@@ -19990,27 +20172,74 @@
|
|
|
19990
20172
|
// @ts-expect-error
|
|
19991
20173
|
v.filter((t) => t.typ != exports.EnumToken.CommentTokenType).length === count)) {
|
|
19992
20174
|
// @ts-ignore
|
|
19993
|
-
iterable =
|
|
20175
|
+
iterable = declarations.values();
|
|
20176
|
+
}
|
|
20177
|
+
else if (hasMapping) {
|
|
20178
|
+
if (patterns.length == Object.keys(tokens).length) {
|
|
20179
|
+
const declaration = cloneNode(declarations.get(patterns[0]));
|
|
20180
|
+
declaration.nam = this.config.shorthand;
|
|
20181
|
+
for (let i = 0; i < patterns.length; i++) {
|
|
20182
|
+
if (declaration.val.length > 0) {
|
|
20183
|
+
declaration.val.push(
|
|
20184
|
+
// @ts-ignore
|
|
20185
|
+
this.config.separator != null
|
|
20186
|
+
? {
|
|
20187
|
+
...this.config.separator,
|
|
20188
|
+
typ: exports.EnumToken[this.config.separator.typ],
|
|
20189
|
+
}
|
|
20190
|
+
: { typ: exports.EnumToken.WhitespaceTokenType });
|
|
20191
|
+
}
|
|
20192
|
+
declaration.val.push(...tokens[patterns[i]].reduce((acc, curr) => {
|
|
20193
|
+
if (acc.length > 0) {
|
|
20194
|
+
acc.push({ typ: exports.EnumToken.WhitespaceTokenType });
|
|
20195
|
+
}
|
|
20196
|
+
acc.push(...curr.reduce((acc, curr) => {
|
|
20197
|
+
if (acc.length > 0) {
|
|
20198
|
+
acc.push({ typ: exports.EnumToken.WhitespaceTokenType });
|
|
20199
|
+
}
|
|
20200
|
+
acc.push(curr);
|
|
20201
|
+
return acc;
|
|
20202
|
+
}, []));
|
|
20203
|
+
return acc;
|
|
20204
|
+
}, []));
|
|
20205
|
+
}
|
|
20206
|
+
return [declaration][Symbol.iterator]();
|
|
20207
|
+
}
|
|
20208
|
+
iterable = declarations.values();
|
|
19994
20209
|
}
|
|
19995
20210
|
else {
|
|
19996
20211
|
let values = Object.entries(tokens)
|
|
19997
20212
|
.reduce((acc, curr) => {
|
|
19998
|
-
const props =
|
|
20213
|
+
const props = propertiesMapping[curr[0]];
|
|
19999
20214
|
for (let i = 0; i < curr[1].length; i++) {
|
|
20000
20215
|
if (acc.length == i) {
|
|
20001
20216
|
acc.push([]);
|
|
20002
20217
|
}
|
|
20003
|
-
|
|
20004
|
-
|
|
20005
|
-
|
|
20006
|
-
|
|
20007
|
-
|
|
20008
|
-
|
|
20009
|
-
|
|
20218
|
+
// if (acc[acc.length - 1].length > 0) {
|
|
20219
|
+
// acc[acc.length - 1].push(
|
|
20220
|
+
// // @ts-ignore
|
|
20221
|
+
// this.config.separator != null ?
|
|
20222
|
+
// {
|
|
20223
|
+
// ...this.config.separator,
|
|
20224
|
+
// typ: EnumToken[this.config.separator.typ as keyof typeof EnumToken],
|
|
20225
|
+
// } : <Token>{ typ: EnumToken.WhitespaceTokenType },
|
|
20226
|
+
// )
|
|
20227
|
+
// }
|
|
20228
|
+
let values = curr[1][i];
|
|
20229
|
+
// .reduce(
|
|
20230
|
+
// (acc, curr) => {
|
|
20231
|
+
// // if (acc.length > 0) {
|
|
20232
|
+
// // acc.push(<Token>{ typ: EnumToken.WhitespaceTokenType });
|
|
20233
|
+
// // }
|
|
20234
|
+
// acc.push(curr);
|
|
20235
|
+
// return acc;
|
|
20236
|
+
// },
|
|
20237
|
+
// <Token[]>[],
|
|
20238
|
+
// );
|
|
20010
20239
|
if (props.default.includes(curr[1][i]
|
|
20011
20240
|
.reduce((acc, curr) => acc + renderValue(curr) + " ", "")
|
|
20012
20241
|
.trimEnd())) {
|
|
20013
|
-
if (!
|
|
20242
|
+
if (!propertiesMapping[curr[0]].required) {
|
|
20014
20243
|
continue;
|
|
20015
20244
|
}
|
|
20016
20245
|
}
|
|
@@ -20024,7 +20253,7 @@
|
|
|
20024
20253
|
exports.EnumToken.IdenTokenType,
|
|
20025
20254
|
].includes(v.typ) ||
|
|
20026
20255
|
(v.typ == exports.EnumToken.IdenTokenType &&
|
|
20027
|
-
!
|
|
20256
|
+
!propertiesMapping[curr[0]].default.includes(v.val))) {
|
|
20028
20257
|
doFilterDefault = false;
|
|
20029
20258
|
break;
|
|
20030
20259
|
}
|
|
@@ -20041,7 +20270,7 @@
|
|
|
20041
20270
|
props.default.includes(val.val)));
|
|
20042
20271
|
});
|
|
20043
20272
|
if (filtered.length > 0 ||
|
|
20044
|
-
!(this.requiredCount == requiredCount &&
|
|
20273
|
+
!(this.requiredCount == requiredCount && propertiesMapping[curr[0]].required)) {
|
|
20045
20274
|
values = filtered;
|
|
20046
20275
|
}
|
|
20047
20276
|
if (values.length > 0) {
|
|
@@ -20066,6 +20295,7 @@
|
|
|
20066
20295
|
acc[i].push({ ...props.prefix, typ: exports.EnumToken[props.prefix.typ] });
|
|
20067
20296
|
}
|
|
20068
20297
|
else if (acc[i].length > 0) {
|
|
20298
|
+
// @ts-ignore
|
|
20069
20299
|
acc[i].push({ typ: exports.EnumToken.WhitespaceTokenType });
|
|
20070
20300
|
}
|
|
20071
20301
|
for (const v of values.reduce((acc, curr) => {
|
|
@@ -20107,6 +20337,8 @@
|
|
|
20107
20337
|
}
|
|
20108
20338
|
return acc;
|
|
20109
20339
|
}, []);
|
|
20340
|
+
// console.error({hasMapping, shorthand: this.config.shorthand, requiredCount, isShorthand,
|
|
20341
|
+
// declarations: declarations.values(), values});
|
|
20110
20342
|
if (this.config.mapping != null) {
|
|
20111
20343
|
const val = values.reduce((acc, curr) => acc +
|
|
20112
20344
|
renderValue(curr, {
|
|
@@ -20299,12 +20531,17 @@
|
|
|
20299
20531
|
return String(input);
|
|
20300
20532
|
}
|
|
20301
20533
|
if (Array.isArray(input)) {
|
|
20302
|
-
|
|
20534
|
+
const result = new Array(input.length);
|
|
20535
|
+
for (const value of input) {
|
|
20536
|
+
result.push(toSortedString(value));
|
|
20537
|
+
}
|
|
20538
|
+
return JSON.stringify(result);
|
|
20303
20539
|
}
|
|
20304
|
-
|
|
20305
|
-
.
|
|
20306
|
-
|
|
20307
|
-
|
|
20540
|
+
const keys = Object.keys(input).sort();
|
|
20541
|
+
for (let i = 0; i < keys.length; i++) {
|
|
20542
|
+
keys[i] = `${keys[i]}:${toSortedString(input[keys[i]])}`;
|
|
20543
|
+
}
|
|
20544
|
+
return `{${keys.join(",")}}`;
|
|
20308
20545
|
}
|
|
20309
20546
|
/**
|
|
20310
20547
|
* Object hash
|
|
@@ -20397,14 +20634,7 @@
|
|
|
20397
20634
|
this.options = options;
|
|
20398
20635
|
this.declarations = new Map();
|
|
20399
20636
|
}
|
|
20400
|
-
|
|
20401
|
-
// return this.add({
|
|
20402
|
-
// typ: EnumToken.DeclarationNodeType,
|
|
20403
|
-
// nam,
|
|
20404
|
-
// val: Array.isArray(value) ? value : parseString(String(value)),
|
|
20405
|
-
// });
|
|
20406
|
-
// }
|
|
20407
|
-
add(...declarations) {
|
|
20637
|
+
add(declarations) {
|
|
20408
20638
|
let name;
|
|
20409
20639
|
let syntaxRules = null;
|
|
20410
20640
|
let result;
|
|
@@ -20442,22 +20672,8 @@
|
|
|
20442
20672
|
}
|
|
20443
20673
|
// do not compute shorthand for invalid declarations
|
|
20444
20674
|
if (declaration[STATE] !== exports.EnumAstNodeStatus.Validated) {
|
|
20445
|
-
// const key = objectHash(declaration);
|
|
20446
|
-
// if (!this.ketsey.has(key)) {
|
|
20447
|
-
// this.ketsey.set(key, [declaration.nam]);
|
|
20448
|
-
// console.error(
|
|
20449
|
-
// `Adding declaration : ${(<AstDeclaration>declaration).nam} with key : ${key}`
|
|
20450
|
-
// )
|
|
20451
|
-
// }
|
|
20452
|
-
// else {
|
|
20453
|
-
// console.error(
|
|
20454
|
-
// `Duplicate declaration found: ${(<AstDeclaration>declaration).nam} with key : [ ${key} => ${this.ketsey.get(key)} ]`
|
|
20455
|
-
// )
|
|
20456
|
-
// console.error(JSON.stringify(toSortedString(declaration)))
|
|
20457
|
-
// this.ketsey.get(key).push(declaration.nam);
|
|
20458
|
-
// }
|
|
20459
20675
|
this.declarations.set(objectHash(declaration), declaration);
|
|
20460
|
-
|
|
20676
|
+
continue;
|
|
20461
20677
|
}
|
|
20462
20678
|
let propertyName = declaration.nam;
|
|
20463
20679
|
let shortHandType;
|
|
@@ -20485,15 +20701,28 @@
|
|
|
20485
20701
|
// @ts-ignore
|
|
20486
20702
|
shorthand = config.property[propertyName];
|
|
20487
20703
|
}
|
|
20704
|
+
// console.error({shortHandType, propertyName, config: config.map[propertyName], map: config.map[shorthand].properties[propertyName]});
|
|
20488
20705
|
// @ts-ignore
|
|
20489
20706
|
if (shortHandType == "map") {
|
|
20707
|
+
let owner = this;
|
|
20490
20708
|
// @ts-ignore
|
|
20491
|
-
|
|
20709
|
+
const mapName = config.map[propertyName]?.map ?? config.map[shorthand]?.properties?.[propertyName]?.map;
|
|
20710
|
+
if (typeof mapName === "string") {
|
|
20711
|
+
if (!this.declarations.has(mapName)) {
|
|
20712
|
+
// @ts-ignore
|
|
20713
|
+
this.declarations.set(mapName, new PropertyMap(config.map[mapName]));
|
|
20714
|
+
}
|
|
20715
|
+
owner = this.declarations.get(mapName);
|
|
20716
|
+
// console.error({mapName});
|
|
20717
|
+
}
|
|
20718
|
+
// @ts-ignore
|
|
20719
|
+
if (!owner.declarations.has(shorthand)) {
|
|
20492
20720
|
// @ts-ignore
|
|
20493
|
-
|
|
20721
|
+
owner.declarations.set(shorthand, new PropertyMap(config.map[shorthand]));
|
|
20494
20722
|
}
|
|
20723
|
+
// console.error({propertyName,mapName, owned: owner == this});
|
|
20495
20724
|
// @ts-ignore
|
|
20496
|
-
|
|
20725
|
+
owner.declarations.get(shorthand).add(declaration);
|
|
20497
20726
|
}
|
|
20498
20727
|
// @ts-ignore
|
|
20499
20728
|
else if (shortHandType == "set") {
|
|
@@ -20580,6 +20809,7 @@
|
|
|
20580
20809
|
[Symbol.iterator]() {
|
|
20581
20810
|
let iterator = this.declarations.values();
|
|
20582
20811
|
const iterators = [];
|
|
20812
|
+
// console.error(this);
|
|
20583
20813
|
return {
|
|
20584
20814
|
next() {
|
|
20585
20815
|
let value = iterator.next();
|
|
@@ -20629,8 +20859,9 @@
|
|
|
20629
20859
|
const j = ast.chi.length;
|
|
20630
20860
|
let k = 0;
|
|
20631
20861
|
let l;
|
|
20632
|
-
let properties = new PropertyList(options);
|
|
20862
|
+
// let properties: PropertyList = new PropertyList(options);
|
|
20633
20863
|
const rules = [];
|
|
20864
|
+
const declarations = [];
|
|
20634
20865
|
// @ts-ignore
|
|
20635
20866
|
for (; k < j; k++) {
|
|
20636
20867
|
l = k;
|
|
@@ -20648,7 +20879,8 @@
|
|
|
20648
20879
|
const node = ast.chi[l];
|
|
20649
20880
|
if (node.typ == exports.EnumToken.DeclarationNodeType) {
|
|
20650
20881
|
for (let m = k; m <= l; m++) {
|
|
20651
|
-
|
|
20882
|
+
declarations.push(ast.chi[m]);
|
|
20883
|
+
// properties.add(ast.chi![m]);
|
|
20652
20884
|
}
|
|
20653
20885
|
}
|
|
20654
20886
|
else {
|
|
@@ -20658,9 +20890,12 @@
|
|
|
20658
20890
|
}
|
|
20659
20891
|
k = l;
|
|
20660
20892
|
}
|
|
20661
|
-
|
|
20662
|
-
|
|
20663
|
-
|
|
20893
|
+
// console.error([...new PropertyList(options).add(declarations)]);
|
|
20894
|
+
if (declarations.length > 0) {
|
|
20895
|
+
ast.chi.length = 0;
|
|
20896
|
+
// @ts-expect-error
|
|
20897
|
+
ast.chi.push(...new PropertyList(options).add(declarations), ...rules);
|
|
20898
|
+
}
|
|
20664
20899
|
return ast;
|
|
20665
20900
|
}
|
|
20666
20901
|
}
|
|
@@ -20875,7 +21110,7 @@
|
|
|
20875
21110
|
}
|
|
20876
21111
|
}
|
|
20877
21112
|
|
|
20878
|
-
const identityMatrix = new
|
|
21113
|
+
const identityMatrix = new Float64Array([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
|
|
20879
21114
|
function identity() {
|
|
20880
21115
|
return identityMatrix.slice();
|
|
20881
21116
|
}
|
|
@@ -20891,7 +21126,7 @@
|
|
|
20891
21126
|
return point1[0] * point2[0] + point1[1] * point2[1] + point1[2] * point2[2];
|
|
20892
21127
|
}
|
|
20893
21128
|
function multiply(matrixA, matrixB) {
|
|
20894
|
-
const result = new
|
|
21129
|
+
const result = new Float64Array(16);
|
|
20895
21130
|
result[0] = matrixA[0] * matrixB[0] + matrixA[4] * matrixB[1] + matrixA[8] * matrixB[2] + matrixA[12] * matrixB[3];
|
|
20896
21131
|
result[1] = matrixA[1] * matrixB[0] + matrixA[5] * matrixB[1] + matrixA[9] * matrixB[2] + matrixA[13] * matrixB[3];
|
|
20897
21132
|
result[2] = matrixA[2] * matrixB[0] + matrixA[6] * matrixB[1] + matrixA[10] * matrixB[2] + matrixA[14] * matrixB[3];
|
|
@@ -24979,7 +25214,6 @@
|
|
|
24979
25214
|
* Source file helper class
|
|
24980
25215
|
*/
|
|
24981
25216
|
class SourceFile {
|
|
24982
|
-
inputSourceMap = null;
|
|
24983
25217
|
/**
|
|
24984
25218
|
* Source file ID
|
|
24985
25219
|
*/
|
|
@@ -24996,6 +25230,7 @@
|
|
|
24996
25230
|
* Source file content
|
|
24997
25231
|
*/
|
|
24998
25232
|
content;
|
|
25233
|
+
inputSourceMap = null;
|
|
24999
25234
|
/**
|
|
25000
25235
|
* Constructor
|
|
25001
25236
|
* @param content
|
|
@@ -25177,7 +25412,7 @@
|
|
|
25177
25412
|
}
|
|
25178
25413
|
return acc + curr.val;
|
|
25179
25414
|
}
|
|
25180
|
-
return acc + renderValue(curr, options, cache, reducer
|
|
25415
|
+
return acc + renderValue(curr, options, cache, reducer);
|
|
25181
25416
|
}, cache),
|
|
25182
25417
|
errors,
|
|
25183
25418
|
stats: {
|
|
@@ -25487,7 +25722,7 @@
|
|
|
25487
25722
|
}
|
|
25488
25723
|
return acc + curr.val;
|
|
25489
25724
|
}
|
|
25490
|
-
return acc + renderValue(curr, options, cache, reducer
|
|
25725
|
+
return acc + renderValue(curr, options, cache, reducer);
|
|
25491
25726
|
};
|
|
25492
25727
|
}
|
|
25493
25728
|
switch (token.typ) {
|
|
@@ -26365,22 +26600,22 @@
|
|
|
26365
26600
|
return token.val;
|
|
26366
26601
|
case exports.EnumToken.SupportsQueryUnaryConditionTokenType:
|
|
26367
26602
|
case exports.EnumToken.WhenElseUnaryConditionTokenType:
|
|
26368
|
-
return (renderValue(token.l, options, cache, reducer
|
|
26603
|
+
return (renderValue(token.l, options, cache, reducer) +
|
|
26369
26604
|
" " +
|
|
26370
|
-
token.r.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer
|
|
26605
|
+
token.r.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer), ""));
|
|
26371
26606
|
case exports.EnumToken.SupportsQueryConditionTokenType:
|
|
26372
26607
|
case exports.EnumToken.WhenElseQueryConditionTokenType:
|
|
26373
|
-
return (token.l.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer
|
|
26608
|
+
return (token.l.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer), "") +
|
|
26374
26609
|
" " +
|
|
26375
|
-
renderValue(token.op, options, cache, reducer
|
|
26610
|
+
renderValue(token.op, options, cache, reducer) +
|
|
26376
26611
|
" " +
|
|
26377
|
-
token.r.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer
|
|
26612
|
+
token.r.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer), ""));
|
|
26378
26613
|
case exports.EnumToken.IfConditionTokenType:
|
|
26379
26614
|
return token.l.length == 0
|
|
26380
26615
|
? ""
|
|
26381
|
-
: token.l.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer
|
|
26616
|
+
: token.l.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer), "") +
|
|
26382
26617
|
":" +
|
|
26383
|
-
token.r.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer
|
|
26618
|
+
token.r.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer), "");
|
|
26384
26619
|
case exports.EnumToken.IfElseConditionTokenType:
|
|
26385
26620
|
return renderValue(token.l) + renderValue(token.r);
|
|
26386
26621
|
case exports.EnumToken.DeclarationNodeType:
|
|
@@ -26388,7 +26623,7 @@
|
|
|
26388
26623
|
":" +
|
|
26389
26624
|
(options.minify ? filterValues(token.val) : token.val).reduce((acc, curr) => acc + renderValue(curr, options, cache), ""));
|
|
26390
26625
|
case exports.EnumToken.MediaQueryUnaryFeatureTokenType:
|
|
26391
|
-
return (renderValue(token.l, options, cache, reducer
|
|
26626
|
+
return (renderValue(token.l, options, cache, reducer) +
|
|
26392
26627
|
" " +
|
|
26393
26628
|
token.r.reduce((acc, curr) => acc + renderValue(curr, options, cache), ""));
|
|
26394
26629
|
case exports.EnumToken.MediaQueryConditionTokenType: {
|
|
@@ -26400,16 +26635,16 @@
|
|
|
26400
26635
|
token.op.typ == exports.EnumToken.GteTokenType
|
|
26401
26636
|
? ""
|
|
26402
26637
|
: " ";
|
|
26403
|
-
return (token.l.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer
|
|
26638
|
+
return (token.l.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer), "") +
|
|
26404
26639
|
indent +
|
|
26405
|
-
renderValue(token.op, options, cache, reducer
|
|
26640
|
+
renderValue(token.op, options, cache, reducer) +
|
|
26406
26641
|
indent +
|
|
26407
26642
|
token.r.reduce((acc, curr) => acc + renderValue(curr, options, cache), ""));
|
|
26408
26643
|
}
|
|
26409
26644
|
case exports.EnumToken.MediaRangeQueryTokenType:
|
|
26410
26645
|
return (token.l.reduce((acc, curr) => acc + renderValue(curr, options, cache), "") +
|
|
26411
26646
|
renderValue(token.op1) +
|
|
26412
|
-
token.val.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer
|
|
26647
|
+
token.val.reduce((acc, curr) => acc + renderValue(curr, options, cache, reducer), "") +
|
|
26413
26648
|
renderValue(token.op2) +
|
|
26414
26649
|
token.r.reduce((acc, curr) => acc + renderValue(curr, options, cache), ""));
|
|
26415
26650
|
case exports.EnumToken.MediaFeatureTokenType:
|
|
@@ -26434,8 +26669,8 @@
|
|
|
26434
26669
|
console.debug({ token });
|
|
26435
26670
|
throw new Error(`Unsupported token type for ${exports.EnumToken[token.typ]}`);
|
|
26436
26671
|
}
|
|
26437
|
-
errors?.push({ action: "ignore", message: `render: unexpected token ${JSON.stringify(token, null, 1)}` });
|
|
26438
|
-
return "";
|
|
26672
|
+
// errors?.push({ action: "ignore", message: `render: unexpected token ${JSON.stringify(token, null, 1)}` });
|
|
26673
|
+
// return "";
|
|
26439
26674
|
}
|
|
26440
26675
|
/**
|
|
26441
26676
|
* Remove whitespace tokens that are not needed
|
|
@@ -28879,24 +29114,6 @@
|
|
|
28879
29114
|
if (tokens[index].chi[l].typ === exports.EnumToken.StringTokenType) {
|
|
28880
29115
|
break;
|
|
28881
29116
|
}
|
|
28882
|
-
// else if ((tokens[index] as FunctionToken).chi[l].typ === EnumToken.IdenTokenType) {
|
|
28883
|
-
// let m: number = l + 1;
|
|
28884
|
-
// while (
|
|
28885
|
-
// (tokens[index] as FunctionToken).chi[m]?.typ === EnumToken.ClassSelectorTokenType
|
|
28886
|
-
// ) {
|
|
28887
|
-
// Object.assign((tokens[index] as FunctionToken).chi[l], {
|
|
28888
|
-
// typ: EnumToken.UrlTokenTokenType,
|
|
28889
|
-
// val:
|
|
28890
|
-
// ((tokens[index] as FunctionToken).chi[l] as IdentToken | UrlToken).val +
|
|
28891
|
-
// ((tokens[index] as FunctionToken).chi[m] as ClassSelectorToken).val,
|
|
28892
|
-
// });
|
|
28893
|
-
// (tokens[index] as FunctionToken).chi[l][LOCEND] = (
|
|
28894
|
-
// tokens[index] as FunctionToken
|
|
28895
|
-
// ).chi[m][LOCEND];
|
|
28896
|
-
// (tokens[index] as FunctionToken).chi.splice(m, 1);
|
|
28897
|
-
// }
|
|
28898
|
-
// break;
|
|
28899
|
-
// }
|
|
28900
29117
|
}
|
|
28901
29118
|
if (tokens[index].chi[l]?.typ === exports.EnumToken.StringTokenType &&
|
|
28902
29119
|
/^[a-zA-Z0-0/_.-]+$/.test(tokens[index].chi[l].val.slice(1, -1))) {
|
|
@@ -33147,7 +33364,7 @@
|
|
|
33147
33364
|
atRule[LOCEND] = (stream.at(-1) ?? atRule)[LOCEND];
|
|
33148
33365
|
// @ts-expect-error
|
|
33149
33366
|
return Object.assign(atRule, {
|
|
33150
|
-
typ:
|
|
33367
|
+
typ: exports.EnumToken.AtRuleNodeType,
|
|
33151
33368
|
val: renderTokens(trimArray(stream), options),
|
|
33152
33369
|
});
|
|
33153
33370
|
}
|
|
@@ -33155,12 +33372,12 @@
|
|
|
33155
33372
|
return null;
|
|
33156
33373
|
}
|
|
33157
33374
|
atRule[TOKENS] = stream;
|
|
33158
|
-
atRule[STATE] = exports.EnumAstNodeStatus.Validated;
|
|
33375
|
+
atRule[STATE] = success ? exports.EnumAstNodeStatus.Validated : exports.EnumAstNodeStatus.Invalid;
|
|
33159
33376
|
atRule[ERRORS] = [];
|
|
33160
33377
|
atRule[LOCEND] = (stream.at(-1) ?? atRule)[LOCEND];
|
|
33161
33378
|
// @ts-expect-error
|
|
33162
33379
|
return Object.assign(atRule, {
|
|
33163
|
-
typ:
|
|
33380
|
+
typ: exports.EnumToken.AtRuleNodeType,
|
|
33164
33381
|
val: renderTokens(trimArray(stream), options),
|
|
33165
33382
|
});
|
|
33166
33383
|
}
|
|
@@ -33718,9 +33935,9 @@
|
|
|
33718
33935
|
let result = null;
|
|
33719
33936
|
if (syntax == null) {
|
|
33720
33937
|
// check matching '(' and ')'
|
|
33721
|
-
// check commas , or ,,
|
|
33722
|
-
// check colon :
|
|
33723
|
-
// check or and and
|
|
33938
|
+
// check commas ',' or ',,'
|
|
33939
|
+
// check colon ':'
|
|
33940
|
+
// check 'or' and 'and'
|
|
33724
33941
|
result = matchGenericSyntax(stream, options);
|
|
33725
33942
|
if (result.errors.length > 0) {
|
|
33726
33943
|
for (const error of result.errors) {
|