@webstudio-is/css-engine 0.252.1 → 0.253.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 +11 -11
- package/lib/types/core/index.d.ts +1 -1
- package/lib/types/core/rules.d.ts +1 -1
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -678,12 +678,10 @@ var MediaRule = class {
|
|
|
678
678
|
#name;
|
|
679
679
|
options;
|
|
680
680
|
rules;
|
|
681
|
-
#mediaType;
|
|
682
681
|
constructor(name, options = {}) {
|
|
683
682
|
this.#name = name;
|
|
684
683
|
this.options = options;
|
|
685
684
|
this.rules = /* @__PURE__ */ new Map();
|
|
686
|
-
this.#mediaType = options.mediaType ?? "all";
|
|
687
685
|
}
|
|
688
686
|
insertRule(rule) {
|
|
689
687
|
this.rules.set(rule.cssText, rule);
|
|
@@ -720,7 +718,7 @@ var MediaRule = class {
|
|
|
720
718
|
return "";
|
|
721
719
|
}
|
|
722
720
|
let conditionText = "";
|
|
723
|
-
const { minWidth, maxWidth, condition } = this.options;
|
|
721
|
+
const { minWidth, maxWidth, condition, mediaType = "all" } = this.options;
|
|
724
722
|
if (condition !== void 0) {
|
|
725
723
|
conditionText = ` and (${condition})`;
|
|
726
724
|
} else {
|
|
@@ -731,10 +729,8 @@ var MediaRule = class {
|
|
|
731
729
|
conditionText += ` and (max-width: ${maxWidth}px)`;
|
|
732
730
|
}
|
|
733
731
|
}
|
|
734
|
-
return `@media ${
|
|
735
|
-
${rules.join(
|
|
736
|
-
"\n"
|
|
737
|
-
)}
|
|
732
|
+
return `@media ${mediaType}${conditionText} {
|
|
733
|
+
${rules.join("\n")}
|
|
738
734
|
}`;
|
|
739
735
|
}
|
|
740
736
|
};
|
|
@@ -780,17 +776,21 @@ var FontFaceRule = class {
|
|
|
780
776
|
};
|
|
781
777
|
|
|
782
778
|
// src/core/compare-media.ts
|
|
779
|
+
var isSimulatedCondition = (options) => options.mediaType !== void 0 && options.condition === void 0 && options.minWidth === void 0 && options.maxWidth === void 0;
|
|
780
|
+
var isCondition = (options) => options.condition !== void 0 || isSimulatedCondition(options);
|
|
783
781
|
var compareMedia = (optionA, optionB) => {
|
|
784
|
-
|
|
785
|
-
|
|
782
|
+
const aIsCondition = isCondition(optionA);
|
|
783
|
+
const bIsCondition = isCondition(optionB);
|
|
784
|
+
if (aIsCondition && bIsCondition) {
|
|
785
|
+
return (optionA.condition ?? "").localeCompare(optionB.condition ?? "");
|
|
786
786
|
}
|
|
787
|
-
if (
|
|
787
|
+
if (aIsCondition) {
|
|
788
788
|
if (optionB.minWidth === void 0 && optionB.maxWidth === void 0) {
|
|
789
789
|
return 1;
|
|
790
790
|
}
|
|
791
791
|
return -1;
|
|
792
792
|
}
|
|
793
|
-
if (
|
|
793
|
+
if (bIsCondition) {
|
|
794
794
|
if (optionA.minWidth === void 0 && optionA.maxWidth === void 0) {
|
|
795
795
|
return -1;
|
|
796
796
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { StyleMap, NestingRule, MediaRule, PlaintextRule, FontFaceRule, } from "./rules";
|
|
1
|
+
export type { StyleMap, NestingRule, MediaRule, MediaRuleOptions, PlaintextRule, FontFaceRule, } from "./rules";
|
|
2
2
|
export { prefixStyles } from "./prefixer";
|
|
3
3
|
export { mergeStyles } from "./merger";
|
|
4
4
|
export { generateStyleMap } from "./rules";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/css-engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.253.0",
|
|
4
4
|
"description": "CSS Renderer for Webstudio",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@emotion/hash": "^0.9.2",
|
|
10
10
|
"zod": "^3.24.2",
|
|
11
|
-
"@webstudio-is/fonts": "0.
|
|
11
|
+
"@webstudio-is/fonts": "0.253.0"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"@types/react": "^18.2.70",
|