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
3296 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
logLevel: LogLevel;
50
loggers: UriDto<ILoggerResource>[];
51
logsLocation: URI;
52
autoStart: boolean;
53
remote: { isRemote: boolean; authority: string | undefined; connectionData: IRemoteConnectionData | null };
54
consoleForward: { includeStack: boolean; logNative: boolean };
55
uiKind: UIKind;
56
messagePorts?: ReadonlyMap<string, MessagePortLike>;
57
handle?: string;
58
}
59
60
export interface IEnvironment {
61
isExtensionDevelopmentDebug: boolean;
62
appName: string;
63
appHost: string;
64
appRoot?: URI;
65
appLanguage: string;
66
isExtensionTelemetryLoggingOnly: boolean;
67
appUriScheme: string;
68
extensionDevelopmentLocationURI?: URI[];
69
extensionTestsLocationURI?: URI;
70
globalStorageHome: URI;
71
workspaceStorageHome: URI;
72
useHostProxy?: boolean;
73
skipWorkspaceStorageLock?: boolean;
74
extensionLogLevel?: [string, string][];
75
}
76
77
export interface IStaticWorkspaceData {
78
id: string;
79
name: string;
80
transient?: boolean;
81
configuration?: UriComponents | null;
82
isUntitled?: boolean | null;
83
}
84
85
export interface MessagePortLike {
86
postMessage(message: any, transfer?: any[]): void;
87
addEventListener(type: 'message', listener: (e: any) => unknown): void;
88
removeEventListener(type: 'message', listener: (e: any) => unknown): void;
89
start(): void;
90
}
91
92
export enum UIKind {
93
Desktop = 1,
94
Web = 2
95
}
96
97
export const enum ExtensionHostExitCode {
98
// nodejs uses codes 1-13 and exit codes >128 are signal exits
99
VersionMismatch = 55,
100
UnexpectedError = 81,
101
}
102
103
export interface IExtHostReadyMessage {
104
type: 'VSCODE_EXTHOST_IPC_READY';
105
}
106
107
export interface IExtHostSocketMessage {
108
type: 'VSCODE_EXTHOST_IPC_SOCKET';
109
initialDataChunk: string;
110
skipWebSocketFrames: boolean;
111
permessageDeflate: boolean;
112
inflateBytes: string;
113
}
114
115
export interface IExtHostReduceGraceTimeMessage {
116
type: 'VSCODE_EXTHOST_IPC_REDUCE_GRACE_TIME';
117
}
118
119
export const enum MessageType {
120
Initialized,
121
Ready,
122
Terminate
123
}
124
125
export function createMessageOfType(type: MessageType): VSBuffer {
126
const result = VSBuffer.alloc(1);
127
128
switch (type) {
129
case MessageType.Initialized: result.writeUInt8(1, 0); break;
130
case MessageType.Ready: result.writeUInt8(2, 0); break;
131
case MessageType.Terminate: result.writeUInt8(3, 0); break;
132
}
133
134
return result;
135
}
136
137
export function isMessageOfType(message: VSBuffer, type: MessageType): boolean {
138
if (message.byteLength !== 1) {
139
return false;
140
}
141
142
switch (message.readUInt8(0)) {
143
case 1: return type === MessageType.Initialized;
144
case 2: return type === MessageType.Ready;
145
case 3: return type === MessageType.Terminate;
146
default: return false;
147
}
148
}
149
150
export const enum NativeLogMarkers {
151
Start = 'START_NATIVE_LOG',
152
End = 'END_NATIVE_LOG',
153
}
154
155