msw 2.11.5 → 2.11.6
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 +365 -308
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/index.mjs +365 -308
- package/lib/browser/index.mjs.map +1 -1
- package/lib/iife/index.js +415 -357
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +1 -1
- package/package.json +4 -3
package/lib/iife/index.js
CHANGED
|
@@ -14395,7 +14395,7 @@ ${operationTypes.join("\n")}
|
|
|
14395
14395
|
return stringToRegexp(path, keys, options);
|
|
14396
14396
|
}
|
|
14397
14397
|
|
|
14398
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
14398
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.40.0/node_modules/@mswjs/interceptors/lib/browser/chunk-6HYIRFX2.mjs
|
|
14399
14399
|
var encoder = new TextEncoder();
|
|
14400
14400
|
function encodeBuffer(text) {
|
|
14401
14401
|
return encoder.encode(text);
|
|
@@ -14411,100 +14411,6 @@ ${operationTypes.join("\n")}
|
|
|
14411
14411
|
);
|
|
14412
14412
|
}
|
|
14413
14413
|
|
|
14414
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.39.1/node_modules/@mswjs/interceptors/lib/browser/chunk-3RXCRGL2.mjs
|
|
14415
|
-
var IS_PATCHED_MODULE = Symbol("isPatchedModule");
|
|
14416
|
-
function canParseUrl(url) {
|
|
14417
|
-
try {
|
|
14418
|
-
new URL(url);
|
|
14419
|
-
return true;
|
|
14420
|
-
} catch (_error) {
|
|
14421
|
-
return false;
|
|
14422
|
-
}
|
|
14423
|
-
}
|
|
14424
|
-
function getValueBySymbol(symbolName, source) {
|
|
14425
|
-
const ownSymbols = Object.getOwnPropertySymbols(source);
|
|
14426
|
-
const symbol = ownSymbols.find((symbol2) => {
|
|
14427
|
-
return symbol2.description === symbolName;
|
|
14428
|
-
});
|
|
14429
|
-
if (symbol) {
|
|
14430
|
-
return Reflect.get(source, symbol);
|
|
14431
|
-
}
|
|
14432
|
-
return;
|
|
14433
|
-
}
|
|
14434
|
-
var _FetchResponse = class extends Response {
|
|
14435
|
-
static isConfigurableStatusCode(status) {
|
|
14436
|
-
return status >= 200 && status <= 599;
|
|
14437
|
-
}
|
|
14438
|
-
static isRedirectResponse(status) {
|
|
14439
|
-
return _FetchResponse.STATUS_CODES_WITH_REDIRECT.includes(status);
|
|
14440
|
-
}
|
|
14441
|
-
/**
|
|
14442
|
-
* Returns a boolean indicating whether the given response status
|
|
14443
|
-
* code represents a response that can have a body.
|
|
14444
|
-
*/
|
|
14445
|
-
static isResponseWithBody(status) {
|
|
14446
|
-
return !_FetchResponse.STATUS_CODES_WITHOUT_BODY.includes(status);
|
|
14447
|
-
}
|
|
14448
|
-
static setUrl(url, response) {
|
|
14449
|
-
if (!url || url === "about:" || !canParseUrl(url)) {
|
|
14450
|
-
return;
|
|
14451
|
-
}
|
|
14452
|
-
const state = getValueBySymbol("state", response);
|
|
14453
|
-
if (state) {
|
|
14454
|
-
state.urlList.push(new URL(url));
|
|
14455
|
-
} else {
|
|
14456
|
-
Object.defineProperty(response, "url", {
|
|
14457
|
-
value: url,
|
|
14458
|
-
enumerable: true,
|
|
14459
|
-
configurable: true,
|
|
14460
|
-
writable: false
|
|
14461
|
-
});
|
|
14462
|
-
}
|
|
14463
|
-
}
|
|
14464
|
-
/**
|
|
14465
|
-
* Parses the given raw HTTP headers into a Fetch API `Headers` instance.
|
|
14466
|
-
*/
|
|
14467
|
-
static parseRawHeaders(rawHeaders) {
|
|
14468
|
-
const headers = new Headers();
|
|
14469
|
-
for (let line = 0; line < rawHeaders.length; line += 2) {
|
|
14470
|
-
headers.append(rawHeaders[line], rawHeaders[line + 1]);
|
|
14471
|
-
}
|
|
14472
|
-
return headers;
|
|
14473
|
-
}
|
|
14474
|
-
constructor(body, init = {}) {
|
|
14475
|
-
var _a2;
|
|
14476
|
-
const status = (_a2 = init.status) != null ? _a2 : 200;
|
|
14477
|
-
const safeStatus = _FetchResponse.isConfigurableStatusCode(status) ? status : 200;
|
|
14478
|
-
const finalBody = _FetchResponse.isResponseWithBody(status) ? body : null;
|
|
14479
|
-
super(finalBody, {
|
|
14480
|
-
status: safeStatus,
|
|
14481
|
-
statusText: init.statusText,
|
|
14482
|
-
headers: init.headers
|
|
14483
|
-
});
|
|
14484
|
-
if (status !== safeStatus) {
|
|
14485
|
-
const state = getValueBySymbol("state", this);
|
|
14486
|
-
if (state) {
|
|
14487
|
-
state.status = status;
|
|
14488
|
-
} else {
|
|
14489
|
-
Object.defineProperty(this, "status", {
|
|
14490
|
-
value: status,
|
|
14491
|
-
enumerable: true,
|
|
14492
|
-
configurable: true,
|
|
14493
|
-
writable: false
|
|
14494
|
-
});
|
|
14495
|
-
}
|
|
14496
|
-
}
|
|
14497
|
-
_FetchResponse.setUrl(init.url, this);
|
|
14498
|
-
}
|
|
14499
|
-
};
|
|
14500
|
-
var FetchResponse = _FetchResponse;
|
|
14501
|
-
FetchResponse.STATUS_CODES_WITHOUT_BODY = [101, 103, 204, 205, 304];
|
|
14502
|
-
FetchResponse.STATUS_CODES_WITH_REDIRECT = [301, 302, 303, 307, 308];
|
|
14503
|
-
var kRawRequest = Symbol("kRawRequest");
|
|
14504
|
-
function setRawRequest(request, rawRequest) {
|
|
14505
|
-
Reflect.set(request, kRawRequest, rawRequest);
|
|
14506
|
-
}
|
|
14507
|
-
|
|
14508
14414
|
// node_modules/.pnpm/is-node-process@1.2.0/node_modules/is-node-process/lib/index.mjs
|
|
14509
14415
|
function isNodeProcess() {
|
|
14510
14416
|
if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
|
|
@@ -14792,7 +14698,20 @@ ${operationTypes.join("\n")}
|
|
|
14792
14698
|
return message4.toString();
|
|
14793
14699
|
}
|
|
14794
14700
|
|
|
14795
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
14701
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.40.0/node_modules/@mswjs/interceptors/lib/browser/chunk-Z5TSB3T6.mjs
|
|
14702
|
+
var __accessCheck = (obj, member, msg) => {
|
|
14703
|
+
if (!member.has(obj))
|
|
14704
|
+
throw TypeError("Cannot " + msg);
|
|
14705
|
+
};
|
|
14706
|
+
var __privateGet = (obj, member, getter) => {
|
|
14707
|
+
__accessCheck(obj, member, "read from private field");
|
|
14708
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
14709
|
+
};
|
|
14710
|
+
var __privateAdd = (obj, member, value) => {
|
|
14711
|
+
if (member.has(obj))
|
|
14712
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
14713
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
14714
|
+
};
|
|
14796
14715
|
var INTERNAL_REQUEST_ID_HEADER_NAME = "x-interceptors-internal-request-id";
|
|
14797
14716
|
function getGlobalSymbol(symbol) {
|
|
14798
14717
|
return (
|
|
@@ -14940,7 +14859,254 @@ ${operationTypes.join("\n")}
|
|
|
14940
14859
|
return Math.random().toString(16).slice(2);
|
|
14941
14860
|
}
|
|
14942
14861
|
|
|
14943
|
-
// node_modules/.pnpm/@
|
|
14862
|
+
// node_modules/.pnpm/@open-draft+deferred-promise@2.2.0/node_modules/@open-draft/deferred-promise/build/index.mjs
|
|
14863
|
+
function createDeferredExecutor() {
|
|
14864
|
+
const executor = (resolve, reject) => {
|
|
14865
|
+
executor.state = "pending";
|
|
14866
|
+
executor.resolve = (data) => {
|
|
14867
|
+
if (executor.state !== "pending") {
|
|
14868
|
+
return;
|
|
14869
|
+
}
|
|
14870
|
+
executor.result = data;
|
|
14871
|
+
const onFulfilled = (value) => {
|
|
14872
|
+
executor.state = "fulfilled";
|
|
14873
|
+
return value;
|
|
14874
|
+
};
|
|
14875
|
+
return resolve(
|
|
14876
|
+
data instanceof Promise ? data : Promise.resolve(data).then(onFulfilled)
|
|
14877
|
+
);
|
|
14878
|
+
};
|
|
14879
|
+
executor.reject = (reason) => {
|
|
14880
|
+
if (executor.state !== "pending") {
|
|
14881
|
+
return;
|
|
14882
|
+
}
|
|
14883
|
+
queueMicrotask(() => {
|
|
14884
|
+
executor.state = "rejected";
|
|
14885
|
+
});
|
|
14886
|
+
return reject(executor.rejectionReason = reason);
|
|
14887
|
+
};
|
|
14888
|
+
};
|
|
14889
|
+
return executor;
|
|
14890
|
+
}
|
|
14891
|
+
var DeferredPromise = class extends Promise {
|
|
14892
|
+
#executor;
|
|
14893
|
+
resolve;
|
|
14894
|
+
reject;
|
|
14895
|
+
constructor(executor = null) {
|
|
14896
|
+
const deferredExecutor = createDeferredExecutor();
|
|
14897
|
+
super((originalResolve, originalReject) => {
|
|
14898
|
+
deferredExecutor(originalResolve, originalReject);
|
|
14899
|
+
executor?.(deferredExecutor.resolve, deferredExecutor.reject);
|
|
14900
|
+
});
|
|
14901
|
+
this.#executor = deferredExecutor;
|
|
14902
|
+
this.resolve = this.#executor.resolve;
|
|
14903
|
+
this.reject = this.#executor.reject;
|
|
14904
|
+
}
|
|
14905
|
+
get state() {
|
|
14906
|
+
return this.#executor.state;
|
|
14907
|
+
}
|
|
14908
|
+
get rejectionReason() {
|
|
14909
|
+
return this.#executor.rejectionReason;
|
|
14910
|
+
}
|
|
14911
|
+
then(onFulfilled, onRejected) {
|
|
14912
|
+
return this.#decorate(super.then(onFulfilled, onRejected));
|
|
14913
|
+
}
|
|
14914
|
+
catch(onRejected) {
|
|
14915
|
+
return this.#decorate(super.catch(onRejected));
|
|
14916
|
+
}
|
|
14917
|
+
finally(onfinally) {
|
|
14918
|
+
return this.#decorate(super.finally(onfinally));
|
|
14919
|
+
}
|
|
14920
|
+
#decorate(promise) {
|
|
14921
|
+
return Object.defineProperties(promise, {
|
|
14922
|
+
resolve: { configurable: true, value: this.resolve },
|
|
14923
|
+
reject: { configurable: true, value: this.reject }
|
|
14924
|
+
});
|
|
14925
|
+
}
|
|
14926
|
+
};
|
|
14927
|
+
|
|
14928
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.40.0/node_modules/@mswjs/interceptors/lib/browser/chunk-LIKZF2VU.mjs
|
|
14929
|
+
var IS_PATCHED_MODULE = Symbol("isPatchedModule");
|
|
14930
|
+
var InterceptorError = class extends Error {
|
|
14931
|
+
constructor(message4) {
|
|
14932
|
+
super(message4);
|
|
14933
|
+
this.name = "InterceptorError";
|
|
14934
|
+
Object.setPrototypeOf(this, InterceptorError.prototype);
|
|
14935
|
+
}
|
|
14936
|
+
};
|
|
14937
|
+
var _handled;
|
|
14938
|
+
var handled_get;
|
|
14939
|
+
var _RequestController = class {
|
|
14940
|
+
constructor(request, source) {
|
|
14941
|
+
this.request = request;
|
|
14942
|
+
this.source = source;
|
|
14943
|
+
__privateAdd(this, _handled);
|
|
14944
|
+
this.readyState = _RequestController.PENDING;
|
|
14945
|
+
this.handled = new DeferredPromise();
|
|
14946
|
+
}
|
|
14947
|
+
/**
|
|
14948
|
+
* Perform this request as-is.
|
|
14949
|
+
*/
|
|
14950
|
+
async passthrough() {
|
|
14951
|
+
invariant.as(
|
|
14952
|
+
InterceptorError,
|
|
14953
|
+
this.readyState === _RequestController.PENDING,
|
|
14954
|
+
'Failed to passthrough the "%s %s" request: the request has already been handled',
|
|
14955
|
+
this.request.method,
|
|
14956
|
+
this.request.url
|
|
14957
|
+
);
|
|
14958
|
+
this.readyState = _RequestController.PASSTHROUGH;
|
|
14959
|
+
await this.source.passthrough();
|
|
14960
|
+
__privateGet(this, _handled, handled_get).resolve();
|
|
14961
|
+
}
|
|
14962
|
+
/**
|
|
14963
|
+
* Respond to this request with the given `Response` instance.
|
|
14964
|
+
*
|
|
14965
|
+
* @example
|
|
14966
|
+
* controller.respondWith(new Response())
|
|
14967
|
+
* controller.respondWith(Response.json({ id }))
|
|
14968
|
+
* controller.respondWith(Response.error())
|
|
14969
|
+
*/
|
|
14970
|
+
respondWith(response) {
|
|
14971
|
+
invariant.as(
|
|
14972
|
+
InterceptorError,
|
|
14973
|
+
this.readyState === _RequestController.PENDING,
|
|
14974
|
+
'Failed to respond to the "%s %s" request with "%d %s": the request has already been handled (%d)',
|
|
14975
|
+
this.request.method,
|
|
14976
|
+
this.request.url,
|
|
14977
|
+
response.status,
|
|
14978
|
+
response.statusText || "OK",
|
|
14979
|
+
this.readyState
|
|
14980
|
+
);
|
|
14981
|
+
this.readyState = _RequestController.RESPONSE;
|
|
14982
|
+
__privateGet(this, _handled, handled_get).resolve();
|
|
14983
|
+
this.source.respondWith(response);
|
|
14984
|
+
}
|
|
14985
|
+
/**
|
|
14986
|
+
* Error this request with the given reason.
|
|
14987
|
+
*
|
|
14988
|
+
* @example
|
|
14989
|
+
* controller.errorWith()
|
|
14990
|
+
* controller.errorWith(new Error('Oops!'))
|
|
14991
|
+
* controller.errorWith({ message: 'Oops!'})
|
|
14992
|
+
*/
|
|
14993
|
+
errorWith(reason) {
|
|
14994
|
+
invariant.as(
|
|
14995
|
+
InterceptorError,
|
|
14996
|
+
this.readyState === _RequestController.PENDING,
|
|
14997
|
+
'Failed to error the "%s %s" request with "%s": the request has already been handled (%d)',
|
|
14998
|
+
this.request.method,
|
|
14999
|
+
this.request.url,
|
|
15000
|
+
reason == null ? void 0 : reason.toString(),
|
|
15001
|
+
this.readyState
|
|
15002
|
+
);
|
|
15003
|
+
this.readyState = _RequestController.ERROR;
|
|
15004
|
+
this.source.errorWith(reason);
|
|
15005
|
+
__privateGet(this, _handled, handled_get).resolve();
|
|
15006
|
+
}
|
|
15007
|
+
};
|
|
15008
|
+
var RequestController = _RequestController;
|
|
15009
|
+
_handled = /* @__PURE__ */ new WeakSet();
|
|
15010
|
+
handled_get = function() {
|
|
15011
|
+
return this.handled;
|
|
15012
|
+
};
|
|
15013
|
+
RequestController.PENDING = 0;
|
|
15014
|
+
RequestController.PASSTHROUGH = 1;
|
|
15015
|
+
RequestController.RESPONSE = 2;
|
|
15016
|
+
RequestController.ERROR = 3;
|
|
15017
|
+
function canParseUrl(url) {
|
|
15018
|
+
try {
|
|
15019
|
+
new URL(url);
|
|
15020
|
+
return true;
|
|
15021
|
+
} catch (_error) {
|
|
15022
|
+
return false;
|
|
15023
|
+
}
|
|
15024
|
+
}
|
|
15025
|
+
function getValueBySymbol(symbolName, source) {
|
|
15026
|
+
const ownSymbols = Object.getOwnPropertySymbols(source);
|
|
15027
|
+
const symbol = ownSymbols.find((symbol2) => {
|
|
15028
|
+
return symbol2.description === symbolName;
|
|
15029
|
+
});
|
|
15030
|
+
if (symbol) {
|
|
15031
|
+
return Reflect.get(source, symbol);
|
|
15032
|
+
}
|
|
15033
|
+
return;
|
|
15034
|
+
}
|
|
15035
|
+
var _FetchResponse = class extends Response {
|
|
15036
|
+
static isConfigurableStatusCode(status) {
|
|
15037
|
+
return status >= 200 && status <= 599;
|
|
15038
|
+
}
|
|
15039
|
+
static isRedirectResponse(status) {
|
|
15040
|
+
return _FetchResponse.STATUS_CODES_WITH_REDIRECT.includes(status);
|
|
15041
|
+
}
|
|
15042
|
+
/**
|
|
15043
|
+
* Returns a boolean indicating whether the given response status
|
|
15044
|
+
* code represents a response that can have a body.
|
|
15045
|
+
*/
|
|
15046
|
+
static isResponseWithBody(status) {
|
|
15047
|
+
return !_FetchResponse.STATUS_CODES_WITHOUT_BODY.includes(status);
|
|
15048
|
+
}
|
|
15049
|
+
static setUrl(url, response) {
|
|
15050
|
+
if (!url || url === "about:" || !canParseUrl(url)) {
|
|
15051
|
+
return;
|
|
15052
|
+
}
|
|
15053
|
+
const state = getValueBySymbol("state", response);
|
|
15054
|
+
if (state) {
|
|
15055
|
+
state.urlList.push(new URL(url));
|
|
15056
|
+
} else {
|
|
15057
|
+
Object.defineProperty(response, "url", {
|
|
15058
|
+
value: url,
|
|
15059
|
+
enumerable: true,
|
|
15060
|
+
configurable: true,
|
|
15061
|
+
writable: false
|
|
15062
|
+
});
|
|
15063
|
+
}
|
|
15064
|
+
}
|
|
15065
|
+
/**
|
|
15066
|
+
* Parses the given raw HTTP headers into a Fetch API `Headers` instance.
|
|
15067
|
+
*/
|
|
15068
|
+
static parseRawHeaders(rawHeaders) {
|
|
15069
|
+
const headers = new Headers();
|
|
15070
|
+
for (let line = 0; line < rawHeaders.length; line += 2) {
|
|
15071
|
+
headers.append(rawHeaders[line], rawHeaders[line + 1]);
|
|
15072
|
+
}
|
|
15073
|
+
return headers;
|
|
15074
|
+
}
|
|
15075
|
+
constructor(body, init = {}) {
|
|
15076
|
+
var _a2;
|
|
15077
|
+
const status = (_a2 = init.status) != null ? _a2 : 200;
|
|
15078
|
+
const safeStatus = _FetchResponse.isConfigurableStatusCode(status) ? status : 200;
|
|
15079
|
+
const finalBody = _FetchResponse.isResponseWithBody(status) ? body : null;
|
|
15080
|
+
super(finalBody, {
|
|
15081
|
+
status: safeStatus,
|
|
15082
|
+
statusText: init.statusText,
|
|
15083
|
+
headers: init.headers
|
|
15084
|
+
});
|
|
15085
|
+
if (status !== safeStatus) {
|
|
15086
|
+
const state = getValueBySymbol("state", this);
|
|
15087
|
+
if (state) {
|
|
15088
|
+
state.status = status;
|
|
15089
|
+
} else {
|
|
15090
|
+
Object.defineProperty(this, "status", {
|
|
15091
|
+
value: status,
|
|
15092
|
+
enumerable: true,
|
|
15093
|
+
configurable: true,
|
|
15094
|
+
writable: false
|
|
15095
|
+
});
|
|
15096
|
+
}
|
|
15097
|
+
}
|
|
15098
|
+
_FetchResponse.setUrl(init.url, this);
|
|
15099
|
+
}
|
|
15100
|
+
};
|
|
15101
|
+
var FetchResponse = _FetchResponse;
|
|
15102
|
+
FetchResponse.STATUS_CODES_WITHOUT_BODY = [101, 103, 204, 205, 304];
|
|
15103
|
+
FetchResponse.STATUS_CODES_WITH_REDIRECT = [301, 302, 303, 307, 308];
|
|
15104
|
+
var kRawRequest = Symbol("kRawRequest");
|
|
15105
|
+
function setRawRequest(request, rawRequest) {
|
|
15106
|
+
Reflect.set(request, kRawRequest, rawRequest);
|
|
15107
|
+
}
|
|
15108
|
+
|
|
15109
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.40.0/node_modules/@mswjs/interceptors/lib/browser/index.mjs
|
|
14944
15110
|
var BatchInterceptor = class extends Interceptor {
|
|
14945
15111
|
constructor(options) {
|
|
14946
15112
|
BatchInterceptor.symbol = Symbol(options.name);
|
|
@@ -18836,72 +19002,6 @@ Consider naming this operation or using "graphql.operation()" request handler to
|
|
|
18836
19002
|
}
|
|
18837
19003
|
};
|
|
18838
19004
|
|
|
18839
|
-
// node_modules/.pnpm/@open-draft+deferred-promise@2.2.0/node_modules/@open-draft/deferred-promise/build/index.mjs
|
|
18840
|
-
function createDeferredExecutor() {
|
|
18841
|
-
const executor = (resolve, reject) => {
|
|
18842
|
-
executor.state = "pending";
|
|
18843
|
-
executor.resolve = (data) => {
|
|
18844
|
-
if (executor.state !== "pending") {
|
|
18845
|
-
return;
|
|
18846
|
-
}
|
|
18847
|
-
executor.result = data;
|
|
18848
|
-
const onFulfilled = (value) => {
|
|
18849
|
-
executor.state = "fulfilled";
|
|
18850
|
-
return value;
|
|
18851
|
-
};
|
|
18852
|
-
return resolve(
|
|
18853
|
-
data instanceof Promise ? data : Promise.resolve(data).then(onFulfilled)
|
|
18854
|
-
);
|
|
18855
|
-
};
|
|
18856
|
-
executor.reject = (reason) => {
|
|
18857
|
-
if (executor.state !== "pending") {
|
|
18858
|
-
return;
|
|
18859
|
-
}
|
|
18860
|
-
queueMicrotask(() => {
|
|
18861
|
-
executor.state = "rejected";
|
|
18862
|
-
});
|
|
18863
|
-
return reject(executor.rejectionReason = reason);
|
|
18864
|
-
};
|
|
18865
|
-
};
|
|
18866
|
-
return executor;
|
|
18867
|
-
}
|
|
18868
|
-
var DeferredPromise = class extends Promise {
|
|
18869
|
-
#executor;
|
|
18870
|
-
resolve;
|
|
18871
|
-
reject;
|
|
18872
|
-
constructor(executor = null) {
|
|
18873
|
-
const deferredExecutor = createDeferredExecutor();
|
|
18874
|
-
super((originalResolve, originalReject) => {
|
|
18875
|
-
deferredExecutor(originalResolve, originalReject);
|
|
18876
|
-
executor?.(deferredExecutor.resolve, deferredExecutor.reject);
|
|
18877
|
-
});
|
|
18878
|
-
this.#executor = deferredExecutor;
|
|
18879
|
-
this.resolve = this.#executor.resolve;
|
|
18880
|
-
this.reject = this.#executor.reject;
|
|
18881
|
-
}
|
|
18882
|
-
get state() {
|
|
18883
|
-
return this.#executor.state;
|
|
18884
|
-
}
|
|
18885
|
-
get rejectionReason() {
|
|
18886
|
-
return this.#executor.rejectionReason;
|
|
18887
|
-
}
|
|
18888
|
-
then(onFulfilled, onRejected) {
|
|
18889
|
-
return this.#decorate(super.then(onFulfilled, onRejected));
|
|
18890
|
-
}
|
|
18891
|
-
catch(onRejected) {
|
|
18892
|
-
return this.#decorate(super.catch(onRejected));
|
|
18893
|
-
}
|
|
18894
|
-
finally(onfinally) {
|
|
18895
|
-
return this.#decorate(super.finally(onfinally));
|
|
18896
|
-
}
|
|
18897
|
-
#decorate(promise) {
|
|
18898
|
-
return Object.defineProperties(promise, {
|
|
18899
|
-
resolve: { configurable: true, value: this.resolve },
|
|
18900
|
-
reject: { configurable: true, value: this.reject }
|
|
18901
|
-
});
|
|
18902
|
-
}
|
|
18903
|
-
};
|
|
18904
|
-
|
|
18905
19005
|
// src/core/ws/WebSocketIndexedDBClientStore.ts
|
|
18906
19006
|
var DB_NAME = "msw-websocket-clients";
|
|
18907
19007
|
var DB_STORE_NAME = "clients";
|
|
@@ -20042,7 +20142,16 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
20042
20142
|
};
|
|
20043
20143
|
};
|
|
20044
20144
|
|
|
20045
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
20145
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.40.0/node_modules/@mswjs/interceptors/lib/browser/chunk-VYSDLBSS.mjs
|
|
20146
|
+
async function emitAsync(emitter, eventName, ...data) {
|
|
20147
|
+
const listeners = emitter.listeners(eventName);
|
|
20148
|
+
if (listeners.length === 0) {
|
|
20149
|
+
return;
|
|
20150
|
+
}
|
|
20151
|
+
for (const listener of listeners) {
|
|
20152
|
+
await listener.apply(emitter, data);
|
|
20153
|
+
}
|
|
20154
|
+
}
|
|
20046
20155
|
function hasConfigurableGlobal(propertyName) {
|
|
20047
20156
|
const descriptor = Object.getOwnPropertyDescriptor(globalThis, propertyName);
|
|
20048
20157
|
if (typeof descriptor === "undefined") {
|
|
@@ -20063,7 +20172,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
20063
20172
|
return true;
|
|
20064
20173
|
}
|
|
20065
20174
|
|
|
20066
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
20175
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.40.0/node_modules/@mswjs/interceptors/lib/browser/interceptors/WebSocket/index.mjs
|
|
20067
20176
|
function bindEvent(target, event) {
|
|
20068
20177
|
Object.defineProperties(event, {
|
|
20069
20178
|
target: {
|
|
@@ -20685,14 +20794,15 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
20685
20794
|
};
|
|
20686
20795
|
const socket = new WebSocketOverride(url, protocols);
|
|
20687
20796
|
const transport = new WebSocketClassTransport(socket);
|
|
20688
|
-
queueMicrotask(() => {
|
|
20797
|
+
queueMicrotask(async () => {
|
|
20689
20798
|
try {
|
|
20690
20799
|
const server = new WebSocketServerConnection(
|
|
20691
20800
|
socket,
|
|
20692
20801
|
transport,
|
|
20693
20802
|
createConnection
|
|
20694
20803
|
);
|
|
20695
|
-
const hasConnectionListeners = this.emitter.
|
|
20804
|
+
const hasConnectionListeners = this.emitter.listenerCount("connection") > 0;
|
|
20805
|
+
await emitAsync(this.emitter, "connection", {
|
|
20696
20806
|
client: new WebSocketClientConnection(socket, transport),
|
|
20697
20807
|
server,
|
|
20698
20808
|
info: {
|
|
@@ -21286,69 +21396,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
21286
21396
|
}
|
|
21287
21397
|
};
|
|
21288
21398
|
|
|
21289
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
21290
|
-
var InterceptorError = class extends Error {
|
|
21291
|
-
constructor(message4) {
|
|
21292
|
-
super(message4);
|
|
21293
|
-
this.name = "InterceptorError";
|
|
21294
|
-
Object.setPrototypeOf(this, InterceptorError.prototype);
|
|
21295
|
-
}
|
|
21296
|
-
};
|
|
21297
|
-
var kRequestHandled = Symbol("kRequestHandled");
|
|
21298
|
-
var kResponsePromise = Symbol("kResponsePromise");
|
|
21299
|
-
var RequestController = class {
|
|
21300
|
-
constructor(request) {
|
|
21301
|
-
this.request = request;
|
|
21302
|
-
this[kRequestHandled] = false;
|
|
21303
|
-
this[kResponsePromise] = new DeferredPromise();
|
|
21304
|
-
}
|
|
21305
|
-
/**
|
|
21306
|
-
* Respond to this request with the given `Response` instance.
|
|
21307
|
-
* @example
|
|
21308
|
-
* controller.respondWith(new Response())
|
|
21309
|
-
* controller.respondWith(Response.json({ id }))
|
|
21310
|
-
* controller.respondWith(Response.error())
|
|
21311
|
-
*/
|
|
21312
|
-
respondWith(response) {
|
|
21313
|
-
invariant.as(
|
|
21314
|
-
InterceptorError,
|
|
21315
|
-
!this[kRequestHandled],
|
|
21316
|
-
'Failed to respond to the "%s %s" request: the "request" event has already been handled.',
|
|
21317
|
-
this.request.method,
|
|
21318
|
-
this.request.url
|
|
21319
|
-
);
|
|
21320
|
-
this[kRequestHandled] = true;
|
|
21321
|
-
this[kResponsePromise].resolve(response);
|
|
21322
|
-
}
|
|
21323
|
-
/**
|
|
21324
|
-
* Error this request with the given reason.
|
|
21325
|
-
*
|
|
21326
|
-
* @example
|
|
21327
|
-
* controller.errorWith()
|
|
21328
|
-
* controller.errorWith(new Error('Oops!'))
|
|
21329
|
-
* controller.errorWith({ message: 'Oops!'})
|
|
21330
|
-
*/
|
|
21331
|
-
errorWith(reason) {
|
|
21332
|
-
invariant.as(
|
|
21333
|
-
InterceptorError,
|
|
21334
|
-
!this[kRequestHandled],
|
|
21335
|
-
'Failed to error the "%s %s" request: the "request" event has already been handled.',
|
|
21336
|
-
this.request.method,
|
|
21337
|
-
this.request.url
|
|
21338
|
-
);
|
|
21339
|
-
this[kRequestHandled] = true;
|
|
21340
|
-
this[kResponsePromise].resolve(reason);
|
|
21341
|
-
}
|
|
21342
|
-
};
|
|
21343
|
-
async function emitAsync(emitter, eventName, ...data) {
|
|
21344
|
-
const listners = emitter.listeners(eventName);
|
|
21345
|
-
if (listners.length === 0) {
|
|
21346
|
-
return;
|
|
21347
|
-
}
|
|
21348
|
-
for (const listener of listners) {
|
|
21349
|
-
await listener.apply(emitter, data);
|
|
21350
|
-
}
|
|
21351
|
-
}
|
|
21399
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.40.0/node_modules/@mswjs/interceptors/lib/browser/chunk-VOUOVDAW.mjs
|
|
21352
21400
|
function isObject3(value, loose = false) {
|
|
21353
21401
|
return loose ? Object.prototype.toString.call(value).startsWith("[object ") : Object.prototype.toString.call(value) === "[object Object]";
|
|
21354
21402
|
}
|
|
@@ -21396,19 +21444,19 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
21396
21444
|
async function handleRequest2(options) {
|
|
21397
21445
|
const handleResponse = async (response) => {
|
|
21398
21446
|
if (response instanceof Error) {
|
|
21399
|
-
options.
|
|
21447
|
+
await options.controller.errorWith(response);
|
|
21400
21448
|
return true;
|
|
21401
21449
|
}
|
|
21402
21450
|
if (isResponseError(response)) {
|
|
21403
|
-
options.
|
|
21451
|
+
await options.controller.respondWith(response);
|
|
21404
21452
|
return true;
|
|
21405
21453
|
}
|
|
21406
21454
|
if (isResponseLike(response)) {
|
|
21407
|
-
await options.
|
|
21455
|
+
await options.controller.respondWith(response);
|
|
21408
21456
|
return true;
|
|
21409
21457
|
}
|
|
21410
21458
|
if (isObject3(response)) {
|
|
21411
|
-
options.
|
|
21459
|
+
await options.controller.errorWith(response);
|
|
21412
21460
|
return true;
|
|
21413
21461
|
}
|
|
21414
21462
|
return false;
|
|
@@ -21418,7 +21466,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
21418
21466
|
throw result.error;
|
|
21419
21467
|
}
|
|
21420
21468
|
if (isNodeLikeError(error3)) {
|
|
21421
|
-
options.
|
|
21469
|
+
await options.controller.errorWith(error3);
|
|
21422
21470
|
return true;
|
|
21423
21471
|
}
|
|
21424
21472
|
if (error3 instanceof Response) {
|
|
@@ -21426,27 +21474,19 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
21426
21474
|
}
|
|
21427
21475
|
return false;
|
|
21428
21476
|
};
|
|
21429
|
-
options.emitter.once("request", ({ requestId: pendingRequestId }) => {
|
|
21430
|
-
if (pendingRequestId !== options.requestId) {
|
|
21431
|
-
return;
|
|
21432
|
-
}
|
|
21433
|
-
if (options.controller[kResponsePromise].state === "pending") {
|
|
21434
|
-
options.controller[kResponsePromise].resolve(void 0);
|
|
21435
|
-
}
|
|
21436
|
-
});
|
|
21437
21477
|
const requestAbortPromise = new DeferredPromise();
|
|
21438
21478
|
if (options.request.signal) {
|
|
21439
21479
|
if (options.request.signal.aborted) {
|
|
21440
|
-
|
|
21441
|
-
|
|
21442
|
-
options.request.signal.addEventListener(
|
|
21443
|
-
"abort",
|
|
21444
|
-
() => {
|
|
21445
|
-
requestAbortPromise.reject(options.request.signal.reason);
|
|
21446
|
-
},
|
|
21447
|
-
{ once: true }
|
|
21448
|
-
);
|
|
21480
|
+
await options.controller.errorWith(options.request.signal.reason);
|
|
21481
|
+
return;
|
|
21449
21482
|
}
|
|
21483
|
+
options.request.signal.addEventListener(
|
|
21484
|
+
"abort",
|
|
21485
|
+
() => {
|
|
21486
|
+
requestAbortPromise.reject(options.request.signal.reason);
|
|
21487
|
+
},
|
|
21488
|
+
{ once: true }
|
|
21489
|
+
);
|
|
21450
21490
|
}
|
|
21451
21491
|
const result = await until2(async () => {
|
|
21452
21492
|
const requestListenersPromise = emitAsync(options.emitter, "request", {
|
|
@@ -21458,52 +21498,58 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
21458
21498
|
// Short-circuit the request handling promise if the request gets aborted.
|
|
21459
21499
|
requestAbortPromise,
|
|
21460
21500
|
requestListenersPromise,
|
|
21461
|
-
options.controller
|
|
21501
|
+
options.controller.handled
|
|
21462
21502
|
]);
|
|
21463
|
-
return await options.controller[kResponsePromise];
|
|
21464
21503
|
});
|
|
21465
21504
|
if (requestAbortPromise.state === "rejected") {
|
|
21466
|
-
options.
|
|
21467
|
-
return
|
|
21505
|
+
await options.controller.errorWith(requestAbortPromise.rejectionReason);
|
|
21506
|
+
return;
|
|
21468
21507
|
}
|
|
21469
21508
|
if (result.error) {
|
|
21470
21509
|
if (await handleResponseError(result.error)) {
|
|
21471
|
-
return
|
|
21510
|
+
return;
|
|
21472
21511
|
}
|
|
21473
21512
|
if (options.emitter.listenerCount("unhandledException") > 0) {
|
|
21474
21513
|
const unhandledExceptionController = new RequestController(
|
|
21475
|
-
options.request
|
|
21514
|
+
options.request,
|
|
21515
|
+
{
|
|
21516
|
+
/**
|
|
21517
|
+
* @note Intentionally empty passthrough handle.
|
|
21518
|
+
* This controller is created within another controller and we only need
|
|
21519
|
+
* to know if `unhandledException` listeners handled the request.
|
|
21520
|
+
*/
|
|
21521
|
+
passthrough() {
|
|
21522
|
+
},
|
|
21523
|
+
async respondWith(response) {
|
|
21524
|
+
await handleResponse(response);
|
|
21525
|
+
},
|
|
21526
|
+
async errorWith(reason) {
|
|
21527
|
+
await options.controller.errorWith(reason);
|
|
21528
|
+
}
|
|
21529
|
+
}
|
|
21476
21530
|
);
|
|
21477
21531
|
await emitAsync(options.emitter, "unhandledException", {
|
|
21478
21532
|
error: result.error,
|
|
21479
21533
|
request: options.request,
|
|
21480
21534
|
requestId: options.requestId,
|
|
21481
21535
|
controller: unhandledExceptionController
|
|
21482
|
-
}).then(() => {
|
|
21483
|
-
if (unhandledExceptionController[kResponsePromise].state === "pending") {
|
|
21484
|
-
unhandledExceptionController[kResponsePromise].resolve(void 0);
|
|
21485
|
-
}
|
|
21486
21536
|
});
|
|
21487
|
-
|
|
21488
|
-
|
|
21489
|
-
);
|
|
21490
|
-
if (nextResult.error) {
|
|
21491
|
-
return handleResponseError(nextResult.error);
|
|
21492
|
-
}
|
|
21493
|
-
if (nextResult.data) {
|
|
21494
|
-
return handleResponse(nextResult.data);
|
|
21537
|
+
if (unhandledExceptionController.readyState !== RequestController.PENDING) {
|
|
21538
|
+
return;
|
|
21495
21539
|
}
|
|
21496
21540
|
}
|
|
21497
|
-
options.
|
|
21498
|
-
|
|
21541
|
+
await options.controller.respondWith(
|
|
21542
|
+
createServerErrorResponse(result.error)
|
|
21543
|
+
);
|
|
21544
|
+
return;
|
|
21499
21545
|
}
|
|
21500
|
-
if (
|
|
21501
|
-
return
|
|
21546
|
+
if (options.controller.readyState === RequestController.PENDING) {
|
|
21547
|
+
return await options.controller.passthrough();
|
|
21502
21548
|
}
|
|
21503
|
-
return
|
|
21549
|
+
return options.controller.handled;
|
|
21504
21550
|
}
|
|
21505
21551
|
|
|
21506
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
21552
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.40.0/node_modules/@mswjs/interceptors/lib/browser/chunk-WOWPV4GR.mjs
|
|
21507
21553
|
function createNetworkError(cause) {
|
|
21508
21554
|
return Object.assign(new TypeError("Failed to fetch"), {
|
|
21509
21555
|
cause
|
|
@@ -21559,7 +21605,12 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
21559
21605
|
request.headers.delete("host");
|
|
21560
21606
|
}
|
|
21561
21607
|
requestInit.headers = request.headers;
|
|
21562
|
-
|
|
21608
|
+
const finalResponse = await fetch(new Request(locationUrl, requestInit));
|
|
21609
|
+
Object.defineProperty(finalResponse, "redirected", {
|
|
21610
|
+
value: true,
|
|
21611
|
+
configurable: true
|
|
21612
|
+
});
|
|
21613
|
+
return finalResponse;
|
|
21563
21614
|
}
|
|
21564
21615
|
function sameOrigin(left, right) {
|
|
21565
21616
|
if (left.origin === right.origin && left.origin === "null") {
|
|
@@ -21657,19 +21708,35 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
21657
21708
|
setRawRequest(request, input);
|
|
21658
21709
|
}
|
|
21659
21710
|
const responsePromise = new DeferredPromise();
|
|
21660
|
-
const controller = new RequestController(request
|
|
21661
|
-
|
|
21662
|
-
|
|
21663
|
-
|
|
21664
|
-
|
|
21665
|
-
|
|
21666
|
-
|
|
21667
|
-
|
|
21668
|
-
|
|
21669
|
-
|
|
21670
|
-
|
|
21671
|
-
|
|
21672
|
-
|
|
21711
|
+
const controller = new RequestController(request, {
|
|
21712
|
+
passthrough: async () => {
|
|
21713
|
+
this.logger.info("request has not been handled, passthrough...");
|
|
21714
|
+
const requestCloneForResponseEvent = request.clone();
|
|
21715
|
+
const { error: responseError, data: originalResponse } = await until2(
|
|
21716
|
+
() => pureFetch(request)
|
|
21717
|
+
);
|
|
21718
|
+
if (responseError) {
|
|
21719
|
+
return responsePromise.reject(responseError);
|
|
21720
|
+
}
|
|
21721
|
+
this.logger.info("original fetch performed", originalResponse);
|
|
21722
|
+
if (this.emitter.listenerCount("response") > 0) {
|
|
21723
|
+
this.logger.info('emitting the "response" event...');
|
|
21724
|
+
const responseClone = originalResponse.clone();
|
|
21725
|
+
await emitAsync(this.emitter, "response", {
|
|
21726
|
+
response: responseClone,
|
|
21727
|
+
isMockedResponse: false,
|
|
21728
|
+
request: requestCloneForResponseEvent,
|
|
21729
|
+
requestId
|
|
21730
|
+
});
|
|
21731
|
+
}
|
|
21732
|
+
responsePromise.resolve(originalResponse);
|
|
21733
|
+
},
|
|
21734
|
+
respondWith: async (rawResponse) => {
|
|
21735
|
+
if (isResponseError(rawResponse)) {
|
|
21736
|
+
this.logger.info("request has errored!", { response: rawResponse });
|
|
21737
|
+
responsePromise.reject(createNetworkError(rawResponse));
|
|
21738
|
+
return;
|
|
21739
|
+
}
|
|
21673
21740
|
this.logger.info("received mocked response!", {
|
|
21674
21741
|
rawResponse
|
|
21675
21742
|
});
|
|
@@ -21707,37 +21774,24 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
21707
21774
|
}
|
|
21708
21775
|
responsePromise.resolve(response);
|
|
21709
21776
|
},
|
|
21710
|
-
|
|
21711
|
-
this.logger.info("request has
|
|
21712
|
-
responsePromise.reject(
|
|
21713
|
-
},
|
|
21714
|
-
onError: (error3) => {
|
|
21715
|
-
this.logger.info("request has been aborted!", { error: error3 });
|
|
21716
|
-
responsePromise.reject(error3);
|
|
21777
|
+
errorWith: (reason) => {
|
|
21778
|
+
this.logger.info("request has been aborted!", { reason });
|
|
21779
|
+
responsePromise.reject(reason);
|
|
21717
21780
|
}
|
|
21718
21781
|
});
|
|
21719
|
-
|
|
21720
|
-
|
|
21721
|
-
return responsePromise;
|
|
21722
|
-
}
|
|
21782
|
+
this.logger.info("[%s] %s", request.method, request.url);
|
|
21783
|
+
this.logger.info("awaiting for the mocked response...");
|
|
21723
21784
|
this.logger.info(
|
|
21724
|
-
|
|
21785
|
+
'emitting the "request" event for %s listener(s)...',
|
|
21786
|
+
this.emitter.listenerCount("request")
|
|
21725
21787
|
);
|
|
21726
|
-
|
|
21727
|
-
|
|
21728
|
-
|
|
21729
|
-
|
|
21730
|
-
|
|
21731
|
-
const responseClone = response.clone();
|
|
21732
|
-
await emitAsync(this.emitter, "response", {
|
|
21733
|
-
response: responseClone,
|
|
21734
|
-
isMockedResponse: false,
|
|
21735
|
-
request: requestCloneForResponseEvent,
|
|
21736
|
-
requestId
|
|
21737
|
-
});
|
|
21738
|
-
}
|
|
21739
|
-
return response;
|
|
21788
|
+
await handleRequest2({
|
|
21789
|
+
request,
|
|
21790
|
+
requestId,
|
|
21791
|
+
emitter: this.emitter,
|
|
21792
|
+
controller
|
|
21740
21793
|
});
|
|
21794
|
+
return responsePromise;
|
|
21741
21795
|
};
|
|
21742
21796
|
Object.defineProperty(globalThis.fetch, IS_PATCHED_MODULE, {
|
|
21743
21797
|
enumerable: true,
|
|
@@ -21759,7 +21813,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
21759
21813
|
var FetchInterceptor = _FetchInterceptor;
|
|
21760
21814
|
FetchInterceptor.symbol = Symbol("fetch");
|
|
21761
21815
|
|
|
21762
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
21816
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.40.0/node_modules/@mswjs/interceptors/lib/browser/chunk-WADP6VHN.mjs
|
|
21763
21817
|
function concatArrayBuffer(left, right) {
|
|
21764
21818
|
const result = new Uint8Array(left.byteLength + right.byteLength);
|
|
21765
21819
|
result.set(left, 0);
|
|
@@ -21927,12 +21981,12 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
21927
21981
|
url: request.responseURL,
|
|
21928
21982
|
status: request.status,
|
|
21929
21983
|
statusText: request.statusText,
|
|
21930
|
-
headers:
|
|
21984
|
+
headers: createHeadersFromXMLHttpRequestHeaders(
|
|
21931
21985
|
request.getAllResponseHeaders()
|
|
21932
21986
|
)
|
|
21933
21987
|
});
|
|
21934
21988
|
}
|
|
21935
|
-
function
|
|
21989
|
+
function createHeadersFromXMLHttpRequestHeaders(headersString) {
|
|
21936
21990
|
const headers = new Headers();
|
|
21937
21991
|
const lines = headersString.split(/[\r\n]+/);
|
|
21938
21992
|
for (const line of lines) {
|
|
@@ -21984,7 +22038,6 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
21984
22038
|
}
|
|
21985
22039
|
},
|
|
21986
22040
|
methodCall: ([methodName, args], invoke) => {
|
|
21987
|
-
var _a2;
|
|
21988
22041
|
switch (methodName) {
|
|
21989
22042
|
case "open": {
|
|
21990
22043
|
const [method, url] = args;
|
|
@@ -22035,24 +22088,27 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
22035
22088
|
const requestBody = typeof body === "string" ? encodeBuffer(body) : body;
|
|
22036
22089
|
const fetchRequest = this.toFetchApiRequest(requestBody);
|
|
22037
22090
|
this[kFetchRequest] = fetchRequest.clone();
|
|
22038
|
-
|
|
22039
|
-
|
|
22040
|
-
|
|
22041
|
-
|
|
22042
|
-
|
|
22043
|
-
|
|
22044
|
-
|
|
22045
|
-
|
|
22046
|
-
this.
|
|
22047
|
-
|
|
22048
|
-
|
|
22049
|
-
this.request.setRequestHeader(
|
|
22050
|
-
INTERNAL_REQUEST_ID_HEADER_NAME,
|
|
22051
|
-
this.requestId
|
|
22091
|
+
queueMicrotask(() => {
|
|
22092
|
+
var _a2;
|
|
22093
|
+
const onceRequestSettled = ((_a2 = this.onRequest) == null ? void 0 : _a2.call(this, {
|
|
22094
|
+
request: fetchRequest,
|
|
22095
|
+
requestId: this.requestId
|
|
22096
|
+
})) || Promise.resolve();
|
|
22097
|
+
onceRequestSettled.finally(() => {
|
|
22098
|
+
if (!this[kIsRequestHandled]) {
|
|
22099
|
+
this.logger.info(
|
|
22100
|
+
"request callback settled but request has not been handled (readystate %d), performing as-is...",
|
|
22101
|
+
this.request.readyState
|
|
22052
22102
|
);
|
|
22103
|
+
if (IS_NODE2) {
|
|
22104
|
+
this.request.setRequestHeader(
|
|
22105
|
+
INTERNAL_REQUEST_ID_HEADER_NAME,
|
|
22106
|
+
this.requestId
|
|
22107
|
+
);
|
|
22108
|
+
}
|
|
22109
|
+
return invoke();
|
|
22053
22110
|
}
|
|
22054
|
-
|
|
22055
|
-
}
|
|
22111
|
+
});
|
|
22056
22112
|
});
|
|
22057
22113
|
break;
|
|
22058
22114
|
}
|
|
@@ -22342,7 +22398,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
22342
22398
|
define(this.request, "readyState", nextReadyState);
|
|
22343
22399
|
this.logger.info("set readyState to: %d", nextReadyState);
|
|
22344
22400
|
if (nextReadyState !== this.request.UNSENT) {
|
|
22345
|
-
this.logger.info('
|
|
22401
|
+
this.logger.info('triggering "readystatechange" event...');
|
|
22346
22402
|
this.trigger("readystatechange", this.request);
|
|
22347
22403
|
}
|
|
22348
22404
|
}
|
|
@@ -22451,35 +22507,37 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
22451
22507
|
logger
|
|
22452
22508
|
);
|
|
22453
22509
|
xhrRequestController.onRequest = async function({ request, requestId }) {
|
|
22454
|
-
const controller = new RequestController(request
|
|
22510
|
+
const controller = new RequestController(request, {
|
|
22511
|
+
passthrough: () => {
|
|
22512
|
+
this.logger.info(
|
|
22513
|
+
"no mocked response received, performing request as-is..."
|
|
22514
|
+
);
|
|
22515
|
+
},
|
|
22516
|
+
respondWith: async (response) => {
|
|
22517
|
+
if (isResponseError(response)) {
|
|
22518
|
+
this.errorWith(new TypeError("Network error"));
|
|
22519
|
+
return;
|
|
22520
|
+
}
|
|
22521
|
+
await this.respondWith(response);
|
|
22522
|
+
},
|
|
22523
|
+
errorWith: (reason) => {
|
|
22524
|
+
this.logger.info("request errored!", { error: reason });
|
|
22525
|
+
if (reason instanceof Error) {
|
|
22526
|
+
this.errorWith(reason);
|
|
22527
|
+
}
|
|
22528
|
+
}
|
|
22529
|
+
});
|
|
22455
22530
|
this.logger.info("awaiting mocked response...");
|
|
22456
22531
|
this.logger.info(
|
|
22457
22532
|
'emitting the "request" event for %s listener(s)...',
|
|
22458
22533
|
emitter.listenerCount("request")
|
|
22459
22534
|
);
|
|
22460
|
-
|
|
22535
|
+
await handleRequest2({
|
|
22461
22536
|
request,
|
|
22462
22537
|
requestId,
|
|
22463
22538
|
controller,
|
|
22464
|
-
emitter
|
|
22465
|
-
onResponse: async (response) => {
|
|
22466
|
-
await this.respondWith(response);
|
|
22467
|
-
},
|
|
22468
|
-
onRequestError: () => {
|
|
22469
|
-
this.errorWith(new TypeError("Network error"));
|
|
22470
|
-
},
|
|
22471
|
-
onError: (error3) => {
|
|
22472
|
-
this.logger.info("request errored!", { error: error3 });
|
|
22473
|
-
if (error3 instanceof Error) {
|
|
22474
|
-
this.errorWith(error3);
|
|
22475
|
-
}
|
|
22476
|
-
}
|
|
22539
|
+
emitter
|
|
22477
22540
|
});
|
|
22478
|
-
if (!isRequestHandled) {
|
|
22479
|
-
this.logger.info(
|
|
22480
|
-
"no mocked response received, performing request as-is..."
|
|
22481
|
-
);
|
|
22482
|
-
}
|
|
22483
22541
|
};
|
|
22484
22542
|
xhrRequestController.onResponse = async function({
|
|
22485
22543
|
response,
|