blob: 7d9b29a6e3a939a932779fbe2102d7a485ff798d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { globals, INodeProcess, IProcessEnvironment } from 'vs/base/common/platform';
import { ISandboxConfiguration } from 'vs/base/parts/sandbox/common/sandboxTypes';
import { IpcRenderer, ProcessMemoryInfo, WebFrame } from 'vs/base/parts/sandbox/electron-sandbox/electronTypes';
/**
* In sandboxed renderers we cannot expose all of the `process` global of node.js
*/
export interface ISandboxNodeProcess extends INodeProcess {
/**
* The process.platform property returns a string identifying the operating system platform
* on which the Node.js process is running.
*/
readonly platform: string;
/**
* The process.arch property returns a string identifying the CPU architecture
* on which the Node.js process is running.
*/
readonly arch: string;
/**
* The type will always be `renderer`.
*/
readonly type: string;
/**
* Whether the process is sandboxed or not.
*/
readonly sandboxed: boolean;
/**
* The `process.pid` property returns the PID of the process.
*/
readonly pid: number;
/**
* A list of versions for the current node.js/electron configuration.
*/
readonly versions: { [key: string]: string | undefined };
/**
* The process.env property returns an object containing the user environment.
*/
readonly env: IProcessEnvironment;
/**
* The `execPath` will be the location of the executable of this application.
*/
readonly execPath: string;
/**
* A listener on the process. Only a small subset of listener types are allowed.
*/
on: (type: string, callback: Function) => void;
/**
* The current working directory of the process.
*/
cwd: () => string;
/**
* Resolves with a ProcessMemoryInfo
*
* Returns an object giving memory usage statistics about the current process. Note
* that all statistics are reported in Kilobytes. This api should be called after
* app ready.
*
* Chromium does not provide `residentSet` value for macOS. This is because macOS
* performs in-memory compression of pages that haven't been recently used. As a
* result the resident set size value is not what one would expect. `private`
* memory is more representative of the actual pre-compression memory usage of the
* process on macOS.
*/
getProcessMemoryInfo: () => Promise<ProcessMemoryInfo>;
/**
* Returns a process environment that includes all shell environment variables even if
* the application was not started from a shell / terminal / console.
*
* There are different layers of environment that will apply:
* - `process.env`: this is the actual environment of the process before this method
* - `shellEnv` : if the program was not started from a terminal, we resolve all shell
* variables to get the same experience as if the program was started from
* a terminal (Linux, macOS)
* - `userEnv` : this is instance specific environment, e.g. if the user started the program
* from a terminal and changed certain variables
*
* The order of overwrites is `process.env` < `shellEnv` < `userEnv`.
*/
shellEnv(): Promise<IProcessEnvironment>;
}
export interface IpcMessagePort {
/**
* Acquire a `MessagePort`. The main process will transfer the port over to
* the `responseChannel` with a payload of `requestNonce` so that the source can
* correlate the response.
*
* The source should install a `window.on('message')` listener, ensuring `e.data`
* matches `nonce`, `e.source` matches `window` and then receiving the `MessagePort`
* via `e.ports[0]`.
*/
acquire(responseChannel: string, nonce: string): void;
}
export interface ISandboxContext {
/**
* A configuration object made accessible from the main side
* to configure the sandbox browser window. Will be `undefined`
* for as long as `resolveConfiguration` is not awaited.
*/
configuration(): ISandboxConfiguration | undefined;
/**
* Allows to await the resolution of the configuration object.
*/
resolveConfiguration(): Promise<ISandboxConfiguration>;
}
export const ipcRenderer: IpcRenderer = globals.vscode.ipcRenderer;
export const ipcMessagePort: IpcMessagePort = globals.vscode.ipcMessagePort;
export const webFrame: WebFrame = globals.vscode.webFrame;
export const process: ISandboxNodeProcess = globals.vscode.process;
export const context: ISandboxContext = globals.vscode.context;
|