msw 0.44.1 → 0.46.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/{glossary-297d38ba.d.ts → glossary-c690f512.d.ts} +17 -7
- package/lib/iife/index.js +14293 -5456
- package/lib/iife/index.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +61 -93
- package/lib/index.js.map +1 -1
- package/lib/mockServiceWorker.js +5 -69
- package/lib/native/index.d.ts +1 -1
- package/lib/native/index.js +14 -5
- package/lib/native/index.mjs +14 -7
- package/lib/node/index.d.ts +2 -2
- package/lib/node/index.js +14 -5
- package/lib/node/index.js.map +1 -1
- package/lib/node/index.mjs +14 -7
- package/lib/node/index.mjs.map +1 -1
- package/package.json +9 -5
package/lib/node/index.mjs
CHANGED
|
@@ -138,11 +138,6 @@ var devUtils = {
|
|
|
138
138
|
// src/utils/request/onUnhandledRequest.ts
|
|
139
139
|
import getStringMatchScore from "js-levenshtein";
|
|
140
140
|
|
|
141
|
-
// src/utils/internal/parseGraphQLRequest.ts
|
|
142
|
-
import {
|
|
143
|
-
parse
|
|
144
|
-
} from "graphql";
|
|
145
|
-
|
|
146
141
|
// src/utils/request/getPublicUrlFromRequest.ts
|
|
147
142
|
var getPublicUrlFromRequest = (request) => {
|
|
148
143
|
return request.referrer.startsWith(request.url.origin) ? request.url.pathname : new URL(request.url.pathname, `${request.url.protocol}//${request.url.host}`).href;
|
|
@@ -170,7 +165,8 @@ function parseDocumentNode(node) {
|
|
|
170
165
|
}
|
|
171
166
|
function parseQuery(query) {
|
|
172
167
|
try {
|
|
173
|
-
const
|
|
168
|
+
const { parse: parse3 } = __require("graphql");
|
|
169
|
+
const ast = parse3(query);
|
|
174
170
|
return parseDocumentNode(ast);
|
|
175
171
|
} catch (error2) {
|
|
176
172
|
return error2;
|
|
@@ -1229,6 +1225,13 @@ function pipeEvents(source, destination) {
|
|
|
1229
1225
|
source.emit._isPiped = true;
|
|
1230
1226
|
}
|
|
1231
1227
|
|
|
1228
|
+
// src/utils/internal/toReadonlyArray.ts
|
|
1229
|
+
function toReadonlyArray(source) {
|
|
1230
|
+
const clone = [...source];
|
|
1231
|
+
Object.freeze(clone);
|
|
1232
|
+
return clone;
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1232
1235
|
// src/node/createSetupServer.ts
|
|
1233
1236
|
var DEFAULT_LISTEN_OPTIONS = {
|
|
1234
1237
|
onUnhandledRequest: "warn"
|
|
@@ -1300,8 +1303,12 @@ function createSetupServer(...interceptors) {
|
|
|
1300
1303
|
resetHandlers(...nextHandlers) {
|
|
1301
1304
|
currentHandlers = resetHandlers(requestHandlers, ...nextHandlers);
|
|
1302
1305
|
},
|
|
1306
|
+
listHandlers() {
|
|
1307
|
+
return toReadonlyArray(currentHandlers);
|
|
1308
|
+
},
|
|
1303
1309
|
printHandlers() {
|
|
1304
|
-
|
|
1310
|
+
const handlers = this.listHandlers();
|
|
1311
|
+
handlers.forEach((handler) => {
|
|
1305
1312
|
const { header, callFrame } = handler.info;
|
|
1306
1313
|
const pragma = handler.info.hasOwnProperty("operationType") ? "[graphql]" : "[rest]";
|
|
1307
1314
|
console.log(`${bold(`${pragma} ${header}`)}
|