@stylexjs/babel-plugin 0.2.0-beta.25 → 0.2.0-beta.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -14,7 +14,7 @@ by passing them to the functions of the corresponding names within `@stylex/shar
14
14
 
15
15
  ## Babel Metadata
16
16
 
17
- The StyleX Babel plugin does more than transform Javascript (or Typescript) files. It also returns a list of injected styles. The way that such a value can be returned while transforming a JS file is by using Babel's `metadata` API.
17
+ The StyleX Babel plugin does more than transform JavaScript (or Typescript) files. It also returns a list of injected styles. The way that such a value can be returned while transforming a JS file is by using Babel's `metadata` API.
18
18
 
19
19
  An example of this can be seen in some of the tests, but the result of using Babel's `transform(...)` function returns an object contains at least two keys:
20
20
 
@@ -3,6 +3,7 @@
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
+ *
6
7
  * @flow strict
7
8
  */
8
9
 
package/lib/index.js CHANGED
@@ -540,33 +540,15 @@ const shorthands$2 = {
540
540
  animationRange: value => [['animationRange', value], ['animationRangeEnd', null], ['animationRangeStart', null]],
541
541
  background: value => [['background', value], ['backgroundAttachment', null], ['backgroundClip', null], ['backgroundColor', null], ['backgroundImage', null], ['backgroundOrigin', null], ...shorthands$2.backgroundPosition(null), ['backgroundRepeat', null], ['backgroundSize', null]],
542
542
  backgroundPosition: value => [['backgroundPosition', value], ['backgroundPositionX', null], ['backgroundPositionY', null]],
543
- border: _rawValue => {
544
- throw new Error('`border` shorthand is not supported. Use `borderWidth`, `borderStyle` and `borderColor` instead.');
545
- },
546
- borderInline: _rawValue => {
547
- throw new Error('`borderInline` shorthand is not supported. Use `borderInlineWidth`, `borderInlineStyle` and `borderInlineColor` instead.');
548
- },
549
- borderBlock: _rawValue => {
550
- throw new Error('`borderBlock` shorthand is not supported. Use `borderBlockWidth`, `borderBlockStyle` and `borderBlockColor` instead.');
551
- },
552
- borderTop: _rawValue => {
553
- throw new Error(['`borderTop` is not supported.', 'Use `borderTopWidth`, `borderTopStyle` and `borderTopColor`,'].join(' '));
554
- },
555
- borderInlineEnd: _rawValue => {
556
- throw new Error('`borderInlineEnd` shorthand is not supported. Use `borderInlineEndWidth`, `borderInlineEndStyle` and `borderInlineEndColor` instead.');
557
- },
558
- borderRight: _rawValue => {
559
- throw new Error('`borderRight` shorthand is not supported. Use `borderRightWidth`, `borderRightStyle` and `borderRightColor` instead.');
560
- },
561
- borderBottom: _rawValue => {
562
- throw new Error('`borderBottom` shorthand is not supported. Use `borderBottomWidth`, `borderBottomStyle` and `borderBottomColor` instead.');
563
- },
564
- borderInlineStart: _rawValue => {
565
- throw new Error('`borderInlineStart` shorthand is not supported. Use `borderInlineStartWidth`, `borderInlineStartStyle` and `borderInlineStartColor` instead.');
566
- },
567
- borderLeft: _rawValue => {
568
- throw new Error(['`borderLeft` is not supported.', 'You could use `borderLeftWidth`, `borderLeftStyle` and `borderLeftColor`,', 'but it is preferable to use `borderInlineStartWidth`, `borderInlineStartStyle` and `borderInlineStartColor`.'].join(' '));
569
- },
543
+ border: rawValue => [['border', rawValue], ...shorthands$2.borderWidth(null), ...shorthands$2.borderStyle(null), ...shorthands$2.borderColor(null)],
544
+ borderInline: rawValue => [['borderInline', rawValue], ...shorthands$2.borderInlineWidth(null), ...shorthands$2.borderInlineStyle(null), ...shorthands$2.borderInlineColor(null)],
545
+ borderBlock: rawValue => [['borderBlock', rawValue], ...shorthands$2.borderBlockWidth(null), ...shorthands$2.borderBlockStyle(null), ...shorthands$2.borderBlockColor(null)],
546
+ borderTop: rawValue => [['borderTop', rawValue], ['borderTopWidth', null], ['borderTopStyle', null], ['borderTopColor', null]],
547
+ borderInlineEnd: rawValue => [['borderInlineEnd', rawValue], ...shorthands$2.borderInlineEndWidth(null), ...shorthands$2.borderInlineEndStyle(null), ...shorthands$2.borderInlineEndColor(null)],
548
+ borderRight: rawValue => [['borderRight', rawValue], ...shorthands$2.borderRightWidth(null), ...shorthands$2.borderRightStyle(null), ...shorthands$2.borderRightColor(null)],
549
+ borderBottom: rawValue => [['borderBottom', rawValue], ['borderBottomWidth', null], ['borderBottomStyle', null], ['borderBottomColor', null]],
550
+ borderInlineStart: _rawValue => [['borderInlineStart', null], ...shorthands$2.borderInlineStartWidth(null), ...shorthands$2.borderInlineStartStyle(null), ...shorthands$2.borderInlineStartColor(null)],
551
+ borderLeft: _rawValue => [['borderLeft', null], ...shorthands$2.borderLeftWidth(null), ...shorthands$2.borderLeftStyle(null), ...shorthands$2.borderLeftColor(null)],
570
552
  borderInlineWidth: rawValue => [['borderInlineWidth', rawValue], ['borderInlineStartWidth', null], ['borderLeftWidth', null], ['borderInlineEndWidth', null], ['borderRightWidth', null]],
571
553
  borderInlineStyle: rawValue => [['borderInlineStyle', rawValue], ['borderInlineStartStyle', null], ['borderLeftStyle', null], ['borderInlineEndStyle', null], ['borderRightStyle', null]],
572
554
  borderInlineColor: rawValue => [['borderInlineColor', rawValue], ['borderInlineStartColor', null], ['borderLeftColor', null], ['borderInlineEndColor', null], ['borderRightColor', null]],
@@ -1308,7 +1290,7 @@ var _normalizeValue = _interopRequireDefault$a(normalizeValue$1);
1308
1290
  function _interopRequireDefault$a(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1309
1291
  function transformValue(key, rawValue) {
1310
1292
  const value = typeof rawValue === 'number' ? String(Math.round(rawValue * 10000) / 10000) + getNumberSuffix(key) : rawValue;
1311
- if (key === 'content' && typeof value === 'string') {
1293
+ if ((key === 'content' || key === 'hyphenateCharacter' || key === 'hyphenate-character') && typeof value === 'string') {
1312
1294
  const val = value.trim();
1313
1295
  if (val.match(/^attr\([a-zA-Z0-9-]+\)$/)) {
1314
1296
  return val;
@@ -1330,7 +1312,7 @@ function getNumberSuffix(key) {
1330
1312
  return suffix;
1331
1313
  }
1332
1314
  }
1333
- const unitlessNumberProperties = new Set(['animationIterationCount', 'aspectRatio', 'borderImageOutset', 'borderImageSlice', 'borderImageWidth', 'columnCount', 'flex', 'flexGrow', 'flexPositive', 'flexShrink', 'flexOrder', 'gridRow', 'gridColumn', 'fontWeight', 'lineClamp', 'lineHeight', 'opacity', 'order', 'orphans', 'tabSize', 'widows', 'zIndex', 'fillOpacity', 'floodOpacity', 'stopOpacity', 'strokeDasharray', 'strokeDashoffset', 'strokeMiterlimit', 'strokeOpacity', 'strokeWidth', 'scale']);
1315
+ const unitlessNumberProperties = new Set(['WebkitLineClamp', 'animationIterationCount', 'aspectRatio', 'borderImageOutset', 'borderImageSlice', 'borderImageWidth', 'counterSet', 'columnCount', 'flex', 'flexGrow', 'flexPositive', 'flexShrink', 'flexOrder', 'gridRow', 'gridColumn', 'fontWeight', 'hyphenateLimitChars', 'lineClamp', 'lineHeight', 'maskBorderOutset', 'maskBorderSlice', 'maskBorderWidth', 'opacity', 'order', 'orphans', 'tabSize', 'widows', 'zIndex', 'fillOpacity', 'floodOpacity', 'rotate', 'scale', 'stopOpacity', 'strokeDasharray', 'strokeDashoffset', 'strokeMiterlimit', 'strokeOpacity', 'strokeWidth', 'scale', 'mathDepth']);
1334
1316
  const numberPropertySuffixes = {
1335
1317
  animationDelay: 'ms',
1336
1318
  animationDuration: 'ms',
@@ -1988,7 +1970,6 @@ longHandLogical.add('inset-inline-end');
1988
1970
  longHandPhysical.add('right');
1989
1971
  longHandLogical.add('clear');
1990
1972
  longHandLogical.add('float');
1991
- longHandLogical.add('overlay');
1992
1973
  longHandLogical.add('position');
1993
1974
  longHandLogical.add('z-index');
1994
1975
  longHandLogical.add('ruby-align');
@@ -2018,14 +1999,8 @@ longHandPhysical.add('scroll-padding-left');
2018
1999
  longHandLogical.add('scroll-padding-inline-end');
2019
2000
  longHandPhysical.add('scroll-padding-right');
2020
2001
  longHandLogical.add('scroll-snap-align');
2021
- longHandLogical.add('scroll-snap-coordinate');
2022
- longHandLogical.add('scroll-snap-destination');
2023
- longHandLogical.add('scroll-snap-points-x');
2024
- longHandLogical.add('scroll-snap-points-y');
2025
2002
  longHandLogical.add('scroll-snap-stop');
2026
2003
  shorthandsOfLonghands.add('scroll-snap-type');
2027
- longHandLogical.add('scroll-snap-type-x');
2028
- longHandLogical.add('scroll-snap-type-y');
2029
2004
  longHandLogical.add('scrollbar-color');
2030
2005
  longHandLogical.add('scrollbar-width');
2031
2006
  longHandLogical.add('shape-image-threshold');
@@ -2070,7 +2045,6 @@ longHandLogical.add('text-transform');
2070
2045
  longHandLogical.add('text-wrap');
2071
2046
  longHandLogical.add('white-space');
2072
2047
  longHandLogical.add('white-space-collapse');
2073
- longHandLogical.add('white-space-trim');
2074
2048
  longHandLogical.add('word-break');
2075
2049
  longHandLogical.add('word-spacing');
2076
2050
  longHandLogical.add('word-wrap');
@@ -2085,7 +2059,6 @@ longHandLogical.add('transform-origin');
2085
2059
  longHandLogical.add('transform-style');
2086
2060
  longHandLogical.add('translate');
2087
2061
  shorthandsOfLonghands.add('transition');
2088
- longHandLogical.add('transition-behavior');
2089
2062
  longHandLogical.add('transition-delay');
2090
2063
  longHandLogical.add('transition-duration');
2091
2064
  longHandLogical.add('transition-property');
@@ -3165,6 +3138,9 @@ function isStatement(path, props) {
3165
3138
  function isStringLiteral(path, props) {
3166
3139
  return path.isStringLiteral(props);
3167
3140
  }
3141
+ function isTSAsExpression(path, props) {
3142
+ return path.isTSAsExpression(props);
3143
+ }
3168
3144
  function isTaggedTemplateExpression(path, props) {
3169
3145
  return path.isTaggedTemplateExpression(props);
3170
3146
  }
@@ -3320,6 +3296,14 @@ function _evaluate(path, state) {
3320
3296
  return state.functions.identifiers[name];
3321
3297
  }
3322
3298
  }
3299
+ if (isTSAsExpression(path)) {
3300
+ const expr = path.get('expression');
3301
+ return evaluateCached(expr, state);
3302
+ }
3303
+ if (path.node.type === 'TSSatisfiesExpression') {
3304
+ const expr = path.get('expression');
3305
+ return evaluateCached(expr, state);
3306
+ }
3323
3307
  if (isSequenceExpression(path)) {
3324
3308
  const exprs = path.get('expressions');
3325
3309
  return evaluateCached(exprs[exprs.length - 1], state);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stylexjs/babel-plugin",
3
- "version": "0.2.0-beta.25",
3
+ "version": "0.2.0-beta.26",
4
4
  "description": "StyleX babel plugin.",
5
5
  "main": "lib/index.js",
6
6
  "repository": "https://github.com/facebook/stylex",
@@ -12,7 +12,7 @@
12
12
  "test": "jest"
13
13
  },
14
14
  "dependencies": {
15
- "@stylexjs/shared": "0.2.0-beta.25"
15
+ "@stylexjs/shared": "0.2.0-beta.26"
16
16
  },
17
17
  "peerDependencies": {
18
18
  "@babel/core": "^7.19.6",