@tbela99/css-parser 1.6.1 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/CHANGELOG.md +92 -2
  2. package/README.md +1 -0
  3. package/dist/index-umd-web.js +1214 -247
  4. package/dist/index.cjs +1214 -247
  5. package/dist/index.d.ts +71 -6
  6. package/dist/lib/ast/features/prefix.js +9 -1
  7. package/dist/lib/ast/features/shorthand.js +1 -1
  8. package/dist/lib/ast/math/expression.js +156 -1
  9. package/dist/lib/ast/transform/compute.js +4 -8
  10. package/dist/lib/ast/types.js +12 -0
  11. package/dist/lib/parser/declaration/list.js +8 -10
  12. package/dist/lib/parser/parse.js +2 -9
  13. package/dist/lib/parser/tokenize.js +50 -18
  14. package/dist/lib/parser/utils/at-rule-font-feature-values.js +1 -1
  15. package/dist/lib/parser/utils/at-rule-media.js +66 -0
  16. package/dist/lib/parser/utils/at-rule-when-else.js +2 -2
  17. package/dist/lib/parser/utils/base64.js +14 -0
  18. package/dist/lib/parser/utils/declaration.js +7 -14
  19. package/dist/lib/parser/utils/eq.js +6 -0
  20. package/dist/lib/parser/utils/hash.js +1 -0
  21. package/dist/lib/parser/utils/selector.js +1 -1
  22. package/dist/lib/parser/utils/text.js +16 -0
  23. package/dist/lib/renderer/render.js +18 -4
  24. package/dist/lib/renderer/sourcemap/lib/codec.js +5 -0
  25. package/dist/lib/renderer/sourcemap/sourcemap.js +35 -5
  26. package/dist/lib/syntax/color/alpha.js +57 -22
  27. package/dist/lib/syntax/color/color-mix.js +18 -18
  28. package/dist/lib/syntax/color/srgb.js +10 -5
  29. package/dist/lib/syntax/color/utils/components.js +1 -1
  30. package/dist/lib/syntax/color/utils/distance.js +2 -2
  31. package/dist/lib/syntax/color/utils/matrix.js +1 -0
  32. package/dist/lib/syntax/color/xyz.js +5 -0
  33. package/dist/lib/syntax/color/xyzd50.js +17 -0
  34. package/dist/lib/syntax/syntax.js +549 -13
  35. package/dist/lib/validation/config.js +26 -0
  36. package/dist/lib/validation/match.js +16 -4
  37. package/dist/node.js +8 -14
  38. package/dist/web.js +8 -14
  39. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -669,6 +669,18 @@ exports.EnumToken = void 0;
669
669
  * wrapped values token type like {Arial, sans-serif}
670
670
  */
671
671
  EnumToken[EnumToken["WrappedValuesTokenType"] = 140] = "WrappedValuesTokenType";
672
+ /**
673
+ * infinity token
674
+ */
675
+ EnumToken[EnumToken["NaNTokenType"] = 141] = "NaNTokenType";
676
+ /**
677
+ * infinity token
678
+ */
679
+ EnumToken[EnumToken["InfinityTokenType"] = 142] = "InfinityTokenType";
680
+ /**
681
+ * negative infinity token
682
+ */
683
+ EnumToken[EnumToken["NegativeInfinityTokenType"] = 143] = "NegativeInfinityTokenType";
672
684
  /* aliases */
673
685
  /**
674
686
  * alias for time token type
@@ -6841,12 +6853,28 @@ const trimTokenSpace$1 = new Set([
6841
6853
  ]);
6842
6854
  const combinators = ["+", ">", "~", "||", "|"];
6843
6855
 
6856
+ /**
6857
+ *
6858
+ * @param value
6859
+ * @returns
6860
+ */
6844
6861
  function dasherize(value) {
6845
6862
  return value.replace(/([A-Z])/g, (all, one) => `-${one.toLowerCase()}`);
6846
6863
  }
6864
+ /**
6865
+ *
6866
+ * @param value
6867
+ * @returns
6868
+ */
6847
6869
  function camelize(value) {
6848
6870
  return value.replace(/-([a-z])/g, (all, one) => one.toUpperCase());
6849
6871
  }
