Skip to content

Commit

Permalink
esm - try to fix build (#229972)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Sep 27, 2024
1 parent 1977d59 commit f9910cd
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 34 deletions.
8 changes: 3 additions & 5 deletions src/bootstrap-window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@

type ISandboxConfiguration = import('vs/base/parts/sandbox/common/sandboxTypes.js').ISandboxConfiguration;
type ILoadOptions<T extends ISandboxConfiguration> = import('vs/platform/window/electron-sandbox/window.js').ILoadOptions<T>;
type PreloadGlobals = typeof import('./vs/base/parts/sandbox/electron-sandbox/globals.js');
type IMainWindowSandboxGlobals = import('./vs/base/parts/sandbox/electron-sandbox/globals.js').IMainWindowSandboxGlobals;

// @ts-ignore (defined in preload.ts)
const preloadGlobals: PreloadGlobals = window.vscode;
const preloadGlobals: IMainWindowSandboxGlobals = (window as any).vscode; // defined by preload.ts
const safeProcess = preloadGlobals.process;

// increase number of stack frames(from 10, https://github.com/v8/v8/wiki/Stack-Trace-API)
Expand Down Expand Up @@ -229,6 +228,5 @@
}
}

// @ts-ignore
globalThis.MonacoBootstrapWindow = { load };
(globalThis as any).MonacoBootstrapWindow = { load };
}());
6 changes: 2 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,7 @@ function registerListeners(): void {
* the app-ready event. We listen very early for open-file and remember this upon startup as path to open.
*/
const macOpenFiles: string[] = [];
// @ts-ignore
globalThis['macOpenFiles'] = macOpenFiles;
(globalThis as any)['macOpenFiles'] = macOpenFiles;
app.on('open-file', function (event, path) {
macOpenFiles.push(path);
});
Expand All @@ -532,8 +531,7 @@ function registerListeners(): void {
app.on('open-url', onOpenUrl);
});

