rspack-plugin-mock 1.0.1 → 1.2.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/dist/chunk-CUT6urMc.cjs +30 -0
- package/dist/helper.cjs +124 -113
- package/dist/helper.d.cts +92 -104
- package/dist/helper.d.ts +92 -104
- package/dist/helper.js +120 -113
- package/dist/index.cjs +82 -99
- package/dist/index.d.cts +10 -22
- package/dist/index.d.ts +10 -22
- package/dist/index.js +74 -97
- package/dist/json5-loader.cjs +30 -15
- package/dist/logger-C0V8Cvvd.cjs +800 -0
- package/dist/logger-C48_LmdS.js +710 -0
- package/dist/mockWebsocket-DkVHpZCx.d.cts +85 -0
- package/dist/mockWebsocket-qLVAe-RI.d.ts +85 -0
- package/dist/resolvePluginOptions-Da5uqlBx.cjs +506 -0
- package/dist/resolvePluginOptions-DlkIkykz.js +476 -0
- package/dist/rsbuild.cjs +164 -190
- package/dist/rsbuild.d.cts +5 -13
- package/dist/rsbuild.d.ts +5 -13
- package/dist/rsbuild.js +161 -188
- package/dist/server.cjs +9 -18
- package/dist/server.d.cts +21 -25
- package/dist/server.d.ts +21 -25
- package/dist/server.js +3 -18
- package/dist/types-6lajtJPx.d.cts +572 -0
- package/dist/types-DPzh7nJq.d.ts +572 -0
- package/package.json +28 -28
- package/dist/chunk-HTVJXQRM.cjs +0 -906
- package/dist/chunk-HV5L72CY.js +0 -557
- package/dist/chunk-M7F5AAOF.cjs +0 -557
- package/dist/chunk-OGWV5ZGG.js +0 -906
- package/dist/mockWebsocket-DBgZBsdo.d.ts +0 -76
- package/dist/mockWebsocket-Ki_cShTv.d.cts +0 -76
- package/dist/types-Aw0AciTG.d.cts +0 -570
- package/dist/types-Aw0AciTG.d.ts +0 -570
|
@@ -0,0 +1,800 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
+
const __pengzhanbo_utils = require_chunk.__toESM(require("@pengzhanbo/utils"));
|
|
3
|
+
const node_path = require_chunk.__toESM(require("node:path"));
|
|
4
|
+
const node_fs = require_chunk.__toESM(require("node:fs"));
|
|
5
|
+
const picocolors = require_chunk.__toESM(require("picocolors"));
|
|
6
|
+
const node_os = require_chunk.__toESM(require("node:os"));
|
|
7
|
+
const node_querystring = require_chunk.__toESM(require("node:querystring"));
|
|
8
|
+
const node_url = require_chunk.__toESM(require("node:url"));
|
|
9
|
+
const debug = require_chunk.__toESM(require("debug"));
|
|
10
|
+
const memfs = require_chunk.__toESM(require("memfs"));
|
|
11
|
+
const path_to_regexp = require_chunk.__toESM(require("path-to-regexp"));
|
|
12
|
+
const node_buffer = require_chunk.__toESM(require("node:buffer"));
|
|
13
|
+
const cookies = require_chunk.__toESM(require("cookies"));
|
|
14
|
+
const http_status = require_chunk.__toESM(require("http-status"));
|
|
15
|
+
const mime_types = require_chunk.__toESM(require("mime-types"));
|
|
16
|
+
const co_body = require_chunk.__toESM(require("co-body"));
|
|
17
|
+
const formidable = require_chunk.__toESM(require("formidable"));
|
|
18
|
+
const ws = require_chunk.__toESM(require("ws"));
|
|
19
|
+
|
|
20
|
+
//#region src/core/utils.ts
|
|
21
|
+
const packageDir = getDirname(require("url").pathToFileURL(__filename).href);
|
|
22
|
+
const vfs = (0, memfs.createFsFromVolume)(new memfs.Volume());
|
|
23
|
+
function isStream(stream) {
|
|
24
|
+
return stream !== null && typeof stream === "object" && typeof stream.pipe === "function";
|
|
25
|
+
}
|
|
26
|
+
function isReadableStream(stream) {
|
|
27
|
+
return isStream(stream) && stream.readable !== false && typeof stream._read === "function" && typeof stream._readableState === "object";
|
|
28
|
+
}
|
|
29
|
+
function getDirname(importMetaUrl) {
|
|
30
|
+
return node_path.default.dirname((0, node_url.fileURLToPath)(importMetaUrl));
|
|
31
|
+
}
|
|
32
|
+
const debug$1 = (0, debug.default)("rspack:mock");
|
|
33
|
+
function lookupFile(dir, formats, options) {
|
|
34
|
+
for (const format of formats) {
|
|
35
|
+
const fullPath = node_path.default.join(dir, format);
|
|
36
|
+
if (node_fs.default.existsSync(fullPath) && node_fs.default.statSync(fullPath).isFile()) {
|
|
37
|
+
const result = options?.pathOnly ? fullPath : node_fs.default.readFileSync(fullPath, "utf-8");
|
|
38
|
+
if (!options?.predicate || options.predicate(result)) return result;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const parentDir = node_path.default.dirname(dir);
|
|
42
|
+
if (parentDir !== dir && (!options?.rootDir || parentDir.startsWith(options?.rootDir))) return lookupFile(parentDir, formats, options);
|
|
43
|
+
}
|
|
44
|
+
function doesProxyContextMatchUrl(context, url, req) {
|
|
45
|
+
if (typeof context === "function") return context(url, req);
|
|
46
|
+
return context[0] === "^" && new RegExp(context).test(url) || url.startsWith(context);
|
|
47
|
+
}
|
|
48
|
+
function parseParams(pattern, url) {
|
|
49
|
+
const urlMatch = (0, path_to_regexp.match)(pattern, { decode: decodeURIComponent })(url) || { params: {} };
|
|
50
|
+
return urlMatch.params || {};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* nodejs 从 19.0.0 开始 弃用 url.parse,因此使用 url.parse 来解析 可能会报错,
|
|
54
|
+
* 使用 URL 来解析
|
|
55
|
+
*/
|
|
56
|
+
function urlParse(input) {
|
|
57
|
+
const url = new node_url.URL(input, "http://example.com");
|
|
58
|
+
const pathname = decodeURIComponent(url.pathname);
|
|
59
|
+
const query = (0, node_querystring.parse)(url.search.replace(/^\?/, ""));
|
|
60
|
+
return {
|
|
61
|
+
pathname,
|
|
62
|
+
query
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
const windowsSlashRE = /\\/g;
|
|
66
|
+
const isWindows = node_os.default.platform() === "win32";
|
|
67
|
+
function slash(p) {
|
|
68
|
+
return p.replace(windowsSlashRE, "/");
|
|
69
|
+
}
|
|
70
|
+
function normalizePath(id) {
|
|
71
|
+
return node_path.default.posix.normalize(isWindows ? slash(id) : id);
|
|
72
|
+
}
|
|
73
|
+
function waitingFor(onSuccess, maxRetry = 5) {
|
|
74
|
+
return function wait(getter, retry = 0) {
|
|
75
|
+
const value = getter();
|
|
76
|
+
if (value) onSuccess(value);
|
|
77
|
+
else if (retry < maxRetry) setTimeout(() => wait(getter, retry + 1), 100);
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/core/validator.ts
|
|
83
|
+
function validate(request, validator) {
|
|
84
|
+
return isObjectSubset(request.headers, validator.headers) && isObjectSubset(request.body, validator.body) && isObjectSubset(request.params, validator.params) && isObjectSubset(request.query, validator.query) && isObjectSubset(request.refererQuery, validator.refererQuery);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Checks if target object is a subset of source object.
|
|
88
|
+
* That is, all properties and their corresponding values in target exist in source.
|
|
89
|
+
*
|
|
90
|
+
* 深度比较两个对象之间,target 是否属于 source 的子集,
|
|
91
|
+
* 即 target 的所有属性和对应的值,都在 source 中,
|
|
92
|
+
*/
|
|
93
|
+
function isObjectSubset(source, target) {
|
|
94
|
+
if (!target) return true;
|
|
95
|
+
for (const key in target) if (!isIncluded(source[key], target[key])) return false;
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
function isIncluded(source, target) {
|
|
99
|
+
if ((0, __pengzhanbo_utils.isArray)(source) && (0, __pengzhanbo_utils.isArray)(target)) {
|
|
100
|
+
const seen = /* @__PURE__ */ new Set();
|
|
101
|
+
return target.every((ti) => source.some((si, i) => {
|
|
102
|
+
if (seen.has(i)) return false;
|
|
103
|
+
const included = isIncluded(si, ti);
|
|
104
|
+
if (included) seen.add(i);
|
|
105
|
+
return included;
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
if ((0, __pengzhanbo_utils.isPlainObject)(source) && (0, __pengzhanbo_utils.isPlainObject)(target)) return isObjectSubset(source, target);
|
|
109
|
+
return Object.is(source, target);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/core/transform.ts
|
|
114
|
+
function transformRawData(rawData) {
|
|
115
|
+
return rawData.filter((item) => item[0]).map(([raw, __filepath__]) => {
|
|
116
|
+
let mockConfig;
|
|
117
|
+
if (raw.default) if (Array.isArray(raw.default)) mockConfig = raw.default.map((item) => ({
|
|
118
|
+
...item,
|
|
119
|
+
__filepath__
|
|
120
|
+
}));
|
|
121
|
+
else mockConfig = {
|
|
122
|
+
...raw.default,
|
|
123
|
+
__filepath__
|
|
124
|
+
};
|
|
125
|
+
else if ("url" in raw) mockConfig = {
|
|
126
|
+
...raw,
|
|
127
|
+
__filepath__
|
|
128
|
+
};
|
|
129
|
+
else {
|
|
130
|
+
mockConfig = [];
|
|
131
|
+
Object.keys(raw || {}).forEach((key) => {
|
|
132
|
+
if (Array.isArray(raw[key])) mockConfig.push(...raw[key].map((item) => ({
|
|
133
|
+
...item,
|
|
134
|
+
__filepath__
|
|
135
|
+
})));
|
|
136
|
+
else mockConfig.push({
|
|
137
|
+
...raw[key],
|
|
138
|
+
__filepath__
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
return mockConfig;
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
function transformMockData(mockList) {
|
|
146
|
+
const list = [];
|
|
147
|
+
for (const [, handle] of mockList.entries()) if (handle) list.push(...(0, __pengzhanbo_utils.toArray)(handle));
|
|
148
|
+
const mocks = {};
|
|
149
|
+
list.filter((mock) => (0, __pengzhanbo_utils.isPlainObject)(mock) && mock.enabled !== false && mock.url).forEach((mock) => {
|
|
150
|
+
const { pathname, query } = urlParse(mock.url);
|
|
151
|
+
const list$1 = mocks[pathname] ??= [];
|
|
152
|
+
const current = {
|
|
153
|
+
...mock,
|
|
154
|
+
url: pathname
|
|
155
|
+
};
|
|
156
|
+
if (current.ws !== true) {
|
|
157
|
+
const validator = current.validator;
|
|
158
|
+
if (!(0, __pengzhanbo_utils.isEmptyObject)(query)) if ((0, __pengzhanbo_utils.isFunction)(validator)) current.validator = function(request) {
|
|
159
|
+
return isObjectSubset(request.query, query) && validator(request);
|
|
160
|
+
};
|
|
161
|
+
else if (validator) {
|
|
162
|
+
current.validator = { ...validator };
|
|
163
|
+
current.validator.query = current.validator.query ? {
|
|
164
|
+
...query,
|
|
165
|
+
...current.validator.query
|
|
166
|
+
} : query;
|
|
167
|
+
} else current.validator = { query };
|
|
168
|
+
}
|
|
169
|
+
list$1.push(current);
|
|
170
|
+
});
|
|
171
|
+
Object.keys(mocks).forEach((key) => {
|
|
172
|
+
mocks[key] = sortByValidator(mocks[key]);
|
|
173
|
+
});
|
|
174
|
+
return mocks;
|
|
175
|
+
}
|
|
176
|
+
function sortByValidator(mocks) {
|
|
177
|
+
return (0, __pengzhanbo_utils.sortBy)(mocks, (item) => {
|
|
178
|
+
if (item.ws === true) return 0;
|
|
179
|
+
const { validator } = item;
|
|
180
|
+
if (!validator || (0, __pengzhanbo_utils.isEmptyObject)(validator)) return 2;
|
|
181
|
+
if ((0, __pengzhanbo_utils.isFunction)(validator)) return 0;
|
|
182
|
+
const count = Object.keys(validator).reduce((prev, key) => prev + keysCount(validator[key]), 0);
|
|
183
|
+
return 1 / count;
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
function keysCount(obj) {
|
|
187
|
+
if (!obj) return 0;
|
|
188
|
+
return Object.keys(obj).length;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region src/core/matchingWeight.ts
|
|
193
|
+
const tokensCache = {};
|
|
194
|
+
function getTokens(rule) {
|
|
195
|
+
if (tokensCache[rule]) return tokensCache[rule];
|
|
196
|
+
const tks = (0, path_to_regexp.parse)(rule);
|
|
197
|
+
const tokens = [];
|
|
198
|
+
for (const tk of tks) if (!(0, __pengzhanbo_utils.isString)(tk)) tokens.push(tk);
|
|
199
|
+
else {
|
|
200
|
+
const hasPrefix = tk[0] === "/";
|
|
201
|
+
const subTks = hasPrefix ? tk.slice(1).split("/") : tk.split("/");
|
|
202
|
+
tokens.push(`${hasPrefix ? "/" : ""}${subTks[0]}`, ...subTks.slice(1).map((t) => `/${t}`));
|
|
203
|
+
}
|
|
204
|
+
tokensCache[rule] = tokens;
|
|
205
|
+
return tokens;
|
|
206
|
+
}
|
|
207
|
+
function getHighest(rules) {
|
|
208
|
+
let weights = rules.map((rule) => getTokens(rule).length);
|
|
209
|
+
weights = weights.length === 0 ? [1] : weights;
|
|
210
|
+
return Math.max(...weights) + 2;
|
|
211
|
+
}
|
|
212
|
+
function sortFn(rule) {
|
|
213
|
+
const tokens = getTokens(rule);
|
|
214
|
+
let w = 0;
|
|
215
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
216
|
+
const token = tokens[i];
|
|
217
|
+
if (!(0, __pengzhanbo_utils.isString)(token)) w += 10 ** (i + 1);
|
|
218
|
+
w += 10 ** (i + 1);
|
|
219
|
+
}
|
|
220
|
+
return w;
|
|
221
|
+
}
|
|
222
|
+
function preSort(rules) {
|
|
223
|
+
let matched = [];
|
|
224
|
+
const preMatch = [];
|
|
225
|
+
for (const rule of rules) {
|
|
226
|
+
const tokens = getTokens(rule);
|
|
227
|
+
const len = tokens.filter((token) => typeof token !== "string").length;
|
|
228
|
+
if (!preMatch[len]) preMatch[len] = [];
|
|
229
|
+
preMatch[len].push(rule);
|
|
230
|
+
}
|
|
231
|
+
for (const match$1 of preMatch.filter((v) => v && v.length > 0)) matched = [...matched, ...(0, __pengzhanbo_utils.sortBy)(match$1, sortFn).reverse()];
|
|
232
|
+
return matched;
|
|
233
|
+
}
|
|
234
|
+
function defaultPriority(rules) {
|
|
235
|
+
const highest = getHighest(rules);
|
|
236
|
+
return (0, __pengzhanbo_utils.sortBy)(rules, (rule) => {
|
|
237
|
+
const tokens = getTokens(rule);
|
|
238
|
+
const dym = tokens.filter((token) => typeof token !== "string");
|
|
239
|
+
if (dym.length === 0) return 0;
|
|
240
|
+
let weight = dym.length;
|
|
241
|
+
let exp = 0;
|
|
242
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
243
|
+
const token = tokens[i];
|
|
244
|
+
const isDynamic = !(0, __pengzhanbo_utils.isString)(token);
|
|
245
|
+
const { pattern = "", modifier, prefix, name } = isDynamic ? token : {};
|
|
246
|
+
const isGlob = pattern && pattern.includes(".*");
|
|
247
|
+
const isSlash = prefix === "/";
|
|
248
|
+
const isNamed = (0, __pengzhanbo_utils.isString)(name);
|
|
249
|
+
exp += isDynamic && isSlash ? 1 : 0;
|
|
250
|
+
if (i === tokens.length - 1 && isGlob) weight += 5 * 10 ** (tokens.length === 1 ? highest + 1 : highest);
|
|
251
|
+
else if (isGlob) weight += 3 * 10 ** (highest - 1);
|
|
252
|
+
else if (pattern) if (isSlash) weight += (isNamed ? 2 : 1) * 10 ** (exp + 1);
|
|
253
|
+
else weight -= 1 * 10 ** exp;
|
|
254
|
+
if (modifier === "+") weight += 1 * 10 ** (highest - 1);
|
|
255
|
+
if (modifier === "*") weight += 1 * 10 ** (highest - 1) + 1;
|
|
256
|
+
if (modifier === "?") weight += 1 * 10 ** (exp + (isSlash ? 1 : 0));
|
|
257
|
+
}
|
|
258
|
+
return weight;
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
function matchingWeight(rules, url, priority) {
|
|
262
|
+
let matched = defaultPriority(preSort(rules.filter((rule) => (0, path_to_regexp.pathToRegexp)(rule).test(url))));
|
|
263
|
+
const { global = [], special = {} } = priority;
|
|
264
|
+
if (global.length === 0 && (0, __pengzhanbo_utils.isEmptyObject)(special) || matched.length === 0) return matched;
|
|
265
|
+
const [statics, dynamics] = twoPartMatch(matched);
|
|
266
|
+
const globalMatch = global.filter((rule) => dynamics.includes(rule));
|
|
267
|
+
if (globalMatch.length > 0) matched = (0, __pengzhanbo_utils.uniq)([
|
|
268
|
+
...statics,
|
|
269
|
+
...globalMatch,
|
|
270
|
+
...dynamics
|
|
271
|
+
]);
|
|
272
|
+
if ((0, __pengzhanbo_utils.isEmptyObject)(special)) return matched;
|
|
273
|
+
const specialRule = Object.keys(special).filter((rule) => matched.includes(rule))[0];
|
|
274
|
+
if (!specialRule) return matched;
|
|
275
|
+
const options = special[specialRule];
|
|
276
|
+
const { rules: lowerRules, when } = (0, __pengzhanbo_utils.isArray)(options) ? {
|
|
277
|
+
rules: options,
|
|
278
|
+
when: []
|
|
279
|
+
} : options;
|
|
280
|
+
if (lowerRules.includes(matched[0])) {
|
|
281
|
+
if (when.length === 0 || when.some((path$1) => (0, path_to_regexp.pathToRegexp)(path$1).test(url))) matched = (0, __pengzhanbo_utils.uniq)([specialRule, ...matched]);
|
|
282
|
+
}
|
|
283
|
+
return matched;
|
|
284
|
+
}
|
|
285
|
+
function twoPartMatch(rules) {
|
|
286
|
+
const statics = [];
|
|
287
|
+
const dynamics = [];
|
|
288
|
+
for (const rule of rules) {
|
|
289
|
+
const tokens = getTokens(rule);
|
|
290
|
+
const dym = tokens.filter((token) => typeof token !== "string");
|
|
291
|
+
if (dym.length > 0) dynamics.push(rule);
|
|
292
|
+
else statics.push(rule);
|
|
293
|
+
}
|
|
294
|
+
return [statics, dynamics];
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
//#endregion
|
|
298
|
+
//#region src/core/parseReqBody.ts
|
|
299
|
+
const DEFAULT_FORMIDABLE_OPTIONS = {
|
|
300
|
+
keepExtensions: true,
|
|
301
|
+
filename(name, ext, part) {
|
|
302
|
+
return part?.originalFilename || `${name}.${Date.now()}${ext ? `.${ext}` : ""}`;
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
async function parseReqBody(req, formidableOptions, bodyParserOptions = {}) {
|
|
306
|
+
const method = req.method.toUpperCase();
|
|
307
|
+
if ([
|
|
308
|
+
"GET",
|
|
309
|
+
"DELETE",
|
|
310
|
+
"HEAD"
|
|
311
|
+
].includes(method)) return void 0;
|
|
312
|
+
const type = req.headers["content-type"]?.toLocaleLowerCase() || "";
|
|
313
|
+
const { limit, formLimit, jsonLimit, textLimit,...rest } = bodyParserOptions;
|
|
314
|
+
try {
|
|
315
|
+
if (type.startsWith("application/json")) return await co_body.default.json(req, {
|
|
316
|
+
limit: jsonLimit || limit,
|
|
317
|
+
...rest
|
|
318
|
+
});
|
|
319
|
+
if (type.startsWith("application/x-www-form-urlencoded")) return await co_body.default.form(req, {
|
|
320
|
+
limit: formLimit || limit,
|
|
321
|
+
...rest
|
|
322
|
+
});
|
|
323
|
+
if (type.startsWith("text/plain")) return await co_body.default.text(req, {
|
|
324
|
+
limit: textLimit || limit,
|
|
325
|
+
...rest
|
|
326
|
+
});
|
|
327
|
+
if (type.startsWith("multipart/form-data")) return await parseMultipart(req, formidableOptions);
|
|
328
|
+
} catch (e) {
|
|
329
|
+
console.error(e);
|
|
330
|
+
}
|
|
331
|
+
return void 0;
|
|
332
|
+
}
|
|
333
|
+
async function parseMultipart(req, options) {
|
|
334
|
+
const form = (0, formidable.default)({
|
|
335
|
+
...DEFAULT_FORMIDABLE_OPTIONS,
|
|
336
|
+
...options
|
|
337
|
+
});
|
|
338
|
+
return new Promise((resolve, reject) => {
|
|
339
|
+
form.parse(req, (error, fields, files) => {
|
|
340
|
+
if (error) {
|
|
341
|
+
reject(error);
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
resolve({
|
|
345
|
+
...fields,
|
|
346
|
+
...files
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
//#endregion
|
|
353
|
+
//#region src/core/requestRecovery.ts
|
|
354
|
+
const requestCollectCache = /* @__PURE__ */ new WeakMap();
|
|
355
|
+
function collectRequest(req) {
|
|
356
|
+
const chunks = [];
|
|
357
|
+
req.addListener("data", (chunk) => {
|
|
358
|
+
chunks.push(node_buffer.Buffer.from(chunk));
|
|
359
|
+
});
|
|
360
|
+
req.addListener("end", () => {
|
|
361
|
+
if (chunks.length) requestCollectCache.set(req, node_buffer.Buffer.concat(chunks));
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
function rewriteRequest(proxyReq, req) {
|
|
365
|
+
const buffer = requestCollectCache.get(req);
|
|
366
|
+
if (buffer) {
|
|
367
|
+
requestCollectCache.delete(req);
|
|
368
|
+
if (!proxyReq.headersSent) proxyReq.setHeader("Content-Length", buffer.byteLength);
|
|
369
|
+
if (!proxyReq.writableEnded) proxyReq.write(buffer);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
//#endregion
|
|
374
|
+
//#region src/core/baseMiddleware.ts
|
|
375
|
+
function baseMiddleware(compiler, { formidableOptions = {}, bodyParserOptions = {}, proxies, cookiesOptions, logger, priority = {} }) {
|
|
376
|
+
return async function(req, res, next) {
|
|
377
|
+
const startTime = (0, __pengzhanbo_utils.timestamp)();
|
|
378
|
+
const { query, pathname } = urlParse(req.url);
|
|
379
|
+
if (!pathname || proxies.length === 0 || !proxies.some((context) => doesProxyContextMatchUrl(context, req.url, req))) return next();
|
|
380
|
+
const mockData = compiler.mockData;
|
|
381
|
+
const mockUrls = matchingWeight(Object.keys(mockData), pathname, priority);
|
|
382
|
+
if (mockUrls.length === 0) return next();
|
|
383
|
+
collectRequest(req);
|
|
384
|
+
const { query: refererQuery } = urlParse(req.headers.referer || "");
|
|
385
|
+
const reqBody = await parseReqBody(req, formidableOptions, bodyParserOptions);
|
|
386
|
+
const cookies$1 = new cookies.default(req, res, cookiesOptions);
|
|
387
|
+
const getCookie = cookies$1.get.bind(cookies$1);
|
|
388
|
+
const method = req.method.toUpperCase();
|
|
389
|
+
let mock;
|
|
390
|
+
let _mockUrl;
|
|
391
|
+
for (const mockUrl of mockUrls) {
|
|
392
|
+
mock = fineMock(mockData[mockUrl], logger, {
|
|
393
|
+
pathname,
|
|
394
|
+
method,
|
|
395
|
+
request: {
|
|
396
|
+
query,
|
|
397
|
+
refererQuery,
|
|
398
|
+
body: reqBody,
|
|
399
|
+
headers: req.headers,
|
|
400
|
+
getCookie
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
if (mock) {
|
|
404
|
+
_mockUrl = mockUrl;
|
|
405
|
+
break;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
if (!mock) {
|
|
409
|
+
const matched = mockUrls.map((m) => m === _mockUrl ? picocolors.default.underline(picocolors.default.bold(m)) : picocolors.default.dim(m)).join(", ");
|
|
410
|
+
logger.warn(`${picocolors.default.green(pathname)} matches ${matched} , but mock data is not found.`);
|
|
411
|
+
return next();
|
|
412
|
+
}
|
|
413
|
+
const request = req;
|
|
414
|
+
const response = res;
|
|
415
|
+
request.body = reqBody;
|
|
416
|
+
request.query = query;
|
|
417
|
+
request.refererQuery = refererQuery;
|
|
418
|
+
request.params = parseParams(mock.url, pathname);
|
|
419
|
+
request.getCookie = getCookie;
|
|
420
|
+
response.setCookie = cookies$1.set.bind(cookies$1);
|
|
421
|
+
const { body, delay, type = "json", response: responseFn, status = 200, statusText, log: logLevel, __filepath__: filepath } = mock;
|
|
422
|
+
responseStatus(response, status, statusText);
|
|
423
|
+
await provideHeaders(request, response, mock, logger);
|
|
424
|
+
await provideCookies(request, response, mock, logger);
|
|
425
|
+
logger.info(requestLog(request, filepath), logLevel);
|
|
426
|
+
logger.debug(`${picocolors.default.magenta("DEBUG")} ${picocolors.default.underline(pathname)} matches: [ ${mockUrls.map((m) => m === _mockUrl ? picocolors.default.underline(picocolors.default.bold(m)) : picocolors.default.dim(m)).join(", ")} ]\n`);
|
|
427
|
+
if (body) {
|
|
428
|
+
try {
|
|
429
|
+
const content = (0, __pengzhanbo_utils.isFunction)(body) ? await body(request) : body;
|
|
430
|
+
await realDelay(startTime, delay);
|
|
431
|
+
sendData(response, content, type);
|
|
432
|
+
} catch (e) {
|
|
433
|
+
logger.error(`${picocolors.default.red(`mock error at ${pathname}`)}\n${e}\n at body (${picocolors.default.underline(filepath)})`, logLevel);
|
|
434
|
+
responseStatus(response, 500);
|
|
435
|
+
res.end("");
|
|
436
|
+
}
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
if (responseFn) {
|
|
440
|
+
try {
|
|
441
|
+
await realDelay(startTime, delay);
|
|
442
|
+
await responseFn(request, response, next);
|
|
443
|
+
} catch (e) {
|
|
444
|
+
logger.error(`${picocolors.default.red(`mock error at ${pathname}`)}\n${e}\n at response (${picocolors.default.underline(filepath)})`, logLevel);
|
|
445
|
+
responseStatus(response, 500);
|
|
446
|
+
res.end("");
|
|
447
|
+
}
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
res.end("");
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
function fineMock(mockList, logger, { pathname, method, request }) {
|
|
454
|
+
return mockList.find((mock) => {
|
|
455
|
+
if (!pathname || !mock || !mock.url || mock.ws === true) return false;
|
|
456
|
+
const methods = mock.method ? (0, __pengzhanbo_utils.isArray)(mock.method) ? mock.method : [mock.method] : ["GET", "POST"];
|
|
457
|
+
if (!methods.includes(method)) return false;
|
|
458
|
+
const hasMock = (0, path_to_regexp.pathToRegexp)(mock.url).test(pathname);
|
|
459
|
+
if (hasMock && mock.validator) {
|
|
460
|
+
const params = parseParams(mock.url, pathname);
|
|
461
|
+
if ((0, __pengzhanbo_utils.isFunction)(mock.validator)) return mock.validator({
|
|
462
|
+
params,
|
|
463
|
+
...request
|
|
464
|
+
});
|
|
465
|
+
else try {
|
|
466
|
+
return validate({
|
|
467
|
+
params,
|
|
468
|
+
...request
|
|
469
|
+
}, mock.validator);
|
|
470
|
+
} catch (e) {
|
|
471
|
+
const file = mock.__filepath__;
|
|
472
|
+
logger.error(`${picocolors.default.red(`mock error at ${pathname}`)}\n${e}\n at validator (${picocolors.default.underline(file)})`, mock.log);
|
|
473
|
+
return false;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
return hasMock;
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
function responseStatus(response, status = 200, statusText) {
|
|
480
|
+
response.statusCode = status;
|
|
481
|
+
response.statusMessage = statusText || getHTTPStatusText(status);
|
|
482
|
+
}
|
|
483
|
+
async function provideHeaders(req, res, mock, logger) {
|
|
484
|
+
const { headers, type = "json" } = mock;
|
|
485
|
+
const filepath = mock.__filepath__;
|
|
486
|
+
const contentType = mime_types.contentType(type) || mime_types.contentType(mime_types.lookup(type) || "");
|
|
487
|
+
if (contentType) res.setHeader("Content-Type", contentType);
|
|
488
|
+
res.setHeader("Cache-Control", "no-cache,max-age=0");
|
|
489
|
+
res.setHeader("X-Mock-Power-By", "vite-plugin-mock-dev-server");
|
|
490
|
+
if (filepath) res.setHeader("X-File-Path", filepath);
|
|
491
|
+
if (!headers) return;
|
|
492
|
+
try {
|
|
493
|
+
const raw = (0, __pengzhanbo_utils.isFunction)(headers) ? await headers(req) : headers;
|
|
494
|
+
Object.keys(raw).forEach((key) => {
|
|
495
|
+
res.setHeader(key, raw[key]);
|
|
496
|
+
});
|
|
497
|
+
} catch (e) {
|
|
498
|
+
logger.error(`${picocolors.default.red(`mock error at ${req.url.split("?")[0]}`)}\n${e}\n at headers (${picocolors.default.underline(filepath)})`, mock.log);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
async function provideCookies(req, res, mock, logger) {
|
|
502
|
+
const { cookies: cookies$1 } = mock;
|
|
503
|
+
const filepath = mock.__filepath__;
|
|
504
|
+
if (!cookies$1) return;
|
|
505
|
+
try {
|
|
506
|
+
const raw = (0, __pengzhanbo_utils.isFunction)(cookies$1) ? await cookies$1(req) : cookies$1;
|
|
507
|
+
Object.keys(raw).forEach((key) => {
|
|
508
|
+
const cookie = raw[key];
|
|
509
|
+
if ((0, __pengzhanbo_utils.isArray)(cookie)) {
|
|
510
|
+
const [value, options] = cookie;
|
|
511
|
+
res.setCookie(key, value, options);
|
|
512
|
+
} else res.setCookie(key, cookie);
|
|
513
|
+
});
|
|
514
|
+
} catch (e) {
|
|
515
|
+
logger.error(`${picocolors.default.red(`mock error at ${req.url.split("?")[0]}`)}\n${e}\n at cookies (${picocolors.default.underline(filepath)})`, mock.log);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
function sendData(res, raw, type) {
|
|
519
|
+
if (isReadableStream(raw)) raw.pipe(res);
|
|
520
|
+
else if (node_buffer.Buffer.isBuffer(raw)) res.end(type === "text" || type === "json" ? raw.toString("utf-8") : raw);
|
|
521
|
+
else {
|
|
522
|
+
const content = typeof raw === "string" ? raw : JSON.stringify(raw);
|
|
523
|
+
res.end(type === "buffer" ? node_buffer.Buffer.from(content) : content);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
async function realDelay(startTime, delay) {
|
|
527
|
+
if (!delay || typeof delay === "number" && delay <= 0 || (0, __pengzhanbo_utils.isArray)(delay) && delay.length !== 2) return;
|
|
528
|
+
let realDelay$1 = 0;
|
|
529
|
+
if ((0, __pengzhanbo_utils.isArray)(delay)) {
|
|
530
|
+
const [min, max] = delay;
|
|
531
|
+
realDelay$1 = (0, __pengzhanbo_utils.random)(min, max);
|
|
532
|
+
} else realDelay$1 = delay - ((0, __pengzhanbo_utils.timestamp)() - startTime);
|
|
533
|
+
if (realDelay$1 > 0) await (0, __pengzhanbo_utils.sleep)(realDelay$1);
|
|
534
|
+
}
|
|
535
|
+
function getHTTPStatusText(status) {
|
|
536
|
+
return http_status.default[status] || "Unknown";
|
|
537
|
+
}
|
|
538
|
+
function requestLog(request, filepath) {
|
|
539
|
+
const { url, method, query, params, body } = request;
|
|
540
|
+
let { pathname } = new URL(url, "http://example.com");
|
|
541
|
+
pathname = picocolors.default.green(decodeURIComponent(pathname));
|
|
542
|
+
const format = (prefix, data) => {
|
|
543
|
+
return !data || (0, __pengzhanbo_utils.isEmptyObject)(data) ? "" : ` ${picocolors.default.gray(`${prefix}:`)}${JSON.stringify(data)}`;
|
|
544
|
+
};
|
|
545
|
+
const ms = picocolors.default.magenta(picocolors.default.bold(method));
|
|
546
|
+
const qs = format("query", query);
|
|
547
|
+
const ps = format("params", params);
|
|
548
|
+
const bs = format("body", body);
|
|
549
|
+
const file = ` ${picocolors.default.dim(picocolors.default.underline(`(${filepath})`))}`;
|
|
550
|
+
return `${ms} ${pathname}${qs}${ps}${bs}${file}`;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
//#endregion
|
|
554
|
+
//#region src/core/mockWebsocket.ts
|
|
555
|
+
function mockWebSocket(compiler, httpServer, { wsProxies: proxies, cookiesOptions, logger }) {
|
|
556
|
+
const hmrMap = /* @__PURE__ */ new Map();
|
|
557
|
+
const poolMap = /* @__PURE__ */ new Map();
|
|
558
|
+
const wssContextMap = /* @__PURE__ */ new WeakMap();
|
|
559
|
+
const getWssMap = (mockUrl) => {
|
|
560
|
+
let wssMap = poolMap.get(mockUrl);
|
|
561
|
+
if (!wssMap) poolMap.set(mockUrl, wssMap = /* @__PURE__ */ new Map());
|
|
562
|
+
return wssMap;
|
|
563
|
+
};
|
|
564
|
+
const addHmr = (filepath, mockUrl) => {
|
|
565
|
+
let urlList = hmrMap.get(filepath);
|
|
566
|
+
if (!urlList) hmrMap.set(filepath, urlList = /* @__PURE__ */ new Set());
|
|
567
|
+
urlList.add(mockUrl);
|
|
568
|
+
};
|
|
569
|
+
const setupWss = (wssMap, wss, mock, context, pathname, filepath) => {
|
|
570
|
+
try {
|
|
571
|
+
mock.setup?.(wss, context);
|
|
572
|
+
wss.on("close", () => wssMap.delete(pathname));
|
|
573
|
+
wss.on("error", (e) => {
|
|
574
|
+
logger.error(`${picocolors.default.red(`WebSocket mock error at ${wss.path}`)}\n${e}\n at setup (${filepath})`, mock.log);
|
|
575
|
+
});
|
|
576
|
+
} catch (e) {
|
|
577
|
+
logger.error(`${picocolors.default.red(`WebSocket mock error at ${wss.path}`)}\n${e}\n at setup (${filepath})`, mock.log);
|
|
578
|
+
}
|
|
579
|
+
};
|
|
580
|
+
const restartWss = (wssMap, wss, mock, pathname, filepath) => {
|
|
581
|
+
const { cleanupList, connectionList, context } = wssContextMap.get(wss);
|
|
582
|
+
cleanupRunner(cleanupList);
|
|
583
|
+
connectionList.forEach(({ ws: ws$1 }) => ws$1.removeAllListeners());
|
|
584
|
+
wss.removeAllListeners();
|
|
585
|
+
setupWss(wssMap, wss, mock, context, pathname, filepath);
|
|
586
|
+
connectionList.forEach(({ ws: ws$1, req }) => emitConnection(wss, ws$1, req, connectionList));
|
|
587
|
+
};
|
|
588
|
+
compiler.on("update", ({ filepath }) => {
|
|
589
|
+
if (!hmrMap.has(filepath)) return;
|
|
590
|
+
const mockUrlList = hmrMap.get(filepath);
|
|
591
|
+
if (!mockUrlList) return;
|
|
592
|
+
for (const mockUrl of mockUrlList.values()) for (const mock of compiler.mockData[mockUrl]) {
|
|
593
|
+
if (!mock.ws || mock.__filepath__ !== filepath) return;
|
|
594
|
+
const wssMap = getWssMap(mockUrl);
|
|
595
|
+
for (const [pathname, wss] of wssMap.entries()) restartWss(wssMap, wss, mock, pathname, filepath);
|
|
596
|
+
}
|
|
597
|
+
});
|
|
598
|
+
httpServer?.on("upgrade", (req, socket, head) => {
|
|
599
|
+
const { pathname, query } = urlParse(req.url);
|
|
600
|
+
if (!pathname || proxies.length === 0 || !proxies.some((context) => doesProxyContextMatchUrl(context, req.url, req))) return;
|
|
601
|
+
const mockData = compiler.mockData;
|
|
602
|
+
const mockUrl = Object.keys(mockData).find((key) => {
|
|
603
|
+
return (0, path_to_regexp.pathToRegexp)(key).test(pathname);
|
|
604
|
+
});
|
|
605
|
+
if (!mockUrl) return;
|
|
606
|
+
const mock = mockData[mockUrl].find((mock$1) => {
|
|
607
|
+
return mock$1.url && mock$1.ws && (0, path_to_regexp.pathToRegexp)(mock$1.url).test(pathname);
|
|
608
|
+
});
|
|
609
|
+
if (!mock) return;
|
|
610
|
+
const filepath = mock.__filepath__;
|
|
611
|
+
addHmr(filepath, mockUrl);
|
|
612
|
+
const wssMap = getWssMap(mockUrl);
|
|
613
|
+
const wss = getWss(wssMap, pathname);
|
|
614
|
+
let wssContext = wssContextMap.get(wss);
|
|
615
|
+
if (!wssContext) {
|
|
616
|
+
const cleanupList = [];
|
|
617
|
+
const context = { onCleanup: (cleanup) => cleanupList.push(cleanup) };
|
|
618
|
+
wssContext = {
|
|
619
|
+
cleanupList,
|
|
620
|
+
context,
|
|
621
|
+
connectionList: []
|
|
622
|
+
};
|
|
623
|
+
wssContextMap.set(wss, wssContext);
|
|
624
|
+
setupWss(wssMap, wss, mock, context, pathname, filepath);
|
|
625
|
+
}
|
|
626
|
+
const request = req;
|
|
627
|
+
const cookies$1 = new cookies.default(req, req, cookiesOptions);
|
|
628
|
+
const { query: refererQuery } = urlParse(req.headers.referer || "");
|
|
629
|
+
request.query = query;
|
|
630
|
+
request.refererQuery = refererQuery;
|
|
631
|
+
request.params = parseParams(mockUrl, pathname);
|
|
632
|
+
request.getCookie = cookies$1.get.bind(cookies$1);
|
|
633
|
+
wss.handleUpgrade(request, socket, head, (ws$1) => {
|
|
634
|
+
logger.info(`${picocolors.default.magenta(picocolors.default.bold("WebSocket"))} ${picocolors.default.green(req.url)} connected ${picocolors.default.dim(`(${filepath})`)}`, mock.log);
|
|
635
|
+
wssContext.connectionList.push({
|
|
636
|
+
req: request,
|
|
637
|
+
ws: ws$1
|
|
638
|
+
});
|
|
639
|
+
emitConnection(wss, ws$1, request, wssContext.connectionList);
|
|
640
|
+
});
|
|
641
|
+
});
|
|
642
|
+
httpServer?.on("close", () => {
|
|
643
|
+
for (const wssMap of poolMap.values()) {
|
|
644
|
+
for (const wss of wssMap.values()) {
|
|
645
|
+
const wssContext = wssContextMap.get(wss);
|
|
646
|
+
cleanupRunner(wssContext.cleanupList);
|
|
647
|
+
wss.close();
|
|
648
|
+
}
|
|
649
|
+
wssMap.clear();
|
|
650
|
+
}
|
|
651
|
+
poolMap.clear();
|
|
652
|
+
hmrMap.clear();
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
function getWss(wssMap, pathname) {
|
|
656
|
+
let wss = wssMap.get(pathname);
|
|
657
|
+
if (!wss) wssMap.set(pathname, wss = new ws.WebSocketServer({ noServer: true }));
|
|
658
|
+
return wss;
|
|
659
|
+
}
|
|
660
|
+
function emitConnection(wss, ws$1, req, connectionList) {
|
|
661
|
+
wss.emit("connection", ws$1, req);
|
|
662
|
+
ws$1.on("close", () => {
|
|
663
|
+
const i = connectionList.findIndex((item) => item.ws === ws$1);
|
|
664
|
+
if (i !== -1) connectionList.splice(i, 1);
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
function cleanupRunner(cleanupList) {
|
|
668
|
+
let cleanup;
|
|
669
|
+
while (cleanup = cleanupList.shift()) cleanup?.();
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
//#endregion
|
|
673
|
+
//#region src/core/logger.ts
|
|
674
|
+
const logLevels = {
|
|
675
|
+
silent: 0,
|
|
676
|
+
error: 1,
|
|
677
|
+
warn: 2,
|
|
678
|
+
info: 3,
|
|
679
|
+
debug: 4
|
|
680
|
+
};
|
|
681
|
+
function createLogger(prefix, defaultLevel = "info") {
|
|
682
|
+
prefix = `[${prefix}]`;
|
|
683
|
+
function output(type, msg, level) {
|
|
684
|
+
level = (0, __pengzhanbo_utils.isBoolean)(level) ? level ? defaultLevel : "error" : level;
|
|
685
|
+
const thresh = logLevels[level];
|
|
686
|
+
if (thresh >= logLevels[type]) {
|
|
687
|
+
const method = type === "info" || type === "debug" ? "log" : type;
|
|
688
|
+
const tag = type === "debug" ? picocolors.default.magenta(picocolors.default.bold(prefix)) : type === "info" ? picocolors.default.cyan(picocolors.default.bold(prefix)) : type === "warn" ? picocolors.default.yellow(picocolors.default.bold(prefix)) : picocolors.default.red(picocolors.default.bold(prefix));
|
|
689
|
+
const format = `${picocolors.default.dim((/* @__PURE__ */ new Date()).toLocaleTimeString())} ${tag} ${msg}`;
|
|
690
|
+
console[method](format);
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
const logger = {
|
|
694
|
+
debug(msg, level = defaultLevel) {
|
|
695
|
+
output("debug", msg, level);
|
|
696
|
+
},
|
|
697
|
+
info(msg, level = defaultLevel) {
|
|
698
|
+
output("info", msg, level);
|
|
699
|
+
},
|
|
700
|
+
warn(msg, level = defaultLevel) {
|
|
701
|
+
output("warn", msg, level);
|
|
702
|
+
},
|
|
703
|
+
error(msg, level = defaultLevel) {
|
|
704
|
+
output("error", msg, level);
|
|
705
|
+
}
|
|
706
|
+
};
|
|
707
|
+
return logger;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
//#endregion
|
|
711
|
+
Object.defineProperty(exports, 'baseMiddleware', {
|
|
712
|
+
enumerable: true,
|
|
713
|
+
get: function () {
|
|
714
|
+
return baseMiddleware;
|
|
715
|
+
}
|
|
716
|
+
});
|
|
717
|
+
Object.defineProperty(exports, 'createLogger', {
|
|
718
|
+
enumerable: true,
|
|
719
|
+
get: function () {
|
|
720
|
+
return createLogger;
|
|
721
|
+
}
|
|
722
|
+
});
|
|
723
|
+
Object.defineProperty(exports, 'doesProxyContextMatchUrl', {
|
|
724
|
+
enumerable: true,
|
|
725
|
+
get: function () {
|
|
726
|
+
return doesProxyContextMatchUrl;
|
|
727
|
+
}
|
|
728
|
+
});
|
|
729
|
+
Object.defineProperty(exports, 'logLevels', {
|
|
730
|
+
enumerable: true,
|
|
731
|
+
get: function () {
|
|
732
|
+
return logLevels;
|
|
733
|
+
}
|
|
734
|
+
});
|
|
735
|
+
Object.defineProperty(exports, 'lookupFile', {
|
|
736
|
+
enumerable: true,
|
|
737
|
+
get: function () {
|
|
738
|
+
return lookupFile;
|
|
739
|
+
}
|
|
740
|
+
});
|
|
741
|
+
Object.defineProperty(exports, 'mockWebSocket', {
|
|
742
|
+
enumerable: true,
|
|
743
|
+
get: function () {
|
|
744
|
+
return mockWebSocket;
|
|
745
|
+
}
|
|
746
|
+
});
|
|
747
|
+
Object.defineProperty(exports, 'normalizePath', {
|
|
748
|
+
enumerable: true,
|
|
749
|
+
get: function () {
|
|
750
|
+
return normalizePath;
|
|
751
|
+
}
|
|
752
|
+
});
|
|
753
|
+
Object.defineProperty(exports, 'packageDir', {
|
|
754
|
+
enumerable: true,
|
|
755
|
+
get: function () {
|
|
756
|
+
return packageDir;
|
|
757
|
+
}
|
|
758
|
+
});
|
|
759
|
+
Object.defineProperty(exports, 'rewriteRequest', {
|
|
760
|
+
enumerable: true,
|
|
761
|
+
get: function () {
|
|
762
|
+
return rewriteRequest;
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
Object.defineProperty(exports, 'sortByValidator', {
|
|
766
|
+
enumerable: true,
|
|
767
|
+
get: function () {
|
|
768
|
+
return sortByValidator;
|
|
769
|
+
}
|
|
770
|
+
});
|
|
771
|
+
Object.defineProperty(exports, 'transformMockData', {
|
|
772
|
+
enumerable: true,
|
|
773
|
+
get: function () {
|
|
774
|
+
return transformMockData;
|
|
775
|
+
}
|
|
776
|
+
});
|
|
777
|
+
Object.defineProperty(exports, 'transformRawData', {
|
|
778
|
+
enumerable: true,
|
|
779
|
+
get: function () {
|
|
780
|
+
return transformRawData;
|
|
781
|
+
}
|
|
782
|
+
});
|
|
783
|
+
Object.defineProperty(exports, 'urlParse', {
|
|
784
|
+
enumerable: true,
|
|
785
|
+
get: function () {
|
|
786
|
+
return urlParse;
|
|
787
|
+
}
|
|
788
|
+
});
|
|
789
|
+
Object.defineProperty(exports, 'vfs', {
|
|
790
|
+
enumerable: true,
|
|
791
|
+
get: function () {
|
|
792
|
+
return vfs;
|
|
793
|
+
}
|
|
794
|
+
});
|
|
795
|
+
Object.defineProperty(exports, 'waitingFor', {
|
|
796
|
+
enumerable: true,
|
|
797
|
+
get: function () {
|
|
798
|
+
return waitingFor;
|
|
799
|
+
}
|
|
800
|
+
});
|