зеркало из https://github.com/electron/electron.git
refactor: const Module = require('module') as NodeJS.ModuleInternal; (#38757)
Co-authored-by: Milan Burda <miburda@microsoft.com>
This commit is contained in:
Родитель
65901f4c6a
Коммит
e71a56d11e
|
@ -5,7 +5,7 @@ import type * as Crypto from 'crypto';
|
|||
|
||||
const asar = process._linkedBinding('electron_common_asar');
|
||||
|
||||
const Module = require('module');
|
||||
const Module = require('module') as NodeJS.ModuleInternal;
|
||||
|
||||
const Promise: PromiseConstructor = global.Promise;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import * as path from 'path';
|
|||
|
||||
import type * as defaultMenuModule from '@electron/internal/browser/default-menu';
|
||||
|
||||
const Module = require('module');
|
||||
const Module = require('module') as NodeJS.ModuleInternal;
|
||||
|
||||
// We modified the original process.argv to let node.js load the init.js,
|
||||
// we need to restore it here.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as path from 'path';
|
||||
|
||||
const Module = require('module');
|
||||
const Module = require('module') as NodeJS.ModuleInternal;
|
||||
|
||||
// We do not want to allow use of the VM module in the renderer process as
|
||||
// it conflicts with Blink's V8::Context internal logic.
|
||||
|
@ -10,7 +10,7 @@ if (process.type === 'renderer') {
|
|||
if (request === 'vm') {
|
||||
console.warn('The vm module of Node.js is deprecated in the renderer process and will be removed.');
|
||||
}
|
||||
return _load.apply(this, arguments);
|
||||
return _load.apply(this, arguments as any);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ const originalResolveFilename = Module._resolveFilename;
|
|||
// renderer process regardless of the names, they're superficial for TypeScript
|
||||
// only.
|
||||
const electronModuleNames = new Set(['electron', 'electron/main', 'electron/renderer', 'electron/common']);
|
||||
Module._resolveFilename = function (request: string, parent: NodeModule, isMain: boolean, options?: { paths: Array<string>}) {
|
||||
Module._resolveFilename = function (request, parent, isMain, options) {
|
||||
if (electronModuleNames.has(request)) {
|
||||
return 'electron';
|
||||
} else {
|
||||
|
|
|
@ -5,7 +5,7 @@ import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages';
|
|||
import type * as ipcRendererInternalModule from '@electron/internal/renderer/ipc-renderer-internal';
|
||||
import type * as ipcRendererUtilsModule from '@electron/internal/renderer/ipc-renderer-internal-utils';
|
||||
|
||||
const Module = require('module');
|
||||
const Module = require('module') as NodeJS.ModuleInternal;
|
||||
|
||||
// Make sure globals like "process" and "global" are always available in preload
|
||||
// scripts even after they are deleted in "loaded" script.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { ParentPort } from '@electron/internal/utility/parent-port';
|
||||
const Module = require('module');
|
||||
const Module = require('module') as NodeJS.ModuleInternal;
|
||||
const v8Util = process._linkedBinding('electron_common_v8_util');
|
||||
|
||||
const entryScript: string = v8Util.getHiddenValue(process, '_serviceStartupScript');
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as path from 'path';
|
||||
|
||||
const Module = require('module');
|
||||
const Module = require('module') as NodeJS.ModuleInternal;
|
||||
|
||||
// We modified the original process.argv to let node.js load the
|
||||
// init.js, we need to restore it here.
|
||||
|
|
|
@ -7,7 +7,7 @@ import { closeAllWindows } from './lib/window-helpers';
|
|||
import * as childProcess from 'node:child_process';
|
||||
import { once } from 'node:events';
|
||||
|
||||
const Module = require('node:module');
|
||||
const Module = require('node:module') as NodeJS.ModuleInternal;
|
||||
|
||||
const nativeModulesEnabled = !process.env.ELECTRON_SKIP_NATIVE_MODULE_TESTS;
|
||||
|
||||
|
|
|
@ -3,6 +3,17 @@ declare const BUILDFLAG: (flag: boolean) => boolean;
|
|||
declare const ENABLE_VIEWS_API: boolean;
|
||||
|
||||
declare namespace NodeJS {
|
||||
interface ModuleInternal extends NodeJS.Module {
|
||||
new(id: string, parent?: NodeJS.Module | null): NodeJS.Module;
|
||||
_load(request: string, parent?: NodeJS.Module | null, isMain?: boolean): any;
|
||||
_resolveFilename(request: string, parent?: NodeJS.Module | null, isMain?: boolean, options?: { paths: string[] }): string;
|
||||
_preloadModules(requests: string[]): void;
|
||||
_nodeModulePaths(from: string): string[];
|
||||
_extensions: Record<string, (module: NodeJS.Module, filename: string) => any>;
|
||||
_cache: Record<string, NodeJS.Module>;
|
||||
wrapper: [string, string];
|
||||
}
|
||||
|
||||
interface FeaturesBinding {
|
||||
isBuiltinSpellCheckerEnabled(): boolean;
|
||||
isPDFViewerEnabled(): boolean;
|
||||
|
|
Загрузка…
Ссылка в новой задаче