@lvce-editor/about-view 4.2.0 → 4.4.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/aboutWorkerMain.js +114 -109
- package/package.json +1 -1
package/dist/aboutWorkerMain.js
CHANGED
@@ -54,27 +54,6 @@ class VError extends Error {
|
|
54
54
|
}
|
55
55
|
}
|
56
56
|
|
57
|
-
const walkValue = (value, transferrables, isTransferrable) => {
|
58
|
-
if (!value) {
|
59
|
-
return;
|
60
|
-
}
|
61
|
-
if (isTransferrable(value)) {
|
62
|
-
transferrables.push(value);
|
63
|
-
return;
|
64
|
-
}
|
65
|
-
if (Array.isArray(value)) {
|
66
|
-
for (const item of value) {
|
67
|
-
walkValue(item, transferrables, isTransferrable);
|
68
|
-
}
|
69
|
-
return;
|
70
|
-
}
|
71
|
-
if (typeof value === 'object') {
|
72
|
-
for (const property of Object.values(value)) {
|
73
|
-
walkValue(property, transferrables, isTransferrable);
|
74
|
-
}
|
75
|
-
return;
|
76
|
-
}
|
77
|
-
};
|
78
57
|
const isMessagePort = value => {
|
79
58
|
return value && value instanceof MessagePort;
|
80
59
|
};
|
@@ -99,6 +78,27 @@ const isTransferrable = value => {
|
|
99
78
|
}
|
100
79
|
return false;
|
101
80
|
};
|
81
|
+
const walkValue = (value, transferrables, isTransferrable) => {
|
82
|
+
if (!value) {
|
83
|
+
return;
|
84
|
+
}
|
85
|
+
if (isTransferrable(value)) {
|
86
|
+
transferrables.push(value);
|
87
|
+
return;
|
88
|
+
}
|
89
|
+
if (Array.isArray(value)) {
|
90
|
+
for (const item of value) {
|
91
|
+
walkValue(item, transferrables, isTransferrable);
|
92
|
+
}
|
93
|
+
return;
|
94
|
+
}
|
95
|
+
if (typeof value === 'object') {
|
96
|
+
for (const property of Object.values(value)) {
|
97
|
+
walkValue(property, transferrables, isTransferrable);
|
98
|
+
}
|
99
|
+
return;
|
100
|
+
}
|
101
|
+
};
|
102
102
|
const getTransferrables = value => {
|
103
103
|
const transferrables = [];
|
104
104
|
walkValue(value, transferrables, isTransferrable);
|
@@ -131,30 +131,35 @@ const NewLine$2 = '\n';
|
|
131
131
|
const joinLines$2 = lines => {
|
132
132
|
return lines.join(NewLine$2);
|
133
133
|
};
|
134
|
-
const
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
134
|
+
const RE_AT = /^\s+at/;
|
135
|
+
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
136
|
+
const isNormalStackLine = line => {
|
137
|
+
return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
|
139
138
|
};
|
140
|
-
const
|
141
|
-
const
|
142
|
-
|
143
|
-
|
139
|
+
const getDetails = lines => {
|
140
|
+
const index = lines.findIndex(isNormalStackLine);
|
141
|
+
if (index === -1) {
|
142
|
+
return {
|
143
|
+
actualMessage: joinLines$2(lines),
|
144
|
+
rest: []
|
145
|
+
};
|
146
|
+
}
|
147
|
+
let lastIndex = index - 1;
|
148
|
+
while (++lastIndex < lines.length) {
|
149
|
+
if (!isNormalStackLine(lines[lastIndex])) {
|
150
|
+
break;
|
151
|
+
}
|
152
|
+
}
|
144
153
|
return {
|
145
|
-
|
146
|
-
|
154
|
+
actualMessage: lines[index - 1],
|
155
|
+
rest: lines.slice(index, lastIndex)
|
147
156
|
};
|
148
157
|
};
|
149
|
-
const
|
150
|
-
|
158
|
+
const splitLines$1 = lines => {
|
159
|
+
return lines.split(NewLine$2);
|
160
|
+
};
|
151
161
|
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
152
162
|
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
163
|
const isMessageCodeBlockStartIndex = line => {
|
159
164
|
return RE_MESSAGE_CODE_BLOCK_START.test(line);
|
160
165
|
};
|
@@ -169,51 +174,46 @@ const getMessageCodeBlock = stderr => {
|
|
169
174
|
const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
|
170
175
|
return relevantMessage;
|
171
176
|
};
|
172
|
-
const
|
173
|
-
|
177
|
+
const isModuleNotFoundMessage = line => {
|
178
|
+
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
179
|
+
};
|
180
|
+
const getModuleNotFoundError = stderr => {
|
181
|
+
const lines = splitLines$1(stderr);
|
182
|
+
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
183
|
+
const message = lines[messageIndex];
|
174
184
|
return {
|
175
|
-
message
|
176
|
-
code:
|
185
|
+
message,
|
186
|
+
code: ERR_MODULE_NOT_FOUND
|
177
187
|
};
|
178
188
|
};
|
179
|
-
const
|
189
|
+
const isModuleNotFoundError = stderr => {
|
180
190
|
if (!stderr) {
|
181
191
|
return false;
|
182
192
|
}
|
183
|
-
return stderr.includes('
|
184
|
-
};
|
185
|
-
const getModuleSyntaxError = () => {
|
186
|
-
return {
|
187
|
-
message: `ES Modules are not supported in electron`,
|
188
|
-
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
|
189
|
-
};
|
193
|
+
return stderr.includes('ERR_MODULE_NOT_FOUND');
|
190
194
|
};
|
191
|
-
const
|
195
|
+
const isModulesSyntaxError = stderr => {
|
192
196
|
if (!stderr) {
|
193
197
|
return false;
|
194
198
|
}
|
195
|
-
return stderr.includes('
|
199
|
+
return stderr.includes('SyntaxError: Cannot use import statement outside a module');
|
196
200
|
};
|
197
|
-
const
|
198
|
-
|
201
|
+
const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
|
202
|
+
const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
|
203
|
+
const isUnhelpfulNativeModuleError = stderr => {
|
204
|
+
return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
|
199
205
|
};
|
200
|
-
const
|
201
|
-
const
|
202
|
-
if (index === -1) {
|
203
|
-
return {
|
204
|
-
actualMessage: joinLines$2(lines),
|
205
|
-
rest: []
|
206
|
-
};
|
207
|
-
}
|
208
|
-
let lastIndex = index - 1;
|
209
|
-
while (++lastIndex < lines.length) {
|
210
|
-
if (!isNormalStackLine(lines[lastIndex])) {
|
211
|
-
break;
|
212
|
-
}
|
213
|
-
}
|
206
|
+
const getNativeModuleErrorMessage = stderr => {
|
207
|
+
const message = getMessageCodeBlock(stderr);
|
214
208
|
return {
|
215
|
-
|
216
|
-
|
209
|
+
message: `Incompatible native node module: ${message}`,
|
210
|
+
code: E_INCOMPATIBLE_NATIVE_MODULE
|
211
|
+
};
|
212
|
+
};
|
213
|
+
const getModuleSyntaxError = () => {
|
214
|
+
return {
|
215
|
+
message: `ES Modules are not supported in electron`,
|
216
|
+
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
|
217
217
|
};
|
218
218
|
};
|
219
219
|
const getHelpfulChildProcessError = (stdout, stderr) => {
|
@@ -232,7 +232,7 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
232
232
|
rest
|
233
233
|
} = getDetails(lines);
|
234
234
|
return {
|
235
|
-
message:
|
235
|
+
message: actualMessage,
|
236
236
|
code: '',
|
237
237
|
stack: rest
|
238
238
|
};
|
@@ -267,14 +267,14 @@ const readyMessage = 'ready';
|
|
267
267
|
const getData$2 = event => {
|
268
268
|
return event.data;
|
269
269
|
};
|
270
|
-
const listen$
|
270
|
+
const listen$7 = () => {
|
271
271
|
// @ts-ignore
|
272
272
|
if (typeof WorkerGlobalScope === 'undefined') {
|
273
273
|
throw new TypeError('module is not in web worker scope');
|
274
274
|
}
|
275
275
|
return globalThis;
|
276
276
|
};
|
277
|
-
const signal$
|
277
|
+
const signal$8 = global => {
|
278
278
|
global.postMessage(readyMessage);
|
279
279
|
};
|
280
280
|
class IpcChildWithModuleWorker extends Ipc {
|
@@ -300,7 +300,7 @@ class IpcChildWithModuleWorker extends Ipc {
|
|
300
300
|
this._rawIpc.addEventListener('message', callback);
|
301
301
|
}
|
302
302
|
}
|
303
|
-
const wrap$
|
303
|
+
const wrap$f = global => {
|
304
304
|
return new IpcChildWithModuleWorker(global);
|
305
305
|
};
|
306
306
|
const withResolvers = () => {
|
@@ -309,6 +309,7 @@ const withResolvers = () => {
|
|
309
309
|
_resolve = resolve;
|
310
310
|
});
|
311
311
|
return {
|
312
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
312
313
|
resolve: _resolve,
|
313
314
|
promise
|
314
315
|
};
|
@@ -325,10 +326,10 @@ const waitForFirstMessage = async port => {
|
|
325
326
|
// @ts-ignore
|
326
327
|
return event.data;
|
327
328
|
};
|
328
|
-
const listen$
|
329
|
-
const parentIpcRaw = listen$
|
330
|
-
signal$
|
331
|
-
const parentIpc = wrap$
|
329
|
+
const listen$6 = async () => {
|
330
|
+
const parentIpcRaw = listen$7();
|
331
|
+
signal$8(parentIpcRaw);
|
332
|
+
const parentIpc = wrap$f(parentIpcRaw);
|
332
333
|
const firstMessage = await waitForFirstMessage(parentIpc);
|
333
334
|
if (firstMessage.method !== 'initialize') {
|
334
335
|
throw new IpcError('unexpected first message');
|
@@ -347,9 +348,6 @@ const listen$5 = async () => {
|
|
347
348
|
return globalThis;
|
348
349
|
};
|
349
350
|
class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
350
|
-
constructor(port) {
|
351
|
-
super(port);
|
352
|
-
}
|
353
351
|
getData(event) {
|
354
352
|
return getData$2(event);
|
355
353
|
}
|
@@ -373,13 +371,13 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
373
371
|
this._rawIpc.start();
|
374
372
|
}
|
375
373
|
}
|
376
|
-
const wrap$
|
374
|
+
const wrap$e = port => {
|
377
375
|
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
378
376
|
};
|
379
377
|
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
380
378
|
__proto__: null,
|
381
|
-
listen: listen$
|
382
|
-
wrap: wrap$
|
379
|
+
listen: listen$6,
|
380
|
+
wrap: wrap$e
|
383
381
|
};
|
384
382
|
|
385
383
|
const Two = '2.0';
|
@@ -391,10 +389,10 @@ const create$4 = (method, params) => {
|
|
391
389
|
};
|
392
390
|
};
|
393
391
|
const callbacks = Object.create(null);
|
394
|
-
const set = (id, fn) => {
|
392
|
+
const set$1 = (id, fn) => {
|
395
393
|
callbacks[id] = fn;
|
396
394
|
};
|
397
|
-
const get = id => {
|
395
|
+
const get$1 = id => {
|
398
396
|
return callbacks[id];
|
399
397
|
};
|
400
398
|
const remove = id => {
|
@@ -404,31 +402,18 @@ let id = 0;
|
|
404
402
|
const create$3 = () => {
|
405
403
|
return ++id;
|
406
404
|
};
|
407
|
-
const warn = (...args) => {
|
408
|
-
console.warn(...args);
|
409
|
-
};
|
410
405
|
const registerPromise = () => {
|
411
406
|
const id = create$3();
|
412
407
|
const {
|
413
408
|
resolve,
|
414
409
|
promise
|
415
410
|
} = Promise.withResolvers();
|
416
|
-
set(id, resolve);
|
411
|
+
set$1(id, resolve);
|
417
412
|
return {
|
418
413
|
id,
|
419
414
|
promise
|
420
415
|
};
|
421
416
|
};
|
422
|
-
const resolve = (id, response) => {
|
423
|
-
const fn = get(id);
|
424
|
-
if (!fn) {
|
425
|
-
console.log(response);
|
426
|
-
warn(`callback ${id} may already be disposed`);
|
427
|
-
return;
|
428
|
-
}
|
429
|
-
fn(response);
|
430
|
-
remove(id);
|
431
|
-
};
|
432
417
|
const create$2 = (method, params) => {
|
433
418
|
const {
|
434
419
|
id,
|
@@ -576,6 +561,19 @@ const unwrapJsonRpcResult = responseMessage => {
|
|
576
561
|
}
|
577
562
|
throw new JsonRpcError('unexpected response message');
|
578
563
|
};
|
564
|
+
const warn = (...args) => {
|
565
|
+
console.warn(...args);
|
566
|
+
};
|
567
|
+
const resolve = (id, response) => {
|
568
|
+
const fn = get$1(id);
|
569
|
+
if (!fn) {
|
570
|
+
console.log(response);
|
571
|
+
warn(`callback ${id} may already be disposed`);
|
572
|
+
return;
|
573
|
+
}
|
574
|
+
fn(response);
|
575
|
+
remove(id);
|
576
|
+
};
|
579
577
|
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
580
578
|
const getErrorType = prettyError => {
|
581
579
|
if (prettyError && prettyError.type) {
|
@@ -745,6 +743,8 @@ const execute = (command, ...args) => {
|
|
745
743
|
|
746
744
|
const createRpc = ipc => {
|
747
745
|
const rpc = {
|
746
|
+
// @ts-ignore
|
747
|
+
ipc,
|
748
748
|
/**
|
749
749
|
* @deprecated
|
750
750
|
*/
|
@@ -771,7 +771,8 @@ const logError = () => {
|
|
771
771
|
};
|
772
772
|
const handleMessage = event => {
|
773
773
|
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
|
774
|
-
|
774
|
+
const actualExecute = event?.target?.execute || execute;
|
775
|
+
return handleJsonRpcMessage(event.target, event.data, actualExecute, resolve, preparePrettyError, logError, actualRequiresSocket);
|
775
776
|
};
|
776
777
|
const handleIpc = ipc => {
|
777
778
|
if ('addEventListener' in ipc) {
|
@@ -1140,17 +1141,21 @@ const joinLines = lines => {
|
|
1140
1141
|
return lines.join(NewLine);
|
1141
1142
|
};
|
1142
1143
|
|
1143
|
-
const
|
1144
|
-
|
1144
|
+
const RendererWorker = 1;
|
1145
|
+
|
1146
|
+
const rpcs = Object.create(null);
|
1147
|
+
const set = (id, rpc) => {
|
1148
|
+
rpcs[id] = rpc;
|
1149
|
+
};
|
1150
|
+
const get = id => {
|
1151
|
+
return rpcs[id];
|
1145
1152
|
};
|
1153
|
+
|
1146
1154
|
const invoke = (method, ...params) => {
|
1147
|
-
const rpc =
|
1155
|
+
const rpc = get(RendererWorker);
|
1148
1156
|
// @ts-ignore
|
1149
1157
|
return rpc.invoke(method, ...params);
|
1150
1158
|
};
|
1151
|
-
const setRpc = rpc => {
|
1152
|
-
state.rpc = rpc;
|
1153
|
-
};
|
1154
1159
|
|
1155
1160
|
const version = '0.0.0-dev';
|
1156
1161
|
const commit = 'unknown commit';
|
@@ -1561,7 +1566,7 @@ const listen = async () => {
|
|
1561
1566
|
const rpc = await WebWorkerRpcClient.create({
|
1562
1567
|
commandMap: commandMap
|
1563
1568
|
});
|
1564
|
-
|
1569
|
+
set(RendererWorker, rpc);
|
1565
1570
|
};
|
1566
1571
|
|
1567
1572
|
const main = async () => {
|