@stylexjs/babel-plugin 0.2.0-beta.24 → 0.2.0-beta.26
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/README.md +1 -1
- package/flow_modules/@babel/core/index.js.flow +1 -0
- package/lib/index.js +56 -46
- package/lib/utils/evaluate-path.d.ts +0 -16
- package/lib/utils/evaluate-path.js.flow +0 -16
- package/lib/utils/state-manager.d.ts +2 -0
- package/lib/utils/state-manager.js.flow +2 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ by passing them to the functions of the corresponding names within `@stylex/shar
|
|
|
14
14
|
|
|
15
15
|
## Babel Metadata
|
|
16
16
|
|
|
17
|
-
The StyleX Babel plugin does more than transform
|
|
17
|
+
The StyleX Babel plugin does more than transform JavaScript (or Typescript) files. It also returns a list of injected styles. The way that such a value can be returned while transforming a JS file is by using Babel's `metadata` API.
|
|
18
18
|
|
|
19
19
|
An example of this can be seen in some of the tests, but the result of using Babel's `transform(...)` function returns an object contains at least two keys:
|
|
20
20
|
|
package/lib/index.js
CHANGED
|
@@ -30,6 +30,7 @@ var t__namespace = /*#__PURE__*/_interopNamespaceDefault(t);
|
|
|
30
30
|
var name = "@stylexjs/stylex";
|
|
31
31
|
|
|
32
32
|
class StateManager {
|
|
33
|
+
importPaths = new Set();
|
|
33
34
|
stylexImport = new Set();
|
|
34
35
|
stylexPropsImport = new Set();
|
|
35
36
|
stylexCreateImport = new Set();
|
|
@@ -64,6 +65,15 @@ class StateManager {
|
|
|
64
65
|
this._state.opts = opts;
|
|
65
66
|
return this._state.opts;
|
|
66
67
|
}
|
|
68
|
+
get importPathString() {
|
|
69
|
+
if (this.importPaths.has('@stylexjs/stylex')) {
|
|
70
|
+
return '@stylexjs/stylex';
|
|
71
|
+
}
|
|
72
|
+
if (this.importPaths.size > 0) {
|
|
73
|
+
return [...this.importPaths][0];
|
|
74
|
+
}
|
|
75
|
+
return '@stylexjs/stylex';
|
|
76
|
+
}
|
|
67
77
|
get canReferenceTheme() {
|
|
68
78
|
return !!this.inStyleXCreate;
|
|
69
79
|
}
|
|
@@ -149,7 +159,7 @@ const filePathResolver = (relativeFilePath, sourceFilePath) => {
|
|
|
149
159
|
const fileToLookFor = relativeFilePath;
|
|
150
160
|
if (EXTENSIONS.some(ext => fileToLookFor.endsWith(ext))) {
|
|
151
161
|
try {
|
|
152
|
-
const resolvedFilePath =
|
|
162
|
+
const resolvedFilePath = require.resolve(fileToLookFor, {
|
|
153
163
|
paths: [path.dirname(sourceFilePath)]
|
|
154
164
|
});
|
|
155
165
|
return resolvedFilePath;
|
|
@@ -157,7 +167,8 @@ const filePathResolver = (relativeFilePath, sourceFilePath) => {
|
|
|
157
167
|
}
|
|
158
168
|
for (const ext of EXTENSIONS) {
|
|
159
169
|
try {
|
|
160
|
-
const
|
|
170
|
+
const importPathStr = fileToLookFor.startsWith('.') ? fileToLookFor + ext : fileToLookFor;
|
|
171
|
+
const resolvedFilePath = require.resolve(importPathStr, {
|
|
161
172
|
paths: [path.dirname(sourceFilePath)]
|
|
162
173
|
});
|
|
163
174
|
return resolvedFilePath;
|
|
@@ -182,6 +193,7 @@ function readImportDeclarations(path, state) {
|
|
|
182
193
|
return;
|
|
183
194
|
}
|
|
184
195
|
if (state.options.importSources.includes(node.source.value)) {
|
|
196
|
+
state.importPaths.add(node.source.value);
|
|
185
197
|
for (const specifier of node.specifiers) {
|
|
186
198
|
if (specifier.type === 'ImportDefaultSpecifier') {
|
|
187
199
|
state.stylexImport.add(specifier.local.name);
|
|
@@ -250,7 +262,10 @@ function readRequires(path, state) {
|
|
|
250
262
|
const {
|
|
251
263
|
node
|
|
252
264
|
} = path;
|
|
253
|
-
|
|
265
|
+
const init = node.init;
|
|
266
|
+
if (init != null && init.type === 'CallExpression' && init.callee?.type === 'Identifier' && init.callee?.name === 'require' && init.arguments?.length === 1 && init.arguments?.[0].type === 'StringLiteral' && state.options.importSources.includes(init.arguments[0].value)) {
|
|
267
|
+
const importPath = init.arguments[0].value;
|
|
268
|
+
importPath != null && state.importPaths.add(importPath);
|
|
254
269
|
if (node.id.type === 'Identifier') {
|
|
255
270
|
state.stylexImport.add(node.id.name);
|
|
256
271
|
}
|
|
@@ -525,33 +540,15 @@ const shorthands$2 = {
|
|
|
525
540
|
animationRange: value => [['animationRange', value], ['animationRangeEnd', null], ['animationRangeStart', null]],
|
|
526
541
|
background: value => [['background', value], ['backgroundAttachment', null], ['backgroundClip', null], ['backgroundColor', null], ['backgroundImage', null], ['backgroundOrigin', null], ...shorthands$2.backgroundPosition(null), ['backgroundRepeat', null], ['backgroundSize', null]],
|
|
527
542
|
backgroundPosition: value => [['backgroundPosition', value], ['backgroundPositionX', null], ['backgroundPositionY', null]],
|
|
528
|
-
border:
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
borderTop: _rawValue => {
|
|
538
|
-
throw new Error(['`borderTop` is not supported.', 'Use `borderTopWidth`, `borderTopStyle` and `borderTopColor`,'].join(' '));
|
|
539
|
-
},
|
|
540
|
-
borderInlineEnd: _rawValue => {
|
|
541
|
-
throw new Error('`borderInlineEnd` shorthand is not supported. Use `borderInlineEndWidth`, `borderInlineEndStyle` and `borderInlineEndColor` instead.');
|
|
542
|
-
},
|
|
543
|
-
borderRight: _rawValue => {
|
|
544
|
-
throw new Error('`borderRight` shorthand is not supported. Use `borderRightWidth`, `borderRightStyle` and `borderRightColor` instead.');
|
|
545
|
-
},
|
|
546
|
-
borderBottom: _rawValue => {
|
|
547
|
-
throw new Error('`borderBottom` shorthand is not supported. Use `borderBottomWidth`, `borderBottomStyle` and `borderBottomColor` instead.');
|
|
548
|
-
},
|
|
549
|
-
borderInlineStart: _rawValue => {
|
|
550
|
-
throw new Error('`borderInlineStart` shorthand is not supported. Use `borderInlineStartWidth`, `borderInlineStartStyle` and `borderInlineStartColor` instead.');
|
|
551
|
-
},
|
|
552
|
-
borderLeft: _rawValue => {
|
|
553
|
-
throw new Error(['`borderLeft` is not supported.', 'You could use `borderLeftWidth`, `borderLeftStyle` and `borderLeftColor`,', 'but it is preferable to use `borderInlineStartWidth`, `borderInlineStartStyle` and `borderInlineStartColor`.'].join(' '));
|
|
554
|
-
},
|
|
543
|
+
border: rawValue => [['border', rawValue], ...shorthands$2.borderWidth(null), ...shorthands$2.borderStyle(null), ...shorthands$2.borderColor(null)],
|
|
544
|
+
borderInline: rawValue => [['borderInline', rawValue], ...shorthands$2.borderInlineWidth(null), ...shorthands$2.borderInlineStyle(null), ...shorthands$2.borderInlineColor(null)],
|
|
545
|
+
borderBlock: rawValue => [['borderBlock', rawValue], ...shorthands$2.borderBlockWidth(null), ...shorthands$2.borderBlockStyle(null), ...shorthands$2.borderBlockColor(null)],
|
|
546
|
+
borderTop: rawValue => [['borderTop', rawValue], ['borderTopWidth', null], ['borderTopStyle', null], ['borderTopColor', null]],
|
|
547
|
+
borderInlineEnd: rawValue => [['borderInlineEnd', rawValue], ...shorthands$2.borderInlineEndWidth(null), ...shorthands$2.borderInlineEndStyle(null), ...shorthands$2.borderInlineEndColor(null)],
|
|
548
|
+
borderRight: rawValue => [['borderRight', rawValue], ...shorthands$2.borderRightWidth(null), ...shorthands$2.borderRightStyle(null), ...shorthands$2.borderRightColor(null)],
|
|
549
|
+
borderBottom: rawValue => [['borderBottom', rawValue], ['borderBottomWidth', null], ['borderBottomStyle', null], ['borderBottomColor', null]],
|
|
550
|
+
borderInlineStart: _rawValue => [['borderInlineStart', null], ...shorthands$2.borderInlineStartWidth(null), ...shorthands$2.borderInlineStartStyle(null), ...shorthands$2.borderInlineStartColor(null)],
|
|
551
|
+
borderLeft: _rawValue => [['borderLeft', null], ...shorthands$2.borderLeftWidth(null), ...shorthands$2.borderLeftStyle(null), ...shorthands$2.borderLeftColor(null)],
|
|
555
552
|
borderInlineWidth: rawValue => [['borderInlineWidth', rawValue], ['borderInlineStartWidth', null], ['borderLeftWidth', null], ['borderInlineEndWidth', null], ['borderRightWidth', null]],
|
|
556
553
|
borderInlineStyle: rawValue => [['borderInlineStyle', rawValue], ['borderInlineStartStyle', null], ['borderLeftStyle', null], ['borderInlineEndStyle', null], ['borderRightStyle', null]],
|
|
557
554
|
borderInlineColor: rawValue => [['borderInlineColor', rawValue], ['borderInlineStartColor', null], ['borderLeftColor', null], ['borderInlineEndColor', null], ['borderRightColor', null]],
|
|
@@ -1293,7 +1290,7 @@ var _normalizeValue = _interopRequireDefault$a(normalizeValue$1);
|
|
|
1293
1290
|
function _interopRequireDefault$a(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1294
1291
|
function transformValue(key, rawValue) {
|
|
1295
1292
|
const value = typeof rawValue === 'number' ? String(Math.round(rawValue * 10000) / 10000) + getNumberSuffix(key) : rawValue;
|
|
1296
|
-
if (key === 'content' && typeof value === 'string') {
|
|
1293
|
+
if ((key === 'content' || key === 'hyphenateCharacter' || key === 'hyphenate-character') && typeof value === 'string') {
|
|
1297
1294
|
const val = value.trim();
|
|
1298
1295
|
if (val.match(/^attr\([a-zA-Z0-9-]+\)$/)) {
|
|
1299
1296
|
return val;
|
|
@@ -1315,7 +1312,7 @@ function getNumberSuffix(key) {
|
|
|
1315
1312
|
return suffix;
|
|
1316
1313
|
}
|
|
1317
1314
|
}
|
|
1318
|
-
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', 'scale']);
|
|
1315
|
+
const unitlessNumberProperties = new Set(['WebkitLineClamp', 'animationIterationCount', 'aspectRatio', 'borderImageOutset', 'borderImageSlice', 'borderImageWidth', 'counterSet', 'columnCount', 'flex', 'flexGrow', 'flexPositive', 'flexShrink', 'flexOrder', 'gridRow', 'gridColumn', 'fontWeight', 'hyphenateLimitChars', 'lineClamp', 'lineHeight', 'maskBorderOutset', 'maskBorderSlice', 'maskBorderWidth', 'opacity', 'order', 'orphans', 'tabSize', 'widows', 'zIndex', 'fillOpacity', 'floodOpacity', 'rotate', 'scale', 'stopOpacity', 'strokeDasharray', 'strokeDashoffset', 'strokeMiterlimit', 'strokeOpacity', 'strokeWidth', 'scale', 'mathDepth']);
|
|
1319
1316
|
const numberPropertySuffixes = {
|
|
1320
1317
|
animationDelay: 'ms',
|
|
1321
1318
|
animationDuration: 'ms',
|
|
@@ -1973,7 +1970,6 @@ longHandLogical.add('inset-inline-end');
|
|
|
1973
1970
|
longHandPhysical.add('right');
|
|
1974
1971
|
longHandLogical.add('clear');
|
|
1975
1972
|
longHandLogical.add('float');
|
|
1976
|
-
longHandLogical.add('overlay');
|
|
1977
1973
|
longHandLogical.add('position');
|
|
1978
1974
|
longHandLogical.add('z-index');
|
|
1979
1975
|
longHandLogical.add('ruby-align');
|
|
@@ -2003,14 +1999,8 @@ longHandPhysical.add('scroll-padding-left');
|
|
|
2003
1999
|
longHandLogical.add('scroll-padding-inline-end');
|
|
2004
2000
|
longHandPhysical.add('scroll-padding-right');
|
|
2005
2001
|
longHandLogical.add('scroll-snap-align');
|
|
2006
|
-
longHandLogical.add('scroll-snap-coordinate');
|
|
2007
|
-
longHandLogical.add('scroll-snap-destination');
|
|
2008
|
-
longHandLogical.add('scroll-snap-points-x');
|
|
2009
|
-
longHandLogical.add('scroll-snap-points-y');
|
|
2010
2002
|
longHandLogical.add('scroll-snap-stop');
|
|
2011
2003
|
shorthandsOfLonghands.add('scroll-snap-type');
|
|
2012
|
-
longHandLogical.add('scroll-snap-type-x');
|
|
2013
|
-
longHandLogical.add('scroll-snap-type-y');
|
|
2014
2004
|
longHandLogical.add('scrollbar-color');
|
|
2015
2005
|
longHandLogical.add('scrollbar-width');
|
|
2016
2006
|
longHandLogical.add('shape-image-threshold');
|
|
@@ -2055,7 +2045,6 @@ longHandLogical.add('text-transform');
|
|
|
2055
2045
|
longHandLogical.add('text-wrap');
|
|
2056
2046
|
longHandLogical.add('white-space');
|
|
2057
2047
|
longHandLogical.add('white-space-collapse');
|
|
2058
|
-
longHandLogical.add('white-space-trim');
|
|
2059
2048
|
longHandLogical.add('word-break');
|
|
2060
2049
|
longHandLogical.add('word-spacing');
|
|
2061
2050
|
longHandLogical.add('word-wrap');
|
|
@@ -2070,7 +2059,6 @@ longHandLogical.add('transform-origin');
|
|
|
2070
2059
|
longHandLogical.add('transform-style');
|
|
2071
2060
|
longHandLogical.add('translate');
|
|
2072
2061
|
shorthandsOfLonghands.add('transition');
|
|
2073
|
-
longHandLogical.add('transition-behavior');
|
|
2074
2062
|
longHandLogical.add('transition-delay');
|
|
2075
2063
|
longHandLogical.add('transition-duration');
|
|
2076
2064
|
longHandLogical.add('transition-property');
|
|
@@ -3108,6 +3096,9 @@ function isImportDeclaration(path, props) {
|
|
|
3108
3096
|
function isImportDefaultSpecifier(path, props) {
|
|
3109
3097
|
return path.isImportDefaultSpecifier(props);
|
|
3110
3098
|
}
|
|
3099
|
+
function isImportNamespaceSpecifier(path, props) {
|
|
3100
|
+
return path.isImportNamespaceSpecifier(props);
|
|
3101
|
+
}
|
|
3111
3102
|
function isImportSpecifier(path, props) {
|
|
3112
3103
|
return path.isImportSpecifier(props);
|
|
3113
3104
|
}
|
|
@@ -3147,6 +3138,9 @@ function isStatement(path, props) {
|
|
|
3147
3138
|
function isStringLiteral(path, props) {
|
|
3148
3139
|
return path.isStringLiteral(props);
|
|
3149
3140
|
}
|
|
3141
|
+
function isTSAsExpression(path, props) {
|
|
3142
|
+
return path.isTSAsExpression(props);
|
|
3143
|
+
}
|
|
3150
3144
|
function isTaggedTemplateExpression(path, props) {
|
|
3151
3145
|
return path.isTaggedTemplateExpression(props);
|
|
3152
3146
|
}
|
|
@@ -3302,6 +3296,14 @@ function _evaluate(path, state) {
|
|
|
3302
3296
|
return state.functions.identifiers[name];
|
|
3303
3297
|
}
|
|
3304
3298
|
}
|
|
3299
|
+
if (isTSAsExpression(path)) {
|
|
3300
|
+
const expr = path.get('expression');
|
|
3301
|
+
return evaluateCached(expr, state);
|
|
3302
|
+
}
|
|
3303
|
+
if (path.node.type === 'TSSatisfiesExpression') {
|
|
3304
|
+
const expr = path.get('expression');
|
|
3305
|
+
return evaluateCached(expr, state);
|
|
3306
|
+
}
|
|
3305
3307
|
if (isSequenceExpression(path)) {
|
|
3306
3308
|
const exprs = path.get('expressions');
|
|
3307
3309
|
return evaluateCached(exprs[exprs.length - 1], state);
|
|
@@ -3365,7 +3367,7 @@ function _evaluate(path, state) {
|
|
|
3365
3367
|
if (isReferencedIdentifier(path)) {
|
|
3366
3368
|
const binding = path.scope?.getBinding(path.node.name);
|
|
3367
3369
|
const bindingPath = binding?.path;
|
|
3368
|
-
if (binding && bindingPath && !isImportDefaultSpecifier(bindingPath) && isImportSpecifier(bindingPath)) {
|
|
3370
|
+
if (binding && bindingPath && !isImportDefaultSpecifier(bindingPath) && !isImportNamespaceSpecifier(bindingPath) && isImportSpecifier(bindingPath)) {
|
|
3369
3371
|
const importSpecifierPath = bindingPath;
|
|
3370
3372
|
const importSpecifierNode = importSpecifierPath.node;
|
|
3371
3373
|
const imported = importSpecifierNode.imported;
|
|
@@ -3379,6 +3381,10 @@ function _evaluate(path, state) {
|
|
|
3379
3381
|
const [type, value] = absPath;
|
|
3380
3382
|
const returnValue = type === 'themeNameRef' ? evaluateThemeRef(value, importedName, state) : evaluateImportedFile(value, importedName, state);
|
|
3381
3383
|
if (state.confident) {
|
|
3384
|
+
if (!state.addedImports.has(importPath.node.source.value)) {
|
|
3385
|
+
importPath.insertBefore(t__namespace.importDeclaration([], importPath.node.source));
|
|
3386
|
+
state.addedImports.add(importPath.node.source.value);
|
|
3387
|
+
}
|
|
3382
3388
|
return returnValue;
|
|
3383
3389
|
} else {
|
|
3384
3390
|
deopt(binding.path, state);
|
|
@@ -3647,15 +3653,19 @@ function evaluateQuasis(path, quasis, state) {
|
|
|
3647
3653
|
if (!state.confident) return;
|
|
3648
3654
|
return str;
|
|
3649
3655
|
}
|
|
3656
|
+
const importsForState = new WeakMap();
|
|
3650
3657
|
function evaluate(path, traversalState) {
|
|
3651
3658
|
let functions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
3652
3659
|
identifiers: {},
|
|
3653
3660
|
memberExpressions: {}
|
|
3654
3661
|
};
|
|
3662
|
+
const addedImports = importsForState.get(traversalState) ?? new Set();
|
|
3663
|
+
importsForState.set(traversalState, addedImports);
|
|
3655
3664
|
const state = {
|
|
3656
3665
|
confident: true,
|
|
3657
3666
|
deoptPath: null,
|
|
3658
3667
|
seen: new Map(),
|
|
3668
|
+
addedImports,
|
|
3659
3669
|
functions,
|
|
3660
3670
|
traversalState
|
|
3661
3671
|
};
|
|
@@ -4001,7 +4011,7 @@ function getStylexDefaultImport(path, state) {
|
|
|
4001
4011
|
});
|
|
4002
4012
|
if (stylexName == null) {
|
|
4003
4013
|
stylexName = '__stylex__';
|
|
4004
|
-
statementPath.insertBefore(t__namespace.importDeclaration([t__namespace.importDefaultSpecifier(t__namespace.identifier(stylexName))], t__namespace.stringLiteral(
|
|
4014
|
+
statementPath.insertBefore(t__namespace.importDeclaration([t__namespace.importDefaultSpecifier(t__namespace.identifier(stylexName))], t__namespace.stringLiteral(state.importPathString)));
|
|
4005
4015
|
state.stylexImport.add(stylexName);
|
|
4006
4016
|
}
|
|
4007
4017
|
return stylexName;
|
|
@@ -4070,7 +4080,7 @@ function transformStyleXDefineVars(callExpressionPath, state) {
|
|
|
4070
4080
|
});
|
|
4071
4081
|
if (stylexName == null) {
|
|
4072
4082
|
stylexName = '__stylex__';
|
|
4073
|
-
statementPath.insertBefore(t__namespace.importDeclaration([t__namespace.importDefaultSpecifier(t__namespace.identifier(stylexName))], t__namespace.stringLiteral(
|
|
4083
|
+
statementPath.insertBefore(t__namespace.importDeclaration([t__namespace.importDefaultSpecifier(t__namespace.identifier(stylexName))], t__namespace.stringLiteral(state.importPathString)));
|
|
4074
4084
|
}
|
|
4075
4085
|
statementPath.insertBefore(t__namespace.expressionStatement(t__namespace.callExpression(t__namespace.memberExpression(t__namespace.identifier(stylexName), t__namespace.identifier('inject')), [t__namespace.stringLiteral(css), t__namespace.numericLiteral(0)])));
|
|
4076
4086
|
}
|
|
@@ -4151,7 +4161,7 @@ function transformStyleXCreateTheme(callExpressionPath, state) {
|
|
|
4151
4161
|
});
|
|
4152
4162
|
if (stylexName == null) {
|
|
4153
4163
|
stylexName = '__stylex__';
|
|
4154
|
-
statementPath?.insertBefore(t__namespace.importDeclaration([t__namespace.importDefaultSpecifier(t__namespace.identifier(stylexName))], t__namespace.stringLiteral(
|
|
4164
|
+
statementPath?.insertBefore(t__namespace.importDeclaration([t__namespace.importDefaultSpecifier(t__namespace.identifier(stylexName))], t__namespace.stringLiteral(state.importPathString)));
|
|
4155
4165
|
}
|
|
4156
4166
|
statementPath?.insertBefore(t__namespace.expressionStatement(t__namespace.callExpression(t__namespace.memberExpression(t__namespace.identifier(stylexName), t__namespace.identifier('inject')), [t__namespace.stringLiteral(css[styleKey].ltr), t__namespace.numericLiteral(css[styleKey].priority)])));
|
|
4157
4167
|
}
|
|
@@ -4218,7 +4228,7 @@ function transformStyleXKeyframes(path, state) {
|
|
|
4218
4228
|
});
|
|
4219
4229
|
if (stylexName == null) {
|
|
4220
4230
|
stylexName = '__stylex__';
|
|
4221
|
-
statementPath.insertBefore(t__namespace.importDeclaration([t__namespace.importDefaultSpecifier(t__namespace.identifier(stylexName))], t__namespace.stringLiteral(
|
|
4231
|
+
statementPath.insertBefore(t__namespace.importDeclaration([t__namespace.importDefaultSpecifier(t__namespace.identifier(stylexName))], t__namespace.stringLiteral(state.importPathString)));
|
|
4222
4232
|
}
|
|
4223
4233
|
statementPath.insertBefore(t__namespace.expressionStatement(t__namespace.callExpression(t__namespace.memberExpression(t__namespace.identifier(stylexName), t__namespace.identifier('inject')), [t__namespace.stringLiteral(ltr), t__namespace.numericLiteral(priority), ...(rtl != null ? [t__namespace.stringLiteral(rtl)] : [])])));
|
|
4224
4234
|
}
|
|
@@ -22,22 +22,6 @@ export type FunctionConfig = {
|
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
|
-
/**
|
|
26
|
-
* Walk the input `node` and statically evaluate it.
|
|
27
|
-
*
|
|
28
|
-
* Returns an object in the form `{ confident, value, deopt }`. `confident`
|
|
29
|
-
* indicates whether or not we had to drop out of evaluating the expression
|
|
30
|
-
* because of hitting an unknown node that we couldn't confidently find the
|
|
31
|
-
* value of, in which case `deopt` is the path of said node.
|
|
32
|
-
*
|
|
33
|
-
* Example:
|
|
34
|
-
*
|
|
35
|
-
* evaluate(parse("5 + 5")) // { confident: true, value: 10 }
|
|
36
|
-
* evaluate(parse("!true")) // { confident: true, value: false }
|
|
37
|
-
* evaluate(parse("foo + foo")) // { confident: false, value: undefined, deopt: NodePath }
|
|
38
|
-
*
|
|
39
|
-
*/
|
|
40
|
-
|
|
41
25
|
export declare function evaluate(
|
|
42
26
|
path: NodePath,
|
|
43
27
|
traversalState: StateManager,
|
|
@@ -26,22 +26,6 @@ export type FunctionConfig = {
|
|
|
26
26
|
},
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
/**
|
|
30
|
-
* Walk the input `node` and statically evaluate it.
|
|
31
|
-
*
|
|
32
|
-
* Returns an object in the form `{ confident, value, deopt }`. `confident`
|
|
33
|
-
* indicates whether or not we had to drop out of evaluating the expression
|
|
34
|
-
* because of hitting an unknown node that we couldn't confidently find the
|
|
35
|
-
* value of, in which case `deopt` is the path of said node.
|
|
36
|
-
*
|
|
37
|
-
* Example:
|
|
38
|
-
*
|
|
39
|
-
* evaluate(parse("5 + 5")) // { confident: true, value: 10 }
|
|
40
|
-
* evaluate(parse("!true")) // { confident: true, value: false }
|
|
41
|
-
* evaluate(parse("foo + foo")) // { confident: false, value: undefined, deopt: NodePath }
|
|
42
|
-
*
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
29
|
declare export function evaluate(
|
|
46
30
|
path: NodePath<>,
|
|
47
31
|
traversalState: StateManager,
|
|
@@ -38,6 +38,7 @@ type StyleXOptions = Omit<
|
|
|
38
38
|
};
|
|
39
39
|
declare class StateManager {
|
|
40
40
|
readonly _state: PluginPass;
|
|
41
|
+
readonly importPaths: Set<string>;
|
|
41
42
|
readonly stylexImport: Set<string>;
|
|
42
43
|
readonly stylexPropsImport: Set<string>;
|
|
43
44
|
readonly stylexCreateImport: Set<string>;
|
|
@@ -53,6 +54,7 @@ declare class StateManager {
|
|
|
53
54
|
inStyleXCreate: boolean;
|
|
54
55
|
constructor(state: PluginPass);
|
|
55
56
|
get options(): StyleXOptions;
|
|
57
|
+
get importPathString(): string;
|
|
56
58
|
get canReferenceTheme(): boolean;
|
|
57
59
|
get metadata(): { [key: string]: any };
|
|
58
60
|
get stylexSheetName(): string | void;
|
|
@@ -43,6 +43,7 @@ type StyleXOptions = {
|
|
|
43
43
|
|
|
44
44
|
declare export default class StateManager {
|
|
45
45
|
+_state: PluginPass;
|
|
46
|
+
+importPaths: Set<string>;
|
|
46
47
|
+stylexImport: Set<string>;
|
|
47
48
|
+stylexPropsImport: Set<string>;
|
|
48
49
|
+stylexCreateImport: Set<string>;
|
|
@@ -58,6 +59,7 @@ declare export default class StateManager {
|
|
|
58
59
|
inStyleXCreate: boolean;
|
|
59
60
|
constructor(state: PluginPass): void;
|
|
60
61
|
get options(): StyleXOptions;
|
|
62
|
+
get importPathString(): string;
|
|
61
63
|
get canReferenceTheme(): boolean;
|
|
62
64
|
get metadata(): { [key: string]: any };
|
|
63
65
|
get stylexSheetName(): string | void;
|
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.26",
|
|
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.26"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
18
|
"@babel/core": "^7.19.6",
|