msw 2.6.8 → 2.7.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/cli/init.js +9 -9
- package/cli/invariant.js +2 -2
- package/lib/core/{GraphQLHandler-Cjm7JNGi.d.ts → GraphQLHandler-C5CUIS_N.d.ts} +1 -1
- package/lib/core/{GraphQLHandler-B6uni-E_.d.mts → GraphQLHandler-CLv2BIIm.d.mts} +1 -1
- package/lib/core/{HttpResponse-DzhqZzTK.d.ts → HttpResponse-5Sn2vNaJ.d.ts} +1 -1
- package/lib/core/{HttpResponse-63H9vVoL.d.mts → HttpResponse-CFPhtDH3.d.mts} +1 -1
- package/lib/core/HttpResponse.d.mts +1 -1
- package/lib/core/HttpResponse.d.ts +1 -1
- package/lib/core/HttpResponse.js +3 -0
- package/lib/core/HttpResponse.js.map +1 -1
- package/lib/core/HttpResponse.mjs +3 -0
- package/lib/core/HttpResponse.mjs.map +1 -1
- package/lib/core/SetupApi.d.mts +1 -1
- package/lib/core/SetupApi.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 +2 -2
- package/lib/core/graphql.d.ts +2 -2
- package/lib/core/handlers/GraphQLHandler.d.mts +2 -2
- package/lib/core/handlers/GraphQLHandler.d.ts +2 -2
- 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/http.d.mts +1 -1
- package/lib/core/http.d.ts +1 -1
- package/lib/core/index.d.mts +2 -2
- package/lib/core/index.d.ts +2 -2
- package/lib/core/passthrough.d.mts +1 -1
- package/lib/core/passthrough.d.ts +1 -1
- package/lib/core/utils/HttpResponse/decorators.d.mts +1 -1
- package/lib/core/utils/HttpResponse/decorators.d.ts +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/isHandlerKind.d.mts +1 -1
- package/lib/core/utils/internal/isHandlerKind.d.ts +1 -1
- package/lib/core/utils/internal/parseGraphQLRequest.d.mts +2 -2
- package/lib/core/utils/internal/parseGraphQLRequest.d.ts +2 -2
- package/lib/core/utils/internal/parseMultipartData.d.mts +1 -1
- package/lib/core/utils/internal/parseMultipartData.d.ts +1 -1
- package/lib/core/utils/internal/requestHandlerUtils.d.mts +1 -1
- package/lib/core/utils/internal/requestHandlerUtils.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 +3 -0
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +1 -1
- package/package.json +4 -3
- package/src/core/HttpResponse.test.ts +81 -10
- package/src/core/HttpResponse.ts +8 -1
package/cli/init.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const fs = require('fs')
|
|
2
2
|
const path = require('path')
|
|
3
|
-
const
|
|
3
|
+
const colors = require('picocolors')
|
|
4
4
|
const confirm = require('@inquirer/confirm').default
|
|
5
5
|
const invariant = require('./invariant')
|
|
6
6
|
const { SERVICE_WORKER_BUILD_PATH } = require('../config/constants')
|
|
@@ -34,7 +34,7 @@ module.exports = async function init(args) {
|
|
|
34
34
|
// will equal to false.
|
|
35
35
|
else if (args.save == null) {
|
|
36
36
|
console.log(`\
|
|
37
|
-
${
|
|
37
|
+
${colors.cyan(
|
|
38
38
|
'INFO',
|
|
39
39
|
)} In order to ease the future updates to the worker script,
|
|
40
40
|
we recommend saving the path to the worker directory in your package.json.`)
|
|
@@ -141,20 +141,20 @@ async function copyWorkerScript(destination, cwd) {
|
|
|
141
141
|
*/
|
|
142
142
|
function printSuccessMessage(paths) {
|
|
143
143
|
console.log(`
|
|
144
|
-
${
|
|
145
|
-
${paths.map((path) =>
|
|
144
|
+
${colors.green('Worker script successfully copied!')}
|
|
145
|
+
${paths.map((path) => colors.gray(` - ${path}\n`))}
|
|
146
146
|
Continue by describing the network in your application:
|
|
147
147
|
|
|
148
148
|
|
|
149
|
-
${
|
|
149
|
+
${colors.red(colors.bold('https://mswjs.io/docs/getting-started'))}
|
|
150
150
|
`)
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
function printFailureMessage(pathsWithErrors) {
|
|
154
154
|
console.error(`\
|
|
155
|
-
${
|
|
155
|
+
${colors.red('Copying the worker script failed at following paths:')}
|
|
156
156
|
${pathsWithErrors
|
|
157
|
-
.map(([path, error]) =>
|
|
157
|
+
.map(([path, error]) => colors.gray(` - ${path}`) + '\n' + ` ${error}`)
|
|
158
158
|
.join('\n\n')}
|
|
159
159
|
`)
|
|
160
160
|
}
|
|
@@ -167,7 +167,7 @@ function saveWorkerDirectory(packageJsonPath, publicDir) {
|
|
|
167
167
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'))
|
|
168
168
|
|
|
169
169
|
console.log(
|
|
170
|
-
|
|
170
|
+
colors.gray('Updating "msw.workerDirectory" at "%s"...'),
|
|
171
171
|
packageJsonPath,
|
|
172
172
|
)
|
|
173
173
|
|
|
@@ -200,7 +200,7 @@ function saveWorkerDirectory(packageJsonPath, publicDir) {
|
|
|
200
200
|
function promptWorkerDirectoryUpdate(message, packageJsonPath, publicDir) {
|
|
201
201
|
return confirm({
|
|
202
202
|
theme: {
|
|
203
|
-
prefix:
|
|
203
|
+
prefix: colors.yellowBright('?'),
|
|
204
204
|
},
|
|
205
205
|
message,
|
|
206
206
|
}).then((answer) => {
|
package/cli/invariant.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const
|
|
1
|
+
const colors = require('picocolors')
|
|
2
2
|
|
|
3
3
|
module.exports = function invariant(predicate, message, ...args) {
|
|
4
4
|
if (!predicate) {
|
|
5
|
-
console.error(
|
|
5
|
+
console.error(colors.red(message), ...args)
|
|
6
6
|
process.exit(1)
|
|
7
7
|
}
|
|
8
8
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OperationTypeNode, DocumentNode, GraphQLError } from 'graphql';
|
|
2
|
-
import { g as RequestHandlerDefaultInfo, D as DefaultBodyType, R as RequestHandler, a as ResponseResolver, c as RequestHandlerOptions } from './HttpResponse-
|
|
2
|
+
import { g as RequestHandlerDefaultInfo, D as DefaultBodyType, R as RequestHandler, a as ResponseResolver, c as RequestHandlerOptions } from './HttpResponse-5Sn2vNaJ.js';
|
|
3
3
|
import { Match, Path } from './utils/matching/matchRequestUrl.js';
|
|
4
4
|
|
|
5
5
|
interface ParsedGraphQLQuery {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OperationTypeNode, DocumentNode, GraphQLError } from 'graphql';
|
|
2
|
-
import { g as RequestHandlerDefaultInfo, D as DefaultBodyType, R as RequestHandler, a as ResponseResolver, c as RequestHandlerOptions } from './HttpResponse-
|
|
2
|
+
import { g as RequestHandlerDefaultInfo, D as DefaultBodyType, R as RequestHandler, a as ResponseResolver, c as RequestHandlerOptions } from './HttpResponse-CFPhtDH3.mjs';
|
|
3
3
|
import { Match, Path } from './utils/matching/matchRequestUrl.mjs';
|
|
4
4
|
|
|
5
5
|
interface ParsedGraphQLQuery {
|
|
@@ -183,7 +183,7 @@ declare class HttpResponse extends Response {
|
|
|
183
183
|
*
|
|
184
184
|
* HttpResponse.arrayBuffer(buffer)
|
|
185
185
|
*/
|
|
186
|
-
static arrayBuffer(body?: ArrayBuffer, init?: HttpResponseInit): Response;
|
|
186
|
+
static arrayBuffer(body?: ArrayBuffer | SharedArrayBuffer, init?: HttpResponseInit): Response;
|
|
187
187
|
/**
|
|
188
188
|
* Create a `Response` with a `FormData` body.
|
|
189
189
|
* @example
|
|
@@ -183,7 +183,7 @@ declare class HttpResponse extends Response {
|
|
|
183
183
|
*
|
|
184
184
|
* HttpResponse.arrayBuffer(buffer)
|
|
185
185
|
*/
|
|
186
|
-
static arrayBuffer(body?: ArrayBuffer, init?: HttpResponseInit): Response;
|
|
186
|
+
static arrayBuffer(body?: ArrayBuffer | SharedArrayBuffer, init?: HttpResponseInit): Response;
|
|
187
187
|
/**
|
|
188
188
|
* Create a `Response` with a `FormData` body.
|
|
189
189
|
* @example
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { f as HttpResponse, H as HttpResponseInit, S as StrictRequest, e as StrictResponse } from './HttpResponse-
|
|
1
|
+
export { f as HttpResponse, H as HttpResponseInit, S as StrictRequest, e as StrictResponse } from './HttpResponse-CFPhtDH3.mjs';
|
|
2
2
|
import './typeUtils.mjs';
|
|
3
3
|
import './utils/internal/isIterable.mjs';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { f as HttpResponse, H as HttpResponseInit, S as StrictRequest, e as StrictResponse } from './HttpResponse-
|
|
1
|
+
export { f as HttpResponse, H as HttpResponseInit, S as StrictRequest, e as StrictResponse } from './HttpResponse-5Sn2vNaJ.js';
|
|
2
2
|
import './typeUtils.js';
|
|
3
3
|
import './utils/internal/isIterable.js';
|
package/lib/core/HttpResponse.js
CHANGED
|
@@ -107,6 +107,9 @@ class HttpResponse extends Response {
|
|
|
107
107
|
*/
|
|
108
108
|
static arrayBuffer(body, init) {
|
|
109
109
|
const responseInit = (0, import_decorators.normalizeResponseInit)(init);
|
|
110
|
+
if (!responseInit.headers.has("Content-Type")) {
|
|
111
|
+
responseInit.headers.set("Content-Type", "application/octet-stream");
|
|
112
|
+
}
|
|
110
113
|
if (body && !responseInit.headers.has("Content-Length")) {
|
|
111
114
|
responseInit.headers.set("Content-Length", body.byteLength.toString());
|
|
112
115
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/HttpResponse.ts"],"sourcesContent":["import type { DefaultBodyType, JsonBodyType } from './handlers/RequestHandler'\nimport type { NoInfer } from './typeUtils'\nimport {\n decorateResponse,\n normalizeResponseInit,\n} from './utils/HttpResponse/decorators'\n\nexport interface HttpResponseInit extends ResponseInit {\n type?: ResponseType\n}\n\ndeclare const bodyType: unique symbol\n\nexport interface StrictRequest<BodyType extends DefaultBodyType>\n extends Request {\n json(): Promise<BodyType>\n}\n\n/**\n * Opaque `Response` type that supports strict body type.\n */\nexport interface StrictResponse<BodyType extends DefaultBodyType>\n extends Response {\n readonly [bodyType]: BodyType\n}\n\n/**\n * A drop-in replacement for the standard `Response` class\n * to allow additional features, like mocking the response `Set-Cookie` header.\n *\n * @example\n * new HttpResponse('Hello world', { status: 201 })\n * HttpResponse.json({ name: 'John' })\n * HttpResponse.formData(form)\n *\n * @see {@link https://mswjs.io/docs/api/http-response `HttpResponse` API reference}\n */\nexport class HttpResponse extends Response {\n constructor(body?: BodyInit | null, init?: HttpResponseInit) {\n const responseInit = normalizeResponseInit(init)\n super(body, responseInit)\n decorateResponse(this, responseInit)\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"text/plain\"` body.\n * @example\n * HttpResponse.text('hello world')\n * HttpResponse.text('Error', { status: 500 })\n */\n static text<BodyType extends string>(\n body?: NoInfer<BodyType> | null,\n init?: HttpResponseInit,\n ): StrictResponse<BodyType> {\n const responseInit = normalizeResponseInit(init)\n\n if (!responseInit.headers.has('Content-Type')) {\n responseInit.headers.set('Content-Type', 'text/plain')\n }\n\n // Automatically set the \"Content-Length\" response header\n // for non-empty text responses. This enforces consistency and\n // brings mocked responses closer to production.\n if (!responseInit.headers.has('Content-Length')) {\n responseInit.headers.set(\n 'Content-Length',\n body ? new Blob([body]).size.toString() : '0',\n )\n }\n\n return new HttpResponse(body, responseInit) as StrictResponse<BodyType>\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"application/json\"` body.\n * @example\n * HttpResponse.json({ firstName: 'John' })\n * HttpResponse.json({ error: 'Not Authorized' }, { status: 401 })\n */\n static json<BodyType extends JsonBodyType>(\n body?: NoInfer<BodyType> | null,\n init?: HttpResponseInit,\n ): StrictResponse<BodyType> {\n const responseInit = normalizeResponseInit(init)\n\n if (!responseInit.headers.has('Content-Type')) {\n responseInit.headers.set('Content-Type', 'application/json')\n }\n\n /**\n * @note TypeScript is incorrect here.\n * Stringifying undefined will return undefined.\n */\n const responseText = JSON.stringify(body) as string | undefined\n\n if (!responseInit.headers.has('Content-Length')) {\n responseInit.headers.set(\n 'Content-Length',\n responseText ? new Blob([responseText]).size.toString() : '0',\n )\n }\n\n return new HttpResponse(\n responseText,\n responseInit,\n ) as StrictResponse<BodyType>\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"application/xml\"` body.\n * @example\n * HttpResponse.xml(`<user name=\"John\" />`)\n * HttpResponse.xml(`<article id=\"abc-123\" />`, { status: 201 })\n */\n static xml<BodyType extends string>(\n body?: BodyType | null,\n init?: HttpResponseInit,\n ): Response {\n const responseInit = normalizeResponseInit(init)\n\n if (!responseInit.headers.has('Content-Type')) {\n responseInit.headers.set('Content-Type', 'text/xml')\n }\n\n return new HttpResponse(body, responseInit)\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"text/html\"` body.\n * @example\n * HttpResponse.html(`<p class=\"author\">Jane Doe</p>`)\n * HttpResponse.html(`<main id=\"abc-123\">Main text</main>`, { status: 201 })\n */\n static html<BodyType extends string>(\n body?: BodyType | null,\n init?: HttpResponseInit,\n ): Response {\n const responseInit = normalizeResponseInit(init)\n\n if (!responseInit.headers.has('Content-Type')) {\n responseInit.headers.set('Content-Type', 'text/html')\n }\n\n return new HttpResponse(body, responseInit)\n }\n\n /**\n * Create a `Response` with an `ArrayBuffer` body.\n * @example\n * const buffer = new ArrayBuffer(3)\n * const view = new Uint8Array(buffer)\n * view.set([1, 2, 3])\n *\n * HttpResponse.arrayBuffer(buffer)\n */\n static arrayBuffer(body?: ArrayBuffer
|
|
1
|
+
{"version":3,"sources":["../../src/core/HttpResponse.ts"],"sourcesContent":["import type { DefaultBodyType, JsonBodyType } from './handlers/RequestHandler'\nimport type { NoInfer } from './typeUtils'\nimport {\n decorateResponse,\n normalizeResponseInit,\n} from './utils/HttpResponse/decorators'\n\nexport interface HttpResponseInit extends ResponseInit {\n type?: ResponseType\n}\n\ndeclare const bodyType: unique symbol\n\nexport interface StrictRequest<BodyType extends DefaultBodyType>\n extends Request {\n json(): Promise<BodyType>\n}\n\n/**\n * Opaque `Response` type that supports strict body type.\n */\nexport interface StrictResponse<BodyType extends DefaultBodyType>\n extends Response {\n readonly [bodyType]: BodyType\n}\n\n/**\n * A drop-in replacement for the standard `Response` class\n * to allow additional features, like mocking the response `Set-Cookie` header.\n *\n * @example\n * new HttpResponse('Hello world', { status: 201 })\n * HttpResponse.json({ name: 'John' })\n * HttpResponse.formData(form)\n *\n * @see {@link https://mswjs.io/docs/api/http-response `HttpResponse` API reference}\n */\nexport class HttpResponse extends Response {\n constructor(body?: BodyInit | null, init?: HttpResponseInit) {\n const responseInit = normalizeResponseInit(init)\n super(body, responseInit)\n decorateResponse(this, responseInit)\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"text/plain\"` body.\n * @example\n * HttpResponse.text('hello world')\n * HttpResponse.text('Error', { status: 500 })\n */\n static text<BodyType extends string>(\n body?: NoInfer<BodyType> | null,\n init?: HttpResponseInit,\n ): StrictResponse<BodyType> {\n const responseInit = normalizeResponseInit(init)\n\n if (!responseInit.headers.has('Content-Type')) {\n responseInit.headers.set('Content-Type', 'text/plain')\n }\n\n // Automatically set the \"Content-Length\" response header\n // for non-empty text responses. This enforces consistency and\n // brings mocked responses closer to production.\n if (!responseInit.headers.has('Content-Length')) {\n responseInit.headers.set(\n 'Content-Length',\n body ? new Blob([body]).size.toString() : '0',\n )\n }\n\n return new HttpResponse(body, responseInit) as StrictResponse<BodyType>\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"application/json\"` body.\n * @example\n * HttpResponse.json({ firstName: 'John' })\n * HttpResponse.json({ error: 'Not Authorized' }, { status: 401 })\n */\n static json<BodyType extends JsonBodyType>(\n body?: NoInfer<BodyType> | null,\n init?: HttpResponseInit,\n ): StrictResponse<BodyType> {\n const responseInit = normalizeResponseInit(init)\n\n if (!responseInit.headers.has('Content-Type')) {\n responseInit.headers.set('Content-Type', 'application/json')\n }\n\n /**\n * @note TypeScript is incorrect here.\n * Stringifying undefined will return undefined.\n */\n const responseText = JSON.stringify(body) as string | undefined\n\n if (!responseInit.headers.has('Content-Length')) {\n responseInit.headers.set(\n 'Content-Length',\n responseText ? new Blob([responseText]).size.toString() : '0',\n )\n }\n\n return new HttpResponse(\n responseText,\n responseInit,\n ) as StrictResponse<BodyType>\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"application/xml\"` body.\n * @example\n * HttpResponse.xml(`<user name=\"John\" />`)\n * HttpResponse.xml(`<article id=\"abc-123\" />`, { status: 201 })\n */\n static xml<BodyType extends string>(\n body?: BodyType | null,\n init?: HttpResponseInit,\n ): Response {\n const responseInit = normalizeResponseInit(init)\n\n if (!responseInit.headers.has('Content-Type')) {\n responseInit.headers.set('Content-Type', 'text/xml')\n }\n\n return new HttpResponse(body, responseInit)\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"text/html\"` body.\n * @example\n * HttpResponse.html(`<p class=\"author\">Jane Doe</p>`)\n * HttpResponse.html(`<main id=\"abc-123\">Main text</main>`, { status: 201 })\n */\n static html<BodyType extends string>(\n body?: BodyType | null,\n init?: HttpResponseInit,\n ): Response {\n const responseInit = normalizeResponseInit(init)\n\n if (!responseInit.headers.has('Content-Type')) {\n responseInit.headers.set('Content-Type', 'text/html')\n }\n\n return new HttpResponse(body, responseInit)\n }\n\n /**\n * Create a `Response` with an `ArrayBuffer` body.\n * @example\n * const buffer = new ArrayBuffer(3)\n * const view = new Uint8Array(buffer)\n * view.set([1, 2, 3])\n *\n * HttpResponse.arrayBuffer(buffer)\n */\n static arrayBuffer(\n body?: ArrayBuffer | SharedArrayBuffer,\n init?: HttpResponseInit,\n ): Response {\n const responseInit = normalizeResponseInit(init)\n\n if (!responseInit.headers.has('Content-Type')) {\n responseInit.headers.set('Content-Type', 'application/octet-stream')\n }\n\n if (body && !responseInit.headers.has('Content-Length')) {\n responseInit.headers.set('Content-Length', body.byteLength.toString())\n }\n\n return new HttpResponse(body, responseInit)\n }\n\n /**\n * Create a `Response` with a `FormData` body.\n * @example\n * const data = new FormData()\n * data.set('name', 'Alice')\n *\n * HttpResponse.formData(data)\n */\n static formData(body?: FormData, init?: HttpResponseInit): Response {\n return new HttpResponse(body, normalizeResponseInit(init))\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,wBAGO;AAgCA,MAAM,qBAAqB,SAAS;AAAA,EACzC,YAAY,MAAwB,MAAyB;AAC3D,UAAM,mBAAe,yCAAsB,IAAI;AAC/C,UAAM,MAAM,YAAY;AACxB,4CAAiB,MAAM,YAAY;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAO,KACL,MACA,MAC0B;AAC1B,UAAM,mBAAe,yCAAsB,IAAI;AAE/C,QAAI,CAAC,aAAa,QAAQ,IAAI,cAAc,GAAG;AAC7C,mBAAa,QAAQ,IAAI,gBAAgB,YAAY;AAAA,IACvD;AAKA,QAAI,CAAC,aAAa,QAAQ,IAAI,gBAAgB,GAAG;AAC/C,mBAAa,QAAQ;AAAA,QACnB;AAAA,QACA,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,SAAS,IAAI;AAAA,MAC5C;AAAA,IACF;AAEA,WAAO,IAAI,aAAa,MAAM,YAAY;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAO,KACL,MACA,MAC0B;AAC1B,UAAM,mBAAe,yCAAsB,IAAI;AAE/C,QAAI,CAAC,aAAa,QAAQ,IAAI,cAAc,GAAG;AAC7C,mBAAa,QAAQ,IAAI,gBAAgB,kBAAkB;AAAA,IAC7D;AAMA,UAAM,eAAe,KAAK,UAAU,IAAI;AAExC,QAAI,CAAC,aAAa,QAAQ,IAAI,gBAAgB,GAAG;AAC/C,mBAAa,QAAQ;AAAA,QACnB;AAAA,QACA,eAAe,IAAI,KAAK,CAAC,YAAY,CAAC,EAAE,KAAK,SAAS,IAAI;AAAA,MAC5D;AAAA,IACF;AAEA,WAAO,IAAI;AAAA,MACT;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAO,IACL,MACA,MACU;AACV,UAAM,mBAAe,yCAAsB,IAAI;AAE/C,QAAI,CAAC,aAAa,QAAQ,IAAI,cAAc,GAAG;AAC7C,mBAAa,QAAQ,IAAI,gBAAgB,UAAU;AAAA,IACrD;AAEA,WAAO,IAAI,aAAa,MAAM,YAAY;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAO,KACL,MACA,MACU;AACV,UAAM,mBAAe,yCAAsB,IAAI;AAE/C,QAAI,CAAC,aAAa,QAAQ,IAAI,cAAc,GAAG;AAC7C,mBAAa,QAAQ,IAAI,gBAAgB,WAAW;AAAA,IACtD;AAEA,WAAO,IAAI,aAAa,MAAM,YAAY;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,OAAO,YACL,MACA,MACU;AACV,UAAM,mBAAe,yCAAsB,IAAI;AAE/C,QAAI,CAAC,aAAa,QAAQ,IAAI,cAAc,GAAG;AAC7C,mBAAa,QAAQ,IAAI,gBAAgB,0BAA0B;AAAA,IACrE;AAEA,QAAI,QAAQ,CAAC,aAAa,QAAQ,IAAI,gBAAgB,GAAG;AACvD,mBAAa,QAAQ,IAAI,kBAAkB,KAAK,WAAW,SAAS,CAAC;AAAA,IACvE;AAEA,WAAO,IAAI,aAAa,MAAM,YAAY;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,OAAO,SAAS,MAAiB,MAAmC;AAClE,WAAO,IAAI,aAAa,UAAM,yCAAsB,IAAI,CAAC;AAAA,EAC3D;AACF;","names":[]}
|
|
@@ -87,6 +87,9 @@ class HttpResponse extends Response {
|
|
|
87
87
|
*/
|
|
88
88
|
static arrayBuffer(body, init) {
|
|
89
89
|
const responseInit = normalizeResponseInit(init);
|
|
90
|
+
if (!responseInit.headers.has("Content-Type")) {
|
|
91
|
+
responseInit.headers.set("Content-Type", "application/octet-stream");
|
|
92
|
+
}
|
|
90
93
|
if (body && !responseInit.headers.has("Content-Length")) {
|
|
91
94
|
responseInit.headers.set("Content-Length", body.byteLength.toString());
|
|
92
95
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/HttpResponse.ts"],"sourcesContent":["import type { DefaultBodyType, JsonBodyType } from './handlers/RequestHandler'\nimport type { NoInfer } from './typeUtils'\nimport {\n decorateResponse,\n normalizeResponseInit,\n} from './utils/HttpResponse/decorators'\n\nexport interface HttpResponseInit extends ResponseInit {\n type?: ResponseType\n}\n\ndeclare const bodyType: unique symbol\n\nexport interface StrictRequest<BodyType extends DefaultBodyType>\n extends Request {\n json(): Promise<BodyType>\n}\n\n/**\n * Opaque `Response` type that supports strict body type.\n */\nexport interface StrictResponse<BodyType extends DefaultBodyType>\n extends Response {\n readonly [bodyType]: BodyType\n}\n\n/**\n * A drop-in replacement for the standard `Response` class\n * to allow additional features, like mocking the response `Set-Cookie` header.\n *\n * @example\n * new HttpResponse('Hello world', { status: 201 })\n * HttpResponse.json({ name: 'John' })\n * HttpResponse.formData(form)\n *\n * @see {@link https://mswjs.io/docs/api/http-response `HttpResponse` API reference}\n */\nexport class HttpResponse extends Response {\n constructor(body?: BodyInit | null, init?: HttpResponseInit) {\n const responseInit = normalizeResponseInit(init)\n super(body, responseInit)\n decorateResponse(this, responseInit)\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"text/plain\"` body.\n * @example\n * HttpResponse.text('hello world')\n * HttpResponse.text('Error', { status: 500 })\n */\n static text<BodyType extends string>(\n body?: NoInfer<BodyType> | null,\n init?: HttpResponseInit,\n ): StrictResponse<BodyType> {\n const responseInit = normalizeResponseInit(init)\n\n if (!responseInit.headers.has('Content-Type')) {\n responseInit.headers.set('Content-Type', 'text/plain')\n }\n\n // Automatically set the \"Content-Length\" response header\n // for non-empty text responses. This enforces consistency and\n // brings mocked responses closer to production.\n if (!responseInit.headers.has('Content-Length')) {\n responseInit.headers.set(\n 'Content-Length',\n body ? new Blob([body]).size.toString() : '0',\n )\n }\n\n return new HttpResponse(body, responseInit) as StrictResponse<BodyType>\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"application/json\"` body.\n * @example\n * HttpResponse.json({ firstName: 'John' })\n * HttpResponse.json({ error: 'Not Authorized' }, { status: 401 })\n */\n static json<BodyType extends JsonBodyType>(\n body?: NoInfer<BodyType> | null,\n init?: HttpResponseInit,\n ): StrictResponse<BodyType> {\n const responseInit = normalizeResponseInit(init)\n\n if (!responseInit.headers.has('Content-Type')) {\n responseInit.headers.set('Content-Type', 'application/json')\n }\n\n /**\n * @note TypeScript is incorrect here.\n * Stringifying undefined will return undefined.\n */\n const responseText = JSON.stringify(body) as string | undefined\n\n if (!responseInit.headers.has('Content-Length')) {\n responseInit.headers.set(\n 'Content-Length',\n responseText ? new Blob([responseText]).size.toString() : '0',\n )\n }\n\n return new HttpResponse(\n responseText,\n responseInit,\n ) as StrictResponse<BodyType>\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"application/xml\"` body.\n * @example\n * HttpResponse.xml(`<user name=\"John\" />`)\n * HttpResponse.xml(`<article id=\"abc-123\" />`, { status: 201 })\n */\n static xml<BodyType extends string>(\n body?: BodyType | null,\n init?: HttpResponseInit,\n ): Response {\n const responseInit = normalizeResponseInit(init)\n\n if (!responseInit.headers.has('Content-Type')) {\n responseInit.headers.set('Content-Type', 'text/xml')\n }\n\n return new HttpResponse(body, responseInit)\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"text/html\"` body.\n * @example\n * HttpResponse.html(`<p class=\"author\">Jane Doe</p>`)\n * HttpResponse.html(`<main id=\"abc-123\">Main text</main>`, { status: 201 })\n */\n static html<BodyType extends string>(\n body?: BodyType | null,\n init?: HttpResponseInit,\n ): Response {\n const responseInit = normalizeResponseInit(init)\n\n if (!responseInit.headers.has('Content-Type')) {\n responseInit.headers.set('Content-Type', 'text/html')\n }\n\n return new HttpResponse(body, responseInit)\n }\n\n /**\n * Create a `Response` with an `ArrayBuffer` body.\n * @example\n * const buffer = new ArrayBuffer(3)\n * const view = new Uint8Array(buffer)\n * view.set([1, 2, 3])\n *\n * HttpResponse.arrayBuffer(buffer)\n */\n static arrayBuffer(body?: ArrayBuffer
|
|
1
|
+
{"version":3,"sources":["../../src/core/HttpResponse.ts"],"sourcesContent":["import type { DefaultBodyType, JsonBodyType } from './handlers/RequestHandler'\nimport type { NoInfer } from './typeUtils'\nimport {\n decorateResponse,\n normalizeResponseInit,\n} from './utils/HttpResponse/decorators'\n\nexport interface HttpResponseInit extends ResponseInit {\n type?: ResponseType\n}\n\ndeclare const bodyType: unique symbol\n\nexport interface StrictRequest<BodyType extends DefaultBodyType>\n extends Request {\n json(): Promise<BodyType>\n}\n\n/**\n * Opaque `Response` type that supports strict body type.\n */\nexport interface StrictResponse<BodyType extends DefaultBodyType>\n extends Response {\n readonly [bodyType]: BodyType\n}\n\n/**\n * A drop-in replacement for the standard `Response` class\n * to allow additional features, like mocking the response `Set-Cookie` header.\n *\n * @example\n * new HttpResponse('Hello world', { status: 201 })\n * HttpResponse.json({ name: 'John' })\n * HttpResponse.formData(form)\n *\n * @see {@link https://mswjs.io/docs/api/http-response `HttpResponse` API reference}\n */\nexport class HttpResponse extends Response {\n constructor(body?: BodyInit | null, init?: HttpResponseInit) {\n const responseInit = normalizeResponseInit(init)\n super(body, responseInit)\n decorateResponse(this, responseInit)\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"text/plain\"` body.\n * @example\n * HttpResponse.text('hello world')\n * HttpResponse.text('Error', { status: 500 })\n */\n static text<BodyType extends string>(\n body?: NoInfer<BodyType> | null,\n init?: HttpResponseInit,\n ): StrictResponse<BodyType> {\n const responseInit = normalizeResponseInit(init)\n\n if (!responseInit.headers.has('Content-Type')) {\n responseInit.headers.set('Content-Type', 'text/plain')\n }\n\n // Automatically set the \"Content-Length\" response header\n // for non-empty text responses. This enforces consistency and\n // brings mocked responses closer to production.\n if (!responseInit.headers.has('Content-Length')) {\n responseInit.headers.set(\n 'Content-Length',\n body ? new Blob([body]).size.toString() : '0',\n )\n }\n\n return new HttpResponse(body, responseInit) as StrictResponse<BodyType>\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"application/json\"` body.\n * @example\n * HttpResponse.json({ firstName: 'John' })\n * HttpResponse.json({ error: 'Not Authorized' }, { status: 401 })\n */\n static json<BodyType extends JsonBodyType>(\n body?: NoInfer<BodyType> | null,\n init?: HttpResponseInit,\n ): StrictResponse<BodyType> {\n const responseInit = normalizeResponseInit(init)\n\n if (!responseInit.headers.has('Content-Type')) {\n responseInit.headers.set('Content-Type', 'application/json')\n }\n\n /**\n * @note TypeScript is incorrect here.\n * Stringifying undefined will return undefined.\n */\n const responseText = JSON.stringify(body) as string | undefined\n\n if (!responseInit.headers.has('Content-Length')) {\n responseInit.headers.set(\n 'Content-Length',\n responseText ? new Blob([responseText]).size.toString() : '0',\n )\n }\n\n return new HttpResponse(\n responseText,\n responseInit,\n ) as StrictResponse<BodyType>\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"application/xml\"` body.\n * @example\n * HttpResponse.xml(`<user name=\"John\" />`)\n * HttpResponse.xml(`<article id=\"abc-123\" />`, { status: 201 })\n */\n static xml<BodyType extends string>(\n body?: BodyType | null,\n init?: HttpResponseInit,\n ): Response {\n const responseInit = normalizeResponseInit(init)\n\n if (!responseInit.headers.has('Content-Type')) {\n responseInit.headers.set('Content-Type', 'text/xml')\n }\n\n return new HttpResponse(body, responseInit)\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"text/html\"` body.\n * @example\n * HttpResponse.html(`<p class=\"author\">Jane Doe</p>`)\n * HttpResponse.html(`<main id=\"abc-123\">Main text</main>`, { status: 201 })\n */\n static html<BodyType extends string>(\n body?: BodyType | null,\n init?: HttpResponseInit,\n ): Response {\n const responseInit = normalizeResponseInit(init)\n\n if (!responseInit.headers.has('Content-Type')) {\n responseInit.headers.set('Content-Type', 'text/html')\n }\n\n return new HttpResponse(body, responseInit)\n }\n\n /**\n * Create a `Response` with an `ArrayBuffer` body.\n * @example\n * const buffer = new ArrayBuffer(3)\n * const view = new Uint8Array(buffer)\n * view.set([1, 2, 3])\n *\n * HttpResponse.arrayBuffer(buffer)\n */\n static arrayBuffer(\n body?: ArrayBuffer | SharedArrayBuffer,\n init?: HttpResponseInit,\n ): Response {\n const responseInit = normalizeResponseInit(init)\n\n if (!responseInit.headers.has('Content-Type')) {\n responseInit.headers.set('Content-Type', 'application/octet-stream')\n }\n\n if (body && !responseInit.headers.has('Content-Length')) {\n responseInit.headers.set('Content-Length', body.byteLength.toString())\n }\n\n return new HttpResponse(body, responseInit)\n }\n\n /**\n * Create a `Response` with a `FormData` body.\n * @example\n * const data = new FormData()\n * data.set('name', 'Alice')\n *\n * HttpResponse.formData(data)\n */\n static formData(body?: FormData, init?: HttpResponseInit): Response {\n return new HttpResponse(body, normalizeResponseInit(init))\n }\n}\n"],"mappings":"AAEA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAgCA,MAAM,qBAAqB,SAAS;AAAA,EACzC,YAAY,MAAwB,MAAyB;AAC3D,UAAM,eAAe,sBAAsB,IAAI;AAC/C,UAAM,MAAM,YAAY;AACxB,qBAAiB,MAAM,YAAY;AAAA,EACrC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAO,KACL,MACA,MAC0B;AAC1B,UAAM,eAAe,sBAAsB,IAAI;AAE/C,QAAI,CAAC,aAAa,QAAQ,IAAI,cAAc,GAAG;AAC7C,mBAAa,QAAQ,IAAI,gBAAgB,YAAY;AAAA,IACvD;AAKA,QAAI,CAAC,aAAa,QAAQ,IAAI,gBAAgB,GAAG;AAC/C,mBAAa,QAAQ;AAAA,QACnB;AAAA,QACA,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,SAAS,IAAI;AAAA,MAC5C;AAAA,IACF;AAEA,WAAO,IAAI,aAAa,MAAM,YAAY;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAO,KACL,MACA,MAC0B;AAC1B,UAAM,eAAe,sBAAsB,IAAI;AAE/C,QAAI,CAAC,aAAa,QAAQ,IAAI,cAAc,GAAG;AAC7C,mBAAa,QAAQ,IAAI,gBAAgB,kBAAkB;AAAA,IAC7D;AAMA,UAAM,eAAe,KAAK,UAAU,IAAI;AAExC,QAAI,CAAC,aAAa,QAAQ,IAAI,gBAAgB,GAAG;AAC/C,mBAAa,QAAQ;AAAA,QACnB;AAAA,QACA,eAAe,IAAI,KAAK,CAAC,YAAY,CAAC,EAAE,KAAK,SAAS,IAAI;AAAA,MAC5D;AAAA,IACF;AAEA,WAAO,IAAI;AAAA,MACT;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAO,IACL,MACA,MACU;AACV,UAAM,eAAe,sBAAsB,IAAI;AAE/C,QAAI,CAAC,aAAa,QAAQ,IAAI,cAAc,GAAG;AAC7C,mBAAa,QAAQ,IAAI,gBAAgB,UAAU;AAAA,IACrD;AAEA,WAAO,IAAI,aAAa,MAAM,YAAY;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAO,KACL,MACA,MACU;AACV,UAAM,eAAe,sBAAsB,IAAI;AAE/C,QAAI,CAAC,aAAa,QAAQ,IAAI,cAAc,GAAG;AAC7C,mBAAa,QAAQ,IAAI,gBAAgB,WAAW;AAAA,IACtD;AAEA,WAAO,IAAI,aAAa,MAAM,YAAY;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,OAAO,YACL,MACA,MACU;AACV,UAAM,eAAe,sBAAsB,IAAI;AAE/C,QAAI,CAAC,aAAa,QAAQ,IAAI,cAAc,GAAG;AAC7C,mBAAa,QAAQ,IAAI,gBAAgB,0BAA0B;AAAA,IACrE;AAEA,QAAI,QAAQ,CAAC,aAAa,QAAQ,IAAI,gBAAgB,GAAG;AACvD,mBAAa,QAAQ,IAAI,kBAAkB,KAAK,WAAW,SAAS,CAAC;AAAA,IACvE;AAEA,WAAO,IAAI,aAAa,MAAM,YAAY;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,OAAO,SAAS,MAAiB,MAAmC;AAClE,WAAO,IAAI,aAAa,MAAM,sBAAsB,IAAI,CAAC;AAAA,EAC3D;AACF;","names":[]}
|
package/lib/core/SetupApi.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventMap, Emitter } from 'strict-event-emitter';
|
|
2
|
-
import { R as RequestHandler } from './HttpResponse-
|
|
2
|
+
import { R as RequestHandler } from './HttpResponse-CFPhtDH3.mjs';
|
|
3
3
|
import { LifeCycleEventEmitter } from './sharedOptions.mjs';
|
|
4
4
|
import { Disposable } from './utils/internal/Disposable.mjs';
|
|
5
5
|
import { WebSocketHandler } from './handlers/WebSocketHandler.mjs';
|
package/lib/core/SetupApi.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventMap, Emitter } from 'strict-event-emitter';
|
|
2
|
-
import { R as RequestHandler } from './HttpResponse-
|
|
2
|
+
import { R as RequestHandler } from './HttpResponse-5Sn2vNaJ.js';
|
|
3
3
|
import { LifeCycleEventEmitter } from './sharedOptions.js';
|
|
4
4
|
import { Disposable } from './utils/internal/Disposable.js';
|
|
5
5
|
import { WebSocketHandler } from './handlers/WebSocketHandler.js';
|
package/lib/core/graphql.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DocumentNode } from 'graphql';
|
|
2
|
-
import { c as RequestHandlerOptions, a as ResponseResolver } from './HttpResponse-
|
|
3
|
-
import { a as GraphQLQuery, b as GraphQLVariables, e as GraphQLHandlerNameSelector, G as GraphQLHandler, f as GraphQLResolverExtras, g as GraphQLResponseBody } from './GraphQLHandler-
|
|
2
|
+
import { c as RequestHandlerOptions, a as ResponseResolver } from './HttpResponse-CFPhtDH3.mjs';
|
|
3
|
+
import { a as GraphQLQuery, b as GraphQLVariables, e as GraphQLHandlerNameSelector, G as GraphQLHandler, f as GraphQLResolverExtras, g as GraphQLResponseBody } from './GraphQLHandler-CLv2BIIm.mjs';
|
|
4
4
|
import { Path } from './utils/matching/matchRequestUrl.mjs';
|
|
5
5
|
import './utils/internal/isIterable.mjs';
|
|
6
6
|
import './typeUtils.mjs';
|
package/lib/core/graphql.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DocumentNode } from 'graphql';
|
|
2
|
-
import { c as RequestHandlerOptions, a as ResponseResolver } from './HttpResponse-
|
|
3
|
-
import { a as GraphQLQuery, b as GraphQLVariables, e as GraphQLHandlerNameSelector, G as GraphQLHandler, f as GraphQLResolverExtras, g as GraphQLResponseBody } from './GraphQLHandler-
|
|
2
|
+
import { c as RequestHandlerOptions, a as ResponseResolver } from './HttpResponse-5Sn2vNaJ.js';
|
|
3
|
+
import { a as GraphQLQuery, b as GraphQLVariables, e as GraphQLHandlerNameSelector, G as GraphQLHandler, f as GraphQLResolverExtras, g as GraphQLResponseBody } from './GraphQLHandler-C5CUIS_N.js';
|
|
4
4
|
import { Path } from './utils/matching/matchRequestUrl.js';
|
|
5
5
|
import './utils/internal/isIterable.js';
|
|
6
6
|
import './typeUtils.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'graphql';
|
|
2
|
-
import '../HttpResponse-
|
|
2
|
+
import '../HttpResponse-CFPhtDH3.mjs';
|
|
3
3
|
import '../utils/matching/matchRequestUrl.mjs';
|
|
4
|
-
export { E as ExpectedOperationTypeNode, G as GraphQLHandler, l as GraphQLHandlerInfo, e as GraphQLHandlerNameSelector, d as GraphQLJsonRequestBody, a as GraphQLQuery, c as GraphQLRequestBody, m as GraphQLRequestParsedResult, f as GraphQLResolverExtras, g as GraphQLResponseBody, b as GraphQLVariables, n as isDocumentNode } from '../GraphQLHandler-
|
|
4
|
+
export { E as ExpectedOperationTypeNode, G as GraphQLHandler, l as GraphQLHandlerInfo, e as GraphQLHandlerNameSelector, d as GraphQLJsonRequestBody, a as GraphQLQuery, c as GraphQLRequestBody, m as GraphQLRequestParsedResult, f as GraphQLResolverExtras, g as GraphQLResponseBody, b as GraphQLVariables, n as isDocumentNode } from '../GraphQLHandler-CLv2BIIm.mjs';
|
|
5
5
|
import '../utils/internal/isIterable.mjs';
|
|
6
6
|
import '../typeUtils.mjs';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'graphql';
|
|
2
|
-
import '../HttpResponse-
|
|
2
|
+
import '../HttpResponse-5Sn2vNaJ.js';
|
|
3
3
|
import '../utils/matching/matchRequestUrl.js';
|
|
4
|
-
export { E as ExpectedOperationTypeNode, G as GraphQLHandler, l as GraphQLHandlerInfo, e as GraphQLHandlerNameSelector, d as GraphQLJsonRequestBody, a as GraphQLQuery, c as GraphQLRequestBody, m as GraphQLRequestParsedResult, f as GraphQLResolverExtras, g as GraphQLResponseBody, b as GraphQLVariables, n as isDocumentNode } from '../GraphQLHandler-
|
|
4
|
+
export { E as ExpectedOperationTypeNode, G as GraphQLHandler, l as GraphQLHandlerInfo, e as GraphQLHandlerNameSelector, d as GraphQLJsonRequestBody, a as GraphQLQuery, c as GraphQLRequestBody, m as GraphQLRequestParsedResult, f as GraphQLResolverExtras, g as GraphQLResponseBody, b as GraphQLVariables, n as isDocumentNode } from '../GraphQLHandler-C5CUIS_N.js';
|
|
5
5
|
import '../utils/internal/isIterable.js';
|
|
6
6
|
import '../typeUtils.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as RequestHandlerDefaultInfo, R as RequestHandler, a as ResponseResolver, c as RequestHandlerOptions, h as ResponseResolutionContext } from '../HttpResponse-
|
|
1
|
+
import { g as RequestHandlerDefaultInfo, R as RequestHandler, a as ResponseResolver, c as RequestHandlerOptions, h as ResponseResolutionContext } from '../HttpResponse-CFPhtDH3.mjs';
|
|
2
2
|
import { Path, Match, PathParams } from '../utils/matching/matchRequestUrl.mjs';
|
|
3
3
|
import '../utils/internal/isIterable.mjs';
|
|
4
4
|
import '../typeUtils.mjs';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as RequestHandlerDefaultInfo, R as RequestHandler, a as ResponseResolver, c as RequestHandlerOptions, h as ResponseResolutionContext } from '../HttpResponse-
|
|
1
|
+
import { g as RequestHandlerDefaultInfo, R as RequestHandler, a as ResponseResolver, c as RequestHandlerOptions, h as ResponseResolutionContext } from '../HttpResponse-5Sn2vNaJ.js';
|
|
2
2
|
import { Path, Match, PathParams } from '../utils/matching/matchRequestUrl.js';
|
|
3
3
|
import '../utils/internal/isIterable.js';
|
|
4
4
|
import '../typeUtils.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import '../utils/internal/isIterable.mjs';
|
|
2
|
-
export { A as AsyncResponseResolverReturnType, D as DefaultBodyType, d as DefaultRequestMultipartBody, J as JsonBodyType, M as MaybeAsyncResponseResolverReturnType, R as RequestHandler, m as RequestHandlerArgs, g as RequestHandlerDefaultInfo, n as RequestHandlerExecutionResult, k as RequestHandlerInternalInfo, c as RequestHandlerOptions, a as ResponseResolver, l as ResponseResolverInfo, b as ResponseResolverReturnType } from '../HttpResponse-
|
|
2
|
+
export { A as AsyncResponseResolverReturnType, D as DefaultBodyType, d as DefaultRequestMultipartBody, J as JsonBodyType, M as MaybeAsyncResponseResolverReturnType, R as RequestHandler, m as RequestHandlerArgs, g as RequestHandlerDefaultInfo, n as RequestHandlerExecutionResult, k as RequestHandlerInternalInfo, c as RequestHandlerOptions, a as ResponseResolver, l as ResponseResolverInfo, b as ResponseResolverReturnType } from '../HttpResponse-CFPhtDH3.mjs';
|
|
3
3
|
import '../typeUtils.mjs';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import '../utils/internal/isIterable.js';
|
|
2
|
-
export { A as AsyncResponseResolverReturnType, D as DefaultBodyType, d as DefaultRequestMultipartBody, J as JsonBodyType, M as MaybeAsyncResponseResolverReturnType, R as RequestHandler, m as RequestHandlerArgs, g as RequestHandlerDefaultInfo, n as RequestHandlerExecutionResult, k as RequestHandlerInternalInfo, c as RequestHandlerOptions, a as ResponseResolver, l as ResponseResolverInfo, b as ResponseResolverReturnType } from '../HttpResponse-
|
|
2
|
+
export { A as AsyncResponseResolverReturnType, D as DefaultBodyType, d as DefaultRequestMultipartBody, J as JsonBodyType, M as MaybeAsyncResponseResolverReturnType, R as RequestHandler, m as RequestHandlerArgs, g as RequestHandlerDefaultInfo, n as RequestHandlerExecutionResult, k as RequestHandlerInternalInfo, c as RequestHandlerOptions, a as ResponseResolver, l as ResponseResolverInfo, b as ResponseResolverReturnType } from '../HttpResponse-5Sn2vNaJ.js';
|
|
3
3
|
import '../typeUtils.js';
|
package/lib/core/http.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DefaultBodyType, c as RequestHandlerOptions, a as ResponseResolver } from './HttpResponse-
|
|
1
|
+
import { D as DefaultBodyType, c as RequestHandlerOptions, a as ResponseResolver } from './HttpResponse-CFPhtDH3.mjs';
|
|
2
2
|
import { HttpHandler, HttpRequestResolverExtras } from './handlers/HttpHandler.mjs';
|
|
3
3
|
import { PathParams, Path } from './utils/matching/matchRequestUrl.mjs';
|
|
4
4
|
import './utils/internal/isIterable.mjs';
|
package/lib/core/http.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DefaultBodyType, c as RequestHandlerOptions, a as ResponseResolver } from './HttpResponse-
|
|
1
|
+
import { D as DefaultBodyType, c as RequestHandlerOptions, a as ResponseResolver } from './HttpResponse-5Sn2vNaJ.js';
|
|
2
2
|
import { HttpHandler, HttpRequestResolverExtras } from './handlers/HttpHandler.js';
|
|
3
3
|
import { PathParams, Path } from './utils/matching/matchRequestUrl.js';
|
|
4
4
|
import './utils/internal/isIterable.js';
|
package/lib/core/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { SetupApi } from './SetupApi.mjs';
|
|
2
|
-
export { A as AsyncResponseResolverReturnType, D as DefaultBodyType, d as DefaultRequestMultipartBody, f as HttpResponse, H as HttpResponseInit, J as JsonBodyType, R as RequestHandler, c as RequestHandlerOptions, a as ResponseResolver, b as ResponseResolverReturnType, S as StrictRequest, e as StrictResponse } from './HttpResponse-
|
|
2
|
+
export { A as AsyncResponseResolverReturnType, D as DefaultBodyType, d as DefaultRequestMultipartBody, f as HttpResponse, H as HttpResponseInit, J as JsonBodyType, R as RequestHandler, c as RequestHandlerOptions, a as ResponseResolver, b as ResponseResolverReturnType, S as StrictRequest, e as StrictResponse } from './HttpResponse-CFPhtDH3.mjs';
|
|
3
3
|
export { HttpRequestHandler, HttpResponseResolver, http } from './http.mjs';
|
|
4
4
|
export { HttpHandler, HttpMethods, HttpRequestParsedResult, RequestQuery } from './handlers/HttpHandler.mjs';
|
|
5
5
|
export { GraphQLRequestHandler, GraphQLResponseResolver, graphql } from './graphql.mjs';
|
|
6
|
-
export { G as GraphQLHandler, d as GraphQLJsonRequestBody, a as GraphQLQuery, c as GraphQLRequestBody, b as GraphQLVariables, P as ParsedGraphQLRequest } from './GraphQLHandler-
|
|
6
|
+
export { G as GraphQLHandler, d as GraphQLJsonRequestBody, a as GraphQLQuery, c as GraphQLRequestBody, b as GraphQLVariables, P as ParsedGraphQLRequest } from './GraphQLHandler-CLv2BIIm.mjs';
|
|
7
7
|
export { WebSocketEventListener, WebSocketLink, ws } from './ws.mjs';
|
|
8
8
|
export { WebSocketHandler, WebSocketHandlerConnection, WebSocketHandlerEventMap } from './handlers/WebSocketHandler.mjs';
|
|
9
9
|
export { Match, Path, PathParams, matchRequestUrl } from './utils/matching/matchRequestUrl.mjs';
|
package/lib/core/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { SetupApi } from './SetupApi.js';
|
|
2
|
-
export { A as AsyncResponseResolverReturnType, D as DefaultBodyType, d as DefaultRequestMultipartBody, f as HttpResponse, H as HttpResponseInit, J as JsonBodyType, R as RequestHandler, c as RequestHandlerOptions, a as ResponseResolver, b as ResponseResolverReturnType, S as StrictRequest, e as StrictResponse } from './HttpResponse-
|
|
2
|
+
export { A as AsyncResponseResolverReturnType, D as DefaultBodyType, d as DefaultRequestMultipartBody, f as HttpResponse, H as HttpResponseInit, J as JsonBodyType, R as RequestHandler, c as RequestHandlerOptions, a as ResponseResolver, b as ResponseResolverReturnType, S as StrictRequest, e as StrictResponse } from './HttpResponse-5Sn2vNaJ.js';
|
|
3
3
|
export { HttpRequestHandler, HttpResponseResolver, http } from './http.js';
|
|
4
4
|
export { HttpHandler, HttpMethods, HttpRequestParsedResult, RequestQuery } from './handlers/HttpHandler.js';
|
|
5
5
|
export { GraphQLRequestHandler, GraphQLResponseResolver, graphql } from './graphql.js';
|
|
6
|
-
export { G as GraphQLHandler, d as GraphQLJsonRequestBody, a as GraphQLQuery, c as GraphQLRequestBody, b as GraphQLVariables, P as ParsedGraphQLRequest } from './GraphQLHandler-
|
|
6
|
+
export { G as GraphQLHandler, d as GraphQLJsonRequestBody, a as GraphQLQuery, c as GraphQLRequestBody, b as GraphQLVariables, P as ParsedGraphQLRequest } from './GraphQLHandler-C5CUIS_N.js';
|
|
7
7
|
export { WebSocketEventListener, WebSocketLink, ws } from './ws.js';
|
|
8
8
|
export { WebSocketHandler, WebSocketHandlerConnection, WebSocketHandlerEventMap } from './handlers/WebSocketHandler.js';
|
|
9
9
|
export { Match, Path, PathParams, matchRequestUrl } from './utils/matching/matchRequestUrl.js';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { i as HandlersExecutionResult, h as ResponseResolutionContext, j as executeHandlers } from '../HttpResponse-
|
|
1
|
+
export { i as HandlersExecutionResult, h as ResponseResolutionContext, j as executeHandlers } from '../HttpResponse-CFPhtDH3.mjs';
|
|
2
2
|
import './internal/isIterable.mjs';
|
|
3
3
|
import '../typeUtils.mjs';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { i as HandlersExecutionResult, h as ResponseResolutionContext, j as executeHandlers } from '../HttpResponse-
|
|
1
|
+
export { i as HandlersExecutionResult, h as ResponseResolutionContext, j as executeHandlers } from '../HttpResponse-5Sn2vNaJ.js';
|
|
2
2
|
import './internal/isIterable.js';
|
|
3
3
|
import '../typeUtils.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Emitter } from 'strict-event-emitter';
|
|
2
2
|
import { SharedOptions, LifeCycleEventsMap } from '../sharedOptions.mjs';
|
|
3
3
|
import { RequiredDeep } from '../typeUtils.mjs';
|
|
4
|
-
import { i as HandlersExecutionResult, R as RequestHandler } from '../HttpResponse-
|
|
4
|
+
import { i as HandlersExecutionResult, R as RequestHandler } from '../HttpResponse-CFPhtDH3.mjs';
|
|
5
5
|
import './request/onUnhandledRequest.mjs';
|
|
6
6
|
import './internal/isIterable.mjs';
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Emitter } from 'strict-event-emitter';
|
|
2
2
|
import { SharedOptions, LifeCycleEventsMap } from '../sharedOptions.js';
|
|
3
3
|
import { RequiredDeep } from '../typeUtils.js';
|
|
4
|
-
import { i as HandlersExecutionResult, R as RequestHandler } from '../HttpResponse-
|
|
4
|
+
import { i as HandlersExecutionResult, R as RequestHandler } from '../HttpResponse-5Sn2vNaJ.js';
|
|
5
5
|
import './request/onUnhandledRequest.js';
|
|
6
6
|
import './internal/isIterable.js';
|
|
7
7
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HandlerKind } from '../../handlers/common.mjs';
|
|
2
|
-
import { R as RequestHandler } from '../../HttpResponse-
|
|
2
|
+
import { R as RequestHandler } from '../../HttpResponse-CFPhtDH3.mjs';
|
|
3
3
|
import { WebSocketHandler } from '../../handlers/WebSocketHandler.mjs';
|
|
4
4
|
import './isIterable.mjs';
|
|
5
5
|
import '../../typeUtils.mjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HandlerKind } from '../../handlers/common.js';
|
|
2
|
-
import { R as RequestHandler } from '../../HttpResponse-
|
|
2
|
+
import { R as RequestHandler } from '../../HttpResponse-5Sn2vNaJ.js';
|
|
3
3
|
import { WebSocketHandler } from '../../handlers/WebSocketHandler.js';
|
|
4
4
|
import './isIterable.js';
|
|
5
5
|
import '../../typeUtils.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'graphql';
|
|
2
|
-
export { j as GraphQLMultipartRequestBody, i as GraphQLParsedOperationsMap, h as ParsedGraphQLQuery, P as ParsedGraphQLRequest, p as parseDocumentNode, k as parseGraphQLRequest } from '../../GraphQLHandler-
|
|
3
|
-
import '../../HttpResponse-
|
|
2
|
+
export { j as GraphQLMultipartRequestBody, i as GraphQLParsedOperationsMap, h as ParsedGraphQLQuery, P as ParsedGraphQLRequest, p as parseDocumentNode, k as parseGraphQLRequest } from '../../GraphQLHandler-CLv2BIIm.mjs';
|
|
3
|
+
import '../../HttpResponse-CFPhtDH3.mjs';
|
|
4
4
|
import './isIterable.mjs';
|
|
5
5
|
import '../../typeUtils.mjs';
|
|
6
6
|
import '../matching/matchRequestUrl.mjs';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'graphql';
|
|
2
|
-
export { j as GraphQLMultipartRequestBody, i as GraphQLParsedOperationsMap, h as ParsedGraphQLQuery, P as ParsedGraphQLRequest, p as parseDocumentNode, k as parseGraphQLRequest } from '../../GraphQLHandler-
|
|
3
|
-
import '../../HttpResponse-
|
|
2
|
+
export { j as GraphQLMultipartRequestBody, i as GraphQLParsedOperationsMap, h as ParsedGraphQLQuery, P as ParsedGraphQLRequest, p as parseDocumentNode, k as parseGraphQLRequest } from '../../GraphQLHandler-C5CUIS_N.js';
|
|
3
|
+
import '../../HttpResponse-5Sn2vNaJ.js';
|
|
4
4
|
import './isIterable.js';
|
|
5
5
|
import '../../typeUtils.js';
|
|
6
6
|
import '../matching/matchRequestUrl.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RequestHandler, g as RequestHandlerDefaultInfo, c as RequestHandlerOptions } from '../../HttpResponse-
|
|
1
|
+
import { R as RequestHandler, g as RequestHandlerDefaultInfo, c as RequestHandlerOptions } from '../../HttpResponse-CFPhtDH3.mjs';
|
|
2
2
|
import './isIterable.mjs';
|
|
3
3
|
import '../../typeUtils.mjs';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as RequestHandler, g as RequestHandlerDefaultInfo, c as RequestHandlerOptions } from '../../HttpResponse-
|
|
1
|
+
import { R as RequestHandler, g as RequestHandlerDefaultInfo, c as RequestHandlerOptions } from '../../HttpResponse-5Sn2vNaJ.js';
|
|
2
2
|
import './isIterable.js';
|
|
3
3
|
import '../../typeUtils.js';
|
|
4
4
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WebSocketConnectionData } from '@mswjs/interceptors/lib/browser/interceptors/WebSocket';
|
|
2
|
-
import { R as RequestHandler } from '../HttpResponse-
|
|
2
|
+
import { R as RequestHandler } from '../HttpResponse-CFPhtDH3.mjs';
|
|
3
3
|
import { WebSocketHandler } from '../handlers/WebSocketHandler.mjs';
|
|
4
4
|
import { UnhandledRequestStrategy } from '../utils/request/onUnhandledRequest.mjs';
|
|
5
5
|
import '../utils/internal/isIterable.mjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WebSocketConnectionData } from '@mswjs/interceptors/lib/browser/interceptors/WebSocket';
|
|
2
|
-
import { R as RequestHandler } from '../HttpResponse-
|
|
2
|
+
import { R as RequestHandler } from '../HttpResponse-5Sn2vNaJ.js';
|
|
3
3
|
import { WebSocketHandler } from '../handlers/WebSocketHandler.js';
|
|
4
4
|
import { UnhandledRequestStrategy } from '../utils/request/onUnhandledRequest.js';
|
|
5
5
|
import '../utils/internal/isIterable.js';
|
package/lib/iife/index.js
CHANGED
|
@@ -28744,6 +28744,9 @@ Read more: https://mswjs.io/docs/getting-started/mocks`;
|
|
|
28744
28744
|
*/
|
|
28745
28745
|
static arrayBuffer(body, init) {
|
|
28746
28746
|
const responseInit = normalizeResponseInit(init);
|
|
28747
|
+
if (!responseInit.headers.has("Content-Type")) {
|
|
28748
|
+
responseInit.headers.set("Content-Type", "application/octet-stream");
|
|
28749
|
+
}
|
|
28747
28750
|
if (body && !responseInit.headers.has("Content-Length")) {
|
|
28748
28751
|
responseInit.headers.set("Content-Length", body.byteLength.toString());
|
|
28749
28752
|
}
|