Skip to content

Commit d50608d

Browse files
committed
Allow ReactCallSite to be passed to useOpenResource
This is basically a super set of ReactFunctionLocation but this will be important to support stack traces.
1 parent a1414c2 commit d50608d

5 files changed

Lines changed: 28 additions & 19 deletions

File tree

packages/react-devtools-core/src/standalone.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
import {localStorageSetItem} from 'react-devtools-shared/src/storage';
2727

2828
import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
29-
import type {ReactFunctionLocation} from 'shared/ReactTypes';
29+
import type {ReactFunctionLocation, ReactCallSite} from 'shared/ReactTypes';
3030

3131
export type StatusTypes = 'server-connected' | 'devtools-connected' | 'error';
3232
export type StatusListener = (message: string, status: StatusTypes) => void;
@@ -144,8 +144,8 @@ async function fetchFileWithCaching(url: string) {
144144
}
145145

146146
function canViewElementSourceFunction(
147-
_source: ReactFunctionLocation,
148-
symbolicatedSource: ReactFunctionLocation | null,
147+
_source: ReactFunctionLocation | ReactCallSite,
148+
symbolicatedSource: ReactFunctionLocation | ReactCallSite | null,
149149
): boolean {
150150
if (symbolicatedSource == null) {
151151
return false;
@@ -156,8 +156,8 @@ function canViewElementSourceFunction(
156156
}
157157

158158
function viewElementSourceFunction(
159-
_source: ReactFunctionLocation,
160-
symbolicatedSource: ReactFunctionLocation | null,
159+
_source: ReactFunctionLocation | ReactCallSite,
160+
symbolicatedSource: ReactFunctionLocation | ReactCallSite | null,
161161
): void {
162162
if (symbolicatedSource == null) {
163163
return;

packages/react-devtools-fusebox/src/frontend.d.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,26 @@ export type ReactFunctionLocation = [
3434
number, // enclosing line number
3535
number, // enclosing column number
3636
];
37+
export type ReactCallSite = [
38+
string, // function name
39+
string, // file name TODO: model nested eval locations as nested arrays
40+
number, // line number
41+
number, // column number
42+
number, // enclosing line number
43+
number, // enclosing column number
44+
boolean, // async resume
45+
];
3746
export type ViewElementSource = (
38-
source: ReactFunctionLocation,
39-
symbolicatedSource: ReactFunctionLocation | null,
47+
source: ReactFunctionLocation | ReactCallSite,
48+
symbolicatedSource: ReactFunctionLocation | ReactCallSite | null,
4049
) => void;
4150
export type ViewAttributeSource = (
4251
id: number,
4352
path: Array<string | number>,
4453
) => void;
4554
export type CanViewElementSource = (
46-
source: ReactFunctionLocation,
47-
symbolicatedSource: ReactFunctionLocation | null,
55+
source: ReactFunctionLocation | ReactCallSite,
56+
symbolicatedSource: ReactFunctionLocation | ReactCallSite | null,
4857
) => boolean;
4958

5059
export type InitializationOptions = {

packages/react-devtools-shared/src/devtools/views/DevTools.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,22 @@ import type {FetchFileWithCaching} from './Components/FetchFileWithCachingContex
5151
import type {HookNamesModuleLoaderFunction} from 'react-devtools-shared/src/devtools/views/Components/HookNamesModuleLoaderContext';
5252
import type {FrontendBridge} from 'react-devtools-shared/src/bridge';
5353
import type {BrowserTheme} from 'react-devtools-shared/src/frontend/types';
54-
import type {ReactFunctionLocation} from 'shared/ReactTypes';
54+
import type {ReactFunctionLocation, ReactCallSite} from 'shared/ReactTypes';
5555
import type {SourceSelection} from './Editor/EditorPane';
5656

5757
export type TabID = 'components' | 'profiler';
5858

5959
export type ViewElementSource = (
60-
source: ReactFunctionLocation,
61-
symbolicatedSource: ReactFunctionLocation | null,
60+
source: ReactFunctionLocation | ReactCallSite,
61+
symbolicatedSource: ReactFunctionLocation | ReactCallSite | null,
6262
) => void;
6363
export type ViewAttributeSource = (
6464
id: number,
6565
path: Array<string | number>,
6666
) => void;
6767
export type CanViewElementSource = (
68-
source: ReactFunctionLocation,
69-
symbolicatedSource: ReactFunctionLocation | null,
68+
source: ReactFunctionLocation | ReactCallSite,
69+
symbolicatedSource: ReactFunctionLocation | ReactCallSite | null,
7070
) => boolean;
7171

7272
export type Props = {

packages/react-devtools-shared/src/devtools/views/Editor/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
* @flow
88
*/
99

10-
import type {ReactFunctionLocation} from 'shared/ReactTypes';
10+
import type {ReactFunctionLocation, ReactCallSite} from 'shared/ReactTypes';
1111

1212
export function checkConditions(
1313
editorURL: string,
14-
source: ReactFunctionLocation,
14+
source: ReactFunctionLocation | ReactCallSite,
1515
): {url: URL | null, shouldDisableButton: boolean} {
1616
try {
1717
const url = new URL(editorURL);

packages/react-devtools-shared/src/devtools/views/useOpenResource.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @flow
88
*/
99

10-
import type {ReactFunctionLocation} from 'shared/ReactTypes';
10+
import type {ReactFunctionLocation, ReactCallSite} from 'shared/ReactTypes';
1111

1212
import {useCallback, useContext, useSyncExternalStore} from 'react';
1313

@@ -22,8 +22,8 @@ import {
2222
import {checkConditions} from './Editor/utils';
2323

2424
const useOpenResource = (
25-
source: null | ReactFunctionLocation,
26-
symbolicatedSource: null | ReactFunctionLocation,
25+
source: null | ReactFunctionLocation | ReactCallSite,
26+
symbolicatedSource: null | ReactFunctionLocation | ReactCallSite,
2727
): [
2828
boolean, // isEnabled
2929
() => void, // Open Resource

0 commit comments

Comments
 (0)