@stylexjs/babel-plugin 0.4.0 → 0.5.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/flow_modules/@babel/core/index.js.flow +1 -1
- package/lib/index.js +660 -75
- package/lib/utils/state-manager.d.ts +19 -11
- package/lib/utils/state-manager.js.flow +15 -13
- package/lib/utils/validate.d.ts +67 -0
- package/lib/utils/validate.js.flow +71 -0
- package/lib/visitors/stylex-attrs.d.ts +21 -0
- package/lib/visitors/stylex-attrs.js.flow +25 -0
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -6,7 +6,6 @@ var helperModuleImports = require('@babel/helper-module-imports');
|
|
|
6
6
|
var require$$0 = require('postcss-value-parser');
|
|
7
7
|
var core = require('@babel/core');
|
|
8
8
|
var traverse = require('@babel/traverse');
|
|
9
|
-
var require$$0$1 = require('styleq');
|
|
10
9
|
|
|
11
10
|
function _interopNamespaceDefault(e) {
|
|
12
11
|
var n = Object.create(null);
|
|
@@ -29,11 +28,150 @@ var t__namespace = /*#__PURE__*/_interopNamespaceDefault(t);
|
|
|
29
28
|
|
|
30
29
|
var name = "@stylexjs/stylex";
|
|
31
30
|
|
|
31
|
+
const defaultMessage = expected => (value, name) => name ? `Expected (${name}) to be ${expected}, but got \`${JSON.stringify(value)}\`.` : expected;
|
|
32
|
+
const defaultUnionMessage = expected => (value, name) => name ? `Expected (${name}) to be ${expected}` : expected;
|
|
33
|
+
const indent = str => str.split('\n').filter(line => !line.trim().startsWith('But got:')).map(line => line.includes(', but got') ? line.replace(/, but got.+$/, '') : line).map(line => line.trim()[0] === '-' ? line : `- ${line}`).map(line => `\n\t${line}`).join('');
|
|
34
|
+
const string = function () {
|
|
35
|
+
let message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultMessage('a string');
|
|
36
|
+
return (value, name) => {
|
|
37
|
+
if (typeof value !== 'string') {
|
|
38
|
+
return new Error(message(value, name));
|
|
39
|
+
}
|
|
40
|
+
return value;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
const nullish = function () {
|
|
44
|
+
let message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultMessage('`null` or `undefined`');
|
|
45
|
+
return (value, name) => value == null ? value : new Error(message(value, name));
|
|
46
|
+
};
|
|
47
|
+
const boolean = function () {
|
|
48
|
+
let message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultMessage('a boolean');
|
|
49
|
+
return (value, name) => {
|
|
50
|
+
if (typeof value !== 'boolean') {
|
|
51
|
+
return new Error(message(value, name));
|
|
52
|
+
}
|
|
53
|
+
return value;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
const literal = function (expected) {
|
|
57
|
+
let message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultMessage(`the literal ${JSON.stringify(expected)}`);
|
|
58
|
+
return (value, name) => {
|
|
59
|
+
if (value === expected) {
|
|
60
|
+
return expected;
|
|
61
|
+
}
|
|
62
|
+
return new Error(message(value, name));
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
const array = function (check) {
|
|
66
|
+
let message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultMessage('an array');
|
|
67
|
+
return function (value) {
|
|
68
|
+
let name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'array';
|
|
69
|
+
if (!Array.isArray(value)) {
|
|
70
|
+
return new Error(message(value, name));
|
|
71
|
+
}
|
|
72
|
+
const validated = value.map((item, i) => check(item, name ? `${name}[${i}]` : undefined));
|
|
73
|
+
const errors = validated.filter(item => item instanceof Error);
|
|
74
|
+
if (errors.length > 0) {
|
|
75
|
+
const errMessageList = errors.map(item => '\t' + item.message).join('\n');
|
|
76
|
+
return new Error(`Failed to validate ${name}:\n${errMessageList}`);
|
|
77
|
+
}
|
|
78
|
+
return validated.filter(item => !(item instanceof Error));
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
const object = function (shape) {
|
|
82
|
+
let message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultMessage('an object where:');
|
|
83
|
+
return (value, name) => {
|
|
84
|
+
if (typeof value !== 'object' || value == null) {
|
|
85
|
+
return new Error(message(value, name));
|
|
86
|
+
}
|
|
87
|
+
const result = {};
|
|
88
|
+
for (const key in shape) {
|
|
89
|
+
const check = shape[key];
|
|
90
|
+
const item = check(value[key], name ? `${name}.${key}` : `obj.${key}`);
|
|
91
|
+
if (item instanceof Error) {
|
|
92
|
+
const objectDescription = Object.entries(shape).map(_ref => {
|
|
93
|
+
let [key, check] = _ref;
|
|
94
|
+
let msg = check(Symbol()).message;
|
|
95
|
+
if (msg.includes('\n')) {
|
|
96
|
+
msg = indent(indent(msg)).split('\n').slice(1).join('\n');
|
|
97
|
+
}
|
|
98
|
+
return `\t- Expected "${key}": to be ${msg}`;
|
|
99
|
+
}).join('\n');
|
|
100
|
+
return new Error(`${message(value, name)}\n${objectDescription}\nBut got: ${indent(JSON.stringify(value))}`);
|
|
101
|
+
}
|
|
102
|
+
result[key] = item;
|
|
103
|
+
}
|
|
104
|
+
return result;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
const unionOf = function (a, b) {
|
|
108
|
+
let message = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultUnionMessage('one of');
|
|
109
|
+
return (value, name) => {
|
|
110
|
+
const resultA = a(value);
|
|
111
|
+
if (!(resultA instanceof Error)) {
|
|
112
|
+
return resultA;
|
|
113
|
+
}
|
|
114
|
+
const resultB = b(value);
|
|
115
|
+
if (!(resultB instanceof Error)) {
|
|
116
|
+
return resultB;
|
|
117
|
+
}
|
|
118
|
+
return new Error(`${message(value, name)}${indent(resultA.message)}${indent(resultB.message)}\nBut got: ${JSON.stringify(value)}`);
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
const unionOf3 = function (a, b, c) {
|
|
122
|
+
let message = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : defaultUnionMessage('one of');
|
|
123
|
+
return (value, name) => {
|
|
124
|
+
const resultA = a(value);
|
|
125
|
+
if (!(resultA instanceof Error)) {
|
|
126
|
+
return resultA;
|
|
127
|
+
}
|
|
128
|
+
const resultB = b(value);
|
|
129
|
+
if (!(resultB instanceof Error)) {
|
|
130
|
+
return resultB;
|
|
131
|
+
}
|
|
132
|
+
const resultC = c(value);
|
|
133
|
+
if (!(resultC instanceof Error)) {
|
|
134
|
+
return resultC;
|
|
135
|
+
}
|
|
136
|
+
return new Error(`${message(value, name)}${indent(resultA.message)}${indent(resultB.message)}${indent(resultC.message)}\nBut got: ${JSON.stringify(value)}`);
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
const logAndDefault = (check, value, def, name) => {
|
|
140
|
+
const result = check(value, name);
|
|
141
|
+
if (result instanceof Error) {
|
|
142
|
+
console.error('[@stylexjs/babel-plugin]', result.message);
|
|
143
|
+
return def;
|
|
144
|
+
}
|
|
145
|
+
return result;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const CheckModuleResolution = unionOf3(object({
|
|
149
|
+
type: literal('commonJS'),
|
|
150
|
+
rootDir: string(),
|
|
151
|
+
themeFileExtension: unionOf(nullish(), string())
|
|
152
|
+
}), object({
|
|
153
|
+
type: literal('haste'),
|
|
154
|
+
themeFileExtension: unionOf(nullish(), string())
|
|
155
|
+
}), object({
|
|
156
|
+
type: literal('experimental_crossFileParsing'),
|
|
157
|
+
rootDir: string(),
|
|
158
|
+
themeFileExtension: unionOf(nullish(), string())
|
|
159
|
+
}));
|
|
160
|
+
const checkImportSource = unionOf(string(), object({
|
|
161
|
+
from: string(),
|
|
162
|
+
as: string()
|
|
163
|
+
}));
|
|
164
|
+
const checkImportSources = array(checkImportSource);
|
|
165
|
+
const checkRuntimeInjection = unionOf3(boolean(), string(), object({
|
|
166
|
+
from: string(),
|
|
167
|
+
as: string()
|
|
168
|
+
}));
|
|
32
169
|
const DEFAULT_INJECT_PATH = '@stylexjs/stylex/lib/stylex-inject';
|
|
33
170
|
class StateManager {
|
|
34
171
|
importPaths = new Set();
|
|
35
172
|
stylexImport = new Set();
|
|
36
173
|
stylexPropsImport = new Set();
|
|
174
|
+
stylexAttrsImport = new Set();
|
|
37
175
|
stylexCreateImport = new Set();
|
|
38
176
|
stylexIncludeImport = new Set();
|
|
39
177
|
stylexFirstThatWorksImport = new Set();
|
|
@@ -49,25 +187,36 @@ class StateManager {
|
|
|
49
187
|
constructor(state) {
|
|
50
188
|
this._state = state;
|
|
51
189
|
state.file.metadata.stylex = [];
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
190
|
+
this.options = this.setOptions(state.opts ?? {});
|
|
191
|
+
}
|
|
192
|
+
setOptions(options) {
|
|
193
|
+
const dev = logAndDefault(boolean(), options.dev ?? false, false, 'options.dev');
|
|
194
|
+
const test = logAndDefault(boolean(), options.test ?? false, false, 'options.test');
|
|
195
|
+
const configRuntimeInjection = logAndDefault(checkRuntimeInjection, options.runtimeInjection ?? dev, dev, 'options.runtimeInjection');
|
|
196
|
+
const runtimeInjection = configRuntimeInjection === true ? DEFAULT_INJECT_PATH : configRuntimeInjection === false ? undefined : configRuntimeInjection;
|
|
197
|
+
const classNamePrefix = logAndDefault(string(), options.classNamePrefix ?? 'x', 'x', 'options.classNamePrefix');
|
|
198
|
+
const configuredImportSources = logAndDefault(checkImportSources, options.importSources ?? [], [], 'options.importSources');
|
|
199
|
+
const importSources = [name, 'stylex', ...configuredImportSources];
|
|
200
|
+
const genConditionalClasses = logAndDefault(boolean(), options.genConditionalClasses ?? false, false, 'options.genConditionalClasses');
|
|
201
|
+
const useRemForFontSize = logAndDefault(boolean(), options.useRemForFontSize ?? false, false, 'options.useRemForFontSize');
|
|
202
|
+
const styleResolution = logAndDefault(unionOf3(literal('application-order'), literal('property-specificity'), literal('legacy-expand-shorthands')), options.styleResolution ?? 'application-order', 'application-order', 'options.styleResolution');
|
|
203
|
+
const unstable_moduleResolution = logAndDefault(unionOf(nullish(), CheckModuleResolution), options.unstable_moduleResolution, null, 'options.unstable_moduleResolution');
|
|
204
|
+
const treeshakeCompensation = logAndDefault(boolean(), options.treeshakeCompensation ?? false, false, 'options.treeshakeCompensation');
|
|
55
205
|
const opts = {
|
|
56
206
|
...options,
|
|
57
|
-
dev
|
|
58
|
-
test
|
|
59
|
-
runtimeInjection
|
|
60
|
-
classNamePrefix
|
|
61
|
-
importSources
|
|
62
|
-
definedStylexCSSVariables:
|
|
63
|
-
genConditionalClasses
|
|
64
|
-
useRemForFontSize
|
|
65
|
-
styleResolution
|
|
66
|
-
unstable_moduleResolution
|
|
67
|
-
treeshakeCompensation
|
|
207
|
+
dev,
|
|
208
|
+
test,
|
|
209
|
+
runtimeInjection,
|
|
210
|
+
classNamePrefix,
|
|
211
|
+
importSources,
|
|
212
|
+
definedStylexCSSVariables: {},
|
|
213
|
+
genConditionalClasses,
|
|
214
|
+
useRemForFontSize,
|
|
215
|
+
styleResolution,
|
|
216
|
+
unstable_moduleResolution,
|
|
217
|
+
treeshakeCompensation
|
|
68
218
|
};
|
|
69
|
-
|
|
70
|
-
return this._state.opts;
|
|
219
|
+
return opts;
|
|
71
220
|
}
|
|
72
221
|
get importPathString() {
|
|
73
222
|
if (this.importPaths.has('@stylexjs/stylex')) {
|
|
@@ -96,9 +245,13 @@ class StateManager {
|
|
|
96
245
|
return this._state.file.metadata;
|
|
97
246
|
}
|
|
98
247
|
get runtimeInjection() {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
248
|
+
if (this.options.runtimeInjection == null) {
|
|
249
|
+
return null;
|
|
250
|
+
}
|
|
251
|
+
const runInj = this.options.runtimeInjection;
|
|
252
|
+
return typeof runInj === 'string' ? {
|
|
253
|
+
from: runInj
|
|
254
|
+
} : runInj || null;
|
|
102
255
|
}
|
|
103
256
|
get isDev() {
|
|
104
257
|
return !!this.options.dev;
|
|
@@ -239,6 +392,9 @@ function readImportDeclarations(path, state) {
|
|
|
239
392
|
if (importedName === 'props') {
|
|
240
393
|
state.stylexPropsImport.add(localName);
|
|
241
394
|
}
|
|
395
|
+
if (importedName === 'attrs') {
|
|
396
|
+
state.stylexAttrsImport.add(localName);
|
|
397
|
+
}
|
|
242
398
|
if (importedName === 'keyframes') {
|
|
243
399
|
state.stylexKeyframesImport.add(localName);
|
|
244
400
|
}
|
|
@@ -287,6 +443,9 @@ function readRequires(path, state) {
|
|
|
287
443
|
if (prop.key.name === 'props') {
|
|
288
444
|
state.stylexPropsImport.add(value.name);
|
|
289
445
|
}
|
|
446
|
+
if (prop.key.name === 'attrs') {
|
|
447
|
+
state.stylexAttrsImport.add(value.name);
|
|
448
|
+
}
|
|
290
449
|
if (prop.key.name === 'keyframes') {
|
|
291
450
|
state.stylexKeyframesImport.add(value.name);
|
|
292
451
|
}
|
|
@@ -4049,8 +4208,27 @@ function transformStyleXDefineVars(callExpressionPath, state) {
|
|
|
4049
4208
|
const varId = variableDeclaratorNode.id;
|
|
4050
4209
|
const args = callExpressionPath.get('arguments');
|
|
4051
4210
|
const firstArg = args[0];
|
|
4211
|
+
const injectedKeyframes = {};
|
|
4212
|
+
function keyframes(animation) {
|
|
4213
|
+
const [animationName, injectedStyle] = keyframes_1(animation, state.options);
|
|
4214
|
+
injectedKeyframes[animationName] = injectedStyle;
|
|
4215
|
+
return animationName;
|
|
4216
|
+
}
|
|
4052
4217
|
const identifiers = {};
|
|
4053
4218
|
const memberExpressions = {};
|
|
4219
|
+
state.stylexKeyframesImport.forEach(name => {
|
|
4220
|
+
identifiers[name] = {
|
|
4221
|
+
fn: keyframes
|
|
4222
|
+
};
|
|
4223
|
+
});
|
|
4224
|
+
state.stylexImport.forEach(name => {
|
|
4225
|
+
if (memberExpressions[name] === undefined) {
|
|
4226
|
+
memberExpressions[name] = {};
|
|
4227
|
+
}
|
|
4228
|
+
memberExpressions[name].keyframes = {
|
|
4229
|
+
fn: keyframes
|
|
4230
|
+
};
|
|
4231
|
+
});
|
|
4054
4232
|
const {
|
|
4055
4233
|
confident,
|
|
4056
4234
|
value
|
|
@@ -4069,13 +4247,17 @@ function transformStyleXDefineVars(callExpressionPath, state) {
|
|
|
4069
4247
|
throw new Error('No filename found for generating theme name.');
|
|
4070
4248
|
}
|
|
4071
4249
|
const exportName = varId.name;
|
|
4072
|
-
const [variablesObj,
|
|
4250
|
+
const [variablesObj, injectedStylesSansKeyframes] = defineVars_1(value, {
|
|
4073
4251
|
...state.options,
|
|
4074
4252
|
themeName: utils_1.genFileBasedIdentifier({
|
|
4075
4253
|
fileName,
|
|
4076
4254
|
exportName
|
|
4077
4255
|
})
|
|
4078
4256
|
});
|
|
4257
|
+
const injectedStyles = {
|
|
4258
|
+
...injectedKeyframes,
|
|
4259
|
+
...injectedStylesSansKeyframes
|
|
4260
|
+
};
|
|
4079
4261
|
callExpressionPath.replaceWith(convertObjectToAST(variablesObj));
|
|
4080
4262
|
const statementPath = variableDeclaratorPath.parentPath.parentPath;
|
|
4081
4263
|
if (Object.keys(injectedStyles).length === 0) {
|
|
@@ -4318,18 +4500,181 @@ function assertValidKeyframes(obj) {
|
|
|
4318
4500
|
}
|
|
4319
4501
|
}
|
|
4320
4502
|
|
|
4321
|
-
var
|
|
4503
|
+
var styleq$1 = {};
|
|
4322
4504
|
|
|
4323
|
-
|
|
4505
|
+
/**
|
|
4506
|
+
* Copyright (c) Nicolas Gallagher
|
|
4507
|
+
*
|
|
4508
|
+
* This source code is licensed under the MIT license found in the
|
|
4509
|
+
* LICENSE file in the root directory of this source tree.
|
|
4510
|
+
*
|
|
4511
|
+
*
|
|
4512
|
+
*/
|
|
4324
4513
|
|
|
4325
|
-
Object.defineProperty(
|
|
4514
|
+
Object.defineProperty(styleq$1, "__esModule", {
|
|
4326
4515
|
value: true
|
|
4327
4516
|
});
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
var
|
|
4331
|
-
|
|
4332
|
-
|
|
4517
|
+
var styleq_2 = styleq$1.styleq = void 0;
|
|
4518
|
+
var cache = new WeakMap();
|
|
4519
|
+
var compiledKey = '$$css';
|
|
4520
|
+
|
|
4521
|
+
function createStyleq(options) {
|
|
4522
|
+
var disableCache;
|
|
4523
|
+
var disableMix;
|
|
4524
|
+
var transform;
|
|
4525
|
+
|
|
4526
|
+
if (options != null) {
|
|
4527
|
+
disableCache = options.disableCache === true;
|
|
4528
|
+
disableMix = options.disableMix === true;
|
|
4529
|
+
transform = options.transform;
|
|
4530
|
+
}
|
|
4531
|
+
|
|
4532
|
+
return function styleq() {
|
|
4533
|
+
// Keep track of property commits to the className
|
|
4534
|
+
var definedProperties = []; // The className and inline style to build up
|
|
4535
|
+
|
|
4536
|
+
var className = '';
|
|
4537
|
+
var inlineStyle = null; // The current position in the cache graph
|
|
4538
|
+
|
|
4539
|
+
var nextCache = disableCache ? null : cache; // This way of creating an array from arguments is fastest
|
|
4540
|
+
|
|
4541
|
+
var styles = new Array(arguments.length);
|
|
4542
|
+
|
|
4543
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
4544
|
+
styles[i] = arguments[i];
|
|
4545
|
+
} // Iterate over styles from last to first
|
|
4546
|
+
|
|
4547
|
+
|
|
4548
|
+
while (styles.length > 0) {
|
|
4549
|
+
var possibleStyle = styles.pop(); // Skip empty items
|
|
4550
|
+
|
|
4551
|
+
if (possibleStyle == null || possibleStyle === false) {
|
|
4552
|
+
continue;
|
|
4553
|
+
} // Push nested styles back onto the stack to be processed
|
|
4554
|
+
|
|
4555
|
+
|
|
4556
|
+
if (Array.isArray(possibleStyle)) {
|
|
4557
|
+
for (var _i = 0; _i < possibleStyle.length; _i++) {
|
|
4558
|
+
styles.push(possibleStyle[_i]);
|
|
4559
|
+
}
|
|
4560
|
+
|
|
4561
|
+
continue;
|
|
4562
|
+
} // Process an individual style object
|
|
4563
|
+
|
|
4564
|
+
|
|
4565
|
+
var style = transform != null ? transform(possibleStyle) : possibleStyle;
|
|
4566
|
+
|
|
4567
|
+
if (style.$$css) {
|
|
4568
|
+
// Build up the class names defined by this object
|
|
4569
|
+
var classNameChunk = ''; // Check the cache to see if we've already done this work
|
|
4570
|
+
|
|
4571
|
+
if (nextCache != null && nextCache.has(style)) {
|
|
4572
|
+
// Cache: read
|
|
4573
|
+
var cacheEntry = nextCache.get(style);
|
|
4574
|
+
|
|
4575
|
+
if (cacheEntry != null) {
|
|
4576
|
+
classNameChunk = cacheEntry[0]; // $FlowIgnore
|
|
4577
|
+
|
|
4578
|
+
definedProperties.push.apply(definedProperties, cacheEntry[1]);
|
|
4579
|
+
nextCache = cacheEntry[2];
|
|
4580
|
+
}
|
|
4581
|
+
} // Update the chunks with data from this object
|
|
4582
|
+
else {
|
|
4583
|
+
// The properties defined by this object
|
|
4584
|
+
var definedPropertiesChunk = [];
|
|
4585
|
+
|
|
4586
|
+
for (var prop in style) {
|
|
4587
|
+
var value = style[prop];
|
|
4588
|
+
if (prop === compiledKey) continue; // Each property value is used as an HTML class name
|
|
4589
|
+
// { 'debug.string': 'debug.string', opacity: 's-jskmnoqp' }
|
|
4590
|
+
|
|
4591
|
+
if (typeof value === 'string' || value === null) {
|
|
4592
|
+
// Only add to chunks if this property hasn't already been seen
|
|
4593
|
+
if (!definedProperties.includes(prop)) {
|
|
4594
|
+
definedProperties.push(prop);
|
|
4595
|
+
|
|
4596
|
+
if (nextCache != null) {
|
|
4597
|
+
definedPropertiesChunk.push(prop);
|
|
4598
|
+
}
|
|
4599
|
+
|
|
4600
|
+
if (typeof value === 'string') {
|
|
4601
|
+
classNameChunk += classNameChunk ? ' ' + value : value;
|
|
4602
|
+
}
|
|
4603
|
+
}
|
|
4604
|
+
} // If we encounter a value that isn't a string or `null`
|
|
4605
|
+
else {
|
|
4606
|
+
console.error("styleq: ".concat(prop, " typeof ").concat(String(value), " is not \"string\" or \"null\"."));
|
|
4607
|
+
}
|
|
4608
|
+
} // Cache: write
|
|
4609
|
+
|
|
4610
|
+
|
|
4611
|
+
if (nextCache != null) {
|
|
4612
|
+
// Create the next WeakMap for this sequence of styles
|
|
4613
|
+
var weakMap = new WeakMap();
|
|
4614
|
+
nextCache.set(style, [classNameChunk, definedPropertiesChunk, weakMap]);
|
|
4615
|
+
nextCache = weakMap;
|
|
4616
|
+
}
|
|
4617
|
+
} // Order of classes in chunks matches property-iteration order of style
|
|
4618
|
+
// object. Order of chunks matches passed order of styles from first to
|
|
4619
|
+
// last (which we iterate over in reverse).
|
|
4620
|
+
|
|
4621
|
+
|
|
4622
|
+
if (classNameChunk) {
|
|
4623
|
+
className = className ? classNameChunk + ' ' + className : classNameChunk;
|
|
4624
|
+
}
|
|
4625
|
+
} // ----- DYNAMIC: Process inline style object -----
|
|
4626
|
+
else {
|
|
4627
|
+
if (disableMix) {
|
|
4628
|
+
if (inlineStyle == null) {
|
|
4629
|
+
inlineStyle = {};
|
|
4630
|
+
}
|
|
4631
|
+
|
|
4632
|
+
inlineStyle = Object.assign({}, style, inlineStyle);
|
|
4633
|
+
} else {
|
|
4634
|
+
var subStyle = null;
|
|
4635
|
+
|
|
4636
|
+
for (var _prop in style) {
|
|
4637
|
+
var _value = style[_prop];
|
|
4638
|
+
|
|
4639
|
+
if (_value !== undefined) {
|
|
4640
|
+
if (!definedProperties.includes(_prop)) {
|
|
4641
|
+
if (_value != null) {
|
|
4642
|
+
if (inlineStyle == null) {
|
|
4643
|
+
inlineStyle = {};
|
|
4644
|
+
}
|
|
4645
|
+
|
|
4646
|
+
if (subStyle == null) {
|
|
4647
|
+
subStyle = {};
|
|
4648
|
+
}
|
|
4649
|
+
|
|
4650
|
+
subStyle[_prop] = _value;
|
|
4651
|
+
}
|
|
4652
|
+
|
|
4653
|
+
definedProperties.push(_prop); // Cache is unnecessary overhead if results can't be reused.
|
|
4654
|
+
|
|
4655
|
+
nextCache = null;
|
|
4656
|
+
}
|
|
4657
|
+
}
|
|
4658
|
+
}
|
|
4659
|
+
|
|
4660
|
+
if (subStyle != null) {
|
|
4661
|
+
inlineStyle = Object.assign(subStyle, inlineStyle);
|
|
4662
|
+
}
|
|
4663
|
+
}
|
|
4664
|
+
}
|
|
4665
|
+
}
|
|
4666
|
+
|
|
4667
|
+
var styleProps = [className, inlineStyle];
|
|
4668
|
+
return styleProps;
|
|
4669
|
+
};
|
|
4670
|
+
}
|
|
4671
|
+
|
|
4672
|
+
var styleq = createStyleq();
|
|
4673
|
+
styleq_2 = styleq$1.styleq = styleq;
|
|
4674
|
+
styleq.factory = createStyleq;
|
|
4675
|
+
|
|
4676
|
+
const errorForFn = name => new Error(`'stylex.${name}' should never be called at runtime. It should be compiled away by '@stylexjs/babel-plugin'`);
|
|
4677
|
+
const errorForType = key => errorForFn(`types.${key}`);
|
|
4333
4678
|
function props() {
|
|
4334
4679
|
const options = this;
|
|
4335
4680
|
for (var _len = arguments.length, styles = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -4338,7 +4683,7 @@ function props() {
|
|
|
4338
4683
|
if (__implementations.props) {
|
|
4339
4684
|
return __implementations.props.call(options, styles);
|
|
4340
4685
|
}
|
|
4341
|
-
const [className, style] = (
|
|
4686
|
+
const [className, style] = styleq_2(styles);
|
|
4342
4687
|
const result = {};
|
|
4343
4688
|
if (className != null && className !== '') {
|
|
4344
4689
|
result.className = className;
|
|
@@ -4348,99 +4693,111 @@ function props() {
|
|
|
4348
4693
|
}
|
|
4349
4694
|
return result;
|
|
4350
4695
|
}
|
|
4696
|
+
function attrs() {
|
|
4697
|
+
const {
|
|
4698
|
+
className,
|
|
4699
|
+
style
|
|
4700
|
+
} = props(...arguments);
|
|
4701
|
+
const result = {};
|
|
4702
|
+
if (className != null && className !== '') {
|
|
4703
|
+
result.class = className;
|
|
4704
|
+
}
|
|
4705
|
+
if (style != null && Object.keys(style).length > 0) {
|
|
4706
|
+
result.style = Object.keys(style).map(key => `${key}:${style[key]};`).join('');
|
|
4707
|
+
}
|
|
4708
|
+
return result;
|
|
4709
|
+
}
|
|
4351
4710
|
function stylexCreate(styles) {
|
|
4352
4711
|
if (__implementations.create != null) {
|
|
4353
4712
|
const create = __implementations.create;
|
|
4354
4713
|
return create(styles);
|
|
4355
4714
|
}
|
|
4356
|
-
throw
|
|
4715
|
+
throw errorForFn('create');
|
|
4357
4716
|
}
|
|
4358
4717
|
function stylexDefineVars(styles) {
|
|
4359
4718
|
if (__implementations.defineVars) {
|
|
4360
4719
|
return __implementations.defineVars(styles);
|
|
4361
4720
|
}
|
|
4362
|
-
throw
|
|
4721
|
+
throw errorForFn('defineVars');
|
|
4363
4722
|
}
|
|
4364
4723
|
const stylexCreateTheme = (baseTokens, overrides) => {
|
|
4365
4724
|
if (__implementations.createTheme) {
|
|
4366
4725
|
return __implementations.createTheme(baseTokens, overrides);
|
|
4367
4726
|
}
|
|
4368
|
-
throw
|
|
4727
|
+
throw errorForFn('createTheme');
|
|
4369
4728
|
};
|
|
4370
4729
|
const stylexInclude = styles => {
|
|
4371
4730
|
if (__implementations.include) {
|
|
4372
4731
|
return __implementations.include(styles);
|
|
4373
4732
|
}
|
|
4374
|
-
throw
|
|
4733
|
+
throw errorForFn('include');
|
|
4375
4734
|
};
|
|
4376
|
-
const create =
|
|
4377
|
-
const defineVars =
|
|
4378
|
-
const createTheme =
|
|
4379
|
-
const include =
|
|
4380
|
-
const types =
|
|
4735
|
+
const create = stylexCreate;
|
|
4736
|
+
const defineVars = stylexDefineVars;
|
|
4737
|
+
const createTheme = stylexCreateTheme;
|
|
4738
|
+
const include = stylexInclude;
|
|
4739
|
+
const types = {
|
|
4381
4740
|
angle: _v => {
|
|
4382
|
-
throw
|
|
4741
|
+
throw errorForType('angle');
|
|
4383
4742
|
},
|
|
4384
4743
|
color: _v => {
|
|
4385
|
-
throw
|
|
4744
|
+
throw errorForType('color');
|
|
4386
4745
|
},
|
|
4387
4746
|
url: _v => {
|
|
4388
|
-
throw
|
|
4747
|
+
throw errorForType('url');
|
|
4389
4748
|
},
|
|
4390
4749
|
image: _v => {
|
|
4391
|
-
throw
|
|
4750
|
+
throw errorForType('image');
|
|
4392
4751
|
},
|
|
4393
4752
|
integer: _v => {
|
|
4394
|
-
throw
|
|
4753
|
+
throw errorForType('integer');
|
|
4395
4754
|
},
|
|
4396
4755
|
lengthPercentage: _v => {
|
|
4397
|
-
throw
|
|
4756
|
+
throw errorForType('lengthPercentage');
|
|
4398
4757
|
},
|
|
4399
4758
|
length: _v => {
|
|
4400
|
-
throw
|
|
4759
|
+
throw errorForType('length');
|
|
4401
4760
|
},
|
|
4402
4761
|
percentage: _v => {
|
|
4403
|
-
throw
|
|
4762
|
+
throw errorForType('percentage');
|
|
4404
4763
|
},
|
|
4405
4764
|
number: _v => {
|
|
4406
|
-
throw
|
|
4765
|
+
throw errorForType('number');
|
|
4407
4766
|
},
|
|
4408
4767
|
resolution: _v => {
|
|
4409
|
-
throw
|
|
4768
|
+
throw errorForType('resolution');
|
|
4410
4769
|
},
|
|
4411
4770
|
time: _v => {
|
|
4412
|
-
throw
|
|
4771
|
+
throw errorForType('time');
|
|
4413
4772
|
},
|
|
4414
4773
|
transformFunction: _v => {
|
|
4415
|
-
throw
|
|
4774
|
+
throw errorForType('transformFunction');
|
|
4416
4775
|
},
|
|
4417
4776
|
transformList: _v => {
|
|
4418
|
-
throw
|
|
4777
|
+
throw errorForType('transformList');
|
|
4419
4778
|
}
|
|
4420
4779
|
};
|
|
4421
|
-
const errorForType = type => `stylex.types.${type} should be compiled away by @stylexjs/babel-plugin`;
|
|
4422
4780
|
const keyframes = keyframes => {
|
|
4423
4781
|
if (__implementations.keyframes) {
|
|
4424
4782
|
return __implementations.keyframes(keyframes);
|
|
4425
4783
|
}
|
|
4426
|
-
throw
|
|
4784
|
+
throw errorForFn('keyframes');
|
|
4427
4785
|
};
|
|
4428
|
-
stylex.keyframes = keyframes;
|
|
4429
4786
|
const firstThatWorks = function () {
|
|
4430
4787
|
if (__implementations.firstThatWorks) {
|
|
4431
4788
|
return __implementations.firstThatWorks(...arguments);
|
|
4432
4789
|
}
|
|
4433
|
-
throw
|
|
4790
|
+
throw errorForFn('firstThatWorks');
|
|
4434
4791
|
};
|
|
4435
|
-
stylex.firstThatWorks = firstThatWorks;
|
|
4436
4792
|
function _stylex() {
|
|
4437
4793
|
for (var _len2 = arguments.length, styles = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
4438
4794
|
styles[_key2] = arguments[_key2];
|
|
4439
4795
|
}
|
|
4440
|
-
const [className] = (
|
|
4796
|
+
const [className] = styleq_2(styles);
|
|
4441
4797
|
return className;
|
|
4442
4798
|
}
|
|
4443
4799
|
_stylex.props = props;
|
|
4800
|
+
_stylex.attrs = attrs;
|
|
4444
4801
|
_stylex.create = create;
|
|
4445
4802
|
_stylex.defineVars = defineVars;
|
|
4446
4803
|
_stylex.createTheme = createTheme;
|
|
@@ -4449,15 +4806,6 @@ _stylex.keyframes = keyframes;
|
|
|
4449
4806
|
_stylex.firstThatWorks = firstThatWorks;
|
|
4450
4807
|
_stylex.types = types;
|
|
4451
4808
|
const __implementations = {};
|
|
4452
|
-
function __monkey_patch__(key, implementation) {
|
|
4453
|
-
if (key === 'types') {
|
|
4454
|
-
Object.assign(types, implementation);
|
|
4455
|
-
} else {
|
|
4456
|
-
__implementations[key] = implementation;
|
|
4457
|
-
}
|
|
4458
|
-
}
|
|
4459
|
-
stylex.stylex = _stylex;
|
|
4460
|
-
default_1 = stylex.default = _stylex;
|
|
4461
4809
|
|
|
4462
4810
|
function skipStylexMergeChildren(path, state) {
|
|
4463
4811
|
const {
|
|
@@ -4481,6 +4829,228 @@ function transformStyleXMerge(path, state) {
|
|
|
4481
4829
|
let bailOutIndex = null;
|
|
4482
4830
|
const resolvedArgs = [];
|
|
4483
4831
|
for (const arg of node.arguments) {
|
|
4832
|
+
currentIndex++;
|
|
4833
|
+
switch (arg.type) {
|
|
4834
|
+
case 'MemberExpression':
|
|
4835
|
+
{
|
|
4836
|
+
const resolved = parseNullableStyle$2(arg, state);
|
|
4837
|
+
if (resolved === 'other') {
|
|
4838
|
+
bailOutIndex = currentIndex;
|
|
4839
|
+
bailOut = true;
|
|
4840
|
+
} else {
|
|
4841
|
+
resolvedArgs.push(resolved);
|
|
4842
|
+
}
|
|
4843
|
+
break;
|
|
4844
|
+
}
|
|
4845
|
+
case 'ConditionalExpression':
|
|
4846
|
+
{
|
|
4847
|
+
const {
|
|
4848
|
+
test,
|
|
4849
|
+
consequent,
|
|
4850
|
+
alternate
|
|
4851
|
+
} = arg;
|
|
4852
|
+
const primary = parseNullableStyle$2(consequent, state);
|
|
4853
|
+
const fallback = parseNullableStyle$2(alternate, state);
|
|
4854
|
+
if (primary === 'other' || fallback === 'other') {
|
|
4855
|
+
bailOutIndex = currentIndex;
|
|
4856
|
+
bailOut = true;
|
|
4857
|
+
} else {
|
|
4858
|
+
resolvedArgs.push([test, primary, fallback]);
|
|
4859
|
+
conditional++;
|
|
4860
|
+
}
|
|
4861
|
+
break;
|
|
4862
|
+
}
|
|
4863
|
+
case 'LogicalExpression':
|
|
4864
|
+
{
|
|
4865
|
+
if (arg.operator !== '&&') {
|
|
4866
|
+
bailOutIndex = currentIndex;
|
|
4867
|
+
bailOut = true;
|
|
4868
|
+
break;
|
|
4869
|
+
}
|
|
4870
|
+
const {
|
|
4871
|
+
left,
|
|
4872
|
+
right
|
|
4873
|
+
} = arg;
|
|
4874
|
+
const leftResolved = parseNullableStyle$2(left, state);
|
|
4875
|
+
const rightResolved = parseNullableStyle$2(right, state);
|
|
4876
|
+
if (leftResolved !== 'other' || rightResolved === 'other') {
|
|
4877
|
+
bailOutIndex = currentIndex;
|
|
4878
|
+
bailOut = true;
|
|
4879
|
+
} else {
|
|
4880
|
+
resolvedArgs.push([left, rightResolved, null]);
|
|
4881
|
+
conditional++;
|
|
4882
|
+
}
|
|
4883
|
+
break;
|
|
4884
|
+
}
|
|
4885
|
+
default:
|
|
4886
|
+
bailOutIndex = currentIndex;
|
|
4887
|
+
bailOut = true;
|
|
4888
|
+
break;
|
|
4889
|
+
}
|
|
4890
|
+
if (conditional > 4) {
|
|
4891
|
+
bailOut = true;
|
|
4892
|
+
}
|
|
4893
|
+
if (bailOut) {
|
|
4894
|
+
break;
|
|
4895
|
+
}
|
|
4896
|
+
}
|
|
4897
|
+
if (!state.options.genConditionalClasses && conditional) {
|
|
4898
|
+
bailOut = true;
|
|
4899
|
+
}
|
|
4900
|
+
if (bailOut) {
|
|
4901
|
+
const argumentPaths = path.get('arguments');
|
|
4902
|
+
let nonNullProps = [];
|
|
4903
|
+
let index = -1;
|
|
4904
|
+
for (const argPath of argumentPaths) {
|
|
4905
|
+
index++;
|
|
4906
|
+
function MemberExpression(path) {
|
|
4907
|
+
const object = path.get('object').node;
|
|
4908
|
+
const property = path.get('property').node;
|
|
4909
|
+
const computed = path.node.computed;
|
|
4910
|
+
let objName = null;
|
|
4911
|
+
let propName = null;
|
|
4912
|
+
if (object.type === 'Identifier' && state.styleMap.has(object.name)) {
|
|
4913
|
+
objName = object.name;
|
|
4914
|
+
if (property.type === 'Identifier' && !computed) {
|
|
4915
|
+
propName = property.name;
|
|
4916
|
+
}
|
|
4917
|
+
if ((property.type === 'StringLiteral' || property.type === 'NumericLiteral') && computed) {
|
|
4918
|
+
propName = property.value;
|
|
4919
|
+
}
|
|
4920
|
+
}
|
|
4921
|
+
let styleNonNullProps = [];
|
|
4922
|
+
if (bailOutIndex != null && index > bailOutIndex) {
|
|
4923
|
+
nonNullProps = true;
|
|
4924
|
+
styleNonNullProps = true;
|
|
4925
|
+
}
|
|
4926
|
+
if (nonNullProps === true) {
|
|
4927
|
+
styleNonNullProps = true;
|
|
4928
|
+
} else {
|
|
4929
|
+
const {
|
|
4930
|
+
confident,
|
|
4931
|
+
value: styleValue
|
|
4932
|
+
} = evaluate(path, state);
|
|
4933
|
+
if (!confident) {
|
|
4934
|
+
nonNullProps = true;
|
|
4935
|
+
styleNonNullProps = true;
|
|
4936
|
+
} else {
|
|
4937
|
+
styleNonNullProps = nonNullProps === true ? true : [...nonNullProps];
|
|
4938
|
+
if (nonNullProps !== true) {
|
|
4939
|
+
nonNullProps = [...nonNullProps, ...Object.keys(styleValue).filter(key => styleValue[key] !== null)];
|
|
4940
|
+
}
|
|
4941
|
+
}
|
|
4942
|
+
}
|
|
4943
|
+
if (objName != null) {
|
|
4944
|
+
state.styleVarsToKeep.add([objName, propName != null ? String(propName) : true, styleNonNullProps]);
|
|
4945
|
+
}
|
|
4946
|
+
}
|
|
4947
|
+
if (isMemberExpression(argPath)) {
|
|
4948
|
+
MemberExpression(argPath);
|
|
4949
|
+
} else {
|
|
4950
|
+
argPath.traverse({
|
|
4951
|
+
MemberExpression
|
|
4952
|
+
});
|
|
4953
|
+
}
|
|
4954
|
+
}
|
|
4955
|
+
} else {
|
|
4956
|
+
path.skip();
|
|
4957
|
+
const stringExpression = makeStringExpression$2(resolvedArgs);
|
|
4958
|
+
path.replaceWith(stringExpression);
|
|
4959
|
+
}
|
|
4960
|
+
}
|
|
4961
|
+
function parseNullableStyle$2(node, state) {
|
|
4962
|
+
if (t__namespace.isNullLiteral(node) || t__namespace.isIdentifier(node) && node.name === 'undefined') {
|
|
4963
|
+
return null;
|
|
4964
|
+
}
|
|
4965
|
+
if (t__namespace.isMemberExpression(node)) {
|
|
4966
|
+
const {
|
|
4967
|
+
object,
|
|
4968
|
+
property,
|
|
4969
|
+
computed: computed
|
|
4970
|
+
} = node;
|
|
4971
|
+
let objName = null;
|
|
4972
|
+
let propName = null;
|
|
4973
|
+
if (object.type === 'Identifier' && state.styleMap.has(object.name) && property.type === 'Identifier' && !computed) {
|
|
4974
|
+
objName = object.name;
|
|
4975
|
+
propName = property.name;
|
|
4976
|
+
}
|
|
4977
|
+
if (object.type === 'Identifier' && state.styleMap.has(object.name) && (property.type === 'StringLiteral' || property.type === 'NumericLiteral') && computed) {
|
|
4978
|
+
objName = object.name;
|
|
4979
|
+
propName = property.value;
|
|
4980
|
+
}
|
|
4981
|
+
if (objName != null && propName != null) {
|
|
4982
|
+
const style = state.styleMap.get(objName);
|
|
4983
|
+
if (style != null && style[String(propName)] != null) {
|
|
4984
|
+
return style[String(propName)];
|
|
4985
|
+
}
|
|
4986
|
+
}
|
|
4987
|
+
}
|
|
4988
|
+
return 'other';
|
|
4989
|
+
}
|
|
4990
|
+
function makeStringExpression$2(values) {
|
|
4991
|
+
const conditions = values.filter(v => Array.isArray(v)).map(v => v[0]);
|
|
4992
|
+
if (conditions.length === 0) {
|
|
4993
|
+
return t__namespace.stringLiteral(_stylex(...values));
|
|
4994
|
+
}
|
|
4995
|
+
const conditionPermutations = genConditionPermutations$2(conditions.length);
|
|
4996
|
+
const objEntries = conditionPermutations.map(permutation => {
|
|
4997
|
+
let i = 0;
|
|
4998
|
+
const args = values.map(v => {
|
|
4999
|
+
if (Array.isArray(v)) {
|
|
5000
|
+
const [_test, primary, fallback] = v;
|
|
5001
|
+
return permutation[i++] ? primary : fallback;
|
|
5002
|
+
} else {
|
|
5003
|
+
return v;
|
|
5004
|
+
}
|
|
5005
|
+
});
|
|
5006
|
+
const key = permutation.reduce((soFar, bool) => soFar << 1 | (bool ? 1 : 0), 0);
|
|
5007
|
+
return t__namespace.objectProperty(t__namespace.numericLiteral(key), t__namespace.stringLiteral(_stylex(...args)));
|
|
5008
|
+
});
|
|
5009
|
+
const objExpressions = t__namespace.objectExpression(objEntries);
|
|
5010
|
+
const conditionsToKey = genBitwiseOrOfConditions$2(conditions);
|
|
5011
|
+
return t__namespace.memberExpression(objExpressions, conditionsToKey, true);
|
|
5012
|
+
}
|
|
5013
|
+
function genConditionPermutations$2(count) {
|
|
5014
|
+
const result = [];
|
|
5015
|
+
for (let i = 0; i < 2 ** count; i++) {
|
|
5016
|
+
const combination = [];
|
|
5017
|
+
for (let j = 0; j < count; j++) {
|
|
5018
|
+
combination.push(Boolean(i & 1 << j));
|
|
5019
|
+
}
|
|
5020
|
+
result.push(combination);
|
|
5021
|
+
}
|
|
5022
|
+
return result;
|
|
5023
|
+
}
|
|
5024
|
+
function genBitwiseOrOfConditions$2(conditions) {
|
|
5025
|
+
const binaryExpressions = conditions.map((condition, i) => {
|
|
5026
|
+
const shift = conditions.length - i - 1;
|
|
5027
|
+
return t__namespace.binaryExpression('<<', t__namespace.unaryExpression('!', t__namespace.unaryExpression('!', condition)), t__namespace.numericLiteral(shift));
|
|
5028
|
+
});
|
|
5029
|
+
return binaryExpressions.reduce((acc, expr) => {
|
|
5030
|
+
return t__namespace.binaryExpression('|', acc, expr);
|
|
5031
|
+
});
|
|
5032
|
+
}
|
|
5033
|
+
|
|
5034
|
+
function skipStylexPropsChildren(path, state) {
|
|
5035
|
+
if (!isCalleeIdentifier$1(path, state) && !isCalleeMemberExpression$1(path, state)) {
|
|
5036
|
+
return;
|
|
5037
|
+
}
|
|
5038
|
+
path.skip();
|
|
5039
|
+
}
|
|
5040
|
+
function transformStylexProps(path, state) {
|
|
5041
|
+
const {
|
|
5042
|
+
node
|
|
5043
|
+
} = path;
|
|
5044
|
+
if (!isCalleeIdentifier$1(path, state) && !isCalleeMemberExpression$1(path, state)) {
|
|
5045
|
+
return;
|
|
5046
|
+
}
|
|
5047
|
+
let bailOut = false;
|
|
5048
|
+
let conditional = 0;
|
|
5049
|
+
const args = node.arguments.flatMap(arg => arg.type === 'ArrayExpression' ? arg.elements : [arg]);
|
|
5050
|
+
let currentIndex = -1;
|
|
5051
|
+
let bailOutIndex = null;
|
|
5052
|
+
const resolvedArgs = [];
|
|
5053
|
+
for (const arg of args) {
|
|
4484
5054
|
currentIndex++;
|
|
4485
5055
|
switch (arg.type) {
|
|
4486
5056
|
case 'MemberExpression':
|
|
@@ -4642,7 +5212,8 @@ function parseNullableStyle$1(node, state) {
|
|
|
4642
5212
|
function makeStringExpression$1(values) {
|
|
4643
5213
|
const conditions = values.filter(v => Array.isArray(v)).map(v => v[0]);
|
|
4644
5214
|
if (conditions.length === 0) {
|
|
4645
|
-
|
|
5215
|
+
const result = props(values);
|
|
5216
|
+
return convertObjectToAST(result);
|
|
4646
5217
|
}
|
|
4647
5218
|
const conditionPermutations = genConditionPermutations$1(conditions.length);
|
|
4648
5219
|
const objEntries = conditionPermutations.map(permutation => {
|
|
@@ -4656,7 +5227,7 @@ function makeStringExpression$1(values) {
|
|
|
4656
5227
|
}
|
|
4657
5228
|
});
|
|
4658
5229
|
const key = permutation.reduce((soFar, bool) => soFar << 1 | (bool ? 1 : 0), 0);
|
|
4659
|
-
return t__namespace.objectProperty(t__namespace.numericLiteral(key),
|
|
5230
|
+
return t__namespace.objectProperty(t__namespace.numericLiteral(key), convertObjectToAST(props(args)));
|
|
4660
5231
|
});
|
|
4661
5232
|
const objExpressions = t__namespace.objectExpression(objEntries);
|
|
4662
5233
|
const conditionsToKey = genBitwiseOrOfConditions$1(conditions);
|
|
@@ -4682,14 +5253,26 @@ function genBitwiseOrOfConditions$1(conditions) {
|
|
|
4682
5253
|
return t__namespace.binaryExpression('|', acc, expr);
|
|
4683
5254
|
});
|
|
4684
5255
|
}
|
|
5256
|
+
function isCalleeIdentifier$1(path, state) {
|
|
5257
|
+
const {
|
|
5258
|
+
node
|
|
5259
|
+
} = path;
|
|
5260
|
+
return node != null && node.callee != null && node.callee.type === 'Identifier' && state.stylexPropsImport.has(node.callee.name);
|
|
5261
|
+
}
|
|
5262
|
+
function isCalleeMemberExpression$1(path, state) {
|
|
5263
|
+
const {
|
|
5264
|
+
node
|
|
5265
|
+
} = path;
|
|
5266
|
+
return node != null && node.callee != null && node.callee.type === 'MemberExpression' && node.callee.object.type === 'Identifier' && node.callee.property.type === 'Identifier' && node.callee.property.name === 'props' && state.stylexImport.has(node.callee.object.name);
|
|
5267
|
+
}
|
|
4685
5268
|
|
|
4686
|
-
function
|
|
5269
|
+
function skipStylexAttrsChildren(path, state) {
|
|
4687
5270
|
if (!isCalleeIdentifier(path, state) && !isCalleeMemberExpression(path, state)) {
|
|
4688
5271
|
return;
|
|
4689
5272
|
}
|
|
4690
5273
|
path.skip();
|
|
4691
5274
|
}
|
|
4692
|
-
function
|
|
5275
|
+
function transformStylexAttrs(path, state) {
|
|
4693
5276
|
const {
|
|
4694
5277
|
node
|
|
4695
5278
|
} = path;
|
|
@@ -4864,7 +5447,7 @@ function parseNullableStyle(node, state) {
|
|
|
4864
5447
|
function makeStringExpression(values) {
|
|
4865
5448
|
const conditions = values.filter(v => Array.isArray(v)).map(v => v[0]);
|
|
4866
5449
|
if (conditions.length === 0) {
|
|
4867
|
-
const result =
|
|
5450
|
+
const result = attrs(values);
|
|
4868
5451
|
return convertObjectToAST(result);
|
|
4869
5452
|
}
|
|
4870
5453
|
const conditionPermutations = genConditionPermutations(conditions.length);
|
|
@@ -4879,7 +5462,7 @@ function makeStringExpression(values) {
|
|
|
4879
5462
|
}
|
|
4880
5463
|
});
|
|
4881
5464
|
const key = permutation.reduce((soFar, bool) => soFar << 1 | (bool ? 1 : 0), 0);
|
|
4882
|
-
return t__namespace.objectProperty(t__namespace.numericLiteral(key), convertObjectToAST(
|
|
5465
|
+
return t__namespace.objectProperty(t__namespace.numericLiteral(key), convertObjectToAST(attrs(args)));
|
|
4883
5466
|
});
|
|
4884
5467
|
const objExpressions = t__namespace.objectExpression(objEntries);
|
|
4885
5468
|
const conditionsToKey = genBitwiseOrOfConditions(conditions);
|
|
@@ -4909,13 +5492,13 @@ function isCalleeIdentifier(path, state) {
|
|
|
4909
5492
|
const {
|
|
4910
5493
|
node
|
|
4911
5494
|
} = path;
|
|
4912
|
-
return node != null && node.callee != null && node.callee.type === 'Identifier' && state.
|
|
5495
|
+
return node != null && node.callee != null && node.callee.type === 'Identifier' && state.stylexAttrsImport.has(node.callee.name);
|
|
4913
5496
|
}
|
|
4914
5497
|
function isCalleeMemberExpression(path, state) {
|
|
4915
5498
|
const {
|
|
4916
5499
|
node
|
|
4917
5500
|
} = path;
|
|
4918
|
-
return node != null && node.callee != null && node.callee.type === 'MemberExpression' && node.callee.object.type === 'Identifier' && node.callee.property.type === 'Identifier' && node.callee.property.name === '
|
|
5501
|
+
return node != null && node.callee != null && node.callee.type === 'MemberExpression' && node.callee.object.type === 'Identifier' && node.callee.property.type === 'Identifier' && node.callee.property.name === 'attrs' && state.stylexImport.has(node.callee.object.name);
|
|
4919
5502
|
}
|
|
4920
5503
|
|
|
4921
5504
|
const NAME = 'stylex';
|
|
@@ -4953,6 +5536,7 @@ function styleXTransform() {
|
|
|
4953
5536
|
CallExpression(path) {
|
|
4954
5537
|
transformStyleXMerge(path, state);
|
|
4955
5538
|
transformStylexProps(path, state);
|
|
5539
|
+
transformStylexAttrs(path, state);
|
|
4956
5540
|
}
|
|
4957
5541
|
});
|
|
4958
5542
|
const varsToKeep = {};
|
|
@@ -5034,6 +5618,7 @@ function styleXTransform() {
|
|
|
5034
5618
|
CallExpression(path) {
|
|
5035
5619
|
skipStylexMergeChildren(path, state);
|
|
5036
5620
|
skipStylexPropsChildren(path, state);
|
|
5621
|
+
skipStylexAttrsChildren(path, state);
|
|
5037
5622
|
},
|
|
5038
5623
|
Identifier(path) {
|
|
5039
5624
|
if (isReferencedIdentifier(path)) {
|
|
@@ -18,13 +18,17 @@ export type ImportPathResolution =
|
|
|
18
18
|
| false
|
|
19
19
|
| ['themeNameRef' | 'filePath', string];
|
|
20
20
|
type ModuleResolution =
|
|
21
|
-
| {
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
| Readonly<{
|
|
22
|
+
type: 'commonJS';
|
|
23
|
+
rootDir: string;
|
|
24
|
+
themeFileExtension?: null | undefined | string;
|
|
25
|
+
}>
|
|
26
|
+
| Readonly<{ type: 'haste'; themeFileExtension?: null | undefined | string }>
|
|
27
|
+
| Readonly<{
|
|
24
28
|
type: 'experimental_crossFileParsing';
|
|
25
29
|
rootDir: string;
|
|
26
|
-
themeFileExtension?: string;
|
|
27
|
-
}
|
|
30
|
+
themeFileExtension?: null | undefined | string;
|
|
31
|
+
}>;
|
|
28
32
|
export type StyleXOptions = Readonly<
|
|
29
33
|
Omit<
|
|
30
34
|
RuntimeOptions,
|
|
@@ -38,7 +42,7 @@ export type StyleXOptions = Readonly<
|
|
|
38
42
|
| Readonly<{ from: string; as: string }>;
|
|
39
43
|
treeshakeCompensation?: boolean;
|
|
40
44
|
genConditionalClasses: boolean;
|
|
41
|
-
unstable_moduleResolution:
|
|
45
|
+
unstable_moduleResolution: null | undefined | ModuleResolution;
|
|
42
46
|
})
|
|
43
47
|
> & {
|
|
44
48
|
importSources: ReadonlyArray<
|
|
@@ -50,7 +54,7 @@ export type StyleXOptions = Readonly<
|
|
|
50
54
|
| Readonly<{ from: string; as: string }>;
|
|
51
55
|
treeshakeCompensation?: boolean;
|
|
52
56
|
genConditionalClasses: boolean;
|
|
53
|
-
unstable_moduleResolution:
|
|
57
|
+
unstable_moduleResolution: null | undefined | ModuleResolution;
|
|
54
58
|
}
|
|
55
59
|
>;
|
|
56
60
|
type StyleXStateOptions = Readonly<
|
|
@@ -59,12 +63,12 @@ type StyleXStateOptions = Readonly<
|
|
|
59
63
|
keyof ({
|
|
60
64
|
runtimeInjection:
|
|
61
65
|
| (null | undefined | string)
|
|
62
|
-
| Readonly<{ from: string; as: string }>;
|
|
66
|
+
| Readonly<{ from: string; as: null | undefined | string }>;
|
|
63
67
|
})
|
|
64
68
|
> & {
|
|
65
69
|
runtimeInjection:
|
|
66
70
|
| (null | undefined | string)
|
|
67
|
-
| Readonly<{ from: string; as: string }>;
|
|
71
|
+
| Readonly<{ from: string; as: null | undefined | string }>;
|
|
68
72
|
}
|
|
69
73
|
>;
|
|
70
74
|
declare class StateManager {
|
|
@@ -72,6 +76,7 @@ declare class StateManager {
|
|
|
72
76
|
readonly importPaths: Set<string>;
|
|
73
77
|
readonly stylexImport: Set<string>;
|
|
74
78
|
readonly stylexPropsImport: Set<string>;
|
|
79
|
+
readonly stylexAttrsImport: Set<string>;
|
|
75
80
|
readonly stylexCreateImport: Set<string>;
|
|
76
81
|
readonly stylexIncludeImport: Set<string>;
|
|
77
82
|
readonly stylexFirstThatWorksImport: Set<string>;
|
|
@@ -84,8 +89,11 @@ declare class StateManager {
|
|
|
84
89
|
readonly styleVars: Map<string, NodePath>;
|
|
85
90
|
readonly styleVarsToKeep: Set<[string, true | string, true | Array<string>]>;
|
|
86
91
|
inStyleXCreate: boolean;
|
|
92
|
+
readonly options: StyleXStateOptions;
|
|
87
93
|
constructor(state: PluginPass);
|
|
88
|
-
|
|
94
|
+
setOptions(options: {
|
|
95
|
+
readonly [$$Key$$: string]: unknown;
|
|
96
|
+
}): StyleXStateOptions;
|
|
89
97
|
get importPathString(): string;
|
|
90
98
|
get importSources(): ReadonlyArray<string>;
|
|
91
99
|
importAs(source: string): null | string;
|
|
@@ -94,7 +102,7 @@ declare class StateManager {
|
|
|
94
102
|
get runtimeInjection():
|
|
95
103
|
| null
|
|
96
104
|
| undefined
|
|
97
|
-
| Readonly<{ from: string; as?: string }>;
|
|
105
|
+
| Readonly<{ from: string; as?: null | undefined | string }>;
|
|
98
106
|
get isDev(): boolean;
|
|
99
107
|
get isTest(): boolean;
|
|
100
108
|
get filename(): string | void;
|
|
@@ -19,20 +19,20 @@ export type ImportPathResolution =
|
|
|
19
19
|
| ['themeNameRef' | 'filePath', string];
|
|
20
20
|
|
|
21
21
|
type ModuleResolution =
|
|
22
|
-
| {
|
|
22
|
+
| $ReadOnly<{
|
|
23
23
|
type: 'commonJS',
|
|
24
24
|
rootDir: string,
|
|
25
|
-
themeFileExtension?: string,
|
|
26
|
-
}
|
|
27
|
-
| {
|
|
25
|
+
themeFileExtension?: ?string,
|
|
26
|
+
}>
|
|
27
|
+
| $ReadOnly<{
|
|
28
28
|
type: 'haste',
|
|
29
|
-
themeFileExtension?: string,
|
|
30
|
-
}
|
|
31
|
-
| {
|
|
29
|
+
themeFileExtension?: ?string,
|
|
30
|
+
}>
|
|
31
|
+
| $ReadOnly<{
|
|
32
32
|
type: 'experimental_crossFileParsing',
|
|
33
33
|
rootDir: string,
|
|
34
|
-
themeFileExtension?: string,
|
|
35
|
-
}
|
|
34
|
+
themeFileExtension?: ?string,
|
|
35
|
+
}>;
|
|
36
36
|
|
|
37
37
|
export type StyleXOptions = $ReadOnly<{
|
|
38
38
|
...RuntimeOptions,
|
|
@@ -42,13 +42,13 @@ export type StyleXOptions = $ReadOnly<{
|
|
|
42
42
|
runtimeInjection: boolean | ?string | $ReadOnly<{ from: string, as: string }>,
|
|
43
43
|
treeshakeCompensation?: boolean,
|
|
44
44
|
genConditionalClasses: boolean,
|
|
45
|
-
unstable_moduleResolution:
|
|
45
|
+
unstable_moduleResolution: ?ModuleResolution,
|
|
46
46
|
...
|
|
47
47
|
}>;
|
|
48
48
|
|
|
49
49
|
type StyleXStateOptions = $ReadOnly<{
|
|
50
50
|
...StyleXOptions,
|
|
51
|
-
runtimeInjection: ?string | $ReadOnly<{ from: string, as: string }>,
|
|
51
|
+
runtimeInjection: ?string | $ReadOnly<{ from: string, as: ?string }>,
|
|
52
52
|
...
|
|
53
53
|
}>;
|
|
54
54
|
|
|
@@ -57,6 +57,7 @@ declare export default class StateManager {
|
|
|
57
57
|
+importPaths: Set<string>;
|
|
58
58
|
+stylexImport: Set<string>;
|
|
59
59
|
+stylexPropsImport: Set<string>;
|
|
60
|
+
+stylexAttrsImport: Set<string>;
|
|
60
61
|
+stylexCreateImport: Set<string>;
|
|
61
62
|
+stylexIncludeImport: Set<string>;
|
|
62
63
|
+stylexFirstThatWorksImport: Set<string>;
|
|
@@ -69,14 +70,15 @@ declare export default class StateManager {
|
|
|
69
70
|
+styleVars: Map<string, NodePath<>>;
|
|
70
71
|
+styleVarsToKeep: Set<[string, true | string, true | Array<string>]>;
|
|
71
72
|
inStyleXCreate: boolean;
|
|
73
|
+
+options: StyleXStateOptions;
|
|
72
74
|
constructor(state: PluginPass): void;
|
|
73
|
-
|
|
75
|
+
setOptions(options: { +[string]: mixed }): StyleXStateOptions;
|
|
74
76
|
get importPathString(): string;
|
|
75
77
|
get importSources(): $ReadOnlyArray<string>;
|
|
76
78
|
importAs(source: string): null | string;
|
|
77
79
|
get canReferenceTheme(): boolean;
|
|
78
80
|
get metadata(): { [key: string]: any };
|
|
79
|
-
get runtimeInjection(): ?$ReadOnly<{ from: string, as?: string }>;
|
|
81
|
+
get runtimeInjection(): ?$ReadOnly<{ from: string, as?: ?string }>;
|
|
80
82
|
get isDev(): boolean;
|
|
81
83
|
get isTest(): boolean;
|
|
82
84
|
get filename(): string | void;
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
export type Check<T> = (val: unknown, name?: string) => Error | T;
|
|
11
|
+
export type InferCheckType<T> = T extends Check<infer U>
|
|
12
|
+
? U
|
|
13
|
+
: /**
|
|
14
|
+
* > 11 | export type InferCheckType<T> = T extends Check<infer U> ? U : empty;
|
|
15
|
+
* | ^^^^^ Unsupported feature: Translating "empty type" is currently not supported.
|
|
16
|
+
**/
|
|
17
|
+
any;
|
|
18
|
+
type Msg = (value: unknown, name?: string) => string;
|
|
19
|
+
type PrimitiveChecker<T> = (message?: Msg) => Check<T>;
|
|
20
|
+
export declare const string: PrimitiveChecker<string>;
|
|
21
|
+
export declare const nullish: PrimitiveChecker<null | void>;
|
|
22
|
+
export declare const boolean: PrimitiveChecker<boolean>;
|
|
23
|
+
export declare const number: PrimitiveChecker<number>;
|
|
24
|
+
export declare const literal: <T extends string | number | boolean>(
|
|
25
|
+
$$PARAM_0$$: T,
|
|
26
|
+
msg?: Msg,
|
|
27
|
+
) => Check<T>;
|
|
28
|
+
export declare const array: <T>(
|
|
29
|
+
$$PARAM_0$$: Check<T>,
|
|
30
|
+
msg?: Msg,
|
|
31
|
+
) => Check<ReadonlyArray<T>>;
|
|
32
|
+
type ObjOfChecks<T extends { readonly [$$Key$$: string]: Check<unknown> }> =
|
|
33
|
+
Readonly<{ [K in keyof T]: InferCheckType<T[K]> }>;
|
|
34
|
+
export declare const object: <
|
|
35
|
+
T extends { readonly [$$Key$$: string]: Check<unknown> },
|
|
36
|
+
>(
|
|
37
|
+
$$PARAM_0$$: T,
|
|
38
|
+
msg?: Msg,
|
|
39
|
+
) => Check<ObjOfChecks<T>>;
|
|
40
|
+
export declare const objectOf: <T>(
|
|
41
|
+
$$PARAM_0$$: Check<T>,
|
|
42
|
+
$$PARAM_1$$: Msg,
|
|
43
|
+
) => Check<{ readonly [$$Key$$: string]: T }>;
|
|
44
|
+
export declare const unionOf: <A, B>(
|
|
45
|
+
a: Check<A>,
|
|
46
|
+
b: Check<B>,
|
|
47
|
+
message: Msg,
|
|
48
|
+
) => Check<A | B>;
|
|
49
|
+
export declare const unionOf3: <A, B, C>(
|
|
50
|
+
a: Check<A>,
|
|
51
|
+
b: Check<B>,
|
|
52
|
+
c: Check<C>,
|
|
53
|
+
message: Msg,
|
|
54
|
+
) => Check<A | B | C>;
|
|
55
|
+
export declare const unionOf4: <A, B, C, D>(
|
|
56
|
+
a: Check<A>,
|
|
57
|
+
b: Check<B>,
|
|
58
|
+
c: Check<C>,
|
|
59
|
+
d: Check<D>,
|
|
60
|
+
message: Msg,
|
|
61
|
+
) => Check<A | B | C | D>;
|
|
62
|
+
export declare const logAndDefault: <T>(
|
|
63
|
+
check: Check<T>,
|
|
64
|
+
value: unknown,
|
|
65
|
+
def: T,
|
|
66
|
+
name?: string,
|
|
67
|
+
) => T;
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
export type Check<+T> = (val: mixed, name?: string) => Error | T;
|
|
11
|
+
export type InferCheckType<T> = T extends Check<infer U> ? U : empty;
|
|
12
|
+
|
|
13
|
+
type Msg = (value: mixed, name?: string) => string;
|
|
14
|
+
type PrimitiveChecker<+T> = (message?: Msg) => Check<T>;
|
|
15
|
+
|
|
16
|
+
declare export const string: PrimitiveChecker<string>;
|
|
17
|
+
|
|
18
|
+
declare export const nullish: PrimitiveChecker<null | void>;
|
|
19
|
+
|
|
20
|
+
declare export const boolean: PrimitiveChecker<boolean>;
|
|
21
|
+
|
|
22
|
+
declare export const number: PrimitiveChecker<number>;
|
|
23
|
+
|
|
24
|
+
declare export const literal: <T: string | number | boolean>(
|
|
25
|
+
T,
|
|
26
|
+
msg?: Msg,
|
|
27
|
+
) => Check<T>;
|
|
28
|
+
|
|
29
|
+
declare export const array: <T>(
|
|
30
|
+
Check<T>,
|
|
31
|
+
msg?: Msg,
|
|
32
|
+
) => Check<$ReadOnlyArray<T>>;
|
|
33
|
+
|
|
34
|
+
type ObjOfChecks<T: { +[string]: Check<mixed> }> = $ReadOnly<{
|
|
35
|
+
[K in keyof T]: InferCheckType<T[K]>,
|
|
36
|
+
}>;
|
|
37
|
+
|
|
38
|
+
declare export const object: <T: { +[string]: Check<mixed> }>(
|
|
39
|
+
T,
|
|
40
|
+
msg?: Msg,
|
|
41
|
+
) => Check<ObjOfChecks<T>>;
|
|
42
|
+
|
|
43
|
+
declare export const objectOf: <T>(Check<T>, Msg) => Check<{ +[string]: T }>;
|
|
44
|
+
|
|
45
|
+
declare export const unionOf: <A, B>(
|
|
46
|
+
a: Check<A>,
|
|
47
|
+
b: Check<B>,
|
|
48
|
+
message: Msg,
|
|
49
|
+
) => Check<A | B>;
|
|
50
|
+
|
|
51
|
+
declare export const unionOf3: <A, B, C>(
|
|
52
|
+
a: Check<A>,
|
|
53
|
+
b: Check<B>,
|
|
54
|
+
c: Check<C>,
|
|
55
|
+
message: Msg,
|
|
56
|
+
) => Check<A | B | C>;
|
|
57
|
+
|
|
58
|
+
declare export const unionOf4: <A, B, C, D>(
|
|
59
|
+
a: Check<A>,
|
|
60
|
+
b: Check<B>,
|
|
61
|
+
c: Check<C>,
|
|
62
|
+
d: Check<D>,
|
|
63
|
+
message: Msg,
|
|
64
|
+
) => Check<A | B | C | D>;
|
|
65
|
+
|
|
66
|
+
declare export const logAndDefault: <T>(
|
|
67
|
+
check: Check<T>,
|
|
68
|
+
value: mixed,
|
|
69
|
+
def: T,
|
|
70
|
+
name?: string,
|
|
71
|
+
) => T;
|
|
@@ -0,0 +1,21 @@
|
|
|
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 type { NodePath } from '@babel/traverse';
|
|
11
|
+
import * as t from '@babel/types';
|
|
12
|
+
import StateManager from '../utils/state-manager';
|
|
13
|
+
export declare function skipStylexAttrsChildren(
|
|
14
|
+
path: NodePath<t.CallExpression>,
|
|
15
|
+
state: StateManager,
|
|
16
|
+
): void;
|
|
17
|
+
declare function transformStylexAttrs(
|
|
18
|
+
path: NodePath<t.CallExpression>,
|
|
19
|
+
state: StateManager,
|
|
20
|
+
): void;
|
|
21
|
+
export default transformStylexAttrs;
|
|
@@ -0,0 +1,25 @@
|
|
|
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 type { NodePath } from '../../flow_modules/@babel/traverse';
|
|
11
|
+
|
|
12
|
+
import * as t from '../../flow_modules/@babel/types';
|
|
13
|
+
import StateManager from '../utils/state-manager';
|
|
14
|
+
declare export function skipStylexAttrsChildren(
|
|
15
|
+
path: NodePath<t.CallExpression>,
|
|
16
|
+
state: StateManager,
|
|
17
|
+
): void;
|
|
18
|
+
|
|
19
|
+
// If a `stylex()` call uses styles that are all locally defined,
|
|
20
|
+
// This function is able to pre-compute that into a single string or
|
|
21
|
+
// a single expression of strings and ternary expressions.
|
|
22
|
+
declare export default function transformStylexAttrs(
|
|
23
|
+
path: NodePath<t.CallExpression>,
|
|
24
|
+
state: StateManager,
|
|
25
|
+
): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stylexjs/babel-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0-alpha.1",
|
|
4
4
|
"description": "StyleX babel plugin.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"repository": "https://github.com/facebook/stylex",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@babel/helper-module-imports": "^7.22.15",
|
|
16
|
-
"@stylexjs/shared": "0.
|
|
17
|
-
"@stylexjs/stylex": "0.
|
|
16
|
+
"@stylexjs/shared": "0.5.0-alpha.1",
|
|
17
|
+
"@stylexjs/stylex": "0.5.0-alpha.1",
|
|
18
18
|
"@babel/core": "^7.23.6",
|
|
19
19
|
"@babel/traverse": "^7.23.6",
|
|
20
20
|
"@babel/types": "^7.23.6"
|