@colorye/react-native-css 0.3.1 → 0.3.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.
- package/crates/transformer/index.js +1 -0
- package/crates/transformer/transformer.darwin-arm64.node +0 -0
- package/crates/transformer/transformer.darwin-x64.node +0 -0
- package/crates/transformer/transformer.linux-x64-gnu.node +0 -0
- package/crates/transformer/transformer.node +0 -0
- package/crates/transformer/transformer.win32-x64-msvc.node +0 -0
- package/dist/babel.js +68 -159
- package/dist/index.d.ts +22 -8
- package/dist/interop.js +17 -5
- package/dist/metro.js +55 -0
- package/dist/transformer-runtime.js +170 -18
- package/dist/transformer.js +73 -20
- package/package.json +3 -1
- package/src/babel.js +71 -224
- package/src/index.d.ts +22 -8
- package/src/interop.js +13 -1
- package/src/metro.js +42 -0
- package/src/transformer-runtime.js +169 -15
- package/src/transformer.js +75 -15
- package/dist/features/build-transform.js +0 -575
- package/dist/features/css-calc.js +0 -539
- package/dist/features/css-media.js +0 -77
- package/dist/features/css-transform.js +0 -426
- package/dist/features/css-vars.js +0 -153
- package/dist/features/stylesheet.js +0 -45
- package/dist/utils/babel.js +0 -363
- package/dist/utils/css.js +0 -263
- package/dist/utils/helper.js +0 -11
- package/src/features/build-transform.js +0 -536
- package/src/features/css-calc.js +0 -490
- package/src/features/css-media.js +0 -78
- package/src/features/css-transform.js +0 -446
- package/src/features/css-vars.js +0 -138
- package/src/features/stylesheet.js +0 -29
- package/src/utils/babel.js +0 -425
- package/src/utils/css.js +0 -221
- package/src/utils/helper.js +0 -3
|
@@ -1,426 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = CssTransform;
|
|
7
|
-
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
8
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
10
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
11
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
-
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
13
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
14
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
15
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
16
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
17
|
-
var UNSUPPORTED_PROPERTIES = ["outline"];
|
|
18
|
-
var remOrEmUnitRe = /([\d.]+)(?:rem|em)\b/g;
|
|
19
|
-
function CssTransform() {
|
|
20
|
-
var _this = this;
|
|
21
|
-
this.transformUnsafeValue = function (property, value) {
|
|
22
|
-
if (!_this.isPropertySupported(property, value)) {
|
|
23
|
-
console.info("UNSUPPORTED", property, value);
|
|
24
|
-
return [];
|
|
25
|
-
}
|
|
26
|
-
if (typeof value === "string") {
|
|
27
|
-
value = value.trim();
|
|
28
|
-
value = _this.transformImportant(property, value);
|
|
29
|
-
}
|
|
30
|
-
value = _this.transformPosition(property, value);
|
|
31
|
-
value = _this.transformBorderRadius(property, value);
|
|
32
|
-
value = _this.transformOpacity(property, value);
|
|
33
|
-
property = _this.getAliasedPropertyName(property);
|
|
34
|
-
return [property, value];
|
|
35
|
-
};
|
|
36
|
-
this.transformUnsupportedUnit = function (value) {
|
|
37
|
-
if (value === undefined || typeof value !== "string") return value;
|
|
38
|
-
remOrEmUnitRe.lastIndex = 0;
|
|
39
|
-
return value.replace(remOrEmUnitRe, function (_, rem) {
|
|
40
|
-
return rem * 16;
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
this.transformViewportUnit = function (value) {
|
|
44
|
-
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
45
|
-
width = _ref.width,
|
|
46
|
-
height = _ref.height;
|
|
47
|
-
if (value === undefined || typeof value !== "string") return value;
|
|
48
|
-
if (!width || !height) return value;
|
|
49
|
-
var viewportUnitRe = /([+-]?[0-9.]+)(vh|vw|vmin|vmax)\b/g;
|
|
50
|
-
var dimensionsMap = {
|
|
51
|
-
vw: width,
|
|
52
|
-
vh: height
|
|
53
|
-
};
|
|
54
|
-
return value.replace(viewportUnitRe, function (_, number, unit) {
|
|
55
|
-
return parseFloat(number) * dimensionsMap[unit] / 100;
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
this.removeUnit = function (value) {
|
|
59
|
-
if (value === undefined || typeof value !== "string") return value;
|
|
60
|
-
return value.replace(/px/g, "");
|
|
61
|
-
};
|
|
62
|
-
this.isPropertySupported = function (property, value) {
|
|
63
|
-
if (UNSUPPORTED_PROPERTIES.includes(property)) return false;
|
|
64
|
-
if (value === undefined) return false;
|
|
65
|
-
if (!["number", "string"].includes(_typeof(value))) return false;
|
|
66
|
-
return true;
|
|
67
|
-
};
|
|
68
|
-
this.transformImportant = function (property, value) {
|
|
69
|
-
if (typeof value !== "string") return value;
|
|
70
|
-
return value.replace(/!important/g, "");
|
|
71
|
-
};
|
|
72
|
-
this.transformPosition = function (property, value) {
|
|
73
|
-
if (property === "position" && value === "fixed") {
|
|
74
|
-
return "absolute";
|
|
75
|
-
}
|
|
76
|
-
return value;
|
|
77
|
-
};
|
|
78
|
-
this.transformBorderRadius = function (property, value) {
|
|
79
|
-
if (property.toLowerCase().endsWith("radius") && typeof value === "string" && value.includes("%")) {
|
|
80
|
-
return 9999;
|
|
81
|
-
}
|
|
82
|
-
return value;
|
|
83
|
-
};
|
|
84
|
-
this.transformOpacity = function (property, value) {
|
|
85
|
-
if (property === "opacity" && typeof value === "string" && value.endsWith("%")) {
|
|
86
|
-
var num = parseFloat(value);
|
|
87
|
-
if (!isNaN(num)) {
|
|
88
|
-
return num / 100;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return value;
|
|
92
|
-
};
|
|
93
|
-
this.transformBorder = function (property, value) {
|
|
94
|
-
if (value === "none") {
|
|
95
|
-
return _defineProperty({}, "".concat(property, "Width"), 0);
|
|
96
|
-
}
|
|
97
|
-
var borderRe = /(\S+)(?:\s+(solid|dashed|dotted)(?:\s+(\S+))?)?/g;
|
|
98
|
-
var _ref3 = borderRe.exec(String(value)) || [],
|
|
99
|
-
_ref4 = _slicedToArray(_ref3, 4),
|
|
100
|
-
width = _ref4[1],
|
|
101
|
-
style = _ref4[2],
|
|
102
|
-
color = _ref4[3];
|
|
103
|
-
var transformed = {};
|
|
104
|
-
if (width) {
|
|
105
|
-
var wStr = String(width).trim();
|
|
106
|
-
transformed["".concat(property, "Width")] = wStr !== "" && !isNaN(Number(wStr)) ? Number(wStr) : width;
|
|
107
|
-
} else {
|
|
108
|
-
transformed["".concat(property, "Width")] = 0;
|
|
109
|
-
}
|
|
110
|
-
if (style) {
|
|
111
|
-
transformed.borderStyle = ["solid", "dotted", "dashed"].includes(style) ? style : "solid";
|
|
112
|
-
}
|
|
113
|
-
if (color) {
|
|
114
|
-
transformed["".concat(property, "Color")] = color;
|
|
115
|
-
}
|
|
116
|
-
return transformed;
|
|
117
|
-
};
|
|
118
|
-
this.transformSpacing = function (property, value) {
|
|
119
|
-
var strValue = String(value).trim();
|
|
120
|
-
var parts = [];
|
|
121
|
-
var current = "";
|
|
122
|
-
var depth = 0;
|
|
123
|
-
for (var i = 0; i < strValue.length; i++) {
|
|
124
|
-
var _char = strValue[i];
|
|
125
|
-
if (_char === "(") {
|
|
126
|
-
depth++;
|
|
127
|
-
current += _char;
|
|
128
|
-
} else if (_char === ")") {
|
|
129
|
-
depth--;
|
|
130
|
-
current += _char;
|
|
131
|
-
} else if (_char === " " && depth === 0) {
|
|
132
|
-
if (current) {
|
|
133
|
-
parts.push(current);
|
|
134
|
-
current = "";
|
|
135
|
-
}
|
|
136
|
-
} else {
|
|
137
|
-
current += _char;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
if (current) {
|
|
141
|
-
parts.push(current);
|
|
142
|
-
}
|
|
143
|
-
var cleanedParts = parts.filter(Boolean);
|
|
144
|
-
var toNumberOrString = function toNumberOrString(val) {
|
|
145
|
-
if (typeof val === "string" && val.trim() !== "" && !isNaN(Number(val))) {
|
|
146
|
-
return Number(val);
|
|
147
|
-
}
|
|
148
|
-
return val;
|
|
149
|
-
};
|
|
150
|
-
var transformed = {};
|
|
151
|
-
if (cleanedParts.length === 0) {
|
|
152
|
-
transformed["".concat(property, "Top")] = 0;
|
|
153
|
-
transformed["".concat(property, "Right")] = 0;
|
|
154
|
-
transformed["".concat(property, "Bottom")] = 0;
|
|
155
|
-
transformed["".concat(property, "Left")] = 0;
|
|
156
|
-
} else if (cleanedParts.length === 1) {
|
|
157
|
-
var top = cleanedParts[0];
|
|
158
|
-
transformed["".concat(property, "Top")] = toNumberOrString(top);
|
|
159
|
-
transformed["".concat(property, "Right")] = toNumberOrString(top);
|
|
160
|
-
transformed["".concat(property, "Bottom")] = toNumberOrString(top);
|
|
161
|
-
transformed["".concat(property, "Left")] = toNumberOrString(top);
|
|
162
|
-
} else if (cleanedParts.length === 2) {
|
|
163
|
-
var _top = cleanedParts[0];
|
|
164
|
-
var right = cleanedParts[1];
|
|
165
|
-
transformed["".concat(property, "Top")] = toNumberOrString(_top);
|
|
166
|
-
transformed["".concat(property, "Right")] = toNumberOrString(right);
|
|
167
|
-
transformed["".concat(property, "Bottom")] = toNumberOrString(_top);
|
|
168
|
-
transformed["".concat(property, "Left")] = toNumberOrString(right);
|
|
169
|
-
} else if (cleanedParts.length === 3) {
|
|
170
|
-
var _top2 = cleanedParts[0];
|
|
171
|
-
var _right = cleanedParts[1];
|
|
172
|
-
var bottom = cleanedParts[2];
|
|
173
|
-
transformed["".concat(property, "Top")] = toNumberOrString(_top2);
|
|
174
|
-
transformed["".concat(property, "Right")] = toNumberOrString(_right);
|
|
175
|
-
transformed["".concat(property, "Bottom")] = toNumberOrString(bottom);
|
|
176
|
-
transformed["".concat(property, "Left")] = toNumberOrString(_right);
|
|
177
|
-
} else {
|
|
178
|
-
var _top3 = cleanedParts[0];
|
|
179
|
-
var _right2 = cleanedParts[1];
|
|
180
|
-
var _bottom = cleanedParts[2];
|
|
181
|
-
var left = cleanedParts[3];
|
|
182
|
-
transformed["".concat(property, "Top")] = toNumberOrString(_top3);
|
|
183
|
-
transformed["".concat(property, "Right")] = toNumberOrString(_right2);
|
|
184
|
-
transformed["".concat(property, "Bottom")] = toNumberOrString(_bottom);
|
|
185
|
-
transformed["".concat(property, "Left")] = toNumberOrString(left);
|
|
186
|
-
}
|
|
187
|
-
return transformed;
|
|
188
|
-
};
|
|
189
|
-
this.transformFontWeight = function (property, value) {
|
|
190
|
-
var fontWeightRe = /(normal|bold|100|200|300|400|500|600|700|800|900)/g;
|
|
191
|
-
if (!fontWeightRe.test(String(value))) return;
|
|
192
|
-
return _defineProperty({}, property, String(value));
|
|
193
|
-
};
|
|
194
|
-
this.transformTransform = function (property, value) {
|
|
195
|
-
var transformRe = /(perspective|rotate|rotateX|rotateY|scale|scaleX|scaleY|translate|translateX|translateY|skew|skewX|skewY)\s*\(\s*([^,)]+)[,\s]*([^)]+)?\)/g;
|
|
196
|
-
var transforms = [];
|
|
197
|
-
var match;
|
|
198
|
-
var strValue = String(value);
|
|
199
|
-
do {
|
|
200
|
-
match = transformRe.exec(strValue);
|
|
201
|
-
if (!match) break;
|
|
202
|
-
var _match = match,
|
|
203
|
-
_match2 = _slicedToArray(_match, 4),
|
|
204
|
-
token = _match2[1],
|
|
205
|
-
val1 = _match2[2],
|
|
206
|
-
val2 = _match2[3];
|
|
207
|
-
if (["translate", "skew"].includes(token)) {
|
|
208
|
-
var v1 = String(val1).trim();
|
|
209
|
-
var v2 = String(val2).trim();
|
|
210
|
-
transforms.push(_defineProperty({}, "".concat(token, "X"), v1 !== "" && !isNaN(Number(v1)) ? Number(v1) : val1));
|
|
211
|
-
transforms.push(_defineProperty({}, "".concat(token, "Y"), v2 !== "" && !isNaN(Number(v2)) ? Number(v2) : val2));
|
|
212
|
-
} else {
|
|
213
|
-
var _v = String(val1).trim();
|
|
214
|
-
transforms.push(_defineProperty({}, token, _v !== "" && !isNaN(Number(_v)) ? Number(_v) : val1));
|
|
215
|
-
}
|
|
216
|
-
} while (match);
|
|
217
|
-
return _defineProperty({}, property, transforms);
|
|
218
|
-
};
|
|
219
|
-
this.transformFontScaling = function (property, value, _ref7) {
|
|
220
|
-
var width = _ref7.width,
|
|
221
|
-
roundFn = _ref7.roundFn;
|
|
222
|
-
if (!["fontSize", "lineHeight"].includes(property)) return value;
|
|
223
|
-
|
|
224
|
-
// Base width for design (iPhone 6/7/8)
|
|
225
|
-
var baseWidth = 375;
|
|
226
|
-
|
|
227
|
-
// Calculate scaling factor based on device width
|
|
228
|
-
var scaleFactor = width ? width / baseWidth : 1;
|
|
229
|
-
if (typeof value === "string" && value.trim() !== "" && !isNaN(Number(value))) {
|
|
230
|
-
return roundFn(Number(value) * scaleFactor);
|
|
231
|
-
} else if (typeof value === "number") {
|
|
232
|
-
return roundFn(value * scaleFactor);
|
|
233
|
-
}
|
|
234
|
-
return value;
|
|
235
|
-
};
|
|
236
|
-
this.transformLogicalProperty = function (property, value) {
|
|
237
|
-
var strValue = String(value).trim();
|
|
238
|
-
var parts = [];
|
|
239
|
-
var current = "";
|
|
240
|
-
var depth = 0;
|
|
241
|
-
for (var i = 0; i < strValue.length; i++) {
|
|
242
|
-
var _char2 = strValue[i];
|
|
243
|
-
if (_char2 === "(") {
|
|
244
|
-
depth++;
|
|
245
|
-
current += _char2;
|
|
246
|
-
} else if (_char2 === ")") {
|
|
247
|
-
depth--;
|
|
248
|
-
current += _char2;
|
|
249
|
-
} else if (_char2 === " " && depth === 0) {
|
|
250
|
-
if (current) {
|
|
251
|
-
parts.push(current);
|
|
252
|
-
current = "";
|
|
253
|
-
}
|
|
254
|
-
} else {
|
|
255
|
-
current += _char2;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
if (current) {
|
|
259
|
-
parts.push(current);
|
|
260
|
-
}
|
|
261
|
-
var cleanedParts = parts.filter(Boolean);
|
|
262
|
-
var toNumberOrString = function toNumberOrString(val) {
|
|
263
|
-
if (typeof val === "string" && val.trim() !== "" && !isNaN(Number(val))) {
|
|
264
|
-
return Number(val);
|
|
265
|
-
}
|
|
266
|
-
return val;
|
|
267
|
-
};
|
|
268
|
-
if (property === "paddingInlineStart") return {
|
|
269
|
-
paddingStart: toNumberOrString(value)
|
|
270
|
-
};
|
|
271
|
-
if (property === "paddingInlineEnd") return {
|
|
272
|
-
paddingEnd: toNumberOrString(value)
|
|
273
|
-
};
|
|
274
|
-
if (property === "marginInlineStart") return {
|
|
275
|
-
marginStart: toNumberOrString(value)
|
|
276
|
-
};
|
|
277
|
-
if (property === "marginInlineEnd") return {
|
|
278
|
-
marginEnd: toNumberOrString(value)
|
|
279
|
-
};
|
|
280
|
-
if (property === "insetInlineStart") return {
|
|
281
|
-
start: toNumberOrString(value)
|
|
282
|
-
};
|
|
283
|
-
if (property === "insetInlineEnd") return {
|
|
284
|
-
end: toNumberOrString(value)
|
|
285
|
-
};
|
|
286
|
-
if (property === "insetBlockStart") return {
|
|
287
|
-
top: toNumberOrString(value)
|
|
288
|
-
};
|
|
289
|
-
if (property === "insetBlockEnd") return {
|
|
290
|
-
bottom: toNumberOrString(value)
|
|
291
|
-
};
|
|
292
|
-
if (property === "paddingInline") {
|
|
293
|
-
if (cleanedParts.length === 1) {
|
|
294
|
-
return {
|
|
295
|
-
paddingHorizontal: toNumberOrString(cleanedParts[0])
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
|
-
if (cleanedParts.length >= 2) {
|
|
299
|
-
return {
|
|
300
|
-
paddingStart: toNumberOrString(cleanedParts[0]),
|
|
301
|
-
paddingEnd: toNumberOrString(cleanedParts[1])
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
if (property === "marginInline") {
|
|
306
|
-
if (cleanedParts.length === 1) {
|
|
307
|
-
return {
|
|
308
|
-
marginHorizontal: toNumberOrString(cleanedParts[0])
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
if (cleanedParts.length >= 2) {
|
|
312
|
-
return {
|
|
313
|
-
marginStart: toNumberOrString(cleanedParts[0]),
|
|
314
|
-
marginEnd: toNumberOrString(cleanedParts[1])
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
if (property === "paddingBlock") {
|
|
319
|
-
if (cleanedParts.length === 1) {
|
|
320
|
-
return {
|
|
321
|
-
paddingVertical: toNumberOrString(cleanedParts[0])
|
|
322
|
-
};
|
|
323
|
-
}
|
|
324
|
-
if (cleanedParts.length >= 2) {
|
|
325
|
-
return {
|
|
326
|
-
paddingTop: toNumberOrString(cleanedParts[0]),
|
|
327
|
-
paddingBottom: toNumberOrString(cleanedParts[1])
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
if (property === "marginBlock") {
|
|
332
|
-
if (cleanedParts.length === 1) {
|
|
333
|
-
return {
|
|
334
|
-
marginVertical: toNumberOrString(cleanedParts[0])
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
if (cleanedParts.length >= 2) {
|
|
338
|
-
return {
|
|
339
|
-
marginTop: toNumberOrString(cleanedParts[0]),
|
|
340
|
-
marginBottom: toNumberOrString(cleanedParts[1])
|
|
341
|
-
};
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
if (property === "insetInline") {
|
|
345
|
-
if (cleanedParts.length === 1) {
|
|
346
|
-
return {
|
|
347
|
-
left: toNumberOrString(cleanedParts[0]),
|
|
348
|
-
right: toNumberOrString(cleanedParts[0])
|
|
349
|
-
};
|
|
350
|
-
}
|
|
351
|
-
if (cleanedParts.length >= 2) {
|
|
352
|
-
return {
|
|
353
|
-
start: toNumberOrString(cleanedParts[0]),
|
|
354
|
-
end: toNumberOrString(cleanedParts[1])
|
|
355
|
-
};
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
if (property === "insetBlock") {
|
|
359
|
-
if (cleanedParts.length === 1) {
|
|
360
|
-
return {
|
|
361
|
-
top: toNumberOrString(cleanedParts[0]),
|
|
362
|
-
bottom: toNumberOrString(cleanedParts[0])
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
if (cleanedParts.length >= 2) {
|
|
366
|
-
return {
|
|
367
|
-
top: toNumberOrString(cleanedParts[0]),
|
|
368
|
-
bottom: toNumberOrString(cleanedParts[1])
|
|
369
|
-
};
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
return null;
|
|
373
|
-
};
|
|
374
|
-
this.transform = function (property, value, _ref8) {
|
|
375
|
-
var width = _ref8.width,
|
|
376
|
-
height = _ref8.height;
|
|
377
|
-
if (property.toLowerCase().endsWith("radius")) {
|
|
378
|
-
value = _this.transformBorderRadius(property, value);
|
|
379
|
-
}
|
|
380
|
-
if (property === "opacity") {
|
|
381
|
-
value = _this.transformOpacity(property, value);
|
|
382
|
-
}
|
|
383
|
-
if (["paddingInline", "marginInline", "paddingBlock", "marginBlock", "paddingInlineStart", "paddingInlineEnd", "marginInlineStart", "marginInlineEnd", "insetInline", "insetInlineStart", "insetInlineEnd", "insetBlock", "insetBlockStart", "insetBlockEnd"].includes(property)) {
|
|
384
|
-
return _this.transformLogicalProperty(property, value);
|
|
385
|
-
}
|
|
386
|
-
if (["border", "borderTop", "borderBottom", "borderLeft", "borderRight"].includes(property)) {
|
|
387
|
-
return _this.transformBorder(property, value);
|
|
388
|
-
}
|
|
389
|
-
if (["padding", "margin"].includes(property)) {
|
|
390
|
-
return _this.transformSpacing(property, value);
|
|
391
|
-
}
|
|
392
|
-
if (["flex"].includes(property)) {
|
|
393
|
-
return {
|
|
394
|
-
flex: parseInt(value)
|
|
395
|
-
};
|
|
396
|
-
}
|
|
397
|
-
if (["fontWeight"].includes(property)) {
|
|
398
|
-
return _this.transformFontWeight(property, value);
|
|
399
|
-
}
|
|
400
|
-
if (["scale"].includes(property)) {
|
|
401
|
-
var scaleVal = value;
|
|
402
|
-
if (typeof scaleVal === "string") {
|
|
403
|
-
var first = scaleVal.trim().split(/\s+/)[0];
|
|
404
|
-
if (first.endsWith("%")) {
|
|
405
|
-
scaleVal = parseFloat(first) / 100;
|
|
406
|
-
} else {
|
|
407
|
-
scaleVal = parseFloat(first);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
return {
|
|
411
|
-
transform: [{
|
|
412
|
-
scale: isNaN(scaleVal) ? 1 : Number(scaleVal)
|
|
413
|
-
}]
|
|
414
|
-
};
|
|
415
|
-
}
|
|
416
|
-
if (["transform"].includes(property)) {
|
|
417
|
-
return _this.transformTransform(property, value);
|
|
418
|
-
}
|
|
419
|
-
return _defineProperty({}, property, isNaN(value) ? value : Number(value));
|
|
420
|
-
};
|
|
421
|
-
this.getAliasedPropertyName = function (property) {
|
|
422
|
-
if (property === "background") property = "backgroundColor";
|
|
423
|
-
return property;
|
|
424
|
-
};
|
|
425
|
-
return this;
|
|
426
|
-
}
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports["default"] = CssVars;
|
|
8
|
-
var _cssMedia = _interopRequireDefault(require("./css-media"));
|
|
9
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
10
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
12
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
13
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
14
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
|
-
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
16
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
17
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
18
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
19
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
20
|
-
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
21
|
-
function CssVars() {
|
|
22
|
-
var _this = this;
|
|
23
|
-
this.global = {};
|
|
24
|
-
this.data = {};
|
|
25
|
-
var media = new _cssMedia["default"]();
|
|
26
|
-
this.setGlobal = function (declarations) {
|
|
27
|
-
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
28
|
-
width = _ref.width,
|
|
29
|
-
height = _ref.height;
|
|
30
|
-
for (var property in declarations) {
|
|
31
|
-
var value = declarations[property];
|
|
32
|
-
var _media$match = media.match(property, {
|
|
33
|
-
width: width,
|
|
34
|
-
height: height
|
|
35
|
-
}),
|
|
36
|
-
_media$match2 = _slicedToArray(_media$match, 2),
|
|
37
|
-
isMedia = _media$match2[0],
|
|
38
|
-
matchedMedia = _media$match2[1];
|
|
39
|
-
if (isMedia) {
|
|
40
|
-
if (matchedMedia) {
|
|
41
|
-
_this.setGlobal(value);
|
|
42
|
-
}
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
if (_this.isVar(property)) {
|
|
46
|
-
_this.global[property] = value;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
this.getGlobal = function () {
|
|
51
|
-
return _this.global;
|
|
52
|
-
};
|
|
53
|
-
this.set = function (selector, declarations) {
|
|
54
|
-
var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
55
|
-
width = _ref2.width,
|
|
56
|
-
height = _ref2.height;
|
|
57
|
-
for (var property in declarations) {
|
|
58
|
-
var value = declarations[property];
|
|
59
|
-
var _media$match3 = media.match(property, {
|
|
60
|
-
width: width,
|
|
61
|
-
height: height
|
|
62
|
-
}),
|
|
63
|
-
_media$match4 = _slicedToArray(_media$match3, 2),
|
|
64
|
-
isMedia = _media$match4[0],
|
|
65
|
-
matchedMedia = _media$match4[1];
|
|
66
|
-
if (isMedia) {
|
|
67
|
-
if (matchedMedia) {
|
|
68
|
-
_this.set(selector, value);
|
|
69
|
-
}
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
if (_this.isVar(property)) {
|
|
73
|
-
if (!_this.data[selector]) _this.data[selector] = {};
|
|
74
|
-
_this.data[selector][property] = value;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
this.get = function (selector) {
|
|
79
|
-
return _objectSpread(_objectSpread({}, _this.global), _this.data[selector] || {});
|
|
80
|
-
};
|
|
81
|
-
this.isVar = function (property) {
|
|
82
|
-
return /^--[\w-]+/.test(property);
|
|
83
|
-
};
|
|
84
|
-
this.injectVar = function (selector, value) {
|
|
85
|
-
if (value === undefined || typeof value !== "string") return value;
|
|
86
|
-
var variables = _this.get(selector);
|
|
87
|
-
function resolveOnce(str) {
|
|
88
|
-
var result = "";
|
|
89
|
-
var i = 0;
|
|
90
|
-
var changed = false;
|
|
91
|
-
while (i < str.length) {
|
|
92
|
-
var varIndex = str.indexOf("var(", i);
|
|
93
|
-
if (varIndex === -1) {
|
|
94
|
-
result += str.slice(i);
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
result += str.slice(i, varIndex);
|
|
98
|
-
var depth = 1;
|
|
99
|
-
var j = varIndex + 4;
|
|
100
|
-
var commaIndex = -1;
|
|
101
|
-
while (j < str.length && depth > 0) {
|
|
102
|
-
if (str[j] === "(") {
|
|
103
|
-
depth++;
|
|
104
|
-
} else if (str[j] === ")") {
|
|
105
|
-
depth--;
|
|
106
|
-
} else if (str[j] === "," && depth === 1 && commaIndex === -1) {
|
|
107
|
-
commaIndex = j;
|
|
108
|
-
}
|
|
109
|
-
j++;
|
|
110
|
-
}
|
|
111
|
-
if (depth !== 0) {
|
|
112
|
-
result += str.slice(varIndex);
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
changed = true;
|
|
116
|
-
var varName = void 0,
|
|
117
|
-
fallback = void 0;
|
|
118
|
-
if (commaIndex !== -1) {
|
|
119
|
-
varName = str.slice(varIndex + 4, commaIndex).trim();
|
|
120
|
-
fallback = str.slice(commaIndex + 1, j - 1).trim();
|
|
121
|
-
} else {
|
|
122
|
-
varName = str.slice(varIndex + 4, j - 1).trim();
|
|
123
|
-
fallback = undefined;
|
|
124
|
-
}
|
|
125
|
-
var val = variables[varName];
|
|
126
|
-
if (val !== undefined && val !== "initial" && val !== "") {
|
|
127
|
-
result += val;
|
|
128
|
-
} else if (fallback !== undefined) {
|
|
129
|
-
result += fallback;
|
|
130
|
-
} else {
|
|
131
|
-
result += "";
|
|
132
|
-
}
|
|
133
|
-
i = j;
|
|
134
|
-
}
|
|
135
|
-
return {
|
|
136
|
-
result: result,
|
|
137
|
-
changed: changed
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
var current = value;
|
|
141
|
-
var iterations = 0;
|
|
142
|
-
while (iterations < 10) {
|
|
143
|
-
var _resolveOnce = resolveOnce(current),
|
|
144
|
-
result = _resolveOnce.result,
|
|
145
|
-
changed = _resolveOnce.changed;
|
|
146
|
-
if (!changed || result === current) break;
|
|
147
|
-
current = result;
|
|
148
|
-
iterations++;
|
|
149
|
-
}
|
|
150
|
-
return current;
|
|
151
|
-
};
|
|
152
|
-
return this;
|
|
153
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = Stylesheet;
|
|
7
|
-
var _buildTransform = require("./build-transform");
|
|
8
|
-
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
9
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
11
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
12
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
13
|
-
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
14
|
-
function Stylesheet() {
|
|
15
|
-
var _this = this;
|
|
16
|
-
this.rawStylesheet = {};
|
|
17
|
-
this.stylesheet = {};
|
|
18
|
-
this.setRawStylesheet = function (raw) {
|
|
19
|
-
_this.rawStylesheet = raw;
|
|
20
|
-
};
|
|
21
|
-
this.finalize = function () {
|
|
22
|
-
for (var _i = 0, _Object$entries = Object.entries(_this.rawStylesheet); _i < _Object$entries.length; _i++) {
|
|
23
|
-
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
24
|
-
selector = _Object$entries$_i[0],
|
|
25
|
-
rawDecl = _Object$entries$_i[1];
|
|
26
|
-
var _precomputeDeclaratio = (0, _buildTransform.precomputeDeclaration)(rawDecl),
|
|
27
|
-
_static = _precomputeDeclaratio._static,
|
|
28
|
-
_dynamic = _precomputeDeclaratio._dynamic,
|
|
29
|
-
_hasDynamic = _precomputeDeclaratio._hasDynamic;
|
|
30
|
-
if (_hasDynamic) {
|
|
31
|
-
_this.stylesheet[selector] = {
|
|
32
|
-
_static: _static,
|
|
33
|
-
_dynamic: _dynamic
|
|
34
|
-
};
|
|
35
|
-
} else {
|
|
36
|
-
_this.stylesheet[selector] = _static;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
this.toJSON = function () {
|
|
41
|
-
_this.finalize();
|
|
42
|
-
return JSON.stringify(_this.stylesheet);
|
|
43
|
-
};
|
|
44
|
-
return this;
|
|
45
|
-
}
|