@stylexjs/babel-plugin 0.5.1 → 0.6.1
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 +546 -511
- package/lib/utils/evaluate-path.d.ts +1 -3
- package/lib/utils/evaluate-path.js.flow +2 -5
- package/lib/utils/js-to-ast.d.ts +4 -0
- package/lib/utils/js-to-ast.js.flow +6 -0
- package/lib/utils/state-manager.d.ts +6 -0
- package/lib/utils/state-manager.js.flow +6 -0
- package/lib/utils/validate.d.ts +8 -7
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -520,6 +520,38 @@ class StateManager {
|
|
|
520
520
|
addStyle(style) {
|
|
521
521
|
this.metadata.stylex.push(style);
|
|
522
522
|
}
|
|
523
|
+
registerStyles(styles, path) {
|
|
524
|
+
if (styles.length === 0) {
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
styles.forEach(style => this.addStyle(style));
|
|
528
|
+
if (path == null || this.runtimeInjection == null) {
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
const runtimeInjection = this.runtimeInjection;
|
|
532
|
+
const statementPath = path.parentPath != null && isProgram(path.parentPath) ? path : getProgramStatement(path);
|
|
533
|
+
let injectName;
|
|
534
|
+
if (this.injectImportInserted != null) {
|
|
535
|
+
injectName = this.injectImportInserted;
|
|
536
|
+
} else {
|
|
537
|
+
const {
|
|
538
|
+
from,
|
|
539
|
+
as
|
|
540
|
+
} = runtimeInjection;
|
|
541
|
+
injectName = as != null ? this.addNamedImport(statementPath, as, from, {
|
|
542
|
+
nameHint: 'inject'
|
|
543
|
+
}) : this.addDefaultImport(statementPath, from, {
|
|
544
|
+
nameHint: 'inject'
|
|
545
|
+
});
|
|
546
|
+
this.injectImportInserted = injectName;
|
|
547
|
+
}
|
|
548
|
+
for (const [_key, {
|
|
549
|
+
ltr,
|
|
550
|
+
rtl
|
|
551
|
+
}, priority] of styles) {
|
|
552
|
+
statementPath.insertBefore(t__namespace.expressionStatement(t__namespace.callExpression(injectName, [t__namespace.stringLiteral(ltr), t__namespace.numericLiteral(priority), ...(rtl != null ? [t__namespace.stringLiteral(rtl)] : [])])));
|
|
553
|
+
}
|
|
554
|
+
}
|
|
523
555
|
markComposedNamespace(memberExpression) {
|
|
524
556
|
this.styleVarsToKeep.add(memberExpression);
|
|
525
557
|
}
|
|
@@ -587,6 +619,13 @@ const getProgramPath = path => {
|
|
|
587
619
|
}
|
|
588
620
|
return programPath;
|
|
589
621
|
};
|
|
622
|
+
const getProgramStatement = path => {
|
|
623
|
+
let programPath = path;
|
|
624
|
+
while (programPath.parentPath != null && !isProgram(programPath.parentPath) && programPath.parentPath != null) {
|
|
625
|
+
programPath = programPath.parentPath;
|
|
626
|
+
}
|
|
627
|
+
return programPath;
|
|
628
|
+
};
|
|
590
629
|
|
|
591
630
|
function readImportDeclarations(path, state) {
|
|
592
631
|
const {
|
|
@@ -708,53 +747,54 @@ var objectUtils = {};
|
|
|
708
747
|
|
|
709
748
|
var stylexInclude$2 = {};
|
|
710
749
|
|
|
711
|
-
var messages$
|
|
750
|
+
var messages$4 = {};
|
|
712
751
|
|
|
713
|
-
Object.defineProperty(messages$
|
|
752
|
+
Object.defineProperty(messages$4, "__esModule", {
|
|
714
753
|
value: true
|
|
715
754
|
});
|
|
716
|
-
messages$
|
|
717
|
-
messages$
|
|
718
|
-
messages$
|
|
719
|
-
messages$
|
|
720
|
-
messages$
|
|
721
|
-
messages$
|
|
722
|
-
messages$
|
|
723
|
-
messages$
|
|
724
|
-
messages$
|
|
725
|
-
messages$
|
|
726
|
-
messages$
|
|
727
|
-
messages$
|
|
728
|
-
messages$
|
|
729
|
-
messages$
|
|
730
|
-
messages$
|
|
731
|
-
messages$
|
|
732
|
-
messages$
|
|
733
|
-
messages$
|
|
734
|
-
messages$
|
|
735
|
-
messages$
|
|
736
|
-
messages$
|
|
737
|
-
messages$
|
|
738
|
-
messages$
|
|
739
|
-
messages$
|
|
740
|
-
messages$
|
|
741
|
-
messages$
|
|
742
|
-
messages$
|
|
743
|
-
messages$
|
|
744
|
-
messages$
|
|
745
|
-
messages$
|
|
746
|
-
messages$
|
|
747
|
-
messages$
|
|
748
|
-
messages$
|
|
755
|
+
messages$4.UNKNOWN_PROP_KEY = messages$4.UNKNOWN_NAMESPACE = messages$4.UNEXPECTED_ARGUMENT = messages$4.UNBOUND_STYLEX_CALL_VALUE = messages$4.ONLY_TOP_LEVEL_INCLUDES = messages$4.ONLY_TOP_LEVEL = messages$4.ONLY_NAMED_PARAMETERS_IN_DYNAMIC_STYLE_FUNCTIONS = messages$4.NO_PROJECT_ROOT_DIRECTORY = messages$4.NO_PARENT_PATH = messages$4.NO_CONDITIONAL_SHORTHAND = messages$4.NON_STATIC_VALUE = messages$4.NON_STATIC_KEYFRAME_VALUE = messages$4.NON_OBJECT_KEYFRAME = messages$4.NON_OBJECT_FOR_STYLEX_KEYFRAMES_CALL = messages$4.NON_OBJECT_FOR_STYLEX_CALL = messages$4.NON_EXPORT_NAMED_DECLARATION = messages$4.NON_CONTIGUOUS_VARS = 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_ARG_LENGTH_FOR_KEYFRAMES = messages$4.ILLEGAL_ARGUMENT_LENGTH = messages$4.EXPECTED_FUNCTION_CALL = messages$4.ESCAPED_STYLEX_VALUE = messages$4.DUPLICATE_CONDITIONAL = messages$4.ANONYMOUS_THEME = void 0;
|
|
756
|
+
messages$4.ILLEGAL_ARGUMENT_LENGTH = 'stylex.create() should have 1 argument.';
|
|
757
|
+
messages$4.ILLEGAL_ARG_LENGTH_FOR_KEYFRAMES = 'stylex.keyframes() should have 1 argument.';
|
|
758
|
+
messages$4.NON_STATIC_VALUE = 'Only static values are allowed inside of a stylex.create() call.';
|
|
759
|
+
messages$4.NON_STATIC_KEYFRAME_VALUE = 'Only static values are allowed inside of a stylex.keyframes() call.';
|
|
760
|
+
messages$4.ESCAPED_STYLEX_VALUE = 'Escaping a stylex.create() value is not allowed.';
|
|
761
|
+
messages$4.UNBOUND_STYLEX_CALL_VALUE = 'stylex.create calls must be bound to a bare variable.';
|
|
762
|
+
messages$4.ONLY_TOP_LEVEL = 'stylex.create() is only allowed at the root of a program.';
|
|
763
|
+
messages$4.NON_OBJECT_FOR_STYLEX_CALL = 'stylex.create() can only accept a style object.';
|
|
764
|
+
messages$4.NON_OBJECT_FOR_STYLEX_KEYFRAMES_CALL = 'stylex.keyframes() can only accept an object.';
|
|
765
|
+
messages$4.UNKNOWN_PROP_KEY = 'Unknown property key';
|
|
766
|
+
messages$4.INVALID_PSEUDO = 'Invalid pseudo selector, not on the whitelist.';
|
|
767
|
+
messages$4.INVALID_PSEUDO_OR_AT_RULE = 'Invalid pseudo or at-rule.';
|
|
768
|
+
messages$4.NO_CONDITIONAL_SHORTHAND = 'You cannot use conditional style values for a shorthand property.';
|
|
769
|
+
messages$4.ILLEGAL_NAMESPACE_TYPE = 'Only a string literal namespace is allowed here.';
|
|
770
|
+
messages$4.UNKNOWN_NAMESPACE = 'Unknown namespace';
|
|
771
|
+
messages$4.ILLEGAL_NESTED_PSEUDO = "Pseudo objects can't be nested more than one level deep.";
|
|
772
|
+
messages$4.ILLEGAL_PROP_VALUE = 'A style value can only contain an array, string or number.';
|
|
773
|
+
messages$4.ILLEGAL_PROP_ARRAY_VALUE = 'A style array value can only contain strings or numbers.';
|
|
774
|
+
messages$4.ILLEGAL_NAMESPACE_VALUE = 'A stylex namespace must be an object.';
|
|
775
|
+
messages$4.NON_OBJECT_KEYFRAME = 'Every frame within a stylex.keyframes() call must be an object.';
|
|
776
|
+
messages$4.INVALID_SPREAD = 'Imported styles spread with a stylex.create call must be type cast as `XStyle<>` to verify their type.';
|
|
777
|
+
messages$4.LINT_UNCLOSED_FUNCTION = 'Rule contains an unclosed function';
|
|
778
|
+
messages$4.LOCAL_ONLY = 'The return value of stylex.create() should not be exported.';
|
|
779
|
+
messages$4.UNEXPECTED_ARGUMENT = 'Unexpected argument passed to the stylex() function.';
|
|
780
|
+
messages$4.EXPECTED_FUNCTION_CALL = 'Expected a simple function call but found something else.';
|
|
781
|
+
messages$4.NO_PARENT_PATH = 'Unexpected AST node without a parent path.';
|
|
782
|
+
messages$4.ONLY_TOP_LEVEL_INCLUDES = 'stylex.include() is only at the top level of a style definition object.';
|
|
783
|
+
messages$4.DUPLICATE_CONDITIONAL = 'The same pseudo selector or at-rule cannot be used more than once.';
|
|
784
|
+
messages$4.NO_PROJECT_ROOT_DIRECTORY = 'The project root directory `rootDir` is not configured.';
|
|
785
|
+
messages$4.NON_EXPORT_NAMED_DECLARATION = 'The return value of stylex.defineVars() must be bound to a named export.';
|
|
786
|
+
messages$4.ANONYMOUS_THEME = 'stylex.createTheme() must be bound to a named constant.';
|
|
787
|
+
messages$4.ONLY_NAMED_PARAMETERS_IN_DYNAMIC_STYLE_FUNCTIONS = 'Only named parameters are allowed in Dynamic Style functions. Destructuring, spreading or default values are not allowed.';
|
|
788
|
+
messages$4.NON_CONTIGUOUS_VARS = 'All variables passed to `stylex.firstThatWorks` must be contiguous.';
|
|
749
789
|
|
|
750
790
|
Object.defineProperty(stylexInclude$2, "__esModule", {
|
|
751
791
|
value: true
|
|
752
792
|
});
|
|
753
793
|
stylexInclude$2.IncludedStyles = void 0;
|
|
754
794
|
stylexInclude$2.default = stylexInclude$1;
|
|
755
|
-
var messages$
|
|
756
|
-
function _getRequireWildcardCache$
|
|
757
|
-
function _interopRequireWildcard$
|
|
795
|
+
var messages$3 = _interopRequireWildcard$4(messages$4);
|
|
796
|
+
function _getRequireWildcardCache$4(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache$4 = function (e) { return e ? t : r; })(e); }
|
|
797
|
+
function _interopRequireWildcard$4(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache$4(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
758
798
|
let number = 0;
|
|
759
799
|
function uuid() {
|
|
760
800
|
return `__included_${++number}__`;
|
|
@@ -767,7 +807,7 @@ class IncludedStyles {
|
|
|
767
807
|
stylexInclude$2.IncludedStyles = IncludedStyles;
|
|
768
808
|
function stylexInclude$1(firstArg) {
|
|
769
809
|
if ((arguments.length <= 1 ? 0 : arguments.length - 1) > 0) {
|
|
770
|
-
throw new Error(messages$
|
|
810
|
+
throw new Error(messages$3.ILLEGAL_ARGUMENT_LENGTH);
|
|
771
811
|
}
|
|
772
812
|
return {
|
|
773
813
|
[uuid()]: new IncludedStyles(firstArg.node)
|
|
@@ -1088,8 +1128,8 @@ Object.defineProperty(splitCssValue, "__esModule", {
|
|
|
1088
1128
|
value: true
|
|
1089
1129
|
});
|
|
1090
1130
|
splitCssValue.default = splitValue;
|
|
1091
|
-
var _postcssValueParser$
|
|
1092
|
-
function _interopRequireDefault$
|
|
1131
|
+
var _postcssValueParser$5 = _interopRequireDefault$g(require$$0);
|
|
1132
|
+
function _interopRequireDefault$g(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1093
1133
|
function printNode(node) {
|
|
1094
1134
|
switch (node.type) {
|
|
1095
1135
|
case 'word':
|
|
@@ -1108,7 +1148,7 @@ function splitValue(str) {
|
|
|
1108
1148
|
if (Array.isArray(str)) {
|
|
1109
1149
|
return str;
|
|
1110
1150
|
}
|
|
1111
|
-
const parsed = (0, _postcssValueParser$
|
|
1151
|
+
const parsed = (0, _postcssValueParser$5.default)(str.trim());
|
|
1112
1152
|
const nodes = parsed.nodes.filter(node => node.type !== 'space' && node.type !== 'div').map(printNode);
|
|
1113
1153
|
if (nodes.length > 1 && nodes[nodes.length - 1].toLowerCase() === '!important') {
|
|
1114
1154
|
return nodes.slice(0, nodes.length - 1).map(node => node + ' !important');
|
|
@@ -1120,8 +1160,8 @@ Object.defineProperty(legacyExpandShorthands, "__esModule", {
|
|
|
1120
1160
|
value: true
|
|
1121
1161
|
});
|
|
1122
1162
|
legacyExpandShorthands.default = void 0;
|
|
1123
|
-
var _splitCssValue = _interopRequireDefault$
|
|
1124
|
-
function _interopRequireDefault$
|
|
1163
|
+
var _splitCssValue = _interopRequireDefault$f(splitCssValue);
|
|
1164
|
+
function _interopRequireDefault$f(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1125
1165
|
const shorthands$1 = {
|
|
1126
1166
|
border: rawValue => {
|
|
1127
1167
|
return [['borderTop', rawValue], ['borderEnd', rawValue], ['borderBottom', rawValue], ['borderStart', rawValue]];
|
|
@@ -1364,10 +1404,10 @@ Object.defineProperty(preprocessRules, "__esModule", {
|
|
|
1364
1404
|
});
|
|
1365
1405
|
preprocessRules.default = flatMapExpandedShorthands;
|
|
1366
1406
|
preprocessRules.getExpandedKeys = getExpandedKeys;
|
|
1367
|
-
var _applicationOrder = _interopRequireDefault$
|
|
1368
|
-
var _legacyExpandShorthands = _interopRequireDefault$
|
|
1369
|
-
var _propertySpecificity = _interopRequireDefault$
|
|
1370
|
-
function _interopRequireDefault$
|
|
1407
|
+
var _applicationOrder = _interopRequireDefault$e(applicationOrder);
|
|
1408
|
+
var _legacyExpandShorthands = _interopRequireDefault$e(legacyExpandShorthands);
|
|
1409
|
+
var _propertySpecificity = _interopRequireDefault$e(propertySpecificity);
|
|
1410
|
+
function _interopRequireDefault$e(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1371
1411
|
const expansions = {
|
|
1372
1412
|
'application-order': _applicationOrder.default,
|
|
1373
1413
|
'property-specificity': _propertySpecificity.default,
|
|
@@ -1453,8 +1493,8 @@ Object.defineProperty(fontSizePxToRem, "__esModule", {
|
|
|
1453
1493
|
value: true
|
|
1454
1494
|
});
|
|
1455
1495
|
fontSizePxToRem.default = convertFontSizeToRem;
|
|
1456
|
-
var _postcssValueParser$
|
|
1457
|
-
function _interopRequireDefault$
|
|
1496
|
+
var _postcssValueParser$4 = _interopRequireDefault$d(require$$0);
|
|
1497
|
+
function _interopRequireDefault$d(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1458
1498
|
const ROOT_FONT_SIZE = 16;
|
|
1459
1499
|
function convertFontSizeToRem(ast, key) {
|
|
1460
1500
|
if (key !== 'fontSize') {
|
|
@@ -1464,7 +1504,7 @@ function convertFontSizeToRem(ast, key) {
|
|
|
1464
1504
|
if (node.type !== 'word') {
|
|
1465
1505
|
return;
|
|
1466
1506
|
}
|
|
1467
|
-
const dimension = _postcssValueParser$
|
|
1507
|
+
const dimension = _postcssValueParser$4.default.unit(node.value);
|
|
1468
1508
|
if (dimension && dimension.unit === 'px') {
|
|
1469
1509
|
node.value = `${parseFloat(dimension.number) / ROOT_FONT_SIZE}rem`;
|
|
1470
1510
|
}
|
|
@@ -1478,8 +1518,8 @@ Object.defineProperty(leadingZero, "__esModule", {
|
|
|
1478
1518
|
value: true
|
|
1479
1519
|
});
|
|
1480
1520
|
leadingZero.default = normalizeLeadingZero;
|
|
1481
|
-
var _postcssValueParser$
|
|
1482
|
-
function _interopRequireDefault$
|
|
1521
|
+
var _postcssValueParser$3 = _interopRequireDefault$c(require$$0);
|
|
1522
|
+
function _interopRequireDefault$c(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1483
1523
|
function normalizeLeadingZero(ast, _) {
|
|
1484
1524
|
ast.walk(node => {
|
|
1485
1525
|
if (node.type !== 'word') {
|
|
@@ -1489,7 +1529,7 @@ function normalizeLeadingZero(ast, _) {
|
|
|
1489
1529
|
if (Number.isNaN(value)) {
|
|
1490
1530
|
return;
|
|
1491
1531
|
}
|
|
1492
|
-
const dimension = _postcssValueParser$
|
|
1532
|
+
const dimension = _postcssValueParser$3.default.unit(node.value);
|
|
1493
1533
|
if (value < 1 && value >= 0) {
|
|
1494
1534
|
node.value = value.toString().replace('0.', '.') + (dimension ? dimension.unit : '');
|
|
1495
1535
|
}
|
|
@@ -1515,14 +1555,14 @@ function normalizeQuotes(ast, _) {
|
|
|
1515
1555
|
return ast;
|
|
1516
1556
|
}
|
|
1517
1557
|
|
|
1518
|
-
var timings
|
|
1558
|
+
var timings = {};
|
|
1519
1559
|
|
|
1520
|
-
Object.defineProperty(timings
|
|
1560
|
+
Object.defineProperty(timings, "__esModule", {
|
|
1521
1561
|
value: true
|
|
1522
1562
|
});
|
|
1523
|
-
timings
|
|
1524
|
-
var _postcssValueParser$
|
|
1525
|
-
function _interopRequireDefault$
|
|
1563
|
+
timings.default = normalizeTimings;
|
|
1564
|
+
var _postcssValueParser$2 = _interopRequireDefault$b(require$$0);
|
|
1565
|
+
function _interopRequireDefault$b(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1526
1566
|
function normalizeTimings(ast, _) {
|
|
1527
1567
|
ast.walk(node => {
|
|
1528
1568
|
if (node.type !== 'word') {
|
|
@@ -1532,7 +1572,7 @@ function normalizeTimings(ast, _) {
|
|
|
1532
1572
|
if (Number.isNaN(value)) {
|
|
1533
1573
|
return;
|
|
1534
1574
|
}
|
|
1535
|
-
const dimension = _postcssValueParser$
|
|
1575
|
+
const dimension = _postcssValueParser$2.default.unit(node.value);
|
|
1536
1576
|
if (!dimension || dimension.unit !== 'ms' || value < 10) {
|
|
1537
1577
|
return;
|
|
1538
1578
|
}
|
|
@@ -1592,56 +1632,19 @@ function normalizeWhitespace(ast, _) {
|
|
|
1592
1632
|
return ast;
|
|
1593
1633
|
}
|
|
1594
1634
|
|
|
1595
|
-
var zeroDimensions = {};
|
|
1596
|
-
|
|
1597
|
-
Object.defineProperty(zeroDimensions, "__esModule", {
|
|
1598
|
-
value: true
|
|
1599
|
-
});
|
|
1600
|
-
zeroDimensions.default = normalizeZeroDimensions;
|
|
1601
|
-
var _postcssValueParser$2 = _interopRequireDefault$b(require$$0);
|
|
1602
|
-
function _interopRequireDefault$b(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1603
|
-
const angles = ['deg', 'grad', 'turn', 'rad'];
|
|
1604
|
-
const timings = ['ms', 's'];
|
|
1605
|
-
function normalizeZeroDimensions(ast, _) {
|
|
1606
|
-
let endFunction = 0;
|
|
1607
|
-
ast.walk(node => {
|
|
1608
|
-
if (node.type === 'function' && !endFunction) {
|
|
1609
|
-
endFunction = node.sourceEndIndex ?? 0;
|
|
1610
|
-
}
|
|
1611
|
-
if (endFunction > 0 && node.sourceIndex > endFunction) {
|
|
1612
|
-
endFunction = 0;
|
|
1613
|
-
}
|
|
1614
|
-
if (node.type !== 'word') {
|
|
1615
|
-
return;
|
|
1616
|
-
}
|
|
1617
|
-
const dimension = _postcssValueParser$2.default.unit(node.value);
|
|
1618
|
-
if (!dimension || dimension.number !== '0') {
|
|
1619
|
-
return;
|
|
1620
|
-
}
|
|
1621
|
-
if (angles.indexOf(dimension.unit) !== -1) {
|
|
1622
|
-
node.value = '0deg';
|
|
1623
|
-
} else if (timings.indexOf(dimension.unit) !== -1) {
|
|
1624
|
-
node.value = '0s';
|
|
1625
|
-
} else if (!endFunction) {
|
|
1626
|
-
node.value = '0';
|
|
1627
|
-
}
|
|
1628
|
-
});
|
|
1629
|
-
return ast;
|
|
1630
|
-
}
|
|
1631
|
-
|
|
1632
1635
|
var detectUnclosedFns$1 = {};
|
|
1633
1636
|
|
|
1634
1637
|
Object.defineProperty(detectUnclosedFns$1, "__esModule", {
|
|
1635
1638
|
value: true
|
|
1636
1639
|
});
|
|
1637
1640
|
detectUnclosedFns$1.default = detectUnclosedFns;
|
|
1638
|
-
var messages$
|
|
1639
|
-
function _getRequireWildcardCache$
|
|
1640
|
-
function _interopRequireWildcard$
|
|
1641
|
+
var messages$2 = _interopRequireWildcard$3(messages$4);
|
|
1642
|
+
function _getRequireWildcardCache$3(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache$3 = function (e) { return e ? t : r; })(e); }
|
|
1643
|
+
function _interopRequireWildcard$3(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache$3(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
1641
1644
|
function detectUnclosedFns(ast, _) {
|
|
1642
1645
|
ast.walk(node => {
|
|
1643
1646
|
if (node.type === 'function' && node.unclosed) {
|
|
1644
|
-
throw new Error(messages$
|
|
1647
|
+
throw new Error(messages$2.LINT_UNCLOSED_FUNCTION);
|
|
1645
1648
|
}
|
|
1646
1649
|
});
|
|
1647
1650
|
return ast;
|
|
@@ -1678,14 +1681,13 @@ normalizeValue$1.default = normalizeValue;
|
|
|
1678
1681
|
var _fontSizePxToRem = _interopRequireDefault$9(fontSizePxToRem);
|
|
1679
1682
|
var _leadingZero = _interopRequireDefault$9(leadingZero);
|
|
1680
1683
|
var _quotes = _interopRequireDefault$9(quotes);
|
|
1681
|
-
var _timings = _interopRequireDefault$9(timings
|
|
1684
|
+
var _timings = _interopRequireDefault$9(timings);
|
|
1682
1685
|
var _whitespace = _interopRequireDefault$9(whitespace);
|
|
1683
|
-
var _zeroDimensions = _interopRequireDefault$9(zeroDimensions);
|
|
1684
1686
|
var _detectUnclosedFns = _interopRequireDefault$9(detectUnclosedFns$1);
|
|
1685
1687
|
var _postcssValueParser$1 = _interopRequireDefault$9(require$$0);
|
|
1686
1688
|
var _convertCamelCaseValues = _interopRequireDefault$9(convertCamelCaseValues);
|
|
1687
1689
|
function _interopRequireDefault$9(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1688
|
-
const normalizers = [_detectUnclosedFns.default, _whitespace.default, _timings.default,
|
|
1690
|
+
const normalizers = [_detectUnclosedFns.default, _whitespace.default, _timings.default, _leadingZero.default, _quotes.default, _convertCamelCaseValues.default];
|
|
1689
1691
|
function normalizeValue(value, key, _ref) {
|
|
1690
1692
|
let {
|
|
1691
1693
|
useRemForFontSize
|
|
@@ -2621,12 +2623,16 @@ Object.defineProperty(convertToClassName, "__esModule", {
|
|
|
2621
2623
|
value: true
|
|
2622
2624
|
});
|
|
2623
2625
|
convertToClassName.convertStyleToClassName = convertStyleToClassName;
|
|
2626
|
+
convertToClassName.default = variableFallbacks;
|
|
2624
2627
|
var _hash$4 = _interopRequireDefault$5(hash$1);
|
|
2625
2628
|
var _dashify$1 = _interopRequireDefault$5(dashify$1);
|
|
2626
2629
|
var _transformValue$1 = _interopRequireDefault$5(transformValue$1);
|
|
2627
2630
|
var _generateCssRule = generateCssRule;
|
|
2628
2631
|
var _defaultOptions$4 = defaultOptions;
|
|
2629
2632
|
var _objectUtils$5 = objectUtils;
|
|
2633
|
+
var messages$1 = _interopRequireWildcard$2(messages$4);
|
|
2634
|
+
function _getRequireWildcardCache$2(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache$2 = function (e) { return e ? t : r; })(e); }
|
|
2635
|
+
function _interopRequireWildcard$2(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache$2(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
2630
2636
|
function _interopRequireDefault$5(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2631
2637
|
function convertStyleToClassName(objEntry, pseudos, atRules) {
|
|
2632
2638
|
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _defaultOptions$4.defaultOptions;
|
|
@@ -2635,7 +2641,10 @@ function convertStyleToClassName(objEntry, pseudos, atRules) {
|
|
|
2635
2641
|
} = options;
|
|
2636
2642
|
const [key, rawValue] = objEntry;
|
|
2637
2643
|
const dashedKey = (0, _dashify$1.default)(key);
|
|
2638
|
-
|
|
2644
|
+
let value = Array.isArray(rawValue) ? rawValue.map(eachValue => (0, _transformValue$1.default)(key, eachValue, options)) : (0, _transformValue$1.default)(key, rawValue, options);
|
|
2645
|
+
if (Array.isArray(value) && value.find(val => val.startsWith('var(') && val.endsWith(')'))) {
|
|
2646
|
+
value = variableFallbacks(value);
|
|
2647
|
+
}
|
|
2639
2648
|
const sortedPseudos = (0, _objectUtils$5.arraySort)(pseudos ?? []);
|
|
2640
2649
|
const sortedAtRules = (0, _objectUtils$5.arraySort)(atRules ?? []);
|
|
2641
2650
|
const atRuleHashString = sortedPseudos.join('');
|
|
@@ -2646,6 +2655,31 @@ function convertStyleToClassName(objEntry, pseudos, atRules) {
|
|
|
2646
2655
|
const cssRules = (0, _generateCssRule.generateRule)(className, dashedKey, value, pseudos, atRules);
|
|
2647
2656
|
return [key, className, cssRules];
|
|
2648
2657
|
}
|
|
2658
|
+
function variableFallbacks(values) {
|
|
2659
|
+
const firstVar = values.findIndex(val => val.startsWith('var(') && val.endsWith(')'));
|
|
2660
|
+
const lastVar = values.findLastIndex(val => val.startsWith('var(') && val.endsWith(')'));
|
|
2661
|
+
const valuesBeforeFirstVar = values.slice(0, firstVar);
|
|
2662
|
+
let varValues = values.slice(firstVar, lastVar + 1).reverse();
|
|
2663
|
+
const valuesAfterLastVar = values.slice(lastVar + 1);
|
|
2664
|
+
if (varValues.find(val => !val.startsWith('var(') || !val.endsWith(')'))) {
|
|
2665
|
+
throw new Error(messages$1.NON_CONTIGUOUS_VARS);
|
|
2666
|
+
}
|
|
2667
|
+
varValues = varValues.map(val => val.slice(4, -1));
|
|
2668
|
+
return [...(valuesBeforeFirstVar.length > 0 ? valuesBeforeFirstVar.map(val => composeVars(...varValues, val)) : composeVars(...varValues)), ...valuesAfterLastVar];
|
|
2669
|
+
}
|
|
2670
|
+
function composeVars() {
|
|
2671
|
+
for (var _len = arguments.length, vars = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2672
|
+
vars[_key] = arguments[_key];
|
|
2673
|
+
}
|
|
2674
|
+
const [first, ...rest] = vars;
|
|
2675
|
+
if (rest.length > 0) {
|
|
2676
|
+
return `var(${first},${composeVars(...rest)})`;
|
|
2677
|
+
} else if (first.startsWith('--')) {
|
|
2678
|
+
return `var(${first})`;
|
|
2679
|
+
} else {
|
|
2680
|
+
return first;
|
|
2681
|
+
}
|
|
2682
|
+
}
|
|
2649
2683
|
|
|
2650
2684
|
Object.defineProperty(PreRule$1, "__esModule", {
|
|
2651
2685
|
value: true
|
|
@@ -2859,7 +2893,7 @@ Object.defineProperty(basicValidation, "__esModule", {
|
|
|
2859
2893
|
});
|
|
2860
2894
|
basicValidation.validateNamespace = validateNamespace;
|
|
2861
2895
|
var _stylexInclude$2 = stylexInclude$2;
|
|
2862
|
-
var messages = _interopRequireWildcard$1(messages$
|
|
2896
|
+
var messages = _interopRequireWildcard$1(messages$4);
|
|
2863
2897
|
var _objectUtils$3 = objectUtils;
|
|
2864
2898
|
function _getRequireWildcardCache$1(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache$1 = function (e) { return e ? t : r; })(e); }
|
|
2865
2899
|
function _interopRequireWildcard$1(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache$1(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -2987,6 +3021,224 @@ function styleXCreateSet(namespaces) {
|
|
|
2987
3021
|
|
|
2988
3022
|
var stylexDefineVars$1 = {};
|
|
2989
3023
|
|
|
3024
|
+
var stylexVarsUtils = {};
|
|
3025
|
+
|
|
3026
|
+
Object.defineProperty(stylexVarsUtils, "__esModule", {
|
|
3027
|
+
value: true
|
|
3028
|
+
});
|
|
3029
|
+
stylexVarsUtils.collectVarsByAtRule = collectVarsByAtRule;
|
|
3030
|
+
stylexVarsUtils.getDefaultValue = getDefaultValue;
|
|
3031
|
+
stylexVarsUtils.priorityForAtRule = priorityForAtRule;
|
|
3032
|
+
stylexVarsUtils.wrapWithAtRules = wrapWithAtRules;
|
|
3033
|
+
const SPLIT_TOKEN = '__$$__';
|
|
3034
|
+
function collectVarsByAtRule(key, _ref) {
|
|
3035
|
+
let {
|
|
3036
|
+
nameHash,
|
|
3037
|
+
value
|
|
3038
|
+
} = _ref;
|
|
3039
|
+
let collection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
3040
|
+
let atRules = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
3041
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
3042
|
+
const val = typeof value === 'number' ? value.toString() : value;
|
|
3043
|
+
const key = atRules.length === 0 ? 'default' : [...atRules].sort().join(SPLIT_TOKEN);
|
|
3044
|
+
collection[key] ??= [];
|
|
3045
|
+
collection[key].push(`--${nameHash}:${val};`);
|
|
3046
|
+
return;
|
|
3047
|
+
}
|
|
3048
|
+
if (value === null) {
|
|
3049
|
+
return;
|
|
3050
|
+
}
|
|
3051
|
+
if (Array.isArray(value)) {
|
|
3052
|
+
throw new Error('Array is not supported in stylex.defineVars');
|
|
3053
|
+
}
|
|
3054
|
+
if (typeof value === 'object') {
|
|
3055
|
+
if (value.default === undefined) {
|
|
3056
|
+
throw new Error('Default value is not defined for ' + key + ' variable.');
|
|
3057
|
+
}
|
|
3058
|
+
for (const atRule of Object.keys(value)) {
|
|
3059
|
+
collectVarsByAtRule(key, {
|
|
3060
|
+
nameHash,
|
|
3061
|
+
value: value[atRule]
|
|
3062
|
+
}, collection, atRule === 'default' ? atRules : [...atRules, atRule]);
|
|
3063
|
+
}
|
|
3064
|
+
}
|
|
3065
|
+
}
|
|
3066
|
+
function wrapWithAtRules(ltr, atRule) {
|
|
3067
|
+
return atRule.split(SPLIT_TOKEN).reduce((acc, atRule) => `${atRule}{${acc}}`, ltr);
|
|
3068
|
+
}
|
|
3069
|
+
function priorityForAtRule(atRule) {
|
|
3070
|
+
if (atRule === 'default') {
|
|
3071
|
+
return 0;
|
|
3072
|
+
}
|
|
3073
|
+
return atRule.split(SPLIT_TOKEN).length;
|
|
3074
|
+
}
|
|
3075
|
+
function getDefaultValue(value) {
|
|
3076
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
3077
|
+
return value.toString();
|
|
3078
|
+
}
|
|
3079
|
+
if (value == null) {
|
|
3080
|
+
return null;
|
|
3081
|
+
}
|
|
3082
|
+
if (Array.isArray(value)) {
|
|
3083
|
+
throw new Error('Array is not supported in stylex.defineVars');
|
|
3084
|
+
}
|
|
3085
|
+
if (typeof value === 'object') {
|
|
3086
|
+
if (value.default === undefined) {
|
|
3087
|
+
throw new Error('Default value is not defined for variable.');
|
|
3088
|
+
}
|
|
3089
|
+
return getDefaultValue(value.default);
|
|
3090
|
+
}
|
|
3091
|
+
throw new Error('Invalid value in stylex.defineVars');
|
|
3092
|
+
}
|
|
3093
|
+
|
|
3094
|
+
var types$2 = {};
|
|
3095
|
+
|
|
3096
|
+
Object.defineProperty(types$2, "__esModule", {
|
|
3097
|
+
value: true
|
|
3098
|
+
});
|
|
3099
|
+
types$2.url = types$2.transformList = types$2.transformFunction = types$2.time = types$2.resolution = types$2.percentage = types$2.number = types$2.lengthPercentage = types$2.length = types$2.isCSSType = types$2.integer = types$2.image = types$2.color = types$2.angle = types$2.Url = types$2.TransformList = types$2.TransformFunction = types$2.Time = types$2.Resolution = types$2.Percentage = types$2.Num = types$2.LengthPercentage = types$2.Length = types$2.Integer = types$2.Image = types$2.Color = types$2.Angle = void 0;
|
|
3100
|
+
class BaseCSSType {
|
|
3101
|
+
constructor(value) {
|
|
3102
|
+
this.value = value;
|
|
3103
|
+
}
|
|
3104
|
+
}
|
|
3105
|
+
const isCSSType = value => {
|
|
3106
|
+
return value instanceof BaseCSSType && value.value != null && typeof value.syntax === 'string';
|
|
3107
|
+
};
|
|
3108
|
+
types$2.isCSSType = isCSSType;
|
|
3109
|
+
class Angle extends BaseCSSType {
|
|
3110
|
+
syntax = '<angle>';
|
|
3111
|
+
static syntax = '<angle>';
|
|
3112
|
+
static create(value) {
|
|
3113
|
+
return new Angle(value);
|
|
3114
|
+
}
|
|
3115
|
+
}
|
|
3116
|
+
types$2.Angle = Angle;
|
|
3117
|
+
types$2.angle = Angle.create;
|
|
3118
|
+
class Color extends BaseCSSType {
|
|
3119
|
+
syntax = '<color>';
|
|
3120
|
+
static create(value) {
|
|
3121
|
+
return new Color(value);
|
|
3122
|
+
}
|
|
3123
|
+
}
|
|
3124
|
+
types$2.Color = Color;
|
|
3125
|
+
types$2.color = Color.create;
|
|
3126
|
+
class Url extends BaseCSSType {
|
|
3127
|
+
syntax = '<url>';
|
|
3128
|
+
static create(value) {
|
|
3129
|
+
return new Url(value);
|
|
3130
|
+
}
|
|
3131
|
+
}
|
|
3132
|
+
types$2.Url = Url;
|
|
3133
|
+
types$2.url = Url.create;
|
|
3134
|
+
class Image extends Url {
|
|
3135
|
+
syntax = '<image>';
|
|
3136
|
+
constructor(value) {
|
|
3137
|
+
super(value);
|
|
3138
|
+
this.value = value;
|
|
3139
|
+
}
|
|
3140
|
+
static create(value) {
|
|
3141
|
+
return new Image(value);
|
|
3142
|
+
}
|
|
3143
|
+
}
|
|
3144
|
+
types$2.Image = Image;
|
|
3145
|
+
types$2.image = Image.create;
|
|
3146
|
+
class Integer extends BaseCSSType {
|
|
3147
|
+
syntax = '<integer>';
|
|
3148
|
+
static create(value) {
|
|
3149
|
+
return new Integer(convertNumberToStringUsing(String)(value));
|
|
3150
|
+
}
|
|
3151
|
+
}
|
|
3152
|
+
types$2.Integer = Integer;
|
|
3153
|
+
types$2.integer = Integer.create;
|
|
3154
|
+
class LengthPercentage extends BaseCSSType {
|
|
3155
|
+
syntax = '<length-percentage>';
|
|
3156
|
+
static createLength(value) {
|
|
3157
|
+
return new LengthPercentage(convertNumberToLength(value));
|
|
3158
|
+
}
|
|
3159
|
+
static createPercentage(value) {
|
|
3160
|
+
return new LengthPercentage(convertNumberToPercentage(value));
|
|
3161
|
+
}
|
|
3162
|
+
}
|
|
3163
|
+
types$2.LengthPercentage = LengthPercentage;
|
|
3164
|
+
types$2.lengthPercentage = LengthPercentage.createLength;
|
|
3165
|
+
class Length extends LengthPercentage {
|
|
3166
|
+
syntax = '<length>';
|
|
3167
|
+
static create(value) {
|
|
3168
|
+
return new Length(convertNumberToLength(value));
|
|
3169
|
+
}
|
|
3170
|
+
}
|
|
3171
|
+
types$2.Length = Length;
|
|
3172
|
+
types$2.length = Length.create;
|
|
3173
|
+
class Percentage extends LengthPercentage {
|
|
3174
|
+
syntax = '<percentage>';
|
|
3175
|
+
static create(value) {
|
|
3176
|
+
return new Percentage(convertNumberToPercentage(value));
|
|
3177
|
+
}
|
|
3178
|
+
}
|
|
3179
|
+
types$2.Percentage = Percentage;
|
|
3180
|
+
types$2.percentage = Percentage.create;
|
|
3181
|
+
class Num extends BaseCSSType {
|
|
3182
|
+
syntax = '<number>';
|
|
3183
|
+
static create(value) {
|
|
3184
|
+
return new Num(convertNumberToBareString(value));
|
|
3185
|
+
}
|
|
3186
|
+
}
|
|
3187
|
+
types$2.Num = Num;
|
|
3188
|
+
types$2.number = Num.create;
|
|
3189
|
+
class Resolution extends BaseCSSType {
|
|
3190
|
+
syntax = '<resolution>';
|
|
3191
|
+
static create(value) {
|
|
3192
|
+
return new Resolution(value);
|
|
3193
|
+
}
|
|
3194
|
+
}
|
|
3195
|
+
types$2.Resolution = Resolution;
|
|
3196
|
+
types$2.resolution = Resolution.create;
|
|
3197
|
+
class Time extends BaseCSSType {
|
|
3198
|
+
syntax = '<time>';
|
|
3199
|
+
static create(value) {
|
|
3200
|
+
return new Time(value);
|
|
3201
|
+
}
|
|
3202
|
+
}
|
|
3203
|
+
types$2.Time = Time;
|
|
3204
|
+
types$2.time = Time.create;
|
|
3205
|
+
class TransformFunction extends BaseCSSType {
|
|
3206
|
+
syntax = '<transform-function>';
|
|
3207
|
+
static create(value) {
|
|
3208
|
+
return new TransformFunction(value);
|
|
3209
|
+
}
|
|
3210
|
+
}
|
|
3211
|
+
types$2.TransformFunction = TransformFunction;
|
|
3212
|
+
types$2.transformFunction = TransformFunction.create;
|
|
3213
|
+
class TransformList extends BaseCSSType {
|
|
3214
|
+
syntax = '<transform-list>';
|
|
3215
|
+
static create(value) {
|
|
3216
|
+
return new TransformList(value);
|
|
3217
|
+
}
|
|
3218
|
+
}
|
|
3219
|
+
types$2.TransformList = TransformList;
|
|
3220
|
+
types$2.transformList = TransformList.create;
|
|
3221
|
+
const convertNumberToStringUsing = (transformNumber, defaultStr) => value => {
|
|
3222
|
+
if (typeof value === 'number') {
|
|
3223
|
+
return transformNumber(value);
|
|
3224
|
+
}
|
|
3225
|
+
if (typeof value === 'string') {
|
|
3226
|
+
return value;
|
|
3227
|
+
}
|
|
3228
|
+
if (typeof value === 'object') {
|
|
3229
|
+
const val = value;
|
|
3230
|
+
const result = {};
|
|
3231
|
+
for (const key of Object.keys(val)) {
|
|
3232
|
+
result[key] = convertNumberToStringUsing(transformNumber)(val[key]);
|
|
3233
|
+
}
|
|
3234
|
+
return result;
|
|
3235
|
+
}
|
|
3236
|
+
return value;
|
|
3237
|
+
};
|
|
3238
|
+
const convertNumberToBareString = convertNumberToStringUsing(value => String(value));
|
|
3239
|
+
const convertNumberToLength = convertNumberToStringUsing(value => value === 0 ? '0' : `${value}px`);
|
|
3240
|
+
const convertNumberToPercentage = convertNumberToStringUsing(value => value === 0 ? '0' : `${value * 100}%`);
|
|
3241
|
+
|
|
2990
3242
|
Object.defineProperty(stylexDefineVars$1, "__esModule", {
|
|
2991
3243
|
value: true
|
|
2992
3244
|
});
|
|
@@ -2994,6 +3246,8 @@ stylexDefineVars$1.default = styleXDefineVars;
|
|
|
2994
3246
|
var _hash$3 = _interopRequireDefault$3(hash$1);
|
|
2995
3247
|
var _objectUtils$1 = objectUtils;
|
|
2996
3248
|
var _defaultOptions$2 = defaultOptions;
|
|
3249
|
+
var _stylexVarsUtils$1 = stylexVarsUtils;
|
|
3250
|
+
var _types$2 = types$2;
|
|
2997
3251
|
function _interopRequireDefault$3(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2998
3252
|
function styleXDefineVars(variables, options) {
|
|
2999
3253
|
const {
|
|
@@ -3004,8 +3258,20 @@ function styleXDefineVars(variables, options) {
|
|
|
3004
3258
|
...options
|
|
3005
3259
|
};
|
|
3006
3260
|
const themeNameHash = classNamePrefix + (0, _hash$3.default)(themeName);
|
|
3261
|
+
const typedVariables = {};
|
|
3007
3262
|
const variablesMap = (0, _objectUtils$1.objMap)(variables, (value, key) => {
|
|
3008
3263
|
const nameHash = classNamePrefix + (0, _hash$3.default)(`${themeName}.${key}`);
|
|
3264
|
+
if ((0, _types$2.isCSSType)(value)) {
|
|
3265
|
+
const v = value;
|
|
3266
|
+
typedVariables[nameHash] = {
|
|
3267
|
+
initialValue: (0, _stylexVarsUtils$1.getDefaultValue)(v.value),
|
|
3268
|
+
syntax: v.syntax
|
|
3269
|
+
};
|
|
3270
|
+
return {
|
|
3271
|
+
nameHash,
|
|
3272
|
+
value: v.value
|
|
3273
|
+
};
|
|
3274
|
+
}
|
|
3009
3275
|
return {
|
|
3010
3276
|
nameHash,
|
|
3011
3277
|
value
|
|
@@ -3018,42 +3284,47 @@ function styleXDefineVars(variables, options) {
|
|
|
3018
3284
|
return `var(--${nameHash})`;
|
|
3019
3285
|
});
|
|
3020
3286
|
const injectableStyles = constructCssVariablesString(variablesMap, themeNameHash);
|
|
3287
|
+
const injectableTypes = (0, _objectUtils$1.objMap)(typedVariables, (_ref2, nameHash) => {
|
|
3288
|
+
let {
|
|
3289
|
+
initialValue: iv,
|
|
3290
|
+
syntax
|
|
3291
|
+
} = _ref2;
|
|
3292
|
+
return {
|
|
3293
|
+
ltr: `@property --${nameHash} { syntax: "${syntax}"; inherits: true;${iv != null ? ` initial-value: ${iv}` : ''} }`,
|
|
3294
|
+
rtl: null,
|
|
3295
|
+
priority: 0
|
|
3296
|
+
};
|
|
3297
|
+
});
|
|
3021
3298
|
return [{
|
|
3022
3299
|
...themeVariablesObject,
|
|
3023
3300
|
__themeName__: themeNameHash
|
|
3024
|
-
},
|
|
3301
|
+
}, {
|
|
3302
|
+
...injectableTypes,
|
|
3303
|
+
...injectableStyles
|
|
3304
|
+
}];
|
|
3025
3305
|
}
|
|
3026
3306
|
function constructCssVariablesString(variables, themeNameHash) {
|
|
3027
|
-
const
|
|
3307
|
+
const rulesByAtRule = {};
|
|
3028
3308
|
for (const [key, {
|
|
3029
3309
|
nameHash,
|
|
3030
3310
|
value
|
|
3031
|
-
}] of
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
const v = value;
|
|
3037
|
-
for (const [key, value] of (0, _objectUtils$1.objEntries)(v)) {
|
|
3038
|
-
ruleByAtRule[key] ??= [];
|
|
3039
|
-
ruleByAtRule[key].push(`--${nameHash}:${value};`);
|
|
3040
|
-
}
|
|
3041
|
-
} else {
|
|
3042
|
-
ruleByAtRule.default ??= [];
|
|
3043
|
-
ruleByAtRule.default.push(`--${nameHash}:${value};`);
|
|
3044
|
-
}
|
|
3311
|
+
}] of Object.entries(variables)) {
|
|
3312
|
+
(0, _stylexVarsUtils$1.collectVarsByAtRule)(key, {
|
|
3313
|
+
nameHash,
|
|
3314
|
+
value
|
|
3315
|
+
}, rulesByAtRule);
|
|
3045
3316
|
}
|
|
3046
3317
|
const result = {};
|
|
3047
|
-
for (const [
|
|
3048
|
-
const suffix =
|
|
3318
|
+
for (const [atRule, value] of Object.entries(rulesByAtRule)) {
|
|
3319
|
+
const suffix = atRule === 'default' ? '' : `-${(0, _hash$3.default)(atRule)}`;
|
|
3049
3320
|
let ltr = `:root{${value.join('')}}`;
|
|
3050
|
-
if (
|
|
3051
|
-
ltr =
|
|
3321
|
+
if (atRule !== 'default') {
|
|
3322
|
+
ltr = (0, _stylexVarsUtils$1.wrapWithAtRules)(ltr, atRule);
|
|
3052
3323
|
}
|
|
3053
3324
|
result[themeNameHash + suffix] = {
|
|
3054
3325
|
ltr,
|
|
3055
3326
|
rtl: null,
|
|
3056
|
-
priority:
|
|
3327
|
+
priority: (0, _stylexVarsUtils$1.priorityForAtRule)(atRule) * 0.1
|
|
3057
3328
|
};
|
|
3058
3329
|
}
|
|
3059
3330
|
return result;
|
|
@@ -3066,6 +3337,8 @@ Object.defineProperty(stylexCreateTheme$1, "__esModule", {
|
|
|
3066
3337
|
});
|
|
3067
3338
|
stylexCreateTheme$1.default = styleXCreateTheme;
|
|
3068
3339
|
var _hash$2 = _interopRequireDefault$2(hash$1);
|
|
3340
|
+
var _stylexVarsUtils = stylexVarsUtils;
|
|
3341
|
+
var _types$1 = types$2;
|
|
3069
3342
|
var _defaultOptions$1 = defaultOptions;
|
|
3070
3343
|
function _interopRequireDefault$2(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
3071
3344
|
function styleXCreateTheme(themeVars, variables, options) {
|
|
@@ -3078,48 +3351,36 @@ function styleXCreateTheme(themeVars, variables, options) {
|
|
|
3078
3351
|
..._defaultOptions$1.defaultOptions,
|
|
3079
3352
|
...options
|
|
3080
3353
|
};
|
|
3354
|
+
const rulesByAtRule = {};
|
|
3081
3355
|
const sortedKeys = Object.keys(variables).sort();
|
|
3082
|
-
const
|
|
3083
|
-
|
|
3084
|
-
const
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
if (atRules[key] == null) {
|
|
3095
|
-
atRules[key] = [definedVarStringForAtRule];
|
|
3096
|
-
} else {
|
|
3097
|
-
atRules[key].push(definedVarStringForAtRule);
|
|
3098
|
-
}
|
|
3099
|
-
}
|
|
3100
|
-
});
|
|
3101
|
-
return definedVarString;
|
|
3102
|
-
}
|
|
3103
|
-
return varNameHash != null && typeof value !== 'object' ? `${varNameHash}:${value};` : '';
|
|
3104
|
-
}).join('');
|
|
3105
|
-
const sortedAtRules = Object.keys(atRules).sort();
|
|
3106
|
-
const atRulesStringForHash = sortedAtRules.map(atRule => {
|
|
3107
|
-
return `${atRule}{${atRules[atRule].sort().join('')}}`;
|
|
3108
|
-
}).join('');
|
|
3109
|
-
const overrideClassName = classNamePrefix + (0, _hash$2.default)(cssVariablesOverrideString + atRulesStringForHash);
|
|
3110
|
-
const stylesToInject = {
|
|
3111
|
-
[overrideClassName]: {
|
|
3112
|
-
ltr: `.${overrideClassName}{${cssVariablesOverrideString}}`,
|
|
3113
|
-
priority: 0.8,
|
|
3114
|
-
rtl: undefined
|
|
3115
|
-
}
|
|
3116
|
-
};
|
|
3356
|
+
for (const key of sortedKeys) {
|
|
3357
|
+
const value = (0, _types$1.isCSSType)(variables[key]) ? variables[key].value : variables[key];
|
|
3358
|
+
const nameHash = themeVars[key].slice(6, -1);
|
|
3359
|
+
(0, _stylexVarsUtils.collectVarsByAtRule)(key, {
|
|
3360
|
+
nameHash,
|
|
3361
|
+
value
|
|
3362
|
+
}, rulesByAtRule);
|
|
3363
|
+
}
|
|
3364
|
+
const sortedAtRules = Object.keys(rulesByAtRule).sort((a, b) => a === 'default' ? -1 : b === 'default' ? 1 : a.localeCompare(b));
|
|
3365
|
+
const atRulesStringForHash = sortedAtRules.map(atRule => (0, _stylexVarsUtils.wrapWithAtRules)(rulesByAtRule[atRule].join(''), atRule)).join('');
|
|
3366
|
+
const overrideClassName = classNamePrefix + (0, _hash$2.default)(atRulesStringForHash);
|
|
3367
|
+
const stylesToInject = {};
|
|
3117
3368
|
for (const atRule of sortedAtRules) {
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3369
|
+
const decls = rulesByAtRule[atRule].join('');
|
|
3370
|
+
const rule = `.${overrideClassName}{${decls}}`;
|
|
3371
|
+
if (atRule === 'default') {
|
|
3372
|
+
stylesToInject[overrideClassName] = {
|
|
3373
|
+
ltr: rule,
|
|
3374
|
+
priority: 0.5,
|
|
3375
|
+
rtl: null
|
|
3376
|
+
};
|
|
3377
|
+
} else {
|
|
3378
|
+
stylesToInject[overrideClassName + '-' + (0, _hash$2.default)(atRule)] = {
|
|
3379
|
+
ltr: (0, _stylexVarsUtils.wrapWithAtRules)(rule, atRule),
|
|
3380
|
+
priority: 0.5 + 0.1 * (0, _stylexVarsUtils.priorityForAtRule)(atRule),
|
|
3381
|
+
rtl: null
|
|
3382
|
+
};
|
|
3383
|
+
}
|
|
3123
3384
|
}
|
|
3124
3385
|
return [{
|
|
3125
3386
|
$$css: true,
|
|
@@ -3211,198 +3472,6 @@ function genFileBasedIdentifier(_ref) {
|
|
|
3211
3472
|
return `${fileName}//${exportName}${key != null ? `.${key}` : ''}`;
|
|
3212
3473
|
}
|
|
3213
3474
|
|
|
3214
|
-
var types$1 = {};
|
|
3215
|
-
|
|
3216
|
-
Object.defineProperty(types$1, "__esModule", {
|
|
3217
|
-
value: true
|
|
3218
|
-
});
|
|
3219
|
-
types$1.url = types$1.transformList = types$1.transformFunction = types$1.time = types$1.resolution = types$1.percentage = types$1.number = types$1.lengthPercentage = types$1.length = types$1.integer = types$1.image = types$1.color = types$1.angle = types$1.Url = types$1.TransformList = types$1.TransformFunction = types$1.Time = types$1.Resolution = types$1.Percentage = types$1.Num = types$1.LengthPercentage = types$1.Length = types$1.Integer = types$1.Image = types$1.Color = types$1.CSSType = types$1.Angle = void 0;
|
|
3220
|
-
class CSSType {}
|
|
3221
|
-
types$1.CSSType = CSSType;
|
|
3222
|
-
class Angle extends CSSType {
|
|
3223
|
-
syntax = '<angle>';
|
|
3224
|
-
static syntax = '<angle>';
|
|
3225
|
-
constructor(value) {
|
|
3226
|
-
super();
|
|
3227
|
-
this.value = value;
|
|
3228
|
-
}
|
|
3229
|
-
static create(value) {
|
|
3230
|
-
return new Angle(value);
|
|
3231
|
-
}
|
|
3232
|
-
}
|
|
3233
|
-
types$1.Angle = Angle;
|
|
3234
|
-
types$1.angle = Angle.create;
|
|
3235
|
-
class Color extends CSSType {
|
|
3236
|
-
syntax = '<color>';
|
|
3237
|
-
constructor(value) {
|
|
3238
|
-
super();
|
|
3239
|
-
this.value = value;
|
|
3240
|
-
}
|
|
3241
|
-
static create(value) {
|
|
3242
|
-
return new Color(value);
|
|
3243
|
-
}
|
|
3244
|
-
}
|
|
3245
|
-
types$1.Color = Color;
|
|
3246
|
-
types$1.color = Color.create;
|
|
3247
|
-
class Url extends CSSType {
|
|
3248
|
-
syntax = '<url>';
|
|
3249
|
-
constructor(value) {
|
|
3250
|
-
super();
|
|
3251
|
-
this.value = value;
|
|
3252
|
-
}
|
|
3253
|
-
static create(value) {
|
|
3254
|
-
return new Url(value);
|
|
3255
|
-
}
|
|
3256
|
-
}
|
|
3257
|
-
types$1.Url = Url;
|
|
3258
|
-
types$1.url = Url.create;
|
|
3259
|
-
class Image extends Url {
|
|
3260
|
-
syntax = '<image>';
|
|
3261
|
-
constructor(value) {
|
|
3262
|
-
super(value);
|
|
3263
|
-
this.value = value;
|
|
3264
|
-
}
|
|
3265
|
-
static create(value) {
|
|
3266
|
-
return new Image(value);
|
|
3267
|
-
}
|
|
3268
|
-
}
|
|
3269
|
-
types$1.Image = Image;
|
|
3270
|
-
types$1.image = Image.create;
|
|
3271
|
-
class Integer extends CSSType {
|
|
3272
|
-
syntax = '<integer>';
|
|
3273
|
-
constructor(value) {
|
|
3274
|
-
super();
|
|
3275
|
-
this.value = value;
|
|
3276
|
-
}
|
|
3277
|
-
static create(value) {
|
|
3278
|
-
return new Integer(value);
|
|
3279
|
-
}
|
|
3280
|
-
}
|
|
3281
|
-
types$1.Integer = Integer;
|
|
3282
|
-
types$1.integer = Integer.create;
|
|
3283
|
-
class LengthPercentage extends CSSType {
|
|
3284
|
-
syntax = '<length-percentage>';
|
|
3285
|
-
constructor(value) {
|
|
3286
|
-
super();
|
|
3287
|
-
this.value = value;
|
|
3288
|
-
}
|
|
3289
|
-
static createLength(value) {
|
|
3290
|
-
return new LengthPercentage(convertNumberToLength(value));
|
|
3291
|
-
}
|
|
3292
|
-
static createPercentage(value) {
|
|
3293
|
-
return new LengthPercentage(convertNumberToPercentage(value));
|
|
3294
|
-
}
|
|
3295
|
-
}
|
|
3296
|
-
types$1.LengthPercentage = LengthPercentage;
|
|
3297
|
-
types$1.lengthPercentage = LengthPercentage.createLength;
|
|
3298
|
-
class Length extends LengthPercentage {
|
|
3299
|
-
syntax = '<length>';
|
|
3300
|
-
constructor(value) {
|
|
3301
|
-
super(convertNumberToLength(value));
|
|
3302
|
-
}
|
|
3303
|
-
static create(value) {
|
|
3304
|
-
return new Length(value);
|
|
3305
|
-
}
|
|
3306
|
-
}
|
|
3307
|
-
types$1.Length = Length;
|
|
3308
|
-
types$1.length = Length.create;
|
|
3309
|
-
class Percentage extends LengthPercentage {
|
|
3310
|
-
syntax = '<percentage>';
|
|
3311
|
-
constructor(value) {
|
|
3312
|
-
super(convertNumberToPercentage(value));
|
|
3313
|
-
}
|
|
3314
|
-
static create(value) {
|
|
3315
|
-
return new Percentage(value);
|
|
3316
|
-
}
|
|
3317
|
-
}
|
|
3318
|
-
types$1.Percentage = Percentage;
|
|
3319
|
-
types$1.percentage = Percentage.create;
|
|
3320
|
-
class Num extends CSSType {
|
|
3321
|
-
syntax = '<number>';
|
|
3322
|
-
constructor(value) {
|
|
3323
|
-
super();
|
|
3324
|
-
this.value = value;
|
|
3325
|
-
}
|
|
3326
|
-
static create(value) {
|
|
3327
|
-
return new Num(value);
|
|
3328
|
-
}
|
|
3329
|
-
}
|
|
3330
|
-
types$1.Num = Num;
|
|
3331
|
-
types$1.number = Num.create;
|
|
3332
|
-
class Resolution extends CSSType {
|
|
3333
|
-
syntax = '<resolution>';
|
|
3334
|
-
constructor(value) {
|
|
3335
|
-
super();
|
|
3336
|
-
this.value = value;
|
|
3337
|
-
}
|
|
3338
|
-
static create(value) {
|
|
3339
|
-
return new Resolution(value);
|
|
3340
|
-
}
|
|
3341
|
-
}
|
|
3342
|
-
types$1.Resolution = Resolution;
|
|
3343
|
-
types$1.resolution = Resolution.create;
|
|
3344
|
-
class Time extends CSSType {
|
|
3345
|
-
syntax = '<time>';
|
|
3346
|
-
constructor(value) {
|
|
3347
|
-
super();
|
|
3348
|
-
this.value = value;
|
|
3349
|
-
}
|
|
3350
|
-
static create(value) {
|
|
3351
|
-
return new Time(value);
|
|
3352
|
-
}
|
|
3353
|
-
}
|
|
3354
|
-
types$1.Time = Time;
|
|
3355
|
-
types$1.time = Time.create;
|
|
3356
|
-
class TransformFunction extends CSSType {
|
|
3357
|
-
syntax = '<transform-function>';
|
|
3358
|
-
constructor(value) {
|
|
3359
|
-
super();
|
|
3360
|
-
this.value = value;
|
|
3361
|
-
}
|
|
3362
|
-
static create(value) {
|
|
3363
|
-
return new TransformFunction(value);
|
|
3364
|
-
}
|
|
3365
|
-
}
|
|
3366
|
-
types$1.TransformFunction = TransformFunction;
|
|
3367
|
-
types$1.transformFunction = TransformFunction.create;
|
|
3368
|
-
class TransformList extends CSSType {
|
|
3369
|
-
syntax = '<transform-list>';
|
|
3370
|
-
constructor(value) {
|
|
3371
|
-
super();
|
|
3372
|
-
this.value = value;
|
|
3373
|
-
}
|
|
3374
|
-
static create(value) {
|
|
3375
|
-
return new TransformList(value);
|
|
3376
|
-
}
|
|
3377
|
-
}
|
|
3378
|
-
types$1.TransformList = TransformList;
|
|
3379
|
-
types$1.transformList = TransformList.create;
|
|
3380
|
-
const convertNumberToStringUsing = (transformNumber, defaultStr) => value => {
|
|
3381
|
-
if (typeof value === 'number') {
|
|
3382
|
-
return transformNumber(value);
|
|
3383
|
-
}
|
|
3384
|
-
if (typeof value === 'string') {
|
|
3385
|
-
return value;
|
|
3386
|
-
}
|
|
3387
|
-
if (typeof value === 'object') {
|
|
3388
|
-
const {
|
|
3389
|
-
default: defaultValue,
|
|
3390
|
-
...rest
|
|
3391
|
-
} = value;
|
|
3392
|
-
const defaultResult = convertNumberToLength(defaultValue);
|
|
3393
|
-
const result = {
|
|
3394
|
-
default: typeof defaultResult === 'string' ? defaultResult : defaultStr
|
|
3395
|
-
};
|
|
3396
|
-
for (const [key, value] of Object.entries(rest)) {
|
|
3397
|
-
result[key] = convertNumberToLength(value);
|
|
3398
|
-
}
|
|
3399
|
-
return result;
|
|
3400
|
-
}
|
|
3401
|
-
return value;
|
|
3402
|
-
};
|
|
3403
|
-
const convertNumberToLength = convertNumberToStringUsing(value => value === 0 ? '0' : `${value}px`, '0px');
|
|
3404
|
-
const convertNumberToPercentage = convertNumberToStringUsing(value => value === 0 ? '0' : `${value * 100}%`, '0');
|
|
3405
|
-
|
|
3406
3475
|
var IncludedStyles_1;
|
|
3407
3476
|
var create_1;
|
|
3408
3477
|
var createTheme_1;
|
|
@@ -3415,7 +3484,7 @@ var messages_1;
|
|
|
3415
3484
|
Object.defineProperty(lib, "__esModule", {
|
|
3416
3485
|
value: true
|
|
3417
3486
|
});
|
|
3418
|
-
var utils_1 = lib.utils = lib.types = messages_1 = lib.messages = keyframes_1 = lib.keyframes = include_1 = lib.include = firstThatWorks_1 = lib.firstThatWorks = defineVars_1 = lib.defineVars = createTheme_1 = lib.createTheme = create_1 = lib.create = lib.PSEUDO_ELEMENT_PRIORITY = lib.PSEUDO_CLASS_PRIORITIES = IncludedStyles_1 = lib.IncludedStyles = lib.AT_RULE_PRIORITIES = void 0;
|
|
3487
|
+
var utils_1 = lib.utils = types$1 = lib.types = messages_1 = lib.messages = keyframes_1 = lib.keyframes = include_1 = lib.include = firstThatWorks_1 = lib.firstThatWorks = defineVars_1 = lib.defineVars = createTheme_1 = lib.createTheme = create_1 = lib.create = lib.PSEUDO_ELEMENT_PRIORITY = lib.PSEUDO_CLASS_PRIORITIES = IncludedStyles_1 = lib.IncludedStyles = lib.AT_RULE_PRIORITIES = void 0;
|
|
3419
3488
|
var _stylexCreate = _interopRequireDefault(stylexCreate$1);
|
|
3420
3489
|
var _stylexDefineVars = _interopRequireDefault(stylexDefineVars$1);
|
|
3421
3490
|
var _stylexCreateTheme = _interopRequireDefault(stylexCreateTheme$1);
|
|
@@ -3424,9 +3493,9 @@ var _stylexInclude = _interopRequireWildcard(stylexInclude$2);
|
|
|
3424
3493
|
var _stylexFirstThatWorks = _interopRequireDefault(stylexFirstThatWorks$1);
|
|
3425
3494
|
var _hash = _interopRequireDefault(hash$1);
|
|
3426
3495
|
var _fileBasedIdentifier = _interopRequireDefault(fileBasedIdentifier);
|
|
3427
|
-
var m = _interopRequireWildcard(messages$
|
|
3428
|
-
var _types = _interopRequireWildcard(types$
|
|
3429
|
-
lib.types = _types;
|
|
3496
|
+
var m = _interopRequireWildcard(messages$4);
|
|
3497
|
+
var _types = _interopRequireWildcard(types$2);
|
|
3498
|
+
var types$1 = lib.types = _types;
|
|
3430
3499
|
var _propertyPriorities = propertyPriorities;
|
|
3431
3500
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
3432
3501
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -3481,6 +3550,12 @@ function convertObjectToAST(obj) {
|
|
|
3481
3550
|
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 === 'number' ? t__namespace.numericLiteral(value) : typeof value === 'boolean' ? t__namespace.booleanLiteral(value) : value === null ? t__namespace.nullLiteral() : convertObjectToAST(value));
|
|
3482
3551
|
}));
|
|
3483
3552
|
}
|
|
3553
|
+
function removeObjectsWithSpreads(obj) {
|
|
3554
|
+
return Object.fromEntries(Object.entries(obj).filter(_ref2 => {
|
|
3555
|
+
let [_key, value] = _ref2;
|
|
3556
|
+
return Object.values(value).every(val => !(val instanceof IncludedStyles_1));
|
|
3557
|
+
}).filter(Boolean));
|
|
3558
|
+
}
|
|
3484
3559
|
function canBeIdentifier(str) {
|
|
3485
3560
|
return str.match(/^[a-zA-Z_$][a-zA-Z0-9_$]*$/) != null;
|
|
3486
3561
|
}
|
|
@@ -3582,6 +3657,10 @@ function evaluateCached(path, state) {
|
|
|
3582
3657
|
resolved: false
|
|
3583
3658
|
};
|
|
3584
3659
|
seen.set(node, item);
|
|
3660
|
+
if (node == null) {
|
|
3661
|
+
deopt(path, state);
|
|
3662
|
+
return;
|
|
3663
|
+
}
|
|
3585
3664
|
const val = _evaluate(path, state);
|
|
3586
3665
|
if (state.confident) {
|
|
3587
3666
|
item.resolved = true;
|
|
@@ -3937,14 +4016,16 @@ function _evaluate(path, state) {
|
|
|
3937
4016
|
const val = object.node.value;
|
|
3938
4017
|
func = val[property.node.name];
|
|
3939
4018
|
}
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
4019
|
+
if (func == null) {
|
|
4020
|
+
const parsedObj = evaluate(object, state.traversalState, state.functions);
|
|
4021
|
+
if (parsedObj.confident && isIdentifier(property)) {
|
|
4022
|
+
func = parsedObj.value[property.node.name];
|
|
4023
|
+
context = parsedObj.value;
|
|
4024
|
+
}
|
|
4025
|
+
if (parsedObj.confident && isStringLiteral(property)) {
|
|
4026
|
+
func = parsedObj.value[property.node.value];
|
|
4027
|
+
context = parsedObj.value;
|
|
4028
|
+
}
|
|
3948
4029
|
}
|
|
3949
4030
|
}
|
|
3950
4031
|
if (func) {
|
|
@@ -4257,7 +4338,8 @@ function transformStyleXCreate(path, state) {
|
|
|
4257
4338
|
};
|
|
4258
4339
|
}
|
|
4259
4340
|
if (varName != null) {
|
|
4260
|
-
|
|
4341
|
+
const stylesToRemember = removeObjectsWithSpreads(compiledStyles);
|
|
4342
|
+
state.styleMap.set(varName, stylesToRemember);
|
|
4261
4343
|
state.styleVars.set(varName, path.parentPath);
|
|
4262
4344
|
}
|
|
4263
4345
|
const resultAst = convertObjectToAST(compiledStyles);
|
|
@@ -4279,41 +4361,18 @@ function transformStyleXCreate(path, state) {
|
|
|
4279
4361
|
return prop;
|
|
4280
4362
|
});
|
|
4281
4363
|
}
|
|
4364
|
+
const listOfStyles = Object.entries(injectedStyles).map(_ref2 => {
|
|
4365
|
+
let [key, {
|
|
4366
|
+
priority,
|
|
4367
|
+
...rest
|
|
4368
|
+
}] = _ref2;
|
|
4369
|
+
return [key, rest, priority];
|
|
4370
|
+
});
|
|
4371
|
+
state.registerStyles(listOfStyles, path);
|
|
4282
4372
|
path.replaceWith(resultAst);
|
|
4283
4373
|
if (Object.keys(injectedStyles).length === 0) {
|
|
4284
4374
|
return;
|
|
4285
4375
|
}
|
|
4286
|
-
const statementPath = path.getStatementParent();
|
|
4287
|
-
if (state.runtimeInjection != null && statementPath != null) {
|
|
4288
|
-
let injectName;
|
|
4289
|
-
if (state.injectImportInserted != null) {
|
|
4290
|
-
injectName = state.injectImportInserted;
|
|
4291
|
-
} else {
|
|
4292
|
-
const {
|
|
4293
|
-
from,
|
|
4294
|
-
as
|
|
4295
|
-
} = state.runtimeInjection;
|
|
4296
|
-
injectName = as != null ? state.addNamedImport(statementPath, as, from, {
|
|
4297
|
-
nameHint: 'inject'
|
|
4298
|
-
}) : state.addDefaultImport(statementPath, from, {
|
|
4299
|
-
nameHint: 'inject'
|
|
4300
|
-
});
|
|
4301
|
-
state.injectImportInserted = injectName;
|
|
4302
|
-
}
|
|
4303
|
-
for (const [_key, {
|
|
4304
|
-
ltr,
|
|
4305
|
-
priority,
|
|
4306
|
-
rtl
|
|
4307
|
-
}] of Object.entries(injectedStyles)) {
|
|
4308
|
-
statementPath.insertBefore(t__namespace.expressionStatement(t__namespace.callExpression(injectName, [t__namespace.stringLiteral(ltr), t__namespace.numericLiteral(priority), ...(rtl != null ? [t__namespace.stringLiteral(rtl)] : [])])));
|
|
4309
|
-
}
|
|
4310
|
-
}
|
|
4311
|
-
for (const [key, {
|
|
4312
|
-
priority,
|
|
4313
|
-
...rest
|
|
4314
|
-
}] of Object.entries(injectedStyles)) {
|
|
4315
|
-
state.addStyle([key, rest, priority]);
|
|
4316
|
-
}
|
|
4317
4376
|
}
|
|
4318
4377
|
state.inStyleXCreate = false;
|
|
4319
4378
|
}
|
|
@@ -4373,6 +4432,9 @@ function transformStyleXDefineVars(callExpressionPath, state) {
|
|
|
4373
4432
|
fn: keyframes
|
|
4374
4433
|
};
|
|
4375
4434
|
});
|
|
4435
|
+
state.stylexTypesImport.forEach(name => {
|
|
4436
|
+
identifiers[name] = types$1;
|
|
4437
|
+
});
|
|
4376
4438
|
state.stylexImport.forEach(name => {
|
|
4377
4439
|
if (memberExpressions[name] === undefined) {
|
|
4378
4440
|
memberExpressions[name] = {};
|
|
@@ -4380,6 +4442,10 @@ function transformStyleXDefineVars(callExpressionPath, state) {
|
|
|
4380
4442
|
memberExpressions[name].keyframes = {
|
|
4381
4443
|
fn: keyframes
|
|
4382
4444
|
};
|
|
4445
|
+
identifiers[name] = {
|
|
4446
|
+
...(identifiers[name] ?? {}),
|
|
4447
|
+
types: types$1
|
|
4448
|
+
};
|
|
4383
4449
|
});
|
|
4384
4450
|
const {
|
|
4385
4451
|
confident,
|
|
@@ -4411,41 +4477,14 @@ function transformStyleXDefineVars(callExpressionPath, state) {
|
|
|
4411
4477
|
...injectedStylesSansKeyframes
|
|
4412
4478
|
};
|
|
4413
4479
|
callExpressionPath.replaceWith(convertObjectToAST(variablesObj));
|
|
4414
|
-
const
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
} else {
|
|
4423
|
-
const {
|
|
4424
|
-
from,
|
|
4425
|
-
as
|
|
4426
|
-
} = state.runtimeInjection;
|
|
4427
|
-
injectName = as != null ? state.addNamedImport(statementPath, as, from, {
|
|
4428
|
-
nameHint: 'inject'
|
|
4429
|
-
}) : state.addDefaultImport(statementPath, from, {
|
|
4430
|
-
nameHint: 'inject'
|
|
4431
|
-
});
|
|
4432
|
-
state.injectImportInserted = injectName;
|
|
4433
|
-
}
|
|
4434
|
-
for (const [_k, {
|
|
4435
|
-
ltr,
|
|
4436
|
-
priority
|
|
4437
|
-
}] of Object.entries(injectedStyles)) {
|
|
4438
|
-
statementPath.insertBefore(t__namespace.expressionStatement(t__namespace.callExpression(injectName, [t__namespace.stringLiteral(ltr), t__namespace.numericLiteral(priority)])));
|
|
4439
|
-
}
|
|
4440
|
-
}
|
|
4441
|
-
for (const [key, {
|
|
4442
|
-
priority,
|
|
4443
|
-
ltr
|
|
4444
|
-
}] of Object.entries(injectedStyles)) {
|
|
4445
|
-
state.addStyle([key, {
|
|
4446
|
-
ltr
|
|
4447
|
-
}, priority]);
|
|
4448
|
-
}
|
|
4480
|
+
const listOfStyles = Object.entries(injectedStyles).map(_ref => {
|
|
4481
|
+
let [key, {
|
|
4482
|
+
priority,
|
|
4483
|
+
...rest
|
|
4484
|
+
}] = _ref;
|
|
4485
|
+
return [key, rest, priority];
|
|
4486
|
+
});
|
|
4487
|
+
state.registerStyles(listOfStyles, variableDeclaratorPath);
|
|
4449
4488
|
}
|
|
4450
4489
|
}
|
|
4451
4490
|
function validateStyleXDefineVars(callExpressionPath) {
|
|
@@ -4473,13 +4512,11 @@ function transformStyleXCreateTheme(callExpressionPath, state) {
|
|
|
4473
4512
|
if (!isVariableDeclarator(variableDeclaratorPath)) {
|
|
4474
4513
|
return;
|
|
4475
4514
|
}
|
|
4476
|
-
const
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
varName = varNamePath.node.name;
|
|
4515
|
+
const id = variableDeclaratorPath.get('id');
|
|
4516
|
+
if (!isIdentifier(id)) {
|
|
4517
|
+
return;
|
|
4480
4518
|
}
|
|
4481
|
-
const
|
|
4482
|
-
const debugName = `${fileName}__${varName}`;
|
|
4519
|
+
const variableName = id.node.name;
|
|
4483
4520
|
const args = callExpressionPath.get('arguments');
|
|
4484
4521
|
const firstArg = args[0];
|
|
4485
4522
|
const secondArg = args[1];
|
|
@@ -4490,10 +4527,41 @@ function transformStyleXCreateTheme(callExpressionPath, state) {
|
|
|
4490
4527
|
if (!confident1) {
|
|
4491
4528
|
throw new Error(messages_1.NON_STATIC_VALUE);
|
|
4492
4529
|
}
|
|
4530
|
+
const injectedKeyframes = {};
|
|
4531
|
+
function keyframes(animation) {
|
|
4532
|
+
const [animationName, injectedStyle] = keyframes_1(animation, state.options);
|
|
4533
|
+
injectedKeyframes[animationName] = injectedStyle;
|
|
4534
|
+
return animationName;
|
|
4535
|
+
}
|
|
4536
|
+
const identifiers = {};
|
|
4537
|
+
const memberExpressions = {};
|
|
4538
|
+
state.stylexKeyframesImport.forEach(name => {
|
|
4539
|
+
identifiers[name] = {
|
|
4540
|
+
fn: keyframes
|
|
4541
|
+
};
|
|
4542
|
+
});
|
|
4543
|
+
state.stylexTypesImport.forEach(name => {
|
|
4544
|
+
identifiers[name] = types$1;
|
|
4545
|
+
});
|
|
4546
|
+
state.stylexImport.forEach(name => {
|
|
4547
|
+
if (memberExpressions[name] === undefined) {
|
|
4548
|
+
memberExpressions[name] = {};
|
|
4549
|
+
}
|
|
4550
|
+
memberExpressions[name].keyframes = {
|
|
4551
|
+
fn: keyframes
|
|
4552
|
+
};
|
|
4553
|
+
identifiers[name] = {
|
|
4554
|
+
...(identifiers[name] ?? {}),
|
|
4555
|
+
types: types$1
|
|
4556
|
+
};
|
|
4557
|
+
});
|
|
4493
4558
|
const {
|
|
4494
4559
|
confident: confident2,
|
|
4495
4560
|
value: overrides
|
|
4496
|
-
} = evaluate(secondArg, state
|
|
4561
|
+
} = evaluate(secondArg, state, {
|
|
4562
|
+
identifiers,
|
|
4563
|
+
memberExpressions
|
|
4564
|
+
});
|
|
4497
4565
|
if (!confident2) {
|
|
4498
4566
|
throw new Error(messages_1.NON_STATIC_VALUE);
|
|
4499
4567
|
}
|
|
@@ -4504,48 +4572,35 @@ function transformStyleXCreateTheme(callExpressionPath, state) {
|
|
|
4504
4572
|
throw new Error('Can only override variables theme created with stylex.defineVars().');
|
|
4505
4573
|
}
|
|
4506
4574
|
let [overridesObj, injectedStyles] = createTheme_1(variables, overrides, state.options);
|
|
4507
|
-
if (state.
|
|
4575
|
+
if (state.isTest) {
|
|
4576
|
+
const fileName = state.filename ?? 'UnknownFile';
|
|
4577
|
+
const basename = path.basename(fileName).split('.')[0];
|
|
4578
|
+
const devClassName = `${basename}__${variableName}`;
|
|
4508
4579
|
overridesObj = {
|
|
4509
|
-
|
|
4510
|
-
|
|
4580
|
+
[devClassName]: devClassName,
|
|
4581
|
+
$$css: true
|
|
4582
|
+
};
|
|
4583
|
+
} else if (state.isDev) {
|
|
4584
|
+
const fileName = state.filename ?? 'UnknownFile';
|
|
4585
|
+
const basename = path.basename(fileName).split('.')[0];
|
|
4586
|
+
const devClassName = `${basename}__${variableName}`;
|
|
4587
|
+
overridesObj = {
|
|
4588
|
+
[devClassName]: devClassName,
|
|
4589
|
+
...overridesObj
|
|
4511
4590
|
};
|
|
4512
4591
|
}
|
|
4513
4592
|
callExpressionPath.replaceWith(convertObjectToAST(overridesObj));
|
|
4514
|
-
const
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
}
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
as
|
|
4526
|
-
} = state.runtimeInjection;
|
|
4527
|
-
injectName = as != null ? state.addNamedImport(statementPath, as, from, {
|
|
4528
|
-
nameHint: 'inject'
|
|
4529
|
-
}) : state.addDefaultImport(statementPath, from, {
|
|
4530
|
-
nameHint: 'inject'
|
|
4531
|
-
});
|
|
4532
|
-
state.injectImportInserted = injectName;
|
|
4533
|
-
}
|
|
4534
|
-
for (const [_k, {
|
|
4535
|
-
ltr,
|
|
4536
|
-
priority
|
|
4537
|
-
}] of Object.entries(injectedStyles)) {
|
|
4538
|
-
statementPath.insertBefore(t__namespace.expressionStatement(t__namespace.callExpression(injectName, [t__namespace.stringLiteral(ltr), t__namespace.numericLiteral(priority)])));
|
|
4539
|
-
}
|
|
4540
|
-
}
|
|
4541
|
-
for (const [key, {
|
|
4542
|
-
priority,
|
|
4543
|
-
ltr
|
|
4544
|
-
}] of Object.entries(injectedStyles)) {
|
|
4545
|
-
state.addStyle([key, {
|
|
4546
|
-
ltr
|
|
4547
|
-
}, priority]);
|
|
4548
|
-
}
|
|
4593
|
+
const listOfStyles = Object.entries({
|
|
4594
|
+
...injectedKeyframes,
|
|
4595
|
+
...injectedStyles
|
|
4596
|
+
}).map(_ref => {
|
|
4597
|
+
let [key, {
|
|
4598
|
+
priority,
|
|
4599
|
+
...rest
|
|
4600
|
+
}] = _ref;
|
|
4601
|
+
return [key, rest, priority];
|
|
4602
|
+
});
|
|
4603
|
+
state.registerStyles(listOfStyles, variableDeclaratorPath);
|
|
4549
4604
|
}
|
|
4550
4605
|
}
|
|
4551
4606
|
function validateStyleXCreateTheme(callExpressionPath) {
|
|
@@ -4609,36 +4664,16 @@ function transformStyleXKeyframes(path, state) {
|
|
|
4609
4664
|
}
|
|
4610
4665
|
const plainObject = value;
|
|
4611
4666
|
assertValidKeyframes(plainObject);
|
|
4612
|
-
const [animationName,
|
|
4613
|
-
init.replaceWith(t__namespace.stringLiteral(animationName));
|
|
4614
|
-
const {
|
|
4667
|
+
const [animationName, {
|
|
4615
4668
|
ltr,
|
|
4616
4669
|
priority,
|
|
4617
4670
|
rtl
|
|
4618
|
-
} =
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
let injectName;
|
|
4622
|
-
if (state.injectImportInserted != null) {
|
|
4623
|
-
injectName = state.injectImportInserted;
|
|
4624
|
-
} else {
|
|
4625
|
-
const {
|
|
4626
|
-
from,
|
|
4627
|
-
as
|
|
4628
|
-
} = state.runtimeInjection;
|
|
4629
|
-
injectName = as != null ? state.addNamedImport(statementPath, as, from, {
|
|
4630
|
-
nameHint: 'inject'
|
|
4631
|
-
}) : state.addDefaultImport(statementPath, from, {
|
|
4632
|
-
nameHint: 'inject'
|
|
4633
|
-
});
|
|
4634
|
-
state.injectImportInserted = injectName;
|
|
4635
|
-
}
|
|
4636
|
-
statementPath.insertBefore(t__namespace.expressionStatement(t__namespace.callExpression(injectName, [t__namespace.stringLiteral(ltr), t__namespace.numericLiteral(priority), ...(rtl != null ? [t__namespace.stringLiteral(rtl)] : [])])));
|
|
4637
|
-
}
|
|
4638
|
-
state.addStyle([animationName, {
|
|
4671
|
+
}] = keyframes_1(plainObject, state.options);
|
|
4672
|
+
init.replaceWith(t__namespace.stringLiteral(animationName));
|
|
4673
|
+
state.registerStyles([[animationName, {
|
|
4639
4674
|
ltr,
|
|
4640
4675
|
rtl
|
|
4641
|
-
}, priority]);
|
|
4676
|
+
}, priority]], path);
|
|
4642
4677
|
}
|
|
4643
4678
|
}
|
|
4644
4679
|
function assertValidKeyframes(obj) {
|
|
@@ -5082,7 +5117,7 @@ function transformStyleXMerge(path, state) {
|
|
|
5082
5117
|
confident,
|
|
5083
5118
|
value: styleValue
|
|
5084
5119
|
} = evaluate(path, state);
|
|
5085
|
-
if (!confident) {
|
|
5120
|
+
if (!confident || styleValue == null) {
|
|
5086
5121
|
nonNullProps = true;
|
|
5087
5122
|
styleNonNullProps = true;
|
|
5088
5123
|
} else {
|
|
@@ -5304,7 +5339,7 @@ function transformStylexProps(path, state) {
|
|
|
5304
5339
|
confident,
|
|
5305
5340
|
value: styleValue
|
|
5306
5341
|
} = evaluate(path, state);
|
|
5307
|
-
if (!confident) {
|
|
5342
|
+
if (!confident || styleValue == null) {
|
|
5308
5343
|
nonNullProps = true;
|
|
5309
5344
|
styleNonNullProps = true;
|
|
5310
5345
|
} else {
|
|
@@ -5539,7 +5574,7 @@ function transformStylexAttrs(path, state) {
|
|
|
5539
5574
|
confident,
|
|
5540
5575
|
value: styleValue
|
|
5541
5576
|
} = evaluate(path, state);
|
|
5542
|
-
if (!confident) {
|
|
5577
|
+
if (!confident || styleValue == null) {
|
|
5543
5578
|
nonNullProps = true;
|
|
5544
5579
|
styleNonNullProps = true;
|
|
5545
5580
|
} else {
|