@cloudflare/vitest-pool-workers 0.12.21 → 0.13.1
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/codemods/vitest-v3-to-v4.mjs +45 -0
- package/dist/codemods/vitest-v3-to-v4.mjs.map +1 -0
- package/dist/pool/index.d.mts +133 -0
- package/dist/pool/index.mjs +2781 -7942
- package/dist/pool/index.mjs.map +1 -6
- package/dist/worker/index.mjs +749 -886
- package/dist/worker/index.mjs.map +1 -6
- package/dist/worker/lib/cloudflare/snapshot.mjs +39 -0
- package/dist/worker/lib/cloudflare/snapshot.mjs.map +1 -0
- package/dist/worker/lib/cloudflare/test-internal.mjs +788 -1276
- package/dist/worker/lib/cloudflare/test-internal.mjs.map +1 -6
- package/dist/worker/lib/cloudflare/test.mjs +3 -36
- package/dist/worker/node/console.mjs +95 -116
- package/dist/worker/node/console.mjs.map +1 -6
- package/dist/worker/node/vm.mjs +10 -11
- package/dist/worker/node/vm.mjs.map +1 -6
- package/package.json +24 -20
- package/types/cloudflare-test.d.ts +5 -30
- package/dist/config/d1.d.ts +0 -7
- package/dist/config/index.cjs +0 -230
- package/dist/config/index.cjs.map +0 -6
- package/dist/config/index.d.ts +0 -27
- package/dist/config/pages.d.ts +0 -2
- package/dist/pool/config.d.ts +0 -112
- package/dist/pool/helpers.d.ts +0 -5
- package/dist/shared/builtin-modules.d.ts +0 -1
- package/dist/shared/d1.d.ts +0 -4
- package/dist/worker/lib/cloudflare/empty-internal.cjs +0 -27
- package/dist/worker/lib/cloudflare/empty-internal.cjs.map +0 -6
- package/dist/worker/lib/cloudflare/mock-agent.cjs +0 -3433
- package/dist/worker/lib/cloudflare/mock-agent.cjs.map +0 -6
- package/dist/worker/lib/cloudflare/test-runner.mjs +0 -246
- package/dist/worker/lib/cloudflare/test-runner.mjs.map +0 -6
- package/dist/worker/lib/cloudflare/test.mjs.map +0 -6
- package/dist/worker/lib/debug.mjs +0 -9
- package/dist/worker/lib/debug.mjs.map +0 -6
- package/dist/worker/lib/mlly.mjs +0 -48
- package/dist/worker/lib/mlly.mjs.map +0 -6
- package/dist/worker/lib/tinypool.mjs +0 -6
- package/dist/worker/lib/tinypool.mjs.map +0 -6
package/dist/worker/index.mjs
CHANGED
|
@@ -1,956 +1,819 @@
|
|
|
1
|
-
|
|
2
|
-
import assert3 from "node:assert";
|
|
3
|
-
import { Buffer as Buffer3 } from "node:buffer";
|
|
4
|
-
import events from "node:events";
|
|
5
|
-
import process from "node:process";
|
|
1
|
+
import assert from "node:assert";
|
|
6
2
|
import * as vm from "node:vm";
|
|
7
3
|
import defines from "__VITEST_POOL_WORKERS_DEFINES";
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
runInRunnerObject,
|
|
14
|
-
setEnv
|
|
15
|
-
} from "cloudflare:test-internal";
|
|
4
|
+
import { createWorkerEntrypointWrapper, maybeHandleRunRequest, registerHandlerAndGlobalWaitUntil, runInRunnerObject } from "cloudflare:test-internal";
|
|
5
|
+
import { DurableObject } from "cloudflare:workers";
|
|
6
|
+
import { Buffer } from "node:buffer";
|
|
7
|
+
|
|
8
|
+
export * from "__VITEST_POOL_WORKERS_USER_OBJECT"
|
|
16
9
|
|
|
17
|
-
|
|
10
|
+
//#region ../../node_modules/.pnpm/devalue@5.6.3/node_modules/devalue/src/utils.js
|
|
18
11
|
var DevalueError = class extends Error {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
12
|
+
/**
|
|
13
|
+
* @param {string} message
|
|
14
|
+
* @param {string[]} keys
|
|
15
|
+
* @param {any} [value] - The value that failed to be serialized
|
|
16
|
+
* @param {any} [root] - The root value being serialized
|
|
17
|
+
*/
|
|
18
|
+
constructor(message, keys, value, root) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.name = "DevalueError";
|
|
21
|
+
this.path = keys.join("");
|
|
22
|
+
this.value = value;
|
|
23
|
+
this.root = root;
|
|
24
|
+
}
|
|
32
25
|
};
|
|
26
|
+
/** @param {any} thing */
|
|
33
27
|
function is_primitive(thing) {
|
|
34
|
-
|
|
28
|
+
return Object(thing) !== thing;
|
|
35
29
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
).sort().join("\0");
|
|
30
|
+
const object_proto_names = /* @__PURE__ */ Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
|
|
31
|
+
/** @param {any} thing */
|
|
39
32
|
function is_plain_object(thing) {
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
const proto = Object.getPrototypeOf(thing);
|
|
34
|
+
return proto === Object.prototype || proto === null || Object.getPrototypeOf(proto) === null || Object.getOwnPropertyNames(proto).sort().join("\0") === object_proto_names;
|
|
42
35
|
}
|
|
36
|
+
/** @param {any} thing */
|
|
43
37
|
function get_type(thing) {
|
|
44
|
-
|
|
38
|
+
return Object.prototype.toString.call(thing).slice(8, -1);
|
|
45
39
|
}
|
|
40
|
+
/** @param {string} char */
|
|
46
41
|
function get_escaped_char(char) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
case "\b":
|
|
61
|
-
return "\\b";
|
|
62
|
-
case "\f":
|
|
63
|
-
return "\\f";
|
|
64
|
-
case "\u2028":
|
|
65
|
-
return "\\u2028";
|
|
66
|
-
case "\u2029":
|
|
67
|
-
return "\\u2029";
|
|
68
|
-
default:
|
|
69
|
-
return char < " " ? `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}` : "";
|
|
70
|
-
}
|
|
42
|
+
switch (char) {
|
|
43
|
+
case "\"": return "\\\"";
|
|
44
|
+
case "<": return "\\u003C";
|
|
45
|
+
case "\\": return "\\\\";
|
|
46
|
+
case "\n": return "\\n";
|
|
47
|
+
case "\r": return "\\r";
|
|
48
|
+
case " ": return "\\t";
|
|
49
|
+
case "\b": return "\\b";
|
|
50
|
+
case "\f": return "\\f";
|
|
51
|
+
case "\u2028": return "\\u2028";
|
|
52
|
+
case "\u2029": return "\\u2029";
|
|
53
|
+
default: return char < " " ? `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}` : "";
|
|
54
|
+
}
|
|
71
55
|
}
|
|
56
|
+
/** @param {string} str */
|
|
72
57
|
function stringify_string(str) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
58
|
+
let result = "";
|
|
59
|
+
let last_pos = 0;
|
|
60
|
+
const len = str.length;
|
|
61
|
+
for (let i = 0; i < len; i += 1) {
|
|
62
|
+
const char = str[i];
|
|
63
|
+
const replacement = get_escaped_char(char);
|
|
64
|
+
if (replacement) {
|
|
65
|
+
result += str.slice(last_pos, i) + replacement;
|
|
66
|
+
last_pos = i + 1;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return `"${last_pos === 0 ? str : result + str.slice(last_pos)}"`;
|
|
85
70
|
}
|
|
71
|
+
/** @param {Record<string | symbol, any>} object */
|
|
86
72
|
function enumerable_symbols(object) {
|
|
87
|
-
|
|
88
|
-
(symbol) => Object.getOwnPropertyDescriptor(object, symbol).enumerable
|
|
89
|
-
);
|
|
73
|
+
return Object.getOwnPropertySymbols(object).filter((symbol) => Object.getOwnPropertyDescriptor(object, symbol).enumerable);
|
|
90
74
|
}
|
|
91
|
-
|
|
75
|
+
const is_identifier = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/;
|
|
76
|
+
/** @param {string} key */
|
|
92
77
|
function stringify_key(key) {
|
|
93
|
-
|
|
78
|
+
return is_identifier.test(key) ? "." + key : "[" + JSON.stringify(key) + "]";
|
|
94
79
|
}
|
|
80
|
+
/** @param {string} s */
|
|
95
81
|
function is_valid_array_index(s) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
82
|
+
if (s.length === 0) return false;
|
|
83
|
+
if (s.length > 1 && s.charCodeAt(0) === 48) return false;
|
|
84
|
+
for (let i = 0; i < s.length; i++) {
|
|
85
|
+
const c = s.charCodeAt(i);
|
|
86
|
+
if (c < 48 || c > 57) return false;
|
|
87
|
+
}
|
|
88
|
+
const n = +s;
|
|
89
|
+
if (n >= 2 ** 32 - 1) return false;
|
|
90
|
+
if (n < 0) return false;
|
|
91
|
+
return true;
|
|
106
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Finds the populated indices of an array.
|
|
95
|
+
* @param {unknown[]} array
|
|
96
|
+
*/
|
|
107
97
|
function valid_array_indices(array) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
keys.length = i + 1;
|
|
115
|
-
return keys;
|
|
98
|
+
const keys = Object.keys(array);
|
|
99
|
+
for (var i = keys.length - 1; i >= 0; i--) if (is_valid_array_index(keys[i])) break;
|
|
100
|
+
keys.length = i + 1;
|
|
101
|
+
return keys;
|
|
116
102
|
}
|
|
117
103
|
|
|
118
|
-
|
|
104
|
+
//#endregion
|
|
105
|
+
//#region ../../node_modules/.pnpm/devalue@5.6.3/node_modules/devalue/src/base64.js
|
|
106
|
+
/**
|
|
107
|
+
* Base64 Encodes an arraybuffer
|
|
108
|
+
* @param {ArrayBuffer} arraybuffer
|
|
109
|
+
* @returns {string}
|
|
110
|
+
*/
|
|
119
111
|
function encode64(arraybuffer) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
return binaryToAscii(binaryString);
|
|
112
|
+
const dv = new DataView(arraybuffer);
|
|
113
|
+
let binaryString = "";
|
|
114
|
+
for (let i = 0; i < arraybuffer.byteLength; i++) binaryString += String.fromCharCode(dv.getUint8(i));
|
|
115
|
+
return binaryToAscii(binaryString);
|
|
126
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Decodes a base64 string into an arraybuffer
|
|
119
|
+
* @param {string} string
|
|
120
|
+
* @returns {ArrayBuffer}
|
|
121
|
+
*/
|
|
127
122
|
function decode64(string) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
return arraybuffer;
|
|
123
|
+
const binaryString = asciiToBinary(string);
|
|
124
|
+
const arraybuffer = new ArrayBuffer(binaryString.length);
|
|
125
|
+
const dv = new DataView(arraybuffer);
|
|
126
|
+
for (let i = 0; i < arraybuffer.byteLength; i++) dv.setUint8(i, binaryString.charCodeAt(i));
|
|
127
|
+
return arraybuffer;
|
|
135
128
|
}
|
|
136
|
-
|
|
129
|
+
const KEY_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
130
|
+
/**
|
|
131
|
+
* Substitute for atob since it's deprecated in node.
|
|
132
|
+
* Does not do any input validation.
|
|
133
|
+
*
|
|
134
|
+
* @see https://github.com/jsdom/abab/blob/master/lib/atob.js
|
|
135
|
+
*
|
|
136
|
+
* @param {string} data
|
|
137
|
+
* @returns {string}
|
|
138
|
+
*/
|
|
137
139
|
function asciiToBinary(data) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
return output;
|
|
140
|
+
if (data.length % 4 === 0) data = data.replace(/==?$/, "");
|
|
141
|
+
let output = "";
|
|
142
|
+
let buffer = 0;
|
|
143
|
+
let accumulatedBits = 0;
|
|
144
|
+
for (let i = 0; i < data.length; i++) {
|
|
145
|
+
buffer <<= 6;
|
|
146
|
+
buffer |= KEY_STRING.indexOf(data[i]);
|
|
147
|
+
accumulatedBits += 6;
|
|
148
|
+
if (accumulatedBits === 24) {
|
|
149
|
+
output += String.fromCharCode((buffer & 16711680) >> 16);
|
|
150
|
+
output += String.fromCharCode((buffer & 65280) >> 8);
|
|
151
|
+
output += String.fromCharCode(buffer & 255);
|
|
152
|
+
buffer = accumulatedBits = 0;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (accumulatedBits === 12) {
|
|
156
|
+
buffer >>= 4;
|
|
157
|
+
output += String.fromCharCode(buffer);
|
|
158
|
+
} else if (accumulatedBits === 18) {
|
|
159
|
+
buffer >>= 2;
|
|
160
|
+
output += String.fromCharCode((buffer & 65280) >> 8);
|
|
161
|
+
output += String.fromCharCode(buffer & 255);
|
|
162
|
+
}
|
|
163
|
+
return output;
|
|
164
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* Substitute for btoa since it's deprecated in node.
|
|
167
|
+
* Does not do any input validation.
|
|
168
|
+
*
|
|
169
|
+
* @see https://github.com/jsdom/abab/blob/master/lib/btoa.js
|
|
170
|
+
*
|
|
171
|
+
* @param {string} str
|
|
172
|
+
* @returns {string}
|
|
173
|
+
*/
|
|
165
174
|
function binaryToAscii(str) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
175
|
+
let out = "";
|
|
176
|
+
for (let i = 0; i < str.length; i += 3) {
|
|
177
|
+
/** @type {[number, number, number, number]} */
|
|
178
|
+
const groupsOfSix = [
|
|
179
|
+
void 0,
|
|
180
|
+
void 0,
|
|
181
|
+
void 0,
|
|
182
|
+
void 0
|
|
183
|
+
];
|
|
184
|
+
groupsOfSix[0] = str.charCodeAt(i) >> 2;
|
|
185
|
+
groupsOfSix[1] = (str.charCodeAt(i) & 3) << 4;
|
|
186
|
+
if (str.length > i + 1) {
|
|
187
|
+
groupsOfSix[1] |= str.charCodeAt(i + 1) >> 4;
|
|
188
|
+
groupsOfSix[2] = (str.charCodeAt(i + 1) & 15) << 2;
|
|
189
|
+
}
|
|
190
|
+
if (str.length > i + 2) {
|
|
191
|
+
groupsOfSix[2] |= str.charCodeAt(i + 2) >> 6;
|
|
192
|
+
groupsOfSix[3] = str.charCodeAt(i + 2) & 63;
|
|
193
|
+
}
|
|
194
|
+
for (let j = 0; j < groupsOfSix.length; j++) if (typeof groupsOfSix[j] === "undefined") out += "=";
|
|
195
|
+
else out += KEY_STRING[groupsOfSix[j]];
|
|
196
|
+
}
|
|
197
|
+
return out;
|
|
188
198
|
}
|
|
189
199
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
200
|
+
//#endregion
|
|
201
|
+
//#region ../../node_modules/.pnpm/devalue@5.6.3/node_modules/devalue/src/constants.js
|
|
202
|
+
const UNDEFINED = -1;
|
|
203
|
+
const HOLE = -2;
|
|
204
|
+
const NAN = -3;
|
|
205
|
+
const POSITIVE_INFINITY = -4;
|
|
206
|
+
const NEGATIVE_INFINITY = -5;
|
|
207
|
+
const NEGATIVE_ZERO = -6;
|
|
208
|
+
const SPARSE = -7;
|
|
198
209
|
|
|
199
|
-
|
|
210
|
+
//#endregion
|
|
211
|
+
//#region ../../node_modules/.pnpm/devalue@5.6.3/node_modules/devalue/src/parse.js
|
|
212
|
+
/**
|
|
213
|
+
* Revive a value serialized with `devalue.stringify`
|
|
214
|
+
* @param {string} serialized
|
|
215
|
+
* @param {Record<string, (value: any) => any>} [revivers]
|
|
216
|
+
*/
|
|
200
217
|
function parse(serialized, revivers) {
|
|
201
|
-
|
|
218
|
+
return unflatten(JSON.parse(serialized), revivers);
|
|
202
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* Revive a value flattened with `devalue.stringify`
|
|
222
|
+
* @param {number | any[]} parsed
|
|
223
|
+
* @param {Record<string, (value: any) => any>} [revivers]
|
|
224
|
+
*/
|
|
203
225
|
function unflatten(parsed, revivers) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
const array = new Array(value.length);
|
|
343
|
-
hydrated[index] = array;
|
|
344
|
-
for (let i = 0; i < value.length; i += 1) {
|
|
345
|
-
const n = value[i];
|
|
346
|
-
if (n === HOLE) continue;
|
|
347
|
-
array[i] = hydrate(n);
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
} else {
|
|
351
|
-
const object = {};
|
|
352
|
-
hydrated[index] = object;
|
|
353
|
-
for (const key of Object.keys(value)) {
|
|
354
|
-
if (key === "__proto__") {
|
|
355
|
-
throw new Error("Cannot parse an object with a `__proto__` property");
|
|
356
|
-
}
|
|
357
|
-
const n = value[key];
|
|
358
|
-
object[key] = hydrate(n);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
return hydrated[index];
|
|
362
|
-
}
|
|
363
|
-
return hydrate(0);
|
|
226
|
+
if (typeof parsed === "number") return hydrate(parsed, true);
|
|
227
|
+
if (!Array.isArray(parsed) || parsed.length === 0) throw new Error("Invalid input");
|
|
228
|
+
const values = parsed;
|
|
229
|
+
const hydrated = Array(values.length);
|
|
230
|
+
/**
|
|
231
|
+
* A set of values currently being hydrated with custom revivers,
|
|
232
|
+
* used to detect invalid cyclical dependencies
|
|
233
|
+
* @type {Set<number> | null}
|
|
234
|
+
*/
|
|
235
|
+
let hydrating = null;
|
|
236
|
+
/**
|
|
237
|
+
* @param {number} index
|
|
238
|
+
* @returns {any}
|
|
239
|
+
*/
|
|
240
|
+
function hydrate(index, standalone = false) {
|
|
241
|
+
if (index === UNDEFINED) return void 0;
|
|
242
|
+
if (index === NAN) return NaN;
|
|
243
|
+
if (index === POSITIVE_INFINITY) return Infinity;
|
|
244
|
+
if (index === NEGATIVE_INFINITY) return -Infinity;
|
|
245
|
+
if (index === NEGATIVE_ZERO) return -0;
|
|
246
|
+
if (standalone || typeof index !== "number") throw new Error(`Invalid input`);
|
|
247
|
+
if (index in hydrated) return hydrated[index];
|
|
248
|
+
const value = values[index];
|
|
249
|
+
if (!value || typeof value !== "object") hydrated[index] = value;
|
|
250
|
+
else if (Array.isArray(value)) if (typeof value[0] === "string") {
|
|
251
|
+
const type = value[0];
|
|
252
|
+
const reviver = revivers && Object.hasOwn(revivers, type) ? revivers[type] : void 0;
|
|
253
|
+
if (reviver) {
|
|
254
|
+
let i = value[1];
|
|
255
|
+
if (typeof i !== "number") i = values.push(value[1]) - 1;
|
|
256
|
+
hydrating ??= /* @__PURE__ */ new Set();
|
|
257
|
+
if (hydrating.has(i)) throw new Error("Invalid circular reference");
|
|
258
|
+
hydrating.add(i);
|
|
259
|
+
hydrated[index] = reviver(hydrate(i));
|
|
260
|
+
hydrating.delete(i);
|
|
261
|
+
return hydrated[index];
|
|
262
|
+
}
|
|
263
|
+
switch (type) {
|
|
264
|
+
case "Date":
|
|
265
|
+
hydrated[index] = new Date(value[1]);
|
|
266
|
+
break;
|
|
267
|
+
case "Set":
|
|
268
|
+
const set = /* @__PURE__ */ new Set();
|
|
269
|
+
hydrated[index] = set;
|
|
270
|
+
for (let i = 1; i < value.length; i += 1) set.add(hydrate(value[i]));
|
|
271
|
+
break;
|
|
272
|
+
case "Map":
|
|
273
|
+
const map = /* @__PURE__ */ new Map();
|
|
274
|
+
hydrated[index] = map;
|
|
275
|
+
for (let i = 1; i < value.length; i += 2) map.set(hydrate(value[i]), hydrate(value[i + 1]));
|
|
276
|
+
break;
|
|
277
|
+
case "RegExp":
|
|
278
|
+
hydrated[index] = new RegExp(value[1], value[2]);
|
|
279
|
+
break;
|
|
280
|
+
case "Object":
|
|
281
|
+
hydrated[index] = Object(value[1]);
|
|
282
|
+
break;
|
|
283
|
+
case "BigInt":
|
|
284
|
+
hydrated[index] = BigInt(value[1]);
|
|
285
|
+
break;
|
|
286
|
+
case "null":
|
|
287
|
+
const obj = Object.create(null);
|
|
288
|
+
hydrated[index] = obj;
|
|
289
|
+
for (let i = 1; i < value.length; i += 2) obj[value[i]] = hydrate(value[i + 1]);
|
|
290
|
+
break;
|
|
291
|
+
case "Int8Array":
|
|
292
|
+
case "Uint8Array":
|
|
293
|
+
case "Uint8ClampedArray":
|
|
294
|
+
case "Int16Array":
|
|
295
|
+
case "Uint16Array":
|
|
296
|
+
case "Int32Array":
|
|
297
|
+
case "Uint32Array":
|
|
298
|
+
case "Float32Array":
|
|
299
|
+
case "Float64Array":
|
|
300
|
+
case "BigInt64Array":
|
|
301
|
+
case "BigUint64Array": {
|
|
302
|
+
if (values[value[1]][0] !== "ArrayBuffer") throw new Error("Invalid data");
|
|
303
|
+
const TypedArrayConstructor = globalThis[type];
|
|
304
|
+
const typedArray = new TypedArrayConstructor(hydrate(value[1]));
|
|
305
|
+
hydrated[index] = value[2] !== void 0 ? typedArray.subarray(value[2], value[3]) : typedArray;
|
|
306
|
+
break;
|
|
307
|
+
}
|
|
308
|
+
case "ArrayBuffer": {
|
|
309
|
+
const base64 = value[1];
|
|
310
|
+
if (typeof base64 !== "string") throw new Error("Invalid ArrayBuffer encoding");
|
|
311
|
+
hydrated[index] = decode64(base64);
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
case "Temporal.Duration":
|
|
315
|
+
case "Temporal.Instant":
|
|
316
|
+
case "Temporal.PlainDate":
|
|
317
|
+
case "Temporal.PlainTime":
|
|
318
|
+
case "Temporal.PlainDateTime":
|
|
319
|
+
case "Temporal.PlainMonthDay":
|
|
320
|
+
case "Temporal.PlainYearMonth":
|
|
321
|
+
case "Temporal.ZonedDateTime": {
|
|
322
|
+
const temporalName = type.slice(9);
|
|
323
|
+
hydrated[index] = Temporal[temporalName].from(value[1]);
|
|
324
|
+
break;
|
|
325
|
+
}
|
|
326
|
+
case "URL":
|
|
327
|
+
hydrated[index] = new URL(value[1]);
|
|
328
|
+
break;
|
|
329
|
+
case "URLSearchParams":
|
|
330
|
+
hydrated[index] = new URLSearchParams(value[1]);
|
|
331
|
+
break;
|
|
332
|
+
default: throw new Error(`Unknown type ${type}`);
|
|
333
|
+
}
|
|
334
|
+
} else if (value[0] === SPARSE) {
|
|
335
|
+
const len = value[1];
|
|
336
|
+
const array = new Array(len);
|
|
337
|
+
hydrated[index] = array;
|
|
338
|
+
for (let i = 2; i < value.length; i += 2) {
|
|
339
|
+
const idx = value[i];
|
|
340
|
+
array[idx] = hydrate(value[i + 1]);
|
|
341
|
+
}
|
|
342
|
+
} else {
|
|
343
|
+
const array = new Array(value.length);
|
|
344
|
+
hydrated[index] = array;
|
|
345
|
+
for (let i = 0; i < value.length; i += 1) {
|
|
346
|
+
const n = value[i];
|
|
347
|
+
if (n === HOLE) continue;
|
|
348
|
+
array[i] = hydrate(n);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
else {
|
|
352
|
+
/** @type {Record<string, any>} */
|
|
353
|
+
const object = {};
|
|
354
|
+
hydrated[index] = object;
|
|
355
|
+
for (const key of Object.keys(value)) {
|
|
356
|
+
if (key === "__proto__") throw new Error("Cannot parse an object with a `__proto__` property");
|
|
357
|
+
const n = value[key];
|
|
358
|
+
object[key] = hydrate(n);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
return hydrated[index];
|
|
362
|
+
}
|
|
363
|
+
return hydrate(0);
|
|
364
364
|
}
|
|
365
365
|
|
|
366
|
-
|
|
366
|
+
//#endregion
|
|
367
|
+
//#region ../../node_modules/.pnpm/devalue@5.6.3/node_modules/devalue/src/stringify.js
|
|
368
|
+
/**
|
|
369
|
+
* Turn a value into a JSON string that can be parsed with `devalue.parse`
|
|
370
|
+
* @param {any} value
|
|
371
|
+
* @param {Record<string, (value: any) => any>} [reducers]
|
|
372
|
+
*/
|
|
367
373
|
function stringify(value, reducers) {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
throw new DevalueError(
|
|
541
|
-
`Cannot stringify objects with __proto__ keys`,
|
|
542
|
-
keys,
|
|
543
|
-
thing,
|
|
544
|
-
value
|
|
545
|
-
);
|
|
546
|
-
}
|
|
547
|
-
keys.push(stringify_key(key));
|
|
548
|
-
str += `,${stringify_string(key)},${flatten(thing[key])}`;
|
|
549
|
-
keys.pop();
|
|
550
|
-
}
|
|
551
|
-
str += "]";
|
|
552
|
-
} else {
|
|
553
|
-
str = "{";
|
|
554
|
-
let started = false;
|
|
555
|
-
for (const key of Object.keys(thing)) {
|
|
556
|
-
if (key === "__proto__") {
|
|
557
|
-
throw new DevalueError(
|
|
558
|
-
`Cannot stringify objects with __proto__ keys`,
|
|
559
|
-
keys,
|
|
560
|
-
thing,
|
|
561
|
-
value
|
|
562
|
-
);
|
|
563
|
-
}
|
|
564
|
-
if (started) str += ",";
|
|
565
|
-
started = true;
|
|
566
|
-
keys.push(stringify_key(key));
|
|
567
|
-
str += `${stringify_string(key)}:${flatten(thing[key])}`;
|
|
568
|
-
keys.pop();
|
|
569
|
-
}
|
|
570
|
-
str += "}";
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
stringified[index2] = str;
|
|
575
|
-
return index2;
|
|
576
|
-
}
|
|
577
|
-
const index = flatten(value);
|
|
578
|
-
if (index < 0) return `${index}`;
|
|
579
|
-
return `[${stringified.join(",")}]`;
|
|
374
|
+
/** @type {any[]} */
|
|
375
|
+
const stringified = [];
|
|
376
|
+
/** @type {Map<any, number>} */
|
|
377
|
+
const indexes = /* @__PURE__ */ new Map();
|
|
378
|
+
/** @type {Array<{ key: string, fn: (value: any) => any }>} */
|
|
379
|
+
const custom = [];
|
|
380
|
+
if (reducers) for (const key of Object.getOwnPropertyNames(reducers)) custom.push({
|
|
381
|
+
key,
|
|
382
|
+
fn: reducers[key]
|
|
383
|
+
});
|
|
384
|
+
/** @type {string[]} */
|
|
385
|
+
const keys = [];
|
|
386
|
+
let p = 0;
|
|
387
|
+
/** @param {any} thing */
|
|
388
|
+
function flatten(thing) {
|
|
389
|
+
if (thing === void 0) return UNDEFINED;
|
|
390
|
+
if (Number.isNaN(thing)) return NAN;
|
|
391
|
+
if (thing === Infinity) return POSITIVE_INFINITY;
|
|
392
|
+
if (thing === -Infinity) return NEGATIVE_INFINITY;
|
|
393
|
+
if (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO;
|
|
394
|
+
if (indexes.has(thing)) return indexes.get(thing);
|
|
395
|
+
const index$1 = p++;
|
|
396
|
+
indexes.set(thing, index$1);
|
|
397
|
+
for (const { key, fn } of custom) {
|
|
398
|
+
const value$1 = fn(thing);
|
|
399
|
+
if (value$1) {
|
|
400
|
+
stringified[index$1] = `["${key}",${flatten(value$1)}]`;
|
|
401
|
+
return index$1;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
if (typeof thing === "function") throw new DevalueError(`Cannot stringify a function`, keys, thing, value);
|
|
405
|
+
let str = "";
|
|
406
|
+
if (is_primitive(thing)) str = stringify_primitive(thing);
|
|
407
|
+
else {
|
|
408
|
+
const type = get_type(thing);
|
|
409
|
+
switch (type) {
|
|
410
|
+
case "Number":
|
|
411
|
+
case "String":
|
|
412
|
+
case "Boolean":
|
|
413
|
+
str = `["Object",${stringify_primitive(thing)}]`;
|
|
414
|
+
break;
|
|
415
|
+
case "BigInt":
|
|
416
|
+
str = `["BigInt",${thing}]`;
|
|
417
|
+
break;
|
|
418
|
+
case "Date":
|
|
419
|
+
str = `["Date","${!isNaN(thing.getDate()) ? thing.toISOString() : ""}"]`;
|
|
420
|
+
break;
|
|
421
|
+
case "URL":
|
|
422
|
+
str = `["URL",${stringify_string(thing.toString())}]`;
|
|
423
|
+
break;
|
|
424
|
+
case "URLSearchParams":
|
|
425
|
+
str = `["URLSearchParams",${stringify_string(thing.toString())}]`;
|
|
426
|
+
break;
|
|
427
|
+
case "RegExp":
|
|
428
|
+
const { source, flags } = thing;
|
|
429
|
+
str = flags ? `["RegExp",${stringify_string(source)},"${flags}"]` : `["RegExp",${stringify_string(source)}]`;
|
|
430
|
+
break;
|
|
431
|
+
case "Array": {
|
|
432
|
+
let mostly_dense = false;
|
|
433
|
+
str = "[";
|
|
434
|
+
for (let i = 0; i < thing.length; i += 1) {
|
|
435
|
+
if (i > 0) str += ",";
|
|
436
|
+
if (Object.hasOwn(thing, i)) {
|
|
437
|
+
keys.push(`[${i}]`);
|
|
438
|
+
str += flatten(thing[i]);
|
|
439
|
+
keys.pop();
|
|
440
|
+
} else if (mostly_dense) str += HOLE;
|
|
441
|
+
else {
|
|
442
|
+
const populated_keys = valid_array_indices(thing);
|
|
443
|
+
const population = populated_keys.length;
|
|
444
|
+
const d = String(thing.length).length;
|
|
445
|
+
if ((thing.length - population) * 3 > 4 + d + population * (d + 1)) {
|
|
446
|
+
str = "[" + SPARSE + "," + thing.length;
|
|
447
|
+
for (let j = 0; j < populated_keys.length; j++) {
|
|
448
|
+
const key = populated_keys[j];
|
|
449
|
+
keys.push(`[${key}]`);
|
|
450
|
+
str += "," + key + "," + flatten(thing[key]);
|
|
451
|
+
keys.pop();
|
|
452
|
+
}
|
|
453
|
+
break;
|
|
454
|
+
} else {
|
|
455
|
+
mostly_dense = true;
|
|
456
|
+
str += HOLE;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
str += "]";
|
|
461
|
+
break;
|
|
462
|
+
}
|
|
463
|
+
case "Set":
|
|
464
|
+
str = "[\"Set\"";
|
|
465
|
+
for (const value$1 of thing) str += `,${flatten(value$1)}`;
|
|
466
|
+
str += "]";
|
|
467
|
+
break;
|
|
468
|
+
case "Map":
|
|
469
|
+
str = "[\"Map\"";
|
|
470
|
+
for (const [key, value$1] of thing) {
|
|
471
|
+
keys.push(`.get(${is_primitive(key) ? stringify_primitive(key) : "..."})`);
|
|
472
|
+
str += `,${flatten(key)},${flatten(value$1)}`;
|
|
473
|
+
keys.pop();
|
|
474
|
+
}
|
|
475
|
+
str += "]";
|
|
476
|
+
break;
|
|
477
|
+
case "Int8Array":
|
|
478
|
+
case "Uint8Array":
|
|
479
|
+
case "Uint8ClampedArray":
|
|
480
|
+
case "Int16Array":
|
|
481
|
+
case "Uint16Array":
|
|
482
|
+
case "Int32Array":
|
|
483
|
+
case "Uint32Array":
|
|
484
|
+
case "Float32Array":
|
|
485
|
+
case "Float64Array":
|
|
486
|
+
case "BigInt64Array":
|
|
487
|
+
case "BigUint64Array": {
|
|
488
|
+
/** @type {import("./types.js").TypedArray} */
|
|
489
|
+
const typedArray = thing;
|
|
490
|
+
str = "[\"" + type + "\"," + flatten(typedArray.buffer);
|
|
491
|
+
const a = thing.byteOffset;
|
|
492
|
+
const b = a + thing.byteLength;
|
|
493
|
+
if (a > 0 || b !== typedArray.buffer.byteLength) {
|
|
494
|
+
const m = +/(\d+)/.exec(type)[1] / 8;
|
|
495
|
+
str += `,${a / m},${b / m}`;
|
|
496
|
+
}
|
|
497
|
+
str += "]";
|
|
498
|
+
break;
|
|
499
|
+
}
|
|
500
|
+
case "ArrayBuffer":
|
|
501
|
+
str = `["ArrayBuffer","${encode64(thing)}"]`;
|
|
502
|
+
break;
|
|
503
|
+
case "Temporal.Duration":
|
|
504
|
+
case "Temporal.Instant":
|
|
505
|
+
case "Temporal.PlainDate":
|
|
506
|
+
case "Temporal.PlainTime":
|
|
507
|
+
case "Temporal.PlainDateTime":
|
|
508
|
+
case "Temporal.PlainMonthDay":
|
|
509
|
+
case "Temporal.PlainYearMonth":
|
|
510
|
+
case "Temporal.ZonedDateTime":
|
|
511
|
+
str = `["${type}",${stringify_string(thing.toString())}]`;
|
|
512
|
+
break;
|
|
513
|
+
default:
|
|
514
|
+
if (!is_plain_object(thing)) throw new DevalueError(`Cannot stringify arbitrary non-POJOs`, keys, thing, value);
|
|
515
|
+
if (enumerable_symbols(thing).length > 0) throw new DevalueError(`Cannot stringify POJOs with symbolic keys`, keys, thing, value);
|
|
516
|
+
if (Object.getPrototypeOf(thing) === null) {
|
|
517
|
+
str = "[\"null\"";
|
|
518
|
+
for (const key of Object.keys(thing)) {
|
|
519
|
+
if (key === "__proto__") throw new DevalueError(`Cannot stringify objects with __proto__ keys`, keys, thing, value);
|
|
520
|
+
keys.push(stringify_key(key));
|
|
521
|
+
str += `,${stringify_string(key)},${flatten(thing[key])}`;
|
|
522
|
+
keys.pop();
|
|
523
|
+
}
|
|
524
|
+
str += "]";
|
|
525
|
+
} else {
|
|
526
|
+
str = "{";
|
|
527
|
+
let started = false;
|
|
528
|
+
for (const key of Object.keys(thing)) {
|
|
529
|
+
if (key === "__proto__") throw new DevalueError(`Cannot stringify objects with __proto__ keys`, keys, thing, value);
|
|
530
|
+
if (started) str += ",";
|
|
531
|
+
started = true;
|
|
532
|
+
keys.push(stringify_key(key));
|
|
533
|
+
str += `${stringify_string(key)}:${flatten(thing[key])}`;
|
|
534
|
+
keys.pop();
|
|
535
|
+
}
|
|
536
|
+
str += "}";
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
stringified[index$1] = str;
|
|
541
|
+
return index$1;
|
|
542
|
+
}
|
|
543
|
+
const index = flatten(value);
|
|
544
|
+
if (index < 0) return `${index}`;
|
|
545
|
+
return `[${stringified.join(",")}]`;
|
|
580
546
|
}
|
|
547
|
+
/**
|
|
548
|
+
* @param {any} thing
|
|
549
|
+
* @returns {string}
|
|
550
|
+
*/
|
|
581
551
|
function stringify_primitive(thing) {
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
552
|
+
const type = typeof thing;
|
|
553
|
+
if (type === "string") return stringify_string(thing);
|
|
554
|
+
if (thing instanceof String) return stringify_string(thing.toString());
|
|
555
|
+
if (thing === void 0) return UNDEFINED.toString();
|
|
556
|
+
if (thing === 0 && 1 / thing < 0) return NEGATIVE_ZERO.toString();
|
|
557
|
+
if (type === "bigint") return `["BigInt","${thing}"]`;
|
|
558
|
+
return String(thing);
|
|
589
559
|
}
|
|
590
560
|
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
BigUint64Array
|
|
561
|
+
//#endregion
|
|
562
|
+
//#region ../miniflare/src/workers/core/devalue.ts
|
|
563
|
+
const ALLOWED_ARRAY_BUFFER_VIEW_CONSTRUCTORS = [
|
|
564
|
+
DataView,
|
|
565
|
+
Int8Array,
|
|
566
|
+
Uint8Array,
|
|
567
|
+
Uint8ClampedArray,
|
|
568
|
+
Int16Array,
|
|
569
|
+
Uint16Array,
|
|
570
|
+
Int32Array,
|
|
571
|
+
Uint32Array,
|
|
572
|
+
Float32Array,
|
|
573
|
+
Float64Array,
|
|
574
|
+
BigInt64Array,
|
|
575
|
+
BigUint64Array
|
|
607
576
|
];
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
// `Error` last so more specific error subclasses preferred
|
|
577
|
+
const ALLOWED_ERROR_CONSTRUCTORS = [
|
|
578
|
+
EvalError,
|
|
579
|
+
RangeError,
|
|
580
|
+
ReferenceError,
|
|
581
|
+
SyntaxError,
|
|
582
|
+
TypeError,
|
|
583
|
+
URIError,
|
|
584
|
+
Error
|
|
617
585
|
];
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
586
|
+
const structuredSerializableReducers = {
|
|
587
|
+
ArrayBuffer(value) {
|
|
588
|
+
if (value instanceof ArrayBuffer) return [Buffer.from(value).toString("base64")];
|
|
589
|
+
},
|
|
590
|
+
ArrayBufferView(value) {
|
|
591
|
+
if (ArrayBuffer.isView(value)) return [
|
|
592
|
+
value.constructor.name,
|
|
593
|
+
value.buffer,
|
|
594
|
+
value.byteOffset,
|
|
595
|
+
value.byteLength
|
|
596
|
+
];
|
|
597
|
+
},
|
|
598
|
+
RegExp(value) {
|
|
599
|
+
if (value instanceof RegExp) {
|
|
600
|
+
const { source, flags } = value;
|
|
601
|
+
const encoded = Buffer.from(source).toString("base64");
|
|
602
|
+
return flags ? [
|
|
603
|
+
"RegExp",
|
|
604
|
+
encoded,
|
|
605
|
+
flags
|
|
606
|
+
] : ["RegExp", encoded];
|
|
607
|
+
}
|
|
608
|
+
},
|
|
609
|
+
Error(value) {
|
|
610
|
+
for (const ctor of ALLOWED_ERROR_CONSTRUCTORS) if (value instanceof ctor && value.name === ctor.name) return [
|
|
611
|
+
value.name,
|
|
612
|
+
value.message,
|
|
613
|
+
value.stack,
|
|
614
|
+
value.cause
|
|
615
|
+
];
|
|
616
|
+
if (value instanceof Error) return [
|
|
617
|
+
"Error",
|
|
618
|
+
value.message,
|
|
619
|
+
value.stack,
|
|
620
|
+
value.cause
|
|
621
|
+
];
|
|
622
|
+
}
|
|
651
623
|
};
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
error.stack = stack;
|
|
694
|
-
return error;
|
|
695
|
-
}
|
|
624
|
+
const structuredSerializableRevivers = {
|
|
625
|
+
ArrayBuffer(value) {
|
|
626
|
+
assert(Array.isArray(value));
|
|
627
|
+
const [encoded] = value;
|
|
628
|
+
assert(typeof encoded === "string");
|
|
629
|
+
const view = Buffer.from(encoded, "base64");
|
|
630
|
+
return view.buffer.slice(view.byteOffset, view.byteOffset + view.byteLength);
|
|
631
|
+
},
|
|
632
|
+
ArrayBufferView(value) {
|
|
633
|
+
assert(Array.isArray(value));
|
|
634
|
+
const [name, buffer, byteOffset, byteLength] = value;
|
|
635
|
+
assert(typeof name === "string");
|
|
636
|
+
assert(buffer instanceof ArrayBuffer);
|
|
637
|
+
assert(typeof byteOffset === "number");
|
|
638
|
+
assert(typeof byteLength === "number");
|
|
639
|
+
const ctor = globalThis[name];
|
|
640
|
+
assert(ALLOWED_ARRAY_BUFFER_VIEW_CONSTRUCTORS.includes(ctor));
|
|
641
|
+
let length = byteLength;
|
|
642
|
+
if ("BYTES_PER_ELEMENT" in ctor) length /= ctor.BYTES_PER_ELEMENT;
|
|
643
|
+
return new ctor(buffer, byteOffset, length);
|
|
644
|
+
},
|
|
645
|
+
RegExp(value) {
|
|
646
|
+
assert(Array.isArray(value));
|
|
647
|
+
const [name, encoded, flags] = value;
|
|
648
|
+
assert(typeof name === "string");
|
|
649
|
+
assert(typeof encoded === "string");
|
|
650
|
+
const source = Buffer.from(encoded, "base64").toString("utf-8");
|
|
651
|
+
return new RegExp(source, flags);
|
|
652
|
+
},
|
|
653
|
+
Error(value) {
|
|
654
|
+
assert(Array.isArray(value));
|
|
655
|
+
const [name, message, stack, cause] = value;
|
|
656
|
+
assert(typeof name === "string");
|
|
657
|
+
assert(typeof message === "string");
|
|
658
|
+
assert(stack === void 0 || typeof stack === "string");
|
|
659
|
+
const ctor = globalThis[name];
|
|
660
|
+
assert(ALLOWED_ERROR_CONSTRUCTORS.includes(ctor));
|
|
661
|
+
const error = new ctor(message, { cause });
|
|
662
|
+
error.stack = stack;
|
|
663
|
+
return error;
|
|
664
|
+
}
|
|
696
665
|
};
|
|
697
666
|
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
import { Buffer as Buffer2 } from "node:buffer";
|
|
701
|
-
function createChunkingSocket(socket, maxChunkByteLength = 1048576) {
|
|
702
|
-
const listeners = [];
|
|
703
|
-
const decoder = new TextDecoder();
|
|
704
|
-
let chunks;
|
|
705
|
-
socket.on((message) => {
|
|
706
|
-
if (typeof message === "string") {
|
|
707
|
-
if (chunks !== void 0) {
|
|
708
|
-
assert2.strictEqual(message, "", "Expected end-of-chunks");
|
|
709
|
-
message = chunks + decoder.decode();
|
|
710
|
-
chunks = void 0;
|
|
711
|
-
}
|
|
712
|
-
for (const listener of listeners) {
|
|
713
|
-
listener(message);
|
|
714
|
-
}
|
|
715
|
-
} else {
|
|
716
|
-
chunks ??= "";
|
|
717
|
-
chunks += decoder.decode(message, { stream: true });
|
|
718
|
-
}
|
|
719
|
-
});
|
|
720
|
-
return {
|
|
721
|
-
post(value) {
|
|
722
|
-
if (Buffer2.byteLength(value) > maxChunkByteLength) {
|
|
723
|
-
const encoded = Buffer2.from(value);
|
|
724
|
-
for (let i = 0; i < encoded.byteLength; i += maxChunkByteLength) {
|
|
725
|
-
socket.post(encoded.subarray(i, i + maxChunkByteLength));
|
|
726
|
-
}
|
|
727
|
-
socket.post("");
|
|
728
|
-
} else {
|
|
729
|
-
socket.post(value);
|
|
730
|
-
}
|
|
731
|
-
},
|
|
732
|
-
on(listener) {
|
|
733
|
-
listeners.push(listener);
|
|
734
|
-
}
|
|
735
|
-
};
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
// src/worker/index.ts
|
|
739
|
-
export * from "__VITEST_POOL_WORKERS_USER_OBJECT";
|
|
667
|
+
//#endregion
|
|
668
|
+
//#region src/worker/index.ts
|
|
740
669
|
function structuredSerializableStringify(value) {
|
|
741
|
-
|
|
670
|
+
return stringify(value, structuredSerializableReducers);
|
|
742
671
|
}
|
|
743
672
|
function structuredSerializableParse(value) {
|
|
744
|
-
|
|
673
|
+
return parse(value, structuredSerializableRevivers);
|
|
745
674
|
}
|
|
746
|
-
globalThis.
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
675
|
+
globalThis.BroadcastChannel = class {
|
|
676
|
+
constructor(name) {
|
|
677
|
+
this.name = name;
|
|
678
|
+
}
|
|
679
|
+
postMessage(_message) {}
|
|
680
|
+
close() {}
|
|
681
|
+
addEventListener(_type, _listener) {}
|
|
682
|
+
removeEventListener(_type, _listener) {}
|
|
683
|
+
onmessage = null;
|
|
684
|
+
onmessageerror = null;
|
|
685
|
+
};
|
|
686
|
+
let cwd;
|
|
750
687
|
process.cwd = () => {
|
|
751
|
-
|
|
752
|
-
|
|
688
|
+
assert(cwd !== void 0, "Expected cwd to be set");
|
|
689
|
+
return cwd;
|
|
753
690
|
};
|
|
754
|
-
Object.setPrototypeOf(process, events.EventEmitter.prototype);
|
|
755
691
|
globalThis.__console = console;
|
|
756
692
|
function getCallerFileName(of) {
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
693
|
+
const originalStackTraceLimit = Error.stackTraceLimit;
|
|
694
|
+
const originalPrepareStackTrace = Error.prepareStackTrace;
|
|
695
|
+
try {
|
|
696
|
+
let fileName = null;
|
|
697
|
+
Error.stackTraceLimit = 1;
|
|
698
|
+
Error.prepareStackTrace = (_error, callSites) => {
|
|
699
|
+
fileName = callSites[0]?.getFileName();
|
|
700
|
+
return "";
|
|
701
|
+
};
|
|
702
|
+
const error = {};
|
|
703
|
+
Error.captureStackTrace(error, of);
|
|
704
|
+
error.stack;
|
|
705
|
+
return fileName;
|
|
706
|
+
} finally {
|
|
707
|
+
Error.stackTraceLimit = originalStackTraceLimit;
|
|
708
|
+
Error.prepareStackTrace = originalPrepareStackTrace;
|
|
709
|
+
}
|
|
774
710
|
}
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
registerHandlerAndGlobalWaitUntil(promise);
|
|
797
|
-
const id = originalSetTimeout.call(globalThis, () => {
|
|
798
|
-
promiseResolve?.();
|
|
799
|
-
callback?.(...restArgs);
|
|
800
|
-
});
|
|
801
|
-
timeoutPromiseResolves.set(id, promiseResolve);
|
|
802
|
-
return id;
|
|
711
|
+
const originalSetTimeout = globalThis.setTimeout;
|
|
712
|
+
const originalClearTimeout = globalThis.clearTimeout;
|
|
713
|
+
const timeoutPromiseResolves = /* @__PURE__ */ new Map();
|
|
714
|
+
const monkeypatchedSetTimeout = (...args) => {
|
|
715
|
+
const [callback, delay, ...restArgs] = args;
|
|
716
|
+
const callbackName = args[0]?.name ?? "";
|
|
717
|
+
const callerFileName = getCallerFileName(monkeypatchedSetTimeout);
|
|
718
|
+
if (!(/\/node_modules\/(\.pnpm\/|\.store\/)?vitest/.test(callerFileName ?? "") || /\/packages\/vitest\/dist/.test(callerFileName ?? "")) || delay) return originalSetTimeout.apply(globalThis, args);
|
|
719
|
+
if (callbackName === "NOOP") return -.5;
|
|
720
|
+
let promiseResolve;
|
|
721
|
+
const promise = new Promise((resolve) => {
|
|
722
|
+
promiseResolve = resolve;
|
|
723
|
+
});
|
|
724
|
+
assert(promiseResolve !== void 0);
|
|
725
|
+
registerHandlerAndGlobalWaitUntil(promise);
|
|
726
|
+
const id = originalSetTimeout.call(globalThis, () => {
|
|
727
|
+
promiseResolve?.();
|
|
728
|
+
callback?.(...restArgs);
|
|
729
|
+
});
|
|
730
|
+
timeoutPromiseResolves.set(id, promiseResolve);
|
|
731
|
+
return id;
|
|
803
732
|
};
|
|
804
733
|
globalThis.setTimeout = monkeypatchedSetTimeout;
|
|
805
734
|
globalThis.clearTimeout = (...args) => {
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
maybePromiseResolve?.();
|
|
813
|
-
return originalClearTimeout.apply(globalThis, args);
|
|
735
|
+
const id = args[0];
|
|
736
|
+
if (id === -.5) return;
|
|
737
|
+
const maybePromiseResolve = timeoutPromiseResolves.get(id);
|
|
738
|
+
timeoutPromiseResolves.delete(id);
|
|
739
|
+
maybePromiseResolve?.();
|
|
740
|
+
return originalClearTimeout.apply(globalThis, args);
|
|
814
741
|
};
|
|
815
742
|
function isDifferentIOContextError(e) {
|
|
816
|
-
|
|
817
|
-
}
|
|
818
|
-
var WebSocketMessagePort = class extends events.EventEmitter {
|
|
819
|
-
constructor(socket) {
|
|
820
|
-
super();
|
|
821
|
-
this.socket = socket;
|
|
822
|
-
this.#chunkingSocket = createChunkingSocket({
|
|
823
|
-
post(message) {
|
|
824
|
-
socket.send(message);
|
|
825
|
-
},
|
|
826
|
-
on(listener) {
|
|
827
|
-
socket.addEventListener("message", (event) => {
|
|
828
|
-
listener(event.data);
|
|
829
|
-
});
|
|
830
|
-
}
|
|
831
|
-
});
|
|
832
|
-
this.#chunkingSocket.on((message) => {
|
|
833
|
-
const parsed = structuredSerializableParse(message);
|
|
834
|
-
this.emit("message", parsed);
|
|
835
|
-
});
|
|
836
|
-
socket.accept();
|
|
837
|
-
}
|
|
838
|
-
#chunkingSocket;
|
|
839
|
-
postMessage(data) {
|
|
840
|
-
const stringified = structuredSerializableStringify(data);
|
|
841
|
-
try {
|
|
842
|
-
if (this.socket.readyState === WebSocket.READY_STATE_OPEN) {
|
|
843
|
-
this.#chunkingSocket.post(stringified);
|
|
844
|
-
}
|
|
845
|
-
} catch (error) {
|
|
846
|
-
if (isDifferentIOContextError(error)) {
|
|
847
|
-
const promise = runInRunnerObject(internalEnv, () => {
|
|
848
|
-
this.#chunkingSocket.post(stringified);
|
|
849
|
-
}).catch((e) => {
|
|
850
|
-
__console.error("Error sending to pool inside runner:", e, data);
|
|
851
|
-
});
|
|
852
|
-
registerHandlerAndGlobalWaitUntil(promise);
|
|
853
|
-
} else {
|
|
854
|
-
__console.error("Error sending to pool:", error, data);
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
};
|
|
859
|
-
function reduceError(e) {
|
|
860
|
-
return {
|
|
861
|
-
name: e?.name,
|
|
862
|
-
message: e?.message ?? String(e),
|
|
863
|
-
stack: e?.stack,
|
|
864
|
-
cause: e?.cause === void 0 ? void 0 : reduceError(e.cause)
|
|
865
|
-
};
|
|
743
|
+
return e instanceof Error && e.message.startsWith("Cannot perform I/O on behalf of a different");
|
|
866
744
|
}
|
|
867
|
-
|
|
745
|
+
let patchedFunction = false;
|
|
868
746
|
function ensurePatchedFunction(unsafeEval) {
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
const script = args.pop();
|
|
876
|
-
return unsafeEval.newFunction(script, "anonymous", ...args);
|
|
877
|
-
}
|
|
878
|
-
});
|
|
747
|
+
if (patchedFunction) return;
|
|
748
|
+
patchedFunction = true;
|
|
749
|
+
globalThis.Function = new Proxy(globalThis.Function, { construct(_target, args, _newTarget) {
|
|
750
|
+
const script = args.pop();
|
|
751
|
+
return unsafeEval.newFunction(script, "anonymous", ...args);
|
|
752
|
+
} });
|
|
879
753
|
}
|
|
880
754
|
function applyDefines() {
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
|
-
}
|
|
755
|
+
for (const [key, value] of Object.entries(defines)) {
|
|
756
|
+
const segments = key.split(".");
|
|
757
|
+
let target = globalThis;
|
|
758
|
+
for (let i = 0; i < segments.length; i++) {
|
|
759
|
+
const segment = segments[i];
|
|
760
|
+
if (i === segments.length - 1) target[segment] = value;
|
|
761
|
+
else target = target[segment] ??= {};
|
|
762
|
+
}
|
|
763
|
+
}
|
|
893
764
|
}
|
|
894
|
-
var __VITEST_POOL_WORKERS_RUNNER_DURABLE_OBJECT__ = class {
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
async fetch(request) {
|
|
944
|
-
const response = await maybeHandleRunRequest(request, this);
|
|
945
|
-
if (response !== void 0) {
|
|
946
|
-
return response;
|
|
947
|
-
}
|
|
948
|
-
return this.handleVitestRunRequest(request);
|
|
949
|
-
}
|
|
765
|
+
var __VITEST_POOL_WORKERS_RUNNER_DURABLE_OBJECT__ = class extends DurableObject {
|
|
766
|
+
constructor(_state, doEnv) {
|
|
767
|
+
super(_state, doEnv);
|
|
768
|
+
vm._setUnsafeEval(doEnv.__VITEST_POOL_WORKERS_UNSAFE_EVAL);
|
|
769
|
+
ensurePatchedFunction(doEnv.__VITEST_POOL_WORKERS_UNSAFE_EVAL);
|
|
770
|
+
applyDefines();
|
|
771
|
+
}
|
|
772
|
+
async handleVitestRunRequest(request) {
|
|
773
|
+
assert.strictEqual(request.headers.get("Upgrade"), "websocket");
|
|
774
|
+
const { 0: poolSocket, 1: poolResponseSocket } = new WebSocketPair();
|
|
775
|
+
const workerDataHeader = request.headers.get("MF-Vitest-Worker-Data");
|
|
776
|
+
assert(workerDataHeader);
|
|
777
|
+
const wd = structuredSerializableParse(workerDataHeader);
|
|
778
|
+
assert(wd && typeof wd === "object" && "cwd" in wd && typeof wd.cwd === "string");
|
|
779
|
+
cwd = wd.cwd;
|
|
780
|
+
const { init, runBaseTests, setupEnvironment } = await import("vitest/worker");
|
|
781
|
+
poolSocket.accept();
|
|
782
|
+
init({
|
|
783
|
+
post: (response) => {
|
|
784
|
+
try {
|
|
785
|
+
poolSocket.send(structuredSerializableStringify(response));
|
|
786
|
+
} catch (error) {
|
|
787
|
+
if (isDifferentIOContextError(error)) registerHandlerAndGlobalWaitUntil(runInRunnerObject(() => {
|
|
788
|
+
poolSocket.send(structuredSerializableStringify(response));
|
|
789
|
+
}).catch((e) => {
|
|
790
|
+
__console.error("Error sending to pool inside runner:", e, response);
|
|
791
|
+
}));
|
|
792
|
+
else __console.error("Error sending to pool:", error, response);
|
|
793
|
+
}
|
|
794
|
+
},
|
|
795
|
+
on: (callback) => {
|
|
796
|
+
poolSocket.addEventListener("message", (m) => {
|
|
797
|
+
callback(structuredSerializableParse(m.data));
|
|
798
|
+
});
|
|
799
|
+
},
|
|
800
|
+
runTests: (state, traces) => runBaseTests("run", state, traces),
|
|
801
|
+
collectTests: (state, traces) => runBaseTests("collect", state, traces),
|
|
802
|
+
setup: setupEnvironment
|
|
803
|
+
});
|
|
804
|
+
return new Response(null, {
|
|
805
|
+
status: 101,
|
|
806
|
+
webSocket: poolResponseSocket
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
async fetch(request) {
|
|
810
|
+
const response = await maybeHandleRunRequest(request, this);
|
|
811
|
+
if (response !== void 0) return response;
|
|
812
|
+
return this.handleVitestRunRequest(request);
|
|
813
|
+
}
|
|
950
814
|
};
|
|
951
815
|
var worker_default = createWorkerEntrypointWrapper("default");
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
//# sourceMappingURL=index.mjs.map
|
|
816
|
+
|
|
817
|
+
//#endregion
|
|
818
|
+
export { __VITEST_POOL_WORKERS_RUNNER_DURABLE_OBJECT__, worker_default as default };
|
|
819
|
+
//# sourceMappingURL=index.mjs.map
|