From 3a65073f634cc93aafdfd941ccff4aa6b76263a3 Mon Sep 17 00:00:00 2001 From: Luna Date: Tue, 28 Jun 2022 22:12:47 -0400 Subject: [PATCH] fix viewSourceLineFunction --- packages/react-devtools-extensions/src/main.js | 6 +++--- .../src/devtools/views/Components/ViewSourceContext.js | 4 ++-- .../src/devtools/views/DevTools.js | 10 +++++----- .../src/devtools/views/Profiler/SidebarEventInfo.js | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/react-devtools-extensions/src/main.js b/packages/react-devtools-extensions/src/main.js index 3f4d24e730e3c..20265e812b67e 100644 --- a/packages/react-devtools-extensions/src/main.js +++ b/packages/react-devtools-extensions/src/main.js @@ -245,8 +245,8 @@ function createPanelIfReactLoaded() { } }; - const viewSourceLineFunction = (url, line) => { - chrome.devtools.panels.openResource(url, line); + const viewUrlSourceFunction = (url, line, col) => { + chrome.devtools.panels.openResource(url, line, col); }; let debugIDCounter = 0; @@ -385,7 +385,7 @@ function createPanelIfReactLoaded() { warnIfUnsupportedVersionDetected: true, viewAttributeSourceFunction, viewElementSourceFunction, - viewSourceLineFunction, + viewUrlSourceFunction, }), ); }; diff --git a/packages/react-devtools-shared/src/devtools/views/Components/ViewSourceContext.js b/packages/react-devtools-shared/src/devtools/views/Components/ViewSourceContext.js index daf216245bb74..39d6ccc470874 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/ViewSourceContext.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/ViewSourceContext.js @@ -9,10 +9,10 @@ import {createContext} from 'react'; -import type {ViewSourceLine} from 'react-devtools-shared/src/devtools/views/DevTools'; +import type {ViewUrlSource} from 'react-devtools-shared/src/devtools/views/DevTools'; export type Context = {| - viewSourceLineFunction: ViewSourceLine | null, + viewUrlSourceFunction: ViewUrlSource | null, |}; const ViewSourceContext = createContext(((null: any): Context)); diff --git a/packages/react-devtools-shared/src/devtools/views/DevTools.js b/packages/react-devtools-shared/src/devtools/views/DevTools.js index 49c947ba91389..a78261e9fc301 100644 --- a/packages/react-devtools-shared/src/devtools/views/DevTools.js +++ b/packages/react-devtools-shared/src/devtools/views/DevTools.js @@ -58,7 +58,7 @@ export type ViewElementSource = ( id: number, inspectedElement: InspectedElement, ) => void; -export type ViewSourceLine = (url: string, row: number, column: number) => void; +export type ViewUrlSource = (url: string, row: number, column: number) => void; export type ViewAttributeSource = ( id: number, path: Array, @@ -79,7 +79,7 @@ export type Props = {| warnIfUnsupportedVersionDetected?: boolean, viewAttributeSourceFunction?: ?ViewAttributeSource, viewElementSourceFunction?: ?ViewElementSource, - viewSourceLineFunction?: ?ViewSourceLine, + viewUrlSourceFunction?: ?ViewUrlSource, readOnly?: boolean, hideSettings?: boolean, hideToggleErrorAction?: boolean, @@ -139,7 +139,7 @@ export default function DevTools({ warnIfUnsupportedVersionDetected = false, viewAttributeSourceFunction, viewElementSourceFunction, - viewSourceLineFunction, + viewUrlSourceFunction, readOnly, hideSettings, hideToggleErrorAction, @@ -205,11 +205,11 @@ export default function DevTools({ const viewSource = useMemo( () => ({ - viewSourceLineFunction: viewSourceLineFunction || null, + viewUrlSourceFunction: viewUrlSourceFunction || null, // todo(blakef): Add inspect(...) method here and remove viewElementSource // to consolidate source code inspection. }), - [viewSourceLineFunction], + [viewUrlSourceFunction], ); const contextMenu = useMemo( diff --git a/packages/react-devtools-shared/src/devtools/views/Profiler/SidebarEventInfo.js b/packages/react-devtools-shared/src/devtools/views/Profiler/SidebarEventInfo.js index b32308d5d5df2..0ad5aedd86cb8 100644 --- a/packages/react-devtools-shared/src/devtools/views/Profiler/SidebarEventInfo.js +++ b/packages/react-devtools-shared/src/devtools/views/Profiler/SidebarEventInfo.js @@ -22,7 +22,7 @@ export type Props = {||}; export default function SidebarEventInfo(_: Props) { const {profilingData, selectedCommitIndex} = useContext(ProfilerContext); - const {viewSourceLineFunction} = useContext(ViewSourceContext); + const {viewUrlSourceFunction} = useContext(ViewSourceContext); const {stack} = useMemo(() => { if ( @@ -55,8 +55,8 @@ export default function SidebarEventInfo(_: Props) { const hasSource = source != null; const onClick = () => { - if (viewSourceLineFunction != null && source != null) { - viewSourceLineFunction(...source); + if (viewUrlSourceFunction != null && source != null) { + viewUrlSourceFunction(...source); } };