e9cb85bea6
build: add import/order eslint rule (#44085) * build: add import/order eslint rule * chore: run lint:js --fix
22 lines
807 B
TypeScript
22 lines
807 B
TypeScript
import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages';
|
|
import * as ipcRendererUtils from '@electron/internal/renderer/ipc-renderer-internal-utils';
|
|
|
|
import { webFrame, WebFrame } from 'electron/renderer';
|
|
|
|
// All keys of WebFrame that extend Function
|
|
type WebFrameMethod = {
|
|
[K in keyof WebFrame]:
|
|
WebFrame[K] extends Function ? K : never
|
|
}
|
|
|
|
export const webFrameInit = () => {
|
|
// Call webFrame method
|
|
ipcRendererUtils.handle(IPC_MESSAGES.RENDERER_WEB_FRAME_METHOD, (
|
|
event, method: keyof WebFrameMethod, ...args: any[]
|
|
) => {
|
|
// The TypeScript compiler cannot handle the sheer number of
|
|
// call signatures here and simply gives up. Incorrect invocations
|
|
// will be caught by "keyof WebFrameMethod" though.
|
|
return (webFrame[method] as any)(...args);
|
|
});
|
|
};
|