msw 2.11.4 → 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/core/index.d.mts +1 -1
- package/lib/core/index.d.ts +1 -1
- package/lib/core/index.js +2 -0
- package/lib/core/index.js.map +1 -1
- package/lib/core/index.mjs +4 -0
- package/lib/core/index.mjs.map +1 -1
- package/lib/iife/index.js +416 -357
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +1 -1
- package/package.json +4 -3
- package/src/core/index.ts +5 -0
package/lib/iife/index.js
CHANGED
|
@@ -13444,6 +13444,7 @@ ${operationTypes.join("\n")}
|
|
|
13444
13444
|
http: () => http,
|
|
13445
13445
|
isCommonAssetRequest: () => isCommonAssetRequest,
|
|
13446
13446
|
matchRequestUrl: () => matchRequestUrl,
|
|
13447
|
+
onUnhandledRequest: () => onUnhandledRequest,
|
|
13447
13448
|
passthrough: () => passthrough,
|
|
13448
13449
|
setupWorker: () => setupWorker,
|
|
13449
13450
|
ws: () => ws
|
|
@@ -14394,7 +14395,7 @@ ${operationTypes.join("\n")}
|
|
|
14394
14395
|
return stringToRegexp(path, keys, options);
|
|
14395
14396
|
}
|
|
14396
14397
|
|
|
14397
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
14398
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.40.0/node_modules/@mswjs/interceptors/lib/browser/chunk-6HYIRFX2.mjs
|
|
14398
14399
|
var encoder = new TextEncoder();
|
|
14399
14400
|
function encodeBuffer(text) {
|
|
14400
14401
|
return encoder.encode(text);
|
|
@@ -14410,100 +14411,6 @@ ${operationTypes.join("\n")}
|
|
|
14410
14411
|
);
|
|
14411
14412
|
}
|
|
14412
14413
|
|
|
14413
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.39.1/node_modules/@mswjs/interceptors/lib/browser/chunk-3RXCRGL2.mjs
|
|
14414
|
-
var IS_PATCHED_MODULE = Symbol("isPatchedModule");
|
|
14415
|
-
function canParseUrl(url) {
|
|
14416
|
-
try {
|
|
14417
|
-
new URL(url);
|
|
14418
|
-
return true;
|
|
14419
|
-
} catch (_error) {
|
|
14420
|
-
return false;
|
|
14421
|
-
}
|
|
14422
|
-
}
|
|
14423
|
-
function getValueBySymbol(symbolName, source) {
|
|
14424
|
-
const ownSymbols = Object.getOwnPropertySymbols(source);
|
|
14425
|
-
const symbol = ownSymbols.find((symbol2) => {
|
|
14426
|
-
return symbol2.description === symbolName;
|
|
14427
|
-
});
|
|
14428
|
-
if (symbol) {
|
|
14429
|
-
return Reflect.get(source, symbol);
|
|
14430
|
-
}
|
|
14431
|
-
return;
|
|
14432
|
-
}
|
|
14433
|
-
var _FetchResponse = class extends Response {
|
|
14434
|
-
static isConfigurableStatusCode(status) {
|
|
14435
|
-
return status >= 200 && status <= 599;
|
|
14436
|
-
}
|
|
14437
|
-
static isRedirectResponse(status) {
|
|
14438
|
-
return _FetchResponse.STATUS_CODES_WITH_REDIRECT.includes(status);
|
|
14439
|
-
}
|
|
14440
|
-
/**
|
|
14441
|
-
* Returns a boolean indicating whether the given response status
|
|
14442
|
-
* code represents a response that can have a body.
|
|
14443
|
-
*/
|
|
14444
|
-
static isResponseWithBody(status) {
|
|
14445
|
-
return !_FetchResponse.STATUS_CODES_WITHOUT_BODY.includes(status);
|
|
14446
|
-
}
|
|
14447
|
-
static setUrl(url, response) {
|
|
14448
|
-
if (!url || url === "about:" || !canParseUrl(url)) {
|
|
14449
|
-
return;
|
|
14450
|
-
}
|
|
14451
|
-
const state = getValueBySymbol("state", response);
|
|
14452
|
-
if (state) {
|
|
14453
|
-
state.urlList.push(new URL(url));
|
|
14454
|
-
} else {
|
|
14455
|
-
Object.defineProperty(response, "url", {
|
|
14456
|
-
value: url,
|
|
14457
|
-
enumerable: true,
|
|
14458
|
-
configurable: true,
|
|
14459
|
-
writable: false
|
|
14460
|
-
});
|
|
14461
|
-
}
|
|
14462
|
-
}
|
|
14463
|
-
/**
|
|
14464
|
-
* Parses the given raw HTTP headers into a Fetch API `Headers` instance.
|
|
14465
|
-
*/
|
|
14466
|
-
static parseRawHeaders(rawHeaders) {
|
|
14467
|
-
const headers = new Headers();
|
|
14468
|
-
for (let line = 0; line < rawHeaders.length; line += 2) {
|
|
14469
|
-
headers.append(rawHeaders[line], rawHeaders[line + 1]);
|
|
14470
|
-
}
|
|
14471
|
-
return headers;
|
|
14472
|
-
}
|
|
14473
|
-
constructor(body, init = {}) {
|
|
14474
|
-
var _a2;
|
|
14475
|
-
const status = (_a2 = init.status) != null ? _a2 : 200;
|
|
14476
|
-
const safeStatus = _FetchResponse.isConfigurableStatusCode(status) ? status : 200;
|
|
14477
|
-
const finalBody = _FetchResponse.isResponseWithBody(status) ? body : null;
|
|
14478
|
-
super(finalBody, {
|
|
14479
|
-
status: safeStatus,
|
|
14480
|
-
statusText: init.statusText,
|
|
14481
|
-
headers: init.headers
|
|
14482
|
-
});
|
|
14483
|
-
if (status !== safeStatus) {
|
|
14484
|
-
const state = getValueBySymbol("state", this);
|
|
14485
|
-
if (state) {
|
|
14486
|
-
state.status = status;
|
|
14487
|
-
} else {
|
|
14488
|
-
Object.defineProperty(this, "status", {
|
|
14489
|
-
value: status,
|
|
14490
|
-
enumerable: true,
|
|
14491
|
-
configurable: true,
|
|
14492
|
-
writable: false
|
|
14493
|
-
});
|
|
14494
|
-
}
|
|
14495
|
-
}
|
|
14496
|
-
_FetchResponse.setUrl(init.url, this);
|
|
14497
|
-
}
|
|
14498
|
-
};
|
|
14499
|
-
var FetchResponse = _FetchResponse;
|
|
14500
|
-
FetchResponse.STATUS_CODES_WITHOUT_BODY = [101, 103, 204, 205, 304];
|
|
14501
|
-
FetchResponse.STATUS_CODES_WITH_REDIRECT = [301, 302, 303, 307, 308];
|
|
14502
|
-
var kRawRequest = Symbol("kRawRequest");
|
|
14503
|
-
function setRawRequest(request, rawRequest) {
|
|
14504
|
-
Reflect.set(request, kRawRequest, rawRequest);
|
|
14505
|
-
}
|
|
14506
|
-
|
|
14507
14414
|
// node_modules/.pnpm/is-node-process@1.2.0/node_modules/is-node-process/lib/index.mjs
|
|
14508
14415
|
function isNodeProcess() {
|
|
14509
14416
|
if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
|
|
@@ -14791,7 +14698,20 @@ ${operationTypes.join("\n")}
|
|
|
14791
14698
|
return message4.toString();
|
|
14792
14699
|
}
|
|
14793
14700
|
|
|
14794
|
-
// 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
|
+
};
|
|
14795
14715
|
var INTERNAL_REQUEST_ID_HEADER_NAME = "x-interceptors-internal-request-id";
|
|
14796
14716
|
function getGlobalSymbol(symbol) {
|
|
14797
14717
|
return (
|
|
@@ -14939,7 +14859,254 @@ ${operationTypes.join("\n")}
|
|
|
14939
14859
|
return Math.random().toString(16).slice(2);
|
|
14940
14860
|
}
|
|
14941
14861
|
|
|
14942
|
-
// 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
|
|
14943
15110
|
var BatchInterceptor = class extends Interceptor {
|
|
14944
15111
|
constructor(options) {
|
|
14945
15112
|
BatchInterceptor.symbol = Symbol(options.name);
|
|
@@ -18835,72 +19002,6 @@ Consider naming this operation or using "graphql.operation()" request handler to
|
|
|
18835
19002
|
}
|
|
18836
19003
|
};
|
|
18837
19004
|
|
|
18838
|
-
// node_modules/.pnpm/@open-draft+deferred-promise@2.2.0/node_modules/@open-draft/deferred-promise/build/index.mjs
|
|
18839
|
-
function createDeferredExecutor() {
|
|
18840
|
-
const executor = (resolve, reject) => {
|
|
18841
|
-
executor.state = "pending";
|
|
18842
|
-
executor.resolve = (data) => {
|
|
18843
|
-
if (executor.state !== "pending") {
|
|
18844
|
-
return;
|
|
18845
|
-
}
|
|
18846
|
-
executor.result = data;
|
|
18847
|
-
const onFulfilled = (value) => {
|
|
18848
|
-
executor.state = "fulfilled";
|
|
18849
|
-
return value;
|
|
18850
|
-
};
|
|
18851
|
-
return resolve(
|
|
18852
|
-
data instanceof Promise ? data : Promise.resolve(data).then(onFulfilled)
|
|
18853
|
-
);
|
|
18854
|
-
};
|
|
18855
|
-
executor.reject = (reason) => {
|
|
18856
|
-
if (executor.state !== "pending") {
|
|
18857
|
-
return;
|
|
18858
|
-
}
|
|
18859
|
-
queueMicrotask(() => {
|
|
18860
|
-
executor.state = "rejected";
|
|
18861
|
-
});
|
|
18862
|
-
return reject(executor.rejectionReason = reason);
|
|
18863
|
-
};
|
|
18864
|
-
};
|
|
18865
|
-
return executor;
|
|
18866
|
-
}
|
|
18867
|
-
var DeferredPromise = class extends Promise {
|
|
18868
|
-
#executor;
|
|
18869
|
-
resolve;
|
|
18870
|
-
reject;
|
|
18871
|
-
constructor(executor = null) {
|
|
18872
|
-
const deferredExecutor = createDeferredExecutor();
|
|
18873
|
-
super((originalResolve, originalReject) => {
|
|
18874
|
-
deferredExecutor(originalResolve, originalReject);
|
|
18875
|
-
executor?.(deferredExecutor.resolve, deferredExecutor.reject);
|
|
18876
|
-
});
|
|
18877
|
-
this.#executor = deferredExecutor;
|
|
18878
|
-
this.resolve = this.#executor.resolve;
|
|
18879
|
-
this.reject = this.#executor.reject;
|
|
18880
|
-
}
|
|
18881
|
-
get state() {
|
|
18882
|
-
return this.#executor.state;
|
|
18883
|
-
}
|
|
18884
|
-
get rejectionReason() {
|
|
18885
|
-
return this.#executor.rejectionReason;
|
|
18886
|
-
}
|
|
18887
|
-
then(onFulfilled, onRejected) {
|
|
18888
|
-
return this.#decorate(super.then(onFulfilled, onRejected));
|
|
18889
|
-
}
|
|
18890
|
-
catch(onRejected) {
|
|
18891
|
-
return this.#decorate(super.catch(onRejected));
|
|
18892
|
-
}
|
|
18893
|
-
finally(onfinally) {
|
|
18894
|
-
return this.#decorate(super.finally(onfinally));
|
|
18895
|
-
}
|
|
18896
|
-
#decorate(promise) {
|
|
18897
|
-
return Object.defineProperties(promise, {
|
|
18898
|
-
resolve: { configurable: true, value: this.resolve },
|
|
18899
|
-
reject: { configurable: true, value: this.reject }
|
|
18900
|
-
});
|
|
18901
|
-
}
|
|
18902
|
-
};
|
|
18903
|
-
|
|
18904
19005
|
// src/core/ws/WebSocketIndexedDBClientStore.ts
|
|
18905
19006
|
var DB_NAME = "msw-websocket-clients";
|
|
18906
19007
|
var DB_STORE_NAME = "clients";
|
|
@@ -20041,7 +20142,16 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
20041
20142
|
};
|
|
20042
20143
|
};
|
|
20043
20144
|
|
|
20044
|
-
// 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
|
+
}
|
|
20045
20155
|
function hasConfigurableGlobal(propertyName) {
|
|
20046
20156
|
const descriptor = Object.getOwnPropertyDescriptor(globalThis, propertyName);
|
|
20047
20157
|
if (typeof descriptor === "undefined") {
|
|
@@ -20062,7 +20172,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
20062
20172
|
return true;
|
|
20063
20173
|
}
|
|
20064
20174
|
|
|
20065
|
-
// 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
|
|
20066
20176
|
function bindEvent(target, event) {
|
|
20067
20177
|
Object.defineProperties(event, {
|
|
20068
20178
|
target: {
|
|
@@ -20684,14 +20794,15 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
20684
20794
|
};
|
|
20685
20795
|
const socket = new WebSocketOverride(url, protocols);
|
|
20686
20796
|
const transport = new WebSocketClassTransport(socket);
|
|
20687
|
-
queueMicrotask(() => {
|
|
20797
|
+
queueMicrotask(async () => {
|
|
20688
20798
|
try {
|
|
20689
20799
|
const server = new WebSocketServerConnection(
|
|
20690
20800
|
socket,
|
|
20691
20801
|
transport,
|
|
20692
20802
|
createConnection
|
|
20693
20803
|
);
|
|
20694
|
-
const hasConnectionListeners = this.emitter.
|
|
20804
|
+
const hasConnectionListeners = this.emitter.listenerCount("connection") > 0;
|
|
20805
|
+
await emitAsync(this.emitter, "connection", {
|
|
20695
20806
|
client: new WebSocketClientConnection(socket, transport),
|
|
20696
20807
|
server,
|
|
20697
20808
|
info: {
|
|
@@ -21285,69 +21396,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
21285
21396
|
}
|
|
21286
21397
|
};
|
|
21287
21398
|
|
|
21288
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
21289
|
-
var InterceptorError = class extends Error {
|
|
21290
|
-
constructor(message4) {
|
|
21291
|
-
super(message4);
|
|
21292
|
-
this.name = "InterceptorError";
|
|
21293
|
-
Object.setPrototypeOf(this, InterceptorError.prototype);
|
|
21294
|
-
}
|
|
21295
|
-
};
|
|
21296
|
-
var kRequestHandled = Symbol("kRequestHandled");
|
|
21297
|
-
var kResponsePromise = Symbol("kResponsePromise");
|
|
21298
|
-
var RequestController = class {
|
|
21299
|
-
constructor(request) {
|
|
21300
|
-
this.request = request;
|
|
21301
|
-
this[kRequestHandled] = false;
|
|
21302
|
-
this[kResponsePromise] = new DeferredPromise();
|
|
21303
|
-
}
|
|
21304
|
-
/**
|
|
21305
|
-
* Respond to this request with the given `Response` instance.
|
|
21306
|
-
* @example
|
|
21307
|
-
* controller.respondWith(new Response())
|
|
21308
|
-
* controller.respondWith(Response.json({ id }))
|
|
21309
|
-
* controller.respondWith(Response.error())
|
|
21310
|
-
*/
|
|
21311
|
-
respondWith(response) {
|
|
21312
|
-
invariant.as(
|
|
21313
|
-
InterceptorError,
|
|
21314
|
-
!this[kRequestHandled],
|
|
21315
|
-
'Failed to respond to the "%s %s" request: the "request" event has already been handled.',
|
|
21316
|
-
this.request.method,
|
|
21317
|
-
this.request.url
|
|
21318
|
-
);
|
|
21319
|
-
this[kRequestHandled] = true;
|
|
21320
|
-
this[kResponsePromise].resolve(response);
|
|
21321
|
-
}
|
|
21322
|
-
/**
|
|
21323
|
-
* Error this request with the given reason.
|
|
21324
|
-
*
|
|
21325
|
-
* @example
|
|
21326
|
-
* controller.errorWith()
|
|
21327
|
-
* controller.errorWith(new Error('Oops!'))
|
|
21328
|
-
* controller.errorWith({ message: 'Oops!'})
|
|
21329
|
-
*/
|
|
21330
|
-
errorWith(reason) {
|
|
21331
|
-
invariant.as(
|
|
21332
|
-
InterceptorError,
|
|
21333
|
-
!this[kRequestHandled],
|
|
21334
|
-
'Failed to error the "%s %s" request: the "request" event has already been handled.',
|
|
21335
|
-
this.request.method,
|
|
21336
|
-
this.request.url
|
|
21337
|
-
);
|
|
21338
|
-
this[kRequestHandled] = true;
|
|
21339
|
-
this[kResponsePromise].resolve(reason);
|
|
21340
|
-
}
|
|
21341
|
-
};
|
|
21342
|
-
async function emitAsync(emitter, eventName, ...data) {
|
|
21343
|
-
const listners = emitter.listeners(eventName);
|
|
21344
|
-
if (listners.length === 0) {
|
|
21345
|
-
return;
|
|
21346
|
-
}
|
|
21347
|
-
for (const listener of listners) {
|
|
21348
|
-
await listener.apply(emitter, data);
|
|
21349
|
-
}
|
|
21350
|
-
}
|
|
21399
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.40.0/node_modules/@mswjs/interceptors/lib/browser/chunk-VOUOVDAW.mjs
|
|
21351
21400
|
function isObject3(value, loose = false) {
|
|
21352
21401
|
return loose ? Object.prototype.toString.call(value).startsWith("[object ") : Object.prototype.toString.call(value) === "[object Object]";
|
|
21353
21402
|
}
|
|
@@ -21395,19 +21444,19 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
21395
21444
|
async function handleRequest2(options) {
|
|
21396
21445
|
const handleResponse = async (response) => {
|
|
21397
21446
|
if (response instanceof Error) {
|
|
21398
|
-
options.
|
|
21447
|
+
await options.controller.errorWith(response);
|
|
21399
21448
|
return true;
|
|
21400
21449
|
}
|
|
21401
21450
|
if (isResponseError(response)) {
|
|
21402
|
-
options.
|
|
21451
|
+
await options.controller.respondWith(response);
|
|
21403
21452
|
return true;
|
|
21404
21453
|
}
|
|
21405
21454
|
if (isResponseLike(response)) {
|
|
21406
|
-
await options.
|
|
21455
|
+
await options.controller.respondWith(response);
|
|
21407
21456
|
return true;
|
|
21408
21457
|
}
|
|
21409
21458
|
if (isObject3(response)) {
|
|
21410
|
-
options.
|
|
21459
|
+
await options.controller.errorWith(response);
|
|
21411
21460
|
return true;
|
|
21412
21461
|
}
|
|
21413
21462
|
return false;
|
|
@@ -21417,7 +21466,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
21417
21466
|
throw result.error;
|
|
21418
21467
|
}
|
|
21419
21468
|
if (isNodeLikeError(error3)) {
|
|
21420
|
-
options.
|
|
21469
|
+
await options.controller.errorWith(error3);
|
|
21421
21470
|
return true;
|
|
21422
21471
|
}
|
|
21423
21472
|
if (error3 instanceof Response) {
|
|
@@ -21425,27 +21474,19 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
21425
21474
|
}
|
|
21426
21475
|
return false;
|
|
21427
21476
|
};
|
|
21428
|
-
options.emitter.once("request", ({ requestId: pendingRequestId }) => {
|
|
21429
|
-
if (pendingRequestId !== options.requestId) {
|
|
21430
|
-
return;
|
|
21431
|
-
}
|
|
21432
|
-
if (options.controller[kResponsePromise].state === "pending") {
|
|
21433
|
-
options.controller[kResponsePromise].resolve(void 0);
|
|
21434
|
-
}
|
|
21435
|
-
});
|
|
21436
21477
|
const requestAbortPromise = new DeferredPromise();
|
|
21437
21478
|
if (options.request.signal) {
|
|
21438
21479
|
if (options.request.signal.aborted) {
|
|
21439
|
-
|
|
21440
|
-
|
|
21441
|
-
options.request.signal.addEventListener(
|
|
21442
|
-
"abort",
|
|
21443
|
-
() => {
|
|
21444
|
-
requestAbortPromise.reject(options.request.signal.reason);
|
|
21445
|
-
},
|
|
21446
|
-
{ once: true }
|
|
21447
|
-
);
|
|
21480
|
+
await options.controller.errorWith(options.request.signal.reason);
|
|
21481
|
+
return;
|
|
21448
21482
|
}
|
|
21483
|
+
options.request.signal.addEventListener(
|
|
21484
|
+
"abort",
|
|
21485
|
+
() => {
|
|
21486
|
+
requestAbortPromise.reject(options.request.signal.reason);
|
|
21487
|
+
},
|
|
21488
|
+
{ once: true }
|
|
21489
|
+
);
|
|
21449
21490
|
}
|
|
21450
21491
|
const result = await until2(async () => {
|
|
21451
21492
|
const requestListenersPromise = emitAsync(options.emitter, "request", {
|
|
@@ -21457,52 +21498,58 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
21457
21498
|
// Short-circuit the request handling promise if the request gets aborted.
|
|
21458
21499
|
requestAbortPromise,
|
|
21459
21500
|
requestListenersPromise,
|
|
21460
|
-
options.controller
|
|
21501
|
+
options.controller.handled
|
|
21461
21502
|
]);
|
|
21462
|
-
return await options.controller[kResponsePromise];
|
|
21463
21503
|
});
|
|
21464
21504
|
if (requestAbortPromise.state === "rejected") {
|
|
21465
|
-
options.
|
|
21466
|
-
return
|
|
21505
|
+
await options.controller.errorWith(requestAbortPromise.rejectionReason);
|
|
21506
|
+
return;
|
|
21467
21507
|
}
|
|
21468
21508
|
if (result.error) {
|
|
21469
21509
|
if (await handleResponseError(result.error)) {
|
|
21470
|
-
return
|
|
21510
|
+
return;
|
|
21471
21511
|
}
|
|
21472
21512
|
if (options.emitter.listenerCount("unhandledException") > 0) {
|
|
21473
21513
|
const unhandledExceptionController = new RequestController(
|
|
21474
|
-
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
|
+
}
|
|
21475
21530
|
);
|
|
21476
21531
|
await emitAsync(options.emitter, "unhandledException", {
|
|
21477
21532
|
error: result.error,
|
|
21478
21533
|
request: options.request,
|
|
21479
21534
|
requestId: options.requestId,
|
|
21480
21535
|
controller: unhandledExceptionController
|
|
21481
|
-
}).then(() => {
|
|
21482
|
-
if (unhandledExceptionController[kResponsePromise].state === "pending") {
|
|
21483
|
-
unhandledExceptionController[kResponsePromise].resolve(void 0);
|
|
21484
|
-
}
|
|
21485
21536
|
});
|
|
21486
|
-
|
|
21487
|
-
|
|
21488
|
-
);
|
|
21489
|
-
if (nextResult.error) {
|
|
21490
|
-
return handleResponseError(nextResult.error);
|
|
21491
|
-
}
|
|
21492
|
-
if (nextResult.data) {
|
|
21493
|
-
return handleResponse(nextResult.data);
|
|
21537
|
+
if (unhandledExceptionController.readyState !== RequestController.PENDING) {
|
|
21538
|
+
return;
|
|
21494
21539
|
}
|
|
21495
21540
|
}
|
|
21496
|
-
options.
|
|
21497
|
-
|
|
21541
|
+
await options.controller.respondWith(
|
|
21542
|
+
createServerErrorResponse(result.error)
|
|
21543
|
+
);
|
|
21544
|
+
return;
|
|
21498
21545
|
}
|
|
21499
|
-
if (
|
|
21500
|
-
return
|
|
21546
|
+
if (options.controller.readyState === RequestController.PENDING) {
|
|
21547
|
+
return await options.controller.passthrough();
|
|
21501
21548
|
}
|
|
21502
|
-
return
|
|
21549
|
+
return options.controller.handled;
|
|
21503
21550
|
}
|
|
21504
21551
|
|
|
21505
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
21552
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.40.0/node_modules/@mswjs/interceptors/lib/browser/chunk-WOWPV4GR.mjs
|
|
21506
21553
|
function createNetworkError(cause) {
|
|
21507
21554
|
return Object.assign(new TypeError("Failed to fetch"), {
|
|
21508
21555
|
cause
|
|
@@ -21558,7 +21605,12 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
21558
21605
|
request.headers.delete("host");
|
|
21559
21606
|
}
|
|
21560
21607
|
requestInit.headers = request.headers;
|
|
21561
|
-
|
|
21608
|
+
const finalResponse = await fetch(new Request(locationUrl, requestInit));
|
|
21609
|
+
Object.defineProperty(finalResponse, "redirected", {
|
|
21610
|
+
value: true,
|
|
21611
|
+
configurable: true
|
|
21612
|
+
});
|
|
21613
|
+
return finalResponse;
|
|
21562
21614
|
}
|
|
21563
21615
|
function sameOrigin(left, right) {
|
|
21564
21616
|
if (left.origin === right.origin && left.origin === "null") {
|
|
@@ -21656,19 +21708,35 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
21656
21708
|
setRawRequest(request, input);
|
|
21657
21709
|
}
|
|
21658
21710
|
const responsePromise = new DeferredPromise();
|
|
21659
|
-
const controller = new RequestController(request
|
|
21660
|
-
|
|
21661
|
-
|
|
21662
|
-
|
|
21663
|
-
|
|
21664
|
-
|
|
21665
|
-
|
|
21666
|
-
|
|
21667
|
-
|
|
21668
|
-
|
|
21669
|
-
|
|
21670
|
-
|
|
21671
|
-
|
|
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
|
+
}
|
|
21672
21740
|
this.logger.info("received mocked response!", {
|
|
21673
21741
|
rawResponse
|
|
21674
21742
|
});
|
|
@@ -21706,37 +21774,24 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
21706
21774
|
}
|
|
21707
21775
|
responsePromise.resolve(response);
|
|
21708
21776
|
},
|
|
21709
|
-
|
|
21710
|
-
this.logger.info("request has
|
|
21711
|
-
responsePromise.reject(
|
|
21712
|
-
},
|
|
21713
|
-
onError: (error3) => {
|
|
21714
|
-
this.logger.info("request has been aborted!", { error: error3 });
|
|
21715
|
-
responsePromise.reject(error3);
|
|
21777
|
+
errorWith: (reason) => {
|
|
21778
|
+
this.logger.info("request has been aborted!", { reason });
|
|
21779
|
+
responsePromise.reject(reason);
|
|
21716
21780
|
}
|
|
21717
21781
|
});
|
|
21718
|
-
|
|
21719
|
-
|
|
21720
|
-
return responsePromise;
|
|
21721
|
-
}
|
|
21782
|
+
this.logger.info("[%s] %s", request.method, request.url);
|
|
21783
|
+
this.logger.info("awaiting for the mocked response...");
|
|
21722
21784
|
this.logger.info(
|
|
21723
|
-
|
|
21785
|
+
'emitting the "request" event for %s listener(s)...',
|
|
21786
|
+
this.emitter.listenerCount("request")
|
|
21724
21787
|
);
|
|
21725
|
-
|
|
21726
|
-
|
|
21727
|
-
|
|
21728
|
-
|
|
21729
|
-
|
|
21730
|
-
const responseClone = response.clone();
|
|
21731
|
-
await emitAsync(this.emitter, "response", {
|
|
21732
|
-
response: responseClone,
|
|
21733
|
-
isMockedResponse: false,
|
|
21734
|
-
request: requestCloneForResponseEvent,
|
|
21735
|
-
requestId
|
|
21736
|
-
});
|
|
21737
|
-
}
|
|
21738
|
-
return response;
|
|
21788
|
+
await handleRequest2({
|
|
21789
|
+
request,
|
|
21790
|
+
requestId,
|
|
21791
|
+
emitter: this.emitter,
|
|
21792
|
+
controller
|
|
21739
21793
|
});
|
|
21794
|
+
return responsePromise;
|
|
21740
21795
|
};
|
|
21741
21796
|
Object.defineProperty(globalThis.fetch, IS_PATCHED_MODULE, {
|
|
21742
21797
|
enumerable: true,
|
|
@@ -21758,7 +21813,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
21758
21813
|
var FetchInterceptor = _FetchInterceptor;
|
|
21759
21814
|
FetchInterceptor.symbol = Symbol("fetch");
|
|
21760
21815
|
|
|
21761
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
21816
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.40.0/node_modules/@mswjs/interceptors/lib/browser/chunk-WADP6VHN.mjs
|
|
21762
21817
|
function concatArrayBuffer(left, right) {
|
|
21763
21818
|
const result = new Uint8Array(left.byteLength + right.byteLength);
|
|
21764
21819
|
result.set(left, 0);
|
|
@@ -21926,12 +21981,12 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
21926
21981
|
url: request.responseURL,
|
|
21927
21982
|
status: request.status,
|
|
21928
21983
|
statusText: request.statusText,
|
|
21929
|
-
headers:
|
|
21984
|
+
headers: createHeadersFromXMLHttpRequestHeaders(
|
|
21930
21985
|
request.getAllResponseHeaders()
|
|
21931
21986
|
)
|
|
21932
21987
|
});
|
|
21933
21988
|
}
|
|
21934
|
-
function
|
|
21989
|
+
function createHeadersFromXMLHttpRequestHeaders(headersString) {
|
|
21935
21990
|
const headers = new Headers();
|
|
21936
21991
|
const lines = headersString.split(/[\r\n]+/);
|
|
21937
21992
|
for (const line of lines) {
|
|
@@ -21983,7 +22038,6 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
21983
22038
|
}
|
|
21984
22039
|
},
|
|
21985
22040
|
methodCall: ([methodName, args], invoke) => {
|
|
21986
|
-
var _a2;
|
|
21987
22041
|
switch (methodName) {
|
|
21988
22042
|
case "open": {
|
|
21989
22043
|
const [method, url] = args;
|
|
@@ -22034,24 +22088,27 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
22034
22088
|
const requestBody = typeof body === "string" ? encodeBuffer(body) : body;
|
|
22035
22089
|
const fetchRequest = this.toFetchApiRequest(requestBody);
|
|
22036
22090
|
this[kFetchRequest] = fetchRequest.clone();
|
|
22037
|
-
|
|
22038
|
-
|
|
22039
|
-
|
|
22040
|
-
|
|
22041
|
-
|
|
22042
|
-
|
|
22043
|
-
|
|
22044
|
-
|
|
22045
|
-
this.
|
|
22046
|
-
|
|
22047
|
-
|
|
22048
|
-
this.request.setRequestHeader(
|
|
22049
|
-
INTERNAL_REQUEST_ID_HEADER_NAME,
|
|
22050
|
-
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
|
|
22051
22102
|
);
|
|
22103
|
+
if (IS_NODE2) {
|
|
22104
|
+
this.request.setRequestHeader(
|
|
22105
|
+
INTERNAL_REQUEST_ID_HEADER_NAME,
|
|
22106
|
+
this.requestId
|
|
22107
|
+
);
|
|
22108
|
+
}
|
|
22109
|
+
return invoke();
|
|
22052
22110
|
}
|
|
22053
|
-
|
|
22054
|
-
}
|
|
22111
|
+
});
|
|
22055
22112
|
});
|
|
22056
22113
|
break;
|
|
22057
22114
|
}
|
|
@@ -22341,7 +22398,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
22341
22398
|
define(this.request, "readyState", nextReadyState);
|
|
22342
22399
|
this.logger.info("set readyState to: %d", nextReadyState);
|
|
22343
22400
|
if (nextReadyState !== this.request.UNSENT) {
|
|
22344
|
-
this.logger.info('
|
|
22401
|
+
this.logger.info('triggering "readystatechange" event...');
|
|
22345
22402
|
this.trigger("readystatechange", this.request);
|
|
22346
22403
|
}
|
|
22347
22404
|
}
|
|
@@ -22450,35 +22507,37 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
22450
22507
|
logger
|
|
22451
22508
|
);
|
|
22452
22509
|
xhrRequestController.onRequest = async function({ request, requestId }) {
|
|
22453
|
-
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
|
+
});
|
|
22454
22530
|
this.logger.info("awaiting mocked response...");
|
|
22455
22531
|
this.logger.info(
|
|
22456
22532
|
'emitting the "request" event for %s listener(s)...',
|
|
22457
22533
|
emitter.listenerCount("request")
|
|
22458
22534
|
);
|
|
22459
|
-
|
|
22535
|
+
await handleRequest2({
|
|
22460
22536
|
request,
|
|
22461
22537
|
requestId,
|
|
22462
22538
|
controller,
|
|
22463
|
-
emitter
|
|
22464
|
-
onResponse: async (response) => {
|
|
22465
|
-
await this.respondWith(response);
|
|
22466
|
-
},
|
|
22467
|
-
onRequestError: () => {
|
|
22468
|
-
this.errorWith(new TypeError("Network error"));
|
|
22469
|
-
},
|
|
22470
|
-
onError: (error3) => {
|
|
22471
|
-
this.logger.info("request errored!", { error: error3 });
|
|
22472
|
-
if (error3 instanceof Error) {
|
|
22473
|
-
this.errorWith(error3);
|
|
22474
|
-
}
|
|
22475
|
-
}
|
|
22539
|
+
emitter
|
|
22476
22540
|
});
|
|
22477
|
-
if (!isRequestHandled) {
|
|
22478
|
-
this.logger.info(
|
|
22479
|
-
"no mocked response received, performing request as-is..."
|
|
22480
|
-
);
|
|
22481
|
-
}
|
|
22482
22541
|
};
|
|
22483
22542
|
xhrRequestController.onResponse = async function({
|
|
22484
22543
|
response,
|