@tbela99/css-parser 1.4.7 → 1.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.4.8
4
+
5
+ ### Improvements
6
+
7
+ - [x] support display-p3-linear color space.
8
+
3
9
  ## v1.4.7
4
10
 
5
11
  ### Improvements
@@ -885,6 +885,10 @@
885
885
  * alpha() color function
886
886
  */
887
887
  ColorType[ColorType["ALPHA"] = 25] = "ALPHA";
888
+ /**
889
+ * color using display-p3-linear
890
+ */
891
+ ColorType[ColorType["DISPLAY_P3_LINEAR"] = 26] = "DISPLAY_P3_LINEAR";
888
892
  /**
889
893
  * alias for rgba
890
894
  */
@@ -6617,9 +6621,12 @@
6617
6621
  "srgb",
6618
6622
  "srgb-linear",
6619
6623
  "display-p3",
6624
+ "display-p3-linear",
6620
6625
  "prophoto-rgb",
6621
6626
  "a98-rgb",
6622
6627
  "rec2020",
6628
+ "lab",
6629
+ "oklab",
6623
6630
  "xyz",
6624
6631
  "xyz-d65",
6625
6632
  "xyz-d50",
@@ -8211,7 +8218,7 @@
8211
8218
  if (value == null) {
8212
8219
  return null;
8213
8220
  }
8214
- return hexToken(value.reduce((acc, curr) => acc + srgb2rgb(curr).toString(16).padStart(2, "0"), "#"));
8221
+ return hexToken(value.reduce((acc, curr) => acc + srgb2rgb(curr + Number.EPSILON).toString(16).padStart(2, "0"), "#"));
8215
8222
  }
8216
8223
  function oklab2HexToken(token) {
8217
8224
  let value = oklab2srgbvalues(token);
@@ -8969,6 +8976,14 @@
8969
8976
  // @ts-ignore
8970
8977
  return lp32p3(...xyz2lp3(...srgb2xyz(r, g, b, alpha)));
8971
8978
  }
