@webstudio-is/css-engine 0.139.0 → 0.141.0

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/lib/index.js CHANGED
@@ -77,6 +77,9 @@ var toValue = (styleValue, transformValue) => {
77
77
  if (value.type === "tuple") {
78
78
  return value.value.map((value2) => toValue(value2, transformValue)).join(" ");
79
79
  }
80
+ if (value.type === "function") {
81
+ return `${value.name}(${toValue(value.args, transformValue)})`;
82
+ }
80
83
  return captureError(new Error("Unknown value type"), value);
81
84
  };
82
85
 
@@ -519,6 +522,11 @@ var RgbValue = z.object({
519
522
  b: z.number(),
520
523
  alpha: z.number()
521
524
  });
525
+ var FunctionValue = z.object({
526
+ type: z.literal("function"),
527
+ name: z.string(),
528
+ args: z.lazy(() => StyleValue)
529
+ });
522
530
  var ImageValue = z.object({
523
531
  type: z.literal("image"),
524
532
  value: z.union([
@@ -542,7 +550,8 @@ var TupleValueItem = z.union([
542
550
  UnitValue,
543
551
  KeywordValue,
544
552
  UnparsedValue,
545
- RgbValue
553
+ RgbValue,
554
+ FunctionValue
546
555
  ]);
547
556
  var TupleValue = z.object({
548
557
  type: z.literal("tuple"),
@@ -555,7 +564,8 @@ var LayerValueItem = z.union([
555
564
  UnparsedValue,
556
565
  ImageValue,
557
566
  TupleValue,
558
- InvalidValue
567
+ InvalidValue,
568
+ FunctionValue
559
569
  ]);
560
570
  var LayersValue = z.object({
561
571
  type: z.literal("layers"),
@@ -569,11 +579,12 @@ var ValidStaticStyleValue = z.union([
569
579
  FontFamilyValue,
570
580
  RgbValue,
571
581
  UnparsedValue,
572
- TupleValue
582
+ TupleValue,
583
+ FunctionValue
573
584
  ]);
574
585
  var isValidStaticStyleValue = (styleValue) => {
575
586
  const staticStyleValue = styleValue;
576
- return staticStyleValue.type === "image" || staticStyleValue.type === "layers" || staticStyleValue.type === "unit" || staticStyleValue.type === "keyword" || staticStyleValue.type === "fontFamily" || staticStyleValue.type === "rgb" || staticStyleValue.type === "unparsed" || staticStyleValue.type === "tuple";
587
+ return staticStyleValue.type === "image" || staticStyleValue.type === "layers" || staticStyleValue.type === "unit" || staticStyleValue.type === "keyword" || staticStyleValue.type === "fontFamily" || staticStyleValue.type === "rgb" || staticStyleValue.type === "unparsed" || staticStyleValue.type === "tuple" || staticStyleValue.type === "function";
577
588
  };
578
589
  var VarValue = z.object({
579
590
  type: z.literal("var"),
@@ -588,6 +599,7 @@ var StyleValue = z.union([
588
599
  ]);
589
600
  var Style = z.record(z.string(), StyleValue);
590
601
  export {
602
+ FunctionValue,
591
603
  ImageValue,
592
604
  InvalidValue,
593
605
  KeywordValue,