@tbela99/css-parser 0.4.1 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -179,7 +179,7 @@
179
179
  }
180
180
  };
181
181
  const colorFuncColorSpace = ['srgb', 'srgb-linear', 'display-p3', 'prophoto-rgb', 'a98-rgb', 'rec2020', 'xyz', 'xyz-d65', 'xyz-d50'];
182
- const powerlessColorComponent = { typ: exports.EnumToken.IdenTokenType, val: 'none' };
182
+ ({ typ: exports.EnumToken.IdenTokenType, val: 'none' });
183
183
  const D50 = [0.3457 / 0.3585, 1.00000, (1.0 - 0.3457 - 0.3585) / 0.3585];
184
184
  const k = Math.pow(29, 3) / Math.pow(3, 3);
185
185
  const e = Math.pow(6, 3) / Math.pow(29, 3);
@@ -559,42 +559,6 @@
559
559
  return alpha == null ? [l, c, h] : [l, c, h, alpha];
560
560
  }
561
561
 
562
- function eq(a, b) {
563
- if (a == null || b == null) {
564
- return a == b;
565
- }
566
- if (typeof a != 'object' || typeof b != 'object') {
567
- return a === b;
568
- }
569
- if (Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) {
570
- return false;
571
- }
572
- if (Array.isArray(a)) {
573
- if (a.length != b.length) {
574
- return false;
575
- }
576
- let i = 0;
577
- for (; i < a.length; i++) {
578
- if (!eq(a[i], b[i])) {
579
- return false;
580
- }
581
- }
582
- return true;
583
- }
584
- const k1 = Object.keys(a);
585
- const k2 = Object.keys(b);
586
- if (k1.length != k2.length) {
587
- return false;
588
- }
589
- let key;
590
- for (key of k1) {
591
- if (!(key in b) || !eq(a[key], b[key])) {
592
- return false;
593
- }
594
- }
595
- return true;
596
- }
597
-
598
562
  function hex2oklch(token) {
599
563
  // @ts-ignore
600
564
  return lab2lchvalues(...hex2oklab(token));
@@ -644,7 +608,7 @@
644
608
  // @ts-ignore
645
609
  t = components[3];
646
610
  // @ts-ignore
647
- const alpha = t == null || eq(t, powerlessColorComponent) ? 1 : getNumber(t);
611
+ const alpha = t == null || (t.typ == exports.EnumToken.IdenTokenType && t.val == 'none') ? 1 : getNumber(t);
648
612
  return [l, c, h, alpha];
649
613
  }
650
614
 
@@ -703,7 +667,7 @@
703
667
  // @ts-ignore
704
668
  t = components[3];
705
669
  // @ts-ignore
706
- const alpha = t == null || eq(t, powerlessColorComponent) ? 1 : getNumber(t);
670
+ const alpha = t == null || (t.typ == exports.EnumToken.IdenTokenType && t.val == 'none') ? 1 : getNumber(t);
707
671
  const rgb = [l, a, b];
708
672
  if (alpha != 1 && alpha != null) {
709
673
  rgb.push(alpha);
@@ -908,10 +872,7 @@
908
872
  return null;
909
873
  }
910
874
  function rgb2srgb(token) {
911
- return getComponents(token).map((t, index) => index == 3 ? (eq(t, {
912
- typ: exports.EnumToken.IdenTokenType,
913
- val: 'none'
914
- }) ? 1 : getNumber(t)) : (t.typ == exports.EnumToken.PercentageTokenType ? 255 : 1) * getNumber(t) / 255);
875
+ return getComponents(token).map((t, index) => index == 3 ? ((t.typ == exports.EnumToken.IdenTokenType && t.val == 'none') ? 1 : getNumber(t)) : (t.typ == exports.EnumToken.PercentageTokenType ? 255 : 1) * getNumber(t) / 255);
915
876
  }
916
877
  function hex2srgb(token) {
917
878
  const value = expandHexValue(token.kin == 'lit' ? COLORS_NAMES[token.val.toLowerCase()] : token.val);
@@ -1198,7 +1159,7 @@
1198
1159
  t = chi[3];
1199
1160
  // @ts-ignore
1200
1161
  let a = null;
1201
- if (t != null && !eq(t, { typ: exports.EnumToken.IdenTokenType, val: 'none' })) {
1162
+ if (t != null && !(t.typ == exports.EnumToken.IdenTokenType && t.val == 'none')) {
1202
1163
  // @ts-ignore
1203
1164
  a = getNumber(t) / 255;
1204
1165
  }
@@ -1284,7 +1245,7 @@
1284
1245
  function rgb2hwb(token) {
1285
1246
  // @ts-ignore
1286
1247
  return srgb2hwb(...getComponents(token).map((t, index) => {
1287
- if (index == 3 && eq(t, { typ: exports.EnumToken.IdenTokenType, val: 'none' })) {
1248
+ if (index == 3 && t.typ == exports.EnumToken.IdenTokenType && t.val == 'none') {
1288
1249
  return 1;
1289
1250
  }
1290
1251
  return getNumber(t) / 255;
@@ -1293,7 +1254,7 @@
1293
1254
  function hsl2hwb(token) {
1294
1255
  // @ts-ignore
1295
1256
  return hsl2hwbvalues(...getComponents(token).map((t, index) => {
1296
- if (index == 3 && eq(t, { typ: exports.EnumToken.IdenTokenType, val: 'none' })) {
1257
+ if (index == 3 && (t.typ == exports.EnumToken.IdenTokenType && t.val == 'none')) {
1297
1258
  return 1;
1298
1259
  }
1299
1260
  if (index == 0) {
@@ -1914,10 +1875,47 @@
1914
1875
  case 'lch':
1915
1876
  values.push(...lch2srgb(token));
1916
1877
  break;
1917
- case 'color':
1878
+ case 'oklch':
1918
1879
  // @ts-ignore
1919
1880
  values.push(...srgb2oklch(...color2srgbvalues(token)));
1920
1881
  break;
1882
+ case 'color':
1883
+ const val = color2srgbvalues(token);
1884
+ switch (to) {
1885
+ case 'srgb':
1886
+ values.push(...val);
1887
+ break;
1888
+ case 'srgb-linear':
1889
+ // @ts-ignore
1890
+ values.push(...srgb2lsrgbvalues(...val));
1891
+ break;
1892
+ case 'display-p3':
1893
+ // @ts-ignore
1894
+ values.push(...srgb2p3values(...val));
1895
+ break;
1896
+ case 'prophoto-rgb':
1897
+ // @ts-ignore
1898
+ values.push(...srgb2prophotorgbvalues(...val));
1899
+ break;
1900
+ case 'a98-rgb':
1901
+ // @ts-ignore
1902
+ values.push(...srgb2a98values(...val));
1903
+ break;
1904
+ case 'rec2020':
1905
+ // @ts-ignore
1906
+ values.push(...srgb2rec2020values(...val));
1907
+ break;
1908
+ case 'xyz':
1909
+ case 'xyz-d65':
1910
+ // @ts-ignore
1911
+ values.push(...srgb2xyz(...val));
1912
+ break;
1913
+ case 'xyz-d50':
1914
+ // @ts-ignore
1915
+ values.push(...(XYZ_D65_to_D50(...srgb2xyz(...val))));
1916
+ break;
1917
+ }
1918
+ break;
1921
1919
  }
1922
1920
  if (values.length > 0) {
1923
1921
  return values2colortoken(values, to);
@@ -2191,10 +2189,10 @@
2191
2189
  }
2192
2190
  const components1 = getComponents(color1);
2193
2191
  const components2 = getComponents(color2);
2194
- if (eq(components1[3], powerlessColorComponent) && values2.length == 4) {
2192
+ if ((components1[3] != null && components1[3].typ == exports.EnumToken.IdenTokenType && components1[3].val == 'none') && values2.length == 4) {
2195
2193
  values1[3] = values2[3];
2196
2194
  }
2197
- if (eq(components2[3], powerlessColorComponent) && values1.length == 4) {
2195
+ if ((components2[3] != null && components2[3].typ == exports.EnumToken.IdenTokenType && components2[3].val == 'none') && values1.length == 4) {
2198
2196
  values2[3] = values1[3];
2199
2197
  }
2200
2198
  const p1 = getNumber(percentage1);
@@ -2306,13 +2304,13 @@
2306
2304
  const lchSpaces = ['lch', 'oklch'];
2307
2305
  // powerless
2308
2306
  if (lchSpaces.includes(color1.kin) || lchSpaces.includes(colorSpace.val)) {
2309
- if (eq(components1[2], powerlessColorComponent) || values1[2] == 0) {
2307
+ if ((components1[2].typ == exports.EnumToken.IdenTokenType && components1[2].val == 'none') || values1[2] == 0) {
2310
2308
  values1[2] = values2[2];
2311
2309
  }
2312
2310
  }
2313
2311
  // powerless
2314
2312
  if (lchSpaces.includes(color1.kin) || lchSpaces.includes(colorSpace.val)) {
2315
- if (eq(components2[2], powerlessColorComponent) || values2[2] == 0) {
2313
+ if ((components2[2].typ == exports.EnumToken.IdenTokenType && components2[2].val == 'none') || values2[2] == 0) {
2316
2314
  values2[2] = values1[2];
2317
2315
  }
2318
2316
  }
@@ -2743,10 +2741,7 @@
2743
2741
  [names[1]]: getValue(g, converted, names[1]), // string,
2744
2742
  [names[2]]: getValue(b, converted, names[2]),
2745
2743
  // @ts-ignore
2746
- alpha: alpha == null || eq(alpha, {
2747
- typ: exports.EnumToken.IdenTokenType,
2748
- val: 'none'
2749
- }) ? {
2744
+ alpha: alpha == null || (alpha.typ == exports.EnumToken.IdenTokenType && alpha.val == 'none') ? {
2750
2745
  typ: exports.EnumToken.NumberTokenType,
2751
2746
  val: '1'
2752
2747
  } : (alpha.typ == exports.EnumToken.PercentageTokenType ? {
@@ -2759,7 +2754,7 @@
2759
2754
  [names[1]]: getValue(gExp, converted, names[1]),
2760
2755
  [names[2]]: getValue(bExp, converted, names[2]),
2761
2756
  // @ts-ignore
2762
- alpha: getValue(aExp == null || eq(aExp, { typ: exports.EnumToken.IdenTokenType, val: 'none' }) ? {
2757
+ alpha: getValue(aExp == null || (aExp.typ == exports.EnumToken.IdenTokenType && aExp.val == 'none') ? {
2763
2758
  typ: exports.EnumToken.NumberTokenType,
2764
2759
  val: '1'
2765
2760
  } : aExp)
@@ -2997,6 +2992,19 @@
2997
2992
  removeComments: false,
2998
2993
  }), sourcemap: false, convertColor: true, expandNestingRules: false, preserveLicense: false, ...options
2999
2994
  };
2995
+ if (options.withParents) {
2996
+ // @ts-ignore
2997
+ let parent = data.parent;
2998
+ // @ts-ignore
2999
+ while (data.parent != null) {
3000
+ // @ts-ignore
3001
+ parent = { ...data.parent, chi: [{ ...data }] };
3002
+ // @ts-ignore
3003
+ parent.parent = data.parent.parent;
3004
+ // @ts-ignore
3005
+ data = parent;
3006
+ }
3007
+ }
3000
3008
  const startTime = performance.now();
3001
3009
  const errors = [];
3002
3010
  const sourcemap = options.sourcemap ? new SourceMap : null;
@@ -3063,7 +3071,7 @@
3063
3071
  return `${data.nam}:${options.indent}${data.val.reduce(reducer, '')}`;
3064
3072
  case exports.EnumToken.CommentNodeType:
3065
3073
  case exports.EnumToken.CDOCOMMNodeType:
3066
- if (data.val.startsWith('# sourceMappingURL=')) {
3074
+ if (data.val.startsWith('/*# sourceMappingURL=')) {
3067
3075
  // ignore sourcemap
3068
3076
  return '';
3069
3077
  }
@@ -3075,12 +3083,12 @@
3075
3083
  return css;
3076
3084
  }
3077
3085
  if (css === '') {
3078
- if (sourcemap != null) {
3086
+ if (sourcemap != null && node.loc != null) {
3079
3087
  updateSourceMap(node, options, cache, sourcemap, position, str);
3080
3088
  }
3081
3089
  return str;
3082
3090
  }
3083
- if (sourcemap != null) {
3091
+ if (sourcemap != null && node.loc != null) {
3084
3092
  update(position, options.newLine);
3085
3093
  updateSourceMap(node, options, cache, sourcemap, position, str);
3086
3094
  }
@@ -3512,14 +3520,14 @@
3512
3520
  // https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-ident-token
3513
3521
  // '\\'
3514
3522
  const REVERSE_SOLIDUS = 0x5c;
3515
- const dimensionUnits = [
3523
+ const dimensionUnits = new Set([
3516
3524
  'q', 'cap', 'ch', 'cm', 'cqb', 'cqh', 'cqi', 'cqmax', 'cqmin', 'cqw', 'dvb',
3517
3525
  'dvh', 'dvi', 'dvmax', 'dvmin', 'dvw', 'em', 'ex', 'ic', 'in', 'lh', 'lvb',
3518
3526
  'lvh', 'lvi', 'lvmax', 'lvw', 'mm', 'pc', 'pt', 'px', 'rem', 'rlh', 'svb',
3519
3527
  'svh', 'svi', 'svmin', 'svw', 'vb', 'vh', 'vi', 'vmax', 'vmin', 'vw'
3520
- ];
3528
+ ]);
3521
3529
  function isLength(dimension) {
3522
- return 'unit' in dimension && dimensionUnits.includes(dimension.unit.toLowerCase());
3530
+ return 'unit' in dimension && dimensionUnits.has(dimension.unit.toLowerCase());
3523
3531
  }
3524
3532
  function isResolution(dimension) {
3525
3533
  return 'unit' in dimension && ['dpi', 'dpcm', 'dppx', 'x'].includes(dimension.unit.toLowerCase());
@@ -3579,7 +3587,7 @@
3579
3587
  for (let i = 1; i < children.length - 2; i++) {
3580
3588
  if (children[i].typ == exports.EnumToken.IdenTokenType) {
3581
3589
  if (children[i].val != 'none' &&
3582
- !(isRelative && ['alpha', 'r', 'g', 'b'].includes(children[i].val) || isColorspace(children[i]))) {
3590
+ !(isRelative && ['alpha', 'r', 'g', 'b', 'x', 'y', 'z'].includes(children[i].val) || isColorspace(children[i]))) {
3583
3591
  return false;
3584
3592
  }
3585
3593
  }
@@ -3587,10 +3595,14 @@
3587
3595
  return false;
3588
3596
  }
3589
3597
  }
3598
+ if (children.length == 4 || (isRelative && children.length == 6)) {
3599
+ return true;
3600
+ }
3590
3601
  if (children.length == 8 || children.length == 6) {
3591
3602
  const sep = children.at(-2);
3592
3603
  const alpha = children.at(-1);
3593
- if (sep.typ != exports.EnumToken.LiteralTokenType || sep.val != '/') {
3604
+ // @ts-ignore
3605
+ if ((children.length > 6 || !isRelative) && sep.typ != exports.EnumToken.LiteralTokenType || sep.val != '/') {
3594
3606
  return false;
3595
3607
  }
3596
3608
  if (alpha.typ == exports.EnumToken.IdenTokenType && alpha.val != 'none') {
@@ -4292,18 +4304,18 @@
4292
4304
  "initial"
4293
4305
  ],
4294
4306
  "default": [
4295
- "0",
4296
- "0 1",
4297
- "0 auto",
4298
- "0 1 auto"
4299
4307
  ],
4308
+ mapping: {
4309
+ "0 1 auto": "initial",
4310
+ "0 0 auto": "none",
4311
+ "1 1 auto": "auto"
4312
+ },
4300
4313
  properties: {
4301
4314
  "flex-grow": {
4302
4315
  required: true,
4303
4316
  keywords: [
4304
4317
  ],
4305
4318
  "default": [
4306
- "0"
4307
4319
  ],
4308
4320
  types: [
4309
4321
  "Number"
@@ -4313,7 +4325,6 @@
4313
4325
  keywords: [
4314
4326
  ],
4315
4327
  "default": [
4316
- "1"
4317
4328
  ],
4318
4329
  types: [
4319
4330
  "Number"
@@ -4329,7 +4340,6 @@
4329
4340
  "auto"
4330
4341
  ],
4331
4342
  "default": [
4332
- "auto"
4333
4343
  ],
4334
4344
  types: [
4335
4345
  "Length",
@@ -4989,8 +4999,8 @@
4989
4999
  "Number"
4990
5000
  ],
4991
5001
  "default": [
4992
- "normal",
4993
- "400"
5002
+ "400",
5003
+ "normal"
4994
5004
  ],
4995
5005
  keywords: [
4996
5006
  "normal",
@@ -5345,6 +5355,8 @@
5345
5355
  left: "0",
5346
5356
  top: "0",
5347
5357
  center: "50%",
5358
+ "center center": "50%",
5359
+ "50% 50%": "50%",
5348
5360
  bottom: "100%",
5349
5361
  right: "100%"
5350
5362
  },
@@ -6029,194 +6041,229 @@
6029
6041
  exports.EnumToken.BadUrlTokenType,
6030
6042
  exports.EnumToken.BadStringTokenType
6031
6043
  ];
6044
+ const enumTokenHints = new Set([
6045
+ exports.EnumToken.WhitespaceTokenType, exports.EnumToken.SemiColonTokenType, exports.EnumToken.ColonTokenType, exports.EnumToken.BlockStartTokenType,
6046
+ exports.EnumToken.BlockStartTokenType, exports.EnumToken.AttrStartTokenType, exports.EnumToken.AttrEndTokenType, exports.EnumToken.StartParensTokenType, exports.EnumToken.EndParensTokenType,
6047
+ exports.EnumToken.CommaTokenType, exports.EnumToken.GtTokenType, exports.EnumToken.LtTokenType, exports.EnumToken.GteTokenType, exports.EnumToken.LteTokenType, exports.EnumToken.CommaTokenType,
6048
+ exports.EnumToken.StartMatchTokenType, exports.EnumToken.EndMatchTokenType, exports.EnumToken.IncludeMatchTokenType, exports.EnumToken.DashMatchTokenType, exports.EnumToken.ContainMatchTokenType,
6049
+ exports.EnumToken.EOFTokenType
6050
+ ]);
6032
6051
  const webkitPseudoAliasMap = {
6033
6052
  '-webkit-autofill': 'autofill'
6034
6053
  };
6054
+ function reject(reason) {
6055
+ throw new Error(reason ?? 'Parsing aborted');
6056
+ }
6035
6057
  async function doParse(iterator, options = {}) {
6036
- return new Promise(async (resolve, reject) => {
6037
- if (options.signal != null) {
6038
- options.signal.addEventListener('abort', reject);
6039
- }
6040
- options = {
6041
- src: '',
6042
- sourcemap: false,
6043
- minify: true,
6044
- parseColor: true,
6045
- nestingRules: false,
6046
- resolveImport: false,
6047
- resolveUrls: false,
6048
- removeCharset: false,
6049
- removeEmpty: true,
6050
- removeDuplicateDeclarations: true,
6051
- computeShorthand: true,
6052
- computeCalcExpression: true,
6053
- inlineCssVariables: false,
6054
- ...options
6055
- };
6056
- if (options.expandNestingRules) {
6057
- options.nestingRules = false;
6058
- }
6059
- if (options.resolveImport) {
6060
- options.resolveUrls = true;
6061
- }
6062
- const startTime = performance.now();
6063
- const errors = [];
6064
- const src = options.src;
6065
- const stack = [];
6066
- const stats = {
6067
- bytesIn: 0,
6068
- importedBytesIn: 0,
6069
- parse: `0ms`,
6070
- minify: `0ms`,
6071
- total: `0ms`
6072
- };
6073
- let ast = {
6074
- typ: exports.EnumToken.StyleSheetNodeType,
6075
- chi: []
6058
+ // return new Promise(async (resolve, reject) => {
6059
+ if (options.signal != null) {
6060
+ options.signal.addEventListener('abort', reject);
6061
+ }
6062
+ options = {
6063
+ src: '',
6064
+ sourcemap: false,
6065
+ minify: true,
6066
+ parseColor: true,
6067
+ nestingRules: false,
6068
+ resolveImport: false,
6069
+ resolveUrls: false,
6070
+ removeCharset: true,
6071
+ removeEmpty: true,
6072
+ removeDuplicateDeclarations: true,
6073
+ computeShorthand: true,
6074
+ computeCalcExpression: true,
6075
+ inlineCssVariables: false,
6076
+ setParent: true,
6077
+ ...options
6078
+ };
6079
+ if (options.expandNestingRules) {
6080
+ options.nestingRules = false;
6081
+ }
6082
+ if (options.resolveImport) {
6083
+ options.resolveUrls = true;
6084
+ }
6085
+ const startTime = performance.now();
6086
+ const errors = [];
6087
+ const src = options.src;
6088
+ const stack = [];
6089
+ const stats = {
6090
+ bytesIn: 0,
6091
+ importedBytesIn: 0,
6092
+ parse: `0ms`,
6093
+ minify: `0ms`,
6094
+ total: `0ms`
6095
+ };
6096
+ let ast = {
6097
+ typ: exports.EnumToken.StyleSheetNodeType,
6098
+ chi: []
6099
+ };
6100
+ let tokens = [];
6101
+ let map = new Map;
6102
+ let context = ast;
6103
+ if (options.sourcemap) {
6104
+ ast.loc = {
6105
+ sta: {
6106
+ ind: 0,
6107
+ lin: 1,
6108
+ col: 1
6109
+ },
6110
+ src: ''
6076
6111
  };
6077
- let tokens = [];
6078
- let map = new Map;
6079
- let context = ast;
6080
- if (options.sourcemap) {
6081
- ast.loc = {
6082
- sta: {
6083
- ind: 0,
6084
- lin: 1,
6085
- col: 1
6086
- },
6087
- src: ''
6088
- };
6112
+ }
6113
+ const iter = tokenize(iterator);
6114
+ let item;
6115
+ while (item = iter.next().value) {
6116
+ stats.bytesIn = item.bytesIn;
6117
+ //
6118
+ // doParse error
6119
+ if (item.hint != null && BadTokensTypes.includes(item.hint)) {
6120
+ // bad token
6121
+ continue;
6089
6122
  }
6090
- const iter = tokenize(iterator);
6091
- let item;
6092
- while (item = iter.next().value) {
6093
- stats.bytesIn = item.bytesIn;
6094
- //
6095
- // doParse error
6096
- if (item.hint != null && BadTokensTypes.includes(item.hint)) {
6097
- // bad token
6098
- continue;
6099
- }
6100
- if (item.hint != exports.EnumToken.EOFTokenType) {
6101
- tokens.push(item);
6102
- }
6103
- if (item.token == ';' || item.token == '{') {
6104
- let node = await parseNode(tokens, context, stats, options, errors, src, map);
6105
- if (node != null) {
6106
- stack.push(node);
6107
- // @ts-ignore
6108
- context = node;
6109
- }
6110
- else if (item.token == '{') {
6111
- // node == null
6112
- // consume and throw away until the closing '}' or EOF
6113
- let inBlock = 1;
6114
- do {
6115
- item = iter.next().value;
6116
- if (item == null) {
6117
- break;
6118
- }
6119
- if (item.token == '{') {
6120
- inBlock++;
6121
- }
6122
- else if (item.token == '}') {
6123
- inBlock--;
6124
- }
6125
- } while (inBlock != 0);
6126
- }
6127
- tokens = [];
6128
- map = new Map;
6129
- }
6130
- else if (item.token == '}') {
6131
- await parseNode(tokens, context, stats, options, errors, src, map);
6132
- const previousNode = stack.pop();
6133
- // @ts-ignore
6134
- context = stack[stack.length - 1] || ast;
6123
+ if (item.hint != exports.EnumToken.EOFTokenType) {
6124
+ tokens.push(item);
6125
+ }
6126
+ if (item.token == ';' || item.token == '{') {
6127
+ let node = await parseNode(tokens, context, stats, options, errors, src, map);
6128
+ if (node != null) {
6129
+ stack.push(node);
6135
6130
  // @ts-ignore
6136
- if (options.removeEmpty && previousNode != null && previousNode.chi.length == 0 && context.chi[context.chi.length - 1] == previousNode) {
6137
- context.chi.pop();
6138
- }
6139
- tokens = [];
6140
- map = new Map;
6131
+ context = node;
6132
+ }
6133
+ else if (item.token == '{') {
6134
+ // node == null
6135
+ // consume and throw away until the closing '}' or EOF
6136
+ let inBlock = 1;
6137
+ do {
6138
+ item = iter.next().value;
6139
+ if (item == null) {
6140
+ break;
6141
+ }
6142
+ if (item.token == '{') {
6143
+ inBlock++;
6144
+ }
6145
+ else if (item.token == '}') {
6146
+ inBlock--;
6147
+ }
6148
+ } while (inBlock != 0);
6141
6149
  }
6150
+ tokens = [];
6151
+ map = new Map;
6142
6152
  }
6143
- if (tokens.length > 0) {
6153
+ else if (item.token == '}') {
6144
6154
  await parseNode(tokens, context, stats, options, errors, src, map);
6145
- }
6146
- while (stack.length > 0 && context != ast) {
6147
6155
  const previousNode = stack.pop();
6148
6156
  // @ts-ignore
6149
- context = stack[stack.length - 1] ?? ast;
6157
+ context = stack[stack.length - 1] || ast;
6150
6158
  // @ts-ignore
6151
6159
  if (options.removeEmpty && previousNode != null && previousNode.chi.length == 0 && context.chi[context.chi.length - 1] == previousNode) {
6152
6160
  context.chi.pop();
6153
- continue;
6154
6161
  }
6155
- break;
6162
+ tokens = [];
6163
+ map = new Map;
6156
6164
  }
6157
- const endParseTime = performance.now();
6158
- if (options.expandNestingRules) {
6159
- ast = expand(ast);
6165
+ }
6166
+ if (tokens.length > 0) {
6167
+ await parseNode(tokens, context, stats, options, errors, src, map);
6168
+ }
6169
+ while (stack.length > 0 && context != ast) {
6170
+ const previousNode = stack.pop();
6171
+ // @ts-ignore
6172
+ context = stack[stack.length - 1] ?? ast;
6173
+ // @ts-ignore
6174
+ if (options.removeEmpty && previousNode != null && previousNode.chi.length == 0 && context.chi[context.chi.length - 1] == previousNode) {
6175
+ context.chi.pop();
6176
+ continue;
6160
6177
  }
6161
- if (options.visitor != null) {
6162
- for (const result of walk(ast)) {
6163
- if (result.node.typ == exports.EnumToken.DeclarationNodeType &&
6164
- // @ts-ignore
6165
- (typeof options.visitor.Declaration == 'function' || options.visitor.Declaration?.[result.node.nam] != null)) {
6166
- const callable = typeof options.visitor.Declaration == 'function' ? options.visitor.Declaration : options.visitor.Declaration[result.node.nam];
6167
- const results = await callable(result.node);
6168
- if (results == null || (Array.isArray(results) && results.length == 0)) {
6169
- continue;
6170
- }
6171
- // @ts-ignore
6172
- result.parent.chi.splice(result.parent.chi.indexOf(result.node), 1, ...(Array.isArray(results) ? results : [results]));
6178
+ break;
6179
+ }
6180
+ const endParseTime = performance.now();
6181
+ if (options.expandNestingRules) {
6182
+ ast = expand(ast);
6183
+ }
6184
+ if (options.visitor != null) {
6185
+ for (const result of walk(ast)) {
6186
+ if (result.node.typ == exports.EnumToken.DeclarationNodeType &&
6187
+ // @ts-ignore
6188
+ (typeof options.visitor.Declaration == 'function' || options.visitor.Declaration?.[result.node.nam] != null)) {
6189
+ const callable = typeof options.visitor.Declaration == 'function' ? options.visitor.Declaration : options.visitor.Declaration[result.node.nam];
6190
+ const results = await callable(result.node);
6191
+ if (results == null || (Array.isArray(results) && results.length == 0)) {
6192
+ continue;
6173
6193
  }
6174
- else if (options.visitor.Rule != null && result.node.typ == exports.EnumToken.RuleNodeType) {
6175
- const results = await options.visitor.Rule(result.node);
6176
- if (results == null || (Array.isArray(results) && results.length == 0)) {
6177
- continue;
6178
- }
6179
- // @ts-ignore
6180
- result.parent.chi.splice(result.parent.chi.indexOf(result.node), 1, ...(Array.isArray(results) ? results : [results]));
6194
+ // @ts-ignore
6195
+ result.parent.chi.splice(result.parent.chi.indexOf(result.node), 1, ...(Array.isArray(results) ? results : [results]));
6196
+ }
6197
+ else if (options.visitor.Rule != null && result.node.typ == exports.EnumToken.RuleNodeType) {
6198
+ const results = await options.visitor.Rule(result.node);
6199
+ if (results == null || (Array.isArray(results) && results.length == 0)) {
6200
+ continue;
6181
6201
  }
6182
- else if (options.visitor.AtRule != null &&
6183
- result.node.typ == exports.EnumToken.AtRuleNodeType &&
6184
- // @ts-ignore
6185
- (typeof options.visitor.AtRule == 'function' || options.visitor.AtRule?.[result.node.nam] != null)) {
6186
- const callable = typeof options.visitor.AtRule == 'function' ? options.visitor.AtRule : options.visitor.AtRule[result.node.nam];
6187
- const results = await callable(result.node);
6188
- if (results == null || (Array.isArray(results) && results.length == 0)) {
6189
- continue;
6190
- }
6191
- // @ts-ignore
6192
- result.parent.chi.splice(result.parent.chi.indexOf(result.node), 1, ...(Array.isArray(results) ? results : [results]));
6202
+ // @ts-ignore
6203
+ result.parent.chi.splice(result.parent.chi.indexOf(result.node), 1, ...(Array.isArray(results) ? results : [results]));
6204
+ }
6205
+ else if (options.visitor.AtRule != null &&
6206
+ result.node.typ == exports.EnumToken.AtRuleNodeType &&
6207
+ // @ts-ignore
6208
+ (typeof options.visitor.AtRule == 'function' || options.visitor.AtRule?.[result.node.nam] != null)) {
6209
+ const callable = typeof options.visitor.AtRule == 'function' ? options.visitor.AtRule : options.visitor.AtRule[result.node.nam];
6210
+ const results = await callable(result.node);
6211
+ if (results == null || (Array.isArray(results) && results.length == 0)) {
6212
+ continue;
6193
6213
  }
6214
+ // @ts-ignore
6215
+ result.parent.chi.splice(result.parent.chi.indexOf(result.node), 1, ...(Array.isArray(results) ? results : [results]));
6194
6216
  }
6195
6217
  }
6196
- if (options.minify) {
6197
- if (ast.chi.length > 0) {
6198
- minify(ast, options, true, errors, false);
6218
+ }
6219
+ if (options.minify) {
6220
+ if (ast.chi.length > 0) {
6221
+ minify(ast, options, true, errors, false);
6222
+ }
6223
+ }
6224
+ if (options.setParent) {
6225
+ const nodes = [ast];
6226
+ let node;
6227
+ while ((node = nodes.shift())) {
6228
+ // @ts-ignore
6229
+ if (node.chi.length > 0) {
6230
+ // @ts-ignore
6231
+ for (const child of node.chi) {
6232
+ if (child.parent != node) {
6233
+ Object.defineProperty(child, 'parent', { ...definedPropertySettings, value: node });
6234
+ }
6235
+ if ('chi' in child && child.chi.length > 0) {
6236
+ // @ts-ignore
6237
+ nodes.push(child);
6238
+ }
6239
+ }
6199
6240
  }
6200
6241
  }
6201
- const endTime = performance.now();
6202
- if (options.signal != null) {
6203
- options.signal.removeEventListener('abort', reject);
6242
+ }
6243
+ const endTime = performance.now();
6244
+ if (options.signal != null) {
6245
+ options.signal.removeEventListener('abort', reject);
6246
+ }
6247
+ stats.bytesIn += stats.importedBytesIn;
6248
+ return {
6249
+ ast,
6250
+ errors,
6251
+ stats: {
6252
+ ...stats,
6253
+ parse: `${(endParseTime - startTime).toFixed(2)}ms`,
6254
+ minify: `${(endTime - endParseTime).toFixed(2)}ms`,
6255
+ total: `${(endTime - startTime).toFixed(2)}ms`
6204
6256
  }
6205
- stats.bytesIn += stats.importedBytesIn;
6206
- resolve({
6207
- ast,
6208
- errors,
6209
- stats: {
6210
- ...stats,
6211
- parse: `${(endParseTime - startTime).toFixed(2)}ms`,
6212
- minify: `${(endTime - endParseTime).toFixed(2)}ms`,
6213
- total: `${(endTime - startTime).toFixed(2)}ms`
6214
- }
6215
- });
6216
- });
6257
+ };
6258
+ // });
6217
6259
  }
6218
6260
  async function parseNode(results, context, stats, options, errors, src, map) {
6219
- let tokens = results.map((t) => mapToken(t, map));
6261
+ let tokens = [];
6262
+ for (const t of results) {
6263
+ const node = getTokenType(t.token, t.hint);
6264
+ map.set(node, t.position);
6265
+ tokens.push(node);
6266
+ }
6220
6267
  let i;
6221
6268
  let loc;
6222
6269
  for (i = 0; i < tokens.length; i++) {
@@ -6324,12 +6371,16 @@
6324
6371
  }
6325
6372
  if (atRule.val == 'import') {
6326
6373
  // @ts-ignore
6327
- if (tokens[0].typ == exports.EnumToken.UrlFunctionTokenType && tokens[1].typ == exports.EnumToken.UrlTokenTokenType) {
6328
- tokens.shift();
6329
- // @ts-ignore
6330
- tokens[0].typ = exports.EnumToken.StringTokenType;
6331
- // @ts-ignore
6332
- tokens[0].val = `"${tokens[0].val}"`;
6374
+ if (tokens[0].typ == exports.EnumToken.UrlFunctionTokenType) {
6375
+ if (tokens[1].typ == exports.EnumToken.UrlTokenTokenType || tokens[1].typ == exports.EnumToken.StringTokenType) {
6376
+ tokens.shift();
6377
+ if (tokens[1].typ == exports.EnumToken.UrlTokenTokenType) {
6378
+ // @ts-ignore
6379
+ tokens[0].typ = exports.EnumToken.StringTokenType;
6380
+ // @ts-ignore
6381
+ tokens[0].val = `"${tokens[0].val}"`;
6382
+ }
6383
+ }
6333
6384
  }
6334
6385
  // @ts-ignore
6335
6386
  if (tokens[0].typ == exports.EnumToken.StringTokenType) {
@@ -6340,6 +6391,7 @@
6340
6391
  const root = await options.load(url, options.src).then((src) => {
6341
6392
  return doParse(src, Object.assign({}, options, {
6342
6393
  minify: false,
6394
+ setParent: false,
6343
6395
  // @ts-ignore
6344
6396
  src: options.resolve(url, options.src).absolute
6345
6397
  }));
@@ -6373,7 +6425,7 @@
6373
6425
  nam: renderToken(atRule, { removeComments: true }),
6374
6426
  val: raw.join('')
6375
6427
  };
6376
- Object.defineProperty(node, 'raw', { enumerable: false, configurable: true, writable: true, value: raw });
6428
+ Object.defineProperty(node, 'raw', { ...definedPropertySettings, value: raw });
6377
6429
  if (delim.typ == exports.EnumToken.BlockStartTokenType) {
6378
6430
  node.chi = [];
6379
6431
  }
@@ -6499,11 +6551,6 @@
6499
6551
  }
6500
6552
  }
6501
6553
  }
6502
- function mapToken(token, map) {
6503
- const node = getTokenType(token.token, token.hint);
6504
- map.set(node, token.position);
6505
- return node;
6506
- }
6507
6554
  function parseString(src, options = { location: false }) {
6508
6555
  return parseTokens([...tokenize(src)].map(t => {
6509
6556
  const token = getTokenType(t.token, t.hint);
@@ -6518,13 +6565,7 @@
6518
6565
  throw new Error('empty string?');
6519
6566
  }
6520
6567
  if (hint != null) {
6521
- return ([
6522
- exports.EnumToken.WhitespaceTokenType, exports.EnumToken.SemiColonTokenType, exports.EnumToken.ColonTokenType, exports.EnumToken.BlockStartTokenType,
6523
- exports.EnumToken.BlockStartTokenType, exports.EnumToken.AttrStartTokenType, exports.EnumToken.AttrEndTokenType, exports.EnumToken.StartParensTokenType, exports.EnumToken.EndParensTokenType,
6524
- exports.EnumToken.CommaTokenType, exports.EnumToken.GtTokenType, exports.EnumToken.LtTokenType, exports.EnumToken.GteTokenType, exports.EnumToken.LteTokenType, exports.EnumToken.CommaTokenType,
6525
- exports.EnumToken.StartMatchTokenType, exports.EnumToken.EndMatchTokenType, exports.EnumToken.IncludeMatchTokenType, exports.EnumToken.DashMatchTokenType, exports.EnumToken.ContainMatchTokenType,
6526
- exports.EnumToken.EOFTokenType
6527
- ].includes(hint) ? { typ: hint } : { typ: hint, val });
6568
+ return enumTokenHints.has(hint) ? { typ: hint } : { typ: hint, val };
6528
6569
  }
6529
6570
  if (val == ' ') {
6530
6571
  return { typ: exports.EnumToken.WhitespaceTokenType };
@@ -6643,10 +6684,10 @@
6643
6684
  return parseDimension(val);
6644
6685
  }
6645
6686
  const v = val.toLowerCase();
6646
- if (v == 'currentcolor' || val == 'transparent' || v in COLORS_NAMES) {
6687
+ if (v == 'currentcolor' || v == 'transparent' || v in COLORS_NAMES) {
6647
6688
  return {
6648
6689
  typ: exports.EnumToken.ColorTokenType,
6649
- val,
6690
+ val: v,
6650
6691
  kin: 'lit'
6651
6692
  };
6652
6693
  }
@@ -6996,12 +7037,47 @@
6996
7037
  return tokens;
6997
7038
  }
6998
7039
 
7040
+ function eq(a, b) {
7041
+ if (a == null || b == null) {
7042
+ return a == b;
7043
+ }
7044
+ if (typeof a != 'object' || typeof b != 'object') {
7045
+ return a === b;
7046
+ }
7047
+ if (a.constructor != b.constructor) {
7048
+ return false;
7049
+ }
7050
+ if (Array.isArray(a)) {
7051
+ if (a.length != b.length) {
7052
+ return false;
7053
+ }
7054
+ let i = 0;
7055
+ for (; i < a.length; i++) {
7056
+ if (!eq(a[i], b[i])) {
7057
+ return false;
7058
+ }
7059
+ }
7060
+ return true;
7061
+ }
7062
+ const k1 = Object.keys(a);
7063
+ const k2 = Object.keys(b);
7064
+ if (k1.length != k2.length) {
7065
+ return false;
7066
+ }
7067
+ let key;
7068
+ for (key of k1) {
7069
+ if (!(key in b) || !eq(a[key], b[key])) {
7070
+ return false;
7071
+ }
7072
+ }
7073
+ return true;
7074
+ }
7075
+
6999
7076
  function* walk(node, filter) {
7000
7077
  const parents = [node];
7001
7078
  const root = node;
7002
- const weakMap = new WeakMap;
7003
- while (parents.length > 0) {
7004
- node = parents.shift();
7079
+ const map = new Map;
7080
+ while ((node = parents.shift())) {
7005
7081
  let option = null;
7006
7082
  if (filter != null) {
7007
7083
  option = filter(node);
@@ -7015,22 +7091,21 @@
7015
7091
  // @ts-ignore
7016
7092
  if (option !== 'children') {
7017
7093
  // @ts-ignore
7018
- yield { node, parent: weakMap.get(node), root };
7094
+ yield { node, parent: map.get(node), root };
7019
7095
  }
7020
7096
  if (option !== 'ignore-children' && 'chi' in node) {
7021
7097
  parents.unshift(...node.chi);
7022
7098
  for (const child of node.chi.slice()) {
7023
- weakMap.set(child, node);
7099
+ map.set(child, node);
7024
7100
  }
7025
7101
  }
7026
7102
  }
7027
7103
  }
7028
7104
  function* walkValues(values, root = null, filter) {
7029
7105
  const stack = values.slice();
7030
- const weakMap = new WeakMap;
7106
+ const map = new Map;
7031
7107
  let value;
7032
- while (stack.length > 0) {
7033
- value = stack.shift();
7108
+ while ((value = stack.shift())) {
7034
7109
  let option = null;
7035
7110
  if (filter != null) {
7036
7111
  option = filter(value);
@@ -7044,17 +7119,17 @@
7044
7119
  // @ts-ignore
7045
7120
  if (option !== 'children') {
7046
7121
  // @ts-ignore
7047
- yield { value, parent: weakMap.get(value), root };
7122
+ yield { value, parent: map.get(value), root };
7048
7123
  }
7049
7124
  if (option !== 'ignore-children' && 'chi' in value) {
7050
7125
  for (const child of value.chi.slice()) {
7051
- weakMap.set(child, value);
7126
+ map.set(child, value);
7052
7127
  }
7053
7128
  stack.unshift(...value.chi);
7054
7129
  }
7055
7130
  else if (value.typ == exports.EnumToken.BinaryExpressionTokenType) {
7056
- weakMap.set(value.l, value);
7057
- weakMap.set(value.r, value);
7131
+ map.set(value.l, value);
7132
+ map.set(value.r, value);
7058
7133
  stack.unshift(value.l, value.r);
7059
7134
  }
7060
7135
  }
@@ -7205,61 +7280,6 @@
7205
7280
  }).reduce((acc, curr) => acc + (curr == '&' ? replace : curr), '');
7206
7281
  }
7207
7282
 
7208
- class MinifyFeature {
7209
- static get ordering() {
7210
- return 10000;
7211
- }
7212
- register(options) {
7213
- }
7214
- }
7215
-
7216
- class IterableWeakSet {
7217
- #weakset = new WeakSet;
7218
- #set = new Set;
7219
- constructor(iterable) {
7220
- if (iterable) {
7221
- for (const value of iterable) {
7222
- const ref = new WeakRef(value);
7223
- this.#weakset.add(value);
7224
- this.#set.add(ref);
7225
- }
7226
- }
7227
- }
7228
- has(value) {
7229
- return this.#weakset.has(value);
7230
- }
7231
- delete(value) {
7232
- if (this.#weakset.has(value)) {
7233
- for (const ref of this.#set) {
7234
- if (ref.deref() === value) {
7235
- this.#set.delete(ref);
7236
- break;
7237
- }
7238
- }
7239
- return this.#weakset.delete(value);
7240
- }
7241
- return false;
7242
- }
7243
- add(value) {
7244
- if (!this.#weakset.has(value)) {
7245
- this.#weakset.add(value);
7246
- this.#set.add(new WeakRef(value));
7247
- }
7248
- return this;
7249
- }
7250
- *[Symbol.iterator]() {
7251
- for (const ref of new Set(this.#set)) {
7252
- const key = ref.deref();
7253
- if (key != null) {
7254
- yield key;
7255
- }
7256
- else {
7257
- this.#set.delete(ref);
7258
- }
7259
- }
7260
- }
7261
- }
7262
-
7263
7283
  function replace(node, variableScope) {
7264
7284
  for (const { value, parent: parentValue } of walkValues(node.val)) {
7265
7285
  if (value?.typ == exports.EnumToken.FunctionTokenType && value.val == 'var') {
@@ -7283,7 +7303,7 @@
7283
7303
  }
7284
7304
  }
7285
7305
  }
7286
- class InlineCssVariablesFeature extends MinifyFeature {
7306
+ class InlineCssVariablesFeature {
7287
7307
  static get ordering() {
7288
7308
  return 0;
7289
7309
  }
@@ -7318,7 +7338,7 @@
7318
7338
  const info = {
7319
7339
  globalScope: isRoot,
7320
7340
  // @ts-ignore
7321
- parent: new IterableWeakSet(),
7341
+ parent: new Set(),
7322
7342
  declarationCount: 1,
7323
7343
  replaceable: isRoot,
7324
7344
  node: node
@@ -7356,6 +7376,9 @@
7356
7376
  }
7357
7377
  cleanup(ast, options = {}, context) {
7358
7378
  const variableScope = context.variableScope;
7379
+ if (variableScope == null) {
7380
+ return;
7381
+ }
7359
7382
  for (const info of variableScope.values()) {
7360
7383
  if (info.replaceable) {
7361
7384
  let i;
@@ -7446,6 +7469,7 @@
7446
7469
  }
7447
7470
  tokens[current].push(token);
7448
7471
  }
7472
+ // @ts-ignore
7449
7473
  if (token.typ == exports.EnumToken.LiteralTokenType && token.val == this.config.separator) {
7450
7474
  tokens.push([]);
7451
7475
  current++;
@@ -7549,6 +7573,7 @@
7549
7573
  }
7550
7574
  }
7551
7575
  if (acc.length > 0) {
7576
+ // @ts-ignore
7552
7577
  acc.push({ typ: exports.EnumToken.LiteralTokenType, val: this.config.separator });
7553
7578
  }
7554
7579
  acc.push(...curr);
@@ -7594,6 +7619,7 @@
7594
7619
  else {
7595
7620
  const separator = this.config.separator != null ? {
7596
7621
  ...this.config.separator,
7622
+ // @ts-ignore
7597
7623
  typ: exports.EnumToken[this.config.separator.typ]
7598
7624
  } : null;
7599
7625
  // expand shorthand
@@ -7603,7 +7629,7 @@
7603
7629
  // @ts-ignore
7604
7630
  this.declarations.get(this.config.shorthand).val.slice().reduce((acc, curr) => {
7605
7631
  // @ts-ignore
7606
- if (separator != null && separator.typ == curr.typ && eq(separator, curr)) {
7632
+ if (separator != null && separator.typ == curr.typ && separator.val == curr.val) {
7607
7633
  acc.push([]);
7608
7634
  return acc;
7609
7635
  }
@@ -7642,11 +7668,8 @@
7642
7668
  i--;
7643
7669
  // @ts-ignore
7644
7670
  if ('prefix' in props && acc[i]?.typ == exports.EnumToken[props.prefix.typ]) {
7645
- if (eq(acc[i], {
7646
- ...this.config.properties[property].prefix,
7647
- // @ts-ignore
7648
- typ: exports.EnumToken[props.prefix.typ]
7649
- })) {
7671
+ // @ts-ignore
7672
+ if (acc[i].typ == exports.EnumToken[props.prefix.typ] && acc[i].val == this.config.properties[property].prefix.val) {
7650
7673
  acc.splice(i, 1);
7651
7674
  i--;
7652
7675
  }
@@ -7813,6 +7836,7 @@
7813
7836
  let values = [];
7814
7837
  // @ts-ignore
7815
7838
  let typ = (exports.EnumToken[this.config.separator?.typ] ?? exports.EnumToken.CommaTokenType);
7839
+ // @ts-ignore
7816
7840
  let separator = this.config.separator ? renderToken(this.config.separator) : ',';
7817
7841
  this.matchTypes(declaration);
7818
7842
  values.push(value);
@@ -7892,6 +7916,26 @@
7892
7916
  }
7893
7917
  return (filtered.length > 0 ? filtered : values)[Symbol.iterator]();
7894
7918
  }
7919
+ for (const declaration of this.declarations.values()) {
7920
+ if (declaration instanceof PropertySet) {
7921
+ continue;
7922
+ }
7923
+ const config = declaration.nam == this.config.shorthand ? this.config : this.config.properties[declaration.nam] ?? this.config;
7924
+ if (!('mapping' in config)) {
7925
+ continue;
7926
+ }
7927
+ // @ts-ignore
7928
+ for (const [key, val] of Object.entries(config.mapping)) {
7929
+ const keys = parseString(key);
7930
+ if (keys.length != declaration.val.length) {
7931
+ continue;
7932
+ }
7933
+ if (eq(declaration.val, keys)) {
7934
+ declaration.val = parseString(val);
7935
+ break;
7936
+ }
7937
+ }
7938
+ }
7895
7939
  // @ts-ignore
7896
7940
  iterable = this.declarations.values();
7897
7941
  }
@@ -7900,6 +7944,7 @@
7900
7944
  let match;
7901
7945
  const separator = this.config.separator != null ? {
7902
7946
  ...this.config.separator,
7947
+ // @ts-ignore
7903
7948
  typ: exports.EnumToken[this.config.separator.typ]
7904
7949
  } : null;
7905
7950
  const tokens = {};
@@ -7917,7 +7962,8 @@
7917
7962
  for (const declaration of [(properties instanceof PropertySet ? [...properties][0] : properties)]) {
7918
7963
  // @ts-ignore
7919
7964
  for (const val of declaration.val) {
7920
- if (separator != null && separator.typ == val.typ && eq(separator, val)) {
7965
+ // @ts-ignore
7966
+ if (separator != null && separator.typ == val.typ && separator.val == val.val) {
7921
7967
  current++;
7922
7968
  if (tokens[curr[0]].length == current) {
7923
7969
  tokens[curr[0]].push([]);
@@ -7928,10 +7974,11 @@
7928
7974
  continue;
7929
7975
  }
7930
7976
  // @ts-ignore
7931
- if (props.multiple && props.separator != null && exports.EnumToken[props.separator.typ] == val.typ && eq({
7932
- ...props.separator,
7933
- typ: exports.EnumToken[props.separator.typ]
7934
- }, val)) {
7977
+ if (props.multiple && props.separator != null &&
7978
+ // @ts-ignore
7979
+ exports.EnumToken[props.separator.typ] == val.typ &&
7980
+ // @ts-ignore
7981
+ props.separator.val == val.val) {
7935
7982
  continue;
7936
7983
  }
7937
7984
  // @ts-ignore
@@ -8036,6 +8083,7 @@
8036
8083
  acc.push({
8037
8084
  ...((props.separator && {
8038
8085
  ...props.separator,
8086
+ // @ts-ignore
8039
8087
  typ: exports.EnumToken[props.separator.typ]
8040
8088
  }) ?? { typ: exports.EnumToken.WhitespaceTokenType })
8041
8089
  });
@@ -8136,6 +8184,7 @@
8136
8184
  if (value[index].typ == exports.EnumToken.WhitespaceTokenType) {
8137
8185
  continue;
8138
8186
  }
8187
+ // @ts-ignore@
8139
8188
  if (value[index].typ == exports.EnumToken[config.prefix.typ] &&
8140
8189
  // @ts-ignore
8141
8190
  value[index].val == config.prefix.val) {
@@ -8156,12 +8205,7 @@
8156
8205
  options = { removeDuplicateDeclarations: true, computeShorthand: true };
8157
8206
  declarations;
8158
8207
  constructor(options = {}) {
8159
- for (const key of Object.keys(this.options)) {
8160
- if (key in options) {
8161
- // @ts-ignore
8162
- this.options[key] = options[key];
8163
- }
8164
- }
8208
+ this.options = options;
8165
8209
  this.declarations = new Map;
8166
8210
  }
8167
8211
  set(nam, value) {
@@ -8255,7 +8299,7 @@
8255
8299
  }
8256
8300
  }
8257
8301
 
8258
- class ComputeShorthandFeature extends MinifyFeature {
8302
+ class ComputeShorthandFeature {
8259
8303
  static get ordering() {
8260
8304
  return 2;
8261
8305
  }
@@ -8267,7 +8311,7 @@
8267
8311
  }
8268
8312
  }
8269
8313
  // @ts-ignore
8270
- options.features.push(new ComputeShorthandFeature());
8314
+ options.features.push(new ComputeShorthandFeature(options));
8271
8315
  }
8272
8316
  }
8273
8317
  run(ast, options = {}, parent, context) {
@@ -8291,7 +8335,7 @@
8291
8335
  }
8292
8336
  }
8293
8337
 
8294
- class ComputeCalcExpressionFeature extends MinifyFeature {
8338
+ class ComputeCalcExpressionFeature {
8295
8339
  static get ordering() {
8296
8340
  return 1;
8297
8341
  }
@@ -8315,7 +8359,7 @@
8315
8359
  if (node.typ != exports.EnumToken.DeclarationNodeType) {
8316
8360
  continue;
8317
8361
  }
8318
- const set = new IterableWeakSet;
8362
+ const set = new Set;
8319
8363
  for (const { value, parent } of walkValues(node.val)) {
8320
8364
  if (value != null && value.typ == exports.EnumToken.FunctionTokenType && value.val == 'calc') {
8321
8365
  if (!set.has(parent)) {
@@ -8356,8 +8400,8 @@
8356
8400
  });
8357
8401
 
8358
8402
  const combinators = ['+', '>', '~', '||'];
8359
- const notEndingWith = ['(', '['].concat(combinators);
8360
8403
  const definedPropertySettings = { configurable: true, enumerable: false, writable: true };
8404
+ const notEndingWith = ['(', '['].concat(combinators);
8361
8405
  // @ts-ignore
8362
8406
  const features = Object.values(allFeatures).sort((a, b) => a.ordering - b.ordering);
8363
8407
  function minify(ast, options = {}, recursive = false, errors, nestingContent, context = {}) {
@@ -9353,8 +9397,10 @@
9353
9397
  if (matchUrl.test(currentFile)) {
9354
9398
  return fetch(new URL(url, currentFile)).then(parseResponse);
9355
9399
  }
9400
+ const path = resolve(url, currentFile).absolute;
9401
+ const t = new URL(path, self.origin);
9356
9402
  // return fetch(new URL(url, new URL(currentFile, self.location.href).href)).then(parseResponse);
9357
- return fetch(resolve(url, currentFile).absolute).then(parseResponse);
9403
+ return fetch(url, t.origin != self.location.origin ? { mode: 'cors' } : {}).then(parseResponse);
9358
9404
  }
9359
9405
 
9360
9406
  function render(data, options = {}) {