File tree 7 files changed +33
-38
lines changed
packages/react-devtools-shared/src
devtools/views/Components
7 files changed +33
-38
lines changed Original file line number Diff line number Diff line change 7
7
* @flow
8
8
*/
9
9
10
- export type StyleXData = { |
11
- sources : Array < string > ,
12
- resolvedStyles : Object ,
13
- | } ;
10
+ import type { StyleXPlugin } from 'react-devtools-shared/src/types' ;
14
11
15
12
const cachedStyleNameToValueMap : Map < string , string > = new Map ( ) ;
16
13
17
- export function getStyleXData ( data : any ) : StyleXData {
14
+ export function getStyleXData ( data : any ) : StyleXPlugin {
18
15
const sources = new Set ( ) ;
19
16
const resolvedStyles = { } ;
20
17
Original file line number Diff line number Diff line change @@ -839,7 +839,9 @@ export function attach(
839
839
rendererPackageName : null ,
840
840
rendererVersion : null ,
841
841
842
- plugins : [ ] ,
842
+ plugins : {
843
+ stylex : null ,
844
+ } ,
843
845
} ;
844
846
}
845
847
Original file line number Diff line number Diff line change @@ -102,7 +102,6 @@ import type {
102
102
NativeType ,
103
103
PathFrame ,
104
104
PathMatch ,
105
- Plugin ,
106
105
ProfilingDataBackend ,
107
106
ProfilingDataForRootBackend ,
108
107
ReactRenderer ,
@@ -113,6 +112,7 @@ import type {
113
112
import type {
114
113
ComponentFilter ,
115
114
ElementType ,
115
+ Plugins ,
116
116
} from 'react-devtools-shared/src/types' ;
117
117
118
118
type getDisplayNameForFiberType = ( fiber : Fiber ) => string | null ;
@@ -3239,14 +3239,13 @@ export function attach(
3239
3239
targetErrorBoundaryID = getNearestErrorBoundaryID ( fiber ) ;
3240
3240
}
3241
3241
3242
- const plugins: Array< Plugin > = [];
3242
+ const plugins: Plugins = {
3243
+ stylex : null ,
3244
+ } ;
3243
3245
3244
3246
if (enableStyleXFeatures) {
3245
3247
if ( memoizedProps . hasOwnProperty ( 'xstyle' ) ) {
3246
- plugins . push ( {
3247
- type : 'stylex' ,
3248
- data : getStyleXData ( memoizedProps . xstyle ) ,
3249
- } ) ;
3248
+ plugins . stylex = getStyleXData ( memoizedProps . xstyle ) ;
3250
3249
}
3251
3250
}
3252
3251
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
13
13
import type {
14
14
ComponentFilter ,
15
15
ElementType ,
16
+ Plugins ,
16
17
} from 'react-devtools-shared/src/types' ;
17
18
import type { ResolveNativeStyle } from 'react-devtools-shared/src/backend/NativeStyleEditor/setupNativeStyleEditor' ;
18
19
@@ -213,14 +214,6 @@ export type OwnersList = {|
213
214
owners : Array < SerializedElement > | null ,
214
215
| } ;
215
216
216
- // For now, let's only support a hard-coded set of plugins.
217
- type PluginType = 'stylex ';
218
-
219
- export type Plugin = {
220
- type : PluginType ,
221
- data : any ,
222
- } ;
223
-
224
217
export type InspectedElement = { |
225
218
id : number ,
226
219
@@ -274,8 +267,8 @@ export type InspectedElement = {|
274
267
rendererPackageName : string | null ,
275
268
rendererVersion : string | null ,
276
269
277
- // Array of UI plugins/visualizations for the inspected element.
278
- plugins : Array < Plugin > ,
270
+ // UI plugins/visualizations for the inspected element.
271
+ plugins : Plugins ,
279
272
| } ;
280
273
281
274
export const InspectElementErrorType = 'error ';
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import KeyValue from './KeyValue';
12
12
import Store from '../../store' ;
13
13
import sharedStyles from './InspectedElementSharedStyles.css' ;
14
14
import styles from './InspectedElementStyleXPlugin.css' ;
15
+ import { enableStyleXFeatures } from 'react-devtools-feature-flags' ;
15
16
16
17
import type { InspectedElement } from './types' ;
17
18
import type { FrontendBridge } from 'react-devtools-shared/src/bridge' ;
@@ -30,14 +31,16 @@ export default function InspectedElementStyleXPlugin({
30
31
inspectedElement,
31
32
store,
32
33
} : Props ) {
33
- const styleXPlugin = inspectedElement . plugins . find (
34
- ( { type} ) => type === 'stylex' ,
35
- ) ;
36
- if ( styleXPlugin == null || styleXPlugin . data == null ) {
34
+ if ( ! enableStyleXFeatures ) {
35
+ return null ;
36
+ }
37
+
38
+ const styleXPlugin = inspectedElement . plugins . stylex ;
39
+ if ( styleXPlugin == null ) {
37
40
return null ;
38
41
}
39
42
40
- const { resolvedStyles, sources} = styleXPlugin . data ;
43
+ const { resolvedStyles, sources} = styleXPlugin ;
41
44
42
45
return (
43
46
< div className = { sharedStyles . InspectedElementTree } >
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import type {
12
12
Dehydrated ,
13
13
Unserializable ,
14
14
} from 'react-devtools-shared/src/hydration' ;
15
- import type { ElementType } from 'react-devtools-shared/src/types' ;
15
+ import type { ElementType , Plugins } from 'react-devtools-shared/src/types' ;
16
16
17
17
// Each element on the frontend corresponds to a Fiber on the backend.
18
18
// Some of its information (e.g. id, type, displayName) come from the backend.
@@ -64,14 +64,6 @@ export type InspectedElementResponseType =
64
64
| 'no-change'
65
65
| 'not-found' ;
66
66
67
- // For now, let's only support a hard-coded set of plugins.
68
- type PluginType = 'stylex' ;
69
-
70
- export type Plugin = {
71
- type : PluginType ,
72
- data : any ,
73
- } ;
74
-
75
67
export type InspectedElement = { |
76
68
id : number ,
77
69
@@ -123,8 +115,8 @@ export type InspectedElement = {|
123
115
rendererPackageName : string | null ,
124
116
rendererVersion : string | null ,
125
117
126
- // Array of UI plugins/visualizations for the inspected element.
127
- plugins : Array < Plugin > ,
118
+ // UI plugins/visualizations for the inspected element.
119
+ plugins : Plugins ,
128
120
| } ;
129
121
130
122
// TODO: Add profiling type
Original file line number Diff line number Diff line change @@ -91,3 +91,12 @@ export type LRUCache<K, V> = {|
91
91
reset : ( ) => void ,
92
92
set : ( key : K , value : V ) => void ,
93
93
| } ;
94
+
95
+ export type StyleXPlugin = { |
96
+ sources : Array < string > ,
97
+ resolvedStyles : Object ,
98
+ | } ;
99
+
100
+ export type Plugins = { |
101
+ stylex : StyleXPlugin | null ,
102
+ | } ;
You can’t perform that action at this time.
0 commit comments