1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- const electron = typeof require !== 'undefined'
- // All exports module see https://www.electronjs.org -> API -> Renderer process Modules
- ? (function requireElectron() {
- const avoid_parse_require = require;
- return avoid_parse_require("electron");
- }())
- : (function nodeIntegrationWarn() {
- console.error(`If you need to use "electron" in the Renderer process, make sure that "nodeIntegration" is enabled in the Main process.`);
- return {
- // TODO: polyfill
- };
- }());
- // Proxy in Worker
- let _ipcRenderer;
- if (typeof document === 'undefined') {
- _ipcRenderer = {};
- const keys = [
- 'invoke',
- 'postMessage',
- 'send',
- 'sendSync',
- 'sendTo',
- 'sendToHost',
- // propertype
- 'addListener',
- 'emit',
- 'eventNames',
- 'getMaxListeners',
- 'listenerCount',
- 'listeners',
- 'off',
- 'on',
- 'once',
- 'prependListener',
- 'prependOnceListener',
- 'rawListeners',
- 'removeAllListeners',
- 'removeListener',
- 'setMaxListeners',
- ];
- for (const key of keys) {
- _ipcRenderer[key] = () => {
- throw new Error(
- 'ipcRenderer doesn\'t work in a Web Worker.\n' +
- 'You can see https://github.com/electron-vite/vite-plugin-electron/issues/69'
- );
- };
- }
- } else {
- _ipcRenderer = electron.ipcRenderer;
- }
- export { electron as default };
- export const clipboard = electron.clipboard;
- export const contextBridge = electron.contextBridge;
- export const crashReporter = electron.crashReporter;
- export const ipcRenderer = _ipcRenderer;
- export const nativeImage = electron.nativeImage;
- export const shell = electron.shell;
- export const webFrame = electron.webFrame;
- export const deprecate = electron.deprecate;
|