8979
+ function srgb2lp3values$1(r, g, b, alpha) {
8980
+ // @ts-ignore
8981
+ return xyz2lp3(...srgb2xyz(r, g, b, alpha));
8982
+ }
8983
+ function lp32srgbvalues(r, g, b, alpha) {
8984
+ // @ts-ignore
8985
+ return xyz2srgb(...lp32xyz(r, g, b, alpha));
8986
+ }
8972
8987
  function p32lp3(r, g, b, alpha) {
8973
8988
  // convert an array of display-p3 RGB values in the range 0.0 - 1.0
8974
8989
  // to linear light (un-companded) form.
@@ -9118,6 +9133,10 @@
9118
9133
  // @ts-ignore
9119
9134
  values = srgb2p3values(...values);
9120
9135
  break;
9136
+ case "display-p3-linear":
9137
+ // @ts-ignore
9138
+ values = srgb2lp3values$1(...values);
9139
+ break;
9121
9140
  case "a98-rgb":
9122
9141
  // @ts-ignore
9123
9142
  values = srgb2a98values(...values);
@@ -9341,6 +9360,9 @@
9341
9360
  case "srgb-linear":
9342
9361
  case "a98-rgb":
9343
9362
  case "rec2020":
9363
+ case "display-p3":
9364
+ case "display-p3-linear":
9365
+ case "prophoto-rgb":
9344
9366
  // @ts-ignore
9345
9367
  return {
9346
9368
  typ: exports.EnumToken.ColorTokenType,
@@ -15014,7 +15036,7 @@
15014
15036
  function convertColor(token, to) {
15015
15037
  if (token.kin == exports.ColorType.SYS ||
15016
15038
  token.kin == exports.ColorType.DPSYS ||
15017
- (isIdentColor(token) && "currentcolor" == token.val.toLowerCase())) {
15039
+ (isIdentColor(token) && "currentcolor" == token.val)) {
15018
15040
  return token;
15019
15041
  }
15020
15042
  if (token.kin == exports.ColorType.ALPHA) {
@@ -15425,6 +15447,10 @@
15425
15447
  // @ts-ignore
15426
15448
  values.push(...srgb2p3values(...val));
15427
15449
  break;
15450
+ case exports.ColorType.DISPLAY_P3_LINEAR:
15451
+ // @ts-ignore
15452
+ values.push(...srgb2lp3values(...val));
15453
+ break;
15428
15454
  case exports.ColorType.PROPHOTO_RGB:
15429
15455
  // @ts-ignore
15430
15456
  values.push(...srgb2prophotorgbvalues(...val));
@@ -15459,11 +15485,15 @@
15459
15485
  }
15460
15486
  const colorSpace = components.shift();
15461
15487
  let values = components.map((val) => getNumber(val));
15462
- switch (colorSpace.val.toLowerCase()) {
15488
+ switch (colorSpace.val) {
15463
15489
  case "display-p3":
15464
15490
  // @ts-ignore
15465
15491
  values = p32srgbvalues(...values);
15466
15492
  break;
15493
+ case "display-p3-linear":
15494
+ // @ts-ignore
15495
+ values = lp32srgbvalues(...values);
15496
+ break;
15467
15497
  case "srgb-linear":
15468
15498
  // @ts-ignore
15469
15499
  values = lsrgb2srgbvalues(...values);
@@ -24533,7 +24563,8 @@
24533
24563
  if (token.typ == exports.EnumToken.ResolutionTokenType && unit == "dppx") {
24534
24564
  unit = "x";
24535
24565
  }
24536
- return val.includes("/") ? val.replace("/", unit + "/") : val + unit;
24566
+ // @ts-ignore
24567
+ return val.includes("/") ? val.replace("/", unit + "/") : minifyNumber(toPrecisionValue(val)) + unit;
24537
24568
  case exports.EnumToken.FlexTokenType:
24538
24569
  case exports.EnumToken.PercentageTokenType:
24539
24570
  const uni = token.typ == exports.EnumToken.PercentageTokenType ? "%" : "fr";
@@ -24812,7 +24843,7 @@
24812
24843
  };
24813
24844
  }
24814
24845
  }
24815
- if (currentDirectory === "" && cwd !== "") {
24846
+ if ((currentDirectory === "" || currentDirectory === ".") && cwd !== "") {
24816
24847
  cwd = normalize(cwd);
24817
24848
  if (url.startsWith(cwd == "/" ? cwd : cwd + "/")) {
24818
24849
  const absolute = url;
@@ -24882,7 +24913,12 @@
24882
24913
  if (okLab1 == null || okLab2 == null) {
24883
24914
  return null;
24884
24915
  }
24885
- return Math.hypot(okLab1[0] - okLab2[0], okLab1[1] - okLab2[1], okLab1[2] - okLab2[2]);
24916
+ const diff = [okLab1[0] - okLab2[0], okLab1[1] - okLab2[1], okLab1[2] - okLab2[2]];
24917
+ // include alpha
24918
+ if (okLab1[3] != null || okLab2[3] != null) {
24919
+ diff.push((okLab1[3] ?? 1) - (okLab2[3] ?? 1));
24920
+ }
24921
+ return Math.hypot(...diff);
24886
24922
  }
24887
24923
  /**
24888
24924
  * Check if two colors are close in okLab space.
@@ -25330,19 +25366,7 @@
25330
25366
  */
25331
25367
  function isRectangularOrthogonalColorspace(token) {
25332
25368
  return (token.typ === exports.EnumToken.IdenTokenType &&
25333
- [
25334
- "srgb",
25335
- "srgb-linear",
25336
- "display-p3",
25337
- "a98-rgb",
25338
- "prophoto-rgb",
25339
- "rec2020",
25340
- "lab",
25341
- "oklab",
25342
- "xyz",
25343
- "xyz-d50",
25344
- "xyz-d65",
25345
- ].some((t) => equalsIgnoreCase(t, token.val)));
25369
+ colorFuncColorSpace.some((t) => equalsIgnoreCase(t, token.val)));
25346
25370
  }
25347
25371
  /**
25348
25372
  * Is polar colorspace
@@ -27642,10 +27666,11 @@
27642
27666
  // break;
27643
27667
  // }
27644
27668
  }
27645
- if (mFGT.has(stack.at(-1)?.typ) ||
27646
- mFLT.has(stack.at(-1)?.typ) ||
27647
- stack.at(-1)?.typ === exports.EnumToken.DelimTokenType ||
27648
- stack.at(-1)?.typ === exports.EnumToken.ColonTokenType) {
27669
+ if (stack.length > 0 &&
27670
+ (mFGT.has(stack.at(-1)?.typ) ||
27671
+ mFLT.has(stack.at(-1)?.typ) ||
27672
+ stack.at(-1)?.typ === exports.EnumToken.DelimTokenType ||
27673
+ stack.at(-1)?.typ === exports.EnumToken.ColonTokenType)) {
27649
27674
  // if (stack[stack.length - 2]?.typ !== EnumToken.StartParensTokenType) {
27650
27675
  // success = false;
27651
27676
  // errors.push({
@@ -27767,16 +27792,16 @@
27767
27792
  [LOC]: { ...names[0][LOC], end: values.at(-1)[LOC].end },
27768
27793
  });
27769
27794
  }
27770
- // if (stack.length === 0) {
27771
- // success = false;
27772
- // errors.push({
27773
- // action: "drop",
27774
- // node: stream[i],
27775
- // location: stream[i]?.[LOC],
27776
- // message: `unmatched ')' at ${stream[i]?.[LOC]?.src}:${stream[i]?.[LOC]?.sta.lin}:${stream[i]?.[LOC]?.sta.col}`,
27777
- // });
27778
- // break;
27779
- // }
27795
+ if (stack.length === 0) {
27796
+ success = false;
27797
+ errors.push({
27798
+ action: "drop",
27799
+ node: stream[i],
27800
+ location: stream[i]?.[LOC],
27801
+ message: `unmatched ')' at ${stream[i]?.[LOC]?.src}:${stream[i]?.[LOC]?.sta.lin}:${stream[i]?.[LOC]?.sta.col}`,
27802
+ });
27803
+ break;
27804
+ }
27780
27805
  {
27781
27806
  const index = tokens.indexOf(stack.at(-1));
27782
27807
  tokens[index] = {
@@ -32420,7 +32445,7 @@
32420
32445
  const { file, input, ...opt } = args[0];
32421
32446
  options = opt;
32422
32447
  if (file != null) {
32423
- return Promise.resolve((options.load ?? load)(file, ".", options.asStream ?? false)).then((stream) => parse(stream, { src: options.file, ...options }));
32448
+ return Promise.resolve((options.load ?? load)(file, "", options.asStream ?? false)).then((stream) => parse(stream, { src: options.file, ...options }));
32424
32449
  }
32425
32450
  else {
32426
32451
  stream = input;
@@ -32514,7 +32539,7 @@
32514
32539
  const { file, input, ...opt } = args[0];
32515
32540
  options = opt;
32516
32541
  if (file != null) {
32517
- return Promise.resolve((options.load ?? load)(file, ".", options.asStream ?? false)).then((stream) => transform(stream, { src: options.file, ...options }));
32542
+ return Promise.resolve((options.load ?? load)(file, "", options.asStream ?? false)).then((stream) => transform(stream, { src: options.file, ...options }));
32518
32543
  }
32519
32544
  else {
32520
32545
  stream = input;
package/dist/index.cjs CHANGED
@@ -887,6 +887,10 @@ exports.ColorType = void 0;
887
887
  * alpha() color function
888
888
  */
889
889
  ColorType[ColorType["ALPHA"] = 25] = "ALPHA";
890
+ /**
891
+ * color using display-p3-linear
892
+ */
893
+ ColorType[ColorType["DISPLAY_P3_LINEAR"] = 26] = "DISPLAY_P3_LINEAR";
890
894
  /**
891
895
  * alias for rgba
892
896
  */
@@ -7175,9 +7179,12 @@ const colorFuncColorSpace = [
7175
7179
  "srgb",
7176
7180
  "srgb-linear",
7177
7181
  "display-p3",
7182
+ "display-p3-linear",
7178
7183
  "prophoto-rgb",
7179
7184
  "a98-rgb",
7180
7185
  "rec2020",
7186
+ "lab",
7187
+ "oklab",
7181
7188
  "xyz",
7182
7189
  "xyz-d65",
7183
7190
  "xyz-d50",
@@ -13205,6 +13212,14 @@ function srgb2p3values(r, g, b, alpha) {
13205
13212
  // @ts-ignore
13206
13213
  return lp32p3(...xyz2lp3(...srgb2xyz(r, g, b, alpha)));
13207
13214
  }
13215
+ function srgb2lp3values$1(r, g, b, alpha) {
13216
+ // @ts-ignore
13217
+ return xyz2lp3(...srgb2xyz(r, g, b, alpha));
13218
+ }
13219
+ function lp32srgbvalues(r, g, b, alpha) {
13220
+ // @ts-ignore
13221
+ return xyz2srgb(...lp32xyz(r, g, b, alpha));
13222
+ }
13208
13223
  function p32lp3(r, g, b, alpha) {
13209
13224
  // convert an array of display-p3 RGB values in the range 0.0 - 1.0
13210
13225
  // to linear light (un-companded) form.
@@ -13354,6 +13369,10 @@ function colorMix(...args) {
13354
13369
  // @ts-ignore
13355
13370
  values = srgb2p3values(...values);
13356
13371
  break;
13372
+ case "display-p3-linear":
13373
+ // @ts-ignore
13374
+ values = srgb2lp3values$1(...values);
13375
+ break;
13357
13376
  case "a98-rgb":
13358
13377
  // @ts-ignore
13359
13378
  values = srgb2a98values(...values);
@@ -13577,6 +13596,9 @@ function colorMix(...args) {
13577
13596
  case "srgb-linear":
13578
13597
  case "a98-rgb":
13579
13598
  case "rec2020":
13599
+ case "display-p3":
13600
+ case "display-p3-linear":
13601
+ case "prophoto-rgb":
13580
13602
  // @ts-ignore
13581
13603
  return {
13582
13604
  typ: exports.EnumToken.ColorTokenType,
@@ -14840,7 +14862,7 @@ function alpha(color, alpha) {
14840
14862
  function convertColor(token, to) {
14841
14863
  if (token.kin == exports.ColorType.SYS ||
14842
14864
  token.kin == exports.ColorType.DPSYS ||
14843
- (isIdentColor(token) && "currentcolor" == token.val.toLowerCase())) {
14865
+ (isIdentColor(token) && "currentcolor" == token.val)) {
14844
14866
  return token;
14845
14867
  }
14846
14868
  if (token.kin == exports.ColorType.ALPHA) {
@@ -15251,6 +15273,10 @@ function srgb2srgbcolorspace(val, to) {
15251
15273
  // @ts-ignore
15252
15274
  values.push(...srgb2p3values(...val));
15253
15275
  break;
15276
+ case exports.ColorType.DISPLAY_P3_LINEAR:
15277
+ // @ts-ignore
15278
+ values.push(...srgb2lp3values(...val));
15279
+ break;
15254
15280
  case exports.ColorType.PROPHOTO_RGB:
15255
15281
  // @ts-ignore
15256
15282
  values.push(...srgb2prophotorgbvalues(...val));
@@ -15285,11 +15311,15 @@ function color2srgbvalues(token) {
15285
15311
  }
15286
15312
  const colorSpace = components.shift();
15287
15313
  let values = components.map((val) => getNumber(val));
15288
- switch (colorSpace.val.toLowerCase()) {
15314
+ switch (colorSpace.val) {
15289
15315
  case "display-p3":
15290
15316
  // @ts-ignore
15291
15317
  values = p32srgbvalues(...values);
15292
15318
  break;
15319
+ case "display-p3-linear":
15320
+ // @ts-ignore
15321
+ values = lp32srgbvalues(...values);
15322
+ break;
15293
15323
  case "srgb-linear":
15294
15324
  // @ts-ignore
15295
15325
  values = lsrgb2srgbvalues(...values);
@@ -15479,7 +15509,7 @@ function color2HexToken(token) {
15479
15509
  if (value == null) {
15480
15510
  return null;
15481
15511
  }
15482
- return hexToken(value.reduce((acc, curr) => acc + srgb2rgb(curr).toString(16).padStart(2, "0"), "#"));
15512
+ return hexToken(value.reduce((acc, curr) => acc + srgb2rgb(curr + Number.EPSILON).toString(16).padStart(2, "0"), "#"));
15483
15513
  }
15484
15514
  function oklab2HexToken(token) {
15485
15515
  let value = oklab2srgbvalues(token);
@@ -16062,19 +16092,7 @@ function reduceConicColorStops(stops) {
16062
16092
  */
16063
16093
  function isRectangularOrthogonalColorspace(token) {
16064
16094
  return (token.typ === exports.EnumToken.IdenTokenType &&
16065
- [
16066
- "srgb",
16067
- "srgb-linear",
16068
- "display-p3",
16069
- "a98-rgb",
16070
- "prophoto-rgb",
16071
- "rec2020",
16072
- "lab",
16073
- "oklab",
16074
- "xyz",
16075
- "xyz-d50",
16076
- "xyz-d65",
16077
- ].some((t) => equalsIgnoreCase(t, token.val)));
16095
+ colorFuncColorSpace.some((t) => equalsIgnoreCase(t, token.val)));
16078
16096
  }
16079
16097
  /**
16080
16098
  * Is polar colorspace
@@ -25717,7 +25735,8 @@ function renderValue(token, options = {}, cache = Object.create(null), reducer,
25717
25735
  if (token.typ == exports.EnumToken.ResolutionTokenType && unit == "dppx") {
25718
25736
  unit = "x";
25719
25737
  }
25720
- return val.includes("/") ? val.replace("/", unit + "/") : val + unit;
25738
+ // @ts-ignore
25739
+ return val.includes("/") ? val.replace("/", unit + "/") : minifyNumber(toPrecisionValue(val)) + unit;
25721
25740
  case exports.EnumToken.FlexTokenType:
25722
25741
  case exports.EnumToken.PercentageTokenType:
25723
25742
  const uni = token.typ == exports.EnumToken.PercentageTokenType ? "%" : "fr";
@@ -27405,10 +27424,11 @@ function parseMediaqueryList(stream, options) {
27405
27424
  // break;
27406
27425
  // }
27407
27426
  }
27408
- if (mFGT.has(stack.at(-1)?.typ) ||
27409
- mFLT.has(stack.at(-1)?.typ) ||
27410
- stack.at(-1)?.typ === exports.EnumToken.DelimTokenType ||
27411
- stack.at(-1)?.typ === exports.EnumToken.ColonTokenType) {
27427
+ if (stack.length > 0 &&
27428
+ (mFGT.has(stack.at(-1)?.typ) ||
27429
+ mFLT.has(stack.at(-1)?.typ) ||
27430
+ stack.at(-1)?.typ === exports.EnumToken.DelimTokenType ||
27431
+ stack.at(-1)?.typ === exports.EnumToken.ColonTokenType)) {
27412
27432
  // if (stack[stack.length - 2]?.typ !== EnumToken.StartParensTokenType) {
27413
27433
  // success = false;
27414
27434
  // errors.push({
@@ -27530,16 +27550,16 @@ function parseMediaqueryList(stream, options) {
27530
27550
  [LOC]: { ...names[0][LOC], end: values.at(-1)[LOC].end },
27531
27551
  });
27532
27552
  }
27533
- // if (stack.length === 0) {
27534
- // success = false;
27535
- // errors.push({
27536
- // action: "drop",
27537
- // node: stream[i],
27538
- // location: stream[i]?.[LOC],
27539
- // message: `unmatched ')' at ${stream[i]?.[LOC]?.src}:${stream[i]?.[LOC]?.sta.lin}:${stream[i]?.[LOC]?.sta.col}`,
27540
- // });
27541
- // break;
27542
- // }
27553
+ if (stack.length === 0) {
27554
+ success = false;
27555
+ errors.push({
27556
+ action: "drop",
27557
+ node: stream[i],
27558
+ location: stream[i]?.[LOC],
27559
+ message: `unmatched ')' at ${stream[i]?.[LOC]?.src}:${stream[i]?.[LOC]?.sta.lin}:${stream[i]?.[LOC]?.sta.col}`,
27560
+ });
27561
+ break;
27562
+ }
27543
27563
  {
27544
27564
  const index = tokens.indexOf(stack.at(-1));
27545
27565
  tokens[index] = {
@@ -32177,7 +32197,7 @@ const resolve = memoize(function (url, currentDirectory, cwd) {
32177
32197
  };
32178
32198
  }
32179
32199
  }
32180
- if (currentDirectory === "" && cwd !== "") {
32200
+ if ((currentDirectory === "" || currentDirectory === ".") && cwd !== "") {
32181
32201
  cwd = normalize(cwd);
32182
32202
  if (url.startsWith(cwd == "/" ? cwd : cwd + "/")) {
32183
32203
  const absolute = url;
@@ -32247,7 +32267,12 @@ function okLabDistance(color1, color2) {
32247
32267
  if (okLab1 == null || okLab2 == null) {
32248
32268
  return null;
32249
32269
  }
32250
- return Math.hypot(okLab1[0] - okLab2[0], okLab1[1] - okLab2[1], okLab1[2] - okLab2[2]);
32270
+ const diff = [okLab1[0] - okLab2[0], okLab1[1] - okLab2[1], okLab1[2] - okLab2[2]];
32271
+ // include alpha
32272
+ if (okLab1[3] != null || okLab2[3] != null) {
32273
+ diff.push((okLab1[3] ?? 1) - (okLab2[3] ?? 1));
32274
+ }
32275
+ return Math.hypot(...diff);
32251
32276
  }
32252
32277
  /**
32253
32278
  * Check if two colors are close in okLab space.
@@ -32441,7 +32466,7 @@ async function parse(...args) {
32441
32466
  const { file, input, ...opt } = args[0];
32442
32467
  options = opt;
32443
32468
  if (file != null) {
32444
- return Promise.resolve((options.load ?? load)(file, ".", options.asStream ?? false)).then((stream) => parse(stream, { src: file, ...options }));
32469
+ return Promise.resolve((options.load ?? load)(file, "", options.asStream ?? false)).then((stream) => parse(stream, { src: file, ...options }));
32445
32470
  }
32446
32471
  else {
32447
32472
  stream = input;
@@ -32554,7 +32579,7 @@ async function transform(...args) {
32554
32579
  const { file, input, ...opt } = args[0];
32555
32580
  options = opt;
32556
32581
  if (file != null) {
32557
- return Promise.resolve((options.load ?? load)(file, ".", options.asStream ?? false)).then((stream) => transform(stream, { src: file, ...options }));
32582
+ return Promise.resolve((options.load ?? load)(file, "", options.asStream ?? false)).then((stream) => transform(stream, { src: file, ...options }));
32558
32583
  }
32559
32584
  else {
32560
32585
  stream = input;
package/dist/index.d.ts CHANGED
@@ -2356,6 +2356,10 @@ declare enum ColorType$1 {
2356
2356
  * alpha() color function
2357
2357
  */
2358
2358
  ALPHA = 25,
2359
+ /**
2360
+ * color using display-p3-linear
2361
+ */
2362
+ DISPLAY_P3_LINEAR = 26,
2359
2363
  /**
2360
2364
  * alias for rgba
2361
2365
  */
@@ -879,6 +879,10 @@ var ColorType;
879
879
  * alpha() color function
880
880
  */
881
881
  ColorType[ColorType["ALPHA"] = 25] = "ALPHA";
882
+ /**
883
+ * color using display-p3-linear
884
+ */
885
+ ColorType[ColorType["DISPLAY_P3_LINEAR"] = 26] = "DISPLAY_P3_LINEAR";
882
886
  /**
883
887
  * alias for rgba
884
888
  */
@@ -140,7 +140,7 @@ const resolve = memoize(function (url, currentDirectory, cwd) {
140
140
  };
141
141
  }
142
142
  }
143
- if (currentDirectory === "" && cwd !== "") {
143
+ if ((currentDirectory === "" || currentDirectory === ".") && cwd !== "") {
144
144
  cwd = normalize(cwd);
145
145
  if (url.startsWith(cwd == "/" ? cwd : cwd + "/")) {
146
146
  const absolute = url;
@@ -0,0 +1,206 @@
1
+ import { EnumToken } from '../ast/types.js';
2
+ import { SourceFile } from './source.js';
3
+
4
+ // Node Data layout
5
+ // (node area)
6
+ // node type -> 1 byte
7
+ // parent -> 4 bytes
8
+ // firstChild -> 4 bytes
9
+ // nextSibling -> 4 bytes
10
+ // firstToken -> 4 bytes // parsed selector or at-rule prelude
11
+ // nextToken -> 4 bytes
12
+ // resolvedTokens -> 4 bytes // selector or at-rule prelude as string
13
+ // flags -> 1 byte (validation state, resolved state, resolved prelude state, decoded string state)
14
+ // SpanArena: (start offset 26)
15
+ // sourceId -> 2 bytes
16
+ // sourceSpanStart -> 4 byte
17
+ // sourceSpanLength -> 4 bytes
18
+ // payloadOffset -> 4 bytes
19
+ // payloadType -> 1 byte
20
+ // (data area)
21
+ // data -> (start offset 41): union of ColorArena (ColorKind, r, g, b, a) | string intern id | number | DimensionArena
22
+ // ColorArena (11 bytes):
23
+ // ColorType -> 1 byte
24
+ // resolved -> 4 bytes
25
+ // componentsCount -> 1 byte
26
+ // components -> 3 to 5 bytes (r,g,b / l, c, h / h , w, b / x, y, z / h, s, l), alpha or (c, m, y, k, alpha)
27
+ // DimensionArena (8 bytes):
28
+ // value -> 4 bytes
29
+ // unit -> 4 bytes
30
+ // String (4 bytes):
31
+ // string id -> 4 bytes
32
+ // Number (4 bytes):
33
+ // number -> 4 bytes
34
+ // Percentage (4 bytes):
35
+ // number -> 4 bytes
36
+ // absolute sizes
37
+ const NODE_AREA_SIZE = 41;
38
+ const COLOR_AREA_SIZE = 11;
39
+ const DIMENSION_AREA_SIZE = 8;
40
+ const STRING_AREA_SIZE = 4;
41
+ const NUMBER_AREA_SIZE = 4;
42
+ const PERCENTAGE_AREA_SIZE = 4;
43
+ const NODE_SPAN_OFFSET = 26;
44
+ const NODE_PAYLOAD_OFFSET = 36;
45
+ const NODE_PAYLOAD_TYPE_OFFSET = 40;
46
+ // relative offsets
47
+ const COLOR_TYPE_OFFSET = 0;
48
+ const COLOR_RESOLVED_OFFSET = 1;
49
+ const COLOR_COMPONENTS_COUNT_OFFSET = 5;
50
+ const COLOR_COMPONENTS_OFFSET = 6;
51
+ var PayloadType;
52
+ (function (PayloadType) {
53
+ PayloadType[PayloadType["Unset"] = 0] = "Unset";
54
+ PayloadType[PayloadType["Color"] = 1] = "Color";
55
+ PayloadType[PayloadType["Dimension"] = 2] = "Dimension";
56
+ PayloadType[PayloadType["String"] = 3] = "String";
57
+ PayloadType[PayloadType["Number"] = 4] = "Number";
58
+ PayloadType[PayloadType["Percentage"] = 5] = "Percentage";
59
+ })(PayloadType || (PayloadType = {}));
60
+ class Arena {
61
+ capacity;
62
+ buffer;
63
+ view;
64
+ count = NODE_AREA_SIZE; // node 0 = null
65
+ // root ast node
66
+ sources = [];
67
+ strings;
68
+ constructor(strings, size = 1024) {
69
+ // Heuristic: one node per source character.
70
+ this.capacity = Math.max(1024, size >>> 0);
71
+ this.buffer = new ArrayBuffer(this.capacity * NODE_AREA_SIZE);
72
+ this.view = new DataView(this.buffer);
73
+ this.strings = strings;
74
+ }
75
+ get root() {
76
+ return this.view.getInt32(NODE_AREA_SIZE);
77
+ }
78
+ allocateRoot() {
79
+ if (this.root !== 0) {
80
+ throw new Error("Root node already allocated");
81
+ }
82
+ return this.allocate(EnumToken.StyleSheetNodeType);
83
+ }
84
+ // =====================================================================
85
+ // === API ===
86
+ // ====================================================================
87
+ getFile(id) {
88
+ return this.sources[id].getFile();
89
+ }
90
+ getPosition(id) {
91
+ return this.sources[this.view.getInt16(id + NODE_SPAN_OFFSET)].position(this.view.getInt16(id + NODE_SPAN_OFFSET + 2));
92
+ }
93
+ addSource(content, lines, file = null) {
94
+ this.sources.push(new SourceFile(this.sources.length, content, lines, file));
95
+ return this.sources[this.sources.length - 1];
96
+ }
97
+ allocate(type) {
98
+ if (this.count + NODE_AREA_SIZE >= this.capacity) {
99
+ this.grow();
100
+ }
101
+ const node = this.count;
102
+ this.count += NODE_AREA_SIZE;
103
+ this.view.setUint8(node, type);
104
+ // Other arrays are already zero-initialized.
105
+ // if (typeof data === "string") {
106
+ // this.data[node] = this.allocate(EnumToken.ValueTokenType, this.strings.intern(data));
107
+ // } else if (typeof data === "number") {
108
+ // this.data[node] = this.allocate(EnumToken.ValueTokenType, data);
109
+ // }
110
+ return node;
111
+ }
112
+ allocateNumber(id, data) {
113
+ if (this.view.getUint8(id + NODE_PAYLOAD_TYPE_OFFSET) === PayloadType.Number) {
114
+ this.view.setFloat32(this.view.getInt32(id + NODE_PAYLOAD_OFFSET), data);
115
+ return;
116
+ }
117
+ if (this.count + NUMBER_AREA_SIZE >= this.capacity) {
118
+ this.grow();
119
+ }
120
+ this.view.setUint8(id + NODE_PAYLOAD_TYPE_OFFSET, PayloadType.Number);
121
+ this.view.setInt32(id + NODE_PAYLOAD_OFFSET, this.count);
122
+ this.view.setFloat32(this.count, data);
123
+ this.count += NUMBER_AREA_SIZE;
124
+ }
125
+ allocatePercentage(id, data) {
126
+ if (this.view.getUint8(id + NODE_PAYLOAD_TYPE_OFFSET) === PayloadType.Percentage) {
127
+ this.view.setFloat32(this.view.getInt32(id + NODE_PAYLOAD_OFFSET), data);
128
+ return;
129
+ }
130
+ if (this.count + PERCENTAGE_AREA_SIZE >= this.capacity) {
131
+ this.grow();
132
+ }
133
+ this.view.setUint8(id + NODE_PAYLOAD_TYPE_OFFSET, PayloadType.Percentage);
134
+ this.view.setInt32(id + NODE_PAYLOAD_OFFSET, this.count);
135
+ this.view.setFloat32(this.count, data);
136
+ this.count += PERCENTAGE_AREA_SIZE;
137
+ }
138
+ allocateString(id, data) {
139
+ if (this.view.getUint8(id + NODE_PAYLOAD_TYPE_OFFSET) === PayloadType.String) {
140
+ this.view.setInt32(this.view.getInt32(id + NODE_PAYLOAD_OFFSET), this.strings.intern(data));
141
+ return;
142
+ }
143
+ if (this.count + STRING_AREA_SIZE >= this.capacity) {
144
+ this.grow();
145
+ }
146
+ this.view.setUint8(id + NODE_PAYLOAD_TYPE_OFFSET, PayloadType.String);
147
+ this.view.setInt32(id + NODE_PAYLOAD_OFFSET, this.count);
148
+ this.view.setInt32(this.count, this.strings.intern(data));
149
+ this.count += STRING_AREA_SIZE;
150
+ }
151
+ allocateDimension(id, value, dimension) {
152
+ if (this.view.getUint8(id + NODE_PAYLOAD_TYPE_OFFSET) === PayloadType.Dimension) {
153
+ const offset = this.view.getInt32(id + NODE_PAYLOAD_OFFSET);
154
+ this.view.setFloat32(offset, value);
155
+ this.view.setInt32(offset + 4, this.strings.intern(dimension));
156
+ return;
157
+ }
158
+ if (this.count + DIMENSION_AREA_SIZE >= this.capacity) {
159
+ this.grow();
160
+ }
161
+ this.view.setUint8(id + NODE_PAYLOAD_TYPE_OFFSET, PayloadType.Dimension);
162
+ this.view.setInt32(id + NODE_PAYLOAD_OFFSET, this.count);
163
+ this.view.setFloat32(this.count, value);
164
+ this.view.setFloat32(this.count + 4, this.strings.intern(dimension));
165
+ this.count += DIMENSION_AREA_SIZE;
166
+ }
167
+ allocateColor(id, type) {
168
+ if (this.view.getUint8(id + NODE_PAYLOAD_TYPE_OFFSET) === PayloadType.Color) {
169
+ this.view.setUint8(this.view.getInt32(id + NODE_PAYLOAD_OFFSET) + COLOR_TYPE_OFFSET, type);
170
+ return;
171
+ }
172
+ if (this.count + COLOR_AREA_SIZE >= this.capacity) {
173
+ this.grow();
174
+ }
175
+ this.view.setUint8(id + NODE_PAYLOAD_TYPE_OFFSET, PayloadType.Color);
176
+ this.view.setInt32(id + NODE_PAYLOAD_OFFSET, this.count);
177
+ this.view.setUint8(this.view.getInt32(id + NODE_PAYLOAD_OFFSET) + COLOR_TYPE_OFFSET, type);
178
+ this.count += COLOR_AREA_SIZE;
179
+ }
180
+ resolveColor(id, resolved) {
181
+ this.view.setInt32(this.view.getInt32(id + NODE_PAYLOAD_OFFSET) + COLOR_RESOLVED_OFFSET, this.strings.intern(resolved));
182
+ }
183
+ setColorComponents(id, data) {
184
+ const offset = this.view.getInt32(id + NODE_PAYLOAD_OFFSET);
185
+ this.view.setUint8(offset + COLOR_COMPONENTS_COUNT_OFFSET, data.length);
186
+ for (let i = 0; i < data.length; i++) {
187
+ this.view.setUint8(offset + COLOR_COMPONENTS_OFFSET + i, data[i]);
188
+ }
189
+ }
190
+ setSpans(id, sourceId, start, end) {
191
+ const offset = id + NODE_SPAN_OFFSET;
192
+ this.view.setInt16(offset, sourceId);
193
+ this.view.setInt32(offset + 2, start);
194
+ this.view.setInt32(offset + 6, end);
195
+ }
196
+ grow() {
197
+ const newCapacity = this.capacity * 2;
198
+ const buffer = new ArrayBuffer(newCapacity);
199
+ this.view = new DataView(buffer);
200
+ new Uint8Array(buffer).set(new Uint8Array(this.buffer));
201
+ this.buffer = buffer;
202
+ this.capacity = newCapacity;
203
+ }
204
+ }
205
+
206
+ export { Arena };
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Compute line and column of the offset
3
+ */
4
+ class LineMap {
5
+ /**
6
+ * line starts
7
+ */
8
+ lineStarts;
9
+ constructor(lines) {
10
+ this.lineStarts = lines;
11
+ }
12
+ /**
13
+ * Compute line and column of the offset
14
+ * @param offset
15
+ * @returns
16
+ */
17
+ position(offset) {
18
+ const line = this.search(offset);
19
+ const column = offset - this.lineStarts[line];
20
+ // [line, column]
21
+ return [line + 1, column == 0 ? 1 : column];
22
+ }
23
+ /**
24
+ * search the greatest index of the value less than or equal to offset
25
+ * @param offset
26
+ * @returns
27
+ */
28
+ search(offset) {
29
+ // search lineStarts using binary search
30
+ let start = 0;
31
+ let end = this.lineStarts.length - 1;
32
+ let mid = 0;
33
+ let result = -1;
34
+ while (start <= end) {
35
+ mid = start + ((end - start) >>> 1);
36
+ if (this.lineStarts[mid] <= offset) {
37
+ result = mid;
38
+ start = mid + 1;
39
+ }
40
+ else if (this.lineStarts[mid] > offset) {
41
+ end = mid - 1;
42
+ }
43
+ }
44
+ return result;
45
+ }
46
+ /**
47
+ * set line starts
48
+ * @param lines
49
+ */
50
+ setLineStarts(lines) {
51
+ this.lineStarts = lines;
52
+ }
53
+ /**
54
+ * get line starts
55
+ * @returns
56
+ */
57
+ getLineStarts() {
58
+ return this.lineStarts;
59
+ }
60
+ }
61
+
62
+ export { LineMap };
@@ -0,0 +1,72 @@
1
+ import { LineMap } from './linemap.js';
2
+
3
+ /**
4
+ * Source file helper class
5
+ */
6
+ class SourceFile {
7
+ /**
8
+ * Source file ID
9
+ */
10
+ id;
11
+ /**
12
+ * Source file content
13
+ */
14
+ content;
15
+ /**
16
+ * Source file path
17
+ */
18
+ file;
19
+ /**
20
+ * Line map
21
+ */
22
+ lineStarts;
23
+ /**
24
+ * Constructor
25
+ * @param id
26
+ * @param content
27
+ * @param lines
28
+ * @param file
29
+ */
30
+ constructor(id, content, lines, file = null) {
31
+ this.id = id;
32
+ this.content = content;
33
+ this.file = file;
34
+ this.lineStarts = new LineMap(lines);
35
+ }
36
+ /**
37
+ * Update source content
38
+ * @param content
39
+ * @param lines
40
+ */
41
+ updateContent(content, lines) {
42
+ this.content = content;
43
+ this.lineStarts = new LineMap(lines);
44
+ }
45
+ getFile() {
46
+ return this.file;
47
+ }
48
+ /**
49
+ * Compute line and column of the offset
50
+ * @param offset
51
+ * @returns
52
+ */
53
+ position(offset) {
54
+ return this.lineStarts.position(offset);
55
+ }
56
+ /**
57
+ * set line starts
58
+ * @param lines
59
+ */
60
+ setLineStarts(lines) {
61
+ this.lineStarts.setLineStarts(lines);
62
+ }
63
+ /**
64
+ * get line starts
65
+ * @returns
66
+ */
67
+ getLineStarts() {
68
+ return this.lineStarts.getLineStarts();
69
+ }
70
+ }
71
+
72
+ export { SourceFile };
@@ -373,10 +373,11 @@ function parseMediaqueryList(stream, options) {
373
373
  // break;
374
374
  // }
375
375
  }
376
- if (mFGT.has(stack.at(-1)?.typ) ||
377
- mFLT.has(stack.at(-1)?.typ) ||
378
- stack.at(-1)?.typ === EnumToken.DelimTokenType ||
379
- stack.at(-1)?.typ === EnumToken.ColonTokenType) {
376
+ if (stack.length > 0 &&
377
+ (mFGT.has(stack.at(-1)?.typ) ||
378
+ mFLT.has(stack.at(-1)?.typ) ||
379
+ stack.at(-1)?.typ === EnumToken.DelimTokenType ||
380
+ stack.at(-1)?.typ === EnumToken.ColonTokenType)) {
380
381
  // if (stack[stack.length - 2]?.typ !== EnumToken.StartParensTokenType) {
381
382
  // success = false;
382
383
  // errors.push({
@@ -498,16 +499,16 @@ function parseMediaqueryList(stream, options) {
498
499
  [LOC]: { ...names[0][LOC], end: values.at(-1)[LOC].end },
499
500
  });
500
501
  }
501
- // if (stack.length === 0) {
502
- // success = false;
503
- // errors.push({
504
- // action: "drop",
505
- // node: stream[i],
506
- // location: stream[i]?.[LOC],
507
- // message: `unmatched ')' at ${stream[i]?.[LOC]?.src}:${stream[i]?.[LOC]?.sta.lin}:${stream[i]?.[LOC]?.sta.col}`,
508
- // });
509
- // break;
510
- // }
502
+ if (stack.length === 0) {
503
+ success = false;
504
+ errors.push({
505
+ action: "drop",
506
+ node: stream[i],
507
+ location: stream[i]?.[LOC],
508
+ message: `unmatched ')' at ${stream[i]?.[LOC]?.src}:${stream[i]?.[LOC]?.sta.lin}:${stream[i]?.[LOC]?.sta.col}`,
509
+ });
510
+ break;
511
+ }
511
512
  {
512
513
  const index = tokens.indexOf(stack.at(-1));
513
514
  tokens[index] = {
@@ -1,4 +1,4 @@
1
- import { convertColor, toPrecisionAngle, getAngle } from '../syntax/color/color.js';
1
+ import { convertColor, toPrecisionAngle, toPrecisionValue, getAngle } from '../syntax/color/color.js';
2
2
  import { reduceHexValue } from '../syntax/color/hex.js';
3
3
  import { EnumToken, minifyNumber, ColorType } from '../ast/types.js';
4
4
  import { expand } from '../ast/expand.js';
@@ -1136,7 +1136,8 @@ function renderValue(token, options = {}, cache = Object.create(null), reducer,
1136
1136
  if (token.typ == EnumToken.ResolutionTokenType && unit == "dppx") {
1137
1137
  unit = "x";
1138
1138
  }
1139
- return val.includes("/") ? val.replace("/", unit + "/") : val + unit;
1139
+ // @ts-ignore
1140
+ return val.includes("/") ? val.replace("/", unit + "/") : minifyNumber(toPrecisionValue(val)) + unit;
1140
1141
  case EnumToken.FlexTokenType:
1141
1142
  case EnumToken.PercentageTokenType:
1142
1143
  const uni = token.typ == EnumToken.PercentageTokenType ? "%" : "fr";
@@ -6,7 +6,7 @@ import { srgb2rgb } from './rgb.js';
6
6
  import { srgb2hslvalues } from './hsl.js';
7
7
  import { srgb2hwb } from './hwb.js';
8
8
  import { srgb2labvalues } from './lab.js';
9
- import { srgb2p3values } from './p3.js';
9
+ import { srgb2lp3values, srgb2p3values } from './p3.js';
10
10
  import { getColorComponents } from './utils/components.js';
11
11
  import { srgb2oklch } from './oklch.js';
12
12
  import { srgb2oklab } from './oklab.js';
@@ -127,6 +127,10 @@ function colorMix(...args) {
127
127
  // @ts-ignore
128
128
  values = srgb2p3values(...values);
129
129
  break;
130
+ case "display-p3-linear":
131
+ // @ts-ignore
132
+ values = srgb2lp3values(...values);
133
+ break;
130
134
  case "a98-rgb":
131
135
  // @ts-ignore
132
136
  values = srgb2a98values(...values);
@@ -350,6 +354,9 @@ function colorMix(...args) {
350
354
  case "srgb-linear":
351
355
  case "a98-rgb":
352
356
  case "rec2020":
357
+ case "display-p3":
358
+ case "display-p3-linear":
359
+ case "prophoto-rgb":
353
360
  // @ts-ignore
354
361
  return {
355
362
  typ: EnumToken.ColorTokenType,
@@ -11,11 +11,11 @@ import { oklch2srgbvalues, lch2srgbvalues, oklab2srgbvalues, lab2srgbvalues, cmy
11
11
  import { prophotorgb2srgbvalues, srgb2prophotorgbvalues } from './prophotorgb.js';
12
12
  import { rec20202srgb, srgb2rec2020values } from './rec2020.js';
13
13
  import { srgb2xyz_d65, srgb2xyz } from './xyz.js';
14
- import { p32srgbvalues, srgb2p3values } from './p3.js';
14
+ import { lp32srgbvalues, p32srgbvalues, srgb2p3values } from './p3.js';
15
15
  import { xyzd502srgb } from './xyzd50.js';
16
16
  import { colorMix } from './color-mix.js';
17
17
  import { reduceHexValue, rgb2HexToken, color2HexToken, lch2HexToken, lab2HexToken, oklch2HexToken, oklab2HexToken, cmyk2HexToken, hwb2HexToken, hsl2HexToken } from './hex.js';
18
- import { parseRelativeColorComponents } from './relativecolor.js';
18
+ import { parseRelativeColorComponents } from './relative-color.js';
19
19
  import { isIdentColor } from '../syntax.js';
20
20
  import { color2cmykToken, lch2cmykToken, lab2cmykToken, oklch2cmykToken, oklab2cmyk, hwb2cmykToken, hsl2cmykToken, rgb2cmykToken } from './cmyk.js';
21
21
  import { a98rgb2srgbvalues, srgb2a98values } from './a98rgb.js';
@@ -39,7 +39,7 @@ import { equalsIgnoreCase } from '../../parser/utils/text.js';
39
39
  function convertColor(token, to) {
40
40
  if (token.kin == ColorType.SYS ||
41
41
  token.kin == ColorType.DPSYS ||
42
- (isIdentColor(token) && "currentcolor" == token.val.toLowerCase())) {
42
+ (isIdentColor(token) && "currentcolor" == token.val)) {
43
43
  return token;
44
44
  }
45
45
  if (token.kin == ColorType.ALPHA) {
@@ -450,6 +450,10 @@ function srgb2srgbcolorspace(val, to) {
450
450
  // @ts-ignore
451
451
  values.push(...srgb2p3values(...val));
452
452
  break;
453
+ case ColorType.DISPLAY_P3_LINEAR:
454
+ // @ts-ignore
455
+ values.push(...srgb2lp3values(...val));
456
+ break;
453
457
  case ColorType.PROPHOTO_RGB:
454
458
  // @ts-ignore
455
459
  values.push(...srgb2prophotorgbvalues(...val));
@@ -484,11 +488,15 @@ function color2srgbvalues(token) {
484
488
  }
485
489
  const colorSpace = components.shift();
486
490
  let values = components.map((val) => getNumber(val));
487
- switch (colorSpace.val.toLowerCase()) {
491
+ switch (colorSpace.val) {
488
492
  case "display-p3":
489
493
  // @ts-ignore
490
494
  values = p32srgbvalues(...values);
491
495
  break;
496
+ case "display-p3-linear":
497
+ // @ts-ignore
498
+ values = lp32srgbvalues(...values);
499
+ break;
492
500
  case "srgb-linear":
493
501
  // @ts-ignore
494
502
  values = lsrgb2srgbvalues(...values);
@@ -70,7 +70,7 @@ function color2HexToken(token) {
70
70
  if (value == null) {
71
71
  return null;
72
72
  }
73
- return hexToken(value.reduce((acc, curr) => acc + srgb2rgb(curr).toString(16).padStart(2, "0"), "#"));
73
+ return hexToken(value.reduce((acc, curr) => acc + srgb2rgb(curr + Number.EPSILON).toString(16).padStart(2, "0"), "#"));
74
74
  }
75
75
  function oklab2HexToken(token) {
76
76
  let value = oklab2srgbvalues(token);
@@ -10,6 +10,14 @@ function srgb2p3values(r, g, b, alpha) {
10
10
  // @ts-ignore
11
11
  return lp32p3(...xyz2lp3(...srgb2xyz(r, g, b, alpha)));
12
12
  }
13
+ function srgb2lp3values(r, g, b, alpha) {
14
+ // @ts-ignore
15
+ return xyz2lp3(...srgb2xyz(r, g, b, alpha));
16
+ }
17
+ function lp32srgbvalues(r, g, b, alpha) {
18
+ // @ts-ignore
19
+ return xyz2srgb(...lp32xyz(r, g, b, alpha));
20
+ }
13
21
  function p32lp3(r, g, b, alpha) {
14
22
  // convert an array of display-p3 RGB values in the range 0.0 - 1.0
15
23
  // to linear light (un-companded) form.
@@ -49,4 +57,4 @@ function xyz2lp3(x, y, z, alpha) {
49
57
  return result;
50
58
  }
51
59
 
52
- export { lp32p3, lp32xyz, p32lp3, p32srgbvalues, srgb2p3values, xyz2lp3 };
60
+ export { lp32p3, lp32srgbvalues, lp32xyz, p32lp3, p32srgbvalues, srgb2lp3values, srgb2p3values, xyz2lp3 };
@@ -22,7 +22,12 @@ function okLabDistance(color1, color2) {
22
22
  if (okLab1 == null || okLab2 == null) {
23
23
  return null;
24
24
  }
25
- return Math.hypot(okLab1[0] - okLab2[0], okLab1[1] - okLab2[1], okLab1[2] - okLab2[2]);
25
+ const diff = [okLab1[0] - okLab2[0], okLab1[1] - okLab2[1], okLab1[2] - okLab2[2]];
26
+ // include alpha
27
+ if (okLab1[3] != null || okLab2[3] != null) {
28
+ diff.push((okLab1[3] ?? 1) - (okLab2[3] ?? 1));
29
+ }
30
+ return Math.hypot(...diff);
26
31
  }
27
32
  /**
28
33
  * Check if two colors are close in okLab space.
@@ -247,9 +247,12 @@ const colorFuncColorSpace = [
247
247
  "srgb",
248
248
  "srgb-linear",
249
249
  "display-p3",
250
+ "display-p3-linear",
250
251
  "prophoto-rgb",
251
252
  "a98-rgb",
252
253
  "rec2020",
254
+ "lab",
255
+ "oklab",
253
256
  "xyz",
254
257
  "xyz-d65",
255
258
  "xyz-d50",
@@ -387,19 +387,7 @@ function reduceConicColorStops(stops) {
387
387
  */
388
388
  function isRectangularOrthogonalColorspace(token) {
389
389
  return (token.typ === EnumToken.IdenTokenType &&
390
- [
391
- "srgb",
392
- "srgb-linear",
393
- "display-p3",
394
- "a98-rgb",
395
- "prophoto-rgb",
396
- "rec2020",
397
- "lab",
398
- "oklab",
399
- "xyz",
400
- "xyz-d50",
401
- "xyz-d65",
402
- ].some((t) => equalsIgnoreCase(t, token.val)));
390
+ colorFuncColorSpace.some((t) => equalsIgnoreCase(t, token.val)));
403
391
  }
404
392
  /**
405
393
  * Is polar colorspace
package/dist/node.js CHANGED
@@ -188,7 +188,7 @@ async function parse(...args) {
188
188
  const { file, input, ...opt } = args[0];
189
189
  options = opt;
190
190
  if (file != null) {
191
- return Promise.resolve((options.load ?? load)(file, ".", options.asStream ?? false)).then((stream) => parse(stream, { src: file, ...options }));
191
+ return Promise.resolve((options.load ?? load)(file, "", options.asStream ?? false)).then((stream) => parse(stream, { src: file, ...options }));
192
192
  }
193
193
  else {
194
194
  stream = input;
@@ -301,7 +301,7 @@ async function transform(...args) {
301
301
  const { file, input, ...opt } = args[0];
302
302
  options = opt;
303
303
  if (file != null) {
304
- return Promise.resolve((options.load ?? load)(file, ".", options.asStream ?? false)).then((stream) => transform(stream, { src: file, ...options }));
304
+ return Promise.resolve((options.load ?? load)(file, "", options.asStream ?? false)).then((stream) => transform(stream, { src: file, ...options }));
305
305
  }
306
306
  else {
307
307
  stream = input;
package/dist/web.js CHANGED
@@ -164,7 +164,7 @@ async function parse(...args) {
164
164
  const { file, input, ...opt } = args[0];
165
165
  options = opt;
166
166
  if (file != null) {
167
- return Promise.resolve((options.load ?? load)(file, ".", options.asStream ?? false)).then((stream) => parse(stream, { src: options.file, ...options }));
167
+ return Promise.resolve((options.load ?? load)(file, "", options.asStream ?? false)).then((stream) => parse(stream, { src: options.file, ...options }));
168
168
  }
169
169
  else {
170
170
  stream = input;
@@ -258,7 +258,7 @@ async function transform(...args) {
258
258
  const { file, input, ...opt } = args[0];
259
259
  options = opt;
260
260
  if (file != null) {
261
- return Promise.resolve((options.load ?? load)(file, ".", options.asStream ?? false)).then((stream) => transform(stream, { src: options.file, ...options }));
261
+ return Promise.resolve((options.load ?? load)(file, "", options.asStream ?? false)).then((stream) => transform(stream, { src: options.file, ...options }));
262
262
  }
263
263
  else {
264
264
  stream = input;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tbela99/css-parser",
3
3
  "description": "CSS parser, minifier and validator for node and the browser",
4
- "version": "1.4.7",
4
+ "version": "1.4.8",
5
5
  "exports": {
6
6
  ".": "./dist/node.js",
7
7
  "./node": "./dist/node.js",
@@ -21,7 +21,7 @@
21
21
  "test": "web-test-runner \"./test/**/web.spec.js\" --timeout=10000 --node-resolve --playwright --browsers chromium firefox webkit --root-dir=.; mocha --reporter-options='maxDiffSize=1801920' --timeout=10000 \"test/**/node.spec.js\"",
22
22
  "test:web": "web-test-runner \"./test/**/web.spec.js\" --timeout 30000 --node-resolve --playwright --browsers chromium firefox webkit --root-dir=.",
23
23
  "test:node": "mocha -p --reporter-options='maxDiffSize=1801920' --timeout=10000 \"test/**/node.spec.js\"",
24
- "test:cov": "superc8 -x 'test/specs/**/*.js' --reporter=html --reporter=text --reporter=json-summary mocha --reporter-options='maxDiffSize=1801920' -p --timeout=10000 'test/**/node.spec.js'",
24
+ "test:cov": "superc8 -x 'test/specs/**/*.js' --reporter=html --reporter=text --reporter=json-summary mocha --reporter-options='maxDiffSize=1801920' -p --timeout=10000 'test/allFiles.js' 'test/**/node.spec.js'",
25
25
  "test:web-cov": "web-test-runner -x 'test/specs/code/*.js' --node-resolve --playwright --browsers chromium firefox webkit --root-dir=. --coverage \"test/specs/web.spec.js\"",
26
26
  "profile": "deno run --allow-read --cpu-prof --cpu-prof-flamegraph test/inspect.js",
27
27
  "config-update": "esno scripts/shorthand.ts",