rspack-plugin-mock 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +406 -65
- package/README.zh-CN.md +406 -66
- package/dist/helper.d.ts +46 -8
- package/dist/helper.js +109 -14
- package/dist/{types-GT6M6WuI.d.ts → index-BMMGM-eD.d.ts} +537 -172
- package/dist/index.d.ts +9 -6
- package/dist/index.js +70 -67
- package/dist/json5-loader.mjs +2 -2
- package/dist/{ws-BcLCWVaK.js → logger-CzeuHKAL.js} +662 -102
- package/dist/{options-Bd0PSZeT.js → options-CI0LRpJZ.js} +48 -7
- package/dist/rsbuild.d.ts +4 -3
- package/dist/rsbuild.js +29 -41
- package/dist/{server-_doRwsZm.d.ts → server-pC78IYdH.d.ts} +48 -24
- package/dist/server.d.ts +2 -2
- package/dist/server.js +2 -2
- package/package.json +8 -3
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as processRawData, d as normalizePath, f as vfs, h as createMatcher, m as getPackageDeps, p as getPackageDepList, s as processMockData, t as createLogger } from "./logger-CzeuHKAL.js";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
-
import { attemptAsync, isBoolean, isPlainObject, toArray, uniq } from "@pengzhanbo/utils";
|
|
4
3
|
import path from "node:path";
|
|
5
4
|
import process from "node:process";
|
|
5
|
+
import { attemptAsync, isBoolean, isPlainObject, toArray, uniq } from "@pengzhanbo/utils";
|
|
6
6
|
import * as rspackCore from "@rspack/core";
|
|
7
7
|
import fs, { promises } from "node:fs";
|
|
8
8
|
import fsp from "node:fs/promises";
|
|
@@ -272,7 +272,7 @@ var MockCompiler = class extends EventEmitter {
|
|
|
272
272
|
//#endregion
|
|
273
273
|
//#region package.json
|
|
274
274
|
var name = "rspack-plugin-mock";
|
|
275
|
-
var version = "2.
|
|
275
|
+
var version = "2.1.0";
|
|
276
276
|
//#endregion
|
|
277
277
|
//#region src/build/packageJson.ts
|
|
278
278
|
function generatePackageJson(options, externals) {
|
|
@@ -362,6 +362,7 @@ async function writeMockEntryFile(entryFile, files, cwd, dir) {
|
|
|
362
362
|
//#endregion
|
|
363
363
|
//#region src/build/generate.ts
|
|
364
364
|
async function buildMockServer(options, outputDir) {
|
|
365
|
+
const buildOptions = options.build;
|
|
365
366
|
const entryFile = path.resolve(process.cwd(), "node_modules/.cache/mock-server/mock-server.ts");
|
|
366
367
|
const { pattern, ignore } = createMatcher(options.include, options.exclude);
|
|
367
368
|
await writeMockEntryFile(entryFile, await glob(pattern, {
|
|
@@ -389,6 +390,16 @@ async function buildMockServer(options, outputDir) {
|
|
|
389
390
|
source: generatePackageJson(options, externals)
|
|
390
391
|
}
|
|
391
392
|
];
|
|
393
|
+
if (options.record.enabled && buildOptions.includeRecord) {
|
|
394
|
+
const files = await glob(path.join(options.record.dir, "**/*.json"), {
|
|
395
|
+
cwd: options.cwd,
|
|
396
|
+
dot: true
|
|
397
|
+
});
|
|
398
|
+
for (const file of files) outputList.push({
|
|
399
|
+
filename: path.join(outputDir, file),
|
|
400
|
+
source: await fsp.readFile(path.join(options.cwd, file), "utf-8")
|
|
401
|
+
});
|
|
402
|
+
}
|
|
392
403
|
const dist = path.resolve(outputDir, options.build.dist);
|
|
393
404
|
options.logger.info(`${ansis.green("✓")} generate mock server in ${ansis.cyan(path.relative(process.cwd(), dist))}`);
|
|
394
405
|
if (!fs.existsSync(dist)) await fsp.mkdir(dist, { recursive: true });
|
|
@@ -400,8 +411,8 @@ async function buildMockServer(options, outputDir) {
|
|
|
400
411
|
}
|
|
401
412
|
}
|
|
402
413
|
//#endregion
|
|
403
|
-
//#region src/options.ts
|
|
404
|
-
function resolvePluginOptions({ prefix = [], wsPrefix = [], cwd, dir = "mock", include = ["**/*.mock.{js,ts,cjs,mjs,json,json5}"], exclude = [], reload = false, log = "info", cors = true, formidableOptions = {}, build = false, cookiesOptions = {}, bodyParserOptions = {}, priority = {} }, { alias, context, plugins, proxies: rawProxies }) {
|
|
414
|
+
//#region src/core/options.ts
|
|
415
|
+
function resolvePluginOptions({ prefix = [], wsPrefix = [], cwd, dir = "mock", include = ["**/*.mock.{js,ts,cjs,mjs,json,json5}"], exclude = [], reload = false, log = "info", cors = true, formidableOptions = {}, build = false, cookiesOptions = {}, bodyParserOptions = {}, priority = {}, activeScene = [], record = false, replay }, { alias, context, plugins, proxies: rawProxies }) {
|
|
405
416
|
const logger = createLogger("rspack:mock", isBoolean(log) ? log ? "info" : "error" : log);
|
|
406
417
|
const proxies = [...toArray(prefix), ...rawProxies];
|
|
407
418
|
const wsProxies = toArray(wsPrefix);
|
|
@@ -412,10 +423,13 @@ function resolvePluginOptions({ prefix = [], wsPrefix = [], cwd, dir = "mock", i
|
|
|
412
423
|
...corsOptions,
|
|
413
424
|
...cors
|
|
414
425
|
};
|
|
426
|
+
cwd = cwd || context || process.cwd();
|
|
427
|
+
const resolvedRecord = resolveRecordOptions(cwd, dir, record);
|
|
415
428
|
return {
|
|
429
|
+
enabled: true,
|
|
416
430
|
prefix,
|
|
417
431
|
wsPrefix,
|
|
418
|
-
cwd
|
|
432
|
+
cwd,
|
|
419
433
|
dir,
|
|
420
434
|
include,
|
|
421
435
|
exclude,
|
|
@@ -439,7 +453,34 @@ function resolvePluginOptions({ prefix = [], wsPrefix = [], cwd, dir = "mock", i
|
|
|
439
453
|
plugins,
|
|
440
454
|
proxies,
|
|
441
455
|
wsProxies,
|
|
442
|
-
logger
|
|
456
|
+
logger,
|
|
457
|
+
activeScene: toArray(activeScene),
|
|
458
|
+
record: resolvedRecord,
|
|
459
|
+
replay: replay ?? resolvedRecord.enabled ?? false
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Resolve record options
|
|
464
|
+
*
|
|
465
|
+
* 解析录制配置
|
|
466
|
+
*
|
|
467
|
+
* @param cwd - Current working directory / 当前工作目录
|
|
468
|
+
* @param dir - Mock context directory / 模拟上下文目录
|
|
469
|
+
* @param record - Record options / 录制配置
|
|
470
|
+
* @returns Resolved record options / 解析后的录制配置
|
|
471
|
+
*/
|
|
472
|
+
function resolveRecordOptions(cwd, dir, record) {
|
|
473
|
+
const recordOptions = typeof record === "boolean" ? { enabled: record } : record;
|
|
474
|
+
const expires = recordOptions?.expires ?? 0;
|
|
475
|
+
return {
|
|
476
|
+
enabled: recordOptions?.enabled ?? false,
|
|
477
|
+
cwd,
|
|
478
|
+
dir: path.join(dir, recordOptions?.dir || ".recordings"),
|
|
479
|
+
overwrite: recordOptions?.overwrite ?? true,
|
|
480
|
+
status: toArray(recordOptions?.status).map(Number),
|
|
481
|
+
expires: expires === 0 ? Number.MAX_SAFE_INTEGER : expires * 1e3,
|
|
482
|
+
gitignore: recordOptions?.gitignore ?? true,
|
|
483
|
+
filter: recordOptions?.filter || (() => true)
|
|
443
484
|
};
|
|
444
485
|
}
|
|
445
486
|
//#endregion
|
package/dist/rsbuild.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { _ as
|
|
1
|
+
import { A as ResponseBody, C as HandleFunction, D as MockResponse, E as MockRequest, M as CookiesOption, N as GetCookieOption, O as NextFunction, P as SetCookieOption, S as ExtraRequest, T as Method, _ as RecordedMeta, a as MockWebsocketItem, b as RecordedRes, c as MockHttpItem, d as LogType, f as MockMatchPriority, g as RecordOptions, h as ServerBuildOption, i as MockOptions, j as SimpleHandleFunction, k as NextHandleFunction, l as BodyParserOptions, m as MockServerPluginOptions, n as HttpProxyPlugin, o as WebSocketSetupContext, p as MockMatchSpecialPriority, r as PathFilter, s as MockErrorConfig, t as FormidableFile, u as LogLevel, v as RecordedReq, w as Headers, x as ResolvedRecordOptions, y as RecordedRequest } from "./index-BMMGM-eD.js";
|
|
2
|
+
import { DefineMockDataOptions, HeaderStream, MockData, SSEMessage, createDefineMock, createSSEStream, defineMock, defineMockData } from "./helper.js";
|
|
2
3
|
import { RsbuildPlugin } from "@rsbuild/core";
|
|
3
4
|
|
|
4
|
-
//#region src/rsbuild.d.ts
|
|
5
|
+
//#region src/core/rsbuild.d.ts
|
|
5
6
|
declare function pluginMockServer(options?: MockServerPluginOptions): RsbuildPlugin;
|
|
6
7
|
//#endregion
|
|
7
|
-
export { BodyParserOptions, ExtraRequest, FormidableFile, LogLevel, LogType, Method, MockHttpItem, MockMatchPriority, MockMatchSpecialPriority, MockOptions, MockRequest, MockResponse, MockServerPluginOptions, MockWebsocketItem, ResponseBody, ServerBuildOption, WebSocketSetupContext, pluginMockServer };
|
|
8
|
+
export { BodyParserOptions, CookiesOption, DefineMockDataOptions, ExtraRequest, type FormidableFile, GetCookieOption, HandleFunction, HeaderStream, Headers, HttpProxyPlugin, LogLevel, LogType, Method, MockData, MockErrorConfig, type MockHttpItem, MockMatchPriority, MockMatchSpecialPriority, type MockOptions, type MockRequest, MockResponse, type MockServerPluginOptions, type MockWebsocketItem, NextFunction, NextHandleFunction, PathFilter, RecordOptions, RecordedMeta, RecordedReq, RecordedRequest, RecordedRes, ResolvedRecordOptions, ResponseBody, SSEMessage, ServerBuildOption, SetCookieOption, SimpleHandleFunction, WebSocketSetupContext, createDefineMock, createSSEStream, defineMock, defineMockData, pluginMockServer };
|
package/dist/rsbuild.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as buildMockServer, r as createMockCompiler, t as resolvePluginOptions } from "./options-
|
|
3
|
-
import {
|
|
1
|
+
import { a as rewriteRequest, i as createMockMiddleware, o as Recorder, r as mockWebSocket } from "./logger-CzeuHKAL.js";
|
|
2
|
+
import { n as buildMockServer, r as createMockCompiler, t as resolvePluginOptions } from "./options-CI0LRpJZ.js";
|
|
3
|
+
import { createDefineMock, createSSEStream, defineMock, defineMockData } from "./helper.js";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import process from "node:process";
|
|
6
|
+
import { isArray, objectEntries, toArray } from "@pengzhanbo/utils";
|
|
6
7
|
import rspack from "@rspack/core";
|
|
7
|
-
|
|
8
|
-
import { Socket } from "node:net";
|
|
9
|
-
//#region src/rsbuild.ts
|
|
8
|
+
//#region src/core/rsbuild.ts
|
|
10
9
|
function pluginMockServer(options = {}) {
|
|
11
10
|
return {
|
|
12
11
|
name: "plugin-mock-server",
|
|
13
12
|
setup(api) {
|
|
13
|
+
if (options.enabled === false) return;
|
|
14
14
|
const rsbuildConfig = api.getRsbuildConfig();
|
|
15
15
|
const resolvedOptions = resolvePluginOptions(options, {
|
|
16
16
|
proxies: resolveConfigProxies(rsbuildConfig),
|
|
@@ -32,9 +32,29 @@ function pluginMockServer(options = {}) {
|
|
|
32
32
|
});
|
|
33
33
|
else mockCompiler.updateAlias(compiler.options.resolve?.alias || {});
|
|
34
34
|
});
|
|
35
|
-
|
|
35
|
+
let recorder = null;
|
|
36
|
+
if (resolvedOptions.record.enabled) recorder = new Recorder(resolvedOptions.record);
|
|
37
|
+
function wrapProxyOptions(options) {
|
|
38
|
+
const plugins = options.plugins ??= [];
|
|
39
|
+
plugins.push((proxyServer) => proxyServer.on("proxyReq", rewriteRequest));
|
|
40
|
+
if (resolvedOptions.record.enabled && recorder) plugins.push(recorder.getPlugin());
|
|
41
|
+
return options;
|
|
42
|
+
}
|
|
43
|
+
api.modifyRsbuildConfig((config) => {
|
|
44
|
+
if (!config.server?.proxy) return;
|
|
45
|
+
if (isArray(config.server.proxy)) config.server.proxy = config.server.proxy.map((item) => item.ws ? item : wrapProxyOptions(item));
|
|
46
|
+
else if (config.server.proxy) {
|
|
47
|
+
const proxy = config.server.proxy;
|
|
48
|
+
Object.keys(proxy).forEach((key) => {
|
|
49
|
+
const target = proxy[key];
|
|
50
|
+
const options = typeof target === "string" ? { target } : target;
|
|
51
|
+
if (options.ws) return;
|
|
52
|
+
proxy[key] = wrapProxyOptions(options);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
});
|
|
36
56
|
function initMockServer(server) {
|
|
37
|
-
server.middlewares.use(
|
|
57
|
+
server.middlewares.use(createMockMiddleware(mockCompiler, resolvedOptions));
|
|
38
58
|
if (resolvedOptions.reload && api.context.action === "dev") mockCompiler.on("update", () => server.sockWrite("static-changed"));
|
|
39
59
|
if (toArray(resolvedOptions.wsPrefix).length > 0) mockWebSocket(mockCompiler, server.httpServer, resolvedOptions);
|
|
40
60
|
mockCompiler.run();
|
|
@@ -45,38 +65,6 @@ function pluginMockServer(options = {}) {
|
|
|
45
65
|
}
|
|
46
66
|
};
|
|
47
67
|
}
|
|
48
|
-
function onProxyError(err, _req, res) {
|
|
49
|
-
console.error(ansis.red(err?.stack || err.message));
|
|
50
|
-
if (!(res instanceof Socket)) res.statusCode = 500;
|
|
51
|
-
res.end();
|
|
52
|
-
}
|
|
53
|
-
function wrapProxyOptions(options) {
|
|
54
|
-
const { on, ...rest } = options;
|
|
55
|
-
return {
|
|
56
|
-
...rest,
|
|
57
|
-
on: {
|
|
58
|
-
...on,
|
|
59
|
-
proxyReq: (proxyReq, req, ...args) => {
|
|
60
|
-
on?.proxyReq?.(proxyReq, req, ...args);
|
|
61
|
-
rewriteRequest(proxyReq, req);
|
|
62
|
-
},
|
|
63
|
-
error: on?.error || onProxyError
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
function updateServerProxyConfigByHttpMock(config) {
|
|
68
|
-
if (!config.server?.proxy) return;
|
|
69
|
-
if (isArray(config.server.proxy)) config.server.proxy = config.server.proxy.map((item) => item.ws ? item : wrapProxyOptions(item));
|
|
70
|
-
else if (config.server.proxy) {
|
|
71
|
-
const proxy = config.server.proxy;
|
|
72
|
-
Object.keys(proxy).forEach((key) => {
|
|
73
|
-
const target = proxy[key];
|
|
74
|
-
const options = typeof target === "string" ? { target } : target;
|
|
75
|
-
if (options.ws) return;
|
|
76
|
-
proxy[key] = wrapProxyOptions(options);
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
68
|
function resolveConfigProxies(config) {
|
|
81
69
|
config.server ??= {};
|
|
82
70
|
const proxy = config.server.proxy ??= {};
|
|
@@ -89,4 +77,4 @@ function resolveConfigProxies(config) {
|
|
|
89
77
|
return proxies;
|
|
90
78
|
}
|
|
91
79
|
//#endregion
|
|
92
|
-
export { pluginMockServer };
|
|
80
|
+
export { createDefineMock, createSSEStream, defineMock, defineMockData, pluginMockServer };
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as MockWebsocketItem, c as MockHttpItem, h as ServerBuildOption, i as MockOptions, k as NextHandleFunction, m as MockServerPluginOptions, r as PathFilter, u as LogLevel, x as ResolvedRecordOptions } from "./index-BMMGM-eD.js";
|
|
2
|
+
import { Arrayable } from "@pengzhanbo/utils";
|
|
2
3
|
import { Compiler, RspackPluginInstance } from "@rspack/core";
|
|
3
4
|
import { Matcher } from "picomatch";
|
|
4
|
-
import Debug from "debug";
|
|
5
5
|
import EventEmitter from "node:events";
|
|
6
6
|
import { FSWatcher } from "chokidar";
|
|
7
7
|
import { CorsOptions } from "cors";
|
|
8
|
-
import
|
|
9
|
-
import http, { Server } from "node:http";
|
|
8
|
+
import { Server } from "node:http";
|
|
10
9
|
import { Http2SecureServer } from "node:http2";
|
|
11
10
|
|
|
12
|
-
//#region src/
|
|
11
|
+
//#region src/core/logger.d.ts
|
|
13
12
|
interface Logger {
|
|
14
13
|
debug: (msg: string, level?: boolean | LogLevel) => void;
|
|
15
14
|
info: (msg: string, level?: boolean | LogLevel) => void;
|
|
@@ -19,25 +18,22 @@ interface Logger {
|
|
|
19
18
|
declare const logLevels: Record<LogLevel, number>;
|
|
20
19
|
declare function createLogger(prefix: string, defaultLevel?: LogLevel): Logger;
|
|
21
20
|
//#endregion
|
|
22
|
-
//#region src/options.d.ts
|
|
21
|
+
//#region src/core/options.d.ts
|
|
23
22
|
interface ResolvedCompilerOptions {
|
|
24
|
-
alias: Record<string, false | string
|
|
25
|
-
proxies:
|
|
26
|
-
wsProxies:
|
|
23
|
+
alias: Record<string, Arrayable<false | string>>;
|
|
24
|
+
proxies: PathFilter[];
|
|
25
|
+
wsProxies: PathFilter[];
|
|
27
26
|
plugins: RspackPluginInstance[];
|
|
28
27
|
context?: string;
|
|
29
|
-
cors: false | CorsOptions;
|
|
30
28
|
}
|
|
31
29
|
type ResolvePluginOptions = Required<Omit<MockServerPluginOptions, "build">> & ResolvedCompilerOptions & {
|
|
32
30
|
logger: Logger;
|
|
33
31
|
build: false | ServerBuildOption;
|
|
32
|
+
cors: false | CorsOptions;
|
|
33
|
+
record: ResolvedRecordOptions;
|
|
34
|
+
activeScene: string[];
|
|
34
35
|
};
|
|
35
36
|
//#endregion
|
|
36
|
-
//#region src/compiler/processData.d.ts
|
|
37
|
-
declare function processRawData(rawData: (readonly [any, string])[]): (MockHttpItem | MockWebsocketItem | MockOptions)[];
|
|
38
|
-
declare function processMockData(mockList: (MockHttpItem | MockWebsocketItem | MockOptions)[]): Record<string, MockOptions>;
|
|
39
|
-
declare function sortByValidator(mocks: MockOptions): (MockHttpItem | MockWebsocketItem)[];
|
|
40
|
-
//#endregion
|
|
41
37
|
//#region src/compiler/mockCompiler.d.ts
|
|
42
38
|
declare class MockCompiler extends EventEmitter {
|
|
43
39
|
options: ResolvePluginOptions;
|
|
@@ -58,25 +54,53 @@ declare class MockCompiler extends EventEmitter {
|
|
|
58
54
|
watchMockFiles(isMatch: Matcher): void;
|
|
59
55
|
}
|
|
60
56
|
//#endregion
|
|
61
|
-
//#region src/
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
//#region src/compiler/processData.d.ts
|
|
58
|
+
declare function processRawData(rawData: (readonly [any, string])[]): (MockHttpItem | MockWebsocketItem | MockOptions)[];
|
|
59
|
+
declare function processMockData(mockList: (MockHttpItem | MockWebsocketItem | MockOptions)[]): Record<string, MockOptions>;
|
|
60
|
+
declare function sortByValidator(mocks: MockOptions): (MockHttpItem | MockWebsocketItem)[];
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/mockHttp/middleware.d.ts
|
|
63
|
+
interface CreateMockMiddlewareOptions extends Pick<ResolvePluginOptions, "formidableOptions" | "cookiesOptions" | "bodyParserOptions" | "priority" | "record" | "replay" | "activeScene"> {
|
|
64
|
+
proxies: PathFilter[];
|
|
64
65
|
logger: Logger;
|
|
65
66
|
cors: false | CorsOptions;
|
|
66
67
|
}
|
|
67
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Create mock middleware
|
|
70
|
+
*
|
|
71
|
+
* 创建 Mock 中间件
|
|
72
|
+
*
|
|
73
|
+
* @param compiler - Compiler instance / 编译器实例
|
|
74
|
+
* @param options - Middleware options / 中间件配置项
|
|
75
|
+
* @param options.formidableOptions - Formidable options / Formidable 配置项
|
|
76
|
+
* @param options.bodyParserOptions - Body parser options / 请求体解析配置项
|
|
77
|
+
* @param options.proxies - Proxy paths / 代理路径
|
|
78
|
+
* @param options.cookiesOptions - Cookies options / Cookies 配置项
|
|
79
|
+
* @param options.logger - Logger instance / 日志实例
|
|
80
|
+
* @param options.priority - Path matching priority / 路径匹配优先级
|
|
81
|
+
* @param options.cors - CORS options / CORS 配置项
|
|
82
|
+
* @param options.record - Record options / 录制配置项
|
|
83
|
+
* @param options.replay - Replay options / 回放配置项
|
|
84
|
+
* @param options.activeScene - Active scene / 活动场景
|
|
85
|
+
*
|
|
86
|
+
* @returns Connect middleware function / Connect 中间件函数
|
|
87
|
+
*/
|
|
88
|
+
declare function createMockMiddleware(compiler: MockCompiler, {
|
|
68
89
|
formidableOptions,
|
|
69
90
|
bodyParserOptions,
|
|
70
91
|
proxies,
|
|
71
92
|
cookiesOptions,
|
|
72
93
|
logger,
|
|
73
94
|
priority,
|
|
74
|
-
cors: corsOptions
|
|
75
|
-
|
|
95
|
+
cors: corsOptions,
|
|
96
|
+
record,
|
|
97
|
+
replay,
|
|
98
|
+
activeScene
|
|
99
|
+
}: CreateMockMiddlewareOptions): NextHandleFunction;
|
|
76
100
|
//#endregion
|
|
77
|
-
//#region src/
|
|
101
|
+
//#region src/mockWebsocket/server.d.ts
|
|
78
102
|
interface MockSocketOptions {
|
|
79
|
-
wsProxies:
|
|
103
|
+
wsProxies: PathFilter[];
|
|
80
104
|
cookiesOptions: MockServerPluginOptions["cookiesOptions"];
|
|
81
105
|
logger: Logger;
|
|
82
106
|
}
|
|
@@ -86,4 +110,4 @@ declare function mockWebSocket(compiler: MockCompiler, httpServer: Server | Http
|
|
|
86
110
|
logger
|
|
87
111
|
}: MockSocketOptions): void;
|
|
88
112
|
//#endregion
|
|
89
|
-
export { processMockData as a,
|
|
113
|
+
export { processMockData as a, MockCompiler as c, createLogger as d, logLevels as f, createMockMiddleware as i, ResolvePluginOptions as l, mockWebSocket as n, processRawData as o, CreateMockMiddlewareOptions as r, sortByValidator as s, MockSocketOptions as t, Logger as u };
|
package/dist/server.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as processMockData,
|
|
2
|
-
export {
|
|
1
|
+
import { a as processMockData, d as createLogger, f as logLevels, i as createMockMiddleware, n as mockWebSocket, o as processRawData, r as CreateMockMiddlewareOptions, s as sortByValidator, t as MockSocketOptions, u as Logger } from "./server-pC78IYdH.js";
|
|
2
|
+
export { CreateMockMiddlewareOptions, Logger, MockSocketOptions, createLogger, createMockMiddleware, logLevels, mockWebSocket, processMockData, processRawData, sortByValidator };
|
package/dist/server.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { c as processRawData, i as createMockMiddleware, l as sortByValidator, n as logLevels, r as mockWebSocket, s as processMockData, t as createLogger } from "./logger-CzeuHKAL.js";
|
|
2
|
+
export { createLogger, createMockMiddleware, logLevels, mockWebSocket, processMockData, processRawData, sortByValidator };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rspack-plugin-mock",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.1.0",
|
|
5
5
|
"description": "inject api mock server to development server",
|
|
6
6
|
"author": "pengzhanbo <q942450674@outlook.com> (https://github.com/pengzhanbo)",
|
|
7
7
|
"license": "MIT",
|
|
@@ -59,7 +59,8 @@
|
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"@rsbuild/core": ">=2.0.0",
|
|
62
|
-
"@rspack/core": ">=2.0.0"
|
|
62
|
+
"@rspack/core": ">=2.0.0",
|
|
63
|
+
"zstd-codec": ">=0.1.5"
|
|
63
64
|
},
|
|
64
65
|
"peerDependenciesMeta": {
|
|
65
66
|
"@rsbuild/core": {
|
|
@@ -67,6 +68,9 @@
|
|
|
67
68
|
},
|
|
68
69
|
"@rspack/core": {
|
|
69
70
|
"optional": true
|
|
71
|
+
},
|
|
72
|
+
"zstd-codec": {
|
|
73
|
+
"optional": true
|
|
70
74
|
}
|
|
71
75
|
},
|
|
72
76
|
"dependencies": {
|
|
@@ -107,7 +111,8 @@
|
|
|
107
111
|
"husky": "^9.1.7",
|
|
108
112
|
"lint-staged": "^16.4.0",
|
|
109
113
|
"tsdown": "^0.21.10",
|
|
110
|
-
"typescript": "^6.0.3"
|
|
114
|
+
"typescript": "^6.0.3",
|
|
115
|
+
"zstd-codec": "^0.1.5"
|
|
111
116
|
},
|
|
112
117
|
"lint-staged": {
|
|
113
118
|
"*": "eslint --fix"
|