修改后台权限

This commit is contained in:
yoyuzh
2026-03-24 14:30:59 +08:00
parent 00f902f475
commit b2d9db7be9
9310 changed files with 1246063 additions and 48 deletions

74
node_modules/msw/lib/native/index.d.mts generated vendored Normal file
View File

@@ -0,0 +1,74 @@
import { RequestHandler } from "../core/handlers/RequestHandler.mjs";
import { BatchInterceptor, Interceptor, HttpRequestEventMap } from '@mswjs/interceptors';
import { SharedOptions, LifeCycleEventEmitter, LifeCycleEventsMap } from "../core/sharedOptions.mjs";
import { SetupApi } from "../core/SetupApi.mjs";
import { WebSocketHandler } from "../core/handlers/WebSocketHandler.mjs";
import { PartialDeep } from 'type-fest';
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>;
}
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;
}
/**
* Sets up a requests interception in React Native 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 function setupServer(...handlers: Array<RequestHandler>): SetupServerCommonApi;
export { setupServer };

74
node_modules/msw/lib/native/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,74 @@
import { RequestHandler } from "../core/handlers/RequestHandler";
import { BatchInterceptor, Interceptor, HttpRequestEventMap } from '@mswjs/interceptors';
import { SharedOptions, LifeCycleEventEmitter, LifeCycleEventsMap } from "../core/sharedOptions";
import { SetupApi } from "../core/SetupApi";
import { WebSocketHandler } from "../core/handlers/WebSocketHandler";
import { PartialDeep } from 'type-fest';
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>;
}
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;
}
/**
* Sets up a requests interception in React Native 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 function setupServer(...handlers: Array<RequestHandler>): SetupServerCommonApi;
export { setupServer };

156
node_modules/msw/lib/native/index.js generated vendored Normal file
View File

@@ -0,0 +1,156 @@
"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/native/index.ts
var index_exports = {};
__export(index_exports, {
setupServer: () => setupServer
});
module.exports = __toCommonJS(index_exports);
var import_fetch = require("@mswjs/interceptors/fetch");
var import_XMLHttpRequest = require("@mswjs/interceptors/XMLHttpRequest");
// 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/native/index.ts
function setupServer(...handlers) {
return new SetupServerCommonApi(
[new import_fetch.FetchInterceptor(), new import_XMLHttpRequest.XMLHttpRequestInterceptor()],
handlers
);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
setupServer
});
//# sourceMappingURL=index.js.map

1
node_modules/msw/lib/native/index.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

134
node_modules/msw/lib/native/index.mjs generated vendored Normal file
View File

@@ -0,0 +1,134 @@
// src/native/index.ts
import { FetchInterceptor } from "@mswjs/interceptors/fetch";
import { XMLHttpRequestInterceptor } from "@mswjs/interceptors/XMLHttpRequest";
// 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/native/index.ts
function setupServer(...handlers) {
return new SetupServerCommonApi(
[new FetchInterceptor(), new XMLHttpRequestInterceptor()],
handlers
);
}
export {
setupServer
};
//# sourceMappingURL=index.mjs.map

1
node_modules/msw/lib/native/index.mjs.map generated vendored Normal file

File diff suppressed because one or more lines are too long