@stylexjs/babel-plugin 0.2.0-beta.19 → 0.2.0-beta.21
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/flow_modules/@babel/core/index.js.flow +3 -4
- package/flow_modules/@babel/parser/index.js.flow +5 -4
- package/lib/babel-path-utils.d.ts +0 -2
- package/lib/index.js +629 -80
- package/lib/utils/evaluate-path.d.ts +1 -1
- package/lib/utils/evaluate-path.js.flow +2 -2
- package/lib/utils/state-manager.d.ts +1 -0
- package/lib/utils/state-manager.js.flow +1 -0
- package/lib/visitors/stylex-create/index.d.ts +17 -0
- package/lib/visitors/stylex-create/index.js.flow +24 -0
- package/lib/visitors/stylex-create/parse-style-function.d.ts +18 -0
- package/lib/visitors/stylex-create/parse-style-function.js.flow +23 -0
- package/lib/visitors/stylex-create/parse-stylex-create-arg.d.ts +29 -0
- package/lib/visitors/stylex-create/parse-stylex-create-arg.js.flow +30 -0
- package/package.json +4 -3
|
@@ -28,8 +28,7 @@ export { traverse, NodePath };
|
|
|
28
28
|
export type Visitor<S> = _Visitor<S>;
|
|
29
29
|
|
|
30
30
|
export type Node = t.Node;
|
|
31
|
-
export type ParseResult<Result:
|
|
32
|
-
_ParseResult<Result>;
|
|
31
|
+
export type ParseResult<Result: t.Node = t.Node> = _ParseResult<Result>;
|
|
33
32
|
declare export var version: string;
|
|
34
33
|
declare export var DEFAULT_EXTENSIONS: ['.js', '.jsx', '.es6', '.es', '.mjs'];
|
|
35
34
|
|
|
@@ -586,7 +585,7 @@ declare export var parse: ((
|
|
|
586
585
|
declare export function parseSync(
|
|
587
586
|
code: string,
|
|
588
587
|
options?: TransformOptions,
|
|
589
|
-
): ParseResult
|
|
588
|
+
): ParseResult<t.File> | null;
|
|
590
589
|
|
|
591
590
|
/**
|
|
592
591
|
* Given some code, parse it using Babel's standard behavior.
|
|
@@ -595,7 +594,7 @@ declare export function parseSync(
|
|
|
595
594
|
declare export function parseAsync(
|
|
596
595
|
code: string,
|
|
597
596
|
options?: TransformOptions,
|
|
598
|
-
): Promise<ParseResult
|
|
597
|
+
): Promise<ParseResult<t.File> | null>;
|
|
599
598
|
|
|
600
599
|
/**
|
|
601
600
|
* Resolve Babel's options fully, resulting in an options object where:
|
|
@@ -246,7 +246,8 @@ export type ParseError = {
|
|
|
246
246
|
reasonCode: string,
|
|
247
247
|
};
|
|
248
248
|
|
|
249
|
-
export type ParseResult<Result:
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
249
|
+
export type ParseResult<Result: t.Node = t.Node> =
|
|
250
|
+
| Result
|
|
251
|
+
| {
|
|
252
|
+
+errors: $ReadOnlyArray<ParseError>,
|
|
253
|
+
};
|
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();
|
|
@@ -208,6 +209,9 @@ function readImportDeclarations(path, state) {
|
|
|
208
209
|
if (specifier.imported.name === "unstable_overrideVars") {
|
|
209
210
|
state.stylexCreateVarsImport.add(specifier.local.name);
|
|
210
211
|
}
|
|
212
|
+
if (specifier.imported.name === "types") {
|
|
213
|
+
state.stylexTypesImport.add(specifier.local.name);
|
|
214
|
+
}
|
|
211
215
|
}
|
|
212
216
|
if (specifier.imported.type === "StringLiteral") {
|
|
213
217
|
if (specifier.imported.value === "create") {
|
|
@@ -228,6 +232,9 @@ function readImportDeclarations(path, state) {
|
|
|
228
232
|
if (specifier.imported.value === "unstable_overrideVars ") {
|
|
229
233
|
state.stylexCreateVarsImport.add(specifier.local.name);
|
|
230
234
|
}
|
|
235
|
+
if (specifier.imported.value === "types ") {
|
|
236
|
+
state.stylexTypesImport.add(specifier.local.name);
|
|
237
|
+
}
|
|
231
238
|
}
|
|
232
239
|
}
|
|
233
240
|
}
|
|
@@ -263,6 +270,9 @@ function readRequires(path, state) {
|
|
|
263
270
|
if (prop.key.name === "unstable_overrideVars") {
|
|
264
271
|
state.stylexCreateVarsImport.add(value.name);
|
|
265
272
|
}
|
|
273
|
+
if (prop.key.name === "types") {
|
|
274
|
+
state.stylexTypesImport.add(value.name);
|
|
275
|
+
}
|
|
266
276
|
}
|
|
267
277
|
}
|
|
268
278
|
}
|
|
@@ -344,9 +354,9 @@ stylexInclude$1.default = stylexInclude;
|
|
|
344
354
|
var messages$3 = _interopRequireWildcard$3(messages$4);
|
|
345
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); }
|
|
346
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; }
|
|
347
|
-
let number = 0;
|
|
357
|
+
let number$1 = 0;
|
|
348
358
|
function uuid() {
|
|
349
|
-
return `__included_${++number}__`;
|
|
359
|
+
return `__included_${++number$1}__`;
|
|
350
360
|
}
|
|
351
361
|
let IncludedStyles$1 = class IncludedStyles {
|
|
352
362
|
constructor(astNode) {
|
|
@@ -524,7 +534,7 @@ Object.defineProperty(applicationOrder, "__esModule", {
|
|
|
524
534
|
applicationOrder.default = void 0;
|
|
525
535
|
var _splitCssValue$2 = _interopRequireDefault$j(splitCssValue);
|
|
526
536
|
function _interopRequireDefault$j(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
527
|
-
const shorthands$
|
|
537
|
+
const shorthands$2 = {
|
|
528
538
|
all: _ => {
|
|
529
539
|
throw new Error("all is not supported");
|
|
530
540
|
},
|
|
@@ -532,24 +542,24 @@ const shorthands$1 = {
|
|
|
532
542
|
background: value => [["background", value], ["backgroundAttachment", null], ["backgroundClip", null], ["backgroundColor", null], ["backgroundImage", null], ["backgroundOrigin", null], ["backgroundPosition", null], ["backgroundRepeat", null], ["backgroundSize", null]],
|
|
533
543
|
border: rawValue => {
|
|
534
544
|
if (typeof rawValue === "number") {
|
|
535
|
-
return shorthands$
|
|
545
|
+
return shorthands$2.borderWidth(rawValue);
|
|
536
546
|
}
|
|
537
547
|
const [width, style, color] = (0, _splitCssValue$2.default)(rawValue);
|
|
538
|
-
return [...shorthands$
|
|
548
|
+
return [...shorthands$2.borderWidth(width), ...shorthands$2.borderStyle(style), ...shorthands$2.borderColor(color)];
|
|
539
549
|
},
|
|
540
550
|
borderInline: rawValue => {
|
|
541
551
|
if (typeof rawValue === "number") {
|
|
542
552
|
return [["borderInlineWidth", rawValue], ["borderInlineStartWidth", null], ["borderInlineEndWidth", null]];
|
|
543
553
|
}
|
|
544
554
|
const [width, style, color] = (0, _splitCssValue$2.default)(rawValue);
|
|
545
|
-
return [...shorthands$
|
|
555
|
+
return [...shorthands$2.borderInlineWidth(width), ...shorthands$2.borderInlineStyle(style), ...shorthands$2.borderInlineColor(color)];
|
|
546
556
|
},
|
|
547
557
|
borderBlock: rawValue => {
|
|
548
558
|
if (typeof rawValue === "number") {
|
|
549
559
|
return [["borderBlockWidth", rawValue], ["borderTopWidth", null], ["borderBottomWidth", null]];
|
|
550
560
|
}
|
|
551
561
|
const [width, style, color] = (0, _splitCssValue$2.default)(rawValue);
|
|
552
|
-
return [...shorthands$
|
|
562
|
+
return [...shorthands$2.borderBlockWidth(width), ...shorthands$2.borderBlockStyle(style), ...shorthands$2.borderBlockColor(color)];
|
|
553
563
|
},
|
|
554
564
|
borderTop: rawValue => {
|
|
555
565
|
if (typeof rawValue === "number") {
|
|
@@ -684,55 +694,61 @@ const shorthands$1 = {
|
|
|
684
694
|
textEmphasis: value => [["textEmphasis", value], ["textEmphasisColor", null], ["textEmphasisStyle", null]],
|
|
685
695
|
transition: value => [["transition", value], ["transitionDelay", null], ["transitionDuration", null], ["transitionProperty", null], ["transitionTimingFunction", null]]
|
|
686
696
|
};
|
|
687
|
-
const aliases$
|
|
688
|
-
borderHorizontal: shorthands$
|
|
689
|
-
borderVertical: shorthands$
|
|
690
|
-
borderBlockStart: shorthands$
|
|
691
|
-
borderEnd: shorthands$
|
|
692
|
-
borderBlockEnd: shorthands$
|
|
693
|
-
borderStart: shorthands$
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
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,
|
|
700
716
|
borderBlockStartColor: value => [["borderTopColor", value]],
|
|
701
717
|
borderBlockEndColor: value => [["borderBottomColor", value]],
|
|
702
718
|
borderBlockStartStyle: value => [["borderTopStyle", value]],
|
|
703
719
|
borderBlockEndStyle: value => [["borderBottomStyle", value]],
|
|
704
720
|
borderBlockStartWidth: value => [["borderTopWidth", value]],
|
|
705
721
|
borderBlockEndWidth: value => [["borderBottomWidth", value]],
|
|
706
|
-
borderStartColor: shorthands$
|
|
707
|
-
borderEndColor: shorthands$
|
|
708
|
-
borderStartStyle: shorthands$
|
|
709
|
-
borderEndStyle: shorthands$
|
|
710
|
-
borderStartWidth: shorthands$
|
|
711
|
-
borderEndWidth: shorthands$
|
|
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,
|
|
712
728
|
borderTopStartRadius: value => [["borderStartStartRadius", value]],
|
|
713
729
|
borderTopEndRadius: value => [["borderStartEndRadius", value]],
|
|
714
730
|
borderBottomStartRadius: value => [["borderEndStartRadius", value]],
|
|
715
731
|
borderBottomEndRadius: value => [["borderEndEndRadius", value]],
|
|
716
732
|
marginBlockStart: value => [["marginTop", value]],
|
|
717
733
|
marginBlockEnd: value => [["marginBottom", value]],
|
|
718
|
-
marginStart: shorthands$
|
|
719
|
-
marginEnd: shorthands$
|
|
720
|
-
marginHorizontal: shorthands$
|
|
721
|
-
marginVertical: shorthands$
|
|
734
|
+
marginStart: shorthands$2.marginInlineStart,
|
|
735
|
+
marginEnd: shorthands$2.marginInlineEnd,
|
|
736
|
+
marginHorizontal: shorthands$2.marginInline,
|
|
737
|
+
marginVertical: shorthands$2.marginBlock,
|
|
722
738
|
paddingBlockStart: rawValue => [["paddingTop", rawValue]],
|
|
723
739
|
paddingBlockEnd: rawValue => [["paddingBottom", rawValue]],
|
|
724
|
-
paddingStart: shorthands$
|
|
725
|
-
paddingEnd: shorthands$
|
|
726
|
-
paddingHorizontal: shorthands$
|
|
727
|
-
paddingVertical: shorthands$
|
|
740
|
+
paddingStart: shorthands$2.paddingInlineStart,
|
|
741
|
+
paddingEnd: shorthands$2.paddingInlineEnd,
|
|
742
|
+
paddingHorizontal: shorthands$2.paddingInline,
|
|
743
|
+
paddingVertical: shorthands$2.paddingBlock,
|
|
728
744
|
insetBlockStart: value => [["top", value]],
|
|
729
745
|
insetBlockEnd: value => [["bottom", value]],
|
|
730
|
-
start: shorthands$
|
|
731
|
-
end: shorthands$
|
|
746
|
+
start: shorthands$2.insetInlineStart,
|
|
747
|
+
end: shorthands$2.insetInlineEnd
|
|
732
748
|
};
|
|
733
749
|
const expansions$3 = {
|
|
734
|
-
...shorthands$
|
|
735
|
-
...aliases$
|
|
750
|
+
...shorthands$2,
|
|
751
|
+
...aliases$2
|
|
736
752
|
};
|
|
737
753
|
var _default$4 = expansions$3;
|
|
738
754
|
applicationOrder.default = _default$4;
|
|
@@ -745,7 +761,7 @@ Object.defineProperty(legacyExpandShorthands, "__esModule", {
|
|
|
745
761
|
legacyExpandShorthands.default = void 0;
|
|
746
762
|
var _splitCssValue$1 = _interopRequireDefault$i(splitCssValue);
|
|
747
763
|
function _interopRequireDefault$i(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
748
|
-
const
|
|
764
|
+
const shorthands$1 = {
|
|
749
765
|
border: rawValue => {
|
|
750
766
|
return [["borderTop", rawValue], ["borderEnd", rawValue], ["borderBottom", rawValue], ["borderStart", rawValue]];
|
|
751
767
|
},
|
|
@@ -767,10 +783,19 @@ const expansions$2 = {
|
|
|
767
783
|
const [top, right = top, bottom = top, left = right] = (0, _splitCssValue$1.default)(rawValue);
|
|
768
784
|
return [["borderTopWidth", top], ["borderEndWidth", right], ["borderBottomWidth", bottom], ["borderStartWidth", left]];
|
|
769
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]],
|
|
770
792
|
borderRadius: rawValue => {
|
|
771
793
|
const [top, right = top, bottom = top, left = right] = (0, _splitCssValue$1.default)(rawValue);
|
|
772
794
|
return [["borderTopStartRadius", top], ["borderTopEndRadius", right], ["borderBottomEndRadius", bottom], ["borderBottomStartRadius", left]];
|
|
773
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]],
|
|
774
799
|
margin: rawValue => {
|
|
775
800
|
const [top, right = top, bottom = top, left = right] = (0, _splitCssValue$1.default)(rawValue);
|
|
776
801
|
return [["marginTop", top], ["marginEnd", right], ["marginBottom", bottom], ["marginStart", left]];
|
|
@@ -789,13 +814,63 @@ const expansions$2 = {
|
|
|
789
814
|
const [top, right = top, bottom = top, left = right] = (0, _splitCssValue$1.default)(rawValue);
|
|
790
815
|
return [["paddingTop", top], ["paddingEnd", right], ["paddingBottom", bottom], ["paddingStart", left]];
|
|
791
816
|
},
|
|
792
|
-
paddingHorizontal:
|
|
793
|
-
return [["paddingStart",
|
|
817
|
+
paddingHorizontal: val => {
|
|
818
|
+
return [["paddingStart", val], ["paddingEnd", val]];
|
|
794
819
|
},
|
|
795
|
-
paddingVertical:
|
|
796
|
-
return [["paddingTop",
|
|
820
|
+
paddingVertical: val => {
|
|
821
|
+
return [["paddingTop", val], ["paddingBottom", val]];
|
|
797
822
|
}
|
|
798
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
|
+
};
|
|
799
874
|
var _default$3 = expansions$2;
|
|
800
875
|
legacyExpandShorthands.default = _default$3;
|
|
801
876
|
|
|
@@ -867,6 +942,12 @@ const aliases = {
|
|
|
867
942
|
borderEnd: shorthands.borderInlineEnd,
|
|
868
943
|
borderBlockEnd: shorthands.borderBottom,
|
|
869
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]],
|
|
870
951
|
borderHorizontalWidth: value => [["borderInlineWidth", value]],
|
|
871
952
|
borderHorizontalStyle: value => [["borderInlineStyle", value]],
|
|
872
953
|
borderHorizontalColor: value => [["borderInlineColor", value]],
|
|
@@ -1208,6 +1289,8 @@ Object.defineProperty(transformValue$1, "__esModule", {
|
|
|
1208
1289
|
value: true
|
|
1209
1290
|
});
|
|
1210
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;
|
|
1211
1294
|
var _normalizeValue = _interopRequireDefault$a(normalizeValue$1);
|
|
1212
1295
|
function _interopRequireDefault$a(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1213
1296
|
function transformValue(key, rawValue) {
|
|
@@ -1234,7 +1317,7 @@ function getNumberSuffix(key) {
|
|
|
1234
1317
|
return suffix;
|
|
1235
1318
|
}
|
|
1236
1319
|
}
|
|
1237
|
-
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"]);
|
|
1238
1321
|
const numberPropertySuffixes = {
|
|
1239
1322
|
animationDelay: "ms",
|
|
1240
1323
|
animationDuration: "ms",
|
|
@@ -1242,6 +1325,10 @@ const numberPropertySuffixes = {
|
|
|
1242
1325
|
transitionDuration: "ms",
|
|
1243
1326
|
voiceDuration: "ms"
|
|
1244
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;
|
|
1245
1332
|
|
|
1246
1333
|
var generateCssRule = {};
|
|
1247
1334
|
|
|
@@ -2176,7 +2263,7 @@ function styleXOverrideVars(themeVars, variables, options) {
|
|
|
2176
2263
|
[themeVars.__themeName__]: overrideClassName
|
|
2177
2264
|
}, {
|
|
2178
2265
|
[overrideClassName]: {
|
|
2179
|
-
ltr: `.${overrideClassName}{${cssVariablesOverrideString}${atRulesCss}
|
|
2266
|
+
ltr: `.${overrideClassName}{${cssVariablesOverrideString}}${atRulesCss}`,
|
|
2180
2267
|
priority: 0.99,
|
|
2181
2268
|
rtl: undefined
|
|
2182
2269
|
}
|
|
@@ -2268,10 +2355,215 @@ function genFileBasedIdentifier(_ref) {
|
|
|
2268
2355
|
return `${fileName}//${exportName}${key != null ? `.${key}` : ""}`;
|
|
2269
2356
|
}
|
|
2270
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
|
+
|
|
2271
2563
|
Object.defineProperty(lib, "__esModule", {
|
|
2272
2564
|
value: true
|
|
2273
2565
|
});
|
|
2274
|
-
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;
|
|
2275
2567
|
var _stylexCreate = _interopRequireDefault$2(stylexCreate$1);
|
|
2276
2568
|
var _stylexCreateVars = _interopRequireDefault$2(stylexCreateVars$1);
|
|
2277
2569
|
var _stylexOverrideVars = _interopRequireDefault$2(stylexOverrideVars$1);
|
|
@@ -2281,6 +2573,8 @@ var _stylexFirstThatWorks = _interopRequireDefault$2(stylexFirstThatWorks$1);
|
|
|
2281
2573
|
var _hash = _interopRequireDefault$2(hash$1);
|
|
2282
2574
|
var _fileBasedIdentifier = _interopRequireDefault$2(fileBasedIdentifier);
|
|
2283
2575
|
var m = _interopRequireWildcard(messages$4);
|
|
2576
|
+
var _types = _interopRequireWildcard(types$1);
|
|
2577
|
+
lib.types = _types;
|
|
2284
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); }
|
|
2285
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; }
|
|
2286
2580
|
function _interopRequireDefault$2(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -2347,6 +2641,9 @@ function canBeIdentifier(str) {
|
|
|
2347
2641
|
function isArrayExpression(path, props) {
|
|
2348
2642
|
return path.isArrayExpression(props);
|
|
2349
2643
|
}
|
|
2644
|
+
function isArrowFunctionExpression(path, props) {
|
|
2645
|
+
return path.isArrowFunctionExpression(props);
|
|
2646
|
+
}
|
|
2350
2647
|
function isBinaryExpression(path, props) {
|
|
2351
2648
|
return path.isBinaryExpression(props);
|
|
2352
2649
|
}
|
|
@@ -2434,9 +2731,6 @@ function isTaggedTemplateExpression(path, props) {
|
|
|
2434
2731
|
function isTemplateLiteral(path, props) {
|
|
2435
2732
|
return path.isTemplateLiteral(props);
|
|
2436
2733
|
}
|
|
2437
|
-
function isTypeCastExpression(path, props) {
|
|
2438
|
-
return path.isTypeCastExpression(props);
|
|
2439
|
-
}
|
|
2440
2734
|
function isUnaryExpression(path, props) {
|
|
2441
2735
|
return path.isUnaryExpression(props);
|
|
2442
2736
|
}
|
|
@@ -2450,8 +2744,8 @@ function isReferencedIdentifier(path, props) {
|
|
|
2450
2744
|
return path.isReferencedIdentifier(props);
|
|
2451
2745
|
}
|
|
2452
2746
|
|
|
2453
|
-
const VALID_CALLEES = ["String", "Number", "Math"];
|
|
2454
|
-
const INVALID_METHODS = ["random"];
|
|
2747
|
+
const VALID_CALLEES = ["String", "Number", "Math", "Object", "Array"];
|
|
2748
|
+
const INVALID_METHODS = ["random", "assign", "defineProperties", "defineProperty", "freeze", "seal", "splice"];
|
|
2455
2749
|
function isValidCallee(val) {
|
|
2456
2750
|
return VALID_CALLEES.includes(val);
|
|
2457
2751
|
}
|
|
@@ -2468,12 +2762,13 @@ function evaluateImportedFile(filePath, namedExport, state) {
|
|
|
2468
2762
|
const ast = core.parseSync(fileContents, {
|
|
2469
2763
|
babelrc: true
|
|
2470
2764
|
});
|
|
2471
|
-
if (!ast) {
|
|
2765
|
+
if (!ast || ast.errors || !t__namespace.isNode(ast)) {
|
|
2472
2766
|
state.confident = false;
|
|
2473
2767
|
return;
|
|
2474
2768
|
}
|
|
2769
|
+
const astNode = ast;
|
|
2475
2770
|
let result;
|
|
2476
|
-
traverse(
|
|
2771
|
+
traverse(astNode, {
|
|
2477
2772
|
ExportNamedDeclaration(path) {
|
|
2478
2773
|
const declaration = path.get("declaration");
|
|
2479
2774
|
if (isVariableDeclaration(declaration)) {
|
|
@@ -2555,6 +2850,35 @@ function evaluateCached(path, state) {
|
|
|
2555
2850
|
}
|
|
2556
2851
|
function _evaluate(path, state) {
|
|
2557
2852
|
if (!state.confident) return;
|
|
2853
|
+
if (isArrowFunctionExpression(path)) {
|
|
2854
|
+
const body = path.get("body");
|
|
2855
|
+
const params = path.get("params");
|
|
2856
|
+
const identParams = params.filter(param => isIdentifier(param)).map(paramPath => paramPath.node.name);
|
|
2857
|
+
if (isExpression(body) && identParams.length === params.length) {
|
|
2858
|
+
const expr = body;
|
|
2859
|
+
return function () {
|
|
2860
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2861
|
+
args[_key] = arguments[_key];
|
|
2862
|
+
}
|
|
2863
|
+
const identifierEntries = identParams.map((ident, index) => [ident, args[index]]);
|
|
2864
|
+
const identifiersObj = Object.fromEntries(identifierEntries);
|
|
2865
|
+
const result = evaluate(expr, state.traversalState, {
|
|
2866
|
+
...state.functions,
|
|
2867
|
+
identifiers: {
|
|
2868
|
+
...state.functions.identifiers,
|
|
2869
|
+
...identifiersObj
|
|
2870
|
+
}
|
|
2871
|
+
});
|
|
2872
|
+
return result.value;
|
|
2873
|
+
};
|
|
2874
|
+
}
|
|
2875
|
+
}
|
|
2876
|
+
if (isIdentifier(path)) {
|
|
2877
|
+
const name = path.node.name;
|
|
2878
|
+
if (Object.keys(state.functions?.identifiers ?? {}).includes(name)) {
|
|
2879
|
+
return state.functions.identifiers[name];
|
|
2880
|
+
}
|
|
2881
|
+
}
|
|
2558
2882
|
if (isSequenceExpression(path)) {
|
|
2559
2883
|
const exprs = path.get("expressions");
|
|
2560
2884
|
return evaluateCached(exprs[exprs.length - 1], state);
|
|
@@ -2859,6 +3183,15 @@ function _evaluate(path, state) {
|
|
|
2859
3183
|
const val = object.node.value;
|
|
2860
3184
|
func = val[property.node.name];
|
|
2861
3185
|
}
|
|
3186
|
+
const parsedObj = evaluate(object, state.traversalState, state.functions);
|
|
3187
|
+
if (parsedObj.confident && isIdentifier(property)) {
|
|
3188
|
+
func = parsedObj.value[property.node.name];
|
|
3189
|
+
context = parsedObj.value;
|
|
3190
|
+
}
|
|
3191
|
+
if (parsedObj.confident && isStringLiteral(property)) {
|
|
3192
|
+
func = parsedObj.value[property.node.value];
|
|
3193
|
+
context = parsedObj.value;
|
|
3194
|
+
}
|
|
2862
3195
|
}
|
|
2863
3196
|
if (func) {
|
|
2864
3197
|
if (func.takesPath) {
|
|
@@ -2912,6 +3245,173 @@ function evaluate(path, traversalState) {
|
|
|
2912
3245
|
};
|
|
2913
3246
|
}
|
|
2914
3247
|
|
|
3248
|
+
function evaluateStyleXCreateArg(path, traversalState) {
|
|
3249
|
+
let functions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
3250
|
+
identifiers: {},
|
|
3251
|
+
memberExpressions: {}
|
|
3252
|
+
};
|
|
3253
|
+
if (!isObjectExpression(path)) {
|
|
3254
|
+
return evaluate(path, traversalState, functions);
|
|
3255
|
+
}
|
|
3256
|
+
const value = {};
|
|
3257
|
+
const fns = {};
|
|
3258
|
+
for (const prop of path.get("properties")) {
|
|
3259
|
+
if (!isObjectProperty(prop)) {
|
|
3260
|
+
return evaluate(path, traversalState, functions);
|
|
3261
|
+
}
|
|
3262
|
+
const objPropPath = prop;
|
|
3263
|
+
const keyResult = evaluateObjKey(objPropPath, traversalState, functions);
|
|
3264
|
+
if (!keyResult.confident) {
|
|
3265
|
+
return {
|
|
3266
|
+
confident: false,
|
|
3267
|
+
deopt: keyResult.deopt,
|
|
3268
|
+
value: null
|
|
3269
|
+
};
|
|
3270
|
+
}
|
|
3271
|
+
const key = keyResult.value;
|
|
3272
|
+
const valPath = prop.get("value");
|
|
3273
|
+
if (!isArrowFunctionExpression(valPath)) {
|
|
3274
|
+
const val = evaluate(valPath, traversalState, functions);
|
|
3275
|
+
if (!val.confident) {
|
|
3276
|
+
return val;
|
|
3277
|
+
}
|
|
3278
|
+
value[key] = val.value;
|
|
3279
|
+
continue;
|
|
3280
|
+
}
|
|
3281
|
+
const fnPath = valPath;
|
|
3282
|
+
const allParams = fnPath.get("params");
|
|
3283
|
+
const params = allParams.filter(param => isIdentifier(param)).map(param => param.node);
|
|
3284
|
+
if (params.length !== allParams.length) {
|
|
3285
|
+
return {
|
|
3286
|
+
confident: false,
|
|
3287
|
+
deopt: valPath,
|
|
3288
|
+
value: null
|
|
3289
|
+
};
|
|
3290
|
+
}
|
|
3291
|
+
const fnBody = fnPath.get("body");
|
|
3292
|
+
if (!isObjectExpression(fnBody)) {
|
|
3293
|
+
return evaluate(path, traversalState, functions);
|
|
3294
|
+
}
|
|
3295
|
+
const fnObjectBody = fnBody;
|
|
3296
|
+
const evalResult = evaluatePartialObjectRecursively(fnObjectBody, traversalState, functions);
|
|
3297
|
+
if (!evalResult.confident) {
|
|
3298
|
+
const {
|
|
3299
|
+
confident,
|
|
3300
|
+
value: v,
|
|
3301
|
+
deopt
|
|
3302
|
+
} = evalResult;
|
|
3303
|
+
return {
|
|
3304
|
+
confident,
|
|
3305
|
+
value: v,
|
|
3306
|
+
deopt
|
|
3307
|
+
};
|
|
3308
|
+
}
|
|
3309
|
+
const {
|
|
3310
|
+
value: v,
|
|
3311
|
+
inlineStyles
|
|
3312
|
+
} = evalResult;
|
|
3313
|
+
value[key] = v;
|
|
3314
|
+
fns[key] = [params, inlineStyles ?? {}];
|
|
3315
|
+
}
|
|
3316
|
+
return {
|
|
3317
|
+
value,
|
|
3318
|
+
confident: true,
|
|
3319
|
+
fns
|
|
3320
|
+
};
|
|
3321
|
+
}
|
|
3322
|
+
function evaluatePartialObjectRecursively(path, traversalState) {
|
|
3323
|
+
let functions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
3324
|
+
identifiers: {},
|
|
3325
|
+
memberExpressions: {}
|
|
3326
|
+
};
|
|
3327
|
+
let keyPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
3328
|
+
const obj = {};
|
|
3329
|
+
const inlineStyles = {};
|
|
3330
|
+
const props = path.get("properties");
|
|
3331
|
+
for (const prop of props) {
|
|
3332
|
+
if (isObjectMethod(prop)) {
|
|
3333
|
+
return {
|
|
3334
|
+
value: null,
|
|
3335
|
+
confident: false
|
|
3336
|
+
};
|
|
3337
|
+
}
|
|
3338
|
+
if (isSpreadElement(prop)) {
|
|
3339
|
+
const result = evaluate(prop.get("argument"), traversalState, functions);
|
|
3340
|
+
if (!result.confident) {
|
|
3341
|
+
return result;
|
|
3342
|
+
}
|
|
3343
|
+
Object.assign(obj, result.value);
|
|
3344
|
+
continue;
|
|
3345
|
+
}
|
|
3346
|
+
if (isObjectProperty(prop)) {
|
|
3347
|
+
const keyResult = evaluateObjKey(prop, traversalState, functions);
|
|
3348
|
+
if (!keyResult.confident) {
|
|
3349
|
+
return {
|
|
3350
|
+
confident: false,
|
|
3351
|
+
deopt: keyResult.deopt,
|
|
3352
|
+
value: null
|
|
3353
|
+
};
|
|
3354
|
+
}
|
|
3355
|
+
const key = keyResult.value;
|
|
3356
|
+
const valuePath = prop.get("value");
|
|
3357
|
+
if (isObjectExpression(valuePath)) {
|
|
3358
|
+
const result = evaluatePartialObjectRecursively(valuePath, traversalState, functions, [...keyPath, key]);
|
|
3359
|
+
if (!result.confident) {
|
|
3360
|
+
return {
|
|
3361
|
+
confident: false,
|
|
3362
|
+
deopt: result.deopt,
|
|
3363
|
+
value: null
|
|
3364
|
+
};
|
|
3365
|
+
}
|
|
3366
|
+
obj[key] = result.value;
|
|
3367
|
+
Object.assign(inlineStyles, result.inlineStyles);
|
|
3368
|
+
} else {
|
|
3369
|
+
const result = evaluate(valuePath, traversalState, functions);
|
|
3370
|
+
if (!result.confident) {
|
|
3371
|
+
const varName = "--" + (keyPath.length > 0 ? utils_1.hash([...keyPath, key].join("_")) : key);
|
|
3372
|
+
obj[key] = `var(${varName}, revert)`;
|
|
3373
|
+
const node = valuePath.node;
|
|
3374
|
+
if (!t__namespace.isExpression(node)) {
|
|
3375
|
+
throw new Error("Expected expression as style value");
|
|
3376
|
+
}
|
|
3377
|
+
const expression = node;
|
|
3378
|
+
const unit = timeUnits_1.has(key) || lengthUnits_1.has(key) ? getNumberSuffix_1(key) : "";
|
|
3379
|
+
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"));
|
|
3380
|
+
} else {
|
|
3381
|
+
obj[key] = result.value;
|
|
3382
|
+
}
|
|
3383
|
+
}
|
|
3384
|
+
}
|
|
3385
|
+
}
|
|
3386
|
+
return {
|
|
3387
|
+
value: obj,
|
|
3388
|
+
confident: true,
|
|
3389
|
+
inlineStyles
|
|
3390
|
+
};
|
|
3391
|
+
}
|
|
3392
|
+
function evaluateObjKey(prop, traversalState, functions) {
|
|
3393
|
+
const keyPath = prop.get("key");
|
|
3394
|
+
let key;
|
|
3395
|
+
if (prop.node.computed) {
|
|
3396
|
+
const result = evaluate(keyPath, traversalState, functions);
|
|
3397
|
+
if (!result.confident) {
|
|
3398
|
+
return {
|
|
3399
|
+
confident: false,
|
|
3400
|
+
deopt: result.deopt
|
|
3401
|
+
};
|
|
3402
|
+
}
|
|
3403
|
+
key = result.value;
|
|
3404
|
+
} else if (isIdentifier(keyPath)) {
|
|
3405
|
+
key = keyPath.node.name;
|
|
3406
|
+
} else {
|
|
3407
|
+
key = keyPath.node.value;
|
|
3408
|
+
}
|
|
3409
|
+
return {
|
|
3410
|
+
confident: true,
|
|
3411
|
+
value: String(key)
|
|
3412
|
+
};
|
|
3413
|
+
}
|
|
3414
|
+
|
|
2915
3415
|
function transformStyleXCreate(path, state) {
|
|
2916
3416
|
const {
|
|
2917
3417
|
node
|
|
@@ -2926,7 +3426,6 @@ function transformStyleXCreate(path, state) {
|
|
|
2926
3426
|
if (!isObjectExpression(firstArg)) {
|
|
2927
3427
|
throw new Error(messages_1.ILLEGAL_ARGUMENT_LENGTH);
|
|
2928
3428
|
}
|
|
2929
|
-
preProcessStyleArg(firstArg, state);
|
|
2930
3429
|
state.inStyleXCreate = true;
|
|
2931
3430
|
const injectedKeyframes = {};
|
|
2932
3431
|
function keyframes(animation) {
|
|
@@ -2969,8 +3468,9 @@ function transformStyleXCreate(path, state) {
|
|
|
2969
3468
|
});
|
|
2970
3469
|
const {
|
|
2971
3470
|
confident,
|
|
2972
|
-
value
|
|
2973
|
-
|
|
3471
|
+
value,
|
|
3472
|
+
fns
|
|
3473
|
+
} = evaluateStyleXCreateArg(firstArg, state, {
|
|
2974
3474
|
identifiers,
|
|
2975
3475
|
memberExpressions
|
|
2976
3476
|
});
|
|
@@ -3003,7 +3503,26 @@ function transformStyleXCreate(path, state) {
|
|
|
3003
3503
|
state.styleMap.set(varName, compiledStyles);
|
|
3004
3504
|
state.styleVars.set(varName, path.parentPath);
|
|
3005
3505
|
}
|
|
3006
|
-
|
|
3506
|
+
const resultAst = convertObjectToAST(compiledStyles);
|
|
3507
|
+
if (fns != null) {
|
|
3508
|
+
resultAst.properties = resultAst.properties.map(prop => {
|
|
3509
|
+
if (t__namespace.isObjectProperty(prop)) {
|
|
3510
|
+
const key = prop.key.type === "Identifier" && !prop.computed ? prop.key.name : prop.key.type === "StringLiteral" ? prop.key.value : null;
|
|
3511
|
+
if (key != null && Object.keys(fns).includes(key)) {
|
|
3512
|
+
const [params, inlineStyles] = fns[key];
|
|
3513
|
+
if (t__namespace.isExpression(prop.value)) {
|
|
3514
|
+
const value = prop.value;
|
|
3515
|
+
prop.value = t__namespace.arrowFunctionExpression(params, t__namespace.arrayExpression([value, t__namespace.objectExpression(Object.entries(inlineStyles).map(_ref => {
|
|
3516
|
+
let [key, value] = _ref;
|
|
3517
|
+
return t__namespace.objectProperty(t__namespace.stringLiteral(key), value);
|
|
3518
|
+
}))]));
|
|
3519
|
+
}
|
|
3520
|
+
}
|
|
3521
|
+
}
|
|
3522
|
+
return prop;
|
|
3523
|
+
});
|
|
3524
|
+
}
|
|
3525
|
+
path.replaceWith(resultAst);
|
|
3007
3526
|
if (Object.keys(injectedStyles).length === 0) {
|
|
3008
3527
|
return;
|
|
3009
3528
|
}
|
|
@@ -3051,25 +3570,6 @@ function findNearestStatementAncestor(path) {
|
|
|
3051
3570
|
}
|
|
3052
3571
|
return findNearestStatementAncestor(path.parentPath);
|
|
3053
3572
|
}
|
|
3054
|
-
function preProcessStyleArg(objPath, state) {
|
|
3055
|
-
objPath.traverse({
|
|
3056
|
-
SpreadElement(path) {
|
|
3057
|
-
const argument = path.get("argument");
|
|
3058
|
-
if (!isTypeCastExpression(argument)) {
|
|
3059
|
-
return;
|
|
3060
|
-
}
|
|
3061
|
-
const expression = argument.get("expression");
|
|
3062
|
-
if (!isIdentifier(expression) && !isMemberExpression(expression)) {
|
|
3063
|
-
throw new Error(messages_1.ILLEGAL_NAMESPACE_VALUE);
|
|
3064
|
-
}
|
|
3065
|
-
if (!(isObjectExpression(path.parentPath) && isObjectProperty(path.parentPath.parentPath) && isObjectExpression(path.parentPath.parentPath.parentPath) && isCallExpression(path.parentPath.parentPath.parentPath.parentPath))) {
|
|
3066
|
-
throw new Error(messages_1.ILLEGAL_NESTED_PSEUDO);
|
|
3067
|
-
}
|
|
3068
|
-
const stylexName = getStylexDefaultImport(path, state);
|
|
3069
|
-
argument.replaceWith(t__namespace.callExpression(t__namespace.memberExpression(t__namespace.identifier(stylexName), t__namespace.identifier("include")), [expression.node]));
|
|
3070
|
-
}
|
|
3071
|
-
});
|
|
3072
|
-
}
|
|
3073
3573
|
function getStylexDefaultImport(path, state) {
|
|
3074
3574
|
const statementPath = findNearestStatementAncestor(path);
|
|
3075
3575
|
let stylexName;
|
|
@@ -3102,10 +3602,15 @@ function transformStyleXCreateVars(callExpressionPath, state) {
|
|
|
3102
3602
|
const varId = variableDeclaratorNode.id;
|
|
3103
3603
|
const args = callExpressionPath.get("arguments");
|
|
3104
3604
|
const firstArg = args[0];
|
|
3605
|
+
const identifiers = {};
|
|
3606
|
+
const memberExpressions = {};
|
|
3105
3607
|
const {
|
|
3106
3608
|
confident,
|
|
3107
3609
|
value
|
|
3108
|
-
} = evaluate(firstArg, state
|
|
3610
|
+
} = evaluate(firstArg, state, {
|
|
3611
|
+
identifiers,
|
|
3612
|
+
memberExpressions
|
|
3613
|
+
});
|
|
3109
3614
|
if (!confident) {
|
|
3110
3615
|
throw new Error(messages_1.NON_STATIC_VALUE);
|
|
3111
3616
|
}
|
|
@@ -3490,7 +3995,7 @@ Object.defineProperty(stylex$1, "__esModule", {
|
|
|
3490
3995
|
});
|
|
3491
3996
|
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;
|
|
3492
3997
|
stylex$1.spread = spread;
|
|
3493
|
-
stylex$1.unstable_overrideVars = stylex$1.unstable_createVars = stylex$1.stylex = void 0;
|
|
3998
|
+
stylex$1.unstable_overrideVars = stylex$1.unstable_createVars = stylex$1.types = stylex$1.stylex = void 0;
|
|
3494
3999
|
var _stylexInject = _interopRequireDefault(stylexInject);
|
|
3495
4000
|
var _styleq = require$$1;
|
|
3496
4001
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -3521,6 +4026,49 @@ const unstable_overrideVars = stylexOverrideVars;
|
|
|
3521
4026
|
stylex$1.unstable_overrideVars = unstable_overrideVars;
|
|
3522
4027
|
const include = stylexIncludes;
|
|
3523
4028
|
stylex$1.include = include;
|
|
4029
|
+
const types = {
|
|
4030
|
+
angle: _v => {
|
|
4031
|
+
throw new Error(errorForType("angle"));
|
|
4032
|
+
},
|
|
4033
|
+
color: _v => {
|
|
4034
|
+
throw new Error(errorForType("color"));
|
|
4035
|
+
},
|
|
4036
|
+
url: _v => {
|
|
4037
|
+
throw new Error(errorForType("url"));
|
|
4038
|
+
},
|
|
4039
|
+
image: _v => {
|
|
4040
|
+
throw new Error(errorForType("image"));
|
|
4041
|
+
},
|
|
4042
|
+
integer: _v => {
|
|
4043
|
+
throw new Error(errorForType("integer"));
|
|
4044
|
+
},
|
|
4045
|
+
lengthPercentage: _v => {
|
|
4046
|
+
throw new Error(errorForType("lengthPercentage"));
|
|
4047
|
+
},
|
|
4048
|
+
length: _v => {
|
|
4049
|
+
throw new Error(errorForType("length"));
|
|
4050
|
+
},
|
|
4051
|
+
percentage: _v => {
|
|
4052
|
+
throw new Error(errorForType("percentage"));
|
|
4053
|
+
},
|
|
4054
|
+
number: _v => {
|
|
4055
|
+
throw new Error(errorForType("number"));
|
|
4056
|
+
},
|
|
4057
|
+
resolution: _v => {
|
|
4058
|
+
throw new Error(errorForType("resolution"));
|
|
4059
|
+
},
|
|
4060
|
+
time: _v => {
|
|
4061
|
+
throw new Error(errorForType("time"));
|
|
4062
|
+
},
|
|
4063
|
+
transformFunction: _v => {
|
|
4064
|
+
throw new Error(errorForType("transformFunction"));
|
|
4065
|
+
},
|
|
4066
|
+
transformList: _v => {
|
|
4067
|
+
throw new Error(errorForType("transformList"));
|
|
4068
|
+
}
|
|
4069
|
+
};
|
|
4070
|
+
stylex$1.types = types;
|
|
4071
|
+
const errorForType = type => `stylex.types.${type} should be compiled away by @stylexjs/babel-plugin`;
|
|
3524
4072
|
const keyframes = _keyframes => {
|
|
3525
4073
|
throw new Error("stylex.keyframes should never be called");
|
|
3526
4074
|
};
|
|
@@ -3551,10 +4099,11 @@ _stylex.keyframes = keyframes;
|
|
|
3551
4099
|
_stylex.firstThatWorks = firstThatWorks;
|
|
3552
4100
|
_stylex.inject = inject;
|
|
3553
4101
|
_stylex.UNSUPPORTED_PROPERTY = UNSUPPORTED_PROPERTY;
|
|
3554
|
-
|
|
3555
|
-
var default_1 = stylex$1.default = _default;
|
|
4102
|
+
_stylex.types = types;
|
|
3556
4103
|
const stylex = _stylex;
|
|
3557
4104
|
stylex$1.stylex = stylex;
|
|
4105
|
+
var _default = _stylex;
|
|
4106
|
+
var default_1 = stylex$1.default = _default;
|
|
3558
4107
|
|
|
3559
4108
|
function skipStylexMergeChildren(path, state) {
|
|
3560
4109
|
const {
|
|
@@ -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.
|
|
3
|
+
"version": "0.2.0-beta.21",
|
|
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.
|
|
15
|
+
"@stylexjs/shared": "0.2.0-beta.21"
|
|
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/*",
|