@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
|
@@ -1,3433 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
4
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
// ../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/core/symbols.js
|
|
8
|
-
var require_symbols = __commonJS({
|
|
9
|
-
"../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/core/symbols.js"(exports2, module2) {
|
|
10
|
-
"use strict";
|
|
11
|
-
module2.exports = {
|
|
12
|
-
kClose: /* @__PURE__ */ Symbol("close"),
|
|
13
|
-
kDestroy: /* @__PURE__ */ Symbol("destroy"),
|
|
14
|
-
kDispatch: /* @__PURE__ */ Symbol("dispatch"),
|
|
15
|
-
kUrl: /* @__PURE__ */ Symbol("url"),
|
|
16
|
-
kWriting: /* @__PURE__ */ Symbol("writing"),
|
|
17
|
-
kResuming: /* @__PURE__ */ Symbol("resuming"),
|
|
18
|
-
kQueue: /* @__PURE__ */ Symbol("queue"),
|
|
19
|
-
kConnect: /* @__PURE__ */ Symbol("connect"),
|
|
20
|
-
kConnecting: /* @__PURE__ */ Symbol("connecting"),
|
|
21
|
-
kKeepAliveDefaultTimeout: /* @__PURE__ */ Symbol("default keep alive timeout"),
|
|
22
|
-
kKeepAliveMaxTimeout: /* @__PURE__ */ Symbol("max keep alive timeout"),
|
|
23
|
-
kKeepAliveTimeoutThreshold: /* @__PURE__ */ Symbol("keep alive timeout threshold"),
|
|
24
|
-
kKeepAliveTimeoutValue: /* @__PURE__ */ Symbol("keep alive timeout"),
|
|
25
|
-
kKeepAlive: /* @__PURE__ */ Symbol("keep alive"),
|
|
26
|
-
kHeadersTimeout: /* @__PURE__ */ Symbol("headers timeout"),
|
|
27
|
-
kBodyTimeout: /* @__PURE__ */ Symbol("body timeout"),
|
|
28
|
-
kServerName: /* @__PURE__ */ Symbol("server name"),
|
|
29
|
-
kLocalAddress: /* @__PURE__ */ Symbol("local address"),
|
|
30
|
-
kHost: /* @__PURE__ */ Symbol("host"),
|
|
31
|
-
kNoRef: /* @__PURE__ */ Symbol("no ref"),
|
|
32
|
-
kBodyUsed: /* @__PURE__ */ Symbol("used"),
|
|
33
|
-
kBody: /* @__PURE__ */ Symbol("abstracted request body"),
|
|
34
|
-
kRunning: /* @__PURE__ */ Symbol("running"),
|
|
35
|
-
kBlocking: /* @__PURE__ */ Symbol("blocking"),
|
|
36
|
-
kPending: /* @__PURE__ */ Symbol("pending"),
|
|
37
|
-
kSize: /* @__PURE__ */ Symbol("size"),
|
|
38
|
-
kBusy: /* @__PURE__ */ Symbol("busy"),
|
|
39
|
-
kQueued: /* @__PURE__ */ Symbol("queued"),
|
|
40
|
-
kFree: /* @__PURE__ */ Symbol("free"),
|
|
41
|
-
kConnected: /* @__PURE__ */ Symbol("connected"),
|
|
42
|
-
kClosed: /* @__PURE__ */ Symbol("closed"),
|
|
43
|
-
kNeedDrain: /* @__PURE__ */ Symbol("need drain"),
|
|
44
|
-
kReset: /* @__PURE__ */ Symbol("reset"),
|
|
45
|
-
kDestroyed: /* @__PURE__ */ Symbol.for("nodejs.stream.destroyed"),
|
|
46
|
-
kResume: /* @__PURE__ */ Symbol("resume"),
|
|
47
|
-
kOnError: /* @__PURE__ */ Symbol("on error"),
|
|
48
|
-
kMaxHeadersSize: /* @__PURE__ */ Symbol("max headers size"),
|
|
49
|
-
kRunningIdx: /* @__PURE__ */ Symbol("running index"),
|
|
50
|
-
kPendingIdx: /* @__PURE__ */ Symbol("pending index"),
|
|
51
|
-
kError: /* @__PURE__ */ Symbol("error"),
|
|
52
|
-
kClients: /* @__PURE__ */ Symbol("clients"),
|
|
53
|
-
kClient: /* @__PURE__ */ Symbol("client"),
|
|
54
|
-
kParser: /* @__PURE__ */ Symbol("parser"),
|
|
55
|
-
kOnDestroyed: /* @__PURE__ */ Symbol("destroy callbacks"),
|
|
56
|
-
kPipelining: /* @__PURE__ */ Symbol("pipelining"),
|
|
57
|
-
kSocket: /* @__PURE__ */ Symbol("socket"),
|
|
58
|
-
kHostHeader: /* @__PURE__ */ Symbol("host header"),
|
|
59
|
-
kConnector: /* @__PURE__ */ Symbol("connector"),
|
|
60
|
-
kStrictContentLength: /* @__PURE__ */ Symbol("strict content length"),
|
|
61
|
-
kMaxRedirections: /* @__PURE__ */ Symbol("maxRedirections"),
|
|
62
|
-
kMaxRequests: /* @__PURE__ */ Symbol("maxRequestsPerClient"),
|
|
63
|
-
kProxy: /* @__PURE__ */ Symbol("proxy agent options"),
|
|
64
|
-
kCounter: /* @__PURE__ */ Symbol("socket request counter"),
|
|
65
|
-
kMaxResponseSize: /* @__PURE__ */ Symbol("max response size"),
|
|
66
|
-
kHTTP2Session: /* @__PURE__ */ Symbol("http2Session"),
|
|
67
|
-
kHTTP2SessionState: /* @__PURE__ */ Symbol("http2Session state"),
|
|
68
|
-
kRetryHandlerDefaultRetry: /* @__PURE__ */ Symbol("retry agent default retry"),
|
|
69
|
-
kConstruct: /* @__PURE__ */ Symbol("constructable"),
|
|
70
|
-
kListeners: /* @__PURE__ */ Symbol("listeners"),
|
|
71
|
-
kHTTPContext: /* @__PURE__ */ Symbol("http context"),
|
|
72
|
-
kMaxConcurrentStreams: /* @__PURE__ */ Symbol("max concurrent streams"),
|
|
73
|
-
kEnableConnectProtocol: /* @__PURE__ */ Symbol("http2session connect protocol"),
|
|
74
|
-
kRemoteSettings: /* @__PURE__ */ Symbol("http2session remote settings"),
|
|
75
|
-
kHTTP2Stream: /* @__PURE__ */ Symbol("http2session client stream"),
|
|
76
|
-
kNoProxyAgent: /* @__PURE__ */ Symbol("no proxy agent"),
|
|
77
|
-
kHttpProxyAgent: /* @__PURE__ */ Symbol("http proxy agent"),
|
|
78
|
-
kHttpsProxyAgent: /* @__PURE__ */ Symbol("https proxy agent")
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
// ../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/core/errors.js
|
|
84
|
-
var require_errors = __commonJS({
|
|
85
|
-
"../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/core/errors.js"(exports2, module2) {
|
|
86
|
-
"use strict";
|
|
87
|
-
var kUndiciError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR");
|
|
88
|
-
var UndiciError = class extends Error {
|
|
89
|
-
constructor(message, options) {
|
|
90
|
-
super(message, options);
|
|
91
|
-
this.name = "UndiciError";
|
|
92
|
-
this.code = "UND_ERR";
|
|
93
|
-
}
|
|
94
|
-
static [Symbol.hasInstance](instance) {
|
|
95
|
-
return instance && instance[kUndiciError] === true;
|
|
96
|
-
}
|
|
97
|
-
get [kUndiciError]() {
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
var kConnectTimeoutError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_CONNECT_TIMEOUT");
|
|
102
|
-
var ConnectTimeoutError = class extends UndiciError {
|
|
103
|
-
constructor(message) {
|
|
104
|
-
super(message);
|
|
105
|
-
this.name = "ConnectTimeoutError";
|
|
106
|
-
this.message = message || "Connect Timeout Error";
|
|
107
|
-
this.code = "UND_ERR_CONNECT_TIMEOUT";
|
|
108
|
-
}
|
|
109
|
-
static [Symbol.hasInstance](instance) {
|
|
110
|
-
return instance && instance[kConnectTimeoutError] === true;
|
|
111
|
-
}
|
|
112
|
-
get [kConnectTimeoutError]() {
|
|
113
|
-
return true;
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
var kHeadersTimeoutError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_HEADERS_TIMEOUT");
|
|
117
|
-
var HeadersTimeoutError = class extends UndiciError {
|
|
118
|
-
constructor(message) {
|
|
119
|
-
super(message);
|
|
120
|
-
this.name = "HeadersTimeoutError";
|
|
121
|
-
this.message = message || "Headers Timeout Error";
|
|
122
|
-
this.code = "UND_ERR_HEADERS_TIMEOUT";
|
|
123
|
-
}
|
|
124
|
-
static [Symbol.hasInstance](instance) {
|
|
125
|
-
return instance && instance[kHeadersTimeoutError] === true;
|
|
126
|
-
}
|
|
127
|
-
get [kHeadersTimeoutError]() {
|
|
128
|
-
return true;
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
var kHeadersOverflowError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_HEADERS_OVERFLOW");
|
|
132
|
-
var HeadersOverflowError = class extends UndiciError {
|
|
133
|
-
constructor(message) {
|
|
134
|
-
super(message);
|
|
135
|
-
this.name = "HeadersOverflowError";
|
|
136
|
-
this.message = message || "Headers Overflow Error";
|
|
137
|
-
this.code = "UND_ERR_HEADERS_OVERFLOW";
|
|
138
|
-
}
|
|
139
|
-
static [Symbol.hasInstance](instance) {
|
|
140
|
-
return instance && instance[kHeadersOverflowError] === true;
|
|
141
|
-
}
|
|
142
|
-
get [kHeadersOverflowError]() {
|
|
143
|
-
return true;
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
var kBodyTimeoutError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_BODY_TIMEOUT");
|
|
147
|
-
var BodyTimeoutError = class extends UndiciError {
|
|
148
|
-
constructor(message) {
|
|
149
|
-
super(message);
|
|
150
|
-
this.name = "BodyTimeoutError";
|
|
151
|
-
this.message = message || "Body Timeout Error";
|
|
152
|
-
this.code = "UND_ERR_BODY_TIMEOUT";
|
|
153
|
-
}
|
|
154
|
-
static [Symbol.hasInstance](instance) {
|
|
155
|
-
return instance && instance[kBodyTimeoutError] === true;
|
|
156
|
-
}
|
|
157
|
-
get [kBodyTimeoutError]() {
|
|
158
|
-
return true;
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
var kInvalidArgumentError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_INVALID_ARG");
|
|
162
|
-
var InvalidArgumentError = class extends UndiciError {
|
|
163
|
-
constructor(message) {
|
|
164
|
-
super(message);
|
|
165
|
-
this.name = "InvalidArgumentError";
|
|
166
|
-
this.message = message || "Invalid Argument Error";
|
|
167
|
-
this.code = "UND_ERR_INVALID_ARG";
|
|
168
|
-
}
|
|
169
|
-
static [Symbol.hasInstance](instance) {
|
|
170
|
-
return instance && instance[kInvalidArgumentError] === true;
|
|
171
|
-
}
|
|
172
|
-
get [kInvalidArgumentError]() {
|
|
173
|
-
return true;
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
var kInvalidReturnValueError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_INVALID_RETURN_VALUE");
|
|
177
|
-
var InvalidReturnValueError = class extends UndiciError {
|
|
178
|
-
constructor(message) {
|
|
179
|
-
super(message);
|
|
180
|
-
this.name = "InvalidReturnValueError";
|
|
181
|
-
this.message = message || "Invalid Return Value Error";
|
|
182
|
-
this.code = "UND_ERR_INVALID_RETURN_VALUE";
|
|
183
|
-
}
|
|
184
|
-
static [Symbol.hasInstance](instance) {
|
|
185
|
-
return instance && instance[kInvalidReturnValueError] === true;
|
|
186
|
-
}
|
|
187
|
-
get [kInvalidReturnValueError]() {
|
|
188
|
-
return true;
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
var kAbortError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_ABORT");
|
|
192
|
-
var AbortError = class extends UndiciError {
|
|
193
|
-
constructor(message) {
|
|
194
|
-
super(message);
|
|
195
|
-
this.name = "AbortError";
|
|
196
|
-
this.message = message || "The operation was aborted";
|
|
197
|
-
this.code = "UND_ERR_ABORT";
|
|
198
|
-
}
|
|
199
|
-
static [Symbol.hasInstance](instance) {
|
|
200
|
-
return instance && instance[kAbortError] === true;
|
|
201
|
-
}
|
|
202
|
-
get [kAbortError]() {
|
|
203
|
-
return true;
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
var kRequestAbortedError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_ABORTED");
|
|
207
|
-
var RequestAbortedError = class extends AbortError {
|
|
208
|
-
constructor(message) {
|
|
209
|
-
super(message);
|
|
210
|
-
this.name = "AbortError";
|
|
211
|
-
this.message = message || "Request aborted";
|
|
212
|
-
this.code = "UND_ERR_ABORTED";
|
|
213
|
-
}
|
|
214
|
-
static [Symbol.hasInstance](instance) {
|
|
215
|
-
return instance && instance[kRequestAbortedError] === true;
|
|
216
|
-
}
|
|
217
|
-
get [kRequestAbortedError]() {
|
|
218
|
-
return true;
|
|
219
|
-
}
|
|
220
|
-
};
|
|
221
|
-
var kInformationalError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_INFO");
|
|
222
|
-
var InformationalError = class extends UndiciError {
|
|
223
|
-
constructor(message) {
|
|
224
|
-
super(message);
|
|
225
|
-
this.name = "InformationalError";
|
|
226
|
-
this.message = message || "Request information";
|
|
227
|
-
this.code = "UND_ERR_INFO";
|
|
228
|
-
}
|
|
229
|
-
static [Symbol.hasInstance](instance) {
|
|
230
|
-
return instance && instance[kInformationalError] === true;
|
|
231
|
-
}
|
|
232
|
-
get [kInformationalError]() {
|
|
233
|
-
return true;
|
|
234
|
-
}
|
|
235
|
-
};
|
|
236
|
-
var kRequestContentLengthMismatchError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_REQ_CONTENT_LENGTH_MISMATCH");
|
|
237
|
-
var RequestContentLengthMismatchError = class extends UndiciError {
|
|
238
|
-
constructor(message) {
|
|
239
|
-
super(message);
|
|
240
|
-
this.name = "RequestContentLengthMismatchError";
|
|
241
|
-
this.message = message || "Request body length does not match content-length header";
|
|
242
|
-
this.code = "UND_ERR_REQ_CONTENT_LENGTH_MISMATCH";
|
|
243
|
-
}
|
|
244
|
-
static [Symbol.hasInstance](instance) {
|
|
245
|
-
return instance && instance[kRequestContentLengthMismatchError] === true;
|
|
246
|
-
}
|
|
247
|
-
get [kRequestContentLengthMismatchError]() {
|
|
248
|
-
return true;
|
|
249
|
-
}
|
|
250
|
-
};
|
|
251
|
-
var kResponseContentLengthMismatchError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_RES_CONTENT_LENGTH_MISMATCH");
|
|
252
|
-
var ResponseContentLengthMismatchError = class extends UndiciError {
|
|
253
|
-
constructor(message) {
|
|
254
|
-
super(message);
|
|
255
|
-
this.name = "ResponseContentLengthMismatchError";
|
|
256
|
-
this.message = message || "Response body length does not match content-length header";
|
|
257
|
-
this.code = "UND_ERR_RES_CONTENT_LENGTH_MISMATCH";
|
|
258
|
-
}
|
|
259
|
-
static [Symbol.hasInstance](instance) {
|
|
260
|
-
return instance && instance[kResponseContentLengthMismatchError] === true;
|
|
261
|
-
}
|
|
262
|
-
get [kResponseContentLengthMismatchError]() {
|
|
263
|
-
return true;
|
|
264
|
-
}
|
|
265
|
-
};
|
|
266
|
-
var kClientDestroyedError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_DESTROYED");
|
|
267
|
-
var ClientDestroyedError = class extends UndiciError {
|
|
268
|
-
constructor(message) {
|
|
269
|
-
super(message);
|
|
270
|
-
this.name = "ClientDestroyedError";
|
|
271
|
-
this.message = message || "The client is destroyed";
|
|
272
|
-
this.code = "UND_ERR_DESTROYED";
|
|
273
|
-
}
|
|
274
|
-
static [Symbol.hasInstance](instance) {
|
|
275
|
-
return instance && instance[kClientDestroyedError] === true;
|
|
276
|
-
}
|
|
277
|
-
get [kClientDestroyedError]() {
|
|
278
|
-
return true;
|
|
279
|
-
}
|
|
280
|
-
};
|
|
281
|
-
var kClientClosedError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_CLOSED");
|
|
282
|
-
var ClientClosedError = class extends UndiciError {
|
|
283
|
-
constructor(message) {
|
|
284
|
-
super(message);
|
|
285
|
-
this.name = "ClientClosedError";
|
|
286
|
-
this.message = message || "The client is closed";
|
|
287
|
-
this.code = "UND_ERR_CLOSED";
|
|
288
|
-
}
|
|
289
|
-
static [Symbol.hasInstance](instance) {
|
|
290
|
-
return instance && instance[kClientClosedError] === true;
|
|
291
|
-
}
|
|
292
|
-
get [kClientClosedError]() {
|
|
293
|
-
return true;
|
|
294
|
-
}
|
|
295
|
-
};
|
|
296
|
-
var kSocketError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_SOCKET");
|
|
297
|
-
var SocketError = class extends UndiciError {
|
|
298
|
-
constructor(message, socket) {
|
|
299
|
-
super(message);
|
|
300
|
-
this.name = "SocketError";
|
|
301
|
-
this.message = message || "Socket error";
|
|
302
|
-
this.code = "UND_ERR_SOCKET";
|
|
303
|
-
this.socket = socket;
|
|
304
|
-
}
|
|
305
|
-
static [Symbol.hasInstance](instance) {
|
|
306
|
-
return instance && instance[kSocketError] === true;
|
|
307
|
-
}
|
|
308
|
-
get [kSocketError]() {
|
|
309
|
-
return true;
|
|
310
|
-
}
|
|
311
|
-
};
|
|
312
|
-
var kNotSupportedError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_NOT_SUPPORTED");
|
|
313
|
-
var NotSupportedError = class extends UndiciError {
|
|
314
|
-
constructor(message) {
|
|
315
|
-
super(message);
|
|
316
|
-
this.name = "NotSupportedError";
|
|
317
|
-
this.message = message || "Not supported error";
|
|
318
|
-
this.code = "UND_ERR_NOT_SUPPORTED";
|
|
319
|
-
}
|
|
320
|
-
static [Symbol.hasInstance](instance) {
|
|
321
|
-
return instance && instance[kNotSupportedError] === true;
|
|
322
|
-
}
|
|
323
|
-
get [kNotSupportedError]() {
|
|
324
|
-
return true;
|
|
325
|
-
}
|
|
326
|
-
};
|
|
327
|
-
var kBalancedPoolMissingUpstreamError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_BPL_MISSING_UPSTREAM");
|
|
328
|
-
var BalancedPoolMissingUpstreamError = class extends UndiciError {
|
|
329
|
-
constructor(message) {
|
|
330
|
-
super(message);
|
|
331
|
-
this.name = "MissingUpstreamError";
|
|
332
|
-
this.message = message || "No upstream has been added to the BalancedPool";
|
|
333
|
-
this.code = "UND_ERR_BPL_MISSING_UPSTREAM";
|
|
334
|
-
}
|
|
335
|
-
static [Symbol.hasInstance](instance) {
|
|
336
|
-
return instance && instance[kBalancedPoolMissingUpstreamError] === true;
|
|
337
|
-
}
|
|
338
|
-
get [kBalancedPoolMissingUpstreamError]() {
|
|
339
|
-
return true;
|
|
340
|
-
}
|
|
341
|
-
};
|
|
342
|
-
var kHTTPParserError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_HTTP_PARSER");
|
|
343
|
-
var HTTPParserError = class extends Error {
|
|
344
|
-
constructor(message, code, data) {
|
|
345
|
-
super(message);
|
|
346
|
-
this.name = "HTTPParserError";
|
|
347
|
-
this.code = code ? `HPE_${code}` : void 0;
|
|
348
|
-
this.data = data ? data.toString() : void 0;
|
|
349
|
-
}
|
|
350
|
-
static [Symbol.hasInstance](instance) {
|
|
351
|
-
return instance && instance[kHTTPParserError] === true;
|
|
352
|
-
}
|
|
353
|
-
get [kHTTPParserError]() {
|
|
354
|
-
return true;
|
|
355
|
-
}
|
|
356
|
-
};
|
|
357
|
-
var kResponseExceededMaxSizeError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_RES_EXCEEDED_MAX_SIZE");
|
|
358
|
-
var ResponseExceededMaxSizeError = class extends UndiciError {
|
|
359
|
-
constructor(message) {
|
|
360
|
-
super(message);
|
|
361
|
-
this.name = "ResponseExceededMaxSizeError";
|
|
362
|
-
this.message = message || "Response content exceeded max size";
|
|
363
|
-
this.code = "UND_ERR_RES_EXCEEDED_MAX_SIZE";
|
|
364
|
-
}
|
|
365
|
-
static [Symbol.hasInstance](instance) {
|
|
366
|
-
return instance && instance[kResponseExceededMaxSizeError] === true;
|
|
367
|
-
}
|
|
368
|
-
get [kResponseExceededMaxSizeError]() {
|
|
369
|
-
return true;
|
|
370
|
-
}
|
|
371
|
-
};
|
|
372
|
-
var kRequestRetryError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_REQ_RETRY");
|
|
373
|
-
var RequestRetryError = class extends UndiciError {
|
|
374
|
-
constructor(message, code, { headers, data }) {
|
|
375
|
-
super(message);
|
|
376
|
-
this.name = "RequestRetryError";
|
|
377
|
-
this.message = message || "Request retry error";
|
|
378
|
-
this.code = "UND_ERR_REQ_RETRY";
|
|
379
|
-
this.statusCode = code;
|
|
380
|
-
this.data = data;
|
|
381
|
-
this.headers = headers;
|
|
382
|
-
}
|
|
383
|
-
static [Symbol.hasInstance](instance) {
|
|
384
|
-
return instance && instance[kRequestRetryError] === true;
|
|
385
|
-
}
|
|
386
|
-
get [kRequestRetryError]() {
|
|
387
|
-
return true;
|
|
388
|
-
}
|
|
389
|
-
};
|
|
390
|
-
var kResponseError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_RESPONSE");
|
|
391
|
-
var ResponseError = class extends UndiciError {
|
|
392
|
-
constructor(message, code, { headers, body }) {
|
|
393
|
-
super(message);
|
|
394
|
-
this.name = "ResponseError";
|
|
395
|
-
this.message = message || "Response error";
|
|
396
|
-
this.code = "UND_ERR_RESPONSE";
|
|
397
|
-
this.statusCode = code;
|
|
398
|
-
this.body = body;
|
|
399
|
-
this.headers = headers;
|
|
400
|
-
}
|
|
401
|
-
static [Symbol.hasInstance](instance) {
|
|
402
|
-
return instance && instance[kResponseError] === true;
|
|
403
|
-
}
|
|
404
|
-
get [kResponseError]() {
|
|
405
|
-
return true;
|
|
406
|
-
}
|
|
407
|
-
};
|
|
408
|
-
var kSecureProxyConnectionError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_PRX_TLS");
|
|
409
|
-
var SecureProxyConnectionError = class extends UndiciError {
|
|
410
|
-
constructor(cause, message, options = {}) {
|
|
411
|
-
super(message, { cause, ...options });
|
|
412
|
-
this.name = "SecureProxyConnectionError";
|
|
413
|
-
this.message = message || "Secure Proxy Connection failed";
|
|
414
|
-
this.code = "UND_ERR_PRX_TLS";
|
|
415
|
-
this.cause = cause;
|
|
416
|
-
}
|
|
417
|
-
static [Symbol.hasInstance](instance) {
|
|
418
|
-
return instance && instance[kSecureProxyConnectionError] === true;
|
|
419
|
-
}
|
|
420
|
-
get [kSecureProxyConnectionError]() {
|
|
421
|
-
return true;
|
|
422
|
-
}
|
|
423
|
-
};
|
|
424
|
-
var kMaxOriginsReachedError = /* @__PURE__ */ Symbol.for("undici.error.UND_ERR_MAX_ORIGINS_REACHED");
|
|
425
|
-
var MaxOriginsReachedError = class extends UndiciError {
|
|
426
|
-
constructor(message) {
|
|
427
|
-
super(message);
|
|
428
|
-
this.name = "MaxOriginsReachedError";
|
|
429
|
-
this.message = message || "Maximum allowed origins reached";
|
|
430
|
-
this.code = "UND_ERR_MAX_ORIGINS_REACHED";
|
|
431
|
-
}
|
|
432
|
-
static [Symbol.hasInstance](instance) {
|
|
433
|
-
return instance && instance[kMaxOriginsReachedError] === true;
|
|
434
|
-
}
|
|
435
|
-
get [kMaxOriginsReachedError]() {
|
|
436
|
-
return true;
|
|
437
|
-
}
|
|
438
|
-
};
|
|
439
|
-
module2.exports = {
|
|
440
|
-
AbortError,
|
|
441
|
-
HTTPParserError,
|
|
442
|
-
UndiciError,
|
|
443
|
-
HeadersTimeoutError,
|
|
444
|
-
HeadersOverflowError,
|
|
445
|
-
BodyTimeoutError,
|
|
446
|
-
RequestContentLengthMismatchError,
|
|
447
|
-
ConnectTimeoutError,
|
|
448
|
-
InvalidArgumentError,
|
|
449
|
-
InvalidReturnValueError,
|
|
450
|
-
RequestAbortedError,
|
|
451
|
-
ClientDestroyedError,
|
|
452
|
-
ClientClosedError,
|
|
453
|
-
InformationalError,
|
|
454
|
-
SocketError,
|
|
455
|
-
NotSupportedError,
|
|
456
|
-
ResponseContentLengthMismatchError,
|
|
457
|
-
BalancedPoolMissingUpstreamError,
|
|
458
|
-
ResponseExceededMaxSizeError,
|
|
459
|
-
RequestRetryError,
|
|
460
|
-
ResponseError,
|
|
461
|
-
SecureProxyConnectionError,
|
|
462
|
-
MaxOriginsReachedError
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
});
|
|
466
|
-
|
|
467
|
-
// ../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/handler/wrap-handler.js
|
|
468
|
-
var require_wrap_handler = __commonJS({
|
|
469
|
-
"../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/handler/wrap-handler.js"(exports2, module2) {
|
|
470
|
-
"use strict";
|
|
471
|
-
var { InvalidArgumentError } = require_errors();
|
|
472
|
-
module2.exports = class WrapHandler {
|
|
473
|
-
#handler;
|
|
474
|
-
constructor(handler) {
|
|
475
|
-
this.#handler = handler;
|
|
476
|
-
}
|
|
477
|
-
static wrap(handler) {
|
|
478
|
-
return handler.onRequestStart ? handler : new WrapHandler(handler);
|
|
479
|
-
}
|
|
480
|
-
// Unwrap Interface
|
|
481
|
-
onConnect(abort, context) {
|
|
482
|
-
return this.#handler.onConnect?.(abort, context);
|
|
483
|
-
}
|
|
484
|
-
onHeaders(statusCode, rawHeaders, resume, statusMessage) {
|
|
485
|
-
return this.#handler.onHeaders?.(statusCode, rawHeaders, resume, statusMessage);
|
|
486
|
-
}
|
|
487
|
-
onUpgrade(statusCode, rawHeaders, socket) {
|
|
488
|
-
return this.#handler.onUpgrade?.(statusCode, rawHeaders, socket);
|
|
489
|
-
}
|
|
490
|
-
onData(data) {
|
|
491
|
-
return this.#handler.onData?.(data);
|
|
492
|
-
}
|
|
493
|
-
onComplete(trailers) {
|
|
494
|
-
return this.#handler.onComplete?.(trailers);
|
|
495
|
-
}
|
|
496
|
-
onError(err) {
|
|
497
|
-
if (!this.#handler.onError) {
|
|
498
|
-
throw err;
|
|
499
|
-
}
|
|
500
|
-
return this.#handler.onError?.(err);
|
|
501
|
-
}
|
|
502
|
-
// Wrap Interface
|
|
503
|
-
onRequestStart(controller, context) {
|
|
504
|
-
this.#handler.onConnect?.((reason) => controller.abort(reason), context);
|
|
505
|
-
}
|
|
506
|
-
onRequestUpgrade(controller, statusCode, headers, socket) {
|
|
507
|
-
const rawHeaders = [];
|
|
508
|
-
for (const [key, val] of Object.entries(headers)) {
|
|
509
|
-
rawHeaders.push(Buffer.from(key), Array.isArray(val) ? val.map((v) => Buffer.from(v)) : Buffer.from(val));
|
|
510
|
-
}
|
|
511
|
-
this.#handler.onUpgrade?.(statusCode, rawHeaders, socket);
|
|
512
|
-
}
|
|
513
|
-
onResponseStart(controller, statusCode, headers, statusMessage) {
|
|
514
|
-
const rawHeaders = [];
|
|
515
|
-
for (const [key, val] of Object.entries(headers)) {
|
|
516
|
-
rawHeaders.push(Buffer.from(key), Array.isArray(val) ? val.map((v) => Buffer.from(v)) : Buffer.from(val));
|
|
517
|
-
}
|
|
518
|
-
if (this.#handler.onHeaders?.(statusCode, rawHeaders, () => controller.resume(), statusMessage) === false) {
|
|
519
|
-
controller.pause();
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
onResponseData(controller, data) {
|
|
523
|
-
if (this.#handler.onData?.(data) === false) {
|
|
524
|
-
controller.pause();
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
onResponseEnd(controller, trailers) {
|
|
528
|
-
const rawTrailers = [];
|
|
529
|
-
for (const [key, val] of Object.entries(trailers)) {
|
|
530
|
-
rawTrailers.push(Buffer.from(key), Array.isArray(val) ? val.map((v) => Buffer.from(v)) : Buffer.from(val));
|
|
531
|
-
}
|
|
532
|
-
this.#handler.onComplete?.(rawTrailers);
|
|
533
|
-
}
|
|
534
|
-
onResponseError(controller, err) {
|
|
535
|
-
if (!this.#handler.onError) {
|
|
536
|
-
throw new InvalidArgumentError("invalid onError method");
|
|
537
|
-
}
|
|
538
|
-
this.#handler.onError?.(err);
|
|
539
|
-
}
|
|
540
|
-
};
|
|
541
|
-
}
|
|
542
|
-
});
|
|
543
|
-
|
|
544
|
-
// ../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/dispatcher/dispatcher.js
|
|
545
|
-
var require_dispatcher = __commonJS({
|
|
546
|
-
"../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/dispatcher/dispatcher.js"(exports2, module2) {
|
|
547
|
-
"use strict";
|
|
548
|
-
var EventEmitter = require("node:events");
|
|
549
|
-
var WrapHandler = require_wrap_handler();
|
|
550
|
-
var wrapInterceptor = (dispatch) => (opts, handler) => dispatch(opts, WrapHandler.wrap(handler));
|
|
551
|
-
var Dispatcher = class extends EventEmitter {
|
|
552
|
-
dispatch() {
|
|
553
|
-
throw new Error("not implemented");
|
|
554
|
-
}
|
|
555
|
-
close() {
|
|
556
|
-
throw new Error("not implemented");
|
|
557
|
-
}
|
|
558
|
-
destroy() {
|
|
559
|
-
throw new Error("not implemented");
|
|
560
|
-
}
|
|
561
|
-
compose(...args) {
|
|
562
|
-
const interceptors = Array.isArray(args[0]) ? args[0] : args;
|
|
563
|
-
let dispatch = this.dispatch.bind(this);
|
|
564
|
-
for (const interceptor of interceptors) {
|
|
565
|
-
if (interceptor == null) {
|
|
566
|
-
continue;
|
|
567
|
-
}
|
|
568
|
-
if (typeof interceptor !== "function") {
|
|
569
|
-
throw new TypeError(`invalid interceptor, expected function received ${typeof interceptor}`);
|
|
570
|
-
}
|
|
571
|
-
dispatch = interceptor(dispatch);
|
|
572
|
-
dispatch = wrapInterceptor(dispatch);
|
|
573
|
-
if (dispatch == null || typeof dispatch !== "function" || dispatch.length !== 2) {
|
|
574
|
-
throw new TypeError("invalid interceptor");
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
return new Proxy(this, {
|
|
578
|
-
get: (target, key) => key === "dispatch" ? dispatch : target[key]
|
|
579
|
-
});
|
|
580
|
-
}
|
|
581
|
-
};
|
|
582
|
-
module2.exports = Dispatcher;
|
|
583
|
-
}
|
|
584
|
-
});
|
|
585
|
-
|
|
586
|
-
// ../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/util/timers.js
|
|
587
|
-
var require_timers = __commonJS({
|
|
588
|
-
"../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/util/timers.js"(exports2, module2) {
|
|
589
|
-
"use strict";
|
|
590
|
-
var fastNow = 0;
|
|
591
|
-
var RESOLUTION_MS = 1e3;
|
|
592
|
-
var TICK_MS = (RESOLUTION_MS >> 1) - 1;
|
|
593
|
-
var fastNowTimeout;
|
|
594
|
-
var kFastTimer = /* @__PURE__ */ Symbol("kFastTimer");
|
|
595
|
-
var fastTimers = [];
|
|
596
|
-
var NOT_IN_LIST = -2;
|
|
597
|
-
var TO_BE_CLEARED = -1;
|
|
598
|
-
var PENDING = 0;
|
|
599
|
-
var ACTIVE = 1;
|
|
600
|
-
function onTick() {
|
|
601
|
-
fastNow += TICK_MS;
|
|
602
|
-
let idx = 0;
|
|
603
|
-
let len = fastTimers.length;
|
|
604
|
-
while (idx < len) {
|
|
605
|
-
const timer = fastTimers[idx];
|
|
606
|
-
if (timer._state === PENDING) {
|
|
607
|
-
timer._idleStart = fastNow - TICK_MS;
|
|
608
|
-
timer._state = ACTIVE;
|
|
609
|
-
} else if (timer._state === ACTIVE && fastNow >= timer._idleStart + timer._idleTimeout) {
|
|
610
|
-
timer._state = TO_BE_CLEARED;
|
|
611
|
-
timer._idleStart = -1;
|
|
612
|
-
timer._onTimeout(timer._timerArg);
|
|
613
|
-
}
|
|
614
|
-
if (timer._state === TO_BE_CLEARED) {
|
|
615
|
-
timer._state = NOT_IN_LIST;
|
|
616
|
-
if (--len !== 0) {
|
|
617
|
-
fastTimers[idx] = fastTimers[len];
|
|
618
|
-
}
|
|
619
|
-
} else {
|
|
620
|
-
++idx;
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
fastTimers.length = len;
|
|
624
|
-
if (fastTimers.length !== 0) {
|
|
625
|
-
refreshTimeout();
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
function refreshTimeout() {
|
|
629
|
-
if (fastNowTimeout?.refresh) {
|
|
630
|
-
fastNowTimeout.refresh();
|
|
631
|
-
} else {
|
|
632
|
-
clearTimeout(fastNowTimeout);
|
|
633
|
-
fastNowTimeout = setTimeout(onTick, TICK_MS);
|
|
634
|
-
fastNowTimeout?.unref();
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
var FastTimer = class {
|
|
638
|
-
[kFastTimer] = true;
|
|
639
|
-
/**
|
|
640
|
-
* The state of the timer, which can be one of the following:
|
|
641
|
-
* - NOT_IN_LIST (-2)
|
|
642
|
-
* - TO_BE_CLEARED (-1)
|
|
643
|
-
* - PENDING (0)
|
|
644
|
-
* - ACTIVE (1)
|
|
645
|
-
*
|
|
646
|
-
* @type {-2|-1|0|1}
|
|
647
|
-
* @private
|
|
648
|
-
*/
|
|
649
|
-
_state = NOT_IN_LIST;
|
|
650
|
-
/**
|
|
651
|
-
* The number of milliseconds to wait before calling the callback.
|
|
652
|
-
*
|
|
653
|
-
* @type {number}
|
|
654
|
-
* @private
|
|
655
|
-
*/
|
|
656
|
-
_idleTimeout = -1;
|
|
657
|
-
/**
|
|
658
|
-
* The time in milliseconds when the timer was started. This value is used to
|
|
659
|
-
* calculate when the timer should expire.
|
|
660
|
-
*
|
|
661
|
-
* @type {number}
|
|
662
|
-
* @default -1
|
|
663
|
-
* @private
|
|
664
|
-
*/
|
|
665
|
-
_idleStart = -1;
|
|
666
|
-
/**
|
|
667
|
-
* The function to be executed when the timer expires.
|
|
668
|
-
* @type {Function}
|
|
669
|
-
* @private
|
|
670
|
-
*/
|
|
671
|
-
_onTimeout;
|
|
672
|
-
/**
|
|
673
|
-
* The argument to be passed to the callback when the timer expires.
|
|
674
|
-
*
|
|
675
|
-
* @type {*}
|
|
676
|
-
* @private
|
|
677
|
-
*/
|
|
678
|
-
_timerArg;
|
|
679
|
-
/**
|
|
680
|
-
* @constructor
|
|
681
|
-
* @param {Function} callback A function to be executed after the timer
|
|
682
|
-
* expires.
|
|
683
|
-
* @param {number} delay The time, in milliseconds that the timer should wait
|
|
684
|
-
* before the specified function or code is executed.
|
|
685
|
-
* @param {*} arg
|
|
686
|
-
*/
|
|
687
|
-
constructor(callback, delay, arg) {
|
|
688
|
-
this._onTimeout = callback;
|
|
689
|
-
this._idleTimeout = delay;
|
|
690
|
-
this._timerArg = arg;
|
|
691
|
-
this.refresh();
|
|
692
|
-
}
|
|
693
|
-
/**
|
|
694
|
-
* Sets the timer's start time to the current time, and reschedules the timer
|
|
695
|
-
* to call its callback at the previously specified duration adjusted to the
|
|
696
|
-
* current time.
|
|
697
|
-
* Using this on a timer that has already called its callback will reactivate
|
|
698
|
-
* the timer.
|
|
699
|
-
*
|
|
700
|
-
* @returns {void}
|
|
701
|
-
*/
|
|
702
|
-
refresh() {
|
|
703
|
-
if (this._state === NOT_IN_LIST) {
|
|
704
|
-
fastTimers.push(this);
|
|
705
|
-
}
|
|
706
|
-
if (!fastNowTimeout || fastTimers.length === 1) {
|
|
707
|
-
refreshTimeout();
|
|
708
|
-
}
|
|
709
|
-
this._state = PENDING;
|
|
710
|
-
}
|
|
711
|
-
/**
|
|
712
|
-
* The `clear` method cancels the timer, preventing it from executing.
|
|
713
|
-
*
|
|
714
|
-
* @returns {void}
|
|
715
|
-
* @private
|
|
716
|
-
*/
|
|
717
|
-
clear() {
|
|
718
|
-
this._state = TO_BE_CLEARED;
|
|
719
|
-
this._idleStart = -1;
|
|
720
|
-
}
|
|
721
|
-
};
|
|
722
|
-
module2.exports = {
|
|
723
|
-
/**
|
|
724
|
-
* The setTimeout() method sets a timer which executes a function once the
|
|
725
|
-
* timer expires.
|
|
726
|
-
* @param {Function} callback A function to be executed after the timer
|
|
727
|
-
* expires.
|
|
728
|
-
* @param {number} delay The time, in milliseconds that the timer should
|
|
729
|
-
* wait before the specified function or code is executed.
|
|
730
|
-
* @param {*} [arg] An optional argument to be passed to the callback function
|
|
731
|
-
* when the timer expires.
|
|
732
|
-
* @returns {NodeJS.Timeout|FastTimer}
|
|
733
|
-
*/
|
|
734
|
-
setTimeout(callback, delay, arg) {
|
|
735
|
-
return delay <= RESOLUTION_MS ? setTimeout(callback, delay, arg) : new FastTimer(callback, delay, arg);
|
|
736
|
-
},
|
|
737
|
-
/**
|
|
738
|
-
* The clearTimeout method cancels an instantiated Timer previously created
|
|
739
|
-
* by calling setTimeout.
|
|
740
|
-
*
|
|
741
|
-
* @param {NodeJS.Timeout|FastTimer} timeout
|
|
742
|
-
*/
|
|
743
|
-
clearTimeout(timeout) {
|
|
744
|
-
if (timeout[kFastTimer]) {
|
|
745
|
-
timeout.clear();
|
|
746
|
-
} else {
|
|
747
|
-
clearTimeout(timeout);
|
|
748
|
-
}
|
|
749
|
-
},
|
|
750
|
-
/**
|
|
751
|
-
* The setFastTimeout() method sets a fastTimer which executes a function once
|
|
752
|
-
* the timer expires.
|
|
753
|
-
* @param {Function} callback A function to be executed after the timer
|
|
754
|
-
* expires.
|
|
755
|
-
* @param {number} delay The time, in milliseconds that the timer should
|
|
756
|
-
* wait before the specified function or code is executed.
|
|
757
|
-
* @param {*} [arg] An optional argument to be passed to the callback function
|
|
758
|
-
* when the timer expires.
|
|
759
|
-
* @returns {FastTimer}
|
|
760
|
-
*/
|
|
761
|
-
setFastTimeout(callback, delay, arg) {
|
|
762
|
-
return new FastTimer(callback, delay, arg);
|
|
763
|
-
},
|
|
764
|
-
/**
|
|
765
|
-
* The clearTimeout method cancels an instantiated FastTimer previously
|
|
766
|
-
* created by calling setFastTimeout.
|
|
767
|
-
*
|
|
768
|
-
* @param {FastTimer} timeout
|
|
769
|
-
*/
|
|
770
|
-
clearFastTimeout(timeout) {
|
|
771
|
-
timeout.clear();
|
|
772
|
-
},
|
|
773
|
-
/**
|
|
774
|
-
* The now method returns the value of the internal fast timer clock.
|
|
775
|
-
*
|
|
776
|
-
* @returns {number}
|
|
777
|
-
*/
|
|
778
|
-
now() {
|
|
779
|
-
return fastNow;
|
|
780
|
-
},
|
|
781
|
-
/**
|
|
782
|
-
* Trigger the onTick function to process the fastTimers array.
|
|
783
|
-
* Exported for testing purposes only.
|
|
784
|
-
* Marking as deprecated to discourage any use outside of testing.
|
|
785
|
-
* @deprecated
|
|
786
|
-
* @param {number} [delay=0] The delay in milliseconds to add to the now value.
|
|
787
|
-
*/
|
|
788
|
-
tick(delay = 0) {
|
|
789
|
-
fastNow += delay - RESOLUTION_MS + 1;
|
|
790
|
-
onTick();
|
|
791
|
-
onTick();
|
|
792
|
-
},
|
|
793
|
-
/**
|
|
794
|
-
* Reset FastTimers.
|
|
795
|
-
* Exported for testing purposes only.
|
|
796
|
-
* Marking as deprecated to discourage any use outside of testing.
|
|
797
|
-
* @deprecated
|
|
798
|
-
*/
|
|
799
|
-
reset() {
|
|
800
|
-
fastNow = 0;
|
|
801
|
-
fastTimers.length = 0;
|
|
802
|
-
clearTimeout(fastNowTimeout);
|
|
803
|
-
fastNowTimeout = null;
|
|
804
|
-
},
|
|
805
|
-
/**
|
|
806
|
-
* Exporting for testing purposes only.
|
|
807
|
-
* Marking as deprecated to discourage any use outside of testing.
|
|
808
|
-
* @deprecated
|
|
809
|
-
*/
|
|
810
|
-
kFastTimer
|
|
811
|
-
};
|
|
812
|
-
}
|
|
813
|
-
});
|
|
814
|
-
|
|
815
|
-
// ../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/core/constants.js
|
|
816
|
-
var require_constants = __commonJS({
|
|
817
|
-
"../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/core/constants.js"(exports2, module2) {
|
|
818
|
-
"use strict";
|
|
819
|
-
var wellknownHeaderNames = (
|
|
820
|
-
/** @type {const} */
|
|
821
|
-
[
|
|
822
|
-
"Accept",
|
|
823
|
-
"Accept-Encoding",
|
|
824
|
-
"Accept-Language",
|
|
825
|
-
"Accept-Ranges",
|
|
826
|
-
"Access-Control-Allow-Credentials",
|
|
827
|
-
"Access-Control-Allow-Headers",
|
|
828
|
-
"Access-Control-Allow-Methods",
|
|
829
|
-
"Access-Control-Allow-Origin",
|
|
830
|
-
"Access-Control-Expose-Headers",
|
|
831
|
-
"Access-Control-Max-Age",
|
|
832
|
-
"Access-Control-Request-Headers",
|
|
833
|
-
"Access-Control-Request-Method",
|
|
834
|
-
"Age",
|
|
835
|
-
"Allow",
|
|
836
|
-
"Alt-Svc",
|
|
837
|
-
"Alt-Used",
|
|
838
|
-
"Authorization",
|
|
839
|
-
"Cache-Control",
|
|
840
|
-
"Clear-Site-Data",
|
|
841
|
-
"Connection",
|
|
842
|
-
"Content-Disposition",
|
|
843
|
-
"Content-Encoding",
|
|
844
|
-
"Content-Language",
|
|
845
|
-
"Content-Length",
|
|
846
|
-
"Content-Location",
|
|
847
|
-
"Content-Range",
|
|
848
|
-
"Content-Security-Policy",
|
|
849
|
-
"Content-Security-Policy-Report-Only",
|
|
850
|
-
"Content-Type",
|
|
851
|
-
"Cookie",
|
|
852
|
-
"Cross-Origin-Embedder-Policy",
|
|
853
|
-
"Cross-Origin-Opener-Policy",
|
|
854
|
-
"Cross-Origin-Resource-Policy",
|
|
855
|
-
"Date",
|
|
856
|
-
"Device-Memory",
|
|
857
|
-
"Downlink",
|
|
858
|
-
"ECT",
|
|
859
|
-
"ETag",
|
|
860
|
-
"Expect",
|
|
861
|
-
"Expect-CT",
|
|
862
|
-
"Expires",
|
|
863
|
-
"Forwarded",
|
|
864
|
-
"From",
|
|
865
|
-
"Host",
|
|
866
|
-
"If-Match",
|
|
867
|
-
"If-Modified-Since",
|
|
868
|
-
"If-None-Match",
|
|
869
|
-
"If-Range",
|
|
870
|
-
"If-Unmodified-Since",
|
|
871
|
-
"Keep-Alive",
|
|
872
|
-
"Last-Modified",
|
|
873
|
-
"Link",
|
|
874
|
-
"Location",
|
|
875
|
-
"Max-Forwards",
|
|
876
|
-
"Origin",
|
|
877
|
-
"Permissions-Policy",
|
|
878
|
-
"Pragma",
|
|
879
|
-
"Proxy-Authenticate",
|
|
880
|
-
"Proxy-Authorization",
|
|
881
|
-
"RTT",
|
|
882
|
-
"Range",
|
|
883
|
-
"Referer",
|
|
884
|
-
"Referrer-Policy",
|
|
885
|
-
"Refresh",
|
|
886
|
-
"Retry-After",
|
|
887
|
-
"Sec-WebSocket-Accept",
|
|
888
|
-
"Sec-WebSocket-Extensions",
|
|
889
|
-
"Sec-WebSocket-Key",
|
|
890
|
-
"Sec-WebSocket-Protocol",
|
|
891
|
-
"Sec-WebSocket-Version",
|
|
892
|
-
"Server",
|
|
893
|
-
"Server-Timing",
|
|
894
|
-
"Service-Worker-Allowed",
|
|
895
|
-
"Service-Worker-Navigation-Preload",
|
|
896
|
-
"Set-Cookie",
|
|
897
|
-
"SourceMap",
|
|
898
|
-
"Strict-Transport-Security",
|
|
899
|
-
"Supports-Loading-Mode",
|
|
900
|
-
"TE",
|
|
901
|
-
"Timing-Allow-Origin",
|
|
902
|
-
"Trailer",
|
|
903
|
-
"Transfer-Encoding",
|
|
904
|
-
"Upgrade",
|
|
905
|
-
"Upgrade-Insecure-Requests",
|
|
906
|
-
"User-Agent",
|
|
907
|
-
"Vary",
|
|
908
|
-
"Via",
|
|
909
|
-
"WWW-Authenticate",
|
|
910
|
-
"X-Content-Type-Options",
|
|
911
|
-
"X-DNS-Prefetch-Control",
|
|
912
|
-
"X-Frame-Options",
|
|
913
|
-
"X-Permitted-Cross-Domain-Policies",
|
|
914
|
-
"X-Powered-By",
|
|
915
|
-
"X-Requested-With",
|
|
916
|
-
"X-XSS-Protection"
|
|
917
|
-
]
|
|
918
|
-
);
|
|
919
|
-
var headerNameLowerCasedRecord = {};
|
|
920
|
-
Object.setPrototypeOf(headerNameLowerCasedRecord, null);
|
|
921
|
-
var wellknownHeaderNameBuffers = {};
|
|
922
|
-
Object.setPrototypeOf(wellknownHeaderNameBuffers, null);
|
|
923
|
-
function getHeaderNameAsBuffer(header) {
|
|
924
|
-
let buffer = wellknownHeaderNameBuffers[header];
|
|
925
|
-
if (buffer === void 0) {
|
|
926
|
-
buffer = Buffer.from(header);
|
|
927
|
-
}
|
|
928
|
-
return buffer;
|
|
929
|
-
}
|
|
930
|
-
for (let i = 0; i < wellknownHeaderNames.length; ++i) {
|
|
931
|
-
const key = wellknownHeaderNames[i];
|
|
932
|
-
const lowerCasedKey = key.toLowerCase();
|
|
933
|
-
headerNameLowerCasedRecord[key] = headerNameLowerCasedRecord[lowerCasedKey] = lowerCasedKey;
|
|
934
|
-
}
|
|
935
|
-
module2.exports = {
|
|
936
|
-
wellknownHeaderNames,
|
|
937
|
-
headerNameLowerCasedRecord,
|
|
938
|
-
getHeaderNameAsBuffer
|
|
939
|
-
};
|
|
940
|
-
}
|
|
941
|
-
});
|
|
942
|
-
|
|
943
|
-
// ../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/core/tree.js
|
|
944
|
-
var require_tree = __commonJS({
|
|
945
|
-
"../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/core/tree.js"(exports2, module2) {
|
|
946
|
-
"use strict";
|
|
947
|
-
var {
|
|
948
|
-
wellknownHeaderNames,
|
|
949
|
-
headerNameLowerCasedRecord
|
|
950
|
-
} = require_constants();
|
|
951
|
-
var TstNode = class _TstNode {
|
|
952
|
-
/** @type {any} */
|
|
953
|
-
value = null;
|
|
954
|
-
/** @type {null | TstNode} */
|
|
955
|
-
left = null;
|
|
956
|
-
/** @type {null | TstNode} */
|
|
957
|
-
middle = null;
|
|
958
|
-
/** @type {null | TstNode} */
|
|
959
|
-
right = null;
|
|
960
|
-
/** @type {number} */
|
|
961
|
-
code;
|
|
962
|
-
/**
|
|
963
|
-
* @param {string} key
|
|
964
|
-
* @param {any} value
|
|
965
|
-
* @param {number} index
|
|
966
|
-
*/
|
|
967
|
-
constructor(key, value, index) {
|
|
968
|
-
if (index === void 0 || index >= key.length) {
|
|
969
|
-
throw new TypeError("Unreachable");
|
|
970
|
-
}
|
|
971
|
-
const code = this.code = key.charCodeAt(index);
|
|
972
|
-
if (code > 127) {
|
|
973
|
-
throw new TypeError("key must be ascii string");
|
|
974
|
-
}
|
|
975
|
-
if (key.length !== ++index) {
|
|
976
|
-
this.middle = new _TstNode(key, value, index);
|
|
977
|
-
} else {
|
|
978
|
-
this.value = value;
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
|
-
/**
|
|
982
|
-
* @param {string} key
|
|
983
|
-
* @param {any} value
|
|
984
|
-
* @returns {void}
|
|
985
|
-
*/
|
|
986
|
-
add(key, value) {
|
|
987
|
-
const length = key.length;
|
|
988
|
-
if (length === 0) {
|
|
989
|
-
throw new TypeError("Unreachable");
|
|
990
|
-
}
|
|
991
|
-
let index = 0;
|
|
992
|
-
let node = this;
|
|
993
|
-
while (true) {
|
|
994
|
-
const code = key.charCodeAt(index);
|
|
995
|
-
if (code > 127) {
|
|
996
|
-
throw new TypeError("key must be ascii string");
|
|
997
|
-
}
|
|
998
|
-
if (node.code === code) {
|
|
999
|
-
if (length === ++index) {
|
|
1000
|
-
node.value = value;
|
|
1001
|
-
break;
|
|
1002
|
-
} else if (node.middle !== null) {
|
|
1003
|
-
node = node.middle;
|
|
1004
|
-
} else {
|
|
1005
|
-
node.middle = new _TstNode(key, value, index);
|
|
1006
|
-
break;
|
|
1007
|
-
}
|
|
1008
|
-
} else if (node.code < code) {
|
|
1009
|
-
if (node.left !== null) {
|
|
1010
|
-
node = node.left;
|
|
1011
|
-
} else {
|
|
1012
|
-
node.left = new _TstNode(key, value, index);
|
|
1013
|
-
break;
|
|
1014
|
-
}
|
|
1015
|
-
} else if (node.right !== null) {
|
|
1016
|
-
node = node.right;
|
|
1017
|
-
} else {
|
|
1018
|
-
node.right = new _TstNode(key, value, index);
|
|
1019
|
-
break;
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
}
|
|
1023
|
-
/**
|
|
1024
|
-
* @param {Uint8Array} key
|
|
1025
|
-
* @returns {TstNode | null}
|
|
1026
|
-
*/
|
|
1027
|
-
search(key) {
|
|
1028
|
-
const keylength = key.length;
|
|
1029
|
-
let index = 0;
|
|
1030
|
-
let node = this;
|
|
1031
|
-
while (node !== null && index < keylength) {
|
|
1032
|
-
let code = key[index];
|
|
1033
|
-
if (code <= 90 && code >= 65) {
|
|
1034
|
-
code |= 32;
|
|
1035
|
-
}
|
|
1036
|
-
while (node !== null) {
|
|
1037
|
-
if (code === node.code) {
|
|
1038
|
-
if (keylength === ++index) {
|
|
1039
|
-
return node;
|
|
1040
|
-
}
|
|
1041
|
-
node = node.middle;
|
|
1042
|
-
break;
|
|
1043
|
-
}
|
|
1044
|
-
node = node.code < code ? node.left : node.right;
|
|
1045
|
-
}
|
|
1046
|
-
}
|
|
1047
|
-
return null;
|
|
1048
|
-
}
|
|
1049
|
-
};
|
|
1050
|
-
var TernarySearchTree = class {
|
|
1051
|
-
/** @type {TstNode | null} */
|
|
1052
|
-
node = null;
|
|
1053
|
-
/**
|
|
1054
|
-
* @param {string} key
|
|
1055
|
-
* @param {any} value
|
|
1056
|
-
* @returns {void}
|
|
1057
|
-
* */
|
|
1058
|
-
insert(key, value) {
|
|
1059
|
-
if (this.node === null) {
|
|
1060
|
-
this.node = new TstNode(key, value, 0);
|
|
1061
|
-
} else {
|
|
1062
|
-
this.node.add(key, value);
|
|
1063
|
-
}
|
|
1064
|
-
}
|
|
1065
|
-
/**
|
|
1066
|
-
* @param {Uint8Array} key
|
|
1067
|
-
* @returns {any}
|
|
1068
|
-
*/
|
|
1069
|
-
lookup(key) {
|
|
1070
|
-
return this.node?.search(key)?.value ?? null;
|
|
1071
|
-
}
|
|
1072
|
-
};
|
|
1073
|
-
var tree = new TernarySearchTree();
|
|
1074
|
-
for (let i = 0; i < wellknownHeaderNames.length; ++i) {
|
|
1075
|
-
const key = headerNameLowerCasedRecord[wellknownHeaderNames[i]];
|
|
1076
|
-
tree.insert(key, key);
|
|
1077
|
-
}
|
|
1078
|
-
module2.exports = {
|
|
1079
|
-
TernarySearchTree,
|
|
1080
|
-
tree
|
|
1081
|
-
};
|
|
1082
|
-
}
|
|
1083
|
-
});
|
|
1084
|
-
|
|
1085
|
-
// ../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/core/util.js
|
|
1086
|
-
var require_util = __commonJS({
|
|
1087
|
-
"../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/core/util.js"(exports2, module2) {
|
|
1088
|
-
"use strict";
|
|
1089
|
-
var assert = require("node:assert");
|
|
1090
|
-
var { kDestroyed, kBodyUsed, kListeners, kBody } = require_symbols();
|
|
1091
|
-
var { IncomingMessage } = require("node:http");
|
|
1092
|
-
var stream = require("node:stream");
|
|
1093
|
-
var net = require("node:net");
|
|
1094
|
-
var { stringify } = require("node:querystring");
|
|
1095
|
-
var { EventEmitter: EE } = require("node:events");
|
|
1096
|
-
var timers = require_timers();
|
|
1097
|
-
var { InvalidArgumentError, ConnectTimeoutError } = require_errors();
|
|
1098
|
-
var { headerNameLowerCasedRecord } = require_constants();
|
|
1099
|
-
var { tree } = require_tree();
|
|
1100
|
-
var [nodeMajor, nodeMinor] = process.versions.node.split(".", 2).map((v) => Number(v));
|
|
1101
|
-
var BodyAsyncIterable = class {
|
|
1102
|
-
constructor(body) {
|
|
1103
|
-
this[kBody] = body;
|
|
1104
|
-
this[kBodyUsed] = false;
|
|
1105
|
-
}
|
|
1106
|
-
async *[Symbol.asyncIterator]() {
|
|
1107
|
-
assert(!this[kBodyUsed], "disturbed");
|
|
1108
|
-
this[kBodyUsed] = true;
|
|
1109
|
-
yield* this[kBody];
|
|
1110
|
-
}
|
|
1111
|
-
};
|
|
1112
|
-
function noop() {
|
|
1113
|
-
}
|
|
1114
|
-
function wrapRequestBody(body) {
|
|
1115
|
-
if (isStream(body)) {
|
|
1116
|
-
if (bodyLength(body) === 0) {
|
|
1117
|
-
body.on("data", function() {
|
|
1118
|
-
assert(false);
|
|
1119
|
-
});
|
|
1120
|
-
}
|
|
1121
|
-
if (typeof body.readableDidRead !== "boolean") {
|
|
1122
|
-
body[kBodyUsed] = false;
|
|
1123
|
-
EE.prototype.on.call(body, "data", function() {
|
|
1124
|
-
this[kBodyUsed] = true;
|
|
1125
|
-
});
|
|
1126
|
-
}
|
|
1127
|
-
return body;
|
|
1128
|
-
} else if (body && typeof body.pipeTo === "function") {
|
|
1129
|
-
return new BodyAsyncIterable(body);
|
|
1130
|
-
} else if (body && typeof body !== "string" && !ArrayBuffer.isView(body) && isIterable(body)) {
|
|
1131
|
-
return new BodyAsyncIterable(body);
|
|
1132
|
-
} else {
|
|
1133
|
-
return body;
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
|
-
function isStream(obj) {
|
|
1137
|
-
return obj && typeof obj === "object" && typeof obj.pipe === "function" && typeof obj.on === "function";
|
|
1138
|
-
}
|
|
1139
|
-
function isBlobLike(object) {
|
|
1140
|
-
if (object === null) {
|
|
1141
|
-
return false;
|
|
1142
|
-
} else if (object instanceof Blob) {
|
|
1143
|
-
return true;
|
|
1144
|
-
} else if (typeof object !== "object") {
|
|
1145
|
-
return false;
|
|
1146
|
-
} else {
|
|
1147
|
-
const sTag = object[Symbol.toStringTag];
|
|
1148
|
-
return (sTag === "Blob" || sTag === "File") && ("stream" in object && typeof object.stream === "function" || "arrayBuffer" in object && typeof object.arrayBuffer === "function");
|
|
1149
|
-
}
|
|
1150
|
-
}
|
|
1151
|
-
function pathHasQueryOrFragment(url) {
|
|
1152
|
-
return url.includes("?") || url.includes("#");
|
|
1153
|
-
}
|
|
1154
|
-
function serializePathWithQuery(url, queryParams) {
|
|
1155
|
-
if (pathHasQueryOrFragment(url)) {
|
|
1156
|
-
throw new Error('Query params cannot be passed when url already contains "?" or "#".');
|
|
1157
|
-
}
|
|
1158
|
-
const stringified = stringify(queryParams);
|
|
1159
|
-
if (stringified) {
|
|
1160
|
-
url += "?" + stringified;
|
|
1161
|
-
}
|
|
1162
|
-
return url;
|
|
1163
|
-
}
|
|
1164
|
-
function isValidPort(port) {
|
|
1165
|
-
const value = parseInt(port, 10);
|
|
1166
|
-
return value === Number(port) && value >= 0 && value <= 65535;
|
|
1167
|
-
}
|
|
1168
|
-
function isHttpOrHttpsPrefixed(value) {
|
|
1169
|
-
return value != null && value[0] === "h" && value[1] === "t" && value[2] === "t" && value[3] === "p" && (value[4] === ":" || value[4] === "s" && value[5] === ":");
|
|
1170
|
-
}
|
|
1171
|
-
function parseURL(url) {
|
|
1172
|
-
if (typeof url === "string") {
|
|
1173
|
-
url = new URL(url);
|
|
1174
|
-
if (!isHttpOrHttpsPrefixed(url.origin || url.protocol)) {
|
|
1175
|
-
throw new InvalidArgumentError("Invalid URL protocol: the URL must start with `http:` or `https:`.");
|
|
1176
|
-
}
|
|
1177
|
-
return url;
|
|
1178
|
-
}
|
|
1179
|
-
if (!url || typeof url !== "object") {
|
|
1180
|
-
throw new InvalidArgumentError("Invalid URL: The URL argument must be a non-null object.");
|
|
1181
|
-
}
|
|
1182
|
-
if (!(url instanceof URL)) {
|
|
1183
|
-
if (url.port != null && url.port !== "" && isValidPort(url.port) === false) {
|
|
1184
|
-
throw new InvalidArgumentError("Invalid URL: port must be a valid integer or a string representation of an integer.");
|
|
1185
|
-
}
|
|
1186
|
-
if (url.path != null && typeof url.path !== "string") {
|
|
1187
|
-
throw new InvalidArgumentError("Invalid URL path: the path must be a string or null/undefined.");
|
|
1188
|
-
}
|
|
1189
|
-
if (url.pathname != null && typeof url.pathname !== "string") {
|
|
1190
|
-
throw new InvalidArgumentError("Invalid URL pathname: the pathname must be a string or null/undefined.");
|
|
1191
|
-
}
|
|
1192
|
-
if (url.hostname != null && typeof url.hostname !== "string") {
|
|
1193
|
-
throw new InvalidArgumentError("Invalid URL hostname: the hostname must be a string or null/undefined.");
|
|
1194
|
-
}
|
|
1195
|
-
if (url.origin != null && typeof url.origin !== "string") {
|
|
1196
|
-
throw new InvalidArgumentError("Invalid URL origin: the origin must be a string or null/undefined.");
|
|
1197
|
-
}
|
|
1198
|
-
if (!isHttpOrHttpsPrefixed(url.origin || url.protocol)) {
|
|
1199
|
-
throw new InvalidArgumentError("Invalid URL protocol: the URL must start with `http:` or `https:`.");
|
|
1200
|
-
}
|
|
1201
|
-
const port = url.port != null ? url.port : url.protocol === "https:" ? 443 : 80;
|
|
1202
|
-
let origin = url.origin != null ? url.origin : `${url.protocol || ""}//${url.hostname || ""}:${port}`;
|
|
1203
|
-
let path = url.path != null ? url.path : `${url.pathname || ""}${url.search || ""}`;
|
|
1204
|
-
if (origin[origin.length - 1] === "/") {
|
|
1205
|
-
origin = origin.slice(0, origin.length - 1);
|
|
1206
|
-
}
|
|
1207
|
-
if (path && path[0] !== "/") {
|
|
1208
|
-
path = `/${path}`;
|
|
1209
|
-
}
|
|
1210
|
-
return new URL(`${origin}${path}`);
|
|
1211
|
-
}
|
|
1212
|
-
if (!isHttpOrHttpsPrefixed(url.origin || url.protocol)) {
|
|
1213
|
-
throw new InvalidArgumentError("Invalid URL protocol: the URL must start with `http:` or `https:`.");
|
|
1214
|
-
}
|
|
1215
|
-
return url;
|
|
1216
|
-
}
|
|
1217
|
-
function parseOrigin(url) {
|
|
1218
|
-
url = parseURL(url);
|
|
1219
|
-
if (url.pathname !== "/" || url.search || url.hash) {
|
|
1220
|
-
throw new InvalidArgumentError("invalid url");
|
|
1221
|
-
}
|
|
1222
|
-
return url;
|
|
1223
|
-
}
|
|
1224
|
-
function getHostname(host) {
|
|
1225
|
-
if (host[0] === "[") {
|
|
1226
|
-
const idx2 = host.indexOf("]");
|
|
1227
|
-
assert(idx2 !== -1);
|
|
1228
|
-
return host.substring(1, idx2);
|
|
1229
|
-
}
|
|
1230
|
-
const idx = host.indexOf(":");
|
|
1231
|
-
if (idx === -1) return host;
|
|
1232
|
-
return host.substring(0, idx);
|
|
1233
|
-
}
|
|
1234
|
-
function getServerName(host) {
|
|
1235
|
-
if (!host) {
|
|
1236
|
-
return null;
|
|
1237
|
-
}
|
|
1238
|
-
assert(typeof host === "string");
|
|
1239
|
-
const servername = getHostname(host);
|
|
1240
|
-
if (net.isIP(servername)) {
|
|
1241
|
-
return "";
|
|
1242
|
-
}
|
|
1243
|
-
return servername;
|
|
1244
|
-
}
|
|
1245
|
-
function deepClone(obj) {
|
|
1246
|
-
return JSON.parse(JSON.stringify(obj));
|
|
1247
|
-
}
|
|
1248
|
-
function isAsyncIterable(obj) {
|
|
1249
|
-
return !!(obj != null && typeof obj[Symbol.asyncIterator] === "function");
|
|
1250
|
-
}
|
|
1251
|
-
function isIterable(obj) {
|
|
1252
|
-
return !!(obj != null && (typeof obj[Symbol.iterator] === "function" || typeof obj[Symbol.asyncIterator] === "function"));
|
|
1253
|
-
}
|
|
1254
|
-
function bodyLength(body) {
|
|
1255
|
-
if (body == null) {
|
|
1256
|
-
return 0;
|
|
1257
|
-
} else if (isStream(body)) {
|
|
1258
|
-
const state = body._readableState;
|
|
1259
|
-
return state && state.objectMode === false && state.ended === true && Number.isFinite(state.length) ? state.length : null;
|
|
1260
|
-
} else if (isBlobLike(body)) {
|
|
1261
|
-
return body.size != null ? body.size : null;
|
|
1262
|
-
} else if (isBuffer(body)) {
|
|
1263
|
-
return body.byteLength;
|
|
1264
|
-
}
|
|
1265
|
-
return null;
|
|
1266
|
-
}
|
|
1267
|
-
function isDestroyed(body) {
|
|
1268
|
-
return body && !!(body.destroyed || body[kDestroyed] || stream.isDestroyed?.(body));
|
|
1269
|
-
}
|
|
1270
|
-
function destroy(stream2, err) {
|
|
1271
|
-
if (stream2 == null || !isStream(stream2) || isDestroyed(stream2)) {
|
|
1272
|
-
return;
|
|
1273
|
-
}
|
|
1274
|
-
if (typeof stream2.destroy === "function") {
|
|
1275
|
-
if (Object.getPrototypeOf(stream2).constructor === IncomingMessage) {
|
|
1276
|
-
stream2.socket = null;
|
|
1277
|
-
}
|
|
1278
|
-
stream2.destroy(err);
|
|
1279
|
-
} else if (err) {
|
|
1280
|
-
queueMicrotask(() => {
|
|
1281
|
-
stream2.emit("error", err);
|
|
1282
|
-
});
|
|
1283
|
-
}
|
|
1284
|
-
if (stream2.destroyed !== true) {
|
|
1285
|
-
stream2[kDestroyed] = true;
|
|
1286
|
-
}
|
|
1287
|
-
}
|
|
1288
|
-
var KEEPALIVE_TIMEOUT_EXPR = /timeout=(\d+)/;
|
|
1289
|
-
function parseKeepAliveTimeout(val) {
|
|
1290
|
-
const m = val.match(KEEPALIVE_TIMEOUT_EXPR);
|
|
1291
|
-
return m ? parseInt(m[1], 10) * 1e3 : null;
|
|
1292
|
-
}
|
|
1293
|
-
function headerNameToString(value) {
|
|
1294
|
-
return typeof value === "string" ? headerNameLowerCasedRecord[value] ?? value.toLowerCase() : tree.lookup(value) ?? value.toString("latin1").toLowerCase();
|
|
1295
|
-
}
|
|
1296
|
-
function bufferToLowerCasedHeaderName(value) {
|
|
1297
|
-
return tree.lookup(value) ?? value.toString("latin1").toLowerCase();
|
|
1298
|
-
}
|
|
1299
|
-
function parseHeaders(headers, obj) {
|
|
1300
|
-
if (obj === void 0) obj = {};
|
|
1301
|
-
for (let i = 0; i < headers.length; i += 2) {
|
|
1302
|
-
const key = headerNameToString(headers[i]);
|
|
1303
|
-
let val = obj[key];
|
|
1304
|
-
if (val) {
|
|
1305
|
-
if (typeof val === "string") {
|
|
1306
|
-
val = [val];
|
|
1307
|
-
obj[key] = val;
|
|
1308
|
-
}
|
|
1309
|
-
val.push(headers[i + 1].toString("utf8"));
|
|
1310
|
-
} else {
|
|
1311
|
-
const headersValue = headers[i + 1];
|
|
1312
|
-
if (typeof headersValue === "string") {
|
|
1313
|
-
obj[key] = headersValue;
|
|
1314
|
-
} else {
|
|
1315
|
-
obj[key] = Array.isArray(headersValue) ? headersValue.map((x) => x.toString("utf8")) : headersValue.toString("utf8");
|
|
1316
|
-
}
|
|
1317
|
-
}
|
|
1318
|
-
}
|
|
1319
|
-
if ("content-length" in obj && "content-disposition" in obj) {
|
|
1320
|
-
obj["content-disposition"] = Buffer.from(obj["content-disposition"]).toString("latin1");
|
|
1321
|
-
}
|
|
1322
|
-
return obj;
|
|
1323
|
-
}
|
|
1324
|
-
function parseRawHeaders(headers) {
|
|
1325
|
-
const headersLength = headers.length;
|
|
1326
|
-
const ret = new Array(headersLength);
|
|
1327
|
-
let hasContentLength = false;
|
|
1328
|
-
let contentDispositionIdx = -1;
|
|
1329
|
-
let key;
|
|
1330
|
-
let val;
|
|
1331
|
-
let kLen = 0;
|
|
1332
|
-
for (let n = 0; n < headersLength; n += 2) {
|
|
1333
|
-
key = headers[n];
|
|
1334
|
-
val = headers[n + 1];
|
|
1335
|
-
typeof key !== "string" && (key = key.toString());
|
|
1336
|
-
typeof val !== "string" && (val = val.toString("utf8"));
|
|
1337
|
-
kLen = key.length;
|
|
1338
|
-
if (kLen === 14 && key[7] === "-" && (key === "content-length" || key.toLowerCase() === "content-length")) {
|
|
1339
|
-
hasContentLength = true;
|
|
1340
|
-
} else if (kLen === 19 && key[7] === "-" && (key === "content-disposition" || key.toLowerCase() === "content-disposition")) {
|
|
1341
|
-
contentDispositionIdx = n + 1;
|
|
1342
|
-
}
|
|
1343
|
-
ret[n] = key;
|
|
1344
|
-
ret[n + 1] = val;
|
|
1345
|
-
}
|
|
1346
|
-
if (hasContentLength && contentDispositionIdx !== -1) {
|
|
1347
|
-
ret[contentDispositionIdx] = Buffer.from(ret[contentDispositionIdx]).toString("latin1");
|
|
1348
|
-
}
|
|
1349
|
-
return ret;
|
|
1350
|
-
}
|
|
1351
|
-
function encodeRawHeaders(headers) {
|
|
1352
|
-
if (!Array.isArray(headers)) {
|
|
1353
|
-
throw new TypeError("expected headers to be an array");
|
|
1354
|
-
}
|
|
1355
|
-
return headers.map((x) => Buffer.from(x));
|
|
1356
|
-
}
|
|
1357
|
-
function isBuffer(buffer) {
|
|
1358
|
-
return buffer instanceof Uint8Array || Buffer.isBuffer(buffer);
|
|
1359
|
-
}
|
|
1360
|
-
function assertRequestHandler(handler, method, upgrade) {
|
|
1361
|
-
if (!handler || typeof handler !== "object") {
|
|
1362
|
-
throw new InvalidArgumentError("handler must be an object");
|
|
1363
|
-
}
|
|
1364
|
-
if (typeof handler.onRequestStart === "function") {
|
|
1365
|
-
return;
|
|
1366
|
-
}
|
|
1367
|
-
if (typeof handler.onConnect !== "function") {
|
|
1368
|
-
throw new InvalidArgumentError("invalid onConnect method");
|
|
1369
|
-
}
|
|
1370
|
-
if (typeof handler.onError !== "function") {
|
|
1371
|
-
throw new InvalidArgumentError("invalid onError method");
|
|
1372
|
-
}
|
|
1373
|
-
if (typeof handler.onBodySent !== "function" && handler.onBodySent !== void 0) {
|
|
1374
|
-
throw new InvalidArgumentError("invalid onBodySent method");
|
|
1375
|
-
}
|
|
1376
|
-
if (upgrade || method === "CONNECT") {
|
|
1377
|
-
if (typeof handler.onUpgrade !== "function") {
|
|
1378
|
-
throw new InvalidArgumentError("invalid onUpgrade method");
|
|
1379
|
-
}
|
|
1380
|
-
} else {
|
|
1381
|
-
if (typeof handler.onHeaders !== "function") {
|
|
1382
|
-
throw new InvalidArgumentError("invalid onHeaders method");
|
|
1383
|
-
}
|
|
1384
|
-
if (typeof handler.onData !== "function") {
|
|
1385
|
-
throw new InvalidArgumentError("invalid onData method");
|
|
1386
|
-
}
|
|
1387
|
-
if (typeof handler.onComplete !== "function") {
|
|
1388
|
-
throw new InvalidArgumentError("invalid onComplete method");
|
|
1389
|
-
}
|
|
1390
|
-
}
|
|
1391
|
-
}
|
|
1392
|
-
function isDisturbed(body) {
|
|
1393
|
-
return !!(body && (stream.isDisturbed(body) || body[kBodyUsed]));
|
|
1394
|
-
}
|
|
1395
|
-
function getSocketInfo(socket) {
|
|
1396
|
-
return {
|
|
1397
|
-
localAddress: socket.localAddress,
|
|
1398
|
-
localPort: socket.localPort,
|
|
1399
|
-
remoteAddress: socket.remoteAddress,
|
|
1400
|
-
remotePort: socket.remotePort,
|
|
1401
|
-
remoteFamily: socket.remoteFamily,
|
|
1402
|
-
timeout: socket.timeout,
|
|
1403
|
-
bytesWritten: socket.bytesWritten,
|
|
1404
|
-
bytesRead: socket.bytesRead
|
|
1405
|
-
};
|
|
1406
|
-
}
|
|
1407
|
-
function ReadableStreamFrom(iterable) {
|
|
1408
|
-
let iterator;
|
|
1409
|
-
return new ReadableStream(
|
|
1410
|
-
{
|
|
1411
|
-
start() {
|
|
1412
|
-
iterator = iterable[Symbol.asyncIterator]();
|
|
1413
|
-
},
|
|
1414
|
-
pull(controller) {
|
|
1415
|
-
return iterator.next().then(({ done, value }) => {
|
|
1416
|
-
if (done) {
|
|
1417
|
-
return queueMicrotask(() => {
|
|
1418
|
-
controller.close();
|
|
1419
|
-
controller.byobRequest?.respond(0);
|
|
1420
|
-
});
|
|
1421
|
-
} else {
|
|
1422
|
-
const buf = Buffer.isBuffer(value) ? value : Buffer.from(value);
|
|
1423
|
-
if (buf.byteLength) {
|
|
1424
|
-
return controller.enqueue(new Uint8Array(buf));
|
|
1425
|
-
} else {
|
|
1426
|
-
return this.pull(controller);
|
|
1427
|
-
}
|
|
1428
|
-
}
|
|
1429
|
-
});
|
|
1430
|
-
},
|
|
1431
|
-
cancel() {
|
|
1432
|
-
return iterator.return();
|
|
1433
|
-
},
|
|
1434
|
-
type: "bytes"
|
|
1435
|
-
}
|
|
1436
|
-
);
|
|
1437
|
-
}
|
|
1438
|
-
function isFormDataLike(object) {
|
|
1439
|
-
return object && typeof object === "object" && typeof object.append === "function" && typeof object.delete === "function" && typeof object.get === "function" && typeof object.getAll === "function" && typeof object.has === "function" && typeof object.set === "function" && object[Symbol.toStringTag] === "FormData";
|
|
1440
|
-
}
|
|
1441
|
-
function addAbortListener(signal, listener) {
|
|
1442
|
-
if ("addEventListener" in signal) {
|
|
1443
|
-
signal.addEventListener("abort", listener, { once: true });
|
|
1444
|
-
return () => signal.removeEventListener("abort", listener);
|
|
1445
|
-
}
|
|
1446
|
-
signal.once("abort", listener);
|
|
1447
|
-
return () => signal.removeListener("abort", listener);
|
|
1448
|
-
}
|
|
1449
|
-
var validTokenChars = new Uint8Array([
|
|
1450
|
-
0,
|
|
1451
|
-
0,
|
|
1452
|
-
0,
|
|
1453
|
-
0,
|
|
1454
|
-
0,
|
|
1455
|
-
0,
|
|
1456
|
-
0,
|
|
1457
|
-
0,
|
|
1458
|
-
0,
|
|
1459
|
-
0,
|
|
1460
|
-
0,
|
|
1461
|
-
0,
|
|
1462
|
-
0,
|
|
1463
|
-
0,
|
|
1464
|
-
0,
|
|
1465
|
-
0,
|
|
1466
|
-
// 0-15
|
|
1467
|
-
0,
|
|
1468
|
-
0,
|
|
1469
|
-
0,
|
|
1470
|
-
0,
|
|
1471
|
-
0,
|
|
1472
|
-
0,
|
|
1473
|
-
0,
|
|
1474
|
-
0,
|
|
1475
|
-
0,
|
|
1476
|
-
0,
|
|
1477
|
-
0,
|
|
1478
|
-
0,
|
|
1479
|
-
0,
|
|
1480
|
-
0,
|
|
1481
|
-
0,
|
|
1482
|
-
0,
|
|
1483
|
-
// 16-31
|
|
1484
|
-
0,
|
|
1485
|
-
1,
|
|
1486
|
-
0,
|
|
1487
|
-
1,
|
|
1488
|
-
1,
|
|
1489
|
-
1,
|
|
1490
|
-
1,
|
|
1491
|
-
1,
|
|
1492
|
-
0,
|
|
1493
|
-
0,
|
|
1494
|
-
1,
|
|
1495
|
-
1,
|
|
1496
|
-
0,
|
|
1497
|
-
1,
|
|
1498
|
-
1,
|
|
1499
|
-
0,
|
|
1500
|
-
// 32-47 (!"#$%&'()*+,-./)
|
|
1501
|
-
1,
|
|
1502
|
-
1,
|
|
1503
|
-
1,
|
|
1504
|
-
1,
|
|
1505
|
-
1,
|
|
1506
|
-
1,
|
|
1507
|
-
1,
|
|
1508
|
-
1,
|
|
1509
|
-
1,
|
|
1510
|
-
1,
|
|
1511
|
-
0,
|
|
1512
|
-
0,
|
|
1513
|
-
0,
|
|
1514
|
-
0,
|
|
1515
|
-
0,
|
|
1516
|
-
0,
|
|
1517
|
-
// 48-63 (0-9:;<=>?)
|
|
1518
|
-
0,
|
|
1519
|
-
1,
|
|
1520
|
-
1,
|
|
1521
|
-
1,
|
|
1522
|
-
1,
|
|
1523
|
-
1,
|
|
1524
|
-
1,
|
|
1525
|
-
1,
|
|
1526
|
-
1,
|
|
1527
|
-
1,
|
|
1528
|
-
1,
|
|
1529
|
-
1,
|
|
1530
|
-
1,
|
|
1531
|
-
1,
|
|
1532
|
-
1,
|
|
1533
|
-
1,
|
|
1534
|
-
// 64-79 (@A-O)
|
|
1535
|
-
1,
|
|
1536
|
-
1,
|
|
1537
|
-
1,
|
|
1538
|
-
1,
|
|
1539
|
-
1,
|
|
1540
|
-
1,
|
|
1541
|
-
1,
|
|
1542
|
-
1,
|
|
1543
|
-
1,
|
|
1544
|
-
1,
|
|
1545
|
-
1,
|
|
1546
|
-
0,
|
|
1547
|
-
0,
|
|
1548
|
-
0,
|
|
1549
|
-
1,
|
|
1550
|
-
1,
|
|
1551
|
-
// 80-95 (P-Z[\]^_)
|
|
1552
|
-
1,
|
|
1553
|
-
1,
|
|
1554
|
-
1,
|
|
1555
|
-
1,
|
|
1556
|
-
1,
|
|
1557
|
-
1,
|
|
1558
|
-
1,
|
|
1559
|
-
1,
|
|
1560
|
-
1,
|
|
1561
|
-
1,
|
|
1562
|
-
1,
|
|
1563
|
-
1,
|
|
1564
|
-
1,
|
|
1565
|
-
1,
|
|
1566
|
-
1,
|
|
1567
|
-
1,
|
|
1568
|
-
// 96-111 (`a-o)
|
|
1569
|
-
1,
|
|
1570
|
-
1,
|
|
1571
|
-
1,
|
|
1572
|
-
1,
|
|
1573
|
-
1,
|
|
1574
|
-
1,
|
|
1575
|
-
1,
|
|
1576
|
-
1,
|
|
1577
|
-
1,
|
|
1578
|
-
1,
|
|
1579
|
-
1,
|
|
1580
|
-
0,
|
|
1581
|
-
1,
|
|
1582
|
-
0,
|
|
1583
|
-
1,
|
|
1584
|
-
0,
|
|
1585
|
-
// 112-127 (p-z{|}~)
|
|
1586
|
-
0,
|
|
1587
|
-
0,
|
|
1588
|
-
0,
|
|
1589
|
-
0,
|
|
1590
|
-
0,
|
|
1591
|
-
0,
|
|
1592
|
-
0,
|
|
1593
|
-
0,
|
|
1594
|
-
0,
|
|
1595
|
-
0,
|
|
1596
|
-
0,
|
|
1597
|
-
0,
|
|
1598
|
-
0,
|
|
1599
|
-
0,
|
|
1600
|
-
0,
|
|
1601
|
-
0,
|
|
1602
|
-
// 128-143
|
|
1603
|
-
0,
|
|
1604
|
-
0,
|
|
1605
|
-
0,
|
|
1606
|
-
0,
|
|
1607
|
-
0,
|
|
1608
|
-
0,
|
|
1609
|
-
0,
|
|
1610
|
-
0,
|
|
1611
|
-
0,
|
|
1612
|
-
0,
|
|
1613
|
-
0,
|
|
1614
|
-
0,
|
|
1615
|
-
0,
|
|
1616
|
-
0,
|
|
1617
|
-
0,
|
|
1618
|
-
0,
|
|
1619
|
-
// 144-159
|
|
1620
|
-
0,
|
|
1621
|
-
0,
|
|
1622
|
-
0,
|
|
1623
|
-
0,
|
|
1624
|
-
0,
|
|
1625
|
-
0,
|
|
1626
|
-
0,
|
|
1627
|
-
0,
|
|
1628
|
-
0,
|
|
1629
|
-
0,
|
|
1630
|
-
0,
|
|
1631
|
-
0,
|
|
1632
|
-
0,
|
|
1633
|
-
0,
|
|
1634
|
-
0,
|
|
1635
|
-
0,
|
|
1636
|
-
// 160-175
|
|
1637
|
-
0,
|
|
1638
|
-
0,
|
|
1639
|
-
0,
|
|
1640
|
-
0,
|
|
1641
|
-
0,
|
|
1642
|
-
0,
|
|
1643
|
-
0,
|
|
1644
|
-
0,
|
|
1645
|
-
0,
|
|
1646
|
-
0,
|
|
1647
|
-
0,
|
|
1648
|
-
0,
|
|
1649
|
-
0,
|
|
1650
|
-
0,
|
|
1651
|
-
0,
|
|
1652
|
-
0,
|
|
1653
|
-
// 176-191
|
|
1654
|
-
0,
|
|
1655
|
-
0,
|
|
1656
|
-
0,
|
|
1657
|
-
0,
|
|
1658
|
-
0,
|
|
1659
|
-
0,
|
|
1660
|
-
0,
|
|
1661
|
-
0,
|
|
1662
|
-
0,
|
|
1663
|
-
0,
|
|
1664
|
-
0,
|
|
1665
|
-
0,
|
|
1666
|
-
0,
|
|
1667
|
-
0,
|
|
1668
|
-
0,
|
|
1669
|
-
0,
|
|
1670
|
-
// 192-207
|
|
1671
|
-
0,
|
|
1672
|
-
0,
|
|
1673
|
-
0,
|
|
1674
|
-
0,
|
|
1675
|
-
0,
|
|
1676
|
-
0,
|
|
1677
|
-
0,
|
|
1678
|
-
0,
|
|
1679
|
-
0,
|
|
1680
|
-
0,
|
|
1681
|
-
0,
|
|
1682
|
-
0,
|
|
1683
|
-
0,
|
|
1684
|
-
0,
|
|
1685
|
-
0,
|
|
1686
|
-
0,
|
|
1687
|
-
// 208-223
|
|
1688
|
-
0,
|
|
1689
|
-
0,
|
|
1690
|
-
0,
|
|
1691
|
-
0,
|
|
1692
|
-
0,
|
|
1693
|
-
0,
|
|
1694
|
-
0,
|
|
1695
|
-
0,
|
|
1696
|
-
0,
|
|
1697
|
-
0,
|
|
1698
|
-
0,
|
|
1699
|
-
0,
|
|
1700
|
-
0,
|
|
1701
|
-
0,
|
|
1702
|
-
0,
|
|
1703
|
-
0,
|
|
1704
|
-
// 224-239
|
|
1705
|
-
0,
|
|
1706
|
-
0,
|
|
1707
|
-
0,
|
|
1708
|
-
0,
|
|
1709
|
-
0,
|
|
1710
|
-
0,
|
|
1711
|
-
0,
|
|
1712
|
-
0,
|
|
1713
|
-
0,
|
|
1714
|
-
0,
|
|
1715
|
-
0,
|
|
1716
|
-
0,
|
|
1717
|
-
0,
|
|
1718
|
-
0,
|
|
1719
|
-
0,
|
|
1720
|
-
0
|
|
1721
|
-
// 240-255
|
|
1722
|
-
]);
|
|
1723
|
-
function isTokenCharCode(c) {
|
|
1724
|
-
return validTokenChars[c] === 1;
|
|
1725
|
-
}
|
|
1726
|
-
var tokenRegExp = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/;
|
|
1727
|
-
function isValidHTTPToken(characters) {
|
|
1728
|
-
if (characters.length >= 12) return tokenRegExp.test(characters);
|
|
1729
|
-
if (characters.length === 0) return false;
|
|
1730
|
-
for (let i = 0; i < characters.length; i++) {
|
|
1731
|
-
if (validTokenChars[characters.charCodeAt(i)] !== 1) {
|
|
1732
|
-
return false;
|
|
1733
|
-
}
|
|
1734
|
-
}
|
|
1735
|
-
return true;
|
|
1736
|
-
}
|
|
1737
|
-
var headerCharRegex = /[^\t\x20-\x7e\x80-\xff]/;
|
|
1738
|
-
function isValidHeaderValue(characters) {
|
|
1739
|
-
return !headerCharRegex.test(characters);
|
|
1740
|
-
}
|
|
1741
|
-
var rangeHeaderRegex = /^bytes (\d+)-(\d+)\/(\d+)?$/;
|
|
1742
|
-
function parseRangeHeader(range) {
|
|
1743
|
-
if (range == null || range === "") return { start: 0, end: null, size: null };
|
|
1744
|
-
const m = range ? range.match(rangeHeaderRegex) : null;
|
|
1745
|
-
return m ? {
|
|
1746
|
-
start: parseInt(m[1]),
|
|
1747
|
-
end: m[2] ? parseInt(m[2]) : null,
|
|
1748
|
-
size: m[3] ? parseInt(m[3]) : null
|
|
1749
|
-
} : null;
|
|
1750
|
-
}
|
|
1751
|
-
function addListener(obj, name, listener) {
|
|
1752
|
-
const listeners = obj[kListeners] ??= [];
|
|
1753
|
-
listeners.push([name, listener]);
|
|
1754
|
-
obj.on(name, listener);
|
|
1755
|
-
return obj;
|
|
1756
|
-
}
|
|
1757
|
-
function removeAllListeners(obj) {
|
|
1758
|
-
if (obj[kListeners] != null) {
|
|
1759
|
-
for (const [name, listener] of obj[kListeners]) {
|
|
1760
|
-
obj.removeListener(name, listener);
|
|
1761
|
-
}
|
|
1762
|
-
obj[kListeners] = null;
|
|
1763
|
-
}
|
|
1764
|
-
return obj;
|
|
1765
|
-
}
|
|
1766
|
-
function errorRequest(client, request, err) {
|
|
1767
|
-
try {
|
|
1768
|
-
request.onError(err);
|
|
1769
|
-
assert(request.aborted);
|
|
1770
|
-
} catch (err2) {
|
|
1771
|
-
client.emit("error", err2);
|
|
1772
|
-
}
|
|
1773
|
-
}
|
|
1774
|
-
var setupConnectTimeout = process.platform === "win32" ? (socketWeakRef, opts) => {
|
|
1775
|
-
if (!opts.timeout) {
|
|
1776
|
-
return noop;
|
|
1777
|
-
}
|
|
1778
|
-
let s1 = null;
|
|
1779
|
-
let s2 = null;
|
|
1780
|
-
const fastTimer = timers.setFastTimeout(() => {
|
|
1781
|
-
s1 = setImmediate(() => {
|
|
1782
|
-
s2 = setImmediate(() => onConnectTimeout(socketWeakRef.deref(), opts));
|
|
1783
|
-
});
|
|
1784
|
-
}, opts.timeout);
|
|
1785
|
-
return () => {
|
|
1786
|
-
timers.clearFastTimeout(fastTimer);
|
|
1787
|
-
clearImmediate(s1);
|
|
1788
|
-
clearImmediate(s2);
|
|
1789
|
-
};
|
|
1790
|
-
} : (socketWeakRef, opts) => {
|
|
1791
|
-
if (!opts.timeout) {
|
|
1792
|
-
return noop;
|
|
1793
|
-
}
|
|
1794
|
-
let s1 = null;
|
|
1795
|
-
const fastTimer = timers.setFastTimeout(() => {
|
|
1796
|
-
s1 = setImmediate(() => {
|
|
1797
|
-
onConnectTimeout(socketWeakRef.deref(), opts);
|
|
1798
|
-
});
|
|
1799
|
-
}, opts.timeout);
|
|
1800
|
-
return () => {
|
|
1801
|
-
timers.clearFastTimeout(fastTimer);
|
|
1802
|
-
clearImmediate(s1);
|
|
1803
|
-
};
|
|
1804
|
-
};
|
|
1805
|
-
function onConnectTimeout(socket, opts) {
|
|
1806
|
-
if (socket == null) {
|
|
1807
|
-
return;
|
|
1808
|
-
}
|
|
1809
|
-
let message = "Connect Timeout Error";
|
|
1810
|
-
if (Array.isArray(socket.autoSelectFamilyAttemptedAddresses)) {
|
|
1811
|
-
message += ` (attempted addresses: ${socket.autoSelectFamilyAttemptedAddresses.join(", ")},`;
|
|
1812
|
-
} else {
|
|
1813
|
-
message += ` (attempted address: ${opts.hostname}:${opts.port},`;
|
|
1814
|
-
}
|
|
1815
|
-
message += ` timeout: ${opts.timeout}ms)`;
|
|
1816
|
-
destroy(socket, new ConnectTimeoutError(message));
|
|
1817
|
-
}
|
|
1818
|
-
function getProtocolFromUrlString(urlString) {
|
|
1819
|
-
if (urlString[0] === "h" && urlString[1] === "t" && urlString[2] === "t" && urlString[3] === "p") {
|
|
1820
|
-
switch (urlString[4]) {
|
|
1821
|
-
case ":":
|
|
1822
|
-
return "http:";
|
|
1823
|
-
case "s":
|
|
1824
|
-
if (urlString[5] === ":") {
|
|
1825
|
-
return "https:";
|
|
1826
|
-
}
|
|
1827
|
-
}
|
|
1828
|
-
}
|
|
1829
|
-
return urlString.slice(0, urlString.indexOf(":") + 1);
|
|
1830
|
-
}
|
|
1831
|
-
var kEnumerableProperty = /* @__PURE__ */ Object.create(null);
|
|
1832
|
-
kEnumerableProperty.enumerable = true;
|
|
1833
|
-
var normalizedMethodRecordsBase = {
|
|
1834
|
-
delete: "DELETE",
|
|
1835
|
-
DELETE: "DELETE",
|
|
1836
|
-
get: "GET",
|
|
1837
|
-
GET: "GET",
|
|
1838
|
-
head: "HEAD",
|
|
1839
|
-
HEAD: "HEAD",
|
|
1840
|
-
options: "OPTIONS",
|
|
1841
|
-
OPTIONS: "OPTIONS",
|
|
1842
|
-
post: "POST",
|
|
1843
|
-
POST: "POST",
|
|
1844
|
-
put: "PUT",
|
|
1845
|
-
PUT: "PUT"
|
|
1846
|
-
};
|
|
1847
|
-
var normalizedMethodRecords = {
|
|
1848
|
-
...normalizedMethodRecordsBase,
|
|
1849
|
-
patch: "patch",
|
|
1850
|
-
PATCH: "PATCH"
|
|
1851
|
-
};
|
|
1852
|
-
Object.setPrototypeOf(normalizedMethodRecordsBase, null);
|
|
1853
|
-
Object.setPrototypeOf(normalizedMethodRecords, null);
|
|
1854
|
-
module2.exports = {
|
|
1855
|
-
kEnumerableProperty,
|
|
1856
|
-
isDisturbed,
|
|
1857
|
-
isBlobLike,
|
|
1858
|
-
parseOrigin,
|
|
1859
|
-
parseURL,
|
|
1860
|
-
getServerName,
|
|
1861
|
-
isStream,
|
|
1862
|
-
isIterable,
|
|
1863
|
-
isAsyncIterable,
|
|
1864
|
-
isDestroyed,
|
|
1865
|
-
headerNameToString,
|
|
1866
|
-
bufferToLowerCasedHeaderName,
|
|
1867
|
-
addListener,
|
|
1868
|
-
removeAllListeners,
|
|
1869
|
-
errorRequest,
|
|
1870
|
-
parseRawHeaders,
|
|
1871
|
-
encodeRawHeaders,
|
|
1872
|
-
parseHeaders,
|
|
1873
|
-
parseKeepAliveTimeout,
|
|
1874
|
-
destroy,
|
|
1875
|
-
bodyLength,
|
|
1876
|
-
deepClone,
|
|
1877
|
-
ReadableStreamFrom,
|
|
1878
|
-
isBuffer,
|
|
1879
|
-
assertRequestHandler,
|
|
1880
|
-
getSocketInfo,
|
|
1881
|
-
isFormDataLike,
|
|
1882
|
-
pathHasQueryOrFragment,
|
|
1883
|
-
serializePathWithQuery,
|
|
1884
|
-
addAbortListener,
|
|
1885
|
-
isValidHTTPToken,
|
|
1886
|
-
isValidHeaderValue,
|
|
1887
|
-
isTokenCharCode,
|
|
1888
|
-
parseRangeHeader,
|
|
1889
|
-
normalizedMethodRecordsBase,
|
|
1890
|
-
normalizedMethodRecords,
|
|
1891
|
-
isValidPort,
|
|
1892
|
-
isHttpOrHttpsPrefixed,
|
|
1893
|
-
nodeMajor,
|
|
1894
|
-
nodeMinor,
|
|
1895
|
-
safeHTTPMethods: Object.freeze(["GET", "HEAD", "OPTIONS", "TRACE"]),
|
|
1896
|
-
wrapRequestBody,
|
|
1897
|
-
setupConnectTimeout,
|
|
1898
|
-
getProtocolFromUrlString
|
|
1899
|
-
};
|
|
1900
|
-
}
|
|
1901
|
-
});
|
|
1902
|
-
|
|
1903
|
-
// ../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/handler/unwrap-handler.js
|
|
1904
|
-
var require_unwrap_handler = __commonJS({
|
|
1905
|
-
"../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/handler/unwrap-handler.js"(exports2, module2) {
|
|
1906
|
-
"use strict";
|
|
1907
|
-
var { parseHeaders } = require_util();
|
|
1908
|
-
var { InvalidArgumentError } = require_errors();
|
|
1909
|
-
var kResume = /* @__PURE__ */ Symbol("resume");
|
|
1910
|
-
var UnwrapController = class {
|
|
1911
|
-
#paused = false;
|
|
1912
|
-
#reason = null;
|
|
1913
|
-
#aborted = false;
|
|
1914
|
-
#abort;
|
|
1915
|
-
[kResume] = null;
|
|
1916
|
-
constructor(abort) {
|
|
1917
|
-
this.#abort = abort;
|
|
1918
|
-
}
|
|
1919
|
-
pause() {
|
|
1920
|
-
this.#paused = true;
|
|
1921
|
-
}
|
|
1922
|
-
resume() {
|
|
1923
|
-
if (this.#paused) {
|
|
1924
|
-
this.#paused = false;
|
|
1925
|
-
this[kResume]?.();
|
|
1926
|
-
}
|
|
1927
|
-
}
|
|
1928
|
-
abort(reason) {
|
|
1929
|
-
if (!this.#aborted) {
|
|
1930
|
-
this.#aborted = true;
|
|
1931
|
-
this.#reason = reason;
|
|
1932
|
-
this.#abort(reason);
|
|
1933
|
-
}
|
|
1934
|
-
}
|
|
1935
|
-
get aborted() {
|
|
1936
|
-
return this.#aborted;
|
|
1937
|
-
}
|
|
1938
|
-
get reason() {
|
|
1939
|
-
return this.#reason;
|
|
1940
|
-
}
|
|
1941
|
-
get paused() {
|
|
1942
|
-
return this.#paused;
|
|
1943
|
-
}
|
|
1944
|
-
};
|
|
1945
|
-
module2.exports = class UnwrapHandler {
|
|
1946
|
-
#handler;
|
|
1947
|
-
#controller;
|
|
1948
|
-
constructor(handler) {
|
|
1949
|
-
this.#handler = handler;
|
|
1950
|
-
}
|
|
1951
|
-
static unwrap(handler) {
|
|
1952
|
-
return !handler.onRequestStart ? handler : new UnwrapHandler(handler);
|
|
1953
|
-
}
|
|
1954
|
-
onConnect(abort, context) {
|
|
1955
|
-
this.#controller = new UnwrapController(abort);
|
|
1956
|
-
this.#handler.onRequestStart?.(this.#controller, context);
|
|
1957
|
-
}
|
|
1958
|
-
onUpgrade(statusCode, rawHeaders, socket) {
|
|
1959
|
-
this.#handler.onRequestUpgrade?.(this.#controller, statusCode, parseHeaders(rawHeaders), socket);
|
|
1960
|
-
}
|
|
1961
|
-
onHeaders(statusCode, rawHeaders, resume, statusMessage) {
|
|
1962
|
-
this.#controller[kResume] = resume;
|
|
1963
|
-
this.#handler.onResponseStart?.(this.#controller, statusCode, parseHeaders(rawHeaders), statusMessage);
|
|
1964
|
-
return !this.#controller.paused;
|
|
1965
|
-
}
|
|
1966
|
-
onData(data) {
|
|
1967
|
-
this.#handler.onResponseData?.(this.#controller, data);
|
|
1968
|
-
return !this.#controller.paused;
|
|
1969
|
-
}
|
|
1970
|
-
onComplete(rawTrailers) {
|
|
1971
|
-
this.#handler.onResponseEnd?.(this.#controller, parseHeaders(rawTrailers));
|
|
1972
|
-
}
|
|
1973
|
-
onError(err) {
|
|
1974
|
-
if (!this.#handler.onResponseError) {
|
|
1975
|
-
throw new InvalidArgumentError("invalid onError method");
|
|
1976
|
-
}
|
|
1977
|
-
this.#handler.onResponseError?.(this.#controller, err);
|
|
1978
|
-
}
|
|
1979
|
-
};
|
|
1980
|
-
}
|
|
1981
|
-
});
|
|
1982
|
-
|
|
1983
|
-
// ../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/dispatcher/dispatcher-base.js
|
|
1984
|
-
var require_dispatcher_base = __commonJS({
|
|
1985
|
-
"../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/dispatcher/dispatcher-base.js"(exports2, module2) {
|
|
1986
|
-
"use strict";
|
|
1987
|
-
var Dispatcher = require_dispatcher();
|
|
1988
|
-
var UnwrapHandler = require_unwrap_handler();
|
|
1989
|
-
var {
|
|
1990
|
-
ClientDestroyedError,
|
|
1991
|
-
ClientClosedError,
|
|
1992
|
-
InvalidArgumentError
|
|
1993
|
-
} = require_errors();
|
|
1994
|
-
var { kDestroy, kClose, kClosed, kDestroyed, kDispatch } = require_symbols();
|
|
1995
|
-
var kOnDestroyed = /* @__PURE__ */ Symbol("onDestroyed");
|
|
1996
|
-
var kOnClosed = /* @__PURE__ */ Symbol("onClosed");
|
|
1997
|
-
var DispatcherBase = class extends Dispatcher {
|
|
1998
|
-
/** @type {boolean} */
|
|
1999
|
-
[kDestroyed] = false;
|
|
2000
|
-
/** @type {Array<Function|null} */
|
|
2001
|
-
[kOnDestroyed] = null;
|
|
2002
|
-
/** @type {boolean} */
|
|
2003
|
-
[kClosed] = false;
|
|
2004
|
-
/** @type {Array<Function>|null} */
|
|
2005
|
-
[kOnClosed] = null;
|
|
2006
|
-
/** @returns {boolean} */
|
|
2007
|
-
get destroyed() {
|
|
2008
|
-
return this[kDestroyed];
|
|
2009
|
-
}
|
|
2010
|
-
/** @returns {boolean} */
|
|
2011
|
-
get closed() {
|
|
2012
|
-
return this[kClosed];
|
|
2013
|
-
}
|
|
2014
|
-
close(callback) {
|
|
2015
|
-
if (callback === void 0) {
|
|
2016
|
-
return new Promise((resolve, reject) => {
|
|
2017
|
-
this.close((err, data) => {
|
|
2018
|
-
return err ? reject(err) : resolve(data);
|
|
2019
|
-
});
|
|
2020
|
-
});
|
|
2021
|
-
}
|
|
2022
|
-
if (typeof callback !== "function") {
|
|
2023
|
-
throw new InvalidArgumentError("invalid callback");
|
|
2024
|
-
}
|
|
2025
|
-
if (this[kDestroyed]) {
|
|
2026
|
-
const err = new ClientDestroyedError();
|
|
2027
|
-
queueMicrotask(() => callback(err, null));
|
|
2028
|
-
return;
|
|
2029
|
-
}
|
|
2030
|
-
if (this[kClosed]) {
|
|
2031
|
-
if (this[kOnClosed]) {
|
|
2032
|
-
this[kOnClosed].push(callback);
|
|
2033
|
-
} else {
|
|
2034
|
-
queueMicrotask(() => callback(null, null));
|
|
2035
|
-
}
|
|
2036
|
-
return;
|
|
2037
|
-
}
|
|
2038
|
-
this[kClosed] = true;
|
|
2039
|
-
this[kOnClosed] ??= [];
|
|
2040
|
-
this[kOnClosed].push(callback);
|
|
2041
|
-
const onClosed = () => {
|
|
2042
|
-
const callbacks = this[kOnClosed];
|
|
2043
|
-
this[kOnClosed] = null;
|
|
2044
|
-
for (let i = 0; i < callbacks.length; i++) {
|
|
2045
|
-
callbacks[i](null, null);
|
|
2046
|
-
}
|
|
2047
|
-
};
|
|
2048
|
-
this[kClose]().then(() => this.destroy()).then(() => queueMicrotask(onClosed));
|
|
2049
|
-
}
|
|
2050
|
-
destroy(err, callback) {
|
|
2051
|
-
if (typeof err === "function") {
|
|
2052
|
-
callback = err;
|
|
2053
|
-
err = null;
|
|
2054
|
-
}
|
|
2055
|
-
if (callback === void 0) {
|
|
2056
|
-
return new Promise((resolve, reject) => {
|
|
2057
|
-
this.destroy(err, (err2, data) => {
|
|
2058
|
-
return err2 ? reject(err2) : resolve(data);
|
|
2059
|
-
});
|
|
2060
|
-
});
|
|
2061
|
-
}
|
|
2062
|
-
if (typeof callback !== "function") {
|
|
2063
|
-
throw new InvalidArgumentError("invalid callback");
|
|
2064
|
-
}
|
|
2065
|
-
if (this[kDestroyed]) {
|
|
2066
|
-
if (this[kOnDestroyed]) {
|
|
2067
|
-
this[kOnDestroyed].push(callback);
|
|
2068
|
-
} else {
|
|
2069
|
-
queueMicrotask(() => callback(null, null));
|
|
2070
|
-
}
|
|
2071
|
-
return;
|
|
2072
|
-
}
|
|
2073
|
-
if (!err) {
|
|
2074
|
-
err = new ClientDestroyedError();
|
|
2075
|
-
}
|
|
2076
|
-
this[kDestroyed] = true;
|
|
2077
|
-
this[kOnDestroyed] ??= [];
|
|
2078
|
-
this[kOnDestroyed].push(callback);
|
|
2079
|
-
const onDestroyed = () => {
|
|
2080
|
-
const callbacks = this[kOnDestroyed];
|
|
2081
|
-
this[kOnDestroyed] = null;
|
|
2082
|
-
for (let i = 0; i < callbacks.length; i++) {
|
|
2083
|
-
callbacks[i](null, null);
|
|
2084
|
-
}
|
|
2085
|
-
};
|
|
2086
|
-
this[kDestroy](err).then(() => queueMicrotask(onDestroyed));
|
|
2087
|
-
}
|
|
2088
|
-
dispatch(opts, handler) {
|
|
2089
|
-
if (!handler || typeof handler !== "object") {
|
|
2090
|
-
throw new InvalidArgumentError("handler must be an object");
|
|
2091
|
-
}
|
|
2092
|
-
handler = UnwrapHandler.unwrap(handler);
|
|
2093
|
-
try {
|
|
2094
|
-
if (!opts || typeof opts !== "object") {
|
|
2095
|
-
throw new InvalidArgumentError("opts must be an object.");
|
|
2096
|
-
}
|
|
2097
|
-
if (this[kDestroyed] || this[kOnDestroyed]) {
|
|
2098
|
-
throw new ClientDestroyedError();
|
|
2099
|
-
}
|
|
2100
|
-
if (this[kClosed]) {
|
|
2101
|
-
throw new ClientClosedError();
|
|
2102
|
-
}
|
|
2103
|
-
return this[kDispatch](opts, handler);
|
|
2104
|
-
} catch (err) {
|
|
2105
|
-
if (typeof handler.onError !== "function") {
|
|
2106
|
-
throw err;
|
|
2107
|
-
}
|
|
2108
|
-
handler.onError(err);
|
|
2109
|
-
return false;
|
|
2110
|
-
}
|
|
2111
|
-
}
|
|
2112
|
-
};
|
|
2113
|
-
module2.exports = DispatcherBase;
|
|
2114
|
-
}
|
|
2115
|
-
});
|
|
2116
|
-
|
|
2117
|
-
// src/mock-agent/pool.cjs
|
|
2118
|
-
var require_pool = __commonJS({
|
|
2119
|
-
"src/mock-agent/pool.cjs"(exports2, module2) {
|
|
2120
|
-
var assert = require("node:assert");
|
|
2121
|
-
module2.exports = class Pool {
|
|
2122
|
-
constructor() {
|
|
2123
|
-
assert.fail("Pool is not implemented in worker");
|
|
2124
|
-
}
|
|
2125
|
-
};
|
|
2126
|
-
}
|
|
2127
|
-
});
|
|
2128
|
-
|
|
2129
|
-
// src/mock-agent/dispatcher.cjs
|
|
2130
|
-
var require_dispatcher2 = __commonJS({
|
|
2131
|
-
"src/mock-agent/dispatcher.cjs"(exports2, module2) {
|
|
2132
|
-
"use strict";
|
|
2133
|
-
var dispatcher;
|
|
2134
|
-
module2.exports = {
|
|
2135
|
-
getDispatcher() {
|
|
2136
|
-
return dispatcher;
|
|
2137
|
-
},
|
|
2138
|
-
setDispatcher(newDispatcher) {
|
|
2139
|
-
dispatcher = newDispatcher;
|
|
2140
|
-
}
|
|
2141
|
-
};
|
|
2142
|
-
}
|
|
2143
|
-
});
|
|
2144
|
-
|
|
2145
|
-
// src/mock-agent/client.cjs
|
|
2146
|
-
var require_client = __commonJS({
|
|
2147
|
-
"src/mock-agent/client.cjs"(exports2, module2) {
|
|
2148
|
-
var assert = require("node:assert");
|
|
2149
|
-
var DispatcherBase = require_dispatcher_base();
|
|
2150
|
-
var { kDispatch, kClose, kDestroy } = require_symbols();
|
|
2151
|
-
var { getDispatcher } = require_dispatcher2();
|
|
2152
|
-
module2.exports = class Client extends DispatcherBase {
|
|
2153
|
-
[kDispatch](opts, handler) {
|
|
2154
|
-
const dispatcher = getDispatcher();
|
|
2155
|
-
if (dispatcher === void 0) {
|
|
2156
|
-
assert.fail("setDispatcher() must be called before Client#[kDispatch]()");
|
|
2157
|
-
}
|
|
2158
|
-
dispatcher(opts, handler);
|
|
2159
|
-
return true;
|
|
2160
|
-
}
|
|
2161
|
-
async [kClose]() {
|
|
2162
|
-
}
|
|
2163
|
-
async [kDestroy](_err) {
|
|
2164
|
-
}
|
|
2165
|
-
};
|
|
2166
|
-
}
|
|
2167
|
-
});
|
|
2168
|
-
|
|
2169
|
-
// ../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/dispatcher/agent.js
|
|
2170
|
-
var require_agent = __commonJS({
|
|
2171
|
-
"../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/dispatcher/agent.js"(exports2, module2) {
|
|
2172
|
-
"use strict";
|
|
2173
|
-
var { InvalidArgumentError, MaxOriginsReachedError } = require_errors();
|
|
2174
|
-
var { kClients: kClients2, kRunning, kClose, kDestroy, kDispatch, kUrl } = require_symbols();
|
|
2175
|
-
var DispatcherBase = require_dispatcher_base();
|
|
2176
|
-
var Pool = require_pool();
|
|
2177
|
-
var Client = require_client();
|
|
2178
|
-
var util = require_util();
|
|
2179
|
-
var kOnConnect = /* @__PURE__ */ Symbol("onConnect");
|
|
2180
|
-
var kOnDisconnect = /* @__PURE__ */ Symbol("onDisconnect");
|
|
2181
|
-
var kOnConnectionError = /* @__PURE__ */ Symbol("onConnectionError");
|
|
2182
|
-
var kOnDrain = /* @__PURE__ */ Symbol("onDrain");
|
|
2183
|
-
var kFactory = /* @__PURE__ */ Symbol("factory");
|
|
2184
|
-
var kOptions = /* @__PURE__ */ Symbol("options");
|
|
2185
|
-
var kOrigins = /* @__PURE__ */ Symbol("origins");
|
|
2186
|
-
function defaultFactory(origin, opts) {
|
|
2187
|
-
return opts && opts.connections === 1 ? new Client(origin, opts) : new Pool(origin, opts);
|
|
2188
|
-
}
|
|
2189
|
-
var Agent = class extends DispatcherBase {
|
|
2190
|
-
constructor({ factory = defaultFactory, maxOrigins = Infinity, connect, ...options } = {}) {
|
|
2191
|
-
if (typeof factory !== "function") {
|
|
2192
|
-
throw new InvalidArgumentError("factory must be a function.");
|
|
2193
|
-
}
|
|
2194
|
-
if (connect != null && typeof connect !== "function" && typeof connect !== "object") {
|
|
2195
|
-
throw new InvalidArgumentError("connect must be a function or an object");
|
|
2196
|
-
}
|
|
2197
|
-
if (typeof maxOrigins !== "number" || Number.isNaN(maxOrigins) || maxOrigins <= 0) {
|
|
2198
|
-
throw new InvalidArgumentError("maxOrigins must be a number greater than 0");
|
|
2199
|
-
}
|
|
2200
|
-
super();
|
|
2201
|
-
if (connect && typeof connect !== "function") {
|
|
2202
|
-
connect = { ...connect };
|
|
2203
|
-
}
|
|
2204
|
-
this[kOptions] = { ...util.deepClone(options), maxOrigins, connect };
|
|
2205
|
-
this[kFactory] = factory;
|
|
2206
|
-
this[kClients2] = /* @__PURE__ */ new Map();
|
|
2207
|
-
this[kOrigins] = /* @__PURE__ */ new Set();
|
|
2208
|
-
this[kOnDrain] = (origin, targets) => {
|
|
2209
|
-
this.emit("drain", origin, [this, ...targets]);
|
|
2210
|
-
};
|
|
2211
|
-
this[kOnConnect] = (origin, targets) => {
|
|
2212
|
-
this.emit("connect", origin, [this, ...targets]);
|
|
2213
|
-
};
|
|
2214
|
-
this[kOnDisconnect] = (origin, targets, err) => {
|
|
2215
|
-
this.emit("disconnect", origin, [this, ...targets], err);
|
|
2216
|
-
};
|
|
2217
|
-
this[kOnConnectionError] = (origin, targets, err) => {
|
|
2218
|
-
this.emit("connectionError", origin, [this, ...targets], err);
|
|
2219
|
-
};
|
|
2220
|
-
}
|
|
2221
|
-
get [kRunning]() {
|
|
2222
|
-
let ret = 0;
|
|
2223
|
-
for (const { dispatcher } of this[kClients2].values()) {
|
|
2224
|
-
ret += dispatcher[kRunning];
|
|
2225
|
-
}
|
|
2226
|
-
return ret;
|
|
2227
|
-
}
|
|
2228
|
-
[kDispatch](opts, handler) {
|
|
2229
|
-
let key;
|
|
2230
|
-
if (opts.origin && (typeof opts.origin === "string" || opts.origin instanceof URL)) {
|
|
2231
|
-
key = String(opts.origin);
|
|
2232
|
-
} else {
|
|
2233
|
-
throw new InvalidArgumentError("opts.origin must be a non-empty string or URL.");
|
|
2234
|
-
}
|
|
2235
|
-
if (this[kOrigins].size >= this[kOptions].maxOrigins && !this[kOrigins].has(key)) {
|
|
2236
|
-
throw new MaxOriginsReachedError();
|
|
2237
|
-
}
|
|
2238
|
-
const result = this[kClients2].get(key);
|
|
2239
|
-
let dispatcher = result && result.dispatcher;
|
|
2240
|
-
if (!dispatcher) {
|
|
2241
|
-
const closeClientIfUnused = (connected) => {
|
|
2242
|
-
const result2 = this[kClients2].get(key);
|
|
2243
|
-
if (result2) {
|
|
2244
|
-
if (connected) result2.count -= 1;
|
|
2245
|
-
if (result2.count <= 0) {
|
|
2246
|
-
this[kClients2].delete(key);
|
|
2247
|
-
result2.dispatcher.close();
|
|
2248
|
-
}
|
|
2249
|
-
this[kOrigins].delete(key);
|
|
2250
|
-
}
|
|
2251
|
-
};
|
|
2252
|
-
dispatcher = this[kFactory](opts.origin, this[kOptions]).on("drain", this[kOnDrain]).on("connect", (origin, targets) => {
|
|
2253
|
-
const result2 = this[kClients2].get(key);
|
|
2254
|
-
if (result2) {
|
|
2255
|
-
result2.count += 1;
|
|
2256
|
-
}
|
|
2257
|
-
this[kOnConnect](origin, targets);
|
|
2258
|
-
}).on("disconnect", (origin, targets, err) => {
|
|
2259
|
-
closeClientIfUnused(true);
|
|
2260
|
-
this[kOnDisconnect](origin, targets, err);
|
|
2261
|
-
}).on("connectionError", (origin, targets, err) => {
|
|
2262
|
-
closeClientIfUnused(false);
|
|
2263
|
-
this[kOnConnectionError](origin, targets, err);
|
|
2264
|
-
});
|
|
2265
|
-
this[kClients2].set(key, { count: 0, dispatcher });
|
|
2266
|
-
this[kOrigins].add(key);
|
|
2267
|
-
}
|
|
2268
|
-
return dispatcher.dispatch(opts, handler);
|
|
2269
|
-
}
|
|
2270
|
-
[kClose]() {
|
|
2271
|
-
const closePromises = [];
|
|
2272
|
-
for (const { dispatcher } of this[kClients2].values()) {
|
|
2273
|
-
closePromises.push(dispatcher.close());
|
|
2274
|
-
}
|
|
2275
|
-
this[kClients2].clear();
|
|
2276
|
-
return Promise.all(closePromises);
|
|
2277
|
-
}
|
|
2278
|
-
[kDestroy](err) {
|
|
2279
|
-
const destroyPromises = [];
|
|
2280
|
-
for (const { dispatcher } of this[kClients2].values()) {
|
|
2281
|
-
destroyPromises.push(dispatcher.destroy(err));
|
|
2282
|
-
}
|
|
2283
|
-
this[kClients2].clear();
|
|
2284
|
-
return Promise.all(destroyPromises);
|
|
2285
|
-
}
|
|
2286
|
-
get stats() {
|
|
2287
|
-
const allClientStats = {};
|
|
2288
|
-
for (const { dispatcher } of this[kClients2].values()) {
|
|
2289
|
-
if (dispatcher.stats) {
|
|
2290
|
-
allClientStats[dispatcher[kUrl].origin] = dispatcher.stats;
|
|
2291
|
-
}
|
|
2292
|
-
}
|
|
2293
|
-
return allClientStats;
|
|
2294
|
-
}
|
|
2295
|
-
};
|
|
2296
|
-
module2.exports = Agent;
|
|
2297
|
-
}
|
|
2298
|
-
});
|
|
2299
|
-
|
|
2300
|
-
// ../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/mock/mock-symbols.js
|
|
2301
|
-
var require_mock_symbols = __commonJS({
|
|
2302
|
-
"../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/mock/mock-symbols.js"(exports2, module2) {
|
|
2303
|
-
"use strict";
|
|
2304
|
-
module2.exports = {
|
|
2305
|
-
kAgent: /* @__PURE__ */ Symbol("agent"),
|
|
2306
|
-
kOptions: /* @__PURE__ */ Symbol("options"),
|
|
2307
|
-
kFactory: /* @__PURE__ */ Symbol("factory"),
|
|
2308
|
-
kDispatches: /* @__PURE__ */ Symbol("dispatches"),
|
|
2309
|
-
kDispatchKey: /* @__PURE__ */ Symbol("dispatch key"),
|
|
2310
|
-
kDefaultHeaders: /* @__PURE__ */ Symbol("default headers"),
|
|
2311
|
-
kDefaultTrailers: /* @__PURE__ */ Symbol("default trailers"),
|
|
2312
|
-
kContentLength: /* @__PURE__ */ Symbol("content length"),
|
|
2313
|
-
kMockAgent: /* @__PURE__ */ Symbol("mock agent"),
|
|
2314
|
-
kMockAgentSet: /* @__PURE__ */ Symbol("mock agent set"),
|
|
2315
|
-
kMockAgentGet: /* @__PURE__ */ Symbol("mock agent get"),
|
|
2316
|
-
kMockDispatch: /* @__PURE__ */ Symbol("mock dispatch"),
|
|
2317
|
-
kClose: /* @__PURE__ */ Symbol("close"),
|
|
2318
|
-
kOriginalClose: /* @__PURE__ */ Symbol("original agent close"),
|
|
2319
|
-
kOriginalDispatch: /* @__PURE__ */ Symbol("original dispatch"),
|
|
2320
|
-
kOrigin: /* @__PURE__ */ Symbol("origin"),
|
|
2321
|
-
kIsMockActive: /* @__PURE__ */ Symbol("is mock active"),
|
|
2322
|
-
kNetConnect: /* @__PURE__ */ Symbol("net connect"),
|
|
2323
|
-
kGetNetConnect: /* @__PURE__ */ Symbol("get net connect"),
|
|
2324
|
-
kConnected: /* @__PURE__ */ Symbol("connected"),
|
|
2325
|
-
kIgnoreTrailingSlash: /* @__PURE__ */ Symbol("ignore trailing slash"),
|
|
2326
|
-
kMockAgentMockCallHistoryInstance: /* @__PURE__ */ Symbol("mock agent mock call history name"),
|
|
2327
|
-
kMockAgentRegisterCallHistory: /* @__PURE__ */ Symbol("mock agent register mock call history"),
|
|
2328
|
-
kMockAgentAddCallHistoryLog: /* @__PURE__ */ Symbol("mock agent add call history log"),
|
|
2329
|
-
kMockAgentIsCallHistoryEnabled: /* @__PURE__ */ Symbol("mock agent is call history enabled"),
|
|
2330
|
-
kMockAgentAcceptsNonStandardSearchParameters: /* @__PURE__ */ Symbol("mock agent accepts non standard search parameters"),
|
|
2331
|
-
kMockCallHistoryAddLog: /* @__PURE__ */ Symbol("mock call history add log")
|
|
2332
|
-
};
|
|
2333
|
-
}
|
|
2334
|
-
});
|
|
2335
|
-
|
|
2336
|
-
// ../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/mock/mock-errors.js
|
|
2337
|
-
var require_mock_errors = __commonJS({
|
|
2338
|
-
"../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/mock/mock-errors.js"(exports2, module2) {
|
|
2339
|
-
"use strict";
|
|
2340
|
-
var { UndiciError } = require_errors();
|
|
2341
|
-
var kMockNotMatchedError = /* @__PURE__ */ Symbol.for("undici.error.UND_MOCK_ERR_MOCK_NOT_MATCHED");
|
|
2342
|
-
var MockNotMatchedError = class extends UndiciError {
|
|
2343
|
-
constructor(message) {
|
|
2344
|
-
super(message);
|
|
2345
|
-
this.name = "MockNotMatchedError";
|
|
2346
|
-
this.message = message || "The request does not match any registered mock dispatches";
|
|
2347
|
-
this.code = "UND_MOCK_ERR_MOCK_NOT_MATCHED";
|
|
2348
|
-
}
|
|
2349
|
-
static [Symbol.hasInstance](instance) {
|
|
2350
|
-
return instance && instance[kMockNotMatchedError] === true;
|
|
2351
|
-
}
|
|
2352
|
-
get [kMockNotMatchedError]() {
|
|
2353
|
-
return true;
|
|
2354
|
-
}
|
|
2355
|
-
};
|
|
2356
|
-
module2.exports = {
|
|
2357
|
-
MockNotMatchedError
|
|
2358
|
-
};
|
|
2359
|
-
}
|
|
2360
|
-
});
|
|
2361
|
-
|
|
2362
|
-
// ../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/mock/mock-utils.js
|
|
2363
|
-
var require_mock_utils = __commonJS({
|
|
2364
|
-
"../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/mock/mock-utils.js"(exports2, module2) {
|
|
2365
|
-
"use strict";
|
|
2366
|
-
var { MockNotMatchedError } = require_mock_errors();
|
|
2367
|
-
var {
|
|
2368
|
-
kDispatches: kDispatches2,
|
|
2369
|
-
kMockAgent,
|
|
2370
|
-
kOriginalDispatch,
|
|
2371
|
-
kOrigin,
|
|
2372
|
-
kGetNetConnect
|
|
2373
|
-
} = require_mock_symbols();
|
|
2374
|
-
var { serializePathWithQuery } = require_util();
|
|
2375
|
-
var { STATUS_CODES } = require("node:http");
|
|
2376
|
-
var {
|
|
2377
|
-
types: {
|
|
2378
|
-
isPromise
|
|
2379
|
-
}
|
|
2380
|
-
} = require("node:util");
|
|
2381
|
-
var { InvalidArgumentError } = require_errors();
|
|
2382
|
-
function matchValue(match, value) {
|
|
2383
|
-
if (typeof match === "string") {
|
|
2384
|
-
return match === value;
|
|
2385
|
-
}
|
|
2386
|
-
if (match instanceof RegExp) {
|
|
2387
|
-
return match.test(value);
|
|
2388
|
-
}
|
|
2389
|
-
if (typeof match === "function") {
|
|
2390
|
-
return match(value) === true;
|
|
2391
|
-
}
|
|
2392
|
-
return false;
|
|
2393
|
-
}
|
|
2394
|
-
function lowerCaseEntries(headers) {
|
|
2395
|
-
return Object.fromEntries(
|
|
2396
|
-
Object.entries(headers).map(([headerName, headerValue]) => {
|
|
2397
|
-
return [headerName.toLocaleLowerCase(), headerValue];
|
|
2398
|
-
})
|
|
2399
|
-
);
|
|
2400
|
-
}
|
|
2401
|
-
function getHeaderByName(headers, key) {
|
|
2402
|
-
if (Array.isArray(headers)) {
|
|
2403
|
-
for (let i = 0; i < headers.length; i += 2) {
|
|
2404
|
-
if (headers[i].toLocaleLowerCase() === key.toLocaleLowerCase()) {
|
|
2405
|
-
return headers[i + 1];
|
|
2406
|
-
}
|
|
2407
|
-
}
|
|
2408
|
-
return void 0;
|
|
2409
|
-
} else if (typeof headers.get === "function") {
|
|
2410
|
-
return headers.get(key);
|
|
2411
|
-
} else {
|
|
2412
|
-
return lowerCaseEntries(headers)[key.toLocaleLowerCase()];
|
|
2413
|
-
}
|
|
2414
|
-
}
|
|
2415
|
-
function buildHeadersFromArray(headers) {
|
|
2416
|
-
const clone = headers.slice();
|
|
2417
|
-
const entries = [];
|
|
2418
|
-
for (let index = 0; index < clone.length; index += 2) {
|
|
2419
|
-
entries.push([clone[index], clone[index + 1]]);
|
|
2420
|
-
}
|
|
2421
|
-
return Object.fromEntries(entries);
|
|
2422
|
-
}
|
|
2423
|
-
function matchHeaders(mockDispatch2, headers) {
|
|
2424
|
-
if (typeof mockDispatch2.headers === "function") {
|
|
2425
|
-
if (Array.isArray(headers)) {
|
|
2426
|
-
headers = buildHeadersFromArray(headers);
|
|
2427
|
-
}
|
|
2428
|
-
return mockDispatch2.headers(headers ? lowerCaseEntries(headers) : {});
|
|
2429
|
-
}
|
|
2430
|
-
if (typeof mockDispatch2.headers === "undefined") {
|
|
2431
|
-
return true;
|
|
2432
|
-
}
|
|
2433
|
-
if (typeof headers !== "object" || typeof mockDispatch2.headers !== "object") {
|
|
2434
|
-
return false;
|
|
2435
|
-
}
|
|
2436
|
-
for (const [matchHeaderName, matchHeaderValue] of Object.entries(mockDispatch2.headers)) {
|
|
2437
|
-
const headerValue = getHeaderByName(headers, matchHeaderName);
|
|
2438
|
-
if (!matchValue(matchHeaderValue, headerValue)) {
|
|
2439
|
-
return false;
|
|
2440
|
-
}
|
|
2441
|
-
}
|
|
2442
|
-
return true;
|
|
2443
|
-
}
|
|
2444
|
-
function normalizeSearchParams(query) {
|
|
2445
|
-
if (typeof query !== "string") {
|
|
2446
|
-
return query;
|
|
2447
|
-
}
|
|
2448
|
-
const originalQp = new URLSearchParams(query);
|
|
2449
|
-
const normalizedQp = new URLSearchParams();
|
|
2450
|
-
for (let [key, value] of originalQp.entries()) {
|
|
2451
|
-
key = key.replace("[]", "");
|
|
2452
|
-
const valueRepresentsString = /^(['"]).*\1$/.test(value);
|
|
2453
|
-
if (valueRepresentsString) {
|
|
2454
|
-
normalizedQp.append(key, value);
|
|
2455
|
-
continue;
|
|
2456
|
-
}
|
|
2457
|
-
if (value.includes(",")) {
|
|
2458
|
-
const values = value.split(",");
|
|
2459
|
-
for (const v of values) {
|
|
2460
|
-
normalizedQp.append(key, v);
|
|
2461
|
-
}
|
|
2462
|
-
continue;
|
|
2463
|
-
}
|
|
2464
|
-
normalizedQp.append(key, value);
|
|
2465
|
-
}
|
|
2466
|
-
return normalizedQp;
|
|
2467
|
-
}
|
|
2468
|
-
function safeUrl(path) {
|
|
2469
|
-
if (typeof path !== "string") {
|
|
2470
|
-
return path;
|
|
2471
|
-
}
|
|
2472
|
-
const pathSegments = path.split("?", 3);
|
|
2473
|
-
if (pathSegments.length !== 2) {
|
|
2474
|
-
return path;
|
|
2475
|
-
}
|
|
2476
|
-
const qp = new URLSearchParams(pathSegments.pop());
|
|
2477
|
-
qp.sort();
|
|
2478
|
-
return [...pathSegments, qp.toString()].join("?");
|
|
2479
|
-
}
|
|
2480
|
-
function matchKey(mockDispatch2, { path, method, body, headers }) {
|
|
2481
|
-
const pathMatch = matchValue(mockDispatch2.path, path);
|
|
2482
|
-
const methodMatch = matchValue(mockDispatch2.method, method);
|
|
2483
|
-
const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
|
|
2484
|
-
const headersMatch = matchHeaders(mockDispatch2, headers);
|
|
2485
|
-
return pathMatch && methodMatch && bodyMatch && headersMatch;
|
|
2486
|
-
}
|
|
2487
|
-
function getResponseData(data) {
|
|
2488
|
-
if (Buffer.isBuffer(data)) {
|
|
2489
|
-
return data;
|
|
2490
|
-
} else if (data instanceof Uint8Array) {
|
|
2491
|
-
return data;
|
|
2492
|
-
} else if (data instanceof ArrayBuffer) {
|
|
2493
|
-
return data;
|
|
2494
|
-
} else if (typeof data === "object") {
|
|
2495
|
-
return JSON.stringify(data);
|
|
2496
|
-
} else if (data) {
|
|
2497
|
-
return data.toString();
|
|
2498
|
-
} else {
|
|
2499
|
-
return "";
|
|
2500
|
-
}
|
|
2501
|
-
}
|
|
2502
|
-
function getMockDispatch(mockDispatches, key) {
|
|
2503
|
-
const basePath = key.query ? serializePathWithQuery(key.path, key.query) : key.path;
|
|
2504
|
-
const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
|
|
2505
|
-
const resolvedPathWithoutTrailingSlash = removeTrailingSlash(resolvedPath);
|
|
2506
|
-
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path, ignoreTrailingSlash }) => {
|
|
2507
|
-
return ignoreTrailingSlash ? matchValue(removeTrailingSlash(safeUrl(path)), resolvedPathWithoutTrailingSlash) : matchValue(safeUrl(path), resolvedPath);
|
|
2508
|
-
});
|
|
2509
|
-
if (matchedMockDispatches.length === 0) {
|
|
2510
|
-
throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
|
|
2511
|
-
}
|
|
2512
|
-
matchedMockDispatches = matchedMockDispatches.filter(({ method }) => matchValue(method, key.method));
|
|
2513
|
-
if (matchedMockDispatches.length === 0) {
|
|
2514
|
-
throw new MockNotMatchedError(`Mock dispatch not matched for method '${key.method}' on path '${resolvedPath}'`);
|
|
2515
|
-
}
|
|
2516
|
-
matchedMockDispatches = matchedMockDispatches.filter(({ body }) => typeof body !== "undefined" ? matchValue(body, key.body) : true);
|
|
2517
|
-
if (matchedMockDispatches.length === 0) {
|
|
2518
|
-
throw new MockNotMatchedError(`Mock dispatch not matched for body '${key.body}' on path '${resolvedPath}'`);
|
|
2519
|
-
}
|
|
2520
|
-
matchedMockDispatches = matchedMockDispatches.filter((mockDispatch2) => matchHeaders(mockDispatch2, key.headers));
|
|
2521
|
-
if (matchedMockDispatches.length === 0) {
|
|
2522
|
-
const headers = typeof key.headers === "object" ? JSON.stringify(key.headers) : key.headers;
|
|
2523
|
-
throw new MockNotMatchedError(`Mock dispatch not matched for headers '${headers}' on path '${resolvedPath}'`);
|
|
2524
|
-
}
|
|
2525
|
-
return matchedMockDispatches[0];
|
|
2526
|
-
}
|
|
2527
|
-
function addMockDispatch(mockDispatches, key, data, opts) {
|
|
2528
|
-
const baseData = { timesInvoked: 0, times: 1, persist: false, consumed: false, ...opts };
|
|
2529
|
-
const replyData = typeof data === "function" ? { callback: data } : { ...data };
|
|
2530
|
-
const newMockDispatch = { ...baseData, ...key, pending: true, data: { error: null, ...replyData } };
|
|
2531
|
-
mockDispatches.push(newMockDispatch);
|
|
2532
|
-
return newMockDispatch;
|
|
2533
|
-
}
|
|
2534
|
-
function deleteMockDispatch(mockDispatches, key) {
|
|
2535
|
-
const index = mockDispatches.findIndex((dispatch) => {
|
|
2536
|
-
if (!dispatch.consumed) {
|
|
2537
|
-
return false;
|
|
2538
|
-
}
|
|
2539
|
-
return matchKey(dispatch, key);
|
|
2540
|
-
});
|
|
2541
|
-
if (index !== -1) {
|
|
2542
|
-
mockDispatches.splice(index, 1);
|
|
2543
|
-
}
|
|
2544
|
-
}
|
|
2545
|
-
function removeTrailingSlash(path) {
|
|
2546
|
-
while (path.endsWith("/")) {
|
|
2547
|
-
path = path.slice(0, -1);
|
|
2548
|
-
}
|
|
2549
|
-
if (path.length === 0) {
|
|
2550
|
-
path = "/";
|
|
2551
|
-
}
|
|
2552
|
-
return path;
|
|
2553
|
-
}
|
|
2554
|
-
function buildKey(opts) {
|
|
2555
|
-
const { path, method, body, headers, query } = opts;
|
|
2556
|
-
return {
|
|
2557
|
-
path,
|
|
2558
|
-
method,
|
|
2559
|
-
body,
|
|
2560
|
-
headers,
|
|
2561
|
-
query
|
|
2562
|
-
};
|
|
2563
|
-
}
|
|
2564
|
-
function generateKeyValues(data) {
|
|
2565
|
-
const keys = Object.keys(data);
|
|
2566
|
-
const result = [];
|
|
2567
|
-
for (let i = 0; i < keys.length; ++i) {
|
|
2568
|
-
const key = keys[i];
|
|
2569
|
-
const value = data[key];
|
|
2570
|
-
const name = Buffer.from(`${key}`);
|
|
2571
|
-
if (Array.isArray(value)) {
|
|
2572
|
-
for (let j = 0; j < value.length; ++j) {
|
|
2573
|
-
result.push(name, Buffer.from(`${value[j]}`));
|
|
2574
|
-
}
|
|
2575
|
-
} else {
|
|
2576
|
-
result.push(name, Buffer.from(`${value}`));
|
|
2577
|
-
}
|
|
2578
|
-
}
|
|
2579
|
-
return result;
|
|
2580
|
-
}
|
|
2581
|
-
function getStatusText(statusCode) {
|
|
2582
|
-
return STATUS_CODES[statusCode] || "unknown";
|
|
2583
|
-
}
|
|
2584
|
-
async function getResponse(body) {
|
|
2585
|
-
const buffers = [];
|
|
2586
|
-
for await (const data of body) {
|
|
2587
|
-
buffers.push(data);
|
|
2588
|
-
}
|
|
2589
|
-
return Buffer.concat(buffers).toString("utf8");
|
|
2590
|
-
}
|
|
2591
|
-
function mockDispatch(opts, handler) {
|
|
2592
|
-
const key = buildKey(opts);
|
|
2593
|
-
const mockDispatch2 = getMockDispatch(this[kDispatches2], key);
|
|
2594
|
-
mockDispatch2.timesInvoked++;
|
|
2595
|
-
if (mockDispatch2.data.callback) {
|
|
2596
|
-
mockDispatch2.data = { ...mockDispatch2.data, ...mockDispatch2.data.callback(opts) };
|
|
2597
|
-
}
|
|
2598
|
-
const { data: { statusCode, data, headers, trailers, error }, delay, persist } = mockDispatch2;
|
|
2599
|
-
const { timesInvoked, times } = mockDispatch2;
|
|
2600
|
-
mockDispatch2.consumed = !persist && timesInvoked >= times;
|
|
2601
|
-
mockDispatch2.pending = timesInvoked < times;
|
|
2602
|
-
if (error !== null) {
|
|
2603
|
-
deleteMockDispatch(this[kDispatches2], key);
|
|
2604
|
-
handler.onError(error);
|
|
2605
|
-
return true;
|
|
2606
|
-
}
|
|
2607
|
-
if (typeof delay === "number" && delay > 0) {
|
|
2608
|
-
setTimeout(() => {
|
|
2609
|
-
handleReply(this[kDispatches2]);
|
|
2610
|
-
}, delay);
|
|
2611
|
-
} else {
|
|
2612
|
-
handleReply(this[kDispatches2]);
|
|
2613
|
-
}
|
|
2614
|
-
function handleReply(mockDispatches, _data = data) {
|
|
2615
|
-
const optsHeaders = Array.isArray(opts.headers) ? buildHeadersFromArray(opts.headers) : opts.headers;
|
|
2616
|
-
const body = typeof _data === "function" ? _data({ ...opts, headers: optsHeaders }) : _data;
|
|
2617
|
-
if (isPromise(body)) {
|
|
2618
|
-
return body.then((newData) => handleReply(mockDispatches, newData));
|
|
2619
|
-
}
|
|
2620
|
-
const responseData = getResponseData(body);
|
|
2621
|
-
const responseHeaders = generateKeyValues(headers);
|
|
2622
|
-
const responseTrailers = generateKeyValues(trailers);
|
|
2623
|
-
handler.onConnect?.((err) => handler.onError(err), null);
|
|
2624
|
-
handler.onHeaders?.(statusCode, responseHeaders, resume, getStatusText(statusCode));
|
|
2625
|
-
handler.onData?.(Buffer.from(responseData));
|
|
2626
|
-
handler.onComplete?.(responseTrailers);
|
|
2627
|
-
deleteMockDispatch(mockDispatches, key);
|
|
2628
|
-
}
|
|
2629
|
-
function resume() {
|
|
2630
|
-
}
|
|
2631
|
-
return true;
|
|
2632
|
-
}
|
|
2633
|
-
function buildMockDispatch() {
|
|
2634
|
-
const agent = this[kMockAgent];
|
|
2635
|
-
const origin = this[kOrigin];
|
|
2636
|
-
const originalDispatch = this[kOriginalDispatch];
|
|
2637
|
-
return function dispatch(opts, handler) {
|
|
2638
|
-
if (agent.isMockActive) {
|
|
2639
|
-
try {
|
|
2640
|
-
mockDispatch.call(this, opts, handler);
|
|
2641
|
-
} catch (error) {
|
|
2642
|
-
if (error.code === "UND_MOCK_ERR_MOCK_NOT_MATCHED") {
|
|
2643
|
-
const netConnect = agent[kGetNetConnect]();
|
|
2644
|
-
if (netConnect === false) {
|
|
2645
|
-
throw new MockNotMatchedError(`${error.message}: subsequent request to origin ${origin} was not allowed (net.connect disabled)`);
|
|
2646
|
-
}
|
|
2647
|
-
if (checkNetConnect(netConnect, origin)) {
|
|
2648
|
-
originalDispatch.call(this, opts, handler);
|
|
2649
|
-
} else {
|
|
2650
|
-
throw new MockNotMatchedError(`${error.message}: subsequent request to origin ${origin} was not allowed (net.connect is not enabled for this origin)`);
|
|
2651
|
-
}
|
|
2652
|
-
} else {
|
|
2653
|
-
throw error;
|
|
2654
|
-
}
|
|
2655
|
-
}
|
|
2656
|
-
} else {
|
|
2657
|
-
originalDispatch.call(this, opts, handler);
|
|
2658
|
-
}
|
|
2659
|
-
};
|
|
2660
|
-
}
|
|
2661
|
-
function checkNetConnect(netConnect, origin) {
|
|
2662
|
-
const url = new URL(origin);
|
|
2663
|
-
if (netConnect === true) {
|
|
2664
|
-
return true;
|
|
2665
|
-
} else if (Array.isArray(netConnect) && netConnect.some((matcher) => matchValue(matcher, url.host))) {
|
|
2666
|
-
return true;
|
|
2667
|
-
}
|
|
2668
|
-
return false;
|
|
2669
|
-
}
|
|
2670
|
-
function buildAndValidateMockOptions(opts) {
|
|
2671
|
-
const { agent, ...mockOptions } = opts;
|
|
2672
|
-
if ("enableCallHistory" in mockOptions && typeof mockOptions.enableCallHistory !== "boolean") {
|
|
2673
|
-
throw new InvalidArgumentError("options.enableCallHistory must to be a boolean");
|
|
2674
|
-
}
|
|
2675
|
-
if ("acceptNonStandardSearchParameters" in mockOptions && typeof mockOptions.acceptNonStandardSearchParameters !== "boolean") {
|
|
2676
|
-
throw new InvalidArgumentError("options.acceptNonStandardSearchParameters must to be a boolean");
|
|
2677
|
-
}
|
|
2678
|
-
if ("ignoreTrailingSlash" in mockOptions && typeof mockOptions.ignoreTrailingSlash !== "boolean") {
|
|
2679
|
-
throw new InvalidArgumentError("options.ignoreTrailingSlash must to be a boolean");
|
|
2680
|
-
}
|
|
2681
|
-
return mockOptions;
|
|
2682
|
-
}
|
|
2683
|
-
module2.exports = {
|
|
2684
|
-
getResponseData,
|
|
2685
|
-
getMockDispatch,
|
|
2686
|
-
addMockDispatch,
|
|
2687
|
-
deleteMockDispatch,
|
|
2688
|
-
buildKey,
|
|
2689
|
-
generateKeyValues,
|
|
2690
|
-
matchValue,
|
|
2691
|
-
getResponse,
|
|
2692
|
-
getStatusText,
|
|
2693
|
-
mockDispatch,
|
|
2694
|
-
buildMockDispatch,
|
|
2695
|
-
checkNetConnect,
|
|
2696
|
-
buildAndValidateMockOptions,
|
|
2697
|
-
getHeaderByName,
|
|
2698
|
-
buildHeadersFromArray,
|
|
2699
|
-
normalizeSearchParams
|
|
2700
|
-
};
|
|
2701
|
-
}
|
|
2702
|
-
});
|
|
2703
|
-
|
|
2704
|
-
// ../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/mock/mock-interceptor.js
|
|
2705
|
-
var require_mock_interceptor = __commonJS({
|
|
2706
|
-
"../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/mock/mock-interceptor.js"(exports2, module2) {
|
|
2707
|
-
"use strict";
|
|
2708
|
-
var { getResponseData, buildKey, addMockDispatch } = require_mock_utils();
|
|
2709
|
-
var {
|
|
2710
|
-
kDispatches: kDispatches2,
|
|
2711
|
-
kDispatchKey,
|
|
2712
|
-
kDefaultHeaders,
|
|
2713
|
-
kDefaultTrailers,
|
|
2714
|
-
kContentLength,
|
|
2715
|
-
kMockDispatch,
|
|
2716
|
-
kIgnoreTrailingSlash
|
|
2717
|
-
} = require_mock_symbols();
|
|
2718
|
-
var { InvalidArgumentError } = require_errors();
|
|
2719
|
-
var { serializePathWithQuery } = require_util();
|
|
2720
|
-
var MockScope = class {
|
|
2721
|
-
constructor(mockDispatch) {
|
|
2722
|
-
this[kMockDispatch] = mockDispatch;
|
|
2723
|
-
}
|
|
2724
|
-
/**
|
|
2725
|
-
* Delay a reply by a set amount in ms.
|
|
2726
|
-
*/
|
|
2727
|
-
delay(waitInMs) {
|
|
2728
|
-
if (typeof waitInMs !== "number" || !Number.isInteger(waitInMs) || waitInMs <= 0) {
|
|
2729
|
-
throw new InvalidArgumentError("waitInMs must be a valid integer > 0");
|
|
2730
|
-
}
|
|
2731
|
-
this[kMockDispatch].delay = waitInMs;
|
|
2732
|
-
return this;
|
|
2733
|
-
}
|
|
2734
|
-
/**
|
|
2735
|
-
* For a defined reply, never mark as consumed.
|
|
2736
|
-
*/
|
|
2737
|
-
persist() {
|
|
2738
|
-
this[kMockDispatch].persist = true;
|
|
2739
|
-
return this;
|
|
2740
|
-
}
|
|
2741
|
-
/**
|
|
2742
|
-
* Allow one to define a reply for a set amount of matching requests.
|
|
2743
|
-
*/
|
|
2744
|
-
times(repeatTimes) {
|
|
2745
|
-
if (typeof repeatTimes !== "number" || !Number.isInteger(repeatTimes) || repeatTimes <= 0) {
|
|
2746
|
-
throw new InvalidArgumentError("repeatTimes must be a valid integer > 0");
|
|
2747
|
-
}
|
|
2748
|
-
this[kMockDispatch].times = repeatTimes;
|
|
2749
|
-
return this;
|
|
2750
|
-
}
|
|
2751
|
-
};
|
|
2752
|
-
var MockInterceptor = class {
|
|
2753
|
-
constructor(opts, mockDispatches) {
|
|
2754
|
-
if (typeof opts !== "object") {
|
|
2755
|
-
throw new InvalidArgumentError("opts must be an object");
|
|
2756
|
-
}
|
|
2757
|
-
if (typeof opts.path === "undefined") {
|
|
2758
|
-
throw new InvalidArgumentError("opts.path must be defined");
|
|
2759
|
-
}
|
|
2760
|
-
if (typeof opts.method === "undefined") {
|
|
2761
|
-
opts.method = "GET";
|
|
2762
|
-
}
|
|
2763
|
-
if (typeof opts.path === "string") {
|
|
2764
|
-
if (opts.query) {
|
|
2765
|
-
opts.path = serializePathWithQuery(opts.path, opts.query);
|
|
2766
|
-
} else {
|
|
2767
|
-
const parsedURL = new URL(opts.path, "data://");
|
|
2768
|
-
opts.path = parsedURL.pathname + parsedURL.search;
|
|
2769
|
-
}
|
|
2770
|
-
}
|
|
2771
|
-
if (typeof opts.method === "string") {
|
|
2772
|
-
opts.method = opts.method.toUpperCase();
|
|
2773
|
-
}
|
|
2774
|
-
this[kDispatchKey] = buildKey(opts);
|
|
2775
|
-
this[kDispatches2] = mockDispatches;
|
|
2776
|
-
this[kIgnoreTrailingSlash] = opts.ignoreTrailingSlash ?? false;
|
|
2777
|
-
this[kDefaultHeaders] = {};
|
|
2778
|
-
this[kDefaultTrailers] = {};
|
|
2779
|
-
this[kContentLength] = false;
|
|
2780
|
-
}
|
|
2781
|
-
createMockScopeDispatchData({ statusCode, data, responseOptions }) {
|
|
2782
|
-
const responseData = getResponseData(data);
|
|
2783
|
-
const contentLength = this[kContentLength] ? { "content-length": responseData.length } : {};
|
|
2784
|
-
const headers = { ...this[kDefaultHeaders], ...contentLength, ...responseOptions.headers };
|
|
2785
|
-
const trailers = { ...this[kDefaultTrailers], ...responseOptions.trailers };
|
|
2786
|
-
return { statusCode, data, headers, trailers };
|
|
2787
|
-
}
|
|
2788
|
-
validateReplyParameters(replyParameters) {
|
|
2789
|
-
if (typeof replyParameters.statusCode === "undefined") {
|
|
2790
|
-
throw new InvalidArgumentError("statusCode must be defined");
|
|
2791
|
-
}
|
|
2792
|
-
if (typeof replyParameters.responseOptions !== "object" || replyParameters.responseOptions === null) {
|
|
2793
|
-
throw new InvalidArgumentError("responseOptions must be an object");
|
|
2794
|
-
}
|
|
2795
|
-
}
|
|
2796
|
-
/**
|
|
2797
|
-
* Mock an undici request with a defined reply.
|
|
2798
|
-
*/
|
|
2799
|
-
reply(replyOptionsCallbackOrStatusCode) {
|
|
2800
|
-
if (typeof replyOptionsCallbackOrStatusCode === "function") {
|
|
2801
|
-
const wrappedDefaultsCallback = (opts) => {
|
|
2802
|
-
const resolvedData = replyOptionsCallbackOrStatusCode(opts);
|
|
2803
|
-
if (typeof resolvedData !== "object" || resolvedData === null) {
|
|
2804
|
-
throw new InvalidArgumentError("reply options callback must return an object");
|
|
2805
|
-
}
|
|
2806
|
-
const replyParameters2 = { data: "", responseOptions: {}, ...resolvedData };
|
|
2807
|
-
this.validateReplyParameters(replyParameters2);
|
|
2808
|
-
return {
|
|
2809
|
-
...this.createMockScopeDispatchData(replyParameters2)
|
|
2810
|
-
};
|
|
2811
|
-
};
|
|
2812
|
-
const newMockDispatch2 = addMockDispatch(this[kDispatches2], this[kDispatchKey], wrappedDefaultsCallback, { ignoreTrailingSlash: this[kIgnoreTrailingSlash] });
|
|
2813
|
-
return new MockScope(newMockDispatch2);
|
|
2814
|
-
}
|
|
2815
|
-
const replyParameters = {
|
|
2816
|
-
statusCode: replyOptionsCallbackOrStatusCode,
|
|
2817
|
-
data: arguments[1] === void 0 ? "" : arguments[1],
|
|
2818
|
-
responseOptions: arguments[2] === void 0 ? {} : arguments[2]
|
|
2819
|
-
};
|
|
2820
|
-
this.validateReplyParameters(replyParameters);
|
|
2821
|
-
const dispatchData = this.createMockScopeDispatchData(replyParameters);
|
|
2822
|
-
const newMockDispatch = addMockDispatch(this[kDispatches2], this[kDispatchKey], dispatchData, { ignoreTrailingSlash: this[kIgnoreTrailingSlash] });
|
|
2823
|
-
return new MockScope(newMockDispatch);
|
|
2824
|
-
}
|
|
2825
|
-
/**
|
|
2826
|
-
* Mock an undici request with a defined error.
|
|
2827
|
-
*/
|
|
2828
|
-
replyWithError(error) {
|
|
2829
|
-
if (typeof error === "undefined") {
|
|
2830
|
-
throw new InvalidArgumentError("error must be defined");
|
|
2831
|
-
}
|
|
2832
|
-
const newMockDispatch = addMockDispatch(this[kDispatches2], this[kDispatchKey], { error }, { ignoreTrailingSlash: this[kIgnoreTrailingSlash] });
|
|
2833
|
-
return new MockScope(newMockDispatch);
|
|
2834
|
-
}
|
|
2835
|
-
/**
|
|
2836
|
-
* Set default reply headers on the interceptor for subsequent replies
|
|
2837
|
-
*/
|
|
2838
|
-
defaultReplyHeaders(headers) {
|
|
2839
|
-
if (typeof headers === "undefined") {
|
|
2840
|
-
throw new InvalidArgumentError("headers must be defined");
|
|
2841
|
-
}
|
|
2842
|
-
this[kDefaultHeaders] = headers;
|
|
2843
|
-
return this;
|
|
2844
|
-
}
|
|
2845
|
-
/**
|
|
2846
|
-
* Set default reply trailers on the interceptor for subsequent replies
|
|
2847
|
-
*/
|
|
2848
|
-
defaultReplyTrailers(trailers) {
|
|
2849
|
-
if (typeof trailers === "undefined") {
|
|
2850
|
-
throw new InvalidArgumentError("trailers must be defined");
|
|
2851
|
-
}
|
|
2852
|
-
this[kDefaultTrailers] = trailers;
|
|
2853
|
-
return this;
|
|
2854
|
-
}
|
|
2855
|
-
/**
|
|
2856
|
-
* Set reply content length header for replies on the interceptor
|
|
2857
|
-
*/
|
|
2858
|
-
replyContentLength() {
|
|
2859
|
-
this[kContentLength] = true;
|
|
2860
|
-
return this;
|
|
2861
|
-
}
|
|
2862
|
-
};
|
|
2863
|
-
module2.exports.MockInterceptor = MockInterceptor;
|
|
2864
|
-
module2.exports.MockScope = MockScope;
|
|
2865
|
-
}
|
|
2866
|
-
});
|
|
2867
|
-
|
|
2868
|
-
// ../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/mock/mock-client.js
|
|
2869
|
-
var require_mock_client = __commonJS({
|
|
2870
|
-
"../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/mock/mock-client.js"(exports2, module2) {
|
|
2871
|
-
"use strict";
|
|
2872
|
-
var { promisify } = require("node:util");
|
|
2873
|
-
var Client = require_client();
|
|
2874
|
-
var { buildMockDispatch } = require_mock_utils();
|
|
2875
|
-
var {
|
|
2876
|
-
kDispatches: kDispatches2,
|
|
2877
|
-
kMockAgent,
|
|
2878
|
-
kClose,
|
|
2879
|
-
kOriginalClose,
|
|
2880
|
-
kOrigin,
|
|
2881
|
-
kOriginalDispatch,
|
|
2882
|
-
kConnected,
|
|
2883
|
-
kIgnoreTrailingSlash
|
|
2884
|
-
} = require_mock_symbols();
|
|
2885
|
-
var { MockInterceptor } = require_mock_interceptor();
|
|
2886
|
-
var Symbols = require_symbols();
|
|
2887
|
-
var { InvalidArgumentError } = require_errors();
|
|
2888
|
-
var MockClient = class extends Client {
|
|
2889
|
-
constructor(origin, opts) {
|
|
2890
|
-
if (!opts || !opts.agent || typeof opts.agent.dispatch !== "function") {
|
|
2891
|
-
throw new InvalidArgumentError("Argument opts.agent must implement Agent");
|
|
2892
|
-
}
|
|
2893
|
-
super(origin, opts);
|
|
2894
|
-
this[kMockAgent] = opts.agent;
|
|
2895
|
-
this[kOrigin] = origin;
|
|
2896
|
-
this[kIgnoreTrailingSlash] = opts.ignoreTrailingSlash ?? false;
|
|
2897
|
-
this[kDispatches2] = [];
|
|
2898
|
-
this[kConnected] = 1;
|
|
2899
|
-
this[kOriginalDispatch] = this.dispatch;
|
|
2900
|
-
this[kOriginalClose] = this.close.bind(this);
|
|
2901
|
-
this.dispatch = buildMockDispatch.call(this);
|
|
2902
|
-
this.close = this[kClose];
|
|
2903
|
-
}
|
|
2904
|
-
get [Symbols.kConnected]() {
|
|
2905
|
-
return this[kConnected];
|
|
2906
|
-
}
|
|
2907
|
-
/**
|
|
2908
|
-
* Sets up the base interceptor for mocking replies from undici.
|
|
2909
|
-
*/
|
|
2910
|
-
intercept(opts) {
|
|
2911
|
-
return new MockInterceptor(
|
|
2912
|
-
opts && { ignoreTrailingSlash: this[kIgnoreTrailingSlash], ...opts },
|
|
2913
|
-
this[kDispatches2]
|
|
2914
|
-
);
|
|
2915
|
-
}
|
|
2916
|
-
cleanMocks() {
|
|
2917
|
-
this[kDispatches2] = [];
|
|
2918
|
-
}
|
|
2919
|
-
async [kClose]() {
|
|
2920
|
-
await promisify(this[kOriginalClose])();
|
|
2921
|
-
this[kConnected] = 0;
|
|
2922
|
-
this[kMockAgent][Symbols.kClients].delete(this[kOrigin]);
|
|
2923
|
-
}
|
|
2924
|
-
};
|
|
2925
|
-
module2.exports = MockClient;
|
|
2926
|
-
}
|
|
2927
|
-
});
|
|
2928
|
-
|
|
2929
|
-
// ../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/mock/mock-pool.js
|
|
2930
|
-
var require_mock_pool = __commonJS({
|
|
2931
|
-
"../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/mock/mock-pool.js"(exports2, module2) {
|
|
2932
|
-
"use strict";
|
|
2933
|
-
var { promisify } = require("node:util");
|
|
2934
|
-
var Pool = require_pool();
|
|
2935
|
-
var { buildMockDispatch } = require_mock_utils();
|
|
2936
|
-
var {
|
|
2937
|
-
kDispatches: kDispatches2,
|
|
2938
|
-
kMockAgent,
|
|
2939
|
-
kClose,
|
|
2940
|
-
kOriginalClose,
|
|
2941
|
-
kOrigin,
|
|
2942
|
-
kOriginalDispatch,
|
|
2943
|
-
kConnected,
|
|
2944
|
-
kIgnoreTrailingSlash
|
|
2945
|
-
} = require_mock_symbols();
|
|
2946
|
-
var { MockInterceptor } = require_mock_interceptor();
|
|
2947
|
-
var Symbols = require_symbols();
|
|
2948
|
-
var { InvalidArgumentError } = require_errors();
|
|
2949
|
-
var MockPool = class extends Pool {
|
|
2950
|
-
constructor(origin, opts) {
|
|
2951
|
-
if (!opts || !opts.agent || typeof opts.agent.dispatch !== "function") {
|
|
2952
|
-
throw new InvalidArgumentError("Argument opts.agent must implement Agent");
|
|
2953
|
-
}
|
|
2954
|
-
super(origin, opts);
|
|
2955
|
-
this[kMockAgent] = opts.agent;
|
|
2956
|
-
this[kOrigin] = origin;
|
|
2957
|
-
this[kIgnoreTrailingSlash] = opts.ignoreTrailingSlash ?? false;
|
|
2958
|
-
this[kDispatches2] = [];
|
|
2959
|
-
this[kConnected] = 1;
|
|
2960
|
-
this[kOriginalDispatch] = this.dispatch;
|
|
2961
|
-
this[kOriginalClose] = this.close.bind(this);
|
|
2962
|
-
this.dispatch = buildMockDispatch.call(this);
|
|
2963
|
-
this.close = this[kClose];
|
|
2964
|
-
}
|
|
2965
|
-
get [Symbols.kConnected]() {
|
|
2966
|
-
return this[kConnected];
|
|
2967
|
-
}
|
|
2968
|
-
/**
|
|
2969
|
-
* Sets up the base interceptor for mocking replies from undici.
|
|
2970
|
-
*/
|
|
2971
|
-
intercept(opts) {
|
|
2972
|
-
return new MockInterceptor(
|
|
2973
|
-
opts && { ignoreTrailingSlash: this[kIgnoreTrailingSlash], ...opts },
|
|
2974
|
-
this[kDispatches2]
|
|
2975
|
-
);
|
|
2976
|
-
}
|
|
2977
|
-
cleanMocks() {
|
|
2978
|
-
this[kDispatches2] = [];
|
|
2979
|
-
}
|
|
2980
|
-
async [kClose]() {
|
|
2981
|
-
await promisify(this[kOriginalClose])();
|
|
2982
|
-
this[kConnected] = 0;
|
|
2983
|
-
this[kMockAgent][Symbols.kClients].delete(this[kOrigin]);
|
|
2984
|
-
}
|
|
2985
|
-
};
|
|
2986
|
-
module2.exports = MockPool;
|
|
2987
|
-
}
|
|
2988
|
-
});
|
|
2989
|
-
|
|
2990
|
-
// src/mock-agent/pending-interceptor-formatter.cjs
|
|
2991
|
-
var require_pending_interceptor_formatter = __commonJS({
|
|
2992
|
-
"src/mock-agent/pending-interceptor-formatter.cjs"(exports2, module2) {
|
|
2993
|
-
var util = require("node:util");
|
|
2994
|
-
module2.exports = class PendingInterceptorsFormatter {
|
|
2995
|
-
constructor({ disableColors } = {}) {
|
|
2996
|
-
this.inspectOptions = {
|
|
2997
|
-
breakLength: Infinity,
|
|
2998
|
-
colors: !disableColors && !process.env.CI
|
|
2999
|
-
};
|
|
3000
|
-
}
|
|
3001
|
-
format(pendingInterceptors) {
|
|
3002
|
-
const formatted = pendingInterceptors.map(
|
|
3003
|
-
({
|
|
3004
|
-
method,
|
|
3005
|
-
path,
|
|
3006
|
-
data: { statusCode },
|
|
3007
|
-
persist,
|
|
3008
|
-
times,
|
|
3009
|
-
timesInvoked,
|
|
3010
|
-
origin
|
|
3011
|
-
}) => {
|
|
3012
|
-
const meta = {
|
|
3013
|
-
persist: Boolean(persist),
|
|
3014
|
-
invoked: timesInvoked,
|
|
3015
|
-
remaining: persist ? Infinity : times - timesInvoked
|
|
3016
|
-
};
|
|
3017
|
-
const inspectedMeta = util.inspect(meta, this.inspectOptions);
|
|
3018
|
-
return `- ${method} ${origin}${path} ${statusCode} ${inspectedMeta}`;
|
|
3019
|
-
}
|
|
3020
|
-
);
|
|
3021
|
-
return formatted.join("\n");
|
|
3022
|
-
}
|
|
3023
|
-
};
|
|
3024
|
-
}
|
|
3025
|
-
});
|
|
3026
|
-
|
|
3027
|
-
// ../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/mock/mock-call-history.js
|
|
3028
|
-
var require_mock_call_history = __commonJS({
|
|
3029
|
-
"../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/mock/mock-call-history.js"(exports2, module2) {
|
|
3030
|
-
"use strict";
|
|
3031
|
-
var { kMockCallHistoryAddLog } = require_mock_symbols();
|
|
3032
|
-
var { InvalidArgumentError } = require_errors();
|
|
3033
|
-
function handleFilterCallsWithOptions(criteria, options, handler, store) {
|
|
3034
|
-
switch (options.operator) {
|
|
3035
|
-
case "OR":
|
|
3036
|
-
store.push(...handler(criteria));
|
|
3037
|
-
return store;
|
|
3038
|
-
case "AND":
|
|
3039
|
-
return handler.call({ logs: store }, criteria);
|
|
3040
|
-
default:
|
|
3041
|
-
throw new InvalidArgumentError("options.operator must to be a case insensitive string equal to 'OR' or 'AND'");
|
|
3042
|
-
}
|
|
3043
|
-
}
|
|
3044
|
-
function buildAndValidateFilterCallsOptions(options = {}) {
|
|
3045
|
-
const finalOptions = {};
|
|
3046
|
-
if ("operator" in options) {
|
|
3047
|
-
if (typeof options.operator !== "string" || options.operator.toUpperCase() !== "OR" && options.operator.toUpperCase() !== "AND") {
|
|
3048
|
-
throw new InvalidArgumentError("options.operator must to be a case insensitive string equal to 'OR' or 'AND'");
|
|
3049
|
-
}
|
|
3050
|
-
return {
|
|
3051
|
-
...finalOptions,
|
|
3052
|
-
operator: options.operator.toUpperCase()
|
|
3053
|
-
};
|
|
3054
|
-
}
|
|
3055
|
-
return finalOptions;
|
|
3056
|
-
}
|
|
3057
|
-
function makeFilterCalls(parameterName) {
|
|
3058
|
-
return (parameterValue) => {
|
|
3059
|
-
if (typeof parameterValue === "string" || parameterValue == null) {
|
|
3060
|
-
return this.logs.filter((log) => {
|
|
3061
|
-
return log[parameterName] === parameterValue;
|
|
3062
|
-
});
|
|
3063
|
-
}
|
|
3064
|
-
if (parameterValue instanceof RegExp) {
|
|
3065
|
-
return this.logs.filter((log) => {
|
|
3066
|
-
return parameterValue.test(log[parameterName]);
|
|
3067
|
-
});
|
|
3068
|
-
}
|
|
3069
|
-
throw new InvalidArgumentError(`${parameterName} parameter should be one of string, regexp, undefined or null`);
|
|
3070
|
-
};
|
|
3071
|
-
}
|
|
3072
|
-
function computeUrlWithMaybeSearchParameters(requestInit) {
|
|
3073
|
-
try {
|
|
3074
|
-
const url = new URL(requestInit.path, requestInit.origin);
|
|
3075
|
-
if (url.search.length !== 0) {
|
|
3076
|
-
return url;
|
|
3077
|
-
}
|
|
3078
|
-
url.search = new URLSearchParams(requestInit.query).toString();
|
|
3079
|
-
return url;
|
|
3080
|
-
} catch (error) {
|
|
3081
|
-
throw new InvalidArgumentError("An error occurred when computing MockCallHistoryLog.url", { cause: error });
|
|
3082
|
-
}
|
|
3083
|
-
}
|
|
3084
|
-
var MockCallHistoryLog = class {
|
|
3085
|
-
constructor(requestInit = {}) {
|
|
3086
|
-
this.body = requestInit.body;
|
|
3087
|
-
this.headers = requestInit.headers;
|
|
3088
|
-
this.method = requestInit.method;
|
|
3089
|
-
const url = computeUrlWithMaybeSearchParameters(requestInit);
|
|
3090
|
-
this.fullUrl = url.toString();
|
|
3091
|
-
this.origin = url.origin;
|
|
3092
|
-
this.path = url.pathname;
|
|
3093
|
-
this.searchParams = Object.fromEntries(url.searchParams);
|
|
3094
|
-
this.protocol = url.protocol;
|
|
3095
|
-
this.host = url.host;
|
|
3096
|
-
this.port = url.port;
|
|
3097
|
-
this.hash = url.hash;
|
|
3098
|
-
}
|
|
3099
|
-
toMap() {
|
|
3100
|
-
return /* @__PURE__ */ new Map(
|
|
3101
|
-
[
|
|
3102
|
-
["protocol", this.protocol],
|
|
3103
|
-
["host", this.host],
|
|
3104
|
-
["port", this.port],
|
|
3105
|
-
["origin", this.origin],
|
|
3106
|
-
["path", this.path],
|
|
3107
|
-
["hash", this.hash],
|
|
3108
|
-
["searchParams", this.searchParams],
|
|
3109
|
-
["fullUrl", this.fullUrl],
|
|
3110
|
-
["method", this.method],
|
|
3111
|
-
["body", this.body],
|
|
3112
|
-
["headers", this.headers]
|
|
3113
|
-
]
|
|
3114
|
-
);
|
|
3115
|
-
}
|
|
3116
|
-
toString() {
|
|
3117
|
-
const options = { betweenKeyValueSeparator: "->", betweenPairSeparator: "|" };
|
|
3118
|
-
let result = "";
|
|
3119
|
-
this.toMap().forEach((value, key) => {
|
|
3120
|
-
if (typeof value === "string" || value === void 0 || value === null) {
|
|
3121
|
-
result = `${result}${key}${options.betweenKeyValueSeparator}${value}${options.betweenPairSeparator}`;
|
|
3122
|
-
}
|
|
3123
|
-
if (typeof value === "object" && value !== null || Array.isArray(value)) {
|
|
3124
|
-
result = `${result}${key}${options.betweenKeyValueSeparator}${JSON.stringify(value)}${options.betweenPairSeparator}`;
|
|
3125
|
-
}
|
|
3126
|
-
});
|
|
3127
|
-
return result.slice(0, -1);
|
|
3128
|
-
}
|
|
3129
|
-
};
|
|
3130
|
-
var MockCallHistory = class {
|
|
3131
|
-
logs = [];
|
|
3132
|
-
calls() {
|
|
3133
|
-
return this.logs;
|
|
3134
|
-
}
|
|
3135
|
-
firstCall() {
|
|
3136
|
-
return this.logs.at(0);
|
|
3137
|
-
}
|
|
3138
|
-
lastCall() {
|
|
3139
|
-
return this.logs.at(-1);
|
|
3140
|
-
}
|
|
3141
|
-
nthCall(number) {
|
|
3142
|
-
if (typeof number !== "number") {
|
|
3143
|
-
throw new InvalidArgumentError("nthCall must be called with a number");
|
|
3144
|
-
}
|
|
3145
|
-
if (!Number.isInteger(number)) {
|
|
3146
|
-
throw new InvalidArgumentError("nthCall must be called with an integer");
|
|
3147
|
-
}
|
|
3148
|
-
if (Math.sign(number) !== 1) {
|
|
3149
|
-
throw new InvalidArgumentError("nthCall must be called with a positive value. use firstCall or lastCall instead");
|
|
3150
|
-
}
|
|
3151
|
-
return this.logs.at(number - 1);
|
|
3152
|
-
}
|
|
3153
|
-
filterCalls(criteria, options) {
|
|
3154
|
-
if (this.logs.length === 0) {
|
|
3155
|
-
return this.logs;
|
|
3156
|
-
}
|
|
3157
|
-
if (typeof criteria === "function") {
|
|
3158
|
-
return this.logs.filter(criteria);
|
|
3159
|
-
}
|
|
3160
|
-
if (criteria instanceof RegExp) {
|
|
3161
|
-
return this.logs.filter((log) => {
|
|
3162
|
-
return criteria.test(log.toString());
|
|
3163
|
-
});
|
|
3164
|
-
}
|
|
3165
|
-
if (typeof criteria === "object" && criteria !== null) {
|
|
3166
|
-
if (Object.keys(criteria).length === 0) {
|
|
3167
|
-
return this.logs;
|
|
3168
|
-
}
|
|
3169
|
-
const finalOptions = { operator: "OR", ...buildAndValidateFilterCallsOptions(options) };
|
|
3170
|
-
let maybeDuplicatedLogsFiltered = [];
|
|
3171
|
-
if ("protocol" in criteria) {
|
|
3172
|
-
maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.protocol, finalOptions, this.filterCallsByProtocol, maybeDuplicatedLogsFiltered);
|
|
3173
|
-
}
|
|
3174
|
-
if ("host" in criteria) {
|
|
3175
|
-
maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.host, finalOptions, this.filterCallsByHost, maybeDuplicatedLogsFiltered);
|
|
3176
|
-
}
|
|
3177
|
-
if ("port" in criteria) {
|
|
3178
|
-
maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.port, finalOptions, this.filterCallsByPort, maybeDuplicatedLogsFiltered);
|
|
3179
|
-
}
|
|
3180
|
-
if ("origin" in criteria) {
|
|
3181
|
-
maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.origin, finalOptions, this.filterCallsByOrigin, maybeDuplicatedLogsFiltered);
|
|
3182
|
-
}
|
|
3183
|
-
if ("path" in criteria) {
|
|
3184
|
-
maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.path, finalOptions, this.filterCallsByPath, maybeDuplicatedLogsFiltered);
|
|
3185
|
-
}
|
|
3186
|
-
if ("hash" in criteria) {
|
|
3187
|
-
maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.hash, finalOptions, this.filterCallsByHash, maybeDuplicatedLogsFiltered);
|
|
3188
|
-
}
|
|
3189
|
-
if ("fullUrl" in criteria) {
|
|
3190
|
-
maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.fullUrl, finalOptions, this.filterCallsByFullUrl, maybeDuplicatedLogsFiltered);
|
|
3191
|
-
}
|
|
3192
|
-
if ("method" in criteria) {
|
|
3193
|
-
maybeDuplicatedLogsFiltered = handleFilterCallsWithOptions(criteria.method, finalOptions, this.filterCallsByMethod, maybeDuplicatedLogsFiltered);
|
|
3194
|
-
}
|
|
3195
|
-
const uniqLogsFiltered = [...new Set(maybeDuplicatedLogsFiltered)];
|
|
3196
|
-
return uniqLogsFiltered;
|
|
3197
|
-
}
|
|
3198
|
-
throw new InvalidArgumentError("criteria parameter should be one of function, regexp, or object");
|
|
3199
|
-
}
|
|
3200
|
-
filterCallsByProtocol = makeFilterCalls.call(this, "protocol");
|
|
3201
|
-
filterCallsByHost = makeFilterCalls.call(this, "host");
|
|
3202
|
-
filterCallsByPort = makeFilterCalls.call(this, "port");
|
|
3203
|
-
filterCallsByOrigin = makeFilterCalls.call(this, "origin");
|
|
3204
|
-
filterCallsByPath = makeFilterCalls.call(this, "path");
|
|
3205
|
-
filterCallsByHash = makeFilterCalls.call(this, "hash");
|
|
3206
|
-
filterCallsByFullUrl = makeFilterCalls.call(this, "fullUrl");
|
|
3207
|
-
filterCallsByMethod = makeFilterCalls.call(this, "method");
|
|
3208
|
-
clear() {
|
|
3209
|
-
this.logs = [];
|
|
3210
|
-
}
|
|
3211
|
-
[kMockCallHistoryAddLog](requestInit) {
|
|
3212
|
-
const log = new MockCallHistoryLog(requestInit);
|
|
3213
|
-
this.logs.push(log);
|
|
3214
|
-
return log;
|
|
3215
|
-
}
|
|
3216
|
-
*[Symbol.iterator]() {
|
|
3217
|
-
for (const log of this.calls()) {
|
|
3218
|
-
yield log;
|
|
3219
|
-
}
|
|
3220
|
-
}
|
|
3221
|
-
};
|
|
3222
|
-
module2.exports.MockCallHistory = MockCallHistory;
|
|
3223
|
-
module2.exports.MockCallHistoryLog = MockCallHistoryLog;
|
|
3224
|
-
}
|
|
3225
|
-
});
|
|
3226
|
-
|
|
3227
|
-
// ../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/mock/mock-agent.js
|
|
3228
|
-
var require_mock_agent = __commonJS({
|
|
3229
|
-
"../../node_modules/.pnpm/undici@7.18.2/node_modules/undici/lib/mock/mock-agent.js"(exports2, module2) {
|
|
3230
|
-
"use strict";
|
|
3231
|
-
var { kClients: kClients2 } = require_symbols();
|
|
3232
|
-
var Agent = require_agent();
|
|
3233
|
-
var {
|
|
3234
|
-
kAgent,
|
|
3235
|
-
kMockAgentSet,
|
|
3236
|
-
kMockAgentGet,
|
|
3237
|
-
kDispatches: kDispatches2,
|
|
3238
|
-
kIsMockActive: kIsMockActive2,
|
|
3239
|
-
kNetConnect,
|
|
3240
|
-
kGetNetConnect,
|
|
3241
|
-
kOptions,
|
|
3242
|
-
kFactory,
|
|
3243
|
-
kMockAgentRegisterCallHistory,
|
|
3244
|
-
kMockAgentIsCallHistoryEnabled,
|
|
3245
|
-
kMockAgentAddCallHistoryLog,
|
|
3246
|
-
kMockAgentMockCallHistoryInstance,
|
|
3247
|
-
kMockAgentAcceptsNonStandardSearchParameters,
|
|
3248
|
-
kMockCallHistoryAddLog,
|
|
3249
|
-
kIgnoreTrailingSlash
|
|
3250
|
-
} = require_mock_symbols();
|
|
3251
|
-
var MockClient = require_mock_client();
|
|
3252
|
-
var MockPool = require_mock_pool();
|
|
3253
|
-
var { matchValue, normalizeSearchParams, buildAndValidateMockOptions } = require_mock_utils();
|
|
3254
|
-
var { InvalidArgumentError, UndiciError } = require_errors();
|
|
3255
|
-
var Dispatcher = require_dispatcher();
|
|
3256
|
-
var PendingInterceptorsFormatter = require_pending_interceptor_formatter();
|
|
3257
|
-
var { MockCallHistory } = require_mock_call_history();
|
|
3258
|
-
var MockAgent2 = class extends Dispatcher {
|
|
3259
|
-
constructor(opts = {}) {
|
|
3260
|
-
super(opts);
|
|
3261
|
-
const mockOptions = buildAndValidateMockOptions(opts);
|
|
3262
|
-
this[kNetConnect] = true;
|
|
3263
|
-
this[kIsMockActive2] = true;
|
|
3264
|
-
this[kMockAgentIsCallHistoryEnabled] = mockOptions.enableCallHistory ?? false;
|
|
3265
|
-
this[kMockAgentAcceptsNonStandardSearchParameters] = mockOptions.acceptNonStandardSearchParameters ?? false;
|
|
3266
|
-
this[kIgnoreTrailingSlash] = mockOptions.ignoreTrailingSlash ?? false;
|
|
3267
|
-
if (opts?.agent && typeof opts.agent.dispatch !== "function") {
|
|
3268
|
-
throw new InvalidArgumentError("Argument opts.agent must implement Agent");
|
|
3269
|
-
}
|
|
3270
|
-
const agent = opts?.agent ? opts.agent : new Agent(opts);
|
|
3271
|
-
this[kAgent] = agent;
|
|
3272
|
-
this[kClients2] = agent[kClients2];
|
|
3273
|
-
this[kOptions] = mockOptions;
|
|
3274
|
-
if (this[kMockAgentIsCallHistoryEnabled]) {
|
|
3275
|
-
this[kMockAgentRegisterCallHistory]();
|
|
3276
|
-
}
|
|
3277
|
-
}
|
|
3278
|
-
get(origin) {
|
|
3279
|
-
const originKey = this[kIgnoreTrailingSlash] ? origin.replace(/\/$/, "") : origin;
|
|
3280
|
-
let dispatcher = this[kMockAgentGet](originKey);
|
|
3281
|
-
if (!dispatcher) {
|
|
3282
|
-
dispatcher = this[kFactory](originKey);
|
|
3283
|
-
this[kMockAgentSet](originKey, dispatcher);
|
|
3284
|
-
}
|
|
3285
|
-
return dispatcher;
|
|
3286
|
-
}
|
|
3287
|
-
dispatch(opts, handler) {
|
|
3288
|
-
this.get(opts.origin);
|
|
3289
|
-
this[kMockAgentAddCallHistoryLog](opts);
|
|
3290
|
-
const acceptNonStandardSearchParameters = this[kMockAgentAcceptsNonStandardSearchParameters];
|
|
3291
|
-
const dispatchOpts = { ...opts };
|
|
3292
|
-
if (acceptNonStandardSearchParameters && dispatchOpts.path) {
|
|
3293
|
-
const [path, searchParams] = dispatchOpts.path.split("?");
|
|
3294
|
-
const normalizedSearchParams = normalizeSearchParams(searchParams, acceptNonStandardSearchParameters);
|
|
3295
|
-
dispatchOpts.path = `${path}?${normalizedSearchParams}`;
|
|
3296
|
-
}
|
|
3297
|
-
return this[kAgent].dispatch(dispatchOpts, handler);
|
|
3298
|
-
}
|
|
3299
|
-
async close() {
|
|
3300
|
-
this.clearCallHistory();
|
|
3301
|
-
await this[kAgent].close();
|
|
3302
|
-
this[kClients2].clear();
|
|
3303
|
-
}
|
|
3304
|
-
deactivate() {
|
|
3305
|
-
this[kIsMockActive2] = false;
|
|
3306
|
-
}
|
|
3307
|
-
activate() {
|
|
3308
|
-
this[kIsMockActive2] = true;
|
|
3309
|
-
}
|
|
3310
|
-
enableNetConnect(matcher) {
|
|
3311
|
-
if (typeof matcher === "string" || typeof matcher === "function" || matcher instanceof RegExp) {
|
|
3312
|
-
if (Array.isArray(this[kNetConnect])) {
|
|
3313
|
-
this[kNetConnect].push(matcher);
|
|
3314
|
-
} else {
|
|
3315
|
-
this[kNetConnect] = [matcher];
|
|
3316
|
-
}
|
|
3317
|
-
} else if (typeof matcher === "undefined") {
|
|
3318
|
-
this[kNetConnect] = true;
|
|
3319
|
-
} else {
|
|
3320
|
-
throw new InvalidArgumentError("Unsupported matcher. Must be one of String|Function|RegExp.");
|
|
3321
|
-
}
|
|
3322
|
-
}
|
|
3323
|
-
disableNetConnect() {
|
|
3324
|
-
this[kNetConnect] = false;
|
|
3325
|
-
}
|
|
3326
|
-
enableCallHistory() {
|
|
3327
|
-
this[kMockAgentIsCallHistoryEnabled] = true;
|
|
3328
|
-
return this;
|
|
3329
|
-
}
|
|
3330
|
-
disableCallHistory() {
|
|
3331
|
-
this[kMockAgentIsCallHistoryEnabled] = false;
|
|
3332
|
-
return this;
|
|
3333
|
-
}
|
|
3334
|
-
getCallHistory() {
|
|
3335
|
-
return this[kMockAgentMockCallHistoryInstance];
|
|
3336
|
-
}
|
|
3337
|
-
clearCallHistory() {
|
|
3338
|
-
if (this[kMockAgentMockCallHistoryInstance] !== void 0) {
|
|
3339
|
-
this[kMockAgentMockCallHistoryInstance].clear();
|
|
3340
|
-
}
|
|
3341
|
-
}
|
|
3342
|
-
// This is required to bypass issues caused by using global symbols - see:
|
|
3343
|
-
// https://github.com/nodejs/undici/issues/1447
|
|
3344
|
-
get isMockActive() {
|
|
3345
|
-
return this[kIsMockActive2];
|
|
3346
|
-
}
|
|
3347
|
-
[kMockAgentRegisterCallHistory]() {
|
|
3348
|
-
if (this[kMockAgentMockCallHistoryInstance] === void 0) {
|
|
3349
|
-
this[kMockAgentMockCallHistoryInstance] = new MockCallHistory();
|
|
3350
|
-
}
|
|
3351
|
-
}
|
|
3352
|
-
[kMockAgentAddCallHistoryLog](opts) {
|
|
3353
|
-
if (this[kMockAgentIsCallHistoryEnabled]) {
|
|
3354
|
-
this[kMockAgentRegisterCallHistory]();
|
|
3355
|
-
this[kMockAgentMockCallHistoryInstance][kMockCallHistoryAddLog](opts);
|
|
3356
|
-
}
|
|
3357
|
-
}
|
|
3358
|
-
[kMockAgentSet](origin, dispatcher) {
|
|
3359
|
-
this[kClients2].set(origin, { count: 0, dispatcher });
|
|
3360
|
-
}
|
|
3361
|
-
[kFactory](origin) {
|
|
3362
|
-
const mockOptions = Object.assign({ agent: this }, this[kOptions]);
|
|
3363
|
-
return this[kOptions] && this[kOptions].connections === 1 ? new MockClient(origin, mockOptions) : new MockPool(origin, mockOptions);
|
|
3364
|
-
}
|
|
3365
|
-
[kMockAgentGet](origin) {
|
|
3366
|
-
const result = this[kClients2].get(origin);
|
|
3367
|
-
if (result?.dispatcher) {
|
|
3368
|
-
return result.dispatcher;
|
|
3369
|
-
}
|
|
3370
|
-
if (typeof origin !== "string") {
|
|
3371
|
-
const dispatcher = this[kFactory]("http://localhost:9999");
|
|
3372
|
-
this[kMockAgentSet](origin, dispatcher);
|
|
3373
|
-
return dispatcher;
|
|
3374
|
-
}
|
|
3375
|
-
for (const [keyMatcher, result2] of Array.from(this[kClients2])) {
|
|
3376
|
-
if (result2 && typeof keyMatcher !== "string" && matchValue(keyMatcher, origin)) {
|
|
3377
|
-
const dispatcher = this[kFactory](origin);
|
|
3378
|
-
this[kMockAgentSet](origin, dispatcher);
|
|
3379
|
-
dispatcher[kDispatches2] = result2.dispatcher[kDispatches2];
|
|
3380
|
-
return dispatcher;
|
|
3381
|
-
}
|
|
3382
|
-
}
|
|
3383
|
-
}
|
|
3384
|
-
[kGetNetConnect]() {
|
|
3385
|
-
return this[kNetConnect];
|
|
3386
|
-
}
|
|
3387
|
-
pendingInterceptors() {
|
|
3388
|
-
const mockAgentClients = this[kClients2];
|
|
3389
|
-
return Array.from(mockAgentClients.entries()).flatMap(([origin, result]) => result.dispatcher[kDispatches2].map((dispatch) => ({ ...dispatch, origin }))).filter(({ pending }) => pending);
|
|
3390
|
-
}
|
|
3391
|
-
assertNoPendingInterceptors({ pendingInterceptorsFormatter = new PendingInterceptorsFormatter() } = {}) {
|
|
3392
|
-
const pending = this.pendingInterceptors();
|
|
3393
|
-
if (pending.length === 0) {
|
|
3394
|
-
return;
|
|
3395
|
-
}
|
|
3396
|
-
throw new UndiciError(
|
|
3397
|
-
pending.length === 1 ? `1 interceptor is pending:
|
|
3398
|
-
|
|
3399
|
-
${pendingInterceptorsFormatter.format(pending)}`.trim() : `${pending.length} interceptors are pending:
|
|
3400
|
-
|
|
3401
|
-
${pendingInterceptorsFormatter.format(pending)}`.trim()
|
|
3402
|
-
);
|
|
3403
|
-
}
|
|
3404
|
-
};
|
|
3405
|
-
module2.exports = MockAgent2;
|
|
3406
|
-
}
|
|
3407
|
-
});
|
|
3408
|
-
|
|
3409
|
-
// src/mock-agent/index.cjs
|
|
3410
|
-
globalThis.global = globalThis;
|
|
3411
|
-
process.versions = { node: "18.0.0" };
|
|
3412
|
-
var MockAgent = require_mock_agent();
|
|
3413
|
-
var { kClients } = require_symbols();
|
|
3414
|
-
var { kIsMockActive, kDispatches } = require_mock_symbols();
|
|
3415
|
-
var { setDispatcher } = require_dispatcher2();
|
|
3416
|
-
function isMockActive(agent) {
|
|
3417
|
-
return agent[kIsMockActive];
|
|
3418
|
-
}
|
|
3419
|
-
function resetMockAgent(agent) {
|
|
3420
|
-
agent.deactivate();
|
|
3421
|
-
agent.enableNetConnect();
|
|
3422
|
-
for (const mockClient of agent[kClients].values()) {
|
|
3423
|
-
mockClient.dispatcher?.[kDispatches].splice(0);
|
|
3424
|
-
}
|
|
3425
|
-
agent.assertNoPendingInterceptors();
|
|
3426
|
-
}
|
|
3427
|
-
module.exports = {
|
|
3428
|
-
MockAgent,
|
|
3429
|
-
setDispatcher,
|
|
3430
|
-
isMockActive,
|
|
3431
|
-
resetMockAgent
|
|
3432
|
-
};
|
|
3433
|
-
//# sourceMappingURL=mock-agent.cjs.map
|