Spaces:
Paused
Paused
Include updated package-lock.json (part 6)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- node_modules/msw/lib/core/isCommonAssetRequest.d.mts +20 -0
- node_modules/msw/lib/core/isCommonAssetRequest.d.ts +20 -0
- node_modules/msw/lib/core/isCommonAssetRequest.js +42 -0
- node_modules/msw/lib/core/isCommonAssetRequest.js.map +1 -0
- node_modules/msw/lib/core/isCommonAssetRequest.mjs +22 -0
- node_modules/msw/lib/core/isCommonAssetRequest.mjs.map +1 -0
- node_modules/msw/lib/core/on-unhandled-frame-BBR-P3kV.d.ts +56 -0
- node_modules/msw/lib/core/on-unhandled-frame-Cr1KOZ0I.d.mts +56 -0
- node_modules/msw/lib/core/passthrough.d.mts +24 -0
- node_modules/msw/lib/core/passthrough.d.ts +24 -0
- node_modules/msw/lib/core/passthrough.js +33 -0
- node_modules/msw/lib/core/passthrough.js.map +1 -0
- node_modules/msw/lib/core/passthrough.mjs +13 -0
- node_modules/msw/lib/core/passthrough.mjs.map +1 -0
- node_modules/msw/lib/core/sharedOptions.d.mts +68 -0
- node_modules/msw/lib/core/sharedOptions.d.ts +68 -0
- node_modules/msw/lib/core/sharedOptions.js +17 -0
- node_modules/msw/lib/core/sharedOptions.js.map +1 -0
- node_modules/msw/lib/core/sharedOptions.mjs +1 -0
- node_modules/msw/lib/core/sharedOptions.mjs.map +1 -0
- node_modules/msw/lib/core/sse.d.mts +102 -0
- node_modules/msw/lib/core/sse.d.ts +102 -0
- node_modules/msw/lib/core/sse.js +667 -0
- node_modules/msw/lib/core/sse.js.map +1 -0
- node_modules/msw/lib/core/sse.mjs +649 -0
- node_modules/msw/lib/core/sse.mjs.map +1 -0
- node_modules/msw/lib/core/typeUtils.d.mts +12 -0
- node_modules/msw/lib/core/typeUtils.d.ts +12 -0
- node_modules/msw/lib/core/typeUtils.js +17 -0
- node_modules/msw/lib/core/typeUtils.js.map +1 -0
- node_modules/msw/lib/core/typeUtils.mjs +1 -0
- node_modules/msw/lib/core/typeUtils.mjs.map +1 -0
- node_modules/msw/lib/core/utils/HttpResponse/decorators.d.mts +17 -0
- node_modules/msw/lib/core/utils/HttpResponse/decorators.d.ts +17 -0
- node_modules/msw/lib/core/utils/HttpResponse/decorators.js +71 -0
- node_modules/msw/lib/core/utils/HttpResponse/decorators.js.map +1 -0
- node_modules/msw/lib/core/utils/HttpResponse/decorators.mjs +41 -0
- node_modules/msw/lib/core/utils/HttpResponse/decorators.mjs.map +1 -0
- node_modules/msw/lib/core/utils/cookieStore.d.mts +13 -0
- node_modules/msw/lib/core/utils/cookieStore.d.ts +13 -0
- node_modules/msw/lib/core/utils/cookieStore.js +90 -0
- node_modules/msw/lib/core/utils/cookieStore.js.map +1 -0
- node_modules/msw/lib/core/utils/cookieStore.mjs +74 -0
- node_modules/msw/lib/core/utils/cookieStore.mjs.map +1 -0
- node_modules/msw/lib/core/utils/executeHandlers.d.mts +6 -0
- node_modules/msw/lib/core/utils/executeHandlers.d.ts +6 -0
- node_modules/msw/lib/core/utils/executeHandlers.js +51 -0
- node_modules/msw/lib/core/utils/executeHandlers.js.map +1 -0
- node_modules/msw/lib/core/utils/executeHandlers.mjs +31 -0
- node_modules/msw/lib/core/utils/executeHandlers.mjs.map +1 -0
node_modules/msw/lib/core/isCommonAssetRequest.d.mts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Determines if the given request is a static asset request.
|
| 3 |
+
* Useful when deciding which unhandled requests to ignore.
|
| 4 |
+
* @note Despite being ignored, you can still intercept and mock
|
| 5 |
+
* static assets by creating request handlers for them.
|
| 6 |
+
*
|
| 7 |
+
* @example
|
| 8 |
+
* import { isCommonAssetRequest } from 'msw'
|
| 9 |
+
*
|
| 10 |
+
* await worker.start({
|
| 11 |
+
* onUnhandledRequest(request, print) {
|
| 12 |
+
* if (!isCommonAssetRequest(request)) {
|
| 13 |
+
* print.warning()
|
| 14 |
+
* }
|
| 15 |
+
* }
|
| 16 |
+
* })
|
| 17 |
+
*/
|
| 18 |
+
declare function isCommonAssetRequest(request: Request): boolean;
|
| 19 |
+
|
| 20 |
+
export { isCommonAssetRequest };
|
node_modules/msw/lib/core/isCommonAssetRequest.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Determines if the given request is a static asset request.
|
| 3 |
+
* Useful when deciding which unhandled requests to ignore.
|
| 4 |
+
* @note Despite being ignored, you can still intercept and mock
|
| 5 |
+
* static assets by creating request handlers for them.
|
| 6 |
+
*
|
| 7 |
+
* @example
|
| 8 |
+
* import { isCommonAssetRequest } from 'msw'
|
| 9 |
+
*
|
| 10 |
+
* await worker.start({
|
| 11 |
+
* onUnhandledRequest(request, print) {
|
| 12 |
+
* if (!isCommonAssetRequest(request)) {
|
| 13 |
+
* print.warning()
|
| 14 |
+
* }
|
| 15 |
+
* }
|
| 16 |
+
* })
|
| 17 |
+
*/
|
| 18 |
+
declare function isCommonAssetRequest(request: Request): boolean;
|
| 19 |
+
|
| 20 |
+
export { isCommonAssetRequest };
|
node_modules/msw/lib/core/isCommonAssetRequest.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __defProp = Object.defineProperty;
|
| 3 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
| 4 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
| 5 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
| 6 |
+
var __export = (target, all) => {
|
| 7 |
+
for (var name in all)
|
| 8 |
+
__defProp(target, name, { get: all[name], enumerable: true });
|
| 9 |
+
};
|
| 10 |
+
var __copyProps = (to, from, except, desc) => {
|
| 11 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
| 12 |
+
for (let key of __getOwnPropNames(from))
|
| 13 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
| 14 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
| 15 |
+
}
|
| 16 |
+
return to;
|
| 17 |
+
};
|
| 18 |
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
| 19 |
+
var isCommonAssetRequest_exports = {};
|
| 20 |
+
__export(isCommonAssetRequest_exports, {
|
| 21 |
+
isCommonAssetRequest: () => isCommonAssetRequest
|
| 22 |
+
});
|
| 23 |
+
module.exports = __toCommonJS(isCommonAssetRequest_exports);
|
| 24 |
+
function isCommonAssetRequest(request) {
|
| 25 |
+
const url = new URL(request.url);
|
| 26 |
+
if (url.protocol === "file:") {
|
| 27 |
+
return true;
|
| 28 |
+
}
|
| 29 |
+
if (/(fonts\.googleapis\.com)/.test(url.hostname)) {
|
| 30 |
+
return true;
|
| 31 |
+
}
|
| 32 |
+
if (/node_modules/.test(url.pathname)) {
|
| 33 |
+
return true;
|
| 34 |
+
}
|
| 35 |
+
if (url.pathname.includes("@vite")) {
|
| 36 |
+
return true;
|
| 37 |
+
}
|
| 38 |
+
return /\.(s?css|less|m?jsx?|m?tsx?|html|ttf|otf|woff|woff2|eot|gif|jpe?g|png|avif|webp|svg|mp4|webm|ogg|mov|mp3|wav|ogg|flac|aac|pdf|txt|csv|json|xml|md|zip|tar|gz|rar|7z)$/i.test(
|
| 39 |
+
url.pathname
|
| 40 |
+
);
|
| 41 |
+
}
|
| 42 |
+
//# sourceMappingURL=isCommonAssetRequest.js.map
|
node_modules/msw/lib/core/isCommonAssetRequest.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../src/core/isCommonAssetRequest.ts"],"sourcesContent":["/**\n * Determines if the given request is a static asset request.\n * Useful when deciding which unhandled requests to ignore.\n * @note Despite being ignored, you can still intercept and mock\n * static assets by creating request handlers for them.\n *\n * @example\n * import { isCommonAssetRequest } from 'msw'\n *\n * await worker.start({\n * onUnhandledRequest(request, print) {\n * if (!isCommonAssetRequest(request)) {\n * print.warning()\n * }\n * }\n * })\n */\nexport function isCommonAssetRequest(request: Request): boolean {\n const url = new URL(request.url)\n\n // Ignore certain protocols.\n if (url.protocol === 'file:') {\n return true\n }\n\n // Ignore static assets hosts.\n if (/(fonts\\.googleapis\\.com)/.test(url.hostname)) {\n return true\n }\n\n // Ignore node modules served over HTTP.\n if (/node_modules/.test(url.pathname)) {\n return true\n }\n\n // Ignore internal Vite requests, like \"/@vite/client\".\n if (url.pathname.includes('@vite')) {\n return true\n }\n\n // Ignore common static assets.\n return /\\.(s?css|less|m?jsx?|m?tsx?|html|ttf|otf|woff|woff2|eot|gif|jpe?g|png|avif|webp|svg|mp4|webm|ogg|mov|mp3|wav|ogg|flac|aac|pdf|txt|csv|json|xml|md|zip|tar|gz|rar|7z)$/i.test(\n url.pathname,\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBO,SAAS,qBAAqB,SAA2B;AAC9D,QAAM,MAAM,IAAI,IAAI,QAAQ,GAAG;AAG/B,MAAI,IAAI,aAAa,SAAS;AAC5B,WAAO;AAAA,EACT;AAGA,MAAI,2BAA2B,KAAK,IAAI,QAAQ,GAAG;AACjD,WAAO;AAAA,EACT;AAGA,MAAI,eAAe,KAAK,IAAI,QAAQ,GAAG;AACrC,WAAO;AAAA,EACT;AAGA,MAAI,IAAI,SAAS,SAAS,OAAO,GAAG;AAClC,WAAO;AAAA,EACT;AAGA,SAAO,yKAAyK;AAAA,IAC9K,IAAI;AAAA,EACN;AACF;","names":[]}
|
node_modules/msw/lib/core/isCommonAssetRequest.mjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function isCommonAssetRequest(request) {
|
| 2 |
+
const url = new URL(request.url);
|
| 3 |
+
if (url.protocol === "file:") {
|
| 4 |
+
return true;
|
| 5 |
+
}
|
| 6 |
+
if (/(fonts\.googleapis\.com)/.test(url.hostname)) {
|
| 7 |
+
return true;
|
| 8 |
+
}
|
| 9 |
+
if (/node_modules/.test(url.pathname)) {
|
| 10 |
+
return true;
|
| 11 |
+
}
|
| 12 |
+
if (url.pathname.includes("@vite")) {
|
| 13 |
+
return true;
|
| 14 |
+
}
|
| 15 |
+
return /\.(s?css|less|m?jsx?|m?tsx?|html|ttf|otf|woff|woff2|eot|gif|jpe?g|png|avif|webp|svg|mp4|webm|ogg|mov|mp3|wav|ogg|flac|aac|pdf|txt|csv|json|xml|md|zip|tar|gz|rar|7z)$/i.test(
|
| 16 |
+
url.pathname
|
| 17 |
+
);
|
| 18 |
+
}
|
| 19 |
+
export {
|
| 20 |
+
isCommonAssetRequest
|
| 21 |
+
};
|
| 22 |
+
//# sourceMappingURL=isCommonAssetRequest.mjs.map
|
node_modules/msw/lib/core/isCommonAssetRequest.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../src/core/isCommonAssetRequest.ts"],"sourcesContent":["/**\n * Determines if the given request is a static asset request.\n * Useful when deciding which unhandled requests to ignore.\n * @note Despite being ignored, you can still intercept and mock\n * static assets by creating request handlers for them.\n *\n * @example\n * import { isCommonAssetRequest } from 'msw'\n *\n * await worker.start({\n * onUnhandledRequest(request, print) {\n * if (!isCommonAssetRequest(request)) {\n * print.warning()\n * }\n * }\n * })\n */\nexport function isCommonAssetRequest(request: Request): boolean {\n const url = new URL(request.url)\n\n // Ignore certain protocols.\n if (url.protocol === 'file:') {\n return true\n }\n\n // Ignore static assets hosts.\n if (/(fonts\\.googleapis\\.com)/.test(url.hostname)) {\n return true\n }\n\n // Ignore node modules served over HTTP.\n if (/node_modules/.test(url.pathname)) {\n return true\n }\n\n // Ignore internal Vite requests, like \"/@vite/client\".\n if (url.pathname.includes('@vite')) {\n return true\n }\n\n // Ignore common static assets.\n return /\\.(s?css|less|m?jsx?|m?tsx?|html|ttf|otf|woff|woff2|eot|gif|jpe?g|png|avif|webp|svg|mp4|webm|ogg|mov|mp3|wav|ogg|flac|aac|pdf|txt|csv|json|xml|md|zip|tar|gz|rar|7z)$/i.test(\n url.pathname,\n )\n}\n"],"mappings":"AAiBO,SAAS,qBAAqB,SAA2B;AAC9D,QAAM,MAAM,IAAI,IAAI,QAAQ,GAAG;AAG/B,MAAI,IAAI,aAAa,SAAS;AAC5B,WAAO;AAAA,EACT;AAGA,MAAI,2BAA2B,KAAK,IAAI,QAAQ,GAAG;AACjD,WAAO;AAAA,EACT;AAGA,MAAI,eAAe,KAAK,IAAI,QAAQ,GAAG;AACrC,WAAO;AAAA,EACT;AAGA,MAAI,IAAI,SAAS,SAAS,OAAO,GAAG;AAClC,WAAO;AAAA,EACT;AAGA,SAAO,yKAAyK;AAAA,IAC9K,IAAI;AAAA,EACN;AACF;","names":[]}
|
node_modules/msw/lib/core/on-unhandled-frame-BBR-P3kV.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { DefaultEventMap, Emitter } from 'rettime';
|
| 2 |
+
import { HandlersController, AnyHandler } from './experimental/handlers-controller.js';
|
| 3 |
+
|
| 4 |
+
type AnyNetworkFrame = NetworkFrame<string, unknown, any>;
|
| 5 |
+
type ExtractFrameEvents<Frame> = Frame extends NetworkFrame<any, any, infer Events> ? Events : never;
|
| 6 |
+
interface NetworkFrameResolutionContext {
|
| 7 |
+
baseUrl?: string | URL;
|
| 8 |
+
quiet?: boolean;
|
| 9 |
+
}
|
| 10 |
+
/**
|
| 11 |
+
* The base for the network frames. Extend this abstract class
|
| 12 |
+
* to implement custom network frames.
|
| 13 |
+
*/
|
| 14 |
+
declare abstract class NetworkFrame<Protocol extends string, Data, Events extends DefaultEventMap> {
|
| 15 |
+
readonly protocol: Protocol;
|
| 16 |
+
readonly data: Data;
|
| 17 |
+
events: Emitter<Events>;
|
| 18 |
+
constructor(protocol: Protocol, data: Data);
|
| 19 |
+
abstract getHandlers(controller: HandlersController): Array<AnyHandler>;
|
| 20 |
+
/**
|
| 21 |
+
* Resolve the current frame against the given list of handlers.
|
| 22 |
+
* Optionally, use a custom resolution context to control behaviors
|
| 23 |
+
* like `baseUrl`.
|
| 24 |
+
*
|
| 25 |
+
* Returns `true` if the frame was handled, `false` if it wasn't, and `null`
|
| 26 |
+
* if its handling was skipped (e.g. the frame was bypassed).
|
| 27 |
+
*/
|
| 28 |
+
abstract resolve(handlers: Array<AnyHandler>, onUnhandledFrame: UnhandledFrameHandle, resolutionContext?: NetworkFrameResolutionContext): Promise<boolean | null>;
|
| 29 |
+
/**
|
| 30 |
+
* Perform this network frame as-is.
|
| 31 |
+
*/
|
| 32 |
+
abstract passthrough(): void;
|
| 33 |
+
/**
|
| 34 |
+
* Error the underling network frame.
|
| 35 |
+
* @param reason The reason for the error.
|
| 36 |
+
*/
|
| 37 |
+
abstract errorWith(reason?: unknown): void;
|
| 38 |
+
/**
|
| 39 |
+
* Get a message to be used when this frame is unhandled.
|
| 40 |
+
*/
|
| 41 |
+
abstract getUnhandledMessage(): Promise<string>;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
type UnhandledFrameHandle = UnhandledFrameStrategy | UnhandledFrameCallback;
|
| 45 |
+
type UnhandledFrameStrategy = 'bypass' | 'warn' | 'error';
|
| 46 |
+
type UnhandledFrameCallback = (args: {
|
| 47 |
+
frame: AnyNetworkFrame;
|
| 48 |
+
defaults: UnhandledFrameDefaults;
|
| 49 |
+
}) => Promise<void> | void;
|
| 50 |
+
type UnhandledFrameDefaults = {
|
| 51 |
+
warn: () => void;
|
| 52 |
+
error: () => void;
|
| 53 |
+
};
|
| 54 |
+
declare function executeUnhandledFrameHandle(frame: AnyNetworkFrame, handle: UnhandledFrameHandle): Promise<void>;
|
| 55 |
+
|
| 56 |
+
export { type AnyNetworkFrame as A, type ExtractFrameEvents as E, NetworkFrame as N, type UnhandledFrameCallback as U, type NetworkFrameResolutionContext as a, type UnhandledFrameHandle as b, type UnhandledFrameStrategy as c, type UnhandledFrameDefaults as d, executeUnhandledFrameHandle as e };
|
node_modules/msw/lib/core/on-unhandled-frame-Cr1KOZ0I.d.mts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { DefaultEventMap, Emitter } from 'rettime';
|
| 2 |
+
import { HandlersController, AnyHandler } from './experimental/handlers-controller.mjs';
|
| 3 |
+
|
| 4 |
+
type AnyNetworkFrame = NetworkFrame<string, unknown, any>;
|
| 5 |
+
type ExtractFrameEvents<Frame> = Frame extends NetworkFrame<any, any, infer Events> ? Events : never;
|
| 6 |
+
interface NetworkFrameResolutionContext {
|
| 7 |
+
baseUrl?: string | URL;
|
| 8 |
+
quiet?: boolean;
|
| 9 |
+
}
|
| 10 |
+
/**
|
| 11 |
+
* The base for the network frames. Extend this abstract class
|
| 12 |
+
* to implement custom network frames.
|
| 13 |
+
*/
|
| 14 |
+
declare abstract class NetworkFrame<Protocol extends string, Data, Events extends DefaultEventMap> {
|
| 15 |
+
readonly protocol: Protocol;
|
| 16 |
+
readonly data: Data;
|
| 17 |
+
events: Emitter<Events>;
|
| 18 |
+
constructor(protocol: Protocol, data: Data);
|
| 19 |
+
abstract getHandlers(controller: HandlersController): Array<AnyHandler>;
|
| 20 |
+
/**
|
| 21 |
+
* Resolve the current frame against the given list of handlers.
|
| 22 |
+
* Optionally, use a custom resolution context to control behaviors
|
| 23 |
+
* like `baseUrl`.
|
| 24 |
+
*
|
| 25 |
+
* Returns `true` if the frame was handled, `false` if it wasn't, and `null`
|
| 26 |
+
* if its handling was skipped (e.g. the frame was bypassed).
|
| 27 |
+
*/
|
| 28 |
+
abstract resolve(handlers: Array<AnyHandler>, onUnhandledFrame: UnhandledFrameHandle, resolutionContext?: NetworkFrameResolutionContext): Promise<boolean | null>;
|
| 29 |
+
/**
|
| 30 |
+
* Perform this network frame as-is.
|
| 31 |
+
*/
|
| 32 |
+
abstract passthrough(): void;
|
| 33 |
+
/**
|
| 34 |
+
* Error the underling network frame.
|
| 35 |
+
* @param reason The reason for the error.
|
| 36 |
+
*/
|
| 37 |
+
abstract errorWith(reason?: unknown): void;
|
| 38 |
+
/**
|
| 39 |
+
* Get a message to be used when this frame is unhandled.
|
| 40 |
+
*/
|
| 41 |
+
abstract getUnhandledMessage(): Promise<string>;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
type UnhandledFrameHandle = UnhandledFrameStrategy | UnhandledFrameCallback;
|
| 45 |
+
type UnhandledFrameStrategy = 'bypass' | 'warn' | 'error';
|
| 46 |
+
type UnhandledFrameCallback = (args: {
|
| 47 |
+
frame: AnyNetworkFrame;
|
| 48 |
+
defaults: UnhandledFrameDefaults;
|
| 49 |
+
}) => Promise<void> | void;
|
| 50 |
+
type UnhandledFrameDefaults = {
|
| 51 |
+
warn: () => void;
|
| 52 |
+
error: () => void;
|
| 53 |
+
};
|
| 54 |
+
declare function executeUnhandledFrameHandle(frame: AnyNetworkFrame, handle: UnhandledFrameHandle): Promise<void>;
|
| 55 |
+
|
| 56 |
+
export { type AnyNetworkFrame as A, type ExtractFrameEvents as E, NetworkFrame as N, type UnhandledFrameCallback as U, type NetworkFrameResolutionContext as a, type UnhandledFrameHandle as b, type UnhandledFrameStrategy as c, type UnhandledFrameDefaults as d, executeUnhandledFrameHandle as e };
|
node_modules/msw/lib/core/passthrough.d.mts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { H as HttpResponse } from './HttpResponse-CQwYpuKo.mjs';
|
| 2 |
+
import '@mswjs/interceptors';
|
| 3 |
+
import './utils/internal/isIterable.mjs';
|
| 4 |
+
import './typeUtils.mjs';
|
| 5 |
+
import 'graphql';
|
| 6 |
+
import './utils/matching/matchRequestUrl.mjs';
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* Performs the intercepted request as-is.
|
| 10 |
+
*
|
| 11 |
+
* This stops request handler lookup so no other handlers
|
| 12 |
+
* can affect this request past this point.
|
| 13 |
+
* Unlike `bypass()`, this will not trigger an additional request.
|
| 14 |
+
*
|
| 15 |
+
* @example
|
| 16 |
+
* http.get('/resource', () => {
|
| 17 |
+
* return passthrough()
|
| 18 |
+
* })
|
| 19 |
+
*
|
| 20 |
+
* @see {@link https://mswjs.io/docs/api/passthrough `passthrough()` API reference}
|
| 21 |
+
*/
|
| 22 |
+
declare function passthrough(): HttpResponse<any>;
|
| 23 |
+
|
| 24 |
+
export { passthrough };
|
node_modules/msw/lib/core/passthrough.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { H as HttpResponse } from './HttpResponse-BFS34nkx.js';
|
| 2 |
+
import '@mswjs/interceptors';
|
| 3 |
+
import './utils/internal/isIterable.js';
|
| 4 |
+
import './typeUtils.js';
|
| 5 |
+
import 'graphql';
|
| 6 |
+
import './utils/matching/matchRequestUrl.js';
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* Performs the intercepted request as-is.
|
| 10 |
+
*
|
| 11 |
+
* This stops request handler lookup so no other handlers
|
| 12 |
+
* can affect this request past this point.
|
| 13 |
+
* Unlike `bypass()`, this will not trigger an additional request.
|
| 14 |
+
*
|
| 15 |
+
* @example
|
| 16 |
+
* http.get('/resource', () => {
|
| 17 |
+
* return passthrough()
|
| 18 |
+
* })
|
| 19 |
+
*
|
| 20 |
+
* @see {@link https://mswjs.io/docs/api/passthrough `passthrough()` API reference}
|
| 21 |
+
*/
|
| 22 |
+
declare function passthrough(): HttpResponse<any>;
|
| 23 |
+
|
| 24 |
+
export { passthrough };
|
node_modules/msw/lib/core/passthrough.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __defProp = Object.defineProperty;
|
| 3 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
| 4 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
| 5 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
| 6 |
+
var __export = (target, all) => {
|
| 7 |
+
for (var name in all)
|
| 8 |
+
__defProp(target, name, { get: all[name], enumerable: true });
|
| 9 |
+
};
|
| 10 |
+
var __copyProps = (to, from, except, desc) => {
|
| 11 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
| 12 |
+
for (let key of __getOwnPropNames(from))
|
| 13 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
| 14 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
| 15 |
+
}
|
| 16 |
+
return to;
|
| 17 |
+
};
|
| 18 |
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
| 19 |
+
var passthrough_exports = {};
|
| 20 |
+
__export(passthrough_exports, {
|
| 21 |
+
passthrough: () => passthrough
|
| 22 |
+
});
|
| 23 |
+
module.exports = __toCommonJS(passthrough_exports);
|
| 24 |
+
function passthrough() {
|
| 25 |
+
return new Response(null, {
|
| 26 |
+
status: 302,
|
| 27 |
+
statusText: "Passthrough",
|
| 28 |
+
headers: {
|
| 29 |
+
"x-msw-intention": "passthrough"
|
| 30 |
+
}
|
| 31 |
+
});
|
| 32 |
+
}
|
| 33 |
+
//# sourceMappingURL=passthrough.js.map
|
node_modules/msw/lib/core/passthrough.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../src/core/passthrough.ts"],"sourcesContent":["import type { HttpResponse } from './HttpResponse'\n\n/**\n * Performs the intercepted request as-is.\n *\n * This stops request handler lookup so no other handlers\n * can affect this request past this point.\n * Unlike `bypass()`, this will not trigger an additional request.\n *\n * @example\n * http.get('/resource', () => {\n * return passthrough()\n * })\n *\n * @see {@link https://mswjs.io/docs/api/passthrough `passthrough()` API reference}\n */\nexport function passthrough(): HttpResponse<any> {\n return new Response(null, {\n status: 302,\n statusText: 'Passthrough',\n headers: {\n 'x-msw-intention': 'passthrough',\n },\n }) as HttpResponse<any>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBO,SAAS,cAAiC;AAC/C,SAAO,IAAI,SAAS,MAAM;AAAA,IACxB,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,SAAS;AAAA,MACP,mBAAmB;AAAA,IACrB;AAAA,EACF,CAAC;AACH;","names":[]}
|
node_modules/msw/lib/core/passthrough.mjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function passthrough() {
|
| 2 |
+
return new Response(null, {
|
| 3 |
+
status: 302,
|
| 4 |
+
statusText: "Passthrough",
|
| 5 |
+
headers: {
|
| 6 |
+
"x-msw-intention": "passthrough"
|
| 7 |
+
}
|
| 8 |
+
});
|
| 9 |
+
}
|
| 10 |
+
export {
|
| 11 |
+
passthrough
|
| 12 |
+
};
|
| 13 |
+
//# sourceMappingURL=passthrough.mjs.map
|
node_modules/msw/lib/core/passthrough.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../src/core/passthrough.ts"],"sourcesContent":["import type { HttpResponse } from './HttpResponse'\n\n/**\n * Performs the intercepted request as-is.\n *\n * This stops request handler lookup so no other handlers\n * can affect this request past this point.\n * Unlike `bypass()`, this will not trigger an additional request.\n *\n * @example\n * http.get('/resource', () => {\n * return passthrough()\n * })\n *\n * @see {@link https://mswjs.io/docs/api/passthrough `passthrough()` API reference}\n */\nexport function passthrough(): HttpResponse<any> {\n return new Response(null, {\n status: 302,\n statusText: 'Passthrough',\n headers: {\n 'x-msw-intention': 'passthrough',\n },\n }) as HttpResponse<any>\n}\n"],"mappings":"AAgBO,SAAS,cAAiC;AAC/C,SAAO,IAAI,SAAS,MAAM;AAAA,IACxB,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,SAAS;AAAA,MACP,mBAAmB;AAAA,IACrB;AAAA,EACF,CAAC;AACH;","names":[]}
|
node_modules/msw/lib/core/sharedOptions.d.mts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { DefaultEventMap, Emitter } from 'rettime';
|
| 2 |
+
import { UnhandledRequestStrategy } from './utils/request/onUnhandledRequest.mjs';
|
| 3 |
+
|
| 4 |
+
interface SharedOptions {
|
| 5 |
+
/**
|
| 6 |
+
* Specifies how to react to a request that has no corresponding
|
| 7 |
+
* request handler. Warns on unhandled requests by default.
|
| 8 |
+
*
|
| 9 |
+
* @example worker.start({ onUnhandledRequest: 'bypass' })
|
| 10 |
+
* @example worker.start({ onUnhandledRequest: 'warn' })
|
| 11 |
+
* @example server.listen({ onUnhandledRequest: 'error' })
|
| 12 |
+
*/
|
| 13 |
+
onUnhandledRequest?: UnhandledRequestStrategy;
|
| 14 |
+
}
|
| 15 |
+
/**
|
| 16 |
+
* @deprecated
|
| 17 |
+
* Please use `HttpNetworkFrameEventMap` or `WebSocketNetworkFrameEventMap` instead.
|
| 18 |
+
*/
|
| 19 |
+
type LifeCycleEventsMap = {
|
| 20 |
+
'request:start': [
|
| 21 |
+
args: {
|
| 22 |
+
request: Request;
|
| 23 |
+
requestId: string;
|
| 24 |
+
}
|
| 25 |
+
];
|
| 26 |
+
'request:match': [
|
| 27 |
+
args: {
|
| 28 |
+
request: Request;
|
| 29 |
+
requestId: string;
|
| 30 |
+
}
|
| 31 |
+
];
|
| 32 |
+
'request:unhandled': [
|
| 33 |
+
args: {
|
| 34 |
+
request: Request;
|
| 35 |
+
requestId: string;
|
| 36 |
+
}
|
| 37 |
+
];
|
| 38 |
+
'request:end': [
|
| 39 |
+
args: {
|
| 40 |
+
request: Request;
|
| 41 |
+
requestId: string;
|
| 42 |
+
}
|
| 43 |
+
];
|
| 44 |
+
'response:mocked': [
|
| 45 |
+
args: {
|
| 46 |
+
response: Response;
|
| 47 |
+
request: Request;
|
| 48 |
+
requestId: string;
|
| 49 |
+
}
|
| 50 |
+
];
|
| 51 |
+
'response:bypass': [
|
| 52 |
+
args: {
|
| 53 |
+
response: Response;
|
| 54 |
+
request: Request;
|
| 55 |
+
requestId: string;
|
| 56 |
+
}
|
| 57 |
+
];
|
| 58 |
+
unhandledException: [
|
| 59 |
+
args: {
|
| 60 |
+
error: Error;
|
| 61 |
+
request: Request;
|
| 62 |
+
requestId: string;
|
| 63 |
+
}
|
| 64 |
+
];
|
| 65 |
+
};
|
| 66 |
+
type LifeCycleEventEmitter<EventMap extends DefaultEventMap> = Pick<Emitter<EventMap>, 'on' | 'removeListener' | 'removeAllListeners'>;
|
| 67 |
+
|
| 68 |
+
export type { LifeCycleEventEmitter, LifeCycleEventsMap, SharedOptions };
|
node_modules/msw/lib/core/sharedOptions.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { DefaultEventMap, Emitter } from 'rettime';
|
| 2 |
+
import { UnhandledRequestStrategy } from './utils/request/onUnhandledRequest.js';
|
| 3 |
+
|
| 4 |
+
interface SharedOptions {
|
| 5 |
+
/**
|
| 6 |
+
* Specifies how to react to a request that has no corresponding
|
| 7 |
+
* request handler. Warns on unhandled requests by default.
|
| 8 |
+
*
|
| 9 |
+
* @example worker.start({ onUnhandledRequest: 'bypass' })
|
| 10 |
+
* @example worker.start({ onUnhandledRequest: 'warn' })
|
| 11 |
+
* @example server.listen({ onUnhandledRequest: 'error' })
|
| 12 |
+
*/
|
| 13 |
+
onUnhandledRequest?: UnhandledRequestStrategy;
|
| 14 |
+
}
|
| 15 |
+
/**
|
| 16 |
+
* @deprecated
|
| 17 |
+
* Please use `HttpNetworkFrameEventMap` or `WebSocketNetworkFrameEventMap` instead.
|
| 18 |
+
*/
|
| 19 |
+
type LifeCycleEventsMap = {
|
| 20 |
+
'request:start': [
|
| 21 |
+
args: {
|
| 22 |
+
request: Request;
|
| 23 |
+
requestId: string;
|
| 24 |
+
}
|
| 25 |
+
];
|
| 26 |
+
'request:match': [
|
| 27 |
+
args: {
|
| 28 |
+
request: Request;
|
| 29 |
+
requestId: string;
|
| 30 |
+
}
|
| 31 |
+
];
|
| 32 |
+
'request:unhandled': [
|
| 33 |
+
args: {
|
| 34 |
+
request: Request;
|
| 35 |
+
requestId: string;
|
| 36 |
+
}
|
| 37 |
+
];
|
| 38 |
+
'request:end': [
|
| 39 |
+
args: {
|
| 40 |
+
request: Request;
|
| 41 |
+
requestId: string;
|
| 42 |
+
}
|
| 43 |
+
];
|
| 44 |
+
'response:mocked': [
|
| 45 |
+
args: {
|
| 46 |
+
response: Response;
|
| 47 |
+
request: Request;
|
| 48 |
+
requestId: string;
|
| 49 |
+
}
|
| 50 |
+
];
|
| 51 |
+
'response:bypass': [
|
| 52 |
+
args: {
|
| 53 |
+
response: Response;
|
| 54 |
+
request: Request;
|
| 55 |
+
requestId: string;
|
| 56 |
+
}
|
| 57 |
+
];
|
| 58 |
+
unhandledException: [
|
| 59 |
+
args: {
|
| 60 |
+
error: Error;
|
| 61 |
+
request: Request;
|
| 62 |
+
requestId: string;
|
| 63 |
+
}
|
| 64 |
+
];
|
| 65 |
+
};
|
| 66 |
+
type LifeCycleEventEmitter<EventMap extends DefaultEventMap> = Pick<Emitter<EventMap>, 'on' | 'removeListener' | 'removeAllListeners'>;
|
| 67 |
+
|
| 68 |
+
export type { LifeCycleEventEmitter, LifeCycleEventsMap, SharedOptions };
|
node_modules/msw/lib/core/sharedOptions.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __defProp = Object.defineProperty;
|
| 3 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
| 4 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
| 5 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
| 6 |
+
var __copyProps = (to, from, except, desc) => {
|
| 7 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
| 8 |
+
for (let key of __getOwnPropNames(from))
|
| 9 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
| 10 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
| 11 |
+
}
|
| 12 |
+
return to;
|
| 13 |
+
};
|
| 14 |
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
| 15 |
+
var sharedOptions_exports = {};
|
| 16 |
+
module.exports = __toCommonJS(sharedOptions_exports);
|
| 17 |
+
//# sourceMappingURL=sharedOptions.js.map
|
node_modules/msw/lib/core/sharedOptions.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../src/core/sharedOptions.ts"],"sourcesContent":["import type { Emitter, DefaultEventMap } from 'rettime'\nimport type { UnhandledRequestStrategy } from './utils/request/onUnhandledRequest'\n\nexport interface SharedOptions {\n /**\n * Specifies how to react to a request that has no corresponding\n * request handler. Warns on unhandled requests by default.\n *\n * @example worker.start({ onUnhandledRequest: 'bypass' })\n * @example worker.start({ onUnhandledRequest: 'warn' })\n * @example server.listen({ onUnhandledRequest: 'error' })\n */\n onUnhandledRequest?: UnhandledRequestStrategy\n}\n\n/**\n * @deprecated\n * Please use `HttpNetworkFrameEventMap` or `WebSocketNetworkFrameEventMap` instead.\n */\nexport type LifeCycleEventsMap = {\n 'request:start': [\n args: {\n request: Request\n requestId: string\n },\n ]\n 'request:match': [\n args: {\n request: Request\n requestId: string\n },\n ]\n 'request:unhandled': [\n args: {\n request: Request\n requestId: string\n },\n ]\n 'request:end': [\n args: {\n request: Request\n requestId: string\n },\n ]\n 'response:mocked': [\n args: {\n response: Response\n request: Request\n requestId: string\n },\n ]\n 'response:bypass': [\n args: {\n response: Response\n request: Request\n requestId: string\n },\n ]\n unhandledException: [\n args: {\n error: Error\n request: Request\n requestId: string\n },\n ]\n}\n\nexport type LifeCycleEventEmitter<EventMap extends DefaultEventMap> = Pick<\n Emitter<EventMap>,\n 'on' | 'removeListener' | 'removeAllListeners'\n>\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
node_modules/msw/lib/core/sharedOptions.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
//# sourceMappingURL=sharedOptions.mjs.map
|
node_modules/msw/lib/core/sharedOptions.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
node_modules/msw/lib/core/sse.d.mts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { a as ResponseResolver } from './HttpResponse-CQwYpuKo.mjs';
|
| 2 |
+
import { HttpRequestResolverExtras, HttpHandler } from './handlers/HttpHandler.mjs';
|
| 3 |
+
import { PathParams, Path } from './utils/matching/matchRequestUrl.mjs';
|
| 4 |
+
import '@mswjs/interceptors';
|
| 5 |
+
import './utils/internal/isIterable.mjs';
|
| 6 |
+
import './typeUtils.mjs';
|
| 7 |
+
import 'graphql';
|
| 8 |
+
|
| 9 |
+
type EventMapConstraint = {
|
| 10 |
+
message?: unknown;
|
| 11 |
+
[key: string]: unknown;
|
| 12 |
+
[key: symbol | number]: never;
|
| 13 |
+
};
|
| 14 |
+
type ServerSentEventResolverExtras<EventMap extends EventMapConstraint, Params extends PathParams> = HttpRequestResolverExtras<Params> & {
|
| 15 |
+
client: ServerSentEventClient<EventMap>;
|
| 16 |
+
server: ServerSentEventServer;
|
| 17 |
+
};
|
| 18 |
+
type ServerSentEventResolver<EventMap extends EventMapConstraint, Params extends PathParams> = ResponseResolver<ServerSentEventResolverExtras<EventMap, Params>, any, any>;
|
| 19 |
+
type ServerSentEventRequestHandler = <EventMap extends EventMapConstraint = {
|
| 20 |
+
message: unknown;
|
| 21 |
+
}, Params extends PathParams<keyof Params> = PathParams, RequestPath extends Path = Path>(path: RequestPath, resolver: ServerSentEventResolver<EventMap, Params>) => HttpHandler;
|
| 22 |
+
type ServerSentEventMessage<EventMap extends EventMapConstraint = {
|
| 23 |
+
message: unknown;
|
| 24 |
+
}> = ToEventDiscriminatedUnion<EventMap & {
|
| 25 |
+
message: unknown;
|
| 26 |
+
}> | {
|
| 27 |
+
id?: never;
|
| 28 |
+
event?: never;
|
| 29 |
+
data?: never;
|
| 30 |
+
retry: number;
|
| 31 |
+
};
|
| 32 |
+
/**
|
| 33 |
+
* Intercept Server-Sent Events (SSE).
|
| 34 |
+
*
|
| 35 |
+
* @example
|
| 36 |
+
* sse('http://localhost:4321', ({ client }) => {
|
| 37 |
+
* client.send({ data: 'hello world' })
|
| 38 |
+
* })
|
| 39 |
+
*
|
| 40 |
+
* @see {@link https://mswjs.io/docs/sse/ Mocking Server-Sent Events}
|
| 41 |
+
* @see {@link https://mswjs.io/docs/api/sse `sse()` API reference}
|
| 42 |
+
*/
|
| 43 |
+
declare const sse: ServerSentEventRequestHandler;
|
| 44 |
+
type Values<T> = T[keyof T];
|
| 45 |
+
type Identity<T> = {
|
| 46 |
+
[K in keyof T]: T[K];
|
| 47 |
+
} & unknown;
|
| 48 |
+
type ToEventDiscriminatedUnion<T> = Values<{
|
| 49 |
+
[K in keyof T]: Identity<(K extends 'message' ? {
|
| 50 |
+
id?: string;
|
| 51 |
+
event?: K;
|
| 52 |
+
data?: T[K];
|
| 53 |
+
retry?: never;
|
| 54 |
+
} : {
|
| 55 |
+
id?: string;
|
| 56 |
+
event: K;
|
| 57 |
+
data?: T[K];
|
| 58 |
+
retry?: never;
|
| 59 |
+
}) & (undefined extends T[K] ? unknown : {
|
| 60 |
+
data: unknown;
|
| 61 |
+
})>;
|
| 62 |
+
}>;
|
| 63 |
+
declare const kClientEmitter: unique symbol;
|
| 64 |
+
declare class ServerSentEventClient<EventMap extends EventMapConstraint = {
|
| 65 |
+
message: unknown;
|
| 66 |
+
}> {
|
| 67 |
+
#private;
|
| 68 |
+
private [kClientEmitter]?;
|
| 69 |
+
constructor(writable: WritableStream);
|
| 70 |
+
/**
|
| 71 |
+
* Sends the given payload to the intercepted `EventSource`.
|
| 72 |
+
*/
|
| 73 |
+
send(payload: ServerSentEventMessage<EventMap>): void;
|
| 74 |
+
/**
|
| 75 |
+
* Dispatches the given event on the intercepted `EventSource`.
|
| 76 |
+
*/
|
| 77 |
+
dispatchEvent(event: Event): void;
|
| 78 |
+
/**
|
| 79 |
+
* Errors the underlying `EventSource`, closing the connection with an error.
|
| 80 |
+
* This is equivalent to aborting the connection and will produce a `TypeError: Failed to fetch`
|
| 81 |
+
* error.
|
| 82 |
+
*/
|
| 83 |
+
error(): void;
|
| 84 |
+
/**
|
| 85 |
+
* Closes the underlying `EventSource`, closing the connection.
|
| 86 |
+
*/
|
| 87 |
+
close(): void;
|
| 88 |
+
}
|
| 89 |
+
declare class ServerSentEventServer {
|
| 90 |
+
#private;
|
| 91 |
+
constructor(args: {
|
| 92 |
+
request: Request;
|
| 93 |
+
client: ServerSentEventClient<any>;
|
| 94 |
+
});
|
| 95 |
+
/**
|
| 96 |
+
* Establishes the actual connection for this SSE request
|
| 97 |
+
* and returns the `EventSource` instance.
|
| 98 |
+
*/
|
| 99 |
+
connect(): EventSource;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
export { type ServerSentEventMessage, type ServerSentEventRequestHandler, type ServerSentEventResolver, type ServerSentEventResolverExtras, sse };
|
node_modules/msw/lib/core/sse.d.ts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { a as ResponseResolver } from './HttpResponse-BFS34nkx.js';
|
| 2 |
+
import { HttpRequestResolverExtras, HttpHandler } from './handlers/HttpHandler.js';
|
| 3 |
+
import { PathParams, Path } from './utils/matching/matchRequestUrl.js';
|
| 4 |
+
import '@mswjs/interceptors';
|
| 5 |
+
import './utils/internal/isIterable.js';
|
| 6 |
+
import './typeUtils.js';
|
| 7 |
+
import 'graphql';
|
| 8 |
+
|
| 9 |
+
type EventMapConstraint = {
|
| 10 |
+
message?: unknown;
|
| 11 |
+
[key: string]: unknown;
|
| 12 |
+
[key: symbol | number]: never;
|
| 13 |
+
};
|
| 14 |
+
type ServerSentEventResolverExtras<EventMap extends EventMapConstraint, Params extends PathParams> = HttpRequestResolverExtras<Params> & {
|
| 15 |
+
client: ServerSentEventClient<EventMap>;
|
| 16 |
+
server: ServerSentEventServer;
|
| 17 |
+
};
|
| 18 |
+
type ServerSentEventResolver<EventMap extends EventMapConstraint, Params extends PathParams> = ResponseResolver<ServerSentEventResolverExtras<EventMap, Params>, any, any>;
|
| 19 |
+
type ServerSentEventRequestHandler = <EventMap extends EventMapConstraint = {
|
| 20 |
+
message: unknown;
|
| 21 |
+
}, Params extends PathParams<keyof Params> = PathParams, RequestPath extends Path = Path>(path: RequestPath, resolver: ServerSentEventResolver<EventMap, Params>) => HttpHandler;
|
| 22 |
+
type ServerSentEventMessage<EventMap extends EventMapConstraint = {
|
| 23 |
+
message: unknown;
|
| 24 |
+
}> = ToEventDiscriminatedUnion<EventMap & {
|
| 25 |
+
message: unknown;
|
| 26 |
+
}> | {
|
| 27 |
+
id?: never;
|
| 28 |
+
event?: never;
|
| 29 |
+
data?: never;
|
| 30 |
+
retry: number;
|
| 31 |
+
};
|
| 32 |
+
/**
|
| 33 |
+
* Intercept Server-Sent Events (SSE).
|
| 34 |
+
*
|
| 35 |
+
* @example
|
| 36 |
+
* sse('http://localhost:4321', ({ client }) => {
|
| 37 |
+
* client.send({ data: 'hello world' })
|
| 38 |
+
* })
|
| 39 |
+
*
|
| 40 |
+
* @see {@link https://mswjs.io/docs/sse/ Mocking Server-Sent Events}
|
| 41 |
+
* @see {@link https://mswjs.io/docs/api/sse `sse()` API reference}
|
| 42 |
+
*/
|
| 43 |
+
declare const sse: ServerSentEventRequestHandler;
|
| 44 |
+
type Values<T> = T[keyof T];
|
| 45 |
+
type Identity<T> = {
|
| 46 |
+
[K in keyof T]: T[K];
|
| 47 |
+
} & unknown;
|
| 48 |
+
type ToEventDiscriminatedUnion<T> = Values<{
|
| 49 |
+
[K in keyof T]: Identity<(K extends 'message' ? {
|
| 50 |
+
id?: string;
|
| 51 |
+
event?: K;
|
| 52 |
+
data?: T[K];
|
| 53 |
+
retry?: never;
|
| 54 |
+
} : {
|
| 55 |
+
id?: string;
|
| 56 |
+
event: K;
|
| 57 |
+
data?: T[K];
|
| 58 |
+
retry?: never;
|
| 59 |
+
}) & (undefined extends T[K] ? unknown : {
|
| 60 |
+
data: unknown;
|
| 61 |
+
})>;
|
| 62 |
+
}>;
|
| 63 |
+
declare const kClientEmitter: unique symbol;
|
| 64 |
+
declare class ServerSentEventClient<EventMap extends EventMapConstraint = {
|
| 65 |
+
message: unknown;
|
| 66 |
+
}> {
|
| 67 |
+
#private;
|
| 68 |
+
private [kClientEmitter]?;
|
| 69 |
+
constructor(writable: WritableStream);
|
| 70 |
+
/**
|
| 71 |
+
* Sends the given payload to the intercepted `EventSource`.
|
| 72 |
+
*/
|
| 73 |
+
send(payload: ServerSentEventMessage<EventMap>): void;
|
| 74 |
+
/**
|
| 75 |
+
* Dispatches the given event on the intercepted `EventSource`.
|
| 76 |
+
*/
|
| 77 |
+
dispatchEvent(event: Event): void;
|
| 78 |
+
/**
|
| 79 |
+
* Errors the underlying `EventSource`, closing the connection with an error.
|
| 80 |
+
* This is equivalent to aborting the connection and will produce a `TypeError: Failed to fetch`
|
| 81 |
+
* error.
|
| 82 |
+
*/
|
| 83 |
+
error(): void;
|
| 84 |
+
/**
|
| 85 |
+
* Closes the underlying `EventSource`, closing the connection.
|
| 86 |
+
*/
|
| 87 |
+
close(): void;
|
| 88 |
+
}
|
| 89 |
+
declare class ServerSentEventServer {
|
| 90 |
+
#private;
|
| 91 |
+
constructor(args: {
|
| 92 |
+
request: Request;
|
| 93 |
+
client: ServerSentEventClient<any>;
|
| 94 |
+
});
|
| 95 |
+
/**
|
| 96 |
+
* Establishes the actual connection for this SSE request
|
| 97 |
+
* and returns the `EventSource` instance.
|
| 98 |
+
*/
|
| 99 |
+
connect(): EventSource;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
export { type ServerSentEventMessage, type ServerSentEventRequestHandler, type ServerSentEventResolver, type ServerSentEventResolverExtras, sse };
|
node_modules/msw/lib/core/sse.js
ADDED
|
@@ -0,0 +1,667 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __defProp = Object.defineProperty;
|
| 3 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
| 4 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
| 5 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
| 6 |
+
var __export = (target, all) => {
|
| 7 |
+
for (var name in all)
|
| 8 |
+
__defProp(target, name, { get: all[name], enumerable: true });
|
| 9 |
+
};
|
| 10 |
+
var __copyProps = (to, from, except, desc) => {
|
| 11 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
| 12 |
+
for (let key of __getOwnPropNames(from))
|
| 13 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
| 14 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
| 15 |
+
}
|
| 16 |
+
return to;
|
| 17 |
+
};
|
| 18 |
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
| 19 |
+
var sse_exports = {};
|
| 20 |
+
__export(sse_exports, {
|
| 21 |
+
sse: () => sse
|
| 22 |
+
});
|
| 23 |
+
module.exports = __toCommonJS(sse_exports);
|
| 24 |
+
var import_outvariant = require("outvariant");
|
| 25 |
+
var import_deferred_promise = require("@open-draft/deferred-promise");
|
| 26 |
+
var import_strict_event_emitter = require("strict-event-emitter");
|
| 27 |
+
var import_HttpHandler = require("./handlers/HttpHandler");
|
| 28 |
+
var import_delay = require("./delay");
|
| 29 |
+
var import_getTimestamp = require("./utils/logging/getTimestamp");
|
| 30 |
+
var import_devUtils = require("./utils/internal/devUtils");
|
| 31 |
+
var import_attachWebSocketLogger = require("./ws/utils/attachWebSocketLogger");
|
| 32 |
+
var import_toPublicUrl = require("./utils/request/toPublicUrl");
|
| 33 |
+
const sse = (path, resolver) => {
|
| 34 |
+
return new ServerSentEventHandler(path, resolver);
|
| 35 |
+
};
|
| 36 |
+
const SSE_RESPONSE_INIT = {
|
| 37 |
+
headers: {
|
| 38 |
+
"content-type": "text/event-stream",
|
| 39 |
+
"cache-control": "no-cache",
|
| 40 |
+
connection: "keep-alive"
|
| 41 |
+
}
|
| 42 |
+
};
|
| 43 |
+
class ServerSentEventHandler extends import_HttpHandler.HttpHandler {
|
| 44 |
+
#emitter;
|
| 45 |
+
constructor(path, resolver) {
|
| 46 |
+
(0, import_outvariant.invariant)(
|
| 47 |
+
typeof EventSource !== "undefined",
|
| 48 |
+
'Failed to construct a Server-Sent Event handler for path "%s": the EventSource API is not supported in this environment',
|
| 49 |
+
path
|
| 50 |
+
);
|
| 51 |
+
super("GET", path, async (info) => {
|
| 52 |
+
const { client, server, response } = createEventStream(
|
| 53 |
+
info.request
|
| 54 |
+
);
|
| 55 |
+
client[kClientEmitter] = this.#emitter;
|
| 56 |
+
await resolver({
|
| 57 |
+
...info,
|
| 58 |
+
client,
|
| 59 |
+
server
|
| 60 |
+
});
|
| 61 |
+
return response;
|
| 62 |
+
});
|
| 63 |
+
this.#emitter = new import_strict_event_emitter.Emitter();
|
| 64 |
+
}
|
| 65 |
+
async predicate(args) {
|
| 66 |
+
if (args.request.headers.get("accept") !== "text/event-stream") {
|
| 67 |
+
return false;
|
| 68 |
+
}
|
| 69 |
+
const matches = await super.predicate(args);
|
| 70 |
+
if (matches && !args.resolutionContext?.quiet) {
|
| 71 |
+
await super.log({
|
| 72 |
+
request: args.request,
|
| 73 |
+
/**
|
| 74 |
+
* @note Construct a placeholder response since SSE response
|
| 75 |
+
* is being streamed and cannot be cloned/consumed for logging.
|
| 76 |
+
*/
|
| 77 |
+
response: new Response("[streaming]", SSE_RESPONSE_INIT)
|
| 78 |
+
});
|
| 79 |
+
this.#attachClientLogger(args.request, this.#emitter);
|
| 80 |
+
}
|
| 81 |
+
return matches;
|
| 82 |
+
}
|
| 83 |
+
async log(_args) {
|
| 84 |
+
return;
|
| 85 |
+
}
|
| 86 |
+
#attachClientLogger(request, emitter) {
|
| 87 |
+
const publicUrl = (0, import_toPublicUrl.toPublicUrl)(request.url);
|
| 88 |
+
emitter.on("message", (payload) => {
|
| 89 |
+
console.groupCollapsed(
|
| 90 |
+
import_devUtils.devUtils.formatMessage(
|
| 91 |
+
`${(0, import_getTimestamp.getTimestamp)()} SSE %s %c\u21E3%c ${payload.event}`
|
| 92 |
+
),
|
| 93 |
+
publicUrl,
|
| 94 |
+
`color:${import_attachWebSocketLogger.colors.mocked}`,
|
| 95 |
+
"color:inherit"
|
| 96 |
+
);
|
| 97 |
+
console.log(payload.frames);
|
| 98 |
+
console.groupEnd();
|
| 99 |
+
});
|
| 100 |
+
emitter.on("error", () => {
|
| 101 |
+
console.groupCollapsed(
|
| 102 |
+
import_devUtils.devUtils.formatMessage(`${(0, import_getTimestamp.getTimestamp)()} SSE %s %c\xD7%c error`),
|
| 103 |
+
publicUrl,
|
| 104 |
+
`color: ${import_attachWebSocketLogger.colors.system}`,
|
| 105 |
+
"color:inherit"
|
| 106 |
+
);
|
| 107 |
+
console.log("Handler:", this);
|
| 108 |
+
console.groupEnd();
|
| 109 |
+
});
|
| 110 |
+
emitter.on("close", () => {
|
| 111 |
+
console.groupCollapsed(
|
| 112 |
+
import_devUtils.devUtils.formatMessage(`${(0, import_getTimestamp.getTimestamp)()} SSE %s %c\u25A0%c close`),
|
| 113 |
+
publicUrl,
|
| 114 |
+
`colors:${import_attachWebSocketLogger.colors.system}`,
|
| 115 |
+
"color:inherit"
|
| 116 |
+
);
|
| 117 |
+
console.log("Handler:", this);
|
| 118 |
+
console.groupEnd();
|
| 119 |
+
});
|
| 120 |
+
}
|
| 121 |
+
}
|
| 122 |
+
const kClientEmitter = Symbol.for("kClientEmitter");
|
| 123 |
+
class ServerSentEventClient {
|
| 124 |
+
[kClientEmitter];
|
| 125 |
+
#encoder;
|
| 126 |
+
#writer;
|
| 127 |
+
constructor(writable) {
|
| 128 |
+
this.#encoder = new TextEncoder();
|
| 129 |
+
this.#writer = writable.getWriter();
|
| 130 |
+
}
|
| 131 |
+
/**
|
| 132 |
+
* Sends the given payload to the intercepted `EventSource`.
|
| 133 |
+
*/
|
| 134 |
+
send(payload) {
|
| 135 |
+
if ("retry" in payload && payload.retry != null) {
|
| 136 |
+
this.#sendRetry(payload.retry);
|
| 137 |
+
return;
|
| 138 |
+
}
|
| 139 |
+
this.#sendMessage({
|
| 140 |
+
id: payload.id,
|
| 141 |
+
event: payload.event,
|
| 142 |
+
data: typeof payload.data === "object" ? JSON.stringify(payload.data) : payload.data
|
| 143 |
+
});
|
| 144 |
+
}
|
| 145 |
+
/**
|
| 146 |
+
* Dispatches the given event on the intercepted `EventSource`.
|
| 147 |
+
*/
|
| 148 |
+
dispatchEvent(event) {
|
| 149 |
+
if (event instanceof MessageEvent) {
|
| 150 |
+
this.#sendMessage({
|
| 151 |
+
id: event.lastEventId || void 0,
|
| 152 |
+
event: event.type === "message" ? void 0 : event.type,
|
| 153 |
+
data: event.data
|
| 154 |
+
});
|
| 155 |
+
return;
|
| 156 |
+
}
|
| 157 |
+
if (event.type === "error") {
|
| 158 |
+
this.error();
|
| 159 |
+
return;
|
| 160 |
+
}
|
| 161 |
+
if (event.type === "close") {
|
| 162 |
+
this.close();
|
| 163 |
+
return;
|
| 164 |
+
}
|
| 165 |
+
}
|
| 166 |
+
/**
|
| 167 |
+
* Errors the underlying `EventSource`, closing the connection with an error.
|
| 168 |
+
* This is equivalent to aborting the connection and will produce a `TypeError: Failed to fetch`
|
| 169 |
+
* error.
|
| 170 |
+
*/
|
| 171 |
+
error() {
|
| 172 |
+
this.#writer.abort().catch((error) => {
|
| 173 |
+
console.error(error);
|
| 174 |
+
import_devUtils.devUtils.error(
|
| 175 |
+
"Failed to abort server-side EventSource. Please see the original error above."
|
| 176 |
+
);
|
| 177 |
+
});
|
| 178 |
+
this[kClientEmitter]?.emit("error");
|
| 179 |
+
}
|
| 180 |
+
/**
|
| 181 |
+
* Closes the underlying `EventSource`, closing the connection.
|
| 182 |
+
*/
|
| 183 |
+
close() {
|
| 184 |
+
this.#writer.close().catch((error) => {
|
| 185 |
+
console.error(error);
|
| 186 |
+
import_devUtils.devUtils.error(
|
| 187 |
+
"Failed to close server-side EventSource. Please see the original error above."
|
| 188 |
+
);
|
| 189 |
+
});
|
| 190 |
+
this[kClientEmitter]?.emit("close");
|
| 191 |
+
}
|
| 192 |
+
#sendRetry(retry) {
|
| 193 |
+
this.#writer.write(this.#encoder.encode(`retry:${retry}
|
| 194 |
+
|
| 195 |
+
`)).catch((error) => {
|
| 196 |
+
console.error(error);
|
| 197 |
+
import_devUtils.devUtils.error(
|
| 198 |
+
"Failed to send a retry packet to server-side EventSource. Please see the original error above."
|
| 199 |
+
);
|
| 200 |
+
});
|
| 201 |
+
}
|
| 202 |
+
#sendMessage(message) {
|
| 203 |
+
const frames = [];
|
| 204 |
+
if (message.id) {
|
| 205 |
+
frames.push(`id:${message.id}`);
|
| 206 |
+
}
|
| 207 |
+
if (message.event) {
|
| 208 |
+
frames.push(`event:${message.event.toString()}`);
|
| 209 |
+
}
|
| 210 |
+
if (message.data != null) {
|
| 211 |
+
for (const line of message.data.toString().split(/\r\n|\r|\n/)) {
|
| 212 |
+
frames.push(`data:${line}`);
|
| 213 |
+
}
|
| 214 |
+
}
|
| 215 |
+
frames.push("", "");
|
| 216 |
+
this.#writer.write(this.#encoder.encode(frames.join("\n"))).catch((error) => {
|
| 217 |
+
console.error(error);
|
| 218 |
+
import_devUtils.devUtils.error(
|
| 219 |
+
"Failed to send a message to server-side EventSource. Please see the original error above."
|
| 220 |
+
);
|
| 221 |
+
});
|
| 222 |
+
this[kClientEmitter]?.emit("message", {
|
| 223 |
+
id: message.id,
|
| 224 |
+
event: message.event?.toString() || "message",
|
| 225 |
+
data: message.data,
|
| 226 |
+
frames
|
| 227 |
+
});
|
| 228 |
+
}
|
| 229 |
+
}
|
| 230 |
+
class ServerSentEventServer {
|
| 231 |
+
#request;
|
| 232 |
+
#client;
|
| 233 |
+
constructor(args) {
|
| 234 |
+
this.#request = args.request;
|
| 235 |
+
this.#client = args.client;
|
| 236 |
+
}
|
| 237 |
+
/**
|
| 238 |
+
* Establishes the actual connection for this SSE request
|
| 239 |
+
* and returns the `EventSource` instance.
|
| 240 |
+
*/
|
| 241 |
+
connect() {
|
| 242 |
+
const source = new ObservableEventSource(this.#request.url, {
|
| 243 |
+
withCredentials: this.#request.credentials === "include",
|
| 244 |
+
headers: {
|
| 245 |
+
/**
|
| 246 |
+
* @note Mark this request as passthrough so it doesn't trigger
|
| 247 |
+
* an infinite loop matching against the existing request handler.
|
| 248 |
+
*/
|
| 249 |
+
accept: "msw/passthrough"
|
| 250 |
+
},
|
| 251 |
+
signal: this.#request.signal
|
| 252 |
+
});
|
| 253 |
+
source[kOnAnyMessage] = (event) => {
|
| 254 |
+
Object.defineProperties(event, {
|
| 255 |
+
target: {
|
| 256 |
+
value: this,
|
| 257 |
+
enumerable: true,
|
| 258 |
+
writable: true,
|
| 259 |
+
configurable: true
|
| 260 |
+
}
|
| 261 |
+
});
|
| 262 |
+
queueMicrotask(() => {
|
| 263 |
+
if (!event.defaultPrevented) {
|
| 264 |
+
this.#client.dispatchEvent(event);
|
| 265 |
+
}
|
| 266 |
+
});
|
| 267 |
+
};
|
| 268 |
+
source.addEventListener("error", (event) => {
|
| 269 |
+
Object.defineProperties(event, {
|
| 270 |
+
target: {
|
| 271 |
+
value: this,
|
| 272 |
+
enumerable: true,
|
| 273 |
+
writable: true,
|
| 274 |
+
configurable: true
|
| 275 |
+
}
|
| 276 |
+
});
|
| 277 |
+
queueMicrotask(() => {
|
| 278 |
+
if (!event.defaultPrevented) {
|
| 279 |
+
this.#client.dispatchEvent(event);
|
| 280 |
+
}
|
| 281 |
+
});
|
| 282 |
+
});
|
| 283 |
+
return source;
|
| 284 |
+
}
|
| 285 |
+
}
|
| 286 |
+
const kRequest = Symbol("kRequest");
|
| 287 |
+
const kReconnectionTime = Symbol("kReconnectionTime");
|
| 288 |
+
const kLastEventId = Symbol("kLastEventId");
|
| 289 |
+
const kAbortController = Symbol("kAbortController");
|
| 290 |
+
const kOnOpen = Symbol("kOnOpen");
|
| 291 |
+
const kOnMessage = Symbol("kOnMessage");
|
| 292 |
+
const kOnAnyMessage = Symbol("kOnAnyMessage");
|
| 293 |
+
const kOnError = Symbol("kOnError");
|
| 294 |
+
class ObservableEventSource extends EventTarget {
|
| 295 |
+
static CONNECTING = 0;
|
| 296 |
+
static OPEN = 1;
|
| 297 |
+
static CLOSED = 2;
|
| 298 |
+
CONNECTING = ObservableEventSource.CONNECTING;
|
| 299 |
+
OPEN = ObservableEventSource.OPEN;
|
| 300 |
+
CLOSED = ObservableEventSource.CLOSED;
|
| 301 |
+
readyState;
|
| 302 |
+
url;
|
| 303 |
+
withCredentials;
|
| 304 |
+
[kRequest];
|
| 305 |
+
[kReconnectionTime];
|
| 306 |
+
[kLastEventId];
|
| 307 |
+
[kAbortController];
|
| 308 |
+
[kOnOpen] = null;
|
| 309 |
+
[kOnMessage] = null;
|
| 310 |
+
[kOnAnyMessage] = null;
|
| 311 |
+
[kOnError] = null;
|
| 312 |
+
constructor(url, init) {
|
| 313 |
+
super();
|
| 314 |
+
this.url = new URL(url).href;
|
| 315 |
+
this.withCredentials = init?.withCredentials ?? false;
|
| 316 |
+
this.readyState = this.CONNECTING;
|
| 317 |
+
const headers = new Headers(init?.headers || {});
|
| 318 |
+
headers.append("accept", "text/event-stream");
|
| 319 |
+
this[kAbortController] = new AbortController();
|
| 320 |
+
this[kReconnectionTime] = 2e3;
|
| 321 |
+
this[kLastEventId] = "";
|
| 322 |
+
this[kRequest] = new Request(this.url, {
|
| 323 |
+
method: "GET",
|
| 324 |
+
headers,
|
| 325 |
+
credentials: this.withCredentials ? "include" : "omit",
|
| 326 |
+
signal: this[kAbortController].signal
|
| 327 |
+
});
|
| 328 |
+
if (init?.signal) {
|
| 329 |
+
if (init.signal.aborted) {
|
| 330 |
+
this.close();
|
| 331 |
+
return;
|
| 332 |
+
}
|
| 333 |
+
init.signal.addEventListener("abort", () => this.close(), {
|
| 334 |
+
once: true,
|
| 335 |
+
signal: this[kAbortController].signal
|
| 336 |
+
});
|
| 337 |
+
}
|
| 338 |
+
this.connect();
|
| 339 |
+
}
|
| 340 |
+
get onopen() {
|
| 341 |
+
return this[kOnOpen];
|
| 342 |
+
}
|
| 343 |
+
set onopen(handler) {
|
| 344 |
+
if (this[kOnOpen]) {
|
| 345 |
+
this.removeEventListener("open", this[kOnOpen]);
|
| 346 |
+
}
|
| 347 |
+
this[kOnOpen] = handler.bind(this);
|
| 348 |
+
this.addEventListener("open", this[kOnOpen]);
|
| 349 |
+
}
|
| 350 |
+
get onmessage() {
|
| 351 |
+
return this[kOnMessage];
|
| 352 |
+
}
|
| 353 |
+
set onmessage(handler) {
|
| 354 |
+
if (this[kOnMessage]) {
|
| 355 |
+
this.removeEventListener("message", { handleEvent: this[kOnMessage] });
|
| 356 |
+
}
|
| 357 |
+
this[kOnMessage] = handler.bind(this);
|
| 358 |
+
this.addEventListener("message", { handleEvent: this[kOnMessage] });
|
| 359 |
+
}
|
| 360 |
+
get onerror() {
|
| 361 |
+
return this[kOnError];
|
| 362 |
+
}
|
| 363 |
+
set onerror(handler) {
|
| 364 |
+
if (this[kOnError]) {
|
| 365 |
+
this.removeEventListener("error", { handleEvent: this[kOnError] });
|
| 366 |
+
}
|
| 367 |
+
this[kOnError] = handler.bind(this);
|
| 368 |
+
this.addEventListener("error", { handleEvent: this[kOnError] });
|
| 369 |
+
}
|
| 370 |
+
addEventListener(type, listener, options) {
|
| 371 |
+
super.addEventListener(
|
| 372 |
+
type,
|
| 373 |
+
listener,
|
| 374 |
+
options
|
| 375 |
+
);
|
| 376 |
+
}
|
| 377 |
+
removeEventListener(type, listener, options) {
|
| 378 |
+
super.removeEventListener(
|
| 379 |
+
type,
|
| 380 |
+
listener,
|
| 381 |
+
options
|
| 382 |
+
);
|
| 383 |
+
}
|
| 384 |
+
dispatchEvent(event) {
|
| 385 |
+
return super.dispatchEvent(event);
|
| 386 |
+
}
|
| 387 |
+
close() {
|
| 388 |
+
this[kAbortController].abort();
|
| 389 |
+
this.readyState = this.CLOSED;
|
| 390 |
+
}
|
| 391 |
+
async connect() {
|
| 392 |
+
await fetch(this[kRequest]).then((response) => {
|
| 393 |
+
this.processResponse(response);
|
| 394 |
+
}).catch(() => {
|
| 395 |
+
this.failConnection();
|
| 396 |
+
});
|
| 397 |
+
}
|
| 398 |
+
processResponse(response) {
|
| 399 |
+
if (!response.body) {
|
| 400 |
+
this.failConnection();
|
| 401 |
+
return;
|
| 402 |
+
}
|
| 403 |
+
if (isNetworkError(response)) {
|
| 404 |
+
this.reestablishConnection();
|
| 405 |
+
return;
|
| 406 |
+
}
|
| 407 |
+
if (response.status !== 200 || response.headers.get("content-type") !== "text/event-stream") {
|
| 408 |
+
this.failConnection();
|
| 409 |
+
return;
|
| 410 |
+
}
|
| 411 |
+
this.announceConnection();
|
| 412 |
+
this.interpretResponseBody(response);
|
| 413 |
+
}
|
| 414 |
+
announceConnection() {
|
| 415 |
+
queueMicrotask(() => {
|
| 416 |
+
if (this.readyState !== this.CLOSED) {
|
| 417 |
+
this.readyState = this.OPEN;
|
| 418 |
+
this.dispatchEvent(new Event("open"));
|
| 419 |
+
}
|
| 420 |
+
});
|
| 421 |
+
}
|
| 422 |
+
interpretResponseBody(response) {
|
| 423 |
+
const parsingStream = new EventSourceParsingStream({
|
| 424 |
+
message: (message) => {
|
| 425 |
+
if (message.id) {
|
| 426 |
+
this[kLastEventId] = message.id;
|
| 427 |
+
}
|
| 428 |
+
const messageEvent = new MessageEvent(
|
| 429 |
+
message.event ? message.event : "message",
|
| 430 |
+
{
|
| 431 |
+
data: message.data,
|
| 432 |
+
origin: this[kRequest].url,
|
| 433 |
+
lastEventId: this[kLastEventId],
|
| 434 |
+
cancelable: true
|
| 435 |
+
}
|
| 436 |
+
);
|
| 437 |
+
this[kOnAnyMessage]?.(messageEvent);
|
| 438 |
+
this.dispatchEvent(messageEvent);
|
| 439 |
+
},
|
| 440 |
+
retry: (reconnectionTime) => {
|
| 441 |
+
this[kReconnectionTime] = reconnectionTime;
|
| 442 |
+
},
|
| 443 |
+
abort: () => {
|
| 444 |
+
throw new Error("Stream abort is not implemented");
|
| 445 |
+
},
|
| 446 |
+
close: () => {
|
| 447 |
+
this.failConnection();
|
| 448 |
+
}
|
| 449 |
+
});
|
| 450 |
+
response.body.pipeTo(parsingStream).then(() => {
|
| 451 |
+
this.processResponseEndOfBody(response);
|
| 452 |
+
}).catch(() => {
|
| 453 |
+
this.failConnection();
|
| 454 |
+
});
|
| 455 |
+
}
|
| 456 |
+
processResponseEndOfBody(response) {
|
| 457 |
+
if (!isNetworkError(response)) {
|
| 458 |
+
this.reestablishConnection();
|
| 459 |
+
}
|
| 460 |
+
}
|
| 461 |
+
async reestablishConnection() {
|
| 462 |
+
queueMicrotask(() => {
|
| 463 |
+
if (this.readyState === this.CLOSED) {
|
| 464 |
+
return;
|
| 465 |
+
}
|
| 466 |
+
this.readyState = this.CONNECTING;
|
| 467 |
+
this.dispatchEvent(new Event("error"));
|
| 468 |
+
});
|
| 469 |
+
const signal = this[kAbortController].signal;
|
| 470 |
+
if (signal.aborted) {
|
| 471 |
+
return;
|
| 472 |
+
}
|
| 473 |
+
const aborted = new import_deferred_promise.DeferredPromise();
|
| 474 |
+
const onAbort = () => aborted.resolve();
|
| 475 |
+
signal.addEventListener("abort", onAbort, { once: true });
|
| 476 |
+
await Promise.race([(0, import_delay.delay)(this[kReconnectionTime]), aborted]).finally(
|
| 477 |
+
() => {
|
| 478 |
+
signal.removeEventListener("abort", onAbort);
|
| 479 |
+
}
|
| 480 |
+
);
|
| 481 |
+
if (signal.aborted) {
|
| 482 |
+
return;
|
| 483 |
+
}
|
| 484 |
+
queueMicrotask(async () => {
|
| 485 |
+
if (this.readyState !== this.CONNECTING) {
|
| 486 |
+
return;
|
| 487 |
+
}
|
| 488 |
+
if (this[kLastEventId] !== "") {
|
| 489 |
+
this[kRequest].headers.set("last-event-id", this[kLastEventId]);
|
| 490 |
+
}
|
| 491 |
+
await this.connect();
|
| 492 |
+
});
|
| 493 |
+
}
|
| 494 |
+
failConnection() {
|
| 495 |
+
queueMicrotask(() => {
|
| 496 |
+
if (this.readyState !== this.CLOSED) {
|
| 497 |
+
this.readyState = this.CLOSED;
|
| 498 |
+
this.dispatchEvent(new Event("error"));
|
| 499 |
+
}
|
| 500 |
+
});
|
| 501 |
+
}
|
| 502 |
+
}
|
| 503 |
+
function isNetworkError(response) {
|
| 504 |
+
return response.type === "error" && response.status === 0 && response.statusText === "" && Array.from(response.headers.entries()).length === 0 && response.body === null;
|
| 505 |
+
}
|
| 506 |
+
var ControlCharacters = /* @__PURE__ */ ((ControlCharacters2) => {
|
| 507 |
+
ControlCharacters2[ControlCharacters2["NewLine"] = 10] = "NewLine";
|
| 508 |
+
ControlCharacters2[ControlCharacters2["CarriageReturn"] = 13] = "CarriageReturn";
|
| 509 |
+
ControlCharacters2[ControlCharacters2["Space"] = 32] = "Space";
|
| 510 |
+
ControlCharacters2[ControlCharacters2["Colon"] = 58] = "Colon";
|
| 511 |
+
return ControlCharacters2;
|
| 512 |
+
})(ControlCharacters || {});
|
| 513 |
+
class EventSourceParsingStream extends WritableStream {
|
| 514 |
+
constructor(underlyingSink) {
|
| 515 |
+
super({
|
| 516 |
+
write: (chunk) => {
|
| 517 |
+
this.processResponseBodyChunk(chunk);
|
| 518 |
+
},
|
| 519 |
+
abort: (reason) => {
|
| 520 |
+
this.underlyingSink.abort?.(reason);
|
| 521 |
+
},
|
| 522 |
+
close: () => {
|
| 523 |
+
this.underlyingSink.close?.();
|
| 524 |
+
}
|
| 525 |
+
});
|
| 526 |
+
this.underlyingSink = underlyingSink;
|
| 527 |
+
this.decoder = new TextDecoder();
|
| 528 |
+
this.position = 0;
|
| 529 |
+
}
|
| 530 |
+
decoder;
|
| 531 |
+
buffer;
|
| 532 |
+
position;
|
| 533 |
+
fieldLength;
|
| 534 |
+
discardTrailingNewline = false;
|
| 535 |
+
message = {
|
| 536 |
+
id: void 0,
|
| 537 |
+
event: void 0,
|
| 538 |
+
data: void 0
|
| 539 |
+
};
|
| 540 |
+
resetMessage() {
|
| 541 |
+
this.message = {
|
| 542 |
+
id: void 0,
|
| 543 |
+
event: void 0,
|
| 544 |
+
data: void 0
|
| 545 |
+
};
|
| 546 |
+
}
|
| 547 |
+
processResponseBodyChunk(chunk) {
|
| 548 |
+
if (this.buffer == null) {
|
| 549 |
+
this.buffer = chunk;
|
| 550 |
+
this.position = 0;
|
| 551 |
+
this.fieldLength = -1;
|
| 552 |
+
} else {
|
| 553 |
+
const nextBuffer = new Uint8Array(this.buffer.length + chunk.length);
|
| 554 |
+
nextBuffer.set(this.buffer);
|
| 555 |
+
nextBuffer.set(chunk, this.buffer.length);
|
| 556 |
+
this.buffer = nextBuffer;
|
| 557 |
+
}
|
| 558 |
+
const bufferLength = this.buffer.length;
|
| 559 |
+
let lineStart = 0;
|
| 560 |
+
while (this.position < bufferLength) {
|
| 561 |
+
if (this.discardTrailingNewline) {
|
| 562 |
+
if (this.buffer[this.position] === 10 /* NewLine */) {
|
| 563 |
+
lineStart = ++this.position;
|
| 564 |
+
}
|
| 565 |
+
this.discardTrailingNewline = false;
|
| 566 |
+
}
|
| 567 |
+
let lineEnd = -1;
|
| 568 |
+
for (; this.position < bufferLength && lineEnd === -1; ++this.position) {
|
| 569 |
+
switch (this.buffer[this.position]) {
|
| 570 |
+
case 58 /* Colon */: {
|
| 571 |
+
if (this.fieldLength === -1) {
|
| 572 |
+
this.fieldLength = this.position - lineStart;
|
| 573 |
+
}
|
| 574 |
+
break;
|
| 575 |
+
}
|
| 576 |
+
case 13 /* CarriageReturn */: {
|
| 577 |
+
this.discardTrailingNewline = true;
|
| 578 |
+
break;
|
| 579 |
+
}
|
| 580 |
+
case 10 /* NewLine */: {
|
| 581 |
+
lineEnd = this.position;
|
| 582 |
+
break;
|
| 583 |
+
}
|
| 584 |
+
}
|
| 585 |
+
}
|
| 586 |
+
if (lineEnd === -1) {
|
| 587 |
+
break;
|
| 588 |
+
}
|
| 589 |
+
this.processLine(
|
| 590 |
+
this.buffer.subarray(lineStart, lineEnd),
|
| 591 |
+
this.fieldLength
|
| 592 |
+
);
|
| 593 |
+
lineStart = this.position;
|
| 594 |
+
this.fieldLength = -1;
|
| 595 |
+
}
|
| 596 |
+
if (lineStart === bufferLength) {
|
| 597 |
+
this.buffer = void 0;
|
| 598 |
+
} else if (lineStart !== 0) {
|
| 599 |
+
this.buffer = this.buffer.subarray(lineStart);
|
| 600 |
+
this.position -= lineStart;
|
| 601 |
+
}
|
| 602 |
+
}
|
| 603 |
+
processLine(line, fieldLength) {
|
| 604 |
+
if (line.length === 0) {
|
| 605 |
+
if (this.message.data === void 0) {
|
| 606 |
+
this.message.event = void 0;
|
| 607 |
+
return;
|
| 608 |
+
}
|
| 609 |
+
this.underlyingSink.message(this.message);
|
| 610 |
+
this.resetMessage();
|
| 611 |
+
return;
|
| 612 |
+
}
|
| 613 |
+
if (fieldLength > 0) {
|
| 614 |
+
const field = this.decoder.decode(line.subarray(0, fieldLength));
|
| 615 |
+
const valueOffset = fieldLength + (line[fieldLength + 1] === 32 /* Space */ ? 2 : 1);
|
| 616 |
+
const value = this.decoder.decode(line.subarray(valueOffset));
|
| 617 |
+
switch (field) {
|
| 618 |
+
case "data": {
|
| 619 |
+
this.message.data = this.message.data ? this.message.data + "\n" + value : value;
|
| 620 |
+
break;
|
| 621 |
+
}
|
| 622 |
+
case "event": {
|
| 623 |
+
this.message.event = value;
|
| 624 |
+
break;
|
| 625 |
+
}
|
| 626 |
+
case "id": {
|
| 627 |
+
this.message.id = value;
|
| 628 |
+
break;
|
| 629 |
+
}
|
| 630 |
+
case "retry": {
|
| 631 |
+
if (/^\d+$/.test(value)) {
|
| 632 |
+
this.underlyingSink.retry?.(parseInt(value, 10));
|
| 633 |
+
}
|
| 634 |
+
break;
|
| 635 |
+
}
|
| 636 |
+
}
|
| 637 |
+
}
|
| 638 |
+
}
|
| 639 |
+
}
|
| 640 |
+
function createEventStream(request) {
|
| 641 |
+
(0, import_outvariant.invariant)(
|
| 642 |
+
!request.signal.aborted,
|
| 643 |
+
'Failed to call "createEventStream" on the "%s %s" request: request aborted',
|
| 644 |
+
request.method,
|
| 645 |
+
request.url
|
| 646 |
+
);
|
| 647 |
+
const { readable, writable } = new TransformStream();
|
| 648 |
+
const client = new ServerSentEventClient(writable);
|
| 649 |
+
const server = new ServerSentEventServer({
|
| 650 |
+
request,
|
| 651 |
+
client
|
| 652 |
+
});
|
| 653 |
+
const response = new Response(readable, SSE_RESPONSE_INIT);
|
| 654 |
+
request.signal.addEventListener(
|
| 655 |
+
"abort",
|
| 656 |
+
() => {
|
| 657 |
+
client.close();
|
| 658 |
+
},
|
| 659 |
+
{ once: true }
|
| 660 |
+
);
|
| 661 |
+
return {
|
| 662 |
+
client,
|
| 663 |
+
server,
|
| 664 |
+
response
|
| 665 |
+
};
|
| 666 |
+
}
|
| 667 |
+
//# sourceMappingURL=sse.js.map
|
node_modules/msw/lib/core/sse.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../src/core/sse.ts"],"sourcesContent":["import { invariant } from 'outvariant'\nimport { DeferredPromise } from '@open-draft/deferred-promise'\nimport { Emitter } from 'strict-event-emitter'\nimport type { ResponseResolver } from './handlers/RequestHandler'\nimport {\n HttpHandler,\n type HttpRequestResolverExtras,\n type HttpRequestParsedResult,\n} from './handlers/HttpHandler'\nimport type { ResponseResolutionContext } from '#core/utils/executeHandlers'\nimport type { Path, PathParams } from './utils/matching/matchRequestUrl'\nimport { delay } from './delay'\nimport { getTimestamp } from './utils/logging/getTimestamp'\nimport { devUtils } from './utils/internal/devUtils'\nimport { colors } from './ws/utils/attachWebSocketLogger'\nimport { toPublicUrl } from './utils/request/toPublicUrl'\n\ntype EventMapConstraint = {\n message?: unknown\n [key: string]: unknown\n [key: symbol | number]: never\n}\n\nexport type ServerSentEventResolverExtras<\n EventMap extends EventMapConstraint,\n Params extends PathParams,\n> = HttpRequestResolverExtras<Params> & {\n client: ServerSentEventClient<EventMap>\n server: ServerSentEventServer\n}\n\nexport type ServerSentEventResolver<\n EventMap extends EventMapConstraint,\n Params extends PathParams,\n> = ResponseResolver<ServerSentEventResolverExtras<EventMap, Params>, any, any>\n\nexport type ServerSentEventRequestHandler = <\n EventMap extends EventMapConstraint = { message: unknown },\n Params extends PathParams<keyof Params> = PathParams,\n RequestPath extends Path = Path,\n>(\n path: RequestPath,\n resolver: ServerSentEventResolver<EventMap, Params>,\n) => HttpHandler\n\nexport type ServerSentEventMessage<\n EventMap extends EventMapConstraint = { message: unknown },\n> =\n | ToEventDiscriminatedUnion<EventMap & { message: unknown }>\n | {\n id?: never\n event?: never\n data?: never\n retry: number\n }\n\n/**\n * Intercept Server-Sent Events (SSE).\n *\n * @example\n * sse('http://localhost:4321', ({ client }) => {\n * client.send({ data: 'hello world' })\n * })\n *\n * @see {@link https://mswjs.io/docs/sse/ Mocking Server-Sent Events}\n * @see {@link https://mswjs.io/docs/api/sse `sse()` API reference}\n */\nexport const sse: ServerSentEventRequestHandler = (path, resolver) => {\n return new ServerSentEventHandler(path, resolver)\n}\n\nconst SSE_RESPONSE_INIT: ResponseInit = {\n headers: {\n 'content-type': 'text/event-stream',\n 'cache-control': 'no-cache',\n connection: 'keep-alive',\n },\n}\n\nclass ServerSentEventHandler<\n EventMap extends EventMapConstraint,\n> extends HttpHandler {\n #emitter: Emitter<ServerSentEventClientEventMap>\n\n constructor(path: Path, resolver: ServerSentEventResolver<EventMap, any>) {\n invariant(\n typeof EventSource !== 'undefined',\n 'Failed to construct a Server-Sent Event handler for path \"%s\": the EventSource API is not supported in this environment',\n path,\n )\n\n super('GET', path, async (info) => {\n const { client, server, response } = createEventStream<EventMap>(\n info.request,\n )\n\n client[kClientEmitter] = this.#emitter\n\n await resolver({\n ...info,\n client,\n server,\n })\n\n return response\n })\n\n this.#emitter = new Emitter<ServerSentEventClientEventMap>()\n }\n\n async predicate(args: {\n request: Request\n parsedResult: HttpRequestParsedResult\n resolutionContext?: ResponseResolutionContext\n }) {\n if (args.request.headers.get('accept') !== 'text/event-stream') {\n return false\n }\n\n const matches = await super.predicate(args)\n\n if (matches && !args.resolutionContext?.quiet) {\n /**\n * @note Log the intercepted request early.\n * Normally, the `this.log()` method is called when the handler returns a response.\n * For SSE, call that method earlier so the logs are in correct order.\n */\n await super.log({\n request: args.request,\n /**\n * @note Construct a placeholder response since SSE response\n * is being streamed and cannot be cloned/consumed for logging.\n */\n response: new Response('[streaming]', SSE_RESPONSE_INIT),\n })\n\n this.#attachClientLogger(args.request, this.#emitter)\n }\n\n return matches\n }\n\n async log(_args: { request: Request; response: Response }): Promise<void> {\n /**\n * @note Skip the default `this.log()` logic so that when this handler is logged\n * upon handling the request, nothing is printed (we log SSE requests early).\n */\n return\n }\n\n #attachClientLogger(\n request: Request,\n emitter: Emitter<ServerSentEventClientEventMap>,\n ): void {\n const publicUrl = toPublicUrl(request.url)\n\n /* eslint-disable no-console */\n emitter.on('message', (payload) => {\n console.groupCollapsed(\n devUtils.formatMessage(\n `${getTimestamp()} SSE %s %c⇣%c ${payload.event}`,\n ),\n publicUrl,\n `color:${colors.mocked}`,\n 'color:inherit',\n )\n console.log(payload.frames)\n console.groupEnd()\n })\n\n emitter.on('error', () => {\n console.groupCollapsed(\n devUtils.formatMessage(`${getTimestamp()} SSE %s %c\\u00D7%c error`),\n publicUrl,\n `color: ${colors.system}`,\n 'color:inherit',\n )\n console.log('Handler:', this)\n console.groupEnd()\n })\n\n emitter.on('close', () => {\n console.groupCollapsed(\n devUtils.formatMessage(`${getTimestamp()} SSE %s %c■%c close`),\n publicUrl,\n `colors:${colors.system}`,\n 'color:inherit',\n )\n console.log('Handler:', this)\n console.groupEnd()\n })\n /* eslint-enable no-console */\n }\n}\n\ntype Values<T> = T[keyof T]\ntype Identity<T> = { [K in keyof T]: T[K] } & unknown\ntype ToEventDiscriminatedUnion<T> = Values<{\n [K in keyof T]: Identity<\n (K extends 'message'\n ? {\n id?: string\n event?: K\n data?: T[K]\n retry?: never\n }\n : {\n id?: string\n event: K\n data?: T[K]\n retry?: never\n }) &\n // Make the `data` field conditionally required through an intersection.\n (undefined extends T[K] ? unknown : { data: unknown })\n >\n}>\n\ntype ServerSentEventClientEventMap = {\n message: [payload: EventStreamMessage]\n error: []\n close: []\n}\n\nconst kClientEmitter = Symbol.for('kClientEmitter')\n\nclass ServerSentEventClient<\n EventMap extends EventMapConstraint = { message: unknown },\n> {\n private [kClientEmitter]?: Emitter<ServerSentEventClientEventMap>\n\n #encoder: TextEncoder\n #writer: WritableStreamDefaultWriter\n\n constructor(writable: WritableStream) {\n this.#encoder = new TextEncoder()\n this.#writer = writable.getWriter()\n }\n\n /**\n * Sends the given payload to the intercepted `EventSource`.\n */\n public send(payload: ServerSentEventMessage<EventMap>): void {\n if ('retry' in payload && payload.retry != null) {\n this.#sendRetry(payload.retry)\n return\n }\n\n this.#sendMessage({\n id: payload.id,\n event: payload.event,\n data:\n typeof payload.data === 'object'\n ? JSON.stringify(payload.data)\n : payload.data,\n })\n }\n\n /**\n * Dispatches the given event on the intercepted `EventSource`.\n */\n public dispatchEvent(event: Event) {\n if (event instanceof MessageEvent) {\n /**\n * @note Use the internal send mechanism to skip normalization\n * of the message data (already normalized by the server).\n */\n this.#sendMessage({\n id: event.lastEventId || undefined,\n event: event.type === 'message' ? undefined : event.type,\n data: event.data,\n })\n return\n }\n\n if (event.type === 'error') {\n this.error()\n return\n }\n\n if (event.type === 'close') {\n this.close()\n return\n }\n }\n\n /**\n * Errors the underlying `EventSource`, closing the connection with an error.\n * This is equivalent to aborting the connection and will produce a `TypeError: Failed to fetch`\n * error.\n */\n public error(): void {\n this.#writer.abort().catch((error) => {\n console.error(error)\n devUtils.error(\n 'Failed to abort server-side EventSource. Please see the original error above.',\n )\n })\n this[kClientEmitter]?.emit('error')\n }\n\n /**\n * Closes the underlying `EventSource`, closing the connection.\n */\n public close(): void {\n this.#writer.close().catch((error) => {\n console.error(error)\n devUtils.error(\n 'Failed to close server-side EventSource. Please see the original error above.',\n )\n })\n this[kClientEmitter]?.emit('close')\n }\n\n #sendRetry(retry: number): void {\n this.#writer\n .write(this.#encoder.encode(`retry:${retry}\\n\\n`))\n .catch((error) => {\n console.error(error)\n devUtils.error(\n 'Failed to send a retry packet to server-side EventSource. Please see the original error above.',\n )\n })\n }\n\n #sendMessage(message: {\n id?: string\n event?: unknown\n data: unknown | undefined\n }): void {\n const frames: Array<string> = []\n\n if (message.id) {\n frames.push(`id:${message.id}`)\n }\n\n if (message.event) {\n frames.push(`event:${message.event.toString()}`)\n }\n\n if (message.data != null) {\n /**\n * Split data on line terminators (LF, CR, or CRLF) and translate them to individual frames.\n * @see https://html.spec.whatwg.org/multipage/server-sent-events.html#event-stream-interpretation\n * @see https://html.spec.whatwg.org/multipage/server-sent-events.html#parsing-an-event-stream\n */\n for (const line of message.data.toString().split(/\\r\\n|\\r|\\n/)) {\n frames.push(`data:${line}`)\n }\n }\n\n frames.push('', '')\n\n this.#writer\n .write(this.#encoder.encode(frames.join('\\n')))\n .catch((error) => {\n console.error(error)\n devUtils.error(\n 'Failed to send a message to server-side EventSource. Please see the original error above.',\n )\n })\n\n this[kClientEmitter]?.emit('message', {\n id: message.id,\n event: message.event?.toString() || 'message',\n data: message.data,\n frames,\n })\n }\n}\n\nclass ServerSentEventServer {\n #request: Request\n #client: ServerSentEventClient<ServerSentEventClientEventMap>\n\n constructor(args: { request: Request; client: ServerSentEventClient<any> }) {\n this.#request = args.request\n this.#client = args.client\n }\n\n /**\n * Establishes the actual connection for this SSE request\n * and returns the `EventSource` instance.\n */\n public connect(): EventSource {\n const source = new ObservableEventSource(this.#request.url, {\n withCredentials: this.#request.credentials === 'include',\n headers: {\n /**\n * @note Mark this request as passthrough so it doesn't trigger\n * an infinite loop matching against the existing request handler.\n */\n accept: 'msw/passthrough',\n },\n signal: this.#request.signal,\n })\n\n source[kOnAnyMessage] = (event) => {\n Object.defineProperties(event, {\n target: {\n value: this,\n enumerable: true,\n writable: true,\n configurable: true,\n },\n })\n\n // Schedule the server-to-client forwarding for the next tick\n // so the user can prevent the message event.\n queueMicrotask(() => {\n if (!event.defaultPrevented) {\n this.#client.dispatchEvent(event)\n }\n })\n }\n\n // Forward stream errors from the actual server to the client.\n source.addEventListener('error', (event) => {\n Object.defineProperties(event, {\n target: {\n value: this,\n enumerable: true,\n writable: true,\n configurable: true,\n },\n })\n\n queueMicrotask(() => {\n // Allow the user to opt-out from this forwarding.\n if (!event.defaultPrevented) {\n this.#client.dispatchEvent(event)\n }\n })\n })\n\n return source\n }\n}\n\ninterface ObservableEventSourceInit extends EventSourceInit {\n headers?: HeadersInit\n signal?: AbortSignal\n}\n\ntype EventHandler<EventType extends Event> = (\n this: EventSource,\n event: EventType,\n) => any\n\nconst kRequest = Symbol('kRequest')\nconst kReconnectionTime = Symbol('kReconnectionTime')\nconst kLastEventId = Symbol('kLastEventId')\nconst kAbortController = Symbol('kAbortController')\nconst kOnOpen = Symbol('kOnOpen')\nconst kOnMessage = Symbol('kOnMessage')\nconst kOnAnyMessage = Symbol('kOnAnyMessage')\nconst kOnError = Symbol('kOnError')\n\nclass ObservableEventSource extends EventTarget implements EventSource {\n static readonly CONNECTING = 0\n static readonly OPEN = 1\n static readonly CLOSED = 2\n\n public readonly CONNECTING = ObservableEventSource.CONNECTING\n public readonly OPEN = ObservableEventSource.OPEN\n public readonly CLOSED = ObservableEventSource.CLOSED\n\n public readyState: number\n public url: string\n public withCredentials: boolean\n\n private [kRequest]: Request\n private [kReconnectionTime]: number\n private [kLastEventId]: string\n private [kAbortController]: AbortController\n private [kOnOpen]: EventHandler<Event> | null = null\n private [kOnMessage]: EventHandler<MessageEvent> | null = null\n private [kOnAnyMessage]: EventHandler<MessageEvent> | null = null\n private [kOnError]: EventHandler<Event> | null = null\n\n constructor(url: string | URL, init?: ObservableEventSourceInit) {\n super()\n\n this.url = new URL(url).href\n this.withCredentials = init?.withCredentials ?? false\n\n this.readyState = this.CONNECTING\n\n // Support custom request init.\n const headers = new Headers(init?.headers || {})\n headers.append('accept', 'text/event-stream')\n\n this[kAbortController] = new AbortController()\n this[kReconnectionTime] = 2000\n this[kLastEventId] = ''\n this[kRequest] = new Request(this.url, {\n method: 'GET',\n headers,\n credentials: this.withCredentials ? 'include' : 'omit',\n signal: this[kAbortController].signal,\n })\n\n if (init?.signal) {\n if (init.signal.aborted) {\n this.close()\n return\n }\n\n init.signal.addEventListener('abort', () => this.close(), {\n once: true,\n signal: this[kAbortController].signal,\n })\n }\n\n this.connect()\n }\n\n get onopen(): EventHandler<Event> | null {\n return this[kOnOpen]\n }\n\n set onopen(handler: EventHandler<Event>) {\n if (this[kOnOpen]) {\n this.removeEventListener('open', this[kOnOpen])\n }\n this[kOnOpen] = handler.bind(this)\n this.addEventListener('open', this[kOnOpen])\n }\n\n get onmessage(): EventHandler<MessageEvent> | null {\n return this[kOnMessage]\n }\n set onmessage(handler: EventHandler<MessageEvent>) {\n if (this[kOnMessage]) {\n this.removeEventListener('message', { handleEvent: this[kOnMessage] })\n }\n this[kOnMessage] = handler.bind(this)\n this.addEventListener('message', { handleEvent: this[kOnMessage] })\n }\n\n get onerror(): EventHandler<Event> | null {\n return this[kOnError]\n }\n set onerror(handler: EventHandler<Event>) {\n if (this[kOnError]) {\n this.removeEventListener('error', { handleEvent: this[kOnError] })\n }\n this[kOnError] = handler.bind(this)\n this.addEventListener('error', { handleEvent: this[kOnError] })\n }\n\n public addEventListener<K extends keyof EventSourceEventMap>(\n type: K,\n listener: EventHandler<EventSourceEventMap[K]>,\n options?: boolean | AddEventListenerOptions,\n ): void\n public addEventListener(\n type: string,\n listener: EventHandler<MessageEvent>,\n options?: boolean | AddEventListenerOptions,\n ): void\n public addEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | AddEventListenerOptions,\n ): void\n\n public addEventListener(\n type: string,\n listener: EventHandler<MessageEvent> | EventListenerOrEventListenerObject,\n options?: boolean | AddEventListenerOptions,\n ): void {\n super.addEventListener(\n type,\n listener as EventListenerOrEventListenerObject,\n options,\n )\n }\n\n public removeEventListener<K extends keyof EventSourceEventMap>(\n type: K,\n listener: (this: EventSource, ev: EventSourceEventMap[K]) => any,\n options?: boolean | EventListenerOptions,\n ): void\n public removeEventListener(\n type: string,\n listener: (this: EventSource, event: MessageEvent) => any,\n options?: boolean | EventListenerOptions,\n ): void\n public removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | EventListenerOptions,\n ): void\n\n public removeEventListener(\n type: string,\n listener: EventHandler<MessageEvent> | EventListenerOrEventListenerObject,\n options?: boolean | AddEventListenerOptions,\n ): void {\n super.removeEventListener(\n type,\n listener as EventListenerOrEventListenerObject,\n options,\n )\n }\n\n public dispatchEvent(event: Event): boolean {\n return super.dispatchEvent(event)\n }\n\n public close(): void {\n this[kAbortController].abort()\n this.readyState = this.CLOSED\n }\n\n private async connect() {\n await fetch(this[kRequest])\n .then((response) => {\n this.processResponse(response)\n })\n .catch(() => {\n // Fail the connection on request errors instead of\n // throwing a generic \"Failed to fetch\" error.\n this.failConnection()\n })\n }\n\n private processResponse(response: Response): void {\n if (!response.body) {\n this.failConnection()\n return\n }\n\n if (isNetworkError(response)) {\n this.reestablishConnection()\n return\n }\n\n if (\n response.status !== 200 ||\n response.headers.get('content-type') !== 'text/event-stream'\n ) {\n this.failConnection()\n return\n }\n\n this.announceConnection()\n this.interpretResponseBody(response)\n }\n\n private announceConnection(): void {\n queueMicrotask(() => {\n if (this.readyState !== this.CLOSED) {\n this.readyState = this.OPEN\n this.dispatchEvent(new Event('open'))\n }\n })\n }\n\n private interpretResponseBody(response: Response): void {\n const parsingStream = new EventSourceParsingStream({\n message: (message) => {\n if (message.id) {\n this[kLastEventId] = message.id\n }\n\n const messageEvent = new MessageEvent(\n message.event ? message.event : 'message',\n {\n data: message.data,\n origin: this[kRequest].url,\n lastEventId: this[kLastEventId],\n cancelable: true,\n },\n )\n\n this[kOnAnyMessage]?.(messageEvent)\n this.dispatchEvent(messageEvent)\n },\n retry: (reconnectionTime) => {\n this[kReconnectionTime] = reconnectionTime\n },\n abort: () => {\n throw new Error('Stream abort is not implemented')\n },\n close: () => {\n this.failConnection()\n },\n })\n\n response\n .body!.pipeTo(parsingStream)\n .then(() => {\n this.processResponseEndOfBody(response)\n })\n .catch(() => {\n this.failConnection()\n })\n }\n\n private processResponseEndOfBody(response: Response): void {\n if (!isNetworkError(response)) {\n this.reestablishConnection()\n }\n }\n\n private async reestablishConnection(): Promise<void> {\n queueMicrotask(() => {\n if (this.readyState === this.CLOSED) {\n return\n }\n\n this.readyState = this.CONNECTING\n this.dispatchEvent(new Event('error'))\n })\n\n const signal = this[kAbortController].signal\n\n if (signal.aborted) {\n return\n }\n\n const aborted = new DeferredPromise<void>()\n const onAbort = () => aborted.resolve()\n signal.addEventListener('abort', onAbort, { once: true })\n\n await Promise.race([delay(this[kReconnectionTime]), aborted]).finally(\n () => {\n signal.removeEventListener('abort', onAbort)\n },\n )\n\n if (signal.aborted) {\n return\n }\n\n queueMicrotask(async () => {\n if (this.readyState !== this.CONNECTING) {\n return\n }\n\n if (this[kLastEventId] !== '') {\n this[kRequest].headers.set('last-event-id', this[kLastEventId])\n }\n\n await this.connect()\n })\n }\n\n private failConnection(): void {\n queueMicrotask(() => {\n if (this.readyState !== this.CLOSED) {\n this.readyState = this.CLOSED\n this.dispatchEvent(new Event('error'))\n }\n })\n }\n}\n\n/**\n * Checks if the given `Response` instance is a network error.\n * @see https://fetch.spec.whatwg.org/#concept-network-error\n */\nfunction isNetworkError(response: Response): boolean {\n return (\n response.type === 'error' &&\n response.status === 0 &&\n response.statusText === '' &&\n Array.from(response.headers.entries()).length === 0 &&\n response.body === null\n )\n}\n\nconst enum ControlCharacters {\n NewLine = 10,\n CarriageReturn = 13,\n Space = 32,\n Colon = 58,\n}\n\ninterface EventSourceMessage {\n id?: string\n event?: string\n data?: string\n}\n\nclass EventSourceParsingStream extends WritableStream {\n private decoder: TextDecoder\n\n private buffer?: Uint8Array\n private position: number\n private fieldLength?: number\n private discardTrailingNewline = false\n\n private message: EventSourceMessage = {\n id: undefined,\n event: undefined,\n data: undefined,\n }\n\n constructor(\n private underlyingSink: {\n message: (message: EventSourceMessage) => void\n retry?: (reconnectionTime: number) => void\n abort?: (reason: any) => void\n close?: () => void\n },\n ) {\n super({\n write: (chunk) => {\n this.processResponseBodyChunk(chunk)\n },\n abort: (reason) => {\n this.underlyingSink.abort?.(reason)\n },\n close: () => {\n this.underlyingSink.close?.()\n },\n })\n\n this.decoder = new TextDecoder()\n this.position = 0\n }\n\n private resetMessage(): void {\n this.message = {\n id: undefined,\n event: undefined,\n data: undefined,\n }\n }\n\n private processResponseBodyChunk(chunk: Uint8Array): void {\n if (this.buffer == null) {\n this.buffer = chunk\n this.position = 0\n this.fieldLength = -1\n } else {\n const nextBuffer = new Uint8Array(this.buffer.length + chunk.length)\n nextBuffer.set(this.buffer)\n nextBuffer.set(chunk, this.buffer.length)\n this.buffer = nextBuffer\n }\n\n const bufferLength = this.buffer.length\n let lineStart = 0\n\n while (this.position < bufferLength) {\n if (this.discardTrailingNewline) {\n if (this.buffer[this.position] === ControlCharacters.NewLine) {\n lineStart = ++this.position\n }\n\n this.discardTrailingNewline = false\n }\n\n let lineEnd = -1\n\n for (; this.position < bufferLength && lineEnd === -1; ++this.position) {\n switch (this.buffer[this.position]) {\n case ControlCharacters.Colon: {\n if (this.fieldLength === -1) {\n this.fieldLength = this.position - lineStart\n }\n break\n }\n\n case ControlCharacters.CarriageReturn: {\n this.discardTrailingNewline = true\n break\n }\n\n case ControlCharacters.NewLine: {\n lineEnd = this.position\n break\n }\n }\n }\n\n if (lineEnd === -1) {\n break\n }\n\n this.processLine(\n this.buffer.subarray(lineStart, lineEnd),\n this.fieldLength!,\n )\n\n lineStart = this.position\n this.fieldLength = -1\n }\n\n if (lineStart === bufferLength) {\n this.buffer = undefined\n } else if (lineStart !== 0) {\n this.buffer = this.buffer.subarray(lineStart)\n this.position -= lineStart\n }\n }\n\n private processLine(line: Uint8Array, fieldLength: number): void {\n // New line indicates the end of the message. Dispatch it.\n if (line.length === 0) {\n // Prevent dispatching the message if the data is an empty string.\n // That is a no-op per spec.\n if (this.message.data === undefined) {\n this.message.event = undefined\n return\n }\n\n this.underlyingSink.message(this.message)\n this.resetMessage()\n return\n }\n\n // Otherwise, keep accumulating message fields until the new line.\n if (fieldLength > 0) {\n const field = this.decoder.decode(line.subarray(0, fieldLength))\n const valueOffset =\n fieldLength +\n (line[fieldLength + 1] === ControlCharacters.Space ? 2 : 1)\n const value = this.decoder.decode(line.subarray(valueOffset))\n\n switch (field) {\n case 'data': {\n this.message.data = this.message.data\n ? this.message.data + '\\n' + value\n : value\n break\n }\n\n case 'event': {\n this.message.event = value\n break\n }\n\n case 'id': {\n this.message.id = value\n break\n }\n\n case 'retry': {\n /**\n * Apply the retry immediately. Don't buffer onto the current message.\n * @see https://html.spec.whatwg.org/multipage/server-sent-events.html#event-stream-interpretation\n */\n if (/^\\d+$/.test(value)) {\n this.underlyingSink.retry?.(parseInt(value, 10))\n }\n break\n }\n }\n }\n }\n}\n\ninterface EventStreamMessage {\n id?: string\n event: string\n data?: unknown\n frames: Array<string>\n}\n\ninterface EventStream<EventMap extends EventMapConstraint> {\n client: ServerSentEventClient<EventMap>\n server: ServerSentEventServer\n response: Response\n}\n\n/**\n * Create an event stream out of the given Fetch API `Request`.\n * Returns the following properties:\n * - `client`, to operate on the intercepted request;\n * - `server`, to establish and manage the actual server connection;\n * - `response`, a `Response` to use as the mock response's body.\n *\n * @example\n * http.post('/resource', ({ request }) => {\n * const { client, server, response } = createEventStream(request)\n * client.send({ data: 'hello world' })\n * return response\n * })\n */\nfunction createEventStream<EventMap extends EventMapConstraint>(\n request: Request,\n): EventStream<EventMap> {\n invariant(\n !request.signal.aborted,\n 'Failed to call \"createEventStream\" on the \"%s %s\" request: request aborted',\n request.method,\n request.url,\n )\n\n const { readable, writable } = new TransformStream()\n\n const client = new ServerSentEventClient<EventMap>(writable)\n const server = new ServerSentEventServer({\n request,\n client,\n })\n\n const response = new Response(readable, SSE_RESPONSE_INIT)\n\n request.signal.addEventListener(\n 'abort',\n () => {\n client.close()\n },\n { once: true },\n )\n\n return {\n client,\n server,\n response,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAA0B;AAC1B,8BAAgC;AAChC,kCAAwB;AAExB,yBAIO;AAGP,mBAAsB;AACtB,0BAA6B;AAC7B,sBAAyB;AACz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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { invariant } from "outvariant";
|
| 2 |
+
import { DeferredPromise } from "@open-draft/deferred-promise";
|
| 3 |
+
import { Emitter } from "strict-event-emitter";
|
| 4 |
+
import {
|
| 5 |
+
HttpHandler
|
| 6 |
+
} from './handlers/HttpHandler.mjs';
|
| 7 |
+
import { delay } from './delay.mjs';
|
| 8 |
+
import { getTimestamp } from './utils/logging/getTimestamp.mjs';
|
| 9 |
+
import { devUtils } from './utils/internal/devUtils.mjs';
|
| 10 |
+
import { colors } from './ws/utils/attachWebSocketLogger.mjs';
|
| 11 |
+
import { toPublicUrl } from './utils/request/toPublicUrl.mjs';
|
| 12 |
+
const sse = (path, resolver) => {
|
| 13 |
+
return new ServerSentEventHandler(path, resolver);
|
| 14 |
+
};
|
| 15 |
+
const SSE_RESPONSE_INIT = {
|
| 16 |
+
headers: {
|
| 17 |
+
"content-type": "text/event-stream",
|
| 18 |
+
"cache-control": "no-cache",
|
| 19 |
+
connection: "keep-alive"
|
| 20 |
+
}
|
| 21 |
+
};
|
| 22 |
+
class ServerSentEventHandler extends HttpHandler {
|
| 23 |
+
#emitter;
|
| 24 |
+
constructor(path, resolver) {
|
| 25 |
+
invariant(
|
| 26 |
+
typeof EventSource !== "undefined",
|
| 27 |
+
'Failed to construct a Server-Sent Event handler for path "%s": the EventSource API is not supported in this environment',
|
| 28 |
+
path
|
| 29 |
+
);
|
| 30 |
+
super("GET", path, async (info) => {
|
| 31 |
+
const { client, server, response } = createEventStream(
|
| 32 |
+
info.request
|
| 33 |
+
);
|
| 34 |
+
client[kClientEmitter] = this.#emitter;
|
| 35 |
+
await resolver({
|
| 36 |
+
...info,
|
| 37 |
+
client,
|
| 38 |
+
server
|
| 39 |
+
});
|
| 40 |
+
return response;
|
| 41 |
+
});
|
| 42 |
+
this.#emitter = new Emitter();
|
| 43 |
+
}
|
| 44 |
+
async predicate(args) {
|
| 45 |
+
if (args.request.headers.get("accept") !== "text/event-stream") {
|
| 46 |
+
return false;
|
| 47 |
+
}
|
| 48 |
+
const matches = await super.predicate(args);
|
| 49 |
+
if (matches && !args.resolutionContext?.quiet) {
|
| 50 |
+
await super.log({
|
| 51 |
+
request: args.request,
|
| 52 |
+
/**
|
| 53 |
+
* @note Construct a placeholder response since SSE response
|
| 54 |
+
* is being streamed and cannot be cloned/consumed for logging.
|
| 55 |
+
*/
|
| 56 |
+
response: new Response("[streaming]", SSE_RESPONSE_INIT)
|
| 57 |
+
});
|
| 58 |
+
this.#attachClientLogger(args.request, this.#emitter);
|
| 59 |
+
}
|
| 60 |
+
return matches;
|
| 61 |
+
}
|
| 62 |
+
async log(_args) {
|
| 63 |
+
return;
|
| 64 |
+
}
|
| 65 |
+
#attachClientLogger(request, emitter) {
|
| 66 |
+
const publicUrl = toPublicUrl(request.url);
|
| 67 |
+
emitter.on("message", (payload) => {
|
| 68 |
+
console.groupCollapsed(
|
| 69 |
+
devUtils.formatMessage(
|
| 70 |
+
`${getTimestamp()} SSE %s %c\u21E3%c ${payload.event}`
|
| 71 |
+
),
|
| 72 |
+
publicUrl,
|
| 73 |
+
`color:${colors.mocked}`,
|
| 74 |
+
"color:inherit"
|
| 75 |
+
);
|
| 76 |
+
console.log(payload.frames);
|
| 77 |
+
console.groupEnd();
|
| 78 |
+
});
|
| 79 |
+
emitter.on("error", () => {
|
| 80 |
+
console.groupCollapsed(
|
| 81 |
+
devUtils.formatMessage(`${getTimestamp()} SSE %s %c\xD7%c error`),
|
| 82 |
+
publicUrl,
|
| 83 |
+
`color: ${colors.system}`,
|
| 84 |
+
"color:inherit"
|
| 85 |
+
);
|
| 86 |
+
console.log("Handler:", this);
|
| 87 |
+
console.groupEnd();
|
| 88 |
+
});
|
| 89 |
+
emitter.on("close", () => {
|
| 90 |
+
console.groupCollapsed(
|
| 91 |
+
devUtils.formatMessage(`${getTimestamp()} SSE %s %c\u25A0%c close`),
|
| 92 |
+
publicUrl,
|
| 93 |
+
`colors:${colors.system}`,
|
| 94 |
+
"color:inherit"
|
| 95 |
+
);
|
| 96 |
+
console.log("Handler:", this);
|
| 97 |
+
console.groupEnd();
|
| 98 |
+
});
|
| 99 |
+
}
|
| 100 |
+
}
|
| 101 |
+
const kClientEmitter = Symbol.for("kClientEmitter");
|
| 102 |
+
class ServerSentEventClient {
|
| 103 |
+
[kClientEmitter];
|
| 104 |
+
#encoder;
|
| 105 |
+
#writer;
|
| 106 |
+
constructor(writable) {
|
| 107 |
+
this.#encoder = new TextEncoder();
|
| 108 |
+
this.#writer = writable.getWriter();
|
| 109 |
+
}
|
| 110 |
+
/**
|
| 111 |
+
* Sends the given payload to the intercepted `EventSource`.
|
| 112 |
+
*/
|
| 113 |
+
send(payload) {
|
| 114 |
+
if ("retry" in payload && payload.retry != null) {
|
| 115 |
+
this.#sendRetry(payload.retry);
|
| 116 |
+
return;
|
| 117 |
+
}
|
| 118 |
+
this.#sendMessage({
|
| 119 |
+
id: payload.id,
|
| 120 |
+
event: payload.event,
|
| 121 |
+
data: typeof payload.data === "object" ? JSON.stringify(payload.data) : payload.data
|
| 122 |
+
});
|
| 123 |
+
}
|
| 124 |
+
/**
|
| 125 |
+
* Dispatches the given event on the intercepted `EventSource`.
|
| 126 |
+
*/
|
| 127 |
+
dispatchEvent(event) {
|
| 128 |
+
if (event instanceof MessageEvent) {
|
| 129 |
+
this.#sendMessage({
|
| 130 |
+
id: event.lastEventId || void 0,
|
| 131 |
+
event: event.type === "message" ? void 0 : event.type,
|
| 132 |
+
data: event.data
|
| 133 |
+
});
|
| 134 |
+
return;
|
| 135 |
+
}
|
| 136 |
+
if (event.type === "error") {
|
| 137 |
+
this.error();
|
| 138 |
+
return;
|
| 139 |
+
}
|
| 140 |
+
if (event.type === "close") {
|
| 141 |
+
this.close();
|
| 142 |
+
return;
|
| 143 |
+
}
|
| 144 |
+
}
|
| 145 |
+
/**
|
| 146 |
+
* Errors the underlying `EventSource`, closing the connection with an error.
|
| 147 |
+
* This is equivalent to aborting the connection and will produce a `TypeError: Failed to fetch`
|
| 148 |
+
* error.
|
| 149 |
+
*/
|
| 150 |
+
error() {
|
| 151 |
+
this.#writer.abort().catch((error) => {
|
| 152 |
+
console.error(error);
|
| 153 |
+
devUtils.error(
|
| 154 |
+
"Failed to abort server-side EventSource. Please see the original error above."
|
| 155 |
+
);
|
| 156 |
+
});
|
| 157 |
+
this[kClientEmitter]?.emit("error");
|
| 158 |
+
}
|
| 159 |
+
/**
|
| 160 |
+
* Closes the underlying `EventSource`, closing the connection.
|
| 161 |
+
*/
|
| 162 |
+
close() {
|
| 163 |
+
this.#writer.close().catch((error) => {
|
| 164 |
+
console.error(error);
|
| 165 |
+
devUtils.error(
|
| 166 |
+
"Failed to close server-side EventSource. Please see the original error above."
|
| 167 |
+
);
|
| 168 |
+
});
|
| 169 |
+
this[kClientEmitter]?.emit("close");
|
| 170 |
+
}
|
| 171 |
+
#sendRetry(retry) {
|
| 172 |
+
this.#writer.write(this.#encoder.encode(`retry:${retry}
|
| 173 |
+
|
| 174 |
+
`)).catch((error) => {
|
| 175 |
+
console.error(error);
|
| 176 |
+
devUtils.error(
|
| 177 |
+
"Failed to send a retry packet to server-side EventSource. Please see the original error above."
|
| 178 |
+
);
|
| 179 |
+
});
|
| 180 |
+
}
|
| 181 |
+
#sendMessage(message) {
|
| 182 |
+
const frames = [];
|
| 183 |
+
if (message.id) {
|
| 184 |
+
frames.push(`id:${message.id}`);
|
| 185 |
+
}
|
| 186 |
+
if (message.event) {
|
| 187 |
+
frames.push(`event:${message.event.toString()}`);
|
| 188 |
+
}
|
| 189 |
+
if (message.data != null) {
|
| 190 |
+
for (const line of message.data.toString().split(/\r\n|\r|\n/)) {
|
| 191 |
+
frames.push(`data:${line}`);
|
| 192 |
+
}
|
| 193 |
+
}
|
| 194 |
+
frames.push("", "");
|
| 195 |
+
this.#writer.write(this.#encoder.encode(frames.join("\n"))).catch((error) => {
|
| 196 |
+
console.error(error);
|
| 197 |
+
devUtils.error(
|
| 198 |
+
"Failed to send a message to server-side EventSource. Please see the original error above."
|
| 199 |
+
);
|
| 200 |
+
});
|
| 201 |
+
this[kClientEmitter]?.emit("message", {
|
| 202 |
+
id: message.id,
|
| 203 |
+
event: message.event?.toString() || "message",
|
| 204 |
+
data: message.data,
|
| 205 |
+
frames
|
| 206 |
+
});
|
| 207 |
+
}
|
| 208 |
+
}
|
| 209 |
+
class ServerSentEventServer {
|
| 210 |
+
#request;
|
| 211 |
+
#client;
|
| 212 |
+
constructor(args) {
|
| 213 |
+
this.#request = args.request;
|
| 214 |
+
this.#client = args.client;
|
| 215 |
+
}
|
| 216 |
+
/**
|
| 217 |
+
* Establishes the actual connection for this SSE request
|
| 218 |
+
* and returns the `EventSource` instance.
|
| 219 |
+
*/
|
| 220 |
+
connect() {
|
| 221 |
+
const source = new ObservableEventSource(this.#request.url, {
|
| 222 |
+
withCredentials: this.#request.credentials === "include",
|
| 223 |
+
headers: {
|
| 224 |
+
/**
|
| 225 |
+
* @note Mark this request as passthrough so it doesn't trigger
|
| 226 |
+
* an infinite loop matching against the existing request handler.
|
| 227 |
+
*/
|
| 228 |
+
accept: "msw/passthrough"
|
| 229 |
+
},
|
| 230 |
+
signal: this.#request.signal
|
| 231 |
+
});
|
| 232 |
+
source[kOnAnyMessage] = (event) => {
|
| 233 |
+
Object.defineProperties(event, {
|
| 234 |
+
target: {
|
| 235 |
+
value: this,
|
| 236 |
+
enumerable: true,
|
| 237 |
+
writable: true,
|
| 238 |
+
configurable: true
|
| 239 |
+
}
|
| 240 |
+
});
|
| 241 |
+
queueMicrotask(() => {
|
| 242 |
+
if (!event.defaultPrevented) {
|
| 243 |
+
this.#client.dispatchEvent(event);
|
| 244 |
+
}
|
| 245 |
+
});
|
| 246 |
+
};
|
| 247 |
+
source.addEventListener("error", (event) => {
|
| 248 |
+
Object.defineProperties(event, {
|
| 249 |
+
target: {
|
| 250 |
+
value: this,
|
| 251 |
+
enumerable: true,
|
| 252 |
+
writable: true,
|
| 253 |
+
configurable: true
|
| 254 |
+
}
|
| 255 |
+
});
|
| 256 |
+
queueMicrotask(() => {
|
| 257 |
+
if (!event.defaultPrevented) {
|
| 258 |
+
this.#client.dispatchEvent(event);
|
| 259 |
+
}
|
| 260 |
+
});
|
| 261 |
+
});
|
| 262 |
+
return source;
|
| 263 |
+
}
|
| 264 |
+
}
|
| 265 |
+
const kRequest = Symbol("kRequest");
|
| 266 |
+
const kReconnectionTime = Symbol("kReconnectionTime");
|
| 267 |
+
const kLastEventId = Symbol("kLastEventId");
|
| 268 |
+
const kAbortController = Symbol("kAbortController");
|
| 269 |
+
const kOnOpen = Symbol("kOnOpen");
|
| 270 |
+
const kOnMessage = Symbol("kOnMessage");
|
| 271 |
+
const kOnAnyMessage = Symbol("kOnAnyMessage");
|
| 272 |
+
const kOnError = Symbol("kOnError");
|
| 273 |
+
class ObservableEventSource extends EventTarget {
|
| 274 |
+
static CONNECTING = 0;
|
| 275 |
+
static OPEN = 1;
|
| 276 |
+
static CLOSED = 2;
|
| 277 |
+
CONNECTING = ObservableEventSource.CONNECTING;
|
| 278 |
+
OPEN = ObservableEventSource.OPEN;
|
| 279 |
+
CLOSED = ObservableEventSource.CLOSED;
|
| 280 |
+
readyState;
|
| 281 |
+
url;
|
| 282 |
+
withCredentials;
|
| 283 |
+
[kRequest];
|
| 284 |
+
[kReconnectionTime];
|
| 285 |
+
[kLastEventId];
|
| 286 |
+
[kAbortController];
|
| 287 |
+
[kOnOpen] = null;
|
| 288 |
+
[kOnMessage] = null;
|
| 289 |
+
[kOnAnyMessage] = null;
|
| 290 |
+
[kOnError] = null;
|
| 291 |
+
constructor(url, init) {
|
| 292 |
+
super();
|
| 293 |
+
this.url = new URL(url).href;
|
| 294 |
+
this.withCredentials = init?.withCredentials ?? false;
|
| 295 |
+
this.readyState = this.CONNECTING;
|
| 296 |
+
const headers = new Headers(init?.headers || {});
|
| 297 |
+
headers.append("accept", "text/event-stream");
|
| 298 |
+
this[kAbortController] = new AbortController();
|
| 299 |
+
this[kReconnectionTime] = 2e3;
|
| 300 |
+
this[kLastEventId] = "";
|
| 301 |
+
this[kRequest] = new Request(this.url, {
|
| 302 |
+
method: "GET",
|
| 303 |
+
headers,
|
| 304 |
+
credentials: this.withCredentials ? "include" : "omit",
|
| 305 |
+
signal: this[kAbortController].signal
|
| 306 |
+
});
|
| 307 |
+
if (init?.signal) {
|
| 308 |
+
if (init.signal.aborted) {
|
| 309 |
+
this.close();
|
| 310 |
+
return;
|
| 311 |
+
}
|
| 312 |
+
init.signal.addEventListener("abort", () => this.close(), {
|
| 313 |
+
once: true,
|
| 314 |
+
signal: this[kAbortController].signal
|
| 315 |
+
});
|
| 316 |
+
}
|
| 317 |
+
this.connect();
|
| 318 |
+
}
|
| 319 |
+
get onopen() {
|
| 320 |
+
return this[kOnOpen];
|
| 321 |
+
}
|
| 322 |
+
set onopen(handler) {
|
| 323 |
+
if (this[kOnOpen]) {
|
| 324 |
+
this.removeEventListener("open", this[kOnOpen]);
|
| 325 |
+
}
|
| 326 |
+
this[kOnOpen] = handler.bind(this);
|
| 327 |
+
this.addEventListener("open", this[kOnOpen]);
|
| 328 |
+
}
|
| 329 |
+
get onmessage() {
|
| 330 |
+
return this[kOnMessage];
|
| 331 |
+
}
|
| 332 |
+
set onmessage(handler) {
|
| 333 |
+
if (this[kOnMessage]) {
|
| 334 |
+
this.removeEventListener("message", { handleEvent: this[kOnMessage] });
|
| 335 |
+
}
|
| 336 |
+
this[kOnMessage] = handler.bind(this);
|
| 337 |
+
this.addEventListener("message", { handleEvent: this[kOnMessage] });
|
| 338 |
+
}
|
| 339 |
+
get onerror() {
|
| 340 |
+
return this[kOnError];
|
| 341 |
+
}
|
| 342 |
+
set onerror(handler) {
|
| 343 |
+
if (this[kOnError]) {
|
| 344 |
+
this.removeEventListener("error", { handleEvent: this[kOnError] });
|
| 345 |
+
}
|
| 346 |
+
this[kOnError] = handler.bind(this);
|
| 347 |
+
this.addEventListener("error", { handleEvent: this[kOnError] });
|
| 348 |
+
}
|
| 349 |
+
addEventListener(type, listener, options) {
|
| 350 |
+
super.addEventListener(
|
| 351 |
+
type,
|
| 352 |
+
listener,
|
| 353 |
+
options
|
| 354 |
+
);
|
| 355 |
+
}
|
| 356 |
+
removeEventListener(type, listener, options) {
|
| 357 |
+
super.removeEventListener(
|
| 358 |
+
type,
|
| 359 |
+
listener,
|
| 360 |
+
options
|
| 361 |
+
);
|
| 362 |
+
}
|
| 363 |
+
dispatchEvent(event) {
|
| 364 |
+
return super.dispatchEvent(event);
|
| 365 |
+
}
|
| 366 |
+
close() {
|
| 367 |
+
this[kAbortController].abort();
|
| 368 |
+
this.readyState = this.CLOSED;
|
| 369 |
+
}
|
| 370 |
+
async connect() {
|
| 371 |
+
await fetch(this[kRequest]).then((response) => {
|
| 372 |
+
this.processResponse(response);
|
| 373 |
+
}).catch(() => {
|
| 374 |
+
this.failConnection();
|
| 375 |
+
});
|
| 376 |
+
}
|
| 377 |
+
processResponse(response) {
|
| 378 |
+
if (!response.body) {
|
| 379 |
+
this.failConnection();
|
| 380 |
+
return;
|
| 381 |
+
}
|
| 382 |
+
if (isNetworkError(response)) {
|
| 383 |
+
this.reestablishConnection();
|
| 384 |
+
return;
|
| 385 |
+
}
|
| 386 |
+
if (response.status !== 200 || response.headers.get("content-type") !== "text/event-stream") {
|
| 387 |
+
this.failConnection();
|
| 388 |
+
return;
|
| 389 |
+
}
|
| 390 |
+
this.announceConnection();
|
| 391 |
+
this.interpretResponseBody(response);
|
| 392 |
+
}
|
| 393 |
+
announceConnection() {
|
| 394 |
+
queueMicrotask(() => {
|
| 395 |
+
if (this.readyState !== this.CLOSED) {
|
| 396 |
+
this.readyState = this.OPEN;
|
| 397 |
+
this.dispatchEvent(new Event("open"));
|
| 398 |
+
}
|
| 399 |
+
});
|
| 400 |
+
}
|
| 401 |
+
interpretResponseBody(response) {
|
| 402 |
+
const parsingStream = new EventSourceParsingStream({
|
| 403 |
+
message: (message) => {
|
| 404 |
+
if (message.id) {
|
| 405 |
+
this[kLastEventId] = message.id;
|
| 406 |
+
}
|
| 407 |
+
const messageEvent = new MessageEvent(
|
| 408 |
+
message.event ? message.event : "message",
|
| 409 |
+
{
|
| 410 |
+
data: message.data,
|
| 411 |
+
origin: this[kRequest].url,
|
| 412 |
+
lastEventId: this[kLastEventId],
|
| 413 |
+
cancelable: true
|
| 414 |
+
}
|
| 415 |
+
);
|
| 416 |
+
this[kOnAnyMessage]?.(messageEvent);
|
| 417 |
+
this.dispatchEvent(messageEvent);
|
| 418 |
+
},
|
| 419 |
+
retry: (reconnectionTime) => {
|
| 420 |
+
this[kReconnectionTime] = reconnectionTime;
|
| 421 |
+
},
|
| 422 |
+
abort: () => {
|
| 423 |
+
throw new Error("Stream abort is not implemented");
|
| 424 |
+
},
|
| 425 |
+
close: () => {
|
| 426 |
+
this.failConnection();
|
| 427 |
+
}
|
| 428 |
+
});
|
| 429 |
+
response.body.pipeTo(parsingStream).then(() => {
|
| 430 |
+
this.processResponseEndOfBody(response);
|
| 431 |
+
}).catch(() => {
|
| 432 |
+
this.failConnection();
|
| 433 |
+
});
|
| 434 |
+
}
|
| 435 |
+
processResponseEndOfBody(response) {
|
| 436 |
+
if (!isNetworkError(response)) {
|
| 437 |
+
this.reestablishConnection();
|
| 438 |
+
}
|
| 439 |
+
}
|
| 440 |
+
async reestablishConnection() {
|
| 441 |
+
queueMicrotask(() => {
|
| 442 |
+
if (this.readyState === this.CLOSED) {
|
| 443 |
+
return;
|
| 444 |
+
}
|
| 445 |
+
this.readyState = this.CONNECTING;
|
| 446 |
+
this.dispatchEvent(new Event("error"));
|
| 447 |
+
});
|
| 448 |
+
const signal = this[kAbortController].signal;
|
| 449 |
+
if (signal.aborted) {
|
| 450 |
+
return;
|
| 451 |
+
}
|
| 452 |
+
const aborted = new DeferredPromise();
|
| 453 |
+
const onAbort = () => aborted.resolve();
|
| 454 |
+
signal.addEventListener("abort", onAbort, { once: true });
|
| 455 |
+
await Promise.race([delay(this[kReconnectionTime]), aborted]).finally(
|
| 456 |
+
() => {
|
| 457 |
+
signal.removeEventListener("abort", onAbort);
|
| 458 |
+
}
|
| 459 |
+
);
|
| 460 |
+
if (signal.aborted) {
|
| 461 |
+
return;
|
| 462 |
+
}
|
| 463 |
+
queueMicrotask(async () => {
|
| 464 |
+
if (this.readyState !== this.CONNECTING) {
|
| 465 |
+
return;
|
| 466 |
+
}
|
| 467 |
+
if (this[kLastEventId] !== "") {
|
| 468 |
+
this[kRequest].headers.set("last-event-id", this[kLastEventId]);
|
| 469 |
+
}
|
| 470 |
+
await this.connect();
|
| 471 |
+
});
|
| 472 |
+
}
|
| 473 |
+
failConnection() {
|
| 474 |
+
queueMicrotask(() => {
|
| 475 |
+
if (this.readyState !== this.CLOSED) {
|
| 476 |
+
this.readyState = this.CLOSED;
|
| 477 |
+
this.dispatchEvent(new Event("error"));
|
| 478 |
+
}
|
| 479 |
+
});
|
| 480 |
+
}
|
| 481 |
+
}
|
| 482 |
+
function isNetworkError(response) {
|
| 483 |
+
return response.type === "error" && response.status === 0 && response.statusText === "" && Array.from(response.headers.entries()).length === 0 && response.body === null;
|
| 484 |
+
}
|
| 485 |
+
var ControlCharacters = /* @__PURE__ */ ((ControlCharacters2) => {
|
| 486 |
+
ControlCharacters2[ControlCharacters2["NewLine"] = 10] = "NewLine";
|
| 487 |
+
ControlCharacters2[ControlCharacters2["CarriageReturn"] = 13] = "CarriageReturn";
|
| 488 |
+
ControlCharacters2[ControlCharacters2["Space"] = 32] = "Space";
|
| 489 |
+
ControlCharacters2[ControlCharacters2["Colon"] = 58] = "Colon";
|
| 490 |
+
return ControlCharacters2;
|
| 491 |
+
})(ControlCharacters || {});
|
| 492 |
+
class EventSourceParsingStream extends WritableStream {
|
| 493 |
+
constructor(underlyingSink) {
|
| 494 |
+
super({
|
| 495 |
+
write: (chunk) => {
|
| 496 |
+
this.processResponseBodyChunk(chunk);
|
| 497 |
+
},
|
| 498 |
+
abort: (reason) => {
|
| 499 |
+
this.underlyingSink.abort?.(reason);
|
| 500 |
+
},
|
| 501 |
+
close: () => {
|
| 502 |
+
this.underlyingSink.close?.();
|
| 503 |
+
}
|
| 504 |
+
});
|
| 505 |
+
this.underlyingSink = underlyingSink;
|
| 506 |
+
this.decoder = new TextDecoder();
|
| 507 |
+
this.position = 0;
|
| 508 |
+
}
|
| 509 |
+
decoder;
|
| 510 |
+
buffer;
|
| 511 |
+
position;
|
| 512 |
+
fieldLength;
|
| 513 |
+
discardTrailingNewline = false;
|
| 514 |
+
message = {
|
| 515 |
+
id: void 0,
|
| 516 |
+
event: void 0,
|
| 517 |
+
data: void 0
|
| 518 |
+
};
|
| 519 |
+
resetMessage() {
|
| 520 |
+
this.message = {
|
| 521 |
+
id: void 0,
|
| 522 |
+
event: void 0,
|
| 523 |
+
data: void 0
|
| 524 |
+
};
|
| 525 |
+
}
|
| 526 |
+
processResponseBodyChunk(chunk) {
|
| 527 |
+
if (this.buffer == null) {
|
| 528 |
+
this.buffer = chunk;
|
| 529 |
+
this.position = 0;
|
| 530 |
+
this.fieldLength = -1;
|
| 531 |
+
} else {
|
| 532 |
+
const nextBuffer = new Uint8Array(this.buffer.length + chunk.length);
|
| 533 |
+
nextBuffer.set(this.buffer);
|
| 534 |
+
nextBuffer.set(chunk, this.buffer.length);
|
| 535 |
+
this.buffer = nextBuffer;
|
| 536 |
+
}
|
| 537 |
+
const bufferLength = this.buffer.length;
|
| 538 |
+
let lineStart = 0;
|
| 539 |
+
while (this.position < bufferLength) {
|
| 540 |
+
if (this.discardTrailingNewline) {
|
| 541 |
+
if (this.buffer[this.position] === 10 /* NewLine */) {
|
| 542 |
+
lineStart = ++this.position;
|
| 543 |
+
}
|
| 544 |
+
this.discardTrailingNewline = false;
|
| 545 |
+
}
|
| 546 |
+
let lineEnd = -1;
|
| 547 |
+
for (; this.position < bufferLength && lineEnd === -1; ++this.position) {
|
| 548 |
+
switch (this.buffer[this.position]) {
|
| 549 |
+
case 58 /* Colon */: {
|
| 550 |
+
if (this.fieldLength === -1) {
|
| 551 |
+
this.fieldLength = this.position - lineStart;
|
| 552 |
+
}
|
| 553 |
+
break;
|
| 554 |
+
}
|
| 555 |
+
case 13 /* CarriageReturn */: {
|
| 556 |
+
this.discardTrailingNewline = true;
|
| 557 |
+
break;
|
| 558 |
+
}
|
| 559 |
+
case 10 /* NewLine */: {
|
| 560 |
+
lineEnd = this.position;
|
| 561 |
+
break;
|
| 562 |
+
}
|
| 563 |
+
}
|
| 564 |
+
}
|
| 565 |
+
if (lineEnd === -1) {
|
| 566 |
+
break;
|
| 567 |
+
}
|
| 568 |
+
this.processLine(
|
| 569 |
+
this.buffer.subarray(lineStart, lineEnd),
|
| 570 |
+
this.fieldLength
|
| 571 |
+
);
|
| 572 |
+
lineStart = this.position;
|
| 573 |
+
this.fieldLength = -1;
|
| 574 |
+
}
|
| 575 |
+
if (lineStart === bufferLength) {
|
| 576 |
+
this.buffer = void 0;
|
| 577 |
+
} else if (lineStart !== 0) {
|
| 578 |
+
this.buffer = this.buffer.subarray(lineStart);
|
| 579 |
+
this.position -= lineStart;
|
| 580 |
+
}
|
| 581 |
+
}
|
| 582 |
+
processLine(line, fieldLength) {
|
| 583 |
+
if (line.length === 0) {
|
| 584 |
+
if (this.message.data === void 0) {
|
| 585 |
+
this.message.event = void 0;
|
| 586 |
+
return;
|
| 587 |
+
}
|
| 588 |
+
this.underlyingSink.message(this.message);
|
| 589 |
+
this.resetMessage();
|
| 590 |
+
return;
|
| 591 |
+
}
|
| 592 |
+
if (fieldLength > 0) {
|
| 593 |
+
const field = this.decoder.decode(line.subarray(0, fieldLength));
|
| 594 |
+
const valueOffset = fieldLength + (line[fieldLength + 1] === 32 /* Space */ ? 2 : 1);
|
| 595 |
+
const value = this.decoder.decode(line.subarray(valueOffset));
|
| 596 |
+
switch (field) {
|
| 597 |
+
case "data": {
|
| 598 |
+
this.message.data = this.message.data ? this.message.data + "\n" + value : value;
|
| 599 |
+
break;
|
| 600 |
+
}
|
| 601 |
+
case "event": {
|
| 602 |
+
this.message.event = value;
|
| 603 |
+
break;
|
| 604 |
+
}
|
| 605 |
+
case "id": {
|
| 606 |
+
this.message.id = value;
|
| 607 |
+
break;
|
| 608 |
+
}
|
| 609 |
+
case "retry": {
|
| 610 |
+
if (/^\d+$/.test(value)) {
|
| 611 |
+
this.underlyingSink.retry?.(parseInt(value, 10));
|
| 612 |
+
}
|
| 613 |
+
break;
|
| 614 |
+
}
|
| 615 |
+
}
|
| 616 |
+
}
|
| 617 |
+
}
|
| 618 |
+
}
|
| 619 |
+
function createEventStream(request) {
|
| 620 |
+
invariant(
|
| 621 |
+
!request.signal.aborted,
|
| 622 |
+
'Failed to call "createEventStream" on the "%s %s" request: request aborted',
|
| 623 |
+
request.method,
|
| 624 |
+
request.url
|
| 625 |
+
);
|
| 626 |
+
const { readable, writable } = new TransformStream();
|
| 627 |
+
const client = new ServerSentEventClient(writable);
|
| 628 |
+
const server = new ServerSentEventServer({
|
| 629 |
+
request,
|
| 630 |
+
client
|
| 631 |
+
});
|
| 632 |
+
const response = new Response(readable, SSE_RESPONSE_INIT);
|
| 633 |
+
request.signal.addEventListener(
|
| 634 |
+
"abort",
|
| 635 |
+
() => {
|
| 636 |
+
client.close();
|
| 637 |
+
},
|
| 638 |
+
{ once: true }
|
| 639 |
+
);
|
| 640 |
+
return {
|
| 641 |
+
client,
|
| 642 |
+
server,
|
| 643 |
+
response
|
| 644 |
+
};
|
| 645 |
+
}
|
| 646 |
+
export {
|
| 647 |
+
sse
|
| 648 |
+
};
|
| 649 |
+
//# sourceMappingURL=sse.mjs.map
|
node_modules/msw/lib/core/sse.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../src/core/sse.ts"],"sourcesContent":["import { invariant } from 'outvariant'\nimport { DeferredPromise } from '@open-draft/deferred-promise'\nimport { Emitter } from 'strict-event-emitter'\nimport type { ResponseResolver } from './handlers/RequestHandler'\nimport {\n HttpHandler,\n type HttpRequestResolverExtras,\n type HttpRequestParsedResult,\n} from './handlers/HttpHandler'\nimport type { ResponseResolutionContext } from '#core/utils/executeHandlers'\nimport type { Path, PathParams } from './utils/matching/matchRequestUrl'\nimport { delay } from './delay'\nimport { getTimestamp } from './utils/logging/getTimestamp'\nimport { devUtils } from './utils/internal/devUtils'\nimport { colors } from './ws/utils/attachWebSocketLogger'\nimport { toPublicUrl } from './utils/request/toPublicUrl'\n\ntype EventMapConstraint = {\n message?: unknown\n [key: string]: unknown\n [key: symbol | number]: never\n}\n\nexport type ServerSentEventResolverExtras<\n EventMap extends EventMapConstraint,\n Params extends PathParams,\n> = HttpRequestResolverExtras<Params> & {\n client: ServerSentEventClient<EventMap>\n server: ServerSentEventServer\n}\n\nexport type ServerSentEventResolver<\n EventMap extends EventMapConstraint,\n Params extends PathParams,\n> = ResponseResolver<ServerSentEventResolverExtras<EventMap, Params>, any, any>\n\nexport type ServerSentEventRequestHandler = <\n EventMap extends EventMapConstraint = { message: unknown },\n Params extends PathParams<keyof Params> = PathParams,\n RequestPath extends Path = Path,\n>(\n path: RequestPath,\n resolver: ServerSentEventResolver<EventMap, Params>,\n) => HttpHandler\n\nexport type ServerSentEventMessage<\n EventMap extends EventMapConstraint = { message: unknown },\n> =\n | ToEventDiscriminatedUnion<EventMap & { message: unknown }>\n | {\n id?: never\n event?: never\n data?: never\n retry: number\n }\n\n/**\n * Intercept Server-Sent Events (SSE).\n *\n * @example\n * sse('http://localhost:4321', ({ client }) => {\n * client.send({ data: 'hello world' })\n * })\n *\n * @see {@link https://mswjs.io/docs/sse/ Mocking Server-Sent Events}\n * @see {@link https://mswjs.io/docs/api/sse `sse()` API reference}\n */\nexport const sse: ServerSentEventRequestHandler = (path, resolver) => {\n return new ServerSentEventHandler(path, resolver)\n}\n\nconst SSE_RESPONSE_INIT: ResponseInit = {\n headers: {\n 'content-type': 'text/event-stream',\n 'cache-control': 'no-cache',\n connection: 'keep-alive',\n },\n}\n\nclass ServerSentEventHandler<\n EventMap extends EventMapConstraint,\n> extends HttpHandler {\n #emitter: Emitter<ServerSentEventClientEventMap>\n\n constructor(path: Path, resolver: ServerSentEventResolver<EventMap, any>) {\n invariant(\n typeof EventSource !== 'undefined',\n 'Failed to construct a Server-Sent Event handler for path \"%s\": the EventSource API is not supported in this environment',\n path,\n )\n\n super('GET', path, async (info) => {\n const { client, server, response } = createEventStream<EventMap>(\n info.request,\n )\n\n client[kClientEmitter] = this.#emitter\n\n await resolver({\n ...info,\n client,\n server,\n })\n\n return response\n })\n\n this.#emitter = new Emitter<ServerSentEventClientEventMap>()\n }\n\n async predicate(args: {\n request: Request\n parsedResult: HttpRequestParsedResult\n resolutionContext?: ResponseResolutionContext\n }) {\n if (args.request.headers.get('accept') !== 'text/event-stream') {\n return false\n }\n\n const matches = await super.predicate(args)\n\n if (matches && !args.resolutionContext?.quiet) {\n /**\n * @note Log the intercepted request early.\n * Normally, the `this.log()` method is called when the handler returns a response.\n * For SSE, call that method earlier so the logs are in correct order.\n */\n await super.log({\n request: args.request,\n /**\n * @note Construct a placeholder response since SSE response\n * is being streamed and cannot be cloned/consumed for logging.\n */\n response: new Response('[streaming]', SSE_RESPONSE_INIT),\n })\n\n this.#attachClientLogger(args.request, this.#emitter)\n }\n\n return matches\n }\n\n async log(_args: { request: Request; response: Response }): Promise<void> {\n /**\n * @note Skip the default `this.log()` logic so that when this handler is logged\n * upon handling the request, nothing is printed (we log SSE requests early).\n */\n return\n }\n\n #attachClientLogger(\n request: Request,\n emitter: Emitter<ServerSentEventClientEventMap>,\n ): void {\n const publicUrl = toPublicUrl(request.url)\n\n /* eslint-disable no-console */\n emitter.on('message', (payload) => {\n console.groupCollapsed(\n devUtils.formatMessage(\n `${getTimestamp()} SSE %s %c⇣%c ${payload.event}`,\n ),\n publicUrl,\n `color:${colors.mocked}`,\n 'color:inherit',\n )\n console.log(payload.frames)\n console.groupEnd()\n })\n\n emitter.on('error', () => {\n console.groupCollapsed(\n devUtils.formatMessage(`${getTimestamp()} SSE %s %c\\u00D7%c error`),\n publicUrl,\n `color: ${colors.system}`,\n 'color:inherit',\n )\n console.log('Handler:', this)\n console.groupEnd()\n })\n\n emitter.on('close', () => {\n console.groupCollapsed(\n devUtils.formatMessage(`${getTimestamp()} SSE %s %c■%c close`),\n publicUrl,\n `colors:${colors.system}`,\n 'color:inherit',\n )\n console.log('Handler:', this)\n console.groupEnd()\n })\n /* eslint-enable no-console */\n }\n}\n\ntype Values<T> = T[keyof T]\ntype Identity<T> = { [K in keyof T]: T[K] } & unknown\ntype ToEventDiscriminatedUnion<T> = Values<{\n [K in keyof T]: Identity<\n (K extends 'message'\n ? {\n id?: string\n event?: K\n data?: T[K]\n retry?: never\n }\n : {\n id?: string\n event: K\n data?: T[K]\n retry?: never\n }) &\n // Make the `data` field conditionally required through an intersection.\n (undefined extends T[K] ? unknown : { data: unknown })\n >\n}>\n\ntype ServerSentEventClientEventMap = {\n message: [payload: EventStreamMessage]\n error: []\n close: []\n}\n\nconst kClientEmitter = Symbol.for('kClientEmitter')\n\nclass ServerSentEventClient<\n EventMap extends EventMapConstraint = { message: unknown },\n> {\n private [kClientEmitter]?: Emitter<ServerSentEventClientEventMap>\n\n #encoder: TextEncoder\n #writer: WritableStreamDefaultWriter\n\n constructor(writable: WritableStream) {\n this.#encoder = new TextEncoder()\n this.#writer = writable.getWriter()\n }\n\n /**\n * Sends the given payload to the intercepted `EventSource`.\n */\n public send(payload: ServerSentEventMessage<EventMap>): void {\n if ('retry' in payload && payload.retry != null) {\n this.#sendRetry(payload.retry)\n return\n }\n\n this.#sendMessage({\n id: payload.id,\n event: payload.event,\n data:\n typeof payload.data === 'object'\n ? JSON.stringify(payload.data)\n : payload.data,\n })\n }\n\n /**\n * Dispatches the given event on the intercepted `EventSource`.\n */\n public dispatchEvent(event: Event) {\n if (event instanceof MessageEvent) {\n /**\n * @note Use the internal send mechanism to skip normalization\n * of the message data (already normalized by the server).\n */\n this.#sendMessage({\n id: event.lastEventId || undefined,\n event: event.type === 'message' ? undefined : event.type,\n data: event.data,\n })\n return\n }\n\n if (event.type === 'error') {\n this.error()\n return\n }\n\n if (event.type === 'close') {\n this.close()\n return\n }\n }\n\n /**\n * Errors the underlying `EventSource`, closing the connection with an error.\n * This is equivalent to aborting the connection and will produce a `TypeError: Failed to fetch`\n * error.\n */\n public error(): void {\n this.#writer.abort().catch((error) => {\n console.error(error)\n devUtils.error(\n 'Failed to abort server-side EventSource. Please see the original error above.',\n )\n })\n this[kClientEmitter]?.emit('error')\n }\n\n /**\n * Closes the underlying `EventSource`, closing the connection.\n */\n public close(): void {\n this.#writer.close().catch((error) => {\n console.error(error)\n devUtils.error(\n 'Failed to close server-side EventSource. Please see the original error above.',\n )\n })\n this[kClientEmitter]?.emit('close')\n }\n\n #sendRetry(retry: number): void {\n this.#writer\n .write(this.#encoder.encode(`retry:${retry}\\n\\n`))\n .catch((error) => {\n console.error(error)\n devUtils.error(\n 'Failed to send a retry packet to server-side EventSource. Please see the original error above.',\n )\n })\n }\n\n #sendMessage(message: {\n id?: string\n event?: unknown\n data: unknown | undefined\n }): void {\n const frames: Array<string> = []\n\n if (message.id) {\n frames.push(`id:${message.id}`)\n }\n\n if (message.event) {\n frames.push(`event:${message.event.toString()}`)\n }\n\n if (message.data != null) {\n /**\n * Split data on line terminators (LF, CR, or CRLF) and translate them to individual frames.\n * @see https://html.spec.whatwg.org/multipage/server-sent-events.html#event-stream-interpretation\n * @see https://html.spec.whatwg.org/multipage/server-sent-events.html#parsing-an-event-stream\n */\n for (const line of message.data.toString().split(/\\r\\n|\\r|\\n/)) {\n frames.push(`data:${line}`)\n }\n }\n\n frames.push('', '')\n\n this.#writer\n .write(this.#encoder.encode(frames.join('\\n')))\n .catch((error) => {\n console.error(error)\n devUtils.error(\n 'Failed to send a message to server-side EventSource. Please see the original error above.',\n )\n })\n\n this[kClientEmitter]?.emit('message', {\n id: message.id,\n event: message.event?.toString() || 'message',\n data: message.data,\n frames,\n })\n }\n}\n\nclass ServerSentEventServer {\n #request: Request\n #client: ServerSentEventClient<ServerSentEventClientEventMap>\n\n constructor(args: { request: Request; client: ServerSentEventClient<any> }) {\n this.#request = args.request\n this.#client = args.client\n }\n\n /**\n * Establishes the actual connection for this SSE request\n * and returns the `EventSource` instance.\n */\n public connect(): EventSource {\n const source = new ObservableEventSource(this.#request.url, {\n withCredentials: this.#request.credentials === 'include',\n headers: {\n /**\n * @note Mark this request as passthrough so it doesn't trigger\n * an infinite loop matching against the existing request handler.\n */\n accept: 'msw/passthrough',\n },\n signal: this.#request.signal,\n })\n\n source[kOnAnyMessage] = (event) => {\n Object.defineProperties(event, {\n target: {\n value: this,\n enumerable: true,\n writable: true,\n configurable: true,\n },\n })\n\n // Schedule the server-to-client forwarding for the next tick\n // so the user can prevent the message event.\n queueMicrotask(() => {\n if (!event.defaultPrevented) {\n this.#client.dispatchEvent(event)\n }\n })\n }\n\n // Forward stream errors from the actual server to the client.\n source.addEventListener('error', (event) => {\n Object.defineProperties(event, {\n target: {\n value: this,\n enumerable: true,\n writable: true,\n configurable: true,\n },\n })\n\n queueMicrotask(() => {\n // Allow the user to opt-out from this forwarding.\n if (!event.defaultPrevented) {\n this.#client.dispatchEvent(event)\n }\n })\n })\n\n return source\n }\n}\n\ninterface ObservableEventSourceInit extends EventSourceInit {\n headers?: HeadersInit\n signal?: AbortSignal\n}\n\ntype EventHandler<EventType extends Event> = (\n this: EventSource,\n event: EventType,\n) => any\n\nconst kRequest = Symbol('kRequest')\nconst kReconnectionTime = Symbol('kReconnectionTime')\nconst kLastEventId = Symbol('kLastEventId')\nconst kAbortController = Symbol('kAbortController')\nconst kOnOpen = Symbol('kOnOpen')\nconst kOnMessage = Symbol('kOnMessage')\nconst kOnAnyMessage = Symbol('kOnAnyMessage')\nconst kOnError = Symbol('kOnError')\n\nclass ObservableEventSource extends EventTarget implements EventSource {\n static readonly CONNECTING = 0\n static readonly OPEN = 1\n static readonly CLOSED = 2\n\n public readonly CONNECTING = ObservableEventSource.CONNECTING\n public readonly OPEN = ObservableEventSource.OPEN\n public readonly CLOSED = ObservableEventSource.CLOSED\n\n public readyState: number\n public url: string\n public withCredentials: boolean\n\n private [kRequest]: Request\n private [kReconnectionTime]: number\n private [kLastEventId]: string\n private [kAbortController]: AbortController\n private [kOnOpen]: EventHandler<Event> | null = null\n private [kOnMessage]: EventHandler<MessageEvent> | null = null\n private [kOnAnyMessage]: EventHandler<MessageEvent> | null = null\n private [kOnError]: EventHandler<Event> | null = null\n\n constructor(url: string | URL, init?: ObservableEventSourceInit) {\n super()\n\n this.url = new URL(url).href\n this.withCredentials = init?.withCredentials ?? false\n\n this.readyState = this.CONNECTING\n\n // Support custom request init.\n const headers = new Headers(init?.headers || {})\n headers.append('accept', 'text/event-stream')\n\n this[kAbortController] = new AbortController()\n this[kReconnectionTime] = 2000\n this[kLastEventId] = ''\n this[kRequest] = new Request(this.url, {\n method: 'GET',\n headers,\n credentials: this.withCredentials ? 'include' : 'omit',\n signal: this[kAbortController].signal,\n })\n\n if (init?.signal) {\n if (init.signal.aborted) {\n this.close()\n return\n }\n\n init.signal.addEventListener('abort', () => this.close(), {\n once: true,\n signal: this[kAbortController].signal,\n })\n }\n\n this.connect()\n }\n\n get onopen(): EventHandler<Event> | null {\n return this[kOnOpen]\n }\n\n set onopen(handler: EventHandler<Event>) {\n if (this[kOnOpen]) {\n this.removeEventListener('open', this[kOnOpen])\n }\n this[kOnOpen] = handler.bind(this)\n this.addEventListener('open', this[kOnOpen])\n }\n\n get onmessage(): EventHandler<MessageEvent> | null {\n return this[kOnMessage]\n }\n set onmessage(handler: EventHandler<MessageEvent>) {\n if (this[kOnMessage]) {\n this.removeEventListener('message', { handleEvent: this[kOnMessage] })\n }\n this[kOnMessage] = handler.bind(this)\n this.addEventListener('message', { handleEvent: this[kOnMessage] })\n }\n\n get onerror(): EventHandler<Event> | null {\n return this[kOnError]\n }\n set onerror(handler: EventHandler<Event>) {\n if (this[kOnError]) {\n this.removeEventListener('error', { handleEvent: this[kOnError] })\n }\n this[kOnError] = handler.bind(this)\n this.addEventListener('error', { handleEvent: this[kOnError] })\n }\n\n public addEventListener<K extends keyof EventSourceEventMap>(\n type: K,\n listener: EventHandler<EventSourceEventMap[K]>,\n options?: boolean | AddEventListenerOptions,\n ): void\n public addEventListener(\n type: string,\n listener: EventHandler<MessageEvent>,\n options?: boolean | AddEventListenerOptions,\n ): void\n public addEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | AddEventListenerOptions,\n ): void\n\n public addEventListener(\n type: string,\n listener: EventHandler<MessageEvent> | EventListenerOrEventListenerObject,\n options?: boolean | AddEventListenerOptions,\n ): void {\n super.addEventListener(\n type,\n listener as EventListenerOrEventListenerObject,\n options,\n )\n }\n\n public removeEventListener<K extends keyof EventSourceEventMap>(\n type: K,\n listener: (this: EventSource, ev: EventSourceEventMap[K]) => any,\n options?: boolean | EventListenerOptions,\n ): void\n public removeEventListener(\n type: string,\n listener: (this: EventSource, event: MessageEvent) => any,\n options?: boolean | EventListenerOptions,\n ): void\n public removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | EventListenerOptions,\n ): void\n\n public removeEventListener(\n type: string,\n listener: EventHandler<MessageEvent> | EventListenerOrEventListenerObject,\n options?: boolean | AddEventListenerOptions,\n ): void {\n super.removeEventListener(\n type,\n listener as EventListenerOrEventListenerObject,\n options,\n )\n }\n\n public dispatchEvent(event: Event): boolean {\n return super.dispatchEvent(event)\n }\n\n public close(): void {\n this[kAbortController].abort()\n this.readyState = this.CLOSED\n }\n\n private async connect() {\n await fetch(this[kRequest])\n .then((response) => {\n this.processResponse(response)\n })\n .catch(() => {\n // Fail the connection on request errors instead of\n // throwing a generic \"Failed to fetch\" error.\n this.failConnection()\n })\n }\n\n private processResponse(response: Response): void {\n if (!response.body) {\n this.failConnection()\n return\n }\n\n if (isNetworkError(response)) {\n this.reestablishConnection()\n return\n }\n\n if (\n response.status !== 200 ||\n response.headers.get('content-type') !== 'text/event-stream'\n ) {\n this.failConnection()\n return\n }\n\n this.announceConnection()\n this.interpretResponseBody(response)\n }\n\n private announceConnection(): void {\n queueMicrotask(() => {\n if (this.readyState !== this.CLOSED) {\n this.readyState = this.OPEN\n this.dispatchEvent(new Event('open'))\n }\n })\n }\n\n private interpretResponseBody(response: Response): void {\n const parsingStream = new EventSourceParsingStream({\n message: (message) => {\n if (message.id) {\n this[kLastEventId] = message.id\n }\n\n const messageEvent = new MessageEvent(\n message.event ? message.event : 'message',\n {\n data: message.data,\n origin: this[kRequest].url,\n lastEventId: this[kLastEventId],\n cancelable: true,\n },\n )\n\n this[kOnAnyMessage]?.(messageEvent)\n this.dispatchEvent(messageEvent)\n },\n retry: (reconnectionTime) => {\n this[kReconnectionTime] = reconnectionTime\n },\n abort: () => {\n throw new Error('Stream abort is not implemented')\n },\n close: () => {\n this.failConnection()\n },\n })\n\n response\n .body!.pipeTo(parsingStream)\n .then(() => {\n this.processResponseEndOfBody(response)\n })\n .catch(() => {\n this.failConnection()\n })\n }\n\n private processResponseEndOfBody(response: Response): void {\n if (!isNetworkError(response)) {\n this.reestablishConnection()\n }\n }\n\n private async reestablishConnection(): Promise<void> {\n queueMicrotask(() => {\n if (this.readyState === this.CLOSED) {\n return\n }\n\n this.readyState = this.CONNECTING\n this.dispatchEvent(new Event('error'))\n })\n\n const signal = this[kAbortController].signal\n\n if (signal.aborted) {\n return\n }\n\n const aborted = new DeferredPromise<void>()\n const onAbort = () => aborted.resolve()\n signal.addEventListener('abort', onAbort, { once: true })\n\n await Promise.race([delay(this[kReconnectionTime]), aborted]).finally(\n () => {\n signal.removeEventListener('abort', onAbort)\n },\n )\n\n if (signal.aborted) {\n return\n }\n\n queueMicrotask(async () => {\n if (this.readyState !== this.CONNECTING) {\n return\n }\n\n if (this[kLastEventId] !== '') {\n this[kRequest].headers.set('last-event-id', this[kLastEventId])\n }\n\n await this.connect()\n })\n }\n\n private failConnection(): void {\n queueMicrotask(() => {\n if (this.readyState !== this.CLOSED) {\n this.readyState = this.CLOSED\n this.dispatchEvent(new Event('error'))\n }\n })\n }\n}\n\n/**\n * Checks if the given `Response` instance is a network error.\n * @see https://fetch.spec.whatwg.org/#concept-network-error\n */\nfunction isNetworkError(response: Response): boolean {\n return (\n response.type === 'error' &&\n response.status === 0 &&\n response.statusText === '' &&\n Array.from(response.headers.entries()).length === 0 &&\n response.body === null\n )\n}\n\nconst enum ControlCharacters {\n NewLine = 10,\n CarriageReturn = 13,\n Space = 32,\n Colon = 58,\n}\n\ninterface EventSourceMessage {\n id?: string\n event?: string\n data?: string\n}\n\nclass EventSourceParsingStream extends WritableStream {\n private decoder: TextDecoder\n\n private buffer?: Uint8Array\n private position: number\n private fieldLength?: number\n private discardTrailingNewline = false\n\n private message: EventSourceMessage = {\n id: undefined,\n event: undefined,\n data: undefined,\n }\n\n constructor(\n private underlyingSink: {\n message: (message: EventSourceMessage) => void\n retry?: (reconnectionTime: number) => void\n abort?: (reason: any) => void\n close?: () => void\n },\n ) {\n super({\n write: (chunk) => {\n this.processResponseBodyChunk(chunk)\n },\n abort: (reason) => {\n this.underlyingSink.abort?.(reason)\n },\n close: () => {\n this.underlyingSink.close?.()\n },\n })\n\n this.decoder = new TextDecoder()\n this.position = 0\n }\n\n private resetMessage(): void {\n this.message = {\n id: undefined,\n event: undefined,\n data: undefined,\n }\n }\n\n private processResponseBodyChunk(chunk: Uint8Array): void {\n if (this.buffer == null) {\n this.buffer = chunk\n this.position = 0\n this.fieldLength = -1\n } else {\n const nextBuffer = new Uint8Array(this.buffer.length + chunk.length)\n nextBuffer.set(this.buffer)\n nextBuffer.set(chunk, this.buffer.length)\n this.buffer = nextBuffer\n }\n\n const bufferLength = this.buffer.length\n let lineStart = 0\n\n while (this.position < bufferLength) {\n if (this.discardTrailingNewline) {\n if (this.buffer[this.position] === ControlCharacters.NewLine) {\n lineStart = ++this.position\n }\n\n this.discardTrailingNewline = false\n }\n\n let lineEnd = -1\n\n for (; this.position < bufferLength && lineEnd === -1; ++this.position) {\n switch (this.buffer[this.position]) {\n case ControlCharacters.Colon: {\n if (this.fieldLength === -1) {\n this.fieldLength = this.position - lineStart\n }\n break\n }\n\n case ControlCharacters.CarriageReturn: {\n this.discardTrailingNewline = true\n break\n }\n\n case ControlCharacters.NewLine: {\n lineEnd = this.position\n break\n }\n }\n }\n\n if (lineEnd === -1) {\n break\n }\n\n this.processLine(\n this.buffer.subarray(lineStart, lineEnd),\n this.fieldLength!,\n )\n\n lineStart = this.position\n this.fieldLength = -1\n }\n\n if (lineStart === bufferLength) {\n this.buffer = undefined\n } else if (lineStart !== 0) {\n this.buffer = this.buffer.subarray(lineStart)\n this.position -= lineStart\n }\n }\n\n private processLine(line: Uint8Array, fieldLength: number): void {\n // New line indicates the end of the message. Dispatch it.\n if (line.length === 0) {\n // Prevent dispatching the message if the data is an empty string.\n // That is a no-op per spec.\n if (this.message.data === undefined) {\n this.message.event = undefined\n return\n }\n\n this.underlyingSink.message(this.message)\n this.resetMessage()\n return\n }\n\n // Otherwise, keep accumulating message fields until the new line.\n if (fieldLength > 0) {\n const field = this.decoder.decode(line.subarray(0, fieldLength))\n const valueOffset =\n fieldLength +\n (line[fieldLength + 1] === ControlCharacters.Space ? 2 : 1)\n const value = this.decoder.decode(line.subarray(valueOffset))\n\n switch (field) {\n case 'data': {\n this.message.data = this.message.data\n ? this.message.data + '\\n' + value\n : value\n break\n }\n\n case 'event': {\n this.message.event = value\n break\n }\n\n case 'id': {\n this.message.id = value\n break\n }\n\n case 'retry': {\n /**\n * Apply the retry immediately. Don't buffer onto the current message.\n * @see https://html.spec.whatwg.org/multipage/server-sent-events.html#event-stream-interpretation\n */\n if (/^\\d+$/.test(value)) {\n this.underlyingSink.retry?.(parseInt(value, 10))\n }\n break\n }\n }\n }\n }\n}\n\ninterface EventStreamMessage {\n id?: string\n event: string\n data?: unknown\n frames: Array<string>\n}\n\ninterface EventStream<EventMap extends EventMapConstraint> {\n client: ServerSentEventClient<EventMap>\n server: ServerSentEventServer\n response: Response\n}\n\n/**\n * Create an event stream out of the given Fetch API `Request`.\n * Returns the following properties:\n * - `client`, to operate on the intercepted request;\n * - `server`, to establish and manage the actual server connection;\n * - `response`, a `Response` to use as the mock response's body.\n *\n * @example\n * http.post('/resource', ({ request }) => {\n * const { client, server, response } = createEventStream(request)\n * client.send({ data: 'hello world' })\n * return response\n * })\n */\nfunction createEventStream<EventMap extends EventMapConstraint>(\n request: Request,\n): EventStream<EventMap> {\n invariant(\n !request.signal.aborted,\n 'Failed to call \"createEventStream\" on the \"%s %s\" request: request aborted',\n request.method,\n request.url,\n )\n\n const { readable, writable } = new TransformStream()\n\n const client = new ServerSentEventClient<EventMap>(writable)\n const server = new ServerSentEventServer({\n request,\n client,\n })\n\n const response = new Response(readable, SSE_RESPONSE_INIT)\n\n request.signal.addEventListener(\n 'abort',\n () => {\n client.close()\n },\n { once: true },\n )\n\n return {\n client,\n server,\n response,\n }\n}\n"],"mappings":"AAAA,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAChC,SAAS,eAAe;AAExB;AAAA,EACE;AAAA,OAGK;AAGP,SAAS,aAAa;AACtB,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB;AACzB,SAAS,cAAc;AACvB,SAAS,mBAAmB;AAoDrB,MAAM,MAAqC,CAAC,MAAM,aA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AK,eAAe,QAAQ,SAAS,OAAO,EAAE,CAAC;AAAA,UACjD;AACA;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AA6BA,SAAS,kBACP,SACuB;AACvB;AAAA,IACE,CAAC,QAAQ,OAAO;AAAA,IAChB;AAAA,IACA,QAAQ;AAAA,IACR,QAAQ;AAAA,EACV;AAEA,QAAM,EAAE,UAAU,SAAS,IAAI,IAAI,gBAAgB;AAEnD,QAAM,SAAS,IAAI,sBAAgC,QAAQ;AAC3D,QAAM,SAAS,IAAI,sBAAsB;AAAA,IACvC;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,WAAW,IAAI,SAAS,UAAU,iBAAiB;AAEzD,UAAQ,OAAO;AAAA,IACb;AAAA,IACA,MAAM;AACJ,aAAO,MAAM;AAAA,IACf;AAAA,IACA,EAAE,MAAM,KAAK;AAAA,EACf;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":["ControlCharacters"]}
|
node_modules/msw/lib/core/typeUtils.d.mts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
type Fn = (...arg: any[]) => any;
|
| 2 |
+
type MaybePromise<T> = T | Promise<T>;
|
| 3 |
+
type RequiredDeep<Type, U extends Record<string, unknown> | Fn | undefined = undefined> = Type extends Fn ? Type : Type extends Record<string, any> ? {
|
| 4 |
+
[Key in keyof Type]-?: NonNullable<Type[Key]> extends NonNullable<U> ? NonNullable<Type[Key]> : RequiredDeep<NonNullable<Type[Key]>, U>;
|
| 5 |
+
} : Type;
|
| 6 |
+
/**
|
| 7 |
+
* @fixme Remove this once TS 5.4 is the lowest supported version.
|
| 8 |
+
* Because "NoInfer" is a built-in type utility there.
|
| 9 |
+
*/
|
| 10 |
+
type NoInfer<T> = [T][T extends any ? 0 : never];
|
| 11 |
+
|
| 12 |
+
export type { MaybePromise, NoInfer, RequiredDeep };
|
node_modules/msw/lib/core/typeUtils.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
type Fn = (...arg: any[]) => any;
|
| 2 |
+
type MaybePromise<T> = T | Promise<T>;
|
| 3 |
+
type RequiredDeep<Type, U extends Record<string, unknown> | Fn | undefined = undefined> = Type extends Fn ? Type : Type extends Record<string, any> ? {
|
| 4 |
+
[Key in keyof Type]-?: NonNullable<Type[Key]> extends NonNullable<U> ? NonNullable<Type[Key]> : RequiredDeep<NonNullable<Type[Key]>, U>;
|
| 5 |
+
} : Type;
|
| 6 |
+
/**
|
| 7 |
+
* @fixme Remove this once TS 5.4 is the lowest supported version.
|
| 8 |
+
* Because "NoInfer" is a built-in type utility there.
|
| 9 |
+
*/
|
| 10 |
+
type NoInfer<T> = [T][T extends any ? 0 : never];
|
| 11 |
+
|
| 12 |
+
export type { MaybePromise, NoInfer, RequiredDeep };
|
node_modules/msw/lib/core/typeUtils.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __defProp = Object.defineProperty;
|
| 3 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
| 4 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
| 5 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
| 6 |
+
var __copyProps = (to, from, except, desc) => {
|
| 7 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
| 8 |
+
for (let key of __getOwnPropNames(from))
|
| 9 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
| 10 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
| 11 |
+
}
|
| 12 |
+
return to;
|
| 13 |
+
};
|
| 14 |
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
| 15 |
+
var typeUtils_exports = {};
|
| 16 |
+
module.exports = __toCommonJS(typeUtils_exports);
|
| 17 |
+
//# sourceMappingURL=typeUtils.js.map
|
node_modules/msw/lib/core/typeUtils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../src/core/typeUtils.ts"],"sourcesContent":["type Fn = (...arg: any[]) => any\n\nexport type MaybePromise<T> = T | Promise<T>\n\nexport type RequiredDeep<\n Type,\n U extends Record<string, unknown> | Fn | undefined = undefined,\n> = Type extends Fn\n ? Type\n : /**\n * @note The \"Fn\" type satisfies the predicate below.\n * It must always come first, before the Record check.\n */\n Type extends Record<string, any>\n ? {\n [Key in keyof Type]-?: NonNullable<Type[Key]> extends NonNullable<U>\n ? NonNullable<Type[Key]>\n : RequiredDeep<NonNullable<Type[Key]>, U>\n }\n : Type\n\n/**\n * @fixme Remove this once TS 5.4 is the lowest supported version.\n * Because \"NoInfer\" is a built-in type utility there.\n */\nexport type NoInfer<T> = [T][T extends any ? 0 : never]\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
node_modules/msw/lib/core/typeUtils.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
//# sourceMappingURL=typeUtils.mjs.map
|
node_modules/msw/lib/core/typeUtils.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
node_modules/msw/lib/core/utils/HttpResponse/decorators.d.mts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { n as HttpResponseInit } from '../../HttpResponse-CQwYpuKo.mjs';
|
| 2 |
+
import '@mswjs/interceptors';
|
| 3 |
+
import '../internal/isIterable.mjs';
|
| 4 |
+
import '../../typeUtils.mjs';
|
| 5 |
+
import 'graphql';
|
| 6 |
+
import '../matching/matchRequestUrl.mjs';
|
| 7 |
+
|
| 8 |
+
interface HttpResponseDecoratedInit extends HttpResponseInit {
|
| 9 |
+
status: number;
|
| 10 |
+
statusText: string;
|
| 11 |
+
headers: Headers;
|
| 12 |
+
}
|
| 13 |
+
declare function normalizeResponseInit(init?: HttpResponseInit): HttpResponseDecoratedInit;
|
| 14 |
+
declare function decorateResponse(response: Response, init: HttpResponseDecoratedInit): Response;
|
| 15 |
+
declare function getRawSetCookie(response: Response): string | undefined;
|
| 16 |
+
|
| 17 |
+
export { type HttpResponseDecoratedInit, decorateResponse, getRawSetCookie, normalizeResponseInit };
|
node_modules/msw/lib/core/utils/HttpResponse/decorators.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { n as HttpResponseInit } from '../../HttpResponse-BFS34nkx.js';
|
| 2 |
+
import '@mswjs/interceptors';
|
| 3 |
+
import '../internal/isIterable.js';
|
| 4 |
+
import '../../typeUtils.js';
|
| 5 |
+
import 'graphql';
|
| 6 |
+
import '../matching/matchRequestUrl.js';
|
| 7 |
+
|
| 8 |
+
interface HttpResponseDecoratedInit extends HttpResponseInit {
|
| 9 |
+
status: number;
|
| 10 |
+
statusText: string;
|
| 11 |
+
headers: Headers;
|
| 12 |
+
}
|
| 13 |
+
declare function normalizeResponseInit(init?: HttpResponseInit): HttpResponseDecoratedInit;
|
| 14 |
+
declare function decorateResponse(response: Response, init: HttpResponseDecoratedInit): Response;
|
| 15 |
+
declare function getRawSetCookie(response: Response): string | undefined;
|
| 16 |
+
|
| 17 |
+
export { type HttpResponseDecoratedInit, decorateResponse, getRawSetCookie, normalizeResponseInit };
|
node_modules/msw/lib/core/utils/HttpResponse/decorators.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __create = Object.create;
|
| 3 |
+
var __defProp = Object.defineProperty;
|
| 4 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
| 5 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
| 6 |
+
var __getProtoOf = Object.getPrototypeOf;
|
| 7 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
| 8 |
+
var __export = (target, all) => {
|
| 9 |
+
for (var name in all)
|
| 10 |
+
__defProp(target, name, { get: all[name], enumerable: true });
|
| 11 |
+
};
|
| 12 |
+
var __copyProps = (to, from, except, desc) => {
|
| 13 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
| 14 |
+
for (let key of __getOwnPropNames(from))
|
| 15 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
| 16 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
| 17 |
+
}
|
| 18 |
+
return to;
|
| 19 |
+
};
|
| 20 |
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
| 21 |
+
// If the importer is in node compatibility mode or this is not an ESM
|
| 22 |
+
// file that has been converted to a CommonJS file using a Babel-
|
| 23 |
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
| 24 |
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
| 25 |
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
| 26 |
+
mod
|
| 27 |
+
));
|
| 28 |
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
| 29 |
+
var decorators_exports = {};
|
| 30 |
+
__export(decorators_exports, {
|
| 31 |
+
decorateResponse: () => decorateResponse,
|
| 32 |
+
getRawSetCookie: () => getRawSetCookie,
|
| 33 |
+
normalizeResponseInit: () => normalizeResponseInit
|
| 34 |
+
});
|
| 35 |
+
module.exports = __toCommonJS(decorators_exports);
|
| 36 |
+
var import_statuses = __toESM(require("../../../shims/statuses"), 1);
|
| 37 |
+
const { message } = import_statuses.default;
|
| 38 |
+
const kSetCookie = Symbol("kSetCookie");
|
| 39 |
+
function normalizeResponseInit(init = {}) {
|
| 40 |
+
const status = init?.status || 200;
|
| 41 |
+
const statusText = init?.statusText || message[status] || "";
|
| 42 |
+
const headers = new Headers(init?.headers);
|
| 43 |
+
return {
|
| 44 |
+
...init,
|
| 45 |
+
headers,
|
| 46 |
+
status,
|
| 47 |
+
statusText
|
| 48 |
+
};
|
| 49 |
+
}
|
| 50 |
+
function decorateResponse(response, init) {
|
| 51 |
+
if (init.type) {
|
| 52 |
+
Object.defineProperty(response, "type", {
|
| 53 |
+
value: init.type,
|
| 54 |
+
enumerable: true,
|
| 55 |
+
writable: false
|
| 56 |
+
});
|
| 57 |
+
}
|
| 58 |
+
const responseCookies = init.headers.get("set-cookie");
|
| 59 |
+
if (responseCookies) {
|
| 60 |
+
Object.defineProperty(response, kSetCookie, {
|
| 61 |
+
value: responseCookies,
|
| 62 |
+
enumerable: false,
|
| 63 |
+
writable: false
|
| 64 |
+
});
|
| 65 |
+
}
|
| 66 |
+
return response;
|
| 67 |
+
}
|
| 68 |
+
function getRawSetCookie(response) {
|
| 69 |
+
return Reflect.get(response, kSetCookie);
|
| 70 |
+
}
|
| 71 |
+
//# sourceMappingURL=decorators.js.map
|
node_modules/msw/lib/core/utils/HttpResponse/decorators.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../../src/core/utils/HttpResponse/decorators.ts"],"sourcesContent":["import statuses from '../../../shims/statuses'\nimport type { HttpResponseInit } from '../../HttpResponse'\n\nconst { message } = statuses\n\nconst kSetCookie = Symbol('kSetCookie')\n\nexport interface HttpResponseDecoratedInit extends HttpResponseInit {\n status: number\n statusText: string\n headers: Headers\n}\n\nexport function normalizeResponseInit(\n init: HttpResponseInit = {},\n): HttpResponseDecoratedInit {\n const status = init?.status || 200\n const statusText = init?.statusText || message[status] || ''\n const headers = new Headers(init?.headers)\n\n return {\n ...init,\n headers,\n status,\n statusText,\n }\n}\n\nexport function decorateResponse(\n response: Response,\n init: HttpResponseDecoratedInit,\n): Response {\n // Allow mocking the response type.\n if (init.type) {\n Object.defineProperty(response, 'type', {\n value: init.type,\n enumerable: true,\n writable: false,\n })\n }\n\n const responseCookies = init.headers.get('set-cookie')\n\n if (responseCookies) {\n // Record the raw \"Set-Cookie\" response header provided\n // in the HeadersInit. This is later used to store these cookies\n // in cookie jar and return the right cookies in the \"cookies\"\n // response resolver argument.\n Object.defineProperty(response, kSetCookie, {\n value: responseCookies,\n enumerable: false,\n writable: false,\n })\n }\n\n return response\n}\n\nexport function getRawSetCookie(response: Response): string | undefined {\n return Reflect.get(response, kSetCookie)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAqB;AAGrB,MAAM,EAAE,QAAQ,IAAI,gBAAAA;AAEpB,MAAM,aAAa,OAAO,YAAY;AAQ/B,SAAS,sBACd,OAAyB,CAAC,GACC;AAC3B,QAAM,SAAS,MAAM,UAAU;AAC/B,QAAM,aAAa,MAAM,cAAc,QAAQ,MAAM,KAAK;AAC1D,QAAM,UAAU,IAAI,QAAQ,MAAM,OAAO;AAEzC,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,iBACd,UACA,MACU;AAEV,MAAI,KAAK,MAAM;AACb,WAAO,eAAe,UAAU,QAAQ;AAAA,MACtC,OAAO,KAAK;AAAA,MACZ,YAAY;AAAA,MACZ,UAAU;AAAA,IACZ,CAAC;AAAA,EACH;AAEA,QAAM,kBAAkB,KAAK,QAAQ,IAAI,YAAY;AAErD,MAAI,iBAAiB;AAKnB,WAAO,eAAe,UAAU,YAAY;AAAA,MAC1C,OAAO;AAAA,MACP,YAAY;AAAA,MACZ,UAAU;AAAA,IACZ,CAAC;AAAA,EACH;AAEA,SAAO;AACT;AAEO,SAAS,gBAAgB,UAAwC;AACtE,SAAO,QAAQ,IAAI,UAAU,UAAU;AACzC;","names":["statuses"]}
|
node_modules/msw/lib/core/utils/HttpResponse/decorators.mjs
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import statuses from '../../../shims/statuses.mjs';
|
| 2 |
+
const { message } = statuses;
|
| 3 |
+
const kSetCookie = Symbol("kSetCookie");
|
| 4 |
+
function normalizeResponseInit(init = {}) {
|
| 5 |
+
const status = init?.status || 200;
|
| 6 |
+
const statusText = init?.statusText || message[status] || "";
|
| 7 |
+
const headers = new Headers(init?.headers);
|
| 8 |
+
return {
|
| 9 |
+
...init,
|
| 10 |
+
headers,
|
| 11 |
+
status,
|
| 12 |
+
statusText
|
| 13 |
+
};
|
| 14 |
+
}
|
| 15 |
+
function decorateResponse(response, init) {
|
| 16 |
+
if (init.type) {
|
| 17 |
+
Object.defineProperty(response, "type", {
|
| 18 |
+
value: init.type,
|
| 19 |
+
enumerable: true,
|
| 20 |
+
writable: false
|
| 21 |
+
});
|
| 22 |
+
}
|
| 23 |
+
const responseCookies = init.headers.get("set-cookie");
|
| 24 |
+
if (responseCookies) {
|
| 25 |
+
Object.defineProperty(response, kSetCookie, {
|
| 26 |
+
value: responseCookies,
|
| 27 |
+
enumerable: false,
|
| 28 |
+
writable: false
|
| 29 |
+
});
|
| 30 |
+
}
|
| 31 |
+
return response;
|
| 32 |
+
}
|
| 33 |
+
function getRawSetCookie(response) {
|
| 34 |
+
return Reflect.get(response, kSetCookie);
|
| 35 |
+
}
|
| 36 |
+
export {
|
| 37 |
+
decorateResponse,
|
| 38 |
+
getRawSetCookie,
|
| 39 |
+
normalizeResponseInit
|
| 40 |
+
};
|
| 41 |
+
//# sourceMappingURL=decorators.mjs.map
|
node_modules/msw/lib/core/utils/HttpResponse/decorators.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../../src/core/utils/HttpResponse/decorators.ts"],"sourcesContent":["import statuses from '../../../shims/statuses'\nimport type { HttpResponseInit } from '../../HttpResponse'\n\nconst { message } = statuses\n\nconst kSetCookie = Symbol('kSetCookie')\n\nexport interface HttpResponseDecoratedInit extends HttpResponseInit {\n status: number\n statusText: string\n headers: Headers\n}\n\nexport function normalizeResponseInit(\n init: HttpResponseInit = {},\n): HttpResponseDecoratedInit {\n const status = init?.status || 200\n const statusText = init?.statusText || message[status] || ''\n const headers = new Headers(init?.headers)\n\n return {\n ...init,\n headers,\n status,\n statusText,\n }\n}\n\nexport function decorateResponse(\n response: Response,\n init: HttpResponseDecoratedInit,\n): Response {\n // Allow mocking the response type.\n if (init.type) {\n Object.defineProperty(response, 'type', {\n value: init.type,\n enumerable: true,\n writable: false,\n })\n }\n\n const responseCookies = init.headers.get('set-cookie')\n\n if (responseCookies) {\n // Record the raw \"Set-Cookie\" response header provided\n // in the HeadersInit. This is later used to store these cookies\n // in cookie jar and return the right cookies in the \"cookies\"\n // response resolver argument.\n Object.defineProperty(response, kSetCookie, {\n value: responseCookies,\n enumerable: false,\n writable: false,\n })\n }\n\n return response\n}\n\nexport function getRawSetCookie(response: Response): string | undefined {\n return Reflect.get(response, kSetCookie)\n}\n"],"mappings":"AAAA,OAAO,cAAc;AAGrB,MAAM,EAAE,QAAQ,IAAI;AAEpB,MAAM,aAAa,OAAO,YAAY;AAQ/B,SAAS,sBACd,OAAyB,CAAC,GACC;AAC3B,QAAM,SAAS,MAAM,UAAU;AAC/B,QAAM,aAAa,MAAM,cAAc,QAAQ,MAAM,KAAK;AAC1D,QAAM,UAAU,IAAI,QAAQ,MAAM,OAAO;AAEzC,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,iBACd,UACA,MACU;AAEV,MAAI,KAAK,MAAM;AACb,WAAO,eAAe,UAAU,QAAQ;AAAA,MACtC,OAAO,KAAK;AAAA,MACZ,YAAY;AAAA,MACZ,UAAU;AAAA,IACZ,CAAC;AAAA,EACH;AAEA,QAAM,kBAAkB,KAAK,QAAQ,IAAI,YAAY;AAErD,MAAI,iBAAiB;AAKnB,WAAO,eAAe,UAAU,YAAY;AAAA,MAC1C,OAAO;AAAA,MACP,YAAY;AAAA,MACZ,UAAU;AAAA,IACZ,CAAC;AAAA,EACH;AAEA,SAAO;AACT;AAEO,SAAS,gBAAgB,UAAwC;AACtE,SAAO,QAAQ,IAAI,UAAU,UAAU;AACzC;","names":[]}
|
node_modules/msw/lib/core/utils/cookieStore.d.mts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { Cookie } from 'tough-cookie';
|
| 2 |
+
|
| 3 |
+
declare class CookieStore {
|
| 4 |
+
#private;
|
| 5 |
+
constructor();
|
| 6 |
+
getCookies(url: string): Array<Cookie>;
|
| 7 |
+
setCookie(cookieName: string, url: string): Promise<void>;
|
| 8 |
+
private getCookieStoreIndex;
|
| 9 |
+
private persist;
|
| 10 |
+
}
|
| 11 |
+
declare const cookieStore: CookieStore;
|
| 12 |
+
|
| 13 |
+
export { cookieStore };
|
node_modules/msw/lib/core/utils/cookieStore.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { Cookie } from 'tough-cookie';
|
| 2 |
+
|
| 3 |
+
declare class CookieStore {
|
| 4 |
+
#private;
|
| 5 |
+
constructor();
|
| 6 |
+
getCookies(url: string): Array<Cookie>;
|
| 7 |
+
setCookie(cookieName: string, url: string): Promise<void>;
|
| 8 |
+
private getCookieStoreIndex;
|
| 9 |
+
private persist;
|
| 10 |
+
}
|
| 11 |
+
declare const cookieStore: CookieStore;
|
| 12 |
+
|
| 13 |
+
export { cookieStore };
|
node_modules/msw/lib/core/utils/cookieStore.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __defProp = Object.defineProperty;
|
| 3 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
| 4 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
| 5 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
| 6 |
+
var __export = (target, all) => {
|
| 7 |
+
for (var name in all)
|
| 8 |
+
__defProp(target, name, { get: all[name], enumerable: true });
|
| 9 |
+
};
|
| 10 |
+
var __copyProps = (to, from, except, desc) => {
|
| 11 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
| 12 |
+
for (let key of __getOwnPropNames(from))
|
| 13 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
| 14 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
| 15 |
+
}
|
| 16 |
+
return to;
|
| 17 |
+
};
|
| 18 |
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
| 19 |
+
var cookieStore_exports = {};
|
| 20 |
+
__export(cookieStore_exports, {
|
| 21 |
+
cookieStore: () => cookieStore
|
| 22 |
+
});
|
| 23 |
+
module.exports = __toCommonJS(cookieStore_exports);
|
| 24 |
+
var import_is_node_process = require("is-node-process");
|
| 25 |
+
var import_outvariant = require("outvariant");
|
| 26 |
+
var import_tough_cookie = require("tough-cookie");
|
| 27 |
+
var import_jsonParse = require("./internal/jsonParse");
|
| 28 |
+
class CookieStore {
|
| 29 |
+
#storageKey = "__msw-cookie-store__";
|
| 30 |
+
#jar;
|
| 31 |
+
#memoryStore;
|
| 32 |
+
constructor() {
|
| 33 |
+
if (!(0, import_is_node_process.isNodeProcess)()) {
|
| 34 |
+
(0, import_outvariant.invariant)(
|
| 35 |
+
typeof localStorage !== "undefined",
|
| 36 |
+
"Failed to create a CookieStore: `localStorage` is not available in this environment. This is likely an issue with your environment, which has been detected as browser (or browser-like) environment and must implement global browser APIs correctly."
|
| 37 |
+
);
|
| 38 |
+
}
|
| 39 |
+
this.#memoryStore = new import_tough_cookie.MemoryCookieStore();
|
| 40 |
+
this.#memoryStore.idx = this.getCookieStoreIndex();
|
| 41 |
+
this.#jar = new import_tough_cookie.CookieJar(this.#memoryStore);
|
| 42 |
+
}
|
| 43 |
+
getCookies(url) {
|
| 44 |
+
return this.#jar.getCookiesSync(url);
|
| 45 |
+
}
|
| 46 |
+
async setCookie(cookieName, url) {
|
| 47 |
+
await this.#jar.setCookie(cookieName, url);
|
| 48 |
+
this.persist();
|
| 49 |
+
}
|
| 50 |
+
getCookieStoreIndex() {
|
| 51 |
+
if (typeof localStorage === "undefined" || typeof localStorage.getItem !== "function") {
|
| 52 |
+
return {};
|
| 53 |
+
}
|
| 54 |
+
const cookiesString = localStorage.getItem(this.#storageKey);
|
| 55 |
+
if (cookiesString == null) {
|
| 56 |
+
return {};
|
| 57 |
+
}
|
| 58 |
+
const rawCookies = (0, import_jsonParse.jsonParse)(cookiesString);
|
| 59 |
+
if (rawCookies == null) {
|
| 60 |
+
return {};
|
| 61 |
+
}
|
| 62 |
+
const cookies = {};
|
| 63 |
+
for (const rawCookie of rawCookies) {
|
| 64 |
+
const cookie = import_tough_cookie.Cookie.fromJSON(rawCookie);
|
| 65 |
+
if (cookie != null && cookie.domain != null && cookie.path != null) {
|
| 66 |
+
cookies[cookie.domain] ||= {};
|
| 67 |
+
cookies[cookie.domain][cookie.path] ||= {};
|
| 68 |
+
cookies[cookie.domain][cookie.path][cookie.key] = cookie;
|
| 69 |
+
}
|
| 70 |
+
}
|
| 71 |
+
return cookies;
|
| 72 |
+
}
|
| 73 |
+
persist() {
|
| 74 |
+
if (typeof localStorage === "undefined" || typeof localStorage.setItem !== "function") {
|
| 75 |
+
return;
|
| 76 |
+
}
|
| 77 |
+
const data = [];
|
| 78 |
+
const { idx } = this.#memoryStore;
|
| 79 |
+
for (const domain in idx) {
|
| 80 |
+
for (const path in idx[domain]) {
|
| 81 |
+
for (const key in idx[domain][path]) {
|
| 82 |
+
data.push(idx[domain][path][key].toJSON());
|
| 83 |
+
}
|
| 84 |
+
}
|
| 85 |
+
}
|
| 86 |
+
localStorage.setItem(this.#storageKey, JSON.stringify(data));
|
| 87 |
+
}
|
| 88 |
+
}
|
| 89 |
+
const cookieStore = new CookieStore();
|
| 90 |
+
//# sourceMappingURL=cookieStore.js.map
|
node_modules/msw/lib/core/utils/cookieStore.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../src/core/utils/cookieStore.ts"],"sourcesContent":["import { isNodeProcess } from 'is-node-process'\nimport { invariant } from 'outvariant'\nimport {\n Cookie,\n CookieJar,\n MemoryCookieStore,\n type SerializedCookie,\n type MemoryCookieStoreIndex,\n} from 'tough-cookie'\nimport { jsonParse } from './internal/jsonParse'\n\nclass CookieStore {\n #storageKey = '__msw-cookie-store__'\n #jar: CookieJar\n #memoryStore: MemoryCookieStore\n\n constructor() {\n if (!isNodeProcess()) {\n invariant(\n typeof localStorage !== 'undefined',\n 'Failed to create a CookieStore: `localStorage` is not available in this environment. This is likely an issue with your environment, which has been detected as browser (or browser-like) environment and must implement global browser APIs correctly.',\n )\n }\n\n this.#memoryStore = new MemoryCookieStore()\n this.#memoryStore.idx = this.getCookieStoreIndex()\n this.#jar = new CookieJar(this.#memoryStore)\n }\n\n public getCookies(url: string): Array<Cookie> {\n return this.#jar.getCookiesSync(url)\n }\n\n public async setCookie(cookieName: string, url: string): Promise<void> {\n await this.#jar.setCookie(cookieName, url)\n this.persist()\n }\n\n private getCookieStoreIndex(): MemoryCookieStoreIndex {\n if (\n typeof localStorage === 'undefined' ||\n typeof localStorage.getItem !== 'function'\n ) {\n return {}\n }\n\n const cookiesString = localStorage.getItem(this.#storageKey)\n if (cookiesString == null) {\n return {}\n }\n\n const rawCookies = jsonParse<Array<Record<string, unknown>>>(cookiesString)\n if (rawCookies == null) {\n return {}\n }\n\n const cookies: MemoryCookieStoreIndex = {}\n\n for (const rawCookie of rawCookies) {\n const cookie = Cookie.fromJSON(rawCookie)\n\n if (cookie != null && cookie.domain != null && cookie.path != null) {\n cookies[cookie.domain] ||= {}\n cookies[cookie.domain][cookie.path] ||= {}\n cookies[cookie.domain][cookie.path][cookie.key] = cookie\n }\n }\n\n return cookies\n }\n\n private persist(): void {\n if (\n typeof localStorage === 'undefined' ||\n typeof localStorage.setItem !== 'function'\n ) {\n return\n }\n\n const data: Array<SerializedCookie> = []\n const { idx } = this.#memoryStore\n\n for (const domain in idx) {\n for (const path in idx[domain]) {\n for (const key in idx[domain][path]) {\n data.push(idx[domain][path][key].toJSON())\n }\n }\n }\n\n localStorage.setItem(this.#storageKey, JSON.stringify(data))\n }\n}\n\nexport const cookieStore = new CookieStore()\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAA8B;AAC9B,wBAA0B;AAC1B,0BAMO;AACP,uBAA0B;AAE1B,MAAM,YAAY;AAAA,EACh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AACvC,UAAM,EAAE,IAAI,IAAI,KAAK;AAErB,eAAW,UAAU,KAAK;AACxB,iBAAW,QAAQ,IAAI,MAAM,GAAG;AAC9B,mBAAW,OAAO,IAAI,MAAM,EAAE,IAAI,GAAG;AACnC,eAAK,KAAK,IAAI,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC;AAAA,QAC3C;AAAA,MACF;AAAA,IACF;AAEA,iBAAa,QAAQ,KAAK,aAAa,KAAK,UAAU,IAAI,CAAC;AAAA,EAC7D;AACF;AAEO,MAAM,cAAc,IAAI,YAAY;","names":[]}
|
node_modules/msw/lib/core/utils/cookieStore.mjs
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { isNodeProcess } from "is-node-process";
|
| 2 |
+
import { invariant } from "outvariant";
|
| 3 |
+
import {
|
| 4 |
+
Cookie,
|
| 5 |
+
CookieJar,
|
| 6 |
+
MemoryCookieStore
|
| 7 |
+
} from "tough-cookie";
|
| 8 |
+
import { jsonParse } from './internal/jsonParse.mjs';
|
| 9 |
+
class CookieStore {
|
| 10 |
+
#storageKey = "__msw-cookie-store__";
|
| 11 |
+
#jar;
|
| 12 |
+
#memoryStore;
|
| 13 |
+
constructor() {
|
| 14 |
+
if (!isNodeProcess()) {
|
| 15 |
+
invariant(
|
| 16 |
+
typeof localStorage !== "undefined",
|
| 17 |
+
"Failed to create a CookieStore: `localStorage` is not available in this environment. This is likely an issue with your environment, which has been detected as browser (or browser-like) environment and must implement global browser APIs correctly."
|
| 18 |
+
);
|
| 19 |
+
}
|
| 20 |
+
this.#memoryStore = new MemoryCookieStore();
|
| 21 |
+
this.#memoryStore.idx = this.getCookieStoreIndex();
|
| 22 |
+
this.#jar = new CookieJar(this.#memoryStore);
|
| 23 |
+
}
|
| 24 |
+
getCookies(url) {
|
| 25 |
+
return this.#jar.getCookiesSync(url);
|
| 26 |
+
}
|
| 27 |
+
async setCookie(cookieName, url) {
|
| 28 |
+
await this.#jar.setCookie(cookieName, url);
|
| 29 |
+
this.persist();
|
| 30 |
+
}
|
| 31 |
+
getCookieStoreIndex() {
|
| 32 |
+
if (typeof localStorage === "undefined" || typeof localStorage.getItem !== "function") {
|
| 33 |
+
return {};
|
| 34 |
+
}
|
| 35 |
+
const cookiesString = localStorage.getItem(this.#storageKey);
|
| 36 |
+
if (cookiesString == null) {
|
| 37 |
+
return {};
|
| 38 |
+
}
|
| 39 |
+
const rawCookies = jsonParse(cookiesString);
|
| 40 |
+
if (rawCookies == null) {
|
| 41 |
+
return {};
|
| 42 |
+
}
|
| 43 |
+
const cookies = {};
|
| 44 |
+
for (const rawCookie of rawCookies) {
|
| 45 |
+
const cookie = Cookie.fromJSON(rawCookie);
|
| 46 |
+
if (cookie != null && cookie.domain != null && cookie.path != null) {
|
| 47 |
+
cookies[cookie.domain] ||= {};
|
| 48 |
+
cookies[cookie.domain][cookie.path] ||= {};
|
| 49 |
+
cookies[cookie.domain][cookie.path][cookie.key] = cookie;
|
| 50 |
+
}
|
| 51 |
+
}
|
| 52 |
+
return cookies;
|
| 53 |
+
}
|
| 54 |
+
persist() {
|
| 55 |
+
if (typeof localStorage === "undefined" || typeof localStorage.setItem !== "function") {
|
| 56 |
+
return;
|
| 57 |
+
}
|
| 58 |
+
const data = [];
|
| 59 |
+
const { idx } = this.#memoryStore;
|
| 60 |
+
for (const domain in idx) {
|
| 61 |
+
for (const path in idx[domain]) {
|
| 62 |
+
for (const key in idx[domain][path]) {
|
| 63 |
+
data.push(idx[domain][path][key].toJSON());
|
| 64 |
+
}
|
| 65 |
+
}
|
| 66 |
+
}
|
| 67 |
+
localStorage.setItem(this.#storageKey, JSON.stringify(data));
|
| 68 |
+
}
|
| 69 |
+
}
|
| 70 |
+
const cookieStore = new CookieStore();
|
| 71 |
+
export {
|
| 72 |
+
cookieStore
|
| 73 |
+
};
|
| 74 |
+
//# sourceMappingURL=cookieStore.mjs.map
|
node_modules/msw/lib/core/utils/cookieStore.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../src/core/utils/cookieStore.ts"],"sourcesContent":["import { isNodeProcess } from 'is-node-process'\nimport { invariant } from 'outvariant'\nimport {\n Cookie,\n CookieJar,\n MemoryCookieStore,\n type SerializedCookie,\n type MemoryCookieStoreIndex,\n} from 'tough-cookie'\nimport { jsonParse } from './internal/jsonParse'\n\nclass CookieStore {\n #storageKey = '__msw-cookie-store__'\n #jar: CookieJar\n #memoryStore: MemoryCookieStore\n\n constructor() {\n if (!isNodeProcess()) {\n invariant(\n typeof localStorage !== 'undefined',\n 'Failed to create a CookieStore: `localStorage` is not available in this environment. This is likely an issue with your environment, which has been detected as browser (or browser-like) environment and must implement global browser APIs correctly.',\n )\n }\n\n this.#memoryStore = new MemoryCookieStore()\n this.#memoryStore.idx = this.getCookieStoreIndex()\n this.#jar = new CookieJar(this.#memoryStore)\n }\n\n public getCookies(url: string): Array<Cookie> {\n return this.#jar.getCookiesSync(url)\n }\n\n public async setCookie(cookieName: string, url: string): Promise<void> {\n await this.#jar.setCookie(cookieName, url)\n this.persist()\n }\n\n private getCookieStoreIndex(): MemoryCookieStoreIndex {\n if (\n typeof localStorage === 'undefined' ||\n typeof localStorage.getItem !== 'function'\n ) {\n return {}\n }\n\n const cookiesString = localStorage.getItem(this.#storageKey)\n if (cookiesString == null) {\n return {}\n }\n\n const rawCookies = jsonParse<Array<Record<string, unknown>>>(cookiesString)\n if (rawCookies == null) {\n return {}\n }\n\n const cookies: MemoryCookieStoreIndex = {}\n\n for (const rawCookie of rawCookies) {\n const cookie = Cookie.fromJSON(rawCookie)\n\n if (cookie != null && cookie.domain != null && cookie.path != null) {\n cookies[cookie.domain] ||= {}\n cookies[cookie.domain][cookie.path] ||= {}\n cookies[cookie.domain][cookie.path][cookie.key] = cookie\n }\n }\n\n return cookies\n }\n\n private persist(): void {\n if (\n typeof localStorage === 'undefined' ||\n typeof localStorage.setItem !== 'function'\n ) {\n return\n }\n\n const data: Array<SerializedCookie> = []\n const { idx } = this.#memoryStore\n\n for (const domain in idx) {\n for (const path in idx[domain]) {\n for (const key in idx[domain][path]) {\n data.push(idx[domain][path][key].toJSON())\n }\n }\n }\n\n localStorage.setItem(this.#storageKey, JSON.stringify(data))\n }\n}\n\nexport const cookieStore = new CookieStore()\n"],"mappings":"AAAA,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAC1B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,iBAAiB;AAE1B,MAAM,YAAY;AAAA,EAChB,cAAc;AAAA,EACd;AAAA,EACA;AAAA,EAEA,cAAc;AACZ,QAAI,CAAC,cAAc,GAAG;AACpB;AAAA,QACE,OAAO,iBAAiB;AAAA,QACxB;AAAA,MACF;AAAA,IACF;AAEA,SAAK,eAAe,IAAI,kBAAkB;AAC1C,SAAK,aAAa,MAAM,KAAK,oBAAoB;AACjD,SAAK,OAAO,IAAI,UAAU,KAAK,YAAY;AAAA,EAC7C;AAAA,EAEO,WAAW,KAA4B;AAC5C,WAAO,KAAK,KAAK,eAAe,GAAG;AAAA,EACrC;AAAA,EAEA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names":[]}
|
node_modules/msw/lib/core/utils/executeHandlers.d.mts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export { s as HandlersExecutionResult, m as ResponseResolutionContext, t as executeHandlers } from '../HttpResponse-CQwYpuKo.mjs';
|
| 2 |
+
import '@mswjs/interceptors';
|
| 3 |
+
import './internal/isIterable.mjs';
|
| 4 |
+
import '../typeUtils.mjs';
|
| 5 |
+
import 'graphql';
|
| 6 |
+
import './matching/matchRequestUrl.mjs';
|
node_modules/msw/lib/core/utils/executeHandlers.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export { s as HandlersExecutionResult, m as ResponseResolutionContext, t as executeHandlers } from '../HttpResponse-BFS34nkx.js';
|
| 2 |
+
import '@mswjs/interceptors';
|
| 3 |
+
import './internal/isIterable.js';
|
| 4 |
+
import '../typeUtils.js';
|
| 5 |
+
import 'graphql';
|
| 6 |
+
import './matching/matchRequestUrl.js';
|
node_modules/msw/lib/core/utils/executeHandlers.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __defProp = Object.defineProperty;
|
| 3 |
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
| 4 |
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
| 5 |
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
| 6 |
+
var __export = (target, all) => {
|
| 7 |
+
for (var name in all)
|
| 8 |
+
__defProp(target, name, { get: all[name], enumerable: true });
|
| 9 |
+
};
|
| 10 |
+
var __copyProps = (to, from, except, desc) => {
|
| 11 |
+
if (from && typeof from === "object" || typeof from === "function") {
|
| 12 |
+
for (let key of __getOwnPropNames(from))
|
| 13 |
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
| 14 |
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
| 15 |
+
}
|
| 16 |
+
return to;
|
| 17 |
+
};
|
| 18 |
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
| 19 |
+
var executeHandlers_exports = {};
|
| 20 |
+
__export(executeHandlers_exports, {
|
| 21 |
+
executeHandlers: () => executeHandlers
|
| 22 |
+
});
|
| 23 |
+
module.exports = __toCommonJS(executeHandlers_exports);
|
| 24 |
+
var import_RequestHandler = require("../handlers/RequestHandler");
|
| 25 |
+
const executeHandlers = async ({
|
| 26 |
+
request,
|
| 27 |
+
requestId,
|
| 28 |
+
handlers,
|
| 29 |
+
resolutionContext
|
| 30 |
+
}) => {
|
| 31 |
+
let matchingHandler = null;
|
| 32 |
+
let result = null;
|
| 33 |
+
for (const handler of handlers) {
|
| 34 |
+
result = await handler.run({ request, requestId, resolutionContext });
|
| 35 |
+
if (result !== null) {
|
| 36 |
+
matchingHandler = handler;
|
| 37 |
+
}
|
| 38 |
+
if (result?.response) {
|
| 39 |
+
break;
|
| 40 |
+
}
|
| 41 |
+
}
|
| 42 |
+
if (matchingHandler) {
|
| 43 |
+
return {
|
| 44 |
+
handler: matchingHandler,
|
| 45 |
+
parsedResult: result?.parsedResult,
|
| 46 |
+
response: result?.response
|
| 47 |
+
};
|
| 48 |
+
}
|
| 49 |
+
return null;
|
| 50 |
+
};
|
| 51 |
+
//# sourceMappingURL=executeHandlers.js.map
|
node_modules/msw/lib/core/utils/executeHandlers.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../src/core/utils/executeHandlers.ts"],"sourcesContent":["import type { RequestHandler } from '../handlers/RequestHandler'\nimport { type RequestHandlerExecutionResult } from '../handlers/RequestHandler'\n\nexport interface HandlersExecutionResult {\n handler: RequestHandler\n parsedResult?: any\n response?: Response\n}\n\nexport interface ResponseResolutionContext {\n /**\n * A base url to use when resolving relative urls.\n * @note This is primarily used by the `@mswjs/http-middleware`\n * to resolve relative urls in the context of the running server\n */\n baseUrl?: string\n quiet?: boolean\n}\n\n/**\n * Executes the list of request handlers against the given request.\n * Returns the execution result object containing any matching request\n * handler and any mocked response it returned.\n */\nexport const executeHandlers = async <Handlers extends Array<RequestHandler>>({\n request,\n requestId,\n handlers,\n resolutionContext,\n}: {\n request: Request\n requestId: string\n handlers: Handlers\n resolutionContext?: ResponseResolutionContext\n}): Promise<HandlersExecutionResult | null> => {\n let matchingHandler: RequestHandler | null = null\n let result: RequestHandlerExecutionResult<any> | null = null\n\n for (const handler of handlers) {\n result = await handler.run({ request, requestId, resolutionContext })\n\n // If the handler produces some result for this request,\n // it automatically becomes matching.\n if (result !== null) {\n matchingHandler = handler\n }\n\n // Stop the lookup if this handler returns a mocked response.\n // If it doesn't, it will still be considered the last matching\n // handler until any of them returns a response. This way we can\n // distinguish between fallthrough handlers without responses\n // and the lack of a matching handler.\n if (result?.response) {\n break\n }\n }\n\n if (matchingHandler) {\n return {\n handler: matchingHandler,\n parsedResult: result?.parsedResult,\n response: result?.response,\n }\n }\n\n return null\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,4BAAmD;AAuB5C,MAAM,kBAAkB,OAA+C;AAAA,EAC5E;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAK+C;AAC7C,MAAI,kBAAyC;AAC7C,MAAI,SAAoD;AAExD,aAAW,WAAW,UAAU;AAC9B,aAAS,MAAM,QAAQ,IAAI,EAAE,SAAS,WAAW,kBAAkB,CAAC;AAIpE,QAAI,WAAW,MAAM;AACnB,wBAAkB;AAAA,IACpB;AAOA,QAAI,QAAQ,UAAU;AACpB;AAAA,IACF;AAAA,EACF;AAEA,MAAI,iBAAiB;AACnB,WAAO;AAAA,MACL,SAAS;AAAA,MACT,cAAc,QAAQ;AAAA,MACtB,UAAU,QAAQ;AAAA,IACpB;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|
node_modules/msw/lib/core/utils/executeHandlers.mjs
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import {} from '../handlers/RequestHandler.mjs';
|
| 2 |
+
const executeHandlers = async ({
|
| 3 |
+
request,
|
| 4 |
+
requestId,
|
| 5 |
+
handlers,
|
| 6 |
+
resolutionContext
|
| 7 |
+
}) => {
|
| 8 |
+
let matchingHandler = null;
|
| 9 |
+
let result = null;
|
| 10 |
+
for (const handler of handlers) {
|
| 11 |
+
result = await handler.run({ request, requestId, resolutionContext });
|
| 12 |
+
if (result !== null) {
|
| 13 |
+
matchingHandler = handler;
|
| 14 |
+
}
|
| 15 |
+
if (result?.response) {
|
| 16 |
+
break;
|
| 17 |
+
}
|
| 18 |
+
}
|
| 19 |
+
if (matchingHandler) {
|
| 20 |
+
return {
|
| 21 |
+
handler: matchingHandler,
|
| 22 |
+
parsedResult: result?.parsedResult,
|
| 23 |
+
response: result?.response
|
| 24 |
+
};
|
| 25 |
+
}
|
| 26 |
+
return null;
|
| 27 |
+
};
|
| 28 |
+
export {
|
| 29 |
+
executeHandlers
|
| 30 |
+
};
|
| 31 |
+
//# sourceMappingURL=executeHandlers.mjs.map
|
node_modules/msw/lib/core/utils/executeHandlers.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"sources":["../../../src/core/utils/executeHandlers.ts"],"sourcesContent":["import type { RequestHandler } from '../handlers/RequestHandler'\nimport { type RequestHandlerExecutionResult } from '../handlers/RequestHandler'\n\nexport interface HandlersExecutionResult {\n handler: RequestHandler\n parsedResult?: any\n response?: Response\n}\n\nexport interface ResponseResolutionContext {\n /**\n * A base url to use when resolving relative urls.\n * @note This is primarily used by the `@mswjs/http-middleware`\n * to resolve relative urls in the context of the running server\n */\n baseUrl?: string\n quiet?: boolean\n}\n\n/**\n * Executes the list of request handlers against the given request.\n * Returns the execution result object containing any matching request\n * handler and any mocked response it returned.\n */\nexport const executeHandlers = async <Handlers extends Array<RequestHandler>>({\n request,\n requestId,\n handlers,\n resolutionContext,\n}: {\n request: Request\n requestId: string\n handlers: Handlers\n resolutionContext?: ResponseResolutionContext\n}): Promise<HandlersExecutionResult | null> => {\n let matchingHandler: RequestHandler | null = null\n let result: RequestHandlerExecutionResult<any> | null = null\n\n for (const handler of handlers) {\n result = await handler.run({ request, requestId, resolutionContext })\n\n // If the handler produces some result for this request,\n // it automatically becomes matching.\n if (result !== null) {\n matchingHandler = handler\n }\n\n // Stop the lookup if this handler returns a mocked response.\n // If it doesn't, it will still be considered the last matching\n // handler until any of them returns a response. This way we can\n // distinguish between fallthrough handlers without responses\n // and the lack of a matching handler.\n if (result?.response) {\n break\n }\n }\n\n if (matchingHandler) {\n return {\n handler: matchingHandler,\n parsedResult: result?.parsedResult,\n response: result?.response,\n }\n }\n\n return null\n}\n"],"mappings":"AACA,eAAmD;AAuB5C,MAAM,kBAAkB,OAA+C;AAAA,EAC5E;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAK+C;AAC7C,MAAI,kBAAyC;AAC7C,MAAI,SAAoD;AAExD,aAAW,WAAW,UAAU;AAC9B,aAAS,MAAM,QAAQ,IAAI,EAAE,SAAS,WAAW,kBAAkB,CAAC;AAIpE,QAAI,WAAW,MAAM;AACnB,wBAAkB;AAAA,IACpB;AAOA,QAAI,QAAQ,UAAU;AACpB;AAAA,IACF;AAAA,EACF;AAEA,MAAI,iBAAiB;AACnB,WAAO;AAAA,MACL,SAAS;AAAA,MACT,cAAc,QAAQ;AAAA,MACtB,UAAU,QAAQ;AAAA,IACpB;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
|