@lvce-editor/test-worker 3.2.0 → 3.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/testWorkerMain.js +89 -82
- package/package.json +1 -1
package/dist/testWorkerMain.js
CHANGED
|
@@ -95,27 +95,6 @@ const string = value => {
|
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
97
|
|
|
98
|
-
const walkValue = (value, transferrables, isTransferrable) => {
|
|
99
|
-
if (!value) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
if (isTransferrable(value)) {
|
|
103
|
-
transferrables.push(value);
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
if (Array.isArray(value)) {
|
|
107
|
-
for (const item of value) {
|
|
108
|
-
walkValue(item, transferrables, isTransferrable);
|
|
109
|
-
}
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
if (typeof value === 'object') {
|
|
113
|
-
for (const property of Object.values(value)) {
|
|
114
|
-
walkValue(property, transferrables, isTransferrable);
|
|
115
|
-
}
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
98
|
const isMessagePort = value => {
|
|
120
99
|
return value && value instanceof MessagePort;
|
|
121
100
|
};
|
|
@@ -140,6 +119,27 @@ const isTransferrable = value => {
|
|
|
140
119
|
}
|
|
141
120
|
return false;
|
|
142
121
|
};
|
|
122
|
+
const walkValue = (value, transferrables, isTransferrable) => {
|
|
123
|
+
if (!value) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (isTransferrable(value)) {
|
|
127
|
+
transferrables.push(value);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (Array.isArray(value)) {
|
|
131
|
+
for (const item of value) {
|
|
132
|
+
walkValue(item, transferrables, isTransferrable);
|
|
133
|
+
}
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (typeof value === 'object') {
|
|
137
|
+
for (const property of Object.values(value)) {
|
|
138
|
+
walkValue(property, transferrables, isTransferrable);
|
|
139
|
+
}
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
143
|
const getTransferrables = value => {
|
|
144
144
|
const transferrables = [];
|
|
145
145
|
walkValue(value, transferrables, isTransferrable);
|
|
@@ -172,30 +172,35 @@ const NewLine$1 = '\n';
|
|
|
172
172
|
const joinLines$1 = lines => {
|
|
173
173
|
return lines.join(NewLine$1);
|
|
174
174
|
};
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
|
175
|
+
const RE_AT = /^\s+at/;
|
|
176
|
+
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
|
177
|
+
const isNormalStackLine = line => {
|
|
178
|
+
return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
|
|
180
179
|
};
|
|
181
|
-
const
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
180
|
+
const getDetails = lines => {
|
|
181
|
+
const index = lines.findIndex(isNormalStackLine);
|
|
182
|
+
if (index === -1) {
|
|
183
|
+
return {
|
|
184
|
+
actualMessage: joinLines$1(lines),
|
|
185
|
+
rest: []
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
let lastIndex = index - 1;
|
|
189
|
+
while (++lastIndex < lines.length) {
|
|
190
|
+
if (!isNormalStackLine(lines[lastIndex])) {
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
185
194
|
return {
|
|
186
|
-
|
|
187
|
-
|
|
195
|
+
actualMessage: lines[index - 1],
|
|
196
|
+
rest: lines.slice(index, lastIndex)
|
|
188
197
|
};
|
|
189
198
|
};
|
|
190
|
-
const
|
|
191
|
-
|
|
199
|
+
const splitLines$1 = lines => {
|
|
200
|
+
return lines.split(NewLine$1);
|
|
201
|
+
};
|
|
192
202
|
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
|
193
203
|
const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
|
|
194
|
-
const RE_AT = /^\s+at/;
|
|
195
|
-
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
|
196
|
-
const isUnhelpfulNativeModuleError = stderr => {
|
|
197
|
-
return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
|
|
198
|
-
};
|
|
199
204
|
const isMessageCodeBlockStartIndex = line => {
|
|
200
205
|
return RE_MESSAGE_CODE_BLOCK_START.test(line);
|
|
201
206
|
};
|
|
@@ -210,51 +215,46 @@ const getMessageCodeBlock = stderr => {
|
|
|
210
215
|
const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
|
|
211
216
|
return relevantMessage;
|
|
212
217
|
};
|
|
213
|
-
const
|
|
214
|
-
|
|
218
|
+
const isModuleNotFoundMessage = line => {
|
|
219
|
+
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
|
220
|
+
};
|
|
221
|
+
const getModuleNotFoundError = stderr => {
|
|
222
|
+
const lines = splitLines$1(stderr);
|
|
223
|
+
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
224
|
+
const message = lines[messageIndex];
|
|
215
225
|
return {
|
|
216
|
-
message
|
|
217
|
-
code:
|
|
226
|
+
message,
|
|
227
|
+
code: ERR_MODULE_NOT_FOUND
|
|
218
228
|
};
|
|
219
229
|
};
|
|
220
|
-
const
|
|
230
|
+
const isModuleNotFoundError = stderr => {
|
|
221
231
|
if (!stderr) {
|
|
222
232
|
return false;
|
|
223
233
|
}
|
|
224
|
-
return stderr.includes('
|
|
225
|
-
};
|
|
226
|
-
const getModuleSyntaxError = () => {
|
|
227
|
-
return {
|
|
228
|
-
message: `ES Modules are not supported in electron`,
|
|
229
|
-
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
|
|
230
|
-
};
|
|
234
|
+
return stderr.includes('ERR_MODULE_NOT_FOUND');
|
|
231
235
|
};
|
|
232
|
-
const
|
|
236
|
+
const isModulesSyntaxError = stderr => {
|
|
233
237
|
if (!stderr) {
|
|
234
238
|
return false;
|
|
235
239
|
}
|
|
236
|
-
return stderr.includes('
|
|
240
|
+
return stderr.includes('SyntaxError: Cannot use import statement outside a module');
|
|
237
241
|
};
|
|
238
|
-
const
|
|
239
|
-
|
|
242
|
+
const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
|
|
243
|
+
const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
|
|
244
|
+
const isUnhelpfulNativeModuleError = stderr => {
|
|
245
|
+
return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
|
|
240
246
|
};
|
|
241
|
-
const
|
|
242
|
-
const
|
|
243
|
-
if (index === -1) {
|
|
244
|
-
return {
|
|
245
|
-
actualMessage: joinLines$1(lines),
|
|
246
|
-
rest: []
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
let lastIndex = index - 1;
|
|
250
|
-
while (++lastIndex < lines.length) {
|
|
251
|
-
if (!isNormalStackLine(lines[lastIndex])) {
|
|
252
|
-
break;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
247
|
+
const getNativeModuleErrorMessage = stderr => {
|
|
248
|
+
const message = getMessageCodeBlock(stderr);
|
|
255
249
|
return {
|
|
256
|
-
|
|
257
|
-
|
|
250
|
+
message: `Incompatible native node module: ${message}`,
|
|
251
|
+
code: E_INCOMPATIBLE_NATIVE_MODULE
|
|
252
|
+
};
|
|
253
|
+
};
|
|
254
|
+
const getModuleSyntaxError = () => {
|
|
255
|
+
return {
|
|
256
|
+
message: `ES Modules are not supported in electron`,
|
|
257
|
+
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
|
|
258
258
|
};
|
|
259
259
|
};
|
|
260
260
|
const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
@@ -273,7 +273,7 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
|
273
273
|
rest
|
|
274
274
|
} = getDetails(lines);
|
|
275
275
|
return {
|
|
276
|
-
message:
|
|
276
|
+
message: actualMessage,
|
|
277
277
|
code: '',
|
|
278
278
|
stack: rest
|
|
279
279
|
};
|
|
@@ -315,7 +315,7 @@ const listen$7 = () => {
|
|
|
315
315
|
}
|
|
316
316
|
return globalThis;
|
|
317
317
|
};
|
|
318
|
-
const signal$
|
|
318
|
+
const signal$8 = global => {
|
|
319
319
|
global.postMessage(readyMessage);
|
|
320
320
|
};
|
|
321
321
|
class IpcChildWithModuleWorker extends Ipc {
|
|
@@ -341,7 +341,7 @@ class IpcChildWithModuleWorker extends Ipc {
|
|
|
341
341
|
this._rawIpc.addEventListener('message', callback);
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
|
-
const wrap$
|
|
344
|
+
const wrap$f = global => {
|
|
345
345
|
return new IpcChildWithModuleWorker(global);
|
|
346
346
|
};
|
|
347
347
|
const withResolvers = () => {
|
|
@@ -350,6 +350,7 @@ const withResolvers = () => {
|
|
|
350
350
|
_resolve = resolve;
|
|
351
351
|
});
|
|
352
352
|
return {
|
|
353
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
353
354
|
resolve: _resolve,
|
|
354
355
|
promise
|
|
355
356
|
};
|
|
@@ -368,8 +369,8 @@ const waitForFirstMessage = async port => {
|
|
|
368
369
|
};
|
|
369
370
|
const listen$6 = async () => {
|
|
370
371
|
const parentIpcRaw = listen$7();
|
|
371
|
-
signal$
|
|
372
|
-
const parentIpc = wrap$
|
|
372
|
+
signal$8(parentIpcRaw);
|
|
373
|
+
const parentIpc = wrap$f(parentIpcRaw);
|
|
373
374
|
const firstMessage = await waitForFirstMessage(parentIpc);
|
|
374
375
|
if (firstMessage.method !== 'initialize') {
|
|
375
376
|
throw new IpcError('unexpected first message');
|
|
@@ -388,9 +389,6 @@ const listen$6 = async () => {
|
|
|
388
389
|
return globalThis;
|
|
389
390
|
};
|
|
390
391
|
class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
391
|
-
constructor(port) {
|
|
392
|
-
super(port);
|
|
393
|
-
}
|
|
394
392
|
getData(event) {
|
|
395
393
|
return getData$2(event);
|
|
396
394
|
}
|
|
@@ -414,13 +412,13 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
|
414
412
|
this._rawIpc.start();
|
|
415
413
|
}
|
|
416
414
|
}
|
|
417
|
-
const wrap$
|
|
415
|
+
const wrap$e = port => {
|
|
418
416
|
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
419
417
|
};
|
|
420
418
|
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
421
419
|
__proto__: null,
|
|
422
420
|
listen: listen$6,
|
|
423
|
-
wrap: wrap$
|
|
421
|
+
wrap: wrap$e
|
|
424
422
|
};
|
|
425
423
|
|
|
426
424
|
const Two = '2.0';
|
|
@@ -786,6 +784,8 @@ const execute$3 = (command, ...args) => {
|
|
|
786
784
|
|
|
787
785
|
const createRpc = ipc => {
|
|
788
786
|
const rpc = {
|
|
787
|
+
// @ts-ignore
|
|
788
|
+
ipc,
|
|
789
789
|
/**
|
|
790
790
|
* @deprecated
|
|
791
791
|
*/
|
|
@@ -812,7 +812,8 @@ const logError$1 = () => {
|
|
|
812
812
|
};
|
|
813
813
|
const handleMessage = event => {
|
|
814
814
|
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket$1;
|
|
815
|
-
|
|
815
|
+
const actualExecute = event?.target?.execute || execute$3;
|
|
816
|
+
return handleJsonRpcMessage(event.target, event.data, actualExecute, resolve, preparePrettyError$1, logError$1, actualRequiresSocket);
|
|
816
817
|
};
|
|
817
818
|
const handleIpc = ipc => {
|
|
818
819
|
if ('addEventListener' in ipc) {
|
|
@@ -999,6 +1000,12 @@ const expect$1 = locator => {
|
|
|
999
1000
|
text
|
|
1000
1001
|
});
|
|
1001
1002
|
},
|
|
1003
|
+
async toContainText(text) {
|
|
1004
|
+
Assert.string(text, 'text must be of type string');
|
|
1005
|
+
return this.checkSingleElementCondition('toContainText', {
|
|
1006
|
+
text
|
|
1007
|
+
});
|
|
1008
|
+
},
|
|
1002
1009
|
async toHaveValue(value) {
|
|
1003
1010
|
Assert.string(value, 'value must be of type string');
|
|
1004
1011
|
return this.checkSingleElementCondition('toHaveValue', {
|