@stylexjs/babel-plugin 0.5.0-alpha.4 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +132 -41
- package/lib/utils/state-manager.d.ts +16 -0
- package/lib/utils/state-manager.js.flow +2 -0
- package/lib/utils/validate.d.ts +1 -1
- package/lib/utils/validate.js.flow +4 -1
- package/package.json +4 -3
package/lib/index.js
CHANGED
|
@@ -30,6 +30,7 @@ var name = "@stylexjs/stylex";
|
|
|
30
30
|
|
|
31
31
|
const defaultMessage = expected => (value, name) => name ? `Expected (${name}) to be ${expected}, but got \`${JSON.stringify(value)}\`.` : expected;
|
|
32
32
|
const defaultUnionMessage = expected => (value, name) => name ? `Expected (${name}) to be ${expected}` : expected;
|
|
33
|
+
const defaultObjectMessage = expected => (value, name) => name ? `Expected (${name}) to be ${expected} but:` : expected;
|
|
33
34
|
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
35
|
const string = function () {
|
|
35
36
|
let message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultMessage('a string');
|
|
@@ -104,6 +105,23 @@ const object = function (shape) {
|
|
|
104
105
|
return result;
|
|
105
106
|
};
|
|
106
107
|
};
|
|
108
|
+
const objectOf = function (check) {
|
|
109
|
+
let message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultObjectMessage('an object');
|
|
110
|
+
return (value, name) => {
|
|
111
|
+
if (typeof value !== 'object' || value == null) {
|
|
112
|
+
return new Error(message(value, name));
|
|
113
|
+
}
|
|
114
|
+
const result = {};
|
|
115
|
+
for (const key in value) {
|
|
116
|
+
const item = check(value[key], name ? `${name}.${key}` : `With the key '${key}':`);
|
|
117
|
+
if (item instanceof Error) {
|
|
118
|
+
return new Error(`${message(value, name)}${indent(item.message)}\nBut got: ${indent(JSON.stringify(value))}`);
|
|
119
|
+
}
|
|
120
|
+
result[key] = item;
|
|
121
|
+
}
|
|
122
|
+
return result;
|
|
123
|
+
};
|
|
124
|
+
};
|
|
107
125
|
const unionOf = function (a, b) {
|
|
108
126
|
let message = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultUnionMessage('one of');
|
|
109
127
|
return (value, name) => {
|
|
@@ -314,8 +332,16 @@ class StateManager {
|
|
|
314
332
|
const styleResolution = logAndDefault(unionOf3(literal('application-order'), literal('property-specificity'), literal('legacy-expand-shorthands')), options.styleResolution ?? 'application-order', 'application-order', 'options.styleResolution');
|
|
315
333
|
const unstable_moduleResolution = logAndDefault(unionOf(nullish(), CheckModuleResolution), options.unstable_moduleResolution, null, 'options.unstable_moduleResolution');
|
|
316
334
|
const treeshakeCompensation = logAndDefault(boolean(), options.treeshakeCompensation ?? false, false, 'options.treeshakeCompensation');
|
|
335
|
+
const aliasesOption = logAndDefault(unionOf(nullish(), objectOf(unionOf(string(), array(string())))), options.aliases, null, 'options.aliases');
|
|
336
|
+
const aliases = aliasesOption == null ? aliasesOption : Object.fromEntries(Object.entries(aliasesOption).map(_ref => {
|
|
337
|
+
let [key, value] = _ref;
|
|
338
|
+
if (typeof value === 'string') {
|
|
339
|
+
return [key, [value]];
|
|
340
|
+
}
|
|
341
|
+
return [key, value];
|
|
342
|
+
}));
|
|
317
343
|
const opts = {
|
|
318
|
-
|
|
344
|
+
aliases,
|
|
319
345
|
dev,
|
|
320
346
|
test,
|
|
321
347
|
runtimeInjection,
|
|
@@ -372,17 +398,20 @@ class StateManager {
|
|
|
372
398
|
return identifier;
|
|
373
399
|
}
|
|
374
400
|
const bodyPath = programPath.get('body');
|
|
375
|
-
let
|
|
401
|
+
let targetImportIndex = -1;
|
|
376
402
|
for (let i = 0; i < bodyPath.length; i++) {
|
|
377
403
|
const statement = bodyPath[i];
|
|
378
404
|
if (isImportDeclaration(statement)) {
|
|
379
|
-
|
|
405
|
+
targetImportIndex = i;
|
|
406
|
+
if (statement.node.specifiers.find(s => s.type === 'ImportSpecifier' && s.local.type === 'Identifier' && s.local.name === identifier.name)) {
|
|
407
|
+
break;
|
|
408
|
+
}
|
|
380
409
|
}
|
|
381
410
|
}
|
|
382
|
-
if (
|
|
411
|
+
if (targetImportIndex === -1) {
|
|
383
412
|
return identifier;
|
|
384
413
|
}
|
|
385
|
-
const lastImport = bodyPath[
|
|
414
|
+
const lastImport = bodyPath[targetImportIndex];
|
|
386
415
|
if (lastImport == null) {
|
|
387
416
|
return identifier;
|
|
388
417
|
}
|
|
@@ -397,17 +426,20 @@ class StateManager {
|
|
|
397
426
|
return identifier;
|
|
398
427
|
}
|
|
399
428
|
const bodyPath = programPath.get('body');
|
|
400
|
-
let
|
|
429
|
+
let targetImportIndex = -1;
|
|
401
430
|
for (let i = 0; i < bodyPath.length; i++) {
|
|
402
431
|
const statement = bodyPath[i];
|
|
403
432
|
if (isImportDeclaration(statement)) {
|
|
404
|
-
|
|
433
|
+
targetImportIndex = i;
|
|
434
|
+
if (statement.node.specifiers.find(s => s.type === 'ImportDefaultSpecifier' && s.local.type === 'Identifier' && s.local.name === identifier.name)) {
|
|
435
|
+
break;
|
|
436
|
+
}
|
|
405
437
|
}
|
|
406
438
|
}
|
|
407
|
-
if (
|
|
439
|
+
if (targetImportIndex === -1) {
|
|
408
440
|
return identifier;
|
|
409
441
|
}
|
|
410
|
-
const lastImport = bodyPath[
|
|
442
|
+
const lastImport = bodyPath[targetImportIndex];
|
|
411
443
|
if (lastImport == null) {
|
|
412
444
|
return identifier;
|
|
413
445
|
}
|
|
@@ -455,11 +487,12 @@ class StateManager {
|
|
|
455
487
|
case 'commonJS':
|
|
456
488
|
{
|
|
457
489
|
const rootDir = this.options.unstable_moduleResolution.rootDir;
|
|
458
|
-
const
|
|
490
|
+
const aliases = this.options.aliases;
|
|
491
|
+
const themeFileExtension = this.options.unstable_moduleResolution?.themeFileExtension ?? '.stylex';
|
|
459
492
|
if (!matchesFileSuffix(themeFileExtension)(importPath)) {
|
|
460
493
|
return false;
|
|
461
494
|
}
|
|
462
|
-
const resolvedFilePath = filePathResolver(importPath, sourceFilePath);
|
|
495
|
+
const resolvedFilePath = filePathResolver(importPath, sourceFilePath, aliases);
|
|
463
496
|
return resolvedFilePath ? ['themeNameRef', path.relative(rootDir, resolvedFilePath)] : false;
|
|
464
497
|
}
|
|
465
498
|
case 'haste':
|
|
@@ -472,11 +505,12 @@ class StateManager {
|
|
|
472
505
|
}
|
|
473
506
|
case 'experimental_crossFileParsing':
|
|
474
507
|
{
|
|
508
|
+
const aliases = this.options.aliases;
|
|
475
509
|
const themeFileExtension = this.options.unstable_moduleResolution.themeFileExtension ?? '.stylex';
|
|
476
510
|
if (!matchesFileSuffix(themeFileExtension)(importPath)) {
|
|
477
511
|
return false;
|
|
478
512
|
}
|
|
479
|
-
const resolvedFilePath = filePathResolver(importPath, sourceFilePath);
|
|
513
|
+
const resolvedFilePath = filePathResolver(importPath, sourceFilePath, aliases);
|
|
480
514
|
return resolvedFilePath ? ['filePath', resolvedFilePath] : false;
|
|
481
515
|
}
|
|
482
516
|
default:
|
|
@@ -490,25 +524,48 @@ class StateManager {
|
|
|
490
524
|
this.styleVarsToKeep.add(memberExpression);
|
|
491
525
|
}
|
|
492
526
|
}
|
|
493
|
-
|
|
494
|
-
const
|
|
495
|
-
if (
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
527
|
+
function possibleAliasedPaths(importPath, aliases) {
|
|
528
|
+
const result = [importPath];
|
|
529
|
+
if (aliases == null || Object.keys(aliases).length === 0) {
|
|
530
|
+
return result;
|
|
531
|
+
}
|
|
532
|
+
for (const [alias, value] of Object.entries(aliases)) {
|
|
533
|
+
if (alias.includes('*')) {
|
|
534
|
+
const [before, after] = alias.split('*');
|
|
535
|
+
if (importPath.startsWith(before) && importPath.endsWith(after)) {
|
|
536
|
+
const replacementString = importPath.slice(before.length, after.length > 0 ? -after.length : undefined);
|
|
537
|
+
value.forEach(v => {
|
|
538
|
+
result.push(v.split('*').join(replacementString));
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
} else if (alias === importPath) {
|
|
542
|
+
value.forEach(v => {
|
|
543
|
+
result.push(v);
|
|
508
544
|
});
|
|
509
|
-
|
|
510
|
-
} catch {}
|
|
545
|
+
}
|
|
511
546
|
}
|
|
547
|
+
return result;
|
|
548
|
+
}
|
|
549
|
+
const filePathResolver = (relativeFilePath, sourceFilePath, aliases) => {
|
|
550
|
+
for (const ext of ['', ...EXTENSIONS]) {
|
|
551
|
+
const importPathStr = relativeFilePath + ext;
|
|
552
|
+
if (importPathStr.startsWith('.')) {
|
|
553
|
+
try {
|
|
554
|
+
return require.resolve(importPathStr, {
|
|
555
|
+
paths: [path.dirname(sourceFilePath)]
|
|
556
|
+
});
|
|
557
|
+
} catch {}
|
|
558
|
+
}
|
|
559
|
+
const allAliases = possibleAliasedPaths(importPathStr, aliases);
|
|
560
|
+
for (const possiblePath of allAliases) {
|
|
561
|
+
try {
|
|
562
|
+
return require.resolve(possiblePath, {
|
|
563
|
+
paths: [path.dirname(sourceFilePath)]
|
|
564
|
+
});
|
|
565
|
+
} catch {}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
return null;
|
|
512
569
|
};
|
|
513
570
|
const EXTENSIONS = ['.js', '.ts', '.tsx', '.jsx', '.mjs', '.cjs'];
|
|
514
571
|
const addFileExtension = (importedFilePath, sourceFile) => {
|
|
@@ -1320,7 +1377,10 @@ function getExpandedKeys(options) {
|
|
|
1320
1377
|
return Object.keys(expansions[options.styleResolution ?? 'application-order']);
|
|
1321
1378
|
}
|
|
1322
1379
|
function flatMapExpandedShorthands(objEntry, options) {
|
|
1323
|
-
|
|
1380
|
+
let [key, value] = objEntry;
|
|
1381
|
+
if (key.startsWith('var(') && key.endsWith(')')) {
|
|
1382
|
+
key = key.slice(4, -1);
|
|
1383
|
+
}
|
|
1324
1384
|
const expansion = expansions[options.styleResolution ?? 'application-order'][key];
|
|
1325
1385
|
if (expansion) {
|
|
1326
1386
|
if (Array.isArray(value)) {
|
|
@@ -1502,6 +1562,16 @@ function normalizeWhitespace(ast, _) {
|
|
|
1502
1562
|
break;
|
|
1503
1563
|
}
|
|
1504
1564
|
case 'div':
|
|
1565
|
+
{
|
|
1566
|
+
if (node.value === ',') {
|
|
1567
|
+
node.before = '';
|
|
1568
|
+
node.after = '';
|
|
1569
|
+
} else {
|
|
1570
|
+
node.before = ' ';
|
|
1571
|
+
node.after = ' ';
|
|
1572
|
+
}
|
|
1573
|
+
break;
|
|
1574
|
+
}
|
|
1505
1575
|
case 'function':
|
|
1506
1576
|
{
|
|
1507
1577
|
node.before = '';
|
|
@@ -1533,7 +1603,14 @@ function _interopRequireDefault$b(obj) { return obj && obj.__esModule ? obj : {
|
|
|
1533
1603
|
const angles = ['deg', 'grad', 'turn', 'rad'];
|
|
1534
1604
|
const timings = ['ms', 's'];
|
|
1535
1605
|
function normalizeZeroDimensions(ast, _) {
|
|
1606
|
+
let endFunction = 0;
|
|
1536
1607
|
ast.walk(node => {
|
|
1608
|
+
if (node.type === 'function' && !endFunction) {
|
|
1609
|
+
endFunction = node.sourceEndIndex ?? 0;
|
|
1610
|
+
}
|
|
1611
|
+
if (endFunction > 0 && node.sourceIndex > endFunction) {
|
|
1612
|
+
endFunction = 0;
|
|
1613
|
+
}
|
|
1537
1614
|
if (node.type !== 'word') {
|
|
1538
1615
|
return;
|
|
1539
1616
|
}
|
|
@@ -1545,7 +1622,7 @@ function normalizeZeroDimensions(ast, _) {
|
|
|
1545
1622
|
node.value = '0deg';
|
|
1546
1623
|
} else if (timings.indexOf(dimension.unit) !== -1) {
|
|
1547
1624
|
node.value = '0s';
|
|
1548
|
-
} else {
|
|
1625
|
+
} else if (!endFunction) {
|
|
1549
1626
|
node.value = '0';
|
|
1550
1627
|
}
|
|
1551
1628
|
});
|
|
@@ -1982,6 +2059,7 @@ var propertyPriorities = {};
|
|
|
1982
2059
|
Object.defineProperty(propertyPriorities, "__esModule", {
|
|
1983
2060
|
value: true
|
|
1984
2061
|
});
|
|
2062
|
+
propertyPriorities.PSEUDO_ELEMENT_PRIORITY = propertyPriorities.PSEUDO_CLASS_PRIORITIES = propertyPriorities.AT_RULE_PRIORITIES = void 0;
|
|
1985
2063
|
propertyPriorities.default = getPriority;
|
|
1986
2064
|
const longHandPhysical = new Set();
|
|
1987
2065
|
const longHandLogical = new Set();
|
|
@@ -2419,7 +2497,7 @@ longHandLogical.add('math-depth');
|
|
|
2419
2497
|
longHandLogical.add('math-shift');
|
|
2420
2498
|
longHandLogical.add('math-style');
|
|
2421
2499
|
longHandLogical.add('touch-action');
|
|
2422
|
-
const
|
|
2500
|
+
const PSEUDO_CLASS_PRIORITIES = propertyPriorities.PSEUDO_CLASS_PRIORITIES = {
|
|
2423
2501
|
':is': 40,
|
|
2424
2502
|
':where': 40,
|
|
2425
2503
|
':not': 40,
|
|
@@ -2474,25 +2552,31 @@ const PRIORITIES = {
|
|
|
2474
2552
|
':focusVisible': 160,
|
|
2475
2553
|
':active': 170
|
|
2476
2554
|
};
|
|
2555
|
+
const AT_RULE_PRIORITIES = propertyPriorities.AT_RULE_PRIORITIES = {
|
|
2556
|
+
'@supports': 30,
|
|
2557
|
+
'@media': 200,
|
|
2558
|
+
'@container': 300
|
|
2559
|
+
};
|
|
2560
|
+
const PSEUDO_ELEMENT_PRIORITY = propertyPriorities.PSEUDO_ELEMENT_PRIORITY = 5000;
|
|
2477
2561
|
function getPriority(key) {
|
|
2478
2562
|
if (key.startsWith('--')) {
|
|
2479
2563
|
return 1;
|
|
2480
2564
|
}
|
|
2481
2565
|
if (key.startsWith('@supports')) {
|
|
2482
|
-
return
|
|
2566
|
+
return AT_RULE_PRIORITIES['@supports'];
|
|
2483
2567
|
}
|
|
2484
2568
|
if (key.startsWith('@media')) {
|
|
2485
|
-
return
|
|
2569
|
+
return AT_RULE_PRIORITIES['@media'];
|
|
2486
2570
|
}
|
|
2487
2571
|
if (key.startsWith('@container')) {
|
|
2488
|
-
return
|
|
2572
|
+
return AT_RULE_PRIORITIES['@container'];
|
|
2489
2573
|
}
|
|
2490
2574
|
if (key.startsWith('::')) {
|
|
2491
|
-
return
|
|
2575
|
+
return PSEUDO_ELEMENT_PRIORITY;
|
|
2492
2576
|
}
|
|
2493
2577
|
if (key.startsWith(':')) {
|
|
2494
2578
|
const prop = key.startsWith(':') && key.includes('(') ? key.slice(0, key.indexOf('(')) : key;
|
|
2495
|
-
return
|
|
2579
|
+
return PSEUDO_CLASS_PRIORITIES[prop] ?? 40;
|
|
2496
2580
|
}
|
|
2497
2581
|
if (longHandPhysical.has(key)) {
|
|
2498
2582
|
return 4000;
|
|
@@ -2516,7 +2600,7 @@ generateCssRule.generateRule = generateRule;
|
|
|
2516
2600
|
var _generateLtr$1 = _interopRequireDefault$6(generateLtr);
|
|
2517
2601
|
var _generateRtl$1 = _interopRequireDefault$6(generateRtl);
|
|
2518
2602
|
var _genCSSRule = genCSSRule$1;
|
|
2519
|
-
var _propertyPriorities = _interopRequireDefault$6(propertyPriorities);
|
|
2603
|
+
var _propertyPriorities$1 = _interopRequireDefault$6(propertyPriorities);
|
|
2520
2604
|
function _interopRequireDefault$6(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2521
2605
|
function generateRule(className, key, value, pseudos, atRules) {
|
|
2522
2606
|
const pairs = Array.isArray(value) ? value.map(eachValue => [key, eachValue]) : [[key, value]];
|
|
@@ -2525,7 +2609,7 @@ function generateRule(className, key, value, pseudos, atRules) {
|
|
|
2525
2609
|
const rtlDecls = pairs.map(_generateRtl$1.default).filter(Boolean).map(pair => pair.join(':')).join(';');
|
|
2526
2610
|
const ltrRule = (0, _genCSSRule.genCSSRule)(className, ltrDecls, pseudos, atRules);
|
|
2527
2611
|
const rtlRule = !rtlDecls ? null : (0, _genCSSRule.genCSSRule)(className, rtlDecls, pseudos, atRules);
|
|
2528
|
-
const priority = (0, _propertyPriorities.default)(key) + pseudos.map(_propertyPriorities.default).reduce((a, b) => a + b, 0) + atRules.map(_propertyPriorities.default).reduce((a, b) => a + b, 0);
|
|
2612
|
+
const priority = (0, _propertyPriorities$1.default)(key) + pseudos.map(_propertyPriorities$1.default).reduce((a, b) => a + b, 0) + atRules.map(_propertyPriorities$1.default).reduce((a, b) => a + b, 0);
|
|
2529
2613
|
return {
|
|
2530
2614
|
priority,
|
|
2531
2615
|
ltr: ltrRule,
|
|
@@ -3331,7 +3415,7 @@ var messages_1;
|
|
|
3331
3415
|
Object.defineProperty(lib, "__esModule", {
|
|
3332
3416
|
value: true
|
|
3333
3417
|
});
|
|
3334
|
-
var utils_1 = lib.utils = lib.types = messages_1 = lib.messages = keyframes_1 = lib.keyframes = include_1 = lib.include = firstThatWorks_1 = lib.firstThatWorks = defineVars_1 = lib.defineVars = createTheme_1 = lib.createTheme = create_1 = lib.create = IncludedStyles_1 = lib.IncludedStyles = void 0;
|
|
3418
|
+
var utils_1 = lib.utils = lib.types = messages_1 = lib.messages = keyframes_1 = lib.keyframes = include_1 = lib.include = firstThatWorks_1 = lib.firstThatWorks = defineVars_1 = lib.defineVars = createTheme_1 = lib.createTheme = create_1 = lib.create = lib.PSEUDO_ELEMENT_PRIORITY = lib.PSEUDO_CLASS_PRIORITIES = IncludedStyles_1 = lib.IncludedStyles = lib.AT_RULE_PRIORITIES = void 0;
|
|
3335
3419
|
var _stylexCreate = _interopRequireDefault(stylexCreate$1);
|
|
3336
3420
|
var _stylexDefineVars = _interopRequireDefault(stylexDefineVars$1);
|
|
3337
3421
|
var _stylexCreateTheme = _interopRequireDefault(stylexCreateTheme$1);
|
|
@@ -3343,6 +3427,7 @@ var _fileBasedIdentifier = _interopRequireDefault(fileBasedIdentifier);
|
|
|
3343
3427
|
var m = _interopRequireWildcard(messages$3);
|
|
3344
3428
|
var _types = _interopRequireWildcard(types$1);
|
|
3345
3429
|
lib.types = _types;
|
|
3430
|
+
var _propertyPriorities = propertyPriorities;
|
|
3346
3431
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
3347
3432
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
3348
3433
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -3358,6 +3443,9 @@ utils_1 = lib.utils = {
|
|
|
3358
3443
|
messages_1 = lib.messages = m;
|
|
3359
3444
|
IncludedStyles_1 = lib.IncludedStyles = _stylexInclude.IncludedStyles;
|
|
3360
3445
|
firstThatWorks_1 = lib.firstThatWorks = _stylexFirstThatWorks.default;
|
|
3446
|
+
lib.PSEUDO_CLASS_PRIORITIES = _propertyPriorities.PSEUDO_CLASS_PRIORITIES;
|
|
3447
|
+
lib.AT_RULE_PRIORITIES = _propertyPriorities.AT_RULE_PRIORITIES;
|
|
3448
|
+
lib.PSEUDO_ELEMENT_PRIORITY = _propertyPriorities.PSEUDO_ELEMENT_PRIORITY;
|
|
3361
3449
|
|
|
3362
3450
|
function namespaceToDevClassName(namespace, varName, filename) {
|
|
3363
3451
|
const basename = path.basename(filename).split('.')[0];
|
|
@@ -4016,7 +4104,10 @@ function evaluatePartialObjectRecursively(path, traversalState) {
|
|
|
4016
4104
|
value: null
|
|
4017
4105
|
};
|
|
4018
4106
|
}
|
|
4019
|
-
|
|
4107
|
+
let key = keyResult.value;
|
|
4108
|
+
if (key.startsWith('var(') && key.endsWith(')')) {
|
|
4109
|
+
key = key.slice(4, -1);
|
|
4110
|
+
}
|
|
4020
4111
|
const valuePath = prop.get('value');
|
|
4021
4112
|
if (isObjectExpression(valuePath)) {
|
|
4022
4113
|
const result = evaluatePartialObjectRecursively(valuePath, traversalState, functions, [...keyPath, key]);
|
|
@@ -48,6 +48,10 @@ export type StyleXOptions = Readonly<
|
|
|
48
48
|
treeshakeCompensation?: boolean;
|
|
49
49
|
genConditionalClasses: boolean;
|
|
50
50
|
unstable_moduleResolution: null | undefined | ModuleResolution;
|
|
51
|
+
aliases?:
|
|
52
|
+
| null
|
|
53
|
+
| undefined
|
|
54
|
+
| Readonly<{ [$$Key$$: string]: string | ReadonlyArray<string> }>;
|
|
51
55
|
})
|
|
52
56
|
> & {
|
|
53
57
|
importSources: ReadonlyArray<
|
|
@@ -60,6 +64,10 @@ export type StyleXOptions = Readonly<
|
|
|
60
64
|
treeshakeCompensation?: boolean;
|
|
61
65
|
genConditionalClasses: boolean;
|
|
62
66
|
unstable_moduleResolution: null | undefined | ModuleResolution;
|
|
67
|
+
aliases?:
|
|
68
|
+
| null
|
|
69
|
+
| undefined
|
|
70
|
+
| Readonly<{ [$$Key$$: string]: string | ReadonlyArray<string> }>;
|
|
63
71
|
}
|
|
64
72
|
>;
|
|
65
73
|
type StyleXStateOptions = Readonly<
|
|
@@ -69,11 +77,19 @@ type StyleXStateOptions = Readonly<
|
|
|
69
77
|
runtimeInjection:
|
|
70
78
|
| (null | undefined | string)
|
|
71
79
|
| Readonly<{ from: string; as: null | undefined | string }>;
|
|
80
|
+
aliases?:
|
|
81
|
+
| null
|
|
82
|
+
| undefined
|
|
83
|
+
| Readonly<{ [$$Key$$: string]: ReadonlyArray<string> }>;
|
|
72
84
|
})
|
|
73
85
|
> & {
|
|
74
86
|
runtimeInjection:
|
|
75
87
|
| (null | undefined | string)
|
|
76
88
|
| Readonly<{ from: string; as: null | undefined | string }>;
|
|
89
|
+
aliases?:
|
|
90
|
+
| null
|
|
91
|
+
| undefined
|
|
92
|
+
| Readonly<{ [$$Key$$: string]: ReadonlyArray<string> }>;
|
|
77
93
|
}
|
|
78
94
|
>;
|
|
79
95
|
declare class StateManager {
|
|
@@ -49,12 +49,14 @@ export type StyleXOptions = $ReadOnly<{
|
|
|
49
49
|
treeshakeCompensation?: boolean,
|
|
50
50
|
genConditionalClasses: boolean,
|
|
51
51
|
unstable_moduleResolution: ?ModuleResolution,
|
|
52
|
+
aliases?: ?$ReadOnly<{ [string]: string | $ReadOnlyArray<string> }>,
|
|
52
53
|
...
|
|
53
54
|
}>;
|
|
54
55
|
|
|
55
56
|
type StyleXStateOptions = $ReadOnly<{
|
|
56
57
|
...StyleXOptions,
|
|
57
58
|
runtimeInjection: ?string | $ReadOnly<{ from: string, as: ?string }>,
|
|
59
|
+
aliases?: ?$ReadOnly<{ [string]: $ReadOnlyArray<string> }>,
|
|
58
60
|
...
|
|
59
61
|
}>;
|
|
60
62
|
|
package/lib/utils/validate.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ export declare const object: <
|
|
|
39
39
|
) => Check<ObjOfChecks<T>>;
|
|
40
40
|
export declare const objectOf: <T>(
|
|
41
41
|
$$PARAM_0$$: Check<T>,
|
|
42
|
-
|
|
42
|
+
message?: Msg,
|
|
43
43
|
) => Check<{ readonly [$$Key$$: string]: T }>;
|
|
44
44
|
export declare const unionOf: <A, B>(
|
|
45
45
|
a: Check<A>,
|
|
@@ -40,7 +40,10 @@ declare export const object: <T: { +[string]: Check<mixed> }>(
|
|
|
40
40
|
msg?: Msg,
|
|
41
41
|
) => Check<ObjOfChecks<T>>;
|
|
42
42
|
|
|
43
|
-
declare export const objectOf: <T>(
|
|
43
|
+
declare export const objectOf: <T>(
|
|
44
|
+
Check<T>,
|
|
45
|
+
message?: Msg,
|
|
46
|
+
) => Check<{ +[string]: T }>;
|
|
44
47
|
|
|
45
48
|
declare export const unionOf: <A, B>(
|
|
46
49
|
a: Check<A>,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stylexjs/babel-plugin",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "StyleX babel plugin.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"repository": "https://github.com/facebook/stylex",
|
|
@@ -9,12 +9,13 @@
|
|
|
9
9
|
"prebuild": "gen-types -i src/ -o lib/",
|
|
10
10
|
"build": "rollup --config ./rollup.config.mjs",
|
|
11
11
|
"build-haste": "HASTE=true rollup --config ./rollup.config.mjs",
|
|
12
|
+
"build-watch": "rollup --config ./rollup.config.mjs --watch",
|
|
12
13
|
"test": "jest"
|
|
13
14
|
},
|
|
14
15
|
"dependencies": {
|
|
15
16
|
"@babel/helper-module-imports": "^7.22.15",
|
|
16
|
-
"@stylexjs/shared": "0.5.
|
|
17
|
-
"@stylexjs/stylex": "0.5.
|
|
17
|
+
"@stylexjs/shared": "0.5.1",
|
|
18
|
+
"@stylexjs/stylex": "0.5.1",
|
|
18
19
|
"@babel/core": "^7.23.6",
|
|
19
20
|
"@babel/traverse": "^7.23.6",
|
|
20
21
|
"@babel/types": "^7.23.6"
|