@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,575 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
exports.expandBorder = expandBorder;
|
|
8
|
-
exports.expandFlex = expandFlex;
|
|
9
|
-
exports.expandFontWeight = expandFontWeight;
|
|
10
|
-
exports.expandLogicalProperty = expandLogicalProperty;
|
|
11
|
-
exports.expandSpacing = expandSpacing;
|
|
12
|
-
exports.expandTransform = expandTransform;
|
|
13
|
-
exports.getAliasedProperty = getAliasedProperty;
|
|
14
|
-
exports.hasMediaQuery = hasMediaQuery;
|
|
15
|
-
exports.isDynamicValue = isDynamicValue;
|
|
16
|
-
exports.isPropertySupported = isPropertySupported;
|
|
17
|
-
exports.precomputeDeclaration = precomputeDeclaration;
|
|
18
|
-
exports.precomputeValue = precomputeValue;
|
|
19
|
-
exports.removeImportant = removeImportant;
|
|
20
|
-
exports.removePxUnit = removePxUnit;
|
|
21
|
-
exports.transformBorderRadius = transformBorderRadius;
|
|
22
|
-
exports.transformColor = transformColor;
|
|
23
|
-
exports.transformOpacity = transformOpacity;
|
|
24
|
-
exports.transformPosition = transformPosition;
|
|
25
|
-
exports.transformRemEm = transformRemEm;
|
|
26
|
-
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
27
|
-
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."); }
|
|
28
|
-
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; } }
|
|
29
|
-
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; }
|
|
30
|
-
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; } }
|
|
31
|
-
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
32
|
-
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; }
|
|
33
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
34
|
-
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); }
|
|
35
|
-
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); }
|
|
36
|
-
/**
|
|
37
|
-
* Build-time CSS transformations
|
|
38
|
-
* Pre-computes static values during Metro transform to reduce runtime work.
|
|
39
|
-
*/
|
|
40
|
-
|
|
41
|
-
// ============================================================================
|
|
42
|
-
// Regex patterns (compiled once)
|
|
43
|
-
// ============================================================================
|
|
44
|
-
var remOrEmUnitRe = /([\d.]+)(rem|em)/g;
|
|
45
|
-
var pxUnitRe = /^([\d.]+)px$/;
|
|
46
|
-
var viewportUnitRe = /([\d.]+)(vh|vw|vmin|vmax)/;
|
|
47
|
-
var cssVarRe = /var\(/;
|
|
48
|
-
var calcRe = /calc\(/;
|
|
49
|
-
var colorRe1 = /rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)/g;
|
|
50
|
-
var colorRe2 = /rgba?\(\s*(\d+)\s+(\d+)\s+(\d+)\s*\/\s*([\d.]+)\s*\)/g;
|
|
51
|
-
var borderRe = /^(\S+)\s+(solid|dashed|dotted)\s+(\S+)$/;
|
|
52
|
-
var borderSimpleRe = /^(\S+)\s+(solid|dashed|dotted)$/;
|
|
53
|
-
var spacingRe = /^\s*(\S+)(?:\s+(\S+)(?:\s+(\S+)(?:\s+(\S+))?)?)?\s*$/;
|
|
54
|
-
var fontWeightRe = /^(normal|bold|[1-9]00)$/;
|
|
55
|
-
var transformFnRe = /(perspective|rotate[XYZ]?|scale[XY]?|translate[XY]?|skew[XY]?)\s*\(\s*([^,)]+)(?:,\s*([^)]+))?\)/g;
|
|
56
|
-
var UNSUPPORTED_PROPERTIES = ["outline"];
|
|
57
|
-
|
|
58
|
-
// ============================================================================
|
|
59
|
-
// Helpers
|
|
60
|
-
// ============================================================================
|
|
61
|
-
var itohex = function itohex(component) {
|
|
62
|
-
var hex = Number(component).toString(16);
|
|
63
|
-
return hex.length === 1 ? "0".concat(hex) : hex;
|
|
64
|
-
};
|
|
65
|
-
var toNumber = function toNumber(value) {
|
|
66
|
-
if (typeof value === "number") return value;
|
|
67
|
-
if (typeof value !== "string") return value;
|
|
68
|
-
var trimmed = value.trim();
|
|
69
|
-
if (trimmed === "") return value;
|
|
70
|
-
// If it's a known string-only property like borderStyle or pure word, don't convert to number
|
|
71
|
-
if (/^(solid|dashed|dotted|none|hidden|double|groove|ridge|inset|outset)$/i.test(trimmed)) {
|
|
72
|
-
return trimmed;
|
|
73
|
-
}
|
|
74
|
-
var num = Number(trimmed);
|
|
75
|
-
return !isNaN(num) ? num : value;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
// ============================================================================
|
|
79
|
-
// Check if value needs runtime processing
|
|
80
|
-
// ============================================================================
|
|
81
|
-
function isDynamicValue(value) {
|
|
82
|
-
if (typeof value !== "string") return false;
|
|
83
|
-
return viewportUnitRe.test(value) || cssVarRe.test(value);
|
|
84
|
-
}
|
|
85
|
-
function hasMediaQuery(declaration) {
|
|
86
|
-
if (!declaration || _typeof(declaration) !== "object") return false;
|
|
87
|
-
return Object.keys(declaration).some(function (key) {
|
|
88
|
-
return key.startsWith("@media");
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// ============================================================================
|
|
93
|
-
// Static transformations (can be done at build time)
|
|
94
|
-
// ============================================================================
|
|
95
|
-
|
|
96
|
-
/** Remove !important */
|
|
97
|
-
function removeImportant(value) {
|
|
98
|
-
if (typeof value !== "string") return value;
|
|
99
|
-
return value.replace(/\s*!important\s*/g, "").trim();
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/** Convert rem/em to px (1rem = 16px) */
|
|
103
|
-
function transformRemEm(value) {
|
|
104
|
-
if (typeof value !== "string") return value;
|
|
105
|
-
return value.replace(remOrEmUnitRe, function (_, num) {
|
|
106
|
-
return "".concat(parseFloat(num) * 16, "px");
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/** Remove px unit and convert to number */
|
|
111
|
-
function removePxUnit(value) {
|
|
112
|
-
if (typeof value !== "string") return value;
|
|
113
|
-
var match = pxUnitRe.exec(value);
|
|
114
|
-
if (match) return parseFloat(match[1]);
|
|
115
|
-
return value;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/** Transform rgba/rgb to hex */
|
|
119
|
-
function transformColor(value) {
|
|
120
|
-
if (typeof value !== "string") return value;
|
|
121
|
-
|
|
122
|
-
// Reset lastIndex for global regexes
|
|
123
|
-
colorRe1.lastIndex = 0;
|
|
124
|
-
colorRe2.lastIndex = 0;
|
|
125
|
-
value = value.replace(colorRe1, function (_, r, g, b, a) {
|
|
126
|
-
var alpha = parseFloat(a);
|
|
127
|
-
if (isNaN(alpha) || alpha >= 1) return "#".concat(itohex(r)).concat(itohex(g)).concat(itohex(b));
|
|
128
|
-
return "#".concat(itohex(r)).concat(itohex(g)).concat(itohex(b)).concat(itohex(Math.round(alpha * 255)));
|
|
129
|
-
});
|
|
130
|
-
value = value.replace(colorRe2, function (_, r, g, b, a) {
|
|
131
|
-
var alpha = parseFloat(a);
|
|
132
|
-
if (isNaN(alpha) || alpha >= 1) return "#".concat(itohex(r)).concat(itohex(g)).concat(itohex(b));
|
|
133
|
-
return "#".concat(itohex(r)).concat(itohex(g)).concat(itohex(b)).concat(itohex(Math.round(alpha * 255)));
|
|
134
|
-
});
|
|
135
|
-
return value;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/** Transform position: fixed → absolute */
|
|
139
|
-
function transformPosition(property, value) {
|
|
140
|
-
if (property === "position" && value === "fixed") return "absolute";
|
|
141
|
-
return value;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/** Transform border-radius with % → 9999 */
|
|
145
|
-
function transformBorderRadius(property, value) {
|
|
146
|
-
if (property.toLowerCase().endsWith("radius") && typeof value === "string" && value.includes("%")) {
|
|
147
|
-
return 9999;
|
|
148
|
-
}
|
|
149
|
-
return value;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/** Transform opacity with % → decimal */
|
|
153
|
-
function transformOpacity(property, value) {
|
|
154
|
-
if (property === "opacity" && typeof value === "string" && value.endsWith("%")) {
|
|
155
|
-
var num = parseFloat(value);
|
|
156
|
-
if (!isNaN(num)) {
|
|
157
|
-
return num / 100;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
return value;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/** Get aliased property name */
|
|
164
|
-
function getAliasedProperty(property) {
|
|
165
|
-
if (property === "background") return "backgroundColor";
|
|
166
|
-
return property;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/** Check if property is supported */
|
|
170
|
-
function isPropertySupported(property, value) {
|
|
171
|
-
if (UNSUPPORTED_PROPERTIES.includes(property)) return false;
|
|
172
|
-
if (value === undefined || value === null) return false;
|
|
173
|
-
if (_typeof(value) === "object") return false; // Skip nested objects (media queries)
|
|
174
|
-
return true;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// ============================================================================
|
|
178
|
-
// Shorthand expansion
|
|
179
|
-
// ============================================================================
|
|
180
|
-
|
|
181
|
-
/** Expand border shorthand */
|
|
182
|
-
function expandBorder(property, value) {
|
|
183
|
-
if (!["border", "borderTop", "borderBottom", "borderLeft", "borderRight"].includes(property)) {
|
|
184
|
-
return null;
|
|
185
|
-
}
|
|
186
|
-
if (value === "none" || value === "0") {
|
|
187
|
-
return _defineProperty({}, "".concat(property, "Width"), 0);
|
|
188
|
-
}
|
|
189
|
-
var match = borderRe.exec(String(value));
|
|
190
|
-
if (match) {
|
|
191
|
-
var _match = _slicedToArray(match, 4),
|
|
192
|
-
width = _match[1],
|
|
193
|
-
style = _match[2],
|
|
194
|
-
color = _match[3];
|
|
195
|
-
return _defineProperty(_defineProperty(_defineProperty({}, "".concat(property, "Width"), toNumber(width)), "borderStyle", ["solid", "dotted", "dashed"].includes(style) ? style : "solid"), "".concat(property, "Color"), color);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// Try "width style" format
|
|
199
|
-
var simpleMatch = borderSimpleRe.exec(String(value));
|
|
200
|
-
if (simpleMatch) {
|
|
201
|
-
var _simpleMatch = _slicedToArray(simpleMatch, 3),
|
|
202
|
-
_width = _simpleMatch[1],
|
|
203
|
-
_style = _simpleMatch[2];
|
|
204
|
-
return _defineProperty(_defineProperty({}, "".concat(property, "Width"), toNumber(_width)), "borderStyle", ["solid", "dotted", "dashed"].includes(_style) ? _style : "solid");
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// Single value (width only)
|
|
208
|
-
return _defineProperty({}, "".concat(property, "Width"), toNumber(value));
|
|
209
|
-
}
|
|
210
|
-
function splitSpacingValues(str) {
|
|
211
|
-
var parts = [];
|
|
212
|
-
var current = "";
|
|
213
|
-
var depth = 0;
|
|
214
|
-
for (var i = 0; i < str.length; i++) {
|
|
215
|
-
var _char = str[i];
|
|
216
|
-
if (_char === "(") {
|
|
217
|
-
depth++;
|
|
218
|
-
current += _char;
|
|
219
|
-
} else if (_char === ")") {
|
|
220
|
-
depth--;
|
|
221
|
-
current += _char;
|
|
222
|
-
} else if (_char === " " && depth === 0) {
|
|
223
|
-
if (current) {
|
|
224
|
-
parts.push(current);
|
|
225
|
-
current = "";
|
|
226
|
-
}
|
|
227
|
-
} else {
|
|
228
|
-
current += _char;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
if (current) {
|
|
232
|
-
parts.push(current);
|
|
233
|
-
}
|
|
234
|
-
return parts.filter(Boolean);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
/** Expand margin/padding shorthand */
|
|
238
|
-
function expandSpacing(property, value) {
|
|
239
|
-
if (!["padding", "margin"].includes(property)) return null;
|
|
240
|
-
var parts = splitSpacingValues(String(value));
|
|
241
|
-
if (parts.length === 0) return null;
|
|
242
|
-
var top = parts[0];
|
|
243
|
-
var right = parts[1] !== undefined ? parts[1] : top;
|
|
244
|
-
var bottom = parts[2] !== undefined ? parts[2] : top;
|
|
245
|
-
var left = parts[3] !== undefined ? parts[3] : right;
|
|
246
|
-
return _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(property, "Top"), toNumber(top)), "".concat(property, "Right"), toNumber(right)), "".concat(property, "Bottom"), toNumber(bottom)), "".concat(property, "Left"), toNumber(left));
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/** Expand fontWeight */
|
|
250
|
-
function expandFontWeight(property, value) {
|
|
251
|
-
if (property !== "fontWeight") return null;
|
|
252
|
-
if (!fontWeightRe.test(String(value))) return null;
|
|
253
|
-
return {
|
|
254
|
-
fontWeight: String(value)
|
|
255
|
-
};
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
/** Expand flex */
|
|
259
|
-
function expandFlex(property, value) {
|
|
260
|
-
if (property !== "flex") return null;
|
|
261
|
-
return {
|
|
262
|
-
flex: parseInt(value, 10)
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/** Expand transform property */
|
|
267
|
-
function expandTransform(property, value) {
|
|
268
|
-
if (property !== "transform") return null;
|
|
269
|
-
if (typeof value !== "string") return null;
|
|
270
|
-
|
|
271
|
-
// If contains dynamic values, skip
|
|
272
|
-
if (isDynamicValue(value)) return null;
|
|
273
|
-
var transforms = [];
|
|
274
|
-
var match;
|
|
275
|
-
var re = new RegExp(transformFnRe.source, "g");
|
|
276
|
-
while ((match = re.exec(value)) !== null) {
|
|
277
|
-
var _match2 = match,
|
|
278
|
-
_match3 = _slicedToArray(_match2, 4),
|
|
279
|
-
fn = _match3[1],
|
|
280
|
-
val1 = _match3[2],
|
|
281
|
-
val2 = _match3[3];
|
|
282
|
-
if (fn === "translate" || fn === "skew") {
|
|
283
|
-
transforms.push(_defineProperty({}, "".concat(fn, "X"), toNumber(val1)));
|
|
284
|
-
if (val2 !== undefined) {
|
|
285
|
-
transforms.push(_defineProperty({}, "".concat(fn, "Y"), toNumber(val2)));
|
|
286
|
-
}
|
|
287
|
-
} else {
|
|
288
|
-
transforms.push(_defineProperty({}, fn, toNumber(val1)));
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
return transforms.length > 0 ? {
|
|
292
|
-
transform: transforms
|
|
293
|
-
} : null;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
/** Expand logical properties like paddingInline, marginInline, paddingBlock, marginBlock */
|
|
297
|
-
function expandLogicalProperty(property, value) {
|
|
298
|
-
if (!["paddingInline", "marginInline", "paddingBlock", "marginBlock", "paddingInlineStart", "paddingInlineEnd", "marginInlineStart", "marginInlineEnd", "insetInline", "insetInlineStart", "insetInlineEnd", "insetBlock", "insetBlockStart", "insetBlockEnd"].includes(property)) {
|
|
299
|
-
return null;
|
|
300
|
-
}
|
|
301
|
-
var strValue = String(value).trim();
|
|
302
|
-
var parts = [];
|
|
303
|
-
var current = "";
|
|
304
|
-
var depth = 0;
|
|
305
|
-
for (var i = 0; i < strValue.length; i++) {
|
|
306
|
-
var _char2 = strValue[i];
|
|
307
|
-
if (_char2 === "(") {
|
|
308
|
-
depth++;
|
|
309
|
-
current += _char2;
|
|
310
|
-
} else if (_char2 === ")") {
|
|
311
|
-
depth--;
|
|
312
|
-
current += _char2;
|
|
313
|
-
} else if (_char2 === " " && depth === 0) {
|
|
314
|
-
if (current) {
|
|
315
|
-
parts.push(current);
|
|
316
|
-
current = "";
|
|
317
|
-
}
|
|
318
|
-
} else {
|
|
319
|
-
current += _char2;
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
if (current) {
|
|
323
|
-
parts.push(current);
|
|
324
|
-
}
|
|
325
|
-
var cleanedParts = parts.filter(Boolean);
|
|
326
|
-
if (property === "paddingInlineStart") return {
|
|
327
|
-
paddingStart: toNumber(value)
|
|
328
|
-
};
|
|
329
|
-
if (property === "paddingInlineEnd") return {
|
|
330
|
-
paddingEnd: toNumber(value)
|
|
331
|
-
};
|
|
332
|
-
if (property === "marginInlineStart") return {
|
|
333
|
-
marginStart: toNumber(value)
|
|
334
|
-
};
|
|
335
|
-
if (property === "marginInlineEnd") return {
|
|
336
|
-
marginEnd: toNumber(value)
|
|
337
|
-
};
|
|
338
|
-
if (property === "insetInlineStart") return {
|
|
339
|
-
start: toNumber(value)
|
|
340
|
-
};
|
|
341
|
-
if (property === "insetInlineEnd") return {
|
|
342
|
-
end: toNumber(value)
|
|
343
|
-
};
|
|
344
|
-
if (property === "insetBlockStart") return {
|
|
345
|
-
top: toNumber(value)
|
|
346
|
-
};
|
|
347
|
-
if (property === "insetBlockEnd") return {
|
|
348
|
-
bottom: toNumber(value)
|
|
349
|
-
};
|
|
350
|
-
if (property === "paddingInline") {
|
|
351
|
-
if (cleanedParts.length === 1) {
|
|
352
|
-
return {
|
|
353
|
-
paddingHorizontal: toNumber(cleanedParts[0])
|
|
354
|
-
};
|
|
355
|
-
}
|
|
356
|
-
if (cleanedParts.length >= 2) {
|
|
357
|
-
return {
|
|
358
|
-
paddingStart: toNumber(cleanedParts[0]),
|
|
359
|
-
paddingEnd: toNumber(cleanedParts[1])
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
if (property === "marginInline") {
|
|
364
|
-
if (cleanedParts.length === 1) {
|
|
365
|
-
return {
|
|
366
|
-
marginHorizontal: toNumber(cleanedParts[0])
|
|
367
|
-
};
|
|
368
|
-
}
|
|
369
|
-
if (cleanedParts.length >= 2) {
|
|
370
|
-
return {
|
|
371
|
-
marginStart: toNumber(cleanedParts[0]),
|
|
372
|
-
marginEnd: toNumber(cleanedParts[1])
|
|
373
|
-
};
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
if (property === "paddingBlock") {
|
|
377
|
-
if (cleanedParts.length === 1) {
|
|
378
|
-
return {
|
|
379
|
-
paddingVertical: toNumber(cleanedParts[0])
|
|
380
|
-
};
|
|
381
|
-
}
|
|
382
|
-
if (cleanedParts.length >= 2) {
|
|
383
|
-
return {
|
|
384
|
-
paddingTop: toNumber(cleanedParts[0]),
|
|
385
|
-
paddingBottom: toNumber(cleanedParts[1])
|
|
386
|
-
};
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
if (property === "marginBlock") {
|
|
390
|
-
if (cleanedParts.length === 1) {
|
|
391
|
-
return {
|
|
392
|
-
marginVertical: toNumber(cleanedParts[0])
|
|
393
|
-
};
|
|
394
|
-
}
|
|
395
|
-
if (cleanedParts.length >= 2) {
|
|
396
|
-
return {
|
|
397
|
-
marginTop: toNumber(cleanedParts[0]),
|
|
398
|
-
marginBottom: toNumber(cleanedParts[1])
|
|
399
|
-
};
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
if (property === "insetInline") {
|
|
403
|
-
if (cleanedParts.length === 1) {
|
|
404
|
-
return {
|
|
405
|
-
left: toNumber(cleanedParts[0]),
|
|
406
|
-
right: toNumber(cleanedParts[0])
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
if (cleanedParts.length >= 2) {
|
|
410
|
-
return {
|
|
411
|
-
start: toNumber(cleanedParts[0]),
|
|
412
|
-
end: toNumber(cleanedParts[1])
|
|
413
|
-
};
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
if (property === "insetBlock") {
|
|
417
|
-
if (cleanedParts.length === 1) {
|
|
418
|
-
return {
|
|
419
|
-
top: toNumber(cleanedParts[0]),
|
|
420
|
-
bottom: toNumber(cleanedParts[0])
|
|
421
|
-
};
|
|
422
|
-
}
|
|
423
|
-
if (cleanedParts.length >= 2) {
|
|
424
|
-
return {
|
|
425
|
-
top: toNumber(cleanedParts[0]),
|
|
426
|
-
bottom: toNumber(cleanedParts[1])
|
|
427
|
-
};
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
return null;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
// ============================================================================
|
|
434
|
-
// Main pre-computation function
|
|
435
|
-
// ============================================================================
|
|
436
|
-
|
|
437
|
-
/**
|
|
438
|
-
* Pre-compute a single property value
|
|
439
|
-
* Returns { property, value, isDynamic }
|
|
440
|
-
*/
|
|
441
|
-
function precomputeValue(property, value) {
|
|
442
|
-
// Handle non-string values
|
|
443
|
-
if (typeof value !== "string") {
|
|
444
|
-
return {
|
|
445
|
-
property: property,
|
|
446
|
-
value: value,
|
|
447
|
-
isDynamic: false
|
|
448
|
-
};
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
// Check if dynamic (needs runtime)
|
|
452
|
-
var isDynamic = isDynamicValue(value) || calcRe.test(value);
|
|
453
|
-
|
|
454
|
-
// Apply static transformations (even for dynamic values, some parts can be pre-processed)
|
|
455
|
-
var processed = value;
|
|
456
|
-
processed = removeImportant(processed);
|
|
457
|
-
processed = transformRemEm(processed);
|
|
458
|
-
processed = transformColor(processed);
|
|
459
|
-
processed = transformPosition(property, processed);
|
|
460
|
-
processed = transformBorderRadius(property, processed);
|
|
461
|
-
processed = transformOpacity(property, processed);
|
|
462
|
-
|
|
463
|
-
// Get aliased property
|
|
464
|
-
var aliasedProp = getAliasedProperty(property);
|
|
465
|
-
|
|
466
|
-
// For static values, remove px and convert to number (unless it's borderStyle, fontWeight, etc.)
|
|
467
|
-
if (!isDynamic) {
|
|
468
|
-
if (aliasedProp.endsWith("Style") || aliasedProp.endsWith("borderStyle") || aliasedProp === "borderStyle") {
|
|
469
|
-
processed = String(processed).trim() || "solid";
|
|
470
|
-
} else {
|
|
471
|
-
processed = removePxUnit(processed);
|
|
472
|
-
if (typeof processed === "string") {
|
|
473
|
-
processed = toNumber(processed);
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
// React Native does not support directional borderStyle properties (e.g. borderBottomStyle)
|
|
479
|
-
if (["borderBottomStyle", "borderTopStyle", "borderLeftStyle", "borderRightStyle"].includes(aliasedProp)) {
|
|
480
|
-
return {
|
|
481
|
-
property: "borderStyle",
|
|
482
|
-
value: processed === "dotted" || processed === "dashed" ? processed : "solid",
|
|
483
|
-
isDynamic: isDynamic
|
|
484
|
-
};
|
|
485
|
-
}
|
|
486
|
-
return {
|
|
487
|
-
property: aliasedProp,
|
|
488
|
-
value: processed,
|
|
489
|
-
isDynamic: isDynamic
|
|
490
|
-
};
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
/**
|
|
494
|
-
* Pre-compute an entire declaration object
|
|
495
|
-
* Returns { _static: {...}, _dynamic: {...}, _hasDynamic: boolean }
|
|
496
|
-
*/
|
|
497
|
-
function precomputeDeclaration(declaration) {
|
|
498
|
-
if (!declaration || _typeof(declaration) !== "object") {
|
|
499
|
-
return {
|
|
500
|
-
_static: {},
|
|
501
|
-
_dynamic: {},
|
|
502
|
-
_hasDynamic: false
|
|
503
|
-
};
|
|
504
|
-
}
|
|
505
|
-
var staticProps = {};
|
|
506
|
-
var dynamicProps = {};
|
|
507
|
-
var hasDynamic = false;
|
|
508
|
-
for (var _i = 0, _Object$entries = Object.entries(declaration); _i < _Object$entries.length; _i++) {
|
|
509
|
-
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
510
|
-
property = _Object$entries$_i[0],
|
|
511
|
-
value = _Object$entries$_i[1];
|
|
512
|
-
// Handle media queries - always dynamic (needs runtime evaluation)
|
|
513
|
-
if (property.startsWith("@media")) {
|
|
514
|
-
// Recursively pre-compute media query content
|
|
515
|
-
var mediaResult = precomputeDeclaration(value);
|
|
516
|
-
dynamicProps[property] = {
|
|
517
|
-
_static: mediaResult._static,
|
|
518
|
-
_dynamic: mediaResult._dynamic
|
|
519
|
-
};
|
|
520
|
-
hasDynamic = true;
|
|
521
|
-
continue;
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
// Keep CSS variables as-is
|
|
525
|
-
if (property.startsWith("--")) {
|
|
526
|
-
staticProps[property] = value;
|
|
527
|
-
continue;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
// Skip unsupported
|
|
531
|
-
if (!isPropertySupported(property, value)) continue;
|
|
532
|
-
|
|
533
|
-
// Pre-compute the value
|
|
534
|
-
var _precomputeValue = precomputeValue(property, value),
|
|
535
|
-
prop = _precomputeValue.property,
|
|
536
|
-
val = _precomputeValue.value,
|
|
537
|
-
isDynamic = _precomputeValue.isDynamic;
|
|
538
|
-
|
|
539
|
-
// Try to expand shorthand
|
|
540
|
-
var expanded = expandBorder(prop, val) || expandSpacing(prop, val) || expandFontWeight(prop, val) || expandFlex(prop, val) || expandTransform(prop, val) || expandLogicalProperty(prop, val);
|
|
541
|
-
if (expanded) {
|
|
542
|
-
// Add expanded properties
|
|
543
|
-
for (var _i2 = 0, _Object$entries2 = Object.entries(expanded); _i2 < _Object$entries2.length; _i2++) {
|
|
544
|
-
var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
|
|
545
|
-
expProp = _Object$entries2$_i[0],
|
|
546
|
-
expVal = _Object$entries2$_i[1];
|
|
547
|
-
if (isDynamic) {
|
|
548
|
-
dynamicProps[expProp] = expVal;
|
|
549
|
-
hasDynamic = true;
|
|
550
|
-
} else {
|
|
551
|
-
staticProps[expProp] = expVal;
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
} else {
|
|
555
|
-
// Single property
|
|
556
|
-
if (isDynamic) {
|
|
557
|
-
dynamicProps[prop] = val;
|
|
558
|
-
hasDynamic = true;
|
|
559
|
-
} else {
|
|
560
|
-
staticProps[prop] = val;
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
return {
|
|
565
|
-
_static: staticProps,
|
|
566
|
-
_dynamic: dynamicProps,
|
|
567
|
-
_hasDynamic: hasDynamic
|
|
568
|
-
};
|
|
569
|
-
}
|
|
570
|
-
var _default = exports["default"] = {
|
|
571
|
-
isDynamicValue: isDynamicValue,
|
|
572
|
-
hasMediaQuery: hasMediaQuery,
|
|
573
|
-
precomputeValue: precomputeValue,
|
|
574
|
-
precomputeDeclaration: precomputeDeclaration
|
|
575
|
-
};
|