Skip to content

The swiss army knife of lossless video/audio editing

732 B
Raw Blame
import type * as Electron from 'electron';

import type { RemoteRpcApi } from '../main/index.ts';

// eslint-disable-next-line @typescript-eslint/no-require-imports
const { ipcRenderer } = require('electron') as typeof Electron;

const apiProxy = new Proxy(
  {} as RemoteRpcApi,
  {
    get(_target, method: keyof RemoteRpcApi) {
      return (...args: unknown[]) => (
        ipcRenderer.invoke('__electron_rpc__', method, args)
      );
    },
  },
);

// todo use contextBridge instead once we get rid of @electron/remote
// eslint-disable-next-line unicorn-js/no-global-object-property-assignment -- TODO fix (new rule in @mifi/lint-config)
window.electron = apiProxy;
// contextBridge.exposeInMainWorld('electron', apiProxy);