@@ -27,6 +27,7 @@ import TabBar from './TabBar';
27
27
import { SettingsContextController } from './Settings/SettingsContext' ;
28
28
import { TreeContextController } from './Components/TreeContext' ;
29
29
import ViewElementSourceContext from './Components/ViewElementSourceContext' ;
30
+ import ViewSourceContext from './Components/ViewSourceContext' ;
30
31
import FetchFileWithCachingContext from './Components/FetchFileWithCachingContext' ;
31
32
import HookNamesModuleLoaderContext from 'react-devtools-shared/src/devtools/views/Components/HookNamesModuleLoaderContext' ;
32
33
import { ProfilerContextController } from './Profiler/ProfilerContext' ;
@@ -57,6 +58,7 @@ export type ViewElementSource = (
57
58
id : number ,
58
59
inspectedElement : InspectedElement ,
59
60
) => void ;
61
+ export type ViewSourceLine = ( url : string , row : number , column : number ) => void ;
60
62
export type ViewAttributeSource = (
61
63
id : number ,
62
64
path : Array < string | number > ,
@@ -77,6 +79,7 @@ export type Props = {|
77
79
warnIfUnsupportedVersionDetected ?: boolean ,
78
80
viewAttributeSourceFunction ?: ?ViewAttributeSource ,
79
81
viewElementSourceFunction ?: ?ViewElementSource ,
82
+ viewSourceLineFunction ?: ?ViewSourceLine ,
80
83
readOnly ?: boolean ,
81
84
hideSettings ?: boolean ,
82
85
hideToggleErrorAction ?: boolean ,
@@ -136,6 +139,7 @@ export default function DevTools({
136
139
warnIfUnsupportedVersionDetected = false ,
137
140
viewAttributeSourceFunction,
138
141
viewElementSourceFunction,
142
+ viewSourceLineFunction,
139
143
readOnly,
140
144
hideSettings,
141
145
hideToggleErrorAction,
@@ -199,6 +203,15 @@ export default function DevTools({
199
203
[ canViewElementSourceFunction , viewElementSourceFunction ] ,
200
204
) ;
201
205
206
+ const viewSource = useMemo (
207
+ ( ) => ( {
208
+ viewSourceLineFunction : viewSourceLineFunction || null ,
209
+ // todo(blakef): Add inspect(...) method here and remove viewElementSource
210
+ // to consolidate source code inspection.
211
+ } ) ,
212
+ [ viewSourceLineFunction ] ,
213
+ ) ;
214
+
202
215
const contextMenu = useMemo (
203
216
( ) => ( {
204
217
isEnabledForInspectedElement : enabledInspectedElementContextMenu ,
@@ -267,55 +280,59 @@ export default function DevTools({
267
280
componentsPortalContainer = { componentsPortalContainer }
268
281
profilerPortalContainer = { profilerPortalContainer } >
269
282
< ViewElementSourceContext . Provider value = { viewElementSource } >
270
- < HookNamesModuleLoaderContext . Provider
271
- value = { hookNamesModuleLoaderFunction || null } >
272
- < FetchFileWithCachingContext . Provider
273
- value = { fetchFileWithCaching || null } >
274
- < TreeContextController >
275
- < ProfilerContextController >
276
- < TimelineContextController >
277
- < ThemeProvider >
278
- < div
279
- className = { styles . DevTools }
280
- ref = { devToolsRef }
281
- data-react-devtools-portal-root = { true } >
282
- { showTabBar && (
283
- < div className = { styles . TabBar } >
284
- < ReactLogo />
285
- < span className = { styles . DevToolsVersion } >
286
- { process . env . DEVTOOLS_VERSION }
287
- </ span >
288
- < div className = { styles . Spacer } />
289
- < TabBar
290
- currentTab = { tab }
291
- id = "DevTools"
292
- selectTab = { selectTab }
293
- tabs = { tabs }
294
- type = "navigation"
283
+ < ViewSourceContext . Provider value = { viewSource } >
284
+ < HookNamesModuleLoaderContext . Provider
285
+ value = { hookNamesModuleLoaderFunction || null } >
286
+ < FetchFileWithCachingContext . Provider
287
+ value = { fetchFileWithCaching || null } >
288
+ < TreeContextController >
289
+ < ProfilerContextController >
290
+ < TimelineContextController >
291
+ < ThemeProvider >
292
+ < div
293
+ className = { styles . DevTools }
294
+ ref = { devToolsRef }
295
+ data-react-devtools-portal-root = { true } >
296
+ { showTabBar && (
297
+ < div className = { styles . TabBar } >
298
+ < ReactLogo />
299
+ < span className = { styles . DevToolsVersion } >
300
+ { process . env . DEVTOOLS_VERSION }
301
+ </ span >
302
+ < div className = { styles . Spacer } />
303
+ < TabBar
304
+ currentTab = { tab }
305
+ id = "DevTools"
306
+ selectTab = { selectTab }
307
+ tabs = { tabs }
308
+ type = "navigation"
309
+ />
310
+ </ div >
311
+ ) }
312
+ < div
313
+ className = { styles . TabContent }
314
+ hidden = { tab !== 'components' } >
315
+ < Components
316
+ portalContainer = {
317
+ componentsPortalContainer
318
+ }
319
+ />
320
+ </ div >
321
+ < div
322
+ className = { styles . TabContent }
323
+ hidden = { tab !== 'profiler' } >
324
+ < Profiler
325
+ portalContainer = { profilerPortalContainer }
295
326
/>
296
327
</ div >
297
- ) }
298
- < div
299
- className = { styles . TabContent }
300
- hidden = { tab !== 'components' } >
301
- < Components
302
- portalContainer = { componentsPortalContainer }
303
- />
304
- </ div >
305
- < div
306
- className = { styles . TabContent }
307
- hidden = { tab !== 'profiler' } >
308
- < Profiler
309
- portalContainer = { profilerPortalContainer }
310
- />
311
328
</ div >
312
- </ div >
313
- </ ThemeProvider >
314
- </ TimelineContextController >
315
- </ ProfilerContextController >
316
- </ TreeContextController >
317
- </ FetchFileWithCachingContext . Provider >
318
- </ HookNamesModuleLoaderContext . Provider >
329
+ </ ThemeProvider >
330
+ </ TimelineContextController >
331
+ </ ProfilerContextController >
332
+ </ TreeContextController >
333
+ </ FetchFileWithCachingContext . Provider >
334
+ </ HookNamesModuleLoaderContext . Provider >
335
+ </ ViewSourceContext . Provider >
319
336
</ ViewElementSourceContext . Provider >
320
337
</ SettingsContextController >
321
338
< UnsupportedBridgeProtocolDialog />
0 commit comments