@stylexjs/babel-plugin 0.1.0-beta.7 → 0.2.0-beta.8
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 +861 -248
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var t = require('@babel/types');
|
|
6
6
|
var require$$0 = require('postcss-value-parser');
|
|
7
7
|
var path = require('path');
|
|
8
|
+
var require$$0$1 = require('invariant');
|
|
8
9
|
|
|
9
10
|
function _interopNamespaceDefault(e) {
|
|
10
11
|
var n = Object.create(null);
|
|
@@ -25,7 +26,7 @@ function _interopNamespaceDefault(e) {
|
|
|
25
26
|
|
|
26
27
|
var t__namespace = /*#__PURE__*/_interopNamespaceDefault(t);
|
|
27
28
|
|
|
28
|
-
function _defineProperty(obj, key, value) {
|
|
29
|
+
function _defineProperty$1(obj, key, value) {
|
|
29
30
|
if (key in obj) {
|
|
30
31
|
Object.defineProperty(obj, key, {
|
|
31
32
|
value: value,
|
|
@@ -49,15 +50,15 @@ class StateManager {
|
|
|
49
50
|
// resuls of `stylex.create` calls that should be kept
|
|
50
51
|
|
|
51
52
|
constructor(state) {
|
|
52
|
-
_defineProperty(this, "_state", void 0);
|
|
53
|
-
_defineProperty(this, "stylexImport", new Set());
|
|
54
|
-
_defineProperty(this, "stylexCreateImport", new Set());
|
|
55
|
-
_defineProperty(this, "stylexIncludeImport", new Set());
|
|
56
|
-
_defineProperty(this, "stylexFirstThatWorksImport", new Set());
|
|
57
|
-
_defineProperty(this, "stylexKeyframesImport", new Set());
|
|
58
|
-
_defineProperty(this, "styleMap", new Map());
|
|
59
|
-
_defineProperty(this, "styleVars", new Map());
|
|
60
|
-
_defineProperty(this, "styleVarsToKeep", new Set());
|
|
53
|
+
_defineProperty$1(this, "_state", void 0);
|
|
54
|
+
_defineProperty$1(this, "stylexImport", new Set());
|
|
55
|
+
_defineProperty$1(this, "stylexCreateImport", new Set());
|
|
56
|
+
_defineProperty$1(this, "stylexIncludeImport", new Set());
|
|
57
|
+
_defineProperty$1(this, "stylexFirstThatWorksImport", new Set());
|
|
58
|
+
_defineProperty$1(this, "stylexKeyframesImport", new Set());
|
|
59
|
+
_defineProperty$1(this, "styleMap", new Map());
|
|
60
|
+
_defineProperty$1(this, "styleVars", new Map());
|
|
61
|
+
_defineProperty$1(this, "styleVarsToKeep", new Set());
|
|
61
62
|
this._state = state;
|
|
62
63
|
state.file.metadata.stylex = [];
|
|
63
64
|
}
|
|
@@ -70,7 +71,9 @@ class StateManager {
|
|
|
70
71
|
stylexSheetName: options.stylexSheetName ?? undefined,
|
|
71
72
|
classNamePrefix: options.classNamePrefix ?? 'x',
|
|
72
73
|
importSources: options.importSources ?? [name, 'stylex'],
|
|
73
|
-
definedStylexCSSVariables: options.definedStylexCSSVariables ?? {}
|
|
74
|
+
definedStylexCSSVariables: options.definedStylexCSSVariables ?? {},
|
|
75
|
+
genConditionalClasses: !!options.genConditionalClasses,
|
|
76
|
+
allowUnsafeProperties: !!options.allowUnsafeProperties
|
|
74
77
|
};
|
|
75
78
|
return this._state.opts;
|
|
76
79
|
}
|
|
@@ -191,7 +194,7 @@ function readRequires(path, state) {
|
|
|
191
194
|
|
|
192
195
|
var lib = {};
|
|
193
196
|
|
|
194
|
-
var stylexCreate = {};
|
|
197
|
+
var stylexCreate$1 = {};
|
|
195
198
|
|
|
196
199
|
var convertToClassName$1 = {};
|
|
197
200
|
|
|
@@ -254,8 +257,8 @@ function murmurhash2_32_gc(str, seed) {
|
|
|
254
257
|
return h >>> 0;
|
|
255
258
|
}
|
|
256
259
|
const hash = str => murmurhash2_32_gc(str, 1).toString(36);
|
|
257
|
-
var _default = hash;
|
|
258
|
-
hash$1.default = _default;
|
|
260
|
+
var _default$1 = hash;
|
|
261
|
+
hash$1.default = _default$1;
|
|
259
262
|
|
|
260
263
|
var dashify$1 = {};
|
|
261
264
|
|
|
@@ -327,8 +330,8 @@ Object.defineProperty(leadingZero, "__esModule", {
|
|
|
327
330
|
value: true
|
|
328
331
|
});
|
|
329
332
|
leadingZero.default = normalizeLeadingZero;
|
|
330
|
-
var _postcssValueParser$5 = _interopRequireDefault$
|
|
331
|
-
function _interopRequireDefault$
|
|
333
|
+
var _postcssValueParser$5 = _interopRequireDefault$d(require$$0);
|
|
334
|
+
function _interopRequireDefault$d(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
332
335
|
/**
|
|
333
336
|
* Remove leading zeros from numbers
|
|
334
337
|
*/
|
|
@@ -396,8 +399,8 @@ Object.defineProperty(timings$1, "__esModule", {
|
|
|
396
399
|
value: true
|
|
397
400
|
});
|
|
398
401
|
timings$1.default = normalizeTimings;
|
|
399
|
-
var _postcssValueParser$4 = _interopRequireDefault$
|
|
400
|
-
function _interopRequireDefault$
|
|
402
|
+
var _postcssValueParser$4 = _interopRequireDefault$c(require$$0);
|
|
403
|
+
function _interopRequireDefault$c(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
401
404
|
/**
|
|
402
405
|
* Turn millisecond values to seconds (shorter), except when < 10ms
|
|
403
406
|
*/
|
|
@@ -491,8 +494,8 @@ Object.defineProperty(zeroDimensions, "__esModule", {
|
|
|
491
494
|
value: true
|
|
492
495
|
});
|
|
493
496
|
zeroDimensions.default = normalizeZeroDimensions;
|
|
494
|
-
var _postcssValueParser$3 = _interopRequireDefault$
|
|
495
|
-
function _interopRequireDefault$
|
|
497
|
+
var _postcssValueParser$3 = _interopRequireDefault$b(require$$0);
|
|
498
|
+
function _interopRequireDefault$b(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
496
499
|
const angles = ['deg', 'grad', 'turn', 'rad'];
|
|
497
500
|
const timings = ['ms', 's'];
|
|
498
501
|
|
|
@@ -538,7 +541,7 @@ var messages$4 = {};
|
|
|
538
541
|
Object.defineProperty(messages$4, "__esModule", {
|
|
539
542
|
value: true
|
|
540
543
|
});
|
|
541
|
-
messages$4.UNKNOWN_PROP_KEY = messages$4.UNKNOWN_NAMESPACE = messages$4.UNEXPECTED_ARGUMENT = messages$4.UNBOUND_STYLEX_CALL_VALUE = messages$4.ONLY_TOP_LEVEL = messages$4.NO_PARENT_PATH = 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 = 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 = void 0;
|
|
544
|
+
messages$4.UNKNOWN_PROP_KEY = messages$4.UNKNOWN_NAMESPACE = messages$4.UNEXPECTED_ARGUMENT = messages$4.UNBOUND_STYLEX_CALL_VALUE = 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.MULTIPLE_DIRECTIONS_IN_SHORTHAND = messages$4.LOCAL_ONLY = messages$4.LINT_UNCLOSED_FUNCTION = messages$4.INVALID_SPREAD = 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 = void 0;
|
|
542
545
|
const ILLEGAL_ARGUMENT_LENGTH = 'stylex() should have 1 argument.';
|
|
543
546
|
messages$4.ILLEGAL_ARGUMENT_LENGTH = ILLEGAL_ARGUMENT_LENGTH;
|
|
544
547
|
const NON_STATIC_VALUE = 'Only static values are allowed inside of a stylex.create() call.';
|
|
@@ -555,6 +558,8 @@ const UNKNOWN_PROP_KEY = 'Unknown property key';
|
|
|
555
558
|
messages$4.UNKNOWN_PROP_KEY = UNKNOWN_PROP_KEY;
|
|
556
559
|
const INVALID_PSEUDO = 'Invalid pseudo selector, not on the whitelist.';
|
|
557
560
|
messages$4.INVALID_PSEUDO = INVALID_PSEUDO;
|
|
561
|
+
const NO_CONDITIONAL_SHORTHAND = 'You cannot use conditional style values for a shorthand property.';
|
|
562
|
+
messages$4.NO_CONDITIONAL_SHORTHAND = NO_CONDITIONAL_SHORTHAND;
|
|
558
563
|
const ILLEGAL_NAMESPACE_TYPE = 'Only a string literal namespace is allowed here.';
|
|
559
564
|
messages$4.ILLEGAL_NAMESPACE_TYPE = ILLEGAL_NAMESPACE_TYPE;
|
|
560
565
|
const UNKNOWN_NAMESPACE = 'Unknown namespace';
|
|
@@ -579,6 +584,8 @@ const EXPECTED_FUNCTION_CALL = 'Expected a simple function call but found someth
|
|
|
579
584
|
messages$4.EXPECTED_FUNCTION_CALL = EXPECTED_FUNCTION_CALL;
|
|
580
585
|
const NO_PARENT_PATH = 'Unexpected AST node without a parent path.';
|
|
581
586
|
messages$4.NO_PARENT_PATH = NO_PARENT_PATH;
|
|
587
|
+
const MULTIPLE_DIRECTIONS_IN_SHORTHAND = 'Shorthand properties cannot contain different values for different directions.';
|
|
588
|
+
messages$4.MULTIPLE_DIRECTIONS_IN_SHORTHAND = MULTIPLE_DIRECTIONS_IN_SHORTHAND;
|
|
582
589
|
|
|
583
590
|
/**
|
|
584
591
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -593,9 +600,9 @@ Object.defineProperty(detectUnclosedFns$1, "__esModule", {
|
|
|
593
600
|
value: true
|
|
594
601
|
});
|
|
595
602
|
detectUnclosedFns$1.default = detectUnclosedFns;
|
|
596
|
-
var messages$3 = _interopRequireWildcard$
|
|
597
|
-
function _getRequireWildcardCache$
|
|
598
|
-
function _interopRequireWildcard$
|
|
603
|
+
var messages$3 = _interopRequireWildcard$4(messages$4);
|
|
604
|
+
function _getRequireWildcardCache$4(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache$4 = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
605
|
+
function _interopRequireWildcard$4(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache$4(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; }
|
|
599
606
|
/**
|
|
600
607
|
* Remove leading zeros from numbers
|
|
601
608
|
*/
|
|
@@ -622,15 +629,15 @@ Object.defineProperty(normalizeValue$1, "__esModule", {
|
|
|
622
629
|
value: true
|
|
623
630
|
});
|
|
624
631
|
normalizeValue$1.default = normalizeValue;
|
|
625
|
-
var _fontSizePxToRem = _interopRequireDefault$
|
|
626
|
-
var _leadingZero = _interopRequireDefault$
|
|
627
|
-
var _quotes = _interopRequireDefault$
|
|
628
|
-
var _timings = _interopRequireDefault$
|
|
629
|
-
var _whitespace = _interopRequireDefault$
|
|
630
|
-
var _zeroDimensions = _interopRequireDefault$
|
|
631
|
-
var _detectUnclosedFns = _interopRequireDefault$
|
|
632
|
-
var _postcssValueParser$2 = _interopRequireDefault$
|
|
633
|
-
function _interopRequireDefault$
|
|
632
|
+
var _fontSizePxToRem = _interopRequireDefault$a(fontSizePxToRem);
|
|
633
|
+
var _leadingZero = _interopRequireDefault$a(leadingZero);
|
|
634
|
+
var _quotes = _interopRequireDefault$a(quotes);
|
|
635
|
+
var _timings = _interopRequireDefault$a(timings$1);
|
|
636
|
+
var _whitespace = _interopRequireDefault$a(whitespace);
|
|
637
|
+
var _zeroDimensions = _interopRequireDefault$a(zeroDimensions);
|
|
638
|
+
var _detectUnclosedFns = _interopRequireDefault$a(detectUnclosedFns$1);
|
|
639
|
+
var _postcssValueParser$2 = _interopRequireDefault$a(require$$0);
|
|
640
|
+
function _interopRequireDefault$a(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
634
641
|
// `Timings` should be before `LeadingZero`, because it
|
|
635
642
|
// changes 500ms to 0.5s, then `LeadingZero` makes it .5s
|
|
636
643
|
const normalizers = [_detectUnclosedFns.default, _whitespace.default, _timings.default, _zeroDimensions.default, _leadingZero.default, _quotes.default, _fontSizePxToRem.default];
|
|
@@ -643,8 +650,8 @@ Object.defineProperty(transformValue$1, "__esModule", {
|
|
|
643
650
|
value: true
|
|
644
651
|
});
|
|
645
652
|
transformValue$1.default = transformValue;
|
|
646
|
-
var _normalizeValue = _interopRequireDefault$
|
|
647
|
-
function _interopRequireDefault$
|
|
653
|
+
var _normalizeValue = _interopRequireDefault$9(normalizeValue$1);
|
|
654
|
+
function _interopRequireDefault$9(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
648
655
|
/**
|
|
649
656
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
650
657
|
*
|
|
@@ -840,8 +847,8 @@ Object.defineProperty(generateRtl, "__esModule", {
|
|
|
840
847
|
value: true
|
|
841
848
|
});
|
|
842
849
|
generateRtl.default = generateRTL;
|
|
843
|
-
var _postcssValueParser$1 = _interopRequireDefault$
|
|
844
|
-
function _interopRequireDefault$
|
|
850
|
+
var _postcssValueParser$1 = _interopRequireDefault$8(require$$0);
|
|
851
|
+
function _interopRequireDefault$8(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
845
852
|
/**
|
|
846
853
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
847
854
|
*
|
|
@@ -1080,10 +1087,10 @@ Object.defineProperty(generateCssRule, "__esModule", {
|
|
|
1080
1087
|
value: true
|
|
1081
1088
|
});
|
|
1082
1089
|
generateCssRule.default = generateCSSRule;
|
|
1083
|
-
var _generateLtr$1 = _interopRequireDefault$
|
|
1084
|
-
var _generateRtl$1 = _interopRequireDefault$
|
|
1085
|
-
var _genCSSRule = _interopRequireDefault$
|
|
1086
|
-
function _interopRequireDefault$
|
|
1090
|
+
var _generateLtr$1 = _interopRequireDefault$7(generateLtr);
|
|
1091
|
+
var _generateRtl$1 = _interopRequireDefault$7(generateRtl);
|
|
1092
|
+
var _genCSSRule = _interopRequireDefault$7(genCSSRule);
|
|
1093
|
+
function _interopRequireDefault$7(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1087
1094
|
/**
|
|
1088
1095
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1089
1096
|
*
|
|
@@ -1143,11 +1150,11 @@ Object.defineProperty(convertToClassName$1, "__esModule", {
|
|
|
1143
1150
|
value: true
|
|
1144
1151
|
});
|
|
1145
1152
|
convertToClassName$1.default = convertToClassName;
|
|
1146
|
-
var _hash$1 = _interopRequireDefault$
|
|
1147
|
-
var _dashify$1 = _interopRequireDefault$
|
|
1148
|
-
var _transformValue$1 = _interopRequireDefault$
|
|
1149
|
-
var _generateCssRule = _interopRequireDefault$
|
|
1150
|
-
function _interopRequireDefault$
|
|
1153
|
+
var _hash$1 = _interopRequireDefault$6(hash$1);
|
|
1154
|
+
var _dashify$1 = _interopRequireDefault$6(dashify$1);
|
|
1155
|
+
var _transformValue$1 = _interopRequireDefault$6(transformValue$1);
|
|
1156
|
+
var _generateCssRule = _interopRequireDefault$6(generateCssRule);
|
|
1157
|
+
function _interopRequireDefault$6(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1151
1158
|
/**
|
|
1152
1159
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1153
1160
|
*
|
|
@@ -1183,9 +1190,14 @@ var expandShorthands = {};
|
|
|
1183
1190
|
Object.defineProperty(expandShorthands, "__esModule", {
|
|
1184
1191
|
value: true
|
|
1185
1192
|
});
|
|
1193
|
+
expandShorthands.BANNED_PROPERTIES = void 0;
|
|
1186
1194
|
expandShorthands.default = flatMapExpandedShorthands;
|
|
1187
|
-
|
|
1188
|
-
|
|
1195
|
+
expandShorthands.expandedKeys = void 0;
|
|
1196
|
+
_interopRequireWildcard$3(messages$4);
|
|
1197
|
+
var _postcssValueParser = _interopRequireDefault$5(require$$0);
|
|
1198
|
+
function _interopRequireDefault$5(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1199
|
+
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); }
|
|
1200
|
+
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; }
|
|
1189
1201
|
/**
|
|
1190
1202
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1191
1203
|
*
|
|
@@ -1245,70 +1257,233 @@ function splitValue(str) {
|
|
|
1245
1257
|
|
|
1246
1258
|
/**
|
|
1247
1259
|
* Shorthand properties:
|
|
1248
|
-
* - [
|
|
1249
|
-
* - [
|
|
1250
|
-
* - [
|
|
1251
|
-
* - [
|
|
1252
|
-
* - [
|
|
1253
|
-
* - [
|
|
1254
|
-
* - [
|
|
1260
|
+
* - [!] all - BANNED
|
|
1261
|
+
* - [!] animation - BANNED
|
|
1262
|
+
* - [!] background - BANNED
|
|
1263
|
+
* - [x] border - adequate for now
|
|
1264
|
+
* - [ ] border-block-end
|
|
1265
|
+
* - [ ] border-block-start
|
|
1266
|
+
* - [x] border-bottom
|
|
1255
1267
|
* - [x] border-color
|
|
1256
|
-
* - [
|
|
1257
|
-
* - [
|
|
1258
|
-
* - [
|
|
1259
|
-
* - [
|
|
1268
|
+
* - [o] border-image - Only the shorthand is allowed.
|
|
1269
|
+
* - [ ] border-inline-end
|
|
1270
|
+
* - [ ] border-inline-start
|
|
1271
|
+
* - [!] border-left - BANNED
|
|
1260
1272
|
* - [x] border-radius
|
|
1261
|
-
* - [
|
|
1273
|
+
* - [!] border-right
|
|
1262
1274
|
* - [x] border-style
|
|
1263
1275
|
* - [ ] border-top
|
|
1264
1276
|
* - [x] border-width
|
|
1265
|
-
* - [
|
|
1266
|
-
* - [
|
|
1267
|
-
* - [
|
|
1268
|
-
* - [
|
|
1269
|
-
* - [
|
|
1270
|
-
* - [
|
|
1271
|
-
* - [
|
|
1272
|
-
* - [
|
|
1273
|
-
* - [
|
|
1274
|
-
* - [
|
|
1275
|
-
* - [
|
|
1276
|
-
* - [
|
|
1277
|
+
* - [o] column-rule - Only the shorthand is allowed.
|
|
1278
|
+
* - [!] columns - BANNED
|
|
1279
|
+
* - [!] flex - BANNED
|
|
1280
|
+
* - [!] flex-flow - BANNED
|
|
1281
|
+
* - [!] font - BANNED
|
|
1282
|
+
* - [x] gap
|
|
1283
|
+
* - [!] grid - BANNED
|
|
1284
|
+
* - [!] grid-area - BANNED
|
|
1285
|
+
* - [!] grid-column - BANNED
|
|
1286
|
+
* - [!] grid-row - BANNED
|
|
1287
|
+
* - [!] grid-template - BANNED
|
|
1288
|
+
* - [!] grid-template-areas - BANNED
|
|
1289
|
+
*
|
|
1290
|
+
* - [o] list-style - Only the shorthand is allowed.
|
|
1277
1291
|
* - [x] margin
|
|
1278
|
-
* - [
|
|
1279
|
-
* - [
|
|
1280
|
-
* - [
|
|
1292
|
+
* - [o] mask - Only the shorthand is allowed.
|
|
1293
|
+
* - [o] offset - Only the shorthand is allowed.
|
|
1294
|
+
* - [o] outline - Only the shorthand is allowed.
|
|
1281
1295
|
* - [x] overflow
|
|
1282
1296
|
* - [x] padding
|
|
1283
|
-
* - [
|
|
1284
|
-
* - [
|
|
1285
|
-
* - [
|
|
1286
|
-
* - [
|
|
1287
|
-
* - [
|
|
1288
|
-
* - [
|
|
1289
|
-
* - [
|
|
1290
|
-
* - [
|
|
1297
|
+
* - [x] place-content
|
|
1298
|
+
* - [x] place-items
|
|
1299
|
+
* - [x] place-self
|
|
1300
|
+
* - [X] scroll-margin
|
|
1301
|
+
* - [x] scroll-padding
|
|
1302
|
+
* - [o] text-decoration - Only the shorthand is allowed.
|
|
1303
|
+
* - [o] text-emphasis - Only the shorthand is allowed.
|
|
1304
|
+
* - [!] transition - BANNED
|
|
1291
1305
|
*/
|
|
1292
1306
|
|
|
1307
|
+
const BANNED_PROPERTIES = {
|
|
1308
|
+
all: '`all` is not supported. Use individual properties instead.',
|
|
1309
|
+
animation: '`animation` is not supported. Use individual properties like `animationName`, `animationDuration`, etc. instead.',
|
|
1310
|
+
background: '`background` is not supported. Use individual properties like `backgroundImage`, `backgroundPosition`, etc. instead.',
|
|
1311
|
+
borderColor: '`borderColor` is not supported. Use `border`, `borderTop`, `borderEnd`, `borderBottom` or `borderStart` instead.',
|
|
1312
|
+
borderStyle: '`borderStyle` is not supported. Use `border`, `borderTop`, `borderEnd`, `borderBottom` or `borderStart` instead.',
|
|
1313
|
+
borderWidth: '`borderWidth` is not supported. Use `border`, `borderTop`, `borderEnd`, `borderBottom` or `borderStart` instead.',
|
|
1314
|
+
borderTopColor: '`borderTopColor` is not supported. Use `borderTop` instead.',
|
|
1315
|
+
borderTopStyle: '`borderTopStyle` is not supported. Use `borderTop` instead.',
|
|
1316
|
+
borderTopWidth: '`borderTopWidth` is not supported. Use `borderTop` instead.',
|
|
1317
|
+
borderEndColor: '`borderEndColor` is not supported. Use `borderEnd` instead.',
|
|
1318
|
+
borderEndStyle: '`borderEndStyle` is not supported. Use `borderEnd` instead.',
|
|
1319
|
+
borderEndWidth: '`borderEndWidth` is not supported. Use `borderEnd` instead.',
|
|
1320
|
+
borderBottomColor: '`borderBottomColor` is not supported. Use `borderBottom` instead.',
|
|
1321
|
+
borderBottomStyle: '`borderBottomStyle` is not supported. Use `borderBottom` instead.',
|
|
1322
|
+
borderBottomWidth: '`borderBottomWidth` is not supported. Use `borderBottom` instead.',
|
|
1323
|
+
borderStartColor: '`borderStartColor` is not supported. Use `borderStart` instead.',
|
|
1324
|
+
borderStartStyle: '`borderStartStyle` is not supported. Use `borderStart` instead.',
|
|
1325
|
+
borderStartWidth: '`borderStartWidth` is not supported. Use `borderStart` instead.',
|
|
1326
|
+
borderBlockStartColor: '`borderBlockStartColor` is not supported. Use `borderTop` instead.',
|
|
1327
|
+
borderBlockStartStyle: '`borderBlockStartStyle` is not supported. Use `borderTop` instead.',
|
|
1328
|
+
borderBlockStartWidth: '`borderBlockStartWidth` is not supported. Use `borderTop` instead.',
|
|
1329
|
+
borderBlockEndColor: '`borderBlockEndColor` is not supported. Use `borderBottom` instead.',
|
|
1330
|
+
borderBlockEndStyle: '`borderBlockEndStyle` is not supported. Use `borderBottom` instead.',
|
|
1331
|
+
borderBlockEndWidth: '`borderBlockEndWidth` is not supported. Use `borderBottom` instead.',
|
|
1332
|
+
borderInlineStartColor: '`borderInlineStartColor` is not supported. Use `borderStart` instead.',
|
|
1333
|
+
borderInlineStartStyle: '`borderInlineStartStyle` is not supported. Use `borderStart` instead.',
|
|
1334
|
+
borderInlineStartWidth: '`borderInlineStartWidth` is not supported. Use `borderStart` instead.',
|
|
1335
|
+
borderInlineEndColor: '`borderInlineEndColor` is not supported. Use `borderEnd` instead.',
|
|
1336
|
+
borderInlineEndStyle: '`borderInlineEndStyle` is not supported. Use `borderEnd` instead.',
|
|
1337
|
+
borderInlineEndWidth: '`borderInlineEndWidth` is not supported. Use `borderEnd` instead.',
|
|
1338
|
+
borderLeft: '`borderLeft` is not supported. Use `borderStart` instead.',
|
|
1339
|
+
borderLeftColor: '`borderLeftColor` is not supported. Use `borderStart` instead.',
|
|
1340
|
+
borderLeftStyle: '`borderLeftStyle` is not supported. Use `borderStart` instead.',
|
|
1341
|
+
borderLeftWidth: '`borderLeftWidth` is not supported. Use `borderStart` instead.',
|
|
1342
|
+
borderRight: '`borderRight` is not supported. Use `borderEnd` instead.',
|
|
1343
|
+
borderRightColor: '`borderRightColor` is not supported. Use `borderEnd` instead.',
|
|
1344
|
+
borderRightStyle: '`borderRightStyle` is not supported. Use `borderEnd` instead.',
|
|
1345
|
+
borderRightWidth: '`borderRightWidth` is not supported. Use `borderEnd` instead.',
|
|
1346
|
+
borderTopLeftRadius: '`borderTopLeftRadius` is not supported. Use `borderTopStartRadius` instead.',
|
|
1347
|
+
borderTopRightRadius: '`borderTopRightRadius` is not supported. Use `borderTopEndRadius` instead.',
|
|
1348
|
+
borderBottomLeftRadius: '`borderBottomLeftRadius` is not supported. Use `borderBottomStartRadius` instead.',
|
|
1349
|
+
borderBottomRightRadius: '`borderBottomRightRadius` is not supported. Use `borderBottomEndRadius` instead.',
|
|
1350
|
+
borderImageSource: '`borderImageSource` is not supported. Use `borderImage` instead.',
|
|
1351
|
+
borderImageSlice: '`borderImageSlice` is not supported. Use `borderImage` instead.',
|
|
1352
|
+
borderImageWidth: '`borderImageWidth` is not supported. Use `borderImage` instead.',
|
|
1353
|
+
borderImageOutset: '`borderImageOutset` is not supported. Use `borderImage` instead.',
|
|
1354
|
+
borderImageRepeat: '`borderImageRepeat` is not supported. Use `borderImage` instead.',
|
|
1355
|
+
marginLeft: '`marginLeft` is not supported. Use `marginStart` instead.',
|
|
1356
|
+
marginRight: '`marginRight` is not supported. Use `marginEnd` instead.',
|
|
1357
|
+
paddingLeft: '`paddingLeft` is not supported. Use `paddingStart` instead.',
|
|
1358
|
+
paddingRight: '`paddingRight` is not supported. Use `paddingEnd` instead.',
|
|
1359
|
+
columnRuleWidth: '`columnRuleWidth` is not supported. Use `columnRule` instead.',
|
|
1360
|
+
columnRuleStyle: '`columnRuleStyle` is not supported. Use `columnRule` instead.',
|
|
1361
|
+
columnRuleColor: '`columnRuleColor` is not supported. Use `columnRule` instead.',
|
|
1362
|
+
columns: '`columns` is not supported. Use `columnCount` and `columnWidth` instead.',
|
|
1363
|
+
flex: '`flex` is not supported. Use `flexGrow`, `flexShrink`, and `flexBasis` instead.',
|
|
1364
|
+
flexFlow: '`flexFlow` is not supported. Use `flexDirection` and `flexWrap` instead.',
|
|
1365
|
+
font: '`font` is not supported. Use individual properties like `fontFamily`, `fontSize`, etc. instead.',
|
|
1366
|
+
grid: '`grid` is not supported. Use individual properties like `gridTemplateColumns`, `gridTemplateRows`, etc. instead.',
|
|
1367
|
+
gridColumn: '`gridColumn` is not supported. Use `gridColumnStart` and `gridColumnEnd` instead.',
|
|
1368
|
+
gridRow: '`gridRow` is not supported. Use `gridRowStart` and `gridRowEnd` instead.',
|
|
1369
|
+
gridArea: '`gridArea` is not supported. Use `gridRowStart`, `gridColumnStart`, `gridRowEnd`, and `gridColumnEnd` instead.',
|
|
1370
|
+
gridTemplate: '`gridTemplate` is not supported. Use individual properties like `gridTemplateColumns`, `gridTemplateRows`, etc. instead.',
|
|
1371
|
+
gridTemplateAreas: '`gridTemplateAreas` is not supported. Use `gridTemplateRows` and `gridTemplateColumns` instead.',
|
|
1372
|
+
listStyleImage: '`listStyleImage` is not supported. Use `listStyle` instead.',
|
|
1373
|
+
listStylePosition: '`listStylePosition` is not supported. Use `listStyle` instead.',
|
|
1374
|
+
listStyleType: '`listStyleType` is not supported. Use `listStyle` instead.',
|
|
1375
|
+
maskClip: '`maskClip` is not supported. Use `mask` instead.',
|
|
1376
|
+
maskComposite: '`maskComposite` is not supported. Use `mask` instead.',
|
|
1377
|
+
maskImage: '`maskImage` is not supported. Use `mask` instead.',
|
|
1378
|
+
maskMode: '`maskMode` is not supported. Use `mask` instead.',
|
|
1379
|
+
maskOrigin: '`maskOrigin` is not supported. Use `mask` instead.',
|
|
1380
|
+
maskPosition: '`maskPosition` is not supported. Use `mask` instead.',
|
|
1381
|
+
maskRepeat: '`maskRepeat` is not supported. Use `mask` instead.',
|
|
1382
|
+
maskSize: '`maskSize` is not supported. Use `mask` instead.',
|
|
1383
|
+
offsetAnchor: '`offsetAnchor` is not supported. Use `offset` instead.',
|
|
1384
|
+
offsetDistance: '`offsetDistance` is not supported. Use `offset` instead.',
|
|
1385
|
+
offsetPath: '`offsetPath` is not supported. Use `offset` instead.',
|
|
1386
|
+
offsetPosition: '`offsetPosition` is not supported. Use `offset` instead.',
|
|
1387
|
+
offsetRotate: '`offsetRotate` is not supported. Use `offset` instead.',
|
|
1388
|
+
outlineColor: '`outlineColor` is not supported. Use `outline` instead.',
|
|
1389
|
+
outlineStyle: '`outlineStyle` is not supported. Use `outline` instead.',
|
|
1390
|
+
outlineWidth: '`outlineWidth` is not supported. Use `outline` instead.',
|
|
1391
|
+
textDecorationColor: '`textDecorationColor` is not supported. Use `textDecoration` instead.',
|
|
1392
|
+
textDecorationLine: '`textDecorationLine` is not supported. Use `textDecoration` instead.',
|
|
1393
|
+
textDecorationStyle: '`textDecorationStyle` is not supported. Use `textDecoration` instead.',
|
|
1394
|
+
textDecorationThickness: '`textDecorationThickness` is not supported. Use `textDecoration` instead.',
|
|
1395
|
+
textEmphasisColor: '`textEmphasisColor` is not supported. Use `textEmphasis` instead.',
|
|
1396
|
+
textEmphasisStyle: '`textEmphasisStyle` is not supported. Use `textEmphasis` instead.',
|
|
1397
|
+
transition: '`transition` is not supported. Use individual properties like `transitionProperty`, `transitionDuration`, etc. instead.'
|
|
1398
|
+
};
|
|
1399
|
+
expandShorthands.BANNED_PROPERTIES = BANNED_PROPERTIES;
|
|
1293
1400
|
const expansions = {
|
|
1294
|
-
// ...aliases,
|
|
1295
1401
|
border: rawValue => {
|
|
1296
1402
|
return [['borderTop', rawValue], ['borderEnd', rawValue], ['borderBottom', rawValue], ['borderStart', rawValue]];
|
|
1297
1403
|
},
|
|
1298
|
-
|
|
1299
|
-
//
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
}
|
|
1311
|
-
|
|
1404
|
+
// border: (rawValue: string) => {
|
|
1405
|
+
// if (typeof rawValue === 'number') {
|
|
1406
|
+
// return expansions.borderWidth(rawValue);
|
|
1407
|
+
// }
|
|
1408
|
+
// const [width, style, color, more] = splitValue(rawValue);
|
|
1409
|
+
// if (more != null) {
|
|
1410
|
+
// throw new Error(messages.MULTIPLE_DIRECTIONS_IN_SHORTHAND);
|
|
1411
|
+
// }
|
|
1412
|
+
// if (style == null || color == null) {
|
|
1413
|
+
// throw new Error(
|
|
1414
|
+
// 'Border shorthand requires at least 2 values - width, style and color.'
|
|
1415
|
+
// );
|
|
1416
|
+
// }
|
|
1417
|
+
// return [
|
|
1418
|
+
// ...expansions.borderWidth(width),
|
|
1419
|
+
// ...expansions.borderStyle(style),
|
|
1420
|
+
// ...expansions.borderColor(color),
|
|
1421
|
+
// ];
|
|
1422
|
+
// },
|
|
1423
|
+
// borderTop: (rawValue: string) => {
|
|
1424
|
+
// if (typeof rawValue === 'number') {
|
|
1425
|
+
// return [['borderTopWidth', rawValue + 'px']];
|
|
1426
|
+
// }
|
|
1427
|
+
// const [width, style, color] = splitValue(rawValue);
|
|
1428
|
+
// if (style == null || color == null) {
|
|
1429
|
+
// throw new Error(
|
|
1430
|
+
// 'BorderTop shorthand requires at least 2 values - width, style and color.'
|
|
1431
|
+
// );
|
|
1432
|
+
// }
|
|
1433
|
+
// return [
|
|
1434
|
+
// ['borderTopWidth', width],
|
|
1435
|
+
// ['borderTopStyle', style],
|
|
1436
|
+
// ['borderTopColor', color],
|
|
1437
|
+
// ];
|
|
1438
|
+
// },
|
|
1439
|
+
// borderEnd: (rawValue: string) => {
|
|
1440
|
+
// if (typeof rawValue === 'number') {
|
|
1441
|
+
// return [['borderEndWidth', rawValue + 'px']];
|
|
1442
|
+
// }
|
|
1443
|
+
// const [width, style, color] = splitValue(rawValue);
|
|
1444
|
+
// if (style == null || color == null) {
|
|
1445
|
+
// throw new Error(
|
|
1446
|
+
// 'BorderEnd shorthand requires at least 2 values - width, style and color.'
|
|
1447
|
+
// );
|
|
1448
|
+
// }
|
|
1449
|
+
// return [
|
|
1450
|
+
// ['borderEndWidth', width],
|
|
1451
|
+
// ['borderEndStyle', style],
|
|
1452
|
+
// ['borderEndColor', color],
|
|
1453
|
+
// ];
|
|
1454
|
+
// },
|
|
1455
|
+
// borderBottom: (rawValue: string) => {
|
|
1456
|
+
// if (typeof rawValue === 'number') {
|
|
1457
|
+
// return [['borderBottomWidth', rawValue + 'px']];
|
|
1458
|
+
// }
|
|
1459
|
+
// const [width, style, color] = splitValue(rawValue);
|
|
1460
|
+
// if (style == null || color == null) {
|
|
1461
|
+
// throw new Error(
|
|
1462
|
+
// 'BorderBottom shorthand requires at least 2 values - width, style and color.'
|
|
1463
|
+
// );
|
|
1464
|
+
// }
|
|
1465
|
+
// return [
|
|
1466
|
+
// ['borderBottomWidth', width],
|
|
1467
|
+
// ['borderBottomStyle', style],
|
|
1468
|
+
// ['borderBottomColor', color],
|
|
1469
|
+
// ];
|
|
1470
|
+
// },
|
|
1471
|
+
// borderStart: (rawValue: string) => {
|
|
1472
|
+
// if (typeof rawValue === 'number') {
|
|
1473
|
+
// return [['borderStartWidth', rawValue + 'px']];
|
|
1474
|
+
// }
|
|
1475
|
+
// const [width, style, color] = splitValue(rawValue);
|
|
1476
|
+
// if (style == null || color == null) {
|
|
1477
|
+
// throw new Error(
|
|
1478
|
+
// 'BorderStart shorthand requires at least 2 values - width, style and color.'
|
|
1479
|
+
// );
|
|
1480
|
+
// }
|
|
1481
|
+
// return [
|
|
1482
|
+
// ['borderStartWidth', width],
|
|
1483
|
+
// ['borderStartStyle', style],
|
|
1484
|
+
// ['borderStartColor', color],
|
|
1485
|
+
// ];
|
|
1486
|
+
// },
|
|
1312
1487
|
borderColor: rawValue => {
|
|
1313
1488
|
const [top, right = top, bottom = top, left = right] = splitValue(rawValue);
|
|
1314
1489
|
return [['borderTopColor', top], ['borderEndColor', right], ['borderBottomColor', bottom], ['borderStartColor', left]];
|
|
@@ -1355,8 +1530,37 @@ const expansions = {
|
|
|
1355
1530
|
},
|
|
1356
1531
|
paddingVertical: rawValue => {
|
|
1357
1532
|
return [['paddingTop', rawValue], ['paddingBottom', rawValue]];
|
|
1533
|
+
},
|
|
1534
|
+
gap: rawValue => {
|
|
1535
|
+
if (typeof rawValue === 'number') {
|
|
1536
|
+
return [['rowGap', rawValue], ['columnGap', rawValue]];
|
|
1537
|
+
}
|
|
1538
|
+
const [row, column = row] = splitValue(rawValue);
|
|
1539
|
+
return [['rowGap', row], ['columnGap', column]];
|
|
1540
|
+
},
|
|
1541
|
+
placeContent: rawValue => {
|
|
1542
|
+
const [align, justify = align] = splitValue(rawValue);
|
|
1543
|
+
return [['alignContent', align], ['justifyContent', justify]];
|
|
1544
|
+
},
|
|
1545
|
+
placeItems: rawValue => {
|
|
1546
|
+
const [align, justify = align] = splitValue(rawValue);
|
|
1547
|
+
return [['alignItems', align], ['justifyItems', justify]];
|
|
1548
|
+
},
|
|
1549
|
+
placeSelf: rawValue => {
|
|
1550
|
+
const [align, justify = align] = splitValue(rawValue);
|
|
1551
|
+
return [['alignSelf', align], ['justifySelf', justify]];
|
|
1552
|
+
},
|
|
1553
|
+
scrollMargin: rawValue => {
|
|
1554
|
+
const [top, right = top, bottom = top, left = right] = typeof rawValue === 'number' ? [rawValue] : splitValue(rawValue);
|
|
1555
|
+
return [['scrollMarginTop', top], ['scrollMarginEnd', right], ['scrollMarginBottom', bottom], ['scrollMarginStart', left]];
|
|
1556
|
+
},
|
|
1557
|
+
scrollPadding: rawValue => {
|
|
1558
|
+
const [top, right = top, bottom = top, left = right] = typeof rawValue === 'number' ? [rawValue] : splitValue(rawValue);
|
|
1559
|
+
return [['scrollPaddingTop', top], ['scrollPaddingEnd', right], ['scrollPaddingBottom', bottom], ['scrollPaddingStart', left]];
|
|
1358
1560
|
}
|
|
1359
1561
|
};
|
|
1562
|
+
const expandedKeys = [...Object.keys(expansions), ...Object.keys(BANNED_PROPERTIES)];
|
|
1563
|
+
expandShorthands.expandedKeys = expandedKeys;
|
|
1360
1564
|
function flatMapExpandedShorthands(objEntry) {
|
|
1361
1565
|
const [key, value] = objEntry;
|
|
1362
1566
|
const expansion = expansions[key];
|
|
@@ -1503,18 +1707,18 @@ class Pipe {
|
|
|
1503
1707
|
}
|
|
1504
1708
|
objectUtils.Pipe = Pipe;
|
|
1505
1709
|
|
|
1506
|
-
Object.defineProperty(stylexCreate, "__esModule", {
|
|
1710
|
+
Object.defineProperty(stylexCreate$1, "__esModule", {
|
|
1507
1711
|
value: true
|
|
1508
1712
|
});
|
|
1509
|
-
stylexCreate.default = styleXCreateSet;
|
|
1510
|
-
var _convertToClassName = _interopRequireDefault$
|
|
1511
|
-
var _expandShorthands$1 =
|
|
1713
|
+
stylexCreate$1.default = styleXCreateSet;
|
|
1714
|
+
var _convertToClassName = _interopRequireDefault$4(convertToClassName$1);
|
|
1715
|
+
var _expandShorthands$1 = _interopRequireWildcard$1(expandShorthands);
|
|
1512
1716
|
var _objectUtils$1 = objectUtils;
|
|
1513
1717
|
var messages$1 = _interopRequireWildcard$1(messages$4);
|
|
1514
1718
|
var _stylexInclude$1 = stylexInclude$1;
|
|
1515
1719
|
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); }
|
|
1516
1720
|
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; }
|
|
1517
|
-
function _interopRequireDefault$
|
|
1721
|
+
function _interopRequireDefault$4(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1518
1722
|
/**
|
|
1519
1723
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1520
1724
|
*
|
|
@@ -1584,7 +1788,7 @@ function styleXCreateNamespace(style, options) {
|
|
|
1584
1788
|
return [[key, value]];
|
|
1585
1789
|
}
|
|
1586
1790
|
if (value != null && typeof value === 'object' && !Array.isArray(value)) {
|
|
1587
|
-
if (!key.startsWith(':') && !key.startsWith('@')) {
|
|
1791
|
+
if (!key.startsWith(':') && !key.startsWith('@') && _expandShorthands$1.expandedKeys.includes(key)) {
|
|
1588
1792
|
throw new Error(messages$1.INVALID_PSEUDO);
|
|
1589
1793
|
}
|
|
1590
1794
|
return [[key, (0, _objectUtils$1.objFromEntries)((0, _objectUtils$1.objEntries)(value).flatMap(_ref2 => {
|
|
@@ -1592,6 +1796,9 @@ function styleXCreateNamespace(style, options) {
|
|
|
1592
1796
|
if (innerValue != null && typeof innerValue === 'object' && !Array.isArray(innerValue)) {
|
|
1593
1797
|
throw new Error(messages$1.ILLEGAL_NESTED_PSEUDO);
|
|
1594
1798
|
}
|
|
1799
|
+
if (!options.allowUnsafeProperties && _expandShorthands$1.BANNED_PROPERTIES[key]) {
|
|
1800
|
+
throw new Error(_expandShorthands$1.BANNED_PROPERTIES[key]);
|
|
1801
|
+
}
|
|
1595
1802
|
return (0, _expandShorthands$1.default)([innerKey, innerValue]);
|
|
1596
1803
|
}))]];
|
|
1597
1804
|
} else {
|
|
@@ -1601,6 +1808,9 @@ function styleXCreateNamespace(style, options) {
|
|
|
1601
1808
|
if (Array.isArray(value) && value.some(val => typeof val === 'object')) {
|
|
1602
1809
|
throw new Error(messages$1.ILLEGAL_PROP_ARRAY_VALUE);
|
|
1603
1810
|
}
|
|
1811
|
+
if (!options.allowUnsafeProperties && _expandShorthands$1.BANNED_PROPERTIES[key]) {
|
|
1812
|
+
throw new Error(_expandShorthands$1.BANNED_PROPERTIES[key]);
|
|
1813
|
+
}
|
|
1604
1814
|
return (0, _expandShorthands$1.default)([key, value]);
|
|
1605
1815
|
}
|
|
1606
1816
|
});
|
|
@@ -1616,18 +1826,34 @@ function styleXCreateNamespace(style, options) {
|
|
|
1616
1826
|
if (val instanceof _stylexInclude$1.IncludedStyles) {
|
|
1617
1827
|
resolvedNamespace[key] = val;
|
|
1618
1828
|
} else if (val != null && typeof val === 'object' && !Array.isArray(val)) {
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1829
|
+
if (key.startsWith(':') || key.startsWith('@')) {
|
|
1830
|
+
const pseudo = key;
|
|
1831
|
+
const innerObj = {};
|
|
1832
|
+
for (const [innerKey, innerVal] of (0, _objectUtils$1.objEntries)(val)) {
|
|
1833
|
+
if (innerVal === null) {
|
|
1834
|
+
innerObj[innerKey] = null;
|
|
1835
|
+
} else {
|
|
1836
|
+
const [updatedKey, className, cssRule] = (0, _convertToClassName.default)([innerKey, innerVal], pseudo, options);
|
|
1837
|
+
innerObj[updatedKey] = className;
|
|
1838
|
+
injectedStyles[updatedKey + pseudo] = [className, cssRule];
|
|
1839
|
+
}
|
|
1628
1840
|
}
|
|
1841
|
+
resolvedNamespace[key] = innerObj;
|
|
1842
|
+
} else {
|
|
1843
|
+
const propKey = key;
|
|
1844
|
+
const classNames = [];
|
|
1845
|
+
for (const [pseudo, innerVal] of (0, _objectUtils$1.objEntries)(val)) {
|
|
1846
|
+
if (pseudo !== 'default' && !pseudo.startsWith(':') && !pseudo.startsWith('@')) {
|
|
1847
|
+
throw new Error(messages$1.INVALID_PSEUDO);
|
|
1848
|
+
}
|
|
1849
|
+
if (innerVal !== null) {
|
|
1850
|
+
const [updatedKey, className, cssRule] = (0, _convertToClassName.default)([propKey, innerVal], pseudo === 'default' ? undefined : pseudo, options);
|
|
1851
|
+
injectedStyles[updatedKey + pseudo] = [className, cssRule];
|
|
1852
|
+
classNames.push(className);
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
resolvedNamespace[key] = classNames.join(' ');
|
|
1629
1856
|
}
|
|
1630
|
-
resolvedNamespace[key] = innerObj;
|
|
1631
1857
|
} else {
|
|
1632
1858
|
if (val === null) {
|
|
1633
1859
|
resolvedNamespace[key] = null;
|
|
@@ -1648,14 +1874,14 @@ Object.defineProperty(stylexKeyframes, "__esModule", {
|
|
|
1648
1874
|
value: true
|
|
1649
1875
|
});
|
|
1650
1876
|
stylexKeyframes.default = styleXKeyframes;
|
|
1651
|
-
var _hash = _interopRequireDefault$
|
|
1652
|
-
var _expandShorthands = _interopRequireDefault$
|
|
1653
|
-
var _generateLtr = _interopRequireDefault$
|
|
1654
|
-
var _generateRtl = _interopRequireDefault$
|
|
1655
|
-
var _transformValue = _interopRequireDefault$
|
|
1656
|
-
var _dashify = _interopRequireDefault$
|
|
1877
|
+
var _hash = _interopRequireDefault$3(hash$1);
|
|
1878
|
+
var _expandShorthands = _interopRequireDefault$3(expandShorthands);
|
|
1879
|
+
var _generateLtr = _interopRequireDefault$3(generateLtr);
|
|
1880
|
+
var _generateRtl = _interopRequireDefault$3(generateRtl);
|
|
1881
|
+
var _transformValue = _interopRequireDefault$3(transformValue$1);
|
|
1882
|
+
var _dashify = _interopRequireDefault$3(dashify$1);
|
|
1657
1883
|
var _objectUtils = objectUtils;
|
|
1658
|
-
function _interopRequireDefault$
|
|
1884
|
+
function _interopRequireDefault$3(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1659
1885
|
/**
|
|
1660
1886
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1661
1887
|
*
|
|
@@ -1733,14 +1959,14 @@ Object.defineProperty(lib, "__esModule", {
|
|
|
1733
1959
|
value: true
|
|
1734
1960
|
});
|
|
1735
1961
|
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;
|
|
1736
|
-
var _stylexCreate = _interopRequireDefault(stylexCreate);
|
|
1737
|
-
var _stylexKeyframes = _interopRequireDefault(stylexKeyframes);
|
|
1962
|
+
var _stylexCreate = _interopRequireDefault$2(stylexCreate$1);
|
|
1963
|
+
var _stylexKeyframes = _interopRequireDefault$2(stylexKeyframes);
|
|
1738
1964
|
var _stylexInclude = _interopRequireWildcard(stylexInclude$1);
|
|
1739
|
-
var _stylexFirstThatWorks = _interopRequireDefault(stylexFirstThatWorks$1);
|
|
1965
|
+
var _stylexFirstThatWorks = _interopRequireDefault$2(stylexFirstThatWorks$1);
|
|
1740
1966
|
var m = _interopRequireWildcard(messages$4);
|
|
1741
1967
|
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); }
|
|
1742
1968
|
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; }
|
|
1743
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1969
|
+
function _interopRequireDefault$2(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1744
1970
|
/**
|
|
1745
1971
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
1746
1972
|
*
|
|
@@ -1849,14 +2075,10 @@ function canBeIdentifier(str) {
|
|
|
1849
2075
|
const VALID_CALLEES = ['String', 'Number', 'Math'];
|
|
1850
2076
|
const INVALID_METHODS = ['random'];
|
|
1851
2077
|
function isValidCallee(val) {
|
|
1852
|
-
return VALID_CALLEES.includes(
|
|
1853
|
-
// @ts-expect-error
|
|
1854
|
-
val);
|
|
2078
|
+
return VALID_CALLEES.includes(val);
|
|
1855
2079
|
}
|
|
1856
2080
|
function isInvalidMethod(val) {
|
|
1857
|
-
return INVALID_METHODS.includes(
|
|
1858
|
-
// @ts-expect-error
|
|
1859
|
-
val);
|
|
2081
|
+
return INVALID_METHODS.includes(val);
|
|
1860
2082
|
}
|
|
1861
2083
|
/**
|
|
1862
2084
|
* Deopts the evaluation
|
|
@@ -2203,6 +2425,13 @@ function evaluateQuasis(path, quasis, state) {
|
|
|
2203
2425
|
let str = '';
|
|
2204
2426
|
let i = 0;
|
|
2205
2427
|
const exprs = path.get('expressions');
|
|
2428
|
+
|
|
2429
|
+
// const exprs: Array<NodePath<t.Node>> = path.isTemplateLiteral()
|
|
2430
|
+
// ? path.get('expressions')
|
|
2431
|
+
// : (path as NodePath<t.TaggedTemplateExpression>)
|
|
2432
|
+
// .get('quasi')
|
|
2433
|
+
// .get('expressions');
|
|
2434
|
+
|
|
2206
2435
|
for (const elem of quasis) {
|
|
2207
2436
|
// not confident, evaluated an expression we don't like
|
|
2208
2437
|
if (!state.confident) break;
|
|
@@ -2538,6 +2767,422 @@ function assertValidKeyframes(obj) {
|
|
|
2538
2767
|
}
|
|
2539
2768
|
}
|
|
2540
2769
|
|
|
2770
|
+
var stylex$1 = {};
|
|
2771
|
+
|
|
2772
|
+
var stylexInject = {};
|
|
2773
|
+
|
|
2774
|
+
var StyleXSheet$1 = {};
|
|
2775
|
+
|
|
2776
|
+
/**
|
|
2777
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2778
|
+
*
|
|
2779
|
+
* This source code is licensed under the MIT license found in the
|
|
2780
|
+
* LICENSE file in the root directory of this source tree.
|
|
2781
|
+
*
|
|
2782
|
+
*
|
|
2783
|
+
*/
|
|
2784
|
+
|
|
2785
|
+
Object.defineProperty(StyleXSheet$1, "__esModule", {
|
|
2786
|
+
value: true
|
|
2787
|
+
});
|
|
2788
|
+
StyleXSheet$1.styleSheet = StyleXSheet$1.StyleXSheet = void 0;
|
|
2789
|
+
var _invariant = _interopRequireDefault$1(require$$0$1);
|
|
2790
|
+
function _interopRequireDefault$1(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2791
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2792
|
+
const LIGHT_MODE_CLASS_NAME = '__fb-light-mode';
|
|
2793
|
+
const DARK_MODE_CLASS_NAME = '__fb-dark-mode';
|
|
2794
|
+
/**
|
|
2795
|
+
* Take a theme and generate it's accompanying CSS variables
|
|
2796
|
+
*/
|
|
2797
|
+
function buildTheme(selector, theme) {
|
|
2798
|
+
const lines = [];
|
|
2799
|
+
lines.push(`${selector} {`);
|
|
2800
|
+
for (const key in theme) {
|
|
2801
|
+
const value = theme[key];
|
|
2802
|
+
lines.push(` --${key}: ${value};`);
|
|
2803
|
+
}
|
|
2804
|
+
lines.push('}');
|
|
2805
|
+
return lines.join('\n');
|
|
2806
|
+
}
|
|
2807
|
+
|
|
2808
|
+
/**
|
|
2809
|
+
* Create a <style> tag and add it to the head.
|
|
2810
|
+
*/
|
|
2811
|
+
function makeStyleTag() {
|
|
2812
|
+
const tag = document.createElement('style');
|
|
2813
|
+
tag.setAttribute('type', 'text/css');
|
|
2814
|
+
tag.setAttribute('data-stylex', 'true');
|
|
2815
|
+
const head = document.head || document.getElementsByTagName('head')[0];
|
|
2816
|
+
(0, _invariant.default)(head, 'expected head');
|
|
2817
|
+
head.appendChild(tag);
|
|
2818
|
+
return tag;
|
|
2819
|
+
}
|
|
2820
|
+
|
|
2821
|
+
/**
|
|
2822
|
+
* Check if the browser supports CSS variables
|
|
2823
|
+
*/
|
|
2824
|
+
function doesSupportCSSVariables() {
|
|
2825
|
+
return globalThis.CSS != null && globalThis.CSS.supports != null && globalThis.CSS.supports('--fake-var:0');
|
|
2826
|
+
}
|
|
2827
|
+
|
|
2828
|
+
// Regex to replace var(--foo) with an inlined version
|
|
2829
|
+
const VARIABLE_MATCH = /var\(--(.*?)\)/g;
|
|
2830
|
+
|
|
2831
|
+
// Stylesheet options
|
|
2832
|
+
|
|
2833
|
+
/**
|
|
2834
|
+
* This class manages the CSS stylesheet for the page and the injection of new
|
|
2835
|
+
* CSS rules.
|
|
2836
|
+
*/
|
|
2837
|
+
class StyleXSheet {
|
|
2838
|
+
constructor(opts) {
|
|
2839
|
+
this.tag = null;
|
|
2840
|
+
this.injected = false;
|
|
2841
|
+
this.ruleForPriority = new Map();
|
|
2842
|
+
this.rules = [];
|
|
2843
|
+
this.rootTheme = opts.rootTheme;
|
|
2844
|
+
this.rootDarkTheme = opts.rootDarkTheme;
|
|
2845
|
+
this.supportsVariables = opts.supportsVariables ?? doesSupportCSSVariables();
|
|
2846
|
+
}
|
|
2847
|
+
getVariableMatch() {
|
|
2848
|
+
return VARIABLE_MATCH;
|
|
2849
|
+
}
|
|
2850
|
+
|
|
2851
|
+
/**
|
|
2852
|
+
* Check if we have don't have access to the dom
|
|
2853
|
+
*/
|
|
2854
|
+
isHeadless() {
|
|
2855
|
+
var _globalThis$document;
|
|
2856
|
+
return this.tag == null || (globalThis === null || globalThis === void 0 ? void 0 : (_globalThis$document = globalThis.document) === null || _globalThis$document === void 0 ? void 0 : _globalThis$document.body) == null;
|
|
2857
|
+
}
|
|
2858
|
+
|
|
2859
|
+
/**
|
|
2860
|
+
* Get the stylesheet tag. Throw if none exists.
|
|
2861
|
+
*/
|
|
2862
|
+
getTag() {
|
|
2863
|
+
const {
|
|
2864
|
+
tag
|
|
2865
|
+
} = this;
|
|
2866
|
+
(0, _invariant.default)(tag != null, 'expected tag');
|
|
2867
|
+
return tag;
|
|
2868
|
+
}
|
|
2869
|
+
|
|
2870
|
+
/**
|
|
2871
|
+
* Get the current stylesheet CSS.
|
|
2872
|
+
*/
|
|
2873
|
+
getCSS() {
|
|
2874
|
+
return this.rules.join('\n');
|
|
2875
|
+
}
|
|
2876
|
+
|
|
2877
|
+
/**
|
|
2878
|
+
* Get the position of the rule in the stylesheet.
|
|
2879
|
+
*/
|
|
2880
|
+
getRulePosition(rule) {
|
|
2881
|
+
return this.rules.indexOf(rule);
|
|
2882
|
+
}
|
|
2883
|
+
|
|
2884
|
+
/**
|
|
2885
|
+
* Count of the current rules in the stylesheet. Used in tests.
|
|
2886
|
+
*/
|
|
2887
|
+
getRuleCount() {
|
|
2888
|
+
return this.rules.length;
|
|
2889
|
+
}
|
|
2890
|
+
|
|
2891
|
+
/**
|
|
2892
|
+
* Inject a style tag into the document head
|
|
2893
|
+
*/
|
|
2894
|
+
inject() {
|
|
2895
|
+
var _globalThis$document2;
|
|
2896
|
+
if (this.injected) {
|
|
2897
|
+
return;
|
|
2898
|
+
}
|
|
2899
|
+
this.injected = true;
|
|
2900
|
+
|
|
2901
|
+
// Running in a server environment
|
|
2902
|
+
if (((_globalThis$document2 = globalThis.document) === null || _globalThis$document2 === void 0 ? void 0 : _globalThis$document2.body) == null) {
|
|
2903
|
+
this.injectTheme();
|
|
2904
|
+
return;
|
|
2905
|
+
}
|
|
2906
|
+
|
|
2907
|
+
// Create style tag if in browser
|
|
2908
|
+
this.tag = makeStyleTag();
|
|
2909
|
+
this.injectTheme();
|
|
2910
|
+
}
|
|
2911
|
+
|
|
2912
|
+
/**
|
|
2913
|
+
* Inject the theme styles
|
|
2914
|
+
*/
|
|
2915
|
+
injectTheme() {
|
|
2916
|
+
if (this.rootTheme != null) {
|
|
2917
|
+
this.insert(buildTheme(`:root, .${LIGHT_MODE_CLASS_NAME}`, this.rootTheme), 0);
|
|
2918
|
+
}
|
|
2919
|
+
if (this.rootDarkTheme != null) {
|
|
2920
|
+
this.insert(buildTheme(`.${DARK_MODE_CLASS_NAME}:root, .${DARK_MODE_CLASS_NAME}`, this.rootDarkTheme), 0);
|
|
2921
|
+
}
|
|
2922
|
+
}
|
|
2923
|
+
|
|
2924
|
+
/**
|
|
2925
|
+
* Inject custom theme styles (only for internal testing)
|
|
2926
|
+
*/
|
|
2927
|
+
__injectCustomThemeForTesting(selector, theme) {
|
|
2928
|
+
if (theme != null) {
|
|
2929
|
+
this.insert(buildTheme(selector, theme), 0);
|
|
2930
|
+
}
|
|
2931
|
+
}
|
|
2932
|
+
|
|
2933
|
+
/**
|
|
2934
|
+
* Delete the requested rule from the stylesheet
|
|
2935
|
+
*/
|
|
2936
|
+
delete(rule) {
|
|
2937
|
+
// Get the index of this rule
|
|
2938
|
+
const index = this.rules.indexOf(rule);
|
|
2939
|
+
(0, _invariant.default)(index >= 0, "Couldn't find the index for rule %s", rule);
|
|
2940
|
+
|
|
2941
|
+
// Remove the rule from our index
|
|
2942
|
+
this.rules.splice(index, 1);
|
|
2943
|
+
if (this.isHeadless()) {
|
|
2944
|
+
return;
|
|
2945
|
+
}
|
|
2946
|
+
const tag = this.getTag();
|
|
2947
|
+
const sheet = tag.sheet;
|
|
2948
|
+
(0, _invariant.default)(sheet, 'expected sheet');
|
|
2949
|
+
sheet.deleteRule(index);
|
|
2950
|
+
}
|
|
2951
|
+
|
|
2952
|
+
/**
|
|
2953
|
+
*
|
|
2954
|
+
*/
|
|
2955
|
+
normalizeRule(rule) {
|
|
2956
|
+
const {
|
|
2957
|
+
rootTheme
|
|
2958
|
+
} = this;
|
|
2959
|
+
if (this.supportsVariables || rootTheme == null) {
|
|
2960
|
+
return rule;
|
|
2961
|
+
}
|
|
2962
|
+
return rule.replace(VARIABLE_MATCH, (_match, name) => {
|
|
2963
|
+
return rootTheme[name];
|
|
2964
|
+
});
|
|
2965
|
+
}
|
|
2966
|
+
|
|
2967
|
+
/**
|
|
2968
|
+
* Get the rule position a rule should be inserted at according to the
|
|
2969
|
+
* specified priority.
|
|
2970
|
+
*/
|
|
2971
|
+
getInsertPositionForPriority(priority) {
|
|
2972
|
+
// If there's an end rule associated with this priority, then get the next
|
|
2973
|
+
// rule which will belong to the next priority
|
|
2974
|
+
// The rule will be inserted before it and assigned to the current priority
|
|
2975
|
+
const priorityRule = this.ruleForPriority.get(priority);
|
|
2976
|
+
if (priorityRule != null) {
|
|
2977
|
+
return this.rules.indexOf(priorityRule) + 1;
|
|
2978
|
+
}
|
|
2979
|
+
|
|
2980
|
+
// If we've never created this priority before, then let's find the highest
|
|
2981
|
+
// priority to target
|
|
2982
|
+
const priorities = Array.from(this.ruleForPriority.keys()).sort((a, b) => b - a).filter(num => num > priority ? 1 : 0);
|
|
2983
|
+
|
|
2984
|
+
// If there's no priorities then place us at the start
|
|
2985
|
+
if (priorities.length === 0) {
|
|
2986
|
+
return this.getRuleCount();
|
|
2987
|
+
}
|
|
2988
|
+
|
|
2989
|
+
// Place us next to the next highest priority
|
|
2990
|
+
const lastPriority = priorities.pop();
|
|
2991
|
+
return this.rules.indexOf(this.ruleForPriority.get(lastPriority));
|
|
2992
|
+
}
|
|
2993
|
+
|
|
2994
|
+
/**
|
|
2995
|
+
* Insert a rule into the stylesheet.
|
|
2996
|
+
*/
|
|
2997
|
+
insert(rawLTRRule, priority, rawRTLRule) {
|
|
2998
|
+
// Inject the stylesheet if it hasn't already been
|
|
2999
|
+
if (this.injected === false) {
|
|
3000
|
+
this.inject();
|
|
3001
|
+
}
|
|
3002
|
+
if (rawRTLRule != null) {
|
|
3003
|
+
this.insert(addAncestorSelector$1(rawLTRRule, "html:not([dir='rtl'])"), priority);
|
|
3004
|
+
this.insert(addAncestorSelector$1(rawRTLRule, "html[dir='rtl']"), priority);
|
|
3005
|
+
return;
|
|
3006
|
+
}
|
|
3007
|
+
const rawRule = rawLTRRule;
|
|
3008
|
+
|
|
3009
|
+
// Don't insert this rule if it already exists
|
|
3010
|
+
if (this.rules.includes(rawRule)) {
|
|
3011
|
+
return;
|
|
3012
|
+
}
|
|
3013
|
+
const rule = this.normalizeRule(rawRule);
|
|
3014
|
+
|
|
3015
|
+
// Get the position where we should insert the rule
|
|
3016
|
+
const insertPos = this.getInsertPositionForPriority(priority);
|
|
3017
|
+
this.rules.splice(insertPos, 0, rule);
|
|
3018
|
+
|
|
3019
|
+
// Set this rule as the end of the priority group
|
|
3020
|
+
this.ruleForPriority.set(priority, rule);
|
|
3021
|
+
if (this.isHeadless()) {
|
|
3022
|
+
return;
|
|
3023
|
+
}
|
|
3024
|
+
const tag = this.getTag();
|
|
3025
|
+
const sheet = tag.sheet;
|
|
3026
|
+
if (sheet != null) {
|
|
3027
|
+
try {
|
|
3028
|
+
sheet.insertRule(rule, insertPos);
|
|
3029
|
+
} catch {
|
|
3030
|
+
// Ignore: error likely due to inserting prefixed rules (e.g. `::-moz-range-thumb`).
|
|
3031
|
+
}
|
|
3032
|
+
}
|
|
3033
|
+
// Ignore the case where sheet == null. It's an edge-case Edge 17 bug.
|
|
3034
|
+
}
|
|
3035
|
+
}
|
|
3036
|
+
|
|
3037
|
+
/**
|
|
3038
|
+
* Adds an ancestor selector in a media-query-aware way.
|
|
3039
|
+
*/
|
|
3040
|
+
StyleXSheet$1.StyleXSheet = StyleXSheet;
|
|
3041
|
+
_defineProperty(StyleXSheet, "LIGHT_MODE_CLASS_NAME", LIGHT_MODE_CLASS_NAME);
|
|
3042
|
+
_defineProperty(StyleXSheet, "DARK_MODE_CLASS_NAME", DARK_MODE_CLASS_NAME);
|
|
3043
|
+
function addAncestorSelector$1(selector, ancestorSelector) {
|
|
3044
|
+
if (!selector.startsWith('@')) {
|
|
3045
|
+
return `${ancestorSelector} ${selector}`;
|
|
3046
|
+
}
|
|
3047
|
+
const firstBracketIndex = selector.indexOf('{');
|
|
3048
|
+
const mediaQueryPart = selector.slice(0, firstBracketIndex + 1);
|
|
3049
|
+
const rest = selector.slice(firstBracketIndex + 1);
|
|
3050
|
+
return `${mediaQueryPart}${ancestorSelector} ${rest}`;
|
|
3051
|
+
}
|
|
3052
|
+
const styleSheet = new StyleXSheet({
|
|
3053
|
+
supportsVariables: true,
|
|
3054
|
+
rootTheme: {},
|
|
3055
|
+
rootDarkTheme: {}
|
|
3056
|
+
});
|
|
3057
|
+
StyleXSheet$1.styleSheet = styleSheet;
|
|
3058
|
+
|
|
3059
|
+
Object.defineProperty(stylexInject, "__esModule", {
|
|
3060
|
+
value: true
|
|
3061
|
+
});
|
|
3062
|
+
stylexInject.default = inject;
|
|
3063
|
+
var _StyleXSheet = StyleXSheet$1;
|
|
3064
|
+
/**
|
|
3065
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3066
|
+
*
|
|
3067
|
+
* This source code is licensed under the MIT license found in the
|
|
3068
|
+
* LICENSE file in the root directory of this source tree.
|
|
3069
|
+
*
|
|
3070
|
+
*
|
|
3071
|
+
*/
|
|
3072
|
+
|
|
3073
|
+
function inject(ltrRule, priority) {
|
|
3074
|
+
let rtlRule = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
3075
|
+
_StyleXSheet.styleSheet.insert(ltrRule, priority, rtlRule);
|
|
3076
|
+
}
|
|
3077
|
+
|
|
3078
|
+
/**
|
|
3079
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3080
|
+
*
|
|
3081
|
+
* This source code is licensed under the MIT license found in the
|
|
3082
|
+
* LICENSE file in the root directory of this source tree.
|
|
3083
|
+
*
|
|
3084
|
+
*
|
|
3085
|
+
*/
|
|
3086
|
+
|
|
3087
|
+
Object.defineProperty(stylex$1, "__esModule", {
|
|
3088
|
+
value: true
|
|
3089
|
+
});
|
|
3090
|
+
var default_1 = stylex$1.default = void 0;
|
|
3091
|
+
var _stylexInject = _interopRequireDefault(stylexInject);
|
|
3092
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
3093
|
+
const cache = new WeakMap() ;
|
|
3094
|
+
function stylex() {
|
|
3095
|
+
// Keep a set of property commits to the className
|
|
3096
|
+
const definedProperties = [];
|
|
3097
|
+
let className = '';
|
|
3098
|
+
let nextCache = cache;
|
|
3099
|
+
for (var _len = arguments.length, styles = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
3100
|
+
styles[_key] = arguments[_key];
|
|
3101
|
+
}
|
|
3102
|
+
while (styles.length) {
|
|
3103
|
+
// Push nested styles back onto the stack to be processed
|
|
3104
|
+
const possibleStyle = styles.pop();
|
|
3105
|
+
if (Array.isArray(possibleStyle)) {
|
|
3106
|
+
for (let i = 0; i < possibleStyle.length; i++) {
|
|
3107
|
+
styles.push(possibleStyle[i]);
|
|
3108
|
+
}
|
|
3109
|
+
continue;
|
|
3110
|
+
}
|
|
3111
|
+
|
|
3112
|
+
// Process an individual style object
|
|
3113
|
+
const styleObj = possibleStyle;
|
|
3114
|
+
if (styleObj != null && typeof styleObj === 'object') {
|
|
3115
|
+
// Build up the class names defined by this object
|
|
3116
|
+
let classNameChunk = '';
|
|
3117
|
+
if (nextCache != null && nextCache.has(styleObj)) {
|
|
3118
|
+
// Cache: read
|
|
3119
|
+
const cacheEntry = nextCache.get(styleObj);
|
|
3120
|
+
if (cacheEntry != null) {
|
|
3121
|
+
classNameChunk = cacheEntry.classNameChunk;
|
|
3122
|
+
definedProperties.push(...cacheEntry.definedPropertiesChunk);
|
|
3123
|
+
nextCache = cacheEntry.next;
|
|
3124
|
+
}
|
|
3125
|
+
} else {
|
|
3126
|
+
// Record the properties this object defines (and that haven't already
|
|
3127
|
+
// been defined by later objects.)
|
|
3128
|
+
const definedPropertiesChunk = [];
|
|
3129
|
+
for (const prop in styleObj) {
|
|
3130
|
+
const value = styleObj[prop];
|
|
3131
|
+
// Style declarations, e.g., opacity: 's3fkgpd'
|
|
3132
|
+
if (typeof value === 'string' || value === null) {
|
|
3133
|
+
// Skip adding to the chunks if property has already been seen
|
|
3134
|
+
if (!definedProperties.includes(prop)) {
|
|
3135
|
+
definedProperties.push(prop);
|
|
3136
|
+
definedPropertiesChunk.push(prop);
|
|
3137
|
+
if (typeof value === 'string') {
|
|
3138
|
+
classNameChunk += classNameChunk ? ' ' + value : value;
|
|
3139
|
+
}
|
|
3140
|
+
}
|
|
3141
|
+
}
|
|
3142
|
+
}
|
|
3143
|
+
// Cache: write
|
|
3144
|
+
if (nextCache != null) {
|
|
3145
|
+
const emptyCache = new WeakMap();
|
|
3146
|
+
nextCache.set(styleObj, {
|
|
3147
|
+
classNameChunk,
|
|
3148
|
+
definedPropertiesChunk,
|
|
3149
|
+
next: emptyCache
|
|
3150
|
+
});
|
|
3151
|
+
nextCache = emptyCache;
|
|
3152
|
+
}
|
|
3153
|
+
}
|
|
3154
|
+
|
|
3155
|
+
// Order of classes in chunks matches property-iteration order of style
|
|
3156
|
+
// object. Order of chunks matches passed order of styles from first to
|
|
3157
|
+
// last (which we iterate over in reverse).
|
|
3158
|
+
if (classNameChunk) {
|
|
3159
|
+
className = className ? classNameChunk + ' ' + className : classNameChunk;
|
|
3160
|
+
}
|
|
3161
|
+
}
|
|
3162
|
+
}
|
|
3163
|
+
return className;
|
|
3164
|
+
}
|
|
3165
|
+
function stylexCreate(_styles) {
|
|
3166
|
+
throw new Error('stylex.create should never be called. It should be compiled away.');
|
|
3167
|
+
}
|
|
3168
|
+
function stylexIncludes(_styles) {
|
|
3169
|
+
throw new Error('stylex.extends should never be called. It should be compiled away.');
|
|
3170
|
+
}
|
|
3171
|
+
stylex.create = stylexCreate;
|
|
3172
|
+
stylex.include = stylexIncludes;
|
|
3173
|
+
stylex.keyframes = _keyframes => {
|
|
3174
|
+
throw new Error('stylex.keyframes should never be called');
|
|
3175
|
+
};
|
|
3176
|
+
stylex.firstThatWorks = function () {
|
|
3177
|
+
throw new Error('stylex.firstThatWorks should never be called.');
|
|
3178
|
+
};
|
|
3179
|
+
stylex.inject = _stylexInject.default;
|
|
3180
|
+
stylex.UNSUPPORTED_PROPERTY = props => {
|
|
3181
|
+
throw new Error('stylex.UNSUPPORTED_PROPERTY should never be called. It should be compiled away.');
|
|
3182
|
+
};
|
|
3183
|
+
var _default = stylex;
|
|
3184
|
+
default_1 = stylex$1.default = _default;
|
|
3185
|
+
|
|
2541
3186
|
/**
|
|
2542
3187
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2543
3188
|
*
|
|
@@ -2565,38 +3210,21 @@ function transformStyleXMerge(path, state) {
|
|
|
2565
3210
|
return;
|
|
2566
3211
|
}
|
|
2567
3212
|
let bailOut = false;
|
|
2568
|
-
|
|
2569
|
-
|
|
3213
|
+
let conditional = false;
|
|
3214
|
+
const resolvedArgs = [];
|
|
3215
|
+
loop: for (const arg of node.arguments) {
|
|
2570
3216
|
switch (arg.type) {
|
|
2571
3217
|
case 'MemberExpression':
|
|
2572
|
-
const
|
|
2573
|
-
|
|
2574
|
-
object,
|
|
2575
|
-
computed
|
|
2576
|
-
} = arg;
|
|
2577
|
-
let objName = null;
|
|
2578
|
-
let propName = null;
|
|
2579
|
-
if (object.type === 'Identifier' && state.styleMap.has(object.name) && property.type === 'Identifier' && !computed) {
|
|
2580
|
-
objName = object.name;
|
|
2581
|
-
propName = property.name;
|
|
2582
|
-
}
|
|
2583
|
-
if (object.type === 'Identifier' && state.styleMap.has(object.name) && (property.type === 'StringLiteral' || property.type === 'NumericLiteral') && computed) {
|
|
2584
|
-
objName = object.name;
|
|
2585
|
-
propName = property.value;
|
|
2586
|
-
}
|
|
2587
|
-
if (objName != null && propName != null) {
|
|
2588
|
-
const style = state.styleMap.get(objName);
|
|
2589
|
-
if (style == null || style[propName] == null) {
|
|
2590
|
-
throw new Error(`Unknown style ${objName}.${propName}. The defined style ${objName}, contains the following keys: ${Object.keys(style ?? {}).join(', ')}`);
|
|
2591
|
-
}
|
|
2592
|
-
const namespace = style[propName];
|
|
2593
|
-
Object.assign(resolvedStyles, namespace);
|
|
2594
|
-
} else {
|
|
2595
|
-
// Unknown style found. bail out.
|
|
3218
|
+
const resolved = parseNullableStyle(arg, state);
|
|
3219
|
+
if (resolved === 'other') {
|
|
2596
3220
|
bailOut = true;
|
|
3221
|
+
break loop;
|
|
3222
|
+
} else {
|
|
3223
|
+
resolvedArgs.push(resolved);
|
|
2597
3224
|
}
|
|
2598
3225
|
break;
|
|
2599
3226
|
case 'ConditionalExpression':
|
|
3227
|
+
conditional = true;
|
|
2600
3228
|
const {
|
|
2601
3229
|
test,
|
|
2602
3230
|
consequent,
|
|
@@ -2606,54 +3234,36 @@ function transformStyleXMerge(path, state) {
|
|
|
2606
3234
|
const fallback = parseNullableStyle(alternate, state);
|
|
2607
3235
|
if (primary === 'other' || fallback === 'other') {
|
|
2608
3236
|
bailOut = true;
|
|
2609
|
-
break;
|
|
2610
|
-
}
|
|
2611
|
-
if (primary === null && fallback === null) {
|
|
2612
|
-
// A no-op
|
|
2613
|
-
break;
|
|
2614
|
-
}
|
|
2615
|
-
const allKeys = new Set([...Object.keys(primary ?? {}), ...Object.keys(fallback ?? {})]);
|
|
2616
|
-
for (const key of allKeys) {
|
|
2617
|
-
// if (resolvedStyles[key] === undefined) {
|
|
2618
|
-
const primaryValue = firstValidValue(primary === null || primary === void 0 ? void 0 : primary[key], resolvedStyles[key], '');
|
|
2619
|
-
const fallbackValue = firstValidValue(fallback === null || fallback === void 0 ? void 0 : fallback[key], resolvedStyles[key], '');
|
|
2620
|
-
resolvedStyles[key] = [test, primaryValue, fallbackValue];
|
|
2621
|
-
// }
|
|
3237
|
+
break loop;
|
|
2622
3238
|
}
|
|
2623
|
-
|
|
3239
|
+
resolvedArgs.push([test, primary, fallback]);
|
|
2624
3240
|
break;
|
|
2625
3241
|
case 'LogicalExpression':
|
|
3242
|
+
conditional = true;
|
|
2626
3243
|
if (arg.operator !== '&&') {
|
|
2627
3244
|
bailOut = true;
|
|
2628
|
-
break;
|
|
3245
|
+
break loop;
|
|
2629
3246
|
}
|
|
2630
3247
|
const {
|
|
2631
3248
|
left,
|
|
2632
3249
|
right
|
|
2633
3250
|
} = arg;
|
|
2634
|
-
|
|
2635
|
-
|
|
3251
|
+
const leftResolved = parseNullableStyle(left, state);
|
|
3252
|
+
const rightResolved = parseNullableStyle(right, state);
|
|
3253
|
+
if (leftResolved !== 'other' || rightResolved === 'other') {
|
|
2636
3254
|
bailOut = true;
|
|
2637
|
-
break;
|
|
2638
|
-
}
|
|
2639
|
-
const value = parseNullableStyle(right, state);
|
|
2640
|
-
if (value === 'other') {
|
|
2641
|
-
bailOut = true;
|
|
2642
|
-
break;
|
|
2643
|
-
}
|
|
2644
|
-
if (value === null) {
|
|
2645
|
-
// A no-op??
|
|
2646
|
-
break;
|
|
2647
|
-
}
|
|
2648
|
-
for (const [key, val] of Object.entries(value)) {
|
|
2649
|
-
resolvedStyles[key] = [left, val, resolvedStyles[key] ?? ''];
|
|
3255
|
+
break loop;
|
|
2650
3256
|
}
|
|
3257
|
+
resolvedArgs.push([left, rightResolved, null]);
|
|
2651
3258
|
break;
|
|
2652
3259
|
default:
|
|
2653
3260
|
bailOut = true;
|
|
2654
3261
|
break;
|
|
2655
3262
|
}
|
|
2656
3263
|
}
|
|
3264
|
+
if (!state.options.genConditionalClasses && conditional) {
|
|
3265
|
+
bailOut = true;
|
|
3266
|
+
}
|
|
2657
3267
|
if (bailOut) {
|
|
2658
3268
|
path.traverse({
|
|
2659
3269
|
MemberExpression(path) {
|
|
@@ -2680,17 +3290,11 @@ function transformStyleXMerge(path, state) {
|
|
|
2680
3290
|
path.skip();
|
|
2681
3291
|
// convert resolvedStyles to a string + ternary expressions
|
|
2682
3292
|
// We no longer need the keys, so we can just use the values.
|
|
2683
|
-
const stringExpression = makeStringExpression(
|
|
3293
|
+
const stringExpression = makeStringExpression(resolvedArgs);
|
|
2684
3294
|
path.replaceWith(stringExpression);
|
|
2685
3295
|
}
|
|
2686
3296
|
}
|
|
2687
|
-
|
|
2688
|
-
for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2689
|
-
values[_key] = arguments[_key];
|
|
2690
|
-
}
|
|
2691
|
-
const [first, ...rest] = values;
|
|
2692
|
-
return first !== undefined ? first : firstValidValue(...rest);
|
|
2693
|
-
}
|
|
3297
|
+
|
|
2694
3298
|
// Looks for Null or locally defined style namespaces.
|
|
2695
3299
|
// Otherwise it returns the string "other"
|
|
2696
3300
|
// Which is used as an indicator to bail out of this optimization.
|
|
@@ -2700,72 +3304,81 @@ function parseNullableStyle(node, state) {
|
|
|
2700
3304
|
}
|
|
2701
3305
|
if (t__namespace.isMemberExpression(node)) {
|
|
2702
3306
|
const {
|
|
2703
|
-
object
|
|
2704
|
-
property
|
|
3307
|
+
object,
|
|
3308
|
+
property,
|
|
2705
3309
|
computed: computed
|
|
2706
3310
|
} = node;
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
3311
|
+
let objName = null;
|
|
3312
|
+
let propName = null;
|
|
3313
|
+
if (object.type === 'Identifier' && state.styleMap.has(object.name) && property.type === 'Identifier' && !computed) {
|
|
3314
|
+
objName = object.name;
|
|
3315
|
+
propName = property.name;
|
|
3316
|
+
}
|
|
3317
|
+
if (object.type === 'Identifier' && state.styleMap.has(object.name) && (property.type === 'StringLiteral' || property.type === 'NumericLiteral') && computed) {
|
|
3318
|
+
objName = object.name;
|
|
3319
|
+
propName = property.value;
|
|
3320
|
+
}
|
|
3321
|
+
if (objName != null && propName != null) {
|
|
3322
|
+
const style = state.styleMap.get(objName);
|
|
3323
|
+
if (style != null && style[propName] != null) {
|
|
3324
|
+
return style[propName];
|
|
3325
|
+
}
|
|
2717
3326
|
}
|
|
2718
|
-
return style;
|
|
2719
|
-
} else {
|
|
2720
|
-
return 'other';
|
|
2721
3327
|
}
|
|
3328
|
+
return 'other';
|
|
2722
3329
|
}
|
|
2723
3330
|
function makeStringExpression(values) {
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
const fallbacks = makeStringExpression(value.map(_ref4 => {
|
|
2742
|
-
let [_a, _b, b] = _ref4;
|
|
2743
|
-
return b;
|
|
2744
|
-
}), true);
|
|
2745
|
-
return t__namespace.conditionalExpression(test, consequents, fallbacks);
|
|
3331
|
+
const conditions = values.filter(v => Array.isArray(v)).map(v => v[0]);
|
|
3332
|
+
if (conditions.length === 0) {
|
|
3333
|
+
return t__namespace.stringLiteral(default_1(...values));
|
|
3334
|
+
}
|
|
3335
|
+
const conditionPermutations = genConditionPermutations(conditions.length);
|
|
3336
|
+
const objEntries = conditionPermutations.map(permutation => {
|
|
3337
|
+
let i = 0;
|
|
3338
|
+
const args = values.map(v => {
|
|
3339
|
+
if (Array.isArray(v)) {
|
|
3340
|
+
const [test, primary, fallback] = v;
|
|
3341
|
+
return permutation[i++] ? primary : fallback;
|
|
3342
|
+
} else {
|
|
3343
|
+
return v;
|
|
3344
|
+
}
|
|
3345
|
+
});
|
|
3346
|
+
const key = permutation.reduce((soFar, bool) => soFar << 1 | (bool ? 1 : 0), 0);
|
|
3347
|
+
return t__namespace.objectProperty(t__namespace.numericLiteral(key), t__namespace.stringLiteral(default_1(...args)));
|
|
2746
3348
|
});
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
let [first, ...nodes] = _ref5;
|
|
2751
|
-
if (nodes.length === 0) {
|
|
2752
|
-
return first;
|
|
2753
|
-
}
|
|
2754
|
-
return t__namespace.binaryExpression('+', first, addAll(nodes));
|
|
3349
|
+
const objExpressions = t__namespace.objectExpression(objEntries);
|
|
3350
|
+
const conditionsToKey = genBitwiseOrOfConditions(conditions);
|
|
3351
|
+
return t__namespace.memberExpression(objExpressions, conditionsToKey, true);
|
|
2755
3352
|
}
|
|
2756
3353
|
|
|
2757
|
-
//
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
3354
|
+
// A function to generate a list of all possible permutations of true and false for a given count of conditional expressions.
|
|
3355
|
+
// For example, if there are 2 conditional expressions, this function will return:
|
|
3356
|
+
// [[true, true], [true, false], [false, true], [false, false]]
|
|
3357
|
+
function genConditionPermutations(count) {
|
|
3358
|
+
const result = [];
|
|
3359
|
+
for (let i = 0; i < 2 ** count; i++) {
|
|
3360
|
+
const combination = [];
|
|
3361
|
+
for (let j = 0; j < count; j++) {
|
|
3362
|
+
combination.push(Boolean(i & 1 << j));
|
|
3363
|
+
}
|
|
3364
|
+
result.push(combination);
|
|
2765
3365
|
}
|
|
2766
3366
|
return result;
|
|
2767
3367
|
}
|
|
2768
3368
|
|
|
3369
|
+
// A function to generate a bitwise or of all the conditions.
|
|
3370
|
+
// For example, if there are 2 conditional expressions, this function will return:
|
|
3371
|
+
// `!!test1 << 2 | !!test2 << 1
|
|
3372
|
+
function genBitwiseOrOfConditions(conditions) {
|
|
3373
|
+
const binaryExpressions = conditions.map((condition, i) => {
|
|
3374
|
+
const shift = conditions.length - i - 1;
|
|
3375
|
+
return t__namespace.binaryExpression('<<', t__namespace.unaryExpression('!', t__namespace.unaryExpression('!', condition)), t__namespace.numericLiteral(shift));
|
|
3376
|
+
});
|
|
3377
|
+
return binaryExpressions.reduce((acc, expr) => {
|
|
3378
|
+
return t__namespace.binaryExpression('|', acc, expr);
|
|
3379
|
+
});
|
|
3380
|
+
}
|
|
3381
|
+
|
|
2769
3382
|
/**
|
|
2770
3383
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2771
3384
|
*
|