@vitest/web-worker 4.0.12 → 4.0.14
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/index.js +1 -1
- package/dist/pure.js +8 -4
- package/package.json +3 -4
package/dist/index.js
CHANGED
package/dist/pure.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MessageChannel } from 'node:worker_threads';
|
|
2
2
|
import { getWorkerState, VitestModuleEvaluator, startVitestModuleRunner, VITEST_VM_CONTEXT_SYMBOL } from 'vitest/internal/module-runner';
|
|
3
|
-
import createDebug from '
|
|
3
|
+
import { createDebug } from 'obug';
|
|
4
4
|
|
|
5
5
|
function startWebWorkerModuleRunner(context) {
|
|
6
6
|
const state = getWorkerState();
|
|
@@ -314,11 +314,13 @@ function createClonedMessageEvent(data, transferOrOptions, clone) {
|
|
|
314
314
|
const transfer = Array.isArray(transferOrOptions) ? transferOrOptions : transferOrOptions?.transfer;
|
|
315
315
|
debug("clone worker message %o", data);
|
|
316
316
|
const origin = typeof location === "undefined" ? undefined : location.origin;
|
|
317
|
+
const ports = transfer?.filter((t) => t instanceof MessagePort);
|
|
317
318
|
if (typeof structuredClone === "function" && clone === "native") {
|
|
318
319
|
debug("create message event, using native structured clone");
|
|
319
320
|
return new MessageEvent("message", {
|
|
320
321
|
data: structuredClone(data, { transfer }),
|
|
321
|
-
origin
|
|
322
|
+
origin,
|
|
323
|
+
ports
|
|
322
324
|
});
|
|
323
325
|
}
|
|
324
326
|
if (clone !== "none") {
|
|
@@ -328,13 +330,15 @@ function createClonedMessageEvent(data, transferOrOptions, clone) {
|
|
|
328
330
|
}
|
|
329
331
|
return new MessageEvent("message", {
|
|
330
332
|
data: ponyfillStructuredClone(data, { lossy: true }),
|
|
331
|
-
origin
|
|
333
|
+
origin,
|
|
334
|
+
ports
|
|
332
335
|
});
|
|
333
336
|
}
|
|
334
337
|
debug("create message event without cloning an object");
|
|
335
338
|
return new MessageEvent("message", {
|
|
336
339
|
data,
|
|
337
|
-
origin
|
|
340
|
+
origin,
|
|
341
|
+
ports
|
|
338
342
|
});
|
|
339
343
|
}
|
|
340
344
|
function createMessageEvent(data, transferOrOptions, clone) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest/web-worker",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.14",
|
|
5
5
|
"description": "Web Worker support for testing in Vitest",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
|
@@ -33,13 +33,12 @@
|
|
|
33
33
|
"dist"
|
|
34
34
|
],
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"vitest": "4.0.
|
|
36
|
+
"vitest": "4.0.14"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"
|
|
39
|
+
"obug": "^2.1.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@types/debug": "^4.1.12",
|
|
43
42
|
"@types/ungap__structured-clone": "^1.2.0",
|
|
44
43
|
"@ungap/structured-clone": "^1.3.0"
|
|
45
44
|
},
|