// @ts-ignore
globalThis['getOpenUrls'] = function () {
(globalThis as any)['getOpenUrls'] = function () {
app.removeListener('open-url', onOpenUrl);

return openUrls;
Expand Down
6 changes: 2 additions & 4 deletions src/server-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ import { IServerAPI } from './vs/server/node/remoteExtensionHostAgentServer.js';
const __dirname = path.dirname(fileURLToPath(import.meta.url));

perf.mark('code/server/start');
// @ts-ignore
globalThis.vscodeServerStartTime = performance.now();
(globalThis as any).vscodeServerStartTime = performance.now();

// Do a quick parse to determine if a server or the cli needs to be started
const parsedArgs = minimist(process.argv.slice(2), {
Expand Down Expand Up @@ -144,8 +143,7 @@ if (shouldSpawnCli) {
console.log(output);

perf.mark('code/server/started');
// @ts-ignore
globalThis.vscodeServerListenTime = performance.now();
(globalThis as any).vscodeServerListenTime = performance.now();

await getRemoteExtensionHostAgentServer();
});
Expand Down
9 changes: 3 additions & 6 deletions src/vs/base/node/unc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ function processUNCHostAllowlist(): Set<string> {
// The property `process.uncHostAllowlist` is not available in official node.js
// releases, only in our own builds, so we have to probe for availability

// @ts-ignore
return process.uncHostAllowlist;
return (process as any).uncHostAllowlist;
}

export function addUNCHostToAllowlist(allowedHost: string | string[]): void {
Expand Down Expand Up @@ -91,15 +90,13 @@ export function disableUNCAccessRestrictions(): void {
return;
}

// @ts-ignore
process.restrictUNCAccess = false;
(process as any).restrictUNCAccess = false;
}

export function isUNCAccessRestrictionsDisabled(): boolean {
if (process.platform !== 'win32') {
return true;
}

// @ts-ignore
return process.restrictUNCAccess === false;
return (process as any).restrictUNCAccess === false;
}
13 changes: 13 additions & 0 deletions src/vs/base/parts/sandbox/electron-sandbox/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ export const process: ISandboxNodeProcess = vscodeGlobal.process;
export const context: ISandboxContext = vscodeGlobal.context;
export const webUtils: WebUtils = vscodeGlobal.webUtils;

/**
* A set of globals only available to main windows that depend
* on `preload.js`.
*/
export interface IMainWindowSandboxGlobals {
readonly ipcRenderer: IpcRenderer;
readonly ipcMessagePort: IpcMessagePort;
readonly webFrame: WebFrame;
readonly process: ISandboxNodeProcess;
readonly context: ISandboxContext;
readonly webUtils: WebUtils;
}

/**
* A set of globals that are available in all windows that either
* depend on `preload.js` or `preload-aux.js`.
Expand Down
6 changes: 2 additions & 4 deletions src/vs/base/parts/sandbox/electron-sandbox/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,7 @@
return process.getProcessMemoryInfo();
},

on(type: string, callback: Function): void {
// @ts-ignore
on(type: string, callback: (...args: any[]) => void): void {
process.on(type, callback);
}
},
Expand Down Expand Up @@ -257,7 +256,6 @@
console.error(error);
}
} else {
// @ts-ignore
window.vscode = globals;
(window as any).vscode = globals;
}
}());
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
(function () {

type IBootstrapWindow = import('vs/platform/window/electron-sandbox/window.js').IBootstrapWindow;

// @ts-ignore (defined in bootstrap-window.js)
const bootstrapWindow: IBootstrapWindow = window.MonacoBootstrapWindow;
const bootstrapWindow: IBootstrapWindow = (window as any).MonacoBootstrapWindow; // defined by bootstrap-window.ts

bootstrapWindow.load('vs/code/electron-sandbox/processExplorer/processExplorerMain', function (processExplorer, configuration) {
return processExplorer.startup(configuration);
Expand Down
8 changes: 3 additions & 5 deletions src/vs/code/electron-sandbox/workbench/workbench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
type INativeWindowConfiguration = import('vs/platform/window/common/window.ts').INativeWindowConfiguration;
type NativeParsedArgs = import('vs/platform/environment/common/argv.js').NativeParsedArgs;
type IBootstrapWindow = import('vs/platform/window/electron-sandbox/window.js').IBootstrapWindow;
type PreloadGlobals = typeof import('vs/base/parts/sandbox/electron-sandbox/globals.js');
type IMainWindowSandboxGlobals = import('vs/base/parts/sandbox/electron-sandbox/globals.js').IMainWindowSandboxGlobals;

// @ts-ignore (defined in bootstrap-window.js)
const bootstrapWindow: IBootstrapWindow = window.MonacoBootstrapWindow;
// @ts-ignore (defined in preload.ts)
const preloadGlobals: PreloadGlobals = window.vscode;
const bootstrapWindow: IBootstrapWindow = (window as any).MonacoBootstrapWindow; // defined by bootstrap-window.ts
const preloadGlobals: IMainWindowSandboxGlobals = (window as any).vscode; // defined by preload.ts

// Add a perf entry right from the top
performance.mark('code/didStartRenderer');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
(function () {

type IBootstrapWindow = import('vs/platform/window/electron-sandbox/window.js').IBootstrapWindow;

// @ts-ignore (defined in bootstrap-window.js)
const bootstrapWindow: IBootstrapWindow = window.MonacoBootstrapWindow;
const bootstrapWindow: IBootstrapWindow = (window as any).MonacoBootstrapWindow; // defined by bootstrap-window.ts

bootstrapWindow.load('vs/workbench/contrib/issue/electron-sandbox/issueReporterMain', function (issueReporter, configuration) {
return issueReporter.startup(configuration);
Expand Down

0 comments on commit f9910cd

Please sign in to comment.