Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/services/extensions/common/extensionHostProtocol.ts
5251 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { VSBuffer } from '../../../../base/common/buffer.js';
7
import { URI, UriComponents, UriDto } from '../../../../base/common/uri.js';
8
import { ExtensionIdentifier, IExtensionDescription } from '../../../../platform/extensions/common/extensions.js';
9
import { ILoggerResource, LogLevel } from '../../../../platform/log/common/log.js';
10
import { IRemoteConnectionData } from '../../../../platform/remote/common/remoteAuthorityResolver.js';
11
12
export interface IExtensionDescriptionSnapshot {
13
readonly versionId: number;
14
readonly allExtensions: IExtensionDescription[];
15
readonly activationEvents: { [extensionId: string]: string[] };
16
readonly myExtensions: ExtensionIdentifier[];
17
}
18
19
export interface IExtensionDescriptionDelta {
20
readonly versionId: number;
21
readonly toRemove: ExtensionIdentifier[];
22
readonly toAdd: IExtensionDescription[];
23
readonly addActivationEvents: { [extensionId: string]: string[] };
24
readonly myToRemove: ExtensionIdentifier[];
25
readonly myToAdd: ExtensionIdentifier[];
26
}
27
28
export interface IExtensionHostInitData {
29
version: string;
30
quality: string | undefined;
31
commit?: string;
32
date?: string;
33
/**
34
* When set to `0`, no polling for the parent process still running will happen.
35
*/
36
parentPid: number | 0;
37
environment: IEnvironment;
38
workspace?: IStaticWorkspaceData | null;
39
extensions: IExtensionDescriptionSnapshot;
40
nlsBaseUrl?: URI;
41
telemetryInfo: {
42
readonly sessionId: string;
43
readonly machineId: string;
44
readonly sqmId: string;
45
readonly devDeviceId: string;
46
readonly firstSessionDate: string;
47
readonly msftInternal?: boolean;
48
};
49
remoteExtensionTips?: { readonly [remoteName: string]: unknown };
50
virtualWorkspaceExtensionTips?: { readonly [remoteName: string]: unknown };
51
logLevel: LogLevel;
52
loggers: UriDto<ILoggerResource>[];
53
logsLocation: URI;
54
autoStart: boolean;
55
remote: { isRemote: boolean; authority: string | undefined; connectionData: IRemoteConnectionData | null };
56
consoleForward: { includeStack: boolean; logNative: boolean };
57
uiKind: UIKind;
58
messagePorts?: ReadonlyMap<string, MessagePortLike>;
59
handle?: string;
60
}
61
62
export interface IEnvironment {
63
isExtensionDevelopmentDebug: boolean;
64
appName: string;
65
appHost: string;
66
appRoot?: URI;
67
appLanguage: string;
68
isExtensionTelemetryLoggingOnly: boolean;
69
appUriScheme: string;
70
isPortable?: boolean;
71
extensionDevelopmentLocationURI?: URI[];
72
extensionTestsLocationURI?: URI;
73
globalStorageHome: URI;
74
workspaceStorageHome: URI;
75
useHostProxy?: boolean;
76
skipWorkspaceStorageLock?: boolean;
77
extensionLogLevel?: [string, LogLevel][];
78
}
79
80
export interface IStaticWorkspaceData {
81
id: string;
82
name: string;
83
transient?: boolean;
84
configuration?: UriComponents | null;
85
isUntitled?: boolean | null;
86
isAgentSessionsWorkspace?: boolean;
87
}
88
89
export interface MessagePortLike {
90
postMessage(message: unknown, transfer?: Transferable[]): void;
91
addEventListener(type: 'message', listener: (e: MessageEvent<unknown>) => unknown): void;
92
removeEventListener(type: 'message', listener: (e: MessageEvent<unknown>) => unknown): void;
93
start(): void;
94
}
95
96
export enum UIKind {
97
Desktop = 1,
98
Web = 2
99
}
100
101
export const enum ExtensionHostExitCode {
102
// nodejs uses codes 1-13 and exit codes >128 are signal exits
103
VersionMismatch = 55,
104
UnexpectedError = 81,
105
}
106
107
export interface IExtHostReadyMessage {
108
type: 'VSCODE_EXTHOST_IPC_READY';
109
}
110
111
export interface IExtHostSocketMessage {
112
type: 'VSCODE_EXTHOST_IPC_SOCKET';
113
initialDataChunk: string;
114
skipWebSocketFrames: boolean;
115
permessageDeflate: boolean;
116
inflateBytes: string;
117
}
118
119
export interface IExtHostReduceGraceTimeMessage {
120
type: 'VSCODE_EXTHOST_IPC_REDUCE_GRACE_TIME';
121
}
122
123
export const enum MessageType {
124
Initialized,
125
Ready,
126
Terminate
127
}
128
129
export function createMessageOfType(type: MessageType): VSBuffer {
130
const result = VSBuffer.alloc(1);
131
132
switch (type) {
133
case MessageType.Initialized: result.writeUInt8(1, 0); break;
134
case MessageType.Ready: result.writeUInt8(2, 0); break;
135
case MessageType.Terminate: result.writeUInt8(3, 0); break;
136
}
137
138
return result;
139
}
140
141
export function isMessageOfType(message: VSBuffer, type: MessageType): boolean {
142
if (message.byteLength !== 1) {
143
return false;
144
}
145
146
switch (message.readUInt8(0)) {
147
case 1: return type === MessageType.Initialized;
148
case 2: return type === MessageType.Ready;
149
case 3: return type === MessageType.Terminate;
150
default: return false;
151
}
152
}
153
154
export const enum NativeLogMarkers {
155
Start = 'START_NATIVE_LOG',
156
End = 'END_NATIVE_LOG',
157
}
158
159