@lvce-editor/file-search-worker 3.1.0 → 3.2.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/fileSearchWorkerMain.js +1562 -745
- package/package.json +1 -1
|
@@ -1,390 +1,59 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
jsonrpc: Two,
|
|
5
|
-
method,
|
|
6
|
-
params
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
|
-
const state$3 = {
|
|
10
|
-
callbacks: Object.create(null)
|
|
11
|
-
};
|
|
12
|
-
const set = (id, fn) => {
|
|
13
|
-
state$3.callbacks[id] = fn;
|
|
14
|
-
};
|
|
15
|
-
const get = id => {
|
|
16
|
-
return state$3.callbacks[id];
|
|
17
|
-
};
|
|
18
|
-
const remove$2 = id => {
|
|
19
|
-
delete state$3.callbacks[id];
|
|
20
|
-
};
|
|
21
|
-
let id = 0;
|
|
22
|
-
const create$3 = () => {
|
|
23
|
-
return ++id;
|
|
24
|
-
};
|
|
25
|
-
const warn = (...args) => {
|
|
26
|
-
console.warn(...args);
|
|
27
|
-
};
|
|
28
|
-
const registerPromise = () => {
|
|
29
|
-
const id = create$3();
|
|
30
|
-
const {
|
|
31
|
-
resolve,
|
|
32
|
-
promise
|
|
33
|
-
} = Promise.withResolvers();
|
|
34
|
-
set(id, resolve);
|
|
35
|
-
return {
|
|
36
|
-
id,
|
|
37
|
-
promise
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
const resolve = (id, response) => {
|
|
41
|
-
const fn = get(id);
|
|
42
|
-
if (!fn) {
|
|
43
|
-
console.log(response);
|
|
44
|
-
warn(`callback ${id} may already be disposed`);
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
fn(response);
|
|
48
|
-
remove$2(id);
|
|
49
|
-
};
|
|
50
|
-
const create$2 = (method, params) => {
|
|
51
|
-
const {
|
|
52
|
-
id,
|
|
53
|
-
promise
|
|
54
|
-
} = registerPromise();
|
|
55
|
-
const message = {
|
|
56
|
-
jsonrpc: Two,
|
|
57
|
-
method,
|
|
58
|
-
params,
|
|
59
|
-
id
|
|
60
|
-
};
|
|
61
|
-
return {
|
|
62
|
-
message,
|
|
63
|
-
promise
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
class JsonRpcError extends Error {
|
|
67
|
-
constructor(message) {
|
|
68
|
-
super(message);
|
|
69
|
-
this.name = 'JsonRpcError';
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
const NewLine$3 = '\n';
|
|
73
|
-
const DomException = 'DOMException';
|
|
74
|
-
const ReferenceError$1 = 'ReferenceError';
|
|
75
|
-
const SyntaxError$1 = 'SyntaxError';
|
|
76
|
-
const TypeError$1 = 'TypeError';
|
|
77
|
-
const getErrorConstructor = (message, type) => {
|
|
78
|
-
if (type) {
|
|
79
|
-
switch (type) {
|
|
80
|
-
case DomException:
|
|
81
|
-
return DOMException;
|
|
82
|
-
case TypeError$1:
|
|
83
|
-
return TypeError;
|
|
84
|
-
case SyntaxError$1:
|
|
85
|
-
return SyntaxError;
|
|
86
|
-
case ReferenceError$1:
|
|
87
|
-
return ReferenceError;
|
|
88
|
-
default:
|
|
89
|
-
return Error;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
if (message.startsWith('TypeError: ')) {
|
|
93
|
-
return TypeError;
|
|
94
|
-
}
|
|
95
|
-
if (message.startsWith('SyntaxError: ')) {
|
|
96
|
-
return SyntaxError;
|
|
97
|
-
}
|
|
98
|
-
if (message.startsWith('ReferenceError: ')) {
|
|
99
|
-
return ReferenceError;
|
|
100
|
-
}
|
|
101
|
-
return Error;
|
|
102
|
-
};
|
|
103
|
-
const constructError = (message, type, name) => {
|
|
104
|
-
const ErrorConstructor = getErrorConstructor(message, type);
|
|
105
|
-
if (ErrorConstructor === DOMException && name) {
|
|
106
|
-
return new ErrorConstructor(message, name);
|
|
107
|
-
}
|
|
108
|
-
if (ErrorConstructor === Error) {
|
|
109
|
-
const error = new Error(message);
|
|
110
|
-
if (name && name !== 'VError') {
|
|
111
|
-
error.name = name;
|
|
112
|
-
}
|
|
113
|
-
return error;
|
|
114
|
-
}
|
|
115
|
-
return new ErrorConstructor(message);
|
|
116
|
-
};
|
|
117
|
-
const getNewLineIndex$2 = (string, startIndex = undefined) => {
|
|
118
|
-
return string.indexOf(NewLine$3, startIndex);
|
|
119
|
-
};
|
|
120
|
-
const getParentStack = error => {
|
|
121
|
-
let parentStack = error.stack || error.data || error.message || '';
|
|
122
|
-
if (parentStack.startsWith(' at')) {
|
|
123
|
-
parentStack = error.message + NewLine$3 + parentStack;
|
|
124
|
-
}
|
|
125
|
-
return parentStack;
|
|
126
|
-
};
|
|
127
|
-
const joinLines$1 = lines => {
|
|
128
|
-
return lines.join(NewLine$3);
|
|
129
|
-
};
|
|
130
|
-
const MethodNotFound = -32601;
|
|
131
|
-
const Custom = -32001;
|
|
132
|
-
const splitLines$2 = lines => {
|
|
133
|
-
return lines.split(NewLine$3);
|
|
134
|
-
};
|
|
135
|
-
const restoreJsonRpcError = error => {
|
|
136
|
-
if (error && error instanceof Error) {
|
|
137
|
-
return error;
|
|
138
|
-
}
|
|
139
|
-
const currentStack = joinLines$1(splitLines$2(new Error().stack || '').slice(1));
|
|
140
|
-
if (error && error.code && error.code === MethodNotFound) {
|
|
141
|
-
const restoredError = new JsonRpcError(error.message);
|
|
142
|
-
const parentStack = getParentStack(error);
|
|
143
|
-
restoredError.stack = parentStack + NewLine$3 + currentStack;
|
|
144
|
-
return restoredError;
|
|
145
|
-
}
|
|
146
|
-
if (error && error.message) {
|
|
147
|
-
const restoredError = constructError(error.message, error.type, error.name);
|
|
148
|
-
if (error.data) {
|
|
149
|
-
if (error.data.stack && error.data.type && error.message) {
|
|
150
|
-
restoredError.stack = error.data.type + ': ' + error.message + NewLine$3 + error.data.stack + NewLine$3 + currentStack;
|
|
151
|
-
} else if (error.data.stack) {
|
|
152
|
-
restoredError.stack = error.data.stack;
|
|
153
|
-
}
|
|
154
|
-
if (error.data.codeFrame) {
|
|
155
|
-
// @ts-ignore
|
|
156
|
-
restoredError.codeFrame = error.data.codeFrame;
|
|
157
|
-
}
|
|
158
|
-
if (error.data.code) {
|
|
159
|
-
// @ts-ignore
|
|
160
|
-
restoredError.code = error.data.code;
|
|
161
|
-
}
|
|
162
|
-
if (error.data.type) {
|
|
163
|
-
// @ts-ignore
|
|
164
|
-
restoredError.name = error.data.type;
|
|
165
|
-
}
|
|
166
|
-
} else {
|
|
167
|
-
if (error.stack) {
|
|
168
|
-
const lowerStack = restoredError.stack || '';
|
|
169
|
-
// @ts-ignore
|
|
170
|
-
const indexNewLine = getNewLineIndex$2(lowerStack);
|
|
171
|
-
const parentStack = getParentStack(error);
|
|
172
|
-
// @ts-ignore
|
|
173
|
-
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
174
|
-
}
|
|
175
|
-
if (error.codeFrame) {
|
|
176
|
-
// @ts-ignore
|
|
177
|
-
restoredError.codeFrame = error.codeFrame;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
return restoredError;
|
|
181
|
-
}
|
|
182
|
-
if (typeof error === 'string') {
|
|
183
|
-
return new Error(`JsonRpc Error: ${error}`);
|
|
184
|
-
}
|
|
185
|
-
return new Error(`JsonRpc Error: ${error}`);
|
|
186
|
-
};
|
|
187
|
-
const unwrapJsonRpcResult = responseMessage => {
|
|
188
|
-
if ('error' in responseMessage) {
|
|
189
|
-
const restoredError = restoreJsonRpcError(responseMessage.error);
|
|
190
|
-
throw restoredError;
|
|
191
|
-
}
|
|
192
|
-
if ('result' in responseMessage) {
|
|
193
|
-
return responseMessage.result;
|
|
194
|
-
}
|
|
195
|
-
throw new JsonRpcError('unexpected response message');
|
|
196
|
-
};
|
|
197
|
-
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
198
|
-
const getErrorType = prettyError => {
|
|
199
|
-
if (prettyError && prettyError.type) {
|
|
200
|
-
return prettyError.type;
|
|
201
|
-
}
|
|
202
|
-
if (prettyError && prettyError.constructor && prettyError.constructor.name) {
|
|
203
|
-
return prettyError.constructor.name;
|
|
204
|
-
}
|
|
205
|
-
return undefined;
|
|
206
|
-
};
|
|
207
|
-
const getErrorProperty = (error, prettyError) => {
|
|
208
|
-
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
209
|
-
return {
|
|
210
|
-
code: MethodNotFound,
|
|
211
|
-
message: error.message,
|
|
212
|
-
data: error.stack
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
return {
|
|
216
|
-
code: Custom,
|
|
217
|
-
message: prettyError.message,
|
|
218
|
-
data: {
|
|
219
|
-
stack: prettyError.stack,
|
|
220
|
-
codeFrame: prettyError.codeFrame,
|
|
221
|
-
type: getErrorType(prettyError),
|
|
222
|
-
code: prettyError.code,
|
|
223
|
-
name: prettyError.name
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
};
|
|
227
|
-
const create$1$1 = (message, error) => {
|
|
228
|
-
return {
|
|
229
|
-
jsonrpc: Two,
|
|
230
|
-
id: message.id,
|
|
231
|
-
error
|
|
232
|
-
};
|
|
233
|
-
};
|
|
234
|
-
const getErrorResponse = (message, error, preparePrettyError, logError) => {
|
|
235
|
-
const prettyError = preparePrettyError(error);
|
|
236
|
-
logError(error, prettyError);
|
|
237
|
-
const errorProperty = getErrorProperty(error, prettyError);
|
|
238
|
-
return create$1$1(message, errorProperty);
|
|
239
|
-
};
|
|
240
|
-
const create = (message, result) => {
|
|
241
|
-
return {
|
|
242
|
-
jsonrpc: Two,
|
|
243
|
-
id: message.id,
|
|
244
|
-
result: result ?? null
|
|
245
|
-
};
|
|
246
|
-
};
|
|
247
|
-
const getSuccessResponse = (message, result) => {
|
|
248
|
-
const resultProperty = result ?? null;
|
|
249
|
-
return create(message, resultProperty);
|
|
250
|
-
};
|
|
251
|
-
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
252
|
-
try {
|
|
253
|
-
const result = requiresSocket(message.method) ? await execute(message.method, ipc, ...message.params) : await execute(message.method, ...message.params);
|
|
254
|
-
return getSuccessResponse(message, result);
|
|
255
|
-
} catch (error) {
|
|
256
|
-
return getErrorResponse(message, error, preparePrettyError, logError);
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
const defaultPreparePrettyError = error => {
|
|
260
|
-
return error;
|
|
261
|
-
};
|
|
262
|
-
const defaultLogError = () => {
|
|
263
|
-
// ignore
|
|
264
|
-
};
|
|
265
|
-
const defaultRequiresSocket = () => {
|
|
266
|
-
return false;
|
|
267
|
-
};
|
|
268
|
-
const defaultResolve = resolve;
|
|
269
|
-
|
|
270
|
-
// TODO maybe remove this in v6 or v7, only accept options object to simplify the code
|
|
271
|
-
const normalizeParams = args => {
|
|
272
|
-
if (args.length === 1) {
|
|
273
|
-
const options = args[0];
|
|
274
|
-
return {
|
|
275
|
-
ipc: options.ipc,
|
|
276
|
-
message: options.message,
|
|
277
|
-
execute: options.execute,
|
|
278
|
-
resolve: options.resolve || defaultResolve,
|
|
279
|
-
preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
|
|
280
|
-
logError: options.logError || defaultLogError,
|
|
281
|
-
requiresSocket: options.requiresSocket || defaultRequiresSocket
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
return {
|
|
285
|
-
ipc: args[0],
|
|
286
|
-
message: args[1],
|
|
287
|
-
execute: args[2],
|
|
288
|
-
resolve: args[3],
|
|
289
|
-
preparePrettyError: args[4],
|
|
290
|
-
logError: args[5],
|
|
291
|
-
requiresSocket: args[6]
|
|
292
|
-
};
|
|
293
|
-
};
|
|
294
|
-
const handleJsonRpcMessage = async (...args) => {
|
|
295
|
-
const options = normalizeParams(args);
|
|
296
|
-
const {
|
|
297
|
-
message,
|
|
298
|
-
ipc,
|
|
299
|
-
execute,
|
|
300
|
-
resolve,
|
|
301
|
-
preparePrettyError,
|
|
302
|
-
logError,
|
|
303
|
-
requiresSocket
|
|
304
|
-
} = options;
|
|
305
|
-
if ('id' in message) {
|
|
306
|
-
if ('method' in message) {
|
|
307
|
-
const response = await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
308
|
-
try {
|
|
309
|
-
ipc.send(response);
|
|
310
|
-
} catch (error) {
|
|
311
|
-
const errorResponse = getErrorResponse(message, error, preparePrettyError, logError);
|
|
312
|
-
ipc.send(errorResponse);
|
|
313
|
-
}
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
resolve(message.id, message);
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
if ('method' in message) {
|
|
320
|
-
await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
321
|
-
return;
|
|
1
|
+
const normalizeLine = line => {
|
|
2
|
+
if (line.startsWith('Error: ')) {
|
|
3
|
+
return line.slice('Error: '.length);
|
|
322
4
|
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
326
|
-
const {
|
|
327
|
-
message,
|
|
328
|
-
promise
|
|
329
|
-
} = create$2(method, params);
|
|
330
|
-
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
331
|
-
ipc.sendAndTransfer(message);
|
|
332
|
-
} else {
|
|
333
|
-
ipc.send(message);
|
|
5
|
+
if (line.startsWith('VError: ')) {
|
|
6
|
+
return line.slice('VError: '.length);
|
|
334
7
|
}
|
|
335
|
-
|
|
336
|
-
return unwrapJsonRpcResult(responseMessage);
|
|
337
|
-
};
|
|
338
|
-
const send = (transport, method, ...params) => {
|
|
339
|
-
const message = create$4(method, params);
|
|
340
|
-
transport.send(message);
|
|
341
|
-
};
|
|
342
|
-
const invoke$2 = (ipc, method, ...params) => {
|
|
343
|
-
return invokeHelper(ipc, method, params, false);
|
|
344
|
-
};
|
|
345
|
-
const invokeAndTransfer = (ipc, method, ...params) => {
|
|
346
|
-
return invokeHelper(ipc, method, params, true);
|
|
347
|
-
};
|
|
348
|
-
|
|
349
|
-
const commands = Object.create(null);
|
|
350
|
-
const register = commandMap => {
|
|
351
|
-
Object.assign(commands, commandMap);
|
|
352
|
-
};
|
|
353
|
-
const getCommand = key => {
|
|
354
|
-
return commands[key];
|
|
8
|
+
return line;
|
|
355
9
|
};
|
|
356
|
-
const
|
|
357
|
-
const
|
|
358
|
-
if (
|
|
359
|
-
|
|
10
|
+
const getCombinedMessage = (error, message) => {
|
|
11
|
+
const stringifiedError = normalizeLine(`${error}`);
|
|
12
|
+
if (message) {
|
|
13
|
+
return `${message}: ${stringifiedError}`;
|
|
360
14
|
}
|
|
361
|
-
return
|
|
15
|
+
return stringifiedError;
|
|
362
16
|
};
|
|
363
|
-
|
|
364
|
-
const
|
|
365
|
-
return
|
|
17
|
+
const NewLine$2 = '\n';
|
|
18
|
+
const getNewLineIndex$1 = (string, startIndex = undefined) => {
|
|
19
|
+
return string.indexOf(NewLine$2, startIndex);
|
|
366
20
|
};
|
|
367
|
-
const
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
21
|
+
const mergeStacks = (parent, child) => {
|
|
22
|
+
if (!child) {
|
|
23
|
+
return parent;
|
|
24
|
+
}
|
|
25
|
+
const parentNewLineIndex = getNewLineIndex$1(parent);
|
|
26
|
+
const childNewLineIndex = getNewLineIndex$1(child);
|
|
27
|
+
if (childNewLineIndex === -1) {
|
|
28
|
+
return parent;
|
|
29
|
+
}
|
|
30
|
+
const parentFirstLine = parent.slice(0, parentNewLineIndex);
|
|
31
|
+
const childRest = child.slice(childNewLineIndex);
|
|
32
|
+
const childFirstLine = normalizeLine(child.slice(0, childNewLineIndex));
|
|
33
|
+
if (parentFirstLine.includes(childFirstLine)) {
|
|
34
|
+
return parentFirstLine + childRest;
|
|
35
|
+
}
|
|
36
|
+
return child;
|
|
379
37
|
};
|
|
380
|
-
class
|
|
381
|
-
constructor(
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
38
|
+
class VError extends Error {
|
|
39
|
+
constructor(error, message) {
|
|
40
|
+
const combinedMessage = getCombinedMessage(error, message);
|
|
41
|
+
super(combinedMessage);
|
|
42
|
+
this.name = 'VError';
|
|
43
|
+
if (error instanceof Error) {
|
|
44
|
+
this.stack = mergeStacks(this.stack, error.stack);
|
|
45
|
+
}
|
|
46
|
+
if (error.codeFrame) {
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
this.codeFrame = error.codeFrame;
|
|
49
|
+
}
|
|
50
|
+
if (error.code) {
|
|
51
|
+
// @ts-ignore
|
|
52
|
+
this.code = error.code;
|
|
53
|
+
}
|
|
385
54
|
}
|
|
386
55
|
}
|
|
387
|
-
|
|
56
|
+
|
|
388
57
|
const walkValue = (value, transferrables, isTransferrable) => {
|
|
389
58
|
if (!value) {
|
|
390
59
|
return;
|
|
@@ -435,313 +104,643 @@ const getTransferrables = value => {
|
|
|
435
104
|
walkValue(value, transferrables, isTransferrable);
|
|
436
105
|
return transferrables;
|
|
437
106
|
};
|
|
438
|
-
const
|
|
107
|
+
const attachEvents = that => {
|
|
108
|
+
const handleMessage = (...args) => {
|
|
109
|
+
const data = that.getData(...args);
|
|
110
|
+
that.dispatchEvent(new MessageEvent('message', {
|
|
111
|
+
data
|
|
112
|
+
}));
|
|
113
|
+
};
|
|
114
|
+
that.onMessage(handleMessage);
|
|
115
|
+
const handleClose = event => {
|
|
116
|
+
that.dispatchEvent(new Event('close'));
|
|
117
|
+
};
|
|
118
|
+
that.onClose(handleClose);
|
|
119
|
+
};
|
|
120
|
+
class Ipc extends EventTarget {
|
|
121
|
+
constructor(rawIpc) {
|
|
122
|
+
super();
|
|
123
|
+
this._rawIpc = rawIpc;
|
|
124
|
+
attachEvents(this);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
128
|
+
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
129
|
+
const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
|
|
130
|
+
const NewLine$1 = '\n';
|
|
131
|
+
const joinLines$1 = lines => {
|
|
132
|
+
return lines.join(NewLine$1);
|
|
133
|
+
};
|
|
134
|
+
const splitLines$2 = lines => {
|
|
135
|
+
return lines.split(NewLine$1);
|
|
136
|
+
};
|
|
137
|
+
const isModuleNotFoundMessage = line => {
|
|
138
|
+
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
|
139
|
+
};
|
|
140
|
+
const getModuleNotFoundError = stderr => {
|
|
141
|
+
const lines = splitLines$2(stderr);
|
|
142
|
+
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
143
|
+
const message = lines[messageIndex];
|
|
144
|
+
return {
|
|
145
|
+
message,
|
|
146
|
+
code: ERR_MODULE_NOT_FOUND
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
|
|
150
|
+
const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
|
|
151
|
+
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
|
152
|
+
const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
|
|
153
|
+
const RE_AT = /^\s+at/;
|
|
154
|
+
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
|
155
|
+
const isUnhelpfulNativeModuleError = stderr => {
|
|
156
|
+
return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
|
|
157
|
+
};
|
|
158
|
+
const isMessageCodeBlockStartIndex = line => {
|
|
159
|
+
return RE_MESSAGE_CODE_BLOCK_START.test(line);
|
|
160
|
+
};
|
|
161
|
+
const isMessageCodeBlockEndIndex = line => {
|
|
162
|
+
return RE_MESSAGE_CODE_BLOCK_END.test(line);
|
|
163
|
+
};
|
|
164
|
+
const getMessageCodeBlock = stderr => {
|
|
165
|
+
const lines = splitLines$2(stderr);
|
|
166
|
+
const startIndex = lines.findIndex(isMessageCodeBlockStartIndex);
|
|
167
|
+
const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex, startIndex);
|
|
168
|
+
const relevantLines = lines.slice(startIndex, endIndex);
|
|
169
|
+
const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
|
|
170
|
+
return relevantMessage;
|
|
171
|
+
};
|
|
172
|
+
const getNativeModuleErrorMessage = stderr => {
|
|
173
|
+
const message = getMessageCodeBlock(stderr);
|
|
174
|
+
return {
|
|
175
|
+
message: `Incompatible native node module: ${message}`,
|
|
176
|
+
code: E_INCOMPATIBLE_NATIVE_MODULE
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
const isModulesSyntaxError = stderr => {
|
|
180
|
+
if (!stderr) {
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
return stderr.includes('SyntaxError: Cannot use import statement outside a module');
|
|
184
|
+
};
|
|
185
|
+
const getModuleSyntaxError = () => {
|
|
186
|
+
return {
|
|
187
|
+
message: `ES Modules are not supported in electron`,
|
|
188
|
+
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
const isModuleNotFoundError = stderr => {
|
|
192
|
+
if (!stderr) {
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
return stderr.includes('ERR_MODULE_NOT_FOUND');
|
|
196
|
+
};
|
|
197
|
+
const isNormalStackLine = line => {
|
|
198
|
+
return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
|
|
199
|
+
};
|
|
200
|
+
const getDetails = lines => {
|
|
201
|
+
const index = lines.findIndex(isNormalStackLine);
|
|
202
|
+
if (index === -1) {
|
|
203
|
+
return {
|
|
204
|
+
actualMessage: joinLines$1(lines),
|
|
205
|
+
rest: []
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
let lastIndex = index - 1;
|
|
209
|
+
while (++lastIndex < lines.length) {
|
|
210
|
+
if (!isNormalStackLine(lines[lastIndex])) {
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return {
|
|
215
|
+
actualMessage: lines[index - 1],
|
|
216
|
+
rest: lines.slice(index, lastIndex)
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
220
|
+
if (isUnhelpfulNativeModuleError(stderr)) {
|
|
221
|
+
return getNativeModuleErrorMessage(stderr);
|
|
222
|
+
}
|
|
223
|
+
if (isModulesSyntaxError(stderr)) {
|
|
224
|
+
return getModuleSyntaxError();
|
|
225
|
+
}
|
|
226
|
+
if (isModuleNotFoundError(stderr)) {
|
|
227
|
+
return getModuleNotFoundError(stderr);
|
|
228
|
+
}
|
|
229
|
+
const lines = splitLines$2(stderr);
|
|
230
|
+
const {
|
|
231
|
+
actualMessage,
|
|
232
|
+
rest
|
|
233
|
+
} = getDetails(lines);
|
|
234
|
+
return {
|
|
235
|
+
message: `${actualMessage}`,
|
|
236
|
+
code: '',
|
|
237
|
+
stack: rest
|
|
238
|
+
};
|
|
239
|
+
};
|
|
240
|
+
class IpcError extends VError {
|
|
241
|
+
// @ts-ignore
|
|
242
|
+
constructor(betterMessage, stdout = '', stderr = '') {
|
|
243
|
+
if (stdout || stderr) {
|
|
244
|
+
// @ts-ignore
|
|
245
|
+
const {
|
|
246
|
+
message,
|
|
247
|
+
code,
|
|
248
|
+
stack
|
|
249
|
+
} = getHelpfulChildProcessError(stdout, stderr);
|
|
250
|
+
const cause = new Error(message);
|
|
251
|
+
// @ts-ignore
|
|
252
|
+
cause.code = code;
|
|
253
|
+
cause.stack = stack;
|
|
254
|
+
super(cause, betterMessage);
|
|
255
|
+
} else {
|
|
256
|
+
super(betterMessage);
|
|
257
|
+
}
|
|
258
|
+
// @ts-ignore
|
|
259
|
+
this.name = 'IpcError';
|
|
260
|
+
// @ts-ignore
|
|
261
|
+
this.stdout = stdout;
|
|
262
|
+
// @ts-ignore
|
|
263
|
+
this.stderr = stderr;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
const readyMessage = 'ready';
|
|
267
|
+
const getData$2 = event => {
|
|
268
|
+
return event.data;
|
|
269
|
+
};
|
|
270
|
+
const listen$6 = () => {
|
|
271
|
+
// @ts-ignore
|
|
272
|
+
if (typeof WorkerGlobalScope === 'undefined') {
|
|
273
|
+
throw new TypeError('module is not in web worker scope');
|
|
274
|
+
}
|
|
275
|
+
return globalThis;
|
|
276
|
+
};
|
|
277
|
+
const signal$6 = global => {
|
|
278
|
+
global.postMessage(readyMessage);
|
|
279
|
+
};
|
|
280
|
+
class IpcChildWithModuleWorker extends Ipc {
|
|
281
|
+
getData(event) {
|
|
282
|
+
return getData$2(event);
|
|
283
|
+
}
|
|
284
|
+
send(message) {
|
|
285
|
+
// @ts-ignore
|
|
286
|
+
this._rawIpc.postMessage(message);
|
|
287
|
+
}
|
|
288
|
+
sendAndTransfer(message) {
|
|
289
|
+
const transfer = getTransferrables(message);
|
|
290
|
+
// @ts-ignore
|
|
291
|
+
this._rawIpc.postMessage(message, transfer);
|
|
292
|
+
}
|
|
293
|
+
dispose() {
|
|
294
|
+
// ignore
|
|
295
|
+
}
|
|
296
|
+
onClose(callback) {
|
|
297
|
+
// ignore
|
|
298
|
+
}
|
|
299
|
+
onMessage(callback) {
|
|
300
|
+
this._rawIpc.addEventListener('message', callback);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
const wrap$d = global => {
|
|
304
|
+
return new IpcChildWithModuleWorker(global);
|
|
305
|
+
};
|
|
306
|
+
const withResolvers = () => {
|
|
307
|
+
let _resolve;
|
|
308
|
+
const promise = new Promise(resolve => {
|
|
309
|
+
_resolve = resolve;
|
|
310
|
+
});
|
|
311
|
+
return {
|
|
312
|
+
resolve: _resolve,
|
|
313
|
+
promise
|
|
314
|
+
};
|
|
315
|
+
};
|
|
316
|
+
const waitForFirstMessage = async port => {
|
|
317
|
+
const {
|
|
318
|
+
resolve,
|
|
319
|
+
promise
|
|
320
|
+
} = withResolvers();
|
|
321
|
+
port.addEventListener('message', resolve, {
|
|
322
|
+
once: true
|
|
323
|
+
});
|
|
324
|
+
const event = await promise;
|
|
439
325
|
// @ts-ignore
|
|
440
|
-
|
|
441
|
-
|
|
326
|
+
return event.data;
|
|
327
|
+
};
|
|
328
|
+
const listen$5 = async () => {
|
|
329
|
+
const parentIpcRaw = listen$6();
|
|
330
|
+
signal$6(parentIpcRaw);
|
|
331
|
+
const parentIpc = wrap$d(parentIpcRaw);
|
|
332
|
+
const firstMessage = await waitForFirstMessage(parentIpc);
|
|
333
|
+
if (firstMessage.method !== 'initialize') {
|
|
334
|
+
throw new IpcError('unexpected first message');
|
|
335
|
+
}
|
|
336
|
+
const type = firstMessage.params[0];
|
|
337
|
+
if (type === 'message-port') {
|
|
338
|
+
parentIpc.send({
|
|
339
|
+
jsonrpc: '2.0',
|
|
340
|
+
id: firstMessage.id,
|
|
341
|
+
result: null
|
|
342
|
+
});
|
|
343
|
+
parentIpc.dispose();
|
|
344
|
+
const port = firstMessage.params[1];
|
|
345
|
+
return port;
|
|
442
346
|
}
|
|
443
347
|
return globalThis;
|
|
444
348
|
};
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
349
|
+
class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
350
|
+
constructor(port) {
|
|
351
|
+
super(port);
|
|
352
|
+
}
|
|
449
353
|
getData(event) {
|
|
450
|
-
return getData$
|
|
354
|
+
return getData$2(event);
|
|
451
355
|
}
|
|
452
356
|
send(message) {
|
|
453
|
-
// @ts-ignore
|
|
454
357
|
this._rawIpc.postMessage(message);
|
|
455
358
|
}
|
|
456
359
|
sendAndTransfer(message) {
|
|
457
360
|
const transfer = getTransferrables(message);
|
|
458
|
-
// @ts-ignore
|
|
459
361
|
this._rawIpc.postMessage(message, transfer);
|
|
460
362
|
}
|
|
461
363
|
dispose() {
|
|
462
|
-
|
|
364
|
+
if (this._rawIpc.close) {
|
|
365
|
+
this._rawIpc.close();
|
|
366
|
+
}
|
|
463
367
|
}
|
|
464
368
|
onClose(callback) {
|
|
465
369
|
// ignore
|
|
466
370
|
}
|
|
467
371
|
onMessage(callback) {
|
|
468
372
|
this._rawIpc.addEventListener('message', callback);
|
|
373
|
+
this._rawIpc.start();
|
|
469
374
|
}
|
|
470
375
|
}
|
|
471
|
-
const wrap$
|
|
472
|
-
return new
|
|
473
|
-
};
|
|
474
|
-
const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
475
|
-
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
476
|
-
const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
|
|
477
|
-
const NewLine$1 = '\n';
|
|
478
|
-
const joinLines = lines => {
|
|
479
|
-
return lines.join(NewLine$1);
|
|
480
|
-
};
|
|
481
|
-
const splitLines$1 = lines => {
|
|
482
|
-
return lines.split(NewLine$1);
|
|
376
|
+
const wrap$c = port => {
|
|
377
|
+
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
483
378
|
};
|
|
484
|
-
const
|
|
485
|
-
|
|
379
|
+
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
380
|
+
__proto__: null,
|
|
381
|
+
listen: listen$5,
|
|
382
|
+
wrap: wrap$c
|
|
486
383
|
};
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
const message = lines[messageIndex];
|
|
384
|
+
|
|
385
|
+
const Two = '2.0';
|
|
386
|
+
const create$4 = (method, params) => {
|
|
491
387
|
return {
|
|
492
|
-
|
|
493
|
-
|
|
388
|
+
jsonrpc: Two,
|
|
389
|
+
method,
|
|
390
|
+
params
|
|
494
391
|
};
|
|
495
392
|
};
|
|
496
|
-
const
|
|
497
|
-
const
|
|
498
|
-
|
|
499
|
-
const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
|
|
500
|
-
const RE_AT = /^\s+at/;
|
|
501
|
-
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
|
502
|
-
const isUnhelpfulNativeModuleError = stderr => {
|
|
503
|
-
return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
|
|
393
|
+
const callbacks = Object.create(null);
|
|
394
|
+
const set = (id, fn) => {
|
|
395
|
+
callbacks[id] = fn;
|
|
504
396
|
};
|
|
505
|
-
const
|
|
506
|
-
return
|
|
397
|
+
const get = id => {
|
|
398
|
+
return callbacks[id];
|
|
507
399
|
};
|
|
508
|
-
const
|
|
509
|
-
|
|
400
|
+
const remove$2 = id => {
|
|
401
|
+
delete callbacks[id];
|
|
510
402
|
};
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex, startIndex);
|
|
515
|
-
const relevantLines = lines.slice(startIndex, endIndex);
|
|
516
|
-
const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
|
|
517
|
-
return relevantMessage;
|
|
403
|
+
let id = 0;
|
|
404
|
+
const create$3 = () => {
|
|
405
|
+
return ++id;
|
|
518
406
|
};
|
|
519
|
-
const
|
|
520
|
-
|
|
407
|
+
const warn$1 = (...args) => {
|
|
408
|
+
console.warn(...args);
|
|
409
|
+
};
|
|
410
|
+
const registerPromise = () => {
|
|
411
|
+
const id = create$3();
|
|
412
|
+
const {
|
|
413
|
+
resolve,
|
|
414
|
+
promise
|
|
415
|
+
} = Promise.withResolvers();
|
|
416
|
+
set(id, resolve);
|
|
521
417
|
return {
|
|
522
|
-
|
|
523
|
-
|
|
418
|
+
id,
|
|
419
|
+
promise
|
|
524
420
|
};
|
|
525
421
|
};
|
|
526
|
-
const
|
|
527
|
-
|
|
528
|
-
|
|
422
|
+
const resolve = (id, response) => {
|
|
423
|
+
const fn = get(id);
|
|
424
|
+
if (!fn) {
|
|
425
|
+
console.log(response);
|
|
426
|
+
warn$1(`callback ${id} may already be disposed`);
|
|
427
|
+
return;
|
|
529
428
|
}
|
|
530
|
-
|
|
429
|
+
fn(response);
|
|
430
|
+
remove$2(id);
|
|
531
431
|
};
|
|
532
|
-
const
|
|
432
|
+
const create$2 = (method, params) => {
|
|
433
|
+
const {
|
|
434
|
+
id,
|
|
435
|
+
promise
|
|
436
|
+
} = registerPromise();
|
|
437
|
+
const message = {
|
|
438
|
+
jsonrpc: Two,
|
|
439
|
+
method,
|
|
440
|
+
params,
|
|
441
|
+
id
|
|
442
|
+
};
|
|
533
443
|
return {
|
|
534
|
-
message
|
|
535
|
-
|
|
444
|
+
message,
|
|
445
|
+
promise
|
|
536
446
|
};
|
|
537
447
|
};
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
448
|
+
class JsonRpcError extends Error {
|
|
449
|
+
constructor(message) {
|
|
450
|
+
super(message);
|
|
451
|
+
this.name = 'JsonRpcError';
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
const NewLine = '\n';
|
|
455
|
+
const DomException = 'DOMException';
|
|
456
|
+
const ReferenceError$1 = 'ReferenceError';
|
|
457
|
+
const SyntaxError$1 = 'SyntaxError';
|
|
458
|
+
const TypeError$1 = 'TypeError';
|
|
459
|
+
const getErrorConstructor = (message, type) => {
|
|
460
|
+
if (type) {
|
|
461
|
+
switch (type) {
|
|
462
|
+
case DomException:
|
|
463
|
+
return DOMException;
|
|
464
|
+
case TypeError$1:
|
|
465
|
+
return TypeError;
|
|
466
|
+
case SyntaxError$1:
|
|
467
|
+
return SyntaxError;
|
|
468
|
+
case ReferenceError$1:
|
|
469
|
+
return ReferenceError;
|
|
470
|
+
default:
|
|
471
|
+
return Error;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
if (message.startsWith('TypeError: ')) {
|
|
475
|
+
return TypeError;
|
|
476
|
+
}
|
|
477
|
+
if (message.startsWith('SyntaxError: ')) {
|
|
478
|
+
return SyntaxError;
|
|
479
|
+
}
|
|
480
|
+
if (message.startsWith('ReferenceError: ')) {
|
|
481
|
+
return ReferenceError;
|
|
482
|
+
}
|
|
483
|
+
return Error;
|
|
484
|
+
};
|
|
485
|
+
const constructError = (message, type, name) => {
|
|
486
|
+
const ErrorConstructor = getErrorConstructor(message, type);
|
|
487
|
+
if (ErrorConstructor === DOMException && name) {
|
|
488
|
+
return new ErrorConstructor(message, name);
|
|
489
|
+
}
|
|
490
|
+
if (ErrorConstructor === Error) {
|
|
491
|
+
const error = new Error(message);
|
|
492
|
+
if (name && name !== 'VError') {
|
|
493
|
+
error.name = name;
|
|
494
|
+
}
|
|
495
|
+
return error;
|
|
496
|
+
}
|
|
497
|
+
return new ErrorConstructor(message);
|
|
498
|
+
};
|
|
499
|
+
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
500
|
+
return string.indexOf(NewLine, startIndex);
|
|
501
|
+
};
|
|
502
|
+
const getParentStack = error => {
|
|
503
|
+
let parentStack = error.stack || error.data || error.message || '';
|
|
504
|
+
if (parentStack.startsWith(' at')) {
|
|
505
|
+
parentStack = error.message + NewLine + parentStack;
|
|
506
|
+
}
|
|
507
|
+
return parentStack;
|
|
508
|
+
};
|
|
509
|
+
const joinLines = lines => {
|
|
510
|
+
return lines.join(NewLine);
|
|
511
|
+
};
|
|
512
|
+
const MethodNotFound = -32601;
|
|
513
|
+
const Custom$1 = -32001;
|
|
514
|
+
const splitLines$1 = lines => {
|
|
515
|
+
return lines.split(NewLine);
|
|
516
|
+
};
|
|
517
|
+
const restoreJsonRpcError = error => {
|
|
518
|
+
if (error && error instanceof Error) {
|
|
519
|
+
return error;
|
|
520
|
+
}
|
|
521
|
+
const currentStack = joinLines(splitLines$1(new Error().stack || '').slice(1));
|
|
522
|
+
if (error && error.code && error.code === MethodNotFound) {
|
|
523
|
+
const restoredError = new JsonRpcError(error.message);
|
|
524
|
+
const parentStack = getParentStack(error);
|
|
525
|
+
restoredError.stack = parentStack + NewLine + currentStack;
|
|
526
|
+
return restoredError;
|
|
527
|
+
}
|
|
528
|
+
if (error && error.message) {
|
|
529
|
+
const restoredError = constructError(error.message, error.type, error.name);
|
|
530
|
+
if (error.data) {
|
|
531
|
+
if (error.data.stack && error.data.type && error.message) {
|
|
532
|
+
restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
|
|
533
|
+
} else if (error.data.stack) {
|
|
534
|
+
restoredError.stack = error.data.stack;
|
|
535
|
+
}
|
|
536
|
+
if (error.data.codeFrame) {
|
|
537
|
+
// @ts-ignore
|
|
538
|
+
restoredError.codeFrame = error.data.codeFrame;
|
|
539
|
+
}
|
|
540
|
+
if (error.data.code) {
|
|
541
|
+
// @ts-ignore
|
|
542
|
+
restoredError.code = error.data.code;
|
|
543
|
+
}
|
|
544
|
+
if (error.data.type) {
|
|
545
|
+
// @ts-ignore
|
|
546
|
+
restoredError.name = error.data.type;
|
|
547
|
+
}
|
|
548
|
+
} else {
|
|
549
|
+
if (error.stack) {
|
|
550
|
+
const lowerStack = restoredError.stack || '';
|
|
551
|
+
// @ts-ignore
|
|
552
|
+
const indexNewLine = getNewLineIndex(lowerStack);
|
|
553
|
+
const parentStack = getParentStack(error);
|
|
554
|
+
// @ts-ignore
|
|
555
|
+
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
556
|
+
}
|
|
557
|
+
if (error.codeFrame) {
|
|
558
|
+
// @ts-ignore
|
|
559
|
+
restoredError.codeFrame = error.codeFrame;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
return restoredError;
|
|
563
|
+
}
|
|
564
|
+
if (typeof error === 'string') {
|
|
565
|
+
return new Error(`JsonRpc Error: ${error}`);
|
|
566
|
+
}
|
|
567
|
+
return new Error(`JsonRpc Error: ${error}`);
|
|
568
|
+
};
|
|
569
|
+
const unwrapJsonRpcResult = responseMessage => {
|
|
570
|
+
if ('error' in responseMessage) {
|
|
571
|
+
const restoredError = restoreJsonRpcError(responseMessage.error);
|
|
572
|
+
throw restoredError;
|
|
541
573
|
}
|
|
542
|
-
|
|
574
|
+
if ('result' in responseMessage) {
|
|
575
|
+
return responseMessage.result;
|
|
576
|
+
}
|
|
577
|
+
throw new JsonRpcError('unexpected response message');
|
|
543
578
|
};
|
|
544
|
-
const
|
|
545
|
-
|
|
579
|
+
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
580
|
+
const getErrorType = prettyError => {
|
|
581
|
+
if (prettyError && prettyError.type) {
|
|
582
|
+
return prettyError.type;
|
|
583
|
+
}
|
|
584
|
+
if (prettyError && prettyError.constructor && prettyError.constructor.name) {
|
|
585
|
+
return prettyError.constructor.name;
|
|
586
|
+
}
|
|
587
|
+
return undefined;
|
|
546
588
|
};
|
|
547
|
-
const
|
|
548
|
-
|
|
549
|
-
if (index === -1) {
|
|
589
|
+
const getErrorProperty = (error, prettyError) => {
|
|
590
|
+
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
550
591
|
return {
|
|
551
|
-
|
|
552
|
-
|
|
592
|
+
code: MethodNotFound,
|
|
593
|
+
message: error.message,
|
|
594
|
+
data: error.stack
|
|
553
595
|
};
|
|
554
596
|
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
597
|
+
return {
|
|
598
|
+
code: Custom$1,
|
|
599
|
+
message: prettyError.message,
|
|
600
|
+
data: {
|
|
601
|
+
stack: prettyError.stack,
|
|
602
|
+
codeFrame: prettyError.codeFrame,
|
|
603
|
+
type: getErrorType(prettyError),
|
|
604
|
+
code: prettyError.code,
|
|
605
|
+
name: prettyError.name
|
|
559
606
|
}
|
|
560
|
-
}
|
|
607
|
+
};
|
|
608
|
+
};
|
|
609
|
+
const create$1 = (message, error) => {
|
|
561
610
|
return {
|
|
562
|
-
|
|
563
|
-
|
|
611
|
+
jsonrpc: Two,
|
|
612
|
+
id: message.id,
|
|
613
|
+
error
|
|
564
614
|
};
|
|
565
615
|
};
|
|
566
|
-
const
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
if (isModuleNotFoundError(stderr)) {
|
|
574
|
-
return getModuleNotFoundError(stderr);
|
|
575
|
-
}
|
|
576
|
-
const lines = splitLines$1(stderr);
|
|
577
|
-
const {
|
|
578
|
-
actualMessage,
|
|
579
|
-
rest
|
|
580
|
-
} = getDetails(lines);
|
|
616
|
+
const getErrorResponse = (message, error, preparePrettyError, logError) => {
|
|
617
|
+
const prettyError = preparePrettyError(error);
|
|
618
|
+
logError(error, prettyError);
|
|
619
|
+
const errorProperty = getErrorProperty(error, prettyError);
|
|
620
|
+
return create$1(message, errorProperty);
|
|
621
|
+
};
|
|
622
|
+
const create$5 = (message, result) => {
|
|
581
623
|
return {
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
624
|
+
jsonrpc: Two,
|
|
625
|
+
id: message.id,
|
|
626
|
+
result: result ?? null
|
|
585
627
|
};
|
|
586
628
|
};
|
|
587
|
-
const
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
}
|
|
591
|
-
if (line.startsWith('VError: ')) {
|
|
592
|
-
return line.slice('VError: '.length);
|
|
593
|
-
}
|
|
594
|
-
return line;
|
|
629
|
+
const getSuccessResponse = (message, result) => {
|
|
630
|
+
const resultProperty = result ?? null;
|
|
631
|
+
return create$5(message, resultProperty);
|
|
595
632
|
};
|
|
596
|
-
const
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
return
|
|
633
|
+
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
634
|
+
try {
|
|
635
|
+
const result = requiresSocket(message.method) ? await execute(message.method, ipc, ...message.params) : await execute(message.method, ...message.params);
|
|
636
|
+
return getSuccessResponse(message, result);
|
|
637
|
+
} catch (error) {
|
|
638
|
+
return getErrorResponse(message, error, preparePrettyError, logError);
|
|
600
639
|
}
|
|
601
|
-
return stringifiedError;
|
|
602
640
|
};
|
|
603
|
-
const
|
|
604
|
-
|
|
605
|
-
return string.indexOf(NewLine$2, startIndex);
|
|
641
|
+
const defaultPreparePrettyError = error => {
|
|
642
|
+
return error;
|
|
606
643
|
};
|
|
607
|
-
const
|
|
608
|
-
|
|
609
|
-
return parent;
|
|
610
|
-
}
|
|
611
|
-
const parentNewLineIndex = getNewLineIndex$1(parent);
|
|
612
|
-
const childNewLineIndex = getNewLineIndex$1(child);
|
|
613
|
-
if (childNewLineIndex === -1) {
|
|
614
|
-
return parent;
|
|
615
|
-
}
|
|
616
|
-
const parentFirstLine = parent.slice(0, parentNewLineIndex);
|
|
617
|
-
const childRest = child.slice(childNewLineIndex);
|
|
618
|
-
const childFirstLine = normalizeLine$1(child.slice(0, childNewLineIndex));
|
|
619
|
-
if (parentFirstLine.includes(childFirstLine)) {
|
|
620
|
-
return parentFirstLine + childRest;
|
|
621
|
-
}
|
|
622
|
-
return child;
|
|
644
|
+
const defaultLogError = () => {
|
|
645
|
+
// ignore
|
|
623
646
|
};
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
const combinedMessage = getCombinedMessage$1(error, message);
|
|
627
|
-
super(combinedMessage);
|
|
628
|
-
this.name = 'VError';
|
|
629
|
-
if (error instanceof Error) {
|
|
630
|
-
this.stack = mergeStacks$1(this.stack, error.stack);
|
|
631
|
-
}
|
|
632
|
-
if (error.codeFrame) {
|
|
633
|
-
// @ts-ignore
|
|
634
|
-
this.codeFrame = error.codeFrame;
|
|
635
|
-
}
|
|
636
|
-
if (error.code) {
|
|
637
|
-
// @ts-ignore
|
|
638
|
-
this.code = error.code;
|
|
639
|
-
}
|
|
640
|
-
}
|
|
647
|
+
const defaultRequiresSocket = () => {
|
|
648
|
+
return false;
|
|
641
649
|
};
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
} else {
|
|
658
|
-
super(betterMessage);
|
|
659
|
-
}
|
|
660
|
-
// @ts-ignore
|
|
661
|
-
this.name = 'IpcError';
|
|
662
|
-
// @ts-ignore
|
|
663
|
-
this.stdout = stdout;
|
|
664
|
-
// @ts-ignore
|
|
665
|
-
this.stderr = stderr;
|
|
650
|
+
const defaultResolve = resolve;
|
|
651
|
+
|
|
652
|
+
// TODO maybe remove this in v6 or v7, only accept options object to simplify the code
|
|
653
|
+
const normalizeParams = args => {
|
|
654
|
+
if (args.length === 1) {
|
|
655
|
+
const options = args[0];
|
|
656
|
+
return {
|
|
657
|
+
ipc: options.ipc,
|
|
658
|
+
message: options.message,
|
|
659
|
+
execute: options.execute,
|
|
660
|
+
resolve: options.resolve || defaultResolve,
|
|
661
|
+
preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
|
|
662
|
+
logError: options.logError || defaultLogError,
|
|
663
|
+
requiresSocket: options.requiresSocket || defaultRequiresSocket
|
|
664
|
+
};
|
|
666
665
|
}
|
|
667
|
-
}
|
|
668
|
-
const withResolvers = () => {
|
|
669
|
-
let _resolve;
|
|
670
|
-
const promise = new Promise(resolve => {
|
|
671
|
-
_resolve = resolve;
|
|
672
|
-
});
|
|
673
666
|
return {
|
|
674
|
-
|
|
675
|
-
|
|
667
|
+
ipc: args[0],
|
|
668
|
+
message: args[1],
|
|
669
|
+
execute: args[2],
|
|
670
|
+
resolve: args[3],
|
|
671
|
+
preparePrettyError: args[4],
|
|
672
|
+
logError: args[5],
|
|
673
|
+
requiresSocket: args[6]
|
|
676
674
|
};
|
|
677
675
|
};
|
|
678
|
-
const
|
|
676
|
+
const handleJsonRpcMessage = async (...args) => {
|
|
677
|
+
const options = normalizeParams(args);
|
|
679
678
|
const {
|
|
679
|
+
message,
|
|
680
|
+
ipc,
|
|
681
|
+
execute,
|
|
680
682
|
resolve,
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
if (firstMessage.method !== 'initialize') {
|
|
696
|
-
throw new IpcError('unexpected first message');
|
|
697
|
-
}
|
|
698
|
-
const type = firstMessage.params[0];
|
|
699
|
-
if (type === 'message-port') {
|
|
700
|
-
parentIpc.send({
|
|
701
|
-
jsonrpc: '2.0',
|
|
702
|
-
id: firstMessage.id,
|
|
703
|
-
result: null
|
|
704
|
-
});
|
|
705
|
-
parentIpc.dispose();
|
|
706
|
-
const port = firstMessage.params[1];
|
|
707
|
-
return port;
|
|
708
|
-
}
|
|
709
|
-
return globalThis;
|
|
710
|
-
};
|
|
711
|
-
class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
712
|
-
constructor(port) {
|
|
713
|
-
super(port);
|
|
714
|
-
}
|
|
715
|
-
getData(event) {
|
|
716
|
-
return getData$1(event);
|
|
717
|
-
}
|
|
718
|
-
send(message) {
|
|
719
|
-
this._rawIpc.postMessage(message);
|
|
720
|
-
}
|
|
721
|
-
sendAndTransfer(message) {
|
|
722
|
-
const transfer = getTransferrables(message);
|
|
723
|
-
this._rawIpc.postMessage(message, transfer);
|
|
724
|
-
}
|
|
725
|
-
dispose() {
|
|
726
|
-
if (this._rawIpc.close) {
|
|
727
|
-
this._rawIpc.close();
|
|
683
|
+
preparePrettyError,
|
|
684
|
+
logError,
|
|
685
|
+
requiresSocket
|
|
686
|
+
} = options;
|
|
687
|
+
if ('id' in message) {
|
|
688
|
+
if ('method' in message) {
|
|
689
|
+
const response = await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
690
|
+
try {
|
|
691
|
+
ipc.send(response);
|
|
692
|
+
} catch (error) {
|
|
693
|
+
const errorResponse = getErrorResponse(message, error, preparePrettyError, logError);
|
|
694
|
+
ipc.send(errorResponse);
|
|
695
|
+
}
|
|
696
|
+
return;
|
|
728
697
|
}
|
|
698
|
+
resolve(message.id, message);
|
|
699
|
+
return;
|
|
729
700
|
}
|
|
730
|
-
|
|
731
|
-
|
|
701
|
+
if ('method' in message) {
|
|
702
|
+
await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
703
|
+
return;
|
|
732
704
|
}
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
705
|
+
throw new JsonRpcError('unexpected message');
|
|
706
|
+
};
|
|
707
|
+
const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
708
|
+
const {
|
|
709
|
+
message,
|
|
710
|
+
promise
|
|
711
|
+
} = create$2(method, params);
|
|
712
|
+
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
713
|
+
ipc.sendAndTransfer(message);
|
|
714
|
+
} else {
|
|
715
|
+
ipc.send(message);
|
|
736
716
|
}
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
717
|
+
const responseMessage = await promise;
|
|
718
|
+
return unwrapJsonRpcResult(responseMessage);
|
|
740
719
|
};
|
|
741
|
-
const
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
720
|
+
const send = (transport, method, ...params) => {
|
|
721
|
+
const message = create$4(method, params);
|
|
722
|
+
transport.send(message);
|
|
723
|
+
};
|
|
724
|
+
const invoke$2 = (ipc, method, ...params) => {
|
|
725
|
+
return invokeHelper(ipc, method, params, false);
|
|
726
|
+
};
|
|
727
|
+
const invokeAndTransfer = (ipc, method, ...params) => {
|
|
728
|
+
return invokeHelper(ipc, method, params, true);
|
|
729
|
+
};
|
|
730
|
+
|
|
731
|
+
const commands = Object.create(null);
|
|
732
|
+
const register = commandMap => {
|
|
733
|
+
Object.assign(commands, commandMap);
|
|
734
|
+
};
|
|
735
|
+
const getCommand = key => {
|
|
736
|
+
return commands[key];
|
|
737
|
+
};
|
|
738
|
+
const execute$1 = (command, ...args) => {
|
|
739
|
+
const fn = getCommand(command);
|
|
740
|
+
if (!fn) {
|
|
741
|
+
throw new Error(`command not found ${command}`);
|
|
742
|
+
}
|
|
743
|
+
return fn(...args);
|
|
745
744
|
};
|
|
746
745
|
|
|
747
746
|
const createRpc = ipc => {
|
|
@@ -771,97 +770,47 @@ const logError = () => {
|
|
|
771
770
|
// handled by renderer worker
|
|
772
771
|
};
|
|
773
772
|
const handleMessage = event => {
|
|
774
|
-
|
|
773
|
+
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
|
|
774
|
+
return handleJsonRpcMessage(event.target, event.data, execute$1, resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
775
775
|
};
|
|
776
776
|
const handleIpc = ipc => {
|
|
777
|
-
|
|
777
|
+
if ('addEventListener' in ipc) {
|
|
778
|
+
ipc.addEventListener('message', handleMessage);
|
|
779
|
+
} else if ('on' in ipc) {
|
|
780
|
+
// deprecated
|
|
781
|
+
ipc.on('message', handleMessage);
|
|
782
|
+
}
|
|
778
783
|
};
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
+
const listen$1 = async (module, options) => {
|
|
785
|
+
const rawIpc = await module.listen(options);
|
|
786
|
+
if (module.signal) {
|
|
787
|
+
module.signal(rawIpc);
|
|
788
|
+
}
|
|
784
789
|
const ipc = module.wrap(rawIpc);
|
|
785
790
|
return ipc;
|
|
786
791
|
};
|
|
787
|
-
const create
|
|
792
|
+
const create = async ({
|
|
788
793
|
commandMap
|
|
789
794
|
}) => {
|
|
790
795
|
// TODO create a commandMap per rpc instance
|
|
791
796
|
register(commandMap);
|
|
792
|
-
const ipc = await listen$1();
|
|
797
|
+
const ipc = await listen$1(IpcChildWithModuleWorkerAndMessagePort$1);
|
|
793
798
|
handleIpc(ipc);
|
|
794
799
|
const rpc = createRpc(ipc);
|
|
795
800
|
return rpc;
|
|
796
801
|
};
|
|
797
802
|
const WebWorkerRpcClient = {
|
|
798
803
|
__proto__: null,
|
|
799
|
-
create
|
|
804
|
+
create
|
|
800
805
|
};
|
|
801
806
|
|
|
802
807
|
const assetDir = '';
|
|
803
808
|
|
|
804
809
|
const Directory$1 = 3;
|
|
805
|
-
const File$
|
|
810
|
+
const File$2 = 7;
|
|
806
811
|
|
|
807
812
|
const fileMapUrl = `${assetDir}/config/fileMap.json`;
|
|
808
813
|
|
|
809
|
-
const normalizeLine = line => {
|
|
810
|
-
if (line.startsWith('Error: ')) {
|
|
811
|
-
return line.slice('Error: '.length);
|
|
812
|
-
}
|
|
813
|
-
if (line.startsWith('VError: ')) {
|
|
814
|
-
return line.slice('VError: '.length);
|
|
815
|
-
}
|
|
816
|
-
return line;
|
|
817
|
-
};
|
|
818
|
-
const getCombinedMessage = (error, message) => {
|
|
819
|
-
const stringifiedError = normalizeLine(`${error}`);
|
|
820
|
-
if (message) {
|
|
821
|
-
return `${message}: ${stringifiedError}`;
|
|
822
|
-
}
|
|
823
|
-
return stringifiedError;
|
|
824
|
-
};
|
|
825
|
-
const NewLine = '\n';
|
|
826
|
-
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
827
|
-
return string.indexOf(NewLine, startIndex);
|
|
828
|
-
};
|
|
829
|
-
const mergeStacks = (parent, child) => {
|
|
830
|
-
if (!child) {
|
|
831
|
-
return parent;
|
|
832
|
-
}
|
|
833
|
-
const parentNewLineIndex = getNewLineIndex(parent);
|
|
834
|
-
const childNewLineIndex = getNewLineIndex(child);
|
|
835
|
-
if (childNewLineIndex === -1) {
|
|
836
|
-
return parent;
|
|
837
|
-
}
|
|
838
|
-
const parentFirstLine = parent.slice(0, parentNewLineIndex);
|
|
839
|
-
const childRest = child.slice(childNewLineIndex);
|
|
840
|
-
const childFirstLine = normalizeLine(child.slice(0, childNewLineIndex));
|
|
841
|
-
if (parentFirstLine.includes(childFirstLine)) {
|
|
842
|
-
return parentFirstLine + childRest;
|
|
843
|
-
}
|
|
844
|
-
return child;
|
|
845
|
-
};
|
|
846
|
-
class VError extends Error {
|
|
847
|
-
constructor(error, message) {
|
|
848
|
-
const combinedMessage = getCombinedMessage(error, message);
|
|
849
|
-
super(combinedMessage);
|
|
850
|
-
this.name = 'VError';
|
|
851
|
-
if (error instanceof Error) {
|
|
852
|
-
this.stack = mergeStacks(this.stack, error.stack);
|
|
853
|
-
}
|
|
854
|
-
if (error.codeFrame) {
|
|
855
|
-
// @ts-ignore
|
|
856
|
-
this.codeFrame = error.codeFrame;
|
|
857
|
-
}
|
|
858
|
-
if (error.code) {
|
|
859
|
-
// @ts-ignore
|
|
860
|
-
this.code = error.code;
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
|
|
865
814
|
const getJson = async url => {
|
|
866
815
|
try {
|
|
867
816
|
const response = await fetch(url);
|
|
@@ -925,7 +874,7 @@ const readDirWithFileTypes$1 = async uri => {
|
|
|
925
874
|
});
|
|
926
875
|
} else {
|
|
927
876
|
dirents.push({
|
|
928
|
-
type: File$
|
|
877
|
+
type: File$2,
|
|
929
878
|
name: rest
|
|
930
879
|
});
|
|
931
880
|
}
|
|
@@ -1013,18 +962,18 @@ const getContentType = uri => {
|
|
|
1013
962
|
|
|
1014
963
|
// TODO move this to an extension?
|
|
1015
964
|
|
|
1016
|
-
const state$
|
|
965
|
+
const state$5 = {
|
|
1017
966
|
files: Object.create(null)
|
|
1018
967
|
};
|
|
1019
968
|
const getDirent = uri => {
|
|
1020
|
-
return state$
|
|
969
|
+
return state$5.files[uri];
|
|
1021
970
|
};
|
|
1022
971
|
const readFile = uri => {
|
|
1023
972
|
const dirent = getDirent(uri);
|
|
1024
973
|
if (!dirent) {
|
|
1025
974
|
throw new FileNotFoundError(uri);
|
|
1026
975
|
}
|
|
1027
|
-
if (dirent.type !== File$
|
|
976
|
+
if (dirent.type !== File$2) {
|
|
1028
977
|
throw new Error('file is a directory');
|
|
1029
978
|
}
|
|
1030
979
|
return dirent.content;
|
|
@@ -1034,7 +983,7 @@ const ensureParentDir = uri => {
|
|
|
1034
983
|
let endIndex = uri.indexOf(Slash);
|
|
1035
984
|
while (endIndex >= 0) {
|
|
1036
985
|
const part = uri.slice(startIndex, endIndex + 1);
|
|
1037
|
-
state$
|
|
986
|
+
state$5.files[part] = {
|
|
1038
987
|
type: Directory$1,
|
|
1039
988
|
content: ''
|
|
1040
989
|
};
|
|
@@ -1047,8 +996,8 @@ const writeFile = (uri, content) => {
|
|
|
1047
996
|
dirent.content = content;
|
|
1048
997
|
} else {
|
|
1049
998
|
ensureParentDir(uri);
|
|
1050
|
-
state$
|
|
1051
|
-
type: File$
|
|
999
|
+
state$5.files[uri] = {
|
|
1000
|
+
type: File$2,
|
|
1052
1001
|
content
|
|
1053
1002
|
};
|
|
1054
1003
|
}
|
|
@@ -1058,20 +1007,20 @@ const mkdir = uri => {
|
|
|
1058
1007
|
uri += Slash;
|
|
1059
1008
|
}
|
|
1060
1009
|
ensureParentDir(uri);
|
|
1061
|
-
state$
|
|
1010
|
+
state$5.files[uri] = {
|
|
1062
1011
|
type: Directory$1,
|
|
1063
1012
|
content: ''
|
|
1064
1013
|
};
|
|
1065
1014
|
};
|
|
1066
1015
|
const remove = uri => {
|
|
1067
1016
|
const toDelete = [];
|
|
1068
|
-
for (const key of Object.keys(state$
|
|
1017
|
+
for (const key of Object.keys(state$5.files)) {
|
|
1069
1018
|
if (key.startsWith(uri)) {
|
|
1070
1019
|
toDelete.push(key);
|
|
1071
1020
|
}
|
|
1072
1021
|
}
|
|
1073
1022
|
for (const key of toDelete) {
|
|
1074
|
-
delete state$
|
|
1023
|
+
delete state$5.files[key];
|
|
1075
1024
|
}
|
|
1076
1025
|
};
|
|
1077
1026
|
const readDirWithFileTypes = uri => {
|
|
@@ -1079,7 +1028,7 @@ const readDirWithFileTypes = uri => {
|
|
|
1079
1028
|
uri += Slash;
|
|
1080
1029
|
}
|
|
1081
1030
|
const dirents = [];
|
|
1082
|
-
for (const [key, value] of Object.entries(state$
|
|
1031
|
+
for (const [key, value] of Object.entries(state$5.files)) {
|
|
1083
1032
|
if (key.startsWith(uri)) {
|
|
1084
1033
|
// @ts-ignore
|
|
1085
1034
|
switch (value.type) {
|
|
@@ -1092,7 +1041,7 @@ const readDirWithFileTypes = uri => {
|
|
|
1092
1041
|
});
|
|
1093
1042
|
}
|
|
1094
1043
|
break;
|
|
1095
|
-
case File$
|
|
1044
|
+
case File$2:
|
|
1096
1045
|
if (!key.includes(Slash, uri.length + 1)) {
|
|
1097
1046
|
dirents.push({
|
|
1098
1047
|
// @ts-ignore
|
|
@@ -1123,7 +1072,7 @@ const chmod = () => {
|
|
|
1123
1072
|
throw new Error('[memfs] chmod not implemented');
|
|
1124
1073
|
};
|
|
1125
1074
|
const getFiles = () => {
|
|
1126
|
-
return state$
|
|
1075
|
+
return state$5.files;
|
|
1127
1076
|
};
|
|
1128
1077
|
|
|
1129
1078
|
const emptyMatches = [];
|
|
@@ -1360,6 +1309,7 @@ const getFolderIcon = () => {
|
|
|
1360
1309
|
};
|
|
1361
1310
|
|
|
1362
1311
|
const Hide = 'hide';
|
|
1312
|
+
const KeepOpen = '';
|
|
1363
1313
|
|
|
1364
1314
|
const emptyObject = {};
|
|
1365
1315
|
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
@@ -1392,6 +1342,30 @@ const UiStrings = {
|
|
|
1392
1342
|
TypeNameOfCommandToRun: 'Type the name of a command to run.',
|
|
1393
1343
|
TypeTheNameOfAViewToOpen: 'Type the name of a view, output channel or terminal to open.'
|
|
1394
1344
|
};
|
|
1345
|
+
const noMatchingColorThemesFound = () => {
|
|
1346
|
+
return i18nString(UiStrings.NoMatchingColorThemesFound);
|
|
1347
|
+
};
|
|
1348
|
+
const selectColorTheme = () => {
|
|
1349
|
+
return i18nString(UiStrings.SelectColorTheme);
|
|
1350
|
+
};
|
|
1351
|
+
const typeNameofCommandToRun = () => {
|
|
1352
|
+
return i18nString(UiStrings.TypeNameOfCommandToRun);
|
|
1353
|
+
};
|
|
1354
|
+
const showAndRunCommands = () => {
|
|
1355
|
+
return i18nString(UiStrings.ShowAndRunCommands);
|
|
1356
|
+
};
|
|
1357
|
+
const noMatchingResults = () => {
|
|
1358
|
+
return i18nString(UiStrings.NoMatchingResults);
|
|
1359
|
+
};
|
|
1360
|
+
const files = () => {
|
|
1361
|
+
return i18nString(UiStrings.Files);
|
|
1362
|
+
};
|
|
1363
|
+
const goToFile = () => {
|
|
1364
|
+
return i18nString(UiStrings.GoToFile);
|
|
1365
|
+
};
|
|
1366
|
+
const noResults = () => {
|
|
1367
|
+
return i18nString(UiStrings.NoResults);
|
|
1368
|
+
};
|
|
1395
1369
|
const selectToOpen = () => {
|
|
1396
1370
|
return i18nString(UiStrings.SelectToOpen);
|
|
1397
1371
|
};
|
|
@@ -1401,17 +1375,23 @@ const openRecent = () => {
|
|
|
1401
1375
|
const noRecentlyOpenedFoldersFound = () => {
|
|
1402
1376
|
return i18nString(UiStrings.NoRecentlyOpenedFoldersFound);
|
|
1403
1377
|
};
|
|
1378
|
+
const noSymbolFound = () => {
|
|
1379
|
+
return i18nString(UiStrings.NoSymbolFound);
|
|
1380
|
+
};
|
|
1381
|
+
const noWorkspaceSymbolsFound = () => {
|
|
1382
|
+
return i18nString(UiStrings.NoWorkspaceSymbolsFound);
|
|
1383
|
+
};
|
|
1404
1384
|
|
|
1405
|
-
const state$
|
|
1385
|
+
const state$4 = {
|
|
1406
1386
|
rpc: undefined
|
|
1407
1387
|
};
|
|
1408
1388
|
const invoke$1 = (method, ...params) => {
|
|
1409
|
-
const rpc = state$
|
|
1389
|
+
const rpc = state$4.rpc;
|
|
1410
1390
|
// @ts-ignore
|
|
1411
1391
|
return rpc.invoke(method, ...params);
|
|
1412
1392
|
};
|
|
1413
1393
|
const setRpc = rpc => {
|
|
1414
|
-
state$
|
|
1394
|
+
state$4.rpc = rpc;
|
|
1415
1395
|
};
|
|
1416
1396
|
|
|
1417
1397
|
// TODO this should be in FileSystem module
|
|
@@ -1435,16 +1415,16 @@ const getRecentlyOpened = () => {
|
|
|
1435
1415
|
const openWorkspaceFolder = uri => {
|
|
1436
1416
|
return invoke$1(/* Workspace.setPath */'Workspace.setPath', /* path */uri);
|
|
1437
1417
|
};
|
|
1438
|
-
const getPlaceholder = () => {
|
|
1418
|
+
const getPlaceholder$b = () => {
|
|
1439
1419
|
return selectToOpen();
|
|
1440
1420
|
};
|
|
1441
|
-
const getLabel = () => {
|
|
1421
|
+
const getLabel$5 = () => {
|
|
1442
1422
|
return openRecent();
|
|
1443
1423
|
};
|
|
1444
|
-
const getHelpEntries = () => {
|
|
1424
|
+
const getHelpEntries$9 = () => {
|
|
1445
1425
|
return [];
|
|
1446
1426
|
};
|
|
1447
|
-
const getNoResults = () => {
|
|
1427
|
+
const getNoResults$a = () => {
|
|
1448
1428
|
return {
|
|
1449
1429
|
label: noRecentlyOpenedFoldersFound()
|
|
1450
1430
|
};
|
|
@@ -1455,69 +1435,413 @@ const getNoResults = () => {
|
|
|
1455
1435
|
// This would make the code more module since the code for getting the picks
|
|
1456
1436
|
// would be more independent of the specific data format of the quickpick provider
|
|
1457
1437
|
|
|
1458
|
-
const getPicks = async () => {
|
|
1438
|
+
const getPicks$b = async () => {
|
|
1459
1439
|
const recentlyOpened = await getRecentlyOpened();
|
|
1460
1440
|
return recentlyOpened;
|
|
1461
1441
|
};
|
|
1462
1442
|
|
|
1463
1443
|
// TODO selectPick should be independent of show/hide
|
|
1464
|
-
const selectPick = async pick => {
|
|
1444
|
+
const selectPick$b = async pick => {
|
|
1465
1445
|
const path = pick;
|
|
1466
1446
|
await openWorkspaceFolder(path);
|
|
1467
1447
|
return {
|
|
1468
1448
|
command: Hide
|
|
1469
1449
|
};
|
|
1470
1450
|
};
|
|
1471
|
-
const getFilterValue = value => {
|
|
1472
|
-
return pathBaseName(value);
|
|
1451
|
+
const getFilterValue$a = value => {
|
|
1452
|
+
return pathBaseName(value);
|
|
1453
|
+
};
|
|
1454
|
+
const getPickFilterValue$6 = pick => {
|
|
1455
|
+
return pathBaseName(pick);
|
|
1456
|
+
};
|
|
1457
|
+
const getPickLabel$5 = pick => {
|
|
1458
|
+
return pathBaseName(pick);
|
|
1459
|
+
};
|
|
1460
|
+
const getPickDescription$3 = pick => {
|
|
1461
|
+
return pathDirName(pick);
|
|
1462
|
+
};
|
|
1463
|
+
const getPickIcon$5 = () => {
|
|
1464
|
+
return '';
|
|
1465
|
+
};
|
|
1466
|
+
const getPickFileIcon$2 = () => {
|
|
1467
|
+
return getFolderIcon();
|
|
1468
|
+
};
|
|
1469
|
+
|
|
1470
|
+
const QuickPickEntriesOpenRecent = {
|
|
1471
|
+
__proto__: null,
|
|
1472
|
+
getFilterValue: getFilterValue$a,
|
|
1473
|
+
getHelpEntries: getHelpEntries$9,
|
|
1474
|
+
getLabel: getLabel$5,
|
|
1475
|
+
getNoResults: getNoResults$a,
|
|
1476
|
+
getPickDescription: getPickDescription$3,
|
|
1477
|
+
getPickFileIcon: getPickFileIcon$2,
|
|
1478
|
+
getPickFilterValue: getPickFilterValue$6,
|
|
1479
|
+
getPickIcon: getPickIcon$5,
|
|
1480
|
+
getPickLabel: getPickLabel$5,
|
|
1481
|
+
getPicks: getPicks$b,
|
|
1482
|
+
getPlaceholder: getPlaceholder$b,
|
|
1483
|
+
selectPick: selectPick$b
|
|
1484
|
+
};
|
|
1485
|
+
|
|
1486
|
+
const CommandPalette = 'quickPick://commandPalette';
|
|
1487
|
+
const File$1 = 'quickPick://file';
|
|
1488
|
+
const EveryThing = 'quickPick://everything';
|
|
1489
|
+
const Number$1 = 'quickPick://number';
|
|
1490
|
+
const Recent = 'quickPick://recent';
|
|
1491
|
+
const ColorTheme = 'quickPick://color-theme';
|
|
1492
|
+
const Symbol$2 = 'quickPick://symbol';
|
|
1493
|
+
const View$1 = 'quickPick://view';
|
|
1494
|
+
const WorkspaceSymbol$1 = 'quickPick://workspace-symbol';
|
|
1495
|
+
const Custom = 'quickPick://custom';
|
|
1496
|
+
|
|
1497
|
+
const loadQuickPickEntries = moduleId => {
|
|
1498
|
+
switch (moduleId) {
|
|
1499
|
+
case Recent:
|
|
1500
|
+
return QuickPickEntriesOpenRecent;
|
|
1501
|
+
default:
|
|
1502
|
+
throw new Error(`unknown module "${moduleId}"`);
|
|
1503
|
+
}
|
|
1504
|
+
};
|
|
1505
|
+
|
|
1506
|
+
const getColorThemeNames = async () => {
|
|
1507
|
+
return invoke$1(/* Ajax.getJson */'ColorTheme.getColorThemeNames');
|
|
1508
|
+
};
|
|
1509
|
+
|
|
1510
|
+
const setColorTheme = id => {
|
|
1511
|
+
return invoke$1(/* ColorTheme.setColorTheme */'ColorTheme.setColorTheme', /* colorThemeId */id);
|
|
1512
|
+
};
|
|
1513
|
+
const getPlaceholder$a = () => {
|
|
1514
|
+
return selectColorTheme();
|
|
1515
|
+
};
|
|
1516
|
+
const getLabel$4 = () => {
|
|
1517
|
+
return selectColorTheme();
|
|
1518
|
+
};
|
|
1519
|
+
const getPicks$a = async searchValue => {
|
|
1520
|
+
const colorThemeNames = await getColorThemeNames();
|
|
1521
|
+
return colorThemeNames;
|
|
1522
|
+
};
|
|
1523
|
+
const selectPick$a = async pick => {
|
|
1524
|
+
await setColorTheme(/* colorThemeId */pick);
|
|
1525
|
+
return {
|
|
1526
|
+
command: Hide
|
|
1527
|
+
};
|
|
1528
|
+
};
|
|
1529
|
+
const focusPick = async pick => {
|
|
1530
|
+
await setColorTheme(/* colorThemeId */pick);
|
|
1531
|
+
};
|
|
1532
|
+
const getFilterValue$9 = value => {
|
|
1533
|
+
return value;
|
|
1534
|
+
};
|
|
1535
|
+
const getNoResults$9 = () => {
|
|
1536
|
+
return {
|
|
1537
|
+
label: noMatchingColorThemesFound()
|
|
1538
|
+
};
|
|
1539
|
+
};
|
|
1540
|
+
const getPickFilterValue$5 = pick => {
|
|
1541
|
+
return pick;
|
|
1542
|
+
};
|
|
1543
|
+
const getPickLabel$4 = pick => {
|
|
1544
|
+
return pick;
|
|
1545
|
+
};
|
|
1546
|
+
const getPickIcon$4 = pick => {
|
|
1547
|
+
return '';
|
|
1548
|
+
};
|
|
1549
|
+
|
|
1550
|
+
const QuickPickEntriesColorTheme = {
|
|
1551
|
+
__proto__: null,
|
|
1552
|
+
focusPick,
|
|
1553
|
+
getFilterValue: getFilterValue$9,
|
|
1554
|
+
getLabel: getLabel$4,
|
|
1555
|
+
getNoResults: getNoResults$9,
|
|
1556
|
+
getPickFilterValue: getPickFilterValue$5,
|
|
1557
|
+
getPickIcon: getPickIcon$4,
|
|
1558
|
+
getPickLabel: getPickLabel$4,
|
|
1559
|
+
getPicks: getPicks$a,
|
|
1560
|
+
getPlaceholder: getPlaceholder$a,
|
|
1561
|
+
selectPick: selectPick$a,
|
|
1562
|
+
setColorTheme
|
|
1563
|
+
};
|
|
1564
|
+
|
|
1565
|
+
const Tag$1 = 'Tag';
|
|
1566
|
+
const Cloud$1 = 'Cloud';
|
|
1567
|
+
const SourceControl$1 = 'SourceControl';
|
|
1568
|
+
const None$1 = '';
|
|
1569
|
+
|
|
1570
|
+
const SourceControl = 1;
|
|
1571
|
+
const Cloud = 2;
|
|
1572
|
+
const Tag = 3;
|
|
1573
|
+
|
|
1574
|
+
const name$8 = 'custom';
|
|
1575
|
+
const state$3 = {
|
|
1576
|
+
args: []
|
|
1577
|
+
};
|
|
1578
|
+
const setArgs = args => {
|
|
1579
|
+
state$3.args = args;
|
|
1580
|
+
};
|
|
1581
|
+
const getPlaceholder$9 = () => {
|
|
1582
|
+
return '';
|
|
1583
|
+
};
|
|
1584
|
+
const getLabel$3 = () => {
|
|
1585
|
+
return 'Custom';
|
|
1586
|
+
};
|
|
1587
|
+
|
|
1588
|
+
// TODO help entries should not be here
|
|
1589
|
+
const getHelpEntries$8 = () => {
|
|
1590
|
+
return [];
|
|
1591
|
+
};
|
|
1592
|
+
const getNoResults$8 = () => {
|
|
1593
|
+
return {
|
|
1594
|
+
label: noMatchingResults()
|
|
1595
|
+
};
|
|
1596
|
+
};
|
|
1597
|
+
const getPicks$9 = async searchValue => {
|
|
1598
|
+
const items = state$3.args[1] || [];
|
|
1599
|
+
return items;
|
|
1600
|
+
};
|
|
1601
|
+
const selectPick$9 = async pick => {
|
|
1602
|
+
const {
|
|
1603
|
+
args
|
|
1604
|
+
} = state$3;
|
|
1605
|
+
const resolve = args[2];
|
|
1606
|
+
resolve(pick);
|
|
1607
|
+
return {
|
|
1608
|
+
command: Hide
|
|
1609
|
+
};
|
|
1610
|
+
};
|
|
1611
|
+
const getFilterValue$8 = value => {
|
|
1612
|
+
return value;
|
|
1613
|
+
};
|
|
1614
|
+
const getPickFilterValue$4 = pick => {
|
|
1615
|
+
return pick;
|
|
1616
|
+
};
|
|
1617
|
+
const getPickLabel$3 = pick => {
|
|
1618
|
+
return pick.label;
|
|
1619
|
+
};
|
|
1620
|
+
const getPickDescription$2 = pick => {
|
|
1621
|
+
return pick.description || '';
|
|
1622
|
+
};
|
|
1623
|
+
const convertIcon = icon => {
|
|
1624
|
+
switch (icon) {
|
|
1625
|
+
case SourceControl:
|
|
1626
|
+
return SourceControl$1;
|
|
1627
|
+
case Cloud:
|
|
1628
|
+
return Cloud$1;
|
|
1629
|
+
case Tag:
|
|
1630
|
+
return Tag$1;
|
|
1631
|
+
default:
|
|
1632
|
+
return None$1;
|
|
1633
|
+
}
|
|
1634
|
+
};
|
|
1635
|
+
const getPickIcon$3 = pick => {
|
|
1636
|
+
return convertIcon(pick.icon);
|
|
1637
|
+
};
|
|
1638
|
+
|
|
1639
|
+
const QuickPickEntriesCustom = {
|
|
1640
|
+
__proto__: null,
|
|
1641
|
+
getFilterValue: getFilterValue$8,
|
|
1642
|
+
getHelpEntries: getHelpEntries$8,
|
|
1643
|
+
getLabel: getLabel$3,
|
|
1644
|
+
getNoResults: getNoResults$8,
|
|
1645
|
+
getPickDescription: getPickDescription$2,
|
|
1646
|
+
getPickFilterValue: getPickFilterValue$4,
|
|
1647
|
+
getPickIcon: getPickIcon$3,
|
|
1648
|
+
getPickLabel: getPickLabel$3,
|
|
1649
|
+
getPicks: getPicks$9,
|
|
1650
|
+
getPlaceholder: getPlaceholder$9,
|
|
1651
|
+
name: name$8,
|
|
1652
|
+
selectPick: selectPick$9,
|
|
1653
|
+
setArgs,
|
|
1654
|
+
state: state$3
|
|
1655
|
+
};
|
|
1656
|
+
|
|
1657
|
+
const name$7 = 'noop';
|
|
1658
|
+
const getPlaceholder$8 = () => {
|
|
1659
|
+
return '';
|
|
1660
|
+
};
|
|
1661
|
+
const getHelpEntries$7 = () => {
|
|
1662
|
+
return [];
|
|
1663
|
+
};
|
|
1664
|
+
const getNoResults$7 = () => {
|
|
1665
|
+
return noResults();
|
|
1666
|
+
};
|
|
1667
|
+
const getPicks$8 = async value => {
|
|
1668
|
+
return [];
|
|
1669
|
+
};
|
|
1670
|
+
const selectPick$8 = async item => {
|
|
1671
|
+
return {
|
|
1672
|
+
command: Hide
|
|
1673
|
+
};
|
|
1674
|
+
};
|
|
1675
|
+
const getFilterValue$7 = value => {
|
|
1676
|
+
return value;
|
|
1677
|
+
};
|
|
1678
|
+
const getPickFilterValue$3 = pick => {
|
|
1679
|
+
return pick;
|
|
1680
|
+
};
|
|
1681
|
+
|
|
1682
|
+
const QuickPickNoop = {
|
|
1683
|
+
__proto__: null,
|
|
1684
|
+
getFilterValue: getFilterValue$7,
|
|
1685
|
+
getHelpEntries: getHelpEntries$7,
|
|
1686
|
+
getNoResults: getNoResults$7,
|
|
1687
|
+
getPickFilterValue: getPickFilterValue$3,
|
|
1688
|
+
getPicks: getPicks$8,
|
|
1689
|
+
getPlaceholder: getPlaceholder$8,
|
|
1690
|
+
name: name$7,
|
|
1691
|
+
selectPick: selectPick$8
|
|
1692
|
+
};
|
|
1693
|
+
|
|
1694
|
+
const Command = '>';
|
|
1695
|
+
const Symbol$1 = '@';
|
|
1696
|
+
const WorkspaceSymbol = '#';
|
|
1697
|
+
const GoToLine = ':';
|
|
1698
|
+
const View = 'view ';
|
|
1699
|
+
const None = '';
|
|
1700
|
+
|
|
1701
|
+
const handleError = async (error, notify = true, prefix = '') => {
|
|
1702
|
+
console.error(error);
|
|
1703
|
+
};
|
|
1704
|
+
const showErrorDialog = async () => {};
|
|
1705
|
+
const warn = (...args) => {
|
|
1706
|
+
console.warn(...args);
|
|
1707
|
+
};
|
|
1708
|
+
|
|
1709
|
+
const state$2 = {
|
|
1710
|
+
menuEntries: []
|
|
1711
|
+
};
|
|
1712
|
+
const getAll = () => {
|
|
1713
|
+
return state$2.menuEntries;
|
|
1714
|
+
};
|
|
1715
|
+
|
|
1716
|
+
const name$6 = 'command';
|
|
1717
|
+
const getPlaceholder$7 = () => {
|
|
1718
|
+
return typeNameofCommandToRun();
|
|
1719
|
+
};
|
|
1720
|
+
const helpEntries = () => {
|
|
1721
|
+
return [{
|
|
1722
|
+
description: showAndRunCommands(),
|
|
1723
|
+
category: 'global commands'
|
|
1724
|
+
}];
|
|
1725
|
+
};
|
|
1726
|
+
const getLabel$2 = () => {
|
|
1727
|
+
return '';
|
|
1728
|
+
};
|
|
1729
|
+
const getNoResults$6 = () => {
|
|
1730
|
+
return {
|
|
1731
|
+
label: noMatchingResults()
|
|
1732
|
+
};
|
|
1733
|
+
};
|
|
1734
|
+
|
|
1735
|
+
// TODO combine Ajax with cache (specify strategy: cacheFirst, networkFirst)
|
|
1736
|
+
const getBuiltinPicks = async () => {
|
|
1737
|
+
const builtinPicks = getAll();
|
|
1738
|
+
return builtinPicks;
|
|
1739
|
+
};
|
|
1740
|
+
const prefixIdWithExt = item => {
|
|
1741
|
+
if (!item.label) {
|
|
1742
|
+
warn('[QuickPick] item has missing label', item);
|
|
1743
|
+
}
|
|
1744
|
+
if (!item.id) {
|
|
1745
|
+
warn('[QuickPick] item has missing id', item);
|
|
1746
|
+
}
|
|
1747
|
+
return {
|
|
1748
|
+
...item,
|
|
1749
|
+
id: `ext.${item.id}`,
|
|
1750
|
+
label: item.label || item.id
|
|
1751
|
+
};
|
|
1752
|
+
};
|
|
1753
|
+
const getExtensionPicks = async () => {
|
|
1754
|
+
try {
|
|
1755
|
+
// TODO don't call this every time
|
|
1756
|
+
const extensionPicks = await invoke$1('ExtensionHostCommands.getCommands');
|
|
1757
|
+
if (!extensionPicks) {
|
|
1758
|
+
return [];
|
|
1759
|
+
}
|
|
1760
|
+
const mappedPicks = extensionPicks.map(prefixIdWithExt);
|
|
1761
|
+
return mappedPicks;
|
|
1762
|
+
} catch (error) {
|
|
1763
|
+
console.error(`Failed to get extension picks: ${error}`);
|
|
1764
|
+
return [];
|
|
1765
|
+
}
|
|
1766
|
+
};
|
|
1767
|
+
|
|
1768
|
+
// TODO send strings to renderer process only once for next occurrence send uint16array of ids of strings
|
|
1769
|
+
|
|
1770
|
+
const getPicks$7 = async () => {
|
|
1771
|
+
const builtinPicks = await getBuiltinPicks();
|
|
1772
|
+
const extensionPicks = await getExtensionPicks();
|
|
1773
|
+
return [...builtinPicks, ...extensionPicks];
|
|
1774
|
+
};
|
|
1775
|
+
const shouldHide = item => {
|
|
1776
|
+
if (item.id === 'Viewlet.openWidget' && item.args[0] === 'QuickPick') {
|
|
1777
|
+
return false;
|
|
1778
|
+
}
|
|
1779
|
+
return true;
|
|
1780
|
+
};
|
|
1781
|
+
const selectPickBuiltin = async item => {
|
|
1782
|
+
const args = item.args || [];
|
|
1783
|
+
// TODO ids should be all numbers for efficiency -> also directly can call command
|
|
1784
|
+
await invoke$1(item.id, ...args);
|
|
1785
|
+
if (shouldHide(item)) {
|
|
1786
|
+
return {
|
|
1787
|
+
command: Hide
|
|
1788
|
+
};
|
|
1789
|
+
}
|
|
1790
|
+
return {
|
|
1791
|
+
command: KeepOpen
|
|
1792
|
+
};
|
|
1793
|
+
};
|
|
1794
|
+
const selectPickExtension = async item => {
|
|
1795
|
+
const id = item.id.slice(4); // TODO lots of string allocation with 'ext.' find a better way to separate builtin commands from extension commands
|
|
1796
|
+
try {
|
|
1797
|
+
await invoke$1('ExtensionHostCommands.executeCommand', id);
|
|
1798
|
+
} catch (error) {
|
|
1799
|
+
await handleError(error, false);
|
|
1800
|
+
// @ts-ignore
|
|
1801
|
+
await showErrorDialog();
|
|
1802
|
+
}
|
|
1803
|
+
return {
|
|
1804
|
+
command: Hide
|
|
1805
|
+
};
|
|
1806
|
+
};
|
|
1807
|
+
const selectPick$7 = async item => {
|
|
1808
|
+
if (item.id.startsWith('ext.')) {
|
|
1809
|
+
return selectPickExtension(item);
|
|
1810
|
+
}
|
|
1811
|
+
return selectPickBuiltin(item);
|
|
1473
1812
|
};
|
|
1474
|
-
const
|
|
1475
|
-
return
|
|
1813
|
+
const getFilterValue$6 = value => {
|
|
1814
|
+
return value;
|
|
1476
1815
|
};
|
|
1477
|
-
const
|
|
1478
|
-
return
|
|
1816
|
+
const getPickFilterValue$2 = pick => {
|
|
1817
|
+
return pick.label;
|
|
1479
1818
|
};
|
|
1480
|
-
const
|
|
1481
|
-
return
|
|
1819
|
+
const getPickLabel$2 = pick => {
|
|
1820
|
+
return pick.label;
|
|
1482
1821
|
};
|
|
1483
|
-
const getPickIcon = () => {
|
|
1822
|
+
const getPickIcon$2 = () => {
|
|
1484
1823
|
return '';
|
|
1485
1824
|
};
|
|
1486
|
-
const getPickFileIcon = () => {
|
|
1487
|
-
return getFolderIcon();
|
|
1488
|
-
};
|
|
1489
1825
|
|
|
1490
|
-
const
|
|
1826
|
+
const QuickPickEntriesCommand = {
|
|
1491
1827
|
__proto__: null,
|
|
1492
|
-
getFilterValue,
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
selectPick
|
|
1828
|
+
getFilterValue: getFilterValue$6,
|
|
1829
|
+
getLabel: getLabel$2,
|
|
1830
|
+
getNoResults: getNoResults$6,
|
|
1831
|
+
getPickFilterValue: getPickFilterValue$2,
|
|
1832
|
+
getPickIcon: getPickIcon$2,
|
|
1833
|
+
getPickLabel: getPickLabel$2,
|
|
1834
|
+
getPicks: getPicks$7,
|
|
1835
|
+
getPlaceholder: getPlaceholder$7,
|
|
1836
|
+
helpEntries,
|
|
1837
|
+
name: name$6,
|
|
1838
|
+
selectPick: selectPick$7
|
|
1504
1839
|
};
|
|
1505
1840
|
|
|
1506
|
-
const
|
|
1507
|
-
|
|
1508
|
-
const loadQuickPickEntries = moduleId => {
|
|
1509
|
-
switch (moduleId) {
|
|
1510
|
-
case Recent:
|
|
1511
|
-
return QuickPickEntriesOpenRecent;
|
|
1512
|
-
default:
|
|
1513
|
-
throw new Error(`unknown module "${moduleId}"`);
|
|
1514
|
-
}
|
|
1841
|
+
const execute = async (method, ...params) => {
|
|
1842
|
+
// TODO
|
|
1515
1843
|
};
|
|
1516
1844
|
|
|
1517
|
-
const Memfs = 'memfs';
|
|
1518
|
-
const Html = 'html';
|
|
1519
|
-
const Fetch = 'fetch';
|
|
1520
|
-
|
|
1521
1845
|
const RE_PROTOCOL = /^([a-z-]+):\/\//;
|
|
1522
1846
|
const getProtocol = uri => {
|
|
1523
1847
|
const protocolMatch = uri.match(RE_PROTOCOL);
|
|
@@ -1527,6 +1851,10 @@ const getProtocol = uri => {
|
|
|
1527
1851
|
return '';
|
|
1528
1852
|
};
|
|
1529
1853
|
|
|
1854
|
+
const Memfs = 'memfs';
|
|
1855
|
+
const Html = 'html';
|
|
1856
|
+
const Fetch = 'fetch';
|
|
1857
|
+
|
|
1530
1858
|
const searchFile$4 = async () => {
|
|
1531
1859
|
const files = await getFiles();
|
|
1532
1860
|
const keys = Object.keys(files);
|
|
@@ -1843,7 +2171,7 @@ replaceTraps(oldTraps => ({
|
|
|
1843
2171
|
}
|
|
1844
2172
|
}));
|
|
1845
2173
|
|
|
1846
|
-
const state = {
|
|
2174
|
+
const state$1 = {
|
|
1847
2175
|
databases: Object.create(null),
|
|
1848
2176
|
eventId: 0,
|
|
1849
2177
|
dbVersion: 1,
|
|
@@ -1854,7 +2182,7 @@ const state = {
|
|
|
1854
2182
|
|
|
1855
2183
|
const getHandleDb = async () => {
|
|
1856
2184
|
// @ts-ignore
|
|
1857
|
-
const db = await openDB('handle', state.dbVersion, {
|
|
2185
|
+
const db = await openDB('handle', state$1.dbVersion, {
|
|
1858
2186
|
async upgrade(db) {
|
|
1859
2187
|
if (!db.objectStoreNames.contains('file-handles-store')) {
|
|
1860
2188
|
await db.createObjectStore('file-handles-store', {});
|
|
@@ -1987,6 +2315,494 @@ const searchFile = async (path, value, prepare, assetDir) => {
|
|
|
1987
2315
|
return result;
|
|
1988
2316
|
};
|
|
1989
2317
|
|
|
2318
|
+
const name$5 = 'file';
|
|
2319
|
+
const getPlaceholder$6 = () => {
|
|
2320
|
+
return '';
|
|
2321
|
+
};
|
|
2322
|
+
const getLabel$1 = () => {
|
|
2323
|
+
return files();
|
|
2324
|
+
};
|
|
2325
|
+
|
|
2326
|
+
// TODO help entries should not be here
|
|
2327
|
+
const getHelpEntries$6 = () => {
|
|
2328
|
+
return [{
|
|
2329
|
+
description: goToFile(),
|
|
2330
|
+
category: 'global commands'
|
|
2331
|
+
}];
|
|
2332
|
+
};
|
|
2333
|
+
const getNoResults$5 = () => {
|
|
2334
|
+
return {
|
|
2335
|
+
label: noMatchingResults()
|
|
2336
|
+
};
|
|
2337
|
+
};
|
|
2338
|
+
const getPicks$6 = async searchValue => {
|
|
2339
|
+
{
|
|
2340
|
+
return [];
|
|
2341
|
+
}
|
|
2342
|
+
};
|
|
2343
|
+
const selectPick$6 = async pick => {
|
|
2344
|
+
if (typeof pick === 'object') {
|
|
2345
|
+
pick = pick.pick;
|
|
2346
|
+
}
|
|
2347
|
+
const workspace = '';
|
|
2348
|
+
const absolutePath = `${workspace}/${pick}`;
|
|
2349
|
+
await execute(/* Main.openUri */'Main.openUri', /* uri */absolutePath);
|
|
2350
|
+
return {
|
|
2351
|
+
command: Hide
|
|
2352
|
+
};
|
|
2353
|
+
};
|
|
2354
|
+
const getFilterValue$5 = value => {
|
|
2355
|
+
return value;
|
|
2356
|
+
};
|
|
2357
|
+
const getPickFilterValue$1 = pick => {
|
|
2358
|
+
if (typeof pick === 'object') {
|
|
2359
|
+
pick = pick.pick;
|
|
2360
|
+
}
|
|
2361
|
+
return pick;
|
|
2362
|
+
};
|
|
2363
|
+
const getPickLabel$1 = pick => {
|
|
2364
|
+
if (typeof pick === 'object') {
|
|
2365
|
+
pick = pick.pick;
|
|
2366
|
+
}
|
|
2367
|
+
const baseName = pathBaseName(pick);
|
|
2368
|
+
return baseName;
|
|
2369
|
+
};
|
|
2370
|
+
const getPickDescription$1 = pick => {
|
|
2371
|
+
if (typeof pick === 'object') {
|
|
2372
|
+
pick = pick.pick;
|
|
2373
|
+
}
|
|
2374
|
+
const dirName = pathDirName(pick);
|
|
2375
|
+
return dirName;
|
|
2376
|
+
};
|
|
2377
|
+
const getPickIcon$1 = () => {
|
|
2378
|
+
return '';
|
|
2379
|
+
};
|
|
2380
|
+
const getPickFileIcon$1 = pick => {
|
|
2381
|
+
return '';
|
|
2382
|
+
};
|
|
2383
|
+
const isPrepared$1 = () => {
|
|
2384
|
+
const workspace = '';
|
|
2385
|
+
// TODO protocol should always be defined. For files it should use file protocol
|
|
2386
|
+
const protocol = getProtocol(workspace);
|
|
2387
|
+
return !protocol;
|
|
2388
|
+
};
|
|
2389
|
+
|
|
2390
|
+
const QuickPickEntriesFile = {
|
|
2391
|
+
__proto__: null,
|
|
2392
|
+
getFilterValue: getFilterValue$5,
|
|
2393
|
+
getHelpEntries: getHelpEntries$6,
|
|
2394
|
+
getLabel: getLabel$1,
|
|
2395
|
+
getNoResults: getNoResults$5,
|
|
2396
|
+
getPickDescription: getPickDescription$1,
|
|
2397
|
+
getPickFileIcon: getPickFileIcon$1,
|
|
2398
|
+
getPickFilterValue: getPickFilterValue$1,
|
|
2399
|
+
getPickIcon: getPickIcon$1,
|
|
2400
|
+
getPickLabel: getPickLabel$1,
|
|
2401
|
+
getPicks: getPicks$6,
|
|
2402
|
+
getPlaceholder: getPlaceholder$6,
|
|
2403
|
+
isPrepared: isPrepared$1,
|
|
2404
|
+
name: name$5,
|
|
2405
|
+
selectPick: selectPick$6
|
|
2406
|
+
};
|
|
2407
|
+
|
|
2408
|
+
const name$4 = 'goToLine';
|
|
2409
|
+
const getPlaceholder$5 = () => {
|
|
2410
|
+
return '';
|
|
2411
|
+
};
|
|
2412
|
+
const getHelpEntries$5 = () => {
|
|
2413
|
+
return [];
|
|
2414
|
+
};
|
|
2415
|
+
const getNoResults$4 = () => {
|
|
2416
|
+
return undefined;
|
|
2417
|
+
};
|
|
2418
|
+
const getPicks$5 = async () => {
|
|
2419
|
+
const picks = [{
|
|
2420
|
+
label: '1'
|
|
2421
|
+
}, {
|
|
2422
|
+
label: '2'
|
|
2423
|
+
}, {
|
|
2424
|
+
label: '3'
|
|
2425
|
+
}, {
|
|
2426
|
+
label: '4'
|
|
2427
|
+
}, {
|
|
2428
|
+
label: '5'
|
|
2429
|
+
}, {
|
|
2430
|
+
label: '6'
|
|
2431
|
+
}];
|
|
2432
|
+
return picks;
|
|
2433
|
+
};
|
|
2434
|
+
const selectPick$5 = async item => {
|
|
2435
|
+
const rowIndex = Number.parseInt(item.label);
|
|
2436
|
+
const position = {
|
|
2437
|
+
rowIndex,
|
|
2438
|
+
columnIndex: 5
|
|
2439
|
+
};
|
|
2440
|
+
await execute(/* EditorSetCursor.editorSetCursor */'TODO', /* position */position);
|
|
2441
|
+
// TODO put cursor onto that line
|
|
2442
|
+
return {
|
|
2443
|
+
command: Hide
|
|
2444
|
+
};
|
|
2445
|
+
};
|
|
2446
|
+
const getFilterValue$4 = value => {
|
|
2447
|
+
return value;
|
|
2448
|
+
};
|
|
2449
|
+
|
|
2450
|
+
const QuickPickEntriesGoToLine = {
|
|
2451
|
+
__proto__: null,
|
|
2452
|
+
getFilterValue: getFilterValue$4,
|
|
2453
|
+
getHelpEntries: getHelpEntries$5,
|
|
2454
|
+
getNoResults: getNoResults$4,
|
|
2455
|
+
getPicks: getPicks$5,
|
|
2456
|
+
getPlaceholder: getPlaceholder$5,
|
|
2457
|
+
name: name$4,
|
|
2458
|
+
selectPick: selectPick$5
|
|
2459
|
+
};
|
|
2460
|
+
|
|
2461
|
+
const name$3 = 'symbol';
|
|
2462
|
+
const getPlaceholder$4 = () => {
|
|
2463
|
+
return '';
|
|
2464
|
+
};
|
|
2465
|
+
const getHelpEntries$4 = () => {
|
|
2466
|
+
return [];
|
|
2467
|
+
};
|
|
2468
|
+
const getNoResults$3 = () => {
|
|
2469
|
+
return {
|
|
2470
|
+
label: noSymbolFound()
|
|
2471
|
+
};
|
|
2472
|
+
};
|
|
2473
|
+
const getPicks$4 = async () => {
|
|
2474
|
+
const picks = [];
|
|
2475
|
+
return picks;
|
|
2476
|
+
};
|
|
2477
|
+
const selectPick$4 = async item => {
|
|
2478
|
+
return {
|
|
2479
|
+
command: Hide
|
|
2480
|
+
};
|
|
2481
|
+
};
|
|
2482
|
+
const getFilterValue$3 = value => {
|
|
2483
|
+
return value;
|
|
2484
|
+
};
|
|
2485
|
+
|
|
2486
|
+
const QuickPickEntriesSymbol = {
|
|
2487
|
+
__proto__: null,
|
|
2488
|
+
getFilterValue: getFilterValue$3,
|
|
2489
|
+
getHelpEntries: getHelpEntries$4,
|
|
2490
|
+
getNoResults: getNoResults$3,
|
|
2491
|
+
getPicks: getPicks$4,
|
|
2492
|
+
getPlaceholder: getPlaceholder$4,
|
|
2493
|
+
name: name$3,
|
|
2494
|
+
selectPick: selectPick$4
|
|
2495
|
+
};
|
|
2496
|
+
|
|
2497
|
+
// TODO probably not needed
|
|
2498
|
+
|
|
2499
|
+
const getPlaceholder$3 = () => {
|
|
2500
|
+
return typeNameofCommandToRun();
|
|
2501
|
+
};
|
|
2502
|
+
const getHelpEntries$3 = () => {
|
|
2503
|
+
return undefined;
|
|
2504
|
+
};
|
|
2505
|
+
const getPicks$3 = async () => {
|
|
2506
|
+
// const views = ViewService.getViews()
|
|
2507
|
+
// const picks = views.map(toPick)
|
|
2508
|
+
// return picks
|
|
2509
|
+
return [];
|
|
2510
|
+
};
|
|
2511
|
+
const selectPick$3 = async item => {
|
|
2512
|
+
// Command.execute(/* openView */ 549, /* viewName */ item.label)
|
|
2513
|
+
// return {
|
|
2514
|
+
// command: QuickPickReturnValue.Hide,
|
|
2515
|
+
// }
|
|
2516
|
+
};
|
|
2517
|
+
const getFilterValue$2 = value => {
|
|
2518
|
+
return value;
|
|
2519
|
+
};
|
|
2520
|
+
|
|
2521
|
+
const QuickPickEntriesView = {
|
|
2522
|
+
__proto__: null,
|
|
2523
|
+
getFilterValue: getFilterValue$2,
|
|
2524
|
+
getHelpEntries: getHelpEntries$3,
|
|
2525
|
+
getPicks: getPicks$3,
|
|
2526
|
+
getPlaceholder: getPlaceholder$3,
|
|
2527
|
+
selectPick: selectPick$3
|
|
2528
|
+
};
|
|
2529
|
+
|
|
2530
|
+
const name$2 = 'workspace-symbol';
|
|
2531
|
+
const getPlaceholder$2 = () => {
|
|
2532
|
+
return '';
|
|
2533
|
+
};
|
|
2534
|
+
const getHelpEntries$2 = () => {
|
|
2535
|
+
return [];
|
|
2536
|
+
};
|
|
2537
|
+
const getNoResults$2 = () => {
|
|
2538
|
+
return {
|
|
2539
|
+
label: noWorkspaceSymbolsFound()
|
|
2540
|
+
};
|
|
2541
|
+
};
|
|
2542
|
+
const getPicks$2 = async () => {
|
|
2543
|
+
const picks = [];
|
|
2544
|
+
return picks;
|
|
2545
|
+
};
|
|
2546
|
+
const selectPick$2 = async item => {
|
|
2547
|
+
return {
|
|
2548
|
+
command: Hide
|
|
2549
|
+
};
|
|
2550
|
+
};
|
|
2551
|
+
const getFilterValue$1 = value => {
|
|
2552
|
+
return value;
|
|
2553
|
+
};
|
|
2554
|
+
|
|
2555
|
+
const QuickPickEntriesWorkspaceSymbol = {
|
|
2556
|
+
__proto__: null,
|
|
2557
|
+
getFilterValue: getFilterValue$1,
|
|
2558
|
+
getHelpEntries: getHelpEntries$2,
|
|
2559
|
+
getNoResults: getNoResults$2,
|
|
2560
|
+
getPicks: getPicks$2,
|
|
2561
|
+
getPlaceholder: getPlaceholder$2,
|
|
2562
|
+
name: name$2,
|
|
2563
|
+
selectPick: selectPick$2
|
|
2564
|
+
};
|
|
2565
|
+
|
|
2566
|
+
// TODO avoid global variable
|
|
2567
|
+
|
|
2568
|
+
const state = {
|
|
2569
|
+
// providerId: PROVIDER_NOOP,
|
|
2570
|
+
provider: QuickPickNoop,
|
|
2571
|
+
prefix: 'string-that-should-never-match-another-string'
|
|
2572
|
+
};
|
|
2573
|
+
|
|
2574
|
+
/**
|
|
2575
|
+
* @type {string}
|
|
2576
|
+
*/
|
|
2577
|
+
const name$1 = 'everything';
|
|
2578
|
+
const getPlaceholder$1 = () => {
|
|
2579
|
+
return state.provider.getPlaceholder();
|
|
2580
|
+
};
|
|
2581
|
+
const getLabel = () => {
|
|
2582
|
+
return '';
|
|
2583
|
+
};
|
|
2584
|
+
const getHelpEntries$1 = () => {
|
|
2585
|
+
return state.provider.getHelpEntries();
|
|
2586
|
+
};
|
|
2587
|
+
const getNoResults$1 = () => {
|
|
2588
|
+
return state.provider.getNoResults();
|
|
2589
|
+
};
|
|
2590
|
+
const getPrefix = value => {
|
|
2591
|
+
if (value.startsWith(Command)) {
|
|
2592
|
+
return Command;
|
|
2593
|
+
}
|
|
2594
|
+
if (value.startsWith(Symbol$1)) {
|
|
2595
|
+
return Symbol$1;
|
|
2596
|
+
}
|
|
2597
|
+
if (value.startsWith(WorkspaceSymbol)) {
|
|
2598
|
+
return WorkspaceSymbol;
|
|
2599
|
+
}
|
|
2600
|
+
if (value.startsWith(GoToLine)) {
|
|
2601
|
+
return GoToLine;
|
|
2602
|
+
}
|
|
2603
|
+
if (value.startsWith(View)) {
|
|
2604
|
+
return View;
|
|
2605
|
+
}
|
|
2606
|
+
return None;
|
|
2607
|
+
};
|
|
2608
|
+
const getQuickPickProvider = prefix => {
|
|
2609
|
+
// TODO could use enum for prefix
|
|
2610
|
+
// TODO could use regex to extract prefix
|
|
2611
|
+
// TODO or could check first letter char code (less comparisons)
|
|
2612
|
+
switch (prefix) {
|
|
2613
|
+
case Command:
|
|
2614
|
+
return QuickPickEntriesCommand;
|
|
2615
|
+
case Symbol$1:
|
|
2616
|
+
return QuickPickEntriesSymbol;
|
|
2617
|
+
case WorkspaceSymbol:
|
|
2618
|
+
return QuickPickEntriesWorkspaceSymbol;
|
|
2619
|
+
case GoToLine:
|
|
2620
|
+
return QuickPickEntriesGoToLine;
|
|
2621
|
+
case View:
|
|
2622
|
+
return QuickPickEntriesView;
|
|
2623
|
+
default:
|
|
2624
|
+
return QuickPickEntriesFile;
|
|
2625
|
+
}
|
|
2626
|
+
};
|
|
2627
|
+
const getPicks$1 = async value => {
|
|
2628
|
+
const prefix = getPrefix(value);
|
|
2629
|
+
// TODO race condition
|
|
2630
|
+
if (state.prefix !== prefix) {
|
|
2631
|
+
state.prefix = prefix;
|
|
2632
|
+
// @ts-ignore
|
|
2633
|
+
state.provider = await getQuickPickProvider(prefix);
|
|
2634
|
+
}
|
|
2635
|
+
// TODO this line is a bit duplicated with getFilterValue
|
|
2636
|
+
const slicedValue = value.slice(prefix.length);
|
|
2637
|
+
const picks = await state.provider.getPicks(slicedValue);
|
|
2638
|
+
return picks;
|
|
2639
|
+
};
|
|
2640
|
+
const selectPick$1 = item => {
|
|
2641
|
+
const {
|
|
2642
|
+
provider
|
|
2643
|
+
} = state;
|
|
2644
|
+
return provider.selectPick(item);
|
|
2645
|
+
};
|
|
2646
|
+
const openCommandPalette = () => {
|
|
2647
|
+
// show('>')
|
|
2648
|
+
};
|
|
2649
|
+
const openView = () => {
|
|
2650
|
+
// show('view ')
|
|
2651
|
+
};
|
|
2652
|
+
const getFilterValue = value => {
|
|
2653
|
+
return value.slice(state.prefix.length);
|
|
2654
|
+
};
|
|
2655
|
+
const getPickFilterValue = pick => {
|
|
2656
|
+
const {
|
|
2657
|
+
provider
|
|
2658
|
+
} = state;
|
|
2659
|
+
return provider.getPickFilterValue(pick);
|
|
2660
|
+
};
|
|
2661
|
+
const getPickDescription = pick => {
|
|
2662
|
+
const {
|
|
2663
|
+
provider
|
|
2664
|
+
} = state;
|
|
2665
|
+
// @ts-ignore
|
|
2666
|
+
if (provider.getPickDescription) {
|
|
2667
|
+
// @ts-ignore
|
|
2668
|
+
return provider.getPickDescription(pick);
|
|
2669
|
+
}
|
|
2670
|
+
return '';
|
|
2671
|
+
};
|
|
2672
|
+
const getPickLabel = pick => {
|
|
2673
|
+
const {
|
|
2674
|
+
provider
|
|
2675
|
+
} = state;
|
|
2676
|
+
// @ts-ignore
|
|
2677
|
+
return provider.getPickLabel(pick);
|
|
2678
|
+
};
|
|
2679
|
+
const getPickIcon = pick => {
|
|
2680
|
+
const {
|
|
2681
|
+
provider
|
|
2682
|
+
} = state;
|
|
2683
|
+
// @ts-ignore
|
|
2684
|
+
return provider.getPickIcon(pick);
|
|
2685
|
+
};
|
|
2686
|
+
const getPickFileIcon = pick => {
|
|
2687
|
+
const {
|
|
2688
|
+
provider
|
|
2689
|
+
} = state;
|
|
2690
|
+
// @ts-ignore
|
|
2691
|
+
if (provider.getPickFileIcon) {
|
|
2692
|
+
// @ts-ignore
|
|
2693
|
+
return provider.getPickFileIcon(pick);
|
|
2694
|
+
}
|
|
2695
|
+
return '';
|
|
2696
|
+
};
|
|
2697
|
+
const isPrepared = () => {
|
|
2698
|
+
const {
|
|
2699
|
+
provider
|
|
2700
|
+
} = state;
|
|
2701
|
+
// @ts-ignore
|
|
2702
|
+
if (provider.isPrepared) {
|
|
2703
|
+
// @ts-ignore
|
|
2704
|
+
return provider.isPrepared();
|
|
2705
|
+
}
|
|
2706
|
+
return false;
|
|
2707
|
+
};
|
|
2708
|
+
|
|
2709
|
+
const QuickPickEntriesEverything = {
|
|
2710
|
+
__proto__: null,
|
|
2711
|
+
getFilterValue,
|
|
2712
|
+
getHelpEntries: getHelpEntries$1,
|
|
2713
|
+
getLabel,
|
|
2714
|
+
getNoResults: getNoResults$1,
|
|
2715
|
+
getPickDescription,
|
|
2716
|
+
getPickFileIcon,
|
|
2717
|
+
getPickFilterValue,
|
|
2718
|
+
getPickIcon,
|
|
2719
|
+
getPickLabel,
|
|
2720
|
+
getPicks: getPicks$1,
|
|
2721
|
+
getPlaceholder: getPlaceholder$1,
|
|
2722
|
+
isPrepared,
|
|
2723
|
+
name: name$1,
|
|
2724
|
+
openCommandPalette,
|
|
2725
|
+
openView,
|
|
2726
|
+
selectPick: selectPick$1,
|
|
2727
|
+
state
|
|
2728
|
+
};
|
|
2729
|
+
|
|
2730
|
+
const name = 'number';
|
|
2731
|
+
const getPlaceholder = () => {
|
|
2732
|
+
return '';
|
|
2733
|
+
};
|
|
2734
|
+
const getHelpEntries = () => {
|
|
2735
|
+
return [];
|
|
2736
|
+
};
|
|
2737
|
+
const getNoResults = () => {
|
|
2738
|
+
return {
|
|
2739
|
+
label: noMatchingResults()
|
|
2740
|
+
};
|
|
2741
|
+
};
|
|
2742
|
+
const getPicks = async () => {
|
|
2743
|
+
const picks = [{
|
|
2744
|
+
label: '1'
|
|
2745
|
+
}, {
|
|
2746
|
+
label: '2'
|
|
2747
|
+
}, {
|
|
2748
|
+
label: '3'
|
|
2749
|
+
}, {
|
|
2750
|
+
label: '4'
|
|
2751
|
+
}, {
|
|
2752
|
+
label: '5'
|
|
2753
|
+
}, {
|
|
2754
|
+
label: '6'
|
|
2755
|
+
}, {
|
|
2756
|
+
label: '7'
|
|
2757
|
+
}, {
|
|
2758
|
+
label: '8'
|
|
2759
|
+
}, {
|
|
2760
|
+
label: '9'
|
|
2761
|
+
}, {
|
|
2762
|
+
label: '10'
|
|
2763
|
+
}];
|
|
2764
|
+
return picks;
|
|
2765
|
+
};
|
|
2766
|
+
const selectPick = async item => {
|
|
2767
|
+
return {
|
|
2768
|
+
command: Hide
|
|
2769
|
+
};
|
|
2770
|
+
};
|
|
2771
|
+
|
|
2772
|
+
const QuickPickEntriesNumber = {
|
|
2773
|
+
__proto__: null,
|
|
2774
|
+
getHelpEntries,
|
|
2775
|
+
getNoResults,
|
|
2776
|
+
getPicks,
|
|
2777
|
+
getPlaceholder,
|
|
2778
|
+
name,
|
|
2779
|
+
selectPick
|
|
2780
|
+
};
|
|
2781
|
+
|
|
2782
|
+
const load = moduleId => {
|
|
2783
|
+
switch (moduleId) {
|
|
2784
|
+
case CommandPalette:
|
|
2785
|
+
case File$1:
|
|
2786
|
+
case EveryThing:
|
|
2787
|
+
case WorkspaceSymbol$1:
|
|
2788
|
+
return QuickPickEntriesEverything;
|
|
2789
|
+
case Number$1:
|
|
2790
|
+
return QuickPickEntriesNumber;
|
|
2791
|
+
case Recent:
|
|
2792
|
+
return QuickPickEntriesOpenRecent;
|
|
2793
|
+
case ColorTheme:
|
|
2794
|
+
return QuickPickEntriesColorTheme;
|
|
2795
|
+
case Symbol$2:
|
|
2796
|
+
return QuickPickEntriesSymbol;
|
|
2797
|
+
case View$1:
|
|
2798
|
+
return QuickPickEntriesView;
|
|
2799
|
+
case Custom:
|
|
2800
|
+
return QuickPickEntriesCustom;
|
|
2801
|
+
default:
|
|
2802
|
+
throw new Error(`unknown module "${moduleId}"`);
|
|
2803
|
+
}
|
|
2804
|
+
};
|
|
2805
|
+
|
|
1990
2806
|
const commandMap = {
|
|
1991
2807
|
'FileSystemFetch.chmod': chmod$1,
|
|
1992
2808
|
'FileSystemFetch.getBlob': getBlob$1,
|
|
@@ -2006,6 +2822,7 @@ const commandMap = {
|
|
|
2006
2822
|
'FileSystemMemory.writeFile': writeFile,
|
|
2007
2823
|
'QuickPick.getKeyBindings': getKeyBindings,
|
|
2008
2824
|
'QuickPick.loadEntries': loadQuickPickEntries,
|
|
2825
|
+
'QuickPick.loadEntries2': load,
|
|
2009
2826
|
'SearchFile.filter': filterQuickPickItems,
|
|
2010
2827
|
'SearchFile.searchFile': searchFile,
|
|
2011
2828
|
'SearchFile.searchFileWithFetch': searchFile$3,
|