-
-
Notifications
You must be signed in to change notification settings - Fork 812
/
Copy pathdevtools.js
42 lines (38 loc) · 1.28 KB
/
devtools.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { getCatchConsoleLogScript } from '../../electron/devtools'
let enabled = false
export const toggleOpenInEditor = (win, port) => {
if (win.devToolsWebContents) {
enabled = !enabled
return win.devToolsWebContents.executeJavaScript(`(() => {
${getCatchConsoleLogScript(port)}
window.__IS_OPEN_IN_EDITOR_ENABLED__ = ${enabled};
})()`)
}
}
export const isOpenInEditorEnabled = () => enabled
export const clearNetworkLogs = (win) => {
if (win.devToolsWebContents) {
return win.devToolsWebContents.executeJavaScript(`setTimeout(() => {
const { network } = UI.panels;
if (network && network.networkLogView && network.networkLogView.reset) {
network.networkLogView.reset()
}
}, 100)`)
}
}
export const selectRNDebuggerWorkerContext = (win) => {
if (win.devToolsWebContents) {
return win.devToolsWebContents.executeJavaScript(`setTimeout(() => {
const { console } = UI.panels;
if (console && console.view && console.view.consoleContextSelector) {
const selector = console.view.consoleContextSelector;
const item = selector.items.items.find(
item => item.label() === 'RNDebuggerWorker.js'
);
if (item) {
selector.itemSelected(item);
}
}
}, 100)`)
}
}