feat: serialize NativeImage over ipc (#30729)

This commit is contained in:
Jeremy Rose 2021-09-07 10:37:45 -07:00 committed by GitHub
parent ee33374675
commit 55c57808fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 79 additions and 157 deletions

View file

@ -1,20 +1,14 @@
import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages';
import type * as ipcRendererUtilsModule from '@electron/internal/renderer/ipc-renderer-internal-utils';
import type * as typeUtilsModule from '@electron/internal/common/type-utils';
const clipboard = process._linkedBinding('electron_common_clipboard');
if (process.type === 'renderer') {
const ipcRendererUtils = require('@electron/internal/renderer/ipc-renderer-internal-utils') as typeof ipcRendererUtilsModule;
const typeUtils = require('@electron/internal/common/type-utils') as typeof typeUtilsModule;
const makeRemoteMethod = function (method: keyof Electron.Clipboard) {
return (...args: any[]) => {
args = typeUtils.serialize(args);
const result = ipcRendererUtils.invokeSync(IPC_MESSAGES.BROWSER_CLIPBOARD_SYNC, method, ...args);
return typeUtils.deserialize(result);
};
const makeRemoteMethod = function (method: keyof Electron.Clipboard): any {
return (...args: any[]) => ipcRendererUtils.invokeSync(IPC_MESSAGES.BROWSER_CLIPBOARD_SYNC, method, ...args);
};
if (process.platform === 'linux') {