@stylexjs/babel-plugin 0.16.3 → 0.17.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.
- package/lib/index.js +835 -1761
- package/lib/index.js.flow +1 -0
- package/lib/shared/index.d.ts +1 -1
- package/lib/shared/index.js.flow +1 -1
- package/lib/shared/preprocess-rules/legacy-expand-shorthands.d.ts +4 -0
- package/lib/shared/preprocess-rules/legacy-expand-shorthands.js.flow +5 -0
- package/lib/shared/types/index.js.flow +1 -1
- package/lib/shared/utils/object-utils.js.flow +1 -1
- package/lib/shared/when/when.d.ts +5 -5
- package/lib/shared/when/when.js.flow +5 -5
- package/lib/utils/evaluate-path.d.ts +1 -0
- package/lib/utils/evaluate-path.js.flow +1 -0
- package/lib/utils/js-to-ast.d.ts +0 -4
- package/lib/utils/js-to-ast.js.flow +0 -6
- package/lib/utils/state-manager.d.ts +1 -0
- package/lib/utils/state-manager.js.flow +1 -0
- package/lib/visitors/stylex-define-marker.d.ts +22 -0
- package/lib/visitors/stylex-define-marker.js.flow +22 -0
- package/package.json +4 -3
package/lib/index.js.flow
CHANGED
package/lib/shared/index.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
PSEUDO_CLASS_PRIORITIES as _PSEUDO_CLASS_PRIORITIES,
|
|
35
35
|
AT_RULE_PRIORITIES as _AT_RULE_PRIORITIES,
|
|
36
36
|
PSEUDO_ELEMENT_PRIORITY as _PSEUDO_ELEMENT_PRIORITY,
|
|
37
|
-
} from '
|
|
37
|
+
} from '@stylexjs/shared';
|
|
38
38
|
export * as types from './types';
|
|
39
39
|
export * as when from './when/when';
|
|
40
40
|
export declare const create: typeof styleXCreateSet;
|
package/lib/shared/index.js.flow
CHANGED
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
PSEUDO_CLASS_PRIORITIES as _PSEUDO_CLASS_PRIORITIES,
|
|
42
42
|
AT_RULE_PRIORITIES as _AT_RULE_PRIORITIES,
|
|
43
43
|
PSEUDO_ELEMENT_PRIORITY as _PSEUDO_ELEMENT_PRIORITY,
|
|
44
|
-
} from '
|
|
44
|
+
} from '@stylexjs/shared';
|
|
45
45
|
|
|
46
46
|
export * as types from './types';
|
|
47
47
|
export * as when from './when/when';
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import type { TStyleValue } from '../common-types';
|
|
11
|
+
export declare const LOGICAL_FLOAT_START_VAR: '--stylex-logical-start';
|
|
12
|
+
export declare const LOGICAL_FLOAT_END_VAR: '--stylex-logical-end';
|
|
11
13
|
/**
|
|
12
14
|
* Shorthand properties:
|
|
13
15
|
* - [x] all - Should be banned
|
|
@@ -150,6 +152,8 @@ declare const aliases: {
|
|
|
150
152
|
paddingInline: any;
|
|
151
153
|
scrollMarginBlockStart: (value: TStyleValue) => TReturn;
|
|
152
154
|
scrollMarginBlockEnd: (value: TStyleValue) => TReturn;
|
|
155
|
+
float: (value: TStyleValue) => TReturn;
|
|
156
|
+
clear: (value: TStyleValue) => TReturn;
|
|
153
157
|
};
|
|
154
158
|
declare const expansions: Omit<shorthands, keyof (aliases | {})> &
|
|
155
159
|
Omit<aliases, keyof ({})> & {};
|
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
|
|
10
10
|
import type { TStyleValue } from '../common-types';
|
|
11
11
|
|
|
12
|
+
declare export const LOGICAL_FLOAT_START_VAR: '--stylex-logical-start';
|
|
13
|
+
declare export const LOGICAL_FLOAT_END_VAR: '--stylex-logical-end';
|
|
14
|
+
|
|
12
15
|
// TODO: to be added later.
|
|
13
16
|
// const aliases = {
|
|
14
17
|
// marginInlineStart: (rawValue) => [['marginStart', rawValue]],
|
|
@@ -129,6 +132,8 @@ declare const aliases: {
|
|
|
129
132
|
paddingInline: $FlowFixMe,
|
|
130
133
|
scrollMarginBlockStart: (value: TStyleValue) => TReturn,
|
|
131
134
|
scrollMarginBlockEnd: (value: TStyleValue) => TReturn,
|
|
135
|
+
float: (value: TStyleValue) => TReturn,
|
|
136
|
+
clear: (value: TStyleValue) => TReturn,
|
|
132
137
|
};
|
|
133
138
|
|
|
134
139
|
declare const expansions: { ...shorthands, ...aliases };
|
|
@@ -65,7 +65,7 @@ export interface CSSType<+_T: string | number = string | number> {
|
|
|
65
65
|
|
|
66
66
|
declare export const isCSSType: (
|
|
67
67
|
value: mixed,
|
|
68
|
-
) => value is CSSType<string | number>;
|
|
68
|
+
) => implies value is CSSType<string | number>;
|
|
69
69
|
|
|
70
70
|
type AngleValue = string;
|
|
71
71
|
declare export class Angle<+T: AngleValue>
|
|
@@ -14,7 +14,7 @@ import type { CompiledStyles } from '../common-types';
|
|
|
14
14
|
// eslint-disable-next-line no-unused-vars
|
|
15
15
|
type AnyObject = { +[string]: mixed };
|
|
16
16
|
|
|
17
|
-
declare export function isPlainObject(obj: mixed): obj is AnyObject;
|
|
17
|
+
declare export function isPlainObject(obj: mixed): implies obj is AnyObject;
|
|
18
18
|
|
|
19
19
|
declare export function flattenObject(obj: CompiledStyles): {
|
|
20
20
|
+[string]: null | string,
|
|
@@ -17,7 +17,7 @@ import type { StyleXOptions } from '../common-types';
|
|
|
17
17
|
* @returns A :where() clause for the ancestor observer
|
|
18
18
|
*/
|
|
19
19
|
export declare function ancestor(
|
|
20
|
-
pseudo: string
|
|
20
|
+
pseudo: `:${string}`,
|
|
21
21
|
options: string | StyleXOptions,
|
|
22
22
|
): string;
|
|
23
23
|
/**
|
|
@@ -28,7 +28,7 @@ export declare function ancestor(
|
|
|
28
28
|
* @returns A :has() clause for the descendant observer
|
|
29
29
|
*/
|
|
30
30
|
export declare function descendant(
|
|
31
|
-
pseudo: string
|
|
31
|
+
pseudo: `:${string}`,
|
|
32
32
|
options: string | StyleXOptions,
|
|
33
33
|
): string;
|
|
34
34
|
/**
|
|
@@ -39,7 +39,7 @@ export declare function descendant(
|
|
|
39
39
|
* @returns A :where() clause for the previous sibling observer
|
|
40
40
|
*/
|
|
41
41
|
export declare function siblingBefore(
|
|
42
|
-
pseudo: string
|
|
42
|
+
pseudo: `:${string}`,
|
|
43
43
|
options: string | StyleXOptions,
|
|
44
44
|
): string;
|
|
45
45
|
/**
|
|
@@ -50,7 +50,7 @@ export declare function siblingBefore(
|
|
|
50
50
|
* @returns A :has() clause for the next sibling observer
|
|
51
51
|
*/
|
|
52
52
|
export declare function siblingAfter(
|
|
53
|
-
pseudo: string
|
|
53
|
+
pseudo: `:${string}`,
|
|
54
54
|
options: string | StyleXOptions,
|
|
55
55
|
): string;
|
|
56
56
|
/**
|
|
@@ -61,6 +61,6 @@ export declare function siblingAfter(
|
|
|
61
61
|
* @returns A :where() clause for the any sibling observer
|
|
62
62
|
*/
|
|
63
63
|
export declare function anySibling(
|
|
64
|
-
pseudo: string
|
|
64
|
+
pseudo: `:${string}`,
|
|
65
65
|
options: string | StyleXOptions,
|
|
66
66
|
): string;
|
|
@@ -18,7 +18,7 @@ import type { StyleXOptions } from '../common-types';
|
|
|
18
18
|
* @returns A :where() clause for the ancestor observer
|
|
19
19
|
*/
|
|
20
20
|
declare export function ancestor(
|
|
21
|
-
pseudo:
|
|
21
|
+
pseudo: StringPrefix<':'>,
|
|
22
22
|
options: string | StyleXOptions,
|
|
23
23
|
): string;
|
|
24
24
|
|
|
@@ -30,7 +30,7 @@ declare export function ancestor(
|
|
|
30
30
|
* @returns A :has() clause for the descendant observer
|
|
31
31
|
*/
|
|
32
32
|
declare export function descendant(
|
|
33
|
-
pseudo:
|
|
33
|
+
pseudo: StringPrefix<':'>,
|
|
34
34
|
options: string | StyleXOptions,
|
|
35
35
|
): string;
|
|
36
36
|
|
|
@@ -42,7 +42,7 @@ declare export function descendant(
|
|
|
42
42
|
* @returns A :where() clause for the previous sibling observer
|
|
43
43
|
*/
|
|
44
44
|
declare export function siblingBefore(
|
|
45
|
-
pseudo:
|
|
45
|
+
pseudo: StringPrefix<':'>,
|
|
46
46
|
options: string | StyleXOptions,
|
|
47
47
|
): string;
|
|
48
48
|
|
|
@@ -54,7 +54,7 @@ declare export function siblingBefore(
|
|
|
54
54
|
* @returns A :has() clause for the next sibling observer
|
|
55
55
|
*/
|
|
56
56
|
declare export function siblingAfter(
|
|
57
|
-
pseudo:
|
|
57
|
+
pseudo: StringPrefix<':'>,
|
|
58
58
|
options: string | StyleXOptions,
|
|
59
59
|
): string;
|
|
60
60
|
|
|
@@ -66,6 +66,6 @@ declare export function siblingAfter(
|
|
|
66
66
|
* @returns A :where() clause for the any sibling observer
|
|
67
67
|
*/
|
|
68
68
|
declare export function anySibling(
|
|
69
|
-
pseudo:
|
|
69
|
+
pseudo: StringPrefix<':'>,
|
|
70
70
|
options: string | StyleXOptions,
|
|
71
71
|
): string;
|
package/lib/utils/js-to-ast.d.ts
CHANGED
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type { FlatCompiledStyles } from '../shared/common-types';
|
|
11
10
|
import * as t from '@babel/types';
|
|
12
11
|
type NestedStringObject = Readonly<{
|
|
13
12
|
[key: string]: string | number | null | boolean | NestedStringObject;
|
|
@@ -15,6 +14,3 @@ type NestedStringObject = Readonly<{
|
|
|
15
14
|
export declare function convertObjectToAST(
|
|
16
15
|
obj: NestedStringObject,
|
|
17
16
|
): t.ObjectExpression;
|
|
18
|
-
export declare function removeObjectsWithSpreads(obj: {
|
|
19
|
-
readonly [$$Key$$: string]: FlatCompiledStyles;
|
|
20
|
-
}): { readonly [$$Key$$: string]: FlatCompiledStyles };
|
|
@@ -7,8 +7,6 @@
|
|
|
7
7
|
* @flow strict
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type { FlatCompiledStyles } from '../shared/common-types';
|
|
11
|
-
|
|
12
10
|
import * as t from '@babel/types';
|
|
13
11
|
|
|
14
12
|
type NestedStringObject = $ReadOnly<{
|
|
@@ -18,7 +16,3 @@ type NestedStringObject = $ReadOnly<{
|
|
|
18
16
|
declare export function convertObjectToAST(
|
|
19
17
|
obj: NestedStringObject,
|
|
20
18
|
): t.ObjectExpression;
|
|
21
|
-
|
|
22
|
-
declare export function removeObjectsWithSpreads(obj: {
|
|
23
|
-
+[string]: FlatCompiledStyles,
|
|
24
|
-
}): { +[string]: FlatCompiledStyles };
|
|
@@ -132,6 +132,7 @@ declare class StateManager {
|
|
|
132
132
|
readonly stylexKeyframesImport: Set<string>;
|
|
133
133
|
readonly stylexPositionTryImport: Set<string>;
|
|
134
134
|
readonly stylexDefineVarsImport: Set<string>;
|
|
135
|
+
readonly stylexDefineMarkerImport: Set<string>;
|
|
135
136
|
readonly stylexDefineConstsImport: Set<string>;
|
|
136
137
|
readonly stylexCreateThemeImport: Set<string>;
|
|
137
138
|
readonly stylexTypesImport: Set<string>;
|
|
@@ -86,6 +86,7 @@ declare export default class StateManager {
|
|
|
86
86
|
+stylexKeyframesImport: Set<string>;
|
|
87
87
|
+stylexPositionTryImport: Set<string>;
|
|
88
88
|
+stylexDefineVarsImport: Set<string>;
|
|
89
|
+
+stylexDefineMarkerImport: Set<string>;
|
|
89
90
|
+stylexDefineConstsImport: Set<string>;
|
|
90
91
|
+stylexCreateThemeImport: Set<string>;
|
|
91
92
|
+stylexTypesImport: Set<string>;
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
* Transforms calls to `stylex.defineMarker()` (or imported `defineMarker()`)
|
|
15
|
+
* into an object: { $$css: true, [hash]: hash } where `hash` is generated from
|
|
16
|
+
* the file path and the export name.
|
|
17
|
+
*/
|
|
18
|
+
declare function transformStyleXDefineMarker(
|
|
19
|
+
path: NodePath<t.CallExpression>,
|
|
20
|
+
state: StateManager,
|
|
21
|
+
): void;
|
|
22
|
+
export default transformStyleXDefineMarker;
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
* Transforms calls to `stylex.defineMarker()` (or imported `defineMarker()`)
|
|
16
|
+
* into an object: { $$css: true, [hash]: hash } where `hash` is generated from
|
|
17
|
+
* the file path and the export name.
|
|
18
|
+
*/
|
|
19
|
+
declare export default function transformStyleXDefineMarker(
|
|
20
|
+
path: NodePath<t.CallExpression>,
|
|
21
|
+
state: StateManager,
|
|
22
|
+
): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stylexjs/babel-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "StyleX babel plugin.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"@babel/traverse": "^7.26.8",
|
|
22
22
|
"@babel/types": "^7.26.8",
|
|
23
23
|
"@dual-bundle/import-meta-resolve": "^4.1.0",
|
|
24
|
-
"@stylexjs/
|
|
24
|
+
"@stylexjs/shared": "0.17.0",
|
|
25
|
+
"@stylexjs/stylex": "0.17.0",
|
|
25
26
|
"postcss-value-parser": "^4.1.0"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
@@ -33,7 +34,7 @@
|
|
|
33
34
|
"@rollup/plugin-replace": "^6.0.1",
|
|
34
35
|
"babel-plugin-syntax-hermes-parser": "^0.26.0",
|
|
35
36
|
"rollup": "^4.24.0",
|
|
36
|
-
"scripts": "0.
|
|
37
|
+
"scripts": "0.17.0"
|
|
37
38
|
},
|
|
38
39
|
"files": [
|
|
39
40
|
"flow_modules/*",
|