|
| 1 | +(function () { |
1 | 2 | // preloads run in devtools panes too, but we don't want to run there |
2 | | -if (document.location.protocol === 'devtools:') return |
| 3 | + if (document.location.protocol === 'devtools:') return |
3 | 4 |
|
4 | | -const { ipcRenderer, contextBridge } = require('electron') |
5 | | -const BugsnagIpcRenderer = require('./bugsnag-ipc-renderer') |
6 | | -const { CHANNEL_CONFIG } = require('./lib/constants') |
| 5 | + const { ipcRenderer, contextBridge } = require('electron') |
| 6 | + const BugsnagIpcRenderer = require('./bugsnag-ipc-renderer') |
| 7 | + const { CHANNEL_CONFIG } = require('./lib/constants') |
7 | 8 |
|
8 | | -// one sync call is required on startup to get the main process config |
9 | | -const config = ipcRenderer.sendSync(CHANNEL_CONFIG) |
10 | | -if (!config) throw new Error('Bugsnag was not started in the main process before browser windows were created') |
| 9 | + // one sync call is required on startup to get the main process config |
| 10 | + const config = ipcRenderer.sendSync(CHANNEL_CONFIG) |
| 11 | + if (!config) throw new Error('Bugsnag was not started in the main process before browser windows were created') |
11 | 12 |
|
12 | | -// attach config to the exposed interface |
13 | | -BugsnagIpcRenderer.config = JSON.parse(config) |
| 13 | + // attach config to the exposed interface |
| 14 | + BugsnagIpcRenderer.config = JSON.parse(config) |
14 | 15 |
|
15 | | -// attach process info to the exposed interface |
16 | | -const { isMainFrame, sandboxed, type } = process |
17 | | -BugsnagIpcRenderer.process = { isMainFrame, sandboxed, type } |
| 16 | + // attach process info to the exposed interface |
| 17 | + const { isMainFrame, sandboxed, type } = process |
| 18 | + BugsnagIpcRenderer.process = { isMainFrame, sandboxed, type } |
18 | 19 |
|
19 | | -// expose Bugsnag as a global object for the browser |
20 | | -try { |
| 20 | + // expose Bugsnag as a global object for the browser |
| 21 | + try { |
21 | 22 | // assume contextIsolation=true |
22 | | - contextBridge.exposeInMainWorld('__bugsnag_ipc__', BugsnagIpcRenderer) |
23 | | -} catch (e) {} |
| 23 | + contextBridge.exposeInMainWorld('__bugsnag_ipc__', BugsnagIpcRenderer) |
| 24 | + } catch (e) {} |
24 | 25 |
|
25 | | -// expose for other preload scripts to use, this also covers contextIsolation=false |
26 | | -window.__bugsnag_ipc__ = BugsnagIpcRenderer |
| 26 | + // expose for other preload scripts to use, this also covers contextIsolation=false |
| 27 | + window.__bugsnag_ipc__ = BugsnagIpcRenderer |
| 28 | +})() |
0 commit comments