@vitest/web-worker 4.0.0-beta.8 → 4.0.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/pure.js +20 -22
- package/package.json +4 -4
package/dist/pure.js
CHANGED
|
@@ -459,15 +459,14 @@ function createSharedWorkerConstructor() {
|
|
|
459
459
|
});
|
|
460
460
|
const fileId = getFileIdFromUrl(url);
|
|
461
461
|
this._vw_name = fileId;
|
|
462
|
-
startWebWorkerModuleRunner(context)
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
});
|
|
462
|
+
const runner = startWebWorkerModuleRunner(context);
|
|
463
|
+
runner.mocker.resolveId(fileId).then(({ url, id: resolvedId }) => {
|
|
464
|
+
this._vw_name = name ?? url;
|
|
465
|
+
debug("initialize shared worker %s", this._vw_name);
|
|
466
|
+
return runner.import(url).then(() => {
|
|
467
|
+
runner._invalidateSubTreeById([resolvedId, runner.mocker.getMockPath(resolvedId)]);
|
|
468
|
+
this._vw_workerTarget.dispatchEvent(new MessageEvent("connect", { ports: [this._vw_workerPort] }));
|
|
469
|
+
debug("shared worker %s successfully initialized", this._vw_name);
|
|
471
470
|
});
|
|
472
471
|
}).catch((e) => {
|
|
473
472
|
debug("shared worker %s failed to initialize: %o", this._vw_name, e);
|
|
@@ -555,19 +554,18 @@ function createWorkerConstructor(options) {
|
|
|
555
554
|
});
|
|
556
555
|
const fileId = getFileIdFromUrl(url);
|
|
557
556
|
this._vw_name = fileId;
|
|
558
|
-
startWebWorkerModuleRunner(context)
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
});
|
|
557
|
+
const runner = startWebWorkerModuleRunner(context);
|
|
558
|
+
runner.mocker.resolveId(fileId).then(({ url, id: resolvedId }) => {
|
|
559
|
+
this._vw_name = options?.name ?? url;
|
|
560
|
+
debug("initialize worker %s", this._vw_name);
|
|
561
|
+
return runner.import(url).then(() => {
|
|
562
|
+
runner._invalidateSubTreeById([resolvedId, runner.mocker.getMockPath(resolvedId)]);
|
|
563
|
+
const q = this._vw_messageQueue;
|
|
564
|
+
this._vw_messageQueue = null;
|
|
565
|
+
if (q) {
|
|
566
|
+
q.forEach(([data, transfer]) => this.postMessage(data, transfer), this);
|
|
567
|
+
}
|
|
568
|
+
debug("worker %s successfully initialized", this._vw_name);
|
|
571
569
|
});
|
|
572
570
|
}).catch((e) => {
|
|
573
571
|
debug("worker %s failed to initialize: %o", this._vw_name, e);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest/web-worker",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.0
|
|
4
|
+
"version": "4.0.0",
|
|
5
5
|
"description": "Web Worker support for testing in Vitest",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"dist"
|
|
34
34
|
],
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"vitest": "4.0.0
|
|
36
|
+
"vitest": "4.0.0"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"debug": "^4.4.
|
|
39
|
+
"debug": "^4.4.3"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/debug": "^4.1.12",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@ungap/structured-clone": "^1.3.0"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
|
-
"build": "
|
|
47
|
+
"build": "premove dist && rollup -c",
|
|
48
48
|
"dev": "rollup -c --watch --watch.include 'src/**'",
|
|
49
49
|
"typecheck": "tsc --noEmit"
|
|
50
50
|
}
|