-
Notifications
You must be signed in to change notification settings - Fork 31.8k
/
Copy pathextensionHostProtocol.ts
143 lines (125 loc) · 4.14 KB
/
extensionHostProtocol.ts
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
133
134
135
136
137
138
139
140
141
142
143
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { VSBuffer } from 'vs/base/common/buffer';
import { URI, UriComponents, UriDto } from 'vs/base/common/uri';
import { ExtensionIdentifier, IExtensionDescription } from 'vs/platform/extensions/common/extensions';
import { ILoggerResource, LogLevel } from 'vs/platform/log/common/log';
import { IRemoteConnectionData } from 'vs/platform/remote/common/remoteAuthorityResolver';
export interface IExtensionDescriptionDelta {
readonly toRemove: ExtensionIdentifier[];
readonly toAdd: IExtensionDescription[];
readonly addActivationEvents: { [extensionId: string]: string[] };
readonly myToRemove: ExtensionIdentifier[];
readonly myToAdd: ExtensionIdentifier[];
}
export interface IExtensionHostInitData {
version: string;
commit?: string;
/**
* When set to `0`, no polling for the parent process still running will happen.
*/
parentPid: number | 0;
environment: IEnvironment;
workspace?: IStaticWorkspaceData | null;
activationEvents: { [extensionId: string]: string[] };
allExtensions: IExtensionDescription[];
myExtensions: ExtensionIdentifier[];
nlsBaseUrl?: URI;
telemetryInfo: {
readonly sessionId: string;
readonly machineId: string;
readonly firstSessionDate: string;
readonly msftInternal?: boolean;
};
logLevel: LogLevel;
loggers: UriDto<ILoggerResource>[];
logsLocation: URI;
autoStart: boolean;
remote: { isRemote: boolean; authority: string | undefined; connectionData: IRemoteConnectionData | null };
consoleForward: { includeStack: boolean; logNative: boolean };
uiKind: UIKind;
messagePorts?: ReadonlyMap<string, MessagePortLike>;
}
export interface IEnvironment {
isExtensionDevelopmentDebug: boolean;
appName: string;
appHost: string;
appRoot?: URI;
appLanguage: string;
extensionTelemetryLogResource: URI;
isExtensionTelemetryLoggingOnly: boolean;
appUriScheme: string;
extensionDevelopmentLocationURI?: URI[];
extensionTestsLocationURI?: URI;
globalStorageHome: URI;
workspaceStorageHome: URI;
useHostProxy?: boolean;
skipWorkspaceStorageLock?: boolean;
extensionLogLevel?: [string, string][];
}
export interface IStaticWorkspaceData {
id: string;
name: string;
transient?: boolean;
configuration?: UriComponents | null;
isUntitled?: boolean | null;
}
export interface MessagePortLike {
postMessage(message: any, transfer?: any[]): void;
addEventListener(type: 'message', listener: (e: any) => any): void;
removeEventListener(type: 'message', listener: (e: any) => any): void;
start(): void;
}
export enum UIKind {
Desktop = 1,
Web = 2
}
export const enum ExtensionHostExitCode {
// nodejs uses codes 1-13 and exit codes >128 are signal exits
VersionMismatch = 55,
UnexpectedError = 81,
}
export interface IExtHostReadyMessage {
type: 'VSCODE_EXTHOST_IPC_READY';
}
export interface IExtHostSocketMessage {
type: 'VSCODE_EXTHOST_IPC_SOCKET';
initialDataChunk: string;
skipWebSocketFrames: boolean;
permessageDeflate: boolean;
inflateBytes: string;
}
export interface IExtHostReduceGraceTimeMessage {
type: 'VSCODE_EXTHOST_IPC_REDUCE_GRACE_TIME';
}
export const enum MessageType {
Initialized,
Ready,
Terminate
}
export function createMessageOfType(type: MessageType): VSBuffer {
const result = VSBuffer.alloc(1);
switch (type) {
case MessageType.Initialized: result.writeUInt8(1, 0); break;
case MessageType.Ready: result.writeUInt8(2, 0); break;
case MessageType.Terminate: result.writeUInt8(3, 0); break;
}
return result;
}
export function isMessageOfType(message: VSBuffer, type: MessageType): boolean {
if (message.byteLength !== 1) {
return false;
}
switch (message.readUInt8(0)) {
case 1: return type === MessageType.Initialized;
case 2: return type === MessageType.Ready;
case 3: return type === MessageType.Terminate;
default: return false;
}
}
export const enum NativeLogMarkers {
Start = 'START_NATIVE_LOG',
End = 'END_NATIVE_LOG',
}