@stylexjs/babel-plugin 0.2.0-beta.18 → 0.2.0-beta.20

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.
@@ -10,8 +10,6 @@
10
10
  import type { NodePath } from '@babel/traverse';
11
11
  import * as t from '@babel/types';
12
12
 
13
- type object = { [key: string]: unknown };
14
-
15
13
  export declare function isAnyTypeAnnotation(
16
14
  path: NodePath,
17
15
  props?: object | null,
package/lib/index.js CHANGED
@@ -38,6 +38,7 @@ class StateManager {
38
38
  stylexKeyframesImport = new Set();
39
39
  stylexCreateVarsImport = new Set();
40
40
  stylexOverrideVarsImport = new Set();
41
+ stylexTypesImport = new Set();
41
42
  styleMap = new Map();
42
43
  styleVars = new Map();
43
44
  styleVarsToKeep = new Set();
@@ -113,8 +114,8 @@ class StateManager {
113
114
  if (!matchesFileSuffix(themeFileExtension)(importPath)) {
114
115
  return false;
115
116
  }
116
- const resolvedFilePath = filePathResolver(importPath, rootDir);
117
- return resolvedFilePath ? ["themeNameRef", resolvedFilePath] : false;
117
+ const resolvedFilePath = filePathResolver(importPath, sourceFilePath);
118
+ return resolvedFilePath ? ["themeNameRef", path.relative(rootDir, resolvedFilePath)] : false;
118
119
  }
119
120
  case "haste":
120
121
  {
@@ -145,16 +146,27 @@ class StateManager {
145
146
  }
146
147
  }
147
148
  const filePathResolver = (relativeFilePath, sourceFilePath) => {
148
- const fileToLookFor = addFileExtension(relativeFilePath, sourceFilePath);
149
- try {
150
- const resolvedFilePath = require.resolve(fileToLookFor, {
151
- paths: [path.dirname(sourceFilePath)]
152
- });
153
- return resolvedFilePath;
154
- } catch {}
149
+ const fileToLookFor = relativeFilePath;
150
+ if (EXTENSIONS.some(ext => fileToLookFor.endsWith(ext))) {
151
+ try {
152
+ const resolvedFilePath = require.resolve(fileToLookFor, {
153
+ paths: [path.dirname(sourceFilePath)]
154
+ });
155
+ return resolvedFilePath;
156
+ } catch {}
157
+ }
158
+ for (const ext of EXTENSIONS) {
159
+ try {
160
+ const resolvedFilePath = require.resolve(fileToLookFor + ext, {
161
+ paths: [path.dirname(sourceFilePath)]
162
+ });
163
+ return resolvedFilePath;
164
+ } catch {}
165
+ }
155
166
  };
167
+ const EXTENSIONS = [".js", ".ts", ".tsx", ".jsx", ".mjs", ".cjs"];
156
168
  const addFileExtension = (importedFilePath, sourceFile) => {
157
- if (importedFilePath.endsWith(".js") || importedFilePath.endsWith(".ts") || importedFilePath.endsWith(".tsx") || importedFilePath.endsWith(".jsx") || importedFilePath.endsWith(".mjs") || importedFilePath.endsWith(".cjs")) {
169
+ if (EXTENSIONS.some(ext => importedFilePath.endsWith(ext))) {
158
170
  return importedFilePath;
159
171
  }
160
172
  const fileExtension = path.extname(sourceFile);
@@ -197,6 +209,9 @@ function readImportDeclarations(path, state) {
197
209
  if (specifier.imported.name === "unstable_overrideVars") {
198
210
  state.stylexCreateVarsImport.add(specifier.local.name);
199
211
  }
212
+ if (specifier.imported.name === "types") {
213
+ state.stylexTypesImport.add(specifier.local.name);
214
+ }
200
215
  }
201
216
  if (specifier.imported.type === "StringLiteral") {
202
217
  if (specifier.imported.value === "create") {
@@ -217,6 +232,9 @@ function readImportDeclarations(path, state) {
217
232
  if (specifier.imported.value === "unstable_overrideVars ") {
218
233
  state.stylexCreateVarsImport.add(specifier.local.name);
219
234
  }
235
+ if (specifier.imported.value === "types ") {
236
+ state.stylexTypesImport.add(specifier.local.name);
237
+ }
220
238
  }
221
239
  }
222
240
  }
@@ -252,6 +270,9 @@ function readRequires(path, state) {
252
270
  if (prop.key.name === "unstable_overrideVars") {
253
271
  state.stylexCreateVarsImport.add(value.name);
254
272
  }
273
+ if (prop.key.name === "types") {
274
+ state.stylexTypesImport.add(value.name);
275
+ }
255
276
  }
256
277
  }
257
278
  }
@@ -333,9 +354,9 @@ stylexInclude$1.default = stylexInclude;
333
354
  var messages$3 = _interopRequireWildcard$3(messages$4);
334
355
  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); }
335
356
  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; }
336
- let number = 0;
357
+ let number$1 = 0;
337
358
  function uuid() {
338
- return `__included_${++number}__`;
359
+ return `__included_${++number$1}__`;
339
360
  }
