mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Runs `yarn format` across lib/, spec/, script/, build/, default_app/, and npm/ to bring the codebase in line with the .oxfmtrc.json settings added in the previous commit. This is a pure formatting pass: import statements are sorted into the groups defined by the config, method chains longer than printWidth are broken, single-quoted strings containing apostrophes are switched to double quotes, and a handful of single-statement `if` bodies are re-wrapped and get braces added by `oxlint --fix` to satisfy the `curly: multi-line` rule. No behavior changes.
76 lines
2.3 KiB
TypeScript
76 lines
2.3 KiB
TypeScript
import '@electron/internal/sandboxed_renderer/pre-init';
|
|
import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages';
|
|
import type * as ipcRendererUtilsModule from '@electron/internal/renderer/ipc-renderer-internal-utils';
|
|
import {
|
|
createPreloadProcessObject,
|
|
executeSandboxedPreloadScripts
|
|
} from '@electron/internal/sandboxed_renderer/preload';
|
|
|
|
import * as events from 'events';
|
|
import { setImmediate, clearImmediate } from 'timers';
|
|
|
|
declare const binding: {
|
|
process: NodeJS.Process;
|
|
createPreloadScript: (src: string) => Function;
|
|
};
|
|
|
|
const ipcRendererUtils =
|
|
require('@electron/internal/renderer/ipc-renderer-internal-utils') as typeof ipcRendererUtilsModule;
|
|
|
|
const { preloadScripts, process: processProps } = ipcRendererUtils.invokeSync<{
|
|
preloadScripts: ElectronInternal.PreloadScript[];
|
|
process: NodeJS.Process;
|
|
}>(IPC_MESSAGES.BROWSER_SANDBOX_LOAD);
|
|
|
|
const electron = require('electron');
|
|
|
|
const loadedModules = new Map<string, any>([
|
|
['electron', electron],
|
|
['electron/common', electron],
|
|
['electron/renderer', electron],
|
|
['events', events],
|
|
['node:events', events]
|
|
]);
|
|
|
|
const loadableModules = new Map<string, Function>([
|
|
['timers', () => require('timers')],
|
|
['node:timers', () => require('timers')],
|
|
['url', () => require('url')],
|
|
['node:url', () => require('url')]
|
|
]);
|
|
|
|
const preloadProcess = createPreloadProcessObject();
|
|
|
|
// InvokeEmitProcessEvent in ElectronSandboxedRendererClient will look for this
|
|
const v8Util = process._linkedBinding('electron_common_v8_util');
|
|
v8Util.setHiddenValue(global, 'emit-process-event', (event: string) => {
|
|
(process as events.EventEmitter).emit(event);
|
|
(preloadProcess as events.EventEmitter).emit(event);
|
|
});
|
|
|
|
Object.assign(preloadProcess, binding.process);
|
|
Object.assign(preloadProcess, processProps);
|
|
|
|
Object.assign(process, processProps);
|
|
|
|
// Common renderer initialization
|
|
require('@electron/internal/renderer/common-init');
|
|
|
|
executeSandboxedPreloadScripts(
|
|
{
|
|
loadedModules,
|
|
loadableModules,
|
|
process: preloadProcess,
|
|
createPreloadScript: binding.createPreloadScript,
|
|
exposeGlobals: {
|
|
Buffer,
|
|
// FIXME(samuelmaddock): workaround webpack bug replacing this with just
|
|
// `__webpack_require__.g,` which causes script error
|
|
global: globalThis,
|
|
setImmediate,
|
|
clearImmediate
|
|
}
|
|
},
|
|
preloadScripts
|
|
);
|