6872
+ /**
6873
+ *
6874
+ * @param a
6875
+ * @param b
6876
+ * @returns
6877
+ */
6850
6878
  function equalsIgnoreCase(a, b) {
6851
6879
  if (a.length !== b.length)
6852
6880
  return false;
@@ -6875,7 +6903,7 @@ function getColorComponents(token) {
6875
6903
  // }
6876
6904
  // }
6877
6905
  if (token.kin == exports.ColorType.HEX || token.kin == exports.ColorType.LIT) {
6878
- if (equalsIgnoreCase('currentcolor', token.val)) {
6906
+ if (equalsIgnoreCase("currentcolor", token.val)) {
6879
6907
  return null;
6880
6908
  }
6881
6909
  const value = expandHexValue(token.kin == exports.ColorType.LIT ? COLORS_NAMES[token.val.toLowerCase()] : token.val);
@@ -6933,6 +6961,7 @@ function getColorComponents(token) {
6933
6961
  */
6934
6962
  // A is m x n. B is n x p. product is m x p.
6935
6963
  function multiplyMatrices(A, B) {
6964
+ // let m: number = A.length;
6936
6965
  // if (!Array.isArray(A[0])) {
6937
6966
  // // A is vector, convert to [[a, b, c, ...]]
6938
6967
  // A = <number[][]>[A];
@@ -7148,6 +7177,23 @@ function getLCHComponents(token) {
7148
7177
  return alpha == null ? [l, c, h] : [l, c, h, alpha];
7149
7178
  }
7150
7179
 
7180
+ // export function srgb2xyzd50values(r: number, g: number, b: number, alpha: number | null = null): number[] {
7181
+ // [r, g, b] = srgb2lsrgbvalues(r, g, b);
7182
+ //
7183
+ // const rgb: number[] = [
7184
+ // 0.436065742824811 * r + 0.3851514688337912 * g + 0.14307845442264197 * b,
7185
+ //
7186
+ // 0.22249319175623702 * r + 0.7168870538238823 * g + 0.06061979053616537 * b,
7187
+ //
7188
+ // 0.013923904500943465 * r + 0.09708128566574634 * g + 0.7140993584005155 * b,
7189
+ // ];
7190
+ //
7191
+ // if (alpha != null && alpha != 1) {
7192
+ // rgb.push(alpha);
7193
+ // }
7194
+ //
7195
+ // return rgb;
7196
+ // }
7151
7197
  /*
7152
7198
  */
7153
7199
  function xyzd502lch(x, y, z, alpha) {
@@ -7181,6 +7227,11 @@ function xyzd502srgb(x, y, z, alpha = null) {
7181
7227
  x * 0.07195537988411677 - y * 0.2289768264158322 + 1.405386058324125 * z, alpha);
7182
7228
  }
7183
7229
 
7230
+ // export function lab2xyz(l: number, a: number, b: number, alpha?: number): number[] {
7231
+ // const [x, y, z] = Lab_to_XYZ(l, a, b);
7232
+ //
7233
+ // return alpha == null || alpha == 1 ? [x, y, z] : [x, y, z, alpha];
7234
+ // }
7184
7235
  function XYZ_to_lin_sRGB(x, y, z, alpha = null) {
7185
7236
  // convert XYZ to linear-light sRGB
7186
7237
  const M = [
@@ -7897,6 +7948,15 @@ function rgb2srgbvalues(token) {
7897
7948
  ? getNumber(t)
7898
7949
  : getNumber(t) / 255) ?? null);
7899
7950
  }
7951
+ // export function rgbvalues2srgbvalues(r: number, g: number, b: number, a: number | null = null): number[] | null {
7952
+ // const result = [r / 255, g / 255, b / 255];
7953
+ //
7954
+ // if (a != null && a != 1) {
7955
+ // result.push(a);
7956
+ // }
7957
+ //
7958
+ // return result;
7959
+ // }
7900
7960
  function hex2srgbvalues(token) {
7901
7961
  const value = expandHexValue(token.kin == exports.ColorType.LIT ? COLORS_NAMES[token.val.toLowerCase()] : token.val);
7902
7962
  const rgb = [];
@@ -7958,11 +8018,7 @@ function cmyk2srgbvalues(token) {
7958
8018
  // @ts-ignore
7959
8019
  const k = getNumber(t);
7960
8020
  const mul = 1 - k;
7961
- const rgb = [
7962
- 1 - Math.min(1, c * mul + k),
7963
- 1 - Math.min(1, m * mul + k),
7964
- 1 - Math.min(1, y * mul + k),
7965
- ];
8021
+ const rgb = [1 - Math.min(1, c * mul + k), 1 - Math.min(1, m * mul + k), 1 - Math.min(1, y * mul + k)];
7966
8022
  if (components.length == 5) {
7967
8023
  rgb.push(getNumber(components[4]));
7968
8024
  }
@@ -9134,7 +9190,7 @@ function colorMix(...args) {
9134
9190
  let colorSpace = "oklab";
9135
9191
  let hueInterpolationMethod = "shorter";
9136
9192
  let values = null;
9137
- const colors = [];
9193
+ // const colors: ColorToken[] = [];
9138
9194
  const percentages = [];
9139
9195
  const srgbComponentValues = [];
9140
9196
  const colorComponents = [];
@@ -9243,7 +9299,8 @@ function colorMix(...args) {
9243
9299
  return null;
9244
9300
  }
9245
9301
  srgbComponentValues.push(values);
9246
- colors.push(args[i++]);
9302
+ // colors.push(args[i++] as ColorToken);
9303
+ i++;
9247
9304
  if (i >= args.length) {
9248
9305
  missingPercentageCount++;
9249
9306
  percentages.push(null);
@@ -9285,9 +9342,16 @@ function colorMix(...args) {
9285
9342
  for (i = 0; i < percentages.length; i++) {
9286
9343
  percentages[i] = percentages[i] / perc;
9287
9344
  }
9288
- totalPercentage = 1;
9289
9345
  }
9290
- i = colors.length;
9346
+ const stack = [];
9347
+ const lchSpaces = ["lch", "oklch"];
9348
+ i = srgbComponentValues.length;
9349
+ while (i--) {
9350
+ stack.push({
9351
+ color: srgbComponentValues[i],
9352
+ alpha: percentages[i],
9353
+ });
9354
+ }
9291
9355
  let currentIndex = 0;
9292
9356
  let r1;
9293
9357
  let r2;
@@ -9298,18 +9362,11 @@ function colorMix(...args) {
9298
9362
  let premult1;
9299
9363
  let premult2;
9300
9364
  let mixedPremult;
9301
- let colorSpace1;
9302
- const stack = [];
9303
- const lchSpaces = ["lch", "oklch"];
9304
- i = srgbComponentValues.length;
9305
- while (i--) {
9306
- stack.push({
9307
- color: srgbComponentValues[i],
9308
- alpha: percentages[i],
9309
- });
9310
- }
9365
+ let colorSpace1 = exports.ColorType[
9366
+ // @ts-expect-error
9367
+ colorComponents.at(-1).kin
9311
9368
  // @ts-expect-error
9312
- colorSpace1 = exports.ColorType[colorComponents.at(-1).kin]?.toLowerCase?.();
9369
+ ]?.toLowerCase?.();
9313
9370
  if (colorComponents[0][3] != null &&
9314
9371
  colorComponents[0][3].typ == exports.EnumToken.IdenTokenType &&
9315
9372
  colorComponents[0][3].val == "none" &&
@@ -9391,14 +9448,13 @@ function colorMix(...args) {
9391
9448
  else {
9392
9449
  values = xyz2lchvalues(values[0], values[1], values[2], values[3]);
9393
9450
  }
9394
- // @ts-ignore
9395
9451
  return {
9396
9452
  typ: exports.EnumToken.ColorTokenType,
9397
9453
  val: "lch",
9398
- chi: values.map((v) => {
9454
+ chi: values.map((val) => {
9399
9455
  return {
9400
9456
  typ: exports.EnumToken.NumberTokenType,
9401
- val: v,
9457
+ val,
9402
9458
  };
9403
9459
  }),
9404
9460
  kin: exports.ColorType.LCH,
@@ -10131,6 +10187,35 @@ function doEvaluate(l, r, op) {
10131
10187
  if (!isScalarToken(l) || !isScalarToken(r) || (l.typ == r.typ && "unit" in l && "unit" in r && l.unit != r.unit)) {
10132
10188
  return defaultReturn;
10133
10189
  }
10190
+ if (l.typ == exports.EnumToken.IdenTokenType) {
10191
+ if (equalsIgnoreCase(l.val, "Infinity")) {
10192
+ Object.assign(l, { typ: exports.EnumToken.InfinityTokenType });
10193
+ }
10194
+ else if (equalsIgnoreCase(l.val, "-Infinity")) {
10195
+ Object.assign(l, { typ: exports.EnumToken.NegativeInfinityTokenType });
10196
+ }
10197
+ else if (equalsIgnoreCase(l.val, "NaN")) {
10198
+ Object.assign(l, { typ: exports.EnumToken.NaNTokenType });
10199
+ }
10200
+ }
10201
+ if (r.typ == exports.EnumToken.IdenTokenType) {
10202
+ if (equalsIgnoreCase(r.val, "Infinity")) {
10203
+ Object.assign(r, { typ: exports.EnumToken.InfinityTokenType });
10204
+ }
10205
+ else if (equalsIgnoreCase(r.val, "-Infinity")) {
10206
+ Object.assign(r, { typ: exports.EnumToken.NegativeInfinityTokenType });
10207
+ }
10208
+ }
10209
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/calc-keyword#notes
10210
+ if (l.typ == exports.EnumToken.NaNTokenType || r.typ == exports.EnumToken.NaNTokenType) {
10211
+ return computeNaN(l, r, defaultReturn);
10212
+ }
10213
+ if (l.typ == exports.EnumToken.InfinityTokenType ||
10214
+ l.typ == exports.EnumToken.NegativeInfinityTokenType ||
10215
+ r.typ == exports.EnumToken.InfinityTokenType ||
10216
+ r.typ == exports.EnumToken.NegativeInfinityTokenType) {
10217
+ return computeInfinity(l, r, op, defaultReturn);
10218
+ }
10134
10219
  if (r.typ == exports.EnumToken.FunctionTokenType || r.typ == exports.EnumToken.MathFunctionTokenType) {
10135
10220
  const val = evaluateFunc(r);
10136
10221
  if (val == null) {
@@ -10201,6 +10286,18 @@ function doEvaluate(l, r, op) {
10201
10286
  }
10202
10287
  }
10203
10288
  }
10289
+ if (op == exports.EnumToken.Div && v2 == 0) {
10290
+ if (v1 == 0) {
10291
+ return Object.assign(l, { typ: exports.EnumToken.IdenTokenType, val: "NaN" });
10292
+ }
10293
+ let sign = Math.sign(v1) * Math.sign(v2);
10294
+ sign = Object.is(sign, -0) ? -1 : 1;
10295
+ Object.assign(l, {
10296
+ typ: l.typ == exports.EnumToken.IdenTokenType ? exports.EnumToken.NumberTokenType : l.typ,
10297
+ val: Object.is(sign, -0) ? -1 : sign,
10298
+ });
10299
+ return defaultReturn;
10300
+ }
10204
10301
  // @ts-ignore
10205
10302
  const val = compute$1(v1, v2, op);
10206
10303
  const token = {
@@ -10217,6 +10314,112 @@ function doEvaluate(l, r, op) {
10217
10314
  }
10218
10315
  return token;
10219
10316
  }
10317
+ /**
10318
+ *
10319
+ * @param l
10320
+ * @param r
10321
+ * @param defaultReturn
10322
+ * @returns
10323
+ */
10324
+ function computeNaN(l, r, defaultReturn) {
10325
+ if (l.typ == exports.EnumToken.NaNTokenType) {
10326
+ if (r.typ == exports.EnumToken.NumberTokenType ||
10327
+ // @ts-expect-error
10328
+ (r.typ == exports.EnumToken.IdenTokenType && typeof Math[r.val.toUpperCase()] == "string")) {
10329
+ return l;
10330
+ }
10331
+ // NaN Infinity e pi ...
10332
+ if (r.typ == exports.EnumToken.IdenTokenType ||
10333
+ r.typ == exports.EnumToken.InfinityTokenType ||
10334
+ r.typ == exports.EnumToken.NegativeInfinityTokenType) {
10335
+ return l;
10336
+ }
10337
+ if (typeof r.val == "number") {
10338
+ Object.assign(r, { val: 1 });
10339
+ }
10340
+ return r.typ == exports.EnumToken.NaNTokenType ? l : defaultReturn;
10341
+ }
10342
+ if (r.typ == exports.EnumToken.NaNTokenType) {
10343
+ // if ((r as IdentToken).val == "NaN") {
10344
+ if (l.typ == exports.EnumToken.NumberTokenType ||
10345
+ // @ts-expect-error
10346
+ (l.typ == exports.EnumToken.IdenTokenType && typeof Math[l.val.toUpperCase()] == "string")) {
10347
+ return r;
10348
+ }
10349
+ if (typeof l.val == "number") {
10350
+ Object.assign(l, { val: 1 });
10351
+ }
10352
+ // return defaultReturn;
10353
+ }
10354
+ // }
10355
+ return defaultReturn;
10356
+ }
10357
+ /**
10358
+ *
10359
+ * @param l
10360
+ * @param r
10361
+ * @param op
10362
+ * @param defaultReturn
10363
+ * @returns
10364
+ */
10365
+ function computeInfinity(l, r, op, defaultReturn) {
10366
+ if (l.typ == exports.EnumToken.InfinityTokenType || l.typ == exports.EnumToken.NegativeInfinityTokenType) {
10367
+ if (r.typ == exports.EnumToken.InfinityTokenType || r.typ == exports.EnumToken.NegativeInfinityTokenType) {
10368
+ // Infinity / Infinity Infinity - Infinity
10369
+ if (op == exports.EnumToken.Div ||
10370
+ (op == exports.EnumToken.Add && l.typ != r.typ) ||
10371
+ (op == exports.EnumToken.Sub && l.typ == r.typ)) {
10372
+ return Object.assign(l, { typ: exports.EnumToken.NaNTokenType });
10373
+ }
10374
+ if (l.typ != r.typ) {
10375
+ l.typ = exports.EnumToken.NegativeInfinityTokenType;
10376
+ }
10377
+ return l;
10378
+ }
10379
+ const value = getValue$1(r);
10380
+ const sign = Math.sign(value);
10381
+ const isNumber = r.typ == exports.EnumToken.NumberTokenType || r.typ == exports.EnumToken.IdenTokenType;
10382
+ // Infinity * 0
10383
+ if (value == 0 && op == exports.EnumToken.Mul) {
10384
+ l.typ = exports.EnumToken.NaNTokenType;
10385
+ return isNumber ? l : defaultReturn;
10386
+ }
10387
+ if (isNumber) {
10388
+ // @ts-ignore
10389
+ r.val /= r.val * sign;
10390
+ }
10391
+ if (op == exports.EnumToken.Div) {
10392
+ return isNumber
10393
+ ? Object.assign(r, { typ: exports.EnumToken.NumberTokenType, val: sign < 0 ? -0 : 0 })
10394
+ : defaultReturn;
10395
+ }
10396
+ if (sign == -1) {
10397
+ l.typ =
10398
+ l.typ == exports.EnumToken.InfinityTokenType
10399
+ ? exports.EnumToken.NegativeInfinityTokenType
10400
+ : exports.EnumToken.InfinityTokenType;
10401
+ }
10402
+ return isNumber ? l : defaultReturn;
10403
+ }
10404
+ if (r.typ == exports.EnumToken.InfinityTokenType || r.typ == exports.EnumToken.NegativeInfinityTokenType) {
10405
+ const value = getValue$1(l);
10406
+ let sign = Math.sign(value);
10407
+ const isNumber = l.typ == exports.EnumToken.NumberTokenType || l.typ == exports.EnumToken.IdenTokenType;
10408
+ if (isNumber) {
10409
+ Object.assign(l, { typ: exports.EnumToken.NumberTokenType, val: sign });
10410
+ }
10411
+ if (value == 0 && op == exports.EnumToken.Mul) {
10412
+ return Object.assign(l, { typ: exports.EnumToken.NaNTokenType });
10413
+ }
10414
+ if (op == exports.EnumToken.Div) {
10415
+ return isNumber
10416
+ ? Object.assign(l, { typ: exports.EnumToken.NumberTokenType, val: sign < 0 ? -0 : 0 })
10417
+ : defaultReturn;
10418
+ }
10419
+ return l.typ == isNumber || value == 0 ? r : defaultReturn;
10420
+ }
10421
+ return defaultReturn;
10422
+ }
10220
10423
  function getValue$1(t) {
10221
10424
  if (t.typ == exports.EnumToken.IdenTokenType) {
10222
10425
  // @ts-ignore
@@ -10551,7 +10754,14 @@ function isScalarToken(token) {
10551
10754
  (token.typ == exports.EnumToken.FunctionTokenType && mathFuncs.includes(token.val)) ||
10552
10755
  // @ts-ignore
10553
10756
  (token.typ == exports.EnumToken.IdenTokenType && typeof Math[token.val.toUpperCase()] == "number") ||
10554
- [exports.EnumToken.NumberTokenType, exports.EnumToken.FractionTokenType, exports.EnumToken.PercentageTokenType].includes(token.typ));
10757
+ (token.typ == exports.EnumToken.IdenTokenType && token.val == "NaN") ||
10758
+ (token.typ == exports.EnumToken.IdenTokenType &&
10759
+ (equalsIgnoreCase(token.val, "Infinity") ||
10760
+ equalsIgnoreCase(token.val, "-Infinity"))) ||
10761
+ [exports.EnumToken.NumberTokenType, exports.EnumToken.FractionTokenType, exports.EnumToken.PercentageTokenType].includes(token.typ) ||
10762
+ token.typ == exports.EnumToken.NaNTokenType ||
10763
+ token.typ == exports.EnumToken.InfinityTokenType ||
10764
+ token.typ == exports.EnumToken.NegativeInfinityTokenType);
10555
10765
  }
10556
10766
  /**
10557
10767
  *
@@ -11832,6 +12042,32 @@ function getSyntaxConfig() {
11832
12042
  // @ts-expect-error
11833
12043
  return config$4;
11834
12044
  }
12045
+ // export const getSyntax = memoize((group: ValidationSyntaxGroupEnum, key: string | string[]): null | string => {
12046
+ // // @ts-expect-error
12047
+ // let obj = config[group] as Record<ValidationSyntaxGroupEnum, ValidationSyntaxNode>;
12048
+ //
12049
+ // const keys: string[] = Array.isArray(key) ? key : [key];
12050
+ //
12051
+ // for (let i = 0; i < keys.length; i++) {
12052
+ // key = keys[i];
12053
+ //
12054
+ // if (!(key in obj)) {
12055
+ // if ((i == 0 && key.charAt(0) == "@") || key.charAt(0) == "-") {
12056
+ // const matches: RegExpMatchArray = key.match(/^(@?)(-[a-zA-Z]+)-(.*?)$/) as RegExpMatchArray;
12057
+ //
12058
+ // if (matches != null) {
12059
+ // key = matches[1] + matches[3];
12060
+ // }
12061
+ // }
12062
+ // }
12063
+ //
12064
+ // // @ts-expect-error
12065
+ // obj = obj[key];
12066
+ // }
12067
+ //
12068
+ // // @ts-expect-error
12069
+ // return obj?.syntax ?? null;
12070
+ // }) as (group: ValidationSyntaxGroupEnum, key: string | string[]) => null | string;
11835
12071
  function findNode(group, key) {
11836
12072
  // @ts-expect-error
11837
12073
  let obj = config$4[group];
@@ -11981,6 +12217,15 @@ function trimArray(tokens) {
11981
12217
  }
11982
12218
  return tokens;
11983
12219
  }
12220
+ /**
12221
+ * is a media feature
12222
+ * @param featureName
12223
+ * @returns
12224
+ */
12225
+ // export function isMFName(featureName: string): boolean {
12226
+ // // @ts-expect-error
12227
+ // return featureName.startsWith("--") || config.mediaFeatures[featureName.toLowerCase()] != null;
12228
+ // }
11984
12229
  /**
11985
12230
  *
11986
12231
  * @param featureName
@@ -11994,6 +12239,7 @@ function getMFInfo(featureName) {
11994
12239
  *
11995
12240
  * @param featureName
11996
12241
  * @param tokens
12242
+ * @param isMFRange
11997
12243
  * @returns object with:
11998
12244
  * - valid: boolean. true the media feaure is known or is a custom property. false otherwise
11999
12245
  * - success: boolean. validation result
@@ -12111,9 +12357,10 @@ function createValidationContext(tokens) {
12111
12357
  },
12112
12358
  /**
12113
12359
  *
12114
- * @param stopCondition
12115
- * @param matchCount
12116
12360
  * @returns
12361
+ * @param open
12362
+ * @param close
12363
+ * @param counter
12117
12364
  */
12118
12365
  peekRange(open = exports.EnumToken.StartParensTokenType, close = exports.EnumToken.EndParensTokenType, counter = 0) {
12119
12366
  let index = this.index;
@@ -12336,7 +12583,7 @@ function matchSelectorSyntax(stream, errors, options, nested = true) {
12336
12583
  case exports.EnumToken.CDOCOMMTokenType:
12337
12584
  break;
12338
12585
  case exports.EnumToken.NestingSelectorTokenType:
12339
- if (nested === false && !options.nestedRule) {
12586
+ if (!nested && !options.nestedRule) {
12340
12587
  return {
12341
12588
  success: false,
12342
12589
  errors: [
@@ -13377,7 +13624,8 @@ function matchSyntax(syntaxes, context, options) {
13377
13624
  errors: [],
13378
13625
  };
13379
13626
  case ValidationTokenEnum.FunctionDefinition:
13380
- if (equalsIgnoreCase(token.val, syntaxes[i].val)) {
13627
+ if (token.val &&
13628
+ equalsIgnoreCase(token.val, syntaxes[i].val)) {
13381
13629
  if (tokensfuncDefMap.has(token.typ)) {
13382
13630
  const children = trimArray(context.peekRange());
13383
13631
  result = matchSyntax((getParsedSyntax(ValidationSyntaxGroupEnum.Syntaxes, syntaxes[i].val + "()")?.[0]).chi ?? [], createValidationContext(children.slice(1, -1)), options);
@@ -14402,104 +14650,6 @@ function getColorType(color) {
14402
14650
  return color.kin;
14403
14651
  }
14404
14652
 
14405
- const trimTokenSpace = new Set([
14406
- exports.EnumToken.CommaTokenType,
14407
- exports.EnumToken.DelimTokenType,
14408
- exports.EnumToken.GtTokenType,
14409
- exports.EnumToken.GteTokenType,
14410
- exports.EnumToken.LtTokenType,
14411
- exports.EnumToken.LteTokenType,
14412
- exports.EnumToken.ChildCombinatorTokenType,
14413
- ]);
14414
- const trimSpaceAfter = new Set([
14415
- ...tokensfuncSet.values(),
14416
- exports.EnumToken.ChildCombinatorTokenType,
14417
- exports.EnumToken.SupportsQueryConditionTokenType,
14418
- exports.EnumToken.SupportsQueryUnaryConditionTokenType,
14419
- ]);
14420
- /**
14421
- * Replace token in its parent node
14422
- * @param parent
14423
- * @param node
14424
- * @param replacement
14425
- * @throws TypeError replacement is null
14426
- * @throws ReferenceError node not found in parent
14427
- */
14428
- function replaceNodeOrValue(parent, node, replacement) {
14429
- if (replacement == null || (Array.isArray(replacement) && replacement.length === 0)) {
14430
- throw new TypeError(`replacement is null`);
14431
- }
14432
- for (const newNode of Array.isArray(replacement) ? replacement : [replacement]) {
14433
- if (newNode[PARENT] != node[PARENT]) {
14434
- newNode[PARENT] = node[PARENT];
14435
- }
14436
- }
14437
- if (parent.typ == exports.EnumToken.BinaryExpressionTokenType) {
14438
- if (parent.l == node) {
14439
- parent.l = replacement;
14440
- }
14441
- else if (parent.r == node) {
14442
- parent.r = replacement;
14443
- }
14444
- else {
14445
- throw new ReferenceError("Node not found");
14446
- }
14447
- }
14448
- else {
14449
- const target = "val" in parent && Array.isArray(parent.val)
14450
- ? parent.val
14451
- : (parent.chi ?? parent);
14452
- if (Array.isArray(target)) {
14453
- // @ts-ignore
14454
- const index = target.indexOf(node);
14455
- if (index == -1) {
14456
- throw new ReferenceError("Node not found");
14457
- }
14458
- target.splice(index, 1, ...(Array.isArray(replacement) ? replacement : [replacement]));
14459
- }
14460
- else if ("l" in target && target.l == node) {
14461
- target.l = replacement;
14462
- }
14463
- else if ("r" in target && target.r == node) {
14464
- target.r = replacement;
14465
- }
14466
- else {
14467
- throw new ReferenceError("Node not found");
14468
- }
14469
- }
14470
- node[PARENT] = null;
14471
- return true;
14472
- }
14473
- function trimWhiteSpaceTokens(tokens) {
14474
- let i = 0;
14475
- if (tokens[0]?.typ === exports.EnumToken.WhitespaceTokenType) {
14476
- tokens.shift();
14477
- }
14478
- if (tokens[tokens.length - 1]?.typ === exports.EnumToken.WhitespaceTokenType) {
14479
- tokens.pop();
14480
- }
14481
- if (tokens.length === 1) {
14482
- if (tokens[0].typ === exports.EnumToken.WhitespaceTokenType) {
14483
- tokens.length = 0;
14484
- }
14485
- return tokens;
14486
- }
14487
- for (; i < tokens.length; i++) {
14488
- if (trimSpaceAfter.has(tokens[i].typ) && tokens[i + 1]?.typ === exports.EnumToken.WhitespaceTokenType) {
14489
- tokens.splice(i + 1, 1);
14490
- }
14491
- else if (trimTokenSpace.has(tokens[i].typ)) {
14492
- if (tokens[i + 1]?.typ === exports.EnumToken.WhitespaceTokenType) {
14493
- tokens.splice(i + 1, 1);
14494
- }
14495
- if (i > 0 && tokens[i - 1].typ === exports.EnumToken.Whitespace) {
14496
- tokens.splice(--i, 1);
14497
- }
14498
- }
14499
- }
14500
- return tokens;
14501
- }
14502
-
14503
14653
  /**
14504
14654
  * Compute alpha color
14505
14655
  * @param color
@@ -14510,40 +14660,76 @@ function alpha(color, alpha) {
14510
14660
  if (alpha == null) {
14511
14661
  return color;
14512
14662
  }
14663
+ // https://www.w3.org/TR/css-color-5/#:~:text=There%20is%20no%20relative%20device%2Dcmyk%28%29%20syntax
14513
14664
  if (color.kin === exports.ColorType.DEVICE_CMYK) {
14514
14665
  return null;
14515
14666
  }
14667
+ let components = getColorComponents(color);
14668
+ if (alpha.typ === exports.EnumToken.MathFunctionTokenType) {
14669
+ const originalAlpha = cloneNode(alpha, true);
14670
+ for (const { value } of walkValues(alpha.chi, alpha)) {
14671
+ if (value.typ === exports.EnumToken.IdenTokenType) {
14672
+ if (equalsIgnoreCase(value.val, "alpha")) {
14673
+ Object.assign(value, components?.[3]
14674
+ ? cloneNode(components[3], true)
14675
+ : {
14676
+ typ: exports.EnumToken.NumberTokenType,
14677
+ val: 1,
14678
+ });
14679
+ // continue;
14680
+ }
14681
+ else if (equalsIgnoreCase(value.val, "none")) {
14682
+ Object.assign(value, {
14683
+ typ: exports.EnumToken.NumberTokenType,
14684
+ val: 0,
14685
+ });
14686
+ }
14687
+ }
14688
+ }
14689
+ const result = evaluate([alpha]);
14690
+ if (result.length == 1) {
14691
+ alpha = result[0];
14692
+ }
14693
+ else {
14694
+ // @ts-expect-error
14695
+ alpha = originalAlpha;
14696
+ }
14697
+ }
14698
+ // console.error({ alpha });
14699
+ if (alpha.typ !== exports.EnumToken.IdenTokenType &&
14700
+ alpha.typ !== exports.EnumToken.NumberTokenType &&
14701
+ alpha.typ !== exports.EnumToken.PercentageTokenType) {
14702
+ return null;
14703
+ }
14704
+ if (alpha.typ === exports.EnumToken.IdenTokenType) {
14705
+ if (equalsIgnoreCase(alpha.val, "NaN") ||
14706
+ equalsIgnoreCase(alpha.val, "Infinity") ||
14707
+ equalsIgnoreCase(alpha.val, "-Infinity")) {
14708
+ return null;
14709
+ }
14710
+ }
14516
14711
  if (color.kin === exports.ColorType.COLOR_MIX || color.cal === "rel") {
14517
14712
  color = convertColor(color, getColorType(color));
14518
14713
  if (color == null) {
14519
14714
  return null;
14520
14715
  }
14716
+ components = getColorComponents(color);
14521
14717
  }
14522
- const components = getColorComponents(color);
14523
14718
  if (components == null) {
14524
14719
  return null;
14525
14720
  }
14526
- if (alpha?.typ === exports.EnumToken.IdenTokenType && equalsIgnoreCase(alpha.val, "alpha")) {
14527
- alpha = components[3] ?? {
14528
- typ: exports.EnumToken.NumberTokenType,
14529
- val: 1,
14530
- };
14531
- }
14532
- else if (alpha.typ === exports.EnumToken.MathFunctionTokenType &&
14533
- equalsIgnoreCase(alpha.val, "calc")) {
14534
- alpha = cloneNode(alpha, true);
14535
- const alphaValue = components[3] ?? {
14536
- typ: exports.EnumToken.NumberTokenType,
14537
- val: 1,
14538
- };
14539
- for (const { value, parent } of walkValues(alpha.chi, alpha)) {
14540
- if (value.typ === exports.EnumToken.IdenTokenType && equalsIgnoreCase(value.val, "alpha")) {
14541
- replaceNodeOrValue(parent, value, alphaValue);
14542
- }
14721
+ if (alpha?.typ === exports.EnumToken.IdenTokenType) {
14722
+ if (equalsIgnoreCase(alpha.val, "alpha")) {
14723
+ alpha = components[3] ?? {
14724
+ typ: exports.EnumToken.NumberTokenType,
14725
+ val: 1,
14726
+ };
14543
14727
  }
14544
- const result = evaluate([alpha]);
14545
- if (result.length == 1) {
14546
- alpha = result[0];
14728
+ else if (equalsIgnoreCase(alpha.val, "node")) {
14729
+ alpha = {
14730
+ typ: exports.EnumToken.NumberTokenType,
14731
+ val: 0,
14732
+ };
14547
14733
  }
14548
14734
  }
14549
14735
  return makeColor(color.kin, components, alpha);
@@ -15113,11 +15299,11 @@ function getAngle(token) {
15113
15299
 
15114
15300
  /**
15115
15301
  * Calculate the distance between two okLab colors.
15116
- * @param okLab1
15117
- * @param okLab2
15118
15302
  *
15119
15303
  * @private
15120
15304
  * {@link https://drafts.csswg.org/css-color-4/#comparing-color-values}
15305
+ * @param color1
15306
+ * @param color2
15121
15307
  */
15122
15308
  function okLabDistance(color1, color2) {
15123
15309
  color1 = convertColor(color1, exports.ColorType.OKLAB);
@@ -15446,6 +15632,300 @@ const pseudoAliasMap = {
15446
15632
  ":-moz-ui-valid": ":user-valid",
15447
15633
  "::-moz-selection": "::selection",
15448
15634
  };
15635
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/WebKit_Extensions
15636
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/::-webkit-scrollbar
15637
+ // export const webkitExtensions = new Set([
15638
+ // "-webkit-app-region",
15639
+ // "-webkit-border-horizontal-spacing",
15640
+ // "-webkit-border-vertical-spacing",
15641
+ // "-webkit-box-reflect",
15642
+ // "-webkit-column-axis",
15643
+ // "-webkit-column-progression",
15644
+ // "-webkit-cursor-visibility",
15645
+ // "-webkit-font-smoothing",
15646
+ // "-webkit-hyphenate-limit-after",
15647
+ // "-webkit-hyphenate-limit-before",
15648
+ // "-webkit-hyphenate-limit-lines",
15649
+ // "-webkit-line-align",
15650
+ // "-webkit-line-box-contain",
15651
+ // "-webkit-line-clamp",
15652
+ // "-webkit-line-grid",
15653
+ // "-webkit-line-snap",
15654
+ // "-webkit-locale",
15655
+ // "-webkit-logical-height",
15656
+ // "-webkit-logical-width",
15657
+ // "-webkit-margin-after",
15658
+ // "-webkit-margin-before",
15659
+ // "-webkit-mask-box-image-outset",
15660
+ // "-webkit-mask-box-image-repeat",
15661
+ // "-webkit-mask-box-image-slice",
15662
+ // "-webkit-mask-box-image-source",
15663
+ // "-webkit-mask-box-image-width",
15664
+ // "-webkit-mask-box-image",
15665
+ // "-webkit-mask-composite",
15666
+ // "-webkit-mask-position-x",
15667
+ // "-webkit-mask-position-y",
15668
+ // "-webkit-mask-repeat-x",
15669
+ // "-webkit-mask-repeat-y",
15670
+ // "-webkit-mask-source-type",
15671
+ // "-webkit-max-logical-height",
15672
+ // "-webkit-max-logical-width",
15673
+ // "-webkit-min-logical-height",
15674
+ // "-webkit-min-logical-width",
15675
+ // "-webkit-nbsp-mode",
15676
+ // "-webkit-match-parent",
15677
+ // "-webkit-perspective-origin-x",
15678
+ // "-webkit-perspective-origin-y",
15679
+ // "-webkit-rtl-ordering",
15680
+ // "-webkit-tap-highlight-color",
15681
+ // "-webkit-text-decoration-skip",
15682
+ // "-webkit-text-decorations-in-effect",
15683
+ // "-webkit-text-fill-color",
15684
+ // "-webkit-text-security",
15685
+ // "-webkit-text-stroke-color",
15686
+ // "-webkit-text-stroke-width",
15687
+ // "-webkit-text-stroke",
15688
+ // "-webkit-text-zoom",
15689
+ // "-webkit-touch-callout",
15690
+ // "-webkit-transform-origin-x",
15691
+ // "-webkit-transform-origin-y",
15692
+ // "-webkit-transform-origin-z",
15693
+ // "-webkit-user-drag",
15694
+ // "-webkit-user-modify",
15695
+ // "-webkit-border-after",
15696
+ // "-webkit-border-after-color",
15697
+ // "-webkit-border-after-style",
15698
+ // "-webkit-border-after-width",
15699
+ // "-webkit-border-before",
15700
+ // "-webkit-border-before-color",
15701
+ // "-webkit-border-before-style",
15702
+ // "-webkit-border-before-width",
15703
+ // "-webkit-border-end",
15704
+ // "-webkit-border-end-color",
15705
+ // "-webkit-border-end-style",
15706
+ // "-webkit-border-end-width",
15707
+ // "-webkit-border-start",
15708
+ // "-webkit-border-start-color",
15709
+ // "-webkit-border-start-style",
15710
+ // "-webkit-border-start-width",
15711
+ // "-webkit-box-align",
15712
+ // "-webkit-box-direction",
15713
+ // "-webkit-box-flex-group",
15714
+ // "-webkit-box-flex",
15715
+ // "-webkit-box-lines",
15716
+ // "-webkit-box-ordinal-group",
15717
+ // "-webkit-box-orient",
15718
+ // "-webkit-box-pack",
15719
+ // "-webkit-column-break-after",
15720
+ // "-webkit-column-break-before",
15721
+ // "-webkit-column-break-inside",
15722
+ // "-webkit-font-feature-settings",
15723
+ // "-webkit-hyphenate-character",
15724
+ // "-webkit-initial-letter",
15725
+ // "-webkit-margin-end",
15726
+ // "-webkit-margin-start",
15727
+ // "-webkit-padding-after",
15728
+ // "-webkit-padding-before",
15729
+ // "-webkit-padding-end",
15730
+ // "-webkit-padding-start",
15731
+ // "-webkit-fill-available",
15732
+ // ":-webkit-animating-full-screen-transition",
15733
+ // ":-webkit-any",
15734
+ // ":-webkit-any-link",
15735
+ // ":-webkit-autofill",
15736
+ // ":-webkit-autofill-strong-password",
15737
+ // ":-webkit-drag",
15738
+ // ":-webkit-full-page-media",
15739
+ // ":-webkit-full-screen*",
15740
+ // ":-webkit-full-screen-ancestor",
15741
+ // ":-webkit-full-screen-document",
15742
+ // ":-webkit-full-screen-controls-hidden",
15743
+ // "::-webkit-file-upload-button*",
15744
+ // "::-webkit-inner-spin-button",
15745
+ // "::-webkit-input-placeholder",
15746
+ // "::-webkit-meter-bar",
15747
+ // "::-webkit-meter-even-less-good-value",
15748
+ // "::-webkit-meter-inner-element",
15749
+ // "::-webkit-meter-optimum-value",
15750
+ // "::-webkit-meter-suboptimum-value",
15751
+ // "::-webkit-progress-bar",
15752
+ // "::-webkit-progress-inner-element",
15753
+ // "::-webkit-progress-value",
15754
+ // "::-webkit-search-cancel-button",
15755
+ // "::-webkit-search-results-button",
15756
+ // "::-webkit-slider-runnable-track",
15757
+ // "::-webkit-slider-thumb",
15758
+ // "-webkit-animation",
15759
+ // "-webkit-device-pixel-ratio",
15760
+ // "-webkit-transform-2d",
15761
+ // "-webkit-transform-3d",
15762
+ // "-webkit-transition",
15763
+ // "::-webkit-scrollbar",
15764
+ // "::-webkit-scrollbar-button",
15765
+ // "::-webkit-scrollbar",
15766
+ // "::-webkit-scrollbar-thumb",
15767
+ // "::-webkit-scrollbar-track",
15768
+ // "::-webkit-scrollbar-track-piece",
15769
+ // "::-webkit-scrollbar:vertical",
15770
+ // "::-webkit-scrollbar-corner ",
15771
+ // "::-webkit-resizer",
15772
+ // ":vertical",
15773
+ // ":horizontal",
15774
+ // ]);
15775
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Mozilla_Extensions
15776
+ // export const mozExtensions = new Set([
15777
+ // "-moz-box-align",
15778
+ // "-moz-box-direction",
15779
+ // "-moz-box-flex",
15780
+ // "-moz-box-ordinal-group",
15781
+ // "-moz-box-orient",
15782
+ // "-moz-box-pack",
15783
+ // "-moz-float-edge",
15784
+ // "-moz-force-broken-image-icon",
15785
+ // "-moz-image-region",
15786
+ // "-moz-orient",
15787
+ // "-moz-osx-font-smoothing",
15788
+ // "-moz-user-focus",
15789
+ // "-moz-user-input",
15790
+ // "-moz-user-modify",
15791
+ // "-moz-animation",
15792
+ // "-moz-animation-delay",
15793
+ // "-moz-animation-direction",
15794
+ // "-moz-animation-duration",
15795
+ // "-moz-animation-fill-mode",
15796
+ // "-moz-animation-iteration-count",
15797
+ // "-moz-animation-name",
15798
+ // "-moz-animation-play-state",
15799
+ // "-moz-animation-timing-function",
15800
+ // "-moz-appearance",
15801
+ // "-moz-backface-visibility",
15802
+ // "-moz-background-clip",
15803
+ // "-moz-background-origin",
15804
+ // "-moz-background-inline-policy",
15805
+ // "-moz-background-size",
15806
+ // "-moz-border-end",
15807
+ // "-moz-border-end-color",
15808
+ // "-moz-border-end-style",
15809
+ // "-moz-border-end-width",
15810
+ // "-moz-border-image",
15811
+ // "-moz-border-start",
15812
+ // "-moz-border-start-color",
15813
+ // "-moz-border-start-style",
15814
+ // "-moz-border-start-width",
15815
+ // "-moz-box-sizing",
15816
+ // "clip-path",
15817
+ // "-moz-column-count",
15818
+ // "-moz-column-fill",
15819
+ // "-moz-column-gap",
15820
+ // "-moz-column-width",
15821
+ // "-moz-column-rule",
15822
+ // "-moz-column-rule-width",
15823
+ // "-moz-column-rule-style",
15824
+ // "-moz-column-rule-color",
15825
+ // "filter",
15826
+ // "-moz-font-feature-settings",
15827
+ // "-moz-font-language-override",
15828
+ // "-moz-hyphens",
15829
+ // "-moz-margin-end",
15830
+ // "-moz-margin-start",
15831
+ // "mask",
15832
+ // "-moz-opacity",
15833
+ // "-moz-outline",
15834
+ // "-moz-outline-color",
15835
+ // "-moz-outline-offset",
15836
+ // "-moz-outline-style",
15837
+ // "-moz-outline-width",
15838
+ // "-moz-padding-end",
15839
+ // "-moz-padding-start",
15840
+ // "-moz-perspective",
15841
+ // "-moz-perspective-origin",
15842
+ // "pointer-events",
15843
+ // "-moz-tab-size",
15844
+ // "-moz-text-align-last",
15845
+ // "-moz-text-decoration-color",
15846
+ // "-moz-text-decoration-line",
15847
+ // "-moz-text-decoration-style",
15848
+ // "-moz-text-size-adjust",
15849
+ // "-moz-transform",
15850
+ // "-moz-transform-origin",
15851
+ // "-moz-transform-style",
15852
+ // "-moz-transition",
15853
+ // "-moz-transition-delay",
15854
+ // "-moz-transition-duration",
15855
+ // "-moz-transition-property",
15856
+ // "-moz-transition-timing-function",
15857
+ // "-moz-user-select",
15858
+ // "-moz-initial",
15859
+ // "-moz-appearance",
15860
+ // "-moz-linear-gradient",
15861
+ // "-moz-radial-gradient",
15862
+ // "-moz-element",
15863
+ // "-moz-image-rect",
15864
+ // "::-moz-anonymous-block",
15865
+ // "::-moz-anonymous-positioned-block",
15866
+ // ":-moz-any",
15867
+ // ":-moz-any-link",
15868
+ // ":-moz-broken",
15869
+ // "::-moz-canvas",
15870
+ // "::-moz-color-swatch",
15871
+ // "::-moz-cell-content",
15872
+ // ":-moz-drag-over",
15873
+ // ":-moz-first-node",
15874
+ // "::-moz-focus-inner",
15875
+ // "::-moz-focus-outer",
15876
+ // ":-moz-full-screen",
15877
+ // ":-moz-full-screen-ancestor",
15878
+ // ":-moz-handler-blocked",
15879
+ // ":-moz-handler-crashed",
15880
+ // ":-moz-handler-disabled",
15881
+ // "::-moz-inline-table",
15882
+ // ":-moz-last-node",
15883
+ // "::-moz-list-bullet",
15884
+ // "::-moz-list-number",
15885
+ // ":-moz-loading",
15886
+ // ":-moz-locale-dir",
15887
+ // ":-moz-locale-dir",
15888
+ // ":-moz-lwtheme",
15889
+ // ":-moz-lwtheme-brighttext",
15890
+ // ":-moz-lwtheme-darktext",
15891
+ // "::-moz-meter-bar",
15892
+ // ":-moz-native-anonymous",
15893
+ // ":-moz-only-whitespace",
15894
+ // "::-moz-pagebreak",
15895
+ // "::-moz-pagecontent",
15896
+ // ":-moz-placeholder",
15897
+ // "::-moz-placeholder",
15898
+ // "::-moz-progress-bar",
15899
+ // "::-moz-range-progress",
15900
+ // "::-moz-range-thumb",
15901
+ // "::-moz-range-track",
15902
+ // ":-moz-read-only",
15903
+ // ":-moz-read-write",
15904
+ // "::-moz-scrolled-canvas",
15905
+ // "::-moz-scrolled-content",
15906
+ // "::-moz-selection",
15907
+ // ":-moz-submit-invalid",
15908
+ // ":-moz-suppressed",
15909
+ // "::-moz-svg-foreign-content",
15910
+ // "::-moz-table",
15911
+ // "::-moz-table-cell",
15912
+ // "::-moz-table-column",
15913
+ // "::-moz-table-column-group",
15914
+ // "::-moz-table-outer",
15915
+ // "::-moz-table-row",
15916
+ // "::-moz-table-row-group",
15917
+ // ":-moz-ui-invalid",
15918
+ // ":-moz-ui-valid",
15919
+ // ":-moz-user-disabled",
15920
+ // "::-moz-viewport",
15921
+ // "::-moz-viewport-scroll",
15922
+ // ":-moz-window-inactive",
15923
+ // "-moz-device-pixel-ratio",
15924
+ // "-moz-os-version",
15925
+ // "-moz-touch-enabled",
15926
+ // "-moz-windows-glass",
15927
+ // "-moz-alt-content",
15928
+ // ]);
15449
15929
  // renamed standard properties
15450
15930
  const renamedStandardProperties = new Map([["color-adjust", "print-color-adjust"]]);
15451
15931
  function isLength(dimension) {
@@ -15463,6 +15943,34 @@ function isTime(dimension) {
15463
15943
  function isFrequency(dimension) {
15464
15944
  return "unit" in dimension && frequencyUnits.includes(dimension.unit.toLowerCase());
15465
15945
  }
15946
+ /**
15947
+ * Is color space
15948
+ * @param token
15949
+ * @returns
15950
+ */
15951
+ // export function isColorspace(token: Token): boolean {
15952
+ // return (
15953
+ // token.typ === EnumToken.IdenTokenType &&
15954
+ // [
15955
+ // "srgb",
15956
+ // "srgb-linear",
15957
+ // "lab",
15958
+ // "oklab",
15959
+ // "lch",
15960
+ // "oklch",
15961
+ // "xyz",
15962
+ // "xyz-d50",
15963
+ // "xyz-d65",
15964
+ // "display-p3",
15965
+ // "a98-rgb",
15966
+ // "prophoto-rgb",
15967
+ // "rec2020",
15968
+ // "rgb",
15969
+ // "hsl",
15970
+ // "hwb",
15971
+ // ].includes((token as IdentToken).val.toLowerCase())
15972
+ // );
15973
+ // }
15466
15974
  /**
15467
15975
  * Reduce color stops
15468
15976
  * @param stops
@@ -15660,6 +16168,26 @@ function isPolarColorspace(token) {
15660
16168
  return (token.typ === exports.EnumToken.IdenTokenType &&
15661
16169
  ["hsl", "hwb", "lch", "oklch"].some((t) => equalsIgnoreCase(t, token.val)));
15662
16170
  }
16171
+ /**
16172
+ * Is hue interpolation method
16173
+ * @param token
16174
+ * @returns
16175
+ */
16176
+ // export function isHueInterpolationMethod(token: Token | Token[]): boolean {
16177
+ // if (!Array.isArray(token)) {
16178
+ // return token.typ == EnumToken.IdenTokenType && "hue" === (token as IdentToken).val?.toLowerCase?.();
16179
+ // }
16180
+ //
16181
+ // if (token.length != 2 || token[0].typ != EnumToken.IdenTokenType || token[1].typ != EnumToken.IdenTokenType) {
16182
+ // return false;
16183
+ // }
16184
+ //
16185
+ // return (
16186
+ // ["shorter", "longer", "increasing", "decreasing"].some((t) =>
16187
+ // equalsIgnoreCase(t, (token[0] as IdentToken).val ?? ""),
16188
+ // ) && "hue" === (token[1] as IdentToken).val?.toLowerCase?.()
16189
+ // );
16190
+ // }
15663
16191
  /**
15664
16192
  * Is ident color
15665
16193
  * @param token
@@ -15670,6 +16198,12 @@ function isIdentColor(token) {
15670
16198
  [exports.ColorType.SYS, exports.ColorType.DPSYS, exports.ColorType.LIT].includes(token.kin) &&
15671
16199
  isIdent(token.val));
15672
16200
  }
16201
+ // export function isPercentageToken(token: Token): boolean {
16202
+ // return (
16203
+ // token.typ == EnumToken.PercentageTokenType ||
16204
+ // (token.typ == EnumToken.NumberTokenType && (token as NumberToken).val == 0)
16205
+ // );
16206
+ // }
15673
16207
  function isColor(token, errors) {
15674
16208
  if (token.typ == exports.EnumToken.WildCardFunctionTokenType) {
15675
16209
  return true;
@@ -15933,21 +16467,33 @@ function isColor(token, errors) {
15933
16467
  return true;
15934
16468
  }
15935
16469
  else {
15936
- // @ts-ignore
15937
- if (["rgb", "hsl", "hwb", "lab", "lch", "oklab", "oklch"].some((t) => equalsIgnoreCase(t, token.val))) {
15938
- for (const keyword of token.val.slice(-3).split("")) {
15939
- }
15940
- }
16470
+ // const keywords: string[] = ["from", "none"];
16471
+ //
16472
+ // // @ts-ignore
16473
+ // if (
16474
+ // ["rgb", "hsl", "hwb", "lab", "lch", "oklab", "oklch"].some((t) =>
16475
+ // equalsIgnoreCase(t, (token as ColorToken).val),
16476
+ // )
16477
+ // ) {
16478
+ // // @ts-ignore
16479
+ // keywords.push("alpha");
16480
+ //
16481
+ // for (const keyword of (token as ColorToken).val.slice(-3).split("")) {
16482
+ // keywords.push(keyword);
16483
+ // }
16484
+ // }
15941
16485
  // @ts-ignore
15942
16486
  for (const v of token.chi) {
15943
- if (v.typ == exports.EnumToken.IdenTokenType) {
15944
- continue;
15945
- }
15946
- if (v.typ === exports.EnumToken.MathFunctionTokenType ||
15947
- v.typ === exports.EnumToken.WildCardFunctionTokenType ||
15948
- colorsFunc.includes(v.val)) {
15949
- continue;
15950
- }
16487
+ // if (v.typ == EnumToken.IdenTokenType) {
16488
+ // continue;
16489
+ // }
16490
+ // if (
16491
+ // v.typ === EnumToken.MathFunctionTokenType ||
16492
+ // v.typ === EnumToken.WildCardFunctionTokenType ||
16493
+ // colorsFunc.includes(v.val)
16494
+ // ) {
16495
+ // continue;
16496
+ // }
15951
16497
  }
15952
16498
  }
15953
16499
  return true;
@@ -16093,6 +16639,44 @@ function isNonPrintable(codepoint) {
16093
16639
  codepoint == 0x7f ||
16094
16640
  (codepoint >= 0xe && codepoint <= 0x1f));
16095
16641
  }
16642
+ // export function isURLToken(str: string): boolean {
16643
+ // let i: number = -1;
16644
+ // let c: number;
16645
+ //
16646
+ // while (++i < str.length) {
16647
+ // c = str.charCodeAt(i) as number;
16648
+ //
16649
+ // // single quote or double quote or start parenthesis or close parenthesis
16650
+ // if (isNonPrintable(c) || c == 0x27 || c == 0x22 || c == 0x28 || c == 0x29) {
16651
+ // return false;
16652
+ // }
16653
+ //
16654
+ // // valid escape
16655
+ // if (c == REVERSE_SOLIDUS) {
16656
+ // i++;
16657
+ //
16658
+ // if (i >= str.length) {
16659
+ // return false;
16660
+ // }
16661
+ //
16662
+ // c = str.charCodeAt(i) as number;
16663
+ //
16664
+ // // c is not '\n' or '\r' or '\f'
16665
+ // if (c == 0x6e || c == 0x72 || c == 0x66) {
16666
+ // return false;
16667
+ // }
16668
+ //
16669
+ // continue;
16670
+ // }
16671
+ //
16672
+ // // is white space
16673
+ // if (c == 0x20 || c == 0x09) {
16674
+ // break;
16675
+ // }
16676
+ // }
16677
+ //
16678
+ // return i == str.length;
16679
+ // }
16096
16680
  function isPseudo(name) {
16097
16681
  return (name.charAt(0) == ":" &&
16098
16682
  ((name.endsWith("(") && isIdent(name.charAt(1) == ":" ? name.slice(2, -1) : name.slice(1, -1))) ||
@@ -16101,6 +16685,94 @@ function isPseudo(name) {
16101
16685
  function isHash(name) {
16102
16686
  return name.charAt(0) == "#" && isIdentStart(name.charCodeAt(1));
16103
16687
  }
16688
+ // export const isNumber = memoize(function (name: string): boolean {
16689
+ // let codepoint: number = name.charCodeAt(0) as number;
16690
+ // let i: number = 0;
16691
+ // const j: number = name.length;
16692
+ //
16693
+ // if (j == 1 && !isDigit(codepoint)) {
16694
+ // return false;
16695
+ // }
16696
+ //
16697
+ // // '+' '-'
16698
+ // if ([0x2b, 0x2d].includes(codepoint)) {
16699
+ // i++;
16700
+ // }
16701
+ //
16702
+ // // consume digits
16703
+ // while (i < j) {
16704
+ // codepoint = name.charCodeAt(i) as number;
16705
+ //
16706
+ // if (isDigit(codepoint)) {
16707
+ // i++;
16708
+ // continue;
16709
+ // }
16710
+ //
16711
+ // // '.' 'E' 'e'
16712
+ // if (codepoint == 0x2e || codepoint == 0x45 || codepoint == 0x65) {
16713
+ // break;
16714
+ // }
16715
+ //
16716
+ // return false;
16717
+ // }
16718
+ //
16719
+ // // '.'
16720
+ // if (codepoint == 0x2e) {
16721
+ // if (!isDigit(name.charCodeAt(++i) as number)) {
16722
+ // return false;
16723
+ // }
16724
+ // }
16725
+ //
16726
+ // while (i < j) {
16727
+ // codepoint = name.charCodeAt(i) as number;
16728
+ //
16729
+ // if (isDigit(codepoint)) {
16730
+ // i++;
16731
+ // continue;
16732
+ // }
16733
+ //
16734
+ // // 'E' 'e'
16735
+ // if (codepoint == 0x45 || codepoint == 0x65) {
16736
+ // i++;
16737
+ // break;
16738
+ // }
16739
+ //
16740
+ // return false;
16741
+ // }
16742
+ //
16743
+ // // 'E' 'e'
16744
+ // if (codepoint == 0x45 || codepoint == 0x65) {
16745
+ // // if (i == j) {
16746
+ // // return false;
16747
+ // // }
16748
+ //
16749
+ // codepoint = name.charCodeAt(i + 1) as number;
16750
+ //
16751
+ // // '+' '-'
16752
+ // // if ([0x2b, 0x2d].includes(codepoint)) {
16753
+ // // i++;
16754
+ // // }
16755
+ //
16756
+ // codepoint = name.charCodeAt(i + 1) as number;
16757
+ //
16758
+ // if (!isDigit(codepoint)) {
16759
+ // return false;
16760
+ // }
16761
+ // }
16762
+ //
16763
+ // // while (++i < j) {
16764
+ // // codepoint = name.charCodeAt(i) as number;
16765
+ //
16766
+ // // if (!isDigit(codepoint)) {
16767
+ // // return false;
16768
+ // // }
16769
+ // // }
16770
+ //
16771
+ // return true;
16772
+ // }) as (name: string) => boolean;
16773
+ // export function isPercentage(name: string) {
16774
+ // return name.endsWith("%") && isNumber(name.slice(0, -1));
16775
+ // }
16104
16776
  function isFlex(dimension) {
16105
16777
  return "unit" in dimension && "fr" == dimension.unit.toLowerCase();
16106
16778
  }
@@ -16155,9 +16827,33 @@ function parseDimension(name) {
16155
16827
  }
16156
16828
  return dimension;
16157
16829
  }
16830
+ // export function isHexColor(name: string): boolean {
16831
+ // if (name.charAt(0) != "#" || ![4, 5, 7, 9].includes(name.length)) {
16832
+ // return false;
16833
+ // }
16834
+ //
16835
+ // for (let chr of name.slice(1)) {
16836
+ // let codepoint: number = chr.charCodeAt(0) as number;
16837
+ //
16838
+ // if (
16839
+ // !isDigit(codepoint) &&
16840
+ // // A-F
16841
+ // !(codepoint >= 0x41 && codepoint <= 0x46) &&
16842
+ // // a-f
16843
+ // !(codepoint >= 0x61 && codepoint <= 0x66)
16844
+ // ) {
16845
+ // return false;
16846
+ // }
16847
+ // }
16848
+ //
16849
+ // return true;
16850
+ // }
16158
16851
  function isFunction(name) {
16159
16852
  return name.endsWith("(") && isIdent(name.slice(0, -1));
16160
16853
  }
16854
+ // export function isAtKeyword(name: string): boolean {
16855
+ // return name.charCodeAt(0) == 0x40 && isIdent(name.slice(1));
16856
+ // }
16161
16857
  function isNewLine(codepoint) {
16162
16858
  // \n \r \f \v
16163
16859
  return (codepoint == 0xa ||
@@ -16178,6 +16874,32 @@ function isWhiteSpace(codepoint) {
16178
16874
  codepoint == 0x2028 ||
16179
16875
  codepoint == 0x2029);
16180
16876
  }
16877
+ // export function isValue(token: Token) {
16878
+ // if (token == null) {
16879
+ // return false;
16880
+ // }
16881
+ //
16882
+ // return (
16883
+ // token.typ === EnumToken.IdenTokenType ||
16884
+ // token.typ === EnumToken.DimensionTokenType ||
16885
+ // token.typ === EnumToken.LengthTokenType ||
16886
+ // token.typ === EnumToken.AngleTokenType ||
16887
+ // token.typ === EnumToken.FlexTokenType ||
16888
+ // token.typ === EnumToken.TimeTokenType ||
16889
+ // token.typ === EnumToken.ResolutionTokenType ||
16890
+ // token.typ === EnumToken.FrequencyTokenType ||
16891
+ // token.typ === EnumToken.NumberTokenType ||
16892
+ // token.typ === EnumToken.ColorTokenType ||
16893
+ // token.typ === EnumToken.FunctionTokenType ||
16894
+ // token.typ === EnumToken.UrlFunctionTokenType ||
16895
+ // token.typ === EnumToken.GridTemplateFuncTokenType ||
16896
+ // token.typ === EnumToken.ImageFunctionTokenType ||
16897
+ // token.typ === EnumToken.TimelineFunctionTokenType ||
16898
+ // token.typ === EnumToken.TimingFunctionTokenType ||
16899
+ // token.typ === EnumToken.MathFunctionTokenType ||
16900
+ // token.typ === EnumToken.TransformFunctionTokenType
16901
+ // );
16902
+ // }
16181
16903
  // https://developer.mozilla.org/en-US/docs/Learn_web_development/Core/Styling_basics/Values_and_units#absolute_length_units
16182
16904
  /**
16183
16905
  * Convert length to px
@@ -16260,6 +16982,12 @@ function toPrecisionAngle(angle, precision = anglePrecision, correctValue = true
16260
16982
  return angle;
16261
16983
  }
16262
16984
 
16985
+ /**
16986
+ *
16987
+ * @param a
16988
+ * @param b
16989
+ * @returns
16990
+ */
16263
16991
  function eq(a, b) {
16264
16992
  if (a == null || b == null) {
16265
16993
  return a == b;
@@ -16339,7 +17067,6 @@ function replaceAstNodes(tokens, root) {
16339
17067
  token.val = pseudoAliasMap[token.val];
16340
17068
  if ((equalsIgnoreCase(token.val, "min-resolution") ||
16341
17069
  equalsIgnoreCase(token.val, "max-resolution")) &&
16342
- // ["min-resolution", "max-resolution"].includes((token as IdentToken).val) &&
16343
17070
  value.r?.[0]?.typ == exports.EnumToken.NumberTokenType) {
16344
17071
  Object.assign(value.r?.[0], {
16345
17072
  typ: exports.EnumToken.ResolutionTokenType,
@@ -16347,6 +17074,14 @@ function replaceAstNodes(tokens, root) {
16347
17074
  });
16348
17075
  result = true;
16349
17076
  }
17077
+ let isMin = token.val.startsWith("min-");
17078
+ let isMax = token.val.startsWith("max-");
17079
+ if (isMin || isMax) {
17080
+ token.val = token.val.slice(4);
17081
+ value.op.typ = isMax
17082
+ ? exports.EnumToken.LteTokenType
17083
+ : exports.EnumToken.GteTokenType;
17084
+ }
16350
17085
  }
16351
17086
  }
16352
17087
  }
@@ -16379,6 +17114,7 @@ function replaceAstNodes(tokens, root) {
16379
17114
  }
16380
17115
  }
16381
17116
  }
17117
+ // remove duplicate tokens
16382
17118
  if (tokens.find((t) => t.typ == exports.EnumToken.CommaTokenType) != null) {
16383
17119
  const set = new Set();
16384
17120
  const split = splitTokenList(tokens, [exports.EnumToken.CommaTokenType]);
@@ -19584,6 +20320,7 @@ function objectHash(object) {
19584
20320
  /**
19585
20321
  * convert input to hex
19586
20322
  * @param input
20323
+ * @param length
19587
20324
  */
19588
20325
  function toHex(input, length) {
19589
20326
  let result = "";
@@ -19659,18 +20396,17 @@ const config = getConfig();
19659
20396
  class PropertyList {
19660
20397
  options = { removeDuplicateDeclarations: true, computeShorthand: true };
19661
20398
  declarations;
19662
- // ketsey = new Map;
19663
20399
  constructor(options = {}) {
19664
20400
  this.options = options;
19665
20401
  this.declarations = new Map();
19666
20402
  }
19667
- set(nam, value) {
19668
- return this.add({
19669
- typ: exports.EnumToken.DeclarationNodeType,
19670
- nam,
19671
- val: Array.isArray(value) ? value : parseString(String(value)),
19672
- });
19673
- }
20403
+ // set(nam: string, value: string | Token[]) {
20404
+ // return this.add({
20405
+ // typ: EnumToken.DeclarationNodeType,
20406
+ // nam,
20407
+ // val: Array.isArray(value) ? value : parseString(String(value)),
20408
+ // });
20409
+ // }
19674
20410
  add(...declarations) {
19675
20411
  let name;
19676
20412
  let syntaxRules = null;
@@ -19889,7 +20625,7 @@ class ComputeShorthandFeature {
19889
20625
  }
19890
20626
  }
19891
20627
  run(ast, options) {
19892
- if (!("chi" in ast)) {
20628
+ if (!("chi" in ast || ast.chi?.length == 0)) {
19893
20629
  return null;
19894
20630
  }
19895
20631
  // @ts-ignore
@@ -19932,6 +20668,104 @@ class ComputeShorthandFeature {
19932
20668
  }
19933
20669
  }
19934
20670
 
20671
+ const trimTokenSpace = new Set([
20672
+ exports.EnumToken.CommaTokenType,
20673
+ exports.EnumToken.DelimTokenType,
20674
+ exports.EnumToken.GtTokenType,
20675
+ exports.EnumToken.GteTokenType,
20676
+ exports.EnumToken.LtTokenType,
20677
+ exports.EnumToken.LteTokenType,
20678
+ exports.EnumToken.ChildCombinatorTokenType,
20679
+ ]);
20680
+ const trimSpaceAfter = new Set([
20681
+ ...tokensfuncSet.values(),
20682
+ exports.EnumToken.ChildCombinatorTokenType,
20683
+ exports.EnumToken.SupportsQueryConditionTokenType,
20684
+ exports.EnumToken.SupportsQueryUnaryConditionTokenType,
20685
+ ]);
20686
+ /**
20687
+ * Replace token in its parent node
20688
+ * @param parent
20689
+ * @param node
20690
+ * @param replacement
20691
+ * @throws TypeError replacement is null
20692
+ * @throws ReferenceError node not found in parent
20693
+ */
20694
+ function replaceNodeOrValue(parent, node, replacement) {
20695
+ if (replacement == null || (Array.isArray(replacement) && replacement.length === 0)) {
20696
+ throw new TypeError(`replacement is null`);
20697
+ }
20698
+ for (const newNode of Array.isArray(replacement) ? replacement : [replacement]) {
20699
+ if (newNode[PARENT] != node[PARENT]) {
20700
+ newNode[PARENT] = node[PARENT];
20701
+ }
20702
+ }
20703
+ if (parent.typ == exports.EnumToken.BinaryExpressionTokenType) {
20704
+ if (parent.l == node) {
20705
+ parent.l = replacement;
20706
+ }
20707
+ else if (parent.r == node) {
20708
+ parent.r = replacement;
20709
+ }
20710
+ else {
20711
+ throw new ReferenceError("Node not found");
20712
+ }
20713
+ }
20714
+ else {
20715
+ const target = "val" in parent && Array.isArray(parent.val)
20716
+ ? parent.val
20717
+ : (parent.chi ?? parent);
20718
+ if (Array.isArray(target)) {
20719
+ // @ts-ignore
20720
+ const index = target.indexOf(node);
20721
+ if (index == -1) {
20722
+ throw new ReferenceError("Node not found");
20723
+ }
20724
+ target.splice(index, 1, ...(Array.isArray(replacement) ? replacement : [replacement]));
20725
+ }
20726
+ else if ("l" in target && target.l == node) {
20727
+ target.l = replacement;
20728
+ }
20729
+ else if ("r" in target && target.r == node) {
20730
+ target.r = replacement;
20731
+ }
20732
+ else {
20733
+ throw new ReferenceError("Node not found");
20734
+ }
20735
+ }
20736
+ node[PARENT] = null;
20737
+ return true;
20738
+ }
20739
+ function trimWhiteSpaceTokens(tokens) {
20740
+ let i = 0;
20741
+ if (tokens[0]?.typ === exports.EnumToken.WhitespaceTokenType) {
20742
+ tokens.shift();
20743
+ }
20744
+ if (tokens[tokens.length - 1]?.typ === exports.EnumToken.WhitespaceTokenType) {
20745
+ tokens.pop();
20746
+ }
20747
+ if (tokens.length === 1) {
20748
+ if (tokens[0].typ === exports.EnumToken.WhitespaceTokenType) {
20749
+ tokens.length = 0;
20750
+ }
20751
+ return tokens;
20752
+ }
20753
+ for (; i < tokens.length; i++) {
20754
+ if (trimSpaceAfter.has(tokens[i].typ) && tokens[i + 1]?.typ === exports.EnumToken.WhitespaceTokenType) {
20755
+ tokens.splice(i + 1, 1);
20756
+ }
20757
+ else if (trimTokenSpace.has(tokens[i].typ)) {
20758
+ if (tokens[i + 1]?.typ === exports.EnumToken.WhitespaceTokenType) {
20759
+ tokens.splice(i + 1, 1);
20760
+ }
20761
+ if (i > 0 && tokens[i - 1].typ === exports.EnumToken.Whitespace) {
20762
+ tokens.splice(--i, 1);
20763
+ }
20764
+ }
20765
+ }
20766
+ return tokens;
20767
+ }
20768
+
19935
20769
  class ComputeCalcExpressionFeature {
19936
20770
  accept = new Set([exports.EnumToken.RuleNodeType, exports.EnumToken.AtRuleNodeType]);
19937
20771
  get ordering() {
@@ -20905,7 +21739,6 @@ function compute(transformLists) {
20905
21739
  let matrix = identity();
20906
21740
  let mat;
20907
21741
  let transforms;
20908
- let shouldComputeMatrix = true;
20909
21742
  const cumulative = [];
20910
21743
  // all transform function arguments must be 0 or scale(1)
20911
21744
  for (const transform of transformLists) {
@@ -20924,17 +21757,14 @@ function compute(transformLists) {
20924
21757
  child.typ != exports.EnumToken.PercentageTokenType) ||
20925
21758
  // angle >= 360deg, do not transform
20926
21759
  Math.abs(getAngle(child)) >= 1) {
20927
- shouldComputeMatrix = false;
21760
+ return null;
20928
21761
  }
20929
21762
  }
20930
- break;
20931
- }
20932
- if (!shouldComputeMatrix) {
20933
- break;
21763
+ // break;
20934
21764
  }
20935
21765
  }
20936
21766
  for (const transformList of splitTransformList(transformLists)) {
20937
- mat = shouldComputeMatrix ? computeMatrix(transformList, identity()) : null;
21767
+ mat = computeMatrix(transformList, identity());
20938
21768
  if (mat == null) {
20939
21769
  return null;
20940
21770
  }
@@ -23499,6 +24329,19 @@ function replaceCompoundLiteral(selector, replace) {
23499
24329
  .reduce((acc, curr) => acc + (curr == "&" ? replace : curr), "");
23500
24330
  }
23501
24331
 
24332
+ /**
24333
+ *
24334
+ * @param value
24335
+ * @returns
24336
+ */
24337
+ function toBase64(value) {
24338
+ let result = '';
24339
+ for (const c of new TextEncoder().encode(value)) {
24340
+ result += String.fromCharCode(c);
24341
+ }
24342
+ return btoa(result);
24343
+ }
24344
+
23502
24345
  // from https://github.com/Rich-Harris/vlq/tree/master
23503
24346
  // credit: Rich Harris
23504
24347
  const integer_to_char = {};
@@ -23557,6 +24400,11 @@ function encode(value) {
23557
24400
  }
23558
24401
  return result;
23559
24402
  }
24403
+ /**
24404
+ *
24405
+ * @param num
24406
+ * @returns
24407
+ */
23560
24408
  function encode_integer(num) {
23561
24409
  let result = '';
23562
24410
  if (num < 0) {
@@ -23578,6 +24426,35 @@ function encode_integer(num) {
23578
24426
 
23579
24427
  /**
23580
24428
  * Generate and parse source map
24429
+ *
24430
+ * ```ts
24431
+ * const sourcemap = new SourceMap();
24432
+ *
24433
+ * // you can also pass an input sourcemap
24434
+ * // const sourcemap = new SourceMap(sourcemapObjectOrJSONString);
24435
+ *
24436
+ * sourcemap.addSourceContent(0, '/css/styles.css', null);
24437
+ * sourcemap.addSourceContent(1, '/css/typography.css', null);
24438
+ *
24439
+ * const maps = [];
24440
+ *
24441
+ * maps.add([
24442
+ 1, 1, 0, 1, 1]);
24443
+ * maps.add([
24444
+ 2, 1, 1, 1, 1
24445
+ ]);
24446
+
24447
+ sourcemap.add(maps);
24448
+
24449
+ // convert to inline sourcemap
24450
+ sourcemap.toUrl();
24451
+
24452
+ // convert to JSON
24453
+ sourcemap.toJSON();
24454
+
24455
+ // find the original file, line and column
24456
+ sourcemap.find(2, 1);
24457
+ ```
23581
24458
  */
23582
24459
  class SourceMap {
23583
24460
  /**
@@ -23628,7 +24505,7 @@ class SourceMap {
23628
24505
  line = -1;
23629
24506
  /**
23630
24507
  *
23631
- * @param sourcemaps
24508
+ * @param sourcemaps input sourcemap
23632
24509
  */
23633
24510
  constructor(sourcemaps) {
23634
24511
  if (typeof sourcemaps === "string") {
@@ -23669,9 +24546,9 @@ class SourceMap {
23669
24546
  }
23670
24547
  /**
23671
24548
  * add source
23672
- * @param id
23673
- * @param fileName
23674
- * @param content
24549
+ * @param id source id
24550
+ * @param fileName source file
24551
+ * @param content source content
23675
24552
  * @returns
23676
24553
  */
23677
24554
  addSourceContent(id, fileName, content) {
@@ -23807,7 +24684,7 @@ class SourceMap {
23807
24684
  */
23808
24685
  toUrl() {
23809
24686
  // /*# sourceMappingURL = ${url} */
23810
- return `data:application/json;charset=utf-8;base64,${btoa(JSON.stringify(this.toJSON()))}`;
24687
+ return `data:application/json;charset=utf-8;base64,${toBase64(JSON.stringify(this.toJSON()))}`;
23811
24688
  }
23812
24689
  /**
23813
24690
  * Convert to JSON object
@@ -24247,11 +25124,13 @@ function doRender(data, options = {}, mapping) {
24247
25124
  ...options,
24248
25125
  };
24249
25126
  if (options.withParents) {
24250
- // @ts-ignore
24251
- let parent = data[PARENT];
25127
+ let parent;
24252
25128
  while (data[PARENT] != null) {
24253
25129
  // @ts-ignore
24254
- parent = { ...data[PARENT], chi: [{ ...data }] };
25130
+ // parent = { ...data[PARENT], chi: [data] };
25131
+ parent = cloneNode(data[PARENT]);
25132
+ // @ts-ignore
25133
+ parent.chi = [data];
24255
25134
  // @ts-ignore
24256
25135
  parent[PARENT] = data[PARENT][PARENT];
24257
25136
  // @ts-ignore
@@ -24421,6 +25300,8 @@ function updateSourceMap(node, options, cache, sourcemaps, sourceLocation, lines
24421
25300
  * @param sourceLocation
24422
25301
  * @param linesMap
24423
25302
  * @param str
25303
+ * @param start
25304
+ * @param end
24424
25305
  */
24425
25306
  function move(sourceLocation, linesMap, str, start, end) {
24426
25307
  let i = start ?? 0;
@@ -24613,8 +25494,8 @@ function renderValue(token, options = {}, cache = Object.create(null), reducer,
24613
25494
  };
24614
25495
  }
24615
25496
  switch (token.typ) {
24616
- case exports.EnumToken.FunctionTokenDefType:
24617
25497
  case exports.EnumToken.UrlFunctionTokenDefType:
25498
+ case exports.EnumToken.FunctionTokenDefType:
24618
25499
  case exports.EnumToken.MathFunctionTokenDefType:
24619
25500
  case exports.EnumToken.ImageFunctionTokenDefType:
24620
25501
  case exports.EnumToken.ColorFunctionTokenDefType:
@@ -24758,6 +25639,9 @@ function renderValue(token, options = {}, cache = Object.create(null), reducer,
24758
25639
  }
24759
25640
  case exports.EnumToken.UrlFunctionTokenType:
24760
25641
  if (options.minify && token.typ === exports.EnumToken.UrlFunctionTokenType) {
25642
+ if (token.chi[0]?.typ === exports.EnumToken.BadUrlTokenType) {
25643
+ return "url()";
25644
+ }
24761
25645
  for (const child of token.chi) {
24762
25646
  if (child.typ === exports.EnumToken.StringTokenType) {
24763
25647
  if (child.val.slice(1, 5) !== "data:" &&
@@ -25445,6 +26329,12 @@ function renderValue(token, options = {}, cache = Object.create(null), reducer,
25445
26329
  return token.val.typ == exports.EnumToken.FractionTokenType
25446
26330
  ? renderValue(token.val, options, cache)
25447
26331
  : minifyNumber(token.val);
26332
+ case exports.EnumToken.InfinityTokenType:
26333
+ return "0/0";
26334
+ case exports.EnumToken.NegativeInfinityTokenType:
26335
+ return "-0/0";
26336
+ case exports.EnumToken.NaNTokenType:
26337
+ return "NaN";
25448
26338
  case exports.EnumToken.AtRuleTokenType:
25449
26339
  return "@" + token.nam;
25450
26340
  case exports.EnumToken.CommentTokenType:
@@ -25574,9 +26464,19 @@ function filterValues(values) {
25574
26464
 
25575
26465
  const SymbolsMapTokens = Object.create(null);
25576
26466
  // Regex for escape sequence decoding - compile once, reuse many times
25577
- const ESCAPE_SEQUENCE_REGEX = /\\([0-9a-fA-F]{1,6})(?:\s)?/g;
26467
+ const ESCAPE_SEQUENCE_REGEX = /\\((\n|\r|\f|\v|\u2028|\u2029|([0-9a-fA-F]{1,6})) ?)/gms;
25578
26468
  function decodeEscapeSequences(value) {
25579
26469
  return value.replace(ESCAPE_SEQUENCE_REGEX, (_, sequence) => {
26470
+ // \n \r \f \v
26471
+ switch (sequence.charCodeAt(0)) {
26472
+ case 0xa:
26473
+ case 0xb:
26474
+ case 0xc:
26475
+ case 0xd:
26476
+ case 0x2028:
26477
+ case 0x2029:
26478
+ return "";
26479
+ }
25580
26480
  const codepoint = parseInt(sequence, 16);
25581
26481
  if (codepoint == 0 ||
25582
26482
  // leading surrogate
@@ -25814,18 +26714,17 @@ class Tokenizer {
25814
26714
  constructor(parseInfo, input = null) {
25815
26715
  this.parseInfo = parseInfo;
25816
26716
  this.input = input;
25817
- if (typeof this.parseInfo == "string") {
25818
- if (typeof parseInfo == "string") {
25819
- this.parseInfo = {
26717
+ this.parseInfo =
26718
+ typeof parseInfo == "string"
26719
+ ? {
25820
26720
  stream: parseInfo,
25821
26721
  source: new SourceFile(parseInfo, [], ""),
25822
26722
  offset: 0,
25823
26723
  time: 0,
25824
26724
  position: 0,
25825
26725
  currentPosition: 0,
25826
- };
25827
- }
25828
- }
26726
+ }
26727
+ : parseInfo;
25829
26728
  }
25830
26729
  /**
25831
26730
  *
@@ -25842,6 +26741,18 @@ class Tokenizer {
25842
26741
  this.advance(parseInfo, 2);
25843
26742
  continue;
25844
26743
  }
26744
+ charCode = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset + 1);
26745
+ // \n \r \f \v
26746
+ if (charCode == 0xa ||
26747
+ charCode == 0xb ||
26748
+ charCode == 0xc ||
26749
+ charCode == 0xd ||
26750
+ charCode == 0x2028 ||
26751
+ charCode == 0x2029) {
26752
+ this.advance(parseInfo, 2);
26753
+ decodeSegments = true;
26754
+ continue;
26755
+ }
25845
26756
  const sequence = this.peek(parseInfo, 7);
25846
26757
  let escapeSequence = "";
25847
26758
  let codepoint;
@@ -25885,7 +26796,7 @@ class Tokenizer {
25885
26796
  this.advance(parseInfo);
25886
26797
  }
25887
26798
  // EOF - 'Unclosed-string' fixed
25888
- return this.makeToken(parseInfo, exports.EnumToken.StringTokenType);
26799
+ return this.makeToken(parseInfo, exports.EnumToken.StringTokenType, decodeSegments ? { decodeSegments } : null);
25889
26800
  // return result;
25890
26801
  }
25891
26802
  /**
@@ -25947,7 +26858,7 @@ class Tokenizer {
25947
26858
  return this.makeToken(parseInfo, exports.EnumToken.BadUrlTokenType);
25948
26859
  }
25949
26860
  if (isWhiteSpace(charCode)) {
25950
- this.advance(parseInfo, k);
26861
+ // this.advance(parseInfo, k);
25951
26862
  k++;
25952
26863
  continue;
25953
26864
  }
@@ -26351,14 +27262,28 @@ class Tokenizer {
26351
27262
  } while (
26352
27263
  // !(value === "/" && this.match(parseInfo, "/*") &&
26353
27264
  charCode !== 41 /* TokenMap.RIGHT_PARENTHESIS */ &&
27265
+ !isWhiteSpace(charCode) &&
26354
27266
  parseInfo.currentPosition < endPosition);
26355
- // if (parseInfo.position < parseInfo.currentPosition) {
27267
+ if (charCode !== 41 /* TokenMap.RIGHT_PARENTHESIS */) {
27268
+ let k = 1;
27269
+ while (k < endPosition) {
27270
+ charCode = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset + k);
27271
+ if (isWhiteSpace(charCode)) {
27272
+ k++;
27273
+ continue;
27274
+ }
27275
+ break;
27276
+ }
27277
+ if (charCode != charCode || (charCode != 41 /* TokenMap.RIGHT_PARENTHESIS */ && !isIdentStart(charCode))) {
27278
+ this.advance(parseInfo, k);
27279
+ return this.makeToken(parseInfo, exports.EnumToken.BadUrlTokenType);
27280
+ }
27281
+ }
26356
27282
  return this.makeToken(parseInfo,
26357
27283
  // parseInfo.position < parseInfo.currentPosition
26358
27284
  (charCode = this.peekCharCode(parseInfo)) != charCode || !this.isURLToken(parseInfo)
26359
27285
  ? exports.EnumToken.BadUrlTokenType
26360
27286
  : exports.EnumToken.UrlTokenTokenType);
26361
- // }
26362
27287
  }
26363
27288
  /**
26364
27289
  *
@@ -26603,8 +27528,6 @@ class Tokenizer {
26603
27528
  /**
26604
27529
  *
26605
27530
  * @param parseInfo
26606
- * @param start
26607
- * @param end
26608
27531
  * @returns
26609
27532
  */
26610
27533
  isIdentToken(parseInfo /* , start?: number, end?: number */) {
@@ -26735,8 +27658,6 @@ class Tokenizer {
26735
27658
  }
26736
27659
  /**
26737
27660
  * Tokenize CSS string
26738
- * @param parseInfo
26739
- * @param yieldEOFToken
26740
27661
  */
26741
27662
  next( /* parseInfo: ParseInfo | string, yieldEOFToken: boolean = true */) {
26742
27663
  const parseInfo = this.parseInfo;
@@ -26877,7 +27798,7 @@ class Tokenizer {
26877
27798
  // ) {
26878
27799
  // this.advance(parseInfo);
26879
27800
  // return this.makeToken(parseInfo, EnumToken.PseudoClassFunctionTokenDefType);
26880
- // } else
27801
+ // } else
26881
27802
  if (this.isIdentToken(parseInfo)) {
26882
27803
  const hint = this.startsWith(parseInfo, "--")
26883
27804
  ? exports.EnumToken.CustomFunctionTokenDefType
@@ -27122,6 +28043,9 @@ class Tokenizer {
27122
28043
  case 46 /* TokenMap.DOT */:
27123
28044
  const codepoint = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset + 1);
27124
28045
  if (isIdentStart(codepoint) || codepoint == 45 /* TokenMap.MINUS */) {
28046
+ if (parseInfo.position < parseInfo.currentPosition) {
28047
+ return this.makeToken(parseInfo);
28048
+ }
27125
28049
  this.advance(parseInfo);
27126
28050
  let tokensCount = this.consumeIdentToken(parseInfo);
27127
28051
  if (tokensCount > 0) {
@@ -27153,8 +28077,6 @@ class Tokenizer {
27153
28077
  }
27154
28078
  /**
27155
28079
  * tokenize readable stream
27156
- * @param input
27157
- * @param parseInfo
27158
28080
  */
27159
28081
  async tokenizeStream() {
27160
28082
  const decoder = new TextDecoder("utf-8");
@@ -27399,7 +28321,7 @@ function parseSelector(tokens, context, options, errors) {
27399
28321
  }
27400
28322
  tokens.length = write;
27401
28323
  }
27402
- const result = matchSelectorSyntax(tokens, errors, options, nested === true);
28324
+ const result = matchSelectorSyntax(tokens, errors, options, nested);
27403
28325
  trimArray(tokens);
27404
28326
  if (result.success) {
27405
28327
  for (let i = 0; i < tokens.length; i++) {
@@ -27830,7 +28752,7 @@ function parseDeclaration(tokens, parent, options, errors) {
27830
28752
  let token;
27831
28753
  let index;
27832
28754
  if (syntaxRules != null) {
27833
- const doNotValidate = options.validation === false || options.validation === exports.ValidationLevel.None;
28755
+ const doNotValidate = options.validation === false;
27834
28756
  result = doNotValidate ? null : matchAllSyntaxes(syntaxRules, createValidationContext(tokens), options);
27835
28757
  if (doNotValidate || result != null) {
27836
28758
  success = doNotValidate || result?.success;
@@ -27861,17 +28783,11 @@ function parseDeclaration(tokens, parent, options, errors) {
27861
28783
  stack.push(token);
27862
28784
  continue;
27863
28785
  }
28786
+ if (token.typ === exports.EnumToken.ColonTokenType && stack.length == 0) {
28787
+ stack.push(token);
28788
+ continue;
28789
+ }
27864
28790
  switch (token.typ) {
27865
- // case EnumToken.IdenTokenType:
27866
- // if (tokens[i + 1]?.typ == EnumToken.StartParensTokenType) {
27867
- // Object.assign(token, {
27868
- // typ: EnumToken.FunctionTokenDefType,
27869
- // });
27870
- // token[LOCEND] = tokens[i + 1][LOCEND];
27871
- // tokens.splice(i + 1, 1);
27872
- // stack.push(token);
27873
- // }
27874
- // break;
27875
28791
  case exports.EnumToken.Literal:
27876
28792
  if (token.val === "/" && stack.at(-1)?.typ == exports.EnumToken.MathFunctionTokenDefType) {
27877
28793
  Object.assign(token, {
@@ -28113,12 +29029,11 @@ function parseDeclaration(tokens, parent, options, errors) {
28113
29029
  name[STATE] = exports.EnumAstNodeStatus.Unknown;
28114
29030
  name[ERRORS] = result?.errors ?? [];
28115
29031
  // @ts-expect-error
28116
- const node = Object.assign(name, {
29032
+ return Object.assign(name, {
28117
29033
  typ: exports.EnumToken.DeclarationNodeType,
28118
29034
  nam: name.val,
28119
29035
  val: tokens,
28120
29036
  });
28121
- return node;
28122
29037
  }
28123
29038
  if (equalsIgnoreCase("composes", name.val)) {
28124
29039
  let index = -1;
@@ -28437,6 +29352,16 @@ function parseMediaqueryList(stream, options) {
28437
29352
  val.splice(0, val.length, ...filteredValues);
28438
29353
  }
28439
29354
  }
29355
+ if (stack.at(-1)?.typ === exports.EnumToken.ColonTokenType) {
29356
+ if (name.startsWith("min-")) {
29357
+ filteredNames[0].val = name.substring(4);
29358
+ stack.at(-1).typ = exports.EnumToken.GteTokenType;
29359
+ }
29360
+ else if (name.startsWith("max-")) {
29361
+ filteredNames[0].val = name.substring(4);
29362
+ stack.at(-1).typ = exports.EnumToken.LteTokenType;
29363
+ }
29364
+ }
28440
29365
  // @ts-expect-error
28441
29366
  tokens.splice(index3 + 1, tokens.length - index3 - 2, {
28442
29367
  typ: exports.EnumToken.MediaQueryConditionTokenType,
@@ -28492,6 +29417,61 @@ function parseMediaqueryList(stream, options) {
28492
29417
  [LOCEND]: right.at(-1)[LOCEND],
28493
29418
  };
28494
29419
  tokens.length = l + 1;
29420
+ // media range query
29421
+ if (options.minify &&
29422
+ tokens[l].op.typ === exports.EnumToken.AndTokenType) {
29423
+ if (left.length === 1 &&
29424
+ left[0].typ == exports.EnumToken.ParensTokenType &&
29425
+ left[0].chi.length == 1 &&
29426
+ left[0].chi[0].typ == exports.EnumToken.MediaQueryConditionTokenType &&
29427
+ left[0].chi[0].l.length == 1 &&
29428
+ left[0].chi[0].l[0].typ ==
29429
+ exports.EnumToken.IdenTokenType &&
29430
+ (left[0].chi[0].op.typ ==
29431
+ exports.EnumToken.GtTokenType ||
29432
+ left[0].chi[0].op.typ ==
29433
+ exports.EnumToken.GteTokenType) &&
29434
+ right.length === 1 &&
29435
+ left[0].typ == exports.EnumToken.ParensTokenType &&
29436
+ right[0].chi.length == 1 &&
29437
+ right[0].chi[0].typ ==
29438
+ exports.EnumToken.MediaQueryConditionTokenType &&
29439
+ right[0].chi[0].l.length == 1 &&
29440
+ right[0].chi[0].l[0].typ ==
29441
+ exports.EnumToken.IdenTokenType &&
29442
+ (right[0].chi[0].op.typ ==
29443
+ exports.EnumToken.LtTokenType ||
29444
+ right[0].chi[0].op.typ ==
29445
+ exports.EnumToken.LteTokenType) &&
29446
+ equalsIgnoreCase(left[0].chi[0]
29447
+ .l[0].val, right[0].chi[0]
29448
+ .l[0].val)) {
29449
+ tokens[l] = {
29450
+ typ: exports.EnumToken.ParensTokenType,
29451
+ chi: [
29452
+ {
29453
+ typ: exports.EnumToken.MediaRangeQueryTokenType,
29454
+ op1: Object.assign(left[0].chi[0]
29455
+ .op, {
29456
+ typ: left[0]
29457
+ .chi[0].op.typ == exports.EnumToken.GteTokenType
29458
+ ? exports.EnumToken.LteTokenType
29459
+ : exports.EnumToken.LtTokenType,
29460
+ }),
29461
+ op2: right[0].chi[0]
29462
+ .op,
29463
+ l: left[0].chi[0].r,
29464
+ val: left[0].chi[0]
29465
+ .l,
29466
+ r: right[0].chi[0].r,
29467
+ [LOCSRCID]: left[0][LOCSRCID],
29468
+ [LOCSTA]: left[0][LOCSTA],
29469
+ [LOCEND]: right.at(-1)[LOCEND],
29470
+ },
29471
+ ],
29472
+ };
29473
+ }
29474
+ }
28495
29475
  expectAndOrComma = true;
28496
29476
  }
28497
29477
  }
@@ -28930,7 +29910,7 @@ function matchAtRuleWhenElseSyntax(stream, context, options = {}) {
28930
29910
  let i = 0;
28931
29911
  let success = true;
28932
29912
  let expectAndOr = false;
28933
- let scope = new Set();
29913
+ // let scope: Set<EnumToken> = new Set();
28934
29914
  const errors = [];
28935
29915
  // const scopes: Array<Set<EnumToken>> = [scope];
28936
29916
  for (; i < stream.length; i++) {
@@ -28952,7 +29932,7 @@ function matchAtRuleWhenElseSyntax(stream, context, options = {}) {
28952
29932
  Object.assign(stream[i], {
28953
29933
  typ: "or" === val ? exports.EnumToken.OrTokenType : exports.EnumToken.AndTokenType,
28954
29934
  });
28955
- scope.add(stream[i].typ);
29935
+ // scope.add(stream[i].typ);
28956
29936
  stack.push(stream[i]);
28957
29937
  // break;
28958
29938
  }
@@ -29332,7 +30312,7 @@ function parseAtRuleFontFeatureValues(stream, context, options = {}) {
29332
30312
  const syntaxRules = getSyntaxRule(ValidationSyntaxGroupEnum.AtRules, "@" + context.nam);
29333
30313
  const syntax = syntaxRules?.getPreludeRules()?.slice?.(1);
29334
30314
  trimArray(stream);
29335
- const { success, errors} = matchAllSyntaxes(syntax, createValidationContext(stream), options);
30315
+ const { success, errors /* , ...all */ } = matchAllSyntaxes(syntax, createValidationContext(stream), options);
29336
30316
  return { success, errors };
29337
30317
  }
29338
30318
 
@@ -29844,7 +30824,7 @@ function parseVisitors(visitorsDef, errors) {
29844
30824
  }
29845
30825
  /**
29846
30826
  * Parse css string
29847
- * @param iter
30827
+ * @param tokenizer
29848
30828
  * @param options
29849
30829
  *
29850
30830
  * @throws Error
@@ -30841,6 +31821,7 @@ async function doParse(iter, options = {}) {
30841
31821
  const imports = [];
30842
31822
  let item;
30843
31823
  let node;
31824
+ // @ts-ignore ignore error
30844
31825
  let parensMatch = 0;
30845
31826
  let curlyBracketMatch = 0;
30846
31827
  let tokenizer = iter instanceof Promise ? await iter : iter;
@@ -32839,14 +33820,6 @@ function parseDeclarations(declaration) {
32839
33820
  * ```
32840
33821
  */
32841
33822
  function parseString(src, options = { parseColor: true }, errors) {
32842
- // const parseInfo: ParseInfo = {
32843
- // stream: src,
32844
- // offset: 0,
32845
- // time: 0,
32846
- // source: new SourceFile(src, [], ""),
32847
- // position: 0,
32848
- // currentPosition: 0,
32849
- // };
32850
33823
  const tokenizer = new Tokenizer({
32851
33824
  stream: src,
32852
33825
  buffer: "",
@@ -33460,13 +34433,10 @@ function transformSync(...args) {
33460
34433
  const parseResult = parseSync(stream, options);
33461
34434
  let mapping = null;
33462
34435
  let importMapping = null;
33463
- if (typeof options.module == "number" && options.module & exports.ModuleScopeEnumOptions.ICSS) {
33464
- mapping = parseResult.mapping;
33465
- importMapping = parseResult.importMapping;
33466
- }
33467
- else if (typeof options.module == "object" &&
33468
- typeof options.module.scoped == "number" &&
33469
- options.module.scoped & exports.ModuleScopeEnumOptions.ICSS) {
34436
+ if ((typeof options.module == "number" && options.module & exports.ModuleScopeEnumOptions.ICSS) ||
34437
+ (typeof options.module == "object" &&
34438
+ typeof options.module.scoped == "number" &&
34439
+ options.module.scoped & exports.ModuleScopeEnumOptions.ICSS)) {
33470
34440
  mapping = parseResult.mapping;
33471
34441
  importMapping = parseResult.importMapping;
33472
34442
  }
@@ -33683,13 +34653,10 @@ async function transform(...args) {
33683
34653
  return parse(stream, options).then((parseResult) => {
33684
34654
  let mapping = null;
33685
34655
  let importMapping = null;
33686
- if (typeof options.module == "number" && options.module & exports.ModuleScopeEnumOptions.ICSS) {
33687
- mapping = parseResult.mapping;
33688
- importMapping = parseResult.importMapping;
33689
- }
33690
- else if (typeof options.module == "object" &&
33691
- typeof options.module.scoped == "number" &&
33692
- options.module.scoped & exports.ModuleScopeEnumOptions.ICSS) {
34656
+ if ((typeof options.module == "number" && options.module & exports.ModuleScopeEnumOptions.ICSS) ||
34657
+ (typeof options.module == "object" &&
34658
+ typeof options.module.scoped == "number" &&
34659
+ options.module.scoped & exports.ModuleScopeEnumOptions.ICSS)) {
33693
34660
  mapping = parseResult.mapping;
33694
34661
  importMapping = parseResult.importMapping;
33695
34662
  }