@stylexjs/babel-plugin 0.2.0-beta.10 → 0.2.0-beta.11
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 +456 -490
- package/package.json +3 -4
package/lib/index.js
CHANGED
|
@@ -190,7 +190,7 @@ var objectUtils = {};
|
|
|
190
190
|
|
|
191
191
|
var stylexInclude$1 = {};
|
|
192
192
|
|
|
193
|
-
var messages$
|
|
193
|
+
var messages$4 = {};
|
|
194
194
|
|
|
195
195
|
/**
|
|
196
196
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -202,67 +202,67 @@ var messages$2 = {};
|
|
|
202
202
|
|
|
203
203
|
// This file contains constants to be used within Error messages.
|
|
204
204
|
// The URLs within will eventually be replaced by links to the documenation website for Stylex.
|
|
205
|
-
Object.defineProperty(messages$
|
|
205
|
+
Object.defineProperty(messages$4, "__esModule", {
|
|
206
206
|
value: true
|
|
207
207
|
});
|
|
208
|
-
messages$
|
|
208
|
+
messages$4.UNKNOWN_PROP_KEY = messages$4.UNKNOWN_NAMESPACE = messages$4.UNEXPECTED_ARGUMENT = messages$4.UNBOUND_STYLEX_CALL_VALUE = messages$4.ONLY_TOP_LEVEL_INLCUDES = messages$4.ONLY_TOP_LEVEL = messages$4.NO_PARENT_PATH = messages$4.NO_CONDITIONAL_SHORTHAND = messages$4.NON_STATIC_VALUE = messages$4.NON_OBJECT_FOR_STYLEX_CALL = messages$4.LOCAL_ONLY = messages$4.LINT_UNCLOSED_FUNCTION = messages$4.INVALID_SPREAD = messages$4.INVALID_PSEUDO_OR_AT_RULE = messages$4.INVALID_PSEUDO = messages$4.ILLEGAL_PROP_VALUE = messages$4.ILLEGAL_PROP_ARRAY_VALUE = messages$4.ILLEGAL_NESTED_PSEUDO = messages$4.ILLEGAL_NAMESPACE_VALUE = messages$4.ILLEGAL_NAMESPACE_TYPE = messages$4.ILLEGAL_ARGUMENT_LENGTH = messages$4.EXPECTED_FUNCTION_CALL = messages$4.ESCAPED_STYLEX_VALUE = messages$4.DUPLICATE_CONDITIONAL = void 0;
|
|
209
209
|
const ILLEGAL_ARGUMENT_LENGTH = 'stylex() should have 1 argument.';
|
|
210
|
-
messages$
|
|
210
|
+
messages$4.ILLEGAL_ARGUMENT_LENGTH = ILLEGAL_ARGUMENT_LENGTH;
|
|
211
211
|
const NON_STATIC_VALUE = 'Only static values are allowed inside of a stylex.create() call.';
|
|
212
|
-
messages$
|
|
212
|
+
messages$4.NON_STATIC_VALUE = NON_STATIC_VALUE;
|
|
213
213
|
const ESCAPED_STYLEX_VALUE = 'Escaping a stylex.create() value is not allowed.';
|
|
214
|
-
messages$
|
|
214
|
+
messages$4.ESCAPED_STYLEX_VALUE = ESCAPED_STYLEX_VALUE;
|
|
215
215
|
const UNBOUND_STYLEX_CALL_VALUE = 'stylex.create calls must be bound to a bare variable.';
|
|
216
|
-
messages$
|
|
216
|
+
messages$4.UNBOUND_STYLEX_CALL_VALUE = UNBOUND_STYLEX_CALL_VALUE;
|
|
217
217
|
const ONLY_TOP_LEVEL = 'stylex.create() is only allowed at the root of a program.';
|
|
218
|
-
messages$
|
|
218
|
+
messages$4.ONLY_TOP_LEVEL = ONLY_TOP_LEVEL;
|
|
219
219
|
const NON_OBJECT_FOR_STYLEX_CALL = 'stylex.create() can only accept a style object.';
|
|
220
|
-
messages$
|
|
220
|
+
messages$4.NON_OBJECT_FOR_STYLEX_CALL = NON_OBJECT_FOR_STYLEX_CALL;
|
|
221
221
|
const UNKNOWN_PROP_KEY = 'Unknown property key';
|
|
222
|
-
messages$
|
|
222
|
+
messages$4.UNKNOWN_PROP_KEY = UNKNOWN_PROP_KEY;
|
|
223
223
|
const INVALID_PSEUDO = 'Invalid pseudo selector, not on the whitelist.';
|
|
224
|
-
messages$
|
|
224
|
+
messages$4.INVALID_PSEUDO = INVALID_PSEUDO;
|
|
225
225
|
const INVALID_PSEUDO_OR_AT_RULE = 'Invalid pseudo or at-rule.';
|
|
226
|
-
messages$
|
|
226
|
+
messages$4.INVALID_PSEUDO_OR_AT_RULE = INVALID_PSEUDO_OR_AT_RULE;
|
|
227
227
|
const NO_CONDITIONAL_SHORTHAND = 'You cannot use conditional style values for a shorthand property.';
|
|
228
|
-
messages$
|
|
228
|
+
messages$4.NO_CONDITIONAL_SHORTHAND = NO_CONDITIONAL_SHORTHAND;
|
|
229
229
|
const ILLEGAL_NAMESPACE_TYPE = 'Only a string literal namespace is allowed here.';
|
|
230
|
-
messages$
|
|
230
|
+
messages$4.ILLEGAL_NAMESPACE_TYPE = ILLEGAL_NAMESPACE_TYPE;
|
|
231
231
|
const UNKNOWN_NAMESPACE = 'Unknown namespace';
|
|
232
|
-
messages$
|
|
232
|
+
messages$4.UNKNOWN_NAMESPACE = UNKNOWN_NAMESPACE;
|
|
233
233
|
const ILLEGAL_NESTED_PSEUDO = "Pseudo objects can't be nested more than one level deep.";
|
|
234
|
-
messages$
|
|
234
|
+
messages$4.ILLEGAL_NESTED_PSEUDO = ILLEGAL_NESTED_PSEUDO;
|
|
235
235
|
const ILLEGAL_PROP_VALUE = 'A style value can only contain an array, string or number.';
|
|
236
|
-
messages$
|
|
236
|
+
messages$4.ILLEGAL_PROP_VALUE = ILLEGAL_PROP_VALUE;
|
|
237
237
|
const ILLEGAL_PROP_ARRAY_VALUE = 'A style array value can only contain strings or numbers.';
|
|
238
|
-
messages$
|
|
238
|
+
messages$4.ILLEGAL_PROP_ARRAY_VALUE = ILLEGAL_PROP_ARRAY_VALUE;
|
|
239
239
|
const ILLEGAL_NAMESPACE_VALUE = 'A stylex namespace must be an object.';
|
|
240
|
-
messages$
|
|
240
|
+
messages$4.ILLEGAL_NAMESPACE_VALUE = ILLEGAL_NAMESPACE_VALUE;
|
|
241
241
|
const INVALID_SPREAD = 'Imported styles spread with a stylex.create call must be type cast as `XStyle<>` to verify their type.';
|
|
242
|
-
messages$
|
|
242
|
+
messages$4.INVALID_SPREAD = INVALID_SPREAD;
|
|
243
243
|
const LINT_UNCLOSED_FUNCTION = 'Rule contains an unclosed function';
|
|
244
|
-
messages$
|
|
244
|
+
messages$4.LINT_UNCLOSED_FUNCTION = LINT_UNCLOSED_FUNCTION;
|
|
245
245
|
const LOCAL_ONLY = 'The return value of stylex.create() should not be exported.';
|
|
246
|
-
messages$
|
|
246
|
+
messages$4.LOCAL_ONLY = LOCAL_ONLY;
|
|
247
247
|
const UNEXPECTED_ARGUMENT = 'Unexpected argument passed to the stylex() function.';
|
|
248
|
-
messages$
|
|
248
|
+
messages$4.UNEXPECTED_ARGUMENT = UNEXPECTED_ARGUMENT;
|
|
249
249
|
const EXPECTED_FUNCTION_CALL = 'Expected a simple function call but found something else.';
|
|
250
|
-
messages$
|
|
250
|
+
messages$4.EXPECTED_FUNCTION_CALL = EXPECTED_FUNCTION_CALL;
|
|
251
251
|
const NO_PARENT_PATH = 'Unexpected AST node without a parent path.';
|
|
252
|
-
messages$
|
|
252
|
+
messages$4.NO_PARENT_PATH = NO_PARENT_PATH;
|
|
253
253
|
const ONLY_TOP_LEVEL_INLCUDES = 'stylex.include() is only at the top level of a style definition object.';
|
|
254
|
-
messages$
|
|
254
|
+
messages$4.ONLY_TOP_LEVEL_INLCUDES = ONLY_TOP_LEVEL_INLCUDES;
|
|
255
255
|
const DUPLICATE_CONDITIONAL = 'The same pseudo selector or at-rule cannot be used more than once.';
|
|
256
|
-
messages$
|
|
256
|
+
messages$4.DUPLICATE_CONDITIONAL = DUPLICATE_CONDITIONAL;
|
|
257
257
|
|
|
258
258
|
Object.defineProperty(stylexInclude$1, "__esModule", {
|
|
259
259
|
value: true
|
|
260
260
|
});
|
|
261
261
|
stylexInclude$1.IncludedStyles = void 0;
|
|
262
262
|
stylexInclude$1.default = stylexInclude;
|
|
263
|
-
var messages$
|
|
264
|
-
function _getRequireWildcardCache$
|
|
265
|
-
function _interopRequireWildcard$
|
|
263
|
+
var messages$3 = _interopRequireWildcard$3(messages$4);
|
|
264
|
+
function _getRequireWildcardCache$3(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache$3 = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
265
|
+
function _interopRequireWildcard$3(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache$3(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
266
266
|
/**
|
|
267
267
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
268
268
|
*
|
|
@@ -277,18 +277,18 @@ let number = 0;
|
|
|
277
277
|
function uuid() {
|
|
278
278
|
return `__included_${++number}__`;
|
|
279
279
|
}
|
|
280
|
-
class IncludedStyles {
|
|
280
|
+
let IncludedStyles$1 = class IncludedStyles {
|
|
281
281
|
constructor(astNode) {
|
|
282
282
|
this.astNode = astNode;
|
|
283
283
|
}
|
|
284
|
-
}
|
|
285
|
-
stylexInclude$1.IncludedStyles = IncludedStyles;
|
|
284
|
+
};
|
|
285
|
+
stylexInclude$1.IncludedStyles = IncludedStyles$1;
|
|
286
286
|
function stylexInclude(firstArg) {
|
|
287
287
|
if ((arguments.length <= 1 ? 0 : arguments.length - 1) > 0) {
|
|
288
|
-
throw new Error(messages$
|
|
288
|
+
throw new Error(messages$3.ILLEGAL_ARGUMENT_LENGTH);
|
|
289
289
|
}
|
|
290
290
|
return {
|
|
291
|
-
[uuid()]: new IncludedStyles(firstArg.node)
|
|
291
|
+
[uuid()]: new IncludedStyles$1(firstArg.node)
|
|
292
292
|
};
|
|
293
293
|
}
|
|
294
294
|
|
|
@@ -304,7 +304,7 @@ objectUtils.objMap = objMap;
|
|
|
304
304
|
objectUtils.objMapEntry = objMapEntry;
|
|
305
305
|
objectUtils.objMapKeys = objMapKeys;
|
|
306
306
|
objectUtils.objValues = objValues;
|
|
307
|
-
var _stylexInclude = stylexInclude$1;
|
|
307
|
+
var _stylexInclude$4 = stylexInclude$1;
|
|
308
308
|
/**
|
|
309
309
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
310
310
|
*
|
|
@@ -324,7 +324,7 @@ function flattenObject(obj) {
|
|
|
324
324
|
for (const [key, value] of objEntries(obj)) {
|
|
325
325
|
if (typeof value === 'string' || value == null) {
|
|
326
326
|
result[key] = value;
|
|
327
|
-
} else if (value instanceof _stylexInclude.IncludedStyles) {
|
|
327
|
+
} else if (value instanceof _stylexInclude$4.IncludedStyles) {
|
|
328
328
|
result[key] = value;
|
|
329
329
|
} else {
|
|
330
330
|
for (const [subKey, subValue] of objEntries(value)) {
|
|
@@ -453,8 +453,8 @@ Object.defineProperty(splitCssValue, "__esModule", {
|
|
|
453
453
|
value: true
|
|
454
454
|
});
|
|
455
455
|
splitCssValue.default = splitValue;
|
|
456
|
-
var _postcssValueParser$5 = _interopRequireDefault$
|
|
457
|
-
function _interopRequireDefault$
|
|
456
|
+
var _postcssValueParser$5 = _interopRequireDefault$h(require$$0);
|
|
457
|
+
function _interopRequireDefault$h(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
458
458
|
/**
|
|
459
459
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
460
460
|
*
|
|
@@ -499,8 +499,8 @@ Object.defineProperty(applicationOrder, "__esModule", {
|
|
|
499
499
|
value: true
|
|
500
500
|
});
|
|
501
501
|
applicationOrder.default = void 0;
|
|
502
|
-
var _splitCssValue$2 = _interopRequireDefault$
|
|
503
|
-
function _interopRequireDefault$
|
|
502
|
+
var _splitCssValue$2 = _interopRequireDefault$g(splitCssValue);
|
|
503
|
+
function _interopRequireDefault$g(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
504
504
|
/**
|
|
505
505
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
506
506
|
*
|
|
@@ -759,8 +759,8 @@ Object.defineProperty(legacyExpandShorthands, "__esModule", {
|
|
|
759
759
|
value: true
|
|
760
760
|
});
|
|
761
761
|
legacyExpandShorthands.default = void 0;
|
|
762
|
-
var _splitCssValue$1 = _interopRequireDefault$
|
|
763
|
-
function _interopRequireDefault$
|
|
762
|
+
var _splitCssValue$1 = _interopRequireDefault$f(splitCssValue);
|
|
763
|
+
function _interopRequireDefault$f(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
764
764
|
const expansions$2 = {
|
|
765
765
|
// TODO: Due to UI regressions internally, we need to maintain the buggy behaviour of
|
|
766
766
|
// border shorthand for now. This will be fixed in a future release.
|
|
@@ -923,8 +923,8 @@ Object.defineProperty(propertySpecificity, "__esModule", {
|
|
|
923
923
|
value: true
|
|
924
924
|
});
|
|
925
925
|
propertySpecificity.default = void 0;
|
|
926
|
-
var _splitCssValue = _interopRequireDefault$
|
|
927
|
-
function _interopRequireDefault$
|
|
926
|
+
var _splitCssValue = _interopRequireDefault$e(splitCssValue);
|
|
927
|
+
function _interopRequireDefault$e(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
928
928
|
/**
|
|
929
929
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
930
930
|
*
|
|
@@ -1058,10 +1058,10 @@ Object.defineProperty(preprocessRules, "__esModule", {
|
|
|
1058
1058
|
});
|
|
1059
1059
|
preprocessRules.default = flatMapExpandedShorthands;
|
|
1060
1060
|
preprocessRules.getExpandedKeys = getExpandedKeys;
|
|
1061
|
-
var _applicationOrder = _interopRequireDefault$
|
|
1062
|
-
var _legacyExpandShorthands = _interopRequireDefault$
|
|
1063
|
-
var _propertySpecificity = _interopRequireDefault$
|
|
1064
|
-
function _interopRequireDefault$
|
|
1061
|
+
var _applicationOrder = _interopRequireDefault$d(applicationOrder);
|
|
1062
|
+
var _legacyExpandShorthands = _interopRequireDefault$d(legacyExpandShorthands);
|
|
1063
|
+
var _propertySpecificity = _interopRequireDefault$d(propertySpecificity);
|
|
1064
|
+
function _interopRequireDefault$d(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1065
1065
|
/**
|
|
1066
1066
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1067
1067
|
*
|
|
@@ -1227,8 +1227,8 @@ Object.defineProperty(leadingZero, "__esModule", {
|
|
|
1227
1227
|
value: true
|
|
1228
1228
|
});
|
|
1229
1229
|
leadingZero.default = normalizeLeadingZero;
|
|
1230
|
-
var _postcssValueParser$4 = _interopRequireDefault$
|
|
1231
|
-
function _interopRequireDefault$
|
|
1230
|
+
var _postcssValueParser$4 = _interopRequireDefault$c(require$$0);
|
|
1231
|
+
function _interopRequireDefault$c(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1232
1232
|
/**
|
|
1233
1233
|
* Remove leading zeros from numbers
|
|
1234
1234
|
*/
|
|
@@ -1296,8 +1296,8 @@ Object.defineProperty(timings$1, "__esModule", {
|
|
|
1296
1296
|
value: true
|
|
1297
1297
|
});
|
|
1298
1298
|
timings$1.default = normalizeTimings;
|
|
1299
|
-
var _postcssValueParser$3 = _interopRequireDefault$
|
|
1300
|
-
function _interopRequireDefault$
|
|
1299
|
+
var _postcssValueParser$3 = _interopRequireDefault$b(require$$0);
|
|
1300
|
+
function _interopRequireDefault$b(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1301
1301
|
/**
|
|
1302
1302
|
* Turn millisecond values to seconds (shorter), except when < 10ms
|
|
1303
1303
|
*/
|
|
@@ -1391,8 +1391,8 @@ Object.defineProperty(zeroDimensions, "__esModule", {
|
|
|
1391
1391
|
value: true
|
|
1392
1392
|
});
|
|
1393
1393
|
zeroDimensions.default = normalizeZeroDimensions;
|
|
1394
|
-
var _postcssValueParser$2 = _interopRequireDefault$
|
|
1395
|
-
function _interopRequireDefault$
|
|
1394
|
+
var _postcssValueParser$2 = _interopRequireDefault$a(require$$0);
|
|
1395
|
+
function _interopRequireDefault$a(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1396
1396
|
const angles = ['deg', 'grad', 'turn', 'rad'];
|
|
1397
1397
|
const timings = ['ms', 's'];
|
|
1398
1398
|
|
|
@@ -1436,16 +1436,16 @@ Object.defineProperty(detectUnclosedFns$1, "__esModule", {
|
|
|
1436
1436
|
value: true
|
|
1437
1437
|
});
|
|
1438
1438
|
detectUnclosedFns$1.default = detectUnclosedFns;
|
|
1439
|
-
var messages = _interopRequireWildcard(messages$
|
|
1440
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
1441
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
1439
|
+
var messages$2 = _interopRequireWildcard$2(messages$4);
|
|
1440
|
+
function _getRequireWildcardCache$2(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache$2 = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
1441
|
+
function _interopRequireWildcard$2(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache$2(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
1442
1442
|
/**
|
|
1443
1443
|
* Remove leading zeros from numbers
|
|
1444
1444
|
*/
|
|
1445
1445
|
function detectUnclosedFns(ast, _) {
|
|
1446
1446
|
ast.walk(node => {
|
|
1447
1447
|
if (node.type === 'function' && node.unclosed) {
|
|
1448
|
-
throw new Error(messages.LINT_UNCLOSED_FUNCTION);
|
|
1448
|
+
throw new Error(messages$2.LINT_UNCLOSED_FUNCTION);
|
|
1449
1449
|
}
|
|
1450
1450
|
});
|
|
1451
1451
|
return ast;
|
|
@@ -1465,15 +1465,15 @@ Object.defineProperty(normalizeValue$1, "__esModule", {
|
|
|
1465
1465
|
value: true
|
|
1466
1466
|
});
|
|
1467
1467
|
normalizeValue$1.default = normalizeValue;
|
|
1468
|
-
var _fontSizePxToRem = _interopRequireDefault$
|
|
1469
|
-
var _leadingZero = _interopRequireDefault$
|
|
1470
|
-
var _quotes = _interopRequireDefault$
|
|
1471
|
-
var _timings = _interopRequireDefault$
|
|
1472
|
-
var _whitespace = _interopRequireDefault$
|
|
1473
|
-
var _zeroDimensions = _interopRequireDefault$
|
|
1474
|
-
var _detectUnclosedFns = _interopRequireDefault$
|
|
1475
|
-
var _postcssValueParser$1 = _interopRequireDefault$
|
|
1476
|
-
function _interopRequireDefault$
|
|
1468
|
+
var _fontSizePxToRem = _interopRequireDefault$9(fontSizePxToRem);
|
|
1469
|
+
var _leadingZero = _interopRequireDefault$9(leadingZero);
|
|
1470
|
+
var _quotes = _interopRequireDefault$9(quotes);
|
|
1471
|
+
var _timings = _interopRequireDefault$9(timings$1);
|
|
1472
|
+
var _whitespace = _interopRequireDefault$9(whitespace);
|
|
1473
|
+
var _zeroDimensions = _interopRequireDefault$9(zeroDimensions);
|
|
1474
|
+
var _detectUnclosedFns = _interopRequireDefault$9(detectUnclosedFns$1);
|
|
1475
|
+
var _postcssValueParser$1 = _interopRequireDefault$9(require$$0);
|
|
1476
|
+
function _interopRequireDefault$9(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1477
1477
|
// `Timings` should be before `LeadingZero`, because it
|
|
1478
1478
|
// changes 500ms to 0.5s, then `LeadingZero` makes it .5s
|
|
1479
1479
|
const normalizers = [_detectUnclosedFns.default, _whitespace.default, _timings.default, _zeroDimensions.default, _leadingZero.default, _quotes.default, _fontSizePxToRem.default];
|
|
@@ -1489,8 +1489,8 @@ Object.defineProperty(transformValue$1, "__esModule", {
|
|
|
1489
1489
|
value: true
|
|
1490
1490
|
});
|
|
1491
1491
|
transformValue$1.default = transformValue;
|
|
1492
|
-
var _normalizeValue = _interopRequireDefault$
|
|
1493
|
-
function _interopRequireDefault$
|
|
1492
|
+
var _normalizeValue = _interopRequireDefault$8(normalizeValue$1);
|
|
1493
|
+
function _interopRequireDefault$8(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1494
1494
|
/**
|
|
1495
1495
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1496
1496
|
*
|
|
@@ -1686,8 +1686,8 @@ Object.defineProperty(generateRtl, "__esModule", {
|
|
|
1686
1686
|
value: true
|
|
1687
1687
|
});
|
|
1688
1688
|
generateRtl.default = generateRTL;
|
|
1689
|
-
var _postcssValueParser = _interopRequireDefault$
|
|
1690
|
-
function _interopRequireDefault$
|
|
1689
|
+
var _postcssValueParser = _interopRequireDefault$7(require$$0);
|
|
1690
|
+
function _interopRequireDefault$7(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1691
1691
|
/**
|
|
1692
1692
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1693
1693
|
*
|
|
@@ -2044,11 +2044,11 @@ Object.defineProperty(generateCssRule, "__esModule", {
|
|
|
2044
2044
|
value: true
|
|
2045
2045
|
});
|
|
2046
2046
|
generateCssRule.generateRule = generateRule;
|
|
2047
|
-
var _generateLtr$1 = _interopRequireDefault$
|
|
2048
|
-
var _generateRtl$1 = _interopRequireDefault$
|
|
2047
|
+
var _generateLtr$1 = _interopRequireDefault$6(generateLtr);
|
|
2048
|
+
var _generateRtl$1 = _interopRequireDefault$6(generateRtl);
|
|
2049
2049
|
var _genCSSRule = genCSSRule$1;
|
|
2050
|
-
var _propertyPriorities = _interopRequireDefault$
|
|
2051
|
-
function _interopRequireDefault$
|
|
2050
|
+
var _propertyPriorities = _interopRequireDefault$6(propertyPriorities);
|
|
2051
|
+
function _interopRequireDefault$6(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2052
2052
|
/**
|
|
2053
2053
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2054
2054
|
*
|
|
@@ -2079,13 +2079,13 @@ Object.defineProperty(convertToClassName, "__esModule", {
|
|
|
2079
2079
|
value: true
|
|
2080
2080
|
});
|
|
2081
2081
|
convertToClassName.convertStyleToClassName = convertStyleToClassName;
|
|
2082
|
-
var _hash$1 = _interopRequireDefault$
|
|
2083
|
-
var _dashify$1 = _interopRequireDefault$
|
|
2084
|
-
var _transformValue$1 = _interopRequireDefault$
|
|
2082
|
+
var _hash$1 = _interopRequireDefault$5(hash$1);
|
|
2083
|
+
var _dashify$1 = _interopRequireDefault$5(dashify$1);
|
|
2084
|
+
var _transformValue$1 = _interopRequireDefault$5(transformValue$1);
|
|
2085
2085
|
var _generateCssRule = generateCssRule;
|
|
2086
|
-
var _defaultOptions$
|
|
2087
|
-
var _objectUtils$
|
|
2088
|
-
function _interopRequireDefault$
|
|
2086
|
+
var _defaultOptions$2 = defaultOptions$1;
|
|
2087
|
+
var _objectUtils$4 = objectUtils;
|
|
2088
|
+
function _interopRequireDefault$5(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2089
2089
|
/**
|
|
2090
2090
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2091
2091
|
*
|
|
@@ -2106,12 +2106,12 @@ function convertStyleToClassName(objEntry, pseudos, atRules) {
|
|
|
2106
2106
|
let {
|
|
2107
2107
|
stylexSheetName = '<>',
|
|
2108
2108
|
classNamePrefix = 'x'
|
|
2109
|
-
} = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _defaultOptions$
|
|
2109
|
+
} = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _defaultOptions$2.defaultOptions;
|
|
2110
2110
|
const [key, rawValue] = objEntry;
|
|
2111
2111
|
const dashedKey = (0, _dashify$1.default)(key);
|
|
2112
2112
|
const value = Array.isArray(rawValue) ? rawValue.map(eachValue => (0, _transformValue$1.default)(key, eachValue)) : (0, _transformValue$1.default)(key, rawValue);
|
|
2113
|
-
const sortedPseudos = (0, _objectUtils$
|
|
2114
|
-
const sortedAtRules = (0, _objectUtils$
|
|
2113
|
+
const sortedPseudos = (0, _objectUtils$4.arraySort)(pseudos ?? []);
|
|
2114
|
+
const sortedAtRules = (0, _objectUtils$4.arraySort)(atRules ?? []);
|
|
2115
2115
|
const atRuleHashString = sortedPseudos.join('');
|
|
2116
2116
|
const pseudoHashString = sortedAtRules.join('');
|
|
2117
2117
|
const modifierHashString = atRuleHashString + pseudoHashString || 'null';
|
|
@@ -2126,7 +2126,7 @@ Object.defineProperty(PreRule$1, "__esModule", {
|
|
|
2126
2126
|
});
|
|
2127
2127
|
PreRule$1.PreRuleSet = PreRule$1.PreRule = PreRule$1.PreIncludedStylesRule = PreRule$1.NullPreRule = void 0;
|
|
2128
2128
|
var _convertToClassName = convertToClassName;
|
|
2129
|
-
var _objectUtils$
|
|
2129
|
+
var _objectUtils$3 = objectUtils;
|
|
2130
2130
|
/**
|
|
2131
2131
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2132
2132
|
*
|
|
@@ -2175,8 +2175,8 @@ class PreRule {
|
|
|
2175
2175
|
constructor(property, value, pseudos, atRules) {
|
|
2176
2176
|
this.property = property;
|
|
2177
2177
|
this.value = value;
|
|
2178
|
-
this.pseudos = pseudos ? (0, _objectUtils$
|
|
2179
|
-
this.atRules = atRules ? (0, _objectUtils$
|
|
2178
|
+
this.pseudos = pseudos ? (0, _objectUtils$3.arraySort)(pseudos, stringComparator) : [];
|
|
2179
|
+
this.atRules = atRules ? (0, _objectUtils$3.arraySort)(atRules) : [];
|
|
2180
2180
|
}
|
|
2181
2181
|
compiled(options) {
|
|
2182
2182
|
const [_key, className, rule] = (0, _convertToClassName.convertStyleToClassName)([this.property, this.value], this.pseudos ?? [], this.atRules ?? [], options);
|
|
@@ -2186,8 +2186,8 @@ class PreRule {
|
|
|
2186
2186
|
if (!(other instanceof PreRule)) {
|
|
2187
2187
|
return false;
|
|
2188
2188
|
}
|
|
2189
|
-
const valuesEqual = Array.isArray(this.value) && Array.isArray(other.value) ? (0, _objectUtils$
|
|
2190
|
-
return this.property === other.property && valuesEqual && (0, _objectUtils$
|
|
2189
|
+
const valuesEqual = Array.isArray(this.value) && Array.isArray(other.value) ? (0, _objectUtils$3.arrayEquals)(this.value, other.value) : this.value === other.value;
|
|
2190
|
+
return this.property === other.property && valuesEqual && (0, _objectUtils$3.arrayEquals)(this.pseudos, other.pseudos) && (0, _objectUtils$3.arrayEquals)(this.atRules, other.atRules);
|
|
2191
2191
|
}
|
|
2192
2192
|
}
|
|
2193
2193
|
PreRule$1.PreRule = PreRule;
|
|
@@ -2216,341 +2216,317 @@ class PreRuleSet {
|
|
|
2216
2216
|
if (this.rules.length !== other.rules.length) {
|
|
2217
2217
|
return false;
|
|
2218
2218
|
}
|
|
2219
|
-
return (0, _objectUtils$
|
|
2219
|
+
return (0, _objectUtils$3.arrayEquals)(this.rules, other.rules, (a, b) => a.equals(b));
|
|
2220
2220
|
}
|
|
2221
2221
|
}
|
|
2222
2222
|
PreRule$1.PreRuleSet = PreRuleSet;
|
|
2223
2223
|
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
for (const [property, preRule] of pairs) {
|
|
2370
|
-
flattened.push([key + '_' + property, preRule]);
|
|
2371
|
-
}
|
|
2372
|
-
}
|
|
2373
|
-
}
|
|
2374
|
-
return flattened;
|
|
2375
|
-
}
|
|
2376
|
-
return flattenRawStyleObj;
|
|
2224
|
+
Object.defineProperty(flattenRawStyleObj, "__esModule", {
|
|
2225
|
+
value: true
|
|
2226
|
+
});
|
|
2227
|
+
flattenRawStyleObj._flattenRawStyleObject = _flattenRawStyleObject;
|
|
2228
|
+
flattenRawStyleObj.flattenRawStyleObject = flattenRawStyleObject;
|
|
2229
|
+
var _index$1 = _interopRequireDefault$4(preprocessRules);
|
|
2230
|
+
var _PreRule = PreRule$1;
|
|
2231
|
+
var _stylexInclude$3 = stylexInclude$1;
|
|
2232
|
+
function _interopRequireDefault$4(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2233
|
+
/**
|
|
2234
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2235
|
+
*
|
|
2236
|
+
* This source code is licensed under the MIT license found in the
|
|
2237
|
+
* LICENSE file in the root directory of this source tree.
|
|
2238
|
+
*
|
|
2239
|
+
*
|
|
2240
|
+
*/
|
|
2241
|
+
|
|
2242
|
+
function flattenRawStyleObject(style, options) {
|
|
2243
|
+
return _flattenRawStyleObject(style, [], [], options);
|
|
2244
|
+
}
|
|
2245
|
+
function _flattenRawStyleObject(style, pseudos, atRules, options) {
|
|
2246
|
+
const flattened = [];
|
|
2247
|
+
for (const key in style) {
|
|
2248
|
+
const value = style[key];
|
|
2249
|
+
|
|
2250
|
+
// Included Styles
|
|
2251
|
+
if (typeof value === 'object' && value instanceof _stylexInclude$3.IncludedStyles) {
|
|
2252
|
+
flattened.push([key, new _PreRule.PreIncludedStylesRule(value)]);
|
|
2253
|
+
continue;
|
|
2254
|
+
}
|
|
2255
|
+
|
|
2256
|
+
// Default styles
|
|
2257
|
+
if (value === null || typeof value === 'string' || typeof value === 'number') {
|
|
2258
|
+
const pairs = (0, _index$1.default)([key, value], options);
|
|
2259
|
+
for (const [property, value] of pairs) {
|
|
2260
|
+
if (value === null) {
|
|
2261
|
+
flattened.push([property, new _PreRule.NullPreRule()]);
|
|
2262
|
+
} else {
|
|
2263
|
+
flattened.push([property, new _PreRule.PreRule(property, value, pseudos, atRules)]);
|
|
2264
|
+
}
|
|
2265
|
+
}
|
|
2266
|
+
continue;
|
|
2267
|
+
}
|
|
2268
|
+
|
|
2269
|
+
// Fallback Styles
|
|
2270
|
+
if (Array.isArray(value)) {
|
|
2271
|
+
const equivalentPairs = {};
|
|
2272
|
+
for (const eachVal of value) {
|
|
2273
|
+
const pairs = (0, _index$1.default)([key, eachVal], options);
|
|
2274
|
+
for (const [property, val] of pairs) {
|
|
2275
|
+
if (Array.isArray(val)) {
|
|
2276
|
+
if (equivalentPairs[property] == null) {
|
|
2277
|
+
equivalentPairs[property] = [...val];
|
|
2278
|
+
} else {
|
|
2279
|
+
equivalentPairs[property].push(...val);
|
|
2280
|
+
}
|
|
2281
|
+
} else if (equivalentPairs[property] == null) {
|
|
2282
|
+
equivalentPairs[property] = [val];
|
|
2283
|
+
} else {
|
|
2284
|
+
equivalentPairs[property].push(val);
|
|
2285
|
+
}
|
|
2286
|
+
}
|
|
2287
|
+
}
|
|
2288
|
+
// Deduplicate
|
|
2289
|
+
Object.entries(equivalentPairs)
|
|
2290
|
+
// Remove Nulls
|
|
2291
|
+
.map(_ref => {
|
|
2292
|
+
let [property, values] = _ref;
|
|
2293
|
+
return [property, [...new Set(values.filter(Boolean))]];
|
|
2294
|
+
})
|
|
2295
|
+
// Deduplicate and default to null when no values are found
|
|
2296
|
+
.map(_ref2 => {
|
|
2297
|
+
let [property, values] = _ref2;
|
|
2298
|
+
return [property, values.length === 0 ? null : values.length === 1 ? values[0] : values];
|
|
2299
|
+
})
|
|
2300
|
+
// Push to flattened
|
|
2301
|
+
.forEach(_ref3 => {
|
|
2302
|
+
let [property, value] = _ref3;
|
|
2303
|
+
if (value === null) {
|
|
2304
|
+
flattened.push([property, new _PreRule.NullPreRule()]);
|
|
2305
|
+
} else {
|
|
2306
|
+
flattened.push([property, new _PreRule.PreRule(property, value, pseudos, atRules)]);
|
|
2307
|
+
}
|
|
2308
|
+
});
|
|
2309
|
+
continue;
|
|
2310
|
+
}
|
|
2311
|
+
|
|
2312
|
+
// Object Values for propetiies. e.g. { color: { hover: 'red', default: 'blue' } }
|
|
2313
|
+
if (typeof value === 'object' && !key.startsWith(':') && !key.startsWith('@')) {
|
|
2314
|
+
const equivalentPairs = {};
|
|
2315
|
+
for (const condition in value) {
|
|
2316
|
+
const innerValue = value[condition];
|
|
2317
|
+
const pseudosToPassDown = [...pseudos];
|
|
2318
|
+
const atRulesToPassDown = [...atRules];
|
|
2319
|
+
if (condition.startsWith(':')) {
|
|
2320
|
+
pseudosToPassDown.push(condition);
|
|
2321
|
+
} else if (condition.startsWith('@')) {
|
|
2322
|
+
atRulesToPassDown.push(condition);
|
|
2323
|
+
}
|
|
2324
|
+
const pairs = _flattenRawStyleObject({
|
|
2325
|
+
[key]: innerValue
|
|
2326
|
+
}, pseudosToPassDown, atRulesToPassDown, options);
|
|
2327
|
+
for (const [property, preRule] of pairs) {
|
|
2328
|
+
if (preRule instanceof _PreRule.PreIncludedStylesRule) {
|
|
2329
|
+
// NOT POSSIBLE, but needed for Flow
|
|
2330
|
+
throw new Error('stylex.include can only be used at the top-level');
|
|
2331
|
+
}
|
|
2332
|
+
if (equivalentPairs[property] == null) {
|
|
2333
|
+
equivalentPairs[property] = {
|
|
2334
|
+
[condition]: preRule
|
|
2335
|
+
};
|
|
2336
|
+
} else {
|
|
2337
|
+
equivalentPairs[property][condition] = preRule;
|
|
2338
|
+
}
|
|
2339
|
+
}
|
|
2340
|
+
}
|
|
2341
|
+
for (const [property, obj] of Object.entries(equivalentPairs)) {
|
|
2342
|
+
const sortedKeys = Object.keys(obj); //.sort();
|
|
2343
|
+
const rules = [];
|
|
2344
|
+
for (const condition of sortedKeys) {
|
|
2345
|
+
rules.push(obj[condition]);
|
|
2346
|
+
}
|
|
2347
|
+
// If there are many conditions with `null` values, we will collapse them into a single `null` value.
|
|
2348
|
+
// `PreRuleSet.create` takes care of that for us.
|
|
2349
|
+
flattened.push([property, _PreRule.PreRuleSet.create(rules)]);
|
|
2350
|
+
}
|
|
2351
|
+
}
|
|
2352
|
+
|
|
2353
|
+
// Object Values for pseudos and at-rules. e.g. { ':hover': { color: 'red' } }
|
|
2354
|
+
if (typeof value === 'object' && (key.startsWith(':') || key.startsWith('@'))) {
|
|
2355
|
+
const pseudosToPassDown = [...pseudos];
|
|
2356
|
+
const atRulesToPassDown = [...atRules];
|
|
2357
|
+
if (key.startsWith(':')) {
|
|
2358
|
+
pseudosToPassDown.push(key);
|
|
2359
|
+
} else if (key.startsWith('@')) {
|
|
2360
|
+
atRulesToPassDown.push(key);
|
|
2361
|
+
}
|
|
2362
|
+
const pairs = _flattenRawStyleObject(value, pseudosToPassDown, atRulesToPassDown, options);
|
|
2363
|
+
for (const [property, preRule] of pairs) {
|
|
2364
|
+
flattened.push([key + '_' + property, preRule]);
|
|
2365
|
+
}
|
|
2366
|
+
}
|
|
2367
|
+
}
|
|
2368
|
+
return flattened;
|
|
2377
2369
|
}
|
|
2378
2370
|
|
|
2379
2371
|
var basicValidation = {};
|
|
2380
2372
|
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
validateConditionalStyles(val);
|
|
2439
|
-
}
|
|
2440
|
-
continue;
|
|
2441
|
-
}
|
|
2442
|
-
throw new Error(messages.ILLEGAL_PROP_VALUE);
|
|
2443
|
-
}
|
|
2444
|
-
}
|
|
2445
|
-
function validateConditionalStyles(val) {
|
|
2446
|
-
let conditions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
2447
|
-
for (const key in val) {
|
|
2448
|
-
const v = val[key];
|
|
2449
|
-
if (!(key.startsWith('@') || key.startsWith(':') || key === 'default')) {
|
|
2450
|
-
throw new Error(messages.INVALID_PSEUDO_OR_AT_RULE);
|
|
2451
|
-
}
|
|
2452
|
-
if (conditions.includes(key)) {
|
|
2453
|
-
throw new Error(messages.DUPLICATE_CONDITIONAL);
|
|
2454
|
-
}
|
|
2455
|
-
if (v === null || typeof v === 'string' || typeof v === 'number') {
|
|
2456
|
-
continue;
|
|
2457
|
-
}
|
|
2458
|
-
if (Array.isArray(v)) {
|
|
2459
|
-
for (const vv of v) {
|
|
2460
|
-
if (vv === null || typeof vv === 'string' || typeof vv === 'number') {
|
|
2461
|
-
continue;
|
|
2462
|
-
}
|
|
2463
|
-
throw new Error(messages.ILLEGAL_PROP_VALUE);
|
|
2464
|
-
}
|
|
2465
|
-
continue;
|
|
2466
|
-
}
|
|
2467
|
-
if (v instanceof _.IncludedStyles) {
|
|
2468
|
-
throw new Error(messages.ONLY_TOP_LEVEL_INLCUDES);
|
|
2469
|
-
}
|
|
2470
|
-
if ((0, _objectUtils.isPlainObject)(v)) {
|
|
2471
|
-
validateConditionalStyles(v, [...conditions, key]);
|
|
2472
|
-
continue;
|
|
2473
|
-
}
|
|
2474
|
-
throw new Error(messages.ILLEGAL_PROP_VALUE);
|
|
2475
|
-
}
|
|
2476
|
-
}
|
|
2477
|
-
return basicValidation;
|
|
2373
|
+
Object.defineProperty(basicValidation, "__esModule", {
|
|
2374
|
+
value: true
|
|
2375
|
+
});
|
|
2376
|
+
basicValidation.validateNamespace = validateNamespace;
|
|
2377
|
+
var _stylexInclude$2 = stylexInclude$1;
|
|
2378
|
+
var messages$1 = _interopRequireWildcard$1(messages$4);
|
|
2379
|
+
var _objectUtils$2 = objectUtils;
|
|
2380
|
+
function _getRequireWildcardCache$1(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache$1 = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
2381
|
+
function _interopRequireWildcard$1(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache$1(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
2382
|
+
/**
|
|
2383
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2384
|
+
*
|
|
2385
|
+
* This source code is licensed under the MIT license found in the
|
|
2386
|
+
* LICENSE file in the root directory of this source tree.
|
|
2387
|
+
*
|
|
2388
|
+
*
|
|
2389
|
+
*/
|
|
2390
|
+
|
|
2391
|
+
function validateNamespace(namespace) {
|
|
2392
|
+
let conditions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
2393
|
+
if (!(0, _objectUtils$2.isPlainObject)(namespace)) {
|
|
2394
|
+
throw new Error(messages$1.ILLEGAL_NAMESPACE_VALUE);
|
|
2395
|
+
}
|
|
2396
|
+
const ns = namespace;
|
|
2397
|
+
for (const key in ns) {
|
|
2398
|
+
const val = ns[key];
|
|
2399
|
+
if (val === null || typeof val === 'string' || typeof val === 'number') {
|
|
2400
|
+
continue;
|
|
2401
|
+
}
|
|
2402
|
+
if (Array.isArray(val)) {
|
|
2403
|
+
for (const v of val) {
|
|
2404
|
+
if (v === null || typeof v === 'string' || typeof v === 'number') {
|
|
2405
|
+
continue;
|
|
2406
|
+
}
|
|
2407
|
+
throw new Error(messages$1.ILLEGAL_PROP_ARRAY_VALUE);
|
|
2408
|
+
}
|
|
2409
|
+
continue;
|
|
2410
|
+
}
|
|
2411
|
+
if (val instanceof _stylexInclude$2.IncludedStyles) {
|
|
2412
|
+
if (conditions.length === 0) {
|
|
2413
|
+
continue;
|
|
2414
|
+
}
|
|
2415
|
+
throw new Error(messages$1.ONLY_TOP_LEVEL_INLCUDES);
|
|
2416
|
+
}
|
|
2417
|
+
if ((0, _objectUtils$2.isPlainObject)(val)) {
|
|
2418
|
+
if (key.startsWith('@') || key.startsWith(':')) {
|
|
2419
|
+
if (conditions.includes(key)) {
|
|
2420
|
+
throw new Error(messages$1.DUPLICATE_CONDITIONAL);
|
|
2421
|
+
}
|
|
2422
|
+
validateNamespace(val, [...conditions, key]);
|
|
2423
|
+
} else {
|
|
2424
|
+
validateConditionalStyles(val);
|
|
2425
|
+
}
|
|
2426
|
+
continue;
|
|
2427
|
+
}
|
|
2428
|
+
throw new Error(messages$1.ILLEGAL_PROP_VALUE);
|
|
2429
|
+
}
|
|
2478
2430
|
}
|
|
2431
|
+
function validateConditionalStyles(val) {
|
|
2432
|
+
let conditions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
2433
|
+
for (const key in val) {
|
|
2434
|
+
const v = val[key];
|
|
2435
|
+
if (!(key.startsWith('@') || key.startsWith(':') || key === 'default')) {
|
|
2436
|
+
throw new Error(messages$1.INVALID_PSEUDO_OR_AT_RULE);
|
|
2437
|
+
}
|
|
2438
|
+
if (conditions.includes(key)) {
|
|
2439
|
+
throw new Error(messages$1.DUPLICATE_CONDITIONAL);
|
|
2440
|
+
}
|
|
2441
|
+
if (v === null || typeof v === 'string' || typeof v === 'number') {
|
|
2442
|
+
continue;
|
|
2443
|
+
}
|
|
2444
|
+
if (Array.isArray(v)) {
|
|
2445
|
+
for (const vv of v) {
|
|
2446
|
+
if (vv === null || typeof vv === 'string' || typeof vv === 'number') {
|
|
2447
|
+
continue;
|
|
2448
|
+
}
|
|
2449
|
+
throw new Error(messages$1.ILLEGAL_PROP_VALUE);
|
|
2450
|
+
}
|
|
2451
|
+
continue;
|
|
2452
|
+
}
|
|
2453
|
+
if (v instanceof _stylexInclude$2.IncludedStyles) {
|
|
2454
|
+
throw new Error(messages$1.ONLY_TOP_LEVEL_INLCUDES);
|
|
2455
|
+
}
|
|
2456
|
+
if ((0, _objectUtils$2.isPlainObject)(v)) {
|
|
2457
|
+
validateConditionalStyles(v, [...conditions, key]);
|
|
2458
|
+
continue;
|
|
2459
|
+
}
|
|
2460
|
+
throw new Error(messages$1.ILLEGAL_PROP_VALUE);
|
|
2461
|
+
}
|
|
2462
|
+
}
|
|
2463
|
+
|
|
2464
|
+
Object.defineProperty(stylexCreate$1, "__esModule", {
|
|
2465
|
+
value: true
|
|
2466
|
+
});
|
|
2467
|
+
stylexCreate$1.default = styleXCreateSet;
|
|
2468
|
+
var _objectUtils$1 = objectUtils;
|
|
2469
|
+
var _stylexInclude$1 = stylexInclude$1;
|
|
2470
|
+
var _defaultOptions$1 = defaultOptions$1;
|
|
2471
|
+
var _flattenRawStyleObj = flattenRawStyleObj;
|
|
2472
|
+
var _basicValidation = basicValidation;
|
|
2473
|
+
/**
|
|
2474
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2475
|
+
*
|
|
2476
|
+
* This source code is licensed under the MIT license found in the
|
|
2477
|
+
* LICENSE file in the root directory of this source tree.
|
|
2478
|
+
*
|
|
2479
|
+
*
|
|
2480
|
+
*/
|
|
2479
2481
|
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
for (const key of Object.keys(compiledNamespace)) {
|
|
2529
|
-
const value = compiledNamespace[key];
|
|
2530
|
-
if (value instanceof _stylexInclude.IncludedStyles) {
|
|
2531
|
-
namespaceObj[key] = value;
|
|
2532
|
-
} else {
|
|
2533
|
-
const classNameTuples = value.map(v => Array.isArray(v) ? v : null).filter(Boolean);
|
|
2534
|
-
const className = classNameTuples.map(_ref2 => {
|
|
2535
|
-
let [className] = _ref2;
|
|
2536
|
-
return className;
|
|
2537
|
-
}).join(' ') || null;
|
|
2538
|
-
namespaceObj[key] = className;
|
|
2539
|
-
for (const [className, injectable] of classNameTuples) {
|
|
2540
|
-
if (injectedStyles[className] == null) {
|
|
2541
|
-
injectedStyles[className] = injectable;
|
|
2542
|
-
}
|
|
2543
|
-
}
|
|
2544
|
-
}
|
|
2545
|
-
}
|
|
2546
|
-
resolvedNamespaces[namespaceName] = {
|
|
2547
|
-
...namespaceObj,
|
|
2548
|
-
$$css: true
|
|
2549
|
-
};
|
|
2550
|
-
}
|
|
2551
|
-
return [resolvedNamespaces, injectedStyles];
|
|
2552
|
-
}
|
|
2553
|
-
return stylexCreate$1;
|
|
2482
|
+
// This takes the object of styles passed to `stylex.create` and transforms it.
|
|
2483
|
+
// The transformation replaces style values with classNames.
|
|
2484
|
+
//
|
|
2485
|
+
// It also collects all injected styles along the way.
|
|
2486
|
+
// It then returns a tuple of the transformed style Object and an object of injected styles.
|
|
2487
|
+
//
|
|
2488
|
+
// This function does some basic validation, and then uses `styleXCreateNamespace` to transform
|
|
2489
|
+
// each namespace within,
|
|
2490
|
+
//
|
|
2491
|
+
// Before returning, it ensures that there are no duplicate styles being injected.
|
|
2492
|
+
function styleXCreateSet(namespaces) {
|
|
2493
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _defaultOptions$1.defaultOptions;
|
|
2494
|
+
const resolvedNamespaces = {};
|
|
2495
|
+
const injectedStyles = {};
|
|
2496
|
+
for (const namespaceName of Object.keys(namespaces)) {
|
|
2497
|
+
const namespace = namespaces[namespaceName];
|
|
2498
|
+
(0, _basicValidation.validateNamespace)(namespace);
|
|
2499
|
+
const flattenedNamespace = (0, _flattenRawStyleObj.flattenRawStyleObject)(namespace, options);
|
|
2500
|
+
const compiledNamespaceTuples = flattenedNamespace.map(_ref => {
|
|
2501
|
+
let [key, value] = _ref;
|
|
2502
|
+
return [key, value.compiled(options)];
|
|
2503
|
+
});
|
|
2504
|
+
const compiledNamespace = (0, _objectUtils$1.objFromEntries)(compiledNamespaceTuples);
|
|
2505
|
+
const namespaceObj = {};
|
|
2506
|
+
for (const key of Object.keys(compiledNamespace)) {
|
|
2507
|
+
const value = compiledNamespace[key];
|
|
2508
|
+
if (value instanceof _stylexInclude$1.IncludedStyles) {
|
|
2509
|
+
namespaceObj[key] = value;
|
|
2510
|
+
} else {
|
|
2511
|
+
const classNameTuples = value.map(v => Array.isArray(v) ? v : null).filter(Boolean);
|
|
2512
|
+
const className = classNameTuples.map(_ref2 => {
|
|
2513
|
+
let [className] = _ref2;
|
|
2514
|
+
return className;
|
|
2515
|
+
}).join(' ') || null;
|
|
2516
|
+
namespaceObj[key] = className;
|
|
2517
|
+
for (const [className, injectable] of classNameTuples) {
|
|
2518
|
+
if (injectedStyles[className] == null) {
|
|
2519
|
+
injectedStyles[className] = injectable;
|
|
2520
|
+
}
|
|
2521
|
+
}
|
|
2522
|
+
}
|
|
2523
|
+
}
|
|
2524
|
+
resolvedNamespaces[namespaceName] = {
|
|
2525
|
+
...namespaceObj,
|
|
2526
|
+
$$css: true
|
|
2527
|
+
};
|
|
2528
|
+
}
|
|
2529
|
+
return [resolvedNamespaces, injectedStyles];
|
|
2554
2530
|
}
|
|
2555
2531
|
|
|
2556
2532
|
var stylexKeyframes = {};
|
|
@@ -2559,15 +2535,15 @@ Object.defineProperty(stylexKeyframes, "__esModule", {
|
|
|
2559
2535
|
value: true
|
|
2560
2536
|
});
|
|
2561
2537
|
stylexKeyframes.default = styleXKeyframes;
|
|
2562
|
-
var _hash = _interopRequireDefault$
|
|
2563
|
-
var _index = _interopRequireDefault$
|
|
2564
|
-
var _generateLtr = _interopRequireDefault$
|
|
2565
|
-
var _generateRtl = _interopRequireDefault$
|
|
2566
|
-
var _transformValue = _interopRequireDefault$
|
|
2567
|
-
var _dashify = _interopRequireDefault$
|
|
2538
|
+
var _hash = _interopRequireDefault$3(hash$1);
|
|
2539
|
+
var _index = _interopRequireDefault$3(preprocessRules);
|
|
2540
|
+
var _generateLtr = _interopRequireDefault$3(generateLtr);
|
|
2541
|
+
var _generateRtl = _interopRequireDefault$3(generateRtl);
|
|
2542
|
+
var _transformValue = _interopRequireDefault$3(transformValue$1);
|
|
2543
|
+
var _dashify = _interopRequireDefault$3(dashify$1);
|
|
2568
2544
|
var _objectUtils = objectUtils;
|
|
2569
2545
|
var _defaultOptions = defaultOptions$1;
|
|
2570
|
-
function _interopRequireDefault$
|
|
2546
|
+
function _interopRequireDefault$3(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2571
2547
|
/**
|
|
2572
2548
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2573
2549
|
*
|
|
@@ -2653,54 +2629,44 @@ function stylexFirstThatWorks() {
|
|
|
2653
2629
|
return [...args].reverse();
|
|
2654
2630
|
}
|
|
2655
2631
|
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
*/
|
|
2682
|
-
|
|
2683
|
-
// All functions exposed from `stylex` are defined in a way that can be run
|
|
2684
|
-
// entirely in the browser.
|
|
2685
|
-
|
|
2686
|
-
// These are the implementations of those functions.
|
|
2687
|
-
|
|
2688
|
-
const create = _stylexCreate.default;
|
|
2689
|
-
lib.create = create;
|
|
2690
|
-
const keyframes = _stylexKeyframes.default;
|
|
2691
|
-
lib.keyframes = keyframes;
|
|
2692
|
-
const include = _stylexInclude.default;
|
|
2693
|
-
lib.include = include;
|
|
2694
|
-
const messages = m;
|
|
2695
|
-
lib.messages = messages;
|
|
2696
|
-
const IncludedStyles = _stylexInclude.IncludedStyles;
|
|
2697
|
-
lib.IncludedStyles = IncludedStyles;
|
|
2698
|
-
const firstThatWorks = _stylexFirstThatWorks.default;
|
|
2699
|
-
lib.firstThatWorks = firstThatWorks;
|
|
2700
|
-
return lib;
|
|
2701
|
-
}
|
|
2632
|
+
Object.defineProperty(lib, "__esModule", {
|
|
2633
|
+
value: true
|
|
2634
|
+
});
|
|
2635
|
+
var messages_1 = lib.messages = keyframes_1 = lib.keyframes = include_1 = lib.include = firstThatWorks_1 = lib.firstThatWorks = create_1 = lib.create = IncludedStyles_1 = lib.IncludedStyles = void 0;
|
|
2636
|
+
var _stylexCreate = _interopRequireDefault$2(stylexCreate$1);
|
|
2637
|
+
var _stylexKeyframes = _interopRequireDefault$2(stylexKeyframes);
|
|
2638
|
+
var _stylexInclude = _interopRequireWildcard(stylexInclude$1);
|
|
2639
|
+
var _stylexFirstThatWorks = _interopRequireDefault$2(stylexFirstThatWorks$1);
|
|
2640
|
+
var m = _interopRequireWildcard(messages$4);
|
|
2641
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
2642
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
2643
|
+
function _interopRequireDefault$2(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2644
|
+
/**
|
|
2645
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2646
|
+
*
|
|
2647
|
+
* This source code is licensed under the MIT license found in the
|
|
2648
|
+
* LICENSE file in the root directory of this source tree.
|
|
2649
|
+
*
|
|
2650
|
+
*
|
|
2651
|
+
*/
|
|
2652
|
+
|
|
2653
|
+
// All functions exposed from `stylex` are defined in a way that can be run
|
|
2654
|
+
// entirely in the browser.
|
|
2655
|
+
|
|
2656
|
+
// These are the implementations of those functions.
|
|
2702
2657
|
|
|
2703
|
-
|
|
2658
|
+
const create$1 = _stylexCreate.default;
|
|
2659
|
+
var create_1 = lib.create = create$1;
|
|
2660
|
+
const keyframes$1 = _stylexKeyframes.default;
|
|
2661
|
+
var keyframes_1 = lib.keyframes = keyframes$1;
|
|
2662
|
+
const include$1 = _stylexInclude.default;
|
|
2663
|
+
var include_1 = lib.include = include$1;
|
|
2664
|
+
const messages = m;
|
|
2665
|
+
messages_1 = lib.messages = messages;
|
|
2666
|
+
const IncludedStyles = _stylexInclude.IncludedStyles;
|
|
2667
|
+
var IncludedStyles_1 = lib.IncludedStyles = IncludedStyles;
|
|
2668
|
+
const firstThatWorks$1 = _stylexFirstThatWorks.default;
|
|
2669
|
+
var firstThatWorks_1 = lib.firstThatWorks = firstThatWorks$1;
|
|
2704
2670
|
|
|
2705
2671
|
/**
|
|
2706
2672
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -2750,7 +2716,7 @@ function convertToTestStyles(obj, varName, state) {
|
|
|
2750
2716
|
function convertObjectToAST(obj) {
|
|
2751
2717
|
return t__namespace.objectExpression(Object.entries(obj).map(_ref => {
|
|
2752
2718
|
let [key, value] = _ref;
|
|
2753
|
-
return value instanceof
|
|
2719
|
+
return value instanceof IncludedStyles_1 ? t__namespace.spreadElement(value.astNode) : t__namespace.objectProperty(canBeIdentifier(key) ? t__namespace.identifier(key) : t__namespace.stringLiteral(key), typeof value === 'string' ? t__namespace.stringLiteral(value) : typeof value === 'boolean' ? t__namespace.booleanLiteral(value) : value === null ? t__namespace.nullLiteral() : convertObjectToAST(value));
|
|
2754
2720
|
}));
|
|
2755
2721
|
}
|
|
2756
2722
|
function canBeIdentifier(str) {
|
|
@@ -3218,12 +3184,12 @@ function transformStyleXCreate(path, state) {
|
|
|
3218
3184
|
const args = path.get('arguments');
|
|
3219
3185
|
const firstArg = args[0];
|
|
3220
3186
|
if (firstArg == null || !firstArg.isObjectExpression()) {
|
|
3221
|
-
throw new Error(
|
|
3187
|
+
throw new Error(messages_1.ILLEGAL_ARGUMENT_LENGTH);
|
|
3222
3188
|
}
|
|
3223
3189
|
preProcessStyleArg(firstArg, state);
|
|
3224
3190
|
const injectedKeyframes = {};
|
|
3225
3191
|
function keyframes(animation) {
|
|
3226
|
-
const [animationName, injectedStyle] =
|
|
3192
|
+
const [animationName, injectedStyle] = keyframes_1(animation, state.options);
|
|
3227
3193
|
injectedKeyframes[animationName] = injectedStyle;
|
|
3228
3194
|
return animationName;
|
|
3229
3195
|
}
|
|
@@ -3231,13 +3197,13 @@ function transformStyleXCreate(path, state) {
|
|
|
3231
3197
|
const memberExpressions = {};
|
|
3232
3198
|
state.stylexIncludeImport.forEach(name => {
|
|
3233
3199
|
identifiers[name] = {
|
|
3234
|
-
fn:
|
|
3200
|
+
fn: include_1,
|
|
3235
3201
|
takesPath: true
|
|
3236
3202
|
};
|
|
3237
3203
|
});
|
|
3238
3204
|
state.stylexFirstThatWorksImport.forEach(name => {
|
|
3239
3205
|
identifiers[name] = {
|
|
3240
|
-
fn:
|
|
3206
|
+
fn: firstThatWorks_1
|
|
3241
3207
|
};
|
|
3242
3208
|
});
|
|
3243
3209
|
state.stylexKeyframesImport.forEach(name => {
|
|
@@ -3250,11 +3216,11 @@ function transformStyleXCreate(path, state) {
|
|
|
3250
3216
|
memberExpressions[name] = {};
|
|
3251
3217
|
}
|
|
3252
3218
|
memberExpressions[name].include = {
|
|
3253
|
-
fn:
|
|
3219
|
+
fn: include_1,
|
|
3254
3220
|
takesPath: true
|
|
3255
3221
|
};
|
|
3256
3222
|
memberExpressions[name].firstThatWorks = {
|
|
3257
|
-
fn:
|
|
3223
|
+
fn: firstThatWorks_1
|
|
3258
3224
|
};
|
|
3259
3225
|
memberExpressions[name].keyframes = {
|
|
3260
3226
|
fn: keyframes
|
|
@@ -3268,10 +3234,10 @@ function transformStyleXCreate(path, state) {
|
|
|
3268
3234
|
memberExpressions
|
|
3269
3235
|
});
|
|
3270
3236
|
if (!confident) {
|
|
3271
|
-
throw new Error(
|
|
3237
|
+
throw new Error(messages_1.NON_STATIC_VALUE);
|
|
3272
3238
|
}
|
|
3273
3239
|
const plainObject = value;
|
|
3274
|
-
let [compiledStyles, injectedStylesSansKeyframes] =
|
|
3240
|
+
let [compiledStyles, injectedStylesSansKeyframes] = create_1(plainObject, state.options);
|
|
3275
3241
|
const injectedStyles = {
|
|
3276
3242
|
...injectedKeyframes,
|
|
3277
3243
|
...injectedStylesSansKeyframes
|
|
@@ -3319,17 +3285,17 @@ function transformStyleXCreate(path, state) {
|
|
|
3319
3285
|
// Validates the first argument to `stylex.create`.
|
|
3320
3286
|
function validateStyleXCreate(path) {
|
|
3321
3287
|
if (path.parentPath == null || path.parentPath.isExpressionStatement()) {
|
|
3322
|
-
throw new Error(
|
|
3288
|
+
throw new Error(messages_1.UNBOUND_STYLEX_CALL_VALUE);
|
|
3323
3289
|
}
|
|
3324
3290
|
const nearestStatement = findNearestStatementAncestor(path);
|
|
3325
3291
|
if (!nearestStatement.parentPath.isProgram() && !nearestStatement.parentPath.isExportNamedDeclaration()) {
|
|
3326
|
-
throw new Error(
|
|
3292
|
+
throw new Error(messages_1.ONLY_TOP_LEVEL);
|
|
3327
3293
|
}
|
|
3328
3294
|
if (path.node.arguments.length !== 1) {
|
|
3329
|
-
throw new Error(
|
|
3295
|
+
throw new Error(messages_1.ILLEGAL_ARGUMENT_LENGTH);
|
|
3330
3296
|
}
|
|
3331
3297
|
if (path.node.arguments[0].type !== 'ObjectExpression') {
|
|
3332
|
-
throw new Error(
|
|
3298
|
+
throw new Error(messages_1.NON_OBJECT_FOR_STYLEX_CALL);
|
|
3333
3299
|
}
|
|
3334
3300
|
}
|
|
3335
3301
|
|
|
@@ -3354,7 +3320,7 @@ function preProcessStyleArg(objPath, state) {
|
|
|
3354
3320
|
}
|
|
3355
3321
|
const expression = argument.get('expression');
|
|
3356
3322
|
if (!expression.isIdentifier() && !expression.isMemberExpression()) {
|
|
3357
|
-
throw new Error(
|
|
3323
|
+
throw new Error(messages_1.ILLEGAL_NAMESPACE_VALUE);
|
|
3358
3324
|
}
|
|
3359
3325
|
if (!(path.parentPath.isObjectExpression() &&
|
|
3360
3326
|
// namespaceObject
|
|
@@ -3366,7 +3332,7 @@ function preProcessStyleArg(objPath, state) {
|
|
|
3366
3332
|
// stylex.create
|
|
3367
3333
|
)) {
|
|
3368
3334
|
// Disallow spreads within pseudo or media query objects
|
|
3369
|
-
throw new Error(
|
|
3335
|
+
throw new Error(messages_1.ILLEGAL_NESTED_PSEUDO);
|
|
3370
3336
|
}
|
|
3371
3337
|
let stylexName = getStylexDefaultImport(path, state);
|
|
3372
3338
|
argument.replaceWith(t__namespace.callExpression(t__namespace.memberExpression(t__namespace.identifier(stylexName), t__namespace.identifier('include')), [expression.node]));
|
|
@@ -3414,10 +3380,10 @@ function transformStyleXKeyframes(path, state) {
|
|
|
3414
3380
|
}
|
|
3415
3381
|
if (node.init.callee.type === 'Identifier' && state.stylexKeyframesImport.has(node.init.callee.name) || node.init.callee.type === 'MemberExpression' && node.init.callee.object.type === 'Identifier' && node.init.callee.property.type === 'Identifier' && state.stylexImport.has(node.init.callee.object.name) && node.init.callee.property.name === 'keyframes') {
|
|
3416
3382
|
if (node.init.arguments.length !== 1) {
|
|
3417
|
-
throw new Error(
|
|
3383
|
+
throw new Error(messages_1.ILLEGAL_ARGUMENT_LENGTH);
|
|
3418
3384
|
}
|
|
3419
3385
|
if (node.init.arguments[0].type !== 'ObjectExpression') {
|
|
3420
|
-
throw new Error(
|
|
3386
|
+
throw new Error(messages_1.NON_OBJECT_FOR_STYLEX_CALL);
|
|
3421
3387
|
}
|
|
3422
3388
|
const init = path.get('init');
|
|
3423
3389
|
const args = init.get('arguments');
|
|
@@ -3431,11 +3397,11 @@ function transformStyleXKeyframes(path, state) {
|
|
|
3431
3397
|
value
|
|
3432
3398
|
} = firstArg.evaluate();
|
|
3433
3399
|
if (!confident) {
|
|
3434
|
-
throw new Error(
|
|
3400
|
+
throw new Error(messages_1.NON_STATIC_VALUE);
|
|
3435
3401
|
}
|
|
3436
3402
|
const plainObject = value;
|
|
3437
3403
|
assertValidKeyframes(plainObject);
|
|
3438
|
-
let [animationName, injectedStyle] =
|
|
3404
|
+
let [animationName, injectedStyle] = keyframes_1(plainObject, state.options);
|
|
3439
3405
|
|
|
3440
3406
|
// This should be a string
|
|
3441
3407
|
path.get('init').replaceWith(t__namespace.stringLiteral(animationName));
|
|
@@ -3466,11 +3432,11 @@ function transformStyleXKeyframes(path, state) {
|
|
|
3466
3432
|
// Validation of `stylex.keyframes` function call.
|
|
3467
3433
|
function assertValidKeyframes(obj) {
|
|
3468
3434
|
if (typeof obj !== 'object' || Array.isArray(obj) || obj == null) {
|
|
3469
|
-
throw new Error(
|
|
3435
|
+
throw new Error(messages_1.NON_OBJECT_FOR_STYLEX_CALL);
|
|
3470
3436
|
}
|
|
3471
3437
|
for (const [key, value] of Object.entries(obj)) {
|
|
3472
3438
|
if (typeof value !== 'object' || Array.isArray(value)) {
|
|
3473
|
-
throw new Error(
|
|
3439
|
+
throw new Error(messages_1.ILLEGAL_NAMESPACE_VALUE);
|
|
3474
3440
|
}
|
|
3475
3441
|
}
|
|
3476
3442
|
}
|