@stylexjs/babel-plugin 0.13.1 → 0.14.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 CHANGED
@@ -720,6 +720,7 @@ class StateManager {
720
720
  stylexDefineConstsImport = (() => new Set())();
721
721
  stylexCreateThemeImport = (() => new Set())();
722
722
  stylexTypesImport = (() => new Set())();
723
+ stylexViewTransitionClassImport = (() => new Set())();
723
724
  injectImportInserted = null;
724
725
  styleMap = (() => new Map())();
725
726
  styleVars = (() => new Map())();
@@ -739,13 +740,14 @@ class StateManager {
739
740
  const enableFontSizePxToRem = logAndDefault(boolean(), options.enableFontSizePxToRem ?? false, false, 'options.enableFontSizePxToRem');
740
741
  const enableInlinedConditionalMerge = logAndDefault(boolean(), options.enableInlinedConditionalMerge ?? true, true, 'options.enableInlinedConditionalMerge');
741
742
  const enableMinifiedKeys = logAndDefault(boolean(), options.enableMinifiedKeys ?? true, true, 'options.enableMinifiedKeys');
743
+ const enableLogicalStylesPolyfill = logAndDefault(boolean(), options.enableLogicalStylesPolyfill ?? false, false, 'options.enableLogicalStylesPolyfill');
742
744
  const test = logAndDefault(boolean(), options.test ?? false, false, 'options.test');
743
745
  const configRuntimeInjection = logAndDefault(checkRuntimeInjection, options.runtimeInjection ?? false, false, 'options.runtimeInjection');
744
746
  const runtimeInjection = configRuntimeInjection === true ? DEFAULT_INJECT_PATH : configRuntimeInjection === false ? undefined : configRuntimeInjection;
745
747
  const classNamePrefix = logAndDefault(string(), options.classNamePrefix ?? 'x', 'x', 'options.classNamePrefix');
746
748
  const configuredImportSources = logAndDefault(checkImportSources, options.importSources ?? [], [], 'options.importSources');
747
749
  const importSources = [name, 'stylex', ...configuredImportSources];
748
- const styleResolution = logAndDefault(unionOf3(literal('application-order'), literal('property-specificity'), literal('legacy-expand-shorthands')), options.styleResolution ?? 'application-order', 'application-order', 'options.styleResolution');
750
+ const styleResolution = logAndDefault(unionOf3(literal('application-order'), literal('property-specificity'), literal('legacy-expand-shorthands')), options.styleResolution ?? 'property-specificity', 'property-specificity', 'options.styleResolution');
749
751
  const unstable_moduleResolution = logAndDefault(unionOf(nullish(), CheckModuleResolution), options.unstable_moduleResolution, null, 'options.unstable_moduleResolution');
750
752
  const treeshakeCompensation = logAndDefault(boolean(), options.treeshakeCompensation ?? false, false, 'options.treeshakeCompensation');
751
753
  const aliasesOption = logAndDefault(unionOf(nullish(), objectOf(unionOf(string(), array(string())))), options.aliases, null, 'options.aliases');
@@ -768,6 +770,7 @@ class StateManager {
768
770
  enableFontSizePxToRem,
769
771
  enableInlinedConditionalMerge,
770
772
  enableMinifiedKeys,
773
+ enableLogicalStylesPolyfill,
771
774
  importSources,
772
775
  rewriteAliases: typeof options.rewriteAliases === 'boolean' ? options.rewriteAliases : false,
773
776
  runtimeInjection,
@@ -1140,6 +1143,9 @@ function readImportDeclarations(path, state) {
1140
1143
  if (importedName === 'positionTry') {
1141
1144
  state.stylexPositionTryImport.add(localName);
1142
1145
  }
1146
+ if (importedName === 'viewTransitionClass') {
1147
+ state.stylexViewTransitionClassImport.add(localName);
1148
+ }
1143
1149
  if (importedName === 'include') {
1144
1150
  state.stylexIncludeImport.add(localName);
1145
1151
  }
@@ -1194,6 +1200,9 @@ function readRequires(path, state) {
1194
1200
  if (prop.key.name === 'positionTry') {
1195
1201
  state.stylexPositionTryImport.add(value.name);
1196
1202
  }
1203
+ if (prop.key.name === 'viewTransitionClass') {
1204
+ state.stylexViewTransitionClassImport.add(value.name);
1205
+ }
1197
1206
  if (prop.key.name === 'include') {
1198
1207
  state.stylexIncludeImport.add(value.name);
1199
1208
  }
@@ -1266,10 +1275,12 @@ const defaultOptions = {
1266
1275
  dev: false,
1267
1276
  debug: false,
1268
1277
  enableDebugClassNames: true,
1278
+ enableDevClassNames: false,
1269
1279
  enableDebugDataProp: true,
1270
- enableFontSizePxToRem: true,
1280
+ enableFontSizePxToRem: false,
1281
+ enableLogicalStylesPolyfill: false,
1271
1282
  enableMinifiedKeys: true,
1272
- styleResolution: 'application-order',
1283
+ styleResolution: 'property-specificity',
1273
1284
  test: false
1274
1285
  };
1275
1286
 
@@ -2068,35 +2079,35 @@ function splitValue(str) {
2068
2079
 
2069
2080
  const shorthands$1 = {
2070
2081
  border: rawValue => {
2071
- return [['borderTop', rawValue], ['borderEnd', rawValue], ['borderBottom', rawValue], ['borderStart', rawValue]];
2082
+ return [['borderTop', rawValue], ['borderInlineEnd', rawValue], ['borderBottom', rawValue], ['borderInlineStart', rawValue]];
2072
2083
  },
2073
2084
  borderColor: rawValue => {
2074
2085
  const [top, right = top, bottom = top, left = right] = splitValue(rawValue);
2075
- return [['borderTopColor', top], ['borderEndColor', right], ['borderBottomColor', bottom], ['borderStartColor', left]];
2086
+ return [['borderTopColor', top], ['borderInlineEndColor', right], ['borderBottomColor', bottom], ['borderInlineStartColor', left]];
2076
2087
  },
2077
2088
  borderHorizontal: rawValue => {
2078
- return [['borderStart', rawValue], ['borderEnd', rawValue]];
2089
+ return [['borderInlineStart', rawValue], ['borderInlineEnd', rawValue]];
2079
2090
  },
2080
2091
  borderStyle: rawValue => {
2081
2092
  const [top, right = top, bottom = top, left = right] = splitValue(rawValue);
2082
- return [['borderTopStyle', top], ['borderEndStyle', right], ['borderBottomStyle', bottom], ['borderStartStyle', left]];
2093
+ return [['borderTopStyle', top], ['borderInlineEndStyle', right], ['borderBottomStyle', bottom], ['borderInlineStartStyle', left]];
2083
2094
  },
2084
2095
  borderVertical: rawValue => {
2085
2096
  return [['borderTop', rawValue], ['borderBottom', rawValue]];
2086
2097
  },
2087
2098
  borderWidth: rawValue => {
2088
2099
  const [top, right = top, bottom = top, left = right] = splitValue(rawValue);
2089
- return [['borderTopWidth', top], ['borderEndWidth', right], ['borderBottomWidth', bottom], ['borderStartWidth', left]];
2100
+ return [['borderTopWidth', top], ['borderInlineEndWidth', right], ['borderBottomWidth', bottom], ['borderInlineStartWidth', left]];
2090
2101
  },
2091
- borderHorizontalColor: rawValue => [['borderStartColor', rawValue], ['borderEndColor', rawValue]],
2092
- borderHorizontalStyle: rawValue => [['borderStartStyle', rawValue], ['borderEndStyle', rawValue]],
2093
- borderHorizontalWidth: rawValue => [['borderStartWidth', rawValue], ['borderEndWidth', rawValue]],
2102
+ borderHorizontalColor: rawValue => [['borderInlineStartColor', rawValue], ['borderInlineEndColor', rawValue]],
2103
+ borderHorizontalStyle: rawValue => [['borderInlineStartStyle', rawValue], ['borderInlineEndStyle', rawValue]],
2104
+ borderHorizontalWidth: rawValue => [['borderInlineStartWidth', rawValue], ['borderInlineEndWidth', rawValue]],
2094
2105
  borderVerticalColor: rawValue => [['borderTopColor', rawValue], ['borderBottomColor', rawValue]],
2095
2106
  borderVerticalStyle: rawValue => [['borderTopStyle', rawValue], ['borderBottomStyle', rawValue]],
2096
2107
  borderVerticalWidth: rawValue => [['borderTopWidth', rawValue], ['borderBottomWidth', rawValue]],
2097
2108
  borderRadius: rawValue => {
2098
2109
  const [top, right = top, bottom = top, left = right] = splitValue(rawValue);
2099
- return [['borderTopStartRadius', top], ['borderTopEndRadius', right], ['borderBottomEndRadius', bottom], ['borderBottomStartRadius', left]];
2110
+ return [['borderStartStartRadius', top], ['borderStartEndRadius', right], ['borderEndEndRadius', bottom], ['borderEndStartRadius', left]];
2100
2111
  },
2101
2112
  containIntrinsicSize: rawValue => {
2102
2113
  const parts = splitValue(rawValue);
@@ -2109,28 +2120,32 @@ const shorthands$1 = {
2109
2120
  }, []);
2110
2121
  return [['containIntrinsicWidth', width], ['containIntrinsicHeight', height]];
2111
2122
  },
2112
- inset: rawValue => [['top', rawValue], ['end', rawValue], ['bottom', rawValue], ['start', rawValue]],
2123
+ inset: rawValue => [['top', rawValue], ['insetInlineEnd', rawValue], ['bottom', rawValue], ['insetInlineStart', rawValue]],
2113
2124
  insetInline: rawValue => [...shorthands$1.start(rawValue), ...shorthands$1.end(rawValue)],
2114
2125
  insetBlock: rawValue => [['top', rawValue], ['bottom', rawValue]],
2115
- start: rawValue => [['start', rawValue], ['left', null], ['right', null]],
2116
- end: rawValue => [['end', rawValue], ['left', null], ['right', null]],
2117
- left: rawValue => [['left', rawValue], ['start', null], ['end', null]],
2118
- right: rawValue => [['right', rawValue], ['start', null], ['end', null]],
2126
+ start: rawValue => [['insetInlineStart', rawValue], ['left', null], ['right', null]],
2127
+ end: rawValue => [['insetInlineEnd', rawValue], ['left', null], ['right', null]],
2128
+ left: rawValue => [['left', rawValue], ['insetInlineStart', null], ['insetInlineEnd', null]],
2129
+ right: rawValue => [['right', rawValue], ['insetInlineStart', null], ['insetInlineEnd', null]],
2119
2130
  gap: rawValue => {
2120
2131
  const [row, column = row] = splitValue(rawValue);
2121
2132
  return [['rowGap', row], ['columnGap', column]];
2122
2133
  },
2123
2134
  margin: rawValue => {
2124
2135
  const [top, right = top, bottom = top, left = right] = splitValue(rawValue);
2125
- return [['marginTop', top], ['marginEnd', right], ['marginBottom', bottom], ['marginStart', left]];
2136
+ return [['marginTop', top], ['marginInlineEnd', right], ['marginBottom', bottom], ['marginInlineStart', left]];
2137
+ },
2138
+ marginHorizontal: rawValue => {
2139
+ const [start, end = start] = splitValue(rawValue);
2140
+ return [...shorthands$1.marginStart(start), ...shorthands$1.marginEnd(end)];
2126
2141
  },
2127
- marginHorizontal: rawValue => [...shorthands$1.marginStart(rawValue), ...shorthands$1.marginEnd(rawValue)],
2128
- marginStart: rawValue => [['marginStart', rawValue], ['marginLeft', null], ['marginRight', null]],
2129
- marginEnd: rawValue => [['marginEnd', rawValue], ['marginLeft', null], ['marginRight', null]],
2130
- marginLeft: rawValue => [['marginLeft', rawValue], ['marginStart', null], ['marginEnd', null]],
2131
- marginRight: rawValue => [['marginRight', rawValue], ['marginStart', null], ['marginEnd', null]],
2142
+ marginStart: rawValue => [['marginInlineStart', rawValue], ['marginLeft', null], ['marginRight', null]],
2143
+ marginEnd: rawValue => [['marginInlineEnd', rawValue], ['marginLeft', null], ['marginRight', null]],
2144
+ marginLeft: rawValue => [['marginLeft', rawValue], ['marginInlineStart', null], ['marginInlineEnd', null]],
2145
+ marginRight: rawValue => [['marginRight', rawValue], ['marginInlineStart', null], ['marginInlineEnd', null]],
2132
2146
  marginVertical: rawValue => {
2133
- return [['marginTop', rawValue], ['marginBottom', rawValue]];
2147
+ const [top, bottom = top] = splitValue(rawValue);
2148
+ return [['marginTop', top], ['marginBottom', bottom]];
2134
2149
  },
2135
2150
  overflow: rawValue => {
2136
2151
  const [x, y = x] = splitValue(rawValue);
@@ -2138,14 +2153,20 @@ const shorthands$1 = {
2138
2153
  },
2139
2154
  padding: rawValue => {
2140
2155
  const [top, right = top, bottom = top, left = right] = splitValue(rawValue);
2141
- return [['paddingTop', top], ['paddingEnd', right], ['paddingBottom', bottom], ['paddingStart', left]];
2156
+ return [['paddingTop', top], ['paddingInlineEnd', right], ['paddingBottom', bottom], ['paddingInlineStart', left]];
2142
2157
  },
2143
- paddingHorizontal: val => [...shorthands$1.paddingStart(val), ...shorthands$1.paddingEnd(val)],
2144
- paddingStart: val => [['paddingStart', val], ['paddingLeft', null], ['paddingRight', null]],
2145
- paddingEnd: val => [['paddingEnd', val], ['paddingLeft', null], ['paddingRight', null]],
2158
+ paddingHorizontal: val => {
2159
+ const [start, end = start] = splitValue(val);
2160
+ return [...shorthands$1.paddingStart(start), ...shorthands$1.paddingEnd(end)];
2161
+ },
2162
+ paddingStart: val => [['paddingInlineStart', val], ['paddingLeft', null], ['paddingRight', null]],
2163
+ paddingEnd: val => [['paddingInlineEnd', val], ['paddingLeft', null], ['paddingRight', null]],
2146
2164
  paddingLeft: val => [['paddingLeft', val], ['paddingStart', null], ['paddingEnd', null]],
2147
- paddingRight: val => [['paddingRight', val], ['paddingStart', null], ['paddingEnd', null]],
2148
- paddingVertical: val => [['paddingTop', val], ['paddingBottom', val]]
2165
+ paddingRight: val => [['paddingRight', val], ['paddingInlineStart', null], ['paddingInlineEnd', null]],
2166
+ paddingVertical: val => {
2167
+ const [top, bottom = top] = splitValue(val);
2168
+ return [['paddingTop', top], ['paddingBottom', bottom]];
2169
+ }
2149
2170
  };
2150
2171
  const aliases$1 = {
2151
2172
  insetBlockStart: val => [['top', val]],
@@ -2158,6 +2179,8 @@ const aliases$1 = {
2158
2179
  minInlineSize: val => [['minWidth', val]],
2159
2180
  maxBlockSize: val => [['maxHeight', val]],
2160
2181
  maxInlineSize: val => [['maxWidth', val]],
2182
+ borderStart: val => [['borderInlineStart', val]],
2183
+ borderEnd: val => [['borderInlineEnd', val]],
2161
2184
  borderBlockWidth: shorthands$1.borderVerticalWidth,
2162
2185
  borderBlockStyle: shorthands$1.borderVerticalStyle,
2163
2186
  borderBlockColor: shorthands$1.borderVerticalColor,
@@ -2170,16 +2193,10 @@ const aliases$1 = {
2170
2193
  borderInlineWidth: shorthands$1.borderHorizontalWidth,
2171
2194
  borderInlineStyle: shorthands$1.borderHorizontalStyle,
2172
2195
  borderInlineColor: shorthands$1.borderHorizontalColor,
2173
- borderInlineStartWidth: val => [['borderStartWidth', val]],
2174
- borderInlineStartStyle: val => [['borderStartStyle', val]],
2175
- borderInlineStartColor: val => [['borderStartColor', val]],
2176
- borderInlineEndWidth: val => [['borderEndWidth', val]],
2177
- borderInlineEndStyle: val => [['borderEndStyle', val]],
2178
- borderInlineEndColor: val => [['borderEndColor', val]],
2179
- borderStartStartRadius: val => [['borderTopStartRadius', val]],
2180
- borderStartEndRadius: val => [['borderTopEndRadius', val]],
2181
- borderEndStartRadius: val => [['borderBottomStartRadius', val]],
2182
- borderEndEndRadius: val => [['borderBottomEndRadius', val]],
2196
+ borderTopStartRadius: val => [['borderStartStartRadius', val]],
2197
+ borderTopEndRadius: val => [['borderStartEndRadius', val]],
2198
+ borderBottomStartRadius: val => [['borderEndStartRadius', val]],
2199
+ borderBottomEndRadius: val => [['borderEndEndRadius', val]],
2183
2200
  gridGap: shorthands$1.gap,
2184
2201
  gridRowGap: value => [['rowGap', value]],
2185
2202
  gridColumnGap: value => [['columnGap', value]],
@@ -2187,16 +2204,12 @@ const aliases$1 = {
2187
2204
  marginBlockStart: val => [['marginTop', val]],
2188
2205
  marginBlockEnd: val => [['marginBottom', val]],
2189
2206
  marginInline: shorthands$1.marginHorizontal,
2190
- marginInlineStart: val => [['marginStart', val]],
2191
- marginInlineEnd: val => [['marginEnd', val]],
2192
2207
  overflowBlock: value => [['overflowY', value]],
2193
2208
  overflowInline: value => [['overflowX', value]],
2194
2209
  paddingBlock: shorthands$1.paddingVertical,
2195
2210
  paddingBlockStart: val => [['paddingTop', val]],
2196
2211
  paddingBlockEnd: val => [['paddingBottom', val]],
2197
2212
  paddingInline: shorthands$1.paddingHorizontal,
2198
- paddingInlineStart: val => [['paddingStart', val]],
2199
- paddingInlineEnd: val => [['paddingEnd', val]],
2200
2213
  scrollMarginBlockStart: value => [['scrollMarginTop', value]],
2201
2214
  scrollMarginBlockEnd: value => [['scrollMarginBottom', value]]
2202
2215
  };
@@ -2316,7 +2329,7 @@ function flatMapExpandedShorthands(objEntry, options) {
2316
2329
  if (key.startsWith('var(') && key.endsWith(')')) {
2317
2330
  key = key.slice(4, -1);
2318
2331
  }
2319
- const expansion = expansions[options.styleResolution ?? 'application-order'][key];
2332
+ const expansion = expansions[options.styleResolution ?? 'property-specificity'][key];
2320
2333
  if (expansion) {
2321
2334
  if (Array.isArray(value)) {
2322
2335
  throw new Error('Cannot use fallbacks for shorthands. Use the expansion instead.');
@@ -2479,6 +2492,7 @@ const nonStaticValue = fn => `Only static values are allowed inside of a ${fn}()
2479
2492
  const nonStyleObject = fn => `${fn}() can only accept an object.`;
2480
2493
  const nonExportNamedDeclaration = fn => `The return value of ${fn}() must be bound to a named export.`;
2481
2494
  const unboundCallValue = fn => `${fn}() calls must be bound to a bare variable.`;
2495
+ const cannotGenerateHash = fn => `Unable to generate hash for ${fn}(). Check that the file has a valid extension and that unstable_moduleResolution is configured.`;
2482
2496
  const DUPLICATE_CONDITIONAL = 'The same pseudo selector or at-rule cannot be used more than once.';
2483
2497
  const ESCAPED_STYLEX_VALUE = 'Escaping a create() value is not allowed.';
2484
2498
  const ILLEGAL_NESTED_PSEUDO = "Pseudo objects can't be nested more than one level deep.";
@@ -2497,6 +2511,7 @@ const ONLY_NAMED_PARAMETERS_IN_DYNAMIC_STYLE_FUNCTIONS = 'Only named parameters
2497
2511
  const ONLY_TOP_LEVEL = 'create() is only allowed at the root of a program.';
2498
2512
  const UNKNOWN_PROP_KEY = 'Unknown property key';
2499
2513
  const POSITION_TRY_INVALID_PROPERTY = 'Invalid property in `positionTry()` call. It may only contain, positionAnchor, positionArea, inset properties (top, left, insetInline etc.), margin properties, size properties (height, inlineSize, etc.), and self-alignment properties (alignSelf, justifySelf, placeSelf)';
2514
+ const VIEW_TRANSITION_CLASS_INVALID_PROPERTY = 'Invalid property in `viewTransitionClass()` call. It may only contain group, imagePair, old, and new properties';
2500
2515
 
2501
2516
  var m = /*#__PURE__*/Object.freeze({
2502
2517
  __proto__: null,
@@ -2518,6 +2533,8 @@ var m = /*#__PURE__*/Object.freeze({
2518
2533
  ONLY_TOP_LEVEL: ONLY_TOP_LEVEL,
2519
2534
  POSITION_TRY_INVALID_PROPERTY: POSITION_TRY_INVALID_PROPERTY,
2520
2535
  UNKNOWN_PROP_KEY: UNKNOWN_PROP_KEY,
2536
+ VIEW_TRANSITION_CLASS_INVALID_PROPERTY: VIEW_TRANSITION_CLASS_INVALID_PROPERTY,
2537
+ cannotGenerateHash: cannotGenerateHash,
2521
2538
  illegalArgumentLength: illegalArgumentLength,
2522
2539
  nonExportNamedDeclaration: nonExportNamedDeclaration,
2523
2540
  nonStaticValue: nonStaticValue,
@@ -2606,100 +2623,202 @@ const lengthUnits = new Set(['backgroundPositionX', 'backgroundPositionY', 'bloc
2606
2623
 
2607
2624
  const logicalToPhysical$1 = {
2608
2625
  start: 'left',
2609
- end: 'right'
2626
+ end: 'right',
2627
+ 'inline-start': 'left',
2628
+ 'inline-end': 'right'
2629
+ };
2630
+ const legacyValuesPolyfill$1 = {
2631
+ float: _ref => {
2632
+ let [key, val] = _ref;
2633
+ return [key, logicalToPhysical$1[val] ?? val];
2634
+ },
2635
+ clear: _ref2 => {
2636
+ let [key, val] = _ref2;
2637
+ return [key, logicalToPhysical$1[val] ?? val];
2638
+ }
2639
+ };
2640
+ const inlinePropertyToLTR = {
2641
+ 'margin-inline-start': _ref3 => {
2642
+ let [_key, val] = _ref3;
2643
+ return ['margin-left', val];
2644
+ },
2645
+ 'margin-inline-end': _ref4 => {
2646
+ let [_key, val] = _ref4;
2647
+ return ['margin-right', val];
2648
+ },
2649
+ 'padding-inline-start': _ref5 => {
2650
+ let [_key, val] = _ref5;
2651
+ return ['padding-left', val];
2652
+ },
2653
+ 'padding-inline-end': _ref6 => {
2654
+ let [_key, val] = _ref6;
2655
+ return ['padding-right', val];
2656
+ },
2657
+ 'border-inline-start': _ref7 => {
2658
+ let [_key, val] = _ref7;
2659
+ return ['border-left', val];
2660
+ },
2661
+ 'border-inline-end': _ref8 => {
2662
+ let [_key, val] = _ref8;
2663
+ return ['border-right', val];
2664
+ },
2665
+ 'border-inline-start-width': _ref9 => {
2666
+ let [_key, val] = _ref9;
2667
+ return ['border-left-width', val];
2668
+ },
2669
+ 'border-inline-end-width': _ref0 => {
2670
+ let [_key, val] = _ref0;
2671
+ return ['border-right-width', val];
2672
+ },
2673
+ 'border-inline-start-color': _ref1 => {
2674
+ let [_key, val] = _ref1;
2675
+ return ['border-left-color', val];
2676
+ },
2677
+ 'border-inline-end-color': _ref10 => {
2678
+ let [_key, val] = _ref10;
2679
+ return ['border-right-color', val];
2680
+ },
2681
+ 'border-inline-start-style': _ref11 => {
2682
+ let [_key, val] = _ref11;
2683
+ return ['border-left-style', val];
2684
+ },
2685
+ 'border-inline-end-style': _ref12 => {
2686
+ let [_key, val] = _ref12;
2687
+ return ['border-right-style', val];
2688
+ },
2689
+ 'border-start-start-radius': _ref13 => {
2690
+ let [_key, val] = _ref13;
2691
+ return ['border-top-left-radius', val];
2692
+ },
2693
+ 'border-end-start-radius': _ref14 => {
2694
+ let [_key, val] = _ref14;
2695
+ return ['border-bottom-left-radius', val];
2696
+ },
2697
+ 'border-start-end-radius': _ref15 => {
2698
+ let [_key, val] = _ref15;
2699
+ return ['border-top-right-radius', val];
2700
+ },
2701
+ 'border-end-end-radius': _ref16 => {
2702
+ let [_key, val] = _ref16;
2703
+ return ['border-bottom-right-radius', val];
2704
+ },
2705
+ 'inset-inline-start': _ref17 => {
2706
+ let [_key, val] = _ref17;
2707
+ return ['left', val];
2708
+ },
2709
+ 'inset-inline-end': _ref18 => {
2710
+ let [_key, val] = _ref18;
2711
+ return ['right', val];
2712
+ }
2610
2713
  };
2611
2714
  const propertyToLTR = {
2612
- 'margin-start': _ref => {
2613
- let [_key, val] = _ref;
2715
+ 'margin-start': _ref19 => {
2716
+ let [_key, val] = _ref19;
2614
2717
  return ['margin-left', val];
2615
2718
  },
2616
- 'margin-end': _ref2 => {
2617
- let [_key, val] = _ref2;
2719
+ 'margin-end': _ref20 => {
2720
+ let [_key, val] = _ref20;
2618
2721
  return ['margin-right', val];
2619
2722
  },
2620
- 'padding-start': _ref3 => {
2621
- let [_key, val] = _ref3;
2723
+ 'padding-start': _ref21 => {
2724
+ let [_key, val] = _ref21;
2622
2725
  return ['padding-left', val];
2623
2726
  },
2624
- 'padding-end': _ref4 => {
2625
- let [_key, val] = _ref4;
2727
+ 'padding-end': _ref22 => {
2728
+ let [_key, val] = _ref22;
2626
2729
  return ['padding-right', val];
2627
2730
  },
2628
- 'border-start': _ref5 => {
2629
- let [_key, val] = _ref5;
2731
+ 'border-start': _ref23 => {
2732
+ let [_key, val] = _ref23;
2630
2733
  return ['border-left', val];
2631
2734
  },
2632
- 'border-end': _ref6 => {
2633
- let [_key, val] = _ref6;
2735
+ 'border-end': _ref24 => {
2736
+ let [_key, val] = _ref24;
2634
2737
  return ['border-right', val];
2635
2738
  },
2636
- 'border-start-width': _ref7 => {
2637
- let [_key, val] = _ref7;
2739
+ 'border-start-width': _ref25 => {
2740
+ let [_key, val] = _ref25;
2638
2741
  return ['border-left-width', val];
2639
2742
  },
2640
- 'border-end-width': _ref8 => {
2641
- let [_key, val] = _ref8;
2743
+ 'border-end-width': _ref26 => {
2744
+ let [_key, val] = _ref26;
2642
2745
  return ['border-right-width', val];
2643
2746
  },
2644
- 'border-start-color': _ref9 => {
2645
- let [_key, val] = _ref9;
2747
+ 'border-start-color': _ref27 => {
2748
+ let [_key, val] = _ref27;
2646
2749
  return ['border-left-color', val];
2647
2750
  },
2648
- 'border-end-color': _ref0 => {
2649
- let [_key, val] = _ref0;
2751
+ 'border-end-color': _ref28 => {
2752
+ let [_key, val] = _ref28;
2650
2753
  return ['border-right-color', val];
2651
2754
  },
2652
- 'border-start-style': _ref1 => {
2653
- let [_key, val] = _ref1;
2755
+ 'border-start-style': _ref29 => {
2756
+ let [_key, val] = _ref29;
2654
2757
  return ['border-left-style', val];
2655
2758
  },
2656
- 'border-end-style': _ref10 => {
2657
- let [_key, val] = _ref10;
2759
+ 'border-end-style': _ref30 => {
2760
+ let [_key, val] = _ref30;
2658
2761
  return ['border-right-style', val];
2659
2762
  },
2660
- 'border-top-start-radius': _ref11 => {
2661
- let [_key, val] = _ref11;
2763
+ 'border-top-start-radius': _ref31 => {
2764
+ let [_key, val] = _ref31;
2662
2765
  return ['border-top-left-radius', val];
2663
2766
  },
2664
- 'border-bottom-start-radius': _ref12 => {
2665
- let [_key, val] = _ref12;
2767
+ 'border-bottom-start-radius': _ref32 => {
2768
+ let [_key, val] = _ref32;
2666
2769
  return ['border-bottom-left-radius', val];
2667
2770
  },
2668
- 'border-top-end-radius': _ref13 => {
2669
- let [_key, val] = _ref13;
2771
+ 'border-top-end-radius': _ref33 => {
2772
+ let [_key, val] = _ref33;
2670
2773
  return ['border-top-right-radius', val];
2671
2774
  },
2672
- 'border-bottom-end-radius': _ref14 => {
2673
- let [_key, val] = _ref14;
2775
+ 'border-bottom-end-radius': _ref34 => {
2776
+ let [_key, val] = _ref34;
2674
2777
  return ['border-bottom-right-radius', val];
2675
2778
  },
2676
- float: _ref15 => {
2677
- let [key, val] = _ref15;
2779
+ float: _ref35 => {
2780
+ let [key, val] = _ref35;
2678
2781
  return [key, logicalToPhysical$1[val] ?? val];
2679
2782
  },
2680
- clear: _ref16 => {
2681
- let [key, val] = _ref16;
2783
+ clear: _ref36 => {
2784
+ let [key, val] = _ref36;
2682
2785
  return [key, logicalToPhysical$1[val] ?? val];
2683
2786
  },
2684
- start: _ref17 => {
2685
- let [_key, val] = _ref17;
2787
+ start: _ref37 => {
2788
+ let [_key, val] = _ref37;
2686
2789
  return ['left', val];
2687
2790
  },
2688
- end: _ref18 => {
2689
- let [_key, val] = _ref18;
2791
+ end: _ref38 => {
2792
+ let [_key, val] = _ref38;
2690
2793
  return ['right', val];
2691
2794
  },
2692
- 'background-position': _ref19 => {
2693
- let [key, val] = _ref19;
2694
- return [key, val.split(' ').map(word => word === 'start' ? 'left' : word === 'end' ? 'right' : word).join(' ')];
2795
+ 'background-position': _ref39 => {
2796
+ let [key, val] = _ref39;
2797
+ return [key, val.split(' ').map(word => word === 'start' || word === 'insetInlineStart' ? 'left' : word === 'end' || word === 'insetInlineEnd' ? 'right' : word).join(' ')];
2695
2798
  }
2696
2799
  };
2697
2800
  function generateLTR(pair) {
2801
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultOptions;
2802
+ const {
2803
+ enableLogicalStylesPolyfill,
2804
+ styleResolution
2805
+ } = options;
2698
2806
  const [key] = pair;
2699
- if (propertyToLTR[key]) {
2700
- return propertyToLTR[key](pair);
2807
+ if (styleResolution === 'legacy-expand-shorthands') {
2808
+ if (!enableLogicalStylesPolyfill) {
2809
+ if (legacyValuesPolyfill$1[key]) {
2810
+ return legacyValuesPolyfill$1[key](pair);
2811
+ }
2812
+ return pair;
2813
+ }
2814
+ if (inlinePropertyToLTR[key]) {
2815
+ return inlinePropertyToLTR[key](pair);
2816
+ }
2701
2817
  }
2702
- return pair;
2818
+ if (!propertyToLTR[key]) {
2819
+ return pair;
2820
+ }
2821
+ return propertyToLTR[key](pair);
2703
2822
  }
2704
2823
 
2705
2824
  const cursorFlip = {
@@ -2758,118 +2877,220 @@ function flipShadow(value) {
2758
2877
  }
2759
2878
  const logicalToPhysical = {
2760
2879
  start: 'right',
2761
- end: 'left'
2880
+ end: 'left',
2881
+ 'inline-start': 'right',
2882
+ 'inline-end': 'left'
2883
+ };
2884
+ const legacyValuesPolyfill = {
2885
+ float: _ref => {
2886
+ let [key, val] = _ref;
2887
+ return [key, logicalToPhysical[val] ?? val];
2888
+ },
2889
+ clear: _ref2 => {
2890
+ let [key, val] = _ref2;
2891
+ return [key, logicalToPhysical[val] ?? val];
2892
+ }
2893
+ };
2894
+ const inlinePropertyToRTL = {
2895
+ 'margin-inline-start': _ref3 => {
2896
+ let [_key, val] = _ref3;
2897
+ return ['margin-right', val];
2898
+ },
2899
+ 'margin-inline-end': _ref4 => {
2900
+ let [_key, val] = _ref4;
2901
+ return ['margin-left', val];
2902
+ },
2903
+ 'padding-inline-start': _ref5 => {
2904
+ let [_key, val] = _ref5;
2905
+ return ['padding-right', val];
2906
+ },
2907
+ 'padding-inline-end': _ref6 => {
2908
+ let [_key, val] = _ref6;
2909
+ return ['padding-left', val];
2910
+ },
2911
+ 'border-inline-start': _ref7 => {
2912
+ let [_key, val] = _ref7;
2913
+ return ['border-right', val];
2914
+ },
2915
+ 'border-inline-end': _ref8 => {
2916
+ let [_key, val] = _ref8;
2917
+ return ['border-left', val];
2918
+ },
2919
+ 'border-inline-start-width': _ref9 => {
2920
+ let [_key, val] = _ref9;
2921
+ return ['border-right-width', val];
2922
+ },
2923
+ 'border-inline-end-width': _ref0 => {
2924
+ let [_key, val] = _ref0;
2925
+ return ['border-left-width', val];
2926
+ },
2927
+ 'border-inline-start-color': _ref1 => {
2928
+ let [_key, val] = _ref1;
2929
+ return ['border-right-color', val];
2930
+ },
2931
+ 'border-inline-end-color': _ref10 => {
2932
+ let [_key, val] = _ref10;
2933
+ return ['border-left-color', val];
2934
+ },
2935
+ 'border-inline-start-style': _ref11 => {
2936
+ let [_key, val] = _ref11;
2937
+ return ['border-right-style', val];
2938
+ },
2939
+ 'border-inline-end-style': _ref12 => {
2940
+ let [_key, val] = _ref12;
2941
+ return ['border-left-style', val];
2942
+ },
2943
+ 'border-start-start-radius': _ref13 => {
2944
+ let [_key, val] = _ref13;
2945
+ return ['border-top-right-radius', val];
2946
+ },
2947
+ 'border-end-start-radius': _ref14 => {
2948
+ let [_key, val] = _ref14;
2949
+ return ['border-bottom-right-radius', val];
2950
+ },
2951
+ 'border-start-end-radius': _ref15 => {
2952
+ let [_key, val] = _ref15;
2953
+ return ['border-top-left-radius', val];
2954
+ },
2955
+ 'border-end-end-radius': _ref16 => {
2956
+ let [_key, val] = _ref16;
2957
+ return ['border-bottom-left-radius', val];
2958
+ },
2959
+ 'inset-inline-start': _ref17 => {
2960
+ let [_key, val] = _ref17;
2961
+ return ['right', val];
2962
+ },
2963
+ 'inset-inline-end': _ref18 => {
2964
+ let [_key, val] = _ref18;
2965
+ return ['left', val];
2966
+ }
2762
2967
  };
2763
2968
  const propertyToRTL = {
2764
- 'margin-start': _ref => {
2765
- let [_key, val] = _ref;
2969
+ 'margin-start': _ref19 => {
2970
+ let [_key, val] = _ref19;
2766
2971
  return ['margin-right', val];
2767
2972
  },
2768
- 'margin-end': _ref2 => {
2769
- let [_key, val] = _ref2;
2973
+ 'margin-end': _ref20 => {
2974
+ let [_key, val] = _ref20;
2770
2975
  return ['margin-left', val];
2771
2976
  },
2772
- 'padding-start': _ref3 => {
2773
- let [_key, val] = _ref3;
2977
+ 'padding-start': _ref21 => {
2978
+ let [_key, val] = _ref21;
2774
2979
  return ['padding-right', val];
2775
2980
  },
2776
- 'padding-end': _ref4 => {
2777
- let [_key, val] = _ref4;
2981
+ 'padding-end': _ref22 => {
2982
+ let [_key, val] = _ref22;
2778
2983
  return ['padding-left', val];
2779
2984
  },
2780
- 'border-start': _ref5 => {
2781
- let [_key, val] = _ref5;
2985
+ 'border-start': _ref23 => {
2986
+ let [_key, val] = _ref23;
2782
2987
  return ['border-right', val];
2783
2988
  },
2784
- 'border-end': _ref6 => {
2785
- let [_key, val] = _ref6;
2989
+ 'border-end': _ref24 => {
2990
+ let [_key, val] = _ref24;
2786
2991
  return ['border-left', val];
2787
2992
  },
2788
- 'border-start-width': _ref7 => {
2789
- let [_key, val] = _ref7;
2993
+ 'border-start-width': _ref25 => {
2994
+ let [_key, val] = _ref25;
2790
2995
  return ['border-right-width', val];
2791
2996
  },
2792
- 'border-end-width': _ref8 => {
2793
- let [_key, val] = _ref8;
2997
+ 'border-end-width': _ref26 => {
2998
+ let [_key, val] = _ref26;
2794
2999
  return ['border-left-width', val];
2795
3000
  },
2796
- 'border-start-color': _ref9 => {
2797
- let [_key, val] = _ref9;
3001
+ 'border-start-color': _ref27 => {
3002
+ let [_key, val] = _ref27;
2798
3003
  return ['border-right-color', val];
2799
3004
  },
2800
- 'border-end-color': _ref0 => {
2801
- let [_key, val] = _ref0;
3005
+ 'border-end-color': _ref28 => {
3006
+ let [_key, val] = _ref28;
2802
3007
  return ['border-left-color', val];
2803
3008
  },
2804
- 'border-start-style': _ref1 => {
2805
- let [_key, val] = _ref1;
3009
+ 'border-start-style': _ref29 => {
3010
+ let [_key, val] = _ref29;
2806
3011
  return ['border-right-style', val];
2807
3012
  },
2808
- 'border-end-style': _ref10 => {
2809
- let [_key, val] = _ref10;
3013
+ 'border-end-style': _ref30 => {
3014
+ let [_key, val] = _ref30;
2810
3015
  return ['border-left-style', val];
2811
3016
  },
2812
- 'border-top-start-radius': _ref11 => {
2813
- let [_key, val] = _ref11;
3017
+ 'border-top-start-radius': _ref31 => {
3018
+ let [_key, val] = _ref31;
2814
3019
  return ['border-top-right-radius', val];
2815
3020
  },
2816
- 'border-bottom-start-radius': _ref12 => {
2817
- let [_key, val] = _ref12;
3021
+ 'border-bottom-start-radius': _ref32 => {
3022
+ let [_key, val] = _ref32;
2818
3023
  return ['border-bottom-right-radius', val];
2819
3024
  },
2820
- 'border-top-end-radius': _ref13 => {
2821
- let [_key, val] = _ref13;
3025
+ 'border-top-end-radius': _ref33 => {
3026
+ let [_key, val] = _ref33;
2822
3027
  return ['border-top-left-radius', val];
2823
3028
  },
2824
- 'border-bottom-end-radius': _ref14 => {
2825
- let [_key, val] = _ref14;
3029
+ 'border-bottom-end-radius': _ref34 => {
3030
+ let [_key, val] = _ref34;
2826
3031
  return ['border-bottom-left-radius', val];
2827
3032
  },
2828
- float: _ref15 => {
2829
- let [key, val] = _ref15;
3033
+ float: _ref35 => {
3034
+ let [key, val] = _ref35;
2830
3035
  return logicalToPhysical[val] != null ? [key, logicalToPhysical[val]] : null;
2831
3036
  },
2832
- clear: _ref16 => {
2833
- let [key, val] = _ref16;
3037
+ clear: _ref36 => {
3038
+ let [key, val] = _ref36;
2834
3039
  return logicalToPhysical[val] != null ? [key, logicalToPhysical[val]] : null;
2835
3040
  },
2836
- start: _ref17 => {
2837
- let [_key, val] = _ref17;
3041
+ start: _ref37 => {
3042
+ let [_key, val] = _ref37;
2838
3043
  return ['right', val];
2839
3044
  },
2840
- end: _ref18 => {
2841
- let [_key, val] = _ref18;
3045
+ end: _ref38 => {
3046
+ let [_key, val] = _ref38;
2842
3047
  return ['left', val];
2843
3048
  },
2844
- 'background-position': _ref19 => {
2845
- let [key, val] = _ref19;
3049
+ 'background-position': _ref39 => {
3050
+ let [key, val] = _ref39;
2846
3051
  const words = val.split(' ');
2847
3052
  if (!words.includes('start') && !words.includes('end')) {
2848
3053
  return null;
2849
3054
  }
2850
- return [key, words.map(word => word === 'start' ? 'right' : word === 'end' ? 'left' : word).join(' ')];
3055
+ return [key, words.map(word => word === 'start' || word === 'insetInlineStart' ? 'right' : word === 'end' || word === 'insetInlineEnd' ? 'left' : word).join(' ')];
2851
3056
  },
2852
- cursor: _ref20 => {
2853
- let [key, val] = _ref20;
3057
+ cursor: _ref40 => {
3058
+ let [key, val] = _ref40;
2854
3059
  return cursorFlip[val] != null ? [key, cursorFlip[val]] : null;
2855
3060
  },
2856
- 'box-shadow': _ref21 => {
2857
- let [key, val] = _ref21;
3061
+ 'box-shadow': _ref41 => {
3062
+ let [key, val] = _ref41;
2858
3063
  const rtlVal = flipShadow(val);
2859
3064
  return rtlVal ? [key, rtlVal] : null;
2860
3065
  },
2861
- 'text-shadow': _ref22 => {
2862
- let [key, val] = _ref22;
3066
+ 'text-shadow': _ref42 => {
3067
+ let [key, val] = _ref42;
2863
3068
  const rtlVal = flipShadow(val);
2864
3069
  return rtlVal ? [key, rtlVal] : null;
2865
3070
  }
2866
3071
  };
2867
- function generateRTL(_ref23) {
2868
- let [key, value] = _ref23;
2869
- if (propertyToRTL[key]) {
2870
- return propertyToRTL[key]([key, value]);
3072
+ function generateRTL(_ref43) {
3073
+ let [key, value] = _ref43;
3074
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultOptions;
3075
+ const {
3076
+ enableLogicalStylesPolyfill,
3077
+ styleResolution
3078
+ } = options;
3079
+ if (styleResolution === 'legacy-expand-shorthands') {
3080
+ if (!enableLogicalStylesPolyfill) {
3081
+ if (legacyValuesPolyfill[key]) {
3082
+ return legacyValuesPolyfill[key]([key, value]);
3083
+ }
3084
+ return null;
3085
+ }
3086
+ if (inlinePropertyToRTL[key]) {
3087
+ return inlinePropertyToRTL[key]([key, value]);
3088
+ }
2871
3089
  }
2872
- return null;
3090
+ if (!propertyToRTL[key]) {
3091
+ return null;
3092
+ }
3093
+ return propertyToRTL[key]([key, value]);
2873
3094
  }
2874
3095
 
2875
3096
  const longHandPhysical = new Set();
@@ -3389,17 +3610,17 @@ function getPriority(key) {
3389
3610
  const prop = key.startsWith(':') && key.includes('(') ? key.slice(0, key.indexOf('(')) : key;
3390
3611
  return PSEUDO_CLASS_PRIORITIES[prop] ?? 40;
3391
3612
  }
3392
- if (longHandPhysical.has(key)) {
3393
- return 4000;
3394
- }
3395
- if (longHandLogical.has(key)) {
3396
- return 3000;
3613
+ if (shorthandsOfShorthands.has(key)) {
3614
+ return 1000;
3397
3615
  }
3398
3616
  if (shorthandsOfLonghands.has(key)) {
3399
3617
  return 2000;
3400
3618
  }
3401
- if (shorthandsOfShorthands.has(key)) {
3402
- return 1000;
3619
+ if (longHandLogical.has(key)) {
3620
+ return 3000;
3621
+ }
3622
+ if (longHandPhysical.has(key)) {
3623
+ return 4000;
3403
3624
  }
3404
3625
  return 3000;
3405
3626
  }
@@ -3415,10 +3636,11 @@ function buildNestedCSSRule(className, decls, pseudos, atRules, constRules) {
3415
3636
  return combinedAtRules.reduce((acc, combinedAtRules) => `${combinedAtRules}{${acc}}`, `${selectorForAtRules}{${decls}}`);
3416
3637
  }
3417
3638
  function generateCSSRule(className, key, value, pseudos, atRules, constRules) {
3639
+ let options = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : defaultOptions;
3418
3640
  const pairs = Array.isArray(value) ? value.map(eachValue => [key, eachValue]) : [[key, value]];
3419
- const ltrPairs = pairs.map(generateLTR);
3641
+ const ltrPairs = pairs.map(pair => generateLTR(pair, options));
3420
3642
  const ltrDecls = ltrPairs.map(pair => pair.join(':')).join(';');
3421
- const rtlDecls = pairs.map(generateRTL).filter(Boolean).map(pair => pair.join(':')).join(';');
3643
+ const rtlDecls = pairs.map(pair => generateRTL(pair, options)).filter(Boolean).map(pair => pair.join(':')).join(';');
3422
3644
  const ltrRule = buildNestedCSSRule(className, ltrDecls, pseudos, atRules, constRules);
3423
3645
  const rtlRule = !rtlDecls ? null : buildNestedCSSRule(className, rtlDecls, pseudos, atRules, constRules);
3424
3646
  const priority = getPriority(key) + pseudos.map(getPriority).reduce((a, b) => a + b, 0) + atRules.map(getPriority).reduce((a, b) => a + b, 0) + constRules.map(getPriority).reduce((a, b) => a + b, 0);
@@ -3546,7 +3768,7 @@ function convertStyleToClassName(objEntry, pseudos, atRules, constRules) {
3546
3768
  const valueAsString = Array.isArray(value) ? value.join(', ') : value;
3547
3769
  const stringToHash = dashedKey + valueAsString + modifierHashString;
3548
3770
  const className = debug && enableDebugClassNames ? `${key}-${classNamePrefix}${hash('<>' + stringToHash)}` : classNamePrefix + hash('<>' + stringToHash);
3549
- const cssRules = generateCSSRule(className, dashedKey, value, pseudos, atRules, constRules);
3771
+ const cssRules = generateCSSRule(className, dashedKey, value, pseudos, atRules, constRules, options);
3550
3772
  return [key, className, cssRules];
3551
3773
  }
3552
3774
  function variableFallbacks(values) {
@@ -4031,7 +4253,7 @@ function collectVarsByAtRule(key, _ref) {
4031
4253
  return;
4032
4254
  }
4033
4255
  if (Array.isArray(value)) {
4034
- throw new Error('Array is not supported in stylex.defineVars');
4256
+ throw new Error('Array is not supported in defineVars');
4035
4257
  }
4036
4258
  if (typeof value === 'object') {
4037
4259
  if (value.default === undefined) {
@@ -4050,7 +4272,7 @@ function wrapWithAtRules(ltr, atRule) {
4050
4272
  }
4051
4273
  function priorityForAtRule(atRule) {
4052
4274
  if (atRule === 'default') {
4053
- return 0;
4275
+ return 1;
4054
4276
  }
4055
4277
  return atRule.split(SPLIT_TOKEN).length;
4056
4278
  }
@@ -4062,7 +4284,7 @@ function getDefaultValue(value) {
4062
4284
  return null;
4063
4285
  }
4064
4286
  if (Array.isArray(value)) {
4065
- throw new Error('Array is not supported in stylex.defineVars');
4287
+ throw new Error('Array is not supported in defineVars');
4066
4288
  }
4067
4289
  if (typeof value === 'object') {
4068
4290
  if (value.default === undefined) {
@@ -4070,7 +4292,7 @@ function getDefaultValue(value) {
4070
4292
  }
4071
4293
  return getDefaultValue(value.default);
4072
4294
  }
4073
- throw new Error('Invalid value in stylex.defineVars');
4295
+ throw new Error('Invalid value in defineVars');
4074
4296
  }
4075
4297
 
4076
4298
  function styleXDefineVars(variables, options) {
@@ -4190,7 +4412,7 @@ function styleXDefineConsts(constants, options) {
4190
4412
 
4191
4413
  function styleXCreateTheme(themeVars, variables, options) {
4192
4414
  if (typeof themeVars.__themeName__ !== 'string') {
4193
- throw new Error('Can only override variables theme created with stylex.defineVars().');
4415
+ throw new Error('Can only override variables theme created with defineVars().');
4194
4416
  }
4195
4417
  const {
4196
4418
  classNamePrefix
@@ -4231,8 +4453,8 @@ function styleXCreateTheme(themeVars, variables, options) {
4231
4453
  }
4232
4454
  const themeClass = `${overrideClassName} ${themeVars.__themeName__}`;
4233
4455
  return [{
4234
- $$css: true,
4235
- [themeVars.__themeName__]: themeClass
4456
+ [themeVars.__themeName__]: themeClass,
4457
+ $$css: true
4236
4458
  }, stylesToInject];
4237
4459
  }
4238
4460
 
@@ -4252,7 +4474,7 @@ function styleXKeyframes(frames) {
4252
4474
  return [animationName, {
4253
4475
  ltr,
4254
4476
  rtl,
4255
- priority: 1
4477
+ priority: 0
4256
4478
  }];
4257
4479
  }
4258
4480
  function expandFrameShorthands(frame, options) {
@@ -4282,7 +4504,7 @@ function styleXPositionTry(styles) {
4282
4504
  const {
4283
4505
  classNamePrefix = 'x'
4284
4506
  } = options;
4285
- const expandedObject = Pipe.create(styles).pipe(styles => preprocessProperties(styles, options)).pipe(x => objMapKeys(x, dashify)).pipe(x => objMap(x, (value, key) => transformValue(key, value, options))).done();
4507
+ const expandedObject = Pipe.create(styles).pipe(styles => preprocessProperties$1(styles, options)).pipe(x => objMapKeys(x, dashify)).pipe(x => objMap(x, (value, key) => transformValue(key, value, options))).done();
4286
4508
  const ltrStyles = objMap(expandedObject, (value, key) => generateLTR([key, value]));
4287
4509
  const rtlStyles = objMap(expandedObject, (value, key) => generateRTL([key, value]) ?? value);
4288
4510
  const ltrString = constructPositionTryObj(ltrStyles);
@@ -4293,10 +4515,10 @@ function styleXPositionTry(styles) {
4293
4515
  return [positionTryName, {
4294
4516
  ltr,
4295
4517
  rtl,
4296
- priority: 1
4518
+ priority: 0
4297
4519
  }];
4298
4520
  }
4299
- function preprocessProperties(styles, options) {
4521
+ function preprocessProperties$1(styles, options) {
4300
4522
  return objFromEntries(objEntries(styles).flatMap(pair => flatMapExpandedShorthands(pair, options).map(_ref => {
4301
4523
  let [key, value] = _ref;
4302
4524
  if (typeof value === 'string' || typeof value === 'number') {
@@ -4557,8 +4779,8 @@ function evaluateThemeRef(fileName, exportName, state) {
4557
4779
  debug,
4558
4780
  enableDebugClassNames
4559
4781
  } = state.traversalState.options;
4560
- const varSafeKey = (key[0] >= '0' && key[0] <= '9' ? `_${key}` : key).replace(/[^a-zA-Z0-9]/g, '_');
4561
- const varName = debug && enableDebugClassNames ? varSafeKey + '-' + state.traversalState.options.classNamePrefix + utils.hash(strToHash) : state.traversalState.options.classNamePrefix + utils.hash(strToHash);
4782
+ const varSafeKey = key === '__themeName__' ? '' : (key[0] >= '0' && key[0] <= '9' ? `_${key}` : key).replace(/[^a-zA-Z0-9]/g, '_') + '-';
4783
+ const varName = debug && enableDebugClassNames ? varSafeKey + state.traversalState.options.classNamePrefix + utils.hash(strToHash) : state.traversalState.options.classNamePrefix + utils.hash(strToHash);
4562
4784
  if (key === '__themeName__') {
4563
4785
  return varName;
4564
4786
  }
@@ -5625,7 +5847,7 @@ function transformStyleXCreateTheme(callExpressionPath, state) {
5625
5847
  throw callExpressionPath.buildCodeFrameError(messages.nonStyleObject('createTheme'), SyntaxError);
5626
5848
  }
5627
5849
  if (typeof variables.__themeName__ !== 'string' || variables.__themeName__ === '') {
5628
- throw callExpressionPath.buildCodeFrameError('Can only override variables theme created with stylex.defineVars().', SyntaxError);
5850
+ throw callExpressionPath.buildCodeFrameError('Can only override variables theme created with defineVars().', SyntaxError);
5629
5851
  }
5630
5852
  let [overridesObj, injectedStyles] = createTheme(variables, overrides, state.options);
5631
5853
  if (state.isTest) {
@@ -5743,7 +5965,7 @@ function transformStyleXDefineVars(callExpressionPath, state) {
5743
5965
  }
5744
5966
  const fileName = state.fileNameForHashing;
5745
5967
  if (fileName == null) {
5746
- throw new Error('No filename found for generating theme name.');
5968
+ throw new Error(messages.cannotGenerateHash('defineVars'));
5747
5969
  }
5748
5970
  const exportName = varId.name;
5749
5971
  const [variablesObj, injectedStylesSansKeyframes] = defineVars(value, {
@@ -5806,7 +6028,7 @@ function transformStyleXDefineConsts(callExpressionPath, state) {
5806
6028
  }
5807
6029
  const fileName = state.fileNameForHashing;
5808
6030
  if (fileName == null) {
5809
- throw new Error('No filename found for generating theme name.');
6031
+ throw new Error(messages.cannotGenerateHash('defineConsts'));
5810
6032
  }
5811
6033
  const exportName = varId.name;
5812
6034
  const themeName = utils.genFileBasedIdentifier({
@@ -5966,7 +6188,7 @@ function transformStyleXPositionTry(path, state) {
5966
6188
  }
5967
6189
  const plainObject = value;
5968
6190
  assertValidPositionTry(firstArgPath, plainObject);
5969
- assertValidProperties(firstArgPath, plainObject);
6191
+ assertValidProperties$1(firstArgPath, plainObject);
5970
6192
  const [positionTryName, {
5971
6193
  ltr,
5972
6194
  priority,
@@ -5985,7 +6207,7 @@ function assertValidPositionTry(path, obj) {
5985
6207
  }
5986
6208
  }
5987
6209
  const VALID_POSITION_TRY_PROPERTIES = ['anchorName', 'positionAnchor', 'positionArea', 'top', 'right', 'bottom', 'left', 'inset', 'insetBlock', 'insetBlockEnd', 'insetBlockStart', 'insetInline', 'insetInlineEnd', 'insetInlineStart', 'margin', 'marginBlock', 'marginBlockEnd', 'marginBlockStart', 'marginInline', 'marginInlineEnd', 'marginInlineStart', 'marginTop', 'marginBottom', 'marginLeft', 'marginRight', 'width', 'height', 'minWidth', 'minHeight', 'maxWidth', 'maxHeight', 'blockSize', 'inlineSize', 'minBlockSize', 'minInlineSize', 'maxBlockSize', 'maxInlineSize', 'alignSelf', 'justifySelf', 'placeSelf'];
5988
- function assertValidProperties(path, obj) {
6210
+ function assertValidProperties$1(path, obj) {
5989
6211
  const keys = Object.keys(obj);
5990
6212
  if (keys.some(key => !VALID_POSITION_TRY_PROPERTIES.includes(key))) {
5991
6213
  throw path.buildCodeFrameError(POSITION_TRY_INVALID_PROPERTY, SyntaxError);
@@ -6451,6 +6673,147 @@ function isCalleeMemberExpression(path, state) {
6451
6673
  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);
6452
6674
  }
6453
6675
 
6676
+ function styleXViewTransitionClass(styles) {
6677
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultOptions;
6678
+ const {
6679
+ classNamePrefix = 'x'
6680
+ } = options;
6681
+ const preprocessedObject = objMap(styles, style => Pipe.create(style).pipe(style => preprocessProperties(style, options)).pipe(x => objMapKeys(x, dashify)).pipe(x => objMap(x, (value, key) => transformValue(key, value, options))).done());
6682
+ const expandedObject = objMapKeys(preprocessedObject, k => `::view-transition-${dashify(k)}`);
6683
+ const styleStrings = objMap(expandedObject, constructViewTransitionClassStyleStr);
6684
+ const viewTransitionClassName = classNamePrefix + hash(constructViewTransitionClassStyleStr(styleStrings));
6685
+ const style = constructFinalViewTransitionCSSStr(styleStrings, viewTransitionClassName);
6686
+ return [viewTransitionClassName, {
6687
+ ltr: style,
6688
+ rtl: null,
6689
+ priority: 1
6690
+ }];
6691
+ }
6692
+ function preprocessProperties(styles, options) {
6693
+ return objFromEntries(objEntries(styles).flatMap(pair => flatMapExpandedShorthands(pair, options).map(_ref => {
6694
+ let [key, value] = _ref;
6695
+ if (typeof value === 'string' || typeof value === 'number') {
6696
+ return [key, value];
6697
+ }
6698
+ return null;
6699
+ }).filter(Boolean)).filter(_ref2 => {
6700
+ let [_key, value] = _ref2;
6701
+ return value != null;
6702
+ }));
6703
+ }
6704
+ function constructViewTransitionClassStyleStr(style) {
6705
+ return objEntries(style).map(_ref3 => {
6706
+ let [k, v] = _ref3;
6707
+ return `${k}:${v};`;
6708
+ }).join('');
6709
+ }
6710
+ function constructFinalViewTransitionCSSStr(styles, className) {
6711
+ return objEntries(styles).map(_ref4 => {
6712
+ let [k, v] = _ref4;
6713
+ return `${k}(*.${className}){${v}}`;
6714
+ }).join('');
6715
+ }
6716
+
6717
+ function transformStyleXViewTransitionClass(path, state) {
6718
+ const initPath = path.get('init');
6719
+ if (!initPath.isCallExpression()) {
6720
+ return;
6721
+ }
6722
+ const callExpressionPath = initPath;
6723
+ const idPath = path.get('id');
6724
+ if (!idPath.isIdentifier()) {
6725
+ return;
6726
+ }
6727
+ const nodeInit = callExpressionPath.node;
6728
+ if (nodeInit.callee.type === 'Identifier' && state.stylexViewTransitionClassImport.has(nodeInit.callee.name) || nodeInit.callee.type === 'MemberExpression' && nodeInit.callee.object.type === 'Identifier' && nodeInit.callee.property.name === 'viewTransitionClass' && nodeInit.callee.property.type === 'Identifier' && state.stylexImport.has(nodeInit.callee.object.name)) {
6729
+ const init = path.get('init');
6730
+ if (init == null || !init.isCallExpression()) {
6731
+ throw path.buildCodeFrameError(nonStaticValue('viewTransitionClass'), SyntaxError);
6732
+ }
6733
+ if (nodeInit.arguments.length !== 1) {
6734
+ throw path.buildCodeFrameError(illegalArgumentLength('viewTransitionClass', 1), SyntaxError);
6735
+ }
6736
+ const args = init.get('arguments');
6737
+ const firstArgPath = args[0];
6738
+ const otherInjectedCSSRules = {};
6739
+ const keyframes$1 = animation => {
6740
+ const [animationName, injectedStyle] = keyframes(animation, state.options);
6741
+ otherInjectedCSSRules[animationName] = injectedStyle;
6742
+ return animationName;
6743
+ };
6744
+ const identifiers = {};
6745
+ const memberExpressions = {};
6746
+ state.stylexFirstThatWorksImport.forEach(name => {
6747
+ identifiers[name] = {
6748
+ fn: firstThatWorks
6749
+ };
6750
+ });
6751
+ state.stylexKeyframesImport.forEach(name => {
6752
+ identifiers[name] = {
6753
+ fn: keyframes$1
6754
+ };
6755
+ });
6756
+ state.stylexImport.forEach(name => {
6757
+ if (memberExpressions[name] == null) {
6758
+ memberExpressions[name] = {};
6759
+ }
6760
+ memberExpressions[name].firstThatWorks = {
6761
+ fn: firstThatWorks
6762
+ };
6763
+ memberExpressions[name].keyframes = {
6764
+ fn: keyframes$1
6765
+ };
6766
+ });
6767
+ const {
6768
+ confident,
6769
+ value
6770
+ } = evaluate(firstArgPath, state, {
6771
+ identifiers,
6772
+ memberExpressions
6773
+ });
6774
+ if (!confident) {
6775
+ throw callExpressionPath.buildCodeFrameError(nonStaticValue('viewTransitionClass'), SyntaxError);
6776
+ }
6777
+ const plainObject = value;
6778
+ assertValidViewTransitionClass(firstArgPath, plainObject);
6779
+ assertValidProperties(firstArgPath, plainObject);
6780
+ const [viewTransitionClassName, {
6781
+ ltr,
6782
+ priority,
6783
+ rtl
6784
+ }] = styleXViewTransitionClass(plainObject, state.options);
6785
+ init.replaceWith(t__namespace.stringLiteral(viewTransitionClassName));
6786
+ const injectedStyles = {
6787
+ ...otherInjectedCSSRules,
6788
+ [viewTransitionClassName]: {
6789
+ priority,
6790
+ ltr,
6791
+ rtl
6792
+ }
6793
+ };
6794
+ const listOfStyles = Object.entries(injectedStyles).map(_ref => {
6795
+ let [key, {
6796
+ priority,
6797
+ ...rest
6798
+ }] = _ref;
6799
+ return [key, rest, priority];
6800
+ });
6801
+ state.registerStyles(listOfStyles, path);
6802
+ }
6803
+ }
6804
+ function assertValidViewTransitionClass(path, obj) {
6805
+ if (typeof obj !== 'object' || Array.isArray(obj) || obj == null) {
6806
+ throw path.buildCodeFrameError(nonStyleObject('viewTransitionClass'), SyntaxError);
6807
+ }
6808
+ }
6809
+ const VALID_VIEW_TRANSITION_CLASS_PROPERTIES = ['group', 'imagePair', 'old', 'new'];
6810
+ function assertValidProperties(path, obj) {
6811
+ const keys = Object.keys(obj);
6812
+ if (keys.some(key => !VALID_VIEW_TRANSITION_CLASS_PROPERTIES.includes(key))) {
6813
+ throw path.buildCodeFrameError(VIEW_TRANSITION_CLASS_INVALID_PROPERTY, SyntaxError);
6814
+ }
6815
+ }
6816
+
6454
6817
  const NAME = 'stylex';
6455
6818
  function styleXTransform() {
6456
6819
  let state;
@@ -6614,6 +6977,7 @@ function styleXTransform() {
6614
6977
  const parentPath = path.parentPath;
6615
6978
  if (parentPath.isVariableDeclarator()) {
6616
6979
  transformStyleXKeyframes(parentPath, state);
6980
+ transformStyleXViewTransitionClass(parentPath, state);
6617
6981
  transformStyleXPositionTry(parentPath, state);
6618
6982
  }
6619
6983
  }
@@ -6727,14 +7091,15 @@ function processStylexRules(rules) {
6727
7091
  }, []);
6728
7092
  const header = useLayers ? '\n@layer ' + grouped.map((_, index) => `priority${index + 1}`).join(', ') + ';\n' : '';
6729
7093
  const collectedCSS = grouped.map((group, index) => {
7094
+ const pri = group[0][2];
6730
7095
  const collectedCSS = Array.from(new Map(group.map(_ref8 => {
6731
7096
  let [a, b] = _ref8;
6732
7097
  return [a, b];
6733
- })).values()).flatMap(_ref9 => {
6734
- let {
7098
+ })).values()).flatMap(rule => {
7099
+ const {
6735
7100
  ltr,
6736
7101
  rtl
6737
- } = _ref9;
7102
+ } = rule;
6738
7103
  let ltrRule = ltr,
6739
7104
  rtlRule = rtl;
6740
7105
  if (!useLayers) {
@@ -6743,7 +7108,7 @@ function processStylexRules(rules) {
6743
7108
  }
6744
7109
  return rtlRule ? [addAncestorSelector(ltrRule, "html:not([dir='rtl'])"), addAncestorSelector(rtlRule, "html[dir='rtl']")] : [ltrRule];
6745
7110
  }).join('\n');
6746
- return useLayers ? `@layer priority${index + 1}{\n${collectedCSS}\n}` : collectedCSS;
7111
+ return useLayers && pri > 0 ? `@layer priority${index + 1}{\n${collectedCSS}\n}` : collectedCSS;
6747
7112
  }).join('\n');
6748
7113
  return header + collectedCSS;
6749
7114
  }