@stylexjs/babel-plugin 0.14.1 → 0.14.3

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 CHANGED
@@ -740,6 +740,7 @@ class StateManager {
740
740
  const enableFontSizePxToRem = logAndDefault(boolean(), options.enableFontSizePxToRem ?? false, false, 'options.enableFontSizePxToRem');
741
741
  const enableInlinedConditionalMerge = logAndDefault(boolean(), options.enableInlinedConditionalMerge ?? true, true, 'options.enableInlinedConditionalMerge');
742
742
  const enableMinifiedKeys = logAndDefault(boolean(), options.enableMinifiedKeys ?? true, true, 'options.enableMinifiedKeys');
743
+ const enableLegacyValueFlipping = logAndDefault(boolean(), options.enableLegacyValueFlipping ?? false, false, 'options.enableLegacyValueFlipping');
743
744
  const enableLogicalStylesPolyfill = logAndDefault(boolean(), options.enableLogicalStylesPolyfill ?? false, false, 'options.enableLogicalStylesPolyfill');
744
745
  const test = logAndDefault(boolean(), options.test ?? false, false, 'options.test');
745
746
  const configRuntimeInjection = logAndDefault(checkRuntimeInjection, options.runtimeInjection ?? false, false, 'options.runtimeInjection');
@@ -770,6 +771,7 @@ class StateManager {
770
771
  enableFontSizePxToRem,
771
772
  enableInlinedConditionalMerge,
772
773
  enableMinifiedKeys,
774
+ enableLegacyValueFlipping,
773
775
  enableLogicalStylesPolyfill,
774
776
  importSources,
775
777
  rewriteAliases: typeof options.rewriteAliases === 'boolean' ? options.rewriteAliases : false,
@@ -1278,6 +1280,7 @@ const defaultOptions = {
1278
1280
  enableDevClassNames: false,
1279
1281
  enableDebugDataProp: true,
1280
1282
  enableFontSizePxToRem: false,
1283
+ enableLegacyValueFlipping: false,
1281
1284
  enableLogicalStylesPolyfill: false,
1282
1285
  enableMinifiedKeys: true,
1283
1286
  styleResolution: 'property-specificity',
@@ -2120,9 +2123,18 @@ const shorthands$1 = {
2120
2123
  }, []);
2121
2124
  return [['containIntrinsicWidth', width], ['containIntrinsicHeight', height]];
2122
2125
  },
2123
- inset: rawValue => [['top', rawValue], ['insetInlineEnd', rawValue], ['bottom', rawValue], ['insetInlineStart', rawValue]],
2124
- insetInline: rawValue => [...shorthands$1.start(rawValue), ...shorthands$1.end(rawValue)],
2125
- insetBlock: rawValue => [['top', rawValue], ['bottom', rawValue]],
2126
+ inset: rawValue => {
2127
+ const [top, right = top, bottom = top, left = right] = splitValue(rawValue);
2128
+ return [['top', top], ['insetInlineEnd', right], ['bottom', bottom], ['insetInlineStart', left]];
2129
+ },
2130
+ insetInline: rawValue => {
2131
+ const [start, end = start] = splitValue(rawValue);
2132
+ return [...shorthands$1.start(start), ...shorthands$1.end(end)];
2133
+ },
2134
+ insetBlock: rawValue => {
2135
+ const [top, bottom = top] = splitValue(rawValue);
2136
+ return [['top', top], ['bottom', bottom]];
2137
+ },
2126
2138
  start: rawValue => [['insetInlineStart', rawValue], ['left', null], ['right', null]],
2127
2139
  end: rawValue => [['insetInlineEnd', rawValue], ['left', null], ['right', null]],
2128
2140
  left: rawValue => [['left', rawValue], ['insetInlineStart', null], ['insetInlineEnd', null]],
@@ -2161,7 +2173,7 @@ const shorthands$1 = {
2161
2173
  },
2162
2174
  paddingStart: val => [['paddingInlineStart', val], ['paddingLeft', null], ['paddingRight', null]],
2163
2175
  paddingEnd: val => [['paddingInlineEnd', val], ['paddingLeft', null], ['paddingRight', null]],
2164
- paddingLeft: val => [['paddingLeft', val], ['paddingStart', null], ['paddingEnd', null]],
2176
+ paddingLeft: val => [['paddingLeft', val], ['paddingInlineStart', null], ['paddingInlineEnd', null]],
2165
2177
  paddingRight: val => [['paddingRight', val], ['paddingInlineStart', null], ['paddingInlineEnd', null]],
2166
2178
  paddingVertical: val => {
2167
2179
  const [top, bottom = top] = splitValue(val);
@@ -2870,7 +2882,7 @@ function flipShadow(value) {
2870
2882
  }
2871
2883
  builtDefs.push(parts.join(' '));
2872
2884
  }
2873
- const rtl = builtDefs.join(', ');
2885
+ const rtl = builtDefs.join(',');
2874
2886
  if (rtl !== value) {
2875
2887
  return rtl;
2876
2888
  }
@@ -3054,43 +3066,55 @@ const propertyToRTL = {
3054
3066
  }
3055
3067
  return [key, words.map(word => word === 'start' || word === 'insetInlineStart' ? 'right' : word === 'end' || word === 'insetInlineEnd' ? 'left' : word).join(' ')];
3056
3068
  },
