msw 2.14.7 → 2.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/index.js +1 -1
- package/lib/browser/index.mjs +1 -1
- package/lib/core/{HttpResponse-BTyqrRB6.d.mts → HttpResponse-BE_Y2Ak9.d.mts} +18 -0
- package/lib/core/{HttpResponse-BXyXQFMJ.d.ts → HttpResponse-DL-P1EeG.d.ts} +18 -0
- package/lib/core/HttpResponse.d.mts +1 -1
- package/lib/core/HttpResponse.d.ts +1 -1
- package/lib/core/experimental/compat.d.mts +1 -1
- package/lib/core/experimental/compat.d.ts +1 -1
- package/lib/core/experimental/define-network.d.mts +1 -1
- package/lib/core/experimental/define-network.d.ts +1 -1
- package/lib/core/experimental/frames/http-frame.d.mts +1 -1
- package/lib/core/experimental/frames/http-frame.d.ts +1 -1
- package/lib/core/experimental/frames/network-frame.d.mts +1 -1
- package/lib/core/experimental/frames/network-frame.d.ts +1 -1
- package/lib/core/experimental/frames/websocket-frame.d.mts +1 -1
- package/lib/core/experimental/frames/websocket-frame.d.ts +1 -1
- package/lib/core/experimental/handlers-controller.d.mts +1 -1
- package/lib/core/experimental/handlers-controller.d.ts +1 -1
- package/lib/core/experimental/index.d.mts +1 -1
- package/lib/core/experimental/index.d.ts +1 -1
- package/lib/core/experimental/on-unhandled-frame.d.mts +1 -1
- package/lib/core/experimental/on-unhandled-frame.d.ts +1 -1
- package/lib/core/experimental/setup-api.d.mts +1 -1
- package/lib/core/experimental/setup-api.d.ts +1 -1
- package/lib/core/experimental/sources/interceptor-source.d.mts +1 -1
- package/lib/core/experimental/sources/interceptor-source.d.ts +1 -1
- package/lib/core/experimental/sources/network-source.d.mts +1 -1
- package/lib/core/experimental/sources/network-source.d.ts +1 -1
- package/lib/core/getResponse.d.mts +1 -1
- package/lib/core/getResponse.d.ts +1 -1
- package/lib/core/graphql.d.mts +1 -1
- package/lib/core/graphql.d.ts +1 -1
- package/lib/core/handlers/GraphQLHandler.d.mts +1 -1
- package/lib/core/handlers/GraphQLHandler.d.ts +1 -1
- package/lib/core/handlers/HttpHandler.d.mts +1 -1
- package/lib/core/handlers/HttpHandler.d.ts +1 -1
- package/lib/core/handlers/RequestHandler.d.mts +1 -1
- package/lib/core/handlers/RequestHandler.d.ts +1 -1
- package/lib/core/handlers/RequestHandler.js +88 -23
- package/lib/core/handlers/RequestHandler.js.map +1 -1
- package/lib/core/handlers/RequestHandler.mjs +88 -23
- package/lib/core/handlers/RequestHandler.mjs.map +1 -1
- package/lib/core/http.d.mts +1 -1
- package/lib/core/http.d.ts +1 -1
- package/lib/core/index.d.mts +1 -1
- package/lib/core/index.d.ts +1 -1
- package/lib/core/passthrough.d.mts +1 -1
- package/lib/core/passthrough.d.ts +1 -1
- package/lib/core/sse.d.mts +2 -2
- package/lib/core/sse.d.ts +2 -2
- package/lib/core/sse.js +66 -48
- package/lib/core/sse.js.map +1 -1
- package/lib/core/sse.mjs +65 -47
- package/lib/core/sse.mjs.map +1 -1
- package/lib/core/utils/HttpResponse/decorators.d.mts +8 -3
- package/lib/core/utils/HttpResponse/decorators.d.ts +8 -3
- package/lib/core/utils/HttpResponse/decorators.js +13 -0
- package/lib/core/utils/HttpResponse/decorators.js.map +1 -1
- package/lib/core/utils/HttpResponse/decorators.mjs +13 -0
- package/lib/core/utils/HttpResponse/decorators.mjs.map +1 -1
- package/lib/core/utils/executeHandlers.d.mts +1 -1
- package/lib/core/utils/executeHandlers.d.ts +1 -1
- package/lib/core/utils/handleRequest.d.mts +1 -1
- package/lib/core/utils/handleRequest.d.ts +1 -1
- package/lib/core/utils/internal/attachSiblingHandlers.d.mts +1 -1
- package/lib/core/utils/internal/attachSiblingHandlers.d.ts +1 -1
- package/lib/core/utils/internal/isHandlerKind.d.mts +1 -1
- package/lib/core/utils/internal/isHandlerKind.d.ts +1 -1
- package/lib/core/utils/internal/observe-response-body-stream.d.mts +18 -0
- package/lib/core/utils/internal/observe-response-body-stream.d.ts +18 -0
- package/lib/core/utils/internal/observe-response-body-stream.js +64 -0
- package/lib/core/utils/internal/observe-response-body-stream.js.map +1 -0
- package/lib/core/utils/internal/observe-response-body-stream.mjs +44 -0
- package/lib/core/utils/internal/observe-response-body-stream.mjs.map +1 -0
- package/lib/core/utils/internal/parseGraphQLRequest.d.mts +1 -1
- package/lib/core/utils/internal/parseGraphQLRequest.d.ts +1 -1
- package/lib/core/utils/internal/parseMultipartData.d.mts +1 -1
- package/lib/core/utils/internal/parseMultipartData.d.ts +1 -1
- package/lib/core/ws/handleWebSocketEvent.d.mts +1 -1
- package/lib/core/ws/handleWebSocketEvent.d.ts +1 -1
- package/lib/iife/index.js +270 -137
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +21 -9
- package/package.json +2 -2
- package/src/core/handlers/HttpHandler.test.ts +89 -0
- package/src/core/handlers/RequestHandler.ts +142 -32
- package/src/core/sse.ts +85 -53
- package/src/core/utils/HttpResponse/decorators.ts +23 -2
- package/src/core/utils/internal/observe-response-body-stream.test.ts +64 -0
- package/src/core/utils/internal/observe-response-body-stream.ts +77 -0
- package/src/mockServiceWorker.js +19 -7
package/lib/iife/index.js
CHANGED
|
@@ -19062,6 +19062,18 @@ ${operationTypes.join("\n")}
|
|
|
19062
19062
|
function getRawSetCookie(response) {
|
|
19063
19063
|
return Reflect.get(response, kSetCookie);
|
|
19064
19064
|
}
|
|
19065
|
+
function copyResponseOwnProperties(source, target) {
|
|
19066
|
+
for (const propertyName of Reflect.ownKeys(source)) {
|
|
19067
|
+
const descriptor = Object.getOwnPropertyDescriptor(source, propertyName);
|
|
19068
|
+
const existingDescriptor = Object.getOwnPropertyDescriptor(
|
|
19069
|
+
target,
|
|
19070
|
+
propertyName
|
|
19071
|
+
);
|
|
19072
|
+
if (descriptor && existingDescriptor == null) {
|
|
19073
|
+
Object.defineProperty(target, propertyName, descriptor);
|
|
19074
|
+
}
|
|
19075
|
+
}
|
|
19076
|
+
}
|
|
19065
19077
|
|
|
19066
19078
|
// src/core/HttpResponse.ts
|
|
19067
19079
|
var bodyType = /* @__PURE__ */ Symbol("bodyType");
|
|
@@ -19213,6 +19225,111 @@ ${operationTypes.join("\n")}
|
|
|
19213
19225
|
}
|
|
19214
19226
|
};
|
|
19215
19227
|
|
|
19228
|
+
// node_modules/.pnpm/@open-draft+deferred-promise@3.0.0/node_modules/@open-draft/deferred-promise/build/index.mjs
|
|
19229
|
+
function createDeferredExecutor2() {
|
|
19230
|
+
const executor = ((resolve, reject) => {
|
|
19231
|
+
executor.state = "pending";
|
|
19232
|
+
executor.resolve = (data) => {
|
|
19233
|
+
if (executor.state !== "pending") return;
|
|
19234
|
+
executor.result = data;
|
|
19235
|
+
const onFulfilled = (value) => {
|
|
19236
|
+
executor.state = "fulfilled";
|
|
19237
|
+
return value;
|
|
19238
|
+
};
|
|
19239
|
+
return resolve(data instanceof Promise ? data : Promise.resolve(data).then(onFulfilled));
|
|
19240
|
+
};
|
|
19241
|
+
executor.reject = (reason) => {
|
|
19242
|
+
if (executor.state !== "pending") return;
|
|
19243
|
+
queueMicrotask(() => {
|
|
19244
|
+
executor.state = "rejected";
|
|
19245
|
+
});
|
|
19246
|
+
return reject(executor.rejectionReason = reason);
|
|
19247
|
+
};
|
|
19248
|
+
});
|
|
19249
|
+
return executor;
|
|
19250
|
+
}
|
|
19251
|
+
var DeferredPromise2 = class extends Promise {
|
|
19252
|
+
#executor;
|
|
19253
|
+
resolve;
|
|
19254
|
+
reject;
|
|
19255
|
+
constructor(executor = null) {
|
|
19256
|
+
const deferredExecutor = createDeferredExecutor2();
|
|
19257
|
+
super((originalResolve, originalReject) => {
|
|
19258
|
+
deferredExecutor(originalResolve, originalReject);
|
|
19259
|
+
executor?.(deferredExecutor.resolve, deferredExecutor.reject);
|
|
19260
|
+
});
|
|
19261
|
+
this.#executor = deferredExecutor;
|
|
19262
|
+
this.resolve = this.#executor.resolve;
|
|
19263
|
+
this.reject = this.#executor.reject;
|
|
19264
|
+
}
|
|
19265
|
+
get state() {
|
|
19266
|
+
return this.#executor.state;
|
|
19267
|
+
}
|
|
19268
|
+
get rejectionReason() {
|
|
19269
|
+
return this.#executor.rejectionReason;
|
|
19270
|
+
}
|
|
19271
|
+
then(onFulfilled, onRejected) {
|
|
19272
|
+
return this.#decorate(super.then(onFulfilled, onRejected));
|
|
19273
|
+
}
|
|
19274
|
+
catch(onRejected) {
|
|
19275
|
+
return this.#decorate(super.catch(onRejected));
|
|
19276
|
+
}
|
|
19277
|
+
finally(onfinally) {
|
|
19278
|
+
return this.#decorate(super.finally(onfinally));
|
|
19279
|
+
}
|
|
19280
|
+
#decorate(promise) {
|
|
19281
|
+
return Object.defineProperties(promise, {
|
|
19282
|
+
resolve: {
|
|
19283
|
+
configurable: true,
|
|
19284
|
+
value: this.resolve
|
|
19285
|
+
},
|
|
19286
|
+
reject: {
|
|
19287
|
+
configurable: true,
|
|
19288
|
+
value: this.reject
|
|
19289
|
+
}
|
|
19290
|
+
});
|
|
19291
|
+
}
|
|
19292
|
+
};
|
|
19293
|
+
|
|
19294
|
+
// src/core/utils/internal/observe-response-body-stream.ts
|
|
19295
|
+
function observeResponseBodyStream(response) {
|
|
19296
|
+
if (response.body == null || response.bodyUsed || response.body.locked) {
|
|
19297
|
+
return null;
|
|
19298
|
+
}
|
|
19299
|
+
const settled = new DeferredPromise2();
|
|
19300
|
+
const reader = response.body.getReader();
|
|
19301
|
+
const observedStream = new ReadableStream({
|
|
19302
|
+
async pull(controller) {
|
|
19303
|
+
try {
|
|
19304
|
+
const readResult = await reader.read();
|
|
19305
|
+
if (readResult.done) {
|
|
19306
|
+
settled.resolve();
|
|
19307
|
+
controller.close();
|
|
19308
|
+
return;
|
|
19309
|
+
}
|
|
19310
|
+
controller.enqueue(readResult.value);
|
|
19311
|
+
} catch (error3) {
|
|
19312
|
+
settled.resolve();
|
|
19313
|
+
throw error3;
|
|
19314
|
+
}
|
|
19315
|
+
},
|
|
19316
|
+
async cancel(reason) {
|
|
19317
|
+
settled.resolve();
|
|
19318
|
+
await reader.cancel(reason);
|
|
19319
|
+
}
|
|
19320
|
+
});
|
|
19321
|
+
const observedResponse = new FetchResponse(observedStream, {
|
|
19322
|
+
status: response.status,
|
|
19323
|
+
statusText: response.statusText,
|
|
19324
|
+
headers: response.headers
|
|
19325
|
+
});
|
|
19326
|
+
copyResponseOwnProperties(response, observedResponse);
|
|
19327
|
+
return {
|
|
19328
|
+
response: observedResponse,
|
|
19329
|
+
settled
|
|
19330
|
+
};
|
|
19331
|
+
}
|
|
19332
|
+
|
|
19216
19333
|
// src/core/handlers/RequestHandler.ts
|
|
19217
19334
|
var RequestHandler = class _RequestHandler {
|
|
19218
19335
|
static cache = /* @__PURE__ */ new WeakMap();
|
|
@@ -19338,18 +19455,32 @@ ${operationTypes.join("\n")}
|
|
|
19338
19455
|
parsedResult
|
|
19339
19456
|
});
|
|
19340
19457
|
const listenerController = new AbortController();
|
|
19341
|
-
|
|
19342
|
-
|
|
19343
|
-
(
|
|
19344
|
-
|
|
19345
|
-
|
|
19346
|
-
|
|
19458
|
+
let finalizeFunction;
|
|
19459
|
+
const getFinalize = () => {
|
|
19460
|
+
if (finalizeFunction == null) {
|
|
19461
|
+
if (!args.request.signal.aborted) {
|
|
19462
|
+
args.request.signal.addEventListener(
|
|
19463
|
+
"abort",
|
|
19464
|
+
() => this.runScheduledCleanups(args.requestId),
|
|
19465
|
+
{
|
|
19466
|
+
once: true,
|
|
19467
|
+
signal: listenerController.signal
|
|
19468
|
+
}
|
|
19469
|
+
);
|
|
19470
|
+
}
|
|
19471
|
+
finalizeFunction = (callback) => {
|
|
19472
|
+
this.scheduleCleanup(args.requestId, callback);
|
|
19473
|
+
if (args.request.signal.aborted) {
|
|
19474
|
+
void this.runScheduledCleanups(args.requestId);
|
|
19475
|
+
}
|
|
19476
|
+
};
|
|
19347
19477
|
}
|
|
19348
|
-
|
|
19478
|
+
return finalizeFunction;
|
|
19479
|
+
};
|
|
19349
19480
|
const mockedResponsePromise = executeResolver({
|
|
19350
19481
|
...resolverExtras,
|
|
19351
|
-
finalize
|
|
19352
|
-
|
|
19482
|
+
get finalize() {
|
|
19483
|
+
return getFinalize();
|
|
19353
19484
|
},
|
|
19354
19485
|
requestId: args.requestId,
|
|
19355
19486
|
request: args.request
|
|
@@ -19386,8 +19517,11 @@ ${operationTypes.join("\n")}
|
|
|
19386
19517
|
throw error3;
|
|
19387
19518
|
}
|
|
19388
19519
|
if (!isIterable(result)) {
|
|
19389
|
-
|
|
19390
|
-
|
|
19520
|
+
return this.complete({
|
|
19521
|
+
request: info.request,
|
|
19522
|
+
requestId: info.requestId,
|
|
19523
|
+
response: result
|
|
19524
|
+
});
|
|
19391
19525
|
}
|
|
19392
19526
|
const existingCleanups = this.scheduledCleanups.get(info.requestId);
|
|
19393
19527
|
if (existingCleanups != null && existingCleanups.length > 0) {
|
|
@@ -19404,8 +19538,11 @@ ${operationTypes.join("\n")}
|
|
|
19404
19538
|
}
|
|
19405
19539
|
if (done) {
|
|
19406
19540
|
this.isUsed = true;
|
|
19407
|
-
|
|
19408
|
-
|
|
19541
|
+
return this.complete({
|
|
19542
|
+
request: info.request,
|
|
19543
|
+
requestId: info.requestId,
|
|
19544
|
+
response: this.resolverIteratorResult?.clone()
|
|
19545
|
+
});
|
|
19409
19546
|
}
|
|
19410
19547
|
return nextResponse;
|
|
19411
19548
|
};
|
|
@@ -19451,21 +19588,65 @@ ${operationTypes.join("\n")}
|
|
|
19451
19588
|
);
|
|
19452
19589
|
}
|
|
19453
19590
|
}
|
|
19454
|
-
|
|
19591
|
+
/**
|
|
19592
|
+
* Remove and return the cleanups scheduled for the given request
|
|
19593
|
+
* (or the pending iterator cleanups for generator resolvers).
|
|
19594
|
+
*/
|
|
19595
|
+
takeScheduledCleanups(requestId) {
|
|
19455
19596
|
if (this.resolverIterator && this.resolverIteratorCleanups != null && this.resolverIteratorCleanups.length > 0) {
|
|
19456
|
-
|
|
19457
|
-
|
|
19458
|
-
|
|
19459
|
-
this.resolverIteratorCleanups = void 0;
|
|
19460
|
-
}
|
|
19461
|
-
return;
|
|
19597
|
+
const cleanups2 = this.resolverIteratorCleanups;
|
|
19598
|
+
this.resolverIteratorCleanups = void 0;
|
|
19599
|
+
return cleanups2;
|
|
19462
19600
|
}
|
|
19463
19601
|
const cleanups = this.scheduledCleanups.get(requestId);
|
|
19464
|
-
if (!cleanups || cleanups.length
|
|
19465
|
-
return;
|
|
19602
|
+
if (!cleanups || cleanups.length === 0) {
|
|
19603
|
+
return void 0;
|
|
19466
19604
|
}
|
|
19467
|
-
await this.exhaustCleanups(cleanups);
|
|
19468
19605
|
this.scheduledCleanups.delete(requestId);
|
|
19606
|
+
return cleanups;
|
|
19607
|
+
}
|
|
19608
|
+
async runScheduledCleanups(requestId) {
|
|
19609
|
+
const cleanups = this.takeScheduledCleanups(requestId);
|
|
19610
|
+
if (cleanups) {
|
|
19611
|
+
await this.exhaustCleanups(cleanups);
|
|
19612
|
+
}
|
|
19613
|
+
}
|
|
19614
|
+
/**
|
|
19615
|
+
* Conclude the response resolution for the given request.
|
|
19616
|
+
* Runs the scheduled cleanups immediately for responses without a
|
|
19617
|
+
* `ReadableStream` body. For streamed responses, returns an observed
|
|
19618
|
+
* copy of the response and defers the cleanups until its body settles
|
|
19619
|
+
* (is read to completion, errored, or canceled) or the request is
|
|
19620
|
+
* aborted, whichever comes first.
|
|
19621
|
+
*/
|
|
19622
|
+
async complete(args) {
|
|
19623
|
+
const cleanups = this.takeScheduledCleanups(args.requestId);
|
|
19624
|
+
if (!cleanups) {
|
|
19625
|
+
return args.response;
|
|
19626
|
+
}
|
|
19627
|
+
const observedResponse = args.response ? observeResponseBodyStream(args.response) : null;
|
|
19628
|
+
if (!observedResponse) {
|
|
19629
|
+
await this.exhaustCleanups(cleanups);
|
|
19630
|
+
return args.response;
|
|
19631
|
+
}
|
|
19632
|
+
const listenerController = new AbortController();
|
|
19633
|
+
const runCleanupsOnce = () => {
|
|
19634
|
+
if (listenerController.signal.aborted) {
|
|
19635
|
+
return;
|
|
19636
|
+
}
|
|
19637
|
+
listenerController.abort();
|
|
19638
|
+
void this.exhaustCleanups(cleanups);
|
|
19639
|
+
};
|
|
19640
|
+
void observedResponse.settled.then(runCleanupsOnce);
|
|
19641
|
+
if (args.request.signal.aborted) {
|
|
19642
|
+
runCleanupsOnce();
|
|
19643
|
+
} else {
|
|
19644
|
+
args.request.signal.addEventListener("abort", runCleanupsOnce, {
|
|
19645
|
+
once: true,
|
|
19646
|
+
signal: listenerController.signal
|
|
19647
|
+
});
|
|
19648
|
+
}
|
|
19649
|
+
return observedResponse.response;
|
|
19469
19650
|
}
|
|
19470
19651
|
};
|
|
19471
19652
|
function forwardResponseCookies(response) {
|
|
@@ -24181,72 +24362,6 @@ Consider naming this operation or using "graphql.operation()" request handler to
|
|
|
24181
24362
|
}
|
|
24182
24363
|
};
|
|
24183
24364
|
|
|
24184
|
-
// node_modules/.pnpm/@open-draft+deferred-promise@3.0.0/node_modules/@open-draft/deferred-promise/build/index.mjs
|
|
24185
|
-
function createDeferredExecutor2() {
|
|
24186
|
-
const executor = ((resolve, reject) => {
|
|
24187
|
-
executor.state = "pending";
|
|
24188
|
-
executor.resolve = (data) => {
|
|
24189
|
-
if (executor.state !== "pending") return;
|
|
24190
|
-
executor.result = data;
|
|
24191
|
-
const onFulfilled = (value) => {
|
|
24192
|
-
executor.state = "fulfilled";
|
|
24193
|
-
return value;
|
|
24194
|
-
};
|
|
24195
|
-
return resolve(data instanceof Promise ? data : Promise.resolve(data).then(onFulfilled));
|
|
24196
|
-
};
|
|
24197
|
-
executor.reject = (reason) => {
|
|
24198
|
-
if (executor.state !== "pending") return;
|
|
24199
|
-
queueMicrotask(() => {
|
|
24200
|
-
executor.state = "rejected";
|
|
24201
|
-
});
|
|
24202
|
-
return reject(executor.rejectionReason = reason);
|
|
24203
|
-
};
|
|
24204
|
-
});
|
|
24205
|
-
return executor;
|
|
24206
|
-
}
|
|
24207
|
-
var DeferredPromise2 = class extends Promise {
|
|
24208
|
-
#executor;
|
|
24209
|
-
resolve;
|
|
24210
|
-
reject;
|
|
24211
|
-
constructor(executor = null) {
|
|
24212
|
-
const deferredExecutor = createDeferredExecutor2();
|
|
24213
|
-
super((originalResolve, originalReject) => {
|
|
24214
|
-
deferredExecutor(originalResolve, originalReject);
|
|
24215
|
-
executor?.(deferredExecutor.resolve, deferredExecutor.reject);
|
|
24216
|
-
});
|
|
24217
|
-
this.#executor = deferredExecutor;
|
|
24218
|
-
this.resolve = this.#executor.resolve;
|
|
24219
|
-
this.reject = this.#executor.reject;
|
|
24220
|
-
}
|
|
24221
|
-
get state() {
|
|
24222
|
-
return this.#executor.state;
|
|
24223
|
-
}
|
|
24224
|
-
get rejectionReason() {
|
|
24225
|
-
return this.#executor.rejectionReason;
|
|
24226
|
-
}
|
|
24227
|
-
then(onFulfilled, onRejected) {
|
|
24228
|
-
return this.#decorate(super.then(onFulfilled, onRejected));
|
|
24229
|
-
}
|
|
24230
|
-
catch(onRejected) {
|
|
24231
|
-
return this.#decorate(super.catch(onRejected));
|
|
24232
|
-
}
|
|
24233
|
-
finally(onfinally) {
|
|
24234
|
-
return this.#decorate(super.finally(onfinally));
|
|
24235
|
-
}
|
|
24236
|
-
#decorate(promise) {
|
|
24237
|
-
return Object.defineProperties(promise, {
|
|
24238
|
-
resolve: {
|
|
24239
|
-
configurable: true,
|
|
24240
|
-
value: this.resolve
|
|
24241
|
-
},
|
|
24242
|
-
reject: {
|
|
24243
|
-
configurable: true,
|
|
24244
|
-
value: this.reject
|
|
24245
|
-
}
|
|
24246
|
-
});
|
|
24247
|
-
}
|
|
24248
|
-
};
|
|
24249
|
-
|
|
24250
24365
|
// src/core/ws/WebSocketIndexedDBClientStore.ts
|
|
24251
24366
|
var DB_NAME = "msw-websocket-clients";
|
|
24252
24367
|
var DB_STORE_NAME = "clients";
|
|
@@ -24628,16 +24743,17 @@ Consider naming this operation or using "graphql.operation()" request handler to
|
|
|
24628
24743
|
const { client, server, response } = createEventStream(
|
|
24629
24744
|
info.request
|
|
24630
24745
|
);
|
|
24631
|
-
const emitter = new
|
|
24746
|
+
const emitter = new Emitter();
|
|
24632
24747
|
client[kClientEmitter] = emitter;
|
|
24633
24748
|
if (this.#loggableRequests.has(info.request)) {
|
|
24634
24749
|
this.#attachClientLogger(info.request, emitter);
|
|
24635
24750
|
}
|
|
24636
|
-
await resolver(
|
|
24637
|
-
|
|
24638
|
-
|
|
24639
|
-
|
|
24640
|
-
|
|
24751
|
+
await resolver(
|
|
24752
|
+
Object.assign(info, {
|
|
24753
|
+
client,
|
|
24754
|
+
server
|
|
24755
|
+
})
|
|
24756
|
+
);
|
|
24641
24757
|
return response;
|
|
24642
24758
|
});
|
|
24643
24759
|
this.#loggableRequests = /* @__PURE__ */ new WeakSet();
|
|
@@ -24660,21 +24776,20 @@ Consider naming this operation or using "graphql.operation()" request handler to
|
|
|
24660
24776
|
}
|
|
24661
24777
|
return matches;
|
|
24662
24778
|
}
|
|
24663
|
-
async log(
|
|
24779
|
+
async log(args) {
|
|
24780
|
+
args.response.body?.cancel();
|
|
24664
24781
|
return;
|
|
24665
24782
|
}
|
|
24666
24783
|
#attachClientLogger(request, emitter) {
|
|
24667
24784
|
const publicUrl = toPublicUrl(request.url);
|
|
24668
|
-
emitter.on("message", (
|
|
24785
|
+
emitter.on("message", ({ data }) => {
|
|
24669
24786
|
console.groupCollapsed(
|
|
24670
|
-
devUtils.formatMessage(
|
|
24671
|
-
`${getTimestamp()} SSE %s %c\u21E3%c ${payload.event}`
|
|
24672
|
-
),
|
|
24787
|
+
devUtils.formatMessage(`${getTimestamp()} SSE %s %c\u21E3%c ${data.event}`),
|
|
24673
24788
|
publicUrl,
|
|
24674
24789
|
`color:${colors.mocked}`,
|
|
24675
24790
|
"color:inherit"
|
|
24676
24791
|
);
|
|
24677
|
-
console.log(
|
|
24792
|
+
console.log(data.frames);
|
|
24678
24793
|
console.groupEnd();
|
|
24679
24794
|
});
|
|
24680
24795
|
emitter.on("error", () => {
|
|
@@ -24703,10 +24818,12 @@ Consider naming this operation or using "graphql.operation()" request handler to
|
|
|
24703
24818
|
var ServerSentEventClient = class {
|
|
24704
24819
|
[kClientEmitter];
|
|
24705
24820
|
#encoder;
|
|
24706
|
-
#
|
|
24707
|
-
|
|
24821
|
+
#controller;
|
|
24822
|
+
#closed;
|
|
24823
|
+
constructor(controller) {
|
|
24708
24824
|
this.#encoder = new TextEncoder();
|
|
24709
|
-
this.#
|
|
24825
|
+
this.#controller = controller;
|
|
24826
|
+
this.#closed = new DeferredPromise2();
|
|
24710
24827
|
}
|
|
24711
24828
|
/**
|
|
24712
24829
|
* Sends the given payload to the intercepted `EventSource`.
|
|
@@ -24749,35 +24866,44 @@ Consider naming this operation or using "graphql.operation()" request handler to
|
|
|
24749
24866
|
* error.
|
|
24750
24867
|
*/
|
|
24751
24868
|
error() {
|
|
24752
|
-
this.#
|
|
24753
|
-
|
|
24754
|
-
|
|
24755
|
-
|
|
24756
|
-
|
|
24757
|
-
|
|
24758
|
-
this[kClientEmitter]?.emit("error");
|
|
24869
|
+
if (this.#closed.state !== "pending") {
|
|
24870
|
+
return;
|
|
24871
|
+
}
|
|
24872
|
+
this.#controller.error();
|
|
24873
|
+
this.#closed.resolve();
|
|
24874
|
+
this[kClientEmitter]?.emit(new TypedEvent("error"));
|
|
24759
24875
|
}
|
|
24760
24876
|
/**
|
|
24761
24877
|
* Closes the underlying `EventSource`, closing the connection.
|
|
24762
24878
|
*/
|
|
24763
24879
|
close() {
|
|
24764
|
-
this.#
|
|
24880
|
+
if (this.#closed.state !== "pending") {
|
|
24881
|
+
return;
|
|
24882
|
+
}
|
|
24883
|
+
try {
|
|
24884
|
+
this.#controller.close();
|
|
24885
|
+
this.#closed.resolve();
|
|
24886
|
+
} catch {
|
|
24887
|
+
}
|
|
24888
|
+
this[kClientEmitter]?.emit(new TypedEvent("close"));
|
|
24889
|
+
}
|
|
24890
|
+
#enqueue(chunk) {
|
|
24891
|
+
if (this.#closed.state !== "pending") {
|
|
24892
|
+
return;
|
|
24893
|
+
}
|
|
24894
|
+
try {
|
|
24895
|
+
this.#controller.enqueue(chunk);
|
|
24896
|
+
} catch (error3) {
|
|
24765
24897
|
console.error(error3);
|
|
24766
24898
|
devUtils.error(
|
|
24767
|
-
"Failed to
|
|
24899
|
+
"Failed to write to server-side EventSource. Please see the original error above."
|
|
24768
24900
|
);
|
|
24769
|
-
}
|
|
24770
|
-
this[kClientEmitter]?.emit("close");
|
|
24901
|
+
}
|
|
24771
24902
|
}
|
|
24772
24903
|
#sendRetry(retry) {
|
|
24773
|
-
this.#
|
|
24904
|
+
this.#enqueue(this.#encoder.encode(`retry:${retry}
|
|
24774
24905
|
|
|
24775
|
-
`))
|
|
24776
|
-
console.error(error3);
|
|
24777
|
-
devUtils.error(
|
|
24778
|
-
"Failed to send a retry packet to server-side EventSource. Please see the original error above."
|
|
24779
|
-
);
|
|
24780
|
-
});
|
|
24906
|
+
`));
|
|
24781
24907
|
}
|
|
24782
24908
|
#sendMessage(message4) {
|
|
24783
24909
|
const frames = [];
|
|
@@ -24793,18 +24919,17 @@ Consider naming this operation or using "graphql.operation()" request handler to
|
|
|
24793
24919
|
}
|
|
24794
24920
|
}
|
|
24795
24921
|
frames.push("", "");
|
|
24796
|
-
this.#
|
|
24797
|
-
|
|
24798
|
-
|
|
24799
|
-
|
|
24800
|
-
|
|
24801
|
-
|
|
24802
|
-
|
|
24803
|
-
|
|
24804
|
-
|
|
24805
|
-
|
|
24806
|
-
|
|
24807
|
-
});
|
|
24922
|
+
this.#enqueue(this.#encoder.encode(frames.join("\n")));
|
|
24923
|
+
this[kClientEmitter]?.emit(
|
|
24924
|
+
new TypedEvent("message", {
|
|
24925
|
+
data: {
|
|
24926
|
+
id: message4.id,
|
|
24927
|
+
event: message4.event?.toString() || "message",
|
|
24928
|
+
data: message4.data,
|
|
24929
|
+
frames
|
|
24930
|
+
}
|
|
24931
|
+
})
|
|
24932
|
+
);
|
|
24808
24933
|
}
|
|
24809
24934
|
};
|
|
24810
24935
|
var ServerSentEventServer = class {
|
|
@@ -25218,8 +25343,16 @@ Consider naming this operation or using "graphql.operation()" request handler to
|
|
|
25218
25343
|
request.method,
|
|
25219
25344
|
request.url
|
|
25220
25345
|
);
|
|
25221
|
-
|
|
25222
|
-
const
|
|
25346
|
+
let controller;
|
|
25347
|
+
const readable = new ReadableStream({
|
|
25348
|
+
start(defaultController) {
|
|
25349
|
+
controller = defaultController;
|
|
25350
|
+
},
|
|
25351
|
+
cancel() {
|
|
25352
|
+
client.close();
|
|
25353
|
+
}
|
|
25354
|
+
});
|
|
25355
|
+
const client = new ServerSentEventClient(controller);
|
|
25223
25356
|
const server = new ServerSentEventServer({
|
|
25224
25357
|
request,
|
|
25225
25358
|
client
|
|
@@ -27098,7 +27231,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
27098
27231
|
this.#channel.postMessage("INTEGRITY_CHECK_REQUEST");
|
|
27099
27232
|
this.#channel.once("INTEGRITY_CHECK_RESPONSE", (event) => {
|
|
27100
27233
|
const { checksum, packageVersion } = event.data;
|
|
27101
|
-
if (checksum !== "
|
|
27234
|
+
if (checksum !== "03cb67ac84128e63d7cd722a6e5b7f1e") {
|
|
27102
27235
|
devUtils.warn(
|
|
27103
27236
|
`The currently registered Service Worker has been generated by a different version of MSW (${packageVersion}) and may not be fully compatible with the installed version.
|
|
27104
27237
|
|