refactor: prevent consistent early exception (#24191)
* refactor: prevent consistent early exception * Use _linkedBinding where possible * Remove dead electronBinding
This commit is contained in:
parent
4c77fe318d
commit
659e79fc08
78 changed files with 134 additions and 145 deletions
|
@ -1,4 +1,4 @@
|
|||
const clipboard = process.electronBinding('clipboard');
|
||||
const clipboard = process._linkedBinding('electron_common_clipboard');
|
||||
|
||||
if (process.type === 'renderer') {
|
||||
const ipcRendererUtils = require('@electron/internal/renderer/ipc-renderer-internal-utils');
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
const { nativeImage } = process.electronBinding('native_image');
|
||||
const { nativeImage } = process._linkedBinding('electron_common_native_image');
|
||||
|
||||
export default nativeImage;
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default process.electronBinding('shell');
|
||||
export default process._linkedBinding('electron_common_shell');
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
export function electronBindingSetup (binding: typeof process['_linkedBinding'], processType: typeof process['type']): typeof process['electronBinding'] {
|
||||
return function electronBinding (name: string) {
|
||||
try {
|
||||
return binding(`electron_${processType}_${name}`);
|
||||
} catch (error) {
|
||||
if (/No such module/.test(error.message)) {
|
||||
return binding(`electron_common_${name}`);
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
|
@ -1,11 +1,7 @@
|
|||
import * as util from 'util';
|
||||
|
||||
import { electronBindingSetup } from '@electron/internal/common/electron-binding-setup';
|
||||
|
||||
const timers = require('timers');
|
||||
|
||||
process.electronBinding = electronBindingSetup(process._linkedBinding, process.type);
|
||||
|
||||
type AnyFn = (...args: any[]) => any
|
||||
|
||||
// setImmediate and process.nextTick makes use of uv_check and uv_prepare to
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { nativeImage, NativeImage } = process.electronBinding('native_image');
|
||||
const { nativeImage, NativeImage } = process._linkedBinding('electron_common_native_image');
|
||||
|
||||
export function isPromise (val: any) {
|
||||
return (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue