修改后台权限
This commit is contained in:
91
node_modules/msw/lib/node/index.d.mts
generated
vendored
Normal file
91
node_modules/msw/lib/node/index.d.mts
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
import { PartialDeep } from 'type-fest';
|
||||
import { RequestHandler } from "../core/handlers/RequestHandler.mjs";
|
||||
import { WebSocketHandler } from "../core/handlers/WebSocketHandler.mjs";
|
||||
import { SharedOptions, LifeCycleEventEmitter, LifeCycleEventsMap } from "../core/sharedOptions.mjs";
|
||||
import { BatchInterceptor, Interceptor, HttpRequestEventMap } from '@mswjs/interceptors';
|
||||
import { SetupApi } from "../core/SetupApi.mjs";
|
||||
|
||||
interface SetupServerCommon {
|
||||
/**
|
||||
* Starts requests interception based on the previously provided request handlers.
|
||||
*
|
||||
* @see {@link https://mswjs.io/docs/api/setup-server/listen `server.listen()` API reference}
|
||||
*/
|
||||
listen(options?: PartialDeep<SharedOptions>): void;
|
||||
/**
|
||||
* Stops requests interception by restoring all augmented modules.
|
||||
*
|
||||
* @see {@link https://mswjs.io/docs/api/setup-server/close `server.close()` API reference}
|
||||
*/
|
||||
close(): void;
|
||||
/**
|
||||
* Prepends given request handlers to the list of existing handlers.
|
||||
*
|
||||
* @see {@link https://mswjs.io/docs/api/setup-server/use `server.use()` API reference}
|
||||
*/
|
||||
use(...handlers: Array<RequestHandler | WebSocketHandler>): void;
|
||||
/**
|
||||
* Marks all request handlers that respond using `res.once()` as unused.
|
||||
*
|
||||
* @see {@link https://mswjs.io/docs/api/setup-server/restore-handlers `server.restore-handlers()` API reference}
|
||||
*/
|
||||
restoreHandlers(): void;
|
||||
/**
|
||||
* Resets request handlers to the initial list given to the `setupServer` call, or to the explicit next request handlers list, if given.
|
||||
*
|
||||
* @see {@link https://mswjs.io/docs/api/setup-server/reset-handlers `server.reset-handlers()` API reference}
|
||||
*/
|
||||
resetHandlers(...nextHandlers: Array<RequestHandler | WebSocketHandler>): void;
|
||||
/**
|
||||
* Returns a readonly list of currently active request handlers.
|
||||
*
|
||||
* @see {@link https://mswjs.io/docs/api/setup-server/list-handlers `server.listHandlers()` API reference}
|
||||
*/
|
||||
listHandlers(): ReadonlyArray<RequestHandler | WebSocketHandler>;
|
||||
/**
|
||||
* Life-cycle events.
|
||||
* Life-cycle events allow you to subscribe to the internal library events occurring during the request/response handling.
|
||||
*
|
||||
* @see {@link https://mswjs.io/docs/api/life-cycle-events Life-cycle Events API reference}
|
||||
*/
|
||||
events: LifeCycleEventEmitter<LifeCycleEventsMap>;
|
||||
}
|
||||
interface SetupServer extends SetupServerCommon {
|
||||
/**
|
||||
* Wraps the given function in a boundary. Any changes to the
|
||||
* network behavior (e.g. adding runtime request handlers via
|
||||
* `server.use()`) will be scoped to this boundary only.
|
||||
* @param callback A function to run (e.g. a test)
|
||||
*
|
||||
* @see {@link https://mswjs.io/docs/api/setup-server/boundary `server.boundary()` API reference}
|
||||
*/
|
||||
boundary<Args extends Array<any>, R>(callback: (...args: Args) => R): (...args: Args) => R;
|
||||
}
|
||||
|
||||
declare class SetupServerCommonApi extends SetupApi<LifeCycleEventsMap> implements SetupServerCommon {
|
||||
protected readonly interceptor: BatchInterceptor<Array<Interceptor<HttpRequestEventMap>>, HttpRequestEventMap>;
|
||||
private resolvedOptions;
|
||||
constructor(interceptors: Array<Interceptor<HttpRequestEventMap>>, handlers: Array<RequestHandler | WebSocketHandler>);
|
||||
/**
|
||||
* Subscribe to all requests that are using the interceptor object
|
||||
*/
|
||||
private init;
|
||||
listen(options?: Partial<SharedOptions>): void;
|
||||
close(): void;
|
||||
}
|
||||
|
||||
declare class SetupServerApi extends SetupServerCommonApi implements SetupServer {
|
||||
constructor(handlers: Array<RequestHandler | WebSocketHandler>, interceptors?: Array<Interceptor<HttpRequestEventMap>>);
|
||||
boundary<Args extends Array<any>, R>(callback: (...args: Args) => R): (...args: Args) => R;
|
||||
close(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up a requests interception in Node.js with the given request handlers.
|
||||
* @param {RequestHandler[]} handlers List of request handlers.
|
||||
*
|
||||
* @see {@link https://mswjs.io/docs/api/setup-server `setupServer()` API reference}
|
||||
*/
|
||||
declare const setupServer: (...handlers: Array<RequestHandler | WebSocketHandler>) => SetupServerApi;
|
||||
|
||||
export { type SetupServer, SetupServerApi, setupServer };
|
||||
91
node_modules/msw/lib/node/index.d.ts
generated
vendored
Normal file
91
node_modules/msw/lib/node/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
import { PartialDeep } from 'type-fest';
|
||||
import { RequestHandler } from "../core/handlers/RequestHandler";
|
||||
import { WebSocketHandler } from "../core/handlers/WebSocketHandler";
|
||||
import { SharedOptions, LifeCycleEventEmitter, LifeCycleEventsMap } from "../core/sharedOptions";
|
||||
import { BatchInterceptor, Interceptor, HttpRequestEventMap } from '@mswjs/interceptors';
|
||||
import { SetupApi } from "../core/SetupApi";
|
||||
|
||||
interface SetupServerCommon {
|
||||
/**
|
||||
* Starts requests interception based on the previously provided request handlers.
|
||||
*
|
||||
* @see {@link https://mswjs.io/docs/api/setup-server/listen `server.listen()` API reference}
|
||||
*/
|
||||
listen(options?: PartialDeep<SharedOptions>): void;
|
||||
/**
|
||||
* Stops requests interception by restoring all augmented modules.
|
||||
*
|
||||
* @see {@link https://mswjs.io/docs/api/setup-server/close `server.close()` API reference}
|
||||
*/
|
||||
close(): void;
|
||||
/**
|
||||
* Prepends given request handlers to the list of existing handlers.
|
||||
*
|
||||
* @see {@link https://mswjs.io/docs/api/setup-server/use `server.use()` API reference}
|
||||
*/
|
||||
use(...handlers: Array<RequestHandler | WebSocketHandler>): void;
|
||||
/**
|
||||
* Marks all request handlers that respond using `res.once()` as unused.
|
||||
*
|
||||
* @see {@link https://mswjs.io/docs/api/setup-server/restore-handlers `server.restore-handlers()` API reference}
|
||||
*/
|
||||
restoreHandlers(): void;
|
||||
/**
|
||||
* Resets request handlers to the initial list given to the `setupServer` call, or to the explicit next request handlers list, if given.
|
||||
*
|
||||
* @see {@link https://mswjs.io/docs/api/setup-server/reset-handlers `server.reset-handlers()` API reference}
|
||||
*/
|
||||
resetHandlers(...nextHandlers: Array<RequestHandler | WebSocketHandler>): void;
|
||||
/**
|
||||
* Returns a readonly list of currently active request handlers.
|
||||
*
|
||||
* @see {@link https://mswjs.io/docs/api/setup-server/list-handlers `server.listHandlers()` API reference}
|
||||
*/
|
||||
listHandlers(): ReadonlyArray<RequestHandler | WebSocketHandler>;
|
||||
/**
|
||||
* Life-cycle events.
|
||||
* Life-cycle events allow you to subscribe to the internal library events occurring during the request/response handling.
|
||||
*
|
||||
* @see {@link https://mswjs.io/docs/api/life-cycle-events Life-cycle Events API reference}
|
||||
*/
|
||||
events: LifeCycleEventEmitter<LifeCycleEventsMap>;
|
||||
}
|
||||
interface SetupServer extends SetupServerCommon {
|
||||
/**
|
||||
* Wraps the given function in a boundary. Any changes to the
|
||||
* network behavior (e.g. adding runtime request handlers via
|
||||
* `server.use()`) will be scoped to this boundary only.
|
||||
* @param callback A function to run (e.g. a test)
|
||||
*
|
||||
* @see {@link https://mswjs.io/docs/api/setup-server/boundary `server.boundary()` API reference}
|
||||
*/
|
||||
boundary<Args extends Array<any>, R>(callback: (...args: Args) => R): (...args: Args) => R;
|
||||
}
|
||||
|
||||
declare class SetupServerCommonApi extends SetupApi<LifeCycleEventsMap> implements SetupServerCommon {
|
||||
protected readonly interceptor: BatchInterceptor<Array<Interceptor<HttpRequestEventMap>>, HttpRequestEventMap>;
|
||||
private resolvedOptions;
|
||||
constructor(interceptors: Array<Interceptor<HttpRequestEventMap>>, handlers: Array<RequestHandler | WebSocketHandler>);
|
||||
/**
|
||||
* Subscribe to all requests that are using the interceptor object
|
||||
*/
|
||||
private init;
|
||||
listen(options?: Partial<SharedOptions>): void;
|
||||
close(): void;
|
||||
}
|
||||
|
||||
declare class SetupServerApi extends SetupServerCommonApi implements SetupServer {
|
||||
constructor(handlers: Array<RequestHandler | WebSocketHandler>, interceptors?: Array<Interceptor<HttpRequestEventMap>>);
|
||||
boundary<Args extends Array<any>, R>(callback: (...args: Args) => R): (...args: Args) => R;
|
||||
close(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up a requests interception in Node.js with the given request handlers.
|
||||
* @param {RequestHandler[]} handlers List of request handlers.
|
||||
*
|
||||
* @see {@link https://mswjs.io/docs/api/setup-server `setupServer()` API reference}
|
||||
*/
|
||||
declare const setupServer: (...handlers: Array<RequestHandler | WebSocketHandler>) => SetupServerApi;
|
||||
|
||||
export { type SetupServer, SetupServerApi, setupServer };
|
||||
209
node_modules/msw/lib/node/index.js
generated
vendored
Normal file
209
node_modules/msw/lib/node/index.js
generated
vendored
Normal file
@@ -0,0 +1,209 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// src/node/index.ts
|
||||
var index_exports = {};
|
||||
__export(index_exports, {
|
||||
SetupServerApi: () => SetupServerApi,
|
||||
setupServer: () => setupServer
|
||||
});
|
||||
module.exports = __toCommonJS(index_exports);
|
||||
|
||||
// src/node/SetupServerApi.ts
|
||||
var import_node_async_hooks = require("async_hooks");
|
||||
var import_ClientRequest = require("@mswjs/interceptors/ClientRequest");
|
||||
var import_XMLHttpRequest = require("@mswjs/interceptors/XMLHttpRequest");
|
||||
var import_fetch = require("@mswjs/interceptors/fetch");
|
||||
|
||||
// src/node/SetupServerCommonApi.ts
|
||||
var import_outvariant = require("outvariant");
|
||||
var import_interceptors = require("@mswjs/interceptors");
|
||||
var import_SetupApi = require("../core/SetupApi");
|
||||
var import_handleRequest = require("../core/utils/handleRequest");
|
||||
var import_mergeRight = require("../core/utils/internal/mergeRight");
|
||||
var import_devUtils = require("../core/utils/internal/devUtils");
|
||||
var import_handleWebSocketEvent = require("../core/ws/handleWebSocketEvent");
|
||||
var import_webSocketInterceptor = require("../core/ws/webSocketInterceptor");
|
||||
var import_isHandlerKind = require("../core/utils/internal/isHandlerKind");
|
||||
var DEFAULT_LISTEN_OPTIONS = {
|
||||
onUnhandledRequest: "warn"
|
||||
};
|
||||
var SetupServerCommonApi = class extends import_SetupApi.SetupApi {
|
||||
interceptor;
|
||||
resolvedOptions;
|
||||
constructor(interceptors, handlers) {
|
||||
super(...handlers);
|
||||
this.interceptor = new import_interceptors.BatchInterceptor({
|
||||
name: "setup-server",
|
||||
interceptors
|
||||
});
|
||||
this.resolvedOptions = {};
|
||||
}
|
||||
/**
|
||||
* Subscribe to all requests that are using the interceptor object
|
||||
*/
|
||||
init() {
|
||||
this.interceptor.on(
|
||||
"request",
|
||||
async ({ request, requestId, controller }) => {
|
||||
const response = await (0, import_handleRequest.handleRequest)(
|
||||
request,
|
||||
requestId,
|
||||
this.handlersController.currentHandlers().filter((0, import_isHandlerKind.isHandlerKind)("RequestHandler")),
|
||||
this.resolvedOptions,
|
||||
this.emitter,
|
||||
{
|
||||
onPassthroughResponse(request2) {
|
||||
const acceptHeader = request2.headers.get("accept");
|
||||
if (acceptHeader) {
|
||||
const nextAcceptHeader = acceptHeader.replace(
|
||||
/(,\s+)?msw\/passthrough/,
|
||||
""
|
||||
);
|
||||
if (nextAcceptHeader) {
|
||||
request2.headers.set("accept", nextAcceptHeader);
|
||||
} else {
|
||||
request2.headers.delete("accept");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
if (response) {
|
||||
controller.respondWith(response);
|
||||
}
|
||||
return;
|
||||
}
|
||||
);
|
||||
this.interceptor.on("unhandledException", ({ error }) => {
|
||||
if (error instanceof import_devUtils.InternalError) {
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
this.interceptor.on(
|
||||
"response",
|
||||
({ response, isMockedResponse, request, requestId }) => {
|
||||
this.emitter.emit(
|
||||
isMockedResponse ? "response:mocked" : "response:bypass",
|
||||
{
|
||||
response,
|
||||
request,
|
||||
requestId
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
(0, import_handleWebSocketEvent.handleWebSocketEvent)({
|
||||
getUnhandledRequestStrategy: () => {
|
||||
return this.resolvedOptions.onUnhandledRequest;
|
||||
},
|
||||
getHandlers: () => {
|
||||
return this.handlersController.currentHandlers();
|
||||
},
|
||||
onMockedConnection: () => {
|
||||
},
|
||||
onPassthroughConnection: () => {
|
||||
}
|
||||
});
|
||||
}
|
||||
listen(options = {}) {
|
||||
this.resolvedOptions = (0, import_mergeRight.mergeRight)(
|
||||
DEFAULT_LISTEN_OPTIONS,
|
||||
options
|
||||
);
|
||||
this.interceptor.apply();
|
||||
this.init();
|
||||
this.subscriptions.push(() => this.interceptor.dispose());
|
||||
import_webSocketInterceptor.webSocketInterceptor.apply();
|
||||
this.subscriptions.push(() => import_webSocketInterceptor.webSocketInterceptor.dispose());
|
||||
(0, import_outvariant.invariant)(
|
||||
[import_interceptors.InterceptorReadyState.APPLYING, import_interceptors.InterceptorReadyState.APPLIED].includes(
|
||||
this.interceptor.readyState
|
||||
),
|
||||
import_devUtils.devUtils.formatMessage(
|
||||
'Failed to start "setupServer": the interceptor failed to apply. This is likely an issue with the library and you should report it at "%s".'
|
||||
),
|
||||
"https://github.com/mswjs/msw/issues/new/choose"
|
||||
);
|
||||
}
|
||||
close() {
|
||||
this.dispose();
|
||||
}
|
||||
};
|
||||
|
||||
// src/node/SetupServerApi.ts
|
||||
var store = new import_node_async_hooks.AsyncLocalStorage();
|
||||
var AsyncHandlersController = class {
|
||||
rootContext;
|
||||
constructor(initialHandlers) {
|
||||
this.rootContext = { initialHandlers, handlers: [] };
|
||||
}
|
||||
get context() {
|
||||
return store.getStore() || this.rootContext;
|
||||
}
|
||||
prepend(runtimeHandlers) {
|
||||
this.context.handlers.unshift(...runtimeHandlers);
|
||||
}
|
||||
reset(nextHandlers) {
|
||||
const context = this.context;
|
||||
context.handlers = [];
|
||||
context.initialHandlers = nextHandlers.length > 0 ? nextHandlers : context.initialHandlers;
|
||||
}
|
||||
currentHandlers() {
|
||||
const { initialHandlers, handlers } = this.context;
|
||||
return handlers.concat(initialHandlers);
|
||||
}
|
||||
};
|
||||
var SetupServerApi = class extends SetupServerCommonApi {
|
||||
constructor(handlers, interceptors = [
|
||||
new import_ClientRequest.ClientRequestInterceptor(),
|
||||
new import_XMLHttpRequest.XMLHttpRequestInterceptor(),
|
||||
new import_fetch.FetchInterceptor()
|
||||
]) {
|
||||
super(interceptors, handlers);
|
||||
this.handlersController = new AsyncHandlersController(handlers);
|
||||
}
|
||||
boundary(callback) {
|
||||
return (...args) => {
|
||||
return store.run(
|
||||
{
|
||||
initialHandlers: this.handlersController.currentHandlers(),
|
||||
handlers: []
|
||||
},
|
||||
callback,
|
||||
...args
|
||||
);
|
||||
};
|
||||
}
|
||||
close() {
|
||||
super.close();
|
||||
store.disable();
|
||||
}
|
||||
};
|
||||
|
||||
// src/node/setupServer.ts
|
||||
var setupServer = (...handlers) => {
|
||||
return new SetupServerApi(handlers);
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
SetupServerApi,
|
||||
setupServer
|
||||
});
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/msw/lib/node/index.js.map
generated
vendored
Normal file
1
node_modules/msw/lib/node/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
184
node_modules/msw/lib/node/index.mjs
generated
vendored
Normal file
184
node_modules/msw/lib/node/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,184 @@
|
||||
// src/node/SetupServerApi.ts
|
||||
import { AsyncLocalStorage } from "async_hooks";
|
||||
import { ClientRequestInterceptor } from "@mswjs/interceptors/ClientRequest";
|
||||
import { XMLHttpRequestInterceptor } from "@mswjs/interceptors/XMLHttpRequest";
|
||||
import { FetchInterceptor } from "@mswjs/interceptors/fetch";
|
||||
|
||||
// src/node/SetupServerCommonApi.ts
|
||||
import { invariant } from "outvariant";
|
||||
import {
|
||||
BatchInterceptor,
|
||||
InterceptorReadyState
|
||||
} from "@mswjs/interceptors";
|
||||
import { SetupApi } from '../core/SetupApi.mjs';
|
||||
import { handleRequest } from '../core/utils/handleRequest.mjs';
|
||||
import { mergeRight } from '../core/utils/internal/mergeRight.mjs';
|
||||
import { InternalError, devUtils } from '../core/utils/internal/devUtils.mjs';
|
||||
import { handleWebSocketEvent } from '../core/ws/handleWebSocketEvent.mjs';
|
||||
import { webSocketInterceptor } from '../core/ws/webSocketInterceptor.mjs';
|
||||
import { isHandlerKind } from '../core/utils/internal/isHandlerKind.mjs';
|
||||
var DEFAULT_LISTEN_OPTIONS = {
|
||||
onUnhandledRequest: "warn"
|
||||
};
|
||||
var SetupServerCommonApi = class extends SetupApi {
|
||||
interceptor;
|
||||
resolvedOptions;
|
||||
constructor(interceptors, handlers) {
|
||||
super(...handlers);
|
||||
this.interceptor = new BatchInterceptor({
|
||||
name: "setup-server",
|
||||
interceptors
|
||||
});
|
||||
this.resolvedOptions = {};
|
||||
}
|
||||
/**
|
||||
* Subscribe to all requests that are using the interceptor object
|
||||
*/
|
||||
init() {
|
||||
this.interceptor.on(
|
||||
"request",
|
||||
async ({ request, requestId, controller }) => {
|
||||
const response = await handleRequest(
|
||||
request,
|
||||
requestId,
|
||||
this.handlersController.currentHandlers().filter(isHandlerKind("RequestHandler")),
|
||||
this.resolvedOptions,
|
||||
this.emitter,
|
||||
{
|
||||
onPassthroughResponse(request2) {
|
||||
const acceptHeader = request2.headers.get("accept");
|
||||
if (acceptHeader) {
|
||||
const nextAcceptHeader = acceptHeader.replace(
|
||||
/(,\s+)?msw\/passthrough/,
|
||||
""
|
||||
);
|
||||
if (nextAcceptHeader) {
|
||||
request2.headers.set("accept", nextAcceptHeader);
|
||||
} else {
|
||||
request2.headers.delete("accept");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
if (response) {
|
||||
controller.respondWith(response);
|
||||
}
|
||||
return;
|
||||
}
|
||||
);
|
||||
this.interceptor.on("unhandledException", ({ error }) => {
|
||||
if (error instanceof InternalError) {
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
this.interceptor.on(
|
||||
"response",
|
||||
({ response, isMockedResponse, request, requestId }) => {
|
||||
this.emitter.emit(
|
||||
isMockedResponse ? "response:mocked" : "response:bypass",
|
||||
{
|
||||
response,
|
||||
request,
|
||||
requestId
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
handleWebSocketEvent({
|
||||
getUnhandledRequestStrategy: () => {
|
||||
return this.resolvedOptions.onUnhandledRequest;
|
||||
},
|
||||
getHandlers: () => {
|
||||
return this.handlersController.currentHandlers();
|
||||
},
|
||||
onMockedConnection: () => {
|
||||
},
|
||||
onPassthroughConnection: () => {
|
||||
}
|
||||
});
|
||||
}
|
||||
listen(options = {}) {
|
||||
this.resolvedOptions = mergeRight(
|
||||
DEFAULT_LISTEN_OPTIONS,
|
||||
options
|
||||
);
|
||||
this.interceptor.apply();
|
||||
this.init();
|
||||
this.subscriptions.push(() => this.interceptor.dispose());
|
||||
webSocketInterceptor.apply();
|
||||
this.subscriptions.push(() => webSocketInterceptor.dispose());
|
||||
invariant(
|
||||
[InterceptorReadyState.APPLYING, InterceptorReadyState.APPLIED].includes(
|
||||
this.interceptor.readyState
|
||||
),
|
||||
devUtils.formatMessage(
|
||||
'Failed to start "setupServer": the interceptor failed to apply. This is likely an issue with the library and you should report it at "%s".'
|
||||
),
|
||||
"https://github.com/mswjs/msw/issues/new/choose"
|
||||
);
|
||||
}
|
||||
close() {
|
||||
this.dispose();
|
||||
}
|
||||
};
|
||||
|
||||
// src/node/SetupServerApi.ts
|
||||
var store = new AsyncLocalStorage();
|
||||
var AsyncHandlersController = class {
|
||||
rootContext;
|
||||
constructor(initialHandlers) {
|
||||
this.rootContext = { initialHandlers, handlers: [] };
|
||||
}
|
||||
get context() {
|
||||
return store.getStore() || this.rootContext;
|
||||
}
|
||||
prepend(runtimeHandlers) {
|
||||
this.context.handlers.unshift(...runtimeHandlers);
|
||||
}
|
||||
reset(nextHandlers) {
|
||||
const context = this.context;
|
||||
context.handlers = [];
|
||||
context.initialHandlers = nextHandlers.length > 0 ? nextHandlers : context.initialHandlers;
|
||||
}
|
||||
currentHandlers() {
|
||||
const { initialHandlers, handlers } = this.context;
|
||||
return handlers.concat(initialHandlers);
|
||||
}
|
||||
};
|
||||
var SetupServerApi = class extends SetupServerCommonApi {
|
||||
constructor(handlers, interceptors = [
|
||||
new ClientRequestInterceptor(),
|
||||
new XMLHttpRequestInterceptor(),
|
||||
new FetchInterceptor()
|
||||
]) {
|
||||
super(interceptors, handlers);
|
||||
this.handlersController = new AsyncHandlersController(handlers);
|
||||
}
|
||||
boundary(callback) {
|
||||
return (...args) => {
|
||||
return store.run(
|
||||
{
|
||||
initialHandlers: this.handlersController.currentHandlers(),
|
||||
handlers: []
|
||||
},
|
||||
callback,
|
||||
...args
|
||||
);
|
||||
};
|
||||
}
|
||||
close() {
|
||||
super.close();
|
||||
store.disable();
|
||||
}
|
||||
};
|
||||
|
||||
// src/node/setupServer.ts
|
||||
var setupServer = (...handlers) => {
|
||||
return new SetupServerApi(handlers);
|
||||
};
|
||||
export {
|
||||
SetupServerApi,
|
||||
setupServer
|
||||
};
|
||||
//# sourceMappingURL=index.mjs.map
|
||||
1
node_modules/msw/lib/node/index.mjs.map
generated
vendored
Normal file
1
node_modules/msw/lib/node/index.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user