File tree 7 files changed +110
-1
lines changed
packages/react-devtools-shared/src
devtools/views/Components 7 files changed +110
-1
lines changed Original file line number Diff line number Diff line change @@ -838,6 +838,8 @@ export function attach(
838
838
rootType : null ,
839
839
rendererPackageName : null ,
840
840
rendererVersion : null ,
841
+
842
+ plugins : [ ] ,
841
843
} ;
842
844
}
843
845
Original file line number Diff line number Diff line change @@ -102,6 +102,7 @@ import type {
102
102
NativeType ,
103
103
PathFrame ,
104
104
PathMatch ,
105
+ Plugin ,
105
106
ProfilingDataBackend ,
106
107
ProfilingDataForRootBackend ,
107
108
ReactRenderer ,
@@ -3238,12 +3239,17 @@ export function attach(
3238
3239
targetErrorBoundaryID = getNearestErrorBoundaryID ( fiber ) ;
3239
3240
}
3240
3241
3242
+ const plugins: Array< Plugin > = [];
3243
+
3241
3244
const modifiedProps = {
3242
3245
...memoizedProps ,
3243
3246
} ;
3244
3247
if (enableStyleXFeatures) {
3245
3248
if ( modifiedProps . hasOwnProperty ( 'xstyle' ) ) {
3246
- modifiedProps . xstyle = getStyleXValues ( modifiedProps . xstyle ) ;
3249
+ plugins . push ( {
3250
+ type : 'stylex' ,
3251
+ data : getStyleXValues ( modifiedProps . xstyle ) ,
3252
+ } ) ;
3247
3253
}
3248
3254
}
3249
3255
@@ -3306,6 +3312,8 @@ export function attach(
3306
3312
rootType ,
3307
3313
rendererPackageName : renderer . rendererPackageName ,
3308
3314
rendererVersion : renderer . version ,
3315
+
3316
+ plugins ,
3309
3317
} ;
3310
3318
}
3311
3319
Original file line number Diff line number Diff line change @@ -213,6 +213,14 @@ export type OwnersList = {|
213
213
owners : Array < SerializedElement > | null ,
214
214
| } ;
215
215
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
+
216
224
export type InspectedElement = { |
217
225
id : number ,
218
226
@@ -265,6 +273,9 @@ export type InspectedElement = {|
265
273
// Meta information about the renderer that created this element.
266
274
rendererPackageName : string | null ,
267
275
rendererVersion : string | null ,
276
+
277
+ // Let's try this
278
+ plugins : Array < Plugin > ,
268
279
| } ;
269
280
270
281
export const InspectElementErrorType = 'error ';
Original file line number Diff line number Diff line change @@ -208,6 +208,7 @@ export function convertInspectedElementBackendToFrontend(
208
208
owners,
209
209
context,
210
210
hooks,
211
+ plugins,
211
212
props,
212
213
rendererPackageName,
213
214
rendererVersion,
@@ -233,6 +234,7 @@ export function convertInspectedElementBackendToFrontend(
233
234
hasLegacyContext ,
234
235
id ,
235
236
key ,
237
+ plugins ,
236
238
rendererPackageName ,
237
239
rendererVersion ,
238
240
rootType ,
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its 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
8
+ */
9
+
10
+ import * as React from 'react' ;
11
+ import KeyValue from './KeyValue' ;
12
+ import Store from '../../store' ;
13
+ import styles from './InspectedElementSharedStyles.css' ;
14
+
15
+ import type { InspectedElement } from './types' ;
16
+ import type { FrontendBridge } from 'react-devtools-shared/src/bridge' ;
17
+ import type { Element } from 'react-devtools-shared/src/devtools/views/Components/types' ;
18
+
19
+ type Props = { |
20
+ bridge : FrontendBridge ,
21
+ element : Element ,
22
+ inspectedElement : InspectedElement ,
23
+ store : Store ,
24
+ | } ;
25
+
26
+ export default function InspectedElementStyleXPlugin ( {
27
+ bridge,
28
+ element,
29
+ inspectedElement,
30
+ store,
31
+ } : Props ) {
32
+ const styleXPlugin = inspectedElement . plugins . find (
33
+ ( { type} ) => type === 'stylex' ,
34
+ ) ;
35
+ if ( styleXPlugin == null || styleXPlugin . data == null ) {
36
+ return null ;
37
+ }
38
+
39
+ return (
40
+ < div className = { styles . InspectedElementTree } >
41
+ < div className = { styles . HeaderRow } >
42
+ < div className = { styles . Header } > stylex</ div >
43
+ </ div >
44
+ { Object . entries ( styleXPlugin . data ) . map ( ( [ name , value ] ) => (
45
+ < KeyValue
46
+ key = { name }
47
+ alphaSort = { true }
48
+ bridge = { bridge }
49
+ canDeletePaths = { false }
50
+ canEditValues = { false }
51
+ canRenamePaths = { false }
52
+ depth = { 1 }
53
+ element = { element }
54
+ hidden = { false }
55
+ inspectedElement = { inspectedElement }
56
+ name = { name }
57
+ path = { [ name ] }
58
+ pathRoot = "stylex"
59
+ store = { store }
60
+ value = { value }
61
+ />
62
+ ) ) }
63
+ </ div >
64
+ ) ;
65
+ }
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import InspectedElementErrorsAndWarningsTree from './InspectedElementErrorsAndWa
23
23
import InspectedElementHooksTree from './InspectedElementHooksTree' ;
24
24
import InspectedElementPropsTree from './InspectedElementPropsTree' ;
25
25
import InspectedElementStateTree from './InspectedElementStateTree' ;
26
+ import InspectedElementStyleXPlugin from './InspectedElementStyleXPlugin' ;
26
27
import InspectedElementSuspenseToggle from './InspectedElementSuspenseToggle' ;
27
28
import NativeStyleEditor from './NativeStyleEditor' ;
28
29
import Badge from './Badge' ;
@@ -31,6 +32,7 @@ import {
31
32
copyInspectedElementPath as copyInspectedElementPathAPI ,
32
33
storeAsGlobal as storeAsGlobalAPI ,
33
34
} from 'react-devtools-shared/src/backendAPI' ;
35
+ import { enableStyleXFeatures } from 'react-devtools-feature-flags' ;
34
36
35
37
import styles from './InspectedElementView.css' ;
36
38
@@ -124,6 +126,15 @@ export default function InspectedElementView({
124
126
store = { store }
125
127
/>
126
128
129
+ { enableStyleXFeatures && (
130
+ < InspectedElementStyleXPlugin
131
+ bridge = { bridge }
132
+ element = { element }
133
+ inspectedElement = { inspectedElement }
134
+ store = { store }
135
+ />
136
+ ) }
137
+
127
138
< InspectedElementErrorsAndWarningsTree
128
139
bridge = { bridge }
129
140
element = { element }
Original file line number Diff line number Diff line change @@ -64,6 +64,14 @@ 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
+
67
75
export type InspectedElement = { |
68
76
id : number ,
69
77
@@ -114,6 +122,8 @@ export type InspectedElement = {|
114
122
// Meta information about the renderer that created this element.
115
123
rendererPackageName : string | null ,
116
124
rendererVersion : string | null ,
125
+
126
+ plugins : Array < Plugin > ,
117
127
| } ;
118
128
119
129
// TODO: Add profiling type
You can’t perform that action at this time.
0 commit comments