340
361
  let IncludedStyles$1 = class IncludedStyles {
341
362
  constructor(astNode) {
@@ -513,7 +534,7 @@ Object.defineProperty(applicationOrder, "__esModule", {
513
534
  applicationOrder.default = void 0;
514
535
  var _splitCssValue$2 = _interopRequireDefault$j(splitCssValue);
515
536
  function _interopRequireDefault$j(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
516
- const shorthands$1 = {
537
+ const shorthands$2 = {
517
538
  all: _ => {
518
539
  throw new Error("all is not supported");
519
540
  },
@@ -521,24 +542,24 @@ const shorthands$1 = {
521
542
  background: value => [["background", value], ["backgroundAttachment", null], ["backgroundClip", null], ["backgroundColor", null], ["backgroundImage", null], ["backgroundOrigin", null], ["backgroundPosition", null], ["backgroundRepeat", null], ["backgroundSize", null]],
522
543
  border: rawValue => {
523
544
  if (typeof rawValue === "number") {
524
- return shorthands$1.borderWidth(rawValue);
545
+ return shorthands$2.borderWidth(rawValue);
525
546
  }
526
547
  const [width, style, color] = (0, _splitCssValue$2.default)(rawValue);
527
- return [...shorthands$1.borderWidth(width), ...shorthands$1.borderStyle(style), ...shorthands$1.borderColor(color)];
548
+ return [...shorthands$2.borderWidth(width), ...shorthands$2.borderStyle(style), ...shorthands$2.borderColor(color)];
528
549
  },
529
550
  borderInline: rawValue => {
530
551
  if (typeof rawValue === "number") {
531
552
  return [["borderInlineWidth", rawValue], ["borderInlineStartWidth", null], ["borderInlineEndWidth", null]];
532
553
  }
533
554
  const [width, style, color] = (0, _splitCssValue$2.default)(rawValue);
534
- return [...shorthands$1.borderInlineWidth(width), ...shorthands$1.borderInlineStyle(style), ...shorthands$1.borderInlineColor(color)];
555
+ return [...shorthands$2.borderInlineWidth(width), ...shorthands$2.borderInlineStyle(style), ...shorthands$2.borderInlineColor(color)];
535
556
  },
536
557
  borderBlock: rawValue => {
537
558
  if (typeof rawValue === "number") {
538
559
  return [["borderBlockWidth", rawValue], ["borderTopWidth", null], ["borderBottomWidth", null]];
539
560
  }
540
561
  const [width, style, color] = (0, _splitCssValue$2.default)(rawValue);
541
- return [...shorthands$1.borderBlockWidth(width), ...shorthands$1.borderBlockStyle(style), ...shorthands$1.borderBlockColor(color)];
562
+ return [...shorthands$2.borderBlockWidth(width), ...shorthands$2.borderBlockStyle(style), ...shorthands$2.borderBlockColor(color)];
542
563
  },
543
564
  borderTop: rawValue => {
544
565
  if (typeof rawValue === "number") {
@@ -673,55 +694,61 @@ const shorthands$1 = {
673
694
  textEmphasis: value => [["textEmphasis", value], ["textEmphasisColor", null], ["textEmphasisStyle", null]],
674
695
  transition: value => [["transition", value], ["transitionDelay", null], ["transitionDuration", null], ["transitionProperty", null], ["transitionTimingFunction", null]]
675
696
  };
676
- const aliases$1 = {
677
- borderHorizontal: shorthands$1.borderInline,
678
- borderVertical: shorthands$1.borderBlock,
679
- borderBlockStart: shorthands$1.borderTop,
680
- borderEnd: shorthands$1.borderInlineEnd,
681
- borderBlockEnd: shorthands$1.borderBottom,
682
- borderStart: shorthands$1.borderInlineStart,
683
- borderHorizontalWidth: shorthands$1.borderInlineWidth,
684
- borderHorizontalStyle: shorthands$1.borderInlineStyle,
685
- borderHorizontalColor: shorthands$1.borderInlineColor,
686
- borderVerticalWidth: shorthands$1.borderBlockWidth,
687
- borderVerticalStyle: shorthands$1.borderBlockStyle,
688
- borderVerticalColor: shorthands$1.borderBlockColor,
697
+ const aliases$2 = {
698
+ borderHorizontal: shorthands$2.borderInline,
699
+ borderVertical: shorthands$2.borderBlock,
700
+ borderBlockStart: shorthands$2.borderTop,
701
+ borderEnd: shorthands$2.borderInlineEnd,
702
+ borderBlockEnd: shorthands$2.borderBottom,
703
+ borderStart: shorthands$2.borderInlineStart,
704
+ blockSize: val => [["height", val]],
705
+ inlineSize: val => [["width", val]],
706
+ minBlockSize: val => [["minHeight", val]],
707
+ minInlineSize: val => [["minWidth", val]],
708
+ maxBlockSize: val => [["maxHeight", val]],
709
+ maxInlineSize: val => [["maxWidth", val]],
710
+ borderHorizontalWidth: shorthands$2.borderInlineWidth,
711
+ borderHorizontalStyle: shorthands$2.borderInlineStyle,
712
+ borderHorizontalColor: shorthands$2.borderInlineColor,
713
+ borderVerticalWidth: shorthands$2.borderBlockWidth,
714
+ borderVerticalStyle: shorthands$2.borderBlockStyle,
715
+ borderVerticalColor: shorthands$2.borderBlockColor,
689
716
  borderBlockStartColor: value => [["borderTopColor", value]],
690
717
  borderBlockEndColor: value => [["borderBottomColor", value]],
691
718
  borderBlockStartStyle: value => [["borderTopStyle", value]],
692
719
  borderBlockEndStyle: value => [["borderBottomStyle", value]],
693
720
  borderBlockStartWidth: value => [["borderTopWidth", value]],
694
721
  borderBlockEndWidth: value => [["borderBottomWidth", value]],
695
- borderStartColor: shorthands$1.borderInlineStartColor,
696
- borderEndColor: shorthands$1.borderInlineEndColor,
697
- borderStartStyle: shorthands$1.borderInlineStartStyle,
698
- borderEndStyle: shorthands$1.borderInlineEndStyle,
699
- borderStartWidth: shorthands$1.borderInlineStartWidth,
700
- borderEndWidth: shorthands$1.borderInlineEndWidth,
722
+ borderStartColor: shorthands$2.borderInlineStartColor,
723
+ borderEndColor: shorthands$2.borderInlineEndColor,
724
+ borderStartStyle: shorthands$2.borderInlineStartStyle,
725
+ borderEndStyle: shorthands$2.borderInlineEndStyle,
726
+ borderStartWidth: shorthands$2.borderInlineStartWidth,
727
+ borderEndWidth: shorthands$2.borderInlineEndWidth,
701
728
  borderTopStartRadius: value => [["borderStartStartRadius", value]],
702
729
  borderTopEndRadius: value => [["borderStartEndRadius", value]],
703
730
  borderBottomStartRadius: value => [["borderEndStartRadius", value]],
704
731
  borderBottomEndRadius: value => [["borderEndEndRadius", value]],
705
732
  marginBlockStart: value => [["marginTop", value]],
706
733
  marginBlockEnd: value => [["marginBottom", value]],
707
- marginStart: shorthands$1.marginInlineStart,
708
- marginEnd: shorthands$1.marginInlineEnd,
709
- marginHorizontal: shorthands$1.marginInline,
710
- marginVertical: shorthands$1.marginBlock,
734
+ marginStart: shorthands$2.marginInlineStart,
735
+ marginEnd: shorthands$2.marginInlineEnd,
736
+ marginHorizontal: shorthands$2.marginInline,
737
+ marginVertical: shorthands$2.marginBlock,
711
738
  paddingBlockStart: rawValue => [["paddingTop", rawValue]],
712
739
  paddingBlockEnd: rawValue => [["paddingBottom", rawValue]],
713
- paddingStart: shorthands$1.paddingInlineStart,
714
- paddingEnd: shorthands$1.paddingInlineEnd,
715
- paddingHorizontal: shorthands$1.paddingInline,
716
- paddingVertical: shorthands$1.paddingBlock,
740
+ paddingStart: shorthands$2.paddingInlineStart,
741
+ paddingEnd: shorthands$2.paddingInlineEnd,
742
+ paddingHorizontal: shorthands$2.paddingInline,
743
+ paddingVertical: shorthands$2.paddingBlock,
717
744
  insetBlockStart: value => [["top", value]],
718
745
  insetBlockEnd: value => [["bottom", value]],
719
- start: shorthands$1.insetInlineStart,
720
- end: shorthands$1.insetInlineEnd
746
+ start: shorthands$2.insetInlineStart,
747
+ end: shorthands$2.insetInlineEnd
721
748
  };
722
749
  const expansions$3 = {
723
- ...shorthands$1,
724
- ...aliases$1
750
+ ...shorthands$2,
751
+ ...aliases$2
725
752
  };
726
753
  var _default$4 = expansions$3;
727
754
  applicationOrder.default = _default$4;
@@ -734,7 +761,7 @@ Object.defineProperty(legacyExpandShorthands, "__esModule", {
734
761
  legacyExpandShorthands.default = void 0;
735
762
  var _splitCssValue$1 = _interopRequireDefault$i(splitCssValue);
736
763
  function _interopRequireDefault$i(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
737
- const expansions$2 = {
764
+ const shorthands$1 = {
738
765
  border: rawValue => {
739
766
  return [["borderTop", rawValue], ["borderEnd", rawValue], ["borderBottom", rawValue], ["borderStart", rawValue]];
740
767
  },
@@ -756,10 +783,19 @@ const expansions$2 = {
756
783
  const [top, right = top, bottom = top, left = right] = (0, _splitCssValue$1.default)(rawValue);
757
784
  return [["borderTopWidth", top], ["borderEndWidth", right], ["borderBottomWidth", bottom], ["borderStartWidth", left]];
758
785
  },
786
+ borderHorizontalColor: rawValue => [["borderStartColor", rawValue], ["borderEndColor", rawValue]],
787
+ borderHorizontalStyle: rawValue => [["borderStartStyle", rawValue], ["borderEndStyle", rawValue]],
788
+ borderHorizontalWidth: rawValue => [["borderStartWidth", rawValue], ["borderEndWidth", rawValue]],
789
+ borderVerticalColor: rawValue => [["borderTopColor", rawValue], ["borderBottomColor", rawValue]],
790
+ borderVerticalStyle: rawValue => [["borderTopStyle", rawValue], ["borderBottomStyle", rawValue]],
791
+ borderVerticalWidth: rawValue => [["borderTopWidth", rawValue], ["borderBottomWidth", rawValue]],
759
792
  borderRadius: rawValue => {
760
793
  const [top, right = top, bottom = top, left = right] = (0, _splitCssValue$1.default)(rawValue);
761
794
  return [["borderTopStartRadius", top], ["borderTopEndRadius", right], ["borderBottomEndRadius", bottom], ["borderBottomStartRadius", left]];
762
795
  },
796
+ inset: rawValue => [["top", rawValue], ["end", rawValue], ["bottom", rawValue], ["start", rawValue]],
797
+ insetInline: rawValue => [["start", rawValue], ["end", rawValue]],
798
+ insetBlock: rawValue => [["top", rawValue], ["bottom", rawValue]],
763
799
  margin: rawValue => {
764
800
  const [top, right = top, bottom = top, left = right] = (0, _splitCssValue$1.default)(rawValue);
765
801
  return [["marginTop", top], ["marginEnd", right], ["marginBottom", bottom], ["marginStart", left]];
@@ -778,13 +814,63 @@ const expansions$2 = {
778
814
  const [top, right = top, bottom = top, left = right] = (0, _splitCssValue$1.default)(rawValue);
779
815
  return [["paddingTop", top], ["paddingEnd", right], ["paddingBottom", bottom], ["paddingStart", left]];
780
816
  },
781
- paddingHorizontal: rawValue => {
782
- return [["paddingStart", rawValue], ["paddingEnd", rawValue]];
817
+ paddingHorizontal: val => {
818
+ return [["paddingStart", val], ["paddingEnd", val]];
783
819
  },
784
- paddingVertical: rawValue => {
785
- return [["paddingTop", rawValue], ["paddingBottom", rawValue]];
820
+ paddingVertical: val => {
821
+ return [["paddingTop", val], ["paddingBottom", val]];
786
822
  }
787
823
  };
824
+ const aliases$1 = {
825
+ insetBlockStart: val => [["top", val]],
826
+ insetBlockEnd: val => [["bottom", val]],
827
+ insetInlineStart: val => [["start", val]],
828
+ insetInlineEnd: val => [["end", val]],
829
+ blockSize: val => [["height", val]],
830
+ inlineSize: val => [["width", val]],
831
+ minBlockSize: val => [["minHeight", val]],
832
+ minInlineSize: val => [["minWidth", val]],
833
+ maxBlockSize: val => [["maxHeight", val]],
834
+ maxInlineSize: val => [["maxWidth", val]],
835
+ borderBlockWidth: shorthands$1.borderVerticalWidth,
836
+ borderBlockStyle: shorthands$1.borderVerticalStyle,
837
+ borderBlockColor: shorthands$1.borderVerticalColor,
838
+ borderBlockStartWidth: val => [["borderTopWidth", val]],
839
+ borderBlockStartStyle: val => [["borderTopStyle", val]],
840
+ borderBlockStartColor: val => [["borderTopColor", val]],
841
+ borderBlockEndWidth: val => [["borderBottomWidth", val]],
842
+ borderBlockEndStyle: val => [["borderBottomStyle", val]],
843
+ borderBlockEndColor: val => [["borderBottomColor", val]],
844
+ borderInlineWidth: shorthands$1.borderHorizontalWidth,
845
+ borderInlineStyle: shorthands$1.borderHorizontalStyle,
846
+ borderInlineColor: shorthands$1.borderHorizontalColor,
847
+ borderInlineStartWidth: val => [["borderStartWidth", val]],
848
+ borderInlineStartStyle: val => [["borderStartStyle", val]],
849
+ borderInlineStartColor: val => [["borderStartColor", val]],
850
+ borderInlineEndWidth: val => [["borderEndWidth", val]],
851
+ borderInlineEndStyle: val => [["borderEndStyle", val]],
852
+ borderInlineEndColor: val => [["borderEndColor", val]],
853
+ borderStartStartRadius: val => [["borderTopStartRadius", val]],
854
+ borderStartEndRadius: val => [["borderTopEndRadius", val]],
855
+ borderEndStartRadius: val => [["borderBottomStartRadius", val]],
856
+ borderEndEndRadius: val => [["borderBottomEndRadius", val]],
857
+ marginBlock: shorthands$1.marginVertical,
858
+ marginBlockStart: val => [["marginTop", val]],
859
+ marginBlockEnd: val => [["marginBottom", val]],
860
+ marginInline: shorthands$1.marginHorizontal,
861
+ marginInlineStart: val => [["marginStart", val]],
862
+ marginInlineEnd: val => [["marginEnd", val]],
863
+ paddingBlock: shorthands$1.paddingVertical,
864
+ paddingBlockStart: val => [["paddingTop", val]],
865
+ paddingBlockEnd: val => [["paddingBottom", val]],
866
+ paddingInline: shorthands$1.paddingHorizontal,
867
+ paddingInlineStart: val => [["paddingStart", val]],
868
+ paddingInlineEnd: val => [["paddingEnd", val]]
869
+ };
870
+ const expansions$2 = {
871
+ ...shorthands$1,
872
+ ...aliases$1
873
+ };
788
874
  var _default$3 = expansions$2;
789
875
  legacyExpandShorthands.default = _default$3;
790
876
 
@@ -856,6 +942,12 @@ const aliases = {
856
942
  borderEnd: shorthands.borderInlineEnd,
857
943
  borderBlockEnd: shorthands.borderBottom,
858
944
  borderStart: shorthands.borderInlineStart,
945
+ blockSize: val => [["height", val]],
946
+ inlineSize: val => [["width", val]],
947
+ minBlockSize: val => [["minHeight", val]],
948
+ minInlineSize: val => [["minWidth", val]],
949
+ maxBlockSize: val => [["maxHeight", val]],
950
+ maxInlineSize: val => [["maxWidth", val]],
859
951
  borderHorizontalWidth: value => [["borderInlineWidth", value]],
860
952
  borderHorizontalStyle: value => [["borderInlineStyle", value]],
861
953
  borderHorizontalColor: value => [["borderInlineColor", value]],
@@ -1197,6 +1289,8 @@ Object.defineProperty(transformValue$1, "__esModule", {
1197
1289
  value: true
1198
1290
  });
1199
1291
  transformValue$1.default = transformValue;
1292
+ var getNumberSuffix_1 = transformValue$1.getNumberSuffix = getNumberSuffix;
1293
+ var timeUnits_1 = transformValue$1.timeUnits = lengthUnits_1 = transformValue$1.lengthUnits = void 0;
1200
1294
  var _normalizeValue = _interopRequireDefault$a(normalizeValue$1);
1201
1295
  function _interopRequireDefault$a(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1202
1296
  function transformValue(key, rawValue) {
@@ -1223,7 +1317,7 @@ function getNumberSuffix(key) {
1223
1317
  return suffix;
1224
1318
  }
1225
1319
  }
1226
- const unitlessNumberProperties = new Set(["animationIterationCount", "borderImageOutset", "borderImageSlice", "borderImageWidth", "columnCount", "flex", "flexGrow", "flexPositive", "flexShrink", "flexOrder", "gridRow", "gridColumn", "fontWeight", "lineClamp", "lineHeight", "opacity", "order", "orphans", "tabSize", "widows", "zIndex", "fillOpacity", "floodOpacity", "stopOpacity", "strokeDasharray", "strokeDashoffset", "strokeMiterlimit", "strokeOpacity", "strokeWidth"]);
1320
+ const unitlessNumberProperties = new Set(["animationIterationCount", "aspectRatio", "borderImageOutset", "borderImageSlice", "borderImageWidth", "columnCount", "flex", "flexGrow", "flexPositive", "flexShrink", "flexOrder", "gridRow", "gridColumn", "fontWeight", "lineClamp", "lineHeight", "opacity", "order", "orphans", "tabSize", "widows", "zIndex", "fillOpacity", "floodOpacity", "stopOpacity", "strokeDasharray", "strokeDashoffset", "strokeMiterlimit", "strokeOpacity", "strokeWidth"]);
1227
1321
  const numberPropertySuffixes = {
1228
1322
  animationDelay: "ms",
1229
1323
  animationDuration: "ms",
@@ -1231,6 +1325,10 @@ const numberPropertySuffixes = {
1231
1325
  transitionDuration: "ms",
1232
1326
  voiceDuration: "ms"
1233
1327
  };
1328
+ const timeUnits = new Set(Object.keys(numberPropertySuffixes));
1329
+ timeUnits_1 = transformValue$1.timeUnits = timeUnits;
1330
+ const lengthUnits = new Set(["backgroundPositionX", "backgroundPositionY", "blockSize", "borderBlockEndWidth", "borderBlockStartWidth", "borderBlockWidth", "borderVerticalWidth", "borderVerticalWidth", "borderBottomLeftRadius", "borderBottomRightRadius", "borderBottomWidth", "borderEndEndRadius", "borderEndStartRadius", "borderImageWidth", "borderInlineEndWidth", "borderEndWidth", "borderInlineStartWidth", "borderStartWidth", "borderInlineWidth", "borderHorizontalWidth", "borderLeftWidth", "borderRightWidth", "borderSpacing", "borderStartEndRadius", "borderStartStartRadius", "borderTopLeftRadius", "borderTopRightRadius", "borderTopWidth", "bottom", "columnGap", "columnRuleWidth", "columnWidth", "containIntrinsicBlockSize", "containIntrinsicHeight", "containIntrinsicInlineSize", "containIntrinsicWidth", "flexBasis", "fontSize", "fontSmooth", "height", "inlineSize", "insetBlockEnd", "insetBlockStart", "insetInlineEnd", "insetInlineStart", "left", "letterSpacing", "marginBlockEnd", "marginBlockStart", "marginBottom", "marginInlineEnd", "marginEnd", "marginInlineStart", "marginStart", "marginLeft", "marginRight", "marginTop", "maskBorderOutset", "maskBorderWidth", "maxBlockSize", "maxHeight", "maxInlineSize", "maxWidth", "minBlockSize", "minHeight", "minInlineSize", "minWidth", "offsetDistance", "outlineOffset", "outlineWidth", "overflowClipMargin", "paddingBlockEnd", "paddingBlockStart", "paddingBottom", "paddingInlineEnd", "paddingEnd", "paddingInlineStart", "paddingStart", "paddingLeft", "paddingRight", "paddingTop", "perspective", "right", "rowGap", "scrollMarginBlockEnd", "scrollMarginBlockStart", "scrollMarginBottom", "scrollMarginInlineEnd", "scrollMarginInlineStart", "scrollMarginLeft", "scrollMarginRight", "scrollMarginTop", "scrollPaddingBlockEnd", "scrollPaddingBlockStart", "scrollPaddingBottom", "scrollPaddingInlineEnd", "scrollPaddingInlineStart", "scrollPaddingLeft", "scrollPaddingRight", "scrollPaddingTop", "scrollSnapMarginBottom", "scrollSnapMarginLeft", "scrollSnapMarginRight", "scrollSnapMarginTop", "shapeMargin", "tabSize", "textDecorationThickness", "textIndent", "textUnderlineOffset", "top", "transformOrigin", "translate", "verticalAlign", "width", "wordSpacing", "border", "borderBlock", "borderBlockEnd", "borderBlockStart", "borderBottom", "borderLeft", "borderRadius", "borderRight", "borderTop", "borderWidth", "columnRule", "containIntrinsicSize", "gap", "inset", "insetBlock", "insetInline", "margin", "marginBlock", "marginVertical", "marginInline", "marginHorizontal", "offset", "outline", "padding", "paddingBlock", "paddingVertical", "paddingInline", "paddingHorizontal", "scrollMargin", "scrollMarginBlock", "scrollMarginInline", "scrollPadding", "scrollPaddingBlock", "scrollPaddingInline", "scrollSnapMargin"]);
1331
+ var lengthUnits_1 = transformValue$1.lengthUnits = lengthUnits;
1234
1332
 
1235
1333
  var generateCssRule = {};
1236
1334
 
@@ -2165,7 +2263,7 @@ function styleXOverrideVars(themeVars, variables, options) {
2165
2263
  [themeVars.__themeName__]: overrideClassName
2166
2264
  }, {
2167
2265
  [overrideClassName]: {
2168
- ltr: `.${overrideClassName}{${cssVariablesOverrideString}${atRulesCss}}`,
2266
+ ltr: `.${overrideClassName}{${cssVariablesOverrideString}}${atRulesCss}`,
2169
2267
  priority: 0.99,
2170
2268
  rtl: undefined
2171
2269
  }
@@ -2257,10 +2355,215 @@ function genFileBasedIdentifier(_ref) {
2257
2355
  return `${fileName}//${exportName}${key != null ? `.${key}` : ""}`;
2258
2356
  }
2259
2357
 
2358
+ var types$1 = {};
2359
+
2360
+ Object.defineProperty(types$1, "__esModule", {
2361
+ value: true
2362
+ });
2363
+ 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;
2364
+ class CSSType {}
2365
+ types$1.CSSType = CSSType;
2366
+ class Angle extends CSSType {
2367
+ syntax = "<angle>";
2368
+ static syntax = "<angle>";
2369
+ constructor(value) {
2370
+ super();
2371
+ this.value = value;
2372
+ }
2373
+ static create(value) {
2374
+ return new Angle(value);
2375
+ }
2376
+ }
2377
+ types$1.Angle = Angle;
2378
+ const angle = Angle.create;
2379
+ types$1.angle = angle;
2380
+ class Color extends CSSType {
2381
+ syntax = "<color>";
2382
+ constructor(value) {
2383
+ super();
2384
+ this.value = value;
2385
+ }
2386
+ static create(value) {
2387
+ return new Color(value);
2388
+ }
2389
+ }
2390
+ types$1.Color = Color;
2391
+ const color = Color.create;
2392
+ types$1.color = color;
2393
+ class Url extends CSSType {
2394
+ syntax = "<url>";
2395
+ constructor(value) {
2396
+ super();
2397
+ this.value = value;
2398
+ }
2399
+ static create(value) {
2400
+ return new Url(value);
2401
+ }
2402
+ }
2403
+ types$1.Url = Url;
2404
+ const url = Url.create;
2405
+ types$1.url = url;
2406
+ class Image extends Url {
2407
+ syntax = "<image>";
2408
+ constructor(value) {
2409
+ super(value);
2410
+ this.value = value;
2411
+ }
2412
+ static create(value) {
2413
+ return new Image(value);
2414
+ }
2415
+ }
2416
+ types$1.Image = Image;
2417
+ const image = Image.create;
2418
+ types$1.image = image;
2419
+ class Integer extends CSSType {
2420
+ syntax = "<integer>";
2421
+ constructor(value) {
2422
+ super();
2423
+ this.value = value;
2424
+ }
2425
+ static create(value) {
2426
+ return new Integer(value);
2427
+ }
2428
+ }
2429
+ types$1.Integer = Integer;
2430
+ const integer = Integer.create;
2431
+ types$1.integer = integer;
2432
+ class LengthPercentage extends CSSType {
2433
+ syntax = "<length-percentage>";
2434
+ constructor(value) {
2435
+ super();
2436
+ this.value = value;
2437
+ }
2438
+ static createLength(value) {
2439
+ return new LengthPercentage(convertNumberToLength(value));
2440
+ }
2441
+ static createPercentage(value) {
2442
+ return new LengthPercentage(convertNumberToPercentage(value));
2443
+ }
2444
+ }
2445
+ types$1.LengthPercentage = LengthPercentage;
2446
+ const lengthPercentage = LengthPercentage.createLength;
2447
+ types$1.lengthPercentage = lengthPercentage;
2448
+ class Length extends LengthPercentage {
2449
+ syntax = "<length>";
2450
+ constructor(value) {
2451
+ super(convertNumberToLength(value));
2452
+ }
2453
+ static create(value) {
2454
+ return new Length(value);
2455
+ }
2456
+ }
2457
+ types$1.Length = Length;
2458
+ const length = Length.create;
2459
+ types$1.length = length;
2460
+ class Percentage extends LengthPercentage {
2461
+ syntax = "<percentage>";
2462
+ constructor(value) {
2463
+ super(convertNumberToPercentage(value));
2464
+ }
2465
+ static create(value) {
2466
+ return new Percentage(value);
2467
+ }
2468
+ }
2469
+ types$1.Percentage = Percentage;
2470
+ const percentage = Percentage.create;
2471
+ types$1.percentage = percentage;
2472
+ class Num extends CSSType {
2473
+ syntax = "<number>";
2474
+ constructor(value) {
2475
+ super();
2476
+ this.value = value;
2477
+ }
2478
+ static create(value) {
2479
+ return new Num(value);
2480
+ }
2481
+ }
2482
+ types$1.Num = Num;
2483
+ const number = Num.create;
2484
+ types$1.number = number;
2485
+ class Resolution extends CSSType {
2486
+ syntax = "<resolution>";
2487
+ constructor(value) {
2488
+ super();
2489
+ this.value = value;
2490
+ }
2491
+ static create(value) {
2492
+ return new Resolution(value);
2493
+ }
2494
+ }
2495
+ types$1.Resolution = Resolution;
2496
+ const resolution = Resolution.create;
2497
+ types$1.resolution = resolution;
2498
+ class Time extends CSSType {
2499
+ syntax = "<time>";
2500
+ constructor(value) {
2501
+ super();
2502
+ this.value = value;
2503
+ }
2504
+ static create(value) {
2505
+ return new Time(value);
2506
+ }
2507
+ }
2508
+ types$1.Time = Time;
2509
+ const time = Time.create;
2510
+ types$1.time = time;
2511
+ class TransformFunction extends CSSType {
2512
+ syntax = "<transform-function>";
2513
+ constructor(value) {
2514
+ super();
2515
+ this.value = value;
2516
+ }
2517
+ static create(value) {
2518
+ return new TransformFunction(value);
2519
+ }
2520
+ }
2521
+ types$1.TransformFunction = TransformFunction;
2522
+ const transformFunction = TransformFunction.create;
2523
+ types$1.transformFunction = transformFunction;
2524
+ class TransformList extends CSSType {
2525
+ syntax = "<transform-list>";
2526
+ constructor(value) {
2527
+ super();
2528
+ this.value = value;
2529
+ }
2530
+ static create(value) {
2531
+ return new TransformList(value);
2532
+ }
2533
+ }
2534
+ types$1.TransformList = TransformList;
2535
+ const transformList = TransformList.create;
2536
+ types$1.transformList = transformList;
2537
+ const convertNumberToStringUsing = (transformNumber, defaultStr) => value => {
2538
+ if (typeof value === "number") {
2539
+ return transformNumber(value);
2540
+ }
2541
+ if (typeof value === "string") {
2542
+ return value;
2543
+ }
2544
+ if (typeof value === "object") {
2545
+ const {
2546
+ default: defaultValue,
2547
+ ...rest
2548
+ } = value;
2549
+ const defaultResult = convertNumberToLength(defaultValue);
2550
+ const result = {
2551
+ default: typeof defaultResult === "string" ? defaultResult : defaultStr
2552
+ };
2553
+ for (const [key, value] of Object.entries(rest)) {
2554
+ result[key] = convertNumberToLength(value);
2555
+ }
2556
+ return result;
2557
+ }
2558
+ return value;
2559
+ };
2560
+ const convertNumberToLength = convertNumberToStringUsing(value => value === 0 ? "0" : `${value}px`, "0px");
2561
+ const convertNumberToPercentage = convertNumberToStringUsing(value => value === 0 ? "0" : `${value * 100}%`, "0");
2562
+
2260
2563
  Object.defineProperty(lib, "__esModule", {
2261
2564
  value: true
2262
2565
  });
2263
- var utils_1 = lib.utils = overrideVars_1 = lib.overrideVars = messages_1 = lib.messages = keyframes_1 = lib.keyframes = include_1 = lib.include = firstThatWorks_1 = lib.firstThatWorks = createVars_1 = lib.createVars = create_1 = lib.create = IncludedStyles_1 = lib.IncludedStyles = void 0;
2566
+ var utils_1 = lib.utils = lib.types = overrideVars_1 = lib.overrideVars = messages_1 = lib.messages = keyframes_1 = lib.keyframes = include_1 = lib.include = firstThatWorks_1 = lib.firstThatWorks = createVars_1 = lib.createVars = create_1 = lib.create = IncludedStyles_1 = lib.IncludedStyles = void 0;
2264
2567
  var _stylexCreate = _interopRequireDefault$2(stylexCreate$1);
2265
2568
  var _stylexCreateVars = _interopRequireDefault$2(stylexCreateVars$1);
2266
2569
  var _stylexOverrideVars = _interopRequireDefault$2(stylexOverrideVars$1);
@@ -2270,6 +2573,8 @@ var _stylexFirstThatWorks = _interopRequireDefault$2(stylexFirstThatWorks$1);
2270
2573
  var _hash = _interopRequireDefault$2(hash$1);
2271
2574
  var _fileBasedIdentifier = _interopRequireDefault$2(fileBasedIdentifier);
2272
2575
  var m = _interopRequireWildcard(messages$4);
2576
+ var _types = _interopRequireWildcard(types$1);
2577
+ lib.types = _types;
2273
2578
  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); }
2274
2579
  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; }
2275
2580
  function _interopRequireDefault$2(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -2336,6 +2641,9 @@ function canBeIdentifier(str) {
2336
2641
  function isArrayExpression(path, props) {
2337
2642
  return path.isArrayExpression(props);
2338
2643
  }
2644
+ function isArrowFunctionExpression(path, props) {
2645
+ return path.isArrowFunctionExpression(props);
2646
+ }
2339
2647
  function isBinaryExpression(path, props) {
2340
2648
  return path.isBinaryExpression(props);
2341
2649
  }
@@ -2423,9 +2731,6 @@ function isTaggedTemplateExpression(path, props) {
2423
2731
  function isTemplateLiteral(path, props) {
2424
2732
  return path.isTemplateLiteral(props);
2425
2733
  }
2426
- function isTypeCastExpression(path, props) {
2427
- return path.isTypeCastExpression(props);
2428
- }
2429
2734
  function isUnaryExpression(path, props) {
2430
2735
  return path.isUnaryExpression(props);
2431
2736
  }
@@ -2901,6 +3206,173 @@ function evaluate(path, traversalState) {
2901
3206
  };
2902
3207
  }
2903
3208
 
3209
+ function evaluateStyleXCreateArg(path, traversalState) {
3210
+ let functions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
3211
+ identifiers: {},
3212
+ memberExpressions: {}
3213
+ };
3214
+ if (!isObjectExpression(path)) {
3215
+ return evaluate(path, traversalState, functions);
3216
+ }
3217
+ const value = {};
3218
+ const fns = {};
3219
+ for (const prop of path.get("properties")) {
3220
+ if (!isObjectProperty(prop)) {
3221
+ return evaluate(path, traversalState, functions);
3222
+ }
3223
+ const objPropPath = prop;
3224
+ const keyResult = evaluateObjKey(objPropPath, traversalState, functions);
3225
+ if (!keyResult.confident) {
3226
+ return {
3227
+ confident: false,
3228
+ deopt: keyResult.deopt,
3229
+ value: null
3230
+ };
3231
+ }
3232
+ const key = keyResult.value;
3233
+ const valPath = prop.get("value");
3234
+ if (!isArrowFunctionExpression(valPath)) {
3235
+ const val = evaluate(valPath, traversalState, functions);
3236
+ if (!val.confident) {
3237
+ return val;
3238
+ }
3239
+ value[key] = val.value;
3240
+ continue;
3241
+ }
3242
+ const fnPath = valPath;
3243
+ const allParams = fnPath.get("params");
3244
+ const params = allParams.filter(param => isIdentifier(param)).map(param => param.node);
3245
+ if (params.length !== allParams.length) {
3246
+ return {
3247
+ confident: false,
3248
+ deopt: valPath,
3249
+ value: null
3250
+ };
3251
+ }
3252
+ const fnBody = fnPath.get("body");
3253
+ if (!isObjectExpression(fnBody)) {
3254
+ return evaluate(path, traversalState, functions);
3255
+ }
3256
+ const fnObjectBody = fnBody;
3257
+ const evalResult = evaluatePartialObjectRecursively(fnObjectBody, traversalState, functions);
3258
+ if (!evalResult.confident) {
3259
+ const {
3260
+ confident,
3261
+ value: v,
3262
+ deopt
3263
+ } = evalResult;
3264
+ return {
3265
+ confident,
3266
+ value: v,
3267
+ deopt
3268
+ };
3269
+ }
3270
+ const {
3271
+ value: v,
3272
+ inlineStyles
3273
+ } = evalResult;
3274
+ value[key] = v;
3275
+ fns[key] = [params, inlineStyles ?? {}];
3276
+ }
3277
+ return {
3278
+ value,
3279
+ confident: true,
3280
+ fns
3281
+ };
3282
+ }
3283
+ function evaluatePartialObjectRecursively(path, traversalState) {
3284
+ let functions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
3285
+ identifiers: {},
3286
+ memberExpressions: {}
3287
+ };
3288
+ let keyPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
3289
+ const obj = {};
3290
+ const inlineStyles = {};
3291
+ const props = path.get("properties");
3292
+ for (const prop of props) {
3293
+ if (isObjectMethod(prop)) {
3294
+ return {
3295
+ value: null,
3296
+ confident: false
3297
+ };
3298
+ }
3299
+ if (isSpreadElement(prop)) {
3300
+ const result = evaluate(prop.get("argument"), traversalState, functions);
3301
+ if (!result.confident) {
3302
+ return result;
3303
+ }
3304
+ Object.assign(obj, result.value);
3305
+ continue;
3306
+ }
3307
+ if (isObjectProperty(prop)) {
3308
+ const keyResult = evaluateObjKey(prop, traversalState, functions);
3309
+ if (!keyResult.confident) {
3310
+ return {
3311
+ confident: false,
3312
+ deopt: keyResult.deopt,
3313
+ value: null
3314
+ };
3315
+ }
3316
+ const key = keyResult.value;
3317
+ const valuePath = prop.get("value");
3318
+ if (isObjectExpression(valuePath)) {
3319
+ const result = evaluatePartialObjectRecursively(valuePath, traversalState, functions, [...keyPath, key]);
3320
+ if (!result.confident) {
3321
+ return {
3322
+ confident: false,
3323
+ deopt: result.deopt,
3324
+ value: null
3325
+ };
3326
+ }
3327
+ obj[key] = result.value;
3328
+ Object.assign(inlineStyles, result.inlineStyles);
3329
+ } else {
3330
+ const result = evaluate(valuePath, traversalState, functions);
3331
+ if (!result.confident) {
3332
+ const varName = "--" + (keyPath.length > 0 ? utils_1.hash([...keyPath, key].join("_")) : key);
3333
+ obj[key] = `var(${varName}, revert)`;
3334
+ const node = valuePath.node;
3335
+ if (!t__namespace.isExpression(node)) {
3336
+ throw new Error("Expected expression as style value");
3337
+ }
3338
+ const expression = node;
3339
+ const unit = timeUnits_1.has(key) || lengthUnits_1.has(key) ? getNumberSuffix_1(key) : "";
3340
+ inlineStyles[varName] = unit !== "" ? t__namespace.callExpression(t__namespace.arrowFunctionExpression([t__namespace.identifier("val")], t__namespace.conditionalExpression(t__namespace.binaryExpression("===", t__namespace.unaryExpression("typeof", t__namespace.identifier("val")), t__namespace.stringLiteral("number")), t__namespace.binaryExpression("+", t__namespace.identifier("val"), t__namespace.stringLiteral(unit)), t__namespace.logicalExpression("??", t__namespace.identifier("val"), t__namespace.stringLiteral("initial")))), [expression]) : t__namespace.logicalExpression("??", expression, t__namespace.stringLiteral("initial"));
3341
+ } else {
3342
+ obj[key] = result.value;
3343
+ }
3344
+ }
3345
+ }
3346
+ }
3347
+ return {
3348
+ value: obj,
3349
+ confident: true,
3350
+ inlineStyles
3351
+ };
3352
+ }
3353
+ function evaluateObjKey(prop, traversalState, functions) {
3354
+ const keyPath = prop.get("key");
3355
+ let key;
3356
+ if (prop.node.computed) {
3357
+ const result = evaluate(keyPath, traversalState, functions);
3358
+ if (!result.confident) {
3359
+ return {
3360
+ confident: false,
3361
+ deopt: result.deopt
3362
+ };
3363
+ }
3364
+ key = result.value;
3365
+ } else if (isIdentifier(keyPath)) {
3366
+ key = keyPath.node.name;
3367
+ } else {
3368
+ key = keyPath.node.value;
3369
+ }
3370
+ return {
3371
+ confident: true,
3372
+ value: String(key)
3373
+ };
3374
+ }
3375
+
2904
3376
  function transformStyleXCreate(path, state) {
2905
3377
  const {
2906
3378
  node
@@ -2915,7 +3387,6 @@ function transformStyleXCreate(path, state) {
2915
3387
  if (!isObjectExpression(firstArg)) {
2916
3388
  throw new Error(messages_1.ILLEGAL_ARGUMENT_LENGTH);
2917
3389
  }
2918
- preProcessStyleArg(firstArg, state);
2919
3390
  state.inStyleXCreate = true;
2920
3391
  const injectedKeyframes = {};
2921
3392
  function keyframes(animation) {
@@ -2958,8 +3429,9 @@ function transformStyleXCreate(path, state) {
2958
3429
  });
2959
3430
  const {
2960
3431
  confident,
2961
- value
2962
- } = evaluate(firstArg, state, {
3432
+ value,
3433
+ fns
3434
+ } = evaluateStyleXCreateArg(firstArg, state, {
2963
3435
  identifiers,
2964
3436
  memberExpressions
2965
3437
  });
@@ -2992,7 +3464,26 @@ function transformStyleXCreate(path, state) {
2992
3464
  state.styleMap.set(varName, compiledStyles);
2993
3465
  state.styleVars.set(varName, path.parentPath);
2994
3466
  }
2995
- path.replaceWith(convertObjectToAST(compiledStyles));
3467
+ const resultAst = convertObjectToAST(compiledStyles);
3468
+ if (fns != null) {
3469
+ resultAst.properties = resultAst.properties.map(prop => {
3470
+ if (t__namespace.isObjectProperty(prop)) {
3471
+ const key = prop.key.type === "Identifier" && !prop.computed ? prop.key.name : prop.key.type === "StringLiteral" ? prop.key.value : null;
3472
+ if (key != null && Object.keys(fns).includes(key)) {
3473
+ const [params, inlineStyles] = fns[key];
3474
+ if (t__namespace.isExpression(prop.value)) {
3475
+ const value = prop.value;
3476
+ prop.value = t__namespace.arrowFunctionExpression(params, t__namespace.arrayExpression([value, t__namespace.objectExpression(Object.entries(inlineStyles).map(_ref => {
3477
+ let [key, value] = _ref;
3478
+ return t__namespace.objectProperty(t__namespace.stringLiteral(key), value);
3479
+ }))]));
3480
+ }
3481
+ }
3482
+ }
3483
+ return prop;
3484
+ });
3485
+ }
3486
+ path.replaceWith(resultAst);
2996
3487
  if (Object.keys(injectedStyles).length === 0) {
2997
3488
  return;
2998
3489
  }
@@ -3040,25 +3531,6 @@ function findNearestStatementAncestor(path) {
3040
3531
  }
3041
3532
  return findNearestStatementAncestor(path.parentPath);
3042
3533
  }
3043
- function preProcessStyleArg(objPath, state) {
3044
- objPath.traverse({
3045
- SpreadElement(path) {
3046
- const argument = path.get("argument");
3047
- if (!isTypeCastExpression(argument)) {
3048
- return;
3049
- }
3050
- const expression = argument.get("expression");
3051
- if (!isIdentifier(expression) && !isMemberExpression(expression)) {
3052
- throw new Error(messages_1.ILLEGAL_NAMESPACE_VALUE);
3053
- }
3054
- if (!(isObjectExpression(path.parentPath) && isObjectProperty(path.parentPath.parentPath) && isObjectExpression(path.parentPath.parentPath.parentPath) && isCallExpression(path.parentPath.parentPath.parentPath.parentPath))) {
3055
- throw new Error(messages_1.ILLEGAL_NESTED_PSEUDO);
3056
- }
3057
- const stylexName = getStylexDefaultImport(path, state);
3058
- argument.replaceWith(t__namespace.callExpression(t__namespace.memberExpression(t__namespace.identifier(stylexName), t__namespace.identifier("include")), [expression.node]));
3059
- }
3060
- });
3061
- }
3062
3534
  function getStylexDefaultImport(path, state) {
3063
3535
  const statementPath = findNearestStatementAncestor(path);
3064
3536
  let stylexName;
@@ -3091,10 +3563,15 @@ function transformStyleXCreateVars(callExpressionPath, state) {
3091
3563
  const varId = variableDeclaratorNode.id;
3092
3564
  const args = callExpressionPath.get("arguments");
3093
3565
  const firstArg = args[0];
3566
+ const identifiers = {};
3567
+ const memberExpressions = {};
3094
3568
  const {
3095
3569
  confident,
3096
3570
  value
3097
- } = evaluate(firstArg, state);
3571
+ } = evaluate(firstArg, state, {
3572
+ identifiers,
3573
+ memberExpressions
3574
+ });
3098
3575
  if (!confident) {
3099
3576
  throw new Error(messages_1.NON_STATIC_VALUE);
3100
3577
  }
@@ -3479,7 +3956,7 @@ Object.defineProperty(stylex$1, "__esModule", {
3479
3956
  });
3480
3957
  stylex$1.keyframes = stylex$1.inject = stylex$1.include = stylex$1.firstThatWorks = default_1 = stylex$1.default = stylex$1.create = stylex$1.UNSUPPORTED_PROPERTY = void 0;
3481
3958
  stylex$1.spread = spread;
3482
- stylex$1.unstable_overrideVars = stylex$1.unstable_createVars = stylex$1.stylex = void 0;
3959
+ stylex$1.unstable_overrideVars = stylex$1.unstable_createVars = stylex$1.types = stylex$1.stylex = void 0;
3483
3960
  var _stylexInject = _interopRequireDefault(stylexInject);
3484
3961
  var _styleq = require$$1;
3485
3962
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -3510,6 +3987,49 @@ const unstable_overrideVars = stylexOverrideVars;
3510
3987
  stylex$1.unstable_overrideVars = unstable_overrideVars;
3511
3988
  const include = stylexIncludes;
3512
3989
  stylex$1.include = include;
3990
+ const types = {
3991
+ angle: _v => {
3992
+ throw new Error(errorForType("angle"));
3993
+ },
3994
+ color: _v => {
3995
+ throw new Error(errorForType("color"));
3996
+ },
3997
+ url: _v => {
3998
+ throw new Error(errorForType("url"));
3999
+ },
4000
+ image: _v => {
4001
+ throw new Error(errorForType("image"));
4002
+ },
4003
+ integer: _v => {
4004
+ throw new Error(errorForType("integer"));
4005
+ },
4006
+ lengthPercentage: _v => {
4007
+ throw new Error(errorForType("lengthPercentage"));
4008
+ },
4009
+ length: _v => {
4010
+ throw new Error(errorForType("length"));
4011
+ },
4012
+ percentage: _v => {
4013
+ throw new Error(errorForType("percentage"));
4014
+ },
4015
+ number: _v => {
4016
+ throw new Error(errorForType("number"));
4017
+ },
4018
+ resolution: _v => {
4019
+ throw new Error(errorForType("resolution"));
4020
+ },
4021
+ time: _v => {
4022
+ throw new Error(errorForType("time"));
4023
+ },
4024
+ transformFunction: _v => {
4025
+ throw new Error(errorForType("transformFunction"));
4026
+ },
4027
+ transformList: _v => {
4028
+ throw new Error(errorForType("transformList"));
4029
+ }
4030
+ };
4031
+ stylex$1.types = types;
4032
+ const errorForType = type => `stylex.types.${type} should be compiled away by @stylexjs/babel-plugin`;
3513
4033
  const keyframes = _keyframes => {
3514
4034
  throw new Error("stylex.keyframes should never be called");
3515
4035
  };
@@ -3540,10 +4060,11 @@ _stylex.keyframes = keyframes;
3540
4060
  _stylex.firstThatWorks = firstThatWorks;
3541
4061
  _stylex.inject = inject;
3542
4062
  _stylex.UNSUPPORTED_PROPERTY = UNSUPPORTED_PROPERTY;
3543
- var _default = _stylex;
3544
- var default_1 = stylex$1.default = _default;
4063
+ _stylex.types = types;
3545
4064
  const stylex = _stylex;
3546
4065
  stylex$1.stylex = stylex;
4066
+ var _default = _stylex;
4067
+ var default_1 = stylex$1.default = _default;
3547
4068
 
3548
4069
  function skipStylexMergeChildren(path, state) {
3549
4070
  const {
@@ -42,4 +42,4 @@ export declare function evaluate(
42
42
  path: NodePath,
43
43
  traversalState: StateManager,
44
44
  functions: FunctionConfig,
45
- ): { confident: boolean; value: any; deopt?: null | NodePath };
45
+ ): Readonly<{ confident: boolean; value: any; deopt?: null | NodePath }>;
@@ -46,8 +46,8 @@ declare export function evaluate(
46
46
  path: NodePath<>,
47
47
  traversalState: StateManager,
48
48
  functions: FunctionConfig,
49
- ): {
49
+ ): $ReadOnly<{
50
50
  confident: boolean,
51
51
  value: any,
52
52
  deopt?: null | NodePath<>,
53
- };
53
+ }>;
@@ -45,6 +45,7 @@ declare class StateManager {
45
45
  readonly stylexKeyframesImport: Set<string>;
46
46
  readonly stylexCreateVarsImport: Set<string>;
47
47
  readonly stylexOverrideVarsImport: Set<string>;
48
+ readonly stylexTypesImport: Set<string>;
48
49
  readonly styleMap: Map<string, CompiledNamespaces>;
49
50
  readonly styleVars: Map<string, NodePath>;
50
51
  readonly styleVarsToKeep: Set<[string, null | string]>;
@@ -50,6 +50,7 @@ declare export default class StateManager {
50
50
  +stylexKeyframesImport: Set<string>;
51
51
  +stylexCreateVarsImport: Set<string>;
52
52
  +stylexOverrideVarsImport: Set<string>;
53
+ +stylexTypesImport: Set<string>;
53
54
  +styleMap: Map<string, CompiledNamespaces>;
54
55
  +styleVars: Map<string, NodePath<>>;
55
56
  +styleVarsToKeep: Set<[string, null | string]>;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ import * as t from '@babel/types';
11
+ import type { NodePath } from '@babel/traverse';
12
+ import StateManager from '../../utils/state-manager';
13
+ declare function transformStyleXCreate(
14
+ path: NodePath<t.CallExpression>,
15
+ state: StateManager,
16
+ ): void;
17
+ export default transformStyleXCreate;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ */
9
+
10
+ import * as t from '../../../flow_modules/@babel/types';
11
+ import type { NodePath } from '../../../flow_modules/@babel/traverse';
12
+ import StateManager from '../../utils/state-manager';
13
+ /// This function looks for `stylex.create` calls and transforms them.
14
+ //. 1. It finds the first argument to `stylex.create` and validates it.
15
+ /// 2. It pre-processes valid-dynamic parts of style object such as custom presets (spreads)
16
+ /// 3. It envalues the style object to get a JS object. This also handles local constants automatically.
17
+ /// 4. It uses the `stylexCreate` from `@stylexjs/shared` to transform the JS
18
+ /// object and to get a list of injected styles.
19
+ /// 5. It converts the resulting Object back into an AST and replaces the call with it.
20
+ /// 6. It also inserts `stylex.inject` calls above the current statement as needed.
21
+ declare export default function transformStyleXCreate(
22
+ path: NodePath<t.CallExpression>,
23
+ state: StateManager,
24
+ ): void;
@@ -0,0 +1,18 @@
1
+ /* eslint-disable no-unused-vars */
2
+ /**
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ *
8
+ * @flow strict
9
+ */
10
+
11
+ import type { NodePath } from '@babel/traverse';
12
+ import StateManager from '../../utils/state-manager';
13
+ import { type FunctionConfig } from '../../utils/evaluate-path';
14
+ export declare function evaluateStyleFunction(
15
+ path: NodePath,
16
+ traversalState: StateManager,
17
+ functions: FunctionConfig,
18
+ ): { confident: boolean; value: any; deopt?: null | NodePath };
@@ -0,0 +1,23 @@
1
+ /* eslint-disable no-unused-vars */
2
+ /**
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ *
8
+ * @flow strict
9
+ */
10
+
11
+ import type { NodePath } from '../../../flow_modules/@babel/traverse';
12
+ import StateManager from '../../utils/state-manager';
13
+ import { type FunctionConfig } from '../../utils/evaluate-path';
14
+ // This
15
+ declare export function evaluateStyleFunction(
16
+ path: NodePath<>,
17
+ traversalState: StateManager,
18
+ functions: FunctionConfig,
19
+ ): {
20
+ confident: boolean,
21
+ value: any,
22
+ deopt?: null | NodePath<>,
23
+ };
@@ -0,0 +1,29 @@
1
+ /* eslint-disable no-unused-vars */
2
+ /**
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ *
8
+ * @flow strict
9
+ */
10
+
11
+ import type { NodePath } from '@babel/traverse';
12
+ import * as t from '@babel/types';
13
+ import StateManager from '../../utils/state-manager';
14
+ import { type FunctionConfig } from '../../utils/evaluate-path';
15
+ export declare function evaluateStyleXCreateArg(
16
+ path: NodePath,
17
+ traversalState: StateManager,
18
+ functions: FunctionConfig,
19
+ ): Readonly<{
20
+ confident: boolean;
21
+ value: any;
22
+ deopt?: null | NodePath;
23
+ fns?: {
24
+ [$$Key$$: string]: [
25
+ Array<t.Identifier>,
26
+ { readonly [$$Key$$: string]: t.Expression | t.PatternLike },
27
+ ];
28
+ };
29
+ }>;
@@ -0,0 +1,30 @@
1
+ /* eslint-disable no-unused-vars */
2
+ /**
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ *
8
+ * @flow strict
9
+ */
10
+
11
+ import type { NodePath } from '../../../flow_modules/@babel/traverse';
12
+ import * as t from '../../../flow_modules/@babel/types';
13
+ import StateManager from '../../utils/state-manager';
14
+ import { type FunctionConfig } from '../../utils/evaluate-path';
15
+ // This
16
+ declare export function evaluateStyleXCreateArg(
17
+ path: NodePath<>,
18
+ traversalState: StateManager,
19
+ functions: FunctionConfig,
20
+ ): $ReadOnly<{
21
+ confident: boolean,
22
+ value: any,
23
+ deopt?: null | NodePath<>,
24
+ fns?: {
25
+ [string]: [
26
+ Array<t.Identifier>,
27
+ { +[string]: t.Expression | t.PatternLike },
28
+ ],
29
+ },
30
+ }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stylexjs/babel-plugin",
3
- "version": "0.2.0-beta.18",
3
+ "version": "0.2.0-beta.20",
4
4
  "description": "StyleX babel plugin.",
5
5
  "main": "lib/index.js",
6
6
  "repository": "https://github.com/facebook/stylex",
@@ -12,7 +12,7 @@
12
12
  "test": "jest"
13
13
  },
14
14
  "dependencies": {
15
- "@stylexjs/shared": "0.2.0-beta.18"
15
+ "@stylexjs/shared": "0.2.0-beta.20"
16
16
  },
17
17
  "peerDependencies": {
18
18
  "@babel/core": "^7.19.6",
@@ -26,7 +26,8 @@
26
26
  "verbose": true,
27
27
  "snapshotFormat": {
28
28
  "printBasicPrototype": false
29
- }
29
+ },
30
+ "prettierPath": null
30
31
  },
31
32
  "files": [
32
33
  "flow_modules/*",