@lvce-editor/extension-host-worker 8.15.0 → 8.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extension-api/index.js +1360 -0
- package/dist/extension-api/parts/Activation/Activation.js +13 -0
- package/dist/extension-api/parts/AssertCompletionProvider/AssertCompletionProvider.js +25 -0
- package/dist/extension-api/parts/AssertFormattingProvider/AssertFormattingProvider.js +22 -0
- package/dist/extension-api/parts/AssertStatusBarItemProvider/AssertStatusBarItemProvider.js +19 -0
- package/dist/extension-api/parts/Command/Command.js +0 -0
- package/dist/extension-api/parts/CommandCallback/CommandCallback.js +0 -0
- package/dist/extension-api/parts/CommandMap/CommandMap.js +14 -0
- package/dist/extension-api/parts/CommandRegistry/CommandRegistry.js +53 -0
- package/dist/extension-api/parts/CommandRegistrySnapshot/CommandRegistrySnapshot.js +0 -0
- package/dist/extension-api/parts/Completion/Completion.js +11 -0
- package/dist/extension-api/parts/CompletionItem/CompletionItem.js +0 -0
- package/dist/extension-api/parts/CompletionProvider/CompletionProvider.js +0 -0
- package/dist/extension-api/parts/CompletionProviderRegistry/CompletionProviderRegistry.js +78 -0
- package/dist/extension-api/parts/CompletionProviderRegistrySnapshot/CompletionProviderRegistrySnapshot.js +0 -0
- package/dist/extension-api/parts/CompletionProviderState/CompletionProviderState.js +10 -0
- package/dist/extension-api/parts/CompletionTextDocument/CompletionTextDocument.js +0 -0
- package/dist/extension-api/parts/Disposable/Disposable.js +0 -0
- package/dist/extension-api/parts/ExecuteCommand/ExecuteCommand.js +7 -0
- package/dist/extension-api/parts/ExecuteCompletionProvider/ExecuteCompletionProvider.js +5 -0
- package/dist/extension-api/parts/ExecuteFormattingProvider/ExecuteFormattingProvider.js +4 -0
- package/dist/extension-api/parts/ExtensionApiCommandMap/ExtensionApiCommandMap.js +17 -0
- package/dist/extension-api/parts/ExtensionApiError/ExtensionApiError.js +9 -0
- package/dist/extension-api/parts/ExtensionApiWorkerCommandMap/ExtensionApiWorkerCommandMap.js +15 -0
- package/dist/extension-api/parts/ExtensionApiWorkerHandleMessagePort/ExtensionApiWorkerHandleMessagePort.js +21 -0
- package/dist/extension-api/parts/ExtensionApiWorkerListen/ExtensionApiWorkerListen.js +11 -0
- package/dist/extension-api/parts/Formatting/Formatting.js +10 -0
- package/dist/extension-api/parts/FormattingEdit/FormattingEdit.js +0 -0
- package/dist/extension-api/parts/FormattingProvider/FormattingProvider.js +0 -0
- package/dist/extension-api/parts/FormattingProviderRegistry/FormattingProviderRegistry.js +42 -0
- package/dist/extension-api/parts/FormattingProviderRegistrySnapshot/FormattingProviderRegistrySnapshot.js +0 -0
- package/dist/extension-api/parts/FormattingProviderState/FormattingProviderState.js +10 -0
- package/dist/extension-api/parts/FormattingTextDocument/FormattingTextDocument.js +0 -0
- package/dist/extension-api/parts/GetCompletionProviderRegistrySnapshot/GetCompletionProviderRegistrySnapshot.js +4 -0
- package/dist/extension-api/parts/GetFormattingProviderRegistrySnapshot/GetFormattingProviderRegistrySnapshot.js +4 -0
- package/dist/extension-api/parts/GetStatusBarItemProviderRegistrySnapshot/GetStatusBarItemProviderRegistrySnapshot.js +4 -0
- package/dist/extension-api/parts/GetStatusBarItems/GetStatusBarItems.js +4 -0
- package/dist/extension-api/parts/HandleExtensionManagementMessagePort/HandleExtensionManagementMessagePort.js +17 -0
- package/dist/extension-api/parts/NotifyStatusBarChange/NotifyStatusBarChange.js +7 -0
- package/dist/extension-api/parts/ProviderRegistry/ProviderRegistry.js +95 -0
- package/dist/extension-api/parts/QuickPick/QuickPick.js +7 -0
- package/dist/extension-api/parts/QuickPickItem/QuickPickItem.js +0 -0
- package/dist/extension-api/parts/RegisterCompletionProvider/RegisterCompletionProvider.js +4 -0
- package/dist/extension-api/parts/RegisterFormattingProvider/RegisterFormattingProvider.js +4 -0
- package/dist/extension-api/parts/RegisterStatusBarItemProvider/RegisterStatusBarItemProvider.js +4 -0
- package/dist/extension-api/parts/RegisteredCommand/RegisteredCommand.js +0 -0
- package/dist/extension-api/parts/RegisteredCompletionProvider/RegisteredCompletionProvider.js +0 -0
- package/dist/extension-api/parts/RegisteredFormattingProvider/RegisteredFormattingProvider.js +0 -0
- package/dist/extension-api/parts/RegisteredStatusBarItemProvider/RegisteredStatusBarItemProvider.js +0 -0
- package/dist/extension-api/parts/ResetCompletionProviderRegistry/ResetCompletionProviderRegistry.js +4 -0
- package/dist/extension-api/parts/ResetFormattingProviderRegistry/ResetFormattingProviderRegistry.js +4 -0
- package/dist/extension-api/parts/ResetStatusBarItemProviderRegistry/ResetStatusBarItemProviderRegistry.js +4 -0
- package/dist/extension-api/parts/Rpc/Rpc.js +14 -0
- package/dist/extension-api/parts/ShowQuickPickOptions/ShowQuickPickOptions.js +0 -0
- package/dist/extension-api/parts/StatusBar/StatusBar.js +8 -0
- package/dist/extension-api/parts/StatusBarItem/StatusBarItem.js +0 -0
- package/dist/extension-api/parts/StatusBarItemProvider/StatusBarItemProvider.js +0 -0
- package/dist/extension-api/parts/StatusBarItemProviderHandle/StatusBarItemProviderHandle.js +0 -0
- package/dist/extension-api/parts/StatusBarItemProviderRegistry/StatusBarItemProviderRegistry.js +52 -0
- package/dist/extension-api/parts/StatusBarItemProviderRegistrySnapshot/StatusBarItemProviderRegistrySnapshot.js +0 -0
- package/dist/extension-api/parts/StatusBarItemProviderState/StatusBarItemProviderState.js +10 -0
- package/dist/extensionHostWorkerMain.js +1308 -1200
- package/package.json +1 -1
|
@@ -19,31 +19,61 @@ const EditorCompletionType = {
|
|
|
19
19
|
Variable
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.name = 'DeprecatedError';
|
|
22
|
+
const normalizeLine = line => {
|
|
23
|
+
if (line.startsWith('Error: ')) {
|
|
24
|
+
return line.slice('Error: '.length);
|
|
26
25
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
if (line.startsWith('VError: ')) {
|
|
27
|
+
return line.slice('VError: '.length);
|
|
28
|
+
}
|
|
29
|
+
return line;
|
|
31
30
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
super(message);
|
|
31
|
+
const getCombinedMessage = (error, message) => {
|
|
32
|
+
const stringifiedError = normalizeLine(`${error}`);
|
|
33
|
+
if (message) {
|
|
34
|
+
return `${message}: ${stringifiedError}`;
|
|
37
35
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
return stringifiedError;
|
|
37
|
+
};
|
|
38
|
+
const NewLine$3 = '\n';
|
|
39
|
+
const getNewLineIndex$1 = (string, startIndex = undefined) => {
|
|
40
|
+
return string.indexOf(NewLine$3, startIndex);
|
|
41
|
+
};
|
|
42
|
+
const mergeStacks = (parent, child) => {
|
|
43
|
+
if (!child) {
|
|
44
|
+
return parent;
|
|
44
45
|
}
|
|
45
|
-
|
|
46
|
+
const parentNewLineIndex = getNewLineIndex$1(parent);
|
|
47
|
+
const childNewLineIndex = getNewLineIndex$1(child);
|
|
48
|
+
if (childNewLineIndex === -1) {
|
|
49
|
+
return parent;
|
|
50
|
+
}
|
|
51
|
+
const parentFirstLine = parent.slice(0, parentNewLineIndex);
|
|
52
|
+
const childRest = child.slice(childNewLineIndex);
|
|
53
|
+
const childFirstLine = normalizeLine(child.slice(0, childNewLineIndex));
|
|
54
|
+
if (parentFirstLine.includes(childFirstLine)) {
|
|
55
|
+
return parentFirstLine + childRest;
|
|
56
|
+
}
|
|
57
|
+
return child;
|
|
46
58
|
};
|
|
59
|
+
class VError extends Error {
|
|
60
|
+
constructor(error, message) {
|
|
61
|
+
const combinedMessage = getCombinedMessage(error, message);
|
|
62
|
+
super(combinedMessage);
|
|
63
|
+
this.name = 'VError';
|
|
64
|
+
if (error instanceof Error) {
|
|
65
|
+
this.stack = mergeStacks(this.stack, error.stack);
|
|
66
|
+
}
|
|
67
|
+
if (error.codeFrame) {
|
|
68
|
+
// @ts-ignore
|
|
69
|
+
this.codeFrame = error.codeFrame;
|
|
70
|
+
}
|
|
71
|
+
if (error.code) {
|
|
72
|
+
// @ts-ignore
|
|
73
|
+
this.code = error.code;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
47
77
|
|
|
48
78
|
class AssertionError extends Error {
|
|
49
79
|
constructor(message) {
|
|
@@ -112,1180 +142,515 @@ const fn = value => {
|
|
|
112
142
|
}
|
|
113
143
|
};
|
|
114
144
|
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
onDidChangeTextDocumentListeners: [],
|
|
118
|
-
/** @type{any[]} */
|
|
119
|
-
onDidSaveTextDocumentListeners: [],
|
|
120
|
-
/** @type{any[]} */
|
|
121
|
-
onWillChangeEditorListeners: [],
|
|
122
|
-
textDocuments: Object.create(null)
|
|
123
|
-
};
|
|
124
|
-
const setDocument = (textDocumentId, textDocument) => {
|
|
125
|
-
state$b.textDocuments[textDocumentId] = textDocument;
|
|
126
|
-
};
|
|
127
|
-
const getDidOpenListeners = () => {
|
|
128
|
-
return state$b.onDidSaveTextDocumentListeners;
|
|
145
|
+
const isMessagePort = value => {
|
|
146
|
+
return value && value instanceof MessagePort;
|
|
129
147
|
};
|
|
130
|
-
const
|
|
131
|
-
return
|
|
148
|
+
const isMessagePortMain = value => {
|
|
149
|
+
return value && value.constructor && value.constructor.name === 'MessagePortMain';
|
|
132
150
|
};
|
|
133
|
-
const
|
|
134
|
-
return
|
|
151
|
+
const isOffscreenCanvas = value => {
|
|
152
|
+
return typeof OffscreenCanvas !== 'undefined' && value instanceof OffscreenCanvas;
|
|
135
153
|
};
|
|
136
|
-
const
|
|
137
|
-
return
|
|
154
|
+
const isInstanceOf = (value, constructorName) => {
|
|
155
|
+
return value?.constructor?.name === constructorName;
|
|
138
156
|
};
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
let offset = 0;
|
|
142
|
-
let rowIndex = 0;
|
|
143
|
-
while (rowIndex++ < position.rowIndex) {
|
|
144
|
-
const newLineIndex = textDocument.text.indexOf('\n', offset);
|
|
145
|
-
offset = newLineIndex + 1;
|
|
146
|
-
}
|
|
147
|
-
offset += position.columnIndex;
|
|
148
|
-
return offset;
|
|
157
|
+
const isSocket = value => {
|
|
158
|
+
return isInstanceOf(value, 'Socket');
|
|
149
159
|
};
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
// return {
|
|
156
|
-
// offset,
|
|
157
|
-
// inserted: documentEdit.inserted,
|
|
158
|
-
// deleted: documentEdit.deleted,
|
|
159
|
-
// // type: /* singleLineEdit */ 1
|
|
160
|
-
// }
|
|
161
|
-
// }
|
|
162
|
-
// case /* splice */ 2:
|
|
163
|
-
// const offset = getOffset(textDocument, {
|
|
164
|
-
// rowIndex: documentEdit.rowIndex,
|
|
165
|
-
// columnIndex: textDocument.lines[documentEdit.rowIndex - 1].length,
|
|
166
|
-
// })
|
|
167
|
-
// const inserted = '\n' + documentEdit.newLines.join('\n')
|
|
168
|
-
// return {
|
|
169
|
-
// offset,
|
|
170
|
-
// inserted,
|
|
171
|
-
// deleted: 0 /* TODO */,
|
|
172
|
-
// }
|
|
173
|
-
// }
|
|
174
|
-
// }
|
|
175
|
-
|
|
176
|
-
// TODO incremental edits, don't send full text
|
|
177
|
-
// export const applyEdit = (id, text, edits) => {
|
|
178
|
-
// const textDocument = get(id)
|
|
179
|
-
// textDocument.lines = text.split('\n')
|
|
180
|
-
// const offsetBasedEdits = edits.map((edit) =>
|
|
181
|
-
// toOffsetBasedEdit(textDocument, edit)
|
|
182
|
-
// )
|
|
183
|
-
// for (const listener of state.onDidChangeTextDocumentListeners) {
|
|
184
|
-
// // TODO avoid extra object allocation
|
|
185
|
-
// listener(textDocument, offsetBasedEdits)
|
|
186
|
-
// }
|
|
187
|
-
// }
|
|
188
|
-
|
|
189
|
-
// TODO data oriented vs object oriented
|
|
190
|
-
// data -> simpler, exposes internals, sometimes weird/long (vscode.TextDocument.getText(textDocument))
|
|
191
|
-
// object oriented -> hides internals, banana problem (textDocument.getText())
|
|
192
|
-
|
|
193
|
-
// TODO send to shared process, which sends it to renderer worker
|
|
194
|
-
// renderer worker sends back the edit
|
|
195
|
-
// export const applyEdit2 = (textDocument, edit) => {
|
|
196
|
-
// if (VALIDATION_ENABLED) {
|
|
197
|
-
// assert(typeof textDocument === 'object')
|
|
198
|
-
// assert(textDocument !== null)
|
|
199
|
-
// assert(typeof textDocument.id === 'number')
|
|
200
|
-
// assert(textDocument.id > 0)
|
|
201
|
-
// assert(typeof textDocument.getText === 'function')
|
|
202
|
-
// assert(typeof edit === 'object')
|
|
203
|
-
// assert(typeof edit.offset === 'number')
|
|
204
|
-
// assert(typeof edit.inserted === 'string')
|
|
205
|
-
// assert(typeof edit.deleted === 'number')
|
|
206
|
-
// }
|
|
207
|
-
|
|
208
|
-
// let rowIndex = 0
|
|
209
|
-
// let offset = 0
|
|
210
|
-
// const lines = textDocument.getText().split('\n')
|
|
211
|
-
// while (offset < edit.offset) {
|
|
212
|
-
// offset += lines[rowIndex++].length + 1
|
|
213
|
-
// }
|
|
214
|
-
// rowIndex--
|
|
215
|
-
// offset -= lines[rowIndex].length + 1
|
|
216
|
-
// const edit2 = {
|
|
217
|
-
// rowIndex,
|
|
218
|
-
// inserted: edit.inserted,
|
|
219
|
-
// deleted: edit.deleted,
|
|
220
|
-
// columnIndex: edit.offset - offset + edit.deleted,
|
|
221
|
-
// type: 1,
|
|
222
|
-
// }
|
|
223
|
-
|
|
224
|
-
// // // TODO should be invoke and return boolean whether edit was applied or not
|
|
225
|
-
// SharedProcess.send({
|
|
226
|
-
// event: 'TextDocument.applyEdit',
|
|
227
|
-
// args: [/* id */ textDocument.id, /* edits */ edit2],
|
|
228
|
-
// })
|
|
229
|
-
// }
|
|
230
|
-
|
|
231
|
-
// export const create = (textDocumentId, languageId, content) => {
|
|
232
|
-
// const textDocument = {
|
|
233
|
-
// languageId,
|
|
234
|
-
// lines: content.split('\n'),
|
|
235
|
-
// }
|
|
236
|
-
// state.textDocuments[textDocumentId] = textDocument
|
|
237
|
-
// }
|
|
238
|
-
|
|
239
|
-
// const createTextDocument = (uri, languageId, text) => {
|
|
240
|
-
// if (VALIDATION_ENABLED) {
|
|
241
|
-
// assert(typeof uri === 'string')
|
|
242
|
-
// assert(typeof languageId === 'string')
|
|
243
|
-
// assert(typeof text === 'string')
|
|
244
|
-
// }
|
|
245
|
-
// const state = {
|
|
246
|
-
// /** @internal */
|
|
247
|
-
// lines: text.split('\n'),
|
|
248
|
-
// uri,
|
|
249
|
-
// languageId,
|
|
250
|
-
// getText() {
|
|
251
|
-
// return state.lines.join('\n')
|
|
252
|
-
// },
|
|
253
|
-
// }
|
|
254
|
-
// return state
|
|
255
|
-
// }
|
|
256
|
-
|
|
257
|
-
// export const sync = (documentId, languageId, text) => {
|
|
258
|
-
// const textDocument = get(documentId)
|
|
259
|
-
// if (!textDocument) {
|
|
260
|
-
// console.warn(`textDocument is undefined ${languageId}`)
|
|
261
|
-
// return
|
|
262
|
-
// }
|
|
263
|
-
// textDocument.languageId = languageId
|
|
264
|
-
// textDocument.lines = text.split('\n')
|
|
265
|
-
// // console.log('sync', JSON.stringify(text))
|
|
266
|
-
// }
|
|
267
|
-
|
|
268
|
-
const runListenerSafe = async (listener, ...args) => {
|
|
269
|
-
try {
|
|
270
|
-
await listener(...args);
|
|
271
|
-
} catch (error) {
|
|
272
|
-
// @ts-ignore
|
|
273
|
-
if (error && error.message) {
|
|
274
|
-
// @ts-ignore
|
|
275
|
-
error.message = 'Failed to run open listener: ' + error.message;
|
|
160
|
+
const transferrables = [isMessagePort, isMessagePortMain, isOffscreenCanvas, isSocket];
|
|
161
|
+
const isTransferrable = value => {
|
|
162
|
+
for (const fn of transferrables) {
|
|
163
|
+
if (fn(value)) {
|
|
164
|
+
return true;
|
|
276
165
|
}
|
|
277
|
-
console.error(error);
|
|
278
166
|
}
|
|
167
|
+
return false;
|
|
279
168
|
};
|
|
280
|
-
const
|
|
281
|
-
|
|
282
|
-
|
|
169
|
+
const walkValue = (value, transferrables, isTransferrable) => {
|
|
170
|
+
if (!value) {
|
|
171
|
+
return;
|
|
283
172
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
const
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
array(changes);
|
|
299
|
-
const change = changes[0];
|
|
300
|
-
const startOffset = getOffset$1(textDocument, change.start);
|
|
301
|
-
const endOffset = getOffset$1(textDocument, change.end);
|
|
302
|
-
const inserted = change.inserted.join('\n');
|
|
303
|
-
const syntheticChanges = [{
|
|
304
|
-
endOffset,
|
|
305
|
-
inserted,
|
|
306
|
-
startOffset
|
|
307
|
-
}];
|
|
308
|
-
return syntheticChanges;
|
|
309
|
-
};
|
|
310
|
-
const syncIncremental = (textDocumentId, changes) => {
|
|
311
|
-
number(textDocumentId);
|
|
312
|
-
array(changes);
|
|
313
|
-
const textDocument = getDocument(textDocumentId);
|
|
314
|
-
if (!textDocument) {
|
|
315
|
-
console.warn(`sync not possible, no matching textDocument with id ${textDocumentId}`);
|
|
173
|
+
if (isTransferrable(value)) {
|
|
174
|
+
transferrables.push(value);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (Array.isArray(value)) {
|
|
178
|
+
for (const item of value) {
|
|
179
|
+
walkValue(item, transferrables, isTransferrable);
|
|
180
|
+
}
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (typeof value === 'object') {
|
|
184
|
+
for (const property of Object.values(value)) {
|
|
185
|
+
walkValue(property, transferrables, isTransferrable);
|
|
186
|
+
}
|
|
316
187
|
return;
|
|
317
188
|
}
|
|
318
|
-
const syntheticChanges = getSyntheticChanges(textDocument, changes);
|
|
319
|
-
runListenersSafe(getWillChangeListeners(), textDocument, syntheticChanges);
|
|
320
|
-
const syntheticChange = syntheticChanges[0];
|
|
321
|
-
const oldText = textDocument.text;
|
|
322
|
-
const before = oldText.slice(0, syntheticChange.startOffset);
|
|
323
|
-
const after = oldText.slice(syntheticChange.endOffset);
|
|
324
|
-
textDocument.text = before + syntheticChange.inserted + after;
|
|
325
|
-
runListenersSafe(getDidChangeListeners(), textDocument, syntheticChanges);
|
|
326
|
-
};
|
|
327
|
-
const get$c = textDocumentId => {
|
|
328
|
-
const textDocument = getDocument(textDocumentId);
|
|
329
|
-
return textDocument;
|
|
330
189
|
};
|
|
331
|
-
const
|
|
332
|
-
|
|
190
|
+
const getTransferrables = value => {
|
|
191
|
+
const transferrables = [];
|
|
192
|
+
walkValue(value, transferrables, isTransferrable);
|
|
193
|
+
return transferrables;
|
|
333
194
|
};
|
|
334
|
-
const
|
|
335
|
-
const
|
|
336
|
-
...
|
|
337
|
-
|
|
195
|
+
const attachEvents = that => {
|
|
196
|
+
const handleMessage = (...args) => {
|
|
197
|
+
const data = that.getData(...args);
|
|
198
|
+
that.dispatchEvent(new MessageEvent('message', {
|
|
199
|
+
data
|
|
200
|
+
}));
|
|
338
201
|
};
|
|
339
|
-
|
|
340
|
-
|
|
202
|
+
that.onMessage(handleMessage);
|
|
203
|
+
const handleClose = event => {
|
|
204
|
+
that.dispatchEvent(new Event('close'));
|
|
205
|
+
};
|
|
206
|
+
that.onClose(handleClose);
|
|
341
207
|
};
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
constructor(message) {
|
|
348
|
-
super(message);
|
|
349
|
-
// @ts-ignore
|
|
350
|
-
this.code = E_NO_PROVIDER_FOUND;
|
|
208
|
+
class Ipc extends EventTarget {
|
|
209
|
+
constructor(rawIpc) {
|
|
210
|
+
super();
|
|
211
|
+
this._rawIpc = rawIpc;
|
|
212
|
+
attachEvents(this);
|
|
351
213
|
}
|
|
352
214
|
}
|
|
353
|
-
|
|
354
|
-
const
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
return 'function';
|
|
360
|
-
case 'number':
|
|
361
|
-
return 'number';
|
|
362
|
-
case 'object':
|
|
363
|
-
if (value === null) {
|
|
364
|
-
return 'null';
|
|
365
|
-
}
|
|
366
|
-
if (Array.isArray(value)) {
|
|
367
|
-
return 'array';
|
|
368
|
-
}
|
|
369
|
-
return 'object';
|
|
370
|
-
case 'string':
|
|
371
|
-
return 'string';
|
|
372
|
-
case 'undefined':
|
|
373
|
-
return 'undefined';
|
|
374
|
-
default:
|
|
375
|
-
return 'unknown';
|
|
376
|
-
}
|
|
215
|
+
const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
216
|
+
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
217
|
+
const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
|
|
218
|
+
const NewLine$2 = '\n';
|
|
219
|
+
const joinLines$1 = lines => {
|
|
220
|
+
return lines.join(NewLine$2);
|
|
377
221
|
};
|
|
378
|
-
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
|
|
222
|
+
const RE_AT = /^\s+at/;
|
|
223
|
+
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
|
224
|
+
const isNormalStackLine = line => {
|
|
225
|
+
return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
|
|
226
|
+
};
|
|
227
|
+
const getDetails = lines => {
|
|
228
|
+
const index = lines.findIndex(isNormalStackLine);
|
|
229
|
+
if (index === -1) {
|
|
230
|
+
return {
|
|
231
|
+
actualMessage: joinLines$1(lines),
|
|
232
|
+
rest: []
|
|
233
|
+
};
|
|
382
234
|
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
if (expectedType !== actualType) {
|
|
388
|
-
return `item.${key} must be of type ${expectedType}`;
|
|
235
|
+
let lastIndex = index - 1;
|
|
236
|
+
while (++lastIndex < lines.length) {
|
|
237
|
+
if (!isNormalStackLine(lines[lastIndex])) {
|
|
238
|
+
break;
|
|
389
239
|
}
|
|
390
240
|
}
|
|
391
|
-
return
|
|
241
|
+
return {
|
|
242
|
+
actualMessage: lines[index - 1],
|
|
243
|
+
rest: lines.slice(index, lastIndex)
|
|
244
|
+
};
|
|
392
245
|
};
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
const actualType = getType$1(item);
|
|
396
|
-
const expectedType = resultShape.items.type;
|
|
397
|
-
if (actualType !== expectedType) {
|
|
398
|
-
return `expected result to be of type ${expectedType} but was of type ${actualType}`;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
return undefined;
|
|
246
|
+
const splitLines$2 = lines => {
|
|
247
|
+
return lines.split(NewLine$2);
|
|
402
248
|
};
|
|
403
|
-
const
|
|
404
|
-
|
|
249
|
+
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
|
250
|
+
const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
|
|
251
|
+
const isMessageCodeBlockStartIndex = line => {
|
|
252
|
+
return RE_MESSAGE_CODE_BLOCK_START.test(line);
|
|
405
253
|
};
|
|
406
|
-
const
|
|
407
|
-
|
|
408
|
-
return '[]';
|
|
409
|
-
}
|
|
410
|
-
return 'array';
|
|
254
|
+
const isMessageCodeBlockEndIndex = line => {
|
|
255
|
+
return RE_MESSAGE_CODE_BLOCK_END.test(line);
|
|
411
256
|
};
|
|
412
|
-
const
|
|
413
|
-
|
|
257
|
+
const getMessageCodeBlock = stderr => {
|
|
258
|
+
const lines = splitLines$2(stderr);
|
|
259
|
+
const startIndex = lines.findIndex(isMessageCodeBlockStartIndex);
|
|
260
|
+
const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex, startIndex);
|
|
261
|
+
const relevantLines = lines.slice(startIndex, endIndex);
|
|
262
|
+
const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
|
|
263
|
+
return relevantMessage;
|
|
414
264
|
};
|
|
415
|
-
const
|
|
416
|
-
|
|
417
|
-
switch (type) {
|
|
418
|
-
case 'array':
|
|
419
|
-
return getPreviewArray(item);
|
|
420
|
-
case 'object':
|
|
421
|
-
return getPreviewObject();
|
|
422
|
-
case 'string':
|
|
423
|
-
return getPreviewString(item);
|
|
424
|
-
default:
|
|
425
|
-
return `${item}`;
|
|
426
|
-
}
|
|
265
|
+
const isModuleNotFoundMessage = line => {
|
|
266
|
+
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
|
427
267
|
};
|
|
428
|
-
const
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
return item;
|
|
437
|
-
}
|
|
438
|
-
const preview = getPreview(item);
|
|
439
|
-
return `item must be of type ${expectedType} but is ${preview}`;
|
|
440
|
-
}
|
|
441
|
-
switch (actualType) {
|
|
442
|
-
case 'array':
|
|
443
|
-
return validateResultArray(item, schema);
|
|
444
|
-
case 'object':
|
|
445
|
-
return validateResultObject(item, schema);
|
|
446
|
-
}
|
|
447
|
-
// TODO use json schema to validate result
|
|
448
|
-
return undefined;
|
|
268
|
+
const getModuleNotFoundError = stderr => {
|
|
269
|
+
const lines = splitLines$2(stderr);
|
|
270
|
+
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
271
|
+
const message = lines[messageIndex];
|
|
272
|
+
return {
|
|
273
|
+
code: ERR_MODULE_NOT_FOUND,
|
|
274
|
+
message
|
|
275
|
+
};
|
|
449
276
|
};
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
return line.slice('Error: '.length);
|
|
454
|
-
}
|
|
455
|
-
if (line.startsWith('VError: ')) {
|
|
456
|
-
return line.slice('VError: '.length);
|
|
277
|
+
const isModuleNotFoundError = stderr => {
|
|
278
|
+
if (!stderr) {
|
|
279
|
+
return false;
|
|
457
280
|
}
|
|
458
|
-
return
|
|
281
|
+
return stderr.includes('ERR_MODULE_NOT_FOUND');
|
|
459
282
|
};
|
|
460
|
-
const
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
return `${message}: ${stringifiedError}`;
|
|
283
|
+
const isModulesSyntaxError = stderr => {
|
|
284
|
+
if (!stderr) {
|
|
285
|
+
return false;
|
|
464
286
|
}
|
|
465
|
-
return
|
|
287
|
+
return stderr.includes('SyntaxError: Cannot use import statement outside a module');
|
|
466
288
|
};
|
|
467
|
-
const
|
|
468
|
-
const
|
|
469
|
-
|
|
289
|
+
const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
|
|
290
|
+
const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
|
|
291
|
+
const isUnhelpfulNativeModuleError = stderr => {
|
|
292
|
+
return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
|
|
470
293
|
};
|
|
471
|
-
const
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
294
|
+
const getNativeModuleErrorMessage = stderr => {
|
|
295
|
+
const message = getMessageCodeBlock(stderr);
|
|
296
|
+
return {
|
|
297
|
+
code: E_INCOMPATIBLE_NATIVE_MODULE,
|
|
298
|
+
message: `Incompatible native node module: ${message}`
|
|
299
|
+
};
|
|
300
|
+
};
|
|
301
|
+
const getModuleSyntaxError = () => {
|
|
302
|
+
return {
|
|
303
|
+
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON,
|
|
304
|
+
message: `ES Modules are not supported in electron`
|
|
305
|
+
};
|
|
306
|
+
};
|
|
307
|
+
const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
308
|
+
if (isUnhelpfulNativeModuleError(stderr)) {
|
|
309
|
+
return getNativeModuleErrorMessage(stderr);
|
|
479
310
|
}
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
const childFirstLine = normalizeLine(child.slice(0, childNewLineIndex));
|
|
483
|
-
if (parentFirstLine.includes(childFirstLine)) {
|
|
484
|
-
return parentFirstLine + childRest;
|
|
311
|
+
if (isModulesSyntaxError(stderr)) {
|
|
312
|
+
return getModuleSyntaxError();
|
|
485
313
|
}
|
|
486
|
-
|
|
314
|
+
if (isModuleNotFoundError(stderr)) {
|
|
315
|
+
return getModuleNotFoundError(stderr);
|
|
316
|
+
}
|
|
317
|
+
const lines = splitLines$2(stderr);
|
|
318
|
+
const {
|
|
319
|
+
actualMessage,
|
|
320
|
+
rest
|
|
321
|
+
} = getDetails(lines);
|
|
322
|
+
return {
|
|
323
|
+
code: '',
|
|
324
|
+
message: actualMessage,
|
|
325
|
+
stack: rest
|
|
326
|
+
};
|
|
487
327
|
};
|
|
488
|
-
class
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
this.name = 'VError';
|
|
493
|
-
if (error instanceof Error) {
|
|
494
|
-
this.stack = mergeStacks(this.stack, error.stack);
|
|
495
|
-
}
|
|
496
|
-
if (error.codeFrame) {
|
|
328
|
+
class IpcError extends VError {
|
|
329
|
+
// @ts-ignore
|
|
330
|
+
constructor(betterMessage, stdout = '', stderr = '') {
|
|
331
|
+
if (stdout || stderr) {
|
|
497
332
|
// @ts-ignore
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
333
|
+
const {
|
|
334
|
+
code,
|
|
335
|
+
message,
|
|
336
|
+
stack
|
|
337
|
+
} = getHelpfulChildProcessError(stdout, stderr);
|
|
338
|
+
const cause = new Error(message);
|
|
501
339
|
// @ts-ignore
|
|
502
|
-
|
|
340
|
+
cause.code = code;
|
|
341
|
+
cause.stack = stack;
|
|
342
|
+
super(cause, betterMessage);
|
|
343
|
+
} else {
|
|
344
|
+
super(betterMessage);
|
|
503
345
|
}
|
|
346
|
+
// @ts-ignore
|
|
347
|
+
this.name = 'IpcError';
|
|
348
|
+
// @ts-ignore
|
|
349
|
+
this.stdout = stdout;
|
|
350
|
+
// @ts-ignore
|
|
351
|
+
this.stderr = stderr;
|
|
504
352
|
}
|
|
505
353
|
}
|
|
506
|
-
|
|
507
|
-
const
|
|
508
|
-
|
|
509
|
-
const spaceOut = camelCaseWord => {
|
|
510
|
-
return camelCaseWord.replaceAll(RE_UPPERCASE_LETTER, (character, index) => {
|
|
511
|
-
if (index === 0) {
|
|
512
|
-
return character.toLowerCase();
|
|
513
|
-
}
|
|
514
|
-
return ' ' + character.toLowerCase();
|
|
515
|
-
});
|
|
354
|
+
const readyMessage = 'ready';
|
|
355
|
+
const getData$2 = event => {
|
|
356
|
+
return event.data;
|
|
516
357
|
};
|
|
517
|
-
const
|
|
518
|
-
|
|
358
|
+
const listen$8 = ({
|
|
359
|
+
port
|
|
360
|
+
}) => {
|
|
361
|
+
return port;
|
|
519
362
|
};
|
|
520
|
-
const
|
|
521
|
-
|
|
522
|
-
|
|
363
|
+
const signal$9 = port => {
|
|
364
|
+
port.postMessage(readyMessage);
|
|
365
|
+
};
|
|
366
|
+
class IpcChildWithMessagePort extends Ipc {
|
|
367
|
+
getData(event) {
|
|
368
|
+
return getData$2(event);
|
|
523
369
|
}
|
|
524
|
-
|
|
525
|
-
|
|
370
|
+
send(message) {
|
|
371
|
+
this._rawIpc.postMessage(message);
|
|
526
372
|
}
|
|
527
|
-
|
|
528
|
-
|
|
373
|
+
sendAndTransfer(message) {
|
|
374
|
+
const transfer = getTransferrables(message);
|
|
375
|
+
this._rawIpc.postMessage(message, transfer);
|
|
529
376
|
}
|
|
530
|
-
|
|
377
|
+
dispose() {
|
|
378
|
+
// ignore
|
|
379
|
+
}
|
|
380
|
+
onClose(callback) {
|
|
381
|
+
// ignore
|
|
382
|
+
}
|
|
383
|
+
onMessage(callback) {
|
|
384
|
+
this._rawIpc.addEventListener('message', callback);
|
|
385
|
+
this._rawIpc.start();
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
const wrap$g = port => {
|
|
389
|
+
return new IpcChildWithMessagePort(port);
|
|
531
390
|
};
|
|
532
|
-
const
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
return pre + ': ' + post;
|
|
391
|
+
const IpcChildWithMessagePort$1 = {
|
|
392
|
+
__proto__: null,
|
|
393
|
+
listen: listen$8,
|
|
394
|
+
signal: signal$9,
|
|
395
|
+
wrap: wrap$g
|
|
538
396
|
};
|
|
539
|
-
const
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
returnUndefinedWhenNoProviderFound
|
|
546
|
-
}) => {
|
|
547
|
-
context[`execute${name}Provider`] = async function (textDocumentId, ...params) {
|
|
548
|
-
try {
|
|
549
|
-
const textDocument = get$c(textDocumentId);
|
|
550
|
-
if (!textDocument) {
|
|
551
|
-
throw new Error(`textDocument with id ${textDocumentId} not found`);
|
|
552
|
-
}
|
|
553
|
-
const provider = providers[textDocument.languageId];
|
|
554
|
-
if (!provider) {
|
|
555
|
-
if (returnUndefinedWhenNoProviderFound) {
|
|
556
|
-
return undefined;
|
|
557
|
-
}
|
|
558
|
-
const spacedOutName = spaceOut(name);
|
|
559
|
-
throw new NoProviderFoundError(`No ${spacedOutName} provider found for ${textDocument.languageId}`);
|
|
560
|
-
}
|
|
561
|
-
const result = await provider[methodName](textDocument, ...params);
|
|
562
|
-
const error = validate(result, resultShape);
|
|
563
|
-
if (error) {
|
|
564
|
-
const improvedError = improveValidationError(name, error);
|
|
565
|
-
throw new VError(improvedError);
|
|
566
|
-
}
|
|
567
|
-
return result;
|
|
568
|
-
} catch (error) {
|
|
569
|
-
const actualError = ensureError(error);
|
|
570
|
-
const spacedOutName = spaceOut(name);
|
|
571
|
-
if (actualError && actualError.message) {
|
|
572
|
-
if (actualError.message === 'provider[methodName] is not a function') {
|
|
573
|
-
const camelCaseName = toCamelCase(name);
|
|
574
|
-
throw new VError(`Failed to execute ${spacedOutName} provider: VError: ${camelCaseName}Provider.${methodName} is not a function`);
|
|
575
|
-
}
|
|
576
|
-
throw new VError(actualError, `Failed to execute ${spacedOutName} provider`);
|
|
577
|
-
}
|
|
578
|
-
throw actualError;
|
|
579
|
-
}
|
|
580
|
-
};
|
|
397
|
+
const listen$7 = () => {
|
|
398
|
+
// @ts-ignore
|
|
399
|
+
if (typeof WorkerGlobalScope === 'undefined') {
|
|
400
|
+
throw new TypeError('module is not in web worker scope');
|
|
401
|
+
}
|
|
402
|
+
return globalThis;
|
|
581
403
|
};
|
|
582
|
-
const
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
const methodName = executeKey || (multipleResults ? `provide${name}s` : `provide${name}`);
|
|
591
|
-
const providers = Object.create(null);
|
|
592
|
-
const context = {
|
|
593
|
-
[`register${name}Provider`](provider) {
|
|
594
|
-
providers[provider.languageId] = provider;
|
|
595
|
-
},
|
|
596
|
-
getProvider(languageId) {
|
|
597
|
-
return providers[languageId];
|
|
598
|
-
},
|
|
599
|
-
reset() {
|
|
600
|
-
for (const key in providers) {
|
|
601
|
-
delete providers[key];
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
};
|
|
605
|
-
registerMethod({
|
|
606
|
-
context,
|
|
607
|
-
methodName,
|
|
608
|
-
name,
|
|
609
|
-
providers,
|
|
610
|
-
resultShape,
|
|
611
|
-
returnUndefinedWhenNoProviderFound
|
|
612
|
-
});
|
|
613
|
-
for (const method of additionalMethodNames) {
|
|
404
|
+
const signal$8 = global => {
|
|
405
|
+
global.postMessage(readyMessage);
|
|
406
|
+
};
|
|
407
|
+
class IpcChildWithModuleWorker extends Ipc {
|
|
408
|
+
getData(event) {
|
|
409
|
+
return getData$2(event);
|
|
410
|
+
}
|
|
411
|
+
send(message) {
|
|
614
412
|
// @ts-ignore
|
|
615
|
-
|
|
616
|
-
context,
|
|
617
|
-
providers,
|
|
618
|
-
...method
|
|
619
|
-
});
|
|
413
|
+
this._rawIpc.postMessage(message);
|
|
620
414
|
}
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
};
|
|
626
|
-
|
|
627
|
-
const Array$1 = 'array';
|
|
628
|
-
const Boolean$1 = 'boolean';
|
|
629
|
-
const Number = 'number';
|
|
630
|
-
const Object$1 = 'object';
|
|
631
|
-
const String$1 = 'string';
|
|
632
|
-
|
|
633
|
-
const {
|
|
634
|
-
executeBraceCompletionProvider,
|
|
635
|
-
registerBraceCompletionProvider} = create$l({
|
|
636
|
-
name: 'BraceCompletion',
|
|
637
|
-
resultShape: {
|
|
638
|
-
type: Boolean$1
|
|
415
|
+
sendAndTransfer(message) {
|
|
416
|
+
const transfer = getTransferrables(message);
|
|
417
|
+
// @ts-ignore
|
|
418
|
+
this._rawIpc.postMessage(message, transfer);
|
|
639
419
|
}
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
const {
|
|
643
|
-
executeClosingTagProvider,
|
|
644
|
-
registerClosingTagProvider
|
|
645
|
-
} = create$l({
|
|
646
|
-
name: 'ClosingTag',
|
|
647
|
-
resultShape: {
|
|
648
|
-
allowUndefined: true,
|
|
649
|
-
type: Object$1
|
|
650
|
-
},
|
|
651
|
-
returnUndefinedWhenNoProviderFound: true
|
|
652
|
-
});
|
|
653
|
-
|
|
654
|
-
const {
|
|
655
|
-
executeCodeActionProvider,
|
|
656
|
-
registerCodeActionProvider
|
|
657
|
-
} = create$l({
|
|
658
|
-
name: 'CodeAction',
|
|
659
|
-
resultShape: {
|
|
660
|
-
items: {
|
|
661
|
-
type: Object$1
|
|
662
|
-
},
|
|
663
|
-
type: Array$1
|
|
420
|
+
dispose() {
|
|
421
|
+
// ignore
|
|
664
422
|
}
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
return action.kind === 'source.organizeImports';
|
|
668
|
-
};
|
|
669
|
-
|
|
670
|
-
// TODO handle case when multiple organize imports providers are registered
|
|
671
|
-
const executeOrganizeImports = async uid => {
|
|
672
|
-
const actions = await executeCodeActionProvider(uid);
|
|
673
|
-
// @ts-ignore
|
|
674
|
-
if (!actions || actions.length === 0) {
|
|
675
|
-
return [];
|
|
423
|
+
onClose(callback) {
|
|
424
|
+
// ignore
|
|
676
425
|
}
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
if (!organizeImportsAction) {
|
|
680
|
-
return [];
|
|
426
|
+
onMessage(callback) {
|
|
427
|
+
this._rawIpc.addEventListener('message', callback);
|
|
681
428
|
}
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
return
|
|
429
|
+
}
|
|
430
|
+
const wrap$f = global => {
|
|
431
|
+
return new IpcChildWithModuleWorker(global);
|
|
685
432
|
};
|
|
686
|
-
|
|
687
|
-
const
|
|
688
|
-
|
|
433
|
+
const waitForFirstMessage = async port => {
|
|
434
|
+
const {
|
|
435
|
+
promise,
|
|
436
|
+
resolve
|
|
437
|
+
} = Promise.withResolvers();
|
|
438
|
+
port.addEventListener('message', resolve, {
|
|
439
|
+
once: true
|
|
440
|
+
});
|
|
441
|
+
const event = await promise;
|
|
442
|
+
// @ts-ignore
|
|
443
|
+
return event.data;
|
|
689
444
|
};
|
|
690
|
-
const
|
|
691
|
-
|
|
692
|
-
|
|
445
|
+
const listen$6 = async () => {
|
|
446
|
+
const parentIpcRaw = listen$7();
|
|
447
|
+
signal$8(parentIpcRaw);
|
|
448
|
+
const parentIpc = wrap$f(parentIpcRaw);
|
|
449
|
+
const firstMessage = await waitForFirstMessage(parentIpc);
|
|
450
|
+
if (firstMessage.method !== 'initialize') {
|
|
451
|
+
throw new IpcError('unexpected first message');
|
|
693
452
|
}
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
if (!command.id) {
|
|
705
|
-
throw new Error('command is missing id');
|
|
706
|
-
}
|
|
707
|
-
if (!command.execute) {
|
|
708
|
-
throw new Error('command is missing execute function');
|
|
709
|
-
}
|
|
710
|
-
if (command.id in state$a.commands) {
|
|
711
|
-
throw new Error(`command cannot be registered multiple times`);
|
|
712
|
-
}
|
|
713
|
-
state$a.commands[command.id] = command;
|
|
714
|
-
} catch (error) {
|
|
715
|
-
const commandDisplayId = getCommandDisplay(command);
|
|
716
|
-
throw new VError(error, `Failed to register command${commandDisplayId}`);
|
|
453
|
+
const type = firstMessage.params[0];
|
|
454
|
+
if (type === 'message-port') {
|
|
455
|
+
parentIpc.send({
|
|
456
|
+
id: firstMessage.id,
|
|
457
|
+
jsonrpc: '2.0',
|
|
458
|
+
result: null
|
|
459
|
+
});
|
|
460
|
+
parentIpc.dispose();
|
|
461
|
+
const port = firstMessage.params[1];
|
|
462
|
+
return port;
|
|
717
463
|
}
|
|
464
|
+
return globalThis;
|
|
718
465
|
};
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
if (!command) {
|
|
723
|
-
throw new Error(`command ${id} not found`);
|
|
724
|
-
}
|
|
725
|
-
const results = await command.execute(...args);
|
|
726
|
-
return results;
|
|
727
|
-
} catch (error) {
|
|
728
|
-
// @ts-ignore
|
|
729
|
-
if (error && error.isExpected) {
|
|
730
|
-
throw error;
|
|
731
|
-
}
|
|
732
|
-
throw new VError(error, 'Failed to execute command');
|
|
466
|
+
class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
467
|
+
getData(event) {
|
|
468
|
+
return getData$2(event);
|
|
733
469
|
}
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
const {
|
|
737
|
-
executeCommentProvider,
|
|
738
|
-
registerCommentProvider
|
|
739
|
-
} = create$l({
|
|
740
|
-
name: 'Comment',
|
|
741
|
-
resultShape() {
|
|
742
|
-
return '';
|
|
470
|
+
send(message) {
|
|
471
|
+
this._rawIpc.postMessage(message);
|
|
743
472
|
}
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
additionalMethodNames: [
|
|
752
|
-
// @ts-ignore
|
|
753
|
-
{
|
|
754
|
-
methodName: 'resolveCompletionItem',
|
|
755
|
-
name: 'resolveCompletionItem',
|
|
756
|
-
resultShape: {
|
|
757
|
-
allowUndefined: true,
|
|
758
|
-
type: Object$1
|
|
473
|
+
sendAndTransfer(message) {
|
|
474
|
+
const transfer = getTransferrables(message);
|
|
475
|
+
this._rawIpc.postMessage(message, transfer);
|
|
476
|
+
}
|
|
477
|
+
dispose() {
|
|
478
|
+
if (this._rawIpc.close) {
|
|
479
|
+
this._rawIpc.close();
|
|
759
480
|
}
|
|
760
|
-
}],
|
|
761
|
-
name: 'Completion',
|
|
762
|
-
resultShape: {
|
|
763
|
-
items: {
|
|
764
|
-
type: Object$1
|
|
765
|
-
},
|
|
766
|
-
type: Array$1
|
|
767
481
|
}
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
}
|
|
776
|
-
const
|
|
777
|
-
|
|
778
|
-
};
|
|
779
|
-
|
|
780
|
-
const isMessagePort = value => {
|
|
781
|
-
return value && value instanceof MessagePort;
|
|
782
|
-
};
|
|
783
|
-
const isMessagePortMain = value => {
|
|
784
|
-
return value && value.constructor && value.constructor.name === 'MessagePortMain';
|
|
482
|
+
onClose(callback) {
|
|
483
|
+
// ignore
|
|
484
|
+
}
|
|
485
|
+
onMessage(callback) {
|
|
486
|
+
this._rawIpc.addEventListener('message', callback);
|
|
487
|
+
this._rawIpc.start();
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
const wrap$e = port => {
|
|
491
|
+
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
785
492
|
};
|
|
786
|
-
const
|
|
787
|
-
|
|
493
|
+
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
494
|
+
__proto__: null,
|
|
495
|
+
listen: listen$6,
|
|
496
|
+
wrap: wrap$e
|
|
788
497
|
};
|
|
789
|
-
const
|
|
790
|
-
|
|
498
|
+
const Error$3 = 1;
|
|
499
|
+
const Open = 2;
|
|
500
|
+
const Close = 3;
|
|
501
|
+
const addListener = (emitter, type, callback) => {
|
|
502
|
+
if ('addEventListener' in emitter) {
|
|
503
|
+
emitter.addEventListener(type, callback);
|
|
504
|
+
} else {
|
|
505
|
+
emitter.on(type, callback);
|
|
506
|
+
}
|
|
791
507
|
};
|
|
792
|
-
const
|
|
793
|
-
|
|
508
|
+
const removeListener = (emitter, type, callback) => {
|
|
509
|
+
if ('removeEventListener' in emitter) {
|
|
510
|
+
emitter.removeEventListener(type, callback);
|
|
511
|
+
} else {
|
|
512
|
+
emitter.off(type, callback);
|
|
513
|
+
}
|
|
794
514
|
};
|
|
795
|
-
const
|
|
796
|
-
const
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
515
|
+
const getFirstEvent = (eventEmitter, eventMap) => {
|
|
516
|
+
const {
|
|
517
|
+
promise,
|
|
518
|
+
resolve
|
|
519
|
+
} = Promise.withResolvers();
|
|
520
|
+
const listenerMap = Object.create(null);
|
|
521
|
+
const cleanup = value => {
|
|
522
|
+
for (const event of Object.keys(eventMap)) {
|
|
523
|
+
removeListener(eventEmitter, event, listenerMap[event]);
|
|
800
524
|
}
|
|
525
|
+
resolve(value);
|
|
526
|
+
};
|
|
527
|
+
for (const [event, type] of Object.entries(eventMap)) {
|
|
528
|
+
const listener = event => {
|
|
529
|
+
cleanup({
|
|
530
|
+
event,
|
|
531
|
+
type
|
|
532
|
+
});
|
|
533
|
+
};
|
|
534
|
+
addListener(eventEmitter, event, listener);
|
|
535
|
+
listenerMap[event] = listener;
|
|
801
536
|
}
|
|
802
|
-
return
|
|
537
|
+
return promise;
|
|
803
538
|
};
|
|
804
|
-
const
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
539
|
+
const Message$1 = 3;
|
|
540
|
+
const create$5$1 = async ({
|
|
541
|
+
isMessagePortOpen,
|
|
542
|
+
messagePort
|
|
543
|
+
}) => {
|
|
544
|
+
if (!isMessagePort(messagePort)) {
|
|
545
|
+
throw new IpcError('port must be of type MessagePort');
|
|
811
546
|
}
|
|
812
|
-
if (
|
|
813
|
-
|
|
814
|
-
walkValue(item, transferrables, isTransferrable);
|
|
815
|
-
}
|
|
816
|
-
return;
|
|
547
|
+
if (isMessagePortOpen) {
|
|
548
|
+
return messagePort;
|
|
817
549
|
}
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
550
|
+
const eventPromise = getFirstEvent(messagePort, {
|
|
551
|
+
message: Message$1
|
|
552
|
+
});
|
|
553
|
+
messagePort.start();
|
|
554
|
+
const {
|
|
555
|
+
event,
|
|
556
|
+
type
|
|
557
|
+
} = await eventPromise;
|
|
558
|
+
if (type !== Message$1) {
|
|
559
|
+
throw new IpcError('Failed to wait for ipc message');
|
|
823
560
|
}
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
const transferrables = [];
|
|
827
|
-
walkValue(value, transferrables, isTransferrable);
|
|
828
|
-
return transferrables;
|
|
829
|
-
};
|
|
830
|
-
const attachEvents = that => {
|
|
831
|
-
const handleMessage = (...args) => {
|
|
832
|
-
const data = that.getData(...args);
|
|
833
|
-
that.dispatchEvent(new MessageEvent('message', {
|
|
834
|
-
data
|
|
835
|
-
}));
|
|
836
|
-
};
|
|
837
|
-
that.onMessage(handleMessage);
|
|
838
|
-
const handleClose = event => {
|
|
839
|
-
that.dispatchEvent(new Event('close'));
|
|
840
|
-
};
|
|
841
|
-
that.onClose(handleClose);
|
|
842
|
-
};
|
|
843
|
-
class Ipc extends EventTarget {
|
|
844
|
-
constructor(rawIpc) {
|
|
845
|
-
super();
|
|
846
|
-
this._rawIpc = rawIpc;
|
|
847
|
-
attachEvents(this);
|
|
561
|
+
if (event.data !== readyMessage) {
|
|
562
|
+
throw new IpcError('unexpected first message');
|
|
848
563
|
}
|
|
849
|
-
|
|
850
|
-
const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
851
|
-
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
852
|
-
const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
|
|
853
|
-
const NewLine$2 = '\n';
|
|
854
|
-
const joinLines$1 = lines => {
|
|
855
|
-
return lines.join(NewLine$2);
|
|
564
|
+
return messagePort;
|
|
856
565
|
};
|
|
857
|
-
const
|
|
858
|
-
|
|
859
|
-
const isNormalStackLine = line => {
|
|
860
|
-
return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
|
|
566
|
+
const signal$1 = messagePort => {
|
|
567
|
+
messagePort.start();
|
|
861
568
|
};
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
actualMessage: joinLines$1(lines),
|
|
867
|
-
rest: []
|
|
868
|
-
};
|
|
569
|
+
class IpcParentWithMessagePort extends Ipc {
|
|
570
|
+
getData = getData$2;
|
|
571
|
+
send(message) {
|
|
572
|
+
this._rawIpc.postMessage(message);
|
|
869
573
|
}
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
break;
|
|
874
|
-
}
|
|
574
|
+
sendAndTransfer(message) {
|
|
575
|
+
const transfer = getTransferrables(message);
|
|
576
|
+
this._rawIpc.postMessage(message, transfer);
|
|
875
577
|
}
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
rest: lines.slice(index, lastIndex)
|
|
879
|
-
};
|
|
880
|
-
};
|
|
881
|
-
const splitLines$2 = lines => {
|
|
882
|
-
return lines.split(NewLine$2);
|
|
883
|
-
};
|
|
884
|
-
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
|
885
|
-
const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
|
|
886
|
-
const isMessageCodeBlockStartIndex = line => {
|
|
887
|
-
return RE_MESSAGE_CODE_BLOCK_START.test(line);
|
|
888
|
-
};
|
|
889
|
-
const isMessageCodeBlockEndIndex = line => {
|
|
890
|
-
return RE_MESSAGE_CODE_BLOCK_END.test(line);
|
|
891
|
-
};
|
|
892
|
-
const getMessageCodeBlock = stderr => {
|
|
893
|
-
const lines = splitLines$2(stderr);
|
|
894
|
-
const startIndex = lines.findIndex(isMessageCodeBlockStartIndex);
|
|
895
|
-
const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex, startIndex);
|
|
896
|
-
const relevantLines = lines.slice(startIndex, endIndex);
|
|
897
|
-
const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
|
|
898
|
-
return relevantMessage;
|
|
899
|
-
};
|
|
900
|
-
const isModuleNotFoundMessage = line => {
|
|
901
|
-
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
|
902
|
-
};
|
|
903
|
-
const getModuleNotFoundError = stderr => {
|
|
904
|
-
const lines = splitLines$2(stderr);
|
|
905
|
-
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
906
|
-
const message = lines[messageIndex];
|
|
907
|
-
return {
|
|
908
|
-
code: ERR_MODULE_NOT_FOUND,
|
|
909
|
-
message
|
|
910
|
-
};
|
|
911
|
-
};
|
|
912
|
-
const isModuleNotFoundError = stderr => {
|
|
913
|
-
if (!stderr) {
|
|
914
|
-
return false;
|
|
578
|
+
dispose() {
|
|
579
|
+
this._rawIpc.close();
|
|
915
580
|
}
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
const isModulesSyntaxError = stderr => {
|
|
919
|
-
if (!stderr) {
|
|
920
|
-
return false;
|
|
581
|
+
onMessage(callback) {
|
|
582
|
+
this._rawIpc.addEventListener('message', callback);
|
|
921
583
|
}
|
|
922
|
-
|
|
923
|
-
}
|
|
924
|
-
const
|
|
925
|
-
|
|
926
|
-
const isUnhelpfulNativeModuleError = stderr => {
|
|
927
|
-
return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
|
|
584
|
+
onClose(callback) {}
|
|
585
|
+
}
|
|
586
|
+
const wrap$5 = messagePort => {
|
|
587
|
+
return new IpcParentWithMessagePort(messagePort);
|
|
928
588
|
};
|
|
929
|
-
const
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
};
|
|
589
|
+
const IpcParentWithMessagePort$1 = {
|
|
590
|
+
__proto__: null,
|
|
591
|
+
create: create$5$1,
|
|
592
|
+
signal: signal$1,
|
|
593
|
+
wrap: wrap$5
|
|
935
594
|
};
|
|
936
|
-
const
|
|
937
|
-
return
|
|
938
|
-
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON,
|
|
939
|
-
message: `ES Modules are not supported in electron`
|
|
940
|
-
};
|
|
595
|
+
const stringifyCompact = value => {
|
|
596
|
+
return JSON.stringify(value);
|
|
941
597
|
};
|
|
942
|
-
const
|
|
943
|
-
if (
|
|
944
|
-
return
|
|
945
|
-
}
|
|
946
|
-
if (isModulesSyntaxError(stderr)) {
|
|
947
|
-
return getModuleSyntaxError();
|
|
598
|
+
const parse$1 = content => {
|
|
599
|
+
if (content === 'undefined') {
|
|
600
|
+
return null;
|
|
948
601
|
}
|
|
949
|
-
|
|
950
|
-
return
|
|
602
|
+
try {
|
|
603
|
+
return JSON.parse(content);
|
|
604
|
+
} catch (error) {
|
|
605
|
+
throw new VError(error, 'failed to parse json');
|
|
951
606
|
}
|
|
952
|
-
const lines = splitLines$2(stderr);
|
|
953
|
-
const {
|
|
954
|
-
actualMessage,
|
|
955
|
-
rest
|
|
956
|
-
} = getDetails(lines);
|
|
957
|
-
return {
|
|
958
|
-
code: '',
|
|
959
|
-
message: actualMessage,
|
|
960
|
-
stack: rest
|
|
961
|
-
};
|
|
962
607
|
};
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
code,
|
|
970
|
-
message,
|
|
971
|
-
stack
|
|
972
|
-
} = getHelpfulChildProcessError(stdout, stderr);
|
|
973
|
-
const cause = new Error(message);
|
|
974
|
-
// @ts-ignore
|
|
975
|
-
cause.code = code;
|
|
976
|
-
cause.stack = stack;
|
|
977
|
-
super(cause, betterMessage);
|
|
978
|
-
} else {
|
|
979
|
-
super(betterMessage);
|
|
980
|
-
}
|
|
981
|
-
// @ts-ignore
|
|
982
|
-
this.name = 'IpcError';
|
|
983
|
-
// @ts-ignore
|
|
984
|
-
this.stdout = stdout;
|
|
985
|
-
// @ts-ignore
|
|
986
|
-
this.stderr = stderr;
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
const readyMessage = 'ready';
|
|
990
|
-
const getData$2 = event => {
|
|
991
|
-
return event.data;
|
|
608
|
+
const waitForWebSocketToBeOpen = webSocket => {
|
|
609
|
+
return getFirstEvent(webSocket, {
|
|
610
|
+
close: Close,
|
|
611
|
+
error: Error$3,
|
|
612
|
+
open: Open
|
|
613
|
+
});
|
|
992
614
|
};
|
|
993
|
-
const
|
|
994
|
-
|
|
615
|
+
const create$k = async ({
|
|
616
|
+
webSocket
|
|
995
617
|
}) => {
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
618
|
+
const firstWebSocketEvent = await waitForWebSocketToBeOpen(webSocket);
|
|
619
|
+
if (firstWebSocketEvent.type === Error$3) {
|
|
620
|
+
throw new IpcError(`WebSocket connection error`);
|
|
621
|
+
}
|
|
622
|
+
if (firstWebSocketEvent.type === Close) {
|
|
623
|
+
throw new IpcError('Websocket connection was immediately closed');
|
|
624
|
+
}
|
|
625
|
+
return webSocket;
|
|
1000
626
|
};
|
|
1001
|
-
class
|
|
627
|
+
let IpcParentWithWebSocket$1 = class IpcParentWithWebSocket extends Ipc {
|
|
1002
628
|
getData(event) {
|
|
1003
|
-
return
|
|
629
|
+
return parse$1(event.data);
|
|
1004
630
|
}
|
|
1005
631
|
send(message) {
|
|
1006
|
-
this._rawIpc.
|
|
632
|
+
this._rawIpc.send(stringifyCompact(message));
|
|
1007
633
|
}
|
|
1008
634
|
sendAndTransfer(message) {
|
|
1009
|
-
|
|
1010
|
-
this._rawIpc.postMessage(message, transfer);
|
|
635
|
+
throw new Error('sendAndTransfer not supported');
|
|
1011
636
|
}
|
|
1012
637
|
dispose() {
|
|
1013
|
-
|
|
638
|
+
this._rawIpc.close();
|
|
1014
639
|
}
|
|
1015
640
|
onClose(callback) {
|
|
1016
|
-
|
|
641
|
+
this._rawIpc.addEventListener('close', callback);
|
|
1017
642
|
}
|
|
1018
643
|
onMessage(callback) {
|
|
1019
644
|
this._rawIpc.addEventListener('message', callback);
|
|
1020
|
-
this._rawIpc.start();
|
|
1021
645
|
}
|
|
1022
|
-
}
|
|
1023
|
-
const wrap$g = port => {
|
|
1024
|
-
return new IpcChildWithMessagePort(port);
|
|
1025
646
|
};
|
|
1026
|
-
const
|
|
647
|
+
const wrap$1 = webSocket => {
|
|
648
|
+
return new IpcParentWithWebSocket$1(webSocket);
|
|
649
|
+
};
|
|
650
|
+
const IpcParentWithWebSocket$1$1 = {
|
|
1027
651
|
__proto__: null,
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
wrap: wrap$g
|
|
1031
|
-
};
|
|
1032
|
-
const listen$7 = () => {
|
|
1033
|
-
// @ts-ignore
|
|
1034
|
-
if (typeof WorkerGlobalScope === 'undefined') {
|
|
1035
|
-
throw new TypeError('module is not in web worker scope');
|
|
1036
|
-
}
|
|
1037
|
-
return globalThis;
|
|
1038
|
-
};
|
|
1039
|
-
const signal$8 = global => {
|
|
1040
|
-
global.postMessage(readyMessage);
|
|
1041
|
-
};
|
|
1042
|
-
class IpcChildWithModuleWorker extends Ipc {
|
|
1043
|
-
getData(event) {
|
|
1044
|
-
return getData$2(event);
|
|
1045
|
-
}
|
|
1046
|
-
send(message) {
|
|
1047
|
-
// @ts-ignore
|
|
1048
|
-
this._rawIpc.postMessage(message);
|
|
1049
|
-
}
|
|
1050
|
-
sendAndTransfer(message) {
|
|
1051
|
-
const transfer = getTransferrables(message);
|
|
1052
|
-
// @ts-ignore
|
|
1053
|
-
this._rawIpc.postMessage(message, transfer);
|
|
1054
|
-
}
|
|
1055
|
-
dispose() {
|
|
1056
|
-
// ignore
|
|
1057
|
-
}
|
|
1058
|
-
onClose(callback) {
|
|
1059
|
-
// ignore
|
|
1060
|
-
}
|
|
1061
|
-
onMessage(callback) {
|
|
1062
|
-
this._rawIpc.addEventListener('message', callback);
|
|
1063
|
-
}
|
|
1064
|
-
}
|
|
1065
|
-
const wrap$f = global => {
|
|
1066
|
-
return new IpcChildWithModuleWorker(global);
|
|
1067
|
-
};
|
|
1068
|
-
const waitForFirstMessage = async port => {
|
|
1069
|
-
const {
|
|
1070
|
-
promise,
|
|
1071
|
-
resolve
|
|
1072
|
-
} = Promise.withResolvers();
|
|
1073
|
-
port.addEventListener('message', resolve, {
|
|
1074
|
-
once: true
|
|
1075
|
-
});
|
|
1076
|
-
const event = await promise;
|
|
1077
|
-
// @ts-ignore
|
|
1078
|
-
return event.data;
|
|
1079
|
-
};
|
|
1080
|
-
const listen$6 = async () => {
|
|
1081
|
-
const parentIpcRaw = listen$7();
|
|
1082
|
-
signal$8(parentIpcRaw);
|
|
1083
|
-
const parentIpc = wrap$f(parentIpcRaw);
|
|
1084
|
-
const firstMessage = await waitForFirstMessage(parentIpc);
|
|
1085
|
-
if (firstMessage.method !== 'initialize') {
|
|
1086
|
-
throw new IpcError('unexpected first message');
|
|
1087
|
-
}
|
|
1088
|
-
const type = firstMessage.params[0];
|
|
1089
|
-
if (type === 'message-port') {
|
|
1090
|
-
parentIpc.send({
|
|
1091
|
-
id: firstMessage.id,
|
|
1092
|
-
jsonrpc: '2.0',
|
|
1093
|
-
result: null
|
|
1094
|
-
});
|
|
1095
|
-
parentIpc.dispose();
|
|
1096
|
-
const port = firstMessage.params[1];
|
|
1097
|
-
return port;
|
|
1098
|
-
}
|
|
1099
|
-
return globalThis;
|
|
1100
|
-
};
|
|
1101
|
-
class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
1102
|
-
getData(event) {
|
|
1103
|
-
return getData$2(event);
|
|
1104
|
-
}
|
|
1105
|
-
send(message) {
|
|
1106
|
-
this._rawIpc.postMessage(message);
|
|
1107
|
-
}
|
|
1108
|
-
sendAndTransfer(message) {
|
|
1109
|
-
const transfer = getTransferrables(message);
|
|
1110
|
-
this._rawIpc.postMessage(message, transfer);
|
|
1111
|
-
}
|
|
1112
|
-
dispose() {
|
|
1113
|
-
if (this._rawIpc.close) {
|
|
1114
|
-
this._rawIpc.close();
|
|
1115
|
-
}
|
|
1116
|
-
}
|
|
1117
|
-
onClose(callback) {
|
|
1118
|
-
// ignore
|
|
1119
|
-
}
|
|
1120
|
-
onMessage(callback) {
|
|
1121
|
-
this._rawIpc.addEventListener('message', callback);
|
|
1122
|
-
this._rawIpc.start();
|
|
1123
|
-
}
|
|
1124
|
-
}
|
|
1125
|
-
const wrap$e = port => {
|
|
1126
|
-
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
1127
|
-
};
|
|
1128
|
-
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
1129
|
-
__proto__: null,
|
|
1130
|
-
listen: listen$6,
|
|
1131
|
-
wrap: wrap$e
|
|
1132
|
-
};
|
|
1133
|
-
const Error$3 = 1;
|
|
1134
|
-
const Open = 2;
|
|
1135
|
-
const Close = 3;
|
|
1136
|
-
const addListener = (emitter, type, callback) => {
|
|
1137
|
-
if ('addEventListener' in emitter) {
|
|
1138
|
-
emitter.addEventListener(type, callback);
|
|
1139
|
-
} else {
|
|
1140
|
-
emitter.on(type, callback);
|
|
1141
|
-
}
|
|
1142
|
-
};
|
|
1143
|
-
const removeListener = (emitter, type, callback) => {
|
|
1144
|
-
if ('removeEventListener' in emitter) {
|
|
1145
|
-
emitter.removeEventListener(type, callback);
|
|
1146
|
-
} else {
|
|
1147
|
-
emitter.off(type, callback);
|
|
1148
|
-
}
|
|
1149
|
-
};
|
|
1150
|
-
const getFirstEvent = (eventEmitter, eventMap) => {
|
|
1151
|
-
const {
|
|
1152
|
-
promise,
|
|
1153
|
-
resolve
|
|
1154
|
-
} = Promise.withResolvers();
|
|
1155
|
-
const listenerMap = Object.create(null);
|
|
1156
|
-
const cleanup = value => {
|
|
1157
|
-
for (const event of Object.keys(eventMap)) {
|
|
1158
|
-
removeListener(eventEmitter, event, listenerMap[event]);
|
|
1159
|
-
}
|
|
1160
|
-
resolve(value);
|
|
1161
|
-
};
|
|
1162
|
-
for (const [event, type] of Object.entries(eventMap)) {
|
|
1163
|
-
const listener = event => {
|
|
1164
|
-
cleanup({
|
|
1165
|
-
event,
|
|
1166
|
-
type
|
|
1167
|
-
});
|
|
1168
|
-
};
|
|
1169
|
-
addListener(eventEmitter, event, listener);
|
|
1170
|
-
listenerMap[event] = listener;
|
|
1171
|
-
}
|
|
1172
|
-
return promise;
|
|
1173
|
-
};
|
|
1174
|
-
const Message$1 = 3;
|
|
1175
|
-
const create$5$1 = async ({
|
|
1176
|
-
isMessagePortOpen,
|
|
1177
|
-
messagePort
|
|
1178
|
-
}) => {
|
|
1179
|
-
if (!isMessagePort(messagePort)) {
|
|
1180
|
-
throw new IpcError('port must be of type MessagePort');
|
|
1181
|
-
}
|
|
1182
|
-
if (isMessagePortOpen) {
|
|
1183
|
-
return messagePort;
|
|
1184
|
-
}
|
|
1185
|
-
const eventPromise = getFirstEvent(messagePort, {
|
|
1186
|
-
message: Message$1
|
|
1187
|
-
});
|
|
1188
|
-
messagePort.start();
|
|
1189
|
-
const {
|
|
1190
|
-
event,
|
|
1191
|
-
type
|
|
1192
|
-
} = await eventPromise;
|
|
1193
|
-
if (type !== Message$1) {
|
|
1194
|
-
throw new IpcError('Failed to wait for ipc message');
|
|
1195
|
-
}
|
|
1196
|
-
if (event.data !== readyMessage) {
|
|
1197
|
-
throw new IpcError('unexpected first message');
|
|
1198
|
-
}
|
|
1199
|
-
return messagePort;
|
|
1200
|
-
};
|
|
1201
|
-
const signal$1 = messagePort => {
|
|
1202
|
-
messagePort.start();
|
|
1203
|
-
};
|
|
1204
|
-
class IpcParentWithMessagePort extends Ipc {
|
|
1205
|
-
getData = getData$2;
|
|
1206
|
-
send(message) {
|
|
1207
|
-
this._rawIpc.postMessage(message);
|
|
1208
|
-
}
|
|
1209
|
-
sendAndTransfer(message) {
|
|
1210
|
-
const transfer = getTransferrables(message);
|
|
1211
|
-
this._rawIpc.postMessage(message, transfer);
|
|
1212
|
-
}
|
|
1213
|
-
dispose() {
|
|
1214
|
-
this._rawIpc.close();
|
|
1215
|
-
}
|
|
1216
|
-
onMessage(callback) {
|
|
1217
|
-
this._rawIpc.addEventListener('message', callback);
|
|
1218
|
-
}
|
|
1219
|
-
onClose(callback) {}
|
|
1220
|
-
}
|
|
1221
|
-
const wrap$5 = messagePort => {
|
|
1222
|
-
return new IpcParentWithMessagePort(messagePort);
|
|
1223
|
-
};
|
|
1224
|
-
const IpcParentWithMessagePort$1 = {
|
|
1225
|
-
__proto__: null,
|
|
1226
|
-
create: create$5$1,
|
|
1227
|
-
signal: signal$1,
|
|
1228
|
-
wrap: wrap$5
|
|
1229
|
-
};
|
|
1230
|
-
const stringifyCompact = value => {
|
|
1231
|
-
return JSON.stringify(value);
|
|
1232
|
-
};
|
|
1233
|
-
const parse$1 = content => {
|
|
1234
|
-
if (content === 'undefined') {
|
|
1235
|
-
return null;
|
|
1236
|
-
}
|
|
1237
|
-
try {
|
|
1238
|
-
return JSON.parse(content);
|
|
1239
|
-
} catch (error) {
|
|
1240
|
-
throw new VError(error, 'failed to parse json');
|
|
1241
|
-
}
|
|
1242
|
-
};
|
|
1243
|
-
const waitForWebSocketToBeOpen = webSocket => {
|
|
1244
|
-
return getFirstEvent(webSocket, {
|
|
1245
|
-
close: Close,
|
|
1246
|
-
error: Error$3,
|
|
1247
|
-
open: Open
|
|
1248
|
-
});
|
|
1249
|
-
};
|
|
1250
|
-
const create$k = async ({
|
|
1251
|
-
webSocket
|
|
1252
|
-
}) => {
|
|
1253
|
-
const firstWebSocketEvent = await waitForWebSocketToBeOpen(webSocket);
|
|
1254
|
-
if (firstWebSocketEvent.type === Error$3) {
|
|
1255
|
-
throw new IpcError(`WebSocket connection error`);
|
|
1256
|
-
}
|
|
1257
|
-
if (firstWebSocketEvent.type === Close) {
|
|
1258
|
-
throw new IpcError('Websocket connection was immediately closed');
|
|
1259
|
-
}
|
|
1260
|
-
return webSocket;
|
|
1261
|
-
};
|
|
1262
|
-
let IpcParentWithWebSocket$1 = class IpcParentWithWebSocket extends Ipc {
|
|
1263
|
-
getData(event) {
|
|
1264
|
-
return parse$1(event.data);
|
|
1265
|
-
}
|
|
1266
|
-
send(message) {
|
|
1267
|
-
this._rawIpc.send(stringifyCompact(message));
|
|
1268
|
-
}
|
|
1269
|
-
sendAndTransfer(message) {
|
|
1270
|
-
throw new Error('sendAndTransfer not supported');
|
|
1271
|
-
}
|
|
1272
|
-
dispose() {
|
|
1273
|
-
this._rawIpc.close();
|
|
1274
|
-
}
|
|
1275
|
-
onClose(callback) {
|
|
1276
|
-
this._rawIpc.addEventListener('close', callback);
|
|
1277
|
-
}
|
|
1278
|
-
onMessage(callback) {
|
|
1279
|
-
this._rawIpc.addEventListener('message', callback);
|
|
1280
|
-
}
|
|
1281
|
-
};
|
|
1282
|
-
const wrap$1 = webSocket => {
|
|
1283
|
-
return new IpcParentWithWebSocket$1(webSocket);
|
|
1284
|
-
};
|
|
1285
|
-
const IpcParentWithWebSocket$1$1 = {
|
|
1286
|
-
__proto__: null,
|
|
1287
|
-
create: create$k,
|
|
1288
|
-
wrap: wrap$1
|
|
652
|
+
create: create$k,
|
|
653
|
+
wrap: wrap$1
|
|
1289
654
|
};
|
|
1290
655
|
|
|
1291
656
|
class CommandNotFoundError extends Error {
|
|
@@ -1311,7 +676,7 @@ const execute = (command, ...args) => {
|
|
|
1311
676
|
|
|
1312
677
|
const Two$1 = '2.0';
|
|
1313
678
|
const callbacks = Object.create(null);
|
|
1314
|
-
const get$
|
|
679
|
+
const get$c = id => {
|
|
1315
680
|
return callbacks[id];
|
|
1316
681
|
};
|
|
1317
682
|
const remove$5 = id => {
|
|
@@ -1460,7 +825,7 @@ const warn$1 = (...args) => {
|
|
|
1460
825
|
console.warn(...args);
|
|
1461
826
|
};
|
|
1462
827
|
const resolve = (id, response) => {
|
|
1463
|
-
const fn = get$
|
|
828
|
+
const fn = get$c(id);
|
|
1464
829
|
if (!fn) {
|
|
1465
830
|
console.log(response);
|
|
1466
831
|
warn$1(`callback ${id} may already be disposed`);
|
|
@@ -1644,9 +1009,9 @@ const create$h = (id, method, params) => {
|
|
|
1644
1009
|
return message;
|
|
1645
1010
|
};
|
|
1646
1011
|
|
|
1647
|
-
let id$
|
|
1012
|
+
let id$1 = 0;
|
|
1648
1013
|
const create$g = () => {
|
|
1649
|
-
return ++id$
|
|
1014
|
+
return ++id$1;
|
|
1650
1015
|
};
|
|
1651
1016
|
|
|
1652
1017
|
const registerPromise = map => {
|
|
@@ -1911,7 +1276,7 @@ const rpcs$2 = Object.create(null);
|
|
|
1911
1276
|
const set$d = (id, rpc) => {
|
|
1912
1277
|
rpcs$2[id] = rpc;
|
|
1913
1278
|
};
|
|
1914
|
-
const get$
|
|
1279
|
+
const get$b = id => {
|
|
1915
1280
|
return rpcs$2[id];
|
|
1916
1281
|
};
|
|
1917
1282
|
const remove$4 = id => {
|
|
@@ -1922,18 +1287,18 @@ const remove$4 = id => {
|
|
|
1922
1287
|
const create$7 = rpcId => {
|
|
1923
1288
|
return {
|
|
1924
1289
|
async dispose() {
|
|
1925
|
-
const rpc = get$
|
|
1290
|
+
const rpc = get$b(rpcId);
|
|
1926
1291
|
await rpc.dispose();
|
|
1927
1292
|
},
|
|
1928
1293
|
// @ts-ignore
|
|
1929
1294
|
invoke(method, ...params) {
|
|
1930
|
-
const rpc = get$
|
|
1295
|
+
const rpc = get$b(rpcId);
|
|
1931
1296
|
// @ts-ignore
|
|
1932
1297
|
return rpc.invoke(method, ...params);
|
|
1933
1298
|
},
|
|
1934
1299
|
// @ts-ignore
|
|
1935
1300
|
invokeAndTransfer(method, ...params) {
|
|
1936
|
-
const rpc = get$
|
|
1301
|
+
const rpc = get$b(rpcId);
|
|
1937
1302
|
// @ts-ignore
|
|
1938
1303
|
return rpc.invokeAndTransfer(method, ...params);
|
|
1939
1304
|
},
|
|
@@ -1955,51 +1320,709 @@ const create$7 = rpcId => {
|
|
|
1955
1320
|
};
|
|
1956
1321
|
};
|
|
1957
1322
|
|
|
1958
|
-
const DebugWorker$1 = 55;
|
|
1959
|
-
const ExtensionManagementWorker = 9006;
|
|
1960
|
-
const RendererWorker$1 = 1;
|
|
1323
|
+
const DebugWorker$1 = 55;
|
|
1324
|
+
const ExtensionManagementWorker = 9006;
|
|
1325
|
+
const RendererWorker$1 = 1;
|
|
1326
|
+
|
|
1327
|
+
const {
|
|
1328
|
+
invoke: invoke$6} = create$7(DebugWorker$1);
|
|
1329
|
+
|
|
1330
|
+
const DebugWorker = {
|
|
1331
|
+
__proto__: null,
|
|
1332
|
+
invoke: invoke$6
|
|
1333
|
+
};
|
|
1334
|
+
|
|
1335
|
+
const {
|
|
1336
|
+
invoke: invoke$5,
|
|
1337
|
+
invokeAndTransfer: invokeAndTransfer$3,
|
|
1338
|
+
set: set$c
|
|
1339
|
+
} = create$7(ExtensionManagementWorker);
|
|
1340
|
+
|
|
1341
|
+
const {
|
|
1342
|
+
set: set$b
|
|
1343
|
+
} = create$7(7013);
|
|
1344
|
+
|
|
1345
|
+
const {
|
|
1346
|
+
invoke: invoke$4,
|
|
1347
|
+
set: set$a
|
|
1348
|
+
} = create$7(10_000);
|
|
1349
|
+
|
|
1350
|
+
const {
|
|
1351
|
+
invoke: invoke$3,
|
|
1352
|
+
invokeAndTransfer: invokeAndTransfer$2} = create$7(RendererWorker$1);
|
|
1353
|
+
const sendMessagePortToFileSearchWorker = async (port, rpcId = 0) => {
|
|
1354
|
+
const command = 'QuickPick.handleMessagePort';
|
|
1355
|
+
await invokeAndTransfer$2('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSearchWorker', port, command, rpcId);
|
|
1356
|
+
};
|
|
1357
|
+
const sendMessagePortToQuickPickWorker = async (port, rpcId = 0) => {
|
|
1358
|
+
const command = 'QuickPick.handleMessagePort';
|
|
1359
|
+
await invokeAndTransfer$2('SendMessagePortToExtensionHostWorker.sendMessagePortToQuickPickWorker', port, command, rpcId);
|
|
1360
|
+
};
|
|
1361
|
+
const sendMessagePortToIframeWorker = async (port, rpcId) => {
|
|
1362
|
+
const command = 'Iframes.handleMessagePort';
|
|
1363
|
+
await invokeAndTransfer$2('SendMessagePortToExtensionHostWorker.sendMessagePortToIframeWorker', port, command, rpcId);
|
|
1364
|
+
};
|
|
1365
|
+
const sendMessagePortToExtensionManagementWorker = async (port, rpcId) => {
|
|
1366
|
+
const command = 'Extensions.handleMessagePort';
|
|
1367
|
+
await invokeAndTransfer$2('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
|
|
1368
|
+
};
|
|
1369
|
+
|
|
1370
|
+
const isCommandNotFoundError = error => {
|
|
1371
|
+
return error instanceof Error && error.name === 'CommandNotFoundError';
|
|
1372
|
+
};
|
|
1373
|
+
const executeCommand$2 = async (id, ...args) => {
|
|
1374
|
+
try {
|
|
1375
|
+
return await invoke$5('Extensions.executeCommand', id, ...args);
|
|
1376
|
+
} catch (error) {
|
|
1377
|
+
if (!isCommandNotFoundError(error)) {
|
|
1378
|
+
throw error;
|
|
1379
|
+
}
|
|
1380
|
+
return invoke$3(id, ...args);
|
|
1381
|
+
}
|
|
1382
|
+
};
|
|
1383
|
+
|
|
1384
|
+
class DepecratedError extends Error {
|
|
1385
|
+
constructor(message) {
|
|
1386
|
+
super(message);
|
|
1387
|
+
this.name = 'DeprecatedError';
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
const getJson$1 = async url => {
|
|
1392
|
+
throw new DepecratedError(`vscode.getJson is deprecated, use createNodeRpc instead`);
|
|
1393
|
+
};
|
|
1394
|
+
|
|
1395
|
+
class NonError extends Error {
|
|
1396
|
+
name = 'NonError';
|
|
1397
|
+
constructor(message) {
|
|
1398
|
+
super(message);
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
|
|
1402
|
+
// ensureError based on https://github.com/sindresorhus/ensure-error/blob/main/index.ts (License MIT)
|
|
1403
|
+
const ensureError = input => {
|
|
1404
|
+
if (!(input instanceof Error)) {
|
|
1405
|
+
return new NonError(input);
|
|
1406
|
+
}
|
|
1407
|
+
return input;
|
|
1408
|
+
};
|
|
1409
|
+
|
|
1410
|
+
const state$b = {
|
|
1411
|
+
/** @type{any[]} */
|
|
1412
|
+
onDidChangeTextDocumentListeners: [],
|
|
1413
|
+
/** @type{any[]} */
|
|
1414
|
+
onDidSaveTextDocumentListeners: [],
|
|
1415
|
+
/** @type{any[]} */
|
|
1416
|
+
onWillChangeEditorListeners: [],
|
|
1417
|
+
textDocuments: Object.create(null)
|
|
1418
|
+
};
|
|
1419
|
+
const setDocument = (textDocumentId, textDocument) => {
|
|
1420
|
+
state$b.textDocuments[textDocumentId] = textDocument;
|
|
1421
|
+
};
|
|
1422
|
+
const getDidOpenListeners = () => {
|
|
1423
|
+
return state$b.onDidSaveTextDocumentListeners;
|
|
1424
|
+
};
|
|
1425
|
+
const getWillChangeListeners = () => {
|
|
1426
|
+
return state$b.onWillChangeEditorListeners;
|
|
1427
|
+
};
|
|
1428
|
+
const getDidChangeListeners = () => {
|
|
1429
|
+
return state$b.onDidChangeTextDocumentListeners;
|
|
1430
|
+
};
|
|
1431
|
+
const getDocument = textDocumentId => {
|
|
1432
|
+
return state$b.textDocuments[textDocumentId];
|
|
1433
|
+
};
|
|
1434
|
+
|
|
1435
|
+
const getOffset$1 = (textDocument, position) => {
|
|
1436
|
+
let offset = 0;
|
|
1437
|
+
let rowIndex = 0;
|
|
1438
|
+
while (rowIndex++ < position.rowIndex) {
|
|
1439
|
+
const newLineIndex = textDocument.text.indexOf('\n', offset);
|
|
1440
|
+
offset = newLineIndex + 1;
|
|
1441
|
+
}
|
|
1442
|
+
offset += position.columnIndex;
|
|
1443
|
+
return offset;
|
|
1444
|
+
};
|
|
1445
|
+
|
|
1446
|
+
// const toOffsetBasedEdit = (textDocument, documentEdit) => {
|
|
1447
|
+
// switch (documentEdit.type) {
|
|
1448
|
+
// case /* singleLineEdit */ 1: {
|
|
1449
|
+
// const offset = getOffset(textDocument, documentEdit)
|
|
1450
|
+
// return {
|
|
1451
|
+
// offset,
|
|
1452
|
+
// inserted: documentEdit.inserted,
|
|
1453
|
+
// deleted: documentEdit.deleted,
|
|
1454
|
+
// // type: /* singleLineEdit */ 1
|
|
1455
|
+
// }
|
|
1456
|
+
// }
|
|
1457
|
+
// case /* splice */ 2:
|
|
1458
|
+
// const offset = getOffset(textDocument, {
|
|
1459
|
+
// rowIndex: documentEdit.rowIndex,
|
|
1460
|
+
// columnIndex: textDocument.lines[documentEdit.rowIndex - 1].length,
|
|
1461
|
+
// })
|
|
1462
|
+
// const inserted = '\n' + documentEdit.newLines.join('\n')
|
|
1463
|
+
// return {
|
|
1464
|
+
// offset,
|
|
1465
|
+
// inserted,
|
|
1466
|
+
// deleted: 0 /* TODO */,
|
|
1467
|
+
// }
|
|
1468
|
+
// }
|
|
1469
|
+
// }
|
|
1470
|
+
|
|
1471
|
+
// TODO incremental edits, don't send full text
|
|
1472
|
+
// export const applyEdit = (id, text, edits) => {
|
|
1473
|
+
// const textDocument = get(id)
|
|
1474
|
+
// textDocument.lines = text.split('\n')
|
|
1475
|
+
// const offsetBasedEdits = edits.map((edit) =>
|
|
1476
|
+
// toOffsetBasedEdit(textDocument, edit)
|
|
1477
|
+
// )
|
|
1478
|
+
// for (const listener of state.onDidChangeTextDocumentListeners) {
|
|
1479
|
+
// // TODO avoid extra object allocation
|
|
1480
|
+
// listener(textDocument, offsetBasedEdits)
|
|
1481
|
+
// }
|
|
1482
|
+
// }
|
|
1483
|
+
|
|
1484
|
+
// TODO data oriented vs object oriented
|
|
1485
|
+
// data -> simpler, exposes internals, sometimes weird/long (vscode.TextDocument.getText(textDocument))
|
|
1486
|
+
// object oriented -> hides internals, banana problem (textDocument.getText())
|
|
1487
|
+
|
|
1488
|
+
// TODO send to shared process, which sends it to renderer worker
|
|
1489
|
+
// renderer worker sends back the edit
|
|
1490
|
+
// export const applyEdit2 = (textDocument, edit) => {
|
|
1491
|
+
// if (VALIDATION_ENABLED) {
|
|
1492
|
+
// assert(typeof textDocument === 'object')
|
|
1493
|
+
// assert(textDocument !== null)
|
|
1494
|
+
// assert(typeof textDocument.id === 'number')
|
|
1495
|
+
// assert(textDocument.id > 0)
|
|
1496
|
+
// assert(typeof textDocument.getText === 'function')
|
|
1497
|
+
// assert(typeof edit === 'object')
|
|
1498
|
+
// assert(typeof edit.offset === 'number')
|
|
1499
|
+
// assert(typeof edit.inserted === 'string')
|
|
1500
|
+
// assert(typeof edit.deleted === 'number')
|
|
1501
|
+
// }
|
|
1502
|
+
|
|
1503
|
+
// let rowIndex = 0
|
|
1504
|
+
// let offset = 0
|
|
1505
|
+
// const lines = textDocument.getText().split('\n')
|
|
1506
|
+
// while (offset < edit.offset) {
|
|
1507
|
+
// offset += lines[rowIndex++].length + 1
|
|
1508
|
+
// }
|
|
1509
|
+
// rowIndex--
|
|
1510
|
+
// offset -= lines[rowIndex].length + 1
|
|
1511
|
+
// const edit2 = {
|
|
1512
|
+
// rowIndex,
|
|
1513
|
+
// inserted: edit.inserted,
|
|
1514
|
+
// deleted: edit.deleted,
|
|
1515
|
+
// columnIndex: edit.offset - offset + edit.deleted,
|
|
1516
|
+
// type: 1,
|
|
1517
|
+
// }
|
|
1518
|
+
|
|
1519
|
+
// // // TODO should be invoke and return boolean whether edit was applied or not
|
|
1520
|
+
// SharedProcess.send({
|
|
1521
|
+
// event: 'TextDocument.applyEdit',
|
|
1522
|
+
// args: [/* id */ textDocument.id, /* edits */ edit2],
|
|
1523
|
+
// })
|
|
1524
|
+
// }
|
|
1525
|
+
|
|
1526
|
+
// export const create = (textDocumentId, languageId, content) => {
|
|
1527
|
+
// const textDocument = {
|
|
1528
|
+
// languageId,
|
|
1529
|
+
// lines: content.split('\n'),
|
|
1530
|
+
// }
|
|
1531
|
+
// state.textDocuments[textDocumentId] = textDocument
|
|
1532
|
+
// }
|
|
1533
|
+
|
|
1534
|
+
// const createTextDocument = (uri, languageId, text) => {
|
|
1535
|
+
// if (VALIDATION_ENABLED) {
|
|
1536
|
+
// assert(typeof uri === 'string')
|
|
1537
|
+
// assert(typeof languageId === 'string')
|
|
1538
|
+
// assert(typeof text === 'string')
|
|
1539
|
+
// }
|
|
1540
|
+
// const state = {
|
|
1541
|
+
// /** @internal */
|
|
1542
|
+
// lines: text.split('\n'),
|
|
1543
|
+
// uri,
|
|
1544
|
+
// languageId,
|
|
1545
|
+
// getText() {
|
|
1546
|
+
// return state.lines.join('\n')
|
|
1547
|
+
// },
|
|
1548
|
+
// }
|
|
1549
|
+
// return state
|
|
1550
|
+
// }
|
|
1551
|
+
|
|
1552
|
+
// export const sync = (documentId, languageId, text) => {
|
|
1553
|
+
// const textDocument = get(documentId)
|
|
1554
|
+
// if (!textDocument) {
|
|
1555
|
+
// console.warn(`textDocument is undefined ${languageId}`)
|
|
1556
|
+
// return
|
|
1557
|
+
// }
|
|
1558
|
+
// textDocument.languageId = languageId
|
|
1559
|
+
// textDocument.lines = text.split('\n')
|
|
1560
|
+
// // console.log('sync', JSON.stringify(text))
|
|
1561
|
+
// }
|
|
1562
|
+
|
|
1563
|
+
const runListenerSafe = async (listener, ...args) => {
|
|
1564
|
+
try {
|
|
1565
|
+
await listener(...args);
|
|
1566
|
+
} catch (error) {
|
|
1567
|
+
// @ts-ignore
|
|
1568
|
+
if (error && error.message) {
|
|
1569
|
+
// @ts-ignore
|
|
1570
|
+
error.message = 'Failed to run open listener: ' + error.message;
|
|
1571
|
+
}
|
|
1572
|
+
console.error(error);
|
|
1573
|
+
}
|
|
1574
|
+
};
|
|
1575
|
+
const runListenersSafe = (listeners, ...args) => {
|
|
1576
|
+
for (const listener of listeners) {
|
|
1577
|
+
runListenerSafe(listener, ...args);
|
|
1578
|
+
}
|
|
1579
|
+
};
|
|
1580
|
+
const syncFull = (uri, textDocumentId, languageId, text) => {
|
|
1581
|
+
const textDocument = {
|
|
1582
|
+
documentId: textDocumentId,
|
|
1583
|
+
languageId,
|
|
1584
|
+
text,
|
|
1585
|
+
uri
|
|
1586
|
+
};
|
|
1587
|
+
setDocument(textDocumentId, textDocument);
|
|
1588
|
+
runListenersSafe(getDidOpenListeners(), textDocument);
|
|
1589
|
+
};
|
|
1590
|
+
const getSyntheticChanges = (textDocument, changes) => {
|
|
1591
|
+
// console.log({ textDocument, changes })
|
|
1592
|
+
object(textDocument);
|
|
1593
|
+
array(changes);
|
|
1594
|
+
const change = changes[0];
|
|
1595
|
+
const startOffset = getOffset$1(textDocument, change.start);
|
|
1596
|
+
const endOffset = getOffset$1(textDocument, change.end);
|
|
1597
|
+
const inserted = change.inserted.join('\n');
|
|
1598
|
+
const syntheticChanges = [{
|
|
1599
|
+
endOffset,
|
|
1600
|
+
inserted,
|
|
1601
|
+
startOffset
|
|
1602
|
+
}];
|
|
1603
|
+
return syntheticChanges;
|
|
1604
|
+
};
|
|
1605
|
+
const syncIncremental = (textDocumentId, changes) => {
|
|
1606
|
+
number(textDocumentId);
|
|
1607
|
+
array(changes);
|
|
1608
|
+
const textDocument = getDocument(textDocumentId);
|
|
1609
|
+
if (!textDocument) {
|
|
1610
|
+
console.warn(`sync not possible, no matching textDocument with id ${textDocumentId}`);
|
|
1611
|
+
return;
|
|
1612
|
+
}
|
|
1613
|
+
const syntheticChanges = getSyntheticChanges(textDocument, changes);
|
|
1614
|
+
runListenersSafe(getWillChangeListeners(), textDocument, syntheticChanges);
|
|
1615
|
+
const syntheticChange = syntheticChanges[0];
|
|
1616
|
+
const oldText = textDocument.text;
|
|
1617
|
+
const before = oldText.slice(0, syntheticChange.startOffset);
|
|
1618
|
+
const after = oldText.slice(syntheticChange.endOffset);
|
|
1619
|
+
textDocument.text = before + syntheticChange.inserted + after;
|
|
1620
|
+
runListenersSafe(getDidChangeListeners(), textDocument, syntheticChanges);
|
|
1621
|
+
};
|
|
1622
|
+
const get$a = textDocumentId => {
|
|
1623
|
+
const textDocument = getDocument(textDocumentId);
|
|
1624
|
+
return textDocument;
|
|
1625
|
+
};
|
|
1626
|
+
const getText$2 = textDocument => {
|
|
1627
|
+
return textDocument.text;
|
|
1628
|
+
};
|
|
1629
|
+
const setLanguageId = (textDocumentId, languageId) => {
|
|
1630
|
+
const newTextDocument = {
|
|
1631
|
+
...getDocument(textDocumentId),
|
|
1632
|
+
languageId
|
|
1633
|
+
};
|
|
1634
|
+
setDocument(textDocumentId, newTextDocument);
|
|
1635
|
+
runListenersSafe(getDidOpenListeners(), newTextDocument);
|
|
1636
|
+
};
|
|
1637
|
+
|
|
1638
|
+
const E_NO_PROVIDER_FOUND = 'E_NO_PROVIDER_FOUND';
|
|
1639
|
+
const BABEL_PARSER_SYNTAX_ERROR = 'BABEL_PARSER_SYNTAX_ERROR';
|
|
1640
|
+
|
|
1641
|
+
class NoProviderFoundError extends Error {
|
|
1642
|
+
constructor(message) {
|
|
1643
|
+
super(message);
|
|
1644
|
+
// @ts-ignore
|
|
1645
|
+
this.code = E_NO_PROVIDER_FOUND;
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
const getType$1 = value => {
|
|
1650
|
+
switch (typeof value) {
|
|
1651
|
+
case 'boolean':
|
|
1652
|
+
return 'boolean';
|
|
1653
|
+
case 'function':
|
|
1654
|
+
return 'function';
|
|
1655
|
+
case 'number':
|
|
1656
|
+
return 'number';
|
|
1657
|
+
case 'object':
|
|
1658
|
+
if (value === null) {
|
|
1659
|
+
return 'null';
|
|
1660
|
+
}
|
|
1661
|
+
if (Array.isArray(value)) {
|
|
1662
|
+
return 'array';
|
|
1663
|
+
}
|
|
1664
|
+
return 'object';
|
|
1665
|
+
case 'string':
|
|
1666
|
+
return 'string';
|
|
1667
|
+
case 'undefined':
|
|
1668
|
+
return 'undefined';
|
|
1669
|
+
default:
|
|
1670
|
+
return 'unknown';
|
|
1671
|
+
}
|
|
1672
|
+
};
|
|
1673
|
+
|
|
1674
|
+
const validateResultObject = (result, resultShape) => {
|
|
1675
|
+
if (!resultShape.properties) {
|
|
1676
|
+
return undefined;
|
|
1677
|
+
}
|
|
1678
|
+
for (const [key, value] of Object.entries(resultShape.properties)) {
|
|
1679
|
+
// @ts-ignore
|
|
1680
|
+
const expectedType = value.type;
|
|
1681
|
+
const actualType = getType$1(result[key]);
|
|
1682
|
+
if (expectedType !== actualType) {
|
|
1683
|
+
return `item.${key} must be of type ${expectedType}`;
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
return undefined;
|
|
1687
|
+
};
|
|
1688
|
+
const validateResultArray = (result, resultShape) => {
|
|
1689
|
+
for (const item of result) {
|
|
1690
|
+
const actualType = getType$1(item);
|
|
1691
|
+
const expectedType = resultShape.items.type;
|
|
1692
|
+
if (actualType !== expectedType) {
|
|
1693
|
+
return `expected result to be of type ${expectedType} but was of type ${actualType}`;
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
return undefined;
|
|
1697
|
+
};
|
|
1698
|
+
const getPreviewObject = item => {
|
|
1699
|
+
return 'object';
|
|
1700
|
+
};
|
|
1701
|
+
const getPreviewArray = item => {
|
|
1702
|
+
if (item.length === 0) {
|
|
1703
|
+
return '[]';
|
|
1704
|
+
}
|
|
1705
|
+
return 'array';
|
|
1706
|
+
};
|
|
1707
|
+
const getPreviewString = item => {
|
|
1708
|
+
return `"${item}"`;
|
|
1709
|
+
};
|
|
1710
|
+
const getPreview = item => {
|
|
1711
|
+
const type = getType$1(item);
|
|
1712
|
+
switch (type) {
|
|
1713
|
+
case 'array':
|
|
1714
|
+
return getPreviewArray(item);
|
|
1715
|
+
case 'object':
|
|
1716
|
+
return getPreviewObject();
|
|
1717
|
+
case 'string':
|
|
1718
|
+
return getPreviewString(item);
|
|
1719
|
+
default:
|
|
1720
|
+
return `${item}`;
|
|
1721
|
+
}
|
|
1722
|
+
};
|
|
1723
|
+
const validate = (item, schema) => {
|
|
1724
|
+
if (typeof schema === 'function') {
|
|
1725
|
+
return schema(item);
|
|
1726
|
+
}
|
|
1727
|
+
const actualType = getType$1(item);
|
|
1728
|
+
const expectedType = schema.type;
|
|
1729
|
+
if (actualType !== expectedType) {
|
|
1730
|
+
if (schema.allowUndefined && (item === undefined || item === null)) {
|
|
1731
|
+
return item;
|
|
1732
|
+
}
|
|
1733
|
+
const preview = getPreview(item);
|
|
1734
|
+
return `item must be of type ${expectedType} but is ${preview}`;
|
|
1735
|
+
}
|
|
1736
|
+
switch (actualType) {
|
|
1737
|
+
case 'array':
|
|
1738
|
+
return validateResultArray(item, schema);
|
|
1739
|
+
case 'object':
|
|
1740
|
+
return validateResultObject(item, schema);
|
|
1741
|
+
}
|
|
1742
|
+
// TODO use json schema to validate result
|
|
1743
|
+
return undefined;
|
|
1744
|
+
};
|
|
1745
|
+
|
|
1746
|
+
const RE_UPPERCASE_LETTER = /[A-Z]/g;
|
|
1747
|
+
const RE_PROPERTY = /item\..*must be of type/;
|
|
1748
|
+
const spaceOut = camelCaseWord => {
|
|
1749
|
+
return camelCaseWord.replaceAll(RE_UPPERCASE_LETTER, (character, index) => {
|
|
1750
|
+
if (index === 0) {
|
|
1751
|
+
return character.toLowerCase();
|
|
1752
|
+
}
|
|
1753
|
+
return ' ' + character.toLowerCase();
|
|
1754
|
+
});
|
|
1755
|
+
};
|
|
1756
|
+
const toCamelCase = string => {
|
|
1757
|
+
return string[0].toLowerCase() + string.slice(1);
|
|
1758
|
+
};
|
|
1759
|
+
const improveValidationErrorPostMessage = (validationError, camelCaseName) => {
|
|
1760
|
+
if (validationError.startsWith('item must be of type')) {
|
|
1761
|
+
return validationError.replace('item', camelCaseName);
|
|
1762
|
+
}
|
|
1763
|
+
if (validationError.startsWith('expected result to be')) {
|
|
1764
|
+
return validationError.replace('result', `${camelCaseName} item`);
|
|
1765
|
+
}
|
|
1766
|
+
if (RE_PROPERTY.test(validationError)) {
|
|
1767
|
+
return validationError.replace('item', camelCaseName);
|
|
1768
|
+
}
|
|
1769
|
+
return validationError;
|
|
1770
|
+
};
|
|
1771
|
+
const improveValidationError = (name, validationError) => {
|
|
1772
|
+
const camelCaseName = toCamelCase(name);
|
|
1773
|
+
const spacedOutName = spaceOut(name);
|
|
1774
|
+
const pre = `invalid ${spacedOutName} result`;
|
|
1775
|
+
const post = improveValidationErrorPostMessage(validationError, camelCaseName);
|
|
1776
|
+
return pre + ': ' + post;
|
|
1777
|
+
};
|
|
1778
|
+
const registerMethod = ({
|
|
1779
|
+
context,
|
|
1780
|
+
methodName,
|
|
1781
|
+
name,
|
|
1782
|
+
providers,
|
|
1783
|
+
resultShape,
|
|
1784
|
+
returnUndefinedWhenNoProviderFound
|
|
1785
|
+
}) => {
|
|
1786
|
+
context[`execute${name}Provider`] = async function (textDocumentId, ...params) {
|
|
1787
|
+
try {
|
|
1788
|
+
const textDocument = get$a(textDocumentId);
|
|
1789
|
+
if (!textDocument) {
|
|
1790
|
+
throw new Error(`textDocument with id ${textDocumentId} not found`);
|
|
1791
|
+
}
|
|
1792
|
+
const provider = providers[textDocument.languageId];
|
|
1793
|
+
if (!provider) {
|
|
1794
|
+
if (returnUndefinedWhenNoProviderFound) {
|
|
1795
|
+
return undefined;
|
|
1796
|
+
}
|
|
1797
|
+
const spacedOutName = spaceOut(name);
|
|
1798
|
+
throw new NoProviderFoundError(`No ${spacedOutName} provider found for ${textDocument.languageId}`);
|
|
1799
|
+
}
|
|
1800
|
+
const result = await provider[methodName](textDocument, ...params);
|
|
1801
|
+
const error = validate(result, resultShape);
|
|
1802
|
+
if (error) {
|
|
1803
|
+
const improvedError = improveValidationError(name, error);
|
|
1804
|
+
throw new VError(improvedError);
|
|
1805
|
+
}
|
|
1806
|
+
return result;
|
|
1807
|
+
} catch (error) {
|
|
1808
|
+
const actualError = ensureError(error);
|
|
1809
|
+
const spacedOutName = spaceOut(name);
|
|
1810
|
+
if (actualError && actualError.message) {
|
|
1811
|
+
if (actualError.message === 'provider[methodName] is not a function') {
|
|
1812
|
+
const camelCaseName = toCamelCase(name);
|
|
1813
|
+
throw new VError(`Failed to execute ${spacedOutName} provider: VError: ${camelCaseName}Provider.${methodName} is not a function`);
|
|
1814
|
+
}
|
|
1815
|
+
throw new VError(actualError, `Failed to execute ${spacedOutName} provider`);
|
|
1816
|
+
}
|
|
1817
|
+
throw actualError;
|
|
1818
|
+
}
|
|
1819
|
+
};
|
|
1820
|
+
};
|
|
1821
|
+
const create$6 = ({
|
|
1822
|
+
additionalMethodNames = [],
|
|
1823
|
+
executeKey = '',
|
|
1824
|
+
name,
|
|
1825
|
+
resultShape,
|
|
1826
|
+
returnUndefinedWhenNoProviderFound = false
|
|
1827
|
+
}) => {
|
|
1828
|
+
const multipleResults = resultShape.type === 'array';
|
|
1829
|
+
const methodName = executeKey || (multipleResults ? `provide${name}s` : `provide${name}`);
|
|
1830
|
+
const providers = Object.create(null);
|
|
1831
|
+
const context = {
|
|
1832
|
+
[`register${name}Provider`](provider) {
|
|
1833
|
+
providers[provider.languageId] = provider;
|
|
1834
|
+
},
|
|
1835
|
+
getProvider(languageId) {
|
|
1836
|
+
return providers[languageId];
|
|
1837
|
+
},
|
|
1838
|
+
getProviders() {
|
|
1839
|
+
return Object.values(providers);
|
|
1840
|
+
},
|
|
1841
|
+
reset() {
|
|
1842
|
+
for (const key in providers) {
|
|
1843
|
+
delete providers[key];
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
};
|
|
1847
|
+
registerMethod({
|
|
1848
|
+
context,
|
|
1849
|
+
methodName,
|
|
1850
|
+
name,
|
|
1851
|
+
providers,
|
|
1852
|
+
resultShape,
|
|
1853
|
+
returnUndefinedWhenNoProviderFound
|
|
1854
|
+
});
|
|
1855
|
+
for (const method of additionalMethodNames) {
|
|
1856
|
+
// @ts-ignore
|
|
1857
|
+
registerMethod({
|
|
1858
|
+
context,
|
|
1859
|
+
providers,
|
|
1860
|
+
...method
|
|
1861
|
+
});
|
|
1862
|
+
}
|
|
1863
|
+
const finalContext = {
|
|
1864
|
+
...context
|
|
1865
|
+
};
|
|
1866
|
+
return finalContext;
|
|
1867
|
+
};
|
|
1868
|
+
|
|
1869
|
+
const Array$1 = 'array';
|
|
1870
|
+
const Boolean$1 = 'boolean';
|
|
1871
|
+
const Number = 'number';
|
|
1872
|
+
const Object$1 = 'object';
|
|
1873
|
+
const String$1 = 'string';
|
|
1961
1874
|
|
|
1962
1875
|
const {
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
}
|
|
1876
|
+
executeBraceCompletionProvider,
|
|
1877
|
+
registerBraceCompletionProvider} = create$6({
|
|
1878
|
+
name: 'BraceCompletion',
|
|
1879
|
+
resultShape: {
|
|
1880
|
+
type: Boolean$1
|
|
1881
|
+
}
|
|
1882
|
+
});
|
|
1969
1883
|
|
|
1970
1884
|
const {
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1885
|
+
executeClosingTagProvider,
|
|
1886
|
+
registerClosingTagProvider
|
|
1887
|
+
} = create$6({
|
|
1888
|
+
name: 'ClosingTag',
|
|
1889
|
+
resultShape: {
|
|
1890
|
+
allowUndefined: true,
|
|
1891
|
+
type: Object$1
|
|
1892
|
+
},
|
|
1893
|
+
returnUndefinedWhenNoProviderFound: true
|
|
1894
|
+
});
|
|
1975
1895
|
|
|
1976
1896
|
const {
|
|
1977
|
-
|
|
1978
|
-
|
|
1897
|
+
executeCodeActionProvider,
|
|
1898
|
+
registerCodeActionProvider
|
|
1899
|
+
} = create$6({
|
|
1900
|
+
name: 'CodeAction',
|
|
1901
|
+
resultShape: {
|
|
1902
|
+
items: {
|
|
1903
|
+
type: Object$1
|
|
1904
|
+
},
|
|
1905
|
+
type: Array$1
|
|
1906
|
+
}
|
|
1907
|
+
});
|
|
1908
|
+
const isOrganizeImports = action => {
|
|
1909
|
+
return action.kind === 'source.organizeImports';
|
|
1910
|
+
};
|
|
1911
|
+
|
|
1912
|
+
// TODO handle case when multiple organize imports providers are registered
|
|
1913
|
+
const executeOrganizeImports = async uid => {
|
|
1914
|
+
const actions = await executeCodeActionProvider(uid);
|
|
1915
|
+
// @ts-ignore
|
|
1916
|
+
if (!actions || actions.length === 0) {
|
|
1917
|
+
return [];
|
|
1918
|
+
}
|
|
1919
|
+
// @ts-ignore
|
|
1920
|
+
const organizeImportsAction = actions.find(isOrganizeImports);
|
|
1921
|
+
if (!organizeImportsAction) {
|
|
1922
|
+
return [];
|
|
1923
|
+
}
|
|
1924
|
+
const textDocument = get$a(uid);
|
|
1925
|
+
const edits = await organizeImportsAction.execute(textDocument);
|
|
1926
|
+
return edits;
|
|
1927
|
+
};
|
|
1928
|
+
|
|
1929
|
+
const state$a = {
|
|
1930
|
+
commands: Object.create(null)
|
|
1931
|
+
};
|
|
1932
|
+
const getCommandDisplay = command => {
|
|
1933
|
+
if (command && command.id && typeof command.id === 'string') {
|
|
1934
|
+
return ` ${command.id}`;
|
|
1935
|
+
}
|
|
1936
|
+
return '';
|
|
1937
|
+
};
|
|
1938
|
+
const registerCommand = command => {
|
|
1939
|
+
try {
|
|
1940
|
+
if (!command) {
|
|
1941
|
+
if (command === null) {
|
|
1942
|
+
throw new Error(`command is null`);
|
|
1943
|
+
}
|
|
1944
|
+
throw new Error('command is not defined');
|
|
1945
|
+
}
|
|
1946
|
+
if (!command.id) {
|
|
1947
|
+
throw new Error('command is missing id');
|
|
1948
|
+
}
|
|
1949
|
+
if (!command.execute) {
|
|
1950
|
+
throw new Error('command is missing execute function');
|
|
1951
|
+
}
|
|
1952
|
+
if (command.id in state$a.commands) {
|
|
1953
|
+
throw new Error(`command cannot be registered multiple times`);
|
|
1954
|
+
}
|
|
1955
|
+
state$a.commands[command.id] = command;
|
|
1956
|
+
} catch (error) {
|
|
1957
|
+
const commandDisplayId = getCommandDisplay(command);
|
|
1958
|
+
throw new VError(error, `Failed to register command${commandDisplayId}`);
|
|
1959
|
+
}
|
|
1960
|
+
};
|
|
1961
|
+
const executeCommand$1 = async (id, ...args) => {
|
|
1962
|
+
try {
|
|
1963
|
+
const command = state$a.commands[id];
|
|
1964
|
+
if (!command) {
|
|
1965
|
+
throw new Error(`command ${id} not found`);
|
|
1966
|
+
}
|
|
1967
|
+
const results = await command.execute(...args);
|
|
1968
|
+
return results;
|
|
1969
|
+
} catch (error) {
|
|
1970
|
+
// @ts-ignore
|
|
1971
|
+
if (error && error.isExpected) {
|
|
1972
|
+
throw error;
|
|
1973
|
+
}
|
|
1974
|
+
throw new VError(error, 'Failed to execute command');
|
|
1975
|
+
}
|
|
1976
|
+
};
|
|
1977
|
+
const getRegisteredCommandIds$1 = () => {
|
|
1978
|
+
return Object.values(state$a.commands).map(command => command.id);
|
|
1979
|
+
};
|
|
1979
1980
|
|
|
1980
1981
|
const {
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
} = create$
|
|
1982
|
+
executeCommentProvider,
|
|
1983
|
+
registerCommentProvider
|
|
1984
|
+
} = create$6({
|
|
1985
|
+
name: 'Comment',
|
|
1986
|
+
resultShape() {
|
|
1987
|
+
return '';
|
|
1988
|
+
}
|
|
1989
|
+
});
|
|
1984
1990
|
|
|
1985
1991
|
const {
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1992
|
+
executeCompletionProvider,
|
|
1993
|
+
executeresolveCompletionItemProvider,
|
|
1994
|
+
getProviders: getProviders$1,
|
|
1995
|
+
registerCompletionProvider} = create$6({
|
|
1996
|
+
additionalMethodNames: [
|
|
1997
|
+
// @ts-ignore
|
|
1998
|
+
{
|
|
1999
|
+
methodName: 'resolveCompletionItem',
|
|
2000
|
+
name: 'resolveCompletionItem',
|
|
2001
|
+
resultShape: {
|
|
2002
|
+
allowUndefined: true,
|
|
2003
|
+
type: Object$1
|
|
2004
|
+
}
|
|
2005
|
+
}],
|
|
2006
|
+
name: 'Completion',
|
|
2007
|
+
resultShape: {
|
|
2008
|
+
items: {
|
|
2009
|
+
type: Object$1
|
|
2010
|
+
},
|
|
2011
|
+
type: Array$1
|
|
2012
|
+
}
|
|
2013
|
+
});
|
|
2014
|
+
const getRegisteredCompletionProviderIds$1 = () => {
|
|
2015
|
+
return getProviders$1().map(provider => provider.id);
|
|
1991
2016
|
};
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
2017
|
+
|
|
2018
|
+
const state$9 = {
|
|
2019
|
+
configuration: Object.create(null)
|
|
1995
2020
|
};
|
|
1996
|
-
const
|
|
1997
|
-
|
|
1998
|
-
await invokeAndTransfer$2('SendMessagePortToExtensionHostWorker.sendMessagePortToIframeWorker', port, command, rpcId);
|
|
2021
|
+
const getConfiguration = key => {
|
|
2022
|
+
return state$9.configuration[key] ?? '';
|
|
1999
2023
|
};
|
|
2000
|
-
const
|
|
2001
|
-
|
|
2002
|
-
await invokeAndTransfer$2('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
|
|
2024
|
+
const setConfigurations = preferences => {
|
|
2025
|
+
state$9.configuration = preferences;
|
|
2003
2026
|
};
|
|
2004
2027
|
|
|
2005
2028
|
const {
|
|
@@ -2192,7 +2215,7 @@ const setPauseOnExceptions = async (protocol, value) => {
|
|
|
2192
2215
|
|
|
2193
2216
|
const {
|
|
2194
2217
|
executeDefinitionProvider,
|
|
2195
|
-
registerDefinitionProvider} = create$
|
|
2218
|
+
registerDefinitionProvider} = create$6({
|
|
2196
2219
|
name: 'Definition',
|
|
2197
2220
|
resultShape: {
|
|
2198
2221
|
allowUndefined: true,
|
|
@@ -2214,7 +2237,7 @@ const {
|
|
|
2214
2237
|
const {
|
|
2215
2238
|
executeDiagnosticProvider,
|
|
2216
2239
|
registerDiagnosticProvider
|
|
2217
|
-
} = create$
|
|
2240
|
+
} = create$6({
|
|
2218
2241
|
name: 'Diagnostic',
|
|
2219
2242
|
resultShape: {
|
|
2220
2243
|
items: {
|
|
@@ -2227,11 +2250,11 @@ const {
|
|
|
2227
2250
|
const RendererWorker = 1;
|
|
2228
2251
|
|
|
2229
2252
|
const invoke$1 = (method, ...params) => {
|
|
2230
|
-
const rpc = get$
|
|
2253
|
+
const rpc = get$b(RendererWorker);
|
|
2231
2254
|
return rpc.invoke(method, ...params);
|
|
2232
2255
|
};
|
|
2233
2256
|
const invokeAndTransfer$1 = (method, ...params) => {
|
|
2234
|
-
const rpc = get$
|
|
2257
|
+
const rpc = get$b(RendererWorker);
|
|
2235
2258
|
return rpc.invokeAndTransfer(method, ...params);
|
|
2236
2259
|
};
|
|
2237
2260
|
|
|
@@ -2363,8 +2386,10 @@ const getPathSeparator = protocol => {
|
|
|
2363
2386
|
};
|
|
2364
2387
|
|
|
2365
2388
|
const {
|
|
2366
|
-
executeFormattingProvider,
|
|
2367
|
-
|
|
2389
|
+
executeFormattingProvider: executeRegisteredFormattingProvider,
|
|
2390
|
+
getProvider: getProvider$3,
|
|
2391
|
+
getProviders,
|
|
2392
|
+
registerFormattingProvider} = create$6({
|
|
2368
2393
|
executeKey: 'format',
|
|
2369
2394
|
name: 'Formatting',
|
|
2370
2395
|
resultShape: {
|
|
@@ -2386,6 +2411,21 @@ const {
|
|
|
2386
2411
|
type: Array$1
|
|
2387
2412
|
}
|
|
2388
2413
|
});
|
|
2414
|
+
const executeRegisteredFormattingProviderWithParams = executeRegisteredFormattingProvider;
|
|
2415
|
+
const executeFormattingProvider = async (textDocumentId, ...params) => {
|
|
2416
|
+
const textDocument = get$a(textDocumentId);
|
|
2417
|
+
if (!textDocument) {
|
|
2418
|
+
throw new VError(`Failed to execute formatting provider: textDocument with id ${textDocumentId} not found`);
|
|
2419
|
+
}
|
|
2420
|
+
const provider = getProvider$3(textDocument.languageId);
|
|
2421
|
+
if (!provider) {
|
|
2422
|
+
throw new VError(`No formatting provider found for ${textDocument.languageId}`, 'Failed to execute formatting provider');
|
|
2423
|
+
}
|
|
2424
|
+
return executeRegisteredFormattingProviderWithParams(textDocumentId, ...params);
|
|
2425
|
+
};
|
|
2426
|
+
const getRegisteredFormattingProviderIds$1 = () => {
|
|
2427
|
+
return getProviders().map(provider => provider.id);
|
|
2428
|
+
};
|
|
2389
2429
|
|
|
2390
2430
|
const getOffset = (textDocument, position) => {
|
|
2391
2431
|
let offset = 0;
|
|
@@ -2425,7 +2465,7 @@ const getPosition = (textDocument, offset) => {
|
|
|
2425
2465
|
|
|
2426
2466
|
const {
|
|
2427
2467
|
executeHoverProvider,
|
|
2428
|
-
registerHoverProvider} = create$
|
|
2468
|
+
registerHoverProvider} = create$6({
|
|
2429
2469
|
name: 'Hover',
|
|
2430
2470
|
resultShape: {
|
|
2431
2471
|
allowUndefined: true,
|
|
@@ -2436,7 +2476,7 @@ const {
|
|
|
2436
2476
|
|
|
2437
2477
|
const {
|
|
2438
2478
|
executeImplementationProvider,
|
|
2439
|
-
registerImplementationProvider} = create$
|
|
2479
|
+
registerImplementationProvider} = create$6({
|
|
2440
2480
|
name: 'Implementation',
|
|
2441
2481
|
resultShape: {
|
|
2442
2482
|
items: {
|
|
@@ -2476,7 +2516,7 @@ const sendPort = async ({
|
|
|
2476
2516
|
url
|
|
2477
2517
|
});
|
|
2478
2518
|
};
|
|
2479
|
-
const create$
|
|
2519
|
+
const create$5 = async ({
|
|
2480
2520
|
commandMap,
|
|
2481
2521
|
name,
|
|
2482
2522
|
url
|
|
@@ -2505,7 +2545,7 @@ const create$6 = async ({
|
|
|
2505
2545
|
|
|
2506
2546
|
const IpcParentWithModuleWorkerAndWorkaroundForChromeDevtoolsBug = {
|
|
2507
2547
|
__proto__: null,
|
|
2508
|
-
create: create$
|
|
2548
|
+
create: create$5
|
|
2509
2549
|
};
|
|
2510
2550
|
|
|
2511
2551
|
const sendMessagePortToElectron = async (port, initialCommand) => {
|
|
@@ -2520,7 +2560,7 @@ const getPort = async type => {
|
|
|
2520
2560
|
await sendMessagePortToElectron(port1, 'HandleMessagePortForExtensionHostHelperProcess.handleMessagePortForExtensionHostHelperProcess');
|
|
2521
2561
|
return port2;
|
|
2522
2562
|
};
|
|
2523
|
-
const create$
|
|
2563
|
+
const create$4 = async ({
|
|
2524
2564
|
type
|
|
2525
2565
|
}) => {
|
|
2526
2566
|
const port = await getPort();
|
|
@@ -2536,7 +2576,7 @@ const create$5 = async ({
|
|
|
2536
2576
|
|
|
2537
2577
|
const IpcParentWithElectronMessagePort = {
|
|
2538
2578
|
__proto__: null,
|
|
2539
|
-
create: create$
|
|
2579
|
+
create: create$4
|
|
2540
2580
|
};
|
|
2541
2581
|
|
|
2542
2582
|
const getWebSocketProtocol = () => {
|
|
@@ -2548,7 +2588,7 @@ const getWebSocketUrl = (type, host) => {
|
|
|
2548
2588
|
return `${wsProtocol}//${host}/websocket/${type}`;
|
|
2549
2589
|
};
|
|
2550
2590
|
|
|
2551
|
-
const create$
|
|
2591
|
+
const create$3 = async ({
|
|
2552
2592
|
type
|
|
2553
2593
|
}) => {
|
|
2554
2594
|
string(type);
|
|
@@ -2563,7 +2603,7 @@ const create$4 = async ({
|
|
|
2563
2603
|
|
|
2564
2604
|
const IpcParentWithWebSocket = {
|
|
2565
2605
|
__proto__: null,
|
|
2566
|
-
create: create$
|
|
2606
|
+
create: create$3
|
|
2567
2607
|
};
|
|
2568
2608
|
|
|
2569
2609
|
const Electron = 'electron';
|
|
@@ -2600,7 +2640,7 @@ const getModule$1 = platform => {
|
|
|
2600
2640
|
return IpcParentWithElectronMessagePort;
|
|
2601
2641
|
}
|
|
2602
2642
|
};
|
|
2603
|
-
const create$
|
|
2643
|
+
const create$2 = async ({
|
|
2604
2644
|
raw,
|
|
2605
2645
|
type
|
|
2606
2646
|
}) => {
|
|
@@ -2613,7 +2653,7 @@ const create$3 = async ({
|
|
|
2613
2653
|
|
|
2614
2654
|
const IpcParentWithNode = {
|
|
2615
2655
|
__proto__: null,
|
|
2616
|
-
create: create$
|
|
2656
|
+
create: create$2
|
|
2617
2657
|
};
|
|
2618
2658
|
|
|
2619
2659
|
const getModule = method => {
|
|
@@ -2629,7 +2669,7 @@ const getModule = method => {
|
|
|
2629
2669
|
}
|
|
2630
2670
|
};
|
|
2631
2671
|
|
|
2632
|
-
const create$
|
|
2672
|
+
const create$1 = async ({
|
|
2633
2673
|
method,
|
|
2634
2674
|
...options
|
|
2635
2675
|
}) => {
|
|
@@ -2654,7 +2694,7 @@ const createNodeRpc = async ({
|
|
|
2654
2694
|
try {
|
|
2655
2695
|
string(path);
|
|
2656
2696
|
fn(execute);
|
|
2657
|
-
const rpc = await create$
|
|
2697
|
+
const rpc = await create$1({
|
|
2658
2698
|
commandMap: {},
|
|
2659
2699
|
method: ElectronMessagePort,
|
|
2660
2700
|
name,
|
|
@@ -2754,11 +2794,6 @@ const confirm = message => {
|
|
|
2754
2794
|
return result;
|
|
2755
2795
|
};
|
|
2756
2796
|
|
|
2757
|
-
let id$1 = 0;
|
|
2758
|
-
const create$1 = () => {
|
|
2759
|
-
return ++id$1;
|
|
2760
|
-
};
|
|
2761
|
-
|
|
2762
2797
|
const validateQuickPickItem = item => {
|
|
2763
2798
|
if (!item || typeof item !== 'object') {
|
|
2764
2799
|
throw new TypeError('quick pick item must be an object');
|
|
@@ -2788,47 +2823,12 @@ const showQuickPick = async ({
|
|
|
2788
2823
|
placeholder
|
|
2789
2824
|
});
|
|
2790
2825
|
};
|
|
2791
|
-
const quickInputs = Object.create(null);
|
|
2792
|
-
const renderQuickInput = async (id, searchValue) => {
|
|
2793
|
-
const render = quickInputs[id];
|
|
2794
|
-
if (!render) {
|
|
2795
|
-
return [];
|
|
2796
|
-
}
|
|
2797
|
-
return render(searchValue);
|
|
2798
|
-
};
|
|
2799
|
-
const showQuickInput = async ({
|
|
2800
|
-
ignoreFocusOut,
|
|
2801
|
-
initialValue,
|
|
2802
|
-
render
|
|
2803
|
-
}) => {
|
|
2804
|
-
const id = create$1();
|
|
2805
|
-
quickInputs[id] = render;
|
|
2806
|
-
const initialItems = await render('');
|
|
2807
|
-
// TODO create direct connection to file search worker
|
|
2808
|
-
const {
|
|
2809
|
-
canceled,
|
|
2810
|
-
inputValue
|
|
2811
|
-
} = await invoke$4('QuickPick.showQuickInput', {
|
|
2812
|
-
id,
|
|
2813
|
-
ignoreFocusOut,
|
|
2814
|
-
initialItems,
|
|
2815
|
-
initialValue
|
|
2816
|
-
});
|
|
2817
|
-
try {
|
|
2818
|
-
return {
|
|
2819
|
-
canceled,
|
|
2820
|
-
inputValue
|
|
2821
|
-
};
|
|
2822
|
-
} finally {
|
|
2823
|
-
delete quickInputs[id];
|
|
2824
|
-
}
|
|
2825
|
-
};
|
|
2826
2826
|
|
|
2827
2827
|
const {
|
|
2828
2828
|
executefileReferenceProvider,
|
|
2829
2829
|
executeReferenceProvider,
|
|
2830
2830
|
getProvider: getProvider$2,
|
|
2831
|
-
registerReferenceProvider} = create$
|
|
2831
|
+
registerReferenceProvider} = create$6({
|
|
2832
2832
|
additionalMethodNames: [
|
|
2833
2833
|
// @ts-ignore
|
|
2834
2834
|
{
|
|
@@ -2890,7 +2890,7 @@ const validateResult = renameResult => {
|
|
|
2890
2890
|
const {
|
|
2891
2891
|
executeprepareRenameProvider,
|
|
2892
2892
|
executeRenameProvider,
|
|
2893
|
-
registerRenameProvider} = create$
|
|
2893
|
+
registerRenameProvider} = create$6({
|
|
2894
2894
|
additionalMethodNames: [
|
|
2895
2895
|
// @ts-ignore
|
|
2896
2896
|
{
|
|
@@ -2932,7 +2932,7 @@ const createLegacyRpc = async ({
|
|
|
2932
2932
|
if (contentSecurityPolicy) {
|
|
2933
2933
|
await set$8(url, contentSecurityPolicy);
|
|
2934
2934
|
}
|
|
2935
|
-
const rpc = await create$
|
|
2935
|
+
const rpc = await create$1({
|
|
2936
2936
|
commandMap,
|
|
2937
2937
|
method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug$1,
|
|
2938
2938
|
name,
|
|
@@ -2972,7 +2972,7 @@ const createRpcWithId$1 = async (id, commandMap, execute) => {
|
|
|
2972
2972
|
if (!info) {
|
|
2973
2973
|
throw new Error(`rpc with id ${id} not found`);
|
|
2974
2974
|
}
|
|
2975
|
-
const rpc = await create$
|
|
2975
|
+
const rpc = await create$1({
|
|
2976
2976
|
commandMap,
|
|
2977
2977
|
isMessagePortOpen: true,
|
|
2978
2978
|
method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug$1,
|
|
@@ -3047,7 +3047,7 @@ const createRpc = ({
|
|
|
3047
3047
|
|
|
3048
3048
|
const {
|
|
3049
3049
|
executeSelectionProvider,
|
|
3050
|
-
registerSelectionProvider} = create$
|
|
3050
|
+
registerSelectionProvider} = create$6({
|
|
3051
3051
|
name: 'Selection',
|
|
3052
3052
|
resultShape: {
|
|
3053
3053
|
allowUndefined: true,
|
|
@@ -3443,7 +3443,7 @@ const registerStatuBarItemProvider = provider => {
|
|
|
3443
3443
|
|
|
3444
3444
|
const {
|
|
3445
3445
|
executeTabCompletionProvider,
|
|
3446
|
-
registerTabCompletionProvider} = create$
|
|
3446
|
+
registerTabCompletionProvider} = create$6({
|
|
3447
3447
|
name: 'TabCompletion',
|
|
3448
3448
|
resultShape: {
|
|
3449
3449
|
allowUndefined: true,
|
|
@@ -3482,7 +3482,7 @@ const executeTextSearchProvider = async (scheme, query) => {
|
|
|
3482
3482
|
|
|
3483
3483
|
const {
|
|
3484
3484
|
executeTypeDefinitionProvider,
|
|
3485
|
-
registerTypeDefinitionProvider} = create$
|
|
3485
|
+
registerTypeDefinitionProvider} = create$6({
|
|
3486
3486
|
name: 'TypeDefinition',
|
|
3487
3487
|
resultShape: {
|
|
3488
3488
|
allowUndefined: true,
|
|
@@ -3586,7 +3586,7 @@ const createWorker = async ({
|
|
|
3586
3586
|
string(method);
|
|
3587
3587
|
string(url);
|
|
3588
3588
|
string(name);
|
|
3589
|
-
const rpc = create$
|
|
3589
|
+
const rpc = create$1({
|
|
3590
3590
|
method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug$1,
|
|
3591
3591
|
name,
|
|
3592
3592
|
url
|
|
@@ -3643,7 +3643,7 @@ const api = {
|
|
|
3643
3643
|
// Comment
|
|
3644
3644
|
|
|
3645
3645
|
executeClosingTagProvider: executeClosingTagProvider,
|
|
3646
|
-
executeCommand: executeCommand$
|
|
3646
|
+
executeCommand: executeCommand$2,
|
|
3647
3647
|
executeCommentProvider: executeCommentProvider,
|
|
3648
3648
|
executeCompletionProvider: executeCompletionProvider,
|
|
3649
3649
|
executeDefinitionProvider: executeDefinitionProvider,
|
|
@@ -3729,7 +3729,6 @@ const api = {
|
|
|
3729
3729
|
// Dialog
|
|
3730
3730
|
showInformationMessage: showInformationMessage,
|
|
3731
3731
|
// QuickPick
|
|
3732
|
-
showQuickInput: showQuickInput,
|
|
3733
3732
|
showQuickPick: showQuickPick,
|
|
3734
3733
|
stat: statExternal,
|
|
3735
3734
|
TextSearchResultType,
|
|
@@ -4228,6 +4227,94 @@ const tryToGetActualImportErrorMessage = async (url, error) => {
|
|
|
4228
4227
|
}
|
|
4229
4228
|
};
|
|
4230
4229
|
|
|
4230
|
+
const getManifestCommandIds = extension => {
|
|
4231
|
+
if (!Array.isArray(extension.commands)) {
|
|
4232
|
+
return [];
|
|
4233
|
+
}
|
|
4234
|
+
return extension.commands.map(command => command.id).filter(id => typeof id === 'string');
|
|
4235
|
+
};
|
|
4236
|
+
const getManifestFormattingProviderIds = extension => {
|
|
4237
|
+
if (!Array.isArray(extension.formattingProviders)) {
|
|
4238
|
+
return [];
|
|
4239
|
+
}
|
|
4240
|
+
return extension.formattingProviders.map(provider => provider.id).filter(id => typeof id === 'string');
|
|
4241
|
+
};
|
|
4242
|
+
const getManifestCompletionProviderIds = extension => {
|
|
4243
|
+
if (!Array.isArray(extension.completionProviders)) {
|
|
4244
|
+
return [];
|
|
4245
|
+
}
|
|
4246
|
+
return extension.completionProviders.map(provider => provider.id).filter(id => typeof id === 'string');
|
|
4247
|
+
};
|
|
4248
|
+
const assertUniqueIds = (ids, label) => {
|
|
4249
|
+
const seen = new Set();
|
|
4250
|
+
for (const id of ids) {
|
|
4251
|
+
if (seen.has(id)) {
|
|
4252
|
+
throw new Error(`${label} ${id} is contributed multiple times`);
|
|
4253
|
+
}
|
|
4254
|
+
seen.add(id);
|
|
4255
|
+
}
|
|
4256
|
+
};
|
|
4257
|
+
const getNewRegisteredCommandIds = beforeCommandIds => {
|
|
4258
|
+
const before = new Set(beforeCommandIds);
|
|
4259
|
+
return getRegisteredCommandIds$1().filter(commandId => !before.has(commandId));
|
|
4260
|
+
};
|
|
4261
|
+
const getNewRegisteredFormattingProviderIds = beforeFormattingProviderIds => {
|
|
4262
|
+
const before = new Set(beforeFormattingProviderIds);
|
|
4263
|
+
return getRegisteredFormattingProviderIds$1().filter(providerId => !before.has(providerId));
|
|
4264
|
+
};
|
|
4265
|
+
const getNewRegisteredCompletionProviderIds = beforeCompletionProviderIds => {
|
|
4266
|
+
const before = new Set(beforeCompletionProviderIds);
|
|
4267
|
+
return getRegisteredCompletionProviderIds$1().filter(providerId => !before.has(providerId));
|
|
4268
|
+
};
|
|
4269
|
+
const getRegisteredCommandIds = () => {
|
|
4270
|
+
return getRegisteredCommandIds$1();
|
|
4271
|
+
};
|
|
4272
|
+
const getRegisteredCompletionProviderIds = () => {
|
|
4273
|
+
return getRegisteredCompletionProviderIds$1();
|
|
4274
|
+
};
|
|
4275
|
+
const getRegisteredFormattingProviderIds = () => {
|
|
4276
|
+
return getRegisteredFormattingProviderIds$1();
|
|
4277
|
+
};
|
|
4278
|
+
const validateIsolatedExtensionContribution = (label, manifestIds, registeredIds) => {
|
|
4279
|
+
assertUniqueIds(manifestIds, label);
|
|
4280
|
+
const manifestIdSet = new Set(manifestIds);
|
|
4281
|
+
const registeredIdSet = new Set(registeredIds);
|
|
4282
|
+
for (const registeredId of registeredIds) {
|
|
4283
|
+
if (!manifestIdSet.has(registeredId)) {
|
|
4284
|
+
throw new Error(`${label} ${registeredId} is registered but not contributed in extension.json`);
|
|
4285
|
+
}
|
|
4286
|
+
}
|
|
4287
|
+
for (const manifestId of manifestIds) {
|
|
4288
|
+
if (!registeredIdSet.has(manifestId)) {
|
|
4289
|
+
throw new Error(`${label} ${manifestId} is contributed in extension.json but not registered`);
|
|
4290
|
+
}
|
|
4291
|
+
}
|
|
4292
|
+
};
|
|
4293
|
+
const validateIsolatedExtensionCommands = (extension, beforeCommandIds) => {
|
|
4294
|
+
if (!extension.isolated) {
|
|
4295
|
+
return;
|
|
4296
|
+
}
|
|
4297
|
+
const manifestCommandIds = getManifestCommandIds(extension);
|
|
4298
|
+
const registeredCommandIds = getNewRegisteredCommandIds(beforeCommandIds);
|
|
4299
|
+
validateIsolatedExtensionContribution('command', manifestCommandIds, registeredCommandIds);
|
|
4300
|
+
};
|
|
4301
|
+
const validateIsolatedExtensionCompletionProviders = (extension, beforeCompletionProviderIds) => {
|
|
4302
|
+
if (!extension.isolated) {
|
|
4303
|
+
return;
|
|
4304
|
+
}
|
|
4305
|
+
const manifestCompletionProviderIds = getManifestCompletionProviderIds(extension);
|
|
4306
|
+
const registeredCompletionProviderIds = getNewRegisteredCompletionProviderIds(beforeCompletionProviderIds);
|
|
4307
|
+
validateIsolatedExtensionContribution('completion provider', manifestCompletionProviderIds, registeredCompletionProviderIds);
|
|
4308
|
+
};
|
|
4309
|
+
const validateIsolatedExtensionFormattingProviders = (extension, beforeFormattingProviderIds) => {
|
|
4310
|
+
if (!extension.isolated) {
|
|
4311
|
+
return;
|
|
4312
|
+
}
|
|
4313
|
+
const manifestFormattingProviderIds = getManifestFormattingProviderIds(extension);
|
|
4314
|
+
const registeredFormattingProviderIds = getNewRegisteredFormattingProviderIds(beforeFormattingProviderIds);
|
|
4315
|
+
validateIsolatedExtensionContribution('formatting provider', manifestFormattingProviderIds, registeredFormattingProviderIds);
|
|
4316
|
+
};
|
|
4317
|
+
|
|
4231
4318
|
// TODO make activation timeout configurable or remove it.
|
|
4232
4319
|
// some extension might do workspace indexing which could take some time
|
|
4233
4320
|
const activationTimeout$1 = 10_000;
|
|
@@ -4247,7 +4334,14 @@ const activateExtension2 = async (extensionId, extension, absolutePath) => {
|
|
|
4247
4334
|
status: Activating
|
|
4248
4335
|
});
|
|
4249
4336
|
const module = acquire(extensionId);
|
|
4250
|
-
|
|
4337
|
+
const activate = module.main || module.activate;
|
|
4338
|
+
const beforeCommandIds = getRegisteredCommandIds();
|
|
4339
|
+
const beforeCompletionProviderIds = getRegisteredCompletionProviderIds();
|
|
4340
|
+
const beforeFormattingProviderIds = getRegisteredFormattingProviderIds();
|
|
4341
|
+
await Promise.race([activate(extension), rejectAfterTimeout$1(activationTimeout$1, token)]);
|
|
4342
|
+
validateIsolatedExtensionCommands(extension, beforeCommandIds);
|
|
4343
|
+
validateIsolatedExtensionCompletionProviders(extension, beforeCompletionProviderIds);
|
|
4344
|
+
validateIsolatedExtensionFormattingProviders(extension, beforeFormattingProviderIds);
|
|
4251
4345
|
const endTime = performance.now();
|
|
4252
4346
|
const time = endTime - startTime;
|
|
4253
4347
|
update(extensionId, {
|
|
@@ -4275,6 +4369,10 @@ const activateExtension3 = async (extensionId, extension) => {
|
|
|
4275
4369
|
if (!module) {
|
|
4276
4370
|
throw new Error(`extension module ${extensionId} not found`);
|
|
4277
4371
|
}
|
|
4372
|
+
if (module.main) {
|
|
4373
|
+
await module.main(extension);
|
|
4374
|
+
return;
|
|
4375
|
+
}
|
|
4278
4376
|
await module.activate(extension);
|
|
4279
4377
|
};
|
|
4280
4378
|
|
|
@@ -4376,7 +4474,8 @@ const activateExtension = async (extension, absolutePath, activationEvent) => {
|
|
|
4376
4474
|
});
|
|
4377
4475
|
const token = create();
|
|
4378
4476
|
try {
|
|
4379
|
-
|
|
4477
|
+
const activate = module.main || module.activate;
|
|
4478
|
+
await Promise.race([activate(extension), rejectAfterTimeout(activationTimeout, token)]);
|
|
4380
4479
|
const endTime = performance.now();
|
|
4381
4480
|
const time = endTime - startTime;
|
|
4382
4481
|
update(extensionId, {
|
|
@@ -5683,6 +5782,13 @@ const handleBeforeUnload = () => {
|
|
|
5683
5782
|
// console.log('before unload')
|
|
5684
5783
|
};
|
|
5685
5784
|
|
|
5785
|
+
const handleExtensionManagementMessagePort = async port => {
|
|
5786
|
+
await create$b({
|
|
5787
|
+
commandMap: commandMap,
|
|
5788
|
+
messagePort: port
|
|
5789
|
+
});
|
|
5790
|
+
};
|
|
5791
|
+
|
|
5686
5792
|
const handleMessagePort2 = async (port, rpcId) => {
|
|
5687
5793
|
const rpc = await create$9({
|
|
5688
5794
|
commandMap: {},
|
|
@@ -6322,6 +6428,7 @@ const commandMap = {
|
|
|
6322
6428
|
'ColorTheme.getColorThemeJson': getColorThemeJson,
|
|
6323
6429
|
'ColorTheme.getColorThemeNames': getColorThemeNames,
|
|
6324
6430
|
'ColorTheme.hydrate': hydrate$1,
|
|
6431
|
+
'Commands.executeCommand': executeCommand$2,
|
|
6325
6432
|
'ExecuteExternalCommand.executeExternalCommand': executeExternalCommand,
|
|
6326
6433
|
'ExtensionHost.activateExtension2': activateExtension2,
|
|
6327
6434
|
'ExtensionHost.activateExtension3': activateExtension3,
|
|
@@ -6395,7 +6502,7 @@ const commandMap = {
|
|
|
6395
6502
|
'ExtensionHostDebug.stepInto': stepInto,
|
|
6396
6503
|
'ExtensionHostDebug.stepOut': stepOut,
|
|
6397
6504
|
'ExtensionHostDebug.stepOver': stepOver,
|
|
6398
|
-
'ExtensionHostQuickPick.
|
|
6505
|
+
'ExtensionHostQuickPick.showQuickPick': showQuickPick,
|
|
6399
6506
|
'ExtensionHostRename.executeprepareRenameProvider': executeprepareRenameProvider,
|
|
6400
6507
|
'ExtensionHostRename.executeRenameProvider': executeRenameProvider,
|
|
6401
6508
|
'ExtensionHostSourceControl.getIconDefinitions': getIconDefinitions,
|
|
@@ -6430,6 +6537,7 @@ const commandMap = {
|
|
|
6430
6537
|
'FileSystemMemory.stat': stat,
|
|
6431
6538
|
'FileSystemMemory.writeFile': writeFile,
|
|
6432
6539
|
'HandleBeforeUnload.handleBeforeUnload': handleBeforeUnload,
|
|
6540
|
+
'HandleMessagePort.handleExtensionManagementMessagePort': handleExtensionManagementMessagePort,
|
|
6433
6541
|
'HandleMessagePort.handleMessagePort': handleMessagePort,
|
|
6434
6542
|
'HandleMessagePort.handleMessagePort2': handleMessagePort2,
|
|
6435
6543
|
'IconTheme.getJson': getIconThemeJson,
|