@stylexjs/babel-plugin 0.17.4 → 0.18.0

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.
@@ -41,6 +41,7 @@ export type StyleXOptions = Readonly<{
41
41
  debug: null | undefined | boolean;
42
42
  definedStylexCSSVariables?: { [key: string]: unknown };
43
43
  dev: boolean;
44
+ propertyValidationMode?: 'throw' | 'warn' | 'silent';
44
45
  enableDebugClassNames?: null | undefined | boolean;
45
46
  enableDebugDataProp?: null | undefined | boolean;
46
47
  enableDevClassNames?: null | undefined | boolean;
@@ -47,7 +47,9 @@ export type StyleXOptions = $ReadOnly<{
47
47
  classNamePrefix: string,
48
48
  debug: ?boolean,
49
49
  definedStylexCSSVariables?: { [key: string]: mixed },
50
+ env?: $ReadOnly<{ [string]: any }>,
50
51
  dev: boolean,
52
+ propertyValidationMode?: 'throw' | 'warn' | 'silent',
51
53
  enableDebugClassNames?: ?boolean,
52
54
  enableDebugDataProp?: ?boolean,
53
55
  enableDevClassNames?: ?boolean,
@@ -35,8 +35,6 @@ export declare const ILLEGAL_PROP_ARRAY_VALUE: 'A style array value can only con
35
35
  export declare type ILLEGAL_PROP_ARRAY_VALUE = typeof ILLEGAL_PROP_ARRAY_VALUE;
36
36
  export declare const ILLEGAL_NAMESPACE_VALUE: 'A StyleX namespace must be an object.';
37
37
  export declare type ILLEGAL_NAMESPACE_VALUE = typeof ILLEGAL_NAMESPACE_VALUE;
38
- export declare const INVALID_CONST_KEY: 'Keys in defineConsts() cannot start with "--".';
39
- export declare type INVALID_CONST_KEY = typeof INVALID_CONST_KEY;
40
38
  export declare const INVALID_PSEUDO: 'Invalid pseudo selector, not on the whitelist.';
41
39
  export declare type INVALID_PSEUDO = typeof INVALID_PSEUDO;
42
40
  export declare const INVALID_PSEUDO_OR_AT_RULE: 'Invalid pseudo or at-rule.';
@@ -26,7 +26,6 @@ declare export const ILLEGAL_NESTED_PSEUDO: "Pseudo objects can't be nested more
26
26
  declare export const ILLEGAL_PROP_VALUE: 'A style value can only contain an array, string or number.';
27
27
  declare export const ILLEGAL_PROP_ARRAY_VALUE: 'A style array value can only contain strings or numbers.';
28
28
  declare export const ILLEGAL_NAMESPACE_VALUE: 'A StyleX namespace must be an object.';
29
- declare export const INVALID_CONST_KEY: 'Keys in defineConsts() cannot start with "--".';
30
29
  declare export const INVALID_PSEUDO: 'Invalid pseudo selector, not on the whitelist.';
31
30
  declare export const INVALID_PSEUDO_OR_AT_RULE: 'Invalid pseudo or at-rule.';
32
31
  declare export const INVALID_MEDIA_QUERY_SYNTAX: 'Invalid media query syntax.';
@@ -23,6 +23,7 @@ import type { TStyleValue } from '../common-types';
23
23
  * - [x] border-inline-start
24
24
  * - [x] border-left
25
25
  * - [x] border-radius
26
+ * - [x] corner-shape
26
27
  * - [x] border-right
27
28
  * - [x] border-style
28
29
  * - [x] border-top
@@ -74,6 +75,7 @@ import type { TStyleValue } from '../common-types';
74
75
  * - [x] border-inline-start
75
76
  * - [x] border-left
76
77
  * - [x] border-radius
78
+ * - [x] corner-shape
77
79
  * - [x] border-right
78
80
  * - [x] border-style
79
81
  * - [x] border-top
@@ -24,6 +24,7 @@ import type { TStyleValue } from '../common-types';
24
24
  * - [x] border-inline-start
25
25
  * - [x] border-left
26
26
  * - [x] border-radius
27
+ * - [x] corner-shape
27
28
  * - [x] border-right
28
29
  * - [x] border-style
29
30
  * - [x] border-top
@@ -13,6 +13,9 @@ export declare function getExpandedKeys(
13
13
  ): ReadonlyArray<string>;
14
14
  declare function flatMapExpandedShorthands(
15
15
  objEntry: Readonly<[string, TStyleValue]>,
16
- options: Readonly<{ styleResolution: StyleXOptions['styleResolution'] }>,
16
+ options: Readonly<{
17
+ styleResolution: StyleXOptions['styleResolution'];
18
+ propertyValidationMode?: StyleXOptions['propertyValidationMode'];
19
+ }>,
17
20
  ): ReadonlyArray<[string, TStyleValue]>;
18
21
  export default flatMapExpandedShorthands;
@@ -17,6 +17,7 @@ declare export default function flatMapExpandedShorthands(
17
17
  objEntry: $ReadOnly<[string, TStyleValue]>,
18
18
  options: $ReadOnly<{
19
19
  styleResolution: StyleXOptions['styleResolution'],
20
+ propertyValidationMode?: StyleXOptions['propertyValidationMode'],
20
21
  ...
21
22
  }>,
22
23
  ): $ReadOnlyArray<[string, TStyleValue]>;
@@ -27,6 +27,7 @@ export declare type LOGICAL_FLOAT_END_VAR = typeof LOGICAL_FLOAT_END_VAR;
27
27
  * - [x] border-inline-start
28
28
  * - [ ] border-left
29
29
  * - [x] border-radius
30
+ * - [ ] corner-shape
30
31
  * - [ ] border-right
31
32
  * - [x] border-style
32
33
  * - [ ] border-top
@@ -74,6 +75,7 @@ export declare type LOGICAL_FLOAT_END_VAR = typeof LOGICAL_FLOAT_END_VAR;
74
75
  * - [x] border-inline-start
75
76
  * - [ ] border-left
76
77
  * - [x] border-radius
78
+ * - [ ] corner-shape
77
79
  * - [ ] border-right
78
80
  * - [x] border-style
79
81
  * - [ ] border-top
@@ -50,6 +50,7 @@ declare export const LOGICAL_FLOAT_END_VAR: '--stylex-logical-end';
50
50
  * - [x] border-inline-start
51
51
  * - [ ] border-left
52
52
  * - [x] border-radius
53
+ * - [ ] corner-shape
53
54
  * - [ ] border-right
54
55
  * - [x] border-style
55
56
  * - [ ] border-top
@@ -7,6 +7,7 @@
7
7
  *
8
8
  */
9
9
 
10
+ /* eslint-disable no-unused-vars, no-redeclare */
10
11
  type NestedWithNumbers =
11
12
  | number
12
13
  | string
@@ -14,6 +14,6 @@
14
14
 
15
15
  declare function normalizeZeroDimensions(
16
16
  ast: PostCSSValueAST,
17
- _: unknown,
17
+ key: unknown,
18
18
  ): PostCSSValueAST;
19
19
  export default normalizeZeroDimensions;
@@ -14,5 +14,5 @@
14
14
 
15
15
  declare export default function normalizeZeroDimensions(
16
16
  ast: PostCSSValueAST,
17
- _: mixed,
17
+ key: mixed,
18
18
  ): PostCSSValueAST;
@@ -8,6 +8,7 @@
8
8
  */
9
9
 
10
10
  import type { StyleXOptions } from '../common-types';
11
+ type WhenSelector = `:${string}` | `[${string}`;
11
12
  /**
12
13
  * Creates selector that observes if the given pseudo-class is
13
14
  * active on an ancestor with the "defaultMarker"
@@ -17,7 +18,7 @@ import type { StyleXOptions } from '../common-types';
17
18
  * @returns A :where() clause for the ancestor observer
18
19
  */
19
20
  export declare function ancestor(
20
- pseudo: `:${string}`,
21
+ pseudo: WhenSelector,
21
22
  options?: string | StyleXOptions,
22
23
  ): string;
23
24
  /**
@@ -28,7 +29,7 @@ export declare function ancestor(
28
29
  * @returns A :has() clause for the descendant observer
29
30
  */
30
31
  export declare function descendant(
31
- pseudo: `:${string}`,
32
+ pseudo: WhenSelector,
32
33
  options?: string | StyleXOptions,
33
34
  ): string;
34
35
  /**
@@ -39,7 +40,7 @@ export declare function descendant(
39
40
  * @returns A :where() clause for the previous sibling observer
40
41
  */
41
42
  export declare function siblingBefore(
42
- pseudo: `:${string}`,
43
+ pseudo: WhenSelector,
43
44
  options?: string | StyleXOptions,
44
45
  ): string;
45
46
  /**
@@ -50,7 +51,7 @@ export declare function siblingBefore(
50
51
  * @returns A :has() clause for the next sibling observer
51
52
  */
52
53
  export declare function siblingAfter(
53
- pseudo: `:${string}`,
54
+ pseudo: WhenSelector,
54
55
  options?: string | StyleXOptions,
55
56
  ): string;
56
57
  /**
@@ -61,6 +62,6 @@ export declare function siblingAfter(
61
62
  * @returns A :where() clause for the any sibling observer
62
63
  */
63
64
  export declare function anySibling(
64
- pseudo: `:${string}`,
65
+ pseudo: WhenSelector,
65
66
  options?: string | StyleXOptions,
66
67
  ): string;
@@ -9,6 +9,8 @@
9
9
 
10
10
  import type { StyleXOptions } from '../common-types';
11
11
 
12
+ type WhenSelector = StringPrefix<':'> | StringPrefix<'['>;
13
+
12
14
  /**
13
15
  * Creates selector that observes if the given pseudo-class is
14
16
  * active on an ancestor with the "defaultMarker"
@@ -18,7 +20,7 @@ import type { StyleXOptions } from '../common-types';
18
20
  * @returns A :where() clause for the ancestor observer
19
21
  */
20
22
  declare export function ancestor(
21
- pseudo: StringPrefix<':'>,
23
+ pseudo: WhenSelector,
22
24
  options?: string | StyleXOptions,
23
25
  ): string;
24
26
 
@@ -30,7 +32,7 @@ declare export function ancestor(
30
32
  * @returns A :has() clause for the descendant observer
31
33
  */
32
34
  declare export function descendant(
33
- pseudo: StringPrefix<':'>,
35
+ pseudo: WhenSelector,
34
36
  options?: string | StyleXOptions,
35
37
  ): string;
36
38
 
@@ -42,7 +44,7 @@ declare export function descendant(
42
44
  * @returns A :where() clause for the previous sibling observer
43
45
  */
44
46
  declare export function siblingBefore(
45
- pseudo: StringPrefix<':'>,
47
+ pseudo: WhenSelector,
46
48
  options?: string | StyleXOptions,
47
49
  ): string;
48
50
 
@@ -54,7 +56,7 @@ declare export function siblingBefore(
54
56
  * @returns A :has() clause for the next sibling observer
55
57
  */
56
58
  declare export function siblingAfter(
57
- pseudo: StringPrefix<':'>,
59
+ pseudo: WhenSelector,
58
60
  options?: string | StyleXOptions,
59
61
  ): string;
60
62
 
@@ -66,6 +68,6 @@ declare export function siblingAfter(
66
68
  * @returns A :where() clause for the any sibling observer
67
69
  */
68
70
  declare export function anySibling(
69
- pseudo: StringPrefix<':'>,
71
+ pseudo: WhenSelector,
70
72
  options?: string | StyleXOptions,
71
73
  ): string;
@@ -13,6 +13,7 @@ import type {
13
13
  CompiledNamespaces,
14
14
  StyleXOptions as RuntimeOptions,
15
15
  } from '../shared';
16
+ import type { FunctionConfig } from './evaluate-path';
16
17
  import * as t from '@babel/types';
17
18
  export type ImportPathResolution =
18
19
  | false
@@ -50,6 +51,7 @@ export type StyleXOptions = Readonly<
50
51
  | null
51
52
  | undefined
52
53
  | Readonly<{ [$$Key$$: string]: string | ReadonlyArray<string> }>;
54
+ propertyValidationMode?: 'throw' | 'warn' | 'silent';
53
55
  enableDebugClassNames?: boolean;
54
56
  enableDebugDataProp?: boolean;
55
57
  enableDevClassNames?: boolean;
@@ -76,6 +78,7 @@ export type StyleXOptions = Readonly<
76
78
  | null
77
79
  | undefined
78
80
  | Readonly<{ [$$Key$$: string]: string | ReadonlyArray<string> }>;
81
+ propertyValidationMode?: 'throw' | 'warn' | 'silent';
79
82
  enableDebugClassNames?: boolean;
80
83
  enableDebugDataProp?: boolean;
81
84
  enableDevClassNames?: boolean;
@@ -102,6 +105,7 @@ type StyleXStateOptions = Readonly<
102
105
  Omit<
103
106
  StyleXOptions,
104
107
  | keyof {
108
+ env: Readonly<{ [$$Key$$: string]: any }>;
105
109
  runtimeInjection:
106
110
  | (null | undefined | string)
107
111
  | Readonly<{ from: string; as: null | undefined | string }>;
@@ -112,6 +116,7 @@ type StyleXStateOptions = Readonly<
112
116
  rewriteAliases: boolean;
113
117
  }
114
118
  > & {
119
+ env: Readonly<{ [$$Key$$: string]: any }>;
115
120
  runtimeInjection:
116
121
  | (null | undefined | string)
117
122
  | Readonly<{ from: string; as: null | undefined | string }>;
@@ -141,6 +146,7 @@ declare class StateManager {
141
146
  readonly stylexViewTransitionClassImport: Set<string>;
142
147
  readonly stylexDefaultMarkerImport: Set<string>;
143
148
  readonly stylexWhenImport: Set<string>;
149
+ readonly stylexEnvImport: Set<string>;
144
150
  injectImportInserted: null | undefined | t.Identifier;
145
151
  readonly styleMap: Map<string, CompiledNamespaces>;
146
152
  readonly styleVars: Map<string, NodePath>;
@@ -154,6 +160,7 @@ declare class StateManager {
154
160
  get importPathString(): string;
155
161
  get importSources(): ReadonlyArray<string>;
156
162
  importAs(source: string): null | string;
163
+ applyStylexEnv(identifiers: FunctionConfig['identifiers']): void;
157
164
  get canReferenceTheme(): boolean;
158
165
  get metadata(): { [key: string]: any };
159
166
  get runtimeInjection():
@@ -13,6 +13,8 @@ import type {
13
13
  CompiledNamespaces,
14
14
  StyleXOptions as RuntimeOptions,
15
15
  } from '../shared';
16
+ import type { FunctionConfig } from './evaluate-path';
17
+
16
18
  import * as t from '@babel/types';
17
19
  export type ImportPathResolution =
18
20
  | false
@@ -47,6 +49,7 @@ type ModuleResolution =
47
49
  export type StyleXOptions = $ReadOnly<{
48
50
  ...RuntimeOptions,
49
51
  aliases?: ?$ReadOnly<{ [string]: string | $ReadOnlyArray<string> }>,
52
+ propertyValidationMode?: 'throw' | 'warn' | 'silent',
50
53
  enableDebugClassNames?: boolean,
51
54
  enableDebugDataProp?: boolean,
52
55
  enableDevClassNames?: boolean,
@@ -69,6 +72,7 @@ export type StyleXOptions = $ReadOnly<{
69
72
 
70
73
  type StyleXStateOptions = $ReadOnly<{
71
74
  ...StyleXOptions,
75
+ env: $ReadOnly<{ [string]: any }>,
72
76
  runtimeInjection: ?string | $ReadOnly<{ from: string, as: ?string }>,
73
77
  aliases?: ?$ReadOnly<{ [string]: $ReadOnlyArray<string> }>,
74
78
  rewriteAliases: boolean,
@@ -95,6 +99,7 @@ declare export default class StateManager {
95
99
  +stylexViewTransitionClassImport: Set<string>;
96
100
  +stylexDefaultMarkerImport: Set<string>;
97
101
  +stylexWhenImport: Set<string>;
102
+ +stylexEnvImport: Set<string>;
98
103
  injectImportInserted: ?t.Identifier;
99
104
  // `stylex.create` calls
100
105
  +styleMap: Map<string, CompiledNamespaces>;
@@ -108,6 +113,7 @@ declare export default class StateManager {
108
113
  get importPathString(): string;
109
114
  get importSources(): $ReadOnlyArray<string>;
110
115
  importAs(source: string): null | string;
116
+ applyStylexEnv(identifiers: FunctionConfig['identifiers']): void;
111
117
  get canReferenceTheme(): boolean;
112
118
  get metadata(): { [key: string]: any };
113
119
  get runtimeInjection(): ?$ReadOnly<{ from: string, as?: ?string }>;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ import type { NodePath } from '@babel/traverse';
11
+ import * as t from '@babel/types';
12
+ import StateManager from '../utils/state-manager';
13
+ /**
14
+ * Transform inline-css call expressions like `css.color(value)`.
15
+ * These become arrow functions that return [compiledObj, inlineObj].
16
+ */
17
+ export declare function transformInlineCSSCall(
18
+ path: NodePath<t.CallExpression>,
19
+ state: StateManager,
20
+ ): void;
21
+ /**
22
+ * Transform inline-css member expressions like `css.display.flex`.
23
+ * These become compiled namespace objects: { [key]: className, $$css: true }
24
+ */
25
+ export declare function transformInlineCSSMemberExpression(
26
+ path: NodePath<t.MemberExpression>,
27
+ state: StateManager,
28
+ ): void;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ */
9
+
10
+ import type { NodePath } from '@babel/traverse';
11
+
12
+ import * as t from '@babel/types';
13
+ import StateManager from '../utils/state-manager';
14
+ /**
15
+ * Transform inline-css call expressions like `css.color(value)`.
16
+ * These become arrow functions that return [compiledObj, inlineObj].
17
+ */
18
+ declare export function transformInlineCSSCall(
19
+ path: NodePath<t.CallExpression>,
20
+ state: StateManager,
21
+ ): void;
22
+
23
+ /**
24
+ * Transform inline-css member expressions like `css.display.flex`.
25
+ * These become compiled namespace objects: { [key]: className, $$css: true }
26
+ */
27
+ declare export function transformInlineCSSMemberExpression(
28
+ path: NodePath<t.MemberExpression>,
29
+ state: StateManager,
30
+ ): void;
@@ -8,7 +8,6 @@
8
8
  */
9
9
 
10
10
  import type { NodePath } from '@babel/traverse';
11
-
12
11
  import * as t from '@babel/types';
13
12
  import StateManager from '../utils/state-manager';
14
13
  /// This function looks for `stylex.defineConsts` calls and transforms them.
@@ -8,7 +8,6 @@
8
8
  */
9
9
 
10
10
  import type { NodePath } from '@babel/traverse';
11
-
12
11
  import * as t from '@babel/types';
13
12
  import StateManager from '../utils/state-manager';
14
13
  declare export function skipStylexMergeChildren(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stylexjs/babel-plugin",
3
- "version": "0.17.4",
3
+ "version": "0.18.0",
4
4
  "description": "StyleX babel plugin.",
5
5
  "main": "lib/index.js",
6
6
  "browser": "lib/index.browser.js",
@@ -13,7 +13,7 @@
13
13
  "scripts": {
14
14
  "prebuild": "gen-types -i src/ -o lib/",
15
15
  "build": "rollup --config ./rollup.config.mjs",
16
- "build-haste": "HASTE=true rollup --config ./rollup.config.mjs",
16
+ "build-haste": "cross-env HASTE=true rollup --config ./rollup.config.mjs",
17
17
  "build-watch": "rollup --config ./rollup.config.mjs --watch",
18
18
  "test": "jest --coverage"
19
19
  },
@@ -23,8 +23,8 @@
23
23
  "@babel/traverse": "^7.26.8",
24
24
  "@babel/types": "^7.26.8",
25
25
  "@dual-bundle/import-meta-resolve": "^4.1.0",
26
- "@stylexjs/shared": "0.17.4",
27
- "@stylexjs/stylex": "0.17.4",
26
+ "@stylexjs/shared": "0.18.0",
27
+ "@stylexjs/stylex": "0.18.0",
28
28
  "postcss-value-parser": "^4.1.0"
29
29
  },
30
30
  "devDependencies": {
@@ -37,7 +37,7 @@
37
37
  "babel-plugin-syntax-hermes-parser": "^0.32.1",
38
38
  "path-browserify": "^1.0.1",
39
39
  "rollup": "^4.24.0",
40
- "scripts": "0.17.4"
40
+ "scripts": "0.18.0"
41
41
  },
42
42
  "files": [
43
43
  "flow_modules/*",