MCPcopy Create free account
hub / github.com/jhen0409/react-native-debugger / getCatchConsoleLogScript

Function getCatchConsoleLogScript

electron/devtools.js:1–29  ·  view source on GitHub ↗
(port)

Source from the content-addressed store, hash-verified

1export const getCatchConsoleLogScript = (port) => `
2 window.__RN_PACKAGER_MATCHER__ = /^http:\\/\\/[^:]+:${port}/;
3 if (!window.__INJECT_OPEN_IN_EDITOR_SCRIPT__) {
4 const rndHelperQuery = 'iframe[data-devtools-extension="RNDebugger devtools helper"]';
5 document.addEventListener('click', event => {
6 if (!window.__IS_OPEN_IN_EDITOR_ENABLED__) {
7 return;
8 }
9 const { target } = event;
10 if (target.className === 'devtools-link') {
11 const source = target.title;
12 if (source && source.match(window.__RN_PACKAGER_MATCHER__)) {
13 const rndHelper = document.querySelector(rndHelperQuery);
14 if (rndHelper && rndHelper.contentWindow) {
15 rndHelper.contentWindow.postMessage(
16 {
17 type: 'open-in-editor',
18 source: source.replace(window.__RN_PACKAGER_MATCHER__, '')
19 },
20 '*'
21 );
22 return event.stopPropagation();
23 }
24 }
25 }
26 }, true);
27 window.__INJECT_OPEN_IN_EDITOR_SCRIPT__ = true;
28 }
29`
30
31export const catchConsoleLogLink = (win, host = 'localhost', port = 8081) => {
32 if (win.devToolsWebContents) {

Callers 2

toggleOpenInEditorFunction · 0.90
catchConsoleLogLinkFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected