(port)
| 1 | export 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 | |
| 31 | export const catchConsoleLogLink = (win, host = 'localhost', port = 8081) => { |
| 32 | if (win.devToolsWebContents) { |
no outgoing calls
no test coverage detected