3057
- cursor: _ref40 => {
3069
+ cursor: function (_ref40) {
3058
3070
  let [key, val] = _ref40;
3071
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultOptions;
3072
+ if (!options.enableLegacyValueFlipping) {
3073
+ return null;
3074
+ }
3059
3075
  return cursorFlip[val] != null ? [key, cursorFlip[val]] : null;
3060
3076
  },
3061
- 'box-shadow': _ref41 => {
3077
+ 'box-shadow': function (_ref41) {
3062
3078
  let [key, val] = _ref41;
3079
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultOptions;
3080
+ if (!options.enableLegacyValueFlipping) {
3081
+ return null;
3082
+ }
3063
3083
  const rtlVal = flipShadow(val);
3064
3084
  return rtlVal ? [key, rtlVal] : null;
3065
3085
  },
3066
- 'text-shadow': _ref42 => {
3086
+ 'text-shadow': function (_ref42) {
3067
3087
  let [key, val] = _ref42;
3088
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultOptions;
3089
+ if (!options.enableLegacyValueFlipping) {
3090
+ return null;
3091
+ }
3068
3092
  const rtlVal = flipShadow(val);
3069
3093
  return rtlVal ? [key, rtlVal] : null;
3070
3094
  }
3071
3095
  };
3072
- function generateRTL(_ref43) {
3073
- let [key, value] = _ref43;
3096
+ function generateRTL(pair) {
3074
3097
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultOptions;
3075
3098
  const {
3076
3099
  enableLogicalStylesPolyfill,
3077
3100
  styleResolution
3078
3101
  } = options;
3102
+ const [key] = pair;
3079
3103
  if (styleResolution === 'legacy-expand-shorthands') {
3080
3104
  if (!enableLogicalStylesPolyfill) {
3081
3105
  if (legacyValuesPolyfill[key]) {
3082
- return legacyValuesPolyfill[key]([key, value]);
3106
+ return legacyValuesPolyfill[key](pair);
3083
3107
  }
3084
3108
  return null;
3085
3109
  }
3086
3110
  if (inlinePropertyToRTL[key]) {
3087
- return inlinePropertyToRTL[key]([key, value]);
3111
+ return inlinePropertyToRTL[key](pair);
3088
3112
  }
3089
3113
  }
3090
3114
  if (!propertyToRTL[key]) {
3091
3115
  return null;
3092
3116
  }
3093
- return propertyToRTL[key]([key, value]);
3117
+ return propertyToRTL[key](pair, options);
3094
3118
  }
3095
3119
 
3096
3120
  const longHandPhysical = new Set();
@@ -4298,18 +4322,18 @@ function getDefaultValue(value) {
4298
4322
  function styleXDefineVars(variables, options) {
4299
4323
  const {
4300
4324
  classNamePrefix,
4301
- themeName,
4325
+ exportId,
4302
4326
  debug,
4303
4327
  enableDebugClassNames
4304
4328
  } = {
4305
4329
  ...defaultOptions,
4306
4330
  ...options
4307
4331
  };
4308
- const themeNameHash = classNamePrefix + hash(themeName);
4332
+ const varGroupHash = classNamePrefix + hash(exportId);
4309
4333
  const typedVariables = {};
4310
4334
  const variablesMap = objMap(variables, (value, key) => {
4311
4335
  const varSafeKey = (key[0] >= '0' && key[0] <= '9' ? `_${key}` : key).replace(/[^a-zA-Z0-9]/g, '_');
4312
- const nameHash = key.startsWith('--') ? key.slice(2) : debug && enableDebugClassNames ? varSafeKey + '-' + classNamePrefix + hash(`${themeName}.${key}`) : classNamePrefix + hash(`${themeName}.${key}`);
4336
+ const nameHash = key.startsWith('--') ? key.slice(2) : debug && enableDebugClassNames ? varSafeKey + '-' + classNamePrefix + hash(`${exportId}.${key}`) : classNamePrefix + hash(`${exportId}.${key}`);
4313
4337
  if (isCSSType(value)) {
4314
4338
  const v = value;
4315
4339
  typedVariables[nameHash] = {
@@ -4332,7 +4356,7 @@ function styleXDefineVars(variables, options) {
4332
4356
  } = _ref;
4333
4357
  return `var(--${nameHash})`;
4334
4358
  });
4335
- const injectableStyles = constructCssVariablesString(variablesMap, themeNameHash);
4359
+ const injectableStyles = constructCssVariablesString(variablesMap, varGroupHash);
4336
4360
  const injectableTypes = objMap(typedVariables, (_ref2, nameHash) => {
4337
4361
  let {
4338
4362
  initialValue: iv,
@@ -4346,13 +4370,13 @@ function styleXDefineVars(variables, options) {
4346
4370
  });
4347
4371
  return [{
4348
4372
  ...themeVariablesObject,
4349
- __themeName__: themeNameHash
4373
+ __varGroupHash__: varGroupHash
4350
4374
  }, {
4351
4375
  ...injectableTypes,
4352
4376
  ...injectableStyles
4353
4377
  }];
4354
4378
  }
4355
- function constructCssVariablesString(variables, themeNameHash) {
4379
+ function constructCssVariablesString(variables, varGroupHash) {
4356
4380
  const rulesByAtRule = {};
4357
4381
  for (const [key, {
4358
4382
  nameHash,
@@ -4366,12 +4390,12 @@ function constructCssVariablesString(variables, themeNameHash) {
4366
4390
  const result = {};
4367
4391
  for (const [atRule, value] of Object.entries(rulesByAtRule)) {
4368
4392
  const suffix = atRule === 'default' ? '' : `-${hash(atRule)}`;
4369
- const selector = `:root, .${themeNameHash}`;
4393
+ const selector = `:root, .${varGroupHash}`;
4370
4394
  let ltr = `${selector}{${value.join('')}}`;
4371
4395
  if (atRule !== 'default') {
4372
4396
  ltr = wrapWithAtRules(ltr, atRule);
4373
4397
  }
4374
- result[themeNameHash + suffix] = {
4398
+ result[varGroupHash + suffix] = {
4375
4399
  ltr,
4376
4400
  rtl: null,
4377
4401
  priority: priorityForAtRule(atRule) * 0.1
@@ -4383,7 +4407,7 @@ function constructCssVariablesString(variables, themeNameHash) {
4383
4407
  function styleXDefineConsts(constants, options) {
4384
4408
  const {
4385
4409
  classNamePrefix,
4386
- themeName,
4410
+ exportId,
4387
4411
  debug,
4388
4412
  enableDebugClassNames
4389
4413
  } = {
@@ -4397,10 +4421,10 @@ function styleXDefineConsts(constants, options) {
4397
4421
  throw new Error(INVALID_CONST_KEY);
4398
4422
  }
4399
4423
  const varSafeKey = (key[0] >= '0' && key[0] <= '9' ? `_${key}` : key).replace(/[^a-zA-Z0-9]/g, '_');
4400
- const nameHash = debug && enableDebugClassNames ? `${varSafeKey}-${classNamePrefix}${hash(`${themeName}.${key}`)}` : `${classNamePrefix}${hash(`${themeName}.${key}`)}`;
4424
+ const constKey = debug && enableDebugClassNames ? `${varSafeKey}-${classNamePrefix}${hash(`${exportId}.${key}`)}` : `${classNamePrefix}${hash(`${exportId}.${key}`)}`;
4401
4425
  jsOutput[key] = value;
4402
- injectableStyles[nameHash] = {
4403
- constKey: nameHash,
4426
+ injectableStyles[constKey] = {
4427
+ constKey,
4404
4428
  constVal: value,
4405
4429
  priority: 0,
4406
4430
  ltr: '',
@@ -4411,7 +4435,7 @@ function styleXDefineConsts(constants, options) {
4411
4435
  }
4412
4436
 
4413
4437
  function styleXCreateTheme(themeVars, variables, options) {
4414
- if (typeof themeVars.__themeName__ !== 'string') {
4438
+ if (typeof themeVars.__varGroupHash__ !== 'string') {
4415
4439
  throw new Error('Can only override variables theme created with defineVars().');
4416
4440
  }
4417
4441
  const {
@@ -4451,9 +4475,9 @@ function styleXCreateTheme(themeVars, variables, options) {
4451
4475
  };
4452
4476
  }
4453
4477
  }
4454
- const themeClass = `${overrideClassName} ${themeVars.__themeName__}`;
4478
+ const themeClass = `${overrideClassName} ${themeVars.__varGroupHash__}`;
4455
4479
  return [{
4456
- [themeVars.__themeName__]: themeClass,
4480
+ [themeVars.__varGroupHash__]: themeClass,
4457
4481
  $$css: true
4458
4482
  }, stylesToInject];
4459
4483
  }
@@ -4464,8 +4488,8 @@ function styleXKeyframes(frames) {
4464
4488
  classNamePrefix = 'x'
4465
4489
  } = options;
4466
4490
  const expandedObject = objMap(frames, frame => Pipe.create(frame).pipe(frame => expandFrameShorthands(frame, options)).pipe(x => objMapKeys(x, dashify)).pipe(x => objMap(x, (value, key) => transformValue(key, value, options))).done());
4467
- const ltrStyles = objMap(expandedObject, frame => objMapEntry(frame, generateLTR));
4468
- const rtlStyles = objMap(expandedObject, frame => objMapEntry(frame, entry => generateRTL(entry) ?? entry));
4491
+ const ltrStyles = objMap(expandedObject, frame => objMapEntry(frame, entry => generateLTR(entry, options)));
4492
+ const rtlStyles = objMap(expandedObject, frame => objMapEntry(frame, entry => generateRTL(entry, options) ?? entry));
4469
4493
  const ltrString = constructKeyframesObj(ltrStyles);
4470
4494
  const rtlString = constructKeyframesObj(rtlStyles);
4471
4495
  const animationName = classNamePrefix + hash('<>' + ltrString) + '-B';
@@ -4767,7 +4791,7 @@ function evaluateThemeRef(fileName, exportName, state) {
4767
4791
  if (key.startsWith('--')) {
4768
4792
  return `var(${key})`;
4769
4793
  }
4770
- const strToHash = key === '__themeName__' ? utils.genFileBasedIdentifier({
4794
+ const strToHash = key === '__varGroupHash__' ? utils.genFileBasedIdentifier({
4771
4795
  fileName,
4772
4796
  exportName
4773
4797
  }) : utils.genFileBasedIdentifier({
@@ -4779,9 +4803,9 @@ function evaluateThemeRef(fileName, exportName, state) {
4779
4803
  debug,
4780
4804
  enableDebugClassNames
4781
4805
  } = state.traversalState.options;
4782
- const varSafeKey = key === '__themeName__' ? '' : (key[0] >= '0' && key[0] <= '9' ? `_${key}` : key).replace(/[^a-zA-Z0-9]/g, '_') + '-';
4806
+ const varSafeKey = key === '__varGroupHash__' ? '' : (key[0] >= '0' && key[0] <= '9' ? `_${key}` : key).replace(/[^a-zA-Z0-9]/g, '_') + '-';
4783
4807
  const varName = debug && enableDebugClassNames ? varSafeKey + state.traversalState.options.classNamePrefix + utils.hash(strToHash) : state.traversalState.options.classNamePrefix + utils.hash(strToHash);
4784
- if (key === '__themeName__') {
4808
+ if (key === '__varGroupHash__') {
4785
4809
  return varName;
4786
4810
  }
4787
4811
  return `var(--${varName})`;
@@ -5484,6 +5508,9 @@ function validateDynamicStyleParams(path, params) {
5484
5508
  }
5485
5509
  }
5486
5510
 
5511
+ function isSafeToSkipNullCheck(expr) {
5512
+ return t__namespace.isBinaryExpression(expr) && ['+', '-', '*', '/', '**'].includes(expr.operator) || t__namespace.isUnaryExpression(expr) && ['-', '+'].includes(expr.operator);
5513
+ }
5487
5514
  function transformStyleXCreate(path, state) {
5488
5515
  const {
5489
5516
  node
@@ -5631,66 +5658,39 @@ function transformStyleXCreate(path, state) {
5631
5658
  }
5632
5659
  if (t__namespace.isObjectExpression(prop.value)) {
5633
5660
  const value = prop.value;
5634
- value.properties = value.properties.map(prop => {
5635
- if (!t__namespace.isObjectProperty(prop)) {
5636
- return prop;
5661
+ const conditionalProps = [];
5662
+ value.properties.forEach(prop => {
5663
+ if (!t__namespace.isObjectProperty(prop) || t__namespace.isPrivateName(prop.key)) {
5664
+ return;
5637
5665
  }
5638
5666
  const objProp = prop;
5639
5667
  const propKey = objProp.key.type === 'Identifier' && !objProp.computed ? objProp.key.name : objProp.key.type === 'StringLiteral' ? objProp.key.value : null;
5640
- if (propKey != null) {
5641
- const dynamicMatch = dynamicStyles.filter(_ref4 => {
5668
+ if (propKey == null || propKey === '$$css') {
5669
+ conditionalProps.push(objProp);
5670
+ return;
5671
+ }
5672
+ const classList = t__namespace.isStringLiteral(objProp.value) ? objProp.value.value.split(' ') : [];
5673
+ const exprList = [];
5674
+ classList.forEach(cls => {
5675
+ const expr = dynamicStyles.find(_ref4 => {
5642
5676
  let {
5643
- key
5677
+ path
5644
5678
  } = _ref4;
5645
- return key === propKey;
5646
- });
5647
- if (dynamicMatch.length > 0) {
5648
- const value = objProp.value;
5649
- if (t__namespace.isStringLiteral(value)) {
5650
- const classList = value.value.split(' ');
5651
- if (classList.length === 1) {
5652
- const cls = classList[0];
5653
- const expr = dynamicMatch.find(_ref5 => {
5654
- let {
5655
- path
5656
- } = _ref5;
5657
- return origClassPaths[cls] === path;
5658
- })?.expression;
5659
- if (expr != null) {
5660
- objProp.value = t__namespace.conditionalExpression(t__namespace.binaryExpression('==', expr, t__namespace.nullLiteral()), t__namespace.nullLiteral(), value);
5661
- }
5662
- } else if (classList.some(cls => dynamicMatch.find(_ref6 => {
5663
- let {
5664
- path
5665
- } = _ref6;
5666
- return origClassPaths[cls] === path;
5667
- }))) {
5668
- const exprArray = classList.map((cls, index) => {
5669
- const expr = dynamicMatch.find(_ref7 => {
5670
- let {
5671
- path
5672
- } = _ref7;
5673
- return origClassPaths[cls] === path;
5674
- })?.expression;
5675
- const suffix = index === classList.length - 1 ? '' : ' ';
5676
- if (expr != null) {
5677
- return t__namespace.conditionalExpression(t__namespace.binaryExpression('==', expr, t__namespace.nullLiteral()), t__namespace.stringLiteral(''), t__namespace.stringLiteral(cls + suffix));
5678
- }
5679
- return t__namespace.stringLiteral(cls + suffix);
5680
- });
5681
- const [first, ...rest] = exprArray;
5682
- objProp.value = rest.reduce((acc, curr) => {
5683
- return t__namespace.binaryExpression('+', acc, curr);
5684
- }, first);
5685
- }
5686
- }
5679
+ return origClassPaths[cls] === path;
5680
+ })?.expression;
5681
+ if (expr && !isSafeToSkipNullCheck(expr)) {
5682
+ exprList.push(t__namespace.conditionalExpression(t__namespace.binaryExpression('!=', expr, t__namespace.nullLiteral()), t__namespace.stringLiteral(cls), expr));
5683
+ } else {
5684
+ exprList.push(t__namespace.stringLiteral(cls));
5687
5685
  }
5688
- }
5689
- return objProp;
5686
+ });
5687
+ const joined = exprList.length === 0 ? t__namespace.stringLiteral('') : exprList.reduce((acc, curr) => t__namespace.binaryExpression('+', acc, curr));
5688
+ conditionalProps.push(t__namespace.objectProperty(objProp.key, joined));
5690
5689
  });
5691
- prop.value = t__namespace.arrowFunctionExpression(params, t__namespace.arrayExpression([value, t__namespace.objectExpression(Object.entries(inlineStyles).map(_ref8 => {
5692
- let [key, value] = _ref8;
5693
- return t__namespace.objectProperty(t__namespace.stringLiteral(key), value.expression);
5690
+ const conditionalObj = t__namespace.objectExpression(conditionalProps);
5691
+ prop.value = t__namespace.arrowFunctionExpression(params, t__namespace.arrayExpression([conditionalObj, t__namespace.objectExpression(Object.entries(inlineStyles).map(_ref5 => {
5692
+ let [key, val] = _ref5;
5693
+ return t__namespace.objectProperty(t__namespace.stringLiteral(key), val.expression);
5694
5694
  }))]));
5695
5695
  }
5696
5696
  }
@@ -5698,11 +5698,11 @@ function transformStyleXCreate(path, state) {
5698
5698
  return prop;
5699
5699
  });
5700
5700
  }
5701
- const listOfStyles = Object.entries(injectedStyles).map(_ref9 => {
5701
+ const listOfStyles = Object.entries(injectedStyles).map(_ref6 => {
5702
5702
  let [key, {
5703
5703
  priority,
5704
5704
  ...rest
5705
- }] = _ref9;
5705
+ }] = _ref6;
5706
5706
  return [key, rest, priority];
5707
5707
  });
5708
5708
  state.registerStyles(listOfStyles, path);
@@ -5743,15 +5743,15 @@ function findNearestStatementAncestor(path) {
5743
5743
  return findNearestStatementAncestor(path.parentPath);
5744
5744
  }
5745
5745
  function legacyExpandShorthands(dynamicStyles) {
5746
- const expandedKeysToKeyPaths = dynamicStyles.flatMap((_ref0, i) => {
5746
+ const expandedKeysToKeyPaths = dynamicStyles.flatMap((_ref7, i) => {
5747
5747
  let {
5748
5748
  key
5749
- } = _ref0;
5749
+ } = _ref7;
5750
5750
  return flatMapExpandedShorthands([key, 'p' + i], {
5751
5751
  styleResolution: 'legacy-expand-shorthands'
5752
5752
  });
5753
- }).map(_ref1 => {
5754
- let [key, value] = _ref1;
5753
+ }).map(_ref8 => {
5754
+ let [key, value] = _ref8;
5755
5755
  if (typeof value !== 'string') {
5756
5756
  return null;
5757
5757
  }
@@ -5846,7 +5846,7 @@ function transformStyleXCreateTheme(callExpressionPath, state) {
5846
5846
  if (typeof overrides !== 'object' || overrides == null) {
5847
5847
  throw callExpressionPath.buildCodeFrameError(messages.nonStyleObject('createTheme'), SyntaxError);
5848
5848
  }
5849
- if (typeof variables.__themeName__ !== 'string' || variables.__themeName__ === '') {
5849
+ if (typeof variables.__varGroupHash__ !== 'string' || variables.__varGroupHash__ === '') {
5850
5850
  throw callExpressionPath.buildCodeFrameError('Can only override variables theme created with defineVars().', SyntaxError);
5851
5851
  }
5852
5852
  let [overridesObj, injectedStyles] = createTheme(variables, overrides, state.options);
@@ -5970,7 +5970,7 @@ function transformStyleXDefineVars(callExpressionPath, state) {
5970
5970
  const exportName = varId.name;
5971
5971
  const [variablesObj, injectedStylesSansKeyframes] = defineVars(value, {
5972
5972
  ...state.options,
5973
- themeName: utils.genFileBasedIdentifier({
5973
+ exportId: utils.genFileBasedIdentifier({
5974
5974
  fileName,
5975
5975
  exportName
5976
5976
  })
@@ -6031,13 +6031,13 @@ function transformStyleXDefineConsts(callExpressionPath, state) {
6031
6031
  throw new Error(messages.cannotGenerateHash('defineConsts'));
6032
6032
  }
6033
6033
  const exportName = varId.name;
6034
- const themeName = utils.genFileBasedIdentifier({
6034
+ const exportId = utils.genFileBasedIdentifier({
6035
6035
  fileName,
6036
6036
  exportName
6037
6037
  });
6038
6038
  const [transformedJsOutput, jsOutput] = defineConsts(value, {
6039
6039
  ...state.options,
6040
- themeName
6040
+ exportId
6041
6041
  });
6042
6042
  callExpressionPath.replaceWith(convertObjectToAST(transformedJsOutput));
6043
6043
  const styles = Object.entries(jsOutput).map(_ref => {
@@ -46,6 +46,7 @@ export type StyleXOptions = Readonly<{
46
46
  enableDebugDataProp?: null | undefined | boolean;
47
47
  enableDevClassNames?: null | undefined | boolean;
48
48
  enableFontSizePxToRem?: null | undefined | boolean;
49
+ enableLegacyValueFlipping?: null | undefined | boolean;
49
50
  enableLogicalStylesPolyfill?: null | undefined | boolean;
50
51
  enableMinifiedKeys?: null | undefined | boolean;
51
52
  styleResolution:
@@ -52,6 +52,7 @@ export type StyleXOptions = $ReadOnly<{
52
52
  enableDebugDataProp?: ?boolean,
53
53
  enableDevClassNames?: ?boolean,
54
54
  enableFontSizePxToRem?: ?boolean,
55
+ enableLegacyValueFlipping?: ?boolean,
55
56
  enableLogicalStylesPolyfill?: ?boolean,
56
57
  enableMinifiedKeys?: ?boolean,
57
58
  styleResolution:
@@ -9,7 +9,7 @@
9
9
 
10
10
  import type { StyleXOptions } from '../common-types';
11
11
  declare function generateRTL(
12
- $$PARAM_0$$: Readonly<[string, string]>,
12
+ pair: Readonly<[string, string]>,
13
13
  options: StyleXOptions,
14
14
  ): null | undefined | Readonly<[string, string]>;
15
15
  export default generateRTL;
@@ -9,6 +9,6 @@
9
9
 
10
10
  import type { StyleXOptions } from '../common-types';
11
11
  declare export default function generateRTL(
12
- $ReadOnly<[string, string]>,
12
+ pair: $ReadOnly<[string, string]>,
13
13
  options: StyleXOptions,
14
14
  ): ?$ReadOnly<[string, string]>;
@@ -10,7 +10,7 @@
10
10
  import type { InjectableStyle, StyleXOptions } from './common-types';
11
11
  declare function styleXCreateTheme(
12
12
  themeVars: {
13
- readonly __themeName__: string;
13
+ readonly __varGroupHash__: string;
14
14
  readonly [$$Key$$: string]: string;
15
15
  },
16
16
  variables: {
@@ -13,7 +13,7 @@ import type { InjectableStyle, StyleXOptions } from './common-types';
13
13
  // and returns a hashed className with variables overrides.
14
14
  //
15
15
  declare export default function styleXCreateTheme(
16
- themeVars: { +__themeName__: string, +[string]: string },
16
+ themeVars: { +__varGroupHash__: string, +[string]: string },
17
17
  variables: { +[string]: string | { default: string, +[string]: string } },
18
18
  options?: StyleXOptions,
19
19
  ): [{ $$css: true, +[string]: string }, { [string]: InjectableStyle }];
@@ -12,8 +12,8 @@ import type { ConstsConfig } from './stylex-consts-utils';
12
12
  declare function styleXDefineConsts<Vars extends ConstsConfig>(
13
13
  constants: Vars,
14
14
  options: Readonly<
15
- Omit<Partial<StyleXOptions>, keyof ({ themeName: string })> & {
16
- themeName: string;
15
+ Omit<Partial<StyleXOptions>, keyof ({ exportId: string })> & {
16
+ exportId: string;
17
17
  }
18
18
  >,
19
19
  ): [
@@ -12,7 +12,7 @@ import type { ConstsConfig } from './stylex-consts-utils';
12
12
 
13
13
  declare export default function styleXDefineConsts<Vars: ConstsConfig>(
14
14
  constants: Vars,
15
- options: $ReadOnly<{ ...Partial<StyleXOptions>, themeName: string, ... }>,
15
+ options: $ReadOnly<{ ...Partial<StyleXOptions>, exportId: string, ... }>,
16
16
  ): [
17
17
  { [string]: string | number }, // jsOutput JS output
18
18
  { [string]: InjectableConstStyle }, // metadata for registerinjectableStyles
@@ -13,15 +13,15 @@ type VarsKeysWithStringValues<Vars extends VarsConfig> = Readonly<{
13
13
  [$$Key$$: keyof Vars]: string;
14
14
  }>;
15
15
  type VarsObject<Vars extends VarsConfig> = Readonly<
16
- Omit<VarsKeysWithStringValues<Vars>, keyof ({ __themeName__: string })> & {
17
- __themeName__: string;
16
+ Omit<VarsKeysWithStringValues<Vars>, keyof ({ __varGroupHash__: string })> & {
17
+ __varGroupHash__: string;
18
18
  }
19
19
  >;
20
20
  declare function styleXDefineVars<Vars extends VarsConfig>(
21
21
  variables: Vars,
22
22
  options: Readonly<
23
- Omit<Partial<StyleXOptions>, keyof ({ themeName: string })> & {
24
- themeName: string;
23
+ Omit<Partial<StyleXOptions>, keyof ({ exportId: string })> & {
24
+ exportId: string;
25
25
  }
26
26
  >,
27
27
  ): [VarsObject<Vars>, { [$$Key$$: string]: InjectableStyle }];
@@ -15,12 +15,12 @@ type VarsKeysWithStringValues<Vars: VarsConfig> = $ReadOnly<{
15
15
 
16
16
  type VarsObject<Vars: VarsConfig> = $ReadOnly<{
17
17
  ...VarsKeysWithStringValues<Vars>,
18
- __themeName__: string,
18
+ __varGroupHash__: string,
19
19
  }>;
20
20
 
21
21
  // Similar to `stylex.create` it takes an object of variables with their values
22
22
  // and returns a string after hashing it.
23
23
  declare export default function styleXDefineVars<Vars: VarsConfig>(
24
24
  variables: Vars,
25
- options: $ReadOnly<{ ...Partial<StyleXOptions>, themeName: string, ... }>,
25
+ options: $ReadOnly<{ ...Partial<StyleXOptions>, exportId: string, ... }>,
26
26
  ): [VarsObject<Vars>, { [string]: InjectableStyle }];
@@ -46,6 +46,7 @@ export type StyleXOptions = Readonly<
46
46
  enableDebugDataProp?: boolean;
47
47
  enableDevClassNames?: boolean;
48
48
  enableInlinedConditionalMerge?: boolean;
49
+ enableLegacyValueFlipping?: boolean;
49
50
  enableLogicalStylesPolyfill?: boolean;
50
51
  enableMinifiedKeys?: boolean;
51
52
  importSources: ReadonlyArray<
@@ -68,6 +69,7 @@ export type StyleXOptions = Readonly<
68
69
  enableDebugDataProp?: boolean;
69
70
  enableDevClassNames?: boolean;
70
71
  enableInlinedConditionalMerge?: boolean;
72
+ enableLegacyValueFlipping?: boolean;
71
73
  enableLogicalStylesPolyfill?: boolean;
72
74
  enableMinifiedKeys?: boolean;
73
75
  importSources: ReadonlyArray<
@@ -48,6 +48,7 @@ export type StyleXOptions = $ReadOnly<{
48
48
  enableDebugDataProp?: boolean,
49
49
  enableDevClassNames?: boolean,
50
50
  enableInlinedConditionalMerge?: boolean,
51
+ enableLegacyValueFlipping?: boolean,
51
52
  enableLogicalStylesPolyfill?: boolean,
52
53
  enableMinifiedKeys?: boolean,
53
54
  importSources: $ReadOnlyArray<
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stylexjs/babel-plugin",
3
- "version": "0.14.1",
3
+ "version": "0.14.3",
4
4
  "description": "StyleX babel plugin.",
5
5
  "main": "lib/index.js",
6
6
  "repository": {
@@ -21,7 +21,7 @@
21
21
  "@babel/traverse": "^7.26.8",
22
22
  "@babel/types": "^7.26.8",
23
23
  "@dual-bundle/import-meta-resolve": "^4.1.0",
24
- "@stylexjs/stylex": "0.14.1",
24
+ "@stylexjs/stylex": "0.14.3",
25
25
  "postcss-value-parser": "^4.1.0"
26
26
  },
27
27
  "devDependencies": {
@@ -33,7 +33,7 @@
33
33
  "@rollup/plugin-replace": "^6.0.1",
34
34
  "babel-plugin-syntax-hermes-parser": "^0.26.0",
35
35
  "rollup": "^4.24.0",
36
- "scripts": "0.14.1"
36
+ "scripts": "0.14.3"
37
37
  },
38
38
  "files": [
39
39
  "flow_modules/*",