@stylexjs/babel-plugin 0.6.0 → 0.6.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 +88 -45
- package/lib/utils/evaluate-path.d.ts +1 -3
- package/lib/utils/evaluate-path.js.flow +2 -5
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -3091,12 +3091,12 @@ function getDefaultValue(value) {
|
|
|
3091
3091
|
throw new Error('Invalid value in stylex.defineVars');
|
|
3092
3092
|
}
|
|
3093
3093
|
|
|
3094
|
-
var types$
|
|
3094
|
+
var types$2 = {};
|
|
3095
3095
|
|
|
3096
|
-
Object.defineProperty(types$
|
|
3096
|
+
Object.defineProperty(types$2, "__esModule", {
|
|
3097
3097
|
value: true
|
|
3098
3098
|
});
|
|
3099
|
-
types$
|
|
3099
|
+
types$2.url = types$2.transformList = types$2.transformFunction = types$2.time = types$2.resolution = types$2.percentage = types$2.number = types$2.lengthPercentage = types$2.length = types$2.isCSSType = types$2.integer = types$2.image = types$2.color = types$2.angle = types$2.Url = types$2.TransformList = types$2.TransformFunction = types$2.Time = types$2.Resolution = types$2.Percentage = types$2.Num = types$2.LengthPercentage = types$2.Length = types$2.Integer = types$2.Image = types$2.Color = types$2.Angle = void 0;
|
|
3100
3100
|
class BaseCSSType {
|
|
3101
3101
|
constructor(value) {
|
|
3102
3102
|
this.value = value;
|
|
@@ -3105,7 +3105,7 @@ class BaseCSSType {
|
|
|
3105
3105
|
const isCSSType = value => {
|
|
3106
3106
|
return value instanceof BaseCSSType && value.value != null && typeof value.syntax === 'string';
|
|
3107
3107
|
};
|
|
3108
|
-
types$
|
|
3108
|
+
types$2.isCSSType = isCSSType;
|
|
3109
3109
|
class Angle extends BaseCSSType {
|
|
3110
3110
|
syntax = '<angle>';
|
|
3111
3111
|
static syntax = '<angle>';
|
|
@@ -3113,24 +3113,24 @@ class Angle extends BaseCSSType {
|
|
|
3113
3113
|
return new Angle(value);
|
|
3114
3114
|
}
|
|
3115
3115
|
}
|
|
3116
|
-
types$
|
|
3117
|
-
types$
|
|
3116
|
+
types$2.Angle = Angle;
|
|
3117
|
+
types$2.angle = Angle.create;
|
|
3118
3118
|
class Color extends BaseCSSType {
|
|
3119
3119
|
syntax = '<color>';
|
|
3120
3120
|
static create(value) {
|
|
3121
3121
|
return new Color(value);
|
|
3122
3122
|
}
|
|
3123
3123
|
}
|
|
3124
|
-
types$
|
|
3125
|
-
types$
|
|
3124
|
+
types$2.Color = Color;
|
|
3125
|
+
types$2.color = Color.create;
|
|
3126
3126
|
class Url extends BaseCSSType {
|
|
3127
3127
|
syntax = '<url>';
|
|
3128
3128
|
static create(value) {
|
|
3129
3129
|
return new Url(value);
|
|
3130
3130
|
}
|
|
3131
3131
|
}
|
|
3132
|
-
types$
|
|
3133
|
-
types$
|
|
3132
|
+
types$2.Url = Url;
|
|
3133
|
+
types$2.url = Url.create;
|
|
3134
3134
|
class Image extends Url {
|
|
3135
3135
|
syntax = '<image>';
|
|
3136
3136
|
constructor(value) {
|
|
@@ -3141,16 +3141,16 @@ class Image extends Url {
|
|
|
3141
3141
|
return new Image(value);
|
|
3142
3142
|
}
|
|
3143
3143
|
}
|
|
3144
|
-
types$
|
|
3145
|
-
types$
|
|
3144
|
+
types$2.Image = Image;
|
|
3145
|
+
types$2.image = Image.create;
|
|
3146
3146
|
class Integer extends BaseCSSType {
|
|
3147
3147
|
syntax = '<integer>';
|
|
3148
3148
|
static create(value) {
|
|
3149
3149
|
return new Integer(convertNumberToStringUsing(String)(value));
|
|
3150
3150
|
}
|
|
3151
3151
|
}
|
|
3152
|
-
types$
|
|
3153
|
-
types$
|
|
3152
|
+
types$2.Integer = Integer;
|
|
3153
|
+
types$2.integer = Integer.create;
|
|
3154
3154
|
class LengthPercentage extends BaseCSSType {
|
|
3155
3155
|
syntax = '<length-percentage>';
|
|
3156
3156
|
static createLength(value) {
|
|
@@ -3160,64 +3160,64 @@ class LengthPercentage extends BaseCSSType {
|
|
|
3160
3160
|
return new LengthPercentage(convertNumberToPercentage(value));
|
|
3161
3161
|
}
|
|
3162
3162
|
}
|
|
3163
|
-
types$
|
|
3164
|
-
types$
|
|
3163
|
+
types$2.LengthPercentage = LengthPercentage;
|
|
3164
|
+
types$2.lengthPercentage = LengthPercentage.createLength;
|
|
3165
3165
|
class Length extends LengthPercentage {
|
|
3166
3166
|
syntax = '<length>';
|
|
3167
3167
|
static create(value) {
|
|
3168
3168
|
return new Length(convertNumberToLength(value));
|
|
3169
3169
|
}
|
|
3170
3170
|
}
|
|
3171
|
-
types$
|
|
3172
|
-
types$
|
|
3171
|
+
types$2.Length = Length;
|
|
3172
|
+
types$2.length = Length.create;
|
|
3173
3173
|
class Percentage extends LengthPercentage {
|
|
3174
3174
|
syntax = '<percentage>';
|
|
3175
3175
|
static create(value) {
|
|
3176
3176
|
return new Percentage(convertNumberToPercentage(value));
|
|
3177
3177
|
}
|
|
3178
3178
|
}
|
|
3179
|
-
types$
|
|
3180
|
-
types$
|
|
3179
|
+
types$2.Percentage = Percentage;
|
|
3180
|
+
types$2.percentage = Percentage.create;
|
|
3181
3181
|
class Num extends BaseCSSType {
|
|
3182
3182
|
syntax = '<number>';
|
|
3183
3183
|
static create(value) {
|
|
3184
3184
|
return new Num(convertNumberToBareString(value));
|
|
3185
3185
|
}
|
|
3186
3186
|
}
|
|
3187
|
-
types$
|
|
3188
|
-
types$
|
|
3187
|
+
types$2.Num = Num;
|
|
3188
|
+
types$2.number = Num.create;
|
|
3189
3189
|
class Resolution extends BaseCSSType {
|
|
3190
3190
|
syntax = '<resolution>';
|
|
3191
3191
|
static create(value) {
|
|
3192
3192
|
return new Resolution(value);
|
|
3193
3193
|
}
|
|
3194
3194
|
}
|
|
3195
|
-
types$
|
|
3196
|
-
types$
|
|
3195
|
+
types$2.Resolution = Resolution;
|
|
3196
|
+
types$2.resolution = Resolution.create;
|
|
3197
3197
|
class Time extends BaseCSSType {
|
|
3198
3198
|
syntax = '<time>';
|
|
3199
3199
|
static create(value) {
|
|
3200
3200
|
return new Time(value);
|
|
3201
3201
|
}
|
|
3202
3202
|
}
|
|
3203
|
-
types$
|
|
3204
|
-
types$
|
|
3203
|
+
types$2.Time = Time;
|
|
3204
|
+
types$2.time = Time.create;
|
|
3205
3205
|
class TransformFunction extends BaseCSSType {
|
|
3206
3206
|
syntax = '<transform-function>';
|
|
3207
3207
|
static create(value) {
|
|
3208
3208
|
return new TransformFunction(value);
|
|
3209
3209
|
}
|
|
3210
3210
|
}
|
|
3211
|
-
types$
|
|
3212
|
-
types$
|
|
3211
|
+
types$2.TransformFunction = TransformFunction;
|
|
3212
|
+
types$2.transformFunction = TransformFunction.create;
|
|
3213
3213
|
class TransformList extends BaseCSSType {
|
|
3214
3214
|
syntax = '<transform-list>';
|
|
3215
3215
|
static create(value) {
|
|
3216
3216
|
return new TransformList(value);
|
|
3217
3217
|
}
|
|
3218
3218
|
}
|
|
3219
|
-
types$
|
|
3220
|
-
types$
|
|
3219
|
+
types$2.TransformList = TransformList;
|
|
3220
|
+
types$2.transformList = TransformList.create;
|
|
3221
3221
|
const convertNumberToStringUsing = (transformNumber, defaultStr) => value => {
|
|
3222
3222
|
if (typeof value === 'number') {
|
|
3223
3223
|
return transformNumber(value);
|
|
@@ -3247,7 +3247,7 @@ var _hash$3 = _interopRequireDefault$3(hash$1);
|
|
|
3247
3247
|
var _objectUtils$1 = objectUtils;
|
|
3248
3248
|
var _defaultOptions$2 = defaultOptions;
|
|
3249
3249
|
var _stylexVarsUtils$1 = stylexVarsUtils;
|
|
3250
|
-
var _types$2 = types$
|
|
3250
|
+
var _types$2 = types$2;
|
|
3251
3251
|
function _interopRequireDefault$3(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
3252
3252
|
function styleXDefineVars(variables, options) {
|
|
3253
3253
|
const {
|
|
@@ -3338,7 +3338,7 @@ Object.defineProperty(stylexCreateTheme$1, "__esModule", {
|
|
|
3338
3338
|
stylexCreateTheme$1.default = styleXCreateTheme;
|
|
3339
3339
|
var _hash$2 = _interopRequireDefault$2(hash$1);
|
|
3340
3340
|
var _stylexVarsUtils = stylexVarsUtils;
|
|
3341
|
-
var _types$1 = types$
|
|
3341
|
+
var _types$1 = types$2;
|
|
3342
3342
|
var _defaultOptions$1 = defaultOptions;
|
|
3343
3343
|
function _interopRequireDefault$2(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
3344
3344
|
function styleXCreateTheme(themeVars, variables, options) {
|
|
@@ -3484,7 +3484,7 @@ var messages_1;
|
|
|
3484
3484
|
Object.defineProperty(lib, "__esModule", {
|
|
3485
3485
|
value: true
|
|
3486
3486
|
});
|
|
3487
|
-
var utils_1 = lib.utils = lib.types = messages_1 = lib.messages = keyframes_1 = lib.keyframes = include_1 = lib.include = firstThatWorks_1 = lib.firstThatWorks = defineVars_1 = lib.defineVars = createTheme_1 = lib.createTheme = create_1 = lib.create = lib.PSEUDO_ELEMENT_PRIORITY = lib.PSEUDO_CLASS_PRIORITIES = IncludedStyles_1 = lib.IncludedStyles = lib.AT_RULE_PRIORITIES = void 0;
|
|
3487
|
+
var utils_1 = lib.utils = types$1 = lib.types = messages_1 = lib.messages = keyframes_1 = lib.keyframes = include_1 = lib.include = firstThatWorks_1 = lib.firstThatWorks = defineVars_1 = lib.defineVars = createTheme_1 = lib.createTheme = create_1 = lib.create = lib.PSEUDO_ELEMENT_PRIORITY = lib.PSEUDO_CLASS_PRIORITIES = IncludedStyles_1 = lib.IncludedStyles = lib.AT_RULE_PRIORITIES = void 0;
|
|
3488
3488
|
var _stylexCreate = _interopRequireDefault(stylexCreate$1);
|
|
3489
3489
|
var _stylexDefineVars = _interopRequireDefault(stylexDefineVars$1);
|
|
3490
3490
|
var _stylexCreateTheme = _interopRequireDefault(stylexCreateTheme$1);
|
|
@@ -3494,8 +3494,8 @@ var _stylexFirstThatWorks = _interopRequireDefault(stylexFirstThatWorks$1);
|
|
|
3494
3494
|
var _hash = _interopRequireDefault(hash$1);
|
|
3495
3495
|
var _fileBasedIdentifier = _interopRequireDefault(fileBasedIdentifier);
|
|
3496
3496
|
var m = _interopRequireWildcard(messages$4);
|
|
3497
|
-
var _types = _interopRequireWildcard(types$
|
|
3498
|
-
lib.types = _types;
|
|
3497
|
+
var _types = _interopRequireWildcard(types$2);
|
|
3498
|
+
var types$1 = lib.types = _types;
|
|
3499
3499
|
var _propertyPriorities = propertyPriorities;
|
|
3500
3500
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
3501
3501
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -4016,14 +4016,16 @@ function _evaluate(path, state) {
|
|
|
4016
4016
|
const val = object.node.value;
|
|
4017
4017
|
func = val[property.node.name];
|
|
4018
4018
|
}
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4019
|
+
if (func == null) {
|
|
4020
|
+
const parsedObj = evaluate(object, state.traversalState, state.functions);
|
|
4021
|
+
if (parsedObj.confident && isIdentifier(property)) {
|
|
4022
|
+
func = parsedObj.value[property.node.name];
|
|
4023
|
+
context = parsedObj.value;
|
|
4024
|
+
}
|
|
4025
|
+
if (parsedObj.confident && isStringLiteral(property)) {
|
|
4026
|
+
func = parsedObj.value[property.node.value];
|
|
4027
|
+
context = parsedObj.value;
|
|
4028
|
+
}
|
|
4027
4029
|
}
|
|
4028
4030
|
}
|
|
4029
4031
|
if (func) {
|
|
@@ -4430,6 +4432,9 @@ function transformStyleXDefineVars(callExpressionPath, state) {
|
|
|
4430
4432
|
fn: keyframes
|
|
4431
4433
|
};
|
|
4432
4434
|
});
|
|
4435
|
+
state.stylexTypesImport.forEach(name => {
|
|
4436
|
+
identifiers[name] = types$1;
|
|
4437
|
+
});
|
|
4433
4438
|
state.stylexImport.forEach(name => {
|
|
4434
4439
|
if (memberExpressions[name] === undefined) {
|
|
4435
4440
|
memberExpressions[name] = {};
|
|
@@ -4437,6 +4442,10 @@ function transformStyleXDefineVars(callExpressionPath, state) {
|
|
|
4437
4442
|
memberExpressions[name].keyframes = {
|
|
4438
4443
|
fn: keyframes
|
|
4439
4444
|
};
|
|
4445
|
+
identifiers[name] = {
|
|
4446
|
+
...(identifiers[name] ?? {}),
|
|
4447
|
+
types: types$1
|
|
4448
|
+
};
|
|
4440
4449
|
});
|
|
4441
4450
|
const {
|
|
4442
4451
|
confident,
|
|
@@ -4518,10 +4527,41 @@ function transformStyleXCreateTheme(callExpressionPath, state) {
|
|
|
4518
4527
|
if (!confident1) {
|
|
4519
4528
|
throw new Error(messages_1.NON_STATIC_VALUE);
|
|
4520
4529
|
}
|
|
4530
|
+
const injectedKeyframes = {};
|
|
4531
|
+
function keyframes(animation) {
|
|
4532
|
+
const [animationName, injectedStyle] = keyframes_1(animation, state.options);
|
|
4533
|
+
injectedKeyframes[animationName] = injectedStyle;
|
|
4534
|
+
return animationName;
|
|
4535
|
+
}
|
|
4536
|
+
const identifiers = {};
|
|
4537
|
+
const memberExpressions = {};
|
|
4538
|
+
state.stylexKeyframesImport.forEach(name => {
|
|
4539
|
+
identifiers[name] = {
|
|
4540
|
+
fn: keyframes
|
|
4541
|
+
};
|
|
4542
|
+
});
|
|
4543
|
+
state.stylexTypesImport.forEach(name => {
|
|
4544
|
+
identifiers[name] = types$1;
|
|
4545
|
+
});
|
|
4546
|
+
state.stylexImport.forEach(name => {
|
|
4547
|
+
if (memberExpressions[name] === undefined) {
|
|
4548
|
+
memberExpressions[name] = {};
|
|
4549
|
+
}
|
|
4550
|
+
memberExpressions[name].keyframes = {
|
|
4551
|
+
fn: keyframes
|
|
4552
|
+
};
|
|
4553
|
+
identifiers[name] = {
|
|
4554
|
+
...(identifiers[name] ?? {}),
|
|
4555
|
+
types: types$1
|
|
4556
|
+
};
|
|
4557
|
+
});
|
|
4521
4558
|
const {
|
|
4522
4559
|
confident: confident2,
|
|
4523
4560
|
value: overrides
|
|
4524
|
-
} = evaluate(secondArg, state
|
|
4561
|
+
} = evaluate(secondArg, state, {
|
|
4562
|
+
identifiers,
|
|
4563
|
+
memberExpressions
|
|
4564
|
+
});
|
|
4525
4565
|
if (!confident2) {
|
|
4526
4566
|
throw new Error(messages_1.NON_STATIC_VALUE);
|
|
4527
4567
|
}
|
|
@@ -4550,7 +4590,10 @@ function transformStyleXCreateTheme(callExpressionPath, state) {
|
|
|
4550
4590
|
};
|
|
4551
4591
|
}
|
|
4552
4592
|
callExpressionPath.replaceWith(convertObjectToAST(overridesObj));
|
|
4553
|
-
const listOfStyles = Object.entries(
|
|
4593
|
+
const listOfStyles = Object.entries({
|
|
4594
|
+
...injectedKeyframes,
|
|
4595
|
+
...injectedStyles
|
|
4596
|
+
}).map(_ref => {
|
|
4554
4597
|
let [key, {
|
|
4555
4598
|
priority,
|
|
4556
4599
|
...rest
|
|
@@ -10,9 +10,7 @@
|
|
|
10
10
|
import type { NodePath } from '@babel/traverse';
|
|
11
11
|
import StateManager from './state-manager';
|
|
12
12
|
export type FunctionConfig = {
|
|
13
|
-
identifiers: {
|
|
14
|
-
[fnName: string]: { fn: (...args: any[]) => any; takesPath?: boolean };
|
|
15
|
-
};
|
|
13
|
+
identifiers: { [fnName: string]: any };
|
|
16
14
|
memberExpressions: {
|
|
17
15
|
[key: string]: {
|
|
18
16
|
[memberName: string]: {
|
|
@@ -11,15 +11,12 @@ import type { NodePath } from '../../flow_modules/@babel/traverse';
|
|
|
11
11
|
import StateManager from './state-manager';
|
|
12
12
|
export type FunctionConfig = {
|
|
13
13
|
identifiers: {
|
|
14
|
-
[fnName: string]:
|
|
15
|
-
fn: (...args: any[]) => any,
|
|
16
|
-
takesPath?: boolean,
|
|
17
|
-
},
|
|
14
|
+
[fnName: string]: $FlowFixMe,
|
|
18
15
|
},
|
|
19
16
|
memberExpressions: {
|
|
20
17
|
[key: string]: {
|
|
21
18
|
[memberName: string]: {
|
|
22
|
-
fn: (...args:
|
|
19
|
+
fn: (...args: $FlowFixMe[]) => $FlowFixMe,
|
|
23
20
|
takesPath?: boolean,
|
|
24
21
|
},
|
|
25
22
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stylexjs/babel-plugin",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "StyleX babel plugin.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"repository": "https://github.com/facebook/stylex",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@babel/helper-module-imports": "^7.22.15",
|
|
17
|
-
"@stylexjs/shared": "0.6.
|
|
18
|
-
"@stylexjs/stylex": "0.6.
|
|
17
|
+
"@stylexjs/shared": "0.6.1",
|
|
18
|
+
"@stylexjs/stylex": "0.6.1",
|
|
19
19
|
"@babel/core": "^7.23.6",
|
|
20
20
|
"@babel/traverse": "^7.23.6",
|
|
21
21
|
"@babel/types": "^7.23.6"
|