@webstudio-is/css-engine 0.35.0 → 0.40.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/cjs/core/rules.cjs +2 -8
- package/lib/cjs/core/to-property.cjs +36 -0
- package/lib/core/rules.js +2 -2
- package/lib/core/to-property.js +10 -0
- package/package.json +3 -3
- package/src/core/rules.ts +2 -2
- package/src/core/to-property.test.ts +11 -0
- package/src/core/to-property.ts +12 -0
package/lib/cjs/core/rules.cjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,10 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
-
mod
|
|
23
|
-
));
|
|
24
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
19
|
var __accessCheck = (obj, member, msg) => {
|
|
26
20
|
if (!member.has(obj))
|
|
@@ -48,8 +42,8 @@ __export(rules_exports, {
|
|
|
48
42
|
StyleRule: () => StyleRule
|
|
49
43
|
});
|
|
50
44
|
module.exports = __toCommonJS(rules_exports);
|
|
51
|
-
var import_hyphenate_style_name = __toESM(require("hyphenate-style-name"), 1);
|
|
52
45
|
var import_to_value = require("./to-value");
|
|
46
|
+
var import_to_property = require("./to-property");
|
|
53
47
|
var _styleMap, _isDirty, _string, _onChange, _mediaType;
|
|
54
48
|
class StylePropertyMap {
|
|
55
49
|
constructor() {
|
|
@@ -87,7 +81,7 @@ class StylePropertyMap {
|
|
|
87
81
|
if (value === void 0) {
|
|
88
82
|
continue;
|
|
89
83
|
}
|
|
90
|
-
block.push(`${(0,
|
|
84
|
+
block.push(`${(0, import_to_property.toProperty)(property)}: ${(0, import_to_value.toValue)(value)}`);
|
|
91
85
|
}
|
|
92
86
|
__privateSet(this, _string, block.join("; "));
|
|
93
87
|
__privateSet(this, _isDirty, false);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var to_property_exports = {};
|
|
26
|
+
__export(to_property_exports, {
|
|
27
|
+
toProperty: () => toProperty
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(to_property_exports);
|
|
30
|
+
var import_hyphenate_style_name = __toESM(require("hyphenate-style-name"), 1);
|
|
31
|
+
const toProperty = (property) => {
|
|
32
|
+
if (property === "backgroundClip") {
|
|
33
|
+
return "-webkit-background-clip";
|
|
34
|
+
}
|
|
35
|
+
return (0, import_hyphenate_style_name.default)(property);
|
|
36
|
+
};
|
package/lib/core/rules.js
CHANGED
|
@@ -17,8 +17,8 @@ var __privateSet = (obj, member, value, setter) => {
|
|
|
17
17
|
return value;
|
|
18
18
|
};
|
|
19
19
|
var _styleMap, _isDirty, _string, _onChange, _mediaType;
|
|
20
|
-
import hyphenate from "hyphenate-style-name";
|
|
21
20
|
import { toValue } from "./to-value";
|
|
21
|
+
import { toProperty } from "./to-property";
|
|
22
22
|
class StylePropertyMap {
|
|
23
23
|
constructor() {
|
|
24
24
|
__privateAdd(this, _styleMap, /* @__PURE__ */ new Map());
|
|
@@ -55,7 +55,7 @@ class StylePropertyMap {
|
|
|
55
55
|
if (value === void 0) {
|
|
56
56
|
continue;
|
|
57
57
|
}
|
|
58
|
-
block.push(`${
|
|
58
|
+
block.push(`${toProperty(property)}: ${toValue(value)}`);
|
|
59
59
|
}
|
|
60
60
|
__privateSet(this, _string, block.join("; "));
|
|
61
61
|
__privateSet(this, _isDirty, false);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/css-engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.40.0",
|
|
4
4
|
"description": "CSS Renderer for Webstudio",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"hyphenate-style-name": "^1.0.4",
|
|
10
10
|
"react": "^17.0.2",
|
|
11
11
|
"react-dom": "^17.0.2",
|
|
12
|
-
"@webstudio-is/fonts": "^0.
|
|
12
|
+
"@webstudio-is/fonts": "^0.40.0"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@jest/globals": "^29.3.1",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"@types/react-dom": "^17.0.9",
|
|
22
22
|
"jest": "^29.3.1",
|
|
23
23
|
"typescript": "4.9.5",
|
|
24
|
-
"@webstudio-is/css-data": "^0.
|
|
24
|
+
"@webstudio-is/css-data": "^0.40.0",
|
|
25
25
|
"@webstudio-is/jest-config": "^1.0.2",
|
|
26
26
|
"@webstudio-is/scripts": "^0.0.0",
|
|
27
27
|
"@webstudio-is/storybook-config": "^0.0.0",
|
package/src/core/rules.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Style, StyleProperty, StyleValue } from "@webstudio-is/css-data";
|
|
2
|
-
import hyphenate from "hyphenate-style-name";
|
|
3
2
|
import { toValue } from "./to-value";
|
|
3
|
+
import { toProperty } from "./to-property";
|
|
4
4
|
|
|
5
5
|
class StylePropertyMap {
|
|
6
6
|
#styleMap: Map<StyleProperty, StyleValue | undefined> = new Map();
|
|
@@ -37,7 +37,7 @@ class StylePropertyMap {
|
|
|
37
37
|
if (value === undefined) {
|
|
38
38
|
continue;
|
|
39
39
|
}
|
|
40
|
-
block.push(`${
|
|
40
|
+
block.push(`${toProperty(property)}: ${toValue(value)}`);
|
|
41
41
|
}
|
|
42
42
|
this.#string = block.join("; ");
|
|
43
43
|
this.#isDirty = false;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { describe, test } from "@jest/globals";
|
|
2
|
+
import { toProperty } from "./to-property";
|
|
3
|
+
|
|
4
|
+
describe("toProperty", () => {
|
|
5
|
+
test("boxSizing", () => {
|
|
6
|
+
expect(toProperty("boxSizing")).toBe("box-sizing");
|
|
7
|
+
});
|
|
8
|
+
test("backgroundClip", () => {
|
|
9
|
+
expect(toProperty("backgroundClip")).toBe("-webkit-background-clip");
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { StyleProperty } from "@webstudio-is/css-data";
|
|
2
|
+
import hyphenate from "hyphenate-style-name";
|
|
3
|
+
|
|
4
|
+
export const toProperty = (property: StyleProperty) => {
|
|
5
|
+
// Currently its a non-standard property and is only officially supported via -webkit- prefix.
|
|
6
|
+
// Safari illegally supports it without the prefix.
|
|
7
|
+
// https://caniuse.com/background-clip-text
|
|
8
|
+
if (property === "backgroundClip") {
|
|
9
|
+
return "-webkit-background-clip";
|
|
10
|
+
}
|
|
11
|
+
return hyphenate(property);
|
|
12
|
+
};
|