@lvce-editor/explorer-view 1.7.0 → 1.8.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/explorerViewWorkerMain.js +645 -682
- package/package.json +1 -1
|
@@ -1,368 +1,161 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const state$1 = {
|
|
10
|
-
callbacks: Object.create(null)
|
|
11
|
-
};
|
|
12
|
-
const set = (id, fn) => {
|
|
13
|
-
state$1.callbacks[id] = fn;
|
|
14
|
-
};
|
|
15
|
-
const get = id => {
|
|
16
|
-
return state$1.callbacks[id];
|
|
17
|
-
};
|
|
18
|
-
const remove$1 = id => {
|
|
19
|
-
delete state$1.callbacks[id];
|
|
20
|
-
};
|
|
21
|
-
let id = 0;
|
|
22
|
-
const create$3 = () => {
|
|
23
|
-
return ++id;
|
|
1
|
+
const normalizeLine = line => {
|
|
2
|
+
if (line.startsWith('Error: ')) {
|
|
3
|
+
return line.slice('Error: '.length);
|
|
4
|
+
}
|
|
5
|
+
if (line.startsWith('VError: ')) {
|
|
6
|
+
return line.slice('VError: '.length);
|
|
7
|
+
}
|
|
8
|
+
return line;
|
|
24
9
|
};
|
|
25
|
-
const
|
|
26
|
-
|
|
10
|
+
const getCombinedMessage = (error, message) => {
|
|
11
|
+
const stringifiedError = normalizeLine(`${error}`);
|
|
12
|
+
if (message) {
|
|
13
|
+
return `${message}: ${stringifiedError}`;
|
|
14
|
+
}
|
|
15
|
+
return stringifiedError;
|
|
27
16
|
};
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
resolve,
|
|
32
|
-
promise
|
|
33
|
-
} = Promise.withResolvers();
|
|
34
|
-
set(id, resolve);
|
|
35
|
-
return {
|
|
36
|
-
id,
|
|
37
|
-
promise
|
|
38
|
-
};
|
|
17
|
+
const NewLine$2 = '\n';
|
|
18
|
+
const getNewLineIndex$1 = (string, startIndex = undefined) => {
|
|
19
|
+
return string.indexOf(NewLine$2, startIndex);
|
|
39
20
|
};
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
console.log(response);
|
|
44
|
-
warn(`callback ${id} may already be disposed`);
|
|
45
|
-
return;
|
|
21
|
+
const mergeStacks = (parent, child) => {
|
|
22
|
+
if (!child) {
|
|
23
|
+
return parent;
|
|
46
24
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
id
|
|
60
|
-
};
|
|
61
|
-
return {
|
|
62
|
-
message,
|
|
63
|
-
promise
|
|
64
|
-
};
|
|
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;
|
|
65
37
|
};
|
|
66
|
-
class
|
|
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
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
class AssertionError extends Error {
|
|
67
58
|
constructor(message) {
|
|
68
59
|
super(message);
|
|
69
|
-
this.name = '
|
|
60
|
+
this.name = 'AssertionError';
|
|
70
61
|
}
|
|
71
62
|
}
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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;
|
|
63
|
+
const getType = value => {
|
|
64
|
+
switch (typeof value) {
|
|
65
|
+
case 'number':
|
|
66
|
+
return 'number';
|
|
67
|
+
case 'function':
|
|
68
|
+
return 'function';
|
|
69
|
+
case 'string':
|
|
70
|
+
return 'string';
|
|
71
|
+
case 'object':
|
|
72
|
+
if (value === null) {
|
|
73
|
+
return 'null';
|
|
74
|
+
}
|
|
75
|
+
if (Array.isArray(value)) {
|
|
76
|
+
return 'array';
|
|
77
|
+
}
|
|
78
|
+
return 'object';
|
|
79
|
+
case 'boolean':
|
|
80
|
+
return 'boolean';
|
|
81
|
+
default:
|
|
82
|
+
return 'unknown';
|
|
100
83
|
}
|
|
101
|
-
return Error;
|
|
102
84
|
};
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
if (
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
if (ErrorConstructor === Error) {
|
|
109
|
-
const error = new Error(message);
|
|
110
|
-
if (name && name !== 'VError') {
|
|
111
|
-
error.name = name;
|
|
112
|
-
}
|
|
113
|
-
return error;
|
|
85
|
+
const object = value => {
|
|
86
|
+
const type = getType(value);
|
|
87
|
+
if (type !== 'object') {
|
|
88
|
+
throw new AssertionError('expected value to be of type object');
|
|
114
89
|
}
|
|
115
|
-
return new ErrorConstructor(message);
|
|
116
90
|
};
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
let parentStack = error.stack || error.data || error.message || '';
|
|
122
|
-
if (parentStack.startsWith(' at')) {
|
|
123
|
-
parentStack = error.message + NewLine$3 + parentStack;
|
|
91
|
+
const number = value => {
|
|
92
|
+
const type = getType(value);
|
|
93
|
+
if (type !== 'number') {
|
|
94
|
+
throw new AssertionError('expected value to be of type number');
|
|
124
95
|
}
|
|
125
|
-
return parentStack;
|
|
126
96
|
};
|
|
127
|
-
const
|
|
128
|
-
|
|
97
|
+
const array = value => {
|
|
98
|
+
const type = getType(value);
|
|
99
|
+
if (type !== 'array') {
|
|
100
|
+
throw new AssertionError('expected value to be of type array');
|
|
101
|
+
}
|
|
129
102
|
};
|
|
130
|
-
const
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
103
|
+
const string = value => {
|
|
104
|
+
const type = getType(value);
|
|
105
|
+
if (type !== 'string') {
|
|
106
|
+
throw new AssertionError('expected value to be of type string');
|
|
107
|
+
}
|
|
134
108
|
};
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
109
|
+
|
|
110
|
+
const walkValue = (value, transferrables, isTransferrable) => {
|
|
111
|
+
if (!value) {
|
|
112
|
+
return;
|
|
138
113
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const parentStack = getParentStack(error);
|
|
143
|
-
restoredError.stack = parentStack + NewLine$3 + currentStack;
|
|
144
|
-
return restoredError;
|
|
114
|
+
if (isTransferrable(value)) {
|
|
115
|
+
transferrables.push(value);
|
|
116
|
+
return;
|
|
145
117
|
}
|
|
146
|
-
if (
|
|
147
|
-
const
|
|
148
|
-
|
|
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
|
-
}
|
|
118
|
+
if (Array.isArray(value)) {
|
|
119
|
+
for (const item of value) {
|
|
120
|
+
walkValue(item, transferrables, isTransferrable);
|
|
179
121
|
}
|
|
180
|
-
return
|
|
122
|
+
return;
|
|
181
123
|
}
|
|
182
|
-
if (typeof
|
|
183
|
-
|
|
124
|
+
if (typeof value === 'object') {
|
|
125
|
+
for (const property of Object.values(value)) {
|
|
126
|
+
walkValue(property, transferrables, isTransferrable);
|
|
127
|
+
}
|
|
128
|
+
return;
|
|
184
129
|
}
|
|
185
|
-
return new Error(`JsonRpc Error: ${error}`);
|
|
186
130
|
};
|
|
187
|
-
const
|
|
188
|
-
|
|
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 = (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(message, errorProperty);
|
|
239
|
-
};
|
|
240
|
-
const create$5 = (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$5(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
|
-
}
|
|
131
|
+
const isMessagePort = value => {
|
|
132
|
+
return value && value instanceof MessagePort;
|
|
258
133
|
};
|
|
259
|
-
const
|
|
260
|
-
return
|
|
134
|
+
const isMessagePortMain = value => {
|
|
135
|
+
return value && value.constructor && value.constructor.name === 'MessagePortMain';
|
|
261
136
|
};
|
|
262
|
-
const
|
|
263
|
-
|
|
137
|
+
const isOffscreenCanvas = value => {
|
|
138
|
+
return typeof OffscreenCanvas !== 'undefined' && value instanceof OffscreenCanvas;
|
|
264
139
|
};
|
|
265
|
-
const
|
|
266
|
-
return
|
|
140
|
+
const isInstanceOf = (value, constructorName) => {
|
|
141
|
+
return value?.constructor?.name === constructorName;
|
|
267
142
|
};
|
|
268
|
-
const
|
|
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
|
-
};
|
|
143
|
+
const isSocket = value => {
|
|
144
|
+
return isInstanceOf(value, 'Socket');
|
|
293
145
|
};
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
const {
|
|
297
|
-
|
|
298
|
-
|
|
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;
|
|
146
|
+
const transferrables = [isMessagePort, isMessagePortMain, isOffscreenCanvas, isSocket];
|
|
147
|
+
const isTransferrable = value => {
|
|
148
|
+
for (const fn of transferrables) {
|
|
149
|
+
if (fn(value)) {
|
|
150
|
+
return true;
|
|
315
151
|
}
|
|
316
|
-
resolve(message.id, message);
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
if ('method' in message) {
|
|
320
|
-
await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
321
|
-
return;
|
|
322
|
-
}
|
|
323
|
-
throw new JsonRpcError('unexpected message');
|
|
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);
|
|
334
|
-
}
|
|
335
|
-
const responseMessage = await promise;
|
|
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$1 = (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];
|
|
355
|
-
};
|
|
356
|
-
const execute = (command, ...args) => {
|
|
357
|
-
const fn = getCommand(command);
|
|
358
|
-
if (!fn) {
|
|
359
|
-
throw new Error(`command not found ${command}`);
|
|
360
152
|
}
|
|
361
|
-
return
|
|
153
|
+
return false;
|
|
362
154
|
};
|
|
363
|
-
|
|
364
|
-
const
|
|
365
|
-
|
|
155
|
+
const getTransferrables = value => {
|
|
156
|
+
const transferrables = [];
|
|
157
|
+
walkValue(value, transferrables, isTransferrable);
|
|
158
|
+
return transferrables;
|
|
366
159
|
};
|
|
367
160
|
const attachEvents = that => {
|
|
368
161
|
const handleMessage = (...args) => {
|
|
@@ -384,132 +177,45 @@ class Ipc extends EventTarget {
|
|
|
384
177
|
attachEvents(this);
|
|
385
178
|
}
|
|
386
179
|
}
|
|
387
|
-
const
|
|
388
|
-
const
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
transferrables.push(value);
|
|
394
|
-
return;
|
|
395
|
-
}
|
|
396
|
-
if (Array.isArray(value)) {
|
|
397
|
-
for (const item of value) {
|
|
398
|
-
walkValue(item, transferrables, isTransferrable);
|
|
399
|
-
}
|
|
400
|
-
return;
|
|
401
|
-
}
|
|
402
|
-
if (typeof value === 'object') {
|
|
403
|
-
for (const property of Object.values(value)) {
|
|
404
|
-
walkValue(property, transferrables, isTransferrable);
|
|
405
|
-
}
|
|
406
|
-
return;
|
|
407
|
-
}
|
|
408
|
-
};
|
|
409
|
-
const isMessagePort = value => {
|
|
410
|
-
return value && value instanceof MessagePort;
|
|
180
|
+
const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
181
|
+
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
182
|
+
const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
|
|
183
|
+
const NewLine$1 = '\n';
|
|
184
|
+
const joinLines$1 = lines => {
|
|
185
|
+
return lines.join(NewLine$1);
|
|
411
186
|
};
|
|
412
|
-
const
|
|
413
|
-
return
|
|
187
|
+
const splitLines$1 = lines => {
|
|
188
|
+
return lines.split(NewLine$1);
|
|
414
189
|
};
|
|
415
|
-
const
|
|
416
|
-
return
|
|
190
|
+
const isModuleNotFoundMessage = line => {
|
|
191
|
+
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
|
417
192
|
};
|
|
418
|
-
const
|
|
419
|
-
|
|
193
|
+
const getModuleNotFoundError = stderr => {
|
|
194
|
+
const lines = splitLines$1(stderr);
|
|
195
|
+
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
196
|
+
const message = lines[messageIndex];
|
|
197
|
+
return {
|
|
198
|
+
message,
|
|
199
|
+
code: ERR_MODULE_NOT_FOUND
|
|
200
|
+
};
|
|
420
201
|
};
|
|
421
|
-
const
|
|
422
|
-
|
|
202
|
+
const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
|
|
203
|
+
const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
|
|
204
|
+
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
|
205
|
+
const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
|
|
206
|
+
const RE_AT = /^\s+at/;
|
|
207
|
+
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
|
208
|
+
const isUnhelpfulNativeModuleError = stderr => {
|
|
209
|
+
return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
|
|
423
210
|
};
|
|
424
|
-
const
|
|
425
|
-
|
|
426
|
-
for (const fn of transferrables) {
|
|
427
|
-
if (fn(value)) {
|
|
428
|
-
return true;
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
return false;
|
|
432
|
-
};
|
|
433
|
-
const getTransferrables = value => {
|
|
434
|
-
const transferrables = [];
|
|
435
|
-
walkValue(value, transferrables, isTransferrable);
|
|
436
|
-
return transferrables;
|
|
437
|
-
};
|
|
438
|
-
const listen$2 = () => {
|
|
439
|
-
// @ts-ignore
|
|
440
|
-
if (typeof WorkerGlobalScope === 'undefined') {
|
|
441
|
-
throw new TypeError('module is not in web worker scope');
|
|
442
|
-
}
|
|
443
|
-
return globalThis;
|
|
444
|
-
};
|
|
445
|
-
const signal$2 = global => {
|
|
446
|
-
global.postMessage(readyMessage);
|
|
447
|
-
};
|
|
448
|
-
class IpcChildWithModuleWorker extends Ipc {
|
|
449
|
-
getData(event) {
|
|
450
|
-
return getData$1(event);
|
|
451
|
-
}
|
|
452
|
-
send(message) {
|
|
453
|
-
// @ts-ignore
|
|
454
|
-
this._rawIpc.postMessage(message);
|
|
455
|
-
}
|
|
456
|
-
sendAndTransfer(message) {
|
|
457
|
-
const transfer = getTransferrables(message);
|
|
458
|
-
// @ts-ignore
|
|
459
|
-
this._rawIpc.postMessage(message, transfer);
|
|
460
|
-
}
|
|
461
|
-
dispose() {
|
|
462
|
-
// ignore
|
|
463
|
-
}
|
|
464
|
-
onClose(callback) {
|
|
465
|
-
// ignore
|
|
466
|
-
}
|
|
467
|
-
onMessage(callback) {
|
|
468
|
-
this._rawIpc.addEventListener('message', callback);
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
const wrap$5 = global => {
|
|
472
|
-
return new IpcChildWithModuleWorker(global);
|
|
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 = lines => {
|
|
482
|
-
return lines.split(NewLine$1);
|
|
483
|
-
};
|
|
484
|
-
const isModuleNotFoundMessage = line => {
|
|
485
|
-
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
|
486
|
-
};
|
|
487
|
-
const getModuleNotFoundError = stderr => {
|
|
488
|
-
const lines = splitLines(stderr);
|
|
489
|
-
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
490
|
-
const message = lines[messageIndex];
|
|
491
|
-
return {
|
|
492
|
-
message,
|
|
493
|
-
code: ERR_MODULE_NOT_FOUND
|
|
494
|
-
};
|
|
495
|
-
};
|
|
496
|
-
const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
|
|
497
|
-
const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
|
|
498
|
-
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
|
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);
|
|
504
|
-
};
|
|
505
|
-
const isMessageCodeBlockStartIndex = line => {
|
|
506
|
-
return RE_MESSAGE_CODE_BLOCK_START.test(line);
|
|
211
|
+
const isMessageCodeBlockStartIndex = line => {
|
|
212
|
+
return RE_MESSAGE_CODE_BLOCK_START.test(line);
|
|
507
213
|
};
|
|
508
214
|
const isMessageCodeBlockEndIndex = line => {
|
|
509
215
|
return RE_MESSAGE_CODE_BLOCK_END.test(line);
|
|
510
216
|
};
|
|
511
217
|
const getMessageCodeBlock = stderr => {
|
|
512
|
-
const lines = splitLines(stderr);
|
|
218
|
+
const lines = splitLines$1(stderr);
|
|
513
219
|
const startIndex = lines.findIndex(isMessageCodeBlockStartIndex);
|
|
514
220
|
const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex, startIndex);
|
|
515
221
|
const relevantLines = lines.slice(startIndex, endIndex);
|
|
@@ -548,7 +254,7 @@ const getDetails = lines => {
|
|
|
548
254
|
const index = lines.findIndex(isNormalStackLine);
|
|
549
255
|
if (index === -1) {
|
|
550
256
|
return {
|
|
551
|
-
actualMessage: joinLines(lines),
|
|
257
|
+
actualMessage: joinLines$1(lines),
|
|
552
258
|
rest: []
|
|
553
259
|
};
|
|
554
260
|
}
|
|
@@ -573,7 +279,7 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
|
573
279
|
if (isModuleNotFoundError(stderr)) {
|
|
574
280
|
return getModuleNotFoundError(stderr);
|
|
575
281
|
}
|
|
576
|
-
const lines = splitLines(stderr);
|
|
282
|
+
const lines = splitLines$1(stderr);
|
|
577
283
|
const {
|
|
578
284
|
actualMessage,
|
|
579
285
|
rest
|
|
@@ -584,62 +290,7 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
|
584
290
|
stack: rest
|
|
585
291
|
};
|
|
586
292
|
};
|
|
587
|
-
|
|
588
|
-
if (line.startsWith('Error: ')) {
|
|
589
|
-
return line.slice('Error: '.length);
|
|
590
|
-
}
|
|
591
|
-
if (line.startsWith('VError: ')) {
|
|
592
|
-
return line.slice('VError: '.length);
|
|
593
|
-
}
|
|
594
|
-
return line;
|
|
595
|
-
};
|
|
596
|
-
const getCombinedMessage$1 = (error, message) => {
|
|
597
|
-
const stringifiedError = normalizeLine$1(`${error}`);
|
|
598
|
-
if (message) {
|
|
599
|
-
return `${message}: ${stringifiedError}`;
|
|
600
|
-
}
|
|
601
|
-
return stringifiedError;
|
|
602
|
-
};
|
|
603
|
-
const NewLine$2 = '\n';
|
|
604
|
-
const getNewLineIndex$1 = (string, startIndex = undefined) => {
|
|
605
|
-
return string.indexOf(NewLine$2, startIndex);
|
|
606
|
-
};
|
|
607
|
-
const mergeStacks$1 = (parent, child) => {
|
|
608
|
-
if (!child) {
|
|
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;
|
|
623
|
-
};
|
|
624
|
-
let VError$1 = class VError extends Error {
|
|
625
|
-
constructor(error, message) {
|
|
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
|
-
}
|
|
641
|
-
};
|
|
642
|
-
class IpcError extends VError$1 {
|
|
293
|
+
class IpcError extends VError {
|
|
643
294
|
// @ts-ignore
|
|
644
295
|
constructor(betterMessage, stdout = '', stderr = '') {
|
|
645
296
|
if (stdout || stderr) {
|
|
@@ -665,6 +316,46 @@ class IpcError extends VError$1 {
|
|
|
665
316
|
this.stderr = stderr;
|
|
666
317
|
}
|
|
667
318
|
}
|
|
319
|
+
const readyMessage = 'ready';
|
|
320
|
+
const getData$2 = event => {
|
|
321
|
+
return event.data;
|
|
322
|
+
};
|
|
323
|
+
const listen$6 = () => {
|
|
324
|
+
// @ts-ignore
|
|
325
|
+
if (typeof WorkerGlobalScope === 'undefined') {
|
|
326
|
+
throw new TypeError('module is not in web worker scope');
|
|
327
|
+
}
|
|
328
|
+
return globalThis;
|
|
329
|
+
};
|
|
330
|
+
const signal$6 = global => {
|
|
331
|
+
global.postMessage(readyMessage);
|
|
332
|
+
};
|
|
333
|
+
class IpcChildWithModuleWorker extends Ipc {
|
|
334
|
+
getData(event) {
|
|
335
|
+
return getData$2(event);
|
|
336
|
+
}
|
|
337
|
+
send(message) {
|
|
338
|
+
// @ts-ignore
|
|
339
|
+
this._rawIpc.postMessage(message);
|
|
340
|
+
}
|
|
341
|
+
sendAndTransfer(message) {
|
|
342
|
+
const transfer = getTransferrables(message);
|
|
343
|
+
// @ts-ignore
|
|
344
|
+
this._rawIpc.postMessage(message, transfer);
|
|
345
|
+
}
|
|
346
|
+
dispose() {
|
|
347
|
+
// ignore
|
|
348
|
+
}
|
|
349
|
+
onClose(callback) {
|
|
350
|
+
// ignore
|
|
351
|
+
}
|
|
352
|
+
onMessage(callback) {
|
|
353
|
+
this._rawIpc.addEventListener('message', callback);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
const wrap$d = global => {
|
|
357
|
+
return new IpcChildWithModuleWorker(global);
|
|
358
|
+
};
|
|
668
359
|
const withResolvers = () => {
|
|
669
360
|
let _resolve;
|
|
670
361
|
const promise = new Promise(resolve => {
|
|
@@ -687,10 +378,10 @@ const waitForFirstMessage = async port => {
|
|
|
687
378
|
// @ts-ignore
|
|
688
379
|
return event.data;
|
|
689
380
|
};
|
|
690
|
-
const listen$
|
|
691
|
-
const parentIpcRaw = listen$
|
|
692
|
-
signal$
|
|
693
|
-
const parentIpc = wrap$
|
|
381
|
+
const listen$5 = async () => {
|
|
382
|
+
const parentIpcRaw = listen$6();
|
|
383
|
+
signal$6(parentIpcRaw);
|
|
384
|
+
const parentIpc = wrap$d(parentIpcRaw);
|
|
694
385
|
const firstMessage = await waitForFirstMessage(parentIpc);
|
|
695
386
|
if (firstMessage.method !== 'initialize') {
|
|
696
387
|
throw new IpcError('unexpected first message');
|
|
@@ -713,7 +404,7 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
|
713
404
|
super(port);
|
|
714
405
|
}
|
|
715
406
|
getData(event) {
|
|
716
|
-
return getData$
|
|
407
|
+
return getData$2(event);
|
|
717
408
|
}
|
|
718
409
|
send(message) {
|
|
719
410
|
this._rawIpc.postMessage(message);
|
|
@@ -722,26 +413,387 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
|
722
413
|
const transfer = getTransferrables(message);
|
|
723
414
|
this._rawIpc.postMessage(message, transfer);
|
|
724
415
|
}
|
|
725
|
-
dispose() {
|
|
726
|
-
if (this._rawIpc.close) {
|
|
727
|
-
this._rawIpc.close();
|
|
416
|
+
dispose() {
|
|
417
|
+
if (this._rawIpc.close) {
|
|
418
|
+
this._rawIpc.close();
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
onClose(callback) {
|
|
422
|
+
// ignore
|
|
423
|
+
}
|
|
424
|
+
onMessage(callback) {
|
|
425
|
+
this._rawIpc.addEventListener('message', callback);
|
|
426
|
+
this._rawIpc.start();
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
const wrap$c = port => {
|
|
430
|
+
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
431
|
+
};
|
|
432
|
+
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
433
|
+
__proto__: null,
|
|
434
|
+
listen: listen$5,
|
|
435
|
+
wrap: wrap$c
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
const Two = '2.0';
|
|
439
|
+
const create$4 = (method, params) => {
|
|
440
|
+
return {
|
|
441
|
+
jsonrpc: Two,
|
|
442
|
+
method,
|
|
443
|
+
params
|
|
444
|
+
};
|
|
445
|
+
};
|
|
446
|
+
const callbacks = Object.create(null);
|
|
447
|
+
const set = (id, fn) => {
|
|
448
|
+
callbacks[id] = fn;
|
|
449
|
+
};
|
|
450
|
+
const get = id => {
|
|
451
|
+
return callbacks[id];
|
|
452
|
+
};
|
|
453
|
+
const remove$1 = id => {
|
|
454
|
+
delete callbacks[id];
|
|
455
|
+
};
|
|
456
|
+
let id = 0;
|
|
457
|
+
const create$3 = () => {
|
|
458
|
+
return ++id;
|
|
459
|
+
};
|
|
460
|
+
const warn = (...args) => {
|
|
461
|
+
console.warn(...args);
|
|
462
|
+
};
|
|
463
|
+
const registerPromise = () => {
|
|
464
|
+
const id = create$3();
|
|
465
|
+
const {
|
|
466
|
+
resolve,
|
|
467
|
+
promise
|
|
468
|
+
} = Promise.withResolvers();
|
|
469
|
+
set(id, resolve);
|
|
470
|
+
return {
|
|
471
|
+
id,
|
|
472
|
+
promise
|
|
473
|
+
};
|
|
474
|
+
};
|
|
475
|
+
const resolve = (id, response) => {
|
|
476
|
+
const fn = get(id);
|
|
477
|
+
if (!fn) {
|
|
478
|
+
console.log(response);
|
|
479
|
+
warn(`callback ${id} may already be disposed`);
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
fn(response);
|
|
483
|
+
remove$1(id);
|
|
484
|
+
};
|
|
485
|
+
const create$2 = (method, params) => {
|
|
486
|
+
const {
|
|
487
|
+
id,
|
|
488
|
+
promise
|
|
489
|
+
} = registerPromise();
|
|
490
|
+
const message = {
|
|
491
|
+
jsonrpc: Two,
|
|
492
|
+
method,
|
|
493
|
+
params,
|
|
494
|
+
id
|
|
495
|
+
};
|
|
496
|
+
return {
|
|
497
|
+
message,
|
|
498
|
+
promise
|
|
499
|
+
};
|
|
500
|
+
};
|
|
501
|
+
class JsonRpcError extends Error {
|
|
502
|
+
constructor(message) {
|
|
503
|
+
super(message);
|
|
504
|
+
this.name = 'JsonRpcError';
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
const NewLine = '\n';
|
|
508
|
+
const DomException = 'DOMException';
|
|
509
|
+
const ReferenceError$1 = 'ReferenceError';
|
|
510
|
+
const SyntaxError$1 = 'SyntaxError';
|
|
511
|
+
const TypeError$1 = 'TypeError';
|
|
512
|
+
const getErrorConstructor = (message, type) => {
|
|
513
|
+
if (type) {
|
|
514
|
+
switch (type) {
|
|
515
|
+
case DomException:
|
|
516
|
+
return DOMException;
|
|
517
|
+
case TypeError$1:
|
|
518
|
+
return TypeError;
|
|
519
|
+
case SyntaxError$1:
|
|
520
|
+
return SyntaxError;
|
|
521
|
+
case ReferenceError$1:
|
|
522
|
+
return ReferenceError;
|
|
523
|
+
default:
|
|
524
|
+
return Error;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
if (message.startsWith('TypeError: ')) {
|
|
528
|
+
return TypeError;
|
|
529
|
+
}
|
|
530
|
+
if (message.startsWith('SyntaxError: ')) {
|
|
531
|
+
return SyntaxError;
|
|
532
|
+
}
|
|
533
|
+
if (message.startsWith('ReferenceError: ')) {
|
|
534
|
+
return ReferenceError;
|
|
535
|
+
}
|
|
536
|
+
return Error;
|
|
537
|
+
};
|
|
538
|
+
const constructError = (message, type, name) => {
|
|
539
|
+
const ErrorConstructor = getErrorConstructor(message, type);
|
|
540
|
+
if (ErrorConstructor === DOMException && name) {
|
|
541
|
+
return new ErrorConstructor(message, name);
|
|
542
|
+
}
|
|
543
|
+
if (ErrorConstructor === Error) {
|
|
544
|
+
const error = new Error(message);
|
|
545
|
+
if (name && name !== 'VError') {
|
|
546
|
+
error.name = name;
|
|
547
|
+
}
|
|
548
|
+
return error;
|
|
549
|
+
}
|
|
550
|
+
return new ErrorConstructor(message);
|
|
551
|
+
};
|
|
552
|
+
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
553
|
+
return string.indexOf(NewLine, startIndex);
|
|
554
|
+
};
|
|
555
|
+
const getParentStack = error => {
|
|
556
|
+
let parentStack = error.stack || error.data || error.message || '';
|
|
557
|
+
if (parentStack.startsWith(' at')) {
|
|
558
|
+
parentStack = error.message + NewLine + parentStack;
|
|
559
|
+
}
|
|
560
|
+
return parentStack;
|
|
561
|
+
};
|
|
562
|
+
const joinLines = lines => {
|
|
563
|
+
return lines.join(NewLine);
|
|
564
|
+
};
|
|
565
|
+
const MethodNotFound = -32601;
|
|
566
|
+
const Custom = -32001;
|
|
567
|
+
const splitLines = lines => {
|
|
568
|
+
return lines.split(NewLine);
|
|
569
|
+
};
|
|
570
|
+
const restoreJsonRpcError = error => {
|
|
571
|
+
if (error && error instanceof Error) {
|
|
572
|
+
return error;
|
|
573
|
+
}
|
|
574
|
+
const currentStack = joinLines(splitLines(new Error().stack || '').slice(1));
|
|
575
|
+
if (error && error.code && error.code === MethodNotFound) {
|
|
576
|
+
const restoredError = new JsonRpcError(error.message);
|
|
577
|
+
const parentStack = getParentStack(error);
|
|
578
|
+
restoredError.stack = parentStack + NewLine + currentStack;
|
|
579
|
+
return restoredError;
|
|
580
|
+
}
|
|
581
|
+
if (error && error.message) {
|
|
582
|
+
const restoredError = constructError(error.message, error.type, error.name);
|
|
583
|
+
if (error.data) {
|
|
584
|
+
if (error.data.stack && error.data.type && error.message) {
|
|
585
|
+
restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
|
|
586
|
+
} else if (error.data.stack) {
|
|
587
|
+
restoredError.stack = error.data.stack;
|
|
588
|
+
}
|
|
589
|
+
if (error.data.codeFrame) {
|
|
590
|
+
// @ts-ignore
|
|
591
|
+
restoredError.codeFrame = error.data.codeFrame;
|
|
592
|
+
}
|
|
593
|
+
if (error.data.code) {
|
|
594
|
+
// @ts-ignore
|
|
595
|
+
restoredError.code = error.data.code;
|
|
596
|
+
}
|
|
597
|
+
if (error.data.type) {
|
|
598
|
+
// @ts-ignore
|
|
599
|
+
restoredError.name = error.data.type;
|
|
600
|
+
}
|
|
601
|
+
} else {
|
|
602
|
+
if (error.stack) {
|
|
603
|
+
const lowerStack = restoredError.stack || '';
|
|
604
|
+
// @ts-ignore
|
|
605
|
+
const indexNewLine = getNewLineIndex(lowerStack);
|
|
606
|
+
const parentStack = getParentStack(error);
|
|
607
|
+
// @ts-ignore
|
|
608
|
+
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
609
|
+
}
|
|
610
|
+
if (error.codeFrame) {
|
|
611
|
+
// @ts-ignore
|
|
612
|
+
restoredError.codeFrame = error.codeFrame;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
return restoredError;
|
|
616
|
+
}
|
|
617
|
+
if (typeof error === 'string') {
|
|
618
|
+
return new Error(`JsonRpc Error: ${error}`);
|
|
619
|
+
}
|
|
620
|
+
return new Error(`JsonRpc Error: ${error}`);
|
|
621
|
+
};
|
|
622
|
+
const unwrapJsonRpcResult = responseMessage => {
|
|
623
|
+
if ('error' in responseMessage) {
|
|
624
|
+
const restoredError = restoreJsonRpcError(responseMessage.error);
|
|
625
|
+
throw restoredError;
|
|
626
|
+
}
|
|
627
|
+
if ('result' in responseMessage) {
|
|
628
|
+
return responseMessage.result;
|
|
629
|
+
}
|
|
630
|
+
throw new JsonRpcError('unexpected response message');
|
|
631
|
+
};
|
|
632
|
+
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
633
|
+
const getErrorType = prettyError => {
|
|
634
|
+
if (prettyError && prettyError.type) {
|
|
635
|
+
return prettyError.type;
|
|
636
|
+
}
|
|
637
|
+
if (prettyError && prettyError.constructor && prettyError.constructor.name) {
|
|
638
|
+
return prettyError.constructor.name;
|
|
639
|
+
}
|
|
640
|
+
return undefined;
|
|
641
|
+
};
|
|
642
|
+
const getErrorProperty = (error, prettyError) => {
|
|
643
|
+
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
644
|
+
return {
|
|
645
|
+
code: MethodNotFound,
|
|
646
|
+
message: error.message,
|
|
647
|
+
data: error.stack
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
return {
|
|
651
|
+
code: Custom,
|
|
652
|
+
message: prettyError.message,
|
|
653
|
+
data: {
|
|
654
|
+
stack: prettyError.stack,
|
|
655
|
+
codeFrame: prettyError.codeFrame,
|
|
656
|
+
type: getErrorType(prettyError),
|
|
657
|
+
code: prettyError.code,
|
|
658
|
+
name: prettyError.name
|
|
659
|
+
}
|
|
660
|
+
};
|
|
661
|
+
};
|
|
662
|
+
const create$1 = (message, error) => {
|
|
663
|
+
return {
|
|
664
|
+
jsonrpc: Two,
|
|
665
|
+
id: message.id,
|
|
666
|
+
error
|
|
667
|
+
};
|
|
668
|
+
};
|
|
669
|
+
const getErrorResponse = (message, error, preparePrettyError, logError) => {
|
|
670
|
+
const prettyError = preparePrettyError(error);
|
|
671
|
+
logError(error, prettyError);
|
|
672
|
+
const errorProperty = getErrorProperty(error, prettyError);
|
|
673
|
+
return create$1(message, errorProperty);
|
|
674
|
+
};
|
|
675
|
+
const create$5 = (message, result) => {
|
|
676
|
+
return {
|
|
677
|
+
jsonrpc: Two,
|
|
678
|
+
id: message.id,
|
|
679
|
+
result: result ?? null
|
|
680
|
+
};
|
|
681
|
+
};
|
|
682
|
+
const getSuccessResponse = (message, result) => {
|
|
683
|
+
const resultProperty = result ?? null;
|
|
684
|
+
return create$5(message, resultProperty);
|
|
685
|
+
};
|
|
686
|
+
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
687
|
+
try {
|
|
688
|
+
const result = requiresSocket(message.method) ? await execute(message.method, ipc, ...message.params) : await execute(message.method, ...message.params);
|
|
689
|
+
return getSuccessResponse(message, result);
|
|
690
|
+
} catch (error) {
|
|
691
|
+
return getErrorResponse(message, error, preparePrettyError, logError);
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
const defaultPreparePrettyError = error => {
|
|
695
|
+
return error;
|
|
696
|
+
};
|
|
697
|
+
const defaultLogError = () => {
|
|
698
|
+
// ignore
|
|
699
|
+
};
|
|
700
|
+
const defaultRequiresSocket = () => {
|
|
701
|
+
return false;
|
|
702
|
+
};
|
|
703
|
+
const defaultResolve = resolve;
|
|
704
|
+
|
|
705
|
+
// TODO maybe remove this in v6 or v7, only accept options object to simplify the code
|
|
706
|
+
const normalizeParams = args => {
|
|
707
|
+
if (args.length === 1) {
|
|
708
|
+
const options = args[0];
|
|
709
|
+
return {
|
|
710
|
+
ipc: options.ipc,
|
|
711
|
+
message: options.message,
|
|
712
|
+
execute: options.execute,
|
|
713
|
+
resolve: options.resolve || defaultResolve,
|
|
714
|
+
preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
|
|
715
|
+
logError: options.logError || defaultLogError,
|
|
716
|
+
requiresSocket: options.requiresSocket || defaultRequiresSocket
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
return {
|
|
720
|
+
ipc: args[0],
|
|
721
|
+
message: args[1],
|
|
722
|
+
execute: args[2],
|
|
723
|
+
resolve: args[3],
|
|
724
|
+
preparePrettyError: args[4],
|
|
725
|
+
logError: args[5],
|
|
726
|
+
requiresSocket: args[6]
|
|
727
|
+
};
|
|
728
|
+
};
|
|
729
|
+
const handleJsonRpcMessage = async (...args) => {
|
|
730
|
+
const options = normalizeParams(args);
|
|
731
|
+
const {
|
|
732
|
+
message,
|
|
733
|
+
ipc,
|
|
734
|
+
execute,
|
|
735
|
+
resolve,
|
|
736
|
+
preparePrettyError,
|
|
737
|
+
logError,
|
|
738
|
+
requiresSocket
|
|
739
|
+
} = options;
|
|
740
|
+
if ('id' in message) {
|
|
741
|
+
if ('method' in message) {
|
|
742
|
+
const response = await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
743
|
+
try {
|
|
744
|
+
ipc.send(response);
|
|
745
|
+
} catch (error) {
|
|
746
|
+
const errorResponse = getErrorResponse(message, error, preparePrettyError, logError);
|
|
747
|
+
ipc.send(errorResponse);
|
|
748
|
+
}
|
|
749
|
+
return;
|
|
728
750
|
}
|
|
751
|
+
resolve(message.id, message);
|
|
752
|
+
return;
|
|
729
753
|
}
|
|
730
|
-
|
|
731
|
-
|
|
754
|
+
if ('method' in message) {
|
|
755
|
+
await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
756
|
+
return;
|
|
732
757
|
}
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
758
|
+
throw new JsonRpcError('unexpected message');
|
|
759
|
+
};
|
|
760
|
+
const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
761
|
+
const {
|
|
762
|
+
message,
|
|
763
|
+
promise
|
|
764
|
+
} = create$2(method, params);
|
|
765
|
+
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
766
|
+
ipc.sendAndTransfer(message);
|
|
767
|
+
} else {
|
|
768
|
+
ipc.send(message);
|
|
736
769
|
}
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
770
|
+
const responseMessage = await promise;
|
|
771
|
+
return unwrapJsonRpcResult(responseMessage);
|
|
740
772
|
};
|
|
741
|
-
const
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
773
|
+
const send = (transport, method, ...params) => {
|
|
774
|
+
const message = create$4(method, params);
|
|
775
|
+
transport.send(message);
|
|
776
|
+
};
|
|
777
|
+
const invoke$1 = (ipc, method, ...params) => {
|
|
778
|
+
return invokeHelper(ipc, method, params, false);
|
|
779
|
+
};
|
|
780
|
+
const invokeAndTransfer = (ipc, method, ...params) => {
|
|
781
|
+
return invokeHelper(ipc, method, params, true);
|
|
782
|
+
};
|
|
783
|
+
|
|
784
|
+
const commands = Object.create(null);
|
|
785
|
+
const register = commandMap => {
|
|
786
|
+
Object.assign(commands, commandMap);
|
|
787
|
+
};
|
|
788
|
+
const getCommand = key => {
|
|
789
|
+
return commands[key];
|
|
790
|
+
};
|
|
791
|
+
const execute = (command, ...args) => {
|
|
792
|
+
const fn = getCommand(command);
|
|
793
|
+
if (!fn) {
|
|
794
|
+
throw new Error(`command not found ${command}`);
|
|
795
|
+
}
|
|
796
|
+
return fn(...args);
|
|
745
797
|
};
|
|
746
798
|
|
|
747
799
|
const createRpc = ipc => {
|
|
@@ -771,16 +823,22 @@ const logError = () => {
|
|
|
771
823
|
// handled by renderer worker
|
|
772
824
|
};
|
|
773
825
|
const handleMessage = event => {
|
|
774
|
-
|
|
826
|
+
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
|
|
827
|
+
return handleJsonRpcMessage(event.target, event.data, execute, resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
775
828
|
};
|
|
776
829
|
const handleIpc = ipc => {
|
|
777
|
-
|
|
830
|
+
if ('addEventListener' in ipc) {
|
|
831
|
+
ipc.addEventListener('message', handleMessage);
|
|
832
|
+
} else if ('on' in ipc) {
|
|
833
|
+
// deprecated
|
|
834
|
+
ipc.on('message', handleMessage);
|
|
835
|
+
}
|
|
778
836
|
};
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
837
|
+
const listen$1 = async (module, options) => {
|
|
838
|
+
const rawIpc = await module.listen(options);
|
|
839
|
+
if (module.signal) {
|
|
840
|
+
module.signal(rawIpc);
|
|
841
|
+
}
|
|
784
842
|
const ipc = module.wrap(rawIpc);
|
|
785
843
|
return ipc;
|
|
786
844
|
};
|
|
@@ -789,7 +847,7 @@ const create = async ({
|
|
|
789
847
|
}) => {
|
|
790
848
|
// TODO create a commandMap per rpc instance
|
|
791
849
|
register(commandMap);
|
|
792
|
-
const ipc = await listen$1();
|
|
850
|
+
const ipc = await listen$1(IpcChildWithModuleWorkerAndMessagePort$1);
|
|
793
851
|
handleIpc(ipc);
|
|
794
852
|
const rpc = createRpc(ipc);
|
|
795
853
|
return rpc;
|
|
@@ -839,7 +897,7 @@ const compareDirent = (direntA, direntB) => {
|
|
|
839
897
|
return compareDirentType(direntA, direntB) || compareDirentName(direntA, direntB);
|
|
840
898
|
};
|
|
841
899
|
|
|
842
|
-
const getFileIcon = ({
|
|
900
|
+
const getFileIcon$1 = ({
|
|
843
901
|
name
|
|
844
902
|
}) => {
|
|
845
903
|
return '';
|
|
@@ -862,7 +920,7 @@ const computeExplorerRenamedDirent = (dirents, index, newName) => {
|
|
|
862
920
|
...oldDirent,
|
|
863
921
|
name: newName,
|
|
864
922
|
path: oldDirent.path.slice(0, -oldDirent.name.length) + newName,
|
|
865
|
-
icon: getFileIcon({
|
|
923
|
+
icon: getFileIcon$1({
|
|
866
924
|
name: newName
|
|
867
925
|
})
|
|
868
926
|
};
|
|
@@ -1219,59 +1277,6 @@ const copyRelativePath$1 = async state => {
|
|
|
1219
1277
|
return state;
|
|
1220
1278
|
};
|
|
1221
1279
|
|
|
1222
|
-
class AssertionError extends Error {
|
|
1223
|
-
constructor(message) {
|
|
1224
|
-
super(message);
|
|
1225
|
-
this.name = 'AssertionError';
|
|
1226
|
-
}
|
|
1227
|
-
}
|
|
1228
|
-
const getType = value => {
|
|
1229
|
-
switch (typeof value) {
|
|
1230
|
-
case 'number':
|
|
1231
|
-
return 'number';
|
|
1232
|
-
case 'function':
|
|
1233
|
-
return 'function';
|
|
1234
|
-
case 'string':
|
|
1235
|
-
return 'string';
|
|
1236
|
-
case 'object':
|
|
1237
|
-
if (value === null) {
|
|
1238
|
-
return 'null';
|
|
1239
|
-
}
|
|
1240
|
-
if (Array.isArray(value)) {
|
|
1241
|
-
return 'array';
|
|
1242
|
-
}
|
|
1243
|
-
return 'object';
|
|
1244
|
-
case 'boolean':
|
|
1245
|
-
return 'boolean';
|
|
1246
|
-
default:
|
|
1247
|
-
return 'unknown';
|
|
1248
|
-
}
|
|
1249
|
-
};
|
|
1250
|
-
const object = value => {
|
|
1251
|
-
const type = getType(value);
|
|
1252
|
-
if (type !== 'object') {
|
|
1253
|
-
throw new AssertionError('expected value to be of type object');
|
|
1254
|
-
}
|
|
1255
|
-
};
|
|
1256
|
-
const number = value => {
|
|
1257
|
-
const type = getType(value);
|
|
1258
|
-
if (type !== 'number') {
|
|
1259
|
-
throw new AssertionError('expected value to be of type number');
|
|
1260
|
-
}
|
|
1261
|
-
};
|
|
1262
|
-
const array = value => {
|
|
1263
|
-
const type = getType(value);
|
|
1264
|
-
if (type !== 'array') {
|
|
1265
|
-
throw new AssertionError('expected value to be of type array');
|
|
1266
|
-
}
|
|
1267
|
-
};
|
|
1268
|
-
const string = value => {
|
|
1269
|
-
const type = getType(value);
|
|
1270
|
-
if (type !== 'string') {
|
|
1271
|
-
throw new AssertionError('expected value to be of type string');
|
|
1272
|
-
}
|
|
1273
|
-
};
|
|
1274
|
-
|
|
1275
1280
|
const isSymbolicLink = dirent => {
|
|
1276
1281
|
return dirent.type === Symlink;
|
|
1277
1282
|
};
|
|
@@ -2171,7 +2176,7 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
|
|
|
2171
2176
|
...item,
|
|
2172
2177
|
isFocused: i === focusedIndex,
|
|
2173
2178
|
isEditing: true,
|
|
2174
|
-
icon: getFileIcon({
|
|
2179
|
+
icon: getFileIcon$1({
|
|
2175
2180
|
name: editingValue
|
|
2176
2181
|
})
|
|
2177
2182
|
});
|
|
@@ -2213,6 +2218,22 @@ const handleBlur = state => {
|
|
|
2213
2218
|
};
|
|
2214
2219
|
};
|
|
2215
2220
|
|
|
2221
|
+
const getFileIcon = dirent => {
|
|
2222
|
+
if (dirent.type === File) {
|
|
2223
|
+
return invoke('IconTheme.getFileIcon', {
|
|
2224
|
+
name: dirent.name
|
|
2225
|
+
});
|
|
2226
|
+
}
|
|
2227
|
+
return invoke('IconTheme.getFolderIcon', {
|
|
2228
|
+
name: dirent.name
|
|
2229
|
+
});
|
|
2230
|
+
};
|
|
2231
|
+
const getFileIcons = async dirents => {
|
|
2232
|
+
const promises = dirents.map(getFileIcon);
|
|
2233
|
+
const icons = await Promise.all(promises);
|
|
2234
|
+
return icons;
|
|
2235
|
+
};
|
|
2236
|
+
|
|
2216
2237
|
const handleClickDirectory = async (state, dirent, index, keepFocus) => {
|
|
2217
2238
|
dirent.type = DirectoryExpanding;
|
|
2218
2239
|
// TODO handle error
|
|
@@ -2238,16 +2259,19 @@ const handleClickDirectory = async (state, dirent, index, keepFocus) => {
|
|
|
2238
2259
|
} = state2;
|
|
2239
2260
|
// TODO when focused index has changed while expanding, don't update it
|
|
2240
2261
|
const maxLineY = getExplorerMaxLineY(minLineY, height, itemHeight, newDirents.length);
|
|
2262
|
+
const parts = newDirents.slice(minLineY, maxLineY);
|
|
2263
|
+
const icons = await getFileIcons(parts);
|
|
2241
2264
|
return {
|
|
2242
2265
|
...state,
|
|
2243
2266
|
items: newDirents,
|
|
2267
|
+
icons,
|
|
2244
2268
|
focusedIndex: newIndex,
|
|
2245
2269
|
focused: keepFocus,
|
|
2246
2270
|
maxLineY
|
|
2247
2271
|
};
|
|
2248
2272
|
};
|
|
2249
2273
|
|
|
2250
|
-
const handleClickDirectoryExpanded$1 = (state, dirent, index, keepFocus) => {
|
|
2274
|
+
const handleClickDirectoryExpanded$1 = async (state, dirent, index, keepFocus) => {
|
|
2251
2275
|
const {
|
|
2252
2276
|
minLineY,
|
|
2253
2277
|
maxLineY,
|
|
@@ -2266,9 +2290,12 @@ const handleClickDirectoryExpanded$1 = (state, dirent, index, keepFocus) => {
|
|
|
2266
2290
|
const newMaxLineY = Math.min(maxLineY, newTotal);
|
|
2267
2291
|
const newMinLineY = newMaxLineY - visibleItems;
|
|
2268
2292
|
const deltaY = newMinLineY * itemHeight;
|
|
2293
|
+
const parts = newDirents.slice(minLineY, maxLineY);
|
|
2294
|
+
const icons = await getFileIcons(parts);
|
|
2269
2295
|
return {
|
|
2270
2296
|
...state,
|
|
2271
2297
|
items: newDirents,
|
|
2298
|
+
icons,
|
|
2272
2299
|
focusedIndex: index,
|
|
2273
2300
|
focused: keepFocus,
|
|
2274
2301
|
minLineY: newMinLineY,
|
|
@@ -2276,9 +2303,12 @@ const handleClickDirectoryExpanded$1 = (state, dirent, index, keepFocus) => {
|
|
|
2276
2303
|
deltaY
|
|
2277
2304
|
};
|
|
2278
2305
|
}
|
|
2306
|
+
const parts = newDirents.slice(state.minLineY, state.maxLineY);
|
|
2307
|
+
const icons = await getFileIcons(parts);
|
|
2279
2308
|
return {
|
|
2280
2309
|
...state,
|
|
2281
2310
|
items: newDirents,
|
|
2311
|
+
icons,
|
|
2282
2312
|
focusedIndex: index,
|
|
2283
2313
|
focused: keepFocus
|
|
2284
2314
|
};
|
|
@@ -2393,23 +2423,6 @@ const LeftClick = 0;
|
|
|
2393
2423
|
|
|
2394
2424
|
// TODO instead of root string, there should be a root dirent
|
|
2395
2425
|
|
|
2396
|
-
const updateIcon$1 = dirent => {
|
|
2397
|
-
return {
|
|
2398
|
-
...dirent,
|
|
2399
|
-
icon: getIcon()
|
|
2400
|
-
};
|
|
2401
|
-
};
|
|
2402
|
-
const updateIcons$1 = state => {
|
|
2403
|
-
const newDirents = state.items.map(updateIcon$1);
|
|
2404
|
-
return {
|
|
2405
|
-
...state,
|
|
2406
|
-
items: newDirents
|
|
2407
|
-
};
|
|
2408
|
-
};
|
|
2409
|
-
const handleIconThemeChange = state => {
|
|
2410
|
-
return updateIcons$1(state);
|
|
2411
|
-
};
|
|
2412
|
-
|
|
2413
2426
|
// TODO rename dirents to items, then can use virtual list component directly
|
|
2414
2427
|
const setDeltaY$1 = (state, deltaY) => {
|
|
2415
2428
|
const {
|
|
@@ -2815,62 +2828,6 @@ const handleDropIndex = (state, index, files) => {
|
|
|
2815
2828
|
}
|
|
2816
2829
|
};
|
|
2817
2830
|
|
|
2818
|
-
const normalizeLine = line => {
|
|
2819
|
-
if (line.startsWith('Error: ')) {
|
|
2820
|
-
return line.slice('Error: '.length);
|
|
2821
|
-
}
|
|
2822
|
-
if (line.startsWith('VError: ')) {
|
|
2823
|
-
return line.slice('VError: '.length);
|
|
2824
|
-
}
|
|
2825
|
-
return line;
|
|
2826
|
-
};
|
|
2827
|
-
const getCombinedMessage = (error, message) => {
|
|
2828
|
-
const stringifiedError = normalizeLine(`${error}`);
|
|
2829
|
-
if (message) {
|
|
2830
|
-
return `${message}: ${stringifiedError}`;
|
|
2831
|
-
}
|
|
2832
|
-
return stringifiedError;
|
|
2833
|
-
};
|
|
2834
|
-
const NewLine = '\n';
|
|
2835
|
-
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
2836
|
-
return string.indexOf(NewLine, startIndex);
|
|
2837
|
-
};
|
|
2838
|
-
const mergeStacks = (parent, child) => {
|
|
2839
|
-
if (!child) {
|
|
2840
|
-
return parent;
|
|
2841
|
-
}
|
|
2842
|
-
const parentNewLineIndex = getNewLineIndex(parent);
|
|
2843
|
-
const childNewLineIndex = getNewLineIndex(child);
|
|
2844
|
-
if (childNewLineIndex === -1) {
|
|
2845
|
-
return parent;
|
|
2846
|
-
}
|
|
2847
|
-
const parentFirstLine = parent.slice(0, parentNewLineIndex);
|
|
2848
|
-
const childRest = child.slice(childNewLineIndex);
|
|
2849
|
-
const childFirstLine = normalizeLine(child.slice(0, childNewLineIndex));
|
|
2850
|
-
if (parentFirstLine.includes(childFirstLine)) {
|
|
2851
|
-
return parentFirstLine + childRest;
|
|
2852
|
-
}
|
|
2853
|
-
return child;
|
|
2854
|
-
};
|
|
2855
|
-
class VError extends Error {
|
|
2856
|
-
constructor(error, message) {
|
|
2857
|
-
const combinedMessage = getCombinedMessage(error, message);
|
|
2858
|
-
super(combinedMessage);
|
|
2859
|
-
this.name = 'VError';
|
|
2860
|
-
if (error instanceof Error) {
|
|
2861
|
-
this.stack = mergeStacks(this.stack, error.stack);
|
|
2862
|
-
}
|
|
2863
|
-
if (error.codeFrame) {
|
|
2864
|
-
// @ts-ignore
|
|
2865
|
-
this.codeFrame = error.codeFrame;
|
|
2866
|
-
}
|
|
2867
|
-
if (error.code) {
|
|
2868
|
-
// @ts-ignore
|
|
2869
|
-
this.code = error.code;
|
|
2870
|
-
}
|
|
2871
|
-
}
|
|
2872
|
-
}
|
|
2873
|
-
|
|
2874
2831
|
const handleDrop = async (state, x, y, files) => {
|
|
2875
2832
|
try {
|
|
2876
2833
|
const index = getIndexFromPosition(state, x, y);
|
|
@@ -2885,6 +2842,25 @@ const handleDrop = async (state, x, y, files) => {
|
|
|
2885
2842
|
}
|
|
2886
2843
|
};
|
|
2887
2844
|
|
|
2845
|
+
const updateIcon = dirent => {
|
|
2846
|
+
return {
|
|
2847
|
+
...dirent,
|
|
2848
|
+
icon: getIcon()
|
|
2849
|
+
};
|
|
2850
|
+
};
|
|
2851
|
+
|
|
2852
|
+
const updateIcons = state => {
|
|
2853
|
+
const newDirents = state.items.map(updateIcon);
|
|
2854
|
+
return {
|
|
2855
|
+
...state,
|
|
2856
|
+
items: newDirents
|
|
2857
|
+
};
|
|
2858
|
+
};
|
|
2859
|
+
|
|
2860
|
+
const handleIconThemeChange = state => {
|
|
2861
|
+
return updateIcons(state);
|
|
2862
|
+
};
|
|
2863
|
+
|
|
2888
2864
|
const getTopLevelDirents = (root, pathSeparator, excluded) => {
|
|
2889
2865
|
if (!root) {
|
|
2890
2866
|
return [];
|
|
@@ -3172,10 +3148,12 @@ const loadContent = async (state, savedState) => {
|
|
|
3172
3148
|
deltaY = savedState.deltaY;
|
|
3173
3149
|
}
|
|
3174
3150
|
const maxLineY = getExplorerMaxLineY(minLineY, height, itemHeight, restoredDirents.length);
|
|
3151
|
+
const icons = await getFileIcons(restoredDirents);
|
|
3175
3152
|
return {
|
|
3176
3153
|
...state,
|
|
3177
3154
|
root,
|
|
3178
3155
|
items: restoredDirents,
|
|
3156
|
+
icons,
|
|
3179
3157
|
minLineY,
|
|
3180
3158
|
deltaY,
|
|
3181
3159
|
maxLineY,
|
|
@@ -3400,21 +3378,6 @@ const restoreState = savedState => {
|
|
|
3400
3378
|
};
|
|
3401
3379
|
};
|
|
3402
3380
|
|
|
3403
|
-
const updateIcon = dirent => {
|
|
3404
|
-
return {
|
|
3405
|
-
...dirent,
|
|
3406
|
-
icon: getIcon()
|
|
3407
|
-
};
|
|
3408
|
-
};
|
|
3409
|
-
|
|
3410
|
-
const updateIcons = state => {
|
|
3411
|
-
const newDirents = state.items.map(updateIcon);
|
|
3412
|
-
return {
|
|
3413
|
-
...state,
|
|
3414
|
-
items: newDirents
|
|
3415
|
-
};
|
|
3416
|
-
};
|
|
3417
|
-
|
|
3418
3381
|
const getIndex = (dirents, uri) => {
|
|
3419
3382
|
for (let i = 0; i < dirents.length; i++) {
|
|
3420
3383
|
const dirent = dirents[i];
|
|
@@ -3688,7 +3651,7 @@ const setDeltaY = (state, deltaY) => {
|
|
|
3688
3651
|
};
|
|
3689
3652
|
|
|
3690
3653
|
const updateEditingValue = (state, value) => {
|
|
3691
|
-
const editingIcon = getFileIcon({
|
|
3654
|
+
const editingIcon = getFileIcon$1({
|
|
3692
3655
|
name: value
|
|
3693
3656
|
});
|
|
3694
3657
|
return {
|